@midscene/cli 1.13.1-beta-20260921032526.0 → 1.13.1-beta-20260921075813.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/framework/index.mjs +20 -5
- package/dist/es/framework/index.mjs.map +1 -1
- package/dist/es/index.mjs +33 -7
- package/dist/es/index.mjs.map +1 -1
- package/dist/lib/framework/index.js +20 -5
- package/dist/lib/framework/index.js.map +1 -1
- package/dist/lib/index.js +33 -7
- package/dist/lib/index.js.map +1 -1
- package/dist/types/framework/index.d.ts +2 -0
- package/package.json +9 -9
|
@@ -2635,6 +2635,7 @@ function printExecutionPlan(config) {
|
|
|
2635
2635
|
console.log(` Continue on error: ${config.continueOnError}`);
|
|
2636
2636
|
console.log(` Retry: ${config.retry ?? 0}`);
|
|
2637
2637
|
console.log(` Share browser context: ${config.shareBrowserContext ?? false}`);
|
|
2638
|
+
console.log(` Reuse browser page: ${config.reusePage ?? false}`);
|
|
2638
2639
|
console.log(` Summary output: ${config.summary}`);
|
|
2639
2640
|
}
|
|
2640
2641
|
function printExecutionFinished() {
|
|
@@ -3329,11 +3330,22 @@ const assertBrowserContextUsage = (setupContext, allContexts, shareBrowserContex
|
|
|
3329
3330
|
}
|
|
3330
3331
|
if (setupContext && !shareBrowserContext && 'puppeteer-web' === resolveBatchRuntimeTarget(setupContext.executionConfig)) throw new Error(`Puppeteer Web setup "${setupContext.file}" requires shareBrowserContext: true so its browser state can be shared with the main files.`);
|
|
3331
3332
|
};
|
|
3332
|
-
const createSharedBrowserRuntime = async (browser, browserContextOptions)=>{
|
|
3333
|
+
const createSharedBrowserRuntime = async (browser, browserContextOptions, reusePage = false)=>{
|
|
3333
3334
|
const browserContext = await browser.createBrowserContext(browserContextOptions);
|
|
3334
|
-
|
|
3335
|
-
browserContext
|
|
3336
|
-
|
|
3335
|
+
try {
|
|
3336
|
+
const page = reusePage ? await browserContext.newPage() : void 0;
|
|
3337
|
+
return {
|
|
3338
|
+
browserContext,
|
|
3339
|
+
page
|
|
3340
|
+
};
|
|
3341
|
+
} catch (error) {
|
|
3342
|
+
try {
|
|
3343
|
+
await browserContext.close();
|
|
3344
|
+
} catch (cleanupError) {
|
|
3345
|
+
batchWarning('failed to close the shared browser context after page creation failed; preserving the original error', cleanupError);
|
|
3346
|
+
}
|
|
3347
|
+
throw error;
|
|
3348
|
+
}
|
|
3337
3349
|
};
|
|
3338
3350
|
class YamlBatchExecutor {
|
|
3339
3351
|
async run(options = {}) {
|
|
@@ -3418,10 +3430,11 @@ class YamlBatchExecutor {
|
|
|
3418
3430
|
sharedRuntime.current = null;
|
|
3419
3431
|
await staleRuntime.browserContext.close();
|
|
3420
3432
|
}
|
|
3421
|
-
sharedRuntime.current = await createSharedBrowserRuntime(browser, browserContextOptions);
|
|
3433
|
+
sharedRuntime.current = await createSharedBrowserRuntime(browser, browserContextOptions, this.config.reusePage);
|
|
3422
3434
|
for (const context of allContexts){
|
|
3423
3435
|
context.options.browser = browser;
|
|
3424
3436
|
context.options.browserContext = sharedRuntime.current.browserContext;
|
|
3437
|
+
if (sharedRuntime.current.page) context.options.page = sharedRuntime.current.page;
|
|
3425
3438
|
}
|
|
3426
3439
|
};
|
|
3427
3440
|
await resetSetupRuntime();
|
|
@@ -3701,6 +3714,8 @@ class YamlBatchExecutor {
|
|
|
3701
3714
|
}, (_, index)=>`batch-occurrence-${index + 1}`);
|
|
3702
3715
|
if (this.caseIds.length !== occurrenceCount) throw new Error(`Batch occurrence identity mismatch: expected ${occurrenceCount} case ID(s), received ${this.caseIds.length}`);
|
|
3703
3716
|
if (new Set(this.caseIds).size !== this.caseIds.length) throw new Error('Batch occurrence case IDs must be unique');
|
|
3717
|
+
if (config.reusePage && !config.shareBrowserContext) throw new Error('reusePage requires shareBrowserContext: true');
|
|
3718
|
+
if (config.reusePage && 1 !== config.concurrent) throw new Error('reusePage requires concurrent: 1');
|
|
3704
3719
|
}
|
|
3705
3720
|
}
|
|
3706
3721
|
async function runYamlBatch(config, options = {}) {
|