@ai-matrx/summon 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/LICENSE +21 -0
- package/README.md +380 -2
- package/dist/closeBinding-C6raC3qJ.d.cts +20 -0
- package/dist/closeBinding-C6raC3qJ.d.ts +20 -0
- package/dist/dialog.cjs +60 -0
- package/dist/dialog.cjs.map +1 -0
- package/dist/dialog.d.cts +16 -0
- package/dist/dialog.d.ts +16 -0
- package/dist/dialog.js +38 -0
- package/dist/dialog.js.map +1 -0
- package/dist/errors-eJrKXq33.d.cts +30 -0
- package/dist/errors-eJrKXq33.d.ts +30 -0
- package/dist/handles.cjs +411 -0
- package/dist/handles.cjs.map +1 -0
- package/dist/handles.d.cts +166 -0
- package/dist/handles.d.ts +166 -0
- package/dist/handles.js +388 -0
- package/dist/handles.js.map +1 -0
- package/dist/index.cjs +2383 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1259 -0
- package/dist/index.d.ts +1259 -0
- package/dist/index.js +2363 -0
- package/dist/index.js.map +1 -0
- package/dist/lite.cjs +460 -0
- package/dist/lite.cjs.map +1 -0
- package/dist/lite.d.cts +56 -0
- package/dist/lite.d.ts +56 -0
- package/dist/lite.js +444 -0
- package/dist/lite.js.map +1 -0
- package/dist/next.cjs +61 -0
- package/dist/next.cjs.map +1 -0
- package/dist/next.d.cts +5 -0
- package/dist/next.d.ts +5 -0
- package/dist/next.js +39 -0
- package/dist/next.js.map +1 -0
- package/dist/persistence-data.cjs +143 -0
- package/dist/persistence-data.cjs.map +1 -0
- package/dist/persistence-data.d.cts +72 -0
- package/dist/persistence-data.d.ts +72 -0
- package/dist/persistence-data.js +120 -0
- package/dist/persistence-data.js.map +1 -0
- package/dist/persistence.cjs +1073 -0
- package/dist/persistence.cjs.map +1 -0
- package/dist/persistence.d.cts +236 -0
- package/dist/persistence.d.ts +236 -0
- package/dist/persistence.js +1077 -0
- package/dist/persistence.js.map +1 -0
- package/dist/react.cjs +733 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.cts +261 -0
- package/dist/react.d.ts +261 -0
- package/dist/react.js +718 -0
- package/dist/react.js.map +1 -0
- package/dist/sheet.cjs +71 -0
- package/dist/sheet.cjs.map +1 -0
- package/dist/sheet.d.cts +17 -0
- package/dist/sheet.d.ts +17 -0
- package/dist/sheet.js +49 -0
- package/dist/sheet.js.map +1 -0
- package/dist/styles.css +78 -0
- package/dist/testing.cjs +132 -0
- package/dist/testing.cjs.map +1 -0
- package/dist/testing.d.cts +44 -0
- package/dist/testing.d.ts +44 -0
- package/dist/testing.js +115 -0
- package/dist/testing.js.map +1 -0
- package/dist/url.cjs +362 -0
- package/dist/url.cjs.map +1 -0
- package/dist/url.d.cts +153 -0
- package/dist/url.d.ts +153 -0
- package/dist/url.js +352 -0
- package/dist/url.js.map +1 -0
- package/dist/window-host.cjs +123 -0
- package/dist/window-host.cjs.map +1 -0
- package/dist/window-host.d.cts +72 -0
- package/dist/window-host.d.ts +72 -0
- package/dist/window-host.js +104 -0
- package/dist/window-host.js.map +1 -0
- package/dist/window.cjs +3978 -0
- package/dist/window.cjs.map +1 -0
- package/dist/window.d.cts +796 -0
- package/dist/window.d.ts +796 -0
- package/dist/window.js +4003 -0
- package/dist/window.js.map +1 -0
- package/package.json +237 -4
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,1259 @@
|
|
|
1
|
+
import * as _reduxjs_toolkit from '@reduxjs/toolkit';
|
|
2
|
+
import { PayloadAction, Reducer, UnknownAction, Middleware } from '@reduxjs/toolkit';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The shared vocabulary of @ai-matrx/summon. Framework-free: no React, no Redux imports.
|
|
6
|
+
*
|
|
7
|
+
* An OVERLAY is any component rendered on top of the app by dispatch — a window, dialog, sheet,
|
|
8
|
+
* light floating window, toast-like card, anything. It is identified by an `OverlayId` and opened
|
|
9
|
+
* as one or more INSTANCES (`instanceId`, "default" for single-instance overlays).
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* The host's overlay registry: overlay id → the data its opener accepts. Hosts extend it by
|
|
13
|
+
* module augmentation so every open call is type-checked:
|
|
14
|
+
*
|
|
15
|
+
* declare module "@ai-matrx/summon" {
|
|
16
|
+
* interface OverlayRegistry { notesWindow: { noteId?: string } }
|
|
17
|
+
* }
|
|
18
|
+
*
|
|
19
|
+
* `defineOverlay` emits nothing at runtime for this; the augmentation is the host's one-line
|
|
20
|
+
* declaration per overlay (the converter writes it next to each definition).
|
|
21
|
+
*/
|
|
22
|
+
interface OverlayRegistry {
|
|
23
|
+
}
|
|
24
|
+
/** Every registered overlay id; plain `string` until the host augments the registry. */
|
|
25
|
+
type OverlayId = [keyof OverlayRegistry] extends [never] ? string : Extract<keyof OverlayRegistry, string>;
|
|
26
|
+
/** The open-data type declared for an overlay id. */
|
|
27
|
+
type OverlayDataOf<Id extends string> = Id extends keyof OverlayRegistry ? OverlayRegistry[Id] : Record<string, unknown>;
|
|
28
|
+
/**
|
|
29
|
+
* Data as it arrives at render time. It crossed Redux, a URL or storage, so it is NOT trusted to
|
|
30
|
+
* match the opener's type: render code narrows it (or the definition supplies `parse`).
|
|
31
|
+
*/
|
|
32
|
+
type OverlayRawData = Readonly<Record<string, unknown>> | null;
|
|
33
|
+
declare const DEFAULT_INSTANCE_ID = "default";
|
|
34
|
+
/** `single`: one instance ("default"). `multi`: any number, each with its own instanceId. */
|
|
35
|
+
type InstanceMode = "single" | "multi";
|
|
36
|
+
/**
|
|
37
|
+
* What closing does to a mounted overlay (Arman, 2026-10-16, C38 R3):
|
|
38
|
+
* none — unmount (default).
|
|
39
|
+
* hidden — stay mounted but hidden; reopening shows the same live component (LRU-capped).
|
|
40
|
+
* restore — unmount, but values saved with `useOverlayState` come back on reopen.
|
|
41
|
+
* Minimizing a window always keeps its component mounted, whatever this says.
|
|
42
|
+
*/
|
|
43
|
+
type KeepAlive = "none" | "hidden" | "restore";
|
|
44
|
+
/** `overlayId:instanceId` — the one key every subsystem uses for an open instance. */
|
|
45
|
+
type InstanceKey = `${string}:${string}`;
|
|
46
|
+
declare function instanceKey(overlayId: string, instanceId?: string): InstanceKey;
|
|
47
|
+
declare function parseInstanceKey(key: string): {
|
|
48
|
+
overlayId: string;
|
|
49
|
+
instanceId: string;
|
|
50
|
+
} | null;
|
|
51
|
+
type MobilePresentation = "fullscreen" | "drawer" | "card" | "hidden";
|
|
52
|
+
/**
|
|
53
|
+
* Default-deny allowlist of the open data a window may save and restore. A window with no
|
|
54
|
+
* preservation entry restores geometry only.
|
|
55
|
+
*/
|
|
56
|
+
interface WindowPreservation {
|
|
57
|
+
readonly dataKeys: readonly string[];
|
|
58
|
+
readonly requiredDataKeys?: readonly string[];
|
|
59
|
+
readonly allowedDataValues?: Readonly<Record<string, readonly (string | number | boolean | null)[]>>;
|
|
60
|
+
/** Default 32 KiB. */
|
|
61
|
+
readonly maxDataBytes?: number;
|
|
62
|
+
}
|
|
63
|
+
/** One declared home for an unbidden (system-raised) window: a route prefix, or one exact page. */
|
|
64
|
+
type UnbiddenHomeRoute = string | {
|
|
65
|
+
readonly route: string;
|
|
66
|
+
readonly exact: true;
|
|
67
|
+
};
|
|
68
|
+
interface OverlayWindowOptions {
|
|
69
|
+
readonly mobile?: MobilePresentation;
|
|
70
|
+
readonly mobileSidebarAs?: "drawer" | "inline";
|
|
71
|
+
/** Never saved or restored (debug panels, one-shot tools, callback-bound editors). */
|
|
72
|
+
readonly ephemeral?: boolean;
|
|
73
|
+
readonly preservation?: WindowPreservation;
|
|
74
|
+
/**
|
|
75
|
+
* Values merged under saved data when a window is RESTORED (reload, another device). Unlike the
|
|
76
|
+
* definition's `defaults`, never applied to a normal open.
|
|
77
|
+
*/
|
|
78
|
+
readonly restoreDefaults?: Readonly<Record<string, unknown>>;
|
|
79
|
+
/**
|
|
80
|
+
* The window-manager id the WindowPanel registers under for the default instance. Default: the
|
|
81
|
+
* overlay id. The render watchdog reveals and inspects this id until the panel acks its own.
|
|
82
|
+
*/
|
|
83
|
+
readonly windowId?: string;
|
|
84
|
+
readonly deprecated?: {
|
|
85
|
+
readonly replacement?: string;
|
|
86
|
+
readonly reason?: string;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Where a window nobody opened (system-raised) may raise itself. Default deny: no home → it may
|
|
90
|
+
* not raise itself anywhere (`mayRaiseUnbidden` in the window section).
|
|
91
|
+
*/
|
|
92
|
+
readonly unbiddenHome?: readonly UnbiddenHomeRoute[];
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Host-specific types the package passes through untouched. A Redux host augments `dispatch`
|
|
96
|
+
* with its thunk-aware dispatch so link hydrators can dispatch its thunks without casts:
|
|
97
|
+
*
|
|
98
|
+
* declare module "@ai-matrx/summon" { interface OverlayHostTypes { dispatch: AppDispatch } }
|
|
99
|
+
*/
|
|
100
|
+
interface OverlayHostTypes {
|
|
101
|
+
}
|
|
102
|
+
type OverlayHostDispatch = OverlayHostTypes extends {
|
|
103
|
+
dispatch: infer D;
|
|
104
|
+
} ? D : (action: unknown) => unknown;
|
|
105
|
+
interface LinkHydrateContext<Data> {
|
|
106
|
+
/** The id segment of the link token (`notes:<id>`). */
|
|
107
|
+
readonly id: string;
|
|
108
|
+
/** Decoded `k-v` arguments of the token. */
|
|
109
|
+
readonly args: Readonly<Record<string, string>>;
|
|
110
|
+
/** Open this overlay. */
|
|
111
|
+
open(options?: {
|
|
112
|
+
readonly instanceId?: string;
|
|
113
|
+
readonly data?: Data;
|
|
114
|
+
}): void;
|
|
115
|
+
/** The host store's dispatch, for thunks a hydrator needs (loading a record first). Typed by
|
|
116
|
+
* augmenting `OverlayHostTypes` with the host's dispatch type. */
|
|
117
|
+
readonly dispatch: OverlayHostDispatch;
|
|
118
|
+
}
|
|
119
|
+
interface OverlayLinkSpec<Data> {
|
|
120
|
+
/** The token type key in `?panels=key:id`. Unique across the host. */
|
|
121
|
+
readonly key: string;
|
|
122
|
+
/** Older keys that still resolve to this overlay. */
|
|
123
|
+
readonly aliases?: readonly string[];
|
|
124
|
+
/** Turn a link token into an open overlay (and its data). `"refused"` keeps the token and says why. */
|
|
125
|
+
hydrate(context: LinkHydrateContext<Data>): void | "refused" | Promise<void | "refused">;
|
|
126
|
+
}
|
|
127
|
+
interface OverlayDefinitionMeta<Id extends string = string, Data = Record<string, unknown>> {
|
|
128
|
+
readonly id: Id;
|
|
129
|
+
/** Human label: tray, menus, diagnostics. */
|
|
130
|
+
readonly label: string;
|
|
131
|
+
readonly instance?: InstanceMode;
|
|
132
|
+
readonly keepAlive?: KeepAlive;
|
|
133
|
+
/** Close when the route changes — the overlay shows a piece of the page that opened it. */
|
|
134
|
+
readonly closesOnNavigation?: boolean;
|
|
135
|
+
/** Present only for overlays that render a WindowPanel. */
|
|
136
|
+
readonly window?: OverlayWindowOptions;
|
|
137
|
+
readonly link?: OverlayLinkSpec<Data>;
|
|
138
|
+
/** Defaults merged under open data (replaces the old per-overlay schema registry). */
|
|
139
|
+
readonly defaults?: Partial<Data>;
|
|
140
|
+
}
|
|
141
|
+
/** The window-manager id a singleton window overlay registers under (`window.windowId ?? id`). */
|
|
142
|
+
declare function defaultWindowIdFor(meta: Pick<OverlayDefinitionMeta, "id" | "window">): string;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Everything the overlays system needs from its host, as ports. Every port ships a working
|
|
146
|
+
* default, so a bare host gets a working system with zero wiring (package standard rule 8); a
|
|
147
|
+
* host overrides only what it has: identity, navigation, notifications, error sink, debug flag,
|
|
148
|
+
* persistence. Framework-free.
|
|
149
|
+
*/
|
|
150
|
+
type Unsubscribe = () => void;
|
|
151
|
+
/** Who the person is, for isolating saved state. `key` changes → everything saved is swapped. */
|
|
152
|
+
interface IdentityPort {
|
|
153
|
+
current(): {
|
|
154
|
+
readonly key: string;
|
|
155
|
+
readonly ready: boolean;
|
|
156
|
+
};
|
|
157
|
+
subscribe(listener: () => void): Unsubscribe;
|
|
158
|
+
}
|
|
159
|
+
/** The address bar: route changes (close-on-navigation) and the `?panels=` link channel. */
|
|
160
|
+
interface RouterPort {
|
|
161
|
+
pathname(): string;
|
|
162
|
+
search(): string;
|
|
163
|
+
/** Replace the query string without navigating or remounting the page. */
|
|
164
|
+
replaceSearch(nextSearch: string): void;
|
|
165
|
+
subscribe(listener: () => void): Unsubscribe;
|
|
166
|
+
}
|
|
167
|
+
interface NotifyOptions {
|
|
168
|
+
readonly id?: string;
|
|
169
|
+
readonly description?: string;
|
|
170
|
+
/** How long the notice stays up (ms). Hosts without timed notices ignore it. */
|
|
171
|
+
readonly duration?: number;
|
|
172
|
+
/** One action button (e.g. the render watchdog's "Show it"). Hosts without actions ignore it. */
|
|
173
|
+
readonly action?: {
|
|
174
|
+
readonly label: string;
|
|
175
|
+
readonly onClick: () => void;
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
interface NotifyPort {
|
|
179
|
+
info(message: string, options?: NotifyOptions): void;
|
|
180
|
+
warn(message: string, options?: NotifyOptions): void;
|
|
181
|
+
error(message: string, options?: NotifyOptions): void;
|
|
182
|
+
/** Withdraw a notice by id (optional). */
|
|
183
|
+
dismiss?(id: string): void;
|
|
184
|
+
}
|
|
185
|
+
interface ErrorSinkPort {
|
|
186
|
+
capture(error: unknown, context: Readonly<Record<string, unknown>>): void;
|
|
187
|
+
}
|
|
188
|
+
interface DebugPort {
|
|
189
|
+
enabled(): boolean;
|
|
190
|
+
subscribe?(listener: () => void): Unsubscribe;
|
|
191
|
+
}
|
|
192
|
+
/** A stored value with its optimistic-concurrency version (0 when the store has none). */
|
|
193
|
+
interface StoredValue<T = unknown> {
|
|
194
|
+
readonly value: T;
|
|
195
|
+
readonly version: number;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Where saved overlay state lives when persistence is on. Keys are already scoped to the
|
|
199
|
+
* identity by the caller (`<identityKey>/<key>`) for stores that are not per-person themselves.
|
|
200
|
+
* Implementations: the browser-local store (`./persistence`), `@ai-matrx/data` over
|
|
201
|
+
* `users.user_surface_state` (`./persistence/data`), or any host database.
|
|
202
|
+
*/
|
|
203
|
+
interface OverlayPersistencePort {
|
|
204
|
+
/**
|
|
205
|
+
* True when the store is per-person itself (rows scoped to the signed-in person, e.g. the
|
|
206
|
+
* `@ai-matrx/data` adapter): the persistence section then passes plain keys (`workspace`,
|
|
207
|
+
* `state:<instanceKey>`) instead of `<identityKey>/<key>`, and defaults to `scope: "person"`.
|
|
208
|
+
*/
|
|
209
|
+
readonly perPerson?: boolean;
|
|
210
|
+
load<T = unknown>(key: string): Promise<StoredValue<T> | null>;
|
|
211
|
+
save<T = unknown>(key: string, value: T, options?: {
|
|
212
|
+
readonly expectedVersion?: number;
|
|
213
|
+
}): Promise<{
|
|
214
|
+
readonly version: number;
|
|
215
|
+
}>;
|
|
216
|
+
remove(key: string): Promise<void>;
|
|
217
|
+
list?(prefix: string): Promise<readonly string[]>;
|
|
218
|
+
}
|
|
219
|
+
interface SummonPorts {
|
|
220
|
+
readonly identity: IdentityPort;
|
|
221
|
+
readonly router: RouterPort;
|
|
222
|
+
readonly notify: NotifyPort;
|
|
223
|
+
readonly errors: ErrorSinkPort;
|
|
224
|
+
readonly debug: DebugPort;
|
|
225
|
+
/** `null` = persistence off (R6). */
|
|
226
|
+
readonly persistence: OverlayPersistencePort | null;
|
|
227
|
+
}
|
|
228
|
+
declare const anonymousIdentity: IdentityPort;
|
|
229
|
+
/** `window.location` + `history.replaceState`; inert on the server. */
|
|
230
|
+
declare const locationRouter: RouterPort;
|
|
231
|
+
declare const consoleNotify: NotifyPort;
|
|
232
|
+
declare const consoleErrorSink: ErrorSinkPort;
|
|
233
|
+
declare const debugOff: DebugPort;
|
|
234
|
+
declare const DEFAULT_PORTS: SummonPorts;
|
|
235
|
+
declare function resolvePorts(overrides: Partial<SummonPorts> | undefined): SummonPorts;
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* A definition's meta with its data type erased, so definitions of every data shape share one
|
|
239
|
+
* registry without casts. (`never` erasure made `defaults` unassignable.)
|
|
240
|
+
*/
|
|
241
|
+
interface AnyOverlayMeta extends Omit<OverlayDefinitionMeta<string, unknown>, "defaults"> {
|
|
242
|
+
readonly defaults?: object | undefined;
|
|
243
|
+
}
|
|
244
|
+
type AnyMeta = AnyOverlayMeta;
|
|
245
|
+
/**
|
|
246
|
+
* Register (or re-register) definitions. Re-registering an id replaces it (hot reload). A link
|
|
247
|
+
* key claimed by two different ids is a host bug and throws, naming both.
|
|
248
|
+
*/
|
|
249
|
+
declare function registerOverlayMeta(definitions: readonly AnyOverlayMeta[]): void;
|
|
250
|
+
declare function getOverlayMeta(overlayId: string): AnyMeta | undefined;
|
|
251
|
+
declare function getOverlayMetaByLinkKey(linkKey: string): AnyMeta | undefined;
|
|
252
|
+
declare function allOverlayMeta(): readonly AnyMeta[];
|
|
253
|
+
declare function isRegisteredOverlay(overlayId: string): boolean;
|
|
254
|
+
declare function subscribeToOverlayRegistry(listener: () => void): () => void;
|
|
255
|
+
/** Test-only. */
|
|
256
|
+
declare function resetOverlayRegistry(): void;
|
|
257
|
+
|
|
258
|
+
interface OpenOverlayPayload<Id extends OverlayId = OverlayId> {
|
|
259
|
+
overlayId: Id;
|
|
260
|
+
instanceId?: string;
|
|
261
|
+
data?: OverlayDataOf<Id> | null;
|
|
262
|
+
}
|
|
263
|
+
interface CloseOverlayPayload<Id extends OverlayId = OverlayId> {
|
|
264
|
+
overlayId: Id;
|
|
265
|
+
instanceId?: string;
|
|
266
|
+
}
|
|
267
|
+
type ToggleOverlayPayload<Id extends OverlayId = OverlayId> = OpenOverlayPayload<Id>;
|
|
268
|
+
interface CloseAllInstancesPayload<Id extends OverlayId = OverlayId> {
|
|
269
|
+
overlayId: Id;
|
|
270
|
+
}
|
|
271
|
+
interface CloseOverlaysBoundToPagePayload {
|
|
272
|
+
/** Overlay ids whose definitions say `closesOnNavigation`. */
|
|
273
|
+
overlayIds: readonly string[];
|
|
274
|
+
}
|
|
275
|
+
interface PruneStaleInstancesPayload {
|
|
276
|
+
olderThanMs: number;
|
|
277
|
+
}
|
|
278
|
+
interface OverlayInstance {
|
|
279
|
+
isOpen: boolean;
|
|
280
|
+
data: unknown;
|
|
281
|
+
/**
|
|
282
|
+
* Unix ms timestamp of the last open action. Used by `pruneStaleInstances` to GC
|
|
283
|
+
* long-forgotten closed entries. Set on every open, untouched on close.
|
|
284
|
+
*/
|
|
285
|
+
lastUsedAt?: number;
|
|
286
|
+
}
|
|
287
|
+
interface OverlayState {
|
|
288
|
+
overlays: Record<string, Record<string, OverlayInstance>>;
|
|
289
|
+
}
|
|
290
|
+
/** Raw reducer payloads: untyped ids + the registry defaults the action creator resolved. */
|
|
291
|
+
interface RawOpenPayload {
|
|
292
|
+
overlayId: string;
|
|
293
|
+
instanceId?: string;
|
|
294
|
+
data?: unknown;
|
|
295
|
+
defaults?: Readonly<Record<string, unknown>>;
|
|
296
|
+
}
|
|
297
|
+
declare const overlaysReducer: _reduxjs_toolkit.Reducer<OverlayState>;
|
|
298
|
+
/** The raw slice action creators (untyped ids). Use for `.match` / `.type`; dispatch the typed ones. */
|
|
299
|
+
declare const overlaysRawActions: _reduxjs_toolkit.CaseReducerActions<{
|
|
300
|
+
openOverlay: (state: {
|
|
301
|
+
overlays: {
|
|
302
|
+
[x: string]: {
|
|
303
|
+
[x: string]: {
|
|
304
|
+
isOpen: boolean;
|
|
305
|
+
data: unknown;
|
|
306
|
+
lastUsedAt?: number;
|
|
307
|
+
};
|
|
308
|
+
};
|
|
309
|
+
};
|
|
310
|
+
}, action: PayloadAction<RawOpenPayload>) => void;
|
|
311
|
+
closeOverlay: (state: {
|
|
312
|
+
overlays: {
|
|
313
|
+
[x: string]: {
|
|
314
|
+
[x: string]: {
|
|
315
|
+
isOpen: boolean;
|
|
316
|
+
data: unknown;
|
|
317
|
+
lastUsedAt?: number;
|
|
318
|
+
};
|
|
319
|
+
};
|
|
320
|
+
};
|
|
321
|
+
}, action: PayloadAction<{
|
|
322
|
+
overlayId: string;
|
|
323
|
+
instanceId?: string;
|
|
324
|
+
}>) => void;
|
|
325
|
+
closeAllOverlays: (state: {
|
|
326
|
+
overlays: {
|
|
327
|
+
[x: string]: {
|
|
328
|
+
[x: string]: {
|
|
329
|
+
isOpen: boolean;
|
|
330
|
+
data: unknown;
|
|
331
|
+
lastUsedAt?: number;
|
|
332
|
+
};
|
|
333
|
+
};
|
|
334
|
+
};
|
|
335
|
+
}) => void;
|
|
336
|
+
toggleOverlay: (state: {
|
|
337
|
+
overlays: {
|
|
338
|
+
[x: string]: {
|
|
339
|
+
[x: string]: {
|
|
340
|
+
isOpen: boolean;
|
|
341
|
+
data: unknown;
|
|
342
|
+
lastUsedAt?: number;
|
|
343
|
+
};
|
|
344
|
+
};
|
|
345
|
+
};
|
|
346
|
+
}, action: PayloadAction<RawOpenPayload>) => void;
|
|
347
|
+
/** Removes every instance of an overlay id (e.g. an editor that spawned many tabs). */
|
|
348
|
+
closeAllInstancesOfOverlay: (state: {
|
|
349
|
+
overlays: {
|
|
350
|
+
[x: string]: {
|
|
351
|
+
[x: string]: {
|
|
352
|
+
isOpen: boolean;
|
|
353
|
+
data: unknown;
|
|
354
|
+
lastUsedAt?: number;
|
|
355
|
+
};
|
|
356
|
+
};
|
|
357
|
+
};
|
|
358
|
+
}, action: PayloadAction<{
|
|
359
|
+
overlayId: string;
|
|
360
|
+
}>) => void;
|
|
361
|
+
/**
|
|
362
|
+
* Route change: close every open instance of the listed overlays — each shows a piece of the
|
|
363
|
+
* page that opened it, so after navigating away it would float over a page it does not
|
|
364
|
+
* belong to. Every other overlay is a workbench tool and stays open.
|
|
365
|
+
*/
|
|
366
|
+
closeOverlaysBoundToPage: (state: {
|
|
367
|
+
overlays: {
|
|
368
|
+
[x: string]: {
|
|
369
|
+
[x: string]: {
|
|
370
|
+
isOpen: boolean;
|
|
371
|
+
data: unknown;
|
|
372
|
+
lastUsedAt?: number;
|
|
373
|
+
};
|
|
374
|
+
};
|
|
375
|
+
};
|
|
376
|
+
}, action: PayloadAction<CloseOverlaysBoundToPagePayload>) => void;
|
|
377
|
+
/**
|
|
378
|
+
* GC pass — removes closed instances last used more than `olderThanMs` ago. Singleton slots
|
|
379
|
+
* are kept regardless so selectors returning stable references don't thrash.
|
|
380
|
+
*/
|
|
381
|
+
pruneStaleInstances: (state: {
|
|
382
|
+
overlays: {
|
|
383
|
+
[x: string]: {
|
|
384
|
+
[x: string]: {
|
|
385
|
+
isOpen: boolean;
|
|
386
|
+
data: unknown;
|
|
387
|
+
lastUsedAt?: number;
|
|
388
|
+
};
|
|
389
|
+
};
|
|
390
|
+
};
|
|
391
|
+
}, action: PayloadAction<PruneStaleInstancesPayload>) => void;
|
|
392
|
+
}, "overlays">;
|
|
393
|
+
declare const openOverlay: (<Id extends OverlayId>(payload: OpenOverlayPayload<Id>) => {
|
|
394
|
+
payload: RawOpenPayload;
|
|
395
|
+
type: "overlays/openOverlay";
|
|
396
|
+
}) & Pick<_reduxjs_toolkit.ActionCreatorWithPayload<RawOpenPayload, "overlays/openOverlay">, "type" | "match">;
|
|
397
|
+
declare const closeOverlay: (<Id extends OverlayId>(payload: CloseOverlayPayload<Id>) => {
|
|
398
|
+
payload: {
|
|
399
|
+
overlayId: string;
|
|
400
|
+
instanceId?: string;
|
|
401
|
+
};
|
|
402
|
+
type: "overlays/closeOverlay";
|
|
403
|
+
}) & Pick<_reduxjs_toolkit.ActionCreatorWithPayload<{
|
|
404
|
+
overlayId: string;
|
|
405
|
+
instanceId?: string;
|
|
406
|
+
}, "overlays/closeOverlay">, "type" | "match">;
|
|
407
|
+
declare const toggleOverlay: (<Id extends OverlayId>(payload: ToggleOverlayPayload<Id>) => {
|
|
408
|
+
payload: RawOpenPayload;
|
|
409
|
+
type: "overlays/toggleOverlay";
|
|
410
|
+
}) & Pick<_reduxjs_toolkit.ActionCreatorWithPayload<RawOpenPayload, "overlays/toggleOverlay">, "type" | "match">;
|
|
411
|
+
declare const closeAllInstancesOfOverlay: (<Id extends OverlayId>(payload: CloseAllInstancesPayload<Id>) => {
|
|
412
|
+
payload: {
|
|
413
|
+
overlayId: string;
|
|
414
|
+
};
|
|
415
|
+
type: "overlays/closeAllInstancesOfOverlay";
|
|
416
|
+
}) & Pick<_reduxjs_toolkit.ActionCreatorWithPayload<{
|
|
417
|
+
overlayId: string;
|
|
418
|
+
}, "overlays/closeAllInstancesOfOverlay">, "type" | "match">;
|
|
419
|
+
/** Ids of every registered overlay whose definition says `closesOnNavigation`. */
|
|
420
|
+
declare function overlayIdsBoundToPage(): string[];
|
|
421
|
+
/** Close page-bound overlays. Omit the ids to use the registry's `closesOnNavigation` list. */
|
|
422
|
+
declare const closeOverlaysBoundToPage: ((payload?: Partial<CloseOverlaysBoundToPagePayload>) => {
|
|
423
|
+
payload: CloseOverlaysBoundToPagePayload;
|
|
424
|
+
type: "overlays/closeOverlaysBoundToPage";
|
|
425
|
+
}) & Pick<_reduxjs_toolkit.ActionCreatorWithPayload<CloseOverlaysBoundToPagePayload, "overlays/closeOverlaysBoundToPage">, "type" | "match">;
|
|
426
|
+
declare const closeAllOverlays: _reduxjs_toolkit.ActionCreatorWithoutPayload<"overlays/closeAllOverlays">;
|
|
427
|
+
declare const pruneStaleInstances: _reduxjs_toolkit.ActionCreatorWithPayload<PruneStaleInstancesPayload, "overlays/pruneStaleInstances">;
|
|
428
|
+
/** The slice of any store these selectors need. */
|
|
429
|
+
type StateWithOverlays = {
|
|
430
|
+
overlays: OverlayState;
|
|
431
|
+
};
|
|
432
|
+
interface OpenInstanceView {
|
|
433
|
+
instanceId: string;
|
|
434
|
+
data: unknown;
|
|
435
|
+
}
|
|
436
|
+
declare const selectOverlay: (state: StateWithOverlays, overlayId: string, instanceId?: string) => OverlayInstance;
|
|
437
|
+
declare const selectIsOverlayOpen: (state: StateWithOverlays, overlayId: string, instanceId?: string) => boolean;
|
|
438
|
+
declare const selectOverlayData: (state: StateWithOverlays, overlayId: string, instanceId?: string) => unknown;
|
|
439
|
+
/**
|
|
440
|
+
* All currently-open instances of an overlay id. Memoized per id: the array reference is stable
|
|
441
|
+
* while the open set is unchanged.
|
|
442
|
+
*/
|
|
443
|
+
declare const selectOpenInstances: (state: StateWithOverlays, overlayId: string) => readonly OpenInstanceView[];
|
|
444
|
+
/** Every open instance key (`overlayId:instanceId`) in the state. */
|
|
445
|
+
declare function listOpenInstanceKeys(state: StateWithOverlays): string[];
|
|
446
|
+
|
|
447
|
+
interface WindowRect {
|
|
448
|
+
x: number;
|
|
449
|
+
y: number;
|
|
450
|
+
width: number;
|
|
451
|
+
height: number;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* Calculates a 4-grid quadrant (2x2).
|
|
456
|
+
* @param index 0: top-left, 1: top-right, 2: bottom-left, 3: bottom-right
|
|
457
|
+
*/
|
|
458
|
+
declare function getGrid4Rect(index: number, vw: number, vh: number): WindowRect;
|
|
459
|
+
/**
|
|
460
|
+
* Calculates a 6-grid partition (3 columns x 2 rows).
|
|
461
|
+
* @param index 0-5. 0-2 is top row (left-to-right), 3-5 is bottom row.
|
|
462
|
+
*/
|
|
463
|
+
declare function getGrid6Rect(index: number, vw: number, vh: number): WindowRect;
|
|
464
|
+
/**
|
|
465
|
+
* Calculates an 8-window grid (4 columns, 2 a rows)
|
|
466
|
+
*/
|
|
467
|
+
declare function getGrid8Rect(index: number, vw: number, vh: number): WindowRect;
|
|
468
|
+
/**
|
|
469
|
+
* Calculates a 9-window grid (3 columns, 3 rows)
|
|
470
|
+
*/
|
|
471
|
+
declare function getGrid9Rect(index: number, vw: number, vh: number): WindowRect;
|
|
472
|
+
/**
|
|
473
|
+
* Calculates a 12-window grid (4 columns, 3 rows)
|
|
474
|
+
*/
|
|
475
|
+
declare function getGrid12Rect(index: number, vw: number, vh: number): WindowRect;
|
|
476
|
+
/**
|
|
477
|
+
* Calculates 2 stacked windows on the right edge.
|
|
478
|
+
* @param index 0: top right half, 1: bottom right half
|
|
479
|
+
*/
|
|
480
|
+
declare function getStackedRight2Rect(index: number, vw: number, vh: number): WindowRect;
|
|
481
|
+
/**
|
|
482
|
+
* Calculates 3 stacked windows on the right edge.
|
|
483
|
+
* @param index 0, 1, 2 top-to-bottom on the right third of the screen.
|
|
484
|
+
*/
|
|
485
|
+
declare function getStackedRight3Rect(index: number, vw: number, vh: number): WindowRect;
|
|
486
|
+
/**
|
|
487
|
+
* Calculates 4 stacked windows on the right edge.
|
|
488
|
+
* @param index 0,1,2,3 top-to-bottom on the right quarter of the screen.
|
|
489
|
+
*/
|
|
490
|
+
declare function getStackedRight4Rect(index: number, vw: number, vh: number): WindowRect;
|
|
491
|
+
/**
|
|
492
|
+
* Calculates 5 stacked windows on the right edge.
|
|
493
|
+
*/
|
|
494
|
+
declare function getStackedRight5Rect(index: number, vw: number, vh: number): WindowRect;
|
|
495
|
+
/**
|
|
496
|
+
* Calculates 2 stacked windows on the left edge.
|
|
497
|
+
* @param index 0: top left half, 1: bottom left half
|
|
498
|
+
*/
|
|
499
|
+
declare function getStackedLeft2Rect(index: number, vw: number, vh: number): WindowRect;
|
|
500
|
+
/**
|
|
501
|
+
* Calculates 3 stacked windows on the left edge.
|
|
502
|
+
* @param index 0, 1, 2 top-to-bottom on the left third of the screen.
|
|
503
|
+
*/
|
|
504
|
+
declare function getStackedLeft3Rect(index: number, vw: number, vh: number): WindowRect;
|
|
505
|
+
/**
|
|
506
|
+
* Calculates 4 stacked windows on the left edge.
|
|
507
|
+
* @param index 0,1,2,3 top-to-bottom on the left quarter of the screen.
|
|
508
|
+
*/
|
|
509
|
+
declare function getStackedLeft4Rect(index: number, vw: number, vh: number): WindowRect;
|
|
510
|
+
/**
|
|
511
|
+
* Calculates 5 stacked windows on the left edge.
|
|
512
|
+
*/
|
|
513
|
+
declare function getStackedLeft5Rect(index: number, vw: number, vh: number): WindowRect;
|
|
514
|
+
type GlobalLayoutType = "grid4" | "grid6" | "grid8" | "grid9" | "grid12" | "stackRight2" | "stackRight3" | "stackRight4" | "stackRight5" | "stackLeft2" | "stackLeft3" | "stackLeft4" | "stackLeft5";
|
|
515
|
+
/**
|
|
516
|
+
* Helper: Applies global arrangement to an array of windows logic.
|
|
517
|
+
* Returns an array of updates to batch dispatch.
|
|
518
|
+
*/
|
|
519
|
+
declare function computeGlobalArrangement(layout: GlobalLayoutType, windowIds: string[], vw: number, vh: number, dirX?: "ltr" | "rtl", dirY?: "ttb" | "btt", primary?: "horizontal" | "vertical"): {
|
|
520
|
+
id: string;
|
|
521
|
+
rect: WindowRect;
|
|
522
|
+
}[];
|
|
523
|
+
|
|
524
|
+
interface DockWindowPayload {
|
|
525
|
+
id: string;
|
|
526
|
+
viewportWidth: number;
|
|
527
|
+
viewportHeight: number;
|
|
528
|
+
}
|
|
529
|
+
/** Build a dock action payload from the live parent viewport. Client-only. */
|
|
530
|
+
declare function buildDockWindowPayload(windowId: string): DockWindowPayload;
|
|
531
|
+
|
|
532
|
+
type WindowState = "windowed" | "maximized" | "minimized";
|
|
533
|
+
declare const WINDOW_SESSION_SCHEMA_VERSION: 1;
|
|
534
|
+
/** Canonical persistence identity. Runtime window ids and registry slugs are not identities. */
|
|
535
|
+
declare function windowSessionKey(overlayId: string, instanceId: string): string;
|
|
536
|
+
interface WindowPersistenceRegistration {
|
|
537
|
+
overlayId: string;
|
|
538
|
+
instanceId: string;
|
|
539
|
+
data: Record<string, unknown>;
|
|
540
|
+
sidebarOpen: boolean;
|
|
541
|
+
sidebarSize: number | null;
|
|
542
|
+
}
|
|
543
|
+
interface WindowPersistenceState extends WindowPersistenceRegistration {
|
|
544
|
+
/** Explicit close suppresses every later snapshot/unmount path. */
|
|
545
|
+
closing: boolean;
|
|
546
|
+
}
|
|
547
|
+
/** Compact, JSON-only record written to the local window workspace cache. */
|
|
548
|
+
interface PersistedWindowSession {
|
|
549
|
+
schemaVersion: typeof WINDOW_SESSION_SCHEMA_VERSION;
|
|
550
|
+
sessionKey: string;
|
|
551
|
+
overlayId: string;
|
|
552
|
+
instanceId: string;
|
|
553
|
+
/** Runtime id is diagnostic/matching metadata, never the canonical identity. */
|
|
554
|
+
windowId: string;
|
|
555
|
+
title: string;
|
|
556
|
+
state: WindowState;
|
|
557
|
+
/** Always the full windowed rect, never minimized-card geometry. */
|
|
558
|
+
windowedRect: WindowRect;
|
|
559
|
+
traySlot: number | null;
|
|
560
|
+
zIndex: number;
|
|
561
|
+
sidebarOpen: boolean;
|
|
562
|
+
sidebarSize: number | null;
|
|
563
|
+
data: Record<string, unknown>;
|
|
564
|
+
savedAt: number;
|
|
565
|
+
}
|
|
566
|
+
/** Viewport-normalized session staged for a live WindowPanel registration. */
|
|
567
|
+
interface HydratedWindowSession extends PersistedWindowSession {
|
|
568
|
+
/** Current-viewport render rect; tray geometry is recomputed, never stored. */
|
|
569
|
+
renderRect: WindowRect;
|
|
570
|
+
}
|
|
571
|
+
/**
|
|
572
|
+
* Pop-out mode for windows that have been detached into a separate browser
|
|
573
|
+
* window. Orthogonal to `WindowState` — a popped-out window still has a
|
|
574
|
+
* "logical" docked state remembered on `prePopoutRect` for the dock-back path.
|
|
575
|
+
*
|
|
576
|
+
* - `"pip"`: Document Picture-in-Picture (Chromium) — frameless, always-on-top.
|
|
577
|
+
* Subject to the single-PiP-per-origin constraint enforced via
|
|
578
|
+
* `activePipWindowId`.
|
|
579
|
+
* - `"popup"`: `window.open()` fallback for browsers without DPiP support
|
|
580
|
+
* (Safari, Firefox). Shows browser chrome.
|
|
581
|
+
* - `null`: Window is docked inside the parent viewport (the default).
|
|
582
|
+
*/
|
|
583
|
+
type PopoutMode = "pip" | "popup" | null;
|
|
584
|
+
interface WindowEntry {
|
|
585
|
+
id: string;
|
|
586
|
+
title: string;
|
|
587
|
+
state: WindowState;
|
|
588
|
+
/** Last windowed size/position — restored when coming back from max/min */
|
|
589
|
+
windowed: WindowRect;
|
|
590
|
+
/** Saved rect before minimize so restore can return to the original size */
|
|
591
|
+
preMinimizedRect: WindowRect | null;
|
|
592
|
+
/** z-index order — higher = on top */
|
|
593
|
+
zIndex: number;
|
|
594
|
+
/** Order in the minimized tray (0-based). */
|
|
595
|
+
traySlot: number | null;
|
|
596
|
+
/**
|
|
597
|
+
* Pop-out mode. `null` while docked. When set, the window is rendered into
|
|
598
|
+
* a separate browser window via Document PiP or `window.open()` fallback.
|
|
599
|
+
* Never written to the local workspace cache — always reset on hydration
|
|
600
|
+
* (see `restoreWindowState`).
|
|
601
|
+
*/
|
|
602
|
+
popoutMode: PopoutMode;
|
|
603
|
+
/**
|
|
604
|
+
* Saved windowed rect at popout time. Restored to `windowed` on dock-back
|
|
605
|
+
* via `dockWindow`. `null` while docked (matches `preMinimizedRect` pattern).
|
|
606
|
+
*/
|
|
607
|
+
prePopoutRect: WindowRect | null;
|
|
608
|
+
/** Present only for registry entries explicitly approved for preservation. */
|
|
609
|
+
persistence?: WindowPersistenceState;
|
|
610
|
+
}
|
|
611
|
+
interface WindowManagerState {
|
|
612
|
+
windows: Record<string, WindowEntry>;
|
|
613
|
+
/** Validated sessions waiting for their WindowPanel registration. */
|
|
614
|
+
pendingRestores: Record<string, HydratedWindowSession>;
|
|
615
|
+
/** Next z-index to assign when a window is focused */
|
|
616
|
+
nextZIndex: number;
|
|
617
|
+
/** How many slots are currently occupied in the tray */
|
|
618
|
+
trayCount: number;
|
|
619
|
+
/** Last viewport used to place tray cards; enables safe reflow on removal. */
|
|
620
|
+
trayViewport: {
|
|
621
|
+
width: number;
|
|
622
|
+
height: number;
|
|
623
|
+
} | null;
|
|
624
|
+
/** Global show/hide toggle — windows stay mounted but are visually hidden */
|
|
625
|
+
windowsHidden: boolean;
|
|
626
|
+
/**
|
|
627
|
+
* The id of the window currently occupying the single Document PiP slot
|
|
628
|
+
* (Chromium allows only one DPiP window per origin at a time). `null` when
|
|
629
|
+
* the slot is free. Windows in `"popup"` mode do NOT count toward this slot.
|
|
630
|
+
*/
|
|
631
|
+
activePipWindowId: string | null;
|
|
632
|
+
/**
|
|
633
|
+
* The id of the window currently being dragged outside the viewport beyond
|
|
634
|
+
* the popout threshold. Used purely for visual feedback ("Release to pop
|
|
635
|
+
* out" outline + ghost label). Cleared on every `pointerup`.
|
|
636
|
+
*/
|
|
637
|
+
popoutCandidateId: string | null;
|
|
638
|
+
/**
|
|
639
|
+
* Z-index lane for LITE windows (`MatrxDynamicPanelHost presentation="floating"`).
|
|
640
|
+
*
|
|
641
|
+
* They are deliberately NOT entries in `windows`: a lite window is a
|
|
642
|
+
* transient form/picker host with no tray chip, no minimize and no
|
|
643
|
+
* persistence, so joining `windows` would put a half-typed create form into
|
|
644
|
+
* "minimize all" and the tray — the lost-work trap the lite window exists to
|
|
645
|
+
* avoid. Keeping them in their own map means every tray/minimize/arrange
|
|
646
|
+
* selector excludes them BY CONSTRUCTION rather than by a flag somebody must
|
|
647
|
+
* remember to filter on.
|
|
648
|
+
*
|
|
649
|
+
* They still draw from the SAME `nextZIndex` counter, so there is one
|
|
650
|
+
* z-order: a lite window opened from a WindowPanel always lands above it,
|
|
651
|
+
* and clicking the WindowPanel afterwards raises it above the lite window.
|
|
652
|
+
*/
|
|
653
|
+
transientZ: Record<string, number>;
|
|
654
|
+
}
|
|
655
|
+
declare const TRAY_CHIP_W = 240;
|
|
656
|
+
declare const TRAY_CHIP_H = 160;
|
|
657
|
+
declare const raiseTransientWindow: _reduxjs_toolkit.ActionCreatorWithPayload<string, "windowManager/raiseTransientWindow">;
|
|
658
|
+
declare const releaseTransientWindow: _reduxjs_toolkit.ActionCreatorWithPayload<string, "windowManager/releaseTransientWindow">;
|
|
659
|
+
declare const registerWindow: _reduxjs_toolkit.ActionCreatorWithPayload<{
|
|
660
|
+
id: string;
|
|
661
|
+
title?: string;
|
|
662
|
+
initial: WindowRect;
|
|
663
|
+
initialState?: "windowed" | "minimized";
|
|
664
|
+
persistence?: WindowPersistenceRegistration;
|
|
665
|
+
viewport?: {
|
|
666
|
+
width: number;
|
|
667
|
+
height: number;
|
|
668
|
+
};
|
|
669
|
+
}, "windowManager/registerWindow">;
|
|
670
|
+
declare const unregisterWindow: _reduxjs_toolkit.ActionCreatorWithPayload<string, "windowManager/unregisterWindow">;
|
|
671
|
+
declare const focusWindow: _reduxjs_toolkit.ActionCreatorWithPayload<string, "windowManager/focusWindow">;
|
|
672
|
+
declare const restoreWindow: _reduxjs_toolkit.ActionCreatorWithPayload<string, "windowManager/restoreWindow">;
|
|
673
|
+
declare const revealWindow: _reduxjs_toolkit.ActionCreatorWithPayload<{
|
|
674
|
+
id: string;
|
|
675
|
+
viewportWidth: number;
|
|
676
|
+
viewportHeight: number;
|
|
677
|
+
}, "windowManager/revealWindow">;
|
|
678
|
+
declare const maximizeWindow: _reduxjs_toolkit.ActionCreatorWithPayload<string, "windowManager/maximizeWindow">;
|
|
679
|
+
declare const minimizeWindow: _reduxjs_toolkit.ActionCreatorWithPayload<{
|
|
680
|
+
id: string;
|
|
681
|
+
viewportWidth: number;
|
|
682
|
+
viewportHeight: number;
|
|
683
|
+
}, "windowManager/minimizeWindow">;
|
|
684
|
+
declare const minimizeAll: _reduxjs_toolkit.ActionCreatorWithPayload<{
|
|
685
|
+
viewportWidth: number;
|
|
686
|
+
viewportHeight: number;
|
|
687
|
+
}, "windowManager/minimizeAll">;
|
|
688
|
+
declare const restoreAll: _reduxjs_toolkit.ActionCreatorWithoutPayload<"windowManager/restoreAll">;
|
|
689
|
+
declare const recomputeTrayPositions: _reduxjs_toolkit.ActionCreatorWithPayload<{
|
|
690
|
+
viewportWidth: number;
|
|
691
|
+
viewportHeight: number;
|
|
692
|
+
}, "windowManager/recomputeTrayPositions">;
|
|
693
|
+
declare const updateWindowRect: _reduxjs_toolkit.ActionCreatorWithPayload<{
|
|
694
|
+
id: string;
|
|
695
|
+
rect: Partial<WindowRect>;
|
|
696
|
+
}, "windowManager/updateWindowRect">;
|
|
697
|
+
declare const updateWindowTitle: _reduxjs_toolkit.ActionCreatorWithPayload<{
|
|
698
|
+
id: string;
|
|
699
|
+
title: string;
|
|
700
|
+
}, "windowManager/updateWindowTitle">;
|
|
701
|
+
declare const toggleWindowsHidden: _reduxjs_toolkit.ActionCreatorWithoutPayload<"windowManager/toggleWindowsHidden">;
|
|
702
|
+
declare const moveTraySlot: _reduxjs_toolkit.ActionCreatorWithPayload<{
|
|
703
|
+
id: string;
|
|
704
|
+
toSlot: number;
|
|
705
|
+
}, "windowManager/moveTraySlot">;
|
|
706
|
+
declare const arrangeActiveWindows: _reduxjs_toolkit.ActionCreatorWithPayload<{
|
|
707
|
+
layout: GlobalLayoutType;
|
|
708
|
+
viewportWidth: number;
|
|
709
|
+
viewportHeight: number;
|
|
710
|
+
dirX?: "ltr" | "rtl";
|
|
711
|
+
dirY?: "ttb" | "btt";
|
|
712
|
+
primary?: "horizontal" | "vertical";
|
|
713
|
+
}, "windowManager/arrangeActiveWindows">;
|
|
714
|
+
declare const popOutWindow: _reduxjs_toolkit.ActionCreatorWithPayload<{
|
|
715
|
+
id: string;
|
|
716
|
+
mode: "pip" | "popup";
|
|
717
|
+
}, "windowManager/popOutWindow">;
|
|
718
|
+
declare const dockWindow: _reduxjs_toolkit.ActionCreatorWithPayload<DockWindowPayload, "windowManager/dockWindow">;
|
|
719
|
+
declare const setPopoutCandidate: _reduxjs_toolkit.ActionCreatorWithPayload<{
|
|
720
|
+
id: string | null;
|
|
721
|
+
}, "windowManager/setPopoutCandidate">;
|
|
722
|
+
declare const clampWindowRect: _reduxjs_toolkit.ActionCreatorWithPayload<{
|
|
723
|
+
id: string;
|
|
724
|
+
viewportWidth: number;
|
|
725
|
+
viewportHeight: number;
|
|
726
|
+
}, "windowManager/clampWindowRect">;
|
|
727
|
+
declare const clampAllWindowRects: _reduxjs_toolkit.ActionCreatorWithPayload<{
|
|
728
|
+
viewportWidth: number;
|
|
729
|
+
viewportHeight: number;
|
|
730
|
+
}, "windowManager/clampAllWindowRects">;
|
|
731
|
+
declare const restoreWindowState: _reduxjs_toolkit.ActionCreatorWithPayload<Record<string, WindowEntry>, "windowManager/restoreWindowState">;
|
|
732
|
+
declare const hydrateWindowSessions: _reduxjs_toolkit.ActionCreatorWithPayload<{
|
|
733
|
+
sessions: HydratedWindowSession[];
|
|
734
|
+
viewportWidth: number;
|
|
735
|
+
viewportHeight: number;
|
|
736
|
+
}, "windowManager/hydrateWindowSessions">;
|
|
737
|
+
declare const confirmWindowRestored: _reduxjs_toolkit.ActionCreatorWithPayload<string, "windowManager/confirmWindowRestored">;
|
|
738
|
+
declare const discardPendingWindowSession: _reduxjs_toolkit.ActionCreatorWithPayload<string, "windowManager/discardPendingWindowSession">;
|
|
739
|
+
declare const updateWindowPersistence: _reduxjs_toolkit.ActionCreatorWithPayload<{
|
|
740
|
+
id: string;
|
|
741
|
+
data?: Record<string, unknown>;
|
|
742
|
+
sidebarOpen?: boolean;
|
|
743
|
+
sidebarSize?: number | null;
|
|
744
|
+
}, "windowManager/updateWindowPersistence">;
|
|
745
|
+
declare const markWindowClosing: _reduxjs_toolkit.ActionCreatorWithPayload<{
|
|
746
|
+
overlayId: string;
|
|
747
|
+
instanceId: string;
|
|
748
|
+
}, "windowManager/markWindowClosing">;
|
|
749
|
+
declare const clearWindowPersistenceState: _reduxjs_toolkit.ActionCreatorWithoutPayload<"windowManager/clearWindowPersistenceState">;
|
|
750
|
+
type StateWithWM = {
|
|
751
|
+
windowManager: WindowManagerState;
|
|
752
|
+
};
|
|
753
|
+
declare const selectPendingWindowRestores: (state: StateWithWM) => Record<string, HydratedWindowSession>;
|
|
754
|
+
declare const selectWindowPersistence: (id: string) => (state: StateWithWM) => WindowPersistenceState | undefined;
|
|
755
|
+
declare const selectWindow: (id: string) => (state: StateWithWM) => WindowEntry | undefined;
|
|
756
|
+
declare const selectWindowState: (id: string) => (state: StateWithWM) => WindowState | undefined;
|
|
757
|
+
declare const selectWindowRect: (id: string) => (state: StateWithWM) => WindowRect | undefined;
|
|
758
|
+
declare const selectWindowZIndex: (id: string) => (state: StateWithWM) => number;
|
|
759
|
+
/** z-index for a transient (lite) window; BASE_Z until it has been raised. */
|
|
760
|
+
declare const selectTransientZIndex: (id: string) => (state: StateWithWM) => number;
|
|
761
|
+
declare const selectWindowTitle: (id: string) => (state: StateWithWM) => string;
|
|
762
|
+
declare const selectTraySlotWidth: () => number;
|
|
763
|
+
declare const selectWindowsHidden: (state: StateWithWM) => boolean;
|
|
764
|
+
/**
|
|
765
|
+
* Minimized windows sorted by tray slot ascending.
|
|
766
|
+
* Memoized — only recalculates when the windows map reference changes.
|
|
767
|
+
*/
|
|
768
|
+
declare const selectTrayWindows: ((state: StateWithWM) => WindowEntry[]) & {
|
|
769
|
+
clearCache: () => void;
|
|
770
|
+
resultsCount: () => number;
|
|
771
|
+
resetResultsCount: () => void;
|
|
772
|
+
} & {
|
|
773
|
+
resultFunc: (resultFuncArgs_0: Record<string, WindowEntry>) => WindowEntry[];
|
|
774
|
+
memoizedResultFunc: ((resultFuncArgs_0: Record<string, WindowEntry>) => WindowEntry[]) & {
|
|
775
|
+
clearCache: () => void;
|
|
776
|
+
resultsCount: () => number;
|
|
777
|
+
resetResultsCount: () => void;
|
|
778
|
+
};
|
|
779
|
+
lastResult: () => WindowEntry[];
|
|
780
|
+
dependencies: [(state: StateWithWM) => Record<string, WindowEntry>];
|
|
781
|
+
recomputations: () => number;
|
|
782
|
+
resetRecomputations: () => void;
|
|
783
|
+
dependencyRecomputations: () => number;
|
|
784
|
+
resetDependencyRecomputations: () => void;
|
|
785
|
+
} & {
|
|
786
|
+
argsMemoize: typeof _reduxjs_toolkit.weakMapMemoize;
|
|
787
|
+
memoize: typeof _reduxjs_toolkit.weakMapMemoize;
|
|
788
|
+
};
|
|
789
|
+
/** All registered windows sorted by zIndex descending (most-recently-focused first). */
|
|
790
|
+
declare const selectAllWindows: ((state: StateWithWM) => WindowEntry[]) & {
|
|
791
|
+
clearCache: () => void;
|
|
792
|
+
resultsCount: () => number;
|
|
793
|
+
resetResultsCount: () => void;
|
|
794
|
+
} & {
|
|
795
|
+
resultFunc: (resultFuncArgs_0: Record<string, WindowEntry>) => WindowEntry[];
|
|
796
|
+
memoizedResultFunc: ((resultFuncArgs_0: Record<string, WindowEntry>) => WindowEntry[]) & {
|
|
797
|
+
clearCache: () => void;
|
|
798
|
+
resultsCount: () => number;
|
|
799
|
+
resetResultsCount: () => void;
|
|
800
|
+
};
|
|
801
|
+
lastResult: () => WindowEntry[];
|
|
802
|
+
dependencies: [(state: StateWithWM) => Record<string, WindowEntry>];
|
|
803
|
+
recomputations: () => number;
|
|
804
|
+
resetRecomputations: () => void;
|
|
805
|
+
dependencyRecomputations: () => number;
|
|
806
|
+
resetDependencyRecomputations: () => void;
|
|
807
|
+
} & {
|
|
808
|
+
argsMemoize: typeof _reduxjs_toolkit.weakMapMemoize;
|
|
809
|
+
memoize: typeof _reduxjs_toolkit.weakMapMemoize;
|
|
810
|
+
};
|
|
811
|
+
/** True when every registered window is minimized (or there are none). */
|
|
812
|
+
declare const selectAllMinimized: ((state: StateWithWM) => boolean) & {
|
|
813
|
+
clearCache: () => void;
|
|
814
|
+
resultsCount: () => number;
|
|
815
|
+
resetResultsCount: () => void;
|
|
816
|
+
} & {
|
|
817
|
+
resultFunc: (resultFuncArgs_0: Record<string, WindowEntry>) => boolean;
|
|
818
|
+
memoizedResultFunc: ((resultFuncArgs_0: Record<string, WindowEntry>) => boolean) & {
|
|
819
|
+
clearCache: () => void;
|
|
820
|
+
resultsCount: () => number;
|
|
821
|
+
resetResultsCount: () => void;
|
|
822
|
+
};
|
|
823
|
+
lastResult: () => boolean;
|
|
824
|
+
dependencies: [(state: StateWithWM) => Record<string, WindowEntry>];
|
|
825
|
+
recomputations: () => number;
|
|
826
|
+
resetRecomputations: () => void;
|
|
827
|
+
dependencyRecomputations: () => number;
|
|
828
|
+
resetDependencyRecomputations: () => void;
|
|
829
|
+
} & {
|
|
830
|
+
argsMemoize: typeof _reduxjs_toolkit.weakMapMemoize;
|
|
831
|
+
memoize: typeof _reduxjs_toolkit.weakMapMemoize;
|
|
832
|
+
};
|
|
833
|
+
/** Current popout mode for a window. Returns `null` if docked or unknown id. */
|
|
834
|
+
declare const selectPopoutMode: (id: string) => (state: StateWithWM) => "pip" | "popup" | null;
|
|
835
|
+
/** True if the window is currently popped out (either pip or popup mode). */
|
|
836
|
+
declare const selectIsPoppedOut: (id: string) => (state: StateWithWM) => boolean;
|
|
837
|
+
/** The id of the window holding the single Document PiP slot, or `null`. */
|
|
838
|
+
declare const selectActivePipWindowId: (state: StateWithWM) => string | null;
|
|
839
|
+
/**
|
|
840
|
+
* The id of the window currently being dragged outside the viewport beyond
|
|
841
|
+
* the popout threshold. Used by WindowPanel to render the "Release to pop
|
|
842
|
+
* out" outline.
|
|
843
|
+
*/
|
|
844
|
+
declare const selectPopoutCandidateId: (state: StateWithWM) => string | null;
|
|
845
|
+
/** Saved rect to dock back to. `null` while docked or after dock-back. */
|
|
846
|
+
declare const selectPrePopoutRect: (id: string) => (state: StateWithWM) => WindowRect | null;
|
|
847
|
+
/**
|
|
848
|
+
* All windows currently docked (popoutMode === null), sorted by zIndex
|
|
849
|
+
* descending. Used by arrange/tray logic so popped-out windows don't get
|
|
850
|
+
* assigned slots in parent-viewport layouts.
|
|
851
|
+
*/
|
|
852
|
+
declare const selectDockedWindows: ((state: StateWithWM) => WindowEntry[]) & {
|
|
853
|
+
clearCache: () => void;
|
|
854
|
+
resultsCount: () => number;
|
|
855
|
+
resetResultsCount: () => void;
|
|
856
|
+
} & {
|
|
857
|
+
resultFunc: (resultFuncArgs_0: Record<string, WindowEntry>) => WindowEntry[];
|
|
858
|
+
memoizedResultFunc: ((resultFuncArgs_0: Record<string, WindowEntry>) => WindowEntry[]) & {
|
|
859
|
+
clearCache: () => void;
|
|
860
|
+
resultsCount: () => number;
|
|
861
|
+
resetResultsCount: () => void;
|
|
862
|
+
};
|
|
863
|
+
lastResult: () => WindowEntry[];
|
|
864
|
+
dependencies: [(state: StateWithWM) => Record<string, WindowEntry>];
|
|
865
|
+
recomputations: () => number;
|
|
866
|
+
resetRecomputations: () => void;
|
|
867
|
+
dependencyRecomputations: () => number;
|
|
868
|
+
resetDependencyRecomputations: () => void;
|
|
869
|
+
} & {
|
|
870
|
+
argsMemoize: typeof _reduxjs_toolkit.weakMapMemoize;
|
|
871
|
+
memoize: typeof _reduxjs_toolkit.weakMapMemoize;
|
|
872
|
+
};
|
|
873
|
+
declare const windowManagerReducer: _reduxjs_toolkit.Reducer<WindowManagerState>;
|
|
874
|
+
|
|
875
|
+
interface UrlSyncEntry {
|
|
876
|
+
typeKey: string;
|
|
877
|
+
instanceId: string;
|
|
878
|
+
args?: Record<string, string>;
|
|
879
|
+
}
|
|
880
|
+
interface UrlSyncState {
|
|
881
|
+
/** Keyed by `${typeKey}:${instanceId}`. */
|
|
882
|
+
entries: Record<string, UrlSyncEntry>;
|
|
883
|
+
isHydrated: boolean;
|
|
884
|
+
}
|
|
885
|
+
declare const linksReducer: _reduxjs_toolkit.Reducer<UrlSyncState>;
|
|
886
|
+
declare const setHydrated: _reduxjs_toolkit.ActionCreatorWithoutPayload<"urlSync/setHydrated">;
|
|
887
|
+
declare const registerSyncEntry: _reduxjs_toolkit.ActionCreatorWithPayload<UrlSyncEntry, "urlSync/registerSyncEntry">;
|
|
888
|
+
declare const unregisterSyncEntry: _reduxjs_toolkit.ActionCreatorWithPayload<{
|
|
889
|
+
typeKey: string;
|
|
890
|
+
instanceId: string;
|
|
891
|
+
}, "urlSync/unregisterSyncEntry">;
|
|
892
|
+
type StateWithUrlSync = {
|
|
893
|
+
urlSync: UrlSyncState;
|
|
894
|
+
};
|
|
895
|
+
declare const selectUrlSyncEntries: (state: StateWithUrlSync) => Record<string, UrlSyncEntry>;
|
|
896
|
+
declare const selectIsUrlHydrated: (state: StateWithUrlSync) => boolean;
|
|
897
|
+
|
|
898
|
+
interface OverlayStateEntry {
|
|
899
|
+
values: Record<string, unknown>;
|
|
900
|
+
updatedAt: number;
|
|
901
|
+
}
|
|
902
|
+
interface OverlayStateState {
|
|
903
|
+
entries: Record<string, OverlayStateEntry>;
|
|
904
|
+
}
|
|
905
|
+
interface SetOverlayStateValuePayload {
|
|
906
|
+
key: InstanceKey;
|
|
907
|
+
name: string;
|
|
908
|
+
value: unknown;
|
|
909
|
+
}
|
|
910
|
+
interface ReplaceOverlayStatePayload {
|
|
911
|
+
key: InstanceKey;
|
|
912
|
+
values: Record<string, unknown>;
|
|
913
|
+
}
|
|
914
|
+
interface HydrateOverlayStatePayload {
|
|
915
|
+
/** Entries to load. Existing keys are replaced; others are left alone. */
|
|
916
|
+
entries: Record<string, {
|
|
917
|
+
values: Record<string, unknown>;
|
|
918
|
+
updatedAt?: number;
|
|
919
|
+
}>;
|
|
920
|
+
}
|
|
921
|
+
declare const overlayStateReducer: _reduxjs_toolkit.Reducer<OverlayStateState>;
|
|
922
|
+
declare const setOverlayStateValue: _reduxjs_toolkit.ActionCreatorWithPayload<SetOverlayStateValuePayload, "overlayState/setOverlayStateValue">;
|
|
923
|
+
declare const replaceOverlayState: _reduxjs_toolkit.ActionCreatorWithPayload<ReplaceOverlayStatePayload, "overlayState/replaceOverlayState">;
|
|
924
|
+
declare const clearOverlayState: _reduxjs_toolkit.ActionCreatorWithPayload<{
|
|
925
|
+
key: InstanceKey;
|
|
926
|
+
}, "overlayState/clearOverlayState">;
|
|
927
|
+
declare const hydrateOverlayState: _reduxjs_toolkit.ActionCreatorWithPayload<HydrateOverlayStatePayload, "overlayState/hydrateOverlayState">;
|
|
928
|
+
type StateWithOverlayState = {
|
|
929
|
+
overlayState: OverlayStateState;
|
|
930
|
+
};
|
|
931
|
+
/** One saved value, `undefined` when never set. */
|
|
932
|
+
declare const selectOverlayStateValue: (state: StateWithOverlayState, key: InstanceKey, name: string) => unknown;
|
|
933
|
+
/** Every saved value of an instance (stable empty object when none). */
|
|
934
|
+
declare const selectOverlayStateFor: (state: StateWithOverlayState, key: InstanceKey) => Readonly<Record<string, unknown>>;
|
|
935
|
+
|
|
936
|
+
/** The four overlays reducers at their canonical root keys. */
|
|
937
|
+
declare const summonReducers: {
|
|
938
|
+
overlays: Reducer<OverlayState>;
|
|
939
|
+
windowManager: Reducer<WindowManagerState>;
|
|
940
|
+
urlSync: Reducer<UrlSyncState>;
|
|
941
|
+
overlayState: Reducer<OverlayStateState>;
|
|
942
|
+
};
|
|
943
|
+
type SummonRootState = {
|
|
944
|
+
[K in keyof typeof summonReducers]: ReturnType<(typeof summonReducers)[K]>;
|
|
945
|
+
};
|
|
946
|
+
/** The overlays middleware, in order: close lifecycle, then the render watchdog. */
|
|
947
|
+
declare function createSummonMiddleware(ports?: Partial<SummonPorts>): Middleware[];
|
|
948
|
+
interface CreateOverlaysStoreOptions {
|
|
949
|
+
ports?: Partial<SummonPorts>;
|
|
950
|
+
preloadedState?: Partial<SummonRootState>;
|
|
951
|
+
/** More reducers mounted beside the overlays keys (a small host that wants one store). */
|
|
952
|
+
extraReducers?: Record<string, Reducer>;
|
|
953
|
+
}
|
|
954
|
+
/** A store holding the overlays slices and middleware. */
|
|
955
|
+
declare function createSummonStore(options?: CreateOverlaysStoreOptions): _reduxjs_toolkit.EnhancedStore<SummonRootState, UnknownAction, _reduxjs_toolkit.Tuple<[_reduxjs_toolkit.StoreEnhancer<{
|
|
956
|
+
dispatch: _reduxjs_toolkit.ThunkDispatch<SummonRootState, undefined, UnknownAction>;
|
|
957
|
+
}>, _reduxjs_toolkit.StoreEnhancer]>>;
|
|
958
|
+
type SummonStore = ReturnType<typeof createSummonStore>;
|
|
959
|
+
type SummonDispatch = SummonStore["dispatch"];
|
|
960
|
+
|
|
961
|
+
/**
|
|
962
|
+
* Close lifecycle — what happens, in one place, when an overlay instance closes:
|
|
963
|
+
*
|
|
964
|
+
* 1. Window preservation identities are tombstoned (`markWindowClosing`) so no later snapshot or
|
|
965
|
+
* unmount path re-saves a window the person closed (ported from matrx-frontend
|
|
966
|
+
* `features/window-panels/persistence/windowPersistenceCloseMiddleware.ts`).
|
|
967
|
+
* 2. Every handle owned by the closed instance (`overlayId:instanceId`) is disposed — pending
|
|
968
|
+
* requests reject, channels drop their subscribers — so no opener disposes by hand.
|
|
969
|
+
* 3. The instance's `overlayState` is cleared, unless its definition says `keepAlive:
|
|
970
|
+
* "restore"` (values come back on reopen). `keepAlive: "hidden"` instances stay mounted, so
|
|
971
|
+
* they keep both their handles and their state until the React host evicts them
|
|
972
|
+
* (`releaseOverlayInstance`).
|
|
973
|
+
* 4. Registered close flushers run (the persistence section writes the post-close workspace).
|
|
974
|
+
*
|
|
975
|
+
* Close actions: closeOverlay, toggleOverlay (when it closed), closeAllOverlays,
|
|
976
|
+
* closeAllInstancesOfOverlay, closeOverlaysBoundToPage. Closed instances are found by diffing the
|
|
977
|
+
* open set before and after the reducer, so every path is covered the same way.
|
|
978
|
+
*/
|
|
979
|
+
|
|
980
|
+
interface CloseIdentity {
|
|
981
|
+
overlayId: string;
|
|
982
|
+
instanceId: string;
|
|
983
|
+
}
|
|
984
|
+
/** What a close meant, for persistence: one exact instance, every instance of an id, or all. */
|
|
985
|
+
type WindowCloseIntent = ({
|
|
986
|
+
scope: "exact";
|
|
987
|
+
} & CloseIdentity) | {
|
|
988
|
+
scope: "overlay";
|
|
989
|
+
overlayId: string;
|
|
990
|
+
} | {
|
|
991
|
+
scope: "all";
|
|
992
|
+
};
|
|
993
|
+
interface CloseEvent {
|
|
994
|
+
/** The intent(s) behind this close (empty when only a page-bound or toggle path closed). */
|
|
995
|
+
readonly intents: readonly WindowCloseIntent[];
|
|
996
|
+
/** Every instance that went from open to closed in this action. */
|
|
997
|
+
readonly closedKeys: readonly InstanceKey[];
|
|
998
|
+
/** The dispatched action's type. */
|
|
999
|
+
readonly actionType: string;
|
|
1000
|
+
}
|
|
1001
|
+
type CloseFlusher = (event: CloseEvent) => void;
|
|
1002
|
+
/**
|
|
1003
|
+
* Run `flush` synchronously after every close, once tombstones and disposal are done. Replaces the
|
|
1004
|
+
* app's `registerWindowPersistenceFlusher`; any number may be registered. Returns the unregister.
|
|
1005
|
+
*/
|
|
1006
|
+
declare function registerCloseFlusher(flush: CloseFlusher): () => void;
|
|
1007
|
+
type CloseRootState = StateWithOverlays & Partial<StateWithOverlayState> & {
|
|
1008
|
+
windowManager?: WindowManagerState;
|
|
1009
|
+
};
|
|
1010
|
+
/**
|
|
1011
|
+
* Release an instance's handles and saved state now (the React host calls this when it evicts a
|
|
1012
|
+
* kept-alive hidden instance). `keepState` keeps `overlayState` (keepAlive "restore").
|
|
1013
|
+
*/
|
|
1014
|
+
declare function releaseOverlayInstance(dispatch: (action: UnknownAction) => unknown, key: InstanceKey, options?: {
|
|
1015
|
+
keepState?: boolean;
|
|
1016
|
+
}): void;
|
|
1017
|
+
/** The close-lifecycle middleware (framework-free; one per overlays store). */
|
|
1018
|
+
declare const closeLifecycleMiddleware: Middleware<object, CloseRootState>;
|
|
1019
|
+
|
|
1020
|
+
/**
|
|
1021
|
+
* overlayRenderWatchdog
|
|
1022
|
+
*
|
|
1023
|
+
* Makes "a panel was triggered but silently never appeared" structurally
|
|
1024
|
+
* impossible to ship unnoticed. Two responsibilities, one middleware:
|
|
1025
|
+
*
|
|
1026
|
+
* 1. REVEAL — on every open of a window-kind overlay, dispatch `revealWindow`
|
|
1027
|
+
* so an already-registered window that is minimized, dragged off-screen, or
|
|
1028
|
+
* suppressed by the global hide-all is brought back into view. Re-opening a
|
|
1029
|
+
* window must never be a silent no-op.
|
|
1030
|
+
*
|
|
1031
|
+
* 2. DETECT — after the open, inspect actual Redux + viewport state and
|
|
1032
|
+
* confirm a *visible* panel is on screen. If not, SCREAM (console.error)
|
|
1033
|
+
* and surface a self-healing toast. This is the loud recovery layer
|
|
1034
|
+
* mandated by CLAUDE.md: a recovery firing means a real bug got past the
|
|
1035
|
+
* proactive layer.
|
|
1036
|
+
*
|
|
1037
|
+
* The one state a fixed timer cannot distinguish is "lazy chunk still loading"
|
|
1038
|
+
* vs "never mounted" — every window component enters through `next/dynamic`,
|
|
1039
|
+
* and a cold dev compile (or a slow network fetch in prod) can take far longer
|
|
1040
|
+
* than any polite delay. The watchdog therefore treats the WindowPanel mount
|
|
1041
|
+
* acknowledgement (`ackOverlayRender`, called from WindowPanel's mount effect,
|
|
1042
|
+
* i.e. strictly after the dynamic import settled) as the chunk-settle signal:
|
|
1043
|
+
* while no ack exists it WAITS for one (bounded by a hard no-mount deadline)
|
|
1044
|
+
* instead of screaming, and diagnoses geometry only once the ack arrives. A
|
|
1045
|
+
* false scream trains people to ignore the real ones.
|
|
1046
|
+
*
|
|
1047
|
+
* If a scream does fire and the panel becomes visible afterwards anyway, the
|
|
1048
|
+
* toast is auto-dismissed and a recovery note is logged — the loud layer never
|
|
1049
|
+
* lingers past the failure it reported.
|
|
1050
|
+
*
|
|
1051
|
+
* The detector is intentionally scoped to SINGLETON window-kind overlays — the
|
|
1052
|
+
* surfaces that render through `WindowPanel` and join the window manager. Non-
|
|
1053
|
+
* window overlays (dialogs/sheets/toasts) don't register geometry and would
|
|
1054
|
+
* false-positive, so they're skipped. Multi-instance windows carry per-instance
|
|
1055
|
+
* ids we don't track here and are skipped too.
|
|
1056
|
+
*
|
|
1057
|
+
* The pure decision (`diagnoseOverlayRender`) is exported separately so it can
|
|
1058
|
+
* be unit-tested without a store, a DOM, or timers.
|
|
1059
|
+
*
|
|
1060
|
+
* Ported from matrx-frontend `features/window-panels/diagnostics/overlayRenderWatchdog.ts`.
|
|
1061
|
+
* Seams inverted: toast → `ports.notify`, the console scream → `ports.errors`, the window
|
|
1062
|
+
* metadata lookup → the core definition registry (`meta.window` = window kind, `meta.instance`,
|
|
1063
|
+
* `defaultWindowIdFor(meta)` = the old registry slug). Ack/waiter/watch maps live in a global
|
|
1064
|
+
* slot instead of module scope. The middleware is a factory over ports.
|
|
1065
|
+
*/
|
|
1066
|
+
|
|
1067
|
+
/**
|
|
1068
|
+
* Hard ceiling on waiting for a lazily mounted window: one constant for every subsystem that
|
|
1069
|
+
* waits on that physical event (the link manager waits on the same one).
|
|
1070
|
+
*/
|
|
1071
|
+
declare const LAZY_WINDOW_MOUNT_DEADLINE_MS: number;
|
|
1072
|
+
declare const RENDER_WATCHDOG_SLOT = "ai-matrx.summon.renderWatchdog";
|
|
1073
|
+
declare function ackOverlayRender(overlayId: string, windowId: string): void;
|
|
1074
|
+
declare function clearOverlayRender(overlayId: string, windowId: string): void;
|
|
1075
|
+
declare function ackOverlaySurfaceRender(overlayId: string): void;
|
|
1076
|
+
declare function clearOverlaySurfaceRender(overlayId: string): void;
|
|
1077
|
+
type RenderFailureReason = "no-window-registered" | "all-windows-hidden" | "zero-size" | "off-screen";
|
|
1078
|
+
type RenderDiagnosis = {
|
|
1079
|
+
ok: true;
|
|
1080
|
+
reason: null;
|
|
1081
|
+
} | {
|
|
1082
|
+
ok: false;
|
|
1083
|
+
reason: RenderFailureReason;
|
|
1084
|
+
};
|
|
1085
|
+
/** A window counts as on-screen if a usable strip of it intersects the
|
|
1086
|
+
* viewport (matches the spirit of `clampRectToViewport`'s safe margin). */
|
|
1087
|
+
declare function rectOnScreen(rect: WindowRect, viewportWidth: number, viewportHeight: number): boolean;
|
|
1088
|
+
/**
|
|
1089
|
+
* Given the window's geometry entry and global state, decide whether a visible
|
|
1090
|
+
* panel is actually on screen. Pure — no store, DOM, or timers.
|
|
1091
|
+
*/
|
|
1092
|
+
declare function diagnoseOverlayRender(args: {
|
|
1093
|
+
entry: WindowEntry | undefined;
|
|
1094
|
+
windowsHidden: boolean;
|
|
1095
|
+
viewportWidth: number;
|
|
1096
|
+
viewportHeight: number;
|
|
1097
|
+
surfaceAcknowledged?: boolean;
|
|
1098
|
+
}): RenderDiagnosis;
|
|
1099
|
+
type WMState = {
|
|
1100
|
+
overlays: OverlayState;
|
|
1101
|
+
windowManager: WindowManagerState;
|
|
1102
|
+
};
|
|
1103
|
+
type WatchdogPorts = Pick<SummonPorts, "notify" | "errors">;
|
|
1104
|
+
/**
|
|
1105
|
+
* Does the watchdog verify this open? Only SINGLETON window-kind overlays: a
|
|
1106
|
+
* multi-instance window renders under a per-instance window id
|
|
1107
|
+
* (`transcription-cleanup-<instanceId>`) that is never the registry slug and
|
|
1108
|
+
* never acks under the overlay id — so watching it, even when it was opened on
|
|
1109
|
+
* the "default" instance (the Tools grid / URL hydration open that way), can
|
|
1110
|
+
* only end in a false "didn't appear" toast over a window that is on screen.
|
|
1111
|
+
*/
|
|
1112
|
+
declare function watchdogTracksOpen(meta: Pick<OverlayDefinitionMeta, "window" | "instance"> | undefined, instanceId: string): boolean;
|
|
1113
|
+
/** The render watchdog for a store whose host supplied `ports` (notify + error sink). */
|
|
1114
|
+
declare function createOverlayRenderWatchdogMiddleware(ports: WatchdogPorts): Middleware<object, WMState>;
|
|
1115
|
+
/** Test-only: cancel every in-flight watch and forget all acks. */
|
|
1116
|
+
declare function resetOverlayRenderWatchdog(): void;
|
|
1117
|
+
|
|
1118
|
+
/**
|
|
1119
|
+
* rectClamp — viewport-safe geometry restoration.
|
|
1120
|
+
*
|
|
1121
|
+
* When hydrating window geometry from the DB (or the legacy localStorage
|
|
1122
|
+
* migration), a rect saved at a larger viewport size or on a different
|
|
1123
|
+
* device can land partially or entirely off-screen. This utility clamps
|
|
1124
|
+
* stored rects into a sensible shape for the current viewport:
|
|
1125
|
+
*
|
|
1126
|
+
* - Width/height capped to viewport minus safe margins.
|
|
1127
|
+
* - Position nudged into bounds so the complete usable window stays visible.
|
|
1128
|
+
* - If the stored rect is entirely nonsensical (e.g. width 0, negative
|
|
1129
|
+
* coords with huge values), fall back to a centered default.
|
|
1130
|
+
*/
|
|
1131
|
+
interface WindowRectLike {
|
|
1132
|
+
x: number;
|
|
1133
|
+
y: number;
|
|
1134
|
+
width: number;
|
|
1135
|
+
height: number;
|
|
1136
|
+
}
|
|
1137
|
+
interface ViewportDims {
|
|
1138
|
+
vw: number;
|
|
1139
|
+
vh: number;
|
|
1140
|
+
/**
|
|
1141
|
+
* True when the measurement was unusable (0, negative, non-finite, or SSR)
|
|
1142
|
+
* and `vw`/`vh` are invented fallbacks rather than a real screen.
|
|
1143
|
+
*
|
|
1144
|
+
* **Anything that WRITES geometry state from a viewport read must check this
|
|
1145
|
+
* and bail without writing.** Inventing 1280×800 is right for "give me
|
|
1146
|
+
* something to render against"; it is wrong for "persist this as the user's
|
|
1147
|
+
* geometry", because the invented value then has to be undone by the next
|
|
1148
|
+
* real measurement — and a write per measurement is how a
|
|
1149
|
+
* measure → write → re-measure cycle starts.
|
|
1150
|
+
*/
|
|
1151
|
+
degenerate: boolean;
|
|
1152
|
+
}
|
|
1153
|
+
/**
|
|
1154
|
+
* Viewport dimensions that are safe to derive or judge window geometry from.
|
|
1155
|
+
*
|
|
1156
|
+
* `window.innerWidth/innerHeight` can measure 0 (hidden or prerendered page,
|
|
1157
|
+
* a background/undisplayed tab, pre-layout read, headless run). Deriving an
|
|
1158
|
+
* initial rect from that turns "90vw" into width 0 — the window registers a
|
|
1159
|
+
* 0×0 rect, renders as nothing, and stays invisible until something
|
|
1160
|
+
* re-clamps it (the "window opens invisible" class, watchdog reason:
|
|
1161
|
+
* zero-size). Judging on-screen position against a 0×0 viewport is just as wrong:
|
|
1162
|
+
* every on-screen rect reads as off-screen. A degenerate measurement is never
|
|
1163
|
+
* a real screen — fall back to sane dimensions, warn once, and tell the
|
|
1164
|
+
* caller so writers can stand down (`degenerate`).
|
|
1165
|
+
*/
|
|
1166
|
+
declare function safeViewportDims(): ViewportDims;
|
|
1167
|
+
/**
|
|
1168
|
+
* Clamp a rect into the current viewport. Pure — caller passes both the
|
|
1169
|
+
* rect and the viewport so this works in tests without DOM globals.
|
|
1170
|
+
*
|
|
1171
|
+
* A zero/negative viewport is a degenerate MEASUREMENT (hidden or embedded
|
|
1172
|
+
* pane, pre-layout read, headless run) — never a real screen. Clamping
|
|
1173
|
+
* against it collapses any rect to `{x:-48, y:0, width:120, height:80}` and
|
|
1174
|
+
* that garbage then gets rendered and persisted, so instead we keep the
|
|
1175
|
+
* caller's geometry (sanitising only non-finite values) and scream once.
|
|
1176
|
+
*
|
|
1177
|
+
* @param rect Stored rect from DB / LS.
|
|
1178
|
+
* @param viewport { width, height } in CSS pixels.
|
|
1179
|
+
*/
|
|
1180
|
+
declare function clampRectToViewport(rect: WindowRectLike, viewport: {
|
|
1181
|
+
width: number;
|
|
1182
|
+
height: number;
|
|
1183
|
+
}): WindowRectLike;
|
|
1184
|
+
/**
|
|
1185
|
+
* Center a rect in the viewport, preserving (clamped) width/height.
|
|
1186
|
+
* Used when docking a popped-out window back into the parent page.
|
|
1187
|
+
*/
|
|
1188
|
+
declare function centerRectInViewport(rect: WindowRectLike, viewport: {
|
|
1189
|
+
width: number;
|
|
1190
|
+
height: number;
|
|
1191
|
+
}): WindowRectLike;
|
|
1192
|
+
/**
|
|
1193
|
+
* Convenience wrapper that reads the current window dimensions. Only safe
|
|
1194
|
+
* to call on the client.
|
|
1195
|
+
*/
|
|
1196
|
+
declare function clampRectToCurrentViewport(rect: WindowRectLike): WindowRectLike;
|
|
1197
|
+
/** Exact rect equality. Used to skip no-op geometry writes. */
|
|
1198
|
+
declare function rectsEqual(a: WindowRectLike, b: WindowRectLike): boolean;
|
|
1199
|
+
|
|
1200
|
+
/**
|
|
1201
|
+
* Tray layout constants.
|
|
1202
|
+
*
|
|
1203
|
+
* Hardcoded previously inside `windowManagerSlice.ts` and `WindowTray.tsx`.
|
|
1204
|
+
* Centralised here so the mobile-responsive sizing path can derive chip
|
|
1205
|
+
* dimensions from a single source.
|
|
1206
|
+
*
|
|
1207
|
+
* Note: `windowManagerSlice` re-exports `TRAY_CHIP_W` and `TRAY_CHIP_H` for
|
|
1208
|
+
* backward compatibility — external consumers should still import from here
|
|
1209
|
+
* going forward.
|
|
1210
|
+
*/
|
|
1211
|
+
/** Desktop minimized-card width in px. */
|
|
1212
|
+
declare const TRAY_CHIP_W_DESKTOP = 240;
|
|
1213
|
+
/** Desktop minimized-card height in px. */
|
|
1214
|
+
declare const TRAY_CHIP_H_DESKTOP = 160;
|
|
1215
|
+
/** Horizontal gap between chips. */
|
|
1216
|
+
declare const TRAY_GAP_X = 8;
|
|
1217
|
+
/** Vertical gap between rows of chips. */
|
|
1218
|
+
declare const TRAY_GAP_Y = 8;
|
|
1219
|
+
/** Gap from the right viewport edge. */
|
|
1220
|
+
declare const TRAY_MARGIN_R = 20;
|
|
1221
|
+
/** Gap from the bottom viewport edge. */
|
|
1222
|
+
declare const TRAY_MARGIN_B = 20;
|
|
1223
|
+
/** Left boundary: cards never flow farther left than this. */
|
|
1224
|
+
declare const TRAY_MARGIN_L = 8;
|
|
1225
|
+
/** Header-only height used when full cards no longer fit in the viewport. */
|
|
1226
|
+
declare const TRAY_COMPACT_H = 32;
|
|
1227
|
+
/** Tighter gap for the overflow overview grid. */
|
|
1228
|
+
declare const TRAY_COMPACT_GAP = 4;
|
|
1229
|
+
/**
|
|
1230
|
+
* Mobile chip width target. The tray becomes a horizontal-scroll strip on
|
|
1231
|
+
* mobile, so the width is a target upper bound clamped against the viewport.
|
|
1232
|
+
*/
|
|
1233
|
+
declare const TRAY_CHIP_W_MOBILE_MAX = 180;
|
|
1234
|
+
/** Mobile chip height — slightly shorter to fit tight screens. */
|
|
1235
|
+
declare const TRAY_CHIP_H_MOBILE = 72;
|
|
1236
|
+
/** Viewport width below which the mobile tray layout takes over. */
|
|
1237
|
+
declare const TRAY_MOBILE_BREAKPOINT = 768;
|
|
1238
|
+
/**
|
|
1239
|
+
* Compute the chip width for a given viewport. On mobile, fits ~2 chips
|
|
1240
|
+
* across with safe-area padding; never exceeds the desktop size on wider
|
|
1241
|
+
* screens.
|
|
1242
|
+
*/
|
|
1243
|
+
declare function computeTrayChipWidth(viewportWidth: number): number;
|
|
1244
|
+
/** Chip height for a given viewport. */
|
|
1245
|
+
declare function computeTrayChipHeight(viewportWidth: number): number;
|
|
1246
|
+
/** Number of cards that fit in a tray row at the current viewport width. */
|
|
1247
|
+
declare function trayChipsPerRow(viewportWidth: number): number;
|
|
1248
|
+
/**
|
|
1249
|
+
* Compute the visual rectangle for a tray slot. Slot zero starts at the
|
|
1250
|
+
* bottom-right; later slots grow left, then wrap upward into additional rows.
|
|
1251
|
+
*/
|
|
1252
|
+
declare function traySlotRect(slot: number, viewportWidth: number, viewportHeight: number, totalSlots?: number): {
|
|
1253
|
+
x: number;
|
|
1254
|
+
y: number;
|
|
1255
|
+
width: number;
|
|
1256
|
+
height: number;
|
|
1257
|
+
};
|
|
1258
|
+
|
|
1259
|
+
export { type AnyOverlayMeta, type CloseAllInstancesPayload, type CloseEvent, type CloseFlusher, type CloseOverlayPayload, type CloseOverlaysBoundToPagePayload, type CreateOverlaysStoreOptions, DEFAULT_INSTANCE_ID, DEFAULT_PORTS, type DebugPort, type DockWindowPayload, type ErrorSinkPort, type GlobalLayoutType, type HydrateOverlayStatePayload, type HydratedWindowSession, type IdentityPort, type InstanceKey, type InstanceMode, type KeepAlive, LAZY_WINDOW_MOUNT_DEADLINE_MS, type LinkHydrateContext, type MobilePresentation, type NotifyOptions, type NotifyPort, type OpenInstanceView, type OpenOverlayPayload, type OverlayDataOf, type OverlayDefinitionMeta, type OverlayHostDispatch, type OverlayHostTypes, type OverlayId, type OverlayInstance, type OverlayLinkSpec, type OverlayPersistencePort, type OverlayRawData, type OverlayRegistry, type OverlayState, type OverlayStateEntry, type OverlayStateState, type OverlayWindowOptions, type PersistedWindowSession, type PopoutMode, type PruneStaleInstancesPayload, RENDER_WATCHDOG_SLOT, type RenderDiagnosis, type RenderFailureReason, type ReplaceOverlayStatePayload, type RouterPort, type SetOverlayStateValuePayload, type StateWithOverlayState, type StateWithOverlays, type StateWithUrlSync, type StoredValue, type SummonDispatch, type SummonPorts, type SummonRootState, type SummonStore, TRAY_CHIP_H, TRAY_CHIP_H_DESKTOP, TRAY_CHIP_H_MOBILE, TRAY_CHIP_W, TRAY_CHIP_W_DESKTOP, TRAY_CHIP_W_MOBILE_MAX, TRAY_COMPACT_GAP, TRAY_COMPACT_H, TRAY_GAP_X, TRAY_GAP_Y, TRAY_MARGIN_B, TRAY_MARGIN_L, TRAY_MARGIN_R, TRAY_MOBILE_BREAKPOINT, type ToggleOverlayPayload, type UnbiddenHomeRoute, type Unsubscribe, type UrlSyncEntry, type UrlSyncState, type ViewportDims, WINDOW_SESSION_SCHEMA_VERSION, type WindowCloseIntent, type WindowEntry, type WindowManagerState, type WindowPersistenceRegistration, type WindowPersistenceState, type WindowPreservation, type WindowRect, type WindowRectLike, type WindowState, ackOverlayRender, ackOverlaySurfaceRender, allOverlayMeta, anonymousIdentity, arrangeActiveWindows, buildDockWindowPayload, centerRectInViewport, clampAllWindowRects, clampRectToCurrentViewport, clampRectToViewport, clampWindowRect, clearOverlayRender, clearOverlayState, clearOverlaySurfaceRender, clearWindowPersistenceState, closeAllInstancesOfOverlay, closeAllOverlays, closeLifecycleMiddleware, closeOverlay, closeOverlaysBoundToPage, computeGlobalArrangement, computeTrayChipHeight, computeTrayChipWidth, confirmWindowRestored, consoleErrorSink, consoleNotify, createOverlayRenderWatchdogMiddleware, createSummonMiddleware, createSummonStore, debugOff, defaultWindowIdFor, diagnoseOverlayRender, discardPendingWindowSession, dockWindow, focusWindow, getGrid12Rect, getGrid4Rect, getGrid6Rect, getGrid8Rect, getGrid9Rect, getOverlayMeta, getOverlayMetaByLinkKey, getStackedLeft2Rect, getStackedLeft3Rect, getStackedLeft4Rect, getStackedLeft5Rect, getStackedRight2Rect, getStackedRight3Rect, getStackedRight4Rect, getStackedRight5Rect, hydrateOverlayState, hydrateWindowSessions, instanceKey, isRegisteredOverlay, linksReducer, listOpenInstanceKeys, locationRouter, markWindowClosing, maximizeWindow, minimizeAll, minimizeWindow, moveTraySlot, openOverlay, overlayIdsBoundToPage, overlayStateReducer, overlaysRawActions, overlaysReducer, parseInstanceKey, popOutWindow, pruneStaleInstances, raiseTransientWindow, recomputeTrayPositions, rectOnScreen, rectsEqual, registerCloseFlusher, registerOverlayMeta, registerSyncEntry, registerWindow, releaseOverlayInstance, releaseTransientWindow, replaceOverlayState, resetOverlayRegistry, resetOverlayRenderWatchdog, resolvePorts, restoreAll, restoreWindow, restoreWindowState, revealWindow, safeViewportDims, selectActivePipWindowId, selectAllMinimized, selectAllWindows, selectDockedWindows, selectIsOverlayOpen, selectIsPoppedOut, selectIsUrlHydrated, selectOpenInstances, selectOverlay, selectOverlayData, selectOverlayStateFor, selectOverlayStateValue, selectPendingWindowRestores, selectPopoutCandidateId, selectPopoutMode, selectPrePopoutRect, selectTransientZIndex, selectTraySlotWidth, selectTrayWindows, selectUrlSyncEntries, selectWindow, selectWindowPersistence, selectWindowRect, selectWindowState, selectWindowTitle, selectWindowZIndex, selectWindowsHidden, setHydrated, setOverlayStateValue, setPopoutCandidate, subscribeToOverlayRegistry, summonReducers, toggleOverlay, toggleWindowsHidden, trayChipsPerRow, traySlotRect, unregisterSyncEntry, unregisterWindow, updateWindowPersistence, updateWindowRect, updateWindowTitle, watchdogTracksOpen, windowManagerReducer, windowSessionKey };
|