@deck-shelves/host 1.2.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/README.md +5 -3
- package/dist/index.cjs +39 -1
- package/dist/index.d.cts +90 -4
- package/dist/index.d.ts +90 -4
- package/dist/index.js +33 -2
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -11,13 +11,15 @@
|
|
|
11
11
|
[](https://www.npmjs.com/package/@deck-shelves/host)
|
|
12
12
|
[](https://www.npmjs.com/package/@deck-shelves/host)
|
|
13
13
|
[](https://www.npmjs.com/package/@deck-shelves/host)
|
|
14
|
-
[](src/contract/index.test.ts)
|
|
15
15
|
[](src/contract/index.ts)
|
|
16
16
|
[](https://bundlephobia.com/package/@deck-shelves/host)
|
|
17
17
|
[](LICENSE)
|
|
18
18
|
[](package.json)
|
|
19
|
-
[](https://github.com/ValveSoftware/SteamOS)
|
|
19
|
+
[](https://github.com/ValveSoftware/SteamOS)
|
|
20
20
|
[](https://github.com/santojon/Deck-Shelves)
|
|
21
|
+
[](https://github.com/santojon/Deck-Shelves-HOST/network/members)
|
|
22
|
+
[](https://github.com/santojon/Deck-Shelves-HOST/graphs/traffic)
|
|
21
23
|
[](https://github.com/sponsors/santojon)
|
|
22
24
|
[](https://ko-fi.com/santojon)
|
|
23
25
|
|
|
@@ -51,7 +53,7 @@ host↔bundle contract, a different audience.
|
|
|
51
53
|
|
|
52
54
|
| Path | What it is |
|
|
53
55
|
|---|---|
|
|
54
|
-
| `src/contract/` | **`HostApi` types** (`HOST_API_VERSION`, `lifecycle`, `rpc`, `ui`, `routes`, `notifications`, `platform`, optional `qam`). The single source of truth both hosts and the bundle build against. |
|
|
56
|
+
| `src/contract/` | **`HostApi` types** (`HOST_API_VERSION`, `lifecycle`, `rpc`, `ui`, `routes`, `notifications`, `platform`, optional `React`/`ReactDOM`/`jsx`, `qam`, `mainMenu`, `updates`). The single source of truth both hosts and the bundle build against. |
|
|
55
57
|
|
|
56
58
|
## Usage
|
|
57
59
|
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,44 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
// src/contract/index.ts
|
|
4
|
-
var HOST_API_VERSION = "1.
|
|
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
|
@@ -6,16 +6,26 @@
|
|
|
6
6
|
* adapter fulfils this shape, so the bundle's call sites depend only on it
|
|
7
7
|
* and never on a specific host's UI library directly.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
9
|
+
* Optional capabilities are additive members a host implements *if it can* and
|
|
10
|
+
* the bundle feature-detects:
|
|
11
11
|
* - `qam` — a Quick Access Menu tab.
|
|
12
12
|
* - `mainMenu` — an entry in the Steam Main Menu / left rail.
|
|
13
|
+
* - `updates` — self-install of plugin updates (see `HostUpdates`).
|
|
14
|
+
* - `React` / `ReactDOM` / `jsx` — the host's React stack, so the bundle's
|
|
15
|
+
* react shims can resolve React from the host instead of a loader global.
|
|
13
16
|
* The contract names no concrete host; a host may implement any, all, or none.
|
|
14
17
|
*
|
|
15
18
|
* Dependency-free by design (mirrors `@deck-shelves/api`): supporting data
|
|
16
19
|
* types are inlined.
|
|
17
20
|
*/
|
|
18
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Compatibility version of the contract SHAPE — independent of this package's
|
|
23
|
+
* npm release version. Bump semver here on shape changes: MINOR for additive,
|
|
24
|
+
* backward-compatible members (a new optional namespace / field); MAJOR on a
|
|
25
|
+
* breaking change. 1.2.0 added the optional `updates` namespace and the
|
|
26
|
+
* optional `React`/`ReactDOM`/`jsx` UI-surface members.
|
|
27
|
+
*/
|
|
28
|
+
declare const HOST_API_VERSION: "1.2.0";
|
|
19
29
|
interface PluginDescriptor {
|
|
20
30
|
name: string;
|
|
21
31
|
version: string;
|
|
@@ -177,6 +187,20 @@ interface HostMainMenu {
|
|
|
177
187
|
*/
|
|
178
188
|
registerEntry(entry: MainMenuEntry): () => void;
|
|
179
189
|
}
|
|
190
|
+
/** Optional: a host that can obtain + apply plugin updates itself (no manual
|
|
191
|
+
* file install). A loader that can only hand the user a file does NOT implement
|
|
192
|
+
* this — the bundle then falls back to the manual download flow. */
|
|
193
|
+
interface HostUpdates {
|
|
194
|
+
/** True if this host can self-install (drives the button: "Install" vs "Download"). */
|
|
195
|
+
canSelfInstall(): boolean;
|
|
196
|
+
/** Obtain the release and swap it in, then reload. `assetUrl`/`assetName` point
|
|
197
|
+
* at the bundle artifact the host injects (the IIFE). */
|
|
198
|
+
applyUpdate(release: {
|
|
199
|
+
version: string;
|
|
200
|
+
assetUrl?: string;
|
|
201
|
+
assetName?: string;
|
|
202
|
+
}): Promise<void>;
|
|
203
|
+
}
|
|
180
204
|
/**
|
|
181
205
|
* What the host process provides to the Deck Shelves bundle. The bundle receives
|
|
182
206
|
* this at startup as `window.__SHELVES_HOST__` and uses it to register itself,
|
|
@@ -195,6 +219,18 @@ interface HostApi {
|
|
|
195
219
|
readonly lifecycle: HostLifecycle;
|
|
196
220
|
readonly rpc: HostRpc;
|
|
197
221
|
readonly ui: HostUi;
|
|
222
|
+
/**
|
|
223
|
+
* Steam's React stack, exposed so a bundle's `react` / `react-dom` /
|
|
224
|
+
* `jsx-runtime` shims can resolve React from the host instead of from
|
|
225
|
+
* loader-published globals — the path a *sole* host (no loader) needs, since
|
|
226
|
+
* no loader is present to publish them. Kept dependency-free: cast to
|
|
227
|
+
* `React` / `ReactDOM` / the jsx-runtime at the call site, as with {@link HostUi}.
|
|
228
|
+
* Optional — a loader-backed host may omit them and let the bundle fall back to
|
|
229
|
+
* the loader's own React globals.
|
|
230
|
+
*/
|
|
231
|
+
readonly React?: unknown;
|
|
232
|
+
readonly ReactDOM?: unknown;
|
|
233
|
+
readonly jsx?: unknown;
|
|
198
234
|
readonly routes: HostRoutes;
|
|
199
235
|
readonly notifications?: HostNotifications;
|
|
200
236
|
readonly platform: PlatformApi;
|
|
@@ -203,7 +239,29 @@ interface HostApi {
|
|
|
203
239
|
/** Optional Main Menu (left-rail) surface; present only on hosts that
|
|
204
240
|
* support it. Injected/shown only while it has content (see `HostMainMenu`). */
|
|
205
241
|
readonly mainMenu?: HostMainMenu;
|
|
242
|
+
/** Optional self-update surface; present only on hosts that can obtain and
|
|
243
|
+
* apply an update themselves (see `HostUpdates`). */
|
|
244
|
+
readonly updates?: HostUpdates;
|
|
206
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;
|
|
207
265
|
/** Shape of the runtime global the host installs in the renderer. */
|
|
208
266
|
type ShelvesHostGlobal = HostApi;
|
|
209
267
|
declare global {
|
|
@@ -227,7 +285,35 @@ declare global {
|
|
|
227
285
|
* `__SHELVES_QAM__`. Equivalent to calling `registerPanel` for each.
|
|
228
286
|
*/
|
|
229
287
|
__SHELVES_QAM_PENDING__?: QamPanel[];
|
|
288
|
+
/**
|
|
289
|
+
* Tab-ownership handshake. A host stamps this with its owner kind (e.g.
|
|
290
|
+
* `"shelveshub"`) the moment its own Deck Shelves QAM tab is actually
|
|
291
|
+
* inserted into the strip — NOT when `__SHELVES_QAM__` is first created
|
|
292
|
+
* (that happens at boot, before any tab exists). A bundle running under a
|
|
293
|
+
* different loader that also renders its own native tab retracts it once
|
|
294
|
+
* this is set, so exactly one Deck Shelves tab survives and it is the
|
|
295
|
+
* host's. Because it is stamped only on real insertion, a host that never
|
|
296
|
+
* inserts leaves the bundle's own tab in place as the fallback rather than
|
|
297
|
+
* both vanishing. Unset means no host has claimed the tab.
|
|
298
|
+
*/
|
|
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;
|
|
230
316
|
}
|
|
231
317
|
}
|
|
232
318
|
|
|
233
|
-
export { type Disposable, HOST_API_VERSION, type HostApi, type HostLifecycle, type HostMainMenu, type HostNotifications, type HostQam, type HostRoutes, type HostRpc, type HostUi, 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
|
@@ -6,16 +6,26 @@
|
|
|
6
6
|
* adapter fulfils this shape, so the bundle's call sites depend only on it
|
|
7
7
|
* and never on a specific host's UI library directly.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
9
|
+
* Optional capabilities are additive members a host implements *if it can* and
|
|
10
|
+
* the bundle feature-detects:
|
|
11
11
|
* - `qam` — a Quick Access Menu tab.
|
|
12
12
|
* - `mainMenu` — an entry in the Steam Main Menu / left rail.
|
|
13
|
+
* - `updates` — self-install of plugin updates (see `HostUpdates`).
|
|
14
|
+
* - `React` / `ReactDOM` / `jsx` — the host's React stack, so the bundle's
|
|
15
|
+
* react shims can resolve React from the host instead of a loader global.
|
|
13
16
|
* The contract names no concrete host; a host may implement any, all, or none.
|
|
14
17
|
*
|
|
15
18
|
* Dependency-free by design (mirrors `@deck-shelves/api`): supporting data
|
|
16
19
|
* types are inlined.
|
|
17
20
|
*/
|
|
18
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Compatibility version of the contract SHAPE — independent of this package's
|
|
23
|
+
* npm release version. Bump semver here on shape changes: MINOR for additive,
|
|
24
|
+
* backward-compatible members (a new optional namespace / field); MAJOR on a
|
|
25
|
+
* breaking change. 1.2.0 added the optional `updates` namespace and the
|
|
26
|
+
* optional `React`/`ReactDOM`/`jsx` UI-surface members.
|
|
27
|
+
*/
|
|
28
|
+
declare const HOST_API_VERSION: "1.2.0";
|
|
19
29
|
interface PluginDescriptor {
|
|
20
30
|
name: string;
|
|
21
31
|
version: string;
|
|
@@ -177,6 +187,20 @@ interface HostMainMenu {
|
|
|
177
187
|
*/
|
|
178
188
|
registerEntry(entry: MainMenuEntry): () => void;
|
|
179
189
|
}
|
|
190
|
+
/** Optional: a host that can obtain + apply plugin updates itself (no manual
|
|
191
|
+
* file install). A loader that can only hand the user a file does NOT implement
|
|
192
|
+
* this — the bundle then falls back to the manual download flow. */
|
|
193
|
+
interface HostUpdates {
|
|
194
|
+
/** True if this host can self-install (drives the button: "Install" vs "Download"). */
|
|
195
|
+
canSelfInstall(): boolean;
|
|
196
|
+
/** Obtain the release and swap it in, then reload. `assetUrl`/`assetName` point
|
|
197
|
+
* at the bundle artifact the host injects (the IIFE). */
|
|
198
|
+
applyUpdate(release: {
|
|
199
|
+
version: string;
|
|
200
|
+
assetUrl?: string;
|
|
201
|
+
assetName?: string;
|
|
202
|
+
}): Promise<void>;
|
|
203
|
+
}
|
|
180
204
|
/**
|
|
181
205
|
* What the host process provides to the Deck Shelves bundle. The bundle receives
|
|
182
206
|
* this at startup as `window.__SHELVES_HOST__` and uses it to register itself,
|
|
@@ -195,6 +219,18 @@ interface HostApi {
|
|
|
195
219
|
readonly lifecycle: HostLifecycle;
|
|
196
220
|
readonly rpc: HostRpc;
|
|
197
221
|
readonly ui: HostUi;
|
|
222
|
+
/**
|
|
223
|
+
* Steam's React stack, exposed so a bundle's `react` / `react-dom` /
|
|
224
|
+
* `jsx-runtime` shims can resolve React from the host instead of from
|
|
225
|
+
* loader-published globals — the path a *sole* host (no loader) needs, since
|
|
226
|
+
* no loader is present to publish them. Kept dependency-free: cast to
|
|
227
|
+
* `React` / `ReactDOM` / the jsx-runtime at the call site, as with {@link HostUi}.
|
|
228
|
+
* Optional — a loader-backed host may omit them and let the bundle fall back to
|
|
229
|
+
* the loader's own React globals.
|
|
230
|
+
*/
|
|
231
|
+
readonly React?: unknown;
|
|
232
|
+
readonly ReactDOM?: unknown;
|
|
233
|
+
readonly jsx?: unknown;
|
|
198
234
|
readonly routes: HostRoutes;
|
|
199
235
|
readonly notifications?: HostNotifications;
|
|
200
236
|
readonly platform: PlatformApi;
|
|
@@ -203,7 +239,29 @@ interface HostApi {
|
|
|
203
239
|
/** Optional Main Menu (left-rail) surface; present only on hosts that
|
|
204
240
|
* support it. Injected/shown only while it has content (see `HostMainMenu`). */
|
|
205
241
|
readonly mainMenu?: HostMainMenu;
|
|
242
|
+
/** Optional self-update surface; present only on hosts that can obtain and
|
|
243
|
+
* apply an update themselves (see `HostUpdates`). */
|
|
244
|
+
readonly updates?: HostUpdates;
|
|
206
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;
|
|
207
265
|
/** Shape of the runtime global the host installs in the renderer. */
|
|
208
266
|
type ShelvesHostGlobal = HostApi;
|
|
209
267
|
declare global {
|
|
@@ -227,7 +285,35 @@ declare global {
|
|
|
227
285
|
* `__SHELVES_QAM__`. Equivalent to calling `registerPanel` for each.
|
|
228
286
|
*/
|
|
229
287
|
__SHELVES_QAM_PENDING__?: QamPanel[];
|
|
288
|
+
/**
|
|
289
|
+
* Tab-ownership handshake. A host stamps this with its owner kind (e.g.
|
|
290
|
+
* `"shelveshub"`) the moment its own Deck Shelves QAM tab is actually
|
|
291
|
+
* inserted into the strip — NOT when `__SHELVES_QAM__` is first created
|
|
292
|
+
* (that happens at boot, before any tab exists). A bundle running under a
|
|
293
|
+
* different loader that also renders its own native tab retracts it once
|
|
294
|
+
* this is set, so exactly one Deck Shelves tab survives and it is the
|
|
295
|
+
* host's. Because it is stamped only on real insertion, a host that never
|
|
296
|
+
* inserts leaves the bundle's own tab in place as the fallback rather than
|
|
297
|
+
* both vanishing. Unset means no host has claimed the tab.
|
|
298
|
+
*/
|
|
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;
|
|
230
316
|
}
|
|
231
317
|
}
|
|
232
318
|
|
|
233
|
-
export { type Disposable, HOST_API_VERSION, type HostApi, type HostLifecycle, type HostMainMenu, type HostNotifications, type HostQam, type HostRoutes, type HostRpc, type HostUi, 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
|
-
var HOST_API_VERSION = "1.
|
|
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
|
+
"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",
|
|
@@ -75,12 +75,12 @@
|
|
|
75
75
|
}
|
|
76
76
|
},
|
|
77
77
|
"devDependencies": {
|
|
78
|
-
"@typescript-eslint/parser": "^8.
|
|
78
|
+
"@typescript-eslint/parser": "^8.70.0",
|
|
79
79
|
"eslint": "^9.39.5",
|
|
80
80
|
"jsdom": "^25.0.1",
|
|
81
81
|
"tsup": "^8.5.1",
|
|
82
82
|
"typescript": "^5.9.3",
|
|
83
|
-
"vitest": "^
|
|
83
|
+
"vitest": "^4.1.11"
|
|
84
84
|
},
|
|
85
85
|
"packageManager": "pnpm@10.33.0"
|
|
86
86
|
}
|