feat: helper fxn for user input
This commit is contained in:
@@ -13,3 +13,34 @@ import { Page } from "playwright";
|
|||||||
import { throttle } from "../../../src/helpers/inputHelpers";
|
import { throttle } from "../../../src/helpers/inputHelpers";
|
||||||
import { CustomActions } from "../../../src/shared/types";
|
import { CustomActions } from "../../../src/shared/types";
|
||||||
|
|
||||||
|
|
||||||
|
const handleWrapper = async (
|
||||||
|
handleCallback: (
|
||||||
|
generator: WorkflowGenerator,
|
||||||
|
page: Page,
|
||||||
|
args?: any
|
||||||
|
) => Promise<void>,
|
||||||
|
args?: any
|
||||||
|
) => {
|
||||||
|
const id = browserPool.getActiveBrowserId();
|
||||||
|
if (id) {
|
||||||
|
const activeBrowser = browserPool.getRemoteBrowser(id);
|
||||||
|
if (activeBrowser?.interpreter.interpretationInProgress() && !activeBrowser.interpreter.interpretationIsPaused) {
|
||||||
|
logger.log('debug', `Ignoring input, while interpretation is in progress`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const currentPage = activeBrowser?.getCurrentPage();
|
||||||
|
if (currentPage && activeBrowser) {
|
||||||
|
if (args) {
|
||||||
|
await handleCallback(activeBrowser.generator, currentPage, args);
|
||||||
|
} else {
|
||||||
|
await handleCallback(activeBrowser.generator, currentPage);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logger.log('warn', `No active page for browser ${id}`);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logger.log('warn', `No active browser for id ${id}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user