@swmansion/argent 0.34.1-next.12 → 0.34.1-next.14

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
@@ -10630,6 +10630,7 @@ var FAILURE_CODES = {
10630
10630
  DEBUGGER_CDP_PROTOCOL_ERROR: "DEBUGGER_CDP_PROTOCOL_ERROR",
10631
10631
  DEBUGGER_CDP_CONNECT_FAILED: "DEBUGGER_CDP_CONNECT_FAILED",
10632
10632
  DEBUGGER_CDP_SOCKET_CLOSED_BEFORE_OPEN: "DEBUGGER_CDP_SOCKET_CLOSED_BEFORE_OPEN",
10633
+ DEBUGGER_CDP_ORIGIN_REJECTED: "DEBUGGER_CDP_ORIGIN_REJECTED",
10633
10634
  DEBUGGER_CDP_NOT_CONNECTED: "DEBUGGER_CDP_NOT_CONNECTED",
10634
10635
  DEBUGGER_CDP_REQUEST_TIMEOUT: "DEBUGGER_CDP_REQUEST_TIMEOUT",
10635
10636
  DEBUGGER_CDP_CONNECTION_CLOSED: "DEBUGGER_CDP_CONNECTION_CLOSED",
@@ -36078,7 +36079,7 @@ var _CI_VENDOR_COUNT_FOR_TEST = vendors_default.length;
36078
36079
  var SESSION_ID2 = randomUUID5();
36079
36080
  function readCliVersion() {
36080
36081
  if (true) {
36081
- return "0.34.1-next.12";
36082
+ return "0.34.1-next.14";
36082
36083
  }
36083
36084
  return "0.0.0";
36084
36085
  }
package/dist/client.js CHANGED
@@ -9203,6 +9203,7 @@ var FAILURE_CODES = {
9203
9203
  DEBUGGER_CDP_PROTOCOL_ERROR: "DEBUGGER_CDP_PROTOCOL_ERROR",
9204
9204
  DEBUGGER_CDP_CONNECT_FAILED: "DEBUGGER_CDP_CONNECT_FAILED",
9205
9205
  DEBUGGER_CDP_SOCKET_CLOSED_BEFORE_OPEN: "DEBUGGER_CDP_SOCKET_CLOSED_BEFORE_OPEN",
9206
+ DEBUGGER_CDP_ORIGIN_REJECTED: "DEBUGGER_CDP_ORIGIN_REJECTED",
9206
9207
  DEBUGGER_CDP_NOT_CONNECTED: "DEBUGGER_CDP_NOT_CONNECTED",
9207
9208
  DEBUGGER_CDP_REQUEST_TIMEOUT: "DEBUGGER_CDP_REQUEST_TIMEOUT",
9208
9209
  DEBUGGER_CDP_CONNECTION_CLOSED: "DEBUGGER_CDP_CONNECTION_CLOSED",
@@ -15853,6 +15853,7 @@ var FAILURE_CODES = {
15853
15853
  DEBUGGER_CDP_PROTOCOL_ERROR: "DEBUGGER_CDP_PROTOCOL_ERROR",
15854
15854
  DEBUGGER_CDP_CONNECT_FAILED: "DEBUGGER_CDP_CONNECT_FAILED",
15855
15855
  DEBUGGER_CDP_SOCKET_CLOSED_BEFORE_OPEN: "DEBUGGER_CDP_SOCKET_CLOSED_BEFORE_OPEN",
15856
+ DEBUGGER_CDP_ORIGIN_REJECTED: "DEBUGGER_CDP_ORIGIN_REJECTED",
15856
15857
  DEBUGGER_CDP_NOT_CONNECTED: "DEBUGGER_CDP_NOT_CONNECTED",
15857
15858
  DEBUGGER_CDP_REQUEST_TIMEOUT: "DEBUGGER_CDP_REQUEST_TIMEOUT",
15858
15859
  DEBUGGER_CDP_CONNECTION_CLOSED: "DEBUGGER_CDP_CONNECTION_CLOSED",
@@ -16877,7 +16878,7 @@ var _CI_VENDOR_COUNT_FOR_TEST = vendors_default.length;
16877
16878
  var SESSION_ID = randomUUID4();
16878
16879
  function readCliVersion() {
16879
16880
  if (true) {
16880
- return "0.34.1-next.12";
16881
+ return "0.34.1-next.14";
16881
16882
  }
16882
16883
  return "0.0.0";
16883
16884
  }
@@ -25913,6 +25913,7 @@ var FAILURE_CODES = {
25913
25913
  DEBUGGER_CDP_PROTOCOL_ERROR: "DEBUGGER_CDP_PROTOCOL_ERROR",
25914
25914
  DEBUGGER_CDP_CONNECT_FAILED: "DEBUGGER_CDP_CONNECT_FAILED",
25915
25915
  DEBUGGER_CDP_SOCKET_CLOSED_BEFORE_OPEN: "DEBUGGER_CDP_SOCKET_CLOSED_BEFORE_OPEN",
25916
+ DEBUGGER_CDP_ORIGIN_REJECTED: "DEBUGGER_CDP_ORIGIN_REJECTED",
25916
25917
  DEBUGGER_CDP_NOT_CONNECTED: "DEBUGGER_CDP_NOT_CONNECTED",
25917
25918
  DEBUGGER_CDP_REQUEST_TIMEOUT: "DEBUGGER_CDP_REQUEST_TIMEOUT",
25918
25919
  DEBUGGER_CDP_CONNECTION_CLOSED: "DEBUGGER_CDP_CONNECTION_CLOSED",
@@ -1673,6 +1673,7 @@ var init_failure_codes = __esm({
1673
1673
  DEBUGGER_CDP_PROTOCOL_ERROR: "DEBUGGER_CDP_PROTOCOL_ERROR",
1674
1674
  DEBUGGER_CDP_CONNECT_FAILED: "DEBUGGER_CDP_CONNECT_FAILED",
1675
1675
  DEBUGGER_CDP_SOCKET_CLOSED_BEFORE_OPEN: "DEBUGGER_CDP_SOCKET_CLOSED_BEFORE_OPEN",
1676
+ DEBUGGER_CDP_ORIGIN_REJECTED: "DEBUGGER_CDP_ORIGIN_REJECTED",
1676
1677
  DEBUGGER_CDP_NOT_CONNECTED: "DEBUGGER_CDP_NOT_CONNECTED",
1677
1678
  DEBUGGER_CDP_REQUEST_TIMEOUT: "DEBUGGER_CDP_REQUEST_TIMEOUT",
1678
1679
  DEBUGGER_CDP_CONNECTION_CLOSED: "DEBUGGER_CDP_CONNECTION_CLOSED",
@@ -4180,9 +4181,9 @@ function parseURLObject(trimmed, def) {
4180
4181
  function stripTabAndNewline(value) {
4181
4182
  return value.replace(asciiTabOrNewline, "");
4182
4183
  }
4183
- function urlHostnameOk(url2, hostname3) {
4184
- hostname3.lastIndex = 0;
4185
- return hostname3.test(url2.hostname);
4184
+ function urlHostnameOk(url2, hostname4) {
4185
+ hostname4.lastIndex = 0;
4186
+ return hostname4.test(url2.hostname);
4186
4187
  }
4187
4188
  function urlProtocolOk(url2, protocol) {
4188
4189
  protocol.lastIndex = 0;
@@ -65524,10 +65525,10 @@ var require_request = __commonJS({
65524
65525
  return addrs;
65525
65526
  });
65526
65527
  defineGetter(req, "subdomains", function subdomains() {
65527
- var hostname3 = this.hostname;
65528
- if (!hostname3) return [];
65528
+ var hostname4 = this.hostname;
65529
+ if (!hostname4) return [];
65529
65530
  var offset = this.app.get("subdomain offset");
65530
- var subdomains2 = !isIP(hostname3) ? hostname3.split(".").reverse() : [hostname3];
65531
+ var subdomains2 = !isIP(hostname4) ? hostname4.split(".").reverse() : [hostname4];
65531
65532
  return subdomains2.slice(offset);
65532
65533
  });
65533
65534
  defineGetter(req, "path", function path64() {
@@ -65543,7 +65544,7 @@ var require_request = __commonJS({
65543
65544
  }
65544
65545
  return val || void 0;
65545
65546
  });
65546
- defineGetter(req, "hostname", function hostname3() {
65547
+ defineGetter(req, "hostname", function hostname4() {
65547
65548
  var host = this.host;
65548
65549
  if (!host) return;
65549
65550
  var offset = host[0] === "[" ? host.indexOf("]") + 1 : 0;
@@ -89287,11 +89288,11 @@ var require_bunyan = __commonJS({
89287
89288
  if (!runtimeEnv) {
89288
89289
  throw new Error("unknown runtime environment");
89289
89290
  }
89290
- var os26;
89291
+ var os27;
89291
89292
  var fs79;
89292
89293
  var dtrace;
89293
89294
  if (runtimeEnv === "browser") {
89294
- os26 = {
89295
+ os27 = {
89295
89296
  hostname: function() {
89296
89297
  return window.location.host;
89297
89298
  }
@@ -89299,7 +89300,7 @@ var require_bunyan = __commonJS({
89299
89300
  fs79 = {};
89300
89301
  dtrace = null;
89301
89302
  } else {
89302
- os26 = require("os");
89303
+ os27 = require("os");
89303
89304
  fs79 = require("fs");
89304
89305
  try {
89305
89306
  dtrace = require("dtrace-provider");
@@ -89633,7 +89634,7 @@ var require_bunyan = __commonJS({
89633
89634
  this._applySerializers(fields);
89634
89635
  }
89635
89636
  if (!fields.hostname && !self2.fields.hostname) {
89636
- fields.hostname = os26.hostname();
89637
+ fields.hostname = os27.hostname();
89637
89638
  }
89638
89639
  if (!fields.pid) {
89639
89640
  fields.pid = process.pid;
@@ -89842,7 +89843,7 @@ var require_bunyan = __commonJS({
89842
89843
  }
89843
89844
  var str3;
89844
89845
  if (noemit || this.haveNonRawStreams) {
89845
- str3 = fastAndSafeJsonStringify(rec) + os26.EOL;
89846
+ str3 = fastAndSafeJsonStringify(rec) + os27.EOL;
89846
89847
  }
89847
89848
  if (noemit)
89848
89849
  return str3;
@@ -101278,7 +101279,7 @@ var _CI_VENDOR_COUNT_FOR_TEST = vendors_default.length;
101278
101279
  var SESSION_ID = (0, import_node_crypto3.randomUUID)();
101279
101280
  function readCliVersion() {
101280
101281
  if (true) {
101281
- return "0.34.1-next.12";
101282
+ return "0.34.1-next.14";
101282
101283
  }
101283
101284
  return "0.0.0";
101284
101285
  }
@@ -120808,14 +120809,14 @@ var parser_os_default = [
120808
120809
  describe(ua) {
120809
120810
  const version3 = Utils.getFirstMatch(/mac os x (\d+(\.?_?\d+)+)/i, ua).replace(/[_\s]/g, ".");
120810
120811
  const versionName3 = Utils.getMacOSVersionName(version3);
120811
- const os26 = {
120812
+ const os27 = {
120812
120813
  name: OS_MAP.MacOS,
120813
120814
  version: version3
120814
120815
  };
120815
120816
  if (versionName3) {
120816
- os26.versionName = versionName3;
120817
+ os27.versionName = versionName3;
120817
120818
  }
120818
- return os26;
120819
+ return os27;
120819
120820
  }
120820
120821
  },
120821
120822
  /* iOS */
@@ -120850,14 +120851,14 @@ var parser_os_default = [
120850
120851
  describe(ua) {
120851
120852
  const version3 = Utils.getFirstMatch(/android[\s/-](\d+(\.\d+)*)/i, ua);
120852
120853
  const versionName3 = Utils.getAndroidVersionName(version3);
120853
- const os26 = {
120854
+ const os27 = {
120854
120855
  name: OS_MAP.Android,
120855
120856
  version: version3
120856
120857
  };
120857
120858
  if (versionName3) {
120858
- os26.versionName = versionName3;
120859
+ os27.versionName = versionName3;
120859
120860
  }
120860
- return os26;
120861
+ return os27;
120861
120862
  }
120862
120863
  },
120863
120864
  /* WebOS */
@@ -120865,13 +120866,13 @@ var parser_os_default = [
120865
120866
  test: [/(web|hpw)[o0]s/i],
120866
120867
  describe(ua) {
120867
120868
  const version3 = Utils.getFirstMatch(/(?:web|hpw)[o0]s\/(\d+(\.\d+)*)/i, ua);
120868
- const os26 = {
120869
+ const os27 = {
120869
120870
  name: OS_MAP.WebOS
120870
120871
  };
120871
120872
  if (version3 && version3.length) {
120872
- os26.version = version3;
120873
+ os27.version = version3;
120873
120874
  }
120874
- return os26;
120875
+ return os27;
120875
120876
  }
120876
120877
  },
120877
120878
  /* BlackBerry */
@@ -121727,7 +121728,7 @@ var Parser = class {
121727
121728
  */
121728
121729
  parseOS() {
121729
121730
  this.parsedResult.os = {};
121730
- const os26 = Utils.find(parser_os_default, (_os) => {
121731
+ const os27 = Utils.find(parser_os_default, (_os) => {
121731
121732
  if (typeof _os.test === "function") {
121732
121733
  return _os.test(this);
121733
121734
  }
@@ -121736,8 +121737,8 @@ var Parser = class {
121736
121737
  }
121737
121738
  throw new Error("Browser's test function is not valid");
121738
121739
  });
121739
- if (os26) {
121740
- this.parsedResult.os = os26.describe(this.getUA());
121740
+ if (os27) {
121741
+ this.parsedResult.os = os27.describe(this.getUA());
121741
121742
  }
121742
121743
  return this.parsedResult.os;
121743
121744
  }
@@ -126917,7 +126918,7 @@ async function issueSandboxExtension(filePath, opts = {}) {
126917
126918
 
126918
126919
  // ../tool-server/src/utils/chromium-discovery.ts
126919
126920
  var fs26 = __toESM(require("node:fs"));
126920
- var os9 = __toESM(require("node:os"));
126921
+ var os10 = __toESM(require("node:os"));
126921
126922
  var path22 = __toESM(require("node:path"));
126922
126923
  init_src2();
126923
126924
  init_device_info();
@@ -126930,7 +126931,7 @@ init_src2();
126930
126931
 
126931
126932
  // ../tool-server/src/chromium-server/cdp-session.ts
126932
126933
  var fs24 = __toESM(require("node:fs"));
126933
- var os8 = __toESM(require("node:os"));
126934
+ var os9 = __toESM(require("node:os"));
126934
126935
  var path20 = __toESM(require("node:path"));
126935
126936
  init_src2();
126936
126937
 
@@ -126938,6 +126939,46 @@ init_src2();
126938
126939
  init_wrapper();
126939
126940
  init_src2();
126940
126941
  var crypto3 = __toESM(require("node:crypto"));
126942
+
126943
+ // ../tool-server/src/utils/debugger/metro-origin.ts
126944
+ var os8 = __toESM(require("node:os"));
126945
+ function metroOriginCandidates(wsUrl) {
126946
+ const { protocol, host, port } = new URL(wsUrl);
126947
+ const scheme = protocol === "wss:" ? "https://" : "http://";
126948
+ const at = (hostname4) => `${scheme}${bracketed(hostname4)}${port ? `:${port}` : ""}`;
126949
+ const candidates = [
126950
+ scheme + host.replace("localhost", "127.0.0.1"),
126951
+ at("localhost"),
126952
+ process.env.REACT_NATIVE_PACKAGER_HOSTNAME?.trim() || void 0,
126953
+ ...lanAddresses(),
126954
+ os8.hostname()
126955
+ ].map((candidate) => candidate && !candidate.includes("://") ? at(candidate) : candidate);
126956
+ return [...new Set(candidates.filter((c) => !!c))];
126957
+ }
126958
+ async function expoManifestOrigin(wsUrl) {
126959
+ const { protocol, host } = new URL(wsUrl);
126960
+ const httpUrl2 = `${protocol === "wss:" ? "https:" : "http:"}//${host}/`;
126961
+ try {
126962
+ const response = await fetch(httpUrl2, {
126963
+ headers: { "expo-platform": "ios", "accept": "application/expo+json,application/json" },
126964
+ signal: AbortSignal.timeout(2e3)
126965
+ });
126966
+ if (!response.ok) return void 0;
126967
+ const manifest = await response.json();
126968
+ const bundleUrl = manifest.launchAsset?.url;
126969
+ return typeof bundleUrl === "string" ? new URL(bundleUrl).origin : void 0;
126970
+ } catch {
126971
+ return void 0;
126972
+ }
126973
+ }
126974
+ function lanAddresses() {
126975
+ return Object.values(os8.networkInterfaces()).flat().filter((address) => address && !address.internal && address.family === "IPv4").map((address) => address.address);
126976
+ }
126977
+ function bracketed(hostname4) {
126978
+ return hostname4.includes(":") && !hostname4.startsWith("[") ? `[${hostname4}]` : hostname4;
126979
+ }
126980
+
126981
+ // ../tool-server/src/utils/debugger/cdp-client.ts
126941
126982
  var BLOCKED_WHILE_PAUSED = /* @__PURE__ */ new Set(["Runtime.evaluate", "Runtime.callFunctionOn"]);
126942
126983
  function trimBundleQuery(url2) {
126943
126984
  const trimmed = url2.split(/[?&]/)[0].replace(/\/+$/, "");
@@ -126958,6 +126999,8 @@ function formatExceptionDetails(details) {
126958
126999
  ${frameLines}`;
126959
127000
  }
126960
127001
  var DEFAULT_TIMEOUT_MS2 = 1e4;
127002
+ var ORIGIN_SETTLE_MS = 100;
127003
+ var acceptedOrigins = /* @__PURE__ */ new Map();
126961
127004
  var CDPClient = class {
126962
127005
  events = new TypedEventEmitter();
126963
127006
  ws = null;
@@ -126981,22 +127024,79 @@ var CDPClient = class {
126981
127024
  this.wsUrl = wsUrl;
126982
127025
  this.sendOrigin = options?.sendOrigin !== false;
126983
127026
  }
126984
- connect() {
126985
- return new Promise((resolve19, reject) => {
126986
- let headers;
126987
- if (this.sendOrigin) {
126988
- const { protocol, host } = new URL(this.wsUrl);
126989
- const origin = (protocol === "wss:" ? "https://" : "http://") + host.replace("localhost", "127.0.0.1");
126990
- headers = { Origin: origin };
127027
+ async connect() {
127028
+ if (!this.sendOrigin) {
127029
+ await this.open(void 0);
127030
+ return;
127031
+ }
127032
+ const metro = new URL(this.wsUrl).host;
127033
+ const tried = [];
127034
+ const attempt = async (origin) => {
127035
+ if (!origin || tried.includes(origin)) return false;
127036
+ tried.push(origin);
127037
+ if (await this.open(origin) === "rejected") return false;
127038
+ acceptedOrigins.set(metro, origin);
127039
+ return true;
127040
+ };
127041
+ const remembered = acceptedOrigins.get(metro);
127042
+ if (await attempt(remembered)) return;
127043
+ if (await attempt(await expoManifestOrigin(this.wsUrl))) return;
127044
+ for (const origin of metroOriginCandidates(this.wsUrl)) {
127045
+ if (await attempt(origin)) return;
127046
+ }
127047
+ acceptedOrigins.delete(metro);
127048
+ throw new FailureError(
127049
+ `Metro at ${metro} refused the debugger connection for every Origin argent tried (${tried.join(", ")}): it answered the upgrade with 401 or 403, or dropped the socket without a close frame right after it. Expo's dev server drops it when the Origin does not match its server URL, which REACT_NATIVE_PACKAGER_HOSTNAME moves to another host. Restart Metro with REACT_NATIVE_PACKAGER_HOSTNAME unset, or set to 127.0.0.1, then retry.`,
127050
+ {
127051
+ error_code: FAILURE_CODES.DEBUGGER_CDP_ORIGIN_REJECTED,
127052
+ failure_stage: "debugger_cdp_connect",
127053
+ failure_area: "tool_server",
127054
+ error_kind: "network"
126991
127055
  }
126992
- const ws = new wrapper_default(this.wsUrl, headers ? { headers } : void 0);
127056
+ );
127057
+ }
127058
+ /**
127059
+ * Open one socket. Without an Origin this is a plain connect.
127060
+ *
127061
+ * With one, the socket must then stay open for {@linkcode ORIGIN_SETTLE_MS}
127062
+ * (or carry a message) before it counts, since Expo completes the upgrade for
127063
+ * any Origin and only then terminates a socket whose Origin it rejects.
127064
+ * `rejected` is that termination (close code 1006, no close frame) or a
127065
+ * 401/403 for the upgrade, and the socket is discarded without emitting
127066
+ * `connected` or `disconnected`. Any other close inside the window, such as
127067
+ * React Native's `[PAGE_NOT_FOUND]` or `[NEW_DEBUGGER_OPENED]`, which carry a
127068
+ * close frame, is not about the Origin: the socket counts as opened and then
127069
+ * lost, as it would without the window.
127070
+ */
127071
+ open(origin) {
127072
+ return new Promise((resolve19, reject) => {
127073
+ const ws = new wrapper_default(this.wsUrl, origin ? { headers: { Origin: origin } } : void 0);
126993
127074
  this.ws = ws;
126994
- const onOpen = () => {
127075
+ let state3 = "opening";
127076
+ let settle3;
127077
+ const accept2 = () => {
126995
127078
  cleanup();
127079
+ state3 = "open";
126996
127080
  this.events.emit("connected");
126997
- resolve19();
127081
+ resolve19("open");
127082
+ };
127083
+ const drop = () => {
127084
+ cleanup();
127085
+ state3 = "dropped";
127086
+ ws.terminate();
127087
+ if (this.ws === ws) this.ws = null;
127088
+ resolve19("rejected");
127089
+ };
127090
+ const onOpen = () => {
127091
+ clearTimeout(timer);
127092
+ if (!origin) return accept2();
127093
+ state3 = "settling";
127094
+ settle3 = setTimeout(accept2, ORIGIN_SETTLE_MS);
127095
+ ws.once("message", accept2);
126998
127096
  };
126999
127097
  const onError = (err) => {
127098
+ if (state3 === "settling") return;
127099
+ if (origin && /Unexpected server response: 40[13]\b/.test(err.message)) return drop();
127000
127100
  cleanup();
127001
127101
  reject(
127002
127102
  new FailureError(
@@ -127011,7 +127111,8 @@ var CDPClient = class {
127011
127111
  )
127012
127112
  );
127013
127113
  };
127014
- const onClose = () => {
127114
+ const onClose = (code) => {
127115
+ if (state3 === "settling") return code === 1006 ? drop() : accept2();
127015
127116
  cleanup();
127016
127117
  reject(
127017
127118
  new FailureError("WebSocket closed before open", {
@@ -127040,19 +127141,24 @@ var CDPClient = class {
127040
127141
  }, DEFAULT_TIMEOUT_MS2);
127041
127142
  const cleanup = () => {
127042
127143
  clearTimeout(timer);
127144
+ clearTimeout(settle3);
127043
127145
  ws.removeListener("open", onOpen);
127044
127146
  ws.removeListener("error", onError);
127045
127147
  ws.removeListener("close", onClose);
127148
+ ws.removeListener("message", accept2);
127046
127149
  };
127047
127150
  ws.on("open", onOpen);
127048
127151
  ws.on("error", onError);
127049
127152
  ws.on("close", onClose);
127153
+ const ignored = () => state3 === "settling" || state3 === "dropped";
127050
127154
  ws.on("message", (raw) => this.handleMessage(raw));
127051
127155
  ws.on("close", () => {
127156
+ if (ignored()) return;
127052
127157
  this.cleanup();
127053
127158
  this.events.emit("disconnected");
127054
127159
  });
127055
127160
  ws.on("error", (err) => {
127161
+ if (ignored()) return;
127056
127162
  this.cleanup();
127057
127163
  this.events.emit("disconnected", err);
127058
127164
  });
@@ -127516,7 +127622,7 @@ async function primePageSession(cdp) {
127516
127622
  }
127517
127623
  }
127518
127624
  function mediaDir() {
127519
- const dir = path20.join(os8.tmpdir(), "argent-chromium-media");
127625
+ const dir = path20.join(os9.tmpdir(), "argent-chromium-media");
127520
127626
  fs24.mkdirSync(dir, { recursive: true });
127521
127627
  return dir;
127522
127628
  }
@@ -128621,7 +128727,7 @@ function parsePortList(raw) {
128621
128727
  }
128622
128728
  var TRACKED_PORTS = /* @__PURE__ */ new Set();
128623
128729
  function portsFilePath() {
128624
- return process.env.ARGENT_CHROMIUM_PORTS_FILE ?? path22.join(os9.homedir(), ".argent", "chromium-cdp-ports.json");
128730
+ return process.env.ARGENT_CHROMIUM_PORTS_FILE ?? path22.join(os10.homedir(), ".argent", "chromium-cdp-ports.json");
128625
128731
  }
128626
128732
  function loadPersistedPorts() {
128627
128733
  try {
@@ -134161,7 +134267,7 @@ var import_node_util18 = require("node:util");
134161
134267
  var import_node_crypto9 = require("node:crypto");
134162
134268
  var fs31 = __toESM(require("node:fs"));
134163
134269
  var fsp = __toESM(require("node:fs/promises"));
134164
- var os11 = __toESM(require("node:os"));
134270
+ var os12 = __toESM(require("node:os"));
134165
134271
  var path27 = __toESM(require("node:path"));
134166
134272
  init_src2();
134167
134273
 
@@ -134362,7 +134468,7 @@ async function xcodeVersionFingerprint() {
134362
134468
  }
134363
134469
  }
134364
134470
  function derivedRoot() {
134365
- return path27.join(os11.homedir(), ".argent", "ios-device-runner", "derived");
134471
+ return path27.join(os12.homedir(), ".argent", "ios-device-runner", "derived");
134366
134472
  }
134367
134473
  function derivedDirForTeam(teamId) {
134368
134474
  return path27.join(derivedRoot(), teamId);
@@ -134568,16 +134674,16 @@ var import_node_child_process27 = require("node:child_process");
134568
134674
  var import_node_events2 = require("node:events");
134569
134675
  var fs32 = __toESM(require("node:fs"));
134570
134676
  var fsp2 = __toESM(require("node:fs/promises"));
134571
- var os12 = __toESM(require("node:os"));
134677
+ var os13 = __toESM(require("node:os"));
134572
134678
  var path28 = __toESM(require("node:path"));
134573
134679
  var import_node_util19 = require("node:util");
134574
134680
  init_src2();
134575
134681
  var execFileAsync19 = (0, import_node_util19.promisify)(import_node_child_process27.execFile);
134576
134682
  function logsRoot() {
134577
- return path28.join(os12.homedir(), ".argent", "ios-device-runner", "logs");
134683
+ return path28.join(os13.homedir(), ".argent", "ios-device-runner", "logs");
134578
134684
  }
134579
134685
  function resultsRoot() {
134580
- return path28.join(os12.homedir(), ".argent", "ios-device-runner", "results");
134686
+ return path28.join(os13.homedir(), ".argent", "ios-device-runner", "results");
134581
134687
  }
134582
134688
  var RUNNER_ATTACHMENT_SETTINGS = [
134583
134689
  ["PreferredScreenCaptureFormat", "screenshots"],
@@ -141491,7 +141597,7 @@ var import_node_child_process30 = require("node:child_process");
141491
141597
  var import_node_events4 = require("node:events");
141492
141598
  var fs35 = __toESM(require("node:fs"));
141493
141599
  var net7 = __toESM(require("node:net"));
141494
- var os13 = __toESM(require("node:os"));
141600
+ var os14 = __toESM(require("node:os"));
141495
141601
  var path30 = __toESM(require("node:path"));
141496
141602
  init_src2();
141497
141603
  init_device_info();
@@ -142113,7 +142219,7 @@ function createMacosAppApi(bundleId) {
142113
142219
  return `argent force-quit ${bundleId} (pid ${app.pid}): ${reason2}. Unsaved changes in it may be lost.`;
142114
142220
  };
142115
142221
  const doLaunch = async (opts) => {
142116
- const hostRefusal = process.platform === "darwin" ? macosVersionRefusal(os13.release()) : "Native Mac apps can only be driven on macOS.";
142222
+ const hostRefusal = process.platform === "darwin" ? macosVersionRefusal(os14.release()) : "Native Mac apps can only be driven on macOS.";
142117
142223
  if (hostRefusal) {
142118
142224
  throw macosFailure(
142119
142225
  hostRefusal,
@@ -144129,8 +144235,8 @@ function isAllowedSourceMapURL(raw) {
144129
144235
  }
144130
144236
  if (parsed.protocol !== "http:" && parsed.protocol !== "https:") return false;
144131
144237
  if (!parsed.pathname.endsWith(".map")) return false;
144132
- const hostname3 = parsed.hostname.startsWith("[") && parsed.hostname.endsWith("]") ? parsed.hostname.slice(1, -1) : parsed.hostname;
144133
- return ALLOWED_SOURCE_MAP_HOSTS.has(hostname3);
144238
+ const hostname4 = parsed.hostname.startsWith("[") && parsed.hostname.endsWith("]") ? parsed.hostname.slice(1, -1) : parsed.hostname;
144239
+ return ALLOWED_SOURCE_MAP_HOSTS.has(hostname4);
144134
144240
  }
144135
144241
  var MAX_SOURCE_MAP_BYTES = 64 * 1024 * 1024;
144136
144242
  async function drainCappedBody(res, maxBytes = MAX_SOURCE_MAP_BYTES) {
@@ -144185,7 +144291,7 @@ var SourceMapsRegistry = class {
144185
144291
  // ../tool-server/src/utils/debugger/log-file-writer.ts
144186
144292
  var fs36 = __toESM(require("node:fs"));
144187
144293
  var path31 = __toESM(require("node:path"));
144188
- var os14 = __toESM(require("node:os"));
144294
+ var os15 = __toESM(require("node:os"));
144189
144295
  var MAX_ENTRIES = 5e4;
144190
144296
  var STALE_LOG_MS = 24 * 60 * 60 * 1e3;
144191
144297
  var CLUSTER_KEY_LENGTH = 80;
@@ -144203,7 +144309,7 @@ var LogFileWriter = class {
144203
144309
  closed = false;
144204
144310
  constructor(port) {
144205
144311
  const timestamp = Date.now();
144206
- const dir = path31.join(os14.homedir(), ".argent", "tmp");
144312
+ const dir = path31.join(os15.homedir(), ".argent", "tmp");
144207
144313
  fs36.mkdirSync(dir, { recursive: true });
144208
144314
  pruneStaleLogs(dir);
144209
144315
  this.filePath = path31.join(dir, `argent-logs-${port}-${timestamp}-p${process.pid}.log`);
@@ -144643,6 +144749,7 @@ var NOT_CONNECTED_CODE_MAP = {
144643
144749
  [FAILURE_CODES.DEBUGGER_TARGET_DEVICE_MISMATCH]: "device_mismatch",
144644
144750
  [FAILURE_CODES.DEBUGGER_CDP_CONNECT_FAILED]: "cdp_unreachable",
144645
144751
  [FAILURE_CODES.DEBUGGER_CDP_SOCKET_CLOSED_BEFORE_OPEN]: "cdp_unreachable",
144752
+ [FAILURE_CODES.DEBUGGER_CDP_ORIGIN_REJECTED]: "cdp_unreachable",
144646
144753
  [FAILURE_CODES.DEBUGGER_CDP_NOT_CONNECTED]: "cdp_unreachable",
144647
144754
  [FAILURE_CODES.DEBUGGER_CDP_CONNECTION_CLOSED]: "cdp_unreachable",
144648
144755
  // Raised by the connect pipeline's enable/binding sends when the target
@@ -145042,8 +145149,8 @@ function createHttpApp(registry2, options) {
145042
145149
  res.status(400).json({ error: "Missing Host header" });
145043
145150
  return;
145044
145151
  }
145045
- const hostname3 = extractHostname(host);
145046
- if (!allowedHostnames.has(hostname3)) {
145152
+ const hostname4 = extractHostname(host);
145153
+ if (!allowedHostnames.has(hostname4)) {
145047
145154
  res.status(403).json({
145048
145155
  error: `Refusing request with Host "${host}". The tool-server accepts loopback hostnames (127.0.0.1, localhost, ::1)` + (isLoopbackHost(bindHost) ? "" : ` and its bind host (${bindHost})`) + ` to defend against DNS-rebinding. If you are reaching this from your own client, use one of those instead of a public hostname.`
145049
145156
  });
@@ -148211,6 +148318,7 @@ function macosAppTargets(pool, bundleId, port) {
148211
148318
  );
148212
148319
  }
148213
148320
  var seenLogicalDeviceIds = /* @__PURE__ */ new Set();
148321
+ var LOGICAL_DEVICE_ID_SHAPE = /^[0-9a-f]{40}$/;
148214
148322
  function selectTarget(targets, port, options) {
148215
148323
  const pool = targets;
148216
148324
  for (const t of pool) {
@@ -148244,9 +148352,11 @@ function selectTarget(targets, port, options) {
148244
148352
  }
148245
148353
  );
148246
148354
  }
148247
- if (seenLogicalDeviceIds.has(deviceId)) {
148355
+ const seen = seenLogicalDeviceIds.has(deviceId);
148356
+ if (seen || LOGICAL_DEVICE_ID_SHAPE.test(deviceId)) {
148357
+ const state3 = seen ? `is no longer attached to Metro on port ${port} \u2014 its app likely exited or reloaded onto another Metro. ` : `is not attached to Metro on port ${port} \u2014 its app is not running, is still starting, or uses another Metro. `;
148248
148358
  throw new FailureError(
148249
- `Device with logicalDeviceId "${deviceId}" is no longer attached to Metro on port ${port} \u2014 its app likely exited or reloaded onto another Metro. Not falling back to the remaining device: ${[...distinctDevices.values()].join(", ")}. If the app exited, relaunch it on the target device (launch-app / restart-app), then retry with the same id: a relaunched app keeps its logicalDeviceId. If it was reinstalled (reinstall-app), iOS can give it a new logicalDeviceId: when the device listed above is your target, retry with the id shown for it.`,
148359
+ `Device with logicalDeviceId "${deviceId}" ${state3}Not falling back to the remaining device: ${[...distinctDevices.values()].join(", ")}. If the app exited, relaunch it on the target device (launch-app / restart-app), then retry with the same id: a relaunched app keeps its logicalDeviceId. If it was reinstalled (reinstall-app), iOS can give it a new logicalDeviceId: when the device listed above is your target, retry with the id shown for it.`,
148250
148360
  {
148251
148361
  error_code: FAILURE_CODES.DEBUGGER_METRO_NO_TARGETS,
148252
148362
  failure_stage: "debugger_select_target",
@@ -154890,7 +155000,7 @@ Returns { opened, url, note? }. \`note\` explains the routing caveat when a web
154890
155000
  // ../tool-server/src/tools/screenshot/index.ts
154891
155001
  var import_node_child_process43 = require("node:child_process");
154892
155002
  var import_node_util33 = require("node:util");
154893
- var os16 = __toESM(require("node:os"));
155003
+ var os17 = __toESM(require("node:os"));
154894
155004
  var path37 = __toESM(require("node:path"));
154895
155005
  init_zod();
154896
155006
  init_src2();
@@ -155110,7 +155220,7 @@ var capability9 = {
155110
155220
  };
155111
155221
  async function iosPhysicalScreenshot(registry2, device, scale) {
155112
155222
  const file2 = path37.join(
155113
- os16.tmpdir(),
155223
+ os17.tmpdir(),
155114
155224
  `argent-ios-device-screenshot-${device.id.slice(0, 8)}-${process.hrtime.bigint()}.png`
155115
155225
  );
155116
155226
  const ref = iosDeviceRunnerRef(device);
@@ -155133,7 +155243,7 @@ async function registerHostCapture(ctx, params, hostPath, label) {
155133
155243
  }
155134
155244
  async function tvScreenshot(udid, scale, signal) {
155135
155245
  const file2 = path37.join(
155136
- os16.tmpdir(),
155246
+ os17.tmpdir(),
155137
155247
  `argent-tv-screenshot-${udid.slice(0, 8)}-${process.hrtime.bigint()}.png`
155138
155248
  );
155139
155249
  await execFileAsync33("xcrun", await simctlArgsForUdid(udid, ["io", udid, "screenshot", file2]), {
@@ -155253,7 +155363,7 @@ Fails if the capture backend (simulator-server, emulator, Chromium CDP<flag:harm
155253
155363
  if (device.platform === "macos") {
155254
155364
  const app = await resolveMacosApp(registry2, device, "screenshot");
155255
155365
  const file2 = path37.join(
155256
- os16.tmpdir(),
155366
+ os17.tmpdir(),
155257
155367
  `argent-macos-screenshot-${process.hrtime.bigint()}.png`
155258
155368
  );
155259
155369
  const png = await macosScreenshotPng(app, { scale: params.scale });
@@ -171707,7 +171817,7 @@ init_capability();
171707
171817
  init_src();
171708
171818
 
171709
171819
  // ../tool-server/src/tools/screen-recording/capture.ts
171710
- var os18 = __toESM(require("os"));
171820
+ var os19 = __toESM(require("os"));
171711
171821
  var path46 = __toESM(require("path"));
171712
171822
  var import_fs18 = require("fs");
171713
171823
  var import_child_process9 = require("child_process");
@@ -172137,7 +172247,7 @@ async function startCaptureLocked(api, params) {
172137
172247
  );
172138
172248
  }
172139
172249
  const outputFile = path46.join(
172140
- os18.tmpdir(),
172250
+ os19.tmpdir(),
172141
172251
  `argent-screen-recording-${api.deviceId.replace(/[^A-Za-z0-9._-]/g, "-")}-${Date.now()}.mp4`
172142
172252
  );
172143
172253
  const stream = await openMjpegStream(params.streamUrl, STREAM_CONNECT_TIMEOUT_MS);
@@ -172405,7 +172515,7 @@ async function stopCapture(api) {
172405
172515
  }
172406
172516
 
172407
172517
  // ../tool-server/src/tools/screen-recording/capture-remote.ts
172408
- var os19 = __toESM(require("os"));
172518
+ var os20 = __toESM(require("os"));
172409
172519
  var path47 = __toESM(require("path"));
172410
172520
  var import_fs19 = require("fs");
172411
172521
  var import_child_process10 = require("child_process");
@@ -172418,7 +172528,7 @@ var execFileAsync38 = (0, import_util16.promisify)(import_child_process10.execFi
172418
172528
  var TRIM_FILTERS = `fps=${OUTPUT_FPS},mpdecimate=hi=1:lo=1:frac=1,setpts=N/${OUTPUT_FPS}/TB,tpad=stop_mode=clone:stop_duration=1`;
172419
172529
  function outputPath(deviceId) {
172420
172530
  return path47.join(
172421
- os19.tmpdir(),
172531
+ os20.tmpdir(),
172422
172532
  `argent-screen-recording-${deviceId.replace(/[^A-Za-z0-9._-]/g, "-")}-${Date.now()}.mp4`
172423
172533
  );
172424
172534
  }
@@ -178795,7 +178905,7 @@ function supportsFlowTree(platform) {
178795
178905
 
178796
178906
  // ../tool-server/src/tools/flows/flow-pixels.ts
178797
178907
  var fs65 = __toESM(require("node:fs/promises"));
178798
- var os20 = __toESM(require("node:os"));
178908
+ var os21 = __toESM(require("node:os"));
178799
178909
  var path50 = __toESM(require("node:path"));
178800
178910
  var import_pngjs5 = __toESM(require_png());
178801
178911
  init_adb();
@@ -178884,7 +178994,7 @@ async function captureIosDeviceFile(env, budgetMs) {
178884
178994
  const runner = await env.registry.resolveService(ref.urn, ref.options);
178885
178995
  const png = await captureRunnerScreenshotPng(runner, budgetMs);
178886
178996
  const file2 = path50.join(
178887
- os20.tmpdir(),
178997
+ os21.tmpdir(),
178888
178998
  `argent-ios-device-settle-${env.device.id.slice(0, 8)}-${process.hrtime.bigint()}.png`
178889
178999
  );
178890
179000
  await fs65.writeFile(file2, png);
@@ -181405,7 +181515,7 @@ init_src2();
181405
181515
  // ../tool-server/src/tools/flows/script/flow-script-executor.ts
181406
181516
  var import_node_child_process48 = require("node:child_process");
181407
181517
  var fs68 = __toESM(require("node:fs"));
181408
- var os21 = __toESM(require("node:os"));
181518
+ var os22 = __toESM(require("node:os"));
181409
181519
  var path54 = __toESM(require("node:path"));
181410
181520
  var import_node_string_decoder = require("node:string_decoder");
181411
181521
  var import_node_url3 = require("node:url");
@@ -182272,7 +182382,7 @@ function clampTimeout(requested, maxTimeoutMs, notes) {
182272
182382
  return maxTimeoutMs;
182273
182383
  }
182274
182384
  function defaultConcurrency() {
182275
- const cpus2 = os21.cpus()?.length || 1;
182385
+ const cpus2 = os22.cpus()?.length || 1;
182276
182386
  return Math.max(2, Math.min(8, cpus2 - 2));
182277
182387
  }
182278
182388
  var MAX_TIMER_MS = 2147483647;
@@ -183072,7 +183182,7 @@ init_capability();
183072
183182
  // ../tool-server/src/tools/flows/flow-visual.ts
183073
183183
  var import_node_crypto16 = require("node:crypto");
183074
183184
  var fs72 = __toESM(require("node:fs/promises"));
183075
- var os22 = __toESM(require("node:os"));
183185
+ var os23 = __toESM(require("node:os"));
183076
183186
  var path57 = __toESM(require("node:path"));
183077
183187
  var import_pngjs7 = __toESM(require_png());
183078
183188
  init_src2();
@@ -185272,7 +185382,7 @@ async function runSnapshot(env, opts) {
185272
185382
  let keepBaselineCopy = false;
185273
185383
  const hostBaseline = async (bytes) => {
185274
185384
  if (opts.clientFlowPath === void 0) return baselinePath;
185275
- baselineCopyDir = await fs72.mkdtemp(path57.join(os22.tmpdir(), "argent-e2e-baseline-"));
185385
+ baselineCopyDir = await fs72.mkdtemp(path57.join(os23.tmpdir(), "argent-e2e-baseline-"));
185276
185386
  const copy = path57.join(baselineCopyDir, key2);
185277
185387
  await fs72.writeFile(copy, bytes);
185278
185388
  return copy;
@@ -185283,7 +185393,7 @@ async function runSnapshot(env, opts) {
185283
185393
  };
185284
185394
  try {
185285
185395
  if (cropFrame !== void 0) {
185286
- cropDir = await fs72.mkdtemp(path57.join(os22.tmpdir(), "argent-e2e-crop-"));
185396
+ cropDir = await fs72.mkdtemp(path57.join(os23.tmpdir(), "argent-e2e-crop-"));
185287
185397
  const croppedPath = path57.join(cropDir, key2);
185288
185398
  const cropped = await cropPngFile(shot.image.hostPath, croppedPath, cropFrame);
185289
185399
  if (cropped === null) {
@@ -185344,7 +185454,7 @@ async function runSnapshot(env, opts) {
185344
185454
  };
185345
185455
  }
185346
185456
  const localBaseline = await hostBaseline(stored);
185347
- const outputDir = await fs72.mkdtemp(path57.join(os22.tmpdir(), "argent-e2e-diff-"));
185457
+ const outputDir = await fs72.mkdtemp(path57.join(os23.tmpdir(), "argent-e2e-diff-"));
185348
185458
  let keepInOutputDir;
185349
185459
  try {
185350
185460
  const result = await diffPngFiles({
@@ -188613,7 +188723,7 @@ Returns { value } for one key, { entries, count } for all keys, and { set } / {
188613
188723
 
188614
188724
  // ../tool-server/src/tools/file-panel/index.ts
188615
188725
  var fs77 = __toESM(require("node:fs/promises"));
188616
- var os24 = __toESM(require("node:os"));
188726
+ var os25 = __toESM(require("node:os"));
188617
188727
  var path61 = __toESM(require("node:path"));
188618
188728
  init_zod();
188619
188729
  init_capability();
@@ -188635,7 +188745,7 @@ function requestedPaths(params, action) {
188635
188745
  throw invalid(`file-panel ${action} needs path (or paths).`, "file_panel_paths");
188636
188746
  }
188637
188747
  return raw.map((p) => {
188638
- const expanded = p === "~" || p.startsWith("~/") ? path61.join(os24.homedir(), p.slice(1)) : p;
188748
+ const expanded = p === "~" || p.startsWith("~/") ? path61.join(os25.homedir(), p.slice(1)) : p;
188639
188749
  if (!path61.isAbsolute(expanded)) {
188640
188750
  throw invalid(
188641
188751
  `file-panel needs an absolute path, got "${p}". The app resolves no relative path.`,
@@ -189121,7 +189231,7 @@ function probeArgentToolServer(host, port, timeoutMs = 500) {
189121
189231
  // ../tool-server/src/utils/preview-window.ts
189122
189232
  var import_node_child_process52 = require("node:child_process");
189123
189233
  var fs78 = __toESM(require("node:fs"));
189124
- var os25 = __toESM(require("node:os"));
189234
+ var os26 = __toESM(require("node:os"));
189125
189235
  var path62 = __toESM(require("node:path"));
189126
189236
  function ensureLensAppBundle(electronBin) {
189127
189237
  if (process.platform !== "darwin") return null;
@@ -189130,7 +189240,7 @@ function ensureLensAppBundle(electronBin) {
189130
189240
  if (!realApp.endsWith(".app")) return null;
189131
189241
  const realContents = path62.join(realApp, "Contents");
189132
189242
  const wrapperContents = path62.join(
189133
- os25.tmpdir(),
189243
+ os26.tmpdir(),
189134
189244
  "argent-lens-app",
189135
189245
  "Argent Lens.app",
189136
189246
  "Contents"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swmansion/argent",
3
- "version": "0.34.1-next.12",
3
+ "version": "0.34.1-next.14",
4
4
  "mcpName": "io.github.software-mansion/argent",
5
5
  "description": "MCP server for iOS Simulator, Android Emulator, Chromium app and Mac app control",
6
6
  "license": "Apache-2.0",