@swmansion/argent 0.18.1-next.4 → 0.18.1-next.5

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
@@ -7009,6 +7009,7 @@ var FAILURE_CODES = {
7009
7009
  CHROMIUM_DEVICE_ID_INVALID: "CHROMIUM_DEVICE_ID_INVALID",
7010
7010
  CHROMIUM_PARAM_INVALID: "CHROMIUM_PARAM_INVALID",
7011
7011
  CHROMIUM_INPUT_INVALID: "CHROMIUM_INPUT_INVALID",
7012
+ CHROMIUM_WINDOW_HIDDEN: "CHROMIUM_WINDOW_HIDDEN",
7012
7013
  CHROMIUM_VIEWPORT_READ_FAILED: "CHROMIUM_VIEWPORT_READ_FAILED",
7013
7014
  CHROMIUM_SCREENSHOT_FAILED: "CHROMIUM_SCREENSHOT_FAILED",
7014
7015
  CHROMIUM_STORAGE_EVAL_FAILED: "CHROMIUM_STORAGE_EVAL_FAILED",
@@ -16235,6 +16235,7 @@ var FAILURE_CODES = {
16235
16235
  CHROMIUM_DEVICE_ID_INVALID: "CHROMIUM_DEVICE_ID_INVALID",
16236
16236
  CHROMIUM_PARAM_INVALID: "CHROMIUM_PARAM_INVALID",
16237
16237
  CHROMIUM_INPUT_INVALID: "CHROMIUM_INPUT_INVALID",
16238
+ CHROMIUM_WINDOW_HIDDEN: "CHROMIUM_WINDOW_HIDDEN",
16238
16239
  CHROMIUM_VIEWPORT_READ_FAILED: "CHROMIUM_VIEWPORT_READ_FAILED",
16239
16240
  CHROMIUM_SCREENSHOT_FAILED: "CHROMIUM_SCREENSHOT_FAILED",
16240
16241
  CHROMIUM_STORAGE_EVAL_FAILED: "CHROMIUM_STORAGE_EVAL_FAILED",
@@ -18265,6 +18265,7 @@ var FAILURE_CODES = {
18265
18265
  CHROMIUM_DEVICE_ID_INVALID: "CHROMIUM_DEVICE_ID_INVALID",
18266
18266
  CHROMIUM_PARAM_INVALID: "CHROMIUM_PARAM_INVALID",
18267
18267
  CHROMIUM_INPUT_INVALID: "CHROMIUM_INPUT_INVALID",
18268
+ CHROMIUM_WINDOW_HIDDEN: "CHROMIUM_WINDOW_HIDDEN",
18268
18269
  CHROMIUM_VIEWPORT_READ_FAILED: "CHROMIUM_VIEWPORT_READ_FAILED",
18269
18270
  CHROMIUM_SCREENSHOT_FAILED: "CHROMIUM_SCREENSHOT_FAILED",
18270
18271
  CHROMIUM_STORAGE_EVAL_FAILED: "CHROMIUM_STORAGE_EVAL_FAILED",
@@ -411,6 +411,7 @@ var init_failure_codes = __esm({
411
411
  CHROMIUM_DEVICE_ID_INVALID: "CHROMIUM_DEVICE_ID_INVALID",
412
412
  CHROMIUM_PARAM_INVALID: "CHROMIUM_PARAM_INVALID",
413
413
  CHROMIUM_INPUT_INVALID: "CHROMIUM_INPUT_INVALID",
414
+ CHROMIUM_WINDOW_HIDDEN: "CHROMIUM_WINDOW_HIDDEN",
414
415
  CHROMIUM_VIEWPORT_READ_FAILED: "CHROMIUM_VIEWPORT_READ_FAILED",
415
416
  CHROMIUM_SCREENSHOT_FAILED: "CHROMIUM_SCREENSHOT_FAILED",
416
417
  CHROMIUM_STORAGE_EVAL_FAILED: "CHROMIUM_STORAGE_EVAL_FAILED",
@@ -115252,13 +115253,17 @@ async function connectCdp(port) {
115252
115253
  await cdp.connect();
115253
115254
  return { cdp, wsUrl, target };
115254
115255
  }
115255
- async function enableCoreDomains(cdp) {
115256
+ async function primePageSession(cdp) {
115256
115257
  for (const domain2 of ["Page", "DOM", "Runtime", "Accessibility"]) {
115257
115258
  try {
115258
115259
  await cdp.send(`${domain2}.enable`);
115259
115260
  } catch {
115260
115261
  }
115261
115262
  }
115263
+ try {
115264
+ await cdp.send("Emulation.setFocusEmulationEnabled", { enabled: true });
115265
+ } catch {
115266
+ }
115262
115267
  }
115263
115268
  function mediaDir() {
115264
115269
  const dir = path11.join(os5.tmpdir(), "argent-chromium-media");
@@ -116070,7 +116075,7 @@ async function readViewport(cdp) {
116070
116075
  // ../tool-server/src/chromium-server/index.ts
116071
116076
  async function createChromiumServer(opts) {
116072
116077
  const { cdp, wsUrl, target } = await connectCdp(opts.port);
116073
- await enableCoreDomains(cdp);
116078
+ await primePageSession(cdp);
116074
116079
  let viewport = await readViewport(cdp);
116075
116080
  const events = new TypedEventEmitter();
116076
116081
  const fps = new FpsTracker(events);
@@ -116085,7 +116090,7 @@ async function createChromiumServer(opts) {
116085
116090
  port: opts.port,
116086
116091
  initialTargetId: target.id,
116087
116092
  onActivated: async () => {
116088
- await enableCoreDomains(cdp);
116093
+ await primePageSession(cdp);
116089
116094
  viewport = await readViewport(cdp);
116090
116095
  await network.reattach();
116091
116096
  }
@@ -124381,11 +124386,21 @@ function signalPid(pid, signal) {
124381
124386
  return err.code === "ESRCH" ? "gone" : "sent";
124382
124387
  }
124383
124388
  }
124389
+ var ANTI_THROTTLING_ARGS = [
124390
+ "--disable-background-timer-throttling",
124391
+ "--disable-backgrounding-occluded-windows",
124392
+ "--disable-renderer-backgrounding"
124393
+ ];
124384
124394
  async function bootElectronApp(options) {
124385
124395
  const port = options.port ?? await pickFreePort();
124386
124396
  const launcher = resolveLauncher(options.appPath);
124387
124397
  const extra = sanitizeExtraArgs(options.extraArgs ?? []);
124388
- const args = [...launcher.args, `--remote-debugging-port=${port}`, ...extra];
124398
+ const args = [
124399
+ ...launcher.args,
124400
+ `--remote-debugging-port=${port}`,
124401
+ ...ANTI_THROTTLING_ARGS,
124402
+ ...extra
124403
+ ];
124389
124404
  let child;
124390
124405
  try {
124391
124406
  child = (0, import_node_child_process17.spawn)(launcher.command, args, {
@@ -126791,6 +126806,34 @@ Fails if the simulator-server / emulator backend / Chromium CDP is not reachable
126791
126806
 
126792
126807
  // ../tool-server/src/tools/gesture-tap/index.ts
126793
126808
  init_zod();
126809
+
126810
+ // ../tool-server/src/utils/chromium-visibility.ts
126811
+ init_src();
126812
+ async function assertChromiumWindowVisible(chromium, action, failureStage) {
126813
+ let value;
126814
+ try {
126815
+ const raw = await chromium.cdp.send("Runtime.evaluate", {
126816
+ expression: "document.visibilityState",
126817
+ returnByValue: true
126818
+ });
126819
+ value = raw.result?.value;
126820
+ } catch {
126821
+ return;
126822
+ }
126823
+ if (value === "hidden") {
126824
+ throw new FailureError(
126825
+ `Cannot ${action}: the Chromium window is hidden (minimized or fully occluded), so the renderer will not process mouse input. Bring the window to the foreground and retry.`,
126826
+ {
126827
+ error_code: FAILURE_CODES.CHROMIUM_WINDOW_HIDDEN,
126828
+ failure_stage: failureStage,
126829
+ failure_area: "tool_server",
126830
+ error_kind: "validation"
126831
+ }
126832
+ );
126833
+ }
126834
+ }
126835
+
126836
+ // ../tool-server/src/tools/gesture-tap/index.ts
126794
126837
  var sleep2 = (ms) => new Promise((r) => setTimeout(r, ms));
126795
126838
  var zodSchema16 = external_exports.object({
126796
126839
  udid: external_exports.string().describe("Target device id from `list-devices` (iOS UDID, Android serial, or Chromium id)."),
@@ -126855,6 +126898,7 @@ Before tapping, determine the correct coordinates by using discovery tools \u201
126855
126898
  const clickCount = params.clickCount ?? 1;
126856
126899
  if (device.platform === "chromium") {
126857
126900
  const chromium = services.chromium;
126901
+ await assertChromiumWindowVisible(chromium, "tap", "chromium_tap_window_hidden");
126858
126902
  await tapChromium(chromium, params.x, params.y, clickCount);
126859
126903
  return { tapped: true, timestampMs };
126860
126904
  }
@@ -126950,30 +126994,7 @@ Pass settle:true for a momentum-free swipe that lands exactly where the finger l
126950
126994
 
126951
126995
  // ../tool-server/src/tools/gesture-scroll/index.ts
126952
126996
  init_zod();
126953
- init_src();
126954
126997
  var sleep4 = (ms) => new Promise((r) => setTimeout(r, ms));
126955
- async function assertWindowVisible(chromium) {
126956
- let raw;
126957
- try {
126958
- raw = await chromium.cdp.send("Runtime.evaluate", {
126959
- expression: "document.visibilityState",
126960
- returnByValue: true
126961
- });
126962
- } catch {
126963
- return;
126964
- }
126965
- if (raw.result?.value === "hidden") {
126966
- throw new FailureError(
126967
- "Cannot scroll: the Chromium window is hidden (minimized or fully occluded), so the renderer will not process input events. Bring the window to the foreground and retry.",
126968
- {
126969
- error_code: FAILURE_CODES.CHROMIUM_INPUT_INVALID,
126970
- failure_stage: "chromium_scroll_window_hidden",
126971
- failure_area: "tool_server",
126972
- error_kind: "validation"
126973
- }
126974
- );
126975
- }
126976
- }
126977
126998
  var zodSchema18 = external_exports.object({
126978
126999
  udid: external_exports.string().describe("Target Chromium device id from `list-devices` (chromium-cdp-<port>)."),
126979
127000
  x: external_exports.number().describe(
@@ -127022,7 +127043,7 @@ Returns { scrolled: true, timestampMs }. Fails if the Chromium CDP session is no
127022
127043
  async execute(services, params) {
127023
127044
  const timestampMs = Date.now();
127024
127045
  const chromium = services.chromium;
127025
- await assertWindowVisible(chromium);
127046
+ await assertChromiumWindowVisible(chromium, "scroll", "chromium_scroll_window_hidden");
127026
127047
  const vp = chromium.getViewport();
127027
127048
  const totalDx = (params.deltaX ?? 0) * vp.width;
127028
127049
  const totalDy = (params.deltaY ?? 0) * vp.height;
@@ -127071,6 +127092,7 @@ Returns { dragged: true, timestampMs }. Fails if the Chromium CDP session is not
127071
127092
  async execute(services, params) {
127072
127093
  const timestampMs = Date.now();
127073
127094
  const chromium = services.chromium;
127095
+ await assertChromiumWindowVisible(chromium, "drag", "chromium_drag_window_hidden");
127074
127096
  const vp = chromium.getViewport();
127075
127097
  const startPx = { x: params.fromX * vp.width, y: params.fromY * vp.height };
127076
127098
  const endPx = { x: params.toX * vp.width, y: params.toY * vp.height };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swmansion/argent",
3
- "version": "0.18.1-next.4",
3
+ "version": "0.18.1-next.5",
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",