@ai-matrx/summon 0.1.6 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -2
- package/dist/gate-DUvE-Cc1.d.cts +399 -0
- package/dist/gate-DUvE-Cc1.d.ts +399 -0
- package/dist/handles.cjs +1 -0
- package/dist/handles.cjs.map +1 -1
- package/dist/handles.d.cts +3 -61
- package/dist/handles.d.ts +3 -61
- package/dist/handles.js +1 -0
- package/dist/handles.js.map +1 -1
- package/dist/helpers-2NY1ha0V.d.cts +63 -0
- package/dist/helpers-2NY1ha0V.d.ts +63 -0
- package/dist/index.cjs +194 -159
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -355
- package/dist/index.d.ts +9 -355
- package/dist/index.js +200 -165
- package/dist/index.js.map +1 -1
- package/dist/instanceBody-CgZAFnic.d.cts +23 -0
- package/dist/instanceBody-CgZAFnic.d.ts +23 -0
- package/dist/open.cjs +408 -0
- package/dist/open.cjs.map +1 -0
- package/dist/open.d.cts +22 -0
- package/dist/open.d.ts +22 -0
- package/dist/open.js +375 -0
- package/dist/open.js.map +1 -0
- package/dist/persistence.cjs +27 -2
- package/dist/persistence.cjs.map +1 -1
- package/dist/persistence.js +28 -3
- package/dist/persistence.js.map +1 -1
- package/dist/react.cjs +249 -352
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +11 -151
- package/dist/react.d.ts +11 -151
- package/dist/react.js +210 -306
- package/dist/react.js.map +1 -1
- package/dist/root.cjs +277 -0
- package/dist/root.cjs.map +1 -0
- package/dist/root.d.cts +175 -0
- package/dist/root.d.ts +175 -0
- package/dist/root.js +254 -0
- package/dist/root.js.map +1 -0
- package/dist/window-host.cjs +11 -2
- package/dist/window-host.cjs.map +1 -1
- package/dist/window-host.d.cts +1 -0
- package/dist/window-host.d.ts +1 -0
- package/dist/window-host.js +11 -2
- package/dist/window-host.js.map +1 -1
- package/dist/window.cjs +2 -1
- package/dist/window.cjs.map +1 -1
- package/dist/window.d.cts +3 -2
- package/dist/window.d.ts +3 -2
- package/dist/window.js +2 -1
- package/dist/window.js.map +1 -1
- package/package.json +26 -3
package/dist/handles.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export { E as EventChannel, H as HandleDisposedError, O as OwnerOption, P as PendingRequest, R as RequestHandle, c as createEventChannel, a as createRequest, g as getEventChannel, b as getHandle, d as getRequest, r as registerHandle, e as removeHandle } from './helpers-2NY1ha0V.js';
|
|
2
|
+
|
|
1
3
|
type CallbackContext = Record<string, unknown>;
|
|
2
4
|
interface ProgressInfo {
|
|
3
5
|
progress?: number;
|
|
@@ -100,67 +102,7 @@ declare const callbackManager: CallbackManager;
|
|
|
100
102
|
/** Remove everything owned by an open instance (`overlayId:instanceId`). */
|
|
101
103
|
declare function disposeOwner(owner: string): number;
|
|
102
104
|
|
|
103
|
-
interface OwnerOption {
|
|
104
|
-
/** The InstanceKey (`overlayId:instanceId`) that owns this handle; disposed when it closes. */
|
|
105
|
-
owner?: string;
|
|
106
|
-
}
|
|
107
|
-
/** Thrown into a request's promise when it is disposed before being answered. */
|
|
108
|
-
declare class HandleDisposedError extends Error {
|
|
109
|
-
readonly handleId: string;
|
|
110
|
-
constructor(handleId: string, message?: string);
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Register an imperative object handle under a caller-chosen id (an editor API, a widget handle,
|
|
114
|
-
* a ref's methods). Re-registering an id replaces the previous handle. Returns a disposer that
|
|
115
|
-
* removes the handle only if it is still the one registered (safe for React effect cleanup).
|
|
116
|
-
*/
|
|
117
|
-
declare function registerHandle<T extends object>(id: string, handle: T, options?: OwnerOption): () => void;
|
|
118
|
-
/** The object handle registered under `id`, or undefined. */
|
|
119
|
-
declare function getHandle<T extends object>(id: string): T | undefined;
|
|
120
|
-
/** Remove the handle registered under `id`. */
|
|
121
|
-
declare function removeHandle(id: string): void;
|
|
122
|
-
interface EventChannel<Events> {
|
|
123
|
-
readonly id: string;
|
|
124
|
-
/** Deliver an event to every subscriber (no-op after dispose). */
|
|
125
|
-
emit(event: Events): void;
|
|
126
|
-
/** Listen; returns the unsubscribe. */
|
|
127
|
-
subscribe(listener: (event: Events) => void): () => void;
|
|
128
|
-
/** Remove the channel and drop every subscriber. */
|
|
129
|
-
dispose(): void;
|
|
130
|
-
readonly disposed: boolean;
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* A many-shot event stream between an opener and an overlay. Pass `channel.id` in open data; the
|
|
134
|
-
* overlay resolves it with `getEventChannel(id)`.
|
|
135
|
-
*/
|
|
136
|
-
declare function createEventChannel<Events>(options?: OwnerOption): EventChannel<Events>;
|
|
137
|
-
/** The channel registered under `id`, or undefined once disposed. */
|
|
138
|
-
declare function getEventChannel<Events>(id: string): EventChannel<Events> | undefined;
|
|
139
|
-
interface PendingRequest<Req, Res> {
|
|
140
|
-
readonly id: string;
|
|
141
|
-
/** What the asker sent. */
|
|
142
|
-
readonly request: Req;
|
|
143
|
-
/** Answer the request (first answer wins; later calls are ignored). */
|
|
144
|
-
resolve(response: Res): void;
|
|
145
|
-
/** Fail the request. */
|
|
146
|
-
reject(reason: unknown): void;
|
|
147
|
-
readonly settled: boolean;
|
|
148
|
-
}
|
|
149
|
-
interface RequestHandle<Req, Res> extends PendingRequest<Req, Res> {
|
|
150
|
-
/** Settles with the answer; rejects with `HandleDisposedError` when disposed unanswered. */
|
|
151
|
-
readonly promise: Promise<Res>;
|
|
152
|
-
/** Remove the request; an unanswered one rejects. */
|
|
153
|
-
dispose(): void;
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* A one-shot promise bridge: the asker awaits `promise`, the overlay answers through
|
|
157
|
-
* `getRequest(id).resolve(…)`. Disposing it unanswered (or closing its owner) rejects.
|
|
158
|
-
*/
|
|
159
|
-
declare function createRequest<Req, Res>(request: Req, options?: OwnerOption): RequestHandle<Req, Res>;
|
|
160
|
-
/** The pending request registered under `id`, or undefined once answered or disposed. */
|
|
161
|
-
declare function getRequest<Req, Res>(id: string): PendingRequest<Req, Res> | undefined;
|
|
162
|
-
|
|
163
105
|
/** A fresh handle id: `crypto.randomUUID` when present, else a v4 UUID from `getRandomValues`. */
|
|
164
106
|
declare function newHandleId(): string;
|
|
165
107
|
|
|
166
|
-
export { type Callback, type CallbackContext, CallbackManager,
|
|
108
|
+
export { type Callback, type CallbackContext, CallbackManager, HANDLES_SLOT, type HandleSlot, type ProgressInfo, type RegisterOptions, type TriggerOptions, callbackManager, disposeOwner, newHandleId };
|
package/dist/handles.js
CHANGED
package/dist/handles.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/handles/callbackManager.ts","../src/handles/ids.ts","../src/handles/helpers.ts"],"sourcesContent":["/**\n * The handles registry — everything that cannot travel through Redux (callbacks, event channels,\n * one-shot requests, imperative object handles) lives here under a string id; only the id goes\n * into overlay open data.\n *\n * Successor of `@ai-matrx/chat` `utils/callbackManager.ts` with the SAME public verbs and types, so\n * moving a caller is an import-path swap. Changes (CHANGELOG 0.1.0):\n * 1. State lives in the global slot \"ai-matrx.summon.handles\", never in module scope: a\n * duplicated module graph (ESM + CJS, unsplit bundles, two packages) sees one registry.\n * 2. Removal bug fixed: `trigger` / `triggerWithContext` / `remove` deleted the entry BEFORE\n * `removeFromGroups` read it, so group membership never shrank and emptied groups were never\n * dropped. Removal now reads the entry first, in one place (`deleteEntry`).\n * 3. Owner scoping: `registerWithContext(cb, { owner })` (an InstanceKey `overlayId:instanceId`)\n * ties the entry to an open overlay instance; `disposeOwner(owner)` removes everything it\n * owns. The overlays close middleware calls it, so no opener disposes by hand.\n * 4. The object slot is handle-agnostic: `registerWidgetHandle<H extends object>(handle)` stores\n * any object (no chat `WidgetHandle` import).\n * 5. Ids come from `crypto.randomUUID` (no `uuid` dependency), with a fallback for insecure\n * contexts where `randomUUID` is absent.\n *\n * Framework-free: no React, no Redux.\n */\nimport { globalSlot } from \"@ai-matrx/kit/global-slot\";\nimport { newHandleId } from \"./ids\";\n\nexport type CallbackContext = Record<string, unknown>;\n\nexport interface ProgressInfo {\n progress?: number;\n status?: \"pending\" | \"running\" | \"completed\" | \"error\";\n error?: Error;\n}\n\nexport type Callback<T = unknown, C extends CallbackContext = CallbackContext> = (\n data: T,\n context?: C,\n) => void | Promise<void>;\n\n/** What an entry's slot holds: a callback, or an object handle retrieved with `get`. */\nexport type HandleSlot = Callback<never, never> | object;\n\nexport interface RegisterOptions<C extends CallbackContext = CallbackContext> {\n context?: C;\n groupId?: string;\n /** The InstanceKey (`overlayId:instanceId`) that owns this entry; disposed when it closes. */\n owner?: string;\n}\n\nexport interface TriggerOptions<C extends CallbackContext = CallbackContext> {\n context?: C;\n progress?: ProgressInfo;\n removeAfterTrigger?: boolean;\n}\n\n/** A registry entry. `callback` is the heterogeneous slot (function or object handle). */\ninterface CallbackEntry {\n callback: HandleSlot;\n context?: CallbackContext;\n groupId?: string;\n owner?: string;\n listeners?: Array<Callback<never, never>>;\n /** Runs once when the entry leaves the registry for any reason (requests reject here). */\n onRemove?: () => void;\n}\n\ninterface HandlesState {\n readonly callbacks: Map<string, CallbackEntry>;\n readonly groups: Map<string, Set<string>>;\n readonly owners: Map<string, Set<string>>;\n readonly registryListeners: Set<() => void>;\n}\n\nexport const HANDLES_SLOT = \"ai-matrx.summon.handles\";\n\nconst handlesState = (): HandlesState =>\n globalSlot<HandlesState>(HANDLES_SLOT, () => ({\n callbacks: new Map(),\n groups: new Map(),\n owners: new Map(),\n registryListeners: new Set(),\n }));\n\n/** Invoke a slot as a callback (a function slot only; object handles are never invoked). */\nfunction invoke(slot: HandleSlot, data: unknown, context?: CallbackContext): void | Promise<void> {\n if (typeof slot !== \"function\") return undefined;\n return (slot as Callback<unknown, CallbackContext>)(data, context);\n}\n\nfunction invokeListener(listener: Callback<never, never>, data: unknown, context?: CallbackContext): void | Promise<void> {\n return (listener as Callback<unknown, CallbackContext>)(data, context);\n}\n\n/** Internal registration options beyond the public ones (used by the typed helpers). */\nexport interface InternalRegisterOptions extends RegisterOptions {\n id?: string;\n onRemove?: () => void;\n}\n\nexport class CallbackManager {\n private get s(): HandlesState {\n return handlesState();\n }\n\n /**\n * Observe the registry itself: `listener` runs after any entry is added or removed. This lets a\n * view that resolves ids with `get` re-render when an id goes away (`useSyncExternalStore`).\n */\n subscribeToRegistry(listener: () => void): () => void {\n const listeners = this.s.registryListeners;\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n }\n\n private notifyRegistry(): void {\n for (const listener of [...this.s.registryListeners]) listener();\n }\n\n /** Register a callback; returns its id. */\n register<T>(callback: Callback<T>): string {\n return this.registerEntry(callback as HandleSlot, {});\n }\n\n /** Register with optional context, group and owner. */\n registerWithContext<T, C extends CallbackContext = CallbackContext>(\n callback: Callback<T, C>,\n options: RegisterOptions<C> = {},\n ): string {\n return this.registerEntry(callback as HandleSlot, options);\n }\n\n /** @internal The one insertion path (typed helpers pass a fixed id and a removal hook). */\n registerEntry(slot: HandleSlot, options: InternalRegisterOptions): string {\n const s = this.s;\n const callbackId = options.id ?? newHandleId();\n if (s.callbacks.has(callbackId)) this.deleteEntry(callbackId, false);\n const entry: CallbackEntry = { callback: slot };\n if (options.context !== undefined) entry.context = options.context;\n if (options.groupId !== undefined) entry.groupId = options.groupId;\n if (options.owner !== undefined) entry.owner = options.owner;\n if (options.onRemove !== undefined) entry.onRemove = options.onRemove;\n s.callbacks.set(callbackId, entry);\n\n if (options.groupId !== undefined) {\n const group = s.groups.get(options.groupId) ?? new Set<string>();\n group.add(callbackId);\n s.groups.set(options.groupId, group);\n }\n if (options.owner !== undefined) {\n const owned = s.owners.get(options.owner) ?? new Set<string>();\n owned.add(callbackId);\n s.owners.set(options.owner, owned);\n }\n this.notifyRegistry();\n return callbackId;\n }\n\n /** Subscribe to results for a callback id. */\n subscribe<T, C extends CallbackContext = CallbackContext>(callbackId: string, listener: Callback<T, C>): boolean {\n const entry = this.s.callbacks.get(callbackId);\n if (!entry) return false;\n (entry.listeners ??= []).push(listener as Callback<never, never>);\n return true;\n }\n\n /** Unsubscribe a listener from a callback id. */\n unsubscribe<T, C extends CallbackContext = CallbackContext>(callbackId: string, listener: Callback<T, C>): boolean {\n const entry = this.s.callbacks.get(callbackId);\n if (!entry || !entry.listeners) return false;\n const index = entry.listeners.indexOf(listener as Callback<never, never>);\n if (index === -1) return false;\n entry.listeners.splice(index, 1);\n return true;\n }\n\n /** Run a callback once, notify its listeners, then remove it. */\n trigger<T>(callbackId: string, data: T): void {\n const entry = this.s.callbacks.get(callbackId);\n if (!entry) return;\n void invoke(entry.callback, data);\n if (entry.listeners && entry.listeners.length > 0) {\n for (const listener of [...entry.listeners]) void invokeListener(listener, data);\n }\n this.deleteEntry(callbackId, true);\n }\n\n /** Trigger with merged context and progress; removes unless `removeAfterTrigger: false`. */\n triggerWithContext<T, C extends CallbackContext = CallbackContext>(\n callbackId: string,\n data: T,\n options?: TriggerOptions<C>,\n ): void {\n const entry = this.s.callbacks.get(callbackId);\n if (!entry) return;\n const mergedContext: CallbackContext = {\n ...entry.context,\n ...options?.context,\n ...(options?.progress && { progress: options.progress }),\n };\n void invoke(entry.callback, data, mergedContext);\n if (entry.listeners && entry.listeners.length > 0) {\n for (const listener of [...entry.listeners]) void invokeListener(listener, data, mergedContext);\n }\n if (options?.removeAfterTrigger !== false) this.deleteEntry(callbackId, true);\n }\n\n /** Trigger every callback in a group. */\n triggerGroup<T, C extends CallbackContext = CallbackContext>(groupId: string, data: T, options?: TriggerOptions<C>): void {\n const group = this.s.groups.get(groupId);\n if (!group) return;\n for (const callbackId of [...group]) this.triggerWithContext(callbackId, data, options);\n if (options?.removeAfterTrigger !== false) this.s.groups.delete(groupId);\n }\n\n /**\n * Run the one durable command registered for a group. A command is retained on rejection so its\n * caller can retry, and is removed only after its promise settles successfully.\n */\n async triggerGroupCommand<T, C extends CallbackContext = CallbackContext>(\n groupId: string,\n data: T,\n options?: { context?: C; removeAfterSuccess?: boolean },\n ): Promise<void> {\n const group = this.s.groups.get(groupId);\n const callbackIds = group ? [...group] : [];\n const callbackId = callbackIds[0];\n if (callbackIds.length !== 1 || callbackId === undefined) {\n throw new Error(`Expected exactly one command callback for group \"${groupId}\", found ${callbackIds.length}`);\n }\n const entry = this.s.callbacks.get(callbackId);\n if (!entry) throw new Error(`Command callback \"${callbackId}\" is no longer available`);\n\n const mergedContext: CallbackContext = { ...entry.context, ...options?.context };\n await invoke(entry.callback, data, mergedContext);\n\n // Observers never control command settlement: the command already acknowledged.\n for (const listener of entry.listeners ?? []) {\n try {\n await invokeListener(listener, data, mergedContext);\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error(\"[overlays/handles] command observer failed\", error);\n }\n }\n\n if (options?.removeAfterSuccess !== false) {\n this.deleteEntry(callbackId, true);\n this.s.groups.delete(groupId);\n }\n }\n\n /** Report progress to a callback (or every callback of a group) without removing it. */\n updateProgress(\n id: string,\n progress: number,\n options?: { status?: ProgressInfo[\"status\"]; error?: Error; groupId?: boolean },\n ): void {\n const progressInfo: ProgressInfo = { progress, status: options?.status || \"running\" };\n if (options?.error !== undefined) progressInfo.error = options.error;\n if (options?.groupId) {\n this.triggerGroup(id, null, { progress: progressInfo, removeAfterTrigger: false });\n } else {\n this.triggerWithContext(id, null, { progress: progressInfo, removeAfterTrigger: false });\n }\n }\n\n /** Create a new, empty group and return its id. */\n createGroup(): string {\n const groupId = newHandleId();\n this.s.groups.set(groupId, new Set());\n return groupId;\n }\n\n /** Remove one entry (and its group/owner membership). */\n remove(callbackId: string): void {\n this.deleteEntry(callbackId, true);\n }\n\n /** Alias of `remove` — the preferred name when unregistering a handle on unmount. */\n unregister(callbackId: string): void {\n this.remove(callbackId);\n }\n\n /** The stored callback or object handle for an id, without invoking it. */\n get<T = unknown>(callbackId: string): T | undefined {\n return this.s.callbacks.get(callbackId)?.callback as T | undefined;\n }\n\n /** True when the id is registered. */\n has(callbackId: string): boolean {\n return this.s.callbacks.has(callbackId);\n }\n\n /**\n * Register an object handle (a widget handle, an editor API, …). The object occupies the slot;\n * it is never invoked by `trigger`, only retrieved with `get`.\n */\n registerWidgetHandle<H extends object>(handle: H, options: { owner?: string } = {}): string {\n return this.registerEntry(handle, options.owner === undefined ? {} : { owner: options.owner });\n }\n\n /** Remove a group and all its callbacks. */\n removeGroup(groupId: string): void {\n const s = this.s;\n const group = s.groups.get(groupId);\n if (!group) return;\n s.groups.delete(groupId);\n for (const callbackId of [...group]) this.deleteEntry(callbackId, false);\n this.notifyRegistry();\n }\n\n /** Remove everything registered with `owner` (an InstanceKey). Returns how many were removed. */\n disposeOwner(owner: string): number {\n const s = this.s;\n const owned = s.owners.get(owner);\n if (!owned) return 0;\n s.owners.delete(owner);\n const ids = [...owned];\n for (const callbackId of ids) this.deleteEntry(callbackId, false);\n if (ids.length > 0) this.notifyRegistry();\n return ids.length;\n }\n\n /** Ids currently owned by `owner`. */\n ownedBy(owner: string): readonly string[] {\n return [...(this.s.owners.get(owner) ?? [])];\n }\n\n /** The member ids of a group (empty when unknown). */\n groupMembers(groupId: string): readonly string[] {\n return [...(this.s.groups.get(groupId) ?? [])];\n }\n\n /** Total registered entries (diagnostics, leak tests). */\n size(): number {\n return this.s.callbacks.size;\n }\n\n /**\n * The one removal path. Reads the entry BEFORE deleting it so group and owner membership shrink\n * (the old `removeFromGroups`-after-delete bug), then runs the entry's removal hook.\n */\n private deleteEntry(callbackId: string, notify: boolean): void {\n const s = this.s;\n const entry = s.callbacks.get(callbackId);\n if (!entry) return;\n s.callbacks.delete(callbackId);\n if (entry.groupId !== undefined) {\n const group = s.groups.get(entry.groupId);\n group?.delete(callbackId);\n if (group?.size === 0) s.groups.delete(entry.groupId);\n }\n if (entry.owner !== undefined) {\n const owned = s.owners.get(entry.owner);\n owned?.delete(callbackId);\n if (owned?.size === 0) s.owners.delete(entry.owner);\n }\n if (notify) this.notifyRegistry();\n entry.onRemove?.();\n }\n}\n\n/** The process-wide handles registry (state in the global slot; every instance shares it). */\nexport const callbackManager = new CallbackManager();\n\n/** Remove everything owned by an open instance (`overlayId:instanceId`). */\nexport function disposeOwner(owner: string): number {\n return callbackManager.disposeOwner(owner);\n}\n","/** A fresh handle id: `crypto.randomUUID` when present, else a v4 UUID from `getRandomValues`. */\nexport function newHandleId(): string {\n const c: Crypto | undefined = typeof globalThis.crypto === \"undefined\" ? undefined : globalThis.crypto;\n if (c && typeof c.randomUUID === \"function\") return c.randomUUID();\n const bytes = new Uint8Array(16);\n if (c && typeof c.getRandomValues === \"function\") {\n c.getRandomValues(bytes);\n } else {\n for (let i = 0; i < 16; i += 1) bytes[i] = Math.floor(Math.random() * 256);\n }\n bytes[6] = ((bytes[6] ?? 0) & 0x0f) | 0x40;\n bytes[8] = ((bytes[8] ?? 0) & 0x3f) | 0x80;\n const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, \"0\")).join(\"\");\n return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;\n}\n","/**\n * Typed helpers over the handles registry: imperative object handles, event channels and one-shot\n * requests. Each is stored in the same registry (so its id can ride overlay open data and `get`\n * still resolves it) and accepts an `owner` InstanceKey so closing the owning overlay disposes it.\n */\nimport { callbackManager } from \"./callbackManager\";\n\nexport interface OwnerOption {\n /** The InstanceKey (`overlayId:instanceId`) that owns this handle; disposed when it closes. */\n owner?: string;\n}\n\n/** Thrown into a request's promise when it is disposed before being answered. */\nexport class HandleDisposedError extends Error {\n readonly handleId: string;\n constructor(handleId: string, message = `[overlays/handles] \"${handleId}\" was disposed before it settled`) {\n super(message);\n this.name = \"HandleDisposedError\";\n this.handleId = handleId;\n }\n}\n\nfunction ownerOptions(options: OwnerOption | undefined): { owner?: string } {\n return options?.owner === undefined ? {} : { owner: options.owner };\n}\n\n// ── Imperative object handles ────────────────────────────────────────────────────────────────\n\n/**\n * Register an imperative object handle under a caller-chosen id (an editor API, a widget handle,\n * a ref's methods). Re-registering an id replaces the previous handle. Returns a disposer that\n * removes the handle only if it is still the one registered (safe for React effect cleanup).\n */\nexport function registerHandle<T extends object>(id: string, handle: T, options?: OwnerOption): () => void {\n callbackManager.registerEntry(handle, { id, ...ownerOptions(options) });\n return () => {\n if (callbackManager.get<T>(id) === handle) callbackManager.remove(id);\n };\n}\n\n/** The object handle registered under `id`, or undefined. */\nexport function getHandle<T extends object>(id: string): T | undefined {\n const value = callbackManager.get<unknown>(id);\n return typeof value === \"object\" && value !== null ? (value as T) : undefined;\n}\n\n/** Remove the handle registered under `id`. */\nexport function removeHandle(id: string): void {\n callbackManager.remove(id);\n}\n\n// ── Event channels ───────────────────────────────────────────────────────────────────────────\n\nexport interface EventChannel<Events> {\n readonly id: string;\n /** Deliver an event to every subscriber (no-op after dispose). */\n emit(event: Events): void;\n /** Listen; returns the unsubscribe. */\n subscribe(listener: (event: Events) => void): () => void;\n /** Remove the channel and drop every subscriber. */\n dispose(): void;\n readonly disposed: boolean;\n}\n\n/**\n * A many-shot event stream between an opener and an overlay. Pass `channel.id` in open data; the\n * overlay resolves it with `getEventChannel(id)`.\n */\nexport function createEventChannel<Events>(options?: OwnerOption): EventChannel<Events> {\n const listeners = new Set<(event: Events) => void>();\n let disposed = false;\n let id = \"\";\n const channel: EventChannel<Events> = {\n get id() {\n return id;\n },\n get disposed() {\n return disposed;\n },\n emit(event) {\n if (disposed) return;\n for (const listener of [...listeners]) listener(event);\n },\n subscribe(listener) {\n if (disposed) return () => {};\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n dispose() {\n if (disposed) return;\n callbackManager.remove(id);\n },\n };\n id = callbackManager.registerEntry(channel, {\n ...ownerOptions(options),\n onRemove: () => {\n disposed = true;\n listeners.clear();\n },\n });\n return channel;\n}\n\n/** The channel registered under `id`, or undefined once disposed. */\nexport function getEventChannel<Events>(id: string): EventChannel<Events> | undefined {\n return getHandle<EventChannel<Events>>(id);\n}\n\n// ── One-shot requests ────────────────────────────────────────────────────────────────────────\n\nexport interface PendingRequest<Req, Res> {\n readonly id: string;\n /** What the asker sent. */\n readonly request: Req;\n /** Answer the request (first answer wins; later calls are ignored). */\n resolve(response: Res): void;\n /** Fail the request. */\n reject(reason: unknown): void;\n readonly settled: boolean;\n}\n\nexport interface RequestHandle<Req, Res> extends PendingRequest<Req, Res> {\n /** Settles with the answer; rejects with `HandleDisposedError` when disposed unanswered. */\n readonly promise: Promise<Res>;\n /** Remove the request; an unanswered one rejects. */\n dispose(): void;\n}\n\n/**\n * A one-shot promise bridge: the asker awaits `promise`, the overlay answers through\n * `getRequest(id).resolve(…)`. Disposing it unanswered (or closing its owner) rejects.\n */\nexport function createRequest<Req, Res>(request: Req, options?: OwnerOption): RequestHandle<Req, Res> {\n let settle!: (response: Res) => void;\n let fail!: (reason: unknown) => void;\n const promise = new Promise<Res>((resolve, reject) => {\n settle = resolve;\n fail = reject;\n });\n // A disposed request nobody awaited must not surface as an unhandled rejection.\n promise.catch(() => {});\n let settled = false;\n let id = \"\";\n const handle: RequestHandle<Req, Res> = {\n get id() {\n return id;\n },\n request,\n promise,\n get settled() {\n return settled;\n },\n resolve(response) {\n if (settled) return;\n settled = true;\n settle(response);\n callbackManager.remove(id);\n },\n reject(reason) {\n if (settled) return;\n settled = true;\n fail(reason);\n callbackManager.remove(id);\n },\n dispose() {\n callbackManager.remove(id);\n },\n };\n id = callbackManager.registerEntry(handle, {\n ...ownerOptions(options),\n onRemove: () => {\n if (settled) return;\n settled = true;\n fail(new HandleDisposedError(id));\n },\n });\n return handle;\n}\n\n/** The pending request registered under `id`, or undefined once answered or disposed. */\nexport function getRequest<Req, Res>(id: string): PendingRequest<Req, Res> | undefined {\n return getHandle<RequestHandle<Req, Res>>(id);\n}\n"],"mappings":";AAsBA,SAAS,kBAAkB;;;ACrBpB,SAAS,cAAsB;AACpC,QAAM,IAAwB,OAAO,WAAW,WAAW,cAAc,SAAY,WAAW;AAChG,MAAI,KAAK,OAAO,EAAE,eAAe,WAAY,QAAO,EAAE,WAAW;AACjE,QAAM,QAAQ,IAAI,WAA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a,OAAO;AAAA,IACvB,UAAU,MAAM;AACd,iBAAW;AACX,gBAAU,MAAM;AAAA,IAClB;AAAA,EACF,CAAC;AACD,SAAO;AACT;AAGO,SAAS,gBAAwB,IAA8C;AACpF,SAAO,UAAgC,EAAE;AAC3C;AA0BO,SAAS,cAAwB,SAAc,SAAgD;AACpG,MAAI;AACJ,MAAI;AACJ,QAAM,UAAU,IAAI,QAAa,CAAC,SAAS,WAAW;AACpD,aAAS;AACT,WAAO;AAAA,EACT,CAAC;AAED,UAAQ,MAAM,MAAM;AAAA,EAAC,CAAC;AACtB,MAAI,UAAU;AACd,MAAI,KAAK;AACT,QAAM,SAAkC;AAAA,IACtC,IAAI,KAAK;AACP,aAAO;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA,IAAI,UAAU;AACZ,aAAO;AAAA,IACT;AAAA,IACA,QAAQ,UAAU;AAChB,UAAI,QAAS;AACb,gBAAU;AACV,aAAO,QAAQ;AACf,sBAAgB,OAAO,EAAE;AAAA,IAC3B;AAAA,IACA,OAAO,QAAQ;AACb,UAAI,QAAS;AACb,gBAAU;AACV,WAAK,MAAM;AACX,sBAAgB,OAAO,EAAE;AAAA,IAC3B;AAAA,IACA,UAAU;AACR,sBAAgB,OAAO,EAAE;AAAA,IAC3B;AAAA,EACF;AACA,OAAK,gBAAgB,cAAc,QAAQ;AAAA,IACzC,GAAG,aAAa,OAAO;AAAA,IACvB,UAAU,MAAM;AACd,UAAI,QAAS;AACb,gBAAU;AACV,WAAK,IAAI,oBAAoB,EAAE,CAAC;AAAA,IAClC;AAAA,EACF,CAAC;AACD,SAAO;AACT;AAGO,SAAS,WAAqB,IAAkD;AACrF,SAAO,UAAmC,EAAE;AAC9C;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/handles/callbackManager.ts","../src/handles/ids.ts","../src/handles/helpers.ts"],"sourcesContent":["/**\n * The handles registry — everything that cannot travel through Redux (callbacks, event channels,\n * one-shot requests, imperative object handles) lives here under a string id; only the id goes\n * into overlay open data.\n *\n * Successor of `@ai-matrx/chat` `utils/callbackManager.ts` with the SAME public verbs and types, so\n * moving a caller is an import-path swap. Changes (CHANGELOG 0.1.0):\n * 1. State lives in the global slot \"ai-matrx.summon.handles\", never in module scope: a\n * duplicated module graph (ESM + CJS, unsplit bundles, two packages) sees one registry.\n * 2. Removal bug fixed: `trigger` / `triggerWithContext` / `remove` deleted the entry BEFORE\n * `removeFromGroups` read it, so group membership never shrank and emptied groups were never\n * dropped. Removal now reads the entry first, in one place (`deleteEntry`).\n * 3. Owner scoping: `registerWithContext(cb, { owner })` (an InstanceKey `overlayId:instanceId`)\n * ties the entry to an open overlay instance; `disposeOwner(owner)` removes everything it\n * owns. The overlays close middleware calls it, so no opener disposes by hand.\n * 4. The object slot is handle-agnostic: `registerWidgetHandle<H extends object>(handle)` stores\n * any object (no chat `WidgetHandle` import).\n * 5. Ids come from `crypto.randomUUID` (no `uuid` dependency), with a fallback for insecure\n * contexts where `randomUUID` is absent.\n *\n * Framework-free: no React, no Redux.\n */\nimport { globalSlot } from \"@ai-matrx/kit/global-slot\";\nimport { newHandleId } from \"./ids\";\n\nexport type CallbackContext = Record<string, unknown>;\n\nexport interface ProgressInfo {\n progress?: number;\n status?: \"pending\" | \"running\" | \"completed\" | \"error\";\n error?: Error;\n}\n\nexport type Callback<T = unknown, C extends CallbackContext = CallbackContext> = (\n data: T,\n context?: C,\n) => void | Promise<void>;\n\n/** What an entry's slot holds: a callback, or an object handle retrieved with `get`. */\nexport type HandleSlot = Callback<never, never> | object;\n\nexport interface RegisterOptions<C extends CallbackContext = CallbackContext> {\n context?: C;\n groupId?: string;\n /** The InstanceKey (`overlayId:instanceId`) that owns this entry; disposed when it closes. */\n owner?: string;\n}\n\nexport interface TriggerOptions<C extends CallbackContext = CallbackContext> {\n context?: C;\n progress?: ProgressInfo;\n removeAfterTrigger?: boolean;\n}\n\n/** A registry entry. `callback` is the heterogeneous slot (function or object handle). */\ninterface CallbackEntry {\n callback: HandleSlot;\n context?: CallbackContext;\n groupId?: string;\n owner?: string;\n listeners?: Array<Callback<never, never>>;\n /** Runs once when the entry leaves the registry for any reason (requests reject here). */\n onRemove?: () => void;\n}\n\ninterface HandlesState {\n readonly callbacks: Map<string, CallbackEntry>;\n readonly groups: Map<string, Set<string>>;\n readonly owners: Map<string, Set<string>>;\n readonly registryListeners: Set<() => void>;\n}\n\nexport const HANDLES_SLOT = \"ai-matrx.summon.handles\";\n\nconst handlesState = (): HandlesState =>\n globalSlot<HandlesState>(HANDLES_SLOT, () => ({\n callbacks: new Map(),\n groups: new Map(),\n owners: new Map(),\n registryListeners: new Set(),\n }));\n\n/** Invoke a slot as a callback (a function slot only; object handles are never invoked). */\nfunction invoke(slot: HandleSlot, data: unknown, context?: CallbackContext): void | Promise<void> {\n if (typeof slot !== \"function\") return undefined;\n return (slot as Callback<unknown, CallbackContext>)(data, context);\n}\n\nfunction invokeListener(listener: Callback<never, never>, data: unknown, context?: CallbackContext): void | Promise<void> {\n return (listener as Callback<unknown, CallbackContext>)(data, context);\n}\n\n/** Internal registration options beyond the public ones (used by the typed helpers). */\nexport interface InternalRegisterOptions extends RegisterOptions {\n id?: string;\n onRemove?: () => void;\n}\n\nexport class CallbackManager {\n private get s(): HandlesState {\n return handlesState();\n }\n\n /**\n * Observe the registry itself: `listener` runs after any entry is added or removed. This lets a\n * view that resolves ids with `get` re-render when an id goes away (`useSyncExternalStore`).\n */\n subscribeToRegistry(listener: () => void): () => void {\n const listeners = this.s.registryListeners;\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n }\n\n private notifyRegistry(): void {\n for (const listener of [...this.s.registryListeners]) listener();\n }\n\n /** Register a callback; returns its id. */\n register<T>(callback: Callback<T>): string {\n return this.registerEntry(callback as HandleSlot, {});\n }\n\n /** Register with optional context, group and owner. */\n registerWithContext<T, C extends CallbackContext = CallbackContext>(\n callback: Callback<T, C>,\n options: RegisterOptions<C> = {},\n ): string {\n return this.registerEntry(callback as HandleSlot, options);\n }\n\n /** @internal The one insertion path (typed helpers pass a fixed id and a removal hook). */\n registerEntry(slot: HandleSlot, options: InternalRegisterOptions): string {\n const s = this.s;\n const callbackId = options.id ?? newHandleId();\n if (s.callbacks.has(callbackId)) this.deleteEntry(callbackId, false);\n const entry: CallbackEntry = { callback: slot };\n if (options.context !== undefined) entry.context = options.context;\n if (options.groupId !== undefined) entry.groupId = options.groupId;\n if (options.owner !== undefined) entry.owner = options.owner;\n if (options.onRemove !== undefined) entry.onRemove = options.onRemove;\n s.callbacks.set(callbackId, entry);\n\n if (options.groupId !== undefined) {\n const group = s.groups.get(options.groupId) ?? new Set<string>();\n group.add(callbackId);\n s.groups.set(options.groupId, group);\n }\n if (options.owner !== undefined) {\n const owned = s.owners.get(options.owner) ?? new Set<string>();\n owned.add(callbackId);\n s.owners.set(options.owner, owned);\n }\n this.notifyRegistry();\n return callbackId;\n }\n\n /** Subscribe to results for a callback id. */\n subscribe<T, C extends CallbackContext = CallbackContext>(callbackId: string, listener: Callback<T, C>): boolean {\n const entry = this.s.callbacks.get(callbackId);\n if (!entry) return false;\n (entry.listeners ??= []).push(listener as Callback<never, never>);\n return true;\n }\n\n /** Unsubscribe a listener from a callback id. */\n unsubscribe<T, C extends CallbackContext = CallbackContext>(callbackId: string, listener: Callback<T, C>): boolean {\n const entry = this.s.callbacks.get(callbackId);\n if (!entry || !entry.listeners) return false;\n const index = entry.listeners.indexOf(listener as Callback<never, never>);\n if (index === -1) return false;\n entry.listeners.splice(index, 1);\n return true;\n }\n\n /** Run a callback once, notify its listeners, then remove it. */\n trigger<T>(callbackId: string, data: T): void {\n const entry = this.s.callbacks.get(callbackId);\n if (!entry) return;\n void invoke(entry.callback, data);\n if (entry.listeners && entry.listeners.length > 0) {\n for (const listener of [...entry.listeners]) void invokeListener(listener, data);\n }\n this.deleteEntry(callbackId, true);\n }\n\n /** Trigger with merged context and progress; removes unless `removeAfterTrigger: false`. */\n triggerWithContext<T, C extends CallbackContext = CallbackContext>(\n callbackId: string,\n data: T,\n options?: TriggerOptions<C>,\n ): void {\n const entry = this.s.callbacks.get(callbackId);\n if (!entry) return;\n const mergedContext: CallbackContext = {\n ...entry.context,\n ...options?.context,\n ...(options?.progress && { progress: options.progress }),\n };\n void invoke(entry.callback, data, mergedContext);\n if (entry.listeners && entry.listeners.length > 0) {\n for (const listener of [...entry.listeners]) void invokeListener(listener, data, mergedContext);\n }\n if (options?.removeAfterTrigger !== false) this.deleteEntry(callbackId, true);\n }\n\n /** Trigger every callback in a group. */\n triggerGroup<T, C extends CallbackContext = CallbackContext>(groupId: string, data: T, options?: TriggerOptions<C>): void {\n const group = this.s.groups.get(groupId);\n if (!group) return;\n for (const callbackId of [...group]) this.triggerWithContext(callbackId, data, options);\n if (options?.removeAfterTrigger !== false) this.s.groups.delete(groupId);\n }\n\n /**\n * Run the one durable command registered for a group. A command is retained on rejection so its\n * caller can retry, and is removed only after its promise settles successfully.\n */\n async triggerGroupCommand<T, C extends CallbackContext = CallbackContext>(\n groupId: string,\n data: T,\n options?: { context?: C; removeAfterSuccess?: boolean },\n ): Promise<void> {\n const group = this.s.groups.get(groupId);\n const callbackIds = group ? [...group] : [];\n const callbackId = callbackIds[0];\n if (callbackIds.length !== 1 || callbackId === undefined) {\n throw new Error(`Expected exactly one command callback for group \"${groupId}\", found ${callbackIds.length}`);\n }\n const entry = this.s.callbacks.get(callbackId);\n if (!entry) throw new Error(`Command callback \"${callbackId}\" is no longer available`);\n\n const mergedContext: CallbackContext = { ...entry.context, ...options?.context };\n await invoke(entry.callback, data, mergedContext);\n\n // Observers never control command settlement: the command already acknowledged.\n for (const listener of entry.listeners ?? []) {\n try {\n await invokeListener(listener, data, mergedContext);\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error(\"[overlays/handles] command observer failed\", error);\n }\n }\n\n if (options?.removeAfterSuccess !== false) {\n this.deleteEntry(callbackId, true);\n this.s.groups.delete(groupId);\n }\n }\n\n /** Report progress to a callback (or every callback of a group) without removing it. */\n updateProgress(\n id: string,\n progress: number,\n options?: { status?: ProgressInfo[\"status\"]; error?: Error; groupId?: boolean },\n ): void {\n const progressInfo: ProgressInfo = { progress, status: options?.status || \"running\" };\n if (options?.error !== undefined) progressInfo.error = options.error;\n if (options?.groupId) {\n this.triggerGroup(id, null, { progress: progressInfo, removeAfterTrigger: false });\n } else {\n this.triggerWithContext(id, null, { progress: progressInfo, removeAfterTrigger: false });\n }\n }\n\n /** Create a new, empty group and return its id. */\n createGroup(): string {\n const groupId = newHandleId();\n this.s.groups.set(groupId, new Set());\n return groupId;\n }\n\n /** Remove one entry (and its group/owner membership). */\n remove(callbackId: string): void {\n this.deleteEntry(callbackId, true);\n }\n\n /** Alias of `remove` — the preferred name when unregistering a handle on unmount. */\n unregister(callbackId: string): void {\n this.remove(callbackId);\n }\n\n /** The stored callback or object handle for an id, without invoking it. */\n get<T = unknown>(callbackId: string): T | undefined {\n return this.s.callbacks.get(callbackId)?.callback as T | undefined;\n }\n\n /** True when the id is registered. */\n has(callbackId: string): boolean {\n return this.s.callbacks.has(callbackId);\n }\n\n /**\n * Register an object handle (a widget handle, an editor API, …). The object occupies the slot;\n * it is never invoked by `trigger`, only retrieved with `get`.\n */\n registerWidgetHandle<H extends object>(handle: H, options: { owner?: string } = {}): string {\n return this.registerEntry(handle, options.owner === undefined ? {} : { owner: options.owner });\n }\n\n /** Remove a group and all its callbacks. */\n removeGroup(groupId: string): void {\n const s = this.s;\n const group = s.groups.get(groupId);\n if (!group) return;\n s.groups.delete(groupId);\n for (const callbackId of [...group]) this.deleteEntry(callbackId, false);\n this.notifyRegistry();\n }\n\n /** Remove everything registered with `owner` (an InstanceKey). Returns how many were removed. */\n disposeOwner(owner: string): number {\n const s = this.s;\n const owned = s.owners.get(owner);\n if (!owned) return 0;\n s.owners.delete(owner);\n const ids = [...owned];\n for (const callbackId of ids) this.deleteEntry(callbackId, false);\n if (ids.length > 0) this.notifyRegistry();\n return ids.length;\n }\n\n /** Ids currently owned by `owner`. */\n ownedBy(owner: string): readonly string[] {\n return [...(this.s.owners.get(owner) ?? [])];\n }\n\n /** The member ids of a group (empty when unknown). */\n groupMembers(groupId: string): readonly string[] {\n return [...(this.s.groups.get(groupId) ?? [])];\n }\n\n /** Total registered entries (diagnostics, leak tests). */\n size(): number {\n return this.s.callbacks.size;\n }\n\n /**\n * The one removal path. Reads the entry BEFORE deleting it so group and owner membership shrink\n * (the old `removeFromGroups`-after-delete bug), then runs the entry's removal hook.\n */\n private deleteEntry(callbackId: string, notify: boolean): void {\n const s = this.s;\n const entry = s.callbacks.get(callbackId);\n if (!entry) return;\n s.callbacks.delete(callbackId);\n if (entry.groupId !== undefined) {\n const group = s.groups.get(entry.groupId);\n group?.delete(callbackId);\n if (group?.size === 0) s.groups.delete(entry.groupId);\n }\n if (entry.owner !== undefined) {\n const owned = s.owners.get(entry.owner);\n owned?.delete(callbackId);\n if (owned?.size === 0) s.owners.delete(entry.owner);\n }\n if (notify) this.notifyRegistry();\n entry.onRemove?.();\n }\n}\n\n/** The process-wide handles registry (state in the global slot; every instance shares it). */\nexport const callbackManager = new CallbackManager();\n\n/** Remove everything owned by an open instance (`overlayId:instanceId`). */\nexport function disposeOwner(owner: string): number {\n return callbackManager.disposeOwner(owner);\n}\n","/** A fresh handle id: `crypto.randomUUID` when present, else a v4 UUID from `getRandomValues`. */\nexport function newHandleId(): string {\n const c: Crypto | undefined = typeof globalThis.crypto === \"undefined\" ? undefined : globalThis.crypto;\n if (c && typeof c.randomUUID === \"function\") return c.randomUUID();\n const bytes = new Uint8Array(16);\n if (c && typeof c.getRandomValues === \"function\") {\n c.getRandomValues(bytes);\n } else {\n for (let i = 0; i < 16; i += 1) bytes[i] = Math.floor(Math.random() * 256);\n }\n bytes[6] = ((bytes[6] ?? 0) & 0x0f) | 0x40;\n bytes[8] = ((bytes[8] ?? 0) & 0x3f) | 0x80;\n const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, \"0\")).join(\"\");\n return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;\n}\n","/**\n * Typed helpers over the handles registry: imperative object handles, event channels and one-shot\n * requests. Each is stored in the same registry (so its id can ride overlay open data and `get`\n * still resolves it) and accepts an `owner` InstanceKey so closing the owning overlay disposes it.\n */\nimport { callbackManager } from \"./callbackManager\";\n\nexport interface OwnerOption {\n /** The InstanceKey (`overlayId:instanceId`) that owns this handle; disposed when it closes. */\n owner?: string;\n}\n\n/** Thrown into a request's promise when it is disposed before being answered. */\nexport class HandleDisposedError extends Error {\n readonly handleId: string;\n constructor(handleId: string, message = `[overlays/handles] \"${handleId}\" was disposed before it settled`) {\n super(message);\n this.name = \"HandleDisposedError\";\n this.handleId = handleId;\n }\n}\n\nfunction ownerOptions(options: OwnerOption | undefined): { owner?: string } {\n return options?.owner === undefined ? {} : { owner: options.owner };\n}\n\n// ── Imperative object handles ────────────────────────────────────────────────────────────────\n\n/**\n * Register an imperative object handle under a caller-chosen id (an editor API, a widget handle,\n * a ref's methods). Re-registering an id replaces the previous handle. Returns a disposer that\n * removes the handle only if it is still the one registered (safe for React effect cleanup).\n */\nexport function registerHandle<T extends object>(id: string, handle: T, options?: OwnerOption): () => void {\n callbackManager.registerEntry(handle, { id, ...ownerOptions(options) });\n return () => {\n if (callbackManager.get<T>(id) === handle) callbackManager.remove(id);\n };\n}\n\n/** The object handle registered under `id`, or undefined. */\nexport function getHandle<T extends object>(id: string): T | undefined {\n const value = callbackManager.get<unknown>(id);\n return typeof value === \"object\" && value !== null ? (value as T) : undefined;\n}\n\n/** Remove the handle registered under `id`. */\nexport function removeHandle(id: string): void {\n callbackManager.remove(id);\n}\n\n// ── Event channels ───────────────────────────────────────────────────────────────────────────\n\nexport interface EventChannel<Events> {\n readonly id: string;\n /** Deliver an event to every subscriber (no-op after dispose). */\n emit(event: Events): void;\n /** Listen; returns the unsubscribe. */\n subscribe(listener: (event: Events) => void): () => void;\n /** Remove the channel and drop every subscriber. */\n dispose(): void;\n readonly disposed: boolean;\n}\n\n/**\n * A many-shot event stream between an opener and an overlay. Pass `channel.id` in open data; the\n * overlay resolves it with `getEventChannel(id)`.\n */\nexport function createEventChannel<Events>(options?: OwnerOption & { readonly id?: string }): EventChannel<Events> {\n const listeners = new Set<(event: Events) => void>();\n let disposed = false;\n let id = \"\";\n const channel: EventChannel<Events> = {\n get id() {\n return id;\n },\n get disposed() {\n return disposed;\n },\n emit(event) {\n if (disposed) return;\n for (const listener of [...listeners]) listener(event);\n },\n subscribe(listener) {\n if (disposed) return () => {};\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n dispose() {\n if (disposed) return;\n callbackManager.remove(id);\n },\n };\n id = callbackManager.registerEntry(channel, {\n ...(options?.id === undefined ? {} : { id: options.id }),\n ...ownerOptions(options),\n onRemove: () => {\n disposed = true;\n listeners.clear();\n },\n });\n return channel;\n}\n\n/** The channel registered under `id`, or undefined once disposed. */\nexport function getEventChannel<Events>(id: string): EventChannel<Events> | undefined {\n return getHandle<EventChannel<Events>>(id);\n}\n\n// ── One-shot requests ────────────────────────────────────────────────────────────────────────\n\nexport interface PendingRequest<Req, Res> {\n readonly id: string;\n /** What the asker sent. */\n readonly request: Req;\n /** Answer the request (first answer wins; later calls are ignored). */\n resolve(response: Res): void;\n /** Fail the request. */\n reject(reason: unknown): void;\n readonly settled: boolean;\n}\n\nexport interface RequestHandle<Req, Res> extends PendingRequest<Req, Res> {\n /** Settles with the answer; rejects with `HandleDisposedError` when disposed unanswered. */\n readonly promise: Promise<Res>;\n /** Remove the request; an unanswered one rejects. */\n dispose(): void;\n}\n\n/**\n * A one-shot promise bridge: the asker awaits `promise`, the overlay answers through\n * `getRequest(id).resolve(…)`. Disposing it unanswered (or closing its owner) rejects.\n */\nexport function createRequest<Req, Res>(request: Req, options?: OwnerOption): RequestHandle<Req, Res> {\n let settle!: (response: Res) => void;\n let fail!: (reason: unknown) => void;\n const promise = new Promise<Res>((resolve, reject) => {\n settle = resolve;\n fail = reject;\n });\n // A disposed request nobody awaited must not surface as an unhandled rejection.\n promise.catch(() => {});\n let settled = false;\n let id = \"\";\n const handle: RequestHandle<Req, Res> = {\n get id() {\n return id;\n },\n request,\n promise,\n get settled() {\n return settled;\n },\n resolve(response) {\n if (settled) return;\n settled = true;\n settle(response);\n callbackManager.remove(id);\n },\n reject(reason) {\n if (settled) return;\n settled = true;\n fail(reason);\n callbackManager.remove(id);\n },\n dispose() {\n callbackManager.remove(id);\n },\n };\n id = callbackManager.registerEntry(handle, {\n ...ownerOptions(options),\n onRemove: () => {\n if (settled) return;\n settled = true;\n fail(new HandleDisposedError(id));\n },\n });\n return handle;\n}\n\n/** The pending request registered under `id`, or undefined once answered or disposed. */\nexport function getRequest<Req, Res>(id: string): PendingRequest<Req, Res> | undefined {\n return getHandle<RequestHandle<Req, Res>>(id);\n}\n"],"mappings":";AAsBA,SAAS,kBAAkB;;;ACrBpB,SAAS,cAAsB;AACpC,QAAM,IAAwB,OAAO,WAAW,WAAW,cAAc,SAAY,WAAW;AAChG,MAAI,KAAK,OAAO,EAAE,eAAe,WAAY,QAAO,EAAE,WAAW;AACjE,QAAM,QAAQ,IAAI,WAAW,EAAE;AAC/B,MAAI,KAAK,OAAO,EAAE,oBAAoB,YAAY;AAChD,MAAE,gBAAgB,KAAK;AAAA,EACzB,OAAO;AACL,aAAS,IAAI,GAAG,IAAI,IAAI,KAAK,EAAG,OAAM,CAAC,IAAI,KAAK,MAAM,KAAK,OAAO,IAAI,GAAG;AAAA,EAC3E;AACA,QAAM,CAAC,KAAM,MAAM,CAAC,KAAK,KAAK,KAAQ;AACtC,QAAM,CAAC,KAAM,MAAM,CAAC,KAAK,KAAK,KAAQ;AACtC,QAAM,MAAM,MAAM,KAAK,OAAO,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG,CAAC,EAAE,KAAK,EAAE;AAC7E,SAAO,GAAG,IAAI,MAAM,GAAG,CAAC,CAAC,IAAI,IAAI,MAAM,GAAG,EAAE,CA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AA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA,IAAI,UAAU;AACZ,aAAO;AAAA,IACT;AAAA,IACA,QAAQ,UAAU;AAChB,UAAI,QAAS;AACb,gBAAU;AACV,aAAO,QAAQ;AACf,sBAAgB,OAAO,EAAE;AAAA,IAC3B;AAAA,IACA,OAAO,QAAQ;AACb,UAAI,QAAS;AACb,gBAAU;AACV,WAAK,MAAM;AACX,sBAAgB,OAAO,EAAE;AAAA,IAC3B;AAAA,IACA,UAAU;AACR,sBAAgB,OAAO,EAAE;AAAA,IAC3B;AAAA,EACF;AACA,OAAK,gBAAgB,cAAc,QAAQ;AAAA,IACzC,GAAG,aAAa,OAAO;AAAA,IACvB,UAAU,MAAM;AACd,UAAI,QAAS;AACb,gBAAU;AACV,WAAK,IAAI,oBAAoB,EAAE,CAAC;AAAA,IAClC;AAAA,EACF,CAAC;AACD,SAAO;AACT;AAGO,SAAS,WAAqB,IAAkD;AACrF,SAAO,UAAmC,EAAE;AAC9C;","names":[]}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
interface OwnerOption {
|
|
2
|
+
/** The InstanceKey (`overlayId:instanceId`) that owns this handle; disposed when it closes. */
|
|
3
|
+
owner?: string;
|
|
4
|
+
}
|
|
5
|
+
/** Thrown into a request's promise when it is disposed before being answered. */
|
|
6
|
+
declare class HandleDisposedError extends Error {
|
|
7
|
+
readonly handleId: string;
|
|
8
|
+
constructor(handleId: string, message?: string);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Register an imperative object handle under a caller-chosen id (an editor API, a widget handle,
|
|
12
|
+
* a ref's methods). Re-registering an id replaces the previous handle. Returns a disposer that
|
|
13
|
+
* removes the handle only if it is still the one registered (safe for React effect cleanup).
|
|
14
|
+
*/
|
|
15
|
+
declare function registerHandle<T extends object>(id: string, handle: T, options?: OwnerOption): () => void;
|
|
16
|
+
/** The object handle registered under `id`, or undefined. */
|
|
17
|
+
declare function getHandle<T extends object>(id: string): T | undefined;
|
|
18
|
+
/** Remove the handle registered under `id`. */
|
|
19
|
+
declare function removeHandle(id: string): void;
|
|
20
|
+
interface EventChannel<Events> {
|
|
21
|
+
readonly id: string;
|
|
22
|
+
/** Deliver an event to every subscriber (no-op after dispose). */
|
|
23
|
+
emit(event: Events): void;
|
|
24
|
+
/** Listen; returns the unsubscribe. */
|
|
25
|
+
subscribe(listener: (event: Events) => void): () => void;
|
|
26
|
+
/** Remove the channel and drop every subscriber. */
|
|
27
|
+
dispose(): void;
|
|
28
|
+
readonly disposed: boolean;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* A many-shot event stream between an opener and an overlay. Pass `channel.id` in open data; the
|
|
32
|
+
* overlay resolves it with `getEventChannel(id)`.
|
|
33
|
+
*/
|
|
34
|
+
declare function createEventChannel<Events>(options?: OwnerOption & {
|
|
35
|
+
readonly id?: string;
|
|
36
|
+
}): EventChannel<Events>;
|
|
37
|
+
/** The channel registered under `id`, or undefined once disposed. */
|
|
38
|
+
declare function getEventChannel<Events>(id: string): EventChannel<Events> | undefined;
|
|
39
|
+
interface PendingRequest<Req, Res> {
|
|
40
|
+
readonly id: string;
|
|
41
|
+
/** What the asker sent. */
|
|
42
|
+
readonly request: Req;
|
|
43
|
+
/** Answer the request (first answer wins; later calls are ignored). */
|
|
44
|
+
resolve(response: Res): void;
|
|
45
|
+
/** Fail the request. */
|
|
46
|
+
reject(reason: unknown): void;
|
|
47
|
+
readonly settled: boolean;
|
|
48
|
+
}
|
|
49
|
+
interface RequestHandle<Req, Res> extends PendingRequest<Req, Res> {
|
|
50
|
+
/** Settles with the answer; rejects with `HandleDisposedError` when disposed unanswered. */
|
|
51
|
+
readonly promise: Promise<Res>;
|
|
52
|
+
/** Remove the request; an unanswered one rejects. */
|
|
53
|
+
dispose(): void;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* A one-shot promise bridge: the asker awaits `promise`, the overlay answers through
|
|
57
|
+
* `getRequest(id).resolve(…)`. Disposing it unanswered (or closing its owner) rejects.
|
|
58
|
+
*/
|
|
59
|
+
declare function createRequest<Req, Res>(request: Req, options?: OwnerOption): RequestHandle<Req, Res>;
|
|
60
|
+
/** The pending request registered under `id`, or undefined once answered or disposed. */
|
|
61
|
+
declare function getRequest<Req, Res>(id: string): PendingRequest<Req, Res> | undefined;
|
|
62
|
+
|
|
63
|
+
export { type EventChannel as E, HandleDisposedError as H, type OwnerOption as O, type PendingRequest as P, type RequestHandle as R, createRequest as a, getHandle as b, createEventChannel as c, getRequest as d, removeHandle as e, getEventChannel as g, registerHandle as r };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
interface OwnerOption {
|
|
2
|
+
/** The InstanceKey (`overlayId:instanceId`) that owns this handle; disposed when it closes. */
|
|
3
|
+
owner?: string;
|
|
4
|
+
}
|
|
5
|
+
/** Thrown into a request's promise when it is disposed before being answered. */
|
|
6
|
+
declare class HandleDisposedError extends Error {
|
|
7
|
+
readonly handleId: string;
|
|
8
|
+
constructor(handleId: string, message?: string);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Register an imperative object handle under a caller-chosen id (an editor API, a widget handle,
|
|
12
|
+
* a ref's methods). Re-registering an id replaces the previous handle. Returns a disposer that
|
|
13
|
+
* removes the handle only if it is still the one registered (safe for React effect cleanup).
|
|
14
|
+
*/
|
|
15
|
+
declare function registerHandle<T extends object>(id: string, handle: T, options?: OwnerOption): () => void;
|
|
16
|
+
/** The object handle registered under `id`, or undefined. */
|
|
17
|
+
declare function getHandle<T extends object>(id: string): T | undefined;
|
|
18
|
+
/** Remove the handle registered under `id`. */
|
|
19
|
+
declare function removeHandle(id: string): void;
|
|
20
|
+
interface EventChannel<Events> {
|
|
21
|
+
readonly id: string;
|
|
22
|
+
/** Deliver an event to every subscriber (no-op after dispose). */
|
|
23
|
+
emit(event: Events): void;
|
|
24
|
+
/** Listen; returns the unsubscribe. */
|
|
25
|
+
subscribe(listener: (event: Events) => void): () => void;
|
|
26
|
+
/** Remove the channel and drop every subscriber. */
|
|
27
|
+
dispose(): void;
|
|
28
|
+
readonly disposed: boolean;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* A many-shot event stream between an opener and an overlay. Pass `channel.id` in open data; the
|
|
32
|
+
* overlay resolves it with `getEventChannel(id)`.
|
|
33
|
+
*/
|
|
34
|
+
declare function createEventChannel<Events>(options?: OwnerOption & {
|
|
35
|
+
readonly id?: string;
|
|
36
|
+
}): EventChannel<Events>;
|
|
37
|
+
/** The channel registered under `id`, or undefined once disposed. */
|
|
38
|
+
declare function getEventChannel<Events>(id: string): EventChannel<Events> | undefined;
|
|
39
|
+
interface PendingRequest<Req, Res> {
|
|
40
|
+
readonly id: string;
|
|
41
|
+
/** What the asker sent. */
|
|
42
|
+
readonly request: Req;
|
|
43
|
+
/** Answer the request (first answer wins; later calls are ignored). */
|
|
44
|
+
resolve(response: Res): void;
|
|
45
|
+
/** Fail the request. */
|
|
46
|
+
reject(reason: unknown): void;
|
|
47
|
+
readonly settled: boolean;
|
|
48
|
+
}
|
|
49
|
+
interface RequestHandle<Req, Res> extends PendingRequest<Req, Res> {
|
|
50
|
+
/** Settles with the answer; rejects with `HandleDisposedError` when disposed unanswered. */
|
|
51
|
+
readonly promise: Promise<Res>;
|
|
52
|
+
/** Remove the request; an unanswered one rejects. */
|
|
53
|
+
dispose(): void;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* A one-shot promise bridge: the asker awaits `promise`, the overlay answers through
|
|
57
|
+
* `getRequest(id).resolve(…)`. Disposing it unanswered (or closing its owner) rejects.
|
|
58
|
+
*/
|
|
59
|
+
declare function createRequest<Req, Res>(request: Req, options?: OwnerOption): RequestHandle<Req, Res>;
|
|
60
|
+
/** The pending request registered under `id`, or undefined once answered or disposed. */
|
|
61
|
+
declare function getRequest<Req, Res>(id: string): PendingRequest<Req, Res> | undefined;
|
|
62
|
+
|
|
63
|
+
export { type EventChannel as E, HandleDisposedError as H, type OwnerOption as O, type PendingRequest as P, type RequestHandle as R, createRequest as a, getHandle as b, createEventChannel as c, getRequest as d, removeHandle as e, getEventChannel as g, registerHandle as r };
|