peachsim 0.1.709 → 0.1.711

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.
Files changed (87) hide show
  1. package/cli/commands/control.ts +55 -1
  2. package/cli/commands/serve.ts +30 -0
  3. package/cli/current-sim.ts +15 -1
  4. package/cli/dev-build-freshness.ts +205 -0
  5. package/cli/drivers/playwright-sim-host.ts +14 -1
  6. package/cli/drivers/playwright.ts +36 -3
  7. package/cli/main.ts +8 -0
  8. package/cli/parent-pid.ts +91 -15
  9. package/cli/ws-bridge.ts +5 -0
  10. package/detox/index.ts +20 -7
  11. package/dist-lib/agent-daemon-client.cjs +1 -1
  12. package/dist-lib/agent-events.cjs +1 -1
  13. package/dist-lib/agent-identity.cjs +1 -1
  14. package/dist-lib/agent-sessions.cjs +1 -1
  15. package/dist-lib/attached-projects.cjs +1 -1
  16. package/dist-lib/auth/shared-session.cjs +1 -1
  17. package/dist-lib/backend-origin.cjs +1 -1
  18. package/dist-lib/beta.cjs +1 -1
  19. package/dist-lib/beta.mjs +1 -1
  20. package/dist-lib/bridge-constants.cjs +1 -1
  21. package/dist-lib/bridge-contract-input.cjs +1 -1
  22. package/dist-lib/bridge-contract-input.mjs +1 -1
  23. package/dist-lib/bridge-contract.cjs +1 -1
  24. package/dist-lib/bridge-contract.mjs +1 -1
  25. package/dist-lib/capture-contract.cjs +1 -1
  26. package/dist-lib/capture-contract.mjs +1 -1
  27. package/dist-lib/cli-constants.cjs +1 -1
  28. package/dist-lib/cloud-contract.cjs +1 -1
  29. package/dist-lib/cloud-contract.mjs +1 -1
  30. package/dist-lib/cloud-test-args.cjs +1 -1
  31. package/dist-lib/cloud-test-args.mjs +1 -1
  32. package/dist-lib/cloud.cjs +1 -1
  33. package/dist-lib/cloud.mjs +1 -1
  34. package/dist-lib/config.cjs +1 -1
  35. package/dist-lib/detox/index.cjs +89 -11
  36. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  37. package/dist-lib/home-paths.cjs +1 -1
  38. package/dist-lib/host/bridge-host.cjs +172 -30
  39. package/dist-lib/host/fetch-proxy-handler.cjs +45 -21
  40. package/dist-lib/host/fetch-proxy-overrides.cjs +2 -2
  41. package/dist-lib/host/fetch-proxy-overrides.mjs +2 -2
  42. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  43. package/dist-lib/host/websocket-proxy.cjs +1 -1
  44. package/dist-lib/index.cjs +78 -5
  45. package/dist-lib/jump-to-source-babel.cjs +1 -1
  46. package/dist-lib/jump-to-source-native.cjs +1 -1
  47. package/dist-lib/kotlin-host.cjs +1 -1
  48. package/dist-lib/menu.cjs +1 -1
  49. package/dist-lib/menu.mjs +1 -1
  50. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  51. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  52. package/dist-lib/metro-production-bundle.cjs +1 -1
  53. package/dist-lib/metro-production-bundle.mjs +1 -1
  54. package/dist-lib/metro.cjs +1 -1
  55. package/dist-lib/native-app-identity.cjs +1 -1
  56. package/dist-lib/native-app-identity.mjs +1 -1
  57. package/dist-lib/native-firebase-metadata.cjs +1 -1
  58. package/dist-lib/native-firebase-metadata.mjs +1 -1
  59. package/dist-lib/plist.cjs +1 -1
  60. package/dist-lib/plist.mjs +1 -1
  61. package/dist-lib/profiles.cjs +1 -1
  62. package/dist-lib/public-brand.cjs +1 -1
  63. package/dist-lib/react-native-host-modules.cjs +1 -1
  64. package/dist-lib/react-native-host-modules.mjs +1 -1
  65. package/dist-lib/render-mode.cjs +1 -1
  66. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  67. package/dist-lib/sdk.cjs +1 -1
  68. package/dist-lib/sdk.mjs +1 -1
  69. package/dist-lib/skills.cjs +331 -51
  70. package/dist-lib/swift-compile.cjs +8 -2
  71. package/dist-lib/swift-compile.mjs +8 -2
  72. package/dist-lib/swift-package.cjs +1 -1
  73. package/dist-lib/swift-package.mjs +1 -1
  74. package/dist-lib/swift-submit.cjs +2 -2
  75. package/dist-lib/swift-submit.mjs +2 -2
  76. package/dist-lib/swift-toolchain.cjs +1 -1
  77. package/dist-lib/swift.cjs +1 -1
  78. package/dist-lib/vite-swift.cjs +9 -3
  79. package/dist-lib/vite.cjs +1 -1
  80. package/package.json +2 -1
  81. package/src/host/bridge-host.ts +65 -0
  82. package/src/host/fetch-proxy-handler.ts +52 -23
  83. package/src/host/fetch-proxy-overrides.ts +5 -1
  84. package/src/host/fetch-proxy-transport.ts +82 -0
  85. package/src/runtime-assets.ts +1 -1
  86. package/src/swift-compile.ts +8 -2
  87. package/src/swift-submit.ts +2 -1
@@ -1,4 +1,4 @@
1
- /*! rnx v0.1.709 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! rnx v0.1.711 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
3
3
  "use strict";
4
4
  var __create = Object.create;
@@ -4228,7 +4228,7 @@ function listMetroAssetDest(assetsPath) {
4228
4228
  return { directory, files, truncated };
4229
4229
  }
4230
4230
  function metroDescriptorHash(scaleBytes) {
4231
- const hasher = (0, import_node_crypto10.createHash)("md5");
4231
+ const hasher = (0, import_node_crypto11.createHash)("md5");
4232
4232
  for (const bytes of scaleBytes) hasher.update(bytes);
4233
4233
  return hasher.digest("hex");
4234
4234
  }
@@ -4257,7 +4257,7 @@ function distinctByContent(directory, options) {
4257
4257
  } catch {
4258
4258
  continue;
4259
4259
  }
4260
- const digest = (0, import_node_crypto10.createHash)("md5").update(bytes).digest("hex");
4260
+ const digest = (0, import_node_crypto11.createHash)("md5").update(bytes).digest("hex");
4261
4261
  if (!byContent.has(digest)) byContent.set(digest, relative2);
4262
4262
  }
4263
4263
  return [...byContent.values()];
@@ -4291,7 +4291,7 @@ function placeMetroDescriptor(listing, descriptor) {
4291
4291
  continue;
4292
4292
  }
4293
4293
  const identical = fileHashes ? bytes.every((file, index) => {
4294
- const digest = (0, import_node_crypto10.createHash)("md5").update(file).digest("hex");
4294
+ const digest = (0, import_node_crypto11.createHash)("md5").update(file).digest("hex");
4295
4295
  return descriptor.scales.some(
4296
4296
  (scale, declared) => scale === scales[index] && fileHashes[declared] === digest
4297
4297
  );
@@ -4526,7 +4526,7 @@ async function produceArtifact(bundlePath, maxBytes, command, assetPolicy) {
4526
4526
  }
4527
4527
  return {
4528
4528
  bytes,
4529
- sha256: (0, import_node_crypto10.createHash)("sha256").update(bytes).digest("hex"),
4529
+ sha256: (0, import_node_crypto11.createHash)("sha256").update(bytes).digest("hex"),
4530
4530
  receipt: artifact.receipt,
4531
4531
  assetsDirectory: prepared.dest?.directory ?? null,
4532
4532
  warnings
@@ -4631,11 +4631,11 @@ async function createCloudBox(options) {
4631
4631
  warnings: artifact.warnings
4632
4632
  };
4633
4633
  }
4634
- var import_node_crypto10, import_node_fs23, import_node_path23, DEFAULT_RNX_CLOUD_ORIGIN, MAX_RNX_CLOUD_BUNDLE_BYTES, REMOTE_COMMAND, MAX_ASSET_DEST_FILES, ACCOUNT_CHOICE_REFUSALS, PROJECT_ONLY_DIRECTORIES, MAX_PLACEMENT_COMBINATIONS;
4634
+ var import_node_crypto11, import_node_fs23, import_node_path23, DEFAULT_RNX_CLOUD_ORIGIN, MAX_RNX_CLOUD_BUNDLE_BYTES, REMOTE_COMMAND, MAX_ASSET_DEST_FILES, ACCOUNT_CHOICE_REFUSALS, PROJECT_ONLY_DIRECTORIES, MAX_PLACEMENT_COMBINATIONS;
4635
4635
  var init_cloud_client = __esm({
4636
4636
  "cli/cloud-client.ts"() {
4637
4637
  "use strict";
4638
- import_node_crypto10 = require("node:crypto");
4638
+ import_node_crypto11 = require("node:crypto");
4639
4639
  import_node_fs23 = require("node:fs");
4640
4640
  import_node_path23 = require("node:path");
4641
4641
  init_metroAssetArtifact();
@@ -6972,8 +6972,14 @@ function writeSwiftProject(layout, input, moduleRoot) {
6972
6972
  }
6973
6973
  ] : compileTargets(input);
6974
6974
  const files = /* @__PURE__ */ new Map();
6975
+ const modulePlan = (0, import_node_crypto3.createHash)("sha256").update(
6976
+ swiftModuleInputFiles(moduleRoot).join("\n")
6977
+ );
6978
+ if (!distribution) {
6979
+ modulePlan.update((0, import_node_fs7.readFileSync)(import_node_path7.default.join(moduleRoot, "Package.swift")));
6980
+ }
6975
6981
  const moduleFiles = `
6976
- // sootsim-swift files ${(0, import_node_crypto3.createHash)("sha256").update(swiftModuleInputFiles(moduleRoot).join("\n")).digest("hex").slice(0, 16)}
6982
+ // sootsim-swift files ${modulePlan.digest("hex").slice(0, 16)}
6977
6983
  `;
6978
6984
  if (targets.length === 0) {
6979
6985
  for (const [file, contents] of Object.entries(input.files)) {
@@ -8056,7 +8062,7 @@ var MAX_SWIFT_COMPILE_RESOURCE_TOTAL_BYTES = 8 * 1024 * 1024;
8056
8062
  var MAX_SWIFT_COMPILE_IMAGES = 128;
8057
8063
  var MAX_SWIFT_COMPILE_IMAGE_BYTES = 4 * 1024 * 1024;
8058
8064
  var MAX_SWIFT_COMPILE_IMAGE_TOTAL_BYTES = 16 * 1024 * 1024;
8059
- var SWIFT_HOST_ABI = 16;
8065
+ var SWIFT_HOST_ABI = 17;
8060
8066
  var POLL_INTERVAL_MS = 1500;
8061
8067
  function httpSwiftCompileSubmit(context) {
8062
8068
  const { assetReadToken, authorization, endpoint } = context;
@@ -10506,6 +10512,7 @@ function mapFrameworkToProjectFramework(fw) {
10506
10512
  // src/host/fetch-proxy-handler.ts
10507
10513
  var import_http2 = __toESM(require("http"), 1);
10508
10514
  var import_https = __toESM(require("https"), 1);
10515
+ var import_node_http2 = require("node:http2");
10509
10516
  var import_promises4 = require("stream/promises");
10510
10517
  init_backend_origin();
10511
10518
 
@@ -10584,7 +10591,7 @@ function buildFetchProxyUpstreamHeaders(requestHeaders, targetUrl) {
10584
10591
  for (const [rawKey, value] of requestHeaders) {
10585
10592
  const key = rawKey.toLowerCase();
10586
10593
  if (key === FETCH_PROXY_NATIVE_USER_AGENT_HEADER) nativeUserAgent = value;
10587
- if (STRIP_FETCH_PROXY_REQUEST_HEADERS.has(key) || key.startsWith("x-forwarded-")) {
10594
+ if (key.startsWith(":") || STRIP_FETCH_PROXY_REQUEST_HEADERS.has(key) || key.startsWith("x-forwarded-")) {
10588
10595
  continue;
10589
10596
  }
10590
10597
  headers[key] = value;
@@ -10613,10 +10620,7 @@ function fetchProxyAgentFor(targetUrl) {
10613
10620
  return targetUrl.protocol === "https:" ? fetchProxyHttpsAgent : fetchProxyHttpAgent;
10614
10621
  }
10615
10622
  var FETCH_PROXY_CORS_HEADERS = {
10616
- "access-control-allow-origin": "*",
10617
- "access-control-allow-methods": "GET,POST,PUT,DELETE,PATCH,OPTIONS",
10618
- "access-control-allow-headers": "*",
10619
- "access-control-expose-headers": "*",
10623
+ "access-control-allow-methods": "GET,HEAD,POST,PUT,DELETE,PATCH,OPTIONS",
10620
10624
  "access-control-max-age": "3600"
10621
10625
  };
10622
10626
  var APP_API_HEADER_REWRITES = /* @__PURE__ */ new Set([
@@ -10631,10 +10635,30 @@ function loopbackTlsOptions(targetUrl) {
10631
10635
  if (targetUrl.protocol !== "https:") return {};
10632
10636
  return isLoopbackHost(targetUrl.hostname) ? { rejectUnauthorized: false } : {};
10633
10637
  }
10634
- function applyFetchProxyCors(res) {
10638
+ function applyFetchProxyCors(req, res) {
10635
10639
  for (const [key, value] of Object.entries(FETCH_PROXY_CORS_HEADERS)) {
10636
10640
  res.setHeader(key, value);
10637
10641
  }
10642
+ res.setHeader("access-control-allow-origin", req.headers.origin ?? "*");
10643
+ res.setHeader("access-control-allow-credentials", "true");
10644
+ res.setHeader(
10645
+ "access-control-allow-headers",
10646
+ req.headers["access-control-request-headers"] ?? "*"
10647
+ );
10648
+ res.setHeader(
10649
+ "access-control-expose-headers",
10650
+ [
10651
+ ...Object.keys(res.getHeaders()).filter(
10652
+ (name2) => !name2.startsWith("access-control-")
10653
+ ),
10654
+ "x-sootsim-set-cookie"
10655
+ ].join(", ")
10656
+ );
10657
+ const vary = res.getHeader("vary");
10658
+ res.setHeader(
10659
+ "vary",
10660
+ vary ? `${Array.isArray(vary) ? vary.join(", ") : vary}, Origin` : "Origin"
10661
+ );
10638
10662
  }
10639
10663
  function buildFetchProxyHeaders(reqHeaders, targetUrl) {
10640
10664
  return buildFetchProxyUpstreamHeaders(nodeRequestHeaderEntries(reqHeaders), targetUrl);
@@ -10656,6 +10680,9 @@ function buildAppApiProxyHeaders(reqHeaders, targetUrl) {
10656
10680
  function isFetchProxyRequestUrl(rawUrl) {
10657
10681
  return rawUrl?.startsWith("/__fetch-proxy?") || rawUrl?.startsWith("/__proxy?") || false;
10658
10682
  }
10683
+ function isBundleProxyRequestUrl(rawUrl) {
10684
+ return rawUrl?.startsWith("/__bundle-proxy?") ?? false;
10685
+ }
10659
10686
  function isAppApiRequestUrl(rawUrl) {
10660
10687
  if (!rawUrl) return false;
10661
10688
  if (rawUrl.startsWith("/__app-api?")) return true;
@@ -10664,16 +10691,17 @@ function isAppApiRequestUrl(rawUrl) {
10664
10691
  }
10665
10692
  async function handleFetchProxyRequest(req, res) {
10666
10693
  if (req.method === "OPTIONS") {
10667
- applyFetchProxyCors(res);
10668
- res.writeHead(204);
10694
+ applyFetchProxyCors(req, res);
10695
+ res.statusCode = 204;
10669
10696
  res.end();
10670
10697
  return;
10671
10698
  }
10672
10699
  const params = new URLSearchParams((req.url || "").split("?")[1] || "");
10673
10700
  const targetUrl = params.get("url");
10674
10701
  if (!targetUrl) {
10675
- applyFetchProxyCors(res);
10676
- res.writeHead(400, { "Content-Type": "text/plain" });
10702
+ applyFetchProxyCors(req, res);
10703
+ res.statusCode = 400;
10704
+ res.setHeader("Content-Type", "text/plain");
10677
10705
  res.end("missing url param");
10678
10706
  return;
10679
10707
  }
@@ -10681,8 +10709,9 @@ async function handleFetchProxyRequest(req, res) {
10681
10709
  try {
10682
10710
  upstreamUrl = resolveFetchProxyTargetUrl(new URL(targetUrl));
10683
10711
  } catch {
10684
- applyFetchProxyCors(res);
10685
- res.writeHead(400, { "Content-Type": "text/plain" });
10712
+ applyFetchProxyCors(req, res);
10713
+ res.statusCode = 400;
10714
+ res.setHeader("Content-Type", "text/plain");
10686
10715
  res.end("invalid url param");
10687
10716
  return;
10688
10717
  }
@@ -10746,7 +10775,7 @@ async function handleFetchProxyRequest(req, res) {
10746
10775
  }
10747
10776
  res.setHeader(key, value);
10748
10777
  }
10749
- applyFetchProxyCors(res);
10778
+ applyFetchProxyCors(req, res);
10750
10779
  const setCookie = proxyRes.headers["set-cookie"] ?? [];
10751
10780
  if (setCookie.length > 0) {
10752
10781
  res.setHeader(
@@ -10783,15 +10812,17 @@ async function handleFetchProxyRequest(req, res) {
10783
10812
  }
10784
10813
  }
10785
10814
  }
10786
- req.socket.destroy();
10815
+ if (req instanceof import_node_http2.Http2ServerRequest) req.stream.destroy();
10816
+ else req.socket.destroy();
10787
10817
  }
10788
10818
  }
10789
10819
  async function handleBundleProxyRequest(req, res) {
10790
10820
  const params = new URLSearchParams((req.url || "").split("?")[1] || "");
10791
10821
  const target = params.get("url");
10792
10822
  if (!target) {
10793
- applyFetchProxyCors(res);
10794
- res.writeHead(400, { "Content-Type": "text/plain" });
10823
+ applyFetchProxyCors(req, res);
10824
+ res.statusCode = 400;
10825
+ res.setHeader("Content-Type", "text/plain");
10795
10826
  res.end("bundle-proxy: missing url query param");
10796
10827
  return;
10797
10828
  }
@@ -10799,14 +10830,16 @@ async function handleBundleProxyRequest(req, res) {
10799
10830
  try {
10800
10831
  targetUrl = new URL(target);
10801
10832
  } catch {
10802
- applyFetchProxyCors(res);
10803
- res.writeHead(400, { "Content-Type": "text/plain" });
10833
+ applyFetchProxyCors(req, res);
10834
+ res.statusCode = 400;
10835
+ res.setHeader("Content-Type", "text/plain");
10804
10836
  res.end("bundle-proxy: invalid url");
10805
10837
  return;
10806
10838
  }
10807
10839
  if (!isLoopbackHost(targetUrl.hostname)) {
10808
- applyFetchProxyCors(res);
10809
- res.writeHead(403, { "Content-Type": "text/plain" });
10840
+ applyFetchProxyCors(req, res);
10841
+ res.statusCode = 403;
10842
+ res.setHeader("Content-Type", "text/plain");
10810
10843
  res.end("bundle-proxy: only loopback targets allowed");
10811
10844
  return;
10812
10845
  }
@@ -10880,6 +10913,75 @@ function handleAppApiRequest(req, res) {
10880
10913
  return true;
10881
10914
  }
10882
10915
 
10916
+ // src/host/fetch-proxy-transport.ts
10917
+ var import_node_crypto10 = require("node:crypto");
10918
+ var import_node_http22 = require("node:http2");
10919
+ var import_x509 = require("@peculiar/x509");
10920
+ async function startFetchProxyTransport() {
10921
+ const algorithm = { name: "ECDSA", namedCurve: "P-256", hash: "SHA-256" };
10922
+ const keys = await crypto.subtle.generateKey(algorithm, true, ["sign", "verify"]);
10923
+ const certificate = await import_x509.X509CertificateGenerator.createSelfSigned(
10924
+ {
10925
+ serialNumber: (0, import_node_crypto10.randomBytes)(16).toString("hex"),
10926
+ name: "CN=localhost",
10927
+ notBefore: new Date(Date.now() - 6e4),
10928
+ notAfter: new Date(Date.now() + 365 * 24 * 60 * 6e4),
10929
+ signingAlgorithm: algorithm,
10930
+ keys,
10931
+ extensions: [
10932
+ new import_x509.SubjectAlternativeNameExtension([{ type: "ip", value: "127.0.0.1" }])
10933
+ ]
10934
+ },
10935
+ crypto
10936
+ );
10937
+ const privateKey = Buffer.from(await crypto.subtle.exportKey("pkcs8", keys.privateKey));
10938
+ const spki = (0, import_node_crypto10.createHash)("sha256").update(Buffer.from(await crypto.subtle.exportKey("spki", keys.publicKey))).digest("base64");
10939
+ const sessions = /* @__PURE__ */ new Set();
10940
+ const server = (0, import_node_http22.createSecureServer)(
10941
+ {
10942
+ cert: certificate.toString("pem"),
10943
+ key: `-----BEGIN PRIVATE KEY-----
10944
+ ${privateKey.toString("base64").match(/.{1,64}/g)?.join("\n")}
10945
+ -----END PRIVATE KEY-----
10946
+ `,
10947
+ settings: { maxConcurrentStreams: 256 }
10948
+ },
10949
+ (req, res) => {
10950
+ res.setHeader("Cross-Origin-Resource-Policy", "cross-origin");
10951
+ res.setHeader("Timing-Allow-Origin", "*");
10952
+ const handler = isBundleProxyRequestUrl(req.url) ? handleBundleProxyRequest : isFetchProxyRequestUrl(req.url) ? handleFetchProxyRequest : null;
10953
+ if (!handler) {
10954
+ res.writeHead(404);
10955
+ res.end();
10956
+ return;
10957
+ }
10958
+ void handler(req, res).catch(() => res.destroy());
10959
+ }
10960
+ );
10961
+ server.on("session", (session) => {
10962
+ sessions.add(session);
10963
+ session.once("close", () => sessions.delete(session));
10964
+ session.on("error", () => session.destroy());
10965
+ });
10966
+ await new Promise((resolve5, reject) => {
10967
+ server.once("error", reject);
10968
+ server.listen(0, "127.0.0.1", () => {
10969
+ server.off("error", reject);
10970
+ resolve5();
10971
+ });
10972
+ });
10973
+ const address = server.address();
10974
+ if (!address || typeof address === "string")
10975
+ throw new Error("fetch proxy has no address");
10976
+ return {
10977
+ descriptor: { origin: `https://127.0.0.1:${address.port}`, spki },
10978
+ async close() {
10979
+ for (const session of sessions) session.destroy();
10980
+ await new Promise((resolve5) => server.close(() => resolve5()));
10981
+ }
10982
+ };
10983
+ }
10984
+
10883
10985
  // src/host/open-url.ts
10884
10986
  var import_child_process2 = require("child_process");
10885
10987
  function buildOpenUrlCommand(url, options = {}) {
@@ -12029,6 +12131,16 @@ function handleWebSocketProxyUpgrade(req, socket, head, forwardOrigin = true) {
12029
12131
 
12030
12132
  // src/host/bridge-host.ts
12031
12133
  var SOOTSIM_CROSS_ORIGIN_EMBEDDER_POLICY = "require-corp";
12134
+ function isProcessGroupAlive(pgid) {
12135
+ if (!Number.isInteger(pgid) || pgid <= 1) return true;
12136
+ try {
12137
+ process.kill(-pgid, 0);
12138
+ return true;
12139
+ } catch (error) {
12140
+ const code = error && typeof error === "object" ? Reflect.get(error, "code") : null;
12141
+ return code !== "ESRCH";
12142
+ }
12143
+ }
12032
12144
  var WRITE_COMMAND_TYPES = /* @__PURE__ */ new Set([
12033
12145
  "tap",
12034
12146
  "keyboard",
@@ -12105,6 +12217,7 @@ var SootSimBridgeHost = class _SootSimBridgeHost {
12105
12217
  openUrlHandler;
12106
12218
  httpServer = null;
12107
12219
  wss = null;
12220
+ fetchProxyTransport = null;
12108
12221
  nextCommandId = 1;
12109
12222
  nextSimNumber = 161;
12110
12223
  sims = /* @__PURE__ */ new Map();
@@ -12115,6 +12228,7 @@ var SootSimBridgeHost = class _SootSimBridgeHost {
12115
12228
  cliLastCommandAt = /* @__PURE__ */ new Map();
12116
12229
  cliIdentityKeyBySocket = /* @__PURE__ */ new Map();
12117
12230
  cliLabelBySocket = /* @__PURE__ */ new Map();
12231
+ cliOwnerPgidBySocket = /* @__PURE__ */ new Map();
12118
12232
  restorableSims = /* @__PURE__ */ new Map();
12119
12233
  nextCliFallbackId = 1;
12120
12234
  cliIdleTimer = null;
@@ -12214,6 +12328,12 @@ var SootSimBridgeHost = class _SootSimBridgeHost {
12214
12328
  `
12215
12329
  );
12216
12330
  }
12331
+ try {
12332
+ this.fetchProxyTransport = await startFetchProxyTransport();
12333
+ } catch (error) {
12334
+ await this.close();
12335
+ throw error;
12336
+ }
12217
12337
  this.afterBind();
12218
12338
  return boundPort;
12219
12339
  } catch (err) {
@@ -12508,6 +12628,7 @@ var SootSimBridgeHost = class _SootSimBridgeHost {
12508
12628
  this.cliLastCommandAt.delete(ws);
12509
12629
  this.cliIdentityKeyBySocket.delete(ws);
12510
12630
  this.cliLabelBySocket.delete(ws);
12631
+ this.cliOwnerPgidBySocket.delete(ws);
12511
12632
  for (const [sentId2, entry] of this.cliBySentId) {
12512
12633
  if (entry.ws === ws) this.cliBySentId.delete(sentId2);
12513
12634
  }
@@ -12520,6 +12641,11 @@ var SootSimBridgeHost = class _SootSimBridgeHost {
12520
12641
  if (typeof msg.cliLabel === "string" && msg.cliLabel.trim()) {
12521
12642
  this.cliLabelBySocket.set(ws, msg.cliLabel.trim());
12522
12643
  }
12644
+ if (typeof msg.cliOwnerPgid === "number" && Number.isInteger(msg.cliOwnerPgid) && msg.cliOwnerPgid > 1) {
12645
+ this.cliOwnerPgidBySocket.set(ws, msg.cliOwnerPgid);
12646
+ } else {
12647
+ this.cliOwnerPgidBySocket.delete(ws);
12648
+ }
12523
12649
  if (ws.readyState === import_ws.WebSocket.OPEN) {
12524
12650
  ws.send(
12525
12651
  JSON.stringify({
@@ -12670,6 +12796,7 @@ var SootSimBridgeHost = class _SootSimBridgeHost {
12670
12796
  this.cliLastCommandAt.delete(ws);
12671
12797
  this.cliIdentityKeyBySocket.delete(ws);
12672
12798
  this.cliLabelBySocket.delete(ws);
12799
+ this.cliOwnerPgidBySocket.delete(ws);
12673
12800
  for (const [sentId, entry] of this.cliBySentId) {
12674
12801
  if (entry.ws === ws) this.cliBySentId.delete(sentId);
12675
12802
  }
@@ -13029,6 +13156,14 @@ var SootSimBridgeHost = class _SootSimBridgeHost {
13029
13156
  * non-upgrade routes that don't match serve index.html (SPA behavior) so
13030
13157
  * electron's webContents can navigate freely inside the runtime. */
13031
13158
  handleHttpRequest(req, res) {
13159
+ if (req.url === "/__peach/fetch-transport") {
13160
+ res.writeHead(200, {
13161
+ "Content-Type": "application/json",
13162
+ "Cache-Control": "no-store"
13163
+ });
13164
+ res.end(JSON.stringify(this.fetchProxyTransport?.descriptor));
13165
+ return;
13166
+ }
13032
13167
  res.setHeader("Cross-Origin-Opener-Policy", "same-origin");
13033
13168
  res.setHeader("Cross-Origin-Embedder-Policy", SOOTSIM_CROSS_ORIGIN_EMBEDDER_POLICY);
13034
13169
  res.setHeader("Cross-Origin-Resource-Policy", "cross-origin");
@@ -13591,6 +13726,8 @@ var SootSimBridgeHost = class _SootSimBridgeHost {
13591
13726
  } catch {
13592
13727
  }
13593
13728
  }
13729
+ await this.fetchProxyTransport?.close();
13730
+ this.fetchProxyTransport = null;
13594
13731
  this.effectivePort = 0;
13595
13732
  this.startedAt = 0;
13596
13733
  this.agentHost.close();
@@ -13655,6 +13792,10 @@ var SootSimBridgeHost = class _SootSimBridgeHost {
13655
13792
  sim.cliLease = void 0;
13656
13793
  return null;
13657
13794
  }
13795
+ if (lease.kind === "cli" && lease.ownerPgid !== void 0 && !isProcessGroupAlive(lease.ownerPgid)) {
13796
+ sim.cliLease = void 0;
13797
+ return null;
13798
+ }
13658
13799
  return lease;
13659
13800
  }
13660
13801
  tryAcquireLease(ws, sim, opts = {}) {
@@ -13697,7 +13838,8 @@ var SootSimBridgeHost = class _SootSimBridgeHost {
13697
13838
  kind: "cli",
13698
13839
  cliIdentityKey,
13699
13840
  cliLabel,
13700
- expiresAt: now + _SootSimBridgeHost.CLI_LEASE_TTL_MS
13841
+ expiresAt: now + _SootSimBridgeHost.CLI_LEASE_TTL_MS,
13842
+ ownerPgid: this.cliOwnerPgidBySocket.get(ws)
13701
13843
  };
13702
13844
  sim.cliLease = lease;
13703
13845
  return { granted: true, lease, bootedCount };
@@ -1,4 +1,4 @@
1
- /*! rnx v0.1.709 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! rnx v0.1.711 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
3
3
  "use strict";
4
4
  var __create = Object.create;
@@ -44,6 +44,7 @@ __export(fetch_proxy_handler_exports, {
44
44
  module.exports = __toCommonJS(fetch_proxy_handler_exports);
45
45
  var import_http = __toESM(require("http"), 1);
46
46
  var import_https = __toESM(require("https"), 1);
47
+ var import_node_http2 = require("node:http2");
47
48
  var import_promises = require("stream/promises");
48
49
 
49
50
  // src/backend-origin.ts
@@ -130,7 +131,7 @@ function buildFetchProxyUpstreamHeaders(requestHeaders, targetUrl) {
130
131
  for (const [rawKey, value] of requestHeaders) {
131
132
  const key = rawKey.toLowerCase();
132
133
  if (key === FETCH_PROXY_NATIVE_USER_AGENT_HEADER) nativeUserAgent = value;
133
- if (STRIP_FETCH_PROXY_REQUEST_HEADERS.has(key) || key.startsWith("x-forwarded-")) {
134
+ if (key.startsWith(":") || STRIP_FETCH_PROXY_REQUEST_HEADERS.has(key) || key.startsWith("x-forwarded-")) {
134
135
  continue;
135
136
  }
136
137
  headers[key] = value;
@@ -159,10 +160,7 @@ function fetchProxyAgentFor(targetUrl) {
159
160
  return targetUrl.protocol === "https:" ? fetchProxyHttpsAgent : fetchProxyHttpAgent;
160
161
  }
161
162
  var FETCH_PROXY_CORS_HEADERS = {
162
- "access-control-allow-origin": "*",
163
- "access-control-allow-methods": "GET,POST,PUT,DELETE,PATCH,OPTIONS",
164
- "access-control-allow-headers": "*",
165
- "access-control-expose-headers": "*",
163
+ "access-control-allow-methods": "GET,HEAD,POST,PUT,DELETE,PATCH,OPTIONS",
166
164
  "access-control-max-age": "3600"
167
165
  };
168
166
  var APP_API_HEADER_REWRITES = /* @__PURE__ */ new Set([
@@ -177,10 +175,30 @@ function loopbackTlsOptions(targetUrl) {
177
175
  if (targetUrl.protocol !== "https:") return {};
178
176
  return isLoopbackHost(targetUrl.hostname) ? { rejectUnauthorized: false } : {};
179
177
  }
180
- function applyFetchProxyCors(res) {
178
+ function applyFetchProxyCors(req, res) {
181
179
  for (const [key, value] of Object.entries(FETCH_PROXY_CORS_HEADERS)) {
182
180
  res.setHeader(key, value);
183
181
  }
182
+ res.setHeader("access-control-allow-origin", req.headers.origin ?? "*");
183
+ res.setHeader("access-control-allow-credentials", "true");
184
+ res.setHeader(
185
+ "access-control-allow-headers",
186
+ req.headers["access-control-request-headers"] ?? "*"
187
+ );
188
+ res.setHeader(
189
+ "access-control-expose-headers",
190
+ [
191
+ ...Object.keys(res.getHeaders()).filter(
192
+ (name) => !name.startsWith("access-control-")
193
+ ),
194
+ "x-sootsim-set-cookie"
195
+ ].join(", ")
196
+ );
197
+ const vary = res.getHeader("vary");
198
+ res.setHeader(
199
+ "vary",
200
+ vary ? `${Array.isArray(vary) ? vary.join(", ") : vary}, Origin` : "Origin"
201
+ );
184
202
  }
185
203
  function buildFetchProxyHeaders(reqHeaders, targetUrl) {
186
204
  return buildFetchProxyUpstreamHeaders(nodeRequestHeaderEntries(reqHeaders), targetUrl);
@@ -213,16 +231,17 @@ function isAppApiRequestUrl(rawUrl) {
213
231
  }
214
232
  async function handleFetchProxyRequest(req, res) {
215
233
  if (req.method === "OPTIONS") {
216
- applyFetchProxyCors(res);
217
- res.writeHead(204);
234
+ applyFetchProxyCors(req, res);
235
+ res.statusCode = 204;
218
236
  res.end();
219
237
  return;
220
238
  }
221
239
  const params = new URLSearchParams((req.url || "").split("?")[1] || "");
222
240
  const targetUrl = params.get("url");
223
241
  if (!targetUrl) {
224
- applyFetchProxyCors(res);
225
- res.writeHead(400, { "Content-Type": "text/plain" });
242
+ applyFetchProxyCors(req, res);
243
+ res.statusCode = 400;
244
+ res.setHeader("Content-Type", "text/plain");
226
245
  res.end("missing url param");
227
246
  return;
228
247
  }
@@ -230,8 +249,9 @@ async function handleFetchProxyRequest(req, res) {
230
249
  try {
231
250
  upstreamUrl = resolveFetchProxyTargetUrl(new URL(targetUrl));
232
251
  } catch {
233
- applyFetchProxyCors(res);
234
- res.writeHead(400, { "Content-Type": "text/plain" });
252
+ applyFetchProxyCors(req, res);
253
+ res.statusCode = 400;
254
+ res.setHeader("Content-Type", "text/plain");
235
255
  res.end("invalid url param");
236
256
  return;
237
257
  }
@@ -295,7 +315,7 @@ async function handleFetchProxyRequest(req, res) {
295
315
  }
296
316
  res.setHeader(key, value);
297
317
  }
298
- applyFetchProxyCors(res);
318
+ applyFetchProxyCors(req, res);
299
319
  const setCookie = proxyRes.headers["set-cookie"] ?? [];
300
320
  if (setCookie.length > 0) {
301
321
  res.setHeader(
@@ -332,15 +352,17 @@ async function handleFetchProxyRequest(req, res) {
332
352
  }
333
353
  }
334
354
  }
335
- req.socket.destroy();
355
+ if (req instanceof import_node_http2.Http2ServerRequest) req.stream.destroy();
356
+ else req.socket.destroy();
336
357
  }
337
358
  }
338
359
  async function handleBundleProxyRequest(req, res) {
339
360
  const params = new URLSearchParams((req.url || "").split("?")[1] || "");
340
361
  const target = params.get("url");
341
362
  if (!target) {
342
- applyFetchProxyCors(res);
343
- res.writeHead(400, { "Content-Type": "text/plain" });
363
+ applyFetchProxyCors(req, res);
364
+ res.statusCode = 400;
365
+ res.setHeader("Content-Type", "text/plain");
344
366
  res.end("bundle-proxy: missing url query param");
345
367
  return;
346
368
  }
@@ -348,14 +370,16 @@ async function handleBundleProxyRequest(req, res) {
348
370
  try {
349
371
  targetUrl = new URL(target);
350
372
  } catch {
351
- applyFetchProxyCors(res);
352
- res.writeHead(400, { "Content-Type": "text/plain" });
373
+ applyFetchProxyCors(req, res);
374
+ res.statusCode = 400;
375
+ res.setHeader("Content-Type", "text/plain");
353
376
  res.end("bundle-proxy: invalid url");
354
377
  return;
355
378
  }
356
379
  if (!isLoopbackHost(targetUrl.hostname)) {
357
- applyFetchProxyCors(res);
358
- res.writeHead(403, { "Content-Type": "text/plain" });
380
+ applyFetchProxyCors(req, res);
381
+ res.statusCode = 403;
382
+ res.setHeader("Content-Type", "text/plain");
359
383
  res.end("bundle-proxy: only loopback targets allowed");
360
384
  return;
361
385
  }
@@ -1,4 +1,4 @@
1
- /*! rnx v0.1.709 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! rnx v0.1.711 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
3
3
  "use strict";
4
4
  var __defProp = Object.defineProperty;
@@ -103,7 +103,7 @@ function buildFetchProxyUpstreamHeaders(requestHeaders, targetUrl) {
103
103
  for (const [rawKey, value] of requestHeaders) {
104
104
  const key = rawKey.toLowerCase();
105
105
  if (key === FETCH_PROXY_NATIVE_USER_AGENT_HEADER) nativeUserAgent = value;
106
- if (STRIP_FETCH_PROXY_REQUEST_HEADERS.has(key) || key.startsWith("x-forwarded-")) {
106
+ if (key.startsWith(":") || STRIP_FETCH_PROXY_REQUEST_HEADERS.has(key) || key.startsWith("x-forwarded-")) {
107
107
  continue;
108
108
  }
109
109
  headers[key] = value;
@@ -1,4 +1,4 @@
1
- /*! rnx v0.1.709 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! rnx v0.1.711 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
 
3
3
  // src/host/fetch-proxy-overrides.ts
4
4
  var FETCH_PROXY_NATIVE_USER_AGENT_HEADER = "x-sootsim-native-user-agent";
@@ -75,7 +75,7 @@ function buildFetchProxyUpstreamHeaders(requestHeaders, targetUrl) {
75
75
  for (const [rawKey, value] of requestHeaders) {
76
76
  const key = rawKey.toLowerCase();
77
77
  if (key === FETCH_PROXY_NATIVE_USER_AGENT_HEADER) nativeUserAgent = value;
78
- if (STRIP_FETCH_PROXY_REQUEST_HEADERS.has(key) || key.startsWith("x-forwarded-")) {
78
+ if (key.startsWith(":") || STRIP_FETCH_PROXY_REQUEST_HEADERS.has(key) || key.startsWith("x-forwarded-")) {
79
79
  continue;
80
80
  }
81
81
  headers[key] = value;
@@ -1,4 +1,4 @@
1
- /*! rnx v0.1.709 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! rnx v0.1.711 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
3
3
  "use strict";
4
4
  var __create = Object.create;
@@ -1,4 +1,4 @@
1
- /*! rnx v0.1.709 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! rnx v0.1.711 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
3
3
  "use strict";
4
4
  var __defProp = Object.defineProperty;