From 38430ec4c1a9820f4feaf18b97eaa7cb937e338d Mon Sep 17 00:00:00 2001 From: RohitR311 Date: Wed, 7 May 2025 09:30:25 +0530 Subject: [PATCH] feat: add mode param options --- maxun-core/src/interpret.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/maxun-core/src/interpret.ts b/maxun-core/src/interpret.ts index 91ade8b2..69dd3127 100644 --- a/maxun-core/src/interpret.ts +++ b/maxun-core/src/interpret.ts @@ -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); @@ -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[] = await page.evaluate((cfg) => window.scrapeList(cfg), config);