@selfhelp/shared 1.1.0 → 1.2.1

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.
@@ -13,7 +13,7 @@ import '../common-B96dASgu.mjs';
13
13
  *
14
14
  * Independent from the npm `version` of `@selfhelp/shared`.
15
15
  */
16
- declare const PLUGIN_API_VERSION: "1.1";
16
+ declare const PLUGIN_API_VERSION: "1.2";
17
17
  interface ISemver {
18
18
  major: number;
19
19
  minor: number;
@@ -385,26 +385,40 @@ interface IPluginRegistryEntry {
385
385
  /**
386
386
  * Registry root document.
387
387
  *
388
- * Mirrors `plugin-registry.schema.json`. The version field is named
389
- * `registryVersion` (integer, bumped only on breaking registry-document
390
- * changes).
388
+ * Mirrors `plugin-registry.schema.json` in the host repository. The
389
+ * canonical schema requires `schemaVersion` (a string enum, currently
390
+ * `'1.0'`) and `plugins`. The publisher/base-url metadata is optional
391
+ * but always emitted by `scripts/publish-to-registry.mjs`.
391
392
  */
392
393
  interface IPluginRegistry {
393
- /** Registry schema generation. Bumped only on breaking registry-document changes. */
394
- registryVersion: number;
395
- /** Registry display name. */
396
- name: string;
397
- /** Registry homepage / maintainer URL. */
398
- homepage?: string;
394
+ /** Canonical registry schema version. Currently fixed at `'1.0'`. */
395
+ schemaVersion: '1.0';
399
396
  /** ISO timestamp this registry was published. */
400
397
  publishedAt?: string;
401
- /** Public key used to verify per-version signatures. */
398
+ /**
399
+ * Public base URL where this registry is served (with trailing
400
+ * slash). Plugin publishers join this to relative
401
+ * `artifacts/<id>-<version>/...` paths to produce the absolute
402
+ * `runtime.entrypointUrl` / `runtime.stylesheetUrl` that gets
403
+ * signed and shipped in each plugin entry.
404
+ */
405
+ baseUrl?: string;
406
+ /** Publisher metadata shown in the admin UI. */
407
+ publisher?: {
408
+ name: string;
409
+ url?: string;
410
+ };
411
+ /** Optional registry display name (legacy helper, not in canonical schema). */
412
+ name?: string;
413
+ /** Registry homepage / maintainer URL (legacy helper, not in canonical schema). */
414
+ homepage?: string;
415
+ /** Public key used to verify per-version signatures (legacy helper, not in canonical schema). */
402
416
  trustKey?: {
403
417
  algo: 'ed25519';
404
418
  publicKeyId: string;
405
419
  publicKey: string;
406
420
  };
407
- /** Channels this registry exposes (subset of stable/beta/alpha/nightly). */
421
+ /** Channels this registry exposes (legacy helper, not in canonical schema). */
408
422
  channels?: TPluginRegistryChannel[];
409
423
  /** Listed plugins. */
410
424
  plugins: IPluginRegistryEntry[];
@@ -950,4 +964,99 @@ interface IUsePluginRealtimeResult<TPayload = unknown> {
950
964
  */
951
965
  declare function usePluginRealtime<TPayload = unknown>(options: IUsePluginRealtimeOptions<TPayload>): IUsePluginRealtimeResult<TPayload>;
952
966
 
953
- export { type IAdminPageDefinition, type IFieldRendererDefinition, type IMenuItemDefinition, type IMobilePluginApi, type IMobilePluginRegistration, type IPluginApi, type IPluginFeatureFlag, type IPluginFieldRendererProps, type IPluginHealthCheck, type IPluginLock, type IPluginLockEntry, type IPluginLockMigration, type IPluginLockMobileEntry, type IPluginManifest, type IPluginManifestAdminPage, type IPluginManifestApiRoute, type IPluginManifestAsset, type IPluginManifestCapability, type IPluginManifestCompatibility, type IPluginManifestConflict, type IPluginManifestDataAccess, type IPluginManifestDependency, type IPluginManifestExternalHost, type IPluginManifestFeatureFlag, type IPluginManifestHealth, type IPluginManifestLookupExtension, type IPluginManifestMobile, type IPluginManifestPermission, type IPluginManifestRealtimeTopic, type IPluginManifestScheduledJob, type IPluginManifestSecurity, type IPluginManifestStyle, type IPluginManifestTrustLevel, type IPluginRealtimePublisher, type IPluginRealtimeTopic, type IPluginRegistration, type IPluginRegistry, type IPluginRegistryEntry, type IPluginRegistryVersionEntry, type IRealtimeTransport, type IRichTextEditorAdapter, type IRichTextEditorAdapterOptions, type IRichTextEditorValue, type IStyleDefinition, type IUsePluginRealtimeOptions, type IUsePluginRealtimeResult, PLUGIN_API_VERSION, type TPluginRegistryChannel, type TRealtimeTransportFactory, assertCmsCompatibility, assertPluginApiVersion, assertPluginVersionSemantics, compareSemver, defineMobilePlugin, definePlugin, definePluginRealtimeTopic, isPluginApiCompatible, parseSemver, satisfiesSemverRange, usePluginRealtime };
967
+ /**
968
+ * Plugin runtime-shim contract.
969
+ *
970
+ * Plugins ship as native ESM bundles that import bare specifiers like
971
+ * `react`, `@mantine/core`, `@tanstack/react-query`, and
972
+ * `@selfhelp/shared/plugin-sdk`. The browser cannot resolve those
973
+ * without help, and the host explicitly does NOT want each plugin to
974
+ * bundle its own copy of those packages — a duplicate React breaks
975
+ * hooks, a duplicate `@tanstack/react-query` shadows the host's
976
+ * `QueryClient`, a duplicate `STYLE_REGISTRY` desynchronises the
977
+ * style dispatcher.
978
+ *
979
+ * Resolution strategy is a single contract shared across:
980
+ *
981
+ * 1. The host frontend (`sh-selfhelp_frontend`) which:
982
+ * - renders `<script type="importmap">` with the entries from
983
+ * {@link PLUGIN_RUNTIME_IMPORT_MAP},
984
+ * - serves a tiny per-module shim at
985
+ * {@link PLUGIN_RUNTIME_SHIM_BASE_PATH}`<specifier>`,
986
+ * - populates {@link PLUGIN_RUNTIME_GLOBAL_KEY} on `globalThis`
987
+ * with the singleton module objects the host already loaded.
988
+ * 2. Every plugin's frontend Vite build, which externalises the
989
+ * same specifiers and rewrites them to the matching shim URL so
990
+ * the published bundle's imports resolve through the host.
991
+ * 3. Every plugin's local dev-runtime server (Vite middleware),
992
+ * which inlines the shim payload fetched from the host so
993
+ * on-demand transforms still consume host singletons.
994
+ *
995
+ * Adding or removing a singleton is a single edit to
996
+ * {@link PLUGIN_RUNTIME_SHIM_SPECIFIERS}. The host shell, plugin
997
+ * builds, and plugin dev runtimes all derive their behaviour from
998
+ * that list, so they stay in lockstep automatically.
999
+ */
1000
+ /**
1001
+ * Bare ESM specifier the host exposes to plugins as a runtime
1002
+ * singleton. The order here is documentation-only; consumers should
1003
+ * treat the list as a set.
1004
+ */
1005
+ type TPluginRuntimeShimSpecifier = 'react' | 'react/jsx-runtime' | 'react/jsx-dev-runtime' | 'react-dom' | 'react-dom/client' | '@mantine/core' | '@mantine/hooks' | '@mantine/notifications' | '@tanstack/react-query' | '@selfhelp/shared' | '@selfhelp/shared/plugin-sdk' | '@selfhelp/shared/registry';
1006
+ /**
1007
+ * Canonical list of bare specifiers the host supports for plugin
1008
+ * runtimes. Every entry MUST be:
1009
+ *
1010
+ * 1. Stashed on `globalThis[PLUGIN_RUNTIME_GLOBAL_KEY]` by the host
1011
+ * (so the shim has something to re-export);
1012
+ * 2. Listed in {@link PLUGIN_RUNTIME_IMPORT_MAP} (so the browser
1013
+ * can rewrite the bare specifier to the shim URL); and
1014
+ * 3. Allowed by the host's `/api/plugins/runtime-shim/*` route
1015
+ * handler (so the shim payload is actually generated).
1016
+ *
1017
+ * The host frontend asserts (1)–(3) cover the same set at build
1018
+ * time; drift between them is a contract bug.
1019
+ */
1020
+ declare const PLUGIN_RUNTIME_SHIM_SPECIFIERS: readonly TPluginRuntimeShimSpecifier[];
1021
+ /**
1022
+ * Host-relative path prefix for the per-module shim endpoint. The
1023
+ * full URL for a given specifier is built by appending the specifier
1024
+ * as-is (it already includes any `@scope/` segment and any
1025
+ * `/subpath`). Use {@link buildPluginRuntimeShimPath} so consumers
1026
+ * never reconstruct the join logic locally.
1027
+ */
1028
+ declare const PLUGIN_RUNTIME_SHIM_BASE_PATH: "/api/plugins/runtime-shim/";
1029
+ /**
1030
+ * `globalThis` key the host populates with the singleton module
1031
+ * instances. The shim payload reads from this key at module-load
1032
+ * time, so identity is preserved between the host shell and every
1033
+ * plugin without any extra serialization.
1034
+ */
1035
+ declare const PLUGIN_RUNTIME_GLOBAL_KEY: "__SELFHELP_RUNTIME__";
1036
+ /**
1037
+ * Build the host-relative URL the import map (and the plugin's Vite
1038
+ * config) should point a given specifier at. The returned string is
1039
+ * always same-origin with the host shell — the entire shim contract
1040
+ * relies on browsers loading the bundle from a URL whose imports
1041
+ * resolve to the host's origin.
1042
+ */
1043
+ declare function buildPluginRuntimeShimPath(specifier: TPluginRuntimeShimSpecifier): string;
1044
+ /**
1045
+ * Type-guarded check that a runtime-supplied string is one of the
1046
+ * specifiers the host knows how to shim. Consumers that take user
1047
+ * input (route segments, manifest values) should always validate
1048
+ * through this helper before falling through to dynamic resolution.
1049
+ */
1050
+ declare function isPluginRuntimeShimSpecifier(value: unknown): value is TPluginRuntimeShimSpecifier;
1051
+ /**
1052
+ * Bare-specifier → shim URL map. Rendered as the body of the
1053
+ * `<script type="importmap">` tag in the host's root layout. Plugins
1054
+ * also consume the same map at build time to keep externalisation
1055
+ * symmetric with the browser-side import map.
1056
+ *
1057
+ * Frozen so consumers can pass it directly to `JSON.stringify`
1058
+ * without worrying about accidental mutation.
1059
+ */
1060
+ declare const PLUGIN_RUNTIME_IMPORT_MAP: Readonly<Record<TPluginRuntimeShimSpecifier, string>>;
1061
+
1062
+ export { type IAdminPageDefinition, type IFieldRendererDefinition, type IMenuItemDefinition, type IMobilePluginApi, type IMobilePluginRegistration, type IPluginApi, type IPluginFeatureFlag, type IPluginFieldRendererProps, type IPluginHealthCheck, type IPluginLock, type IPluginLockEntry, type IPluginLockMigration, type IPluginLockMobileEntry, type IPluginManifest, type IPluginManifestAdminPage, type IPluginManifestApiRoute, type IPluginManifestAsset, type IPluginManifestCapability, type IPluginManifestCompatibility, type IPluginManifestConflict, type IPluginManifestDataAccess, type IPluginManifestDependency, type IPluginManifestExternalHost, type IPluginManifestFeatureFlag, type IPluginManifestHealth, type IPluginManifestLookupExtension, type IPluginManifestMobile, type IPluginManifestPermission, type IPluginManifestRealtimeTopic, type IPluginManifestScheduledJob, type IPluginManifestSecurity, type IPluginManifestStyle, type IPluginManifestTrustLevel, type IPluginRealtimePublisher, type IPluginRealtimeTopic, type IPluginRegistration, type IPluginRegistry, type IPluginRegistryEntry, type IPluginRegistryVersionEntry, type IRealtimeTransport, type IRichTextEditorAdapter, type IRichTextEditorAdapterOptions, type IRichTextEditorValue, type IStyleDefinition, type IUsePluginRealtimeOptions, type IUsePluginRealtimeResult, PLUGIN_API_VERSION, PLUGIN_RUNTIME_GLOBAL_KEY, PLUGIN_RUNTIME_IMPORT_MAP, PLUGIN_RUNTIME_SHIM_BASE_PATH, PLUGIN_RUNTIME_SHIM_SPECIFIERS, type TPluginRegistryChannel, type TPluginRuntimeShimSpecifier, type TRealtimeTransportFactory, assertCmsCompatibility, assertPluginApiVersion, assertPluginVersionSemantics, buildPluginRuntimeShimPath, compareSemver, defineMobilePlugin, definePlugin, definePluginRealtimeTopic, isPluginApiCompatible, isPluginRuntimeShimSpecifier, parseSemver, satisfiesSemverRange, usePluginRealtime };
@@ -13,7 +13,7 @@ import '../common-B96dASgu.js';
13
13
  *
14
14
  * Independent from the npm `version` of `@selfhelp/shared`.
15
15
  */
16
- declare const PLUGIN_API_VERSION: "1.1";
16
+ declare const PLUGIN_API_VERSION: "1.2";
17
17
  interface ISemver {
18
18
  major: number;
19
19
  minor: number;
@@ -385,26 +385,40 @@ interface IPluginRegistryEntry {
385
385
  /**
386
386
  * Registry root document.
387
387
  *
388
- * Mirrors `plugin-registry.schema.json`. The version field is named
389
- * `registryVersion` (integer, bumped only on breaking registry-document
390
- * changes).
388
+ * Mirrors `plugin-registry.schema.json` in the host repository. The
389
+ * canonical schema requires `schemaVersion` (a string enum, currently
390
+ * `'1.0'`) and `plugins`. The publisher/base-url metadata is optional
391
+ * but always emitted by `scripts/publish-to-registry.mjs`.
391
392
  */
392
393
  interface IPluginRegistry {
393
- /** Registry schema generation. Bumped only on breaking registry-document changes. */
394
- registryVersion: number;
395
- /** Registry display name. */
396
- name: string;
397
- /** Registry homepage / maintainer URL. */
398
- homepage?: string;
394
+ /** Canonical registry schema version. Currently fixed at `'1.0'`. */
395
+ schemaVersion: '1.0';
399
396
  /** ISO timestamp this registry was published. */
400
397
  publishedAt?: string;
401
- /** Public key used to verify per-version signatures. */
398
+ /**
399
+ * Public base URL where this registry is served (with trailing
400
+ * slash). Plugin publishers join this to relative
401
+ * `artifacts/<id>-<version>/...` paths to produce the absolute
402
+ * `runtime.entrypointUrl` / `runtime.stylesheetUrl` that gets
403
+ * signed and shipped in each plugin entry.
404
+ */
405
+ baseUrl?: string;
406
+ /** Publisher metadata shown in the admin UI. */
407
+ publisher?: {
408
+ name: string;
409
+ url?: string;
410
+ };
411
+ /** Optional registry display name (legacy helper, not in canonical schema). */
412
+ name?: string;
413
+ /** Registry homepage / maintainer URL (legacy helper, not in canonical schema). */
414
+ homepage?: string;
415
+ /** Public key used to verify per-version signatures (legacy helper, not in canonical schema). */
402
416
  trustKey?: {
403
417
  algo: 'ed25519';
404
418
  publicKeyId: string;
405
419
  publicKey: string;
406
420
  };
407
- /** Channels this registry exposes (subset of stable/beta/alpha/nightly). */
421
+ /** Channels this registry exposes (legacy helper, not in canonical schema). */
408
422
  channels?: TPluginRegistryChannel[];
409
423
  /** Listed plugins. */
410
424
  plugins: IPluginRegistryEntry[];
@@ -950,4 +964,99 @@ interface IUsePluginRealtimeResult<TPayload = unknown> {
950
964
  */
951
965
  declare function usePluginRealtime<TPayload = unknown>(options: IUsePluginRealtimeOptions<TPayload>): IUsePluginRealtimeResult<TPayload>;
952
966
 
953
- export { type IAdminPageDefinition, type IFieldRendererDefinition, type IMenuItemDefinition, type IMobilePluginApi, type IMobilePluginRegistration, type IPluginApi, type IPluginFeatureFlag, type IPluginFieldRendererProps, type IPluginHealthCheck, type IPluginLock, type IPluginLockEntry, type IPluginLockMigration, type IPluginLockMobileEntry, type IPluginManifest, type IPluginManifestAdminPage, type IPluginManifestApiRoute, type IPluginManifestAsset, type IPluginManifestCapability, type IPluginManifestCompatibility, type IPluginManifestConflict, type IPluginManifestDataAccess, type IPluginManifestDependency, type IPluginManifestExternalHost, type IPluginManifestFeatureFlag, type IPluginManifestHealth, type IPluginManifestLookupExtension, type IPluginManifestMobile, type IPluginManifestPermission, type IPluginManifestRealtimeTopic, type IPluginManifestScheduledJob, type IPluginManifestSecurity, type IPluginManifestStyle, type IPluginManifestTrustLevel, type IPluginRealtimePublisher, type IPluginRealtimeTopic, type IPluginRegistration, type IPluginRegistry, type IPluginRegistryEntry, type IPluginRegistryVersionEntry, type IRealtimeTransport, type IRichTextEditorAdapter, type IRichTextEditorAdapterOptions, type IRichTextEditorValue, type IStyleDefinition, type IUsePluginRealtimeOptions, type IUsePluginRealtimeResult, PLUGIN_API_VERSION, type TPluginRegistryChannel, type TRealtimeTransportFactory, assertCmsCompatibility, assertPluginApiVersion, assertPluginVersionSemantics, compareSemver, defineMobilePlugin, definePlugin, definePluginRealtimeTopic, isPluginApiCompatible, parseSemver, satisfiesSemverRange, usePluginRealtime };
967
+ /**
968
+ * Plugin runtime-shim contract.
969
+ *
970
+ * Plugins ship as native ESM bundles that import bare specifiers like
971
+ * `react`, `@mantine/core`, `@tanstack/react-query`, and
972
+ * `@selfhelp/shared/plugin-sdk`. The browser cannot resolve those
973
+ * without help, and the host explicitly does NOT want each plugin to
974
+ * bundle its own copy of those packages — a duplicate React breaks
975
+ * hooks, a duplicate `@tanstack/react-query` shadows the host's
976
+ * `QueryClient`, a duplicate `STYLE_REGISTRY` desynchronises the
977
+ * style dispatcher.
978
+ *
979
+ * Resolution strategy is a single contract shared across:
980
+ *
981
+ * 1. The host frontend (`sh-selfhelp_frontend`) which:
982
+ * - renders `<script type="importmap">` with the entries from
983
+ * {@link PLUGIN_RUNTIME_IMPORT_MAP},
984
+ * - serves a tiny per-module shim at
985
+ * {@link PLUGIN_RUNTIME_SHIM_BASE_PATH}`<specifier>`,
986
+ * - populates {@link PLUGIN_RUNTIME_GLOBAL_KEY} on `globalThis`
987
+ * with the singleton module objects the host already loaded.
988
+ * 2. Every plugin's frontend Vite build, which externalises the
989
+ * same specifiers and rewrites them to the matching shim URL so
990
+ * the published bundle's imports resolve through the host.
991
+ * 3. Every plugin's local dev-runtime server (Vite middleware),
992
+ * which inlines the shim payload fetched from the host so
993
+ * on-demand transforms still consume host singletons.
994
+ *
995
+ * Adding or removing a singleton is a single edit to
996
+ * {@link PLUGIN_RUNTIME_SHIM_SPECIFIERS}. The host shell, plugin
997
+ * builds, and plugin dev runtimes all derive their behaviour from
998
+ * that list, so they stay in lockstep automatically.
999
+ */
1000
+ /**
1001
+ * Bare ESM specifier the host exposes to plugins as a runtime
1002
+ * singleton. The order here is documentation-only; consumers should
1003
+ * treat the list as a set.
1004
+ */
1005
+ type TPluginRuntimeShimSpecifier = 'react' | 'react/jsx-runtime' | 'react/jsx-dev-runtime' | 'react-dom' | 'react-dom/client' | '@mantine/core' | '@mantine/hooks' | '@mantine/notifications' | '@tanstack/react-query' | '@selfhelp/shared' | '@selfhelp/shared/plugin-sdk' | '@selfhelp/shared/registry';
1006
+ /**
1007
+ * Canonical list of bare specifiers the host supports for plugin
1008
+ * runtimes. Every entry MUST be:
1009
+ *
1010
+ * 1. Stashed on `globalThis[PLUGIN_RUNTIME_GLOBAL_KEY]` by the host
1011
+ * (so the shim has something to re-export);
1012
+ * 2. Listed in {@link PLUGIN_RUNTIME_IMPORT_MAP} (so the browser
1013
+ * can rewrite the bare specifier to the shim URL); and
1014
+ * 3. Allowed by the host's `/api/plugins/runtime-shim/*` route
1015
+ * handler (so the shim payload is actually generated).
1016
+ *
1017
+ * The host frontend asserts (1)–(3) cover the same set at build
1018
+ * time; drift between them is a contract bug.
1019
+ */
1020
+ declare const PLUGIN_RUNTIME_SHIM_SPECIFIERS: readonly TPluginRuntimeShimSpecifier[];
1021
+ /**
1022
+ * Host-relative path prefix for the per-module shim endpoint. The
1023
+ * full URL for a given specifier is built by appending the specifier
1024
+ * as-is (it already includes any `@scope/` segment and any
1025
+ * `/subpath`). Use {@link buildPluginRuntimeShimPath} so consumers
1026
+ * never reconstruct the join logic locally.
1027
+ */
1028
+ declare const PLUGIN_RUNTIME_SHIM_BASE_PATH: "/api/plugins/runtime-shim/";
1029
+ /**
1030
+ * `globalThis` key the host populates with the singleton module
1031
+ * instances. The shim payload reads from this key at module-load
1032
+ * time, so identity is preserved between the host shell and every
1033
+ * plugin without any extra serialization.
1034
+ */
1035
+ declare const PLUGIN_RUNTIME_GLOBAL_KEY: "__SELFHELP_RUNTIME__";
1036
+ /**
1037
+ * Build the host-relative URL the import map (and the plugin's Vite
1038
+ * config) should point a given specifier at. The returned string is
1039
+ * always same-origin with the host shell — the entire shim contract
1040
+ * relies on browsers loading the bundle from a URL whose imports
1041
+ * resolve to the host's origin.
1042
+ */
1043
+ declare function buildPluginRuntimeShimPath(specifier: TPluginRuntimeShimSpecifier): string;
1044
+ /**
1045
+ * Type-guarded check that a runtime-supplied string is one of the
1046
+ * specifiers the host knows how to shim. Consumers that take user
1047
+ * input (route segments, manifest values) should always validate
1048
+ * through this helper before falling through to dynamic resolution.
1049
+ */
1050
+ declare function isPluginRuntimeShimSpecifier(value: unknown): value is TPluginRuntimeShimSpecifier;
1051
+ /**
1052
+ * Bare-specifier → shim URL map. Rendered as the body of the
1053
+ * `<script type="importmap">` tag in the host's root layout. Plugins
1054
+ * also consume the same map at build time to keep externalisation
1055
+ * symmetric with the browser-side import map.
1056
+ *
1057
+ * Frozen so consumers can pass it directly to `JSON.stringify`
1058
+ * without worrying about accidental mutation.
1059
+ */
1060
+ declare const PLUGIN_RUNTIME_IMPORT_MAP: Readonly<Record<TPluginRuntimeShimSpecifier, string>>;
1061
+
1062
+ export { type IAdminPageDefinition, type IFieldRendererDefinition, type IMenuItemDefinition, type IMobilePluginApi, type IMobilePluginRegistration, type IPluginApi, type IPluginFeatureFlag, type IPluginFieldRendererProps, type IPluginHealthCheck, type IPluginLock, type IPluginLockEntry, type IPluginLockMigration, type IPluginLockMobileEntry, type IPluginManifest, type IPluginManifestAdminPage, type IPluginManifestApiRoute, type IPluginManifestAsset, type IPluginManifestCapability, type IPluginManifestCompatibility, type IPluginManifestConflict, type IPluginManifestDataAccess, type IPluginManifestDependency, type IPluginManifestExternalHost, type IPluginManifestFeatureFlag, type IPluginManifestHealth, type IPluginManifestLookupExtension, type IPluginManifestMobile, type IPluginManifestPermission, type IPluginManifestRealtimeTopic, type IPluginManifestScheduledJob, type IPluginManifestSecurity, type IPluginManifestStyle, type IPluginManifestTrustLevel, type IPluginRealtimePublisher, type IPluginRealtimeTopic, type IPluginRegistration, type IPluginRegistry, type IPluginRegistryEntry, type IPluginRegistryVersionEntry, type IRealtimeTransport, type IRichTextEditorAdapter, type IRichTextEditorAdapterOptions, type IRichTextEditorValue, type IStyleDefinition, type IUsePluginRealtimeOptions, type IUsePluginRealtimeResult, PLUGIN_API_VERSION, PLUGIN_RUNTIME_GLOBAL_KEY, PLUGIN_RUNTIME_IMPORT_MAP, PLUGIN_RUNTIME_SHIM_BASE_PATH, PLUGIN_RUNTIME_SHIM_SPECIFIERS, type TPluginRegistryChannel, type TPluginRuntimeShimSpecifier, type TRealtimeTransportFactory, assertCmsCompatibility, assertPluginApiVersion, assertPluginVersionSemantics, buildPluginRuntimeShimPath, compareSemver, defineMobilePlugin, definePlugin, definePluginRealtimeTopic, isPluginApiCompatible, isPluginRuntimeShimSpecifier, parseSemver, satisfiesSemverRange, usePluginRealtime };
@@ -21,14 +21,20 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var plugin_sdk_exports = {};
22
22
  __export(plugin_sdk_exports, {
23
23
  PLUGIN_API_VERSION: () => PLUGIN_API_VERSION,
24
+ PLUGIN_RUNTIME_GLOBAL_KEY: () => PLUGIN_RUNTIME_GLOBAL_KEY,
25
+ PLUGIN_RUNTIME_IMPORT_MAP: () => PLUGIN_RUNTIME_IMPORT_MAP,
26
+ PLUGIN_RUNTIME_SHIM_BASE_PATH: () => PLUGIN_RUNTIME_SHIM_BASE_PATH,
27
+ PLUGIN_RUNTIME_SHIM_SPECIFIERS: () => PLUGIN_RUNTIME_SHIM_SPECIFIERS,
24
28
  assertCmsCompatibility: () => assertCmsCompatibility,
25
29
  assertPluginApiVersion: () => assertPluginApiVersion,
26
30
  assertPluginVersionSemantics: () => assertPluginVersionSemantics,
31
+ buildPluginRuntimeShimPath: () => buildPluginRuntimeShimPath,
27
32
  compareSemver: () => compareSemver,
28
33
  defineMobilePlugin: () => defineMobilePlugin,
29
34
  definePlugin: () => definePlugin,
30
35
  definePluginRealtimeTopic: () => definePluginRealtimeTopic,
31
36
  isPluginApiCompatible: () => isPluginApiCompatible,
37
+ isPluginRuntimeShimSpecifier: () => isPluginRuntimeShimSpecifier,
32
38
  parseSemver: () => parseSemver,
33
39
  satisfiesSemverRange: () => satisfiesSemverRange,
34
40
  usePluginRealtime: () => usePluginRealtime
@@ -36,7 +42,7 @@ __export(plugin_sdk_exports, {
36
42
  module.exports = __toCommonJS(plugin_sdk_exports);
37
43
 
38
44
  // src/plugin-sdk/version.ts
39
- var PLUGIN_API_VERSION = "1.1";
45
+ var PLUGIN_API_VERSION = "1.2";
40
46
  var SEMVER_REGEX = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/;
41
47
  function parseSemver(version) {
42
48
  const match = SEMVER_REGEX.exec(version);
@@ -473,17 +479,52 @@ function usePluginRealtime(options) {
473
479
  }, [enabled, endpoint, pluginId, topic, topicParamsKey, transportFactory]);
474
480
  return { data, isOnline, lastEventAt, error };
475
481
  }
482
+
483
+ // src/plugin-sdk/runtime-shim.ts
484
+ var PLUGIN_RUNTIME_SHIM_SPECIFIERS = [
485
+ "react",
486
+ "react/jsx-runtime",
487
+ "react/jsx-dev-runtime",
488
+ "react-dom",
489
+ "react-dom/client",
490
+ "@mantine/core",
491
+ "@mantine/hooks",
492
+ "@mantine/notifications",
493
+ "@tanstack/react-query",
494
+ "@selfhelp/shared",
495
+ "@selfhelp/shared/plugin-sdk",
496
+ "@selfhelp/shared/registry"
497
+ ];
498
+ var PLUGIN_RUNTIME_SHIM_BASE_PATH = "/api/plugins/runtime-shim/";
499
+ var PLUGIN_RUNTIME_GLOBAL_KEY = "__SELFHELP_RUNTIME__";
500
+ function buildPluginRuntimeShimPath(specifier) {
501
+ return `${PLUGIN_RUNTIME_SHIM_BASE_PATH}${specifier}`;
502
+ }
503
+ function isPluginRuntimeShimSpecifier(value) {
504
+ return typeof value === "string" && PLUGIN_RUNTIME_SHIM_SPECIFIERS.includes(value);
505
+ }
506
+ var PLUGIN_RUNTIME_IMPORT_MAP = Object.freeze(
507
+ Object.fromEntries(
508
+ PLUGIN_RUNTIME_SHIM_SPECIFIERS.map((s) => [s, buildPluginRuntimeShimPath(s)])
509
+ )
510
+ );
476
511
  // Annotate the CommonJS export names for ESM import in node:
477
512
  0 && (module.exports = {
478
513
  PLUGIN_API_VERSION,
514
+ PLUGIN_RUNTIME_GLOBAL_KEY,
515
+ PLUGIN_RUNTIME_IMPORT_MAP,
516
+ PLUGIN_RUNTIME_SHIM_BASE_PATH,
517
+ PLUGIN_RUNTIME_SHIM_SPECIFIERS,
479
518
  assertCmsCompatibility,
480
519
  assertPluginApiVersion,
481
520
  assertPluginVersionSemantics,
521
+ buildPluginRuntimeShimPath,
482
522
  compareSemver,
483
523
  defineMobilePlugin,
484
524
  definePlugin,
485
525
  definePluginRealtimeTopic,
486
526
  isPluginApiCompatible,
527
+ isPluginRuntimeShimSpecifier,
487
528
  parseSemver,
488
529
  satisfiesSemverRange,
489
530
  usePluginRealtime
@@ -1,5 +1,5 @@
1
1
  // src/plugin-sdk/version.ts
2
- var PLUGIN_API_VERSION = "1.1";
2
+ var PLUGIN_API_VERSION = "1.2";
3
3
  var SEMVER_REGEX = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/;
4
4
  function parseSemver(version) {
5
5
  const match = SEMVER_REGEX.exec(version);
@@ -436,16 +436,51 @@ function usePluginRealtime(options) {
436
436
  }, [enabled, endpoint, pluginId, topic, topicParamsKey, transportFactory]);
437
437
  return { data, isOnline, lastEventAt, error };
438
438
  }
439
+
440
+ // src/plugin-sdk/runtime-shim.ts
441
+ var PLUGIN_RUNTIME_SHIM_SPECIFIERS = [
442
+ "react",
443
+ "react/jsx-runtime",
444
+ "react/jsx-dev-runtime",
445
+ "react-dom",
446
+ "react-dom/client",
447
+ "@mantine/core",
448
+ "@mantine/hooks",
449
+ "@mantine/notifications",
450
+ "@tanstack/react-query",
451
+ "@selfhelp/shared",
452
+ "@selfhelp/shared/plugin-sdk",
453
+ "@selfhelp/shared/registry"
454
+ ];
455
+ var PLUGIN_RUNTIME_SHIM_BASE_PATH = "/api/plugins/runtime-shim/";
456
+ var PLUGIN_RUNTIME_GLOBAL_KEY = "__SELFHELP_RUNTIME__";
457
+ function buildPluginRuntimeShimPath(specifier) {
458
+ return `${PLUGIN_RUNTIME_SHIM_BASE_PATH}${specifier}`;
459
+ }
460
+ function isPluginRuntimeShimSpecifier(value) {
461
+ return typeof value === "string" && PLUGIN_RUNTIME_SHIM_SPECIFIERS.includes(value);
462
+ }
463
+ var PLUGIN_RUNTIME_IMPORT_MAP = Object.freeze(
464
+ Object.fromEntries(
465
+ PLUGIN_RUNTIME_SHIM_SPECIFIERS.map((s) => [s, buildPluginRuntimeShimPath(s)])
466
+ )
467
+ );
439
468
  export {
440
469
  PLUGIN_API_VERSION,
470
+ PLUGIN_RUNTIME_GLOBAL_KEY,
471
+ PLUGIN_RUNTIME_IMPORT_MAP,
472
+ PLUGIN_RUNTIME_SHIM_BASE_PATH,
473
+ PLUGIN_RUNTIME_SHIM_SPECIFIERS,
441
474
  assertCmsCompatibility,
442
475
  assertPluginApiVersion,
443
476
  assertPluginVersionSemantics,
477
+ buildPluginRuntimeShimPath,
444
478
  compareSemver,
445
479
  defineMobilePlugin,
446
480
  definePlugin,
447
481
  definePluginRealtimeTopic,
448
482
  isPluginApiCompatible,
483
+ isPluginRuntimeShimSpecifier,
449
484
  parseSemver,
450
485
  satisfiesSemverRange,
451
486
  usePluginRealtime
package/package.json CHANGED
@@ -1,93 +1,93 @@
1
- {
2
- "name": "@selfhelp/shared",
3
- "version": "1.1.0",
4
- "description": "Shared TypeScript package for SelfHelp web frontend and mobile app: style registry, types, API contracts, Mantine theme tokens, condition + interpolation engines, CMS class allow-list.",
5
- "repository": {
6
- "type": "git",
7
- "url": "git+https://github.com/humdek-unibe-ch/sh-selfhelp_shared.git"
8
- },
9
- "homepage": "https://github.com/humdek-unibe-ch/sh-selfhelp_shared#readme",
10
- "bugs": {
11
- "url": "https://github.com/humdek-unibe-ch/sh-selfhelp_shared/issues"
12
- },
13
- "main": "dist/index.js",
14
- "module": "dist/index.mjs",
15
- "types": "dist/index.d.ts",
16
- "exports": {
17
- ".": {
18
- "types": "./dist/index.d.ts",
19
- "import": "./dist/index.mjs",
20
- "require": "./dist/index.js"
21
- },
22
- "./registry": {
23
- "types": "./dist/registry/index.d.ts",
24
- "import": "./dist/registry/index.mjs",
25
- "require": "./dist/registry/index.js"
26
- },
27
- "./theme": {
28
- "types": "./dist/theme/index.d.ts",
29
- "import": "./dist/theme/index.mjs",
30
- "require": "./dist/theme/index.js"
31
- },
32
- "./tailwind": {
33
- "types": "./dist/theme/tailwind.d.ts",
34
- "import": "./dist/theme/tailwind.mjs",
35
- "require": "./dist/theme/tailwind.js"
36
- },
37
- "./plugin-sdk": {
38
- "types": "./dist/plugin-sdk/index.d.ts",
39
- "import": "./dist/plugin-sdk/index.mjs",
40
- "require": "./dist/plugin-sdk/index.js"
41
- }
42
- },
43
- "files": [
44
- "dist",
45
- "src",
46
- "README.md",
47
- "CHANGELOG.md"
48
- ],
49
- "scripts": {
50
- "build": "tsup src/index.ts src/registry/index.ts src/theme/index.ts src/theme/tailwind.ts src/plugin-sdk/index.ts --format cjs,esm --dts --clean --no-splitting",
51
- "dev": "tsup src/index.ts src/registry/index.ts src/theme/index.ts src/theme/tailwind.ts src/plugin-sdk/index.ts --format cjs,esm --dts --watch --no-splitting",
52
- "lint": "eslint . --ext .ts",
53
- "typecheck": "tsc --noEmit",
54
- "test": "vitest run",
55
- "check:schemas": "node scripts/check-schema-parity.mjs",
56
- "prepublishOnly": "npm run build",
57
- "headers:check": "license-check-and-add check -f license-check-and-add-config.json",
58
- "headers:add": "license-check-and-add add -f license-check-and-add-config.json",
59
- "headers:remove": "license-check-and-add remove -f license-check-and-add-config.json"
60
- },
61
- "dependencies": {
62
- "json-logic-js": "^2.0.5"
63
- },
64
- "peerDependencies": {
65
- "react": "^18.0.0 || ^19.0.0"
66
- },
67
- "peerDependenciesMeta": {
68
- "react": {
69
- "optional": true
70
- }
71
- },
72
- "devDependencies": {
73
- "@types/json-logic-js": "^2.0.8",
74
- "@types/node": "^22.10.0",
75
- "@types/react": "^19.2.15",
76
- "@typescript-eslint/eslint-plugin": "^8.0.0",
77
- "@typescript-eslint/parser": "^8.0.0",
78
- "eslint": "^9.18.0",
79
- "license-check-and-add": "^4.0.5",
80
- "react": "^19.2.6",
81
- "tsup": "^8.3.5",
82
- "typescript": "^5.6.0",
83
- "vitest": "^2.1.0"
84
- },
85
- "publishConfig": {
86
- "access": "public"
87
- },
88
- "engines": {
89
- "node": ">=18"
90
- },
91
- "sideEffects": false,
92
- "license": "MPL-2.0"
93
- }
1
+ {
2
+ "name": "@selfhelp/shared",
3
+ "version": "1.2.1",
4
+ "description": "Shared TypeScript package for SelfHelp web frontend and mobile app: style registry, types, API contracts, Mantine theme tokens, condition + interpolation engines, CMS class allow-list.",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/humdek-unibe-ch/sh-selfhelp_shared.git"
8
+ },
9
+ "homepage": "https://github.com/humdek-unibe-ch/sh-selfhelp_shared#readme",
10
+ "bugs": {
11
+ "url": "https://github.com/humdek-unibe-ch/sh-selfhelp_shared/issues"
12
+ },
13
+ "main": "dist/index.js",
14
+ "module": "dist/index.mjs",
15
+ "types": "dist/index.d.ts",
16
+ "exports": {
17
+ ".": {
18
+ "types": "./dist/index.d.ts",
19
+ "import": "./dist/index.mjs",
20
+ "require": "./dist/index.js"
21
+ },
22
+ "./registry": {
23
+ "types": "./dist/registry/index.d.ts",
24
+ "import": "./dist/registry/index.mjs",
25
+ "require": "./dist/registry/index.js"
26
+ },
27
+ "./theme": {
28
+ "types": "./dist/theme/index.d.ts",
29
+ "import": "./dist/theme/index.mjs",
30
+ "require": "./dist/theme/index.js"
31
+ },
32
+ "./tailwind": {
33
+ "types": "./dist/theme/tailwind.d.ts",
34
+ "import": "./dist/theme/tailwind.mjs",
35
+ "require": "./dist/theme/tailwind.js"
36
+ },
37
+ "./plugin-sdk": {
38
+ "types": "./dist/plugin-sdk/index.d.ts",
39
+ "import": "./dist/plugin-sdk/index.mjs",
40
+ "require": "./dist/plugin-sdk/index.js"
41
+ }
42
+ },
43
+ "files": [
44
+ "dist",
45
+ "src",
46
+ "README.md",
47
+ "CHANGELOG.md"
48
+ ],
49
+ "scripts": {
50
+ "build": "tsup src/index.ts src/registry/index.ts src/theme/index.ts src/theme/tailwind.ts src/plugin-sdk/index.ts --format cjs,esm --dts --clean --no-splitting",
51
+ "dev": "tsup src/index.ts src/registry/index.ts src/theme/index.ts src/theme/tailwind.ts src/plugin-sdk/index.ts --format cjs,esm --dts --watch --no-splitting",
52
+ "lint": "eslint . --ext .ts",
53
+ "typecheck": "tsc --noEmit",
54
+ "test": "vitest run --passWithNoTests",
55
+ "check:schemas": "node scripts/check-schema-parity.mjs",
56
+ "prepublishOnly": "npm run build",
57
+ "headers:check": "license-check-and-add check -f license-check-and-add-config.json",
58
+ "headers:add": "license-check-and-add add -f license-check-and-add-config.json",
59
+ "headers:remove": "license-check-and-add remove -f license-check-and-add-config.json"
60
+ },
61
+ "dependencies": {
62
+ "json-logic-js": "^2.0.5"
63
+ },
64
+ "peerDependencies": {
65
+ "react": "^18.0.0 || ^19.0.0"
66
+ },
67
+ "peerDependenciesMeta": {
68
+ "react": {
69
+ "optional": true
70
+ }
71
+ },
72
+ "devDependencies": {
73
+ "@types/json-logic-js": "^2.0.8",
74
+ "@types/node": "^22.10.0",
75
+ "@types/react": "^19.2.15",
76
+ "@typescript-eslint/eslint-plugin": "^8.0.0",
77
+ "@typescript-eslint/parser": "^8.0.0",
78
+ "eslint": "^9.18.0",
79
+ "license-check-and-add": "^4.0.5",
80
+ "react": "^19.2.6",
81
+ "tsup": "^8.3.5",
82
+ "typescript": "^5.6.0",
83
+ "vitest": "^2.1.0"
84
+ },
85
+ "publishConfig": {
86
+ "access": "public"
87
+ },
88
+ "engines": {
89
+ "node": ">=18"
90
+ },
91
+ "sideEffects": false,
92
+ "license": "MPL-2.0"
93
+ }