fix structuredclone
This commit is contained in:
@@ -13,22 +13,22 @@ export let language:typeof languageEnglish = languageEnglish
|
|||||||
|
|
||||||
export function changeLanguage(lang:string){
|
export function changeLanguage(lang:string){
|
||||||
if(lang === 'cn'){
|
if(lang === 'cn'){
|
||||||
language = merge(structuredClone(languageEnglish), languageChinese)
|
language = merge(safeStructuredClone(languageEnglish), languageChinese)
|
||||||
}
|
}
|
||||||
else if(lang === 'de'){
|
else if(lang === 'de'){
|
||||||
language = merge(structuredClone(languageEnglish), languageGerman)
|
language = merge(safeStructuredClone(languageEnglish), languageGerman)
|
||||||
}
|
}
|
||||||
else if(lang === 'ko'){
|
else if(lang === 'ko'){
|
||||||
language = merge(structuredClone(languageEnglish), languageKorean)
|
language = merge(safeStructuredClone(languageEnglish), languageKorean)
|
||||||
}
|
}
|
||||||
else if(lang === 'vi'){
|
else if(lang === 'vi'){
|
||||||
language = merge(structuredClone(languageEnglish), LanguageVietnamese)
|
language = merge(safeStructuredClone(languageEnglish), LanguageVietnamese)
|
||||||
}
|
}
|
||||||
else if(lang === 'zh-Hant'){
|
else if(lang === 'zh-Hant'){
|
||||||
language = merge(structuredClone(languageEnglish), languageChineseTraditional)
|
language = merge(safeStructuredClone(languageEnglish), languageChineseTraditional)
|
||||||
}
|
}
|
||||||
else if(lang === 'es'){
|
else if(lang === 'es'){
|
||||||
language = merge(structuredClone(languageEnglish), languageSpanish)
|
language = merge(safeStructuredClone(languageEnglish), languageSpanish)
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
language = languageEnglish
|
language = languageEnglish
|
||||||
|
|||||||
@@ -141,7 +141,7 @@
|
|||||||
if(rerollid < rerolls.length - 1){
|
if(rerollid < rerolls.length - 1){
|
||||||
if(Array.isArray(rerolls[rerollid + 1])){
|
if(Array.isArray(rerolls[rerollid + 1])){
|
||||||
rerollid += 1
|
rerollid += 1
|
||||||
let rerollData = structuredClone(rerolls[rerollid])
|
let rerollData = safeStructuredClone(rerolls[rerollid])
|
||||||
let msgs = DBState.db.characters[$selectedCharID].chats[DBState.db.characters[$selectedCharID].chatPage].message
|
let msgs = DBState.db.characters[$selectedCharID].chats[DBState.db.characters[$selectedCharID].chatPage].message
|
||||||
for(let i = 0; i < rerollData.length; i++){
|
for(let i = 0; i < rerollData.length; i++){
|
||||||
msgs[msgs.length - rerollData.length + i] = rerollData[i]
|
msgs[msgs.length - rerollData.length + i] = rerollData[i]
|
||||||
@@ -151,10 +151,10 @@
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if(rerolls.length === 0){
|
if(rerolls.length === 0){
|
||||||
rerolls.push(structuredClone([DBState.db.characters[$selectedCharID].chats[DBState.db.characters[$selectedCharID].chatPage].message.at(-1)]))
|
rerolls.push(safeStructuredClone([DBState.db.characters[$selectedCharID].chats[DBState.db.characters[$selectedCharID].chatPage].message.at(-1)]))
|
||||||
rerollid = rerolls.length - 1
|
rerollid = rerolls.length - 1
|
||||||
}
|
}
|
||||||
let cha = structuredClone(DBState.db.characters[$selectedCharID].chats[DBState.db.characters[$selectedCharID].chatPage].message)
|
let cha = safeStructuredClone(DBState.db.characters[$selectedCharID].chats[DBState.db.characters[$selectedCharID].chatPage].message)
|
||||||
if(cha.length === 0 ){
|
if(cha.length === 0 ){
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -198,7 +198,7 @@
|
|||||||
}
|
}
|
||||||
if(Array.isArray(rerolls[rerollid - 1])){
|
if(Array.isArray(rerolls[rerollid - 1])){
|
||||||
rerollid -= 1
|
rerollid -= 1
|
||||||
let rerollData = structuredClone(rerolls[rerollid])
|
let rerollData = safeStructuredClone(rerolls[rerollid])
|
||||||
let msgs = DBState.db.characters[$selectedCharID].chats[DBState.db.characters[$selectedCharID].chatPage].message
|
let msgs = DBState.db.characters[$selectedCharID].chats[DBState.db.characters[$selectedCharID].chatPage].message
|
||||||
for(let i = 0; i < rerollData.length; i++){
|
for(let i = 0; i < rerollData.length; i++){
|
||||||
msgs[msgs.length - rerollData.length + i] = rerollData[i]
|
msgs[msgs.length - rerollData.length + i] = rerollData[i]
|
||||||
@@ -220,7 +220,7 @@
|
|||||||
continue:continued
|
continue:continued
|
||||||
})
|
})
|
||||||
if(previousLength < DBState.db.characters[$selectedCharID].chats[DBState.db.characters[$selectedCharID].chatPage].message.length){
|
if(previousLength < DBState.db.characters[$selectedCharID].chats[DBState.db.characters[$selectedCharID].chatPage].message.length){
|
||||||
rerolls.push(structuredClone(DBState.db.characters[$selectedCharID].chats[DBState.db.characters[$selectedCharID].chatPage].message).slice(previousLength))
|
rerolls.push(safeStructuredClone(DBState.db.characters[$selectedCharID].chats[DBState.db.characters[$selectedCharID].chatPage].message).slice(previousLength))
|
||||||
rerollid = rerolls.length - 1
|
rerollid = rerolls.length - 1
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -253,14 +253,14 @@
|
|||||||
{#if subMenu === 0}
|
{#if subMenu === 0}
|
||||||
{#each builtComponentTrees as component, i}
|
{#each builtComponentTrees as component, i}
|
||||||
<button class="p-2 border border-black rounded" onclick={() => {
|
<button class="p-2 border border-black rounded" onclick={() => {
|
||||||
addContainerToTree(structuredClone(component), selectedContatiner)
|
addContainerToTree(safeStructuredClone(component), selectedContatiner)
|
||||||
renderMainTree(tree)
|
renderMainTree(tree)
|
||||||
}}>{component.type}</button>
|
}}>{component.type}</button>
|
||||||
{/each}
|
{/each}
|
||||||
{:else if subMenu === 1}
|
{:else if subMenu === 1}
|
||||||
{#each builtContainerTrees as container, i}
|
{#each builtContainerTrees as container, i}
|
||||||
<button class="p-2 border border-black rounded" onclick={() => {
|
<button class="p-2 border border-black rounded" onclick={() => {
|
||||||
addContainerToTree(structuredClone(container), selectedContatiner)
|
addContainerToTree(safeStructuredClone(container), selectedContatiner)
|
||||||
renderMainTree(tree)
|
renderMainTree(tree)
|
||||||
}}>{container.type}</button>
|
}}>{container.type}</button>
|
||||||
{/each}
|
{/each}
|
||||||
|
|||||||
@@ -85,7 +85,7 @@
|
|||||||
<div class="flex mt-2 items-center">
|
<div class="flex mt-2 items-center">
|
||||||
<button class="text-textcolor2 hover:text-green-500 cursor-pointer mr-1" onclick={() => {
|
<button class="text-textcolor2 hover:text-green-500 cursor-pointer mr-1" onclick={() => {
|
||||||
let botPresets = DBState.db.botPresets
|
let botPresets = DBState.db.botPresets
|
||||||
let newPreset = structuredClone(prebuiltPresets.OAI2)
|
let newPreset = safeStructuredClone(prebuiltPresets.OAI2)
|
||||||
newPreset.name = `New Preset`
|
newPreset.name = `New Preset`
|
||||||
botPresets.push(newPreset)
|
botPresets.push(newPreset)
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@
|
|||||||
"system": "⚙️ System",
|
"system": "⚙️ System",
|
||||||
"assistant": "✨ Assistant",
|
"assistant": "✨ Assistant",
|
||||||
}
|
}
|
||||||
let formated = structuredClone(previewFormated)
|
let formated = safeStructuredClone(previewFormated)
|
||||||
|
|
||||||
if(previewJoin === 'yes'){
|
if(previewJoin === 'yes'){
|
||||||
let newFormated = []
|
let newFormated = []
|
||||||
|
|||||||
@@ -107,7 +107,7 @@
|
|||||||
const option = await alertChatOptions()
|
const option = await alertChatOptions()
|
||||||
switch(option){
|
switch(option){
|
||||||
case 0:{
|
case 0:{
|
||||||
const newChat = structuredClone($state.snapshot(chara.chats[i]))
|
const newChat = safeStructuredClone($state.snapshot(chara.chats[i]))
|
||||||
newChat.name = `Copy of ${newChat.name}`
|
newChat.name = `Copy of ${newChat.name}`
|
||||||
chara.chats.unshift(newChat)
|
chara.chats.unshift(newChat)
|
||||||
chara.chatPage = 0
|
chara.chatPage = 0
|
||||||
|
|||||||
@@ -137,7 +137,7 @@
|
|||||||
const da = db.characterOrder[mainIndex.index]
|
const da = db.characterOrder[mainIndex.index]
|
||||||
if(typeof(da) !== 'string'){
|
if(typeof(da) !== 'string'){
|
||||||
mainId = da.id
|
mainId = da.id
|
||||||
movingFolder = structuredClone($state.snapshot(da))
|
movingFolder = safeStructuredClone($state.snapshot(da))
|
||||||
if(targetIndex.folder){
|
if(targetIndex.folder){
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import "./styles.css";
|
import "./styles.css";
|
||||||
|
import "./ts/polyfill";
|
||||||
import "core-js/actual"
|
import "core-js/actual"
|
||||||
import "./ts/storage/database.svelte"
|
import "./ts/storage/database.svelte"
|
||||||
import App from "./App.svelte";
|
import App from "./App.svelte";
|
||||||
import { loadData } from "./ts/storage/globalApi";
|
import { loadData } from "./ts/storage/globalApi";
|
||||||
import { initHotkey } from "./ts/hotkey";
|
import { initHotkey } from "./ts/hotkey";
|
||||||
import { polyfill } from "./ts/polyfill";
|
|
||||||
import { preLoadCheck } from "./preload";
|
import { preLoadCheck } from "./preload";
|
||||||
import { mount } from "svelte";
|
import { mount } from "svelte";
|
||||||
|
|
||||||
@@ -25,12 +25,10 @@ export const removeDefaultHandler = () => {
|
|||||||
window.removeEventListener('unhandledrejection', rejectHandler)
|
window.removeEventListener('unhandledrejection', rejectHandler)
|
||||||
}
|
}
|
||||||
|
|
||||||
let app: App;
|
let app: any;
|
||||||
|
|
||||||
if(preLoadCheck()){
|
if(preLoadCheck()){
|
||||||
try {
|
try {
|
||||||
polyfill()
|
|
||||||
|
|
||||||
app = mount(App, {
|
app = mount(App, {
|
||||||
target: document.getElementById("app"),
|
target: document.getElementById("app"),
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -569,7 +569,7 @@ function convertOffSpecCards(charaData:OldTavernChar|CharacterCardV2Risu, imgp:s
|
|||||||
|
|
||||||
export async function exportChar(charaID:number):Promise<string> {
|
export async function exportChar(charaID:number):Promise<string> {
|
||||||
const db = getDatabase({snapshot: true})
|
const db = getDatabase({snapshot: true})
|
||||||
let char = structuredClone(db.characters[charaID])
|
let char = safeStructuredClone(db.characters[charaID])
|
||||||
|
|
||||||
if(char.type === 'group'){
|
if(char.type === 'group'){
|
||||||
return ''
|
return ''
|
||||||
@@ -607,7 +607,7 @@ async function importCharacterCardSpec(card:CharacterCardV2Risu|CharacterCardV3,
|
|||||||
let im = img ? await saveAsset(await reencodeImage(img)) : undefined
|
let im = img ? await saveAsset(await reencodeImage(img)) : undefined
|
||||||
let db = getDatabase()
|
let db = getDatabase()
|
||||||
|
|
||||||
const risuext = structuredClone(data.extensions.risuai)
|
const risuext = safeStructuredClone(data.extensions.risuai)
|
||||||
let emotions:[string, string][] = []
|
let emotions:[string, string][] = []
|
||||||
let bias:[string, number][] = []
|
let bias:[string, number][] = []
|
||||||
let viewScreen: "none" | "emotion" | "imggen" = 'none'
|
let viewScreen: "none" | "emotion" | "imggen" = 'none'
|
||||||
@@ -827,7 +827,7 @@ async function importCharacterCardSpec(card:CharacterCardV2Risu|CharacterCardV3,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let ext = structuredClone(data?.extensions ?? {})
|
let ext = safeStructuredClone(data?.extensions ?? {})
|
||||||
|
|
||||||
for(const key in ext){
|
for(const key in ext){
|
||||||
if(key === 'risuai'){
|
if(key === 'risuai'){
|
||||||
@@ -931,7 +931,7 @@ async function createBaseV2(char:character) {
|
|||||||
key:string
|
key:string
|
||||||
data:string[]
|
data:string[]
|
||||||
}
|
}
|
||||||
} = structuredClone(lore.extentions ?? {})
|
} = safeStructuredClone(lore.extentions ?? {})
|
||||||
|
|
||||||
let caseSensitive = ext.risu_case_sensitive ?? false
|
let caseSensitive = ext.risu_case_sensitive ?? false
|
||||||
ext.risu_activationPercent = lore.activationPercent
|
ext.risu_activationPercent = lore.activationPercent
|
||||||
@@ -1261,7 +1261,7 @@ export function createBaseV3(char:character){
|
|||||||
uri: string
|
uri: string
|
||||||
name: string
|
name: string
|
||||||
ext: string
|
ext: string
|
||||||
}> = structuredClone(char.ccAssets ?? [])
|
}> = safeStructuredClone(char.ccAssets ?? [])
|
||||||
|
|
||||||
if(char.additionalAssets){
|
if(char.additionalAssets){
|
||||||
for(const asset of char.additionalAssets){
|
for(const asset of char.additionalAssets){
|
||||||
@@ -1300,7 +1300,7 @@ export function createBaseV3(char:character){
|
|||||||
key:string
|
key:string
|
||||||
data:string[]
|
data:string[]
|
||||||
}
|
}
|
||||||
} = structuredClone(lore.extentions ?? {})
|
} = safeStructuredClone(lore.extentions ?? {})
|
||||||
|
|
||||||
let caseSensitive = ext.risu_case_sensitive ?? false
|
let caseSensitive = ext.risu_case_sensitive ?? false
|
||||||
ext.risu_activationPercent = lore.activationPercent
|
ext.risu_activationPercent = lore.activationPercent
|
||||||
@@ -1400,7 +1400,7 @@ export async function shareRisuHub2(char:character, arg:{
|
|||||||
update: boolean
|
update: boolean
|
||||||
}) {
|
}) {
|
||||||
try {
|
try {
|
||||||
char = structuredClone(char)
|
char = safeStructuredClone(char)
|
||||||
char.license = arg.license
|
char.license = arg.license
|
||||||
let tagList = arg.tag.split(',')
|
let tagList = arg.tag.split(',')
|
||||||
|
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ let BackupDb:Database = null
|
|||||||
|
|
||||||
|
|
||||||
export async function syncDrive() {
|
export async function syncDrive() {
|
||||||
BackupDb = structuredClone(getDatabase())
|
BackupDb = safeStructuredClone(getDatabase())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ export const colorSchemeList = Object.keys(colorShemes) as (keyof typeof colorSh
|
|||||||
export function changeColorScheme(colorScheme: string){
|
export function changeColorScheme(colorScheme: string){
|
||||||
let db = getDatabase()
|
let db = getDatabase()
|
||||||
if(colorScheme !== 'custom'){
|
if(colorScheme !== 'custom'){
|
||||||
db.colorScheme = structuredClone(colorShemes[colorScheme])
|
db.colorScheme = safeStructuredClone(colorShemes[colorScheme])
|
||||||
}
|
}
|
||||||
db.colorSchemeName = colorScheme
|
db.colorSchemeName = colorScheme
|
||||||
setDatabase(db)
|
setDatabase(db)
|
||||||
@@ -130,11 +130,11 @@ export function updateColorScheme(){
|
|||||||
let colorScheme = db.colorScheme
|
let colorScheme = db.colorScheme
|
||||||
|
|
||||||
if(colorScheme == null){
|
if(colorScheme == null){
|
||||||
colorScheme = structuredClone(defaultColorScheme)
|
colorScheme = safeStructuredClone(defaultColorScheme)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(get(isLite)){
|
if(get(isLite)){
|
||||||
colorScheme = structuredClone(colorShemes.lite)
|
colorScheme = safeStructuredClone(colorShemes.lite)
|
||||||
}
|
}
|
||||||
|
|
||||||
//set css variables
|
//set css variables
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ export async function exportUserPersona(){
|
|||||||
|
|
||||||
let img = await readImage(db.userIcon)
|
let img = await readImage(db.userIcon)
|
||||||
|
|
||||||
let card:PersonaCard = structuredClone({
|
let card:PersonaCard = safeStructuredClone({
|
||||||
name: db.username,
|
name: db.username,
|
||||||
personaPrompt: db.personaPrompt,
|
personaPrompt: db.personaPrompt,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ addWorkerFunction('getChat', async () => {
|
|||||||
})
|
})
|
||||||
const selectedChar = get(selectedCharID)
|
const selectedChar = get(selectedCharID)
|
||||||
const char = db.characters[selectedChar]
|
const char = db.characters[selectedChar]
|
||||||
return structuredClone(char.chats[char.chatPage].message)
|
return safeStructuredClone(char.chats[char.chatPage].message)
|
||||||
})
|
})
|
||||||
|
|
||||||
addWorkerFunction('setChat', async (data:Message[]) => {
|
addWorkerFunction('setChat', async (data:Message[]) => {
|
||||||
|
|||||||
@@ -3,7 +3,14 @@ import { Buffer as BufferPolyfill } from 'buffer'
|
|||||||
import { polyfill as dragPolyfill} from "mobile-drag-drop"
|
import { polyfill as dragPolyfill} from "mobile-drag-drop"
|
||||||
import {scrollBehaviourDragImageTranslateOverride} from 'mobile-drag-drop/scroll-behaviour'
|
import {scrollBehaviourDragImageTranslateOverride} from 'mobile-drag-drop/scroll-behaviour'
|
||||||
|
|
||||||
export function polyfill() {
|
function safeStructuredClone<T>(data:T):T{
|
||||||
|
try {
|
||||||
|
return structuredClone(data)
|
||||||
|
} catch (error) {
|
||||||
|
return JSON.parse(JSON.stringify(data))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const testDom = document.createElement('div');
|
const testDom = document.createElement('div');
|
||||||
const supports = ('draggable' in testDom) || ('ondragstart' in testDom && 'ondrop' in testDom);
|
const supports = ('draggable' in testDom) || ('ondragstart' in testDom && 'ondrop' in testDom);
|
||||||
@@ -22,9 +29,13 @@ export function polyfill() {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
globalThis.safeStructuredClone = safeStructuredClone
|
||||||
|
|
||||||
globalThis.Buffer = BufferPolyfill
|
globalThis.Buffer = BufferPolyfill
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
globalThis.WritableStream = globalThis.WritableStream ?? WritableStream
|
globalThis.WritableStream = globalThis.WritableStream ?? WritableStream
|
||||||
|
//@ts-ignore
|
||||||
globalThis.ReadableStream = globalThis.ReadableStream ?? ReadableStream
|
globalThis.ReadableStream = globalThis.ReadableStream ?? ReadableStream
|
||||||
|
//@ts-ignore
|
||||||
globalThis.TransformStream = globalThis.TransformStream ?? TransformStream
|
globalThis.TransformStream = globalThis.TransformStream ?? TransformStream
|
||||||
}
|
|
||||||
@@ -229,7 +229,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{
|
|||||||
'personaPrompt':([] as OpenAIChat[])
|
'personaPrompt':([] as OpenAIChat[])
|
||||||
}
|
}
|
||||||
|
|
||||||
let promptTemplate = structuredClone(db.promptTemplate)
|
let promptTemplate = safeStructuredClone(db.promptTemplate)
|
||||||
const usingPromptTemplate = !!promptTemplate
|
const usingPromptTemplate = !!promptTemplate
|
||||||
if(promptTemplate){
|
if(promptTemplate){
|
||||||
let hasPostEverything = false
|
let hasPostEverything = false
|
||||||
@@ -466,7 +466,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{
|
|||||||
for(const card of template){
|
for(const card of template){
|
||||||
switch(card.type){
|
switch(card.type){
|
||||||
case 'persona':{
|
case 'persona':{
|
||||||
let pmt = structuredClone(unformated.personaPrompt)
|
let pmt = safeStructuredClone(unformated.personaPrompt)
|
||||||
if(card.innerFormat && pmt.length > 0){
|
if(card.innerFormat && pmt.length > 0){
|
||||||
for(let i=0;i<pmt.length;i++){
|
for(let i=0;i<pmt.length;i++){
|
||||||
pmt[i].content = risuChatParser(positionParser(card.innerFormat), {chara: currentChar}).replace('{{slot}}', pmt[i].content)
|
pmt[i].content = risuChatParser(positionParser(card.innerFormat), {chara: currentChar}).replace('{{slot}}', pmt[i].content)
|
||||||
@@ -477,7 +477,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
case 'description':{
|
case 'description':{
|
||||||
let pmt = structuredClone(unformated.description)
|
let pmt = safeStructuredClone(unformated.description)
|
||||||
if(card.innerFormat && pmt.length > 0){
|
if(card.innerFormat && pmt.length > 0){
|
||||||
for(let i=0;i<pmt.length;i++){
|
for(let i=0;i<pmt.length;i++){
|
||||||
pmt[i].content = risuChatParser(positionParser(card.innerFormat), {chara: currentChar}).replace('{{slot}}', pmt[i].content)
|
pmt[i].content = risuChatParser(positionParser(card.innerFormat), {chara: currentChar}).replace('{{slot}}', pmt[i].content)
|
||||||
@@ -488,7 +488,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
case 'authornote':{
|
case 'authornote':{
|
||||||
let pmt = structuredClone(unformated.authorNote)
|
let pmt = safeStructuredClone(unformated.authorNote)
|
||||||
if(card.innerFormat && pmt.length > 0){
|
if(card.innerFormat && pmt.length > 0){
|
||||||
for(let i=0;i<pmt.length;i++){
|
for(let i=0;i<pmt.length;i++){
|
||||||
pmt[i].content = risuChatParser(positionParser(card.innerFormat), {chara: currentChar}).replace('{{slot}}', pmt[i].content || card.defaultText || '')
|
pmt[i].content = risuChatParser(positionParser(card.innerFormat), {chara: currentChar}).replace('{{slot}}', pmt[i].content || card.defaultText || '')
|
||||||
@@ -883,7 +883,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{
|
|||||||
//make into one
|
//make into one
|
||||||
|
|
||||||
let formated:OpenAIChat[] = []
|
let formated:OpenAIChat[] = []
|
||||||
const formatOrder = structuredClone(db.formatingOrder)
|
const formatOrder = safeStructuredClone(db.formatingOrder)
|
||||||
if(formatOrder){
|
if(formatOrder){
|
||||||
formatOrder.push('postEverything')
|
formatOrder.push('postEverything')
|
||||||
}
|
}
|
||||||
@@ -927,7 +927,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{
|
|||||||
for(const card of template){
|
for(const card of template){
|
||||||
switch(card.type){
|
switch(card.type){
|
||||||
case 'persona':{
|
case 'persona':{
|
||||||
let pmt = structuredClone(unformated.personaPrompt)
|
let pmt = safeStructuredClone(unformated.personaPrompt)
|
||||||
if(card.innerFormat && pmt.length > 0){
|
if(card.innerFormat && pmt.length > 0){
|
||||||
for(let i=0;i<pmt.length;i++){
|
for(let i=0;i<pmt.length;i++){
|
||||||
pmt[i].content = risuChatParser(positionParser(card.innerFormat), {chara: currentChar}).replace('{{slot}}', pmt[i].content)
|
pmt[i].content = risuChatParser(positionParser(card.innerFormat), {chara: currentChar}).replace('{{slot}}', pmt[i].content)
|
||||||
@@ -938,7 +938,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
case 'description':{
|
case 'description':{
|
||||||
let pmt = structuredClone(unformated.description)
|
let pmt = safeStructuredClone(unformated.description)
|
||||||
if(card.innerFormat && pmt.length > 0){
|
if(card.innerFormat && pmt.length > 0){
|
||||||
for(let i=0;i<pmt.length;i++){
|
for(let i=0;i<pmt.length;i++){
|
||||||
pmt[i].content = risuChatParser(positionParser(card.innerFormat), {chara: currentChar}).replace('{{slot}}', pmt[i].content)
|
pmt[i].content = risuChatParser(positionParser(card.innerFormat), {chara: currentChar}).replace('{{slot}}', pmt[i].content)
|
||||||
@@ -949,7 +949,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
case 'authornote':{
|
case 'authornote':{
|
||||||
let pmt = structuredClone(unformated.authorNote)
|
let pmt = safeStructuredClone(unformated.authorNote)
|
||||||
if(card.innerFormat && pmt.length > 0){
|
if(card.innerFormat && pmt.length > 0){
|
||||||
for(let i=0;i<pmt.length;i++){
|
for(let i=0;i<pmt.length;i++){
|
||||||
pmt[i].content = risuChatParser(positionParser(card.innerFormat), {chara: currentChar}).replace('{{slot}}', pmt[i].content || card.defaultText || '')
|
pmt[i].content = risuChatParser(positionParser(card.innerFormat), {chara: currentChar}).replace('{{slot}}', pmt[i].content || card.defaultText || '')
|
||||||
@@ -1041,7 +1041,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
case 'memory':{
|
case 'memory':{
|
||||||
let pmt = structuredClone(memories)
|
let pmt = safeStructuredClone(memories)
|
||||||
if(card.innerFormat && pmt.length > 0){
|
if(card.innerFormat && pmt.length > 0){
|
||||||
for(let i=0;i<pmt.length;i++){
|
for(let i=0;i<pmt.length;i++){
|
||||||
pmt[i].content = risuChatParser(card.innerFormat, {chara: currentChar}).replace('{{slot}}', pmt[i].content)
|
pmt[i].content = risuChatParser(card.innerFormat, {chara: currentChar}).replace('{{slot}}', pmt[i].content)
|
||||||
|
|||||||
@@ -214,7 +214,7 @@ export async function loadLoreBookV3Prompt(){
|
|||||||
const characterLore = char.globalLore ?? []
|
const characterLore = char.globalLore ?? []
|
||||||
const chatLore = char.chats[page].localLore ?? []
|
const chatLore = char.chats[page].localLore ?? []
|
||||||
const moduleLorebook = getModuleLorebooks()
|
const moduleLorebook = getModuleLorebooks()
|
||||||
const fullLore = structuredClone(characterLore.concat(chatLore).concat(moduleLorebook))
|
const fullLore = safeStructuredClone(characterLore.concat(chatLore).concat(moduleLorebook))
|
||||||
const currentChat = char.chats[page].message
|
const currentChat = char.chats[page].message
|
||||||
const loreDepth = char.loreSettings?.scanDepth ?? db.loreBookDepth
|
const loreDepth = char.loreSettings?.scanDepth ?? db.loreBookDepth
|
||||||
const loreToken = char.loreSettings?.tokenBudget ?? db.loreBookToken
|
const loreToken = char.loreSettings?.tokenBudget ?? db.loreBookToken
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ export async function supaMemory(
|
|||||||
for(let j=0;j<HypaData.length;j++){
|
for(let j=0;j<HypaData.length;j++){
|
||||||
let i =0;
|
let i =0;
|
||||||
let countTokens = currentTokens
|
let countTokens = currentTokens
|
||||||
let countChats = structuredClone(chats)
|
let countChats = safeStructuredClone(chats)
|
||||||
while(true){
|
while(true){
|
||||||
if(countChats.length === 0){
|
if(countChats.length === 0){
|
||||||
break
|
break
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ export async function exportModule(module:RisuModule, arg:{
|
|||||||
}
|
}
|
||||||
|
|
||||||
const assets = module.assets ?? []
|
const assets = module.assets ?? []
|
||||||
module = structuredClone(module)
|
module = safeStructuredClone(module)
|
||||||
module.assets ??= []
|
module.assets ??= []
|
||||||
module.assets = module.assets.map((asset) => {
|
module.assets = module.assets.map((asset) => {
|
||||||
return [asset[0], '', asset[2]] as [string,string,string]
|
return [asset[0], '', asset[2]] as [string,string,string]
|
||||||
@@ -360,7 +360,7 @@ export async function applyModule() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const module = structuredClone(getModuleById(sel))
|
const module = safeStructuredClone(getModuleById(sel))
|
||||||
if (!module) {
|
if (!module) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -256,7 +256,7 @@ export const OobaParams = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
export function promptConvertion(files:{ name: string, content: string, type:string }[]){
|
export function promptConvertion(files:{ name: string, content: string, type:string }[]){
|
||||||
let preset = structuredClone(presetTemplate)
|
let preset = safeStructuredClone(presetTemplate)
|
||||||
let instData = {
|
let instData = {
|
||||||
"system_prompt": "",
|
"system_prompt": "",
|
||||||
"input_sequence": "",
|
"input_sequence": "",
|
||||||
|
|||||||
@@ -179,7 +179,7 @@ export interface OpenAIChatExtra {
|
|||||||
|
|
||||||
export async function requestChatDataMain(arg:requestDataArgument, model:'model'|'submodel', abortSignal:AbortSignal=null):Promise<requestDataResponse> {
|
export async function requestChatDataMain(arg:requestDataArgument, model:'model'|'submodel', abortSignal:AbortSignal=null):Promise<requestDataResponse> {
|
||||||
const db = getDatabase()
|
const db = getDatabase()
|
||||||
let formated = structuredClone(arg.formated)
|
let formated = safeStructuredClone(arg.formated)
|
||||||
let maxTokens = arg.maxTokens ??db.maxResponse
|
let maxTokens = arg.maxTokens ??db.maxResponse
|
||||||
let temperature = arg.temperature ?? (db.temperature / 100)
|
let temperature = arg.temperature ?? (db.temperature / 100)
|
||||||
let bias = arg.bias
|
let bias = arg.bias
|
||||||
@@ -245,7 +245,7 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model'
|
|||||||
for(let i=0;i<formated.length;i++){
|
for(let i=0;i<formated.length;i++){
|
||||||
const m = formated[i]
|
const m = formated[i]
|
||||||
if(m.multimodals && m.multimodals.length > 0 && m.role === 'user'){
|
if(m.multimodals && m.multimodals.length > 0 && m.role === 'user'){
|
||||||
let v:OpenAIChatExtra = structuredClone(m)
|
let v:OpenAIChatExtra = safeStructuredClone(m)
|
||||||
let contents:OpenAIContents[] = []
|
let contents:OpenAIContents[] = []
|
||||||
for(let j=0;j<m.multimodals.length;j++){
|
for(let j=0;j<m.multimodals.length;j++){
|
||||||
contents.push({
|
contents.push({
|
||||||
|
|||||||
@@ -231,7 +231,7 @@ export async function processScriptFull(char:character|groupChat|simpleCharacter
|
|||||||
for (const script of scripts){
|
for (const script of scripts){
|
||||||
if(script.ableFlag && script.flag?.includes('<')){
|
if(script.ableFlag && script.flag?.includes('<')){
|
||||||
const rregex = /<(.+?)>/g
|
const rregex = /<(.+?)>/g
|
||||||
const scriptData = structuredClone(script)
|
const scriptData = safeStructuredClone(script)
|
||||||
let order = 0
|
let order = 0
|
||||||
const actions:string[] = []
|
const actions:string[] = []
|
||||||
scriptData.flag = scriptData.flag?.replace(rregex, (v:string, p1:string) => {
|
scriptData.flag = scriptData.flag?.replace(rregex, (v:string, p1:string) => {
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ export const applyChatTemplate = (messages:OpenAIChat[], arg:{
|
|||||||
if(!type){
|
if(!type){
|
||||||
throw new Error('Template type is not set')
|
throw new Error('Template type is not set')
|
||||||
}
|
}
|
||||||
let clonedMessages = structuredClone(messages)
|
let clonedMessages = safeStructuredClone(messages)
|
||||||
const template = type === 'jinja' ? (new Template(arg.custom ?? db.JinjaTemplate)) :(new Template(chatTemplates[type]))
|
const template = type === 'jinja' ? (new Template(arg.custom ?? db.JinjaTemplate)) :(new Template(chatTemplates[type]))
|
||||||
let formatedMessages:{
|
let formatedMessages:{
|
||||||
"role": 'user'|'assistant'|'system',
|
"role": 'user'|'assistant'|'system',
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ export async function runTrigger(char:character,mode:triggerMode, arg:{
|
|||||||
manualName?: string
|
manualName?: string
|
||||||
}){
|
}){
|
||||||
arg.recursiveCount ??= 0
|
arg.recursiveCount ??= 0
|
||||||
char = structuredClone(char)
|
char = safeStructuredClone(char)
|
||||||
let varChanged = false
|
let varChanged = false
|
||||||
let stopSending = arg.stopSending ?? false
|
let stopSending = arg.stopSending ?? false
|
||||||
const CharacterlowLevelAccess = char.lowLevelAccess ?? false
|
const CharacterlowLevelAccess = char.lowLevelAccess ?? false
|
||||||
@@ -169,7 +169,7 @@ export async function runTrigger(char:character,mode:triggerMode, arg:{
|
|||||||
}).concat(getModuleTriggers())
|
}).concat(getModuleTriggers())
|
||||||
const db = getDatabase()
|
const db = getDatabase()
|
||||||
const defaultVariables = parseKeyValue(char.defaultVariables).concat(parseKeyValue(db.templateDefaultVariables))
|
const defaultVariables = parseKeyValue(char.defaultVariables).concat(parseKeyValue(db.templateDefaultVariables))
|
||||||
let chat = structuredClone(arg.chat ?? char.chats[char.chatPage])
|
let chat = safeStructuredClone(arg.chat ?? char.chats[char.chatPage])
|
||||||
if((!triggers) || (triggers.length === 0)){
|
if((!triggers) || (triggers.length === 0)){
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ window.addEventListener("message", (event) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
export async function shareRealmCardData():Promise<{ name: ArrayBuffer; data: ArrayBuffer; }> {
|
export async function shareRealmCardData():Promise<{ name: ArrayBuffer; data: ArrayBuffer; }> {
|
||||||
const char = structuredClone(getCurrentCharacter({snapshot:true})) as character
|
const char = safeStructuredClone(getCurrentCharacter({snapshot:true})) as character
|
||||||
const trimedName = char.name.replace(/[^a-zA-Z0-9]/g, '') || 'character';
|
const trimedName = char.name.replace(/[^a-zA-Z0-9]/g, '') || 'character';
|
||||||
const writer = new VirtualWriter()
|
const writer = new VirtualWriter()
|
||||||
const namebuf = new TextEncoder().encode(trimedName + '.png')
|
const namebuf = new TextEncoder().encode(trimedName + '.png')
|
||||||
|
|||||||
@@ -319,16 +319,16 @@ export function setDatabase(data:Database){
|
|||||||
largePortrait: false
|
largePortrait: false
|
||||||
}]
|
}]
|
||||||
data.classicMaxWidth ??= false
|
data.classicMaxWidth ??= false
|
||||||
data.ooba ??= structuredClone(defaultOoba)
|
data.ooba ??= safeStructuredClone(defaultOoba)
|
||||||
data.ainconfig ??= structuredClone(defaultAIN)
|
data.ainconfig ??= safeStructuredClone(defaultAIN)
|
||||||
data.openrouterKey ??= ''
|
data.openrouterKey ??= ''
|
||||||
data.openrouterRequestModel ??= 'openai/gpt-3.5-turbo'
|
data.openrouterRequestModel ??= 'openai/gpt-3.5-turbo'
|
||||||
data.toggleConfirmRecommendedPreset ??= true
|
data.toggleConfirmRecommendedPreset ??= true
|
||||||
data.officialplugins ??= {}
|
data.officialplugins ??= {}
|
||||||
data.NAIsettings ??= structuredClone(prebuiltNAIpresets)
|
data.NAIsettings ??= safeStructuredClone(prebuiltNAIpresets)
|
||||||
data.assetWidth ??= -1
|
data.assetWidth ??= -1
|
||||||
data.animationSpeed ??= 0.4
|
data.animationSpeed ??= 0.4
|
||||||
data.colorScheme ??= structuredClone(defaultColorScheme)
|
data.colorScheme ??= safeStructuredClone(defaultColorScheme)
|
||||||
data.colorSchemeName ??= 'default'
|
data.colorSchemeName ??= 'default'
|
||||||
data.NAIsettings.starter ??= ""
|
data.NAIsettings.starter ??= ""
|
||||||
data.hypaModel ??= 'MiniLM'
|
data.hypaModel ??= 'MiniLM'
|
||||||
@@ -1304,8 +1304,8 @@ export const presetTemplate:botPreset = {
|
|||||||
promptPreprocess: false,
|
promptPreprocess: false,
|
||||||
proxyKey: '',
|
proxyKey: '',
|
||||||
bias: [],
|
bias: [],
|
||||||
ooba: structuredClone(defaultOoba),
|
ooba: safeStructuredClone(defaultOoba),
|
||||||
ainconfig: structuredClone(defaultAIN),
|
ainconfig: safeStructuredClone(defaultAIN),
|
||||||
reverseProxyOobaArgs: {
|
reverseProxyOobaArgs: {
|
||||||
mode: 'instruct'
|
mode: 'instruct'
|
||||||
},
|
},
|
||||||
@@ -1324,7 +1324,7 @@ const defaultSdData:[string,string][] = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
export const defaultSdDataFunc = () =>{
|
export const defaultSdDataFunc = () =>{
|
||||||
return structuredClone(defaultSdData)
|
return safeStructuredClone(defaultSdData)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function saveCurrentPreset(){
|
export function saveCurrentPreset(){
|
||||||
@@ -1354,20 +1354,20 @@ export function saveCurrentPreset(){
|
|||||||
bias: db.bias,
|
bias: db.bias,
|
||||||
koboldURL: db.koboldURL,
|
koboldURL: db.koboldURL,
|
||||||
proxyKey: db.proxyKey,
|
proxyKey: db.proxyKey,
|
||||||
ooba: structuredClone(db.ooba),
|
ooba: safeStructuredClone(db.ooba),
|
||||||
ainconfig: structuredClone(db.ainconfig),
|
ainconfig: safeStructuredClone(db.ainconfig),
|
||||||
proxyRequestModel: db.proxyRequestModel,
|
proxyRequestModel: db.proxyRequestModel,
|
||||||
openrouterRequestModel: db.openrouterRequestModel,
|
openrouterRequestModel: db.openrouterRequestModel,
|
||||||
NAISettings: structuredClone(db.NAIsettings),
|
NAISettings: safeStructuredClone(db.NAIsettings),
|
||||||
promptTemplate: db.promptTemplate ?? null,
|
promptTemplate: db.promptTemplate ?? null,
|
||||||
NAIadventure: db.NAIadventure ?? false,
|
NAIadventure: db.NAIadventure ?? false,
|
||||||
NAIappendName: db.NAIappendName ?? false,
|
NAIappendName: db.NAIappendName ?? false,
|
||||||
localStopStrings: db.localStopStrings,
|
localStopStrings: db.localStopStrings,
|
||||||
autoSuggestPrompt: db.autoSuggestPrompt,
|
autoSuggestPrompt: db.autoSuggestPrompt,
|
||||||
customProxyRequestModel: db.customProxyRequestModel,
|
customProxyRequestModel: db.customProxyRequestModel,
|
||||||
reverseProxyOobaArgs: structuredClone(db.reverseProxyOobaArgs) ?? null,
|
reverseProxyOobaArgs: safeStructuredClone(db.reverseProxyOobaArgs) ?? null,
|
||||||
top_p: db.top_p ?? 1,
|
top_p: db.top_p ?? 1,
|
||||||
promptSettings: structuredClone(db.promptSettings) ?? null,
|
promptSettings: safeStructuredClone(db.promptSettings) ?? null,
|
||||||
repetition_penalty: db.repetition_penalty,
|
repetition_penalty: db.repetition_penalty,
|
||||||
min_p: db.min_p,
|
min_p: db.min_p,
|
||||||
top_a: db.top_a,
|
top_a: db.top_a,
|
||||||
@@ -1394,7 +1394,7 @@ export function copyPreset(id:number){
|
|||||||
saveCurrentPreset()
|
saveCurrentPreset()
|
||||||
let db = getDatabase()
|
let db = getDatabase()
|
||||||
let pres = db.botPresets
|
let pres = db.botPresets
|
||||||
const newPres = structuredClone(pres[id])
|
const newPres = safeStructuredClone(pres[id])
|
||||||
newPres.name += " Copy"
|
newPres.name += " Copy"
|
||||||
db.botPresets.push(newPres)
|
db.botPresets.push(newPres)
|
||||||
setDatabase(db)
|
setDatabase(db)
|
||||||
@@ -1434,8 +1434,8 @@ export function setPreset(db:Database, newPres: botPreset){
|
|||||||
db.bias = newPres.bias ?? db.bias
|
db.bias = newPres.bias ?? db.bias
|
||||||
db.koboldURL = newPres.koboldURL ?? db.koboldURL
|
db.koboldURL = newPres.koboldURL ?? db.koboldURL
|
||||||
db.proxyKey = newPres.proxyKey ?? db.proxyKey
|
db.proxyKey = newPres.proxyKey ?? db.proxyKey
|
||||||
db.ooba = structuredClone(newPres.ooba ?? db.ooba)
|
db.ooba = safeStructuredClone(newPres.ooba ?? db.ooba)
|
||||||
db.ainconfig = structuredClone(newPres.ainconfig ?? db.ainconfig)
|
db.ainconfig = safeStructuredClone(newPres.ainconfig ?? db.ainconfig)
|
||||||
db.openrouterRequestModel = newPres.openrouterRequestModel ?? db.openrouterRequestModel
|
db.openrouterRequestModel = newPres.openrouterRequestModel ?? db.openrouterRequestModel
|
||||||
db.proxyRequestModel = newPres.proxyRequestModel ?? db.proxyRequestModel
|
db.proxyRequestModel = newPres.proxyRequestModel ?? db.proxyRequestModel
|
||||||
db.NAIsettings = newPres.NAISettings ?? db.NAIsettings
|
db.NAIsettings = newPres.NAISettings ?? db.NAIsettings
|
||||||
@@ -1450,12 +1450,12 @@ export function setPreset(db:Database, newPres: botPreset){
|
|||||||
db.NAIsettings.mirostat_lr ??= 1
|
db.NAIsettings.mirostat_lr ??= 1
|
||||||
db.localStopStrings = newPres.localStopStrings
|
db.localStopStrings = newPres.localStopStrings
|
||||||
db.customProxyRequestModel = newPres.customProxyRequestModel ?? ''
|
db.customProxyRequestModel = newPres.customProxyRequestModel ?? ''
|
||||||
db.reverseProxyOobaArgs = structuredClone(newPres.reverseProxyOobaArgs) ?? {
|
db.reverseProxyOobaArgs = safeStructuredClone(newPres.reverseProxyOobaArgs) ?? {
|
||||||
mode: 'instruct'
|
mode: 'instruct'
|
||||||
}
|
}
|
||||||
db.top_p = newPres.top_p ?? 1
|
db.top_p = newPres.top_p ?? 1
|
||||||
//@ts-ignore //for legacy mistpings
|
//@ts-ignore //for legacy mistpings
|
||||||
db.promptSettings = structuredClone(newPres.promptSettings) ?? {
|
db.promptSettings = safeStructuredClone(newPres.promptSettings) ?? {
|
||||||
assistantPrefill: '',
|
assistantPrefill: '',
|
||||||
postEndInnerFormat: '',
|
postEndInnerFormat: '',
|
||||||
sendChatAsSystem: false,
|
sendChatAsSystem: false,
|
||||||
@@ -1493,7 +1493,7 @@ import { selectedCharID } from '../stores';
|
|||||||
export async function downloadPreset(id:number, type:'json'|'risupreset'|'return' = 'json'){
|
export async function downloadPreset(id:number, type:'json'|'risupreset'|'return' = 'json'){
|
||||||
saveCurrentPreset()
|
saveCurrentPreset()
|
||||||
let db = getDatabase()
|
let db = getDatabase()
|
||||||
let pres = structuredClone(db.botPresets[id])
|
let pres = safeStructuredClone(db.botPresets[id])
|
||||||
console.log(pres)
|
console.log(pres)
|
||||||
pres.openAIKey = ''
|
pres.openAIKey = ''
|
||||||
pres.forceReplaceUrl = ''
|
pres.forceReplaceUrl = ''
|
||||||
@@ -1566,7 +1566,7 @@ export async function importPreset(f:{
|
|||||||
let db = getDatabase()
|
let db = getDatabase()
|
||||||
if(pre.presetVersion && pre.presetVersion >= 3){
|
if(pre.presetVersion && pre.presetVersion >= 3){
|
||||||
//NAI preset
|
//NAI preset
|
||||||
const pr = structuredClone(prebuiltPresets.NAI2)
|
const pr = safeStructuredClone(prebuiltPresets.NAI2)
|
||||||
pr.temperature = pre.parameters.temperature * 100
|
pr.temperature = pre.parameters.temperature * 100
|
||||||
pr.maxResponse = pre.parameters.max_length
|
pr.maxResponse = pre.parameters.max_length
|
||||||
pr.NAISettings.topK = pre.parameters.top_k
|
pr.NAISettings.topK = pre.parameters.top_k
|
||||||
@@ -1591,7 +1591,7 @@ export async function importPreset(f:{
|
|||||||
|
|
||||||
if(Array.isArray(pre?.prompt_order?.[0]?.order) && Array.isArray(pre?.prompts)){
|
if(Array.isArray(pre?.prompt_order?.[0]?.order) && Array.isArray(pre?.prompts)){
|
||||||
//ST preset
|
//ST preset
|
||||||
const pr = structuredClone(presetTemplate)
|
const pr = safeStructuredClone(presetTemplate)
|
||||||
pr.promptTemplate = []
|
pr.promptTemplate = []
|
||||||
|
|
||||||
function findPrompt(identifier:number){
|
function findPrompt(identifier:number){
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ export async function createMultiuserRoom(){
|
|||||||
snapshot: true
|
snapshot: true
|
||||||
})
|
})
|
||||||
const selectedCharId = get(selectedCharID)
|
const selectedCharId = get(selectedCharID)
|
||||||
const char = structuredClone(db.characters[selectedCharId])
|
const char = safeStructuredClone(db.characters[selectedCharId])
|
||||||
if(char.type === 'group'){
|
if(char.type === 'group'){
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -133,7 +133,7 @@ export async function createMultiuserRoom(){
|
|||||||
snapshot: true
|
snapshot: true
|
||||||
})
|
})
|
||||||
const selectedCharId = get(selectedCharID)
|
const selectedCharId = get(selectedCharID)
|
||||||
const char = structuredClone(db.characters[selectedCharId])
|
const char = safeStructuredClone(db.characters[selectedCharId])
|
||||||
const recivedChar = data.data
|
const recivedChar = data.data
|
||||||
if(char.type === 'group'){
|
if(char.type === 'group'){
|
||||||
return
|
return
|
||||||
@@ -317,7 +317,7 @@ export async function joinMultiuserRoom(){
|
|||||||
snapshot: true
|
snapshot: true
|
||||||
})
|
})
|
||||||
const selectedCharId = get(selectedCharID)
|
const selectedCharId = get(selectedCharID)
|
||||||
const char = structuredClone(db.characters[selectedCharId])
|
const char = safeStructuredClone(db.characters[selectedCharId])
|
||||||
char.chats[char.chatPage] = data.data
|
char.chats[char.chatPage] = data.data
|
||||||
db.characters[selectedCharId] = char
|
db.characters[selectedCharId] = char
|
||||||
latestSyncChat = data.data
|
latestSyncChat = data.data
|
||||||
|
|||||||
1
src/vite-env.d.ts
vendored
1
src/vite-env.d.ts
vendored
@@ -3,3 +3,4 @@
|
|||||||
|
|
||||||
|
|
||||||
declare var Buffer: BufferConstructor
|
declare var Buffer: BufferConstructor
|
||||||
|
declare var safeStructuredClone: <T>(data: T) => T
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "ES2022",
|
"target": "ES2023",
|
||||||
"useDefineForClassFields": true,
|
"useDefineForClassFields": true,
|
||||||
"module": "ES2022",
|
"module": "ES2022",
|
||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
|
|||||||
Reference in New Issue
Block a user