@dimina-kit/electron-deck 0.1.0-dev.20260618090552 → 0.1.0-dev.20260624084417

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.
@@ -363,7 +363,7 @@ function createCapabilityRegistry() {
363
363
  //#endregion
364
364
  //#region src/internal/wire-transport.ts
365
365
  /**
366
- * WireTransport — main 端的真 Electron wire 桥接(Phase 3b)。
366
+ * WireTransport — main 端的真 Electron wire 桥接。
367
367
  *
368
368
  * 责任:
369
369
  * - 在 `ipcMain.handle('__electron-deck:invoke')` / `'__electron-deck:probe'` 上路由
@@ -388,7 +388,7 @@ var DECK_CODE = {
388
388
  UntrustedFrame: "DECK_UNTRUSTED_FRAME",
389
389
  UnknownKind: "DECK_UNKNOWN_KIND",
390
390
  BadRequest: "DECK_BAD_REQUEST",
391
- /** P4 Phase B — the grant gate denied a privileged command for this sender. */
391
+ /** The grant gate denied a privileged command for this sender. */
392
392
  Forbidden: "DECK_FORBIDDEN"
393
393
  };
394
394
  var WireTransport = class {
@@ -766,8 +766,8 @@ var DEFAULT_MAIN_WIDTH = 1024;
766
766
  var DEFAULT_MAIN_HEIGHT = 768;
767
767
  /**
768
768
  * Framework-internal "app" object —— `electronDeck(config)` 顶层入口的 plain-class
769
- * 形态,便于 Phase 2 测试驱动 lifecycle 转换。Phase 3b 加 wireTransport 注入
770
- * 后可接真 ipcMain;Phase 4 加 electron 注入后可装配 mainWindow / toolbarView
769
+ * 形态,便于测试驱动 lifecycle 转换。加 wireTransport 注入
770
+ * 后可接真 ipcMain;加 electron 注入后可装配 mainWindow / toolbarView
771
771
  * / declared windows。两者都不注入时退化为同进程内存 fake。
772
772
  *
773
773
  * @internal
@@ -780,21 +780,21 @@ var DeckApp = class {
780
780
  ipc = new InMemoryTypedIpcRegistry();
781
781
  fwListeners = /* @__PURE__ */ new Map();
782
782
  trustSet = createTrustSet();
783
- /** P4 Phase B — privileged-command grant registry. The policy gates
783
+ /** Privileged-command grant registry. The policy gates
784
784
  * ControlBus.dispatch; grants are minted via `runtime.grants.issue`. */
785
785
  capability = createCapabilityRegistry();
786
- /** P4 Phase B — the grant-gated command bus for PRIVILEGED `layout.*`
786
+ /** The grant-gated command bus for PRIVILEGED `layout.*`
787
787
  * commands. Constructed in `bindWireTransport` with the capability policy
788
788
  * injected, so `dispatch` default-DENIES any command lacking a live grant.
789
789
  * Privileged commands are registered via `runtime.layout.command`; ordinary
790
790
  * domain APIs stay on the un-gated `InMemoryTypedIpcRegistry`. */
791
791
  controlBus = null;
792
- /** v2 — per-webContents backend `onWindowTrusted` Disposable, so a window's
792
+ /** Per-webContents backend `onWindowTrusted` Disposable, so a window's
793
793
  * trust mirror is undone when THAT window closes (not only at teardown). */
794
794
  backendTrustDisposables = /* @__PURE__ */ new Map();
795
795
  options;
796
796
  wireTransport = null;
797
- /** v2 — the live wire senderPolicy, reused by buildRuntime so
797
+ /** The live wire senderPolicy, reused by buildRuntime so
798
798
  * `context._senderPolicy` reflects real trust instead of a `() => true` stub. */
799
799
  wireSenderPolicy = null;
800
800
  mainWindow = null;
@@ -802,23 +802,19 @@ var DeckApp = class {
802
802
  declaredWindows = /* @__PURE__ */ new Map();
803
803
  trackedWindows = /* @__PURE__ */ new Set();
804
804
  /**
805
- * unified-lifetime P0 (observation-only, zero-regression). The root lifetime
806
- * scope of the app + a shadow map mirroring `trackedWindows`, keyed by each
807
- * window's webContents, carrying a per-window child Scope. P0 is PURELY
808
- * OBSERVATIONAL: these windowScopes own NO resources (no destroy/trust/wire is
809
- * moved onto them), so `rootScope.close()` during shutdown is a no-op for app
810
- * behaviour — it exists only to lay the foundation P1 will take over. The
805
+ * The root lifetime scope of the app + a shadow map mirroring `trackedWindows`,
806
+ * keyed by each window's webContents, carrying a per-window child Scope. The
811
807
  * shadow's key set is kept in lock-step with `trackedWindows` at every
812
808
  * maintenance point.
813
809
  */
814
810
  rootScope = createScope();
815
811
  lifetimeShadow = /* @__PURE__ */ new Map();
816
812
  /**
817
- * unified-lifetime P1b: per-trusted-webContents trust record. `wcScope` is a
813
+ * Per-trusted-webContents trust record. `wcScope` is a
818
814
  * child of the owning window's `windowScope`; it OWNS the wc's trust ref-count
819
815
  * lease(s). When the window closes, `windowScope.close()` cascades into this
820
816
  * `wcScope` (children-first LIFO), disposing every lease → ref-count hits 0 →
821
- * the wc leaves the trust set. This replaces the imperative `deleteEntry`.
817
+ * the wc leaves the trust set.
822
818
  * A wc can be trusted more than once (framework auto-trust + host
823
819
  * `windows.trust`), so `leases` is a Set.
824
820
  */
@@ -826,13 +822,13 @@ var DeckApp = class {
826
822
  pendingWindowCreated = [];
827
823
  pendingLoadFailed = [];
828
824
  /**
829
- * host-view slice 1 — per-window native-view substrate, keyed by the window's
825
+ * Per-window native-view substrate, keyed by the window's
830
826
  * webContents (same key discipline as `lifetimeShadow`). Created at both
831
827
  * window-construction sites; dropped in `handleSubWindowClosed`.
832
828
  */
833
829
  windowSubstrates = /* @__PURE__ */ new Map();
834
830
  /**
835
- * P3 — per-adopted-window registration handle, keyed by the adopted window's
831
+ * Per-adopted-window registration handle, keyed by the adopted window's
836
832
  * webContents. `runtime.windows.adopt` is idempotent by wc identity: a second
837
833
  * adopt of the same window returns this stored Disposable (no double-admit, no
838
834
  * second substrate). The entry is removed when the registration is disposed
@@ -840,7 +836,7 @@ var DeckApp = class {
840
836
  */
841
837
  adoptedWindows = /* @__PURE__ */ new Map();
842
838
  /**
843
- * C1/C4 — per-registered-window {@link DeckWindow} facade + its per-window
839
+ * Per-registered-window {@link DeckWindow} facade + its per-window
844
840
  * close deciders, keyed by the window's control wc. Populated by
845
841
  * {@link registerWindow} for framework-created and adopted windows, plus the
846
842
  * framework-built main window. `deciders` is an ORDERED list run in
@@ -848,13 +844,13 @@ var DeckApp = class {
848
844
  * decision latch (mirrors the main-window `closingDecisionPromise`).
849
845
  */
850
846
  windowRegistrations = /* @__PURE__ */ new Map();
851
- /** C1 — the framework-built main window's control wc, so `runtime.windows.main`
847
+ /** The framework-built main window's control wc, so `runtime.windows.main`
852
848
  * can resolve its {@link DeckWindow}. Null under an `ownsWindows:true` backend. */
853
849
  mainControlWc = null;
854
- /** host-view slice 1 — monotonic id source for `runtime.view` native views. */
850
+ /** Monotonic id source for `runtime.view` native views. */
855
851
  viewSeq = 0;
856
852
  /**
857
- * P2 — provenance map for `runtime.scopes.create()` sessions: maps an opaque
853
+ * Provenance map for `runtime.scopes.create()` sessions: maps an opaque
858
854
  * {@link DeckSession} to its internal `rootScope.child()` Scope. A WeakMap so a
859
855
  * dropped session is GC'd; the framework holds the scope's lifetime via
860
856
  * rootScope anyway (the session scope is a rootScope child). `runtime.view`
@@ -871,7 +867,7 @@ var DeckApp = class {
871
867
  * without `keepAlive` never participate.
872
868
  */
873
869
  keepAliveGroups = /* @__PURE__ */ new Map();
874
- /** C3: wcs that already have the `did-start-navigation` grant-reset hook bound,
870
+ /** Wcs that already have the `did-start-navigation` grant-reset hook bound,
875
871
  * so {@link bindNavigationGrantReset} is idempotent — a wc admitted to trust
876
872
  * more than once (e.g. constructed `autoTrust:false` then `windows.trust()`ed,
877
873
  * or un-adopted then re-adopted) never accumulates duplicate nav listeners. */
@@ -891,9 +887,9 @@ var DeckApp = class {
891
887
  /** Set when shutdown is driven by the `will-quit` handler — the app is already
892
888
  * quitting, so `doShutdown()` must NOT re-`app.quit()` (re-entrant quit). */
893
889
  quitInitiated = false;
894
- /** v2 close machine: non-null while a close decision is awaiting (in-flight latch). */
890
+ /** Close machine: non-null while a close decision is awaiting (in-flight latch). */
895
891
  closingDecisionPromise = null;
896
- /** v2 close machine: set once a 'close' decision is committed (guards the
892
+ /** Close machine: set once a 'close' decision is committed (guards the
897
893
  * window between decision-resolve and the 'closed' event). Never resets. */
898
894
  shuttingDown = false;
899
895
  /** Idempotency latch for {@link runShutdownCleanup}: the cleanup body
@@ -998,7 +994,7 @@ var DeckApp = class {
998
994
  return this.shutdownPromise;
999
995
  }
1000
996
  /**
1001
- * @internal Phase 4 windows.trust() / framework 内部添加 trusted webContents.
997
+ * @internal windows.trust() / framework 内部添加 trusted webContents.
1002
998
  * Backend-owned / untracked-window fallback: there is no framework windowScope
1003
999
  * for these (the backend manages their lifetime), so the trust lease is owned
1004
1000
  * by `rootScope` as an app-shutdown backstop. The backend still disposes the
@@ -1008,14 +1004,14 @@ var DeckApp = class {
1008
1004
  return this.trustSet.admit(wc, this.rootScope);
1009
1005
  }
1010
1006
  /**
1011
- * unified-lifetime P1b: admit `wc` to the trust set under `windowScope`. Gets
1007
+ * Admit `wc` to the trust set under `windowScope`. Gets
1012
1008
  * or creates the wc's `wcScope` (a child of `windowScope`), takes a fresh
1013
1009
  * `trustSet.admit(wc, wcScope)` ref-count lease OWNED BY that wcScope, and returns a
1014
1010
  * one-shot host-facing Disposable that releases just THIS lease early. On
1015
1011
  * `wcScope.close()` (window-close cascade) every still-held lease is disposed
1016
- * → ref-count zeroes → the wc leaves the set (equivalent to the old
1017
- * `deleteEntry`, but driven by Scope teardown and covering partially-built
1018
- * windows too). Idempotent registry cleanup is owned by the wcScope.
1012
+ * → ref-count zeroes → the wc leaves the set (driven by Scope teardown,
1013
+ * covering partially-built windows too). Idempotent registry cleanup is owned
1014
+ * by the wcScope.
1019
1015
  */
1020
1016
  admitTrust(wc, windowScope) {
1021
1017
  if (wc.isDestroyed()) return { dispose: () => {} };
@@ -1044,7 +1040,7 @@ var DeckApp = class {
1044
1040
  } };
1045
1041
  }
1046
1042
  /**
1047
- * C3 (P0 security) — bind the main-frame cross-document navigation grant-reset
1043
+ * Bind the main-frame cross-document navigation grant-reset
1048
1044
  * hook on a control `wc`. On a MAIN-FRAME CROSS-DOCUMENT navigation
1049
1045
  * (`isMainFrame && !isInPlace`) this SYNCHRONOUSLY revokes the wc's capability
1050
1046
  * grants (`capability.revokeBySenderId`) and slot tokens, so the navigated-to
@@ -1071,7 +1067,7 @@ var DeckApp = class {
1071
1067
  });
1072
1068
  }
1073
1069
  /**
1074
- * C1 — build the {@link DeckWindow} facade over a registered window and record
1070
+ * Build the {@link DeckWindow} facade over a registered window and record
1075
1071
  * it (so `runtime.windows.create()` / `runtime.windows.main` can return it and
1076
1072
  * the per-window close machine can find its deciders). `newSession()` mints a
1077
1073
  * window-rooted {@link DeckSession} (a `windowScope.child()` registered in the
@@ -1121,7 +1117,7 @@ var DeckApp = class {
1121
1117
  /**
1122
1118
  * Resolve a window argument that may be either a raw `BrowserWindow` (the
1123
1119
  * historical `runtime.view().placeIn(window)` shape) OR a {@link DeckWindow}
1124
- * handle (the C1 `runtime.windows.create()` return). A DeckWindow exposes the
1120
+ * handle (the `runtime.windows.create()` return). A DeckWindow exposes the
1125
1121
  * underlying window via `.window` and has no `.webContents` of its own; a raw
1126
1122
  * window has `.webContents`. Unwrap so the substrate lookup keys off the real
1127
1123
  * control webContents either way — keeping the `placeIn(deckWindow)` and
@@ -1133,7 +1129,7 @@ var DeckApp = class {
1133
1129
  return win;
1134
1130
  }
1135
1131
  /**
1136
- * C4 — run a registered window's per-window close deciders (registration order;
1132
+ * Run a registered window's per-window close deciders (registration order;
1137
1133
  * any `'keep'` vetoes), with an in-flight latch so a re-entrant close during a
1138
1134
  * pending decision decides ONCE. A throw / rejection fails CLOSED. Returns the
1139
1135
  * committed decision, or `null` when the decision is still in flight / there are
@@ -1156,7 +1152,7 @@ var DeckApp = class {
1156
1152
  return "close";
1157
1153
  }
1158
1154
  /**
1159
- * C4 — arm the per-window cancelable close-decision machine on a CREATED /
1155
+ * Arm the per-window cancelable close-decision machine on a CREATED /
1160
1156
  * adopted window. On a `close` attempt: `preventDefault`, dispatch the
1161
1157
  * per-window deciders behind an in-flight latch (re-entrant closes swallowed),
1162
1158
  * and on a `'close'` decision `win.destroy()` (→ `'closed'` → revoke +
@@ -1192,26 +1188,26 @@ var DeckApp = class {
1192
1188
  });
1193
1189
  }
1194
1190
  /**
1195
- * @internal unified-lifetime P0 accessors (observation-only). The live shadow
1196
- * map mirroring `trackedWindows`, the root Scope, and a consistency assertion.
1191
+ * @internal Lifetime accessors. The live shadow map mirroring `trackedWindows`,
1192
+ * the root Scope, and a consistency assertion.
1197
1193
  */
1198
1194
  __lifetimeShadow() {
1199
1195
  return this.lifetimeShadow;
1200
1196
  }
1201
- /** @internal unified-lifetime P0: the root lifetime Scope. */
1197
+ /** @internal The root lifetime Scope. */
1202
1198
  __rootScope() {
1203
1199
  return this.rootScope;
1204
1200
  }
1205
- /** @internal unified-lifetime P1b: the per-trusted-wc trust records. */
1201
+ /** @internal The per-trusted-wc trust records. */
1206
1202
  __wcRecords() {
1207
1203
  return this.wcRecords;
1208
1204
  }
1209
- /** @internal P4 Phase B: the live capability policy (grant gate reads it). */
1205
+ /** @internal The live capability policy (grant gate reads it). */
1210
1206
  __capabilityPolicy() {
1211
1207
  return this.capability.policy;
1212
1208
  }
1213
1209
  /**
1214
- * @internal unified-lifetime P0 invariant (A): the shadow's per-window set
1210
+ * @internal Lifetime invariant: the shadow's per-window set
1215
1211
  * (the `window` of each entry) must equal `trackedWindows` membership. Throws
1216
1212
  * if violated; no-op otherwise.
1217
1213
  */
@@ -1234,12 +1230,11 @@ var DeckApp = class {
1234
1230
  }
1235
1231
  }
1236
1232
  /**
1237
- * host-view slice 1 — build a per-window {@link ViewSubstrate}. The
1233
+ * Build a per-window {@link ViewSubstrate}. The
1238
1234
  * `ContentViewHost` adapts `win.contentView` and tracks the Compositor-managed
1239
1235
  * z-order in `order` (the minimal `contentView` has no `children()`). The
1240
1236
  * substrate's `detachAll` is owned on `windowScope` AFTER the window's
1241
- * `win.destroy` own, so LIFO teardown runs detachAll (STEP1) BEFORE destroy
1242
- * (STEP4) — the A4 ordering.
1237
+ * `win.destroy` own, so LIFO teardown runs detachAll BEFORE destroy.
1243
1238
  */
1244
1239
  createWindowSubstrate(win, windowScope) {
1245
1240
  const wcvById = /* @__PURE__ */ new Map();
@@ -1407,7 +1402,7 @@ var DeckApp = class {
1407
1402
  });
1408
1403
  }
1409
1404
  }
1410
- /** Phase 4 race fix:在 wireTransport.start 之后再 loadURL/loadFile。 */
1405
+ /** wireTransport.start 之后再 loadURL/loadFile,避免 preload 先于 ipcMain handler 注册触发 invoke。 */
1411
1406
  loadAssembledSources() {
1412
1407
  if (this.toolbarView && this.config.toolbar) this.safeLoad(this.toolbarView.webContents, this.config.toolbar.source);
1413
1408
  if (this.config.windows) for (const [key, contrib] of Object.entries(this.config.windows)) {
@@ -1417,7 +1412,7 @@ var DeckApp = class {
1417
1412
  if (this.mainWindow && this.config.app?.source) this.safeLoad(this.mainWindow.webContents, this.config.app.source);
1418
1413
  }
1419
1414
  /**
1420
- * #3 R5/C2 — load is best-effort: log + emit `load-failed` if it rejects,
1415
+ * Load is best-effort: log + emit `load-failed` if it rejects,
1421
1416
  * but never let start() reject because of a renderer load issue (we'd
1422
1417
  * leave the host blocked indefinitely while the framework is otherwise
1423
1418
  * happy).
@@ -1495,7 +1490,7 @@ var DeckApp = class {
1495
1490
  return name.startsWith("layout.");
1496
1491
  }
1497
1492
  /**
1498
- * KA-4: warn ONCE about an invalid `keepAlive.max` (negative / non-integer /
1493
+ * Warn ONCE about an invalid `keepAlive.max` (negative / non-integer /
1499
1494
  * NaN). Such a view is not keep-alive-managed (the group is skipped); warning
1500
1495
  * once avoids log spam when many views share the same bad config.
1501
1496
  */
@@ -1541,7 +1536,7 @@ var DeckApp = class {
1541
1536
  return win;
1542
1537
  }
1543
1538
  /**
1544
- * P3 — register an EXTERNALLY-created window into the framework so
1539
+ * Register an EXTERNALLY-created window into the framework so
1545
1540
  * `runtime.view().placeIn(win)` works for it: a `rootScope.child()`
1546
1541
  * windowScope, a per-window {@link ViewSubstrate}, and the TRUST lifecycle —
1547
1542
  * mirroring {@link constructWindow}'s registration, but for a window the host
@@ -1555,7 +1550,7 @@ var DeckApp = class {
1555
1550
  * windowScope so app shutdown destroys the window; for `'observe'` the host
1556
1551
  * keeps lifetime control (the framework never destroys it),
1557
1552
  * 4) arm trust+grant+slot-token revocation as the FIRST `'closed'` listener via
1558
- * `prependListener` (codex R2 — runs before any external `'closed'` listener),
1553
+ * `prependListener` (runs before any external `'closed'` listener),
1559
1554
  * 5) `admitTrust` AFTER the revoke listener is registered (constructWindow order).
1560
1555
  *
1561
1556
  * Idempotent by webContents identity: a second adopt of the same window returns
@@ -1602,12 +1597,11 @@ var DeckApp = class {
1602
1597
  return registration;
1603
1598
  }
1604
1599
  /**
1605
- * unified-lifetime P1b: synchronously revoke BOTH trust leases AND capability
1600
+ * Synchronously revoke BOTH trust leases AND capability
1606
1601
  * grants for every wc admitted under `windowScope` (the window's control wc +
1607
1602
  * any siblings like the toolbar wc). Called from the window's 'closed' handler
1608
- * so both authorizations are gone the instant the window is destroyed
1609
- * matching the old synchronous `deleteEntry` timing and closing every
1610
- * async-cascade race (a destroyed wc can never be observed trusted OR granted
1603
+ * so both authorizations are gone the instant the window is destroyed,
1604
+ * closing every async-cascade race (a destroyed wc can never be observed trusted OR granted
1611
1605
  * by a later shutdown/beforeClose, nor by a NEW window that reuses the same
1612
1606
  * wc.id before the async scope cascade revokes it). The leases are ALSO owned
1613
1607
  * by their wcScope, so the async `windowScope.close()` still runs (it disposes
@@ -1625,8 +1619,8 @@ var DeckApp = class {
1625
1619
  }
1626
1620
  }
1627
1621
  /**
1628
- * Arm the wire's slot-token inbound channels (idempotent). P5 eager-arm:
1629
- * called once at framework start() (bindWireTransport, right after
1622
+ * Arm the wire's slot-token inbound channels (idempotent). Called once at
1623
+ * framework start() (bindWireTransport, right after
1630
1624
  * transport.start()) so a layout client can subscribe before the first
1631
1625
  * anchored placeIn; the anchored `placeIn` call site is now a redundant no-op
1632
1626
  * (kept for safety). No-op when there's no wire transport (main-internal-only
@@ -1678,7 +1672,7 @@ var DeckApp = class {
1678
1672
  this.emitFrameworkEvent("window-closed", { window: win });
1679
1673
  }
1680
1674
  /**
1681
- * v2 — notify the backend that the framework has edge-trusted one of its
1675
+ * Notify the backend that the framework has edge-trusted one of its
1682
1676
  * (framework-built) webContents, so the backend can mirror it into the domain
1683
1677
  * trust set. The returned Disposable is disposed when THAT window closes
1684
1678
  * ({@link handleSubWindowClosed}) — honouring the contract "framework disposes
@@ -2155,8 +2149,8 @@ async function runWithTimeout(work, timeoutMs) {
2155
2149
  *
2156
2150
  * - Invalid config → reject `TypeError`,phase 不前进
2157
2151
  * - Valid config → 装配 runtime + 调 `config.setup(runtime)` await 完成 →
2158
- * resolve。Phase 2 不接 Electron,resolve 后 framework 仍持有运行时;
2159
- * Phase 4 接 Electron app lifecycle 后,由 Electron event loop 撑住进程,
2152
+ * resolve。不接 Electron 时,resolve 后 framework 仍持有运行时;
2153
+ * 接 Electron app lifecycle 后,由 Electron event loop 撑住进程,
2160
2154
  * `electronDeck()` 同样 resolve(host 的 main 文件不需 await 阻塞)。
2161
2155
  *
2162
2156
  * backend host(如 devtools)走 `electronDeck({ backend })`——backend 是
@@ -2292,4 +2286,4 @@ function validateHandlerMap(fieldName, value) {
2292
2286
  //#endregion
2293
2287
  export { WireTransport as a, InMemoryTypedIpcRegistry as c, createControlBus as i, EventBus as l, startElectronDeck as n, createCapabilityRegistry as o, validateConfig as r, createTrustSet as s, electronDeck as t, defineEvent as u };
2294
2288
 
2295
- //# sourceMappingURL=electron-deck-CW6gkGS-.js.map
2289
+ //# sourceMappingURL=electron-deck-C9_Yu3fd.js.map