@swmansion/argent 0.28.1-next.24 → 0.28.1-next.25

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/cli-cmds.mjs CHANGED
@@ -30095,7 +30095,7 @@ var _CI_VENDOR_COUNT_FOR_TEST = vendors_default.length;
30095
30095
  var SESSION_ID2 = randomUUID5();
30096
30096
  function readCliVersion() {
30097
30097
  if (true) {
30098
- return "0.28.1-next.24";
30098
+ return "0.28.1-next.25";
30099
30099
  }
30100
30100
  return "0.0.0";
30101
30101
  }
@@ -16739,7 +16739,7 @@ var _CI_VENDOR_COUNT_FOR_TEST = vendors_default.length;
16739
16739
  var SESSION_ID = randomUUID4();
16740
16740
  function readCliVersion() {
16741
16741
  if (true) {
16742
- return "0.28.1-next.24";
16742
+ return "0.28.1-next.25";
16743
16743
  }
16744
16744
  return "0.0.0";
16745
16745
  }
@@ -802,7 +802,7 @@ export interface ArgentToolArgs {
802
802
  udid: string;
803
803
  /** Orientation override for the screenshot (rotates the captured image after Page.captureScreenshot on Chromium). On Android the capture already follows the device's rotation. Ignored on physical iPhones. */
804
804
  rotation?: "Portrait" | "LandscapeLeft" | "LandscapeRight" | "PortraitUpsideDown";
805
- /** Scale factor (0.01-1.0). Defaults to ARGENT_SCREENSHOT_SCALE env var, or 0.25 if unset for iOS/Android. On Chromium the default is 1.0 (no downscale); pass <1 to opt in. Downscaling on Chromium requires the optional `sharp` dependency. */
805
+ /** Scale factor (0.01-1.0). Defaults to ARGENT_SCREENSHOT_SCALE env var, or 0.25 if unset for iOS/Android. On a local Apple TV simulator, an Android TV or Vega, with neither set, the capture is downscaled to a 576 px long side (0.15 of a 4K capture); an Android TV whose form factor or display size cannot be read in time keeps 0.25. On Chromium the default is 1.0 (no downscale); pass <1 to opt in. Downscaling on Chromium requires the optional `sharp` dependency. */
806
806
  scale?: number;
807
807
  /** Default true. Set false only when capturing a full-resolution PNG (scale: 1.0) to save as a baseline/current for screenshot-diff. The file is still written, but the image bytes are not attached to the agent context. */
808
808
  includeImageInContext?: boolean;
@@ -94923,7 +94923,7 @@ var _CI_VENDOR_COUNT_FOR_TEST = vendors_default.length;
94923
94923
  var SESSION_ID = (0, import_node_crypto3.randomUUID)();
94924
94924
  function readCliVersion() {
94925
94925
  if (true) {
94926
- return "0.28.1-next.24";
94926
+ return "0.28.1-next.25";
94927
94927
  }
94928
94928
  return "0.0.0";
94929
94929
  }
@@ -107957,6 +107957,7 @@ var os5 = __toESM(require("node:os"));
107957
107957
  var import_node_crypto6 = require("node:crypto");
107958
107958
  var import_node_url = require("node:url");
107959
107959
  var DEFAULT_SCREENSHOT_SCALE = 0.25;
107960
+ var TV_DEFAULT_LONG_SIDE = 576;
107960
107961
  var NO_IMAGE_ERROR = /no image to export/i;
107961
107962
  var FIRST_FRAME_WAIT_MS = 6e3;
107962
107963
  var FIRST_FRAME_POLL_MS = 250;
@@ -108312,19 +108313,24 @@ async function simulatorPost(toolLabel, api, endpoint, reqBody, signal, fallback
108312
108313
  return { res, body };
108313
108314
  }
108314
108315
  var warnedScaleValue;
108315
- function getScreenshotScale() {
108316
+ function getScreenshotScaleOverride() {
108316
108317
  const v = process.env.ARGENT_SCREENSHOT_SCALE;
108317
- if (v) {
108318
- const n = parseFloat(v);
108319
- if (!Number.isNaN(n) && n >= 0.01 && n <= 1) return n;
108320
- if (v !== warnedScaleValue) {
108321
- warnedScaleValue = v;
108322
- console.warn(
108323
- `[screenshot] Ignoring ARGENT_SCREENSHOT_SCALE=${v}: expected a number between 0.01 and 1.0. Using ${DEFAULT_SCREENSHOT_SCALE}.`
108324
- );
108325
- }
108318
+ if (!v) return void 0;
108319
+ const n = parseFloat(v);
108320
+ if (!Number.isNaN(n) && n >= 0.01 && n <= 1) return n;
108321
+ if (v !== warnedScaleValue) {
108322
+ warnedScaleValue = v;
108323
+ console.warn(
108324
+ `[screenshot] Ignoring ARGENT_SCREENSHOT_SCALE=${v}: expected a number between 0.01 and 1.0. Using the default.`
108325
+ );
108326
108326
  }
108327
- return DEFAULT_SCREENSHOT_SCALE;
108327
+ return void 0;
108328
+ }
108329
+ function getScreenshotScale() {
108330
+ return getScreenshotScaleOverride() ?? DEFAULT_SCREENSHOT_SCALE;
108331
+ }
108332
+ function tvDefaultScale(width, height) {
108333
+ return Math.min(1, TV_DEFAULT_LONG_SIDE / Math.max(width, height));
108328
108334
  }
108329
108335
  async function httpScreenshot(api, rotation, signal, scale, screen) {
108330
108336
  if (api.transport) {
@@ -123892,6 +123898,7 @@ var os13 = __toESM(require("node:os"));
123892
123898
  var path29 = __toESM(require("node:path"));
123893
123899
  init_zod();
123894
123900
  init_device_info();
123901
+ init_adb();
123895
123902
 
123896
123903
  // ../tool-server/src/utils/device-orientation.ts
123897
123904
  var import_node_fs13 = require("node:fs");
@@ -124443,7 +124450,7 @@ async function captureViaEmulatorConsole(opts) {
124443
124450
  }
124444
124451
  }
124445
124452
  function scalePng(src, scale) {
124446
- const s = scale ?? getScreenshotScale();
124453
+ const s = scale ?? getScreenshotScaleOverride() ?? tvDefaultScale(src.width, src.height);
124447
124454
  if (s >= 1) return src;
124448
124455
  const outW = Math.max(1, Math.round(src.width * s));
124449
124456
  const outH = Math.max(1, Math.round(src.height * s));
@@ -124468,7 +124475,7 @@ var zodSchema16 = external_exports.object({
124468
124475
  "Orientation override for the screenshot (rotates the captured image after Page.captureScreenshot on Chromium). On Android the capture already follows the device's rotation. Ignored on physical iPhones."
124469
124476
  ),
124470
124477
  scale: external_exports.number().min(0.01).max(1).optional().describe(
124471
- "Scale factor (0.01-1.0). Defaults to ARGENT_SCREENSHOT_SCALE env var, or 0.25 if unset for iOS/Android. On Chromium the default is 1.0 (no downscale); pass <1 to opt in. Downscaling on Chromium requires the optional `sharp` dependency."
124478
+ "Scale factor (0.01-1.0). Defaults to ARGENT_SCREENSHOT_SCALE env var, or 0.25 if unset for iOS/Android. On a local Apple TV simulator, an Android TV or Vega, with neither set, the capture is downscaled to a 576 px long side (0.15 of a 4K capture); an Android TV whose form factor or display size cannot be read in time keeps 0.25. On Chromium the default is 1.0 (no downscale); pass <1 to opt in. Downscaling on Chromium requires the optional `sharp` dependency."
124472
124479
  ),
124473
124480
  includeImageInContext: external_exports.boolean().optional().default(true).describe(
124474
124481
  "Default true. Set false only when capturing a full-resolution PNG (scale: 1.0) to save as a baseline/current for screenshot-diff. The file is still written, but the image bytes are not attached to the agent context."
@@ -124503,7 +124510,7 @@ async function tvScreenshot(udid, scale, signal) {
124503
124510
  await execFileAsync25("xcrun", await simctlArgsForUdid(udid, ["io", udid, "screenshot", file2]), {
124504
124511
  signal
124505
124512
  });
124506
- if (scale < 1) {
124513
+ if (scale === void 0 || scale < 1) {
124507
124514
  await execFileAsync25("sips", ["-Z", String(await tvTargetLongSide(file2, scale)), file2], {
124508
124515
  signal
124509
124516
  }).catch(() => {
@@ -124522,7 +124529,28 @@ async function tvTargetLongSide(file2, scale) {
124522
124529
  }
124523
124530
  } catch {
124524
124531
  }
124525
- return Math.round(longSide * scale);
124532
+ return scale === void 0 ? Math.min(TV_DEFAULT_LONG_SIDE, longSide) : Math.round(longSide * scale);
124533
+ }
124534
+ var ANDROID_TV_PROBE_BUDGET_MS = 2e3;
124535
+ async function androidTvDefaultScale(serial, notBefore) {
124536
+ if (getScreenshotScaleOverride() !== void 0) return void 0;
124537
+ const probe3 = Promise.all([
124538
+ isAndroidTv(serial).catch(() => false),
124539
+ getAndroidScreenSize(serial).catch(() => void 0)
124540
+ ]).then(([isTv, size]) => isTv && size ? tvDefaultScale(size.width, size.height) : void 0);
124541
+ let timer;
124542
+ const budget = new Promise((resolve14) => {
124543
+ timer = setTimeout(resolve14, ANDROID_TV_PROBE_BUDGET_MS);
124544
+ });
124545
+ try {
124546
+ return await Promise.race([
124547
+ probe3,
124548
+ Promise.all([budget, notBefore.catch(() => {
124549
+ })]).then(() => void 0)
124550
+ ]);
124551
+ } finally {
124552
+ clearTimeout(timer);
124553
+ }
124526
124554
  }
124527
124555
  async function downscalePngInPlace(file2, scale, signal) {
124528
124556
  if (scale >= 1) {
@@ -124589,7 +124617,11 @@ Fails if the simulator-server / emulator backend / Chromium CDP is not reachable
124589
124617
  return { image: image2, ...note ? { [RESULT_NOTE_KEY]: note } : {} };
124590
124618
  }
124591
124619
  if (device.platform === "ios" && await isTvOsSimulator(params.udid)) {
124592
- const pngPath = await tvScreenshot(params.udid, scale, signal);
124620
+ const pngPath = await tvScreenshot(
124621
+ params.udid,
124622
+ params.scale ?? getScreenshotScaleOverride(),
124623
+ signal
124624
+ );
124593
124625
  const image2 = await requireArtifacts(ctx).register({
124594
124626
  hostPath: pngPath,
124595
124627
  kind: "screenshot",
@@ -124615,14 +124647,18 @@ Fails if the simulator-server / emulator backend / Chromium CDP is not reachable
124615
124647
  return { image: image2, ...note ? { [RESULT_NOTE_KEY]: note } : {} };
124616
124648
  }
124617
124649
  const ref = simulatorServerRef(device);
124618
- const api = await registry2.resolveService(ref.urn, ref.options);
124650
+ const apiReady = registry2.resolveService(ref.urn, ref.options);
124651
+ const [api, androidTvScale] = await Promise.all([
124652
+ apiReady,
124653
+ params.scale === void 0 && device.platform === "android" ? androidTvDefaultScale(device.id, apiReady) : void 0
124654
+ ]);
124619
124655
  const panel = await resolveCapturePanel(api);
124620
124656
  const { path: capturedPath } = await captureScreenshotUpright(
124621
124657
  api,
124622
124658
  device,
124623
124659
  params.rotation,
124624
124660
  signal,
124625
- params.scale,
124661
+ params.scale ?? androidTvScale,
124626
124662
  panel ? (a, r, s, sc) => httpScreenshot(a, r, s, sc, panel.screen) : void 0,
124627
124663
  androidDevtoolsRotationPeek(registry2, device)
124628
124664
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swmansion/argent",
3
- "version": "0.28.1-next.24",
3
+ "version": "0.28.1-next.25",
4
4
  "mcpName": "io.github.software-mansion/argent",
5
5
  "description": "MCP server for iOS Simulator and Android Emulator control",
6
6
  "license": "Apache-2.0",