@assistant-ui/core 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/adapters/attachment.js +1 -1
- package/dist/adapters/attachment.js.map +1 -1
- package/dist/react/AssistantProvider.d.ts +10 -0
- package/dist/react/AssistantProvider.d.ts.map +1 -0
- package/dist/react/AssistantProvider.js +13 -0
- package/dist/react/AssistantProvider.js.map +1 -0
- package/dist/react/RuntimeAdapter.d.ts +3 -0
- package/dist/react/RuntimeAdapter.d.ts.map +1 -0
- package/dist/react/RuntimeAdapter.js +13 -0
- package/dist/react/RuntimeAdapter.js.map +1 -0
- package/dist/react/client/DataRenderers.d.ts +3 -0
- package/dist/react/client/DataRenderers.d.ts.map +1 -0
- package/dist/react/client/DataRenderers.js +33 -0
- package/dist/react/client/DataRenderers.js.map +1 -0
- package/dist/react/client/Tools.d.ts +8 -0
- package/dist/react/client/Tools.d.ts.map +1 -0
- package/dist/react/client/Tools.js +68 -0
- package/dist/react/client/Tools.js.map +1 -0
- package/dist/react/client/index.d.ts +3 -0
- package/dist/react/client/index.d.ts.map +1 -0
- package/dist/react/client/index.js +3 -0
- package/dist/react/client/index.js.map +1 -0
- package/dist/react/index.d.ts +17 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +19 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/model-context/index.d.ts +12 -0
- package/dist/react/model-context/index.d.ts.map +1 -0
- package/dist/react/model-context/index.js +11 -0
- package/dist/react/model-context/index.js.map +1 -0
- package/dist/react/model-context/makeAssistantDataUI.d.ts +7 -0
- package/dist/react/model-context/makeAssistantDataUI.d.ts.map +1 -0
- package/dist/react/model-context/makeAssistantDataUI.js +10 -0
- package/dist/react/model-context/makeAssistantDataUI.js.map +1 -0
- package/dist/react/model-context/makeAssistantTool.d.ts +7 -0
- package/dist/react/model-context/makeAssistantTool.d.ts.map +1 -0
- package/dist/react/model-context/makeAssistantTool.js +10 -0
- package/dist/react/model-context/makeAssistantTool.js.map +1 -0
- package/dist/react/model-context/makeAssistantToolUI.d.ts +7 -0
- package/dist/react/model-context/makeAssistantToolUI.d.ts.map +1 -0
- package/dist/react/model-context/makeAssistantToolUI.js +10 -0
- package/dist/react/model-context/makeAssistantToolUI.js.map +1 -0
- package/dist/react/model-context/toolbox.d.ts +10 -0
- package/dist/react/model-context/toolbox.d.ts.map +1 -0
- package/dist/react/model-context/toolbox.js +2 -0
- package/dist/react/model-context/toolbox.js.map +1 -0
- package/dist/react/model-context/useAssistantDataUI.d.ts +7 -0
- package/dist/react/model-context/useAssistantDataUI.d.ts.map +1 -0
- package/dist/react/model-context/useAssistantDataUI.js +11 -0
- package/dist/react/model-context/useAssistantDataUI.js.map +1 -0
- package/dist/react/model-context/useAssistantInstructions.d.ts +4 -0
- package/dist/react/model-context/useAssistantInstructions.d.ts.map +1 -0
- package/dist/react/model-context/useAssistantInstructions.js +22 -0
- package/dist/react/model-context/useAssistantInstructions.js.map +1 -0
- package/dist/react/model-context/useAssistantTool.d.ts +7 -0
- package/dist/react/model-context/useAssistantTool.d.ts.map +1 -0
- package/dist/react/model-context/useAssistantTool.js +22 -0
- package/dist/react/model-context/useAssistantTool.js.map +1 -0
- package/dist/react/model-context/useAssistantToolUI.d.ts +7 -0
- package/dist/react/model-context/useAssistantToolUI.d.ts.map +1 -0
- package/dist/react/model-context/useAssistantToolUI.js +11 -0
- package/dist/react/model-context/useAssistantToolUI.js.map +1 -0
- package/dist/react/model-context/useInlineRender.d.ts +4 -0
- package/dist/react/model-context/useInlineRender.d.ts.map +1 -0
- package/dist/react/model-context/useInlineRender.js +15 -0
- package/dist/react/model-context/useInlineRender.js.map +1 -0
- package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.d.ts +27 -0
- package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.d.ts.map +1 -0
- package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.js +27 -0
- package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.js.map +1 -0
- package/dist/react/primitives/composer/ComposerAttachments.d.ts +23 -0
- package/dist/react/primitives/composer/ComposerAttachments.d.ts.map +1 -0
- package/dist/react/primitives/composer/ComposerAttachments.js +47 -0
- package/dist/react/primitives/composer/ComposerAttachments.js.map +1 -0
- package/dist/react/primitives/composer/ComposerIf.d.ts +20 -0
- package/dist/react/primitives/composer/ComposerIf.d.ts.map +1 -0
- package/dist/react/primitives/composer/ComposerIf.js +24 -0
- package/dist/react/primitives/composer/ComposerIf.js.map +1 -0
- package/dist/react/primitives/message/MessageAttachments.d.ts +23 -0
- package/dist/react/primitives/message/MessageAttachments.d.ts.map +1 -0
- package/dist/react/primitives/message/MessageAttachments.js +51 -0
- package/dist/react/primitives/message/MessageAttachments.js.map +1 -0
- package/dist/react/primitives/message/MessageParts.d.ts +139 -0
- package/dist/react/primitives/message/MessageParts.d.ts.map +1 -0
- package/dist/react/primitives/message/MessageParts.js +251 -0
- package/dist/react/primitives/message/MessageParts.js.map +1 -0
- package/dist/react/primitives/thread/ThreadMessages.d.ts +95 -0
- package/dist/react/primitives/thread/ThreadMessages.d.ts.map +1 -0
- package/dist/react/primitives/thread/ThreadMessages.js +112 -0
- package/dist/react/primitives/thread/ThreadMessages.js.map +1 -0
- package/dist/react/primitives/thread/ThreadSuggestions.d.ts +28 -0
- package/dist/react/primitives/thread/ThreadSuggestions.d.ts.map +1 -0
- package/dist/react/primitives/thread/ThreadSuggestions.js +32 -0
- package/dist/react/primitives/thread/ThreadSuggestions.js.map +1 -0
- package/dist/react/primitives/threadList/ThreadListItems.d.ts +22 -0
- package/dist/react/primitives/threadList/ThreadListItems.d.ts.map +1 -0
- package/dist/react/primitives/threadList/ThreadListItems.js +23 -0
- package/dist/react/primitives/threadList/ThreadListItems.js.map +1 -0
- package/dist/react/primitives/threadListItem/ThreadListItemTitle.d.ts +8 -0
- package/dist/react/primitives/threadListItem/ThreadListItemTitle.d.ts.map +1 -0
- package/dist/react/primitives/threadListItem/ThreadListItemTitle.js +8 -0
- package/dist/react/primitives/threadListItem/ThreadListItemTitle.js.map +1 -0
- package/dist/react/providers/AttachmentByIndexProvider.d.ts +8 -0
- package/dist/react/providers/AttachmentByIndexProvider.d.ts.map +1 -0
- package/dist/react/providers/AttachmentByIndexProvider.js +23 -0
- package/dist/react/providers/AttachmentByIndexProvider.js.map +1 -0
- package/dist/react/providers/ChainOfThoughtByIndicesProvider.d.ts +6 -0
- package/dist/react/providers/ChainOfThoughtByIndicesProvider.d.ts.map +1 -0
- package/dist/react/providers/ChainOfThoughtByIndicesProvider.js +20 -0
- package/dist/react/providers/ChainOfThoughtByIndicesProvider.js.map +1 -0
- package/dist/react/providers/ChainOfThoughtPartByIndexProvider.d.ts +5 -0
- package/dist/react/providers/ChainOfThoughtPartByIndexProvider.d.ts.map +1 -0
- package/dist/react/providers/ChainOfThoughtPartByIndexProvider.js +13 -0
- package/dist/react/providers/ChainOfThoughtPartByIndexProvider.js.map +1 -0
- package/dist/react/providers/MessageByIndexProvider.d.ts +5 -0
- package/dist/react/providers/MessageByIndexProvider.d.ts.map +1 -0
- package/dist/react/providers/MessageByIndexProvider.js +18 -0
- package/dist/react/providers/MessageByIndexProvider.js.map +1 -0
- package/dist/react/providers/PartByIndexProvider.d.ts +5 -0
- package/dist/react/providers/PartByIndexProvider.d.ts.map +1 -0
- package/dist/react/providers/PartByIndexProvider.js +13 -0
- package/dist/react/providers/PartByIndexProvider.js.map +1 -0
- package/dist/react/providers/SuggestionByIndexProvider.d.ts +6 -0
- package/dist/react/providers/SuggestionByIndexProvider.d.ts.map +1 -0
- package/dist/react/providers/SuggestionByIndexProvider.js +13 -0
- package/dist/react/providers/SuggestionByIndexProvider.js.map +1 -0
- package/dist/react/providers/TextMessagePartProvider.d.ts +6 -0
- package/dist/react/providers/TextMessagePartProvider.d.ts.map +1 -0
- package/dist/react/providers/TextMessagePartProvider.js +26 -0
- package/dist/react/providers/TextMessagePartProvider.js.map +1 -0
- package/dist/react/providers/ThreadListItemByIndexProvider.d.ts +6 -0
- package/dist/react/providers/ThreadListItemByIndexProvider.d.ts.map +1 -0
- package/dist/react/providers/ThreadListItemByIndexProvider.js +13 -0
- package/dist/react/providers/ThreadListItemByIndexProvider.js.map +1 -0
- package/dist/react/providers/ThreadListItemRuntimeProvider.d.ts +6 -0
- package/dist/react/providers/ThreadListItemRuntimeProvider.d.ts.map +1 -0
- package/dist/react/providers/ThreadListItemRuntimeProvider.js +10 -0
- package/dist/react/providers/ThreadListItemRuntimeProvider.js.map +1 -0
- package/dist/react/providers/index.d.ts +10 -0
- package/dist/react/providers/index.d.ts.map +1 -0
- package/dist/react/providers/index.js +10 -0
- package/dist/react/providers/index.js.map +1 -0
- package/dist/react/types/MessagePartComponentTypes.d.ts +33 -0
- package/dist/react/types/MessagePartComponentTypes.d.ts.map +1 -0
- package/dist/react/types/MessagePartComponentTypes.js +2 -0
- package/dist/react/types/MessagePartComponentTypes.js.map +1 -0
- package/dist/react/types/index.d.ts +3 -0
- package/dist/react/types/index.d.ts.map +1 -0
- package/dist/react/types/index.js +2 -0
- package/dist/react/types/index.js.map +1 -0
- package/dist/react/types/scopes/dataRenderers.d.ts +13 -0
- package/dist/react/types/scopes/dataRenderers.d.ts.map +1 -0
- package/dist/react/types/scopes/dataRenderers.js +2 -0
- package/dist/react/types/scopes/dataRenderers.js.map +1 -0
- package/dist/react/types/scopes/index.d.ts +3 -0
- package/dist/react/types/scopes/index.d.ts.map +1 -0
- package/dist/react/types/scopes/index.js +2 -0
- package/dist/react/types/scopes/index.js.map +1 -0
- package/dist/react/types/scopes/tools.d.ts +13 -0
- package/dist/react/types/scopes/tools.d.ts.map +1 -0
- package/dist/react/types/scopes/tools.js +2 -0
- package/dist/react/types/scopes/tools.js.map +1 -0
- package/dist/react/types/store-augmentation.d.ts +10 -0
- package/dist/react/types/store-augmentation.d.ts.map +1 -0
- package/dist/react/types/store-augmentation.js +2 -0
- package/dist/react/types/store-augmentation.js.map +1 -0
- package/dist/runtime/api/attachment-runtime.d.ts +2 -2
- package/dist/runtime/api/attachment-runtime.d.ts.map +1 -1
- package/dist/runtime/api/attachment-runtime.js.map +1 -1
- package/dist/runtime/api/composer-runtime.d.ts +8 -6
- package/dist/runtime/api/composer-runtime.d.ts.map +1 -1
- package/dist/runtime/api/composer-runtime.js +2 -2
- package/dist/runtime/api/composer-runtime.js.map +1 -1
- package/dist/runtime/api/thread-runtime.d.ts +27 -2
- package/dist/runtime/api/thread-runtime.d.ts.map +1 -1
- package/dist/runtime/base/base-composer-runtime-core.d.ts +2 -2
- package/dist/runtime/base/base-composer-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/base-composer-runtime-core.js +28 -8
- package/dist/runtime/base/base-composer-runtime-core.js.map +1 -1
- package/dist/runtime/base/default-thread-composer-runtime-core.d.ts +1 -2
- package/dist/runtime/base/default-thread-composer-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/default-thread-composer-runtime-core.js +0 -3
- package/dist/runtime/base/default-thread-composer-runtime-core.js.map +1 -1
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +1 -1
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/interfaces/composer-runtime-core.d.ts +3 -5
- package/dist/runtime/interfaces/composer-runtime-core.d.ts.map +1 -1
- package/dist/runtime/utils/external-store-message.d.ts +8 -0
- package/dist/runtime/utils/external-store-message.d.ts.map +1 -1
- package/dist/runtime/utils/external-store-message.js +12 -0
- package/dist/runtime/utils/external-store-message.js.map +1 -1
- package/dist/runtime/utils/thread-message-like.d.ts +10 -3
- package/dist/runtime/utils/thread-message-like.d.ts.map +1 -1
- package/dist/runtime/utils/thread-message-like.js +20 -5
- package/dist/runtime/utils/thread-message-like.js.map +1 -1
- package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/external-store/external-store-thread-runtime-core.js +26 -8
- package/dist/runtimes/external-store/external-store-thread-runtime-core.js.map +1 -1
- package/dist/runtimes/remote-thread-list/empty-thread-core.js +1 -1
- package/dist/runtimes/remote-thread-list/empty-thread-core.js.map +1 -1
- package/dist/store/clients/chain-of-thought-client.d.ts +1 -1
- package/dist/store/clients/chain-of-thought-client.d.ts.map +1 -1
- package/dist/store/clients/model-context-client.d.ts +1 -1
- package/dist/store/clients/model-context-client.d.ts.map +1 -1
- package/dist/store/clients/no-op-composer-client.d.ts +1 -1
- package/dist/store/clients/no-op-composer-client.d.ts.map +1 -1
- package/dist/store/clients/runtime-adapter.d.ts +5 -0
- package/dist/store/clients/runtime-adapter.d.ts.map +1 -0
- package/dist/store/clients/runtime-adapter.js +46 -0
- package/dist/store/clients/runtime-adapter.js.map +1 -0
- package/dist/store/clients/suggestions.d.ts +1 -1
- package/dist/store/clients/suggestions.d.ts.map +1 -1
- package/dist/store/clients/suggestions.js +1 -1
- package/dist/store/clients/suggestions.js.map +1 -1
- package/dist/store/clients/thread-message-client.d.ts +1 -1
- package/dist/store/clients/thread-message-client.d.ts.map +1 -1
- package/dist/store/clients/thread-message-client.js +1 -1
- package/dist/store/clients/thread-message-client.js.map +1 -1
- package/dist/store/index.d.ts +1 -11
- package/dist/store/index.d.ts.map +1 -1
- package/dist/store/index.js +2 -9
- package/dist/store/index.js.map +1 -1
- package/dist/store/internal.d.ts +1 -9
- package/dist/store/internal.d.ts.map +1 -1
- package/dist/store/internal.js +1 -10
- package/dist/store/internal.js.map +1 -1
- package/dist/store/runtime-clients/attachment-runtime-client.d.ts +1 -1
- package/dist/store/runtime-clients/attachment-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/composer-runtime-client.d.ts +1 -1
- package/dist/store/runtime-clients/composer-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/composer-runtime-client.js +1 -1
- package/dist/store/runtime-clients/composer-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/message-part-runtime-client.d.ts +1 -1
- package/dist/store/runtime-clients/message-part-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/message-runtime-client.d.ts +1 -1
- package/dist/store/runtime-clients/message-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/message-runtime-client.js +1 -1
- package/dist/store/runtime-clients/message-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/thread-list-item-runtime-client.d.ts +1 -1
- package/dist/store/runtime-clients/thread-list-item-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/thread-list-item-runtime-client.js +1 -1
- 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 +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 +1 -1
- package/dist/store/runtime-clients/thread-list-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/thread-runtime-client.d.ts +1 -1
- package/dist/store/runtime-clients/thread-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/thread-runtime-client.js +1 -1
- package/dist/store/runtime-clients/thread-runtime-client.js.map +1 -1
- package/dist/store/scope-registration.d.ts +27 -0
- package/dist/store/scope-registration.d.ts.map +1 -0
- package/dist/store/scope-registration.js +2 -0
- package/dist/store/scope-registration.js.map +1 -0
- package/dist/store/scopes/composer.d.ts +2 -2
- package/dist/store/scopes/composer.d.ts.map +1 -1
- package/dist/types/attachment.d.ts +9 -2
- package/dist/types/attachment.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +35 -12
- package/src/adapters/attachment.ts +1 -1
- package/src/react/AssistantProvider.tsx +34 -0
- package/src/react/RuntimeAdapter.ts +22 -0
- package/src/react/client/DataRenderers.ts +42 -0
- package/src/react/client/Tools.ts +97 -0
- package/src/react/client/index.ts +2 -0
- package/src/react/index.ts +50 -0
- package/src/react/model-context/index.ts +25 -0
- package/src/react/model-context/makeAssistantDataUI.ts +20 -0
- package/src/react/model-context/makeAssistantTool.ts +20 -0
- package/src/react/model-context/makeAssistantToolUI.ts +20 -0
- package/src/react/model-context/toolbox.ts +15 -0
- package/src/react/model-context/useAssistantDataUI.ts +16 -0
- package/src/react/model-context/useAssistantInstructions.ts +30 -0
- package/src/react/model-context/useAssistantTool.ts +37 -0
- package/src/react/model-context/useAssistantToolUI.ts +18 -0
- package/src/react/model-context/useInlineRender.ts +25 -0
- package/src/react/primitives/chainOfThought/ChainOfThoughtParts.tsx +73 -0
- package/src/react/primitives/composer/ComposerAttachments.tsx +95 -0
- package/src/react/primitives/composer/ComposerIf.tsx +49 -0
- package/src/react/primitives/message/MessageAttachments.tsx +98 -0
- package/src/react/primitives/message/MessageParts.tsx +561 -0
- package/src/react/primitives/thread/ThreadMessages.tsx +222 -0
- package/src/react/primitives/thread/ThreadSuggestions.tsx +82 -0
- package/src/react/primitives/threadList/ThreadListItems.tsx +66 -0
- package/src/react/primitives/threadListItem/ThreadListItemTitle.tsx +17 -0
- package/src/react/providers/AttachmentByIndexProvider.tsx +34 -0
- package/src/react/providers/ChainOfThoughtByIndicesProvider.tsx +34 -0
- package/src/react/providers/ChainOfThoughtPartByIndexProvider.tsx +18 -0
- package/src/react/providers/MessageByIndexProvider.tsx +23 -0
- package/src/react/providers/PartByIndexProvider.tsx +18 -0
- package/src/react/providers/SuggestionByIndexProvider.tsx +21 -0
- package/src/react/providers/TextMessagePartProvider.tsx +46 -0
- package/src/react/providers/ThreadListItemByIndexProvider.tsx +19 -0
- package/src/react/providers/ThreadListItemRuntimeProvider.tsx +16 -0
- package/src/react/providers/index.ts +15 -0
- package/src/react/types/MessagePartComponentTypes.ts +66 -0
- package/src/react/types/index.ts +31 -0
- package/src/react/types/scopes/dataRenderers.ts +15 -0
- package/src/react/types/scopes/index.ts +6 -0
- package/src/react/types/scopes/tools.ts +18 -0
- package/src/react/types/store-augmentation.ts +11 -0
- package/src/runtime/api/attachment-runtime.ts +2 -7
- package/src/runtime/api/composer-runtime.ts +9 -8
- package/src/runtime/base/base-composer-runtime-core.ts +28 -8
- package/src/runtime/base/default-thread-composer-runtime-core.ts +1 -5
- package/src/runtime/index.ts +1 -0
- package/src/runtime/interfaces/composer-runtime-core.ts +3 -6
- package/src/runtime/utils/external-store-message.ts +15 -0
- package/src/runtime/utils/thread-message-like.ts +40 -7
- package/src/runtimes/external-store/external-store-thread-runtime-core.ts +29 -12
- package/src/runtimes/remote-thread-list/empty-thread-core.ts +1 -1
- package/src/store/clients/chain-of-thought-client.ts +1 -1
- package/src/store/clients/model-context-client.ts +1 -1
- package/src/store/clients/no-op-composer-client.ts +1 -1
- package/src/store/clients/runtime-adapter.ts +67 -0
- package/src/store/clients/suggestions.ts +2 -2
- package/src/store/clients/thread-message-client.ts +2 -2
- package/src/store/index.ts +2 -38
- package/src/store/internal.ts +4 -31
- package/src/store/runtime-clients/attachment-runtime-client.ts +1 -1
- package/src/store/runtime-clients/composer-runtime-client.ts +5 -1
- package/src/store/runtime-clients/message-part-runtime-client.ts +1 -1
- package/src/store/runtime-clients/message-runtime-client.ts +5 -1
- package/src/store/runtime-clients/thread-list-item-runtime-client.ts +1 -1
- package/src/store/runtime-clients/thread-list-runtime-client.ts +5 -1
- package/src/store/runtime-clients/thread-runtime-client.ts +1 -1
- package/src/store/scope-registration.ts +27 -0
- package/src/store/scopes/composer.ts +2 -1
- package/src/tests/external-store-thread-runtime-core.test.ts +152 -0
- package/src/tests/thread-message-like.test.ts +110 -0
- package/src/types/attachment.ts +10 -2
- package/src/types/index.ts +1 -0
- package/dist/store/types/client.d.ts +0 -137
- package/dist/store/types/client.d.ts.map +0 -1
- package/dist/store/types/client.js +0 -2
- package/dist/store/types/client.js.map +0 -1
- package/dist/store/types/events.d.ts +0 -33
- package/dist/store/types/events.d.ts.map +0 -1
- package/dist/store/types/events.js +0 -8
- package/dist/store/types/events.js.map +0 -1
- package/dist/store/types/index.d.ts +0 -3
- package/dist/store/types/index.d.ts.map +0 -1
- package/dist/store/types/index.js +0 -2
- package/dist/store/types/index.js.map +0 -1
- package/dist/store/utils/attach-transform-scopes.d.ts +0 -11
- package/dist/store/utils/attach-transform-scopes.d.ts.map +0 -1
- package/dist/store/utils/attach-transform-scopes.js +0 -12
- package/dist/store/utils/attach-transform-scopes.js.map +0 -1
- package/dist/store/utils/base-proxy-handler.d.ts +0 -23
- package/dist/store/utils/base-proxy-handler.d.ts.map +0 -1
- package/dist/store/utils/base-proxy-handler.js +0 -46
- package/dist/store/utils/base-proxy-handler.js.map +0 -1
- package/dist/store/utils/derived.d.ts +0 -34
- package/dist/store/utils/derived.d.ts.map +0 -1
- package/dist/store/utils/derived.js +0 -24
- package/dist/store/utils/derived.js.map +0 -1
- package/dist/store/utils/index.d.ts +0 -7
- package/dist/store/utils/index.d.ts.map +0 -1
- package/dist/store/utils/index.js +0 -7
- package/dist/store/utils/index.js.map +0 -1
- package/dist/store/utils/notification-manager.d.ts +0 -11
- package/dist/store/utils/notification-manager.d.ts.map +0 -1
- package/dist/store/utils/notification-manager.js +0 -84
- package/dist/store/utils/notification-manager.js.map +0 -1
- package/dist/store/utils/proxied-assistant-state.d.ts +0 -8
- package/dist/store/utils/proxied-assistant-state.d.ts.map +0 -1
- package/dist/store/utils/proxied-assistant-state.js +0 -33
- package/dist/store/utils/proxied-assistant-state.js.map +0 -1
- package/dist/store/utils/split-clients.d.ts +0 -10
- package/dist/store/utils/split-clients.d.ts.map +0 -1
- package/dist/store/utils/split-clients.js +0 -53
- package/dist/store/utils/split-clients.js.map +0 -1
- package/dist/store/utils/tap-assistant-context.d.ts +0 -19
- package/dist/store/utils/tap-assistant-context.d.ts.map +0 -1
- package/dist/store/utils/tap-assistant-context.js +0 -23
- package/dist/store/utils/tap-assistant-context.js.map +0 -1
- package/dist/store/utils/tap-client-list.d.ts +0 -28
- package/dist/store/utils/tap-client-list.d.ts.map +0 -1
- package/dist/store/utils/tap-client-list.js +0 -68
- package/dist/store/utils/tap-client-list.js.map +0 -1
- package/dist/store/utils/tap-client-lookup.d.ts +0 -15
- package/dist/store/utils/tap-client-lookup.d.ts.map +0 -1
- package/dist/store/utils/tap-client-lookup.js +0 -42
- package/dist/store/utils/tap-client-lookup.js.map +0 -1
- package/dist/store/utils/tap-client-resource.d.ts +0 -13
- package/dist/store/utils/tap-client-resource.d.ts.map +0 -1
- package/dist/store/utils/tap-client-resource.js +0 -114
- package/dist/store/utils/tap-client-resource.js.map +0 -1
- package/dist/store/utils/tap-client-stack-context.d.ts +0 -23
- package/dist/store/utils/tap-client-stack-context.d.ts.map +0 -1
- package/dist/store/utils/tap-client-stack-context.js +0 -28
- package/dist/store/utils/tap-client-stack-context.js.map +0 -1
- package/dist/store/utils/wrapper-resource.d.ts +0 -3
- package/dist/store/utils/wrapper-resource.d.ts.map +0 -1
- package/dist/store/utils/wrapper-resource.js +0 -11
- package/dist/store/utils/wrapper-resource.js.map +0 -1
- package/src/store/types/client.ts +0 -203
- package/src/store/types/events.ts +0 -77
- package/src/store/types/index.ts +0 -23
- package/src/store/utils/attach-transform-scopes.ts +0 -38
- package/src/store/utils/base-proxy-handler.ts +0 -50
- package/src/store/utils/derived.ts +0 -46
- package/src/store/utils/index.ts +0 -28
- package/src/store/utils/notification-manager.ts +0 -114
- package/src/store/utils/proxied-assistant-state.ts +0 -55
- package/src/store/utils/split-clients.ts +0 -82
- package/src/store/utils/tap-assistant-context.ts +0 -58
- package/src/store/utils/tap-client-list.ts +0 -121
- package/src/store/utils/tap-client-lookup.ts +0 -79
- package/src/store/utils/tap-client-resource.ts +0 -187
- package/src/store/utils/tap-client-stack-context.ts +0 -51
- package/src/store/utils/wrapper-resource.ts +0 -17
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
tapEffect,
|
|
3
|
-
tapMemo,
|
|
4
|
-
tapRef,
|
|
5
|
-
type ResourceElement,
|
|
6
|
-
tapResource,
|
|
7
|
-
} from "@assistant-ui/tap";
|
|
8
|
-
import type { ClientMethods } from "../types/client";
|
|
9
|
-
import {
|
|
10
|
-
tapClientStack,
|
|
11
|
-
tapWithClientStack,
|
|
12
|
-
SYMBOL_CLIENT_INDEX,
|
|
13
|
-
} from "./tap-client-stack-context";
|
|
14
|
-
import {
|
|
15
|
-
BaseProxyHandler,
|
|
16
|
-
handleIntrospectionProp,
|
|
17
|
-
} from "./base-proxy-handler";
|
|
18
|
-
import { wrapperResource } from "./wrapper-resource";
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Symbol used internally to get state from ClientProxy.
|
|
22
|
-
* This allows getState() to be optional in the user-facing client.
|
|
23
|
-
*/
|
|
24
|
-
const SYMBOL_GET_OUTPUT = Symbol("assistant-ui.store.getValue");
|
|
25
|
-
|
|
26
|
-
type ClientInternal = {
|
|
27
|
-
[SYMBOL_GET_OUTPUT]: ClientMethods;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export const getClientState = (client: ClientMethods) => {
|
|
31
|
-
const output = (client as unknown as ClientInternal)[SYMBOL_GET_OUTPUT];
|
|
32
|
-
if (!output) {
|
|
33
|
-
throw new Error(
|
|
34
|
-
"Client scope contains a non-client resource. " +
|
|
35
|
-
"Ensure your Derived get() returns a client created with tapClientResource(), not a plain resource.",
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
return (output as any).getState?.();
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
// Global cache for function templates by field name
|
|
42
|
-
const fieldAccessFns = new Map<
|
|
43
|
-
string | symbol,
|
|
44
|
-
(this: unknown, ...args: unknown[]) => unknown
|
|
45
|
-
>();
|
|
46
|
-
|
|
47
|
-
function getOrCreateProxyFn(prop: string | symbol) {
|
|
48
|
-
let template = fieldAccessFns.get(prop);
|
|
49
|
-
if (!template) {
|
|
50
|
-
template = function (this: unknown, ...args: unknown[]) {
|
|
51
|
-
if (!this || typeof this !== "object") {
|
|
52
|
-
throw new Error(
|
|
53
|
-
`Method "${String(prop)}" called without proper context. ` +
|
|
54
|
-
`This may indicate the function was called incorrectly.`,
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const output = (this as ClientInternal)[SYMBOL_GET_OUTPUT];
|
|
59
|
-
if (!output) {
|
|
60
|
-
throw new Error(
|
|
61
|
-
`Method "${String(prop)}" called on invalid client proxy. ` +
|
|
62
|
-
`Ensure you are calling this method on a valid client instance.`,
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const method = output[prop];
|
|
67
|
-
if (!method)
|
|
68
|
-
throw new Error(`Method "${String(prop)}" is not implemented.`);
|
|
69
|
-
if (typeof method !== "function")
|
|
70
|
-
throw new Error(`"${String(prop)}" is not a function.`);
|
|
71
|
-
return method(...args);
|
|
72
|
-
};
|
|
73
|
-
fieldAccessFns.set(prop, template);
|
|
74
|
-
}
|
|
75
|
-
return template;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
class ClientProxyHandler
|
|
79
|
-
extends BaseProxyHandler
|
|
80
|
-
implements ProxyHandler<object>
|
|
81
|
-
{
|
|
82
|
-
private boundFns: Map<string | symbol, Function> | undefined;
|
|
83
|
-
private cachedReceiver: unknown;
|
|
84
|
-
|
|
85
|
-
constructor(
|
|
86
|
-
private readonly outputRef: {
|
|
87
|
-
current: ClientMethods;
|
|
88
|
-
},
|
|
89
|
-
private readonly index: number,
|
|
90
|
-
) {
|
|
91
|
-
super();
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
get(_: unknown, prop: string | symbol, receiver: unknown) {
|
|
95
|
-
if (prop === SYMBOL_GET_OUTPUT) return this.outputRef.current;
|
|
96
|
-
if (prop === SYMBOL_CLIENT_INDEX) return this.index;
|
|
97
|
-
const introspection = handleIntrospectionProp(prop, "ClientProxy");
|
|
98
|
-
if (introspection !== false) return introspection;
|
|
99
|
-
const value = this.outputRef.current[prop];
|
|
100
|
-
if (typeof value === "function") {
|
|
101
|
-
if (this.cachedReceiver !== receiver) {
|
|
102
|
-
this.boundFns = new Map();
|
|
103
|
-
this.cachedReceiver = receiver;
|
|
104
|
-
}
|
|
105
|
-
let bound = this.boundFns!.get(prop);
|
|
106
|
-
if (!bound) {
|
|
107
|
-
bound = getOrCreateProxyFn(prop).bind(receiver);
|
|
108
|
-
this.boundFns!.set(prop, bound);
|
|
109
|
-
}
|
|
110
|
-
return bound;
|
|
111
|
-
}
|
|
112
|
-
return value;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
ownKeys(): ArrayLike<string | symbol> {
|
|
116
|
-
return Object.keys(this.outputRef.current);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
has(_: unknown, prop: string | symbol) {
|
|
120
|
-
if (prop === SYMBOL_GET_OUTPUT) return true;
|
|
121
|
-
if (prop === SYMBOL_CLIENT_INDEX) return true;
|
|
122
|
-
return prop in this.outputRef.current;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Resource that wraps a plain resource element to create a stable client proxy.
|
|
128
|
-
*
|
|
129
|
-
* Takes a ResourceElement that returns methods (with optional getState()) and
|
|
130
|
-
* wraps it to produce a stable client proxy. This adds the client to the
|
|
131
|
-
* client stack, enabling event scoping.
|
|
132
|
-
*
|
|
133
|
-
* @internal
|
|
134
|
-
*/
|
|
135
|
-
export const ClientResource = wrapperResource(
|
|
136
|
-
<TMethods extends ClientMethods>(
|
|
137
|
-
element: ResourceElement<TMethods>,
|
|
138
|
-
): {
|
|
139
|
-
methods: TMethods;
|
|
140
|
-
state: unknown;
|
|
141
|
-
key: string | number | undefined;
|
|
142
|
-
} => {
|
|
143
|
-
const valueRef = tapRef(null as unknown as TMethods);
|
|
144
|
-
|
|
145
|
-
const index = tapClientStack().length;
|
|
146
|
-
const methods = tapMemo(
|
|
147
|
-
() =>
|
|
148
|
-
new Proxy<TMethods>(
|
|
149
|
-
{} as TMethods,
|
|
150
|
-
new ClientProxyHandler(valueRef, index),
|
|
151
|
-
),
|
|
152
|
-
[index],
|
|
153
|
-
);
|
|
154
|
-
|
|
155
|
-
const value = tapWithClientStack(methods, () => tapResource(element));
|
|
156
|
-
if (!valueRef.current) {
|
|
157
|
-
valueRef.current = value;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
tapEffect(() => {
|
|
161
|
-
valueRef.current = value;
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
const state = (value as any).getState?.();
|
|
165
|
-
return { methods, state, key: element.key };
|
|
166
|
-
},
|
|
167
|
-
);
|
|
168
|
-
|
|
169
|
-
type InferClientState<TMethods> = TMethods extends {
|
|
170
|
-
getState: () => infer S;
|
|
171
|
-
}
|
|
172
|
-
? S
|
|
173
|
-
: undefined;
|
|
174
|
-
|
|
175
|
-
export const tapClientResource = <TMethods extends ClientMethods>(
|
|
176
|
-
element: ResourceElement<TMethods>,
|
|
177
|
-
): {
|
|
178
|
-
state: InferClientState<TMethods>;
|
|
179
|
-
methods: TMethods;
|
|
180
|
-
key: string | number | undefined;
|
|
181
|
-
} => {
|
|
182
|
-
return tapResource(ClientResource(element)) as {
|
|
183
|
-
state: InferClientState<TMethods>;
|
|
184
|
-
methods: TMethods;
|
|
185
|
-
key: string | number | undefined;
|
|
186
|
-
};
|
|
187
|
-
};
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createResourceContext,
|
|
3
|
-
tap,
|
|
4
|
-
withContextProvider,
|
|
5
|
-
tapMemo,
|
|
6
|
-
} from "@assistant-ui/tap";
|
|
7
|
-
import type { ClientMethods } from "../types/client";
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Symbol used to get the client index from a ClientProxy.
|
|
11
|
-
*/
|
|
12
|
-
export const SYMBOL_CLIENT_INDEX = Symbol("assistant-ui.store.clientIndex");
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Get the index of a client (its position in the client stack when created).
|
|
16
|
-
*/
|
|
17
|
-
export const getClientIndex = (client: ClientMethods): number => {
|
|
18
|
-
return (client as unknown as { [SYMBOL_CLIENT_INDEX]: number })[
|
|
19
|
-
SYMBOL_CLIENT_INDEX
|
|
20
|
-
];
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* The client stack - an array of clients representing the current hierarchy.
|
|
25
|
-
*/
|
|
26
|
-
export type ClientStack = readonly ClientMethods[];
|
|
27
|
-
|
|
28
|
-
const ClientStackContext = createResourceContext<ClientStack>([]);
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Get the current client stack inside a tap resource.
|
|
32
|
-
*/
|
|
33
|
-
export const tapClientStack = (): ClientStack => {
|
|
34
|
-
return tap(ClientStackContext);
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Execute a callback with a client pushed onto the stack.
|
|
39
|
-
* The stack is duplicated, not mutated.
|
|
40
|
-
*/
|
|
41
|
-
export const tapWithClientStack = <T>(
|
|
42
|
-
client: ClientMethods,
|
|
43
|
-
callback: () => T,
|
|
44
|
-
): T => {
|
|
45
|
-
const currentStack = tapClientStack();
|
|
46
|
-
const newStack = tapMemo(
|
|
47
|
-
() => [...currentStack, client],
|
|
48
|
-
[currentStack, client],
|
|
49
|
-
);
|
|
50
|
-
return withContextProvider(ClientStackContext, newStack, callback);
|
|
51
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type ResourceElement,
|
|
3
|
-
Resource,
|
|
4
|
-
resource,
|
|
5
|
-
withKey,
|
|
6
|
-
} from "@assistant-ui/tap";
|
|
7
|
-
|
|
8
|
-
export const wrapperResource = <R, P>(
|
|
9
|
-
fn: (props: ResourceElement<P>) => R,
|
|
10
|
-
): Resource<R, ResourceElement<P>> => {
|
|
11
|
-
const res = resource(fn);
|
|
12
|
-
return (props: ResourceElement<P>) => {
|
|
13
|
-
const el = res(props);
|
|
14
|
-
if (props.key === undefined) return el;
|
|
15
|
-
return withKey(props.key, el);
|
|
16
|
-
};
|
|
17
|
-
};
|