Improve app launch speed

This commit is contained in:
2025-09-21 03:04:23 +08:00
parent e372a0dd7c
commit 0338351680
80 changed files with 1227 additions and 17065 deletions

View File

@@ -20,19 +20,30 @@ const webParser: Parser<string> = {
locEnd: (text: string) => text.length,
};
// Initialize web_fmt WASM module
// Lazy initialize web_fmt WASM module
let processorInstance: any = null;
let initPromise: Promise<any> | null = null;
const getProcessorInstance = async () => {
if (!processorInstance) {
try {
await webInit();
processorInstance = { initialized: true };
} catch (error) {
console.warn('Failed to initialize web_fmt WASM module:', error);
processorInstance = null;
}
if (!processorInstance && !initPromise) {
initPromise = (async () => {
try {
await webInit();
processorInstance = { initialized: true };
return processorInstance;
} catch (error) {
console.warn('Failed to initialize web_fmt WASM module:', error);
processorInstance = null;
initPromise = null;
throw error;
}
})();
}
if (initPromise) {
return await initPromise;
}
return processorInstance;
};