@swmansion/argent 0.34.1-next.23 → 0.34.1-next.24

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.
@@ -3488,6 +3488,10 @@
3488
3488
  const j = await d.json();
3489
3489
  if (j && j.tree) {
3490
3490
  vp.tree = j.tree;
3491
+ // The tree is drawn over the stream, in the screen's
3492
+ // portrait-native space; screenshots are upright. Kept to
3493
+ // turn a frame for cropping one (see vpUprightFrame).
3494
+ vp.uiOrientation = j.uiOrientation || null;
3491
3495
  vp.treeAt = Date.now();
3492
3496
  describeWarmupPending = false;
3493
3497
  // A right-click that landed before the tree was loaded waits
@@ -3632,6 +3636,27 @@
3632
3636
  // into a chip. Letterboxed (no distortion). Falls back to the full,
3633
3637
  // contained image when the element isn't matched on-screen or the agent
3634
3638
  // supplied a data: URI (treated as author-made art, shown whole).
3639
+ // A frame of the preview's describe tree (the screen's portrait-native
3640
+ // space) in the UI's upright space, the space of screenshots. The same
3641
+ // map as the tool-server's nativeFrameToUi.
3642
+ function vpUprightFrame(f, orientation) {
3643
+ switch (orientation) {
3644
+ case "landscapeRight":
3645
+ return { x: f.y, y: 1 - f.x - f.width, width: f.height, height: f.width };
3646
+ case "landscapeLeft":
3647
+ return { x: 1 - f.y - f.height, y: f.x, width: f.height, height: f.width };
3648
+ case "portraitUpsideDown":
3649
+ return {
3650
+ x: 1 - f.x - f.width,
3651
+ y: 1 - f.y - f.height,
3652
+ width: f.width,
3653
+ height: f.height,
3654
+ };
3655
+ default:
3656
+ return { x: f.x, y: f.y, width: f.width, height: f.height };
3657
+ }
3658
+ }
3659
+
3635
3660
  function applyThumbCrop(tw, frame) {
3636
3661
  const im = tw.querySelector(".thumb-img");
3637
3662
  if (!im || !im.naturalWidth || !im.naturalHeight) return;
@@ -5133,8 +5158,9 @@
5133
5158
  };
5134
5159
  }
5135
5160
  if (p._node && !vp.thumbFrames[p.id]) {
5136
- const f = p._node.frame;
5137
- vp.thumbFrames[p.id] = { x: f.x, y: f.y, width: f.width, height: f.height };
5161
+ // The thumbnail crops a screenshot, which is upright, while the
5162
+ // tree's frame is in the stream's portrait-native space.
5163
+ vp.thumbFrames[p.id] = vpUprightFrame(p._node.frame, vp.uiOrientation);
5138
5164
  }
5139
5165
  }
5140
5166
  layoutCards();
@@ -143,8 +143,6 @@ export interface ArgentToolArgs {
143
143
  port?: number;
144
144
  /** Device id from list-devices: the SAME id you passed to debugger-connect (iOS simulator UDID or Android serial). */
145
145
  device_id: string;
146
- /** iOS simulator UDID from list-devices. Pass it when device_id is a logicalDeviceId (two or more devices share one Metro), so that the tap coordinates of a landscape UI are on the screen's axes. Give the UDID of the simulator that shows the app. */
147
- udid?: string;
148
146
  /** When true, only components visible on screen are returned. Set to false to include all mounted components, including those scrolled off-screen, e.g. to understand the full page structure. */
149
147
  onScreenOnly?: boolean;
150
148
  /** Maximum total nodes to include. When exceeded, intermediate single-child wrapper chains are collapsed to preserve both root structure and leaf elements. Default: no limit. */
@@ -590,7 +588,7 @@ export interface ArgentToolArgs {
590
588
  udid: string;
591
589
  /** Bundle ID of the app (on a Mac app, the bundle id in the device id) */
592
590
  bundleId: string;
593
- /** Raw X coordinate in points, on the portrait axes of the screen; on a Mac app, points from the top-left of the area describe reports. NOT normalized [0,1] tap space. */
591
+ /** Raw X coordinate in points, on the axes of the UI as the user sees it (the axes of screenshots and describe frames); on a Mac app, points from the top-left of the area describe reports. NOT normalized [0,1] tap space. */
594
592
  x: number;
595
593
  /** Raw Y coordinate in points, on the same axes as x. NOT normalized [0,1] tap space. */
596
594
  y: number;
@@ -612,7 +610,7 @@ export interface ArgentToolArgs {
612
610
  udid: string;
613
611
  /** Bundle ID of the app (on a Mac app, the bundle id in the device id) */
614
612
  bundleId: string;
615
- /** Raw X coordinate in points, on the portrait axes of the screen; on a Mac app, points from the top-left of the area describe reports. NOT normalized [0,1] tap space. */
613
+ /** Raw X coordinate in points, on the axes of the UI as the user sees it (the axes of screenshots and describe frames); on a Mac app, points from the top-left of the area describe reports. NOT normalized [0,1] tap space. */
616
614
  x: number;
617
615
  /** Raw Y coordinate in points, on the same axes as x. NOT normalized [0,1] tap space. */
618
616
  y: number;
@@ -889,7 +887,7 @@ export interface ArgentToolArgs {
889
887
  screenshot: {
890
888
  /** Target device id from `list-devices` (iOS UDID, Android serial, Apple TV UDID, Vega serial, HarmonyOS id, Mac app id, or Chromium id). */
891
889
  udid: string;
892
- /** Orientation override for the screenshot (on Chromium it rotates the captured image). On Android the capture already follows the device's rotation. Rejected on HarmonyOS, which captures the display in its current orientation and has no override. Ignored on physical iPhones. */
890
+ /** Orientation override for the screenshot (on Chromium it rotates the captured image). Rarely needed: on Android and iOS simulators the capture already follows the UI's orientation, the space describe frames and gesture coordinates use, and an override can make the image disagree with them. Rejected on HarmonyOS, which captures the display in its current orientation and has no override. Ignored on physical iPhones. */
893
891
  rotation?: "Portrait" | "LandscapeLeft" | "LandscapeRight" | "PortraitUpsideDown";
894
892
  /** Scale factor. Defaults to ARGENT_SCREENSHOT_SCALE env var, or 0.25 if unset for iOS/Android/HarmonyOS. 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). On Chromium the default is 1.0 (no downscale); pass <1 to opt in. Downscaling on Chromium requires the optional `sharp` dependency. On a Mac app the default is one pixel per window point, downscaled to a 768 px long side for a larger window. */
895
893
  scale?: number;