@ai-matrx/summon 0.1.0 → 0.1.1
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 +8 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +15 -10
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +6 -1
- package/dist/react.d.ts +6 -1
- package/dist/react.js +17 -12
- package/dist/react.js.map +1 -1
- package/dist/window.cjs +1 -2
- package/dist/window.cjs.map +1 -1
- package/dist/window.js +1 -2
- package/dist/window.js.map +1 -1
- package/package.json +4 -4
package/dist/react.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/react/SummonProvider.tsx","../src/react/context.ts","../src/react/fallbacks.tsx","../src/react/storeHooks.ts","../src/react/keepAlive.ts","../src/react/loaderCache.ts","../src/react/defineOverlay.tsx","../src/react/dispatchers.ts","../src/react/events.ts","../src/react/instanceBody.tsx","../src/react/OverlayErrorBoundary.tsx","../src/react/instance.tsx","../src/react/SummonHost.tsx","../src/react/hooks.ts"],"sourcesContent":["// `<SummonProvider>` — mounts the overlays store on the package's own context (the host's store\n// when passed — AI Matrx mounts `summonReducers` into its one store — else a private store made\n// once), the resolved ports, and the render-layer knobs (fallbacks, error extras, wrapper,\n// keep-alive cap, import timeout).\n\nimport { useEffect, useMemo, useRef, useState, type ComponentType, type ReactNode } from \"react\";\nimport { Provider } from \"react-redux\";\nimport type { Store } from \"@reduxjs/toolkit\";\nimport { resolvePorts, type SummonPorts } from \"@ai-matrx/summon\";\nimport { createSummonStore } from \"@ai-matrx/summon\";\nimport {\n SummonConfigContext,\n SummonPortsContext,\n SummonStoreContext,\n type OverlayErrorExtrasContext,\n type OverlayErrorFallbackProps,\n type OverlayLoadingFallbackProps,\n type OverlayRenderContext,\n type SummonReactConfig,\n} from \"./context\";\nimport { OverlayErrorFallback, OverlayLoadingFallback } from \"./fallbacks\";\nimport { KeepAliveRegistry } from \"./keepAlive\";\nimport { LoaderCache } from \"./loaderCache\";\n\nexport const DEFAULT_KEEP_ALIVE_LIMIT = 8;\nexport const DEFAULT_IMPORT_TIMEOUT_MS = 12_000;\nexport const DEFAULT_STALL_WARN_MS = 10_000;\n\nexport interface SummonProviderProps {\n /** The host's Redux store with `summonReducers` mounted at their root keys. Omit for a private store. */\n readonly store?: Store<unknown>;\n /** Host ports; anything omitted uses the working default. */\n readonly ports?: Partial<SummonPorts>;\n readonly fallbacks?: {\n readonly loading?: ComponentType<OverlayLoadingFallbackProps>;\n readonly error?: ComponentType<OverlayErrorFallbackProps>;\n };\n /** Extra controls in the default error card's footer (AI Matrx: \"Copy for AI\"). */\n readonly errorReportExtras?: (context: OverlayErrorExtrasContext) => ReactNode;\n /** Wrap every rendered overlay (AI Matrx: its surface layer boundary). */\n readonly renderWrapper?: (node: ReactNode, context: OverlayRenderContext) => ReactNode;\n /** Most closed-but-alive (`keepAlive: \"hidden\"`) instances kept mounted. Default 8. */\n readonly keepAliveLimit?: number;\n /** A render-module import that has not settled by then becomes a ChunkLoadError. Default 12 s. */\n readonly importTimeoutMs?: number;\n /** When the loading fallback reports a stall to the error port. Default 10 s. */\n readonly stallWarnMs?: number;\n readonly children?: ReactNode;\n}\n\nexport function SummonProvider({\n store,\n ports,\n fallbacks,\n errorReportExtras,\n renderWrapper,\n keepAliveLimit = DEFAULT_KEEP_ALIVE_LIMIT,\n importTimeoutMs = DEFAULT_IMPORT_TIMEOUT_MS,\n stallWarnMs = DEFAULT_STALL_WARN_MS,\n children,\n}: SummonProviderProps) {\n const resolvedPorts = useMemo(() => resolvePorts(ports), [ports]);\n const [privateStore] = useState(() => (store ? null : createSummonStore({ ports: resolvedPorts })));\n const activeStore: Store<unknown> = store ?? (privateStore as Store<unknown>);\n\n const timeoutRef = useRef(importTimeoutMs);\n timeoutRef.current = importTimeoutMs;\n const [keepAlive] = useState(() => new KeepAliveRegistry(keepAliveLimit));\n const [loaders] = useState(() => new LoaderCache({ timeoutMs: () => timeoutRef.current }));\n useEffect(() => keepAlive.setLimit(keepAliveLimit), [keepAlive, keepAliveLimit]);\n\n const loading = fallbacks?.loading ?? OverlayLoadingFallback;\n const error = fallbacks?.error ?? OverlayErrorFallback;\n const config = useMemo<SummonReactConfig>(\n () => ({\n loadingFallback: loading,\n errorFallback: error,\n errorReportExtras: errorReportExtras ?? null,\n renderWrapper: renderWrapper ?? null,\n importTimeoutMs,\n stallWarnMs,\n keepAlive,\n loaders,\n }),\n [loading, error, errorReportExtras, renderWrapper, importTimeoutMs, stallWarnMs, keepAlive, loaders],\n );\n\n return (\n <Provider store={activeStore} context={SummonStoreContext}>\n <SummonPortsContext.Provider value={resolvedPorts}>\n <SummonConfigContext.Provider value={config}>{children}</SummonConfigContext.Provider>\n </SummonPortsContext.Provider>\n </Provider>\n );\n}\n","// The React section's own contexts. The overlays store rides its OWN react-redux context\n// (chat-package pattern), so a private overlays store never collides with a host's store and a\n// host that mounts `summonReducers` into its one store simply passes it in.\n\nimport { createContext, type ComponentType, type ReactNode } from \"react\";\nimport type { ReactReduxContextValue } from \"react-redux\";\nimport type { SummonPorts } from \"@ai-matrx/summon\";\nimport type { KeepAliveRegistry } from \"./keepAlive\";\nimport type { LoaderCache } from \"./loaderCache\";\n\nexport const SummonStoreContext = createContext<ReactReduxContextValue | null>(null);\nSummonStoreContext.displayName = \"SummonStoreContext\";\n\nexport const SummonPortsContext = createContext<SummonPorts | null>(null);\nSummonPortsContext.displayName = \"SummonPortsContext\";\n\n/** What every slot hands to `renderWrapper`, error extras and the fallbacks. */\nexport interface OverlayRenderContext {\n readonly overlayId: string;\n readonly instanceId: string;\n readonly instanceKey: string;\n readonly label: string;\n}\n\nexport interface OverlayLoadingFallbackProps {\n readonly overlayId: string;\n readonly label: string;\n}\n\nexport interface OverlayErrorFallbackProps {\n readonly overlayId: string;\n readonly instanceId: string;\n readonly label: string;\n readonly error: unknown;\n readonly componentStack: string | null;\n /** Re-import the render module and mount again. */\n readonly retry: () => void;\n /** Close this instance (no reload). */\n readonly close: () => void;\n /** Host-provided extras (AI Matrx: \"Copy for AI\"), already rendered for this error. */\n readonly extras: ReactNode;\n}\n\nexport interface OverlayErrorExtrasContext extends OverlayRenderContext {\n readonly error: unknown;\n readonly componentStack: string | null;\n}\n\nexport interface SummonReactConfig {\n readonly loadingFallback: ComponentType<OverlayLoadingFallbackProps>;\n readonly errorFallback: ComponentType<OverlayErrorFallbackProps>;\n readonly errorReportExtras: ((context: OverlayErrorExtrasContext) => ReactNode) | null;\n readonly renderWrapper: ((node: ReactNode, context: OverlayRenderContext) => ReactNode) | null;\n readonly importTimeoutMs: number;\n readonly stallWarnMs: number;\n readonly keepAlive: KeepAliveRegistry;\n readonly loaders: LoaderCache;\n}\n\nexport const SummonConfigContext = createContext<SummonReactConfig | null>(null);\nSummonConfigContext.displayName = \"SummonConfigContext\";\n","// The default loading and error fallbacks every overlay renders through. A host replaces either\n// with `<SummonProvider fallbacks>`; AI Matrx adds its \"Copy for AI\" through `errorReportExtras`.\n// Design-system components and tokens only — no app imports.\n\nimport { useEffect } from \"react\";\nimport { Button } from \"@ai-matrx/design-system\";\nimport type { OverlayErrorFallbackProps, OverlayLoadingFallbackProps } from \"./context\";\nimport { useSummonConfig, useSummonPorts } from \"./storeHooks\";\n\nexport interface NormalizedOverlayError {\n readonly name: string;\n readonly message: string;\n readonly stack: string | null;\n readonly isChunkLoadError: boolean;\n}\n\nexport function normalizeOverlayError(error: unknown): NormalizedOverlayError {\n if (error instanceof Error) {\n const isChunkLoadError =\n error.name === \"ChunkLoadError\" ||\n /Loading chunk [\\w-]+ failed|Failed to fetch dynamically imported module|Importing a module script failed/i.test(\n error.message,\n );\n return { name: error.name, message: error.message, stack: error.stack ?? null, isChunkLoadError };\n }\n return { name: \"Error\", message: typeof error === \"string\" ? error : String(error), stack: null, isChunkLoadError: false };\n}\n\n/**\n * Spinner while the render module is in flight. Never blank. At the stall threshold it reports\n * once through the error port; the loader's import timeout (later) turns a hung import into a\n * real error so the error fallback takes over.\n */\nexport function OverlayLoadingFallback({ overlayId, label }: OverlayLoadingFallbackProps) {\n const ports = useSummonPorts();\n const { stallWarnMs } = useSummonConfig();\n useEffect(() => {\n const timer = setTimeout(() => {\n ports.errors.capture(new Error(`Overlay \"${overlayId}\" still loading after ${stallWarnMs}ms`), {\n stage: \"overlay-load-stall\",\n overlayId,\n level: \"warning\",\n });\n }, stallWarnMs);\n return () => clearTimeout(timer);\n }, [ports, overlayId, stallWarnMs]);\n\n return (\n <div className=\"pointer-events-none fixed inset-0 z-[2147483000] flex items-center justify-center p-4\">\n <div\n role=\"status\"\n aria-label={`Loading ${label}`}\n className=\"pointer-events-auto flex items-center gap-3 rounded-xl border border-border bg-card px-5 py-4 text-sm text-muted-foreground shadow-[var(--elevation-2)]\"\n >\n <span aria-hidden className=\"size-4 animate-spin rounded-full border-2 border-border border-t-primary\" />\n <span>Loading…</span>\n </div>\n </div>\n );\n}\n\n/** The error card: what failed, and a way out that never needs a page reload. */\nexport function OverlayErrorFallback({ label, error, retry, close, extras }: OverlayErrorFallbackProps) {\n const e = normalizeOverlayError(error);\n return (\n <div className=\"pointer-events-none fixed inset-0 z-[2147483001] flex items-center justify-center p-4\">\n <div\n role=\"alertdialog\"\n aria-label={`${label} failed to load`}\n className=\"pointer-events-auto flex max-h-[85dvh] w-full max-w-lg flex-col overflow-hidden rounded-xl border border-destructive bg-card shadow-[var(--elevation-3)]\"\n >\n <div className=\"border-b border-border px-5 py-4\">\n <h2 className=\"text-sm font-semibold text-foreground\">{label} failed to load</h2>\n <p className=\"mt-1 text-xs text-muted-foreground\">\n {e.isChunkLoadError ? \"Part of it did not finish loading.\" : \"It hit an error while rendering.\"}\n </p>\n </div>\n <div className=\"min-h-0 flex-1 overflow-auto px-5 py-4\">\n <div className=\"rounded-lg bg-muted px-3 py-2 font-mono text-xs text-foreground\">\n <span className=\"text-destructive\">{e.name}</span>: {e.message}\n </div>\n </div>\n <div className=\"flex items-center justify-between gap-2 border-t border-border px-5 py-3\">\n <div>{extras}</div>\n <div className=\"flex items-center gap-2\">\n <Button variant=\"ghost\" size=\"sm\" onClick={close}>\n Close\n </Button>\n <Button variant=\"primary\" size=\"sm\" onClick={retry}>\n Try again\n </Button>\n <Button\n variant=\"outline\"\n size=\"sm\"\n onClick={() => {\n if (typeof window !== \"undefined\") window.location.reload();\n }}\n >\n Reload page\n </Button>\n </div>\n </div>\n </div>\n </div>\n );\n}\n","// Typed hooks over the package's own store context. Every package component reads the overlays\n// store through these, never react-redux's default context, so a host's own <Provider> and the\n// overlays store never collide.\n\nimport { useContext } from \"react\";\nimport {\n createDispatchHook,\n createSelectorHook,\n createStoreHook,\n type UseDispatch,\n type UseSelector,\n type UseStore,\n} from \"react-redux\";\nimport type { Dispatch, Store, UnknownAction } from \"@reduxjs/toolkit\";\nimport type { SummonRootState } from \"@ai-matrx/summon\";\nimport { DEFAULT_PORTS, type SummonPorts } from \"@ai-matrx/summon\";\nimport { SummonConfigContext, SummonPortsContext, SummonStoreContext, type SummonReactConfig } from \"./context\";\n\n/** Dispatch as the React section uses it: plain actions (thunks are the host's business). */\nexport type SummonReactDispatch = Dispatch<UnknownAction>;\n\n/** The store as the React section sees it: the overlays slices at their root keys (a host store has more). */\nexport type SummonReactStore = Store<SummonRootState>;\n\n/** Select from the overlays store. */\nexport const useSummonSelector: UseSelector<SummonRootState> = createSelectorHook(SummonStoreContext).withTypes<SummonRootState>();\n\n/** The overlays store's dispatch. */\nexport const useSummonDispatch: UseDispatch<SummonReactDispatch> = createDispatchHook(SummonStoreContext).withTypes<SummonReactDispatch>();\n\n/** The overlays store itself (for `getState()` inside callbacks). */\nexport const useSummonStore: UseStore<SummonReactStore> = createStoreHook(SummonStoreContext).withTypes<SummonReactStore>();\n\nconst MISSING_PROVIDER =\n \"[summon] No <SummonProvider> above this component. Wrap the app (or the part that opens overlays) in <SummonProvider>.\";\n\n/** The resolved ports of the nearest provider. */\nexport function useSummonPorts(): SummonPorts {\n const ports = useContext(SummonPortsContext);\n if (!ports) throw new Error(MISSING_PROVIDER);\n return ports;\n}\n\n/**\n * The provider's ports, or the working defaults when no SummonProvider is above — for\n * components that are usable page-local without the system (dialogs, sheets).\n */\nexport function useOptionalSummonPorts(): SummonPorts {\n return useContext(SummonPortsContext) ?? DEFAULT_PORTS;\n}\n\nexport function useSummonConfig(): SummonReactConfig {\n const config = useContext(SummonConfigContext);\n if (!config) throw new Error(MISSING_PROVIDER);\n return config;\n}\n","// The provider's LRU of closed-but-alive instances (`keepAlive: \"hidden\"`, C38 R3). Each slot\n// retains its own hidden instances; this registry only keeps the global order and tells the\n// owning slot when one falls off the end, so at most `limit` hidden components stay mounted.\n\nexport class KeepAliveRegistry {\n private readonly order: string[] = [];\n private readonly evictors = new Map<string, () => void>();\n\n constructor(private limit: number) {}\n\n setLimit(limit: number): void {\n this.limit = Math.max(0, Math.floor(limit));\n this.trim();\n }\n\n /** Mark `key` as hidden-alive (most recent). `evict` unmounts it when the cap is exceeded. */\n retain(key: string, evict: () => void): void {\n this.drop(key);\n this.order.push(key);\n this.evictors.set(key, evict);\n this.trim();\n }\n\n /** `key` reopened or its slot went away: no longer counted. */\n release(key: string): void {\n this.drop(key);\n }\n\n size(): number {\n return this.order.length;\n }\n\n private drop(key: string): void {\n const at = this.order.indexOf(key);\n if (at >= 0) this.order.splice(at, 1);\n this.evictors.delete(key);\n }\n\n private trim(): void {\n while (this.order.length > this.limit) {\n const oldest = this.order.shift();\n if (oldest === undefined) return;\n const evict = this.evictors.get(oldest);\n this.evictors.delete(oldest);\n evict?.();\n }\n }\n}\n","// Per-provider cache of each definition's lazily loaded render component. Lives in the provider\n// (React state), never at module level. A definition's render module is fetched the first time\n// one of its instances mounts — never before — and a retry swaps in a FRESH lazy so the import is\n// genuinely attempted again (a React.lazy caches its first rejection forever).\n\nimport { lazy, type ComponentType, type LazyExoticComponent } from \"react\";\n\nexport interface RenderModule<P> {\n readonly default: ComponentType<P>;\n}\n\nexport type RenderLoader<P> = () => Promise<RenderModule<P>>;\n\nexport interface LoaderEntry<P> {\n readonly attempt: number;\n readonly Component: LazyExoticComponent<ComponentType<P>>;\n}\n\nexport interface LoaderCacheOptions {\n readonly timeoutMs: () => number;\n readonly onImportStart?: (key: string, attempt: number) => void;\n}\n\n/** The error a stalled import becomes, so the error boundary always fires. */\nexport function chunkTimeoutError(key: string, timeoutMs: number): Error {\n const error = new Error(\n `Overlay \"${key}\" render module did not load within ${timeoutMs}ms. The import() did not resolve before the recovery timeout.`,\n );\n error.name = \"ChunkLoadError\";\n return error;\n}\n\nfunction raceTimeout<T>(key: string, real: Promise<T>, timeoutMs: number): Promise<T> {\n // A late rejection after the timeout won must not surface as unhandled.\n real.catch(() => undefined);\n let timer: ReturnType<typeof setTimeout> | undefined;\n const timeout = new Promise<never>((_, reject) => {\n timer = setTimeout(() => reject(chunkTimeoutError(key, timeoutMs)), timeoutMs);\n });\n return Promise.race([real, timeout]).finally(() => {\n if (timer !== undefined) clearTimeout(timer);\n });\n}\n\nexport class LoaderCache {\n private readonly entries = new Map<string, LoaderEntry<unknown>>();\n\n constructor(private readonly options: LoaderCacheOptions) {}\n\n private create<P>(key: string, loader: RenderLoader<P>, attempt: number): LoaderEntry<P> {\n const Component = lazy(() => {\n this.options.onImportStart?.(key, attempt);\n return raceTimeout(key, loader(), this.options.timeoutMs());\n });\n return { attempt, Component };\n }\n\n /** The current lazy component for `key`, created on first request. */\n get<P>(key: string, loader: RenderLoader<P>): LoaderEntry<P> {\n const existing = this.entries.get(key);\n // Sound by construction: an entry under `key` is only ever created from that key's loader.\n if (existing) return existing as LoaderEntry<P>;\n const created = this.create(key, loader, 0);\n this.entries.set(key, created as LoaderEntry<unknown>);\n return created;\n }\n\n /** Replace `key`'s lazy with a fresh one so the next render re-imports. */\n retry<P>(key: string, loader: RenderLoader<P>, failedAttempt: number): void {\n const existing = this.entries.get(key);\n // Another instance already retried past the failed attempt: share its fresh lazy.\n if (existing && existing.attempt > failedAttempt) return;\n const next = this.create(key, loader, failedAttempt + 1);\n this.entries.set(key, next as LoaderEntry<unknown>);\n }\n}\n","// `defineOverlay` — the declare-once API (C38 R2). One light definition per overlay carries its\n// metadata and a lazy `render` import; the definition generates the opener hook, the declarative\n// Controller, the open/close hooks and a typed event emitter. The host renders definitions; the\n// render module is the old controller block, moved verbatim, and is fetched only when opened.\n\nimport { useCallback, useEffect, useMemo, useRef, useState, type ComponentType } from \"react\";\nimport {\n DEFAULT_INSTANCE_ID,\n instanceKey as toInstanceKey,\n type InstanceKey,\n type OverlayDefinitionMeta,\n type OverlayRawData,\n type AnyOverlayMeta,\n} from \"@ai-matrx/summon\";\nimport { selectIsOverlayOpen } from \"@ai-matrx/summon\";\nimport { dispatchClose, dispatchOpen, newInstanceId } from \"./dispatchers\";\nimport { emitOverlayEvent, openOverlayEventChannel, type OverlayEventMap, type OverlayHandlers } from \"./events\";\nimport { createInstanceBody, type InstanceBodyProps, type OverlayRenderProps } from \"./instanceBody\";\nimport { useOptionalOverlayInstance } from \"./instance\";\nimport type { RenderModule } from \"./loaderCache\";\nimport { useSummonDispatch, useSummonSelector, type SummonReactDispatch } from \"./storeHooks\";\n\n/** The open-data key that carries an overlay's event channel id (the old callback-group key). */\nexport const CALLBACK_GROUP_KEY = \"callbackGroupId\";\n\nexport interface OverlayHandle {\n readonly overlayId: string;\n readonly instanceId: string;\n close(): void;\n}\n\nexport interface OverlayOpenOptions<Data, Events extends OverlayEventMap> {\n readonly data?: Data;\n /** Single-instance overlays ignore it unless given; multi-instance generate one when omitted. */\n readonly instanceId?: string;\n /** Plain functions; they reach the caller through an event channel owned by the instance. */\n readonly handlers?: OverlayHandlers<Events>;\n}\n\nexport type OverlayOpener<Data, Events extends OverlayEventMap> = (options?: OverlayOpenOptions<Data, Events>) => OverlayHandle;\n\nexport type OverlayControllerProps<Data, Events extends OverlayEventMap> = Data & {\n readonly instanceId?: string;\n readonly handlers?: OverlayHandlers<Events>;\n};\n\nexport type OverlayEmitter<Events extends OverlayEventMap> = <K extends keyof Events & string>(event: K, payload: Events[K]) => void;\n\n/** What a definition file passes to `defineOverlay<Data>()(…)`. */\nexport interface OverlaySpec<Id extends string, Data, Parsed> extends OverlayDefinitionMeta<Id, Data> {\n /** The lazily loaded render module. Its default export receives `OverlayRenderProps<Parsed>`. */\n readonly render: () => Promise<RenderModule<OverlayRenderProps<NoInfer<Parsed>>>>;\n /** Narrow raw open data once. `null` = refuse: the instance is closed with a warning. */\n readonly parse?: (raw: OverlayRawData) => Parsed | null;\n}\n\n/** The type-erased half the host renders; no data types cross this line. */\nexport interface HostableOverlay {\n readonly id: string;\n readonly label: string;\n readonly instance: \"single\" | \"multi\";\n readonly keepAlive: \"none\" | \"hidden\" | \"restore\";\n /** The metadata the core registry stores (links, window options, defaults…). */\n readonly meta: AnyOverlayMeta;\n readonly Body: ComponentType<InstanceBodyProps>;\n}\n\nexport interface OverlayDefinition<Id extends string, Data, Parsed, Events extends OverlayEventMap>\n extends Omit<OverlayDefinitionMeta<Id, Data>, \"id\" | \"instance\" | \"keepAlive\">,\n HostableOverlay {\n readonly id: Id;\n readonly render: () => Promise<RenderModule<OverlayRenderProps<Parsed>>>;\n /** Imperative opener: `const open = def.useSummon(); open({ data })` → handle. */\n useSummon(): OverlayOpener<Data, Events>;\n /** Declarative form: opens on mount, closes on unmount, re-opens when its data changes. */\n readonly Controller: (props: OverlayControllerProps<Data, Events>) => null;\n useIsOpen(instanceId?: string): boolean;\n /** `const close = def.useClose(); close(instanceId?)`. */\n useClose(): (instanceId?: string) => void;\n /** Inside the render tree: emit a declared event to the opener's handlers. */\n useEmit(): OverlayEmitter<Events>;\n}\n\nfunction openWith<Data, Events extends OverlayEventMap>(\n dispatch: SummonReactDispatch,\n id: string,\n multi: boolean,\n options: OverlayOpenOptions<Data, Events> | undefined,\n): OverlayHandle {\n const instanceId = options?.instanceId ?? (multi ? newInstanceId(id) : DEFAULT_INSTANCE_ID);\n const key = toInstanceKey(id, instanceId);\n const data: Record<string, unknown> = {};\n const given: unknown = options?.data;\n if (typeof given === \"object\" && given !== null) Object.assign(data, given);\n const handlers = options?.handlers;\n if (handlers) data[CALLBACK_GROUP_KEY] = openOverlayEventChannel<Events>(key, () => handlers);\n dispatchOpen(dispatch, id, instanceId, data);\n return { overlayId: id, instanceId, close: () => dispatchClose(dispatch, id, instanceId) };\n}\n\n/** Stable identity for the serialisable part of Controller props (functions never reopen). */\nfunction dataSignature(data: Readonly<Record<string, unknown>>): string {\n try {\n return JSON.stringify(data, (_key, value: unknown) => (typeof value === \"function\" ? undefined : value));\n } catch {\n return String(Date.now());\n }\n}\n\n/**\n * Declare an overlay once. Curried so `Data` (and `Events`) are named while the id and the\n * parsed-data type are inferred:\n *\n * export const notesWindow = defineOverlay<NotesWindowData>()({\n * id: \"notesWindow\", label: \"Notes\", render: () => import(\"./notesWindow.render\"),\n * });\n */\nexport function defineOverlay<Data extends object = Record<string, never>, Events extends OverlayEventMap = Record<never, never>>() {\n return function define<const Id extends string, Parsed = OverlayRawData>(\n spec: OverlaySpec<Id, Data, Parsed>,\n ): OverlayDefinition<Id, Data, Parsed, Events> {\n const id = spec.id;\n const multi = spec.instance === \"multi\";\n // Without `parse`, Parsed is OverlayRawData (NoInfer keeps the render module from widening it).\n const parse = spec.parse ?? ((raw: OverlayRawData) => raw as Parsed);\n const Body = createInstanceBody<Parsed>(id, spec.label, spec.render, parse, spec.parse !== undefined);\n // The registry stores every definition's metadata under one erased type (AnyOverlayMeta).\n const meta: AnyOverlayMeta = spec;\n\n function useSummon(): OverlayOpener<Data, Events> {\n const dispatch = useSummonDispatch();\n return useCallback((options) => openWith(dispatch, id, multi, options), [dispatch]);\n }\n\n function useIsOpen(instanceId: string = DEFAULT_INSTANCE_ID): boolean {\n return useSummonSelector((state) => selectIsOverlayOpen(state, id, instanceId));\n }\n\n function useClose(): (instanceId?: string) => void {\n const dispatch = useSummonDispatch();\n return useCallback((instanceId?: string) => dispatchClose(dispatch, id, instanceId ?? DEFAULT_INSTANCE_ID), [dispatch]);\n }\n\n function useEmit(): OverlayEmitter<Events> {\n const instance = useOptionalOverlayInstance();\n const channelId = instance?.overlayId === id ? instance.rawData?.[CALLBACK_GROUP_KEY] : undefined;\n return useCallback<OverlayEmitter<Events>>(\n (event, payload) => {\n if (typeof channelId === \"string\") emitOverlayEvent(channelId, event, payload);\n },\n [channelId],\n );\n }\n\n function Controller(props: OverlayControllerProps<Data, Events>): null {\n const dispatch = useSummonDispatch();\n const [ownInstanceId] = useState(() => (multi ? newInstanceId(id) : DEFAULT_INSTANCE_ID));\n const instanceId = props.instanceId ?? ownInstanceId;\n // Latest handlers, read at emit time: a new function identity never reopens the overlay.\n const handlersRef = useRef(props.handlers);\n handlersRef.current = props.handlers;\n const hasHandlers = props.handlers !== undefined;\n\n const data = useMemo(() => {\n const out: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(props)) {\n if (key !== \"instanceId\" && key !== \"handlers\") out[key] = value;\n }\n return out;\n }, [props]);\n const signature = dataSignature(data);\n const dataRef = useRef(data);\n dataRef.current = data;\n\n useEffect(() => {\n const key: InstanceKey = toInstanceKey(id, instanceId);\n const open: Record<string, unknown> = { ...dataRef.current };\n if (hasHandlers) open[CALLBACK_GROUP_KEY] = openOverlayEventChannel<Events>(key, () => handlersRef.current);\n dispatchOpen(dispatch, id, instanceId, open);\n return () => dispatchClose(dispatch, id, instanceId);\n }, [dispatch, instanceId, signature, hasHandlers]);\n\n return null;\n }\n Controller.displayName = `${id}Controller`;\n\n return {\n ...spec,\n id,\n label: spec.label,\n instance: multi ? \"multi\" : \"single\",\n keepAlive: spec.keepAlive ?? \"none\",\n meta,\n Body,\n useSummon,\n Controller,\n useIsOpen,\n useClose,\n useEmit,\n };\n };\n}\n","// The one place the React section turns an untyped (string) overlay id into the core's typed\n// action creators. Inside the package `OverlayId` is `string`; a host that augments the registry\n// narrows it to its ids, and these keep compiling there because definitions carry their own id.\n\nimport { closeOverlay, openOverlay } from \"@ai-matrx/summon\";\nimport { DEFAULT_INSTANCE_ID, type OverlayDataOf, type OverlayId } from \"@ai-matrx/summon\";\nimport type { SummonReactDispatch } from \"./storeHooks\";\n\nexport function newInstanceId(overlayId: string): string {\n return `${overlayId}-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;\n}\n\nexport function dispatchOpen(dispatch: SummonReactDispatch, overlayId: string, instanceId: string, data: unknown): void {\n dispatch(\n openOverlay({\n overlayId: overlayId as OverlayId,\n instanceId,\n data: (data ?? null) as OverlayDataOf<OverlayId> | null,\n }),\n );\n}\n\nexport function dispatchClose(dispatch: SummonReactDispatch, overlayId: string, instanceId: string = DEFAULT_INSTANCE_ID): void {\n dispatch(closeOverlay({ overlayId: overlayId as OverlayId, instanceId }));\n}\n","// Callback-aware opening: callers pass plain handler functions; the opener puts them behind a\n// handles event channel owned by the instance (`overlayId:instanceId`) and only the channel's id\n// rides open data. Closing the instance disposes the channel (the core close middleware calls\n// `disposeOwner`), so no opener disposes by hand.\n\nimport { createEventChannel, getEventChannel } from \"@ai-matrx/summon/handles\";\nimport type { InstanceKey } from \"@ai-matrx/summon\";\n\n/** Event name → payload, declared once per overlay: `defineOverlay<Data, { uploaded: Result }>()`. */\nexport type OverlayEventMap = Record<string, unknown>;\n\nexport type OverlayHandlers<Events extends OverlayEventMap> = {\n readonly [K in keyof Events]?: (payload: Events[K]) => void;\n};\n\n/** The one message shape on an overlay's channel. */\nexport interface OverlayEventMessage {\n readonly type: string;\n readonly payload: unknown;\n}\n\n/** Open a channel owned by `owner` that forwards each event to the handler `getHandlers` returns now. */\nexport function openOverlayEventChannel<Events extends OverlayEventMap>(\n owner: InstanceKey,\n getHandlers: () => OverlayHandlers<Events> | undefined,\n): string {\n const channel = createEventChannel<OverlayEventMessage>({ owner });\n channel.subscribe((message) => {\n const handlers = getHandlers() as Readonly<Record<string, ((payload: unknown) => void) | undefined>> | undefined;\n handlers?.[message.type]?.(message.payload);\n });\n return channel.id;\n}\n\n/** Deliver one event on a channel; a disposed or unknown channel is a silent no-op by contract. */\nexport function emitOverlayEvent(channelId: string, type: string, payload: unknown): void {\n getEventChannel<OverlayEventMessage>(channelId)?.emit({ type, payload });\n}\n","// One open instance, rendered: instance context → host wrapper → error boundary → Suspense →\n// the lazily loaded render module with its typed props. Created per definition (inside\n// `defineOverlay`) so the parsed-data type stays inside the closure and the host deals only in\n// untyped instances — no casts at the host.\n\nimport { Suspense, useEffect, useMemo, useRef, type ComponentType, type ReactNode } from \"react\";\nimport type { InstanceKey, OverlayRawData } from \"@ai-matrx/summon\";\nimport type { OverlayRenderContext } from \"./context\";\nimport { OverlayErrorBoundary } from \"./OverlayErrorBoundary\";\nimport { OverlayInstanceContext, type OverlayInstanceContextValue } from \"./instance\";\nimport type { RenderLoader } from \"./loaderCache\";\nimport { useSummonConfig, useSummonPorts } from \"./storeHooks\";\n\n/** The props every overlay's render module receives. */\nexport interface OverlayRenderProps<Data = OverlayRawData> {\n readonly overlayId: string;\n readonly instanceId: string;\n /** The open data: raw (narrow it yourself) unless the definition declares `parse`. */\n readonly data: Data;\n readonly isOpen: true;\n readonly close: () => void;\n /** True while kept alive behind a close (`keepAlive: \"hidden\"`). */\n readonly hidden: boolean;\n}\n\n/** What the host hands each instance — no data type, by design. */\nexport interface InstanceBodyProps {\n readonly instanceId: string;\n readonly instanceKey: InstanceKey;\n readonly data: OverlayRawData;\n readonly hidden: boolean;\n readonly close: () => void;\n}\n\ninterface LazyRenderProps<Parsed> {\n readonly overlayId: string;\n readonly instanceId: string;\n readonly data: Parsed;\n readonly hidden: boolean;\n readonly close: () => void;\n readonly render: RenderLoader<OverlayRenderProps<Parsed>>;\n readonly attemptRef: { current: number };\n}\n\nfunction LazyRender<Parsed>({ overlayId, instanceId, data, hidden, close, render, attemptRef }: LazyRenderProps<Parsed>) {\n const { loaders } = useSummonConfig();\n const entry = loaders.get(overlayId, render);\n attemptRef.current = entry.attempt;\n const Render = entry.Component;\n return <Render overlayId={overlayId} instanceId={instanceId} data={data} isOpen close={close} hidden={hidden} />;\n}\n\nexport function createInstanceBody<Parsed>(\n overlayId: string,\n label: string,\n render: RenderLoader<OverlayRenderProps<Parsed>>,\n parse: (raw: OverlayRawData) => Parsed | null,\n /** False when the definition has no `parse`: a null result is then just empty data. */\n refusable: boolean,\n): ComponentType<InstanceBodyProps> {\n function OverlayInstanceBody({ instanceId, instanceKey, data, hidden, close }: InstanceBodyProps) {\n const config = useSummonConfig();\n const ports = useSummonPorts();\n const attemptRef = useRef(0);\n const parsed = useMemo(() => parse(data), [data]);\n const refused = refusable && parsed === null;\n\n useEffect(() => {\n if (!refused) return;\n if (process.env.NODE_ENV !== \"production\") {\n ports.notify.warn(`Overlay \"${overlayId}\" was opened with data its parse() refused; closing it.`, {\n id: `overlays-parse-${instanceKey}`,\n });\n }\n close();\n }, [refused, ports, instanceKey, close]);\n\n const instance = useMemo<OverlayInstanceContextValue>(\n () => ({ overlayId, instanceId, instanceKey, close, hidden, rawData: data }),\n [instanceId, instanceKey, close, hidden, data],\n );\n\n if (refused) return null;\n\n const context: OverlayRenderContext = { overlayId, instanceId, instanceKey, label };\n const body: ReactNode = (\n <OverlayErrorBoundary\n overlayId={overlayId}\n instanceId={instanceId}\n instanceKey={instanceKey}\n label={label}\n errors={ports.errors}\n fallback={config.errorFallback}\n extras={config.errorReportExtras}\n onRetry={() => config.loaders.retry(overlayId, render, attemptRef.current)}\n onClose={close}\n >\n <Suspense fallback={<config.loadingFallback overlayId={overlayId} label={label} />}>\n <LazyRender\n overlayId={overlayId}\n instanceId={instanceId}\n data={parsed as Parsed}\n hidden={hidden}\n close={close}\n render={render}\n attemptRef={attemptRef}\n />\n </Suspense>\n </OverlayErrorBoundary>\n );\n\n return (\n <OverlayInstanceContext.Provider value={instance}>\n {config.renderWrapper ? config.renderWrapper(body, context) : body}\n </OverlayInstanceContext.Provider>\n );\n }\n OverlayInstanceBody.displayName = `Overlay(${overlayId})`;\n return OverlayInstanceBody;\n}\n","// A per-instance error boundary. React.lazy + Suspense give a loading state but no error state,\n// so a rejected import (or a render throw) would otherwise unmount the whole host. Outcomes are\n// exactly: the overlay, its loading fallback, or a meaningful error with Close and Try again.\n\nimport { Component, type ComponentType, type ErrorInfo, type ReactNode } from \"react\";\nimport type { ErrorSinkPort } from \"@ai-matrx/summon\";\nimport type { OverlayErrorExtrasContext, OverlayErrorFallbackProps } from \"./context\";\nimport { normalizeOverlayError } from \"./fallbacks\";\n\nexport interface OverlayErrorBoundaryProps {\n readonly overlayId: string;\n readonly instanceId: string;\n readonly instanceKey: string;\n readonly label: string;\n readonly errors: ErrorSinkPort;\n readonly fallback: ComponentType<OverlayErrorFallbackProps>;\n readonly extras: ((context: OverlayErrorExtrasContext) => ReactNode) | null;\n /** Swap in a fresh loader BEFORE the boundary clears, so the remount re-imports. */\n readonly onRetry: () => void;\n readonly onClose: () => void;\n readonly children: ReactNode;\n}\n\ninterface OverlayErrorBoundaryState {\n readonly error: unknown;\n readonly hasError: boolean;\n readonly componentStack: string | null;\n}\n\nconst CLEAR: OverlayErrorBoundaryState = { error: null, hasError: false, componentStack: null };\n\nexport class OverlayErrorBoundary extends Component<OverlayErrorBoundaryProps, OverlayErrorBoundaryState> {\n override state: OverlayErrorBoundaryState = CLEAR;\n\n static getDerivedStateFromError(error: unknown): Partial<OverlayErrorBoundaryState> {\n return { error, hasError: true };\n }\n\n override componentDidCatch(error: unknown, info: ErrorInfo): void {\n const componentStack = info.componentStack ?? null;\n this.setState({ componentStack });\n const e = normalizeOverlayError(error);\n // Loud recovery: a caught overlay error is a real bug or a broken chunk graph.\n this.props.errors.capture(error, {\n boundary: \"OverlayErrorBoundary\",\n overlayId: this.props.overlayId,\n instanceId: this.props.instanceId,\n errorName: e.name,\n isChunkLoadError: e.isChunkLoadError,\n componentStack,\n });\n }\n\n private readonly retry = (): void => {\n this.props.onRetry();\n this.setState(CLEAR);\n };\n\n override render(): ReactNode {\n const { hasError, error, componentStack } = this.state;\n if (!hasError) return this.props.children;\n const { overlayId, instanceId, instanceKey, label, extras, onClose } = this.props;\n const Fallback = this.props.fallback;\n const renderedExtras = extras ? extras({ overlayId, instanceId, instanceKey, label, error, componentStack }) : null;\n return (\n <Fallback\n overlayId={overlayId}\n instanceId={instanceId}\n label={label}\n error={error}\n componentStack={componentStack}\n retry={this.retry}\n close={onClose}\n extras={renderedExtras}\n />\n );\n }\n}\n","// The context every rendered overlay instance provides to its subtree, and the hooks that read\n// it: who am I, close me, am I hidden, and `useOverlayState` — saved component state scoped to\n// the open instance that survives `keepAlive: \"restore\"` (and persistence, when on).\n\nimport { createContext, useCallback, useContext } from \"react\";\nimport type { InstanceKey, OverlayRawData } from \"@ai-matrx/summon\";\nimport { selectOverlayStateValue, setOverlayStateValue } from \"@ai-matrx/summon\";\nimport { useSummonDispatch, useSummonSelector, useSummonStore } from \"./storeHooks\";\n\nexport interface OverlayInstanceContextValue {\n readonly overlayId: string;\n readonly instanceId: string;\n readonly instanceKey: InstanceKey;\n readonly close: () => void;\n readonly hidden: boolean;\n /** The open data as it arrived (pre-parse); event emitters read their channel id from it. */\n readonly rawData: OverlayRawData;\n}\n\nexport const OverlayInstanceContext = createContext<OverlayInstanceContextValue | null>(null);\nOverlayInstanceContext.displayName = \"OverlayInstanceContext\";\n\n/** The open instance this component renders inside. Throws outside an overlay. */\nexport function useOverlayInstance(): OverlayInstanceContextValue {\n const value = useContext(OverlayInstanceContext);\n if (!value) {\n throw new Error(\"[summon] useOverlayInstance() was called outside a rendered overlay.\");\n }\n return value;\n}\n\n/** Same as `useOverlayInstance`, but `null` outside an overlay. */\nexport function useOptionalOverlayInstance(): OverlayInstanceContextValue | null {\n return useContext(OverlayInstanceContext);\n}\n\nexport type OverlayStateSetter<T> = (next: T | ((previous: T) => T)) => void;\n\n/**\n * Saved state for the current overlay instance — `useState`, but kept in the overlays store under\n * `overlayId:instanceId` so it survives `keepAlive: \"restore\"` close/reopen and is persisted when\n * persistence is on. Any descendant of the overlay may call it; the same `name` reads the same\n * value. Values must be serialisable.\n */\nexport function useOverlayState<T>(name: string, initial: T): [T, OverlayStateSetter<T>] {\n const { instanceKey } = useOverlayInstance();\n const dispatch = useSummonDispatch();\n const store = useSummonStore();\n const stored = useSummonSelector((state) => selectOverlayStateValue(state, instanceKey, name));\n const value = stored === undefined ? initial : (stored as T);\n const setValue = useCallback<OverlayStateSetter<T>>(\n (next) => {\n const current = selectOverlayStateValue(store.getState(), instanceKey, name);\n const previous = current === undefined ? initial : (current as T);\n const resolved = typeof next === \"function\" ? (next as (previous: T) => T)(previous) : next;\n dispatch(setOverlayStateValue({ key: instanceKey, name, value: resolved }));\n },\n // `initial` is the first-render default, like useState's; its identity never re-binds.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [dispatch, store, instanceKey, name],\n );\n return [value, setValue];\n}\n","// `<SummonHost definitions>` — registers each definition's metadata and renders every definition\n// through its OWN subscriber (`DefinitionSlot`), so opening overlay A never re-renders B (the old\n// controller held ~440 subscriptions in one component). A closed overlay puts nothing in the tree\n// and fetches no chunk. `keepAlive: \"hidden\"` keeps closed instances mounted inside\n// `<Activity mode=\"hidden\">`, LRU-capped per provider.\n\nimport { Activity, useCallback, useEffect, useRef, useState, type ReactNode } from \"react\";\nimport { releaseOverlayInstance } from \"@ai-matrx/summon\";\nimport { registerOverlayMeta } from \"@ai-matrx/summon\";\nimport { closeOverlaysBoundToPage, overlayIdsBoundToPage, selectOpenInstances, type OpenInstanceView } from \"@ai-matrx/summon\";\nimport { instanceKey as toInstanceKey, type OverlayRawData } from \"@ai-matrx/summon\";\nimport type { HostableOverlay } from \"./defineOverlay\";\nimport { dispatchClose } from \"./dispatchers\";\nimport { useSummonConfig, useSummonDispatch, useSummonPorts, useSummonSelector } from \"./storeHooks\";\n\nexport interface SummonHostProps {\n /** Every overlay this host can render — the app's definition list, passed once. */\n readonly definitions: readonly HostableOverlay[];\n}\n\nfunction asRawData(data: unknown): OverlayRawData {\n return typeof data === \"object\" && data !== null && !Array.isArray(data) ? (data as OverlayRawData) : null;\n}\n\n/** Equal when the same instances are open with the same data references. */\nfunction sameInstances(a: readonly OpenInstanceView[], b: readonly OpenInstanceView[]): boolean {\n if (a === b) return true;\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i += 1) {\n const x = a[i];\n const y = b[i];\n if (!x || !y || x.instanceId !== y.instanceId || x.data !== y.data) return false;\n }\n return true;\n}\n\nconst NO_RETAINED: ReadonlyMap<string, OverlayRawData> = new Map();\n\n/** Close-on-navigation: on a pathname change, close every overlay bound to the page. */\nexport function useCloseOnNavigation(): void {\n const ports = useSummonPorts();\n const dispatch = useSummonDispatch();\n useEffect(() => {\n const router = ports.router;\n let previous = router.pathname();\n return router.subscribe(() => {\n const next = router.pathname();\n if (next === previous) return;\n previous = next;\n const overlayIds = overlayIdsBoundToPage();\n if (overlayIds.length > 0) dispatch(closeOverlaysBoundToPage({ overlayIds }));\n });\n }, [ports, dispatch]);\n}\n\ninterface InstanceSlotProps {\n readonly definition: HostableOverlay;\n readonly instanceId: string;\n readonly data: OverlayRawData;\n readonly hidden: boolean;\n}\n\nfunction InstanceSlot({ definition, instanceId, data, hidden }: InstanceSlotProps) {\n const dispatch = useSummonDispatch();\n const close = useCallback(() => dispatchClose(dispatch, definition.id, instanceId), [dispatch, definition.id, instanceId]);\n const Body = definition.Body;\n return <Body instanceId={instanceId} instanceKey={toInstanceKey(definition.id, instanceId)} data={data} hidden={hidden} close={close} />;\n}\n\nfunction DefinitionSlot({ definition }: { readonly definition: HostableOverlay }) {\n const { keepAlive } = useSummonConfig();\n const dispatch = useSummonDispatch();\n const open = useSummonSelector((state) => selectOpenInstances(state, definition.id), sameInstances);\n const keepHidden = definition.keepAlive === \"hidden\";\n\n // Closed-but-alive instances, derived during render (no unmount/remount flash on close).\n const [retained, setRetained] = useState(NO_RETAINED);\n const [previousOpen, setPreviousOpen] = useState(open);\n if (previousOpen !== open) {\n setPreviousOpen(open);\n if (keepHidden) {\n const openIds = new Set(open.map((instance) => instance.instanceId));\n const next = new Map(retained);\n for (const instance of previousOpen) {\n if (!openIds.has(instance.instanceId)) next.set(instance.instanceId, asRawData(instance.data));\n }\n for (const id of openIds) next.delete(id);\n setRetained(next);\n }\n }\n\n // Mirror the retained set into the provider LRU; eviction unmounts here.\n const registered = useRef(new Set<string>());\n useEffect(() => {\n const seen = registered.current;\n for (const instanceId of retained.keys()) {\n if (seen.has(instanceId)) continue;\n seen.add(instanceId);\n const key = toInstanceKey(definition.id, instanceId);\n keepAlive.retain(key, () => {\n seen.delete(instanceId);\n // Evicted: its handles and saved state go now, as a plain close would have done.\n releaseOverlayInstance(dispatch, key);\n setRetained((current) => {\n if (!current.has(instanceId)) return current;\n const next = new Map(current);\n next.delete(instanceId);\n return next;\n });\n });\n }\n for (const instanceId of [...seen]) {\n if (retained.has(instanceId)) continue;\n seen.delete(instanceId);\n keepAlive.release(toInstanceKey(definition.id, instanceId));\n }\n }, [retained, keepAlive, definition.id, dispatch]);\n useEffect(() => {\n const seen = registered.current;\n return () => {\n for (const instanceId of seen) {\n const key = toInstanceKey(definition.id, instanceId);\n keepAlive.release(key);\n releaseOverlayInstance(dispatch, key);\n }\n seen.clear();\n };\n }, [keepAlive, definition.id, dispatch]);\n\n if (open.length === 0 && retained.size === 0) return null;\n\n const nodes: ReactNode[] = [];\n for (const instance of open) {\n const node = (\n <InstanceSlot key={instance.instanceId} definition={definition} instanceId={instance.instanceId} data={asRawData(instance.data)} hidden={false} />\n );\n nodes.push(\n keepHidden ? (\n <Activity key={instance.instanceId} mode=\"visible\">\n {node}\n </Activity>\n ) : (\n node\n ),\n );\n }\n if (keepHidden) {\n for (const [instanceId, data] of retained) {\n nodes.push(\n <Activity key={instanceId} mode=\"hidden\">\n <InstanceSlot key={instanceId} definition={definition} instanceId={instanceId} data={data} hidden />\n </Activity>,\n );\n }\n }\n return <>{nodes}</>;\n}\n\nexport function SummonHost({ definitions }: SummonHostProps) {\n // Register before any slot renders: links, the close middleware and defaults read the registry.\n const registeredFor = useRef<readonly HostableOverlay[] | null>(null);\n if (registeredFor.current !== definitions) {\n registerOverlayMeta(definitions.map((definition) => definition.meta));\n registeredFor.current = definitions;\n }\n useCloseOnNavigation();\n return (\n <>\n {definitions.map((definition) => (\n <DefinitionSlot key={definition.id} definition={definition} />\n ))}\n </>\n );\n}\n","// Id-addressed hooks — the escape hatch when a caller has an overlay id rather than its\n// definition. Typed through the host's `OverlayRegistry` augmentation.\n\nimport { useCallback } from \"react\";\nimport { getOverlayMeta } from \"@ai-matrx/summon\";\nimport { selectIsOverlayOpen } from \"@ai-matrx/summon\";\nimport { DEFAULT_INSTANCE_ID, type OverlayDataOf, type OverlayId } from \"@ai-matrx/summon\";\nimport type { OverlayHandle } from \"./defineOverlay\";\nimport { dispatchClose, dispatchOpen, newInstanceId } from \"./dispatchers\";\nimport { useSummonDispatch, useSummonSelector } from \"./storeHooks\";\n\n/** True while the instance is open. */\nexport function useIsOverlayOpen(overlayId: OverlayId, instanceId: string = DEFAULT_INSTANCE_ID): boolean {\n return useSummonSelector((state) => selectIsOverlayOpen(state, overlayId, instanceId));\n}\n\nexport interface OpenOverlayOptions<Id extends OverlayId> {\n readonly data?: OverlayDataOf<Id>;\n readonly instanceId?: string;\n}\n\n/**\n * Open an overlay by id. A multi-instance overlay (per its registered definition) gets a fresh\n * instance id when none is given; a single-instance one opens \"default\".\n */\nexport function useOpenOverlay<Id extends OverlayId>(overlayId: Id): (options?: OpenOverlayOptions<Id>) => OverlayHandle {\n const dispatch = useSummonDispatch();\n return useCallback(\n (options?: OpenOverlayOptions<Id>) => {\n const multi = getOverlayMeta(overlayId)?.instance === \"multi\";\n const instanceId = options?.instanceId ?? (multi ? newInstanceId(overlayId) : DEFAULT_INSTANCE_ID);\n dispatchOpen(dispatch, overlayId, instanceId, options?.data ?? null);\n return { overlayId, instanceId, close: () => dispatchClose(dispatch, overlayId, instanceId) };\n },\n [dispatch, overlayId],\n );\n}\n\n/** A stable close function for one instance (pass straight to an `onClose` prop). */\nexport function useCloseOverlay(overlayId: OverlayId, instanceId: string = DEFAULT_INSTANCE_ID): () => void {\n const dispatch = useSummonDispatch();\n return useCallback(() => dispatchClose(dispatch, overlayId, instanceId), [dispatch, overlayId, instanceId]);\n}\n"],"mappings":";;;AAKA,SAAS,aAAAA,YAAW,SAAS,QAAQ,gBAAoD;AACzF,SAAS,gBAAgB;AAEzB,SAAS,oBAAsC;AAC/C,SAAS,yBAAyB;;;ACLlC,SAAS,qBAAyD;AAM3D,IAAM,qBAAqB,cAA6C,IAAI;AACnF,mBAAmB,cAAc;AAE1B,IAAM,qBAAqB,cAAkC,IAAI;AACxE,mBAAmB,cAAc;AA6C1B,IAAM,sBAAsB,cAAwC,IAAI;AAC/E,oBAAoB,cAAc;;;ACxDlC,SAAS,iBAAiB;AAC1B,SAAS,cAAc;;;ACDvB,SAAS,kBAAkB;AAC3B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AAGP,SAAS,qBAAuC;AAUzC,IAAM,oBAAkD,mBAAmB,kBAAkB,EAAE,UAA2B;AAG1H,IAAM,oBAAsD,mBAAmB,kBAAkB,EAAE,UAA+B;AAGlI,IAAM,iBAA6C,gBAAgB,kBAAkB,EAAE,UAA4B;AAE1H,IAAM,mBACJ;AAGK,SAAS,iBAA8B;AAC5C,QAAM,QAAQ,WAAW,kBAAkB;AAC3C,MAAI,CAAC,MAAO,OAAM,IAAI,MAAM,gBAAgB;AAC5C,SAAO;AACT;AAMO,SAAS,yBAAsC;AACpD,SAAO,WAAW,kBAAkB,KAAK;AAC3C;AAEO,SAAS,kBAAqC;AACnD,QAAM,SAAS,WAAW,mBAAmB;AAC7C,MAAI,CAAC,OAAQ,OAAM,IAAI,MAAM,gBAAgB;AAC7C,SAAO;AACT;;;ADNM,SAKE,KALF;AAjCC,SAAS,sBAAsB,OAAwC;AAC5E,MAAI,iBAAiB,OAAO;AAC1B,UAAM,mBACJ,MAAM,SAAS,oBACf,4GAA4G;AAAA,MAC1G,MAAM;AAAA,IACR;AACF,WAAO,EAAE,MAAM,MAAM,MAAM,SAAS,MAAM,SAAS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ACxG,SAAO,kBAAkB,CAAC,UAAUC,qBAAoB,OAAO,WAAW,UAAU,CAAC;AACvF;AAWO,SAAS,eAAqC,WAAoE;AACvH,QAAM,WAAW,kBAAkB;AACnC,SAAOC;AAAA,IACL,CAAC,YAAqC;AACpC,YAAM,QAAQ,eAAe,SAAS,GAAG,aAAa;AACtD,YAAM,aAAa,SAAS,eAAe,QAAQ,cAAc,SAAS,IAAIF;AAC9E,mBAAa,UAAU,WAAW,YAAY,SAAS,QAAQ,IAAI;AACnE,aAAO,EAAE,WAAW,YAAY,OAAO,MAAM,cAAc,UAAU,WAAW,UAAU,EAAE;AAAA,IAC9F;AAAA,IACA,CAAC,UAAU,SAAS;AAAA,EACtB;AACF;AAGO,SAAS,gBAAgB,WAAsB,aAAqBA,sBAAiC;AAC1G,QAAM,WAAW,kBAAkB;AACnC,SAAOE,aAAY,MAAM,cAAc,UAAU,WAAW,UAAU,GAAG,CAAC,UAAU,WAAW,UAAU,CAAC;AAC5G;","names":["useEffect","Component","jsx","useEffect","useCallback","useEffect","useMemo","useRef","useState","DEFAULT_INSTANCE_ID","useEffect","useMemo","useRef","jsx","createContext","useContext","createContext","useContext","jsx","useRef","useMemo","useEffect","DEFAULT_INSTANCE_ID","useCallback","useState","useRef","useMemo","useEffect","useCallback","useEffect","useRef","useState","toInstanceKey","jsx","useEffect","useCallback","toInstanceKey","useState","useRef","useCallback","selectIsOverlayOpen","DEFAULT_INSTANCE_ID","DEFAULT_INSTANCE_ID","selectIsOverlayOpen","useCallback"]}
|
|
1
|
+
{"version":3,"sources":["../src/react/SummonProvider.tsx","../src/react/context.ts","../src/react/fallbacks.tsx","../src/react/storeHooks.ts","../src/react/keepAlive.ts","../src/react/loaderCache.ts","../src/react/defineOverlay.tsx","../src/react/dispatchers.ts","../src/react/events.ts","../src/react/instanceBody.tsx","../src/react/OverlayErrorBoundary.tsx","../src/react/instance.tsx","../src/react/SummonHost.tsx","../src/react/hooks.ts"],"sourcesContent":["// `<SummonProvider>` — mounts the overlays store on the package's own context (the host's store\n// when passed — AI Matrx mounts `summonReducers` into its one store — else a private store made\n// once), the resolved ports, and the render-layer knobs (fallbacks, error extras, wrapper,\n// keep-alive cap, import timeout).\n\nimport { useEffect, useMemo, useRef, useState, type ComponentType, type ReactNode } from \"react\";\nimport { Provider } from \"react-redux\";\nimport type { Store } from \"@reduxjs/toolkit\";\nimport { resolvePorts, type SummonPorts } from \"@ai-matrx/summon\";\nimport { createSummonStore } from \"@ai-matrx/summon\";\nimport {\n SummonConfigContext,\n SummonPortsContext,\n SummonStoreContext,\n type OverlayErrorExtrasContext,\n type OverlayErrorFallbackProps,\n type OverlayLoadingFallbackProps,\n type OverlayRenderContext,\n type SummonReactConfig,\n} from \"./context\";\nimport { OverlayErrorFallback, OverlayLoadingFallback } from \"./fallbacks\";\nimport { KeepAliveRegistry } from \"./keepAlive\";\nimport { LoaderCache } from \"./loaderCache\";\n\nexport const DEFAULT_KEEP_ALIVE_LIMIT = 8;\nexport const DEFAULT_IMPORT_TIMEOUT_MS = 12_000;\nexport const DEFAULT_STALL_WARN_MS = 10_000;\n\nexport interface SummonProviderProps {\n /** The host's Redux store with `summonReducers` mounted at their root keys. Omit for a private store. */\n readonly store?: Store<unknown>;\n /** Host ports; anything omitted uses the working default. */\n readonly ports?: Partial<SummonPorts>;\n readonly fallbacks?: {\n readonly loading?: ComponentType<OverlayLoadingFallbackProps>;\n readonly error?: ComponentType<OverlayErrorFallbackProps>;\n };\n /** Extra controls in the default error card's footer (AI Matrx: \"Copy for AI\"). */\n readonly errorReportExtras?: (context: OverlayErrorExtrasContext) => ReactNode;\n /** Wrap every rendered overlay (AI Matrx: its surface layer boundary). */\n readonly renderWrapper?: (node: ReactNode, context: OverlayRenderContext) => ReactNode;\n /** Most closed-but-alive (`keepAlive: \"hidden\"`) instances kept mounted. Default 8. */\n readonly keepAliveLimit?: number;\n /** A render-module import that has not settled by then becomes a ChunkLoadError. Default 12 s. */\n readonly importTimeoutMs?: number;\n /** When the loading fallback reports a stall to the error port. Default 10 s. */\n readonly stallWarnMs?: number;\n readonly children?: ReactNode;\n}\n\nexport function SummonProvider({\n store,\n ports,\n fallbacks,\n errorReportExtras,\n renderWrapper,\n keepAliveLimit = DEFAULT_KEEP_ALIVE_LIMIT,\n importTimeoutMs = DEFAULT_IMPORT_TIMEOUT_MS,\n stallWarnMs = DEFAULT_STALL_WARN_MS,\n children,\n}: SummonProviderProps) {\n const resolvedPorts = useMemo(() => resolvePorts(ports), [ports]);\n const [privateStore] = useState(() => (store ? null : createSummonStore({ ports: resolvedPorts })));\n const activeStore: Store<unknown> = store ?? (privateStore as Store<unknown>);\n\n const timeoutRef = useRef(importTimeoutMs);\n timeoutRef.current = importTimeoutMs;\n const [keepAlive] = useState(() => new KeepAliveRegistry(keepAliveLimit));\n const [loaders] = useState(() => new LoaderCache({ timeoutMs: () => timeoutRef.current }));\n useEffect(() => keepAlive.setLimit(keepAliveLimit), [keepAlive, keepAliveLimit]);\n\n const loading = fallbacks?.loading ?? OverlayLoadingFallback;\n const error = fallbacks?.error ?? OverlayErrorFallback;\n const config = useMemo<SummonReactConfig>(\n () => ({\n loadingFallback: loading,\n errorFallback: error,\n errorReportExtras: errorReportExtras ?? null,\n renderWrapper: renderWrapper ?? null,\n importTimeoutMs,\n stallWarnMs,\n keepAlive,\n loaders,\n }),\n [loading, error, errorReportExtras, renderWrapper, importTimeoutMs, stallWarnMs, keepAlive, loaders],\n );\n\n return (\n <Provider store={activeStore} context={SummonStoreContext}>\n <SummonPortsContext.Provider value={resolvedPorts}>\n <SummonConfigContext.Provider value={config}>{children}</SummonConfigContext.Provider>\n </SummonPortsContext.Provider>\n </Provider>\n );\n}\n","// The React section's own contexts. The overlays store rides its OWN react-redux context\n// (chat-package pattern), so a private overlays store never collides with a host's store and a\n// host that mounts `summonReducers` into its one store simply passes it in.\n\nimport { createContext, type ComponentType, type ReactNode } from \"react\";\nimport type { ReactReduxContextValue } from \"react-redux\";\nimport type { SummonPorts } from \"@ai-matrx/summon\";\nimport type { KeepAliveRegistry } from \"./keepAlive\";\nimport type { LoaderCache } from \"./loaderCache\";\n\nexport const SummonStoreContext = createContext<ReactReduxContextValue | null>(null);\nSummonStoreContext.displayName = \"SummonStoreContext\";\n\nexport const SummonPortsContext = createContext<SummonPorts | null>(null);\nSummonPortsContext.displayName = \"SummonPortsContext\";\n\n/** What every slot hands to `renderWrapper`, error extras and the fallbacks. */\nexport interface OverlayRenderContext {\n readonly overlayId: string;\n readonly instanceId: string;\n readonly instanceKey: string;\n readonly label: string;\n}\n\nexport interface OverlayLoadingFallbackProps {\n readonly overlayId: string;\n readonly label: string;\n}\n\nexport interface OverlayErrorFallbackProps {\n readonly overlayId: string;\n readonly instanceId: string;\n readonly label: string;\n readonly error: unknown;\n readonly componentStack: string | null;\n /** Re-import the render module and mount again. */\n readonly retry: () => void;\n /** Close this instance (no reload). */\n readonly close: () => void;\n /** Host-provided extras (AI Matrx: \"Copy for AI\"), already rendered for this error. */\n readonly extras: ReactNode;\n}\n\nexport interface OverlayErrorExtrasContext extends OverlayRenderContext {\n readonly error: unknown;\n readonly componentStack: string | null;\n}\n\nexport interface SummonReactConfig {\n readonly loadingFallback: ComponentType<OverlayLoadingFallbackProps>;\n readonly errorFallback: ComponentType<OverlayErrorFallbackProps>;\n readonly errorReportExtras: ((context: OverlayErrorExtrasContext) => ReactNode) | null;\n readonly renderWrapper: ((node: ReactNode, context: OverlayRenderContext) => ReactNode) | null;\n readonly importTimeoutMs: number;\n readonly stallWarnMs: number;\n readonly keepAlive: KeepAliveRegistry;\n readonly loaders: LoaderCache;\n}\n\nexport const SummonConfigContext = createContext<SummonReactConfig | null>(null);\nSummonConfigContext.displayName = \"SummonConfigContext\";\n","// The default loading and error fallbacks every overlay renders through. A host replaces either\n// with `<SummonProvider fallbacks>`; AI Matrx adds its \"Copy for AI\" through `errorReportExtras`.\n// Design-system components and tokens only — no app imports.\n\nimport { useEffect } from \"react\";\nimport { Button } from \"@ai-matrx/design-system\";\nimport type { OverlayErrorFallbackProps, OverlayLoadingFallbackProps } from \"./context\";\nimport { useSummonConfig, useSummonPorts } from \"./storeHooks\";\n\nexport interface NormalizedOverlayError {\n readonly name: string;\n readonly message: string;\n readonly stack: string | null;\n readonly isChunkLoadError: boolean;\n}\n\nexport function normalizeOverlayError(error: unknown): NormalizedOverlayError {\n if (error instanceof Error) {\n const isChunkLoadError =\n error.name === \"ChunkLoadError\" ||\n /Loading chunk [\\w-]+ failed|Failed to fetch dynamically imported module|Importing a module script failed/i.test(\n error.message,\n );\n return { name: error.name, message: error.message, stack: error.stack ?? null, isChunkLoadError };\n }\n return { name: \"Error\", message: typeof error === \"string\" ? error : String(error), stack: null, isChunkLoadError: false };\n}\n\n/**\n * Spinner while the render module is in flight. Never blank. At the stall threshold it reports\n * once through the error port; the loader's import timeout (later) turns a hung import into a\n * real error so the error fallback takes over.\n */\nexport function OverlayLoadingFallback({ overlayId, label }: OverlayLoadingFallbackProps) {\n const ports = useSummonPorts();\n const { stallWarnMs } = useSummonConfig();\n useEffect(() => {\n const timer = setTimeout(() => {\n ports.errors.capture(new Error(`Overlay \"${overlayId}\" still loading after ${stallWarnMs}ms`), {\n stage: \"overlay-load-stall\",\n overlayId,\n level: \"warning\",\n });\n }, stallWarnMs);\n return () => clearTimeout(timer);\n }, [ports, overlayId, stallWarnMs]);\n\n return (\n <div className=\"pointer-events-none fixed inset-0 z-[2147483000] flex items-center justify-center p-4\">\n <div\n role=\"status\"\n aria-label={`Loading ${label}`}\n className=\"pointer-events-auto flex items-center gap-3 rounded-xl border border-border bg-card px-5 py-4 text-sm text-muted-foreground shadow-[var(--elevation-2)]\"\n >\n <span aria-hidden className=\"size-4 animate-spin rounded-full border-2 border-border border-t-primary\" />\n <span>Loading…</span>\n </div>\n </div>\n );\n}\n\n/** The error card: what failed, and a way out that never needs a page reload. */\nexport function OverlayErrorFallback({ label, error, retry, close, extras }: OverlayErrorFallbackProps) {\n const e = normalizeOverlayError(error);\n return (\n <div className=\"pointer-events-none fixed inset-0 z-[2147483001] flex items-center justify-center p-4\">\n <div\n role=\"alertdialog\"\n aria-label={`${label} failed to load`}\n className=\"pointer-events-auto flex max-h-[85dvh] w-full max-w-lg flex-col overflow-hidden rounded-xl border border-destructive bg-card shadow-[var(--elevation-3)]\"\n >\n <div className=\"border-b border-border px-5 py-4\">\n <h2 className=\"text-sm font-semibold text-foreground\">{label} failed to load</h2>\n <p className=\"mt-1 text-xs text-muted-foreground\">\n {e.isChunkLoadError ? \"Part of it did not finish loading.\" : \"It hit an error while rendering.\"}\n </p>\n </div>\n <div className=\"min-h-0 flex-1 overflow-auto px-5 py-4\">\n <div className=\"rounded-lg bg-muted px-3 py-2 font-mono text-xs text-foreground\">\n <span className=\"text-destructive\">{e.name}</span>: {e.message}\n </div>\n </div>\n <div className=\"flex items-center justify-between gap-2 border-t border-border px-5 py-3\">\n <div>{extras}</div>\n <div className=\"flex items-center gap-2\">\n <Button variant=\"ghost\" size=\"sm\" onClick={close}>\n Close\n </Button>\n <Button variant=\"primary\" size=\"sm\" onClick={retry}>\n Try again\n </Button>\n <Button\n variant=\"outline\"\n size=\"sm\"\n onClick={() => {\n if (typeof window !== \"undefined\") window.location.reload();\n }}\n >\n Reload page\n </Button>\n </div>\n </div>\n </div>\n </div>\n );\n}\n","// Typed hooks over the package's own store context. Every package component reads the overlays\n// store through these, never react-redux's default context, so a host's own <Provider> and the\n// overlays store never collide.\n\nimport { useContext } from \"react\";\nimport {\n createDispatchHook,\n createSelectorHook,\n createStoreHook,\n type UseDispatch,\n type UseSelector,\n type UseStore,\n} from \"react-redux\";\nimport type { Dispatch, Store, UnknownAction } from \"@reduxjs/toolkit\";\nimport type { SummonRootState } from \"@ai-matrx/summon\";\nimport { DEFAULT_PORTS, type SummonPorts } from \"@ai-matrx/summon\";\nimport { SummonConfigContext, SummonPortsContext, SummonStoreContext, type SummonReactConfig } from \"./context\";\n\n/** Dispatch as the React section uses it: plain actions (thunks are the host's business). */\nexport type SummonReactDispatch = Dispatch<UnknownAction>;\n\n/** The store as the React section sees it: the overlays slices at their root keys (a host store has more). */\nexport type SummonReactStore = Store<SummonRootState>;\n\n/** Select from the overlays store. */\nexport const useSummonSelector: UseSelector<SummonRootState> = createSelectorHook(SummonStoreContext).withTypes<SummonRootState>();\n\n/** The overlays store's dispatch. */\nexport const useSummonDispatch: UseDispatch<SummonReactDispatch> = createDispatchHook(SummonStoreContext).withTypes<SummonReactDispatch>();\n\n/** The overlays store itself (for `getState()` inside callbacks). */\nexport const useSummonStore: UseStore<SummonReactStore> = createStoreHook(SummonStoreContext).withTypes<SummonReactStore>();\n\nconst MISSING_PROVIDER =\n \"[summon] No <SummonProvider> above this component. Wrap the app (or the part that opens overlays) in <SummonProvider>.\";\n\n/** The resolved ports of the nearest provider. */\nexport function useSummonPorts(): SummonPorts {\n const ports = useContext(SummonPortsContext);\n if (!ports) throw new Error(MISSING_PROVIDER);\n return ports;\n}\n\n/**\n * The provider's ports, or the working defaults when no SummonProvider is above — for\n * components that are usable page-local without the system (dialogs, sheets).\n */\nexport function useOptionalSummonPorts(): SummonPorts {\n return useContext(SummonPortsContext) ?? DEFAULT_PORTS;\n}\n\n/**\n * The nearest provider's store, or `null` when no SummonProvider is above — for packages that\n * mount their own provider only when the host has none (chat's windows on a bare host).\n */\nexport function useOptionalSummonStore(): SummonReactStore | null {\n const context = useContext(SummonStoreContext);\n return context ? (context.store as unknown as SummonReactStore) : null;\n}\n\nexport function useSummonConfig(): SummonReactConfig {\n const config = useContext(SummonConfigContext);\n if (!config) throw new Error(MISSING_PROVIDER);\n return config;\n}\n","// The provider's LRU of closed-but-alive instances (`keepAlive: \"hidden\"`, C38 R3). Each slot\n// retains its own hidden instances; this registry only keeps the global order and tells the\n// owning slot when one falls off the end, so at most `limit` hidden components stay mounted.\n\nexport class KeepAliveRegistry {\n private readonly order: string[] = [];\n private readonly evictors = new Map<string, () => void>();\n\n private limit: number;\n\n constructor(limit: number) {\n this.limit = limit;\n }\n\n setLimit(limit: number): void {\n this.limit = Math.max(0, Math.floor(limit));\n this.trim();\n }\n\n /** Mark `key` as hidden-alive (most recent). `evict` unmounts it when the cap is exceeded. */\n retain(key: string, evict: () => void): void {\n this.drop(key);\n this.order.push(key);\n this.evictors.set(key, evict);\n this.trim();\n }\n\n /** `key` reopened or its slot went away: no longer counted. */\n release(key: string): void {\n this.drop(key);\n }\n\n size(): number {\n return this.order.length;\n }\n\n private drop(key: string): void {\n const at = this.order.indexOf(key);\n if (at >= 0) this.order.splice(at, 1);\n this.evictors.delete(key);\n }\n\n private trim(): void {\n while (this.order.length > this.limit) {\n const oldest = this.order.shift();\n if (oldest === undefined) return;\n const evict = this.evictors.get(oldest);\n this.evictors.delete(oldest);\n evict?.();\n }\n }\n}\n","// Per-provider cache of each definition's lazily loaded render component. Lives in the provider\n// (React state), never at module level. A definition's render module is fetched the first time\n// one of its instances mounts — never before — and a retry swaps in a FRESH lazy so the import is\n// genuinely attempted again (a React.lazy caches its first rejection forever).\n\nimport { lazy, type ComponentType, type LazyExoticComponent } from \"react\";\n\nexport interface RenderModule<P> {\n readonly default: ComponentType<P>;\n}\n\nexport type RenderLoader<P> = () => Promise<RenderModule<P>>;\n\nexport interface LoaderEntry<P> {\n readonly attempt: number;\n readonly Component: LazyExoticComponent<ComponentType<P>>;\n}\n\nexport interface LoaderCacheOptions {\n readonly timeoutMs: () => number;\n readonly onImportStart?: (key: string, attempt: number) => void;\n}\n\n/** The error a stalled import becomes, so the error boundary always fires. */\nexport function chunkTimeoutError(key: string, timeoutMs: number): Error {\n const error = new Error(\n `Overlay \"${key}\" render module did not load within ${timeoutMs}ms. The import() did not resolve before the recovery timeout.`,\n );\n error.name = \"ChunkLoadError\";\n return error;\n}\n\nfunction raceTimeout<T>(key: string, real: Promise<T>, timeoutMs: number): Promise<T> {\n // A late rejection after the timeout won must not surface as unhandled.\n real.catch(() => undefined);\n let timer: ReturnType<typeof setTimeout> | undefined;\n const timeout = new Promise<never>((_, reject) => {\n timer = setTimeout(() => reject(chunkTimeoutError(key, timeoutMs)), timeoutMs);\n });\n return Promise.race([real, timeout]).finally(() => {\n if (timer !== undefined) clearTimeout(timer);\n });\n}\n\nexport class LoaderCache {\n private readonly entries = new Map<string, LoaderEntry<unknown>>();\n\n private readonly options: LoaderCacheOptions;\n\n constructor(options: LoaderCacheOptions) {\n this.options = options;\n }\n\n private create<P>(key: string, loader: RenderLoader<P>, attempt: number): LoaderEntry<P> {\n const Component = lazy(() => {\n this.options.onImportStart?.(key, attempt);\n return raceTimeout(key, loader(), this.options.timeoutMs());\n });\n return { attempt, Component };\n }\n\n /** The current lazy component for `key`, created on first request. */\n get<P>(key: string, loader: RenderLoader<P>): LoaderEntry<P> {\n const existing = this.entries.get(key);\n // Sound by construction: an entry under `key` is only ever created from that key's loader.\n if (existing) return existing as LoaderEntry<P>;\n const created = this.create(key, loader, 0);\n this.entries.set(key, created as LoaderEntry<unknown>);\n return created;\n }\n\n /** Replace `key`'s lazy with a fresh one so the next render re-imports. */\n retry<P>(key: string, loader: RenderLoader<P>, failedAttempt: number): void {\n const existing = this.entries.get(key);\n // Another instance already retried past the failed attempt: share its fresh lazy.\n if (existing && existing.attempt > failedAttempt) return;\n const next = this.create(key, loader, failedAttempt + 1);\n this.entries.set(key, next as LoaderEntry<unknown>);\n }\n}\n","// `defineOverlay` — the declare-once API (C38 R2). One light definition per overlay carries its\n// metadata and a lazy `render` import; the definition generates the opener hook, the declarative\n// Controller, the open/close hooks and a typed event emitter. The host renders definitions; the\n// render module is the old controller block, moved verbatim, and is fetched only when opened.\n\nimport { useCallback, useEffect, useMemo, useRef, useState, type ComponentType } from \"react\";\nimport {\n DEFAULT_INSTANCE_ID,\n instanceKey as toInstanceKey,\n type InstanceKey,\n type OverlayDefinitionMeta,\n type OverlayRawData,\n type AnyOverlayMeta,\n} from \"@ai-matrx/summon\";\nimport { selectIsOverlayOpen } from \"@ai-matrx/summon\";\nimport { dispatchClose, dispatchOpen, newInstanceId } from \"./dispatchers\";\nimport { emitOverlayEvent, openOverlayEventChannel, type OverlayEventMap, type OverlayHandlers } from \"./events\";\nimport { createInstanceBody, type InstanceBodyProps, type OverlayRenderProps } from \"./instanceBody\";\nimport { useOptionalOverlayInstance } from \"./instance\";\nimport type { RenderModule } from \"./loaderCache\";\nimport { useSummonDispatch, useSummonSelector, type SummonReactDispatch } from \"./storeHooks\";\n\n/** The open-data key that carries an overlay's event channel id (the old callback-group key). */\nexport const CALLBACK_GROUP_KEY = \"callbackGroupId\";\n\nexport interface OverlayHandle {\n readonly overlayId: string;\n readonly instanceId: string;\n close(): void;\n}\n\nexport interface OverlayOpenOptions<Data, Events extends OverlayEventMap> {\n readonly data?: Data;\n /** Single-instance overlays ignore it unless given; multi-instance generate one when omitted. */\n readonly instanceId?: string;\n /** Plain functions; they reach the caller through an event channel owned by the instance. */\n readonly handlers?: OverlayHandlers<Events>;\n}\n\nexport type OverlayOpener<Data, Events extends OverlayEventMap> = (options?: OverlayOpenOptions<Data, Events>) => OverlayHandle;\n\nexport type OverlayControllerProps<Data, Events extends OverlayEventMap> = Data & {\n readonly instanceId?: string;\n readonly handlers?: OverlayHandlers<Events>;\n};\n\nexport type OverlayEmitter<Events extends OverlayEventMap> = <K extends keyof Events & string>(event: K, payload: Events[K]) => void;\n\n/** What a definition file passes to `defineOverlay<Data>()(…)`. */\nexport interface OverlaySpec<Id extends string, Data, Parsed> extends OverlayDefinitionMeta<Id, Data> {\n /** The lazily loaded render module. Its default export receives `OverlayRenderProps<Parsed>`. */\n readonly render: () => Promise<RenderModule<OverlayRenderProps<NoInfer<Parsed>>>>;\n /** Narrow raw open data once. `null` = refuse: the instance is closed with a warning. */\n readonly parse?: (raw: OverlayRawData) => Parsed | null;\n}\n\n/** The type-erased half the host renders; no data types cross this line. */\nexport interface HostableOverlay {\n readonly id: string;\n readonly label: string;\n readonly instance: \"single\" | \"multi\";\n readonly keepAlive: \"none\" | \"hidden\" | \"restore\";\n /** The metadata the core registry stores (links, window options, defaults…). */\n readonly meta: AnyOverlayMeta;\n readonly Body: ComponentType<InstanceBodyProps>;\n}\n\nexport interface OverlayDefinition<Id extends string, Data, Parsed, Events extends OverlayEventMap>\n extends Omit<OverlayDefinitionMeta<Id, Data>, \"id\" | \"instance\" | \"keepAlive\">,\n HostableOverlay {\n readonly id: Id;\n readonly render: () => Promise<RenderModule<OverlayRenderProps<Parsed>>>;\n /** Imperative opener: `const open = def.useSummon(); open({ data })` → handle. */\n useSummon(): OverlayOpener<Data, Events>;\n /** Declarative form: opens on mount, closes on unmount, re-opens when its data changes. */\n readonly Controller: (props: OverlayControllerProps<Data, Events>) => null;\n useIsOpen(instanceId?: string): boolean;\n /** `const close = def.useClose(); close(instanceId?)`. */\n useClose(): (instanceId?: string) => void;\n /** Inside the render tree: emit a declared event to the opener's handlers. */\n useEmit(): OverlayEmitter<Events>;\n}\n\nfunction openWith<Data, Events extends OverlayEventMap>(\n dispatch: SummonReactDispatch,\n id: string,\n multi: boolean,\n options: OverlayOpenOptions<Data, Events> | undefined,\n): OverlayHandle {\n const instanceId = options?.instanceId ?? (multi ? newInstanceId(id) : DEFAULT_INSTANCE_ID);\n const key = toInstanceKey(id, instanceId);\n const data: Record<string, unknown> = {};\n const given: unknown = options?.data;\n if (typeof given === \"object\" && given !== null) Object.assign(data, given);\n const handlers = options?.handlers;\n if (handlers) data[CALLBACK_GROUP_KEY] = openOverlayEventChannel<Events>(key, () => handlers);\n dispatchOpen(dispatch, id, instanceId, data);\n return { overlayId: id, instanceId, close: () => dispatchClose(dispatch, id, instanceId) };\n}\n\n/** Stable identity for the serialisable part of Controller props (functions never reopen). */\nfunction dataSignature(data: Readonly<Record<string, unknown>>): string {\n try {\n return JSON.stringify(data, (_key, value: unknown) => (typeof value === \"function\" ? undefined : value));\n } catch {\n return String(Date.now());\n }\n}\n\n/**\n * Declare an overlay once. Curried so `Data` (and `Events`) are named while the id and the\n * parsed-data type are inferred:\n *\n * export const notesWindow = defineOverlay<NotesWindowData>()({\n * id: \"notesWindow\", label: \"Notes\", render: () => import(\"./notesWindow.render\"),\n * });\n */\nexport function defineOverlay<Data extends object = Record<string, never>, Events extends OverlayEventMap = Record<never, never>>() {\n return function define<const Id extends string, Parsed = OverlayRawData>(\n spec: OverlaySpec<Id, Data, Parsed>,\n ): OverlayDefinition<Id, Data, Parsed, Events> {\n const id = spec.id;\n const multi = spec.instance === \"multi\";\n // Without `parse`, Parsed is OverlayRawData (NoInfer keeps the render module from widening it).\n const parse = spec.parse ?? ((raw: OverlayRawData) => raw as Parsed);\n const Body = createInstanceBody<Parsed>(id, spec.label, spec.render, parse, spec.parse !== undefined);\n // The registry stores every definition's metadata under one erased type (AnyOverlayMeta).\n const meta: AnyOverlayMeta = spec;\n\n function useSummon(): OverlayOpener<Data, Events> {\n const dispatch = useSummonDispatch();\n return useCallback((options) => openWith(dispatch, id, multi, options), [dispatch]);\n }\n\n function useIsOpen(instanceId: string = DEFAULT_INSTANCE_ID): boolean {\n return useSummonSelector((state) => selectIsOverlayOpen(state, id, instanceId));\n }\n\n function useClose(): (instanceId?: string) => void {\n const dispatch = useSummonDispatch();\n return useCallback((instanceId?: string) => dispatchClose(dispatch, id, instanceId ?? DEFAULT_INSTANCE_ID), [dispatch]);\n }\n\n function useEmit(): OverlayEmitter<Events> {\n const instance = useOptionalOverlayInstance();\n const channelId = instance?.overlayId === id ? instance.rawData?.[CALLBACK_GROUP_KEY] : undefined;\n return useCallback<OverlayEmitter<Events>>(\n (event, payload) => {\n if (typeof channelId === \"string\") emitOverlayEvent(channelId, event, payload);\n },\n [channelId],\n );\n }\n\n function Controller(props: OverlayControllerProps<Data, Events>): null {\n const dispatch = useSummonDispatch();\n const [ownInstanceId] = useState(() => (multi ? newInstanceId(id) : DEFAULT_INSTANCE_ID));\n const instanceId = props.instanceId ?? ownInstanceId;\n // Latest handlers, read at emit time: a new function identity never reopens the overlay.\n const handlersRef = useRef(props.handlers);\n handlersRef.current = props.handlers;\n const hasHandlers = props.handlers !== undefined;\n\n const data = useMemo(() => {\n const out: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(props)) {\n if (key !== \"instanceId\" && key !== \"handlers\") out[key] = value;\n }\n return out;\n }, [props]);\n const signature = dataSignature(data);\n const dataRef = useRef(data);\n dataRef.current = data;\n\n useEffect(() => {\n const key: InstanceKey = toInstanceKey(id, instanceId);\n const open: Record<string, unknown> = { ...dataRef.current };\n if (hasHandlers) open[CALLBACK_GROUP_KEY] = openOverlayEventChannel<Events>(key, () => handlersRef.current);\n dispatchOpen(dispatch, id, instanceId, open);\n return () => dispatchClose(dispatch, id, instanceId);\n }, [dispatch, instanceId, signature, hasHandlers]);\n\n return null;\n }\n Controller.displayName = `${id}Controller`;\n\n return {\n ...spec,\n id,\n label: spec.label,\n instance: multi ? \"multi\" : \"single\",\n keepAlive: spec.keepAlive ?? \"none\",\n meta,\n Body,\n useSummon,\n Controller,\n useIsOpen,\n useClose,\n useEmit,\n };\n };\n}\n","// The one place the React section turns an untyped (string) overlay id into the core's typed\n// action creators. Inside the package `OverlayId` is `string`; a host that augments the registry\n// narrows it to its ids, and these keep compiling there because definitions carry their own id.\n\nimport { closeOverlay, openOverlay } from \"@ai-matrx/summon\";\nimport { DEFAULT_INSTANCE_ID, type OverlayDataOf, type OverlayId } from \"@ai-matrx/summon\";\nimport type { SummonReactDispatch } from \"./storeHooks\";\n\nexport function newInstanceId(overlayId: string): string {\n return `${overlayId}-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;\n}\n\nexport function dispatchOpen(dispatch: SummonReactDispatch, overlayId: string, instanceId: string, data: unknown): void {\n dispatch(\n openOverlay({\n overlayId: overlayId as OverlayId,\n instanceId,\n data: (data ?? null) as OverlayDataOf<OverlayId> | null,\n }),\n );\n}\n\nexport function dispatchClose(dispatch: SummonReactDispatch, overlayId: string, instanceId: string = DEFAULT_INSTANCE_ID): void {\n dispatch(closeOverlay({ overlayId: overlayId as OverlayId, instanceId }));\n}\n","// Callback-aware opening: callers pass plain handler functions; the opener puts them behind a\n// handles event channel owned by the instance (`overlayId:instanceId`) and only the channel's id\n// rides open data. Closing the instance disposes the channel (the core close middleware calls\n// `disposeOwner`), so no opener disposes by hand.\n\nimport { createEventChannel, getEventChannel } from \"@ai-matrx/summon/handles\";\nimport type { InstanceKey } from \"@ai-matrx/summon\";\n\n/** Event name → payload, declared once per overlay: `defineOverlay<Data, { uploaded: Result }>()`. */\nexport type OverlayEventMap = Record<string, unknown>;\n\nexport type OverlayHandlers<Events extends OverlayEventMap> = {\n readonly [K in keyof Events]?: (payload: Events[K]) => void;\n};\n\n/** The one message shape on an overlay's channel. */\nexport interface OverlayEventMessage {\n readonly type: string;\n readonly payload: unknown;\n}\n\n/** Open a channel owned by `owner` that forwards each event to the handler `getHandlers` returns now. */\nexport function openOverlayEventChannel<Events extends OverlayEventMap>(\n owner: InstanceKey,\n getHandlers: () => OverlayHandlers<Events> | undefined,\n): string {\n const channel = createEventChannel<OverlayEventMessage>({ owner });\n channel.subscribe((message) => {\n const handlers = getHandlers() as Readonly<Record<string, ((payload: unknown) => void) | undefined>> | undefined;\n handlers?.[message.type]?.(message.payload);\n });\n return channel.id;\n}\n\n/** Deliver one event on a channel; a disposed or unknown channel is a silent no-op by contract. */\nexport function emitOverlayEvent(channelId: string, type: string, payload: unknown): void {\n getEventChannel<OverlayEventMessage>(channelId)?.emit({ type, payload });\n}\n","// One open instance, rendered: instance context → host wrapper → error boundary → Suspense →\n// the lazily loaded render module with its typed props. Created per definition (inside\n// `defineOverlay`) so the parsed-data type stays inside the closure and the host deals only in\n// untyped instances — no casts at the host.\n\nimport { Suspense, memo, useEffect, useMemo, useRef, type ComponentType, type ReactNode } from \"react\";\nimport type { InstanceKey, OverlayRawData } from \"@ai-matrx/summon\";\nimport type { OverlayRenderContext } from \"./context\";\nimport { OverlayErrorBoundary } from \"./OverlayErrorBoundary\";\nimport { OverlayInstanceContext, type OverlayInstanceContextValue } from \"./instance\";\nimport type { RenderLoader } from \"./loaderCache\";\nimport { useSummonConfig, useSummonPorts } from \"./storeHooks\";\n\n/** The props every overlay's render module receives. */\nexport interface OverlayRenderProps<Data = OverlayRawData> {\n readonly overlayId: string;\n readonly instanceId: string;\n /** The open data: raw (narrow it yourself) unless the definition declares `parse`. */\n readonly data: Data;\n readonly isOpen: true;\n readonly close: () => void;\n /** True while kept alive behind a close (`keepAlive: \"hidden\"`). */\n readonly hidden: boolean;\n}\n\n/** What the host hands each instance — no data type, by design. */\nexport interface InstanceBodyProps {\n readonly instanceId: string;\n readonly instanceKey: InstanceKey;\n readonly data: OverlayRawData;\n readonly hidden: boolean;\n readonly close: () => void;\n}\n\ninterface LazyRenderProps<Parsed> {\n readonly overlayId: string;\n readonly instanceId: string;\n readonly data: Parsed;\n readonly hidden: boolean;\n readonly close: () => void;\n readonly render: RenderLoader<OverlayRenderProps<Parsed>>;\n readonly attemptRef: { current: number };\n}\n\nfunction LazyRender<Parsed>({ overlayId, instanceId, data, hidden, close, render, attemptRef }: LazyRenderProps<Parsed>) {\n const { loaders } = useSummonConfig();\n const entry = loaders.get(overlayId, render);\n attemptRef.current = entry.attempt;\n const Render = entry.Component;\n return <Render overlayId={overlayId} instanceId={instanceId} data={data} isOpen close={close} hidden={hidden} />;\n}\n\nexport function createInstanceBody<Parsed>(\n overlayId: string,\n label: string,\n render: RenderLoader<OverlayRenderProps<Parsed>>,\n parse: (raw: OverlayRawData) => Parsed | null,\n /** False when the definition has no `parse`: a null result is then just empty data. */\n refusable: boolean,\n): ComponentType<InstanceBodyProps> {\n function OverlayInstanceBody({ instanceId, instanceKey, data, hidden, close }: InstanceBodyProps) {\n const config = useSummonConfig();\n const ports = useSummonPorts();\n const attemptRef = useRef(0);\n const parsed = useMemo(() => parse(data), [data]);\n const refused = refusable && parsed === null;\n\n useEffect(() => {\n if (!refused) return;\n if (process.env.NODE_ENV !== \"production\") {\n ports.notify.warn(`Overlay \"${overlayId}\" was opened with data its parse() refused; closing it.`, {\n id: `overlays-parse-${instanceKey}`,\n });\n }\n close();\n }, [refused, ports, instanceKey, close]);\n\n const instance = useMemo<OverlayInstanceContextValue>(\n () => ({ overlayId, instanceId, instanceKey, close, hidden, rawData: data }),\n [instanceId, instanceKey, close, hidden, data],\n );\n\n if (refused) return null;\n\n const context: OverlayRenderContext = { overlayId, instanceId, instanceKey, label };\n const body: ReactNode = (\n <OverlayErrorBoundary\n overlayId={overlayId}\n instanceId={instanceId}\n instanceKey={instanceKey}\n label={label}\n errors={ports.errors}\n fallback={config.errorFallback}\n extras={config.errorReportExtras}\n onRetry={() => config.loaders.retry(overlayId, render, attemptRef.current)}\n onClose={close}\n >\n <Suspense fallback={<config.loadingFallback overlayId={overlayId} label={label} />}>\n <LazyRender\n overlayId={overlayId}\n instanceId={instanceId}\n data={parsed as Parsed}\n hidden={hidden}\n close={close}\n render={render}\n attemptRef={attemptRef}\n />\n </Suspense>\n </OverlayErrorBoundary>\n );\n\n return (\n <OverlayInstanceContext.Provider value={instance}>\n {config.renderWrapper ? config.renderWrapper(body, context) : body}\n </OverlayInstanceContext.Provider>\n );\n }\n OverlayInstanceBody.displayName = `Overlay(${overlayId})`;\n // Memoized: props are the instance's own (ids, data reference, hidden, a stable close).\n return memo(OverlayInstanceBody);\n}\n","// A per-instance error boundary. React.lazy + Suspense give a loading state but no error state,\n// so a rejected import (or a render throw) would otherwise unmount the whole host. Outcomes are\n// exactly: the overlay, its loading fallback, or a meaningful error with Close and Try again.\n\nimport { Component, type ComponentType, type ErrorInfo, type ReactNode } from \"react\";\nimport type { ErrorSinkPort } from \"@ai-matrx/summon\";\nimport type { OverlayErrorExtrasContext, OverlayErrorFallbackProps } from \"./context\";\nimport { normalizeOverlayError } from \"./fallbacks\";\n\nexport interface OverlayErrorBoundaryProps {\n readonly overlayId: string;\n readonly instanceId: string;\n readonly instanceKey: string;\n readonly label: string;\n readonly errors: ErrorSinkPort;\n readonly fallback: ComponentType<OverlayErrorFallbackProps>;\n readonly extras: ((context: OverlayErrorExtrasContext) => ReactNode) | null;\n /** Swap in a fresh loader BEFORE the boundary clears, so the remount re-imports. */\n readonly onRetry: () => void;\n readonly onClose: () => void;\n readonly children: ReactNode;\n}\n\ninterface OverlayErrorBoundaryState {\n readonly error: unknown;\n readonly hasError: boolean;\n readonly componentStack: string | null;\n}\n\nconst CLEAR: OverlayErrorBoundaryState = { error: null, hasError: false, componentStack: null };\n\nexport class OverlayErrorBoundary extends Component<OverlayErrorBoundaryProps, OverlayErrorBoundaryState> {\n override state: OverlayErrorBoundaryState = CLEAR;\n\n static getDerivedStateFromError(error: unknown): Partial<OverlayErrorBoundaryState> {\n return { error, hasError: true };\n }\n\n override componentDidCatch(error: unknown, info: ErrorInfo): void {\n const componentStack = info.componentStack ?? null;\n this.setState({ componentStack });\n const e = normalizeOverlayError(error);\n // Loud recovery: a caught overlay error is a real bug or a broken chunk graph.\n this.props.errors.capture(error, {\n boundary: \"OverlayErrorBoundary\",\n overlayId: this.props.overlayId,\n instanceId: this.props.instanceId,\n errorName: e.name,\n isChunkLoadError: e.isChunkLoadError,\n componentStack,\n });\n }\n\n private readonly retry = (): void => {\n this.props.onRetry();\n this.setState(CLEAR);\n };\n\n override render(): ReactNode {\n const { hasError, error, componentStack } = this.state;\n if (!hasError) return this.props.children;\n const { overlayId, instanceId, instanceKey, label, extras, onClose } = this.props;\n const Fallback = this.props.fallback;\n const renderedExtras = extras ? extras({ overlayId, instanceId, instanceKey, label, error, componentStack }) : null;\n return (\n <Fallback\n overlayId={overlayId}\n instanceId={instanceId}\n label={label}\n error={error}\n componentStack={componentStack}\n retry={this.retry}\n close={onClose}\n extras={renderedExtras}\n />\n );\n }\n}\n","// The context every rendered overlay instance provides to its subtree, and the hooks that read\n// it: who am I, close me, am I hidden, and `useOverlayState` — saved component state scoped to\n// the open instance that survives `keepAlive: \"restore\"` (and persistence, when on).\n\nimport { createContext, useCallback, useContext } from \"react\";\nimport type { InstanceKey, OverlayRawData } from \"@ai-matrx/summon\";\nimport { selectOverlayStateValue, setOverlayStateValue } from \"@ai-matrx/summon\";\nimport { useSummonDispatch, useSummonSelector, useSummonStore } from \"./storeHooks\";\n\nexport interface OverlayInstanceContextValue {\n readonly overlayId: string;\n readonly instanceId: string;\n readonly instanceKey: InstanceKey;\n readonly close: () => void;\n readonly hidden: boolean;\n /** The open data as it arrived (pre-parse); event emitters read their channel id from it. */\n readonly rawData: OverlayRawData;\n}\n\nexport const OverlayInstanceContext = createContext<OverlayInstanceContextValue | null>(null);\nOverlayInstanceContext.displayName = \"OverlayInstanceContext\";\n\n/** The open instance this component renders inside. Throws outside an overlay. */\nexport function useOverlayInstance(): OverlayInstanceContextValue {\n const value = useContext(OverlayInstanceContext);\n if (!value) {\n throw new Error(\"[summon] useOverlayInstance() was called outside a rendered overlay.\");\n }\n return value;\n}\n\n/** Same as `useOverlayInstance`, but `null` outside an overlay. */\nexport function useOptionalOverlayInstance(): OverlayInstanceContextValue | null {\n return useContext(OverlayInstanceContext);\n}\n\nexport type OverlayStateSetter<T> = (next: T | ((previous: T) => T)) => void;\n\n/**\n * Saved state for the current overlay instance — `useState`, but kept in the overlays store under\n * `overlayId:instanceId` so it survives `keepAlive: \"restore\"` close/reopen and is persisted when\n * persistence is on. Any descendant of the overlay may call it; the same `name` reads the same\n * value. Values must be serialisable.\n */\nexport function useOverlayState<T>(name: string, initial: T): [T, OverlayStateSetter<T>] {\n const { instanceKey } = useOverlayInstance();\n const dispatch = useSummonDispatch();\n const store = useSummonStore();\n const stored = useSummonSelector((state) => selectOverlayStateValue(state, instanceKey, name));\n const value = stored === undefined ? initial : (stored as T);\n const setValue = useCallback<OverlayStateSetter<T>>(\n (next) => {\n const current = selectOverlayStateValue(store.getState(), instanceKey, name);\n const previous = current === undefined ? initial : (current as T);\n const resolved = typeof next === \"function\" ? (next as (previous: T) => T)(previous) : next;\n dispatch(setOverlayStateValue({ key: instanceKey, name, value: resolved }));\n },\n // `initial` is the first-render default, like useState's; its identity never re-binds.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [dispatch, store, instanceKey, name],\n );\n return [value, setValue];\n}\n","// `<SummonHost definitions>` — registers each definition's metadata and renders every definition\n// through its OWN subscriber (`DefinitionSlot`), so opening overlay A never re-renders B (the old\n// controller held ~440 subscriptions in one component). A closed overlay puts nothing in the tree\n// and fetches no chunk. `keepAlive: \"hidden\"` keeps closed instances mounted inside\n// `<Activity mode=\"hidden\">`, LRU-capped per provider.\n\nimport { Activity, memo, useCallback, useEffect, useRef, useState, type ReactNode } from \"react\";\nimport { releaseOverlayInstance } from \"@ai-matrx/summon\";\nimport { registerOverlayMeta } from \"@ai-matrx/summon\";\nimport { closeOverlaysBoundToPage, overlayIdsBoundToPage, selectOpenInstances, type OpenInstanceView } from \"@ai-matrx/summon\";\nimport { instanceKey as toInstanceKey, type OverlayRawData } from \"@ai-matrx/summon\";\nimport type { HostableOverlay } from \"./defineOverlay\";\nimport { dispatchClose } from \"./dispatchers\";\nimport { useSummonConfig, useSummonDispatch, useSummonPorts, useSummonSelector } from \"./storeHooks\";\n\nexport interface SummonHostProps {\n /** Every overlay this host can render — the app's definition list, passed once. */\n readonly definitions: readonly HostableOverlay[];\n}\n\nfunction asRawData(data: unknown): OverlayRawData {\n return typeof data === \"object\" && data !== null && !Array.isArray(data) ? (data as OverlayRawData) : null;\n}\n\n/** Equal when the same instances are open with the same data references. */\nfunction sameInstances(a: readonly OpenInstanceView[], b: readonly OpenInstanceView[]): boolean {\n if (a === b) return true;\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i += 1) {\n const x = a[i];\n const y = b[i];\n if (!x || !y || x.instanceId !== y.instanceId || x.data !== y.data) return false;\n }\n return true;\n}\n\nconst NO_RETAINED: ReadonlyMap<string, OverlayRawData> = new Map();\n\n/** Close-on-navigation: on a pathname change, close every overlay bound to the page. */\nexport function useCloseOnNavigation(): void {\n const ports = useSummonPorts();\n const dispatch = useSummonDispatch();\n useEffect(() => {\n const router = ports.router;\n let previous = router.pathname();\n return router.subscribe(() => {\n const next = router.pathname();\n if (next === previous) return;\n previous = next;\n const overlayIds = overlayIdsBoundToPage();\n if (overlayIds.length > 0) dispatch(closeOverlaysBoundToPage({ overlayIds }));\n });\n }, [ports, dispatch]);\n}\n\ninterface InstanceSlotProps {\n readonly definition: HostableOverlay;\n readonly instanceId: string;\n readonly data: OverlayRawData;\n readonly hidden: boolean;\n}\n\n// Memoized: a slot re-renders only when its own instance changes, never because the host did.\nconst InstanceSlot = memo(function InstanceSlot({ definition, instanceId, data, hidden }: InstanceSlotProps) {\n const dispatch = useSummonDispatch();\n const close = useCallback(() => dispatchClose(dispatch, definition.id, instanceId), [dispatch, definition.id, instanceId]);\n const Body = definition.Body;\n return <Body instanceId={instanceId} instanceKey={toInstanceKey(definition.id, instanceId)} data={data} hidden={hidden} close={close} />;\n});\n\n// Memoized on the definition: the slot re-renders from its own store subscription (one overlay's\n// open instances) and nothing else. Unmemoized, every re-render of the host's parent re-rendered\n// every open overlay's render module (the ~425-renders-in-2-s storm the runtime sweep measured).\nconst DefinitionSlot = memo(function DefinitionSlot({ definition }: { readonly definition: HostableOverlay }) {\n const { keepAlive } = useSummonConfig();\n const dispatch = useSummonDispatch();\n const open = useSummonSelector((state) => selectOpenInstances(state, definition.id), sameInstances);\n const keepHidden = definition.keepAlive === \"hidden\";\n\n // Closed-but-alive instances, derived during render (no unmount/remount flash on close).\n const [retained, setRetained] = useState(NO_RETAINED);\n const [previousOpen, setPreviousOpen] = useState(open);\n if (previousOpen !== open) {\n setPreviousOpen(open);\n if (keepHidden) {\n const openIds = new Set(open.map((instance) => instance.instanceId));\n const next = new Map(retained);\n for (const instance of previousOpen) {\n if (!openIds.has(instance.instanceId)) next.set(instance.instanceId, asRawData(instance.data));\n }\n for (const id of openIds) next.delete(id);\n setRetained(next);\n }\n }\n\n // Mirror the retained set into the provider LRU; eviction unmounts here.\n const registered = useRef(new Set<string>());\n useEffect(() => {\n const seen = registered.current;\n for (const instanceId of retained.keys()) {\n if (seen.has(instanceId)) continue;\n seen.add(instanceId);\n const key = toInstanceKey(definition.id, instanceId);\n keepAlive.retain(key, () => {\n seen.delete(instanceId);\n // Evicted: its handles and saved state go now, as a plain close would have done.\n releaseOverlayInstance(dispatch, key);\n setRetained((current) => {\n if (!current.has(instanceId)) return current;\n const next = new Map(current);\n next.delete(instanceId);\n return next;\n });\n });\n }\n for (const instanceId of [...seen]) {\n if (retained.has(instanceId)) continue;\n seen.delete(instanceId);\n keepAlive.release(toInstanceKey(definition.id, instanceId));\n }\n }, [retained, keepAlive, definition.id, dispatch]);\n useEffect(() => {\n const seen = registered.current;\n return () => {\n for (const instanceId of seen) {\n const key = toInstanceKey(definition.id, instanceId);\n keepAlive.release(key);\n releaseOverlayInstance(dispatch, key);\n }\n seen.clear();\n };\n }, [keepAlive, definition.id, dispatch]);\n\n if (open.length === 0 && retained.size === 0) return null;\n\n const nodes: ReactNode[] = [];\n for (const instance of open) {\n const node = (\n <InstanceSlot key={instance.instanceId} definition={definition} instanceId={instance.instanceId} data={asRawData(instance.data)} hidden={false} />\n );\n nodes.push(\n keepHidden ? (\n <Activity key={instance.instanceId} mode=\"visible\">\n {node}\n </Activity>\n ) : (\n node\n ),\n );\n }\n if (keepHidden) {\n for (const [instanceId, data] of retained) {\n nodes.push(\n <Activity key={instanceId} mode=\"hidden\">\n <InstanceSlot key={instanceId} definition={definition} instanceId={instanceId} data={data} hidden />\n </Activity>,\n );\n }\n }\n return <>{nodes}</>;\n});\n\nexport function SummonHost({ definitions }: SummonHostProps) {\n // Register before any slot renders: links, the close middleware and defaults read the registry.\n const registeredFor = useRef<readonly HostableOverlay[] | null>(null);\n if (registeredFor.current !== definitions) {\n registerOverlayMeta(definitions.map((definition) => definition.meta));\n registeredFor.current = definitions;\n }\n useCloseOnNavigation();\n return (\n <>\n {definitions.map((definition) => (\n <DefinitionSlot key={definition.id} definition={definition} />\n ))}\n </>\n );\n}\n","// Id-addressed hooks — the escape hatch when a caller has an overlay id rather than its\n// definition. Typed through the host's `OverlayRegistry` augmentation.\n\nimport { useCallback } from \"react\";\nimport { getOverlayMeta } from \"@ai-matrx/summon\";\nimport { selectIsOverlayOpen } from \"@ai-matrx/summon\";\nimport { DEFAULT_INSTANCE_ID, type OverlayDataOf, type OverlayId } from \"@ai-matrx/summon\";\nimport type { OverlayHandle } from \"./defineOverlay\";\nimport { dispatchClose, dispatchOpen, newInstanceId } from \"./dispatchers\";\nimport { useSummonDispatch, useSummonSelector } from \"./storeHooks\";\n\n/** True while the instance is open. */\nexport function useIsOverlayOpen(overlayId: OverlayId, instanceId: string = DEFAULT_INSTANCE_ID): boolean {\n return useSummonSelector((state) => selectIsOverlayOpen(state, overlayId, instanceId));\n}\n\nexport interface OpenOverlayOptions<Id extends OverlayId> {\n readonly data?: OverlayDataOf<Id>;\n readonly instanceId?: string;\n}\n\n/**\n * Open an overlay by id. A multi-instance overlay (per its registered definition) gets a fresh\n * instance id when none is given; a single-instance one opens \"default\".\n */\nexport function useOpenOverlay<Id extends OverlayId>(overlayId: Id): (options?: OpenOverlayOptions<Id>) => OverlayHandle {\n const dispatch = useSummonDispatch();\n return useCallback(\n (options?: OpenOverlayOptions<Id>) => {\n const multi = getOverlayMeta(overlayId)?.instance === \"multi\";\n const instanceId = options?.instanceId ?? (multi ? newInstanceId(overlayId) : DEFAULT_INSTANCE_ID);\n dispatchOpen(dispatch, overlayId, instanceId, options?.data ?? null);\n return { overlayId, instanceId, close: () => dispatchClose(dispatch, overlayId, instanceId) };\n },\n [dispatch, overlayId],\n );\n}\n\n/** A stable close function for one instance (pass straight to an `onClose` prop). */\nexport function useCloseOverlay(overlayId: OverlayId, instanceId: string = DEFAULT_INSTANCE_ID): () => void {\n const dispatch = useSummonDispatch();\n return useCallback(() => dispatchClose(dispatch, overlayId, instanceId), [dispatch, overlayId, instanceId]);\n}\n"],"mappings":";;;AAKA,SAAS,aAAAA,YAAW,SAAS,QAAQ,gBAAoD;AACzF,SAAS,gBAAgB;AAEzB,SAAS,oBAAsC;AAC/C,SAAS,yBAAyB;;;ACLlC,SAAS,qBAAyD;AAM3D,IAAM,qBAAqB,cAA6C,IA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AC;AACvF;AAWO,SAAS,eAAqC,WAAoE;AACvH,QAAM,WAAW,kBAAkB;AACnC,SAAOC;AAAA,IACL,CAAC,YAAqC;AACpC,YAAM,QAAQ,eAAe,SAAS,GAAG,aAAa;AACtD,YAAM,aAAa,SAAS,eAAe,QAAQ,cAAc,SAAS,IAAIF;AAC9E,mBAAa,UAAU,WAAW,YAAY,SAAS,QAAQ,IAAI;AACnE,aAAO,EAAE,WAAW,YAAY,OAAO,MAAM,cAAc,UAAU,WAAW,UAAU,EAAE;AAAA,IAC9F;AAAA,IACA,CAAC,UAAU,SAAS;AAAA,EACtB;AACF;AAGO,SAAS,gBAAgB,WAAsB,aAAqBA,sBAAiC;AAC1G,QAAM,WAAW,kBAAkB;AACnC,SAAOE,aAAY,MAAM,cAAc,UAAU,WAAW,UAAU,GAAG,CAAC,UAAU,WAAW,UAAU,CAAC;AAC5G;","names":["useEffect","Component","jsx","useEffect","useCallback","useEffect","useMemo","useRef","useState","DEFAULT_INSTANCE_ID","useEffect","useMemo","useRef","jsx","createContext","useContext","createContext","useContext","jsx","useRef","useMemo","useEffect","DEFAULT_INSTANCE_ID","useCallback","useState","useRef","useMemo","useEffect","memo","useCallback","useEffect","useRef","useState","toInstanceKey","jsx","useEffect","memo","InstanceSlot","useCallback","toInstanceKey","DefinitionSlot","useState","useRef","useCallback","selectIsOverlayOpen","DEFAULT_INSTANCE_ID","DEFAULT_INSTANCE_ID","selectIsOverlayOpen","useCallback"]}
|
package/dist/window.cjs
CHANGED
|
@@ -2371,7 +2371,6 @@ function WindowPanel({
|
|
|
2371
2371
|
onResizeStart,
|
|
2372
2372
|
onFocus,
|
|
2373
2373
|
onRestore,
|
|
2374
|
-
onMaximize,
|
|
2375
2374
|
onMinimize,
|
|
2376
2375
|
onToggleMaximize,
|
|
2377
2376
|
isInteracting
|
|
@@ -3517,7 +3516,7 @@ function GreenTrafficLight({
|
|
|
3517
3516
|
"w-3.5 h-3.5 rounded-full flex items-center justify-center transition-colors shrink-0",
|
|
3518
3517
|
"matrx-window-light-maximize cursor-pointer"
|
|
3519
3518
|
),
|
|
3520
|
-
onClick: (
|
|
3519
|
+
onClick: () => {
|
|
3521
3520
|
if ("ontouchstart" in window || navigator.maxTouchPoints > 0) {
|
|
3522
3521
|
setDropdownOpen((prev) => !prev);
|
|
3523
3522
|
} else {
|