@midscene/cli 1.12.9 → 1.12.10-beta-20260918062325.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/lib/index.js CHANGED
@@ -3271,6 +3271,7 @@ var __webpack_modules__ = {
3271
3271
  console.log(` Continue on error: ${config.continueOnError}`);
3272
3272
  console.log(` Retry: ${config.retry ?? 0}`);
3273
3273
  console.log(` Share browser context: ${config.shareBrowserContext ?? false}`);
3274
+ console.log(` Reuse browser page: ${config.reusePage ?? false}`);
3274
3275
  console.log(` Summary output: ${config.summary}`);
3275
3276
  }
3276
3277
  function printExecutionFinished() {
@@ -4249,11 +4250,22 @@ var __webpack_modules__ = {
4249
4250
  }
4250
4251
  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.`);
4251
4252
  };
4252
- const createSharedBrowserRuntime = async (browser, browserContextOptions)=>{
4253
+ const createSharedBrowserRuntime = async (browser, browserContextOptions, reusePage = false)=>{
4253
4254
  const browserContext = await browser.createBrowserContext(browserContextOptions);
4254
- return {
4255
- browserContext
4256
- };
4255
+ try {
4256
+ const page = reusePage ? await browserContext.newPage() : void 0;
4257
+ return {
4258
+ browserContext,
4259
+ page
4260
+ };
4261
+ } catch (error) {
4262
+ try {
4263
+ await browserContext.close();
4264
+ } catch (cleanupError) {
4265
+ batchWarning('failed to close the shared browser context after page creation failed; preserving the original error', cleanupError);
4266
+ }
4267
+ throw error;
4268
+ }
4257
4269
  };
4258
4270
  class YamlBatchExecutor {
4259
4271
  async run(options = {}) {
@@ -4338,10 +4350,11 @@ var __webpack_modules__ = {
4338
4350
  sharedRuntime.current = null;
4339
4351
  await staleRuntime.browserContext.close();
4340
4352
  }
4341
- sharedRuntime.current = await createSharedBrowserRuntime(browser, browserContextOptions);
4353
+ sharedRuntime.current = await createSharedBrowserRuntime(browser, browserContextOptions, this.config.reusePage);
4342
4354
  for (const context of allContexts){
4343
4355
  context.options.browser = browser;
4344
4356
  context.options.browserContext = sharedRuntime.current.browserContext;
4357
+ if (sharedRuntime.current.page) context.options.page = sharedRuntime.current.page;
4345
4358
  }
4346
4359
  };
4347
4360
  await resetSetupRuntime();
@@ -4621,6 +4634,8 @@ var __webpack_modules__ = {
4621
4634
  }, (_, index)=>`batch-occurrence-${index + 1}`);
4622
4635
  if (this.caseIds.length !== occurrenceCount) throw new Error(`Batch occurrence identity mismatch: expected ${occurrenceCount} case ID(s), received ${this.caseIds.length}`);
4623
4636
  if (new Set(this.caseIds).size !== this.caseIds.length) throw new Error('Batch occurrence case IDs must be unique');
4637
+ if (config.reusePage && !config.shareBrowserContext) throw new Error('reusePage requires shareBrowserContext: true');
4638
+ if (config.reusePage && 1 !== config.concurrent) throw new Error('reusePage requires concurrent: 1');
4624
4639
  }
4625
4640
  }
4626
4641
  async function runYamlBatch(config, options = {}) {
@@ -5069,9 +5084,7 @@ defineYamlBatchTest(test, testOptions);
5069
5084
  "use strict";
5070
5085
  var core_ = __webpack_require__("@midscene/core");
5071
5086
  const cli_namespaceObject = require("@midscene/shared/cli");
5072
- var package_namespaceObject = {
5073
- rE: "1.12.9"
5074
- };
5087
+ var package_namespaceObject = JSON.parse('{"rE":"1.12.10-beta-20260918062325.0"}');
5075
5088
  var external_node_fs_ = __webpack_require__("node:fs");
5076
5089
  var external_node_fs_namespaceObject = /*#__PURE__*/ __webpack_require__.t(external_node_fs_, 2);
5077
5090
  var external_node_path_ = __webpack_require__("node:path");
@@ -10662,6 +10675,7 @@ defineYamlBatchTest(test, testOptions);
10662
10675
  continueOnError: false,
10663
10676
  retry: 0,
10664
10677
  shareBrowserContext: false,
10678
+ reusePage: false,
10665
10679
  headed: false,
10666
10680
  keepWindow: false,
10667
10681
  dotenvOverride: false,
@@ -10736,6 +10750,10 @@ Usage:
10736
10750
  type: 'boolean',
10737
10751
  description: `Share a Puppeteer Web browser context across multiple yaml files, default is ${config_options_defaultConfig.shareBrowserContext}`
10738
10752
  },
10753
+ 'reuse-page': {
10754
+ type: 'boolean',
10755
+ description: `Reuse one Puppeteer Web page across sequential yaml files; requires --share-browser-context and --concurrent 1, default is ${config_options_defaultConfig.reusePage}`
10756
+ },
10739
10757
  'dotenv-override': {
10740
10758
  type: 'boolean',
10741
10759
  description: `Whether the variables in the .env file override the global variables, the default is ${config_options_defaultConfig.dotenvOverride}`
@@ -10748,7 +10766,7 @@ Usage:
10748
10766
  type: 'boolean',
10749
10767
  description: 'Whether to dismiss the HarmonyOS keyboard after text input'
10750
10768
  }
10751
- }).version('version', 'Show version number', "1.12.9").help().epilogue(`For complete list of configuration options, please visit:
10769
+ }).version('version', 'Show version number', "1.12.10-beta-20260918062325.0").help().epilogue(`For complete list of configuration options, please visit:
10752
10770
  • Web options: https://midscenejs.com/automate-with-scripts-in-yaml#the-web-part
10753
10771
  • Android options: https://midscenejs.com/automate-with-scripts-in-yaml#the-android-part
10754
10772
  • HarmonyOS options: https://midscenejs.com/automate-with-scripts-in-yaml#the-harmony-part
@@ -12924,6 +12942,7 @@ Examples:
12924
12942
  retry: configYaml.retry ?? config_options_defaultConfig.retry,
12925
12943
  summary: configYaml.summary ?? defaultSummary,
12926
12944
  shareBrowserContext: configYaml.shareBrowserContext ?? config_options_defaultConfig.shareBrowserContext,
12945
+ reusePage: configYaml.reusePage ?? config_options_defaultConfig.reusePage,
12927
12946
  patterns: configYaml.files,
12928
12947
  files,
12929
12948
  setup,
@@ -12951,6 +12970,7 @@ Examples:
12951
12970
  setup = await resolveSetupFile(options.setup, basePath);
12952
12971
  }
12953
12972
  const shareBrowserContext = options?.shareBrowserContext ?? parsedConfig.shareBrowserContext;
12973
+ const reusePage = options?.reusePage ?? parsedConfig.reusePage;
12954
12974
  return {
12955
12975
  files,
12956
12976
  setup,
@@ -12959,6 +12979,7 @@ Examples:
12959
12979
  retry: options?.retry ?? parsedConfig.retry,
12960
12980
  summary: options?.summary ?? parsedConfig.summary,
12961
12981
  shareBrowserContext,
12982
+ reusePage,
12962
12983
  headed: finalHeaded,
12963
12984
  keepWindow: keepWindow,
12964
12985
  dotenvOverride: options?.dotenvOverride ?? parsedConfig.dotenvOverride,
@@ -12975,6 +12996,7 @@ Examples:
12975
12996
  const headed = options.headed ?? config_options_defaultConfig.headed;
12976
12997
  const finalHeaded = keepWindow || headed;
12977
12998
  const shareBrowserContext = options.shareBrowserContext ?? config_options_defaultConfig.shareBrowserContext;
12999
+ const reusePage = options.reusePage ?? config_options_defaultConfig.reusePage;
12978
13000
  return {
12979
13001
  files,
12980
13002
  setup,
@@ -12983,6 +13005,7 @@ Examples:
12983
13005
  retry: options.retry ?? config_options_defaultConfig.retry,
12984
13006
  summary: options.summary ?? defaultSummary,
12985
13007
  shareBrowserContext,
13008
+ reusePage,
12986
13009
  headed: finalHeaded,
12987
13010
  keepWindow: keepWindow,
12988
13011
  dotenvOverride: options.dotenvOverride ?? config_options_defaultConfig.dotenvOverride,
@@ -13208,6 +13231,7 @@ Examples:
13208
13231
  retry: options.retry,
13209
13232
  summary: options.summary,
13210
13233
  shareBrowserContext: options['share-browser-context'],
13234
+ reusePage: options['reuse-page'],
13211
13235
  headed: options.headed,
13212
13236
  keepWindow: options['keep-window'],
13213
13237
  dotenvOverride: options['dotenv-override'],