@assistant-ui/core 0.2.14 → 0.2.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/attachment.js.map +1 -1
- package/dist/adapters/directive-formatter.js.map +1 -1
- package/dist/adapters/speech.js.map +1 -1
- package/dist/adapters/voice.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js.map +1 -1
- package/dist/internal/duplicate-detection.js.map +1 -1
- package/dist/internal.d.ts +2 -1
- package/dist/internal.js +2 -1
- package/dist/model-context/frame/host.js.map +1 -1
- package/dist/model-context/frame/provider.js.map +1 -1
- package/dist/model-context/frame/types.js.map +1 -1
- package/dist/model-context/registry.js.map +1 -1
- package/dist/model-context/tool.js.map +1 -1
- package/dist/model-context/types.d.ts +1 -0
- package/dist/model-context/types.d.ts.map +1 -1
- package/dist/model-context/types.js.map +1 -1
- package/dist/react/AssistantProvider.js +1 -0
- package/dist/react/AssistantProvider.js.map +1 -1
- package/dist/react/AssistantRuntimeProvider.js +18 -6
- package/dist/react/AssistantRuntimeProvider.js.map +1 -1
- package/dist/react/RuntimeAdapter.js +26 -7
- package/dist/react/RuntimeAdapter.js.map +1 -1
- package/dist/react/adapters/LocalStorageThreadListAdapter.js +29 -7
- package/dist/react/adapters/LocalStorageThreadListAdapter.js.map +1 -1
- package/dist/react/adapters/TitleGenerationAdapter.js.map +1 -1
- package/dist/react/client/DataRenderers.js +54 -35
- package/dist/react/client/DataRenderers.js.map +1 -1
- package/dist/react/client/Interactables.js +67 -67
- package/dist/react/client/Interactables.js.map +1 -1
- package/dist/react/client/Tools.d.ts.map +1 -1
- package/dist/react/client/Tools.js +118 -55
- package/dist/react/client/Tools.js.map +1 -1
- package/dist/react/client/interactable-model-context.js.map +1 -1
- package/dist/react/model-context/define-mcp-toolkit.js.map +1 -1
- package/dist/react/model-context/define-toolkit.js.map +1 -1
- package/dist/react/model-context/external-tool.js.map +1 -1
- package/dist/react/model-context/human-tool.js.map +1 -1
- package/dist/react/model-context/makeAssistantDataUI.js.map +1 -1
- package/dist/react/model-context/makeAssistantTool.js.map +1 -1
- package/dist/react/model-context/makeAssistantToolUI.js.map +1 -1
- package/dist/react/model-context/provider-tool.js.map +1 -1
- package/dist/react/model-context/stub-tool.js.map +1 -1
- package/dist/react/model-context/toolbox.js.map +1 -1
- package/dist/react/model-context/useAssistantContext.js.map +1 -1
- package/dist/react/model-context/useAssistantDataUI.js +27 -8
- package/dist/react/model-context/useAssistantDataUI.js.map +1 -1
- package/dist/react/model-context/useAssistantInstructions.js +33 -10
- package/dist/react/model-context/useAssistantInstructions.js.map +1 -1
- package/dist/react/model-context/useAssistantInteractable.js.map +1 -1
- package/dist/react/model-context/useAssistantTool.js +59 -17
- package/dist/react/model-context/useAssistantTool.js.map +1 -1
- package/dist/react/model-context/useAssistantToolUI.js +30 -9
- package/dist/react/model-context/useAssistantToolUI.js.map +1 -1
- package/dist/react/model-context/useAuiToolOverrides.js.map +1 -1
- package/dist/react/model-context/useInlineRender.js +35 -8
- package/dist/react/model-context/useInlineRender.js.map +1 -1
- package/dist/react/model-context/useInteractableState.js +65 -19
- package/dist/react/model-context/useInteractableState.js.map +1 -1
- package/dist/react/model-context/useToolArgsStatus.js +42 -14
- package/dist/react/model-context/useToolArgsStatus.js.map +1 -1
- package/dist/react/primitive-hooks/useActionBarCopy.js +59 -22
- package/dist/react/primitive-hooks/useActionBarCopy.js.map +1 -1
- package/dist/react/primitive-hooks/useActionBarEdit.js +25 -7
- package/dist/react/primitive-hooks/useActionBarEdit.js.map +1 -1
- package/dist/react/primitive-hooks/useActionBarFeedback.js +49 -13
- package/dist/react/primitive-hooks/useActionBarFeedback.js.map +1 -1
- package/dist/react/primitive-hooks/useActionBarReload.js +25 -7
- package/dist/react/primitive-hooks/useActionBarReload.js.map +1 -1
- package/dist/react/primitive-hooks/useActionBarSpeak.js +28 -9
- package/dist/react/primitive-hooks/useActionBarSpeak.js.map +1 -1
- package/dist/react/primitive-hooks/useActionBarStopSpeaking.js +25 -7
- package/dist/react/primitive-hooks/useActionBarStopSpeaking.js.map +1 -1
- package/dist/react/primitive-hooks/useBranchPickerNext.js +27 -11
- package/dist/react/primitive-hooks/useBranchPickerNext.js.map +1 -1
- package/dist/react/primitive-hooks/useBranchPickerPrevious.js +27 -11
- package/dist/react/primitive-hooks/useBranchPickerPrevious.js.map +1 -1
- package/dist/react/primitive-hooks/useComposerAddAttachment.js +24 -8
- package/dist/react/primitive-hooks/useComposerAddAttachment.js.map +1 -1
- package/dist/react/primitive-hooks/useComposerCancel.js +25 -7
- package/dist/react/primitive-hooks/useComposerCancel.js.map +1 -1
- package/dist/react/primitive-hooks/useComposerDictate.js +25 -7
- package/dist/react/primitive-hooks/useComposerDictate.js.map +1 -1
- package/dist/react/primitive-hooks/useComposerSend.js +25 -7
- package/dist/react/primitive-hooks/useComposerSend.js.map +1 -1
- package/dist/react/primitive-hooks/useEditComposerCancel.js +18 -4
- package/dist/react/primitive-hooks/useEditComposerCancel.js.map +1 -1
- package/dist/react/primitive-hooks/useEditComposerSend.js +25 -7
- package/dist/react/primitive-hooks/useEditComposerSend.js.map +1 -1
- package/dist/react/primitive-hooks/useMessageBranching.js +41 -9
- package/dist/react/primitive-hooks/useMessageBranching.js.map +1 -1
- package/dist/react/primitive-hooks/useMessageError.js +4 -1
- package/dist/react/primitive-hooks/useMessageError.js.map +1 -1
- package/dist/react/primitive-hooks/useMessageReload.js +25 -7
- package/dist/react/primitive-hooks/useMessageReload.js.map +1 -1
- package/dist/react/primitive-hooks/useSuggestionTrigger.js +31 -13
- package/dist/react/primitive-hooks/useSuggestionTrigger.js.map +1 -1
- package/dist/react/primitive-hooks/useThreadIsEmpty.js +4 -1
- package/dist/react/primitive-hooks/useThreadIsEmpty.js.map +1 -1
- package/dist/react/primitive-hooks/useThreadIsRunning.js +4 -1
- package/dist/react/primitive-hooks/useThreadIsRunning.js.map +1 -1
- package/dist/react/primitive-hooks/useThreadListItemArchive.js +18 -4
- package/dist/react/primitive-hooks/useThreadListItemArchive.js.map +1 -1
- package/dist/react/primitive-hooks/useThreadListItemDelete.js +18 -4
- package/dist/react/primitive-hooks/useThreadListItemDelete.js.map +1 -1
- package/dist/react/primitive-hooks/useThreadListItemTrigger.js +18 -4
- package/dist/react/primitive-hooks/useThreadListItemTrigger.js.map +1 -1
- package/dist/react/primitive-hooks/useThreadListItemUnarchive.js +18 -4
- package/dist/react/primitive-hooks/useThreadListItemUnarchive.js.map +1 -1
- package/dist/react/primitive-hooks/useThreadListLoadMore.js +25 -7
- package/dist/react/primitive-hooks/useThreadListLoadMore.js.map +1 -1
- package/dist/react/primitive-hooks/useThreadListNew.js +18 -4
- package/dist/react/primitive-hooks/useThreadListNew.js.map +1 -1
- package/dist/react/primitive-hooks/useThreadMessages.js +4 -1
- package/dist/react/primitive-hooks/useThreadMessages.js.map +1 -1
- package/dist/react/primitive-hooks/useVoice.js +63 -13
- package/dist/react/primitive-hooks/useVoice.js.map +1 -1
- package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.js +42 -7
- package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.js.map +1 -1
- package/dist/react/primitives/composer/ComposerAttachments.js +67 -16
- package/dist/react/primitives/composer/ComposerAttachments.js.map +1 -1
- package/dist/react/primitives/composer/ComposerIf.js +30 -9
- package/dist/react/primitives/composer/ComposerIf.js.map +1 -1
- package/dist/react/primitives/composer/ComposerQueue.js.map +1 -1
- package/dist/react/primitives/generativeUI/GenerativeUI.js +55 -13
- package/dist/react/primitives/generativeUI/GenerativeUI.js.map +1 -1
- package/dist/react/primitives/message/MessageAttachments.js +68 -16
- package/dist/react/primitives/message/MessageAttachments.js.map +1 -1
- package/dist/react/primitives/message/MessageGroupedParts.js +3 -3
- package/dist/react/primitives/message/MessageGroupedParts.js.map +1 -1
- package/dist/react/primitives/message/MessageParts.js +649 -181
- package/dist/react/primitives/message/MessageParts.js.map +1 -1
- package/dist/react/primitives/message/MessageQuote.js +18 -2
- package/dist/react/primitives/message/MessageQuote.js.map +1 -1
- package/dist/react/primitives/messagePart/MessagePartInProgress.js +6 -2
- package/dist/react/primitives/messagePart/MessagePartInProgress.js.map +1 -1
- package/dist/react/primitives/part/PartMessages.js +46 -14
- package/dist/react/primitives/part/PartMessages.js.map +1 -1
- package/dist/react/primitives/thread/ThreadMessages.js +67 -10
- package/dist/react/primitives/thread/ThreadMessages.js.map +1 -1
- package/dist/react/primitives/thread/ThreadSuggestions.js +50 -10
- package/dist/react/primitives/thread/ThreadSuggestions.js.map +1 -1
- package/dist/react/primitives/threadList/ThreadListItems.js +55 -14
- package/dist/react/primitives/threadList/ThreadListItems.js.map +1 -1
- package/dist/react/primitives/threadListItem/ThreadListItemTitle.js +15 -2
- package/dist/react/primitives/threadListItem/ThreadListItemTitle.js.map +1 -1
- package/dist/react/providers/AttachmentByIndexProvider.js +57 -12
- package/dist/react/providers/AttachmentByIndexProvider.js.map +1 -1
- package/dist/react/providers/ChainOfThoughtByIndicesProvider.js +33 -11
- package/dist/react/providers/ChainOfThoughtByIndicesProvider.js.map +1 -1
- package/dist/react/providers/ChainOfThoughtPartByIndexProvider.js +29 -6
- package/dist/react/providers/ChainOfThoughtPartByIndexProvider.js.map +1 -1
- package/dist/react/providers/MessageByIndexProvider.js +49 -19
- package/dist/react/providers/MessageByIndexProvider.js.map +1 -1
- package/dist/react/providers/PartByIndexProvider.js +29 -6
- package/dist/react/providers/PartByIndexProvider.js.map +1 -1
- package/dist/react/providers/QueueItemByIndexProvider.js +29 -6
- package/dist/react/providers/QueueItemByIndexProvider.js.map +1 -1
- package/dist/react/providers/ReadonlyThreadProvider.js +83 -28
- package/dist/react/providers/ReadonlyThreadProvider.js.map +1 -1
- package/dist/react/providers/SuggestionByIndexProvider.js +29 -6
- package/dist/react/providers/SuggestionByIndexProvider.js.map +1 -1
- package/dist/react/providers/TextMessagePartProvider.js +73 -25
- package/dist/react/providers/TextMessagePartProvider.js.map +1 -1
- package/dist/react/providers/ThreadListItemByIndexProvider.js +30 -6
- package/dist/react/providers/ThreadListItemByIndexProvider.js.map +1 -1
- package/dist/react/providers/ThreadListItemRuntimeProvider.js +28 -5
- package/dist/react/providers/ThreadListItemRuntimeProvider.js.map +1 -1
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js +19 -4
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js.map +1 -1
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js.map +1 -1
- package/dist/react/runtimes/RuntimeAdapterProvider.js +27 -10
- package/dist/react/runtimes/RuntimeAdapterProvider.js.map +1 -1
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js +10 -1
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js.map +1 -1
- package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.js.map +1 -1
- package/dist/react/runtimes/cloud/auiV0.js.map +1 -1
- package/dist/react/runtimes/cloud/useCloudThreadListAdapter.js +17 -17
- package/dist/react/runtimes/cloud/useCloudThreadListAdapter.js.map +1 -1
- package/dist/react/runtimes/createMessageConverter.js.map +1 -1
- package/dist/react/runtimes/external-message-converter.d.ts.map +1 -1
- package/dist/react/runtimes/external-message-converter.js +67 -30
- package/dist/react/runtimes/external-message-converter.js.map +1 -1
- package/dist/react/runtimes/useExternalStoreRuntime.js +44 -10
- package/dist/react/runtimes/useExternalStoreRuntime.js.map +1 -1
- package/dist/react/runtimes/useExternalStoreSharedOptions.js +17 -12
- package/dist/react/runtimes/useExternalStoreSharedOptions.js.map +1 -1
- package/dist/react/runtimes/useLocalRuntime.js.map +1 -1
- package/dist/react/runtimes/useRemoteThreadListRuntime.js +34 -6
- package/dist/react/runtimes/useRemoteThreadListRuntime.js.map +1 -1
- package/dist/react/types/MessagePartComponentTypes.d.ts +5 -6
- package/dist/react/types/MessagePartComponentTypes.d.ts.map +1 -1
- package/dist/react/utils/getMessageQuote.js.map +1 -1
- package/dist/react/utils/groupParts.js.map +1 -1
- package/dist/runtime/api/assistant-runtime.js.map +1 -1
- package/dist/runtime/api/attachment-runtime.js.map +1 -1
- package/dist/runtime/api/composer-runtime.js.map +1 -1
- package/dist/runtime/api/message-part-runtime.d.ts +3 -9
- package/dist/runtime/api/message-part-runtime.d.ts.map +1 -1
- package/dist/runtime/api/message-part-runtime.js +3 -6
- package/dist/runtime/api/message-part-runtime.js.map +1 -1
- package/dist/runtime/api/message-runtime.js.map +1 -1
- package/dist/runtime/api/thread-list-item-runtime.js.map +1 -1
- package/dist/runtime/api/thread-list-runtime.js.map +1 -1
- package/dist/runtime/api/thread-runtime.js.map +1 -1
- package/dist/runtime/base/base-assistant-runtime-core.js.map +1 -1
- package/dist/runtime/base/base-composer-runtime-core.js.map +1 -1
- package/dist/runtime/base/base-thread-runtime-core.js.map +1 -1
- package/dist/runtime/base/default-edit-composer-runtime-core.js.map +1 -1
- package/dist/runtime/base/default-thread-composer-runtime-core.js.map +1 -1
- package/dist/runtime/interfaces/thread-runtime-core.d.ts +2 -1
- package/dist/runtime/interfaces/thread-runtime-core.d.ts.map +1 -1
- package/dist/runtime/queue/message-queue.js.map +1 -1
- package/dist/runtime/utils/auto-status.js.map +1 -1
- package/dist/runtime/utils/external-store-message.js.map +1 -1
- package/dist/runtime/utils/message-repository.js.map +1 -1
- package/dist/runtime/utils/resolveToolApprovalResponse.d.ts +15 -0
- package/dist/runtime/utils/resolveToolApprovalResponse.d.ts.map +1 -0
- package/dist/runtime/utils/resolveToolApprovalResponse.js +35 -0
- package/dist/runtime/utils/resolveToolApprovalResponse.js.map +1 -0
- package/dist/runtime/utils/thread-message-like.d.ts +5 -1
- package/dist/runtime/utils/thread-message-like.d.ts.map +1 -1
- package/dist/runtime/utils/thread-message-like.js.map +1 -1
- package/dist/runtimes/assistant-transport/utils.js.map +1 -1
- package/dist/runtimes/external-store/external-store-runtime-core.js.map +1 -1
- package/dist/runtimes/external-store/external-store-shared-options.js.map +1 -1
- package/dist/runtimes/external-store/external-store-thread-list-runtime-core.js.map +1 -1
- package/dist/runtimes/external-store/external-store-thread-runtime-core.js.map +1 -1
- package/dist/runtimes/external-store/thread-message-converter.js.map +1 -1
- package/dist/runtimes/local/local-runtime-core.js.map +1 -1
- package/dist/runtimes/local/local-thread-list-runtime-core.js.map +1 -1
- package/dist/runtimes/local/local-thread-runtime-core.d.ts +1 -0
- package/dist/runtimes/local/local-thread-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/local/local-thread-runtime-core.js +9 -7
- package/dist/runtimes/local/local-thread-runtime-core.js.map +1 -1
- package/dist/runtimes/local/should-continue.js +1 -1
- package/dist/runtimes/local/should-continue.js.map +1 -1
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.js.map +1 -1
- package/dist/runtimes/remote-thread-list/adapter/in-memory.js.map +1 -1
- package/dist/runtimes/remote-thread-list/empty-thread-core.js.map +1 -1
- package/dist/runtimes/remote-thread-list/optimistic-state.js.map +1 -1
- package/dist/runtimes/remote-thread-list/remote-thread-state.js.map +1 -1
- package/dist/runtimes/tool-invocations/ToolInvocationTracker.js.map +1 -1
- package/dist/store/clients/chain-of-thought-client.js +37 -19
- package/dist/store/clients/chain-of-thought-client.js.map +1 -1
- package/dist/store/clients/model-context-client.js +64 -14
- package/dist/store/clients/model-context-client.js.map +1 -1
- package/dist/store/clients/no-op-composer-client.js +94 -53
- package/dist/store/clients/no-op-composer-client.js.map +1 -1
- package/dist/store/clients/runtime-adapter.js.map +1 -1
- package/dist/store/clients/suggestions.d.ts.map +1 -1
- package/dist/store/clients/suggestions.js +59 -21
- package/dist/store/clients/suggestions.js.map +1 -1
- package/dist/store/clients/thread-message-client.d.ts.map +1 -1
- package/dist/store/clients/thread-message-client.js +176 -69
- package/dist/store/clients/thread-message-client.js.map +1 -1
- package/dist/store/runtime-clients/attachment-runtime-client.js +29 -6
- package/dist/store/runtime-clients/attachment-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/composer-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/composer-runtime-client.js +188 -68
- package/dist/store/runtime-clients/composer-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/liveRef.d.ts +7 -0
- package/dist/store/runtime-clients/liveRef.d.ts.map +1 -0
- package/dist/store/runtime-clients/liveRef.js +8 -0
- package/dist/store/runtime-clients/liveRef.js.map +1 -0
- package/dist/store/runtime-clients/message-part-runtime-client.js +47 -8
- package/dist/store/runtime-clients/message-part-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/message-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/message-runtime-client.js +214 -52
- package/dist/store/runtime-clients/message-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/thread-list-item-runtime-client.js +69 -25
- package/dist/store/runtime-clients/thread-list-item-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/thread-list-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/thread-list-runtime-client.js +137 -34
- package/dist/store/runtime-clients/thread-list-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/thread-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/thread-runtime-client.js +192 -71
- package/dist/store/runtime-clients/thread-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/useSubscribable.js +2 -9
- package/dist/store/runtime-clients/useSubscribable.js.map +1 -1
- package/dist/store/scopes/part.d.ts +5 -6
- package/dist/store/scopes/part.d.ts.map +1 -1
- package/dist/store/scopes/queue-item.js.map +1 -1
- package/dist/subscribable/subscribable.js.map +1 -1
- package/dist/tests/remote-thread-list-test-helpers.js.map +1 -1
- package/dist/types/message.d.ts +38 -5
- package/dist/types/message.d.ts.map +1 -1
- package/dist/types/message.js.map +1 -1
- package/dist/utils/composite-context-provider.js.map +1 -1
- package/dist/utils/id.js.map +1 -1
- package/dist/utils/json/is-json-equal.js.map +1 -1
- package/dist/utils/json/is-json.js.map +1 -1
- package/dist/utils/text.js.map +1 -1
- package/package.json +6 -6
- package/src/index.ts +4 -0
- package/src/internal.ts +1 -0
- package/src/model-context/types.ts +1 -0
- package/src/react/AssistantProvider.tsx +7 -0
- package/src/react/client/Tools.ts +3 -5
- package/src/react/runtimes/external-message-converter.ts +3 -1
- package/src/react/types/MessagePartComponentTypes.ts +5 -5
- package/src/runtime/api/message-part-runtime.ts +14 -11
- package/src/runtime/interfaces/thread-runtime-core.ts +2 -0
- package/src/runtime/utils/resolveToolApprovalResponse.test.ts +91 -0
- package/src/runtime/utils/resolveToolApprovalResponse.ts +55 -0
- package/src/runtime/utils/thread-message-like.ts +10 -1
- package/src/runtimes/local/local-thread-runtime-core.test.ts +61 -2
- package/src/runtimes/local/local-thread-runtime-core.ts +17 -8
- package/src/runtimes/local/should-continue.ts +2 -1
- package/src/store/clients/suggestions.ts +3 -5
- package/src/store/clients/thread-message-client.ts +13 -14
- package/src/store/runtime-clients/composer-runtime-client.ts +18 -21
- package/src/store/runtime-clients/liveRef.ts +5 -0
- package/src/store/runtime-clients/message-runtime-client.ts +16 -21
- package/src/store/runtime-clients/thread-list-runtime-client.ts +3 -5
- package/src/store/runtime-clients/thread-runtime-client.ts +9 -10
- package/src/store/runtime-clients/useSubscribable.ts +2 -10
- package/src/store/scopes/part.ts +5 -2
- package/src/types/message.ts +45 -3
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ComposerAttachmentByIndexProvider } from "../../providers/AttachmentByIndexProvider.js";
|
|
2
2
|
import { memo, useMemo } from "@assistant-ui/tap/react-shim";
|
|
3
3
|
import { RenderChildrenWithAccessor, useAuiState } from "@assistant-ui/store";
|
|
4
|
+
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
4
5
|
import { jsx } from "react/jsx-runtime";
|
|
5
6
|
//#region src/react/primitives/composer/ComposerAttachments.tsx
|
|
6
7
|
const getComponent = (components, attachment) => {
|
|
@@ -11,21 +12,51 @@ const getComponent = (components, attachment) => {
|
|
|
11
12
|
default: return components?.Attachment;
|
|
12
13
|
}
|
|
13
14
|
};
|
|
14
|
-
const AttachmentComponent = (
|
|
15
|
-
const
|
|
15
|
+
const AttachmentComponent = (t0) => {
|
|
16
|
+
const $ = c(5);
|
|
17
|
+
const { components } = t0;
|
|
18
|
+
const attachment = useAuiState(_temp);
|
|
16
19
|
if (!attachment) return null;
|
|
17
|
-
|
|
20
|
+
let t1;
|
|
21
|
+
if ($[0] !== attachment || $[1] !== components) {
|
|
22
|
+
t1 = getComponent(components, attachment);
|
|
23
|
+
$[0] = attachment;
|
|
24
|
+
$[1] = components;
|
|
25
|
+
$[2] = t1;
|
|
26
|
+
} else t1 = $[2];
|
|
27
|
+
const Component = t1;
|
|
18
28
|
if (!Component) return null;
|
|
19
|
-
|
|
29
|
+
let t2;
|
|
30
|
+
if ($[3] !== Component) {
|
|
31
|
+
t2 = /* @__PURE__ */ jsx(Component, {});
|
|
32
|
+
$[3] = Component;
|
|
33
|
+
$[4] = t2;
|
|
34
|
+
} else t2 = $[4];
|
|
35
|
+
return t2;
|
|
20
36
|
};
|
|
21
37
|
/**
|
|
22
38
|
* Renders a single attachment at the specified index within the composer.
|
|
23
39
|
*/
|
|
24
|
-
const ComposerPrimitiveAttachmentByIndex = memo((
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
40
|
+
const ComposerPrimitiveAttachmentByIndex = memo((t0) => {
|
|
41
|
+
const $ = c(5);
|
|
42
|
+
const { index, components } = t0;
|
|
43
|
+
let t1;
|
|
44
|
+
if ($[0] !== components) {
|
|
45
|
+
t1 = /* @__PURE__ */ jsx(AttachmentComponent, { components });
|
|
46
|
+
$[0] = components;
|
|
47
|
+
$[1] = t1;
|
|
48
|
+
} else t1 = $[1];
|
|
49
|
+
let t2;
|
|
50
|
+
if ($[2] !== index || $[3] !== t1) {
|
|
51
|
+
t2 = /* @__PURE__ */ jsx(ComposerAttachmentByIndexProvider, {
|
|
52
|
+
index,
|
|
53
|
+
children: t1
|
|
54
|
+
});
|
|
55
|
+
$[2] = index;
|
|
56
|
+
$[3] = t1;
|
|
57
|
+
$[4] = t2;
|
|
58
|
+
} else t2 = $[4];
|
|
59
|
+
return t2;
|
|
29
60
|
}, (prev, next) => prev.index === next.index && prev.components?.Image === next.components?.Image && prev.components?.Document === next.components?.Document && prev.components?.File === next.components?.File && prev.components?.Attachment === next.components?.Attachment);
|
|
30
61
|
ComposerPrimitiveAttachmentByIndex.displayName = "ComposerPrimitive.AttachmentByIndex";
|
|
31
62
|
const ComposerPrimitiveAttachmentsInner = ({ children }) => {
|
|
@@ -40,15 +71,35 @@ const ComposerPrimitiveAttachmentsInner = ({ children }) => {
|
|
|
40
71
|
})
|
|
41
72
|
}, index)), [attachmentsCount, children]);
|
|
42
73
|
};
|
|
43
|
-
const ComposerPrimitiveAttachments = (
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
74
|
+
const ComposerPrimitiveAttachments = (t0) => {
|
|
75
|
+
const $ = c(4);
|
|
76
|
+
const { components, children } = t0;
|
|
77
|
+
if (components) {
|
|
78
|
+
let t1;
|
|
79
|
+
if ($[0] !== components) {
|
|
80
|
+
t1 = /* @__PURE__ */ jsx(ComposerPrimitiveAttachmentsInner, { children: (t2) => {
|
|
81
|
+
const { attachment } = t2;
|
|
82
|
+
const Component = getComponent(components, attachment);
|
|
83
|
+
if (!Component) return null;
|
|
84
|
+
return /* @__PURE__ */ jsx(Component, {});
|
|
85
|
+
} });
|
|
86
|
+
$[0] = components;
|
|
87
|
+
$[1] = t1;
|
|
88
|
+
} else t1 = $[1];
|
|
89
|
+
return t1;
|
|
90
|
+
}
|
|
91
|
+
let t1;
|
|
92
|
+
if ($[2] !== children) {
|
|
93
|
+
t1 = /* @__PURE__ */ jsx(ComposerPrimitiveAttachmentsInner, { children });
|
|
94
|
+
$[2] = children;
|
|
95
|
+
$[3] = t1;
|
|
96
|
+
} else t1 = $[3];
|
|
97
|
+
return t1;
|
|
50
98
|
};
|
|
51
99
|
ComposerPrimitiveAttachments.displayName = "ComposerPrimitive.Attachments";
|
|
100
|
+
function _temp(s) {
|
|
101
|
+
return s.attachment;
|
|
102
|
+
}
|
|
52
103
|
//#endregion
|
|
53
104
|
export { ComposerPrimitiveAttachmentByIndex, ComposerPrimitiveAttachments };
|
|
54
105
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComposerAttachments.js","names":[],"sources":["../../../../src/react/primitives/composer/ComposerAttachments.tsx"],"sourcesContent":["import type { Attachment } from \"../../../types/attachment\";\nimport {\n type ComponentType,\n type FC,\n type ReactNode,\n memo,\n useMemo,\n} from \"react\";\nimport { RenderChildrenWithAccessor, useAuiState } from \"@assistant-ui/store\";\nimport { ComposerAttachmentByIndexProvider } from \"../../providers/AttachmentByIndexProvider\";\n\ntype ComposerAttachmentsComponentConfig = {\n Image?: ComponentType | undefined;\n Document?: ComponentType | undefined;\n File?: ComponentType | undefined;\n Attachment?: ComponentType | undefined;\n};\n\nexport namespace ComposerPrimitiveAttachments {\n export type Props =\n | {\n /** @deprecated Use the children render function instead. */\n components: ComposerAttachmentsComponentConfig;\n children?: never;\n }\n | {\n /** Render function called for each attachment. Receives the attachment. */\n children: (value: { attachment: Attachment }) => ReactNode;\n components?: never;\n };\n}\n\nconst getComponent = (\n components: ComposerAttachmentsComponentConfig | undefined,\n attachment: Attachment,\n) => {\n const type = attachment.type;\n switch (type) {\n case \"image\":\n return components?.Image ?? components?.Attachment;\n case \"document\":\n return components?.Document ?? components?.Attachment;\n case \"file\":\n return components?.File ?? components?.Attachment;\n default:\n return components?.Attachment;\n }\n};\n\nconst AttachmentComponent: FC<{\n components: ComposerAttachmentsComponentConfig | undefined;\n}> = ({ components }) => {\n const attachment = useAuiState((s) => s.attachment);\n if (!attachment) return null;\n\n const Component = getComponent(components, attachment);\n if (!Component) return null;\n return <Component />;\n};\n\nexport namespace ComposerPrimitiveAttachmentByIndex {\n export type Props = {\n index: number;\n components?: ComposerAttachmentsComponentConfig;\n };\n}\n\n/**\n * Renders a single attachment at the specified index within the composer.\n */\nexport const ComposerPrimitiveAttachmentByIndex: FC<ComposerPrimitiveAttachmentByIndex.Props> =\n memo(\n ({ index, components }) => {\n return (\n <ComposerAttachmentByIndexProvider index={index}>\n <AttachmentComponent components={components} />\n </ComposerAttachmentByIndexProvider>\n );\n },\n (prev, next) =>\n prev.index === next.index &&\n prev.components?.Image === next.components?.Image &&\n prev.components?.Document === next.components?.Document &&\n prev.components?.File === next.components?.File &&\n prev.components?.Attachment === next.components?.Attachment,\n );\n\nComposerPrimitiveAttachmentByIndex.displayName =\n \"ComposerPrimitive.AttachmentByIndex\";\n\nconst ComposerPrimitiveAttachmentsInner: FC<{\n children: (value: { attachment: Attachment }) => ReactNode;\n}> = ({ children }) => {\n const attachmentsCount = useAuiState((s) => s.composer.attachments.length);\n\n return useMemo(\n () =>\n Array.from({ length: attachmentsCount }, (_, index) => (\n <ComposerAttachmentByIndexProvider key={index} index={index}>\n <RenderChildrenWithAccessor\n getItemState={(aui) =>\n aui.composer().attachment({ index }).getState()\n }\n >\n {(getItem) =>\n children({\n get attachment() {\n return getItem();\n },\n })\n }\n </RenderChildrenWithAccessor>\n </ComposerAttachmentByIndexProvider>\n )),\n [attachmentsCount, children],\n );\n};\n\nexport const ComposerPrimitiveAttachments: FC<\n ComposerPrimitiveAttachments.Props\n> = ({ components, children }) => {\n if (components) {\n return (\n <ComposerPrimitiveAttachmentsInner>\n {({ attachment }) => {\n const Component = getComponent(components, attachment);\n if (!Component) return null;\n return <Component />;\n }}\n </ComposerPrimitiveAttachmentsInner>\n );\n }\n return (\n <ComposerPrimitiveAttachmentsInner>\n {children}\n </ComposerPrimitiveAttachmentsInner>\n );\n};\n\nComposerPrimitiveAttachments.displayName = \"ComposerPrimitive.Attachments\";\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ComposerAttachments.js","names":["Attachment","ComponentType","FC","ReactNode","memo","useMemo","RenderChildrenWithAccessor","useAuiState","ComposerAttachmentByIndexProvider","ComposerAttachmentsComponentConfig","Image","Document","File","ComposerPrimitiveAttachments","Props","components","children","value","attachment","getComponent","type","AttachmentComponent","t0","$","_c","_temp","t1","Component","t2","ComposerPrimitiveAttachmentByIndex","index","prev","next","displayName","ComposerPrimitiveAttachmentsInner","attachmentsCount","s","composer","attachments","length","Array","from","_","aui","getState","getItem"],"sources":["../../../../src/react/primitives/composer/ComposerAttachments.tsx"],"sourcesContent":["import type { Attachment } from \"../../../types/attachment\";\nimport {\n type ComponentType,\n type FC,\n type ReactNode,\n memo,\n useMemo,\n} from \"react\";\nimport { RenderChildrenWithAccessor, useAuiState } from \"@assistant-ui/store\";\nimport { ComposerAttachmentByIndexProvider } from \"../../providers/AttachmentByIndexProvider\";\n\ntype ComposerAttachmentsComponentConfig = {\n Image?: ComponentType | undefined;\n Document?: ComponentType | undefined;\n File?: ComponentType | undefined;\n Attachment?: ComponentType | undefined;\n};\n\nexport namespace ComposerPrimitiveAttachments {\n export type Props =\n | {\n /** @deprecated Use the children render function instead. */\n components: ComposerAttachmentsComponentConfig;\n children?: never;\n }\n | {\n /** Render function called for each attachment. Receives the attachment. */\n children: (value: { attachment: Attachment }) => ReactNode;\n components?: never;\n };\n}\n\nconst getComponent = (\n components: ComposerAttachmentsComponentConfig | undefined,\n attachment: Attachment,\n) => {\n const type = attachment.type;\n switch (type) {\n case \"image\":\n return components?.Image ?? components?.Attachment;\n case \"document\":\n return components?.Document ?? components?.Attachment;\n case \"file\":\n return components?.File ?? components?.Attachment;\n default:\n return components?.Attachment;\n }\n};\n\nconst AttachmentComponent: FC<{\n components: ComposerAttachmentsComponentConfig | undefined;\n}> = ({ components }) => {\n const attachment = useAuiState((s) => s.attachment);\n if (!attachment) return null;\n\n const Component = getComponent(components, attachment);\n if (!Component) return null;\n return <Component />;\n};\n\nexport namespace ComposerPrimitiveAttachmentByIndex {\n export type Props = {\n index: number;\n components?: ComposerAttachmentsComponentConfig;\n };\n}\n\n/**\n * Renders a single attachment at the specified index within the composer.\n */\nexport const ComposerPrimitiveAttachmentByIndex: FC<ComposerPrimitiveAttachmentByIndex.Props> =\n memo(\n ({ index, components }) => {\n return (\n <ComposerAttachmentByIndexProvider index={index}>\n <AttachmentComponent components={components} />\n </ComposerAttachmentByIndexProvider>\n );\n },\n (prev, next) =>\n prev.index === next.index &&\n prev.components?.Image === next.components?.Image &&\n prev.components?.Document === next.components?.Document &&\n prev.components?.File === next.components?.File &&\n prev.components?.Attachment === next.components?.Attachment,\n );\n\nComposerPrimitiveAttachmentByIndex.displayName =\n \"ComposerPrimitive.AttachmentByIndex\";\n\nconst ComposerPrimitiveAttachmentsInner: FC<{\n children: (value: { attachment: Attachment }) => ReactNode;\n}> = ({ children }) => {\n const attachmentsCount = useAuiState((s) => s.composer.attachments.length);\n\n return useMemo(\n () =>\n Array.from({ length: attachmentsCount }, (_, index) => (\n <ComposerAttachmentByIndexProvider key={index} index={index}>\n <RenderChildrenWithAccessor\n getItemState={(aui) =>\n aui.composer().attachment({ index }).getState()\n }\n >\n {(getItem) =>\n children({\n get attachment() {\n return getItem();\n },\n })\n }\n </RenderChildrenWithAccessor>\n </ComposerAttachmentByIndexProvider>\n )),\n [attachmentsCount, children],\n );\n};\n\nexport const ComposerPrimitiveAttachments: FC<\n ComposerPrimitiveAttachments.Props\n> = ({ components, children }) => {\n if (components) {\n return (\n <ComposerPrimitiveAttachmentsInner>\n {({ attachment }) => {\n const Component = getComponent(components, attachment);\n if (!Component) return null;\n return <Component />;\n }}\n </ComposerPrimitiveAttachmentsInner>\n );\n }\n return (\n <ComposerPrimitiveAttachmentsInner>\n {children}\n </ComposerPrimitiveAttachmentsInner>\n );\n};\n\nComposerPrimitiveAttachments.displayName = \"ComposerPrimitive.Attachments\";\n"],"mappings":";;;;;;AAgCA,MAAMmB,gBACJJ,YACAG,eACG;CAEH,QADaA,WAAWE,MACxB;EACE,KAAK,SACH,OAAOL,YAAYL,SAASK,YAAYf;EAC1C,KAAK,YACH,OAAOe,YAAYJ,YAAYI,YAAYf;EAC7C,KAAK,QACH,OAAOe,YAAYH,QAAQG,YAAYf;EACzC,SAC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AEoC;AAIxCb,6BAA6BoB,cAAc;AAxFtC,SAAAR,MAAAW,GAAA;CAAA,OACmCA,EAAClB;AAAW"}
|
|
@@ -1,19 +1,40 @@
|
|
|
1
1
|
import { useAuiState } from "@assistant-ui/store";
|
|
2
|
+
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
2
3
|
//#region src/react/primitives/composer/ComposerIf.tsx
|
|
3
4
|
const useComposerIf = (props) => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
const $ = c(3);
|
|
6
|
+
let t0;
|
|
7
|
+
if ($[0] !== props.dictation || $[1] !== props.editing) {
|
|
8
|
+
t0 = (s) => {
|
|
9
|
+
if (props.editing === true && !s.composer.isEditing) return false;
|
|
10
|
+
if (props.editing === false && s.composer.isEditing) return false;
|
|
11
|
+
const isDictating = s.composer.dictation != null;
|
|
12
|
+
if (props.dictation === true && !isDictating) return false;
|
|
13
|
+
if (props.dictation === false && isDictating) return false;
|
|
14
|
+
return true;
|
|
15
|
+
};
|
|
16
|
+
$[0] = props.dictation;
|
|
17
|
+
$[1] = props.editing;
|
|
18
|
+
$[2] = t0;
|
|
19
|
+
} else t0 = $[2];
|
|
20
|
+
return useAuiState(t0);
|
|
12
21
|
};
|
|
13
22
|
/**
|
|
14
23
|
* @deprecated Use `<AuiIf condition={(s) => s.composer...} />` instead.
|
|
15
24
|
*/
|
|
16
|
-
const ComposerPrimitiveIf = (
|
|
25
|
+
const ComposerPrimitiveIf = (t0) => {
|
|
26
|
+
const $ = c(3);
|
|
27
|
+
let children;
|
|
28
|
+
let query;
|
|
29
|
+
if ($[0] !== t0) {
|
|
30
|
+
({children, ...query} = t0);
|
|
31
|
+
$[0] = t0;
|
|
32
|
+
$[1] = children;
|
|
33
|
+
$[2] = query;
|
|
34
|
+
} else {
|
|
35
|
+
children = $[1];
|
|
36
|
+
query = $[2];
|
|
37
|
+
}
|
|
17
38
|
return useComposerIf(query) ? children : null;
|
|
18
39
|
};
|
|
19
40
|
ComposerPrimitiveIf.displayName = "ComposerPrimitive.If";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComposerIf.js","names":[],"sources":["../../../../src/react/primitives/composer/ComposerIf.tsx"],"sourcesContent":["import type { FC, PropsWithChildren } from \"react\";\nimport { useAuiState } from \"@assistant-ui/store\";\n\ntype ComposerIfFilters = {\n /** Whether the composer is in editing mode */\n editing: boolean | undefined;\n /** Whether dictation is currently active */\n dictation: boolean | undefined;\n};\n\nexport type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<\n T,\n Exclude<keyof T, Keys>\n> &\n {\n [K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>;\n }[Keys];\n\nexport type UseComposerIfProps = RequireAtLeastOne<ComposerIfFilters>;\n\nconst useComposerIf = (props: UseComposerIfProps) => {\n return useAuiState((s) => {\n if (props.editing === true && !s.composer.isEditing) return false;\n if (props.editing === false && s.composer.isEditing) return false;\n\n const isDictating = s.composer.dictation != null;\n if (props.dictation === true && !isDictating) return false;\n if (props.dictation === false && isDictating) return false;\n\n return true;\n });\n};\n\nexport namespace ComposerPrimitiveIf {\n export type Props = PropsWithChildren<UseComposerIfProps>;\n}\n\n/**\n * @deprecated Use `<AuiIf condition={(s) => s.composer...} />` instead.\n */\nexport const ComposerPrimitiveIf: FC<ComposerPrimitiveIf.Props> = ({\n children,\n ...query\n}) => {\n const result = useComposerIf(query);\n return result ? children : null;\n};\n\nComposerPrimitiveIf.displayName = \"ComposerPrimitive.If\";\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ComposerIf.js","names":["FC","PropsWithChildren","useAuiState","ComposerIfFilters","editing","dictation","RequireAtLeastOne","T","Pick","Exclude","Keys","Required","K","Partial","UseComposerIfProps","useComposerIf","props","$","_c","t0","s","composer","isEditing","isDictating","ComposerPrimitiveIf","Props","children","query","result","displayName"],"sources":["../../../../src/react/primitives/composer/ComposerIf.tsx"],"sourcesContent":["import type { FC, PropsWithChildren } from \"react\";\nimport { useAuiState } from \"@assistant-ui/store\";\n\ntype ComposerIfFilters = {\n /** Whether the composer is in editing mode */\n editing: boolean | undefined;\n /** Whether dictation is currently active */\n dictation: boolean | undefined;\n};\n\nexport type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<\n T,\n Exclude<keyof T, Keys>\n> &\n {\n [K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>;\n }[Keys];\n\nexport type UseComposerIfProps = RequireAtLeastOne<ComposerIfFilters>;\n\nconst useComposerIf = (props: UseComposerIfProps) => {\n return useAuiState((s) => {\n if (props.editing === true && !s.composer.isEditing) return false;\n if (props.editing === false && s.composer.isEditing) return false;\n\n const isDictating = s.composer.dictation != null;\n if (props.dictation === true && !isDictating) return false;\n if (props.dictation === false && isDictating) return false;\n\n return true;\n });\n};\n\nexport namespace ComposerPrimitiveIf {\n export type Props = PropsWithChildren<UseComposerIfProps>;\n}\n\n/**\n * @deprecated Use `<AuiIf condition={(s) => s.composer...} />` instead.\n */\nexport const ComposerPrimitiveIf: FC<ComposerPrimitiveIf.Props> = ({\n children,\n ...query\n}) => {\n const result = useComposerIf(query);\n return result ? children : null;\n};\n\nComposerPrimitiveIf.displayName = \"ComposerPrimitive.If\";\n"],"mappings":";;;AAoBA,MAAMe,iBAAgBC,UAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CAAA,IAAAC;CAAA,IAAAF,EAAA,OAAAD,MAAAX,aAAAY,EAAA,OAAAD,MAAAZ,SAAA;EACDe,MAAAC,MAAA;GACjB,IAAIJ,MAAKZ,YAAa,QAAlB,CAA2BgB,EAACC,SAASC,WAAU,OAAS;GAC5D,IAAIN,MAAKZ,YAAa,SAASgB,EAACC,SAASC,WAAU,OAAS;GAE5D,MAAAC,cAAoBH,EAACC,SAAShB,aAAc;GAC5C,IAAIW,MAAKX,cAAe,QAApB,CAA6BkB,aAAW,OAAS;GACrD,IAAIP,MAAKX,cAAe,SAApBkB,aAAwC,OAAS;GAAM,OAEpD;EAAI;EACZN,EAAA,KAAAD,MAAAX;EAAAY,EAAA,KAAAD,MAAAZ;EAAAa,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAAA,OATMf,YAAYiB,EASlB;AAAC;;;;AAUJ,MAAaK,uBAAqDL,OAAA;CAAA,MAAAF,IAAAC,EAAA,CAAA;CAAA,IAAAQ;CAAA,IAAAC;CAAA,IAAAV,EAAA,OAAAE,IAAA;EAAC,CAAA,CAAAO,aAAAC,SAAAR;EAGlEF,EAAA,KAAAE;EAAAF,EAAA,KAAAS;EAAAT,EAAA,KAAAU;CAAA,OAAA;EAAAD,WAAAT,EAAA;EAAAU,QAAAV,EAAA;CAAA;CACqC,OAArBF,cAAcY,KACtBC,IAAAF,WAAA;AAAwB;AAGjCF,oBAAoBK,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComposerQueue.js","names":[],"sources":["../../../../src/react/primitives/composer/ComposerQueue.tsx"],"sourcesContent":["import { type FC, type ReactNode, memo, useMemo } from \"react\";\nimport { RenderChildrenWithAccessor, useAuiState } from \"@assistant-ui/store\";\nimport type { QueueItemState } from \"../../../store/scopes/queue-item\";\nimport { QueueItemByIndexProvider } from \"../../providers/QueueItemByIndexProvider\";\n\nexport namespace ComposerPrimitiveQueue {\n export type Props = {\n /** Render function called for each queue item. Receives the queue item state. */\n children: (value: { queueItem: QueueItemState }) => ReactNode;\n };\n}\n\nconst ComposerPrimitiveQueueInner: FC<{\n children: (value: { queueItem: QueueItemState }) => ReactNode;\n}> = ({ children }) => {\n const queue = useAuiState((s) => s.composer.queue.length);\n\n return useMemo(\n () =>\n Array.from({ length: queue }, (_, index) => (\n <QueueItemByIndexProvider key={index} index={index}>\n <RenderChildrenWithAccessor\n getItemState={(aui) =>\n aui.composer().queueItem({ index }).getState()\n }\n >\n {(getItem) =>\n children({\n get queueItem() {\n return getItem();\n },\n })\n }\n </RenderChildrenWithAccessor>\n </QueueItemByIndexProvider>\n )),\n [queue, children],\n );\n};\n\n/**\n * Renders all queue items in the composer.\n *\n * @example\n * ```tsx\n * <ComposerPrimitive.Queue>\n * {({ queueItem }) => (\n * <div>\n * <QueueItemPrimitive.Text />\n * <QueueItemPrimitive.Steer>Run Now</QueueItemPrimitive.Steer>\n * </div>\n * )}\n * </ComposerPrimitive.Queue>\n * ```\n */\nexport const ComposerPrimitiveQueue = memo(ComposerPrimitiveQueueInner);\n\nComposerPrimitiveQueue.displayName = \"ComposerPrimitive.Queue\";\n"],"mappings":";;;;;AAYA,
|
|
1
|
+
{"version":3,"file":"ComposerQueue.js","names":["FC","ReactNode","memo","useMemo","RenderChildrenWithAccessor","useAuiState","QueueItemState","QueueItemByIndexProvider","ComposerPrimitiveQueue","Props","children","value","queueItem","ComposerPrimitiveQueueInner","queue","s","composer","length","Array","from","_","index","aui","getState","getItem","displayName"],"sources":["../../../../src/react/primitives/composer/ComposerQueue.tsx"],"sourcesContent":["import { type FC, type ReactNode, memo, useMemo } from \"react\";\nimport { RenderChildrenWithAccessor, useAuiState } from \"@assistant-ui/store\";\nimport type { QueueItemState } from \"../../../store/scopes/queue-item\";\nimport { QueueItemByIndexProvider } from \"../../providers/QueueItemByIndexProvider\";\n\nexport namespace ComposerPrimitiveQueue {\n export type Props = {\n /** Render function called for each queue item. Receives the queue item state. */\n children: (value: { queueItem: QueueItemState }) => ReactNode;\n };\n}\n\nconst ComposerPrimitiveQueueInner: FC<{\n children: (value: { queueItem: QueueItemState }) => ReactNode;\n}> = ({ children }) => {\n const queue = useAuiState((s) => s.composer.queue.length);\n\n return useMemo(\n () =>\n Array.from({ length: queue }, (_, index) => (\n <QueueItemByIndexProvider key={index} index={index}>\n <RenderChildrenWithAccessor\n getItemState={(aui) =>\n aui.composer().queueItem({ index }).getState()\n }\n >\n {(getItem) =>\n children({\n get queueItem() {\n return getItem();\n },\n })\n }\n </RenderChildrenWithAccessor>\n </QueueItemByIndexProvider>\n )),\n [queue, children],\n );\n};\n\n/**\n * Renders all queue items in the composer.\n *\n * @example\n * ```tsx\n * <ComposerPrimitive.Queue>\n * {({ queueItem }) => (\n * <div>\n * <QueueItemPrimitive.Text />\n * <QueueItemPrimitive.Steer>Run Now</QueueItemPrimitive.Steer>\n * </div>\n * )}\n * </ComposerPrimitive.Queue>\n * ```\n */\nexport const ComposerPrimitiveQueue = memo(ComposerPrimitiveQueueInner);\n\nComposerPrimitiveQueue.displayName = \"ComposerPrimitive.Queue\";\n"],"mappings":";;;;;AAYA,MAAMa,+BAEA,EAAEH,eAAe;CACrB,MAAMI,QAAQT,aAAaU,MAAMA,EAAEC,SAASF,MAAMG,MAAM;CAExD,OAAOd,cAEHe,MAAMC,KAAK,EAAEF,QAAQH,MAAM,IAAIM,GAAGC,UAChC,oBAAC,0BAAD;EAA6CA;YAC3C,oBAAC,4BAAD;GACE,eAAeC,QACbA,IAAIN,SAAS,CAAC,CAACJ,UAAU,EAAES,MAAM,CAAC,CAAC,CAACE,SAAS;cAG7CC,YACAd,SAAS,EACP,IAAIE,YAAY;IACd,OAAOY,QAAQ;GACjB,EACF,CAAC;EAEuB,CAAA;CACJ,GAdKH,KAcL,CAC3B,GACH,CAACP,OAAOJ,QAAQ,CAClB;AACF;;;;;;;;;;;;;;;;AAiBA,MAAaF,yBAAyBN,KAAKW,2BAA2B;AAEtEL,uBAAuBiB,cAAc"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { createElement
|
|
2
|
+
import { createElement } from "@assistant-ui/tap/react-shim";
|
|
3
3
|
import { useAuiState } from "@assistant-ui/store";
|
|
4
|
+
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
4
5
|
import { Fragment as Fragment$1, jsx } from "react/jsx-runtime";
|
|
5
6
|
//#region src/react/primitives/generativeUI/GenerativeUI.tsx
|
|
6
7
|
/**
|
|
@@ -50,8 +51,38 @@ const normalizeRoot = (spec) => {
|
|
|
50
51
|
* allowlist. Used by `MessagePrimitive.GenerativeUI` and by
|
|
51
52
|
* `MessagePrimitive.Parts` when handling a `generative-ui` part.
|
|
52
53
|
*/
|
|
53
|
-
const GenerativeUIRender = (
|
|
54
|
-
|
|
54
|
+
const GenerativeUIRender = (t0) => {
|
|
55
|
+
const $ = c(11);
|
|
56
|
+
const { spec, components, Fallback } = t0;
|
|
57
|
+
let t1;
|
|
58
|
+
if ($[0] !== spec) {
|
|
59
|
+
t1 = normalizeRoot(spec);
|
|
60
|
+
$[0] = spec;
|
|
61
|
+
$[1] = t1;
|
|
62
|
+
} else t1 = $[1];
|
|
63
|
+
const nodes = t1;
|
|
64
|
+
let t2;
|
|
65
|
+
if ($[2] !== Fallback || $[3] !== components || $[4] !== nodes) {
|
|
66
|
+
let t3;
|
|
67
|
+
if ($[6] !== Fallback || $[7] !== components) {
|
|
68
|
+
t3 = (node, i) => renderNode(node, components, Fallback, `${i}`);
|
|
69
|
+
$[6] = Fallback;
|
|
70
|
+
$[7] = components;
|
|
71
|
+
$[8] = t3;
|
|
72
|
+
} else t3 = $[8];
|
|
73
|
+
t2 = nodes.map(t3);
|
|
74
|
+
$[2] = Fallback;
|
|
75
|
+
$[3] = components;
|
|
76
|
+
$[4] = nodes;
|
|
77
|
+
$[5] = t2;
|
|
78
|
+
} else t2 = $[5];
|
|
79
|
+
let t3;
|
|
80
|
+
if ($[9] !== t2) {
|
|
81
|
+
t3 = /* @__PURE__ */ jsx(Fragment$1, { children: t2 });
|
|
82
|
+
$[9] = t2;
|
|
83
|
+
$[10] = t3;
|
|
84
|
+
} else t3 = $[10];
|
|
85
|
+
return t3;
|
|
55
86
|
};
|
|
56
87
|
GenerativeUIRender.displayName = "GenerativeUIRender";
|
|
57
88
|
/**
|
|
@@ -71,20 +102,31 @@ GenerativeUIRender.displayName = "GenerativeUIRender";
|
|
|
71
102
|
* />
|
|
72
103
|
* ```
|
|
73
104
|
*/
|
|
74
|
-
const MessagePrimitiveGenerativeUI = (
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
});
|
|
105
|
+
const MessagePrimitiveGenerativeUI = (t0) => {
|
|
106
|
+
const $ = c(4);
|
|
107
|
+
const { components, spec, Fallback } = t0;
|
|
108
|
+
const storeSpec = useAuiState(_temp);
|
|
79
109
|
const partSpec = spec ?? storeSpec;
|
|
80
110
|
if (!partSpec) return null;
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
111
|
+
let t1;
|
|
112
|
+
if ($[0] !== Fallback || $[1] !== components || $[2] !== partSpec) {
|
|
113
|
+
t1 = /* @__PURE__ */ jsx(GenerativeUIRender, {
|
|
114
|
+
spec: partSpec,
|
|
115
|
+
components,
|
|
116
|
+
Fallback
|
|
117
|
+
});
|
|
118
|
+
$[0] = Fallback;
|
|
119
|
+
$[1] = components;
|
|
120
|
+
$[2] = partSpec;
|
|
121
|
+
$[3] = t1;
|
|
122
|
+
} else t1 = $[3];
|
|
123
|
+
return t1;
|
|
86
124
|
};
|
|
87
125
|
MessagePrimitiveGenerativeUI.displayName = "MessagePrimitive.GenerativeUI";
|
|
126
|
+
function _temp(s) {
|
|
127
|
+
const part = s.part;
|
|
128
|
+
return part?.type === "generative-ui" ? part.spec : void 0;
|
|
129
|
+
}
|
|
88
130
|
//#endregion
|
|
89
131
|
export { GenerativeUIRender, GenerativeUIRenderError, MessagePrimitiveGenerativeUI };
|
|
90
132
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GenerativeUI.js","names":[],"sources":["../../../../src/react/primitives/generativeUI/GenerativeUI.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type ComponentType,\n type FC,\n type ReactNode,\n createElement,\n useMemo,\n} from \"react\";\nimport { useAuiState } from \"@assistant-ui/store\";\nimport type {\n GenerativeUINode,\n GenerativeUISpec,\n} from \"../../../types/message\";\nimport type {\n GenerativeUIComponentRegistry,\n GenerativeUIRenderProps,\n} from \"../../types/MessagePartComponentTypes\";\n\n/**\n * Thrown when a generative-ui spec references a component name that is not\n * present in the consumer-provided allowlist. The allowlist is the security\n * boundary in the same-realm rendering path — there is no fallback by\n * default. Pass `Fallback` to opt into a soft-fail UX.\n */\nexport class GenerativeUIRenderError extends Error {\n public readonly componentName: string;\n\n constructor(\n componentName: string,\n message = `Component \"${componentName}\" is not in the generative-ui allowlist.`,\n ) {\n super(message);\n this.name = \"GenerativeUIRenderError\";\n this.componentName = componentName;\n }\n}\n\nconst isObjectNode = (\n node: GenerativeUINode,\n): node is Exclude<GenerativeUINode, string> =>\n typeof node === \"object\" && node !== null;\n\nconst renderNode = (\n node: GenerativeUINode | undefined,\n components: GenerativeUIComponentRegistry,\n Fallback: GenerativeUIRenderProps[\"Fallback\"],\n path: string,\n): ReactNode => {\n if (node === undefined || node === null) return null;\n\n if (typeof node === \"string\") return node;\n\n if (!isObjectNode(node) || !(\"component\" in node)) {\n if (\n typeof process !== \"undefined\" &&\n process.env?.NODE_ENV !== \"production\"\n ) {\n console.warn(`[generative-ui] Skipping malformed node at ${path}:`, node);\n }\n return null;\n }\n\n const { component, props, children, key } = node;\n\n const Resolved = components[component];\n if (!Resolved) {\n if (Fallback) {\n return <Fallback key={key ?? path} component={component} props={props} />;\n }\n throw new GenerativeUIRenderError(component);\n }\n\n const renderedChildren = children?.length\n ? children.map((child, i) =>\n renderNode(child, components, Fallback, `${path}/${i}`),\n )\n : undefined;\n\n return createElement(\n Resolved,\n { ...(props ?? {}), key: key ?? path },\n ...(renderedChildren ?? []),\n );\n};\n\nconst normalizeRoot = (\n spec: GenerativeUISpec | undefined,\n): readonly GenerativeUINode[] => {\n if (!spec || spec.root === undefined || spec.root === null) return [];\n const root = spec.root;\n return Array.isArray(root)\n ? (root as readonly GenerativeUINode[])\n : [root as GenerativeUINode];\n};\n\n/**\n * Internal renderer. Resolves a {@link GenerativeUISpec} against the consumer\n * allowlist. Used by `MessagePrimitive.GenerativeUI` and by\n * `MessagePrimitive.Parts` when handling a `generative-ui` part.\n */\nexport const GenerativeUIRender: FC<GenerativeUIRenderProps> = ({\n spec,\n components,\n Fallback,\n}) => {\n const nodes = useMemo(() => normalizeRoot(spec), [spec]);\n\n return (\n <>\n {nodes.map((node, i) => renderNode(node, components, Fallback, `${i}`))}\n </>\n );\n};\n\nGenerativeUIRender.displayName = \"GenerativeUIRender\";\n\nexport namespace MessagePrimitiveGenerativeUI {\n export type Props = {\n /**\n * The component allowlist. Keys are the names referenced in the spec\n * (e.g. `\"Card\"`, `\"Button\"`), values are the React components.\n *\n * This is the security boundary — any name not in the allowlist is\n * rejected with {@link GenerativeUIRenderError}.\n */\n components: GenerativeUIComponentRegistry;\n /**\n * Optional override spec. If omitted, the primitive reads the\n * `generative-ui` part from the surrounding `MessagePartProvider` /\n * `PartByIndexProvider` context.\n */\n spec?: GenerativeUISpec | undefined;\n /** Optional fallback for unknown component names. */\n Fallback?:\n | ComponentType<{ component: string; props?: unknown }>\n | undefined;\n };\n}\n\n/**\n * Renders a generative-ui message part using a consumer-provided allowlist.\n *\n * The agent emits a `generative-ui` message part containing a JSON spec\n * (see {@link GenerativeUISpec}). This primitive walks the spec and resolves\n * each `component` name against the allowlist. Names not in the allowlist\n * throw {@link GenerativeUIRenderError} unless a `Fallback` is provided.\n *\n * Stream-friendly: a partial spec renders progressively as it is filled in.\n *\n * @example\n * ```tsx\n * <MessagePrimitive.GenerativeUI\n * components={{ Card: MyCard, Button: MyButton }}\n * />\n * ```\n */\nexport const MessagePrimitiveGenerativeUI: FC<\n MessagePrimitiveGenerativeUI.Props\n> = ({ components, spec, Fallback }) => {\n // Selector reads store state only — combining with the `spec` prop inside\n // the selector closes over a value that may change identity per render and\n // would trigger spurious tearing-detection re-renders in\n // `useSyncExternalStore`.\n const storeSpec = useAuiState((s) => {\n const part = s.part as { type?: string; spec?: GenerativeUISpec };\n return part?.type === \"generative-ui\" ? part.spec : undefined;\n });\n const partSpec = spec ?? storeSpec;\n\n if (!partSpec) return null;\n\n return (\n <GenerativeUIRender\n spec={partSpec}\n components={components}\n Fallback={Fallback}\n />\n );\n};\n\nMessagePrimitiveGenerativeUI.displayName = \"MessagePrimitive.GenerativeUI\";\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"GenerativeUI.js","names":["c","_c","ComponentType","FC","ReactNode","createElement","useMemo","useAuiState","GenerativeUINode","GenerativeUISpec","GenerativeUIComponentRegistry","GenerativeUIRenderProps","GenerativeUIRenderError","Error","componentName","constructor","message","name","isObjectNode","node","Exclude","renderNode","components","Fallback","path","undefined","process","env","NODE_ENV","console","warn","component","props","children","key","Resolved","renderedChildren","length","map","child","i","normalizeRoot","spec","root","Array","isArray","GenerativeUIRender","t0","$","t1","nodes","t2","t3","displayName","MessagePrimitiveGenerativeUI","Props","storeSpec","_temp","partSpec","s","part","type"],"sources":["../../../../src/react/primitives/generativeUI/GenerativeUI.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type ComponentType,\n type FC,\n type ReactNode,\n createElement,\n useMemo,\n} from \"react\";\nimport { useAuiState } from \"@assistant-ui/store\";\nimport type {\n GenerativeUINode,\n GenerativeUISpec,\n} from \"../../../types/message\";\nimport type {\n GenerativeUIComponentRegistry,\n GenerativeUIRenderProps,\n} from \"../../types/MessagePartComponentTypes\";\n\n/**\n * Thrown when a generative-ui spec references a component name that is not\n * present in the consumer-provided allowlist. The allowlist is the security\n * boundary in the same-realm rendering path — there is no fallback by\n * default. Pass `Fallback` to opt into a soft-fail UX.\n */\nexport class GenerativeUIRenderError extends Error {\n public readonly componentName: string;\n\n constructor(\n componentName: string,\n message = `Component \"${componentName}\" is not in the generative-ui allowlist.`,\n ) {\n super(message);\n this.name = \"GenerativeUIRenderError\";\n this.componentName = componentName;\n }\n}\n\nconst isObjectNode = (\n node: GenerativeUINode,\n): node is Exclude<GenerativeUINode, string> =>\n typeof node === \"object\" && node !== null;\n\nconst renderNode = (\n node: GenerativeUINode | undefined,\n components: GenerativeUIComponentRegistry,\n Fallback: GenerativeUIRenderProps[\"Fallback\"],\n path: string,\n): ReactNode => {\n if (node === undefined || node === null) return null;\n\n if (typeof node === \"string\") return node;\n\n if (!isObjectNode(node) || !(\"component\" in node)) {\n if (\n typeof process !== \"undefined\" &&\n process.env?.NODE_ENV !== \"production\"\n ) {\n console.warn(`[generative-ui] Skipping malformed node at ${path}:`, node);\n }\n return null;\n }\n\n const { component, props, children, key } = node;\n\n const Resolved = components[component];\n if (!Resolved) {\n if (Fallback) {\n return <Fallback key={key ?? path} component={component} props={props} />;\n }\n throw new GenerativeUIRenderError(component);\n }\n\n const renderedChildren = children?.length\n ? children.map((child, i) =>\n renderNode(child, components, Fallback, `${path}/${i}`),\n )\n : undefined;\n\n return createElement(\n Resolved,\n { ...(props ?? {}), key: key ?? path },\n ...(renderedChildren ?? []),\n );\n};\n\nconst normalizeRoot = (\n spec: GenerativeUISpec | undefined,\n): readonly GenerativeUINode[] => {\n if (!spec || spec.root === undefined || spec.root === null) return [];\n const root = spec.root;\n return Array.isArray(root)\n ? (root as readonly GenerativeUINode[])\n : [root as GenerativeUINode];\n};\n\n/**\n * Internal renderer. Resolves a {@link GenerativeUISpec} against the consumer\n * allowlist. Used by `MessagePrimitive.GenerativeUI` and by\n * `MessagePrimitive.Parts` when handling a `generative-ui` part.\n */\nexport const GenerativeUIRender: FC<GenerativeUIRenderProps> = ({\n spec,\n components,\n Fallback,\n}) => {\n const nodes = useMemo(() => normalizeRoot(spec), [spec]);\n\n return (\n <>\n {nodes.map((node, i) => renderNode(node, components, Fallback, `${i}`))}\n </>\n );\n};\n\nGenerativeUIRender.displayName = \"GenerativeUIRender\";\n\nexport namespace MessagePrimitiveGenerativeUI {\n export type Props = {\n /**\n * The component allowlist. Keys are the names referenced in the spec\n * (e.g. `\"Card\"`, `\"Button\"`), values are the React components.\n *\n * This is the security boundary — any name not in the allowlist is\n * rejected with {@link GenerativeUIRenderError}.\n */\n components: GenerativeUIComponentRegistry;\n /**\n * Optional override spec. If omitted, the primitive reads the\n * `generative-ui` part from the surrounding `MessagePartProvider` /\n * `PartByIndexProvider` context.\n */\n spec?: GenerativeUISpec | undefined;\n /** Optional fallback for unknown component names. */\n Fallback?:\n | ComponentType<{ component: string; props?: unknown }>\n | undefined;\n };\n}\n\n/**\n * Renders a generative-ui message part using a consumer-provided allowlist.\n *\n * The agent emits a `generative-ui` message part containing a JSON spec\n * (see {@link GenerativeUISpec}). This primitive walks the spec and resolves\n * each `component` name against the allowlist. Names not in the allowlist\n * throw {@link GenerativeUIRenderError} unless a `Fallback` is provided.\n *\n * Stream-friendly: a partial spec renders progressively as it is filled in.\n *\n * @example\n * ```tsx\n * <MessagePrimitive.GenerativeUI\n * components={{ Card: MyCard, Button: MyButton }}\n * />\n * ```\n */\nexport const MessagePrimitiveGenerativeUI: FC<\n MessagePrimitiveGenerativeUI.Props\n> = ({ components, spec, Fallback }) => {\n // Selector reads store state only — combining with the `spec` prop inside\n // the selector closes over a value that may change identity per render and\n // would trigger spurious tearing-detection re-renders in\n // `useSyncExternalStore`.\n const storeSpec = useAuiState((s) => {\n const part = s.part as { type?: string; spec?: GenerativeUISpec };\n return part?.type === \"generative-ui\" ? part.spec : undefined;\n });\n const partSpec = spec ?? storeSpec;\n\n if (!partSpec) return null;\n\n return (\n <GenerativeUIRender\n spec={partSpec}\n components={components}\n Fallback={Fallback}\n />\n );\n};\n\nMessagePrimitiveGenerativeUI.displayName = \"MessagePrimitive.GenerativeUI\";\n"],"mappings":";;;;;;;;;;;;AAyBA,IAAaY,0BAAb,cAA6CC,MAAM;CACjD;CAEAE,YACED,eACAE,UAAU,cAAcF,cAAa,2CACrC;EACA,MAAME,OAAO;EACb,KAAKC,OAAO;EACZ,KAAKH,gBAAgBA;CACvB;AACF;AAEA,MAAMI,gBACJC,SAEA,OAAOA,SAAS,YAAYA,SAAS;AAEvC,MAAME,cACJF,MACAG,YACAC,UACAC,SACc;CACd,IAAIL,SAASM,KAAAA,KAAaN,SAAS,MAAM,OAAO;CAE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,MAAAC,OAAaD,EAACC;CAAoD,OAC3DA,MAAIC,SAAW,kBAAkBD,KAAIlB,OAArCjB,KAAAA;AAAsD"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { MessageAttachmentByIndexProvider } from "../../providers/AttachmentByIndexProvider.js";
|
|
2
2
|
import { memo, useMemo } from "@assistant-ui/tap/react-shim";
|
|
3
3
|
import { RenderChildrenWithAccessor, useAuiState } from "@assistant-ui/store";
|
|
4
|
+
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
4
5
|
import { jsx } from "react/jsx-runtime";
|
|
5
6
|
//#region src/react/primitives/message/MessageAttachments.tsx
|
|
6
7
|
const getComponent = (components, attachment) => {
|
|
@@ -11,21 +12,52 @@ const getComponent = (components, attachment) => {
|
|
|
11
12
|
default: return components?.Attachment;
|
|
12
13
|
}
|
|
13
14
|
};
|
|
14
|
-
const AttachmentComponent = (
|
|
15
|
-
const
|
|
15
|
+
const AttachmentComponent = (t0) => {
|
|
16
|
+
const $ = c(5);
|
|
17
|
+
const { components } = t0;
|
|
18
|
+
const attachment = useAuiState(_temp);
|
|
16
19
|
if (!attachment) return null;
|
|
17
|
-
const
|
|
20
|
+
const t1 = attachment;
|
|
21
|
+
let t2;
|
|
22
|
+
if ($[0] !== components || $[1] !== t1) {
|
|
23
|
+
t2 = getComponent(components, t1);
|
|
24
|
+
$[0] = components;
|
|
25
|
+
$[1] = t1;
|
|
26
|
+
$[2] = t2;
|
|
27
|
+
} else t2 = $[2];
|
|
28
|
+
const Component = t2;
|
|
18
29
|
if (!Component) return null;
|
|
19
|
-
|
|
30
|
+
let t3;
|
|
31
|
+
if ($[3] !== Component) {
|
|
32
|
+
t3 = /* @__PURE__ */ jsx(Component, {});
|
|
33
|
+
$[3] = Component;
|
|
34
|
+
$[4] = t3;
|
|
35
|
+
} else t3 = $[4];
|
|
36
|
+
return t3;
|
|
20
37
|
};
|
|
21
38
|
/**
|
|
22
39
|
* Renders a single attachment at the specified index within the current message.
|
|
23
40
|
*/
|
|
24
|
-
const MessagePrimitiveAttachmentByIndex = memo((
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
41
|
+
const MessagePrimitiveAttachmentByIndex = memo((t0) => {
|
|
42
|
+
const $ = c(5);
|
|
43
|
+
const { index, components } = t0;
|
|
44
|
+
let t1;
|
|
45
|
+
if ($[0] !== components) {
|
|
46
|
+
t1 = /* @__PURE__ */ jsx(AttachmentComponent, { components });
|
|
47
|
+
$[0] = components;
|
|
48
|
+
$[1] = t1;
|
|
49
|
+
} else t1 = $[1];
|
|
50
|
+
let t2;
|
|
51
|
+
if ($[2] !== index || $[3] !== t1) {
|
|
52
|
+
t2 = /* @__PURE__ */ jsx(MessageAttachmentByIndexProvider, {
|
|
53
|
+
index,
|
|
54
|
+
children: t1
|
|
55
|
+
});
|
|
56
|
+
$[2] = index;
|
|
57
|
+
$[3] = t1;
|
|
58
|
+
$[4] = t2;
|
|
59
|
+
} else t2 = $[4];
|
|
60
|
+
return t2;
|
|
29
61
|
}, (prev, next) => prev.index === next.index && prev.components?.Image === next.components?.Image && prev.components?.Document === next.components?.Document && prev.components?.File === next.components?.File && prev.components?.Attachment === next.components?.Attachment);
|
|
30
62
|
MessagePrimitiveAttachmentByIndex.displayName = "MessagePrimitive.AttachmentByIndex";
|
|
31
63
|
const MessagePrimitiveAttachmentsInner = ({ children }) => {
|
|
@@ -43,15 +75,35 @@ const MessagePrimitiveAttachmentsInner = ({ children }) => {
|
|
|
43
75
|
})
|
|
44
76
|
}, index)), [attachmentsCount, children]);
|
|
45
77
|
};
|
|
46
|
-
const MessagePrimitiveAttachments = (
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
78
|
+
const MessagePrimitiveAttachments = (t0) => {
|
|
79
|
+
const $ = c(4);
|
|
80
|
+
const { components, children } = t0;
|
|
81
|
+
if (components) {
|
|
82
|
+
let t1;
|
|
83
|
+
if ($[0] !== components) {
|
|
84
|
+
t1 = /* @__PURE__ */ jsx(MessagePrimitiveAttachmentsInner, { children: (t2) => {
|
|
85
|
+
const { attachment } = t2;
|
|
86
|
+
const Component = getComponent(components, attachment);
|
|
87
|
+
if (!Component) return null;
|
|
88
|
+
return /* @__PURE__ */ jsx(Component, {});
|
|
89
|
+
} });
|
|
90
|
+
$[0] = components;
|
|
91
|
+
$[1] = t1;
|
|
92
|
+
} else t1 = $[1];
|
|
93
|
+
return t1;
|
|
94
|
+
}
|
|
95
|
+
let t1;
|
|
96
|
+
if ($[2] !== children) {
|
|
97
|
+
t1 = /* @__PURE__ */ jsx(MessagePrimitiveAttachmentsInner, { children });
|
|
98
|
+
$[2] = children;
|
|
99
|
+
$[3] = t1;
|
|
100
|
+
} else t1 = $[3];
|
|
101
|
+
return t1;
|
|
53
102
|
};
|
|
54
103
|
MessagePrimitiveAttachments.displayName = "MessagePrimitive.Attachments";
|
|
104
|
+
function _temp(s) {
|
|
105
|
+
return s.attachment;
|
|
106
|
+
}
|
|
55
107
|
//#endregion
|
|
56
108
|
export { MessagePrimitiveAttachmentByIndex, MessagePrimitiveAttachments };
|
|
57
109
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageAttachments.js","names":[],"sources":["../../../../src/react/primitives/message/MessageAttachments.tsx"],"sourcesContent":["import type { CompleteAttachment } from \"../../../types/attachment\";\nimport {\n type ComponentType,\n type FC,\n type ReactNode,\n memo,\n useMemo,\n} from \"react\";\nimport { RenderChildrenWithAccessor, useAuiState } from \"@assistant-ui/store\";\nimport { MessageAttachmentByIndexProvider } from \"../../providers/AttachmentByIndexProvider\";\n\ntype MessageAttachmentsComponentConfig = {\n Image?: ComponentType | undefined;\n Document?: ComponentType | undefined;\n File?: ComponentType | undefined;\n Attachment?: ComponentType | undefined;\n};\n\nexport namespace MessagePrimitiveAttachments {\n export type Props =\n | {\n /** @deprecated Use the children render function instead. */\n components: MessageAttachmentsComponentConfig;\n children?: never;\n }\n | {\n /** Render function called for each attachment. Receives the attachment. */\n children: (value: { attachment: CompleteAttachment }) => ReactNode;\n components?: never;\n };\n}\n\nconst getComponent = (\n components: MessageAttachmentsComponentConfig | undefined,\n attachment: CompleteAttachment,\n) => {\n const type = attachment.type;\n switch (type) {\n case \"image\":\n return components?.Image ?? components?.Attachment;\n case \"document\":\n return components?.Document ?? components?.Attachment;\n case \"file\":\n return components?.File ?? components?.Attachment;\n default:\n return components?.Attachment;\n }\n};\n\nconst AttachmentComponent: FC<{\n components: MessageAttachmentsComponentConfig | undefined;\n}> = ({ components }) => {\n const attachment = useAuiState((s) => s.attachment);\n if (!attachment) return null;\n\n const Component = getComponent(components, attachment as CompleteAttachment);\n if (!Component) return null;\n return <Component />;\n};\n\nexport namespace MessagePrimitiveAttachmentByIndex {\n export type Props = {\n index: number;\n components?: MessageAttachmentsComponentConfig;\n };\n}\n\n/**\n * Renders a single attachment at the specified index within the current message.\n */\nexport const MessagePrimitiveAttachmentByIndex: FC<MessagePrimitiveAttachmentByIndex.Props> =\n memo(\n ({ index, components }) => {\n return (\n <MessageAttachmentByIndexProvider index={index}>\n <AttachmentComponent components={components} />\n </MessageAttachmentByIndexProvider>\n );\n },\n (prev, next) =>\n prev.index === next.index &&\n prev.components?.Image === next.components?.Image &&\n prev.components?.Document === next.components?.Document &&\n prev.components?.File === next.components?.File &&\n prev.components?.Attachment === next.components?.Attachment,\n );\n\nMessagePrimitiveAttachmentByIndex.displayName =\n \"MessagePrimitive.AttachmentByIndex\";\n\nconst MessagePrimitiveAttachmentsInner: FC<{\n children: (value: { attachment: CompleteAttachment }) => ReactNode;\n}> = ({ children }) => {\n const attachmentsCount = useAuiState((s) => {\n if (s.message.role !== \"user\") return 0;\n return (s.message.attachments ?? []).length;\n });\n\n return useMemo(\n () =>\n Array.from({ length: attachmentsCount }, (_, index) => (\n <MessageAttachmentByIndexProvider key={index} index={index}>\n <RenderChildrenWithAccessor\n getItemState={(aui) =>\n aui.message().attachment({ index }).getState()\n }\n >\n {(getItem) =>\n children({\n get attachment() {\n return getItem() as CompleteAttachment;\n },\n })\n }\n </RenderChildrenWithAccessor>\n </MessageAttachmentByIndexProvider>\n )),\n [attachmentsCount, children],\n );\n};\n\nexport const MessagePrimitiveAttachments: FC<\n MessagePrimitiveAttachments.Props\n> = ({ components, children }) => {\n if (components) {\n return (\n <MessagePrimitiveAttachmentsInner>\n {({ attachment }) => {\n const Component = getComponent(components, attachment);\n if (!Component) return null;\n return <Component />;\n }}\n </MessagePrimitiveAttachmentsInner>\n );\n }\n return (\n <MessagePrimitiveAttachmentsInner>\n {children}\n </MessagePrimitiveAttachmentsInner>\n );\n};\n\nMessagePrimitiveAttachments.displayName = \"MessagePrimitive.Attachments\";\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"MessageAttachments.js","names":["CompleteAttachment","ComponentType","FC","ReactNode","memo","useMemo","RenderChildrenWithAccessor","useAuiState","MessageAttachmentByIndexProvider","MessageAttachmentsComponentConfig","Image","Document","File","Attachment","MessagePrimitiveAttachments","Props","components","children","value","attachment","getComponent","type","AttachmentComponent","t0","$","_c","_temp","t1","t2","Component","t3","MessagePrimitiveAttachmentByIndex","index","prev","next","displayName","MessagePrimitiveAttachmentsInner","attachmentsCount","s","message","role","attachments","length","Array","from","_","aui","getState","getItem"],"sources":["../../../../src/react/primitives/message/MessageAttachments.tsx"],"sourcesContent":["import type { CompleteAttachment } from \"../../../types/attachment\";\nimport {\n type ComponentType,\n type FC,\n type ReactNode,\n memo,\n useMemo,\n} from \"react\";\nimport { RenderChildrenWithAccessor, useAuiState } from \"@assistant-ui/store\";\nimport { MessageAttachmentByIndexProvider } from \"../../providers/AttachmentByIndexProvider\";\n\ntype MessageAttachmentsComponentConfig = {\n Image?: ComponentType | undefined;\n Document?: ComponentType | undefined;\n File?: ComponentType | undefined;\n Attachment?: ComponentType | undefined;\n};\n\nexport namespace MessagePrimitiveAttachments {\n export type Props =\n | {\n /** @deprecated Use the children render function instead. */\n components: MessageAttachmentsComponentConfig;\n children?: never;\n }\n | {\n /** Render function called for each attachment. Receives the attachment. */\n children: (value: { attachment: CompleteAttachment }) => ReactNode;\n components?: never;\n };\n}\n\nconst getComponent = (\n components: MessageAttachmentsComponentConfig | undefined,\n attachment: CompleteAttachment,\n) => {\n const type = attachment.type;\n switch (type) {\n case \"image\":\n return components?.Image ?? components?.Attachment;\n case \"document\":\n return components?.Document ?? components?.Attachment;\n case \"file\":\n return components?.File ?? components?.Attachment;\n default:\n return components?.Attachment;\n }\n};\n\nconst AttachmentComponent: FC<{\n components: MessageAttachmentsComponentConfig | undefined;\n}> = ({ components }) => {\n const attachment = useAuiState((s) => s.attachment);\n if (!attachment) return null;\n\n const Component = getComponent(components, attachment as CompleteAttachment);\n if (!Component) return null;\n return <Component />;\n};\n\nexport namespace MessagePrimitiveAttachmentByIndex {\n export type Props = {\n index: number;\n components?: MessageAttachmentsComponentConfig;\n };\n}\n\n/**\n * Renders a single attachment at the specified index within the current message.\n */\nexport const MessagePrimitiveAttachmentByIndex: FC<MessagePrimitiveAttachmentByIndex.Props> =\n memo(\n ({ index, components }) => {\n return (\n <MessageAttachmentByIndexProvider index={index}>\n <AttachmentComponent components={components} />\n </MessageAttachmentByIndexProvider>\n );\n },\n (prev, next) =>\n prev.index === next.index &&\n prev.components?.Image === next.components?.Image &&\n prev.components?.Document === next.components?.Document &&\n prev.components?.File === next.components?.File &&\n prev.components?.Attachment === next.components?.Attachment,\n );\n\nMessagePrimitiveAttachmentByIndex.displayName =\n \"MessagePrimitive.AttachmentByIndex\";\n\nconst MessagePrimitiveAttachmentsInner: FC<{\n children: (value: { attachment: CompleteAttachment }) => ReactNode;\n}> = ({ children }) => {\n const attachmentsCount = useAuiState((s) => {\n if (s.message.role !== \"user\") return 0;\n return (s.message.attachments ?? []).length;\n });\n\n return useMemo(\n () =>\n Array.from({ length: attachmentsCount }, (_, index) => (\n <MessageAttachmentByIndexProvider key={index} index={index}>\n <RenderChildrenWithAccessor\n getItemState={(aui) =>\n aui.message().attachment({ index }).getState()\n }\n >\n {(getItem) =>\n children({\n get attachment() {\n return getItem() as CompleteAttachment;\n },\n })\n }\n </RenderChildrenWithAccessor>\n </MessageAttachmentByIndexProvider>\n )),\n [attachmentsCount, children],\n );\n};\n\nexport const MessagePrimitiveAttachments: FC<\n MessagePrimitiveAttachments.Props\n> = ({ components, children }) => {\n if (components) {\n return (\n <MessagePrimitiveAttachmentsInner>\n {({ attachment }) => {\n const Component = getComponent(components, attachment);\n if (!Component) return null;\n return <Component />;\n }}\n </MessagePrimitiveAttachmentsInner>\n );\n }\n return (\n <MessagePrimitiveAttachmentsInner>\n {children}\n </MessagePrimitiveAttachmentsInner>\n );\n};\n\nMessagePrimitiveAttachments.displayName = \"MessagePrimitive.Attachments\";\n"],"mappings":";;;;;;AAgCA,MAAMoB,gBACJJ,YACAG,eACG;CAEH,QADaA,WAAWE,MACxB;EACE,KAAK,SACH,OAAOL,YAAYN,SAASM,YAAYH;EAC1C,KAAK,YACH,OAAOG,YAAYL,YAAYK,YAAYH;EAC7C,KAAK,QACH,OAAOG,YAAYJ,QAAQI,YAAYH;EACzC,SACE,OAAOG,YAAYH;CACvB;AACF;AAEA,MAAMS,uBAEDC,OAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CAAC,MAAA,EAAAT,eAAAO;CACJ,MAAAJ,aAAmBZ,YAAYmB,KAAmB;CAClD,IAAI,CAACP,YAAU,OAAS;CAEmB,MAAAQ,KAAAR;CAAgC,IAAAS;CAAA,IAAAJ,EAAA,OAAAR,cAAAQ,EAAA,OAAAG,IAAA;EAAzDC,KAAAR,aAAaJ,YAAYW,EAAgC;EAACH,EAAA,KAAAR;EAAAQ,EAAA,KAAAG;EAAAH,EAAA,KAAAI;CAAA,OAAAA,KAAAJ,EAAA;CAA5E,MAAAK,YAAkBD;CAClB,IAAI,CAACC,WAAS,OAAS;CAAK,IAAAC;CAAA,IAAAN,EAAA,OAAAK,WAAA;EACrBC,KAAA,oBAAC,WAAD,CA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AW,EAAEa,MAAM,CAAC,CAAC,CAACe,SAAS;cAG7CC,YACA/B,SAAS,EACP,IAAIE,aAAa;IACf,OAAO6B,QAAQ;GACjB,EACF,CAAC;EAEuB,CAAA;CACI,GAdKhB,KAcL,CACnC,GACH,CAACK,kBAAkBpB,QAAQ,CAC7B;AACF;AAEA,MAAaH,+BAETS,OAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CAAC,MAAA,EAAAT,YAAAC,aAAAM;CACH,IAAIP,YAAU;EAAA,IAAAW;EAAA,IAAAH,EAAA,OAAAR,YAAA;GAEVW,KAAA,oBAAC,kCAAD,EAAA,WACGC,OAAA;IAAC,MAAA,EAAAT,eAAAS;IACA,MAAAC,YAAkBT,aAAaJ,YAAYG,UAAU;IACrD,IAAI,CAACU,WAAS,OAAS;IAAK,OACrB,oBAAC,WAAD,CAAU,CAAA;GAAG,EAJS,CAAA;GAMEL,EAAA,KAAAR;GAAAQ,EAAA,KAAAG;EAAA,OAAAA,KAAAH,EAAA;EAAA,OANnCG;CAMmC;CAEtC,IAAAA;CAAA,IAAAH,EAAA,OAAAP,UAAA;EAECU,KAAA,oBAAC,kCAAD,EACGV,SAD8B,CAAA;EAEEO,EAAA,KAAAP;EAAAO,EAAA,KAAAG;CAAA,OAAAA,KAAAH,EAAA;CAAA,OAFnCG;AAEmC;AAIvCb,4BAA4BqB,cAAc;AA3FrC,SAAAT,MAAAY,GAAA;CAAA,OACmCA,EAACnB;AAAW"}
|
|
@@ -81,11 +81,11 @@ const renderNode = (node, parts, render) => {
|
|
|
81
81
|
*/
|
|
82
82
|
const MessagePrimitiveGroupedParts = ({ groupBy, indicator = "no-text", children }) => {
|
|
83
83
|
const parts = useAuiState(useShallow((s) => s.message.parts));
|
|
84
|
-
const toolUIs = useAuiState((
|
|
85
|
-
const isRunning = useAuiState((
|
|
84
|
+
const toolUIs = useAuiState((s_0) => s_0.tools.toolUIs);
|
|
85
|
+
const isRunning = useAuiState((s_1) => indicator === "never" ? false : s_1.message.status?.type === "running");
|
|
86
86
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [useMemo(() => {
|
|
87
87
|
const context = { toolUIs };
|
|
88
|
-
return buildGroupTree(parts.map((part) => groupBy(part, context) ?? []), parts.map((
|
|
88
|
+
return buildGroupTree(parts.map((part) => groupBy(part, context) ?? []), parts.map((part_0) => part_0.type === "tool-call" ? part_0.toolCallId : void 0));
|
|
89
89
|
}, [
|
|
90
90
|
parts,
|
|
91
91
|
groupBy[GROUPBY_MEMO_KEY] ?? groupBy,
|