@ai-matrx/summon 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/LICENSE +21 -0
- package/README.md +380 -2
- package/dist/closeBinding-C6raC3qJ.d.cts +20 -0
- package/dist/closeBinding-C6raC3qJ.d.ts +20 -0
- package/dist/dialog.cjs +60 -0
- package/dist/dialog.cjs.map +1 -0
- package/dist/dialog.d.cts +16 -0
- package/dist/dialog.d.ts +16 -0
- package/dist/dialog.js +38 -0
- package/dist/dialog.js.map +1 -0
- package/dist/errors-eJrKXq33.d.cts +30 -0
- package/dist/errors-eJrKXq33.d.ts +30 -0
- package/dist/handles.cjs +411 -0
- package/dist/handles.cjs.map +1 -0
- package/dist/handles.d.cts +166 -0
- package/dist/handles.d.ts +166 -0
- package/dist/handles.js +388 -0
- package/dist/handles.js.map +1 -0
- package/dist/index.cjs +2383 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1259 -0
- package/dist/index.d.ts +1259 -0
- package/dist/index.js +2363 -0
- package/dist/index.js.map +1 -0
- package/dist/lite.cjs +460 -0
- package/dist/lite.cjs.map +1 -0
- package/dist/lite.d.cts +56 -0
- package/dist/lite.d.ts +56 -0
- package/dist/lite.js +444 -0
- package/dist/lite.js.map +1 -0
- package/dist/next.cjs +61 -0
- package/dist/next.cjs.map +1 -0
- package/dist/next.d.cts +5 -0
- package/dist/next.d.ts +5 -0
- package/dist/next.js +39 -0
- package/dist/next.js.map +1 -0
- package/dist/persistence-data.cjs +143 -0
- package/dist/persistence-data.cjs.map +1 -0
- package/dist/persistence-data.d.cts +72 -0
- package/dist/persistence-data.d.ts +72 -0
- package/dist/persistence-data.js +120 -0
- package/dist/persistence-data.js.map +1 -0
- package/dist/persistence.cjs +1073 -0
- package/dist/persistence.cjs.map +1 -0
- package/dist/persistence.d.cts +236 -0
- package/dist/persistence.d.ts +236 -0
- package/dist/persistence.js +1077 -0
- package/dist/persistence.js.map +1 -0
- package/dist/react.cjs +733 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.cts +261 -0
- package/dist/react.d.ts +261 -0
- package/dist/react.js +718 -0
- package/dist/react.js.map +1 -0
- package/dist/sheet.cjs +71 -0
- package/dist/sheet.cjs.map +1 -0
- package/dist/sheet.d.cts +17 -0
- package/dist/sheet.d.ts +17 -0
- package/dist/sheet.js +49 -0
- package/dist/sheet.js.map +1 -0
- package/dist/styles.css +78 -0
- package/dist/testing.cjs +132 -0
- package/dist/testing.cjs.map +1 -0
- package/dist/testing.d.cts +44 -0
- package/dist/testing.d.ts +44 -0
- package/dist/testing.js +115 -0
- package/dist/testing.js.map +1 -0
- package/dist/url.cjs +362 -0
- package/dist/url.cjs.map +1 -0
- package/dist/url.d.cts +153 -0
- package/dist/url.d.ts +153 -0
- package/dist/url.js +352 -0
- package/dist/url.js.map +1 -0
- package/dist/window-host.cjs +123 -0
- package/dist/window-host.cjs.map +1 -0
- package/dist/window-host.d.cts +72 -0
- package/dist/window-host.d.ts +72 -0
- package/dist/window-host.js +104 -0
- package/dist/window-host.js.map +1 -0
- package/dist/window.cjs +3978 -0
- package/dist/window.cjs.map +1 -0
- package/dist/window.d.cts +796 -0
- package/dist/window.d.ts +796 -0
- package/dist/window.js +4003 -0
- package/dist/window.js.map +1 -0
- package/package.json +237 -4
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
type CallbackContext = Record<string, unknown>;
|
|
2
|
+
interface ProgressInfo {
|
|
3
|
+
progress?: number;
|
|
4
|
+
status?: "pending" | "running" | "completed" | "error";
|
|
5
|
+
error?: Error;
|
|
6
|
+
}
|
|
7
|
+
type Callback<T = unknown, C extends CallbackContext = CallbackContext> = (data: T, context?: C) => void | Promise<void>;
|
|
8
|
+
/** What an entry's slot holds: a callback, or an object handle retrieved with `get`. */
|
|
9
|
+
type HandleSlot = Callback<never, never> | object;
|
|
10
|
+
interface RegisterOptions<C extends CallbackContext = CallbackContext> {
|
|
11
|
+
context?: C;
|
|
12
|
+
groupId?: string;
|
|
13
|
+
/** The InstanceKey (`overlayId:instanceId`) that owns this entry; disposed when it closes. */
|
|
14
|
+
owner?: string;
|
|
15
|
+
}
|
|
16
|
+
interface TriggerOptions<C extends CallbackContext = CallbackContext> {
|
|
17
|
+
context?: C;
|
|
18
|
+
progress?: ProgressInfo;
|
|
19
|
+
removeAfterTrigger?: boolean;
|
|
20
|
+
}
|
|
21
|
+
declare const HANDLES_SLOT = "ai-matrx.summon.handles";
|
|
22
|
+
/** Internal registration options beyond the public ones (used by the typed helpers). */
|
|
23
|
+
interface InternalRegisterOptions extends RegisterOptions {
|
|
24
|
+
id?: string;
|
|
25
|
+
onRemove?: () => void;
|
|
26
|
+
}
|
|
27
|
+
declare class CallbackManager {
|
|
28
|
+
private get s();
|
|
29
|
+
/**
|
|
30
|
+
* Observe the registry itself: `listener` runs after any entry is added or removed. This lets a
|
|
31
|
+
* view that resolves ids with `get` re-render when an id goes away (`useSyncExternalStore`).
|
|
32
|
+
*/
|
|
33
|
+
subscribeToRegistry(listener: () => void): () => void;
|
|
34
|
+
private notifyRegistry;
|
|
35
|
+
/** Register a callback; returns its id. */
|
|
36
|
+
register<T>(callback: Callback<T>): string;
|
|
37
|
+
/** Register with optional context, group and owner. */
|
|
38
|
+
registerWithContext<T, C extends CallbackContext = CallbackContext>(callback: Callback<T, C>, options?: RegisterOptions<C>): string;
|
|
39
|
+
/** @internal The one insertion path (typed helpers pass a fixed id and a removal hook). */
|
|
40
|
+
registerEntry(slot: HandleSlot, options: InternalRegisterOptions): string;
|
|
41
|
+
/** Subscribe to results for a callback id. */
|
|
42
|
+
subscribe<T, C extends CallbackContext = CallbackContext>(callbackId: string, listener: Callback<T, C>): boolean;
|
|
43
|
+
/** Unsubscribe a listener from a callback id. */
|
|
44
|
+
unsubscribe<T, C extends CallbackContext = CallbackContext>(callbackId: string, listener: Callback<T, C>): boolean;
|
|
45
|
+
/** Run a callback once, notify its listeners, then remove it. */
|
|
46
|
+
trigger<T>(callbackId: string, data: T): void;
|
|
47
|
+
/** Trigger with merged context and progress; removes unless `removeAfterTrigger: false`. */
|
|
48
|
+
triggerWithContext<T, C extends CallbackContext = CallbackContext>(callbackId: string, data: T, options?: TriggerOptions<C>): void;
|
|
49
|
+
/** Trigger every callback in a group. */
|
|
50
|
+
triggerGroup<T, C extends CallbackContext = CallbackContext>(groupId: string, data: T, options?: TriggerOptions<C>): void;
|
|
51
|
+
/**
|
|
52
|
+
* Run the one durable command registered for a group. A command is retained on rejection so its
|
|
53
|
+
* caller can retry, and is removed only after its promise settles successfully.
|
|
54
|
+
*/
|
|
55
|
+
triggerGroupCommand<T, C extends CallbackContext = CallbackContext>(groupId: string, data: T, options?: {
|
|
56
|
+
context?: C;
|
|
57
|
+
removeAfterSuccess?: boolean;
|
|
58
|
+
}): Promise<void>;
|
|
59
|
+
/** Report progress to a callback (or every callback of a group) without removing it. */
|
|
60
|
+
updateProgress(id: string, progress: number, options?: {
|
|
61
|
+
status?: ProgressInfo["status"];
|
|
62
|
+
error?: Error;
|
|
63
|
+
groupId?: boolean;
|
|
64
|
+
}): void;
|
|
65
|
+
/** Create a new, empty group and return its id. */
|
|
66
|
+
createGroup(): string;
|
|
67
|
+
/** Remove one entry (and its group/owner membership). */
|
|
68
|
+
remove(callbackId: string): void;
|
|
69
|
+
/** Alias of `remove` — the preferred name when unregistering a handle on unmount. */
|
|
70
|
+
unregister(callbackId: string): void;
|
|
71
|
+
/** The stored callback or object handle for an id, without invoking it. */
|
|
72
|
+
get<T = unknown>(callbackId: string): T | undefined;
|
|
73
|
+
/** True when the id is registered. */
|
|
74
|
+
has(callbackId: string): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Register an object handle (a widget handle, an editor API, …). The object occupies the slot;
|
|
77
|
+
* it is never invoked by `trigger`, only retrieved with `get`.
|
|
78
|
+
*/
|
|
79
|
+
registerWidgetHandle<H extends object>(handle: H, options?: {
|
|
80
|
+
owner?: string;
|
|
81
|
+
}): string;
|
|
82
|
+
/** Remove a group and all its callbacks. */
|
|
83
|
+
removeGroup(groupId: string): void;
|
|
84
|
+
/** Remove everything registered with `owner` (an InstanceKey). Returns how many were removed. */
|
|
85
|
+
disposeOwner(owner: string): number;
|
|
86
|
+
/** Ids currently owned by `owner`. */
|
|
87
|
+
ownedBy(owner: string): readonly string[];
|
|
88
|
+
/** The member ids of a group (empty when unknown). */
|
|
89
|
+
groupMembers(groupId: string): readonly string[];
|
|
90
|
+
/** Total registered entries (diagnostics, leak tests). */
|
|
91
|
+
size(): number;
|
|
92
|
+
/**
|
|
93
|
+
* The one removal path. Reads the entry BEFORE deleting it so group and owner membership shrink
|
|
94
|
+
* (the old `removeFromGroups`-after-delete bug), then runs the entry's removal hook.
|
|
95
|
+
*/
|
|
96
|
+
private deleteEntry;
|
|
97
|
+
}
|
|
98
|
+
/** The process-wide handles registry (state in the global slot; every instance shares it). */
|
|
99
|
+
declare const callbackManager: CallbackManager;
|
|
100
|
+
/** Remove everything owned by an open instance (`overlayId:instanceId`). */
|
|
101
|
+
declare function disposeOwner(owner: string): number;
|
|
102
|
+
|
|
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
|
+
/** A fresh handle id: `crypto.randomUUID` when present, else a v4 UUID from `getRandomValues`. */
|
|
164
|
+
declare function newHandleId(): string;
|
|
165
|
+
|
|
166
|
+
export { type Callback, type CallbackContext, CallbackManager, type EventChannel, HANDLES_SLOT, HandleDisposedError, type HandleSlot, type OwnerOption, type PendingRequest, type ProgressInfo, type RegisterOptions, type RequestHandle, type TriggerOptions, callbackManager, createEventChannel, createRequest, disposeOwner, getEventChannel, getHandle, getRequest, newHandleId, registerHandle, removeHandle };
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
type CallbackContext = Record<string, unknown>;
|
|
2
|
+
interface ProgressInfo {
|
|
3
|
+
progress?: number;
|
|
4
|
+
status?: "pending" | "running" | "completed" | "error";
|
|
5
|
+
error?: Error;
|
|
6
|
+
}
|
|
7
|
+
type Callback<T = unknown, C extends CallbackContext = CallbackContext> = (data: T, context?: C) => void | Promise<void>;
|
|
8
|
+
/** What an entry's slot holds: a callback, or an object handle retrieved with `get`. */
|
|
9
|
+
type HandleSlot = Callback<never, never> | object;
|
|
10
|
+
interface RegisterOptions<C extends CallbackContext = CallbackContext> {
|
|
11
|
+
context?: C;
|
|
12
|
+
groupId?: string;
|
|
13
|
+
/** The InstanceKey (`overlayId:instanceId`) that owns this entry; disposed when it closes. */
|
|
14
|
+
owner?: string;
|
|
15
|
+
}
|
|
16
|
+
interface TriggerOptions<C extends CallbackContext = CallbackContext> {
|
|
17
|
+
context?: C;
|
|
18
|
+
progress?: ProgressInfo;
|
|
19
|
+
removeAfterTrigger?: boolean;
|
|
20
|
+
}
|
|
21
|
+
declare const HANDLES_SLOT = "ai-matrx.summon.handles";
|
|
22
|
+
/** Internal registration options beyond the public ones (used by the typed helpers). */
|
|
23
|
+
interface InternalRegisterOptions extends RegisterOptions {
|
|
24
|
+
id?: string;
|
|
25
|
+
onRemove?: () => void;
|
|
26
|
+
}
|
|
27
|
+
declare class CallbackManager {
|
|
28
|
+
private get s();
|
|
29
|
+
/**
|
|
30
|
+
* Observe the registry itself: `listener` runs after any entry is added or removed. This lets a
|
|
31
|
+
* view that resolves ids with `get` re-render when an id goes away (`useSyncExternalStore`).
|
|
32
|
+
*/
|
|
33
|
+
subscribeToRegistry(listener: () => void): () => void;
|
|
34
|
+
private notifyRegistry;
|
|
35
|
+
/** Register a callback; returns its id. */
|
|
36
|
+
register<T>(callback: Callback<T>): string;
|
|
37
|
+
/** Register with optional context, group and owner. */
|
|
38
|
+
registerWithContext<T, C extends CallbackContext = CallbackContext>(callback: Callback<T, C>, options?: RegisterOptions<C>): string;
|
|
39
|
+
/** @internal The one insertion path (typed helpers pass a fixed id and a removal hook). */
|
|
40
|
+
registerEntry(slot: HandleSlot, options: InternalRegisterOptions): string;
|
|
41
|
+
/** Subscribe to results for a callback id. */
|
|
42
|
+
subscribe<T, C extends CallbackContext = CallbackContext>(callbackId: string, listener: Callback<T, C>): boolean;
|
|
43
|
+
/** Unsubscribe a listener from a callback id. */
|
|
44
|
+
unsubscribe<T, C extends CallbackContext = CallbackContext>(callbackId: string, listener: Callback<T, C>): boolean;
|
|
45
|
+
/** Run a callback once, notify its listeners, then remove it. */
|
|
46
|
+
trigger<T>(callbackId: string, data: T): void;
|
|
47
|
+
/** Trigger with merged context and progress; removes unless `removeAfterTrigger: false`. */
|
|
48
|
+
triggerWithContext<T, C extends CallbackContext = CallbackContext>(callbackId: string, data: T, options?: TriggerOptions<C>): void;
|
|
49
|
+
/** Trigger every callback in a group. */
|
|
50
|
+
triggerGroup<T, C extends CallbackContext = CallbackContext>(groupId: string, data: T, options?: TriggerOptions<C>): void;
|
|
51
|
+
/**
|
|
52
|
+
* Run the one durable command registered for a group. A command is retained on rejection so its
|
|
53
|
+
* caller can retry, and is removed only after its promise settles successfully.
|
|
54
|
+
*/
|
|
55
|
+
triggerGroupCommand<T, C extends CallbackContext = CallbackContext>(groupId: string, data: T, options?: {
|
|
56
|
+
context?: C;
|
|
57
|
+
removeAfterSuccess?: boolean;
|
|
58
|
+
}): Promise<void>;
|
|
59
|
+
/** Report progress to a callback (or every callback of a group) without removing it. */
|
|
60
|
+
updateProgress(id: string, progress: number, options?: {
|
|
61
|
+
status?: ProgressInfo["status"];
|
|
62
|
+
error?: Error;
|
|
63
|
+
groupId?: boolean;
|
|
64
|
+
}): void;
|
|
65
|
+
/** Create a new, empty group and return its id. */
|
|
66
|
+
createGroup(): string;
|
|
67
|
+
/** Remove one entry (and its group/owner membership). */
|
|
68
|
+
remove(callbackId: string): void;
|
|
69
|
+
/** Alias of `remove` — the preferred name when unregistering a handle on unmount. */
|
|
70
|
+
unregister(callbackId: string): void;
|
|
71
|
+
/** The stored callback or object handle for an id, without invoking it. */
|
|
72
|
+
get<T = unknown>(callbackId: string): T | undefined;
|
|
73
|
+
/** True when the id is registered. */
|
|
74
|
+
has(callbackId: string): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Register an object handle (a widget handle, an editor API, …). The object occupies the slot;
|
|
77
|
+
* it is never invoked by `trigger`, only retrieved with `get`.
|
|
78
|
+
*/
|
|
79
|
+
registerWidgetHandle<H extends object>(handle: H, options?: {
|
|
80
|
+
owner?: string;
|
|
81
|
+
}): string;
|
|
82
|
+
/** Remove a group and all its callbacks. */
|
|
83
|
+
removeGroup(groupId: string): void;
|
|
84
|
+
/** Remove everything registered with `owner` (an InstanceKey). Returns how many were removed. */
|
|
85
|
+
disposeOwner(owner: string): number;
|
|
86
|
+
/** Ids currently owned by `owner`. */
|
|
87
|
+
ownedBy(owner: string): readonly string[];
|
|
88
|
+
/** The member ids of a group (empty when unknown). */
|
|
89
|
+
groupMembers(groupId: string): readonly string[];
|
|
90
|
+
/** Total registered entries (diagnostics, leak tests). */
|
|
91
|
+
size(): number;
|
|
92
|
+
/**
|
|
93
|
+
* The one removal path. Reads the entry BEFORE deleting it so group and owner membership shrink
|
|
94
|
+
* (the old `removeFromGroups`-after-delete bug), then runs the entry's removal hook.
|
|
95
|
+
*/
|
|
96
|
+
private deleteEntry;
|
|
97
|
+
}
|
|
98
|
+
/** The process-wide handles registry (state in the global slot; every instance shares it). */
|
|
99
|
+
declare const callbackManager: CallbackManager;
|
|
100
|
+
/** Remove everything owned by an open instance (`overlayId:instanceId`). */
|
|
101
|
+
declare function disposeOwner(owner: string): number;
|
|
102
|
+
|
|
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
|
+
/** A fresh handle id: `crypto.randomUUID` when present, else a v4 UUID from `getRandomValues`. */
|
|
164
|
+
declare function newHandleId(): string;
|
|
165
|
+
|
|
166
|
+
export { type Callback, type CallbackContext, CallbackManager, type EventChannel, HANDLES_SLOT, HandleDisposedError, type HandleSlot, type OwnerOption, type PendingRequest, type ProgressInfo, type RegisterOptions, type RequestHandle, type TriggerOptions, callbackManager, createEventChannel, createRequest, disposeOwner, getEventChannel, getHandle, getRequest, newHandleId, registerHandle, removeHandle };
|