@assistant-ui/react 0.10.24 → 0.10.26
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/api/{ContentPartRuntime.d.ts → MessagePartRuntime.d.ts} +14 -14
- package/dist/api/{ContentPartRuntime.d.ts.map → MessagePartRuntime.d.ts.map} +1 -1
- package/dist/api/{ContentPartRuntime.js → MessagePartRuntime.js} +6 -6
- package/dist/api/{ContentPartRuntime.js.map → MessagePartRuntime.js.map} +1 -1
- package/dist/api/MessageRuntime.d.ts +8 -8
- package/dist/api/MessageRuntime.js +17 -17
- package/dist/api/MessageRuntime.js.map +1 -1
- package/dist/api/RuntimePathTypes.d.ts +2 -2
- package/dist/api/ThreadListRuntime.d.ts +3 -0
- package/dist/api/ThreadListRuntime.d.ts.map +1 -1
- package/dist/api/ThreadListRuntime.js +5 -1
- package/dist/api/ThreadListRuntime.js.map +1 -1
- package/dist/api/ThreadRuntime.d.ts +5 -0
- package/dist/api/ThreadRuntime.d.ts.map +1 -1
- package/dist/api/ThreadRuntime.js +1 -0
- package/dist/api/ThreadRuntime.js.map +1 -1
- package/dist/api/index.d.ts +2 -1
- package/dist/api/index.d.ts.map +1 -1
- package/dist/cloud/auiV0.d.ts +2 -2
- package/dist/cloud/auiV0.js +1 -1
- package/dist/cloud/auiV0.js.map +1 -1
- package/dist/context/providers/MessagePartRuntimeProvider.d.ts +9 -0
- package/dist/context/providers/{ContentPartRuntimeProvider.d.ts.map → MessagePartRuntimeProvider.d.ts.map} +1 -1
- package/dist/context/providers/{ContentPartRuntimeProvider.js → MessagePartRuntimeProvider.js} +9 -9
- package/dist/context/providers/MessagePartRuntimeProvider.js.map +1 -0
- package/dist/context/providers/{TextContentPartProvider.d.ts → TextMessagePartProvider.d.ts} +3 -3
- package/dist/context/providers/{TextContentPartProvider.d.ts.map → TextMessagePartProvider.d.ts.map} +1 -1
- package/dist/context/providers/{TextContentPartProvider.js → TextMessagePartProvider.js} +19 -19
- package/dist/context/providers/{TextContentPartProvider.js.map → TextMessagePartProvider.js.map} +1 -1
- package/dist/context/providers/index.d.ts +2 -1
- package/dist/context/providers/index.d.ts.map +1 -1
- package/dist/context/providers/index.js +4 -2
- package/dist/context/providers/index.js.map +1 -1
- package/dist/context/react/AttachmentContext.d.ts +72 -72
- package/dist/context/react/MessagePartContext.d.ts +41 -0
- package/dist/context/react/{ContentPartContext.d.ts.map → MessagePartContext.d.ts.map} +1 -1
- package/dist/context/react/MessagePartContext.js +25 -0
- package/dist/context/react/MessagePartContext.js.map +1 -0
- package/dist/context/react/index.d.ts +1 -1
- package/dist/context/react/index.js +3 -3
- package/dist/context/react/index.js.map +1 -1
- package/dist/context/stores/AssistantToolUIs.d.ts +3 -3
- package/dist/context/stores/AssistantToolUIs.js.map +1 -1
- package/dist/model-context/useAssistantTool.d.ts +2 -2
- package/dist/model-context/useAssistantTool.js.map +1 -1
- package/dist/model-context/useAssistantToolUI.d.ts +2 -2
- package/dist/model-context/useAssistantToolUI.js.map +1 -1
- package/dist/model-context/useInlineRender.d.ts +2 -2
- package/dist/model-context/useInlineRender.js.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalContent.d.ts +2 -0
- package/dist/primitives/assistantModal/AssistantModalContent.d.ts.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalContent.js +2 -1
- package/dist/primitives/assistantModal/AssistantModalContent.js.map +1 -1
- package/dist/primitives/index.d.ts +12 -6
- package/dist/primitives/index.d.ts.map +1 -1
- package/dist/primitives/index.js +23 -11
- package/dist/primitives/index.js.map +1 -1
- package/dist/primitives/message/MessageParts.d.ts +116 -0
- package/dist/primitives/message/MessageParts.d.ts.map +1 -0
- package/dist/primitives/message/MessageParts.js +208 -0
- package/dist/primitives/message/MessageParts.js.map +1 -0
- package/dist/primitives/message/index.d.ts +2 -1
- package/dist/primitives/message/index.d.ts.map +1 -1
- package/dist/primitives/message/index.js +4 -2
- package/dist/primitives/message/index.js.map +1 -1
- package/dist/primitives/{contentPart/ContentPartImage.d.ts → messagePart/MessagePartImage.d.ts} +8 -8
- package/dist/primitives/{contentPart/ContentPartImage.d.ts.map → messagePart/MessagePartImage.d.ts.map} +1 -1
- package/dist/primitives/messagePart/MessagePartImage.js +16 -0
- package/dist/primitives/messagePart/MessagePartImage.js.map +1 -0
- package/dist/primitives/messagePart/MessagePartInProgress.d.ts +6 -0
- package/dist/primitives/{contentPart/ContentPartInProgress.d.ts.map → messagePart/MessagePartInProgress.d.ts.map} +1 -1
- package/dist/primitives/messagePart/MessagePartInProgress.js +13 -0
- package/dist/primitives/messagePart/MessagePartInProgress.js.map +1 -0
- package/dist/primitives/{contentPart/ContentPartText.d.ts → messagePart/MessagePartText.d.ts} +6 -6
- package/dist/primitives/{contentPart/ContentPartText.d.ts.map → messagePart/MessagePartText.d.ts.map} +1 -1
- package/dist/primitives/messagePart/MessagePartText.js +18 -0
- package/dist/primitives/{contentPart/ContentPartText.js.map → messagePart/MessagePartText.js.map} +1 -1
- package/dist/primitives/messagePart/index.d.ts +4 -0
- package/dist/primitives/{contentPart → messagePart}/index.d.ts.map +1 -1
- package/dist/primitives/messagePart/index.js +10 -0
- package/dist/primitives/messagePart/index.js.map +1 -0
- package/dist/primitives/messagePart/useMessagePartFile.d.ts +5 -0
- package/dist/primitives/messagePart/useMessagePartFile.d.ts.map +1 -0
- package/dist/primitives/messagePart/useMessagePartFile.js +18 -0
- package/dist/primitives/messagePart/useMessagePartFile.js.map +1 -0
- package/dist/primitives/messagePart/useMessagePartImage.d.ts +5 -0
- package/dist/primitives/messagePart/useMessagePartImage.d.ts.map +1 -0
- package/dist/primitives/messagePart/useMessagePartImage.js +18 -0
- package/dist/primitives/messagePart/useMessagePartImage.js.map +1 -0
- package/dist/primitives/messagePart/useMessagePartReasoning.d.ts +5 -0
- package/dist/primitives/messagePart/useMessagePartReasoning.d.ts.map +1 -0
- package/dist/primitives/messagePart/useMessagePartReasoning.js +18 -0
- package/dist/primitives/messagePart/useMessagePartReasoning.js.map +1 -0
- package/dist/primitives/messagePart/useMessagePartSource.d.ts +5 -0
- package/dist/primitives/messagePart/useMessagePartSource.d.ts.map +1 -0
- package/dist/primitives/messagePart/useMessagePartSource.js +18 -0
- package/dist/primitives/messagePart/useMessagePartSource.js.map +1 -0
- package/dist/primitives/messagePart/useMessagePartText.d.ts +7 -0
- package/dist/primitives/messagePart/useMessagePartText.d.ts.map +1 -0
- package/dist/primitives/messagePart/useMessagePartText.js +18 -0
- package/dist/primitives/messagePart/useMessagePartText.js.map +1 -0
- package/dist/runtimes/core/BaseThreadRuntimeCore.d.ts +1 -0
- package/dist/runtimes/core/BaseThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/core/BaseThreadRuntimeCore.js.map +1 -1
- package/dist/runtimes/core/ThreadListRuntimeCore.d.ts +1 -0
- package/dist/runtimes/core/ThreadListRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/core/ThreadRuntimeCore.d.ts +1 -0
- package/dist/runtimes/core/ThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreAdapter.d.ts +2 -0
- package/dist/runtimes/external-store/ExternalStoreAdapter.d.ts.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.d.ts +1 -0
- package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.js +3 -0
- package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.js.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.d.ts +1 -0
- package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.js +3 -8
- package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.js.map +1 -1
- package/dist/runtimes/external-store/ThreadMessageLike.d.ts +3 -3
- package/dist/runtimes/external-store/ThreadMessageLike.js +4 -4
- package/dist/runtimes/external-store/ThreadMessageLike.js.map +1 -1
- package/dist/runtimes/external-store/createMessageConverter.js +3 -3
- package/dist/runtimes/external-store/createMessageConverter.js.map +1 -1
- package/dist/runtimes/external-store/external-message-converter.js.map +1 -1
- package/dist/runtimes/local/ChatModelAdapter.d.ts +4 -4
- package/dist/runtimes/local/LocalThreadListRuntimeCore.d.ts +1 -0
- package/dist/runtimes/local/LocalThreadListRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/local/LocalThreadListRuntimeCore.js +3 -0
- package/dist/runtimes/local/LocalThreadListRuntimeCore.js.map +1 -1
- package/dist/runtimes/local/LocalThreadRuntimeCore.d.ts +2 -0
- package/dist/runtimes/local/LocalThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/local/LocalThreadRuntimeCore.js +12 -1
- package/dist/runtimes/local/LocalThreadRuntimeCore.js.map +1 -1
- package/dist/runtimes/remote-thread-list/EMPTY_THREAD_CORE.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/EMPTY_THREAD_CORE.js +1 -0
- package/dist/runtimes/remote-thread-list/EMPTY_THREAD_CORE.js.map +1 -1
- package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.d.ts +2 -0
- package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.d.ts +3 -0
- package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.js +3 -0
- package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.js.map +1 -1
- package/dist/runtimes/utils/MessageRepository.js +1 -1
- package/dist/runtimes/utils/MessageRepository.js.map +1 -1
- package/dist/tests/setup.js +8 -8
- package/dist/tests/setup.js.map +1 -1
- package/dist/types/AssistantTypes.d.ts +15 -15
- package/dist/types/AttachmentTypes.d.ts +3 -3
- package/dist/types/MessagePartComponentTypes.d.ts +25 -0
- package/dist/types/{ContentPartComponentTypes.d.ts.map → MessagePartComponentTypes.d.ts.map} +1 -1
- package/dist/types/MessagePartComponentTypes.js +1 -0
- package/dist/types/index.d.ts +4 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/getThreadMessageText.js.map +1 -1
- package/dist/utils/smooth/SmoothContext.js +3 -3
- package/dist/utils/smooth/SmoothContext.js.map +1 -1
- package/dist/utils/smooth/useSmooth.d.ts +3 -3
- package/dist/utils/smooth/useSmooth.js.map +1 -1
- package/dist/utils/useToolArgsFieldStatus.js +3 -3
- package/dist/utils/useToolArgsFieldStatus.js.map +1 -1
- package/package.json +8 -8
- package/src/api/{ContentPartRuntime.ts → MessagePartRuntime.ts} +20 -20
- package/src/api/MessageRuntime.ts +32 -32
- package/src/api/RuntimePathTypes.ts +2 -2
- package/src/api/ThreadListRuntime.ts +8 -0
- package/src/api/ThreadRuntime.ts +6 -0
- package/src/api/index.ts +11 -3
- package/src/cloud/auiV0.ts +3 -3
- package/src/context/providers/MessagePartRuntimeProvider.tsx +42 -0
- package/src/context/providers/{TextContentPartProvider.tsx → TextMessagePartProvider.tsx} +27 -27
- package/src/context/providers/index.ts +4 -1
- package/src/context/react/MessagePartContext.ts +37 -0
- package/src/context/react/index.ts +1 -1
- package/src/context/stores/AssistantToolUIs.ts +4 -4
- package/src/model-context/useAssistantTool.tsx +2 -2
- package/src/model-context/useAssistantToolUI.tsx +2 -2
- package/src/model-context/useInlineRender.tsx +3 -3
- package/src/primitives/assistantModal/AssistantModalContent.tsx +5 -1
- package/src/primitives/index.ts +14 -6
- package/src/primitives/message/MessageParts.tsx +423 -0
- package/src/primitives/message/index.ts +2 -1
- package/src/primitives/messagePart/MessagePartImage.tsx +39 -0
- package/src/primitives/messagePart/MessagePartInProgress.tsx +19 -0
- package/src/primitives/{contentPart/ContentPartText.tsx → messagePart/MessagePartText.tsx} +10 -10
- package/src/primitives/messagePart/index.ts +3 -0
- package/src/primitives/messagePart/useMessagePartFile.tsx +18 -0
- package/src/primitives/messagePart/useMessagePartImage.tsx +18 -0
- package/src/primitives/messagePart/useMessagePartReasoning.tsx +18 -0
- package/src/primitives/messagePart/useMessagePartSource.tsx +18 -0
- package/src/primitives/messagePart/useMessagePartText.tsx +18 -0
- package/src/runtimes/core/BaseThreadRuntimeCore.tsx +1 -0
- package/src/runtimes/core/ThreadListRuntimeCore.tsx +1 -0
- package/src/runtimes/core/ThreadRuntimeCore.tsx +1 -0
- package/src/runtimes/external-store/ExternalStoreAdapter.tsx +2 -0
- package/src/runtimes/external-store/ExternalStoreThreadListRuntimeCore.tsx +4 -0
- package/src/runtimes/external-store/ExternalStoreThreadRuntimeCore.tsx +3 -8
- package/src/runtimes/external-store/ThreadMessageLike.tsx +21 -21
- package/src/runtimes/external-store/createMessageConverter.tsx +3 -3
- package/src/runtimes/external-store/external-message-converter.tsx +2 -2
- package/src/runtimes/local/ChatModelAdapter.tsx +13 -13
- package/src/runtimes/local/LocalThreadListRuntimeCore.tsx +4 -0
- package/src/runtimes/local/LocalThreadRuntimeCore.tsx +30 -15
- package/src/runtimes/remote-thread-list/EMPTY_THREAD_CORE.tsx +1 -0
- package/src/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.tsx +4 -0
- package/src/runtimes/utils/MessageRepository.tsx +1 -1
- package/src/tests/MessageRepository.test.ts +6 -6
- package/src/types/AssistantTypes.ts +24 -24
- package/src/types/AttachmentTypes.ts +3 -3
- package/src/types/MessagePartComponentTypes.tsx +52 -0
- package/src/types/index.ts +69 -28
- package/src/utils/getThreadMessageText.tsx +2 -2
- package/src/utils/smooth/SmoothContext.tsx +7 -7
- package/src/utils/smooth/useSmooth.tsx +7 -7
- package/src/utils/useToolArgsFieldStatus.tsx +3 -3
- package/dist/context/providers/ContentPartRuntimeProvider.d.ts +0 -9
- package/dist/context/providers/ContentPartRuntimeProvider.js.map +0 -1
- package/dist/context/react/ContentPartContext.d.ts +0 -41
- package/dist/context/react/ContentPartContext.js +0 -25
- package/dist/context/react/ContentPartContext.js.map +0 -1
- package/dist/primitives/contentPart/ContentPartImage.js +0 -16
- package/dist/primitives/contentPart/ContentPartImage.js.map +0 -1
- package/dist/primitives/contentPart/ContentPartInProgress.d.ts +0 -6
- package/dist/primitives/contentPart/ContentPartInProgress.js +0 -13
- package/dist/primitives/contentPart/ContentPartInProgress.js.map +0 -1
- package/dist/primitives/contentPart/ContentPartText.js +0 -18
- package/dist/primitives/contentPart/index.d.ts +0 -4
- package/dist/primitives/contentPart/index.js +0 -10
- package/dist/primitives/contentPart/index.js.map +0 -1
- package/dist/primitives/contentPart/useContentPartFile.d.ts +0 -5
- package/dist/primitives/contentPart/useContentPartFile.d.ts.map +0 -1
- package/dist/primitives/contentPart/useContentPartFile.js +0 -18
- package/dist/primitives/contentPart/useContentPartFile.js.map +0 -1
- package/dist/primitives/contentPart/useContentPartImage.d.ts +0 -5
- package/dist/primitives/contentPart/useContentPartImage.d.ts.map +0 -1
- package/dist/primitives/contentPart/useContentPartImage.js +0 -18
- package/dist/primitives/contentPart/useContentPartImage.js.map +0 -1
- package/dist/primitives/contentPart/useContentPartReasoning.d.ts +0 -5
- package/dist/primitives/contentPart/useContentPartReasoning.d.ts.map +0 -1
- package/dist/primitives/contentPart/useContentPartReasoning.js +0 -18
- package/dist/primitives/contentPart/useContentPartReasoning.js.map +0 -1
- package/dist/primitives/contentPart/useContentPartSource.d.ts +0 -5
- package/dist/primitives/contentPart/useContentPartSource.d.ts.map +0 -1
- package/dist/primitives/contentPart/useContentPartSource.js +0 -18
- package/dist/primitives/contentPart/useContentPartSource.js.map +0 -1
- package/dist/primitives/contentPart/useContentPartText.d.ts +0 -7
- package/dist/primitives/contentPart/useContentPartText.d.ts.map +0 -1
- package/dist/primitives/contentPart/useContentPartText.js +0 -18
- package/dist/primitives/contentPart/useContentPartText.js.map +0 -1
- package/dist/primitives/message/MessageContent.d.ts +0 -64
- package/dist/primitives/message/MessageContent.d.ts.map +0 -1
- package/dist/primitives/message/MessageContent.js +0 -141
- package/dist/primitives/message/MessageContent.js.map +0 -1
- package/dist/types/ContentPartComponentTypes.d.ts +0 -25
- package/dist/types/ContentPartComponentTypes.js +0 -1
- package/src/context/providers/ContentPartRuntimeProvider.tsx +0 -42
- package/src/context/react/ContentPartContext.ts +0 -37
- package/src/primitives/contentPart/ContentPartImage.tsx +0 -39
- package/src/primitives/contentPart/ContentPartInProgress.tsx +0 -19
- package/src/primitives/contentPart/index.ts +0 -3
- package/src/primitives/contentPart/useContentPartFile.tsx +0 -18
- package/src/primitives/contentPart/useContentPartImage.tsx +0 -18
- package/src/primitives/contentPart/useContentPartReasoning.tsx +0 -18
- package/src/primitives/contentPart/useContentPartSource.tsx +0 -18
- package/src/primitives/contentPart/useContentPartText.tsx +0 -18
- package/src/primitives/message/MessageContent.tsx +0 -277
- package/src/types/ContentPartComponentTypes.tsx +0 -52
- /package/dist/types/{ContentPartComponentTypes.js.map → MessagePartComponentTypes.js.map} +0 -0
@@ -1,64 +0,0 @@
|
|
1
|
-
import { type ComponentType, type FC } from "react";
|
2
|
-
import type { Unstable_AudioContentPartComponent, EmptyContentPartComponent, TextContentPartComponent, ImageContentPartComponent, SourceContentPartComponent, ToolCallContentPartComponent, ToolCallContentPartProps, FileContentPartComponent, ReasoningContentPartComponent } from "../../types/ContentPartComponentTypes";
|
3
|
-
export declare namespace MessagePrimitiveContent {
|
4
|
-
type Props = {
|
5
|
-
/**
|
6
|
-
* Component configuration for rendering different types of message content.
|
7
|
-
*
|
8
|
-
* You can provide custom components for each content type (text, image, file, etc.)
|
9
|
-
* and configure tool rendering behavior. If not provided, default components will be used.
|
10
|
-
*/
|
11
|
-
components?: {
|
12
|
-
/** Component for rendering empty messages */
|
13
|
-
Empty?: EmptyContentPartComponent | undefined;
|
14
|
-
/** Component for rendering text content */
|
15
|
-
Text?: TextContentPartComponent | undefined;
|
16
|
-
/** Component for rendering reasoning content (typically hidden) */
|
17
|
-
Reasoning?: ReasoningContentPartComponent | undefined;
|
18
|
-
/** Component for rendering source content */
|
19
|
-
Source?: SourceContentPartComponent | undefined;
|
20
|
-
/** Component for rendering image content */
|
21
|
-
Image?: ImageContentPartComponent | undefined;
|
22
|
-
/** Component for rendering file content */
|
23
|
-
File?: FileContentPartComponent | undefined;
|
24
|
-
/** Component for rendering audio content (experimental) */
|
25
|
-
Unstable_Audio?: Unstable_AudioContentPartComponent | undefined;
|
26
|
-
/** Configuration for tool call rendering */
|
27
|
-
tools?: {
|
28
|
-
/** Map of tool names to their specific components */
|
29
|
-
by_name?: Record<string, ToolCallContentPartComponent | undefined> | undefined;
|
30
|
-
/** Fallback component for unregistered tools */
|
31
|
-
Fallback?: ComponentType<ToolCallContentPartProps> | undefined;
|
32
|
-
} | {
|
33
|
-
/** Override component that handles all tool calls */
|
34
|
-
Override: ComponentType<ToolCallContentPartProps>;
|
35
|
-
} | undefined;
|
36
|
-
} | undefined;
|
37
|
-
};
|
38
|
-
}
|
39
|
-
/**
|
40
|
-
* Renders the content of a message with support for multiple content types.
|
41
|
-
*
|
42
|
-
* This component automatically handles different types of message content including
|
43
|
-
* text, images, files, tool calls, and more. It provides a flexible component
|
44
|
-
* system for customizing how each content type is rendered.
|
45
|
-
*
|
46
|
-
* @example
|
47
|
-
* ```tsx
|
48
|
-
* <MessagePrimitive.Content
|
49
|
-
* components={{
|
50
|
-
* Text: ({ text }) => <p className="message-text">{text}</p>,
|
51
|
-
* Image: ({ image }) => <img src={image} alt="Message image" />,
|
52
|
-
* tools: {
|
53
|
-
* by_name: {
|
54
|
-
* calculator: CalculatorTool,
|
55
|
-
* weather: WeatherTool,
|
56
|
-
* },
|
57
|
-
* Fallback: DefaultToolComponent
|
58
|
-
* }
|
59
|
-
* }}
|
60
|
-
* />
|
61
|
-
* ```
|
62
|
-
*/
|
63
|
-
export declare const MessagePrimitiveContent: FC<MessagePrimitiveContent.Props>;
|
64
|
-
//# sourceMappingURL=MessageContent.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"MessageContent.d.ts","sourceRoot":"","sources":["../../../src/primitives/message/MessageContent.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,EAAE,EAAiB,MAAM,OAAO,CAAC;AAcnE,OAAO,KAAK,EACV,kCAAkC,EAClC,yBAAyB,EACzB,wBAAwB,EACxB,yBAAyB,EACzB,0BAA0B,EAC1B,4BAA4B,EAC5B,wBAAwB,EACxB,wBAAwB,EACxB,6BAA6B,EAC9B,MAAM,uCAAuC,CAAC;AAI/C,yBAAiB,uBAAuB,CAAC;IACvC,KAAY,KAAK,GAAG;QAClB;;;;;WAKG;QACH,UAAU,CAAC,EACP;YACE,6CAA6C;YAC7C,KAAK,CAAC,EAAE,yBAAyB,GAAG,SAAS,CAAC;YAC9C,2CAA2C;YAC3C,IAAI,CAAC,EAAE,wBAAwB,GAAG,SAAS,CAAC;YAC5C,mEAAmE;YACnE,SAAS,CAAC,EAAE,6BAA6B,GAAG,SAAS,CAAC;YACtD,6CAA6C;YAC7C,MAAM,CAAC,EAAE,0BAA0B,GAAG,SAAS,CAAC;YAChD,4CAA4C;YAC5C,KAAK,CAAC,EAAE,yBAAyB,GAAG,SAAS,CAAC;YAC9C,2CAA2C;YAC3C,IAAI,CAAC,EAAE,wBAAwB,GAAG,SAAS,CAAC;YAC5C,2DAA2D;YAC3D,cAAc,CAAC,EAAE,kCAAkC,GAAG,SAAS,CAAC;YAChE,4CAA4C;YAC5C,KAAK,CAAC,EACF;gBACE,qDAAqD;gBACrD,OAAO,CAAC,EACJ,MAAM,CAAC,MAAM,EAAE,4BAA4B,GAAG,SAAS,CAAC,GACxD,SAAS,CAAC;gBACd,gDAAgD;gBAChD,QAAQ,CAAC,EAAE,aAAa,CAAC,wBAAwB,CAAC,GAAG,SAAS,CAAC;aAChE,GACD;gBACE,qDAAqD;gBACrD,QAAQ,EAAE,aAAa,CAAC,wBAAwB,CAAC,CAAC;aACnD,GACD,SAAS,CAAC;SACf,GACD,SAAS,CAAC;KACf,CAAC;CACH;AA+JD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,uBAAuB,EAAE,EAAE,CAAC,uBAAuB,CAAC,KAAK,CAmBrE,CAAC"}
|
@@ -1,141 +0,0 @@
|
|
1
|
-
"use client";
|
2
|
-
|
3
|
-
// src/primitives/message/MessageContent.tsx
|
4
|
-
import { memo, useMemo } from "react";
|
5
|
-
import {
|
6
|
-
TextContentPartProvider,
|
7
|
-
useContentPart,
|
8
|
-
useContentPartRuntime,
|
9
|
-
useToolUIs
|
10
|
-
} from "../../context/index.js";
|
11
|
-
import {
|
12
|
-
useMessage,
|
13
|
-
useMessageRuntime
|
14
|
-
} from "../../context/react/MessageContext.js";
|
15
|
-
import { ContentPartRuntimeProvider } from "../../context/providers/ContentPartRuntimeProvider.js";
|
16
|
-
import { ContentPartPrimitiveText } from "../contentPart/ContentPartText.js";
|
17
|
-
import { ContentPartPrimitiveImage } from "../contentPart/ContentPartImage.js";
|
18
|
-
import { ContentPartPrimitiveInProgress } from "../contentPart/ContentPartInProgress.js";
|
19
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
20
|
-
var ToolUIDisplay = ({
|
21
|
-
Fallback,
|
22
|
-
...props
|
23
|
-
}) => {
|
24
|
-
const Render = useToolUIs((s) => s.getToolUI(props.toolName)) ?? Fallback;
|
25
|
-
if (!Render) return null;
|
26
|
-
return /* @__PURE__ */ jsx(Render, { ...props });
|
27
|
-
};
|
28
|
-
var defaultComponents = {
|
29
|
-
Text: () => /* @__PURE__ */ jsxs("p", { style: { whiteSpace: "pre-line" }, children: [
|
30
|
-
/* @__PURE__ */ jsx(ContentPartPrimitiveText, {}),
|
31
|
-
/* @__PURE__ */ jsx(ContentPartPrimitiveInProgress, { children: /* @__PURE__ */ jsx("span", { style: { fontFamily: "revert" }, children: " \u25CF" }) })
|
32
|
-
] }),
|
33
|
-
Reasoning: () => null,
|
34
|
-
Source: () => null,
|
35
|
-
Image: () => /* @__PURE__ */ jsx(ContentPartPrimitiveImage, {}),
|
36
|
-
File: () => null,
|
37
|
-
Unstable_Audio: () => null
|
38
|
-
};
|
39
|
-
var MessageContentPartComponent = ({
|
40
|
-
components: {
|
41
|
-
Text = defaultComponents.Text,
|
42
|
-
Reasoning = defaultComponents.Reasoning,
|
43
|
-
Image = defaultComponents.Image,
|
44
|
-
Source = defaultComponents.Source,
|
45
|
-
File = defaultComponents.File,
|
46
|
-
Unstable_Audio: Audio = defaultComponents.Unstable_Audio,
|
47
|
-
tools = {}
|
48
|
-
} = {}
|
49
|
-
}) => {
|
50
|
-
const contentPartRuntime = useContentPartRuntime();
|
51
|
-
const part = useContentPart();
|
52
|
-
const type = part.type;
|
53
|
-
if (type === "tool-call") {
|
54
|
-
const addResult = (result) => contentPartRuntime.addToolResult(result);
|
55
|
-
if ("Override" in tools)
|
56
|
-
return /* @__PURE__ */ jsx(tools.Override, { ...part, addResult });
|
57
|
-
const Tool = tools.by_name?.[part.toolName] ?? tools.Fallback;
|
58
|
-
return /* @__PURE__ */ jsx(ToolUIDisplay, { ...part, Fallback: Tool, addResult });
|
59
|
-
}
|
60
|
-
if (part.status.type === "requires-action")
|
61
|
-
throw new Error("Encountered unexpected requires-action status");
|
62
|
-
switch (type) {
|
63
|
-
case "text":
|
64
|
-
return /* @__PURE__ */ jsx(Text, { ...part });
|
65
|
-
case "reasoning":
|
66
|
-
return /* @__PURE__ */ jsx(Reasoning, { ...part });
|
67
|
-
case "source":
|
68
|
-
return /* @__PURE__ */ jsx(Source, { ...part });
|
69
|
-
case "image":
|
70
|
-
return /* @__PURE__ */ jsx(Image, { ...part });
|
71
|
-
case "file":
|
72
|
-
return /* @__PURE__ */ jsx(File, { ...part });
|
73
|
-
case "audio":
|
74
|
-
return /* @__PURE__ */ jsx(Audio, { ...part });
|
75
|
-
default:
|
76
|
-
const unhandledType = type;
|
77
|
-
throw new Error(`Unknown content part type: ${unhandledType}`);
|
78
|
-
}
|
79
|
-
};
|
80
|
-
var MessageContentPartImpl = ({
|
81
|
-
partIndex,
|
82
|
-
components
|
83
|
-
}) => {
|
84
|
-
const messageRuntime = useMessageRuntime();
|
85
|
-
const runtime = useMemo(
|
86
|
-
() => messageRuntime.getContentPartByIndex(partIndex),
|
87
|
-
[messageRuntime, partIndex]
|
88
|
-
);
|
89
|
-
return /* @__PURE__ */ jsx(ContentPartRuntimeProvider, { runtime, children: /* @__PURE__ */ jsx(MessageContentPartComponent, { components }) });
|
90
|
-
};
|
91
|
-
var MessageContentPart = memo(
|
92
|
-
MessageContentPartImpl,
|
93
|
-
(prev, next) => prev.partIndex === next.partIndex && prev.components?.Text === next.components?.Text && prev.components?.Reasoning === next.components?.Reasoning && prev.components?.Source === next.components?.Source && prev.components?.Image === next.components?.Image && prev.components?.File === next.components?.File && prev.components?.Unstable_Audio === next.components?.Unstable_Audio && prev.components?.tools === next.components?.tools
|
94
|
-
);
|
95
|
-
var COMPLETE_STATUS = Object.freeze({
|
96
|
-
type: "complete"
|
97
|
-
});
|
98
|
-
var EmptyContentFallback = ({ status, component: Component }) => {
|
99
|
-
return /* @__PURE__ */ jsx(TextContentPartProvider, { text: "", isRunning: status.type === "running", children: /* @__PURE__ */ jsx(Component, { type: "text", text: "", status }) });
|
100
|
-
};
|
101
|
-
var EmptyContentImpl = ({
|
102
|
-
components
|
103
|
-
}) => {
|
104
|
-
const status = useMessage((s) => s.status) ?? COMPLETE_STATUS;
|
105
|
-
if (components?.Empty) return /* @__PURE__ */ jsx(components.Empty, { status });
|
106
|
-
return /* @__PURE__ */ jsx(
|
107
|
-
EmptyContentFallback,
|
108
|
-
{
|
109
|
-
status,
|
110
|
-
component: components?.Text ?? defaultComponents.Text
|
111
|
-
}
|
112
|
-
);
|
113
|
-
};
|
114
|
-
var EmptyContent = memo(
|
115
|
-
EmptyContentImpl,
|
116
|
-
(prev, next) => prev.components?.Empty === next.components?.Empty && prev.components?.Text === next.components?.Text
|
117
|
-
);
|
118
|
-
var MessagePrimitiveContent = ({
|
119
|
-
components
|
120
|
-
}) => {
|
121
|
-
const contentLength = useMessage((s) => s.content.length);
|
122
|
-
const contentElements = useMemo(() => {
|
123
|
-
if (contentLength === 0) {
|
124
|
-
return /* @__PURE__ */ jsx(EmptyContent, { components });
|
125
|
-
}
|
126
|
-
return Array.from({ length: contentLength }, (_, index) => /* @__PURE__ */ jsx(
|
127
|
-
MessageContentPart,
|
128
|
-
{
|
129
|
-
partIndex: index,
|
130
|
-
components
|
131
|
-
},
|
132
|
-
index
|
133
|
-
));
|
134
|
-
}, [contentLength, components]);
|
135
|
-
return /* @__PURE__ */ jsx(Fragment, { children: contentElements });
|
136
|
-
};
|
137
|
-
MessagePrimitiveContent.displayName = "MessagePrimitive.Content";
|
138
|
-
export {
|
139
|
-
MessagePrimitiveContent
|
140
|
-
};
|
141
|
-
//# sourceMappingURL=MessageContent.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/primitives/message/MessageContent.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ComponentType, type FC, memo, useMemo } from \"react\";\nimport {\n TextContentPartProvider,\n useContentPart,\n useContentPartRuntime,\n useToolUIs,\n} from \"../../context\";\nimport {\n useMessage,\n useMessageRuntime,\n} from \"../../context/react/MessageContext\";\nimport { ContentPartRuntimeProvider } from \"../../context/providers/ContentPartRuntimeProvider\";\nimport { ContentPartPrimitiveText } from \"../contentPart/ContentPartText\";\nimport { ContentPartPrimitiveImage } from \"../contentPart/ContentPartImage\";\nimport type {\n Unstable_AudioContentPartComponent,\n EmptyContentPartComponent,\n TextContentPartComponent,\n ImageContentPartComponent,\n SourceContentPartComponent,\n ToolCallContentPartComponent,\n ToolCallContentPartProps,\n FileContentPartComponent,\n ReasoningContentPartComponent,\n} from \"../../types/ContentPartComponentTypes\";\nimport { ContentPartPrimitiveInProgress } from \"../contentPart/ContentPartInProgress\";\nimport { ContentPartStatus } from \"../../types/AssistantTypes\";\n\nexport namespace MessagePrimitiveContent {\n export type Props = {\n /**\n * Component configuration for rendering different types of message content.\n *\n * You can provide custom components for each content type (text, image, file, etc.)\n * and configure tool rendering behavior. If not provided, default components will be used.\n */\n components?:\n | {\n /** Component for rendering empty messages */\n Empty?: EmptyContentPartComponent | undefined;\n /** Component for rendering text content */\n Text?: TextContentPartComponent | undefined;\n /** Component for rendering reasoning content (typically hidden) */\n Reasoning?: ReasoningContentPartComponent | undefined;\n /** Component for rendering source content */\n Source?: SourceContentPartComponent | undefined;\n /** Component for rendering image content */\n Image?: ImageContentPartComponent | undefined;\n /** Component for rendering file content */\n File?: FileContentPartComponent | undefined;\n /** Component for rendering audio content (experimental) */\n Unstable_Audio?: Unstable_AudioContentPartComponent | undefined;\n /** Configuration for tool call rendering */\n tools?:\n | {\n /** Map of tool names to their specific components */\n by_name?:\n | Record<string, ToolCallContentPartComponent | undefined>\n | undefined;\n /** Fallback component for unregistered tools */\n Fallback?: ComponentType<ToolCallContentPartProps> | undefined;\n }\n | {\n /** Override component that handles all tool calls */\n Override: ComponentType<ToolCallContentPartProps>;\n }\n | undefined;\n }\n | undefined;\n };\n}\n\nconst ToolUIDisplay = ({\n Fallback,\n ...props\n}: {\n Fallback: ToolCallContentPartComponent | undefined;\n} & ToolCallContentPartProps) => {\n const Render = useToolUIs((s) => s.getToolUI(props.toolName)) ?? Fallback;\n if (!Render) return null;\n return <Render {...props} />;\n};\n\nconst defaultComponents = {\n Text: () => (\n <p style={{ whiteSpace: \"pre-line\" }}>\n <ContentPartPrimitiveText />\n <ContentPartPrimitiveInProgress>\n <span style={{ fontFamily: \"revert\" }}>{\" \\u25CF\"}</span>\n </ContentPartPrimitiveInProgress>\n </p>\n ),\n Reasoning: () => null,\n Source: () => null,\n Image: () => <ContentPartPrimitiveImage />,\n File: () => null,\n Unstable_Audio: () => null,\n} satisfies MessagePrimitiveContent.Props[\"components\"];\n\ntype MessageContentPartComponentProps = {\n components: MessagePrimitiveContent.Props[\"components\"];\n};\n\nconst MessageContentPartComponent: FC<MessageContentPartComponentProps> = ({\n components: {\n Text = defaultComponents.Text,\n Reasoning = defaultComponents.Reasoning,\n Image = defaultComponents.Image,\n Source = defaultComponents.Source,\n File = defaultComponents.File,\n Unstable_Audio: Audio = defaultComponents.Unstable_Audio,\n tools = {},\n } = {},\n}) => {\n const contentPartRuntime = useContentPartRuntime();\n\n const part = useContentPart();\n\n const type = part.type;\n if (type === \"tool-call\") {\n const addResult = (result: any) => contentPartRuntime.addToolResult(result);\n if (\"Override\" in tools)\n return <tools.Override {...part} addResult={addResult} />;\n const Tool = tools.by_name?.[part.toolName] ?? tools.Fallback;\n return <ToolUIDisplay {...part} Fallback={Tool} addResult={addResult} />;\n }\n\n if (part.status.type === \"requires-action\")\n throw new Error(\"Encountered unexpected requires-action status\");\n\n switch (type) {\n case \"text\":\n return <Text {...part} />;\n\n case \"reasoning\":\n return <Reasoning {...part} />;\n\n case \"source\":\n return <Source {...part} />;\n\n case \"image\":\n // eslint-disable-next-line jsx-a11y/alt-text\n return <Image {...part} />;\n\n case \"file\":\n return <File {...part} />;\n\n case \"audio\":\n return <Audio {...part} />;\n\n default:\n const unhandledType: never = type;\n throw new Error(`Unknown content part type: ${unhandledType}`);\n }\n};\n\ntype MessageContentPartProps = {\n partIndex: number;\n components: MessagePrimitiveContent.Props[\"components\"];\n};\n\nconst MessageContentPartImpl: FC<MessageContentPartProps> = ({\n partIndex,\n components,\n}) => {\n const messageRuntime = useMessageRuntime();\n const runtime = useMemo(\n () => messageRuntime.getContentPartByIndex(partIndex),\n [messageRuntime, partIndex],\n );\n\n return (\n <ContentPartRuntimeProvider runtime={runtime}>\n <MessageContentPartComponent components={components} />\n </ContentPartRuntimeProvider>\n );\n};\n\nconst MessageContentPart = memo(\n MessageContentPartImpl,\n (prev, next) =>\n prev.partIndex === next.partIndex &&\n prev.components?.Text === next.components?.Text &&\n prev.components?.Reasoning === next.components?.Reasoning &&\n prev.components?.Source === next.components?.Source &&\n prev.components?.Image === next.components?.Image &&\n prev.components?.File === next.components?.File &&\n prev.components?.Unstable_Audio === next.components?.Unstable_Audio &&\n prev.components?.tools === next.components?.tools,\n);\n\nconst COMPLETE_STATUS: ContentPartStatus = Object.freeze({\n type: \"complete\",\n});\n\nconst EmptyContentFallback: FC<{\n status: ContentPartStatus;\n component: TextContentPartComponent;\n}> = ({ status, component: Component }) => {\n return (\n <TextContentPartProvider text=\"\" isRunning={status.type === \"running\"}>\n <Component type=\"text\" text=\"\" status={status} />\n </TextContentPartProvider>\n );\n};\n\nconst EmptyContentImpl: FC<MessageContentPartComponentProps> = ({\n components,\n}) => {\n const status =\n useMessage((s) => s.status as ContentPartStatus) ?? COMPLETE_STATUS;\n\n if (components?.Empty) return <components.Empty status={status} />;\n\n return (\n <EmptyContentFallback\n status={status}\n component={components?.Text ?? defaultComponents.Text}\n />\n );\n};\n\nconst EmptyContent = memo(\n EmptyContentImpl,\n (prev, next) =>\n prev.components?.Empty === next.components?.Empty &&\n prev.components?.Text === next.components?.Text,\n);\n\n/**\n * Renders the content of a message with support for multiple content types.\n *\n * This component automatically handles different types of message content including\n * text, images, files, tool calls, and more. It provides a flexible component\n * system for customizing how each content type is rendered.\n *\n * @example\n * ```tsx\n * <MessagePrimitive.Content\n * components={{\n * Text: ({ text }) => <p className=\"message-text\">{text}</p>,\n * Image: ({ image }) => <img src={image} alt=\"Message image\" />,\n * tools: {\n * by_name: {\n * calculator: CalculatorTool,\n * weather: WeatherTool,\n * },\n * Fallback: DefaultToolComponent\n * }\n * }}\n * />\n * ```\n */\nexport const MessagePrimitiveContent: FC<MessagePrimitiveContent.Props> = ({\n components,\n}) => {\n const contentLength = useMessage((s) => s.content.length);\n\n const contentElements = useMemo(() => {\n if (contentLength === 0) {\n return <EmptyContent components={components} />;\n }\n return Array.from({ length: contentLength }, (_, index) => (\n <MessageContentPart\n key={index}\n partIndex={index}\n components={components}\n />\n ));\n }, [contentLength, components]);\n\n return <>{contentElements}</>;\n};\n\nMessagePrimitiveContent.displayName = \"MessagePrimitive.Content\";\n"],"mapp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 @@
|
|
1
|
-
import type { ComponentType } from "react";
|
2
|
-
import type { ContentPartStatus, FileContentPart, ImageContentPart, ReasoningContentPart, SourceContentPart, TextContentPart, ToolCallContentPart, Unstable_AudioContentPart } from "./AssistantTypes";
|
3
|
-
import { ContentPartState } from "../api/ContentPartRuntime";
|
4
|
-
import { ToolResponse } from "assistant-stream";
|
5
|
-
export type EmptyContentPartProps = {
|
6
|
-
status: ContentPartStatus;
|
7
|
-
};
|
8
|
-
export type EmptyContentPartComponent = ComponentType<EmptyContentPartProps>;
|
9
|
-
export type TextContentPartProps = ContentPartState & TextContentPart;
|
10
|
-
export type TextContentPartComponent = ComponentType<TextContentPartProps>;
|
11
|
-
export type ReasoningContentPartProps = ContentPartState & ReasoningContentPart;
|
12
|
-
export type ReasoningContentPartComponent = ComponentType<ReasoningContentPartProps>;
|
13
|
-
export type SourceContentPartProps = ContentPartState & SourceContentPart;
|
14
|
-
export type SourceContentPartComponent = ComponentType<SourceContentPartProps>;
|
15
|
-
export type ImageContentPartProps = ContentPartState & ImageContentPart;
|
16
|
-
export type ImageContentPartComponent = ComponentType<ImageContentPartProps>;
|
17
|
-
export type FileContentPartProps = ContentPartState & FileContentPart;
|
18
|
-
export type FileContentPartComponent = ComponentType<FileContentPartProps>;
|
19
|
-
export type Unstable_AudioContentPartProps = ContentPartState & Unstable_AudioContentPart;
|
20
|
-
export type Unstable_AudioContentPartComponent = ComponentType<Unstable_AudioContentPartProps>;
|
21
|
-
export type ToolCallContentPartProps<TArgs = any, TResult = unknown> = ContentPartState & ToolCallContentPart<TArgs, TResult> & {
|
22
|
-
addResult: (result: TResult | ToolResponse<TResult>) => void;
|
23
|
-
};
|
24
|
-
export type ToolCallContentPartComponent<TArgs = any, TResult = any> = ComponentType<ToolCallContentPartProps<TArgs, TResult>>;
|
25
|
-
//# sourceMappingURL=ContentPartComponentTypes.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
//# sourceMappingURL=ContentPartComponentTypes.js.map
|
@@ -1,42 +0,0 @@
|
|
1
|
-
"use client";
|
2
|
-
|
3
|
-
import { type FC, type PropsWithChildren, useEffect, useState } from "react";
|
4
|
-
import { create } from "zustand";
|
5
|
-
import { ContentPartContext } from "../react/ContentPartContext";
|
6
|
-
import type { ContentPartContextValue } from "../react/ContentPartContext";
|
7
|
-
import { writableStore } from "../ReadonlyStore";
|
8
|
-
import { ContentPartRuntime } from "../../api/ContentPartRuntime";
|
9
|
-
import { ensureBinding } from "../react/utils/ensureBinding";
|
10
|
-
|
11
|
-
export namespace ContentPartRuntimeProvider {
|
12
|
-
export type Props = PropsWithChildren<{
|
13
|
-
runtime: ContentPartRuntime;
|
14
|
-
}>;
|
15
|
-
}
|
16
|
-
|
17
|
-
const useContentPartRuntimeStore = (runtime: ContentPartRuntime) => {
|
18
|
-
const [store] = useState(() => create(() => runtime));
|
19
|
-
|
20
|
-
useEffect(() => {
|
21
|
-
ensureBinding(runtime);
|
22
|
-
|
23
|
-
writableStore(store).setState(runtime, true);
|
24
|
-
}, [runtime, store]);
|
25
|
-
|
26
|
-
return store;
|
27
|
-
};
|
28
|
-
|
29
|
-
export const ContentPartRuntimeProvider: FC<
|
30
|
-
ContentPartRuntimeProvider.Props
|
31
|
-
> = ({ runtime, children }) => {
|
32
|
-
const useContentPartRuntime = useContentPartRuntimeStore(runtime);
|
33
|
-
const [context] = useState<ContentPartContextValue>(() => {
|
34
|
-
return { useContentPartRuntime };
|
35
|
-
});
|
36
|
-
|
37
|
-
return (
|
38
|
-
<ContentPartContext.Provider value={context}>
|
39
|
-
{children}
|
40
|
-
</ContentPartContext.Provider>
|
41
|
-
);
|
42
|
-
};
|
@@ -1,37 +0,0 @@
|
|
1
|
-
"use client";
|
2
|
-
|
3
|
-
import { createContext } from "react";
|
4
|
-
import { ReadonlyStore } from "../ReadonlyStore";
|
5
|
-
import { createContextHook } from "./utils/createContextHook";
|
6
|
-
import { UseBoundStore } from "zustand";
|
7
|
-
import { ContentPartRuntime } from "../../api/ContentPartRuntime";
|
8
|
-
import { createStateHookForRuntime } from "./utils/createStateHookForRuntime";
|
9
|
-
|
10
|
-
export type ContentPartContextValue = {
|
11
|
-
useContentPartRuntime: UseBoundStore<ReadonlyStore<ContentPartRuntime>>;
|
12
|
-
};
|
13
|
-
|
14
|
-
export const ContentPartContext = createContext<ContentPartContextValue | null>(
|
15
|
-
null,
|
16
|
-
);
|
17
|
-
|
18
|
-
const useContentPartContext = createContextHook(
|
19
|
-
ContentPartContext,
|
20
|
-
"a component passed to <MessagePrimitive.Content components={...}>",
|
21
|
-
);
|
22
|
-
|
23
|
-
export function useContentPartRuntime(options?: {
|
24
|
-
optional?: false | undefined;
|
25
|
-
}): ContentPartRuntime;
|
26
|
-
export function useContentPartRuntime(options?: {
|
27
|
-
optional?: boolean | undefined;
|
28
|
-
}): ContentPartRuntime | null;
|
29
|
-
export function useContentPartRuntime(options?: {
|
30
|
-
optional?: boolean | undefined;
|
31
|
-
}) {
|
32
|
-
const context = useContentPartContext(options);
|
33
|
-
if (!context) return null;
|
34
|
-
return context.useContentPartRuntime();
|
35
|
-
}
|
36
|
-
|
37
|
-
export const useContentPart = createStateHookForRuntime(useContentPartRuntime);
|
@@ -1,39 +0,0 @@
|
|
1
|
-
"use client";
|
2
|
-
|
3
|
-
import { Primitive } from "@radix-ui/react-primitive";
|
4
|
-
import { type ComponentRef, forwardRef, ComponentPropsWithoutRef } from "react";
|
5
|
-
import { useContentPartImage } from "./useContentPartImage";
|
6
|
-
|
7
|
-
export namespace ContentPartPrimitiveImage {
|
8
|
-
export type Element = ComponentRef<typeof Primitive.img>;
|
9
|
-
/**
|
10
|
-
* Props for the ContentPartPrimitive.Image component.
|
11
|
-
* Accepts all standard img element props.
|
12
|
-
*/
|
13
|
-
export type Props = ComponentPropsWithoutRef<typeof Primitive.img>;
|
14
|
-
}
|
15
|
-
|
16
|
-
/**
|
17
|
-
* Renders an image from the current content part context.
|
18
|
-
*
|
19
|
-
* This component displays image content from the current content part,
|
20
|
-
* automatically setting the src attribute from the content part's image data.
|
21
|
-
*
|
22
|
-
* @example
|
23
|
-
* ```tsx
|
24
|
-
* <ContentPartPrimitive.Image
|
25
|
-
* alt="Generated image"
|
26
|
-
* className="message-image"
|
27
|
-
* style={{ maxWidth: '100%' }}
|
28
|
-
* />
|
29
|
-
* ```
|
30
|
-
*/
|
31
|
-
export const ContentPartPrimitiveImage = forwardRef<
|
32
|
-
ContentPartPrimitiveImage.Element,
|
33
|
-
ContentPartPrimitiveImage.Props
|
34
|
-
>((props, forwardedRef) => {
|
35
|
-
const { image } = useContentPartImage();
|
36
|
-
return <Primitive.img src={image} {...props} ref={forwardedRef} />;
|
37
|
-
});
|
38
|
-
|
39
|
-
ContentPartPrimitiveImage.displayName = "ContentPartPrimitive.Image";
|
@@ -1,19 +0,0 @@
|
|
1
|
-
"use client";
|
2
|
-
|
3
|
-
import { FC, PropsWithChildren } from "react";
|
4
|
-
import { useContentPart } from "../../context";
|
5
|
-
|
6
|
-
export namespace ContentPartPrimitiveInProgress {
|
7
|
-
export type Props = PropsWithChildren;
|
8
|
-
}
|
9
|
-
|
10
|
-
// TODO should this be renamed to IsRunning?
|
11
|
-
export const ContentPartPrimitiveInProgress: FC<
|
12
|
-
ContentPartPrimitiveInProgress.Props
|
13
|
-
> = ({ children }) => {
|
14
|
-
const isInProgress = useContentPart((c) => c.status.type === "running");
|
15
|
-
|
16
|
-
return isInProgress ? children : null;
|
17
|
-
};
|
18
|
-
|
19
|
-
ContentPartPrimitiveInProgress.displayName = "ContentPartPrimitive.InProgress";
|
@@ -1,18 +0,0 @@
|
|
1
|
-
"use client";
|
2
|
-
|
3
|
-
import { ContentPartState } from "../../api/ContentPartRuntime";
|
4
|
-
import { useContentPart } from "../../context/react/ContentPartContext";
|
5
|
-
import { FileContentPart } from "../../types";
|
6
|
-
|
7
|
-
export const useContentPartFile = () => {
|
8
|
-
const file = useContentPart((c) => {
|
9
|
-
if (c.type !== "file")
|
10
|
-
throw new Error(
|
11
|
-
"ContentPartFile can only be used inside file content parts.",
|
12
|
-
);
|
13
|
-
|
14
|
-
return c as ContentPartState & FileContentPart;
|
15
|
-
});
|
16
|
-
|
17
|
-
return file;
|
18
|
-
};
|
@@ -1,18 +0,0 @@
|
|
1
|
-
"use client";
|
2
|
-
|
3
|
-
import { ContentPartState } from "../../api/ContentPartRuntime";
|
4
|
-
import { useContentPart } from "../../context/react/ContentPartContext";
|
5
|
-
import { ImageContentPart } from "../../types";
|
6
|
-
|
7
|
-
export const useContentPartImage = () => {
|
8
|
-
const image = useContentPart((c) => {
|
9
|
-
if (c.type !== "image")
|
10
|
-
throw new Error(
|
11
|
-
"ContentPartImage can only be used inside image content parts.",
|
12
|
-
);
|
13
|
-
|
14
|
-
return c as ContentPartState & ImageContentPart;
|
15
|
-
});
|
16
|
-
|
17
|
-
return image;
|
18
|
-
};
|
@@ -1,18 +0,0 @@
|
|
1
|
-
"use client";
|
2
|
-
|
3
|
-
import { ContentPartState } from "../../api/ContentPartRuntime";
|
4
|
-
import { useContentPart } from "../../context/react/ContentPartContext";
|
5
|
-
import { ReasoningContentPart } from "../../types";
|
6
|
-
|
7
|
-
export const useContentPartReasoning = () => {
|
8
|
-
const text = useContentPart((c) => {
|
9
|
-
if (c.type !== "reasoning")
|
10
|
-
throw new Error(
|
11
|
-
"ContentPartReasoning can only be used inside reasoning content parts.",
|
12
|
-
);
|
13
|
-
|
14
|
-
return c as ContentPartState & ReasoningContentPart;
|
15
|
-
});
|
16
|
-
|
17
|
-
return text;
|
18
|
-
};
|
@@ -1,18 +0,0 @@
|
|
1
|
-
"use client";
|
2
|
-
|
3
|
-
import { ContentPartState } from "../../api/ContentPartRuntime";
|
4
|
-
import { useContentPart } from "../../context/react/ContentPartContext";
|
5
|
-
import { SourceContentPart } from "../../types";
|
6
|
-
|
7
|
-
export const useContentPartSource = () => {
|
8
|
-
const source = useContentPart((c) => {
|
9
|
-
if (c.type !== "source")
|
10
|
-
throw new Error(
|
11
|
-
"ContentPartSource can only be used inside source content parts.",
|
12
|
-
);
|
13
|
-
|
14
|
-
return c as ContentPartState & SourceContentPart;
|
15
|
-
});
|
16
|
-
|
17
|
-
return source;
|
18
|
-
};
|
@@ -1,18 +0,0 @@
|
|
1
|
-
"use client";
|
2
|
-
|
3
|
-
import { ContentPartState } from "../../api/ContentPartRuntime";
|
4
|
-
import { useContentPart } from "../../context/react/ContentPartContext";
|
5
|
-
import { TextContentPart, ReasoningContentPart } from "../../types";
|
6
|
-
|
7
|
-
export const useContentPartText = () => {
|
8
|
-
const text = useContentPart((c) => {
|
9
|
-
if (c.type !== "text" && c.type !== "reasoning")
|
10
|
-
throw new Error(
|
11
|
-
"ContentPartText can only be used inside text or reasoning content parts.",
|
12
|
-
);
|
13
|
-
|
14
|
-
return c as ContentPartState & (TextContentPart | ReasoningContentPart);
|
15
|
-
});
|
16
|
-
|
17
|
-
return text;
|
18
|
-
};
|