Fix store making vite crash on hmr

This commit is contained in:
kwaroran
2024-10-26 20:27:47 +09:00
parent 40655c266f
commit d575b0817c
8 changed files with 107 additions and 120 deletions

View File

@@ -1,11 +1,10 @@
<script lang="ts"> <script lang="ts">
import { DynamicGUI, settingsOpen, sideBarStore, ShowRealmFrameStore, openPresetList, openPersonaList, MobileGUI, CustomGUISettingMenuStore, loadedStore, alertStore } from './ts/stores';
import Sidebar from './lib/SideBars/Sidebar.svelte'; import Sidebar from './lib/SideBars/Sidebar.svelte';
import { DynamicGUI, settingsOpen, sideBarStore, ShowRealmFrameStore, openPresetList, openPersonaList, MobileGUI, CustomGUISettingMenuStore } from './ts/stores'; import { DBState } from './ts/storage/database.svelte';
import { DBState, loadedStore } from './ts/storage/database.svelte';
import ChatScreen from './lib/ChatScreens/ChatScreen.svelte'; import ChatScreen from './lib/ChatScreens/ChatScreen.svelte';
import AlertComp from './lib/Others/AlertComp.svelte'; import AlertComp from './lib/Others/AlertComp.svelte';
import RealmPopUp from './lib/UI/Realm/RealmPopUp.svelte'; import RealmPopUp from './lib/UI/Realm/RealmPopUp.svelte';
import { alertStore } from './ts/alert';
import GridChars from './lib/Others/GridCatalog.svelte'; import GridChars from './lib/Others/GridCatalog.svelte';
import WelcomeRisu from './lib/Others/WelcomeRisu.svelte'; import WelcomeRisu from './lib/Others/WelcomeRisu.svelte';
import Settings from './lib/Setting/Settings.svelte'; import Settings from './lib/Setting/Settings.svelte';

View File

@@ -3,7 +3,7 @@
import Suggestion from './Suggestion.svelte'; import Suggestion from './Suggestion.svelte';
import AdvancedChatEditor from './AdvancedChatEditor.svelte'; import AdvancedChatEditor from './AdvancedChatEditor.svelte';
import { CameraIcon, DatabaseIcon, DicesIcon, GlobeIcon, ImagePlusIcon, LanguagesIcon, Laugh, MenuIcon, MicOffIcon, PackageIcon, Plus, RefreshCcwIcon, ReplyIcon, Send, StepForwardIcon } from "lucide-svelte"; import { CameraIcon, DatabaseIcon, DicesIcon, GlobeIcon, ImagePlusIcon, LanguagesIcon, Laugh, MenuIcon, MicOffIcon, PackageIcon, Plus, RefreshCcwIcon, ReplyIcon, Send, StepForwardIcon } from "lucide-svelte";
import { selectedCharID, CurrentShowMemoryLimit, PlaygroundStore, UserIconProtrait, createSimpleCharacter } from "../../ts/stores"; import { selectedCharID, PlaygroundStore, UserIconProtrait, createSimpleCharacter } from "../../ts/stores";
import Chat from "./Chat.svelte"; import Chat from "./Chat.svelte";
import { DBState, type Message, type character, type groupChat } from "../../ts/storage/database.svelte"; import { DBState, type Message, type character, type groupChat } from "../../ts/storage/database.svelte";
import { getCharImage } from "../../ts/characters"; import { getCharImage } from "../../ts/characters";
@@ -565,7 +565,7 @@
rerollIcon={i === 0} rerollIcon={i === 0}
onReroll={reroll} onReroll={reroll}
unReroll={unReroll} unReroll={unReroll}
isLastMemory={DBState.db.characters[$selectedCharID].chats[DBState.db.characters[$selectedCharID].chatPage].lastMemory === (chat.chatId ?? 'none') && $CurrentShowMemoryLimit} isLastMemory={DBState.db.characters[$selectedCharID].chats[DBState.db.characters[$selectedCharID].chatPage].lastMemory === (chat.chatId ?? 'none') && DBState.db.showMemoryLimit}
character={createSimpleCharacter(DBState.db.characters[$selectedCharID])} character={createSimpleCharacter(DBState.db.characters[$selectedCharID])}
largePortrait={DBState.db.characters[$selectedCharID].largePortrait} largePortrait={DBState.db.characters[$selectedCharID].largePortrait}
messageGenerationInfo={chat.generationInfo} messageGenerationInfo={chat.generationInfo}
@@ -579,7 +579,7 @@
onReroll={reroll} onReroll={reroll}
unReroll={unReroll} unReroll={unReroll}
img={getCharImage(findCharacterbyId(chat.saying).image, 'css')} img={getCharImage(findCharacterbyId(chat.saying).image, 'css')}
isLastMemory={DBState.db.characters[$selectedCharID].chats[DBState.db.characters[$selectedCharID].chatPage].lastMemory === (chat.chatId ?? 'none') && $CurrentShowMemoryLimit} isLastMemory={DBState.db.characters[$selectedCharID].chats[DBState.db.characters[$selectedCharID].chatPage].lastMemory === (chat.chatId ?? 'none') && DBState.db.showMemoryLimit}
character={chat.saying} character={chat.saying}
largePortrait={findCharacterbyId(chat.saying).largePortrait} largePortrait={findCharacterbyId(chat.saying).largePortrait}
messageGenerationInfo={chat.generationInfo} messageGenerationInfo={chat.generationInfo}
@@ -592,7 +592,7 @@
name={chat.name ?? DBState.db.username} name={chat.name ?? DBState.db.username}
message={chat.data} message={chat.data}
img={$ConnectionOpenStore ? '' : getCharImage(DBState.db.userIcon, 'css')} img={$ConnectionOpenStore ? '' : getCharImage(DBState.db.userIcon, 'css')}
isLastMemory={DBState.db.characters[$selectedCharID].chats[DBState.db.characters[$selectedCharID].chatPage].lastMemory === (chat.chatId ?? 'none') && $CurrentShowMemoryLimit} isLastMemory={DBState.db.characters[$selectedCharID].chats[DBState.db.characters[$selectedCharID].chatPage].lastMemory === (chat.chatId ?? 'none') && DBState.db.showMemoryLimit}
largePortrait={$UserIconProtrait} largePortrait={$UserIconProtrait}
messageGenerationInfo={chat.generationInfo} messageGenerationInfo={chat.generationInfo}
/> />

View File

@@ -1,5 +1,5 @@
<script lang="ts"> <script lang="ts">
import { alertStore, alertGenerationInfoStore } from "../../ts/alert"; import { alertGenerationInfoStore } from "../../ts/alert";
import { DBState } from '../../ts/storage/database.svelte'; import { DBState } from '../../ts/storage/database.svelte';
import { getCharImage } from '../../ts/characters'; import { getCharImage } from '../../ts/characters';
import { ParseMarkdown } from '../../ts/parser.svelte'; import { ParseMarkdown } from '../../ts/parser.svelte';
@@ -14,7 +14,7 @@
import OptionInput from "../UI/GUI/OptionInput.svelte"; import OptionInput from "../UI/GUI/OptionInput.svelte";
import { language } from 'src/lang'; import { language } from 'src/lang';
import { getFetchData } from 'src/ts/storage/globalApi'; import { getFetchData } from 'src/ts/storage/globalApi';
import { selectedCharID } from "src/ts/stores"; import { alertStore, selectedCharID } from "src/ts/stores";
import { tokenize } from "src/ts/tokenizer"; import { tokenize } from "src/ts/tokenizer";
import TextAreaInput from "../UI/GUI/TextAreaInput.svelte"; import TextAreaInput from "../UI/GUI/TextAreaInput.svelte";
import ModuleChatMenu from "../Setting/Pages/Module/ModuleChatMenu.svelte"; import ModuleChatMenu from "../Setting/Pages/Module/ModuleChatMenu.svelte";

View File

@@ -4,8 +4,9 @@ import { language } from "../lang"
import { isNodeServer, isTauri } from "./storage/globalApi" import { isNodeServer, isTauri } from "./storage/globalApi"
import { Capacitor } from "@capacitor/core" import { Capacitor } from "@capacitor/core"
import { getDatabase, type MessageGenerationInfo } from "./storage/database.svelte" import { getDatabase, type MessageGenerationInfo } from "./storage/database.svelte"
import { alertStore as alertStoreImported } from "./stores"
interface alertData{ export interface alertData{
type: 'error'|'normal'|'none'|'ask'|'wait'|'selectChar' type: 'error'|'normal'|'none'|'ask'|'wait'|'selectChar'
|'input'|'toast'|'wait2'|'markdown'|'select'|'login' |'input'|'toast'|'wait2'|'markdown'|'select'|'login'
|'tos'|'cardexport'|'requestdata'|'addchar'|'hypaV2'|'selectModule' |'tos'|'cardexport'|'requestdata'|'addchar'|'hypaV2'|'selectModule'
@@ -14,16 +15,16 @@ interface alertData{
submsg?: string submsg?: string
} }
export const alertStore = writable({
type: 'none',
msg: 'n',
} as alertData)
type AlertGenerationInfoStoreData = { type AlertGenerationInfoStoreData = {
genInfo: MessageGenerationInfo, genInfo: MessageGenerationInfo,
idx: number idx: number
} }
export const alertGenerationInfoStore = writable<AlertGenerationInfoStoreData>(null) export const alertGenerationInfoStore = writable<AlertGenerationInfoStoreData>(null)
export const alertStore = {
set: (d:alertData) => {
alertStoreImported.set(d)
}
}
export function alertError(msg:string){ export function alertError(msg:string){
console.error(msg) console.error(msg)
@@ -55,7 +56,7 @@ export function alertError(msg:string){
(!isTauri && !isNodeServer && !Capacitor.isNativePlatform()) ? language.errors.networkFetchWeb : language.errors.networkFetch (!isTauri && !isNodeServer && !Capacitor.isNativePlatform()) ? language.errors.networkFetchWeb : language.errors.networkFetch
} }
alertStore.set({ alertStoreImported.set({
'type': 'error', 'type': 'error',
'msg': msg, 'msg': msg,
'submsg': submsg 'submsg': submsg
@@ -63,19 +64,19 @@ export function alertError(msg:string){
} }
export function alertNormal(msg:string){ export function alertNormal(msg:string){
alertStore.set({ alertStoreImported.set({
'type': 'normal', 'type': 'normal',
'msg': msg 'msg': msg
}) })
} }
export async function alertNormalWait(msg:string){ export async function alertNormalWait(msg:string){
alertStore.set({ alertStoreImported.set({
'type': 'normal', 'type': 'normal',
'msg': msg 'msg': msg
}) })
while(true){ while(true){
if (get(alertStore).type === 'none'){ if (get(alertStoreImported).type === 'none'){
break break
} }
await sleep(10) await sleep(10)
@@ -83,73 +84,73 @@ export async function alertNormalWait(msg:string){
} }
export async function alertAddCharacter() { export async function alertAddCharacter() {
alertStore.set({ alertStoreImported.set({
'type': 'addchar', 'type': 'addchar',
'msg': language.addCharacter 'msg': language.addCharacter
}) })
while(true){ while(true){
if (get(alertStore).type === 'none'){ if (get(alertStoreImported).type === 'none'){
break break
} }
await sleep(10) await sleep(10)
} }
return get(alertStore).msg return get(alertStoreImported).msg
} }
export async function alertChatOptions() { export async function alertChatOptions() {
alertStore.set({ alertStoreImported.set({
'type': 'chatOptions', 'type': 'chatOptions',
'msg': language.chatOptions 'msg': language.chatOptions
}) })
while(true){ while(true){
if (get(alertStore).type === 'none'){ if (get(alertStoreImported).type === 'none'){
break break
} }
await sleep(10) await sleep(10)
} }
return parseInt(get(alertStore).msg) return parseInt(get(alertStoreImported).msg)
} }
export async function alertLogin(){ export async function alertLogin(){
alertStore.set({ alertStoreImported.set({
'type': 'login', 'type': 'login',
'msg': 'login' 'msg': 'login'
}) })
while(true){ while(true){
if (get(alertStore).type === 'none'){ if (get(alertStoreImported).type === 'none'){
break break
} }
await sleep(10) await sleep(10)
} }
return get(alertStore).msg return get(alertStoreImported).msg
} }
export async function alertSelect(msg:string[]){ export async function alertSelect(msg:string[]){
alertStore.set({ alertStoreImported.set({
'type': 'select', 'type': 'select',
'msg': msg.join('||') 'msg': msg.join('||')
}) })
while(true){ while(true){
if (get(alertStore).type === 'none'){ if (get(alertStoreImported).type === 'none'){
break break
} }
await sleep(10) await sleep(10)
} }
return get(alertStore).msg return get(alertStoreImported).msg
} }
export async function alertErrorWait(msg:string){ export async function alertErrorWait(msg:string){
alertStore.set({ alertStoreImported.set({
'type': 'wait2', 'type': 'wait2',
'msg': msg 'msg': msg
}) })
while(true){ while(true){
if (get(alertStore).type === 'none'){ if (get(alertStoreImported).type === 'none'){
break break
} }
await sleep(10) await sleep(10)
@@ -157,25 +158,25 @@ export async function alertErrorWait(msg:string){
} }
export function alertMd(msg:string){ export function alertMd(msg:string){
alertStore.set({ alertStoreImported.set({
'type': 'markdown', 'type': 'markdown',
'msg': msg 'msg': msg
}) })
} }
export function doingAlert(){ export function doingAlert(){
return get(alertStore).type !== 'none' && get(alertStore).type !== 'toast' return get(alertStoreImported).type !== 'none' && get(alertStoreImported).type !== 'toast'
} }
export function alertToast(msg:string){ export function alertToast(msg:string){
alertStore.set({ alertStoreImported.set({
'type': 'toast', 'type': 'toast',
'msg': msg 'msg': msg
}) })
} }
export function alertWait(msg:string){ export function alertWait(msg:string){
alertStore.set({ alertStoreImported.set({
'type': 'wait', 'type': 'wait',
'msg': msg 'msg': msg
}) })
@@ -184,61 +185,61 @@ export function alertWait(msg:string){
export function alertClear(){ export function alertClear(){
alertStore.set({ alertStoreImported.set({
'type': 'none', 'type': 'none',
'msg': '' 'msg': ''
}) })
} }
export async function alertSelectChar(){ export async function alertSelectChar(){
alertStore.set({ alertStoreImported.set({
'type': 'selectChar', 'type': 'selectChar',
'msg': '' 'msg': ''
}) })
while(true){ while(true){
if (get(alertStore).type === 'none'){ if (get(alertStoreImported).type === 'none'){
break break
} }
await sleep(10) await sleep(10)
} }
return get(alertStore).msg return get(alertStoreImported).msg
} }
export async function alertConfirm(msg:string){ export async function alertConfirm(msg:string){
alertStore.set({ alertStoreImported.set({
'type': 'ask', 'type': 'ask',
'msg': msg 'msg': msg
}) })
while(true){ while(true){
if (get(alertStore).type === 'none'){ if (get(alertStoreImported).type === 'none'){
break break
} }
await sleep(10) await sleep(10)
} }
return get(alertStore).msg === 'yes' return get(alertStoreImported).msg === 'yes'
} }
export async function alertCardExport(type:string = ''){ export async function alertCardExport(type:string = ''){
alertStore.set({ alertStoreImported.set({
'type': 'cardexport', 'type': 'cardexport',
'msg': '', 'msg': '',
'submsg': type 'submsg': type
}) })
while(true){ while(true){
if (get(alertStore).type === 'none'){ if (get(alertStoreImported).type === 'none'){
break break
} }
await sleep(10) await sleep(10)
} }
return JSON.parse(get(alertStore).msg) as { return JSON.parse(get(alertStoreImported).msg) as {
type: string, type: string,
type2: string, type2: string,
} }
@@ -250,19 +251,19 @@ export async function alertTOS(){
return true return true
} }
alertStore.set({ alertStoreImported.set({
'type': 'tos', 'type': 'tos',
'msg': 'tos' 'msg': 'tos'
}) })
while(true){ while(true){
if (get(alertStore).type === 'none'){ if (get(alertStoreImported).type === 'none'){
break break
} }
await sleep(10) await sleep(10)
} }
if(get(alertStore).msg === 'yes'){ if(get(alertStoreImported).msg === 'yes'){
localStorage.setItem('tos2', 'true') localStorage.setItem('tos2', 'true')
return true return true
} }
@@ -272,48 +273,48 @@ export async function alertTOS(){
export async function alertInput(msg:string){ export async function alertInput(msg:string){
alertStore.set({ alertStoreImported.set({
'type': 'input', 'type': 'input',
'msg': msg 'msg': msg
}) })
while(true){ while(true){
if (get(alertStore).type === 'none'){ if (get(alertStoreImported).type === 'none'){
break break
} }
await sleep(10) await sleep(10)
} }
return get(alertStore).msg return get(alertStoreImported).msg
} }
export async function alertModuleSelect(){ export async function alertModuleSelect(){
alertStore.set({ alertStoreImported.set({
'type': 'selectModule', 'type': 'selectModule',
'msg': '' 'msg': ''
}) })
while(true){ while(true){
if (get(alertStore).type === 'none'){ if (get(alertStoreImported).type === 'none'){
break break
} }
await sleep(10) await sleep(20)
} }
return get(alertStore).msg return get(alertStoreImported).msg
} }
export function alertRequestData(info:AlertGenerationInfoStoreData){ export function alertRequestData(info:AlertGenerationInfoStoreData){
alertGenerationInfoStore.set(info) alertGenerationInfoStore.set(info)
alertStore.set({ alertStoreImported.set({
'type': 'requestdata', 'type': 'requestdata',
'msg': info.genInfo.generationId ?? 'none' 'msg': info.genInfo.generationId ?? 'none'
}) })
} }
export function showHypaV2Alert(){ export function showHypaV2Alert(){
alertStore.set({ alertStoreImported.set({
'type': 'hypaV2', 'type': 'hypaV2',
'msg': "" 'msg': ""
}) })

View File

@@ -8,6 +8,7 @@ import { convertExternalLorebook } from "./lorebook.svelte"
import { decodeRPack, encodeRPack } from "../rpack/rpack_bg" import { decodeRPack, encodeRPack } from "../rpack/rpack_bg"
import { convertImage } from "../parser.svelte" import { convertImage } from "../parser.svelte"
import { Capacitor } from "@capacitor/core" import { Capacitor } from "@capacitor/core"
import { HideIconStore, moduleBackgroundEmbedding } from "../stores"
export interface RisuModule{ export interface RisuModule{
name: string name: string
@@ -392,4 +393,39 @@ export async function applyModule() {
setCurrentCharacter(currentChar) setCurrentCharacter(currentChar)
alertNormal(language.successApplyModule) alertNormal(language.successApplyModule)
}
let lastGlobalEnabledModules: string[] = []
let lastChatEnabledModules: string[] = []
let characterHideIcon = false
function onModuleUpdate(){
if(!Array.isArray(lastGlobalEnabledModules)){
lastGlobalEnabledModules = []
}
if(!Array.isArray(lastChatEnabledModules)){
lastChatEnabledModules = []
}
const m = getModules()
let moduleHideIcon = false
let backgroundEmbedding = ''
m.forEach((module) => {
if(!module){
return
}
if(module.hideIcon){
moduleHideIcon = true
}
if(module.backgroundEmbedding){
backgroundEmbedding += '\n' + module.backgroundEmbedding + '\n'
}
})
if(backgroundEmbedding){
moduleBackgroundEmbedding.set(backgroundEmbedding)
}
HideIconStore.set(characterHideIcon || moduleHideIcon)
} }

View File

@@ -15,7 +15,6 @@ import type { OobaChatCompletionRequestParams } from '../model/ooba';
export const DBState = $state({ export const DBState = $state({
db: {} as any as Database db: {} as any as Database
}) })
export const loadedStore = writable(false)
export let appVer = "137.1.0" export let appVer = "137.1.0"
export let webAppSubVer = '-svelte5-exp' export let webAppSubVer = '-svelte5-exp'

View File

@@ -13,10 +13,10 @@ import { v4 as uuidv4, v4 } from 'uuid';
import { appDataDir, join } from "@tauri-apps/api/path"; import { appDataDir, join } from "@tauri-apps/api/path";
import { get } from "svelte/store"; import { get } from "svelte/store";
import {open} from '@tauri-apps/plugin-shell' import {open} from '@tauri-apps/plugin-shell'
import { loadedStore, setDatabase, type Database, defaultSdDataFunc, getDatabase } from "./database.svelte"; import { setDatabase, type Database, defaultSdDataFunc, getDatabase } from "./database.svelte";
import { getCurrentWebviewWindow } from "@tauri-apps/api/webviewWindow"; import { getCurrentWebviewWindow } from "@tauri-apps/api/webviewWindow";
import { checkRisuUpdate } from "../update"; import { checkRisuUpdate } from "../update";
import { MobileGUI, botMakerMode, selectedCharID } from "../stores"; import { MobileGUI, botMakerMode, selectedCharID, loadedStore } from "../stores";
import { loadPlugins } from "../plugins/plugins"; import { loadPlugins } from "../plugins/plugins";
import { alertConfirm, alertError, alertNormal, alertNormalWait, alertSelect, alertTOS, alertWait } from "../alert"; import { alertConfirm, alertError, alertNormal, alertNormalWait, alertSelect, alertTOS, alertWait } from "../alert";
import { checkDriverInit, syncDrive } from "../drive/drive"; import { checkDriverInit, syncDrive } from "../drive/drive";

View File

@@ -1,8 +1,7 @@
import { writable, type Writable } from "svelte/store"; import { writable, type Writable } from "svelte/store";
import { getDatabase, type Chat, type character, type groupChat } from "./storage/database.svelte"; import type { character, groupChat } from "./storage/database.svelte";
import type { simpleCharacterArgument } from "./parser.svelte"; import type { simpleCharacterArgument } from "./parser.svelte";
import { sleep } from "./util"; import type { alertData } from "./alert";
import { getModules } from "./process/modules";
function updateSize(){ function updateSize(){
SizeStore.set({ SizeStore.set({
@@ -16,6 +15,9 @@ export const SizeStore = writable({
w: 0, w: 0,
h: 0 h: 0
}) })
const t = 'https://raw.githubusercontent.com/ProjectAliceDev/ProjectAliceDev.github.io/master/'
export const loadedStore = writable(false)
export const DynamicGUI = writable(false) export const DynamicGUI = writable(false)
export const sideBarClosing = writable(false) export const sideBarClosing = writable(false)
export const sideBarStore = writable(window.innerWidth > 1024) export const sideBarStore = writable(window.innerWidth > 1024)
@@ -30,9 +32,6 @@ export const openPersonaList = writable(false)
export const MobileGUI = writable(false) export const MobileGUI = writable(false)
export const MobileGUIStack = writable(0) export const MobileGUIStack = writable(0)
export const MobileSideBar = writable(0) export const MobileSideBar = writable(0)
//optimization
export const CurrentShowMemoryLimit = writable(false) as Writable<boolean>
export const ShowVN = writable(false) export const ShowVN = writable(false)
export const SettingsMenuIndex = writable(-1) export const SettingsMenuIndex = writable(-1)
export const ReloadGUIPointer = writable(0) export const ReloadGUIPointer = writable(0)
@@ -46,12 +45,10 @@ export const SafeModeStore = writable(false)
export const MobileSearch = writable('') export const MobileSearch = writable('')
export const CharConfigSubMenu = writable(0) export const CharConfigSubMenu = writable(0)
export const CustomGUISettingMenuStore = writable(false) export const CustomGUISettingMenuStore = writable(false)
export const alertStore = writable({
let lastGlobalEnabledModules: string[] = [] type: 'none',
let lastChatEnabledModules: string[] = [] msg: 'n',
let moduleHideIcon = false } as alertData)
let characterHideIcon = false
CustomCSSStore.subscribe((css) => { CustomCSSStore.subscribe((css) => {
console.log(css) console.log(css)
@@ -86,50 +83,5 @@ export function createSimpleCharacter(char:character|groupChat){
} }
function trySync(){
try {
let db = getDatabase()
CurrentShowMemoryLimit.set(db.showMemoryLimit)
} catch (error) {}
}
trySync()
async function preInit(){
await sleep(1)
}
function onModuleUpdate(){
if(!Array.isArray(lastGlobalEnabledModules)){
lastGlobalEnabledModules = []
}
if(!Array.isArray(lastChatEnabledModules)){
lastChatEnabledModules = []
}
const m = getModules()
let moduleHideIcon = false
let backgroundEmbedding = ''
m.forEach((module) => {
if(!module){
return
}
if(module.hideIcon){
moduleHideIcon = true
}
if(module.backgroundEmbedding){
backgroundEmbedding += '\n' + module.backgroundEmbedding + '\n'
}
})
if(backgroundEmbedding){
moduleBackgroundEmbedding.set(backgroundEmbedding)
}
HideIconStore.set(characterHideIcon || moduleHideIcon)
}
updateSize() updateSize()
window.addEventListener("resize", updateSize); window.addEventListener("resize", updateSize);
preInit()