@assistant-ui/react 0.15.23 → 0.15.25
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/README.md +44 -23
- package/dist/assistant-transport.js.map +1 -1
- package/dist/cloud-renderer/CloudRendererHost.js.map +1 -1
- package/dist/context/providers/MessageProvider.js.map +1 -1
- package/dist/context/providers/ThreadViewportProvider.js.map +1 -1
- package/dist/hooks/useToolCallElapsed.d.ts +3 -1
- package/dist/hooks/useToolCallElapsed.d.ts.map +1 -1
- package/dist/hooks/useToolCallElapsed.js +7 -8
- package/dist/hooks/useToolCallElapsed.js.map +1 -1
- package/dist/index.d.ts +10 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/legacy-runtime/AssistantRuntimeProvider.js.map +1 -1
- package/dist/mcp-apps/app-frame.js.map +1 -1
- package/dist/model-context/frame/useAssistantFrameHost.js.map +1 -1
- package/dist/model-context/makeAssistantVisible.d.ts +1 -0
- package/dist/model-context/makeAssistantVisible.d.ts.map +1 -1
- package/dist/model-context/makeAssistantVisible.js +31 -12
- package/dist/model-context/makeAssistantVisible.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarCopy.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarEdit.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarExportMarkdown.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarFeedbackNegative.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarFeedbackPositive.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarReload.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarRoot.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarSpeak.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarStopSpeaking.js.map +1 -1
- package/dist/primitives/actionBar/useActionBarFloatStatus.js.map +1 -1
- package/dist/primitives/actionBarMore/ActionBarMoreContent.js.map +1 -1
- package/dist/primitives/actionBarMore/ActionBarMoreItem.js.map +1 -1
- package/dist/primitives/actionBarMore/ActionBarMoreRoot.js.map +1 -1
- package/dist/primitives/actionBarMore/ActionBarMoreSeparator.js.map +1 -1
- package/dist/primitives/actionBarMore/ActionBarMoreTrigger.js.map +1 -1
- package/dist/primitives/actionBarMore/scope.js.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalAnchor.js.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalContent.js.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalRoot.js.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalTrigger.js.map +1 -1
- package/dist/primitives/assistantModal/popoverRenderPrimitives.js.map +1 -1
- package/dist/primitives/assistantModal/scope.js.map +1 -1
- package/dist/primitives/attachment/AttachmentName.js.map +1 -1
- package/dist/primitives/attachment/AttachmentRemove.js.map +1 -1
- package/dist/primitives/attachment/AttachmentRoot.js.map +1 -1
- package/dist/primitives/attachment/AttachmentThumb.js.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerCount.js.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerNext.js.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerNumber.js.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerPrevious.js.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerRoot.js.map +1 -1
- package/dist/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.js.map +1 -1
- package/dist/primitives/chainOfThought/ChainOfThoughtRoot.js.map +1 -1
- package/dist/primitives/composer/ComposerAddAttachment.js.map +1 -1
- package/dist/primitives/composer/ComposerCancel.js.map +1 -1
- package/dist/primitives/composer/ComposerDictate.js.map +1 -1
- package/dist/primitives/composer/ComposerDictationTranscript.js.map +1 -1
- package/dist/primitives/composer/ComposerInput.d.ts +1 -1
- package/dist/primitives/composer/ComposerInput.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerInput.js +4 -3
- package/dist/primitives/composer/ComposerInput.js.map +1 -1
- package/dist/primitives/composer/ComposerInputPluginContext.js.map +1 -1
- package/dist/primitives/composer/ComposerQuote.js.map +1 -1
- package/dist/primitives/composer/ComposerRoot.js.map +1 -1
- package/dist/primitives/composer/ComposerSend.js.map +1 -1
- package/dist/primitives/composer/ComposerStopDictation.js.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopover.d.ts +11 -11
- package/dist/primitives/composer/trigger/TriggerPopover.d.ts.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopover.js +62 -60
- package/dist/primitives/composer/trigger/TriggerPopover.js.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverAction.d.ts +8 -8
- package/dist/primitives/composer/trigger/TriggerPopoverAction.d.ts.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverAction.js +6 -6
- package/dist/primitives/composer/trigger/TriggerPopoverAction.js.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverBack.js.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverCategories.d.ts +3 -3
- package/dist/primitives/composer/trigger/TriggerPopoverCategories.d.ts.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverCategories.js.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverDirective.d.ts +9 -9
- package/dist/primitives/composer/trigger/TriggerPopoverDirective.d.ts.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverDirective.js +7 -7
- package/dist/primitives/composer/trigger/TriggerPopoverDirective.js.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverItems.d.ts +5 -5
- package/dist/primitives/composer/trigger/TriggerPopoverItems.d.ts.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverItems.js.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverResource.js.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverRootContext.d.ts +8 -8
- package/dist/primitives/composer/trigger/TriggerPopoverRootContext.js +8 -8
- package/dist/primitives/composer/trigger/TriggerPopoverRootContext.js.map +1 -1
- package/dist/primitives/composer/trigger/index.d.ts +1 -1
- package/dist/primitives/composer/trigger/index.js.map +1 -1
- package/dist/primitives/composer/trigger/triggerDetectionResource.js.map +1 -1
- package/dist/primitives/composer/trigger/triggerKeyboardResource.js.map +1 -1
- package/dist/primitives/composer/trigger/triggerNavigationResource.js.map +1 -1
- package/dist/primitives/composer/trigger/triggerSelectionResource.js.map +1 -1
- package/dist/primitives/composer/useComposerInputState.js.map +1 -1
- package/dist/primitives/composer.d.ts +20 -1
- package/dist/primitives/composer.d.ts.map +1 -1
- package/dist/primitives/composer.js +8 -1
- package/dist/primitives/composer.js.map +1 -1
- package/dist/primitives/dropdownMenuRenderPrimitives.js.map +1 -1
- package/dist/primitives/error/ErrorMessage.js.map +1 -1
- package/dist/primitives/error/ErrorRoot.js.map +1 -1
- package/dist/primitives/message/MessageIf.js.map +1 -1
- package/dist/primitives/message/MessageParts.js.map +1 -1
- package/dist/primitives/message/MessagePartsGrouped.d.ts.map +1 -1
- package/dist/primitives/message/MessagePartsGrouped.js +42 -17
- package/dist/primitives/message/MessagePartsGrouped.js.map +1 -1
- package/dist/primitives/message/MessageRoot.js.map +1 -1
- package/dist/primitives/messagePart/MessagePartImage.js.map +1 -1
- package/dist/primitives/queueItem/QueueItemRemove.js.map +1 -1
- package/dist/primitives/queueItem/QueueItemSteer.js.map +1 -1
- package/dist/primitives/queueItem/QueueItemText.js.map +1 -1
- package/dist/primitives/reasoning/useScrollLock.js.map +1 -1
- package/dist/primitives/selectionToolbar/SelectionToolbarQuote.js.map +1 -1
- package/dist/primitives/selectionToolbar/SelectionToolbarRoot.js.map +1 -1
- package/dist/primitives/suggestion/SuggestionDescription.js.map +1 -1
- package/dist/primitives/suggestion/SuggestionTitle.js.map +1 -1
- package/dist/primitives/suggestion/SuggestionTrigger.js.map +1 -1
- package/dist/primitives/thread/ThreadIf.js.map +1 -1
- package/dist/primitives/thread/ThreadLoadEarlier.d.ts +19 -0
- package/dist/primitives/thread/ThreadLoadEarlier.d.ts.map +1 -0
- package/dist/primitives/thread/ThreadLoadEarlier.js +36 -0
- package/dist/primitives/thread/ThreadLoadEarlier.js.map +1 -0
- package/dist/primitives/thread/ThreadMessages.d.ts +1 -1
- package/dist/primitives/thread/ThreadMessages.d.ts.map +1 -1
- package/dist/primitives/thread/ThreadMessages.js +2 -2
- package/dist/primitives/thread/ThreadRoot.d.ts.map +1 -1
- package/dist/primitives/thread/ThreadRoot.js +2 -0
- package/dist/primitives/thread/ThreadRoot.js.map +1 -1
- package/dist/primitives/thread/ThreadScrollToBottom.js.map +1 -1
- package/dist/primitives/thread/ThreadSuggestion.js.map +1 -1
- package/dist/primitives/thread/ThreadViewport.js.map +1 -1
- package/dist/primitives/thread/ThreadViewportFooter.js.map +1 -1
- package/dist/primitives/thread/topAnchor/useTopAnchorReserve.js.map +1 -1
- package/dist/primitives/thread/useThreadViewportAutoScroll.d.ts.map +1 -1
- package/dist/primitives/thread/useThreadViewportAutoScroll.js +111 -2
- package/dist/primitives/thread/useThreadViewportAutoScroll.js.map +1 -1
- package/dist/primitives/thread.d.ts +2 -0
- package/dist/primitives/thread.d.ts.map +1 -1
- package/dist/primitives/thread.js +5 -2
- package/dist/primitives/thread.js.map +1 -1
- package/dist/primitives/threadList/ThreadListLoadMore.js.map +1 -1
- package/dist/primitives/threadList/ThreadListNew.js.map +1 -1
- package/dist/primitives/threadList/ThreadListRoot.js.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemArchive.js.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemDelete.js.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemRoot.js.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemTrigger.js.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemUnarchive.js.map +1 -1
- package/dist/primitives/threadListItemMore/ThreadListItemMoreContent.js.map +1 -1
- package/dist/primitives/threadListItemMore/ThreadListItemMoreItem.js.map +1 -1
- package/dist/primitives/threadListItemMore/ThreadListItemMoreRoot.js.map +1 -1
- package/dist/primitives/threadListItemMore/ThreadListItemMoreSeparator.js.map +1 -1
- package/dist/primitives/threadListItemMore/ThreadListItemMoreTrigger.js.map +1 -1
- package/dist/primitives/threadListItemMore/scope.js.map +1 -1
- package/dist/sandbox-host/SandboxHost.d.ts.map +1 -1
- package/dist/sandbox-host/SandboxHost.js +6 -1
- package/dist/sandbox-host/SandboxHost.js.map +1 -1
- package/dist/unstable/useMessageStallDetection.d.ts.map +1 -1
- package/dist/unstable/useMessageStallDetection.js +10 -6
- package/dist/unstable/useMessageStallDetection.js.map +1 -1
- package/dist/unstable/useModelContextSnapshot.js.map +1 -1
- package/dist/unstable/webmcp/WebMcpRegistrationResource.js.map +1 -1
- package/dist/unstable/webmcp/useWebMcpProvider.js.map +1 -1
- package/dist/utils/Primitive.js.map +1 -1
- package/dist/utils/createActionButton.js.map +1 -1
- package/dist/utils/hooks/useManagedRef.js.map +1 -1
- package/dist/utils/hooks/useMediaQuery.js.map +1 -1
- package/dist/utils/hooks/useOnResizeContent.js.map +1 -1
- package/dist/utils/hooks/useOnScrollToBottom.js.map +1 -1
- package/dist/utils/hooks/useSizeHandle.js.map +1 -1
- package/dist/utils/isCompositionKey.d.ts +2 -0
- package/dist/utils/isCompositionKey.d.ts.map +1 -0
- package/dist/utils/isCompositionKey.js +6 -0
- package/dist/utils/isCompositionKey.js.map +1 -0
- package/dist/utils/smooth/SmoothContext.js.map +1 -1
- package/dist/utils/smooth/useSmooth.js +6 -6
- package/dist/utils/smooth/useSmooth.js.map +1 -1
- package/package.json +12 -11
- package/src/hooks/useToolCallElapsed.test.tsx +35 -0
- package/src/hooks/useToolCallElapsed.ts +9 -7
- package/src/index.ts +28 -3
- package/src/model-context/makeAssistantVisible.test.tsx +315 -5
- package/src/model-context/makeAssistantVisible.tsx +43 -7
- package/src/primitives/composer/ComposerInput.test.tsx +33 -1
- package/src/primitives/composer/ComposerInput.tsx +4 -3
- package/src/primitives/composer/trigger/TriggerPopover.tsx +11 -11
- package/src/primitives/composer/trigger/TriggerPopoverAction.tsx +10 -13
- package/src/primitives/composer/trigger/TriggerPopoverCategories.tsx +2 -2
- package/src/primitives/composer/trigger/TriggerPopoverDirective.tsx +11 -14
- package/src/primitives/composer/trigger/TriggerPopoverExports.test.ts +61 -0
- package/src/primitives/composer/trigger/TriggerPopoverItems.tsx +3 -3
- package/src/primitives/composer/trigger/TriggerPopoverRootContext.tsx +8 -8
- package/src/primitives/composer.ts +21 -1
- package/src/primitives/message/MessagePartsGrouped.test.tsx +271 -1
- package/src/primitives/message/MessagePartsGrouped.tsx +14 -6
- package/src/primitives/message/MessageRoot.test.tsx +125 -2
- package/src/primitives/thread/ThreadLoadEarlier.tsx +35 -0
- package/src/primitives/thread/ThreadMessages.tsx +1 -0
- package/src/primitives/thread/ThreadRoot.test.tsx +33 -0
- package/src/primitives/thread/ThreadRoot.tsx +3 -0
- package/src/primitives/thread/useThreadViewportAutoScroll.test.tsx +256 -5
- package/src/primitives/thread/useThreadViewportAutoScroll.ts +147 -1
- package/src/primitives/thread.ts +2 -0
- package/src/sandbox-host/SandboxHost.test.tsx +34 -0
- package/src/sandbox-host/SandboxHost.tsx +8 -4
- package/src/tests/toolCallTiming.test.tsx +19 -2
- package/src/unstable/useMessageStallDetection.test.tsx +40 -0
- package/src/unstable/useMessageStallDetection.ts +10 -6
- package/src/utils/isCompositionKey.ts +5 -0
- package/src/utils/smooth/useSmooth.test.tsx +16 -5
- package/src/utils/smooth/useSmooth.ts +7 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-frame.js","names":["c","_c","MutableRefObject","useEffect","useLayoutEffect","useRef","McpAppBridge","createMcpAppBridge","SandboxHost","SandboxBridge","SandboxHostApi","SandboxHostFrame","McpAppBridgeHandlers","McpAppFrameProps","McpAppHostContext","isRecord","DEFAULT_PRODUCT","INIT_TIMEOUT_MS","DEFAULT_MAX_HEIGHT","isPlainObject","value","Record","prototype","Object","getPrototypeOf","isSameHostContext","a","b","depth","is","Array","isArray","length","i","aKeys","keys","every","key","hasOwn","useBridgeNotify","bridgeRef","widgetReadyRef","pendingRef","lastSentRef","notify","t0","$","isEqual","undefined","t1","current","t2","LiveSnapshot","handlers","hostInfo","hostContext","input","output","FrameLifecycle","onInitialized","onSizeChange","params","width","height","buildLiveHandlers","initial","liveRef","lifecycle","live","has","K","out","defineProperty","get","allowedTools","enumerable","configurable","liveCall","NonNullable","p","fn","Error","callTool","readResource","listResources","openLink","sendMessage","updateModelContext","requestDisplayMode","onRequestTeardown","onLog","onError","e","McpAppFrame","app","resource","sandbox","maxHeight","lastSentInputRef","lastSentOutputRef","lastSentHostContextRef","pendingInputRef","pendingOutputRef","pendingHostContextRef","t3","t4","t5","Symbol","for","frame","host","initTimeoutId","flushPending","notifyToolInput","notifyToolResult","notifyHostContextChanged","wrappedHandlers","clearTimeout","setHeight","setTimeout","bridge","onMessage","dispose","createBridge","_temp","_temp2","_temp3","t6","html","t7","serverId","uri","t8","product","t9","t10","err","t11","meta","prefersBorder","t12","resourceUri","t13","b_2","v_1","v","b_1","v_0","b_0"],"sources":["../../src/mcp-apps/app-frame.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type MutableRefObject,\n useEffect,\n useLayoutEffect,\n useRef,\n} from \"react\";\nimport { type McpAppBridge, createMcpAppBridge } from \"./bridge\";\nimport {\n SandboxHost,\n type SandboxBridge,\n type SandboxHostApi,\n type SandboxHostFrame,\n} from \"../sandbox-host/SandboxHost\";\nimport type {\n McpAppBridgeHandlers,\n McpAppFrameProps,\n McpAppHostContext,\n} from \"./types\";\nimport { isRecord } from \"@assistant-ui/core/internal\";\n\nconst DEFAULT_PRODUCT = \"assistant-ui-mcp-app\";\nconst INIT_TIMEOUT_MS = 5000;\nconst DEFAULT_MAX_HEIGHT = 800;\n\n// Only a plain object can be compared by its own keys. Structured clone carries\n// a Date, Map, or class instance to the widget intact, and those expose no\n// enumerable keys, so walking them would report two different values as equal.\nconst isPlainObject = (value: unknown): value is Record<string, unknown> => {\n if (!isRecord(value)) return false;\n const prototype = Object.getPrototypeOf(value);\n return prototype === null || prototype === Object.prototype;\n};\n\n// Hosts commonly rebuild an equal context object on every render, and the\n// widget cannot tell a repeated notification apart from a real change. The\n// open index signature on McpAppHostContext admits values JSON rejects (an\n// undefined property value is enough), so leaves the walk cannot compare fall\n// back to identity rather than failing the whole comparison.\nconst isSameHostContext = (a: unknown, b: unknown, depth = 0): boolean => {\n if (Object.is(a, b)) return true;\n if (depth > 100) return false;\n if (Array.isArray(a) || Array.isArray(b)) {\n if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length)\n return false;\n for (let i = 0; i < a.length; i++) {\n if (!isSameHostContext(a[i], b[i], depth + 1)) return false;\n }\n return true;\n }\n if (!isPlainObject(a) || !isPlainObject(b)) return false;\n const aKeys = Object.keys(a);\n return (\n aKeys.length === Object.keys(b).length &&\n aKeys.every(\n (key) =>\n Object.hasOwn(b, key) && isSameHostContext(a[key], b[key], depth + 1),\n )\n );\n};\n\nfunction useBridgeNotify<T>(\n value: T | undefined,\n bridgeRef: MutableRefObject<McpAppBridge | null>,\n widgetReadyRef: MutableRefObject<boolean>,\n pendingRef: MutableRefObject<T | undefined>,\n lastSentRef: MutableRefObject<T | undefined>,\n notify: (bridge: McpAppBridge, v: T) => void,\n isEqual: (sent: T | undefined, next: T) => boolean = Object.is,\n) {\n useEffect(() => {\n if (!bridgeRef.current) return;\n // Nothing to deliver, either because there is no value or because the\n // widget already holds it; a queued value here is superseded and would\n // otherwise flush after initialization as a stale update.\n if (value === undefined || isEqual(lastSentRef.current, value)) {\n pendingRef.current = undefined;\n return;\n }\n if (!widgetReadyRef.current) {\n pendingRef.current = value;\n return;\n }\n notify(bridgeRef.current, value);\n lastSentRef.current = value;\n // oxlint-disable-next-line react/exhaustive-deps -- refs are stable; notify and isEqual are assumed stable; re-run only when value changes\n }, [value]);\n}\n\ntype LiveSnapshot = {\n handlers: McpAppBridgeHandlers | undefined;\n hostInfo: McpAppFrameProps[\"hostInfo\"];\n hostContext: McpAppFrameProps[\"hostContext\"];\n input: unknown;\n output: unknown;\n};\n\ntype FrameLifecycle = {\n onInitialized: () => void;\n onSizeChange: (params: { width?: number; height?: number }) => void;\n};\n\n// Proxy each per-call handler through liveRef so the bridge always dispatches\n// to the latest handler reference (e.g. inline callbacks closing over state).\n// Capability presence is snapshot at mount: a handler added later requires a\n// remount (keyed on resource URI) to expose the capability to the widget.\n// allowedTools is the exception: it is never advertised in the ui/initialize\n// response, so it stays a live getter, which means this object must reach the\n// bridge uncopied and the frame passes its lifecycle work in rather than\n// wrapping the result.\nfunction buildLiveHandlers(\n initial: McpAppBridgeHandlers | undefined,\n liveRef: { readonly current: LiveSnapshot },\n lifecycle: FrameLifecycle,\n): McpAppBridgeHandlers {\n const live = () => liveRef.current.handlers;\n const has = <K extends keyof McpAppBridgeHandlers>(key: K) =>\n initial?.[key] !== undefined;\n const out: McpAppBridgeHandlers = {};\n Object.defineProperty(out, \"allowedTools\", {\n get: () => live()?.allowedTools,\n enumerable: true,\n configurable: true,\n });\n const liveCall = <K extends keyof McpAppBridgeHandlers>(\n key: K,\n ): NonNullable<McpAppBridgeHandlers[K]> =>\n ((p: unknown) => {\n const fn = live()?.[key] as ((p: unknown) => unknown) | undefined;\n if (!fn) {\n throw new Error(`${key} handler is no longer available`);\n }\n return fn(p);\n }) as NonNullable<McpAppBridgeHandlers[K]>;\n if (has(\"callTool\")) out.callTool = liveCall(\"callTool\");\n if (has(\"readResource\")) out.readResource = liveCall(\"readResource\");\n if (has(\"listResources\")) out.listResources = liveCall(\"listResources\");\n if (has(\"openLink\")) out.openLink = liveCall(\"openLink\");\n if (has(\"sendMessage\")) out.sendMessage = liveCall(\"sendMessage\");\n if (has(\"updateModelContext\"))\n out.updateModelContext = liveCall(\"updateModelContext\");\n if (has(\"requestDisplayMode\"))\n out.requestDisplayMode = liveCall(\"requestDisplayMode\");\n out.onSizeChange = (p) => {\n lifecycle.onSizeChange(p);\n live()?.onSizeChange?.(p);\n };\n out.onInitialized = () => {\n lifecycle.onInitialized();\n live()?.onInitialized?.();\n };\n out.onRequestTeardown = (p) => live()?.onRequestTeardown?.(p);\n out.onLog = (p) => live()?.onLog?.(p);\n out.onError = (e) => live()?.onError?.(e);\n return out;\n}\n\nexport function McpAppFrame({\n app,\n resource,\n input,\n output,\n sandbox,\n handlers,\n hostInfo,\n hostContext,\n maxHeight = DEFAULT_MAX_HEIGHT,\n}: McpAppFrameProps) {\n const bridgeRef = useRef<McpAppBridge | null>(null);\n const lastSentInputRef = useRef<unknown>(undefined);\n const lastSentOutputRef = useRef<unknown>(undefined);\n const lastSentHostContextRef = useRef<McpAppHostContext | undefined>(\n undefined,\n );\n // Per MCP Apps spec, the host should defer notifications until the widget\n // signals readiness via `notifications/initialized`. Until then, we record\n // pending values and flush them on init.\n const widgetReadyRef = useRef(false);\n const pendingInputRef = useRef<unknown>(undefined);\n const pendingOutputRef = useRef<unknown>(undefined);\n const pendingHostContextRef = useRef<McpAppHostContext | undefined>(\n undefined,\n );\n\n const liveRef = useRef<LiveSnapshot>({\n handlers,\n hostInfo,\n hostContext,\n input,\n output,\n });\n useLayoutEffect(() => {\n liveRef.current = {\n handlers,\n hostInfo,\n hostContext,\n input,\n output,\n };\n }, [handlers, hostInfo, hostContext, input, output]);\n\n const createBridge = (\n frame: SandboxHostFrame,\n host: SandboxHostApi,\n ): SandboxBridge => {\n const current = liveRef.current;\n let initTimeoutId: ReturnType<typeof setTimeout> | null = null;\n\n const flushPending = () => {\n if (widgetReadyRef.current) return;\n widgetReadyRef.current = true;\n const b = bridgeRef.current;\n if (!b) return;\n if (pendingInputRef.current !== undefined) {\n b.notifyToolInput(pendingInputRef.current);\n lastSentInputRef.current = pendingInputRef.current;\n pendingInputRef.current = undefined;\n }\n if (pendingOutputRef.current !== undefined) {\n b.notifyToolResult(pendingOutputRef.current);\n lastSentOutputRef.current = pendingOutputRef.current;\n pendingOutputRef.current = undefined;\n }\n if (pendingHostContextRef.current !== undefined) {\n b.notifyHostContextChanged(pendingHostContextRef.current);\n lastSentHostContextRef.current = pendingHostContextRef.current;\n pendingHostContextRef.current = undefined;\n }\n };\n\n const wrappedHandlers = buildLiveHandlers(current.handlers, liveRef, {\n onInitialized: () => {\n if (initTimeoutId !== null) {\n clearTimeout(initTimeoutId);\n initTimeoutId = null;\n }\n flushPending();\n },\n onSizeChange: (p) => {\n if (p.height != null) host.setHeight(p.height);\n },\n });\n\n // Safety net: if the widget never sends notifications/initialized (broken\n // or non-spec-compliant), flush the queue anyway so the host doesn't\n // appear hung.\n initTimeoutId = setTimeout(() => {\n initTimeoutId = null;\n flushPending();\n }, INIT_TIMEOUT_MS);\n\n const bridge = createMcpAppBridge({\n frame,\n handlers: wrappedHandlers,\n hostInfo: current.hostInfo,\n hostContext: current.hostContext,\n });\n bridgeRef.current = bridge;\n\n if (current.input !== undefined) pendingInputRef.current = current.input;\n if (current.output !== undefined) pendingOutputRef.current = current.output;\n // hostContext is delivered inside the ui/initialize response, where the\n // bridge defaults it to {}; recording that same normalized value keeps the\n // first later change from repeating what the widget already holds.\n lastSentHostContextRef.current = current.hostContext ?? {};\n\n return {\n onMessage: bridge.onMessage,\n dispose: () => {\n if (initTimeoutId !== null) {\n clearTimeout(initTimeoutId);\n initTimeoutId = null;\n }\n bridge.dispose();\n bridgeRef.current = null;\n lastSentInputRef.current = undefined;\n lastSentOutputRef.current = undefined;\n lastSentHostContextRef.current = undefined;\n widgetReadyRef.current = false;\n pendingInputRef.current = undefined;\n pendingOutputRef.current = undefined;\n pendingHostContextRef.current = undefined;\n },\n };\n };\n\n useBridgeNotify(\n input,\n bridgeRef,\n widgetReadyRef,\n pendingInputRef,\n lastSentInputRef,\n (b, v) => b.notifyToolInput(v),\n );\n useBridgeNotify(\n output,\n bridgeRef,\n widgetReadyRef,\n pendingOutputRef,\n lastSentOutputRef,\n (b, v) => b.notifyToolResult(v),\n );\n useBridgeNotify(\n hostContext,\n bridgeRef,\n widgetReadyRef,\n pendingHostContextRef,\n lastSentHostContextRef,\n (b, v) => b.notifyHostContextChanged(v),\n isSameHostContext,\n );\n\n return (\n <SandboxHost\n content={{ html: resource.html }}\n contentKey={\n app.serverId ? `${app.serverId} ${resource.uri}` : resource.uri\n }\n sandbox={{ ...sandbox, product: sandbox?.product ?? DEFAULT_PRODUCT }}\n maxHeight={maxHeight}\n createBridge={createBridge}\n onError={(err) => liveRef.current.handlers?.onError?.(err)}\n containerProps={{\n \"data-mcp-app-resource\": app.resourceUri,\n \"data-mcp-app-prefers-border\": resource.meta?.prefersBorder\n ? \"\"\n : undefined,\n }}\n />\n );\n}\n"],"mappings":";;;;;;;;AAsBA,MAAMgB,kBAAkB;AACxB,MAAMC,kBAAkB;AACxB,MAAMC,qBAAqB;AAK3B,MAAMC,iBAAiBC,UAAqD;CAC1E,IAAI,CAACL,SAASK,KAAK,GAAG,OAAO;CAC7B,MAAME,YAAYC,OAAOC,eAAeJ,KAAK;CAC7C,OAAOE,cAAc,QAAQA,cAAcC,OAAOD;AACpD;AAOA,MAAMG,qBAAqBC,GAAYC,GAAYC,QAAQ,MAAe;CACxE,IAAIL,OAAOM,GAAGH,GAAGC,CAAC,GAAG,OAAO;CAC5B,IAAIC,QAAQ,KAAK,OAAO;CACxB,IAAIE,MAAMC,QAAQL,CAAC,KAAKI,MAAMC,QAAQJ,CAAC,GAAG;EACxC,IAAI,CAACG,MAAMC,QAAQL,CAAC,KAAK,CAACI,MAAMC,QAAQJ,CAAC,KAAKD,EAAEM,WAAWL,EAAEK,QAC3D,OAAO;EACT,KAAK,IAAIC,IAAI,GAAGA,IAAIP,EAAEM,QAAQC,KAC5B,IAAI,CAACR,kBAAkBC,EAAEO,IAAIN,EAAEM,IAAIL,QAAQ,CAAC,GAAG,OAAO;EAExD,OAAO;CACT;CACA,IAAI,CAACT,cAAcO,CAAC,KAAK,CAACP,cAAcQ,CAAC,GAAG,OAAO;CACnD,MAAMO,QAAQX,OAAOY,KAAKT,CAAC;CAC3B,OACEQ,MAAMF,WAAWT,OAAOY,KAAKR,CAAC,CAAC,CAACK,UAChCE,MAAME,OACHC,QACCd,OAAO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,EAAA,MAAAgG;CAAA,OAAAA,MAAAhG,EAAA;CAAA,OAfFgG;AAeE;AA3KC,SAAAhB,OAAAiB,KAAAC,KAAA;CAAA,OAuJOrH,IAACwF,yBAA0B8B,GAAC;AAAC;AAvJpC,SAAApB,OAAAqB,KAAAC,KAAA;CAAA,OA+IOxH,IAACuF,iBAAkB+B,GAAC;AAAC;AA/I5B,SAAArB,MAAAwB,KAAAH,GAAA;CAAA,OAuIOtH,IAACsF,gBAAiBgC,CAAC;AAAC"}
|
|
1
|
+
{"version":3,"file":"app-frame.js","names":["c","_c","MutableRefObject","useEffect","useLayoutEffect","useRef","McpAppBridge","createMcpAppBridge","SandboxHost","SandboxBridge","SandboxHostApi","SandboxHostFrame","McpAppBridgeHandlers","McpAppFrameProps","McpAppHostContext","isRecord","DEFAULT_PRODUCT","INIT_TIMEOUT_MS","DEFAULT_MAX_HEIGHT","isPlainObject","value","Record","prototype","Object","getPrototypeOf","isSameHostContext","a","b","depth","is","Array","isArray","length","i","aKeys","keys","every","key","hasOwn","useBridgeNotify","bridgeRef","widgetReadyRef","pendingRef","lastSentRef","notify","t0","$","isEqual","undefined","t1","current","t2","LiveSnapshot","handlers","hostInfo","hostContext","input","output","FrameLifecycle","onInitialized","onSizeChange","params","width","height","buildLiveHandlers","initial","liveRef","lifecycle","live","has","K","out","defineProperty","get","allowedTools","enumerable","configurable","liveCall","NonNullable","p","fn","Error","callTool","readResource","listResources","openLink","sendMessage","updateModelContext","requestDisplayMode","onRequestTeardown","onLog","onError","e","McpAppFrame","app","resource","sandbox","maxHeight","lastSentInputRef","lastSentOutputRef","lastSentHostContextRef","pendingInputRef","pendingOutputRef","pendingHostContextRef","t3","t4","t5","Symbol","for","frame","host","initTimeoutId","flushPending","notifyToolInput","notifyToolResult","notifyHostContextChanged","wrappedHandlers","clearTimeout","setHeight","setTimeout","bridge","onMessage","dispose","createBridge","_temp","_temp2","_temp3","t6","html","t7","serverId","uri","t8","product","t9","t10","err","t11","meta","prefersBorder","t12","resourceUri","t13","b_2","v_1","v","b_1","v_0","b_0","_c"],"sources":["../../src/mcp-apps/app-frame.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type MutableRefObject,\n useEffect,\n useLayoutEffect,\n useRef,\n} from \"react\";\nimport { type McpAppBridge, createMcpAppBridge } from \"./bridge\";\nimport {\n SandboxHost,\n type SandboxBridge,\n type SandboxHostApi,\n type SandboxHostFrame,\n} from \"../sandbox-host/SandboxHost\";\nimport type {\n McpAppBridgeHandlers,\n McpAppFrameProps,\n McpAppHostContext,\n} from \"./types\";\nimport { isRecord } from \"@assistant-ui/core/internal\";\n\nconst DEFAULT_PRODUCT = \"assistant-ui-mcp-app\";\nconst INIT_TIMEOUT_MS = 5000;\nconst DEFAULT_MAX_HEIGHT = 800;\n\n// Only a plain object can be compared by its own keys. Structured clone carries\n// a Date, Map, or class instance to the widget intact, and those expose no\n// enumerable keys, so walking them would report two different values as equal.\nconst isPlainObject = (value: unknown): value is Record<string, unknown> => {\n if (!isRecord(value)) return false;\n const prototype = Object.getPrototypeOf(value);\n return prototype === null || prototype === Object.prototype;\n};\n\n// Hosts commonly rebuild an equal context object on every render, and the\n// widget cannot tell a repeated notification apart from a real change. The\n// open index signature on McpAppHostContext admits values JSON rejects (an\n// undefined property value is enough), so leaves the walk cannot compare fall\n// back to identity rather than failing the whole comparison.\nconst isSameHostContext = (a: unknown, b: unknown, depth = 0): boolean => {\n if (Object.is(a, b)) return true;\n if (depth > 100) return false;\n if (Array.isArray(a) || Array.isArray(b)) {\n if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length)\n return false;\n for (let i = 0; i < a.length; i++) {\n if (!isSameHostContext(a[i], b[i], depth + 1)) return false;\n }\n return true;\n }\n if (!isPlainObject(a) || !isPlainObject(b)) return false;\n const aKeys = Object.keys(a);\n return (\n aKeys.length === Object.keys(b).length &&\n aKeys.every(\n (key) =>\n Object.hasOwn(b, key) && isSameHostContext(a[key], b[key], depth + 1),\n )\n );\n};\n\nfunction useBridgeNotify<T>(\n value: T | undefined,\n bridgeRef: MutableRefObject<McpAppBridge | null>,\n widgetReadyRef: MutableRefObject<boolean>,\n pendingRef: MutableRefObject<T | undefined>,\n lastSentRef: MutableRefObject<T | undefined>,\n notify: (bridge: McpAppBridge, v: T) => void,\n isEqual: (sent: T | undefined, next: T) => boolean = Object.is,\n) {\n useEffect(() => {\n if (!bridgeRef.current) return;\n // Nothing to deliver, either because there is no value or because the\n // widget already holds it; a queued value here is superseded and would\n // otherwise flush after initialization as a stale update.\n if (value === undefined || isEqual(lastSentRef.current, value)) {\n pendingRef.current = undefined;\n return;\n }\n if (!widgetReadyRef.current) {\n pendingRef.current = value;\n return;\n }\n notify(bridgeRef.current, value);\n lastSentRef.current = value;\n // oxlint-disable-next-line react/exhaustive-deps -- refs are stable; notify and isEqual are assumed stable; re-run only when value changes\n }, [value]);\n}\n\ntype LiveSnapshot = {\n handlers: McpAppBridgeHandlers | undefined;\n hostInfo: McpAppFrameProps[\"hostInfo\"];\n hostContext: McpAppFrameProps[\"hostContext\"];\n input: unknown;\n output: unknown;\n};\n\ntype FrameLifecycle = {\n onInitialized: () => void;\n onSizeChange: (params: { width?: number; height?: number }) => void;\n};\n\n// Proxy each per-call handler through liveRef so the bridge always dispatches\n// to the latest handler reference (e.g. inline callbacks closing over state).\n// Capability presence is snapshot at mount: a handler added later requires a\n// remount (keyed on resource URI) to expose the capability to the widget.\n// allowedTools is the exception: it is never advertised in the ui/initialize\n// response, so it stays a live getter, which means this object must reach the\n// bridge uncopied and the frame passes its lifecycle work in rather than\n// wrapping the result.\nfunction buildLiveHandlers(\n initial: McpAppBridgeHandlers | undefined,\n liveRef: { readonly current: LiveSnapshot },\n lifecycle: FrameLifecycle,\n): McpAppBridgeHandlers {\n const live = () => liveRef.current.handlers;\n const has = <K extends keyof McpAppBridgeHandlers>(key: K) =>\n initial?.[key] !== undefined;\n const out: McpAppBridgeHandlers = {};\n Object.defineProperty(out, \"allowedTools\", {\n get: () => live()?.allowedTools,\n enumerable: true,\n configurable: true,\n });\n const liveCall = <K extends keyof McpAppBridgeHandlers>(\n key: K,\n ): NonNullable<McpAppBridgeHandlers[K]> =>\n ((p: unknown) => {\n const fn = live()?.[key] as ((p: unknown) => unknown) | undefined;\n if (!fn) {\n throw new Error(`${key} handler is no longer available`);\n }\n return fn(p);\n }) as NonNullable<McpAppBridgeHandlers[K]>;\n if (has(\"callTool\")) out.callTool = liveCall(\"callTool\");\n if (has(\"readResource\")) out.readResource = liveCall(\"readResource\");\n if (has(\"listResources\")) out.listResources = liveCall(\"listResources\");\n if (has(\"openLink\")) out.openLink = liveCall(\"openLink\");\n if (has(\"sendMessage\")) out.sendMessage = liveCall(\"sendMessage\");\n if (has(\"updateModelContext\"))\n out.updateModelContext = liveCall(\"updateModelContext\");\n if (has(\"requestDisplayMode\"))\n out.requestDisplayMode = liveCall(\"requestDisplayMode\");\n out.onSizeChange = (p) => {\n lifecycle.onSizeChange(p);\n live()?.onSizeChange?.(p);\n };\n out.onInitialized = () => {\n lifecycle.onInitialized();\n live()?.onInitialized?.();\n };\n out.onRequestTeardown = (p) => live()?.onRequestTeardown?.(p);\n out.onLog = (p) => live()?.onLog?.(p);\n out.onError = (e) => live()?.onError?.(e);\n return out;\n}\n\nexport function McpAppFrame({\n app,\n resource,\n input,\n output,\n sandbox,\n handlers,\n hostInfo,\n hostContext,\n maxHeight = DEFAULT_MAX_HEIGHT,\n}: McpAppFrameProps) {\n const bridgeRef = useRef<McpAppBridge | null>(null);\n const lastSentInputRef = useRef<unknown>(undefined);\n const lastSentOutputRef = useRef<unknown>(undefined);\n const lastSentHostContextRef = useRef<McpAppHostContext | undefined>(\n undefined,\n );\n // Per MCP Apps spec, the host should defer notifications until the widget\n // signals readiness via `notifications/initialized`. Until then, we record\n // pending values and flush them on init.\n const widgetReadyRef = useRef(false);\n const pendingInputRef = useRef<unknown>(undefined);\n const pendingOutputRef = useRef<unknown>(undefined);\n const pendingHostContextRef = useRef<McpAppHostContext | undefined>(\n undefined,\n );\n\n const liveRef = useRef<LiveSnapshot>({\n handlers,\n hostInfo,\n hostContext,\n input,\n output,\n });\n useLayoutEffect(() => {\n liveRef.current = {\n handlers,\n hostInfo,\n hostContext,\n input,\n output,\n };\n }, [handlers, hostInfo, hostContext, input, output]);\n\n const createBridge = (\n frame: SandboxHostFrame,\n host: SandboxHostApi,\n ): SandboxBridge => {\n const current = liveRef.current;\n let initTimeoutId: ReturnType<typeof setTimeout> | null = null;\n\n const flushPending = () => {\n if (widgetReadyRef.current) return;\n widgetReadyRef.current = true;\n const b = bridgeRef.current;\n if (!b) return;\n if (pendingInputRef.current !== undefined) {\n b.notifyToolInput(pendingInputRef.current);\n lastSentInputRef.current = pendingInputRef.current;\n pendingInputRef.current = undefined;\n }\n if (pendingOutputRef.current !== undefined) {\n b.notifyToolResult(pendingOutputRef.current);\n lastSentOutputRef.current = pendingOutputRef.current;\n pendingOutputRef.current = undefined;\n }\n if (pendingHostContextRef.current !== undefined) {\n b.notifyHostContextChanged(pendingHostContextRef.current);\n lastSentHostContextRef.current = pendingHostContextRef.current;\n pendingHostContextRef.current = undefined;\n }\n };\n\n const wrappedHandlers = buildLiveHandlers(current.handlers, liveRef, {\n onInitialized: () => {\n if (initTimeoutId !== null) {\n clearTimeout(initTimeoutId);\n initTimeoutId = null;\n }\n flushPending();\n },\n onSizeChange: (p) => {\n if (p.height != null) host.setHeight(p.height);\n },\n });\n\n // Safety net: if the widget never sends notifications/initialized (broken\n // or non-spec-compliant), flush the queue anyway so the host doesn't\n // appear hung.\n initTimeoutId = setTimeout(() => {\n initTimeoutId = null;\n flushPending();\n }, INIT_TIMEOUT_MS);\n\n const bridge = createMcpAppBridge({\n frame,\n handlers: wrappedHandlers,\n hostInfo: current.hostInfo,\n hostContext: current.hostContext,\n });\n bridgeRef.current = bridge;\n\n if (current.input !== undefined) pendingInputRef.current = current.input;\n if (current.output !== undefined) pendingOutputRef.current = current.output;\n // hostContext is delivered inside the ui/initialize response, where the\n // bridge defaults it to {}; recording that same normalized value keeps the\n // first later change from repeating what the widget already holds.\n lastSentHostContextRef.current = current.hostContext ?? {};\n\n return {\n onMessage: bridge.onMessage,\n dispose: () => {\n if (initTimeoutId !== null) {\n clearTimeout(initTimeoutId);\n initTimeoutId = null;\n }\n bridge.dispose();\n bridgeRef.current = null;\n lastSentInputRef.current = undefined;\n lastSentOutputRef.current = undefined;\n lastSentHostContextRef.current = undefined;\n widgetReadyRef.current = false;\n pendingInputRef.current = undefined;\n pendingOutputRef.current = undefined;\n pendingHostContextRef.current = undefined;\n },\n };\n };\n\n useBridgeNotify(\n input,\n bridgeRef,\n widgetReadyRef,\n pendingInputRef,\n lastSentInputRef,\n (b, v) => b.notifyToolInput(v),\n );\n useBridgeNotify(\n output,\n bridgeRef,\n widgetReadyRef,\n pendingOutputRef,\n lastSentOutputRef,\n (b, v) => b.notifyToolResult(v),\n );\n useBridgeNotify(\n hostContext,\n bridgeRef,\n widgetReadyRef,\n pendingHostContextRef,\n lastSentHostContextRef,\n (b, v) => b.notifyHostContextChanged(v),\n isSameHostContext,\n );\n\n return (\n <SandboxHost\n content={{ html: resource.html }}\n contentKey={\n app.serverId ? `${app.serverId} ${resource.uri}` : resource.uri\n }\n sandbox={{ ...sandbox, product: sandbox?.product ?? DEFAULT_PRODUCT }}\n maxHeight={maxHeight}\n createBridge={createBridge}\n onError={(err) => liveRef.current.handlers?.onError?.(err)}\n containerProps={{\n \"data-mcp-app-resource\": app.resourceUri,\n \"data-mcp-app-prefers-border\": resource.meta?.prefersBorder\n ? \"\"\n : undefined,\n }}\n />\n );\n}\n"],"mappings":";;;;;;;;AAsBA,MAAMgB,kBAAkB;AACxB,MAAMC,kBAAkB;AACxB,MAAMC,qBAAqB;AAK3B,MAAMC,iBAAiBC,UAAqD;CAC1E,IAAI,CAACL,SAASK,KAAK,GAAG,OAAO;CAC7B,MAAME,YAAYC,OAAOC,eAAeJ,KAAK;CAC7C,OAAOE,cAAc,QAAQA,cAAcC,OAAOD;AACpD;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F,MAAA1C,SAAQ2C,MAAoBC,gBAA5B,KAAA3F,KAAAA;CAElB,IAAA4F;CAAA,IAAA9F,EAAA,QAAAgD,IAAA+C,eAAA/F,EAAA,QAAA2F,KAAA;EAJCG,MAAA;GAAA,yBACW9C,IAAG+C;GAAY,+BACTJ;EAGjC;EAAC3F,EAAA,MAAAgD,IAAA+C;EAAA/F,EAAA,MAAA2F;EAAA3F,EAAA,MAAA8F;CAAA,OAAAA,MAAA9F,EAAA;CAAA,IAAAgG;CAAA,IAAAhG,EAAA,QAAAmD,aAAAnD,EAAA,QAAA8F,OAAA9F,EAAA,QAAAiF,MAAAjF,EAAA,QAAAmF,MAAAnF,EAAA,QAAAwF,IAAA;EAdHQ,MAAA,oBAAC,aAAD;GACW,SAAAf;GAEP,YAAAE;GAEO,SAAAK;GACErC;GACG0B;GACL,SAAAY;GACO,gBAAAK;EAKf,CAAA;EACD9F,EAAA,MAAAmD;EAAAnD,EAAA,MAAA8F;EAAA9F,EAAA,MAAAiF;EAAAjF,EAAA,MAAAmF;EAAAnF,EAAA,MAAAwF;EAAAxF,EAAA,MAAAgG;CAAA,OAAAA,MAAAhG,EAAA;CAAA,OAfFgG;AAeE;AA3KC,SAAAhB,OAAAiB,KAAAC,KAAA;CAAA,OAuJOrH,IAACwF,yBAA0B8B,GAAC;AAAC;AAvJpC,SAAApB,OAAAqB,KAAAC,KAAA;CAAA,OA+IOxH,IAACuF,iBAAkB+B,GAAC;AAAC;AA/I5B,SAAArB,MAAAwB,KAAAH,GAAA;CAAA,OAuIOtH,IAACsF,gBAAiBgC,CAAC;AAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAssistantFrameHost.js","names":["c","_c","Unsubscribe","useEffect","RefObject","AssistantFrameHost","UseAssistantFrameHostOptions","iframeRef","Readonly","HTMLIFrameElement","targetOrigin","register","frameHost","useAssistantFrameHost","t0","$","t1","t2","iframeWindow","current","contentWindow","unsubscribe","cleanupFailed","cleanupError","dispose","t3","error","t4","console"],"sources":["../../../src/model-context/frame/useAssistantFrameHost.ts"],"sourcesContent":["\"use client\";\n\nimport type { Unsubscribe } from \"@assistant-ui/core\";\nimport { useEffect, type RefObject } from \"react\";\nimport { AssistantFrameHost } from \"@assistant-ui/core\";\n\ntype UseAssistantFrameHostOptions = {\n iframeRef: Readonly<RefObject<HTMLIFrameElement | null | undefined>>;\n targetOrigin?: string;\n register: (frameHost: AssistantFrameHost) => Unsubscribe;\n};\n\n/**\n * React hook that manages the lifecycle of an AssistantFrameHost and its binding to the current AssistantRuntime.\n *\n * Usage example:\n * ```typescript\n * function MyComponent() {\n * const iframeRef = useRef<HTMLIFrameElement>(null);\n *\n * useAssistantFrameHost({\n * iframeRef,\n * targetOrigin: \"https://trusted-domain.com\",\n * });\n *\n * return <iframe ref={iframeRef} src=\"...\" />;\n * }\n * ```\n */\nexport const useAssistantFrameHost = ({\n iframeRef,\n targetOrigin,\n register,\n}: UseAssistantFrameHostOptions): void => {\n useEffect(() => {\n const iframeWindow = iframeRef.current?.contentWindow;\n if (!iframeWindow) return;\n\n const frameHost = new AssistantFrameHost(iframeWindow, targetOrigin);\n\n const unsubscribe = register(frameHost);\n\n return () => {\n let cleanupFailed = false;\n let cleanupError: unknown;\n\n try {\n frameHost.dispose();\n } catch (error) {\n cleanupFailed = true;\n cleanupError = error;\n }\n\n try {\n unsubscribe();\n } catch (error) {\n if (cleanupFailed) {\n console.error(\n \"[assistant-ui] AssistantFrameHost unregistration failed.\",\n error,\n );\n } else {\n cleanupFailed = true;\n cleanupError = error;\n }\n }\n\n if (cleanupFailed) throw cleanupError;\n };\n }, [iframeRef, targetOrigin, register]);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA6BA,MAAaa,yBAAwBC,OAAA;CAAA,MAAAC,IAAAd,EAAA,CAAA;CAAC,MAAA,EAAAM,WAAAG,cAAAC,aAAAG;CAIP,IAAAE;CAAA,IAAAC;CAAA,IAAAF,EAAA,OAAAR,aAAAQ,EAAA,OAAAJ,YAAAI,EAAA,OAAAL,cAAA;EACnBM,WAAA;GACR,MAAAE,eAAqBX,UAASY,SAAuBC;GACrD,IAAI,CAACF,cAAY;GAEjB,MAAAN,YAAkB,IAAIP,mBAAmBa,cAAcR,YAAY;GAEnE,MAAAW,cAAoBV,SAASC,SAAS;GAAE,aAEjC;IACL,IAAAU,gBAAoB;IAChBC,IAAAA;IAEJ,IAAA;KACEX,UAASY,QAAS;IAAC,SAAAC,IAAA;KACZC,MAAAA,QAAAA;KACPJ,gBAAgBA;KAChBC,eAAeG;IAAH;IAGd,IAAA;KACEL,YAAY;IAAC,SAAAM,IAAA;KACND,MAAAA,UAAAA;KACP,IAAIJ,eACFM,QAAOF,MACL,4DACAA,OACF;UAAC;MAEDJ,gBAAgBA;MAChBC,eAAeG;KAAH;IACb;IAGH,IAAIJ,eAAe,MAAMC;GAAa;EACvC;EACAN,KAAA;GAACV;GAAWG;GAAcC;EAAQ;EAACI,EAAA,KAAAR;EAAAQ,EAAA,KAAAJ;EAAAI,EAAA,KAAAL;EAAAK,EAAA,KAAAC;EAAAD,EAAA,KAAAE;CAAA,OAAA;EAAAD,KAAAD,EAAA;EAAAE,KAAAF,EAAA;CAAA;CAnCtCZ,UAAUa,IAmCPC,EAAmC;AAAC"}
|
|
1
|
+
{"version":3,"file":"useAssistantFrameHost.js","names":["c","_c","Unsubscribe","useEffect","RefObject","AssistantFrameHost","UseAssistantFrameHostOptions","iframeRef","Readonly","HTMLIFrameElement","targetOrigin","register","frameHost","useAssistantFrameHost","t0","$","t1","t2","iframeWindow","current","contentWindow","unsubscribe","cleanupFailed","cleanupError","dispose","t3","error","t4","console","_c"],"sources":["../../../src/model-context/frame/useAssistantFrameHost.ts"],"sourcesContent":["\"use client\";\n\nimport type { Unsubscribe } from \"@assistant-ui/core\";\nimport { useEffect, type RefObject } from \"react\";\nimport { AssistantFrameHost } from \"@assistant-ui/core\";\n\ntype UseAssistantFrameHostOptions = {\n iframeRef: Readonly<RefObject<HTMLIFrameElement | null | undefined>>;\n targetOrigin?: string;\n register: (frameHost: AssistantFrameHost) => Unsubscribe;\n};\n\n/**\n * React hook that manages the lifecycle of an AssistantFrameHost and its binding to the current AssistantRuntime.\n *\n * Usage example:\n * ```typescript\n * function MyComponent() {\n * const iframeRef = useRef<HTMLIFrameElement>(null);\n *\n * useAssistantFrameHost({\n * iframeRef,\n * targetOrigin: \"https://trusted-domain.com\",\n * });\n *\n * return <iframe ref={iframeRef} src=\"...\" />;\n * }\n * ```\n */\nexport const useAssistantFrameHost = ({\n iframeRef,\n targetOrigin,\n register,\n}: UseAssistantFrameHostOptions): void => {\n useEffect(() => {\n const iframeWindow = iframeRef.current?.contentWindow;\n if (!iframeWindow) return;\n\n const frameHost = new AssistantFrameHost(iframeWindow, targetOrigin);\n\n const unsubscribe = register(frameHost);\n\n return () => {\n let cleanupFailed = false;\n let cleanupError: unknown;\n\n try {\n frameHost.dispose();\n } catch (error) {\n cleanupFailed = true;\n cleanupError = error;\n }\n\n try {\n unsubscribe();\n } catch (error) {\n if (cleanupFailed) {\n console.error(\n \"[assistant-ui] AssistantFrameHost unregistration failed.\",\n error,\n );\n } else {\n cleanupFailed = true;\n cleanupError = error;\n }\n }\n\n if (cleanupFailed) throw cleanupError;\n };\n }, [iframeRef, targetOrigin, register]);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA6BA,MAAaa,yBAAwBC,OAAA;CAAA,MAAAC,IAAAd,EAAA,CAAA;CAAC,MAAA,EAAAM,WAAAG,cAAAC,aAAAG;CAIP,IAAAE;CAAA,IAAAC;CAAA,IAAAF,EAAA,OAAAR,aAAAQ,EAAA,OAAAJ,YAAAI,EAAA,OAAAL,cAAA;EACnBM,WAAA;GACR,MAAAE,eAAqBX,UAASY,SAAuBC;GACrD,IAAI,CAACF,cAAY;GAEjB,MAAAN,YAAkB,IAAIP,mBAAmBa,cAAcR,YAAY;GAEnE,MAAAW,cAAoBV,SAASC,SAAS;GAAE,aAEjC;IACL,IAAAU,gBAAoB;IAChBC,IAAAA;IAEJ,IAAA;KACEX,UAASY,QAAS;IAAC,SAAAC,IAAA;KACZC,MAAAA,QAAAA;KACPJ,gBAAgBA;KAChBC,eAAeG;IAAH;IAGd,IAAA;KACEL,YAAY;IAAC,SAAAM,IAAA;KACND,MAAAA,UAAAA;KACP,IAAIJ,eACFM,QAAOF,MACL,4DACAA,OACF;UAAC;MAEDJ,gBAAgBA;MAChBC,eAAeG;KAAH;IACb;IAGH,IAAIJ,eAAe,MAAMC;GAAa;EACvC;EACAN,KAAA;GAACV;GAAWG;GAAcC;EAAQ;EAACI,EAAA,KAAAR;EAAAQ,EAAA,KAAAJ;EAAAI,EAAA,KAAAL;EAAAK,EAAA,KAAAC;EAAAD,EAAA,KAAAE;CAAA,OAAA;EAAAD,KAAAD,EAAA;EAAAE,KAAAF,EAAA;CAAA;CAnCtCZ,UAAUa,IAmCPC,EAAmC;AAAC"}
|
|
@@ -2,6 +2,7 @@ import { type ComponentType } from "react";
|
|
|
2
2
|
export declare const makeAssistantVisible: <T extends ComponentType<any>>(Component: T, config?: {
|
|
3
3
|
clickable?: boolean | undefined;
|
|
4
4
|
editable?: boolean | undefined;
|
|
5
|
+
settleDelayMs?: number | undefined;
|
|
5
6
|
}) => T;
|
|
6
7
|
export default makeAssistantVisible;
|
|
7
8
|
//# sourceMappingURL=makeAssistantVisible.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"makeAssistantVisible.d.ts","sourceRoot":"","sources":["../../src/model-context/makeAssistantVisible.tsx"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,aAAa,EAMnB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"makeAssistantVisible.d.ts","sourceRoot":"","sources":["../../src/model-context/makeAssistantVisible.tsx"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,aAAa,EAMnB,MAAM,OAAO,CAAC;AAgGf,eAAO,MAAM,oBAAoB,GAAI,CAAC,SAAS,aAAa,CAAC,GAAG,CAAC,EAC/D,WAAW,CAAC,EACZ,SAAS;IACP,SAAS,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAChC,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC/B,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACpC,KA4DsC,CACxC,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -6,6 +6,17 @@ import { jsx } from "react/jsx-runtime";
|
|
|
6
6
|
import { tool } from "@assistant-ui/core";
|
|
7
7
|
import { useComposedRefs } from "radix-ui/internal";
|
|
8
8
|
//#region src/model-context/makeAssistantVisible.tsx
|
|
9
|
+
const DEFAULT_ACTION_SETTLE_DELAY_MS = 2e3;
|
|
10
|
+
const MAX_ACTION_SETTLE_DELAY_MS = 2147483647;
|
|
11
|
+
const waitForSettle = async (settleDelayMs) => {
|
|
12
|
+
const delay = Number.isFinite(settleDelayMs) && settleDelayMs >= 0 && settleDelayMs <= MAX_ACTION_SETTLE_DELAY_MS ? settleDelayMs : DEFAULT_ACTION_SETTLE_DELAY_MS;
|
|
13
|
+
if (delay === 0) return;
|
|
14
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
15
|
+
};
|
|
16
|
+
const readActionSettleDelay = (element) => {
|
|
17
|
+
const value = element.dataset.actionSettleDelay;
|
|
18
|
+
return value === void 0 || value.trim() === "" ? DEFAULT_ACTION_SETTLE_DELAY_MS : Number(value);
|
|
19
|
+
};
|
|
9
20
|
const click = tool({
|
|
10
21
|
parameters: {
|
|
11
22
|
type: "object",
|
|
@@ -17,7 +28,7 @@ const click = tool({
|
|
|
17
28
|
const el = document.querySelector(`[data-click-id='${escapedClickId}']`);
|
|
18
29
|
if (el instanceof HTMLElement) {
|
|
19
30
|
el.click();
|
|
20
|
-
await
|
|
31
|
+
await waitForSettle(readActionSettleDelay(el));
|
|
21
32
|
return {};
|
|
22
33
|
} else return "Element not found";
|
|
23
34
|
}
|
|
@@ -44,15 +55,17 @@ const edit = tool({
|
|
|
44
55
|
setNativeValue(el, value);
|
|
45
56
|
el.dispatchEvent(new Event("input", { bubbles: true }));
|
|
46
57
|
el.dispatchEvent(new Event("change", { bubbles: true }));
|
|
47
|
-
await
|
|
58
|
+
await waitForSettle(readActionSettleDelay(el));
|
|
48
59
|
return {};
|
|
49
60
|
} else return "Element not found";
|
|
50
61
|
}
|
|
51
62
|
});
|
|
52
63
|
const ReadableContext = createContext(false);
|
|
53
64
|
const makeAssistantVisible = (Component, config) => {
|
|
65
|
+
const settleDelayMs = config?.settleDelayMs ?? DEFAULT_ACTION_SETTLE_DELAY_MS;
|
|
66
|
+
if (!Number.isFinite(settleDelayMs) || settleDelayMs < 0 || settleDelayMs > MAX_ACTION_SETTLE_DELAY_MS) throw new RangeError(`settleDelayMs must be between 0 and ${MAX_ACTION_SETTLE_DELAY_MS}`);
|
|
54
67
|
const ReadableComponent = forwardRef((props, outerRef) => {
|
|
55
|
-
const $ = c(
|
|
68
|
+
const $ = c(16);
|
|
56
69
|
const isNestedReadable = useContext(ReadableContext);
|
|
57
70
|
const clickId = useId();
|
|
58
71
|
const componentRef = useRef(null);
|
|
@@ -104,23 +117,29 @@ const makeAssistantVisible = (Component, config) => {
|
|
|
104
117
|
t5 = $[9];
|
|
105
118
|
}
|
|
106
119
|
let t6;
|
|
107
|
-
if ($[10]
|
|
108
|
-
t6 =
|
|
120
|
+
if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
|
|
121
|
+
t6 = config?.settleDelayMs !== void 0 && (config.clickable || config.editable) ? { "data-action-settle-delay": settleDelayMs } : {};
|
|
122
|
+
$[10] = t6;
|
|
123
|
+
} else t6 = $[10];
|
|
124
|
+
let t7;
|
|
125
|
+
if ($[11] !== ref || $[12] !== t3 || $[13] !== t4 || $[14] !== t5) {
|
|
126
|
+
t7 = /* @__PURE__ */ jsx(ReadableContext.Provider, {
|
|
109
127
|
value: true,
|
|
110
128
|
children: /* @__PURE__ */ jsx(Component, {
|
|
111
129
|
...t3,
|
|
112
130
|
...t4,
|
|
113
131
|
...t5,
|
|
132
|
+
...t6,
|
|
114
133
|
ref
|
|
115
134
|
})
|
|
116
135
|
});
|
|
117
|
-
$[
|
|
118
|
-
$[
|
|
119
|
-
$[
|
|
120
|
-
$[
|
|
121
|
-
$[
|
|
122
|
-
} else
|
|
123
|
-
return
|
|
136
|
+
$[11] = ref;
|
|
137
|
+
$[12] = t3;
|
|
138
|
+
$[13] = t4;
|
|
139
|
+
$[14] = t5;
|
|
140
|
+
$[15] = t7;
|
|
141
|
+
} else t7 = $[15];
|
|
142
|
+
return t7;
|
|
124
143
|
});
|
|
125
144
|
ReadableComponent.displayName = Component.displayName;
|
|
126
145
|
return ReadableComponent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"makeAssistantVisible.js","names":["c","_c","useEffect","useRef","forwardRef","ComponentType","ForwardedRef","PropsWithoutRef","useId","createContext","useContext","useAui","useComposedRefs","tool","
|
|
1
|
+
{"version":3,"file":"makeAssistantVisible.js","names":["c","_c","useEffect","useRef","forwardRef","ComponentType","ForwardedRef","PropsWithoutRef","useId","createContext","useContext","useAui","useComposedRefs","tool","DEFAULT_ACTION_SETTLE_DELAY_MS","MAX_ACTION_SETTLE_DELAY_MS","waitForSettle","settleDelayMs","delay","Number","isFinite","Promise","resolve","setTimeout","readActionSettleDelay","element","HTMLElement","value","dataset","actionSettleDelay","undefined","trim","click","parameters","type","properties","clickId","required","execute","escapedClickId","CSS","escape","el","document","querySelector","setNativeValue","HTMLInputElement","HTMLTextAreaElement","prototype","setter","Object","getOwnPropertyDescriptor","set","call","edit","editId","escapedEditId","dispatchEvent","Event","bubbles","ReadableContext","makeAssistantVisible","Component","T","config","clickable","editable","RangeError","ReadableComponent","props","outerRef","$","isNestedReadable","componentRef","aui","t0","Symbol","for","t1","modelContext","register","getModelContext","tools","system","current","outerHTML","t2","ref","t3","t4","t5","t6","t7","displayName","_c"],"sources":["../../src/model-context/makeAssistantVisible.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n useEffect,\n useRef,\n forwardRef,\n type ComponentType,\n type ForwardedRef,\n type PropsWithoutRef,\n useId,\n createContext,\n useContext,\n} from \"react\";\nimport { useAui } from \"@assistant-ui/store\";\nimport { useComposedRefs } from \"radix-ui/internal\";\nimport { tool } from \"@assistant-ui/core\";\n\nconst DEFAULT_ACTION_SETTLE_DELAY_MS = 2000;\nconst MAX_ACTION_SETTLE_DELAY_MS = 2_147_483_647;\n\nconst waitForSettle = async (settleDelayMs: number) => {\n const delay =\n Number.isFinite(settleDelayMs) &&\n settleDelayMs >= 0 &&\n settleDelayMs <= MAX_ACTION_SETTLE_DELAY_MS\n ? settleDelayMs\n : DEFAULT_ACTION_SETTLE_DELAY_MS;\n if (delay === 0) return;\n await new Promise<void>((resolve) => setTimeout(resolve, delay));\n};\n\nconst readActionSettleDelay = (element: HTMLElement) => {\n const value = element.dataset.actionSettleDelay;\n return value === undefined || value.trim() === \"\"\n ? DEFAULT_ACTION_SETTLE_DELAY_MS\n : Number(value);\n};\n\nconst click = tool({\n parameters: {\n type: \"object\",\n properties: {\n clickId: {\n type: \"string\",\n },\n },\n required: [\"clickId\"],\n },\n execute: async ({ clickId }: { clickId: string }) => {\n const escapedClickId = CSS.escape(clickId);\n const el = document.querySelector(`[data-click-id='${escapedClickId}']`);\n if (el instanceof HTMLElement) {\n el.click();\n await waitForSettle(readActionSettleDelay(el));\n return {};\n } else {\n return \"Element not found\";\n }\n },\n});\n\nconst setNativeValue = (\n element: HTMLInputElement | HTMLTextAreaElement,\n value: string,\n) => {\n const prototype =\n element instanceof HTMLInputElement\n ? HTMLInputElement.prototype\n : HTMLTextAreaElement.prototype;\n const setter = Object.getOwnPropertyDescriptor(prototype, \"value\")?.set;\n\n if (setter) {\n setter.call(element, value);\n } else {\n element.value = value;\n }\n};\n\nconst edit = tool({\n parameters: {\n type: \"object\",\n properties: {\n editId: {\n type: \"string\",\n },\n value: {\n type: \"string\",\n },\n },\n required: [\"editId\", \"value\"],\n },\n execute: async ({ editId, value }: { editId: string; value: string }) => {\n const escapedEditId = CSS.escape(editId);\n const el = document.querySelector(`[data-edit-id='${escapedEditId}']`);\n if (el instanceof HTMLInputElement || el instanceof HTMLTextAreaElement) {\n setNativeValue(el, value);\n el.dispatchEvent(new Event(\"input\", { bubbles: true }));\n el.dispatchEvent(new Event(\"change\", { bubbles: true }));\n await waitForSettle(readActionSettleDelay(el));\n return {};\n } else {\n return \"Element not found\";\n }\n },\n});\n\nconst ReadableContext = createContext<boolean>(false);\n\nexport const makeAssistantVisible = <T extends ComponentType<any>>(\n Component: T,\n config?: {\n clickable?: boolean | undefined;\n editable?: boolean | undefined;\n settleDelayMs?: number | undefined;\n },\n) => {\n const settleDelayMs = config?.settleDelayMs ?? DEFAULT_ACTION_SETTLE_DELAY_MS;\n if (\n !Number.isFinite(settleDelayMs) ||\n settleDelayMs < 0 ||\n settleDelayMs > MAX_ACTION_SETTLE_DELAY_MS\n ) {\n throw new RangeError(\n `settleDelayMs must be between 0 and ${MAX_ACTION_SETTLE_DELAY_MS}`,\n );\n }\n\n const ReadableComponent = forwardRef(\n (props: PropsWithoutRef<T>, outerRef: ForwardedRef<any>) => {\n const isNestedReadable = useContext(ReadableContext);\n\n const clickId = useId();\n const componentRef = useRef<HTMLElement>(null);\n\n const aui = useAui();\n\n const { clickable, editable } = config ?? {};\n useEffect(() => {\n return aui.modelContext.register({\n getModelContext: () => {\n return {\n tools: {\n ...(clickable ? { click } : {}),\n ...(editable ? { edit } : {}),\n },\n system: !isNestedReadable // only pass content if this readable isn't nested in another readable\n ? componentRef.current?.outerHTML\n : undefined,\n };\n },\n });\n }, [isNestedReadable, aui, clickable, editable]);\n\n const ref = useComposedRefs(componentRef, outerRef);\n\n return (\n <ReadableContext.Provider value={true}>\n <Component\n {...(props as any)}\n {...(config?.clickable ? { \"data-click-id\": clickId } : {})}\n {...(config?.editable ? { \"data-edit-id\": clickId } : {})}\n {...(config?.settleDelayMs !== undefined &&\n (config.clickable || config.editable)\n ? { \"data-action-settle-delay\": settleDelayMs }\n : {})}\n ref={ref}\n />\n </ReadableContext.Provider>\n );\n },\n );\n\n ReadableComponent.displayName = Component.displayName;\n\n return ReadableComponent as unknown as T;\n};\n\nexport default makeAssistantVisible;\n"],"mappings":";;;;;;;;AAiBA,MAAMc,iCAAiC;AACvC,MAAMC,6BAA6B;AAEnC,MAAMC,gBAAgB,OAAOC,kBAA0B;CACrD,MAAMC,QACJC,OAAOC,SAASH,aAAa,KAC7BA,iBAAiB,KACjBA,iBAAiBF,6BACbE,gBACAH;CACN,IAAII,UAAU,GAAG;CACjB,MAAM,IAAIG,SAAeC,YAAYC,WAAWD,SAASJ,KAAK,CAAC;AACjE;AAEA,MAAMM,yBAAyBC,YAAyB;CACtD,MAAME,QAAQF,QAAQG,QAAQC;CAC9B,OAAOF,UAAUG,KAAAA,KAAaH,MAAMI,KAAK,MAAM,KAC3CjB,iCACAK,OAAOQ,KAAK;AAClB;AAEA,MAAMK,QAAQnB,KAAK;CACjBoB,YAAY;EACVC,MAAM;EACNC,YAAY,EACVC,SAAS,EACPF,MAAM,SACR,EACF;EACAG,UAAU,CAAC,SAAS;CACtB;CACAC,SAAS,OAAO,EAAEF,cAAmC;EACnD,MAAMG,iBAAiBC,IAAIC,OAAOL,OAAO;EACzC,MAAMM,KAAKC,SAASC,cAAc,mBAAmBL,eAAc,GAAI;EACvE,IAAIG,cAAchB,aAAa;GAC7BgB,GAAGV,MAAM;GACT,MAAMhB,cAAcQ,sBAAsBkB,EAAE,CAAC;GAC7C,OAAO,CAAC;EACV,OACE,OAAO;CAEX;AACF,CAAC;AAED,MAAMG,kBACJpB,SACAE,UACG;CACH,MAAMqB,YACJvB,mBAAmBqB,mBACfA,iBAAiBE,YACjBD,oBAAoBC;CAC1B,MAAMC,SAASC,OAAOC,yBAAyBH,WAAW,OAAO,CAAC,EAAEI;CAEpE,IAAIH,QACFA,OAAOI,KAAK5B,SAASE,KAAK;MAE1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D,OAAME,YADtB,EAAA,4BAE6BjD,cAC7B,IAHA,CAGA;GAACsD,EAAA,MAAAoB;EAAA,OAAAA,KAAApB,EAAA;EAAA,IAAAqB;EAAA,IAAArB,EAAA,QAAAgB,OAAAhB,EAAA,QAAAiB,MAAAjB,EAAA,QAAAkB,MAAAlB,EAAA,QAAAmB,IAAA;GARVE,KAAA,oBAAA,gBAAA,UAAA;IAAiC,OAAA;IAC/B,UAAA,oBAAC,WAAD;KAAU,GACHJ;KAAY,GACZC;KAAqD,GACrDC;KAAmD,GACnDC;KAIAJ;IAAG,CAAA;GAEZ,CAAA;GAA2BhB,EAAA,MAAAgB;GAAAhB,EAAA,MAAAiB;GAAAjB,EAAA,MAAAkB;GAAAlB,EAAA,MAAAmB;GAAAnB,EAAA,MAAAqB;EAAA,OAAAA,KAAArB,EAAA;EAAA,OAX3BqB;CAW2B,CAGjC;CAEAxB,kBAAkByB,cAAc/B,UAAU+B;CAE1C,OAAOzB;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionBarCopy.js","names":["c","_c","forwardRef","ActionButtonProps","composeEventHandlers","Primitive","useActionBarCopy","useAuiState","useActionBarPrimitiveCopy","t0","$","t1","undefined","copiedDuration","t2","t3","copyToClipboard","_temp","copy","disabled","ActionBarPrimitiveCopy","Element","HTMLButtonElement","Props","forwardedRef","onClick","props","isCopied","_temp2","callback","t4","t5","t6","displayName","text","navigator","clipboard","Promise","reject","Error","writeText","s","message"],"sources":["../../../src/primitives/actionBar/ActionBarCopy.tsx"],"sourcesContent":["\"use client\";\n\nimport { forwardRef } from \"react\";\nimport type { ActionButtonProps } from \"../../utils/createActionButton\";\nimport { composeEventHandlers } from \"radix-ui/internal\";\nimport { Primitive } from \"../../utils/Primitive\";\nimport { useActionBarCopy } from \"@assistant-ui/core/react\";\nimport { useAuiState } from \"@assistant-ui/store\";\n\n/**\n * Hook that provides copy functionality for action bar buttons.\n *\n * This hook returns a callback function that copies message content to the clipboard,\n * or null if copying is not available. It handles both regular message content and\n * composer text when in editing mode.\n *\n * @param options Configuration options\n * @param options.copiedDuration Duration in milliseconds to show the copied state\n * @returns A copy callback function, or null if copying is disabled\n *\n * @example\n * ```tsx\n * function CustomCopyButton() {\n * const copy = useActionBarPrimitiveCopy({ copiedDuration: 2000 });\n *\n * return (\n * <button onClick={copy} disabled={!copy}>\n * {copy ? \"Copy\" : \"Cannot Copy\"}\n * </button>\n * );\n * }\n * ```\n */\nconst useActionBarPrimitiveCopy = ({\n copiedDuration = 3000,\n}: {\n copiedDuration?: number | undefined;\n} = {}) => {\n const { copy, disabled } = useActionBarCopy({\n copiedDuration,\n copyToClipboard: (text) => {\n if (typeof navigator === \"undefined\" || !navigator.clipboard) {\n return Promise.reject(new Error(\"Clipboard API is unavailable\"));\n }\n return navigator.clipboard.writeText(text);\n },\n });\n if (disabled) return null;\n return copy;\n};\n\nexport namespace ActionBarPrimitiveCopy {\n export type Element = HTMLButtonElement;\n /**\n * Props for the ActionBarPrimitive.Copy component.\n * Inherits all button element props and action button functionality.\n */\n export type Props = ActionButtonProps<typeof useActionBarPrimitiveCopy>;\n}\n\n/**\n * A button component that copies message content to the clipboard.\n *\n * This component automatically handles copying message text to the clipboard\n * and provides visual feedback through the data-copied attribute. It's disabled\n * when there's no copyable content available.\n *\n * @example\n * ```tsx\n * <ActionBarPrimitive.Copy copiedDuration={2000}>\n * Copy Message\n * </ActionBarPrimitive.Copy>\n * ```\n */\nexport const ActionBarPrimitiveCopy = forwardRef<\n ActionBarPrimitiveCopy.Element,\n ActionBarPrimitiveCopy.Props\n>(({ copiedDuration, onClick, disabled, ...props }, forwardedRef) => {\n const isCopied = useAuiState((s) => s.message.isCopied);\n const callback = useActionBarPrimitiveCopy({ copiedDuration });\n return (\n <Primitive.button\n type=\"button\"\n {...(isCopied ? { \"data-copied\": \"true\" } : {})}\n {...props}\n ref={forwardedRef}\n disabled={disabled || !callback}\n onClick={composeEventHandlers(onClick, () => {\n callback?.();\n })}\n />\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E,eAAiB;EAACH,EAAA,KAAAG;EAAAH,EAAA,KAAAC;CAAA,OAAAA,KAAAD,EAAA;CAA7D,MAAAmB,WAAiBrB,0BAA0BG,EAAkB;CAAE,IAAAG;CAAA,IAAAJ,EAAA,OAAAiB,UAAA;EAItDb,KAAAa,WAAA,EAAA,eAA4B,OAAY,IAAxC,CAAwC;EAACjB,EAAA,KAAAiB;EAAAjB,EAAA,KAAAI;CAAA,OAAAA,KAAAJ,EAAA;CAGpC,MAAAK,KAAAI,YAAA,CAAaU;CAAQ,IAAAC;CAAA,IAAApB,EAAA,OAAAmB,UAAA;EACQC,WAAA;GACrCD,WAAW;EAAC;EACbnB,EAAA,KAAAmB;EAAAnB,EAAA,MAAAoB;CAAA,OAAAA,KAAApB,EAAA;CAAA,IAAAqB;CAAA,IAAArB,EAAA,QAAAe,WAAAf,EAAA,QAAAoB,IAAA;EAFQC,KAAA3B,qBAAqBqB,SAASK,EAEtC;EAACpB,EAAA,MAAAe;EAAAf,EAAA,MAAAoB;EAAApB,EAAA,MAAAqB;CAAA,OAAAA,KAAArB,EAAA;CAAA,IAAAsB;CAAA,IAAAtB,EAAA,QAAAc,gBAAAd,EAAA,QAAAgB,SAAAhB,EAAA,QAAAI,MAAAJ,EAAA,QAAAK,MAAAL,EAAA,QAAAqB,IAAA;EARJC,KAAA,
|
|
1
|
+
{"version":3,"file":"ActionBarCopy.js","names":["c","_c","forwardRef","ActionButtonProps","composeEventHandlers","Primitive","useActionBarCopy","useAuiState","useActionBarPrimitiveCopy","t0","$","t1","undefined","copiedDuration","t2","t3","copyToClipboard","_temp","copy","disabled","ActionBarPrimitiveCopy","Element","HTMLButtonElement","Props","forwardedRef","onClick","props","isCopied","_temp2","callback","t4","t5","t6","displayName","text","navigator","clipboard","Promise","reject","Error","writeText","s","message","_c","Primitive"],"sources":["../../../src/primitives/actionBar/ActionBarCopy.tsx"],"sourcesContent":["\"use client\";\n\nimport { forwardRef } from \"react\";\nimport type { ActionButtonProps } from \"../../utils/createActionButton\";\nimport { composeEventHandlers } from \"radix-ui/internal\";\nimport { Primitive } from \"../../utils/Primitive\";\nimport { useActionBarCopy } from \"@assistant-ui/core/react\";\nimport { useAuiState } from \"@assistant-ui/store\";\n\n/**\n * Hook that provides copy functionality for action bar buttons.\n *\n * This hook returns a callback function that copies message content to the clipboard,\n * or null if copying is not available. It handles both regular message content and\n * composer text when in editing mode.\n *\n * @param options Configuration options\n * @param options.copiedDuration Duration in milliseconds to show the copied state\n * @returns A copy callback function, or null if copying is disabled\n *\n * @example\n * ```tsx\n * function CustomCopyButton() {\n * const copy = useActionBarPrimitiveCopy({ copiedDuration: 2000 });\n *\n * return (\n * <button onClick={copy} disabled={!copy}>\n * {copy ? \"Copy\" : \"Cannot Copy\"}\n * </button>\n * );\n * }\n * ```\n */\nconst useActionBarPrimitiveCopy = ({\n copiedDuration = 3000,\n}: {\n copiedDuration?: number | undefined;\n} = {}) => {\n const { copy, disabled } = useActionBarCopy({\n copiedDuration,\n copyToClipboard: (text) => {\n if (typeof navigator === \"undefined\" || !navigator.clipboard) {\n return Promise.reject(new Error(\"Clipboard API is unavailable\"));\n }\n return navigator.clipboard.writeText(text);\n },\n });\n if (disabled) return null;\n return copy;\n};\n\nexport namespace ActionBarPrimitiveCopy {\n export type Element = HTMLButtonElement;\n /**\n * Props for the ActionBarPrimitive.Copy component.\n * Inherits all button element props and action button functionality.\n */\n export type Props = ActionButtonProps<typeof useActionBarPrimitiveCopy>;\n}\n\n/**\n * A button component that copies message content to the clipboard.\n *\n * This component automatically handles copying message text to the clipboard\n * and provides visual feedback through the data-copied attribute. It's disabled\n * when there's no copyable content available.\n *\n * @example\n * ```tsx\n * <ActionBarPrimitive.Copy copiedDuration={2000}>\n * Copy Message\n * </ActionBarPrimitive.Copy>\n * ```\n */\nexport const ActionBarPrimitiveCopy = forwardRef<\n ActionBarPrimitiveCopy.Element,\n ActionBarPrimitiveCopy.Props\n>(({ copiedDuration, onClick, disabled, ...props }, forwardedRef) => {\n const isCopied = useAuiState((s) => s.message.isCopied);\n const callback = useActionBarPrimitiveCopy({ copiedDuration });\n return (\n <Primitive.button\n type=\"button\"\n {...(isCopied ? { \"data-copied\": \"true\" } : {})}\n {...props}\n ref={forwardedRef}\n disabled={disabled || !callback}\n onClick={composeEventHandlers(onClick, () => {\n callback?.();\n })}\n />\n );\n});\n\nActionBarPrimitiveCopy.displayName = \"ActionBarPrimitive.Copy\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,MAAMQ,6BAA4BC,OAAA;CAAA,MAAAC,IAAAT,EAAA,CAAA;CAAA,IAAAU;CAAA,IAAAD,EAAA,OAAAD,IAAA;EAACE,KAAAF,OAAAG,KAAAA,IAAA,CAI9B,IAJ8BH;EAI7BC,EAAA,KAAAD;EAAAC,EAAA,KAAAC;CAAA,OAAAA,KAAAD,EAAA;CAJ6B,MAAA,EAAAG,gBAAAC,OAAAH;CACjC,MAAAE,iBAAAC,OAAAF,KAAAA,IAAA,MAAAE;CAAqB,IAAAC;CAAA,IAAAL,EAAA,OAAAG,gBAAA;EAIuBE,KAAA;GAAAF;GAAAG,iBAEzBC;EAMnB;EAACP,EAAA,KAAAG;EAAAH,EAAA,KAAAK;CAAA,OAAAA,KAAAL,EAAA;CARD,MAAA,EAAAQ,MAAAC,aAA2Bb,iBAAiBS,EAQ3C;CACD,IAAII,UAAQ,OAAS;CAAK,OACnBD;AAAI;;;;;;;;;;;;;;;AA0Bb,MAAaE,yBAAyBlB,YAGpCO,IAAAe,iBAAA;CAAA,MAAAd,IAAAT,EAAA,EAAA;CAAA,IAAAY;CAAA,IAAAM;CAAA,IAAAM;CAAA,IAAAC;CAAA,IAAAhB,EAAA,OAAAD,IAAA;EAAC,CAAA,CAAAI,gBAAAY,SAAAN,UAAA,GAAAO,SAAAjB;EAA+CC,EAAA,KAAAD;EAAAC,EAAA,KAAAG;EAAAH,EAAA,KAAAS;EAAAT,EAAA,KAAAe;EAAAf,EAAA,KAAAgB;C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L,EAAA,MAAAqB;EAAArB,EAAA,MAAAsB;CAAA,OAAAA,KAAAtB,EAAA;CAAA,OATFsB;AASE,CAEL;AAEDZ,uBAAuBa,cAAc;AA7DH,SAAAhB,MAAAiB,MAAA;CAQ5B,IAAI,OAAOC,cAAc,eAArB,CAAqCA,UAASC,WAAU,OACnDC,QAAOC,uBAAQ,IAAIC,MAAM,8BAA8B,CAAC;CAChE,OACMJ,UAASC,UAAUI,UAAWN,IAAI;AAAC;AAiC9C,SAAAN,OAAAa,GAAA;CAAA,OACoCA,EAACC,QAAQf;AAAS"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionBarEdit.js","names":["ActionButtonElement","ActionButtonProps","createActionButton","useActionBarEdit","useActionBarEditBehavior","disabled","edit","ActionBarPrimitiveEdit","Element","Props"],"sources":["../../../src/primitives/actionBar/ActionBarEdit.ts"],"sourcesContent":["\"use client\";\n\nimport {\n type ActionButtonElement,\n type ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useActionBarEdit as useActionBarEditBehavior } from \"@assistant-ui/core/react\";\n\n/**\n * Hook that provides edit functionality for action bar buttons.\n *\n * This hook returns a callback function that starts editing the current message,\n * or null if editing is not available (e.g., already in editing mode).\n *\n * @returns An edit callback function, or null if editing is disabled\n *\n * @example\n * ```tsx\n * function CustomEditButton() {\n * const edit = useActionBarEdit();\n *\n * return (\n * <button onClick={edit} disabled={!edit}>\n * {edit ? \"Edit Message\" : \"Cannot Edit\"}\n * </button>\n * );\n * }\n * ```\n */\nconst useActionBarEdit = () => {\n const { disabled, edit } = useActionBarEditBehavior();\n if (disabled) return null;\n return edit;\n};\n\nexport namespace ActionBarPrimitiveEdit {\n export type Element = ActionButtonElement;\n /**\n * Props for the ActionBarPrimitive.Edit component.\n * Inherits all button element props and action button functionality.\n */\n export type Props = ActionButtonProps<typeof useActionBarEdit>;\n}\n\n/**\n * A button component that starts editing the current message.\n *\n * This component automatically handles starting the edit mode for the current message\n * and is disabled when editing is not available (e.g., already in editing mode).\n *\n * @example\n * ```tsx\n * <ActionBarPrimitive.Edit>\n * Edit Message\n * </ActionBarPrimitive.Edit>\n * ```\n */\nexport const ActionBarPrimitiveEdit = createActionButton(\n \"ActionBarPrimitive.Edit\",\n useActionBarEdit,\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAMG,2BAAmB;CACvB,MAAA,EAAAE,UAAAC,SAA2BF,iBAAyB;CACpD,IAAIC,UAAQ,OAAS;CAAK,OACnBC;AAAI;;;;;;;;;;;;;;AAyBb,MAAaC,yBAAyBL,mBACpC,2BACAC,kBACF"}
|
|
1
|
+
{"version":3,"file":"ActionBarEdit.js","names":["ActionButtonElement","ActionButtonProps","createActionButton","useActionBarEdit","useActionBarEditBehavior","disabled","edit","ActionBarPrimitiveEdit","Element","Props","useActionBarEdit","useActionBarEditBehavior"],"sources":["../../../src/primitives/actionBar/ActionBarEdit.ts"],"sourcesContent":["\"use client\";\n\nimport {\n type ActionButtonElement,\n type ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useActionBarEdit as useActionBarEditBehavior } from \"@assistant-ui/core/react\";\n\n/**\n * Hook that provides edit functionality for action bar buttons.\n *\n * This hook returns a callback function that starts editing the current message,\n * or null if editing is not available (e.g., already in editing mode).\n *\n * @returns An edit callback function, or null if editing is disabled\n *\n * @example\n * ```tsx\n * function CustomEditButton() {\n * const edit = useActionBarEdit();\n *\n * return (\n * <button onClick={edit} disabled={!edit}>\n * {edit ? \"Edit Message\" : \"Cannot Edit\"}\n * </button>\n * );\n * }\n * ```\n */\nconst useActionBarEdit = () => {\n const { disabled, edit } = useActionBarEditBehavior();\n if (disabled) return null;\n return edit;\n};\n\nexport namespace ActionBarPrimitiveEdit {\n export type Element = ActionButtonElement;\n /**\n * Props for the ActionBarPrimitive.Edit component.\n * Inherits all button element props and action button functionality.\n */\n export type Props = ActionButtonProps<typeof useActionBarEdit>;\n}\n\n/**\n * A button component that starts editing the current message.\n *\n * This component automatically handles starting the edit mode for the current message\n * and is disabled when editing is not available (e.g., already in editing mode).\n *\n * @example\n * ```tsx\n * <ActionBarPrimitive.Edit>\n * Edit Message\n * </ActionBarPrimitive.Edit>\n * ```\n */\nexport const ActionBarPrimitiveEdit = createActionButton(\n \"ActionBarPrimitive.Edit\",\n useActionBarEdit,\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAMG,2BAAmB;CACvB,MAAA,EAAAE,UAAAC,SAA2BF,iBAAyB;CACpD,IAAIC,UAAQ,OAAS;CAAK,OACnBC;AAAI;;;;;;;;;;;;;;AAyBb,MAAaC,yBAAyBL,mBACpC,2BACAC,kBACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionBarExportMarkdown.js","names":["c","_c","forwardRef","useCallback","ActionButtonProps","composeEventHandlers","Primitive","useAuiState","useAui","useActionBarExportMarkdown","t0","$","t1","undefined","filename","onExport","aui","hasExportableContent","_temp2","t2","message","content","getCopyText","blob","Blob","type","url","URL","createObjectURL","a","document","createElement","href","download","Date","now","rel","body","appendChild","click","removeChild","setTimeout","revokeObjectURL","callback","ActionBarPrimitiveExportMarkdown","Element","HTMLButtonElement","Props","forwardedRef","disabled","onClick","props","t3","catch","_temp3","t4","t5","displayName","_temp","text","length","s","role","status","parts","some","error","console"],"sources":["../../../src/primitives/actionBar/ActionBarExportMarkdown.tsx"],"sourcesContent":["\"use client\";\n\nimport { forwardRef, useCallback } from \"react\";\nimport type { ActionButtonProps } from \"../../utils/createActionButton\";\nimport { composeEventHandlers } from \"radix-ui/internal\";\nimport { Primitive } from \"../../utils/Primitive\";\nimport { useAuiState, useAui } from \"@assistant-ui/store\";\n\nconst useActionBarExportMarkdown = ({\n filename,\n onExport,\n}: {\n filename?: string | undefined;\n onExport?: ((content: string) => void | Promise<void>) | undefined;\n} = {}) => {\n const aui = useAui();\n const hasExportableContent = useAuiState((s) => {\n return (\n (s.message.role !== \"assistant\" ||\n s.message.status?.type !== \"running\") &&\n s.message.parts.some((c) => c.type === \"text\" && c.text.length > 0)\n );\n });\n\n const callback = useCallback(async () => {\n const content = aui.message.getCopyText();\n if (!content) return;\n\n if (onExport) {\n await onExport(content);\n return;\n }\n\n const blob = new Blob([content], { type: \"text/markdown\" });\n const url = URL.createObjectURL(blob);\n const a = document.createElement(\"a\");\n a.href = url;\n a.download = filename ?? `message-${Date.now()}.md`;\n a.rel = \"noopener\";\n // Firefox starts a download only for an anchor that is in the document.\n document.body.appendChild(a);\n a.click();\n document.body.removeChild(a);\n setTimeout(() => URL.revokeObjectURL(url), 40_000);\n }, [aui, filename, onExport]);\n\n if (!hasExportableContent) return null;\n return callback;\n};\n\nexport namespace ActionBarPrimitiveExportMarkdown {\n export type Element = HTMLButtonElement;\n export type Props = ActionButtonProps<typeof useActionBarExportMarkdown>;\n}\n\nexport const ActionBarPrimitiveExportMarkdown = forwardRef<\n ActionBarPrimitiveExportMarkdown.Element,\n ActionBarPrimitiveExportMarkdown.Props\n>(({ filename, onExport, onClick, disabled, ...props }, forwardedRef) => {\n const callback = useActionBarExportMarkdown({ filename, onExport });\n return (\n <Primitive.button\n type=\"button\"\n {...props}\n ref={forwardedRef}\n disabled={disabled || !callback}\n onClick={composeEventHandlers(onClick, () => {\n void callback?.().catch((error: unknown) => {\n console.error(\"[assistant-ui] markdown export failed:\", error);\n });\n })}\n />\n );\n});\n\nActionBarPrimitiveExportMarkdown.displayName =\n \"ActionBarPrimitive.ExportMarkdown\";\n"],"mappings":";;;;;;;;AAQA,MAAMS,8BAA6BC,OAAA;CAAA,MAAAC,IAAAV,EAAA,CAAA;CAAA,IAAAW;CAAA,IAAAD,EAAA,OAAAD,IAAA;EAACE,KAAAF,OAAAG,KAAAA,IAAA,CAM/B,IAN+BH;EAM9BC,EAAA,KAAAD;EAAAC,EAAA,KAAAC;CAAA,OAAAA,KAAAD,EAAA;CAN8B,MAAA,EAAAG,UAAAC,aAAAH;CAOlC,MAAA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AAAuC;EAAAvC,EAAA,KAAAI;EAAAJ,EAAA,KAAAwC;CAAA,OAAA;EAAAF,WAAAtC,EAAA;EAAAG,WAAAH,EAAA;EAAAuC,UAAAvC,EAAA;EAAAI,WAAAJ,EAAA;EAAAwC,QAAAxC,EAAA;CAAA;CAAA,IAAAC;CAAA,IAAAD,EAAA,OAAAG,YAAAH,EAAA,OAAAI,UAAA;EACRH,KAAA;GAAAE;GAAAC;EAAqB;EAACJ,EAAA,KAAAG;EAAAH,EAAA,KAAAI;EAAAJ,EAAA,KAAAC;CAAA,OAAAA,KAAAD,EAAA;CAAlE,MAAAgC,WAAiBlC,2BAA2BG,EAAsB;CAMpD,MAAAO,KAAA8B,YAAA,CAAaN;CAAQ,IAAAS;CAAA,IAAAzC,EAAA,OAAAgC,UAAA;EACQS,WAAA;GAChCT,WAAiB,CAAC,CAAAU,MAACC,MAEvB;EAAC;EACH3C,EAAA,KAAAgC;EAAAhC,EAAA,MAAAyC;CAAA,OAAAA,KAAAzC,EAAA;CAAA,IAAA4C;CAAA,IAAA5C,EAAA,QAAAuC,WAAAvC,EAAA,QAAAyC,IAAA;EAJQG,KAAAlD,qBAAqB6C,SAASE,EAItC;EAACzC,EAAA,MAAAuC;EAAAvC,EAAA,MAAAyC;EAAAzC,EAAA,MAAA4C;CAAA,OAAAA,KAAA5C,EAAA;CAAA,IAAA6C;CAAA,IAAA7C,EAAA,QAAAqC,gBAAArC,EAAA,QAAAwC,SAAAxC,EAAA,QAAAQ,MAAAR,EAAA,QAAA4C,IAAA;EATJC,KAAA,
|
|
1
|
+
{"version":3,"file":"ActionBarExportMarkdown.js","names":["c","_c","forwardRef","useCallback","ActionButtonProps","composeEventHandlers","Primitive","useAuiState","useAui","useActionBarExportMarkdown","t0","$","t1","undefined","filename","onExport","aui","hasExportableContent","_temp2","t2","message","content","getCopyText","blob","Blob","type","url","URL","createObjectURL","a","document","createElement","href","download","Date","now","rel","body","appendChild","click","removeChild","setTimeout","revokeObjectURL","callback","ActionBarPrimitiveExportMarkdown","Element","HTMLButtonElement","Props","forwardedRef","disabled","onClick","props","t3","catch","_temp3","t4","t5","displayName","_temp","text","length","s","role","status","parts","some","error","console","_c","Primitive"],"sources":["../../../src/primitives/actionBar/ActionBarExportMarkdown.tsx"],"sourcesContent":["\"use client\";\n\nimport { forwardRef, useCallback } from \"react\";\nimport type { ActionButtonProps } from \"../../utils/createActionButton\";\nimport { composeEventHandlers } from \"radix-ui/internal\";\nimport { Primitive } from \"../../utils/Primitive\";\nimport { useAuiState, useAui } from \"@assistant-ui/store\";\n\nconst useActionBarExportMarkdown = ({\n filename,\n onExport,\n}: {\n filename?: string | undefined;\n onExport?: ((content: string) => void | Promise<void>) | undefined;\n} = {}) => {\n const aui = useAui();\n const hasExportableContent = useAuiState((s) => {\n return (\n (s.message.role !== \"assistant\" ||\n s.message.status?.type !== \"running\") &&\n s.message.parts.some((c) => c.type === \"text\" && c.text.length > 0)\n );\n });\n\n const callback = useCallback(async () => {\n const content = aui.message.getCopyText();\n if (!content) return;\n\n if (onExport) {\n await onExport(content);\n return;\n }\n\n const blob = new Blob([content], { type: \"text/markdown\" });\n const url = URL.createObjectURL(blob);\n const a = document.createElement(\"a\");\n a.href = url;\n a.download = filename ?? `message-${Date.now()}.md`;\n a.rel = \"noopener\";\n // Firefox starts a download only for an anchor that is in the document.\n document.body.appendChild(a);\n a.click();\n document.body.removeChild(a);\n setTimeout(() => URL.revokeObjectURL(url), 40_000);\n }, [aui, filename, onExport]);\n\n if (!hasExportableContent) return null;\n return callback;\n};\n\nexport namespace ActionBarPrimitiveExportMarkdown {\n export type Element = HTMLButtonElement;\n export type Props = ActionButtonProps<typeof useActionBarExportMarkdown>;\n}\n\nexport const ActionBarPrimitiveExportMarkdown = forwardRef<\n ActionBarPrimitiveExportMarkdown.Element,\n ActionBarPrimitiveExportMarkdown.Props\n>(({ filename, onExport, onClick, disabled, ...props }, forwardedRef) => {\n const callback = useActionBarExportMarkdown({ filename, onExport });\n return (\n <Primitive.button\n type=\"button\"\n {...props}\n ref={forwardedRef}\n disabled={disabled || !callback}\n onClick={composeEventHandlers(onClick, () => {\n void callback?.().catch((error: unknown) => {\n console.error(\"[assistant-ui] markdown export failed:\", error);\n });\n })}\n />\n );\n});\n\nActionBarPrimitiveExportMarkdown.displayName =\n \"ActionBarPrimitive.ExportMarkdown\";\n"],"mappings":";;;;;;;;AAQA,MAAMS,8BAA6BC,OAAA;CAAA,MAAAC,IAAAV,EAAA,CAAA;CAAA,IAAAW;CAAA,IAAAD,EAAA,OAAAD,IAAA;EAACE,KAAAF,OAAAG,KAAAA,IAAA,CAM/B,IAN+BH;EAM9BC,EAAA,KAAAD;EAAAC,EAAA,KAAAC;CAAA,OAAAA,KAAAD,EAAA;CAN8B,MAAA,EAAAG,UAAAC,aAAAH;CAOlC,MAAAI,MAAYR,OAAO;CACnB,MAAAS,uBAA6BV,YAAYW,MAMxC;CAAE,IAAAC;CAAA,IAAAR,EAAA,OAAAK,IAAAI,WAAAT,EAAA,OAAAG,YAAAH,EAAA,OAAAI,UAAA;EAE0BI,KAAA,YAAA;GAC3B,MAAAE,UAAgBL,IAAGI,QAAQE,YAAa;GACxC,IAAI,CAACD,SAAO;GAEZ,IAAIN,UAAQ;IACV,MAAMA,SAASM,OAAO;IAAC;GAAA;GAIzB,MAAAE,OAAa,IAAIC,KAAK,CAACH,OAAO,GAAG,EAAAI,MAAQ,gBAAgB,CAAC;GAC1D,MAAAC,MAAYC,IAAGC,gBAAiBL,IAAI;GACpC,MAAAM,IAAUC,SAAQC,cAAe,GAAG;GACpCF,EAACG,OAAQN;GACTG,EAACI,WAAYnB,YAAA,WAAuBoB,KAAIC,IAAK,EAAC;GAC9CN,EAACO,MAAO;GAERN,SAAQO,KAAKC,YAAaT,CAAC;GAC3BA,EAACU,MAAO;GACRT,SAAQO,KAAKG,YAAaX,CAAC;GAC3BY,iBAAiBd,IAAGe,gBAAiBhB,GAAG,GAAG,GAAM;EAAC;EACnDf,EAAA,KAAAK,IAA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SAASE,EAItC;EAACzC,EAAA,MAAAuC;EAAAvC,EAAA,MAAAyC;EAAAzC,EAAA,MAAA4C;CAAA,OAAAA,KAAA5C,EAAA;CAAA,IAAA6C;CAAA,IAAA7C,EAAA,QAAAqC,gBAAArC,EAAA,QAAAwC,SAAAxC,EAAA,QAAAQ,MAAAR,EAAA,QAAA4C,IAAA;EATJC,KAAA,oBAAAa,YAAA,QAAA;GACO,MAAA;GAAQ,GACTlB;GACCH,KAAAA;GACK,UAAA7B;GACD,SAAAoC;EAIP,CAAA;EACF5C,EAAA,MAAAqC;EAAArC,EAAA,MAAAwC;EAAAxC,EAAA,MAAAQ;EAAAR,EAAA,MAAA4C;EAAA5C,EAAA,MAAA6C;CAAA,OAAAA,KAAA7C,EAAA;CAAA,OAVF6C;AAUE,CAEL;AAEDZ,iCAAiCa,cAC/B;AApEiC,SAAAC,MAAA1D,GAAA;CAAA,OAYDA,EAACyB,SAAU,UAAUzB,EAAC2D,KAAKC,SAAU;AAAC;AAZrC,SAAA1C,OAAA2C,GAAA;CAAA,QAU5BA,EAACzC,QAAQ0C,SAAU,eAClBD,EAACzC,QAAQ2C,QAAatC,SAAK,cAC7BoC,EAACzC,QAAQ4C,MAAMC,KAAMP,KAA6C;AAAC;AAsCvE,SAAAJ,OAAAY,OAAA;CAUQC,QAAOD,MAAO,0CAA0CA,KAAK;AAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionBarFeedbackNegative.js","names":["c","_c","forwardRef","ActionButtonProps","composeEventHandlers","Primitive","useAuiState","useActionBarFeedbackNegative","useActionBarFeedbackNegativeBehavior","submit","ActionBarPrimitiveFeedbackNegative","Element","HTMLButtonElement","Props","t0","forwardedRef","$","disabled","onClick","props","isSubmitted","_temp","callback","t1","t2","t3","t4","t5","displayName","s","message","metadata","submittedFeedback","type"],"sources":["../../../src/primitives/actionBar/ActionBarFeedbackNegative.tsx"],"sourcesContent":["\"use client\";\n\nimport { forwardRef } from \"react\";\nimport type { ActionButtonProps } from \"../../utils/createActionButton\";\nimport { composeEventHandlers } from \"radix-ui/internal\";\nimport { Primitive } from \"../../utils/Primitive\";\nimport { useAuiState } from \"@assistant-ui/store\";\nimport { useActionBarFeedbackNegative as useActionBarFeedbackNegativeBehavior } from \"@assistant-ui/core/react\";\n\nconst useActionBarFeedbackNegative = () => {\n const { submit } = useActionBarFeedbackNegativeBehavior();\n return submit;\n};\n\nexport namespace ActionBarPrimitiveFeedbackNegative {\n export type Element = HTMLButtonElement;\n export type Props = ActionButtonProps<typeof useActionBarFeedbackNegative>;\n}\n\nexport const ActionBarPrimitiveFeedbackNegative = forwardRef<\n ActionBarPrimitiveFeedbackNegative.Element,\n ActionBarPrimitiveFeedbackNegative.Props\n>(({ onClick, disabled, ...props }, forwardedRef) => {\n const isSubmitted = useAuiState(\n (s) => s.message.metadata.submittedFeedback?.type === \"negative\",\n );\n const callback = useActionBarFeedbackNegative();\n return (\n <Primitive.button\n type=\"button\"\n aria-pressed={isSubmitted}\n {...(isSubmitted ? { \"data-submitted\": \"true\" } : {})}\n {...props}\n ref={forwardedRef}\n disabled={disabled || !callback}\n onClick={composeEventHandlers(onClick, () => {\n callback?.();\n })}\n />\n );\n});\n\nActionBarPrimitiveFeedbackNegative.displayName =\n \"ActionBarPrimitive.FeedbackNegative\";\n"],"mappings":";;;;;;;;;AASA,MAAMO,uCAA+B;CACnC,MAAA,EAAAE,WAAmBD,6BAAqC;CAAE,OACnDC;AAAM;AAQf,MAAaC,qCAAqCR,YAGhDY,IAAAC,iBAAA;CAAA,MAAAC,IAAAf,EAAA,EAAA;CAAA,IAAAgB;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAH,EAAA,OAAAF,IAAA;EAAC,CAAA,CAAAI,SAAAD,UAAA,GAAAE,SAAAL;EAA+BE,EAAA,KAAAF;EAAAE,EAAA,KAAAC;EAAAD,EAAA,KAAAE;EAAAF,EAAA,KAAAG;CAAA,OAAA;EAAAF,WAAAD,EAAA;EAAAE,UAAAF,EAAA;EAAAG,QAAAH,EAAA;CAAA;CAChC,MAAAI,cAAoBd,YAClBe,KACF;CACA,MAAAC,WAAiBf,+BAA6B;CAAE,IAAAgB;CAAA,IAAAP,EAAA,OAAAI,aAAA;EAKvCG,KAAAH,cAAA,EAAA,kBAAkC,OAAY,IAA9C,CAA8C;EAACJ,EAAA,KAAAI;EAAAJ,EAAA,KAAAO;CAAA,OAAAA,KAAAP,EAAA;CAG1C,MAAAQ,KAAAP,YAAA,CAAaK;CAAQ,IAAAG;CAAA,IAAAT,EAAA,OAAAM,UAAA;EACQG,WAAA;GACrCH,WAAW;EAAC;EACbN,EAAA,KAAAM;EAAAN,EAAA,KAAAS;CAAA,OAAAA,KAAAT,EAAA;CAAA,IAAAU;CAAA,IAAAV,EAAA,OAAAE,WAAAF,EAAA,OAAAS,IAAA;EAFQC,KAAAtB,qBAAqBc,SAASO,EAEtC;EAACT,EAAA,KAAAE;EAAAF,EAAA,KAAAS;EAAAT,EAAA,MAAAU;CAAA,OAAAA,KAAAV,EAAA;CAAA,IAAAW;CAAA,IAAAX,EAAA,QAAAD,gBAAAC,EAAA,QAAAI,eAAAJ,EAAA,QAAAG,SAAAH,EAAA,QAAAO,MAAAP,EAAA,QAAAQ,MAAAR,EAAA,QAAAU,IAAA;EATJC,KAAA,
|
|
1
|
+
{"version":3,"file":"ActionBarFeedbackNegative.js","names":["c","_c","forwardRef","ActionButtonProps","composeEventHandlers","Primitive","useAuiState","useActionBarFeedbackNegative","useActionBarFeedbackNegativeBehavior","submit","ActionBarPrimitiveFeedbackNegative","Element","HTMLButtonElement","Props","t0","forwardedRef","$","disabled","onClick","props","isSubmitted","_temp","callback","t1","t2","t3","t4","t5","displayName","s","message","metadata","submittedFeedback","type","useActionBarFeedbackNegative","useActionBarFeedbackNegativeBehavior","_c","Primitive"],"sources":["../../../src/primitives/actionBar/ActionBarFeedbackNegative.tsx"],"sourcesContent":["\"use client\";\n\nimport { forwardRef } from \"react\";\nimport type { ActionButtonProps } from \"../../utils/createActionButton\";\nimport { composeEventHandlers } from \"radix-ui/internal\";\nimport { Primitive } from \"../../utils/Primitive\";\nimport { useAuiState } from \"@assistant-ui/store\";\nimport { useActionBarFeedbackNegative as useActionBarFeedbackNegativeBehavior } from \"@assistant-ui/core/react\";\n\nconst useActionBarFeedbackNegative = () => {\n const { submit } = useActionBarFeedbackNegativeBehavior();\n return submit;\n};\n\nexport namespace ActionBarPrimitiveFeedbackNegative {\n export type Element = HTMLButtonElement;\n export type Props = ActionButtonProps<typeof useActionBarFeedbackNegative>;\n}\n\nexport const ActionBarPrimitiveFeedbackNegative = forwardRef<\n ActionBarPrimitiveFeedbackNegative.Element,\n ActionBarPrimitiveFeedbackNegative.Props\n>(({ onClick, disabled, ...props }, forwardedRef) => {\n const isSubmitted = useAuiState(\n (s) => s.message.metadata.submittedFeedback?.type === \"negative\",\n );\n const callback = useActionBarFeedbackNegative();\n return (\n <Primitive.button\n type=\"button\"\n aria-pressed={isSubmitted}\n {...(isSubmitted ? { \"data-submitted\": \"true\" } : {})}\n {...props}\n ref={forwardedRef}\n disabled={disabled || !callback}\n onClick={composeEventHandlers(onClick, () => {\n callback?.();\n })}\n />\n );\n});\n\nActionBarPrimitiveFeedbackNegative.displayName =\n \"ActionBarPrimitive.FeedbackNegative\";\n"],"mappings":";;;;;;;;;AASA,MAAMO,uCAA+B;CACnC,MAAA,EAAAE,WAAmBD,6BAAqC;CAAE,OACnDC;AAAM;AAQf,MAAaC,qCAAqCR,YAGhDY,IAAAC,iBAAA;CAAA,MAAAC,IAAAf,EAAA,EAAA;CAAA,IAAAgB;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAH,EAAA,OAAAF,IAAA;EAAC,CAAA,CAAAI,SAAAD,UAAA,GAAAE,SAAAL;EAA+BE,EAAA,KAAAF;EAAAE,EAAA,KAAAC;EAAAD,EAAA,KAAAE;EAAAF,EAAA,KAAAG;CAAA,OAAA;EAAAF,WAAAD,EAAA;EAAAE,UAAAF,EAAA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
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionBarFeedbackPositive.js","names":["c","_c","forwardRef","ActionButtonProps","composeEventHandlers","useAuiState","Primitive","useActionBarFeedbackPositive","useActionBarFeedbackPositiveBehavior","submit","ActionBarPrimitiveFeedbackPositive","Element","HTMLButtonElement","Props","t0","forwardedRef","$","disabled","onClick","props","isSubmitted","_temp","callback","t1","t2","t3","t4","t5","displayName","s","message","metadata","submittedFeedback","type"],"sources":["../../../src/primitives/actionBar/ActionBarFeedbackPositive.tsx"],"sourcesContent":["\"use client\";\n\nimport { forwardRef } from \"react\";\nimport type { ActionButtonProps } from \"../../utils/createActionButton\";\nimport { composeEventHandlers } from \"radix-ui/internal\";\nimport { useAuiState } from \"@assistant-ui/store\";\nimport { Primitive } from \"../../utils/Primitive\";\nimport { useActionBarFeedbackPositive as useActionBarFeedbackPositiveBehavior } from \"@assistant-ui/core/react\";\n\nconst useActionBarFeedbackPositive = () => {\n const { submit } = useActionBarFeedbackPositiveBehavior();\n return submit;\n};\n\nexport namespace ActionBarPrimitiveFeedbackPositive {\n export type Element = HTMLButtonElement;\n export type Props = ActionButtonProps<typeof useActionBarFeedbackPositive>;\n}\n\nexport const ActionBarPrimitiveFeedbackPositive = forwardRef<\n ActionBarPrimitiveFeedbackPositive.Element,\n ActionBarPrimitiveFeedbackPositive.Props\n>(({ onClick, disabled, ...props }, forwardedRef) => {\n const isSubmitted = useAuiState(\n (s) => s.message.metadata.submittedFeedback?.type === \"positive\",\n );\n const callback = useActionBarFeedbackPositive();\n return (\n <Primitive.button\n type=\"button\"\n aria-pressed={isSubmitted}\n {...(isSubmitted ? { \"data-submitted\": \"true\" } : {})}\n {...props}\n ref={forwardedRef}\n disabled={disabled || !callback}\n onClick={composeEventHandlers(onClick, () => {\n callback?.();\n })}\n />\n );\n});\n\nActionBarPrimitiveFeedbackPositive.displayName =\n \"ActionBarPrimitive.FeedbackPositive\";\n"],"mappings":";;;;;;;;;AASA,MAAMO,uCAA+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js","names":["c","_c","forwardRef","ActionButtonProps","composeEventHandlers","useAuiState","Primitive","useActionBarFeedbackPositive","useActionBarFeedbackPositiveBehavior","submit","ActionBarPrimitiveFeedbackPositive","Element","HTMLButtonElement","Props","t0","forwardedRef","$","disabled","onClick","props","isSubmitted","_temp","callback","t1","t2","t3","t4","t5","displayName","s","message","metadata","submittedFeedback","type","useActionBarFeedbackPositive","useActionBarFeedbackPositiveBehavior","_c","Primitive"],"sources":["../../../src/primitives/actionBar/ActionBarFeedbackPositive.tsx"],"sourcesContent":["\"use client\";\n\nimport { forwardRef } from \"react\";\nimport type { ActionButtonProps } from \"../../utils/createActionButton\";\nimport { composeEventHandlers } from \"radix-ui/internal\";\nimport { useAuiState } from \"@assistant-ui/store\";\nimport { Primitive } from \"../../utils/Primitive\";\nimport { useActionBarFeedbackPositive as useActionBarFeedbackPositiveBehavior } from \"@assistant-ui/core/react\";\n\nconst useActionBarFeedbackPositive = () => {\n const { submit } = useActionBarFeedbackPositiveBehavior();\n return submit;\n};\n\nexport namespace ActionBarPrimitiveFeedbackPositive {\n export type Element = HTMLButtonElement;\n export type Props = ActionButtonProps<typeof useActionBarFeedbackPositive>;\n}\n\nexport const ActionBarPrimitiveFeedbackPositive = forwardRef<\n ActionBarPrimitiveFeedbackPositive.Element,\n ActionBarPrimitiveFeedbackPositive.Props\n>(({ onClick, disabled, ...props }, forwardedRef) => {\n const isSubmitted = useAuiState(\n (s) => s.message.metadata.submittedFeedback?.type === \"positive\",\n );\n const callback = useActionBarFeedbackPositive();\n return (\n <Primitive.button\n type=\"button\"\n aria-pressed={isSubmitted}\n {...(isSubmitted ? { \"data-submitted\": \"true\" } : {})}\n {...props}\n ref={forwardedRef}\n disabled={disabled || !callback}\n onClick={composeEventHandlers(onClick, () => {\n callback?.();\n })}\n />\n );\n});\n\nActionBarPrimitiveFeedbackPositive.displayName =\n \"ActionBarPrimitive.FeedbackPositive\";\n"],"mappings":";;;;;;;;;AASA,MAAMO,uCAA+B;CACnC,M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,GACpBG;GAA+C,GAChDJ;GACCJ,KAAAA;GACK,UAAAS;GACD,SAAAE;EAEP,CAAA;EACFV,EAAA,MAAAD;EAAAC,EAAA,MAAAI;EAAAJ,EAAA,MAAAG;EAAAH,EAAA,MAAAO;EAAAP,EAAA,MAAAQ;EAAAR,EAAA,MAAAU;EAAAV,EAAA,MAAAW;CAAA,OAAAA,KAAAX,EAAA;CAAA,OAVFW;AAUE,CAEL;AAEDjB,mCAAmCkB,cACjC;AArBA,SAAAP,MAAAQ,GAAA;CAAA,OAESA,EAACC,QAAQC,SAASC,mBAAwBC,SAAK;AAAU"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionBarReload.js","names":["ActionButtonElement","ActionButtonProps","createActionButton","useActionBarReload","useActionBarReloadBehavior","disabled","reload","ActionBarPrimitiveReload","Element","Props"],"sources":["../../../src/primitives/actionBar/ActionBarReload.ts"],"sourcesContent":["\"use client\";\n\nimport {\n type ActionButtonElement,\n type ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useActionBarReload as useActionBarReloadBehavior } from \"@assistant-ui/core/react\";\n\n/**\n * Hook that provides reload functionality for action bar buttons.\n *\n * This hook returns a callback function that reloads/regenerates the current assistant message,\n * or null if reloading is not available (e.g., thread is running, disabled, or message is not from assistant).\n *\n * @returns A reload callback function, or null if reloading is disabled\n *\n * @example\n * ```tsx\n * function CustomReloadButton() {\n * const reload = useActionBarReload();\n *\n * return (\n * <button onClick={reload} disabled={!reload}>\n * {reload ? \"Reload Message\" : \"Cannot Reload\"}\n * </button>\n * );\n * }\n * ```\n */\nconst useActionBarReload = () => {\n const { disabled, reload } = useActionBarReloadBehavior();\n if (disabled) return null;\n return reload;\n};\n\nexport namespace ActionBarPrimitiveReload {\n export type Element = ActionButtonElement;\n /**\n * Props for the ActionBarPrimitive.Reload component.\n * Inherits all button element props and action button functionality.\n */\n export type Props = ActionButtonProps<typeof useActionBarReload>;\n}\n\n/**\n * A button component that reloads/regenerates the current assistant message.\n *\n * This component automatically handles reloading the current assistant message\n * and is disabled when reloading is not available (e.g., thread is running,\n * disabled, or message is not from assistant).\n *\n * @example\n * ```tsx\n * <ActionBarPrimitive.Reload>\n * Reload Message\n * </ActionBarPrimitive.Reload>\n * ```\n */\nexport const ActionBarPrimitiveReload = createActionButton(\n \"ActionBarPrimitive.Reload\",\n useActionBarReload,\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAMG,6BAAqB;CACzB,MAAA,EAAAE,UAAAC,WAA6BF,mBAA2B;CACxD,IAAIC,UAAQ,OAAS;CAAK,OACnBC;AAAM;;;;;;;;;;;;;;;AA0Bf,MAAaC,2BAA2BL,mBACtC,6BACAC,oBACF"}
|
|
1
|
+
{"version":3,"file":"ActionBarReload.js","names":["ActionButtonElement","ActionButtonProps","createActionButton","useActionBarReload","useActionBarReloadBehavior","disabled","reload","ActionBarPrimitiveReload","Element","Props","useActionBarReload","useActionBarReloadBehavior"],"sources":["../../../src/primitives/actionBar/ActionBarReload.ts"],"sourcesContent":["\"use client\";\n\nimport {\n type ActionButtonElement,\n type ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useActionBarReload as useActionBarReloadBehavior } from \"@assistant-ui/core/react\";\n\n/**\n * Hook that provides reload functionality for action bar buttons.\n *\n * This hook returns a callback function that reloads/regenerates the current assistant message,\n * or null if reloading is not available (e.g., thread is running, disabled, or message is not from assistant).\n *\n * @returns A reload callback function, or null if reloading is disabled\n *\n * @example\n * ```tsx\n * function CustomReloadButton() {\n * const reload = useActionBarReload();\n *\n * return (\n * <button onClick={reload} disabled={!reload}>\n * {reload ? \"Reload Message\" : \"Cannot Reload\"}\n * </button>\n * );\n * }\n * ```\n */\nconst useActionBarReload = () => {\n const { disabled, reload } = useActionBarReloadBehavior();\n if (disabled) return null;\n return reload;\n};\n\nexport namespace ActionBarPrimitiveReload {\n export type Element = ActionButtonElement;\n /**\n * Props for the ActionBarPrimitive.Reload component.\n * Inherits all button element props and action button functionality.\n */\n export type Props = ActionButtonProps<typeof useActionBarReload>;\n}\n\n/**\n * A button component that reloads/regenerates the current assistant message.\n *\n * This component automatically handles reloading the current assistant message\n * and is disabled when reloading is not available (e.g., thread is running,\n * disabled, or message is not from assistant).\n *\n * @example\n * ```tsx\n * <ActionBarPrimitive.Reload>\n * Reload Message\n * </ActionBarPrimitive.Reload>\n * ```\n */\nexport const ActionBarPrimitiveReload = createActionButton(\n \"ActionBarPrimitive.Reload\",\n useActionBarReload,\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAMG,6BAAqB;CACzB,MAAA,EAAAE,UAAAC,WAA6BF,mBAA2B;CACxD,IAAIC,UAAQ,OAAS;CAAK,OACnBC;AAAM;;;;;;;;;;;;;;;AA0Bf,MAAaC,2BAA2BL,mBACtC,6BACAC,oBACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionBarRoot.js","names":["c","_c","Primitive","ComponentRef","forwardRef","ComponentPropsWithoutRef","useCallback","useMemo","useState","useActionBarFloatStatus","HideAndFloatStatus","ActionBarInteractionContext","PrimitiveDivProps","div","ActionBarPrimitiveRoot","Element","Props","hideWhenRunning","autohide","autohideFloat","t0","ref","$","rest","interactionCount","setInteractionCount","t1","Symbol","for","released","_temp","_temp2","acquireInteractionLock","t2","interactionContext","t3","t4","forceVisible","hideAndfloatStatus","Hidden","t5","Floating","t6","displayName","count","count_0","Math","max"],"sources":["../../../src/primitives/actionBar/ActionBarRoot.tsx"],"sourcesContent":["\"use client\";\n\nimport { Primitive } from \"../../utils/Primitive\";\nimport {\n type ComponentRef,\n forwardRef,\n type ComponentPropsWithoutRef,\n useCallback,\n useMemo,\n useState,\n} from \"react\";\nimport {\n useActionBarFloatStatus,\n HideAndFloatStatus,\n} from \"./useActionBarFloatStatus\";\nimport { ActionBarInteractionContext } from \"./ActionBarInteractionContext\";\n\ntype PrimitiveDivProps = ComponentPropsWithoutRef<typeof Primitive.div>;\n\nexport namespace ActionBarPrimitiveRoot {\n export type Element = ComponentRef<typeof Primitive.div>;\n export type Props = PrimitiveDivProps & {\n /**\n * Whether to hide the action bar when the thread is running.\n * @default false\n */\n hideWhenRunning?: boolean | undefined;\n /**\n * Controls when the action bar should automatically hide.\n * - \"always\": Always hide unless hovered\n * - \"not-last\": Hide unless this is the last message\n * - \"never\": Never auto-hide\n * @default \"never\"\n */\n autohide?: \"always\" | \"not-last\" | \"never\" | undefined;\n /**\n * Controls floating behavior when auto-hidden.\n * - \"always\": Always float when hidden\n * - \"single-branch\": Float only for single-branch messages\n * - \"never\": Never float\n * @default \"never\"\n */\n autohideFloat?: \"always\" | \"single-branch\" | \"never\" | undefined;\n };\n}\n\n/**\n * The root container for action bar components.\n *\n * This component provides intelligent visibility and floating behavior for action bars,\n * automatically hiding and showing based on message state, hover status, and configuration.\n * It supports floating mode for better UX when space is limited.\n *\n * @example\n * ```tsx\n * <ActionBarPrimitive.Root\n * hideWhenRunning={true}\n * autohide=\"not-last\"\n * autohideFloat=\"single-branch\"\n * >\n * <ActionBarPrimitive.Copy />\n * <ActionBarPrimitive.Edit />\n * <ActionBarPrimitive.Reload />\n * </ActionBarPrimitive.Root>\n * ```\n */\nexport const ActionBarPrimitiveRoot = forwardRef<\n ActionBarPrimitiveRoot.Element,\n ActionBarPrimitiveRoot.Props\n>(({ hideWhenRunning, autohide, autohideFloat, ...rest }, ref) => {\n const [interactionCount, setInteractionCount] = useState(0);\n\n const acquireInteractionLock = useCallback(() => {\n let released = false;\n\n setInteractionCount((count) => count + 1);\n\n return () => {\n if (released) return;\n released = true;\n setInteractionCount((count) => Math.max(0, count - 1));\n };\n }, []);\n\n const interactionContext = useMemo(\n () => ({ acquireInteractionLock }),\n [acquireInteractionLock],\n );\n\n const hideAndfloatStatus = useActionBarFloatStatus({\n hideWhenRunning,\n autohide,\n autohideFloat,\n forceVisible: interactionCount > 0,\n });\n\n if (hideAndfloatStatus === HideAndFloatStatus.Hidden) return null;\n\n return (\n <ActionBarInteractionContext.Provider value={interactionContext}>\n <Primitive.div\n {...(hideAndfloatStatus === HideAndFloatStatus.Floating\n ? { \"data-floating\": \"true\" }\n : null)}\n {...rest}\n ref={ref}\n />\n </ActionBarInteractionContext.Provider>\n );\n});\n\nActionBarPrimitiveRoot.displayName = \"ActionBarPrimitive.Root\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkEA,MAAac,yBAAyBV,YAGpCgB,IAAAC,QAAA;CAAA,MAAAC,IAAArB,EAAA,EAAA;CAAA,IAAAiB;CAAA,IAAAC;CAAA,IAAAF;CAAA,IAAAM;CAAA,IAAAD,EAAA,OAAAF,IAAA;EAAC,CAAA,CAAAH,iBAAAC,UAAAC,eAAA,GAAAI,QAAAH;EAAqDE,EAAA,KAAAF;EAAAE,EAAA,KAAAJ;EAAAI,EAAA,KAAAH;EAAAG,EAAA,KAAAL;EAAAK,EAAA,KAAAC;CAAA,OAAA;EAAAL,WAAAI,EAAA;EAAAH,gBAAAG,EAAA;EAAAL,kBAAAK,EAAA;EAAAC,OAAAD,EAAA;CAAA;CACtD,MAAA,CAAAE,kBAAAC,uBAAgDjB,SAAS,CAAC;CAAE,IAAAkB;CAAA,IAAAJ,EAAA,OAAAK,OAAAC,IAAA,2BAAA,GAAA;EAEjBF,WAAA;GACzC,IAAAG,WAAe;GAEfJ,oBAAoBK,KAAoB;GAAC,aAElC;IACL,IAAID,UAAQ;IACZA,WAAWA;IACXJ,oBAAoBM,MAAiC;GAAC;EACvD;EACFT,EAAA,KAAAI;CAAA,OAAAA,KAAAJ,EAAA;CAVD,MAAAU,yBAA+BN;CAUxB,IAAAO;CAAA,IAAAX,EAAA,OAAAK,OAAAC,IAAA,2BAAA,GAAA;EAGEK,KAAA,EAAAD,uBAAyB;EAACV,EAAA,KAAAW;CAAA,OAAAA,KAAAX,EAAA;CADnC,MAAAY,qBACSD;CAQO,MAAAE,KAAAX,mBAAmB;CAAC,IAAAY;CAAA,IAAAd,EAAA,OAAAJ,YAAAI,EAAA,OAAAH,iBAAAG,EAAA,OAAAL,mBAAAK,EAAA,QAAAa,IAAA;EAJeC,KAAA;GAAAnB;GAAAC;GAAAC;GAAAkB,cAInCF;EAChB;EAACb,EAAA,KAAAJ;EAAAI,EAAA,KAAAH;EAAAG,EAAA,KAAAL;EAAAK,EAAA,MAAAa;EAAAb,EAAA,MAAAc;CAAA,OAAAA,KAAAd,EAAA;CALD,MAAAgB,qBAA2B7B,wBAAwB2B,EAKlD;CAED,IAAIE,uBAAuB5B,mBAAkB6B,QAAO,OAAS;CAAK,IAAAC;CAAA,IAAAlB,EAAA,QAAAgB,oBAAA;EAKvDE,KAAAF,uBAAuB5B,mBAAkB+B,WAAzC,EAAA,iBACkB,OAChB,IAFF;EAEGnB,EAAA,MAAAgB;EAAAhB,EAAA,MAAAkB;CAAA,OAAAA,KAAAlB,EAAA;CAAA,IAAAoB;CAAA,IAAApB,EAAA,QAAAD,OAAAC,EAAA,QAAAC,QAAAD,EAAA,QAAAkB,IAAA;EAJZE,KAAA,oBAAA,4BAAA,UAAA;GAA6CR,OAAAA;GAC3C,UAAA,oBAAA,UAAA,KAAA;IAAA,GACOM;IAEG,GACJjB;IACCF;GAAG,CAAA;EAEZ,CAAA;EAAuCC,EAAA,MAAAD;EAAAC,EAAA,MAAAC;EAAAD,EAAA,MAAAkB;EAAAlB,EAAA,MAAAoB;CAAA,OAAAA,KAAApB,EAAA;CAAA,OARvCoB;AAQuC,CAE1C;AAED5B,uBAAuB6B,cAAc;AA1CnC,SAAAb,MAAAc,OAAA;CAAA,OAMiCA,QAAQ;AAAC;AAN1C,SAAAb,OAAAc,SAAA;CAAA,OAWmCC,KAAIC,IAAK,GAAGH,UAAQ,CAAC;AAAC"}
|
|
1
|
+
{"version":3,"file":"ActionBarRoot.js","names":["c","_c","Primitive","ComponentRef","forwardRef","ComponentPropsWithoutRef","useCallback","useMemo","useState","useActionBarFloatStatus","HideAndFloatStatus","ActionBarInteractionContext","PrimitiveDivProps","div","ActionBarPrimitiveRoot","Element","Props","hideWhenRunning","autohide","autohideFloat","t0","ref","$","rest","interactionCount","setInteractionCount","t1","Symbol","for","released","_temp","_temp2","acquireInteractionLock","t2","interactionContext","t3","t4","forceVisible","hideAndfloatStatus","Hidden","t5","Floating","t6","displayName","count","count_0","Math","max","_c"],"sources":["../../../src/primitives/actionBar/ActionBarRoot.tsx"],"sourcesContent":["\"use client\";\n\nimport { Primitive } from \"../../utils/Primitive\";\nimport {\n type ComponentRef,\n forwardRef,\n type ComponentPropsWithoutRef,\n useCallback,\n useMemo,\n useState,\n} from \"react\";\nimport {\n useActionBarFloatStatus,\n HideAndFloatStatus,\n} from \"./useActionBarFloatStatus\";\nimport { ActionBarInteractionContext } from \"./ActionBarInteractionContext\";\n\ntype PrimitiveDivProps = ComponentPropsWithoutRef<typeof Primitive.div>;\n\nexport namespace ActionBarPrimitiveRoot {\n export type Element = ComponentRef<typeof Primitive.div>;\n export type Props = PrimitiveDivProps & {\n /**\n * Whether to hide the action bar when the thread is running.\n * @default false\n */\n hideWhenRunning?: boolean | undefined;\n /**\n * Controls when the action bar should automatically hide.\n * - \"always\": Always hide unless hovered\n * - \"not-last\": Hide unless this is the last message\n * - \"never\": Never auto-hide\n * @default \"never\"\n */\n autohide?: \"always\" | \"not-last\" | \"never\" | undefined;\n /**\n * Controls floating behavior when auto-hidden.\n * - \"always\": Always float when hidden\n * - \"single-branch\": Float only for single-branch messages\n * - \"never\": Never float\n * @default \"never\"\n */\n autohideFloat?: \"always\" | \"single-branch\" | \"never\" | undefined;\n };\n}\n\n/**\n * The root container for action bar components.\n *\n * This component provides intelligent visibility and floating behavior for action bars,\n * automatically hiding and showing based on message state, hover status, and configuration.\n * It supports floating mode for better UX when space is limited.\n *\n * @example\n * ```tsx\n * <ActionBarPrimitive.Root\n * hideWhenRunning={true}\n * autohide=\"not-last\"\n * autohideFloat=\"single-branch\"\n * >\n * <ActionBarPrimitive.Copy />\n * <ActionBarPrimitive.Edit />\n * <ActionBarPrimitive.Reload />\n * </ActionBarPrimitive.Root>\n * ```\n */\nexport const ActionBarPrimitiveRoot = forwardRef<\n ActionBarPrimitiveRoot.Element,\n ActionBarPrimitiveRoot.Props\n>(({ hideWhenRunning, autohide, autohideFloat, ...rest }, ref) => {\n const [interactionCount, setInteractionCount] = useState(0);\n\n const acquireInteractionLock = useCallback(() => {\n let released = false;\n\n setInteractionCount((count) => count + 1);\n\n return () => {\n if (released) return;\n released = true;\n setInteractionCount((count) => Math.max(0, count - 1));\n };\n }, []);\n\n const interactionContext = useMemo(\n () => ({ acquireInteractionLock }),\n [acquireInteractionLock],\n );\n\n const hideAndfloatStatus = useActionBarFloatStatus({\n hideWhenRunning,\n autohide,\n autohideFloat,\n forceVisible: interactionCount > 0,\n });\n\n if (hideAndfloatStatus === HideAndFloatStatus.Hidden) return null;\n\n return (\n <ActionBarInteractionContext.Provider value={interactionContext}>\n <Primitive.div\n {...(hideAndfloatStatus === HideAndFloatStatus.Floating\n ? { \"data-floating\": \"true\" }\n : null)}\n {...rest}\n ref={ref}\n />\n </ActionBarInteractionContext.Provider>\n );\n});\n\nActionBarPrimitiveRoot.displayName = \"ActionBarPrimitive.Root\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkEA,MAAac,yBAAyBV,YAGpCgB,IAAAC,QAAA;CAAA,MAAAC,IAAArB,EAAA,EAAA;CAAA,IAAAiB;CAAA,IAAAC;CAAA,IAAAF;CAAA,IAAAM;CAAA,IAAAD,EAAA,OAAAF,IAAA;EAAC,CAAA,CAAAH,iBAAAC,UAAAC,eAAA,GAAAI,QAAAH;EAAqDE,EAAA,KAAAF;EAAAE,EAAA,KAAAJ;EAAAI,EAAA,KAAAH;EAAAG,EAAA,KAAAL;EAAAK,EAAA,KAAAC;CAAA,OAAA;EAAAL,WAAAI,EAAA;EAAAH,gBAAAG,EAAA;EAAAL,kBAAAK,EAAA;EAAAC,OAAAD,EAAA;CAAA;CACtD,MAA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UAAA,oBAAA,UAAA,KAAA;IAAA,GACOM;IAEG,GACJjB;IACCF;GAAG,CAAA;EAEZ,CAAA;EAAuCC,EAAA,MAAAD;EAAAC,EAAA,MAAAC;EAAAD,EAAA,MAAAkB;EAAAlB,EAAA,MAAAoB;CAAA,OAAAA,KAAApB,EAAA;CAAA,OARvCoB;AAQuC,CAE1C;AAED5B,uBAAuB6B,cAAc;AA1CnC,SAAAb,MAAAc,OAAA;CAAA,OAMiCA,QAAQ;AAAC;AAN1C,SAAAb,OAAAc,SAAA;CAAA,OAWmCC,KAAIC,IAAK,GAAGH,UAAQ,CAAC;AAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionBarSpeak.js","names":["ActionButtonElement","ActionButtonProps","createActionButton","useActionBarSpeak","useActionBarSpeakBehavior","disabled","speak","ActionBarPrimitiveSpeak","Element","Props"],"sources":["../../../src/primitives/actionBar/ActionBarSpeak.ts"],"sourcesContent":["\"use client\";\n\nimport {\n type ActionButtonElement,\n type ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useActionBarSpeak as useActionBarSpeakBehavior } from \"@assistant-ui/core/react\";\n\nconst useActionBarSpeak = () => {\n const { disabled, speak } = useActionBarSpeakBehavior();\n if (disabled) return null;\n return speak;\n};\n\nexport namespace ActionBarPrimitiveSpeak {\n export type Element = ActionButtonElement;\n export type Props = ActionButtonProps<typeof useActionBarSpeak>;\n}\n\nexport const ActionBarPrimitiveSpeak = createActionButton(\n \"ActionBarPrimitive.Speak\",\n useActionBarSpeak,\n);\n"],"mappings":";;;;AASA,MAAMG,4BAAoB;CACxB,MAAA,EAAAE,UAAAC,UAA4BF,kBAA0B;CACtD,IAAIC,UAAQ,OAAS;CAAK,OACnBC;AAAK;AAQd,MAAaC,0BAA0BL,mBACrC,4BACAC,mBACF"}
|
|
1
|
+
{"version":3,"file":"ActionBarSpeak.js","names":["ActionButtonElement","ActionButtonProps","createActionButton","useActionBarSpeak","useActionBarSpeakBehavior","disabled","speak","ActionBarPrimitiveSpeak","Element","Props","useActionBarSpeak","useActionBarSpeakBehavior"],"sources":["../../../src/primitives/actionBar/ActionBarSpeak.ts"],"sourcesContent":["\"use client\";\n\nimport {\n type ActionButtonElement,\n type ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useActionBarSpeak as useActionBarSpeakBehavior } from \"@assistant-ui/core/react\";\n\nconst useActionBarSpeak = () => {\n const { disabled, speak } = useActionBarSpeakBehavior();\n if (disabled) return null;\n return speak;\n};\n\nexport namespace ActionBarPrimitiveSpeak {\n export type Element = ActionButtonElement;\n export type Props = ActionButtonProps<typeof useActionBarSpeak>;\n}\n\nexport const ActionBarPrimitiveSpeak = createActionButton(\n \"ActionBarPrimitive.Speak\",\n useActionBarSpeak,\n);\n"],"mappings":";;;;AASA,MAAMG,4BAAoB;CACxB,MAAA,EAAAE,UAAAC,UAA4BF,kBAA0B;CACtD,IAAIC,UAAQ,OAAS;CAAK,OACnBC;AAAK;AAQd,MAAaC,0BAA0BL,mBACrC,4BACAC,mBACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionBarStopSpeaking.js","names":["c","_c","forwardRef","ActionButtonProps","Primitive","composeEventHandlers","useActionBarStopSpeaking","useActionBarStopSpeakingBehavior","disabled","stopSpeaking","ActionBarPrimitiveStopSpeaking","Element","HTMLButtonElement","Props","props","ref","$","callback","t0","t1","t2","onClick","t3","displayName"],"sources":["../../../src/primitives/actionBar/ActionBarStopSpeaking.tsx"],"sourcesContent":["\"use client\";\n\nimport { forwardRef } from \"react\";\nimport type { ActionButtonProps } from \"../../utils/createActionButton\";\nimport { Primitive } from \"../../utils/Primitive\";\nimport { composeEventHandlers } from \"radix-ui/internal\";\nimport { useActionBarStopSpeaking as useActionBarStopSpeakingBehavior } from \"@assistant-ui/core/react\";\n\nconst useActionBarStopSpeaking = () => {\n const { disabled, stopSpeaking } = useActionBarStopSpeakingBehavior();\n if (disabled) return null;\n return stopSpeaking;\n};\n\nexport namespace ActionBarPrimitiveStopSpeaking {\n export type Element = HTMLButtonElement;\n export type Props = ActionButtonProps<typeof useActionBarStopSpeaking>;\n}\n\nexport const ActionBarPrimitiveStopSpeaking = forwardRef<\n ActionBarPrimitiveStopSpeaking.Element,\n ActionBarPrimitiveStopSpeaking.Props\n>((props, ref) => {\n const callback = useActionBarStopSpeaking();\n\n return (\n <Primitive.button\n type=\"button\"\n disabled={!callback}\n {...props}\n ref={ref}\n onClick={composeEventHandlers(props.onClick, () => {\n callback?.();\n })}\n />\n );\n});\n\nActionBarPrimitiveStopSpeaking.displayName = \"ActionBarPrimitive.StopSpeaking\";\n"],"mappings":";;;;;;;;AAQA,MAAMM,mCAA2B;CAC/B,MAAA,EAAAE,UAAAC,iBAAmCF,yBAAiC;CACpE,IAAIC,UAAQ,OAAS;CAAK,OACnBC;AAAY;AAQrB,MAAaC,iCAAiCR,YAG5CY,OAAAC,QAAA;CAAA,MAAAC,IAAAf,EAAA,EAAA;CACA,MAAAgB,WAAiBX,2BAAyB;CAK5B,MAAAY,KAAA,CAACD;CAAQ,IAAAE;CAAA,IAAAH,EAAA,OAAAC,UAAA;EAG0BE,WAAA;GAC3CF,WAAW;EAAC;EACbD,EAAA,KAAAC;EAAAD,EAAA,KAAAG;CAAA,OAAAA,KAAAH,EAAA;CAAA,IAAAI;CAAA,IAAAJ,EAAA,OAAAF,MAAAO,WAAAL,EAAA,OAAAG,IAAA;EAFQC,KAAAf,qBAAqBS,MAAKO,SAAUF,EAE5C;EAACH,EAAA,KAAAF,MAAAO;EAAAL,EAAA,KAAAG;EAAAH,EAAA,KAAAI;CAAA,OAAAA,KAAAJ,EAAA;CAAA,IAAAM;CAAA,IAAAN,EAAA,OAAAF,SAAAE,EAAA,OAAAD,OAAAC,EAAA,OAAAE,MAAAF,EAAA,OAAAI,IAAA;EAPJE,KAAA,
|
|
1
|
+
{"version":3,"file":"ActionBarStopSpeaking.js","names":["c","_c","forwardRef","ActionButtonProps","Primitive","composeEventHandlers","useActionBarStopSpeaking","useActionBarStopSpeakingBehavior","disabled","stopSpeaking","ActionBarPrimitiveStopSpeaking","Element","HTMLButtonElement","Props","props","ref","$","callback","t0","t1","t2","onClick","t3","displayName","useActionBarStopSpeaking","useActionBarStopSpeakingBehavior","_c","Primitive"],"sources":["../../../src/primitives/actionBar/ActionBarStopSpeaking.tsx"],"sourcesContent":["\"use client\";\n\nimport { forwardRef } from \"react\";\nimport type { ActionButtonProps } from \"../../utils/createActionButton\";\nimport { Primitive } from \"../../utils/Primitive\";\nimport { composeEventHandlers } from \"radix-ui/internal\";\nimport { useActionBarStopSpeaking as useActionBarStopSpeakingBehavior } from \"@assistant-ui/core/react\";\n\nconst useActionBarStopSpeaking = () => {\n const { disabled, stopSpeaking } = useActionBarStopSpeakingBehavior();\n if (disabled) return null;\n return stopSpeaking;\n};\n\nexport namespace ActionBarPrimitiveStopSpeaking {\n export type Element = HTMLButtonElement;\n export type Props = ActionButtonProps<typeof useActionBarStopSpeaking>;\n}\n\nexport const ActionBarPrimitiveStopSpeaking = forwardRef<\n ActionBarPrimitiveStopSpeaking.Element,\n ActionBarPrimitiveStopSpeaking.Props\n>((props, ref) => {\n const callback = useActionBarStopSpeaking();\n\n return (\n <Primitive.button\n type=\"button\"\n disabled={!callback}\n {...props}\n ref={ref}\n onClick={composeEventHandlers(props.onClick, () => {\n callback?.();\n })}\n />\n );\n});\n\nActionBarPrimitiveStopSpeaking.displayName = \"ActionBarPrimitive.StopSpeaking\";\n"],"mappings":";;;;;;;;AAQA,MAAMM,mCAA2B;CAC/B,MAAA,EAAAE,UAAAC,iBAAmCF,yBAAiC;CACpE,IAAIC,UAAQ,OAAS;CAAK,OACnBC;AAAY;AAQrB,MAAaC,iCAAiCR,YAG5CY,OAAAC,QAAA;CAAA,MAAAC,IAAAf,EAAA,EAAA;CACA,MAAAgB,WAAiBX,2BAAyB;CAK5B,MAAAY,KAAA,CAACD;CAAQ,IAAAE;CAAA,IAAAH,EAAA,OAAAC,UAAA;EAG0BE,WAAA;GAC3CF,WAAW;EAAC;EACbD,EAAA,KAAAC;EAAAD,EAAA,KAAAG;CAAA,OAAAA,KAAAH,EAAA;CAAA,IAAAI;CAAA,IAAAJ,EAAA,OAAAF,MAAAO,WAAAL,EAAA,OAAAG,IAAA;EAFQC,KAAAf,qBAAqBS,MAAKO,SAAUF,EAE5C;EAACH,EAAA,KAAAF,MAAAO;EAAAL,EAAA,KAAAG;EAAAH,EAAA,KAAAI;CAAA,OAAAA,KAAAJ,EAAA;CAAA,IAAAM;CAAA,IAAAN,EAAA,OAAAF,SAAAE,EAAA,OAAAD,OAAAC,EAAA,OAAAE,MAAAF,EAAA,OAAAI,IAAA;EAPJE,KAAA,oBAAAK,YAAA,QAAA;GACO,MAAA;GACK,UAAAT;GAAS,GACfJ;GACCC;GACI,SAAAK;EAEP,CAAA;EACFJ,EAAA,KAAAF;EAAAE,EAAA,KAAAD;EAAAC,EAAA,KAAAE;EAAAF,EAAA,KAAAI;EAAAJ,EAAA,KAAAM;CAAA,OAAAA,KAAAN,EAAA;CAAA,OARFM;AAQE,CAEL;AAEDZ,+BAA+Ba,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useActionBarFloatStatus.js","names":["c","_c","useAuiState","HideAndFloatStatus","Hidden","Floating","Normal","const","UseActionBarFloatStatusProps","hideWhenRunning","autohide","autohideFloat","forceVisible","useActionBarFloatStatus","t0","$","t1","s","thread","isRunning","autohideEnabled","message","isLast","isVisibleByInteraction","isHovering","branchCount"],"sources":["../../../src/primitives/actionBar/useActionBarFloatStatus.ts"],"sourcesContent":["\"use client\";\n\nimport { useAuiState } from \"@assistant-ui/store\";\n\nexport const HideAndFloatStatus = {\n Hidden: \"hidden\",\n Floating: \"floating\",\n Normal: \"normal\",\n} as const;\nexport type HideAndFloatStatus =\n (typeof HideAndFloatStatus)[keyof typeof HideAndFloatStatus];\n\nexport type UseActionBarFloatStatusProps = {\n hideWhenRunning?: boolean | undefined;\n autohide?: \"always\" | \"not-last\" | \"never\" | undefined;\n autohideFloat?: \"always\" | \"single-branch\" | \"never\" | undefined;\n forceVisible?: boolean | undefined;\n};\n\nexport const useActionBarFloatStatus = ({\n hideWhenRunning,\n autohide,\n autohideFloat,\n forceVisible,\n}: UseActionBarFloatStatusProps) => {\n return useAuiState((s) => {\n if (hideWhenRunning && s.thread.isRunning) return HideAndFloatStatus.Hidden;\n\n const autohideEnabled =\n autohide === \"always\" || (autohide === \"not-last\" && !s.message.isLast);\n const isVisibleByInteraction = forceVisible || s.message.isHovering;\n\n // normal status\n if (!autohideEnabled) return HideAndFloatStatus.Normal;\n\n // hidden status\n if (!isVisibleByInteraction) return HideAndFloatStatus.Hidden;\n\n // floating status\n if (\n autohideFloat === \"always\" ||\n (autohideFloat === \"single-branch\" && s.message.branchCount <= 1)\n )\n return HideAndFloatStatus.Floating;\n\n return HideAndFloatStatus.Normal;\n });\n};\n"],"mappings":";;;;AAIA,MAAaG,qBAAqB;CAChCC,QAAQ;CACRC,UAAU;CACVC,QAAQ;AACV;AAWA,MAAaO,2BAA0BC,OAAA;CAAA,MAAAC,IAAAd,EAAA,CAAA;CAAC,MAAA,EAAAQ,iBAAAC,UAAAC,eAAAC,iBAAAE;CAKT,IAAAE;CAAA,IAAAD,EAAA,OAAAL,YAAAK,EAAA,OAAAJ,iBAAAI,EAAA,OAAAH,gBAAAG,EAAA,OAAAN,iBAAA;EACVO,MAAAC,MAAA;GACjB,IAAIR,mBAAmBQ,EAACC,OAAOC,WAAU,OAAShB,mBAAkBC;GAEpE,MAAAgB,kBACEV,aAAa,YAAaA,aAAa,cAAb,CAA4BO,EAACI,QAAQC;GACjE,MAAAC,yBAA+BX,gBAAgBK,EAACI,QAAQG;GAGxD,IAAI,CAACJ,iBAAe,OAASjB,mBAAkBG;GAG/C,IAAI,CAACiB,wBAAsB,OAASpB,mBAAkBC;GAGtD,IACEO,kBAAkB,YACjBA,kBAAkB,mBAAmBM,EAACI,QAAQI,eAAgB,GAAE,OAE1DtB,mBAAkBE;GAAU,OAE9BF,mBAAkBG;EAAO;EACjCS,EAAA,KAAAL;EAAAK,EAAA,KAAAJ;EAAAI,EAAA,KAAAH;EAAAG,EAAA,KAAAN;EAAAM,EAAA,KAAAC;CAAA,OAAAA,KAAAD,EAAA;CAAA,OArBMb,YAAYc,EAqBlB;AAAC"}
|
|
1
|
+
{"version":3,"file":"useActionBarFloatStatus.js","names":["c","_c","useAuiState","HideAndFloatStatus","Hidden","Floating","Normal","const","UseActionBarFloatStatusProps","hideWhenRunning","autohide","autohideFloat","forceVisible","useActionBarFloatStatus","t0","$","t1","s","thread","isRunning","autohideEnabled","message","isLast","isVisibleByInteraction","isHovering","branchCount","_c"],"sources":["../../../src/primitives/actionBar/useActionBarFloatStatus.ts"],"sourcesContent":["\"use client\";\n\nimport { useAuiState } from \"@assistant-ui/store\";\n\nexport const HideAndFloatStatus = {\n Hidden: \"hidden\",\n Floating: \"floating\",\n Normal: \"normal\",\n} as const;\nexport type HideAndFloatStatus =\n (typeof HideAndFloatStatus)[keyof typeof HideAndFloatStatus];\n\nexport type UseActionBarFloatStatusProps = {\n hideWhenRunning?: boolean | undefined;\n autohide?: \"always\" | \"not-last\" | \"never\" | undefined;\n autohideFloat?: \"always\" | \"single-branch\" | \"never\" | undefined;\n forceVisible?: boolean | undefined;\n};\n\nexport const useActionBarFloatStatus = ({\n hideWhenRunning,\n autohide,\n autohideFloat,\n forceVisible,\n}: UseActionBarFloatStatusProps) => {\n return useAuiState((s) => {\n if (hideWhenRunning && s.thread.isRunning) return HideAndFloatStatus.Hidden;\n\n const autohideEnabled =\n autohide === \"always\" || (autohide === \"not-last\" && !s.message.isLast);\n const isVisibleByInteraction = forceVisible || s.message.isHovering;\n\n // normal status\n if (!autohideEnabled) return HideAndFloatStatus.Normal;\n\n // hidden status\n if (!isVisibleByInteraction) return HideAndFloatStatus.Hidden;\n\n // floating status\n if (\n autohideFloat === \"always\" ||\n (autohideFloat === \"single-branch\" && s.message.branchCount <= 1)\n )\n return HideAndFloatStatus.Floating;\n\n return HideAndFloatStatus.Normal;\n });\n};\n"],"mappings":";;;;AAIA,MAAaG,qBAAqB;CAChCC,QAAQ;CACRC,UAAU;CACVC,QAAQ;AACV;AAWA,MAAaO,2BAA0BC,OAAA;CAAA,MAAAC,IAAAd,EAAA,CAAA;CAAC,MAAA,EAAAQ,iBAAAC,UAAAC,eAAAC,iBAAAE;CAKT,IAAAE;CAAA,IAAAD,EAAA,OAAAL,YAAAK,EAAA,OAAAJ,iBAAAI,EAAA,OAAAH,gBAAAG,EAAA,OAAAN,iBAAA;EACVO,MAAAC,MAAA;GACjB,IAAIR,mBAAmBQ,EAACC,OAAOC,WAAU,OAAShB,mBAAkBC;GAEpE,MAAAgB,kBACEV,aAAa,YAAaA,aAAa,cAAb,CAA4BO,EAACI,QAAQC;GACjE,MAAAC,yBAA+BX,gBAAgBK,EAACI,QAAQG;GAGxD,IAAI,CAACJ,iBAAe,OAASjB,mBAAkBG;GAG/C,IAAI,CAACiB,wBAAsB,OAASpB,mBAAkBC;GAGtD,IACEO,kBAAkB,YACjBA,kBAAkB,mBAAmBM,EAACI,QAAQI,eAAgB,GAAE,OAE1DtB,mBAAkBE;GAAU,OAE9BF,mBAAkBG;EAAO;EACjCS,EAAA,KAAAL;EAAAK,EAAA,KAAAJ;EAAAI,EAAA,KAAAH;EAAAG,EAAA,KAAAN;EAAAM,EAAA,KAAAC;CAAA,OAAAA,KAAAD,EAAA;CAAA,OArBMb,YAAYc,EAqBlB;AAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionBarMoreContent.js","names":["c","_c","ComponentPropsWithoutRef","ComponentRef","forwardRef","DropdownMenu","DropdownMenuPrimitive","WithRenderPropProps","DropdownMenuRenderContent","ScopedProps","useDropdownMenuScope","ActionBarMorePrimitiveContent","Element","Content","Props","portalProps","Portal","t0","forwardedRef","$","__scopeActionBarMore","props","t1","sideOffset","undefined","scope","t2","t3","displayName"],"sources":["../../../src/primitives/actionBarMore/ActionBarMoreContent.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type ComponentPropsWithoutRef,\n type ComponentRef,\n forwardRef,\n} from \"react\";\nimport { DropdownMenu as DropdownMenuPrimitive } from \"radix-ui\";\nimport type { WithRenderPropProps } from \"../../utils/Primitive\";\nimport { DropdownMenuRenderContent } from \"../dropdownMenuRenderPrimitives\";\nimport { type ScopedProps, useDropdownMenuScope } from \"./scope\";\n\nexport namespace ActionBarMorePrimitiveContent {\n export type Element = ComponentRef<typeof DropdownMenuPrimitive.Content>;\n export type Props = WithRenderPropProps<\n typeof DropdownMenuPrimitive.Content\n > & {\n portalProps?:\n | ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Portal>\n | undefined;\n };\n}\n\nexport const ActionBarMorePrimitiveContent = forwardRef<\n ActionBarMorePrimitiveContent.Element,\n ActionBarMorePrimitiveContent.Props\n>(\n (\n {\n __scopeActionBarMore,\n portalProps,\n sideOffset = 4,\n ...props\n }: ScopedProps<ActionBarMorePrimitiveContent.Props>,\n forwardedRef,\n ) => {\n const scope = useDropdownMenuScope(__scopeActionBarMore);\n\n return (\n <DropdownMenuPrimitive.Portal {...scope} {...portalProps}>\n <DropdownMenuRenderContent\n {...scope}\n {...props}\n ref={forwardedRef}\n sideOffset={sideOffset}\n />\n </DropdownMenuPrimitive.Portal>\n );\n },\n);\n\nActionBarMorePrimitiveContent.displayName = \"ActionBarMorePrimitive.Content\";\n"],"mappings":";;;;;;;;AAuBA,MAAaW,gCAAgCP,YAI3Ca,IAAAC,iBAAA;CAAA,MAAAC,IAAAlB,EAAA,EAAA;CAAA,IAAAmB;CAAA,IAAAL;CAAA,IAAAM;CAAA,IAAAC;CAAA,IAAAH,EAAA,OAAAF,IAAA;EACE,CAAA,CAAAG,sBAAAL,aAAAQ,YAAAD,IAAA,GAAAD,SAAAJ;EAKmDE,EAAA,KAAAF;EAAAE,EAAA,KAAAC;EAAAD,EAAA,KAAAJ;EAAAI,EAAA,KAAAE;EAAAF,EAAA,KAAAG;CAAA,OAAA;EAAAF,uBAAAD,EAAA;EAAAJ,cAAAI,EAAA;EAAAE,QAAAF,EAAA;EAAAG,KAAAH,EAAA;CAAA;CAFjD,MAAAI,aAAAD,OAAAE,KAAAA,IAAA,IAAAF;CAKF,MAAAG,QAAcf,qBAAqBU,oBAAoB;CAAE,IAAAM;CAAA,IAAAP,EAAA,OAAAD,gBAAAC,EAAA,OAAAE,SAAAF,EAAA,OAAAM,SAAAN,EAAA,OAAAI,YAAA;EAIrDG,KAAA,oBAAC,2BAAD;GAA0B,GACpBD;GAAK,GACLJ;GACCH,KAAAA;GACOK;EAAU,CAAA;EACtBJ,EAAA,KAAAD;EAAAC,EAAA,KAAAE;EAAAF,EAAA,KAAAM;EAAAN,EAAA,KAAAI;EAAAJ,EAAA,KAAAO;CAAA,OAAAA,KAAAP,EAAA;CAAA,IAAAQ;CAAA,IAAAR,EAAA,QAAAJ,eAAAI,EAAA,QAAAM,SAAAN,EAAA,QAAAO,IAAA;EANJC,KAAA,
|
|
1
|
+
{"version":3,"file":"ActionBarMoreContent.js","names":["c","_c","ComponentPropsWithoutRef","ComponentRef","forwardRef","DropdownMenu","DropdownMenuPrimitive","WithRenderPropProps","DropdownMenuRenderContent","ScopedProps","useDropdownMenuScope","ActionBarMorePrimitiveContent","Element","Content","Props","portalProps","Portal","t0","forwardedRef","$","__scopeActionBarMore","props","t1","sideOffset","undefined","scope","t2","t3","displayName","_c","DropdownMenuPrimitive"],"sources":["../../../src/primitives/actionBarMore/ActionBarMoreContent.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type ComponentPropsWithoutRef,\n type ComponentRef,\n forwardRef,\n} from \"react\";\nimport { DropdownMenu as DropdownMenuPrimitive } from \"radix-ui\";\nimport type { WithRenderPropProps } from \"../../utils/Primitive\";\nimport { DropdownMenuRenderContent } from \"../dropdownMenuRenderPrimitives\";\nimport { type ScopedProps, useDropdownMenuScope } from \"./scope\";\n\nexport namespace ActionBarMorePrimitiveContent {\n export type Element = ComponentRef<typeof DropdownMenuPrimitive.Content>;\n export type Props = WithRenderPropProps<\n typeof DropdownMenuPrimitive.Content\n > & {\n portalProps?:\n | ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Portal>\n | undefined;\n };\n}\n\nexport const ActionBarMorePrimitiveContent = forwardRef<\n ActionBarMorePrimitiveContent.Element,\n ActionBarMorePrimitiveContent.Props\n>(\n (\n {\n __scopeActionBarMore,\n portalProps,\n sideOffset = 4,\n ...props\n }: ScopedProps<ActionBarMorePrimitiveContent.Props>,\n forwardedRef,\n ) => {\n const scope = useDropdownMenuScope(__scopeActionBarMore);\n\n return (\n <DropdownMenuPrimitive.Portal {...scope} {...portalProps}>\n <DropdownMenuRenderContent\n {...scope}\n {...props}\n ref={forwardedRef}\n sideOffset={sideOffset}\n />\n </DropdownMenuPrimitive.Portal>\n );\n },\n);\n\nActionBarMorePrimitiveContent.displayName = \"ActionBarMorePrimitive.Content\";\n"],"mappings":";;;;;;;;AAuBA,MAAaW,gCAAgCP,YAI3Ca,IAAAC,iBAAA;CAAA,MAAAC,IAAAlB,EAAA,EAAA;CAAA,IAAAmB;CAAA,IAAAL;CAAA,IAAAM;CAAA,IAAAC;CAAA,IAAAH,EAAA,OAAAF,IAAA;EACE,CAAA,CAAAG,sBAAAL,aAAAQ,YAAAD,IAAA,GAAAD,SAAAJ;EAKmDE,EAAA,KAAAF;EAAAE,EAAA,KAAAC;EAAAD,EAAA,KAAAJ;EAAAI,EAAA,KAAAE;EAAAF,EAAA,KAAAG;CAAA,OAAA;EAAAF,uBAAAD,EAAA;EAAAJ,cAAAI,EAAA;EAAAE,QAAAF,EAAA;EAAAG,KAAAH,EAAA;CAAA;CAFjD,MAAAI,aAAAD,OAAAE,KAAAA,IAAA,IAAAF;CAKF,MAAAG,QAAcf,qBAAqBU,oBAAoB;CAAE,IAAAM;CAAA,IAAAP,EAAA,OAAAD,gBAAAC,EAAA,OAAAE,SAAAF,EAAA,OAAAM,SAAAN,EAAA,OAAAI,YAAA;EAIrDG,KAAA,oBAAC,2BAAD;GAA0B,GACpBD;GAAK,GACLJ;GACCH,KAAAA;GACOK;EAAU,CAAA;EACtBJ,EAAA,KAAAD;EAAAC,EAAA,KAAAE;EAAAF,EAAA,KAAAM;EAAAN,EAAA,KAAAI;EAAAJ,EAAA,KAAAO;CAAA,OAAAA,KAAAP,EAAA;CAAA,IAAAQ;CAAA,IAAAR,EAAA,QAAAJ,eAAAI,EAAA,QAAAM,SAAAN,EAAA,QAAAO,IAAA;EANJC,KAAA,oBAAAG,aAAA,QAAA;GAAA,GAAkCL;GAAK,GAAMV;GAC3CW,UAAAA;EAMF,CAAA;EAA+BP,EAAA,MAAAJ;EAAAI,EAAA,MAAAM;EAAAN,EAAA,MAAAO;EAAAP,EAAA,MAAAQ;CAAA,OAAAA,KAAAR,EAAA;CAAA,OAP/BQ;AAO+B,CAGrC;AAEAhB,8BAA8BiB,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionBarMoreItem.js","names":["c","_c","ComponentRef","forwardRef","DropdownMenu","DropdownMenuPrimitive","WithRenderPropProps","DropdownMenuRenderItem","ScopedProps","useDropdownMenuScope","ActionBarMorePrimitiveItem","Element","Item","Props","t0","ref","$","__scopeActionBarMore","rest","scope","t1","displayName"],"sources":["../../../src/primitives/actionBarMore/ActionBarMoreItem.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ComponentRef, forwardRef } from \"react\";\nimport type { DropdownMenu as DropdownMenuPrimitive } from \"radix-ui\";\nimport type { WithRenderPropProps } from \"../../utils/Primitive\";\nimport { DropdownMenuRenderItem } from \"../dropdownMenuRenderPrimitives\";\nimport { type ScopedProps, useDropdownMenuScope } from \"./scope\";\n\nexport namespace ActionBarMorePrimitiveItem {\n export type Element = ComponentRef<typeof DropdownMenuPrimitive.Item>;\n export type Props = WithRenderPropProps<typeof DropdownMenuPrimitive.Item>;\n}\n\nexport const ActionBarMorePrimitiveItem = forwardRef<\n ActionBarMorePrimitiveItem.Element,\n ActionBarMorePrimitiveItem.Props\n>(\n (\n {\n __scopeActionBarMore,\n ...rest\n }: ScopedProps<ActionBarMorePrimitiveItem.Props>,\n ref,\n ) => {\n const scope = useDropdownMenuScope(__scopeActionBarMore);\n\n return <DropdownMenuRenderItem {...scope} {...rest} ref={ref} />;\n },\n);\n\nActionBarMorePrimitiveItem.displayName = \"ActionBarMorePrimitive.Item\";\n"],"mappings":";;;;;;;AAaA,MAAaU,6BAA6BP,YAIxCW,IAAAC,QAAA;CAAA,MAAAC,IAAAf,EAAA,CAAA;CAAA,IAAAgB;CAAA,IAAAC;CAAA,IAAAF,EAAA,OAAAF,IAAA;EACE,CAAA,CAAAG,sBAAA,GAAAC,QAAAJ;EAGgDE,EAAA,KAAAF;EAAAE,EAAA,KAAAC;EAAAD,EAAA,KAAAE;CAAA,OAAA;EAAAD,uBAAAD,EAAA;EAAAE,OAAAF,EAAA;CAAA;CAGhD,MAAAG,QAAcV,qBAAqBQ,oBAAoB;CAAE,IAAAG;CAAA,IAAAJ,EAAA,OAAAD,OAAAC,EAAA,OAAAE,QAAAF,EAAA,OAAAG,OAAA;EAElDC,KAAA,oBAAC,wBAAD;GAAuB,GAAKD;GAAK,GAAMD;GAAWH;EAAG,CAAA;EAAIC,EAAA,KAAAD;EAAAC,EAAA,KAAAE;EAAAF,EAAA,KAAAG;EAAAH,EAAA,KAAAI;CAAA,OAAAA,KAAAJ,EAAA;CAAA,OAAzDI;AAAyD,CAEpE;AAEAV,2BAA2BW,cAAc"}
|
|
1
|
+
{"version":3,"file":"ActionBarMoreItem.js","names":["c","_c","ComponentRef","forwardRef","DropdownMenu","DropdownMenuPrimitive","WithRenderPropProps","DropdownMenuRenderItem","ScopedProps","useDropdownMenuScope","ActionBarMorePrimitiveItem","Element","Item","Props","t0","ref","$","__scopeActionBarMore","rest","scope","t1","displayName","_c"],"sources":["../../../src/primitives/actionBarMore/ActionBarMoreItem.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ComponentRef, forwardRef } from \"react\";\nimport type { DropdownMenu as DropdownMenuPrimitive } from \"radix-ui\";\nimport type { WithRenderPropProps } from \"../../utils/Primitive\";\nimport { DropdownMenuRenderItem } from \"../dropdownMenuRenderPrimitives\";\nimport { type ScopedProps, useDropdownMenuScope } from \"./scope\";\n\nexport namespace ActionBarMorePrimitiveItem {\n export type Element = ComponentRef<typeof DropdownMenuPrimitive.Item>;\n export type Props = WithRenderPropProps<typeof DropdownMenuPrimitive.Item>;\n}\n\nexport const ActionBarMorePrimitiveItem = forwardRef<\n ActionBarMorePrimitiveItem.Element,\n ActionBarMorePrimitiveItem.Props\n>(\n (\n {\n __scopeActionBarMore,\n ...rest\n }: ScopedProps<ActionBarMorePrimitiveItem.Props>,\n ref,\n ) => {\n const scope = useDropdownMenuScope(__scopeActionBarMore);\n\n return <DropdownMenuRenderItem {...scope} {...rest} ref={ref} />;\n },\n);\n\nActionBarMorePrimitiveItem.displayName = \"ActionBarMorePrimitive.Item\";\n"],"mappings":";;;;;;;AAaA,MAAaU,6BAA6BP,YAIxCW,IAAAC,QAAA;CAAA,MAAAC,IAAAf,EAAA,CAAA;CAAA,IAAAgB;CAAA,IAAAC;CAAA,IAAAF,EAAA,OAAAF,IAAA;EACE,CAAA,CAAAG,sBAAA,GAAAC,QAAAJ;EAGgDE,EAAA,KAAAF;EAAAE,EAAA,KAAAC;EAAAD,EAAA,KAAAE;CAAA,OAAA;EAAAD,uBAAAD,EAAA;EAAAE,OAAAF,EAAA;CAAA;CAGhD,MAAAG,QAAcV,qBAAqBQ,oBAAoB;CAAE,IAAAG;CAAA,IAAAJ,EAAA,OAAAD,OAAAC,EAAA,OAAAE,QAAAF,EAAA,OAAAG,OAAA;EAElDC,KAAA,oBAAC,wBAAD;GAAuB,GAAKD;GAAK,GAAMD;GAAWH;EAAG,CAAA;EAAIC,EAAA,KAAAD;EAAAC,EAAA,KAAAE;EAAAF,EAAA,KAAAG;EAAAH,EAAA,KAAAI;CAAA,OAAAA,KAAAJ,EAAA;CAAA,OAAzDI;AAAyD,CAEpE;AAEAV,2BAA2BW,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionBarMoreRoot.js","names":["c","_c","FC","useCallback","useEffect","useRef","DropdownMenu","DropdownMenuPrimitive","ScopedProps","useDropdownMenuScope","useActionBarInteractionContext","ActionBarMorePrimitiveRoot","Props","DropdownMenuProps","t0","$","__scopeActionBarMore","onOpenChange","open","rest","scope","actionBarInteraction","releaseInteractionLockRef","isControlled","undefined","t1","nextOpen","current","acquireInteractionLock","setInteractionOpen","t2","nextOpen_0","handleOpenChange","t3","t4","Boolean","t5","t6","Symbol","for","t7","t8","displayName"],"sources":["../../../src/primitives/actionBarMore/ActionBarMoreRoot.tsx"],"sourcesContent":["\"use client\";\n\nimport { type FC, useCallback, useEffect, useRef } from \"react\";\nimport { DropdownMenu as DropdownMenuPrimitive } from \"radix-ui\";\nimport { type ScopedProps, useDropdownMenuScope } from \"./scope\";\nimport { useActionBarInteractionContext } from \"../actionBar/ActionBarInteractionContext\";\n\nexport namespace ActionBarMorePrimitiveRoot {\n export type Props = DropdownMenuPrimitive.DropdownMenuProps;\n}\n\nexport const ActionBarMorePrimitiveRoot: FC<\n ActionBarMorePrimitiveRoot.Props\n> = ({\n __scopeActionBarMore,\n open,\n onOpenChange,\n ...rest\n}: ScopedProps<ActionBarMorePrimitiveRoot.Props>) => {\n const scope = useDropdownMenuScope(__scopeActionBarMore);\n const actionBarInteraction = useActionBarInteractionContext();\n const releaseInteractionLockRef = useRef<(() => void) | null>(null);\n const isControlled = open !== undefined;\n\n const setInteractionOpen = useCallback(\n (nextOpen: boolean) => {\n if (nextOpen) {\n if (releaseInteractionLockRef.current) return;\n releaseInteractionLockRef.current =\n actionBarInteraction?.acquireInteractionLock() ?? null;\n return;\n }\n\n releaseInteractionLockRef.current?.();\n releaseInteractionLockRef.current = null;\n },\n [actionBarInteraction],\n );\n\n const handleOpenChange = useCallback(\n (nextOpen: boolean) => {\n if (!isControlled) {\n setInteractionOpen(nextOpen);\n }\n onOpenChange?.(nextOpen);\n },\n [isControlled, setInteractionOpen, onOpenChange],\n );\n\n useEffect(() => {\n if (!isControlled) return;\n setInteractionOpen(Boolean(open));\n }, [isControlled, open, setInteractionOpen]);\n\n useEffect(() => {\n return () => {\n releaseInteractionLockRef.current?.();\n releaseInteractionLockRef.current = null;\n };\n }, []);\n\n return (\n <DropdownMenuPrimitive.Root\n {...scope}\n {...rest}\n {...(open !== undefined ? { open } : null)}\n onOpenChange={handleOpenChange}\n />\n );\n};\n\nActionBarMorePrimitiveRoot.displayName = \"ActionBarMorePrimitive.Root\";\n"],"mappings":";;;;;;;;AAWA,MAAaW,8BAETG,OAAA;CAAA,MAAAC,IAAAd,EAAA,EAAA;CAAA,IAAAe;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAJ,EAAA,OAAAD,IAAA;EAAC,CAAA,CAAAE,sBAAAE,MAAAD,cAAA,GAAAE,QAAAL;EAK2CC,EAAA,KAAAD;EAAAC,EAAA,KAAAC;EAAAD,EAAA,KAAAE;EAAAF,EAAA,KAAAG;EAAAH,EAAA,KAAAI;CAAA,OAAA;EAAAH,uBAAAD,EAAA;EAAAE,eAAAF,EAAA;EAAAG,OAAAH,EAAA;EAAAI,OAAAJ,EAAA;CAAA;CAC9C,MAAAK,QAAcX,qBAAqBO,oBAAoB;CACvD,MAAAK,uBAA6BX,+BAA+B;CAC5D,MAAAY,4BAAkCjB,OAA4B,IAAI;CAClE,MAAAkB,eAAqBL,SAASM,KAAAA;CAAU,IAAAC;CAAA,IAAAV,EAAA,OAAAM,sBAAA;EAGtCI,MAAAC,aAAA;GACE,IAAIA,UAAQ;IACV,IAAIJ,0BAAyBK,SAAQ;IACrCL,0BAAyBK,UACvBN,sBAAoBO,uBAAiC,KAArD;IAD+B;GAAA;GAKnCN,0BAAyBK,UAAW;GACpCL,0BAAy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AAN,KAAmC,IAAnC;EAAoCH,EAAA,MAAAG;EAAAH,EAAA,MAAAyB;CAAA,OAAAA,KAAAzB,EAAA;CAAA,IAAA0B;CAAA,IAAA1B,EAAA,QAAAiB,oBAAAjB,EAAA,QAAAI,QAAAJ,EAAA,QAAAK,SAAAL,EAAA,QAAAyB,IAAA;EAH3CC,KAAA,
|
|
1
|
+
{"version":3,"file":"ActionBarMoreRoot.js","names":["c","_c","FC","useCallback","useEffect","useRef","DropdownMenu","DropdownMenuPrimitive","ScopedProps","useDropdownMenuScope","useActionBarInteractionContext","ActionBarMorePrimitiveRoot","Props","DropdownMenuProps","t0","$","__scopeActionBarMore","onOpenChange","open","rest","scope","actionBarInteraction","releaseInteractionLockRef","isControlled","undefined","t1","nextOpen","current","acquireInteractionLock","setInteractionOpen","t2","nextOpen_0","handleOpenChange","t3","t4","Boolean","t5","t6","Symbol","for","t7","t8","displayName","_c","DropdownMenuPrimitive"],"sources":["../../../src/primitives/actionBarMore/ActionBarMoreRoot.tsx"],"sourcesContent":["\"use client\";\n\nimport { type FC, useCallback, useEffect, useRef } from \"react\";\nimport { DropdownMenu as DropdownMenuPrimitive } from \"radix-ui\";\nimport { type ScopedProps, useDropdownMenuScope } from \"./scope\";\nimport { useActionBarInteractionContext } from \"../actionBar/ActionBarInteractionContext\";\n\nexport namespace ActionBarMorePrimitiveRoot {\n export type Props = DropdownMenuPrimitive.DropdownMenuProps;\n}\n\nexport const ActionBarMorePrimitiveRoot: FC<\n ActionBarMorePrimitiveRoot.Props\n> = ({\n __scopeActionBarMore,\n open,\n onOpenChange,\n ...rest\n}: ScopedProps<ActionBarMorePrimitiveRoot.Props>) => {\n const scope = useDropdownMenuScope(__scopeActionBarMore);\n const actionBarInteraction = useActionBarInteractionContext();\n const releaseInteractionLockRef = useRef<(() => void) | null>(null);\n const isControlled = open !== undefined;\n\n const setInteractionOpen = useCallback(\n (nextOpen: boolean) => {\n if (nextOpen) {\n if (releaseInteractionLockRef.current) return;\n releaseInteractionLockRef.current =\n actionBarInteraction?.acquireInteractionLock() ?? null;\n return;\n }\n\n releaseInteractionLockRef.current?.();\n releaseInteractionLockRef.current = null;\n },\n [actionBarInteraction],\n );\n\n const handleOpenChange = useCallback(\n (nextOpen: boolean) => {\n if (!isControlled) {\n setInteractionOpen(nextOpen);\n }\n onOpenChange?.(nextOpen);\n },\n [isControlled, setInteractionOpen, onOpenChange],\n );\n\n useEffect(() => {\n if (!isControlled) return;\n setInteractionOpen(Boolean(open));\n }, [isControlled, open, setInteractionOpen]);\n\n useEffect(() => {\n return () => {\n releaseInteractionLockRef.current?.();\n releaseInteractionLockRef.current = null;\n };\n }, []);\n\n return (\n <DropdownMenuPrimitive.Root\n {...scope}\n {...rest}\n {...(open !== undefined ? { open } : null)}\n onOpenChange={handleOpenChange}\n />\n );\n};\n\nActionBarMorePrimitiveRoot.displayName = \"ActionBarMorePrimitive.Root\";\n"],"mappings":";;;;;;;;AAWA,MAAaW,8BAETG,OAAA;CAAA,MAAAC,IAAAd,EAAA,EAAA;CAAA,IAAAe;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAJ,EAAA,OAAAD,IAAA;EAAC,CAAA,CAAAE,sBAAAE,MAAAD,cAAA,GAAAE,QAAAL;EAK2CC,EAAA,KAAAD;EAAAC,EAAA,KAAAC;EAAAD,EAAA,KAAAE;EAAAF,EAAA,KAAAG;EAAAH,EAAA,KAAAI;CAAA,OAAA;EAAAH,uBAAAD,EAAA;EAAAE,eAAAF,EAAA;EAAAG,OAAAH,EAAA;EAAAI,OAAAJ,EAAA;CAAA;CAC9C,MAAAK,QAAcX,qBAAqBO,oBAAoB;CACvD,MAAAK,uBAA6BX,+BAA+B;CAC5D,MAAAY,4BAAkCjB,OAA4B,IAAI;CAClE,MAAAkB,eAAqBL,SAASM,KAAAA;CAAU,IAAAC;CAAA,IAAAV,EAAA,OAAAM,sBAAA;EAGtCI,MAAAC,aAAA;GACE,IAAIA,UAAQ;IACV,IAAIJ,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