@deck-shelves/host 1.3.2 → 1.4.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.
package/dist/index.d.cts CHANGED
@@ -38,6 +38,14 @@ interface HostLifecycle {
38
38
  register(plugin: PluginDescriptor): Disposable;
39
39
  onMount(cb: () => void): void;
40
40
  onUnmount(cb: () => void): void;
41
+ /**
42
+ * Dispose the CURRENT bundle instance: runs every `onUnmount` handler once and
43
+ * clears them. The host calls this before it hot-swaps a new bundle in place, so
44
+ * two instances never both own the Home. Optional (feature-detected) — a bundle
45
+ * needing clean re-eval should register real teardown in `onUnmount`.
46
+ * Returns the number of handlers run.
47
+ */
48
+ teardown?(): number;
41
49
  }
42
50
  /** Generic RPC channel into the host backend. Each host routes it to the
43
51
  * plugin's data backend through its own transport (an in-process bridge, a
@@ -242,6 +250,22 @@ interface HostApi {
242
250
  /** Optional self-update surface; present only on hosts that can obtain and
243
251
  * apply an update themselves (see `HostUpdates`). */
244
252
  readonly updates?: HostUpdates;
253
+ /** Optional handshake: identifies the host and the capabilities it implements,
254
+ * so a bundle can adapt (and skip feature-detecting each member). Present on
255
+ * hosts that support it; absent hosts are read via direct feature detection. */
256
+ handshake?(): HostHandshake;
257
+ }
258
+ /** What {@link HostApi.handshake} reports: who is hosting, its versions, and a
259
+ * flat map of capability flags the bundle can branch on. `hostKind` is an opaque
260
+ * host-chosen label (see {@link HostOwnerKind}); the contract names no host. */
261
+ interface HostHandshake {
262
+ readonly hostKind: HostOwnerKind;
263
+ /** The host's own product version (e.g. the daemon version). */
264
+ readonly hostVersion: string;
265
+ /** The contract version the host implements ({@link HOST_API_VERSION}). */
266
+ readonly hostApiVersion: string;
267
+ /** Feature flags, e.g. `{ teardown: true, selfUpdate: true, nativeQam: true }`. */
268
+ readonly capabilities: Readonly<Record<string, boolean>>;
245
269
  }
246
270
  /** An owner label is an opaque, host-chosen string; the contract never enumerates
247
271
  concrete names (that would bake a host/loader identity into the boundary). */
@@ -324,4 +348,4 @@ declare global {
324
348
  }
325
349
  }
326
350
 
327
- export { type Disposable, FORCE_OWNER_GLOBAL, HOST_API_VERSION, type HostApi, type HostLifecycle, type HostMainMenu, type HostNotifications, type HostOwnerKind, type HostOwnerMetadata, type HostQam, type HostRoutes, type HostRpc, type HostUi, type HostUpdates, INJECTED_HOST_GLOBAL, type MainMenuEntry, OWNER_GLOBAL, OWNER_METADATA_GLOBAL, type PlatformApi, type PlatformAppMeta, type PlatformCollection, type PlatformTab, type PluginDescriptor, type QamPanel, type ShelfSource, type ShelvesHostGlobal, type ToastOptions, getInjectedHost, isForcedOwner, readForcedOwner, readOwner };
351
+ export { type Disposable, FORCE_OWNER_GLOBAL, HOST_API_VERSION, type HostApi, type HostHandshake, type HostLifecycle, type HostMainMenu, type HostNotifications, type HostOwnerKind, type HostOwnerMetadata, type HostQam, type HostRoutes, type HostRpc, type HostUi, type HostUpdates, INJECTED_HOST_GLOBAL, type MainMenuEntry, OWNER_GLOBAL, OWNER_METADATA_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
@@ -38,6 +38,14 @@ interface HostLifecycle {
38
38
  register(plugin: PluginDescriptor): Disposable;
39
39
  onMount(cb: () => void): void;
40
40
  onUnmount(cb: () => void): void;
41
+ /**
42
+ * Dispose the CURRENT bundle instance: runs every `onUnmount` handler once and
43
+ * clears them. The host calls this before it hot-swaps a new bundle in place, so
44
+ * two instances never both own the Home. Optional (feature-detected) — a bundle
45
+ * needing clean re-eval should register real teardown in `onUnmount`.
46
+ * Returns the number of handlers run.
47
+ */
48
+ teardown?(): number;
41
49
  }
42
50
  /** Generic RPC channel into the host backend. Each host routes it to the
43
51
  * plugin's data backend through its own transport (an in-process bridge, a
@@ -242,6 +250,22 @@ interface HostApi {
242
250
  /** Optional self-update surface; present only on hosts that can obtain and
243
251
  * apply an update themselves (see `HostUpdates`). */
244
252
  readonly updates?: HostUpdates;
253
+ /** Optional handshake: identifies the host and the capabilities it implements,
254
+ * so a bundle can adapt (and skip feature-detecting each member). Present on
255
+ * hosts that support it; absent hosts are read via direct feature detection. */
256
+ handshake?(): HostHandshake;
257
+ }
258
+ /** What {@link HostApi.handshake} reports: who is hosting, its versions, and a
259
+ * flat map of capability flags the bundle can branch on. `hostKind` is an opaque
260
+ * host-chosen label (see {@link HostOwnerKind}); the contract names no host. */
261
+ interface HostHandshake {
262
+ readonly hostKind: HostOwnerKind;
263
+ /** The host's own product version (e.g. the daemon version). */
264
+ readonly hostVersion: string;
265
+ /** The contract version the host implements ({@link HOST_API_VERSION}). */
266
+ readonly hostApiVersion: string;
267
+ /** Feature flags, e.g. `{ teardown: true, selfUpdate: true, nativeQam: true }`. */
268
+ readonly capabilities: Readonly<Record<string, boolean>>;
245
269
  }
246
270
  /** An owner label is an opaque, host-chosen string; the contract never enumerates
247
271
  concrete names (that would bake a host/loader identity into the boundary). */
@@ -324,4 +348,4 @@ declare global {
324
348
  }
325
349
  }
326
350
 
327
- export { type Disposable, FORCE_OWNER_GLOBAL, HOST_API_VERSION, type HostApi, type HostLifecycle, type HostMainMenu, type HostNotifications, type HostOwnerKind, type HostOwnerMetadata, type HostQam, type HostRoutes, type HostRpc, type HostUi, type HostUpdates, INJECTED_HOST_GLOBAL, type MainMenuEntry, OWNER_GLOBAL, OWNER_METADATA_GLOBAL, type PlatformApi, type PlatformAppMeta, type PlatformCollection, type PlatformTab, type PluginDescriptor, type QamPanel, type ShelfSource, type ShelvesHostGlobal, type ToastOptions, getInjectedHost, isForcedOwner, readForcedOwner, readOwner };
351
+ export { type Disposable, FORCE_OWNER_GLOBAL, HOST_API_VERSION, type HostApi, type HostHandshake, type HostLifecycle, type HostMainMenu, type HostNotifications, type HostOwnerKind, type HostOwnerMetadata, type HostQam, type HostRoutes, type HostRpc, type HostUi, type HostUpdates, INJECTED_HOST_GLOBAL, type MainMenuEntry, OWNER_GLOBAL, OWNER_METADATA_GLOBAL, type PlatformApi, type PlatformAppMeta, type PlatformCollection, type PlatformTab, type PluginDescriptor, type QamPanel, type ShelfSource, type ShelvesHostGlobal, type ToastOptions, getInjectedHost, isForcedOwner, readForcedOwner, readOwner };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deck-shelves/host",
3
- "version": "1.3.2",
3
+ "version": "1.4.0",
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",