@ai-matrx/summon 0.1.13 → 0.1.15
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 +16 -0
- package/dist/define.cjs +123 -0
- package/dist/define.cjs.map +1 -0
- package/dist/define.d.cts +79 -0
- package/dist/define.d.ts +79 -0
- package/dist/define.js +114 -0
- package/dist/define.js.map +1 -0
- package/dist/{gate-1c08vnzx.d.cts → gate-BalZq3nu.d.cts} +1 -1
- package/dist/{gate-1c08vnzx.d.ts → gate-BalZq3nu.d.ts} +1 -1
- package/dist/handles.cjs +3 -1
- package/dist/handles.cjs.map +1 -1
- package/dist/handles.d.cts +4 -1
- package/dist/handles.d.ts +4 -1
- package/dist/handles.js +3 -1
- package/dist/handles.js.map +1 -1
- package/dist/index.cjs +3 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/open.cjs +33 -0
- package/dist/open.cjs.map +1 -1
- package/dist/open.d.cts +45 -2
- package/dist/open.d.ts +45 -2
- package/dist/open.js +33 -0
- package/dist/open.js.map +1 -1
- package/dist/react.cjs +8 -8
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +2 -1
- package/dist/react.d.ts +2 -1
- package/dist/react.js +1 -1
- package/dist/react.js.map +1 -1
- package/dist/root.cjs +27 -125
- package/dist/root.cjs.map +1 -1
- package/dist/root.d.cts +4 -76
- package/dist/root.d.ts +4 -76
- package/dist/root.js +18 -121
- package/dist/root.js.map +1 -1
- package/dist/url.cjs +7 -23
- package/dist/url.cjs.map +1 -1
- package/dist/url.d.cts +3 -37
- package/dist/url.d.ts +3 -37
- package/dist/url.js +4 -20
- package/dist/url.js.map +1 -1
- package/package.json +13 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
### Unreleased
|
|
4
|
+
|
|
5
|
+
- **`defineOverlay` moves to its own entry, `@ai-matrx/summon/define`** (breaking: `./root` no longer exports it or `CALLBACK_GROUP_KEY`; the types stay on `./root`). Why: a bundler keeps every export of a module that anything uses, and each entry is one module — definitions are read only by a host's lazy registry, yet `defineOverlay` sat in `./root` and rode into every route's first load. Consumer action: import `defineOverlay` from `@ai-matrx/summon/define`, only in definition modules (never in a file callers import for its openers).
|
|
6
|
+
- **`peekHandle(id)` on `./open`**: `callbackManager.get(id)` without loading the handles registry (it reads the registry's global slot; `undefined` until something registers). For boot-time code that only resolves ids. Guard: `src/open/peek.test.ts`.
|
|
7
|
+
- **The `?panels=` grammar's READ side moves to `./url`** (`parseLinkToken`, `parseLinkParam`, `decodeLinkPart`, `readPanelsParam`, `withPanelsParam`); `./open` keeps the WRITE side (`formatLinkToken`, `encodeLinkId`, `encodeLinkArg`, `LinkToken`, `LinkEntry`). Parsing happens only in the lazy link runtime. Consumer action: import parsers from `@ai-matrx/summon/url`. Guard: `src/importCost.test.ts` ("first-load entries export nothing only the lazy runtime needs").
|
|
8
|
+
|
|
9
|
+
## 0.1.15
|
|
10
|
+
|
|
11
|
+
UNVERIFIED: this release has no Unreleased entry and the source comparison could not be made (the caller supplied no source comparison). Whether source changed is unknown; consumer action is unknown.
|
|
12
|
+
Check the package's gitHead on npm against this version's gitHead: `git diff <previous gitHead> <this gitHead> -- apps/shared/summon/src`.
|
|
13
|
+
|
|
14
|
+
## 0.1.14
|
|
15
|
+
### Unreleased
|
|
16
|
+
|
|
17
|
+
- **The `?panels=` grammar is on `./open`** (`formatLinkToken`, `parseLinkParam`, `withPanelsParam`, … — pure string functions; `./url` re-exports them). Why: `./url` reaches the core and the react section, so chat building an agent-variable link put the whole runtime in every AI Matrx route's first load. Consumer action: none; import the grammar from `./open`.
|
|
18
|
+
|
|
3
19
|
## 0.1.13
|
|
4
20
|
### Unreleased
|
|
5
21
|
|
package/dist/define.cjs
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/define.ts
|
|
22
|
+
var define_exports = {};
|
|
23
|
+
__export(define_exports, {
|
|
24
|
+
CALLBACK_GROUP_KEY: () => CALLBACK_GROUP_KEY,
|
|
25
|
+
defineOverlay: () => defineOverlay
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(define_exports);
|
|
28
|
+
|
|
29
|
+
// src/define/defineOverlay.tsx
|
|
30
|
+
var import_react = require("react");
|
|
31
|
+
var import_open = require("@ai-matrx/summon/open");
|
|
32
|
+
var import_root = require("@ai-matrx/summon/root");
|
|
33
|
+
function openOverlayEventChannel(owner, getHandlers) {
|
|
34
|
+
return (0, import_open.openPendingEventChannel)(owner, getHandlers);
|
|
35
|
+
}
|
|
36
|
+
var CALLBACK_GROUP_KEY = "callbackGroupId";
|
|
37
|
+
function openWith(dispatch, id, multi, options) {
|
|
38
|
+
const instanceId = options?.instanceId ?? (multi ? (0, import_root.newInstanceId)(id) : import_open.DEFAULT_INSTANCE_ID);
|
|
39
|
+
const key = (0, import_open.instanceKey)(id, instanceId);
|
|
40
|
+
const data = {};
|
|
41
|
+
const given = options?.data;
|
|
42
|
+
if (typeof given === "object" && given !== null) Object.assign(data, given);
|
|
43
|
+
const handlers = options?.handlers;
|
|
44
|
+
if (handlers) data[CALLBACK_GROUP_KEY] = openOverlayEventChannel(key, () => handlers);
|
|
45
|
+
(0, import_root.dispatchOpen)(dispatch, id, instanceId, data);
|
|
46
|
+
return { overlayId: id, instanceId, close: () => (0, import_root.dispatchClose)(dispatch, id, instanceId) };
|
|
47
|
+
}
|
|
48
|
+
function dataSignature(data) {
|
|
49
|
+
try {
|
|
50
|
+
return JSON.stringify(data, (_key, value) => typeof value === "function" ? void 0 : value);
|
|
51
|
+
} catch {
|
|
52
|
+
return String(Date.now());
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function defineOverlay() {
|
|
56
|
+
return function define(spec) {
|
|
57
|
+
const id = spec.id;
|
|
58
|
+
const multi = spec.instance === "multi";
|
|
59
|
+
const meta = spec;
|
|
60
|
+
function useSummon() {
|
|
61
|
+
const dispatch = (0, import_root.useSummonDispatch)();
|
|
62
|
+
return (0, import_react.useCallback)((options) => openWith(dispatch, id, multi, options), [dispatch]);
|
|
63
|
+
}
|
|
64
|
+
function useIsOpen(instanceId = import_open.DEFAULT_INSTANCE_ID) {
|
|
65
|
+
return (0, import_root.useSummonSelector)((state) => (0, import_open.selectIsOverlayOpen)(state, id, instanceId));
|
|
66
|
+
}
|
|
67
|
+
function useClose() {
|
|
68
|
+
const dispatch = (0, import_root.useSummonDispatch)();
|
|
69
|
+
return (0, import_react.useCallback)((instanceId) => (0, import_root.dispatchClose)(dispatch, id, instanceId ?? import_open.DEFAULT_INSTANCE_ID), [dispatch]);
|
|
70
|
+
}
|
|
71
|
+
function useEmit() {
|
|
72
|
+
const instance = (0, import_root.useOptionalOverlayInstance)();
|
|
73
|
+
const channelId = instance?.overlayId === id ? instance.rawData?.[CALLBACK_GROUP_KEY] : void 0;
|
|
74
|
+
return (0, import_react.useCallback)(
|
|
75
|
+
(event, payload) => {
|
|
76
|
+
if (typeof channelId === "string") (0, import_root.emitOverlayEventLight)(channelId, event, payload);
|
|
77
|
+
},
|
|
78
|
+
[channelId]
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
function Controller(props) {
|
|
82
|
+
const dispatch = (0, import_root.useSummonDispatch)();
|
|
83
|
+
const [ownInstanceId] = (0, import_react.useState)(() => multi ? (0, import_root.newInstanceId)(id) : import_open.DEFAULT_INSTANCE_ID);
|
|
84
|
+
const instanceId = props.instanceId ?? ownInstanceId;
|
|
85
|
+
const handlersRef = (0, import_react.useRef)(props.handlers);
|
|
86
|
+
handlersRef.current = props.handlers;
|
|
87
|
+
const hasHandlers = props.handlers !== void 0;
|
|
88
|
+
const data = (0, import_react.useMemo)(() => {
|
|
89
|
+
const out = {};
|
|
90
|
+
for (const [key, value] of Object.entries(props)) {
|
|
91
|
+
if (key !== "instanceId" && key !== "handlers") out[key] = value;
|
|
92
|
+
}
|
|
93
|
+
return out;
|
|
94
|
+
}, [props]);
|
|
95
|
+
const signature = dataSignature(data);
|
|
96
|
+
const dataRef = (0, import_react.useRef)(data);
|
|
97
|
+
dataRef.current = data;
|
|
98
|
+
(0, import_react.useEffect)(() => {
|
|
99
|
+
const key = (0, import_open.instanceKey)(id, instanceId);
|
|
100
|
+
const open = { ...dataRef.current };
|
|
101
|
+
if (hasHandlers) open[CALLBACK_GROUP_KEY] = openOverlayEventChannel(key, () => handlersRef.current);
|
|
102
|
+
(0, import_root.dispatchOpen)(dispatch, id, instanceId, open);
|
|
103
|
+
return () => (0, import_root.dispatchClose)(dispatch, id, instanceId);
|
|
104
|
+
}, [dispatch, instanceId, signature, hasHandlers]);
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
Controller.displayName = `${id}Controller`;
|
|
108
|
+
return {
|
|
109
|
+
...spec,
|
|
110
|
+
id,
|
|
111
|
+
label: spec.label,
|
|
112
|
+
instance: multi ? "multi" : "single",
|
|
113
|
+
keepAlive: spec.keepAlive ?? "none",
|
|
114
|
+
meta,
|
|
115
|
+
useSummon,
|
|
116
|
+
Controller,
|
|
117
|
+
useIsOpen,
|
|
118
|
+
useClose,
|
|
119
|
+
useEmit
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=define.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/define.ts","../src/define/defineOverlay.tsx"],"sourcesContent":["// @ai-matrx/summon/define — `defineOverlay` (openers, Controller, open/close hooks, emitter). Import\n// it only from definition modules a host's lazy registry loads: whatever imports this entry pays for\n// it, so an opener file that callers import must never declare a definition beside its openers.\nexport {\n defineOverlay,\n CALLBACK_GROUP_KEY,\n type OverlayDefinition,\n type OverlaySpec,\n type HostableOverlay,\n type OverlayHandle,\n type OverlayOpener,\n type OverlayOpenOptions,\n type OverlayControllerProps,\n type OverlayEmitter,\n type OverlayEventMap,\n type OverlayHandlers,\n} from \"./define/defineOverlay\";\n","// `defineOverlay` — the declare-once API (C38 R2). One light definition per overlay carries its\n// metadata and (optionally) a lazy `render` import; the definition generates the opener hook, the declarative\n// Controller, the open/close hooks and a typed event emitter. The host renders definitions; the\n// render module is the old controller block, moved verbatim, and is fetched only when opened.\n//\n// Light by construction (the root section): no slice, no host, no handles registry. Opening goes\n// through the light creators (a gated host store loads the core on the first one); a callback-aware\n// open reserves its event channel and the handles section arrives with that first open.\n\nimport { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport {\n DEFAULT_INSTANCE_ID,\n instanceKey as toInstanceKey,\n openPendingEventChannel,\n selectIsOverlayOpen,\n type InstanceKey,\n type OverlayDefinitionMeta,\n type OverlayRawData,\n type AnyOverlayMeta,\n} from \"@ai-matrx/summon/open\";\nimport type { OverlayRenderProps } from \"../react/instanceBody\";\nimport type { RenderModule } from \"../react/loaderCache\";\n// The root's pieces by entry, never by relative path: the instance context and the store hooks must\n// keep ONE identity across the dist entries (this file ships in ./define, they ship in ./root).\nimport {\n dispatchClose,\n dispatchOpen,\n newInstanceId,\n emitOverlayEventLight,\n useOptionalOverlayInstance,\n useSummonDispatch,\n useSummonSelector,\n type SummonReactDispatch,\n} from \"@ai-matrx/summon/root\";\n\n/** Event name → payload, declared once per overlay: `defineOverlay<Data, { uploaded: Result }>()`. */\nexport type OverlayEventMap = Record<string, unknown>;\n\nexport type OverlayHandlers<Events extends OverlayEventMap> = {\n readonly [K in keyof Events]?: (payload: Events[K]) => void;\n};\n\nfunction openOverlayEventChannel<Events extends OverlayEventMap>(\n owner: InstanceKey,\n getHandlers: () => OverlayHandlers<Events> | undefined,\n): string {\n return openPendingEventChannel(owner, getHandlers as () => Readonly<Record<string, ((payload: unknown) => void) | undefined>> | undefined);\n}\n\n/** The open-data key that carries an overlay's event channel id (the old callback-group key). */\nexport const CALLBACK_GROUP_KEY = \"callbackGroupId\";\n\nexport interface OverlayHandle {\n readonly overlayId: string;\n readonly instanceId: string;\n close(): void;\n}\n\nexport interface OverlayOpenOptions<Data, Events extends OverlayEventMap> {\n readonly data?: Data;\n /** Single-instance overlays ignore it unless given; multi-instance generate one when omitted. */\n readonly instanceId?: string;\n /** Plain functions; they reach the caller through an event channel owned by the instance. */\n readonly handlers?: OverlayHandlers<Events>;\n}\n\nexport type OverlayOpener<Data, Events extends OverlayEventMap> = (options?: OverlayOpenOptions<Data, Events>) => OverlayHandle;\n\nexport type OverlayControllerProps<Data, Events extends OverlayEventMap> = Data & {\n readonly instanceId?: string;\n readonly handlers?: OverlayHandlers<Events>;\n};\n\nexport type OverlayEmitter<Events extends OverlayEventMap> = <K extends keyof Events & string>(event: K, payload: Events[K]) => void;\n\n/** What a definition file passes to `defineOverlay<Data>()(…)`. */\nexport interface OverlaySpec<Id extends string, Data, Parsed> extends OverlayDefinitionMeta<Id, Data> {\n /**\n * The lazily loaded render module. Its default export receives `OverlayRenderProps<Parsed>`.\n * Optional: a large app leaves it out and hands `<SummonHost renders={…}>` one id → import map,\n * so files that import a definition for its opener never gain an import() edge to the window\n * (the host-build law). When present it wins over the host map.\n */\n readonly render?: () => Promise<RenderModule<OverlayRenderProps<NoInfer<Parsed>>>>;\n /** Narrow raw open data once. `null` = refuse: the instance is closed with a warning. */\n readonly parse?: (raw: OverlayRawData) => Parsed | null;\n}\n\n/** The type-erased half the host renders; no data types cross this line. */\nexport interface HostableOverlay {\n readonly id: string;\n readonly label: string;\n readonly instance: \"single\" | \"multi\";\n readonly keepAlive: \"none\" | \"hidden\" | \"restore\";\n /** The metadata the core registry stores (links, window options, defaults…). */\n readonly meta: AnyOverlayMeta;\n /** The definition's own render loader (the host's `renders` map is used when absent). */\n readonly render?: (() => Promise<unknown>) | undefined;\n /** Narrows raw open data; the host builds each instance body from it on first render. */\n readonly parse?: ((raw: OverlayRawData) => unknown) | undefined;\n}\n\nexport interface OverlayDefinition<Id extends string, Data, Parsed, Events extends OverlayEventMap>\n extends Omit<OverlayDefinitionMeta<Id, Data>, \"id\" | \"instance\" | \"keepAlive\">,\n HostableOverlay {\n readonly id: Id;\n readonly render?: () => Promise<RenderModule<OverlayRenderProps<Parsed>>>;\n /** Imperative opener: `const open = def.useSummon(); open({ data })` → handle. */\n useSummon(): OverlayOpener<Data, Events>;\n /** Declarative form: opens on mount, closes on unmount, re-opens when its data changes. */\n readonly Controller: (props: OverlayControllerProps<Data, Events>) => null;\n useIsOpen(instanceId?: string): boolean;\n /** `const close = def.useClose(); close(instanceId?)`. */\n useClose(): (instanceId?: string) => void;\n /** Inside the render tree: emit a declared event to the opener's handlers. */\n useEmit(): OverlayEmitter<Events>;\n}\n\nfunction openWith<Data, Events extends OverlayEventMap>(\n dispatch: SummonReactDispatch,\n id: string,\n multi: boolean,\n options: OverlayOpenOptions<Data, Events> | undefined,\n): OverlayHandle {\n const instanceId = options?.instanceId ?? (multi ? newInstanceId(id) : DEFAULT_INSTANCE_ID);\n const key = toInstanceKey(id, instanceId);\n const data: Record<string, unknown> = {};\n const given: unknown = options?.data;\n if (typeof given === \"object\" && given !== null) Object.assign(data, given);\n const handlers = options?.handlers;\n if (handlers) data[CALLBACK_GROUP_KEY] = openOverlayEventChannel<Events>(key, () => handlers);\n dispatchOpen(dispatch, id, instanceId, data);\n return { overlayId: id, instanceId, close: () => dispatchClose(dispatch, id, instanceId) };\n}\n\n/** Stable identity for the serialisable part of Controller props (functions never reopen). */\nfunction dataSignature(data: Readonly<Record<string, unknown>>): string {\n try {\n return JSON.stringify(data, (_key, value: unknown) => (typeof value === \"function\" ? undefined : value));\n } catch {\n return String(Date.now());\n }\n}\n\n/**\n * Declare an overlay once. Curried so `Data` (and `Events`) are named while the id and the\n * parsed-data type are inferred:\n *\n * export const notesWindow = defineOverlay<NotesWindowData>()({\n * id: \"notesWindow\", label: \"Notes\", render: () => import(\"./notesWindow.render\"),\n * });\n */\nexport function defineOverlay<Data extends object = Record<string, never>, Events extends OverlayEventMap = Record<never, never>>() {\n return function define<const Id extends string, Parsed = OverlayRawData>(\n spec: OverlaySpec<Id, Data, Parsed>,\n ): OverlayDefinition<Id, Data, Parsed, Events> {\n const id = spec.id;\n const multi = spec.instance === \"multi\";\n // The registry stores every definition's metadata under one erased type (AnyOverlayMeta).\n const meta: AnyOverlayMeta = spec;\n\n function useSummon(): OverlayOpener<Data, Events> {\n const dispatch = useSummonDispatch();\n return useCallback((options) => openWith(dispatch, id, multi, options), [dispatch]);\n }\n\n function useIsOpen(instanceId: string = DEFAULT_INSTANCE_ID): boolean {\n return useSummonSelector((state) => selectIsOverlayOpen(state, id, instanceId));\n }\n\n function useClose(): (instanceId?: string) => void {\n const dispatch = useSummonDispatch();\n return useCallback((instanceId?: string) => dispatchClose(dispatch, id, instanceId ?? DEFAULT_INSTANCE_ID), [dispatch]);\n }\n\n function useEmit(): OverlayEmitter<Events> {\n const instance = useOptionalOverlayInstance();\n const channelId = instance?.overlayId === id ? instance.rawData?.[CALLBACK_GROUP_KEY] : undefined;\n return useCallback<OverlayEmitter<Events>>(\n (event, payload) => {\n if (typeof channelId === \"string\") emitOverlayEventLight(channelId, event, payload);\n },\n [channelId],\n );\n }\n\n function Controller(props: OverlayControllerProps<Data, Events>): null {\n const dispatch = useSummonDispatch();\n const [ownInstanceId] = useState(() => (multi ? newInstanceId(id) : DEFAULT_INSTANCE_ID));\n const instanceId = props.instanceId ?? ownInstanceId;\n // Latest handlers, read at emit time: a new function identity never reopens the overlay.\n const handlersRef = useRef(props.handlers);\n handlersRef.current = props.handlers;\n const hasHandlers = props.handlers !== undefined;\n\n const data = useMemo(() => {\n const out: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(props)) {\n if (key !== \"instanceId\" && key !== \"handlers\") out[key] = value;\n }\n return out;\n }, [props]);\n const signature = dataSignature(data);\n const dataRef = useRef(data);\n dataRef.current = data;\n\n useEffect(() => {\n const key: InstanceKey = toInstanceKey(id, instanceId);\n const open: Record<string, unknown> = { ...dataRef.current };\n if (hasHandlers) open[CALLBACK_GROUP_KEY] = openOverlayEventChannel<Events>(key, () => handlersRef.current);\n dispatchOpen(dispatch, id, instanceId, open);\n return () => dispatchClose(dispatch, id, instanceId);\n }, [dispatch, instanceId, signature, hasHandlers]);\n\n return null;\n }\n Controller.displayName = `${id}Controller`;\n\n return {\n ...spec,\n id,\n label: spec.label,\n instance: multi ? \"multi\" : \"single\",\n keepAlive: spec.keepAlive ?? \"none\",\n meta,\n useSummon,\n Controller,\n useIsOpen,\n useClose,\n useEmit,\n };\n };\n}\n"],"mappings":"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","names":["toInstanceKey"]}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { AnyOverlayMeta, OverlayRawData, OverlayDefinitionMeta } from '@ai-matrx/summon/open';
|
|
2
|
+
import { a as RenderModule, O as OverlayRenderProps } from './instanceBody-CgZAFnic.cjs';
|
|
3
|
+
import 'react';
|
|
4
|
+
import '@ai-matrx/summon';
|
|
5
|
+
|
|
6
|
+
/** Event name → payload, declared once per overlay: `defineOverlay<Data, { uploaded: Result }>()`. */
|
|
7
|
+
type OverlayEventMap = Record<string, unknown>;
|
|
8
|
+
type OverlayHandlers<Events extends OverlayEventMap> = {
|
|
9
|
+
readonly [K in keyof Events]?: (payload: Events[K]) => void;
|
|
10
|
+
};
|
|
11
|
+
/** The open-data key that carries an overlay's event channel id (the old callback-group key). */
|
|
12
|
+
declare const CALLBACK_GROUP_KEY = "callbackGroupId";
|
|
13
|
+
interface OverlayHandle {
|
|
14
|
+
readonly overlayId: string;
|
|
15
|
+
readonly instanceId: string;
|
|
16
|
+
close(): void;
|
|
17
|
+
}
|
|
18
|
+
interface OverlayOpenOptions<Data, Events extends OverlayEventMap> {
|
|
19
|
+
readonly data?: Data;
|
|
20
|
+
/** Single-instance overlays ignore it unless given; multi-instance generate one when omitted. */
|
|
21
|
+
readonly instanceId?: string;
|
|
22
|
+
/** Plain functions; they reach the caller through an event channel owned by the instance. */
|
|
23
|
+
readonly handlers?: OverlayHandlers<Events>;
|
|
24
|
+
}
|
|
25
|
+
type OverlayOpener<Data, Events extends OverlayEventMap> = (options?: OverlayOpenOptions<Data, Events>) => OverlayHandle;
|
|
26
|
+
type OverlayControllerProps<Data, Events extends OverlayEventMap> = Data & {
|
|
27
|
+
readonly instanceId?: string;
|
|
28
|
+
readonly handlers?: OverlayHandlers<Events>;
|
|
29
|
+
};
|
|
30
|
+
type OverlayEmitter<Events extends OverlayEventMap> = <K extends keyof Events & string>(event: K, payload: Events[K]) => void;
|
|
31
|
+
/** What a definition file passes to `defineOverlay<Data>()(…)`. */
|
|
32
|
+
interface OverlaySpec<Id extends string, Data, Parsed> extends OverlayDefinitionMeta<Id, Data> {
|
|
33
|
+
/**
|
|
34
|
+
* The lazily loaded render module. Its default export receives `OverlayRenderProps<Parsed>`.
|
|
35
|
+
* Optional: a large app leaves it out and hands `<SummonHost renders={…}>` one id → import map,
|
|
36
|
+
* so files that import a definition for its opener never gain an import() edge to the window
|
|
37
|
+
* (the host-build law). When present it wins over the host map.
|
|
38
|
+
*/
|
|
39
|
+
readonly render?: () => Promise<RenderModule<OverlayRenderProps<NoInfer<Parsed>>>>;
|
|
40
|
+
/** Narrow raw open data once. `null` = refuse: the instance is closed with a warning. */
|
|
41
|
+
readonly parse?: (raw: OverlayRawData) => Parsed | null;
|
|
42
|
+
}
|
|
43
|
+
/** The type-erased half the host renders; no data types cross this line. */
|
|
44
|
+
interface HostableOverlay {
|
|
45
|
+
readonly id: string;
|
|
46
|
+
readonly label: string;
|
|
47
|
+
readonly instance: "single" | "multi";
|
|
48
|
+
readonly keepAlive: "none" | "hidden" | "restore";
|
|
49
|
+
/** The metadata the core registry stores (links, window options, defaults…). */
|
|
50
|
+
readonly meta: AnyOverlayMeta;
|
|
51
|
+
/** The definition's own render loader (the host's `renders` map is used when absent). */
|
|
52
|
+
readonly render?: (() => Promise<unknown>) | undefined;
|
|
53
|
+
/** Narrows raw open data; the host builds each instance body from it on first render. */
|
|
54
|
+
readonly parse?: ((raw: OverlayRawData) => unknown) | undefined;
|
|
55
|
+
}
|
|
56
|
+
interface OverlayDefinition<Id extends string, Data, Parsed, Events extends OverlayEventMap> extends Omit<OverlayDefinitionMeta<Id, Data>, "id" | "instance" | "keepAlive">, HostableOverlay {
|
|
57
|
+
readonly id: Id;
|
|
58
|
+
readonly render?: () => Promise<RenderModule<OverlayRenderProps<Parsed>>>;
|
|
59
|
+
/** Imperative opener: `const open = def.useSummon(); open({ data })` → handle. */
|
|
60
|
+
useSummon(): OverlayOpener<Data, Events>;
|
|
61
|
+
/** Declarative form: opens on mount, closes on unmount, re-opens when its data changes. */
|
|
62
|
+
readonly Controller: (props: OverlayControllerProps<Data, Events>) => null;
|
|
63
|
+
useIsOpen(instanceId?: string): boolean;
|
|
64
|
+
/** `const close = def.useClose(); close(instanceId?)`. */
|
|
65
|
+
useClose(): (instanceId?: string) => void;
|
|
66
|
+
/** Inside the render tree: emit a declared event to the opener's handlers. */
|
|
67
|
+
useEmit(): OverlayEmitter<Events>;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Declare an overlay once. Curried so `Data` (and `Events`) are named while the id and the
|
|
71
|
+
* parsed-data type are inferred:
|
|
72
|
+
*
|
|
73
|
+
* export const notesWindow = defineOverlay<NotesWindowData>()({
|
|
74
|
+
* id: "notesWindow", label: "Notes", render: () => import("./notesWindow.render"),
|
|
75
|
+
* });
|
|
76
|
+
*/
|
|
77
|
+
declare function defineOverlay<Data extends object = Record<string, never>, Events extends OverlayEventMap = Record<never, never>>(): <const Id extends string, Parsed = OverlayRawData>(spec: OverlaySpec<Id, Data, Parsed>) => OverlayDefinition<Id, Data, Parsed, Events>;
|
|
78
|
+
|
|
79
|
+
export { CALLBACK_GROUP_KEY, type HostableOverlay, type OverlayControllerProps, type OverlayDefinition, type OverlayEmitter, type OverlayEventMap, type OverlayHandle, type OverlayHandlers, type OverlayOpenOptions, type OverlayOpener, type OverlaySpec, defineOverlay };
|
package/dist/define.d.ts
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { AnyOverlayMeta, OverlayRawData, OverlayDefinitionMeta } from '@ai-matrx/summon/open';
|
|
2
|
+
import { a as RenderModule, O as OverlayRenderProps } from './instanceBody-CgZAFnic.js';
|
|
3
|
+
import 'react';
|
|
4
|
+
import '@ai-matrx/summon';
|
|
5
|
+
|
|
6
|
+
/** Event name → payload, declared once per overlay: `defineOverlay<Data, { uploaded: Result }>()`. */
|
|
7
|
+
type OverlayEventMap = Record<string, unknown>;
|
|
8
|
+
type OverlayHandlers<Events extends OverlayEventMap> = {
|
|
9
|
+
readonly [K in keyof Events]?: (payload: Events[K]) => void;
|
|
10
|
+
};
|
|
11
|
+
/** The open-data key that carries an overlay's event channel id (the old callback-group key). */
|
|
12
|
+
declare const CALLBACK_GROUP_KEY = "callbackGroupId";
|
|
13
|
+
interface OverlayHandle {
|
|
14
|
+
readonly overlayId: string;
|
|
15
|
+
readonly instanceId: string;
|
|
16
|
+
close(): void;
|
|
17
|
+
}
|
|
18
|
+
interface OverlayOpenOptions<Data, Events extends OverlayEventMap> {
|
|
19
|
+
readonly data?: Data;
|
|
20
|
+
/** Single-instance overlays ignore it unless given; multi-instance generate one when omitted. */
|
|
21
|
+
readonly instanceId?: string;
|
|
22
|
+
/** Plain functions; they reach the caller through an event channel owned by the instance. */
|
|
23
|
+
readonly handlers?: OverlayHandlers<Events>;
|
|
24
|
+
}
|
|
25
|
+
type OverlayOpener<Data, Events extends OverlayEventMap> = (options?: OverlayOpenOptions<Data, Events>) => OverlayHandle;
|
|
26
|
+
type OverlayControllerProps<Data, Events extends OverlayEventMap> = Data & {
|
|
27
|
+
readonly instanceId?: string;
|
|
28
|
+
readonly handlers?: OverlayHandlers<Events>;
|
|
29
|
+
};
|
|
30
|
+
type OverlayEmitter<Events extends OverlayEventMap> = <K extends keyof Events & string>(event: K, payload: Events[K]) => void;
|
|
31
|
+
/** What a definition file passes to `defineOverlay<Data>()(…)`. */
|
|
32
|
+
interface OverlaySpec<Id extends string, Data, Parsed> extends OverlayDefinitionMeta<Id, Data> {
|
|
33
|
+
/**
|
|
34
|
+
* The lazily loaded render module. Its default export receives `OverlayRenderProps<Parsed>`.
|
|
35
|
+
* Optional: a large app leaves it out and hands `<SummonHost renders={…}>` one id → import map,
|
|
36
|
+
* so files that import a definition for its opener never gain an import() edge to the window
|
|
37
|
+
* (the host-build law). When present it wins over the host map.
|
|
38
|
+
*/
|
|
39
|
+
readonly render?: () => Promise<RenderModule<OverlayRenderProps<NoInfer<Parsed>>>>;
|
|
40
|
+
/** Narrow raw open data once. `null` = refuse: the instance is closed with a warning. */
|
|
41
|
+
readonly parse?: (raw: OverlayRawData) => Parsed | null;
|
|
42
|
+
}
|
|
43
|
+
/** The type-erased half the host renders; no data types cross this line. */
|
|
44
|
+
interface HostableOverlay {
|
|
45
|
+
readonly id: string;
|
|
46
|
+
readonly label: string;
|
|
47
|
+
readonly instance: "single" | "multi";
|
|
48
|
+
readonly keepAlive: "none" | "hidden" | "restore";
|
|
49
|
+
/** The metadata the core registry stores (links, window options, defaults…). */
|
|
50
|
+
readonly meta: AnyOverlayMeta;
|
|
51
|
+
/** The definition's own render loader (the host's `renders` map is used when absent). */
|
|
52
|
+
readonly render?: (() => Promise<unknown>) | undefined;
|
|
53
|
+
/** Narrows raw open data; the host builds each instance body from it on first render. */
|
|
54
|
+
readonly parse?: ((raw: OverlayRawData) => unknown) | undefined;
|
|
55
|
+
}
|
|
56
|
+
interface OverlayDefinition<Id extends string, Data, Parsed, Events extends OverlayEventMap> extends Omit<OverlayDefinitionMeta<Id, Data>, "id" | "instance" | "keepAlive">, HostableOverlay {
|
|
57
|
+
readonly id: Id;
|
|
58
|
+
readonly render?: () => Promise<RenderModule<OverlayRenderProps<Parsed>>>;
|
|
59
|
+
/** Imperative opener: `const open = def.useSummon(); open({ data })` → handle. */
|
|
60
|
+
useSummon(): OverlayOpener<Data, Events>;
|
|
61
|
+
/** Declarative form: opens on mount, closes on unmount, re-opens when its data changes. */
|
|
62
|
+
readonly Controller: (props: OverlayControllerProps<Data, Events>) => null;
|
|
63
|
+
useIsOpen(instanceId?: string): boolean;
|
|
64
|
+
/** `const close = def.useClose(); close(instanceId?)`. */
|
|
65
|
+
useClose(): (instanceId?: string) => void;
|
|
66
|
+
/** Inside the render tree: emit a declared event to the opener's handlers. */
|
|
67
|
+
useEmit(): OverlayEmitter<Events>;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Declare an overlay once. Curried so `Data` (and `Events`) are named while the id and the
|
|
71
|
+
* parsed-data type are inferred:
|
|
72
|
+
*
|
|
73
|
+
* export const notesWindow = defineOverlay<NotesWindowData>()({
|
|
74
|
+
* id: "notesWindow", label: "Notes", render: () => import("./notesWindow.render"),
|
|
75
|
+
* });
|
|
76
|
+
*/
|
|
77
|
+
declare function defineOverlay<Data extends object = Record<string, never>, Events extends OverlayEventMap = Record<never, never>>(): <const Id extends string, Parsed = OverlayRawData>(spec: OverlaySpec<Id, Data, Parsed>) => OverlayDefinition<Id, Data, Parsed, Events>;
|
|
78
|
+
|
|
79
|
+
export { CALLBACK_GROUP_KEY, type HostableOverlay, type OverlayControllerProps, type OverlayDefinition, type OverlayEmitter, type OverlayEventMap, type OverlayHandle, type OverlayHandlers, type OverlayOpenOptions, type OverlayOpener, type OverlaySpec, defineOverlay };
|
package/dist/define.js
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/define/defineOverlay.tsx
|
|
4
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
5
|
+
import {
|
|
6
|
+
DEFAULT_INSTANCE_ID,
|
|
7
|
+
instanceKey as toInstanceKey,
|
|
8
|
+
openPendingEventChannel,
|
|
9
|
+
selectIsOverlayOpen
|
|
10
|
+
} from "@ai-matrx/summon/open";
|
|
11
|
+
import {
|
|
12
|
+
dispatchClose,
|
|
13
|
+
dispatchOpen,
|
|
14
|
+
newInstanceId,
|
|
15
|
+
emitOverlayEventLight,
|
|
16
|
+
useOptionalOverlayInstance,
|
|
17
|
+
useSummonDispatch,
|
|
18
|
+
useSummonSelector
|
|
19
|
+
} from "@ai-matrx/summon/root";
|
|
20
|
+
function openOverlayEventChannel(owner, getHandlers) {
|
|
21
|
+
return openPendingEventChannel(owner, getHandlers);
|
|
22
|
+
}
|
|
23
|
+
var CALLBACK_GROUP_KEY = "callbackGroupId";
|
|
24
|
+
function openWith(dispatch, id, multi, options) {
|
|
25
|
+
const instanceId = options?.instanceId ?? (multi ? newInstanceId(id) : DEFAULT_INSTANCE_ID);
|
|
26
|
+
const key = toInstanceKey(id, instanceId);
|
|
27
|
+
const data = {};
|
|
28
|
+
const given = options?.data;
|
|
29
|
+
if (typeof given === "object" && given !== null) Object.assign(data, given);
|
|
30
|
+
const handlers = options?.handlers;
|
|
31
|
+
if (handlers) data[CALLBACK_GROUP_KEY] = openOverlayEventChannel(key, () => handlers);
|
|
32
|
+
dispatchOpen(dispatch, id, instanceId, data);
|
|
33
|
+
return { overlayId: id, instanceId, close: () => dispatchClose(dispatch, id, instanceId) };
|
|
34
|
+
}
|
|
35
|
+
function dataSignature(data) {
|
|
36
|
+
try {
|
|
37
|
+
return JSON.stringify(data, (_key, value) => typeof value === "function" ? void 0 : value);
|
|
38
|
+
} catch {
|
|
39
|
+
return String(Date.now());
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function defineOverlay() {
|
|
43
|
+
return function define(spec) {
|
|
44
|
+
const id = spec.id;
|
|
45
|
+
const multi = spec.instance === "multi";
|
|
46
|
+
const meta = spec;
|
|
47
|
+
function useSummon() {
|
|
48
|
+
const dispatch = useSummonDispatch();
|
|
49
|
+
return useCallback((options) => openWith(dispatch, id, multi, options), [dispatch]);
|
|
50
|
+
}
|
|
51
|
+
function useIsOpen(instanceId = DEFAULT_INSTANCE_ID) {
|
|
52
|
+
return useSummonSelector((state) => selectIsOverlayOpen(state, id, instanceId));
|
|
53
|
+
}
|
|
54
|
+
function useClose() {
|
|
55
|
+
const dispatch = useSummonDispatch();
|
|
56
|
+
return useCallback((instanceId) => dispatchClose(dispatch, id, instanceId ?? DEFAULT_INSTANCE_ID), [dispatch]);
|
|
57
|
+
}
|
|
58
|
+
function useEmit() {
|
|
59
|
+
const instance = useOptionalOverlayInstance();
|
|
60
|
+
const channelId = instance?.overlayId === id ? instance.rawData?.[CALLBACK_GROUP_KEY] : void 0;
|
|
61
|
+
return useCallback(
|
|
62
|
+
(event, payload) => {
|
|
63
|
+
if (typeof channelId === "string") emitOverlayEventLight(channelId, event, payload);
|
|
64
|
+
},
|
|
65
|
+
[channelId]
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
function Controller(props) {
|
|
69
|
+
const dispatch = useSummonDispatch();
|
|
70
|
+
const [ownInstanceId] = useState(() => multi ? newInstanceId(id) : DEFAULT_INSTANCE_ID);
|
|
71
|
+
const instanceId = props.instanceId ?? ownInstanceId;
|
|
72
|
+
const handlersRef = useRef(props.handlers);
|
|
73
|
+
handlersRef.current = props.handlers;
|
|
74
|
+
const hasHandlers = props.handlers !== void 0;
|
|
75
|
+
const data = useMemo(() => {
|
|
76
|
+
const out = {};
|
|
77
|
+
for (const [key, value] of Object.entries(props)) {
|
|
78
|
+
if (key !== "instanceId" && key !== "handlers") out[key] = value;
|
|
79
|
+
}
|
|
80
|
+
return out;
|
|
81
|
+
}, [props]);
|
|
82
|
+
const signature = dataSignature(data);
|
|
83
|
+
const dataRef = useRef(data);
|
|
84
|
+
dataRef.current = data;
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
const key = toInstanceKey(id, instanceId);
|
|
87
|
+
const open = { ...dataRef.current };
|
|
88
|
+
if (hasHandlers) open[CALLBACK_GROUP_KEY] = openOverlayEventChannel(key, () => handlersRef.current);
|
|
89
|
+
dispatchOpen(dispatch, id, instanceId, open);
|
|
90
|
+
return () => dispatchClose(dispatch, id, instanceId);
|
|
91
|
+
}, [dispatch, instanceId, signature, hasHandlers]);
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
Controller.displayName = `${id}Controller`;
|
|
95
|
+
return {
|
|
96
|
+
...spec,
|
|
97
|
+
id,
|
|
98
|
+
label: spec.label,
|
|
99
|
+
instance: multi ? "multi" : "single",
|
|
100
|
+
keepAlive: spec.keepAlive ?? "none",
|
|
101
|
+
meta,
|
|
102
|
+
useSummon,
|
|
103
|
+
Controller,
|
|
104
|
+
useIsOpen,
|
|
105
|
+
useClose,
|
|
106
|
+
useEmit
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
export {
|
|
111
|
+
CALLBACK_GROUP_KEY,
|
|
112
|
+
defineOverlay
|
|
113
|
+
};
|
|
114
|
+
//# sourceMappingURL=define.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/define/defineOverlay.tsx"],"sourcesContent":["// `defineOverlay` — the declare-once API (C38 R2). One light definition per overlay carries its\n// metadata and (optionally) a lazy `render` import; the definition generates the opener hook, the declarative\n// Controller, the open/close hooks and a typed event emitter. The host renders definitions; the\n// render module is the old controller block, moved verbatim, and is fetched only when opened.\n//\n// Light by construction (the root section): no slice, no host, no handles registry. Opening goes\n// through the light creators (a gated host store loads the core on the first one); a callback-aware\n// open reserves its event channel and the handles section arrives with that first open.\n\nimport { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport {\n DEFAULT_INSTANCE_ID,\n instanceKey as toInstanceKey,\n openPendingEventChannel,\n selectIsOverlayOpen,\n type InstanceKey,\n type OverlayDefinitionMeta,\n type OverlayRawData,\n type AnyOverlayMeta,\n} from \"@ai-matrx/summon/open\";\nimport type { OverlayRenderProps } from \"../react/instanceBody\";\nimport type { RenderModule } from \"../react/loaderCache\";\n// The root's pieces by entry, never by relative path: the instance context and the store hooks must\n// keep ONE identity across the dist entries (this file ships in ./define, they ship in ./root).\nimport {\n dispatchClose,\n dispatchOpen,\n newInstanceId,\n emitOverlayEventLight,\n useOptionalOverlayInstance,\n useSummonDispatch,\n useSummonSelector,\n type SummonReactDispatch,\n} from \"@ai-matrx/summon/root\";\n\n/** Event name → payload, declared once per overlay: `defineOverlay<Data, { uploaded: Result }>()`. */\nexport type OverlayEventMap = Record<string, unknown>;\n\nexport type OverlayHandlers<Events extends OverlayEventMap> = {\n readonly [K in keyof Events]?: (payload: Events[K]) => void;\n};\n\nfunction openOverlayEventChannel<Events extends OverlayEventMap>(\n owner: InstanceKey,\n getHandlers: () => OverlayHandlers<Events> | undefined,\n): string {\n return openPendingEventChannel(owner, getHandlers as () => Readonly<Record<string, ((payload: unknown) => void) | undefined>> | undefined);\n}\n\n/** The open-data key that carries an overlay's event channel id (the old callback-group key). */\nexport const CALLBACK_GROUP_KEY = \"callbackGroupId\";\n\nexport interface OverlayHandle {\n readonly overlayId: string;\n readonly instanceId: string;\n close(): void;\n}\n\nexport interface OverlayOpenOptions<Data, Events extends OverlayEventMap> {\n readonly data?: Data;\n /** Single-instance overlays ignore it unless given; multi-instance generate one when omitted. */\n readonly instanceId?: string;\n /** Plain functions; they reach the caller through an event channel owned by the instance. */\n readonly handlers?: OverlayHandlers<Events>;\n}\n\nexport type OverlayOpener<Data, Events extends OverlayEventMap> = (options?: OverlayOpenOptions<Data, Events>) => OverlayHandle;\n\nexport type OverlayControllerProps<Data, Events extends OverlayEventMap> = Data & {\n readonly instanceId?: string;\n readonly handlers?: OverlayHandlers<Events>;\n};\n\nexport type OverlayEmitter<Events extends OverlayEventMap> = <K extends keyof Events & string>(event: K, payload: Events[K]) => void;\n\n/** What a definition file passes to `defineOverlay<Data>()(…)`. */\nexport interface OverlaySpec<Id extends string, Data, Parsed> extends OverlayDefinitionMeta<Id, Data> {\n /**\n * The lazily loaded render module. Its default export receives `OverlayRenderProps<Parsed>`.\n * Optional: a large app leaves it out and hands `<SummonHost renders={…}>` one id → import map,\n * so files that import a definition for its opener never gain an import() edge to the window\n * (the host-build law). When present it wins over the host map.\n */\n readonly render?: () => Promise<RenderModule<OverlayRenderProps<NoInfer<Parsed>>>>;\n /** Narrow raw open data once. `null` = refuse: the instance is closed with a warning. */\n readonly parse?: (raw: OverlayRawData) => Parsed | null;\n}\n\n/** The type-erased half the host renders; no data types cross this line. */\nexport interface HostableOverlay {\n readonly id: string;\n readonly label: string;\n readonly instance: \"single\" | \"multi\";\n readonly keepAlive: \"none\" | \"hidden\" | \"restore\";\n /** The metadata the core registry stores (links, window options, defaults…). */\n readonly meta: AnyOverlayMeta;\n /** The definition's own render loader (the host's `renders` map is used when absent). */\n readonly render?: (() => Promise<unknown>) | undefined;\n /** Narrows raw open data; the host builds each instance body from it on first render. */\n readonly parse?: ((raw: OverlayRawData) => unknown) | undefined;\n}\n\nexport interface OverlayDefinition<Id extends string, Data, Parsed, Events extends OverlayEventMap>\n extends Omit<OverlayDefinitionMeta<Id, Data>, \"id\" | \"instance\" | \"keepAlive\">,\n HostableOverlay {\n readonly id: Id;\n readonly render?: () => Promise<RenderModule<OverlayRenderProps<Parsed>>>;\n /** Imperative opener: `const open = def.useSummon(); open({ data })` → handle. */\n useSummon(): OverlayOpener<Data, Events>;\n /** Declarative form: opens on mount, closes on unmount, re-opens when its data changes. */\n readonly Controller: (props: OverlayControllerProps<Data, Events>) => null;\n useIsOpen(instanceId?: string): boolean;\n /** `const close = def.useClose(); close(instanceId?)`. */\n useClose(): (instanceId?: string) => void;\n /** Inside the render tree: emit a declared event to the opener's handlers. */\n useEmit(): OverlayEmitter<Events>;\n}\n\nfunction openWith<Data, Events extends OverlayEventMap>(\n dispatch: SummonReactDispatch,\n id: string,\n multi: boolean,\n options: OverlayOpenOptions<Data, Events> | undefined,\n): OverlayHandle {\n const instanceId = options?.instanceId ?? (multi ? newInstanceId(id) : DEFAULT_INSTANCE_ID);\n const key = toInstanceKey(id, instanceId);\n const data: Record<string, unknown> = {};\n const given: unknown = options?.data;\n if (typeof given === \"object\" && given !== null) Object.assign(data, given);\n const handlers = options?.handlers;\n if (handlers) data[CALLBACK_GROUP_KEY] = openOverlayEventChannel<Events>(key, () => handlers);\n dispatchOpen(dispatch, id, instanceId, data);\n return { overlayId: id, instanceId, close: () => dispatchClose(dispatch, id, instanceId) };\n}\n\n/** Stable identity for the serialisable part of Controller props (functions never reopen). */\nfunction dataSignature(data: Readonly<Record<string, unknown>>): string {\n try {\n return JSON.stringify(data, (_key, value: unknown) => (typeof value === \"function\" ? undefined : value));\n } catch {\n return String(Date.now());\n }\n}\n\n/**\n * Declare an overlay once. Curried so `Data` (and `Events`) are named while the id and the\n * parsed-data type are inferred:\n *\n * export const notesWindow = defineOverlay<NotesWindowData>()({\n * id: \"notesWindow\", label: \"Notes\", render: () => import(\"./notesWindow.render\"),\n * });\n */\nexport function defineOverlay<Data extends object = Record<string, never>, Events extends OverlayEventMap = Record<never, never>>() {\n return function define<const Id extends string, Parsed = OverlayRawData>(\n spec: OverlaySpec<Id, Data, Parsed>,\n ): OverlayDefinition<Id, Data, Parsed, Events> {\n const id = spec.id;\n const multi = spec.instance === \"multi\";\n // The registry stores every definition's metadata under one erased type (AnyOverlayMeta).\n const meta: AnyOverlayMeta = spec;\n\n function useSummon(): OverlayOpener<Data, Events> {\n const dispatch = useSummonDispatch();\n return useCallback((options) => openWith(dispatch, id, multi, options), [dispatch]);\n }\n\n function useIsOpen(instanceId: string = DEFAULT_INSTANCE_ID): boolean {\n return useSummonSelector((state) => selectIsOverlayOpen(state, id, instanceId));\n }\n\n function useClose(): (instanceId?: string) => void {\n const dispatch = useSummonDispatch();\n return useCallback((instanceId?: string) => dispatchClose(dispatch, id, instanceId ?? DEFAULT_INSTANCE_ID), [dispatch]);\n }\n\n function useEmit(): OverlayEmitter<Events> {\n const instance = useOptionalOverlayInstance();\n const channelId = instance?.overlayId === id ? instance.rawData?.[CALLBACK_GROUP_KEY] : undefined;\n return useCallback<OverlayEmitter<Events>>(\n (event, payload) => {\n if (typeof channelId === \"string\") emitOverlayEventLight(channelId, event, payload);\n },\n [channelId],\n );\n }\n\n function Controller(props: OverlayControllerProps<Data, Events>): null {\n const dispatch = useSummonDispatch();\n const [ownInstanceId] = useState(() => (multi ? newInstanceId(id) : DEFAULT_INSTANCE_ID));\n const instanceId = props.instanceId ?? ownInstanceId;\n // Latest handlers, read at emit time: a new function identity never reopens the overlay.\n const handlersRef = useRef(props.handlers);\n handlersRef.current = props.handlers;\n const hasHandlers = props.handlers !== undefined;\n\n const data = useMemo(() => {\n const out: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(props)) {\n if (key !== \"instanceId\" && key !== \"handlers\") out[key] = value;\n }\n return out;\n }, [props]);\n const signature = dataSignature(data);\n const dataRef = useRef(data);\n dataRef.current = data;\n\n useEffect(() => {\n const key: InstanceKey = toInstanceKey(id, instanceId);\n const open: Record<string, unknown> = { ...dataRef.current };\n if (hasHandlers) open[CALLBACK_GROUP_KEY] = openOverlayEventChannel<Events>(key, () => handlersRef.current);\n dispatchOpen(dispatch, id, instanceId, open);\n return () => dispatchClose(dispatch, id, instanceId);\n }, [dispatch, instanceId, signature, hasHandlers]);\n\n return null;\n }\n Controller.displayName = `${id}Controller`;\n\n return {\n ...spec,\n id,\n label: spec.label,\n instance: multi ? \"multi\" : \"single\",\n keepAlive: spec.keepAlive ?? \"none\",\n meta,\n useSummon,\n Controller,\n useIsOpen,\n useClose,\n useEmit,\n };\n };\n}\n"],"mappings":";;;AASA,SAAS,aAAa,WAAW,SAAS,QAAQ,gBAAgB;AAClE;AAAA,EACE;AAAA,EACA,eAAe;AAAA,EACf;AAAA,EACA;AAAA,OAKK;AAKP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AASP,SAAS,wBACP,OACA,aACQ;AACR,SAAO,wBAAwB,OAAO,WAAmG;AAC3I;AAGO,IAAM,qBAAqB;AAoElC,SAAS,SACP,UACA,IACA,OACA,SACe;AACf,QAAM,aAAa,SAAS,eAAe,QAAQ,cAAc,EAAE,IAAI;AACvE,QAAM,MAAM,cAAc,IAAI,UAAU;AACxC,QAAM,OAAgC,CAAC;AACvC,QAAM,QAAiB,SAAS;AAChC,MAAI,OAAO,UAAU,YAAY,UAAU,KAAM,QAAO,OAAO,MAAM,KAAK;AAC1E,QAAM,WAAW,SAAS;AAC1B,MAAI,SAAU,MAAK,kBAAkB,IAAI,wBAAgC,KAAK,MAAM,QAAQ;AAC5F,eAAa,UAAU,IAAI,YAAY,IAAI;AAC3C,SAAO,EAAE,WAAW,IAAI,YAAY,OAAO,MAAM,cAAc,UAAU,IAAI,UAAU,EAAE;AAC3F;AAGA,SAAS,cAAc,MAAiD;AACtE,MAAI;AACF,WAAO,KAAK,UAAU,MAAM,CAAC,MAAM,UAAoB,OAAO,UAAU,aAAa,SAAY,KAAM;AAAA,EACzG,QAAQ;AACN,WAAO,OAAO,KAAK,IAAI,CAAC;AAAA,EAC1B;AACF;AAUO,SAAS,gBAAoH;AAClI,SAAO,SAAS,OACd,MAC6C;AAC7C,UAAM,KAAK,KAAK;AAChB,UAAM,QAAQ,KAAK,aAAa;AAEhC,UAAM,OAAuB;AAE7B,aAAS,YAAyC;AAChD,YAAM,WAAW,kBAAkB;AACnC,aAAO,YAAY,CAAC,YAAY,SAAS,UAAU,IAAI,OAAO,OAAO,GAAG,CAAC,QAAQ,CAAC;AAAA,IACpF;AAEA,aAAS,UAAU,aAAqB,qBAA8B;AACpE,aAAO,kBAAkB,CAAC,UAAU,oBAAoB,OAAO,IAAI,UAAU,CAAC;AAAA,IAChF;AAEA,aAAS,WAA0C;AACjD,YAAM,WAAW,kBAAkB;AACnC,aAAO,YAAY,CAAC,eAAwB,cAAc,UAAU,IAAI,cAAc,mBAAmB,GAAG,CAAC,QAAQ,CAAC;AAAA,IACxH;AAEA,aAAS,UAAkC;AACzC,YAAM,WAAW,2BAA2B;AAC5C,YAAM,YAAY,UAAU,cAAc,KAAK,SAAS,UAAU,kBAAkB,IAAI;AACxF,aAAO;AAAA,QACL,CAAC,OAAO,YAAY;AAClB,cAAI,OAAO,cAAc,SAAU,uBAAsB,WAAW,OAAO,OAAO;AAAA,QACpF;AAAA,QACA,CAAC,SAAS;AAAA,MACZ;AAAA,IACF;AAEA,aAAS,WAAW,OAAmD;AACrE,YAAM,WAAW,kBAAkB;AACnC,YAAM,CAAC,aAAa,IAAI,SAAS,MAAO,QAAQ,cAAc,EAAE,IAAI,mBAAoB;AACxF,YAAM,aAAa,MAAM,cAAc;AAEvC,YAAM,cAAc,OAAO,MAAM,QAAQ;AACzC,kBAAY,UAAU,MAAM;AAC5B,YAAM,cAAc,MAAM,aAAa;AAEvC,YAAM,OAAO,QAAQ,MAAM;AACzB,cAAM,MAA+B,CAAC;AACtC,mBAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,KAAK,GAAG;AAChD,cAAI,QAAQ,gBAAgB,QAAQ,WAAY,KAAI,GAAG,IAAI;AAAA,QAC7D;AACA,eAAO;AAAA,MACT,GAAG,CAAC,KAAK,CAAC;AACV,YAAM,YAAY,cAAc,IAAI;AACpC,YAAM,UAAU,OAAO,IAAI;AAC3B,cAAQ,UAAU;AAElB,gBAAU,MAAM;AACd,cAAM,MAAmB,cAAc,IAAI,UAAU;AACrD,cAAM,OAAgC,EAAE,GAAG,QAAQ,QAAQ;AAC3D,YAAI,YAAa,MAAK,kBAAkB,IAAI,wBAAgC,KAAK,MAAM,YAAY,OAAO;AAC1G,qBAAa,UAAU,IAAI,YAAY,IAAI;AAC3C,eAAO,MAAM,cAAc,UAAU,IAAI,UAAU;AAAA,MACrD,GAAG,CAAC,UAAU,YAAY,WAAW,WAAW,CAAC;AAEjD,aAAO;AAAA,IACT;AACA,eAAW,cAAc,GAAG,EAAE;AAE9B,WAAO;AAAA,MACL,GAAG;AAAA,MACH;AAAA,MACA,OAAO,KAAK;AAAA,MACZ,UAAU,QAAQ,UAAU;AAAA,MAC5B,WAAW,KAAK,aAAa;AAAA,MAC7B;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
@@ -873,4 +873,4 @@ interface CreateSummonGateOptions {
|
|
|
873
873
|
}
|
|
874
874
|
declare function createSummonGate(options?: CreateSummonGateOptions): SummonGate;
|
|
875
875
|
|
|
876
|
-
export {
|
|
876
|
+
export { consoleErrorSink as $, type AnyOverlayMeta as A, type SummonGate as B, type CloseAllInstancesPayload as C, DEFAULT_INSTANCE_ID as D, type ErrorSinkPort as E, type SummonPorts as F, type Unsubscribe as G, type UrlSyncEntryPayload as H, type IdentityPort as I, allOverlayMeta as J, type KeepAlive as K, type LinkHydrateContext as L, type MobilePresentation as M, type NotifyOptions as N, type OpenInstanceView as O, type PruneStaleInstancesPayload as P, anonymousIdentity as Q, type RawOpenPayload as R, SUMMON_INSTALLED_ACTION as S, type ToggleOverlayPayload as T, type UnbiddenHomeRoute as U, arrangeActiveWindows$1 as V, type WindowPreservation as W, closeAllInstancesOfOverlay as X, closeAllOverlays as Y, closeOverlay as Z, closeOverlaysBoundToPage as _, type ArrangeActiveWindowsPayload as a, confirmWindowRestored as a$, consoleNotify as a0, createSummonGate as a1, debugOff as a2, defaultWindowIdFor as a3, ensureSummonRuntime as a4, focusWindow$1 as a5, getOverlayMeta as a6, getOverlayMetaByLinkKey as a7, installSummonCore as a8, instanceKey as a9, setOverlayStateValue as aA, subscribeSummonInstalled as aB, subscribeToOverlayRegistry as aC, toggleOverlay as aD, toggleWindowsHidden$1 as aE, unregisterSyncEntry as aF, updateWindowRect$1 as aG, type WindowManagerState as aH, type WindowEntry as aI, type WindowRect as aJ, type DockWindowPayload as aK, type GlobalLayoutType as aL, type HydratedWindowSession as aM, type PersistedWindowSession as aN, type PopoutMode as aO, TRAY_CHIP_H as aP, TRAY_CHIP_W as aQ, WINDOW_SESSION_SCHEMA_VERSION as aR, type WindowPersistenceRegistration as aS, type WindowPersistenceState as aT, type WindowState as aU, arrangeActiveWindows as aV, buildDockWindowPayload as aW, clampAllWindowRects as aX, clampWindowRect as aY, clearWindowPersistenceState as aZ, computeGlobalArrangement as a_, isRegisteredOverlay as aa, isSummonAction as ab, isSummonInstalled as ac, listOpenInstanceKeys as ad, locationRouter as ae, minimizeAll$1 as af, openOverlay as ag, overlayIdsBoundToPage as ah, parseInstanceKey as ai, prefetchSummonRuntime as aj, pruneStaleInstances as ak, registerOverlayMeta as al, registerSyncEntry as am, resetOverlayRegistry as an, resolvePorts as ao, restoreAll$1 as ap, restoreWindow$1 as aq, revealWindow$1 as ar, selectAllMinimized as as, selectAllWindows as at, selectAnyOverlayTouched as au, selectIsOverlayOpen as av, selectOpenInstances as aw, selectOverlay as ax, selectOverlayData as ay, selectWindowsHidden as az, type CloseOverlayPayload as b, discardPendingWindowSession as b0, dockWindow as b1, focusWindow as b2, getGrid12Rect as b3, getGrid4Rect as b4, getGrid6Rect as b5, getGrid8Rect as b6, getGrid9Rect as b7, getStackedLeft2Rect as b8, getStackedLeft3Rect as b9, selectPendingWindowRestores as bA, selectPopoutCandidateId as bB, selectPopoutMode as bC, selectPrePopoutRect as bD, selectTransientZIndex as bE, selectTraySlotWidth as bF, selectTrayWindows as bG, selectWindow as bH, selectWindowPersistence as bI, selectWindowRect as bJ, selectWindowState as bK, selectWindowTitle as bL, selectWindowZIndex as bM, selectWindowsHidden$1 as bN, setPopoutCandidate as bO, toggleWindowsHidden as bP, unregisterWindow as bQ, updateWindowPersistence as bR, updateWindowRect as bS, updateWindowTitle as bT, windowManagerReducer as bU, windowSessionKey as bV, getStackedLeft4Rect as ba, getStackedLeft5Rect as bb, getStackedRight2Rect as bc, getStackedRight3Rect as bd, getStackedRight4Rect as be, getStackedRight5Rect as bf, hydrateWindowSessions as bg, markWindowClosing as bh, maximizeWindow as bi, minimizeAll as bj, minimizeWindow as bk, moveTraySlot as bl, popOutWindow as bm, raiseTransientWindow as bn, recomputeTrayPositions as bo, registerWindow as bp, releaseTransientWindow as bq, restoreAll as br, restoreWindow as bs, restoreWindowState as bt, revealWindow as bu, selectActivePipWindowId as bv, selectAllMinimized$1 as bw, selectAllWindows$1 as bx, selectDockedWindows as by, selectIsPoppedOut as bz, type CloseOverlaysBoundToPagePayload as c, type CreateSummonGateOptions as d, DEFAULT_PORTS as e, type DebugPort as f, type InstanceKey as g, type InstanceMode as h, type NotifyPort as i, type OpenOverlayPayload as j, type OverlayDataOf as k, type OverlayDefinitionMeta as l, type OverlayHostDispatch as m, type OverlayId as n, type OverlayInstance as o, type OverlayLinkSpec as p, type OverlayPersistencePort as q, type OverlayRawData as r, type OverlayState as s, type OverlayWindowOptions as t, type RouterPort as u, SUMMON_SLICE_KEYS as v, type StateWithOverlays as w, type StoredValue as x, type SummonAction as y, type SummonCore as z };
|
|
@@ -873,4 +873,4 @@ interface CreateSummonGateOptions {
|
|
|
873
873
|
}
|
|
874
874
|
declare function createSummonGate(options?: CreateSummonGateOptions): SummonGate;
|
|
875
875
|
|
|
876
|
-
export {
|
|
876
|
+
export { consoleErrorSink as $, type AnyOverlayMeta as A, type SummonGate as B, type CloseAllInstancesPayload as C, DEFAULT_INSTANCE_ID as D, type ErrorSinkPort as E, type SummonPorts as F, type Unsubscribe as G, type UrlSyncEntryPayload as H, type IdentityPort as I, allOverlayMeta as J, type KeepAlive as K, type LinkHydrateContext as L, type MobilePresentation as M, type NotifyOptions as N, type OpenInstanceView as O, type PruneStaleInstancesPayload as P, anonymousIdentity as Q, type RawOpenPayload as R, SUMMON_INSTALLED_ACTION as S, type ToggleOverlayPayload as T, type UnbiddenHomeRoute as U, arrangeActiveWindows$1 as V, type WindowPreservation as W, closeAllInstancesOfOverlay as X, closeAllOverlays as Y, closeOverlay as Z, closeOverlaysBoundToPage as _, type ArrangeActiveWindowsPayload as a, confirmWindowRestored as a$, consoleNotify as a0, createSummonGate as a1, debugOff as a2, defaultWindowIdFor as a3, ensureSummonRuntime as a4, focusWindow$1 as a5, getOverlayMeta as a6, getOverlayMetaByLinkKey as a7, installSummonCore as a8, instanceKey as a9, setOverlayStateValue as aA, subscribeSummonInstalled as aB, subscribeToOverlayRegistry as aC, toggleOverlay as aD, toggleWindowsHidden$1 as aE, unregisterSyncEntry as aF, updateWindowRect$1 as aG, type WindowManagerState as aH, type WindowEntry as aI, type WindowRect as aJ, type DockWindowPayload as aK, type GlobalLayoutType as aL, type HydratedWindowSession as aM, type PersistedWindowSession as aN, type PopoutMode as aO, TRAY_CHIP_H as aP, TRAY_CHIP_W as aQ, WINDOW_SESSION_SCHEMA_VERSION as aR, type WindowPersistenceRegistration as aS, type WindowPersistenceState as aT, type WindowState as aU, arrangeActiveWindows as aV, buildDockWindowPayload as aW, clampAllWindowRects as aX, clampWindowRect as aY, clearWindowPersistenceState as aZ, computeGlobalArrangement as a_, isRegisteredOverlay as aa, isSummonAction as ab, isSummonInstalled as ac, listOpenInstanceKeys as ad, locationRouter as ae, minimizeAll$1 as af, openOverlay as ag, overlayIdsBoundToPage as ah, parseInstanceKey as ai, prefetchSummonRuntime as aj, pruneStaleInstances as ak, registerOverlayMeta as al, registerSyncEntry as am, resetOverlayRegistry as an, resolvePorts as ao, restoreAll$1 as ap, restoreWindow$1 as aq, revealWindow$1 as ar, selectAllMinimized as as, selectAllWindows as at, selectAnyOverlayTouched as au, selectIsOverlayOpen as av, selectOpenInstances as aw, selectOverlay as ax, selectOverlayData as ay, selectWindowsHidden as az, type CloseOverlayPayload as b, discardPendingWindowSession as b0, dockWindow as b1, focusWindow as b2, getGrid12Rect as b3, getGrid4Rect as b4, getGrid6Rect as b5, getGrid8Rect as b6, getGrid9Rect as b7, getStackedLeft2Rect as b8, getStackedLeft3Rect as b9, selectPendingWindowRestores as bA, selectPopoutCandidateId as bB, selectPopoutMode as bC, selectPrePopoutRect as bD, selectTransientZIndex as bE, selectTraySlotWidth as bF, selectTrayWindows as bG, selectWindow as bH, selectWindowPersistence as bI, selectWindowRect as bJ, selectWindowState as bK, selectWindowTitle as bL, selectWindowZIndex as bM, selectWindowsHidden$1 as bN, setPopoutCandidate as bO, toggleWindowsHidden as bP, unregisterWindow as bQ, updateWindowPersistence as bR, updateWindowRect as bS, updateWindowTitle as bT, windowManagerReducer as bU, windowSessionKey as bV, getStackedLeft4Rect as ba, getStackedLeft5Rect as bb, getStackedRight2Rect as bc, getStackedRight3Rect as bd, getStackedRight4Rect as be, getStackedRight5Rect as bf, hydrateWindowSessions as bg, markWindowClosing as bh, maximizeWindow as bi, minimizeAll as bj, minimizeWindow as bk, moveTraySlot as bl, popOutWindow as bm, raiseTransientWindow as bn, recomputeTrayPositions as bo, registerWindow as bp, releaseTransientWindow as bq, restoreAll as br, restoreWindow as bs, restoreWindowState as bt, revealWindow as bu, selectActivePipWindowId as bv, selectAllMinimized$1 as bw, selectAllWindows$1 as bx, selectDockedWindows as by, selectIsPoppedOut as bz, type CloseOverlaysBoundToPagePayload as c, type CreateSummonGateOptions as d, DEFAULT_PORTS as e, type DebugPort as f, type InstanceKey as g, type InstanceMode as h, type NotifyPort as i, type OpenOverlayPayload as j, type OverlayDataOf as k, type OverlayDefinitionMeta as l, type OverlayHostDispatch as m, type OverlayId as n, type OverlayInstance as o, type OverlayLinkSpec as p, type OverlayPersistencePort as q, type OverlayRawData as r, type OverlayState as s, type OverlayWindowOptions as t, type RouterPort as u, SUMMON_SLICE_KEYS as v, type StateWithOverlays as w, type StoredValue as x, type SummonAction as y, type SummonCore as z };
|
package/dist/handles.cjs
CHANGED
|
@@ -55,8 +55,10 @@ function newHandleId() {
|
|
|
55
55
|
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
// src/handles/
|
|
58
|
+
// src/handles/slot.ts
|
|
59
59
|
var HANDLES_SLOT = "ai-matrx.summon.handles";
|
|
60
|
+
|
|
61
|
+
// src/handles/callbackManager.ts
|
|
60
62
|
var handlesState = () => (0, import_global_slot.globalSlot)(HANDLES_SLOT, () => ({
|
|
61
63
|
callbacks: /* @__PURE__ */ new Map(),
|
|
62
64
|
groups: /* @__PURE__ */ new Map(),
|