@swmansion/argent 0.14.1-next.13 → 0.14.1-next.15

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.
@@ -118565,6 +118565,19 @@ var fs20 = __toESM(require("node:fs"));
118565
118565
  var net5 = __toESM(require("node:net"));
118566
118566
  var path18 = __toESM(require("node:path"));
118567
118567
  init_src();
118568
+
118569
+ // ../tool-server/src/utils/electron-env.ts
118570
+ function electronGuiChildEnv(overrides = {}) {
118571
+ const env = { ...process.env, ...overrides };
118572
+ for (const key of Object.keys(env)) {
118573
+ if (key.toLowerCase() === "electron_run_as_node") {
118574
+ delete env[key];
118575
+ }
118576
+ }
118577
+ return env;
118578
+ }
118579
+
118580
+ // ../tool-server/src/tools/devices/boot-electron.ts
118568
118581
  var DEFAULT_READY_TIMEOUT_MS = 3e4;
118569
118582
  async function pickFreePort() {
118570
118583
  return new Promise((resolve5, reject) => {
@@ -118688,7 +118701,12 @@ async function bootElectronApp(options) {
118688
118701
  child = (0, import_node_child_process15.spawn)(launcher.command, args, {
118689
118702
  detached: true,
118690
118703
  stdio: ["ignore", "pipe", "pipe"],
118691
- env: { ...process.env, ELECTRON_ENABLE_LOGGING: "1" }
118704
+ // Strip ELECTRON_RUN_AS_NODE (see electronGuiChildEnv): if the tool-server
118705
+ // inherited it from an Electron-based MCP host, the Electron binary would
118706
+ // run in Node mode with no CDP endpoint — so boot-device fails below (the
118707
+ // child exits early, or the readiness probe times out) instead of the app
118708
+ // coming up.
118709
+ env: electronGuiChildEnv({ ELECTRON_ENABLE_LOGGING: "1" })
118692
118710
  });
118693
118711
  } catch (err) {
118694
118712
  throw new FailureError(
@@ -129951,10 +129969,7 @@ function num(attrs, key) {
129951
129969
  function isInteractive2(attrs) {
129952
129970
  return isTrue(attrs, "focusable") || isTrue(attrs, "selectable") || isTrue(attrs, "clickable");
129953
129971
  }
129954
- function isMeaningful(node) {
129955
- return Boolean(node.attrs.role) || isInteractive2(node.attrs) || node.text.length > 0;
129956
- }
129957
- function labelOf2(node) {
129972
+ function ownText(node) {
129958
129973
  const parts = [];
129959
129974
  if (node.text) parts.push(node.text);
129960
129975
  for (const c of node.children) {
@@ -129962,6 +129977,9 @@ function labelOf2(node) {
129962
129977
  }
129963
129978
  return parts.join(" ").trim();
129964
129979
  }
129980
+ function isMeaningful(node, ownTextValue) {
129981
+ return Boolean(node.attrs.role) || isInteractive2(node.attrs) || ownTextValue.length > 0;
129982
+ }
129965
129983
  function normalizeFrame(attrs, screenW, screenH) {
129966
129984
  const x = num(attrs, "x") ?? 0;
129967
129985
  const y = num(attrs, "y") ?? 0;
@@ -129981,20 +129999,28 @@ function normalizeFrame(attrs, screenW, screenH) {
129981
129999
  function clamp(n, lo, hi) {
129982
130000
  return Math.max(lo, Math.min(n, hi));
129983
130001
  }
130002
+ function isPlainTextSpan(n) {
130003
+ return n.role === "view" && n.label !== void 0 && n.children.length === 0 && n.identifier === void 0 && !n.clickable && !n.focused && !n.selected;
130004
+ }
130005
+ function childrenReconstructLabel(children, label) {
130006
+ if (children.length === 0 || !children.every(isPlainTextSpan)) return false;
130007
+ return children.map((c) => c.label).join("") === label;
130008
+ }
129984
130009
  function convert(node, screenW, screenH) {
129985
130010
  const childNodes = [];
129986
130011
  for (const c of node.children) {
129987
130012
  if (c.tag === "text") continue;
129988
130013
  childNodes.push(...convert(c, screenW, screenH));
129989
130014
  }
129990
- if (!isMeaningful(node)) return childNodes;
130015
+ const label = ownText(node);
130016
+ if (!isMeaningful(node, label)) return childNodes;
129991
130017
  const attrs = node.attrs;
130018
+ const keptChildren = label && childrenReconstructLabel(childNodes, label) ? [] : childNodes;
129992
130019
  const out = {
129993
130020
  role: attrs.role || "view",
129994
130021
  frame: normalizeFrame(attrs, screenW, screenH),
129995
- children: childNodes
130022
+ children: keptChildren
129996
130023
  };
129997
- const label = labelOf2(node);
129998
130024
  if (label) out.label = label;
129999
130025
  if (attrs.test_id) out.identifier = attrs.test_id;
130000
130026
  if (isInteractive2(attrs)) out.clickable = true;
@@ -142244,7 +142270,11 @@ function createPreviewWindowManager(opts = {}) {
142244
142270
  const launchBin = wrapperBin ?? electronBin;
142245
142271
  const launchArgs = wrapperBin ? ["--no-sandbox", mainScript] : [mainScript];
142246
142272
  const next = (0, import_node_child_process27.spawn)(launchBin, launchArgs, {
142247
- env: { ...process.env, ARGENT_PREVIEW_URL: url2 },
142273
+ // Strip ELECTRON_RUN_AS_NODE so the child boots as a GUI Electron app, not
142274
+ // a bare Node runtime (see electronGuiChildEnv). An Electron-based MCP
142275
+ // host puts it in our env, and inheriting it makes main.cjs crash at
142276
+ // app.setName() with `app` undefined — the window never opens.
142277
+ env: electronGuiChildEnv({ ARGENT_PREVIEW_URL: url2 }),
142248
142278
  stdio: ["pipe", "ignore", "pipe"]
142249
142279
  });
142250
142280
  next.on("error", (err) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swmansion/argent",
3
- "version": "0.14.1-next.13",
3
+ "version": "0.14.1-next.15",
4
4
  "description": "MCP server for iOS Simulator and Android Emulator control",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {