@ai-matrx/summon 0.1.13 → 0.1.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/define.cjs +123 -0
  3. package/dist/define.cjs.map +1 -0
  4. package/dist/define.d.cts +79 -0
  5. package/dist/define.d.ts +79 -0
  6. package/dist/define.js +114 -0
  7. package/dist/define.js.map +1 -0
  8. package/dist/{gate-1c08vnzx.d.cts → gate-BalZq3nu.d.cts} +1 -1
  9. package/dist/{gate-1c08vnzx.d.ts → gate-BalZq3nu.d.ts} +1 -1
  10. package/dist/handles.cjs +3 -1
  11. package/dist/handles.cjs.map +1 -1
  12. package/dist/handles.d.cts +4 -1
  13. package/dist/handles.d.ts +4 -1
  14. package/dist/handles.js +3 -1
  15. package/dist/handles.js.map +1 -1
  16. package/dist/index.cjs +3 -1
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.d.cts +2 -2
  19. package/dist/index.d.ts +2 -2
  20. package/dist/index.js +3 -1
  21. package/dist/index.js.map +1 -1
  22. package/dist/open.cjs +33 -0
  23. package/dist/open.cjs.map +1 -1
  24. package/dist/open.d.cts +45 -2
  25. package/dist/open.d.ts +45 -2
  26. package/dist/open.js +33 -0
  27. package/dist/open.js.map +1 -1
  28. package/dist/react.cjs +8 -8
  29. package/dist/react.cjs.map +1 -1
  30. package/dist/react.d.cts +2 -1
  31. package/dist/react.d.ts +2 -1
  32. package/dist/react.js +1 -1
  33. package/dist/react.js.map +1 -1
  34. package/dist/root.cjs +27 -125
  35. package/dist/root.cjs.map +1 -1
  36. package/dist/root.d.cts +4 -76
  37. package/dist/root.d.ts +4 -76
  38. package/dist/root.js +18 -121
  39. package/dist/root.js.map +1 -1
  40. package/dist/url.cjs +7 -23
  41. package/dist/url.cjs.map +1 -1
  42. package/dist/url.d.cts +3 -37
  43. package/dist/url.d.ts +3 -37
  44. package/dist/url.js +4 -20
  45. package/dist/url.js.map +1 -1
  46. package/package.json +13 -3
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.ts","../src/react/events.ts","../src/react/SummonHost.tsx","../src/react/hostRenders.ts","../src/react/instanceBody.tsx","../src/react/OverlayErrorBoundary.tsx","../src/react/instance.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\nimport { DEFAULT_IMPORT_TIMEOUT_MS, DEFAULT_KEEP_ALIVE_LIMIT, DEFAULT_STALL_WARN_MS } from \"./storeHooks\";\nexport { DEFAULT_IMPORT_TIMEOUT_MS, DEFAULT_KEEP_ALIVE_LIMIT, DEFAULT_STALL_WARN_MS };\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 { KeepAliveRegistry } from \"./keepAlive\";\nimport type { LoaderCache } from \"./loaderCache\";\nimport type { OverlayRenderContext, OverlayErrorExtrasContext } from \"@ai-matrx/summon/root\";\n\n// One identity: the store and ports contexts live in the light root section.\nexport { SummonStoreContext, SummonPortsContext } from \"@ai-matrx/summon/root\";\nexport type { OverlayRenderContext, OverlayErrorExtrasContext };\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 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","// The store hooks live in the light root section (one context identity); the render-layer config\n// hook stays here: the nearest SummonProvider's config, else one built from the root's settings.\nimport { useContext } from \"react\";\nimport { getSummonHostConfig, getSummonHostVersion } from \"@ai-matrx/summon/root\";\nimport { globalSlot } from \"@ai-matrx/kit/global-slot\";\nimport { SummonConfigContext, type SummonReactConfig } from \"./context\";\nimport { OverlayErrorFallback, OverlayLoadingFallback } from \"./fallbacks\";\nimport { KeepAliveRegistry } from \"./keepAlive\";\nimport { LoaderCache } from \"./loaderCache\";\n\nexport {\n useSummonSelector,\n useSummonDispatch,\n useSummonStore,\n useSummonPorts,\n useOptionalSummonPorts,\n useOptionalSummonStore,\n type SummonReactDispatch,\n type SummonReactStore,\n} from \"@ai-matrx/summon/root\";\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\ninterface HostConfigSlot {\n version: number;\n config: SummonReactConfig | null;\n keepAlive: KeepAliveRegistry | null;\n loaders: LoaderCache | null;\n}\n\nconst hostConfigSlot = (): HostConfigSlot =>\n globalSlot<HostConfigSlot>(\"ai-matrx.summon.hostReactConfig\", () => ({ version: -1, config: null, keepAlive: null, loaders: null }));\n\n/** The render config when no SummonProvider is above: the root's settings, one keep-alive and loader cache per page. */\nexport function hostReactConfig(): SummonReactConfig {\n const s = hostConfigSlot();\n const version = getSummonHostVersion();\n if (s.config && s.version === version) return s.config;\n const host = getSummonHostConfig();\n s.keepAlive ??= new KeepAliveRegistry(DEFAULT_KEEP_ALIVE_LIMIT);\n s.loaders ??= new LoaderCache({ timeoutMs: () => DEFAULT_IMPORT_TIMEOUT_MS });\n s.config = {\n loadingFallback: OverlayLoadingFallback,\n errorFallback: OverlayErrorFallback,\n errorReportExtras: host.errorReportExtras ?? null,\n renderWrapper: host.renderWrapper ?? null,\n importTimeoutMs: DEFAULT_IMPORT_TIMEOUT_MS,\n stallWarnMs: DEFAULT_STALL_WARN_MS,\n keepAlive: s.keepAlive,\n loaders: s.loaders,\n };\n s.version = version;\n return s.config;\n}\n\nexport function useSummonConfig(): SummonReactConfig {\n return useContext(SummonConfigContext) ?? hostReactConfig();\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","// @ai-matrx/summon/react — the render layer: provider (own store context), declare-once\n// definitions, the host, the lazy loader with its boundary and fallbacks, and the hooks.\nexport { SummonProvider, DEFAULT_IMPORT_TIMEOUT_MS, DEFAULT_KEEP_ALIVE_LIMIT, DEFAULT_STALL_WARN_MS, type SummonProviderProps } from \"./react/SummonProvider\";\nexport {\n SummonStoreContext,\n type OverlayRenderContext,\n type OverlayLoadingFallbackProps,\n type OverlayErrorFallbackProps,\n type OverlayErrorExtrasContext,\n} from \"./react/context\";\nexport {\n useSummonSelector,\n useSummonDispatch,\n useSummonStore,\n useSummonPorts,\n useOptionalSummonPorts,\n useOptionalSummonStore,\n type SummonReactDispatch,\n type SummonReactStore,\n} from \"./react/storeHooks\";\nexport {\n defineOverlay,\n CALLBACK_GROUP_KEY,\n type OverlayDefinition,\n type OverlaySpec,\n type HostableOverlay,\n type OverlayHandle,\n type OverlayOpener,\n type OverlayOpenOptions,\n type OverlayControllerProps,\n type OverlayEmitter,\n} from \"@ai-matrx/summon/root\";\nexport type { OverlayRenderProps } from \"./react/instanceBody\";\nexport { emitOverlayEvent, type OverlayEventMap, type OverlayHandlers } from \"./react/events\";\nexport type { RenderModule, RenderLoader } from \"./react/loaderCache\";\nexport { SummonHost, useCloseOnNavigation, type SummonHostProps } from \"./react/SummonHost\";\nexport { MISSING_RENDER_ERROR, type ErasedRenderLoader, type OverlayRenderMap } from \"./react/hostRenders\";\nexport { SummonRoot, type SummonRootProps, configureSummonHost, type SummonHostConfig } from \"@ai-matrx/summon/root\";\nexport {\n useOverlayInstance,\n useOptionalOverlayInstance,\n useOverlayState,\n type OverlayInstanceContextValue,\n type OverlayStateSetter,\n} from \"./react/instance\";\nexport { useIsOverlayOpen, useOpenOverlay, useCloseOverlay, type OpenOverlayOptions } from \"./react/hooks\";\n// Also on `./url`; lives here so a render module can publish its link without loading the link section.\nexport { useOverlayLink } from \"@ai-matrx/summon/root\";\nexport { OverlayErrorBoundary, type OverlayErrorBoundaryProps } from \"./react/OverlayErrorBoundary\";\nexport { OverlayErrorFallback, OverlayLoadingFallback, normalizeOverlayError, type NormalizedOverlayError } from \"./react/fallbacks\";\nexport { chunkTimeoutError } from \"./react/loaderCache\";\n","// Overlay events on the render side. Opening (the channel id that rides open data) is light and\n// lives in the root section; here, with the handles registry loaded, an emit first creates any\n// channel still pending and then delivers synchronously. Registered on evaluation so a\n// definition's `useEmit` (light) emits synchronously inside the render tree.\n\nimport { createEventChannel, getEventChannel } from \"@ai-matrx/summon/handles\";\nimport { materializePendingChannels, type OverlayEventMessage } from \"@ai-matrx/summon/open\";\nimport { registerOverlayEmitter } from \"@ai-matrx/summon/root\";\n\nexport type { OverlayEventMap, OverlayHandlers } from \"@ai-matrx/summon/root\";\nexport type { OverlayEventMessage };\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 materializePendingChannels(createEventChannel);\n getEventChannel<OverlayEventMessage>(channelId)?.emit({ type, payload });\n}\n\nregisterOverlayEmitter(emitOverlayEvent);\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 ComponentType, 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 { dispatchClose, type HostableOverlay } from \"@ai-matrx/summon/root\";\nimport { HostRendersContext, type OverlayRenderMap } from \"./hostRenders\";\nimport { createInstanceBody, type InstanceBodyProps, type OverlayRenderProps } from \"./instanceBody\";\nimport type { RenderLoader } from \"./loaderCache\";\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 * id → `() => import(\"./<id>.render\")` for definitions declared without `render`. Large apps\n * use it so opener importers never reach a window subtree; a definition's own `render` wins.\n */\n readonly renders?: OverlayRenderMap;\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\n// A definition is light (it carries no render code); the host builds each one's instance body on\n// first render and keeps it for the definition's lifetime.\nconst bodies = new WeakMap<HostableOverlay, ComponentType<InstanceBodyProps>>();\nfunction bodyOf(definition: HostableOverlay): ComponentType<InstanceBodyProps> {\n let body = bodies.get(definition);\n if (!body) {\n const parse = definition.parse ?? ((raw: OverlayRawData) => raw);\n // The definition's loader returns its own render module; erased here like the host map's entries.\n const render = definition.render as RenderLoader<OverlayRenderProps<unknown>> | undefined;\n body = createInstanceBody<unknown>(definition.id, definition.label, render, parse, definition.parse !== undefined);\n bodies.set(definition, body);\n }\n return body;\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 = bodyOf(definition);\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, renders }: 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 <HostRendersContext.Provider value={renders ?? null}>\n {definitions.map((definition) => (\n <DefinitionSlot key={definition.id} definition={definition} />\n ))}\n </HostRendersContext.Provider>\n );\n}\n","// The host-side render map. A definition may omit `render`; the host then resolves the overlay's\n// render module from `<SummonHost renders={…}>`. This keeps import() edges out of every file\n// that imports a definition only to open it: in a large app, ~450 opener importers each gaining\n// an edge to a window subtree multiplied the build graph (the host-build law). One generated map\n// imported by the host alone keeps every import() behind the host's own lazy boundary.\n\nimport { createContext, type JSXElementConstructor } from \"react\";\nimport type { OverlayRenderProps } from \"./instanceBody\";\nimport type { RenderLoader } from \"./loaderCache\";\n\n/**\n * One overlay's loader with its data type erased. `never` data accepts every render component\n * typed `OverlayRenderProps<Data>`, so a map of differently typed render modules type-checks\n * without `any` (JSXElementConstructor, not ComponentType: `defaultProps` would make a class\n * component's props covariant and refuse the erasure).\n */\nexport type ErasedRenderLoader = () => Promise<{ readonly default: JSXElementConstructor<OverlayRenderProps<never>> }>;\n\n/** id → lazy render module, for definitions declared without `render`. */\nexport type OverlayRenderMap = Readonly<Record<string, ErasedRenderLoader>>;\n\nexport const HostRendersContext = createContext<OverlayRenderMap | null>(null);\n\n/** The name of the error an overlay with no render source raises into its error card. */\nexport const MISSING_RENDER_ERROR = \"OverlayRenderMissingError\";\n\nconst missing = new Map<string, () => Promise<never>>();\n\n/**\n * A loader for an overlay that is open but has no render module anywhere (no `render` on the\n * definition and no entry in the host's `renders`). It rejects, so the instance shows the error\n * card; in development it also logs once. Never a silent blank.\n */\nexport function missingRenderLoader<P>(overlayId: string): RenderLoader<P> {\n let loader = missing.get(overlayId);\n if (!loader) {\n const message = `Overlay \"${overlayId}\" is open but has no render module: its definition has no \\`render\\` and <SummonHost renders> has no \"${overlayId}\" entry.`;\n loader = () => {\n if (process.env.NODE_ENV !== \"production\") console.error(`[summon] ${message}`);\n const error = new Error(message);\n error.name = MISSING_RENDER_ERROR;\n return Promise.reject(error);\n };\n missing.set(overlayId, loader);\n }\n return loader;\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, useContext, 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 { HostRendersContext, missingRenderLoader } from \"./hostRenders\";\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 /** The definition's own loader; when absent the host's `renders` map supplies it. */\n ownRender: RenderLoader<OverlayRenderProps<Parsed>> | undefined,\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 hostRenders = useContext(HostRendersContext);\n const hostRender = ownRender ? undefined : hostRenders?.[overlayId];\n // The host map is erased (it holds every overlay's loader); the entry under this id was\n // generated from this definition's own render file, so narrowing it to Parsed is sound.\n const render: RenderLoader<OverlayRenderProps<Parsed>> =\n ownRender ?? (hostRender as RenderLoader<OverlayRenderProps<Parsed>> | undefined) ?? missingRenderLoader(overlayId);\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 { useCallback } from \"react\";\nimport { selectOverlayStateValue, setOverlayStateValue } from \"@ai-matrx/summon\";\nimport { useOverlayInstance } from \"@ai-matrx/summon/root\";\nimport { useSummonDispatch, useSummonSelector, useSummonStore } from \"./storeHooks\";\n\nexport {\n OverlayInstanceContext,\n useOverlayInstance,\n useOptionalOverlayInstance,\n type OverlayInstanceContextValue,\n} from \"@ai-matrx/summon/root\";\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","// 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 { dispatchClose, dispatchOpen, newInstanceId, type OverlayHandle } from \"@ai-matrx/summon/root\";\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;AAMlE,SAAS,oBAAoB,0BAA0B;AAiChD,IAAM,sBAAsB,cAAwC,IAAI;AAC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C;AAAA,IACL,CAAC,YAAqC;AACpC,YAAM,QAAQ,eAAe,SAAS,GAAG,aAAa;AACtD,YAAM,aAAa,SAAS,eAAe,QAAQ,cAAc,SAAS,IAAI;AAC9E,mBAAa,UAAU,WAAW,YAAY,SAAS,QAAQ,IAAI;AACnE,aAAO,EAAE,WAAW,YAAY,OAAO,MAAMC,eAAc,UAAU,WAAW,UAAU,EAAE;AAAA,IAC9F;AAAA,IACA,CAAC,UAAU,SAAS;AAAA,EACtB;AACF;AAGO,SAAS,gBAAgB,WAAsB,aAAqB,qBAAiC;AAC1G,QAAM,WAAW,kBAAkB;AACnC,SAAOD,aAAY,MAAMC,eAAc,UAAU,WAAW,UAAU,GAAG,CAAC,UAAU,WAAW,UAAU,CAAC;AAC5G;;;APMA,SAAS,sBAAsB;","names":["useEffect","Component","jsx","useEffect","jsx","memo","useCallback","useEffect","useRef","useState","createContext","useContext","useEffect","useMemo","useRef","jsx","useOverlayInstance","jsx","useContext","useRef","useMemo","useEffect","jsx","useEffect","memo","InstanceSlot","useCallback","DefinitionSlot","useState","useRef","useCallback","dispatchClose","useCallback","dispatchClose"]}
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.ts","../src/react/events.ts","../src/react/SummonHost.tsx","../src/react/hostRenders.ts","../src/react/instanceBody.tsx","../src/react/OverlayErrorBoundary.tsx","../src/react/instance.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\nimport { DEFAULT_IMPORT_TIMEOUT_MS, DEFAULT_KEEP_ALIVE_LIMIT, DEFAULT_STALL_WARN_MS } from \"./storeHooks\";\nexport { DEFAULT_IMPORT_TIMEOUT_MS, DEFAULT_KEEP_ALIVE_LIMIT, DEFAULT_STALL_WARN_MS };\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 { KeepAliveRegistry } from \"./keepAlive\";\nimport type { LoaderCache } from \"./loaderCache\";\nimport type { OverlayRenderContext, OverlayErrorExtrasContext } from \"@ai-matrx/summon/root\";\n\n// One identity: the store and ports contexts live in the light root section.\nexport { SummonStoreContext, SummonPortsContext } from \"@ai-matrx/summon/root\";\nexport type { OverlayRenderContext, OverlayErrorExtrasContext };\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 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","// The store hooks live in the light root section (one context identity); the render-layer config\n// hook stays here: the nearest SummonProvider's config, else one built from the root's settings.\nimport { useContext } from \"react\";\nimport { getSummonHostConfig, getSummonHostVersion } from \"@ai-matrx/summon/root\";\nimport { globalSlot } from \"@ai-matrx/kit/global-slot\";\nimport { SummonConfigContext, type SummonReactConfig } from \"./context\";\nimport { OverlayErrorFallback, OverlayLoadingFallback } from \"./fallbacks\";\nimport { KeepAliveRegistry } from \"./keepAlive\";\nimport { LoaderCache } from \"./loaderCache\";\n\nexport {\n useSummonSelector,\n useSummonDispatch,\n useSummonStore,\n useSummonPorts,\n useOptionalSummonPorts,\n useOptionalSummonStore,\n type SummonReactDispatch,\n type SummonReactStore,\n} from \"@ai-matrx/summon/root\";\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\ninterface HostConfigSlot {\n version: number;\n config: SummonReactConfig | null;\n keepAlive: KeepAliveRegistry | null;\n loaders: LoaderCache | null;\n}\n\nconst hostConfigSlot = (): HostConfigSlot =>\n globalSlot<HostConfigSlot>(\"ai-matrx.summon.hostReactConfig\", () => ({ version: -1, config: null, keepAlive: null, loaders: null }));\n\n/** The render config when no SummonProvider is above: the root's settings, one keep-alive and loader cache per page. */\nexport function hostReactConfig(): SummonReactConfig {\n const s = hostConfigSlot();\n const version = getSummonHostVersion();\n if (s.config && s.version === version) return s.config;\n const host = getSummonHostConfig();\n s.keepAlive ??= new KeepAliveRegistry(DEFAULT_KEEP_ALIVE_LIMIT);\n s.loaders ??= new LoaderCache({ timeoutMs: () => DEFAULT_IMPORT_TIMEOUT_MS });\n s.config = {\n loadingFallback: OverlayLoadingFallback,\n errorFallback: OverlayErrorFallback,\n errorReportExtras: host.errorReportExtras ?? null,\n renderWrapper: host.renderWrapper ?? null,\n importTimeoutMs: DEFAULT_IMPORT_TIMEOUT_MS,\n stallWarnMs: DEFAULT_STALL_WARN_MS,\n keepAlive: s.keepAlive,\n loaders: s.loaders,\n };\n s.version = version;\n return s.config;\n}\n\nexport function useSummonConfig(): SummonReactConfig {\n return useContext(SummonConfigContext) ?? hostReactConfig();\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","// @ai-matrx/summon/react — the render layer: provider (own store context), declare-once\n// definitions, the host, the lazy loader with its boundary and fallbacks, and the hooks.\nexport { SummonProvider, DEFAULT_IMPORT_TIMEOUT_MS, DEFAULT_KEEP_ALIVE_LIMIT, DEFAULT_STALL_WARN_MS, type SummonProviderProps } from \"./react/SummonProvider\";\nexport {\n SummonStoreContext,\n type OverlayRenderContext,\n type OverlayLoadingFallbackProps,\n type OverlayErrorFallbackProps,\n type OverlayErrorExtrasContext,\n} from \"./react/context\";\nexport {\n useSummonSelector,\n useSummonDispatch,\n useSummonStore,\n useSummonPorts,\n useOptionalSummonPorts,\n useOptionalSummonStore,\n type SummonReactDispatch,\n type SummonReactStore,\n} from \"./react/storeHooks\";\nexport {\n defineOverlay,\n CALLBACK_GROUP_KEY,\n type OverlayDefinition,\n type OverlaySpec,\n type HostableOverlay,\n type OverlayHandle,\n type OverlayOpener,\n type OverlayOpenOptions,\n type OverlayControllerProps,\n type OverlayEmitter,\n} from \"@ai-matrx/summon/define\";\nexport type { OverlayRenderProps } from \"./react/instanceBody\";\nexport { emitOverlayEvent, type OverlayEventMap, type OverlayHandlers } from \"./react/events\";\nexport type { RenderModule, RenderLoader } from \"./react/loaderCache\";\nexport { SummonHost, useCloseOnNavigation, type SummonHostProps } from \"./react/SummonHost\";\nexport { MISSING_RENDER_ERROR, type ErasedRenderLoader, type OverlayRenderMap } from \"./react/hostRenders\";\nexport { SummonRoot, type SummonRootProps, configureSummonHost, type SummonHostConfig } from \"@ai-matrx/summon/root\";\nexport {\n useOverlayInstance,\n useOptionalOverlayInstance,\n useOverlayState,\n type OverlayInstanceContextValue,\n type OverlayStateSetter,\n} from \"./react/instance\";\nexport { useIsOverlayOpen, useOpenOverlay, useCloseOverlay, type OpenOverlayOptions } from \"./react/hooks\";\n// Also on `./url`; lives here so a render module can publish its link without loading the link section.\nexport { useOverlayLink } from \"@ai-matrx/summon/root\";\nexport { OverlayErrorBoundary, type OverlayErrorBoundaryProps } from \"./react/OverlayErrorBoundary\";\nexport { OverlayErrorFallback, OverlayLoadingFallback, normalizeOverlayError, type NormalizedOverlayError } from \"./react/fallbacks\";\nexport { chunkTimeoutError } from \"./react/loaderCache\";\n","// Overlay events on the render side. Opening (the channel id that rides open data) is light and\n// lives in the root section; here, with the handles registry loaded, an emit first creates any\n// channel still pending and then delivers synchronously. Registered on evaluation so a\n// definition's `useEmit` (light) emits synchronously inside the render tree.\n\nimport { createEventChannel, getEventChannel } from \"@ai-matrx/summon/handles\";\nimport { materializePendingChannels, type OverlayEventMessage } from \"@ai-matrx/summon/open\";\nimport { registerOverlayEmitter } from \"@ai-matrx/summon/root\";\n\nexport type { OverlayEventMap, OverlayHandlers } from \"@ai-matrx/summon/root\";\nexport type { OverlayEventMessage };\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 materializePendingChannels(createEventChannel);\n getEventChannel<OverlayEventMessage>(channelId)?.emit({ type, payload });\n}\n\nregisterOverlayEmitter(emitOverlayEvent);\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 ComponentType, 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 { dispatchClose, type HostableOverlay } from \"@ai-matrx/summon/root\";\nimport { HostRendersContext, type OverlayRenderMap } from \"./hostRenders\";\nimport { createInstanceBody, type InstanceBodyProps, type OverlayRenderProps } from \"./instanceBody\";\nimport type { RenderLoader } from \"./loaderCache\";\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 * id → `() => import(\"./<id>.render\")` for definitions declared without `render`. Large apps\n * use it so opener importers never reach a window subtree; a definition's own `render` wins.\n */\n readonly renders?: OverlayRenderMap;\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\n// A definition is light (it carries no render code); the host builds each one's instance body on\n// first render and keeps it for the definition's lifetime.\nconst bodies = new WeakMap<HostableOverlay, ComponentType<InstanceBodyProps>>();\nfunction bodyOf(definition: HostableOverlay): ComponentType<InstanceBodyProps> {\n let body = bodies.get(definition);\n if (!body) {\n const parse = definition.parse ?? ((raw: OverlayRawData) => raw);\n // The definition's loader returns its own render module; erased here like the host map's entries.\n const render = definition.render as RenderLoader<OverlayRenderProps<unknown>> | undefined;\n body = createInstanceBody<unknown>(definition.id, definition.label, render, parse, definition.parse !== undefined);\n bodies.set(definition, body);\n }\n return body;\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 = bodyOf(definition);\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, renders }: 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 <HostRendersContext.Provider value={renders ?? null}>\n {definitions.map((definition) => (\n <DefinitionSlot key={definition.id} definition={definition} />\n ))}\n </HostRendersContext.Provider>\n );\n}\n","// The host-side render map. A definition may omit `render`; the host then resolves the overlay's\n// render module from `<SummonHost renders={…}>`. This keeps import() edges out of every file\n// that imports a definition only to open it: in a large app, ~450 opener importers each gaining\n// an edge to a window subtree multiplied the build graph (the host-build law). One generated map\n// imported by the host alone keeps every import() behind the host's own lazy boundary.\n\nimport { createContext, type JSXElementConstructor } from \"react\";\nimport type { OverlayRenderProps } from \"./instanceBody\";\nimport type { RenderLoader } from \"./loaderCache\";\n\n/**\n * One overlay's loader with its data type erased. `never` data accepts every render component\n * typed `OverlayRenderProps<Data>`, so a map of differently typed render modules type-checks\n * without `any` (JSXElementConstructor, not ComponentType: `defaultProps` would make a class\n * component's props covariant and refuse the erasure).\n */\nexport type ErasedRenderLoader = () => Promise<{ readonly default: JSXElementConstructor<OverlayRenderProps<never>> }>;\n\n/** id → lazy render module, for definitions declared without `render`. */\nexport type OverlayRenderMap = Readonly<Record<string, ErasedRenderLoader>>;\n\nexport const HostRendersContext = createContext<OverlayRenderMap | null>(null);\n\n/** The name of the error an overlay with no render source raises into its error card. */\nexport const MISSING_RENDER_ERROR = \"OverlayRenderMissingError\";\n\nconst missing = new Map<string, () => Promise<never>>();\n\n/**\n * A loader for an overlay that is open but has no render module anywhere (no `render` on the\n * definition and no entry in the host's `renders`). It rejects, so the instance shows the error\n * card; in development it also logs once. Never a silent blank.\n */\nexport function missingRenderLoader<P>(overlayId: string): RenderLoader<P> {\n let loader = missing.get(overlayId);\n if (!loader) {\n const message = `Overlay \"${overlayId}\" is open but has no render module: its definition has no \\`render\\` and <SummonHost renders> has no \"${overlayId}\" entry.`;\n loader = () => {\n if (process.env.NODE_ENV !== \"production\") console.error(`[summon] ${message}`);\n const error = new Error(message);\n error.name = MISSING_RENDER_ERROR;\n return Promise.reject(error);\n };\n missing.set(overlayId, loader);\n }\n return loader;\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, useContext, 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 { HostRendersContext, missingRenderLoader } from \"./hostRenders\";\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 /** The definition's own loader; when absent the host's `renders` map supplies it. */\n ownRender: RenderLoader<OverlayRenderProps<Parsed>> | undefined,\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 hostRenders = useContext(HostRendersContext);\n const hostRender = ownRender ? undefined : hostRenders?.[overlayId];\n // The host map is erased (it holds every overlay's loader); the entry under this id was\n // generated from this definition's own render file, so narrowing it to Parsed is sound.\n const render: RenderLoader<OverlayRenderProps<Parsed>> =\n ownRender ?? (hostRender as RenderLoader<OverlayRenderProps<Parsed>> | undefined) ?? missingRenderLoader(overlayId);\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 { useCallback } from \"react\";\nimport { selectOverlayStateValue, setOverlayStateValue } from \"@ai-matrx/summon\";\nimport { useOverlayInstance } from \"@ai-matrx/summon/root\";\nimport { useSummonDispatch, useSummonSelector, useSummonStore } from \"./storeHooks\";\n\nexport {\n OverlayInstanceContext,\n useOverlayInstance,\n useOptionalOverlayInstance,\n type OverlayInstanceContextValue,\n} from \"@ai-matrx/summon/root\";\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","// 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 { dispatchClose, dispatchOpen, newInstanceId, type OverlayHandle } from \"@ai-matrx/summon/root\";\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;AAMlE,SAAS,oBAAoB,0BAA0B;AAiChD,IAAM,sBAAsB,cAAwC,IAAI;AAC/E,oBAAoB,cAAc;;;ACxClC,SAAS,iBAAiB;AAC1B,SAAS,cAAc;;;ACHvB,SAAS,kBAAkB;AAC3B,SAAS,qBAAqB,4BAA4B;AAC1D,SAAS,kBAAkB;;;ACApB,IAAM,oBAAN,MAAwB;AAAA,EACZ,QAAkB,CAAC;AAAA,EACnB,WAAW,oBAAI,IAAwB;AAAA,EAEhD;AAAA,EAER,YAAY,OAAe;AACzB,SAAK,QAAQ;AAAA,EACf;AAAA,EAEA,SAAS,OAAqB;AAC5B,SAAK,QAAQ,KAAK,IAAI,GAAG,KAAK,MAAM,KAAK,CAAC;AAC1C,SAAK,KAAK;AAAA,EACZ;AAAA;AAAA,EAGA,OAAO,KAAa,OAAyB;AAC3C,SAAK,KAAK,GAAG;AACb,SAAK,MAAM,KAAK,GAAG;AACnB,SAAK,SAAS,IAAI,KAAK,KAAK;AAC5B,SAAK,KAAK;AAAA,EACZ;AAAA;AAAA,EAGA,QAAQ,KAA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ACpE,MAAI,cAAc,YAAY,aAAa;AACzC,wBAAoB,YAAY,IAAI,CAAC,eAAe,WAAW,IAAI,CAAC;AACpE,kBAAc,UAAU;AAAA,EAC1B;AACA,uBAAqB;AACrB,SACE,gBAAAP,KAAC,mBAAmB,UAAnB,EAA4B,OAAO,WAAW,MAC5C,sBAAY,IAAI,CAAC,eAChB,gBAAAA,KAAC,kBAAmC,cAAf,WAAW,EAA4B,CAC7D,GACH;AAEJ;;;AFlKA,SAAS,YAAkC,2BAAkD;;;AOlC7F,SAAS,eAAAQ,oBAAmB;AAC5B,SAAS,sBAAsB;AAC/B,SAAS,2BAA2B;AACpC,SAAS,2BAA+D;AACxE,SAAS,iBAAAC,gBAAe,cAAc,qBAAyC;AAIxE,SAAS,iBAAiB,WAAsB,aAAqB,qBAA8B;AACxG,SAAO,kBAAkB,CAAC,UAAU,oBAAoB,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,IAAI;AAC9E,mBAAa,UAAU,WAAW,YAAY,SAAS,QAAQ,IAAI;AACnE,aAAO,EAAE,WAAW,YAAY,OAAO,MAAMC,eAAc,UAAU,WAAW,UAAU,EAAE;AAAA,IAC9F;AAAA,IACA,CAAC,UAAU,SAAS;AAAA,EACtB;AACF;AAGO,SAAS,gBAAgB,WAAsB,aAAqB,qBAAiC;AAC1G,QAAM,WAAW,kBAAkB;AACnC,SAAOD,aAAY,MAAMC,eAAc,UAAU,WAAW,UAAU,GAAG,CAAC,UAAU,WAAW,UAAU,CAAC;AAC5G;;;APMA,SAAS,sBAAsB;","names":["useEffect","Component","jsx","useEffect","jsx","memo","useCallback","useEffect","useRef","useState","createContext","useContext","useEffect","useMemo","useRef","jsx","useOverlayInstance","jsx","useContext","useRef","useMemo","useEffect","jsx","useEffect","memo","InstanceSlot","useCallback","DefinitionSlot","useState","useRef","useCallback","dispatchClose","useCallback","dispatchClose"]}
package/dist/root.cjs CHANGED
@@ -31,14 +31,12 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  // src/root.ts
32
32
  var root_exports = {};
33
33
  __export(root_exports, {
34
- CALLBACK_GROUP_KEY: () => CALLBACK_GROUP_KEY,
35
34
  OverlayInstanceContext: () => OverlayInstanceContext,
36
35
  PopoutContext: () => PopoutContext,
37
36
  SummonPortsContext: () => SummonPortsContext,
38
37
  SummonRoot: () => SummonRoot,
39
38
  SummonStoreContext: () => SummonStoreContext,
40
39
  configureSummonHost: () => configureSummonHost,
41
- defineOverlay: () => defineOverlay,
42
40
  dispatchClose: () => dispatchClose,
43
41
  dispatchOpen: () => dispatchOpen,
44
42
  emitOverlayEventLight: () => emitOverlayEventLight,
@@ -134,10 +132,6 @@ function useOptionalSummonStore() {
134
132
  return context ? context.store : null;
135
133
  }
136
134
 
137
- // src/root/defineOverlay.tsx
138
- var import_react5 = require("react");
139
- var import_open5 = require("@ai-matrx/summon/open");
140
-
141
135
  // src/root/dispatchers.ts
142
136
  var import_open3 = require("@ai-matrx/summon/open");
143
137
  function newInstanceId(overlayId) {
@@ -156,6 +150,19 @@ function dispatchClose(dispatch, overlayId, instanceId = import_open3.DEFAULT_IN
156
150
  dispatch((0, import_open3.closeOverlay)({ overlayId, instanceId }));
157
151
  }
158
152
 
153
+ // src/root/instance.ts
154
+ var import_react4 = require("react");
155
+ var OverlayInstanceContext = (0, import_react4.createContext)(null);
156
+ OverlayInstanceContext.displayName = "OverlayInstanceContext";
157
+ function useOverlayInstance() {
158
+ const value = (0, import_react4.useContext)(OverlayInstanceContext);
159
+ if (!value) throw new Error("[summon] useOverlayInstance() was called outside a rendered overlay.");
160
+ return value;
161
+ }
162
+ function useOptionalOverlayInstance() {
163
+ return (0, import_react4.useContext)(OverlayInstanceContext);
164
+ }
165
+
159
166
  // src/root/emit.ts
160
167
  var import_global_slot2 = require("@ai-matrx/kit/global-slot");
161
168
  var import_open4 = require("@ai-matrx/summon/open");
@@ -175,122 +182,17 @@ function emitOverlayEventLight(channelId, type, payload) {
175
182
  });
176
183
  }
177
184
 
178
- // src/root/instance.ts
179
- var import_react4 = require("react");
180
- var OverlayInstanceContext = (0, import_react4.createContext)(null);
181
- OverlayInstanceContext.displayName = "OverlayInstanceContext";
182
- function useOverlayInstance() {
183
- const value = (0, import_react4.useContext)(OverlayInstanceContext);
184
- if (!value) throw new Error("[summon] useOverlayInstance() was called outside a rendered overlay.");
185
- return value;
186
- }
187
- function useOptionalOverlayInstance() {
188
- return (0, import_react4.useContext)(OverlayInstanceContext);
189
- }
190
-
191
- // src/root/defineOverlay.tsx
192
- function openOverlayEventChannel(owner, getHandlers) {
193
- return (0, import_open5.openPendingEventChannel)(owner, getHandlers);
194
- }
195
- var CALLBACK_GROUP_KEY = "callbackGroupId";
196
- function openWith(dispatch, id, multi, options) {
197
- const instanceId = options?.instanceId ?? (multi ? newInstanceId(id) : import_open5.DEFAULT_INSTANCE_ID);
198
- const key = (0, import_open5.instanceKey)(id, instanceId);
199
- const data = {};
200
- const given = options?.data;
201
- if (typeof given === "object" && given !== null) Object.assign(data, given);
202
- const handlers = options?.handlers;
203
- if (handlers) data[CALLBACK_GROUP_KEY] = openOverlayEventChannel(key, () => handlers);
204
- dispatchOpen(dispatch, id, instanceId, data);
205
- return { overlayId: id, instanceId, close: () => dispatchClose(dispatch, id, instanceId) };
206
- }
207
- function dataSignature(data) {
208
- try {
209
- return JSON.stringify(data, (_key, value) => typeof value === "function" ? void 0 : value);
210
- } catch {
211
- return String(Date.now());
212
- }
213
- }
214
- function defineOverlay() {
215
- return function define(spec) {
216
- const id = spec.id;
217
- const multi = spec.instance === "multi";
218
- const meta = spec;
219
- function useSummon() {
220
- const dispatch = useSummonDispatch();
221
- return (0, import_react5.useCallback)((options) => openWith(dispatch, id, multi, options), [dispatch]);
222
- }
223
- function useIsOpen(instanceId = import_open5.DEFAULT_INSTANCE_ID) {
224
- return useSummonSelector((state) => (0, import_open5.selectIsOverlayOpen)(state, id, instanceId));
225
- }
226
- function useClose() {
227
- const dispatch = useSummonDispatch();
228
- return (0, import_react5.useCallback)((instanceId) => dispatchClose(dispatch, id, instanceId ?? import_open5.DEFAULT_INSTANCE_ID), [dispatch]);
229
- }
230
- function useEmit() {
231
- const instance = useOptionalOverlayInstance();
232
- const channelId = instance?.overlayId === id ? instance.rawData?.[CALLBACK_GROUP_KEY] : void 0;
233
- return (0, import_react5.useCallback)(
234
- (event, payload) => {
235
- if (typeof channelId === "string") emitOverlayEventLight(channelId, event, payload);
236
- },
237
- [channelId]
238
- );
239
- }
240
- function Controller(props) {
241
- const dispatch = useSummonDispatch();
242
- const [ownInstanceId] = (0, import_react5.useState)(() => multi ? newInstanceId(id) : import_open5.DEFAULT_INSTANCE_ID);
243
- const instanceId = props.instanceId ?? ownInstanceId;
244
- const handlersRef = (0, import_react5.useRef)(props.handlers);
245
- handlersRef.current = props.handlers;
246
- const hasHandlers = props.handlers !== void 0;
247
- const data = (0, import_react5.useMemo)(() => {
248
- const out = {};
249
- for (const [key, value] of Object.entries(props)) {
250
- if (key !== "instanceId" && key !== "handlers") out[key] = value;
251
- }
252
- return out;
253
- }, [props]);
254
- const signature = dataSignature(data);
255
- const dataRef = (0, import_react5.useRef)(data);
256
- dataRef.current = data;
257
- (0, import_react5.useEffect)(() => {
258
- const key = (0, import_open5.instanceKey)(id, instanceId);
259
- const open = { ...dataRef.current };
260
- if (hasHandlers) open[CALLBACK_GROUP_KEY] = openOverlayEventChannel(key, () => handlersRef.current);
261
- dispatchOpen(dispatch, id, instanceId, open);
262
- return () => dispatchClose(dispatch, id, instanceId);
263
- }, [dispatch, instanceId, signature, hasHandlers]);
264
- return null;
265
- }
266
- Controller.displayName = `${id}Controller`;
267
- return {
268
- ...spec,
269
- id,
270
- label: spec.label,
271
- instance: multi ? "multi" : "single",
272
- keepAlive: spec.keepAlive ?? "none",
273
- meta,
274
- useSummon,
275
- Controller,
276
- useIsOpen,
277
- useClose,
278
- useEmit
279
- };
280
- };
281
- }
282
-
283
185
  // src/root/PopoutContext.tsx
284
- var import_react6 = require("react");
186
+ var import_react5 = require("react");
285
187
  var DEFAULT_VALUE = {
286
188
  popoutDocument: null,
287
189
  popoutWindow: null,
288
190
  popoutContainer: null,
289
191
  mode: null
290
192
  };
291
- var PopoutContext = (0, import_react6.createContext)(DEFAULT_VALUE);
193
+ var PopoutContext = (0, import_react5.createContext)(DEFAULT_VALUE);
292
194
  function usePopout() {
293
- return (0, import_react6.useContext)(PopoutContext);
195
+ return (0, import_react5.useContext)(PopoutContext);
294
196
  }
295
197
 
296
198
  // src/root/usePopoutContainer.ts
@@ -299,30 +201,30 @@ function usePopoutContainer() {
299
201
  }
300
202
 
301
203
  // src/root/useOverlaySurfaceRenderAck.ts
302
- var import_react7 = require("react");
303
- var import_open6 = require("@ai-matrx/summon/open");
204
+ var import_react6 = require("react");
205
+ var import_open5 = require("@ai-matrx/summon/open");
304
206
  function useOverlaySurfaceRenderAck(overlayId, active) {
305
- (0, import_react7.useEffect)(() => {
207
+ (0, import_react6.useEffect)(() => {
306
208
  if (!active) return void 0;
307
- (0, import_open6.ackOverlaySurfaceRender)(overlayId);
308
- return () => (0, import_open6.clearOverlaySurfaceRender)(overlayId);
209
+ (0, import_open5.ackOverlaySurfaceRender)(overlayId);
210
+ return () => (0, import_open5.clearOverlaySurfaceRender)(overlayId);
309
211
  }, [active, overlayId]);
310
212
  }
311
213
 
312
214
  // src/root/useOverlayLink.ts
313
- var import_react8 = require("react");
314
- var import_open7 = require("@ai-matrx/summon/open");
215
+ var import_react7 = require("react");
216
+ var import_open6 = require("@ai-matrx/summon/open");
315
217
  function useOverlayLink(linkKey, id, args) {
316
218
  const dispatch = useSummonDispatch();
317
219
  const argsKey = args ? JSON.stringify(
318
220
  Object.keys(args).sort().map((k) => [k, args[k]])
319
221
  ) : "";
320
- const stableArgs = (0, import_react8.useMemo)(() => args ? { ...args } : void 0, [argsKey]);
321
- (0, import_react8.useEffect)(() => {
222
+ const stableArgs = (0, import_react7.useMemo)(() => args ? { ...args } : void 0, [argsKey]);
223
+ (0, import_react7.useEffect)(() => {
322
224
  if (!linkKey || !id) return void 0;
323
- dispatch((0, import_open7.registerSyncEntry)(stableArgs ? { typeKey: linkKey, instanceId: id, args: stableArgs } : { typeKey: linkKey, instanceId: id }));
225
+ dispatch((0, import_open6.registerSyncEntry)(stableArgs ? { typeKey: linkKey, instanceId: id, args: stableArgs } : { typeKey: linkKey, instanceId: id }));
324
226
  return () => {
325
- dispatch((0, import_open7.unregisterSyncEntry)({ typeKey: linkKey, instanceId: id }));
227
+ dispatch((0, import_open6.unregisterSyncEntry)({ typeKey: linkKey, instanceId: id }));
326
228
  };
327
229
  }, [dispatch, linkKey, id, stableArgs]);
328
230
  }