@ai-matrx/summon 0.1.9 → 0.1.11
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/CHANGELOG.md +21 -0
- package/README.md +24 -0
- package/dist/{gate-CfjdNWP6.d.cts → gate-2V3LrLFh.d.cts} +23 -1
- package/dist/{gate-CfjdNWP6.d.ts → gate-2V3LrLFh.d.ts} +23 -1
- package/dist/index.cjs +6 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/dist/open.cjs +49 -13
- package/dist/open.cjs.map +1 -1
- package/dist/open.d.cts +5 -2
- package/dist/open.d.ts +5 -2
- package/dist/open.js +49 -13
- package/dist/open.js.map +1 -1
- package/dist/react.cjs +3 -18
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +2 -9
- package/dist/react.d.ts +2 -9
- package/dist/react.js +2 -17
- package/dist/react.js.map +1 -1
- package/dist/root.cjs +52 -0
- package/dist/root.cjs.map +1 -1
- package/dist/root.d.cts +52 -1
- package/dist/root.d.ts +52 -1
- package/dist/root.js +52 -0
- package/dist/root.js.map +1 -1
- package/dist/window-host.cjs +6 -32
- package/dist/window-host.cjs.map +1 -1
- package/dist/window-host.d.cts +2 -45
- package/dist/window-host.d.ts +2 -45
- package/dist/window-host.js +2 -28
- package/dist/window-host.js.map +1 -1
- package/package.json +4 -4
package/dist/open.cjs
CHANGED
|
@@ -34,8 +34,10 @@ __export(open_exports, {
|
|
|
34
34
|
DEFAULT_PORTS: () => DEFAULT_PORTS,
|
|
35
35
|
SUMMON_INSTALLED_ACTION: () => SUMMON_INSTALLED_ACTION,
|
|
36
36
|
SUMMON_SLICE_KEYS: () => SUMMON_SLICE_KEYS,
|
|
37
|
+
ackOverlaySurfaceRender: () => ackOverlaySurfaceRender,
|
|
37
38
|
allOverlayMeta: () => allOverlayMeta,
|
|
38
39
|
anonymousIdentity: () => anonymousIdentity,
|
|
40
|
+
clearOverlaySurfaceRender: () => clearOverlaySurfaceRender,
|
|
39
41
|
closeAllInstancesOfOverlay: () => closeAllInstancesOfOverlay,
|
|
40
42
|
closeAllOverlays: () => closeAllOverlays,
|
|
41
43
|
closeOverlay: () => closeOverlay,
|
|
@@ -66,10 +68,12 @@ __export(open_exports, {
|
|
|
66
68
|
prefetchSummonRuntime: () => prefetchSummonRuntime,
|
|
67
69
|
pruneStaleInstances: () => pruneStaleInstances,
|
|
68
70
|
registerOverlayMeta: () => registerOverlayMeta,
|
|
71
|
+
registerSyncEntry: () => registerSyncEntry,
|
|
69
72
|
resetOverlayRegistry: () => resetOverlayRegistry,
|
|
70
73
|
resolvePorts: () => resolvePorts,
|
|
71
74
|
restoreAll: () => restoreAll,
|
|
72
75
|
restoreWindow: () => restoreWindow,
|
|
76
|
+
selectAllWindows: () => selectAllWindows,
|
|
73
77
|
selectAnyOverlayTouched: () => selectAnyOverlayTouched,
|
|
74
78
|
selectIsOverlayOpen: () => selectIsOverlayOpen,
|
|
75
79
|
selectOpenInstances: () => selectOpenInstances,
|
|
@@ -79,7 +83,8 @@ __export(open_exports, {
|
|
|
79
83
|
subscribeSummonInstalled: () => subscribeSummonInstalled,
|
|
80
84
|
subscribeToOverlayRegistry: () => subscribeToOverlayRegistry,
|
|
81
85
|
toggleOverlay: () => toggleOverlay,
|
|
82
|
-
toggleWindowsHidden: () => toggleWindowsHidden
|
|
86
|
+
toggleWindowsHidden: () => toggleWindowsHidden,
|
|
87
|
+
unregisterSyncEntry: () => unregisterSyncEntry
|
|
83
88
|
});
|
|
84
89
|
module.exports = __toCommonJS(open_exports);
|
|
85
90
|
|
|
@@ -245,6 +250,8 @@ var restoreWindow = creator(W + "restoreWindow", pass());
|
|
|
245
250
|
var toggleWindowsHidden = creator(W + "toggleWindowsHidden", () => void 0);
|
|
246
251
|
var restoreAll = creator(W + "restoreAll", () => void 0);
|
|
247
252
|
var minimizeAll = creator(W + "minimizeAll", pass());
|
|
253
|
+
var registerSyncEntry = creator("urlSync/registerSyncEntry", pass());
|
|
254
|
+
var unregisterSyncEntry = creator("urlSync/unregisterSyncEntry", pass());
|
|
248
255
|
var SUMMON_SLICE_KEYS = ["overlays", "windowManager", "urlSync", "overlayState"];
|
|
249
256
|
function isSummonAction(action) {
|
|
250
257
|
if (typeof action !== "object" || action === null) return false;
|
|
@@ -254,14 +261,31 @@ function isSummonAction(action) {
|
|
|
254
261
|
return slash > 0 && SUMMON_SLICE_KEYS.includes(type.slice(0, slash));
|
|
255
262
|
}
|
|
256
263
|
|
|
257
|
-
// src/open/
|
|
264
|
+
// src/open/renderAcks.ts
|
|
258
265
|
var import_global_slot2 = require("@ai-matrx/kit/global-slot");
|
|
266
|
+
var slot = () => (0, import_global_slot2.globalSlot)("ai-matrx.summon.renderWatchdog", () => ({ renderAcks: /* @__PURE__ */ new Map(), ackWaiters: /* @__PURE__ */ new Map(), watches: /* @__PURE__ */ new Map() }));
|
|
267
|
+
function ackOverlaySurfaceRender(overlayId) {
|
|
268
|
+
const s = slot();
|
|
269
|
+
s.renderAcks.set(overlayId, { kind: "surface" });
|
|
270
|
+
const notify = s.ackWaiters.get(overlayId);
|
|
271
|
+
if (notify) {
|
|
272
|
+
s.ackWaiters.delete(overlayId);
|
|
273
|
+
notify();
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
function clearOverlaySurfaceRender(overlayId) {
|
|
277
|
+
const s = slot();
|
|
278
|
+
if (s.renderAcks.get(overlayId)?.kind === "surface") s.renderAcks.delete(overlayId);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
// src/open/selectors.ts
|
|
282
|
+
var import_global_slot3 = require("@ai-matrx/kit/global-slot");
|
|
259
283
|
var CLOSED = Object.freeze({ isOpen: false, data: null });
|
|
260
284
|
var EMPTY = Object.freeze([]);
|
|
261
285
|
var selectOverlay = (state2, overlayId, instanceId = DEFAULT_INSTANCE_ID) => state2.overlays?.overlays[overlayId]?.[instanceId] ?? CLOSED;
|
|
262
286
|
var selectIsOverlayOpen = (state2, overlayId, instanceId = DEFAULT_INSTANCE_ID) => selectOverlay(state2, overlayId, instanceId).isOpen;
|
|
263
287
|
var selectOverlayData = (state2, overlayId, instanceId = DEFAULT_INSTANCE_ID) => selectOverlay(state2, overlayId, instanceId).data;
|
|
264
|
-
var openCache = () => (0,
|
|
288
|
+
var openCache = () => (0, import_global_slot3.globalSlot)("ai-matrx.summon.openInstances", () => /* @__PURE__ */ new Map());
|
|
265
289
|
var selectOpenInstances = (state2, overlayId) => {
|
|
266
290
|
const bucket = state2.overlays?.overlays[overlayId];
|
|
267
291
|
const cache = openCache();
|
|
@@ -288,13 +312,25 @@ function selectAnyOverlayTouched(state2) {
|
|
|
288
312
|
return false;
|
|
289
313
|
}
|
|
290
314
|
var selectWindowsHidden = (state2) => state2.windowManager?.windowsHidden ?? false;
|
|
315
|
+
var EMPTY_WINDOWS = Object.freeze([]);
|
|
316
|
+
var lastWindowsMap = null;
|
|
317
|
+
var lastWindows = EMPTY_WINDOWS;
|
|
318
|
+
function selectAllWindows(state2) {
|
|
319
|
+
const map = state2.windowManager?.windows;
|
|
320
|
+
if (!map) return EMPTY_WINDOWS;
|
|
321
|
+
if (map !== lastWindowsMap) {
|
|
322
|
+
lastWindowsMap = map;
|
|
323
|
+
lastWindows = Object.values(map).sort((a, b) => b.zIndex - a.zIndex);
|
|
324
|
+
}
|
|
325
|
+
return lastWindows;
|
|
326
|
+
}
|
|
291
327
|
|
|
292
328
|
// src/open/gate.ts
|
|
293
|
-
var
|
|
329
|
+
var import_global_slot4 = require("@ai-matrx/kit/global-slot");
|
|
294
330
|
var SUMMON_INSTALLED_ACTION = "@@summon/installed";
|
|
295
|
-
var
|
|
331
|
+
var slot2 = () => (0, import_global_slot4.globalSlot)("ai-matrx.summon.gate", () => ({ core: null, loading: null, gates: /* @__PURE__ */ new Set(), listeners: /* @__PURE__ */ new Set() }));
|
|
296
332
|
function installSummonCore(core) {
|
|
297
|
-
const s =
|
|
333
|
+
const s = slot2();
|
|
298
334
|
if (s.core) return;
|
|
299
335
|
s.core = core;
|
|
300
336
|
const gates = [...s.gates];
|
|
@@ -303,15 +339,15 @@ function installSummonCore(core) {
|
|
|
303
339
|
for (const listener of [...s.listeners]) listener();
|
|
304
340
|
}
|
|
305
341
|
function isSummonInstalled() {
|
|
306
|
-
return
|
|
342
|
+
return slot2().core !== null;
|
|
307
343
|
}
|
|
308
344
|
function subscribeSummonInstalled(listener) {
|
|
309
|
-
const s =
|
|
345
|
+
const s = slot2();
|
|
310
346
|
s.listeners.add(listener);
|
|
311
347
|
return () => s.listeners.delete(listener);
|
|
312
348
|
}
|
|
313
349
|
function ensureSummonRuntime() {
|
|
314
|
-
const s =
|
|
350
|
+
const s = slot2();
|
|
315
351
|
if (s.core) return Promise.resolve();
|
|
316
352
|
s.loading ??= import("@ai-matrx/summon").then(
|
|
317
353
|
(core) => installSummonCore(core.summonCore),
|
|
@@ -352,14 +388,14 @@ function createSummonGate(options = {}) {
|
|
|
352
388
|
else if (queue.length > 0) queueMicrotask(flush);
|
|
353
389
|
};
|
|
354
390
|
const internals = { install: (core2) => settle(core2, true) };
|
|
355
|
-
const core = () =>
|
|
391
|
+
const core = () => slot2().core;
|
|
356
392
|
const middleware = (storeApi) => {
|
|
357
393
|
api = storeApi;
|
|
358
394
|
return (nextDispatch) => {
|
|
359
395
|
next = nextDispatch;
|
|
360
396
|
const loaded = core();
|
|
361
397
|
if (loaded) settle(loaded, false);
|
|
362
|
-
else
|
|
398
|
+
else slot2().gates.add(internals);
|
|
363
399
|
return (action) => {
|
|
364
400
|
if (chain) return chain(action);
|
|
365
401
|
if (!isSummonAction(action)) return nextDispatch(action);
|
|
@@ -385,8 +421,8 @@ function createSummonGate(options = {}) {
|
|
|
385
421
|
}
|
|
386
422
|
|
|
387
423
|
// src/open/channels.ts
|
|
388
|
-
var
|
|
389
|
-
var pending = () => (0,
|
|
424
|
+
var import_global_slot5 = require("@ai-matrx/kit/global-slot");
|
|
425
|
+
var pending = () => (0, import_global_slot5.globalSlot)("ai-matrx.summon.pendingChannels", () => /* @__PURE__ */ new Map());
|
|
390
426
|
function materializePendingChannels(createEventChannel) {
|
|
391
427
|
const map = pending();
|
|
392
428
|
for (const [id, entry] of [...map]) {
|
package/dist/open.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/open.ts","../src/core/types.ts","../src/core/ports.ts","../src/core/registry.ts","../src/open/actions.ts","../src/open/selectors.ts","../src/open/gate.ts","../src/open/channels.ts"],"sourcesContent":["// @ai-matrx/summon/open — what a page pays before anything opens: the action creators (plain\n// objects with the slices' type strings), selectors that read \"closed\" until the runtime exists,\n// the definition registry, ports, and the gate that loads the core on the first request.\n// Framework-free; never loads a slice, the middleware, React, or the handles registry.\nexport * from \"./core/types\";\nexport * from \"./core/ports\";\nexport * from \"./core/registry\";\nexport {\n openOverlay,\n closeOverlay,\n toggleOverlay,\n closeAllInstancesOfOverlay,\n closeOverlaysBoundToPage,\n closeAllOverlays,\n pruneStaleInstances,\n overlayIdsBoundToPage,\n focusWindow,\n restoreWindow,\n toggleWindowsHidden,\n restoreAll,\n minimizeAll,\n isSummonAction,\n SUMMON_SLICE_KEYS,\n type OpenOverlayPayload,\n type CloseOverlayPayload,\n type ToggleOverlayPayload,\n type CloseAllInstancesPayload,\n type CloseOverlaysBoundToPagePayload,\n type PruneStaleInstancesPayload,\n type RawOpenPayload,\n type SummonAction,\n} from \"./open/actions\";\nexport {\n selectOverlay,\n selectIsOverlayOpen,\n selectOverlayData,\n selectOpenInstances,\n listOpenInstanceKeys,\n selectAnyOverlayTouched,\n selectWindowsHidden,\n type OverlayInstance,\n type OverlayState,\n type StateWithOverlays,\n type OpenInstanceView,\n} from \"./open/selectors\";\nexport {\n createSummonGate,\n installSummonCore,\n isSummonInstalled,\n subscribeSummonInstalled,\n ensureSummonRuntime,\n prefetchSummonRuntime,\n SUMMON_INSTALLED_ACTION,\n type SummonCore,\n type SummonGate,\n type CreateSummonGateOptions,\n} from \"./open/gate\";\nexport { openPendingEventChannel, materializePendingChannels, dropPendingChannelsOf, type OverlayEventMessage } from \"./open/channels\";\n","/**\n * The shared vocabulary of @ai-matrx/summon. Framework-free: no React, no Redux imports.\n *\n * An OVERLAY is any component rendered on top of the app by dispatch — a window, dialog, sheet,\n * light floating window, toast-like card, anything. It is identified by an `OverlayId` and opened\n * as one or more INSTANCES (`instanceId`, \"default\" for single-instance overlays).\n */\n\n/**\n * The host's overlay registry: overlay id → the data its opener accepts. Hosts extend it by\n * module augmentation so every open call is type-checked:\n *\n * declare module \"@ai-matrx/summon\" {\n * interface OverlayRegistry { notesWindow: { noteId?: string } }\n * }\n *\n * `defineOverlay` emits nothing at runtime for this; the augmentation is the host's one-line\n * declaration per overlay (the converter writes it next to each definition).\n */\n// Declared in ./augment (bundled only into the core's declarations, so `declare module\n// \"@ai-matrx/summon\"` merges into it); every section reads it through the package name.\nimport type { OverlayRegistry, OverlayHostTypes } from \"@ai-matrx/summon\";\nexport type { OverlayRegistry, OverlayHostTypes };\n\n/** Every registered overlay id; plain `string` until the host augments the registry. */\nexport type OverlayId = [keyof OverlayRegistry] extends [never]\n ? string\n : Extract<keyof OverlayRegistry, string>;\n\n/** The open-data type declared for an overlay id. */\nexport type OverlayDataOf<Id extends string> = Id extends keyof OverlayRegistry\n ? OverlayRegistry[Id]\n : Record<string, unknown>;\n\n/**\n * Data as it arrives at render time. It crossed Redux, a URL or storage, so it is NOT trusted to\n * match the opener's type: render code narrows it (or the definition supplies `parse`).\n */\nexport type OverlayRawData = Readonly<Record<string, unknown>> | null;\n\nexport const DEFAULT_INSTANCE_ID = \"default\";\n\n/** `single`: one instance (\"default\"). `multi`: any number, each with its own instanceId. */\nexport type InstanceMode = \"single\" | \"multi\";\n\n/**\n * What closing does to a mounted overlay (Arman, 2026-10-16, C38 R3):\n * none — unmount (default).\n * hidden — stay mounted but hidden; reopening shows the same live component (LRU-capped).\n * restore — unmount, but values saved with `useOverlayState` come back on reopen.\n * Minimizing a window always keeps its component mounted, whatever this says.\n */\nexport type KeepAlive = \"none\" | \"hidden\" | \"restore\";\n\n/** `overlayId:instanceId` — the one key every subsystem uses for an open instance. */\nexport type InstanceKey = `${string}:${string}`;\n\nexport function instanceKey(overlayId: string, instanceId: string = DEFAULT_INSTANCE_ID): InstanceKey {\n return `${overlayId}:${instanceId}`;\n}\n\nexport function parseInstanceKey(key: string): { overlayId: string; instanceId: string } | null {\n const at = key.indexOf(\":\");\n if (at <= 0 || at === key.length - 1) return null;\n return { overlayId: key.slice(0, at), instanceId: key.slice(at + 1) };\n}\n\n// ── Window options (consumed by the window surface; inert for other surfaces) ──────────────────\n\nexport type MobilePresentation = \"fullscreen\" | \"drawer\" | \"card\" | \"hidden\";\n\n/**\n * Default-deny allowlist of the open data a window may save and restore. A window with no\n * preservation entry restores geometry only.\n */\nexport interface WindowPreservation {\n readonly dataKeys: readonly string[];\n readonly requiredDataKeys?: readonly string[];\n readonly allowedDataValues?: Readonly<Record<string, readonly (string | number | boolean | null)[]>>;\n /** Default 32 KiB. */\n readonly maxDataBytes?: number;\n}\n\n/** One declared home for an unbidden (system-raised) window: a route prefix, or one exact page. */\nexport type UnbiddenHomeRoute = string | { readonly route: string; readonly exact: true };\n\nexport interface OverlayWindowOptions {\n readonly mobile?: MobilePresentation;\n readonly mobileSidebarAs?: \"drawer\" | \"inline\";\n /** Never saved or restored (debug panels, one-shot tools, callback-bound editors). */\n readonly ephemeral?: boolean;\n readonly preservation?: WindowPreservation;\n /**\n * Values merged under saved data when a window is RESTORED (reload, another device). Unlike the\n * definition's `defaults`, never applied to a normal open.\n */\n readonly restoreDefaults?: Readonly<Record<string, unknown>>;\n /**\n * The window-manager id the WindowPanel registers under for the default instance. Default: the\n * overlay id. The render watchdog reveals and inspects this id until the panel acks its own.\n */\n readonly windowId?: string;\n readonly deprecated?: { readonly replacement?: string; readonly reason?: string };\n /**\n * Where a window nobody opened (system-raised) may raise itself. Default deny: no home → it may\n * not raise itself anywhere (`mayRaiseUnbidden` in the window section).\n */\n readonly unbiddenHome?: readonly UnbiddenHomeRoute[];\n}\n\n// ── Host types (augmentable) ────────────────────────────────────────────────────────────────\n\n/**\n * Host-specific types the package passes through untouched. A Redux host augments `dispatch`\n * with its thunk-aware dispatch so link hydrators can dispatch its thunks without casts:\n *\n * declare module \"@ai-matrx/summon\" { interface OverlayHostTypes { dispatch: AppDispatch } }\n */\nexport type OverlayHostDispatch = OverlayHostTypes extends { dispatch: infer D } ? D : (action: unknown) => unknown;\n\n// ── Links (address-bar references) ──────────────────────────────────────────────────────────\n\nexport interface LinkHydrateContext<Data> {\n /** The id segment of the link token (`notes:<id>`). */\n readonly id: string;\n /** Decoded `k-v` arguments of the token. */\n readonly args: Readonly<Record<string, string>>;\n /** Open this overlay. */\n open(options?: { readonly instanceId?: string; readonly data?: Data }): void;\n /** The host store's dispatch, for thunks a hydrator needs (loading a record first). Typed by\n * augmenting `OverlayHostTypes` with the host's dispatch type. */\n readonly dispatch: OverlayHostDispatch;\n}\n\nexport interface OverlayLinkSpec<Data> {\n /** The token type key in `?panels=key:id`. Unique across the host. */\n readonly key: string;\n /** Older keys that still resolve to this overlay. */\n readonly aliases?: readonly string[];\n /** Turn a link token into an open overlay (and its data). `\"refused\"` keeps the token and says why. */\n hydrate(context: LinkHydrateContext<Data>): void | \"refused\" | Promise<void | \"refused\">;\n}\n\n// ── Definitions (framework-free half; the React half adds `render`) ─────────────────────────\n\nexport interface OverlayDefinitionMeta<Id extends string = string, Data = Record<string, unknown>> {\n readonly id: Id;\n /** Human label: tray, menus, diagnostics. */\n readonly label: string;\n readonly instance?: InstanceMode;\n readonly keepAlive?: KeepAlive;\n /** Close when the route changes — the overlay shows a piece of the page that opened it. */\n readonly closesOnNavigation?: boolean;\n /** Present only for overlays that render a WindowPanel. */\n readonly window?: OverlayWindowOptions;\n readonly link?: OverlayLinkSpec<Data>;\n /** Defaults merged under open data (replaces the old per-overlay schema registry). */\n readonly defaults?: Partial<Data>;\n}\n\n/** The window-manager id a singleton window overlay registers under (`window.windowId ?? id`). */\nexport function defaultWindowIdFor(meta: Pick<OverlayDefinitionMeta, \"id\" | \"window\">): string {\n return meta.window?.windowId ?? meta.id;\n}\n","/**\n * Everything the overlays system needs from its host, as ports. Every port ships a working\n * default, so a bare host gets a working system with zero wiring (package standard rule 8); a\n * host overrides only what it has: identity, navigation, notifications, error sink, debug flag,\n * persistence. Framework-free.\n */\n\nexport type Unsubscribe = () => void;\n\n/** Who the person is, for isolating saved state. `key` changes → everything saved is swapped. */\nexport interface IdentityPort {\n current(): { readonly key: string; readonly ready: boolean };\n subscribe(listener: () => void): Unsubscribe;\n}\n\n/** The address bar: route changes (close-on-navigation) and the `?panels=` link channel. */\nexport interface RouterPort {\n pathname(): string;\n search(): string;\n /** Replace the query string without navigating or remounting the page. */\n replaceSearch(nextSearch: string): void;\n subscribe(listener: () => void): Unsubscribe;\n}\n\nexport interface NotifyOptions {\n readonly id?: string;\n readonly description?: string;\n /** How long the notice stays up (ms). Hosts without timed notices ignore it. */\n readonly duration?: number;\n /** One action button (e.g. the render watchdog's \"Show it\"). Hosts without actions ignore it. */\n readonly action?: { readonly label: string; readonly onClick: () => void };\n}\n\nexport interface NotifyPort {\n info(message: string, options?: NotifyOptions): void;\n warn(message: string, options?: NotifyOptions): void;\n error(message: string, options?: NotifyOptions): void;\n /** Withdraw a notice by id (optional). */\n dismiss?(id: string): void;\n}\n\nexport interface ErrorSinkPort {\n capture(error: unknown, context: Readonly<Record<string, unknown>>): void;\n}\n\nexport interface DebugPort {\n enabled(): boolean;\n subscribe?(listener: () => void): Unsubscribe;\n}\n\n/** A stored value with its optimistic-concurrency version (0 when the store has none). */\nexport interface StoredValue<T = unknown> {\n readonly value: T;\n readonly version: number;\n}\n\n/**\n * Where saved overlay state lives when persistence is on. Keys are already scoped to the\n * identity by the caller (`<identityKey>/<key>`) for stores that are not per-person themselves.\n * Implementations: the browser-local store (`./persistence`), `@ai-matrx/data` over\n * `users.user_surface_state` (`./persistence/data`), or any host database.\n */\nexport interface OverlayPersistencePort {\n /**\n * True when the store is per-person itself (rows scoped to the signed-in person, e.g. the\n * `@ai-matrx/data` adapter): the persistence section then passes plain keys (`workspace`,\n * `state:<instanceKey>`) instead of `<identityKey>/<key>`, and defaults to `scope: \"person\"`.\n */\n readonly perPerson?: boolean;\n load<T = unknown>(key: string): Promise<StoredValue<T> | null>;\n save<T = unknown>(key: string, value: T, options?: { readonly expectedVersion?: number }): Promise<{ readonly version: number }>;\n remove(key: string): Promise<void>;\n list?(prefix: string): Promise<readonly string[]>;\n /**\n * Every saved value at once (key → value), for stores where one read is cheaper than several.\n * When present, restoring an identity costs exactly this one call: the workspace and every\n * saved component state come out of it, and `load`/`list` are not called on boot.\n */\n loadAll?(): Promise<ReadonlyMap<string, StoredValue>>;\n}\n\nexport interface SummonPorts {\n readonly identity: IdentityPort;\n readonly router: RouterPort;\n readonly notify: NotifyPort;\n readonly errors: ErrorSinkPort;\n readonly debug: DebugPort;\n /** `null` = persistence off (R6). */\n readonly persistence: OverlayPersistencePort | null;\n}\n\nconst noop = (): void => {};\n\nexport const anonymousIdentity: IdentityPort = {\n current: () => ({ key: \"anonymous\", ready: true }),\n subscribe: () => noop,\n};\n\n/** `window.location` + `history.replaceState`; inert on the server. */\nexport const locationRouter: RouterPort = {\n pathname: () => (typeof window === \"undefined\" ? \"/\" : window.location.pathname),\n search: () => (typeof window === \"undefined\" ? \"\" : window.location.search),\n replaceSearch: (nextSearch) => {\n if (typeof window === \"undefined\") return;\n const query = nextSearch && !nextSearch.startsWith(\"?\") ? `?${nextSearch}` : nextSearch;\n const url = `${window.location.pathname}${query}${window.location.hash}`;\n window.history.replaceState(window.history.state, \"\", url);\n },\n subscribe: (listener) => {\n if (typeof window === \"undefined\") return noop;\n window.addEventListener(\"popstate\", listener);\n return () => window.removeEventListener(\"popstate\", listener);\n },\n};\n\n/* eslint-disable no-console */\nexport const consoleNotify: NotifyPort = {\n info: (message) => console.info(`[summon] ${message}`),\n warn: (message) => console.warn(`[summon] ${message}`),\n error: (message) => console.error(`[summon] ${message}`),\n};\n\nexport const consoleErrorSink: ErrorSinkPort = {\n capture: (error, context) => console.error(\"[summon]\", error, context),\n};\n/* eslint-enable no-console */\n\nexport const debugOff: DebugPort = { enabled: () => false };\n\nexport const DEFAULT_PORTS: SummonPorts = {\n identity: anonymousIdentity,\n router: locationRouter,\n notify: consoleNotify,\n errors: consoleErrorSink,\n debug: debugOff,\n persistence: null,\n};\n\nexport function resolvePorts(overrides: Partial<SummonPorts> | undefined): SummonPorts {\n return { ...DEFAULT_PORTS, ...overrides };\n}\n","/**\n * The process-wide registry of overlay definition metadata (the framework-free half of each\n * definition). The host registers its definitions once (`<SummonHost definitions>` does it);\n * reducers stay pure — middleware and hooks read this registry and put what reducers need in the\n * action payload (e.g. the ids bound to the page).\n *\n * State lives in a global slot so a duplicated module graph (ESM + CJS, unsplit bundles) sees one\n * registry (kit `globalSlot`, architecture D9).\n */\nimport { globalSlot } from \"@ai-matrx/kit/global-slot\";\nimport type { OverlayDefinitionMeta } from \"./types\";\n\n/**\n * A definition's meta with its data type erased, so definitions of every data shape share one\n * registry without casts. (`never` erasure made `defaults` unassignable.)\n */\nexport interface AnyOverlayMeta extends Omit<OverlayDefinitionMeta<string, unknown>, \"defaults\"> {\n readonly defaults?: object | undefined;\n}\n\ntype AnyMeta = AnyOverlayMeta;\n\ninterface RegistryState {\n readonly byId: Map<string, AnyMeta>;\n readonly byLinkKey: Map<string, AnyMeta>;\n readonly listeners: Set<() => void>;\n}\n\nconst state = (): RegistryState =>\n globalSlot<RegistryState>(\"ai-matrx.summon.registry\", () => ({\n byId: new Map(),\n byLinkKey: new Map(),\n listeners: new Set(),\n }));\n\n/**\n * Register (or re-register) definitions. Re-registering an id replaces it (hot reload). A link\n * key claimed by two different ids is a host bug and throws, naming both.\n */\nexport function registerOverlayMeta(definitions: readonly AnyOverlayMeta[]): void {\n const s = state();\n for (const def of definitions) {\n s.byId.set(def.id, def);\n const keys = def.link ? [def.link.key, ...(def.link.aliases ?? [])] : [];\n for (const key of keys) {\n const holder = s.byLinkKey.get(key);\n if (holder && holder.id !== def.id) {\n throw new Error(`[summon] link key \"${key}\" is claimed by both \"${holder.id}\" and \"${def.id}\"`);\n }\n s.byLinkKey.set(key, def);\n }\n }\n for (const listener of s.listeners) listener();\n}\n\nexport function getOverlayMeta(overlayId: string): AnyMeta | undefined {\n return state().byId.get(overlayId);\n}\n\nexport function getOverlayMetaByLinkKey(linkKey: string): AnyMeta | undefined {\n return state().byLinkKey.get(linkKey);\n}\n\nexport function allOverlayMeta(): readonly AnyMeta[] {\n return [...state().byId.values()];\n}\n\nexport function isRegisteredOverlay(overlayId: string): boolean {\n return state().byId.has(overlayId);\n}\n\nexport function subscribeToOverlayRegistry(listener: () => void): () => void {\n const s = state();\n s.listeners.add(listener);\n return () => s.listeners.delete(listener);\n}\n\n/** Test-only. */\nexport function resetOverlayRegistry(): void {\n const s = state();\n s.byId.clear();\n s.byLinkKey.clear();\n}\n","// The public action creators, light: plain objects with the slices' own type strings, so a file\n// that only opens or closes something never loads a slice. The slices (core) handle these exact\n// types; `actions.parity.test.ts` proves every creator here equals its slice twin.\n//\n// `openOverlay`/`toggleOverlay` keep the two guarantees the slice creators had: functions are\n// stripped from open data (they can never travel through Redux — the D33 dead-button class) and\n// the definition's registered `defaults` ride the payload, so the reducer stays pure.\nimport { getOverlayMeta, allOverlayMeta } from \"../core/registry\";\nimport { DEFAULT_INSTANCE_ID, type OverlayDataOf, type OverlayId } from \"../core/types\";\n\nexport interface OpenOverlayPayload<Id extends OverlayId = OverlayId> {\n overlayId: Id;\n instanceId?: string;\n data?: OverlayDataOf<Id> | null;\n}\n\nexport interface CloseOverlayPayload<Id extends OverlayId = OverlayId> {\n overlayId: Id;\n instanceId?: string;\n}\n\nexport type ToggleOverlayPayload<Id extends OverlayId = OverlayId> = OpenOverlayPayload<Id>;\n\nexport interface CloseAllInstancesPayload<Id extends OverlayId = OverlayId> {\n overlayId: Id;\n}\n\nexport interface CloseOverlaysBoundToPagePayload {\n /** Overlay ids whose definitions say `closesOnNavigation`. */\n overlayIds: readonly string[];\n}\n\nexport interface PruneStaleInstancesPayload {\n olderThanMs: number;\n}\n\n/** Raw reducer payload: untyped ids + the registry defaults the creator resolved. */\nexport interface RawOpenPayload {\n overlayId: string;\n instanceId?: string;\n data?: unknown;\n defaults?: Readonly<Record<string, unknown>>;\n}\n\nexport interface SummonAction<P> {\n type: string;\n payload: P;\n /** Structurally a Redux `UnknownAction`. */\n [extra: string]: unknown;\n}\n\ntype Creator<Args extends unknown[], P> = ((...args: Args) => SummonAction<P>) & {\n readonly type: string;\n match(action: unknown): action is SummonAction<P>;\n};\n\nfunction creator<Args extends unknown[], P>(type: string, build: (...args: Args) => P): Creator<Args, P> {\n const create = (...args: Args): SummonAction<P> => ({ type, payload: build(...args) });\n return Object.assign(create, {\n type,\n toString: () => type,\n match: (action: unknown): action is SummonAction<P> =>\n typeof action === \"object\" && action !== null && (action as { type?: unknown }).type === type,\n });\n}\n\nfunction isPlainRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction stripFunctions(overlayId: string, data: unknown): unknown {\n if (!isPlainRecord(data)) return data;\n const offenders = Object.keys(data).filter((key) => typeof data[key] === \"function\");\n if (offenders.length === 0) return data;\n // eslint-disable-next-line no-console\n console.error(\n `[summon] BUG: function value(s) in openOverlay data for \"${overlayId}\" (keys: ${offenders.join(\", \")}). ` +\n `Functions cannot travel through Redux — the handler would NEVER fire. Register a handle ` +\n `(@ai-matrx/summon/handles) and pass its id string instead. The offending key(s) were stripped from state.`,\n );\n const cleaned = { ...data };\n for (const key of offenders) delete cleaned[key];\n return cleaned;\n}\n\nfunction rawOpen(payload: { overlayId: string; instanceId?: string; data?: unknown }): RawOpenPayload {\n const raw: RawOpenPayload = { overlayId: payload.overlayId };\n if (payload.instanceId !== undefined) raw.instanceId = payload.instanceId;\n if (payload.data !== undefined) raw.data = stripFunctions(payload.overlayId, payload.data);\n const defaults: unknown = getOverlayMeta(payload.overlayId)?.defaults;\n if (isPlainRecord(defaults)) raw.defaults = stripFunctions(payload.overlayId, defaults) as Record<string, unknown>;\n return raw;\n}\n\nconst O = \"overlays/\";\n\nexport const openOverlay = creator(O + \"openOverlay\", <Id extends OverlayId>(payload: OpenOverlayPayload<Id>) => rawOpen(payload));\n\nexport const closeOverlay = creator(O + \"closeOverlay\", <Id extends OverlayId>(payload: CloseOverlayPayload<Id>) =>\n payload.instanceId === undefined\n ? { overlayId: payload.overlayId as string }\n : { overlayId: payload.overlayId as string, instanceId: payload.instanceId },\n);\n\nexport const toggleOverlay = creator(O + \"toggleOverlay\", <Id extends OverlayId>(payload: ToggleOverlayPayload<Id>) => rawOpen(payload));\n\nexport const closeAllInstancesOfOverlay = creator(\n O + \"closeAllInstancesOfOverlay\",\n <Id extends OverlayId>(payload: CloseAllInstancesPayload<Id>) => ({ overlayId: payload.overlayId as string }),\n);\n\n/** Ids of every registered overlay whose definition says `closesOnNavigation`. */\nexport function overlayIdsBoundToPage(): string[] {\n return allOverlayMeta()\n .filter((meta) => meta.closesOnNavigation === true)\n .map((meta) => meta.id);\n}\n\n/** Close page-bound overlays. Omit the ids to use the registry's `closesOnNavigation` list. */\nexport const closeOverlaysBoundToPage = creator(\n O + \"closeOverlaysBoundToPage\",\n (payload?: Partial<CloseOverlaysBoundToPagePayload>): CloseOverlaysBoundToPagePayload => ({\n overlayIds: [...(payload?.overlayIds ?? overlayIdsBoundToPage())],\n }),\n);\n\nexport const closeAllOverlays = creator(O + \"closeAllOverlays\", () => undefined);\nexport const pruneStaleInstances = creator(O + \"pruneStaleInstances\", (payload: PruneStaleInstancesPayload) => payload);\n\n// ── Window manager: the ones callers outside a window dispatch (menus, shortcuts, settings) ──\n\nconst W = \"windowManager/\";\nconst pass = <P>() => (payload: P) => payload;\n\nexport const focusWindow = creator(W + \"focusWindow\", pass<string>());\nexport const restoreWindow = creator(W + \"restoreWindow\", pass<string>());\nexport const toggleWindowsHidden = creator(W + \"toggleWindowsHidden\", () => undefined);\nexport const restoreAll = creator(W + \"restoreAll\", () => undefined);\nexport const minimizeAll = creator(W + \"minimizeAll\", pass<{ viewportWidth: number; viewportHeight: number }>());\n\n/** Every slice key the summon reducers own; an action under one of them needs the runtime. */\nexport const SUMMON_SLICE_KEYS = [\"overlays\", \"windowManager\", \"urlSync\", \"overlayState\"] as const;\n\nexport function isSummonAction(action: unknown): action is { type: string } {\n if (typeof action !== \"object\" || action === null) return false;\n const type = (action as { type?: unknown }).type;\n if (typeof type !== \"string\") return false;\n const slash = type.indexOf(\"/\");\n return slash > 0 && (SUMMON_SLICE_KEYS as readonly string[]).includes(type.slice(0, slash));\n}\n\nexport { DEFAULT_INSTANCE_ID };\n","// The public overlay selectors, light and safe before the runtime: a host that loads the summon\n// slices on first use (the gate) has no `overlays` key until then, and every overlay reads closed.\nimport { DEFAULT_INSTANCE_ID } from \"../core/types\";\nimport { globalSlot } from \"@ai-matrx/kit/global-slot\";\n\nexport interface OverlayInstance {\n isOpen: boolean;\n data: unknown;\n /** Unix ms of the last open (pruneStaleInstances reads it). */\n lastUsedAt?: number;\n}\n\nexport interface OverlayState {\n overlays: Record<string, Record<string, OverlayInstance>>;\n}\n\n/** The slice of any store these selectors need (absent until the summon runtime is installed). */\nexport type StateWithOverlays = { overlays?: OverlayState };\n\nexport interface OpenInstanceView {\n instanceId: string;\n data: unknown;\n}\n\nconst CLOSED: OverlayInstance = Object.freeze({ isOpen: false, data: null });\nconst EMPTY: readonly OpenInstanceView[] = Object.freeze([]);\n\nexport const selectOverlay = (state: StateWithOverlays, overlayId: string, instanceId: string = DEFAULT_INSTANCE_ID): OverlayInstance =>\n state.overlays?.overlays[overlayId]?.[instanceId] ?? CLOSED;\n\nexport const selectIsOverlayOpen = (state: StateWithOverlays, overlayId: string, instanceId: string = DEFAULT_INSTANCE_ID): boolean =>\n selectOverlay(state, overlayId, instanceId).isOpen;\n\nexport const selectOverlayData = (state: StateWithOverlays, overlayId: string, instanceId: string = DEFAULT_INSTANCE_ID): unknown =>\n selectOverlay(state, overlayId, instanceId).data;\n\ninterface CachedOpen {\n bucket: Record<string, OverlayInstance> | undefined;\n result: readonly OpenInstanceView[];\n}\nconst openCache = (): Map<string, CachedOpen> => globalSlot(\"ai-matrx.summon.openInstances\", () => new Map<string, CachedOpen>());\n\n/** All open instances of an overlay id; the array reference is stable while the open set is unchanged. */\nexport const selectOpenInstances = (state: StateWithOverlays, overlayId: string): readonly OpenInstanceView[] => {\n const bucket = state.overlays?.overlays[overlayId];\n const cache = openCache();\n const hit = cache.get(overlayId);\n if (hit && hit.bucket === bucket) return hit.result;\n let result: readonly OpenInstanceView[] = EMPTY;\n if (bucket) {\n const open: OpenInstanceView[] = [];\n for (const [instanceId, inst] of Object.entries(bucket)) if (inst.isOpen) open.push({ instanceId, data: inst.data });\n if (open.length > 0) result = open;\n }\n cache.set(overlayId, { bucket, result });\n return result;\n};\n\n/** Every open instance key (`overlayId:instanceId`). */\nexport function listOpenInstanceKeys(state: StateWithOverlays): string[] {\n const keys: string[] = [];\n for (const [overlayId, bucket] of Object.entries(state.overlays?.overlays ?? {})) {\n for (const [instanceId, inst] of Object.entries(bucket)) if (inst.isOpen) keys.push(`${overlayId}:${instanceId}`);\n }\n return keys;\n}\n\n/** True once anything has ever been opened in this store (a key exists in the slice). */\nexport function selectAnyOverlayTouched(state: StateWithOverlays): boolean {\n for (const _ in state.overlays?.overlays ?? {}) return true;\n return false;\n}\n\n/** The global hide-all flag (false before the runtime is installed). */\nexport const selectWindowsHidden = (state: { windowManager?: { windowsHidden: boolean } }): boolean =>\n state.windowManager?.windowsHidden ?? false;\n","// The summon gate: a host store carries NONE of the summon slices or middleware until something\n// needs them. The gate is one middleware in the host chain. Before the core is loaded, every\n// summon action (open, close, a window action…) is queued and the first one starts ONE import()\n// of the core; when the core module evaluates it installs itself into every gate — the slices are\n// injected into the host's root reducer, the real middleware (close lifecycle, render watchdog)\n// joins the chain, and the queue replays in order. A host may also start the import early\n// (`prefetchSummonRuntime` on idle or pointer intent) so the first click opens at once.\n//\n// A module that needs the slices synchronously (the window section, links, persistence) imports\n// the core statically; the core installs at evaluation, so its state exists before it renders.\nimport type { Dispatch, Middleware, MiddlewareAPI, Reducer, UnknownAction } from \"@reduxjs/toolkit\";\nimport { globalSlot } from \"@ai-matrx/kit/global-slot\";\nimport type { SummonPorts } from \"../core/ports\";\nimport { isSummonAction } from \"./actions\";\n\n/** What the core hands the gate when it loads. */\nexport interface SummonCore {\n readonly reducers: Readonly<Record<string, Reducer>>;\n createMiddleware(ports?: Partial<SummonPorts>): Middleware[];\n}\n\n/** Dispatched once after the slices are injected into a live store, so they hold their initial state. */\nexport const SUMMON_INSTALLED_ACTION = \"@@summon/installed\";\n\ninterface GateInternals {\n install(core: SummonCore): void;\n}\n\ninterface GateSlot {\n core: SummonCore | null;\n loading: Promise<void> | null;\n readonly gates: Set<GateInternals>;\n readonly listeners: Set<() => void>;\n}\n\nconst slot = (): GateSlot =>\n globalSlot<GateSlot>(\"ai-matrx.summon.gate\", () => ({ core: null, loading: null, gates: new Set(), listeners: new Set() }));\n\n/** Called by the core module when it evaluates (idempotent). */\nexport function installSummonCore(core: SummonCore): void {\n const s = slot();\n if (s.core) return;\n s.core = core;\n const gates = [...s.gates];\n s.gates.clear();\n for (const gate of gates) gate.install(core);\n for (const listener of [...s.listeners]) listener();\n}\n\nexport function isSummonInstalled(): boolean {\n return slot().core !== null;\n}\n\nexport function subscribeSummonInstalled(listener: () => void): () => void {\n const s = slot();\n s.listeners.add(listener);\n return () => s.listeners.delete(listener);\n}\n\n/** Load the summon core (one import(), shared by every caller). Resolves once it is installed. */\nexport function ensureSummonRuntime(): Promise<void> {\n const s = slot();\n if (s.core) return Promise.resolve();\n s.loading ??= import(\"@ai-matrx/summon\").then(\n (core) => installSummonCore(core.summonCore),\n (error: unknown) => {\n s.loading = null; // a failed chunk may be retried by the next request\n throw error;\n },\n );\n return s.loading;\n}\n\n/** Start loading the core without waiting (idle, pointer intent). Errors surface on the next real request. */\nexport function prefetchSummonRuntime(): void {\n ensureSummonRuntime().catch(() => undefined);\n}\n\nexport interface SummonGate {\n /** Put this in the host store's middleware chain. */\n readonly middleware: Middleware;\n /**\n * Give the gate the host root reducer's inject function — before `configureStore`, so a core\n * that is already loaded (a page that imported the window section) is injected before the\n * store's first state exists.\n */\n attachReducer(inject: (reducers: Readonly<Record<string, Reducer>>) => void): void;\n}\n\nexport interface CreateSummonGateOptions {\n /** Ports for the summon middleware (render watchdog: notify, errors, debug). */\n readonly ports?: Partial<SummonPorts>;\n}\n\nexport function createSummonGate(options: CreateSummonGateOptions = {}): SummonGate {\n let inject: ((reducers: Readonly<Record<string, Reducer>>) => void) | null = null;\n let injected = false;\n let api: MiddlewareAPI<Dispatch<UnknownAction>, unknown> | null = null;\n let next: ((action: unknown) => unknown) | null = null;\n let chain: ((action: unknown) => unknown) | null = null;\n const queue: unknown[] = [];\n\n const settle = (core: SummonCore, live: boolean) => {\n if (inject && !injected) {\n inject(core.reducers);\n injected = true;\n }\n if (!api || !next || chain) return;\n const store = api;\n let composed: (action: unknown) => unknown = next;\n for (const middleware of [...core.createMiddleware(options.ports)].reverse()) {\n composed = middleware(store)(composed) as (action: unknown) => unknown;\n }\n chain = composed;\n const flush = () => {\n if (live) store.dispatch({ type: SUMMON_INSTALLED_ACTION });\n for (const action of queue.splice(0)) store.dispatch(action as UnknownAction);\n };\n // Redux forbids dispatching while the middleware chain is being built.\n if (live) flush();\n else if (queue.length > 0) queueMicrotask(flush);\n };\n\n const internals: GateInternals = { install: (core) => settle(core, true) };\n const core = () => slot().core;\n\n const middleware: Middleware = (storeApi) => {\n api = storeApi as MiddlewareAPI<Dispatch<UnknownAction>, unknown>;\n return (nextDispatch) => {\n next = nextDispatch as (action: unknown) => unknown;\n const loaded = core();\n if (loaded) settle(loaded, false);\n else slot().gates.add(internals);\n return (action) => {\n if (chain) return chain(action);\n if (!isSummonAction(action)) return nextDispatch(action);\n queue.push(action);\n void ensureSummonRuntime().catch((error: unknown) => {\n // eslint-disable-next-line no-console\n console.error(\"[summon] the overlay runtime failed to load; queued requests are kept for the next try\", error);\n });\n return action;\n };\n };\n };\n\n return {\n middleware,\n attachReducer(fn) {\n inject = fn;\n const loaded = core();\n if (loaded) {\n inject(loaded.reducers);\n injected = true;\n }\n },\n };\n}\n","// Callback-aware opening without loading the handles registry up front. The opener needs a\n// channel id synchronously (it rides open data); the channel itself is created when the handles\n// section arrives — one import() started by the first such open — or at once by whoever emits\n// first (the render tree has handles statically). Closing the owner before then drops it.\nimport { globalSlot } from \"@ai-matrx/kit/global-slot\";\nimport type { EventChannel } from \"../handles/helpers\";\n\ntype Handlers = Readonly<Record<string, ((payload: unknown) => void) | undefined>> | undefined;\n\ninterface PendingChannel {\n readonly owner: string;\n readonly getHandlers: () => Handlers;\n}\n\n/** The one message shape on an overlay's channel. */\nexport interface OverlayEventMessage {\n readonly type: string;\n readonly payload: unknown;\n}\n\ntype CreateChannel = (options: { owner?: string; id?: string }) => EventChannel<OverlayEventMessage>;\n\nconst pending = (): Map<string, PendingChannel> => globalSlot(\"ai-matrx.summon.pendingChannels\", () => new Map<string, PendingChannel>());\n\n/** Create every pending channel now (idempotent per id). */\nexport function materializePendingChannels(createEventChannel: CreateChannel): void {\n const map = pending();\n for (const [id, entry] of [...map]) {\n map.delete(id);\n const channel = createEventChannel({ owner: entry.owner, id });\n channel.subscribe((message) => entry.getHandlers()?.[message.type]?.(message.payload));\n }\n}\n\n/** Reserve a channel owned by `owner` whose events go to the handlers `getHandlers` returns at emit time. */\nexport function openPendingEventChannel(owner: string, getHandlers: () => Handlers): string {\n const id = `ch-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;\n pending().set(id, { owner, getHandlers });\n void import(\"@ai-matrx/summon/handles\").then(({ createEventChannel }) => materializePendingChannels(createEventChannel));\n return id;\n}\n\n/** The owner closed before its channel was created: forget it. */\nexport function dropPendingChannelsOf(owner: string): void {\n const map = pending();\n for (const [id, entry] of [...map]) if (entry.owner === owner) map.delete(id);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACwCO,IAAM,sBAAsB;AAiB5B,SAAS,YAAY,WAAmB,aAAqB,qBAAkC;AACpG,SAAO,GAAG,SAAS,IAAI,UAAU;AACnC;AAEO,SAAS,iBAAiB,KAA+D;AAC9F,QAAM,KAAK,IAAI,QAAQ,GAAG;AAC1B,MAAI,MAAM,KAAK,OAAO,IAAI,SAAS,EAAG,QAAO;AAC7C,SAAO,EAAE,WAAW,IAAI,MAAM,GAAG,EAAE,GAAG,YAAY,IAAI,MAAM,KAAK,CAAC,EAAE;AACtE;AAgGO,SAAS,mBAAmB,MAA4D;AAC7F,SAAO,KAAK,QAAQ,YAAY,KAAK;AACvC;;;ACxEA,IAAM,OAAO,MAAY;AAAC;AAEnB,IAAM,oBAAkC;AAAA,EAC7C,SAAS,OAAO,EAAE,KAAK,aAAa,OAAO,KAAK;AAAA,EAChD,WAAW,MAAM;AACnB;AAGO,IAAM,iBAA6B;AAAA,EACxC,UAAU,MAAO,OAAO,WAAW,cAAc,MAAM,OAAO,SAAS;AAAA,EACvE,QAAQ,MAAO,OAAO,WAAW,cAAc,KAAK,OAAO,SAAS;AAAA,EACpE,eAAe,CAAC,eAAe;AAC7B,QAAI,OAAO,WAAW,YAAa;AACnC,UAAM,QA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,sBAA2B;AAkB3B,IAAM,UAAU,UAAmC,gCAAW,mCAAmC,MAAM,oBAAI,IAA4B,CAAC;AAGjI,SAAS,2BAA2B,oBAAyC;AAClF,QAAM,MAAM,QAAQ;AACpB,aAAW,CAAC,IAAI,KAAK,KAAK,CAAC,GAAG,GAAG,GAAG;AAClC,QAAI,OAAO,EAAE;AACb,UAAM,UAAU,mBAAmB,EAAE,OAAO,MAAM,OAAO,GAAG,CAAC;AAC7D,YAAQ,UAAU,CAAC,YAAY,MAAM,YAAY,IAAI,QAAQ,IAAI,IAAI,QAAQ,OAAO,CAAC;AAAA,EACvF;AACF;AAGO,SAAS,wBAAwB,OAAe,aAAqC;AAC1F,QAAM,KAAK,MAAM,KAAK,IAAI,EAAE,SAAS,EAAE,CAAC,IAAI,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,MAAM,GAAG,EAAE,CAAC;AACnF,UAAQ,EAAE,IAAI,IAAI,EAAE,OAAO,YAAY,CAAC;AACxC,OAAK,OAAO,0BAA0B,EAAE,KAAK,CAAC,EAAE,mBAAmB,MAAM,2BAA2B,kBAAkB,CAAC;AACvH,SAAO;AACT;AAGO,SAAS,sBAAsB,OAAqB;AACzD,QAAM,MAAM,QAAQ;AACpB,aAAW,CAAC,IAAI,KAAK,KAAK,CAAC,GAAG,GAAG,EAAG,KAAI,MAAM,UAAU,MAAO,KAAI,OAAO,EAAE;AAC9E;","names":["import_global_slot","state","import_global_slot","core","middleware","import_global_slot"]}
|
|
1
|
+
{"version":3,"sources":["../src/open.ts","../src/core/types.ts","../src/core/ports.ts","../src/core/registry.ts","../src/open/actions.ts","../src/open/renderAcks.ts","../src/open/selectors.ts","../src/open/gate.ts","../src/open/channels.ts"],"sourcesContent":["// @ai-matrx/summon/open — what a page pays before anything opens: the action creators (plain\n// objects with the slices' type strings), selectors that read \"closed\" until the runtime exists,\n// the definition registry, ports, and the gate that loads the core on the first request.\n// Framework-free; never loads a slice, the middleware, React, or the handles registry.\nexport * from \"./core/types\";\nexport * from \"./core/ports\";\nexport * from \"./core/registry\";\nexport {\n openOverlay,\n closeOverlay,\n toggleOverlay,\n closeAllInstancesOfOverlay,\n closeOverlaysBoundToPage,\n closeAllOverlays,\n pruneStaleInstances,\n overlayIdsBoundToPage,\n focusWindow,\n restoreWindow,\n toggleWindowsHidden,\n restoreAll,\n minimizeAll,\n registerSyncEntry,\n unregisterSyncEntry,\n isSummonAction,\n SUMMON_SLICE_KEYS,\n type OpenOverlayPayload,\n type CloseOverlayPayload,\n type ToggleOverlayPayload,\n type CloseAllInstancesPayload,\n type CloseOverlaysBoundToPagePayload,\n type PruneStaleInstancesPayload,\n type RawOpenPayload,\n type SummonAction,\n type UrlSyncEntryPayload,\n} from \"./open/actions\";\nexport { ackOverlaySurfaceRender, clearOverlaySurfaceRender } from \"./open/renderAcks\";\nexport {\n selectOverlay,\n selectIsOverlayOpen,\n selectOverlayData,\n selectOpenInstances,\n listOpenInstanceKeys,\n selectAnyOverlayTouched,\n selectWindowsHidden,\n selectAllWindows,\n type OverlayInstance,\n type OverlayState,\n type StateWithOverlays,\n type OpenInstanceView,\n} from \"./open/selectors\";\nexport {\n createSummonGate,\n installSummonCore,\n isSummonInstalled,\n subscribeSummonInstalled,\n ensureSummonRuntime,\n prefetchSummonRuntime,\n SUMMON_INSTALLED_ACTION,\n type SummonCore,\n type SummonGate,\n type CreateSummonGateOptions,\n} from \"./open/gate\";\nexport { openPendingEventChannel, materializePendingChannels, dropPendingChannelsOf, type OverlayEventMessage } from \"./open/channels\";\n","/**\n * The shared vocabulary of @ai-matrx/summon. Framework-free: no React, no Redux imports.\n *\n * An OVERLAY is any component rendered on top of the app by dispatch — a window, dialog, sheet,\n * light floating window, toast-like card, anything. It is identified by an `OverlayId` and opened\n * as one or more INSTANCES (`instanceId`, \"default\" for single-instance overlays).\n */\n\n/**\n * The host's overlay registry: overlay id → the data its opener accepts. Hosts extend it by\n * module augmentation so every open call is type-checked:\n *\n * declare module \"@ai-matrx/summon\" {\n * interface OverlayRegistry { notesWindow: { noteId?: string } }\n * }\n *\n * `defineOverlay` emits nothing at runtime for this; the augmentation is the host's one-line\n * declaration per overlay (the converter writes it next to each definition).\n */\n// Declared in ./augment (bundled only into the core's declarations, so `declare module\n// \"@ai-matrx/summon\"` merges into it); every section reads it through the package name.\nimport type { OverlayRegistry, OverlayHostTypes } from \"@ai-matrx/summon\";\nexport type { OverlayRegistry, OverlayHostTypes };\n\n/** Every registered overlay id; plain `string` until the host augments the registry. */\nexport type OverlayId = [keyof OverlayRegistry] extends [never]\n ? string\n : Extract<keyof OverlayRegistry, string>;\n\n/** The open-data type declared for an overlay id. */\nexport type OverlayDataOf<Id extends string> = Id extends keyof OverlayRegistry\n ? OverlayRegistry[Id]\n : Record<string, unknown>;\n\n/**\n * Data as it arrives at render time. It crossed Redux, a URL or storage, so it is NOT trusted to\n * match the opener's type: render code narrows it (or the definition supplies `parse`).\n */\nexport type OverlayRawData = Readonly<Record<string, unknown>> | null;\n\nexport const DEFAULT_INSTANCE_ID = \"default\";\n\n/** `single`: one instance (\"default\"). `multi`: any number, each with its own instanceId. */\nexport type InstanceMode = \"single\" | \"multi\";\n\n/**\n * What closing does to a mounted overlay (Arman, 2026-10-16, C38 R3):\n * none — unmount (default).\n * hidden — stay mounted but hidden; reopening shows the same live component (LRU-capped).\n * restore — unmount, but values saved with `useOverlayState` come back on reopen.\n * Minimizing a window always keeps its component mounted, whatever this says.\n */\nexport type KeepAlive = \"none\" | \"hidden\" | \"restore\";\n\n/** `overlayId:instanceId` — the one key every subsystem uses for an open instance. */\nexport type InstanceKey = `${string}:${string}`;\n\nexport function instanceKey(overlayId: string, instanceId: string = DEFAULT_INSTANCE_ID): InstanceKey {\n return `${overlayId}:${instanceId}`;\n}\n\nexport function parseInstanceKey(key: string): { overlayId: string; instanceId: string } | null {\n const at = key.indexOf(\":\");\n if (at <= 0 || at === key.length - 1) return null;\n return { overlayId: key.slice(0, at), instanceId: key.slice(at + 1) };\n}\n\n// ── Window options (consumed by the window surface; inert for other surfaces) ──────────────────\n\nexport type MobilePresentation = \"fullscreen\" | \"drawer\" | \"card\" | \"hidden\";\n\n/**\n * Default-deny allowlist of the open data a window may save and restore. A window with no\n * preservation entry restores geometry only.\n */\nexport interface WindowPreservation {\n readonly dataKeys: readonly string[];\n readonly requiredDataKeys?: readonly string[];\n readonly allowedDataValues?: Readonly<Record<string, readonly (string | number | boolean | null)[]>>;\n /** Default 32 KiB. */\n readonly maxDataBytes?: number;\n}\n\n/** One declared home for an unbidden (system-raised) window: a route prefix, or one exact page. */\nexport type UnbiddenHomeRoute = string | { readonly route: string; readonly exact: true };\n\nexport interface OverlayWindowOptions {\n readonly mobile?: MobilePresentation;\n readonly mobileSidebarAs?: \"drawer\" | \"inline\";\n /** Never saved or restored (debug panels, one-shot tools, callback-bound editors). */\n readonly ephemeral?: boolean;\n readonly preservation?: WindowPreservation;\n /**\n * Values merged under saved data when a window is RESTORED (reload, another device). Unlike the\n * definition's `defaults`, never applied to a normal open.\n */\n readonly restoreDefaults?: Readonly<Record<string, unknown>>;\n /**\n * The window-manager id the WindowPanel registers under for the default instance. Default: the\n * overlay id. The render watchdog reveals and inspects this id until the panel acks its own.\n */\n readonly windowId?: string;\n readonly deprecated?: { readonly replacement?: string; readonly reason?: string };\n /**\n * Where a window nobody opened (system-raised) may raise itself. Default deny: no home → it may\n * not raise itself anywhere (`mayRaiseUnbidden` in the window section).\n */\n readonly unbiddenHome?: readonly UnbiddenHomeRoute[];\n}\n\n// ── Host types (augmentable) ────────────────────────────────────────────────────────────────\n\n/**\n * Host-specific types the package passes through untouched. A Redux host augments `dispatch`\n * with its thunk-aware dispatch so link hydrators can dispatch its thunks without casts:\n *\n * declare module \"@ai-matrx/summon\" { interface OverlayHostTypes { dispatch: AppDispatch } }\n */\nexport type OverlayHostDispatch = OverlayHostTypes extends { dispatch: infer D } ? D : (action: unknown) => unknown;\n\n// ── Links (address-bar references) ──────────────────────────────────────────────────────────\n\nexport interface LinkHydrateContext<Data> {\n /** The id segment of the link token (`notes:<id>`). */\n readonly id: string;\n /** Decoded `k-v` arguments of the token. */\n readonly args: Readonly<Record<string, string>>;\n /** Open this overlay. */\n open(options?: { readonly instanceId?: string; readonly data?: Data }): void;\n /** The host store's dispatch, for thunks a hydrator needs (loading a record first). Typed by\n * augmenting `OverlayHostTypes` with the host's dispatch type. */\n readonly dispatch: OverlayHostDispatch;\n}\n\nexport interface OverlayLinkSpec<Data> {\n /** The token type key in `?panels=key:id`. Unique across the host. */\n readonly key: string;\n /** Older keys that still resolve to this overlay. */\n readonly aliases?: readonly string[];\n /** Turn a link token into an open overlay (and its data). `\"refused\"` keeps the token and says why. */\n hydrate(context: LinkHydrateContext<Data>): void | \"refused\" | Promise<void | \"refused\">;\n}\n\n// ── Definitions (framework-free half; the React half adds `render`) ─────────────────────────\n\nexport interface OverlayDefinitionMeta<Id extends string = string, Data = Record<string, unknown>> {\n readonly id: Id;\n /** Human label: tray, menus, diagnostics. */\n readonly label: string;\n readonly instance?: InstanceMode;\n readonly keepAlive?: KeepAlive;\n /** Close when the route changes — the overlay shows a piece of the page that opened it. */\n readonly closesOnNavigation?: boolean;\n /** Present only for overlays that render a WindowPanel. */\n readonly window?: OverlayWindowOptions;\n readonly link?: OverlayLinkSpec<Data>;\n /** Defaults merged under open data (replaces the old per-overlay schema registry). */\n readonly defaults?: Partial<Data>;\n}\n\n/** The window-manager id a singleton window overlay registers under (`window.windowId ?? id`). */\nexport function defaultWindowIdFor(meta: Pick<OverlayDefinitionMeta, \"id\" | \"window\">): string {\n return meta.window?.windowId ?? meta.id;\n}\n","/**\n * Everything the overlays system needs from its host, as ports. Every port ships a working\n * default, so a bare host gets a working system with zero wiring (package standard rule 8); a\n * host overrides only what it has: identity, navigation, notifications, error sink, debug flag,\n * persistence. Framework-free.\n */\n\nexport type Unsubscribe = () => void;\n\n/** Who the person is, for isolating saved state. `key` changes → everything saved is swapped. */\nexport interface IdentityPort {\n current(): { readonly key: string; readonly ready: boolean };\n subscribe(listener: () => void): Unsubscribe;\n}\n\n/** The address bar: route changes (close-on-navigation) and the `?panels=` link channel. */\nexport interface RouterPort {\n pathname(): string;\n search(): string;\n /** Replace the query string without navigating or remounting the page. */\n replaceSearch(nextSearch: string): void;\n subscribe(listener: () => void): Unsubscribe;\n}\n\nexport interface NotifyOptions {\n readonly id?: string;\n readonly description?: string;\n /** How long the notice stays up (ms). Hosts without timed notices ignore it. */\n readonly duration?: number;\n /** One action button (e.g. the render watchdog's \"Show it\"). Hosts without actions ignore it. */\n readonly action?: { readonly label: string; readonly onClick: () => void };\n}\n\nexport interface NotifyPort {\n info(message: string, options?: NotifyOptions): void;\n warn(message: string, options?: NotifyOptions): void;\n error(message: string, options?: NotifyOptions): void;\n /** Withdraw a notice by id (optional). */\n dismiss?(id: string): void;\n}\n\nexport interface ErrorSinkPort {\n capture(error: unknown, context: Readonly<Record<string, unknown>>): void;\n}\n\nexport interface DebugPort {\n enabled(): boolean;\n subscribe?(listener: () => void): Unsubscribe;\n}\n\n/** A stored value with its optimistic-concurrency version (0 when the store has none). */\nexport interface StoredValue<T = unknown> {\n readonly value: T;\n readonly version: number;\n}\n\n/**\n * Where saved overlay state lives when persistence is on. Keys are already scoped to the\n * identity by the caller (`<identityKey>/<key>`) for stores that are not per-person themselves.\n * Implementations: the browser-local store (`./persistence`), `@ai-matrx/data` over\n * `users.user_surface_state` (`./persistence/data`), or any host database.\n */\nexport interface OverlayPersistencePort {\n /**\n * True when the store is per-person itself (rows scoped to the signed-in person, e.g. the\n * `@ai-matrx/data` adapter): the persistence section then passes plain keys (`workspace`,\n * `state:<instanceKey>`) instead of `<identityKey>/<key>`, and defaults to `scope: \"person\"`.\n */\n readonly perPerson?: boolean;\n load<T = unknown>(key: string): Promise<StoredValue<T> | null>;\n save<T = unknown>(key: string, value: T, options?: { readonly expectedVersion?: number }): Promise<{ readonly version: number }>;\n remove(key: string): Promise<void>;\n list?(prefix: string): Promise<readonly string[]>;\n /**\n * Every saved value at once (key → value), for stores where one read is cheaper than several.\n * When present, restoring an identity costs exactly this one call: the workspace and every\n * saved component state come out of it, and `load`/`list` are not called on boot.\n */\n loadAll?(): Promise<ReadonlyMap<string, StoredValue>>;\n}\n\nexport interface SummonPorts {\n readonly identity: IdentityPort;\n readonly router: RouterPort;\n readonly notify: NotifyPort;\n readonly errors: ErrorSinkPort;\n readonly debug: DebugPort;\n /** `null` = persistence off (R6). */\n readonly persistence: OverlayPersistencePort | null;\n}\n\nconst noop = (): void => {};\n\nexport const anonymousIdentity: IdentityPort = {\n current: () => ({ key: \"anonymous\", ready: true }),\n subscribe: () => noop,\n};\n\n/** `window.location` + `history.replaceState`; inert on the server. */\nexport const locationRouter: RouterPort = {\n pathname: () => (typeof window === \"undefined\" ? \"/\" : window.location.pathname),\n search: () => (typeof window === \"undefined\" ? \"\" : window.location.search),\n replaceSearch: (nextSearch) => {\n if (typeof window === \"undefined\") return;\n const query = nextSearch && !nextSearch.startsWith(\"?\") ? `?${nextSearch}` : nextSearch;\n const url = `${window.location.pathname}${query}${window.location.hash}`;\n window.history.replaceState(window.history.state, \"\", url);\n },\n subscribe: (listener) => {\n if (typeof window === \"undefined\") return noop;\n window.addEventListener(\"popstate\", listener);\n return () => window.removeEventListener(\"popstate\", listener);\n },\n};\n\n/* eslint-disable no-console */\nexport const consoleNotify: NotifyPort = {\n info: (message) => console.info(`[summon] ${message}`),\n warn: (message) => console.warn(`[summon] ${message}`),\n error: (message) => console.error(`[summon] ${message}`),\n};\n\nexport const consoleErrorSink: ErrorSinkPort = {\n capture: (error, context) => console.error(\"[summon]\", error, context),\n};\n/* eslint-enable no-console */\n\nexport const debugOff: DebugPort = { enabled: () => false };\n\nexport const DEFAULT_PORTS: SummonPorts = {\n identity: anonymousIdentity,\n router: locationRouter,\n notify: consoleNotify,\n errors: consoleErrorSink,\n debug: debugOff,\n persistence: null,\n};\n\nexport function resolvePorts(overrides: Partial<SummonPorts> | undefined): SummonPorts {\n return { ...DEFAULT_PORTS, ...overrides };\n}\n","/**\n * The process-wide registry of overlay definition metadata (the framework-free half of each\n * definition). The host registers its definitions once (`<SummonHost definitions>` does it);\n * reducers stay pure — middleware and hooks read this registry and put what reducers need in the\n * action payload (e.g. the ids bound to the page).\n *\n * State lives in a global slot so a duplicated module graph (ESM + CJS, unsplit bundles) sees one\n * registry (kit `globalSlot`, architecture D9).\n */\nimport { globalSlot } from \"@ai-matrx/kit/global-slot\";\nimport type { OverlayDefinitionMeta } from \"./types\";\n\n/**\n * A definition's meta with its data type erased, so definitions of every data shape share one\n * registry without casts. (`never` erasure made `defaults` unassignable.)\n */\nexport interface AnyOverlayMeta extends Omit<OverlayDefinitionMeta<string, unknown>, \"defaults\"> {\n readonly defaults?: object | undefined;\n}\n\ntype AnyMeta = AnyOverlayMeta;\n\ninterface RegistryState {\n readonly byId: Map<string, AnyMeta>;\n readonly byLinkKey: Map<string, AnyMeta>;\n readonly listeners: Set<() => void>;\n}\n\nconst state = (): RegistryState =>\n globalSlot<RegistryState>(\"ai-matrx.summon.registry\", () => ({\n byId: new Map(),\n byLinkKey: new Map(),\n listeners: new Set(),\n }));\n\n/**\n * Register (or re-register) definitions. Re-registering an id replaces it (hot reload). A link\n * key claimed by two different ids is a host bug and throws, naming both.\n */\nexport function registerOverlayMeta(definitions: readonly AnyOverlayMeta[]): void {\n const s = state();\n for (const def of definitions) {\n s.byId.set(def.id, def);\n const keys = def.link ? [def.link.key, ...(def.link.aliases ?? [])] : [];\n for (const key of keys) {\n const holder = s.byLinkKey.get(key);\n if (holder && holder.id !== def.id) {\n throw new Error(`[summon] link key \"${key}\" is claimed by both \"${holder.id}\" and \"${def.id}\"`);\n }\n s.byLinkKey.set(key, def);\n }\n }\n for (const listener of s.listeners) listener();\n}\n\nexport function getOverlayMeta(overlayId: string): AnyMeta | undefined {\n return state().byId.get(overlayId);\n}\n\nexport function getOverlayMetaByLinkKey(linkKey: string): AnyMeta | undefined {\n return state().byLinkKey.get(linkKey);\n}\n\nexport function allOverlayMeta(): readonly AnyMeta[] {\n return [...state().byId.values()];\n}\n\nexport function isRegisteredOverlay(overlayId: string): boolean {\n return state().byId.has(overlayId);\n}\n\nexport function subscribeToOverlayRegistry(listener: () => void): () => void {\n const s = state();\n s.listeners.add(listener);\n return () => s.listeners.delete(listener);\n}\n\n/** Test-only. */\nexport function resetOverlayRegistry(): void {\n const s = state();\n s.byId.clear();\n s.byLinkKey.clear();\n}\n","// The public action creators, light: plain objects with the slices' own type strings, so a file\n// that only opens or closes something never loads a slice. The slices (core) handle these exact\n// types; `actions.parity.test.ts` proves every creator here equals its slice twin.\n//\n// `openOverlay`/`toggleOverlay` keep the two guarantees the slice creators had: functions are\n// stripped from open data (they can never travel through Redux — the D33 dead-button class) and\n// the definition's registered `defaults` ride the payload, so the reducer stays pure.\nimport { getOverlayMeta, allOverlayMeta } from \"../core/registry\";\nimport { DEFAULT_INSTANCE_ID, type OverlayDataOf, type OverlayId } from \"../core/types\";\n\nexport interface OpenOverlayPayload<Id extends OverlayId = OverlayId> {\n overlayId: Id;\n instanceId?: string;\n data?: OverlayDataOf<Id> | null;\n}\n\nexport interface CloseOverlayPayload<Id extends OverlayId = OverlayId> {\n overlayId: Id;\n instanceId?: string;\n}\n\nexport type ToggleOverlayPayload<Id extends OverlayId = OverlayId> = OpenOverlayPayload<Id>;\n\nexport interface CloseAllInstancesPayload<Id extends OverlayId = OverlayId> {\n overlayId: Id;\n}\n\nexport interface CloseOverlaysBoundToPagePayload {\n /** Overlay ids whose definitions say `closesOnNavigation`. */\n overlayIds: readonly string[];\n}\n\nexport interface PruneStaleInstancesPayload {\n olderThanMs: number;\n}\n\n/** Raw reducer payload: untyped ids + the registry defaults the creator resolved. */\nexport interface RawOpenPayload {\n overlayId: string;\n instanceId?: string;\n data?: unknown;\n defaults?: Readonly<Record<string, unknown>>;\n}\n\nexport interface SummonAction<P> {\n type: string;\n payload: P;\n /** Structurally a Redux `UnknownAction`. */\n [extra: string]: unknown;\n}\n\ntype Creator<Args extends unknown[], P> = ((...args: Args) => SummonAction<P>) & {\n readonly type: string;\n match(action: unknown): action is SummonAction<P>;\n};\n\nfunction creator<Args extends unknown[], P>(type: string, build: (...args: Args) => P): Creator<Args, P> {\n const create = (...args: Args): SummonAction<P> => ({ type, payload: build(...args) });\n return Object.assign(create, {\n type,\n toString: () => type,\n match: (action: unknown): action is SummonAction<P> =>\n typeof action === \"object\" && action !== null && (action as { type?: unknown }).type === type,\n });\n}\n\nfunction isPlainRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction stripFunctions(overlayId: string, data: unknown): unknown {\n if (!isPlainRecord(data)) return data;\n const offenders = Object.keys(data).filter((key) => typeof data[key] === \"function\");\n if (offenders.length === 0) return data;\n // eslint-disable-next-line no-console\n console.error(\n `[summon] BUG: function value(s) in openOverlay data for \"${overlayId}\" (keys: ${offenders.join(\", \")}). ` +\n `Functions cannot travel through Redux — the handler would NEVER fire. Register a handle ` +\n `(@ai-matrx/summon/handles) and pass its id string instead. The offending key(s) were stripped from state.`,\n );\n const cleaned = { ...data };\n for (const key of offenders) delete cleaned[key];\n return cleaned;\n}\n\nfunction rawOpen(payload: { overlayId: string; instanceId?: string; data?: unknown }): RawOpenPayload {\n const raw: RawOpenPayload = { overlayId: payload.overlayId };\n if (payload.instanceId !== undefined) raw.instanceId = payload.instanceId;\n if (payload.data !== undefined) raw.data = stripFunctions(payload.overlayId, payload.data);\n const defaults: unknown = getOverlayMeta(payload.overlayId)?.defaults;\n if (isPlainRecord(defaults)) raw.defaults = stripFunctions(payload.overlayId, defaults) as Record<string, unknown>;\n return raw;\n}\n\nconst O = \"overlays/\";\n\nexport const openOverlay = creator(O + \"openOverlay\", <Id extends OverlayId>(payload: OpenOverlayPayload<Id>) => rawOpen(payload));\n\nexport const closeOverlay = creator(O + \"closeOverlay\", <Id extends OverlayId>(payload: CloseOverlayPayload<Id>) =>\n payload.instanceId === undefined\n ? { overlayId: payload.overlayId as string }\n : { overlayId: payload.overlayId as string, instanceId: payload.instanceId },\n);\n\nexport const toggleOverlay = creator(O + \"toggleOverlay\", <Id extends OverlayId>(payload: ToggleOverlayPayload<Id>) => rawOpen(payload));\n\nexport const closeAllInstancesOfOverlay = creator(\n O + \"closeAllInstancesOfOverlay\",\n <Id extends OverlayId>(payload: CloseAllInstancesPayload<Id>) => ({ overlayId: payload.overlayId as string }),\n);\n\n/** Ids of every registered overlay whose definition says `closesOnNavigation`. */\nexport function overlayIdsBoundToPage(): string[] {\n return allOverlayMeta()\n .filter((meta) => meta.closesOnNavigation === true)\n .map((meta) => meta.id);\n}\n\n/** Close page-bound overlays. Omit the ids to use the registry's `closesOnNavigation` list. */\nexport const closeOverlaysBoundToPage = creator(\n O + \"closeOverlaysBoundToPage\",\n (payload?: Partial<CloseOverlaysBoundToPagePayload>): CloseOverlaysBoundToPagePayload => ({\n overlayIds: [...(payload?.overlayIds ?? overlayIdsBoundToPage())],\n }),\n);\n\nexport const closeAllOverlays = creator(O + \"closeAllOverlays\", () => undefined);\nexport const pruneStaleInstances = creator(O + \"pruneStaleInstances\", (payload: PruneStaleInstancesPayload) => payload);\n\n// ── Window manager: the ones callers outside a window dispatch (menus, shortcuts, settings) ──\n\nconst W = \"windowManager/\";\nconst pass = <P>() => (payload: P) => payload;\n\nexport const focusWindow = creator(W + \"focusWindow\", pass<string>());\nexport const restoreWindow = creator(W + \"restoreWindow\", pass<string>());\nexport const toggleWindowsHidden = creator(W + \"toggleWindowsHidden\", () => undefined);\nexport const restoreAll = creator(W + \"restoreAll\", () => undefined);\nexport const minimizeAll = creator(W + \"minimizeAll\", pass<{ viewportWidth: number; viewportHeight: number }>());\n\n// ── Links ────────────────────────────────────────────────────────────────────────────────────\n\nexport interface UrlSyncEntryPayload {\n typeKey: string;\n instanceId: string;\n args?: Readonly<Record<string, string>>;\n}\nexport const registerSyncEntry = creator(\"urlSync/registerSyncEntry\", pass<UrlSyncEntryPayload>());\nexport const unregisterSyncEntry = creator(\"urlSync/unregisterSyncEntry\", pass<{ typeKey: string; instanceId: string }>());\n\n/** Every slice key the summon reducers own; an action under one of them needs the runtime. */\nexport const SUMMON_SLICE_KEYS = [\"overlays\", \"windowManager\", \"urlSync\", \"overlayState\"] as const;\n\nexport function isSummonAction(action: unknown): action is { type: string } {\n if (typeof action !== \"object\" || action === null) return false;\n const type = (action as { type?: unknown }).type;\n if (typeof type !== \"string\") return false;\n const slash = type.indexOf(\"/\");\n return slash > 0 && (SUMMON_SLICE_KEYS as readonly string[]).includes(type.slice(0, slash));\n}\n\nexport { DEFAULT_INSTANCE_ID };\n","// Render acknowledgements a mobile surface reports (it renders instead of a WindowPanel). Light:\n// the same slot the render watchdog (core) reads, so a boot-graph hook can report without the core.\nimport { globalSlot } from \"@ai-matrx/kit/global-slot\";\n\ninterface AckSlot {\n readonly renderAcks: Map<string, { kind: \"window\"; windowId: string } | { kind: \"surface\" }>;\n readonly ackWaiters: Map<string, () => void>;\n readonly watches: Map<string, unknown>;\n}\n\n// Same key and shape as core/middleware/renderWatchdog.ts (RENDER_WATCHDOG_SLOT).\nconst slot = (): AckSlot =>\n globalSlot<AckSlot>(\"ai-matrx.summon.renderWatchdog\", () => ({ renderAcks: new Map(), ackWaiters: new Map(), watches: new Map() }));\n\nexport function ackOverlaySurfaceRender(overlayId: string): void {\n const s = slot();\n s.renderAcks.set(overlayId, { kind: \"surface\" });\n const notify = s.ackWaiters.get(overlayId);\n if (notify) {\n s.ackWaiters.delete(overlayId);\n notify();\n }\n}\n\nexport function clearOverlaySurfaceRender(overlayId: string): void {\n const s = slot();\n if (s.renderAcks.get(overlayId)?.kind === \"surface\") s.renderAcks.delete(overlayId);\n}\n","// The public overlay selectors, light and safe before the runtime: a host that loads the summon\n// slices on first use (the gate) has no `overlays` key until then, and every overlay reads closed.\nimport { DEFAULT_INSTANCE_ID } from \"../core/types\";\nimport { globalSlot } from \"@ai-matrx/kit/global-slot\";\n\nexport interface OverlayInstance {\n isOpen: boolean;\n data: unknown;\n /** Unix ms of the last open (pruneStaleInstances reads it). */\n lastUsedAt?: number;\n}\n\nexport interface OverlayState {\n overlays: Record<string, Record<string, OverlayInstance>>;\n}\n\n/** The slice of any store these selectors need (absent until the summon runtime is installed). */\nexport type StateWithOverlays = { overlays?: OverlayState };\n\nexport interface OpenInstanceView {\n instanceId: string;\n data: unknown;\n}\n\nconst CLOSED: OverlayInstance = Object.freeze({ isOpen: false, data: null });\nconst EMPTY: readonly OpenInstanceView[] = Object.freeze([]);\n\nexport const selectOverlay = (state: StateWithOverlays, overlayId: string, instanceId: string = DEFAULT_INSTANCE_ID): OverlayInstance =>\n state.overlays?.overlays[overlayId]?.[instanceId] ?? CLOSED;\n\nexport const selectIsOverlayOpen = (state: StateWithOverlays, overlayId: string, instanceId: string = DEFAULT_INSTANCE_ID): boolean =>\n selectOverlay(state, overlayId, instanceId).isOpen;\n\nexport const selectOverlayData = (state: StateWithOverlays, overlayId: string, instanceId: string = DEFAULT_INSTANCE_ID): unknown =>\n selectOverlay(state, overlayId, instanceId).data;\n\ninterface CachedOpen {\n bucket: Record<string, OverlayInstance> | undefined;\n result: readonly OpenInstanceView[];\n}\nconst openCache = (): Map<string, CachedOpen> => globalSlot(\"ai-matrx.summon.openInstances\", () => new Map<string, CachedOpen>());\n\n/** All open instances of an overlay id; the array reference is stable while the open set is unchanged. */\nexport const selectOpenInstances = (state: StateWithOverlays, overlayId: string): readonly OpenInstanceView[] => {\n const bucket = state.overlays?.overlays[overlayId];\n const cache = openCache();\n const hit = cache.get(overlayId);\n if (hit && hit.bucket === bucket) return hit.result;\n let result: readonly OpenInstanceView[] = EMPTY;\n if (bucket) {\n const open: OpenInstanceView[] = [];\n for (const [instanceId, inst] of Object.entries(bucket)) if (inst.isOpen) open.push({ instanceId, data: inst.data });\n if (open.length > 0) result = open;\n }\n cache.set(overlayId, { bucket, result });\n return result;\n};\n\n/** Every open instance key (`overlayId:instanceId`). */\nexport function listOpenInstanceKeys(state: StateWithOverlays): string[] {\n const keys: string[] = [];\n for (const [overlayId, bucket] of Object.entries(state.overlays?.overlays ?? {})) {\n for (const [instanceId, inst] of Object.entries(bucket)) if (inst.isOpen) keys.push(`${overlayId}:${instanceId}`);\n }\n return keys;\n}\n\n/** True once anything has ever been opened in this store (a key exists in the slice). */\nexport function selectAnyOverlayTouched(state: StateWithOverlays): boolean {\n for (const _ in state.overlays?.overlays ?? {}) return true;\n return false;\n}\n\n/** The global hide-all flag (false before the runtime is installed). */\nexport const selectWindowsHidden = (state: { windowManager?: { windowsHidden: boolean } }): boolean =>\n state.windowManager?.windowsHidden ?? false;\n\ninterface WindowLike {\n readonly zIndex: number;\n}\nconst EMPTY_WINDOWS: readonly never[] = Object.freeze([]);\nlet lastWindowsMap: unknown = null;\nlet lastWindows: readonly WindowLike[] = EMPTY_WINDOWS;\n\n/** Every registered window, topmost first (empty before the runtime is installed). Memoized on the map. */\nexport function selectAllWindows<W extends WindowLike = WindowLike>(state: { windowManager?: { windows: Record<string, W> } }): readonly W[] {\n const map = state.windowManager?.windows;\n if (!map) return EMPTY_WINDOWS;\n if (map !== lastWindowsMap) {\n lastWindowsMap = map;\n lastWindows = Object.values(map).sort((a, b) => b.zIndex - a.zIndex);\n }\n return lastWindows as readonly W[];\n}\n","// The summon gate: a host store carries NONE of the summon slices or middleware until something\n// needs them. The gate is one middleware in the host chain. Before the core is loaded, every\n// summon action (open, close, a window action…) is queued and the first one starts ONE import()\n// of the core; when the core module evaluates it installs itself into every gate — the slices are\n// injected into the host's root reducer, the real middleware (close lifecycle, render watchdog)\n// joins the chain, and the queue replays in order. A host may also start the import early\n// (`prefetchSummonRuntime` on idle or pointer intent) so the first click opens at once.\n//\n// A module that needs the slices synchronously (the window section, links, persistence) imports\n// the core statically; the core installs at evaluation, so its state exists before it renders.\nimport type { Dispatch, Middleware, MiddlewareAPI, Reducer, UnknownAction } from \"@reduxjs/toolkit\";\nimport { globalSlot } from \"@ai-matrx/kit/global-slot\";\nimport type { SummonPorts } from \"../core/ports\";\nimport { isSummonAction } from \"./actions\";\n\n/** What the core hands the gate when it loads. */\nexport interface SummonCore {\n readonly reducers: Readonly<Record<string, Reducer>>;\n createMiddleware(ports?: Partial<SummonPorts>): Middleware[];\n}\n\n/** Dispatched once after the slices are injected into a live store, so they hold their initial state. */\nexport const SUMMON_INSTALLED_ACTION = \"@@summon/installed\";\n\ninterface GateInternals {\n install(core: SummonCore): void;\n}\n\ninterface GateSlot {\n core: SummonCore | null;\n loading: Promise<void> | null;\n readonly gates: Set<GateInternals>;\n readonly listeners: Set<() => void>;\n}\n\nconst slot = (): GateSlot =>\n globalSlot<GateSlot>(\"ai-matrx.summon.gate\", () => ({ core: null, loading: null, gates: new Set(), listeners: new Set() }));\n\n/** Called by the core module when it evaluates (idempotent). */\nexport function installSummonCore(core: SummonCore): void {\n const s = slot();\n if (s.core) return;\n s.core = core;\n const gates = [...s.gates];\n s.gates.clear();\n for (const gate of gates) gate.install(core);\n for (const listener of [...s.listeners]) listener();\n}\n\nexport function isSummonInstalled(): boolean {\n return slot().core !== null;\n}\n\nexport function subscribeSummonInstalled(listener: () => void): () => void {\n const s = slot();\n s.listeners.add(listener);\n return () => s.listeners.delete(listener);\n}\n\n/** Load the summon core (one import(), shared by every caller). Resolves once it is installed. */\nexport function ensureSummonRuntime(): Promise<void> {\n const s = slot();\n if (s.core) return Promise.resolve();\n s.loading ??= import(\"@ai-matrx/summon\").then(\n (core) => installSummonCore(core.summonCore),\n (error: unknown) => {\n s.loading = null; // a failed chunk may be retried by the next request\n throw error;\n },\n );\n return s.loading;\n}\n\n/** Start loading the core without waiting (idle, pointer intent). Errors surface on the next real request. */\nexport function prefetchSummonRuntime(): void {\n ensureSummonRuntime().catch(() => undefined);\n}\n\nexport interface SummonGate {\n /** Put this in the host store's middleware chain. */\n readonly middleware: Middleware;\n /**\n * Give the gate the host root reducer's inject function — before `configureStore`, so a core\n * that is already loaded (a page that imported the window section) is injected before the\n * store's first state exists.\n */\n attachReducer(inject: (reducers: Readonly<Record<string, Reducer>>) => void): void;\n}\n\nexport interface CreateSummonGateOptions {\n /** Ports for the summon middleware (render watchdog: notify, errors, debug). */\n readonly ports?: Partial<SummonPorts>;\n}\n\nexport function createSummonGate(options: CreateSummonGateOptions = {}): SummonGate {\n let inject: ((reducers: Readonly<Record<string, Reducer>>) => void) | null = null;\n let injected = false;\n let api: MiddlewareAPI<Dispatch<UnknownAction>, unknown> | null = null;\n let next: ((action: unknown) => unknown) | null = null;\n let chain: ((action: unknown) => unknown) | null = null;\n const queue: unknown[] = [];\n\n const settle = (core: SummonCore, live: boolean) => {\n if (inject && !injected) {\n inject(core.reducers);\n injected = true;\n }\n if (!api || !next || chain) return;\n const store = api;\n let composed: (action: unknown) => unknown = next;\n for (const middleware of [...core.createMiddleware(options.ports)].reverse()) {\n composed = middleware(store)(composed) as (action: unknown) => unknown;\n }\n chain = composed;\n const flush = () => {\n if (live) store.dispatch({ type: SUMMON_INSTALLED_ACTION });\n for (const action of queue.splice(0)) store.dispatch(action as UnknownAction);\n };\n // Redux forbids dispatching while the middleware chain is being built.\n if (live) flush();\n else if (queue.length > 0) queueMicrotask(flush);\n };\n\n const internals: GateInternals = { install: (core) => settle(core, true) };\n const core = () => slot().core;\n\n const middleware: Middleware = (storeApi) => {\n api = storeApi as MiddlewareAPI<Dispatch<UnknownAction>, unknown>;\n return (nextDispatch) => {\n next = nextDispatch as (action: unknown) => unknown;\n const loaded = core();\n if (loaded) settle(loaded, false);\n else slot().gates.add(internals);\n return (action) => {\n if (chain) return chain(action);\n if (!isSummonAction(action)) return nextDispatch(action);\n queue.push(action);\n void ensureSummonRuntime().catch((error: unknown) => {\n // eslint-disable-next-line no-console\n console.error(\"[summon] the overlay runtime failed to load; queued requests are kept for the next try\", error);\n });\n return action;\n };\n };\n };\n\n return {\n middleware,\n attachReducer(fn) {\n inject = fn;\n const loaded = core();\n if (loaded) {\n inject(loaded.reducers);\n injected = true;\n }\n },\n };\n}\n","// Callback-aware opening without loading the handles registry up front. The opener needs a\n// channel id synchronously (it rides open data); the channel itself is created when the handles\n// section arrives — one import() started by the first such open — or at once by whoever emits\n// first (the render tree has handles statically). Closing the owner before then drops it.\nimport { globalSlot } from \"@ai-matrx/kit/global-slot\";\nimport type { EventChannel } from \"../handles/helpers\";\n\ntype Handlers = Readonly<Record<string, ((payload: unknown) => void) | undefined>> | undefined;\n\ninterface PendingChannel {\n readonly owner: string;\n readonly getHandlers: () => Handlers;\n}\n\n/** The one message shape on an overlay's channel. */\nexport interface OverlayEventMessage {\n readonly type: string;\n readonly payload: unknown;\n}\n\ntype CreateChannel = (options: { owner?: string; id?: string }) => EventChannel<OverlayEventMessage>;\n\nconst pending = (): Map<string, PendingChannel> => globalSlot(\"ai-matrx.summon.pendingChannels\", () => new Map<string, PendingChannel>());\n\n/** Create every pending channel now (idempotent per id). */\nexport function materializePendingChannels(createEventChannel: CreateChannel): void {\n const map = pending();\n for (const [id, entry] of [...map]) {\n map.delete(id);\n const channel = createEventChannel({ owner: entry.owner, id });\n channel.subscribe((message) => entry.getHandlers()?.[message.type]?.(message.payload));\n }\n}\n\n/** Reserve a channel owned by `owner` whose events go to the handlers `getHandlers` returns at emit time. */\nexport function openPendingEventChannel(owner: string, getHandlers: () => Handlers): string {\n const id = `ch-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;\n pending().set(id, { owner, getHandlers });\n void import(\"@ai-matrx/summon/handles\").then(({ createEventChannel }) => materializePendingChannels(createEventChannel));\n return id;\n}\n\n/** The owner closed before its channel was created: forget it. */\nexport function dropPendingChannelsOf(owner: string): void {\n const map = pending();\n for (const [id, entry] of [...map]) if (entry.owner === owner) map.delete(id);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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EAAE,IAAI,IAAI,EAAE,OAAO,YAAY,CAAC;AACxC,OAAK,OAAO,0BAA0B,EAAE,KAAK,CAAC,EAAE,mBAAmB,MAAM,2BAA2B,kBAAkB,CAAC;AACvH,SAAO;AACT;AAGO,SAAS,sBAAsB,OAAqB;AACzD,QAAM,MAAM,QAAQ;AACpB,aAAW,CAAC,IAAI,KAAK,KAAK,CAAC,GAAG,GAAG,EAAG,KAAI,MAAM,UAAU,MAAO,KAAI,OAAO,EAAE;AAC9E;","names":["import_global_slot","import_global_slot","state","import_global_slot","slot","core","middleware","import_global_slot"]}
|
package/dist/open.d.cts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
export { A as AnyOverlayMeta, d as CloseAllInstancesPayload, e as CloseOverlayPayload, C as CloseOverlaysBoundToPagePayload, ac as CreateSummonGateOptions, D as DEFAULT_INSTANCE_ID, f as DEFAULT_PORTS, g as DebugPort, E as ErrorSinkPort, h as IdentityPort, I as InstanceKey, i as InstanceMode, K as KeepAlive, L as LinkHydrateContext, M as MobilePresentation, N as NotifyOptions, j as NotifyPort, k as OpenInstanceView, l as OpenOverlayPayload, m as OverlayDataOf, b as OverlayDefinitionMeta, n as OverlayHostDispatch, o as OverlayId, p as OverlayInstance, q as OverlayLinkSpec, r as OverlayPersistencePort, s as OverlayRawData, O as OverlayState, t as OverlayWindowOptions, P as PruneStaleInstancesPayload, R as RawOpenPayload, u as RouterPort, ad as SUMMON_INSTALLED_ACTION, ae as SUMMON_SLICE_KEYS, a as StateWithOverlays, v as StoredValue, af as SummonAction, c as SummonCore, ag as SummonGate, S as SummonPorts, T as ToggleOverlayPayload, U as UnbiddenHomeRoute, w as Unsubscribe, W as WindowPreservation, x as allOverlayMeta, y as anonymousIdentity, z as closeAllInstancesOfOverlay,
|
|
1
|
+
export { A as AnyOverlayMeta, d as CloseAllInstancesPayload, e as CloseOverlayPayload, C as CloseOverlaysBoundToPagePayload, ac as CreateSummonGateOptions, D as DEFAULT_INSTANCE_ID, f as DEFAULT_PORTS, g as DebugPort, E as ErrorSinkPort, h as IdentityPort, I as InstanceKey, i as InstanceMode, K as KeepAlive, L as LinkHydrateContext, M as MobilePresentation, N as NotifyOptions, j as NotifyPort, k as OpenInstanceView, l as OpenOverlayPayload, m as OverlayDataOf, b as OverlayDefinitionMeta, n as OverlayHostDispatch, o as OverlayId, p as OverlayInstance, q as OverlayLinkSpec, r as OverlayPersistencePort, s as OverlayRawData, O as OverlayState, t as OverlayWindowOptions, P as PruneStaleInstancesPayload, R as RawOpenPayload, u as RouterPort, ad as SUMMON_INSTALLED_ACTION, ae as SUMMON_SLICE_KEYS, a as StateWithOverlays, v as StoredValue, af as SummonAction, c as SummonCore, ag as SummonGate, S as SummonPorts, T as ToggleOverlayPayload, U as UnbiddenHomeRoute, w as Unsubscribe, ah as UrlSyncEntryPayload, W as WindowPreservation, x as allOverlayMeta, y as anonymousIdentity, z as closeAllInstancesOfOverlay, ai as closeAllOverlays, B as closeOverlay, F as closeOverlaysBoundToPage, G as consoleErrorSink, H as consoleNotify, aj as createSummonGate, J as debugOff, Q as defaultWindowIdFor, ak as ensureSummonRuntime, al as focusWindow, V as getOverlayMeta, X as getOverlayMetaByLinkKey, am as installSummonCore, Y as instanceKey, Z as isRegisteredOverlay, an as isSummonAction, ao as isSummonInstalled, _ as listOpenInstanceKeys, $ as locationRouter, ap as minimizeAll, a0 as openOverlay, a1 as overlayIdsBoundToPage, a2 as parseInstanceKey, aq as prefetchSummonRuntime, ar as pruneStaleInstances, a3 as registerOverlayMeta, as as registerSyncEntry, a4 as resetOverlayRegistry, a5 as resolvePorts, at as restoreAll, au as restoreWindow, av as selectAllWindows, aw as selectAnyOverlayTouched, a6 as selectIsOverlayOpen, a7 as selectOpenInstances, a8 as selectOverlay, a9 as selectOverlayData, ax as selectWindowsHidden, ay as subscribeSummonInstalled, aa as subscribeToOverlayRegistry, ab as toggleOverlay, az as toggleWindowsHidden, aA as unregisterSyncEntry } from './gate-2V3LrLFh.cjs';
|
|
2
2
|
import { E as EventChannel } from './helpers-2NY1ha0V.cjs';
|
|
3
3
|
export { OverlayHostTypes, OverlayRegistry } from '@ai-matrx/summon';
|
|
4
4
|
import '@reduxjs/toolkit';
|
|
5
5
|
|
|
6
|
+
declare function ackOverlaySurfaceRender(overlayId: string): void;
|
|
7
|
+
declare function clearOverlaySurfaceRender(overlayId: string): void;
|
|
8
|
+
|
|
6
9
|
type Handlers = Readonly<Record<string, ((payload: unknown) => void) | undefined>> | undefined;
|
|
7
10
|
/** The one message shape on an overlay's channel. */
|
|
8
11
|
interface OverlayEventMessage {
|
|
@@ -20,4 +23,4 @@ declare function openPendingEventChannel(owner: string, getHandlers: () => Handl
|
|
|
20
23
|
/** The owner closed before its channel was created: forget it. */
|
|
21
24
|
declare function dropPendingChannelsOf(owner: string): void;
|
|
22
25
|
|
|
23
|
-
export { type OverlayEventMessage, dropPendingChannelsOf, materializePendingChannels, openPendingEventChannel };
|
|
26
|
+
export { type OverlayEventMessage, ackOverlaySurfaceRender, clearOverlaySurfaceRender, dropPendingChannelsOf, materializePendingChannels, openPendingEventChannel };
|
package/dist/open.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
export { A as AnyOverlayMeta, d as CloseAllInstancesPayload, e as CloseOverlayPayload, C as CloseOverlaysBoundToPagePayload, ac as CreateSummonGateOptions, D as DEFAULT_INSTANCE_ID, f as DEFAULT_PORTS, g as DebugPort, E as ErrorSinkPort, h as IdentityPort, I as InstanceKey, i as InstanceMode, K as KeepAlive, L as LinkHydrateContext, M as MobilePresentation, N as NotifyOptions, j as NotifyPort, k as OpenInstanceView, l as OpenOverlayPayload, m as OverlayDataOf, b as OverlayDefinitionMeta, n as OverlayHostDispatch, o as OverlayId, p as OverlayInstance, q as OverlayLinkSpec, r as OverlayPersistencePort, s as OverlayRawData, O as OverlayState, t as OverlayWindowOptions, P as PruneStaleInstancesPayload, R as RawOpenPayload, u as RouterPort, ad as SUMMON_INSTALLED_ACTION, ae as SUMMON_SLICE_KEYS, a as StateWithOverlays, v as StoredValue, af as SummonAction, c as SummonCore, ag as SummonGate, S as SummonPorts, T as ToggleOverlayPayload, U as UnbiddenHomeRoute, w as Unsubscribe, W as WindowPreservation, x as allOverlayMeta, y as anonymousIdentity, z as closeAllInstancesOfOverlay,
|
|
1
|
+
export { A as AnyOverlayMeta, d as CloseAllInstancesPayload, e as CloseOverlayPayload, C as CloseOverlaysBoundToPagePayload, ac as CreateSummonGateOptions, D as DEFAULT_INSTANCE_ID, f as DEFAULT_PORTS, g as DebugPort, E as ErrorSinkPort, h as IdentityPort, I as InstanceKey, i as InstanceMode, K as KeepAlive, L as LinkHydrateContext, M as MobilePresentation, N as NotifyOptions, j as NotifyPort, k as OpenInstanceView, l as OpenOverlayPayload, m as OverlayDataOf, b as OverlayDefinitionMeta, n as OverlayHostDispatch, o as OverlayId, p as OverlayInstance, q as OverlayLinkSpec, r as OverlayPersistencePort, s as OverlayRawData, O as OverlayState, t as OverlayWindowOptions, P as PruneStaleInstancesPayload, R as RawOpenPayload, u as RouterPort, ad as SUMMON_INSTALLED_ACTION, ae as SUMMON_SLICE_KEYS, a as StateWithOverlays, v as StoredValue, af as SummonAction, c as SummonCore, ag as SummonGate, S as SummonPorts, T as ToggleOverlayPayload, U as UnbiddenHomeRoute, w as Unsubscribe, ah as UrlSyncEntryPayload, W as WindowPreservation, x as allOverlayMeta, y as anonymousIdentity, z as closeAllInstancesOfOverlay, ai as closeAllOverlays, B as closeOverlay, F as closeOverlaysBoundToPage, G as consoleErrorSink, H as consoleNotify, aj as createSummonGate, J as debugOff, Q as defaultWindowIdFor, ak as ensureSummonRuntime, al as focusWindow, V as getOverlayMeta, X as getOverlayMetaByLinkKey, am as installSummonCore, Y as instanceKey, Z as isRegisteredOverlay, an as isSummonAction, ao as isSummonInstalled, _ as listOpenInstanceKeys, $ as locationRouter, ap as minimizeAll, a0 as openOverlay, a1 as overlayIdsBoundToPage, a2 as parseInstanceKey, aq as prefetchSummonRuntime, ar as pruneStaleInstances, a3 as registerOverlayMeta, as as registerSyncEntry, a4 as resetOverlayRegistry, a5 as resolvePorts, at as restoreAll, au as restoreWindow, av as selectAllWindows, aw as selectAnyOverlayTouched, a6 as selectIsOverlayOpen, a7 as selectOpenInstances, a8 as selectOverlay, a9 as selectOverlayData, ax as selectWindowsHidden, ay as subscribeSummonInstalled, aa as subscribeToOverlayRegistry, ab as toggleOverlay, az as toggleWindowsHidden, aA as unregisterSyncEntry } from './gate-2V3LrLFh.js';
|
|
2
2
|
import { E as EventChannel } from './helpers-2NY1ha0V.js';
|
|
3
3
|
export { OverlayHostTypes, OverlayRegistry } from '@ai-matrx/summon';
|
|
4
4
|
import '@reduxjs/toolkit';
|
|
5
5
|
|
|
6
|
+
declare function ackOverlaySurfaceRender(overlayId: string): void;
|
|
7
|
+
declare function clearOverlaySurfaceRender(overlayId: string): void;
|
|
8
|
+
|
|
6
9
|
type Handlers = Readonly<Record<string, ((payload: unknown) => void) | undefined>> | undefined;
|
|
7
10
|
/** The one message shape on an overlay's channel. */
|
|
8
11
|
interface OverlayEventMessage {
|
|
@@ -20,4 +23,4 @@ declare function openPendingEventChannel(owner: string, getHandlers: () => Handl
|
|
|
20
23
|
/** The owner closed before its channel was created: forget it. */
|
|
21
24
|
declare function dropPendingChannelsOf(owner: string): void;
|
|
22
25
|
|
|
23
|
-
export { type OverlayEventMessage, dropPendingChannelsOf, materializePendingChannels, openPendingEventChannel };
|
|
26
|
+
export { type OverlayEventMessage, ackOverlaySurfaceRender, clearOverlaySurfaceRender, dropPendingChannelsOf, materializePendingChannels, openPendingEventChannel };
|
package/dist/open.js
CHANGED
|
@@ -160,6 +160,8 @@ var restoreWindow = creator(W + "restoreWindow", pass());
|
|
|
160
160
|
var toggleWindowsHidden = creator(W + "toggleWindowsHidden", () => void 0);
|
|
161
161
|
var restoreAll = creator(W + "restoreAll", () => void 0);
|
|
162
162
|
var minimizeAll = creator(W + "minimizeAll", pass());
|
|
163
|
+
var registerSyncEntry = creator("urlSync/registerSyncEntry", pass());
|
|
164
|
+
var unregisterSyncEntry = creator("urlSync/unregisterSyncEntry", pass());
|
|
163
165
|
var SUMMON_SLICE_KEYS = ["overlays", "windowManager", "urlSync", "overlayState"];
|
|
164
166
|
function isSummonAction(action) {
|
|
165
167
|
if (typeof action !== "object" || action === null) return false;
|
|
@@ -169,14 +171,31 @@ function isSummonAction(action) {
|
|
|
169
171
|
return slash > 0 && SUMMON_SLICE_KEYS.includes(type.slice(0, slash));
|
|
170
172
|
}
|
|
171
173
|
|
|
172
|
-
// src/open/
|
|
174
|
+
// src/open/renderAcks.ts
|
|
173
175
|
import { globalSlot as globalSlot2 } from "@ai-matrx/kit/global-slot";
|
|
176
|
+
var slot = () => globalSlot2("ai-matrx.summon.renderWatchdog", () => ({ renderAcks: /* @__PURE__ */ new Map(), ackWaiters: /* @__PURE__ */ new Map(), watches: /* @__PURE__ */ new Map() }));
|
|
177
|
+
function ackOverlaySurfaceRender(overlayId) {
|
|
178
|
+
const s = slot();
|
|
179
|
+
s.renderAcks.set(overlayId, { kind: "surface" });
|
|
180
|
+
const notify = s.ackWaiters.get(overlayId);
|
|
181
|
+
if (notify) {
|
|
182
|
+
s.ackWaiters.delete(overlayId);
|
|
183
|
+
notify();
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
function clearOverlaySurfaceRender(overlayId) {
|
|
187
|
+
const s = slot();
|
|
188
|
+
if (s.renderAcks.get(overlayId)?.kind === "surface") s.renderAcks.delete(overlayId);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// src/open/selectors.ts
|
|
192
|
+
import { globalSlot as globalSlot3 } from "@ai-matrx/kit/global-slot";
|
|
174
193
|
var CLOSED = Object.freeze({ isOpen: false, data: null });
|
|
175
194
|
var EMPTY = Object.freeze([]);
|
|
176
195
|
var selectOverlay = (state2, overlayId, instanceId = DEFAULT_INSTANCE_ID) => state2.overlays?.overlays[overlayId]?.[instanceId] ?? CLOSED;
|
|
177
196
|
var selectIsOverlayOpen = (state2, overlayId, instanceId = DEFAULT_INSTANCE_ID) => selectOverlay(state2, overlayId, instanceId).isOpen;
|
|
178
197
|
var selectOverlayData = (state2, overlayId, instanceId = DEFAULT_INSTANCE_ID) => selectOverlay(state2, overlayId, instanceId).data;
|
|
179
|
-
var openCache = () =>
|
|
198
|
+
var openCache = () => globalSlot3("ai-matrx.summon.openInstances", () => /* @__PURE__ */ new Map());
|
|
180
199
|
var selectOpenInstances = (state2, overlayId) => {
|
|
181
200
|
const bucket = state2.overlays?.overlays[overlayId];
|
|
182
201
|
const cache = openCache();
|
|
@@ -203,13 +222,25 @@ function selectAnyOverlayTouched(state2) {
|
|
|
203
222
|
return false;
|
|
204
223
|
}
|
|
205
224
|
var selectWindowsHidden = (state2) => state2.windowManager?.windowsHidden ?? false;
|
|
225
|
+
var EMPTY_WINDOWS = Object.freeze([]);
|
|
226
|
+
var lastWindowsMap = null;
|
|
227
|
+
var lastWindows = EMPTY_WINDOWS;
|
|
228
|
+
function selectAllWindows(state2) {
|
|
229
|
+
const map = state2.windowManager?.windows;
|
|
230
|
+
if (!map) return EMPTY_WINDOWS;
|
|
231
|
+
if (map !== lastWindowsMap) {
|
|
232
|
+
lastWindowsMap = map;
|
|
233
|
+
lastWindows = Object.values(map).sort((a, b) => b.zIndex - a.zIndex);
|
|
234
|
+
}
|
|
235
|
+
return lastWindows;
|
|
236
|
+
}
|
|
206
237
|
|
|
207
238
|
// src/open/gate.ts
|
|
208
|
-
import { globalSlot as
|
|
239
|
+
import { globalSlot as globalSlot4 } from "@ai-matrx/kit/global-slot";
|
|
209
240
|
var SUMMON_INSTALLED_ACTION = "@@summon/installed";
|
|
210
|
-
var
|
|
241
|
+
var slot2 = () => globalSlot4("ai-matrx.summon.gate", () => ({ core: null, loading: null, gates: /* @__PURE__ */ new Set(), listeners: /* @__PURE__ */ new Set() }));
|
|
211
242
|
function installSummonCore(core) {
|
|
212
|
-
const s =
|
|
243
|
+
const s = slot2();
|
|
213
244
|
if (s.core) return;
|
|
214
245
|
s.core = core;
|
|
215
246
|
const gates = [...s.gates];
|
|
@@ -218,15 +249,15 @@ function installSummonCore(core) {
|
|
|
218
249
|
for (const listener of [...s.listeners]) listener();
|
|
219
250
|
}
|
|
220
251
|
function isSummonInstalled() {
|
|
221
|
-
return
|
|
252
|
+
return slot2().core !== null;
|
|
222
253
|
}
|
|
223
254
|
function subscribeSummonInstalled(listener) {
|
|
224
|
-
const s =
|
|
255
|
+
const s = slot2();
|
|
225
256
|
s.listeners.add(listener);
|
|
226
257
|
return () => s.listeners.delete(listener);
|
|
227
258
|
}
|
|
228
259
|
function ensureSummonRuntime() {
|
|
229
|
-
const s =
|
|
260
|
+
const s = slot2();
|
|
230
261
|
if (s.core) return Promise.resolve();
|
|
231
262
|
s.loading ??= import("@ai-matrx/summon").then(
|
|
232
263
|
(core) => installSummonCore(core.summonCore),
|
|
@@ -267,14 +298,14 @@ function createSummonGate(options = {}) {
|
|
|
267
298
|
else if (queue.length > 0) queueMicrotask(flush);
|
|
268
299
|
};
|
|
269
300
|
const internals = { install: (core2) => settle(core2, true) };
|
|
270
|
-
const core = () =>
|
|
301
|
+
const core = () => slot2().core;
|
|
271
302
|
const middleware = (storeApi) => {
|
|
272
303
|
api = storeApi;
|
|
273
304
|
return (nextDispatch) => {
|
|
274
305
|
next = nextDispatch;
|
|
275
306
|
const loaded = core();
|
|
276
307
|
if (loaded) settle(loaded, false);
|
|
277
|
-
else
|
|
308
|
+
else slot2().gates.add(internals);
|
|
278
309
|
return (action) => {
|
|
279
310
|
if (chain) return chain(action);
|
|
280
311
|
if (!isSummonAction(action)) return nextDispatch(action);
|
|
@@ -300,8 +331,8 @@ function createSummonGate(options = {}) {
|
|
|
300
331
|
}
|
|
301
332
|
|
|
302
333
|
// src/open/channels.ts
|
|
303
|
-
import { globalSlot as
|
|
304
|
-
var pending = () =>
|
|
334
|
+
import { globalSlot as globalSlot5 } from "@ai-matrx/kit/global-slot";
|
|
335
|
+
var pending = () => globalSlot5("ai-matrx.summon.pendingChannels", () => /* @__PURE__ */ new Map());
|
|
305
336
|
function materializePendingChannels(createEventChannel) {
|
|
306
337
|
const map = pending();
|
|
307
338
|
for (const [id, entry] of [...map]) {
|
|
@@ -325,8 +356,10 @@ export {
|
|
|
325
356
|
DEFAULT_PORTS,
|
|
326
357
|
SUMMON_INSTALLED_ACTION,
|
|
327
358
|
SUMMON_SLICE_KEYS,
|
|
359
|
+
ackOverlaySurfaceRender,
|
|
328
360
|
allOverlayMeta,
|
|
329
361
|
anonymousIdentity,
|
|
362
|
+
clearOverlaySurfaceRender,
|
|
330
363
|
closeAllInstancesOfOverlay,
|
|
331
364
|
closeAllOverlays,
|
|
332
365
|
closeOverlay,
|
|
@@ -357,10 +390,12 @@ export {
|
|
|
357
390
|
prefetchSummonRuntime,
|
|
358
391
|
pruneStaleInstances,
|
|
359
392
|
registerOverlayMeta,
|
|
393
|
+
registerSyncEntry,
|
|
360
394
|
resetOverlayRegistry,
|
|
361
395
|
resolvePorts,
|
|
362
396
|
restoreAll,
|
|
363
397
|
restoreWindow,
|
|
398
|
+
selectAllWindows,
|
|
364
399
|
selectAnyOverlayTouched,
|
|
365
400
|
selectIsOverlayOpen,
|
|
366
401
|
selectOpenInstances,
|
|
@@ -370,6 +405,7 @@ export {
|
|
|
370
405
|
subscribeSummonInstalled,
|
|
371
406
|
subscribeToOverlayRegistry,
|
|
372
407
|
toggleOverlay,
|
|
373
|
-
toggleWindowsHidden
|
|
408
|
+
toggleWindowsHidden,
|
|
409
|
+
unregisterSyncEntry
|
|
374
410
|
};
|
|
375
411
|
//# sourceMappingURL=open.js.map
|