@ai-matrx/summon 0.1.6 → 0.1.8
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 -2
- package/dist/gate-DUvE-Cc1.d.cts +399 -0
- package/dist/gate-DUvE-Cc1.d.ts +399 -0
- package/dist/handles.cjs +1 -0
- package/dist/handles.cjs.map +1 -1
- package/dist/handles.d.cts +3 -61
- package/dist/handles.d.ts +3 -61
- package/dist/handles.js +1 -0
- package/dist/handles.js.map +1 -1
- package/dist/helpers-2NY1ha0V.d.cts +63 -0
- package/dist/helpers-2NY1ha0V.d.ts +63 -0
- package/dist/index.cjs +194 -159
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -355
- package/dist/index.d.ts +9 -355
- package/dist/index.js +200 -165
- package/dist/index.js.map +1 -1
- package/dist/instanceBody-CgZAFnic.d.cts +23 -0
- package/dist/instanceBody-CgZAFnic.d.ts +23 -0
- package/dist/open.cjs +408 -0
- package/dist/open.cjs.map +1 -0
- package/dist/open.d.cts +22 -0
- package/dist/open.d.ts +22 -0
- package/dist/open.js +375 -0
- package/dist/open.js.map +1 -0
- package/dist/persistence.cjs +27 -2
- package/dist/persistence.cjs.map +1 -1
- package/dist/persistence.js +28 -3
- package/dist/persistence.js.map +1 -1
- package/dist/react.cjs +249 -352
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +11 -151
- package/dist/react.d.ts +11 -151
- package/dist/react.js +210 -306
- package/dist/react.js.map +1 -1
- package/dist/root.cjs +277 -0
- package/dist/root.cjs.map +1 -0
- package/dist/root.d.cts +175 -0
- package/dist/root.d.ts +175 -0
- package/dist/root.js +254 -0
- package/dist/root.js.map +1 -0
- package/dist/window-host.cjs +11 -2
- package/dist/window-host.cjs.map +1 -1
- package/dist/window-host.d.cts +1 -0
- package/dist/window-host.d.ts +1 -0
- package/dist/window-host.js +11 -2
- package/dist/window-host.js.map +1 -1
- package/dist/window.cjs +2 -1
- package/dist/window.cjs.map +1 -1
- package/dist/window.d.cts +3 -2
- package/dist/window.d.ts +3 -2
- package/dist/window.js +2 -1
- package/dist/window.js.map +1 -1
- package/package.json +26 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,13 +1,32 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.8
|
|
4
|
+
### Unreleased
|
|
5
|
+
|
|
6
|
+
- **New: `./open` and `./root` — a page pays next to nothing until something opens.** `./open` (framework-free) holds the action creators (plain objects carrying the slices' own type strings: `openOverlay`, `closeOverlay`, `toggleOverlay`, `closeAllInstancesOfOverlay`, `closeOverlaysBoundToPage`, `closeAllOverlays`, `pruneStaleInstances`, `focusWindow`, `restoreWindow`, `toggleWindowsHidden`, `restoreAll`, `minimizeAll`), selectors that read "closed" while the slices are absent, the registry, ports, and `createSummonGate()`. `./root` holds `<SummonRoot store runtime …settings>`, the store hooks, `defineOverlay` and the instance context. The gate is one middleware in a host store: the store carries no summon slice or middleware; the first summon action queues and starts ONE `import()` of the core, which installs itself on evaluation (injects the slices through the host's `attachReducer` inject, adds the close lifecycle + render watchdog, replays the queue). Any module that imports the core statically (the window section, links, persistence) installs it before it renders. `<SummonRoot>` records the host settings (ports, renderWrapper, errorReportExtras, windows) once; `useSummonPorts`, `useSummonConfig` and `useWindowConfig` fall back to them when no provider is above, so a page's own WindowPanel and the lazily loaded host need no provider. Callback-aware opens reserve their event channel id and the handles registry arrives with that first open (`openPendingEventChannel`). Measured in AI Matrx: summon first load per route 73 KB min / 23 KB gz before. Guards: `src/importCost.test.ts` (`./open`/`./root` reach no slice, middleware, react section, window or handles), `src/open/gate.test.ts`, `src/open/actions.parity.test.ts`, `src/root/summonRoot.test.tsx`. Consumer action: none for hosts that mount `summonReducers` or use `<SummonProvider>`; to drop summon from first load, mount `createSummonGate()` + `<SummonRoot>` instead and import openers/selectors from `./open`, `defineOverlay` from `./root`.
|
|
7
|
+
- **Changed: definitions carry no render code.** `defineOverlay` no longer builds `Body`; `HostableOverlay` is `{ id, label, instance, keepAlive, meta, render?, parse? }` and `<SummonHost>` builds each instance body on first render. Consumer action: none unless you read `definition.Body` (render through `<SummonHost>`).
|
|
8
|
+
- **Changed: `selectIsOverlayOpen` & co. accept a state without the `overlays` key** (`StateWithOverlays.overlays` is optional). Consumer action: none.
|
|
9
|
+
- **Un-deprecated: `initialRect` on WindowPanel is the explicit placement option.** It opens the window at exactly that rect and is never auto-placed (an auto-opened window with an explicit x/y keeps it). For hosts that place windows themselves (Workflow Studio's canvas, where auto-placement finds no free gutter). Consumer action: none.
|
|
10
|
+
- `createEventChannel` accepts an `id`.
|
|
11
|
+
|
|
12
|
+
## 0.1.7
|
|
13
|
+
|
|
14
|
+
SOURCE CHANGED WITH NO RELEASE NOTE. This release shipped source changes that nobody described in an Unreleased entry,
|
|
15
|
+
so they may include breaking API changes. Consumer action is UNKNOWN: read the diff before upgrading.
|
|
16
|
+
Diff: `git diff cf8dd92752 9a2e801ddf -- apps/shared/summon/src`
|
|
17
|
+
|
|
18
|
+
Changed shipped source files (1):
|
|
19
|
+
- `apps/shared/summon/src/persistence/OverlayPersistence.tsx`
|
|
20
|
+
|
|
3
21
|
## 0.1.6
|
|
4
22
|
|
|
5
|
-
|
|
6
|
-
|
|
23
|
+
Automatic changed-only republish (docs/metadata drift since the last published version; verified: `git diff 4c976ac0a1 cf8dd92752 -- apps/shared/summon/src`
|
|
24
|
+
has no shipped-source changes outside tests, fixtures and docs). No consumer action required.
|
|
7
25
|
|
|
8
26
|
## 0.1.5
|
|
9
27
|
### Unreleased
|
|
10
28
|
|
|
29
|
+
- **Fixed: persistence's boot read ran twice on every page load in a host that publishes a port after mount.** `useOverlayPersistence` restarted on any change to the ports object, so AI Matrx (which hands in the Next router port right after mount) read the workspace and listed saved state twice per signed-in load (measured on a production build: 4 `users.user_surface_state` requests on /notes). It now restarts only when the store, the persistence port or the identity port changes, and reads the other ports live. Guard: `src/persistence/__tests__/portsSwapNoReload.test.tsx` (red on the previous code: 4 reads vs 2). Consumer action: none.
|
|
11
30
|
- **Light imports for the boot graph.** `usePopout`, `PopoutContext`, `usePopoutContainer` and `useOverlaySurfaceRenderAck` are now on `./window-host` (the popout context lives there, one identity; `./window` re-exports them), and `useOverlayLink` is on `./react` (`./url` re-exports it). Why: a section ships as one module, so an app that imported one of these hooks from `./window` or `./url` at boot carried the whole window section (WindowPanel, popout, mobile, tray: ~100 KB minified) or the link manager in every route's first load (AI Matrx: `/pricing`, `/notes`, `/dashboard`). Consumer action: none required; import these hooks from `./window-host` / `./react` to drop the heavy sections from a static graph.
|
|
12
31
|
- **New: `./dock`, the one primitive for floating chrome-less cards, pills and docks** (design R5 wave 2). `<Dock>` / `<DockHandle>` / `useDock()` / `useDockContext()` / `<DockProvider>`: pointer drag that never re-renders while moving (CSS `translate` in one animation frame, one commit on release), corner-relative positions clamped to the viewport with an optional nearest-corner snap and fixed-control avoidance, the position remembered per dock id (own store, `DockProvider`, else localStorage) or reported to a controlled host, the window manager's z-order lane on press, the design-system drag cursor hold, a click-vs-drag threshold that swallows the trailing click. Replaces the copies in AI Matrx (`useDraggableFloat`, the assists `useDockDrag`) and in `@ai-matrx/chat` (`useDraggablePanel`, the agent widget drags). Guard: `src/dock/__tests__/dock.test.tsx`. Consumer action: none.
|
|
13
32
|
- **Idle cost: the root-mounted pieces do nothing until used.** `WindowTraySync` no longer dispatches two actions on mount and on every resize of a page with no windows: it attaches its resize listener only while a window is registered or waiting to restore (one boolean selector), and `recomputeTrayPositions` writes nothing when the tray is empty (a resize with no tray hands subscribers the same state). Persistence boot is one read: a port may implement `loadAll()` (key → stored value), and when it does the controller restores the workspace and every saved component state from that single call instead of `load` + `list` + one `load` per state key; the `./persistence/data` adapter implements it (one `users.user_surface_state` select). Guards: `src/window/__tests__/windowTraySyncIdle.test.tsx`, `controller.test.ts` (boot = exactly `["loadAll"]`), `src/importCost.test.ts` (the root-mounted entries `.`, `./react`, `./window-host`, `./next` never reach WindowPanel, links, persistence, dialog/sheet/lite or testing). Consumer action: none.
|
|
@@ -0,0 +1,399 @@
|
|
|
1
|
+
import { Reducer, Middleware } from '@reduxjs/toolkit';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The shared vocabulary of @ai-matrx/summon. Framework-free: no React, no Redux imports.
|
|
5
|
+
*
|
|
6
|
+
* An OVERLAY is any component rendered on top of the app by dispatch — a window, dialog, sheet,
|
|
7
|
+
* light floating window, toast-like card, anything. It is identified by an `OverlayId` and opened
|
|
8
|
+
* as one or more INSTANCES (`instanceId`, "default" for single-instance overlays).
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* The host's overlay registry: overlay id → the data its opener accepts. Hosts extend it by
|
|
12
|
+
* module augmentation so every open call is type-checked:
|
|
13
|
+
*
|
|
14
|
+
* declare module "@ai-matrx/summon" {
|
|
15
|
+
* interface OverlayRegistry { notesWindow: { noteId?: string } }
|
|
16
|
+
* }
|
|
17
|
+
*
|
|
18
|
+
* `defineOverlay` emits nothing at runtime for this; the augmentation is the host's one-line
|
|
19
|
+
* declaration per overlay (the converter writes it next to each definition).
|
|
20
|
+
*/
|
|
21
|
+
interface OverlayRegistry {
|
|
22
|
+
}
|
|
23
|
+
/** Every registered overlay id; plain `string` until the host augments the registry. */
|
|
24
|
+
type OverlayId = [keyof OverlayRegistry] extends [never] ? string : Extract<keyof OverlayRegistry, string>;
|
|
25
|
+
/** The open-data type declared for an overlay id. */
|
|
26
|
+
type OverlayDataOf<Id extends string> = Id extends keyof OverlayRegistry ? OverlayRegistry[Id] : Record<string, unknown>;
|
|
27
|
+
/**
|
|
28
|
+
* Data as it arrives at render time. It crossed Redux, a URL or storage, so it is NOT trusted to
|
|
29
|
+
* match the opener's type: render code narrows it (or the definition supplies `parse`).
|
|
30
|
+
*/
|
|
31
|
+
type OverlayRawData = Readonly<Record<string, unknown>> | null;
|
|
32
|
+
declare const DEFAULT_INSTANCE_ID = "default";
|
|
33
|
+
/** `single`: one instance ("default"). `multi`: any number, each with its own instanceId. */
|
|
34
|
+
type InstanceMode = "single" | "multi";
|
|
35
|
+
/**
|
|
36
|
+
* What closing does to a mounted overlay (Arman, 2026-10-16, C38 R3):
|
|
37
|
+
* none — unmount (default).
|
|
38
|
+
* hidden — stay mounted but hidden; reopening shows the same live component (LRU-capped).
|
|
39
|
+
* restore — unmount, but values saved with `useOverlayState` come back on reopen.
|
|
40
|
+
* Minimizing a window always keeps its component mounted, whatever this says.
|
|
41
|
+
*/
|
|
42
|
+
type KeepAlive = "none" | "hidden" | "restore";
|
|
43
|
+
/** `overlayId:instanceId` — the one key every subsystem uses for an open instance. */
|
|
44
|
+
type InstanceKey = `${string}:${string}`;
|
|
45
|
+
declare function instanceKey(overlayId: string, instanceId?: string): InstanceKey;
|
|
46
|
+
declare function parseInstanceKey(key: string): {
|
|
47
|
+
overlayId: string;
|
|
48
|
+
instanceId: string;
|
|
49
|
+
} | null;
|
|
50
|
+
type MobilePresentation = "fullscreen" | "drawer" | "card" | "hidden";
|
|
51
|
+
/**
|
|
52
|
+
* Default-deny allowlist of the open data a window may save and restore. A window with no
|
|
53
|
+
* preservation entry restores geometry only.
|
|
54
|
+
*/
|
|
55
|
+
interface WindowPreservation {
|
|
56
|
+
readonly dataKeys: readonly string[];
|
|
57
|
+
readonly requiredDataKeys?: readonly string[];
|
|
58
|
+
readonly allowedDataValues?: Readonly<Record<string, readonly (string | number | boolean | null)[]>>;
|
|
59
|
+
/** Default 32 KiB. */
|
|
60
|
+
readonly maxDataBytes?: number;
|
|
61
|
+
}
|
|
62
|
+
/** One declared home for an unbidden (system-raised) window: a route prefix, or one exact page. */
|
|
63
|
+
type UnbiddenHomeRoute = string | {
|
|
64
|
+
readonly route: string;
|
|
65
|
+
readonly exact: true;
|
|
66
|
+
};
|
|
67
|
+
interface OverlayWindowOptions {
|
|
68
|
+
readonly mobile?: MobilePresentation;
|
|
69
|
+
readonly mobileSidebarAs?: "drawer" | "inline";
|
|
70
|
+
/** Never saved or restored (debug panels, one-shot tools, callback-bound editors). */
|
|
71
|
+
readonly ephemeral?: boolean;
|
|
72
|
+
readonly preservation?: WindowPreservation;
|
|
73
|
+
/**
|
|
74
|
+
* Values merged under saved data when a window is RESTORED (reload, another device). Unlike the
|
|
75
|
+
* definition's `defaults`, never applied to a normal open.
|
|
76
|
+
*/
|
|
77
|
+
readonly restoreDefaults?: Readonly<Record<string, unknown>>;
|
|
78
|
+
/**
|
|
79
|
+
* The window-manager id the WindowPanel registers under for the default instance. Default: the
|
|
80
|
+
* overlay id. The render watchdog reveals and inspects this id until the panel acks its own.
|
|
81
|
+
*/
|
|
82
|
+
readonly windowId?: string;
|
|
83
|
+
readonly deprecated?: {
|
|
84
|
+
readonly replacement?: string;
|
|
85
|
+
readonly reason?: string;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Where a window nobody opened (system-raised) may raise itself. Default deny: no home → it may
|
|
89
|
+
* not raise itself anywhere (`mayRaiseUnbidden` in the window section).
|
|
90
|
+
*/
|
|
91
|
+
readonly unbiddenHome?: readonly UnbiddenHomeRoute[];
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Host-specific types the package passes through untouched. A Redux host augments `dispatch`
|
|
95
|
+
* with its thunk-aware dispatch so link hydrators can dispatch its thunks without casts:
|
|
96
|
+
*
|
|
97
|
+
* declare module "@ai-matrx/summon" { interface OverlayHostTypes { dispatch: AppDispatch } }
|
|
98
|
+
*/
|
|
99
|
+
interface OverlayHostTypes {
|
|
100
|
+
}
|
|
101
|
+
type OverlayHostDispatch = OverlayHostTypes extends {
|
|
102
|
+
dispatch: infer D;
|
|
103
|
+
} ? D : (action: unknown) => unknown;
|
|
104
|
+
interface LinkHydrateContext<Data> {
|
|
105
|
+
/** The id segment of the link token (`notes:<id>`). */
|
|
106
|
+
readonly id: string;
|
|
107
|
+
/** Decoded `k-v` arguments of the token. */
|
|
108
|
+
readonly args: Readonly<Record<string, string>>;
|
|
109
|
+
/** Open this overlay. */
|
|
110
|
+
open(options?: {
|
|
111
|
+
readonly instanceId?: string;
|
|
112
|
+
readonly data?: Data;
|
|
113
|
+
}): void;
|
|
114
|
+
/** The host store's dispatch, for thunks a hydrator needs (loading a record first). Typed by
|
|
115
|
+
* augmenting `OverlayHostTypes` with the host's dispatch type. */
|
|
116
|
+
readonly dispatch: OverlayHostDispatch;
|
|
117
|
+
}
|
|
118
|
+
interface OverlayLinkSpec<Data> {
|
|
119
|
+
/** The token type key in `?panels=key:id`. Unique across the host. */
|
|
120
|
+
readonly key: string;
|
|
121
|
+
/** Older keys that still resolve to this overlay. */
|
|
122
|
+
readonly aliases?: readonly string[];
|
|
123
|
+
/** Turn a link token into an open overlay (and its data). `"refused"` keeps the token and says why. */
|
|
124
|
+
hydrate(context: LinkHydrateContext<Data>): void | "refused" | Promise<void | "refused">;
|
|
125
|
+
}
|
|
126
|
+
interface OverlayDefinitionMeta<Id extends string = string, Data = Record<string, unknown>> {
|
|
127
|
+
readonly id: Id;
|
|
128
|
+
/** Human label: tray, menus, diagnostics. */
|
|
129
|
+
readonly label: string;
|
|
130
|
+
readonly instance?: InstanceMode;
|
|
131
|
+
readonly keepAlive?: KeepAlive;
|
|
132
|
+
/** Close when the route changes — the overlay shows a piece of the page that opened it. */
|
|
133
|
+
readonly closesOnNavigation?: boolean;
|
|
134
|
+
/** Present only for overlays that render a WindowPanel. */
|
|
135
|
+
readonly window?: OverlayWindowOptions;
|
|
136
|
+
readonly link?: OverlayLinkSpec<Data>;
|
|
137
|
+
/** Defaults merged under open data (replaces the old per-overlay schema registry). */
|
|
138
|
+
readonly defaults?: Partial<Data>;
|
|
139
|
+
}
|
|
140
|
+
/** The window-manager id a singleton window overlay registers under (`window.windowId ?? id`). */
|
|
141
|
+
declare function defaultWindowIdFor(meta: Pick<OverlayDefinitionMeta, "id" | "window">): string;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Everything the overlays system needs from its host, as ports. Every port ships a working
|
|
145
|
+
* default, so a bare host gets a working system with zero wiring (package standard rule 8); a
|
|
146
|
+
* host overrides only what it has: identity, navigation, notifications, error sink, debug flag,
|
|
147
|
+
* persistence. Framework-free.
|
|
148
|
+
*/
|
|
149
|
+
type Unsubscribe = () => void;
|
|
150
|
+
/** Who the person is, for isolating saved state. `key` changes → everything saved is swapped. */
|
|
151
|
+
interface IdentityPort {
|
|
152
|
+
current(): {
|
|
153
|
+
readonly key: string;
|
|
154
|
+
readonly ready: boolean;
|
|
155
|
+
};
|
|
156
|
+
subscribe(listener: () => void): Unsubscribe;
|
|
157
|
+
}
|
|
158
|
+
/** The address bar: route changes (close-on-navigation) and the `?panels=` link channel. */
|
|
159
|
+
interface RouterPort {
|
|
160
|
+
pathname(): string;
|
|
161
|
+
search(): string;
|
|
162
|
+
/** Replace the query string without navigating or remounting the page. */
|
|
163
|
+
replaceSearch(nextSearch: string): void;
|
|
164
|
+
subscribe(listener: () => void): Unsubscribe;
|
|
165
|
+
}
|
|
166
|
+
interface NotifyOptions {
|
|
167
|
+
readonly id?: string;
|
|
168
|
+
readonly description?: string;
|
|
169
|
+
/** How long the notice stays up (ms). Hosts without timed notices ignore it. */
|
|
170
|
+
readonly duration?: number;
|
|
171
|
+
/** One action button (e.g. the render watchdog's "Show it"). Hosts without actions ignore it. */
|
|
172
|
+
readonly action?: {
|
|
173
|
+
readonly label: string;
|
|
174
|
+
readonly onClick: () => void;
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
interface NotifyPort {
|
|
178
|
+
info(message: string, options?: NotifyOptions): void;
|
|
179
|
+
warn(message: string, options?: NotifyOptions): void;
|
|
180
|
+
error(message: string, options?: NotifyOptions): void;
|
|
181
|
+
/** Withdraw a notice by id (optional). */
|
|
182
|
+
dismiss?(id: string): void;
|
|
183
|
+
}
|
|
184
|
+
interface ErrorSinkPort {
|
|
185
|
+
capture(error: unknown, context: Readonly<Record<string, unknown>>): void;
|
|
186
|
+
}
|
|
187
|
+
interface DebugPort {
|
|
188
|
+
enabled(): boolean;
|
|
189
|
+
subscribe?(listener: () => void): Unsubscribe;
|
|
190
|
+
}
|
|
191
|
+
/** A stored value with its optimistic-concurrency version (0 when the store has none). */
|
|
192
|
+
interface StoredValue<T = unknown> {
|
|
193
|
+
readonly value: T;
|
|
194
|
+
readonly version: number;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Where saved overlay state lives when persistence is on. Keys are already scoped to the
|
|
198
|
+
* identity by the caller (`<identityKey>/<key>`) for stores that are not per-person themselves.
|
|
199
|
+
* Implementations: the browser-local store (`./persistence`), `@ai-matrx/data` over
|
|
200
|
+
* `users.user_surface_state` (`./persistence/data`), or any host database.
|
|
201
|
+
*/
|
|
202
|
+
interface OverlayPersistencePort {
|
|
203
|
+
/**
|
|
204
|
+
* True when the store is per-person itself (rows scoped to the signed-in person, e.g. the
|
|
205
|
+
* `@ai-matrx/data` adapter): the persistence section then passes plain keys (`workspace`,
|
|
206
|
+
* `state:<instanceKey>`) instead of `<identityKey>/<key>`, and defaults to `scope: "person"`.
|
|
207
|
+
*/
|
|
208
|
+
readonly perPerson?: boolean;
|
|
209
|
+
load<T = unknown>(key: string): Promise<StoredValue<T> | null>;
|
|
210
|
+
save<T = unknown>(key: string, value: T, options?: {
|
|
211
|
+
readonly expectedVersion?: number;
|
|
212
|
+
}): Promise<{
|
|
213
|
+
readonly version: number;
|
|
214
|
+
}>;
|
|
215
|
+
remove(key: string): Promise<void>;
|
|
216
|
+
list?(prefix: string): Promise<readonly string[]>;
|
|
217
|
+
/**
|
|
218
|
+
* Every saved value at once (key → value), for stores where one read is cheaper than several.
|
|
219
|
+
* When present, restoring an identity costs exactly this one call: the workspace and every
|
|
220
|
+
* saved component state come out of it, and `load`/`list` are not called on boot.
|
|
221
|
+
*/
|
|
222
|
+
loadAll?(): Promise<ReadonlyMap<string, StoredValue>>;
|
|
223
|
+
}
|
|
224
|
+
interface SummonPorts {
|
|
225
|
+
readonly identity: IdentityPort;
|
|
226
|
+
readonly router: RouterPort;
|
|
227
|
+
readonly notify: NotifyPort;
|
|
228
|
+
readonly errors: ErrorSinkPort;
|
|
229
|
+
readonly debug: DebugPort;
|
|
230
|
+
/** `null` = persistence off (R6). */
|
|
231
|
+
readonly persistence: OverlayPersistencePort | null;
|
|
232
|
+
}
|
|
233
|
+
declare const anonymousIdentity: IdentityPort;
|
|
234
|
+
/** `window.location` + `history.replaceState`; inert on the server. */
|
|
235
|
+
declare const locationRouter: RouterPort;
|
|
236
|
+
declare const consoleNotify: NotifyPort;
|
|
237
|
+
declare const consoleErrorSink: ErrorSinkPort;
|
|
238
|
+
declare const debugOff: DebugPort;
|
|
239
|
+
declare const DEFAULT_PORTS: SummonPorts;
|
|
240
|
+
declare function resolvePorts(overrides: Partial<SummonPorts> | undefined): SummonPorts;
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* A definition's meta with its data type erased, so definitions of every data shape share one
|
|
244
|
+
* registry without casts. (`never` erasure made `defaults` unassignable.)
|
|
245
|
+
*/
|
|
246
|
+
interface AnyOverlayMeta extends Omit<OverlayDefinitionMeta<string, unknown>, "defaults"> {
|
|
247
|
+
readonly defaults?: object | undefined;
|
|
248
|
+
}
|
|
249
|
+
type AnyMeta = AnyOverlayMeta;
|
|
250
|
+
/**
|
|
251
|
+
* Register (or re-register) definitions. Re-registering an id replaces it (hot reload). A link
|
|
252
|
+
* key claimed by two different ids is a host bug and throws, naming both.
|
|
253
|
+
*/
|
|
254
|
+
declare function registerOverlayMeta(definitions: readonly AnyOverlayMeta[]): void;
|
|
255
|
+
declare function getOverlayMeta(overlayId: string): AnyMeta | undefined;
|
|
256
|
+
declare function getOverlayMetaByLinkKey(linkKey: string): AnyMeta | undefined;
|
|
257
|
+
declare function allOverlayMeta(): readonly AnyMeta[];
|
|
258
|
+
declare function isRegisteredOverlay(overlayId: string): boolean;
|
|
259
|
+
declare function subscribeToOverlayRegistry(listener: () => void): () => void;
|
|
260
|
+
/** Test-only. */
|
|
261
|
+
declare function resetOverlayRegistry(): void;
|
|
262
|
+
|
|
263
|
+
interface OpenOverlayPayload<Id extends OverlayId = OverlayId> {
|
|
264
|
+
overlayId: Id;
|
|
265
|
+
instanceId?: string;
|
|
266
|
+
data?: OverlayDataOf<Id> | null;
|
|
267
|
+
}
|
|
268
|
+
interface CloseOverlayPayload<Id extends OverlayId = OverlayId> {
|
|
269
|
+
overlayId: Id;
|
|
270
|
+
instanceId?: string;
|
|
271
|
+
}
|
|
272
|
+
type ToggleOverlayPayload<Id extends OverlayId = OverlayId> = OpenOverlayPayload<Id>;
|
|
273
|
+
interface CloseAllInstancesPayload<Id extends OverlayId = OverlayId> {
|
|
274
|
+
overlayId: Id;
|
|
275
|
+
}
|
|
276
|
+
interface CloseOverlaysBoundToPagePayload {
|
|
277
|
+
/** Overlay ids whose definitions say `closesOnNavigation`. */
|
|
278
|
+
overlayIds: readonly string[];
|
|
279
|
+
}
|
|
280
|
+
interface PruneStaleInstancesPayload {
|
|
281
|
+
olderThanMs: number;
|
|
282
|
+
}
|
|
283
|
+
/** Raw reducer payload: untyped ids + the registry defaults the creator resolved. */
|
|
284
|
+
interface RawOpenPayload {
|
|
285
|
+
overlayId: string;
|
|
286
|
+
instanceId?: string;
|
|
287
|
+
data?: unknown;
|
|
288
|
+
defaults?: Readonly<Record<string, unknown>>;
|
|
289
|
+
}
|
|
290
|
+
interface SummonAction<P> {
|
|
291
|
+
type: string;
|
|
292
|
+
payload: P;
|
|
293
|
+
/** Structurally a Redux `UnknownAction`. */
|
|
294
|
+
[extra: string]: unknown;
|
|
295
|
+
}
|
|
296
|
+
type Creator<Args extends unknown[], P> = ((...args: Args) => SummonAction<P>) & {
|
|
297
|
+
readonly type: string;
|
|
298
|
+
match(action: unknown): action is SummonAction<P>;
|
|
299
|
+
};
|
|
300
|
+
declare const openOverlay: Creator<[payload: OpenOverlayPayload<string>], RawOpenPayload>;
|
|
301
|
+
declare const closeOverlay: Creator<[payload: CloseOverlayPayload<string>], {
|
|
302
|
+
overlayId: string;
|
|
303
|
+
instanceId?: never;
|
|
304
|
+
} | {
|
|
305
|
+
overlayId: string;
|
|
306
|
+
instanceId: string;
|
|
307
|
+
}>;
|
|
308
|
+
declare const toggleOverlay: Creator<[payload: ToggleOverlayPayload<string>], RawOpenPayload>;
|
|
309
|
+
declare const closeAllInstancesOfOverlay: Creator<[payload: CloseAllInstancesPayload<string>], {
|
|
310
|
+
overlayId: string;
|
|
311
|
+
}>;
|
|
312
|
+
/** Ids of every registered overlay whose definition says `closesOnNavigation`. */
|
|
313
|
+
declare function overlayIdsBoundToPage(): string[];
|
|
314
|
+
/** Close page-bound overlays. Omit the ids to use the registry's `closesOnNavigation` list. */
|
|
315
|
+
declare const closeOverlaysBoundToPage: Creator<[payload?: Partial<CloseOverlaysBoundToPagePayload> | undefined], CloseOverlaysBoundToPagePayload>;
|
|
316
|
+
declare const closeAllOverlays: Creator<[], undefined>;
|
|
317
|
+
declare const pruneStaleInstances: Creator<[payload: PruneStaleInstancesPayload], PruneStaleInstancesPayload>;
|
|
318
|
+
declare const focusWindow: Creator<[payload: string], string>;
|
|
319
|
+
declare const restoreWindow: Creator<[payload: string], string>;
|
|
320
|
+
declare const toggleWindowsHidden: Creator<[], undefined>;
|
|
321
|
+
declare const restoreAll: Creator<[], undefined>;
|
|
322
|
+
declare const minimizeAll: Creator<[payload: {
|
|
323
|
+
viewportWidth: number;
|
|
324
|
+
viewportHeight: number;
|
|
325
|
+
}], {
|
|
326
|
+
viewportWidth: number;
|
|
327
|
+
viewportHeight: number;
|
|
328
|
+
}>;
|
|
329
|
+
/** Every slice key the summon reducers own; an action under one of them needs the runtime. */
|
|
330
|
+
declare const SUMMON_SLICE_KEYS: readonly ["overlays", "windowManager", "urlSync", "overlayState"];
|
|
331
|
+
declare function isSummonAction(action: unknown): action is {
|
|
332
|
+
type: string;
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
interface OverlayInstance {
|
|
336
|
+
isOpen: boolean;
|
|
337
|
+
data: unknown;
|
|
338
|
+
/** Unix ms of the last open (pruneStaleInstances reads it). */
|
|
339
|
+
lastUsedAt?: number;
|
|
340
|
+
}
|
|
341
|
+
interface OverlayState {
|
|
342
|
+
overlays: Record<string, Record<string, OverlayInstance>>;
|
|
343
|
+
}
|
|
344
|
+
/** The slice of any store these selectors need (absent until the summon runtime is installed). */
|
|
345
|
+
type StateWithOverlays = {
|
|
346
|
+
overlays?: OverlayState;
|
|
347
|
+
};
|
|
348
|
+
interface OpenInstanceView {
|
|
349
|
+
instanceId: string;
|
|
350
|
+
data: unknown;
|
|
351
|
+
}
|
|
352
|
+
declare const selectOverlay: (state: StateWithOverlays, overlayId: string, instanceId?: string) => OverlayInstance;
|
|
353
|
+
declare const selectIsOverlayOpen: (state: StateWithOverlays, overlayId: string, instanceId?: string) => boolean;
|
|
354
|
+
declare const selectOverlayData: (state: StateWithOverlays, overlayId: string, instanceId?: string) => unknown;
|
|
355
|
+
/** All open instances of an overlay id; the array reference is stable while the open set is unchanged. */
|
|
356
|
+
declare const selectOpenInstances: (state: StateWithOverlays, overlayId: string) => readonly OpenInstanceView[];
|
|
357
|
+
/** Every open instance key (`overlayId:instanceId`). */
|
|
358
|
+
declare function listOpenInstanceKeys(state: StateWithOverlays): string[];
|
|
359
|
+
/** True once anything has ever been opened in this store (a key exists in the slice). */
|
|
360
|
+
declare function selectAnyOverlayTouched(state: StateWithOverlays): boolean;
|
|
361
|
+
/** The global hide-all flag (false before the runtime is installed). */
|
|
362
|
+
declare const selectWindowsHidden: (state: {
|
|
363
|
+
windowManager?: {
|
|
364
|
+
windowsHidden: boolean;
|
|
365
|
+
};
|
|
366
|
+
}) => boolean;
|
|
367
|
+
|
|
368
|
+
/** What the core hands the gate when it loads. */
|
|
369
|
+
interface SummonCore {
|
|
370
|
+
readonly reducers: Readonly<Record<string, Reducer>>;
|
|
371
|
+
createMiddleware(ports?: Partial<SummonPorts>): Middleware[];
|
|
372
|
+
}
|
|
373
|
+
/** Dispatched once after the slices are injected into a live store, so they hold their initial state. */
|
|
374
|
+
declare const SUMMON_INSTALLED_ACTION = "@@summon/installed";
|
|
375
|
+
/** Called by the core module when it evaluates (idempotent). */
|
|
376
|
+
declare function installSummonCore(core: SummonCore): void;
|
|
377
|
+
declare function isSummonInstalled(): boolean;
|
|
378
|
+
declare function subscribeSummonInstalled(listener: () => void): () => void;
|
|
379
|
+
/** Load the summon core (one import(), shared by every caller). Resolves once it is installed. */
|
|
380
|
+
declare function ensureSummonRuntime(): Promise<void>;
|
|
381
|
+
/** Start loading the core without waiting (idle, pointer intent). Errors surface on the next real request. */
|
|
382
|
+
declare function prefetchSummonRuntime(): void;
|
|
383
|
+
interface SummonGate {
|
|
384
|
+
/** Put this in the host store's middleware chain. */
|
|
385
|
+
readonly middleware: Middleware;
|
|
386
|
+
/**
|
|
387
|
+
* Give the gate the host root reducer's inject function — before `configureStore`, so a core
|
|
388
|
+
* that is already loaded (a page that imported the window section) is injected before the
|
|
389
|
+
* store's first state exists.
|
|
390
|
+
*/
|
|
391
|
+
attachReducer(inject: (reducers: Readonly<Record<string, Reducer>>) => void): void;
|
|
392
|
+
}
|
|
393
|
+
interface CreateSummonGateOptions {
|
|
394
|
+
/** Ports for the summon middleware (render watchdog: notify, errors, debug). */
|
|
395
|
+
readonly ports?: Partial<SummonPorts>;
|
|
396
|
+
}
|
|
397
|
+
declare function createSummonGate(options?: CreateSummonGateOptions): SummonGate;
|
|
398
|
+
|
|
399
|
+
export { isRegisteredOverlay as $, type AnyOverlayMeta as A, anonymousIdentity as B, type CloseOverlaysBoundToPagePayload as C, DEFAULT_INSTANCE_ID as D, type ErrorSinkPort as E, closeAllInstancesOfOverlay as F, closeOverlay as G, closeOverlaysBoundToPage as H, type InstanceKey as I, consoleErrorSink as J, type KeepAlive as K, type LinkHydrateContext as L, type MobilePresentation as M, type NotifyOptions as N, type OverlayState as O, type PruneStaleInstancesPayload as P, consoleNotify as Q, type RawOpenPayload as R, type SummonPorts as S, type ToggleOverlayPayload as T, type UnbiddenHomeRoute as U, debugOff as V, type WindowPreservation as W, defaultWindowIdFor as X, getOverlayMeta as Y, getOverlayMetaByLinkKey as Z, instanceKey as _, type StateWithOverlays as a, listOpenInstanceKeys as a0, locationRouter as a1, openOverlay as a2, overlayIdsBoundToPage as a3, parseInstanceKey as a4, registerOverlayMeta as a5, resetOverlayRegistry as a6, resolvePorts as a7, selectIsOverlayOpen as a8, selectOpenInstances as a9, selectOverlay as aa, selectOverlayData as ab, subscribeToOverlayRegistry as ac, toggleOverlay as ad, type CreateSummonGateOptions as ae, SUMMON_INSTALLED_ACTION as af, SUMMON_SLICE_KEYS as ag, type SummonAction as ah, type SummonGate as ai, closeAllOverlays as aj, createSummonGate as ak, ensureSummonRuntime as al, focusWindow as am, installSummonCore as an, isSummonAction as ao, isSummonInstalled as ap, minimizeAll as aq, prefetchSummonRuntime as ar, pruneStaleInstances as as, restoreAll as at, restoreWindow as au, selectAnyOverlayTouched as av, selectWindowsHidden as aw, subscribeSummonInstalled as ax, toggleWindowsHidden as ay, type OverlayDefinitionMeta as b, type SummonCore as c, type CloseAllInstancesPayload as d, type CloseOverlayPayload as e, DEFAULT_PORTS as f, type DebugPort as g, type IdentityPort as h, type InstanceMode as i, type NotifyPort as j, type OpenInstanceView as k, type OpenOverlayPayload as l, type OverlayDataOf as m, type OverlayHostDispatch as n, type OverlayHostTypes as o, type OverlayId as p, type OverlayInstance as q, type OverlayLinkSpec as r, type OverlayPersistencePort as s, type OverlayRawData as t, type OverlayRegistry as u, type OverlayWindowOptions as v, type RouterPort as w, type StoredValue as x, type Unsubscribe as y, allOverlayMeta as z };
|