@ai-matrx/summon 0.1.7 → 0.1.9
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 +15 -2
- package/dist/gate-CfjdNWP6.d.cts +397 -0
- package/dist/gate-CfjdNWP6.d.ts +397 -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 +12 -350
- package/dist/index.d.ts +12 -350
- 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 +23 -0
- package/dist/open.d.ts +23 -0
- package/dist/open.js +375 -0
- package/dist/open.js.map +1 -0
- 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 +28 -5
package/dist/react.d.ts
CHANGED
|
@@ -1,25 +1,12 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
2
|
+
import { ReactNode, ComponentType, JSXElementConstructor, Component, ErrorInfo } from 'react';
|
|
3
|
+
import { Store } from '@reduxjs/toolkit';
|
|
4
|
+
import { SummonPorts, OverlayId, OverlayDataOf, ErrorSinkPort } from '@ai-matrx/summon';
|
|
5
|
+
import { OverlayErrorExtrasContext, OverlayRenderContext, HostableOverlay, OverlayHandle } from '@ai-matrx/summon/root';
|
|
6
|
+
export { CALLBACK_GROUP_KEY, HostableOverlay, OverlayControllerProps, OverlayDefinition, OverlayEmitter, OverlayErrorExtrasContext, OverlayEventMap, OverlayHandle, OverlayHandlers, OverlayInstanceContextValue, OverlayOpenOptions, OverlayOpener, OverlayRenderContext, OverlaySpec, SummonHostConfig, SummonReactDispatch, SummonReactStore, SummonRoot, SummonRootProps, SummonStoreContext, configureSummonHost, defineOverlay, useOptionalOverlayInstance, useOptionalSummonPorts, useOptionalSummonStore, useOverlayInstance, useSummonDispatch, useSummonPorts, useSummonSelector, useSummonStore } from '@ai-matrx/summon/root';
|
|
7
|
+
import { O as OverlayRenderProps } from './instanceBody-CgZAFnic.js';
|
|
8
|
+
export { R as RenderLoader, a as RenderModule, c as chunkTimeoutError } from './instanceBody-CgZAFnic.js';
|
|
7
9
|
|
|
8
|
-
interface RenderModule<P> {
|
|
9
|
-
readonly default: ComponentType<P>;
|
|
10
|
-
}
|
|
11
|
-
type RenderLoader<P> = () => Promise<RenderModule<P>>;
|
|
12
|
-
/** The error a stalled import becomes, so the error boundary always fires. */
|
|
13
|
-
declare function chunkTimeoutError(key: string, timeoutMs: number): Error;
|
|
14
|
-
|
|
15
|
-
declare const SummonStoreContext: react.Context<ReactReduxContextValue<any, _reduxjs_toolkit.UnknownAction> | null>;
|
|
16
|
-
/** What every slot hands to `renderWrapper`, error extras and the fallbacks. */
|
|
17
|
-
interface OverlayRenderContext {
|
|
18
|
-
readonly overlayId: string;
|
|
19
|
-
readonly instanceId: string;
|
|
20
|
-
readonly instanceKey: string;
|
|
21
|
-
readonly label: string;
|
|
22
|
-
}
|
|
23
10
|
interface OverlayLoadingFallbackProps {
|
|
24
11
|
readonly overlayId: string;
|
|
25
12
|
readonly label: string;
|
|
@@ -37,14 +24,11 @@ interface OverlayErrorFallbackProps {
|
|
|
37
24
|
/** Host-provided extras (AI Matrx: "Copy for AI"), already rendered for this error. */
|
|
38
25
|
readonly extras: ReactNode;
|
|
39
26
|
}
|
|
40
|
-
interface OverlayErrorExtrasContext extends OverlayRenderContext {
|
|
41
|
-
readonly error: unknown;
|
|
42
|
-
readonly componentStack: string | null;
|
|
43
|
-
}
|
|
44
27
|
|
|
45
28
|
declare const DEFAULT_KEEP_ALIVE_LIMIT = 8;
|
|
46
29
|
declare const DEFAULT_IMPORT_TIMEOUT_MS = 12000;
|
|
47
30
|
declare const DEFAULT_STALL_WARN_MS = 10000;
|
|
31
|
+
|
|
48
32
|
interface SummonProviderProps {
|
|
49
33
|
/** The host's Redux store with `summonReducers` mounted at their root keys. Omit for a private store. */
|
|
50
34
|
readonly store?: Store<unknown>;
|
|
@@ -68,119 +52,8 @@ interface SummonProviderProps {
|
|
|
68
52
|
}
|
|
69
53
|
declare function SummonProvider({ store, ports, fallbacks, errorReportExtras, renderWrapper, keepAliveLimit, importTimeoutMs, stallWarnMs, children, }: SummonProviderProps): react.JSX.Element;
|
|
70
54
|
|
|
71
|
-
/**
|
|
72
|
-
type
|
|
73
|
-
/** The store as the React section sees it: the overlays slices at their root keys (a host store has more). */
|
|
74
|
-
type SummonReactStore = Store<SummonRootState>;
|
|
75
|
-
/** Select from the overlays store. */
|
|
76
|
-
declare const useSummonSelector: UseSelector<SummonRootState>;
|
|
77
|
-
/** The overlays store's dispatch. */
|
|
78
|
-
declare const useSummonDispatch: UseDispatch<SummonReactDispatch>;
|
|
79
|
-
/** The overlays store itself (for `getState()` inside callbacks). */
|
|
80
|
-
declare const useSummonStore: UseStore<SummonReactStore>;
|
|
81
|
-
/** The resolved ports of the nearest provider. */
|
|
82
|
-
declare function useSummonPorts(): SummonPorts;
|
|
83
|
-
/**
|
|
84
|
-
* The provider's ports, or the working defaults when no SummonProvider is above — for
|
|
85
|
-
* components that are usable page-local without the system (dialogs, sheets).
|
|
86
|
-
*/
|
|
87
|
-
declare function useOptionalSummonPorts(): SummonPorts;
|
|
88
|
-
/**
|
|
89
|
-
* The nearest provider's store, or `null` when no SummonProvider is above — for packages that
|
|
90
|
-
* mount their own provider only when the host has none (chat's windows on a bare host).
|
|
91
|
-
*/
|
|
92
|
-
declare function useOptionalSummonStore(): SummonReactStore | null;
|
|
93
|
-
|
|
94
|
-
/** Event name → payload, declared once per overlay: `defineOverlay<Data, { uploaded: Result }>()`. */
|
|
95
|
-
type OverlayEventMap = Record<string, unknown>;
|
|
96
|
-
type OverlayHandlers<Events extends OverlayEventMap> = {
|
|
97
|
-
readonly [K in keyof Events]?: (payload: Events[K]) => void;
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
/** The props every overlay's render module receives. */
|
|
101
|
-
interface OverlayRenderProps<Data = OverlayRawData> {
|
|
102
|
-
readonly overlayId: string;
|
|
103
|
-
readonly instanceId: string;
|
|
104
|
-
/** The open data: raw (narrow it yourself) unless the definition declares `parse`. */
|
|
105
|
-
readonly data: Data;
|
|
106
|
-
readonly isOpen: true;
|
|
107
|
-
readonly close: () => void;
|
|
108
|
-
/** True while kept alive behind a close (`keepAlive: "hidden"`). */
|
|
109
|
-
readonly hidden: boolean;
|
|
110
|
-
}
|
|
111
|
-
/** What the host hands each instance — no data type, by design. */
|
|
112
|
-
interface InstanceBodyProps {
|
|
113
|
-
readonly instanceId: string;
|
|
114
|
-
readonly instanceKey: InstanceKey;
|
|
115
|
-
readonly data: OverlayRawData;
|
|
116
|
-
readonly hidden: boolean;
|
|
117
|
-
readonly close: () => void;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/** The open-data key that carries an overlay's event channel id (the old callback-group key). */
|
|
121
|
-
declare const CALLBACK_GROUP_KEY = "callbackGroupId";
|
|
122
|
-
interface OverlayHandle {
|
|
123
|
-
readonly overlayId: string;
|
|
124
|
-
readonly instanceId: string;
|
|
125
|
-
close(): void;
|
|
126
|
-
}
|
|
127
|
-
interface OverlayOpenOptions<Data, Events extends OverlayEventMap> {
|
|
128
|
-
readonly data?: Data;
|
|
129
|
-
/** Single-instance overlays ignore it unless given; multi-instance generate one when omitted. */
|
|
130
|
-
readonly instanceId?: string;
|
|
131
|
-
/** Plain functions; they reach the caller through an event channel owned by the instance. */
|
|
132
|
-
readonly handlers?: OverlayHandlers<Events>;
|
|
133
|
-
}
|
|
134
|
-
type OverlayOpener<Data, Events extends OverlayEventMap> = (options?: OverlayOpenOptions<Data, Events>) => OverlayHandle;
|
|
135
|
-
type OverlayControllerProps<Data, Events extends OverlayEventMap> = Data & {
|
|
136
|
-
readonly instanceId?: string;
|
|
137
|
-
readonly handlers?: OverlayHandlers<Events>;
|
|
138
|
-
};
|
|
139
|
-
type OverlayEmitter<Events extends OverlayEventMap> = <K extends keyof Events & string>(event: K, payload: Events[K]) => void;
|
|
140
|
-
/** What a definition file passes to `defineOverlay<Data>()(…)`. */
|
|
141
|
-
interface OverlaySpec<Id extends string, Data, Parsed> extends OverlayDefinitionMeta<Id, Data> {
|
|
142
|
-
/**
|
|
143
|
-
* The lazily loaded render module. Its default export receives `OverlayRenderProps<Parsed>`.
|
|
144
|
-
* Optional: a large app leaves it out and hands `<SummonHost renders={…}>` one id → import map,
|
|
145
|
-
* so files that import a definition for its opener never gain an import() edge to the window
|
|
146
|
-
* (the host-build law). When present it wins over the host map.
|
|
147
|
-
*/
|
|
148
|
-
readonly render?: () => Promise<RenderModule<OverlayRenderProps<NoInfer<Parsed>>>>;
|
|
149
|
-
/** Narrow raw open data once. `null` = refuse: the instance is closed with a warning. */
|
|
150
|
-
readonly parse?: (raw: OverlayRawData) => Parsed | null;
|
|
151
|
-
}
|
|
152
|
-
/** The type-erased half the host renders; no data types cross this line. */
|
|
153
|
-
interface HostableOverlay {
|
|
154
|
-
readonly id: string;
|
|
155
|
-
readonly label: string;
|
|
156
|
-
readonly instance: "single" | "multi";
|
|
157
|
-
readonly keepAlive: "none" | "hidden" | "restore";
|
|
158
|
-
/** The metadata the core registry stores (links, window options, defaults…). */
|
|
159
|
-
readonly meta: AnyOverlayMeta;
|
|
160
|
-
readonly Body: ComponentType<InstanceBodyProps>;
|
|
161
|
-
}
|
|
162
|
-
interface OverlayDefinition<Id extends string, Data, Parsed, Events extends OverlayEventMap> extends Omit<OverlayDefinitionMeta<Id, Data>, "id" | "instance" | "keepAlive">, HostableOverlay {
|
|
163
|
-
readonly id: Id;
|
|
164
|
-
readonly render?: () => Promise<RenderModule<OverlayRenderProps<Parsed>>>;
|
|
165
|
-
/** Imperative opener: `const open = def.useSummon(); open({ data })` → handle. */
|
|
166
|
-
useSummon(): OverlayOpener<Data, Events>;
|
|
167
|
-
/** Declarative form: opens on mount, closes on unmount, re-opens when its data changes. */
|
|
168
|
-
readonly Controller: (props: OverlayControllerProps<Data, Events>) => null;
|
|
169
|
-
useIsOpen(instanceId?: string): boolean;
|
|
170
|
-
/** `const close = def.useClose(); close(instanceId?)`. */
|
|
171
|
-
useClose(): (instanceId?: string) => void;
|
|
172
|
-
/** Inside the render tree: emit a declared event to the opener's handlers. */
|
|
173
|
-
useEmit(): OverlayEmitter<Events>;
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* Declare an overlay once. Curried so `Data` (and `Events`) are named while the id and the
|
|
177
|
-
* parsed-data type are inferred:
|
|
178
|
-
*
|
|
179
|
-
* export const notesWindow = defineOverlay<NotesWindowData>()({
|
|
180
|
-
* id: "notesWindow", label: "Notes", render: () => import("./notesWindow.render"),
|
|
181
|
-
* });
|
|
182
|
-
*/
|
|
183
|
-
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>;
|
|
55
|
+
/** Deliver one event on a channel; a disposed or unknown channel is a silent no-op by contract. */
|
|
56
|
+
declare function emitOverlayEvent(channelId: string, type: string, payload: unknown): void;
|
|
184
57
|
|
|
185
58
|
/**
|
|
186
59
|
* One overlay's loader with its data type erased. `never` data accepts every render component
|
|
@@ -209,19 +82,6 @@ interface SummonHostProps {
|
|
|
209
82
|
declare function useCloseOnNavigation(): void;
|
|
210
83
|
declare function SummonHost({ definitions, renders }: SummonHostProps): react.JSX.Element;
|
|
211
84
|
|
|
212
|
-
interface OverlayInstanceContextValue {
|
|
213
|
-
readonly overlayId: string;
|
|
214
|
-
readonly instanceId: string;
|
|
215
|
-
readonly instanceKey: InstanceKey;
|
|
216
|
-
readonly close: () => void;
|
|
217
|
-
readonly hidden: boolean;
|
|
218
|
-
/** The open data as it arrived (pre-parse); event emitters read their channel id from it. */
|
|
219
|
-
readonly rawData: OverlayRawData;
|
|
220
|
-
}
|
|
221
|
-
/** The open instance this component renders inside. Throws outside an overlay. */
|
|
222
|
-
declare function useOverlayInstance(): OverlayInstanceContextValue;
|
|
223
|
-
/** Same as `useOverlayInstance`, but `null` outside an overlay. */
|
|
224
|
-
declare function useOptionalOverlayInstance(): OverlayInstanceContextValue | null;
|
|
225
85
|
type OverlayStateSetter<T> = (next: T | ((previous: T) => T)) => void;
|
|
226
86
|
/**
|
|
227
87
|
* Saved state for the current overlay instance — `useState`, but kept in the overlays store under
|
|
@@ -294,4 +154,4 @@ declare function OverlayLoadingFallback({ overlayId, label }: OverlayLoadingFall
|
|
|
294
154
|
/** The error card: what failed, and a way out that never needs a page reload. */
|
|
295
155
|
declare function OverlayErrorFallback({ label, error, retry, close, extras }: OverlayErrorFallbackProps): react.JSX.Element;
|
|
296
156
|
|
|
297
|
-
export {
|
|
157
|
+
export { DEFAULT_IMPORT_TIMEOUT_MS, DEFAULT_KEEP_ALIVE_LIMIT, DEFAULT_STALL_WARN_MS, type ErasedRenderLoader, MISSING_RENDER_ERROR, type NormalizedOverlayError, type OpenOverlayOptions, OverlayErrorBoundary, type OverlayErrorBoundaryProps, OverlayErrorFallback, type OverlayErrorFallbackProps, OverlayLoadingFallback, type OverlayLoadingFallbackProps, type OverlayRenderMap, OverlayRenderProps, type OverlayStateSetter, SummonHost, type SummonHostProps, SummonProvider, type SummonProviderProps, emitOverlayEvent, normalizeOverlayError, useCloseOnNavigation, useCloseOverlay, useIsOverlayOpen, useOpenOverlay, useOverlayLink, useOverlayState };
|