@panomc/sdk 2.0.0-dev.61 → 2.0.0-dev.62

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@panomc/sdk",
3
- "version": "2.0.0-dev.61",
3
+ "version": "2.0.0-dev.62",
4
4
  "sdkLine": "2.0.0",
5
5
  "author": "PanoMC",
6
6
  "repository": {
@@ -79,6 +79,10 @@
79
79
  "svelte": "./src/controllers.js",
80
80
  "default": "./src/controllers.js"
81
81
  },
82
+ "./runtime-specifiers": {
83
+ "svelte": "./src/runtime-specifiers.js",
84
+ "default": "./src/runtime-specifiers.js"
85
+ },
82
86
  "./build/*": "./build/*",
83
87
  "./core/*": {
84
88
  "svelte": "./core/*",
@@ -101,5 +105,13 @@
101
105
  },
102
106
  "scripts": {},
103
107
  "svelte": "./src/index.js",
104
- "type": "module"
108
+ "type": "module",
109
+ "peerDependencies": {
110
+ "@sveltejs/kit": "^2.0.0"
111
+ },
112
+ "peerDependenciesMeta": {
113
+ "@sveltejs/kit": {
114
+ "optional": true
115
+ }
116
+ }
105
117
  }
@@ -0,0 +1,88 @@
1
+ /**
2
+ * THE single source of truth for the plugin runtime module surface (owned by @panomc/sdk: the theme engine, the plugin
3
+ * kit and the widget host all depend on the sdk, so none of them has to depend on another to read this table).
4
+ *
5
+ * Every bare specifier a plugin build may import is listed here, mapped to the
6
+ * stable shim file the theme serves under /runtime/. This list drives:
7
+ * - bin/generate-runtime-shims.js (emits static/runtime/<shimFile> per entry)
8
+ * - createThemeHooks() (the <script type="importmap"> in every page)
9
+ * - the runtime registry in kit/hooks-client.js (which must keep literal
10
+ * import() calls for bundler static analysis — its keys are asserted
11
+ * against this list in dev so the two can never drift)
12
+ *
13
+ * FROZEN CONTRACT: shipped plugin client builds resolve these exact names via
14
+ * the import map forever. Never rename or remove an entry; additions are a
15
+ * core minor version.
16
+ */
17
+ export const RUNTIME_SPECIFIERS = {
18
+ "svelte": "svelte/index.js",
19
+ "svelte/animate": "svelte/animate.js",
20
+ "svelte/easing": "svelte/easing.js",
21
+ "svelte/motion": "svelte/motion.js",
22
+ "svelte/store": "svelte/store.js",
23
+ "svelte/transition": "svelte/transition.js",
24
+ "svelte/internal": "svelte/internal.js",
25
+ "svelte/internal/client": "svelte/internal-client.js",
26
+ "svelte/internal/disclose-version": "svelte/internal-disclose-version.js",
27
+ "svelte/internal/flags/legacy": "svelte/internal-flags-legacy.js",
28
+ "svelte/internal/flags/async": "svelte/internal-flags-async.js",
29
+ "svelte/internal/flags/tracing": "svelte/internal-flags-tracing.js",
30
+ "svelte/legacy": "svelte/legacy.js",
31
+ "svelte/events": "svelte/events.js",
32
+ "svelte/attachments": "svelte/attachments.js",
33
+ "svelte/reactivity": "svelte/reactivity.js",
34
+ "svelte/reactivity/window": "svelte/reactivity-window.js",
35
+ "svelte-i18n": "svelte/i18n.js",
36
+ "@panomc/sdk": "sdk/index.js",
37
+ "@panomc/sdk/components/theme": "sdk/components-theme.js",
38
+ "@panomc/sdk/components/panel": "sdk/components-panel.js",
39
+ "@panomc/sdk/toasts": "sdk/toasts.js",
40
+ "@panomc/sdk/utils/api": "sdk/utils-api.js",
41
+ "@panomc/sdk/utils/auth": "sdk/utils-auth.js",
42
+ "@panomc/sdk/utils/tooltip": "sdk/utils-tooltip.js",
43
+ "@panomc/sdk/utils/language": "sdk/utils-language.js",
44
+ "@panomc/sdk/utils/component": "sdk/utils-component.js",
45
+ "@panomc/sdk/utils/text": "sdk/utils-text.js",
46
+ "@panomc/sdk/variables": "sdk/variables.js",
47
+ "@panomc/sdk/svelte": "sdk/svelte.js",
48
+ "@panomc/sdk/internal": "sdk/internal.js",
49
+ "@panomc/sdk/views": "sdk/views.js",
50
+ "@panomc/sdk/controllers": "sdk/controllers.js",
51
+ "@panomc/sdk/utils/route": "sdk/utils-route.js",
52
+ };
53
+
54
+ /** Entries whose shim re-exports come from the svelte/svelte-i18n packages. */
55
+ export const SVELTE_SPECIFIERS = Object.fromEntries(
56
+ Object.entries(RUNTIME_SPECIFIERS).filter(([, file]) =>
57
+ file.startsWith("svelte/"),
58
+ ),
59
+ );
60
+
61
+ /** Entries whose shim re-exports come from @panomc/sdk. */
62
+ export const SDK_SPECIFIERS = Object.fromEntries(
63
+ Object.entries(RUNTIME_SPECIFIERS).filter(([, file]) =>
64
+ file.startsWith("sdk/"),
65
+ ),
66
+ );
67
+
68
+ /** Specifier -> file of the widget runtime directory (`dist/runtime/` of @panomc/widget-host), for every `svelte*` name and every `@panomc/sdk` facade. */
69
+ export const RUNTIME_FILES = Object.freeze(
70
+ Object.fromEntries(
71
+ Object.entries(RUNTIME_SPECIFIERS).map(([specifier, file]) => {
72
+ if (specifier === "svelte-i18n") return [specifier, "svelte-i18n.js"];
73
+ if (file.startsWith("sdk/")) return [specifier, `host/${file.slice("sdk/".length)}`];
74
+ return [specifier, file];
75
+ }),
76
+ ),
77
+ );
78
+
79
+ /**
80
+ * Relative URL of a runtime file seen from a widget module that sits in `.../_/ui/widgets/` of a plugin
81
+ * (`/api/v1/plugins/<id>/_/ui/widgets/` -> five levels up is `/api/v1/`, doc 06 section 3.3).
82
+ * @param {string} specifier
83
+ */
84
+ export function widgetImportPath(specifier) {
85
+ const file = RUNTIME_FILES[specifier];
86
+ if (!file) throw new Error(`no runtime file for ${specifier}`);
87
+ return `../../../../../widgets/runtime/${file}`;
88
+ }