@rolder/kit 3.0.0-alpha.32 → 3.0.0-alpha.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai/ui/chat/Empty.js +1 -1
- package/dist/ai/ui/chat/File.js +1 -1
- package/dist/ai/ui/chat/Loader.js +1 -1
- package/dist/ai/ui/chat/Message.js +1 -1
- package/dist/ai/ui/chat/Messages.js +1 -1
- package/dist/ai/ui/chat/chatInput/File.js +3 -3
- package/dist/ai/ui/chat/chatInput/Root.d.ts +2 -2
- package/dist/ai/ui/chat/chatInput/Root.js +1 -1
- package/dist/ai/ui/chat/chatInput/Submit.js +3 -3
- package/dist/ai/ui/chat/chatInput/Textarea.js +3 -3
- package/dist/ai/ui/chat/chatInput/store/file.d.ts +8 -0
- package/dist/ai/ui/chat/chatInput/{store.js → store/file.js} +5 -13
- package/dist/ai/ui/chat/chatInput/store/fileErrorNotificaton.d.ts +2 -0
- package/dist/ai/ui/chat/chatInput/store/fileErrorNotificaton.js +21 -0
- package/dist/ai/ui/chat/chatInput/store/index.d.ts +2 -0
- package/dist/ai/ui/chat/chatInput/store/index.js +2 -0
- package/dist/ai/ui/chat/chatInput/store/input.d.ts +13 -0
- package/dist/ai/ui/chat/chatInput/store/input.js +80 -0
- package/dist/ai/ui/chat/chatInput/store/parseFile.d.ts +2 -0
- package/dist/ai/ui/chat/chatInput/store/parseFile.js +23 -0
- package/dist/ai/ui/chat/store/messages.d.ts +1 -0
- package/dist/ai/ui/chat/store/messages.js +11 -1
- package/dist/app/AppDefaults.js +1 -1
- package/dist/app/DefaultApp.js +1 -1
- package/dist/app/cookieColorSchemeManager.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/tanstackFunctions/index.d.ts +2 -0
- package/dist/tanstackFunctions/index.js +2 -0
- package/dist/tanstackFunctions/s3/getS3Client.d.ts +2 -0
- package/dist/tanstackFunctions/s3/getS3Client.js +18 -0
- package/dist/tanstackFunctions/s3/getSignedFileUrlFn.d.ts +4 -0
- package/dist/tanstackFunctions/s3/getSignedFileUrlFn.js +21 -0
- package/dist/tanstackFunctions/s3/index.d.ts +2 -0
- package/dist/tanstackFunctions/s3/index.js +2 -0
- package/dist/tanstackFunctions/s3/uploadRequest.d.ts +3 -0
- package/dist/tanstackFunctions/s3/uploadRequest.js +21 -0
- package/dist/ui/JsonInput.js +1 -1
- package/package.json +28 -23
- package/dist/ai/ui/chat/chatInput/store.d.ts +0 -13
- /package/dist/{functions → tanstackFunctions/cookie}/getCookie.d.ts +0 -0
- /package/dist/{functions → tanstackFunctions/cookie}/getCookie.js +0 -0
- /package/dist/{functions → tanstackFunctions/cookie}/index.d.ts +0 -0
- /package/dist/{functions → tanstackFunctions/cookie}/index.js +0 -0
- /package/dist/{functions → tanstackFunctions/cookie}/setCookie.d.ts +0 -0
- /package/dist/{functions → tanstackFunctions/cookie}/setCookie.js +0 -0
- /package/dist/{functions → tanstackFunctions/cookie}/setCookies.d.ts +0 -0
- /package/dist/{functions → tanstackFunctions/cookie}/setCookies.js +0 -0
package/dist/ai/ui/chat/Empty.js
CHANGED
|
@@ -3,7 +3,7 @@ import { Stack, Text } from "@mantine/core";
|
|
|
3
3
|
import { useIsEmpty } from "./store/index.js";
|
|
4
4
|
const Empty = ()=>{
|
|
5
5
|
const isEmpty = useIsEmpty();
|
|
6
|
-
console.log('Empty render');
|
|
6
|
+
console.log('Empty render', isEmpty);
|
|
7
7
|
return isEmpty ? null : /*#__PURE__*/ jsxs(Stack, {
|
|
8
8
|
align: "center",
|
|
9
9
|
gap: 0,
|
package/dist/ai/ui/chat/File.js
CHANGED
|
@@ -5,7 +5,7 @@ import { useChatMessagePart } from "./store/index.js";
|
|
|
5
5
|
const File = ({ messageId })=>{
|
|
6
6
|
const part = useChatMessagePart(messageId, 'file');
|
|
7
7
|
const textFileType = messageId.split('-')[1];
|
|
8
|
-
console.log('File render');
|
|
8
|
+
console.log('File render', part);
|
|
9
9
|
const FileComponent = ()=>{
|
|
10
10
|
switch(textFileType){
|
|
11
11
|
case 'excel':
|
|
@@ -3,7 +3,7 @@ import { Loader } from "@mantine/core";
|
|
|
3
3
|
import { useIsLoading } from "./store/index.js";
|
|
4
4
|
const Loader_Loader = (props)=>{
|
|
5
5
|
const isLoading = useIsLoading();
|
|
6
|
-
console.log('Loader render');
|
|
6
|
+
console.log('Loader render', isLoading);
|
|
7
7
|
return isLoading ? /*#__PURE__*/ jsx(Loader, {
|
|
8
8
|
size: 28,
|
|
9
9
|
type: "dots",
|
|
@@ -6,7 +6,7 @@ const Message = ({ messageId })=>{
|
|
|
6
6
|
const message = useChatMessage(messageId);
|
|
7
7
|
const part = useChatMessagePart(messageId, 'text');
|
|
8
8
|
const isStreaming = useIsStreaming();
|
|
9
|
-
console.log('Message render');
|
|
9
|
+
console.log('Message render', message, part);
|
|
10
10
|
return part ? /*#__PURE__*/ jsx(Paper, {
|
|
11
11
|
radius: "md",
|
|
12
12
|
px: "md",
|
|
@@ -3,7 +3,7 @@ import { Stack } from "@mantine/core";
|
|
|
3
3
|
import { useChatMessageIds } from "./store/index.js";
|
|
4
4
|
const Messages = ({ children, ...props })=>{
|
|
5
5
|
const messageIds = useChatMessageIds();
|
|
6
|
-
console.log('Messages render');
|
|
6
|
+
console.log('Messages render', messageIds);
|
|
7
7
|
return messageIds.map((messageId)=>/*#__PURE__*/ jsx(Stack, {
|
|
8
8
|
...props,
|
|
9
9
|
children: children
|
|
@@ -4,13 +4,13 @@ import { IconPaperclip, IconTrash } from "@tabler/icons-react";
|
|
|
4
4
|
import { useRef } from "react";
|
|
5
5
|
import { useIsLoading } from "../store/index.js";
|
|
6
6
|
import { FileIcon } from "./FileIcon.js";
|
|
7
|
-
import { getAccept, setFile, useFile, useIsUploading } from "./store.js";
|
|
7
|
+
import { getAccept, setFile, useFile, useIsUploading } from "./store/index.js";
|
|
8
8
|
const File = (props)=>{
|
|
9
9
|
const resetRef = useRef(null);
|
|
10
10
|
const isLoading = useIsLoading();
|
|
11
11
|
const isUploading = useIsUploading();
|
|
12
12
|
const file = useFile();
|
|
13
|
-
console.log('Input File render');
|
|
13
|
+
console.log('Input File render', file);
|
|
14
14
|
return /*#__PURE__*/ jsx(FileButton, {
|
|
15
15
|
resetRef: resetRef,
|
|
16
16
|
onChange: async (file)=>{
|
|
@@ -56,7 +56,7 @@ const File = (props)=>{
|
|
|
56
56
|
},
|
|
57
57
|
onClick: ()=>{
|
|
58
58
|
resetRef.current?.();
|
|
59
|
-
setFile(
|
|
59
|
+
setFile(void 0);
|
|
60
60
|
},
|
|
61
61
|
children: /*#__PURE__*/ jsx(IconTrash, {
|
|
62
62
|
size: 24,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type PaperProps } from '@mantine/core';
|
|
2
|
-
import { type Accept } from './store';
|
|
2
|
+
import { type Accept, type OnSubmitProps } from './store';
|
|
3
3
|
export interface ChatInputRootProps extends PaperProps {
|
|
4
4
|
children?: React.ReactNode;
|
|
5
|
-
onSubmit?: () => void;
|
|
5
|
+
onSubmit?: (props: OnSubmitProps) => void;
|
|
6
6
|
isUploading?: boolean;
|
|
7
7
|
accept?: Accept;
|
|
8
8
|
}
|
|
@@ -2,7 +2,7 @@ import { jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { Paper } from "@mantine/core";
|
|
3
3
|
import clsx from "clsx";
|
|
4
4
|
import { useEffect } from "react";
|
|
5
|
-
import { setAccept, setIsUploading, setOnSubmit } from "./store.js";
|
|
5
|
+
import { setAccept, setIsUploading, setOnSubmit } from "./store/index.js";
|
|
6
6
|
const Root = ({ children, className, onSubmit, isUploading, accept, ...props })=>{
|
|
7
7
|
useEffect(()=>{
|
|
8
8
|
if (onSubmit) setOnSubmit(onSubmit);
|
|
@@ -2,19 +2,19 @@ import { jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { ActionIcon } from "@mantine/core";
|
|
3
3
|
import { IconArrowBigUp } from "@tabler/icons-react";
|
|
4
4
|
import { useIsLoading } from "../store/index.js";
|
|
5
|
-
import {
|
|
5
|
+
import { onSubmit, useIsUploading } from "./store/index.js";
|
|
6
6
|
const Submit = ({ children, ...props })=>{
|
|
7
7
|
const Icon = /*#__PURE__*/ jsx(IconArrowBigUp, {
|
|
8
8
|
strokeWidth: 1.5
|
|
9
9
|
});
|
|
10
10
|
const isLoading = useIsLoading();
|
|
11
11
|
const isUploading = useIsUploading();
|
|
12
|
-
console.log('Input submit render'
|
|
12
|
+
console.log('Input submit render');
|
|
13
13
|
return /*#__PURE__*/ jsx(ActionIcon, {
|
|
14
14
|
"aria-label": "Submit",
|
|
15
15
|
variant: "light",
|
|
16
16
|
size: "lg",
|
|
17
|
-
onClick:
|
|
17
|
+
onClick: onSubmit,
|
|
18
18
|
disabled: isUploading,
|
|
19
19
|
loading: isLoading,
|
|
20
20
|
...props,
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Textarea } from "@mantine/core";
|
|
3
3
|
import { useIsLoading } from "../store/index.js";
|
|
4
|
-
import { getIsComposing,
|
|
4
|
+
import { getIsComposing, onSubmit, setIsComposing, setText, useIsUploading, useText } from "./store/index.js";
|
|
5
5
|
const Textarea_Textarea = (props)=>{
|
|
6
6
|
const text = useText();
|
|
7
7
|
const isLoading = useIsLoading();
|
|
8
8
|
const isUploading = useIsUploading();
|
|
9
|
-
console.log('Input textarea render');
|
|
9
|
+
console.log('Input textarea render', text);
|
|
10
10
|
const handleKeyDown = (e)=>{
|
|
11
11
|
if ('Enter' === e.key) {
|
|
12
12
|
if (getIsComposing() || e.nativeEvent.isComposing) return;
|
|
13
13
|
if (e.shiftKey) return;
|
|
14
14
|
e.preventDefault();
|
|
15
|
-
|
|
15
|
+
onSubmit();
|
|
16
16
|
}
|
|
17
17
|
};
|
|
18
18
|
return /*#__PURE__*/ jsx(Textarea, {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const getFile: () => File | undefined;
|
|
2
|
+
export declare const useFile: () => File | undefined;
|
|
3
|
+
export declare const setFile: (file: File | undefined) => void;
|
|
4
|
+
export declare const useIsUploading: () => boolean;
|
|
5
|
+
export declare const setIsUploading: (isUploading: boolean) => void;
|
|
6
|
+
export type Accept = ('text' | 'image' | 'pdf' | 'word' | 'excel')[];
|
|
7
|
+
export declare const getAccept: () => string;
|
|
8
|
+
export declare const setAccept: (accept: Accept) => void;
|
|
@@ -1,20 +1,12 @@
|
|
|
1
1
|
import { useStore } from "@nanostores/react";
|
|
2
2
|
import { atom } from "nanostores";
|
|
3
|
-
const $
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const getIsComposing = ()=>$isComposing.get();
|
|
8
|
-
const setIsComposing = (isComposing)=>$isComposing.set(isComposing);
|
|
3
|
+
const $file = atom();
|
|
4
|
+
const getFile = ()=>$file.get();
|
|
5
|
+
const useFile = ()=>useStore($file);
|
|
6
|
+
const setFile = (file)=>$file.set(file);
|
|
9
7
|
const $isUploading = atom(false);
|
|
10
8
|
const useIsUploading = ()=>useStore($isUploading);
|
|
11
9
|
const setIsUploading = (isUploading)=>$isUploading.set(isUploading);
|
|
12
|
-
const $file = atom(null);
|
|
13
|
-
const useFile = ()=>useStore($file);
|
|
14
|
-
const setFile = (file)=>$file.set(file);
|
|
15
|
-
const $onSubmit = atom(()=>()=>{});
|
|
16
|
-
const getOnSubmit = ()=>$onSubmit.get();
|
|
17
|
-
const setOnSubmit = (onSubmit)=>$onSubmit.set(onSubmit);
|
|
18
10
|
const $accept = atom([
|
|
19
11
|
'text',
|
|
20
12
|
'image',
|
|
@@ -37,4 +29,4 @@ const getAccept = ()=>$accept.get().map((type)=>{
|
|
|
37
29
|
}
|
|
38
30
|
}).join(',');
|
|
39
31
|
const setAccept = (accept)=>$accept.set(accept);
|
|
40
|
-
export { getAccept,
|
|
32
|
+
export { getAccept, getFile, setAccept, setFile, setIsUploading, useFile, useIsUploading };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { notifications } from "@mantine/notifications";
|
|
2
|
+
const serverErrorCodes = {
|
|
3
|
+
unknown: 'Неизвестная ошибка',
|
|
4
|
+
invalid_request: 'Неверный запрос',
|
|
5
|
+
aborted: 'Загрузка прервана',
|
|
6
|
+
rejected: 'Файл отклонен',
|
|
7
|
+
s3_upload: 'Ошибка при загрузке на S3',
|
|
8
|
+
no_files: 'Нет файлов для загрузки',
|
|
9
|
+
file_too_large: 'Один или несколько файлов слишком большие',
|
|
10
|
+
invalid_file_type: 'Один или несколько файлов неверного типа',
|
|
11
|
+
too_many_files: 'Слишком много файлов'
|
|
12
|
+
};
|
|
13
|
+
const fileErrorNotificaton = (error)=>{
|
|
14
|
+
notifications.show({
|
|
15
|
+
title: serverErrorCodes[error.type],
|
|
16
|
+
message: error.message,
|
|
17
|
+
color: 'red',
|
|
18
|
+
autoClose: 5000
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
export { fileErrorNotificaton };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { FileUIPart } from 'ai';
|
|
2
|
+
export declare const getText: () => string;
|
|
3
|
+
export declare const useText: () => string;
|
|
4
|
+
export declare const setText: (text: string) => void;
|
|
5
|
+
export declare const getIsComposing: () => boolean;
|
|
6
|
+
export declare const setIsComposing: (isComposing: boolean) => void;
|
|
7
|
+
export interface OnSubmitProps {
|
|
8
|
+
text: string;
|
|
9
|
+
file?: FileUIPart;
|
|
10
|
+
}
|
|
11
|
+
export declare const getOnSubmit: () => (props: OnSubmitProps) => void;
|
|
12
|
+
export declare const setOnSubmit: (onSubmit: (props: OnSubmitProps) => void) => void;
|
|
13
|
+
export declare const onSubmit: () => Promise<void>;
|
|
@@ -0,0 +1,80 @@
|
|
|
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
|
+
};
|
|
80
|
+
export { getIsComposing, getOnSubmit, getText, input_onSubmit as onSubmit, setIsComposing, setOnSubmit, setText, useText };
|
|
@@ -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 };
|
|
@@ -3,6 +3,7 @@ import type { ChatInit, FileUIPart, UIDataTypes, UIMessage, UIMessagePart, UIToo
|
|
|
3
3
|
export declare const $chatMessageIds: import("nanostores").PreinitializedWritableAtom<string[]> & object;
|
|
4
4
|
export declare const $chatMessages: import("nanostores").PreinitializedMapStore<Record<string, UIMessage<unknown, UIDataTypes, UITools>>> & object;
|
|
5
5
|
export declare const getChatMessage: (messageId: string) => UIMessage<unknown, UIDataTypes, UITools>;
|
|
6
|
+
export declare const addChatMessage: (newMessage: UIMessage) => void;
|
|
6
7
|
export declare const getChatMessages: <T extends UIMessage>() => T[];
|
|
7
8
|
export declare const setChatMessages: <T extends UIMessage>(messages: T[]) => void;
|
|
8
9
|
export declare const getIsEmpty: () => boolean;
|
|
@@ -7,6 +7,16 @@ import { setChatError, setChatStatus } from "./states.js";
|
|
|
7
7
|
const $chatMessageIds = atom([]);
|
|
8
8
|
const $chatMessages = map({});
|
|
9
9
|
const getChatMessage = (messageId)=>$chatMessages.get()[messageId];
|
|
10
|
+
const addChatMessage = (newMessage)=>{
|
|
11
|
+
$chatMessageIds.set([
|
|
12
|
+
...$chatMessageIds.get(),
|
|
13
|
+
newMessage.id
|
|
14
|
+
]);
|
|
15
|
+
$chatMessages.set({
|
|
16
|
+
...$chatMessages.get(),
|
|
17
|
+
[newMessage.id]: newMessage
|
|
18
|
+
});
|
|
19
|
+
};
|
|
10
20
|
const getChatMessages = ()=>$chatMessageIds.get().map((id)=>$chatMessages.get()[id]);
|
|
11
21
|
const setChatMessages = (messages)=>{
|
|
12
22
|
$chatMessageIds.set(messages.map((msg)=>msg.id));
|
|
@@ -75,4 +85,4 @@ const messages_sendMessage = async ({ text, file }, data)=>{
|
|
|
75
85
|
body: data
|
|
76
86
|
});
|
|
77
87
|
};
|
|
78
|
-
export { $chatMessageIds, $chatMessages, getChatMessage, getChatMessages, getIsEmpty, messages_sendMessage as sendMessage, setChatMessages, useChatMessage, useChatMessageIds, useChatMessagePart, useIsEmpty };
|
|
88
|
+
export { $chatMessageIds, $chatMessages, addChatMessage, getChatMessage, getChatMessages, getIsEmpty, messages_sendMessage as sendMessage, setChatMessages, useChatMessage, useChatMessageIds, useChatMessagePart, useIsEmpty };
|
package/dist/app/AppDefaults.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useComputedColorScheme } from "@mantine/core";
|
|
2
2
|
import { useEffect } from "react";
|
|
3
|
-
import { setCookies } from "../
|
|
3
|
+
import { setCookies } from "../tanstackFunctions/index.js";
|
|
4
4
|
const AppDefaults = ({ saveColorScheme })=>{
|
|
5
5
|
const colorScheme = useComputedColorScheme();
|
|
6
6
|
useEffect(()=>{
|
package/dist/app/DefaultApp.js
CHANGED
|
@@ -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 "../
|
|
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 "../
|
|
3
|
+
import { setCookie } from "../tanstackFunctions/index.js";
|
|
4
4
|
const $colorScheme = atom();
|
|
5
5
|
let unsubscribeSystemTheme;
|
|
6
6
|
const cookieColorSchemeManager = ({ key = 'colorScheme' } = {})=>({
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { custom } from "@better-upload/server/clients";
|
|
2
|
+
const getS3Client = ()=>{
|
|
3
|
+
const host = process.env.S3_HOST;
|
|
4
|
+
if (!host) throw new Error('S3_HOST environment variable is not set');
|
|
5
|
+
const region = process.env.S3_REGION;
|
|
6
|
+
if (!region) throw new Error('S3_REGION environment variable is not set');
|
|
7
|
+
const accessKeyId = process.env.S3_ACCESS_KEY_ID;
|
|
8
|
+
if (!accessKeyId) throw new Error('S3_ACCESS_KEY_ID environment variable is not set');
|
|
9
|
+
const accessKeySecret = process.env.S3_ACCESS_KEY_SECRET;
|
|
10
|
+
if (!accessKeySecret) throw new Error('S3_ACCESS_KEY_SECRET environment variable is not set');
|
|
11
|
+
return custom({
|
|
12
|
+
host,
|
|
13
|
+
region,
|
|
14
|
+
accessKeyId,
|
|
15
|
+
secretAccessKey: accessKeySecret
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
export { getS3Client };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { presignGetObject } from "@better-upload/server/helpers";
|
|
2
|
+
import { createServerFn } from "@tanstack/react-start";
|
|
3
|
+
import v4 from "zod/v4";
|
|
4
|
+
import { getS3Client } from "./getS3Client.js";
|
|
5
|
+
const Schema = v4.object({
|
|
6
|
+
s3Key: v4.string()
|
|
7
|
+
});
|
|
8
|
+
const getSignedFileUrlFn = createServerFn({
|
|
9
|
+
method: 'POST'
|
|
10
|
+
}).inputValidator(Schema).handler(async ({ data: { s3Key } })=>{
|
|
11
|
+
const bucket = process.env.S3_BUCKET_NAME;
|
|
12
|
+
if (!bucket) throw new Error('S3_BUCKET_NAME environment variable is not set');
|
|
13
|
+
const s3 = getS3Client();
|
|
14
|
+
const url = await presignGetObject(s3, {
|
|
15
|
+
bucket,
|
|
16
|
+
key: s3Key,
|
|
17
|
+
expiresIn: 300
|
|
18
|
+
});
|
|
19
|
+
return url;
|
|
20
|
+
});
|
|
21
|
+
export { getSignedFileUrlFn };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { handleRequest, route } from "@better-upload/server";
|
|
2
|
+
import { createServerOnlyFn } from "@tanstack/react-start";
|
|
3
|
+
import { getS3Client } from "./getS3Client.js";
|
|
4
|
+
const getRouter = createServerOnlyFn(()=>{
|
|
5
|
+
const bucket = process.env.BUCKET_NAME;
|
|
6
|
+
if (!bucket) throw new Error('BUCKET_NAME environment variable is not set');
|
|
7
|
+
const s3 = getS3Client();
|
|
8
|
+
const router = {
|
|
9
|
+
client: s3,
|
|
10
|
+
bucketName: bucket,
|
|
11
|
+
routes: {
|
|
12
|
+
upload: route({
|
|
13
|
+
multipleFiles: false,
|
|
14
|
+
maxFileSize: 52428800
|
|
15
|
+
})
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
return router;
|
|
19
|
+
});
|
|
20
|
+
const uploadRequest = async ({ request })=>handleRequest(request, getRouter());
|
|
21
|
+
export { uploadRequest };
|
package/dist/ui/JsonInput.js
CHANGED
|
@@ -5,7 +5,7 @@ import { linter } from "@codemirror/lint";
|
|
|
5
5
|
import { keymap } from "@codemirror/view";
|
|
6
6
|
import { vscodeDark, vscodeLight } from "@uiw/codemirror-theme-vscode";
|
|
7
7
|
import react_codemirror from "@uiw/react-codemirror";
|
|
8
|
-
import { getCookie } from "../
|
|
8
|
+
import { getCookie } from "../tanstackFunctions/index.js";
|
|
9
9
|
const formatJson = (view)=>{
|
|
10
10
|
try {
|
|
11
11
|
const text = view.state.doc.toString();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rolder/kit",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.34",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -26,43 +26,48 @@
|
|
|
26
26
|
"@types/js-cookie": "^3.0.6",
|
|
27
27
|
"@types/omgopass": "^3.2.3",
|
|
28
28
|
"@types/react": "^19.2.8",
|
|
29
|
-
"@typescript/native-preview": "^7.0.0-dev.
|
|
29
|
+
"@typescript/native-preview": "^7.0.0-dev.20260116.1",
|
|
30
30
|
"typescript": "^5.9.3"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"react": "^
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"@
|
|
33
|
+
"@ai-sdk/react": "^3.0.41",
|
|
34
|
+
"@better-upload/client": "^3.0.12",
|
|
35
|
+
"@better-upload/server": "^3.0.12",
|
|
36
|
+
"@codemirror/lang-json": "^6.0.2",
|
|
37
|
+
"@codemirror/lint": "^6.9.2",
|
|
38
|
+
"@mantine/core": "^8.3.12",
|
|
39
|
+
"@mantine/hooks": "^8.3.12",
|
|
40
|
+
"@mantine/notifications": "^8.3.12",
|
|
41
|
+
"@mantine/tiptap": "^8.3.12",
|
|
42
|
+
"@nanostores/react": "^1.0.0",
|
|
43
|
+
"@tanstack/react-form": "^1.27.7",
|
|
44
|
+
"@tanstack/react-query": "^5.90.18",
|
|
45
|
+
"@tanstack/react-router": "^1.150.0",
|
|
46
|
+
"@tanstack/react-router-ssr-query": "^1.150.0",
|
|
47
|
+
"@tanstack/react-start": "^1.150.0",
|
|
37
48
|
"@tiptap/extension-highlight": "^3.15.3",
|
|
38
49
|
"@tiptap/extension-placeholder": "^3.15.3",
|
|
39
50
|
"@tiptap/extension-table": "^3.15.3",
|
|
40
51
|
"@tiptap/extension-task-item": "^3.15.3",
|
|
41
52
|
"@tiptap/extension-task-list": "^3.15.3",
|
|
42
53
|
"@tiptap/extension-text-align": "^3.15.3",
|
|
54
|
+
"@tiptap/react": "^3.15.3",
|
|
43
55
|
"@tiptap/starter-kit": "^3.15.3",
|
|
44
|
-
"@codemirror/lang-json": "^6.0.2",
|
|
45
|
-
"@codemirror/lint": "^6.9.2",
|
|
46
56
|
"@uiw/codemirror-theme-vscode": "^4.25.4",
|
|
47
57
|
"@uiw/react-codemirror": "^4.25.4",
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"@mantine/tiptap": "^8.3.12",
|
|
51
|
-
"@mantine/notifications": "^8.3.12",
|
|
52
|
-
"@tanstack/react-router": "^1.150.0",
|
|
53
|
-
"@tanstack/react-form": "^1.27.7",
|
|
54
|
-
"@tanstack/react-start": "^1.150.0",
|
|
55
|
-
"@tanstack/react-query": "^5.90.17",
|
|
56
|
-
"@tanstack/react-router-ssr-query": "^1.150.0",
|
|
57
|
-
"zod": "^4.3.5",
|
|
58
|
+
"ai": "^6.0.39",
|
|
59
|
+
"clsx": "^2.1.1",
|
|
58
60
|
"js-cookie": "^3.0.5",
|
|
61
|
+
"mammoth": "^1.11.0",
|
|
62
|
+
"nanoid": "^5.1.6",
|
|
59
63
|
"nanostores": "^1.1.0",
|
|
60
|
-
"@nanostores/react": "^1.0.0",
|
|
61
|
-
"surrealdb": "^2.0.0-alpha.16",
|
|
62
64
|
"omgopass": "^3.2.1",
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"streamdown": "^2.0.1"
|
|
65
|
+
"react": "^19.2.3",
|
|
66
|
+
"react-dom": "^19.2.3",
|
|
67
|
+
"streamdown": "^2.0.1",
|
|
68
|
+
"surrealdb": "^2.0.0-alpha.16",
|
|
69
|
+
"xlsx": "^0.18.5",
|
|
70
|
+
"zod": "^4.3.5"
|
|
66
71
|
},
|
|
67
72
|
"trustedDependencies": [
|
|
68
73
|
"core-js",
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export declare const setText: (text: string) => void;
|
|
2
|
-
export declare const useText: () => string;
|
|
3
|
-
export declare const getIsComposing: () => boolean;
|
|
4
|
-
export declare const setIsComposing: (isComposing: boolean) => void;
|
|
5
|
-
export declare const useIsUploading: () => boolean;
|
|
6
|
-
export declare const setIsUploading: (isUploading: boolean) => void;
|
|
7
|
-
export declare const useFile: () => File | null;
|
|
8
|
-
export declare const setFile: (file: File | null) => void;
|
|
9
|
-
export declare const getOnSubmit: () => () => void;
|
|
10
|
-
export declare const setOnSubmit: (onSubmit: () => void) => void;
|
|
11
|
-
export type Accept = ('text' | 'image' | 'pdf' | 'word' | 'excel')[];
|
|
12
|
-
export declare const getAccept: () => string;
|
|
13
|
-
export declare const setAccept: (accept: Accept) => void;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|