@@ -6,21 +6,17 @@ import { getAddons, getConfig, setConfig } from './config'
66import { SERVICE_WORKER , WEB , WEB_WORKER } from './constant'
77import { hasTouch , isFirefox } from './context'
88import { blur , clickPanel , focus , isInputElement , redrawCaretAndPreeditUnderline } from './focus'
9- import { rmR , traverseAsync } from './fs'
9+ import { mount , reset , rmR , traverseAsync } from './fs'
1010import { currentInputMethod , getAllInputMethods , getInputMethods , getLanguageName , setCurrentInputMethod , setInputMethods } from './input-method'
1111import { createKeyboard , sendEventToKeyboard } from './keyboard'
1212import { jsKeyToFcitxString , keyEvent } from './keycode'
1313import { getLocale } from './locale'
1414import Module from './module'
15- import { getInstalledPlugins , installPlugin , unzip } from './plugin'
15+ import { getInstalledPlugins , installPlugin , restorePlugins , unzip } from './plugin'
1616import { utf8Index2JS } from './unicode'
1717import { deployRimeInWorker } from './workerAPI'
1818
19- let res : ( value : any ) => void
20-
21- const fcitxReady = new Promise ( ( resolve ) => {
22- res = resolve
23- } )
19+ const { promise : fcitxReady , resolve } = Promise . withResolvers ( )
2420
2521let inputMethodsCallback = ( ) => { }
2622let statusAreaCallback = ( ) => { }
@@ -148,6 +144,7 @@ globalThis.fcitx = {
148144 rmR,
149145 traverseAsync,
150146 deployRimeInWorker,
147+ reset,
151148 // Private field that indicates whether spawn a worker in current environment.
152149 // On f5o main thread set true to enable worker. On worker thread this is always false.
153150 useWorker : false ,
@@ -171,7 +168,13 @@ for (const api of apis) {
171168 globalThis . fcitx [ name ] = ( ...args : any [ ] ) => Module . ccall ( 'web_action' , 'void' , [ 'string' , 'string' ] , [ name , JSON . stringify ( args ) ] )
172169}
173170
174- Module . onRuntimeInitialized = ( ) => res ( null )
171+ Module . onRuntimeInitialized = ( ) => {
172+ mount ( )
173+ Module . FS . syncfs ( true , ( ) => {
174+ restorePlugins ( )
175+ resolve ( null )
176+ } )
177+ }
175178
176179export {
177180 fcitxReady ,
0 commit comments