@rolder/kit 3.0.0-alpha.8 → 3.0.0-alpha.81

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 (297) 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/Empty.d.ts +1 -0
  4. package/dist/ai/ui/chat/Empty.js +21 -0
  5. package/dist/ai/ui/chat/File.d.ts +3 -0
  6. package/dist/ai/ui/chat/File.js +43 -0
  7. package/dist/ai/ui/chat/FileIcon.d.ts +3 -0
  8. package/dist/ai/ui/chat/FileIcon.js +43 -0
  9. package/dist/ai/ui/chat/Loader.d.ts +2 -0
  10. package/dist/ai/ui/chat/Loader.js +13 -0
  11. package/dist/ai/ui/chat/Message.d.ts +3 -0
  12. package/dist/ai/ui/chat/Message.js +23 -0
  13. package/dist/ai/ui/chat/Messages.d.ts +2 -0
  14. package/dist/ai/ui/chat/Messages.js +27 -0
  15. package/dist/ai/ui/chat/Root.d.ts +49 -0
  16. package/dist/ai/ui/chat/Root.js +18 -0
  17. package/dist/ai/ui/chat/chatInput/File.d.ts +2 -0
  18. package/dist/ai/ui/chat/chatInput/File.js +71 -0
  19. package/dist/ai/ui/chat/chatInput/FileIcon.d.ts +3 -0
  20. package/dist/ai/ui/chat/chatInput/FileIcon.js +43 -0
  21. package/dist/ai/ui/chat/chatInput/Footer.d.ts +2 -0
  22. package/dist/ai/ui/chat/chatInput/Footer.js +8 -0
  23. package/dist/ai/ui/chat/chatInput/Root.d.ts +9 -0
  24. package/dist/ai/ui/chat/chatInput/Root.js +24 -0
  25. package/dist/ai/ui/chat/chatInput/Submit.d.ts +2 -0
  26. package/dist/ai/ui/chat/chatInput/Submit.js +23 -0
  27. package/dist/ai/ui/chat/chatInput/Textarea.d.ts +2 -0
  28. package/dist/ai/ui/chat/chatInput/Textarea.js +34 -0
  29. package/dist/ai/ui/chat/chatInput/index.d.ts +7 -0
  30. package/dist/ai/ui/chat/chatInput/index.js +13 -0
  31. package/dist/ai/ui/chat/chatInput/store/file.d.ts +8 -0
  32. package/dist/ai/ui/chat/chatInput/store/file.js +32 -0
  33. package/dist/ai/ui/chat/chatInput/store/fileErrorNotificaton.d.ts +2 -0
  34. package/dist/ai/ui/chat/chatInput/store/fileErrorNotificaton.js +21 -0
  35. package/dist/ai/ui/chat/chatInput/store/index.d.ts +2 -0
  36. package/dist/ai/ui/chat/chatInput/store/index.js +2 -0
  37. package/dist/ai/ui/chat/chatInput/store/input.d.ts +13 -0
  38. package/dist/ai/ui/chat/chatInput/store/input.js +81 -0
  39. package/dist/ai/ui/chat/chatInput/store/parseFile.d.ts +2 -0
  40. package/dist/ai/ui/chat/chatInput/store/parseFile.js +23 -0
  41. package/dist/ai/ui/chat/index.d.ts +13 -0
  42. package/dist/ai/ui/chat/index.js +15 -0
  43. package/dist/ai/ui/chat/store/index.d.ts +5 -0
  44. package/dist/ai/ui/chat/store/index.js +5 -0
  45. package/dist/ai/ui/chat/store/messageIds.d.ts +8 -0
  46. package/dist/ai/ui/chat/store/messageIds.js +41 -0
  47. package/dist/ai/ui/chat/store/messagesMap.d.ts +5 -0
  48. package/dist/ai/ui/chat/store/messagesMap.js +15 -0
  49. package/dist/ai/ui/chat/store/send.d.ts +14 -0
  50. package/dist/ai/ui/chat/store/send.js +16 -0
  51. package/dist/ai/ui/chat/store/states.d.ts +11 -0
  52. package/dist/ai/ui/chat/store/states.js +17 -0
  53. package/dist/ai/ui/chat/store/useInitChat.d.ts +3 -0
  54. package/dist/ai/ui/chat/store/useInitChat.js +40 -0
  55. package/dist/ai/ui/index.d.ts +1 -0
  56. package/dist/ai/ui/index.js +1 -0
  57. package/dist/ai/utils/convertFileUIPartBlobToDataURL.d.ts +5 -0
  58. package/dist/ai/utils/convertFileUIPartBlobToDataURL.js +21 -0
  59. package/dist/ai/utils/index.d.ts +2 -0
  60. package/dist/ai/utils/index.js +2 -0
  61. package/dist/ai/utils/parseAiMessagePart.d.ts +2 -0
  62. package/dist/ai/utils/parseAiMessagePart.js +12 -0
  63. package/dist/app/AppDefaults.d.ts +3 -0
  64. package/dist/app/AppDefaults.js +27 -0
  65. package/dist/app/DefaultApp.d.ts +6 -0
  66. package/dist/app/DefaultApp.js +43 -0
  67. package/dist/app/cookieColorSchemeManager.d.ts +6 -0
  68. package/dist/app/cookieColorSchemeManager.js +46 -0
  69. package/dist/app/defaultRequestMiddlewares.d.ts +4 -0
  70. package/dist/app/defaultRequestMiddlewares.js +24 -0
  71. package/dist/app/defaultTheme.d.ts +141 -0
  72. package/dist/app/defaultTheme.js +24 -0
  73. package/dist/app/index.d.ts +4 -0
  74. package/dist/app/index.js +4 -0
  75. package/dist/hooks/index.d.ts +2 -0
  76. package/dist/hooks/index.js +2 -0
  77. package/dist/hooks/useMutation.d.ts +4 -0
  78. package/dist/hooks/useMutation.js +8 -0
  79. package/dist/hooks/useMutationWithInvalidate.d.ts +4 -0
  80. package/dist/hooks/useMutationWithInvalidate.js +16 -0
  81. package/dist/index.d.ts +5 -0
  82. package/dist/index.js +5 -0
  83. package/{src → dist}/styles.css +14 -29
  84. package/dist/tanstackFunctions/cookie/getCookie.d.ts +3 -0
  85. package/dist/tanstackFunctions/cookie/getCookie.js +8 -0
  86. package/dist/tanstackFunctions/cookie/index.d.ts +3 -0
  87. package/dist/tanstackFunctions/cookie/index.js +4 -0
  88. package/dist/tanstackFunctions/cookie/setCookie.d.ts +10 -0
  89. package/dist/tanstackFunctions/cookie/setCookie.js +19 -0
  90. package/dist/tanstackFunctions/cookie/setCookies.d.ts +14 -0
  91. package/dist/tanstackFunctions/cookie/setCookies.js +13 -0
  92. package/dist/tanstackFunctions/index.d.ts +3 -0
  93. package/dist/tanstackFunctions/index.js +3 -0
  94. package/dist/tanstackFunctions/s3/getS3Client.d.ts +2 -0
  95. package/dist/tanstackFunctions/s3/getS3Client.js +18 -0
  96. package/dist/tanstackFunctions/s3/getSignedFileUrlFn.d.ts +4 -0
  97. package/dist/tanstackFunctions/s3/getSignedFileUrlFn.js +21 -0
  98. package/dist/tanstackFunctions/s3/index.d.ts +2 -0
  99. package/dist/tanstackFunctions/s3/index.js +2 -0
  100. package/dist/tanstackFunctions/s3/uploadRequest.d.ts +3 -0
  101. package/dist/tanstackFunctions/s3/uploadRequest.js +21 -0
  102. package/dist/tanstackFunctions/surreal/connection.d.ts +9 -0
  103. package/dist/tanstackFunctions/surreal/connection.js +49 -0
  104. package/dist/tanstackFunctions/surreal/deafaultCrud.d.ts +2 -0
  105. package/dist/tanstackFunctions/surreal/deafaultCrud.js +18 -0
  106. package/dist/tanstackFunctions/surreal/deserialize.d.ts +17 -0
  107. package/dist/tanstackFunctions/surreal/deserialize.js +46 -0
  108. package/dist/tanstackFunctions/surreal/encryption.d.ts +6 -0
  109. package/dist/tanstackFunctions/surreal/encryption.js +30 -0
  110. package/dist/tanstackFunctions/surreal/index.d.ts +4 -0
  111. package/dist/tanstackFunctions/surreal/index.js +4 -0
  112. package/dist/ui/AnimatedChevron.d.ts +6 -0
  113. package/dist/ui/AnimatedChevron.js +13 -0
  114. package/dist/ui/JsonInput.d.ts +2 -0
  115. package/dist/ui/JsonInput.js +45 -0
  116. package/dist/ui/RouterLink.d.ts +16 -0
  117. package/dist/ui/RouterLink.js +36 -0
  118. package/dist/ui/editor/Content.d.ts +3 -0
  119. package/dist/ui/editor/Content.js +13 -0
  120. package/dist/ui/editor/Root.d.ts +8 -0
  121. package/dist/ui/editor/Root.js +55 -0
  122. package/dist/ui/editor/Toolbar.d.ts +5 -0
  123. package/dist/ui/editor/Toolbar.js +138 -0
  124. package/dist/ui/editor/index.d.ts +11 -0
  125. package/dist/ui/editor/index.js +10 -0
  126. package/dist/ui/editor/store.d.ts +6 -0
  127. package/dist/ui/editor/store.js +10 -0
  128. package/dist/ui/error/DefaultError.d.ts +2 -0
  129. package/dist/ui/error/DefaultError.js +62 -0
  130. package/dist/ui/error/DefaultNotFound.d.ts +1 -0
  131. package/dist/ui/error/DefaultNotFound.js +37 -0
  132. package/dist/ui/error/Forbidden.d.ts +1 -0
  133. package/dist/ui/error/Forbidden.js +32 -0
  134. package/dist/ui/error/defaultErrorNotification.d.ts +1 -0
  135. package/dist/ui/error/defaultErrorNotification.js +8 -0
  136. package/dist/ui/error/index.js +5 -0
  137. package/dist/ui/form/blurOnError.d.ts +4 -0
  138. package/dist/ui/form/blurOnError.js +11 -0
  139. package/dist/ui/form/buttons/CancelButton.d.ts +5 -0
  140. package/dist/ui/form/buttons/CancelButton.js +22 -0
  141. package/dist/ui/form/buttons/SubmitButton.d.ts +5 -0
  142. package/dist/ui/form/buttons/SubmitButton.js +22 -0
  143. package/dist/ui/form/buttons/SubscribeActionIcon.d.ts +4 -0
  144. package/dist/ui/form/buttons/SubscribeActionIcon.js +15 -0
  145. package/dist/ui/form/buttons/SubscribeButton.d.ts +5 -0
  146. package/dist/ui/form/buttons/SubscribeButton.js +16 -0
  147. package/dist/ui/form/buttons/index.js +4 -0
  148. package/dist/ui/form/context.d.ts +83 -0
  149. package/dist/ui/form/context.js +26 -0
  150. package/dist/ui/form/fields/JsonField.d.ts +2 -0
  151. package/dist/ui/form/fields/JsonField.js +13 -0
  152. package/dist/ui/form/fields/MultiSelectField.d.ts +2 -0
  153. package/dist/ui/form/fields/MultiSelectField.js +15 -0
  154. package/dist/ui/form/fields/NumberField.d.ts +2 -0
  155. package/dist/ui/form/fields/NumberField.js +15 -0
  156. package/dist/ui/form/fields/PassowrdField.d.ts +2 -0
  157. package/dist/ui/form/fields/PassowrdField.js +18 -0
  158. package/dist/ui/form/fields/SelectField.d.ts +2 -0
  159. package/dist/ui/form/fields/SelectField.js +15 -0
  160. package/dist/ui/form/fields/SwitchField.d.ts +2 -0
  161. package/dist/ui/form/fields/SwitchField.js +15 -0
  162. package/dist/ui/form/fields/TextField.d.ts +2 -0
  163. package/dist/ui/form/fields/TextField.js +15 -0
  164. package/dist/ui/form/fields/TextPassowrdField.d.ts +2 -0
  165. package/dist/ui/form/fields/TextPassowrdField.js +29 -0
  166. package/dist/ui/form/fields/TextareaField.d.ts +2 -0
  167. package/dist/ui/form/fields/TextareaField.js +15 -0
  168. package/dist/ui/form/fields/index.js +9 -0
  169. package/dist/ui/form/fieldsSchema.d.ts +12 -0
  170. package/dist/ui/form/fieldsSchema.js +13 -0
  171. package/dist/ui/form/index.js +4 -0
  172. package/dist/ui/hoverPaper/HoverPaper.d.ts +6 -0
  173. package/dist/ui/hoverPaper/HoverPaper.js +15 -0
  174. package/dist/ui/hoverPaper/index.js +3 -0
  175. package/dist/ui/hoverPaper/usePaperHover.d.ts +4 -0
  176. package/dist/ui/hoverPaper/usePaperHover.js +9 -0
  177. package/dist/ui/index.d.ts +9 -0
  178. package/dist/ui/index.js +9 -0
  179. package/dist/ui/saveInput/JsonInput.d.ts +6 -0
  180. package/dist/ui/saveInput/JsonInput.js +34 -0
  181. package/dist/ui/saveInput/NumberInput.d.ts +6 -0
  182. package/dist/ui/saveInput/NumberInput.js +27 -0
  183. package/dist/ui/saveInput/SaveInput.d.ts +36 -0
  184. package/dist/ui/saveInput/SaveInput.js +15 -0
  185. package/dist/ui/saveInput/Select.d.ts +6 -0
  186. package/dist/ui/saveInput/Select.js +27 -0
  187. package/dist/ui/saveInput/Switch.d.ts +6 -0
  188. package/dist/ui/saveInput/Switch.js +30 -0
  189. package/dist/ui/saveInput/TextInput.d.ts +6 -0
  190. package/dist/ui/saveInput/TextInput.js +26 -0
  191. package/dist/ui/saveInput/Textarea.d.ts +6 -0
  192. package/dist/ui/saveInput/Textarea.js +26 -0
  193. package/dist/ui/saveInput/index.js +2 -0
  194. package/dist/ui/scrollArea/Root.d.ts +7 -0
  195. package/dist/ui/scrollArea/Root.js +42 -0
  196. package/dist/ui/scrollArea/ScrollButton.d.ts +10 -0
  197. package/dist/ui/scrollArea/ScrollButton.js +30 -0
  198. package/dist/ui/scrollArea/index.d.ts +6 -0
  199. package/dist/ui/scrollArea/index.js +7 -0
  200. package/dist/ui/scrollArea/methods.d.ts +4 -0
  201. package/dist/ui/scrollArea/methods.js +32 -0
  202. package/dist/ui/scrollArea/store.d.ts +12 -0
  203. package/dist/ui/scrollArea/store.js +25 -0
  204. package/package.json +40 -28
  205. package/rslib.config.ts +0 -21
  206. package/src/ai/ui/conversation/ConversationContext.ts +0 -21
  207. package/src/ai/ui/conversation/ConversationProvider.tsx +0 -21
  208. package/src/ai/ui/conversation/Empty.tsx +0 -15
  209. package/src/ai/ui/conversation/File.tsx +0 -40
  210. package/src/ai/ui/conversation/FileIcon.tsx +0 -143
  211. package/src/ai/ui/conversation/Loader.tsx +0 -8
  212. package/src/ai/ui/conversation/Message.tsx +0 -34
  213. package/src/ai/ui/conversation/Root.tsx +0 -24
  214. package/src/ai/ui/conversation/index.ts +0 -16
  215. package/src/ai/ui/conversation/types.ts +0 -8
  216. package/src/ai/ui/conversation/useChatMessage.ts +0 -13
  217. package/src/ai/ui/promptInput/File.tsx +0 -98
  218. package/src/ai/ui/promptInput/FileIcon.tsx +0 -149
  219. package/src/ai/ui/promptInput/Footer.tsx +0 -5
  220. package/src/ai/ui/promptInput/PromptInputContext.ts +0 -24
  221. package/src/ai/ui/promptInput/PromptInputProvider.tsx +0 -54
  222. package/src/ai/ui/promptInput/Root.tsx +0 -29
  223. package/src/ai/ui/promptInput/Submit.tsx +0 -39
  224. package/src/ai/ui/promptInput/Textarea.tsx +0 -39
  225. package/src/ai/ui/promptInput/index.ts +0 -15
  226. package/src/ai/ui/promptInput/types.ts +0 -9
  227. package/src/ai/utils/convertFileUIPartBlobToDataURL.ts +0 -29
  228. package/src/ai/utils/parseAiMessagePart.ts +0 -19
  229. package/src/app/AppDefaults.tsx +0 -21
  230. package/src/app/DefaultApp.tsx +0 -50
  231. package/src/app/cookieColorSchemeManager.ts +0 -70
  232. package/src/app/defaultRequestMiddlewares.ts +0 -22
  233. package/src/app/defaultTheme.ts +0 -22
  234. package/src/functions/getCookie.ts +0 -36
  235. package/src/functions/setCookie.ts +0 -29
  236. package/src/functions/setCookies.ts +0 -24
  237. package/src/hooks/useMutation.ts +0 -14
  238. package/src/hooks/useMutationWithInvalidate.ts +0 -23
  239. package/src/index.ts +0 -66
  240. package/src/surreal/connection.ts +0 -72
  241. package/src/surreal/deafaultCrud.ts +0 -25
  242. package/src/surreal/deserialize.ts +0 -144
  243. package/src/surreal/encryption.ts +0 -51
  244. package/src/ui/AnimatedChevron.tsx +0 -32
  245. package/src/ui/JsonInput.tsx +0 -52
  246. package/src/ui/RouterLink.tsx +0 -78
  247. package/src/ui/editor/Content.tsx +0 -11
  248. package/src/ui/editor/Provider.tsx +0 -96
  249. package/src/ui/editor/Root.tsx +0 -25
  250. package/src/ui/editor/Toolbar.tsx +0 -92
  251. package/src/ui/editor/index.ts +0 -13
  252. package/src/ui/editor/types.ts +0 -7
  253. package/src/ui/error/DefaultError.tsx +0 -60
  254. package/src/ui/error/DefaultNotFound.tsx +0 -19
  255. package/src/ui/error/Forbidden.tsx +0 -18
  256. package/src/ui/error/defaultErrorNotification.ts +0 -9
  257. package/src/ui/form/blurOnError.ts +0 -21
  258. package/src/ui/form/buttons/CancelButton.tsx +0 -42
  259. package/src/ui/form/buttons/SubmitButton.tsx +0 -43
  260. package/src/ui/form/buttons/SubscribeActionIcon.tsx +0 -18
  261. package/src/ui/form/buttons/SubscribeButton.tsx +0 -17
  262. package/src/ui/form/context.ts +0 -45
  263. package/src/ui/form/fields/JsonField.tsx +0 -16
  264. package/src/ui/form/fields/MultiSelectField.tsx +0 -17
  265. package/src/ui/form/fields/NumberField.tsx +0 -17
  266. package/src/ui/form/fields/PassowrdField.tsx +0 -20
  267. package/src/ui/form/fields/SelectField.tsx +0 -17
  268. package/src/ui/form/fields/SwitchField.tsx +0 -17
  269. package/src/ui/form/fields/TextField.tsx +0 -17
  270. package/src/ui/form/fields/TextPassowrdField.tsx +0 -51
  271. package/src/ui/form/fields/TextareaField.tsx +0 -17
  272. package/src/ui/form/fieldsSchema.ts +0 -24
  273. package/src/ui/hoverPaper/HoverPaper.tsx +0 -17
  274. package/src/ui/hoverPaper/usePaperHover.ts +0 -9
  275. package/src/ui/saveInput/JsonInput.tsx +0 -40
  276. package/src/ui/saveInput/NumberInput.tsx +0 -40
  277. package/src/ui/saveInput/SaveInput.tsx +0 -15
  278. package/src/ui/saveInput/Select.tsx +0 -41
  279. package/src/ui/saveInput/Switch.tsx +0 -46
  280. package/src/ui/saveInput/TextInput.tsx +0 -40
  281. package/src/ui/saveInput/Textarea.tsx +0 -40
  282. package/src/ui/scrollArea/ARCH.md +0 -204
  283. package/src/ui/scrollArea/README.md +0 -369
  284. package/src/ui/scrollArea/ScrollArea.tsx +0 -93
  285. package/src/ui/scrollArea/ScrollAreaButton.tsx +0 -56
  286. package/src/ui/scrollArea/ScrollAreaContent.tsx +0 -36
  287. package/src/ui/scrollArea/context.tsx +0 -43
  288. package/src/ui/scrollArea/index.ts +0 -10
  289. package/src/ui/scrollArea/types.ts +0 -77
  290. package/src/ui/scrollArea/useScrollArea.ts +0 -227
  291. package/tsconfig.json +0 -14
  292. /package/{src/ui/error/index.ts → dist/ui/error/index.d.ts} +0 -0
  293. /package/{src/ui/form/buttons/index.ts → dist/ui/form/buttons/index.d.ts} +0 -0
  294. /package/{src/ui/form/fields/index.ts → dist/ui/form/fields/index.d.ts} +0 -0
  295. /package/{src/ui/form/index.ts → dist/ui/form/index.d.ts} +0 -0
  296. /package/{src/ui/hoverPaper/index.ts → dist/ui/hoverPaper/index.d.ts} +0 -0
  297. /package/{src/ui/saveInput/index.ts → dist/ui/saveInput/index.d.ts} +0 -0
@@ -0,0 +1,81 @@
1
+ import { uploadFile } from "@better-upload/client";
2
+ import { useStore } from "@nanostores/react";
3
+ import { nanoid } from "nanoid";
4
+ import { atom } from "nanostores";
5
+ import { getSignedFileUrlFn } from "../../../../../tanstackFunctions/index.js";
6
+ import { addChatMessage, sendMessage } from "../../store/index.js";
7
+ import { getFile } from "./file.js";
8
+ import { fileErrorNotificaton } from "./fileErrorNotificaton.js";
9
+ import { parseExcel, parseWord } from "./parseFile.js";
10
+ const $text = atom('');
11
+ const getText = ()=>$text.get();
12
+ const useText = ()=>useStore($text);
13
+ const setText = (text)=>$text.set(text);
14
+ const $isComposing = atom(false);
15
+ const getIsComposing = ()=>$isComposing.get();
16
+ const setIsComposing = (isComposing)=>$isComposing.set(isComposing);
17
+ const $onSubmit = atom();
18
+ const getOnSubmit = ()=>$onSubmit.get();
19
+ const setOnSubmit = (onSubmit)=>$onSubmit.set(onSubmit);
20
+ const input_onSubmit = async ()=>{
21
+ const onSubmit = getOnSubmit();
22
+ const text = getText();
23
+ const file = getFile();
24
+ let fileUIPart;
25
+ if (file) if ([
26
+ 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
27
+ 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
28
+ ].includes(file.type)) {
29
+ let fileContent;
30
+ let type;
31
+ if ('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' === file.type) {
32
+ fileContent = await parseExcel(file);
33
+ type = 'excel';
34
+ } else if ('application/vnd.openxmlformats-officedocument.wordprocessingml.document' === file.type) {
35
+ fileContent = await parseWord(file);
36
+ type = 'word';
37
+ }
38
+ if (fileContent && type) addChatMessage({
39
+ id: `file-${type}-${nanoid()}`,
40
+ role: 'system',
41
+ parts: [
42
+ {
43
+ type: 'text',
44
+ text: `Пользователь загрузил файл типа "${type}" c содержимым:
45
+ \`\`\`
46
+ ${fileContent}
47
+ \`\`\``
48
+ }
49
+ ]
50
+ });
51
+ } else try {
52
+ const result = await uploadFile({
53
+ file,
54
+ route: 'upload'
55
+ });
56
+ const url = await getSignedFileUrlFn({
57
+ data: {
58
+ s3Key: result.file.objectInfo.key
59
+ }
60
+ });
61
+ fileUIPart = {
62
+ id: nanoid(),
63
+ type: 'file',
64
+ url,
65
+ mediaType: file.type,
66
+ filename: file.name
67
+ };
68
+ } catch (error) {
69
+ fileErrorNotificaton(error);
70
+ }
71
+ if (onSubmit) onSubmit({
72
+ text,
73
+ file: fileUIPart
74
+ });
75
+ sendMessage({
76
+ text,
77
+ file: fileUIPart
78
+ });
79
+ setText('');
80
+ };
81
+ export { getIsComposing, getOnSubmit, getText, input_onSubmit as onSubmit, setIsComposing, setOnSubmit, setText, useText };
@@ -0,0 +1,2 @@
1
+ export declare const parseExcel: (file: File) => Promise<string>;
2
+ export declare const parseWord: (file: File) => Promise<string>;
@@ -0,0 +1,23 @@
1
+ import mammoth from "mammoth";
2
+ import { read, utils } from "xlsx";
3
+ const parseExcel = async (file)=>{
4
+ const buffer = await file.arrayBuffer();
5
+ const workbook = read(buffer, {
6
+ type: 'array',
7
+ cellDates: true
8
+ });
9
+ const sheetName = workbook.SheetNames[0];
10
+ const worksheet = workbook.Sheets[sheetName];
11
+ const jsonData = utils.sheet_to_json(worksheet, {
12
+ dateNF: 'yyyy-mm-dd'
13
+ });
14
+ return JSON.stringify(jsonData, null, 2);
15
+ };
16
+ const parseWord = async (file)=>{
17
+ const arrayBuffer = await file.arrayBuffer();
18
+ const { value } = await mammoth.convertToHtml({
19
+ arrayBuffer
20
+ });
21
+ return value;
22
+ };
23
+ export { parseExcel, parseWord };
@@ -0,0 +1,13 @@
1
+ export declare const Chat: {
2
+ Root: ({ chatOptions, ...props }: import("./Root").ChatRootProps) => import("react/jsx-runtime").JSX.Element;
3
+ Message: import("react").MemoExoticComponent<({ 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;
11
+ };
12
+ export { ChatInput } from './chatInput';
13
+ export * from './store';
@@ -0,0 +1,15 @@
1
+ import { Empty } from "./Empty.js";
2
+ import { File } from "./File.js";
3
+ import { Loader } from "./Loader.js";
4
+ import { Message } from "./Message.js";
5
+ import { Root } from "./Root.js";
6
+ import { ChatInput } from "./chatInput/index.js";
7
+ export * from "./store/index.js";
8
+ const Chat = {
9
+ Root: Root,
10
+ Message: Message,
11
+ File: File,
12
+ Empty: Empty,
13
+ Loader: Loader
14
+ };
15
+ export { Chat, ChatInput };
@@ -0,0 +1,5 @@
1
+ export * from './messageIds';
2
+ export * from './messagesMap';
3
+ export * from './send';
4
+ export * from './states';
5
+ export * from './useInitChat';
@@ -0,0 +1,5 @@
1
+ export * from "./messageIds.js";
2
+ export * from "./messagesMap.js";
3
+ export * from "./send.js";
4
+ export * from "./states.js";
5
+ export * from "./useInitChat.js";
@@ -0,0 +1,8 @@
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;
@@ -0,0 +1,41 @@
1
+ import { useStore } from "@nanostores/react";
2
+ import { atom, computed, onSet } from "nanostores";
3
+ import { $chatMessages } from "./messagesMap.js";
4
+ const $chatMessageIds = atom([]);
5
+ const getChatMessages = ()=>$chatMessageIds.get().map((id)=>$chatMessages.get()[id]);
6
+ const useChatMessageIds = ()=>useStore($chatMessageIds);
7
+ onSet($chatMessageIds, ({ newValue, abort })=>{
8
+ const currentValue = $chatMessageIds.get();
9
+ if (currentValue.length === newValue.length && currentValue.every((id, index)=>id === newValue[index])) abort();
10
+ });
11
+ const addChatMessage = (newMessage)=>{
12
+ $chatMessageIds.set([
13
+ ...$chatMessageIds.get(),
14
+ newMessage.id
15
+ ]);
16
+ $chatMessages.set({
17
+ ...$chatMessages.get(),
18
+ [newMessage.id]: newMessage
19
+ });
20
+ };
21
+ const setChatMessages = (messages)=>{
22
+ const newIds = messages.map((msg)=>msg.id);
23
+ $chatMessageIds.set(newIds);
24
+ const currentMessages = $chatMessages.get();
25
+ const lastMessage = messages[messages.length - 1];
26
+ for(let i = 0; i < messages.length; i++){
27
+ const msg = messages[i];
28
+ const currentMsg = currentMessages[msg.id];
29
+ const isLastMessage = msg === lastMessage;
30
+ if (currentMsg) if (isLastMessage) $chatMessages.setKey(msg.id, msg);
31
+ else {
32
+ const isChanged = JSON.stringify(currentMsg) !== JSON.stringify(msg);
33
+ if (isChanged) $chatMessages.setKey(msg.id, msg);
34
+ }
35
+ else $chatMessages.setKey(msg.id, msg);
36
+ }
37
+ };
38
+ const $isEmpty = computed($chatMessageIds, (messages)=>0 === messages.length);
39
+ const getIsEmpty = ()=>$isEmpty.get();
40
+ const useIsEmpty = ()=>useStore($isEmpty);
41
+ export { $chatMessageIds, addChatMessage, getChatMessages, getIsEmpty, setChatMessages, useChatMessageIds, useIsEmpty };
@@ -0,0 +1,5 @@
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;
@@ -0,0 +1,15 @@
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 };
@@ -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 setChatStatus: (status: ChatStatus) => void;
4
+ export declare const useChatStatus: () => ChatStatus;
5
+ export declare const getIsLoading: () => boolean;
6
+ export declare const useIsLoading: () => boolean;
7
+ export declare const getIsStreaming: () => boolean;
8
+ export declare const useIsStreaming: () => boolean;
9
+ export declare const getChatError: () => string | undefined;
10
+ export declare const setChatError: (error: string | undefined) => void;
11
+ export declare const useChatError: () => string | undefined;
@@ -0,0 +1,17 @@
1
+ import { useStore } from "@nanostores/react";
2
+ import { atom, computed } from "nanostores";
3
+ const $chatStatus = atom('ready');
4
+ const getChatStatus = ()=>$chatStatus.get();
5
+ const setChatStatus = (status)=>$chatStatus.set(status);
6
+ const useChatStatus = ()=>useStore($chatStatus);
7
+ const $isLoading = computed($chatStatus, (status)=>'ready' !== status);
8
+ const getIsLoading = ()=>$isLoading.get();
9
+ const useIsLoading = ()=>useStore($isLoading);
10
+ const $isStreaming = computed($chatStatus, (status)=>'streaming' === status);
11
+ const getIsStreaming = ()=>$isStreaming.get();
12
+ const useIsStreaming = ()=>useStore($isStreaming);
13
+ const $chatError = atom();
14
+ const getChatError = ()=>$chatError.get();
15
+ const setChatError = (error)=>$chatError.set(error);
16
+ const useChatError = ()=>useStore($chatError);
17
+ export { getChatError, getChatStatus, getIsLoading, getIsStreaming, setChatError, setChatStatus, 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 "./messageIds.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,5 @@
1
+ import type { FileUIPart } from 'ai';
2
+ /**
3
+ * Converts FileUIPart array with blob URLs to data URLs
4
+ */
5
+ export declare function convertFileUIPartBlobToDataURL(file: FileUIPart): Promise<FileUIPart>;
@@ -0,0 +1,21 @@
1
+ async function blobToDataURL(blobUrl) {
2
+ const response = await fetch(blobUrl);
3
+ const blob = await response.blob();
4
+ return new Promise((resolve, reject)=>{
5
+ const reader = new FileReader();
6
+ reader.onload = ()=>resolve(reader.result);
7
+ reader.onerror = reject;
8
+ reader.readAsDataURL(blob);
9
+ });
10
+ }
11
+ async function convertFileUIPartBlobToDataURL(file) {
12
+ if (file.url.startsWith('blob:')) {
13
+ const dataUrl = await blobToDataURL(file.url);
14
+ return {
15
+ ...file,
16
+ url: dataUrl
17
+ };
18
+ }
19
+ return file;
20
+ }
21
+ export { convertFileUIPartBlobToDataURL };
@@ -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";
@@ -0,0 +1,2 @@
1
+ import { type TextUIPart } from 'ai';
2
+ export declare const parseAiMessagePart: <T extends TextUIPart>(part: T) => Promise<T>;
@@ -0,0 +1,12 @@
1
+ import { parsePartialJson } from "ai";
2
+ const parseAiMessagePart = async (part)=>{
3
+ if (!part.text.startsWith('{')) return part;
4
+ try {
5
+ const result = await parsePartialJson(part.text);
6
+ return result?.value || part;
7
+ } catch (error) {
8
+ console.error('Error parsing partial JSON:', error);
9
+ return part;
10
+ }
11
+ };
12
+ export { parseAiMessagePart };
@@ -0,0 +1,3 @@
1
+ export declare const AppDefaults: ({ saveColorScheme, }: {
2
+ saveColorScheme: boolean;
3
+ }) => null;
@@ -0,0 +1,27 @@
1
+ import { useComputedColorScheme } from "@mantine/core";
2
+ import { useEffect } from "react";
3
+ import { setCookies } from "../tanstackFunctions/index.js";
4
+ const AppDefaults = ({ saveColorScheme })=>{
5
+ const colorScheme = useComputedColorScheme();
6
+ useEffect(()=>{
7
+ const tz = Intl.DateTimeFormat().resolvedOptions().timeZone;
8
+ const cookies = [
9
+ {
10
+ name: 'tz',
11
+ value: tz,
12
+ expires: 365
13
+ }
14
+ ];
15
+ if (saveColorScheme) cookies.push({
16
+ name: 'colorScheme',
17
+ value: colorScheme,
18
+ expires: 365
19
+ });
20
+ setCookies(cookies);
21
+ }, [
22
+ colorScheme,
23
+ saveColorScheme
24
+ ]);
25
+ return null;
26
+ };
27
+ export { AppDefaults };
@@ -0,0 +1,6 @@
1
+ import { type MantineProviderProps } from '@mantine/core';
2
+ interface Props extends MantineProviderProps {
3
+ saveColorScheme?: boolean;
4
+ }
5
+ export declare const DefaultApp: ({ children, saveColorScheme, defaultColorScheme, ...props }: Props) => import("react/jsx-runtime").JSX.Element;
6
+ export {};
@@ -0,0 +1,43 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { ColorSchemeScript, MantineProvider } from "@mantine/core";
3
+ import { HeadContent, Scripts } from "@tanstack/react-router";
4
+ import { getCookie } from "../tanstackFunctions/index.js";
5
+ import { AppDefaults } from "./AppDefaults.js";
6
+ import { cookieColorSchemeManager } from "./cookieColorSchemeManager.js";
7
+ import { defaultTheme } from "./defaultTheme.js";
8
+ const colorSchemeManager = cookieColorSchemeManager();
9
+ const DefaultApp = ({ children, saveColorScheme = true, defaultColorScheme = 'auto', ...props })=>{
10
+ const colorScheme = saveColorScheme ? getCookie('colorScheme', defaultColorScheme) : defaultColorScheme;
11
+ return /*#__PURE__*/ jsxs("html", {
12
+ lang: "ru",
13
+ suppressHydrationWarning: true,
14
+ children: [
15
+ /*#__PURE__*/ jsxs("head", {
16
+ children: [
17
+ /*#__PURE__*/ jsx(HeadContent, {}),
18
+ /*#__PURE__*/ jsx(ColorSchemeScript, {
19
+ defaultColorScheme: colorScheme
20
+ })
21
+ ]
22
+ }),
23
+ /*#__PURE__*/ jsxs("body", {
24
+ children: [
25
+ /*#__PURE__*/ jsxs(MantineProvider, {
26
+ defaultColorScheme: colorScheme,
27
+ theme: defaultTheme,
28
+ colorSchemeManager: colorSchemeManager,
29
+ ...props,
30
+ children: [
31
+ /*#__PURE__*/ jsx(AppDefaults, {
32
+ saveColorScheme: saveColorScheme
33
+ }),
34
+ children
35
+ ]
36
+ }),
37
+ /*#__PURE__*/ jsx(Scripts, {})
38
+ ]
39
+ })
40
+ ]
41
+ });
42
+ };
43
+ export { DefaultApp };
@@ -0,0 +1,6 @@
1
+ import { type MantineColorSchemeManager } from '@mantine/core';
2
+ export interface CookieColorSchemeManager {
3
+ /** Название куки, `colorScheme` по умолчанию */
4
+ key?: string;
5
+ }
6
+ export declare const cookieColorSchemeManager: ({ key, }?: CookieColorSchemeManager) => MantineColorSchemeManager;
@@ -0,0 +1,46 @@
1
+ import { isMantineColorScheme } from "@mantine/core";
2
+ import { atom } from "nanostores";
3
+ import { setCookie } from "../tanstackFunctions/index.js";
4
+ const $colorScheme = atom();
5
+ let unsubscribeSystemTheme;
6
+ const cookieColorSchemeManager = ({ key = 'colorScheme' } = {})=>({
7
+ get: (defaultValue)=>{
8
+ try {
9
+ return $colorScheme.get() || defaultValue;
10
+ } catch {
11
+ return defaultValue;
12
+ }
13
+ },
14
+ set: (value)=>{
15
+ try {
16
+ setCookie(key, value);
17
+ $colorScheme.set(value);
18
+ } catch (error) {
19
+ console.warn('[cookieColorSchemeManager] Ошибка при сохранении цветовой схемы в куки.', error);
20
+ }
21
+ },
22
+ subscribe: (onUpdate)=>{
23
+ $colorScheme.listen((newValue)=>{
24
+ if (isMantineColorScheme(newValue)) {
25
+ setCookie(key, newValue);
26
+ onUpdate(newValue);
27
+ }
28
+ });
29
+ const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
30
+ const handleSystemThemeChange = ()=>onUpdate('auto');
31
+ mediaQuery.addEventListener('change', handleSystemThemeChange);
32
+ unsubscribeSystemTheme = ()=>mediaQuery.removeEventListener('change', handleSystemThemeChange);
33
+ },
34
+ unsubscribe: ()=>{
35
+ $colorScheme.off();
36
+ if (unsubscribeSystemTheme) {
37
+ unsubscribeSystemTheme();
38
+ unsubscribeSystemTheme = void 0;
39
+ }
40
+ },
41
+ clear: ()=>{
42
+ setCookie(key);
43
+ $colorScheme.set(void 0);
44
+ }
45
+ });
46
+ export { cookieColorSchemeManager };
@@ -0,0 +1,4 @@
1
+ export declare const defaultRequestMiddlewares: import("@tanstack/start-client-core").RequestMiddlewareAfterServer<{}, undefined, {
2
+ locale: string;
3
+ timeZone: string;
4
+ }>[];
@@ -0,0 +1,24 @@
1
+ import { createMiddleware } from "@tanstack/react-start";
2
+ import { getCookie, getRequestHeader, setCookie } from "@tanstack/react-start/server";
3
+ const defaultRequestMiddlewares_locale = createMiddleware().server(async ({ next })=>{
4
+ const header = getRequestHeader('accept-language');
5
+ const headerLocale = header?.split(',')[0] || 'ru-RU';
6
+ const cookieLocale = getCookie('locale');
7
+ const cookieTz = getCookie('tz');
8
+ const locale = cookieLocale || headerLocale;
9
+ const timeZone = cookieTz || 'UTC';
10
+ setCookie('locale', locale, {
11
+ path: '/',
12
+ maxAge: 31536000
13
+ });
14
+ return next({
15
+ context: {
16
+ locale,
17
+ timeZone
18
+ }
19
+ });
20
+ });
21
+ const defaultRequestMiddlewares = [
22
+ defaultRequestMiddlewares_locale
23
+ ];
24
+ export { defaultRequestMiddlewares };