[feat] node hosting support
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
import Sidebar from './lib/SideBars/Sidebar.svelte';
|
||||
import {ArrowRight} from 'lucide-svelte'
|
||||
import { SizeStore, settingsOpen, sideBarStore } from './ts/stores';
|
||||
import { DataBase, loadedStore } from './ts/database';
|
||||
import { DataBase, loadedStore } from './ts/storage/database';
|
||||
import ChatScreen from './lib/ChatScreens/ChatScreen.svelte';
|
||||
import AlertComp from './lib/Others/AlertComp.svelte';
|
||||
import { alertStore } from './ts/alert';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script>
|
||||
import { onMount } from 'svelte';
|
||||
import { DataBase } from "../../ts/database";
|
||||
import { DataBase } from "../../ts/storage/database";
|
||||
|
||||
let textarea;
|
||||
let previousScrollHeight = 0;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import AutoresizeArea from "./AutoresizeArea.svelte";
|
||||
import { alertConfirm } from "../../ts/alert";
|
||||
import { language } from "../../lang";
|
||||
import { DataBase, type character, type groupChat } from "../../ts/database";
|
||||
import { DataBase, type character, type groupChat } from "../../ts/storage/database";
|
||||
import { selectedCharID } from "../../ts/stores";
|
||||
import { translate } from "../../ts/translator/translator";
|
||||
import { replacePlaceholders } from "../../ts/util";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { getCustomBackground, getEmotion } from "../../ts/util";
|
||||
import { DataBase } from "../../ts/database";
|
||||
import { DataBase } from "../../ts/storage/database";
|
||||
import { CharEmotion, SizeStore, selectedCharID, sideBarStore } from "../../ts/stores";
|
||||
import ResizeBox from './ResizeBox.svelte'
|
||||
import DefaultChatScreen from "./DefaultChatScreen.svelte";
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import { DatabaseIcon, DicesIcon, LanguagesIcon, MenuIcon, MicOffIcon, RefreshCcwIcon, Send } from "lucide-svelte";
|
||||
import { selectedCharID } from "../../ts/stores";
|
||||
import Chat from "./Chat.svelte";
|
||||
import { DataBase, appVer, type Message } from "../../ts/database";
|
||||
import { DataBase, appVer, type Message } from "../../ts/storage/database";
|
||||
import { getCharImage } from "../../ts/characters";
|
||||
import { doingChat, sendChat } from "../../ts/process/index";
|
||||
import { findCharacterbyId, messageForm, sleep } from "../../ts/util";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script>
|
||||
import { DataBase } from '../../ts/database';
|
||||
import { DataBase } from '../../ts/storage/database';
|
||||
import { CharEmotion } from '../../ts/stores';
|
||||
import { getEmotion } from '../../ts/util';
|
||||
</script>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import EmotionBox from './EmotionBox.svelte';
|
||||
import TransitionImage from './TransitionImage.svelte';
|
||||
import { getEmotion } from '../../ts/util';
|
||||
import { DataBase } from '../../ts/database';
|
||||
import { DataBase } from '../../ts/storage/database';
|
||||
|
||||
let box;
|
||||
let isResizing = false;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script>
|
||||
import { onMount } from 'svelte';
|
||||
import { alertStore } from "../../ts/alert";
|
||||
import { DataBase } from '../../ts/database';
|
||||
import { DataBase } from '../../ts/storage/database';
|
||||
import { getCharImage } from '../../ts/characters';
|
||||
import { ParseMarkdown } from '../../ts/parser';
|
||||
import BarIcon from '../SideBars/BarIcon.svelte';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script>
|
||||
import { alertConfirm, alertError } from "../../ts/alert";
|
||||
import { language } from "../../lang";
|
||||
import { DataBase } from "../../ts/database";
|
||||
import { DataBase } from "../../ts/storage/database";
|
||||
import { selectedCharID } from "../../ts/stores";
|
||||
import { DownloadIcon, EditIcon, FolderUpIcon, PlusIcon, TrashIcon, XIcon } from "lucide-svelte";
|
||||
import { exportChat, importChat } from "../../ts/characters";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { isTauri, openURL } from "src/ts/globalApi";
|
||||
import { isTauri, openURL } from "src/ts/storage/globalApi";
|
||||
|
||||
</script>
|
||||
<svelte:head>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { characterFormatUpdate, getCharImage } from "../../ts/characters";
|
||||
import { DataBase } from "../../ts/database";
|
||||
import { DataBase } from "../../ts/storage/database";
|
||||
import BarIcon from "../SideBars/BarIcon.svelte";
|
||||
import { User, Users } from "lucide-svelte";
|
||||
import { selectedCharID } from "../../ts/stores";
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import { ArrowBigLeftIcon } from "lucide-svelte";
|
||||
import { changeLanguage, language } from "src/lang";
|
||||
import { addDefaultCharacters } from "src/ts/characters";
|
||||
import { DataBase } from "src/ts/database";
|
||||
import { DataBase } from "src/ts/storage/database";
|
||||
import { sleep } from "src/ts/util";
|
||||
|
||||
let step = 0
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import Check from "src/lib/Others/Check.svelte";
|
||||
import { language } from "src/lang";
|
||||
import { DataBase } from "src/ts/database";
|
||||
import { DataBase } from "src/ts/storage/database";
|
||||
|
||||
</script>
|
||||
<h2 class="mb-2 text-2xl font-bold mt-2">{language.accessibility}</h2>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
import Check from "src/lib/Others/Check.svelte";
|
||||
import { language } from "src/lang";
|
||||
import Help from "src/lib/Others/Help.svelte";
|
||||
import { DataBase } from "src/ts/database";
|
||||
import { DataBase } from "src/ts/storage/database";
|
||||
import { alertMd } from "src/ts/alert";
|
||||
import { getRequestLog, isTauri } from "src/ts/globalApi";
|
||||
import { getRequestLog, isTauri } from "src/ts/storage/globalApi";
|
||||
|
||||
</script>
|
||||
<h2 class="text-2xl font-bold mt-2">{language.advancedSettings}</h2>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
import Check from "src/lib/Others/Check.svelte";
|
||||
import { language } from "src/lang";
|
||||
import Help from "src/lib/Others/Help.svelte";
|
||||
import { DataBase } from "src/ts/database";
|
||||
import { DataBase } from "src/ts/storage/database";
|
||||
import { customProviderStore, getCurrentPluginMax } from "src/ts/process/plugins";
|
||||
import { isTauri } from "src/ts/globalApi";
|
||||
import { isTauri } from "src/ts/storage/globalApi";
|
||||
import { tokenize } from "src/ts/tokenizer";
|
||||
import ModelList from "src/lib/UI/ModelList.svelte";
|
||||
import DropList from "src/lib/SideBars/DropList.svelte";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { language } from "src/lang";
|
||||
import { openURL } from "src/ts/globalApi";
|
||||
import { openURL } from "src/ts/storage/globalApi";
|
||||
</script>
|
||||
|
||||
<h2 class="mb-2 text-2xl font-bold mt-2">{language.community}</h2>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { language } from "src/lang";
|
||||
import { DataBase, saveImage, updateTextTheme } from "src/ts/database";
|
||||
import { DataBase, saveImage, updateTextTheme } from "src/ts/storage/database";
|
||||
import { changeFullscreen, selectSingleFile, sleep } from "src/ts/util";
|
||||
import Check from "src/lib/Others/Check.svelte";
|
||||
import Help from "src/lib/Others/Help.svelte";
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import { language } from "src/lang";
|
||||
import { alertConfirm } from "src/ts/alert";
|
||||
import { checkDriver } from "src/ts/drive/drive";
|
||||
import { isTauri } from "src/ts/globalApi";
|
||||
import { isTauri } from "src/ts/storage/globalApi";
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import { language } from "src/lang";
|
||||
import Help from "src/lib/Others/Help.svelte";
|
||||
import LoreBookSetting from "src/lib/SideBars/LoreBookSetting.svelte";
|
||||
import { DataBase } from "src/ts/database";
|
||||
import { DataBase } from "src/ts/storage/database";
|
||||
export let openLoreList = false
|
||||
</script>
|
||||
<h2 class="mb-2 text-2xl font-bold mt-2">{language.globalLoreBook} <Help key="lorebook" /></h2>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import { language } from "src/lang";
|
||||
import Help from "src/lib/Others/Help.svelte";
|
||||
import RegexData from "src/lib/SideBars/RegexData.svelte";
|
||||
import { DataBase } from "src/ts/database";
|
||||
import { DataBase } from "src/ts/storage/database";
|
||||
import { exportRegex, importRegex } from "src/ts/process/scripts";
|
||||
</script>
|
||||
<h2 class="mb-2 text-2xl font-bold mt-2">{language.globalRegexScript} <Help key="regexScript" /></h2>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import Check from "src/lib/Others/Check.svelte";
|
||||
import { changeLanguage, language } from "src/lang";
|
||||
import { DataBase } from "src/ts/database";
|
||||
import { DataBase } from "src/ts/storage/database";
|
||||
import { sleep } from "src/ts/util";
|
||||
let langChanged = false
|
||||
</script>
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
import Check from "src/lib/Others/Check.svelte";
|
||||
import { language } from "src/lang";
|
||||
import Help from "src/lib/Others/Help.svelte";
|
||||
import { DataBase } from "src/ts/database";
|
||||
import { isTauri } from "src/ts/globalApi";
|
||||
import { DataBase } from "src/ts/storage/database";
|
||||
import { isTauri } from "src/ts/storage/globalApi";
|
||||
|
||||
</script>
|
||||
<h2 class="mb-2 text-2xl font-bold mt-2">{language.otherBots}</h2>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import { PlusIcon, TrashIcon } from "lucide-svelte";
|
||||
import { language } from "src/lang";
|
||||
import { alertConfirm } from "src/ts/alert";
|
||||
import { DataBase } from "src/ts/database";
|
||||
import { DataBase } from "src/ts/storage/database";
|
||||
import { importPlugin } from "src/ts/process/plugins";
|
||||
|
||||
</script>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script>
|
||||
import { language } from "src/lang";
|
||||
import { getCharImage, selectUserImg } from "src/ts/characters";
|
||||
import { DataBase } from "src/ts/database";
|
||||
import { DataBase } from "src/ts/storage/database";
|
||||
</script>
|
||||
|
||||
<h2 class="mb-2 text-2xl font-bold mt-2">{language.user}</h2>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script>
|
||||
import { alertConfirm, alertError } from "../../ts/alert";
|
||||
import { language } from "../../lang";
|
||||
import { DataBase, changeToPreset, copyPreset, presetTemplate } from "../../ts/database";
|
||||
import { DataBase, changeToPreset, copyPreset, presetTemplate } from "../../ts/storage/database";
|
||||
import { CopyIcon, EditIcon, PlusIcon, TrashIcon, XIcon } from "lucide-svelte";
|
||||
|
||||
let editMode = false
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script>
|
||||
import { alertConfirm, alertError } from "../../ts/alert";
|
||||
import { language } from "../../lang";
|
||||
import { DataBase } from "../../ts/database";
|
||||
import { DataBase } from "../../ts/storage/database";
|
||||
import { EditIcon, PlusIcon, TrashIcon, XIcon } from "lucide-svelte";
|
||||
let editMode = false
|
||||
export let close = () => {}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { language } from "../../lang";
|
||||
import { tokenize } from "../../ts/tokenizer";
|
||||
import { DataBase, saveImage as saveAsset, type Database, type character, type groupChat } from "../../ts/database";
|
||||
import { DataBase, saveImage as saveAsset, type Database, type character, type groupChat } from "../../ts/storage/database";
|
||||
import { selectedCharID } from "../../ts/stores";
|
||||
import { PlusIcon, SmileIcon, TrashIcon, UserIcon, ActivityIcon, BookIcon, LoaderIcon, User, DnaIcon, CurlyBracesIcon, Volume2Icon } from 'lucide-svelte'
|
||||
import Check from "../Others/Check.svelte";
|
||||
@@ -16,7 +16,7 @@
|
||||
import RegexData from "./RegexData.svelte";
|
||||
import { exportChar } from "src/ts/characterCards";
|
||||
import { getElevenTTSVoices, getWebSpeechTTSVoices, getVOICEVOXVoices } from "src/ts/process/tts";
|
||||
import { checkCharOrder } from "src/ts/globalApi";
|
||||
import { checkCharOrder } from "src/ts/storage/globalApi";
|
||||
|
||||
let subMenu = 0
|
||||
let subberMenu = 0
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { XIcon } from "lucide-svelte";
|
||||
import { language } from "../../lang";
|
||||
import type { loreBook } from "../../ts/database";
|
||||
import type { loreBook } from "../../ts/storage/database";
|
||||
import { alertConfirm } from "../../ts/alert";
|
||||
import Check from "../Others/Check.svelte";
|
||||
import Help from "../Others/Help.svelte";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { DataBase } from "../../ts/database";
|
||||
import { DataBase } from "../../ts/storage/database";
|
||||
import { language } from "../../lang";
|
||||
import {selectedCharID} from '../../ts/stores'
|
||||
import { DownloadIcon, FolderUpIcon, ImportIcon, PlusIcon } from "lucide-svelte";
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import { XIcon } from "lucide-svelte";
|
||||
import { language } from "src/lang";
|
||||
import { alertConfirm } from "src/ts/alert";
|
||||
import type { customscript } from "src/ts/database";
|
||||
import type { customscript } from "src/ts/storage/database";
|
||||
|
||||
export let value:customscript
|
||||
export let onRemove: () => void = () => {}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
settingsOpen,
|
||||
sideBarStore,
|
||||
} from "../../ts/stores";
|
||||
import { DataBase, setDatabase, type folder } from "../../ts/database";
|
||||
import { DataBase, setDatabase, type folder } from "../../ts/storage/database";
|
||||
import BarIcon from "./BarIcon.svelte";
|
||||
import SidebarIndicator from "./SidebarIndicator.svelte";
|
||||
import {
|
||||
@@ -41,7 +41,7 @@
|
||||
import { get } from "svelte/store";
|
||||
import { findCharacterIndexbyId, findCharacterbyId, getCharacterIndexObject } from "src/ts/util";
|
||||
import { v4 } from "uuid";
|
||||
import { checkCharOrder } from "src/ts/globalApi";
|
||||
import { checkCharOrder } from "src/ts/storage/globalApi";
|
||||
let openPresetList = false;
|
||||
let sideBarMode = 0;
|
||||
let editMode = false;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { DataBase } from "src/ts/database";
|
||||
import { DataBase } from "src/ts/storage/database";
|
||||
import { getHordeModels } from "src/ts/horde/getModels";
|
||||
import Arcodion from "./Arcodion.svelte";
|
||||
import { language } from "src/lang";
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import "./styles.css";
|
||||
import "core-js/actual"
|
||||
import App from "./App.svelte";
|
||||
import { loadData } from "./ts/globalApi";
|
||||
import { loadData } from "./ts/storage/globalApi";
|
||||
import { initHotkey } from "./ts/hotkey";
|
||||
import { polyfill } from "./ts/polyfill";
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { get } from "svelte/store"
|
||||
import { alertConfirm, alertError, alertNormal, alertSelect, alertStore } from "./alert"
|
||||
import { DataBase, defaultSdDataFunc, type character, setDatabase, type customscript, type loreSettings, type loreBook } from "./database"
|
||||
import { DataBase, defaultSdDataFunc, type character, setDatabase, type customscript, type loreSettings, type loreBook } from "./storage/database"
|
||||
import { checkNullish, selectMultipleFile, selectSingleFile, sleep } from "./util"
|
||||
import { language } from "src/lang"
|
||||
import { encode as encodeMsgpack, decode as decodeMsgpack } from "@msgpack/msgpack";
|
||||
@@ -8,7 +8,7 @@ import { v4 as uuidv4 } from 'uuid';
|
||||
import exifr from 'exifr'
|
||||
import { PngMetadata } from "./exif"
|
||||
import { characterFormatUpdate } from "./characters"
|
||||
import { checkCharOrder, downloadFile, readImage, saveAsset } from "./globalApi"
|
||||
import { checkCharOrder, downloadFile, readImage, saveAsset } from "./storage/globalApi"
|
||||
import { cloneDeep } from "lodash"
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { get, writable } from "svelte/store";
|
||||
import { DataBase, saveImage, setDatabase, type character, type Chat, defaultSdDataFunc } from "./database";
|
||||
import { DataBase, saveImage, setDatabase, type character, type Chat, defaultSdDataFunc } from "./storage/database";
|
||||
import exifr from 'exifr'
|
||||
import { alertConfirm, alertError, alertNormal, alertSelect, alertStore } from "./alert";
|
||||
import { language } from "../lang";
|
||||
@@ -8,7 +8,7 @@ import { encode as encodeMsgpack, decode as decodeMsgpack } from "@msgpack/msgpa
|
||||
import { checkNullish, findCharacterbyId, selectMultipleFile, selectSingleFile, sleep } from "./util";
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { selectedCharID } from "./stores";
|
||||
import { checkCharOrder, downloadFile, getFileSrc, readImage } from "./globalApi";
|
||||
import { checkCharOrder, downloadFile, getFileSrc, readImage } from "./storage/globalApi";
|
||||
|
||||
export function createNewCharacter() {
|
||||
let db = get(DataBase)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { get } from "svelte/store";
|
||||
import { alertError, alertInput, alertNormal, alertSelect, alertStore } from "../alert";
|
||||
import { DataBase, setDatabase, type Database } from "../database";
|
||||
import { forageStorage, getUnpargeables, isTauri } from "../globalApi";
|
||||
import { DataBase, setDatabase, type Database } from "../storage/database";
|
||||
import { forageStorage, getUnpargeables, isTauri } from "../storage/globalApi";
|
||||
import pako from "pako";
|
||||
import { BaseDirectory, exists, readBinaryFile, readDir, writeBinaryFile } from "@tauri-apps/api/fs";
|
||||
import { language } from "../../lang";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { get } from "svelte/store"
|
||||
import { alertToast, doingAlert } from "./alert"
|
||||
import { DataBase, changeToPreset as changeToPreset2 } from "./database"
|
||||
import { DataBase, changeToPreset as changeToPreset2 } from "./storage/database"
|
||||
|
||||
export function initHotkey(){
|
||||
document.addEventListener('keydown', (ev) => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import DOMPurify from 'isomorphic-dompurify';
|
||||
import showdown from 'showdown';
|
||||
import type { character, groupChat } from './database';
|
||||
import { getFileSrc } from './globalApi';
|
||||
import type { character, groupChat } from './storage/database';
|
||||
import { getFileSrc } from './storage/globalApi';
|
||||
import { processScript } from './process/scripts';
|
||||
|
||||
const convertor = new showdown.Converter({
|
||||
|
||||
@@ -19,6 +19,9 @@ export function polyfill() {
|
||||
forceApply: true
|
||||
});
|
||||
}
|
||||
else{
|
||||
console.log("supports dragdrop")
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { OpenAIChat } from ".";
|
||||
import type { character } from "../database";
|
||||
import type { character } from "../storage/database";
|
||||
import { replacePlaceholders } from "../util";
|
||||
|
||||
export function exampleMessage(char:character):OpenAIChat[]{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { get, writable } from "svelte/store";
|
||||
import { DataBase, setDatabase, type character } from "../database";
|
||||
import { DataBase, setDatabase, type character } from "../storage/database";
|
||||
import { CharEmotion, selectedCharID } from "../stores";
|
||||
import { tokenize, tokenizeNum } from "../tokenizer";
|
||||
import { language } from "../../lang";
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { get } from "svelte/store";
|
||||
import {selectedCharID} from '../stores'
|
||||
import { DataBase, setDatabase, type loreBook } from "../database";
|
||||
import { DataBase, setDatabase, type loreBook } from "../storage/database";
|
||||
import { tokenize } from "../tokenizer";
|
||||
import { selectSingleFile } from "../util";
|
||||
import { alertError, alertNormal } from "../alert";
|
||||
import { language } from "../../lang";
|
||||
import { downloadFile } from "../globalApi";
|
||||
import { downloadFile } from "../storage/globalApi";
|
||||
|
||||
export function addLorebook(type:number) {
|
||||
let selectedID = get(selectedCharID)
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { get, writable } from "svelte/store";
|
||||
import { language } from "../../lang";
|
||||
import { alertError } from "../alert";
|
||||
import { DataBase } from "../database";
|
||||
import { DataBase } from "../storage/database";
|
||||
import { checkNullish, selectSingleFile, sleep } from "../util";
|
||||
import type { OpenAIChat } from ".";
|
||||
import { globalFetch } from "../globalApi";
|
||||
import { globalFetch } from "../storage/globalApi";
|
||||
import { selectedCharID } from "../stores";
|
||||
|
||||
export const customProviderStore = writable([] as string[])
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { get } from "svelte/store";
|
||||
import type { OpenAIChat } from ".";
|
||||
import { DataBase, setDatabase, type character } from "../database";
|
||||
import { DataBase, setDatabase, type character } from "../storage/database";
|
||||
import { pluginProcess } from "./plugins";
|
||||
import { language } from "../../lang";
|
||||
import { stringlizeChat, unstringlizeChat } from "./stringlize";
|
||||
import { globalFetch, isTauri } from "../globalApi";
|
||||
import { globalFetch, isTauri } from "../storage/globalApi";
|
||||
import { alertError } from "../alert";
|
||||
import { sleep } from "../util";
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { get } from "svelte/store";
|
||||
import { CharEmotion, selectedCharID } from "../stores";
|
||||
import { DataBase, setDatabase, type character, type customscript } from "../database";
|
||||
import { downloadFile } from "../globalApi";
|
||||
import { DataBase, setDatabase, type character, type customscript } from "../storage/database";
|
||||
import { downloadFile } from "../storage/globalApi";
|
||||
import { alertError, alertNormal } from "../alert";
|
||||
import { language } from "src/lang";
|
||||
import { selectSingleFile } from "../util";
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { get } from "svelte/store"
|
||||
import { DataBase, type character } from "../database"
|
||||
import { DataBase, type character } from "../storage/database"
|
||||
import { requestChatData } from "./request"
|
||||
import { alertError } from "../alert"
|
||||
import { globalFetch } from "../globalApi"
|
||||
import { globalFetch } from "../storage/globalApi"
|
||||
import { CharEmotion } from "../stores"
|
||||
import type { OpenAIChat } from "."
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { get } from "svelte/store";
|
||||
import type { OpenAIChat } from ".";
|
||||
import { DataBase, type Chat, type character, type groupChat } from "../database";
|
||||
import { DataBase, type Chat, type character, type groupChat } from "../storage/database";
|
||||
import { tokenize } from "../tokenizer";
|
||||
import { findCharacterbyId } from "../util";
|
||||
import { requestChatData } from "./request";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { get } from "svelte/store";
|
||||
import { alertError } from "../alert";
|
||||
import { DataBase, type character } from "../database";
|
||||
import { DataBase, type character } from "../storage/database";
|
||||
import { translateVox } from "../translator/translator";
|
||||
|
||||
let sourceNode:AudioBufferSourceNode = null
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { get, writable } from 'svelte/store';
|
||||
import { checkNullish } from './util';
|
||||
import { changeLanguage } from '../lang';
|
||||
import type { RisuPlugin } from './process/plugins';
|
||||
import { checkNullish } from '../util';
|
||||
import { changeLanguage } from '../../lang';
|
||||
import type { RisuPlugin } from '../process/plugins';
|
||||
import { saveAsset as saveImageGlobal } from './globalApi';
|
||||
import { cloneDeep } from 'lodash';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { writeBinaryFile,BaseDirectory, readBinaryFile, exists, createDir, readDir, removeFile } from "@tauri-apps/api/fs"
|
||||
import { changeFullscreen, checkNullish, findCharacterbyId, sleep } from "./util"
|
||||
import { changeFullscreen, checkNullish, findCharacterbyId, sleep } from "../util"
|
||||
import localforage from 'localforage'
|
||||
import { convertFileSrc, invoke } from "@tauri-apps/api/tauri"
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
@@ -9,19 +9,22 @@ import {open} from '@tauri-apps/api/shell'
|
||||
import { DataBase, loadedStore, setDatabase, type Database, updateTextTheme, defaultSdDataFunc } from "./database";
|
||||
import pako from "pako";
|
||||
import { appWindow } from "@tauri-apps/api/window";
|
||||
import { checkOldDomain, checkUpdate } from "./update";
|
||||
import { selectedCharID } from "./stores";
|
||||
import { checkOldDomain, checkUpdate } from "../update";
|
||||
import { selectedCharID } from "../stores";
|
||||
import { Body, ResponseType, fetch as TauriFetch } from "@tauri-apps/api/http";
|
||||
import { loadPlugins } from "./process/plugins";
|
||||
import { alertError, alertStore } from "./alert";
|
||||
import { checkDriverInit } from "./drive/drive";
|
||||
import { hasher } from "./parser";
|
||||
import { characterHubImport } from "./characterCards";
|
||||
import { loadPlugins } from "../process/plugins";
|
||||
import { alertError, alertStore } from "../alert";
|
||||
import { checkDriverInit } from "../drive/drive";
|
||||
import { hasher } from "../parser";
|
||||
import { characterHubImport } from "../characterCards";
|
||||
import { cloneDeep } from "lodash";
|
||||
import { NodeStorage } from "./nodeStorage";
|
||||
|
||||
//@ts-ignore
|
||||
export const isTauri = !!window.__TAURI__
|
||||
export const forageStorage = localforage.createInstance({
|
||||
//@ts-ignore
|
||||
export const isNodeServer = !!globalThis.__NODE__
|
||||
export const forageStorage = isNodeServer ? new NodeStorage() : localforage.createInstance({
|
||||
name: "risuai"
|
||||
})
|
||||
|
||||
@@ -554,7 +557,8 @@ export async function globalFetch(url:string, arg:{body?:any,headers?:{[key:stri
|
||||
const da = await fetch(furl, {
|
||||
body: JSON.stringify(arg.body),
|
||||
headers: {
|
||||
"risu-header": encodeURIComponent(JSON.stringify(arg.headers))
|
||||
"risu-header": encodeURIComponent(JSON.stringify(arg.headers)),
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
method: method
|
||||
})
|
||||
@@ -571,7 +575,8 @@ export async function globalFetch(url:string, arg:{body?:any,headers?:{[key:stri
|
||||
const da = await fetch(furl, {
|
||||
body: JSON.stringify(arg.body),
|
||||
headers: {
|
||||
"risu-header": encodeURIComponent(JSON.stringify(arg.headers))
|
||||
"risu-header": encodeURIComponent(JSON.stringify(arg.headers)),
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
method: method
|
||||
})
|
||||
73
src/ts/storage/nodeStorage.ts
Normal file
73
src/ts/storage/nodeStorage.ts
Normal file
@@ -0,0 +1,73 @@
|
||||
|
||||
export class NodeStorage{
|
||||
async setItem(key:string, value:Uint8Array) {
|
||||
const da = await fetch('/api/write', {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
content: Buffer.from(value).toString('base64')
|
||||
}),
|
||||
headers: {
|
||||
'content-type': 'application/json',
|
||||
'file-path': Buffer.from(key, 'utf-8').toString('hex')
|
||||
}
|
||||
})
|
||||
if(da.status < 200 || da.status >= 300){
|
||||
throw "setItem Error"
|
||||
}
|
||||
const data = await da.json()
|
||||
if(data.error){
|
||||
throw data.error
|
||||
}
|
||||
|
||||
}
|
||||
async getItem(key:string):Promise<Buffer> {
|
||||
const da = await fetch('/api/read', {
|
||||
method: "GET",
|
||||
headers: {
|
||||
'file-path': Buffer.from(key, 'utf-8').toString('hex')
|
||||
}
|
||||
})
|
||||
const data = await da.json()
|
||||
if(da.status < 200 || da.status >= 300){
|
||||
throw "getItem Error"
|
||||
}
|
||||
if(data.error){
|
||||
throw data.error
|
||||
}
|
||||
if(data.content === null){
|
||||
return null
|
||||
}
|
||||
return Buffer.from(data.content, 'base64')
|
||||
}
|
||||
async keys():Promise<string[]>{
|
||||
const da = await fetch('/api/list', {
|
||||
method: "GET",
|
||||
})
|
||||
const data = await da.json()
|
||||
if(da.status < 200 || da.status >= 300){
|
||||
throw "listItem Error"
|
||||
}
|
||||
if(data.error){
|
||||
throw data.error
|
||||
}
|
||||
return data.content
|
||||
}
|
||||
async removeItem(key:string){
|
||||
const da = await fetch('/api/list', {
|
||||
method: "GET",
|
||||
headers: {
|
||||
'file-path': Buffer.from(key, 'utf-8').toString('hex')
|
||||
}
|
||||
})
|
||||
if(da.status < 200 || da.status >= 300){
|
||||
throw "removeItem Error"
|
||||
}
|
||||
const data = await da.json()
|
||||
if(data.error){
|
||||
throw data.error
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
listItem = this.keys
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { Tiktoken } from "@dqbd/tiktoken";
|
||||
import type { character } from "./database";
|
||||
import type { character } from "./storage/database";
|
||||
|
||||
async function encode(data:string):Promise<(number[]|Uint32Array)>{
|
||||
return await tikJS(data)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { get } from "svelte/store"
|
||||
import { translatorPlugin } from "../process/plugins"
|
||||
import { DataBase } from "../database"
|
||||
import { DataBase } from "../storage/database"
|
||||
|
||||
let cache={
|
||||
origin: [''],
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { fetch } from "@tauri-apps/api/http";
|
||||
import { DataBase, appVer, setDatabase } from "./database";
|
||||
import { DataBase, appVer, setDatabase } from "./storage/database";
|
||||
import { alertConfirm, alertMd } from "./alert";
|
||||
import { language } from "../lang";
|
||||
import { get } from "svelte/store";
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { get } from "svelte/store"
|
||||
import type { Database, Message } from "./database"
|
||||
import { DataBase } from "./database"
|
||||
import type { Database, Message } from "./storage/database"
|
||||
import { DataBase } from "./storage/database"
|
||||
import { selectedCharID } from "./stores"
|
||||
import {open} from '@tauri-apps/api/dialog'
|
||||
import { readBinaryFile } from "@tauri-apps/api/fs"
|
||||
import { basename } from "@tauri-apps/api/path"
|
||||
import { createBlankChar, getCharImage } from "./characters"
|
||||
import { appWindow } from '@tauri-apps/api/window';
|
||||
import { isTauri } from "./globalApi"
|
||||
import { isTauri } from "./storage/globalApi"
|
||||
|
||||
export interface Messagec extends Message{
|
||||
index: number
|
||||
|
||||
Reference in New Issue
Block a user