Merge pull request #1340 from hgiesel/exportinternal
Export Svelte internals
This commit is contained in:
commit
1dd3583b43
@ -50,6 +50,7 @@ ts_library(
|
|||||||
"lib",
|
"lib",
|
||||||
"//ts/components",
|
"//ts/components",
|
||||||
"//ts/lib",
|
"//ts/lib",
|
||||||
|
"//ts/sveltelib",
|
||||||
"@npm//@popperjs",
|
"@npm//@popperjs",
|
||||||
"@npm//svelte2tsx",
|
"@npm//svelte2tsx",
|
||||||
],
|
],
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
@typescript-eslint/no-explicit-any: "off",
|
@typescript-eslint/no-explicit-any: "off",
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import "sveltelib/export-runtime";
|
||||||
|
|
||||||
import { getDeckOptionsInfo, DeckOptionsState } from "./lib";
|
import { getDeckOptionsInfo, DeckOptionsState } from "./lib";
|
||||||
import { setupI18n, ModuleName } from "lib/i18n";
|
import { setupI18n, ModuleName } from "lib/i18n";
|
||||||
import { checkNightMode } from "lib/nightmode";
|
import { checkNightMode } from "lib/nightmode";
|
||||||
|
@ -5,6 +5,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||||||
<script context="module" lang="typescript">
|
<script context="module" lang="typescript">
|
||||||
import IconButton from "components/IconButton.svelte";
|
import IconButton from "components/IconButton.svelte";
|
||||||
import LabelButton from "components/LabelButton.svelte";
|
import LabelButton from "components/LabelButton.svelte";
|
||||||
|
import WithShortcut from "components/WithShortcut.svelte";
|
||||||
import WithContext from "components/WithContext.svelte";
|
import WithContext from "components/WithContext.svelte";
|
||||||
import WithState from "components/WithState.svelte";
|
import WithState from "components/WithState.svelte";
|
||||||
|
|
||||||
@ -14,6 +15,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||||||
export const components = {
|
export const components = {
|
||||||
IconButton,
|
IconButton,
|
||||||
LabelButton,
|
LabelButton,
|
||||||
|
WithShortcut,
|
||||||
WithContext,
|
WithContext,
|
||||||
WithState,
|
WithState,
|
||||||
contextKeys: { ...contextKeys, ...editorContextKeys },
|
contextKeys: { ...contextKeys, ...editorContextKeys },
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
@typescript-eslint/no-explicit-any: "off",
|
@typescript-eslint/no-explicit-any: "off",
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import "sveltelib/export-runtime";
|
||||||
|
|
||||||
import { filterHTML } from "html-filter";
|
import { filterHTML } from "html-filter";
|
||||||
import { updateActiveButtons } from "./toolbar";
|
import { updateActiveButtons } from "./toolbar";
|
||||||
import { setupI18n, ModuleName } from "lib/i18n";
|
import { setupI18n, ModuleName } from "lib/i18n";
|
||||||
|
19
ts/lib/runtime-require.ts
Normal file
19
ts/lib/runtime-require.ts
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
// Copyright: Ankitects Pty Ltd and contributors
|
||||||
|
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
|
/* eslint
|
||||||
|
@typescript-eslint/no-explicit-any: "off",
|
||||||
|
*/
|
||||||
|
|
||||||
|
/// This can be extended to allow require() calls at runtime, for libraries
|
||||||
|
/// that are not included at bundling time.
|
||||||
|
export const runtimeLibraries = {};
|
||||||
|
|
||||||
|
// Export require() as a global.
|
||||||
|
(globalThis as any).require = function (name: string): unknown {
|
||||||
|
const lib = runtimeLibraries[name];
|
||||||
|
if (lib === undefined) {
|
||||||
|
throw new Error(`Cannot require(${name}) at runtime.`);
|
||||||
|
}
|
||||||
|
return lib;
|
||||||
|
};
|
@ -13,6 +13,7 @@ ts_library(
|
|||||||
tsconfig = "//:tsconfig.json",
|
tsconfig = "//:tsconfig.json",
|
||||||
visibility = ["//visibility:public"],
|
visibility = ["//visibility:public"],
|
||||||
deps = [
|
deps = [
|
||||||
|
"//ts/lib",
|
||||||
"@npm//svelte",
|
"@npm//svelte",
|
||||||
"@npm//tslib",
|
"@npm//tslib",
|
||||||
],
|
],
|
||||||
|
11
ts/sveltelib/export-runtime.ts
Normal file
11
ts/sveltelib/export-runtime.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
// Copyright: Ankitects Pty Ltd and contributors
|
||||||
|
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
//
|
||||||
|
// Expose the Svelte runtime bundled with Anki, so that add-ons can require() it.
|
||||||
|
// If they were to bundle their own runtime, things like bindings and contexts
|
||||||
|
// would not work.
|
||||||
|
|
||||||
|
import { runtimeLibraries } from "lib/runtime-require";
|
||||||
|
import * as svelteRuntime from "svelte/internal";
|
||||||
|
|
||||||
|
runtimeLibraries["svelte/internal"] = svelteRuntime;
|
@ -4215,9 +4215,9 @@ svelte2tsx@^0.1.133:
|
|||||||
pascal-case "^3.1.1"
|
pascal-case "^3.1.1"
|
||||||
|
|
||||||
svelte@^3.25.0:
|
svelte@^3.25.0:
|
||||||
version "3.38.2"
|
version "3.42.2"
|
||||||
resolved "https://registry.yarnpkg.com/svelte/-/svelte-3.38.2.tgz#55e5c681f793ae349b5cc2fe58e5782af4275ef5"
|
resolved "https://registry.yarnpkg.com/svelte/-/svelte-3.42.2.tgz#0246c175c820c1aeca07300c48573a15aae3c1e4"
|
||||||
integrity sha512-q5Dq0/QHh4BLJyEVWGe7Cej5NWs040LWjMbicBGZ+3qpFWJ1YObRmUDZKbbovddLC9WW7THTj3kYbTOFmU9fbg==
|
integrity sha512-FOyNYKXb8wdE0Ot+Ctt2/OyDLsNBP8+V6PUE9ag6ZKeLslIou0LnMu1fhtWUA+HjzKTbAM1yj+4PFLtg/3pMJA==
|
||||||
|
|
||||||
symbol-tree@^3.2.4:
|
symbol-tree@^3.2.4:
|
||||||
version "3.2.4"
|
version "3.2.4"
|
||||||
|
Loading…
Reference in New Issue
Block a user