@deck-shelves/host 1.3.0 → 1.3.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.
package/dist/index.cjs CHANGED
@@ -2,5 +2,43 @@
2
2
 
3
3
  // src/contract/index.ts
4
4
  var HOST_API_VERSION = "1.2.0";
5
+ var INJECTED_HOST_GLOBAL = "__SHELVES_HOST__";
6
+ var FORCE_OWNER_GLOBAL = "__SHELVES_FORCE_OWNER__";
7
+ var OWNER_GLOBAL = "__DECK_SHELVES_OWNER__";
8
+ function ownershipScope() {
9
+ const g = globalThis;
10
+ return g.window ?? g;
11
+ }
12
+ function readOwnerString(name) {
13
+ try {
14
+ const v = ownershipScope()[name];
15
+ return typeof v === "string" && v.length > 0 ? v : null;
16
+ } catch {
17
+ return null;
18
+ }
19
+ }
20
+ function getInjectedHost() {
21
+ try {
22
+ return ownershipScope()[INJECTED_HOST_GLOBAL] ?? null;
23
+ } catch {
24
+ return null;
25
+ }
26
+ }
27
+ function readForcedOwner() {
28
+ return readOwnerString(FORCE_OWNER_GLOBAL);
29
+ }
30
+ function readOwner() {
31
+ return readOwnerString(OWNER_GLOBAL);
32
+ }
33
+ function isForcedOwner() {
34
+ return readForcedOwner() != null;
35
+ }
5
36
 
37
+ exports.FORCE_OWNER_GLOBAL = FORCE_OWNER_GLOBAL;
6
38
  exports.HOST_API_VERSION = HOST_API_VERSION;
39
+ exports.INJECTED_HOST_GLOBAL = INJECTED_HOST_GLOBAL;
40
+ exports.OWNER_GLOBAL = OWNER_GLOBAL;
41
+ exports.getInjectedHost = getInjectedHost;
42
+ exports.isForcedOwner = isForcedOwner;
43
+ exports.readForcedOwner = readForcedOwner;
44
+ exports.readOwner = readOwner;
package/dist/index.d.cts CHANGED
@@ -243,6 +243,25 @@ interface HostApi {
243
243
  * apply an update themselves (see `HostUpdates`). */
244
244
  readonly updates?: HostUpdates;
245
245
  }
246
+ /** An owner label is an opaque, host-chosen string; the contract never enumerates
247
+ concrete names (that would bake a host/loader identity into the boundary). */
248
+ type HostOwnerKind = string;
249
+ /** Renderer global NAMES (augmented on `Window` below). */
250
+ declare const INJECTED_HOST_GLOBAL: "__SHELVES_HOST__";
251
+ declare const FORCE_OWNER_GLOBAL: "__SHELVES_FORCE_OWNER__";
252
+ declare const OWNER_GLOBAL: "__DECK_SHELVES_OWNER__";
253
+ /** The injected host runtime, or null when no neutral host is present. */
254
+ declare function getInjectedHost(): ShelvesHostGlobal | null;
255
+ /** The forced-owner label a host stamped, or null when none. */
256
+ declare function readForcedOwner(): string | null;
257
+ /** The renderer's single-owner claim, or null when still unclaimed. */
258
+ declare function readOwner(): string | null;
259
+ /** True when a host stamped a forced-owner claim. Only the injected neutral host
260
+ does this, so `isForcedOwner() && getInjectedHost()` means "the injected host
261
+ was forced to own" (cooperative ownership) without naming any host: the loader
262
+ keeps the renderer + its other plugins, and the bundle binds to the injected
263
+ host — waiting via {@link getInjectedHost} if the loader booted it first. */
264
+ declare function isForcedOwner(): boolean;
246
265
  /** Shape of the runtime global the host installs in the renderer. */
247
266
  type ShelvesHostGlobal = HostApi;
248
267
  declare global {
@@ -278,7 +297,23 @@ declare global {
278
297
  * both vanishing. Unset means no host has claimed the tab.
279
298
  */
280
299
  __SHELVES_QAM_OWNER__?: string;
300
+ /**
301
+ * Forced-owner handshake. A host stamps its own (opaque) owner label here to
302
+ * claim the renderer even alongside a loader (cooperative ownership): the
303
+ * loader keeps owning the renderer and its other plugins, but the bundle binds
304
+ * to the injected host (`__SHELVES_HOST__`) — waiting for it to appear if the
305
+ * loader booted the bundle first — instead of the loader that launched it.
306
+ * Only the injected host stamps this, so presence (not the label's value) is
307
+ * what the bundle keys on.
308
+ */
309
+ __SHELVES_FORCE_OWNER__?: HostOwnerKind;
310
+ /**
311
+ * The renderer's single-owner claim. The first host/bundle to claim writes
312
+ * its kind; a second instance reads it and stands down (no home patch, no
313
+ * settings writes) so there is exactly one injector and one writer.
314
+ */
315
+ __DECK_SHELVES_OWNER__?: HostOwnerKind;
281
316
  }
282
317
  }
283
318
 
284
- export { type Disposable, HOST_API_VERSION, type HostApi, type HostLifecycle, type HostMainMenu, type HostNotifications, type HostQam, type HostRoutes, type HostRpc, type HostUi, type HostUpdates, type MainMenuEntry, type PlatformApi, type PlatformAppMeta, type PlatformCollection, type PlatformTab, type PluginDescriptor, type QamPanel, type ShelfSource, type ShelvesHostGlobal, type ToastOptions };
319
+ export { type Disposable, FORCE_OWNER_GLOBAL, HOST_API_VERSION, type HostApi, type HostLifecycle, type HostMainMenu, type HostNotifications, type HostOwnerKind, type HostQam, type HostRoutes, type HostRpc, type HostUi, type HostUpdates, INJECTED_HOST_GLOBAL, type MainMenuEntry, OWNER_GLOBAL, type PlatformApi, type PlatformAppMeta, type PlatformCollection, type PlatformTab, type PluginDescriptor, type QamPanel, type ShelfSource, type ShelvesHostGlobal, type ToastOptions, getInjectedHost, isForcedOwner, readForcedOwner, readOwner };
package/dist/index.d.ts CHANGED
@@ -243,6 +243,25 @@ interface HostApi {
243
243
  * apply an update themselves (see `HostUpdates`). */
244
244
  readonly updates?: HostUpdates;
245
245
  }
246
+ /** An owner label is an opaque, host-chosen string; the contract never enumerates
247
+ concrete names (that would bake a host/loader identity into the boundary). */
248
+ type HostOwnerKind = string;
249
+ /** Renderer global NAMES (augmented on `Window` below). */
250
+ declare const INJECTED_HOST_GLOBAL: "__SHELVES_HOST__";
251
+ declare const FORCE_OWNER_GLOBAL: "__SHELVES_FORCE_OWNER__";
252
+ declare const OWNER_GLOBAL: "__DECK_SHELVES_OWNER__";
253
+ /** The injected host runtime, or null when no neutral host is present. */
254
+ declare function getInjectedHost(): ShelvesHostGlobal | null;
255
+ /** The forced-owner label a host stamped, or null when none. */
256
+ declare function readForcedOwner(): string | null;
257
+ /** The renderer's single-owner claim, or null when still unclaimed. */
258
+ declare function readOwner(): string | null;
259
+ /** True when a host stamped a forced-owner claim. Only the injected neutral host
260
+ does this, so `isForcedOwner() && getInjectedHost()` means "the injected host
261
+ was forced to own" (cooperative ownership) without naming any host: the loader
262
+ keeps the renderer + its other plugins, and the bundle binds to the injected
263
+ host — waiting via {@link getInjectedHost} if the loader booted it first. */
264
+ declare function isForcedOwner(): boolean;
246
265
  /** Shape of the runtime global the host installs in the renderer. */
247
266
  type ShelvesHostGlobal = HostApi;
248
267
  declare global {
@@ -278,7 +297,23 @@ declare global {
278
297
  * both vanishing. Unset means no host has claimed the tab.
279
298
  */
280
299
  __SHELVES_QAM_OWNER__?: string;
300
+ /**
301
+ * Forced-owner handshake. A host stamps its own (opaque) owner label here to
302
+ * claim the renderer even alongside a loader (cooperative ownership): the
303
+ * loader keeps owning the renderer and its other plugins, but the bundle binds
304
+ * to the injected host (`__SHELVES_HOST__`) — waiting for it to appear if the
305
+ * loader booted the bundle first — instead of the loader that launched it.
306
+ * Only the injected host stamps this, so presence (not the label's value) is
307
+ * what the bundle keys on.
308
+ */
309
+ __SHELVES_FORCE_OWNER__?: HostOwnerKind;
310
+ /**
311
+ * The renderer's single-owner claim. The first host/bundle to claim writes
312
+ * its kind; a second instance reads it and stands down (no home patch, no
313
+ * settings writes) so there is exactly one injector and one writer.
314
+ */
315
+ __DECK_SHELVES_OWNER__?: HostOwnerKind;
281
316
  }
282
317
  }
283
318
 
284
- export { type Disposable, HOST_API_VERSION, type HostApi, type HostLifecycle, type HostMainMenu, type HostNotifications, type HostQam, type HostRoutes, type HostRpc, type HostUi, type HostUpdates, type MainMenuEntry, type PlatformApi, type PlatformAppMeta, type PlatformCollection, type PlatformTab, type PluginDescriptor, type QamPanel, type ShelfSource, type ShelvesHostGlobal, type ToastOptions };
319
+ export { type Disposable, FORCE_OWNER_GLOBAL, HOST_API_VERSION, type HostApi, type HostLifecycle, type HostMainMenu, type HostNotifications, type HostOwnerKind, type HostQam, type HostRoutes, type HostRpc, type HostUi, type HostUpdates, INJECTED_HOST_GLOBAL, type MainMenuEntry, OWNER_GLOBAL, type PlatformApi, type PlatformAppMeta, type PlatformCollection, type PlatformTab, type PluginDescriptor, type QamPanel, type ShelfSource, type ShelvesHostGlobal, type ToastOptions, getInjectedHost, isForcedOwner, readForcedOwner, readOwner };
package/dist/index.js CHANGED
@@ -1,4 +1,35 @@
1
1
  // src/contract/index.ts
2
2
  var HOST_API_VERSION = "1.2.0";
3
+ var INJECTED_HOST_GLOBAL = "__SHELVES_HOST__";
4
+ var FORCE_OWNER_GLOBAL = "__SHELVES_FORCE_OWNER__";
5
+ var OWNER_GLOBAL = "__DECK_SHELVES_OWNER__";
6
+ function ownershipScope() {
7
+ const g = globalThis;
8
+ return g.window ?? g;
9
+ }
10
+ function readOwnerString(name) {
11
+ try {
12
+ const v = ownershipScope()[name];
13
+ return typeof v === "string" && v.length > 0 ? v : null;
14
+ } catch {
15
+ return null;
16
+ }
17
+ }
18
+ function getInjectedHost() {
19
+ try {
20
+ return ownershipScope()[INJECTED_HOST_GLOBAL] ?? null;
21
+ } catch {
22
+ return null;
23
+ }
24
+ }
25
+ function readForcedOwner() {
26
+ return readOwnerString(FORCE_OWNER_GLOBAL);
27
+ }
28
+ function readOwner() {
29
+ return readOwnerString(OWNER_GLOBAL);
30
+ }
31
+ function isForcedOwner() {
32
+ return readForcedOwner() != null;
33
+ }
3
34
 
4
- export { HOST_API_VERSION };
35
+ export { FORCE_OWNER_GLOBAL, HOST_API_VERSION, INJECTED_HOST_GLOBAL, OWNER_GLOBAL, getInjectedHost, isForcedOwner, readForcedOwner, readOwner };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deck-shelves/host",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "Deck Shelves host contract — the HostApi types all host adapters and the bundle build against.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",