@midscene/cli 1.10.4-beta-20260710100314.0 → 1.10.4-beta-20260710115744.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.
@@ -6,7 +6,7 @@ import { createHash } from "node:crypto";
6
6
  import { ReportMergingTool } from "@midscene/core";
7
7
  import { getMidsceneRunSubDir } from "@midscene/shared/common";
8
8
  import { getDebug } from "@midscene/shared/logger";
9
- import { ScriptPlayer, parseYamlScript } from "@midscene/core/yaml";
9
+ import { ScriptPlayer, parseYamlScript, resolveWebTarget } from "@midscene/core/yaml";
10
10
  import { buildChromeArgs, buildDownloadBehavior, defaultViewportHeight, defaultViewportWidth, puppeteerAgentForTarget } from "@midscene/web/puppeteer-agent-launcher";
11
11
  import lodash_merge from "lodash.merge";
12
12
  import puppeteer from "puppeteer";
@@ -2772,9 +2772,10 @@ async function createYamlPlayer(file, script, options) {
2772
2772
  };
2773
2773
  const player = new ScriptPlayer(clonedYamlScript, async ()=>{
2774
2774
  const freeFn = [];
2775
- const webTarget = clonedYamlScript.web || clonedYamlScript.target;
2775
+ const resolvedWebTarget = resolveWebTarget(clonedYamlScript);
2776
+ const webTarget = resolvedWebTarget?.target;
2776
2777
  const targetCount = [
2777
- void 0 !== webTarget,
2778
+ void 0 !== resolvedWebTarget,
2778
2779
  void 0 !== clonedYamlScript.android,
2779
2780
  void 0 !== clonedYamlScript.ios,
2780
2781
  void 0 !== clonedYamlScript.harmony,
@@ -2783,17 +2784,17 @@ async function createYamlPlayer(file, script, options) {
2783
2784
  ].filter(Boolean).length;
2784
2785
  if (targetCount > 1) {
2785
2786
  const specifiedTargets = [
2786
- void 0 !== webTarget ? 'web' : null,
2787
+ resolvedWebTarget?.source ?? null,
2787
2788
  void 0 !== clonedYamlScript.android ? 'android' : null,
2788
2789
  void 0 !== clonedYamlScript.ios ? 'ios' : null,
2789
2790
  void 0 !== clonedYamlScript.harmony ? 'harmony' : null,
2790
2791
  void 0 !== clonedYamlScript.computer ? 'computer' : null,
2791
2792
  void 0 !== clonedYamlScript.interface ? 'interface' : null
2792
2793
  ].filter(Boolean);
2793
- throw new Error(`Only one target type can be specified, but found multiple: ${specifiedTargets.join(', ')}. Please specify only one of: web, android, ios, harmony, computer, or interface.`);
2794
+ throw new Error(`Only one target type can be specified, but found multiple: ${specifiedTargets.join(', ')}. Please specify only one of: page, browser, web, android, ios, harmony, computer, or interface.`);
2794
2795
  }
2795
2796
  if (void 0 !== webTarget) {
2796
- if (void 0 !== clonedYamlScript.target) console.warn("target is deprecated, please use web instead. See https://midscenejs.com/automate-with-scripts-in-yaml for more information. Sorry for the inconvenience.");
2797
+ if (resolvedWebTarget?.source === 'target') console.warn("target is deprecated, please use page or browser instead. See https://midscenejs.com/automate-with-scripts-in-yaml for more information. Sorry for the inconvenience.");
2797
2798
  let localServer;
2798
2799
  let urlToVisit;
2799
2800
  if (webTarget.serve) {
@@ -2808,6 +2809,7 @@ async function createYamlPlayer(file, script, options) {
2808
2809
  webTarget.url = urlToVisit;
2809
2810
  }
2810
2811
  if (webTarget.cdpEndpoint && webTarget.bridgeMode) throw new Error('cdpEndpoint and bridgeMode are mutually exclusive. Please specify only one.');
2812
+ if ('browser' === webTarget.mode && webTarget.bridgeMode) throw new Error('[midscene] browser mode does not support bridgeMode. Use page: or web.mode: page for bridge mode.');
2811
2813
  if (webTarget.cdpEndpoint) {
2812
2814
  const cdpBrowser = options?.browser ?? await puppeteer.connect({
2813
2815
  browserWSEndpoint: webTarget.cdpEndpoint,
@@ -3450,9 +3452,9 @@ class YamlBatchExecutor {
3450
3452
  setupContext,
3451
3453
  ...fileContextList
3452
3454
  ] : fileContextList;
3453
- const needsBrowser = allContexts.some((ctx)=>Object.keys(ctx.executionConfig.web || ctx.executionConfig.target || {}).length > 0);
3455
+ const needsBrowser = allContexts.some((ctx)=>void 0 !== resolveWebTarget(ctx.executionConfig));
3454
3456
  if (needsBrowser && this.config.shareBrowserContext) {
3455
- const globalWebConfig = this.config.globalConfig?.web;
3457
+ const globalWebConfig = resolveWebTarget(this.config.globalConfig ?? {})?.target;
3456
3458
  if (globalWebConfig?.cdpEndpoint) browser = await puppeteer.connect({
3457
3459
  browserWSEndpoint: globalWebConfig.cdpEndpoint,
3458
3460
  defaultViewport: null,
@@ -3490,7 +3492,7 @@ class YamlBatchExecutor {
3490
3492
  this.results = await this.processResults(executedResults, notExecutedContexts);
3491
3493
  } finally{
3492
3494
  if (browser && !this.config.keepWindow) {
3493
- const isCdp = !!this.config.globalConfig?.web?.cdpEndpoint;
3495
+ const isCdp = !!resolveWebTarget(this.config.globalConfig ?? {})?.target.cdpEndpoint;
3494
3496
  if (isCdp) browser.disconnect();
3495
3497
  else await browser.close();
3496
3498
  }
@@ -3501,20 +3503,6 @@ class YamlBatchExecutor {
3501
3503
  async createFileContext(file, fileConfig, options) {
3502
3504
  const { globalConfig } = this.config;
3503
3505
  const clonedFileConfig = JSON.parse(JSON.stringify(fileConfig));
3504
- if (clonedFileConfig.target) {
3505
- clonedFileConfig.web = {
3506
- ...clonedFileConfig.target,
3507
- ...clonedFileConfig.web
3508
- };
3509
- delete clonedFileConfig.target;
3510
- }
3511
- if (globalConfig?.target) {
3512
- globalConfig.web = {
3513
- ...globalConfig.target,
3514
- ...globalConfig.web
3515
- };
3516
- delete globalConfig.target;
3517
- }
3518
3506
  const executionConfig = lodash_merge(clonedFileConfig, globalConfig);
3519
3507
  return {
3520
3508
  file,