@swmansion/argent 0.26.1-next.8 → 0.26.1-next.9

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.
Binary file
Binary file
Binary file
Binary file
package/dist/cli-cmds.mjs CHANGED
@@ -21877,7 +21877,7 @@ var _CI_VENDOR_COUNT_FOR_TEST = vendors_default.length;
21877
21877
  var SESSION_ID2 = randomUUID5();
21878
21878
  function readCliVersion() {
21879
21879
  if (true) {
21880
- return "0.26.1-next.8";
21880
+ return "0.26.1-next.9";
21881
21881
  }
21882
21882
  return "0.0.0";
21883
21883
  }
@@ -23416,7 +23416,7 @@ function renderFailedFlows(failed) {
23416
23416
  var SAFE_ARTIFACT_NAME = FLOW_NAME_PATTERN;
23417
23417
  var SAFE_FLOW_NAME = FLOW_NAME_PATTERN;
23418
23418
  var FLOWS_DIR = path14.join(".argent", "flows");
23419
- var SHELL_SAFE_ARG = /^[A-Za-z0-9_@%+=:,./-]+$/;
23419
+ var SHELL_SAFE_ARG = /^(?!=)[A-Za-z0-9_@%+=:,./-]+$/;
23420
23420
  function shellQuoteArg(arg) {
23421
23421
  if (SHELL_SAFE_ARG.test(arg)) return arg;
23422
23422
  return `'${arg.replaceAll("'", "'\\''")}'`;
@@ -16730,7 +16730,7 @@ var _CI_VENDOR_COUNT_FOR_TEST = vendors_default.length;
16730
16730
  var SESSION_ID = randomUUID4();
16731
16731
  function readCliVersion() {
16732
16732
  if (true) {
16733
- return "0.26.1-next.8";
16733
+ return "0.26.1-next.9";
16734
16734
  }
16735
16735
  return "0.0.0";
16736
16736
  }
@@ -73390,6 +73390,9 @@ function resolveDevice(udid) {
73390
73390
  function isIosPhysicalDevice(device) {
73391
73391
  return device.platform === "ios" && device.kind === "device";
73392
73392
  }
73393
+ function isIosSimulator(device) {
73394
+ return device.platform === "ios" && device.kind === "simulator" || device.platform === "ios-remote";
73395
+ }
73393
73396
  function parseChromiumCdpPort(udid) {
73394
73397
  if (!udid.startsWith(CHROMIUM_ID_PREFIX)) return null;
73395
73398
  const tail = udid.slice(CHROMIUM_ID_PREFIX.length);
@@ -94811,7 +94814,7 @@ var _CI_VENDOR_COUNT_FOR_TEST = vendors_default.length;
94811
94814
  var SESSION_ID = (0, import_node_crypto3.randomUUID)();
94812
94815
  function readCliVersion() {
94813
94816
  if (true) {
94814
- return "0.26.1-next.8";
94817
+ return "0.26.1-next.9";
94815
94818
  }
94816
94819
  return "0.0.0";
94817
94820
  }
@@ -96626,6 +96629,7 @@ var path11 = __toESM(require("node:path"));
96626
96629
  var import_node_child_process7 = require("node:child_process");
96627
96630
  var import_node_util6 = require("node:util");
96628
96631
  init_external_devices();
96632
+ init_device_info();
96629
96633
  var execFileAsync6 = (0, import_node_util6.promisify)(import_node_child_process7.execFile);
96630
96634
  async function listDeviceSetSimulators(deviceSet) {
96631
96635
  if (deviceSet && !fs12.existsSync(deviceSet)) return [];
@@ -96686,11 +96690,15 @@ var runtimeKindCache = /* @__PURE__ */ new Map();
96686
96690
  async function getSimulatorRuntimeKind(udid) {
96687
96691
  const cached3 = runtimeKindCache.get(udid);
96688
96692
  if (cached3) return cached3;
96689
- const listing = isExternalId(udid) ? await listDeviceSetSimulators(await deviceSetForUdid(udid)) : await listIosSimulators();
96690
- const kind = listing.find((s) => s.udid === externalNativeId(udid))?.runtimeKind;
96693
+ const kind = (await findIosSimulator(udid))?.runtimeKind;
96691
96694
  if (kind) runtimeKindCache.set(udid, kind);
96692
96695
  return kind;
96693
96696
  }
96697
+ async function findIosSimulator(udid) {
96698
+ const listing = isExternalId(udid) ? await listDeviceSetSimulators(await deviceSetForUdid(udid)) : await listIosSimulators();
96699
+ const native = externalNativeId(udid);
96700
+ return listing.find((s) => s.udid === native);
96701
+ }
96694
96702
  async function isTvOsSimulator(udid) {
96695
96703
  return await getSimulatorRuntimeKind(udid) === "tv";
96696
96704
  }
@@ -96754,11 +96762,11 @@ async function isFoldableDeviceType(identifier) {
96754
96762
  return foldable;
96755
96763
  }
96756
96764
  async function isFoldableSimulator(udid) {
96765
+ const device = resolveDevice(udid);
96766
+ if (device.platform !== "ios" || device.kind !== "simulator") return false;
96757
96767
  const cached3 = foldableCache.get(udid);
96758
96768
  if (cached3 !== void 0) return cached3;
96759
- const listing = isExternalId(udid) ? await listDeviceSetSimulators(await deviceSetForUdid(udid)) : await listIosSimulators();
96760
- const native = externalNativeId(udid);
96761
- const found = listing.find((s) => s.udid === native);
96769
+ const found = await findIosSimulator(udid);
96762
96770
  const foldable = found?.foldable === true;
96763
96771
  if (found) foldableCache.set(udid, foldable);
96764
96772
  return foldable;
@@ -134469,22 +134477,36 @@ function buildTextTree(data, opts) {
134469
134477
  }
134470
134478
  }
134471
134479
  const lines = [];
134472
- const turn = opts.uiOrientation && opts.uiOrientation !== "unknown" && opts.uiOrientation !== "ambiguous" ? opts.uiOrientation : void 0;
134480
+ const turn = opts.uiOrientation && opts.uiOrientation !== "unknown" && opts.uiOrientation !== "ambiguous" && opts.uiOrientation !== "mismatched" ? opts.uiOrientation : void 0;
134473
134481
  if (canNormalize) {
134474
134482
  lines.push(`Screen: ${screenW}x${screenH}`);
134475
- if (turn && turn !== "portrait") {
134483
+ if (opts.uiOrientation === "mismatched") {
134484
+ lines.push(
134485
+ "Note: The udid is not the UDID of the simulator that shows this app. Thus, the tool did not use the udid. If the UI is landscape, the tap points are not correct. The describe tool gives correct tap points. This tool also gives correct tap points with the UDID of the simulator that shows this app."
134486
+ );
134487
+ } else if (turn && turn !== "portrait") {
134476
134488
  lines.push(
134477
134489
  `The UI is ${turn} on the screen. The tap points are on the screen's axes, which the gesture tools use.`
134478
134490
  );
134479
134491
  } else if (opts.uiOrientation === "ambiguous" && screenW > screenH) {
134480
134492
  lines.push(
134481
- "Note: the UI is landscape, and two booted simulators have this device's name, so its orientation could not be read. The tap points are on the UI's axes, so a tap can miss. Call again with the simulator's udid, or use describe for tap points."
134493
+ "Note: the UI is landscape, and two booted simulators have this device's name, so its orientation could not be read. The tap points are on the UI's axes, so a tap can miss. Use describe for tap points, or call again with the udid of the simulator that shows this app."
134482
134494
  );
134483
134495
  } else if (opts.uiOrientation === "unknown" && screenW > screenH) {
134484
134496
  lines.push(
134485
134497
  "Note: the UI is landscape, and its orientation could not be read. The tap points are on the UI's axes, so a tap can miss. Use describe for tap points."
134486
134498
  );
134487
134499
  }
134500
+ if (opts.readInsteadOfUdid) {
134501
+ lines.push(
134502
+ `Note: the udid is not the UDID of the simulator that shows this app. The tool used ${opts.readInsteadOfUdid}, the UDID of that simulator.`
134503
+ );
134504
+ }
134505
+ if (opts.udidUnchecked && (screenW > screenH || turn !== void 0 && turn !== "portrait")) {
134506
+ lines.push(
134507
+ "Note: two booted simulators have this device's name, so the tool could not check that the udid is the simulator that shows this app. If it is another simulator, a tap can miss. Use describe for tap points."
134508
+ );
134509
+ }
134488
134510
  lines.push("");
134489
134511
  }
134490
134512
  function formatLabel2(c) {
@@ -134588,14 +134610,57 @@ async function debuggedBundleId(api, appName) {
134588
134610
  }
134589
134611
  var BUNDLE_ID_NAMED_TARGET = /^[\w-]+(\.[\w-]+)+( \(|$)/;
134590
134612
  var AMBIGUOUS_SIMULATOR = "ambiguous-simulator";
134591
- function isIosSimulator(device) {
134592
- return device.platform === "ios" && device.kind === "simulator" || device.platform === "ios-remote";
134593
- }
134613
+ var MISMATCHED_UDID = "mismatched-udid";
134614
+ var UNLISTED_UDID = "unlisted-udid";
134594
134615
  async function iosSimulatorOf(app) {
134595
- if (app.udid) {
134596
- const named2 = resolveDevice(app.udid);
134597
- return isIosSimulator(named2) ? named2 : void 0;
134616
+ if (!app.udid) {
134617
+ const session2 = await iosSimulatorOfSession(app);
134618
+ return session2 === AMBIGUOUS_SIMULATOR || !session2 ? session2 : { device: session2 };
134619
+ }
134620
+ const named = resolveDevice(app.udid);
134621
+ const own = resolveDevice(canonicalDeviceId(app.deviceId) ?? app.deviceId);
134622
+ if (isIosSimulator(own)) {
134623
+ if (own.id === named.id) return { device: own };
134624
+ if (isIosSimulator(named)) {
134625
+ const [listed2, ownListed] = await Promise.all([
134626
+ listedAs(named, app.deviceName),
134627
+ listedAs(own, app.deviceName)
134628
+ ]);
134629
+ if (listed2 === "booted" && ownListed !== "booted") return { device: named };
134630
+ }
134631
+ return { device: own, readInsteadOfUdid: own.id };
134598
134632
  }
134633
+ const [listed, session] = await Promise.all([
134634
+ isIosSimulator(named) ? listedAs(named, app.deviceName) : void 0,
134635
+ iosSimulatorOfSession(app)
134636
+ ]);
134637
+ if (listed === "booted" || listed === "twin") {
134638
+ const sole = session === void 0 || session !== AMBIGUOUS_SIMULATOR && session.id === named.id;
134639
+ return listed === "booted" && sole ? { device: named } : { device: named, udidUnchecked: true };
134640
+ }
134641
+ if (session === AMBIGUOUS_SIMULATOR) return MISMATCHED_UDID;
134642
+ if (session) {
134643
+ return session.id === named.id ? { device: session } : { device: session, readInsteadOfUdid: session.id };
134644
+ }
134645
+ return listed === "unlisted" ? UNLISTED_UDID : void 0;
134646
+ }
134647
+ async function listedAs(device, name) {
134648
+ if (device.platform !== "ios-remote") {
134649
+ const sim2 = await findIosSimulator(device.id);
134650
+ if (!sim2) return "unlisted";
134651
+ return sim2.state === "Booted" && sim2.name === name ? "booted" : "other";
134652
+ }
134653
+ const listing = Object.values(
134654
+ (await simctlListDevices({ timeoutMs: ORIENTATION_READ_TIMEOUT_MS }).catch(() => ({
134655
+ devices: {}
134656
+ }))).devices
134657
+ ).flat();
134658
+ const sim = listing.find((d) => d.udid === stripRemotePrefix(device.id));
134659
+ if (!sim) return "unlisted";
134660
+ if (sim.state !== "Booted" || sim.name !== name) return "other";
134661
+ return listing.some((d) => d !== sim && d.state === "Booted" && d.name === name) ? "twin" : "booted";
134662
+ }
134663
+ async function iosSimulatorOfSession(app) {
134599
134664
  const device = resolveDevice(canonicalDeviceId(app.deviceId) ?? app.deviceId);
134600
134665
  if (isIosSimulator(device)) return device;
134601
134666
  const logicalKeyed = app.deviceId === app.logicalDeviceId || isLogicalKeyedDevice(app.deviceId);
@@ -134608,22 +134673,28 @@ async function iosSimulatorOf(app) {
134608
134673
  }
134609
134674
  async function readTapAxes(registry2, app) {
134610
134675
  const read = (async () => {
134611
- const device = await iosSimulatorOf(app);
134612
- if (device === void 0) return void 0;
134613
- if (device === AMBIGUOUS_SIMULATOR) return "ambiguous";
134676
+ const pick2 = await iosSimulatorOf(app);
134677
+ if (pick2 === void 0) return {};
134678
+ if (pick2 === AMBIGUOUS_SIMULATOR) return { uiOrientation: "ambiguous" };
134679
+ if (pick2 === MISMATCHED_UDID) return { uiOrientation: "mismatched" };
134680
+ if (pick2 === UNLISTED_UDID) return { uiOrientation: "unknown" };
134681
+ const { device, ...udid } = pick2;
134614
134682
  const ref = nativeDevtoolsRef(device);
134615
134683
  const api = await registry2.resolveService(ref.urn, ref.options);
134616
134684
  const bundleId = await debuggedBundleId(api, app.appName);
134617
- if (!bundleId) return "unknown";
134685
+ if (!bundleId) return { uiOrientation: "unknown", ...udid };
134618
134686
  const raw = await api.queryViewHierarchy(bundleId, "ViewHierarchy.getFullHierarchy", {
134619
134687
  fields: ["className"],
134620
134688
  maxDepth: 1
134621
134689
  });
134622
- return asUiOrientation(raw?.screen?.interfaceOrientation) ?? "unknown";
134623
- })().catch(() => "unknown");
134690
+ return {
134691
+ uiOrientation: asUiOrientation(raw?.screen?.interfaceOrientation) ?? "unknown",
134692
+ ...udid
134693
+ };
134694
+ })().catch(() => ({ uiOrientation: "unknown" }));
134624
134695
  let timer;
134625
134696
  const timeout = new Promise((resolve14) => {
134626
- timer = setTimeout(() => resolve14("unknown"), ORIENTATION_READ_TIMEOUT_MS);
134697
+ timer = setTimeout(() => resolve14({ uiOrientation: "unknown" }), ORIENTATION_READ_TIMEOUT_MS);
134627
134698
  });
134628
134699
  try {
134629
134700
  return await Promise.race([read, timeout]);
@@ -134637,7 +134708,7 @@ var zodSchema34 = external_exports.object({
134637
134708
  "Device id from list-devices \u2014 the SAME id you passed to debugger-connect (iOS simulator UDID or Android serial)."
134638
134709
  ),
134639
134710
  udid: external_exports.string().optional().describe(
134640
- "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."
134711
+ "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."
134641
134712
  ),
134642
134713
  onScreenOnly: external_exports.boolean().default(true).describe(
134643
134714
  "When true (default), only components visible on screen are returned. Set to false to include all mounted components including those scrolled off-screen. Useful when you need to understand the full page structure."
@@ -134716,7 +134787,7 @@ Use when you need tap coordinates for a React Native UI element. Returns a compa
134716
134787
  onScreenOnly: params.onScreenOnly,
134717
134788
  maxNodes: params.maxNodes,
134718
134789
  includeSkipped: params.includeSkipped,
134719
- uiOrientation: await tapAxes
134790
+ ...await tapAxes
134720
134791
  });
134721
134792
  const deviceLine = [
134722
134793
  `device: ${api.deviceName}`,
@@ -150259,7 +150330,7 @@ async function runSwipe(env, step) {
150259
150330
  toPoint = p;
150260
150331
  }
150261
150332
  const orientation = env.lastRead?.uiOrientation;
150262
- if (settle.warning !== void 0 && step.direction) {
150333
+ if (settle.warning !== void 0 && step.direction && isIosSimulator(env.device)) {
150263
150334
  settle = { ...settle, warning: `${settle.warning} ${unreadOrientationNote(orientation)}` };
150264
150335
  }
150265
150336
  let start2;
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swmansion/argent",
3
- "version": "0.26.1-next.8",
3
+ "version": "0.26.1-next.9",
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",