feat: add mode param options

This commit is contained in:
RohitR311
2025-05-07 09:30:25 +05:30
parent 817c7254d2
commit 38430ec4c1

View File

@@ -37,6 +37,7 @@ declare global {
* Defines optional intepreter options (passed in constructor)
*/
interface InterpreterOptions {
mode?: string;
maxRepeats: number;
maxConcurrency: number;
serializableCallback: (output: any) => (void | Promise<void>);
@@ -432,6 +433,11 @@ export default class Interpreter extends EventEmitter {
if (this.options.debugChannel?.setActionType) {
this.options.debugChannel.setActionType('scrapeSchema');
}
if (this.options.mode && this.options.mode === 'editor') {
await this.options.serializableCallback({});
return;
}
await this.ensureScriptsLoaded(page);
@@ -463,6 +469,11 @@ export default class Interpreter extends EventEmitter {
this.options.debugChannel.setActionType('scrapeList');
}
if (this.options.mode && this.options.mode === 'editor') {
await this.options.serializableCallback({});
return;
}
await this.ensureScriptsLoaded(page);
if (!config.pagination) {
const scrapeResults: Record<string, any>[] = await page.evaluate((cfg) => window.scrapeList(cfg), config);