@midscene/cli 1.10.4-beta-20260710115744.0 → 1.10.4-beta-20260710135045.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, resolveWebTarget } from "@midscene/core/yaml";
9
+ import { ScriptPlayer, parseYamlScript } 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,10 +2772,9 @@ async function createYamlPlayer(file, script, options) {
2772
2772
  };
2773
2773
  const player = new ScriptPlayer(clonedYamlScript, async ()=>{
2774
2774
  const freeFn = [];
2775
- const resolvedWebTarget = resolveWebTarget(clonedYamlScript);
2776
- const webTarget = resolvedWebTarget?.target;
2775
+ const webTarget = clonedYamlScript.web || clonedYamlScript.target;
2777
2776
  const targetCount = [
2778
- void 0 !== resolvedWebTarget,
2777
+ void 0 !== webTarget,
2779
2778
  void 0 !== clonedYamlScript.android,
2780
2779
  void 0 !== clonedYamlScript.ios,
2781
2780
  void 0 !== clonedYamlScript.harmony,
@@ -2784,17 +2783,17 @@ async function createYamlPlayer(file, script, options) {
2784
2783
  ].filter(Boolean).length;
2785
2784
  if (targetCount > 1) {
2786
2785
  const specifiedTargets = [
2787
- resolvedWebTarget?.source ?? null,
2786
+ void 0 !== webTarget ? 'web' : null,
2788
2787
  void 0 !== clonedYamlScript.android ? 'android' : null,
2789
2788
  void 0 !== clonedYamlScript.ios ? 'ios' : null,
2790
2789
  void 0 !== clonedYamlScript.harmony ? 'harmony' : null,
2791
2790
  void 0 !== clonedYamlScript.computer ? 'computer' : null,
2792
2791
  void 0 !== clonedYamlScript.interface ? 'interface' : null
2793
2792
  ].filter(Boolean);
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.`);
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.`);
2795
2794
  }
2796
2795
  if (void 0 !== webTarget) {
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.");
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.");
2798
2797
  let localServer;
2799
2798
  let urlToVisit;
2800
2799
  if (webTarget.serve) {
@@ -2809,7 +2808,6 @@ async function createYamlPlayer(file, script, options) {
2809
2808
  webTarget.url = urlToVisit;
2810
2809
  }
2811
2810
  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.');
2813
2811
  if (webTarget.cdpEndpoint) {
2814
2812
  const cdpBrowser = options?.browser ?? await puppeteer.connect({
2815
2813
  browserWSEndpoint: webTarget.cdpEndpoint,
@@ -3452,9 +3450,9 @@ class YamlBatchExecutor {
3452
3450
  setupContext,
3453
3451
  ...fileContextList
3454
3452
  ] : fileContextList;
3455
- const needsBrowser = allContexts.some((ctx)=>void 0 !== resolveWebTarget(ctx.executionConfig));
3453
+ const needsBrowser = allContexts.some((ctx)=>Object.keys(ctx.executionConfig.web || ctx.executionConfig.target || {}).length > 0);
3456
3454
  if (needsBrowser && this.config.shareBrowserContext) {
3457
- const globalWebConfig = resolveWebTarget(this.config.globalConfig ?? {})?.target;
3455
+ const globalWebConfig = this.config.globalConfig?.web;
3458
3456
  if (globalWebConfig?.cdpEndpoint) browser = await puppeteer.connect({
3459
3457
  browserWSEndpoint: globalWebConfig.cdpEndpoint,
3460
3458
  defaultViewport: null,
@@ -3492,7 +3490,7 @@ class YamlBatchExecutor {
3492
3490
  this.results = await this.processResults(executedResults, notExecutedContexts);
3493
3491
  } finally{
3494
3492
  if (browser && !this.config.keepWindow) {
3495
- const isCdp = !!resolveWebTarget(this.config.globalConfig ?? {})?.target.cdpEndpoint;
3493
+ const isCdp = !!this.config.globalConfig?.web?.cdpEndpoint;
3496
3494
  if (isCdp) browser.disconnect();
3497
3495
  else await browser.close();
3498
3496
  }
@@ -3503,6 +3501,20 @@ class YamlBatchExecutor {
3503
3501
  async createFileContext(file, fileConfig, options) {
3504
3502
  const { globalConfig } = this.config;
3505
3503
  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
+ }
3506
3518
  const executionConfig = lodash_merge(clonedFileConfig, globalConfig);
3507
3519
  return {
3508
3520
  file,