@rolder/kit 3.0.0-alpha.85 → 3.0.0-alpha.86

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.
Files changed (40) hide show
  1. package/dist/ai/ui/chat/Message.d.ts +10 -2
  2. package/dist/ai/ui/chat/Message.js +13 -20
  3. package/dist/ai/ui/chat/Root.d.ts +2 -0
  4. package/dist/ai/ui/chat/Root.js +1 -1
  5. package/dist/ai/ui/chat/index.d.ts +6 -8
  6. package/dist/ai/ui/chat/index.js +5 -6
  7. package/dist/ai/ui/chat/messages/Empty.d.ts +4 -0
  8. package/dist/ai/ui/chat/messages/Empty.js +11 -0
  9. package/dist/ai/ui/chat/messages/Loader.d.ts +5 -0
  10. package/dist/ai/ui/chat/{Loader.js → messages/Loader.js} +3 -3
  11. package/dist/ai/ui/chat/messages/Messages.d.ts +2 -0
  12. package/dist/ai/ui/chat/{Messages.js → messages/Messages.js} +14 -5
  13. package/dist/ai/ui/chat/messages/index.d.ts +1 -0
  14. package/dist/ai/ui/chat/messages/index.js +1 -0
  15. package/dist/ai/ui/chat/parts/File.d.ts +6 -0
  16. package/dist/ai/ui/chat/{File.js → parts/File.js} +2 -4
  17. package/dist/ai/ui/chat/parts/TextPart.d.ts +6 -0
  18. package/dist/ai/ui/chat/parts/TextPart.js +21 -0
  19. package/dist/ai/ui/chat/parts/ToolPart.d.ts +9 -0
  20. package/dist/ai/ui/chat/parts/ToolPart.js +26 -0
  21. package/dist/ai/ui/chat/parts/index.d.ts +2 -0
  22. package/dist/ai/ui/chat/parts/index.js +2 -0
  23. package/dist/ai/ui/chat/store/index.d.ts +1 -2
  24. package/dist/ai/ui/chat/store/index.js +1 -2
  25. package/dist/ai/ui/chat/store/messages.d.ts +9 -0
  26. package/dist/ai/ui/chat/store/{messageIds.js → messages.js} +9 -5
  27. package/dist/ai/ui/chat/store/states.d.ts +0 -1
  28. package/dist/ai/ui/chat/store/states.js +1 -2
  29. package/dist/ai/ui/chat/store/useInitChat.js +1 -1
  30. package/package.json +1 -1
  31. package/dist/ai/ui/chat/Empty.d.ts +0 -1
  32. package/dist/ai/ui/chat/Empty.js +0 -21
  33. package/dist/ai/ui/chat/File.d.ts +0 -3
  34. package/dist/ai/ui/chat/Loader.d.ts +0 -2
  35. package/dist/ai/ui/chat/Messages.d.ts +0 -2
  36. package/dist/ai/ui/chat/store/messageIds.d.ts +0 -8
  37. package/dist/ai/ui/chat/store/messagesMap.d.ts +0 -5
  38. package/dist/ai/ui/chat/store/messagesMap.js +0 -15
  39. /package/dist/ai/ui/chat/{FileIcon.d.ts → parts/FileIcon.d.ts} +0 -0
  40. /package/dist/ai/ui/chat/{FileIcon.js → parts/FileIcon.js} +0 -0
@@ -1,3 +1,11 @@
1
- export declare const Message: ({ messageId }: {
1
+ import { type StackProps } from '@mantine/core';
2
+ import type { UIMessage } from 'ai';
3
+ import { type ReactNode } from 'react';
4
+ export interface MessageProps<TMessage extends UIMessage> extends Omit<StackProps, 'children'> {
5
+ children: ({ parts, role, }: {
6
+ parts: TMessage['parts'];
7
+ role: TMessage['role'];
8
+ }) => ReactNode;
2
9
  messageId: string;
3
- }) => import("react/jsx-runtime").JSX.Element | null;
10
+ }
11
+ export declare const Message: <TMessage extends UIMessage>(props: MessageProps<TMessage>) => React.JSX.Element;
@@ -1,23 +1,16 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import { Paper } from "@mantine/core";
3
- import { Streamdown } from "streamdown";
4
- import { getIsStreaming, useChatMessage, useChatMessagePart } from "./store/index.js";
5
- const Message = ({ messageId })=>{
2
+ import { Stack } from "@mantine/core";
3
+ import { memo } from "react";
4
+ import { useChatMessage } from "./store/index.js";
5
+ const Message = /*#__PURE__*/ memo(({ children, messageId, ...props })=>{
6
6
  const message = useChatMessage(messageId);
7
- const part = useChatMessagePart(messageId, 'text');
8
- console.log('Message render', message);
9
- return part?.text ? /*#__PURE__*/ jsx(Paper, {
10
- radius: "md",
11
- px: "md",
12
- py: "sm",
13
- maw: "80%",
14
- ml: 'user' === message.role ? 'auto' : void 0,
15
- bg: 'user' === message.role ? 'var(--mantine-color-default-hover)' : 'var(--mantine-primary-color-light)',
16
- fz: "sm",
17
- children: /*#__PURE__*/ jsx(Streamdown, {
18
- isAnimating: getIsStreaming() && 'assistant' === message.role,
19
- children: part?.text
20
- })
21
- }) : null;
22
- };
7
+ console.log('Message render');
8
+ return /*#__PURE__*/ jsx(Stack, {
9
+ ...props,
10
+ children: 'function' == typeof children ? children({
11
+ parts: message.parts,
12
+ role: message.role
13
+ }) : null
14
+ });
15
+ });
23
16
  export { Message };
@@ -10,6 +10,8 @@ export interface ChatRootProps extends PaperProps {
10
10
  scrollAreaProps?: Omit<ScrollAreaProps, 'children' | 'h'>;
11
11
  withScrollButton?: boolean;
12
12
  stackProps?: Omit<StackProps, 'p'>;
13
+ emptyComponent?: ReactNode;
14
+ loaderComponent?: ReactNode;
13
15
  chatOptions?: UseChatOptions<UIMessage> & ChatInit<UIMessage>;
14
16
  }
15
17
  /**
@@ -1,5 +1,5 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
- import { Messages } from "./Messages.js";
2
+ import { Messages } from "./messages/index.js";
3
3
  import { useInitChat } from "./store/index.js";
4
4
  const ChatInitializer = ({ chatOptions })=>{
5
5
  useInitChat(chatOptions);
@@ -1,13 +1,11 @@
1
1
  export declare const Chat: {
2
2
  Root: ({ chatOptions, ...props }: import("./Root").ChatRootProps) => import("react/jsx-runtime").JSX.Element;
3
- Message: ({ messageId }: {
4
- messageId: string;
5
- }) => import("react/jsx-runtime").JSX.Element | null;
6
- File: ({ messageId }: {
7
- messageId: string;
8
- }) => import("react/jsx-runtime").JSX.Element | null;
9
- Empty: () => import("react/jsx-runtime").JSX.Element | null;
10
- Loader: (props: import("@mantine/core").LoaderProps) => import("react/jsx-runtime").JSX.Element | null;
3
+ Message: <TMessage extends import("ai").UIMessage>(props: import("./Message").MessageProps<TMessage>) => React.JSX.Element;
4
+ TextPart: import("react").MemoExoticComponent<({ part, role }: import("./parts").TextPartProps) => import("react/jsx-runtime").JSX.Element>;
5
+ ToolPart: <TPart extends import("ai").ToolUIPart = {
6
+ type: `tool-${string}`;
7
+ } & import("ai").UIToolInvocation<import("ai").UITool>>(props: import("./parts").ToolPartProps<TPart>) => import("react").ReactNode;
8
+ FilePart: ({ part, messageId }: import("./parts/File").FilePartProps) => import("react/jsx-runtime").JSX.Element | null;
11
9
  };
12
10
  export { ChatInput } from './chatInput';
13
11
  export * from './store';
@@ -1,15 +1,14 @@
1
- import { Empty } from "./Empty.js";
2
- import { File } from "./File.js";
3
- import { Loader } from "./Loader.js";
4
1
  import { Message } from "./Message.js";
2
+ import { TextPart, ToolPart } from "./parts/index.js";
3
+ import { FilePart } from "./parts/File.js";
5
4
  import { Root } from "./Root.js";
6
5
  import { ChatInput } from "./chatInput/index.js";
7
6
  export * from "./store/index.js";
8
7
  const Chat = {
9
8
  Root: Root,
10
9
  Message: Message,
11
- File: File,
12
- Empty: Empty,
13
- Loader: Loader
10
+ TextPart: TextPart,
11
+ ToolPart: ToolPart,
12
+ FilePart: FilePart
14
13
  };
15
14
  export { Chat, ChatInput };
@@ -0,0 +1,4 @@
1
+ import type { ReactNode } from 'react';
2
+ export declare const Empty: ({ emptyComponent }: {
3
+ emptyComponent?: ReactNode;
4
+ }) => string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,11 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { Stack, Text } from "@mantine/core";
3
+ import { getIsEmpty } from "../store/index.js";
4
+ const Empty = ({ emptyComponent })=>getIsEmpty() ? emptyComponent ?? /*#__PURE__*/ jsx(Stack, {
5
+ align: "center",
6
+ gap: 0,
7
+ children: /*#__PURE__*/ jsx(Text, {
8
+ children: "Нет сообщений"
9
+ })
10
+ }) : null;
11
+ export { Empty };
@@ -0,0 +1,5 @@
1
+ import { type LoaderProps } from '@mantine/core';
2
+ import type { ReactNode } from 'react';
3
+ export declare const Loader: ({ loaderComponent, ...props }: LoaderProps & {
4
+ loaderComponent?: ReactNode;
5
+ }) => string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | import("react/jsx-runtime").JSX.Element | null;
@@ -1,10 +1,10 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { Loader } from "@mantine/core";
3
- import { useIsLoading, useIsStreaming } from "./store/index.js";
4
- const Loader_Loader = (props)=>{
3
+ import { useIsLoading, useIsStreaming } from "../store/index.js";
4
+ const Loader_Loader = ({ loaderComponent, ...props })=>{
5
5
  const isLoading = useIsLoading();
6
6
  const isStreaming = useIsStreaming();
7
- return isLoading && !isStreaming ? /*#__PURE__*/ jsx(Loader, {
7
+ return isLoading && !isStreaming ? loaderComponent ?? /*#__PURE__*/ jsx(Loader, {
8
8
  size: 28,
9
9
  type: "dots",
10
10
  ...props
@@ -0,0 +1,2 @@
1
+ import type { ChatRootProps } from '../Root';
2
+ export declare const Messages: ({ children, height, radius, padding, scrollAreaProps, withScrollButton, stackProps, emptyComponent, loaderComponent, ...props }: Omit<ChatRootProps, "chatOptions">) => import("react/jsx-runtime").JSX.Element;
@@ -1,8 +1,10 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { Paper, Stack } from "@mantine/core";
3
- import { ScrollArea } from "../../../ui/index.js";
4
- import { useChatMessageIds } from "./store/index.js";
5
- const Messages = ({ children, height, radius = 'md', padding = 'md', scrollAreaProps, withScrollButton = true, stackProps, ...props })=>{
3
+ import { ScrollArea } from "../../../../ui/index.js";
4
+ import { useChatMessageIds } from "../store/index.js";
5
+ import { Empty } from "./Empty.js";
6
+ import { Loader } from "./Loader.js";
7
+ const Messages = ({ children, height, radius = 'md', padding = 'md', scrollAreaProps, withScrollButton = true, stackProps, emptyComponent, loaderComponent, ...props })=>{
6
8
  const messageIds = useChatMessageIds();
7
9
  console.log('Messages render');
8
10
  return /*#__PURE__*/ jsx(Paper, {
@@ -15,10 +17,17 @@ const Messages = ({ children, height, radius = 'md', padding = 'md', scrollAreaP
15
17
  radius: radius,
16
18
  ...scrollAreaProps,
17
19
  children: [
18
- /*#__PURE__*/ jsx(Stack, {
20
+ /*#__PURE__*/ jsxs(Stack, {
19
21
  p: padding,
20
22
  ...stackProps,
21
- children: 'function' == typeof children ? children(messageIds) : null
23
+ children: [
24
+ messageIds.length ? 'function' == typeof children ? children(messageIds) : null : /*#__PURE__*/ jsx(Empty, {
25
+ emptyComponent: emptyComponent
26
+ }),
27
+ /*#__PURE__*/ jsx(Loader, {
28
+ loaderComponent: loaderComponent
29
+ })
30
+ ]
22
31
  }),
23
32
  withScrollButton && /*#__PURE__*/ jsx(ScrollArea.ScrollButton, {})
24
33
  ]
@@ -0,0 +1 @@
1
+ export * from './Messages';
@@ -0,0 +1 @@
1
+ export * from "./Messages.js";
@@ -0,0 +1,6 @@
1
+ import type { FileUIPart } from 'ai';
2
+ export interface FilePartProps<TPart extends FileUIPart = FileUIPart> {
3
+ part: TPart;
4
+ messageId: string;
5
+ }
6
+ export declare const FilePart: ({ part, messageId }: FilePartProps) => import("react/jsx-runtime").JSX.Element | null;
@@ -1,9 +1,7 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { Image, Paper } from "@mantine/core";
3
3
  import { FileIcon } from "./FileIcon.js";
4
- import { useChatMessagePart } from "./store/index.js";
5
- const File = ({ messageId })=>{
6
- const part = useChatMessagePart(messageId, 'file');
4
+ const FilePart = ({ part, messageId })=>{
7
5
  const textFileType = messageId.split('-')[1];
8
6
  const FileComponent = ()=>{
9
7
  switch(textFileType){
@@ -40,4 +38,4 @@ const File = ({ messageId })=>{
40
38
  children: /*#__PURE__*/ jsx(FileComponent, {})
41
39
  }) : null;
42
40
  };
43
- export { File };
41
+ export { FilePart };
@@ -0,0 +1,6 @@
1
+ import type { TextUIPart, UIMessage } from 'ai';
2
+ export interface TextPartProps {
3
+ part: TextUIPart;
4
+ role: UIMessage['role'];
5
+ }
6
+ export declare const TextPart: import("react").MemoExoticComponent<({ part, role }: TextPartProps) => import("react/jsx-runtime").JSX.Element>;
@@ -0,0 +1,21 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { Paper } from "@mantine/core";
3
+ import { memo } from "react";
4
+ import { Streamdown } from "streamdown";
5
+ const TextPart = /*#__PURE__*/ memo(({ part, role })=>{
6
+ console.log('TextPart render', part.text?.length);
7
+ return /*#__PURE__*/ jsx(Paper, {
8
+ radius: "md",
9
+ px: "md",
10
+ py: "sm",
11
+ maw: "80%",
12
+ ml: 'user' === role ? 'auto' : void 0,
13
+ bg: 'user' === role ? 'var(--mantine-color-default-hover)' : 'var(--mantine-primary-color-light)',
14
+ fz: "sm",
15
+ children: /*#__PURE__*/ jsx(Streamdown, {
16
+ isAnimating: 'streaming' === part.state,
17
+ children: part?.text
18
+ })
19
+ });
20
+ });
21
+ export { TextPart };
@@ -0,0 +1,9 @@
1
+ import type { ToolUIPart } from 'ai';
2
+ import { type ReactNode } from 'react';
3
+ export interface ToolPartProps<TPart extends ToolUIPart = ToolUIPart> {
4
+ children: (toolOutput: NonNullable<TPart['output']>) => ReactNode;
5
+ part: TPart;
6
+ loader?: ReactNode;
7
+ onError?: (error: string) => ReactNode;
8
+ }
9
+ export declare const ToolPart: <TPart extends ToolUIPart = ToolUIPart>(props: ToolPartProps<TPart>) => ReactNode;
@@ -0,0 +1,26 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Loader, Text } from "@mantine/core";
3
+ import { memo } from "react";
4
+ const ToolPart = /*#__PURE__*/ memo(({ children, part, loader, onError })=>{
5
+ console.log('ToolPart render', part.state);
6
+ switch(part.state){
7
+ case 'input-available':
8
+ return loader || /*#__PURE__*/ jsx(Loader, {
9
+ size: 28,
10
+ type: "dots"
11
+ });
12
+ case 'output-available':
13
+ return part.output ? children(part.output) : null;
14
+ case 'output-error':
15
+ return onError ? onError(part.errorText) : /*#__PURE__*/ jsxs(Text, {
16
+ c: "red",
17
+ children: [
18
+ "Ошибка: ",
19
+ part.errorText
20
+ ]
21
+ });
22
+ default:
23
+ return null;
24
+ }
25
+ });
26
+ export { ToolPart };
@@ -0,0 +1,2 @@
1
+ export * from './TextPart';
2
+ export * from './ToolPart';
@@ -0,0 +1,2 @@
1
+ export * from "./TextPart.js";
2
+ export * from "./ToolPart.js";
@@ -1,5 +1,4 @@
1
- export * from './messageIds';
2
- export * from './messagesMap';
1
+ export * from './messages';
3
2
  export * from './send';
4
3
  export * from './states';
5
4
  export * from './useInitChat';
@@ -1,5 +1,4 @@
1
- export * from "./messageIds.js";
2
- export * from "./messagesMap.js";
1
+ export * from "./messages.js";
3
2
  export * from "./send.js";
4
3
  export * from "./states.js";
5
4
  export * from "./useInitChat.js";
@@ -0,0 +1,9 @@
1
+ import type { UIMessage } from 'ai';
2
+ export declare const $chatMessageIds: import("nanostores").PreinitializedWritableAtom<string[]> & object;
3
+ export declare const useChatMessageIds: () => string[];
4
+ export declare const $chatMessages: import("nanostores").PreinitializedMapStore<Record<string, UIMessage<unknown, import("ai").UIDataTypes, import("ai").UITools>>> & object;
5
+ export declare const getChatMessage: <TMessage extends UIMessage>(messageId: string) => TMessage | undefined;
6
+ export declare const useChatMessage: <TMessage extends UIMessage>(messageId: string) => TMessage;
7
+ export declare const addChatMessage: <TMessage extends UIMessage>(newMessage: TMessage) => void;
8
+ export declare const setChatMessages: <TMessage extends UIMessage>(messages: TMessage[]) => void;
9
+ export declare const getIsEmpty: () => boolean;
@@ -1,13 +1,18 @@
1
1
  import { useStore } from "@nanostores/react";
2
- import { atom, computed, onSet } from "nanostores";
3
- import { $chatMessages } from "./messagesMap.js";
2
+ import { atom, computed, map, onSet } from "nanostores";
4
3
  const $chatMessageIds = atom([]);
5
- const getChatMessages = ()=>$chatMessageIds.get().map((id)=>$chatMessages.get()[id]);
6
4
  const useChatMessageIds = ()=>useStore($chatMessageIds);
7
5
  onSet($chatMessageIds, ({ newValue, abort })=>{
8
6
  const currentValue = $chatMessageIds.get();
9
7
  if (currentValue.length === newValue.length && currentValue.every((id, index)=>id === newValue[index])) abort();
10
8
  });
9
+ const $chatMessages = map({});
10
+ const getChatMessage = (messageId)=>$chatMessages.get()[messageId];
11
+ const useChatMessage = (messageId)=>useStore($chatMessages, {
12
+ keys: [
13
+ messageId
14
+ ]
15
+ })[messageId];
11
16
  const addChatMessage = (newMessage)=>{
12
17
  $chatMessageIds.set([
13
18
  ...$chatMessageIds.get(),
@@ -37,5 +42,4 @@ const setChatMessages = (messages)=>{
37
42
  };
38
43
  const $isEmpty = computed($chatMessageIds, (messages)=>0 === messages.length);
39
44
  const getIsEmpty = ()=>$isEmpty.get();
40
- const useIsEmpty = ()=>useStore($isEmpty);
41
- export { $chatMessageIds, addChatMessage, getChatMessages, getIsEmpty, setChatMessages, useChatMessageIds, useIsEmpty };
45
+ export { $chatMessageIds, $chatMessages, addChatMessage, getChatMessage, getIsEmpty, setChatMessages, useChatMessage, useChatMessageIds };
@@ -4,7 +4,6 @@ export declare const setChatStatus: (status: ChatStatus) => void;
4
4
  export declare const useChatStatus: () => ChatStatus;
5
5
  export declare const getIsLoading: () => boolean;
6
6
  export declare const useIsLoading: () => boolean;
7
- export declare const getIsStreaming: () => boolean;
8
7
  export declare const useIsStreaming: () => boolean;
9
8
  export declare const getChatError: () => string | undefined;
10
9
  export declare const setChatError: (error: string | undefined) => void;
@@ -8,10 +8,9 @@ const $isLoading = computed($chatStatus, (status)=>'ready' !== status);
8
8
  const getIsLoading = ()=>$isLoading.get();
9
9
  const useIsLoading = ()=>useStore($isLoading);
10
10
  const $isStreaming = computed($chatStatus, (status)=>'streaming' === status);
11
- const getIsStreaming = ()=>$isStreaming.get();
12
11
  const useIsStreaming = ()=>useStore($isStreaming);
13
12
  const $chatError = atom();
14
13
  const getChatError = ()=>$chatError.get();
15
14
  const setChatError = (error)=>$chatError.set(error);
16
15
  const useChatError = ()=>useStore($chatError);
17
- export { getChatError, getChatStatus, getIsLoading, getIsStreaming, setChatError, setChatStatus, useChatError, useChatStatus, useIsLoading, useIsStreaming };
16
+ export { getChatError, getChatStatus, getIsLoading, setChatError, setChatStatus, useChatError, useChatStatus, useIsLoading, useIsStreaming };
@@ -1,7 +1,7 @@
1
1
  import { useChat } from "@ai-sdk/react";
2
2
  import { notifications } from "@mantine/notifications";
3
3
  import { useEffect } from "react";
4
- import { setChatMessages } from "./messageIds.js";
4
+ import { setChatMessages } from "./messages.js";
5
5
  import { setChatSendMessage } from "./send.js";
6
6
  import { setChatError, setChatStatus } from "./states.js";
7
7
  const useInitChat = (props)=>{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rolder/kit",
3
- "version": "3.0.0-alpha.85",
3
+ "version": "3.0.0-alpha.86",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -1 +0,0 @@
1
- export declare const Empty: () => import("react/jsx-runtime").JSX.Element | null;
@@ -1,21 +0,0 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import { Stack, Text } from "@mantine/core";
3
- import { useIsEmpty } from "./store/index.js";
4
- const Empty = ()=>{
5
- const isEmpty = useIsEmpty();
6
- return isEmpty ? /*#__PURE__*/ jsxs(Stack, {
7
- align: "center",
8
- gap: 0,
9
- children: [
10
- /*#__PURE__*/ jsx(Text, {
11
- children: "Нет сообщений"
12
- }),
13
- /*#__PURE__*/ jsx(Text, {
14
- size: "sm",
15
- c: "dimmed",
16
- children: "Начните общение, чтобы увидеть сообщения здесь"
17
- })
18
- ]
19
- }) : null;
20
- };
21
- export { Empty };
@@ -1,3 +0,0 @@
1
- export declare const File: ({ messageId }: {
2
- messageId: string;
3
- }) => import("react/jsx-runtime").JSX.Element | null;
@@ -1,2 +0,0 @@
1
- import { type LoaderProps } from '@mantine/core';
2
- export declare const Loader: (props: LoaderProps) => import("react/jsx-runtime").JSX.Element | null;
@@ -1,2 +0,0 @@
1
- import type { ChatRootProps } from './Root';
2
- export declare const Messages: ({ children, height, radius, padding, scrollAreaProps, withScrollButton, stackProps, ...props }: Omit<ChatRootProps, "chatOptions">) => import("react/jsx-runtime").JSX.Element;
@@ -1,8 +0,0 @@
1
- import type { UIMessage } from 'ai';
2
- export declare const $chatMessageIds: import("nanostores").PreinitializedWritableAtom<string[]> & object;
3
- export declare const getChatMessages: <T extends UIMessage>() => T[];
4
- export declare const useChatMessageIds: () => string[];
5
- export declare const addChatMessage: (newMessage: UIMessage) => void;
6
- export declare const setChatMessages: <T extends UIMessage>(messages: T[]) => void;
7
- export declare const getIsEmpty: () => boolean;
8
- export declare const useIsEmpty: () => boolean;
@@ -1,5 +0,0 @@
1
- import type { UIDataTypes, UIMessage, UIMessagePart, UITools } from 'ai';
2
- export declare const $chatMessages: import("nanostores").PreinitializedMapStore<Record<string, UIMessage<unknown, UIDataTypes, UITools>>> & object;
3
- export declare const getChatMessage: (messageId: string) => UIMessage<unknown, UIDataTypes, UITools>;
4
- export declare const useChatMessage: <T extends UIMessage>(messageId: string) => T;
5
- export declare const useChatMessagePart: <M extends UIMessage, T extends UIMessagePart<UIDataTypes, UITools>>(messageId: string, type?: T["type"]) => T | undefined;
@@ -1,15 +0,0 @@
1
- import { useStore } from "@nanostores/react";
2
- import { map } from "nanostores";
3
- const $chatMessages = map({});
4
- const getChatMessage = (messageId)=>$chatMessages.get()[messageId];
5
- const useChatMessage = (messageId)=>useStore($chatMessages, {
6
- keys: [
7
- messageId
8
- ]
9
- })[messageId];
10
- const useChatMessagePart = (messageId, type)=>{
11
- const message = useChatMessage(messageId);
12
- const part = message?.parts?.find((i)=>i.type === type);
13
- return part;
14
- };
15
- export { $chatMessages, getChatMessage, useChatMessage, useChatMessagePart };