@anweat/dsh-browser 0.2.0-rc.1 → 0.2.0

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.
@@ -1,56 +0,0 @@
1
- /**
2
- * Host-version-adaptive settings scope resolution.
3
- *
4
- * DSH changed how a plugin declares its editable configuration section:
5
- *
6
- * - Older hosts (dsh-v0.1.1-rc.2 … v0.1.5-alpha.1) exposed a standalone
7
- * `settingsNamespace()` helper plus a `settings.register(ns, schema, opts)`
8
- * provider method. The plugin owned a mutable source ref and read the
9
- * registered scope on every operation.
10
- * - Newer hosts (dsh-v0.1.7-rc.2+) removed both. Settings pages are derived
11
- * from the Loader entry's own `Config` schema, and `SettingsForms` exposes
12
- * only `configure/describe/update/replace/mutate` — there is no `register`.
13
- * The host re-validates the entry config and restarts the plugin fiber, so
14
- * the value handed to `apply(ctx, config)` is already the live resolved one.
15
- *
16
- * Calling `settings.register` unconditionally therefore throws
17
- * `TypeError: settings.register is not a function` on a newer host and aborts
18
- * the whole plugin fiber, so this module probes for the method and degrades to
19
- * the entry-config path instead.
20
- * @module dsh-browser/settings-scope
21
- */
22
- /** The subset of the older host's `settings.register` contract we depend on. */
23
- export interface LegacySettingsRegister {
24
- register: (ns: string, schema: unknown, options?: {
25
- base?: unknown;
26
- applies?: string;
27
- }) => {
28
- get: () => unknown;
29
- };
30
- }
31
- /** Resolved settings access: either the legacy live scope or the entry config. */
32
- export interface SettingsResolution<TConfig> {
33
- /**
34
- * Read the current configuration. On a legacy host this re-reads the
35
- * registered scope (so edits are observed live); on a newer host it returns
36
- * the entry config that the host keeps current by restarting the fiber.
37
- */
38
- get: () => TConfig;
39
- /**
40
- * How the value is kept up to date: `'scope'` when the legacy provider owns
41
- * it, `'entry'` when the Loader re-applies the plugin config itself.
42
- */
43
- mode: 'scope' | 'entry';
44
- }
45
- /**
46
- * Register the plugin's settings section when the host supports it, and
47
- * otherwise fall back to the Loader-managed entry config.
48
- *
49
- * @param settings - the injected `ctx.settings` service, or undefined when the
50
- * host composes none.
51
- * @param namespace - the settings namespace / loader entry id (e.g. `browser`).
52
- * @param schema - the plugin's schemastery `Config` schema.
53
- * @param entryConfig - the config the host passed into `apply`.
54
- * @returns a version-independent reader for the current configuration.
55
- */
56
- export declare function resolveSettingsScope<TConfig>(settings: unknown, namespace: string, schema: unknown, entryConfig: TConfig): SettingsResolution<TConfig>;
@@ -1,51 +0,0 @@
1
- /**
2
- * Host-version-adaptive settings scope resolution.
3
- *
4
- * DSH changed how a plugin declares its editable configuration section:
5
- *
6
- * - Older hosts (dsh-v0.1.1-rc.2 … v0.1.5-alpha.1) exposed a standalone
7
- * `settingsNamespace()` helper plus a `settings.register(ns, schema, opts)`
8
- * provider method. The plugin owned a mutable source ref and read the
9
- * registered scope on every operation.
10
- * - Newer hosts (dsh-v0.1.7-rc.2+) removed both. Settings pages are derived
11
- * from the Loader entry's own `Config` schema, and `SettingsForms` exposes
12
- * only `configure/describe/update/replace/mutate` — there is no `register`.
13
- * The host re-validates the entry config and restarts the plugin fiber, so
14
- * the value handed to `apply(ctx, config)` is already the live resolved one.
15
- *
16
- * Calling `settings.register` unconditionally therefore throws
17
- * `TypeError: settings.register is not a function` on a newer host and aborts
18
- * the whole plugin fiber, so this module probes for the method and degrades to
19
- * the entry-config path instead.
20
- * @module dsh-browser/settings-scope
21
- */
22
- /** Narrow an unknown service to the legacy registering shape. */
23
- function legacyRegister(settings) {
24
- if (settings === null || typeof settings !== 'object')
25
- return undefined;
26
- const candidate = settings.register;
27
- return typeof candidate === 'function'
28
- ? candidate.bind(settings)
29
- : undefined;
30
- }
31
- /**
32
- * Register the plugin's settings section when the host supports it, and
33
- * otherwise fall back to the Loader-managed entry config.
34
- *
35
- * @param settings - the injected `ctx.settings` service, or undefined when the
36
- * host composes none.
37
- * @param namespace - the settings namespace / loader entry id (e.g. `browser`).
38
- * @param schema - the plugin's schemastery `Config` schema.
39
- * @param entryConfig - the config the host passed into `apply`.
40
- * @returns a version-independent reader for the current configuration.
41
- */
42
- export function resolveSettingsScope(settings, namespace, schema, entryConfig) {
43
- const register = legacyRegister(settings);
44
- if (register === undefined)
45
- return { get: () => entryConfig, mode: 'entry' };
46
- // The legacy provider is present: keep reading through it so live edits are
47
- // visible without a fiber restart (the historical behaviour on those hosts).
48
- const scope = register(namespace, schema, { base: entryConfig, applies: 'restart' });
49
- return { get: () => scope.get(), mode: 'scope' };
50
- }
51
- //# sourceMappingURL=settings-scope.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"settings-scope.js","sourceRoot":"","sources":["../src/settings-scope.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AA0BH,iEAAiE;AACjE,SAAS,cAAc,CAAC,QAAiB;IACvC,IAAI,QAAQ,KAAK,IAAI,IAAI,OAAO,QAAQ,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAA;IACvE,MAAM,SAAS,GAAI,QAAmC,CAAC,QAAQ,CAAA;IAC/D,OAAO,OAAO,SAAS,KAAK,UAAU;QACpC,CAAC,CAAE,SAAgD,CAAC,IAAI,CAAC,QAAQ,CAAC;QAClE,CAAC,CAAC,SAAS,CAAA;AACf,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,oBAAoB,CAClC,QAAiB,EACjB,SAAiB,EACjB,MAAe,EACf,WAAoB;IAEpB,MAAM,QAAQ,GAAG,cAAc,CAAC,QAAQ,CAAC,CAAA;IACzC,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,CAAA;IAC5E,4EAA4E;IAC5E,6EAA6E;IAC7E,MAAM,KAAK,GAAG,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,CAAA;IACpF,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,EAAa,EAAE,IAAI,EAAE,OAAO,EAAE,CAAA;AAC7D,CAAC"}