feat: delay mask import

This commit is contained in:
Simon
2026-01-28 17:16:39 +08:00
parent 142231a16c
commit 04d51c566d
2 changed files with 13 additions and 11 deletions

View File

@@ -94,17 +94,18 @@ export class PageController extends EventTarget {
patchReact(this)
if (config.enableMask) {
this.maskReady = this.initMask()
}
if (config.enableMask) this.initMask()
}
/**
* Initialize mask asynchronously (dynamic import to avoid CSS loading in Node)
*/
private async initMask(): Promise<void> {
const { SimulatorMask } = await import('./mask/SimulatorMask')
this.mask = new SimulatorMask()
initMask() {
if (this.maskReady !== null) return
this.maskReady = (async () => {
const { SimulatorMask } = await import('./mask/SimulatorMask')
this.mask = new SimulatorMask()
})()
}
// ======= State Queries =======
@@ -394,7 +395,7 @@ export class PageController extends EventTarget {
/**
* Show the visual mask overlay.
* Only works if enableMask was set to true in config.
* Only works after mask is setup.
*/
async showMask(): Promise<void> {
await this.maskReady
@@ -403,7 +404,7 @@ export class PageController extends EventTarget {
/**
* Hide the visual mask overlay.
* Only works if enableMask was set to true in config.
* Only works after mask is setup.
*/
async hideMask(): Promise<void> {
await this.maskReady