feat(PageController): make showMask and hideMask async

This commit is contained in:
Simon
2026-01-19 12:54:33 +08:00
parent ef2777b521
commit 6820eec676
2 changed files with 9 additions and 5 deletions

View File

@@ -82,6 +82,7 @@ export class PageController extends EventTarget {
/** Visual mask overlay for blocking user interaction during automation */
private mask: InstanceType<typeof import('./mask/SimulatorMask').SimulatorMask> | null = null
private maskReady: Promise<void> | null = null
constructor(config: PageControllerConfig = {}) {
super()
@@ -91,9 +92,10 @@ export class PageController extends EventTarget {
patchReact(this)
if (config.enableMask) {
this.initMask()
this.maskReady = this.initMask()
}
}
/**
* Initialize mask asynchronously (dynamic import to avoid CSS loading in Node)
*/
@@ -369,7 +371,8 @@ export class PageController extends EventTarget {
* Show the visual mask overlay.
* Only works if enableMask was set to true in config.
*/
showMask(): void {
async showMask(): Promise<void> {
await this.maskReady
this.mask?.show()
}
@@ -377,7 +380,8 @@ export class PageController extends EventTarget {
* Hide the visual mask overlay.
* Only works if enableMask was set to true in config.
*/
hideMask(): void {
async hideMask(): Promise<void> {
await this.maskReady
this.mask?.hide()
}