@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.
- package/CHANGELOG.md +16 -0
- package/dist/define.cjs +123 -0
- package/dist/define.cjs.map +1 -0
- package/dist/define.d.cts +79 -0
- package/dist/define.d.ts +79 -0
- package/dist/define.js +114 -0
- package/dist/define.js.map +1 -0
- package/dist/{gate-1c08vnzx.d.cts → gate-BalZq3nu.d.cts} +1 -1
- package/dist/{gate-1c08vnzx.d.ts → gate-BalZq3nu.d.ts} +1 -1
- package/dist/handles.cjs +3 -1
- package/dist/handles.cjs.map +1 -1
- package/dist/handles.d.cts +4 -1
- package/dist/handles.d.ts +4 -1
- package/dist/handles.js +3 -1
- package/dist/handles.js.map +1 -1
- package/dist/index.cjs +3 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/open.cjs +33 -0
- package/dist/open.cjs.map +1 -1
- package/dist/open.d.cts +45 -2
- package/dist/open.d.ts +45 -2
- package/dist/open.js +33 -0
- package/dist/open.js.map +1 -1
- package/dist/react.cjs +8 -8
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +2 -1
- package/dist/react.d.ts +2 -1
- package/dist/react.js +1 -1
- package/dist/react.js.map +1 -1
- package/dist/root.cjs +27 -125
- package/dist/root.cjs.map +1 -1
- package/dist/root.d.cts +4 -76
- package/dist/root.d.ts +4 -76
- package/dist/root.js +18 -121
- package/dist/root.js.map +1 -1
- package/dist/url.cjs +7 -23
- package/dist/url.cjs.map +1 -1
- package/dist/url.d.cts +3 -37
- package/dist/url.d.ts +3 -37
- package/dist/url.js +4 -20
- package/dist/url.js.map +1 -1
- package/package.json +13 -3
package/dist/root.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/root.ts","../src/root/SummonRoot.tsx","../src/root/context.ts","../src/root/host.ts","../src/root/storeHooks.ts","../src/root/defineOverlay.tsx","../src/root/dispatchers.ts","../src/root/emit.ts","../src/root/instance.ts","../src/root/PopoutContext.tsx","../src/root/usePopoutContainer.ts","../src/root/useOverlaySurfaceRenderAck.ts","../src/root/useOverlayLink.ts"],"sourcesContent":["// @ai-matrx/summon/root — the light React half: `<SummonRoot>` (store + host settings, nothing\n// heavy), the store hooks, `defineOverlay` (openers, Controller, open/close hooks, emitter) and the\n// instance context. Importing it never loads a slice, the host, a window or the handles registry.\nexport { SummonRoot, type SummonRootProps } from \"./root/SummonRoot\";\nexport { SummonStoreContext, SummonPortsContext } from \"./root/context\";\nexport {\n configureSummonHost,\n getSummonHostConfig,\n getSummonHostPorts,\n getSummonHostVersion,\n type SummonHostConfig,\n type SummonHostWindows,\n type OverlayRenderContext,\n type OverlayErrorExtrasContext,\n} from \"./root/host\";\nexport {\n useSummonSelector,\n useSummonDispatch,\n useSummonStore,\n useSummonPorts,\n useOptionalSummonPorts,\n useOptionalSummonStore,\n type SummonReactDispatch,\n type SummonReactStore,\n} from \"./root/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 type OverlayEventMap,\n type OverlayHandlers,\n} from \"./root/defineOverlay\";\nexport { newInstanceId, dispatchOpen, dispatchClose } from \"./root/dispatchers\";\nexport { OverlayInstanceContext, useOverlayInstance, useOptionalOverlayInstance, type OverlayInstanceContextValue } from \"./root/instance\";\nexport { registerOverlayEmitter, emitOverlayEventLight } from \"./root/emit\";\n// Hooks a render module calls inside a window, light enough for any boot graph (one identity:\n// `./window-host`, `./window`, `./react` and `./url` re-export these).\nexport { usePopout, PopoutContext, type PopoutContextValue, type PopoutMode } from \"./root/PopoutContext\";\nexport { usePopoutContainer } from \"./root/usePopoutContainer\";\nexport { useOverlaySurfaceRenderAck } from \"./root/useOverlaySurfaceRenderAck\";\nexport { useOverlayLink } from \"./root/useOverlayLink\";\n","// `<SummonRoot>` — the only summon component a host mounts at its root, and it does next to\n// nothing: it hands the host's store to the summon context (so every opener works at once) and\n// records the host's settings. Nothing heavy loads here. The host's runtime component (tray sync,\n// router bridge — whatever only matters once windows exist) is fetched and mounted the moment the\n// summon core installs: on the first open, a page's own WindowPanel, a link, or saved windows.\n\nimport { lazy, Suspense, useEffect, useState, useSyncExternalStore, type ComponentType, type ReactNode } from \"react\";\nimport { Provider } from \"react-redux\";\nimport type { Store } from \"@reduxjs/toolkit\";\nimport { isSummonInstalled, subscribeSummonInstalled } from \"@ai-matrx/summon/open\";\nimport { SummonStoreContext } from \"./context\";\nimport { configureSummonHost, type SummonHostConfig } from \"./host\";\n\nexport interface SummonRootProps extends SummonHostConfig {\n /** The host store, with the gate (`createSummonGate`) in its middleware chain. */\n readonly store: Store<unknown>;\n /** Mounted once the summon core is installed; one import() of the host's whole runtime set. */\n readonly runtime?: () => Promise<{ default: ComponentType }>;\n readonly children?: ReactNode;\n}\n\nconst serverSnapshot = () => false;\n\nexport function SummonRoot({ store, runtime, children, ports, renderWrapper, errorReportExtras, windows }: SummonRootProps) {\n // Settings are recorded before the first child renders (a page's WindowPanel may read them).\n const [config] = useState<SummonHostConfig>(() => {\n const initial = { ports, renderWrapper, errorReportExtras, windows };\n configureSummonHost(initial);\n return initial;\n });\n useEffect(() => {\n if (config.ports === ports && config.renderWrapper === renderWrapper && config.errorReportExtras === errorReportExtras && config.windows === windows) return;\n configureSummonHost({ ports, renderWrapper, errorReportExtras, windows });\n }, [config, ports, renderWrapper, errorReportExtras, windows]);\n\n const installed = useSyncExternalStore(subscribeSummonInstalled, isSummonInstalled, serverSnapshot);\n const [Runtime] = useState(() => (runtime ? lazy(runtime) : null));\n\n return (\n <Provider store={store} context={SummonStoreContext}>\n {children}\n {installed && Runtime ? (\n <Suspense fallback={null}>\n <Runtime />\n </Suspense>\n ) : null}\n </Provider>\n );\n}\n","// The contexts every summon section reads, light enough for the root: the overlays store rides\n// its OWN react-redux context (chat-package pattern), so a private overlays store never collides\n// with a host's store and a host that hands its one store to `<SummonRoot>` simply passes it in.\nimport { createContext } from \"react\";\nimport type { ReactReduxContextValue } from \"react-redux\";\nimport type { SummonPorts } from \"@ai-matrx/summon/open\";\n\nexport const SummonStoreContext = createContext<ReactReduxContextValue | null>(null);\nSummonStoreContext.displayName = \"SummonStoreContext\";\n\nexport const SummonPortsContext = createContext<SummonPorts | null>(null);\nSummonPortsContext.displayName = \"SummonPortsContext\";\n","// The host's settings, configured ONCE at the root (`<SummonRoot>`) and read wherever a provider\n// is absent: a WindowPanel rendered by a page, the lazily loaded host, links and persistence. A\n// heavy `<SummonProvider>` still overrides them for its subtree (a package's own bare host).\nimport { globalSlot } from \"@ai-matrx/kit/global-slot\";\nimport { resolvePorts, type SummonPorts } from \"@ai-matrx/summon/open\";\nimport type { ComponentType, ReactNode } from \"react\";\n\n/** One rendered overlay instance, as the host wrapper and error extras see it. */\nexport interface OverlayRenderContext {\n readonly overlayId: string;\n readonly instanceId: string;\n readonly instanceKey: string;\n readonly label: string;\n}\n\nexport interface OverlayErrorExtrasContext extends OverlayRenderContext {\n readonly error: unknown;\n readonly componentStack: string | null;\n}\n\nexport interface SummonHostWindows {\n readonly escapeYieldSelector?: string | undefined;\n readonly mobileTopOffset?: string | undefined;\n readonly selectionSurface?: ComponentType<{ readonly children: ReactNode }> | undefined;\n}\n\nexport interface SummonHostConfig {\n readonly ports?: Partial<SummonPorts> | undefined;\n /** Wrap every rendered overlay (AI Matrx: its surface layer boundary). */\n readonly renderWrapper?: ((node: ReactNode, context: OverlayRenderContext) => ReactNode) | undefined;\n /** Extra controls in the default error card's footer (AI Matrx: \"Copy for AI\"). */\n readonly errorReportExtras?: ((context: OverlayErrorExtrasContext) => ReactNode) | undefined;\n /** Window host options (the window section reads them when no WindowsProvider is above). */\n readonly windows?: SummonHostWindows | undefined;\n}\n\ninterface HostSlot {\n config: SummonHostConfig;\n ports: SummonPorts | null;\n version: number;\n}\n\nconst slot = (): HostSlot => globalSlot<HostSlot>(\"ai-matrx.summon.host\", () => ({ config: {}, ports: null, version: 0 }));\n\nexport function configureSummonHost(config: SummonHostConfig): void {\n const s = slot();\n if (s.config === config) return;\n s.config = config;\n s.ports = null;\n s.version += 1;\n}\n\nexport function getSummonHostConfig(): SummonHostConfig {\n return slot().config;\n}\n\n/** The configured ports, resolved over the working defaults (stable until reconfigured). */\nexport function getSummonHostPorts(): SummonPorts {\n const s = slot();\n return (s.ports ??= resolvePorts(s.config.ports));\n}\n\n/** Bumps on every reconfigure; memo keys for values derived from the host config. */\nexport function getSummonHostVersion(): number {\n return slot().version;\n}\n","// Typed hooks over the package's own store context. Every package component reads the overlays\n// store through these, never react-redux's default context, so a host's own <Provider> and the\n// overlays store never collide.\n\nimport { useContext } from \"react\";\nimport {\n createDispatchHook,\n createSelectorHook,\n createStoreHook,\n type UseDispatch,\n type UseSelector,\n type UseStore,\n} from \"react-redux\";\nimport type { Dispatch, Store, UnknownAction } from \"@reduxjs/toolkit\";\nimport type { SummonRootState } from \"@ai-matrx/summon\";\nimport type { SummonPorts } from \"@ai-matrx/summon/open\";\nimport { SummonPortsContext, SummonStoreContext } from \"./context\";\nimport { getSummonHostPorts } from \"./host\";\n\n/** Dispatch as the React section uses it: plain actions (thunks are the host's business). */\nexport type SummonReactDispatch = Dispatch<UnknownAction>;\n\n/** The store as the React section sees it: the overlays slices at their root keys (a host store has more). */\nexport type SummonReactStore = Store<SummonRootState>;\n\n/** Select from the overlays store. */\nexport const useSummonSelector: UseSelector<SummonRootState> = createSelectorHook(SummonStoreContext).withTypes<SummonRootState>();\n\n/** The overlays store's dispatch. */\nexport const useSummonDispatch: UseDispatch<SummonReactDispatch> = createDispatchHook(SummonStoreContext).withTypes<SummonReactDispatch>();\n\n/** The overlays store itself (for `getState()` inside callbacks). */\nexport const useSummonStore: UseStore<SummonReactStore> = createStoreHook(SummonStoreContext).withTypes<SummonReactStore>();\n\n/** The nearest provider's ports, else the ports configured at the root, else the working defaults. */\nexport function useSummonPorts(): SummonPorts {\n return useContext(SummonPortsContext) ?? getSummonHostPorts();\n}\n\n/** Same as `useSummonPorts` (kept for components written to work page-local). */\nexport function useOptionalSummonPorts(): SummonPorts {\n return useContext(SummonPortsContext) ?? getSummonHostPorts();\n}\n\n/**\n * The nearest provider's store, or `null` when nothing above provides one — for packages that\n * mount their own provider only when the host has none (chat's windows on a bare host).\n */\nexport function useOptionalSummonStore(): SummonReactStore | null {\n const context = useContext(SummonStoreContext);\n return context ? (context.store as unknown as SummonReactStore) : null;\n}\n","// `defineOverlay` — the declare-once API (C38 R2). One light definition per overlay carries its\n// metadata and (optionally) a lazy `render` import; the definition generates the opener hook, the declarative\n// Controller, the open/close hooks and a typed event emitter. The host renders definitions; the\n// render module is the old controller block, moved verbatim, and is fetched only when opened.\n//\n// Light by construction (the root section): no slice, no host, no handles registry. Opening goes\n// through the light creators (a gated host store loads the core on the first one); a callback-aware\n// open reserves its event channel and the handles section arrives with that first open.\n\nimport { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport {\n DEFAULT_INSTANCE_ID,\n instanceKey as toInstanceKey,\n openPendingEventChannel,\n selectIsOverlayOpen,\n type InstanceKey,\n type OverlayDefinitionMeta,\n type OverlayRawData,\n type AnyOverlayMeta,\n} from \"@ai-matrx/summon/open\";\nimport type { OverlayRenderProps } from \"../react/instanceBody\";\nimport type { RenderModule } from \"../react/loaderCache\";\nimport { dispatchClose, dispatchOpen, newInstanceId } from \"./dispatchers\";\nimport { emitOverlayEventLight } from \"./emit\";\nimport { useOptionalOverlayInstance } from \"./instance\";\nimport { useSummonDispatch, useSummonSelector, type SummonReactDispatch } from \"./storeHooks\";\n\n/** Event name → payload, declared once per overlay: `defineOverlay<Data, { uploaded: Result }>()`. */\nexport type OverlayEventMap = Record<string, unknown>;\n\nexport type OverlayHandlers<Events extends OverlayEventMap> = {\n readonly [K in keyof Events]?: (payload: Events[K]) => void;\n};\n\nfunction openOverlayEventChannel<Events extends OverlayEventMap>(\n owner: InstanceKey,\n getHandlers: () => OverlayHandlers<Events> | undefined,\n): string {\n return openPendingEventChannel(owner, getHandlers as () => Readonly<Record<string, ((payload: unknown) => void) | undefined>> | undefined);\n}\n\n/** The open-data key that carries an overlay's event channel id (the old callback-group key). */\nexport const CALLBACK_GROUP_KEY = \"callbackGroupId\";\n\nexport interface OverlayHandle {\n readonly overlayId: string;\n readonly instanceId: string;\n close(): void;\n}\n\nexport interface OverlayOpenOptions<Data, Events extends OverlayEventMap> {\n readonly data?: Data;\n /** Single-instance overlays ignore it unless given; multi-instance generate one when omitted. */\n readonly instanceId?: string;\n /** Plain functions; they reach the caller through an event channel owned by the instance. */\n readonly handlers?: OverlayHandlers<Events>;\n}\n\nexport type OverlayOpener<Data, Events extends OverlayEventMap> = (options?: OverlayOpenOptions<Data, Events>) => OverlayHandle;\n\nexport type OverlayControllerProps<Data, Events extends OverlayEventMap> = Data & {\n readonly instanceId?: string;\n readonly handlers?: OverlayHandlers<Events>;\n};\n\nexport type OverlayEmitter<Events extends OverlayEventMap> = <K extends keyof Events & string>(event: K, payload: Events[K]) => void;\n\n/** What a definition file passes to `defineOverlay<Data>()(…)`. */\nexport interface OverlaySpec<Id extends string, Data, Parsed> extends OverlayDefinitionMeta<Id, Data> {\n /**\n * The lazily loaded render module. Its default export receives `OverlayRenderProps<Parsed>`.\n * Optional: a large app leaves it out and hands `<SummonHost renders={…}>` one id → import map,\n * so files that import a definition for its opener never gain an import() edge to the window\n * (the host-build law). When present it wins over the host map.\n */\n readonly render?: () => Promise<RenderModule<OverlayRenderProps<NoInfer<Parsed>>>>;\n /** Narrow raw open data once. `null` = refuse: the instance is closed with a warning. */\n readonly parse?: (raw: OverlayRawData) => Parsed | null;\n}\n\n/** The type-erased half the host renders; no data types cross this line. */\nexport interface HostableOverlay {\n readonly id: string;\n readonly label: string;\n readonly instance: \"single\" | \"multi\";\n readonly keepAlive: \"none\" | \"hidden\" | \"restore\";\n /** The metadata the core registry stores (links, window options, defaults…). */\n readonly meta: AnyOverlayMeta;\n /** The definition's own render loader (the host's `renders` map is used when absent). */\n readonly render?: (() => Promise<unknown>) | undefined;\n /** Narrows raw open data; the host builds each instance body from it on first render. */\n readonly parse?: ((raw: OverlayRawData) => unknown) | undefined;\n}\n\nexport interface OverlayDefinition<Id extends string, Data, Parsed, Events extends OverlayEventMap>\n extends Omit<OverlayDefinitionMeta<Id, Data>, \"id\" | \"instance\" | \"keepAlive\">,\n HostableOverlay {\n readonly id: Id;\n readonly render?: () => Promise<RenderModule<OverlayRenderProps<Parsed>>>;\n /** Imperative opener: `const open = def.useSummon(); open({ data })` → handle. */\n useSummon(): OverlayOpener<Data, Events>;\n /** Declarative form: opens on mount, closes on unmount, re-opens when its data changes. */\n readonly Controller: (props: OverlayControllerProps<Data, Events>) => null;\n useIsOpen(instanceId?: string): boolean;\n /** `const close = def.useClose(); close(instanceId?)`. */\n useClose(): (instanceId?: string) => void;\n /** Inside the render tree: emit a declared event to the opener's handlers. */\n useEmit(): OverlayEmitter<Events>;\n}\n\nfunction openWith<Data, Events extends OverlayEventMap>(\n dispatch: SummonReactDispatch,\n id: string,\n multi: boolean,\n options: OverlayOpenOptions<Data, Events> | undefined,\n): OverlayHandle {\n const instanceId = options?.instanceId ?? (multi ? newInstanceId(id) : DEFAULT_INSTANCE_ID);\n const key = toInstanceKey(id, instanceId);\n const data: Record<string, unknown> = {};\n const given: unknown = options?.data;\n if (typeof given === \"object\" && given !== null) Object.assign(data, given);\n const handlers = options?.handlers;\n if (handlers) data[CALLBACK_GROUP_KEY] = openOverlayEventChannel<Events>(key, () => handlers);\n dispatchOpen(dispatch, id, instanceId, data);\n return { overlayId: id, instanceId, close: () => dispatchClose(dispatch, id, instanceId) };\n}\n\n/** Stable identity for the serialisable part of Controller props (functions never reopen). */\nfunction dataSignature(data: Readonly<Record<string, unknown>>): string {\n try {\n return JSON.stringify(data, (_key, value: unknown) => (typeof value === \"function\" ? undefined : value));\n } catch {\n return String(Date.now());\n }\n}\n\n/**\n * Declare an overlay once. Curried so `Data` (and `Events`) are named while the id and the\n * parsed-data type are inferred:\n *\n * export const notesWindow = defineOverlay<NotesWindowData>()({\n * id: \"notesWindow\", label: \"Notes\", render: () => import(\"./notesWindow.render\"),\n * });\n */\nexport function defineOverlay<Data extends object = Record<string, never>, Events extends OverlayEventMap = Record<never, never>>() {\n return function define<const Id extends string, Parsed = OverlayRawData>(\n spec: OverlaySpec<Id, Data, Parsed>,\n ): OverlayDefinition<Id, Data, Parsed, Events> {\n const id = spec.id;\n const multi = spec.instance === \"multi\";\n // The registry stores every definition's metadata under one erased type (AnyOverlayMeta).\n const meta: AnyOverlayMeta = spec;\n\n function useSummon(): OverlayOpener<Data, Events> {\n const dispatch = useSummonDispatch();\n return useCallback((options) => openWith(dispatch, id, multi, options), [dispatch]);\n }\n\n function useIsOpen(instanceId: string = DEFAULT_INSTANCE_ID): boolean {\n return useSummonSelector((state) => selectIsOverlayOpen(state, id, instanceId));\n }\n\n function useClose(): (instanceId?: string) => void {\n const dispatch = useSummonDispatch();\n return useCallback((instanceId?: string) => dispatchClose(dispatch, id, instanceId ?? DEFAULT_INSTANCE_ID), [dispatch]);\n }\n\n function useEmit(): OverlayEmitter<Events> {\n const instance = useOptionalOverlayInstance();\n const channelId = instance?.overlayId === id ? instance.rawData?.[CALLBACK_GROUP_KEY] : undefined;\n return useCallback<OverlayEmitter<Events>>(\n (event, payload) => {\n if (typeof channelId === \"string\") emitOverlayEventLight(channelId, event, payload);\n },\n [channelId],\n );\n }\n\n function Controller(props: OverlayControllerProps<Data, Events>): null {\n const dispatch = useSummonDispatch();\n const [ownInstanceId] = useState(() => (multi ? newInstanceId(id) : DEFAULT_INSTANCE_ID));\n const instanceId = props.instanceId ?? ownInstanceId;\n // Latest handlers, read at emit time: a new function identity never reopens the overlay.\n const handlersRef = useRef(props.handlers);\n handlersRef.current = props.handlers;\n const hasHandlers = props.handlers !== undefined;\n\n const data = useMemo(() => {\n const out: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(props)) {\n if (key !== \"instanceId\" && key !== \"handlers\") out[key] = value;\n }\n return out;\n }, [props]);\n const signature = dataSignature(data);\n const dataRef = useRef(data);\n dataRef.current = data;\n\n useEffect(() => {\n const key: InstanceKey = toInstanceKey(id, instanceId);\n const open: Record<string, unknown> = { ...dataRef.current };\n if (hasHandlers) open[CALLBACK_GROUP_KEY] = openOverlayEventChannel<Events>(key, () => handlersRef.current);\n dispatchOpen(dispatch, id, instanceId, open);\n return () => dispatchClose(dispatch, id, instanceId);\n }, [dispatch, instanceId, signature, hasHandlers]);\n\n return null;\n }\n Controller.displayName = `${id}Controller`;\n\n return {\n ...spec,\n id,\n label: spec.label,\n instance: multi ? \"multi\" : \"single\",\n keepAlive: spec.keepAlive ?? \"none\",\n meta,\n useSummon,\n Controller,\n useIsOpen,\n useClose,\n useEmit,\n };\n };\n}\n","// The one place a definition turns an untyped (string) overlay id into the typed action creators.\n// Inside the package `OverlayId` is `string`; a host that augments the registry narrows it to its\n// ids, and these keep compiling there because definitions carry their own id.\n\nimport { closeOverlay, openOverlay, DEFAULT_INSTANCE_ID, type OverlayDataOf, type OverlayId } from \"@ai-matrx/summon/open\";\nimport type { SummonReactDispatch } from \"./storeHooks\";\n\nexport function newInstanceId(overlayId: string): string {\n return `${overlayId}-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;\n}\n\nexport function dispatchOpen(dispatch: SummonReactDispatch, overlayId: string, instanceId: string, data: unknown): void {\n dispatch(\n openOverlay({\n overlayId: overlayId as OverlayId,\n instanceId,\n data: (data ?? null) as OverlayDataOf<OverlayId> | null,\n }),\n );\n}\n\nexport function dispatchClose(dispatch: SummonReactDispatch, overlayId: string, instanceId: string = DEFAULT_INSTANCE_ID): void {\n dispatch(closeOverlay({ overlayId: overlayId as OverlayId, instanceId }));\n}\n","// Emitting an overlay event from inside its render tree. The render tree has the handles registry\n// loaded (the react section registers its synchronous emitter on evaluation); before that, the\n// emit waits for the one handles import.\nimport { globalSlot } from \"@ai-matrx/kit/global-slot\";\nimport { materializePendingChannels } from \"@ai-matrx/summon/open\";\n\ntype Emitter = (channelId: string, type: string, payload: unknown) => void;\n\nconst slot = (): { emit: Emitter | null } => globalSlot(\"ai-matrx.summon.emitter\", () => ({ emit: null as Emitter | null }));\n\n/** The react section installs the synchronous emitter (it holds handles statically). */\nexport function registerOverlayEmitter(emit: Emitter): void {\n slot().emit = emit;\n}\n\nexport function emitOverlayEventLight(channelId: string, type: string, payload: unknown): void {\n const emit = slot().emit;\n if (emit) {\n emit(channelId, type, payload);\n return;\n }\n void import(\"@ai-matrx/summon/handles\").then(({ createEventChannel, getEventChannel }) => {\n materializePendingChannels(createEventChannel);\n getEventChannel<{ type: string; payload: unknown }>(channelId)?.emit({ type, payload });\n });\n}\n","// The context every rendered overlay instance provides to its subtree, and the hooks that read who\n// it is. Light: a definition's `useEmit` reads it; the saved-state hook stays in `./react`.\nimport { createContext, useContext } from \"react\";\nimport type { InstanceKey, OverlayRawData } from \"@ai-matrx/summon/open\";\n\nexport interface OverlayInstanceContextValue {\n readonly overlayId: string;\n readonly instanceId: string;\n readonly instanceKey: InstanceKey;\n readonly close: () => void;\n readonly hidden: boolean;\n /** The open data as it arrived (pre-parse); event emitters read their channel id from it. */\n readonly rawData: OverlayRawData;\n}\n\nexport const OverlayInstanceContext = createContext<OverlayInstanceContextValue | null>(null);\nOverlayInstanceContext.displayName = \"OverlayInstanceContext\";\n\n/** The open instance this component renders inside. Throws outside an overlay. */\nexport function useOverlayInstance(): OverlayInstanceContextValue {\n const value = useContext(OverlayInstanceContext);\n if (!value) throw new Error(\"[summon] useOverlayInstance() was called outside a rendered overlay.\");\n return value;\n}\n\n/** Same as `useOverlayInstance`, but `null` outside an overlay. */\nexport function useOptionalOverlayInstance(): OverlayInstanceContextValue | null {\n return useContext(OverlayInstanceContext);\n}\n","\"use client\";\n\n/**\n * PopoutContext — exposes the popout `Document` / `Window` / portal target\n * to descendants of a popped-out subtree.\n *\n * The default value (`popoutDocument: null`, etc.) means \"I'm rendered in\n * the parent document.\" Descendants that need to behave differently inside\n * a popout (e.g. Radix portals retargeting their content) call\n * `usePopout()` and branch on the values.\n *\n * **Architectural note:** because `createPortal` preserves the parent\n * React tree, every ancestor `Provider` cascades into the popout — Redux,\n * Theme, Tooltip, Router, all work without re-wrapping. This context is\n * for the *opposite* direction: telling popped-out content \"you're inside\n * a popout window, here's the document/window/container you should use\n * instead of the global `document`/`window`.\"\n */\nimport { createContext, useContext } from \"react\";\n\nexport type PopoutMode = \"pip\" | \"popup\";\n\nexport interface PopoutContextValue {\n /**\n * The popout `Document`. `null` when this subtree is rendered in the\n * parent (the default).\n */\n popoutDocument: Document | null;\n /**\n * The popout `Window`. `null` when this subtree is rendered in the parent.\n * Use for `addEventListener`, `matchMedia`, `innerWidth`, etc., when the\n * popout-scoped answer is what you need.\n */\n popoutWindow: Window | null;\n /**\n * Element to use as the Radix `Portal.container` prop so floating UI\n * (tooltips, popovers, dropdowns) renders inside the popout instead of\n * the parent `document.body`. Returns `null` outside a popout —\n * `usePopoutContainer` coerces this to `undefined` so Radix falls back\n * to its default container automatically.\n */\n popoutContainer: HTMLElement | null;\n /**\n * Which popout mechanism is in use. `null` outside a popout.\n * Currently only used for diagnostics; downstream components may branch\n * on it later (e.g. show different chrome for `popup` vs `pip`).\n */\n mode: PopoutMode | null;\n}\n\nconst DEFAULT_VALUE: PopoutContextValue = {\n popoutDocument: null,\n popoutWindow: null,\n popoutContainer: null,\n mode: null,\n};\n\nexport const PopoutContext =\n createContext<PopoutContextValue>(DEFAULT_VALUE);\n\n/** Read the current popout context. Always defined — never throws. */\nexport function usePopout(): PopoutContextValue {\n return useContext(PopoutContext);\n}\n","\"use client\";\n\n/**\n * usePopoutContainer — return the element Radix portals (Tooltip, Popover,\n * Dropdown, Dialog, Select, AlertDialog, HoverCard) should mount into.\n *\n * **The problem this solves:** by default every Radix `Portal` mounts to\n * `document.body`. When a tooltip-trigger lives inside a popped-out window\n * but the popover content portals to the *parent* document, the tooltip\n * appears in the wrong window — typically invisible to the user.\n *\n * **The fix:** wrappers around Radix primitives call this hook and pass\n * the result as `<Primitive.Portal container={...} />`. Inside a popout,\n * the result is the popout's `<body>`. Outside a popout, the result is\n * `undefined`, which Radix interprets as \"use the default\" — meaning no\n * behavior change for any of the thousands of existing usages.\n *\n * **Why `undefined` instead of `null`?** Radix's `container` prop accepts\n * `HTMLElement | null | undefined`. Passing `null` actively tries to\n * portal into a `null` target and crashes. Passing `undefined` falls\n * through to the default (`document.body`). The `?? undefined` coerces\n * the `null` we get from `PopoutContext` outside a popout into the\n * Radix-friendly default-fallthrough value.\n */\nimport { usePopout } from \"./PopoutContext\";\n\nexport function usePopoutContainer(): HTMLElement | undefined {\n return usePopout().popoutContainer ?? undefined;\n}\n","\"use client\";\n\nimport { useEffect } from \"react\";\nimport { ackOverlaySurfaceRender, clearOverlaySurfaceRender } from \"@ai-matrx/summon/open\";\n\n/**\n * Acknowledge a visible presentation that intentionally replaces WindowPanel.\n *\n * Registered singleton window overlays normally prove they are on screen by mounting a\n * WindowPanel and registering geometry. Mobile drawers, sheets, and full-screen\n * viewers have no window-manager geometry, so their composition root must use\n * this hook while that alternate surface is active.\n */\nexport function useOverlaySurfaceRenderAck(\n overlayId: string,\n active: boolean,\n): void {\n useEffect(() => {\n if (!active) return undefined;\n ackOverlaySurfaceRender(overlayId);\n return () => clearOverlaySurfaceRender(overlayId);\n }, [active, overlayId]);\n}\n","import { useEffect, useMemo } from \"react\";\nimport { registerSyncEntry, unregisterSyncEntry } from \"@ai-matrx/summon/open\";\nimport { useSummonDispatch } from \"./storeHooks\";\n\n/**\n * Publish an open instance's address into `?panels=` while it is mounted. `linkKey` undefined →\n * nothing is published (a window with no link); so is an undefined or empty `id`. The token is `linkKey:id[:args]`; args are\n * compared by value, so a new object with equal contents never re-registers.\n */\nexport function useOverlayLink(linkKey: string | undefined, id: string | undefined, args?: Readonly<Record<string, string>>): void {\n const dispatch = useSummonDispatch();\n const argsKey = args\n ? JSON.stringify(\n Object.keys(args)\n .sort()\n .map((k) => [k, args[k]]),\n )\n : \"\";\n // Rebuilt only when the VALUES change (argsKey), never on a fresh object with equal contents.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const stableArgs = useMemo(() => (args ? { ...args } : undefined), [argsKey]);\n\n useEffect(() => {\n if (!linkKey || !id) return undefined;\n dispatch(registerSyncEntry(stableArgs ? { typeKey: linkKey, instanceId: id, args: stableArgs } : { typeKey: linkKey, instanceId: id }));\n return () => {\n dispatch(unregisterSyncEntry({ typeKey: linkKey, instanceId: id }));\n };\n }, [dispatch, linkKey, id, stableArgs]);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACMA,IAAAA,gBAA8G;AAC9G,yBAAyB;AAEzB,IAAAC,eAA4D;;;ACN5D,mBAA8B;AAIvB,IAAM,yBAAqB,4BAA6C,IAAI;AACnF,mBAAmB,cAAc;AAE1B,IAAM,yBAAqB,4BAAkC,IAAI;AACxE,mBAAmB,cAAc;;;ACRjC,yBAA2B;AAC3B,kBAA+C;AAsC/C,IAAM,OAAO,UAAgB,+BAAqB,wBAAwB,OAAO,EAAE,QAAQ,CAAC,GAAG,OAAO,MAAM,SAAS,EAAE,EAAE;AAElH,SAAS,oBAAoB,QAAgC;AAClE,QAAM,IAAI,KAAK;AACf,MAAI,EAAE,WAAW,OAAQ;AACzB,IAAE,SAAS;AACX,IAAE,QAAQ;AACV,IAAE,WAAW;AACf;AAEO,SAAS,sBAAwC;AACtD,SAAO,KAAK,EAAE;AACh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C;AAE5E,+BAAU,MAAM;AACd,QAAI,CAAC,WAAW,CAAC,GAAI,QAAO;AAC5B,iBAAS,gCAAkB,aAAa,EAAE,SAAS,SAAS,YAAY,IAAI,MAAM,WAAW,IAAI,EAAE,SAAS,SAAS,YAAY,GAAG,CAAC,CAAC;AACtI,WAAO,MAAM;AACX,mBAAS,kCAAoB,EAAE,SAAS,SAAS,YAAY,GAAG,CAAC,CAAC;AAAA,IACpE;AAAA,EACF,GAAG,CAAC,UAAU,SAAS,IAAI,UAAU,CAAC;AACxC;","names":["import_react","import_open","import_react","import_react_redux","import_react","import_open","import_open","import_global_slot","import_open","slot","import_react","toInstanceKey","import_react","import_react","import_open","import_react","import_open"]}
|
|
1
|
+
{"version":3,"sources":["../src/root.ts","../src/root/SummonRoot.tsx","../src/root/context.ts","../src/root/host.ts","../src/root/storeHooks.ts","../src/root/dispatchers.ts","../src/root/instance.ts","../src/root/emit.ts","../src/root/PopoutContext.tsx","../src/root/usePopoutContainer.ts","../src/root/useOverlaySurfaceRenderAck.ts","../src/root/useOverlayLink.ts"],"sourcesContent":["// @ai-matrx/summon/root — the light React half: `<SummonRoot>` (store + host settings, nothing\n// heavy), the store hooks, the dispatchers and the instance context (`defineOverlay` is\n// `@ai-matrx/summon/define`). Importing it never loads a slice, the host, a window or the handles registry.\nexport { SummonRoot, type SummonRootProps } from \"./root/SummonRoot\";\nexport { SummonStoreContext, SummonPortsContext } from \"./root/context\";\nexport {\n configureSummonHost,\n getSummonHostConfig,\n getSummonHostPorts,\n getSummonHostVersion,\n type SummonHostConfig,\n type SummonHostWindows,\n type OverlayRenderContext,\n type OverlayErrorExtrasContext,\n} from \"./root/host\";\nexport {\n useSummonSelector,\n useSummonDispatch,\n useSummonStore,\n useSummonPorts,\n useOptionalSummonPorts,\n useOptionalSummonStore,\n type SummonReactDispatch,\n type SummonReactStore,\n} from \"./root/storeHooks\";\n// `defineOverlay` itself ships in `@ai-matrx/summon/define`: definitions are read only by a host's\n// lazy registry, and a bundler keeps every export of a module that anything uses — in this entry it\n// rode into every route's first load (W4 2026-10-17). The types stay here (erased at build).\nexport type {\n OverlayDefinition,\n OverlaySpec,\n HostableOverlay,\n OverlayHandle,\n OverlayOpener,\n OverlayOpenOptions,\n OverlayControllerProps,\n OverlayEmitter,\n OverlayEventMap,\n OverlayHandlers,\n} from \"./define/defineOverlay\";\nexport { newInstanceId, dispatchOpen, dispatchClose } from \"./root/dispatchers\";\nexport { OverlayInstanceContext, useOverlayInstance, useOptionalOverlayInstance, type OverlayInstanceContextValue } from \"./root/instance\";\nexport { registerOverlayEmitter, emitOverlayEventLight } from \"./root/emit\";\n// Hooks a render module calls inside a window, light enough for any boot graph (one identity:\n// `./window-host`, `./window`, `./react` and `./url` re-export these).\nexport { usePopout, PopoutContext, type PopoutContextValue, type PopoutMode } from \"./root/PopoutContext\";\nexport { usePopoutContainer } from \"./root/usePopoutContainer\";\nexport { useOverlaySurfaceRenderAck } from \"./root/useOverlaySurfaceRenderAck\";\nexport { useOverlayLink } from \"./root/useOverlayLink\";\n","// `<SummonRoot>` — the only summon component a host mounts at its root, and it does next to\n// nothing: it hands the host's store to the summon context (so every opener works at once) and\n// records the host's settings. Nothing heavy loads here. The host's runtime component (tray sync,\n// router bridge — whatever only matters once windows exist) is fetched and mounted the moment the\n// summon core installs: on the first open, a page's own WindowPanel, a link, or saved windows.\n\nimport { lazy, Suspense, useEffect, useState, useSyncExternalStore, type ComponentType, type ReactNode } from \"react\";\nimport { Provider } from \"react-redux\";\nimport type { Store } from \"@reduxjs/toolkit\";\nimport { isSummonInstalled, subscribeSummonInstalled } from \"@ai-matrx/summon/open\";\nimport { SummonStoreContext } from \"./context\";\nimport { configureSummonHost, type SummonHostConfig } from \"./host\";\n\nexport interface SummonRootProps extends SummonHostConfig {\n /** The host store, with the gate (`createSummonGate`) in its middleware chain. */\n readonly store: Store<unknown>;\n /** Mounted once the summon core is installed; one import() of the host's whole runtime set. */\n readonly runtime?: () => Promise<{ default: ComponentType }>;\n readonly children?: ReactNode;\n}\n\nconst serverSnapshot = () => false;\n\nexport function SummonRoot({ store, runtime, children, ports, renderWrapper, errorReportExtras, windows }: SummonRootProps) {\n // Settings are recorded before the first child renders (a page's WindowPanel may read them).\n const [config] = useState<SummonHostConfig>(() => {\n const initial = { ports, renderWrapper, errorReportExtras, windows };\n configureSummonHost(initial);\n return initial;\n });\n useEffect(() => {\n if (config.ports === ports && config.renderWrapper === renderWrapper && config.errorReportExtras === errorReportExtras && config.windows === windows) return;\n configureSummonHost({ ports, renderWrapper, errorReportExtras, windows });\n }, [config, ports, renderWrapper, errorReportExtras, windows]);\n\n const installed = useSyncExternalStore(subscribeSummonInstalled, isSummonInstalled, serverSnapshot);\n const [Runtime] = useState(() => (runtime ? lazy(runtime) : null));\n\n return (\n <Provider store={store} context={SummonStoreContext}>\n {children}\n {installed && Runtime ? (\n <Suspense fallback={null}>\n <Runtime />\n </Suspense>\n ) : null}\n </Provider>\n );\n}\n","// The contexts every summon section reads, light enough for the root: the overlays store rides\n// its OWN react-redux context (chat-package pattern), so a private overlays store never collides\n// with a host's store and a host that hands its one store to `<SummonRoot>` simply passes it in.\nimport { createContext } from \"react\";\nimport type { ReactReduxContextValue } from \"react-redux\";\nimport type { SummonPorts } from \"@ai-matrx/summon/open\";\n\nexport const SummonStoreContext = createContext<ReactReduxContextValue | null>(null);\nSummonStoreContext.displayName = \"SummonStoreContext\";\n\nexport const SummonPortsContext = createContext<SummonPorts | null>(null);\nSummonPortsContext.displayName = \"SummonPortsContext\";\n","// The host's settings, configured ONCE at the root (`<SummonRoot>`) and read wherever a provider\n// is absent: a WindowPanel rendered by a page, the lazily loaded host, links and persistence. A\n// heavy `<SummonProvider>` still overrides them for its subtree (a package's own bare host).\nimport { globalSlot } from \"@ai-matrx/kit/global-slot\";\nimport { resolvePorts, type SummonPorts } from \"@ai-matrx/summon/open\";\nimport type { ComponentType, ReactNode } from \"react\";\n\n/** One rendered overlay instance, as the host wrapper and error extras see it. */\nexport interface OverlayRenderContext {\n readonly overlayId: string;\n readonly instanceId: string;\n readonly instanceKey: string;\n readonly label: string;\n}\n\nexport interface OverlayErrorExtrasContext extends OverlayRenderContext {\n readonly error: unknown;\n readonly componentStack: string | null;\n}\n\nexport interface SummonHostWindows {\n readonly escapeYieldSelector?: string | undefined;\n readonly mobileTopOffset?: string | undefined;\n readonly selectionSurface?: ComponentType<{ readonly children: ReactNode }> | undefined;\n}\n\nexport interface SummonHostConfig {\n readonly ports?: Partial<SummonPorts> | undefined;\n /** Wrap every rendered overlay (AI Matrx: its surface layer boundary). */\n readonly renderWrapper?: ((node: ReactNode, context: OverlayRenderContext) => ReactNode) | undefined;\n /** Extra controls in the default error card's footer (AI Matrx: \"Copy for AI\"). */\n readonly errorReportExtras?: ((context: OverlayErrorExtrasContext) => ReactNode) | undefined;\n /** Window host options (the window section reads them when no WindowsProvider is above). */\n readonly windows?: SummonHostWindows | undefined;\n}\n\ninterface HostSlot {\n config: SummonHostConfig;\n ports: SummonPorts | null;\n version: number;\n}\n\nconst slot = (): HostSlot => globalSlot<HostSlot>(\"ai-matrx.summon.host\", () => ({ config: {}, ports: null, version: 0 }));\n\nexport function configureSummonHost(config: SummonHostConfig): void {\n const s = slot();\n if (s.config === config) return;\n s.config = config;\n s.ports = null;\n s.version += 1;\n}\n\nexport function getSummonHostConfig(): SummonHostConfig {\n return slot().config;\n}\n\n/** The configured ports, resolved over the working defaults (stable until reconfigured). */\nexport function getSummonHostPorts(): SummonPorts {\n const s = slot();\n return (s.ports ??= resolvePorts(s.config.ports));\n}\n\n/** Bumps on every reconfigure; memo keys for values derived from the host config. */\nexport function getSummonHostVersion(): number {\n return slot().version;\n}\n","// Typed hooks over the package's own store context. Every package component reads the overlays\n// store through these, never react-redux's default context, so a host's own <Provider> and the\n// overlays store never collide.\n\nimport { useContext } from \"react\";\nimport {\n createDispatchHook,\n createSelectorHook,\n createStoreHook,\n type UseDispatch,\n type UseSelector,\n type UseStore,\n} from \"react-redux\";\nimport type { Dispatch, Store, UnknownAction } from \"@reduxjs/toolkit\";\nimport type { SummonRootState } from \"@ai-matrx/summon\";\nimport type { SummonPorts } from \"@ai-matrx/summon/open\";\nimport { SummonPortsContext, SummonStoreContext } from \"./context\";\nimport { getSummonHostPorts } from \"./host\";\n\n/** Dispatch as the React section uses it: plain actions (thunks are the host's business). */\nexport type SummonReactDispatch = Dispatch<UnknownAction>;\n\n/** The store as the React section sees it: the overlays slices at their root keys (a host store has more). */\nexport type SummonReactStore = Store<SummonRootState>;\n\n/** Select from the overlays store. */\nexport const useSummonSelector: UseSelector<SummonRootState> = createSelectorHook(SummonStoreContext).withTypes<SummonRootState>();\n\n/** The overlays store's dispatch. */\nexport const useSummonDispatch: UseDispatch<SummonReactDispatch> = createDispatchHook(SummonStoreContext).withTypes<SummonReactDispatch>();\n\n/** The overlays store itself (for `getState()` inside callbacks). */\nexport const useSummonStore: UseStore<SummonReactStore> = createStoreHook(SummonStoreContext).withTypes<SummonReactStore>();\n\n/** The nearest provider's ports, else the ports configured at the root, else the working defaults. */\nexport function useSummonPorts(): SummonPorts {\n return useContext(SummonPortsContext) ?? getSummonHostPorts();\n}\n\n/** Same as `useSummonPorts` (kept for components written to work page-local). */\nexport function useOptionalSummonPorts(): SummonPorts {\n return useContext(SummonPortsContext) ?? getSummonHostPorts();\n}\n\n/**\n * The nearest provider's store, or `null` when nothing above provides one — for packages that\n * mount their own provider only when the host has none (chat's windows on a bare host).\n */\nexport function useOptionalSummonStore(): SummonReactStore | null {\n const context = useContext(SummonStoreContext);\n return context ? (context.store as unknown as SummonReactStore) : null;\n}\n","// The one place a definition turns an untyped (string) overlay id into the typed action creators.\n// Inside the package `OverlayId` is `string`; a host that augments the registry narrows it to its\n// ids, and these keep compiling there because definitions carry their own id.\n\nimport { closeOverlay, openOverlay, DEFAULT_INSTANCE_ID, type OverlayDataOf, type OverlayId } from \"@ai-matrx/summon/open\";\nimport type { SummonReactDispatch } from \"./storeHooks\";\n\nexport function newInstanceId(overlayId: string): string {\n return `${overlayId}-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;\n}\n\nexport function dispatchOpen(dispatch: SummonReactDispatch, overlayId: string, instanceId: string, data: unknown): void {\n dispatch(\n openOverlay({\n overlayId: overlayId as OverlayId,\n instanceId,\n data: (data ?? null) as OverlayDataOf<OverlayId> | null,\n }),\n );\n}\n\nexport function dispatchClose(dispatch: SummonReactDispatch, overlayId: string, instanceId: string = DEFAULT_INSTANCE_ID): void {\n dispatch(closeOverlay({ overlayId: overlayId as OverlayId, instanceId }));\n}\n","// The context every rendered overlay instance provides to its subtree, and the hooks that read who\n// it is. Light: a definition's `useEmit` reads it; the saved-state hook stays in `./react`.\nimport { createContext, useContext } from \"react\";\nimport type { InstanceKey, OverlayRawData } from \"@ai-matrx/summon/open\";\n\nexport interface OverlayInstanceContextValue {\n readonly overlayId: string;\n readonly instanceId: string;\n readonly instanceKey: InstanceKey;\n readonly close: () => void;\n readonly hidden: boolean;\n /** The open data as it arrived (pre-parse); event emitters read their channel id from it. */\n readonly rawData: OverlayRawData;\n}\n\nexport const OverlayInstanceContext = createContext<OverlayInstanceContextValue | null>(null);\nOverlayInstanceContext.displayName = \"OverlayInstanceContext\";\n\n/** The open instance this component renders inside. Throws outside an overlay. */\nexport function useOverlayInstance(): OverlayInstanceContextValue {\n const value = useContext(OverlayInstanceContext);\n if (!value) throw new Error(\"[summon] useOverlayInstance() was called outside a rendered overlay.\");\n return value;\n}\n\n/** Same as `useOverlayInstance`, but `null` outside an overlay. */\nexport function useOptionalOverlayInstance(): OverlayInstanceContextValue | null {\n return useContext(OverlayInstanceContext);\n}\n","// Emitting an overlay event from inside its render tree. The render tree has the handles registry\n// loaded (the react section registers its synchronous emitter on evaluation); before that, the\n// emit waits for the one handles import.\nimport { globalSlot } from \"@ai-matrx/kit/global-slot\";\nimport { materializePendingChannels } from \"@ai-matrx/summon/open\";\n\ntype Emitter = (channelId: string, type: string, payload: unknown) => void;\n\nconst slot = (): { emit: Emitter | null } => globalSlot(\"ai-matrx.summon.emitter\", () => ({ emit: null as Emitter | null }));\n\n/** The react section installs the synchronous emitter (it holds handles statically). */\nexport function registerOverlayEmitter(emit: Emitter): void {\n slot().emit = emit;\n}\n\nexport function emitOverlayEventLight(channelId: string, type: string, payload: unknown): void {\n const emit = slot().emit;\n if (emit) {\n emit(channelId, type, payload);\n return;\n }\n void import(\"@ai-matrx/summon/handles\").then(({ createEventChannel, getEventChannel }) => {\n materializePendingChannels(createEventChannel);\n getEventChannel<{ type: string; payload: unknown }>(channelId)?.emit({ type, payload });\n });\n}\n","\"use client\";\n\n/**\n * PopoutContext — exposes the popout `Document` / `Window` / portal target\n * to descendants of a popped-out subtree.\n *\n * The default value (`popoutDocument: null`, etc.) means \"I'm rendered in\n * the parent document.\" Descendants that need to behave differently inside\n * a popout (e.g. Radix portals retargeting their content) call\n * `usePopout()` and branch on the values.\n *\n * **Architectural note:** because `createPortal` preserves the parent\n * React tree, every ancestor `Provider` cascades into the popout — Redux,\n * Theme, Tooltip, Router, all work without re-wrapping. This context is\n * for the *opposite* direction: telling popped-out content \"you're inside\n * a popout window, here's the document/window/container you should use\n * instead of the global `document`/`window`.\"\n */\nimport { createContext, useContext } from \"react\";\n\nexport type PopoutMode = \"pip\" | \"popup\";\n\nexport interface PopoutContextValue {\n /**\n * The popout `Document`. `null` when this subtree is rendered in the\n * parent (the default).\n */\n popoutDocument: Document | null;\n /**\n * The popout `Window`. `null` when this subtree is rendered in the parent.\n * Use for `addEventListener`, `matchMedia`, `innerWidth`, etc., when the\n * popout-scoped answer is what you need.\n */\n popoutWindow: Window | null;\n /**\n * Element to use as the Radix `Portal.container` prop so floating UI\n * (tooltips, popovers, dropdowns) renders inside the popout instead of\n * the parent `document.body`. Returns `null` outside a popout —\n * `usePopoutContainer` coerces this to `undefined` so Radix falls back\n * to its default container automatically.\n */\n popoutContainer: HTMLElement | null;\n /**\n * Which popout mechanism is in use. `null` outside a popout.\n * Currently only used for diagnostics; downstream components may branch\n * on it later (e.g. show different chrome for `popup` vs `pip`).\n */\n mode: PopoutMode | null;\n}\n\nconst DEFAULT_VALUE: PopoutContextValue = {\n popoutDocument: null,\n popoutWindow: null,\n popoutContainer: null,\n mode: null,\n};\n\nexport const PopoutContext =\n createContext<PopoutContextValue>(DEFAULT_VALUE);\n\n/** Read the current popout context. Always defined — never throws. */\nexport function usePopout(): PopoutContextValue {\n return useContext(PopoutContext);\n}\n","\"use client\";\n\n/**\n * usePopoutContainer — return the element Radix portals (Tooltip, Popover,\n * Dropdown, Dialog, Select, AlertDialog, HoverCard) should mount into.\n *\n * **The problem this solves:** by default every Radix `Portal` mounts to\n * `document.body`. When a tooltip-trigger lives inside a popped-out window\n * but the popover content portals to the *parent* document, the tooltip\n * appears in the wrong window — typically invisible to the user.\n *\n * **The fix:** wrappers around Radix primitives call this hook and pass\n * the result as `<Primitive.Portal container={...} />`. Inside a popout,\n * the result is the popout's `<body>`. Outside a popout, the result is\n * `undefined`, which Radix interprets as \"use the default\" — meaning no\n * behavior change for any of the thousands of existing usages.\n *\n * **Why `undefined` instead of `null`?** Radix's `container` prop accepts\n * `HTMLElement | null | undefined`. Passing `null` actively tries to\n * portal into a `null` target and crashes. Passing `undefined` falls\n * through to the default (`document.body`). The `?? undefined` coerces\n * the `null` we get from `PopoutContext` outside a popout into the\n * Radix-friendly default-fallthrough value.\n */\nimport { usePopout } from \"./PopoutContext\";\n\nexport function usePopoutContainer(): HTMLElement | undefined {\n return usePopout().popoutContainer ?? undefined;\n}\n","\"use client\";\n\nimport { useEffect } from \"react\";\nimport { ackOverlaySurfaceRender, clearOverlaySurfaceRender } from \"@ai-matrx/summon/open\";\n\n/**\n * Acknowledge a visible presentation that intentionally replaces WindowPanel.\n *\n * Registered singleton window overlays normally prove they are on screen by mounting a\n * WindowPanel and registering geometry. Mobile drawers, sheets, and full-screen\n * viewers have no window-manager geometry, so their composition root must use\n * this hook while that alternate surface is active.\n */\nexport function useOverlaySurfaceRenderAck(\n overlayId: string,\n active: boolean,\n): void {\n useEffect(() => {\n if (!active) return undefined;\n ackOverlaySurfaceRender(overlayId);\n return () => clearOverlaySurfaceRender(overlayId);\n }, [active, overlayId]);\n}\n","import { useEffect, useMemo } from \"react\";\nimport { registerSyncEntry, unregisterSyncEntry } from \"@ai-matrx/summon/open\";\nimport { useSummonDispatch } from \"./storeHooks\";\n\n/**\n * Publish an open instance's address into `?panels=` while it is mounted. `linkKey` undefined →\n * nothing is published (a window with no link); so is an undefined or empty `id`. The token is `linkKey:id[:args]`; args are\n * compared by value, so a new object with equal contents never re-registers.\n */\nexport function useOverlayLink(linkKey: string | undefined, id: string | undefined, args?: Readonly<Record<string, string>>): void {\n const dispatch = useSummonDispatch();\n const argsKey = args\n ? JSON.stringify(\n Object.keys(args)\n .sort()\n .map((k) => [k, args[k]]),\n )\n : \"\";\n // Rebuilt only when the VALUES change (argsKey), never on a fresh object with equal contents.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const stableArgs = useMemo(() => (args ? { ...args } : undefined), [argsKey]);\n\n useEffect(() => {\n if (!linkKey || !id) return undefined;\n dispatch(registerSyncEntry(stableArgs ? { typeKey: linkKey, instanceId: id, args: stableArgs } : { typeKey: linkKey, instanceId: id }));\n return () => {\n dispatch(unregisterSyncEntry({ typeKey: linkKey, instanceId: id }));\n };\n }, [dispatch, linkKey, id, stableArgs]);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACMA,IAAAA,gBAA8G;AAC9G,yBAAyB;AAEzB,IAAAC,eAA4D;;;ACN5D,mBAA8B;AAIvB,IAAM,yBAAqB,4BAA6C,IAAI;AACnF,mBAAmB,cAAc;AAE1B,IAAM,yBAAqB,4BAAkC,IAAI;AAC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,OAAO,EAAE,GAAG,KAAK,IAAI,QAAY,CAAC,OAAO,CAAC;AAE5E,+BAAU,MAAM;AACd,QAAI,CAAC,WAAW,CAAC,GAAI,QAAO;AAC5B,iBAAS,gCAAkB,aAAa,EAAE,SAAS,SAAS,YAAY,IAAI,MAAM,WAAW,IAAI,EAAE,SAAS,SAAS,YAAY,GAAG,CAAC,CAAC;AACtI,WAAO,MAAM;AACX,mBAAS,kCAAoB,EAAE,SAAS,SAAS,YAAY,GAAG,CAAC,CAAC;AAAA,IACpE;AAAA,EACF,GAAG,CAAC,UAAU,SAAS,IAAI,UAAU,CAAC;AACxC;","names":["import_react","import_open","import_react","import_react_redux","import_open","import_react","import_global_slot","import_open","slot","import_react","import_react","import_open","import_react","import_open"]}
|
package/dist/root.d.cts
CHANGED
|
@@ -2,10 +2,11 @@ import * as react from 'react';
|
|
|
2
2
|
import { ReactNode, ComponentType } from 'react';
|
|
3
3
|
import * as _reduxjs_toolkit from '@reduxjs/toolkit';
|
|
4
4
|
import { Store, Dispatch, UnknownAction } from '@reduxjs/toolkit';
|
|
5
|
-
import { SummonPorts,
|
|
5
|
+
import { SummonPorts, InstanceKey, OverlayRawData } from '@ai-matrx/summon/open';
|
|
6
6
|
import { ReactReduxContextValue, UseDispatch, UseSelector, UseStore } from 'react-redux';
|
|
7
7
|
import { SummonRootState } from '@ai-matrx/summon';
|
|
8
|
-
|
|
8
|
+
export { HostableOverlay, OverlayControllerProps, OverlayDefinition, OverlayEmitter, OverlayEventMap, OverlayHandle, OverlayHandlers, OverlayOpenOptions, OverlayOpener, OverlaySpec } from './define.cjs';
|
|
9
|
+
import './instanceBody-CgZAFnic.cjs';
|
|
9
10
|
|
|
10
11
|
/** One rendered overlay instance, as the host wrapper and error extras see it. */
|
|
11
12
|
interface OverlayRenderContext {
|
|
@@ -75,79 +76,6 @@ declare function useOptionalSummonPorts(): SummonPorts;
|
|
|
75
76
|
*/
|
|
76
77
|
declare function useOptionalSummonStore(): SummonReactStore | null;
|
|
77
78
|
|
|
78
|
-
/** Event name → payload, declared once per overlay: `defineOverlay<Data, { uploaded: Result }>()`. */
|
|
79
|
-
type OverlayEventMap = Record<string, unknown>;
|
|
80
|
-
type OverlayHandlers<Events extends OverlayEventMap> = {
|
|
81
|
-
readonly [K in keyof Events]?: (payload: Events[K]) => void;
|
|
82
|
-
};
|
|
83
|
-
/** The open-data key that carries an overlay's event channel id (the old callback-group key). */
|
|
84
|
-
declare const CALLBACK_GROUP_KEY = "callbackGroupId";
|
|
85
|
-
interface OverlayHandle {
|
|
86
|
-
readonly overlayId: string;
|
|
87
|
-
readonly instanceId: string;
|
|
88
|
-
close(): void;
|
|
89
|
-
}
|
|
90
|
-
interface OverlayOpenOptions<Data, Events extends OverlayEventMap> {
|
|
91
|
-
readonly data?: Data;
|
|
92
|
-
/** Single-instance overlays ignore it unless given; multi-instance generate one when omitted. */
|
|
93
|
-
readonly instanceId?: string;
|
|
94
|
-
/** Plain functions; they reach the caller through an event channel owned by the instance. */
|
|
95
|
-
readonly handlers?: OverlayHandlers<Events>;
|
|
96
|
-
}
|
|
97
|
-
type OverlayOpener<Data, Events extends OverlayEventMap> = (options?: OverlayOpenOptions<Data, Events>) => OverlayHandle;
|
|
98
|
-
type OverlayControllerProps<Data, Events extends OverlayEventMap> = Data & {
|
|
99
|
-
readonly instanceId?: string;
|
|
100
|
-
readonly handlers?: OverlayHandlers<Events>;
|
|
101
|
-
};
|
|
102
|
-
type OverlayEmitter<Events extends OverlayEventMap> = <K extends keyof Events & string>(event: K, payload: Events[K]) => void;
|
|
103
|
-
/** What a definition file passes to `defineOverlay<Data>()(…)`. */
|
|
104
|
-
interface OverlaySpec<Id extends string, Data, Parsed> extends OverlayDefinitionMeta<Id, Data> {
|
|
105
|
-
/**
|
|
106
|
-
* The lazily loaded render module. Its default export receives `OverlayRenderProps<Parsed>`.
|
|
107
|
-
* Optional: a large app leaves it out and hands `<SummonHost renders={…}>` one id → import map,
|
|
108
|
-
* so files that import a definition for its opener never gain an import() edge to the window
|
|
109
|
-
* (the host-build law). When present it wins over the host map.
|
|
110
|
-
*/
|
|
111
|
-
readonly render?: () => Promise<RenderModule<OverlayRenderProps<NoInfer<Parsed>>>>;
|
|
112
|
-
/** Narrow raw open data once. `null` = refuse: the instance is closed with a warning. */
|
|
113
|
-
readonly parse?: (raw: OverlayRawData) => Parsed | null;
|
|
114
|
-
}
|
|
115
|
-
/** The type-erased half the host renders; no data types cross this line. */
|
|
116
|
-
interface HostableOverlay {
|
|
117
|
-
readonly id: string;
|
|
118
|
-
readonly label: string;
|
|
119
|
-
readonly instance: "single" | "multi";
|
|
120
|
-
readonly keepAlive: "none" | "hidden" | "restore";
|
|
121
|
-
/** The metadata the core registry stores (links, window options, defaults…). */
|
|
122
|
-
readonly meta: AnyOverlayMeta;
|
|
123
|
-
/** The definition's own render loader (the host's `renders` map is used when absent). */
|
|
124
|
-
readonly render?: (() => Promise<unknown>) | undefined;
|
|
125
|
-
/** Narrows raw open data; the host builds each instance body from it on first render. */
|
|
126
|
-
readonly parse?: ((raw: OverlayRawData) => unknown) | undefined;
|
|
127
|
-
}
|
|
128
|
-
interface OverlayDefinition<Id extends string, Data, Parsed, Events extends OverlayEventMap> extends Omit<OverlayDefinitionMeta<Id, Data>, "id" | "instance" | "keepAlive">, HostableOverlay {
|
|
129
|
-
readonly id: Id;
|
|
130
|
-
readonly render?: () => Promise<RenderModule<OverlayRenderProps<Parsed>>>;
|
|
131
|
-
/** Imperative opener: `const open = def.useSummon(); open({ data })` → handle. */
|
|
132
|
-
useSummon(): OverlayOpener<Data, Events>;
|
|
133
|
-
/** Declarative form: opens on mount, closes on unmount, re-opens when its data changes. */
|
|
134
|
-
readonly Controller: (props: OverlayControllerProps<Data, Events>) => null;
|
|
135
|
-
useIsOpen(instanceId?: string): boolean;
|
|
136
|
-
/** `const close = def.useClose(); close(instanceId?)`. */
|
|
137
|
-
useClose(): (instanceId?: string) => void;
|
|
138
|
-
/** Inside the render tree: emit a declared event to the opener's handlers. */
|
|
139
|
-
useEmit(): OverlayEmitter<Events>;
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Declare an overlay once. Curried so `Data` (and `Events`) are named while the id and the
|
|
143
|
-
* parsed-data type are inferred:
|
|
144
|
-
*
|
|
145
|
-
* export const notesWindow = defineOverlay<NotesWindowData>()({
|
|
146
|
-
* id: "notesWindow", label: "Notes", render: () => import("./notesWindow.render"),
|
|
147
|
-
* });
|
|
148
|
-
*/
|
|
149
|
-
declare function defineOverlay<Data extends object = Record<string, never>, Events extends OverlayEventMap = Record<never, never>>(): <const Id extends string, Parsed = OverlayRawData>(spec: OverlaySpec<Id, Data, Parsed>) => OverlayDefinition<Id, Data, Parsed, Events>;
|
|
150
|
-
|
|
151
79
|
declare function newInstanceId(overlayId: string): string;
|
|
152
80
|
declare function dispatchOpen(dispatch: SummonReactDispatch, overlayId: string, instanceId: string, data: unknown): void;
|
|
153
81
|
declare function dispatchClose(dispatch: SummonReactDispatch, overlayId: string, instanceId?: string): void;
|
|
@@ -223,4 +151,4 @@ declare function useOverlaySurfaceRenderAck(overlayId: string, active: boolean):
|
|
|
223
151
|
*/
|
|
224
152
|
declare function useOverlayLink(linkKey: string | undefined, id: string | undefined, args?: Readonly<Record<string, string>>): void;
|
|
225
153
|
|
|
226
|
-
export {
|
|
154
|
+
export { type OverlayErrorExtrasContext, OverlayInstanceContext, type OverlayInstanceContextValue, type OverlayRenderContext, PopoutContext, type PopoutContextValue, type PopoutMode, type SummonHostConfig, type SummonHostWindows, SummonPortsContext, type SummonReactDispatch, type SummonReactStore, SummonRoot, type SummonRootProps, SummonStoreContext, configureSummonHost, dispatchClose, dispatchOpen, emitOverlayEventLight, getSummonHostConfig, getSummonHostPorts, getSummonHostVersion, newInstanceId, registerOverlayEmitter, useOptionalOverlayInstance, useOptionalSummonPorts, useOptionalSummonStore, useOverlayInstance, useOverlayLink, useOverlaySurfaceRenderAck, usePopout, usePopoutContainer, useSummonDispatch, useSummonPorts, useSummonSelector, useSummonStore };
|
package/dist/root.d.ts
CHANGED
|
@@ -2,10 +2,11 @@ import * as react from 'react';
|
|
|
2
2
|
import { ReactNode, ComponentType } from 'react';
|
|
3
3
|
import * as _reduxjs_toolkit from '@reduxjs/toolkit';
|
|
4
4
|
import { Store, Dispatch, UnknownAction } from '@reduxjs/toolkit';
|
|
5
|
-
import { SummonPorts,
|
|
5
|
+
import { SummonPorts, InstanceKey, OverlayRawData } from '@ai-matrx/summon/open';
|
|
6
6
|
import { ReactReduxContextValue, UseDispatch, UseSelector, UseStore } from 'react-redux';
|
|
7
7
|
import { SummonRootState } from '@ai-matrx/summon';
|
|
8
|
-
|
|
8
|
+
export { HostableOverlay, OverlayControllerProps, OverlayDefinition, OverlayEmitter, OverlayEventMap, OverlayHandle, OverlayHandlers, OverlayOpenOptions, OverlayOpener, OverlaySpec } from './define.js';
|
|
9
|
+
import './instanceBody-CgZAFnic.js';
|
|
9
10
|
|
|
10
11
|
/** One rendered overlay instance, as the host wrapper and error extras see it. */
|
|
11
12
|
interface OverlayRenderContext {
|
|
@@ -75,79 +76,6 @@ declare function useOptionalSummonPorts(): SummonPorts;
|
|
|
75
76
|
*/
|
|
76
77
|
declare function useOptionalSummonStore(): SummonReactStore | null;
|
|
77
78
|
|
|
78
|
-
/** Event name → payload, declared once per overlay: `defineOverlay<Data, { uploaded: Result }>()`. */
|
|
79
|
-
type OverlayEventMap = Record<string, unknown>;
|
|
80
|
-
type OverlayHandlers<Events extends OverlayEventMap> = {
|
|
81
|
-
readonly [K in keyof Events]?: (payload: Events[K]) => void;
|
|
82
|
-
};
|
|
83
|
-
/** The open-data key that carries an overlay's event channel id (the old callback-group key). */
|
|
84
|
-
declare const CALLBACK_GROUP_KEY = "callbackGroupId";
|
|
85
|
-
interface OverlayHandle {
|
|
86
|
-
readonly overlayId: string;
|
|
87
|
-
readonly instanceId: string;
|
|
88
|
-
close(): void;
|
|
89
|
-
}
|
|
90
|
-
interface OverlayOpenOptions<Data, Events extends OverlayEventMap> {
|
|
91
|
-
readonly data?: Data;
|
|
92
|
-
/** Single-instance overlays ignore it unless given; multi-instance generate one when omitted. */
|
|
93
|
-
readonly instanceId?: string;
|
|
94
|
-
/** Plain functions; they reach the caller through an event channel owned by the instance. */
|
|
95
|
-
readonly handlers?: OverlayHandlers<Events>;
|
|
96
|
-
}
|
|
97
|
-
type OverlayOpener<Data, Events extends OverlayEventMap> = (options?: OverlayOpenOptions<Data, Events>) => OverlayHandle;
|
|
98
|
-
type OverlayControllerProps<Data, Events extends OverlayEventMap> = Data & {
|
|
99
|
-
readonly instanceId?: string;
|
|
100
|
-
readonly handlers?: OverlayHandlers<Events>;
|
|
101
|
-
};
|
|
102
|
-
type OverlayEmitter<Events extends OverlayEventMap> = <K extends keyof Events & string>(event: K, payload: Events[K]) => void;
|
|
103
|
-
/** What a definition file passes to `defineOverlay<Data>()(…)`. */
|
|
104
|
-
interface OverlaySpec<Id extends string, Data, Parsed> extends OverlayDefinitionMeta<Id, Data> {
|
|
105
|
-
/**
|
|
106
|
-
* The lazily loaded render module. Its default export receives `OverlayRenderProps<Parsed>`.
|
|
107
|
-
* Optional: a large app leaves it out and hands `<SummonHost renders={…}>` one id → import map,
|
|
108
|
-
* so files that import a definition for its opener never gain an import() edge to the window
|
|
109
|
-
* (the host-build law). When present it wins over the host map.
|
|
110
|
-
*/
|
|
111
|
-
readonly render?: () => Promise<RenderModule<OverlayRenderProps<NoInfer<Parsed>>>>;
|
|
112
|
-
/** Narrow raw open data once. `null` = refuse: the instance is closed with a warning. */
|
|
113
|
-
readonly parse?: (raw: OverlayRawData) => Parsed | null;
|
|
114
|
-
}
|
|
115
|
-
/** The type-erased half the host renders; no data types cross this line. */
|
|
116
|
-
interface HostableOverlay {
|
|
117
|
-
readonly id: string;
|
|
118
|
-
readonly label: string;
|
|
119
|
-
readonly instance: "single" | "multi";
|
|
120
|
-
readonly keepAlive: "none" | "hidden" | "restore";
|
|
121
|
-
/** The metadata the core registry stores (links, window options, defaults…). */
|
|
122
|
-
readonly meta: AnyOverlayMeta;
|
|
123
|
-
/** The definition's own render loader (the host's `renders` map is used when absent). */
|
|
124
|
-
readonly render?: (() => Promise<unknown>) | undefined;
|
|
125
|
-
/** Narrows raw open data; the host builds each instance body from it on first render. */
|
|
126
|
-
readonly parse?: ((raw: OverlayRawData) => unknown) | undefined;
|
|
127
|
-
}
|
|
128
|
-
interface OverlayDefinition<Id extends string, Data, Parsed, Events extends OverlayEventMap> extends Omit<OverlayDefinitionMeta<Id, Data>, "id" | "instance" | "keepAlive">, HostableOverlay {
|
|
129
|
-
readonly id: Id;
|
|
130
|
-
readonly render?: () => Promise<RenderModule<OverlayRenderProps<Parsed>>>;
|
|
131
|
-
/** Imperative opener: `const open = def.useSummon(); open({ data })` → handle. */
|
|
132
|
-
useSummon(): OverlayOpener<Data, Events>;
|
|
133
|
-
/** Declarative form: opens on mount, closes on unmount, re-opens when its data changes. */
|
|
134
|
-
readonly Controller: (props: OverlayControllerProps<Data, Events>) => null;
|
|
135
|
-
useIsOpen(instanceId?: string): boolean;
|
|
136
|
-
/** `const close = def.useClose(); close(instanceId?)`. */
|
|
137
|
-
useClose(): (instanceId?: string) => void;
|
|
138
|
-
/** Inside the render tree: emit a declared event to the opener's handlers. */
|
|
139
|
-
useEmit(): OverlayEmitter<Events>;
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Declare an overlay once. Curried so `Data` (and `Events`) are named while the id and the
|
|
143
|
-
* parsed-data type are inferred:
|
|
144
|
-
*
|
|
145
|
-
* export const notesWindow = defineOverlay<NotesWindowData>()({
|
|
146
|
-
* id: "notesWindow", label: "Notes", render: () => import("./notesWindow.render"),
|
|
147
|
-
* });
|
|
148
|
-
*/
|
|
149
|
-
declare function defineOverlay<Data extends object = Record<string, never>, Events extends OverlayEventMap = Record<never, never>>(): <const Id extends string, Parsed = OverlayRawData>(spec: OverlaySpec<Id, Data, Parsed>) => OverlayDefinition<Id, Data, Parsed, Events>;
|
|
150
|
-
|
|
151
79
|
declare function newInstanceId(overlayId: string): string;
|
|
152
80
|
declare function dispatchOpen(dispatch: SummonReactDispatch, overlayId: string, instanceId: string, data: unknown): void;
|
|
153
81
|
declare function dispatchClose(dispatch: SummonReactDispatch, overlayId: string, instanceId?: string): void;
|
|
@@ -223,4 +151,4 @@ declare function useOverlaySurfaceRenderAck(overlayId: string, active: boolean):
|
|
|
223
151
|
*/
|
|
224
152
|
declare function useOverlayLink(linkKey: string | undefined, id: string | undefined, args?: Readonly<Record<string, string>>): void;
|
|
225
153
|
|
|
226
|
-
export {
|
|
154
|
+
export { type OverlayErrorExtrasContext, OverlayInstanceContext, type OverlayInstanceContextValue, type OverlayRenderContext, PopoutContext, type PopoutContextValue, type PopoutMode, type SummonHostConfig, type SummonHostWindows, SummonPortsContext, type SummonReactDispatch, type SummonReactStore, SummonRoot, type SummonRootProps, SummonStoreContext, configureSummonHost, dispatchClose, dispatchOpen, emitOverlayEventLight, getSummonHostConfig, getSummonHostPorts, getSummonHostVersion, newInstanceId, registerOverlayEmitter, useOptionalOverlayInstance, useOptionalSummonPorts, useOptionalSummonStore, useOverlayInstance, useOverlayLink, useOverlaySurfaceRenderAck, usePopout, usePopoutContainer, useSummonDispatch, useSummonPorts, useSummonSelector, useSummonStore };
|
package/dist/root.js
CHANGED
|
@@ -76,15 +76,6 @@ function useOptionalSummonStore() {
|
|
|
76
76
|
return context ? context.store : null;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
// src/root/defineOverlay.tsx
|
|
80
|
-
import { useCallback, useEffect as useEffect2, useMemo, useRef, useState as useState2 } from "react";
|
|
81
|
-
import {
|
|
82
|
-
DEFAULT_INSTANCE_ID as DEFAULT_INSTANCE_ID2,
|
|
83
|
-
instanceKey as toInstanceKey,
|
|
84
|
-
openPendingEventChannel,
|
|
85
|
-
selectIsOverlayOpen
|
|
86
|
-
} from "@ai-matrx/summon/open";
|
|
87
|
-
|
|
88
79
|
// src/root/dispatchers.ts
|
|
89
80
|
import { closeOverlay, openOverlay, DEFAULT_INSTANCE_ID } from "@ai-matrx/summon/open";
|
|
90
81
|
function newInstanceId(overlayId) {
|
|
@@ -103,6 +94,19 @@ function dispatchClose(dispatch, overlayId, instanceId = DEFAULT_INSTANCE_ID) {
|
|
|
103
94
|
dispatch(closeOverlay({ overlayId, instanceId }));
|
|
104
95
|
}
|
|
105
96
|
|
|
97
|
+
// src/root/instance.ts
|
|
98
|
+
import { createContext as createContext2, useContext as useContext2 } from "react";
|
|
99
|
+
var OverlayInstanceContext = createContext2(null);
|
|
100
|
+
OverlayInstanceContext.displayName = "OverlayInstanceContext";
|
|
101
|
+
function useOverlayInstance() {
|
|
102
|
+
const value = useContext2(OverlayInstanceContext);
|
|
103
|
+
if (!value) throw new Error("[summon] useOverlayInstance() was called outside a rendered overlay.");
|
|
104
|
+
return value;
|
|
105
|
+
}
|
|
106
|
+
function useOptionalOverlayInstance() {
|
|
107
|
+
return useContext2(OverlayInstanceContext);
|
|
108
|
+
}
|
|
109
|
+
|
|
106
110
|
// src/root/emit.ts
|
|
107
111
|
import { globalSlot as globalSlot2 } from "@ai-matrx/kit/global-slot";
|
|
108
112
|
import { materializePendingChannels } from "@ai-matrx/summon/open";
|
|
@@ -122,111 +126,6 @@ function emitOverlayEventLight(channelId, type, payload) {
|
|
|
122
126
|
});
|
|
123
127
|
}
|
|
124
128
|
|
|
125
|
-
// src/root/instance.ts
|
|
126
|
-
import { createContext as createContext2, useContext as useContext2 } from "react";
|
|
127
|
-
var OverlayInstanceContext = createContext2(null);
|
|
128
|
-
OverlayInstanceContext.displayName = "OverlayInstanceContext";
|
|
129
|
-
function useOverlayInstance() {
|
|
130
|
-
const value = useContext2(OverlayInstanceContext);
|
|
131
|
-
if (!value) throw new Error("[summon] useOverlayInstance() was called outside a rendered overlay.");
|
|
132
|
-
return value;
|
|
133
|
-
}
|
|
134
|
-
function useOptionalOverlayInstance() {
|
|
135
|
-
return useContext2(OverlayInstanceContext);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// src/root/defineOverlay.tsx
|
|
139
|
-
function openOverlayEventChannel(owner, getHandlers) {
|
|
140
|
-
return openPendingEventChannel(owner, getHandlers);
|
|
141
|
-
}
|
|
142
|
-
var CALLBACK_GROUP_KEY = "callbackGroupId";
|
|
143
|
-
function openWith(dispatch, id, multi, options) {
|
|
144
|
-
const instanceId = options?.instanceId ?? (multi ? newInstanceId(id) : DEFAULT_INSTANCE_ID2);
|
|
145
|
-
const key = toInstanceKey(id, instanceId);
|
|
146
|
-
const data = {};
|
|
147
|
-
const given = options?.data;
|
|
148
|
-
if (typeof given === "object" && given !== null) Object.assign(data, given);
|
|
149
|
-
const handlers = options?.handlers;
|
|
150
|
-
if (handlers) data[CALLBACK_GROUP_KEY] = openOverlayEventChannel(key, () => handlers);
|
|
151
|
-
dispatchOpen(dispatch, id, instanceId, data);
|
|
152
|
-
return { overlayId: id, instanceId, close: () => dispatchClose(dispatch, id, instanceId) };
|
|
153
|
-
}
|
|
154
|
-
function dataSignature(data) {
|
|
155
|
-
try {
|
|
156
|
-
return JSON.stringify(data, (_key, value) => typeof value === "function" ? void 0 : value);
|
|
157
|
-
} catch {
|
|
158
|
-
return String(Date.now());
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
function defineOverlay() {
|
|
162
|
-
return function define(spec) {
|
|
163
|
-
const id = spec.id;
|
|
164
|
-
const multi = spec.instance === "multi";
|
|
165
|
-
const meta = spec;
|
|
166
|
-
function useSummon() {
|
|
167
|
-
const dispatch = useSummonDispatch();
|
|
168
|
-
return useCallback((options) => openWith(dispatch, id, multi, options), [dispatch]);
|
|
169
|
-
}
|
|
170
|
-
function useIsOpen(instanceId = DEFAULT_INSTANCE_ID2) {
|
|
171
|
-
return useSummonSelector((state) => selectIsOverlayOpen(state, id, instanceId));
|
|
172
|
-
}
|
|
173
|
-
function useClose() {
|
|
174
|
-
const dispatch = useSummonDispatch();
|
|
175
|
-
return useCallback((instanceId) => dispatchClose(dispatch, id, instanceId ?? DEFAULT_INSTANCE_ID2), [dispatch]);
|
|
176
|
-
}
|
|
177
|
-
function useEmit() {
|
|
178
|
-
const instance = useOptionalOverlayInstance();
|
|
179
|
-
const channelId = instance?.overlayId === id ? instance.rawData?.[CALLBACK_GROUP_KEY] : void 0;
|
|
180
|
-
return useCallback(
|
|
181
|
-
(event, payload) => {
|
|
182
|
-
if (typeof channelId === "string") emitOverlayEventLight(channelId, event, payload);
|
|
183
|
-
},
|
|
184
|
-
[channelId]
|
|
185
|
-
);
|
|
186
|
-
}
|
|
187
|
-
function Controller(props) {
|
|
188
|
-
const dispatch = useSummonDispatch();
|
|
189
|
-
const [ownInstanceId] = useState2(() => multi ? newInstanceId(id) : DEFAULT_INSTANCE_ID2);
|
|
190
|
-
const instanceId = props.instanceId ?? ownInstanceId;
|
|
191
|
-
const handlersRef = useRef(props.handlers);
|
|
192
|
-
handlersRef.current = props.handlers;
|
|
193
|
-
const hasHandlers = props.handlers !== void 0;
|
|
194
|
-
const data = useMemo(() => {
|
|
195
|
-
const out = {};
|
|
196
|
-
for (const [key, value] of Object.entries(props)) {
|
|
197
|
-
if (key !== "instanceId" && key !== "handlers") out[key] = value;
|
|
198
|
-
}
|
|
199
|
-
return out;
|
|
200
|
-
}, [props]);
|
|
201
|
-
const signature = dataSignature(data);
|
|
202
|
-
const dataRef = useRef(data);
|
|
203
|
-
dataRef.current = data;
|
|
204
|
-
useEffect2(() => {
|
|
205
|
-
const key = toInstanceKey(id, instanceId);
|
|
206
|
-
const open = { ...dataRef.current };
|
|
207
|
-
if (hasHandlers) open[CALLBACK_GROUP_KEY] = openOverlayEventChannel(key, () => handlersRef.current);
|
|
208
|
-
dispatchOpen(dispatch, id, instanceId, open);
|
|
209
|
-
return () => dispatchClose(dispatch, id, instanceId);
|
|
210
|
-
}, [dispatch, instanceId, signature, hasHandlers]);
|
|
211
|
-
return null;
|
|
212
|
-
}
|
|
213
|
-
Controller.displayName = `${id}Controller`;
|
|
214
|
-
return {
|
|
215
|
-
...spec,
|
|
216
|
-
id,
|
|
217
|
-
label: spec.label,
|
|
218
|
-
instance: multi ? "multi" : "single",
|
|
219
|
-
keepAlive: spec.keepAlive ?? "none",
|
|
220
|
-
meta,
|
|
221
|
-
useSummon,
|
|
222
|
-
Controller,
|
|
223
|
-
useIsOpen,
|
|
224
|
-
useClose,
|
|
225
|
-
useEmit
|
|
226
|
-
};
|
|
227
|
-
};
|
|
228
|
-
}
|
|
229
|
-
|
|
230
129
|
// src/root/PopoutContext.tsx
|
|
231
130
|
import { createContext as createContext3, useContext as useContext3 } from "react";
|
|
232
131
|
var DEFAULT_VALUE = {
|
|
@@ -246,10 +145,10 @@ function usePopoutContainer() {
|
|
|
246
145
|
}
|
|
247
146
|
|
|
248
147
|
// src/root/useOverlaySurfaceRenderAck.ts
|
|
249
|
-
import { useEffect as
|
|
148
|
+
import { useEffect as useEffect2 } from "react";
|
|
250
149
|
import { ackOverlaySurfaceRender, clearOverlaySurfaceRender } from "@ai-matrx/summon/open";
|
|
251
150
|
function useOverlaySurfaceRenderAck(overlayId, active) {
|
|
252
|
-
|
|
151
|
+
useEffect2(() => {
|
|
253
152
|
if (!active) return void 0;
|
|
254
153
|
ackOverlaySurfaceRender(overlayId);
|
|
255
154
|
return () => clearOverlaySurfaceRender(overlayId);
|
|
@@ -257,15 +156,15 @@ function useOverlaySurfaceRenderAck(overlayId, active) {
|
|
|
257
156
|
}
|
|
258
157
|
|
|
259
158
|
// src/root/useOverlayLink.ts
|
|
260
|
-
import { useEffect as
|
|
159
|
+
import { useEffect as useEffect3, useMemo } from "react";
|
|
261
160
|
import { registerSyncEntry, unregisterSyncEntry } from "@ai-matrx/summon/open";
|
|
262
161
|
function useOverlayLink(linkKey, id, args) {
|
|
263
162
|
const dispatch = useSummonDispatch();
|
|
264
163
|
const argsKey = args ? JSON.stringify(
|
|
265
164
|
Object.keys(args).sort().map((k) => [k, args[k]])
|
|
266
165
|
) : "";
|
|
267
|
-
const stableArgs =
|
|
268
|
-
|
|
166
|
+
const stableArgs = useMemo(() => args ? { ...args } : void 0, [argsKey]);
|
|
167
|
+
useEffect3(() => {
|
|
269
168
|
if (!linkKey || !id) return void 0;
|
|
270
169
|
dispatch(registerSyncEntry(stableArgs ? { typeKey: linkKey, instanceId: id, args: stableArgs } : { typeKey: linkKey, instanceId: id }));
|
|
271
170
|
return () => {
|
|
@@ -274,14 +173,12 @@ function useOverlayLink(linkKey, id, args) {
|
|
|
274
173
|
}, [dispatch, linkKey, id, stableArgs]);
|
|
275
174
|
}
|
|
276
175
|
export {
|
|
277
|
-
CALLBACK_GROUP_KEY,
|
|
278
176
|
OverlayInstanceContext,
|
|
279
177
|
PopoutContext,
|
|
280
178
|
SummonPortsContext,
|
|
281
179
|
SummonRoot,
|
|
282
180
|
SummonStoreContext,
|
|
283
181
|
configureSummonHost,
|
|
284
|
-
defineOverlay,
|
|
285
182
|
dispatchClose,
|
|
286
183
|
dispatchOpen,
|
|
287
184
|
emitOverlayEventLight,
|