@anvia/react-ui 0.2.0 → 0.3.0
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/attachment/index.js +2 -2
- package/dist/chat/index.d.ts +13 -2
- package/dist/chat/index.js +4 -4
- package/dist/{chunk-LSHD67YK.js → chunk-4Z7LULAM.js} +2 -2
- package/dist/{chunk-7AS6R7BB.js → chunk-5IHC7D4U.js} +93 -16
- package/dist/chunk-5IHC7D4U.js.map +1 -0
- package/dist/{chunk-AOZN3SWB.js → chunk-5Z2IWZ5O.js} +4 -3
- package/dist/{chunk-AOZN3SWB.js.map → chunk-5Z2IWZ5O.js.map} +1 -1
- package/dist/chunk-IHRCKGRS.js +432 -0
- package/dist/chunk-IHRCKGRS.js.map +1 -0
- package/dist/{chunk-AXZB6JSE.js → chunk-LRAQW3ZK.js} +125 -11
- package/dist/chunk-LRAQW3ZK.js.map +1 -0
- package/dist/chunk-MXYHYD3O.js +291 -0
- package/dist/chunk-MXYHYD3O.js.map +1 -0
- package/dist/chunk-OKTDYMSA.js +236 -0
- package/dist/chunk-OKTDYMSA.js.map +1 -0
- package/dist/{chunk-RRINF6FN.js → chunk-QHP4GSRG.js} +2 -2
- package/dist/{chunk-WK33ER4Q.js → chunk-YDMDLFU4.js} +2 -2
- package/dist/completion/index.js +2 -2
- package/dist/human-input/index.js +2 -2
- package/dist/image/index.d.ts +40 -0
- package/dist/image/index.js +12 -0
- package/dist/image/index.js.map +1 -0
- package/dist/image-DanUxcl2.d.ts +14 -0
- package/dist/index.d.ts +7 -1
- package/dist/index.js +32 -8
- package/dist/message/index.js +3 -3
- package/dist/selection-toolbar/index.d.ts +21 -0
- package/dist/selection-toolbar/index.js +12 -0
- package/dist/selection-toolbar/index.js.map +1 -0
- package/dist/selection-toolbar-Cwjbuv5S.d.ts +14 -0
- package/dist/shared.d.ts +4 -1
- package/dist/shared.js +13 -3
- package/dist/styles.css +22 -0
- package/dist/{thread-CluT3m5k.d.ts → thread-DYPvlsJa.d.ts} +8 -1
- package/dist/thread-list/index.d.ts +47 -0
- package/dist/thread-list/index.js +18 -0
- package/dist/thread-list/index.js.map +1 -0
- package/dist/thread-list-On8db4XL.d.ts +34 -0
- package/package.json +17 -4
- package/dist/chunk-7AS6R7BB.js.map +0 -1
- package/dist/chunk-AXZB6JSE.js.map +0 -1
- /package/dist/{chunk-LSHD67YK.js.map → chunk-4Z7LULAM.js.map} +0 -0
- /package/dist/{chunk-RRINF6FN.js.map → chunk-QHP4GSRG.js.map} +0 -0
- /package/dist/{chunk-WK33ER4Q.js.map → chunk-YDMDLFU4.js.map} +0 -0
package/dist/attachment/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Attachment
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-QHP4GSRG.js";
|
|
4
4
|
import "../chunk-T3ZFZ3NP.js";
|
|
5
5
|
import {
|
|
6
6
|
useAttachment
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-5IHC7D4U.js";
|
|
8
8
|
export {
|
|
9
9
|
Attachment,
|
|
10
10
|
useAttachment
|
package/dist/chat/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { C as ChatController } from '../chat-B3kucz1w.js';
|
|
2
2
|
export { a as ChatProvider, b as ChatProviderProps, u as useChatContext } from '../chat-B3kucz1w.js';
|
|
3
|
-
|
|
3
|
+
import { c as ComposerQuote } from '../thread-DYPvlsJa.js';
|
|
4
|
+
export { C as ComposerAttachmentInput, a as ComposerAttachmentsUpdate, b as ComposerContextValue, T as ThreadContextValue, u as useComposer, d as useThread } from '../thread-DYPvlsJa.js';
|
|
4
5
|
import * as react from 'react';
|
|
5
6
|
import { ReactNode } from 'react';
|
|
6
7
|
import { UIAttachment, UIMessage, UseChatStatus, ChatSuggestion } from '@anvia/react';
|
|
@@ -10,6 +11,7 @@ type ComposerSubmitMessageArgs<TEvent = unknown> = {
|
|
|
10
11
|
input: string;
|
|
11
12
|
attachments: UIAttachment[];
|
|
12
13
|
chat: ChatController<TEvent>;
|
|
14
|
+
quote?: ComposerQuote | undefined;
|
|
13
15
|
clear(): void;
|
|
14
16
|
};
|
|
15
17
|
type ComposerSubmitMessage<TEvent = unknown> = (args: ComposerSubmitMessageArgs<TEvent>) => Promise<void> | void;
|
|
@@ -21,11 +23,20 @@ declare const Composer: {
|
|
|
21
23
|
attachments?: UIAttachment[];
|
|
22
24
|
defaultAttachments?: UIAttachment[];
|
|
23
25
|
defaultInput?: string;
|
|
26
|
+
defaultQuote?: ComposerQuote | undefined;
|
|
24
27
|
input?: string;
|
|
25
28
|
onAttachmentsChange?: (attachments: UIAttachment[]) => void;
|
|
26
29
|
onInputChange?: (input: string) => void;
|
|
30
|
+
onQuoteChange?: (quote: ComposerQuote | undefined) => void;
|
|
31
|
+
quote?: ComposerQuote | undefined;
|
|
27
32
|
submitMessage?: ComposerSubmitMessage;
|
|
28
33
|
} & react.RefAttributes<HTMLFormElement>>;
|
|
34
|
+
readonly Quote: react.ForwardRefExoticComponent<Omit<PrimitiveProps<"blockquote">, "children"> & {
|
|
35
|
+
children?: ReactNode | ((quote: ComposerQuote) => ReactNode);
|
|
36
|
+
} & react.RefAttributes<HTMLQuoteElement>>;
|
|
37
|
+
readonly ClearQuote: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref">, "asChild"> & {
|
|
38
|
+
asChild?: boolean;
|
|
39
|
+
} & react.RefAttributes<HTMLButtonElement>>;
|
|
29
40
|
readonly Input: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>, "ref">, "asChild"> & {
|
|
30
41
|
asChild?: boolean;
|
|
31
42
|
} & {
|
|
@@ -103,4 +114,4 @@ declare const Thread: {
|
|
|
103
114
|
} & react.RefAttributes<HTMLButtonElement>>;
|
|
104
115
|
};
|
|
105
116
|
|
|
106
|
-
export { ChatController, Composer, type ComposerSubmitMessage, type ComposerSubmitMessageArgs, Thread };
|
|
117
|
+
export { ChatController, Composer, ComposerQuote, type ComposerSubmitMessage, type ComposerSubmitMessageArgs, Thread };
|
package/dist/chat/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Composer,
|
|
3
3
|
Thread
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
6
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-LRAQW3ZK.js";
|
|
5
|
+
import "../chunk-5Z2IWZ5O.js";
|
|
6
|
+
import "../chunk-QHP4GSRG.js";
|
|
7
7
|
import "../chunk-T3ZFZ3NP.js";
|
|
8
8
|
import {
|
|
9
9
|
ChatProvider,
|
|
10
10
|
useChatContext,
|
|
11
11
|
useComposer,
|
|
12
12
|
useThread
|
|
13
|
-
} from "../chunk-
|
|
13
|
+
} from "../chunk-5IHC7D4U.js";
|
|
14
14
|
export {
|
|
15
15
|
ChatProvider,
|
|
16
16
|
Composer,
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
InternalCompletionInputProvider,
|
|
6
6
|
useCompletionContext,
|
|
7
7
|
useCompletionInput
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-5IHC7D4U.js";
|
|
9
9
|
|
|
10
10
|
// src/completion/form.tsx
|
|
11
11
|
import {
|
|
@@ -197,4 +197,4 @@ var Completion = {
|
|
|
197
197
|
export {
|
|
198
198
|
Completion
|
|
199
199
|
};
|
|
200
|
-
//# sourceMappingURL=chunk-
|
|
200
|
+
//# sourceMappingURL=chunk-4Z7LULAM.js.map
|
|
@@ -14,6 +14,9 @@ function useAttachment() {
|
|
|
14
14
|
}
|
|
15
15
|
return value;
|
|
16
16
|
}
|
|
17
|
+
function useOptionalAttachment() {
|
|
18
|
+
return useContext(AttachmentContext);
|
|
19
|
+
}
|
|
17
20
|
|
|
18
21
|
// src/contexts/chat.tsx
|
|
19
22
|
import { createContext as createContext2, createElement as createElement2, useContext as useContext2 } from "react";
|
|
@@ -146,64 +149,130 @@ function useQuestionPrompt() {
|
|
|
146
149
|
return value;
|
|
147
150
|
}
|
|
148
151
|
|
|
149
|
-
// src/contexts/
|
|
152
|
+
// src/contexts/image.tsx
|
|
150
153
|
import { createContext as createContext7, createElement as createElement7, useContext as useContext7 } from "react";
|
|
151
|
-
var
|
|
152
|
-
|
|
154
|
+
var ImageContext = createContext7(void 0);
|
|
155
|
+
function InternalImageProvider({
|
|
156
|
+
value,
|
|
157
|
+
children
|
|
158
|
+
}) {
|
|
159
|
+
return createElement7(ImageContext.Provider, { value }, children);
|
|
160
|
+
}
|
|
161
|
+
function useImage() {
|
|
162
|
+
const value = useContext7(ImageContext);
|
|
163
|
+
if (value === void 0) {
|
|
164
|
+
throw new Error("Image primitives must be used inside Image.Root.");
|
|
165
|
+
}
|
|
166
|
+
return value;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// src/contexts/message.tsx
|
|
170
|
+
import { createContext as createContext8, createElement as createElement8, useContext as useContext8 } from "react";
|
|
171
|
+
var MessageContext = createContext8(void 0);
|
|
172
|
+
var MessagePartContext = createContext8(void 0);
|
|
153
173
|
function InternalMessageProvider({
|
|
154
174
|
message,
|
|
155
175
|
children
|
|
156
176
|
}) {
|
|
157
|
-
return
|
|
177
|
+
return createElement8(MessageContext.Provider, { value: { message } }, children);
|
|
158
178
|
}
|
|
159
179
|
function InternalMessagePartProvider({
|
|
160
180
|
part,
|
|
161
181
|
children
|
|
162
182
|
}) {
|
|
163
|
-
return
|
|
183
|
+
return createElement8(MessagePartContext.Provider, { value: { part } }, children);
|
|
164
184
|
}
|
|
165
185
|
function useMessage() {
|
|
166
|
-
const value =
|
|
186
|
+
const value = useContext8(MessageContext);
|
|
167
187
|
if (value === void 0) {
|
|
168
188
|
throw new Error("Message primitives must be used inside Message.Root or Thread.Messages.");
|
|
169
189
|
}
|
|
170
190
|
return value;
|
|
171
191
|
}
|
|
172
192
|
function useMessagePart() {
|
|
173
|
-
const value =
|
|
193
|
+
const value = useContext8(MessagePartContext);
|
|
174
194
|
if (value === void 0) {
|
|
175
195
|
throw new Error("Message part primitives must be used inside Message.Parts or Message.Part.");
|
|
176
196
|
}
|
|
177
197
|
return value;
|
|
178
198
|
}
|
|
179
199
|
function useOptionalMessagePart() {
|
|
180
|
-
return
|
|
200
|
+
return useContext8(MessagePartContext);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// src/contexts/selection-toolbar.tsx
|
|
204
|
+
import { createContext as createContext9, createElement as createElement9, useContext as useContext9 } from "react";
|
|
205
|
+
var SelectionToolbarContext = createContext9(void 0);
|
|
206
|
+
function InternalSelectionToolbarProvider({
|
|
207
|
+
value,
|
|
208
|
+
children
|
|
209
|
+
}) {
|
|
210
|
+
return createElement9(SelectionToolbarContext.Provider, { value }, children);
|
|
211
|
+
}
|
|
212
|
+
function useSelectionToolbar() {
|
|
213
|
+
const value = useContext9(SelectionToolbarContext);
|
|
214
|
+
if (value === void 0) {
|
|
215
|
+
throw new Error("SelectionToolbar primitives must be used inside SelectionToolbar.Root.");
|
|
216
|
+
}
|
|
217
|
+
return value;
|
|
181
218
|
}
|
|
182
219
|
|
|
183
220
|
// src/contexts/thread.tsx
|
|
184
221
|
import {
|
|
185
|
-
createContext as
|
|
186
|
-
createElement as
|
|
187
|
-
useContext as
|
|
222
|
+
createContext as createContext10,
|
|
223
|
+
createElement as createElement10,
|
|
224
|
+
useContext as useContext10
|
|
188
225
|
} from "react";
|
|
189
|
-
var ThreadContext =
|
|
226
|
+
var ThreadContext = createContext10(void 0);
|
|
190
227
|
function InternalThreadProvider({
|
|
191
228
|
value,
|
|
192
229
|
children
|
|
193
230
|
}) {
|
|
194
|
-
return
|
|
231
|
+
return createElement10(ThreadContext.Provider, { value }, children);
|
|
195
232
|
}
|
|
196
233
|
function useThread() {
|
|
197
|
-
const value =
|
|
234
|
+
const value = useContext10(ThreadContext);
|
|
198
235
|
if (value === void 0) {
|
|
199
236
|
throw new Error("Thread primitives must be used inside Thread.Root.");
|
|
200
237
|
}
|
|
201
238
|
return value;
|
|
202
239
|
}
|
|
203
240
|
|
|
241
|
+
// src/contexts/thread-list.tsx
|
|
242
|
+
import { createContext as createContext11, createElement as createElement11, useContext as useContext11 } from "react";
|
|
243
|
+
var ThreadListContext = createContext11(void 0);
|
|
244
|
+
var ThreadListItemContext = createContext11(void 0);
|
|
245
|
+
function ThreadListProvider({
|
|
246
|
+
controller,
|
|
247
|
+
children
|
|
248
|
+
}) {
|
|
249
|
+
return createElement11(ThreadListContext.Provider, { value: controller }, children);
|
|
250
|
+
}
|
|
251
|
+
function InternalThreadListItemProvider({
|
|
252
|
+
value,
|
|
253
|
+
children
|
|
254
|
+
}) {
|
|
255
|
+
return createElement11(ThreadListItemContext.Provider, { value }, children);
|
|
256
|
+
}
|
|
257
|
+
function useThreadList() {
|
|
258
|
+
const value = useContext11(ThreadListContext);
|
|
259
|
+
if (value === void 0) {
|
|
260
|
+
throw new Error("ThreadList primitives must be used inside ThreadListProvider.");
|
|
261
|
+
}
|
|
262
|
+
return value;
|
|
263
|
+
}
|
|
264
|
+
function useThreadListItem() {
|
|
265
|
+
const value = useContext11(ThreadListItemContext);
|
|
266
|
+
if (value === void 0) {
|
|
267
|
+
throw new Error("ThreadListItem primitives must be used inside ThreadList.Items.");
|
|
268
|
+
}
|
|
269
|
+
return value;
|
|
270
|
+
}
|
|
271
|
+
|
|
204
272
|
export {
|
|
205
273
|
InternalAttachmentProvider,
|
|
206
274
|
useAttachment,
|
|
275
|
+
useOptionalAttachment,
|
|
207
276
|
ChatProvider,
|
|
208
277
|
useChatContext,
|
|
209
278
|
useHumanInput,
|
|
@@ -219,12 +288,20 @@ export {
|
|
|
219
288
|
useApproval,
|
|
220
289
|
useQuestion,
|
|
221
290
|
useQuestionPrompt,
|
|
291
|
+
InternalImageProvider,
|
|
292
|
+
useImage,
|
|
222
293
|
InternalMessageProvider,
|
|
223
294
|
InternalMessagePartProvider,
|
|
224
295
|
useMessage,
|
|
225
296
|
useMessagePart,
|
|
226
297
|
useOptionalMessagePart,
|
|
298
|
+
InternalSelectionToolbarProvider,
|
|
299
|
+
useSelectionToolbar,
|
|
227
300
|
InternalThreadProvider,
|
|
228
|
-
useThread
|
|
301
|
+
useThread,
|
|
302
|
+
ThreadListProvider,
|
|
303
|
+
InternalThreadListItemProvider,
|
|
304
|
+
useThreadList,
|
|
305
|
+
useThreadListItem
|
|
229
306
|
};
|
|
230
|
-
//# sourceMappingURL=chunk-
|
|
307
|
+
//# sourceMappingURL=chunk-5IHC7D4U.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/contexts/attachment.tsx","../src/contexts/chat.tsx","../src/contexts/completion.tsx","../src/contexts/completion-input.tsx","../src/contexts/composer.tsx","../src/contexts/human-input.tsx","../src/contexts/image.tsx","../src/contexts/message.tsx","../src/contexts/selection-toolbar.tsx","../src/contexts/thread.tsx","../src/contexts/thread-list.tsx"],"sourcesContent":["import type { UIAttachment } from \"@anvia/react\";\nimport { createContext, createElement, type ReactElement, type ReactNode, useContext } from \"react\";\n\nexport type AttachmentContextValue = {\n attachment: UIAttachment;\n remove?(): void;\n};\n\nconst AttachmentContext = createContext<AttachmentContextValue | undefined>(undefined);\n\nexport function InternalAttachmentProvider({\n value,\n children,\n}: {\n value: AttachmentContextValue;\n children?: ReactNode;\n}): ReactElement {\n return createElement(AttachmentContext.Provider, { value }, children);\n}\n\nexport function useAttachment(): AttachmentContextValue {\n const value = useContext(AttachmentContext);\n if (value === undefined) {\n throw new Error(\"Attachment primitives must be used inside Attachment.Root.\");\n }\n return value;\n}\n\nexport function useOptionalAttachment(): AttachmentContextValue | undefined {\n return useContext(AttachmentContext);\n}\n","import type { UseChatResult } from \"@anvia/react\";\nimport { createContext, createElement, type ReactElement, type ReactNode, useContext } from \"react\";\n\nexport type ChatController<TEvent = unknown> = UseChatResult<TEvent>;\n\nexport type ChatProviderProps<TEvent = unknown> = {\n controller: ChatController<TEvent>;\n children?: ReactNode;\n};\n\nconst ChatContext = createContext<ChatController | undefined>(undefined);\n\nexport function ChatProvider<TEvent = unknown>({\n controller,\n children,\n}: ChatProviderProps<TEvent>): ReactElement {\n return createElement(ChatContext.Provider, { value: controller as ChatController }, children);\n}\n\nexport function useChatContext<TEvent = unknown>(): ChatController<TEvent> {\n const value = useContext(ChatContext);\n if (value === undefined) {\n throw new Error(\"Anvia chat primitives must be used inside ChatProvider.\");\n }\n return value as ChatController<TEvent>;\n}\n\nexport function useHumanInput(): ChatController[\"humanInput\"] {\n return useChatContext().humanInput;\n}\n","import type { UseCompletionResult } from \"@anvia/react\";\nimport { createContext, createElement, type ReactElement, type ReactNode, useContext } from \"react\";\n\nexport type CompletionController<TEvent = unknown> = UseCompletionResult<TEvent>;\n\nexport type CompletionProviderProps<TEvent = unknown> = {\n controller: CompletionController<TEvent>;\n children?: ReactNode;\n};\n\nconst CompletionContext = createContext<CompletionController | undefined>(undefined);\n\nexport function CompletionProvider<TEvent = unknown>({\n controller,\n children,\n}: CompletionProviderProps<TEvent>): ReactElement {\n return createElement(\n CompletionContext.Provider,\n { value: controller as CompletionController },\n children,\n );\n}\n\nexport function useCompletionContext<TEvent = unknown>(): CompletionController<TEvent> {\n const value = useContext(CompletionContext);\n if (value === undefined) {\n throw new Error(\"Anvia completion primitives must be used inside CompletionProvider.\");\n }\n return value as CompletionController<TEvent>;\n}\n","import { createContext, createElement, type ReactElement, type ReactNode, useContext } from \"react\";\n\nimport type { CompletionController } from \"./completion\";\n\nexport type CompletionInputContextValue = {\n input: string;\n setInput(input: string): void;\n submit(): Promise<void>;\n stop(): void;\n status: CompletionController[\"status\"];\n canSubmit: boolean;\n canStop: boolean;\n};\n\nconst CompletionInputContext = createContext<CompletionInputContextValue | undefined>(undefined);\n\nexport function InternalCompletionInputProvider({\n value,\n children,\n}: {\n value: CompletionInputContextValue;\n children?: ReactNode;\n}): ReactElement {\n return createElement(CompletionInputContext.Provider, { value }, children);\n}\n\nexport function useCompletionInput(): CompletionInputContextValue {\n const value = useContext(CompletionInputContext);\n if (value === undefined) {\n throw new Error(\"Completion input primitives must be used inside Completion.Form.\");\n }\n return value;\n}\n","import type { CreateUIAttachment, UIAttachment } from \"@anvia/react\";\nimport { createContext, createElement, type ReactElement, type ReactNode, useContext } from \"react\";\nimport type { ChatController } from \"./chat\";\n\nexport type ComposerAttachmentInput = File | CreateUIAttachment;\nexport type ComposerAttachmentsUpdate =\n | UIAttachment[]\n | ((attachments: UIAttachment[]) => UIAttachment[]);\nexport type ComposerQuote = {\n text: string;\n messageId: string;\n};\n\nexport type ComposerContextValue = {\n input: string;\n setInput(input: string): void;\n attachments: UIAttachment[];\n setAttachments(update: ComposerAttachmentsUpdate): void;\n addAttachment(attachment: ComposerAttachmentInput): Promise<void>;\n removeAttachment(id: string): void;\n clearAttachments(): void;\n quote?: ComposerQuote | undefined;\n setQuote(quote: ComposerQuote | undefined): void;\n clearQuote(): void;\n submit(): Promise<void>;\n stop(): void;\n status: ChatController[\"status\"];\n canSubmit: boolean;\n canStop: boolean;\n};\n\nconst ComposerContext = createContext<ComposerContextValue | undefined>(undefined);\n\nexport function InternalComposerProvider({\n value,\n children,\n}: {\n value: ComposerContextValue;\n children?: ReactNode;\n}): ReactElement {\n return createElement(ComposerContext.Provider, { value }, children);\n}\n\nexport function useComposer(): ComposerContextValue {\n const value = useContext(ComposerContext);\n if (value === undefined) {\n throw new Error(\"Composer primitives must be used inside Composer.Root.\");\n }\n return value;\n}\n","import type {\n ToolApproval,\n ToolQuestion,\n ToolQuestionAnswer,\n ToolQuestionPrompt,\n} from \"@anvia/react\";\nimport {\n createContext,\n createElement,\n type ReactElement,\n type ReactNode,\n useContext,\n useMemo,\n useState,\n} from \"react\";\n\nexport type ApprovalContextValue = {\n approval: ToolApproval;\n reason: string;\n setReason(reason: string): void;\n};\n\nexport type QuestionContextValue = {\n question: ToolQuestion;\n answers: Record<string, ToolQuestionAnswer>;\n setAnswer(prompt: ToolQuestionPrompt, answer: ToolQuestionAnswer): void;\n};\n\nexport type QuestionPromptContextValue = {\n prompt: ToolQuestionPrompt;\n};\n\nconst ApprovalContext = createContext<ApprovalContextValue | undefined>(undefined);\nconst QuestionContext = createContext<QuestionContextValue | undefined>(undefined);\nconst QuestionPromptContext = createContext<QuestionPromptContextValue | undefined>(undefined);\n\nexport function InternalApprovalProvider({\n approval,\n children,\n}: {\n approval: ToolApproval;\n children?: ReactNode;\n}): ReactElement {\n const [reason, setReason] = useState(\"\");\n const value = useMemo<ApprovalContextValue>(\n () => ({ approval, reason, setReason }),\n [approval, reason],\n );\n\n return createElement(ApprovalContext.Provider, { value }, children);\n}\n\nexport function InternalQuestionProvider({\n value,\n children,\n}: {\n value: QuestionContextValue;\n children?: ReactNode;\n}): ReactElement {\n return createElement(QuestionContext.Provider, { value }, children);\n}\n\nexport function InternalQuestionPromptProvider({\n prompt,\n children,\n}: {\n prompt: ToolQuestionPrompt;\n children?: ReactNode;\n}): ReactElement {\n return createElement(QuestionPromptContext.Provider, { value: { prompt } }, children);\n}\n\nexport function useApproval(): ApprovalContextValue {\n const value = useContext(ApprovalContext);\n if (value === undefined) {\n throw new Error(\"Approval primitives must be used inside HumanInput.Approval.\");\n }\n return value;\n}\n\nexport function useQuestion(): QuestionContextValue {\n const value = useContext(QuestionContext);\n if (value === undefined) {\n throw new Error(\"Question primitives must be used inside HumanInput.Question.\");\n }\n return value;\n}\n\nexport function useQuestionPrompt(): QuestionPromptContextValue {\n const value = useContext(QuestionPromptContext);\n if (value === undefined) {\n throw new Error(\"Question choice primitives must be used inside HumanInput.QuestionPrompt.\");\n }\n return value;\n}\n","import type { UIAttachment } from \"@anvia/react\";\nimport { createContext, createElement, type ReactElement, type ReactNode, useContext } from \"react\";\n\nexport type ImageContextValue = {\n attachment: UIAttachment;\n src?: string;\n name?: string;\n mediaType?: string;\n isImage: boolean;\n zoomOpen: boolean;\n setZoomOpen(open: boolean): void;\n};\n\nconst ImageContext = createContext<ImageContextValue | undefined>(undefined);\n\nexport function InternalImageProvider({\n value,\n children,\n}: {\n value: ImageContextValue;\n children?: ReactNode;\n}): ReactElement {\n return createElement(ImageContext.Provider, { value }, children);\n}\n\nexport function useImage(): ImageContextValue {\n const value = useContext(ImageContext);\n if (value === undefined) {\n throw new Error(\"Image primitives must be used inside Image.Root.\");\n }\n return value;\n}\n","import type { UIMessage, UIMessagePart } from \"@anvia/react\";\nimport { createContext, createElement, type ReactElement, type ReactNode, useContext } from \"react\";\n\nexport type MessageContextValue = {\n message: UIMessage;\n};\n\nexport type MessagePartContextValue = {\n part: UIMessagePart;\n};\n\nconst MessageContext = createContext<MessageContextValue | undefined>(undefined);\nconst MessagePartContext = createContext<MessagePartContextValue | undefined>(undefined);\n\nexport function InternalMessageProvider({\n message,\n children,\n}: {\n message: UIMessage;\n children?: ReactNode;\n}): ReactElement {\n return createElement(MessageContext.Provider, { value: { message } }, children);\n}\n\nexport function InternalMessagePartProvider({\n part,\n children,\n}: {\n part: UIMessagePart;\n children?: ReactNode;\n}): ReactElement {\n return createElement(MessagePartContext.Provider, { value: { part } }, children);\n}\n\nexport function useMessage(): MessageContextValue {\n const value = useContext(MessageContext);\n if (value === undefined) {\n throw new Error(\"Message primitives must be used inside Message.Root or Thread.Messages.\");\n }\n return value;\n}\n\nexport function useMessagePart(): MessagePartContextValue {\n const value = useContext(MessagePartContext);\n if (value === undefined) {\n throw new Error(\"Message part primitives must be used inside Message.Parts or Message.Part.\");\n }\n return value;\n}\n\nexport function useOptionalMessagePart(): MessagePartContextValue | undefined {\n return useContext(MessagePartContext);\n}\n","import { createContext, createElement, type ReactElement, type ReactNode, useContext } from \"react\";\n\nexport type SelectionToolbarSelection = {\n text: string;\n messageId: string;\n rect: DOMRect;\n};\n\nexport type SelectionToolbarContextValue = {\n selection?: SelectionToolbarSelection;\n quote(): void;\n copy(): Promise<void>;\n clear(): void;\n};\n\nconst SelectionToolbarContext = createContext<SelectionToolbarContextValue | undefined>(undefined);\n\nexport function InternalSelectionToolbarProvider({\n value,\n children,\n}: {\n value: SelectionToolbarContextValue;\n children?: ReactNode;\n}): ReactElement {\n return createElement(SelectionToolbarContext.Provider, { value }, children);\n}\n\nexport function useSelectionToolbar(): SelectionToolbarContextValue {\n const value = useContext(SelectionToolbarContext);\n if (value === undefined) {\n throw new Error(\"SelectionToolbar primitives must be used inside SelectionToolbar.Root.\");\n }\n return value;\n}\n","import {\n createContext,\n createElement,\n type MutableRefObject,\n type ReactElement,\n type ReactNode,\n useContext,\n} from \"react\";\n\nexport type ThreadContextValue = {\n viewportRef: MutableRefObject<HTMLElement | null>;\n atBottom: boolean;\n setAtBottom(atBottom: boolean): void;\n scrollToBottom(behavior?: ScrollBehavior): void;\n};\n\nconst ThreadContext = createContext<ThreadContextValue | undefined>(undefined);\n\nexport function InternalThreadProvider({\n value,\n children,\n}: {\n value: ThreadContextValue;\n children?: ReactNode;\n}): ReactElement {\n return createElement(ThreadContext.Provider, { value }, children);\n}\n\nexport function useThread(): ThreadContextValue {\n const value = useContext(ThreadContext);\n if (value === undefined) {\n throw new Error(\"Thread primitives must be used inside Thread.Root.\");\n }\n return value;\n}\n","import { createContext, createElement, type ReactElement, type ReactNode, useContext } from \"react\";\n\nexport type ThreadListRecord = {\n id: string;\n title?: string;\n createdAt?: string | Date;\n updatedAt?: string | Date;\n archived?: boolean;\n metadata?: unknown;\n};\n\nexport type ThreadListController = {\n threads: ThreadListRecord[];\n activeThreadId?: string;\n status?: \"idle\" | \"loading\" | \"error\";\n error?: unknown;\n createThread(): Promise<void> | void;\n switchThread(threadId: string): Promise<void> | void;\n archiveThread?(threadId: string): Promise<void> | void;\n unarchiveThread?(threadId: string): Promise<void> | void;\n deleteThread?(threadId: string): Promise<void> | void;\n};\n\nexport type ThreadListItemContextValue = {\n thread: ThreadListRecord;\n active: boolean;\n};\n\nexport type ThreadListProviderProps = {\n controller: ThreadListController;\n children?: ReactNode;\n};\n\nconst ThreadListContext = createContext<ThreadListController | undefined>(undefined);\nconst ThreadListItemContext = createContext<ThreadListItemContextValue | undefined>(undefined);\n\nexport function ThreadListProvider({\n controller,\n children,\n}: ThreadListProviderProps): ReactElement {\n return createElement(ThreadListContext.Provider, { value: controller }, children);\n}\n\nexport function InternalThreadListItemProvider({\n value,\n children,\n}: {\n value: ThreadListItemContextValue;\n children?: ReactNode;\n}): ReactElement {\n return createElement(ThreadListItemContext.Provider, { value }, children);\n}\n\nexport function useThreadList(): ThreadListController {\n const value = useContext(ThreadListContext);\n if (value === undefined) {\n throw new Error(\"ThreadList primitives must be used inside ThreadListProvider.\");\n }\n return value;\n}\n\nexport function useThreadListItem(): ThreadListItemContextValue {\n const value = useContext(ThreadListItemContext);\n if (value === undefined) {\n throw new Error(\"ThreadListItem primitives must be used inside ThreadList.Items.\");\n }\n return value;\n}\n"],"mappings":";AACA,SAAS,eAAe,eAAkD,kBAAkB;AAO5F,IAAM,oBAAoB,cAAkD,MAAS;AAE9E,SAAS,2BAA2B;AAAA,EACzC;AAAA,EACA;AACF,GAGiB;AACf,SAAO,cAAc,kBAAkB,UAAU,EAAE,MAAM,GAAG,QAAQ;AACtE;AAEO,SAAS,gBAAwC;AACtD,QAAM,QAAQ,WAAW,iBAAiB;AAC1C,MAAI,UAAU,QAAW;AACvB,UAAM,IAAI,MAAM,4DAA4D;AAAA,EAC9E;AACA,SAAO;AACT;AAEO,SAAS,wBAA4D;AAC1E,SAAO,WAAW,iBAAiB;AACrC;;;AC7BA,SAAS,iBAAAA,gBAAe,iBAAAC,gBAAkD,cAAAC,mBAAkB;AAS5F,IAAM,cAAcF,eAA0C,MAAS;AAEhE,SAAS,aAA+B;AAAA,EAC7C;AAAA,EACA;AACF,GAA4C;AAC1C,SAAOC,eAAc,YAAY,UAAU,EAAE,OAAO,WAA6B,GAAG,QAAQ;AAC9F;AAEO,SAAS,iBAA2D;AACzE,QAAM,QAAQC,YAAW,WAAW;AACp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AQ;AAC5E;AAEO,SAAS,sBAAoD;AAClE,QAAM,QAAQC,YAAW,uBAAuB;AAChD,MAAI,UAAU,QAAW;AACvB,UAAM,IAAI,MAAM,wEAAwE;AAAA,EAC1F;AACA,SAAO;AACT;;;ACjCA;AAAA,EACE,iBAAAC;AAAA,EACA,iBAAAC;AAAA,EAIA,cAAAC;AAAA,OACK;AASP,IAAM,gBAAgBF,gBAA8C,MAAS;AAEtE,SAAS,uBAAuB;AAAA,EACrC;AAAA,EACA;AACF,GAGiB;AACf,SAAOC,gBAAc,cAAc,UAAU,EAAE,MAAM,GAAG,QAAQ;AAClE;AAEO,SAAS,YAAgC;AAC9C,QAAM,QAAQC,aAAW,aAAa;AACtC,MAAI,UAAU,QAAW;AACvB,UAAM,IAAI,MAAM,oDAAoD;AAAA,EACtE;AACA,SAAO;AACT;;;AClCA,SAAS,iBAAAC,iBAAe,iBAAAC,iBAAkD,cAAAC,oBAAkB;AAiC5F,IAAM,oBAAoBF,gBAAgD,MAAS;AACnF,IAAM,wBAAwBA,gBAAsD,MAAS;AAEtF,SAAS,mBAAmB;AAAA,EACjC;AAAA,EACA;AACF,GAA0C;AACxC,SAAOC,gBAAc,kBAAkB,UAAU,EAAE,OAAO,WAAW,GAAG,QAAQ;AAClF;AAEO,SAAS,+BAA+B;AAAA,EAC7C;AAAA,EACA;AACF,GAGiB;AACf,SAAOA,gBAAc,sBAAsB,UAAU,EAAE,MAAM,GAAG,QAAQ;AAC1E;AAEO,SAAS,gBAAsC;AACpD,QAAM,QAAQC,aAAW,iBAAiB;AAC1C,MAAI,UAAU,QAAW;AACvB,UAAM,IAAI,MAAM,+DAA+D;AAAA,EACjF;AACA,SAAO;AACT;AAEO,SAAS,oBAAgD;AAC9D,QAAM,QAAQA,aAAW,qBAAqB;AAC9C,MAAI,UAAU,QAAW;AACvB,UAAM,IAAI,MAAM,iEAAiE;AAAA,EACnF;AACA,SAAO;AACT;","names":["createContext","createElement","useContext","createContext","createElement","useContext","createContext","createElement","useContext","createContext","createElement","useContext","createContext","createElement","useContext","createContext","createElement","useContext","createContext","createElement","useContext","createContext","createElement","useContext","createContext","createElement","useContext","createContext","createElement","useContext"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Attachment
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-QHP4GSRG.js";
|
|
4
4
|
import {
|
|
5
5
|
renderPrimitive
|
|
6
6
|
} from "./chunk-T3ZFZ3NP.js";
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
useMessage,
|
|
12
12
|
useMessagePart,
|
|
13
13
|
useOptionalMessagePart
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-5IHC7D4U.js";
|
|
15
15
|
|
|
16
16
|
// src/message/actions.tsx
|
|
17
17
|
import { forwardRef, useCallback, useEffect, useRef, useState } from "react";
|
|
@@ -481,6 +481,7 @@ var MessageRoot = forwardRef3(function MessageRoot2({ children, ...props }, ref)
|
|
|
481
481
|
...props,
|
|
482
482
|
children: renderedChildren,
|
|
483
483
|
"data-anvia-message": "",
|
|
484
|
+
"data-anvia-message-id": message.id,
|
|
484
485
|
"data-role": message.role
|
|
485
486
|
},
|
|
486
487
|
ref
|
|
@@ -526,4 +527,4 @@ var Message = {
|
|
|
526
527
|
export {
|
|
527
528
|
Message
|
|
528
529
|
};
|
|
529
|
-
//# sourceMappingURL=chunk-
|
|
530
|
+
//# sourceMappingURL=chunk-5Z2IWZ5O.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/message/actions.tsx","../src/format/message.ts","../src/format/value.ts","../src/message/parts.tsx","../src/message/root.tsx","../src/message/index.ts"],"sourcesContent":["import { forwardRef, type MouseEvent, useCallback, useEffect, useRef, useState } from \"react\";\n\nimport { useChatContext, useMessage } from \"../contexts\";\nimport { messageText } from \"../format\";\nimport { type PrimitiveProps, renderPrimitive } from \"../primitives\";\n\nconst MessageActions = forwardRef<HTMLDivElement, PrimitiveProps<\"div\">>(\n function MessageActions(props, ref) {\n return renderPrimitive(\n \"div\",\n {\n ...props,\n children: props.children ?? (\n <>\n <MessageCopy />\n <MessageRegenerate />\n </>\n ),\n \"data-anvia-message-actions\": \"\",\n } as PrimitiveProps<\"div\">,\n ref,\n );\n },\n);\n\ntype MessageCopyState = \"idle\" | \"copied\" | \"error\";\n\nconst MessageCopy = forwardRef<HTMLButtonElement, PrimitiveProps<\"button\">>(function MessageCopy(\n { onClick, ...props },\n ref,\n) {\n const { message } = useMessage();\n const [copyState, setCopyState] = useState<MessageCopyState>(\"idle\");\n const text = messageText(message);\n const previousTextRef = useRef(text);\n const disabled = props.disabled ?? text.length === 0;\n\n useEffect(() => {\n if (previousTextRef.current !== text) {\n previousTextRef.current = text;\n setCopyState(\"idle\");\n }\n }, [text]);\n\n const handleClick = useCallback(\n async (event: MouseEvent<HTMLButtonElement>) => {\n onClick?.(event);\n if (event.defaultPrevented || disabled) {\n return;\n }\n const writeText = navigator.clipboard?.writeText;\n if (writeText === undefined) {\n setCopyState(\"error\");\n return;\n }\n try {\n await writeText.call(navigator.clipboard, text);\n setCopyState(\"copied\");\n } catch {\n setCopyState(\"error\");\n }\n },\n [disabled, onClick, text],\n );\n\n return renderPrimitive(\n \"button\",\n {\n ...props,\n children: props.children ?? \"Copy\",\n disabled,\n onClick: handleClick,\n type: props.type ?? \"button\",\n \"data-anvia-copy\": \"\",\n \"data-state\": copyState,\n } as PrimitiveProps<\"button\">,\n ref,\n );\n});\n\nconst MessageRegenerate = forwardRef<HTMLButtonElement, PrimitiveProps<\"button\">>(\n function MessageRegenerate({ onClick, ...props }, ref) {\n const chat = useChatContext();\n const { message } = useMessage();\n const latestAssistantMessage = [...chat.messages]\n .reverse()\n .find((item) => item.role === \"assistant\");\n const disabled =\n props.disabled ??\n (chat.status === \"streaming\" ||\n message.role !== \"assistant\" ||\n latestAssistantMessage?.id !== message.id);\n\n const handleClick = useCallback(\n (event: MouseEvent<HTMLButtonElement>) => {\n onClick?.(event);\n if (event.defaultPrevented || disabled) {\n return;\n }\n void chat.regenerate();\n },\n [chat, disabled, onClick],\n );\n\n return renderPrimitive(\n \"button\",\n {\n ...props,\n children: props.children ?? \"Regenerate\",\n disabled,\n onClick: handleClick,\n type: props.type ?? \"button\",\n \"data-anvia-regenerate\": \"\",\n \"data-state\": disabled ? \"disabled\" : \"idle\",\n } as PrimitiveProps<\"button\">,\n ref,\n );\n },\n);\n\nexport { MessageActions, MessageCopy, MessageRegenerate };\n","import type { UIMessage, UIMessagePart } from \"@anvia/react\";\n\nexport function messageText(message: UIMessage): string {\n return message.parts\n .filter((part): part is Extract<UIMessagePart, { type: \"text\" }> => part.type === \"text\")\n .map((part) => part.text)\n .join(\"\");\n}\n","export function stringifyValue(value: unknown): string {\n if (value === undefined) {\n return \"\";\n }\n if (typeof value === \"string\") {\n return value;\n }\n try {\n return JSON.stringify(value, null, 2);\n } catch {\n return String(value);\n }\n}\n","import type { UIAttachment, UIMessagePart } from \"@anvia/react\";\nimport { type ComponentPropsWithoutRef, forwardRef, type ReactNode } from \"react\";\nimport ReactMarkdown, {\n type Components,\n type Options as ReactMarkdownOptions,\n} from \"react-markdown\";\nimport remarkGfm from \"remark-gfm\";\n\nimport { Attachment } from \"../attachment/index\";\nimport {\n InternalAttachmentProvider,\n InternalMessagePartProvider,\n useMessage,\n useMessagePart,\n useOptionalMessagePart,\n} from \"../contexts\";\nimport { stringifyValue } from \"../format\";\nimport { type PrimitiveProps, renderPrimitive } from \"../primitives\";\n\ntype MessagePartChildren = ReactNode | ((part: UIMessagePart) => ReactNode);\nexport type MessagePartsFilter = (part: UIMessagePart) => boolean;\nexport type MessageToolPart = Extract<UIMessagePart, { type: \"tool\" }>;\ntype MessageToolChildren = ReactNode | ((part: MessageToolPart) => ReactNode);\nexport type MessageToolRenderWhen = \"always\" | \"pending\" | \"settled\";\nexport type MessageAttachmentPart = Extract<UIMessagePart, { type: \"attachment\" }>;\ntype MessageAttachmentChildren = ReactNode | ((attachment: UIAttachment) => ReactNode);\n\ntype MessagePartsProps = Omit<PrimitiveProps<\"div\">, \"children\"> & {\n children?: MessagePartChildren;\n filter?: MessagePartsFilter;\n};\n\nconst MessageParts = forwardRef<HTMLDivElement, MessagePartsProps>(function MessageParts(\n { children, filter, ...props },\n ref,\n) {\n const { message } = useMessage();\n const parts = filter === undefined ? message.parts : message.parts.filter(filter);\n\n return renderPrimitive(\n \"div\",\n {\n ...props,\n children: parts.map((part) => (\n <InternalMessagePartProvider key={part.id} part={part}>\n {typeof children === \"function\" ? children(part) : (children ?? <MessagePart />)}\n </InternalMessagePartProvider>\n )),\n \"data-anvia-message-parts\": \"\",\n } as PrimitiveProps<\"div\">,\n ref,\n );\n});\n\ntype MessagePartProps = Omit<PrimitiveProps<\"div\">, \"children\"> & {\n children?: MessagePartChildren;\n};\n\nconst MessagePart = forwardRef<HTMLDivElement, MessagePartProps>(function MessagePart(\n { children, ...props },\n ref,\n) {\n const { part } = useMessagePart();\n const renderedChildren =\n typeof children === \"function\" ? children(part) : (children ?? defaultPart(part));\n\n return renderPrimitive(\n \"div\",\n {\n ...props,\n children: renderedChildren,\n \"data-anvia-part\": \"\",\n \"data-part\": part.type,\n } as PrimitiveProps<\"div\">,\n ref,\n );\n});\n\nconst MessageText = forwardRef<HTMLSpanElement, PrimitiveProps<\"span\">>(\n function MessageText(props, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"text\") {\n return null;\n }\n\n return renderPrimitive(\n \"span\",\n {\n ...props,\n children: props.children ?? part.text,\n \"data-anvia-text\": \"\",\n } as PrimitiveProps<\"span\">,\n ref,\n );\n },\n);\n\ntype MessageMarkdownProps = Omit<PrimitiveProps<\"div\">, \"children\"> & {\n children?: string;\n components?: Components;\n remarkPlugins?: ReactMarkdownOptions[\"remarkPlugins\"];\n};\n\nconst MessageMarkdown = forwardRef<HTMLDivElement, MessageMarkdownProps>(function MessageMarkdown(\n { children, components, remarkPlugins, ...props },\n ref,\n) {\n const { message } = useMessage();\n const partContext = useOptionalMessagePart();\n const part = partContext?.part;\n if (part !== undefined && part.type !== \"text\") {\n return null;\n }\n\n const markdown =\n children ??\n (part?.type === \"text\"\n ? part.text\n : message.parts.flatMap((item) => (item.type === \"text\" ? [item.text] : [])).join(\"\\n\\n\"));\n\n return renderPrimitive(\n \"div\",\n {\n ...props,\n children: (\n <ReactMarkdown\n components={{ code: defaultCodeComponent, pre: defaultPreComponent, ...components }}\n remarkPlugins={remarkPlugins ?? [remarkGfm]}\n >\n {markdown}\n </ReactMarkdown>\n ),\n \"data-anvia-markdown\": \"\",\n } as PrimitiveProps<\"div\">,\n ref,\n );\n});\n\ntype MessageCodeBlockProps = Omit<PrimitiveProps<\"pre\">, \"children\"> & {\n children?: ReactNode;\n code?: string;\n language?: string;\n};\n\nconst MessageCodeBlock = forwardRef<HTMLPreElement, MessageCodeBlockProps>(\n function MessageCodeBlock({ children, code, language, ...props }, ref) {\n return renderPrimitive(\n \"pre\",\n {\n ...props,\n children: children ?? (\n <code data-anvia-code=\"\" data-language={language}>\n {code ?? \"\"}\n </code>\n ),\n \"data-anvia-code-block\": \"\",\n \"data-language\": language,\n } as PrimitiveProps<\"pre\">,\n ref,\n );\n },\n);\n\nconst MessageReasoning = forwardRef<HTMLDetailsElement, PrimitiveProps<\"details\">>(\n function MessageReasoning(props, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"reasoning\") {\n return null;\n }\n\n return renderPrimitive(\n \"details\",\n {\n ...props,\n children: props.children ?? (\n <>\n <summary>Reasoning</summary>\n <pre>{part.text}</pre>\n </>\n ),\n \"data-anvia-reasoning\": \"\",\n } as PrimitiveProps<\"details\">,\n ref,\n );\n },\n);\n\ntype MessageToolProps = Omit<PrimitiveProps<\"div\">, \"children\"> & {\n children?: MessageToolChildren;\n renderWhen?: MessageToolRenderWhen;\n};\n\nconst MessageTool = forwardRef<HTMLDivElement, MessageToolProps>(function MessageTool(\n { children, renderWhen = \"always\", ...props },\n ref,\n) {\n const { part } = useMessagePart();\n if (part.type !== \"tool\" || !shouldRenderTool(part, renderWhen)) {\n return null;\n }\n const renderedChildren =\n typeof children === \"function\" ? children(part) : (children ?? defaultToolContent());\n\n return renderPrimitive(\n \"div\",\n {\n ...props,\n children: renderedChildren,\n \"data-anvia-tool\": \"\",\n \"data-state\": part.state,\n } as PrimitiveProps<\"div\">,\n ref,\n );\n});\n\nconst MessageToolName = forwardRef<HTMLSpanElement, PrimitiveProps<\"span\">>(\n function MessageToolName(props, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"tool\") {\n return null;\n }\n\n return renderPrimitive(\n \"span\",\n {\n ...props,\n children: props.children ?? part.toolName,\n \"data-anvia-tool-name\": \"\",\n } as PrimitiveProps<\"span\">,\n ref,\n );\n },\n);\n\nconst MessageToolStatus = forwardRef<HTMLSpanElement, PrimitiveProps<\"span\">>(\n function MessageToolStatus(props, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"tool\") {\n return null;\n }\n\n return renderPrimitive(\n \"span\",\n {\n ...props,\n children: props.children ?? toolStateLabel(part.state),\n \"data-anvia-tool-status\": \"\",\n \"data-state\": part.state,\n } as PrimitiveProps<\"span\">,\n ref,\n );\n },\n);\n\nconst MessageToolInput = forwardRef<HTMLPreElement, PrimitiveProps<\"pre\">>(\n function MessageToolInput(props, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"tool\" || part.input === undefined) {\n return null;\n }\n\n return renderPrimitive(\n \"pre\",\n {\n ...props,\n children: props.children ?? stringifyValue(part.input),\n \"data-anvia-tool-input\": \"\",\n } as PrimitiveProps<\"pre\">,\n ref,\n );\n },\n);\n\nconst MessageToolOutput = forwardRef<HTMLPreElement, PrimitiveProps<\"pre\">>(\n function MessageToolOutput(props, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"tool\" || part.output === undefined) {\n return null;\n }\n\n return renderPrimitive(\n \"pre\",\n {\n ...props,\n children: props.children ?? stringifyValue(part.output),\n \"data-anvia-tool-output\": \"\",\n } as PrimitiveProps<\"pre\">,\n ref,\n );\n },\n);\n\nconst MessageToolError = forwardRef<HTMLDivElement, PrimitiveProps<\"div\">>(\n function MessageToolError(props, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"tool\" || part.error === undefined) {\n return null;\n }\n\n return renderPrimitive(\n \"div\",\n {\n ...props,\n children: props.children ?? part.error.message,\n \"data-anvia-tool-error\": \"\",\n role: props.role ?? \"alert\",\n } as PrimitiveProps<\"div\">,\n ref,\n );\n },\n);\n\ntype MessageAttachmentProps = Omit<PrimitiveProps<\"div\">, \"children\"> & {\n children?: MessageAttachmentChildren;\n};\n\nconst MessageAttachment = forwardRef<HTMLDivElement, MessageAttachmentProps>(\n function MessageAttachment({ children, ...props }, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"attachment\") {\n return null;\n }\n const renderedChildren =\n typeof children === \"function\"\n ? children(part.attachment)\n : (children ?? <Attachment.Root />);\n\n return (\n <InternalAttachmentProvider value={{ attachment: part.attachment }}>\n {renderPrimitive(\n \"div\",\n {\n ...props,\n children: renderedChildren,\n \"data-anvia-message-attachment\": \"\",\n } as PrimitiveProps<\"div\">,\n ref,\n )}\n </InternalAttachmentProvider>\n );\n },\n);\n\nconst MessageData = forwardRef<HTMLPreElement, PrimitiveProps<\"pre\">>(\n function MessageData(props, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"data\") {\n return null;\n }\n\n return renderPrimitive(\n \"pre\",\n {\n ...props,\n children: props.children ?? stringifyValue(part.data),\n \"data-anvia-data\": \"\",\n \"data-name\": part.name,\n } as PrimitiveProps<\"pre\">,\n ref,\n );\n },\n);\n\nconst MessageError = forwardRef<HTMLDivElement, PrimitiveProps<\"div\">>(\n function MessageError(props, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"error\") {\n return null;\n }\n\n return renderPrimitive(\n \"div\",\n {\n ...props,\n children: props.children ?? part.error.message,\n \"data-anvia-error\": \"\",\n role: props.role ?? \"alert\",\n } as PrimitiveProps<\"div\">,\n ref,\n );\n },\n);\n\nfunction defaultPart(part: UIMessagePart): ReactNode {\n if (part.type === \"text\") {\n return <MessageText />;\n }\n if (part.type === \"reasoning\") {\n return <MessageReasoning />;\n }\n if (part.type === \"tool\") {\n return <MessageTool />;\n }\n if (part.type === \"attachment\") {\n return <MessageAttachment />;\n }\n if (part.type === \"data\") {\n return <MessageData />;\n }\n return <MessageError />;\n}\n\nfunction defaultToolContent(): ReactNode {\n return (\n <>\n <MessageToolName />\n <MessageToolStatus />\n <MessageToolInput />\n <MessageToolOutput />\n <MessageToolError />\n </>\n );\n}\n\nfunction defaultCodeComponent({\n children,\n className,\n node: _node,\n ...props\n}: ComponentPropsWithoutRef<\"code\"> & { node?: unknown }): ReactNode {\n const language = /language-(\\S+)/.exec(className ?? \"\")?.[1];\n\n return (\n <code\n className={className}\n data-anvia-code=\"\"\n data-anvia-inline-code={language === undefined ? \"\" : undefined}\n data-language={language}\n {...props}\n >\n {children}\n </code>\n );\n}\n\nfunction defaultPreComponent({\n children,\n node: _node,\n ...props\n}: ComponentPropsWithoutRef<\"pre\"> & { node?: unknown }): ReactNode {\n return <MessageCodeBlock {...props}>{children}</MessageCodeBlock>;\n}\n\nfunction shouldRenderTool(part: MessageToolPart, renderWhen: MessageToolRenderWhen): boolean {\n if (renderWhen === \"always\") {\n return true;\n }\n if (renderWhen === \"pending\") {\n return part.state === \"input-streaming\" || part.state === \"input-available\";\n }\n return part.state === \"output-available\" || part.state === \"error\";\n}\n\nfunction toolStateLabel(state: MessageToolPart[\"state\"]): string {\n if (state === \"output-available\") {\n return \"Done\";\n }\n if (state === \"error\") {\n return \"Error\";\n }\n return \"Running\";\n}\n\nexport {\n MessageAttachment,\n MessageCodeBlock,\n MessageData,\n MessageError,\n MessageMarkdown,\n MessagePart,\n MessageParts,\n MessageReasoning,\n MessageText,\n MessageTool,\n MessageToolError,\n MessageToolInput,\n MessageToolName,\n MessageToolOutput,\n MessageToolStatus,\n};\n","import type { UIMessage } from \"@anvia/react\";\nimport { forwardRef, type ReactNode } from \"react\";\n\nimport { useMessage } from \"../contexts\";\nimport { type PrimitiveProps, renderPrimitive } from \"../primitives\";\n\ntype MessageChildren = ReactNode | ((message: UIMessage) => ReactNode);\n\ntype MessageRootProps = Omit<PrimitiveProps<\"article\">, \"children\"> & {\n children?: MessageChildren;\n};\n\nconst MessageRoot = forwardRef<HTMLElement, MessageRootProps>(function MessageRoot(\n { children, ...props },\n ref,\n) {\n const { message } = useMessage();\n const renderedChildren = typeof children === \"function\" ? children(message) : children;\n\n return renderPrimitive(\n \"article\",\n {\n ...props,\n children: renderedChildren,\n \"data-anvia-message\": \"\",\n \"data-role\": message.role,\n } as PrimitiveProps<\"article\">,\n ref,\n );\n});\n\nconst MessageContent = forwardRef<HTMLDivElement, PrimitiveProps<\"div\">>(\n function MessageContent(props, ref) {\n return renderPrimitive(\n \"div\",\n {\n ...props,\n \"data-anvia-message-content\": \"\",\n } as PrimitiveProps<\"div\">,\n ref,\n );\n },\n);\n\nexport { MessageContent, MessageRoot };\n","import { MessageActions, MessageCopy, MessageRegenerate } from \"./actions\";\nimport {\n MessageAttachment,\n MessageCodeBlock,\n MessageData,\n MessageError,\n MessageMarkdown,\n MessagePart,\n MessageParts,\n MessageReasoning,\n MessageText,\n MessageTool,\n MessageToolError,\n MessageToolInput,\n MessageToolName,\n MessageToolOutput,\n MessageToolStatus,\n} from \"./parts\";\nimport { MessageContent, MessageRoot } from \"./root\";\n\nexport const Message = {\n Root: MessageRoot,\n Content: MessageContent,\n Parts: MessageParts,\n Part: MessagePart,\n Text: MessageText,\n Markdown: MessageMarkdown,\n CodeBlock: MessageCodeBlock,\n Reasoning: MessageReasoning,\n Tool: MessageTool,\n ToolName: MessageToolName,\n ToolInput: MessageToolInput,\n ToolOutput: MessageToolOutput,\n ToolError: MessageToolError,\n ToolStatus: MessageToolStatus,\n Attachment: MessageAttachment,\n Data: MessageData,\n Error: MessageError,\n Actions: MessageActions,\n Copy: MessageCopy,\n Regenerate: MessageRegenerate,\n} as const;\n\nexport type { MessageContextValue, MessagePartContextValue } from \"../contexts\";\nexport { useChatContext, useMessage, useMessagePart } from \"../contexts\";\nexport type {\n MessageAttachmentPart,\n MessagePartsFilter,\n MessageToolPart,\n MessageToolRenderWhen,\n} from \"./parts\";\n"],"mappings":";;;;;;;;;;;;;;;;AAAA,SAAS,YAA6B,aAAa,WAAW,QAAQ,gBAAgB;;;ACE/E,SAAS,YAAY,SAA4B;AACtD,SAAO,QAAQ,MACZ,OAAO,CAAC,SAA2D,KAAK,SAAS,MAAM,EACvF,IAAI,CAAC,SAAS,KAAK,IAAI,EACvB,KAAK,EAAE;AACZ;;;ACPO,SAAS,eAAe,OAAwB;AACrD,MAAI,UAAU,QAAW;AACvB,WAAO;AAAA,EACT;AACA,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO;AAAA,EACT;AACA,MAAI;AACF,WAAO,KAAK,UAAU,OAAO,MAAM,CAAC;AAAA,EACtC,QAAQ;AACN,WAAO,OAAO,KAAK;AAAA,EACrB;AACF;;;AFCU,mBACE,KADF;AAPV,IAAM,iBAAiB;AAAA,EACrB,SAASA,gBAAe,OAAO,KAAK;AAClC,WAAO;AAAA,MACL;AAAA,MACA;AAAA,QACE,GAAG;AAAA,QACH,UAAU,MAAM,YACd,iCACE;AAAA,8BAAC,eAAY;AAAA,UACb,oBAAC,qBAAkB;AAAA,WACrB;AAAA,QAEF,8BAA8B;AAAA,MAChC;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;AAIA,IAAM,cAAc,WAAwD,SAASC,aACnF,EAAE,SAAS,GAAG,MAAM,GACpB,KACA;AACA,QAAM,EAAE,QAAQ,IAAI,WAAW;AAC/B,QAAM,CAAC,WAAW,YAAY,IAAI,SAA2B,MAAM;AACnE,QAAM,OAAO,YAAY,OAAO;AAChC,QAAM,kBAAkB,OAAO,IAAI;AACnC,QAAM,WAAW,MAAM,YAAY,KAAK,WAAW;AAEnD,YAAU,MAAM;AACd,QAAI,gBAAgB,YAAY,MAAM;AACpC,sBAAgB,UAAU;A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,MAAI,eAAe,WAAW;AAC5B,WAAO,KAAK,UAAU,qBAAqB,KAAK,UAAU;AAAA,EAC5D;AACA,SAAO,KAAK,UAAU,sBAAsB,KAAK,UAAU;AAC7D;AAEA,SAAS,eAAe,OAAyC;AAC/D,MAAI,UAAU,oBAAoB;AAChC,WAAO;AAAA,EACT;AACA,MAAI,UAAU,SAAS;AACrB,WAAO;AAAA,EACT;AACA,SAAO;AACT;;;AC5cA,SAAS,cAAAkB,mBAAkC;AAW3C,IAAM,cAAcC,YAA0C,SAASC,aACrE,EAAE,UAAU,GAAG,MAAM,GACrB,KACA;AACA,QAAM,EAAE,QAAQ,IAAI,WAAW;AAC/B,QAAM,mBAAmB,OAAO,aAAa,aAAa,SAAS,OAAO,IAAI;AAE9E,SAAO;AAAA,IACL;AAAA,IACA;AAAA,MACE,GAAG;AAAA,MACH,UAAU;AAAA,MACV,sBAAsB;AAAA,MACtB,aAAa,QAAQ;AAAA,IACvB;AAAA,IACA;AAAA,EACF;AACF,CAAC;AAED,IAAM,iBAAiBD;AAAA,EACrB,SAASE,gBAAe,OAAO,KAAK;AAClC,WAAO;AAAA,MACL;AAAA,MACA;AAAA,QACE,GAAG;AAAA,QACH,8BAA8B;AAAA,MAChC;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;;;ACtBO,IAAM,UAAU;AAAA,EACrB,MAAM;AAAA,EACN,SAAS;AAAA,EACT,OAAO;AAAA,EACP,MAAM;AAAA,EACN,MAAM;AAAA,EACN,UAAU;AAAA,EACV,WAAW;AAAA,EACX,WAAW;AAAA,EACX,MAAM;AAAA,EACN,UAAU;AAAA,EACV,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,MAAM;AAAA,EACN,OAAO;AAAA,EACP,SAAS;AAAA,EACT,MAAM;AAAA,EACN,YAAY;AACd;","names":["MessageActions","MessageCopy","MessageRegenerate","forwardRef","Fragment","jsx","jsxs","forwardRef","MessageParts","MessagePart","MessageText","MessageMarkdown","MessageCodeBlock","MessageReasoning","MessageTool","MessageToolName","MessageToolStatus","MessageToolInput","MessageToolOutput","MessageToolError","MessageAttachment","MessageData","MessageError","forwardRef","forwardRef","MessageRoot","MessageContent"]}
|
|
1
|
+
{"version":3,"sources":["../src/message/actions.tsx","../src/format/message.ts","../src/format/value.ts","../src/message/parts.tsx","../src/message/root.tsx","../src/message/index.ts"],"sourcesContent":["import { forwardRef, type MouseEvent, useCallback, useEffect, useRef, useState } from \"react\";\n\nimport { useChatContext, useMessage } from \"../contexts\";\nimport { messageText } from \"../format\";\nimport { type PrimitiveProps, renderPrimitive } from \"../primitives\";\n\nconst MessageActions = forwardRef<HTMLDivElement, PrimitiveProps<\"div\">>(\n function MessageActions(props, ref) {\n return renderPrimitive(\n \"div\",\n {\n ...props,\n children: props.children ?? (\n <>\n <MessageCopy />\n <MessageRegenerate />\n </>\n ),\n \"data-anvia-message-actions\": \"\",\n } as PrimitiveProps<\"div\">,\n ref,\n );\n },\n);\n\ntype MessageCopyState = \"idle\" | \"copied\" | \"error\";\n\nconst MessageCopy = forwardRef<HTMLButtonElement, PrimitiveProps<\"button\">>(function MessageCopy(\n { onClick, ...props },\n ref,\n) {\n const { message } = useMessage();\n const [copyState, setCopyState] = useState<MessageCopyState>(\"idle\");\n const text = messageText(message);\n const previousTextRef = useRef(text);\n const disabled = props.disabled ?? text.length === 0;\n\n useEffect(() => {\n if (previousTextRef.current !== text) {\n previousTextRef.current = text;\n setCopyState(\"idle\");\n }\n }, [text]);\n\n const handleClick = useCallback(\n async (event: MouseEvent<HTMLButtonElement>) => {\n onClick?.(event);\n if (event.defaultPrevented || disabled) {\n return;\n }\n const writeText = navigator.clipboard?.writeText;\n if (writeText === undefined) {\n setCopyState(\"error\");\n return;\n }\n try {\n await writeText.call(navigator.clipboard, text);\n setCopyState(\"copied\");\n } catch {\n setCopyState(\"error\");\n }\n },\n [disabled, onClick, text],\n );\n\n return renderPrimitive(\n \"button\",\n {\n ...props,\n children: props.children ?? \"Copy\",\n disabled,\n onClick: handleClick,\n type: props.type ?? \"button\",\n \"data-anvia-copy\": \"\",\n \"data-state\": copyState,\n } as PrimitiveProps<\"button\">,\n ref,\n );\n});\n\nconst MessageRegenerate = forwardRef<HTMLButtonElement, PrimitiveProps<\"button\">>(\n function MessageRegenerate({ onClick, ...props }, ref) {\n const chat = useChatContext();\n const { message } = useMessage();\n const latestAssistantMessage = [...chat.messages]\n .reverse()\n .find((item) => item.role === \"assistant\");\n const disabled =\n props.disabled ??\n (chat.status === \"streaming\" ||\n message.role !== \"assistant\" ||\n latestAssistantMessage?.id !== message.id);\n\n const handleClick = useCallback(\n (event: MouseEvent<HTMLButtonElement>) => {\n onClick?.(event);\n if (event.defaultPrevented || disabled) {\n return;\n }\n void chat.regenerate();\n },\n [chat, disabled, onClick],\n );\n\n return renderPrimitive(\n \"button\",\n {\n ...props,\n children: props.children ?? \"Regenerate\",\n disabled,\n onClick: handleClick,\n type: props.type ?? \"button\",\n \"data-anvia-regenerate\": \"\",\n \"data-state\": disabled ? \"disabled\" : \"idle\",\n } as PrimitiveProps<\"button\">,\n ref,\n );\n },\n);\n\nexport { MessageActions, MessageCopy, MessageRegenerate };\n","import type { UIMessage, UIMessagePart } from \"@anvia/react\";\n\nexport function messageText(message: UIMessage): string {\n return message.parts\n .filter((part): part is Extract<UIMessagePart, { type: \"text\" }> => part.type === \"text\")\n .map((part) => part.text)\n .join(\"\");\n}\n","export function stringifyValue(value: unknown): string {\n if (value === undefined) {\n return \"\";\n }\n if (typeof value === \"string\") {\n return value;\n }\n try {\n return JSON.stringify(value, null, 2);\n } catch {\n return String(value);\n }\n}\n","import type { UIAttachment, UIMessagePart } from \"@anvia/react\";\nimport { type ComponentPropsWithoutRef, forwardRef, type ReactNode } from \"react\";\nimport ReactMarkdown, {\n type Components,\n type Options as ReactMarkdownOptions,\n} from \"react-markdown\";\nimport remarkGfm from \"remark-gfm\";\n\nimport { Attachment } from \"../attachment/index\";\nimport {\n InternalAttachmentProvider,\n InternalMessagePartProvider,\n useMessage,\n useMessagePart,\n useOptionalMessagePart,\n} from \"../contexts\";\nimport { stringifyValue } from \"../format\";\nimport { type PrimitiveProps, renderPrimitive } from \"../primitives\";\n\ntype MessagePartChildren = ReactNode | ((part: UIMessagePart) => ReactNode);\nexport type MessagePartsFilter = (part: UIMessagePart) => boolean;\nexport type MessageToolPart = Extract<UIMessagePart, { type: \"tool\" }>;\ntype MessageToolChildren = ReactNode | ((part: MessageToolPart) => ReactNode);\nexport type MessageToolRenderWhen = \"always\" | \"pending\" | \"settled\";\nexport type MessageAttachmentPart = Extract<UIMessagePart, { type: \"attachment\" }>;\ntype MessageAttachmentChildren = ReactNode | ((attachment: UIAttachment) => ReactNode);\n\ntype MessagePartsProps = Omit<PrimitiveProps<\"div\">, \"children\"> & {\n children?: MessagePartChildren;\n filter?: MessagePartsFilter;\n};\n\nconst MessageParts = forwardRef<HTMLDivElement, MessagePartsProps>(function MessageParts(\n { children, filter, ...props },\n ref,\n) {\n const { message } = useMessage();\n const parts = filter === undefined ? message.parts : message.parts.filter(filter);\n\n return renderPrimitive(\n \"div\",\n {\n ...props,\n children: parts.map((part) => (\n <InternalMessagePartProvider key={part.id} part={part}>\n {typeof children === \"function\" ? children(part) : (children ?? <MessagePart />)}\n </InternalMessagePartProvider>\n )),\n \"data-anvia-message-parts\": \"\",\n } as PrimitiveProps<\"div\">,\n ref,\n );\n});\n\ntype MessagePartProps = Omit<PrimitiveProps<\"div\">, \"children\"> & {\n children?: MessagePartChildren;\n};\n\nconst MessagePart = forwardRef<HTMLDivElement, MessagePartProps>(function MessagePart(\n { children, ...props },\n ref,\n) {\n const { part } = useMessagePart();\n const renderedChildren =\n typeof children === \"function\" ? children(part) : (children ?? defaultPart(part));\n\n return renderPrimitive(\n \"div\",\n {\n ...props,\n children: renderedChildren,\n \"data-anvia-part\": \"\",\n \"data-part\": part.type,\n } as PrimitiveProps<\"div\">,\n ref,\n );\n});\n\nconst MessageText = forwardRef<HTMLSpanElement, PrimitiveProps<\"span\">>(\n function MessageText(props, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"text\") {\n return null;\n }\n\n return renderPrimitive(\n \"span\",\n {\n ...props,\n children: props.children ?? part.text,\n \"data-anvia-text\": \"\",\n } as PrimitiveProps<\"span\">,\n ref,\n );\n },\n);\n\ntype MessageMarkdownProps = Omit<PrimitiveProps<\"div\">, \"children\"> & {\n children?: string;\n components?: Components;\n remarkPlugins?: ReactMarkdownOptions[\"remarkPlugins\"];\n};\n\nconst MessageMarkdown = forwardRef<HTMLDivElement, MessageMarkdownProps>(function MessageMarkdown(\n { children, components, remarkPlugins, ...props },\n ref,\n) {\n const { message } = useMessage();\n const partContext = useOptionalMessagePart();\n const part = partContext?.part;\n if (part !== undefined && part.type !== \"text\") {\n return null;\n }\n\n const markdown =\n children ??\n (part?.type === \"text\"\n ? part.text\n : message.parts.flatMap((item) => (item.type === \"text\" ? [item.text] : [])).join(\"\\n\\n\"));\n\n return renderPrimitive(\n \"div\",\n {\n ...props,\n children: (\n <ReactMarkdown\n components={{ code: defaultCodeComponent, pre: defaultPreComponent, ...components }}\n remarkPlugins={remarkPlugins ?? [remarkGfm]}\n >\n {markdown}\n </ReactMarkdown>\n ),\n \"data-anvia-markdown\": \"\",\n } as PrimitiveProps<\"div\">,\n ref,\n );\n});\n\ntype MessageCodeBlockProps = Omit<PrimitiveProps<\"pre\">, \"children\"> & {\n children?: ReactNode;\n code?: string;\n language?: string;\n};\n\nconst MessageCodeBlock = forwardRef<HTMLPreElement, MessageCodeBlockProps>(\n function MessageCodeBlock({ children, code, language, ...props }, ref) {\n return renderPrimitive(\n \"pre\",\n {\n ...props,\n children: children ?? (\n <code data-anvia-code=\"\" data-language={language}>\n {code ?? \"\"}\n </code>\n ),\n \"data-anvia-code-block\": \"\",\n \"data-language\": language,\n } as PrimitiveProps<\"pre\">,\n ref,\n );\n },\n);\n\nconst MessageReasoning = forwardRef<HTMLDetailsElement, PrimitiveProps<\"details\">>(\n function MessageReasoning(props, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"reasoning\") {\n return null;\n }\n\n return renderPrimitive(\n \"details\",\n {\n ...props,\n children: props.children ?? (\n <>\n <summary>Reasoning</summary>\n <pre>{part.text}</pre>\n </>\n ),\n \"data-anvia-reasoning\": \"\",\n } as PrimitiveProps<\"details\">,\n ref,\n );\n },\n);\n\ntype MessageToolProps = Omit<PrimitiveProps<\"div\">, \"children\"> & {\n children?: MessageToolChildren;\n renderWhen?: MessageToolRenderWhen;\n};\n\nconst MessageTool = forwardRef<HTMLDivElement, MessageToolProps>(function MessageTool(\n { children, renderWhen = \"always\", ...props },\n ref,\n) {\n const { part } = useMessagePart();\n if (part.type !== \"tool\" || !shouldRenderTool(part, renderWhen)) {\n return null;\n }\n const renderedChildren =\n typeof children === \"function\" ? children(part) : (children ?? defaultToolContent());\n\n return renderPrimitive(\n \"div\",\n {\n ...props,\n children: renderedChildren,\n \"data-anvia-tool\": \"\",\n \"data-state\": part.state,\n } as PrimitiveProps<\"div\">,\n ref,\n );\n});\n\nconst MessageToolName = forwardRef<HTMLSpanElement, PrimitiveProps<\"span\">>(\n function MessageToolName(props, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"tool\") {\n return null;\n }\n\n return renderPrimitive(\n \"span\",\n {\n ...props,\n children: props.children ?? part.toolName,\n \"data-anvia-tool-name\": \"\",\n } as PrimitiveProps<\"span\">,\n ref,\n );\n },\n);\n\nconst MessageToolStatus = forwardRef<HTMLSpanElement, PrimitiveProps<\"span\">>(\n function MessageToolStatus(props, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"tool\") {\n return null;\n }\n\n return renderPrimitive(\n \"span\",\n {\n ...props,\n children: props.children ?? toolStateLabel(part.state),\n \"data-anvia-tool-status\": \"\",\n \"data-state\": part.state,\n } as PrimitiveProps<\"span\">,\n ref,\n );\n },\n);\n\nconst MessageToolInput = forwardRef<HTMLPreElement, PrimitiveProps<\"pre\">>(\n function MessageToolInput(props, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"tool\" || part.input === undefined) {\n return null;\n }\n\n return renderPrimitive(\n \"pre\",\n {\n ...props,\n children: props.children ?? stringifyValue(part.input),\n \"data-anvia-tool-input\": \"\",\n } as PrimitiveProps<\"pre\">,\n ref,\n );\n },\n);\n\nconst MessageToolOutput = forwardRef<HTMLPreElement, PrimitiveProps<\"pre\">>(\n function MessageToolOutput(props, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"tool\" || part.output === undefined) {\n return null;\n }\n\n return renderPrimitive(\n \"pre\",\n {\n ...props,\n children: props.children ?? stringifyValue(part.output),\n \"data-anvia-tool-output\": \"\",\n } as PrimitiveProps<\"pre\">,\n ref,\n );\n },\n);\n\nconst MessageToolError = forwardRef<HTMLDivElement, PrimitiveProps<\"div\">>(\n function MessageToolError(props, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"tool\" || part.error === undefined) {\n return null;\n }\n\n return renderPrimitive(\n \"div\",\n {\n ...props,\n children: props.children ?? part.error.message,\n \"data-anvia-tool-error\": \"\",\n role: props.role ?? \"alert\",\n } as PrimitiveProps<\"div\">,\n ref,\n );\n },\n);\n\ntype MessageAttachmentProps = Omit<PrimitiveProps<\"div\">, \"children\"> & {\n children?: MessageAttachmentChildren;\n};\n\nconst MessageAttachment = forwardRef<HTMLDivElement, MessageAttachmentProps>(\n function MessageAttachment({ children, ...props }, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"attachment\") {\n return null;\n }\n const renderedChildren =\n typeof children === \"function\"\n ? children(part.attachment)\n : (children ?? <Attachment.Root />);\n\n return (\n <InternalAttachmentProvider value={{ attachment: part.attachment }}>\n {renderPrimitive(\n \"div\",\n {\n ...props,\n children: renderedChildren,\n \"data-anvia-message-attachment\": \"\",\n } as PrimitiveProps<\"div\">,\n ref,\n )}\n </InternalAttachmentProvider>\n );\n },\n);\n\nconst MessageData = forwardRef<HTMLPreElement, PrimitiveProps<\"pre\">>(\n function MessageData(props, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"data\") {\n return null;\n }\n\n return renderPrimitive(\n \"pre\",\n {\n ...props,\n children: props.children ?? stringifyValue(part.data),\n \"data-anvia-data\": \"\",\n \"data-name\": part.name,\n } as PrimitiveProps<\"pre\">,\n ref,\n );\n },\n);\n\nconst MessageError = forwardRef<HTMLDivElement, PrimitiveProps<\"div\">>(\n function MessageError(props, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"error\") {\n return null;\n }\n\n return renderPrimitive(\n \"div\",\n {\n ...props,\n children: props.children ?? part.error.message,\n \"data-anvia-error\": \"\",\n role: props.role ?? \"alert\",\n } as PrimitiveProps<\"div\">,\n ref,\n );\n },\n);\n\nfunction defaultPart(part: UIMessagePart): ReactNode {\n if (part.type === \"text\") {\n return <MessageText />;\n }\n if (part.type === \"reasoning\") {\n return <MessageReasoning />;\n }\n if (part.type === \"tool\") {\n return <MessageTool />;\n }\n if (part.type === \"attachment\") {\n return <MessageAttachment />;\n }\n if (part.type === \"data\") {\n return <MessageData />;\n }\n return <MessageError />;\n}\n\nfunction defaultToolContent(): ReactNode {\n return (\n <>\n <MessageToolName />\n <MessageToolStatus />\n <MessageToolInput />\n <MessageToolOutput />\n <MessageToolError />\n </>\n );\n}\n\nfunction defaultCodeComponent({\n children,\n className,\n node: _node,\n ...props\n}: ComponentPropsWithoutRef<\"code\"> & { node?: unknown }): ReactNode {\n const language = /language-(\\S+)/.exec(className ?? \"\")?.[1];\n\n return (\n <code\n className={className}\n data-anvia-code=\"\"\n data-anvia-inline-code={language === undefined ? \"\" : undefined}\n data-language={language}\n {...props}\n >\n {children}\n </code>\n );\n}\n\nfunction defaultPreComponent({\n children,\n node: _node,\n ...props\n}: ComponentPropsWithoutRef<\"pre\"> & { node?: unknown }): ReactNode {\n return <MessageCodeBlock {...props}>{children}</MessageCodeBlock>;\n}\n\nfunction shouldRenderTool(part: MessageToolPart, renderWhen: MessageToolRenderWhen): boolean {\n if (renderWhen === \"always\") {\n return true;\n }\n if (renderWhen === \"pending\") {\n return part.state === \"input-streaming\" || part.state === \"input-available\";\n }\n return part.state === \"output-available\" || part.state === \"error\";\n}\n\nfunction toolStateLabel(state: MessageToolPart[\"state\"]): string {\n if (state === \"output-available\") {\n return \"Done\";\n }\n if (state === \"error\") {\n return \"Error\";\n }\n return \"Running\";\n}\n\nexport {\n MessageAttachment,\n MessageCodeBlock,\n MessageData,\n MessageError,\n MessageMarkdown,\n MessagePart,\n MessageParts,\n MessageReasoning,\n MessageText,\n MessageTool,\n MessageToolError,\n MessageToolInput,\n MessageToolName,\n MessageToolOutput,\n MessageToolStatus,\n};\n","import type { UIMessage } from \"@anvia/react\";\nimport { forwardRef, type ReactNode } from \"react\";\n\nimport { useMessage } from \"../contexts\";\nimport { type PrimitiveProps, renderPrimitive } from \"../primitives\";\n\ntype MessageChildren = ReactNode | ((message: UIMessage) => ReactNode);\n\ntype MessageRootProps = Omit<PrimitiveProps<\"article\">, \"children\"> & {\n children?: MessageChildren;\n};\n\nconst MessageRoot = forwardRef<HTMLElement, MessageRootProps>(function MessageRoot(\n { children, ...props },\n ref,\n) {\n const { message } = useMessage();\n const renderedChildren = typeof children === \"function\" ? children(message) : children;\n\n return renderPrimitive(\n \"article\",\n {\n ...props,\n children: renderedChildren,\n \"data-anvia-message\": \"\",\n \"data-anvia-message-id\": message.id,\n \"data-role\": message.role,\n } as PrimitiveProps<\"article\">,\n ref,\n );\n});\n\nconst MessageContent = forwardRef<HTMLDivElement, PrimitiveProps<\"div\">>(\n function MessageContent(props, ref) {\n return renderPrimitive(\n \"div\",\n {\n ...props,\n \"data-anvia-message-content\": \"\",\n } as PrimitiveProps<\"div\">,\n ref,\n );\n },\n);\n\nexport { MessageContent, MessageRoot };\n","import { MessageActions, MessageCopy, MessageRegenerate } from \"./actions\";\nimport {\n MessageAttachment,\n MessageCodeBlock,\n MessageData,\n MessageError,\n MessageMarkdown,\n MessagePart,\n MessageParts,\n MessageReasoning,\n MessageText,\n MessageTool,\n MessageToolError,\n MessageToolInput,\n MessageToolName,\n MessageToolOutput,\n MessageToolStatus,\n} from \"./parts\";\nimport { MessageContent, MessageRoot } from \"./root\";\n\nexport const Message = {\n Root: MessageRoot,\n Content: MessageContent,\n Parts: MessageParts,\n Part: MessagePart,\n Text: MessageText,\n Markdown: MessageMarkdown,\n CodeBlock: MessageCodeBlock,\n Reasoning: MessageReasoning,\n Tool: MessageTool,\n ToolName: MessageToolName,\n ToolInput: MessageToolInput,\n ToolOutput: MessageToolOutput,\n ToolError: MessageToolError,\n ToolStatus: MessageToolStatus,\n Attachment: MessageAttachment,\n Data: MessageData,\n Error: MessageError,\n Actions: MessageActions,\n Copy: MessageCopy,\n Regenerate: MessageRegenerate,\n} as const;\n\nexport type { MessageContextValue, MessagePartContextValue } from \"../contexts\";\nexport { useChatContext, useMessage, useMessagePart } from \"../contexts\";\nexport type {\n MessageAttachmentPart,\n MessagePartsFilter,\n MessageToolPart,\n MessageToolRenderWhen,\n} from \"./parts\";\n"],"mappings":";;;;;;;;;;;;;;;;AAAA,SAAS,YAA6B,aAAa,WAAW,QAAQ,gBAAgB;;;ACE/E,SAAS,YAAY,SAA4B;AACtD,SAAO,QAAQ,MACZ,OAAO,CAAC,SAA2D,KAAK,SAAS,MAAM,EACvF,IAAI,CAAC,SAAS,KAAK,IAAI,EACvB,KAAK,EAAE;AACZ;;;ACPO,SAAS,eAAe,OAAwB;AACrD,MAAI,UAAU,QAAW;AACvB,WAAO;AAAA,EACT;AACA,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO;AAAA,EACT;AACA,MAAI;AACF,WAAO,KAAK,UAAU,OAAO,MAAM,CAAC;AAAA,EACtC,QAAQ;AACN,WAAO,OAAO,KAAK;AAAA,EACrB;AACF;;;AFCU,mBACE,KADF;AAPV,IAAM,iBAAiB;AAAA,EACrB,SAASA,gBAAe,OAAO,KAAK;AAClC,WAAO;AAAA,MACL;AAAA,MACA;AAAA,QACE,GAAG;AAAA,QACH,UAAU,MAAM,YACd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AAA,QACH,8BAA8B;AAAA,MAChC;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;;;ACvBO,IAAM,UAAU;AAAA,EACrB,MAAM;AAAA,EACN,SAAS;AAAA,EACT,OAAO;AAAA,EACP,MAAM;AAAA,EACN,MAAM;AAAA,EACN,UAAU;AAAA,EACV,WAAW;AAAA,EACX,WAAW;AAAA,EACX,MAAM;AAAA,EACN,UAAU;AAAA,EACV,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,MAAM;AAAA,EACN,OAAO;AAAA,EACP,SAAS;AAAA,EACT,MAAM;AAAA,EACN,YAAY;AACd;","names":["MessageActions","MessageCopy","MessageRegenerate","forwardRef","Fragment","jsx","jsxs","forwardRef","MessageParts","MessagePart","MessageText","MessageMarkdown","MessageCodeBlock","MessageReasoning","MessageTool","MessageToolName","MessageToolStatus","MessageToolInput","MessageToolOutput","MessageToolError","MessageAttachment","MessageData","MessageError","forwardRef","forwardRef","MessageRoot","MessageContent"]}
|