feat(PageController): make showMask and hideMask async
This commit is contained in:
@@ -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()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user