peachsim 0.1.1653 → 0.1.1654

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 (110) hide show
  1. package/cli/app-stubs.ts +97 -14
  2. package/cli/bridge-diagnostics.ts +10 -7
  3. package/cli/cloud-client.ts +11 -2
  4. package/cli/commands/doctor.ts +20 -10
  5. package/cli/commands/inspect/core.ts +2 -1
  6. package/cli/commands/inspect/shared.ts +2 -0
  7. package/cli/commands/inspect.ts +11 -2
  8. package/cli/output-redaction.ts +22 -6
  9. package/cli/pause-aware-timeout.ts +24 -10
  10. package/cli/ws-bridge.ts +17 -1
  11. package/dist-lib/agent-daemon-client.cjs +1 -1
  12. package/dist-lib/agent-events.cjs +1 -1
  13. package/dist-lib/attached-projects.cjs +1 -1
  14. package/dist-lib/auth/shared-session.cjs +1 -1
  15. package/dist-lib/backend-origin.cjs +1 -1
  16. package/dist-lib/beta.cjs +1 -1
  17. package/dist-lib/beta.mjs +1 -1
  18. package/dist-lib/bridge-constants.cjs +1 -1
  19. package/dist-lib/bridge-contract-input.cjs +1 -1
  20. package/dist-lib/bridge-contract-input.mjs +1 -1
  21. package/dist-lib/bridge-contract.cjs +1 -1
  22. package/dist-lib/bridge-contract.mjs +1 -1
  23. package/dist-lib/bundle-channel.cjs +42 -50
  24. package/dist-lib/capture-contract.cjs +1 -1
  25. package/dist-lib/capture-contract.mjs +1 -1
  26. package/dist-lib/cloud-contract.cjs +1 -1
  27. package/dist-lib/cloud-contract.mjs +1 -1
  28. package/dist-lib/cloud-test-args.cjs +1 -1
  29. package/dist-lib/cloud-test-args.mjs +1 -1
  30. package/dist-lib/cloud.cjs +1 -1
  31. package/dist-lib/cloud.mjs +1 -1
  32. package/dist-lib/config.cjs +1 -1
  33. package/dist-lib/config.mjs +1 -1
  34. package/dist-lib/detox/index.cjs +47 -12
  35. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  36. package/dist-lib/expo-swift-bundle.cjs +41 -49
  37. package/dist-lib/expo-swift-metadata.cjs +1 -1
  38. package/dist-lib/expo-swift-metadata.mjs +1 -1
  39. package/dist-lib/home-paths.cjs +1 -1
  40. package/dist-lib/host/bridge-host.cjs +70 -52
  41. package/dist-lib/host/fetch-proxy-handler.cjs +176 -31
  42. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  43. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  44. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  45. package/dist-lib/host/websocket-proxy.cjs +1 -1
  46. package/dist-lib/index.cjs +633 -373
  47. package/dist-lib/jump-to-source-babel.cjs +1 -1
  48. package/dist-lib/jump-to-source-native.cjs +1 -1
  49. package/dist-lib/kotlin-host.cjs +1 -1
  50. package/dist-lib/menu.cjs +1 -1
  51. package/dist-lib/menu.mjs +1 -1
  52. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  53. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  54. package/dist-lib/metro-production-bundle.cjs +1 -1
  55. package/dist-lib/metro-production-bundle.mjs +1 -1
  56. package/dist-lib/metro.cjs +62 -14
  57. package/dist-lib/native-app-identity-project.cjs +1 -1
  58. package/dist-lib/native-app-identity-project.mjs +1 -1
  59. package/dist-lib/native-app-identity.cjs +1 -1
  60. package/dist-lib/native-app-identity.mjs +1 -1
  61. package/dist-lib/native-firebase-metadata.cjs +1 -1
  62. package/dist-lib/native-firebase-metadata.mjs +1 -1
  63. package/dist-lib/plist.cjs +1 -1
  64. package/dist-lib/plist.mjs +1 -1
  65. package/dist-lib/profiles.cjs +1 -1
  66. package/dist-lib/public-brand.cjs +1 -1
  67. package/dist-lib/public-origins-lib-esm.json +23 -23
  68. package/dist-lib/public-origins-lib.json +62 -54
  69. package/dist-lib/react-native-host-modules.cjs +1 -1
  70. package/dist-lib/react-native-host-modules.mjs +1 -1
  71. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  72. package/dist-lib/sdk.cjs +2 -2
  73. package/dist-lib/sdk.mjs +2 -2
  74. package/dist-lib/skills.cjs +284 -185
  75. package/dist-lib/swift-compile.cjs +23 -3
  76. package/dist-lib/swift-compile.mjs +22 -3
  77. package/dist-lib/swift-package.cjs +1 -1
  78. package/dist-lib/swift-package.mjs +1 -1
  79. package/dist-lib/swift-submit.cjs +1 -1
  80. package/dist-lib/swift-submit.mjs +1 -1
  81. package/dist-lib/swift-toolchain.cjs +1 -1
  82. package/dist-lib/swift.cjs +1 -1
  83. package/dist-lib/vite-swift.cjs +41 -49
  84. package/dist-lib/vite.cjs +385 -200
  85. package/dist-lib/worklet-executable.cjs +1 -1
  86. package/dist-lib/worklet-executable.mjs +1 -1
  87. package/dist-types/packages/peach-compat/src/stubs/native-seams/react-native-gesture-handler.d.ts +1 -0
  88. package/dist-types/packages/peach-compat/src/stubs/screen-transition-math.d.ts +10 -7
  89. package/dist-types/packages/peach-engine/src/capture/browser-composite.d.ts +10 -0
  90. package/dist-types/packages/peach-engine/src/cli-companion.d.ts +1 -0
  91. package/dist-types/packages/peach-engine/src/engine/node.d.ts +3 -1
  92. package/dist-types/packages/peach-engine/src/engine/scene-table.d.ts +1 -1
  93. package/dist-types/packages/peach-engine/src/engine/text-first-baseline.d.ts +23 -0
  94. package/dist-types/packages/peach-engine/src/engine/types.d.ts +1 -1
  95. package/dist-types/packages/peach-engine/src/engine/visible-frame.d.ts +1 -0
  96. package/dist-types/packages/peach-engine/src/observability/types.d.ts +1 -0
  97. package/dist-types/packages/peach-engine/src/render-worker/compositor-protocol.d.ts +38 -0
  98. package/dist-types/packages/peach-engine/src/rolldown-bundle-inventory.d.ts +5 -0
  99. package/package.json +5 -1
  100. package/runtime-companion.json +1 -1
  101. package/src/bridge-contract.ts +2 -0
  102. package/src/bundleGlobalFooter.ts +9 -0
  103. package/src/host/fetch-proxy-handler.ts +37 -0
  104. package/src/sfSymbolMetricsContract.ts +268 -0
  105. package/src/swift-compile.ts +16 -1
  106. package/src/swift-distribution.lock.json +20 -46
  107. package/src/swift-objc-metadata.ts +21 -7
  108. package/src/swift-objc-sdk.ts +13 -0
  109. package/src/vite-plugin-one.ts +161 -16
  110. package/src/host/lease-owner.test.ts +0 -49
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.1653 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1654 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; } catch {}
3
3
  "use strict";
4
4
  var __create = Object.create;
@@ -81,9 +81,19 @@ ${prefix2}${json}${suffix}`;
81
81
  const identity = findBundleFooter(source, "globalThis.__sootsimModulePaths=");
82
82
  return identity < 0 ? source + footer : source.slice(0, identity) + footer + source.slice(identity);
83
83
  }
84
+ var ROLLDOWN_INVENTORY_HEADER;
84
85
  var init_bundleGlobalFooter = __esm({
85
86
  "src/bundleGlobalFooter.ts"() {
86
87
  "use strict";
88
+ ROLLDOWN_INVENTORY_HEADER = "X-Peach-Rolldown-Inventory";
89
+ }
90
+ });
91
+
92
+ // runtime-companion.json
93
+ var runtime_companion_default;
94
+ var init_runtime_companion = __esm({
95
+ "runtime-companion.json"() {
96
+ runtime_companion_default = { abi: 1, sha256: "a1b49c57129dd06888a9cdfbb05051be3626e8233980236705a3efd52b651623", file: "node/cli-a1b49c57129dd06888a9cdfbb05051be3626e8233980236705a3efd52b651623.cjs" };
87
97
  }
88
98
  });
89
99
 
@@ -446,10 +456,53 @@ var init_runtime_assets = __esm({
446
456
  });
447
457
 
448
458
  // src/cli-runtime.ts
459
+ function cliCompanionPath() {
460
+ return `node/cli-${runtime_companion_default.sha256}.cjs`;
461
+ }
462
+ function verifyCliCompanion(root) {
463
+ const file = (0, import_node_path2.join)(root, cliCompanionPath());
464
+ let bytes;
465
+ try {
466
+ bytes = (0, import_node_fs2.readFileSync)(file);
467
+ } catch (cause) {
468
+ throw new Error(
469
+ "Peach runtime is missing the companion required by this CLI; run `peach runtime install`",
470
+ { cause }
471
+ );
472
+ }
473
+ const hash = (0, import_node_crypto.createHash)("sha256").update(bytes).digest("hex");
474
+ if (hash !== runtime_companion_default.sha256) {
475
+ throw new Error(
476
+ "Peach runtime companion does not match this CLI; run `peach runtime install`"
477
+ );
478
+ }
479
+ }
480
+ function getCliRuntime() {
481
+ if (loaded) return loaded.runtime;
482
+ const root = resolveDevCheckoutRuntimeAssetRoot() ?? resolveActiveRuntimeRoot();
483
+ if (!root) throw new Error("No Peach runtime installed; run `peach runtime install`");
484
+ verifyCliCompanion(root);
485
+ const require2 = (0, import_node_module.createRequire)(__sootsim_import_meta_url);
486
+ const runtime = require2((0, import_node_path2.join)(root, cliCompanionPath()));
487
+ if (runtime.cliCompanionAbi !== CLI_COMPANION_ABI) {
488
+ throw new Error(
489
+ "Incompatible Peach runtime companion ABI; run `peach runtime install`"
490
+ );
491
+ }
492
+ loaded = { root, runtime };
493
+ return runtime;
494
+ }
495
+ var import_node_crypto, import_node_fs2, import_node_module, import_node_path2, CLI_COMPANION_ABI, loaded;
449
496
  var init_cli_runtime = __esm({
450
497
  "src/cli-runtime.ts"() {
451
498
  "use strict";
499
+ import_node_crypto = require("node:crypto");
500
+ import_node_fs2 = require("node:fs");
501
+ import_node_module = require("node:module");
502
+ import_node_path2 = require("node:path");
503
+ init_runtime_companion();
452
504
  init_runtime_assets();
505
+ CLI_COMPANION_ABI = 1;
453
506
  }
454
507
  });
455
508
 
@@ -4499,24 +4552,24 @@ var init_browser = __esm({
4499
4552
  });
4500
4553
 
4501
4554
  // cli/commands/nodeRepoFileReader.ts
4502
- var import_node_fs2, nodeRepoFileReader;
4555
+ var import_node_fs3, nodeRepoFileReader;
4503
4556
  var init_nodeRepoFileReader = __esm({
4504
4557
  "cli/commands/nodeRepoFileReader.ts"() {
4505
4558
  "use strict";
4506
- import_node_fs2 = require("node:fs");
4559
+ import_node_fs3 = require("node:fs");
4507
4560
  nodeRepoFileReader = {
4508
- exists: import_node_fs2.existsSync,
4509
- readText: (filePath) => (0, import_node_fs2.readFileSync)(filePath, "utf8"),
4510
- entries: (directory) => (0, import_node_fs2.readdirSync)(directory, { withFileTypes: true }).map((entry) => ({
4561
+ exists: import_node_fs3.existsSync,
4562
+ readText: (filePath) => (0, import_node_fs3.readFileSync)(filePath, "utf8"),
4563
+ entries: (directory) => (0, import_node_fs3.readdirSync)(directory, { withFileTypes: true }).map((entry) => ({
4511
4564
  name: entry.name,
4512
4565
  directory: entry.isDirectory()
4513
4566
  })),
4514
- isDirectory: (filePath) => (0, import_node_fs2.statSync)(filePath).isDirectory(),
4567
+ isDirectory: (filePath) => (0, import_node_fs3.statSync)(filePath).isDirectory(),
4515
4568
  readMetadata(filePath) {
4516
4569
  try {
4517
- const info = (0, import_node_fs2.lstatSync)(filePath);
4570
+ const info = (0, import_node_fs3.lstatSync)(filePath);
4518
4571
  if (!info.isFile() || info.size > 4 * 1024 * 1024) return null;
4519
- return (0, import_node_fs2.readFileSync)(filePath, "utf8");
4572
+ return (0, import_node_fs3.readFileSync)(filePath, "utf8");
4520
4573
  } catch {
4521
4574
  return null;
4522
4575
  }
@@ -4539,7 +4592,7 @@ function scanRepository(root) {
4539
4592
  directories.push(next.dir);
4540
4593
  let handle;
4541
4594
  try {
4542
- handle = (0, import_node_fs3.opendirSync)(next.dir);
4595
+ handle = (0, import_node_fs4.opendirSync)(next.dir);
4543
4596
  } catch {
4544
4597
  unreadable++;
4545
4598
  continue;
@@ -4554,7 +4607,7 @@ function scanRepository(root) {
4554
4607
  truncated = true;
4555
4608
  continue;
4556
4609
  }
4557
- pending.push({ dir: (0, import_node_path2.join)(next.dir, entry.name), depth: next.depth + 1 });
4610
+ pending.push({ dir: (0, import_node_path3.join)(next.dir, entry.name), depth: next.depth + 1 });
4558
4611
  }
4559
4612
  } finally {
4560
4613
  handle.closeSync();
@@ -4584,7 +4637,7 @@ function readProjectJson(path20, files = nodeRepoFileReader) {
4584
4637
  }
4585
4638
  }
4586
4639
  function readProjectManifest(dir, files = nodeRepoFileReader) {
4587
- const parsed = readProjectJson((0, import_node_path2.join)(dir, "package.json"), files);
4640
+ const parsed = readProjectJson((0, import_node_path3.join)(dir, "package.json"), files);
4588
4641
  if (!parsed || typeof parsed !== "object") return null;
4589
4642
  const record = (value) => {
4590
4643
  if (!value || typeof value !== "object") return {};
@@ -4601,12 +4654,12 @@ function readProjectManifest(dir, files = nodeRepoFileReader) {
4601
4654
  devDependencies: record(metadataValue(parsed, "devDependencies"))
4602
4655
  };
4603
4656
  }
4604
- var import_node_fs3, import_node_path2, import_json5, REPORT_SKIP_DIRS;
4657
+ var import_node_fs4, import_node_path3, import_json5, REPORT_SKIP_DIRS;
4605
4658
  var init_detect = __esm({
4606
4659
  "cli/commands/detect.ts"() {
4607
4660
  "use strict";
4608
- import_node_fs3 = require("node:fs");
4609
- import_node_path2 = require("node:path");
4661
+ import_node_fs4 = require("node:fs");
4662
+ import_node_path3 = require("node:path");
4610
4663
  import_json5 = __toESM(require_lib(), 1);
4611
4664
  init_browser();
4612
4665
  init_nodeRepoFileReader();
@@ -4660,7 +4713,7 @@ function normalize(p) {
4660
4713
  if (trailingSlash) joined += "/";
4661
4714
  return absolute ? "/" + joined : joined;
4662
4715
  }
4663
- function join3(...parts) {
4716
+ function join4(...parts) {
4664
4717
  const present = parts.filter((part) => part.length > 0);
4665
4718
  if (present.length === 0) return ".";
4666
4719
  return normalize(present.join("/"));
@@ -4723,7 +4776,7 @@ var init_posixPath = __esm({
4723
4776
  delimiter,
4724
4777
  isAbsolute,
4725
4778
  normalize,
4726
- join: join3,
4779
+ join: join4,
4727
4780
  resolve: resolve2,
4728
4781
  dirname: dirname4,
4729
4782
  basename: basename3,
@@ -4965,16 +5018,16 @@ function sendJavaScript(req, res, source) {
4965
5018
  res.end(req.method === "HEAD" ? void 0 : source);
4966
5019
  }
4967
5020
  function resolveReplacementModuleFile(fromFile, specifier) {
4968
- const base = import_node_path7.default.resolve(import_node_path7.default.dirname(fromFile), specifier);
5021
+ const base = import_node_path8.default.resolve(import_node_path8.default.dirname(fromFile), specifier);
4969
5022
  const candidates = [
4970
5023
  ...REPLACEMENT_MODULE_EXTENSIONS.some(
4971
- (ext) => ext === import_node_path7.default.extname(base).toLowerCase()
5024
+ (ext) => ext === import_node_path8.default.extname(base).toLowerCase()
4972
5025
  ) ? [base] : [],
4973
5026
  ...REPLACEMENT_MODULE_EXTENSIONS.map((ext) => base + ext),
4974
- ...REPLACEMENT_MODULE_EXTENSIONS.map((ext) => import_node_path7.default.join(base, `index${ext}`))
5027
+ ...REPLACEMENT_MODULE_EXTENSIONS.map((ext) => import_node_path8.default.join(base, `index${ext}`))
4975
5028
  ];
4976
5029
  const found = candidates.find(
4977
- (candidate) => (0, import_node_fs8.statSync)(candidate, { throwIfNoEntry: false })?.isFile()
5030
+ (candidate) => (0, import_node_fs9.statSync)(candidate, { throwIfNoEntry: false })?.isFile()
4978
5031
  );
4979
5032
  if (!found) {
4980
5033
  throw new Error(
@@ -4985,8 +5038,8 @@ function resolveReplacementModuleFile(fromFile, specifier) {
4985
5038
  }
4986
5039
  function isInsideAny(roots, file) {
4987
5040
  return roots.some((root) => {
4988
- const relative3 = import_node_path7.default.relative(root, file);
4989
- return !relative3.startsWith("..") && !import_node_path7.default.isAbsolute(relative3);
5041
+ const relative3 = import_node_path8.default.relative(root, file);
5042
+ return !relative3.startsWith("..") && !import_node_path8.default.isAbsolute(relative3);
4990
5043
  });
4991
5044
  }
4992
5045
  function isReplacementModuleRequestUrl(rawUrl) {
@@ -5035,19 +5088,19 @@ async function handleReplacementModuleRequest(req, res, options = {}) {
5035
5088
  res.end("missing path param");
5036
5089
  return true;
5037
5090
  }
5038
- const extension = import_node_path7.default.extname(targetPath).toLowerCase();
5091
+ const extension = import_node_path8.default.extname(targetPath).toLowerCase();
5039
5092
  if (!REPLACEMENT_MODULE_EXTENSIONS.some((allowed) => allowed === extension)) {
5040
5093
  res.writeHead(400, { "Content-Type": "text/plain; charset=utf-8" });
5041
5094
  res.end(`replacement files must be ${REPLACEMENT_MODULE_EXTENSIONS.join(", ")}`);
5042
5095
  return true;
5043
5096
  }
5044
- if (!import_node_path7.default.isAbsolute(targetPath)) {
5097
+ if (!import_node_path8.default.isAbsolute(targetPath)) {
5045
5098
  res.writeHead(400, { "Content-Type": "text/plain; charset=utf-8" });
5046
5099
  res.end("replacement file path must be absolute");
5047
5100
  return true;
5048
5101
  }
5049
5102
  const runtimePackages = new Set(url.searchParams.getAll("runtimePackage"));
5050
- const servedRoots = options.servedRoots?.map((root) => import_node_path7.default.resolve(root));
5103
+ const servedRoots = options.servedRoots?.map((root) => import_node_path8.default.resolve(root));
5051
5104
  if (servedRoots && !isInsideAny(servedRoots, targetPath)) {
5052
5105
  res.writeHead(403, { "Content-Type": "text/plain; charset=utf-8" });
5053
5106
  res.end("replacement file must be inside a folder the bundler serves");
@@ -5099,13 +5152,13 @@ async function handleReplacementModuleRequest(req, res, options = {}) {
5099
5152
  }
5100
5153
  return true;
5101
5154
  }
5102
- var import_node_fs8, import_promises, import_node_path7, REPLACEMENT_MODULE_ROUTE;
5155
+ var import_node_fs9, import_promises, import_node_path8, REPLACEMENT_MODULE_ROUTE;
5103
5156
  var init_replacement_module_handler = __esm({
5104
5157
  "src/host/replacement-module-handler.ts"() {
5105
5158
  "use strict";
5106
- import_node_fs8 = require("node:fs");
5159
+ import_node_fs9 = require("node:fs");
5107
5160
  import_promises = __toESM(require("node:fs/promises"), 1);
5108
- import_node_path7 = __toESM(require("node:path"), 1);
5161
+ import_node_path8 = __toESM(require("node:path"), 1);
5109
5162
  init_replacementModule();
5110
5163
  init_backend_origin();
5111
5164
  REPLACEMENT_MODULE_ROUTE = "/__sootsim-replacement-module";
@@ -5115,9 +5168,9 @@ var init_replacement_module_handler = __esm({
5115
5168
  // cli/app-project.ts
5116
5169
  function firstNamedFile(dir, names) {
5117
5170
  for (const name2 of names) {
5118
- const candidate = import_node_path10.default.join(dir, name2);
5171
+ const candidate = import_node_path11.default.join(dir, name2);
5119
5172
  try {
5120
- if (import_node_fs11.default.statSync(candidate).isFile()) return candidate;
5173
+ if (import_node_fs12.default.statSync(candidate).isFile()) return candidate;
5121
5174
  } catch {
5122
5175
  }
5123
5176
  }
@@ -5130,24 +5183,24 @@ function findRNXAppConfig(dir) {
5130
5183
  return firstNamedFile(dir, PEACH_APP_CONFIG_NAMES);
5131
5184
  }
5132
5185
  function resolveAppProject(projectRoot) {
5133
- const appDir = import_node_path10.default.resolve(projectRoot);
5186
+ const appDir = import_node_path11.default.resolve(projectRoot);
5134
5187
  try {
5135
- if (!import_node_fs11.default.statSync(appDir).isDirectory()) return null;
5188
+ if (!import_node_fs12.default.statSync(appDir).isDirectory()) return null;
5136
5189
  } catch {
5137
5190
  return null;
5138
5191
  }
5139
5192
  const configPath = findRNXAppConfig(appDir);
5140
- if (!configPath && !findExpoAppConfig(appDir) && !import_node_fs11.default.existsSync(import_node_path10.default.join(appDir, "package.json"))) {
5193
+ if (!configPath && !findExpoAppConfig(appDir) && !import_node_fs12.default.existsSync(import_node_path11.default.join(appDir, "package.json"))) {
5141
5194
  return null;
5142
5195
  }
5143
5196
  return { appDir, configPath };
5144
5197
  }
5145
- var import_node_fs11, import_node_path10, EXPO_APP_CONFIG_NAMES, PEACH_APP_CONFIG_NAMES;
5198
+ var import_node_fs12, import_node_path11, EXPO_APP_CONFIG_NAMES, PEACH_APP_CONFIG_NAMES;
5146
5199
  var init_app_project = __esm({
5147
5200
  "cli/app-project.ts"() {
5148
5201
  "use strict";
5149
- import_node_fs11 = __toESM(require("node:fs"), 1);
5150
- import_node_path10 = __toESM(require("node:path"), 1);
5202
+ import_node_fs12 = __toESM(require("node:fs"), 1);
5203
+ import_node_path11 = __toESM(require("node:path"), 1);
5151
5204
  EXPO_APP_CONFIG_NAMES = [
5152
5205
  "app.config.js",
5153
5206
  "app.config.ts",
@@ -5514,10 +5567,10 @@ function expandStubs(appDir, source) {
5514
5567
  return { modules, views };
5515
5568
  }
5516
5569
  function lowerStub(stub, baseDir) {
5517
- return stub === "noop" ? stub : { file: (0, import_node_path16.resolve)(baseDir, stub) };
5570
+ return stub === "noop" ? stub : { file: (0, import_node_path17.resolve)(baseDir, stub) };
5518
5571
  }
5519
5572
  function readPackageJson(dir) {
5520
- const text2 = readSmallFile((0, import_node_path16.join)(dir, "package.json"));
5573
+ const text2 = readSmallFile((0, import_node_path17.join)(dir, "package.json"));
5521
5574
  if (!text2) return null;
5522
5575
  try {
5523
5576
  const parsed = JSON.parse(text2);
@@ -5529,13 +5582,19 @@ function readPackageJson(dir) {
5529
5582
  function installedPackageDir(appDir, name2) {
5530
5583
  let current = appDir;
5531
5584
  while (true) {
5532
- const dir = (0, import_node_path16.join)(current, "node_modules", name2);
5533
- if ((0, import_node_fs16.existsSync)((0, import_node_path16.join)(dir, "package.json"))) return (0, import_node_fs16.realpathSync)(dir);
5534
- const parent = (0, import_node_path16.dirname)(current);
5585
+ const dir = (0, import_node_path17.join)(current, "node_modules", name2);
5586
+ if ((0, import_node_fs17.existsSync)((0, import_node_path17.join)(dir, "package.json"))) return (0, import_node_fs17.realpathSync)(dir);
5587
+ const parent = (0, import_node_path17.dirname)(current);
5535
5588
  if (parent === current) return null;
5536
5589
  current = parent;
5537
5590
  }
5538
5591
  }
5592
+ function isAndroidCheck(node) {
5593
+ if (node.type !== "BinaryExpression" || !["===", "=="].includes(node.operator))
5594
+ return false;
5595
+ const side = (value, literal) => value.type === "MemberExpression" && !value.computed && nativeLookupName(value.object) === "Platform" && nativeLookupName(value) === "OS" && literal.type === "Literal" && literal.value === "android";
5596
+ return side(node.left, node.right) || side(node.right, node.left);
5597
+ }
5539
5598
  function nativeLookupName(node) {
5540
5599
  if (node.type === "Identifier") return node.name;
5541
5600
  if (node.type === "MemberExpression" && !node.computed && node.property.type === "Identifier")
@@ -5544,6 +5603,7 @@ function nativeLookupName(node) {
5544
5603
  }
5545
5604
  function sourceNativeRequests(file, text2, includeLegacy = false) {
5546
5605
  if (!NATIVE_LOOKUP.test(text2)) return [];
5606
+ const androidFile = /\.android\.[cm]?[jt]sx?$/.test(file);
5547
5607
  let code;
5548
5608
  try {
5549
5609
  code = (0, import_sucrase.transform)(text2, {
@@ -5556,40 +5616,67 @@ function sourceNativeRequests(file, text2, includeLegacy = false) {
5556
5616
  const { program, errors } = (0, import_oxc_parser2.parseSync)(file, code, { lang: "jsx" });
5557
5617
  if (errors.length) return [];
5558
5618
  const found = [];
5559
- const add = (kind, name2, at) => {
5560
- found.push({ kind, name: name2, line: code.slice(0, at).split("\n").length });
5619
+ const androidRanges = [];
5620
+ const guard = (test, branch) => {
5621
+ if (isAndroidCheck(test)) androidRanges.push([branch.start, branch.end]);
5622
+ };
5623
+ const add = (kind, name2, at, optional) => {
5624
+ found.push({
5625
+ kind,
5626
+ name: name2,
5627
+ optional,
5628
+ androidOnly: androidFile || androidRanges.some(([start, end]) => at >= start && at < end),
5629
+ line: code.slice(0, at).split("\n").length
5630
+ });
5561
5631
  };
5562
5632
  visitParsedProgram(program, {
5633
+ IfStatement(node) {
5634
+ guard(node.test, node.consequent);
5635
+ },
5636
+ ConditionalExpression(node) {
5637
+ guard(node.test, node.consequent);
5638
+ },
5639
+ LogicalExpression(node) {
5640
+ if (node.operator === "&&") guard(node.left, node.right);
5641
+ },
5563
5642
  CallExpression(node) {
5564
5643
  const first = node.arguments[0];
5565
5644
  if (first?.type !== "Literal" || typeof first.value !== "string") return;
5566
5645
  const callee = node.callee;
5567
5646
  const lookup = nativeLookupName(callee);
5568
5647
  if (callee.type === "MemberExpression" && !callee.computed && nativeLookupName(callee.object) === "TurboModuleRegistry" && (lookup === "get" || lookup === "getEnforcing")) {
5569
- add("module", first.value, node.start);
5648
+ add("module", first.value, node.start, false);
5570
5649
  } else if (lookup) {
5571
5650
  if (["requireNativeModule", "requireOptionalNativeModule"].includes(lookup))
5572
- add("module", first.value, node.start);
5651
+ add("module", first.value, node.start, lookup === "requireOptionalNativeModule");
5573
5652
  else if (["requireNativeComponent", "codegenNativeComponent"].includes(lookup))
5574
- add("view", first.value, node.start);
5653
+ add("view", first.value, node.start, false);
5575
5654
  else if (["requireNativeView", "requireNativeViewManager"].includes(lookup)) {
5576
5655
  const second = node.arguments[1];
5577
5656
  const name2 = second?.type === "Literal" && typeof second.value === "string" ? `${first.value}_${second.value}` : first.value;
5578
- add("view", name2, node.start);
5657
+ add("view", name2, node.start, false);
5579
5658
  }
5580
5659
  }
5581
5660
  },
5582
5661
  MemberExpression(node) {
5583
5662
  if (includeLegacy && !node.computed && nativeLookupName(node.object) === "NativeModules" && node.property.type === "Identifier")
5584
- add("module", node.property.name, node.start);
5663
+ add("module", node.property.name, node.start, false);
5585
5664
  }
5586
5665
  });
5587
5666
  return found;
5588
5667
  }
5668
+ function mergeRequests(previous, next) {
5669
+ if (!previous) return next;
5670
+ return {
5671
+ ...next,
5672
+ optional: previous.optional && next.optional,
5673
+ androidOnly: previous.androidOnly && next.androidOnly
5674
+ };
5675
+ }
5589
5676
  function packageNativeRequests(dir) {
5590
5677
  const found = /* @__PURE__ */ new Map();
5591
5678
  const directories = scanRepository(dir).directories.filter((sub) => {
5592
- const segments = (0, import_node_path16.relative)(dir, sub).split("/");
5679
+ const segments = (0, import_node_path17.relative)(dir, sub).split("/");
5593
5680
  return !NATIVE_SOURCE_DIRS.has(segments[0]) && !segments.some((segment) => PACKAGE_SKIP_DIRS.has(segment));
5594
5681
  });
5595
5682
  let files = 0;
@@ -5597,11 +5684,14 @@ function packageNativeRequests(dir) {
5597
5684
  for (const name2 of listDir(sub)) {
5598
5685
  if (!SOURCE_FILE.test(name2) || name2.endsWith(".d.ts") || files >= 2e3) continue;
5599
5686
  files++;
5600
- const file = (0, import_node_path16.join)(sub, name2);
5687
+ const file = (0, import_node_path17.join)(sub, name2);
5601
5688
  const text2 = readSmallFile(file);
5602
5689
  if (!text2) continue;
5603
- for (const { kind, name: name3 } of sourceNativeRequests(file, text2, true))
5604
- found.set(`${kind}:${name3}`, { kind, name: name3 });
5690
+ for (const { line: _line, ...request } of sourceNativeRequests(file, text2, true))
5691
+ found.set(
5692
+ `${request.kind}:${request.name}`,
5693
+ mergeRequests(found.get(`${request.kind}:${request.name}`), request)
5694
+ );
5605
5695
  }
5606
5696
  }
5607
5697
  return [...found.values()].sort(
@@ -5713,27 +5803,27 @@ function wireSlotMigration(appDir, configPath, wire, kept = []) {
5713
5803
  }
5714
5804
  function listDir(dir) {
5715
5805
  try {
5716
- return (0, import_node_fs16.readdirSync)(dir);
5806
+ return (0, import_node_fs17.readdirSync)(dir);
5717
5807
  } catch {
5718
5808
  return [];
5719
5809
  }
5720
5810
  }
5721
5811
  function readSmallFile(file) {
5722
5812
  try {
5723
- return (0, import_node_fs16.statSync)(file).size <= 1024 * 1024 ? (0, import_node_fs16.readFileSync)(file, "utf8") : null;
5813
+ return (0, import_node_fs17.statSync)(file).size <= 1024 * 1024 ? (0, import_node_fs17.readFileSync)(file, "utf8") : null;
5724
5814
  } catch {
5725
5815
  return null;
5726
5816
  }
5727
5817
  }
5728
5818
  function hasNativeCode(dir, platform) {
5729
- const expoConfig = (0, import_node_path16.join)(dir, "expo-module.config.json");
5819
+ const expoConfig = (0, import_node_path17.join)(dir, "expo-module.config.json");
5730
5820
  const platforms = metadataValue(readProjectJson(expoConfig), "platforms");
5731
5821
  if (Array.isArray(platforms))
5732
5822
  return platforms.includes(platform) || platform === "ios" && platforms.includes("apple");
5733
- if ([platform, "expo-module.config.json"].some((entry) => (0, import_node_fs16.existsSync)((0, import_node_path16.join)(dir, entry))))
5823
+ if ([platform, "expo-module.config.json"].some((entry) => (0, import_node_fs17.existsSync)((0, import_node_path17.join)(dir, entry))))
5734
5824
  return true;
5735
5825
  if (listDir(dir).some((name2) => name2.endsWith(".podspec"))) return true;
5736
- const manifest = readSmallFile((0, import_node_path16.join)(dir, "package.json"));
5826
+ const manifest = readSmallFile((0, import_node_path17.join)(dir, "package.json"));
5737
5827
  return manifest !== null && manifest.includes('"codegenConfig"');
5738
5828
  }
5739
5829
  function scanLocalNative(appDir, pkg, answered, platform, knownPackages = /* @__PURE__ */ new Set(), includeLegacy = false, providers) {
@@ -5746,7 +5836,7 @@ function scanLocalNative(appDir, pkg, answered, platform, knownPackages = /* @__
5746
5836
  (excluded) => dir === excluded || dir.startsWith(`${excluded}/`)
5747
5837
  ))
5748
5838
  continue;
5749
- if ((0, import_node_fs16.existsSync)((0, import_node_path16.join)(dir, "expo-module.config.json"))) {
5839
+ if ((0, import_node_fs17.existsSync)((0, import_node_path17.join)(dir, "expo-module.config.json"))) {
5750
5840
  if (platform && !hasNativeCode(dir, platform)) {
5751
5841
  excludedModuleDirs.push(dir);
5752
5842
  continue;
@@ -5755,7 +5845,7 @@ function scanLocalNative(appDir, pkg, answered, platform, knownPackages = /* @__
5755
5845
  }
5756
5846
  for (const name2 of listDir(dir)) {
5757
5847
  if (SOURCE_FILE.test(name2) && !name2.endsWith(".d.ts"))
5758
- sourceFiles.push((0, import_node_path16.join)(dir, name2));
5848
+ sourceFiles.push((0, import_node_path17.join)(dir, name2));
5759
5849
  }
5760
5850
  }
5761
5851
  }
@@ -5765,7 +5855,7 @@ function scanLocalNative(appDir, pkg, answered, platform, knownPackages = /* @__
5765
5855
  scanRepository(dir).directories.flatMap(
5766
5856
  (sub) => listDir(sub).filter(
5767
5857
  (name2) => NATIVE_SOURCE_FILE.test(name2) && (!platform || (platform === "ios" ? name2.endsWith(".swift") : name2.endsWith(".kt")))
5768
- ).map((name2) => (0, import_node_path16.join)(sub, name2))
5858
+ ).map((name2) => (0, import_node_path17.join)(sub, name2))
5769
5859
  )
5770
5860
  ])
5771
5861
  );
@@ -5774,25 +5864,30 @@ function scanLocalNative(appDir, pkg, answered, platform, knownPackages = /* @__
5774
5864
  const known = owners.get(dir);
5775
5865
  if (known) return known;
5776
5866
  const name2 = readPackageJson(dir)?.name;
5777
- const parent = (0, import_node_path16.dirname)(dir);
5867
+ const parent = (0, import_node_path17.dirname)(dir);
5778
5868
  const result = typeof name2 === "string" ? name2 : parent === dir ? pkg.name ?? "app" : owner(parent);
5779
5869
  owners.set(dir, result);
5780
5870
  return result;
5781
5871
  };
5782
5872
  const found = /* @__PURE__ */ new Map();
5783
- const add = (kind, name2, file, line) => {
5873
+ const add = (kind, name2, file, line, optional = false) => {
5784
5874
  const key = `${kind}:${name2}`;
5785
- if (found.has(key)) return;
5875
+ const known = found.get(key);
5876
+ if (known) {
5877
+ known.optional &&= optional;
5878
+ return;
5879
+ }
5786
5880
  providers ??= dependencyNativeOwners(appDir, pkg);
5787
- const packageName = providers.get(key) ?? owner((0, import_node_path16.dirname)(file));
5881
+ const packageName = providers.get(key) ?? owner((0, import_node_path17.dirname)(file));
5788
5882
  if (knownPackages.has(packageName)) return;
5789
5883
  const moduleDir = expoModuleDirs.find((dir) => file.startsWith(`${dir}/`)) ?? null;
5790
5884
  found.set(key, {
5791
5885
  kind,
5792
5886
  name: name2,
5793
5887
  package: packageName,
5794
- path: `${(0, import_node_path16.relative)(appDir, file)}:${line}`,
5795
- expoModule: moduleDir ? (0, import_node_path16.relative)(appDir, moduleDir) || "." : null,
5888
+ path: `${(0, import_node_path17.relative)(appDir, file)}:${line}`,
5889
+ expoModule: moduleDir ? (0, import_node_path17.relative)(appDir, moduleDir) || "." : null,
5890
+ optional,
5796
5891
  swift: moduleDir ? (nativeFilesByModule.get(moduleDir) ?? []).some(
5797
5892
  (path20) => path20.endsWith(".swift") && [...(readSmallFile(path20) ?? "").matchAll(/\bName\(\s*"(\w+)"\s*\)/g)].some(
5798
5893
  (match) => match[1] === name2
@@ -5804,8 +5899,14 @@ function scanLocalNative(appDir, pkg, answered, platform, knownPackages = /* @__
5804
5899
  for (const file of sourceFiles) {
5805
5900
  const text2 = readSmallFile(file);
5806
5901
  if (!text2) continue;
5807
- for (const { kind, name: name2, line } of sourceNativeRequests(file, text2, includeLegacy))
5808
- add(kind, name2, file, line);
5902
+ for (const { kind, name: name2, line, optional, androidOnly } of sourceNativeRequests(
5903
+ file,
5904
+ text2,
5905
+ includeLegacy
5906
+ )) {
5907
+ if (androidOnly && platform === "ios") continue;
5908
+ add(kind, name2, file, line, optional);
5909
+ }
5809
5910
  }
5810
5911
  for (const [, files] of nativeFilesByModule) {
5811
5912
  const swiftFirst = [...files].sort(
@@ -5829,29 +5930,29 @@ function workspacePackageDirs(appDir, pkg) {
5829
5930
  for (const name2 of Object.keys({ ...pkg.dependencies, ...pkg.devDependencies })) {
5830
5931
  let current = appDir;
5831
5932
  while (true) {
5832
- const link = (0, import_node_path16.join)(current, "node_modules", name2);
5833
- if ((0, import_node_fs16.existsSync)(link)) {
5834
- if ((0, import_node_fs16.lstatSync)(link).isSymbolicLink()) {
5835
- const target = (0, import_node_fs16.realpathSync)(link);
5933
+ const link = (0, import_node_path17.join)(current, "node_modules", name2);
5934
+ if ((0, import_node_fs17.existsSync)(link)) {
5935
+ if ((0, import_node_fs17.lstatSync)(link).isSymbolicLink()) {
5936
+ const target = (0, import_node_fs17.realpathSync)(link);
5836
5937
  if (!target.split("/").includes("node_modules") && !target.startsWith(`${appDir}/`)) {
5837
5938
  dirs.add(target);
5838
5939
  }
5839
5940
  }
5840
5941
  break;
5841
5942
  }
5842
- const parent = (0, import_node_path16.dirname)(current);
5943
+ const parent = (0, import_node_path17.dirname)(current);
5843
5944
  if (parent === current) break;
5844
5945
  current = parent;
5845
5946
  }
5846
5947
  }
5847
5948
  return [...dirs];
5848
5949
  }
5849
- var import_node_fs16, import_node_path16, import_version_range, import_oxc_parser2, import_sucrase, SOURCE_FILE, NATIVE_LOOKUP, NATIVE_SOURCE_DIRS, PACKAGE_SKIP_DIRS, NATIVE_SOURCE_FILE;
5950
+ var import_node_fs17, import_node_path17, import_version_range, import_oxc_parser2, import_sucrase, SOURCE_FILE, NATIVE_LOOKUP, NATIVE_SOURCE_DIRS, PACKAGE_SKIP_DIRS, NATIVE_SOURCE_FILE;
5850
5951
  var init_app_stubs = __esm({
5851
5952
  "cli/app-stubs.ts"() {
5852
5953
  "use strict";
5853
- import_node_fs16 = require("node:fs");
5854
- import_node_path16 = require("node:path");
5954
+ import_node_fs17 = require("node:fs");
5955
+ import_node_path17 = require("node:path");
5855
5956
  import_version_range = require("@peach/compat/version-range");
5856
5957
  import_oxc_parser2 = require("oxc-parser");
5857
5958
  import_sucrase = require("sucrase");
@@ -5886,12 +5987,12 @@ function resolveFileEntries(entries, configDir) {
5886
5987
  return Object.fromEntries(
5887
5988
  Object.entries(entries).map(([name2, resolution]) => [
5888
5989
  name2,
5889
- resolution && typeof resolution === "object" && "file" in resolution && typeof resolution.file === "string" ? { ...resolution, file: import_node_path17.default.resolve(configDir, resolution.file) } : resolution
5990
+ resolution && typeof resolution === "object" && "file" in resolution && typeof resolution.file === "string" ? { ...resolution, file: import_node_path18.default.resolve(configDir, resolution.file) } : resolution
5890
5991
  ])
5891
5992
  );
5892
5993
  }
5893
5994
  function resolveConfigReplacementFiles(config, configPath) {
5894
- const configDir = import_node_path17.default.dirname(configPath);
5995
+ const configDir = import_node_path18.default.dirname(configPath);
5895
5996
  return {
5896
5997
  ...config,
5897
5998
  modules: resolveFileEntries(config.modules, configDir)
@@ -5907,7 +6008,7 @@ async function loadRNXAppStubs(project) {
5907
6008
  return resolveAppStubs(
5908
6009
  project.appDir,
5909
6010
  config,
5910
- project.configPath ? import_node_path17.default.dirname(project.configPath) : project.appDir
6011
+ project.configPath ? import_node_path18.default.dirname(project.configPath) : project.appDir
5911
6012
  );
5912
6013
  } catch (error) {
5913
6014
  const message = error instanceof Error ? error.message : String(error);
@@ -5926,20 +6027,20 @@ async function loadConfigFile(project) {
5926
6027
  [`${rnxPublicBrand.packageName}/config`]: config_exports
5927
6028
  }
5928
6029
  });
5929
- const loaded2 = project.configPath.endsWith(".json") ? JSON.parse((0, import_node_fs17.readFileSync)(project.configPath, "utf8")) : await jiti.import(project.configPath, { default: true });
5930
- if (!isPeachConfig(loaded2)) {
6030
+ const loaded3 = project.configPath.endsWith(".json") ? JSON.parse((0, import_node_fs18.readFileSync)(project.configPath, "utf8")) : await jiti.import(project.configPath, { default: true });
6031
+ if (!isPeachConfig(loaded3)) {
5931
6032
  throw new Error("the default export must be a peach config object");
5932
6033
  }
5933
- const wire = WIRE_SLOTS.filter((slot) => loaded2[slot] !== void 0);
6034
+ const wire = WIRE_SLOTS.filter((slot) => loaded3[slot] !== void 0);
5934
6035
  if (wire.length > 0) {
5935
6036
  const slots = WIRE_SLOTS;
5936
- const kept = Object.entries(loaded2).filter(([key, value]) => !slots.includes(key) && value !== void 0).map(([key]) => key);
6037
+ const kept = Object.entries(loaded3).filter(([key, value]) => !slots.includes(key) && value !== void 0).map(([key]) => key);
5937
6038
  const migration = wireSlotMigration(
5938
6039
  project.appDir,
5939
6040
  project.configPath,
5940
6041
  {
5941
- modules: { ...loaded2.turboModules, ...loaded2.nativeModules },
5942
- views: { ...loaded2.nativeViews }
6042
+ modules: { ...loaded3.turboModules, ...loaded3.nativeModules },
6043
+ views: { ...loaded3.nativeViews }
5943
6044
  },
5944
6045
  kept
5945
6046
  );
@@ -5948,7 +6049,7 @@ async function loadConfigFile(project) {
5948
6049
  ${migration}`
5949
6050
  );
5950
6051
  }
5951
- return resolveConfigReplacementFiles(loaded2, project.configPath);
6052
+ return resolveConfigReplacementFiles(loaded3, project.configPath);
5952
6053
  } catch (error) {
5953
6054
  const message = error instanceof Error ? error.message : String(error);
5954
6055
  throw new Error(`could not load ${project.configPath}: ${message}`);
@@ -5958,12 +6059,12 @@ async function resolveRNXAppConfig(startDir = process.cwd()) {
5958
6059
  const project = resolveAppProject(startDir);
5959
6060
  return { project, ...await loadRNXAppStubs(project) };
5960
6061
  }
5961
- var import_node_fs17, import_node_path17, import_jiti, WIRE_SLOTS;
6062
+ var import_node_fs18, import_node_path18, import_jiti, WIRE_SLOTS;
5962
6063
  var init_app_config = __esm({
5963
6064
  "cli/app-config.ts"() {
5964
6065
  "use strict";
5965
- import_node_fs17 = require("node:fs");
5966
- import_node_path17 = __toESM(require("node:path"), 1);
6066
+ import_node_fs18 = require("node:fs");
6067
+ import_node_path18 = __toESM(require("node:path"), 1);
5967
6068
  import_jiti = require("jiti");
5968
6069
  init_config();
5969
6070
  init_config();
@@ -6059,14 +6160,14 @@ async function produceConfiguredBundle(source, config, runtimePackages) {
6059
6160
  const neededPackages = /* @__PURE__ */ new Set();
6060
6161
  const factories = [];
6061
6162
  const visit3 = (filePath) => {
6062
- const real = import_node_fs18.default.realpathSync(filePath);
6163
+ const real = import_node_fs19.default.realpathSync(filePath);
6063
6164
  const previous = files.get(real);
6064
6165
  if (previous !== void 0) return previous;
6065
6166
  const id = "peach-config-file:" + files.size;
6066
6167
  files.set(real, id);
6067
6168
  const compiled = compileReplacementModule({
6068
6169
  filePath: real,
6069
- source: import_node_fs18.default.readFileSync(real, "utf8"),
6170
+ source: import_node_fs19.default.readFileSync(real, "utf8"),
6070
6171
  runtimePackages,
6071
6172
  localModuleUrl: (specifier) => visit3(resolveReplacementModuleFile(real, specifier))
6072
6173
  });
@@ -6084,7 +6185,7 @@ async function produceConfiguredBundle(source, config, runtimePackages) {
6084
6185
  if (!entries || typeof entries !== "object") continue;
6085
6186
  for (const resolution of Object.values(entries)) {
6086
6187
  if (resolution && typeof resolution === "object" && "file" in resolution && typeof resolution.file === "string") {
6087
- resolution.file = visit3(import_node_path18.default.resolve(resolution.file));
6188
+ resolution.file = visit3(import_node_path19.default.resolve(resolution.file));
6088
6189
  }
6089
6190
  }
6090
6191
  }
@@ -6108,12 +6209,12 @@ async function produceConfiguredBundle(source, config, runtimePackages) {
6108
6209
  const identityStart = findBundleFooter(source, "globalThis.__sootsimModulePaths=");
6109
6210
  return prefix2 + (identityStart < 0 ? source + footer : source.slice(0, identityStart) + footer + source.slice(identityStart));
6110
6211
  }
6111
- var import_node_fs18, import_node_path18, import_sucrase2, import_terser;
6212
+ var import_node_fs19, import_node_path19, import_sucrase2, import_terser;
6112
6213
  var init_configured_bundle_producer = __esm({
6113
6214
  "src/configured-bundle-producer.ts"() {
6114
6215
  "use strict";
6115
- import_node_fs18 = __toESM(require("node:fs"), 1);
6116
- import_node_path18 = __toESM(require("node:path"), 1);
6216
+ import_node_fs19 = __toESM(require("node:fs"), 1);
6217
+ import_node_path19 = __toESM(require("node:path"), 1);
6117
6218
  import_sucrase2 = require("sucrase");
6118
6219
  import_terser = require("terser");
6119
6220
  init_dependencies();
@@ -6154,7 +6255,7 @@ __export(src_exports, {
6154
6255
  module.exports = __toCommonJS(src_exports);
6155
6256
 
6156
6257
  // cli/cloud-client.ts
6157
- var import_node_crypto = require("node:crypto");
6258
+ var import_node_crypto2 = require("node:crypto");
6158
6259
 
6159
6260
  // src/androidAutolinkingContract.ts
6160
6261
  init_bundleGlobalFooter();
@@ -6290,7 +6391,20 @@ var DEFAULT_ORIGIN = peachPublicBrand.origin;
6290
6391
 
6291
6392
  // cli/run-rnx.ts
6292
6393
  var import_node_async_hooks = require("node:async_hooks");
6394
+ var PeachExit = class extends Error {
6395
+ code;
6396
+ reason;
6397
+ constructor(code, reason = null) {
6398
+ super(`peach exited with code ${code}`);
6399
+ this.name = "PeachExit";
6400
+ this.code = code;
6401
+ this.reason = reason;
6402
+ }
6403
+ };
6293
6404
  var sinks = new import_node_async_hooks.AsyncLocalStorage();
6405
+ function peachExit(code, reason) {
6406
+ throw new PeachExit(code, reason);
6407
+ }
6294
6408
 
6295
6409
  // cli/auth.ts
6296
6410
  var CHOOSE_ACCOUNT_HINT = "this sign-in belongs to several accounts; run `peach login --account <name>` to choose the one to bill";
@@ -6509,7 +6623,7 @@ var CloudBridge = class {
6509
6623
  async send(command, options) {
6510
6624
  const timeoutMs = options?.timeoutMs ?? this.explicitTimeoutMs ?? options?.defaultTimeoutMs;
6511
6625
  const body = {
6512
- id: (0, import_node_crypto.randomUUID)(),
6626
+ id: (0, import_node_crypto2.randomUUID)(),
6513
6627
  claimId: this.session.claimId,
6514
6628
  command: cloudCommand(command)
6515
6629
  };
@@ -6581,7 +6695,7 @@ var CloudBoxBridge = class {
6581
6695
  plane = "cloud";
6582
6696
  async send(command, options) {
6583
6697
  const timeoutMs = options?.timeoutMs ?? this.explicitTimeoutMs ?? options?.defaultTimeoutMs;
6584
- const id = (0, import_node_crypto.randomUUID)();
6698
+ const id = (0, import_node_crypto2.randomUUID)();
6585
6699
  const payload = {};
6586
6700
  for (const [key, value] of Object.entries(command)) {
6587
6701
  if (key !== "id" && key !== "simId") payload[key] = value;
@@ -6864,25 +6978,25 @@ function tryBuildDarwinPgidFfi() {
6864
6978
  }
6865
6979
 
6866
6980
  // cli/secure-file.ts
6867
- var import_node_crypto2 = require("node:crypto");
6868
- var import_node_fs4 = require("node:fs");
6869
- var import_node_path3 = require("node:path");
6981
+ var import_node_crypto3 = require("node:crypto");
6982
+ var import_node_fs5 = require("node:fs");
6983
+ var import_node_path4 = require("node:path");
6870
6984
  function writeSecureJsonAtomic(filepath, value) {
6871
- (0, import_node_fs4.mkdirSync)((0, import_node_path3.dirname)(filepath), { recursive: true });
6872
- const temporary = `${filepath}.tmp-${process.pid}-${(0, import_node_crypto2.randomUUID)()}`;
6985
+ (0, import_node_fs5.mkdirSync)((0, import_node_path4.dirname)(filepath), { recursive: true });
6986
+ const temporary = `${filepath}.tmp-${process.pid}-${(0, import_node_crypto3.randomUUID)()}`;
6873
6987
  let descriptor = null;
6874
6988
  try {
6875
- descriptor = (0, import_node_fs4.openSync)(temporary, "wx", 384);
6876
- (0, import_node_fs4.fchmodSync)(descriptor, 384);
6877
- (0, import_node_fs4.writeFileSync)(descriptor, `${JSON.stringify(value, null, 2)}
6989
+ descriptor = (0, import_node_fs5.openSync)(temporary, "wx", 384);
6990
+ (0, import_node_fs5.fchmodSync)(descriptor, 384);
6991
+ (0, import_node_fs5.writeFileSync)(descriptor, `${JSON.stringify(value, null, 2)}
6878
6992
  `);
6879
- (0, import_node_fs4.fsyncSync)(descriptor);
6880
- (0, import_node_fs4.closeSync)(descriptor);
6993
+ (0, import_node_fs5.fsyncSync)(descriptor);
6994
+ (0, import_node_fs5.closeSync)(descriptor);
6881
6995
  descriptor = null;
6882
- (0, import_node_fs4.renameSync)(temporary, filepath);
6996
+ (0, import_node_fs5.renameSync)(temporary, filepath);
6883
6997
  } catch (error) {
6884
- if (descriptor !== null) (0, import_node_fs4.closeSync)(descriptor);
6885
- (0, import_node_fs4.rmSync)(temporary, { force: true });
6998
+ if (descriptor !== null) (0, import_node_fs5.closeSync)(descriptor);
6999
+ (0, import_node_fs5.rmSync)(temporary, { force: true });
6886
7000
  throw error;
6887
7001
  }
6888
7002
  }
@@ -7041,8 +7155,8 @@ function isOpenPending() {
7041
7155
  }
7042
7156
 
7043
7157
  // cli/ws-bridge.ts
7044
- var import_node_fs6 = __toESM(require("node:fs"), 1);
7045
- var import_node_path5 = __toESM(require("node:path"), 1);
7158
+ var import_node_fs7 = __toESM(require("node:fs"), 1);
7159
+ var import_node_path6 = __toESM(require("node:path"), 1);
7046
7160
  var import_ws = require("ws");
7047
7161
 
7048
7162
  // src/simulator-route.ts
@@ -7121,20 +7235,21 @@ init_home_paths();
7121
7235
 
7122
7236
  // cli/pause-aware-timeout.ts
7123
7237
  var import_node_child_process = require("node:child_process");
7124
- var import_node_fs5 = require("node:fs");
7238
+ var import_node_fs6 = require("node:fs");
7125
7239
  var import_node_os2 = __toESM(require("node:os"), 1);
7126
- var import_node_path4 = __toESM(require("node:path"), 1);
7127
- var LEDGER_PATH = import_node_path4.default.join(
7128
- process.env.TM_HOME || import_node_path4.default.join(import_node_os2.default.homedir(), ".team-machine"),
7240
+ var import_node_path5 = __toESM(require("node:path"), 1);
7241
+ var LEDGER_PATH = import_node_path5.default.join(
7242
+ process.env.TM_HOME || import_node_path5.default.join(import_node_os2.default.homedir(), ".team-machine"),
7129
7243
  "governor-pauses.json"
7130
7244
  );
7131
7245
  var TICK_MS = 500;
7132
7246
  var timers = /* @__PURE__ */ new Set();
7133
7247
  var poll;
7248
+ var pollDueAt = 0;
7134
7249
  function pausedPids() {
7135
7250
  try {
7136
7251
  const ledger = JSON.parse(
7137
- (0, import_node_fs5.readFileSync)(LEDGER_PATH, "utf8")
7252
+ (0, import_node_fs6.readFileSync)(LEDGER_PATH, "utf8")
7138
7253
  );
7139
7254
  return Object.values(ledger).flatMap((procs) => procs.map((proc) => proc.pid));
7140
7255
  } catch {
@@ -7162,6 +7277,7 @@ function heldRoots(paused, roots) {
7162
7277
  return held;
7163
7278
  }
7164
7279
  function tick() {
7280
+ poll = void 0;
7165
7281
  const now = Date.now();
7166
7282
  const paused = pausedPids();
7167
7283
  const held = paused.length ? heldRoots(paused, new Set([...timers].map((timer) => timer.hostPid))) : /* @__PURE__ */ new Set();
@@ -7173,10 +7289,23 @@ function tick() {
7173
7289
  timer.fire();
7174
7290
  }
7175
7291
  }
7176
- if (timers.size === 0 && poll) {
7177
- clearInterval(poll);
7292
+ schedule();
7293
+ }
7294
+ function schedule() {
7295
+ if (timers.size === 0) {
7296
+ if (poll) clearTimeout(poll);
7178
7297
  poll = void 0;
7298
+ return;
7179
7299
  }
7300
+ const now = Date.now();
7301
+ const soonest = Math.min(
7302
+ ...[...timers].map((timer) => timer.remaining - (now - timer.accountedAt))
7303
+ );
7304
+ const due = now + Math.max(0, Math.min(TICK_MS, soonest));
7305
+ if (poll && pollDueAt <= due) return;
7306
+ if (poll) clearTimeout(poll);
7307
+ pollDueAt = due;
7308
+ poll = setTimeout(tick, due - now);
7180
7309
  }
7181
7310
  function setPauseAwareTimeout(fn, budgetMs, hostPid) {
7182
7311
  if (hostPid === void 0) {
@@ -7185,15 +7314,10 @@ function setPauseAwareTimeout(fn, budgetMs, hostPid) {
7185
7314
  }
7186
7315
  const timer = { hostPid, remaining: budgetMs, accountedAt: Date.now(), fire: fn };
7187
7316
  timers.add(timer);
7188
- if (!poll) {
7189
- poll = setInterval(tick, TICK_MS);
7190
- }
7317
+ schedule();
7191
7318
  return () => {
7192
7319
  timers.delete(timer);
7193
- if (timers.size === 0 && poll) {
7194
- clearInterval(poll);
7195
- poll = void 0;
7196
- }
7320
+ schedule();
7197
7321
  };
7198
7322
  }
7199
7323
 
@@ -7206,17 +7330,17 @@ function liveDevBridgeLockfiles() {
7206
7330
  return readDevBridgeLockfiles().filter((lockfile) => isDevBridgeLockfileFresh(lockfile));
7207
7331
  }
7208
7332
  function checkoutRoot(cwd) {
7209
- let current = import_node_path5.default.resolve(cwd);
7333
+ let current = import_node_path6.default.resolve(cwd);
7210
7334
  while (true) {
7211
- if (import_node_fs6.default.existsSync(import_node_path5.default.join(current, ".git"))) return current;
7212
- const parent = import_node_path5.default.dirname(current);
7335
+ if (import_node_fs7.default.existsSync(import_node_path6.default.join(current, ".git"))) return current;
7336
+ const parent = import_node_path6.default.dirname(current);
7213
7337
  if (parent === current) return null;
7214
7338
  current = parent;
7215
7339
  }
7216
7340
  }
7217
7341
  function pathContains(parent, child) {
7218
- const relative3 = import_node_path5.default.relative(parent, child);
7219
- return relative3 === "" || relative3 !== ".." && !relative3.startsWith(`..${import_node_path5.default.sep}`) && !import_node_path5.default.isAbsolute(relative3);
7342
+ const relative3 = import_node_path6.default.relative(parent, child);
7343
+ return relative3 === "" || relative3 !== ".." && !relative3.startsWith(`..${import_node_path6.default.sep}`) && !import_node_path6.default.isAbsolute(relative3);
7220
7344
  }
7221
7345
  function resolveDefaultDevBridgeLockfile() {
7222
7346
  const lockfiles = liveDevBridgeLockfiles();
@@ -7330,6 +7454,18 @@ var DisconnectedSimError = class extends Error {
7330
7454
  function disconnectedSavedSimMessage(simId, detail = "") {
7331
7455
  return `saved sim ${simId} is not connected${detail}; commands resume when it reconnects, or run \`peach list\` and \`peach use <sim>\`, or open a fresh sim`;
7332
7456
  }
7457
+ var TIMEOUT_UNIT_MS = { ms: 1, s: 1e3, m: 6e4 };
7458
+ function parseTimeoutMs(value) {
7459
+ const match = /^(\d+(?:\.\d+)?)(ms|s|m)?$/.exec(value.trim());
7460
+ const ms = match ? Number(match[1]) * TIMEOUT_UNIT_MS[match[2] ?? "ms"] : NaN;
7461
+ if (!(ms > 0)) {
7462
+ console.error(
7463
+ `--timeout takes a positive duration in milliseconds (or with an ms, s or m suffix), got "${value}"`
7464
+ );
7465
+ peachExit(2);
7466
+ }
7467
+ return ms;
7468
+ }
7333
7469
  var BRIDGE_VALUE_FLAGS_TABLE = [
7334
7470
  {
7335
7471
  names: ["--port", "-p"],
@@ -7344,7 +7480,7 @@ var BRIDGE_VALUE_FLAGS_TABLE = [
7344
7480
  names: ["--timeout"],
7345
7481
  apply: (state, value) => {
7346
7482
  if (value !== void 0) {
7347
- state.commandTimeoutMs = Number(value);
7483
+ state.commandTimeoutMs = parseTimeoutMs(value);
7348
7484
  state.explicitTimeout = true;
7349
7485
  }
7350
7486
  }
@@ -8336,7 +8472,7 @@ function waitReadyReason(status) {
8336
8472
  return `sim unreachable: ${status.bridgeError} \u2014 the target tab is closed or no sim is connected (check \`peach list\`, reopen with \`peach open\`)`;
8337
8473
  }
8338
8474
  const waitingOnGuestFetch = status.externalReady === false && /https?:\/\//.test(status.externalStatus);
8339
- const base = status.externalError ? `guest app errored: ${status.externalError}` : waitingOnGuestFetch ? `waiting on a guest fetch: ${status.externalStatus}` : status.loadingText ? `still showing "${status.loadingText}"` : status.externalReady === false ? "guest app is still loading" : status.flag !== true && status.targets > 0 ? "native content is rendered but the ready signal has not settled" : status.flag !== true ? "guest app has not emitted sootsim:externalAppReady" : status.targets <= 0 ? "ready flag emitted but no visible app content is inspectable yet" : "node tree is still changing";
8475
+ const base = status.externalError ? `guest app errored: ${status.externalError}` : waitingOnGuestFetch ? `waiting on a guest fetch: ${status.externalStatus}` : status.loadingText ? `still showing "${status.loadingText}"` : status.externalReady === false ? "guest app is still loading" : status.flag !== true && status.targets > 0 ? "native content is rendered but the ready signal has not settled" : status.flag !== true ? "guest app has not emitted sootsim:externalAppReady" : status.targets <= 0 && !status.paintedAppContent ? "ready flag emitted but no visible app content is inspectable yet" : "node tree is still changing";
8340
8476
  return !status.externalError && status.suppressedEntryError ? `${base} (suppressed entry error: ${status.suppressedEntryError})` : base;
8341
8477
  }
8342
8478
  async function inspectWaitReady(bridge, timeoutMs = 2e4, options = {}) {
@@ -10525,16 +10661,18 @@ function isRnxCaptureRegionAtlas(value) {
10525
10661
 
10526
10662
  // src/vite-plugin-one.ts
10527
10663
  var import_fs5 = __toESM(require("fs"), 1);
10528
- var import_node_crypto5 = require("node:crypto");
10664
+ var import_node_crypto6 = require("node:crypto");
10529
10665
  var import_node_url = require("node:url");
10530
10666
  var import_path4 = __toESM(require("path"), 1);
10531
10667
  var import_ws2 = require("ws");
10668
+ init_bundleGlobalFooter();
10669
+ init_cli_runtime();
10532
10670
 
10533
10671
  // src/dev-server-open.ts
10534
10672
  var import_node_child_process2 = require("node:child_process");
10535
- var import_node_crypto3 = require("node:crypto");
10536
- var import_node_fs7 = __toESM(require("node:fs"), 1);
10537
- var import_node_path6 = __toESM(require("node:path"), 1);
10673
+ var import_node_crypto4 = require("node:crypto");
10674
+ var import_node_fs8 = __toESM(require("node:fs"), 1);
10675
+ var import_node_path7 = __toESM(require("node:path"), 1);
10538
10676
  function resolveRnxDesktopAppName(open, projectRoot) {
10539
10677
  if (!open) return null;
10540
10678
  if (typeof open === "object") {
@@ -10542,8 +10680,8 @@ function resolveRnxDesktopAppName(open, projectRoot) {
10542
10680
  if (!appName) throw new Error("peach: open.appName must not be empty");
10543
10681
  return appName;
10544
10682
  }
10545
- const packageJsonPath = import_node_path6.default.join(projectRoot, "package.json");
10546
- const packageJson = JSON.parse(import_node_fs7.default.readFileSync(packageJsonPath, "utf8"));
10683
+ const packageJsonPath = import_node_path7.default.join(projectRoot, "package.json");
10684
+ const packageJson = JSON.parse(import_node_fs8.default.readFileSync(packageJsonPath, "utf8"));
10547
10685
  const packageName = packageJson && typeof packageJson === "object" ? Reflect.get(packageJson, "name") : void 0;
10548
10686
  if (typeof packageName !== "string" || !packageName.trim()) {
10549
10687
  throw new Error(`peach: ${packageJsonPath} must declare a package name`);
@@ -10557,7 +10695,7 @@ function tagRnxBundleForPlugin(bundleUrl, replacementOrigin, replacementToken, p
10557
10695
  url.searchParams.set("rnxAppName", appName);
10558
10696
  url.searchParams.set(
10559
10697
  "rnxProjectId",
10560
- (0, import_node_crypto3.createHash)("sha256").update(import_node_fs7.default.realpathSync(projectRoot)).digest("hex").slice(0, 32)
10698
+ (0, import_node_crypto4.createHash)("sha256").update(import_node_fs8.default.realpathSync(projectRoot)).digest("hex").slice(0, 32)
10561
10699
  );
10562
10700
  }
10563
10701
  url.searchParams.set("rnxReplacementOrigin", replacementOrigin);
@@ -13604,10 +13742,10 @@ function readInstalledNativePackageVersions(projectRoot) {
13604
13742
 
13605
13743
  // src/one-widget-metadata.ts
13606
13744
  var import_node_child_process3 = require("node:child_process");
13607
- var import_node_crypto4 = require("node:crypto");
13608
- var import_node_fs10 = __toESM(require("node:fs"), 1);
13609
- var import_node_module = require("node:module");
13610
- var import_node_path9 = __toESM(require("node:path"), 1);
13745
+ var import_node_crypto5 = require("node:crypto");
13746
+ var import_node_fs11 = __toESM(require("node:fs"), 1);
13747
+ var import_node_module2 = require("node:module");
13748
+ var import_node_path10 = __toESM(require("node:path"), 1);
13611
13749
  var import_node_util = require("node:util");
13612
13750
 
13613
13751
  // cli/internal-child.ts
@@ -13631,28 +13769,28 @@ function isHomeWidgetFamily(value) {
13631
13769
  }
13632
13770
 
13633
13771
  // src/swift-source-file.ts
13634
- var import_node_fs9 = __toESM(require("node:fs"), 1);
13635
- var import_node_path8 = __toESM(require("node:path"), 1);
13772
+ var import_node_fs10 = __toESM(require("node:fs"), 1);
13773
+ var import_node_path9 = __toESM(require("node:path"), 1);
13636
13774
  function readPackageFile(root, file, maxBytes) {
13637
- const canonicalRoot = import_node_fs9.default.realpathSync(root);
13638
- const relative3 = import_node_path8.default.relative(canonicalRoot, import_node_fs9.default.realpathSync(file));
13639
- if (relative3 === ".." || relative3.startsWith(`..${import_node_path8.default.sep}`) || import_node_path8.default.isAbsolute(relative3)) {
13775
+ const canonicalRoot = import_node_fs10.default.realpathSync(root);
13776
+ const relative3 = import_node_path9.default.relative(canonicalRoot, import_node_fs10.default.realpathSync(file));
13777
+ if (relative3 === ".." || relative3.startsWith(`..${import_node_path9.default.sep}`) || import_node_path9.default.isAbsolute(relative3)) {
13640
13778
  throw new Error(`swift input escapes the selected package: ${file}`);
13641
13779
  }
13642
- let ancestor = import_node_path8.default.resolve(file);
13780
+ let ancestor = import_node_path9.default.resolve(file);
13643
13781
  while (ancestor !== canonicalRoot) {
13644
- if (import_node_fs9.default.lstatSync(ancestor).isSymbolicLink()) {
13782
+ if (import_node_fs10.default.lstatSync(ancestor).isSymbolicLink()) {
13645
13783
  throw new Error(`swift input is a symlink: ${ancestor}`);
13646
13784
  }
13647
- const parent = import_node_path8.default.dirname(ancestor);
13785
+ const parent = import_node_path9.default.dirname(ancestor);
13648
13786
  if (parent === ancestor)
13649
13787
  throw new Error(`swift input escapes the selected package: ${file}`);
13650
13788
  ancestor = parent;
13651
13789
  }
13652
- const expected = import_node_fs9.default.statSync(file);
13653
- const fd = import_node_fs9.default.openSync(file, import_node_fs9.default.constants.O_RDONLY | import_node_fs9.default.constants.O_NOFOLLOW);
13790
+ const expected = import_node_fs10.default.statSync(file);
13791
+ const fd = import_node_fs10.default.openSync(file, import_node_fs10.default.constants.O_RDONLY | import_node_fs10.default.constants.O_NOFOLLOW);
13654
13792
  try {
13655
- const stat = import_node_fs9.default.fstatSync(fd);
13793
+ const stat = import_node_fs10.default.fstatSync(fd);
13656
13794
  if (stat.dev !== expected.dev || stat.ino !== expected.ino) {
13657
13795
  throw new Error(`swift input changed while opening: ${file}`);
13658
13796
  }
@@ -13662,16 +13800,16 @@ function readPackageFile(root, file, maxBytes) {
13662
13800
  const bytes = Buffer.alloc(stat.size + 1);
13663
13801
  let offset = 0;
13664
13802
  while (offset < bytes.length) {
13665
- const count = import_node_fs9.default.readSync(fd, bytes, offset, bytes.length - offset, null);
13803
+ const count = import_node_fs10.default.readSync(fd, bytes, offset, bytes.length - offset, null);
13666
13804
  if (count === 0) break;
13667
13805
  offset += count;
13668
13806
  }
13669
- if (offset !== stat.size || import_node_fs9.default.fstatSync(fd).size !== stat.size) {
13807
+ if (offset !== stat.size || import_node_fs10.default.fstatSync(fd).size !== stat.size) {
13670
13808
  throw new Error(`swift input changed while reading: ${file}`);
13671
13809
  }
13672
13810
  return bytes.subarray(0, offset);
13673
13811
  } finally {
13674
- import_node_fs9.default.closeSync(fd);
13812
+ import_node_fs10.default.closeSync(fd);
13675
13813
  }
13676
13814
  }
13677
13815
 
@@ -13710,8 +13848,8 @@ fs.writeFileSync(process.argv[2], JSON.stringify({
13710
13848
  function configStamp(files) {
13711
13849
  return JSON.stringify(
13712
13850
  files.map((file) => {
13713
- if (!import_node_fs10.default.existsSync(file)) return [file, null];
13714
- const stat = import_node_fs10.default.statSync(file);
13851
+ if (!import_node_fs11.default.existsSync(file)) return [file, null];
13852
+ const stat = import_node_fs11.default.statSync(file);
13715
13853
  return [file, stat.mtimeMs, stat.ctimeMs, stat.size];
13716
13854
  })
13717
13855
  );
@@ -13722,13 +13860,13 @@ async function readConfig(root) {
13722
13860
  const reading = reads.get(root);
13723
13861
  if (reading) return reading;
13724
13862
  const promise = (async () => {
13725
- (0, import_node_module.createRequire)(import_node_path9.default.join(root, "package.json")).resolve("one/vite");
13726
- const cache = import_node_path9.default.join(root, "node_modules/.cache/peach-widget-config");
13727
- import_node_fs10.default.mkdirSync(cache, { recursive: true });
13728
- const directory = import_node_fs10.default.mkdtempSync(import_node_path9.default.join(cache, "read-"));
13729
- const script = import_node_path9.default.join(directory, "read.mjs");
13730
- const result = import_node_path9.default.join(directory, "result.json");
13731
- import_node_fs10.default.writeFileSync(script, CONFIG_CHILD);
13863
+ (0, import_node_module2.createRequire)(import_node_path10.default.join(root, "package.json")).resolve("one/vite");
13864
+ const cache = import_node_path10.default.join(root, "node_modules/.cache/peach-widget-config");
13865
+ import_node_fs11.default.mkdirSync(cache, { recursive: true });
13866
+ const directory = import_node_fs11.default.mkdtempSync(import_node_path10.default.join(cache, "read-"));
13867
+ const script = import_node_path10.default.join(directory, "read.mjs");
13868
+ const result = import_node_path10.default.join(directory, "result.json");
13869
+ import_node_fs11.default.writeFileSync(script, CONFIG_CHILD);
13732
13870
  try {
13733
13871
  await run(process.execPath, [script, result], {
13734
13872
  cwd: root,
@@ -13736,7 +13874,7 @@ async function readConfig(root) {
13736
13874
  timeout: 3e4,
13737
13875
  maxBuffer: 1024 * 1024
13738
13876
  });
13739
- const value = JSON.parse(import_node_fs10.default.readFileSync(result, "utf8"));
13877
+ const value = JSON.parse(import_node_fs11.default.readFileSync(result, "utf8"));
13740
13878
  if (!isRecord(value) || !Array.isArray(value.watched) || !value.watched.every((file) => typeof file === "string"))
13741
13879
  throw new Error("One config loader returned invalid dependencies");
13742
13880
  if (!Array.isArray(value.urlSchemes) || !value.urlSchemes.every(
@@ -13759,20 +13897,20 @@ async function readConfig(root) {
13759
13897
  }
13760
13898
  const watched = [
13761
13899
  .../* @__PURE__ */ new Set([
13762
- import_node_path9.default.join(root, "package.json"),
13763
- ...value.watched.map((file) => import_node_path9.default.resolve(root, file))
13900
+ import_node_path10.default.join(root, "package.json"),
13901
+ ...value.watched.map((file) => import_node_path10.default.resolve(root, file))
13764
13902
  ])
13765
13903
  ];
13766
- const loaded2 = {
13904
+ const loaded3 = {
13767
13905
  widget,
13768
13906
  urlSchemes: value.urlSchemes,
13769
13907
  watched,
13770
13908
  stamp: configStamp(watched)
13771
13909
  };
13772
- configs.set(root, loaded2);
13773
- return loaded2;
13910
+ configs.set(root, loaded3);
13911
+ return loaded3;
13774
13912
  } finally {
13775
- import_node_fs10.default.rmSync(directory, { recursive: true, force: true });
13913
+ import_node_fs11.default.rmSync(directory, { recursive: true, force: true });
13776
13914
  }
13777
13915
  })();
13778
13916
  reads.set(root, promise);
@@ -13793,13 +13931,13 @@ function declaredFamilies(source) {
13793
13931
  return home;
13794
13932
  }
13795
13933
  async function readOneWidgetSources(appRoot) {
13796
- const root = import_node_fs10.default.realpathSync(appRoot);
13934
+ const root = import_node_fs11.default.realpathSync(appRoot);
13797
13935
  const config = await readConfig(root);
13798
13936
  if (!config.widget) return null;
13799
13937
  const widget = config.widget;
13800
13938
  const sourceFiles = {
13801
- "OneWidget.swift": import_node_path9.default.join(root, "ios/OneWidgets/OneWidget.swift"),
13802
- "OneWidgetContract.swift": import_node_path9.default.join(
13939
+ "OneWidget.swift": import_node_path10.default.join(root, "ios/OneWidgets/OneWidget.swift"),
13940
+ "OneWidgetContract.swift": import_node_path10.default.join(
13803
13941
  root,
13804
13942
  "ios",
13805
13943
  widget.appName,
@@ -13809,14 +13947,14 @@ async function readOneWidgetSources(appRoot) {
13809
13947
  const files = /* @__PURE__ */ new Map();
13810
13948
  const sources = {};
13811
13949
  for (const [name2, file] of Object.entries(sourceFiles)) {
13812
- if (!import_node_fs10.default.existsSync(file))
13950
+ if (!import_node_fs11.default.existsSync(file))
13813
13951
  throw new Error(`missing One widget prebuild source ${file}; run one prebuild`);
13814
13952
  const bytes = readPackageFile(root, file, MAX_SWIFT_COMPILE_SOURCE_BYTES);
13815
13953
  const text2 = bytes.toString("utf8");
13816
13954
  if (!Buffer.from(text2).equals(bytes))
13817
13955
  throw new Error(`One widget prebuild source is not UTF-8: ${file}`);
13818
13956
  files.set(name2, text2);
13819
- sources[import_node_path9.default.relative(root, file).split(import_node_path9.default.sep).join("/")] = (0, import_node_crypto4.createHash)("sha256").update(bytes).digest("hex");
13957
+ sources[import_node_path10.default.relative(root, file).split(import_node_path10.default.sep).join("/")] = (0, import_node_crypto5.createHash)("sha256").update(bytes).digest("hex");
13820
13958
  }
13821
13959
  const contract = files.get("OneWidgetContract.swift") ?? "";
13822
13960
  const source = files.get("OneWidget.swift") ?? "";
@@ -13840,7 +13978,7 @@ async function configuredOneWidget(appRoot, bundleUrl) {
13840
13978
  return {
13841
13979
  metadata: source.widget,
13842
13980
  projectRoot: source.root,
13843
- appIdentity: (0, import_node_crypto4.createHash)("sha256").update(JSON.stringify([source.root, source.widget.bundleId])).digest("hex"),
13981
+ appIdentity: (0, import_node_crypto5.createHash)("sha256").update(JSON.stringify([source.root, source.widget.bundleId])).digest("hex"),
13844
13982
  bundleUrl,
13845
13983
  packageUrl: new URL(`${SWIFT_PACKAGE_PATH}OneWidgets`, bundleUrl).href,
13846
13984
  urlSchemes: source.urlSchemes
@@ -13869,12 +14007,15 @@ function peachPlugin(options = {}) {
13869
14007
  vxrnNative({ root, dev }) {
13870
14008
  return {
13871
14009
  name: "peach:package-versions",
13872
- generateBundle(_options, bundle) {
14010
+ async generateBundle(_options, bundle) {
13873
14011
  if (options.enabled === false || dev) return;
13874
14012
  const versions = readInstalledNativePackageVersions(root);
14013
+ const { attachRolldownBundleInventory } = getCliRuntime().rolldown_bundle_inventory;
13875
14014
  for (const output of Object.values(bundle)) {
13876
14015
  if (output.type !== "chunk") continue;
13877
- output.code = insertPackageVersionsFooter(output.code, versions);
14016
+ output.code = await attachRolldownBundleInventory(
14017
+ insertPackageVersionsFooter(output.code, versions)
14018
+ );
13878
14019
  }
13879
14020
  }
13880
14021
  };
@@ -13893,6 +14034,135 @@ function peachPlugin(options = {}) {
13893
14034
  },
13894
14035
  async configureServer(server) {
13895
14036
  if (options.enabled === false) return;
14037
+ server.middlewares.use((req, res, next) => {
14038
+ if (!(req.url ?? "").split("?")[0].endsWith(".bundle")) {
14039
+ next();
14040
+ return;
14041
+ }
14042
+ res.setHeader(
14043
+ PACKAGE_VERSIONS_HEADER,
14044
+ JSON.stringify(readInstalledNativePackageVersions(server.config.root))
14045
+ );
14046
+ exposeHeader(res, PACKAGE_VERSIONS_HEADER);
14047
+ res.setHeader(ROLLDOWN_INVENTORY_HEADER, "1");
14048
+ exposeHeader(res, ROLLDOWN_INVENTORY_HEADER);
14049
+ const origWriteHead = res.writeHead.bind(res);
14050
+ const origWrite = res.write.bind(res);
14051
+ const origEnd = res.end.bind(res);
14052
+ let pendingStatus;
14053
+ let pendingMessage;
14054
+ const flushHead = () => {
14055
+ if (pendingStatus !== void 0 && !res.headersSent) {
14056
+ const code = pendingStatus;
14057
+ const msg = pendingMessage;
14058
+ pendingStatus = void 0;
14059
+ pendingMessage = void 0;
14060
+ if (typeof msg === "string") origWriteHead(code, msg);
14061
+ else origWriteHead(code);
14062
+ }
14063
+ };
14064
+ Reflect.set(
14065
+ res,
14066
+ "writeHead",
14067
+ function(statusCode, statusMessage, headers) {
14068
+ pendingStatus = statusCode;
14069
+ res.statusCode = statusCode;
14070
+ if (typeof statusMessage === "string") pendingMessage = statusMessage;
14071
+ const hdrs = typeof statusMessage === "object" && statusMessage !== null ? statusMessage : headers;
14072
+ if (hdrs && typeof hdrs === "object" && !Array.isArray(hdrs)) {
14073
+ for (const [key, value] of Object.entries(hdrs)) {
14074
+ if (key.toLowerCase() === "content-length") continue;
14075
+ if (typeof value === "string" || typeof value === "number" || Array.isArray(value)) {
14076
+ res.setHeader(key, value);
14077
+ }
14078
+ }
14079
+ }
14080
+ res.removeHeader("content-length");
14081
+ if (statusCode !== 200) res.removeHeader(ROLLDOWN_INVENTORY_HEADER);
14082
+ return res;
14083
+ }
14084
+ );
14085
+ const chunks = [];
14086
+ let buffering = false;
14087
+ const isBufferEncoding = (value) => typeof value === "string" && Buffer.isEncoding(value);
14088
+ const toBuffer = (chunk, encoding) => {
14089
+ if (chunk === void 0 || chunk === null || typeof chunk === "function")
14090
+ return null;
14091
+ if (Buffer.isBuffer(chunk)) return chunk;
14092
+ if (chunk instanceof Uint8Array) return Buffer.from(chunk);
14093
+ if (typeof chunk === "string")
14094
+ return Buffer.from(chunk, isBufferEncoding(encoding) ? encoding : "utf8");
14095
+ return null;
14096
+ };
14097
+ Reflect.set(res, "write", function(chunk, arg1) {
14098
+ const buf = toBuffer(chunk, arg1);
14099
+ if (!buf) {
14100
+ flushHead();
14101
+ return origWrite("");
14102
+ }
14103
+ if (!buffering) {
14104
+ const lower = buf.toString("utf8").toLowerCase();
14105
+ const contentType = String(res.getHeader("content-type") ?? "").toLowerCase();
14106
+ if (!contentType.includes("multipart/mixed") || lower.includes("content-type: text/javascript") || lower.includes("content-type: application/javascript")) {
14107
+ buffering = true;
14108
+ }
14109
+ }
14110
+ if (buffering) {
14111
+ chunks.push(buf);
14112
+ return true;
14113
+ }
14114
+ flushHead();
14115
+ return origWrite(buf);
14116
+ });
14117
+ Reflect.set(
14118
+ res,
14119
+ "end",
14120
+ function(chunk, arg1, arg2) {
14121
+ const callback = typeof chunk === "function" ? chunk : typeof arg1 === "function" ? arg1 : typeof arg2 === "function" ? arg2 : void 0;
14122
+ const finish = () => {
14123
+ flushHead();
14124
+ if (typeof callback === "function") {
14125
+ return origEnd(() => {
14126
+ Reflect.apply(callback, res, []);
14127
+ });
14128
+ }
14129
+ return origEnd();
14130
+ };
14131
+ const buf = toBuffer(chunk, arg1);
14132
+ if (buf) chunks.push(buf);
14133
+ if (chunks.length === 0 || res.statusCode && res.statusCode !== 200) {
14134
+ if (!res.headersSent) res.removeHeader(ROLLDOWN_INVENTORY_HEADER);
14135
+ flushHead();
14136
+ for (const queued of chunks) origWrite(queued);
14137
+ return finish();
14138
+ }
14139
+ const payload = Buffer.concat(chunks).toString("utf8");
14140
+ const contentType = String(res.getHeader("content-type") ?? "");
14141
+ void getCliRuntime().rolldown_bundle_inventory.attachRolldownBundleHttpPayload(
14142
+ payload,
14143
+ contentType
14144
+ ).then((annotated) => {
14145
+ if (!res.headersSent) res.removeHeader("content-length");
14146
+ flushHead();
14147
+ origWrite(Buffer.from(annotated, "utf8"));
14148
+ finish();
14149
+ }).catch((error) => {
14150
+ console.error("[peach] failed to attach rolldown bundle inventory", error);
14151
+ if (!res.headersSent) {
14152
+ res.removeHeader("content-length");
14153
+ res.removeHeader(ROLLDOWN_INVENTORY_HEADER);
14154
+ }
14155
+ flushHead();
14156
+ origWrite(Buffer.from(payload, "utf8"));
14157
+ finish();
14158
+ });
14159
+ return res;
14160
+ }
14161
+ );
14162
+ next();
14163
+ });
14164
+ const bundleLayer = server.middlewares.stack.pop();
14165
+ if (bundleLayer) server.middlewares.stack.unshift(bundleLayer);
13896
14166
  const { swiftPackageDirectories } = await import("vxrn");
13897
14167
  let swiftPackages;
13898
14168
  let swiftModuleRoot;
@@ -14080,7 +14350,7 @@ function peachPlugin(options = {}) {
14080
14350
  });
14081
14351
  const bundleUrl = options.bundleUrl || "/node_modules/one/metro-entry.bundle?platform=ios&dev=true&minify=false";
14082
14352
  const appName = resolveRnxDesktopAppName(options.open, server.config.root);
14083
- const replacementToken = (0, import_node_crypto5.randomUUID)();
14353
+ const replacementToken = (0, import_node_crypto6.randomUUID)();
14084
14354
  const bundleForOrigin = (origin) => {
14085
14355
  const fullBundleUrl = new URL(bundleUrl, `${origin}/`).toString();
14086
14356
  return tagRnxBundleForPlugin(
@@ -14114,16 +14384,6 @@ function peachPlugin(options = {}) {
14114
14384
  };
14115
14385
  next();
14116
14386
  });
14117
- server.middlewares.use((req, res, next) => {
14118
- if ((req.url ?? "").split("?")[0].endsWith(".bundle")) {
14119
- res.setHeader(
14120
- PACKAGE_VERSIONS_HEADER,
14121
- JSON.stringify(readInstalledNativePackageVersions(server.config.root))
14122
- );
14123
- exposeHeader(res, PACKAGE_VERSIONS_HEADER);
14124
- }
14125
- next();
14126
- });
14127
14387
  server.middlewares.use(async (req, res, next) => {
14128
14388
  if ((req.url || "").split("?")[0] !== "/__server-scan") return next();
14129
14389
  const scanPort = listeningPort();
@@ -14228,21 +14488,21 @@ function peachPlugin(options = {}) {
14228
14488
  // src/metro-plugin.ts
14229
14489
  var import_fs6 = __toESM(require("fs"), 1);
14230
14490
  var import_module2 = require("module");
14231
- var import_node_crypto7 = require("node:crypto");
14491
+ var import_node_crypto8 = require("node:crypto");
14232
14492
  var import_path5 = __toESM(require("path"), 1);
14233
14493
  init_app_project();
14234
14494
 
14235
14495
  // src/android-autolinking.ts
14236
14496
  var import_node_child_process4 = require("node:child_process");
14237
- var import_node_fs12 = __toESM(require("node:fs"), 1);
14238
- var import_node_module2 = require("node:module");
14239
- var import_node_path11 = __toESM(require("node:path"), 1);
14497
+ var import_node_fs13 = __toESM(require("node:fs"), 1);
14498
+ var import_node_module3 = require("node:module");
14499
+ var import_node_path12 = __toESM(require("node:path"), 1);
14240
14500
  var import_node_util2 = require("node:util");
14241
14501
  init_is_record();
14242
14502
  var run2 = (0, import_node_util2.promisify)(import_node_child_process4.execFile);
14243
14503
  var resolving = /* @__PURE__ */ new Map();
14244
14504
  async function resolveExpoAndroidAutolinking(appRoot) {
14245
- const root = import_node_fs12.default.realpathSync(appRoot);
14505
+ const root = import_node_fs13.default.realpathSync(appRoot);
14246
14506
  const existing = resolving.get(root);
14247
14507
  if (existing) return existing;
14248
14508
  const pending = resolveAndroidModules(root);
@@ -14256,7 +14516,7 @@ async function resolveExpoAndroidAutolinking(appRoot) {
14256
14516
  async function resolveAndroidModules(appRoot) {
14257
14517
  let autolinker;
14258
14518
  try {
14259
- autolinker = (0, import_node_module2.createRequire)(import_node_path11.default.join(appRoot, "package.json")).resolve(
14519
+ autolinker = (0, import_node_module3.createRequire)(import_node_path12.default.join(appRoot, "package.json")).resolve(
14260
14520
  "expo-modules-autolinking/package.json"
14261
14521
  );
14262
14522
  } catch (error) {
@@ -14266,7 +14526,7 @@ async function resolveAndroidModules(appRoot) {
14266
14526
  const { stdout } = await run2(
14267
14527
  process.execPath,
14268
14528
  [
14269
- import_node_path11.default.join(import_node_path11.default.dirname(autolinker), "bin/expo-modules-autolinking.js"),
14529
+ import_node_path12.default.join(import_node_path12.default.dirname(autolinker), "bin/expo-modules-autolinking.js"),
14270
14530
  "resolve",
14271
14531
  "--platform",
14272
14532
  "android",
@@ -14652,7 +14912,7 @@ function parseOpenStepPlist(text2) {
14652
14912
  // src/xcode-target-members.ts
14653
14913
  var NEVER_MEMBER = /(?:^|\/)(?:Info\.plist|[^/]+\.entitlements|[^/]+\.xcconfig|\.DS_Store)$/;
14654
14914
  var BUNDLE_DIR = /\.(xcassets|bundle|lproj|xcdatamodeld|scnassets|spriteatlas|rcproject|storyboardc|icon)$/;
14655
- function xcodePathResolver(objects, projectDir, join5) {
14915
+ function xcodePathResolver(objects, projectDir, join6) {
14656
14916
  const parents = /* @__PURE__ */ new Map();
14657
14917
  for (const [id, entry] of Object.entries(objects)) {
14658
14918
  if (!isDict(entry)) continue;
@@ -14670,11 +14930,11 @@ function xcodePathResolver(objects, projectDir, join5) {
14670
14930
  const own = str(entry.path) ?? "";
14671
14931
  const tree = str(entry.sourceTree) ?? "<group>";
14672
14932
  if (tree === "<absolute>") result = own;
14673
- else if (tree === "SOURCE_ROOT") result = join5(projectDir, own);
14933
+ else if (tree === "SOURCE_ROOT") result = join6(projectDir, own);
14674
14934
  else if (tree === "<group>") {
14675
14935
  const parent = parents.get(id);
14676
14936
  const base = parent ? resolve4(parent) : projectDir;
14677
- if (base !== null) result = join5(base, own);
14937
+ if (base !== null) result = join6(base, own);
14678
14938
  }
14679
14939
  }
14680
14940
  paths.set(id, result);
@@ -14682,7 +14942,7 @@ function xcodePathResolver(objects, projectDir, join5) {
14682
14942
  };
14683
14943
  return resolve4;
14684
14944
  }
14685
- function visitXcodeTargetMembers(objects, targetId, resolvePath, filesUnder, join5, visit3) {
14945
+ function visitXcodeTargetMembers(objects, targetId, resolvePath, filesUnder, join6, visit3) {
14686
14946
  const target = objects[targetId];
14687
14947
  if (!isDict(target)) return;
14688
14948
  for (const phaseId of list(target.buildPhases)) {
@@ -14718,7 +14978,7 @@ function visitXcodeTargetMembers(objects, targetId, resolvePath, filesUnder, joi
14718
14978
  for (const relative3 of list(exception.membershipExceptions))
14719
14979
  exceptions.add(relative3);
14720
14980
  }
14721
- const members = owned.has(groupId) ? filesUnder(folder) : [...exceptions].flatMap((relative3) => filesUnder(join5(folder, relative3)));
14981
+ const members = owned.has(groupId) ? filesUnder(folder) : [...exceptions].flatMap((relative3) => filesUnder(join6(folder, relative3)));
14722
14982
  for (const file of members) {
14723
14983
  const relative3 = file.slice(prefix2.length);
14724
14984
  const excepted = [...exceptions].some(
@@ -15115,7 +15375,7 @@ function nativeAppIdentityFromIos(files, parseInfoPlist, iosTarget, resourceUri)
15115
15375
  if (resourceUri) {
15116
15376
  if (!selectedTarget)
15117
15377
  throw new Error("native app icon target membership is unresolved");
15118
- const join5 = (base, own) => {
15378
+ const join6 = (base, own) => {
15119
15379
  const segments = [];
15120
15380
  for (const segment of `${base}/${own}`.split("/")) {
15121
15381
  if (segment === "" || segment === ".") continue;
@@ -15128,7 +15388,7 @@ function nativeAppIdentityFromIos(files, parseInfoPlist, iosTarget, resourceUri)
15128
15388
  const project = Object.values(objects).find(
15129
15389
  (object) => isRecord(object) && object.isa === "PBXProject"
15130
15390
  );
15131
- const projectDir = join5(
15391
+ const projectDir = join6(
15132
15392
  pbxprojPath.replace(/(?:^|\/)[^/]+\.xcodeproj\/project\.pbxproj$/, ""),
15133
15393
  isRecord(project) && typeof project.projectDirPath === "string" ? project.projectDirPath : ""
15134
15394
  );
@@ -15136,7 +15396,7 @@ function nativeAppIdentityFromIos(files, parseInfoPlist, iosTarget, resourceUri)
15136
15396
  visitXcodeTargetMembers(
15137
15397
  objects,
15138
15398
  selectedTarget.id,
15139
- xcodePathResolver(objects, projectDir, join5),
15399
+ xcodePathResolver(objects, projectDir, join6),
15140
15400
  (file) => {
15141
15401
  if (Object.hasOwn(files, file)) return [file];
15142
15402
  const prefix2 = file === "" ? "" : `${file.replace(/\/$/, "")}/`;
@@ -15144,7 +15404,7 @@ function nativeAppIdentityFromIos(files, parseInfoPlist, iosTarget, resourceUri)
15144
15404
  (path20) => path20.startsWith(prefix2) && !/(?:^|\/)\./.test(path20.slice(prefix2.length))
15145
15405
  );
15146
15406
  },
15147
- join5,
15407
+ join6,
15148
15408
  (file, kind) => {
15149
15409
  if (kind === "resource") resources.add(file);
15150
15410
  }
@@ -15237,9 +15497,9 @@ function extractNativeAppIdentityFromFiles(files, platform, parseInfoPlist, iosT
15237
15497
  }
15238
15498
 
15239
15499
  // src/native-app-identity-project.ts
15240
- var import_node_fs14 = __toESM(require("node:fs"), 1);
15241
- var import_node_module3 = require("node:module");
15242
- var import_node_path14 = __toESM(require("node:path"), 1);
15500
+ var import_node_fs15 = __toESM(require("node:fs"), 1);
15501
+ var import_node_module4 = require("node:module");
15502
+ var import_node_path15 = __toESM(require("node:path"), 1);
15243
15503
  init_is_record();
15244
15504
 
15245
15505
  // src/plist.ts
@@ -15250,13 +15510,13 @@ function parsePlistSource(source) {
15250
15510
 
15251
15511
  // src/xcode-project.ts
15252
15512
  var import_node_child_process5 = require("node:child_process");
15253
- var import_node_crypto6 = require("node:crypto");
15254
- var import_node_fs13 = __toESM(require("node:fs"), 1);
15255
- var import_node_path13 = __toESM(require("node:path"), 1);
15513
+ var import_node_crypto7 = require("node:crypto");
15514
+ var import_node_fs14 = __toESM(require("node:fs"), 1);
15515
+ var import_node_path14 = __toESM(require("node:path"), 1);
15256
15516
  var import_plist2 = __toESM(require("plist"), 1);
15257
15517
 
15258
15518
  // src/xcode-json-project.ts
15259
- var import_node_path12 = __toESM(require("node:path"), 1);
15519
+ var import_node_path13 = __toESM(require("node:path"), 1);
15260
15520
  var import_json52 = __toESM(require_lib(), 1);
15261
15521
  var isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
15262
15522
  var text = (value) => typeof value === "string" ? value : void 0;
@@ -15272,7 +15532,7 @@ var PHASE_ISA = {
15272
15532
  function readXcodeJsonProject(xcodeproj, source) {
15273
15533
  const json = import_json52.default.parse(source);
15274
15534
  if (!isJsonObject(json)) throw new Error(`${xcodeproj}/project.xcproj is not an object`);
15275
- const projectDir = import_node_path12.default.dirname(xcodeproj);
15535
+ const projectDir = import_node_path13.default.dirname(xcodeproj);
15276
15536
  const objects = {};
15277
15537
  let next = 0;
15278
15538
  const add = (entry, id) => {
@@ -15285,7 +15545,7 @@ function readXcodeJsonProject(xcodeproj, source) {
15285
15545
  const base = /^<([A-Z]+)>\/(.*)$/.exec(raw);
15286
15546
  if (base) {
15287
15547
  if (base[1] === "PROJECT")
15288
- return { sourceTree: "<absolute>", path: import_node_path12.default.join(projectDir, base[2]) };
15548
+ return { sourceTree: "<absolute>", path: import_node_path13.default.join(projectDir, base[2]) };
15289
15549
  if (base[1] === "PRODUCTS")
15290
15550
  return { sourceTree: "BUILT_PRODUCTS_DIR", path: base[2] };
15291
15551
  return null;
@@ -15293,7 +15553,7 @@ function readXcodeJsonProject(xcodeproj, source) {
15293
15553
  const unescaped = raw.replaceAll("\\<", "<");
15294
15554
  if (unescaped.startsWith("/")) return { sourceTree: "<absolute>", path: unescaped };
15295
15555
  if (unescaped.startsWith("~")) return null;
15296
- return groupDir === null ? null : { sourceTree: "<absolute>", path: import_node_path12.default.join(groupDir, unescaped) };
15556
+ return groupDir === null ? null : { sourceTree: "<absolute>", path: import_node_path13.default.join(groupDir, unescaped) };
15297
15557
  };
15298
15558
  const memberships = [];
15299
15559
  const folders = [];
@@ -15304,7 +15564,7 @@ function readXcodeJsonProject(xcodeproj, source) {
15304
15564
  const kind = text(entry.kind) ?? "file-reference";
15305
15565
  const raw = text(entry.path) ?? "";
15306
15566
  const located = raw === "" ? null : locate(raw, parent.dir);
15307
- const name2 = text(entry.name) ?? import_node_path12.default.basename(raw);
15567
+ const name2 = text(entry.name) ?? import_node_path13.default.basename(raw);
15308
15568
  const node = { id: "", name: name2, dir: null, parent, children: [] };
15309
15569
  if (kind === "group" || kind === "variant-group" || kind === "version-group") {
15310
15570
  node.dir = raw === "" ? parent.dir : located?.sourceTree === "<absolute>" ? located.path : null;
@@ -15419,7 +15679,7 @@ function readXcodeJsonProject(xcodeproj, source) {
15419
15679
  if (!isObject(entry)) continue;
15420
15680
  const repository = text(entry.repository);
15421
15681
  const local = text(entry.path);
15422
- const name2 = local !== void 0 ? import_node_path12.default.basename(import_node_path12.default.resolve(import_node_path12.default.dirname(xcodeproj), local)) : import_node_path12.default.basename(repository ?? "").replace(/\.git$/, "");
15682
+ const name2 = local !== void 0 ? import_node_path13.default.basename(import_node_path13.default.resolve(import_node_path13.default.dirname(xcodeproj), local)) : import_node_path13.default.basename(repository ?? "").replace(/\.git$/, "");
15423
15683
  const id = text(entry.kind) === "local" && local !== void 0 ? add({ isa: "XCLocalSwiftPackageReference", relativePath: local }) : add({ isa: "XCRemoteSwiftPackageReference", repositoryURL: repository ?? "" });
15424
15684
  packageIds.set(name2.toLowerCase(), id);
15425
15685
  }
@@ -15602,28 +15862,28 @@ var CONDITIONS = {
15602
15862
  variant: "normal"
15603
15863
  };
15604
15864
  function walkFiles(dir) {
15605
- if (!import_node_fs13.default.existsSync(dir)) return [];
15865
+ if (!import_node_fs14.default.existsSync(dir)) return [];
15606
15866
  const out = [];
15607
- for (const entry of import_node_fs13.default.readdirSync(dir, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
15867
+ for (const entry of import_node_fs14.default.readdirSync(dir, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
15608
15868
  if (entry.name.startsWith(".")) continue;
15609
- const full = import_node_path13.default.join(dir, entry.name);
15869
+ const full = import_node_path14.default.join(dir, entry.name);
15610
15870
  if (entry.isDirectory()) out.push(...walkFiles(full));
15611
15871
  else if (entry.isFile()) out.push(full);
15612
15872
  }
15613
15873
  return out;
15614
15874
  }
15615
- var isDirectory = (dir) => import_node_fs13.default.existsSync(dir) && import_node_fs13.default.statSync(dir).isDirectory();
15875
+ var isDirectory = (dir) => import_node_fs14.default.existsSync(dir) && import_node_fs14.default.statSync(dir).isDirectory();
15616
15876
  function readXcconfig(file, read) {
15617
- if (read.includes(file) || !import_node_fs13.default.existsSync(file)) return {};
15877
+ if (read.includes(file) || !import_node_fs14.default.existsSync(file)) return {};
15618
15878
  read.push(file);
15619
15879
  const settings = {};
15620
- for (const raw of import_node_fs13.default.readFileSync(file, "utf8").split("\n")) {
15880
+ for (const raw of import_node_fs14.default.readFileSync(file, "utf8").split("\n")) {
15621
15881
  const line = raw.replace(/\/\/.*$/, "").trim();
15622
15882
  const include = /^#include\??\s+"([^"]+)"/.exec(line);
15623
15883
  if (include) {
15624
15884
  Object.assign(
15625
15885
  settings,
15626
- readXcconfig(import_node_path13.default.resolve(import_node_path13.default.dirname(file), include[1]), read)
15886
+ readXcconfig(import_node_path14.default.resolve(import_node_path14.default.dirname(file), include[1]), read)
15627
15887
  );
15628
15888
  continue;
15629
15889
  }
@@ -15673,22 +15933,22 @@ function decodeXml(text2) {
15673
15933
  return text2.replaceAll("&quot;", '"').replaceAll("&apos;", "'").replaceAll("&lt;", "<").replaceAll("&gt;", ">").replaceAll("&amp;", "&");
15674
15934
  }
15675
15935
  function workspaceReferences(workspace) {
15676
- const data = import_node_path13.default.join(workspace, "contents.xcworkspacedata");
15677
- if (!import_node_fs13.default.existsSync(data))
15936
+ const data = import_node_path14.default.join(workspace, "contents.xcworkspacedata");
15937
+ if (!import_node_fs14.default.existsSync(data))
15678
15938
  throw new Error(`${workspace} has no contents.xcworkspacedata`);
15679
- const container = import_node_path13.default.dirname(workspace);
15939
+ const container = import_node_path14.default.dirname(workspace);
15680
15940
  const locate = (location, base) => {
15681
15941
  const colon = location.indexOf(":");
15682
15942
  const kind = location.slice(0, colon);
15683
15943
  const rest = location.slice(colon + 1);
15684
- if (kind === "group") return import_node_path13.default.resolve(base, rest);
15685
- if (kind === "container" || kind === "self") return import_node_path13.default.resolve(container, rest);
15686
- if (kind === "absolute") return import_node_path13.default.resolve(rest);
15687
- throw new Error(`${import_node_path13.default.basename(workspace)} has an unsupported location ${location}`);
15944
+ if (kind === "group") return import_node_path14.default.resolve(base, rest);
15945
+ if (kind === "container" || kind === "self") return import_node_path14.default.resolve(container, rest);
15946
+ if (kind === "absolute") return import_node_path14.default.resolve(rest);
15947
+ throw new Error(`${import_node_path14.default.basename(workspace)} has an unsupported location ${location}`);
15688
15948
  };
15689
15949
  const groups = [container];
15690
15950
  const references = [];
15691
- for (const [, closing, tag, attributes, selfClosing] of import_node_fs13.default.readFileSync(data, "utf8").matchAll(/<(\/?)(Group|FileRef)\b([^>]*?)(\/?)>/g)) {
15951
+ for (const [, closing, tag, attributes, selfClosing] of import_node_fs14.default.readFileSync(data, "utf8").matchAll(/<(\/?)(Group|FileRef)\b([^>]*?)(\/?)>/g)) {
15692
15952
  if (closing) {
15693
15953
  if (tag === "Group") groups.pop();
15694
15954
  continue;
@@ -15701,11 +15961,11 @@ function workspaceReferences(workspace) {
15701
15961
  }
15702
15962
  return references;
15703
15963
  }
15704
- var loaded = /* @__PURE__ */ new Map();
15964
+ var loaded2 = /* @__PURE__ */ new Map();
15705
15965
  function xcodeProjectFile(xcodeproj) {
15706
15966
  for (const name2 of ["project.pbxproj", "project.xcproj"]) {
15707
- const file = import_node_path13.default.join(xcodeproj, name2);
15708
- if (import_node_fs13.default.existsSync(file)) return file;
15967
+ const file = import_node_path14.default.join(xcodeproj, name2);
15968
+ if (import_node_fs14.default.existsSync(file)) return file;
15709
15969
  }
15710
15970
  return null;
15711
15971
  }
@@ -15713,10 +15973,10 @@ function loadProject(xcodeproj) {
15713
15973
  const projectFile = xcodeProjectFile(xcodeproj);
15714
15974
  if (!projectFile)
15715
15975
  throw new Error(`${xcodeproj} has no project.pbxproj or project.xcproj`);
15716
- const mtimeMs = import_node_fs13.default.statSync(projectFile).mtimeMs;
15717
- const cached2 = loaded.get(projectFile);
15976
+ const mtimeMs = import_node_fs14.default.statSync(projectFile).mtimeMs;
15977
+ const cached2 = loaded2.get(projectFile);
15718
15978
  if (cached2?.mtimeMs === mtimeMs) return cached2.project;
15719
- const source = import_node_fs13.default.readFileSync(projectFile, "utf8");
15979
+ const source = import_node_fs14.default.readFileSync(projectFile, "utf8");
15720
15980
  const root = projectFile.endsWith(".xcproj") ? readXcodeJsonProject(xcodeproj, source) : parseOpenStepPlist(source);
15721
15981
  if (!isDict(root) || !isDict(root.objects)) {
15722
15982
  throw new Error(`${projectFile} has no objects table`);
@@ -15730,10 +15990,10 @@ function loadProject(xcodeproj) {
15730
15990
  if (!project || project.isa !== "PBXProject") {
15731
15991
  throw new Error(`${projectFile} has no PBXProject root`);
15732
15992
  }
15733
- const projectDir = import_node_fs13.default.realpathSync(
15734
- import_node_path13.default.resolve(import_node_path13.default.dirname(xcodeproj), str(project.projectDirPath) ?? "")
15993
+ const projectDir = import_node_fs14.default.realpathSync(
15994
+ import_node_path14.default.resolve(import_node_path14.default.dirname(xcodeproj), str(project.projectDirPath) ?? "")
15735
15995
  );
15736
- const resolvePath = xcodePathResolver(objects, projectDir, import_node_path13.default.join);
15996
+ const resolvePath = xcodePathResolver(objects, projectDir, import_node_path14.default.join);
15737
15997
  const result = {
15738
15998
  xcodeproj,
15739
15999
  projectFile,
@@ -15743,7 +16003,7 @@ function loadProject(xcodeproj) {
15743
16003
  object,
15744
16004
  resolvePath
15745
16005
  };
15746
- loaded.set(projectFile, { mtimeMs, project: result });
16006
+ loaded2.set(projectFile, { mtimeMs, project: result });
15747
16007
  return result;
15748
16008
  }
15749
16009
  function defaultConfiguration(project) {
@@ -15767,8 +16027,8 @@ function targetSettings(ref, configuration, builtins, options = {}) {
15767
16027
  const relative3 = str(config.baseConfigurationReferenceRelativePath);
15768
16028
  const own = isDict(config.buildSettings) ? config.buildSettings : {};
15769
16029
  const directory = anchor ? project.resolvePath(anchor) : null;
15770
- const baseFile = base ? project.resolvePath(base) : directory && relative3 ? import_node_path13.default.resolve(directory, relative3) : null;
15771
- if (options.requireSources !== false && (base || anchor || relative3) && (!baseFile || !import_node_fs13.default.existsSync(baseFile)))
16030
+ const baseFile = base ? project.resolvePath(base) : directory && relative3 ? import_node_path14.default.resolve(directory, relative3) : null;
16031
+ if (options.requireSources !== false && (base || anchor || relative3) && (!baseFile || !import_node_fs14.default.existsSync(baseFile)))
15772
16032
  throw new Error(
15773
16033
  `Unable to open base configuration reference file '${baseFile ?? base ?? relative3 ?? anchor}'`
15774
16034
  );
@@ -15843,26 +16103,26 @@ function settingList(value) {
15843
16103
  return items2;
15844
16104
  }
15845
16105
  function expandSearchPath(directory, rules) {
15846
- if (import_node_path13.default.basename(directory) !== "**") return [directory];
16106
+ if (import_node_path14.default.basename(directory) !== "**") return [directory];
15847
16107
  const expanded = [];
15848
16108
  const seen = /* @__PURE__ */ new Set();
15849
- const queue = [import_node_path13.default.dirname(directory)];
16109
+ const queue = [import_node_path14.default.dirname(directory)];
15850
16110
  for (let at = 0; at < queue.length; at++) {
15851
16111
  const current = queue[at];
15852
16112
  let real;
15853
16113
  try {
15854
- real = import_node_fs13.default.realpathSync(current);
16114
+ real = import_node_fs14.default.realpathSync(current);
15855
16115
  } catch {
15856
16116
  continue;
15857
16117
  }
15858
- if (!import_node_fs13.default.statSync(real).isDirectory() || seen.has(real)) continue;
16118
+ if (!import_node_fs14.default.statSync(real).isDirectory() || seen.has(real)) continue;
15859
16119
  seen.add(real);
15860
16120
  expanded.push(current);
15861
- for (const entry of import_node_fs13.default.readdirSync(real, { withFileTypes: true }).sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0)) {
16121
+ for (const entry of import_node_fs14.default.readdirSync(real, { withFileTypes: true }).sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0)) {
15862
16122
  if (entry.isSymbolicLink() ? !rules.followLinks : !entry.isDirectory()) continue;
15863
16123
  if (rules.excluded.some((pattern) => pattern.test(entry.name)) && !rules.included.some((pattern) => pattern.test(entry.name)))
15864
16124
  continue;
15865
- queue.push(import_node_path13.default.join(current, entry.name));
16125
+ queue.push(import_node_path14.default.join(current, entry.name));
15866
16126
  }
15867
16127
  }
15868
16128
  return expanded;
@@ -15916,7 +16176,7 @@ function targetMembers(ref, settings, options, settingKeys, projectInputs) {
15916
16176
  const phase = project.object(phaseId);
15917
16177
  if (phase?.isa !== "PBXShellScriptBuildPhase") continue;
15918
16178
  const script = str(phase.name) ?? phaseId;
15919
- const absolute = (raw) => import_node_path13.default.resolve(project.projectDir, expand(raw, settings));
16179
+ const absolute = (raw) => import_node_path14.default.resolve(project.projectDir, expand(raw, settings));
15920
16180
  const inputs = list(phase.inputPaths).map(absolute);
15921
16181
  const outputs = list(phase.outputPaths).map(absolute);
15922
16182
  const fileLists = /* @__PURE__ */ new Map();
@@ -15925,10 +16185,10 @@ function targetMembers(ref, settings, options, settingKeys, projectInputs) {
15925
16185
  kind === "INPUT" ? phase.inputFileListPaths : phase.outputFileListPaths
15926
16186
  ).map((raw) => {
15927
16187
  const file = absolute(raw);
15928
- if (!import_node_fs13.default.existsSync(file)) {
16188
+ if (!import_node_fs14.default.existsSync(file)) {
15929
16189
  return { file, entries: [] };
15930
16190
  }
15931
- const entries = import_node_fs13.default.readFileSync(file, "utf8").split(/\r?\n/).map((line) => line.trim()).filter((line) => line !== "" && !line.startsWith("#")).map(absolute);
16191
+ const entries = import_node_fs14.default.readFileSync(file, "utf8").split(/\r?\n/).map((line) => line.trim()).filter((line) => line !== "" && !line.startsWith("#")).map(absolute);
15932
16192
  return { file, entries };
15933
16193
  });
15934
16194
  fileLists.set(kind, lists);
@@ -15946,13 +16206,13 @@ function targetMembers(ref, settings, options, settingKeys, projectInputs) {
15946
16206
  ...fileLists.get("OUTPUT").map((item) => item.file)
15947
16207
  ];
15948
16208
  if (allOutputs.some((file) => file.endsWith(".swift"))) {
15949
- for (const file of inputFiles) if (import_node_fs13.default.existsSync(file)) projectInputs.add(file);
16209
+ for (const file of inputFiles) if (import_node_fs14.default.existsSync(file)) projectInputs.add(file);
15950
16210
  }
15951
16211
  if (options.prepareGeneratedSources && options.requireSources !== false && allOutputs.some((file) => file.endsWith(".swift"))) {
15952
- const phaseDir = import_node_path13.default.join(settings("TARGET_TEMP_DIR"), `Script-${phaseId}`);
16212
+ const phaseDir = import_node_path14.default.join(settings("TARGET_TEMP_DIR"), `Script-${phaseId}`);
15953
16213
  for (const lists of fileLists.values())
15954
16214
  for (const { file } of lists)
15955
- if (!import_node_fs13.default.existsSync(file))
16215
+ if (!import_node_fs14.default.existsSync(file))
15956
16216
  throw new Error(
15957
16217
  `${targetName}: Run Script "${script}" missing file list ${file}`
15958
16218
  );
@@ -15971,32 +16231,32 @@ function targetMembers(ref, settings, options, settingKeys, projectInputs) {
15971
16231
  const lists = fileLists.get(kind);
15972
16232
  env[`SCRIPT_${kind}_FILE_LIST_COUNT`] = String(lists.length);
15973
16233
  lists.forEach((_item, index) => {
15974
- env[`SCRIPT_${kind}_FILE_LIST_${index}`] = import_node_path13.default.join(
16234
+ env[`SCRIPT_${kind}_FILE_LIST_${index}`] = import_node_path14.default.join(
15975
16235
  phaseDir,
15976
16236
  `${kind}-${index}.xcfilelist`
15977
16237
  );
15978
16238
  });
15979
16239
  }
15980
- const signature = (0, import_node_crypto6.createHash)("sha256").update(
16240
+ const signature = (0, import_node_crypto7.createHash)("sha256").update(
15981
16241
  JSON.stringify([phase, [...settingKeys].map((key2) => [key2, settings(key2)])])
15982
16242
  );
15983
16243
  for (const file of inputFiles) {
15984
16244
  signature.update(file);
15985
- if (import_node_fs13.default.existsSync(file)) {
15986
- const stat = import_node_fs13.default.statSync(file);
16245
+ if (import_node_fs14.default.existsSync(file)) {
16246
+ const stat = import_node_fs14.default.statSync(file);
15987
16247
  signature.update(`${stat.mtimeMs}:${stat.ctimeMs}:${stat.size}`);
15988
16248
  } else signature.update("missing");
15989
16249
  }
15990
16250
  const stamp = signature.digest("hex");
15991
16251
  const key = `${project.projectFile}:${targetId}:${phaseId}:${settings("CONFIGURATION")}`;
15992
- if (preparedSourcePhases.get(key) === stamp && allOutputs.every((file) => import_node_fs13.default.existsSync(file)))
16252
+ if (preparedSourcePhases.get(key) === stamp && allOutputs.every((file) => import_node_fs14.default.existsSync(file)))
15993
16253
  continue;
15994
- import_node_fs13.default.mkdirSync(phaseDir, { recursive: true });
15995
- import_node_fs13.default.mkdirSync(settings("BUILT_PRODUCTS_DIR"), { recursive: true });
15996
- import_node_fs13.default.mkdirSync(settings("DERIVED_FILE_DIR"), { recursive: true });
16254
+ import_node_fs14.default.mkdirSync(phaseDir, { recursive: true });
16255
+ import_node_fs14.default.mkdirSync(settings("BUILT_PRODUCTS_DIR"), { recursive: true });
16256
+ import_node_fs14.default.mkdirSync(settings("DERIVED_FILE_DIR"), { recursive: true });
15997
16257
  for (const [kind, lists] of fileLists)
15998
16258
  lists.forEach((item, index) => {
15999
- import_node_fs13.default.writeFileSync(
16259
+ import_node_fs14.default.writeFileSync(
16000
16260
  env[`SCRIPT_${kind}_FILE_LIST_${index}`],
16001
16261
  `${item.entries.join("\n")}
16002
16262
  `
@@ -16022,7 +16282,7 @@ ${output}`
16022
16282
  );
16023
16283
  }
16024
16284
  const missing = allOutputs.filter(
16025
- (file) => file.endsWith(".swift") && !import_node_fs13.default.existsSync(file)
16285
+ (file) => file.endsWith(".swift") && !import_node_fs14.default.existsSync(file)
16026
16286
  );
16027
16287
  if (missing.length > 0)
16028
16288
  throw new Error(
@@ -16035,8 +16295,8 @@ ${output}`
16035
16295
  project.objects,
16036
16296
  targetId,
16037
16297
  project.resolvePath,
16038
- (file) => isDirectory(file) ? walkFiles(file) : import_node_fs13.default.existsSync(file) ? [file] : [],
16039
- import_node_path13.default.join,
16298
+ (file) => isDirectory(file) ? walkFiles(file) : import_node_fs14.default.existsSync(file) ? [file] : [],
16299
+ import_node_path14.default.join,
16040
16300
  (file, kind) => {
16041
16301
  if (kind === "header") {
16042
16302
  headers.add(file);
@@ -16046,9 +16306,9 @@ ${output}`
16046
16306
  resources.add(file);
16047
16307
  return;
16048
16308
  }
16049
- if (!import_node_fs13.default.existsSync(file)) {
16309
+ if (!import_node_fs14.default.existsSync(file)) {
16050
16310
  if (options.requireSources === false) return;
16051
- const script = scriptForOutput.get(import_node_path13.default.normalize(file));
16311
+ const script = scriptForOutput.get(import_node_path14.default.normalize(file));
16052
16312
  throw new Error(
16053
16313
  script ? `${targetName}: missing generated source ${file} (Run Script "${script}" declares it in outputPaths; run the script or check in its output)` : `${targetName}: missing source ${file}`
16054
16314
  );
@@ -16059,7 +16319,7 @@ ${output}`
16059
16319
  );
16060
16320
  for (const [file, script] of scriptForOutput) {
16061
16321
  if (sources.has(file) || allSources.has(file)) continue;
16062
- if (!import_node_fs13.default.existsSync(file)) {
16322
+ if (!import_node_fs14.default.existsSync(file)) {
16063
16323
  if (options.requireSources === false) continue;
16064
16324
  throw new Error(
16065
16325
  `${targetName}: missing generated source ${file} (Run Script "${script}" declares it in outputPaths; run the script or check in its output)`
@@ -16078,8 +16338,8 @@ ${output}`
16078
16338
  function commonAncestor(dirs) {
16079
16339
  let common = dirs[0];
16080
16340
  for (const dir of dirs) {
16081
- while (common !== import_node_path13.default.dirname(common) && import_node_path13.default.relative(common, dir).startsWith(".."))
16082
- common = import_node_path13.default.dirname(common);
16341
+ while (common !== import_node_path14.default.dirname(common) && import_node_path14.default.relative(common, dir).startsWith(".."))
16342
+ common = import_node_path14.default.dirname(common);
16083
16343
  }
16084
16344
  return common;
16085
16345
  }
@@ -16089,8 +16349,8 @@ function workspaceProjects(xcodeprojOrWorkspace) {
16089
16349
  const projectAt = /* @__PURE__ */ new Map();
16090
16350
  const addProject = (xcodeproj) => {
16091
16351
  if (!xcodeProjectFile(xcodeproj)) return;
16092
- const key = import_node_fs13.default.realpathSync(xcodeproj);
16093
- if (projectAt.has(key) || key.split(import_node_path13.default.sep).includes("Pods")) return;
16352
+ const key = import_node_fs14.default.realpathSync(xcodeproj);
16353
+ if (projectAt.has(key) || key.split(import_node_path14.default.sep).includes("Pods")) return;
16094
16354
  const project = loadProject(key);
16095
16355
  projectAt.set(key, project);
16096
16356
  projects.push(project);
@@ -16106,7 +16366,7 @@ function workspaceProjects(xcodeprojOrWorkspace) {
16106
16366
  for (const reference of listed)
16107
16367
  if (reference.endsWith(".xcodeproj")) addProject(reference);
16108
16368
  if (projects.length === 0) {
16109
- throw new Error(`${import_node_path13.default.basename(xcodeprojOrWorkspace)} lists no Xcode project`);
16369
+ throw new Error(`${import_node_path14.default.basename(xcodeprojOrWorkspace)} lists no Xcode project`);
16110
16370
  }
16111
16371
  return { listed, projects, projectAt };
16112
16372
  }
@@ -16142,13 +16402,13 @@ function listXcodeAppTargets(xcodeprojOrWorkspace, options = {}) {
16142
16402
  return workspaceProjects(xcodeprojOrWorkspace).projects.flatMap(nativeTargets).filter((ref) => isIosAppTarget(ref, options)).map((ref) => str(ref.target.name) ?? ref.id);
16143
16403
  }
16144
16404
  function readXcodeAppTarget(input, targetName, configurationName, options = {}) {
16145
- const xcodeprojOrWorkspace = import_node_fs13.default.realpathSync(input);
16405
+ const xcodeprojOrWorkspace = import_node_fs14.default.realpathSync(input);
16146
16406
  const workspace = xcodeprojOrWorkspace.endsWith(".xcworkspace") ? xcodeprojOrWorkspace : null;
16147
16407
  const { listed, projects, projectAt } = workspaceProjects(xcodeprojOrWorkspace);
16148
16408
  const allTargets = projects.flatMap(nativeTargets);
16149
16409
  const appTargets = allTargets.filter((ref) => isIosAppTarget(ref, options));
16150
16410
  const appTargetNames = appTargets.map((ref) => str(ref.target.name) ?? ref.id);
16151
- const container = import_node_path13.default.basename(xcodeprojOrWorkspace);
16411
+ const container = import_node_path14.default.basename(xcodeprojOrWorkspace);
16152
16412
  const named = targetName ? appTargets.filter((ref) => ref.target.name === targetName) : appTargets;
16153
16413
  if (named.length !== 1) {
16154
16414
  throw new Error(
@@ -16161,15 +16421,15 @@ function readXcodeAppTarget(input, targetName, configurationName, options = {})
16161
16421
  for (const ref of allTargets) {
16162
16422
  const product = ref.project.object(str(ref.target.productReference));
16163
16423
  const file = str(product?.path);
16164
- if (file && !byProduct.has(import_node_path13.default.basename(file)))
16165
- byProduct.set(import_node_path13.default.basename(file), ref);
16424
+ if (file && !byProduct.has(import_node_path14.default.basename(file)))
16425
+ byProduct.set(import_node_path14.default.basename(file), ref);
16166
16426
  }
16167
16427
  const proxied = (project, proxyId) => {
16168
16428
  const proxy = project.object(proxyId);
16169
16429
  if (proxy?.isa !== "PBXContainerItemProxy") return void 0;
16170
16430
  const portal = str(proxy.containerPortal);
16171
16431
  const portalPath = project.resolvePath(portal ?? "");
16172
- const owner = project.object(portal)?.isa === "PBXProject" ? project : portalPath && import_node_fs13.default.existsSync(portalPath) ? projectAt.get(import_node_fs13.default.realpathSync(portalPath)) : void 0;
16432
+ const owner = project.object(portal)?.isa === "PBXProject" ? project : portalPath && import_node_fs14.default.existsSync(portalPath) ? projectAt.get(import_node_fs14.default.realpathSync(portalPath)) : void 0;
16173
16433
  const remote = str(proxy.remoteGlobalIDString);
16174
16434
  if (!owner || !remote) return void 0;
16175
16435
  return nativeTargets(owner).find(
@@ -16190,7 +16450,7 @@ function readXcodeAppTarget(input, targetName, configurationName, options = {})
16190
16450
  if (phase?.isa !== "PBXFrameworksBuildPhase") continue;
16191
16451
  for (const buildFileId of list(phase.files)) {
16192
16452
  const file = project.object(str(project.object(buildFileId)?.fileRef));
16193
- const resolved = file?.isa === "PBXReferenceProxy" ? proxied(project, str(file.remoteRef)) : file && str(file.sourceTree) === "BUILT_PRODUCTS_DIR" ? byProduct.get(import_node_path13.default.basename(str(file.path) ?? "")) : void 0;
16453
+ const resolved = file?.isa === "PBXReferenceProxy" ? proxied(project, str(file.remoteRef)) : file && str(file.sourceTree) === "BUILT_PRODUCTS_DIR" ? byProduct.get(import_node_path14.default.basename(str(file.path) ?? "")) : void 0;
16194
16454
  if (resolved) found.push(resolved);
16195
16455
  }
16196
16456
  }
@@ -16219,13 +16479,13 @@ function readXcodeAppTarget(input, targetName, configurationName, options = {})
16219
16479
  configuration,
16220
16480
  {
16221
16481
  TARGET_NAME: name2,
16222
- PROJECT_NAME: import_node_path13.default.basename(ref.project.xcodeproj, ".xcodeproj"),
16482
+ PROJECT_NAME: import_node_path14.default.basename(ref.project.xcodeproj, ".xcodeproj"),
16223
16483
  SRCROOT: ref.project.projectDir,
16224
16484
  SOURCE_ROOT: ref.project.projectDir,
16225
16485
  PROJECT_DIR: ref.project.projectDir,
16226
- SYMROOT: import_node_path13.default.join(ref.project.projectDir, ".build/peach-xcode/Build/Products"),
16486
+ SYMROOT: import_node_path14.default.join(ref.project.projectDir, ".build/peach-xcode/Build/Products"),
16227
16487
  BUILD_DIR: "$(SYMROOT)",
16228
- OBJROOT: import_node_path13.default.join(
16488
+ OBJROOT: import_node_path14.default.join(
16229
16489
  ref.project.projectDir,
16230
16490
  ".build/peach-xcode/Build/Intermediates.noindex"
16231
16491
  ),
@@ -16253,7 +16513,7 @@ function readXcodeAppTarget(input, targetName, configurationName, options = {})
16253
16513
  const implementations = members.allSources.filter(
16254
16514
  (file) => /\.(c|cc|cpp|cxx|m|mm)$/.test(file)
16255
16515
  );
16256
- const absolute = (file) => import_node_path13.default.resolve(ref.project.projectDir, file);
16516
+ const absolute = (file) => import_node_path14.default.resolve(ref.project.projectDir, file);
16257
16517
  const fileFlags = {};
16258
16518
  for (const phaseId of list(ref.target.buildPhases)) {
16259
16519
  const phase = ref.project.object(phaseId);
@@ -16298,7 +16558,7 @@ function readXcodeAppTarget(input, targetName, configurationName, options = {})
16298
16558
  ...headers,
16299
16559
  ...Object.keys(ref.project.objects).flatMap((id) => {
16300
16560
  const file = ref.project.resolvePath(id);
16301
- return file && /\.(h|hh|hpp|hxx|pch)$/.test(file) && import_node_fs13.default.existsSync(file) ? [file] : [];
16561
+ return file && /\.(h|hh|hpp|hxx|pch)$/.test(file) && import_node_fs14.default.existsSync(file) ? [file] : [];
16302
16562
  })
16303
16563
  ])
16304
16564
  ],
@@ -16343,8 +16603,8 @@ function readXcodeAppTarget(input, targetName, configurationName, options = {})
16343
16603
  }
16344
16604
  return value;
16345
16605
  };
16346
- const infoPlistFile = settings("INFOPLIST_FILE") ? import_node_path13.default.resolve(app.project.projectDir, settings("INFOPLIST_FILE")) : null;
16347
- const sourceInfo = infoPlistFile ? import_plist2.default.parse(import_node_fs13.default.readFileSync(infoPlistFile, "utf8")) : {};
16606
+ const infoPlistFile = settings("INFOPLIST_FILE") ? import_node_path14.default.resolve(app.project.projectDir, settings("INFOPLIST_FILE")) : null;
16607
+ const sourceInfo = infoPlistFile ? import_plist2.default.parse(import_node_fs14.default.readFileSync(infoPlistFile, "utf8")) : {};
16348
16608
  if (!sourceInfo || typeof sourceInfo !== "object" || Array.isArray(sourceInfo) || sourceInfo instanceof Date || Buffer.isBuffer(sourceInfo)) {
16349
16609
  throw new Error(`${module2.name} Info.plist must contain a dictionary`);
16350
16610
  }
@@ -16372,7 +16632,7 @@ function readXcodeAppTarget(input, targetName, configurationName, options = {})
16372
16632
  };
16373
16633
  }
16374
16634
  const localPackageDirs = [
16375
- ...listed.filter((reference) => import_node_fs13.default.existsSync(import_node_path13.default.join(reference, "Package.swift"))),
16635
+ ...listed.filter((reference) => import_node_fs14.default.existsSync(import_node_path14.default.join(reference, "Package.swift"))),
16376
16636
  ...projects.flatMap(
16377
16637
  (project) => Object.entries(project.objects).flatMap(([id, entry]) => {
16378
16638
  if (!isDict(entry)) return [];
@@ -16382,19 +16642,19 @@ function readXcodeAppTarget(input, targetName, configurationName, options = {})
16382
16642
  const packages = [];
16383
16643
  while (pending.length > 0) {
16384
16644
  const dir = pending.pop();
16385
- if (import_node_fs13.default.existsSync(import_node_path13.default.join(dir, "Package.swift"))) {
16645
+ if (import_node_fs14.default.existsSync(import_node_path14.default.join(dir, "Package.swift"))) {
16386
16646
  packages.push(dir);
16387
16647
  continue;
16388
16648
  }
16389
16649
  if (!isDirectory(dir)) continue;
16390
- for (const child of import_node_fs13.default.readdirSync(dir, { withFileTypes: true }))
16650
+ for (const child of import_node_fs14.default.readdirSync(dir, { withFileTypes: true }))
16391
16651
  if (child.isDirectory() && !child.name.startsWith("."))
16392
- pending.push(import_node_path13.default.join(dir, child.name));
16652
+ pending.push(import_node_path14.default.join(dir, child.name));
16393
16653
  }
16394
16654
  return packages;
16395
16655
  }
16396
- const candidate = entry.isa === "XCLocalSwiftPackageReference" ? import_node_path13.default.resolve(project.projectDir, str(entry.relativePath) ?? "") : entry.isa === "PBXFileReference" ? project.resolvePath(id) : null;
16397
- return candidate && import_node_fs13.default.existsSync(import_node_path13.default.join(candidate, "Package.swift")) ? [candidate] : [];
16656
+ const candidate = entry.isa === "XCLocalSwiftPackageReference" ? import_node_path14.default.resolve(project.projectDir, str(entry.relativePath) ?? "") : entry.isa === "PBXFileReference" ? project.resolvePath(id) : null;
16657
+ return candidate && import_node_fs14.default.existsSync(import_node_path14.default.join(candidate, "Package.swift")) ? [candidate] : [];
16398
16658
  })
16399
16659
  )
16400
16660
  ];
@@ -16418,7 +16678,7 @@ function readXcodeAppTarget(input, targetName, configurationName, options = {})
16418
16678
  product,
16419
16679
  source: reference?.isa === "XCRemoteSwiftPackageReference" ? { kind: "remote", url: str(reference.repositoryURL) ?? "" } : reference?.isa === "XCLocalSwiftPackageReference" ? {
16420
16680
  kind: "local",
16421
- dir: import_node_path13.default.resolve(
16681
+ dir: import_node_path14.default.resolve(
16422
16682
  project.projectDir,
16423
16683
  str(reference.relativePath) ?? ""
16424
16684
  )
@@ -16441,25 +16701,25 @@ function readXcodeAppTarget(input, targetName, configurationName, options = {})
16441
16701
  }
16442
16702
  }
16443
16703
  }
16444
- const resolvedFile = import_node_path13.default.join(
16445
- workspace ?? import_node_path13.default.join(xcodeprojOrWorkspace, "project.xcworkspace"),
16704
+ const resolvedFile = import_node_path14.default.join(
16705
+ workspace ?? import_node_path14.default.join(xcodeprojOrWorkspace, "project.xcworkspace"),
16446
16706
  "xcshareddata",
16447
16707
  "swiftpm",
16448
16708
  "Package.resolved"
16449
16709
  );
16450
- const packageResolved = import_node_fs13.default.existsSync(resolvedFile) ? [import_node_fs13.default.realpathSync(resolvedFile)] : [...new Set(localPackageDirs.map((dir) => import_node_path13.default.join(dir, "Package.resolved")))].filter((file) => import_node_fs13.default.existsSync(file)).map((file) => import_node_fs13.default.realpathSync(file)).sort();
16710
+ const packageResolved = import_node_fs14.default.existsSync(resolvedFile) ? [import_node_fs14.default.realpathSync(resolvedFile)] : [...new Set(localPackageDirs.map((dir) => import_node_path14.default.join(dir, "Package.resolved")))].filter((file) => import_node_fs14.default.existsSync(file)).map((file) => import_node_fs14.default.realpathSync(file)).sort();
16451
16711
  const used = order.map((ref) => ref.project);
16452
16712
  return {
16453
16713
  ...module2,
16454
16714
  rootDir: commonAncestor(
16455
16715
  [
16456
- workspace ? import_node_path13.default.dirname(workspace) : app.project.projectDir,
16716
+ workspace ? import_node_path14.default.dirname(workspace) : app.project.projectDir,
16457
16717
  ...used.map((project) => project.projectDir),
16458
16718
  ...localPackageDirs,
16459
16719
  ...linkedProducts.flatMap(
16460
- ({ source }) => source.kind === "local" && import_node_fs13.default.existsSync(source.dir) ? [source.dir] : []
16720
+ ({ source }) => source.kind === "local" && import_node_fs14.default.existsSync(source.dir) ? [source.dir] : []
16461
16721
  )
16462
- ].map((dir) => import_node_fs13.default.realpathSync(dir))
16722
+ ].map((dir) => import_node_fs14.default.realpathSync(dir))
16463
16723
  ),
16464
16724
  projectFiles: [
16465
16725
  .../* @__PURE__ */ new Set([...used.map((project) => project.projectFile), ...xcconfigs])
@@ -16470,7 +16730,7 @@ function readXcodeAppTarget(input, targetName, configurationName, options = {})
16470
16730
  frameworks,
16471
16731
  linkedProducts,
16472
16732
  localPackageDirs: [
16473
- ...new Set(localPackageDirs.map((dir) => import_node_fs13.default.realpathSync(dir)))
16733
+ ...new Set(localPackageDirs.map((dir) => import_node_fs14.default.realpathSync(dir)))
16474
16734
  ].sort(),
16475
16735
  binaryFrameworks: [...binaryFrameworks].map(([name2, file]) => ({ name: name2, path: file })).sort((left, right) => left.name.localeCompare(right.name)),
16476
16736
  packageResolved,
@@ -16544,7 +16804,7 @@ function readNativeAppIdentityFromXcodeTarget(app, parseInfoPlist = parsePlistSo
16544
16804
  const rtcAppGroupIdentifier = nonEmptyString2(dictionary.RTCAppGroupIdentifier);
16545
16805
  const screenShareExtensionBundleId = typeof dictionary.ScreenShareExtensionBundleId === "string" ? dictionary.ScreenShareExtensionBundleId : void 0;
16546
16806
  const rootModuleName = readRootModuleName(
16547
- app.allSources.filter((file) => /\.(?:swift|mm|m)$/.test(file) && import_node_fs14.default.existsSync(file)).map((file) => import_node_fs14.default.readFileSync(file, "utf8"))
16807
+ app.allSources.filter((file) => /\.(?:swift|mm|m)$/.test(file) && import_node_fs15.default.existsSync(file)).map((file) => import_node_fs15.default.readFileSync(file, "utf8"))
16548
16808
  );
16549
16809
  return {
16550
16810
  applicationName,
@@ -16565,7 +16825,7 @@ function readNativeAppIdentityFromXcodeTarget(app, parseInfoPlist = parsePlistSo
16565
16825
  googleSignIn: readGoogleSignInConfiguration(
16566
16826
  dictionary,
16567
16827
  Object.fromEntries(
16568
- app.resources.filter((file) => file.endsWith(".plist")).map((file) => [file, parseInfoPlist(import_node_fs14.default.readFileSync(file, "utf8"))])
16828
+ app.resources.filter((file) => file.endsWith(".plist")).map((file) => [file, parseInfoPlist(import_node_fs15.default.readFileSync(file, "utf8"))])
16569
16829
  )
16570
16830
  ),
16571
16831
  supportedInterfaceOrientations,
@@ -16574,11 +16834,11 @@ function readNativeAppIdentityFromXcodeTarget(app, parseInfoPlist = parsePlistSo
16574
16834
  alternateIconNames: [...alternateIconNames],
16575
16835
  appIconArtwork: resolveNativeAppIconArtwork(
16576
16836
  app.resources,
16577
- (file) => import_node_fs14.default.readFileSync(file, "utf8"),
16837
+ (file) => import_node_fs15.default.readFileSync(file, "utf8"),
16578
16838
  (file) => {
16579
- const extension = import_node_path14.default.extname(file).toLowerCase();
16839
+ const extension = import_node_path15.default.extname(file).toLowerCase();
16580
16840
  const contentType = extension === ".jpg" || extension === ".jpeg" ? "image/jpeg" : extension === ".webp" ? "image/webp" : "image/png";
16581
- return `data:${contentType};base64,${import_node_fs14.default.readFileSync(file).toString("base64")}`;
16841
+ return `data:${contentType};base64,${import_node_fs15.default.readFileSync(file).toString("base64")}`;
16582
16842
  },
16583
16843
  icons,
16584
16844
  app.appIconName,
@@ -16609,22 +16869,22 @@ function readNativeAppIdentityFromSources(projectRoot, platform, parseInfoPlist,
16609
16869
  const read = selectNativeAppIdentityReader(platform, {
16610
16870
  android: () => null,
16611
16871
  ios: () => {
16612
- const iosRoot = import_node_path14.default.join(projectRoot, "ios");
16613
- if (!import_node_fs14.default.existsSync(iosRoot)) return null;
16872
+ const iosRoot = import_node_path15.default.join(projectRoot, "ios");
16873
+ if (!import_node_fs15.default.existsSync(iosRoot)) return null;
16614
16874
  const files = {};
16615
- for (const entry of import_node_fs14.default.readdirSync(iosRoot, { withFileTypes: true })) {
16875
+ for (const entry of import_node_fs15.default.readdirSync(iosRoot, { withFileTypes: true })) {
16616
16876
  if (entry.name === "Pods") continue;
16617
16877
  if (entry.isDirectory()) {
16618
16878
  const names = entry.name.endsWith(".xcodeproj") ? ["project.pbxproj"] : ["Info.plist", "AppDelegate.swift", "AppDelegate.mm", "AppDelegate.m"];
16619
16879
  for (const name2 of names) {
16620
16880
  const relative3 = `ios/${entry.name}/${name2}`;
16621
- const file = import_node_path14.default.join(projectRoot, relative3);
16622
- if (import_node_fs14.default.existsSync(file)) files[relative3] = import_node_fs14.default.readFileSync(file, "utf8");
16881
+ const file = import_node_path15.default.join(projectRoot, relative3);
16882
+ if (import_node_fs15.default.existsSync(file)) files[relative3] = import_node_fs15.default.readFileSync(file, "utf8");
16623
16883
  }
16624
16884
  } else if (/AppDelegate\.(?:swift|mm|m)$/.test(entry.name)) {
16625
16885
  const relative3 = `ios/${entry.name}`;
16626
- const file = import_node_path14.default.join(projectRoot, relative3);
16627
- if (import_node_fs14.default.existsSync(file)) files[relative3] = import_node_fs14.default.readFileSync(file, "utf8");
16886
+ const file = import_node_path15.default.join(projectRoot, relative3);
16887
+ if (import_node_fs15.default.existsSync(file)) files[relative3] = import_node_fs15.default.readFileSync(file, "utf8");
16628
16888
  }
16629
16889
  }
16630
16890
  return extractNativeAppIdentityFromFiles(files, "ios", parseInfoPlist, iosTarget);
@@ -16635,41 +16895,41 @@ function readNativeAppIdentityFromSources(projectRoot, platform, parseInfoPlist,
16635
16895
  function readAndroidNativeAppIdentity(projectRoot, androidMergedManifest) {
16636
16896
  const files = {};
16637
16897
  if (androidMergedManifest) {
16638
- const file = import_node_path14.default.resolve(projectRoot, androidMergedManifest);
16639
- if (!import_node_fs14.default.existsSync(file)) return null;
16640
- files[androidMergedManifest] = import_node_fs14.default.readFileSync(file, "utf8");
16898
+ const file = import_node_path15.default.resolve(projectRoot, androidMergedManifest);
16899
+ if (!import_node_fs15.default.existsSync(file)) return null;
16900
+ files[androidMergedManifest] = import_node_fs15.default.readFileSync(file, "utf8");
16641
16901
  } else {
16642
- const androidRoot = import_node_path14.default.join(projectRoot, "android");
16643
- if (!import_node_fs14.default.existsSync(androidRoot)) return null;
16902
+ const androidRoot = import_node_path15.default.join(projectRoot, "android");
16903
+ if (!import_node_fs15.default.existsSync(androidRoot)) return null;
16644
16904
  const collect = (directory) => {
16645
- for (const entry of import_node_fs14.default.readdirSync(directory, { withFileTypes: true })) {
16646
- const file = import_node_path14.default.join(directory, entry.name);
16905
+ for (const entry of import_node_fs15.default.readdirSync(directory, { withFileTypes: true })) {
16906
+ const file = import_node_path15.default.join(directory, entry.name);
16647
16907
  if (entry.isDirectory()) collect(file);
16648
16908
  else if (entry.isFile() && entry.name === "AndroidManifest.xml")
16649
- files[import_node_path14.default.relative(projectRoot, file).split(import_node_path14.default.sep).join("/")] = import_node_fs14.default.readFileSync(file, "utf8");
16909
+ files[import_node_path15.default.relative(projectRoot, file).split(import_node_path15.default.sep).join("/")] = import_node_fs15.default.readFileSync(file, "utf8");
16650
16910
  }
16651
16911
  };
16652
- for (const module2 of import_node_fs14.default.readdirSync(androidRoot, { withFileTypes: true })) {
16912
+ for (const module2 of import_node_fs15.default.readdirSync(androidRoot, { withFileTypes: true })) {
16653
16913
  if (!module2.isDirectory()) continue;
16654
- const outputs = import_node_path14.default.join(
16914
+ const outputs = import_node_path15.default.join(
16655
16915
  androidRoot,
16656
16916
  module2.name,
16657
16917
  "build/intermediates/merged_manifests"
16658
16918
  );
16659
- if (import_node_fs14.default.existsSync(outputs)) collect(outputs);
16919
+ if (import_node_fs15.default.existsSync(outputs)) collect(outputs);
16660
16920
  }
16661
16921
  }
16662
16922
  for (const manifest of Object.keys(files)) {
16663
16923
  const resourceDirectory = androidMergedResourceValuesDirectory(manifest);
16664
16924
  if (!resourceDirectory) continue;
16665
- const absolute = import_node_path14.default.resolve(projectRoot, resourceDirectory);
16666
- if (!import_node_fs14.default.existsSync(absolute)) continue;
16667
- for (const entry of import_node_fs14.default.readdirSync(absolute, { withFileTypes: true })) {
16925
+ const absolute = import_node_path15.default.resolve(projectRoot, resourceDirectory);
16926
+ if (!import_node_fs15.default.existsSync(absolute)) continue;
16927
+ for (const entry of import_node_fs15.default.readdirSync(absolute, { withFileTypes: true })) {
16668
16928
  if (!entry.isDirectory() || !/^values(?:-|$)/.test(entry.name)) continue;
16669
- for (const resource of import_node_fs14.default.readdirSync(import_node_path14.default.join(absolute, entry.name))) {
16929
+ for (const resource of import_node_fs15.default.readdirSync(import_node_path15.default.join(absolute, entry.name))) {
16670
16930
  if (!resource.endsWith(".xml")) continue;
16671
16931
  const file = `${resourceDirectory}/${entry.name}/${resource}`;
16672
- files[file] = import_node_fs14.default.readFileSync(import_node_path14.default.resolve(projectRoot, file), "utf8");
16932
+ files[file] = import_node_fs15.default.readFileSync(import_node_path15.default.resolve(projectRoot, file), "utf8");
16673
16933
  }
16674
16934
  }
16675
16935
  }
@@ -16686,8 +16946,8 @@ function readIosNativeAppIdentity(projectRoot, parseInfoPlist, iosTarget) {
16686
16946
  const app = readIosAppTarget(projectRoot, iosTarget);
16687
16947
  if (!app) return null;
16688
16948
  const identity = readNativeAppIdentityFromXcodeTarget(app, parseInfoPlist);
16689
- const projectManifestPath = import_node_path14.default.join(projectRoot, "package.json");
16690
- const projectRequire = (0, import_node_module3.createRequire)(projectManifestPath);
16949
+ const projectManifestPath = import_node_path15.default.join(projectRoot, "package.json");
16950
+ const projectRequire = (0, import_node_module4.createRequire)(projectManifestPath);
16691
16951
  let reanimatedManifestPath;
16692
16952
  try {
16693
16953
  reanimatedManifestPath = projectRequire.resolve(
@@ -16700,22 +16960,22 @@ function readIosNativeAppIdentity(projectRoot, parseInfoPlist, iosTarget) {
16700
16960
  throw error;
16701
16961
  }
16702
16962
  const installedManifest = JSON.parse(
16703
- import_node_fs14.default.readFileSync(reanimatedManifestPath, "utf8")
16963
+ import_node_fs15.default.readFileSync(reanimatedManifestPath, "utf8")
16704
16964
  );
16705
16965
  const installedVersion = isRecord(installedManifest) ? nonEmptyString2(installedManifest.version) : void 0;
16706
16966
  if (!installedVersion) throw new Error("Reanimated package version is malformed");
16707
16967
  if (Number.parseInt(installedVersion, 10) < 4) return identity;
16708
16968
  const defaults = JSON.parse(
16709
- import_node_fs14.default.readFileSync(
16710
- import_node_path14.default.join(
16711
- import_node_path14.default.dirname(reanimatedManifestPath),
16969
+ import_node_fs15.default.readFileSync(
16970
+ import_node_path15.default.join(
16971
+ import_node_path15.default.dirname(reanimatedManifestPath),
16712
16972
  "src/featureFlags/staticFlags.json"
16713
16973
  ),
16714
16974
  "utf8"
16715
16975
  )
16716
16976
  );
16717
16977
  if (!isRecord(defaults)) throw new Error("Reanimated static flags are malformed");
16718
- const manifest = JSON.parse(import_node_fs14.default.readFileSync(projectManifestPath, "utf8"));
16978
+ const manifest = JSON.parse(import_node_fs15.default.readFileSync(projectManifestPath, "utf8"));
16719
16979
  const reanimated = isRecord(manifest) ? manifest.reanimated : void 0;
16720
16980
  const overrides = isRecord(reanimated) ? reanimated.staticFeatureFlags : void 0;
16721
16981
  if (overrides !== void 0 && !isRecord(overrides)) {
@@ -16738,9 +16998,9 @@ function readIosNativeAppIdentity(projectRoot, parseInfoPlist, iosTarget) {
16738
16998
  return { ...identity, reanimatedStaticFeatureFlags: flags };
16739
16999
  }
16740
17000
  function readIosAppTarget(projectRoot, iosTarget) {
16741
- const iosRoot = import_node_path14.default.join(projectRoot, "ios");
16742
- if (!import_node_fs14.default.existsSync(iosRoot)) return null;
16743
- const projects = import_node_fs14.default.readdirSync(iosRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory() && entry.name.endsWith(".xcodeproj"));
17001
+ const iosRoot = import_node_path15.default.join(projectRoot, "ios");
17002
+ if (!import_node_fs15.default.existsSync(iosRoot)) return null;
17003
+ const projects = import_node_fs15.default.readdirSync(iosRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory() && entry.name.endsWith(".xcodeproj"));
16744
17004
  if (projects.length === 0) return null;
16745
17005
  if (projects.length > 1 && !iosTarget) {
16746
17006
  throw new NativeAppTargetSelectionError(
@@ -16750,7 +17010,7 @@ function readIosAppTarget(projectRoot, iosTarget) {
16750
17010
  let project = projects[0];
16751
17011
  if (iosTarget && projects.length > 1) {
16752
17012
  const matches = projects.filter(
16753
- (entry) => listXcodeAppTargets(import_node_path14.default.join(iosRoot, entry.name), {
17013
+ (entry) => listXcodeAppTargets(import_node_path15.default.join(iosRoot, entry.name), {
16754
17014
  requireSources: false
16755
17015
  }).includes(iosTarget)
16756
17016
  );
@@ -16764,7 +17024,7 @@ function readIosAppTarget(projectRoot, iosTarget) {
16764
17024
  }
16765
17025
  project = matches[0];
16766
17026
  }
16767
- const xcodeproj = import_node_path14.default.join(iosRoot, project.name);
17027
+ const xcodeproj = import_node_path15.default.join(iosRoot, project.name);
16768
17028
  const appTargets = listXcodeAppTargets(xcodeproj, { requireSources: false });
16769
17029
  if (!iosTarget && appTargets.length > 1) {
16770
17030
  throw new NativeAppTargetSelectionError(
@@ -16778,9 +17038,9 @@ function readIosAppTarget(projectRoot, iosTarget) {
16778
17038
 
16779
17039
  // src/native-firebase-config.ts
16780
17040
  var import_node_child_process6 = require("node:child_process");
16781
- var import_node_fs15 = __toESM(require("node:fs"), 1);
17041
+ var import_node_fs16 = __toESM(require("node:fs"), 1);
16782
17042
  var import_node_os3 = __toESM(require("node:os"), 1);
16783
- var import_node_path15 = __toESM(require("node:path"), 1);
17043
+ var import_node_path16 = __toESM(require("node:path"), 1);
16784
17044
  init_is_record();
16785
17045
  var EXPO_CONFIG_SCRIPT = `const { createRequire } = require('node:module');
16786
17046
  const { writeFileSync } = require('node:fs');
@@ -16791,13 +17051,13 @@ const result = JSON.stringify(getConfig(root, { skipSDKVersionRequirement: true
16791
17051
  if (Buffer.byteLength(result) > 1024 * 1024) throw new Error('Expo native configuration exceeds 1 MiB.');
16792
17052
  writeFileSync(process.argv[2], result, { mode: 0o600 });`;
16793
17053
  function hasExpoConfig(projectRoot) {
16794
- const appJsonPath = import_node_path15.default.join(projectRoot, "app.json");
16795
- const appJson = import_node_fs15.default.existsSync(appJsonPath) ? JSON.parse(import_node_fs15.default.readFileSync(appJsonPath, "utf8")) : null;
17054
+ const appJsonPath = import_node_path16.default.join(projectRoot, "app.json");
17055
+ const appJson = import_node_fs16.default.existsSync(appJsonPath) ? JSON.parse(import_node_fs16.default.readFileSync(appJsonPath, "utf8")) : null;
16796
17056
  const staticExpo = isRecord(appJson) && (isRecord(appJson.expo) || [appJson.ios, appJson.android].some(
16797
17057
  (value) => isRecord(value) && typeof value.googleServicesFile === "string"
16798
17058
  ));
16799
17059
  return staticExpo || ["app.config.js", "app.config.ts", "app.config.cjs", "app.config.mjs"].some(
16800
- (name2) => import_node_fs15.default.existsSync(import_node_path15.default.join(projectRoot, name2))
17060
+ (name2) => import_node_fs16.default.existsSync(import_node_path16.default.join(projectRoot, name2))
16801
17061
  );
16802
17062
  }
16803
17063
  function expoConfigArgs(projectRoot, resultPath) {
@@ -16805,22 +17065,22 @@ function expoConfigArgs(projectRoot, resultPath) {
16805
17065
  "--input-type=commonjs",
16806
17066
  "-e",
16807
17067
  EXPO_CONFIG_SCRIPT,
16808
- import_node_path15.default.resolve(projectRoot),
17068
+ import_node_path16.default.resolve(projectRoot),
16809
17069
  resultPath
16810
17070
  ];
16811
17071
  }
16812
17072
  function readExpoConfigResult(resultPath, status, stderr) {
16813
17073
  if (status !== 0)
16814
17074
  throw new Error(stderr || "Expo native configuration evaluation failed.");
16815
- const resolved = JSON.parse(import_node_fs15.default.readFileSync(resultPath, "utf8"));
17075
+ const resolved = JSON.parse(import_node_fs16.default.readFileSync(resultPath, "utf8"));
16816
17076
  if (!isRecord(resolved)) throw new Error("Expo native configuration is unavailable.");
16817
17077
  return resolved;
16818
17078
  }
16819
- var resultDirectory = () => import_node_fs15.default.mkdtempSync(import_node_path15.default.join(import_node_os3.default.tmpdir(), "peach-expo-config-"));
17079
+ var resultDirectory = () => import_node_fs16.default.mkdtempSync(import_node_path16.default.join(import_node_os3.default.tmpdir(), "peach-expo-config-"));
16820
17080
  function readExpoConfig(projectRoot) {
16821
17081
  if (!hasExpoConfig(projectRoot)) return {};
16822
17082
  const directory = resultDirectory();
16823
- const resultPath = import_node_path15.default.join(directory, "config.json");
17083
+ const resultPath = import_node_path16.default.join(directory, "config.json");
16824
17084
  try {
16825
17085
  const child = (0, import_node_child_process6.spawnSync)("node", expoConfigArgs(projectRoot, resultPath), {
16826
17086
  cwd: projectRoot,
@@ -16832,7 +17092,7 @@ function readExpoConfig(projectRoot) {
16832
17092
  if (child.error) throw child.error;
16833
17093
  return readExpoConfigResult(resultPath, child.status, child.stderr);
16834
17094
  } finally {
16835
- import_node_fs15.default.rmSync(directory, { recursive: true, force: true });
17095
+ import_node_fs16.default.rmSync(directory, { recursive: true, force: true });
16836
17096
  }
16837
17097
  }
16838
17098
  function evaluateFirebaseGuard(header, resources) {
@@ -16854,7 +17114,7 @@ function evaluateFirebaseGuard(header, resources) {
16854
17114
  }
16855
17115
  clauses.push(condition.slice(start).trim());
16856
17116
  const sources = resources.filter(
16857
- (file) => import_node_path15.default.basename(file) === "GoogleService-Info.plist"
17117
+ (file) => import_node_path16.default.basename(file) === "GoogleService-Info.plist"
16858
17118
  );
16859
17119
  const bound = /* @__PURE__ */ new Map();
16860
17120
  for (const clause of clauses) {
@@ -16870,7 +17130,7 @@ function evaluateFirebaseGuard(header, resources) {
16870
17130
  const dictionary = /^let\s+(\w+)\s*=\s*NSDictionary\s*\(\s*contentsOfFile:\s*(\w+)\s*\)$/.exec(clause);
16871
17131
  if (dictionary && typeof bound.get(dictionary[2]) === "string") {
16872
17132
  const parsed = parsePlistSource(
16873
- import_node_fs15.default.readFileSync(String(bound.get(dictionary[2])), "utf8")
17133
+ import_node_fs16.default.readFileSync(String(bound.get(dictionary[2])), "utf8")
16874
17134
  );
16875
17135
  if (!isRecord(parsed)) return false;
16876
17136
  bound.set(dictionary[1], parsed);
@@ -16952,7 +17212,7 @@ function findDefaultConfigureCall(body, sources) {
16952
17212
  const [, type, name2] = call;
16953
17213
  for (const file of sources) {
16954
17214
  if (!file.endsWith(".swift")) continue;
16955
- const source = blankSwiftObjcLiterals(import_node_fs15.default.readFileSync(file, "utf8"));
17215
+ const source = blankSwiftObjcLiterals(import_node_fs16.default.readFileSync(file, "utf8"));
16956
17216
  const declaration = new RegExp(
16957
17217
  `\\b(?:enum|struct|class)\\s+${type}\\b[^{]*\\{`
16958
17218
  ).exec(source);
@@ -16973,10 +17233,10 @@ function readTargetGoogleServicesFile(projectRoot, xcodeproj, target) {
16973
17233
  requireSources: false
16974
17234
  });
16975
17235
  const delegates = app.allSources.filter(
16976
- (file) => /^AppDelegate\.(swift|mm|m)$/.test(import_node_path15.default.basename(file))
17236
+ (file) => /^AppDelegate\.(swift|mm|m)$/.test(import_node_path16.default.basename(file))
16977
17237
  );
16978
17238
  const defaultConfigured = delegates.some((file) => {
16979
- const raw = import_node_fs15.default.readFileSync(file, "utf8");
17239
+ const raw = import_node_fs16.default.readFileSync(file, "utf8");
16980
17240
  const source = blankSwiftObjcLiterals(raw);
16981
17241
  const launch = /(?:\bfunc\s+application\s*\([\s\S]*?didFinishLaunchingWithOptions[\s\S]*?\)\s*->\s*Bool|^-\s*\(BOOL\)\s*application\s*:[\s\S]*?didFinishLaunchingWithOptions[^{]*)\s*\{/m.exec(
16982
17242
  source
@@ -17042,27 +17302,27 @@ function readTargetGoogleServicesFile(projectRoot, xcodeproj, target) {
17042
17302
  });
17043
17303
  if (!defaultConfigured) return null;
17044
17304
  const resources = app.resources.filter(
17045
- (file) => /^GoogleService-Info\.plist$/.test(import_node_path15.default.basename(file))
17305
+ (file) => /^GoogleService-Info\.plist$/.test(import_node_path16.default.basename(file))
17046
17306
  );
17047
17307
  if (resources.length !== 1)
17048
17308
  throw new Error(
17049
17309
  "native Firebase default initialization requires one GoogleService-Info.plist build resource"
17050
17310
  );
17051
- return import_node_path15.default.relative(import_node_fs15.default.realpathSync(projectRoot), resources[0]);
17311
+ return import_node_path16.default.relative(import_node_fs16.default.realpathSync(projectRoot), resources[0]);
17052
17312
  }
17053
17313
  function readNativeFirebaseConfig(projectRoot, platforms = ["ios", "android"], iosTarget, config = readExpoConfig(projectRoot)) {
17054
17314
  const result = {};
17055
17315
  const ios = config.ios;
17056
17316
  if (platforms.includes("ios") && (!isRecord(ios) || typeof ios.googleServicesFile !== "string")) {
17057
- const iosRoot = import_node_path15.default.join(projectRoot, "ios");
17058
- if (import_node_fs15.default.existsSync(iosRoot)) {
17059
- const projects = import_node_fs15.default.readdirSync(iosRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory() && entry.name.endsWith(".xcodeproj"));
17317
+ const iosRoot = import_node_path16.default.join(projectRoot, "ios");
17318
+ if (import_node_fs16.default.existsSync(iosRoot)) {
17319
+ const projects = import_node_fs16.default.readdirSync(iosRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory() && entry.name.endsWith(".xcodeproj"));
17060
17320
  if (projects.length > 1)
17061
17321
  throw new Error(
17062
17322
  `native Firebase configuration requires a selected Xcode project; set withPeach's iosTarget to an app target in one of: ${projects.map((entry) => entry.name).join(", ")}`
17063
17323
  );
17064
17324
  if (projects.length === 1) {
17065
- const xcodeproj = import_node_path15.default.join(iosRoot, projects[0].name);
17325
+ const xcodeproj = import_node_path16.default.join(iosRoot, projects[0].name);
17066
17326
  const appTargets = listXcodeAppTargets(xcodeproj, { requireSources: false });
17067
17327
  const files = new Set(
17068
17328
  (iosTarget ? [iosTarget] : appTargets).map(
@@ -17082,8 +17342,8 @@ function readNativeFirebaseConfig(projectRoot, platforms = ["ios", "android"], i
17082
17342
  const native = config[platform];
17083
17343
  if (!isRecord(native) || typeof native.googleServicesFile !== "string") continue;
17084
17344
  try {
17085
- const source = import_node_fs15.default.readFileSync(
17086
- import_node_path15.default.resolve(projectRoot, native.googleServicesFile),
17345
+ const source = import_node_fs16.default.readFileSync(
17346
+ import_node_path16.default.resolve(projectRoot, native.googleServicesFile),
17087
17347
  "utf8"
17088
17348
  );
17089
17349
  const parsed = platform === "ios" ? parsePlistSource(source) : JSON.parse(source);
@@ -17349,7 +17609,7 @@ function withPeach(config, options = {}) {
17349
17609
  const configuredBundleUrl = "/index.bundle?platform=ios&dev=true&hot=true&minify=false";
17350
17610
  const cfgServer = config.server;
17351
17611
  const port = resolveMetroPort(cfgServer);
17352
- const metroServerId = (0, import_node_crypto7.randomUUID)();
17612
+ const metroServerId = (0, import_node_crypto8.randomUUID)();
17353
17613
  const bundleUrl = tagRnxBundleForPlugin(
17354
17614
  configuredBundleUrl,
17355
17615
  `http://localhost:${port}`,