@rolder/kit 3.0.0-alpha.9 → 3.0.0-alpha.91

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 (217) hide show
  1. package/dist/ai/index.d.ts +2 -0
  2. package/dist/ai/index.js +2 -0
  3. package/dist/ai/ui/chat/Root.d.ts +55 -0
  4. package/dist/ai/ui/chat/Root.js +18 -0
  5. package/dist/ai/ui/chat/chatInput/File.js +71 -0
  6. package/dist/ai/ui/chat/chatInput/FileIcon.js +43 -0
  7. package/dist/ai/ui/chat/chatInput/Root.d.ts +9 -0
  8. package/dist/ai/ui/chat/chatInput/Root.js +24 -0
  9. package/dist/ai/ui/chat/chatInput/Submit.js +23 -0
  10. package/dist/ai/ui/{promptInput → chat/chatInput}/Textarea.js +8 -7
  11. package/dist/ai/ui/{promptInput → chat/chatInput}/index.d.ts +2 -3
  12. package/dist/ai/ui/{promptInput → chat/chatInput}/index.js +2 -2
  13. package/dist/ai/ui/chat/chatInput/store/file.d.ts +8 -0
  14. package/dist/ai/ui/chat/chatInput/store/file.js +32 -0
  15. package/dist/ai/ui/chat/chatInput/store/fileErrorNotificaton.d.ts +2 -0
  16. package/dist/ai/ui/chat/chatInput/store/fileErrorNotificaton.js +21 -0
  17. package/dist/ai/ui/chat/chatInput/store/index.d.ts +2 -0
  18. package/dist/ai/ui/chat/chatInput/store/index.js +2 -0
  19. package/dist/ai/ui/chat/chatInput/store/input.d.ts +13 -0
  20. package/dist/ai/ui/chat/chatInput/store/input.js +81 -0
  21. package/dist/ai/ui/chat/chatInput/store/parseFile.d.ts +2 -0
  22. package/dist/ai/ui/chat/chatInput/store/parseFile.js +23 -0
  23. package/dist/ai/ui/chat/index.d.ts +12 -0
  24. package/dist/ai/ui/chat/index.js +15 -0
  25. package/dist/ai/ui/chat/messages/Empty.d.ts +4 -0
  26. package/dist/ai/ui/chat/messages/Empty.js +11 -0
  27. package/dist/ai/ui/chat/messages/Loader.d.ts +5 -0
  28. package/dist/ai/ui/chat/messages/Loader.js +12 -0
  29. package/dist/ai/ui/chat/messages/Message.d.ts +8 -0
  30. package/dist/ai/ui/chat/messages/Message.js +22 -0
  31. package/dist/ai/ui/chat/messages/Messages.d.ts +3 -0
  32. package/dist/ai/ui/chat/messages/Messages.js +40 -0
  33. package/dist/ai/ui/chat/messages/index.d.ts +2 -0
  34. package/dist/ai/ui/chat/messages/index.js +2 -0
  35. package/dist/ai/ui/chat/parts/File.d.ts +6 -0
  36. package/dist/ai/ui/{conversation → chat/parts}/File.js +10 -10
  37. package/dist/ai/ui/chat/parts/FileIcon.js +43 -0
  38. package/dist/ai/ui/chat/parts/PartPaper.d.ts +8 -0
  39. package/dist/ai/ui/chat/parts/PartPaper.js +14 -0
  40. package/dist/ai/ui/chat/parts/TextPart.d.ts +6 -0
  41. package/dist/ai/ui/chat/parts/TextPart.js +15 -0
  42. package/dist/ai/ui/chat/parts/ToolExecution.d.ts +7 -0
  43. package/dist/ai/ui/chat/parts/ToolExecution.js +56 -0
  44. package/dist/ai/ui/chat/parts/ToolPart.d.ts +10 -0
  45. package/dist/ai/ui/chat/parts/ToolPart.js +24 -0
  46. package/dist/ai/ui/chat/parts/index.d.ts +3 -0
  47. package/dist/ai/ui/chat/parts/index.js +3 -0
  48. package/dist/ai/ui/chat/store/index.d.ts +4 -0
  49. package/dist/ai/ui/chat/store/index.js +4 -0
  50. package/dist/ai/ui/chat/store/messages.d.ts +12 -0
  51. package/dist/ai/ui/chat/store/messages.js +40 -0
  52. package/dist/ai/ui/chat/store/send.d.ts +14 -0
  53. package/dist/ai/ui/chat/store/send.js +16 -0
  54. package/dist/ai/ui/chat/store/states.d.ts +11 -0
  55. package/dist/ai/ui/chat/store/states.js +20 -0
  56. package/dist/ai/ui/chat/store/useInitChat.d.ts +3 -0
  57. package/dist/ai/ui/chat/store/useInitChat.js +40 -0
  58. package/dist/ai/ui/index.d.ts +1 -0
  59. package/dist/ai/ui/index.js +1 -0
  60. package/dist/ai/utils/index.d.ts +2 -0
  61. package/dist/ai/utils/index.js +2 -0
  62. package/dist/app/AppDefaults.js +1 -1
  63. package/dist/app/DefaultApp.js +1 -1
  64. package/dist/app/cookieColorSchemeManager.js +1 -1
  65. package/dist/app/defaultRequestMiddlewares.d.ts +1 -1
  66. package/dist/app/defaultTheme.d.ts +6 -6
  67. package/dist/app/index.d.ts +4 -0
  68. package/dist/app/index.js +4 -0
  69. package/dist/hooks/index.d.ts +2 -0
  70. package/dist/hooks/index.js +2 -0
  71. package/dist/index.d.ts +5 -26
  72. package/dist/index.js +5 -26
  73. package/dist/styles.css +3 -8
  74. package/dist/tanstackFunctions/cookie/index.d.ts +3 -0
  75. package/dist/tanstackFunctions/cookie/index.js +4 -0
  76. package/dist/{functions → tanstackFunctions/cookie}/setCookie.d.ts +1 -1
  77. package/dist/tanstackFunctions/index.d.ts +3 -0
  78. package/dist/tanstackFunctions/index.js +3 -0
  79. package/dist/tanstackFunctions/s3/getS3Client.d.ts +2 -0
  80. package/dist/tanstackFunctions/s3/getS3Client.js +18 -0
  81. package/dist/tanstackFunctions/s3/getSignedFileUrlFn.d.ts +4 -0
  82. package/dist/tanstackFunctions/s3/getSignedFileUrlFn.js +21 -0
  83. package/dist/tanstackFunctions/s3/index.d.ts +2 -0
  84. package/dist/tanstackFunctions/s3/index.js +2 -0
  85. package/dist/tanstackFunctions/s3/uploadRequest.d.ts +3 -0
  86. package/dist/tanstackFunctions/s3/uploadRequest.js +21 -0
  87. package/dist/{surreal → tanstackFunctions/surreal}/connection.js +5 -1
  88. package/dist/tanstackFunctions/surreal/deafaultCrud.d.ts +2 -0
  89. package/dist/tanstackFunctions/surreal/index.d.ts +4 -0
  90. package/dist/tanstackFunctions/surreal/index.js +4 -0
  91. package/dist/ui/AnimatedChevron.d.ts +3 -4
  92. package/dist/ui/AnimatedChevron.js +6 -25
  93. package/dist/ui/JsonInput.d.ts +1 -1
  94. package/dist/ui/JsonInput.js +1 -1
  95. package/dist/ui/editor/Content.d.ts +2 -2
  96. package/dist/ui/editor/Content.js +2 -2
  97. package/dist/ui/editor/Root.d.ts +7 -1
  98. package/dist/ui/editor/Root.js +42 -5
  99. package/dist/ui/editor/Toolbar.d.ts +3 -2
  100. package/dist/ui/editor/Toolbar.js +7 -25
  101. package/dist/ui/editor/index.d.ts +5 -9
  102. package/dist/ui/editor/index.js +3 -4
  103. package/dist/ui/editor/store.d.ts +6 -0
  104. package/dist/ui/editor/store.js +10 -0
  105. package/dist/ui/error/DefaultError.d.ts +1 -1
  106. package/dist/ui/error/DefaultNotFound.d.ts +1 -1
  107. package/dist/ui/error/Forbidden.d.ts +1 -1
  108. package/dist/ui/form/buttons/CancelButton.d.ts +2 -2
  109. package/dist/ui/form/buttons/CancelButton.js +4 -26
  110. package/dist/ui/form/buttons/SubmitButton.d.ts +2 -2
  111. package/dist/ui/form/buttons/SubmitButton.js +4 -29
  112. package/dist/ui/form/buttons/SubscribeActionIcon.d.ts +2 -2
  113. package/dist/ui/form/buttons/SubscribeButton.d.ts +2 -2
  114. package/dist/ui/form/context.d.ts +55 -55
  115. package/dist/ui/form/context.js +3 -3
  116. package/dist/ui/form/fields/JsonField.d.ts +1 -1
  117. package/dist/ui/form/fields/MultiSelectField.d.ts +1 -1
  118. package/dist/ui/form/fields/NumberField.d.ts +1 -1
  119. package/dist/ui/form/fields/PasswordField.d.ts +2 -0
  120. package/dist/ui/form/fields/{PassowrdField.js → PasswordField.js} +2 -2
  121. package/dist/ui/form/fields/SelectField.d.ts +1 -1
  122. package/dist/ui/form/fields/SwitchField.d.ts +1 -1
  123. package/dist/ui/form/fields/TextField.d.ts +1 -1
  124. package/dist/ui/form/fields/TextPasswordField.d.ts +2 -0
  125. package/dist/ui/form/fields/TextPasswordField.js +29 -0
  126. package/dist/ui/form/fields/TextareaField.d.ts +1 -1
  127. package/dist/ui/form/fields/index.d.ts +2 -2
  128. package/dist/ui/form/fields/index.js +2 -2
  129. package/dist/ui/index.d.ts +9 -0
  130. package/dist/ui/index.js +9 -0
  131. package/dist/ui/saveInput/JsonInput.d.ts +2 -2
  132. package/dist/ui/saveInput/NumberInput.d.ts +2 -2
  133. package/dist/ui/saveInput/SaveInput.d.ts +14 -14
  134. package/dist/ui/saveInput/Select.d.ts +2 -2
  135. package/dist/ui/saveInput/Switch.d.ts +2 -2
  136. package/dist/ui/saveInput/TextInput.d.ts +2 -2
  137. package/dist/ui/saveInput/Textarea.d.ts +2 -2
  138. package/dist/ui/scrollArea/Root.d.ts +7 -0
  139. package/dist/ui/scrollArea/Root.js +42 -0
  140. package/dist/ui/scrollArea/ScrollButton.d.ts +7 -0
  141. package/dist/ui/scrollArea/ScrollButton.js +30 -0
  142. package/dist/ui/scrollArea/index.d.ts +6 -3
  143. package/dist/ui/scrollArea/index.js +7 -3
  144. package/dist/ui/scrollArea/methods.d.ts +4 -0
  145. package/dist/ui/scrollArea/methods.js +32 -0
  146. package/dist/ui/scrollArea/store.d.ts +12 -0
  147. package/dist/ui/scrollArea/store.js +25 -0
  148. package/package.json +73 -68
  149. package/dist/ai/ui/conversation/ConversationContext.d.ts +0 -7
  150. package/dist/ai/ui/conversation/ConversationContext.js +0 -8
  151. package/dist/ai/ui/conversation/ConversationProvider.d.ts +0 -2
  152. package/dist/ai/ui/conversation/ConversationProvider.js +0 -14
  153. package/dist/ai/ui/conversation/Empty.d.ts +0 -1
  154. package/dist/ai/ui/conversation/Empty.js +0 -21
  155. package/dist/ai/ui/conversation/File.d.ts +0 -4
  156. package/dist/ai/ui/conversation/FileIcon.js +0 -225
  157. package/dist/ai/ui/conversation/Loader.d.ts +0 -2
  158. package/dist/ai/ui/conversation/Loader.js +0 -12
  159. package/dist/ai/ui/conversation/Message.d.ts +0 -4
  160. package/dist/ai/ui/conversation/Message.js +0 -25
  161. package/dist/ai/ui/conversation/Root.d.ts +0 -2
  162. package/dist/ai/ui/conversation/Root.js +0 -26
  163. package/dist/ai/ui/conversation/index.d.ts +0 -13
  164. package/dist/ai/ui/conversation/index.js +0 -14
  165. package/dist/ai/ui/conversation/types.d.ts +0 -7
  166. package/dist/ai/ui/conversation/types.js +0 -0
  167. package/dist/ai/ui/conversation/useChatMessage.d.ts +0 -2
  168. package/dist/ai/ui/conversation/useChatMessage.js +0 -12
  169. package/dist/ai/ui/promptInput/File.js +0 -117
  170. package/dist/ai/ui/promptInput/FileIcon.js +0 -225
  171. package/dist/ai/ui/promptInput/PromptInputContext.d.ts +0 -12
  172. package/dist/ai/ui/promptInput/PromptInputContext.js +0 -8
  173. package/dist/ai/ui/promptInput/PromptInputProvider.d.ts +0 -2
  174. package/dist/ai/ui/promptInput/PromptInputProvider.js +0 -50
  175. package/dist/ai/ui/promptInput/Root.d.ts +0 -3
  176. package/dist/ai/ui/promptInput/Root.js +0 -17
  177. package/dist/ai/ui/promptInput/Submit.js +0 -40
  178. package/dist/ai/ui/promptInput/types.d.ts +0 -11
  179. package/dist/ai/ui/promptInput/types.js +0 -0
  180. package/dist/surreal/deafaultCrud.d.ts +0 -2
  181. package/dist/ui/editor/Provider.d.ts +0 -17
  182. package/dist/ui/editor/Provider.js +0 -80
  183. package/dist/ui/editor/types.d.ts +0 -7
  184. package/dist/ui/editor/types.js +0 -0
  185. package/dist/ui/form/fields/PassowrdField.d.ts +0 -2
  186. package/dist/ui/form/fields/TextPassowrdField.d.ts +0 -2
  187. package/dist/ui/form/fields/TextPassowrdField.js +0 -51
  188. package/dist/ui/scrollArea/ScrollArea.d.ts +0 -62
  189. package/dist/ui/scrollArea/ScrollArea.js +0 -30
  190. package/dist/ui/scrollArea/ScrollAreaButton.d.ts +0 -5
  191. package/dist/ui/scrollArea/ScrollAreaButton.js +0 -51
  192. package/dist/ui/scrollArea/ScrollAreaContent.d.ts +0 -6
  193. package/dist/ui/scrollArea/ScrollAreaContent.js +0 -29
  194. package/dist/ui/scrollArea/context.d.ts +0 -28
  195. package/dist/ui/scrollArea/context.js +0 -10
  196. package/dist/ui/scrollArea/types.d.ts +0 -65
  197. package/dist/ui/scrollArea/types.js +0 -0
  198. package/dist/ui/scrollArea/useScrollArea.d.ts +0 -9
  199. package/dist/ui/scrollArea/useScrollArea.js +0 -146
  200. /package/dist/ai/ui/{promptInput → chat/chatInput}/File.d.ts +0 -0
  201. /package/dist/ai/ui/{conversation → chat/chatInput}/FileIcon.d.ts +0 -0
  202. /package/dist/ai/ui/{promptInput → chat/chatInput}/Footer.d.ts +0 -0
  203. /package/dist/ai/ui/{promptInput → chat/chatInput}/Footer.js +0 -0
  204. /package/dist/ai/ui/{promptInput → chat/chatInput}/Submit.d.ts +0 -0
  205. /package/dist/ai/ui/{promptInput → chat/chatInput}/Textarea.d.ts +0 -0
  206. /package/dist/ai/ui/{promptInput → chat/parts}/FileIcon.d.ts +0 -0
  207. /package/dist/{functions → tanstackFunctions/cookie}/getCookie.d.ts +0 -0
  208. /package/dist/{functions → tanstackFunctions/cookie}/getCookie.js +0 -0
  209. /package/dist/{functions → tanstackFunctions/cookie}/setCookie.js +0 -0
  210. /package/dist/{functions → tanstackFunctions/cookie}/setCookies.d.ts +0 -0
  211. /package/dist/{functions → tanstackFunctions/cookie}/setCookies.js +0 -0
  212. /package/dist/{surreal → tanstackFunctions/surreal}/connection.d.ts +0 -0
  213. /package/dist/{surreal → tanstackFunctions/surreal}/deafaultCrud.js +0 -0
  214. /package/dist/{surreal → tanstackFunctions/surreal}/deserialize.d.ts +0 -0
  215. /package/dist/{surreal → tanstackFunctions/surreal}/deserialize.js +0 -0
  216. /package/dist/{surreal → tanstackFunctions/surreal}/encryption.d.ts +0 -0
  217. /package/dist/{surreal → tanstackFunctions/surreal}/encryption.js +0 -0
@@ -0,0 +1,40 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Paper, Stack } from "@mantine/core";
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
+ import { Message } from "./Message.js";
8
+ const Messages = ({ children, height, radius = 'md', padding = 'md', scrollAreaProps, withScrollButton = true, stackProps, emptyComponent, loaderComponent, ...props })=>{
9
+ const messageIds = useChatMessageIds();
10
+ return /*#__PURE__*/ jsx(Paper, {
11
+ withBorder: true,
12
+ radius: radius,
13
+ ...props,
14
+ children: /*#__PURE__*/ jsxs(ScrollArea.Root, {
15
+ autoScroll: true,
16
+ height: height,
17
+ radius: radius,
18
+ ...scrollAreaProps,
19
+ children: [
20
+ /*#__PURE__*/ jsxs(Stack, {
21
+ p: padding,
22
+ ...stackProps,
23
+ children: [
24
+ messageIds.length ? messageIds.map((messageId)=>/*#__PURE__*/ jsx(Message, {
25
+ messageId: messageId,
26
+ children: children
27
+ }, messageId)) : /*#__PURE__*/ jsx(Empty, {
28
+ emptyComponent: emptyComponent
29
+ }),
30
+ /*#__PURE__*/ jsx(Loader, {
31
+ loaderComponent: loaderComponent
32
+ })
33
+ ]
34
+ }),
35
+ withScrollButton && /*#__PURE__*/ jsx(ScrollArea.ScrollButton, {})
36
+ ]
37
+ })
38
+ });
39
+ };
40
+ export { Messages };
@@ -0,0 +1,2 @@
1
+ export * from './Message';
2
+ export * from './Messages';
@@ -0,0 +1,2 @@
1
+ export * from "./Message.js";
2
+ 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: import("react").MemoExoticComponent<({ part, messageId }: FilePartProps) => import("react/jsx-runtime").JSX.Element | null>;
@@ -1,10 +1,9 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { Image, Paper } from "@mantine/core";
3
+ import { memo } from "react";
3
4
  import { FileIcon } from "./FileIcon.js";
4
- const File = ({ message })=>{
5
- const textFileType = message.id.split('-')[1];
6
- const fileParts = message.parts?.filter((i)=>'file' === i.type);
7
- const lastFilePart = fileParts[fileParts.length - 1];
5
+ const FilePart = /*#__PURE__*/ memo(({ part, messageId })=>{
6
+ const textFileType = messageId.split('-')[1];
8
7
  const FileComponent = ()=>{
9
8
  switch(textFileType){
10
9
  case 'excel':
@@ -20,17 +19,18 @@ const File = ({ message })=>{
20
19
  mimeType: "powerpoint"
21
20
  });
22
21
  }
23
- if (lastFilePart.mediaType.includes('image/')) return /*#__PURE__*/ jsx(Image, {
22
+ if (!part) return null;
23
+ if (part.mediaType.includes('image/')) return /*#__PURE__*/ jsx(Image, {
24
24
  radius: "md",
25
25
  h: 128,
26
- src: lastFilePart.url,
26
+ src: part.url,
27
27
  alt: "Image Preview"
28
28
  });
29
29
  return /*#__PURE__*/ jsx(FileIcon, {
30
- mimeType: lastFilePart.mediaType
30
+ mimeType: part.mediaType
31
31
  });
32
32
  };
33
- return textFileType || lastFilePart ? /*#__PURE__*/ jsx(Paper, {
33
+ return textFileType || part ? /*#__PURE__*/ jsx(Paper, {
34
34
  radius: "md",
35
35
  px: "md",
36
36
  py: "sm",
@@ -38,5 +38,5 @@ const File = ({ message })=>{
38
38
  bg: "var(--mantine-color-default-hover)",
39
39
  children: /*#__PURE__*/ jsx(FileComponent, {})
40
40
  }) : null;
41
- };
42
- export { File };
41
+ });
42
+ export { FilePart };
@@ -0,0 +1,43 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { IconFile, IconFileTypeDoc, IconFileTypePdf, IconFileTypePpt, IconFileTypeXls, IconPhoto } from "@tabler/icons-react";
3
+ const FileIcon = ({ mimeType })=>{
4
+ switch(true){
5
+ case mimeType.includes('image/'):
6
+ return /*#__PURE__*/ jsx(IconPhoto, {
7
+ size: 36,
8
+ stroke: 1.5,
9
+ color: "var(--mantine-color-text)"
10
+ });
11
+ case mimeType.includes('application/pdf'):
12
+ return /*#__PURE__*/ jsx(IconFileTypePdf, {
13
+ size: 36,
14
+ stroke: 1.5,
15
+ color: "var(--mantine-color-text)"
16
+ });
17
+ case 'word' === mimeType:
18
+ return /*#__PURE__*/ jsx(IconFileTypeDoc, {
19
+ size: 36,
20
+ stroke: 1.5,
21
+ color: "var(--mantine-color-text)"
22
+ });
23
+ case 'excel' === mimeType:
24
+ return /*#__PURE__*/ jsx(IconFileTypeXls, {
25
+ size: 36,
26
+ stroke: 1.5,
27
+ color: "var(--mantine-color-text)"
28
+ });
29
+ case 'powerpoint' === mimeType:
30
+ return /*#__PURE__*/ jsx(IconFileTypePpt, {
31
+ size: 36,
32
+ stroke: 1.5,
33
+ color: "var(--mantine-color-text)"
34
+ });
35
+ default:
36
+ return /*#__PURE__*/ jsx(IconFile, {
37
+ size: 36,
38
+ stroke: 1.5,
39
+ color: "var(--mantine-color-text)"
40
+ });
41
+ }
42
+ };
43
+ export { FileIcon };
@@ -0,0 +1,8 @@
1
+ import { type PaperProps } from '@mantine/core';
2
+ import type { UIMessage } from 'ai';
3
+ import type { ReactNode } from 'react';
4
+ export interface PartPaperProps extends PaperProps {
5
+ children: ReactNode;
6
+ chatRole: UIMessage['role'];
7
+ }
8
+ export declare const PartPaper: ({ children, chatRole, ...props }: PartPaperProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,14 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { Paper } from "@mantine/core";
3
+ const PartPaper = ({ children, chatRole, ...props })=>/*#__PURE__*/ jsx(Paper, {
4
+ radius: "md",
5
+ px: "md",
6
+ py: "sm",
7
+ maw: "80%",
8
+ ml: 'user' === chatRole ? 'auto' : void 0,
9
+ bg: 'user' === chatRole ? 'var(--mantine-color-default-hover)' : 'var(--mantine-primary-color-light)',
10
+ fz: "sm",
11
+ ...props,
12
+ children: children
13
+ });
14
+ export { PartPaper };
@@ -0,0 +1,6 @@
1
+ import type { TextUIPart } from 'ai';
2
+ export interface TextPartProps {
3
+ messageId: string;
4
+ part: TextUIPart;
5
+ }
6
+ export declare const TextPart: ({ messageId, part }: TextPartProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,15 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { Streamdown } from "streamdown";
3
+ import { getChatMessage } from "../store/index.js";
4
+ import { PartPaper } from "./PartPaper.js";
5
+ const TextPart = ({ messageId, part })=>{
6
+ const message = getChatMessage(messageId);
7
+ return /*#__PURE__*/ jsx(PartPaper, {
8
+ chatRole: message.role,
9
+ children: /*#__PURE__*/ jsx(Streamdown, {
10
+ isAnimating: 'streaming' === part.state,
11
+ children: part.text
12
+ })
13
+ });
14
+ };
15
+ export { TextPart };
@@ -0,0 +1,7 @@
1
+ import type { ToolUIPart } from 'ai';
2
+ import type { ReactNode } from 'react';
3
+ export interface ToolExecutionProps {
4
+ part: ToolUIPart;
5
+ onError?: (error: string) => ReactNode;
6
+ }
7
+ export declare const ToolExecution: ({ part, onError }: ToolExecutionProps) => 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 | undefined;
@@ -0,0 +1,56 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Group, Loader, Text } from "@mantine/core";
3
+ import { IconCheck } from "@tabler/icons-react";
4
+ import { setIsLoading } from "../store/index.js";
5
+ const ToolExecution = ({ part, onError })=>{
6
+ switch(part.state){
7
+ case 'input-available':
8
+ setIsLoading(false);
9
+ return /*#__PURE__*/ jsxs(Group, {
10
+ gap: "xs",
11
+ children: [
12
+ /*#__PURE__*/ jsx(Loader, {
13
+ size: 28,
14
+ type: "dots"
15
+ }),
16
+ /*#__PURE__*/ jsxs(Text, {
17
+ size: "sm",
18
+ children: [
19
+ 'Запускаю "',
20
+ part.title,
21
+ '"...'
22
+ ]
23
+ })
24
+ ]
25
+ });
26
+ case 'output-available':
27
+ return /*#__PURE__*/ jsxs(Group, {
28
+ gap: "xs",
29
+ children: [
30
+ /*#__PURE__*/ jsx(IconCheck, {
31
+ size: 28,
32
+ color: "green"
33
+ }),
34
+ /*#__PURE__*/ jsxs(Text, {
35
+ size: "sm",
36
+ children: [
37
+ '"',
38
+ part.title,
39
+ '" выполнен'
40
+ ]
41
+ })
42
+ ]
43
+ });
44
+ case 'output-error':
45
+ return onError ? onError(part.errorText) : /*#__PURE__*/ jsxs(Text, {
46
+ c: "red",
47
+ children: [
48
+ "Ошибка: ",
49
+ part.errorText
50
+ ]
51
+ });
52
+ default:
53
+ return null;
54
+ }
55
+ };
56
+ export { ToolExecution };
@@ -0,0 +1,10 @@
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
+ withLoader?: boolean;
7
+ loader?: ReactNode;
8
+ onError?: (error: string) => ReactNode;
9
+ }
10
+ export declare const ToolPart: <TPart extends ToolUIPart = ToolUIPart>({ children, part, withLoader, loader, onError, }: ToolPartProps<TPart>) => 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 | undefined;
@@ -0,0 +1,24 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Loader, Text } from "@mantine/core";
3
+ const ToolPart = ({ children, part, withLoader, loader = /*#__PURE__*/ jsx(Loader, {
4
+ size: 28,
5
+ type: "dots"
6
+ }), onError })=>{
7
+ switch(part.state){
8
+ case 'input-available':
9
+ return withLoader ? loader : null;
10
+ case 'output-available':
11
+ return part.output ? children(part.output) : null;
12
+ case 'output-error':
13
+ return onError ? onError(part.errorText) : /*#__PURE__*/ jsxs(Text, {
14
+ c: "red",
15
+ children: [
16
+ "Ошибка: ",
17
+ part.errorText
18
+ ]
19
+ });
20
+ default:
21
+ return null;
22
+ }
23
+ };
24
+ export { ToolPart };
@@ -0,0 +1,3 @@
1
+ export * from './PartPaper';
2
+ export * from './TextPart';
3
+ export * from './ToolPart';
@@ -0,0 +1,3 @@
1
+ export * from "./PartPaper.js";
2
+ export * from "./TextPart.js";
3
+ export * from "./ToolPart.js";
@@ -0,0 +1,4 @@
1
+ export * from './messages';
2
+ export * from './send';
3
+ export * from './states';
4
+ export * from './useInitChat';
@@ -0,0 +1,4 @@
1
+ export * from "./messages.js";
2
+ export * from "./send.js";
3
+ export * from "./states.js";
4
+ export * from "./useInitChat.js";
@@ -0,0 +1,12 @@
1
+ import type { UIMessage } from 'ai';
2
+ export declare const getChatMessages: () => UIMessage<unknown, import("ai").UIDataTypes, import("ai").UITools>[];
3
+ export declare const getChatMessage: <TMessage extends UIMessage>(messageId: string) => TMessage;
4
+ export declare const setChatMessages: (messages: UIMessage[]) => void;
5
+ export declare const addChatMessage: <TMessage extends UIMessage>(newMessage: TMessage) => void;
6
+ export declare const getChatMessageIds: () => string[];
7
+ export declare const useChatMessageIds: () => string[];
8
+ export type MessagesParts = Record<string, UIMessage['parts']>;
9
+ export declare const getMessagesParts: () => MessagesParts;
10
+ export declare const setMessageParts: (messageId: string, messageParts: UIMessage["parts"]) => void;
11
+ export declare const useMessageParts: <TMessage extends UIMessage>(messageId: string) => TMessage["parts"];
12
+ export declare const getIsEmpty: () => boolean;
@@ -0,0 +1,40 @@
1
+ import { useStore } from "@nanostores/react";
2
+ import { atom, computed, map } from "nanostores";
3
+ const $chatMessages = atom([]);
4
+ const getChatMessages = ()=>$chatMessages.get();
5
+ const getChatMessage = (messageId)=>$chatMessages.get().find((msg)=>msg.id === messageId);
6
+ const setChatMessages = (messages)=>{
7
+ const newIds = messages.map((msg)=>msg.id);
8
+ if (getChatMessageIds().length !== newIds.length) {
9
+ $chatMessages.set(messages);
10
+ $chatMessageIds.set(newIds);
11
+ }
12
+ messages.forEach((msg)=>{
13
+ setMessageParts(msg.id, msg.parts);
14
+ });
15
+ };
16
+ const addChatMessage = (newMessage)=>{
17
+ $chatMessages.set([
18
+ ...getChatMessages(),
19
+ newMessage
20
+ ]);
21
+ $chatMessageIds.set([
22
+ ...getChatMessageIds(),
23
+ newMessage.id
24
+ ]);
25
+ setMessageParts(newMessage.id, newMessage.parts);
26
+ };
27
+ const $chatMessageIds = atom([]);
28
+ const getChatMessageIds = ()=>$chatMessageIds.get();
29
+ const useChatMessageIds = ()=>useStore($chatMessageIds);
30
+ const $messagesParts = map({});
31
+ const getMessagesParts = ()=>$messagesParts.get();
32
+ const setMessageParts = (messageId, messageParts)=>$messagesParts.setKey(messageId, messageParts);
33
+ const useMessageParts = (messageId)=>useStore($messagesParts, {
34
+ keys: [
35
+ messageId
36
+ ]
37
+ })[messageId];
38
+ const $isEmpty = computed($chatMessageIds, (messages)=>0 === messages.length);
39
+ const getIsEmpty = ()=>$isEmpty.get();
40
+ export { addChatMessage, getChatMessage, getChatMessageIds, getChatMessages, getIsEmpty, getMessagesParts, setChatMessages, setMessageParts, useChatMessageIds, useMessageParts };
@@ -0,0 +1,14 @@
1
+ import type { FileUIPart } from 'ai';
2
+ export type SendMessage = ({ text, file }: {
3
+ text: string;
4
+ file?: FileUIPart;
5
+ }, data?: Record<string, unknown>) => Promise<void>;
6
+ type SendSdkMessage = ({ text, files }: {
7
+ text: string;
8
+ files?: FileUIPart[];
9
+ }, { body }: {
10
+ body?: Record<string, unknown>;
11
+ }) => Promise<void>;
12
+ export declare const setChatSendMessage: (sendMessage: SendSdkMessage) => void;
13
+ export declare const sendMessage: SendMessage;
14
+ export {};
@@ -0,0 +1,16 @@
1
+ import { atom } from "nanostores";
2
+ const $chatSendMessage = atom();
3
+ const getChatSendMessage = ()=>$chatSendMessage.get();
4
+ const setChatSendMessage = (sendMessage)=>$chatSendMessage.set(sendMessage);
5
+ const send_sendMessage = async ({ text, file }, data)=>{
6
+ const files = file ? [
7
+ file
8
+ ] : [];
9
+ await getChatSendMessage()?.({
10
+ text,
11
+ files
12
+ }, {
13
+ body: data
14
+ });
15
+ };
16
+ export { send_sendMessage as sendMessage, setChatSendMessage };
@@ -0,0 +1,11 @@
1
+ import type { ChatStatus } from 'ai';
2
+ export declare const getChatStatus: () => ChatStatus;
3
+ export declare const useChatStatus: () => ChatStatus;
4
+ export declare const setChatStatus: (status: ChatStatus) => void;
5
+ export declare const getIsLoading: () => boolean;
6
+ export declare const useIsLoading: () => boolean;
7
+ export declare const setIsLoading: (isLoading: boolean) => void;
8
+ export declare const useIsStreaming: () => boolean;
9
+ export declare const getChatError: () => string | undefined;
10
+ export declare const useChatError: () => string | undefined;
11
+ export declare const setChatError: (error: string | undefined) => void;
@@ -0,0 +1,20 @@
1
+ import { useStore } from "@nanostores/react";
2
+ import { atom, computed } from "nanostores";
3
+ const $chatStatus = atom('ready');
4
+ const getChatStatus = ()=>$chatStatus.get();
5
+ const useChatStatus = ()=>useStore($chatStatus);
6
+ const setChatStatus = (status)=>$chatStatus.set(status);
7
+ const $isLoading = atom(false);
8
+ const getIsLoading = ()=>$isLoading.get();
9
+ const useIsLoading = ()=>useStore($isLoading);
10
+ const setIsLoading = (isLoading)=>$isLoading.set(isLoading);
11
+ $chatStatus.listen((status)=>{
12
+ 'ready' === status || 'streaming' === status ? setIsLoading(false) : setIsLoading(true);
13
+ });
14
+ const $isStreaming = computed($chatStatus, (status)=>'streaming' === status);
15
+ const useIsStreaming = ()=>useStore($isStreaming);
16
+ const $chatError = atom();
17
+ const getChatError = ()=>$chatError.get();
18
+ const useChatError = ()=>useStore($chatError);
19
+ const setChatError = (error)=>$chatError.set(error);
20
+ export { getChatError, getChatStatus, getIsLoading, setChatError, setChatStatus, setIsLoading, useChatError, useChatStatus, useIsLoading, useIsStreaming };
@@ -0,0 +1,3 @@
1
+ import { type UseChatOptions } from '@ai-sdk/react';
2
+ import type { ChatInit, UIMessage } from 'ai';
3
+ export declare const useInitChat: <T extends UIMessage>(props?: UseChatOptions<T> & ChatInit<T>) => void;
@@ -0,0 +1,40 @@
1
+ import { useChat } from "@ai-sdk/react";
2
+ import { notifications } from "@mantine/notifications";
3
+ import { useEffect } from "react";
4
+ import { setChatMessages } from "./messages.js";
5
+ import { setChatSendMessage } from "./send.js";
6
+ import { setChatError, setChatStatus } from "./states.js";
7
+ const useInitChat = (props)=>{
8
+ const { messages, status, error, sendMessage } = useChat({
9
+ onError: (e)=>{
10
+ notifications.show({
11
+ title: 'Ошибка сервера ИИ',
12
+ message: e.message,
13
+ color: 'red',
14
+ autoClose: false
15
+ });
16
+ },
17
+ ...props
18
+ });
19
+ useEffect(()=>{
20
+ setChatStatus(status);
21
+ }, [
22
+ status
23
+ ]);
24
+ useEffect(()=>{
25
+ setChatError(error?.message);
26
+ }, [
27
+ error?.message
28
+ ]);
29
+ useEffect(()=>{
30
+ setChatSendMessage(sendMessage);
31
+ }, [
32
+ sendMessage
33
+ ]);
34
+ useEffect(()=>{
35
+ setChatMessages(messages);
36
+ }, [
37
+ messages
38
+ ]);
39
+ };
40
+ export { useInitChat };
@@ -0,0 +1 @@
1
+ export * from './chat';
@@ -0,0 +1 @@
1
+ export * from "./chat/index.js";
@@ -0,0 +1,2 @@
1
+ export * from './convertFileUIPartBlobToDataURL';
2
+ export * from './parseAiMessagePart';
@@ -0,0 +1,2 @@
1
+ export * from "./convertFileUIPartBlobToDataURL.js";
2
+ export * from "./parseAiMessagePart.js";
@@ -1,6 +1,6 @@
1
1
  import { useComputedColorScheme } from "@mantine/core";
2
2
  import { useEffect } from "react";
3
- import { setCookies } from "../functions/setCookies.js";
3
+ import { setCookies } from "../tanstackFunctions/index.js";
4
4
  const AppDefaults = ({ saveColorScheme })=>{
5
5
  const colorScheme = useComputedColorScheme();
6
6
  useEffect(()=>{
@@ -1,7 +1,7 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { ColorSchemeScript, MantineProvider } from "@mantine/core";
3
3
  import { HeadContent, Scripts } from "@tanstack/react-router";
4
- import { getCookie } from "../functions/getCookie.js";
4
+ import { getCookie } from "../tanstackFunctions/index.js";
5
5
  import { AppDefaults } from "./AppDefaults.js";
6
6
  import { cookieColorSchemeManager } from "./cookieColorSchemeManager.js";
7
7
  import { defaultTheme } from "./defaultTheme.js";
@@ -1,6 +1,6 @@
1
1
  import { isMantineColorScheme } from "@mantine/core";
2
2
  import { atom } from "nanostores";
3
- import { setCookie } from "../functions/setCookie.js";
3
+ import { setCookie } from "../tanstackFunctions/index.js";
4
4
  const $colorScheme = atom();
5
5
  let unsubscribeSystemTheme;
6
6
  const cookieColorSchemeManager = ({ key = 'colorScheme' } = {})=>({
@@ -1,4 +1,4 @@
1
- export declare const defaultRequestMiddlewares: import("@tanstack/start-client-core").RequestMiddlewareAfterServer<{}, undefined, {
1
+ export declare const defaultRequestMiddlewares: import("@tanstack/react-start").RequestMiddlewareAfterServer<{}, undefined, {
2
2
  locale: string;
3
3
  timeZone: string;
4
4
  }>[];
@@ -70,9 +70,9 @@ export declare const defaultTheme: {
70
70
  } | undefined;
71
71
  radius?: {
72
72
  [x: string & {}]: string | undefined;
73
+ md?: string | undefined;
73
74
  xs?: string | undefined;
74
75
  sm?: string | undefined;
75
- md?: string | undefined;
76
76
  lg?: string | undefined;
77
77
  xl?: string | undefined;
78
78
  } | undefined;
@@ -80,41 +80,41 @@ export declare const defaultTheme: {
80
80
  spacing?: {
81
81
  [x: number]: string | undefined;
82
82
  [x: string & {}]: string | undefined;
83
+ md?: string | undefined;
83
84
  xs?: string | undefined;
84
85
  sm?: string | undefined;
85
- md?: string | undefined;
86
86
  lg?: string | undefined;
87
87
  xl?: string | undefined;
88
88
  } | undefined;
89
89
  fontSizes?: {
90
90
  [x: string & {}]: string | undefined;
91
+ md?: string | undefined;
91
92
  xs?: string | undefined;
92
93
  sm?: string | undefined;
93
- md?: string | undefined;
94
94
  lg?: string | undefined;
95
95
  xl?: string | undefined;
96
96
  } | undefined;
97
97
  lineHeights?: {
98
98
  [x: string & {}]: string | undefined;
99
+ md?: string | undefined;
99
100
  xs?: string | undefined;
100
101
  sm?: string | undefined;
101
- md?: string | undefined;
102
102
  lg?: string | undefined;
103
103
  xl?: string | undefined;
104
104
  } | undefined;
105
105
  breakpoints?: {
106
106
  [x: string & {}]: string | undefined;
107
+ md?: string | undefined;
107
108
  xs?: string | undefined;
108
109
  sm?: string | undefined;
109
- md?: string | undefined;
110
110
  lg?: string | undefined;
111
111
  xl?: string | undefined;
112
112
  } | undefined;
113
113
  shadows?: {
114
114
  [x: string & {}]: string | undefined;
115
+ md?: string | undefined;
115
116
  xs?: string | undefined;
116
117
  sm?: string | undefined;
117
- md?: string | undefined;
118
118
  lg?: string | undefined;
119
119
  xl?: string | undefined;
120
120
  } | undefined;
@@ -0,0 +1,4 @@
1
+ export * from './AppDefaults';
2
+ export * from './DefaultApp';
3
+ export * from './defaultRequestMiddlewares';
4
+ export * from './defaultTheme';
@@ -0,0 +1,4 @@
1
+ export * from "./AppDefaults.js";
2
+ export * from "./DefaultApp.js";
3
+ export * from "./defaultRequestMiddlewares.js";
4
+ export * from "./defaultTheme.js";
@@ -0,0 +1,2 @@
1
+ export * from './useMutation';
2
+ export * from './useMutationWithInvalidate';
@@ -0,0 +1,2 @@
1
+ export * from "./useMutation.js";
2
+ export * from "./useMutationWithInvalidate.js";