@swmansion/argent 0.20.1-next.3 → 0.20.1-next.4

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.
@@ -112329,6 +112329,7 @@ var nativeDevtoolsBlueprint = {
112329
112329
  );
112330
112330
  }
112331
112331
  const id = nextRpcId++;
112332
+ const timeoutMs = method === "ViewHierarchy.getFullHierarchy" ? 15e3 : 5e3;
112332
112333
  return new Promise((resolve11, reject) => {
112333
112334
  pendingRpc.set(id, { resolve: resolve11, reject });
112334
112335
  conn.socket.write(
@@ -112349,7 +112350,7 @@ var nativeDevtoolsBlueprint = {
112349
112350
  })
112350
112351
  );
112351
112352
  }
112352
- }, 5e3);
112353
+ }, timeoutMs);
112353
112354
  });
112354
112355
  }
112355
112356
  if (transport === "unix") {
@@ -144437,6 +144438,9 @@ function bindDeviceArgs(registry2, toolName, deviceId, args, deviceIsExplicit =
144437
144438
  return out;
144438
144439
  }
144439
144440
 
144441
+ // ../tool-server/src/tools/flows/flow-ios-tree.ts
144442
+ init_src();
144443
+
144440
144444
  // ../tool-server/src/tools/flows/flow-tree-flatten.ts
144441
144445
  function intersectClip(rect, clip3) {
144442
144446
  if (!clip3) return rect;
@@ -144613,7 +144617,7 @@ var FULL_HIERARCHY_FIELDS = [
144613
144617
  // request, which just leaves the wait's poll unconfirmed.
144614
144618
  "firstResponder"
144615
144619
  ];
144616
- async function queryFullHierarchyTree(registry2, device) {
144620
+ async function queryFullHierarchyTree(registry2, device, launchedNativeApp) {
144617
144621
  let nativeApi;
144618
144622
  try {
144619
144623
  const ndRef = nativeDevtoolsRef(device);
@@ -144624,7 +144628,17 @@ async function queryFullHierarchyTree(registry2, device) {
144624
144628
  { cause: err }
144625
144629
  );
144626
144630
  }
144627
- const target = await resolveNativeTargetApp(nativeApi, void 0);
144631
+ let target;
144632
+ try {
144633
+ target = await resolveNativeTargetApp(nativeApi, void 0);
144634
+ } catch (err) {
144635
+ const timedOut = getFailureSignal(err)?.error_code === FAILURE_CODES.NATIVE_DEVTOOLS_RPC_TIMEOUT;
144636
+ if (timedOut && launchedNativeApp !== void 0 && nativeApi.listConnectedBundleIds().includes(launchedNativeApp)) {
144637
+ target = { bundleId: launchedNativeApp };
144638
+ } else {
144639
+ throw err;
144640
+ }
144641
+ }
144628
144642
  if (await nativeApi.requiresAppRestart(target.bundleId)) {
144629
144643
  throw new Error(
144630
144644
  `${target.bundleId} was launched before argent's instrumentation loaded \u2014 relaunch it (launch-app, or a flow \`launch\` step) so the full view hierarchy is readable`
@@ -144851,9 +144865,9 @@ async function queryVegaTree(device) {
144851
144865
  }
144852
144866
 
144853
144867
  // ../tool-server/src/tools/flows/flow-tree.ts
144854
- async function fetchFlowTree(registry2, device) {
144868
+ async function fetchFlowTree(registry2, device, launchedNativeApp) {
144855
144869
  if (device.platform === "ios") {
144856
- return queryFullHierarchyTree(registry2, device);
144870
+ return queryFullHierarchyTree(registry2, device, launchedNativeApp);
144857
144871
  }
144858
144872
  if (device.platform === "android") {
144859
144873
  return queryAndroidFullHierarchy(registry2, device);
@@ -145405,7 +145419,7 @@ async function settleTree(env) {
145405
145419
  if (env.signal?.aborted) return void 0;
145406
145420
  let tree;
145407
145421
  try {
145408
- ({ tree } = await fetchFlowTree(env.registry, env.device));
145422
+ ({ tree } = await fetchFlowTree(env.registry, env.device, env.launchedNativeApp));
145409
145423
  } catch (err) {
145410
145424
  lastError = err instanceof Error ? err : new Error(String(err));
145411
145425
  }
@@ -145466,7 +145480,7 @@ async function waitForFocus(env, into, tappedFrame) {
145466
145480
  for (; ; ) {
145467
145481
  if (env.signal?.aborted) return;
145468
145482
  try {
145469
- const { tree, source } = await fetchFlowTree(env.registry, env.device);
145483
+ const { tree, source } = await fetchFlowTree(env.registry, env.device, env.launchedNativeApp);
145470
145484
  if (!FOCUS_REPORTING_SOURCES.has(source)) return;
145471
145485
  const target = flowSelectorToFrame(tree, into) ?? tappedFrame;
145472
145486
  if (collectFocused(tree, []).some((n) => framesOverlap(n.frame, target))) return;
@@ -145668,7 +145682,7 @@ async function runPinch(env, step) {
145668
145682
  }
145669
145683
  async function fetchScreenAspect(env) {
145670
145684
  try {
145671
- const { screen } = await fetchFlowTree(env.registry, env.device);
145685
+ const { screen } = await fetchFlowTree(env.registry, env.device, env.launchedNativeApp);
145672
145686
  return screen && screen.width > 0 && screen.height > 0 ? screen.width / screen.height : void 0;
145673
145687
  } catch {
145674
145688
  return void 0;
@@ -145756,7 +145770,7 @@ async function waitForCondition(env, step, timeoutMs) {
145756
145770
  for (; ; ) {
145757
145771
  if (env.signal?.aborted) return ABORTED_OUTCOME;
145758
145772
  try {
145759
- const data = await fetchFlowTree(env.registry, env.device);
145773
+ const data = await fetchFlowTree(env.registry, env.device, env.launchedNativeApp);
145760
145774
  lastMatches = flowFindAll(data.tree, step.selector);
145761
145775
  fetchError = void 0;
145762
145776
  everMatched ||= lastMatches.length > 0;
@@ -145851,7 +145865,11 @@ async function waitForIdle(env, step) {
145851
145865
  const roundStartedAt = Date.now();
145852
145866
  let answeredReadMs;
145853
145867
  const [read, frame] = await Promise.all([
145854
- settleWithin(fetchFlowTree(env.registry, env.device), roundBudget, env.signal).then((r) => {
145868
+ settleWithin(
145869
+ fetchFlowTree(env.registry, env.device, env.launchedNativeApp),
145870
+ roundBudget,
145871
+ env.signal
145872
+ ).then((r) => {
145855
145873
  answeredReadMs = Date.now() - roundStartedAt;
145856
145874
  return r;
145857
145875
  }),
@@ -148427,8 +148445,15 @@ var fileInputs3 = [
148427
148445
  ];
148428
148446
  var MAX_RUN_DEPTH = 20;
148429
148447
  var POST_LAUNCH_SETTLE_MS = 1500;
148430
- var NATIVE_READY_TIMEOUT_MS = 8e3;
148448
+ var NATIVE_READY_TIMEOUT_MS = 15e3;
148431
148449
  var NATIVE_READY_POLL_MS = 250;
148450
+ var FOREGROUND_CHANGING_TOOLS = /* @__PURE__ */ new Set([
148451
+ "launch-app",
148452
+ "restart-app",
148453
+ "reinstall-app",
148454
+ "open-url",
148455
+ "button"
148456
+ ]);
148432
148457
  async function waitForNativeDevtools(registry2, device, bundleId, signal) {
148433
148458
  let api;
148434
148459
  try {
@@ -148509,6 +148534,7 @@ async function runLaunch(state3, app) {
148509
148534
  const gate = await treeSourceGate(registry2, device, bundleId, signal);
148510
148535
  if (signal?.aborted) return ABORTED_OUTCOME;
148511
148536
  if (gate) return { ok: false, reason: gate };
148537
+ state3.launchedNativeApp = bundleId;
148512
148538
  return { ok: true };
148513
148539
  }
148514
148540
  async function runChromiumLaunch(state3, app) {
@@ -149369,6 +149395,9 @@ async function execLeafStep(state3, step, index, scope) {
149369
149395
  return { ...base, status: "skip", tool: step.name, reason: "run aborted during delay" };
149370
149396
  }
149371
149397
  try {
149398
+ if (FOREGROUND_CHANGING_TOOLS.has(step.name)) {
149399
+ state3.launchedNativeApp = void 0;
149400
+ }
149372
149401
  const result = await invokeSubTool(registry2, ctx, step.name, args);
149373
149402
  if (isUnmetUiWaitResult(step.name, result)) {
149374
149403
  const note = result.note;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swmansion/argent",
3
- "version": "0.20.1-next.3",
3
+ "version": "0.20.1-next.4",
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",