peachsim 0.1.1673 → 0.1.1684

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 (213) hide show
  1. package/cli/commands/control.ts +13 -1
  2. package/cli/commands/coverage-swift.ts +83 -27
  3. package/cli/commands/coverage.ts +219 -20
  4. package/cli/commands/detect.ts +10 -6
  5. package/cli/commands/inspect/core.ts +2 -0
  6. package/cli/commands/inspect/settling.ts +37 -4
  7. package/cli/commands/inspect/wait-ready.ts +7 -0
  8. package/cli/outbound-endpoints.ts +12 -0
  9. package/detox/index.ts +11 -1
  10. package/detox/jest-environment.cjs +14 -0
  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 +3299 -1665
  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 +43 -8
  35. package/dist-lib/detox/jest-environment.cjs +14 -0
  36. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  37. package/dist-lib/expo-swift-bundle.cjs +2432 -1128
  38. package/dist-lib/expo-swift-metadata.cjs +1 -1
  39. package/dist-lib/expo-swift-metadata.mjs +1 -1
  40. package/dist-lib/home-paths.cjs +1 -1
  41. package/dist-lib/host/bridge-host.cjs +2908 -1601
  42. package/dist-lib/host/fetch-proxy-handler.cjs +22 -6
  43. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  44. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  45. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  46. package/dist-lib/host/websocket-proxy.cjs +1 -1
  47. package/dist-lib/index.cjs +1941 -742
  48. package/dist-lib/jump-to-source-babel.cjs +1 -1
  49. package/dist-lib/jump-to-source-native.cjs +1 -1
  50. package/dist-lib/kotlin-host.cjs +1 -1
  51. package/dist-lib/menu.cjs +1 -1
  52. package/dist-lib/menu.mjs +1 -1
  53. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  54. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  55. package/dist-lib/metro-production-bundle.cjs +1 -1
  56. package/dist-lib/metro-production-bundle.mjs +1 -1
  57. package/dist-lib/metro.cjs +6215 -4283
  58. package/dist-lib/native-app-identity-project.cjs +31 -6
  59. package/dist-lib/native-app-identity-project.mjs +31 -6
  60. package/dist-lib/native-app-identity.cjs +1 -1
  61. package/dist-lib/native-app-identity.mjs +1 -1
  62. package/dist-lib/native-firebase-metadata.cjs +1 -1
  63. package/dist-lib/native-firebase-metadata.mjs +1 -1
  64. package/dist-lib/plist.cjs +1 -1
  65. package/dist-lib/plist.mjs +1 -1
  66. package/dist-lib/profiles.cjs +1 -1
  67. package/dist-lib/public-brand.cjs +1 -1
  68. package/dist-lib/public-origins-lib-esm.json +24 -23
  69. package/dist-lib/public-origins-lib-static.json +1 -1
  70. package/dist-lib/public-origins-lib.json +134 -78
  71. package/dist-lib/react-native-host-modules.cjs +1 -1
  72. package/dist-lib/react-native-host-modules.mjs +1 -1
  73. package/dist-lib/reap-browser.cjs +2 -2
  74. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  75. package/dist-lib/sdk.cjs +39 -5
  76. package/dist-lib/sdk.mjs +39 -5
  77. package/dist-lib/skills.cjs +3637 -2168
  78. package/dist-lib/swift-compile.cjs +496 -352
  79. package/dist-lib/swift-compile.mjs +494 -350
  80. package/dist-lib/swift-package.cjs +58 -9
  81. package/dist-lib/swift-package.mjs +57 -9
  82. package/dist-lib/swift-submit.cjs +1 -1
  83. package/dist-lib/swift-submit.mjs +1 -1
  84. package/dist-lib/swift-toolchain.cjs +26 -11
  85. package/dist-lib/swift.cjs +1 -1
  86. package/dist-lib/vite-swift.cjs +2443 -1134
  87. package/dist-lib/vite.cjs +1907 -763
  88. package/dist-lib/worklet-executable.cjs +1 -1
  89. package/dist-lib/worklet-executable.mjs +1 -1
  90. package/dist-types/packages/peach-engine/src/engine/canvaskit-api.d.ts +1 -1
  91. package/dist-types/packages/peach-engine/src/engine/clipboardContract.d.ts +9 -1
  92. package/dist-types/packages/peach-engine/src/engine/paint-boundary.d.ts +1 -0
  93. package/dist-types/packages/peach-engine/src/preview/upload-protocol.d.ts +11 -3
  94. package/dist-types/packages/peach-engine/src/rolldown-bundle-inventory.d.ts +1 -1
  95. package/dist-types/packages/peach-engine/src/webview-automation-host.d.ts +6 -0
  96. package/dist-types/packages/peach-globals/src/clipboardBridgeContract.d.ts +2 -0
  97. package/dist-types/packages/peach-globals/src/compositorBridgeContract.d.ts +10 -1
  98. package/dist-types/packages/peach-globals/src/index.d.ts +1 -1
  99. package/package.json +1 -1
  100. package/runtime-companion.json +1 -1
  101. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h +69 -2
  102. package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h +44 -4
  103. package/sdk/ios/System/Library/Frameworks/MessageUI.framework/Headers/MFComposeAssistantViewController.h +29 -0
  104. package/sdk/ios/System/Library/Frameworks/MessageUI.framework/Headers/MFMailComposeControllerDeferredAction.h +14 -0
  105. package/sdk/ios/System/Library/Frameworks/MessageUI.framework/Headers/MFMailComposeViewController.h +162 -0
  106. package/sdk/ios/System/Library/Frameworks/MessageUI.framework/Headers/MFMailDraft.h +24 -0
  107. package/sdk/ios/System/Library/Frameworks/MessageUI.framework/Headers/MFMessageComposeViewController+UPI.h +31 -0
  108. package/sdk/ios/System/Library/Frameworks/MessageUI.framework/Headers/MFMessageComposeViewController.h +169 -0
  109. package/sdk/ios/System/Library/Frameworks/MessageUI.framework/Headers/MessageUI.h +13 -0
  110. package/sdk/ios/System/Library/Frameworks/MessageUI.framework/Modules/module.modulemap +11 -0
  111. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h +10 -0
  112. package/sdk/ios/usr/include/_ctype.h +388 -0
  113. package/sdk/ios/usr/include/_inttypes.h +296 -0
  114. package/sdk/ios/usr/include/_locale.h +83 -0
  115. package/sdk/ios/usr/include/_locale_posix2008.h +65 -0
  116. package/sdk/ios/usr/include/_time.h +207 -0
  117. package/sdk/ios/usr/include/arm/param.h +151 -0
  118. package/sdk/ios/usr/include/ctype.h +70 -0
  119. package/sdk/ios/usr/include/dispatch/dispatch.h +72 -6
  120. package/sdk/ios/usr/include/dlfcn.h +1 -2
  121. package/sdk/ios/usr/include/inttypes.h +35 -0
  122. package/sdk/ios/usr/include/locale.h +59 -0
  123. package/sdk/ios/usr/include/machine/param.h +42 -0
  124. package/sdk/ios/usr/include/net/if.h +1 -2
  125. package/sdk/ios/usr/include/peach/pthread.h +4 -4
  126. package/sdk/ios/usr/include/pthread/qos.h +304 -0
  127. package/sdk/ios/usr/include/runetype.h +118 -0
  128. package/sdk/ios/usr/include/setjmp.h +99 -0
  129. package/sdk/ios/usr/include/sys/_types/_clock_t.h +32 -0
  130. package/sdk/ios/usr/include/sys/_types/_ct_rune_t.h +33 -0
  131. package/sdk/ios/usr/include/sys/_types/_fd_clr.h +31 -0
  132. package/sdk/ios/usr/include/sys/_types/_fd_copy.h +31 -0
  133. package/sdk/ios/usr/include/sys/_types/_fd_def.h +121 -0
  134. package/sdk/ios/usr/include/sys/_types/_fd_isset.h +31 -0
  135. package/sdk/ios/usr/include/sys/_types/_fd_set.h +31 -0
  136. package/sdk/ios/usr/include/sys/_types/_fd_setsize.h +31 -0
  137. package/sdk/ios/usr/include/sys/_types/_fd_zero.h +31 -0
  138. package/sdk/ios/usr/include/sys/_types/_rune_t.h +32 -0
  139. package/sdk/ios/usr/include/sys/_types/_time_t.h +32 -0
  140. package/sdk/ios/usr/include/sys/_types/_wint_t.h +33 -0
  141. package/sdk/ios/usr/include/sys/cdefs.h +5 -0
  142. package/sdk/ios/usr/include/sys/param.h +235 -0
  143. package/sdk/ios/usr/include/sys/proc.h +1 -0
  144. package/sdk/ios/usr/include/sys/qos.h +151 -12
  145. package/sdk/ios/usr/include/time.h +67 -2
  146. package/sdk/ios/wasm/include/__typedef_sigset_t.h +7 -0
  147. package/sdk/ios/wasm/include/fcntl.h +11 -0
  148. package/sdk/ios/wasm/include/mach/machine/boolean.h +2 -0
  149. package/sdk/ios/wasm/include/mach/machine/exception.h +5 -0
  150. package/sdk/ios/wasm/include/mach/machine/kern_return.h +2 -0
  151. package/sdk/ios/wasm/include/mach/machine/processor_info.h +2 -0
  152. package/sdk/ios/wasm/include/mach/machine/rpc.h +2 -0
  153. package/sdk/ios/wasm/include/mach/machine/thread_state.h +3 -0
  154. package/sdk/ios/wasm/include/mach/machine/thread_status.h +3 -0
  155. package/sdk/ios/wasm/include/mach/machine/vm_param.h +3 -0
  156. package/sdk/ios/wasm/include/mach/machine/vm_types.h +18 -0
  157. package/sdk/ios/wasm/include/machine/_types.h +153 -0
  158. package/sdk/ios/wasm/include/machine/endian.h +2 -0
  159. package/sdk/ios/wasm/include/machine/limits.h +2 -0
  160. package/sdk/ios/wasm/include/machine/types.h +30 -0
  161. package/sdk/ios/wasm/include/poll.h +8 -0
  162. package/sdk/ios/wasm/include/pthread.h +50 -0
  163. package/sdk/ios/wasm/include/signal.h +72 -0
  164. package/sdk/ios/wasm/include/stdlib.h +3 -0
  165. package/sdk/ios/wasm/include/string.h +10 -0
  166. package/sdk/ios/wasm/include/sys/_pthread/_pthread_attr_t.h +7 -0
  167. package/sdk/ios/wasm/include/sys/_pthread/_pthread_t.h +7 -0
  168. package/sdk/ios/wasm/include/sys/mman.h +122 -0
  169. package/sdk/ios/wasm/include/sys/select.h +37 -0
  170. package/sdk/ios/wasm/include/sys/signal.h +259 -0
  171. package/sdk/ios/wasm/include/sys/socket.h +8 -0
  172. package/sdk/ios/wasm/include/sys/types.h +14 -0
  173. package/sdk/ios/wasm/include/sys/ucontext.h +1 -0
  174. package/sdk/ios/wasm/include/sys/uio.h +11 -0
  175. package/sdk/ios/wasm/include/sys/wait.h +89 -0
  176. package/sdk/ios/wasm/include/time.h +8 -0
  177. package/sdk/ios/wasm/include/unistd.h +17 -0
  178. package/src/bridge-contract.ts +2 -0
  179. package/src/chromium-admission.ts +10 -5
  180. package/src/device-catalog.ts +4 -4
  181. package/src/host/fetch-proxy-handler.ts +20 -0
  182. package/src/host/rolldown-bundle-forward.ts +4 -1
  183. package/src/metro-plugin.ts +5 -2
  184. package/src/nitro-adapter.lock.json +6 -6
  185. package/src/nitro-compile.ts +63 -2
  186. package/src/numbered-lock.ts +72 -0
  187. package/src/react-native-coverage/capability-reference-resolution.ts +62 -5
  188. package/src/react-native-coverage/capability-source-references.ts +50 -13
  189. package/src/react-native-coverage/native-source-credit.ts +126 -0
  190. package/src/react-native-coverage/native-source-ranges-file.ts +38 -0
  191. package/src/react-native-coverage/native-surface.ts +49 -0
  192. package/src/react-native-coverage/verified-reach.ts +22 -2
  193. package/src/runtime-assets.ts +17 -0
  194. package/src/swift-compile.ts +84 -47
  195. package/src/swift-coverage/indexing.ts +17 -1
  196. package/src/swift-coverage/sdk.ts +71 -0
  197. package/src/swift-coverage/source.ts +74 -2
  198. package/src/swift-coverage/types.ts +6 -0
  199. package/src/swift-distribution.lock.json +12 -12
  200. package/src/swift-host.ts +133 -14
  201. package/src/swift-objc-compile.ts +11 -22
  202. package/src/swift-objc-metadata.ts +2 -8
  203. package/src/swift-objc-platform.ts +53 -0
  204. package/src/swift-objc-standin.ts +49 -0
  205. package/src/swift-package-manifest.ts +48 -3
  206. package/src/swift-package.ts +85 -12
  207. package/src/swift-packages.ts +157 -44
  208. package/src/swift-source-pods.ts +288 -0
  209. package/src/swift-standins.ts +4 -1
  210. package/src/swift-toolchain.ts +32 -10
  211. package/src/vite-plugin-one.ts +5 -4
  212. package/src/worker-system-chunks.ts +7 -1
  213. package/src/xcode-project.ts +40 -11
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.1673 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1684 | (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;
@@ -98,7 +98,7 @@ var init_bundleGlobalFooter = __esm({
98
98
  var runtime_companion_default;
99
99
  var init_runtime_companion = __esm({
100
100
  "runtime-companion.json"() {
101
- runtime_companion_default = { abi: 1, sha256: "64b30b73101e38ea8d4aaa3e07f22bdedd2736a7d1f0f21f9229f2f4daf45756", file: "node/cli-64b30b73101e38ea8d4aaa3e07f22bdedd2736a7d1f0f21f9229f2f4daf45756.cjs" };
101
+ runtime_companion_default = { abi: 1, sha256: "0aa1bb93377f2ed084f869ab161285ff9e1c638510065738c97f0cbe806bb630", file: "node/cli-0aa1bb93377f2ed084f869ab161285ff9e1c638510065738c97f0cbe806bb630.cjs" };
102
102
  }
103
103
  });
104
104
 
@@ -356,7 +356,18 @@ function resolveRuntimeFilePath(runtimeRoot, pathname) {
356
356
  if (!import_fs.default.existsSync(fullPath) || !import_fs.default.statSync(fullPath).isFile()) return null;
357
357
  return fullPath;
358
358
  }
359
+ function setRuntimeIsolationHeaders(res) {
360
+ res.setHeader("cross-origin-opener-policy", "same-origin");
361
+ res.setHeader("cross-origin-embedder-policy", "require-corp");
362
+ res.setHeader("cross-origin-resource-policy", "cross-origin");
363
+ }
364
+ function sendShellHtml(res, html) {
365
+ setRuntimeIsolationHeaders(res);
366
+ res.setHeader("content-type", "text/html");
367
+ res.end(html);
368
+ }
359
369
  function serveRuntimeFile(req, res, fullPath) {
370
+ setRuntimeIsolationHeaders(res);
360
371
  const ext = import_path.default.extname(fullPath);
361
372
  const stat = import_fs.default.statSync(fullPath);
362
373
  const lastModified = stat.mtime.toUTCString();
@@ -526,6 +537,26 @@ function isLoopbackHost(hostname) {
526
537
  const normalized = normalizeHostname(hostname);
527
538
  return normalized === "localhost" || normalized.endsWith(".localhost") || normalized === "0.0.0.0" || normalized === "::1" || /^127(?:\.\d{1,3}){3}$/.test(normalized);
528
539
  }
540
+ function isTrustedBridgeRequest(headers) {
541
+ const origin = headers.origin;
542
+ if (origin === void 0) return true;
543
+ try {
544
+ const { hostname, host } = new URL(String(origin));
545
+ return isLoopbackHost(hostname) || [headers.host, headers[":authority"], headers["x-forwarded-host"]].some(
546
+ (value) => typeof value === "string" && value.toLowerCase() === host
547
+ );
548
+ } catch {
549
+ return false;
550
+ }
551
+ }
552
+ function loopbackOriginOf(value) {
553
+ try {
554
+ const url = new URL(value);
555
+ return isLoopbackHost(url.hostname) ? url.origin : null;
556
+ } catch {
557
+ return null;
558
+ }
559
+ }
529
560
  var init_backend_origin = __esm({
530
561
  "src/backend-origin.ts"() {
531
562
  "use strict";
@@ -1732,17 +1763,17 @@ function visit(node, visitor) {
1732
1763
  } else
1733
1764
  visit_(null, node, visitor_, Object.freeze([]));
1734
1765
  }
1735
- function visit_(key, node, visitor, path21) {
1736
- const ctrl = callVisitor(key, node, visitor, path21);
1766
+ function visit_(key, node, visitor, path22) {
1767
+ const ctrl = callVisitor(key, node, visitor, path22);
1737
1768
  if (isNode(ctrl) || isPair(ctrl)) {
1738
- replaceNode(key, path21, ctrl);
1739
- return visit_(key, ctrl, visitor, path21);
1769
+ replaceNode(key, path22, ctrl);
1770
+ return visit_(key, ctrl, visitor, path22);
1740
1771
  }
1741
1772
  if (typeof ctrl !== "symbol") {
1742
1773
  if (isCollection(node)) {
1743
- path21 = Object.freeze(path21.concat(node));
1774
+ path22 = Object.freeze(path22.concat(node));
1744
1775
  for (let i = 0; i < node.items.length; ++i) {
1745
- const ci = visit_(i, node.items[i], visitor, path21);
1776
+ const ci = visit_(i, node.items[i], visitor, path22);
1746
1777
  if (typeof ci === "number")
1747
1778
  i = ci - 1;
1748
1779
  else if (ci === BREAK)
@@ -1753,13 +1784,13 @@ function visit_(key, node, visitor, path21) {
1753
1784
  }
1754
1785
  }
1755
1786
  } else if (isPair(node)) {
1756
- path21 = Object.freeze(path21.concat(node));
1757
- const ck = visit_("key", node.key, visitor, path21);
1787
+ path22 = Object.freeze(path22.concat(node));
1788
+ const ck = visit_("key", node.key, visitor, path22);
1758
1789
  if (ck === BREAK)
1759
1790
  return BREAK;
1760
1791
  else if (ck === REMOVE)
1761
1792
  node.key = null;
1762
- const cv = visit_("value", node.value, visitor, path21);
1793
+ const cv = visit_("value", node.value, visitor, path22);
1763
1794
  if (cv === BREAK)
1764
1795
  return BREAK;
1765
1796
  else if (cv === REMOVE)
@@ -1777,17 +1808,17 @@ async function visitAsync(node, visitor) {
1777
1808
  } else
1778
1809
  await visitAsync_(null, node, visitor_, Object.freeze([]));
1779
1810
  }
1780
- async function visitAsync_(key, node, visitor, path21) {
1781
- const ctrl = await callVisitor(key, node, visitor, path21);
1811
+ async function visitAsync_(key, node, visitor, path22) {
1812
+ const ctrl = await callVisitor(key, node, visitor, path22);
1782
1813
  if (isNode(ctrl) || isPair(ctrl)) {
1783
- replaceNode(key, path21, ctrl);
1784
- return visitAsync_(key, ctrl, visitor, path21);
1814
+ replaceNode(key, path22, ctrl);
1815
+ return visitAsync_(key, ctrl, visitor, path22);
1785
1816
  }
1786
1817
  if (typeof ctrl !== "symbol") {
1787
1818
  if (isCollection(node)) {
1788
- path21 = Object.freeze(path21.concat(node));
1819
+ path22 = Object.freeze(path22.concat(node));
1789
1820
  for (let i = 0; i < node.items.length; ++i) {
1790
- const ci = await visitAsync_(i, node.items[i], visitor, path21);
1821
+ const ci = await visitAsync_(i, node.items[i], visitor, path22);
1791
1822
  if (typeof ci === "number")
1792
1823
  i = ci - 1;
1793
1824
  else if (ci === BREAK)
@@ -1798,13 +1829,13 @@ async function visitAsync_(key, node, visitor, path21) {
1798
1829
  }
1799
1830
  }
1800
1831
  } else if (isPair(node)) {
1801
- path21 = Object.freeze(path21.concat(node));
1802
- const ck = await visitAsync_("key", node.key, visitor, path21);
1832
+ path22 = Object.freeze(path22.concat(node));
1833
+ const ck = await visitAsync_("key", node.key, visitor, path22);
1803
1834
  if (ck === BREAK)
1804
1835
  return BREAK;
1805
1836
  else if (ck === REMOVE)
1806
1837
  node.key = null;
1807
- const cv = await visitAsync_("value", node.value, visitor, path21);
1838
+ const cv = await visitAsync_("value", node.value, visitor, path22);
1808
1839
  if (cv === BREAK)
1809
1840
  return BREAK;
1810
1841
  else if (cv === REMOVE)
@@ -1831,23 +1862,23 @@ function initVisitor(visitor) {
1831
1862
  }
1832
1863
  return visitor;
1833
1864
  }
1834
- function callVisitor(key, node, visitor, path21) {
1865
+ function callVisitor(key, node, visitor, path22) {
1835
1866
  if (typeof visitor === "function")
1836
- return visitor(key, node, path21);
1867
+ return visitor(key, node, path22);
1837
1868
  if (isMap(node))
1838
- return visitor.Map?.(key, node, path21);
1869
+ return visitor.Map?.(key, node, path22);
1839
1870
  if (isSeq(node))
1840
- return visitor.Seq?.(key, node, path21);
1871
+ return visitor.Seq?.(key, node, path22);
1841
1872
  if (isPair(node))
1842
- return visitor.Pair?.(key, node, path21);
1873
+ return visitor.Pair?.(key, node, path22);
1843
1874
  if (isScalar(node))
1844
- return visitor.Scalar?.(key, node, path21);
1875
+ return visitor.Scalar?.(key, node, path22);
1845
1876
  if (isAlias(node))
1846
- return visitor.Alias?.(key, node, path21);
1877
+ return visitor.Alias?.(key, node, path22);
1847
1878
  return void 0;
1848
1879
  }
1849
- function replaceNode(key, path21, node) {
1850
- const parent = path21[path21.length - 1];
1880
+ function replaceNode(key, path22, node) {
1881
+ const parent = path22[path22.length - 1];
1851
1882
  if (isCollection(parent)) {
1852
1883
  parent.items[key] = node;
1853
1884
  } else if (isPair(parent)) {
@@ -2407,10 +2438,10 @@ var init_createNode = __esm({
2407
2438
  });
2408
2439
 
2409
2440
  // ../../node_modules/yaml/browser/dist/nodes/Collection.js
2410
- function collectionFromPath(schema4, path21, value) {
2441
+ function collectionFromPath(schema4, path22, value) {
2411
2442
  let v = value;
2412
- for (let i = path21.length - 1; i >= 0; --i) {
2413
- const k = path21[i];
2443
+ for (let i = path22.length - 1; i >= 0; --i) {
2444
+ const k = path22[i];
2414
2445
  if (typeof k === "number" && Number.isInteger(k) && k >= 0) {
2415
2446
  const a = [];
2416
2447
  a[k] = v;
@@ -2436,7 +2467,7 @@ var init_Collection = __esm({
2436
2467
  init_createNode();
2437
2468
  init_identity();
2438
2469
  init_Node();
2439
- isEmptyPath = (path21) => path21 == null || typeof path21 === "object" && !!path21[Symbol.iterator]().next().done;
2470
+ isEmptyPath = (path22) => path22 == null || typeof path22 === "object" && !!path22[Symbol.iterator]().next().done;
2440
2471
  Collection = class extends NodeBase {
2441
2472
  constructor(type, schema4) {
2442
2473
  super(type);
@@ -2466,11 +2497,11 @@ var init_Collection = __esm({
2466
2497
  * be a Pair instance or a `{ key, value }` object, which may not have a key
2467
2498
  * that already exists in the map.
2468
2499
  */
2469
- addIn(path21, value) {
2470
- if (isEmptyPath(path21))
2500
+ addIn(path22, value) {
2501
+ if (isEmptyPath(path22))
2471
2502
  this.add(value);
2472
2503
  else {
2473
- const [key, ...rest] = path21;
2504
+ const [key, ...rest] = path22;
2474
2505
  const node = this.get(key, true);
2475
2506
  if (isCollection(node))
2476
2507
  node.addIn(rest, value);
@@ -2484,8 +2515,8 @@ var init_Collection = __esm({
2484
2515
  * Removes a value from the collection.
2485
2516
  * @returns `true` if the item was found and removed.
2486
2517
  */
2487
- deleteIn(path21) {
2488
- const [key, ...rest] = path21;
2518
+ deleteIn(path22) {
2519
+ const [key, ...rest] = path22;
2489
2520
  if (rest.length === 0)
2490
2521
  return this.delete(key);
2491
2522
  const node = this.get(key, true);
@@ -2499,8 +2530,8 @@ var init_Collection = __esm({
2499
2530
  * scalar values from their surrounding node; to disable set `keepScalar` to
2500
2531
  * `true` (collections are always returned intact).
2501
2532
  */
2502
- getIn(path21, keepScalar) {
2503
- const [key, ...rest] = path21;
2533
+ getIn(path22, keepScalar) {
2534
+ const [key, ...rest] = path22;
2504
2535
  const node = this.get(key, true);
2505
2536
  if (rest.length === 0)
2506
2537
  return !keepScalar && isScalar(node) ? node.value : node;
@@ -2518,8 +2549,8 @@ var init_Collection = __esm({
2518
2549
  /**
2519
2550
  * Checks if the collection includes a value with the key `key`.
2520
2551
  */
2521
- hasIn(path21) {
2522
- const [key, ...rest] = path21;
2552
+ hasIn(path22) {
2553
+ const [key, ...rest] = path22;
2523
2554
  if (rest.length === 0)
2524
2555
  return this.has(key);
2525
2556
  const node = this.get(key, true);
@@ -2529,8 +2560,8 @@ var init_Collection = __esm({
2529
2560
  * Sets a value in this collection. For `!!set`, `value` needs to be a
2530
2561
  * boolean to add/remove the item from the set.
2531
2562
  */
2532
- setIn(path21, value) {
2533
- const [key, ...rest] = path21;
2563
+ setIn(path22, value) {
2564
+ const [key, ...rest] = path22;
2534
2565
  if (rest.length === 0) {
2535
2566
  this.set(key, value);
2536
2567
  } else {
@@ -4503,15 +4534,15 @@ function visit2(cst, visitor) {
4503
4534
  cst = { start: cst.start, value: cst.value };
4504
4535
  _visit(Object.freeze([]), cst, visitor);
4505
4536
  }
4506
- function _visit(path21, item, visitor) {
4507
- let ctrl = visitor(item, path21);
4537
+ function _visit(path22, item, visitor) {
4538
+ let ctrl = visitor(item, path22);
4508
4539
  if (typeof ctrl === "symbol")
4509
4540
  return ctrl;
4510
4541
  for (const field of ["key", "value"]) {
4511
4542
  const token = item[field];
4512
4543
  if (token && "items" in token) {
4513
4544
  for (let i = 0; i < token.items.length; ++i) {
4514
- const ci = _visit(Object.freeze(path21.concat([[field, i]])), token.items[i], visitor);
4545
+ const ci = _visit(Object.freeze(path22.concat([[field, i]])), token.items[i], visitor);
4515
4546
  if (typeof ci === "number")
4516
4547
  i = ci - 1;
4517
4548
  else if (ci === BREAK2)
@@ -4522,10 +4553,10 @@ function _visit(path21, item, visitor) {
4522
4553
  }
4523
4554
  }
4524
4555
  if (typeof ctrl === "function" && field === "key")
4525
- ctrl = ctrl(item, path21);
4556
+ ctrl = ctrl(item, path22);
4526
4557
  }
4527
4558
  }
4528
- return typeof ctrl === "function" ? ctrl(item, path21) : ctrl;
4559
+ return typeof ctrl === "function" ? ctrl(item, path22) : ctrl;
4529
4560
  }
4530
4561
  var BREAK2, SKIP2, REMOVE2;
4531
4562
  var init_cst_visit = __esm({
@@ -4537,9 +4568,9 @@ var init_cst_visit = __esm({
4537
4568
  visit2.BREAK = BREAK2;
4538
4569
  visit2.SKIP = SKIP2;
4539
4570
  visit2.REMOVE = REMOVE2;
4540
- visit2.itemAtPath = (cst, path21) => {
4571
+ visit2.itemAtPath = (cst, path22) => {
4541
4572
  let item = cst;
4542
- for (const [field, index] of path21) {
4573
+ for (const [field, index] of path22) {
4543
4574
  const tok = item?.[field];
4544
4575
  if (tok && "items" in tok) {
4545
4576
  item = tok.items[index];
@@ -4548,9 +4579,9 @@ var init_cst_visit = __esm({
4548
4579
  }
4549
4580
  return item;
4550
4581
  };
4551
- visit2.parentCollection = (cst, path21) => {
4552
- const parent = visit2.itemAtPath(cst, path21.slice(0, -1));
4553
- const field = path21[path21.length - 1][0];
4582
+ visit2.parentCollection = (cst, path22) => {
4583
+ const parent = visit2.itemAtPath(cst, path22.slice(0, -1));
4584
+ const field = path22[path22.length - 1][0];
4554
4585
  const coll = parent?.[field];
4555
4586
  if (coll && "items" in coll)
4556
4587
  return coll;
@@ -4720,8 +4751,8 @@ function metadataValue(value, key) {
4720
4751
  if (!value || typeof value !== "object") return void 0;
4721
4752
  return Object.getOwnPropertyDescriptor(value, key)?.value;
4722
4753
  }
4723
- function readProjectJson(path21, files = nodeRepoFileReader) {
4724
- const text2 = readProjectMetadata(path21, files);
4754
+ function readProjectJson(path22, files = nodeRepoFileReader) {
4755
+ const text2 = readProjectMetadata(path22, files);
4725
4756
  if (text2 === null) return null;
4726
4757
  try {
4727
4758
  const value = JSON.parse(text2);
@@ -4778,6 +4809,227 @@ var init_detect = __esm({
4778
4809
  }
4779
4810
  });
4780
4811
 
4812
+ // src/nativeViewSourceContract.ts
4813
+ function isNativeViewSource(value) {
4814
+ if (!isRecord(value)) return false;
4815
+ if (value.type === "placeholder")
4816
+ return (value.uri === void 0 || typeof value.uri === "string" && value.uri.length > 0) && (value.color === void 0 || typeof value.color === "string");
4817
+ if (value.type === "web") {
4818
+ if (typeof value.uri !== "string") return false;
4819
+ try {
4820
+ const url = new URL(value.uri);
4821
+ return url.protocol === "http:" || url.protocol === "https:";
4822
+ } catch {
4823
+ return false;
4824
+ }
4825
+ }
4826
+ return value.type === "video" && typeof value.uri === "string" && value.uri.length > 0 && ["paused", "loop", "muted"].every(
4827
+ (key) => value[key] === void 0 || typeof value[key] === "boolean"
4828
+ ) && (value.currentTime === void 0 || typeof value.currentTime === "number" && Number.isFinite(value.currentTime) && value.currentTime >= 0) && (value.resizeMode === void 0 || value.resizeMode === "contain" || value.resizeMode === "cover" || value.resizeMode === "stretch");
4829
+ }
4830
+ var init_nativeViewSourceContract = __esm({
4831
+ "src/nativeViewSourceContract.ts"() {
4832
+ "use strict";
4833
+ init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
4834
+ init_is_record();
4835
+ }
4836
+ });
4837
+
4838
+ // src/config.ts
4839
+ var config_exports = {};
4840
+ __export(config_exports, {
4841
+ PEACH_CONFIGURED_FILES_HOOK: () => PEACH_CONFIGURED_FILES_HOOK,
4842
+ PEACH_CONFIG_QUERY_PARAM: () => PEACH_CONFIG_QUERY_PARAM,
4843
+ applyPeachConfigToUrl: () => applyPeachConfigToUrl,
4844
+ collectConfiguredFileModules: () => collectConfiguredFileModules,
4845
+ createPeachBundleConfigFooter: () => createPeachBundleConfigFooter,
4846
+ defineConfig: () => defineConfig,
4847
+ detachPeachBundleConfigFooter: () => detachPeachBundleConfigFooter,
4848
+ hasPeachConfig: () => hasPeachConfig,
4849
+ isPackageStubs: () => isPackageStubs,
4850
+ isPeachConfig: () => isPeachConfig,
4851
+ mergePeachConfig: () => mergePeachConfig,
4852
+ readNativeRenderer: () => readNativeRenderer,
4853
+ readPeachBundleConfig: () => readPeachBundleConfig,
4854
+ readPeachBundleConfigFooter: () => readPeachBundleConfigFooter,
4855
+ readPeachConfigFromSearchParams: () => readPeachConfigFromSearchParams
4856
+ });
4857
+ function readNativeRenderer(value) {
4858
+ if (value === void 0) return void 0;
4859
+ if (value === "paper" || value === "fabric") return value;
4860
+ throw new Error("nativeRenderer must be paper or fabric");
4861
+ }
4862
+ function isHybridObjectAnswer(answer) {
4863
+ return answer === "unsupported" || isRecord(answer) && typeof answer.file === "string" && answer.file.length > 0;
4864
+ }
4865
+ function isHybridObjects(value) {
4866
+ return isRecord(value) && Object.entries(value).every(
4867
+ ([name2, answer]) => name2.length > 0 && isHybridObjectAnswer(answer)
4868
+ );
4869
+ }
4870
+ function isPackageHybridObjects(value) {
4871
+ return isRecord(value) && Object.entries(value).every(
4872
+ ([name2, answer]) => name2.length > 0 && typeof answer === "string" && answer.length > 0 && answer !== "noop"
4873
+ );
4874
+ }
4875
+ function isPackageStubs(value) {
4876
+ if (value === "noop") return true;
4877
+ if (!isRecord(value)) return false;
4878
+ return (value.modules === void 0 || isRecord(value.modules) && Object.values(value.modules).every(
4879
+ (stub) => typeof stub === "string" && stub.length > 0
4880
+ )) && (value.views === void 0 || isRecord(value.views) && Object.values(value.views).every(
4881
+ (stub) => typeof stub === "string" && stub.length > 0 || isNativeViewSource(stub)
4882
+ )) && (value.hybridObjects === void 0 || isPackageHybridObjects(value.hybridObjects));
4883
+ }
4884
+ function collectConfiguredFileModules(config) {
4885
+ return [
4886
+ ...new Set(
4887
+ [
4888
+ "modules",
4889
+ "turboModules",
4890
+ "nativeModules",
4891
+ "nativeViews",
4892
+ "nativeHybridObjects"
4893
+ ].flatMap((key) => {
4894
+ const entries = config && Reflect.get(config, key);
4895
+ if (!isRecord(entries)) return [];
4896
+ return Object.values(entries).flatMap(
4897
+ (entry) => isRecord(entry) && typeof entry.file === "string" ? [entry.file] : []
4898
+ );
4899
+ })
4900
+ )
4901
+ ];
4902
+ }
4903
+ function isPeachConfig(value) {
4904
+ if (!isRecord(value)) return false;
4905
+ return (value.nativeRenderer === void 0 || value.nativeRenderer === "paper" || value.nativeRenderer === "fabric") && (value.mapKit === void 0 || isRecord(value.mapKit) && typeof value.mapKit.token === "string" && value.mapKit.token.length > 0 && value.mapKit.token === value.mapKit.token.trim()) && (value.runtimeVersion === void 0 || typeof value.runtimeVersion === "string" && value.runtimeVersion === value.runtimeVersion.trim() && isValidRuntimeVersion(value.runtimeVersion)) && [
4906
+ "modules",
4907
+ "packages",
4908
+ "turboModules",
4909
+ "nativeModules",
4910
+ "nativeViews",
4911
+ "nativeHybridObjects",
4912
+ "env",
4913
+ "network",
4914
+ "settings",
4915
+ "initialProps",
4916
+ "initialState"
4917
+ ].every((key) => value[key] === void 0 || isRecord(value[key])) && (value.packages === void 0 || isRecord(value.packages) && Object.values(value.packages).every(isPackageStubs)) && (value.nativeHybridObjects === void 0 || isHybridObjects(value.nativeHybridObjects)) && (value.nativeViews === void 0 || isRecord(value.nativeViews) && Object.values(value.nativeViews).every(
4918
+ (entry) => entry === "noop" || isNativeViewSource(entry) || isRecord(entry) && typeof entry.file === "string" && entry.file.length > 0
4919
+ ));
4920
+ }
4921
+ function readPeachBundleConfig(value) {
4922
+ if (value === void 0 || value === null) return null;
4923
+ if (!isRecord(value) || !isPeachConfig(value.config) || !Array.isArray(value.runtimePackages) || !value.runtimePackages.every((name2) => typeof name2 === "string")) {
4924
+ throw new Error("configured bundle metadata is malformed");
4925
+ }
4926
+ return { config: value.config, runtimePackages: [...value.runtimePackages] };
4927
+ }
4928
+ function readPeachBundleConfigFooter(source) {
4929
+ const start = findBundleFooter(source, BUNDLE_CONFIG_PREFIX);
4930
+ if (start < 0) return null;
4931
+ const end = source.indexOf("\n", start + 1);
4932
+ const line = source.slice(start + 1, end < 0 ? void 0 : end);
4933
+ if (!line.endsWith(";")) throw new Error("configured bundle footer is truncated");
4934
+ const result = readPeachBundleConfig(
4935
+ JSON.parse(line.slice(BUNDLE_CONFIG_PREFIX.length, -1))
4936
+ );
4937
+ if (!result) throw new Error("configured bundle footer is empty");
4938
+ return result;
4939
+ }
4940
+ function createPeachBundleConfigFooter(config) {
4941
+ const json = JSON.stringify(config).replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029").replace(/<\//g, "<\\/");
4942
+ return "\n" + BUNDLE_CONFIG_PREFIX + json + ";";
4943
+ }
4944
+ function detachPeachBundleConfigFooter(source) {
4945
+ const configuredBundle = readPeachBundleConfigFooter(source);
4946
+ if (!configuredBundle) return { source, configuredBundle };
4947
+ const start = findBundleFooter(source, BUNDLE_CONFIG_PREFIX);
4948
+ const end = source.indexOf("\n", start + 1);
4949
+ return {
4950
+ source: source.slice(0, start) + source.slice(end < 0 ? source.length : end),
4951
+ configuredBundle
4952
+ };
4953
+ }
4954
+ function defineConfig(config) {
4955
+ return config;
4956
+ }
4957
+ function hasOwnKeys(value) {
4958
+ return !!value && Object.keys(value).length > 0;
4959
+ }
4960
+ function hasPeachConfig(config) {
4961
+ if (!config) return false;
4962
+ return config.nativeRenderer !== void 0 || config.mapKit !== void 0 || typeof config.runtimeVersion === "string" && config.runtimeVersion.length > 0 || hasOwnKeys(config.modules) || hasOwnKeys(config.turboModules) || hasOwnKeys(config.nativeModules) || hasOwnKeys(config.nativeViews) || hasOwnKeys(config.nativeHybridObjects) || hasOwnKeys(config.env) || hasOwnKeys(config.network?.remap) || hasOwnKeys(config.settings) || hasOwnKeys(config.initialProps) || hasOwnKeys(config.initialState);
4963
+ }
4964
+ function mergePeachConfig(base, override) {
4965
+ if (!hasPeachConfig(base) && !hasPeachConfig(override)) return void 0;
4966
+ if (!hasPeachConfig(base)) return override ? { ...override } : void 0;
4967
+ if (!hasPeachConfig(override)) return base ? { ...base } : void 0;
4968
+ return {
4969
+ runtimeVersion: override.runtimeVersion ?? base.runtimeVersion,
4970
+ nativeRenderer: override.nativeRenderer ?? base.nativeRenderer,
4971
+ mapKit: override.mapKit ?? base.mapKit,
4972
+ modules: { ...base.modules || {}, ...override.modules || {} },
4973
+ turboModules: { ...base.turboModules || {}, ...override.turboModules || {} },
4974
+ nativeModules: {
4975
+ ...base.nativeModules || {},
4976
+ ...override.nativeModules || {}
4977
+ },
4978
+ nativeViews: { ...base.nativeViews || {}, ...override.nativeViews || {} },
4979
+ nativeHybridObjects: {
4980
+ ...base.nativeHybridObjects || {},
4981
+ ...override.nativeHybridObjects || {}
4982
+ },
4983
+ env: { ...base.env || {}, ...override.env || {} },
4984
+ network: {
4985
+ remap: { ...base.network?.remap || {}, ...override.network?.remap || {} }
4986
+ },
4987
+ settings: {
4988
+ ...base.settings || {},
4989
+ ...override.settings || {}
4990
+ },
4991
+ initialProps: { ...base.initialProps || {}, ...override.initialProps || {} },
4992
+ initialState: { ...base.initialState || {}, ...override.initialState || {} }
4993
+ };
4994
+ }
4995
+ function readPeachConfigFromSearchParams(searchParams) {
4996
+ const raw = searchParams.get(PEACH_CONFIG_QUERY_PARAM);
4997
+ if (!raw) return void 0;
4998
+ let parsed;
4999
+ try {
5000
+ parsed = JSON.parse(raw);
5001
+ } catch (error) {
5002
+ const message = error instanceof Error ? error.message : String(error);
5003
+ console.warn(`[peach] invalid ${PEACH_CONFIG_QUERY_PARAM}: ${message}`);
5004
+ return void 0;
5005
+ }
5006
+ if (isRecord(parsed)) readNativeRenderer(parsed.nativeRenderer);
5007
+ return isPeachConfig(parsed) && hasPeachConfig(parsed) ? parsed : void 0;
5008
+ }
5009
+ function applyPeachConfigToUrl(url, config) {
5010
+ const parsed = new URL(url);
5011
+ if (hasPeachConfig(config)) {
5012
+ parsed.searchParams.set(PEACH_CONFIG_QUERY_PARAM, JSON.stringify(config));
5013
+ } else {
5014
+ parsed.searchParams.delete(PEACH_CONFIG_QUERY_PARAM);
5015
+ }
5016
+ return parsed.toString();
5017
+ }
5018
+ var PEACH_CONFIG_QUERY_PARAM, BUNDLE_CONFIG_PREFIX, PEACH_CONFIGURED_FILES_HOOK;
5019
+ var init_config = __esm({
5020
+ "src/config.ts"() {
5021
+ "use strict";
5022
+ init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
5023
+ init_version();
5024
+ init_bundleGlobalFooter();
5025
+ init_is_record();
5026
+ init_nativeViewSourceContract();
5027
+ PEACH_CONFIG_QUERY_PARAM = "peachConfig";
5028
+ BUNDLE_CONFIG_PREFIX = "globalThis.__peachBundleConfig=";
5029
+ PEACH_CONFIGURED_FILES_HOOK = "__peachInstallConfiguredFiles";
5030
+ }
5031
+ });
5032
+
4781
5033
  // ../contrast-bundler/src/posixPath.ts
4782
5034
  function isAbsolute(p) {
4783
5035
  return p.charCodeAt(0) === 47;
@@ -4808,12 +5060,12 @@ function normalize(p) {
4808
5060
  if (trailingSlash) joined += "/";
4809
5061
  return absolute ? "/" + joined : joined;
4810
5062
  }
4811
- function join4(...parts) {
5063
+ function join5(...parts) {
4812
5064
  const present = parts.filter((part) => part.length > 0);
4813
5065
  if (present.length === 0) return ".";
4814
5066
  return normalize(present.join("/"));
4815
5067
  }
4816
- function resolve2(...parts) {
5068
+ function resolve3(...parts) {
4817
5069
  let resolved = "";
4818
5070
  let absolute = false;
4819
5071
  for (let i = parts.length - 1; i >= 0 && !absolute; i--) {
@@ -4872,8 +5124,8 @@ var init_posixPath = __esm({
4872
5124
  delimiter,
4873
5125
  isAbsolute,
4874
5126
  normalize,
4875
- join: join4,
4876
- resolve: resolve2,
5127
+ join: join5,
5128
+ resolve: resolve3,
4877
5129
  dirname: dirname4,
4878
5130
  basename: basename3,
4879
5131
  extname,
@@ -5115,16 +5367,16 @@ function sendJavaScript(req, res, source) {
5115
5367
  res.end(req.method === "HEAD" ? void 0 : source);
5116
5368
  }
5117
5369
  function resolveReplacementModuleFile(fromFile, specifier) {
5118
- const base = import_node_path8.default.resolve(import_node_path8.default.dirname(fromFile), specifier);
5370
+ const base = import_node_path9.default.resolve(import_node_path9.default.dirname(fromFile), specifier);
5119
5371
  const candidates = [
5120
5372
  ...REPLACEMENT_MODULE_EXTENSIONS.some(
5121
- (ext) => ext === import_node_path8.default.extname(base).toLowerCase()
5373
+ (ext) => ext === import_node_path9.default.extname(base).toLowerCase()
5122
5374
  ) ? [base] : [],
5123
5375
  ...REPLACEMENT_MODULE_EXTENSIONS.map((ext) => base + ext),
5124
- ...REPLACEMENT_MODULE_EXTENSIONS.map((ext) => import_node_path8.default.join(base, `index${ext}`))
5376
+ ...REPLACEMENT_MODULE_EXTENSIONS.map((ext) => import_node_path9.default.join(base, `index${ext}`))
5125
5377
  ];
5126
5378
  const found = candidates.find(
5127
- (candidate) => (0, import_node_fs9.statSync)(candidate, { throwIfNoEntry: false })?.isFile()
5379
+ (candidate) => (0, import_node_fs10.statSync)(candidate, { throwIfNoEntry: false })?.isFile()
5128
5380
  );
5129
5381
  if (!found) {
5130
5382
  throw new Error(
@@ -5135,8 +5387,8 @@ function resolveReplacementModuleFile(fromFile, specifier) {
5135
5387
  }
5136
5388
  function isInsideAny(roots, file) {
5137
5389
  return roots.some((root) => {
5138
- const relative3 = import_node_path8.default.relative(root, file);
5139
- return !relative3.startsWith("..") && !import_node_path8.default.isAbsolute(relative3);
5390
+ const relative3 = import_node_path9.default.relative(root, file);
5391
+ return !relative3.startsWith("..") && !import_node_path9.default.isAbsolute(relative3);
5140
5392
  });
5141
5393
  }
5142
5394
  function isReplacementModuleRequestUrl(rawUrl) {
@@ -5185,19 +5437,19 @@ async function handleReplacementModuleRequest(req, res, options = {}) {
5185
5437
  res.end("missing path param");
5186
5438
  return true;
5187
5439
  }
5188
- const extension = import_node_path8.default.extname(targetPath).toLowerCase();
5440
+ const extension = import_node_path9.default.extname(targetPath).toLowerCase();
5189
5441
  if (!REPLACEMENT_MODULE_EXTENSIONS.some((allowed) => allowed === extension)) {
5190
5442
  res.writeHead(400, { "Content-Type": "text/plain; charset=utf-8" });
5191
5443
  res.end(`replacement files must be ${REPLACEMENT_MODULE_EXTENSIONS.join(", ")}`);
5192
5444
  return true;
5193
5445
  }
5194
- if (!import_node_path8.default.isAbsolute(targetPath)) {
5446
+ if (!import_node_path9.default.isAbsolute(targetPath)) {
5195
5447
  res.writeHead(400, { "Content-Type": "text/plain; charset=utf-8" });
5196
5448
  res.end("replacement file path must be absolute");
5197
5449
  return true;
5198
5450
  }
5199
5451
  const runtimePackages = new Set(url.searchParams.getAll("runtimePackage"));
5200
- const servedRoots = options.servedRoots?.map((root) => import_node_path8.default.resolve(root));
5452
+ const servedRoots = options.servedRoots?.map((root) => import_node_path9.default.resolve(root));
5201
5453
  if (servedRoots && !isInsideAny(servedRoots, targetPath)) {
5202
5454
  res.writeHead(403, { "Content-Type": "text/plain; charset=utf-8" });
5203
5455
  res.end("replacement file must be inside a folder the bundler serves");
@@ -5205,7 +5457,7 @@ async function handleReplacementModuleRequest(req, res, options = {}) {
5205
5457
  }
5206
5458
  let resolvedTargetPath;
5207
5459
  try {
5208
- resolvedTargetPath = await import_promises.default.realpath(targetPath);
5460
+ resolvedTargetPath = await import_promises4.default.realpath(targetPath);
5209
5461
  } catch (error) {
5210
5462
  const message = error instanceof Error ? error.message : String(error);
5211
5463
  res.writeHead(404, { "Content-Type": "text/plain; charset=utf-8" });
@@ -5213,7 +5465,7 @@ async function handleReplacementModuleRequest(req, res, options = {}) {
5213
5465
  return true;
5214
5466
  }
5215
5467
  if (servedRoots) {
5216
- const realRoots = (await Promise.all(servedRoots.map((root) => import_promises.default.realpath(root).catch(() => null)))).filter((root) => root !== null);
5468
+ const realRoots = (await Promise.all(servedRoots.map((root) => import_promises4.default.realpath(root).catch(() => null)))).filter((root) => root !== null);
5217
5469
  if (!isInsideAny(realRoots, resolvedTargetPath)) {
5218
5470
  res.writeHead(403, { "Content-Type": "text/plain; charset=utf-8" });
5219
5471
  res.end("replacement file must be inside a folder the bundler serves");
@@ -5223,7 +5475,7 @@ async function handleReplacementModuleRequest(req, res, options = {}) {
5223
5475
  try {
5224
5476
  const compiled = compileReplacementModule({
5225
5477
  filePath: resolvedTargetPath,
5226
- source: await import_promises.default.readFile(resolvedTargetPath, "utf8"),
5478
+ source: await import_promises4.default.readFile(resolvedTargetPath, "utf8"),
5227
5479
  runtimePackages,
5228
5480
  // the imported file's url is this request's with only its path changed,
5229
5481
  // so the token, cache key and runtime packages carry over.
@@ -5249,14 +5501,14 @@ async function handleReplacementModuleRequest(req, res, options = {}) {
5249
5501
  }
5250
5502
  return true;
5251
5503
  }
5252
- var import_node_fs9, import_promises, import_node_path8, REPLACEMENT_MODULE_ROUTE;
5504
+ var import_node_fs10, import_promises4, import_node_path9, REPLACEMENT_MODULE_ROUTE;
5253
5505
  var init_replacement_module_handler = __esm({
5254
5506
  "src/host/replacement-module-handler.ts"() {
5255
5507
  "use strict";
5256
5508
  init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
5257
- import_node_fs9 = require("node:fs");
5258
- import_promises = __toESM(require("node:fs/promises"), 1);
5259
- import_node_path8 = __toESM(require("node:path"), 1);
5509
+ import_node_fs10 = require("node:fs");
5510
+ import_promises4 = __toESM(require("node:fs/promises"), 1);
5511
+ import_node_path9 = __toESM(require("node:path"), 1);
5260
5512
  init_replacementModule();
5261
5513
  init_backend_origin();
5262
5514
  REPLACEMENT_MODULE_ROUTE = "/__sootsim-replacement-module";
@@ -5265,25 +5517,25 @@ var init_replacement_module_handler = __esm({
5265
5517
 
5266
5518
  // src/swift-source-file.ts
5267
5519
  function readPackageFile(root, file, maxBytes) {
5268
- const canonicalRoot = import_node_fs10.default.realpathSync(root);
5269
- const relative3 = import_node_path9.default.relative(canonicalRoot, import_node_fs10.default.realpathSync(file));
5270
- if (relative3 === ".." || relative3.startsWith(`..${import_node_path9.default.sep}`) || import_node_path9.default.isAbsolute(relative3)) {
5520
+ const canonicalRoot = import_node_fs11.default.realpathSync(root);
5521
+ const relative3 = import_node_path10.default.relative(canonicalRoot, import_node_fs11.default.realpathSync(file));
5522
+ if (relative3 === ".." || relative3.startsWith(`..${import_node_path10.default.sep}`) || import_node_path10.default.isAbsolute(relative3)) {
5271
5523
  throw new Error(`swift input escapes the selected package: ${file}`);
5272
5524
  }
5273
- let ancestor = import_node_path9.default.resolve(file);
5525
+ let ancestor = import_node_path10.default.resolve(file);
5274
5526
  while (ancestor !== canonicalRoot) {
5275
- if (import_node_fs10.default.lstatSync(ancestor).isSymbolicLink()) {
5527
+ if (import_node_fs11.default.lstatSync(ancestor).isSymbolicLink()) {
5276
5528
  throw new Error(`swift input is a symlink: ${ancestor}`);
5277
5529
  }
5278
- const parent = import_node_path9.default.dirname(ancestor);
5530
+ const parent = import_node_path10.default.dirname(ancestor);
5279
5531
  if (parent === ancestor)
5280
5532
  throw new Error(`swift input escapes the selected package: ${file}`);
5281
5533
  ancestor = parent;
5282
5534
  }
5283
- const expected = import_node_fs10.default.statSync(file);
5284
- const fd = import_node_fs10.default.openSync(file, import_node_fs10.default.constants.O_RDONLY | import_node_fs10.default.constants.O_NOFOLLOW);
5535
+ const expected = import_node_fs11.default.statSync(file);
5536
+ const fd = import_node_fs11.default.openSync(file, import_node_fs11.default.constants.O_RDONLY | import_node_fs11.default.constants.O_NOFOLLOW);
5285
5537
  try {
5286
- const stat = import_node_fs10.default.fstatSync(fd);
5538
+ const stat = import_node_fs11.default.fstatSync(fd);
5287
5539
  if (stat.dev !== expected.dev || stat.ino !== expected.ino) {
5288
5540
  throw new Error(`swift input changed while opening: ${file}`);
5289
5541
  }
@@ -5293,25 +5545,25 @@ function readPackageFile(root, file, maxBytes) {
5293
5545
  const bytes = Buffer.alloc(stat.size + 1);
5294
5546
  let offset = 0;
5295
5547
  while (offset < bytes.length) {
5296
- const count = import_node_fs10.default.readSync(fd, bytes, offset, bytes.length - offset, null);
5548
+ const count = import_node_fs11.default.readSync(fd, bytes, offset, bytes.length - offset, null);
5297
5549
  if (count === 0) break;
5298
5550
  offset += count;
5299
5551
  }
5300
- if (offset !== stat.size || import_node_fs10.default.fstatSync(fd).size !== stat.size) {
5552
+ if (offset !== stat.size || import_node_fs11.default.fstatSync(fd).size !== stat.size) {
5301
5553
  throw new Error(`swift input changed while reading: ${file}`);
5302
5554
  }
5303
5555
  return bytes.subarray(0, offset);
5304
5556
  } finally {
5305
- import_node_fs10.default.closeSync(fd);
5557
+ import_node_fs11.default.closeSync(fd);
5306
5558
  }
5307
5559
  }
5308
- var import_node_fs10, import_node_path9;
5560
+ var import_node_fs11, import_node_path10;
5309
5561
  var init_swift_source_file = __esm({
5310
5562
  "src/swift-source-file.ts"() {
5311
5563
  "use strict";
5312
5564
  init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
5313
- import_node_fs10 = __toESM(require("node:fs"), 1);
5314
- import_node_path9 = __toESM(require("node:path"), 1);
5565
+ import_node_fs11 = __toESM(require("node:fs"), 1);
5566
+ import_node_path10 = __toESM(require("node:path"), 1);
5315
5567
  }
5316
5568
  });
5317
5569
 
@@ -5357,9 +5609,9 @@ var init_swift_submit = __esm({
5357
5609
  // cli/app-project.ts
5358
5610
  function firstNamedFile(dir, names) {
5359
5611
  for (const name2 of names) {
5360
- const candidate = import_node_path11.default.join(dir, name2);
5612
+ const candidate = import_node_path12.default.join(dir, name2);
5361
5613
  try {
5362
- if (import_node_fs12.default.statSync(candidate).isFile()) return candidate;
5614
+ if (import_node_fs13.default.statSync(candidate).isFile()) return candidate;
5363
5615
  } catch {
5364
5616
  }
5365
5617
  }
@@ -5372,25 +5624,25 @@ function findRNXAppConfig(dir) {
5372
5624
  return firstNamedFile(dir, PEACH_APP_CONFIG_NAMES);
5373
5625
  }
5374
5626
  function resolveAppProject(projectRoot) {
5375
- const appDir = import_node_path11.default.resolve(projectRoot);
5627
+ const appDir = import_node_path12.default.resolve(projectRoot);
5376
5628
  try {
5377
- if (!import_node_fs12.default.statSync(appDir).isDirectory()) return null;
5629
+ if (!import_node_fs13.default.statSync(appDir).isDirectory()) return null;
5378
5630
  } catch {
5379
5631
  return null;
5380
5632
  }
5381
5633
  const configPath = findRNXAppConfig(appDir);
5382
- if (!configPath && !findExpoAppConfig(appDir) && !import_node_fs12.default.existsSync(import_node_path11.default.join(appDir, "package.json"))) {
5634
+ if (!configPath && !findExpoAppConfig(appDir) && !import_node_fs13.default.existsSync(import_node_path12.default.join(appDir, "package.json"))) {
5383
5635
  return null;
5384
5636
  }
5385
5637
  return { appDir, configPath };
5386
5638
  }
5387
- var import_node_fs12, import_node_path11, EXPO_APP_CONFIG_NAMES, PEACH_APP_CONFIG_NAMES;
5639
+ var import_node_fs13, import_node_path12, EXPO_APP_CONFIG_NAMES, PEACH_APP_CONFIG_NAMES;
5388
5640
  var init_app_project = __esm({
5389
5641
  "cli/app-project.ts"() {
5390
5642
  "use strict";
5391
5643
  init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
5392
- import_node_fs12 = __toESM(require("node:fs"), 1);
5393
- import_node_path11 = __toESM(require("node:path"), 1);
5644
+ import_node_fs13 = __toESM(require("node:fs"), 1);
5645
+ import_node_path12 = __toESM(require("node:path"), 1);
5394
5646
  EXPO_APP_CONFIG_NAMES = [
5395
5647
  "app.config.js",
5396
5648
  "app.config.ts",
@@ -5407,248 +5659,27 @@ var init_app_project = __esm({
5407
5659
  }
5408
5660
  });
5409
5661
 
5410
- // src/nativeViewSourceContract.ts
5411
- function isNativeViewSource(value) {
5412
- if (!isRecord(value)) return false;
5413
- if (value.type === "placeholder")
5414
- return (value.uri === void 0 || typeof value.uri === "string" && value.uri.length > 0) && (value.color === void 0 || typeof value.color === "string");
5415
- if (value.type === "web") {
5416
- if (typeof value.uri !== "string") return false;
5417
- try {
5418
- const url = new URL(value.uri);
5419
- return url.protocol === "http:" || url.protocol === "https:";
5420
- } catch {
5421
- return false;
5422
- }
5423
- }
5424
- return value.type === "video" && typeof value.uri === "string" && value.uri.length > 0 && ["paused", "loop", "muted"].every(
5425
- (key) => value[key] === void 0 || typeof value[key] === "boolean"
5426
- ) && (value.currentTime === void 0 || typeof value.currentTime === "number" && Number.isFinite(value.currentTime) && value.currentTime >= 0) && (value.resizeMode === void 0 || value.resizeMode === "contain" || value.resizeMode === "cover" || value.resizeMode === "stretch");
5427
- }
5428
- var init_nativeViewSourceContract = __esm({
5429
- "src/nativeViewSourceContract.ts"() {
5430
- "use strict";
5431
- init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
5432
- init_is_record();
5433
- }
5434
- });
5435
-
5436
- // src/config.ts
5437
- var config_exports = {};
5438
- __export(config_exports, {
5439
- PEACH_CONFIGURED_FILES_HOOK: () => PEACH_CONFIGURED_FILES_HOOK,
5440
- PEACH_CONFIG_QUERY_PARAM: () => PEACH_CONFIG_QUERY_PARAM,
5441
- applyPeachConfigToUrl: () => applyPeachConfigToUrl,
5442
- collectConfiguredFileModules: () => collectConfiguredFileModules,
5443
- createPeachBundleConfigFooter: () => createPeachBundleConfigFooter,
5444
- defineConfig: () => defineConfig,
5445
- detachPeachBundleConfigFooter: () => detachPeachBundleConfigFooter,
5446
- hasPeachConfig: () => hasPeachConfig,
5447
- isPackageStubs: () => isPackageStubs,
5448
- isPeachConfig: () => isPeachConfig,
5449
- mergePeachConfig: () => mergePeachConfig,
5450
- readNativeRenderer: () => readNativeRenderer,
5451
- readPeachBundleConfig: () => readPeachBundleConfig,
5452
- readPeachBundleConfigFooter: () => readPeachBundleConfigFooter,
5453
- readPeachConfigFromSearchParams: () => readPeachConfigFromSearchParams
5454
- });
5455
- function readNativeRenderer(value) {
5456
- if (value === void 0) return void 0;
5457
- if (value === "paper" || value === "fabric") return value;
5458
- throw new Error("nativeRenderer must be paper or fabric");
5459
- }
5460
- function isHybridObjectAnswer(answer) {
5461
- return answer === "unsupported" || isRecord(answer) && typeof answer.file === "string" && answer.file.length > 0;
5462
- }
5463
- function isHybridObjects(value) {
5464
- return isRecord(value) && Object.entries(value).every(
5465
- ([name2, answer]) => name2.length > 0 && isHybridObjectAnswer(answer)
5466
- );
5467
- }
5468
- function isPackageHybridObjects(value) {
5469
- return isRecord(value) && Object.entries(value).every(
5470
- ([name2, answer]) => name2.length > 0 && typeof answer === "string" && answer.length > 0 && answer !== "noop"
5471
- );
5472
- }
5473
- function isPackageStubs(value) {
5474
- if (value === "noop") return true;
5475
- if (!isRecord(value)) return false;
5476
- return (value.modules === void 0 || isRecord(value.modules) && Object.values(value.modules).every(
5477
- (stub) => typeof stub === "string" && stub.length > 0
5478
- )) && (value.views === void 0 || isRecord(value.views) && Object.values(value.views).every(
5479
- (stub) => typeof stub === "string" && stub.length > 0 || isNativeViewSource(stub)
5480
- )) && (value.hybridObjects === void 0 || isPackageHybridObjects(value.hybridObjects));
5481
- }
5482
- function collectConfiguredFileModules(config) {
5483
- return [
5484
- ...new Set(
5485
- [
5486
- "modules",
5487
- "turboModules",
5488
- "nativeModules",
5489
- "nativeViews",
5490
- "nativeHybridObjects"
5491
- ].flatMap((key) => {
5492
- const entries = config && Reflect.get(config, key);
5493
- if (!isRecord(entries)) return [];
5494
- return Object.values(entries).flatMap(
5495
- (entry) => isRecord(entry) && typeof entry.file === "string" ? [entry.file] : []
5496
- );
5497
- })
5498
- )
5499
- ];
5500
- }
5501
- function isPeachConfig(value) {
5502
- if (!isRecord(value)) return false;
5503
- return (value.nativeRenderer === void 0 || value.nativeRenderer === "paper" || value.nativeRenderer === "fabric") && (value.mapKit === void 0 || isRecord(value.mapKit) && typeof value.mapKit.token === "string" && value.mapKit.token.length > 0 && value.mapKit.token === value.mapKit.token.trim()) && (value.runtimeVersion === void 0 || typeof value.runtimeVersion === "string" && value.runtimeVersion === value.runtimeVersion.trim() && isValidRuntimeVersion(value.runtimeVersion)) && [
5504
- "modules",
5505
- "packages",
5506
- "turboModules",
5507
- "nativeModules",
5508
- "nativeViews",
5509
- "nativeHybridObjects",
5510
- "env",
5511
- "network",
5512
- "settings",
5513
- "initialProps",
5514
- "initialState"
5515
- ].every((key) => value[key] === void 0 || isRecord(value[key])) && (value.packages === void 0 || isRecord(value.packages) && Object.values(value.packages).every(isPackageStubs)) && (value.nativeHybridObjects === void 0 || isHybridObjects(value.nativeHybridObjects)) && (value.nativeViews === void 0 || isRecord(value.nativeViews) && Object.values(value.nativeViews).every(
5516
- (entry) => entry === "noop" || isNativeViewSource(entry) || isRecord(entry) && typeof entry.file === "string" && entry.file.length > 0
5517
- ));
5518
- }
5519
- function readPeachBundleConfig(value) {
5520
- if (value === void 0 || value === null) return null;
5521
- if (!isRecord(value) || !isPeachConfig(value.config) || !Array.isArray(value.runtimePackages) || !value.runtimePackages.every((name2) => typeof name2 === "string")) {
5522
- throw new Error("configured bundle metadata is malformed");
5523
- }
5524
- return { config: value.config, runtimePackages: [...value.runtimePackages] };
5525
- }
5526
- function readPeachBundleConfigFooter(source) {
5527
- const start = findBundleFooter(source, BUNDLE_CONFIG_PREFIX);
5528
- if (start < 0) return null;
5529
- const end = source.indexOf("\n", start + 1);
5530
- const line = source.slice(start + 1, end < 0 ? void 0 : end);
5531
- if (!line.endsWith(";")) throw new Error("configured bundle footer is truncated");
5532
- const result = readPeachBundleConfig(
5533
- JSON.parse(line.slice(BUNDLE_CONFIG_PREFIX.length, -1))
5534
- );
5535
- if (!result) throw new Error("configured bundle footer is empty");
5536
- return result;
5537
- }
5538
- function createPeachBundleConfigFooter(config) {
5539
- const json = JSON.stringify(config).replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029").replace(/<\//g, "<\\/");
5540
- return "\n" + BUNDLE_CONFIG_PREFIX + json + ";";
5541
- }
5542
- function detachPeachBundleConfigFooter(source) {
5543
- const configuredBundle = readPeachBundleConfigFooter(source);
5544
- if (!configuredBundle) return { source, configuredBundle };
5545
- const start = findBundleFooter(source, BUNDLE_CONFIG_PREFIX);
5546
- const end = source.indexOf("\n", start + 1);
5547
- return {
5548
- source: source.slice(0, start) + source.slice(end < 0 ? source.length : end),
5549
- configuredBundle
5550
- };
5551
- }
5552
- function defineConfig(config) {
5553
- return config;
5554
- }
5555
- function hasOwnKeys(value) {
5556
- return !!value && Object.keys(value).length > 0;
5557
- }
5558
- function hasPeachConfig(config) {
5559
- if (!config) return false;
5560
- return config.nativeRenderer !== void 0 || config.mapKit !== void 0 || typeof config.runtimeVersion === "string" && config.runtimeVersion.length > 0 || hasOwnKeys(config.modules) || hasOwnKeys(config.turboModules) || hasOwnKeys(config.nativeModules) || hasOwnKeys(config.nativeViews) || hasOwnKeys(config.nativeHybridObjects) || hasOwnKeys(config.env) || hasOwnKeys(config.network?.remap) || hasOwnKeys(config.settings) || hasOwnKeys(config.initialProps) || hasOwnKeys(config.initialState);
5561
- }
5562
- function mergePeachConfig(base, override) {
5563
- if (!hasPeachConfig(base) && !hasPeachConfig(override)) return void 0;
5564
- if (!hasPeachConfig(base)) return override ? { ...override } : void 0;
5565
- if (!hasPeachConfig(override)) return base ? { ...base } : void 0;
5566
- return {
5567
- runtimeVersion: override.runtimeVersion ?? base.runtimeVersion,
5568
- nativeRenderer: override.nativeRenderer ?? base.nativeRenderer,
5569
- mapKit: override.mapKit ?? base.mapKit,
5570
- modules: { ...base.modules || {}, ...override.modules || {} },
5571
- turboModules: { ...base.turboModules || {}, ...override.turboModules || {} },
5572
- nativeModules: {
5573
- ...base.nativeModules || {},
5574
- ...override.nativeModules || {}
5575
- },
5576
- nativeViews: { ...base.nativeViews || {}, ...override.nativeViews || {} },
5577
- nativeHybridObjects: {
5578
- ...base.nativeHybridObjects || {},
5579
- ...override.nativeHybridObjects || {}
5580
- },
5581
- env: { ...base.env || {}, ...override.env || {} },
5582
- network: {
5583
- remap: { ...base.network?.remap || {}, ...override.network?.remap || {} }
5584
- },
5585
- settings: {
5586
- ...base.settings || {},
5587
- ...override.settings || {}
5588
- },
5589
- initialProps: { ...base.initialProps || {}, ...override.initialProps || {} },
5590
- initialState: { ...base.initialState || {}, ...override.initialState || {} }
5591
- };
5592
- }
5593
- function readPeachConfigFromSearchParams(searchParams) {
5594
- const raw = searchParams.get(PEACH_CONFIG_QUERY_PARAM);
5595
- if (!raw) return void 0;
5596
- let parsed;
5597
- try {
5598
- parsed = JSON.parse(raw);
5599
- } catch (error) {
5600
- const message = error instanceof Error ? error.message : String(error);
5601
- console.warn(`[peach] invalid ${PEACH_CONFIG_QUERY_PARAM}: ${message}`);
5602
- return void 0;
5603
- }
5604
- if (isRecord(parsed)) readNativeRenderer(parsed.nativeRenderer);
5605
- return isPeachConfig(parsed) && hasPeachConfig(parsed) ? parsed : void 0;
5606
- }
5607
- function applyPeachConfigToUrl(url, config) {
5608
- const parsed = new URL(url);
5609
- if (hasPeachConfig(config)) {
5610
- parsed.searchParams.set(PEACH_CONFIG_QUERY_PARAM, JSON.stringify(config));
5611
- } else {
5612
- parsed.searchParams.delete(PEACH_CONFIG_QUERY_PARAM);
5613
- }
5614
- return parsed.toString();
5615
- }
5616
- var PEACH_CONFIG_QUERY_PARAM, BUNDLE_CONFIG_PREFIX, PEACH_CONFIGURED_FILES_HOOK;
5617
- var init_config = __esm({
5618
- "src/config.ts"() {
5619
- "use strict";
5620
- init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
5621
- init_version();
5622
- init_bundleGlobalFooter();
5623
- init_is_record();
5624
- init_nativeViewSourceContract();
5625
- PEACH_CONFIG_QUERY_PARAM = "peachConfig";
5626
- BUNDLE_CONFIG_PREFIX = "globalThis.__peachBundleConfig=";
5627
- PEACH_CONFIGURED_FILES_HOOK = "__peachInstallConfiguredFiles";
5628
- }
5629
- });
5630
-
5631
- // src/nitro-source.ts
5632
- function object(value) {
5633
- return value !== null && typeof value === "object" && !Array.isArray(value);
5662
+ // src/nitro-source.ts
5663
+ function object(value) {
5664
+ return value !== null && typeof value === "object" && !Array.isArray(value);
5634
5665
  }
5635
5666
  function readJson(root, relative3) {
5636
5667
  return JSON.parse(
5637
5668
  readPackageFile(
5638
5669
  root,
5639
- import_node_path17.default.join(root, relative3),
5670
+ import_node_path18.default.join(root, relative3),
5640
5671
  MAX_SWIFT_COMPILE_SOURCE_BYTES
5641
5672
  ).toString("utf8")
5642
5673
  );
5643
5674
  }
5644
5675
  function registrations(root) {
5645
- const directory = import_node_path17.default.join(root, "nitrogen/generated/ios");
5646
- const initializers = import_node_fs17.default.readdirSync(directory).filter((file) => file.endsWith("Autolinking.mm"));
5676
+ const directory = import_node_path18.default.join(root, "nitrogen/generated/ios");
5677
+ const initializers = import_node_fs18.default.readdirSync(directory).filter((file) => file.endsWith("Autolinking.mm"));
5647
5678
  if (initializers.length !== 1)
5648
5679
  throw new Error(`${root}: expected one generated Nitro iOS initializer`);
5649
5680
  const source = readPackageFile(
5650
5681
  root,
5651
- import_node_path17.default.join(directory, initializers[0]),
5682
+ import_node_path18.default.join(directory, initializers[0]),
5652
5683
  MAX_SWIFT_COMPILE_SOURCE_BYTES
5653
5684
  ).toString("utf8");
5654
5685
  const namespaces = [
@@ -5690,12 +5721,12 @@ function registrations(root) {
5690
5721
  return { namespace, swiftModule, classes, views: viewNames(root, classes) };
5691
5722
  }
5692
5723
  function viewNames(root, classes) {
5693
- const directory = import_node_path17.default.join(root, "nitrogen/generated/shared/json");
5694
- if (!import_node_fs17.default.existsSync(directory)) return /* @__PURE__ */ new Set();
5724
+ const directory = import_node_path18.default.join(root, "nitrogen/generated/shared/json");
5725
+ if (!import_node_fs18.default.existsSync(directory)) return /* @__PURE__ */ new Set();
5695
5726
  const views = /* @__PURE__ */ new Set();
5696
- for (const file of import_node_fs17.default.readdirSync(directory)) {
5727
+ for (const file of import_node_fs18.default.readdirSync(directory)) {
5697
5728
  if (!file.endsWith("Config.json")) continue;
5698
- const config = readJson(root, import_node_path17.default.join("nitrogen/generated/shared/json", file));
5729
+ const config = readJson(root, import_node_path18.default.join("nitrogen/generated/shared/json", file));
5699
5730
  const name2 = object(config) ? config.uiViewClassName : void 0;
5700
5731
  if (typeof name2 === "string" && classes.some((entry) => entry.name === name2))
5701
5732
  views.add(name2);
@@ -5703,21 +5734,21 @@ function viewNames(root, classes) {
5703
5734
  return views;
5704
5735
  }
5705
5736
  function hasNitroIosInitializer(root) {
5706
- const generated = import_node_path17.default.join(root, "nitrogen/generated/ios");
5707
- return import_node_fs17.default.existsSync(generated) && import_node_fs17.default.readdirSync(generated).some((file) => file.endsWith("Autolinking.mm"));
5737
+ const generated = import_node_path18.default.join(root, "nitrogen/generated/ios");
5738
+ return import_node_fs18.default.existsSync(generated) && import_node_fs18.default.readdirSync(generated).some((file) => file.endsWith("Autolinking.mm"));
5708
5739
  }
5709
5740
  function nitroRegisteredNames(root) {
5710
5741
  if (!hasNitroIosInitializer(root)) return null;
5711
5742
  const { classes, views } = registrations(root);
5712
5743
  return { names: classes.map(({ name: name2 }) => name2), views: [...views].sort() };
5713
5744
  }
5714
- var import_node_fs17, import_node_path17;
5745
+ var import_node_fs18, import_node_path18;
5715
5746
  var init_nitro_source = __esm({
5716
5747
  "src/nitro-source.ts"() {
5717
5748
  "use strict";
5718
5749
  init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
5719
- import_node_fs17 = __toESM(require("node:fs"), 1);
5720
- import_node_path17 = __toESM(require("node:path"), 1);
5750
+ import_node_fs18 = __toESM(require("node:fs"), 1);
5751
+ import_node_path18 = __toESM(require("node:path"), 1);
5721
5752
  init_swift_source_file();
5722
5753
  init_swift_submit();
5723
5754
  }
@@ -5839,7 +5870,7 @@ function resolveAppStubs(appDir, config, configDir) {
5839
5870
  const { modules, views, hybridObjects } = expandStubs(appDir, source);
5840
5871
  assertRegisteredHybridObjects(appDir, source, hybridObjects);
5841
5872
  for (const [name2, answer] of Object.entries(hybridObjects))
5842
- nativeHybridObjects[name2] = answer === "unsupported" ? answer : { file: (0, import_node_path18.resolve)(source.baseDir, answer) };
5873
+ nativeHybridObjects[name2] = answer === "unsupported" ? answer : { file: (0, import_node_path19.resolve)(source.baseDir, answer) };
5843
5874
  for (const [name2, stub] of Object.entries(modules))
5844
5875
  nativeModules[name2] = lowerStub(stub, source.baseDir);
5845
5876
  for (const [name2, stub] of Object.entries(views))
@@ -5903,10 +5934,10 @@ function assertRegisteredHybridObjects(appDir, source, hybridObjects) {
5903
5934
  );
5904
5935
  }
5905
5936
  function lowerStub(stub, baseDir) {
5906
- return stub === "noop" ? stub : { file: (0, import_node_path18.resolve)(baseDir, stub) };
5937
+ return stub === "noop" ? stub : { file: (0, import_node_path19.resolve)(baseDir, stub) };
5907
5938
  }
5908
5939
  function readPackageJson(dir) {
5909
- const text2 = readSmallFile((0, import_node_path18.join)(dir, "package.json"));
5940
+ const text2 = readSmallFile((0, import_node_path19.join)(dir, "package.json"));
5910
5941
  if (!text2) return null;
5911
5942
  try {
5912
5943
  const parsed = JSON.parse(text2);
@@ -5918,9 +5949,9 @@ function readPackageJson(dir) {
5918
5949
  function installedPackageDir(appDir, name2) {
5919
5950
  let current = appDir;
5920
5951
  while (true) {
5921
- const dir = (0, import_node_path18.join)(current, "node_modules", name2);
5922
- if ((0, import_node_fs18.existsSync)((0, import_node_path18.join)(dir, "package.json"))) return (0, import_node_fs18.realpathSync)(dir);
5923
- const parent = (0, import_node_path18.dirname)(current);
5952
+ const dir = (0, import_node_path19.join)(current, "node_modules", name2);
5953
+ if ((0, import_node_fs19.existsSync)((0, import_node_path19.join)(dir, "package.json"))) return (0, import_node_fs19.realpathSync)(dir);
5954
+ const parent = (0, import_node_path19.dirname)(current);
5924
5955
  if (parent === current) return null;
5925
5956
  current = parent;
5926
5957
  }
@@ -6012,7 +6043,7 @@ function mergeRequests(previous, next) {
6012
6043
  function packageNativeRequests(dir) {
6013
6044
  const found = /* @__PURE__ */ new Map();
6014
6045
  const directories = scanRepository(dir).directories.filter((sub) => {
6015
- const segments = (0, import_node_path18.relative)(dir, sub).split("/");
6046
+ const segments = (0, import_node_path19.relative)(dir, sub).split("/");
6016
6047
  return !NATIVE_SOURCE_DIRS.has(segments[0]) && !segments.some((segment) => PACKAGE_SKIP_DIRS.has(segment));
6017
6048
  });
6018
6049
  let files = 0;
@@ -6020,7 +6051,7 @@ function packageNativeRequests(dir) {
6020
6051
  for (const name2 of listDir(sub)) {
6021
6052
  if (!SOURCE_FILE.test(name2) || name2.endsWith(".d.ts") || files >= 2e3) continue;
6022
6053
  files++;
6023
- const file = (0, import_node_path18.join)(sub, name2);
6054
+ const file = (0, import_node_path19.join)(sub, name2);
6024
6055
  const text2 = readSmallFile(file);
6025
6056
  if (!text2) continue;
6026
6057
  for (const { line: _line, ...request } of sourceNativeRequests(file, text2, true))
@@ -6139,27 +6170,27 @@ function wireSlotMigration(appDir, configPath, wire, kept = []) {
6139
6170
  }
6140
6171
  function listDir(dir) {
6141
6172
  try {
6142
- return (0, import_node_fs18.readdirSync)(dir);
6173
+ return (0, import_node_fs19.readdirSync)(dir);
6143
6174
  } catch {
6144
6175
  return [];
6145
6176
  }
6146
6177
  }
6147
6178
  function readSmallFile(file) {
6148
6179
  try {
6149
- return (0, import_node_fs18.statSync)(file).size <= 1024 * 1024 ? (0, import_node_fs18.readFileSync)(file, "utf8") : null;
6180
+ return (0, import_node_fs19.statSync)(file).size <= 1024 * 1024 ? (0, import_node_fs19.readFileSync)(file, "utf8") : null;
6150
6181
  } catch {
6151
6182
  return null;
6152
6183
  }
6153
6184
  }
6154
6185
  function hasNativeCode(dir, platform) {
6155
- const expoConfig = (0, import_node_path18.join)(dir, "expo-module.config.json");
6186
+ const expoConfig = (0, import_node_path19.join)(dir, "expo-module.config.json");
6156
6187
  const platforms = metadataValue(readProjectJson(expoConfig), "platforms");
6157
6188
  if (Array.isArray(platforms))
6158
6189
  return platforms.includes(platform) || platform === "ios" && platforms.includes("apple");
6159
- if ([platform, "expo-module.config.json"].some((entry) => (0, import_node_fs18.existsSync)((0, import_node_path18.join)(dir, entry))))
6190
+ if ([platform, "expo-module.config.json"].some((entry) => (0, import_node_fs19.existsSync)((0, import_node_path19.join)(dir, entry))))
6160
6191
  return true;
6161
6192
  if (listDir(dir).some((name2) => name2.endsWith(".podspec"))) return true;
6162
- const manifest = readSmallFile((0, import_node_path18.join)(dir, "package.json"));
6193
+ const manifest = readSmallFile((0, import_node_path19.join)(dir, "package.json"));
6163
6194
  return manifest !== null && manifest.includes('"codegenConfig"');
6164
6195
  }
6165
6196
  function scanLocalNative(appDir, pkg, answered, platform, knownPackages = /* @__PURE__ */ new Set(), includeLegacy = false, providers) {
@@ -6172,7 +6203,7 @@ function scanLocalNative(appDir, pkg, answered, platform, knownPackages = /* @__
6172
6203
  (excluded) => dir === excluded || dir.startsWith(`${excluded}/`)
6173
6204
  ))
6174
6205
  continue;
6175
- if ((0, import_node_fs18.existsSync)((0, import_node_path18.join)(dir, "expo-module.config.json"))) {
6206
+ if ((0, import_node_fs19.existsSync)((0, import_node_path19.join)(dir, "expo-module.config.json"))) {
6176
6207
  if (platform && !hasNativeCode(dir, platform)) {
6177
6208
  excludedModuleDirs.push(dir);
6178
6209
  continue;
@@ -6181,7 +6212,7 @@ function scanLocalNative(appDir, pkg, answered, platform, knownPackages = /* @__
6181
6212
  }
6182
6213
  for (const name2 of listDir(dir)) {
6183
6214
  if (SOURCE_FILE.test(name2) && !name2.endsWith(".d.ts"))
6184
- sourceFiles.push((0, import_node_path18.join)(dir, name2));
6215
+ sourceFiles.push((0, import_node_path19.join)(dir, name2));
6185
6216
  }
6186
6217
  }
6187
6218
  }
@@ -6191,7 +6222,7 @@ function scanLocalNative(appDir, pkg, answered, platform, knownPackages = /* @__
6191
6222
  scanRepository(dir).directories.flatMap(
6192
6223
  (sub) => listDir(sub).filter(
6193
6224
  (name2) => NATIVE_SOURCE_FILE.test(name2) && (!platform || (platform === "ios" ? name2.endsWith(".swift") : name2.endsWith(".kt")))
6194
- ).map((name2) => (0, import_node_path18.join)(sub, name2))
6225
+ ).map((name2) => (0, import_node_path19.join)(sub, name2))
6195
6226
  )
6196
6227
  ])
6197
6228
  );
@@ -6200,7 +6231,7 @@ function scanLocalNative(appDir, pkg, answered, platform, knownPackages = /* @__
6200
6231
  const known = owners.get(dir);
6201
6232
  if (known) return known;
6202
6233
  const name2 = readPackageJson(dir)?.name;
6203
- const parent = (0, import_node_path18.dirname)(dir);
6234
+ const parent = (0, import_node_path19.dirname)(dir);
6204
6235
  const result = typeof name2 === "string" ? name2 : parent === dir ? pkg.name ?? "app" : owner(parent);
6205
6236
  owners.set(dir, result);
6206
6237
  return result;
@@ -6214,18 +6245,18 @@ function scanLocalNative(appDir, pkg, answered, platform, knownPackages = /* @__
6214
6245
  return;
6215
6246
  }
6216
6247
  providers ??= dependencyNativeOwners(appDir, pkg);
6217
- const packageName = providers.get(key) ?? owner((0, import_node_path18.dirname)(file));
6248
+ const packageName = providers.get(key) ?? owner((0, import_node_path19.dirname)(file));
6218
6249
  if (knownPackages.has(packageName)) return;
6219
6250
  const moduleDir = expoModuleDirs.find((dir) => file.startsWith(`${dir}/`)) ?? null;
6220
6251
  found.set(key, {
6221
6252
  kind,
6222
6253
  name: name2,
6223
6254
  package: packageName,
6224
- path: `${(0, import_node_path18.relative)(appDir, file)}:${line}`,
6225
- expoModule: moduleDir ? (0, import_node_path18.relative)(appDir, moduleDir) || "." : null,
6255
+ path: `${(0, import_node_path19.relative)(appDir, file)}:${line}`,
6256
+ expoModule: moduleDir ? (0, import_node_path19.relative)(appDir, moduleDir) || "." : null,
6226
6257
  optional,
6227
6258
  swift: moduleDir ? (nativeFilesByModule.get(moduleDir) ?? []).some(
6228
- (path21) => path21.endsWith(".swift") && [...(readSmallFile(path21) ?? "").matchAll(/\bName\(\s*"(\w+)"\s*\)/g)].some(
6259
+ (path22) => path22.endsWith(".swift") && [...(readSmallFile(path22) ?? "").matchAll(/\bName\(\s*"(\w+)"\s*\)/g)].some(
6229
6260
  (match) => match[1] === name2
6230
6261
  )
6231
6262
  ) : false,
@@ -6266,30 +6297,30 @@ function workspacePackageDirs(appDir, pkg) {
6266
6297
  for (const name2 of Object.keys({ ...pkg.dependencies, ...pkg.devDependencies })) {
6267
6298
  let current = appDir;
6268
6299
  while (true) {
6269
- const link = (0, import_node_path18.join)(current, "node_modules", name2);
6270
- if ((0, import_node_fs18.existsSync)(link)) {
6271
- if ((0, import_node_fs18.lstatSync)(link).isSymbolicLink()) {
6272
- const target = (0, import_node_fs18.realpathSync)(link);
6300
+ const link = (0, import_node_path19.join)(current, "node_modules", name2);
6301
+ if ((0, import_node_fs19.existsSync)(link)) {
6302
+ if ((0, import_node_fs19.lstatSync)(link).isSymbolicLink()) {
6303
+ const target = (0, import_node_fs19.realpathSync)(link);
6273
6304
  if (!target.split("/").includes("node_modules") && !target.startsWith(`${appDir}/`)) {
6274
6305
  dirs.add(target);
6275
6306
  }
6276
6307
  }
6277
6308
  break;
6278
6309
  }
6279
- const parent = (0, import_node_path18.dirname)(current);
6310
+ const parent = (0, import_node_path19.dirname)(current);
6280
6311
  if (parent === current) break;
6281
6312
  current = parent;
6282
6313
  }
6283
6314
  }
6284
6315
  return [...dirs];
6285
6316
  }
6286
- var import_node_fs18, import_node_path18, import_version_range, import_oxc_parser2, import_sucrase, SOURCE_FILE, NATIVE_LOOKUP, NATIVE_SOURCE_DIRS, PACKAGE_SKIP_DIRS, NATIVE_SOURCE_FILE;
6317
+ var import_node_fs19, import_node_path19, import_version_range, import_oxc_parser2, import_sucrase, SOURCE_FILE, NATIVE_LOOKUP, NATIVE_SOURCE_DIRS, PACKAGE_SKIP_DIRS, NATIVE_SOURCE_FILE;
6287
6318
  var init_app_stubs = __esm({
6288
6319
  "cli/app-stubs.ts"() {
6289
6320
  "use strict";
6290
6321
  init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
6291
- import_node_fs18 = require("node:fs");
6292
- import_node_path18 = require("node:path");
6322
+ import_node_fs19 = require("node:fs");
6323
+ import_node_path19 = require("node:path");
6293
6324
  import_version_range = require("@peach/compat/version-range");
6294
6325
  import_oxc_parser2 = require("oxc-parser");
6295
6326
  import_sucrase = require("sucrase");
@@ -6325,12 +6356,12 @@ function resolveFileEntries(entries, configDir) {
6325
6356
  return Object.fromEntries(
6326
6357
  Object.entries(entries).map(([name2, resolution]) => [
6327
6358
  name2,
6328
- resolution && typeof resolution === "object" && "file" in resolution && typeof resolution.file === "string" ? { ...resolution, file: import_node_path19.default.resolve(configDir, resolution.file) } : resolution
6359
+ resolution && typeof resolution === "object" && "file" in resolution && typeof resolution.file === "string" ? { ...resolution, file: import_node_path20.default.resolve(configDir, resolution.file) } : resolution
6329
6360
  ])
6330
6361
  );
6331
6362
  }
6332
6363
  function resolveConfigReplacementFiles(config, configPath) {
6333
- const configDir = import_node_path19.default.dirname(configPath);
6364
+ const configDir = import_node_path20.default.dirname(configPath);
6334
6365
  return {
6335
6366
  ...config,
6336
6367
  modules: resolveFileEntries(config.modules, configDir)
@@ -6346,7 +6377,7 @@ async function loadRNXAppStubs(project) {
6346
6377
  return resolveAppStubs(
6347
6378
  project.appDir,
6348
6379
  config,
6349
- project.configPath ? import_node_path19.default.dirname(project.configPath) : project.appDir
6380
+ project.configPath ? import_node_path20.default.dirname(project.configPath) : project.appDir
6350
6381
  );
6351
6382
  } catch (error) {
6352
6383
  const message = error instanceof Error ? error.message : String(error);
@@ -6365,7 +6396,7 @@ async function loadConfigFile(project) {
6365
6396
  [`${rnxPublicBrand.packageName}/config`]: config_exports
6366
6397
  }
6367
6398
  });
6368
- const loaded3 = project.configPath.endsWith(".json") ? JSON.parse((0, import_node_fs19.readFileSync)(project.configPath, "utf8")) : await jiti.import(project.configPath, { default: true });
6399
+ const loaded3 = project.configPath.endsWith(".json") ? JSON.parse((0, import_node_fs20.readFileSync)(project.configPath, "utf8")) : await jiti.import(project.configPath, { default: true });
6369
6400
  if (!isPeachConfig(loaded3)) {
6370
6401
  throw new Error("the default export must be a peach config object");
6371
6402
  }
@@ -6401,13 +6432,13 @@ async function resolveRNXAppConfig(startDir = process.cwd()) {
6401
6432
  const project = resolveAppProject(startDir);
6402
6433
  return { project, ...await loadRNXAppStubs(project) };
6403
6434
  }
6404
- var import_node_fs19, import_node_path19, import_jiti, WIRE_SLOTS;
6435
+ var import_node_fs20, import_node_path20, import_jiti, WIRE_SLOTS;
6405
6436
  var init_app_config = __esm({
6406
6437
  "cli/app-config.ts"() {
6407
6438
  "use strict";
6408
6439
  init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
6409
- import_node_fs19 = require("node:fs");
6410
- import_node_path19 = __toESM(require("node:path"), 1);
6440
+ import_node_fs20 = require("node:fs");
6441
+ import_node_path20 = __toESM(require("node:path"), 1);
6411
6442
  import_jiti = require("jiti");
6412
6443
  init_config();
6413
6444
  init_config();
@@ -6504,14 +6535,14 @@ async function produceConfiguredBundle(source, config, runtimePackages) {
6504
6535
  const neededPackages = /* @__PURE__ */ new Set();
6505
6536
  const factories = [];
6506
6537
  const visit3 = (filePath) => {
6507
- const real = import_node_fs20.default.realpathSync(filePath);
6538
+ const real = import_node_fs21.default.realpathSync(filePath);
6508
6539
  const previous = files.get(real);
6509
6540
  if (previous !== void 0) return previous;
6510
6541
  const id = "peach-config-file:" + files.size;
6511
6542
  files.set(real, id);
6512
6543
  const compiled = compileReplacementModule({
6513
6544
  filePath: real,
6514
- source: import_node_fs20.default.readFileSync(real, "utf8"),
6545
+ source: import_node_fs21.default.readFileSync(real, "utf8"),
6515
6546
  runtimePackages,
6516
6547
  localModuleUrl: (specifier) => visit3(resolveReplacementModuleFile(real, specifier))
6517
6548
  });
@@ -6535,7 +6566,7 @@ async function produceConfiguredBundle(source, config, runtimePackages) {
6535
6566
  if (!entries || typeof entries !== "object") continue;
6536
6567
  for (const resolution of Object.values(entries)) {
6537
6568
  if (resolution && typeof resolution === "object" && "file" in resolution && typeof resolution.file === "string") {
6538
- resolution.file = visit3(import_node_path20.default.resolve(resolution.file));
6569
+ resolution.file = visit3(import_node_path21.default.resolve(resolution.file));
6539
6570
  }
6540
6571
  }
6541
6572
  }
@@ -6559,13 +6590,13 @@ async function produceConfiguredBundle(source, config, runtimePackages) {
6559
6590
  const identityStart = findBundleFooter(source, "globalThis.__sootsimModulePaths=");
6560
6591
  return prefix2 + (identityStart < 0 ? source + footer : source.slice(0, identityStart) + footer + source.slice(identityStart));
6561
6592
  }
6562
- var import_node_fs20, import_node_path20, import_sucrase2, import_terser;
6593
+ var import_node_fs21, import_node_path21, import_sucrase2, import_terser;
6563
6594
  var init_configured_bundle_producer = __esm({
6564
6595
  "src/configured-bundle-producer.ts"() {
6565
6596
  "use strict";
6566
6597
  init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
6567
- import_node_fs20 = __toESM(require("node:fs"), 1);
6568
- import_node_path20 = __toESM(require("node:path"), 1);
6598
+ import_node_fs21 = __toESM(require("node:fs"), 1);
6599
+ import_node_path21 = __toESM(require("node:path"), 1);
6569
6600
  import_sucrase2 = require("sucrase");
6570
6601
  import_terser = require("terser");
6571
6602
  init_dependencies();
@@ -7897,7 +7928,7 @@ function createBridge(wsPort, opts = {}) {
7897
7928
  const identity = getCliIdentity();
7898
7929
  const ownerPid = getStableOwnerPid();
7899
7930
  let terminalError;
7900
- const ready = new Promise((resolve4, reject) => {
7931
+ const ready = new Promise((resolve5, reject) => {
7901
7932
  const handshakeTimer = setTimeout(() => {
7902
7933
  reject(
7903
7934
  new Error(
@@ -7926,7 +7957,7 @@ function createBridge(wsPort, opts = {}) {
7926
7957
  );
7927
7958
  } catch {
7928
7959
  }
7929
- resolve4();
7960
+ resolve5();
7930
7961
  });
7931
7962
  ws.on("close", (code, reason) => {
7932
7963
  clearTimeout(handshakeTimer);
@@ -8022,7 +8053,7 @@ function createBridge(wsPort, opts = {}) {
8022
8053
  await ready;
8023
8054
  if (terminalError) throw terminalError;
8024
8055
  const id = nextId++;
8025
- return new Promise((resolve4, reject) => {
8056
+ return new Promise((resolve5, reject) => {
8026
8057
  const payload = { ...cmdOverride ?? cmd, id };
8027
8058
  if (payload.simId === void 0 && defaultSimId) {
8028
8059
  payload.simId = defaultSimId;
@@ -8038,7 +8069,7 @@ function createBridge(wsPort, opts = {}) {
8038
8069
  pending.set(id, {
8039
8070
  resolve: (v) => {
8040
8071
  clearTimeoutFn();
8041
- resolve4(v);
8072
+ resolve5(v);
8042
8073
  },
8043
8074
  reject: (e) => {
8044
8075
  clearTimeoutFn();
@@ -8964,6 +8995,7 @@ function waitReadyStatus(result, ready) {
8964
8995
  externalError: probe?.externalError ?? "",
8965
8996
  suppressedEntryError: probe?.suppressedEntryError ?? "",
8966
8997
  errors: probe?.errors ?? 0,
8998
+ startup: probe?.startup,
8967
8999
  bridgeError: result.error ?? "",
8968
9000
  paintedAppContent: probe?.paintedAppContent ?? false,
8969
9001
  treeQuietMs: probe?.treeQuietMs ?? 0,
@@ -9511,6 +9543,9 @@ async function waitForSootsimIdle({
9511
9543
  hierarchy = null
9512
9544
  }
9513
9545
  const nodes = []
9546
+ // identity beside each geometry entry, from the rows already read,
9547
+ // so a changed layout can name the nodes that moved.
9548
+ const nodeRows = []
9514
9549
  const LOADING_TEXT_REGEX = /^(creating webview|loading html|fetching bundle|waiting for first render|starting preview|loading simulator|fetching app code|waiting for native preview|starting design|loading canvas|fetching screens|painting the canvas|waiting for webview|waiting for preview|waiting for canvas|preview stalled)/i
9515
9550
  const noteLoading = (state, text) => {
9516
9551
  if (state?.busy === true) {
@@ -9531,7 +9566,9 @@ async function waitForSootsimIdle({
9531
9566
  // subtree count by their own layout; the rest of the screen
9532
9567
  // still catches the fling.
9533
9568
  const abs = n.backgroundPlayback ? layout : n.absolute || n.absolutePosition || layout
9534
- nodes.push(Math.round(abs.x) + ',' + Math.round(abs.y) + ',' + Math.round(layout.width))
9569
+ const geometry = Math.round(abs.x) + ',' + Math.round(abs.y) + ',' + Math.round(layout.width)
9570
+ nodes.push(geometry)
9571
+ nodeRows.push([String(n.nodeId ?? nodes.length - 1), (n.type || '?') + (n.testId ? '#' + n.testId : ''), geometry])
9535
9572
  }
9536
9573
  noteLoading(
9537
9574
  n.accessibilityState,
@@ -9543,7 +9580,9 @@ async function waitForSootsimIdle({
9543
9580
  if (root) {
9544
9581
  const walk = (n) => {
9545
9582
  if (n.layout && n.layout.width > 0) {
9546
- nodes.push(Math.round(n.layout.x) + ',' + Math.round(n.layout.y) + ',' + Math.round(n.layout.width))
9583
+ const geometry = Math.round(n.layout.x) + ',' + Math.round(n.layout.y) + ',' + Math.round(n.layout.width)
9584
+ nodes.push(geometry)
9585
+ nodeRows.push([String(n.id ?? nodes.length - 1), (n.type || '?') + (n.props?.testID ? '#' + n.props.testID : ''), geometry])
9547
9586
  }
9548
9587
  noteLoading(
9549
9588
  n.props?.accessibilityState,
@@ -9592,7 +9631,7 @@ async function waitForSootsimIdle({
9592
9631
  pixelFrameToken = token
9593
9632
  }
9594
9633
  }
9595
- return { layout: nodes.join(';'), nativeHierarchy, screenPixels, animating, shellAnimating, shellBlockers, layoutDirty, pendingFetches, workerBusy, webViewStarting, webViewBlocker, renderStatsAvailable, requestTotal, requestInFlight, appCommits, nodeCount }
9634
+ return { layout: nodes.join(';'), nodeRows, nativeHierarchy, screenPixels, animating, shellAnimating, shellBlockers, layoutDirty, pendingFetches, workerBusy, webViewStarting, webViewBlocker, renderStatsAvailable, requestTotal, requestInFlight, appCommits, nodeCount }
9596
9635
  }
9597
9636
 
9598
9637
  // how long generic background network is allowed to keep us waiting AFTER
@@ -9608,6 +9647,27 @@ async function waitForSootsimIdle({
9608
9647
  const networkQuietGraceMs = 1200
9609
9648
  let lastNativeHierarchy = null
9610
9649
  let lastLayout = ''
9650
+ let lastNodeRows = []
9651
+ // what moved between the last two differing polls, bounded; names the
9652
+ // nodes behind "layout changed" without keeping any poll history.
9653
+ let lastLayoutChange = null
9654
+ const describeLayoutChange = (before, after) => {
9655
+ const previous = new Map(before.map(([key, label, geometry]) => [key, [label, geometry]]))
9656
+ const moved = []
9657
+ const added = []
9658
+ const short = (label, key) => String(label).slice(0, 48) + ' [' + String(key).slice(0, 24) + ']'
9659
+ for (const [key, label, geometry] of after) {
9660
+ const was = previous.get(key)
9661
+ previous.delete(key)
9662
+ if (!was) added.push(short(label, key) + ' ' + geometry)
9663
+ else if (was[1] !== geometry) moved.push(short(label, key) + ' ' + was[1] + '->' + geometry)
9664
+ }
9665
+ const removed = [...previous].map(([key, [label, geometry]]) => short(label, key) + ' ' + geometry)
9666
+ return {
9667
+ moved: moved.length, added: added.length, removed: removed.length,
9668
+ movedSample: moved.slice(0, 3), addedSample: added.slice(0, 3), removedSample: removed.slice(0, 3),
9669
+ }
9670
+ }
9611
9671
  let lastScreenPixels = null
9612
9672
  let screenChangedPolls = 0
9613
9673
  let lastRequestTotal = -1
@@ -9686,7 +9746,10 @@ async function waitForSootsimIdle({
9686
9746
  if (snapshot.layoutDirty) dirtyPolls++
9687
9747
  if (snapshot.animating || snapshot.shellAnimating) animatingPolls++
9688
9748
  if (snapshot.webViewStarting) webViewStartingPolls++
9689
- if (polls > 1 && snapshot.layout !== lastLayout) layoutChangedPolls++
9749
+ if (polls > 1 && snapshot.layout !== lastLayout) {
9750
+ layoutChangedPolls++
9751
+ lastLayoutChange = describeLayoutChange(lastNodeRows, snapshot.nodeRows)
9752
+ }
9690
9753
  const screenChanged = paintStill && !screenUnchanged(snapshot.screenPixels, lastScreenPixels)
9691
9754
  if (polls > 1 && screenChanged) screenChangedPolls++
9692
9755
  const strictOk =
@@ -9753,6 +9816,7 @@ async function waitForSootsimIdle({
9753
9816
  }
9754
9817
  lastNativeHierarchy = snapshot.nativeHierarchy
9755
9818
  lastLayout = snapshot.layout
9819
+ lastNodeRows = snapshot.nodeRows
9756
9820
  lastScreenPixels = snapshot.screenPixels
9757
9821
  lastRequestTotal = snapshot.requestTotal
9758
9822
  lastAppCommits = snapshot.appCommits
@@ -9799,6 +9863,7 @@ async function waitForSootsimIdle({
9799
9863
  blockedBy:
9800
9864
  blockers.join(', ') + ' over ' + polls + ' polls (layout changed ' + layoutChangedPolls +
9801
9865
  'x, layoutDirty ' + dirtyPolls + 'x, animating ' + animatingPolls + 'x, webViewStarting ' + webViewStartingPolls + 'x, screen changed ' + screenChangedPolls + 'x)' +
9866
+ (lastLayoutChange ? '; last layout change ' + JSON.stringify(lastLayoutChange) : '') +
9802
9867
  (activityHost ? '; tenant activity ' + JSON.stringify({ initial: initialActivity, current: activityHost.getRenderActivity?.(), busySeen, idleSince, transitionEndedAt, startedAt: start }) : ''),
9803
9868
  }
9804
9869
  } finally {
@@ -9960,7 +10025,7 @@ async function tapResolvedTarget(bridge, args) {
9960
10025
  motionOnly: true
9961
10026
  });
9962
10027
  } catch {
9963
- await new Promise((resolve4) => setTimeout(resolve4, Math.min(120, remaining)));
10028
+ await new Promise((resolve5) => setTimeout(resolve5, Math.min(120, remaining)));
9964
10029
  }
9965
10030
  }
9966
10031
  return {
@@ -10216,7 +10281,7 @@ var LAUNCH_METADATA_KEYS = [
10216
10281
  // src/sleep.ts
10217
10282
  init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
10218
10283
  function sleep(ms) {
10219
- return new Promise((resolve4) => setTimeout(resolve4, ms));
10284
+ return new Promise((resolve5) => setTimeout(resolve5, ms));
10220
10285
  }
10221
10286
 
10222
10287
  // src/sim-client.ts
@@ -11078,13 +11143,13 @@ function isRnxCaptureRegionAtlas(value) {
11078
11143
 
11079
11144
  // src/vite-plugin-one.ts
11080
11145
  init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
11081
- var import_fs5 = __toESM(require("fs"), 1);
11146
+ var import_fs6 = __toESM(require("fs"), 1);
11082
11147
  var import_node_crypto6 = require("node:crypto");
11083
11148
  var import_node_http = __toESM(require("node:http"), 1);
11084
11149
  var import_node_https = __toESM(require("node:https"), 1);
11085
11150
  var import_node_url = require("node:url");
11086
- var import_path4 = __toESM(require("path"), 1);
11087
- var import_promises3 = require("stream/promises");
11151
+ var import_path5 = __toESM(require("path"), 1);
11152
+ var import_promises5 = require("stream/promises");
11088
11153
  var import_ws2 = require("ws");
11089
11154
  init_cli_runtime();
11090
11155
 
@@ -11161,58 +11226,19 @@ function launchRnxDesktop(bundleUrl, appName) {
11161
11226
 
11162
11227
  // src/vite-plugin-one.ts
11163
11228
  init_home_paths();
11164
- init_replacement_module_handler();
11165
11229
 
11166
- // src/host/rolldown-bundle-forward.ts
11230
+ // src/host/fetch-proxy-handler.ts
11167
11231
  init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
11168
- var import_stream = require("stream");
11169
- var import_promises2 = require("stream/promises");
11170
- init_cli_runtime();
11171
- var ROLLDOWN_INVENTORY_HEADER = "x-peach-rolldown-inventory";
11172
- async function forwardRolldownBundleResponse(upstream, res) {
11173
- res.setHeader(ROLLDOWN_INVENTORY_HEADER, "1");
11174
- if (upstream.headers[ROLLDOWN_INVENTORY_HEADER] === "1") {
11175
- await (0, import_promises2.pipeline)(upstream, res);
11176
- return;
11177
- }
11178
- const contentType = typeof upstream.headers["content-type"] === "string" ? upstream.headers["content-type"] : "";
11179
- const inventory = getCliRuntime().rolldown_bundle_inventory;
11180
- res.removeHeader("content-length");
11181
- const annotate = async function* () {
11182
- const decoder = new TextDecoder();
11183
- let payload = "";
11184
- let sent = 0;
11185
- let bundleStarted = false;
11186
- for await (const chunk of upstream) {
11187
- payload += decoder.decode(chunk, { stream: true });
11188
- if (bundleStarted) continue;
11189
- const releasable = inventory.releasableMultipartPrefix(payload, contentType);
11190
- bundleStarted = releasable.bundleStarted;
11191
- if (releasable.length > sent) {
11192
- yield Buffer.from(payload.slice(sent, releasable.length), "utf8");
11193
- sent = releasable.length;
11194
- }
11195
- }
11196
- payload += decoder.decode();
11197
- let annotated;
11198
- try {
11199
- annotated = await inventory.attachRolldownBundleHttpPayload(payload, contentType);
11200
- } catch (error) {
11201
- const message = `could not attach the rolldown bundle inventory: ${error instanceof Error ? error.message : String(error)}`;
11202
- console.error(`[peach] ${message}`);
11203
- if (contentType.toLowerCase().includes("multipart/mixed")) {
11204
- yield Buffer.from(inventory.multipartFailurePart(contentType, message), "utf8");
11205
- return;
11206
- }
11207
- res.statusCode = 500;
11208
- res.setHeader("content-type", "application/json");
11209
- yield Buffer.from(JSON.stringify({ message }), "utf8");
11210
- return;
11211
- }
11212
- yield Buffer.from(annotated.slice(sent), "utf8");
11213
- };
11214
- await (0, import_promises2.pipeline)(import_stream.Readable.from(annotate(), { objectMode: false }), res);
11215
- }
11232
+ var import_http = __toESM(require("http"), 1);
11233
+ var import_https = __toESM(require("https"), 1);
11234
+ var import_node_http2 = require("node:http2");
11235
+ var import_promises3 = require("stream/promises");
11236
+ init_backend_origin();
11237
+
11238
+ // src/host/dev-server-package-versions.ts
11239
+ init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
11240
+ var import_fs5 = __toESM(require("fs"), 1);
11241
+ var import_path4 = __toESM(require("path"), 1);
11216
11242
 
11217
11243
  // src/installed-package-versions.ts
11218
11244
  init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
@@ -12601,6 +12627,7 @@ var NATIVE_STUB_PACKAGE_NAMES = [
12601
12627
  "expo-quick-actions",
12602
12628
  "expo-rich-input",
12603
12629
  "expo-roomplan",
12630
+ "expo-router",
12604
12631
  "expo-screen-capture",
12605
12632
  "expo-screen-corner-radius",
12606
12633
  "expo-screen-orientation",
@@ -13200,7 +13227,6 @@ var NATIVE_RUNTIME_PACKAGE_NAMES = [
13200
13227
  "@tamagui/native-registry",
13201
13228
  "@uniswap/ethers-rs-mobile",
13202
13229
  "@valora/react-native-keychain",
13203
- "expo-router",
13204
13230
  "react-native-app-control",
13205
13231
  "react-native-blue-crypto",
13206
13232
  "react-native-nitro-base64",
@@ -14123,12 +14149,32 @@ function answerSync(step) {
14123
14149
  throw error;
14124
14150
  }
14125
14151
  }
14152
+ async function answerAsync(step) {
14153
+ if (step.op === "exists")
14154
+ return import_fs4.default.promises.access(step.path).then(
14155
+ () => true,
14156
+ () => false
14157
+ );
14158
+ if (step.op === "realpath") return import_fs4.default.promises.realpath(step.path);
14159
+ try {
14160
+ return parseManifest(await import_fs4.default.promises.readFile(step.path, "utf8"));
14161
+ } catch (error) {
14162
+ if (isMissing(error)) return null;
14163
+ throw error;
14164
+ }
14165
+ }
14126
14166
  function runSync(walk) {
14127
14167
  for (let step = walk.next(); ; ) {
14128
14168
  if (step.done) return step.value;
14129
14169
  step = walk.next(answerSync(step.value));
14130
14170
  }
14131
14171
  }
14172
+ async function runAsync(walk) {
14173
+ for (let step = walk.next(); ; ) {
14174
+ if (step.done) return step.value;
14175
+ step = walk.next(await answerAsync(step.value));
14176
+ }
14177
+ }
14132
14178
  function createInstalledPackageReader() {
14133
14179
  const hasModules = /* @__PURE__ */ new Map();
14134
14180
  const manifests = /* @__PURE__ */ new Map();
@@ -14222,31 +14268,94 @@ function* nativePackageVersionsWalk(projectRoot) {
14222
14268
  function readInstalledNativePackageVersions(projectRoot) {
14223
14269
  return runSync(nativePackageVersionsWalk(projectRoot));
14224
14270
  }
14271
+ var INSTALL_RECORD_FILES = [
14272
+ "package.json",
14273
+ "bun.lock",
14274
+ "bun.lockb",
14275
+ "package-lock.json",
14276
+ "yarn.lock",
14277
+ "pnpm-lock.yaml",
14278
+ "node_modules",
14279
+ "node_modules/.package-lock.json",
14280
+ "node_modules/.yarn-integrity",
14281
+ "node_modules/.modules.yaml"
14282
+ ];
14283
+ async function installFingerprint(projectRoot) {
14284
+ const appRoot = await import_fs4.default.promises.realpath(projectRoot);
14285
+ const targets = [];
14286
+ for (let dir = appRoot; ; ) {
14287
+ if (import_path3.default.basename(dir) !== "node_modules")
14288
+ for (const file of INSTALL_RECORD_FILES) targets.push(import_path3.default.join(dir, file));
14289
+ const parent = import_path3.default.dirname(dir);
14290
+ if (parent === dir) break;
14291
+ dir = parent;
14292
+ }
14293
+ const stats = await Promise.all(
14294
+ targets.map(
14295
+ (target) => import_fs4.default.promises.stat(target).then(
14296
+ (stat) => `${stat.ino}:${stat.size}:${stat.mtimeMs}`,
14297
+ () => ""
14298
+ )
14299
+ )
14300
+ );
14301
+ return `${appRoot}
14302
+ ${stats.join("\n")}`;
14303
+ }
14304
+ var scans = /* @__PURE__ */ new Map();
14305
+ async function readInstalledNativePackageVersionsAsync(projectRoot) {
14306
+ const fingerprint = await installFingerprint(projectRoot);
14307
+ const cached2 = scans.get(projectRoot);
14308
+ if (cached2?.fingerprint === fingerprint) return cached2.versions;
14309
+ const versions = runAsync(nativePackageVersionsWalk(projectRoot));
14310
+ scans.set(projectRoot, { fingerprint, versions });
14311
+ versions.catch(() => {
14312
+ if (scans.get(projectRoot)?.versions === versions) scans.delete(projectRoot);
14313
+ });
14314
+ return versions;
14315
+ }
14225
14316
 
14226
- // src/one-widget-metadata.ts
14317
+ // src/metro-project-root.ts
14227
14318
  init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
14228
- var import_node_child_process3 = require("node:child_process");
14229
- var import_node_crypto5 = require("node:crypto");
14230
- var import_node_fs11 = __toESM(require("node:fs"), 1);
14231
- var import_node_module2 = require("node:module");
14232
- var import_node_path10 = __toESM(require("node:path"), 1);
14233
- var import_node_util = require("node:util");
14234
14319
 
14235
- // cli/internal-child.ts
14320
+ // scripts/dev-server-scanner.ts
14236
14321
  init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
14237
- var RNX_FORKED_SCRIPT_ENV = "PEACH_RUNS_FORKED_SCRIPTS";
14322
+ var import_child_process2 = require("child_process");
14323
+ var import_promises = require("fs/promises");
14324
+ var import_node_fs9 = require("node:fs");
14325
+ var import_node_os3 = require("node:os");
14326
+ var import_node_path8 = require("node:path");
14327
+ init_backend_origin();
14328
+ init_config();
14238
14329
 
14239
- // src/one-widget-metadata.ts
14240
- init_is_record();
14330
+ // src/dev-bundle-resolution.ts
14331
+ init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
14332
+ init_backend_origin();
14241
14333
 
14242
- // src/oneWidgetContract.ts
14334
+ // src/expo-manifest-body.ts
14243
14335
  init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
14336
+ function parseExpoManifestBody(body) {
14337
+ const opening = /^(--[^\r\n]+)\r?\n/.exec(body);
14338
+ if (!opening) return JSON.parse(body);
14339
+ for (const part of body.split(opening[1])) {
14340
+ const headerEnd = part.search(/\r?\n\r?\n/);
14341
+ if (headerEnd < 0 || !/\bname="manifest"/.test(part.slice(0, headerEnd))) continue;
14342
+ return JSON.parse(part.slice(headerEnd).trim());
14343
+ }
14344
+ throw new Error("Expo manifest response has no manifest part");
14345
+ }
14244
14346
 
14245
14347
  // src/native-dev-bundle-url.ts
14246
14348
  init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
14247
14349
  init_backend_origin();
14248
14350
 
14351
+ // src/dev-bundle-resolution.ts
14352
+ var MANIFEST_PROBE_TIMEOUT_MS = 3e4;
14353
+
14354
+ // src/kotlinDiscoveryContract.ts
14355
+ init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
14356
+
14249
14357
  // src/oneWidgetContract.ts
14358
+ init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
14250
14359
  var HOME_WIDGET_FAMILIES = [
14251
14360
  "systemSmall",
14252
14361
  "systemMedium",
@@ -14257,7 +14366,1080 @@ function isHomeWidgetFamily(value) {
14257
14366
  return HOME_WIDGET_FAMILIES.some((family) => family === value);
14258
14367
  }
14259
14368
 
14369
+ // src/settings-bundle.ts
14370
+ init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
14371
+ init_is_record();
14372
+
14373
+ // src/plist.ts
14374
+ init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
14375
+ var import_plist = __toESM(require("plist"), 1);
14376
+ function parsePlistSource(source) {
14377
+ return import_plist.default.parse(source);
14378
+ }
14379
+
14380
+ // src/swiftDiscoveryContract.ts
14381
+ init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
14382
+
14383
+ // scripts/optional-demo-registry.ts
14384
+ init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
14385
+
14386
+ // scripts/dev-server-scanner.ts
14387
+ var LISTENER_LOCK_PATH = (0, import_node_path8.join)((0, import_node_os3.tmpdir)(), "peach-listener-scan.lock");
14388
+ var LISTENER_RESULT_PATH = (0, import_node_path8.join)((0, import_node_os3.tmpdir)(), "peach-listener-scan.result");
14389
+ var LISTENER_LOCK_STALE_MS = 25e3;
14390
+ var LISTENER_LOCK_WAIT_MS = 8e3;
14391
+ function sleep2(ms) {
14392
+ return new Promise((resolve5) => setTimeout(resolve5, ms));
14393
+ }
14394
+ function pidIsAlive(pid) {
14395
+ if (!Number.isInteger(pid) || pid <= 0) return false;
14396
+ try {
14397
+ process.kill(pid, 0);
14398
+ return true;
14399
+ } catch (error) {
14400
+ const code = error && typeof error === "object" && "code" in error ? String(error.code) : "";
14401
+ return code !== "ESRCH";
14402
+ }
14403
+ }
14404
+ function readLockOwner() {
14405
+ try {
14406
+ const raw = (0, import_node_fs9.readFileSync)(LISTENER_LOCK_PATH, "utf8");
14407
+ const mtimeMs = (0, import_node_fs9.statSync)(LISTENER_LOCK_PATH).mtimeMs;
14408
+ const pid = Number(raw.split("-")[0]);
14409
+ return { raw, pid: Number.isInteger(pid) ? pid : -1, mtimeMs };
14410
+ } catch {
14411
+ return null;
14412
+ }
14413
+ }
14414
+ function lockIsAbandoned(owner) {
14415
+ if (owner.pid <= 0 || !pidIsAlive(owner.pid)) return true;
14416
+ return Date.now() - owner.mtimeMs > LISTENER_LOCK_STALE_MS;
14417
+ }
14418
+ function clearLock(raw) {
14419
+ try {
14420
+ if ((0, import_node_fs9.readFileSync)(LISTENER_LOCK_PATH, "utf8") !== raw) return;
14421
+ (0, import_node_fs9.unlinkSync)(LISTENER_LOCK_PATH);
14422
+ } catch {
14423
+ }
14424
+ }
14425
+ function readResult() {
14426
+ try {
14427
+ const parsed = JSON.parse(
14428
+ (0, import_node_fs9.readFileSync)(LISTENER_RESULT_PATH, "utf8")
14429
+ );
14430
+ if (!parsed || typeof parsed.token !== "string" || typeof parsed.key !== "string")
14431
+ return null;
14432
+ return parsed;
14433
+ } catch {
14434
+ return null;
14435
+ }
14436
+ }
14437
+ function publishResult(payload) {
14438
+ const tmp = `${LISTENER_RESULT_PATH}.${process.pid}.tmp`;
14439
+ (0, import_node_fs9.writeFileSync)(tmp, JSON.stringify(payload));
14440
+ (0, import_node_fs9.renameSync)(tmp, LISTENER_RESULT_PATH);
14441
+ }
14442
+ function throwPublished(payload) {
14443
+ throw Object.assign(new Error(payload.message || "listener scan failed"), {
14444
+ killed: payload.killed === true
14445
+ });
14446
+ }
14447
+ async function waitForSharedResult(owner, key) {
14448
+ const cap = Date.now() + LISTING_TIMEOUT_MS;
14449
+ let current = owner;
14450
+ while (Date.now() < cap) {
14451
+ const published = readResult();
14452
+ if (published && published.token === current.raw) {
14453
+ if (published.key !== key) return { kind: "retry" };
14454
+ if (!published.ok) throwPublished(published);
14455
+ return { kind: "value", value: published.value };
14456
+ }
14457
+ const latest = readLockOwner();
14458
+ if (!latest) {
14459
+ const again = readResult();
14460
+ if (again && again.token === current.raw && again.key === key) {
14461
+ if (!again.ok) throwPublished(again);
14462
+ return { kind: "value", value: again.value };
14463
+ }
14464
+ return { kind: "retry" };
14465
+ }
14466
+ if (latest.raw !== current.raw) current = latest;
14467
+ if (lockIsAbandoned(latest)) {
14468
+ clearLock(latest.raw);
14469
+ return { kind: "retry" };
14470
+ }
14471
+ await sleep2(25);
14472
+ }
14473
+ throw Object.assign(new Error("listener scan lock was held past the wait"), {
14474
+ killed: true
14475
+ });
14476
+ }
14477
+ async function withListenerLock(key, body) {
14478
+ const token = `${process.pid}-${Date.now()}-${Math.random()}`;
14479
+ const deadline = Date.now() + LISTENER_LOCK_WAIT_MS;
14480
+ for (; ; ) {
14481
+ let fd = null;
14482
+ try {
14483
+ fd = (0, import_node_fs9.openSync)(LISTENER_LOCK_PATH, "wx");
14484
+ } catch (error) {
14485
+ const code = error instanceof Error && "code" in error ? error.code : "";
14486
+ if (code !== "EEXIST") throw error;
14487
+ const owner = readLockOwner();
14488
+ if (!owner || lockIsAbandoned(owner)) {
14489
+ if (owner) clearLock(owner.raw);
14490
+ else {
14491
+ try {
14492
+ (0, import_node_fs9.unlinkSync)(LISTENER_LOCK_PATH);
14493
+ } catch {
14494
+ }
14495
+ }
14496
+ continue;
14497
+ }
14498
+ if (Date.now() >= deadline) {
14499
+ const shared = await waitForSharedResult(owner, key);
14500
+ if (shared.kind === "value") return shared.value;
14501
+ continue;
14502
+ }
14503
+ await sleep2(25);
14504
+ continue;
14505
+ }
14506
+ if (fd === null) continue;
14507
+ try {
14508
+ (0, import_node_fs9.writeSync)(fd, token);
14509
+ try {
14510
+ const value = await body();
14511
+ publishResult({ token, key, ok: true, value });
14512
+ return value;
14513
+ } catch (error) {
14514
+ publishResult({
14515
+ token,
14516
+ key,
14517
+ ok: false,
14518
+ message: error instanceof Error ? error.message : String(error),
14519
+ killed: !!(error && typeof error === "object" && error.killed)
14520
+ });
14521
+ throw error;
14522
+ }
14523
+ } finally {
14524
+ try {
14525
+ (0, import_node_fs9.closeSync)(fd);
14526
+ } catch {
14527
+ }
14528
+ clearLock(token);
14529
+ }
14530
+ }
14531
+ }
14532
+ function spawnReaped(file, args, timeoutMs, maxBuffer = 1024 * 1024) {
14533
+ return withListenerLock(
14534
+ `${file}\0${args.join("\0")}`,
14535
+ () => new Promise((resolvePromise, reject) => {
14536
+ const child = (0, import_child_process2.spawn)(file, args, {
14537
+ stdio: ["ignore", "pipe", "pipe"]
14538
+ });
14539
+ let stdout = "";
14540
+ let settled = false;
14541
+ let timedOut = false;
14542
+ let overflow = false;
14543
+ let spawnError = null;
14544
+ const timeoutError = () => Object.assign(new Error(`\`${file}\` did not exit within ${timeoutMs}ms`), {
14545
+ killed: true
14546
+ });
14547
+ const finish = (err, code) => {
14548
+ if (settled) return;
14549
+ settled = true;
14550
+ clearTimeout(deadline);
14551
+ clearTimeout(backup);
14552
+ if (err) reject(err);
14553
+ else resolvePromise({ stdout, code });
14554
+ };
14555
+ const killChild = () => {
14556
+ if (child.exitCode !== null || child.signalCode !== null) return;
14557
+ try {
14558
+ child.kill("SIGKILL");
14559
+ } catch {
14560
+ }
14561
+ };
14562
+ let backup;
14563
+ const deadline = setTimeout(() => {
14564
+ timedOut = true;
14565
+ killChild();
14566
+ backup = setTimeout(() => finish(timeoutError(), null), 1e3);
14567
+ }, timeoutMs);
14568
+ child.stdout?.setEncoding("utf8");
14569
+ child.stderr?.on("data", () => {
14570
+ });
14571
+ child.stdout?.on("data", (chunk) => {
14572
+ stdout += chunk;
14573
+ if (stdout.length > maxBuffer) {
14574
+ overflow = true;
14575
+ killChild();
14576
+ }
14577
+ });
14578
+ child.on("error", (err) => {
14579
+ spawnError = err;
14580
+ killChild();
14581
+ });
14582
+ child.on("close", (code) => {
14583
+ if (timedOut) finish(timeoutError(), code);
14584
+ else if (overflow)
14585
+ finish(new Error(`\`${file}\` exceeded maxBuffer ${maxBuffer}`), code);
14586
+ else if (spawnError && !stdout) finish(spawnError, code);
14587
+ else finish(null, code);
14588
+ });
14589
+ })
14590
+ );
14591
+ }
14592
+ var FALLBACK_PORTS = [
14593
+ 8081,
14594
+ 8082,
14595
+ 8083,
14596
+ 8084,
14597
+ 8085,
14598
+ 8086,
14599
+ 3e3,
14600
+ 3001,
14601
+ 19e3
14602
+ ].map((port) => ({ port, pid: 0 }));
14603
+ var LISTING_TIMEOUT_MS = 1e4;
14604
+ function wasKilledByTimeout(err) {
14605
+ return !!(err && typeof err === "object" && err.killed);
14606
+ }
14607
+ var LISTENER_CACHE_MS = 2e3;
14608
+ var listenerCache = null;
14609
+ var inflightListing = null;
14610
+ var listenerHolds = 0;
14611
+ function cachedPidsAlive(scan) {
14612
+ if (scan.state !== "looked") return true;
14613
+ return scan.processes.every((entry) => entry.pid <= 0 || pidIsAlive(entry.pid));
14614
+ }
14615
+ async function cachedPortsStillHeld(scan) {
14616
+ if (scan.state !== "looked") return true;
14617
+ const owned = scan.processes.filter((entry) => entry.pid > 0);
14618
+ if (owned.length === 0) return true;
14619
+ const pids = [...new Set(owned.map((entry) => entry.pid))];
14620
+ try {
14621
+ const { stdout, code } = await spawnReaped(
14622
+ "lsof",
14623
+ ["-nP", "-b", "-w", "-a", "-p", pids.join(","), "-iTCP", "-sTCP:LISTEN", "-Fpcn"],
14624
+ 8e3,
14625
+ 16 * 1024 * 1024
14626
+ );
14627
+ if (code !== 0 && code !== 1) return false;
14628
+ const live = new Set(
14629
+ parseLsofListeners(stdout).map((entry) => `${entry.port}:${entry.pid}`)
14630
+ );
14631
+ return owned.every((entry) => live.has(`${entry.port}:${entry.pid}`));
14632
+ } catch {
14633
+ return false;
14634
+ }
14635
+ }
14636
+ function listListenersShared() {
14637
+ inflightListing ??= loadListeners().finally(() => {
14638
+ inflightListing = null;
14639
+ });
14640
+ return inflightListing;
14641
+ }
14642
+ async function loadListeners() {
14643
+ const cached2 = listenerCache;
14644
+ if (cached2 && (listenerHolds > 0 || Date.now() - cached2.at < LISTENER_CACHE_MS) && cachedPidsAlive(cached2.scan) && await cachedPortsStillHeld(cached2.scan)) {
14645
+ return cached2.scan;
14646
+ }
14647
+ listenerCache = null;
14648
+ const scan = await listListeners();
14649
+ listenerCache = { at: Date.now(), scan };
14650
+ return scan;
14651
+ }
14652
+ function isSpawnMissing(err) {
14653
+ return !!(err && typeof err === "object" && err.code === "ENOENT");
14654
+ }
14655
+ function parseLsofListeners(stdout) {
14656
+ const seen = /* @__PURE__ */ new Map();
14657
+ let pid = 0;
14658
+ let command = "";
14659
+ for (const line of stdout.split("\n")) {
14660
+ if (line.startsWith("p")) {
14661
+ pid = Number(line.slice(1));
14662
+ command = "";
14663
+ continue;
14664
+ }
14665
+ if (line.startsWith("c")) {
14666
+ command = line.slice(1);
14667
+ continue;
14668
+ }
14669
+ if (!line.startsWith("n") || pid <= 0) continue;
14670
+ if (!/^(node|bun|peach|vite)/.test(command)) continue;
14671
+ const match = line.match(/:(\d+)$/);
14672
+ if (!match) continue;
14673
+ const port = Number(match[1]);
14674
+ if (!seen.has(port)) seen.set(port, pid);
14675
+ }
14676
+ return [...seen.entries()].map(([port, owner]) => ({ port, pid: owner }));
14677
+ }
14678
+ function parseSsListeners(stdout) {
14679
+ const seen = /* @__PURE__ */ new Map();
14680
+ for (const line of stdout.split("\n")) {
14681
+ if (!/"(node|bun|peach|vite)/.test(line)) continue;
14682
+ const portMatch = line.match(/:(\d+)\s/);
14683
+ const pidMatch = line.match(/pid=(\d+)/);
14684
+ if (!portMatch) continue;
14685
+ const port = Number(portMatch[1]);
14686
+ const pid = pidMatch ? Number(pidMatch[1]) : 0;
14687
+ if (!seen.has(port)) seen.set(port, pid);
14688
+ }
14689
+ return [...seen.entries()].map(([port, pid]) => ({ port, pid }));
14690
+ }
14691
+ async function listListeners() {
14692
+ let timedOut = false;
14693
+ try {
14694
+ const { stdout, code } = await spawnReaped(
14695
+ "lsof",
14696
+ [
14697
+ "-nP",
14698
+ "-b",
14699
+ "-w",
14700
+ "-a",
14701
+ "-c",
14702
+ "node",
14703
+ "-c",
14704
+ "bun",
14705
+ "-c",
14706
+ "peach",
14707
+ "-c",
14708
+ "vite",
14709
+ "-iTCP",
14710
+ "-sTCP:LISTEN",
14711
+ "-Fpcn"
14712
+ ],
14713
+ LISTING_TIMEOUT_MS,
14714
+ 16 * 1024 * 1024
14715
+ );
14716
+ if (code === 0 || code === 1) {
14717
+ return { state: "looked", processes: parseLsofListeners(stdout) };
14718
+ }
14719
+ } catch (err) {
14720
+ if (wasKilledByTimeout(err)) timedOut = true;
14721
+ else if (!isSpawnMissing(err)) return { state: "could-not-look" };
14722
+ }
14723
+ if (!timedOut) {
14724
+ try {
14725
+ const { stdout, code } = await spawnReaped(
14726
+ "ss",
14727
+ ["-H", "-ltnp"],
14728
+ LISTING_TIMEOUT_MS,
14729
+ 16 * 1024 * 1024
14730
+ );
14731
+ if (code === 0 || code === 1) {
14732
+ return { state: "looked", processes: parseSsListeners(stdout) };
14733
+ }
14734
+ } catch (err) {
14735
+ if (wasKilledByTimeout(err)) timedOut = true;
14736
+ else if (!isSpawnMissing(err)) return { state: "could-not-look" };
14737
+ }
14738
+ }
14739
+ if (timedOut) return { state: "could-not-look" };
14740
+ return { state: "looked", processes: FALLBACK_PORTS };
14741
+ }
14742
+ async function resolveListeningPid(port) {
14743
+ if (!Number.isInteger(port) || port <= 0) return null;
14744
+ const scan = await listListenersShared();
14745
+ if (scan.state !== "looked") return null;
14746
+ const pids = [
14747
+ ...new Set(
14748
+ scan.processes.filter((entry) => entry.port === port && entry.pid > 0).map((entry) => entry.pid)
14749
+ )
14750
+ ];
14751
+ return pids.length === 1 && pids[0] !== void 0 ? pids[0] : null;
14752
+ }
14753
+ var cwdByPid = /* @__PURE__ */ new Map();
14754
+ var cwdQueue = [];
14755
+ var cwdFlushing = false;
14756
+ function kickCwdFlush() {
14757
+ if (cwdFlushing || cwdQueue.length === 0) return;
14758
+ cwdFlushing = true;
14759
+ void flushCwdQueue().finally(() => {
14760
+ cwdFlushing = false;
14761
+ kickCwdFlush();
14762
+ });
14763
+ }
14764
+ async function flushCwdQueue() {
14765
+ await Promise.resolve();
14766
+ while (cwdQueue.length > 0) {
14767
+ const batch = cwdQueue.splice(0, cwdQueue.length);
14768
+ const pending = [...new Set(batch.map((waiter) => waiter.pid))].filter(
14769
+ (pid) => !cwdByPid.has(pid)
14770
+ );
14771
+ const needLsof = [];
14772
+ for (const pid of pending) {
14773
+ try {
14774
+ const cwd = await (0, import_promises.readlink)(`/proc/${pid}/cwd`);
14775
+ if (cwd) {
14776
+ cwdByPid.set(pid, cwd);
14777
+ continue;
14778
+ }
14779
+ } catch {
14780
+ }
14781
+ needLsof.push(pid);
14782
+ }
14783
+ if (needLsof.length > 0) {
14784
+ let looked = false;
14785
+ try {
14786
+ const { stdout, code } = await spawnReaped(
14787
+ "lsof",
14788
+ ["-b", "-w", "-nP", "-a", "-d", "cwd", "-p", needLsof.join(","), "-Fn"],
14789
+ 8e3,
14790
+ 4 * 1024 * 1024
14791
+ );
14792
+ if (code === 0 || code === 1) {
14793
+ looked = true;
14794
+ let current = 0;
14795
+ for (const line of stdout.split("\n")) {
14796
+ if (line.startsWith("p")) {
14797
+ current = Number(line.slice(1));
14798
+ continue;
14799
+ }
14800
+ if (!line.startsWith("n") || line.length <= 1 || !needLsof.includes(current))
14801
+ continue;
14802
+ const cwd = line.slice(1).trim();
14803
+ if (cwd) cwdByPid.set(current, cwd);
14804
+ }
14805
+ }
14806
+ } catch {
14807
+ }
14808
+ if (looked) {
14809
+ for (const pid of needLsof) {
14810
+ if (!cwdByPid.has(pid)) cwdByPid.set(pid, null);
14811
+ }
14812
+ }
14813
+ }
14814
+ for (const waiter of batch) waiter.resolve(cwdByPid.get(waiter.pid) ?? null);
14815
+ }
14816
+ }
14817
+ function resolveProcessCwd(pid) {
14818
+ if (pid <= 0) return Promise.resolve(null);
14819
+ if (cwdByPid.has(pid)) return Promise.resolve(cwdByPid.get(pid) ?? null);
14820
+ return new Promise((resolveCwd) => {
14821
+ cwdQueue.push({ pid, resolve: resolveCwd });
14822
+ kickCwdFlush();
14823
+ });
14824
+ }
14825
+
14826
+ // src/metro-project-root.ts
14827
+ init_backend_origin();
14828
+ async function resolveMetroProjectRoot(bundleUrl) {
14829
+ const origin = loopbackOriginOf(bundleUrl);
14830
+ if (!origin) return null;
14831
+ const controller = new AbortController();
14832
+ const timer = setTimeout(() => controller.abort(), MANIFEST_PROBE_TIMEOUT_MS);
14833
+ let servedManifest = false;
14834
+ let metroRunning = false;
14835
+ try {
14836
+ const status = await fetch(`${origin}/status`, { signal: controller.signal });
14837
+ const advertisedRoot = status.headers.get("X-React-Native-Project-Root");
14838
+ if (status.ok && advertisedRoot) return decodeURI(advertisedRoot);
14839
+ metroRunning = status.ok && (await status.text()).trim() === "packager-status:running";
14840
+ const res = await fetch(`${origin}/`, {
14841
+ headers: { "expo-platform": "ios", Accept: "application/json" },
14842
+ signal: controller.signal
14843
+ });
14844
+ if (res.ok) {
14845
+ const manifest = parseExpoManifestBody(await res.text());
14846
+ servedManifest = true;
14847
+ let root = manifest;
14848
+ for (const key of ["extra", "expoClient", "_internal", "projectRoot"]) {
14849
+ root = typeof root === "object" && root !== null ? Reflect.get(root, key) : void 0;
14850
+ }
14851
+ if (typeof root === "string" && root.length > 0) return root;
14852
+ }
14853
+ } catch {
14854
+ if (controller.signal.aborted)
14855
+ throw new Error(
14856
+ `Metro project root request timed out after ${MANIFEST_PROBE_TIMEOUT_MS / 1e3}s: ${origin}. Wait for the dev server to finish starting or pass --project-root.`
14857
+ );
14858
+ } finally {
14859
+ clearTimeout(timer);
14860
+ }
14861
+ if (servedManifest || !metroRunning) return null;
14862
+ const port = Number(new URL(origin).port);
14863
+ if (!Number.isFinite(port) || port <= 0) return null;
14864
+ const pid = await resolveListeningPid(port);
14865
+ return pid === null ? null : resolveProcessCwd(pid);
14866
+ }
14867
+
14868
+ // src/host/dev-server-package-versions.ts
14869
+ async function readDevServerPackageVersions(bundleUrl) {
14870
+ if (!bundleUrl.pathname.endsWith(".bundle")) return null;
14871
+ const projectRoot = await resolveMetroProjectRoot(bundleUrl.href);
14872
+ if (!projectRoot) return null;
14873
+ try {
14874
+ await import_fs5.default.promises.access(import_path4.default.join(projectRoot, "package.json"));
14875
+ } catch {
14876
+ return null;
14877
+ }
14878
+ return readInstalledNativePackageVersionsAsync(projectRoot);
14879
+ }
14880
+
14881
+ // src/host/fetch-proxy-overrides.ts
14882
+ init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
14883
+ var FETCH_PROXY_NATIVE_USER_AGENT_HEADER = "x-sootsim-native-user-agent";
14884
+ var FETCH_PROXY_FAILURE_PARAM = "peachFailure";
14885
+ var FETCH_PROXY_FAILURE_HEADER = "x-peach-upstream-failure";
14886
+ var FETCH_PROXY_RESPONSE_URL_HEADER = "x-peach-response-url";
14887
+ var FETCH_PROXY_NATIVE_COOKIE_HEADER = "x-peach-native-cookie";
14888
+ var FETCH_PROXY_NATIVE_COOKIE_RESPONSE_HEADER = "x-peach-native-cookie-response";
14889
+ function nativeCookieHopHeader(hop) {
14890
+ return encodeURIComponent(JSON.stringify(hop));
14891
+ }
14892
+ function isNativeCookieRedirect(hop) {
14893
+ return hop.location !== null && [301, 302, 303, 307, 308].includes(hop.status);
14894
+ }
14895
+ function resolveRedirectUrl(location, from) {
14896
+ const next = new URL(location, from);
14897
+ if (!location.includes("#")) next.hash = from.hash;
14898
+ return next;
14899
+ }
14900
+ var HOST_HEADER_OVERRIDES = [
14901
+ {
14902
+ hostSuffix: "uniswap.org",
14903
+ headers: {
14904
+ origin: "https://app.uniswap.org",
14905
+ referer: "https://app.uniswap.org/"
14906
+ }
14907
+ }
14908
+ ];
14909
+ function headerOverridesFor(hostname) {
14910
+ const host = hostname.toLowerCase();
14911
+ for (const override of HOST_HEADER_OVERRIDES) {
14912
+ if (host === override.hostSuffix || host.endsWith(`.${override.hostSuffix}`)) {
14913
+ return override;
14914
+ }
14915
+ }
14916
+ return void 0;
14917
+ }
14918
+ var PUBLIC_RPC_TENANT = "rnx-public-rpc";
14919
+ var QUICKNODE_HOST_SUFFIX = ".quiknode.pro";
14920
+ var PUBLIC_RPC_BY_QUICKNODE_CHAIN = {
14921
+ "": "https://ethereum-rpc.publicnode.com",
14922
+ "arbitrum-mainnet": "https://arbitrum-one-rpc.publicnode.com",
14923
+ "avalanche-mainnet": "https://avalanche-c-chain-rpc.publicnode.com",
14924
+ "base-mainnet": "https://base-rpc.publicnode.com",
14925
+ "blast-mainnet": "https://blast-rpc.publicnode.com",
14926
+ bsc: "https://bsc-rpc.publicnode.com",
14927
+ "celo-mainnet": "https://celo-rpc.publicnode.com",
14928
+ matic: "https://polygon-bor-rpc.publicnode.com",
14929
+ optimism: "https://optimism-rpc.publicnode.com",
14930
+ "soneium-mainnet": "https://soneium-rpc.publicnode.com",
14931
+ "unichain-mainnet": "https://unichain-rpc.publicnode.com"
14932
+ };
14933
+ function resolveFetchProxyTargetUrl(requested) {
14934
+ const host = requested.hostname.toLowerCase();
14935
+ if (!host.endsWith(QUICKNODE_HOST_SUFFIX)) return requested;
14936
+ const tenant = host.slice(0, -QUICKNODE_HOST_SUFFIX.length);
14937
+ if (tenant !== PUBLIC_RPC_TENANT && !tenant.startsWith(`${PUBLIC_RPC_TENANT}.`)) {
14938
+ return requested;
14939
+ }
14940
+ const chain = tenant === PUBLIC_RPC_TENANT ? "" : tenant.slice(PUBLIC_RPC_TENANT.length + 1);
14941
+ const replacement = PUBLIC_RPC_BY_QUICKNODE_CHAIN[chain];
14942
+ return replacement ? new URL(replacement) : requested;
14943
+ }
14944
+ var STRIP_FETCH_PROXY_REQUEST_HEADERS = /* @__PURE__ */ new Set([
14945
+ "host",
14946
+ "x-forwarded",
14947
+ "x-real-ip",
14948
+ "forwarded",
14949
+ "origin",
14950
+ "referer",
14951
+ "user-agent",
14952
+ "accept-encoding",
14953
+ "cookie",
14954
+ "connection",
14955
+ "keep-alive",
14956
+ "transfer-encoding",
14957
+ "upgrade",
14958
+ "content-length",
14959
+ "sec-fetch-site",
14960
+ "sec-fetch-mode",
14961
+ "sec-fetch-dest",
14962
+ "sec-ch-ua",
14963
+ "sec-ch-ua-mobile",
14964
+ "sec-ch-ua-platform",
14965
+ FETCH_PROXY_NATIVE_USER_AGENT_HEADER,
14966
+ FETCH_PROXY_NATIVE_COOKIE_HEADER,
14967
+ FETCH_PROXY_NATIVE_COOKIE_RESPONSE_HEADER
14968
+ ]);
14969
+ function buildFetchProxyUpstreamHeaders(requestHeaders, targetUrl) {
14970
+ const headers = {};
14971
+ let nativeUserAgent;
14972
+ let nativeCookie;
14973
+ for (const [rawKey, value] of requestHeaders) {
14974
+ const key = rawKey.toLowerCase();
14975
+ if (key === FETCH_PROXY_NATIVE_USER_AGENT_HEADER) nativeUserAgent = value;
14976
+ if (key === FETCH_PROXY_NATIVE_COOKIE_HEADER) nativeCookie = decodeURIComponent(value);
14977
+ if (key.startsWith(":") || STRIP_FETCH_PROXY_REQUEST_HEADERS.has(key) || key.startsWith("x-forwarded-")) {
14978
+ continue;
14979
+ }
14980
+ headers[key] = value;
14981
+ }
14982
+ if (!targetUrl) return headers;
14983
+ return {
14984
+ ...headers,
14985
+ "accept-encoding": "identity",
14986
+ ...nativeUserAgent ? { "user-agent": nativeUserAgent } : {},
14987
+ ...nativeCookie ? { cookie: nativeCookie } : {},
14988
+ ...headerOverridesFor(targetUrl.hostname)?.headers
14989
+ };
14990
+ }
14991
+ function nodeRequestHeaderEntries(headers) {
14992
+ const entries = [];
14993
+ for (const [key, value] of Object.entries(headers)) {
14994
+ if (!value) continue;
14995
+ entries.push([key, Array.isArray(value) ? value.join(", ") : value]);
14996
+ }
14997
+ return entries;
14998
+ }
14999
+
15000
+ // src/host/loopback-ports.ts
15001
+ init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
15002
+ init_backend_origin();
15003
+ var LOOPBACK_PORTS = /* @__PURE__ */ new Map();
15004
+ for (const pair of process.env.PEACH_LOOPBACK_PORTS?.split(",").filter(Boolean) ?? []) {
15005
+ const match = /^\s*([1-9][0-9]{0,4}):([1-9][0-9]{0,4})\s*$/.exec(pair);
15006
+ const from = Number(match?.[1]);
15007
+ const to = Number(match?.[2]);
15008
+ if (!match || from > 65535 || to > 65535 || LOOPBACK_PORTS.has(from)) {
15009
+ throw new Error(`PEACH_LOOPBACK_PORTS has an invalid entry: ${JSON.stringify(pair)}`);
15010
+ }
15011
+ LOOPBACK_PORTS.set(from, to);
15012
+ }
15013
+ function projectLoopbackPort(hostname, port) {
15014
+ return isLoopbackHost(hostname) ? LOOPBACK_PORTS.get(port) ?? port : port;
15015
+ }
15016
+
15017
+ // src/host/rolldown-bundle-forward.ts
15018
+ init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
15019
+ var import_stream = require("stream");
15020
+ var import_promises2 = require("stream/promises");
15021
+ init_cli_runtime();
15022
+ var ROLLDOWN_INVENTORY_HEADER = "x-peach-rolldown-inventory";
15023
+ async function forwardRolldownBundleResponse(upstream, res) {
15024
+ res.setHeader(ROLLDOWN_INVENTORY_HEADER, "1");
15025
+ if (upstream.headers[ROLLDOWN_INVENTORY_HEADER] === "1") {
15026
+ await (0, import_promises2.pipeline)(upstream, res);
15027
+ return;
15028
+ }
15029
+ const contentType = typeof upstream.headers["content-type"] === "string" ? upstream.headers["content-type"] : "";
15030
+ const inventory = getCliRuntime().rolldown_bundle_inventory;
15031
+ res.removeHeader("content-length");
15032
+ const annotate = async function* () {
15033
+ const decoder = new TextDecoder();
15034
+ let payload = "";
15035
+ let sent = 0;
15036
+ let bundleStarted = false;
15037
+ for await (const chunk of upstream) {
15038
+ payload += decoder.decode(chunk, { stream: true });
15039
+ if (bundleStarted) continue;
15040
+ const releasable = inventory.releasableMultipartPrefix(payload, contentType);
15041
+ bundleStarted = releasable.bundleStarted;
15042
+ if (releasable.length > sent) {
15043
+ yield Buffer.from(payload.slice(sent, releasable.length), "utf8");
15044
+ sent = releasable.length;
15045
+ }
15046
+ }
15047
+ payload += decoder.decode();
15048
+ let annotated;
15049
+ try {
15050
+ annotated = await inventory.attachRolldownBundleHttpPayload(payload, contentType);
15051
+ } catch (error) {
15052
+ const message = `could not attach the rolldown bundle inventory: ${error instanceof Error ? error.message : String(error)}`;
15053
+ console.error(`[peach] ${message}`);
15054
+ if (contentType.toLowerCase().includes("multipart/mixed")) {
15055
+ yield Buffer.from(
15056
+ inventory.multipartFailurePart(contentType, message, payload.slice(0, sent)),
15057
+ "utf8"
15058
+ );
15059
+ return;
15060
+ }
15061
+ res.statusCode = 500;
15062
+ res.setHeader("content-type", "application/json");
15063
+ yield Buffer.from(JSON.stringify({ message }), "utf8");
15064
+ return;
15065
+ }
15066
+ yield Buffer.from(annotated.slice(sent), "utf8");
15067
+ };
15068
+ await (0, import_promises2.pipeline)(import_stream.Readable.from(annotate(), { objectMode: false }), res);
15069
+ }
15070
+
15071
+ // src/host/fetch-proxy-handler.ts
15072
+ var fetchProxyHttpAgent = new import_http.default.Agent({ keepAlive: true, maxSockets: 256 });
15073
+ var fetchProxyHttpsAgent = new import_https.default.Agent({ keepAlive: true, maxSockets: 256 });
15074
+ function fetchProxyAgentFor(targetUrl) {
15075
+ return targetUrl.protocol === "https:" ? fetchProxyHttpsAgent : fetchProxyHttpAgent;
15076
+ }
15077
+ var FETCH_PROXY_CORS_HEADERS = {
15078
+ "access-control-allow-methods": "GET,HEAD,POST,PUT,DELETE,PATCH,OPTIONS",
15079
+ "access-control-max-age": "3600"
15080
+ };
15081
+ var APP_API_HEADER_REWRITES = /* @__PURE__ */ new Set([
15082
+ "host",
15083
+ "origin",
15084
+ "referer",
15085
+ "sec-fetch-site",
15086
+ "sec-fetch-mode",
15087
+ "sec-fetch-dest"
15088
+ ]);
15089
+ function loopbackTlsOptions(targetUrl) {
15090
+ if (targetUrl.protocol !== "https:") return {};
15091
+ return isLoopbackHost(targetUrl.hostname) ? { rejectUnauthorized: false } : {};
15092
+ }
15093
+ function applyFetchProxyCors(req, res) {
15094
+ for (const [key, value] of Object.entries(FETCH_PROXY_CORS_HEADERS)) {
15095
+ res.setHeader(key, value);
15096
+ }
15097
+ res.setHeader("access-control-allow-origin", req.headers.origin ?? "*");
15098
+ res.setHeader("access-control-allow-credentials", "true");
15099
+ res.setHeader(
15100
+ "access-control-allow-headers",
15101
+ req.headers["access-control-request-headers"] ?? "*"
15102
+ );
15103
+ res.setHeader(
15104
+ "access-control-expose-headers",
15105
+ [
15106
+ ...Object.keys(res.getHeaders()).filter(
15107
+ (name2) => !name2.startsWith("access-control-")
15108
+ ),
15109
+ "x-sootsim-set-cookie"
15110
+ ].join(", ")
15111
+ );
15112
+ const vary = res.getHeader("vary");
15113
+ res.setHeader(
15114
+ "vary",
15115
+ vary ? `${Array.isArray(vary) ? vary.join(", ") : vary}, Origin` : "Origin"
15116
+ );
15117
+ }
15118
+ function buildFetchProxyHeaders(reqHeaders, targetUrl) {
15119
+ return buildFetchProxyUpstreamHeaders(nodeRequestHeaderEntries(reqHeaders), targetUrl);
15120
+ }
15121
+ function buildAppApiProxyHeaders(reqHeaders, targetUrl) {
15122
+ const headers = {};
15123
+ for (const [key, value] of Object.entries(reqHeaders)) {
15124
+ if (!value) continue;
15125
+ if (key.toLowerCase() === FETCH_PROXY_NATIVE_COOKIE_HEADER || key.toLowerCase() === FETCH_PROXY_NATIVE_COOKIE_RESPONSE_HEADER || reqHeaders[FETCH_PROXY_NATIVE_COOKIE_HEADER] !== void 0 && key.toLowerCase() === "cookie" || APP_API_HEADER_REWRITES.has(key.toLowerCase()))
15126
+ continue;
15127
+ headers[key] = value;
15128
+ }
15129
+ const nativeCookie = reqHeaders[FETCH_PROXY_NATIVE_COOKIE_HEADER];
15130
+ if (typeof nativeCookie === "string" && nativeCookie)
15131
+ headers.cookie = decodeURIComponent(nativeCookie);
15132
+ headers.host = targetUrl.host;
15133
+ if (!Object.keys(headers).some((name2) => name2.toLowerCase() === "mobile-origin")) {
15134
+ headers.origin = targetUrl.origin;
15135
+ headers.referer = `${targetUrl.origin}/`;
15136
+ }
15137
+ return headers;
15138
+ }
15139
+ function rejectUntrustedBridgeOrigin(req, res) {
15140
+ if (isTrustedBridgeRequest(req.headers)) return false;
15141
+ res.statusCode = 403;
15142
+ res.setHeader("Content-Type", "text/plain; charset=utf-8");
15143
+ res.end(`peach bridge: origin ${req.headers.origin} may not use this bridge`);
15144
+ return true;
15145
+ }
15146
+ function isFetchProxyRequestUrl(rawUrl) {
15147
+ return rawUrl?.startsWith("/__fetch-proxy?") || rawUrl?.startsWith("/__proxy?") || false;
15148
+ }
15149
+ function isBundleProxyRequestUrl(rawUrl) {
15150
+ return rawUrl?.startsWith("/__bundle-proxy?") ?? false;
15151
+ }
15152
+ function isAppApiRequestUrl(rawUrl) {
15153
+ if (!rawUrl) return false;
15154
+ if (rawUrl.startsWith("/__app-api?")) return true;
15155
+ if (rawUrl.startsWith("/__app-api/")) return true;
15156
+ return false;
15157
+ }
15158
+ async function handleFetchProxyRequest(req, res) {
15159
+ if (req.method === "OPTIONS") {
15160
+ applyFetchProxyCors(req, res);
15161
+ res.statusCode = 204;
15162
+ res.end();
15163
+ return;
15164
+ }
15165
+ const params = new URLSearchParams((req.url || "").split("?")[1] || "");
15166
+ const targetUrl = params.get("url");
15167
+ if (!targetUrl) {
15168
+ applyFetchProxyCors(req, res);
15169
+ res.statusCode = 400;
15170
+ res.setHeader("Content-Type", "text/plain");
15171
+ res.end("missing url param");
15172
+ return;
15173
+ }
15174
+ let upstreamUrl;
15175
+ try {
15176
+ upstreamUrl = resolveFetchProxyTargetUrl(new URL(targetUrl));
15177
+ } catch {
15178
+ applyFetchProxyCors(req, res);
15179
+ res.statusCode = 400;
15180
+ res.setHeader("Content-Type", "text/plain");
15181
+ res.end("invalid url param");
15182
+ return;
15183
+ }
15184
+ const packageVersionsRead = isBundleProxyRequestUrl(req.url) && req.method === "GET" ? readDevServerPackageVersions(upstreamUrl) : null;
15185
+ packageVersionsRead?.catch(() => {
15186
+ });
15187
+ await proxyUpstream(req, res, upstreamUrl, params.has(FETCH_PROXY_FAILURE_PARAM), {
15188
+ requestHeaders: (target) => buildFetchProxyHeaders(req.headers, target),
15189
+ respond: async (upstream, setCookies) => {
15190
+ for (const [key, value] of Object.entries(upstream.headers)) {
15191
+ const lowerKey = key.toLowerCase();
15192
+ if (value === void 0 || lowerKey === "set-cookie" || lowerKey === "connection" || lowerKey === "keep-alive" || lowerKey === "proxy-authenticate" || lowerKey === "proxy-authorization" || lowerKey === "te" || lowerKey === "trailer" || lowerKey === "transfer-encoding" || lowerKey === "upgrade" || lowerKey === FETCH_PROXY_NATIVE_COOKIE_RESPONSE_HEADER || lowerKey === FETCH_PROXY_RESPONSE_URL_HEADER || lowerKey.startsWith("access-control-")) {
15193
+ continue;
15194
+ }
15195
+ res.setHeader(key, value);
15196
+ }
15197
+ if (packageVersionsRead && upstream.statusCode === 200 && !res.hasHeader(PACKAGE_VERSIONS_HEADER)) {
15198
+ const packageVersions = await packageVersionsRead;
15199
+ if (packageVersions)
15200
+ res.setHeader(PACKAGE_VERSIONS_HEADER, JSON.stringify(packageVersions));
15201
+ }
15202
+ applyFetchProxyCors(req, res);
15203
+ if (setCookies.length > 0)
15204
+ res.setHeader("x-sootsim-set-cookie", setCookies.join(", "));
15205
+ }
15206
+ });
15207
+ }
15208
+ function handleAppApiRequest(req, res) {
15209
+ const reqUrl = req.url || "";
15210
+ let targetPath = "";
15211
+ let targetOrigin = "";
15212
+ let reportFailure = false;
15213
+ if (reqUrl.startsWith("/__app-api?")) {
15214
+ const parsed = new URL(reqUrl, "http://sootsim.local");
15215
+ targetPath = parsed.searchParams.get("path") || "";
15216
+ targetOrigin = parsed.searchParams.get("origin")?.trim() || "";
15217
+ reportFailure = parsed.searchParams.has(FETCH_PROXY_FAILURE_PARAM);
15218
+ } else if (reqUrl.startsWith("/__app-api/")) {
15219
+ targetPath = reqUrl.slice("/__app-api".length);
15220
+ } else {
15221
+ return false;
15222
+ }
15223
+ if (!targetOrigin) {
15224
+ res.writeHead(400, { "Content-Type": "text/plain" });
15225
+ res.end("app-api: missing origin query param");
15226
+ return true;
15227
+ }
15228
+ if (req.method === "OPTIONS") {
15229
+ res.writeHead(204, {
15230
+ "Access-Control-Allow-Origin": req.headers.origin || "*",
15231
+ "Access-Control-Allow-Methods": "GET,POST,PUT,PATCH,DELETE,OPTIONS",
15232
+ "Access-Control-Allow-Headers": req.headers["access-control-request-headers"] || "*",
15233
+ "Access-Control-Allow-Credentials": "true",
15234
+ "Access-Control-Max-Age": "86400"
15235
+ });
15236
+ res.end();
15237
+ return true;
15238
+ }
15239
+ let targetUrl;
15240
+ try {
15241
+ targetUrl = new URL(targetPath, targetOrigin);
15242
+ } catch {
15243
+ res.writeHead(400, { "Content-Type": "text/plain" });
15244
+ res.end("app-api: invalid origin or path");
15245
+ return true;
15246
+ }
15247
+ void proxyUpstream(req, res, targetUrl, reportFailure, {
15248
+ requestHeaders: (target) => buildAppApiProxyHeaders(req.headers, target),
15249
+ respond: (upstream, setCookies) => {
15250
+ for (const [key, value] of Object.entries(upstream.headers)) {
15251
+ const lowerKey = key.toLowerCase();
15252
+ if (value === void 0 || lowerKey === "set-cookie" || lowerKey === FETCH_PROXY_NATIVE_COOKIE_RESPONSE_HEADER || lowerKey === FETCH_PROXY_RESPONSE_URL_HEADER) {
15253
+ continue;
15254
+ }
15255
+ res.setHeader(key, value);
15256
+ }
15257
+ if (setCookies.length > 0 && req.headers[FETCH_PROXY_NATIVE_COOKIE_HEADER] === void 0)
15258
+ res.setHeader("set-cookie", setCookies);
15259
+ res.setHeader("access-control-allow-origin", req.headers.origin || "*");
15260
+ res.setHeader("access-control-allow-credentials", "true");
15261
+ res.setHeader(
15262
+ "access-control-expose-headers",
15263
+ Object.keys(res.getHeaders()).filter((name2) => !name2.startsWith("access-control-") && name2 !== "set-cookie").join(", ")
15264
+ );
15265
+ }
15266
+ });
15267
+ return true;
15268
+ }
15269
+ function serveBrowserProxyRoute(req, res) {
15270
+ if (isBundleProxyRequestUrl(req.url) || isFetchProxyRequestUrl(req.url)) {
15271
+ if (!rejectUntrustedBridgeOrigin(req, res)) void handleFetchProxyRequest(req, res);
15272
+ return true;
15273
+ }
15274
+ if (isAppApiRequestUrl(req.url)) {
15275
+ if (rejectUntrustedBridgeOrigin(req, res)) return true;
15276
+ return handleAppApiRequest(req, res);
15277
+ }
15278
+ return false;
15279
+ }
15280
+ async function proxyUpstream(req, res, upstreamUrl, reportFailure, route) {
15281
+ const originalMethod = req.method || "GET";
15282
+ const proxy = async (targetUrl, method, nextBody, redirects, setCookies) => {
15283
+ const transport = targetUrl.protocol === "https:" ? import_https.default : import_http.default;
15284
+ const targetHeaders = route.requestHeaders(targetUrl);
15285
+ if (targetUrl.origin !== upstreamUrl.origin) {
15286
+ delete targetHeaders.authorization;
15287
+ delete targetHeaders["proxy-authorization"];
15288
+ }
15289
+ if (method === "GET" || method === "HEAD") {
15290
+ delete targetHeaders["content-length"];
15291
+ delete targetHeaders["content-type"];
15292
+ } else if (nextBody) {
15293
+ delete targetHeaders["transfer-encoding"];
15294
+ targetHeaders["content-length"] = String(nextBody.byteLength);
15295
+ }
15296
+ const port = projectLoopbackPort(
15297
+ targetUrl.hostname,
15298
+ Number(targetUrl.port || (targetUrl.protocol === "https:" ? 443 : 80))
15299
+ );
15300
+ let clientAborted = false;
15301
+ const markAborted = () => {
15302
+ clientAborted = true;
15303
+ };
15304
+ req.once("aborted", markAborted);
15305
+ const send = () => new Promise((resolve5, reject) => {
15306
+ let responded = false;
15307
+ const proxyReq = transport.request(
15308
+ {
15309
+ hostname: normalizeHostname(targetUrl.hostname),
15310
+ port,
15311
+ path: targetUrl.pathname + targetUrl.search,
15312
+ method,
15313
+ headers: targetHeaders,
15314
+ agent: fetchProxyAgentFor(targetUrl),
15315
+ ...loopbackTlsOptions(targetUrl)
15316
+ },
15317
+ (upstream) => {
15318
+ responded = true;
15319
+ resolve5(upstream);
15320
+ }
15321
+ );
15322
+ const abort = () => proxyReq.destroy();
15323
+ req.once("aborted", abort);
15324
+ proxyReq.once("close", () => req.off("aborted", abort));
15325
+ let failed = false;
15326
+ proxyReq.on("error", (err) => {
15327
+ if (failed) return;
15328
+ failed = true;
15329
+ if (proxyReq.reusedSocket && !responded && !clientAborted && err.code === "ECONNRESET")
15330
+ resolve5(send());
15331
+ else reject(err);
15332
+ });
15333
+ if (nextBody === void 0) proxyReq.end();
15334
+ else proxyReq.end(nextBody);
15335
+ });
15336
+ const proxyRes = await send().finally(() => req.off("aborted", markAborted));
15337
+ const status = proxyRes.statusCode ?? 502;
15338
+ const location = proxyRes.headers.location;
15339
+ const hopCookies = [...setCookies, ...proxyRes.headers["set-cookie"] ?? []];
15340
+ if (req.headers[FETCH_PROXY_NATIVE_COOKIE_HEADER] !== void 0) {
15341
+ const hop = {
15342
+ url: upstreamUrl.href,
15343
+ status,
15344
+ location: location ?? null,
15345
+ cookies: hopCookies,
15346
+ redirectLimit: 10
15347
+ };
15348
+ res.setHeader(FETCH_PROXY_NATIVE_COOKIE_RESPONSE_HEADER, nativeCookieHopHeader(hop));
15349
+ await route.respond(proxyRes, hopCookies);
15350
+ if (isNativeCookieRedirect(hop)) res.removeHeader("location");
15351
+ res.statusCode = isNativeCookieRedirect(hop) ? 200 : status;
15352
+ await (0, import_promises3.pipeline)(proxyRes, res);
15353
+ return;
15354
+ }
15355
+ if (location && (status === 301 || status === 302 || status === 303 || status === 307 || status === 308)) {
15356
+ if (redirects >= 10) {
15357
+ proxyRes.destroy();
15358
+ throw new Error("too many redirects");
15359
+ }
15360
+ const switchToGet = (status === 301 || status === 302) && method === "POST" || status === 303 && method !== "GET" && method !== "HEAD";
15361
+ const redirectUrl = resolveRedirectUrl(location, targetUrl);
15362
+ proxyRes.resume();
15363
+ await (0, import_promises3.finished)(proxyRes);
15364
+ await proxy(
15365
+ redirectUrl,
15366
+ switchToGet ? "GET" : method,
15367
+ switchToGet ? void 0 : nextBody,
15368
+ redirects + 1,
15369
+ hopCookies
15370
+ );
15371
+ return;
15372
+ }
15373
+ if (redirects > 0) res.setHeader(FETCH_PROXY_RESPONSE_URL_HEADER, targetUrl.href);
15374
+ await route.respond(proxyRes, hopCookies);
15375
+ res.statusCode = status;
15376
+ if (isBundleProxyRequestUrl(req.url) && method === "GET" && status === 200 && targetUrl.pathname.endsWith(".bundle")) {
15377
+ await forwardRolldownBundleResponse(proxyRes, res);
15378
+ return;
15379
+ }
15380
+ await (0, import_promises3.pipeline)(proxyRes, res);
15381
+ };
15382
+ let body;
15383
+ try {
15384
+ if (req.method !== "GET" && req.method !== "HEAD") {
15385
+ const chunks = [];
15386
+ for await (const chunk of req) {
15387
+ chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
15388
+ }
15389
+ if (chunks.length > 0) {
15390
+ body = Buffer.concat(chunks);
15391
+ }
15392
+ }
15393
+ await proxy(upstreamUrl, originalMethod, body, 0, []);
15394
+ } catch (err) {
15395
+ const norm = normalizeHostname(upstreamUrl.hostname);
15396
+ if (!res.headersSent && isLoopbackHost(norm) && err?.code === "ECONNREFUSED") {
15397
+ const altHosts = norm === "::1" ? ["127.0.0.1"] : norm === "127.0.0.1" ? ["[::1]"] : ["[::1]", "127.0.0.1"];
15398
+ for (const altHost of altHosts) {
15399
+ try {
15400
+ const altUrl = new URL(upstreamUrl.href);
15401
+ altUrl.hostname = altHost;
15402
+ await proxy(altUrl, originalMethod, body, 0, []);
15403
+ return;
15404
+ } catch {
15405
+ }
15406
+ }
15407
+ }
15408
+ if (!res.headersSent && reportFailure) {
15409
+ const code = err?.code;
15410
+ res.statusCode = 502;
15411
+ res.setHeader(
15412
+ FETCH_PROXY_FAILURE_HEADER,
15413
+ typeof code === "string" ? code : "unknown"
15414
+ );
15415
+ applyFetchProxyCors(req, res);
15416
+ res.end();
15417
+ return;
15418
+ }
15419
+ if (req instanceof import_node_http2.Http2ServerRequest)
15420
+ req.stream.destroy(new Error("fetch proxy upstream failed", { cause: err }));
15421
+ else req.socket.destroy();
15422
+ }
15423
+ }
15424
+
15425
+ // src/vite-plugin-one.ts
15426
+ init_replacement_module_handler();
15427
+
15428
+ // src/one-widget-metadata.ts
15429
+ init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
15430
+ var import_node_child_process3 = require("node:child_process");
15431
+ var import_node_crypto5 = require("node:crypto");
15432
+ var import_node_fs12 = __toESM(require("node:fs"), 1);
15433
+ var import_node_module2 = require("node:module");
15434
+ var import_node_path11 = __toESM(require("node:path"), 1);
15435
+ var import_node_util = require("node:util");
15436
+
15437
+ // cli/internal-child.ts
15438
+ init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
15439
+ var RNX_FORKED_SCRIPT_ENV = "PEACH_RUNS_FORKED_SCRIPTS";
15440
+
14260
15441
  // src/one-widget-metadata.ts
15442
+ init_is_record();
14261
15443
  init_swift_source_file();
14262
15444
  init_swift_submit();
14263
15445
  var run = (0, import_node_util.promisify)(import_node_child_process3.execFile);
@@ -14280,8 +15462,8 @@ fs.writeFileSync(process.argv[2], JSON.stringify({
14280
15462
  function configStamp(files) {
14281
15463
  return JSON.stringify(
14282
15464
  files.map((file) => {
14283
- if (!import_node_fs11.default.existsSync(file)) return [file, null];
14284
- const stat = import_node_fs11.default.statSync(file);
15465
+ if (!import_node_fs12.default.existsSync(file)) return [file, null];
15466
+ const stat = import_node_fs12.default.statSync(file);
14285
15467
  return [file, stat.mtimeMs, stat.ctimeMs, stat.size];
14286
15468
  })
14287
15469
  );
@@ -14292,13 +15474,13 @@ async function readConfig(root) {
14292
15474
  const reading = reads.get(root);
14293
15475
  if (reading) return reading;
14294
15476
  const promise = (async () => {
14295
- (0, import_node_module2.createRequire)(import_node_path10.default.join(root, "package.json")).resolve("one/vite");
14296
- const cache = import_node_path10.default.join(root, "node_modules/.cache/peach-widget-config");
14297
- import_node_fs11.default.mkdirSync(cache, { recursive: true });
14298
- const directory = import_node_fs11.default.mkdtempSync(import_node_path10.default.join(cache, "read-"));
14299
- const script = import_node_path10.default.join(directory, "read.mjs");
14300
- const result = import_node_path10.default.join(directory, "result.json");
14301
- import_node_fs11.default.writeFileSync(script, CONFIG_CHILD);
15477
+ (0, import_node_module2.createRequire)(import_node_path11.default.join(root, "package.json")).resolve("one/vite");
15478
+ const cache = import_node_path11.default.join(root, "node_modules/.cache/peach-widget-config");
15479
+ import_node_fs12.default.mkdirSync(cache, { recursive: true });
15480
+ const directory = import_node_fs12.default.mkdtempSync(import_node_path11.default.join(cache, "read-"));
15481
+ const script = import_node_path11.default.join(directory, "read.mjs");
15482
+ const result = import_node_path11.default.join(directory, "result.json");
15483
+ import_node_fs12.default.writeFileSync(script, CONFIG_CHILD);
14302
15484
  try {
14303
15485
  await run(process.execPath, [script, result], {
14304
15486
  cwd: root,
@@ -14306,7 +15488,7 @@ async function readConfig(root) {
14306
15488
  timeout: 3e4,
14307
15489
  maxBuffer: 1024 * 1024
14308
15490
  });
14309
- const value = JSON.parse(import_node_fs11.default.readFileSync(result, "utf8"));
15491
+ const value = JSON.parse(import_node_fs12.default.readFileSync(result, "utf8"));
14310
15492
  if (!isRecord(value) || !Array.isArray(value.watched) || !value.watched.every((file) => typeof file === "string"))
14311
15493
  throw new Error("One config loader returned invalid dependencies");
14312
15494
  if (!Array.isArray(value.urlSchemes) || !value.urlSchemes.every(
@@ -14329,8 +15511,8 @@ async function readConfig(root) {
14329
15511
  }
14330
15512
  const watched = [
14331
15513
  .../* @__PURE__ */ new Set([
14332
- import_node_path10.default.join(root, "package.json"),
14333
- ...value.watched.map((file) => import_node_path10.default.resolve(root, file))
15514
+ import_node_path11.default.join(root, "package.json"),
15515
+ ...value.watched.map((file) => import_node_path11.default.resolve(root, file))
14334
15516
  ])
14335
15517
  ];
14336
15518
  const loaded3 = {
@@ -14342,7 +15524,7 @@ async function readConfig(root) {
14342
15524
  configs.set(root, loaded3);
14343
15525
  return loaded3;
14344
15526
  } finally {
14345
- import_node_fs11.default.rmSync(directory, { recursive: true, force: true });
15527
+ import_node_fs12.default.rmSync(directory, { recursive: true, force: true });
14346
15528
  }
14347
15529
  })();
14348
15530
  reads.set(root, promise);
@@ -14363,13 +15545,13 @@ function declaredFamilies(source) {
14363
15545
  return home;
14364
15546
  }
14365
15547
  async function readOneWidgetSources(appRoot) {
14366
- const root = import_node_fs11.default.realpathSync(appRoot);
15548
+ const root = import_node_fs12.default.realpathSync(appRoot);
14367
15549
  const config = await readConfig(root);
14368
15550
  if (!config.widget) return null;
14369
15551
  const widget = config.widget;
14370
15552
  const sourceFiles = {
14371
- "OneWidget.swift": import_node_path10.default.join(root, "ios/OneWidgets/OneWidget.swift"),
14372
- "OneWidgetContract.swift": import_node_path10.default.join(
15553
+ "OneWidget.swift": import_node_path11.default.join(root, "ios/OneWidgets/OneWidget.swift"),
15554
+ "OneWidgetContract.swift": import_node_path11.default.join(
14373
15555
  root,
14374
15556
  "ios",
14375
15557
  widget.appName,
@@ -14379,14 +15561,14 @@ async function readOneWidgetSources(appRoot) {
14379
15561
  const files = /* @__PURE__ */ new Map();
14380
15562
  const sources = {};
14381
15563
  for (const [name2, file] of Object.entries(sourceFiles)) {
14382
- if (!import_node_fs11.default.existsSync(file))
15564
+ if (!import_node_fs12.default.existsSync(file))
14383
15565
  throw new Error(`missing One widget prebuild source ${file}; run one prebuild`);
14384
15566
  const bytes = readPackageFile(root, file, MAX_SWIFT_COMPILE_SOURCE_BYTES);
14385
15567
  const text2 = bytes.toString("utf8");
14386
15568
  if (!Buffer.from(text2).equals(bytes))
14387
15569
  throw new Error(`One widget prebuild source is not UTF-8: ${file}`);
14388
15570
  files.set(name2, text2);
14389
- 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");
15571
+ sources[import_node_path11.default.relative(root, file).split(import_node_path11.default.sep).join("/")] = (0, import_node_crypto5.createHash)("sha256").update(bytes).digest("hex");
14390
15572
  }
14391
15573
  const contract = files.get("OneWidgetContract.swift") ?? "";
14392
15574
  const source = files.get("OneWidget.swift") ?? "";
@@ -14554,7 +15736,7 @@ function peachPlugin(options = {}) {
14554
15736
  }
14555
15737
  res.setHeader(key, value);
14556
15738
  }
14557
- const forward = res.statusCode === 200 ? forwardRolldownBundleResponse(upstream, res) : (0, import_promises3.pipeline)(upstream, res);
15739
+ const forward = res.statusCode === 200 ? forwardRolldownBundleResponse(upstream, res) : (0, import_promises5.pipeline)(upstream, res);
14558
15740
  forward.catch(
14559
15741
  (error) => res.destroy(error instanceof Error ? error : new Error(String(error)))
14560
15742
  );
@@ -14573,11 +15755,11 @@ function peachPlugin(options = {}) {
14573
15755
  let swiftModuleRoot;
14574
15756
  const moduleRootFor = () => {
14575
15757
  if (swiftModuleRoot === void 0) {
14576
- const moduleRoot = import_path4.default.resolve(
14577
- import_path4.default.dirname((0, import_node_url.fileURLToPath)(__sootsim_import_meta_url)),
15758
+ const moduleRoot = import_path5.default.resolve(
15759
+ import_path5.default.dirname((0, import_node_url.fileURLToPath)(__sootsim_import_meta_url)),
14578
15760
  "../../sootsim-swift"
14579
15761
  );
14580
- swiftModuleRoot = import_fs5.default.existsSync(import_path4.default.join(moduleRoot, "toolchain.json")) ? moduleRoot : null;
15762
+ swiftModuleRoot = import_fs6.default.existsSync(import_path5.default.join(moduleRoot, "toolchain.json")) ? moduleRoot : null;
14581
15763
  }
14582
15764
  return swiftModuleRoot ?? void 0;
14583
15765
  };
@@ -14662,15 +15844,15 @@ function peachPlugin(options = {}) {
14662
15844
  });
14663
15845
  }
14664
15846
  server.watcher.on("add", (file) => {
14665
- if (import_path4.default.basename(file) === "Package.swift") swiftPackages = void 0;
15847
+ if (import_path5.default.basename(file) === "Package.swift") swiftPackages = void 0;
14666
15848
  });
14667
15849
  server.watcher.on("unlink", (file) => {
14668
- if (import_path4.default.basename(file) === "Package.swift") swiftPackages = void 0;
15850
+ if (import_path5.default.basename(file) === "Package.swift") swiftPackages = void 0;
14669
15851
  });
14670
15852
  let kotlinModuleRoot;
14671
15853
  server.watcher.on("all", (_event, file) => {
14672
15854
  if (!kotlinModuleRoot) return;
14673
- if (file.endsWith(".kt") || file.startsWith(`${kotlinModuleRoot}${import_path4.default.sep}`))
15855
+ if (file.endsWith(".kt") || file.startsWith(`${kotlinModuleRoot}${import_path5.default.sep}`))
14674
15856
  sendSwiftChange({ type: "kotlin", packageName: "kotlin" });
14675
15857
  });
14676
15858
  server.middlewares.use((req, res, next) => {
@@ -14681,7 +15863,7 @@ function peachPlugin(options = {}) {
14681
15863
  const root = host.peachKotlinModuleRoot();
14682
15864
  kotlinModuleRoot = root;
14683
15865
  server.watcher.add(
14684
- ["sdk.tar.gz", "toolchain.json"].map((file) => import_path4.default.join(root, file))
15866
+ ["sdk.tar.gz", "toolchain.json"].map((file) => import_path5.default.join(root, file))
14685
15867
  );
14686
15868
  }
14687
15869
  const served = await host.serveKotlinRequest(pathname, res, {
@@ -14712,7 +15894,7 @@ function peachPlugin(options = {}) {
14712
15894
  for (const packageName of activeSwiftPackages) {
14713
15895
  const packagePath = packages.get(packageName);
14714
15896
  const widgetChanged = packageName === "OneWidgets" && widgetPackage?.watched.includes(file);
14715
- if (!widgetChanged && !(packagePath && file.startsWith(`${packagePath}${import_path4.default.sep}`)) && !(moduleRoot && file.startsWith(`${moduleRoot}${import_path4.default.sep}`)))
15897
+ if (!widgetChanged && !(packagePath && file.startsWith(`${packagePath}${import_path5.default.sep}`)) && !(moduleRoot && file.startsWith(`${moduleRoot}${import_path5.default.sep}`)))
14716
15898
  continue;
14717
15899
  void packageMetadata(packageName, moduleRoot).then((metadata) => {
14718
15900
  sendSwiftChange({
@@ -14782,7 +15964,7 @@ function peachPlugin(options = {}) {
14782
15964
  );
14783
15965
  };
14784
15966
  const buildShellHtml = (runtimeRoot, origin) => {
14785
- const html = import_fs5.default.readFileSync(import_path4.default.join(runtimeRoot, "index.html"), "utf8");
15967
+ const html = import_fs6.default.readFileSync(import_path5.default.join(runtimeRoot, "index.html"), "utf8");
14786
15968
  const lock = readDaemonLockfile();
14787
15969
  const bridgePort = lock && isDaemonLockfileFresh(lock) && lock.bridgePort > 0 ? lock.bridgePort : DEFAULT_SOOTSIM_BRIDGE_PORT;
14788
15970
  const inject = `<script>(function(){var u=new URL(location.href);var b=${JSON.stringify(bundleForOrigin(origin))};if(!u.searchParams.has('bundle'))u.searchParams.set('bundle',b);window.__sootsimBridgePort=${bridgePort};window.__peachPageServingAuthority='contributor';history.replaceState(null,'','${prefix2}/'+u.search)})()</script>`;
@@ -14847,6 +16029,7 @@ function peachPlugin(options = {}) {
14847
16029
  });
14848
16030
  });
14849
16031
  server.middlewares.use((req, res, next) => {
16032
+ if (serveBrowserProxyRoute(req, res)) return;
14850
16033
  const url = req.url || "";
14851
16034
  const pathname = url.split("?")[0];
14852
16035
  const runtimeRoot = resolveRuntimeRootForRequestHost(req.headers.host);
@@ -14867,8 +16050,7 @@ function peachPlugin(options = {}) {
14867
16050
  }
14868
16051
  }
14869
16052
  if (pathname === prefix2 || pathname === prefix2 + "/") {
14870
- res.setHeader("content-type", "text/html");
14871
- res.end(buildShellHtml(runtimeRoot, requestOrigin(req)));
16053
+ sendShellHtml(res, buildShellHtml(runtimeRoot, requestOrigin(req)));
14872
16054
  return;
14873
16055
  }
14874
16056
  if (pathname.startsWith(prefix2 + "/")) {
@@ -14880,10 +16062,9 @@ function peachPlugin(options = {}) {
14880
16062
  serveRuntimeFile(req, res, fullPath);
14881
16063
  return;
14882
16064
  }
14883
- const ext = import_path4.default.extname(pathname);
16065
+ const ext = import_path5.default.extname(pathname);
14884
16066
  if (!ext) {
14885
- res.setHeader("content-type", "text/html");
14886
- res.end(buildShellHtml(runtimeRoot, requestOrigin(req)));
16067
+ sendShellHtml(res, buildShellHtml(runtimeRoot, requestOrigin(req)));
14887
16068
  return;
14888
16069
  }
14889
16070
  }
@@ -14907,24 +16088,24 @@ function peachPlugin(options = {}) {
14907
16088
 
14908
16089
  // src/metro-plugin.ts
14909
16090
  init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
14910
- var import_fs6 = __toESM(require("fs"), 1);
16091
+ var import_fs7 = __toESM(require("fs"), 1);
14911
16092
  var import_module2 = require("module");
14912
16093
  var import_node_crypto8 = require("node:crypto");
14913
- var import_path5 = __toESM(require("path"), 1);
16094
+ var import_path6 = __toESM(require("path"), 1);
14914
16095
  init_app_project();
14915
16096
 
14916
16097
  // src/android-autolinking.ts
14917
16098
  init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
14918
16099
  var import_node_child_process4 = require("node:child_process");
14919
- var import_node_fs13 = __toESM(require("node:fs"), 1);
16100
+ var import_node_fs14 = __toESM(require("node:fs"), 1);
14920
16101
  var import_node_module3 = require("node:module");
14921
- var import_node_path12 = __toESM(require("node:path"), 1);
16102
+ var import_node_path13 = __toESM(require("node:path"), 1);
14922
16103
  var import_node_util2 = require("node:util");
14923
16104
  init_is_record();
14924
16105
  var run2 = (0, import_node_util2.promisify)(import_node_child_process4.execFile);
14925
16106
  var resolving = /* @__PURE__ */ new Map();
14926
16107
  async function resolveExpoAndroidAutolinking(appRoot) {
14927
- const root = import_node_fs13.default.realpathSync(appRoot);
16108
+ const root = import_node_fs14.default.realpathSync(appRoot);
14928
16109
  const existing = resolving.get(root);
14929
16110
  if (existing) return existing;
14930
16111
  const pending = resolveAndroidModules(root);
@@ -14938,7 +16119,7 @@ async function resolveExpoAndroidAutolinking(appRoot) {
14938
16119
  async function resolveAndroidModules(appRoot) {
14939
16120
  let autolinker;
14940
16121
  try {
14941
- autolinker = (0, import_node_module3.createRequire)(import_node_path12.default.join(appRoot, "package.json")).resolve(
16122
+ autolinker = (0, import_node_module3.createRequire)(import_node_path13.default.join(appRoot, "package.json")).resolve(
14942
16123
  "expo-modules-autolinking/package.json"
14943
16124
  );
14944
16125
  } catch (error) {
@@ -14948,7 +16129,7 @@ async function resolveAndroidModules(appRoot) {
14948
16129
  const { stdout } = await run2(
14949
16130
  process.execPath,
14950
16131
  [
14951
- import_node_path12.default.join(import_node_path12.default.dirname(autolinker), "bin/expo-modules-autolinking.js"),
16132
+ import_node_path13.default.join(import_node_path13.default.dirname(autolinker), "bin/expo-modules-autolinking.js"),
14952
16133
  "resolve",
14953
16134
  "--platform",
14954
16135
  "android",
@@ -15183,7 +16364,7 @@ function resolveNativeAppIconArtwork(resources, readText, resourceUri, icons, pr
15183
16364
  isRecord(dictionary.CFBundleAlternateIcons) ? dictionary.CFBundleAlternateIcons : {}
15184
16365
  ).map(([name2, declaration]) => [resolveReference(name2), declaration])
15185
16366
  );
15186
- const resolve4 = (declaration, defaultName) => {
16367
+ const resolve5 = (declaration, defaultName) => {
15187
16368
  const entry = isRecord(declaration) ? declaration : {};
15188
16369
  const name2 = typeof entry.CFBundleIconName === "string" ? resolveReference(entry.CFBundleIconName) : resolveReference(defaultName);
15189
16370
  const catalogs = resources.filter(
@@ -15234,12 +16415,12 @@ function resolveNativeAppIconArtwork(resources, readText, resourceUri, icons, pr
15234
16415
  return uri ? [{ uri, scale }] : [];
15235
16416
  }).sort((a, b) => a.scale - b.scale);
15236
16417
  };
15237
- const primary = resolve4(dictionary.CFBundlePrimaryIcon, primaryName);
16418
+ const primary = resolve5(dictionary.CFBundlePrimaryIcon, primaryName);
15238
16419
  return {
15239
16420
  ...primary.length ? { primary } : {},
15240
16421
  alternates: Object.fromEntries(
15241
16422
  alternateNames.flatMap((name2) => {
15242
- const images = resolve4(alternates[name2], name2);
16423
+ const images = resolve5(alternates[name2], name2);
15243
16424
  return images.length ? [[name2, images]] : [];
15244
16425
  })
15245
16426
  )
@@ -15346,7 +16527,7 @@ function parseOpenStepPlist(text2) {
15346
16527
  init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
15347
16528
  var NEVER_MEMBER = /(?:^|\/)(?:Info\.plist|[^/]+\.entitlements|[^/]+\.xcconfig|\.DS_Store)$/;
15348
16529
  var BUNDLE_DIR = /\.(xcassets|bundle|lproj|xcdatamodeld|scnassets|spriteatlas|rcproject|storyboardc|icon)$/;
15349
- function xcodePathResolver(objects, projectDir, join6) {
16530
+ function xcodePathResolver(objects, projectDir, join7) {
15350
16531
  const parents = /* @__PURE__ */ new Map();
15351
16532
  for (const [id, entry] of Object.entries(objects)) {
15352
16533
  if (!isDict(entry)) continue;
@@ -15355,7 +16536,7 @@ function xcodePathResolver(objects, projectDir, join6) {
15355
16536
  }
15356
16537
  }
15357
16538
  const paths = /* @__PURE__ */ new Map();
15358
- const resolve4 = (id) => {
16539
+ const resolve5 = (id) => {
15359
16540
  if (paths.has(id)) return paths.get(id);
15360
16541
  paths.set(id, null);
15361
16542
  const entry = objects[id];
@@ -15364,19 +16545,19 @@ function xcodePathResolver(objects, projectDir, join6) {
15364
16545
  const own = str(entry.path) ?? "";
15365
16546
  const tree = str(entry.sourceTree) ?? "<group>";
15366
16547
  if (tree === "<absolute>") result = own;
15367
- else if (tree === "SOURCE_ROOT") result = join6(projectDir, own);
16548
+ else if (tree === "SOURCE_ROOT") result = join7(projectDir, own);
15368
16549
  else if (tree === "<group>") {
15369
16550
  const parent = parents.get(id);
15370
- const base = parent ? resolve4(parent) : projectDir;
15371
- if (base !== null) result = join6(base, own);
16551
+ const base = parent ? resolve5(parent) : projectDir;
16552
+ if (base !== null) result = join7(base, own);
15372
16553
  }
15373
16554
  }
15374
16555
  paths.set(id, result);
15375
16556
  return result;
15376
16557
  };
15377
- return resolve4;
16558
+ return resolve5;
15378
16559
  }
15379
- function visitXcodeTargetMembers(objects, targetId, resolvePath, filesUnder, join6, visit3) {
16560
+ function visitXcodeTargetMembers(objects, targetId, resolvePath, filesUnder, join7, visit3) {
15380
16561
  const target = objects[targetId];
15381
16562
  if (!isDict(target)) return;
15382
16563
  for (const phaseId of list(target.buildPhases)) {
@@ -15412,7 +16593,7 @@ function visitXcodeTargetMembers(objects, targetId, resolvePath, filesUnder, joi
15412
16593
  for (const relative3 of list(exception.membershipExceptions))
15413
16594
  exceptions.add(relative3);
15414
16595
  }
15415
- const members = owned.has(groupId) ? filesUnder(folder) : [...exceptions].flatMap((relative3) => filesUnder(join6(folder, relative3)));
16596
+ const members = owned.has(groupId) ? filesUnder(folder) : [...exceptions].flatMap((relative3) => filesUnder(join7(folder, relative3)));
15416
16597
  for (const file of members) {
15417
16598
  const relative3 = file.slice(prefix2.length);
15418
16599
  const excepted = [...exceptions].some(
@@ -15566,10 +16747,10 @@ function appTargetReleaseSettings(pbxproj, targetName, infoPlistRelativePath) {
15566
16747
  var APP_DELEGATE_PATH_RE = /(?:^|\/)ios\/([^/]+)\/AppDelegate\.(?:swift|mm|m)$/;
15567
16748
  function nativeAppIdentityFromIos(files, parseInfoPlist, iosTarget, resourceUri) {
15568
16749
  const pbxprojPath = Object.keys(files).find(
15569
- (path21) => /(?:^|\/)ios\/[^/]+\.xcodeproj\/project\.pbxproj$/.test(path21)
16750
+ (path22) => /(?:^|\/)ios\/[^/]+\.xcodeproj\/project\.pbxproj$/.test(path22)
15570
16751
  ) ?? Object.keys(files).find(
15571
- (path21) => /(?:^|\/)[^/]+\.xcodeproj\/project\.pbxproj$/.test(path21)
15572
- ) ?? Object.keys(files).find((path21) => /(?:^|\/)project\.pbxproj$/.test(path21));
16752
+ (path22) => /(?:^|\/)[^/]+\.xcodeproj\/project\.pbxproj$/.test(path22)
16753
+ ) ?? Object.keys(files).find((path22) => /(?:^|\/)project\.pbxproj$/.test(path22));
15573
16754
  if (!pbxprojPath) return null;
15574
16755
  const pbxproj = files[pbxprojPath];
15575
16756
  let objects = {};
@@ -15611,7 +16792,7 @@ function nativeAppIdentityFromIos(files, parseInfoPlist, iosTarget, resourceUri)
15611
16792
  } else if (applicationTargetNames.size === 1) {
15612
16793
  targetName = [...applicationTargetNames][0];
15613
16794
  } else if (applicationTargetNames.size > 1) {
15614
- const delegateTargets = Object.keys(files).filter((path21) => !path21.includes("/Pods/")).map((path21) => path21.match(APP_DELEGATE_PATH_RE)?.[1]).filter(
16795
+ const delegateTargets = Object.keys(files).filter((path22) => !path22.includes("/Pods/")).map((path22) => path22.match(APP_DELEGATE_PATH_RE)?.[1]).filter(
15615
16796
  (name2) => typeof name2 === "string" && applicationTargetNames.has(name2)
15616
16797
  );
15617
16798
  if (delegateTargets.length === 1) {
@@ -15809,7 +16990,7 @@ function nativeAppIdentityFromIos(files, parseInfoPlist, iosTarget, resourceUri)
15809
16990
  if (resourceUri) {
15810
16991
  if (!selectedTarget)
15811
16992
  throw new Error("native app icon target membership is unresolved");
15812
- const join6 = (base, own) => {
16993
+ const join7 = (base, own) => {
15813
16994
  const segments = [];
15814
16995
  for (const segment of `${base}/${own}`.split("/")) {
15815
16996
  if (segment === "" || segment === ".") continue;
@@ -15822,7 +17003,7 @@ function nativeAppIdentityFromIos(files, parseInfoPlist, iosTarget, resourceUri)
15822
17003
  const project = Object.values(objects).find(
15823
17004
  (object2) => isRecord(object2) && object2.isa === "PBXProject"
15824
17005
  );
15825
- const projectDir = join6(
17006
+ const projectDir = join7(
15826
17007
  pbxprojPath.replace(/(?:^|\/)[^/]+\.xcodeproj\/project\.pbxproj$/, ""),
15827
17008
  isRecord(project) && typeof project.projectDirPath === "string" ? project.projectDirPath : ""
15828
17009
  );
@@ -15830,15 +17011,15 @@ function nativeAppIdentityFromIos(files, parseInfoPlist, iosTarget, resourceUri)
15830
17011
  visitXcodeTargetMembers(
15831
17012
  objects,
15832
17013
  selectedTarget.id,
15833
- xcodePathResolver(objects, projectDir, join6),
17014
+ xcodePathResolver(objects, projectDir, join7),
15834
17015
  (file) => {
15835
17016
  if (Object.hasOwn(files, file)) return [file];
15836
17017
  const prefix2 = file === "" ? "" : `${file.replace(/\/$/, "")}/`;
15837
17018
  return paths.filter(
15838
- (path21) => path21.startsWith(prefix2) && !/(?:^|\/)\./.test(path21.slice(prefix2.length))
17019
+ (path22) => path22.startsWith(prefix2) && !/(?:^|\/)\./.test(path22.slice(prefix2.length))
15839
17020
  );
15840
17021
  },
15841
- join6,
17022
+ join7,
15842
17023
  (file, kind) => {
15843
17024
  if (kind === "resource") resources.add(file);
15844
17025
  }
@@ -15846,7 +17027,7 @@ function nativeAppIdentityFromIos(files, parseInfoPlist, iosTarget, resourceUri)
15846
17027
  }
15847
17028
  const rootModuleName = readRootModuleName(
15848
17029
  Object.entries(files).filter(
15849
- ([path21]) => !path21.includes("/Pods/") && (/(?:^|\/)ios\/AppDelegate\.(?:swift|mm|m)$/.test(path21) || path21.match(APP_DELEGATE_PATH_RE)?.[1] === targetName)
17030
+ ([path22]) => !path22.includes("/Pods/") && (/(?:^|\/)ios\/AppDelegate\.(?:swift|mm|m)$/.test(path22) || path22.match(APP_DELEGATE_PATH_RE)?.[1] === targetName)
15850
17031
  ).map(([, source]) => source)
15851
17032
  );
15852
17033
  return {
@@ -15932,29 +17113,22 @@ function extractNativeAppIdentityFromFiles(files, platform, parseInfoPlist, iosT
15932
17113
 
15933
17114
  // src/native-app-identity-project.ts
15934
17115
  init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
15935
- var import_node_fs15 = __toESM(require("node:fs"), 1);
17116
+ var import_node_fs16 = __toESM(require("node:fs"), 1);
15936
17117
  var import_node_module4 = require("node:module");
15937
- var import_node_path15 = __toESM(require("node:path"), 1);
17118
+ var import_node_path16 = __toESM(require("node:path"), 1);
15938
17119
  init_is_record();
15939
17120
 
15940
- // src/plist.ts
15941
- init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
15942
- var import_plist = __toESM(require("plist"), 1);
15943
- function parsePlistSource(source) {
15944
- return import_plist.default.parse(source);
15945
- }
15946
-
15947
17121
  // src/xcode-project.ts
15948
17122
  init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
15949
17123
  var import_node_child_process5 = require("node:child_process");
15950
17124
  var import_node_crypto7 = require("node:crypto");
15951
- var import_node_fs14 = __toESM(require("node:fs"), 1);
15952
- var import_node_path14 = __toESM(require("node:path"), 1);
15953
- var import_plist2 = __toESM(require("plist"), 1);
17125
+ var import_node_fs15 = __toESM(require("node:fs"), 1);
17126
+ var import_node_path15 = __toESM(require("node:path"), 1);
17127
+ var import_plist3 = __toESM(require("plist"), 1);
15954
17128
 
15955
17129
  // src/xcode-json-project.ts
15956
17130
  init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
15957
- var import_node_path13 = __toESM(require("node:path"), 1);
17131
+ var import_node_path14 = __toESM(require("node:path"), 1);
15958
17132
  var import_json52 = __toESM(require_lib(), 1);
15959
17133
  var isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
15960
17134
  var text = (value) => typeof value === "string" ? value : void 0;
@@ -15970,7 +17144,7 @@ var PHASE_ISA = {
15970
17144
  function readXcodeJsonProject(xcodeproj, source) {
15971
17145
  const json = import_json52.default.parse(source);
15972
17146
  if (!isJsonObject(json)) throw new Error(`${xcodeproj}/project.xcproj is not an object`);
15973
- const projectDir = import_node_path13.default.dirname(xcodeproj);
17147
+ const projectDir = import_node_path14.default.dirname(xcodeproj);
15974
17148
  const objects = {};
15975
17149
  let next = 0;
15976
17150
  const add = (entry, id) => {
@@ -15983,7 +17157,7 @@ function readXcodeJsonProject(xcodeproj, source) {
15983
17157
  const base = /^<([A-Z]+)>\/(.*)$/.exec(raw);
15984
17158
  if (base) {
15985
17159
  if (base[1] === "PROJECT")
15986
- return { sourceTree: "<absolute>", path: import_node_path13.default.join(projectDir, base[2]) };
17160
+ return { sourceTree: "<absolute>", path: import_node_path14.default.join(projectDir, base[2]) };
15987
17161
  if (base[1] === "PRODUCTS")
15988
17162
  return { sourceTree: "BUILT_PRODUCTS_DIR", path: base[2] };
15989
17163
  return null;
@@ -15991,7 +17165,7 @@ function readXcodeJsonProject(xcodeproj, source) {
15991
17165
  const unescaped = raw.replaceAll("\\<", "<");
15992
17166
  if (unescaped.startsWith("/")) return { sourceTree: "<absolute>", path: unescaped };
15993
17167
  if (unescaped.startsWith("~")) return null;
15994
- return groupDir === null ? null : { sourceTree: "<absolute>", path: import_node_path13.default.join(groupDir, unescaped) };
17168
+ return groupDir === null ? null : { sourceTree: "<absolute>", path: import_node_path14.default.join(groupDir, unescaped) };
15995
17169
  };
15996
17170
  const memberships = [];
15997
17171
  const folders = [];
@@ -16002,7 +17176,7 @@ function readXcodeJsonProject(xcodeproj, source) {
16002
17176
  const kind = text(entry.kind) ?? "file-reference";
16003
17177
  const raw = text(entry.path) ?? "";
16004
17178
  const located = raw === "" ? null : locate(raw, parent.dir);
16005
- const name2 = text(entry.name) ?? import_node_path13.default.basename(raw);
17179
+ const name2 = text(entry.name) ?? import_node_path14.default.basename(raw);
16006
17180
  const node = { id: "", name: name2, dir: null, parent, children: [] };
16007
17181
  if (kind === "group" || kind === "variant-group" || kind === "version-group") {
16008
17182
  node.dir = raw === "" ? parent.dir : located?.sourceTree === "<absolute>" ? located.path : null;
@@ -16117,7 +17291,7 @@ function readXcodeJsonProject(xcodeproj, source) {
16117
17291
  if (!isObject(entry)) continue;
16118
17292
  const repository = text(entry.repository);
16119
17293
  const local = text(entry.path);
16120
- 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$/, "");
17294
+ const name2 = local !== void 0 ? import_node_path14.default.basename(import_node_path14.default.resolve(import_node_path14.default.dirname(xcodeproj), local)) : import_node_path14.default.basename(repository ?? "").replace(/\.git$/, "");
16121
17295
  const id = text(entry.kind) === "local" && local !== void 0 ? add({ isa: "XCLocalSwiftPackageReference", relativePath: local }) : add({ isa: "XCRemoteSwiftPackageReference", repositoryURL: repository ?? "" });
16122
17296
  packageIds.set(name2.toLowerCase(), id);
16123
17297
  }
@@ -16305,28 +17479,28 @@ var CONDITIONS = {
16305
17479
  variant: "normal"
16306
17480
  };
16307
17481
  function walkFiles(dir) {
16308
- if (!import_node_fs14.default.existsSync(dir)) return [];
17482
+ if (!import_node_fs15.default.existsSync(dir)) return [];
16309
17483
  const out = [];
16310
- for (const entry of import_node_fs14.default.readdirSync(dir, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
17484
+ for (const entry of import_node_fs15.default.readdirSync(dir, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
16311
17485
  if (entry.name.startsWith(".")) continue;
16312
- const full = import_node_path14.default.join(dir, entry.name);
17486
+ const full = import_node_path15.default.join(dir, entry.name);
16313
17487
  if (entry.isDirectory()) out.push(...walkFiles(full));
16314
17488
  else if (entry.isFile()) out.push(full);
16315
17489
  }
16316
17490
  return out;
16317
17491
  }
16318
- var isDirectory = (dir) => import_node_fs14.default.existsSync(dir) && import_node_fs14.default.statSync(dir).isDirectory();
17492
+ var isDirectory = (dir) => import_node_fs15.default.existsSync(dir) && import_node_fs15.default.statSync(dir).isDirectory();
16319
17493
  function readXcconfig(file, read) {
16320
- if (read.includes(file) || !import_node_fs14.default.existsSync(file)) return {};
17494
+ if (read.includes(file) || !import_node_fs15.default.existsSync(file)) return {};
16321
17495
  read.push(file);
16322
17496
  const settings = {};
16323
- for (const raw of import_node_fs14.default.readFileSync(file, "utf8").split("\n")) {
17497
+ for (const raw of import_node_fs15.default.readFileSync(file, "utf8").split("\n")) {
16324
17498
  const line = raw.replace(/\/\/.*$/, "").trim();
16325
17499
  const include = /^#include\??\s+"([^"]+)"/.exec(line);
16326
17500
  if (include) {
16327
17501
  Object.assign(
16328
17502
  settings,
16329
- readXcconfig(import_node_path14.default.resolve(import_node_path14.default.dirname(file), include[1]), read)
17503
+ readXcconfig(import_node_path15.default.resolve(import_node_path15.default.dirname(file), include[1]), read)
16330
17504
  );
16331
17505
  continue;
16332
17506
  }
@@ -16376,22 +17550,22 @@ function decodeXml(text2) {
16376
17550
  return text2.replaceAll("&quot;", '"').replaceAll("&apos;", "'").replaceAll("&lt;", "<").replaceAll("&gt;", ">").replaceAll("&amp;", "&");
16377
17551
  }
16378
17552
  function workspaceReferences(workspace) {
16379
- const data = import_node_path14.default.join(workspace, "contents.xcworkspacedata");
16380
- if (!import_node_fs14.default.existsSync(data))
17553
+ const data = import_node_path15.default.join(workspace, "contents.xcworkspacedata");
17554
+ if (!import_node_fs15.default.existsSync(data))
16381
17555
  throw new Error(`${workspace} has no contents.xcworkspacedata`);
16382
- const container = import_node_path14.default.dirname(workspace);
17556
+ const container = import_node_path15.default.dirname(workspace);
16383
17557
  const locate = (location, base) => {
16384
17558
  const colon = location.indexOf(":");
16385
17559
  const kind = location.slice(0, colon);
16386
17560
  const rest = location.slice(colon + 1);
16387
- if (kind === "group") return import_node_path14.default.resolve(base, rest);
16388
- if (kind === "container" || kind === "self") return import_node_path14.default.resolve(container, rest);
16389
- if (kind === "absolute") return import_node_path14.default.resolve(rest);
16390
- throw new Error(`${import_node_path14.default.basename(workspace)} has an unsupported location ${location}`);
17561
+ if (kind === "group") return import_node_path15.default.resolve(base, rest);
17562
+ if (kind === "container" || kind === "self") return import_node_path15.default.resolve(container, rest);
17563
+ if (kind === "absolute") return import_node_path15.default.resolve(rest);
17564
+ throw new Error(`${import_node_path15.default.basename(workspace)} has an unsupported location ${location}`);
16391
17565
  };
16392
17566
  const groups = [container];
16393
17567
  const references = [];
16394
- for (const [, closing, tag, attributes, selfClosing] of import_node_fs14.default.readFileSync(data, "utf8").matchAll(/<(\/?)(Group|FileRef)\b([^>]*?)(\/?)>/g)) {
17568
+ for (const [, closing, tag, attributes, selfClosing] of import_node_fs15.default.readFileSync(data, "utf8").matchAll(/<(\/?)(Group|FileRef)\b([^>]*?)(\/?)>/g)) {
16395
17569
  if (closing) {
16396
17570
  if (tag === "Group") groups.pop();
16397
17571
  continue;
@@ -16407,8 +17581,8 @@ function workspaceReferences(workspace) {
16407
17581
  var loaded2 = /* @__PURE__ */ new Map();
16408
17582
  function xcodeProjectFile(xcodeproj) {
16409
17583
  for (const name2 of ["project.pbxproj", "project.xcproj"]) {
16410
- const file = import_node_path14.default.join(xcodeproj, name2);
16411
- if (import_node_fs14.default.existsSync(file)) return file;
17584
+ const file = import_node_path15.default.join(xcodeproj, name2);
17585
+ if (import_node_fs15.default.existsSync(file)) return file;
16412
17586
  }
16413
17587
  return null;
16414
17588
  }
@@ -16416,7 +17590,7 @@ function loadProject(xcodeproj) {
16416
17590
  const projectFile = xcodeProjectFile(xcodeproj);
16417
17591
  if (!projectFile)
16418
17592
  throw new Error(`${xcodeproj} has no project.pbxproj or project.xcproj`);
16419
- const source = import_node_fs14.default.readFileSync(projectFile, "utf8");
17593
+ const source = import_node_fs15.default.readFileSync(projectFile, "utf8");
16420
17594
  const digest = (0, import_node_crypto7.createHash)("sha256").update(source).digest("hex");
16421
17595
  const cached2 = loaded2.get(projectFile);
16422
17596
  if (cached2?.digest === digest) return cached2.project;
@@ -16433,10 +17607,10 @@ function loadProject(xcodeproj) {
16433
17607
  if (!project || project.isa !== "PBXProject") {
16434
17608
  throw new Error(`${projectFile} has no PBXProject root`);
16435
17609
  }
16436
- const projectDir = import_node_fs14.default.realpathSync(
16437
- import_node_path14.default.resolve(import_node_path14.default.dirname(xcodeproj), str(project.projectDirPath) ?? "")
17610
+ const projectDir = import_node_fs15.default.realpathSync(
17611
+ import_node_path15.default.resolve(import_node_path15.default.dirname(xcodeproj), str(project.projectDirPath) ?? "")
16438
17612
  );
16439
- const resolvePath = xcodePathResolver(objects, projectDir, import_node_path14.default.join);
17613
+ const resolvePath = xcodePathResolver(objects, projectDir, import_node_path15.default.join);
16440
17614
  const result = {
16441
17615
  xcodeproj,
16442
17616
  projectFile,
@@ -16470,8 +17644,8 @@ function targetSettings(ref, configuration, builtins, options = {}, overrides =
16470
17644
  const relative3 = str(config.baseConfigurationReferenceRelativePath);
16471
17645
  const own = isDict(config.buildSettings) ? config.buildSettings : {};
16472
17646
  const directory = anchor ? project.resolvePath(anchor) : null;
16473
- const baseFile = base ? project.resolvePath(base) : directory && relative3 ? import_node_path14.default.resolve(directory, relative3) : null;
16474
- if (options.requireSources !== false && (base || anchor || relative3) && (!baseFile || !import_node_fs14.default.existsSync(baseFile)))
17647
+ const baseFile = base ? project.resolvePath(base) : directory && relative3 ? import_node_path15.default.resolve(directory, relative3) : null;
17648
+ if (options.requireSources !== false && (base || anchor || relative3) && (!baseFile || !import_node_fs15.default.existsSync(baseFile)))
16475
17649
  throw new Error(
16476
17650
  `Unable to open base configuration reference file '${baseFile ?? base ?? relative3 ?? anchor}'`
16477
17651
  );
@@ -16547,26 +17721,26 @@ function settingList(value) {
16547
17721
  return items2;
16548
17722
  }
16549
17723
  function expandSearchPath(directory, rules) {
16550
- if (import_node_path14.default.basename(directory) !== "**") return [directory];
17724
+ if (import_node_path15.default.basename(directory) !== "**") return [directory];
16551
17725
  const expanded = [];
16552
17726
  const seen = /* @__PURE__ */ new Set();
16553
- const queue = [import_node_path14.default.dirname(directory)];
17727
+ const queue = [import_node_path15.default.dirname(directory)];
16554
17728
  for (let at = 0; at < queue.length; at++) {
16555
17729
  const current = queue[at];
16556
17730
  let real;
16557
17731
  try {
16558
- real = import_node_fs14.default.realpathSync(current);
17732
+ real = import_node_fs15.default.realpathSync(current);
16559
17733
  } catch {
16560
17734
  continue;
16561
17735
  }
16562
- if (!import_node_fs14.default.statSync(real).isDirectory() || seen.has(real)) continue;
17736
+ if (!import_node_fs15.default.statSync(real).isDirectory() || seen.has(real)) continue;
16563
17737
  seen.add(real);
16564
17738
  expanded.push(current);
16565
- 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)) {
17739
+ for (const entry of import_node_fs15.default.readdirSync(real, { withFileTypes: true }).sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0)) {
16566
17740
  if (entry.isSymbolicLink() ? !rules.followLinks : !entry.isDirectory()) continue;
16567
17741
  if (rules.excluded.some((pattern) => pattern.test(entry.name)) && !rules.included.some((pattern) => pattern.test(entry.name)))
16568
17742
  continue;
16569
- queue.push(import_node_path14.default.join(current, entry.name));
17743
+ queue.push(import_node_path15.default.join(current, entry.name));
16570
17744
  }
16571
17745
  }
16572
17746
  return expanded;
@@ -16620,7 +17794,7 @@ function targetMembers(ref, settings, options, settingKeys, projectInputs) {
16620
17794
  const phase = project.object(phaseId);
16621
17795
  if (phase?.isa !== "PBXShellScriptBuildPhase") continue;
16622
17796
  const script = str(phase.name) ?? phaseId;
16623
- const absolute = (raw) => import_node_path14.default.resolve(project.projectDir, expand(raw, settings));
17797
+ const absolute = (raw) => import_node_path15.default.resolve(project.projectDir, expand(raw, settings));
16624
17798
  const inputs = list(phase.inputPaths).map(absolute);
16625
17799
  const outputs = list(phase.outputPaths).map(absolute);
16626
17800
  const fileLists = /* @__PURE__ */ new Map();
@@ -16629,10 +17803,10 @@ function targetMembers(ref, settings, options, settingKeys, projectInputs) {
16629
17803
  kind === "INPUT" ? phase.inputFileListPaths : phase.outputFileListPaths
16630
17804
  ).map((raw) => {
16631
17805
  const file = absolute(raw);
16632
- if (!import_node_fs14.default.existsSync(file)) {
17806
+ if (!import_node_fs15.default.existsSync(file)) {
16633
17807
  return { file, entries: [] };
16634
17808
  }
16635
- const entries = import_node_fs14.default.readFileSync(file, "utf8").split(/\r?\n/).map((line) => line.trim()).filter((line) => line !== "" && !line.startsWith("#")).map(absolute);
17809
+ const entries = import_node_fs15.default.readFileSync(file, "utf8").split(/\r?\n/).map((line) => line.trim()).filter((line) => line !== "" && !line.startsWith("#")).map(absolute);
16636
17810
  return { file, entries };
16637
17811
  });
16638
17812
  fileLists.set(kind, lists);
@@ -16650,13 +17824,13 @@ function targetMembers(ref, settings, options, settingKeys, projectInputs) {
16650
17824
  ...fileLists.get("OUTPUT").map((item) => item.file)
16651
17825
  ];
16652
17826
  if (allOutputs.some((file) => file.endsWith(".swift"))) {
16653
- for (const file of inputFiles) if (import_node_fs14.default.existsSync(file)) projectInputs.add(file);
17827
+ for (const file of inputFiles) if (import_node_fs15.default.existsSync(file)) projectInputs.add(file);
16654
17828
  }
16655
17829
  if (options.prepareGeneratedSources && options.requireSources !== false && allOutputs.some((file) => file.endsWith(".swift"))) {
16656
- const phaseDir = import_node_path14.default.join(settings("TARGET_TEMP_DIR"), `Script-${phaseId}`);
17830
+ const phaseDir = import_node_path15.default.join(settings("TARGET_TEMP_DIR"), `Script-${phaseId}`);
16657
17831
  for (const lists of fileLists.values())
16658
17832
  for (const { file } of lists)
16659
- if (!import_node_fs14.default.existsSync(file))
17833
+ if (!import_node_fs15.default.existsSync(file))
16660
17834
  throw new Error(
16661
17835
  `${targetName}: Run Script "${script}" missing file list ${file}`
16662
17836
  );
@@ -16675,7 +17849,7 @@ function targetMembers(ref, settings, options, settingKeys, projectInputs) {
16675
17849
  const lists = fileLists.get(kind);
16676
17850
  env[`SCRIPT_${kind}_FILE_LIST_COUNT`] = String(lists.length);
16677
17851
  lists.forEach((_item, index) => {
16678
- env[`SCRIPT_${kind}_FILE_LIST_${index}`] = import_node_path14.default.join(
17852
+ env[`SCRIPT_${kind}_FILE_LIST_${index}`] = import_node_path15.default.join(
16679
17853
  phaseDir,
16680
17854
  `${kind}-${index}.xcfilelist`
16681
17855
  );
@@ -16686,21 +17860,21 @@ function targetMembers(ref, settings, options, settingKeys, projectInputs) {
16686
17860
  );
16687
17861
  for (const file of inputFiles) {
16688
17862
  signature.update(file);
16689
- if (import_node_fs14.default.existsSync(file)) {
16690
- const stat = import_node_fs14.default.statSync(file);
17863
+ if (import_node_fs15.default.existsSync(file)) {
17864
+ const stat = import_node_fs15.default.statSync(file);
16691
17865
  signature.update(`${stat.mtimeMs}:${stat.ctimeMs}:${stat.size}`);
16692
17866
  } else signature.update("missing");
16693
17867
  }
16694
17868
  const stamp = signature.digest("hex");
16695
17869
  const key = `${project.projectFile}:${targetId}:${phaseId}:${settings("CONFIGURATION")}`;
16696
- if (preparedSourcePhases.get(key) === stamp && allOutputs.every((file) => import_node_fs14.default.existsSync(file)))
17870
+ if (preparedSourcePhases.get(key) === stamp && allOutputs.every((file) => import_node_fs15.default.existsSync(file)))
16697
17871
  continue;
16698
- import_node_fs14.default.mkdirSync(phaseDir, { recursive: true });
16699
- import_node_fs14.default.mkdirSync(settings("BUILT_PRODUCTS_DIR"), { recursive: true });
16700
- import_node_fs14.default.mkdirSync(settings("DERIVED_FILE_DIR"), { recursive: true });
17872
+ import_node_fs15.default.mkdirSync(phaseDir, { recursive: true });
17873
+ import_node_fs15.default.mkdirSync(settings("BUILT_PRODUCTS_DIR"), { recursive: true });
17874
+ import_node_fs15.default.mkdirSync(settings("DERIVED_FILE_DIR"), { recursive: true });
16701
17875
  for (const [kind, lists] of fileLists)
16702
17876
  lists.forEach((item, index) => {
16703
- import_node_fs14.default.writeFileSync(
17877
+ import_node_fs15.default.writeFileSync(
16704
17878
  env[`SCRIPT_${kind}_FILE_LIST_${index}`],
16705
17879
  `${item.entries.join("\n")}
16706
17880
  `
@@ -16726,7 +17900,7 @@ ${output}`
16726
17900
  );
16727
17901
  }
16728
17902
  const missing = allOutputs.filter(
16729
- (file) => file.endsWith(".swift") && !import_node_fs14.default.existsSync(file)
17903
+ (file) => file.endsWith(".swift") && !import_node_fs15.default.existsSync(file)
16730
17904
  );
16731
17905
  if (missing.length > 0)
16732
17906
  throw new Error(
@@ -16739,8 +17913,8 @@ ${output}`
16739
17913
  project.objects,
16740
17914
  targetId,
16741
17915
  project.resolvePath,
16742
- (file) => isDirectory(file) ? walkFiles(file) : import_node_fs14.default.existsSync(file) ? [file] : [],
16743
- import_node_path14.default.join,
17916
+ (file) => isDirectory(file) ? walkFiles(file) : import_node_fs15.default.existsSync(file) ? [file] : [],
17917
+ import_node_path15.default.join,
16744
17918
  (file, kind) => {
16745
17919
  if (kind === "header") {
16746
17920
  headers.add(file);
@@ -16750,9 +17924,9 @@ ${output}`
16750
17924
  resources.add(file);
16751
17925
  return;
16752
17926
  }
16753
- if (!import_node_fs14.default.existsSync(file)) {
17927
+ if (!import_node_fs15.default.existsSync(file)) {
16754
17928
  if (options.requireSources === false) return;
16755
- const script = scriptForOutput.get(import_node_path14.default.normalize(file));
17929
+ const script = scriptForOutput.get(import_node_path15.default.normalize(file));
16756
17930
  throw new Error(
16757
17931
  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}`
16758
17932
  );
@@ -16763,7 +17937,7 @@ ${output}`
16763
17937
  );
16764
17938
  for (const [file, script] of scriptForOutput) {
16765
17939
  if (sources.has(file) || allSources.has(file)) continue;
16766
- if (!import_node_fs14.default.existsSync(file)) {
17940
+ if (!import_node_fs15.default.existsSync(file)) {
16767
17941
  if (options.requireSources === false) continue;
16768
17942
  throw new Error(
16769
17943
  `${targetName}: missing generated source ${file} (Run Script "${script}" declares it in outputPaths; run the script or check in its output)`
@@ -16782,37 +17956,37 @@ ${output}`
16782
17956
  function commonAncestor(dirs) {
16783
17957
  let common = dirs[0];
16784
17958
  for (const dir of dirs) {
16785
- while (common !== import_node_path14.default.dirname(common) && import_node_path14.default.relative(common, dir).startsWith(".."))
16786
- common = import_node_path14.default.dirname(common);
17959
+ while (common !== import_node_path15.default.dirname(common) && import_node_path15.default.relative(common, dir).startsWith(".."))
17960
+ common = import_node_path15.default.dirname(common);
16787
17961
  }
16788
17962
  return common;
16789
17963
  }
16790
- var isPodsProject = (xcodeproj) => import_node_path14.default.basename(xcodeproj) === "Pods.xcodeproj" && import_node_path14.default.basename(import_node_path14.default.dirname(xcodeproj)) === "Pods";
17964
+ var isPodsProject = (xcodeproj) => import_node_path15.default.basename(xcodeproj) === "Pods.xcodeproj" && import_node_path15.default.basename(import_node_path15.default.dirname(xcodeproj)) === "Pods";
16791
17965
  function installedPodsSandbox(pods) {
16792
- const podfileLock = import_node_path14.default.join(import_node_path14.default.dirname(pods), "Podfile.lock");
16793
- const manifestLock = import_node_path14.default.join(pods, "Manifest.lock");
16794
- if (!import_node_fs14.default.existsSync(podfileLock))
17966
+ const podfileLock = import_node_path15.default.join(import_node_path15.default.dirname(pods), "Podfile.lock");
17967
+ const manifestLock = import_node_path15.default.join(pods, "Manifest.lock");
17968
+ if (!import_node_fs15.default.existsSync(podfileLock))
16795
17969
  throw new Error(
16796
- `${pods} has no ${podfileLock}: run \`pod install\` in ${import_node_path14.default.dirname(pods)}`
17970
+ `${pods} has no ${podfileLock}: run \`pod install\` in ${import_node_path15.default.dirname(pods)}`
16797
17971
  );
16798
- if (!import_node_fs14.default.existsSync(manifestLock) || !import_node_fs14.default.readFileSync(manifestLock).equals(import_node_fs14.default.readFileSync(podfileLock)))
17972
+ if (!import_node_fs15.default.existsSync(manifestLock) || !import_node_fs15.default.readFileSync(manifestLock).equals(import_node_fs15.default.readFileSync(podfileLock)))
16799
17973
  throw new Error(
16800
- `The sandbox is not in sync with the Podfile.lock: ${manifestLock} differs from ${podfileLock}. Run \`pod install\` in ${import_node_path14.default.dirname(pods)}`
17974
+ `The sandbox is not in sync with the Podfile.lock: ${manifestLock} differs from ${podfileLock}. Run \`pod install\` in ${import_node_path15.default.dirname(pods)}`
16801
17975
  );
16802
17976
  const specChecksums = {};
16803
- const lines = import_node_fs14.default.readFileSync(manifestLock, "utf8").split("\n");
17977
+ const lines = import_node_fs15.default.readFileSync(manifestLock, "utf8").split("\n");
16804
17978
  const start = lines.indexOf("SPEC CHECKSUMS:");
16805
17979
  for (const line of start === -1 ? [] : lines.slice(start + 1)) {
16806
17980
  const entry = /^ {2}"?([^":]+)"?: ([0-9a-f]+)$/.exec(line);
16807
17981
  if (!entry) break;
16808
17982
  specChecksums[entry[1]] = entry[2];
16809
17983
  }
16810
- const specs = import_node_path14.default.join(pods, "Local Podspecs");
17984
+ const specs = import_node_path15.default.join(pods, "Local Podspecs");
16811
17985
  return {
16812
17986
  podfileLock,
16813
17987
  manifestLock,
16814
17988
  specChecksums,
16815
- localPodspecs: isDirectory(specs) ? import_node_fs14.default.readdirSync(specs).filter((name2) => name2.endsWith(".podspec.json")).sort().map((name2) => import_node_path14.default.join(specs, name2)) : []
17989
+ localPodspecs: isDirectory(specs) ? import_node_fs15.default.readdirSync(specs).filter((name2) => name2.endsWith(".podspec.json")).sort().map((name2) => import_node_path15.default.join(specs, name2)) : []
16816
17990
  };
16817
17991
  }
16818
17992
  function workspaceProjects(xcodeprojOrWorkspace, installedPods = false) {
@@ -16824,14 +17998,14 @@ function workspaceProjects(xcodeprojOrWorkspace, installedPods = false) {
16824
17998
  if (!xcodeProjectFile(xcodeproj)) {
16825
17999
  if (installedPods && isPodsProject(xcodeproj))
16826
18000
  throw new Error(
16827
- `${import_node_path14.default.basename(xcodeprojOrWorkspace)} builds ${xcodeproj}, which is not installed: run \`pod install\` in ${import_node_path14.default.dirname(import_node_path14.default.dirname(xcodeproj))}`
18001
+ `${import_node_path15.default.basename(xcodeprojOrWorkspace)} builds ${xcodeproj}, which is not installed: run \`pod install\` in ${import_node_path15.default.dirname(import_node_path15.default.dirname(xcodeproj))}`
16828
18002
  );
16829
18003
  return;
16830
18004
  }
16831
- const key = import_node_fs14.default.realpathSync(xcodeproj);
16832
- if (projectAt.has(key) || !installedPods && key.split(import_node_path14.default.sep).includes("Pods"))
18005
+ const key = import_node_fs15.default.realpathSync(xcodeproj);
18006
+ if (projectAt.has(key) || !installedPods && key.split(import_node_path15.default.sep).includes("Pods"))
16833
18007
  return;
16834
- if (isPodsProject(key)) cocoapods = installedPodsSandbox(import_node_path14.default.dirname(key));
18008
+ if (isPodsProject(key)) cocoapods = installedPodsSandbox(import_node_path15.default.dirname(key));
16835
18009
  const project = loadProject(key);
16836
18010
  projectAt.set(key, project);
16837
18011
  projects.push(project);
@@ -16847,12 +18021,12 @@ function workspaceProjects(xcodeprojOrWorkspace, installedPods = false) {
16847
18021
  for (const reference of listed)
16848
18022
  if (reference.endsWith(".xcodeproj")) addProject(reference);
16849
18023
  if (projects.length === 0) {
16850
- throw new Error(`${import_node_path14.default.basename(xcodeprojOrWorkspace)} lists no Xcode project`);
18024
+ throw new Error(`${import_node_path15.default.basename(xcodeprojOrWorkspace)} lists no Xcode project`);
16851
18025
  }
16852
- const podfile = import_node_path14.default.join(import_node_path14.default.dirname(xcodeprojOrWorkspace), "Podfile");
16853
- if (installedPods && !cocoapods && import_node_fs14.default.existsSync(podfile))
18026
+ const podfile = import_node_path15.default.join(import_node_path15.default.dirname(xcodeprojOrWorkspace), "Podfile");
18027
+ if (installedPods && !cocoapods && import_node_fs15.default.existsSync(podfile))
16854
18028
  throw new Error(
16855
- `${podfile} is not installed into ${import_node_path14.default.basename(xcodeprojOrWorkspace)}: run \`pod install\` in ${import_node_path14.default.dirname(podfile)} and open the workspace it writes`
18029
+ `${podfile} is not installed into ${import_node_path15.default.basename(xcodeprojOrWorkspace)}: run \`pod install\` in ${import_node_path15.default.dirname(podfile)} and open the workspace it writes`
16856
18030
  );
16857
18031
  return { listed, projects, projectAt, cocoapods };
16858
18032
  }
@@ -16888,7 +18062,7 @@ function listXcodeAppTargets(xcodeprojOrWorkspace, options = {}) {
16888
18062
  return workspaceProjects(xcodeprojOrWorkspace).projects.flatMap(nativeTargets).filter((ref) => isIosAppTarget(ref, options)).map((ref) => str(ref.target.name) ?? ref.id);
16889
18063
  }
16890
18064
  function readXcodeAppTarget(input, targetName, configurationName, options = {}) {
16891
- const xcodeprojOrWorkspace = import_node_fs14.default.realpathSync(input);
18065
+ const xcodeprojOrWorkspace = import_node_fs15.default.realpathSync(input);
16892
18066
  const workspace = xcodeprojOrWorkspace.endsWith(".xcworkspace") ? xcodeprojOrWorkspace : null;
16893
18067
  const { listed, projects, projectAt, cocoapods } = workspaceProjects(
16894
18068
  xcodeprojOrWorkspace,
@@ -16897,7 +18071,7 @@ function readXcodeAppTarget(input, targetName, configurationName, options = {})
16897
18071
  const allTargets = projects.flatMap(nativeTargets);
16898
18072
  const appTargets = allTargets.filter((ref) => isIosAppTarget(ref, options));
16899
18073
  const appTargetNames = appTargets.map((ref) => str(ref.target.name) ?? ref.id);
16900
- const container = import_node_path14.default.basename(xcodeprojOrWorkspace);
18074
+ const container = import_node_path15.default.basename(xcodeprojOrWorkspace);
16901
18075
  const named = targetName ? appTargets.filter((ref) => ref.target.name === targetName) : appTargets;
16902
18076
  if (named.length !== 1) {
16903
18077
  throw new Error(
@@ -16910,15 +18084,15 @@ function readXcodeAppTarget(input, targetName, configurationName, options = {})
16910
18084
  for (const ref of allTargets) {
16911
18085
  const product = ref.project.object(str(ref.target.productReference));
16912
18086
  const file = str(product?.path);
16913
- if (file && !byProduct.has(import_node_path14.default.basename(file)))
16914
- byProduct.set(import_node_path14.default.basename(file), ref);
18087
+ if (file && !byProduct.has(import_node_path15.default.basename(file)))
18088
+ byProduct.set(import_node_path15.default.basename(file), ref);
16915
18089
  }
16916
18090
  const proxied = (project, proxyId) => {
16917
18091
  const proxy = project.object(proxyId);
16918
18092
  if (proxy?.isa !== "PBXContainerItemProxy") return void 0;
16919
18093
  const portal = str(proxy.containerPortal);
16920
18094
  const portalPath = project.resolvePath(portal ?? "");
16921
- 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;
18095
+ const owner = project.object(portal)?.isa === "PBXProject" ? project : portalPath && import_node_fs15.default.existsSync(portalPath) ? projectAt.get(import_node_fs15.default.realpathSync(portalPath)) : void 0;
16922
18096
  const remote = str(proxy.remoteGlobalIDString);
16923
18097
  if (!owner || !remote) return void 0;
16924
18098
  return nativeTargets(owner).find(
@@ -16939,7 +18113,7 @@ function readXcodeAppTarget(input, targetName, configurationName, options = {})
16939
18113
  if (phase?.isa !== "PBXFrameworksBuildPhase") continue;
16940
18114
  for (const buildFileId of list(phase.files)) {
16941
18115
  const file = project.object(str(project.object(buildFileId)?.fileRef));
16942
- 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;
18116
+ const resolved = file?.isa === "PBXReferenceProxy" ? proxied(project, str(file.remoteRef)) : file && str(file.sourceTree) === "BUILT_PRODUCTS_DIR" ? byProduct.get(import_node_path15.default.basename(str(file.path) ?? "")) : void 0;
16943
18117
  if (resolved) found.push(resolved);
16944
18118
  }
16945
18119
  }
@@ -16987,7 +18161,7 @@ function readXcodeAppTarget(input, targetName, configurationName, options = {})
16987
18161
  const framework = FRAMEWORK_PRODUCTS.has(str(ref.target.productType) ?? "");
16988
18162
  const product = framework ? productName(ref) : "";
16989
18163
  for (const { file, visibility } of headerPhase(ref)) {
16990
- const name2 = import_node_path14.default.basename(file);
18164
+ const name2 = import_node_path15.default.basename(file);
16991
18165
  if (!entries.has(name2))
16992
18166
  entries.set(
16993
18167
  name2,
@@ -16998,18 +18172,18 @@ function readXcodeAppTarget(input, targetName, configurationName, options = {})
16998
18172
  for (const id of Object.keys(project.objects)) {
16999
18173
  if (project.object(id)?.isa !== "PBXFileReference") continue;
17000
18174
  const file = project.resolvePath(id);
17001
- if (file && HEADER_FILE.test(file) && !entries.has(import_node_path14.default.basename(file)))
17002
- entries.set(import_node_path14.default.basename(file), file);
18175
+ if (file && HEADER_FILE.test(file) && !entries.has(import_node_path15.default.basename(file)))
18176
+ entries.set(import_node_path15.default.basename(file), file);
17003
18177
  }
17004
18178
  const map2 = [...entries];
17005
18179
  projectHeaderMaps.set(project, map2);
17006
18180
  return map2;
17007
18181
  };
17008
18182
  const xcconfigs = /* @__PURE__ */ new Set();
17009
- const buildDir = (project) => import_node_path14.default.join(project.projectDir, ".build/peach-xcode/Build");
18183
+ const buildDir = (project) => import_node_path15.default.join(project.projectDir, ".build/peach-xcode/Build");
17010
18184
  const podsBuild = {
17011
- SYMROOT: import_node_path14.default.join(buildDir(app.project), "Products"),
17012
- OBJROOT: import_node_path14.default.join(buildDir(app.project), "Intermediates.noindex")
18185
+ SYMROOT: import_node_path15.default.join(buildDir(app.project), "Products"),
18186
+ OBJROOT: import_node_path15.default.join(buildDir(app.project), "Intermediates.noindex")
17013
18187
  };
17014
18188
  const moduleTarget = (ref) => {
17015
18189
  const name2 = str(ref.target.name) ?? ref.id;
@@ -17022,13 +18196,13 @@ function readXcodeAppTarget(input, targetName, configurationName, options = {})
17022
18196
  configuration,
17023
18197
  {
17024
18198
  TARGET_NAME: name2,
17025
- PROJECT_NAME: import_node_path14.default.basename(ref.project.xcodeproj, ".xcodeproj"),
18199
+ PROJECT_NAME: import_node_path15.default.basename(ref.project.xcodeproj, ".xcodeproj"),
17026
18200
  SRCROOT: ref.project.projectDir,
17027
18201
  SOURCE_ROOT: ref.project.projectDir,
17028
18202
  PROJECT_DIR: ref.project.projectDir,
17029
- SYMROOT: import_node_path14.default.join(buildDir(ref.project), "Products"),
18203
+ SYMROOT: import_node_path15.default.join(buildDir(ref.project), "Products"),
17030
18204
  BUILD_DIR: "$(SYMROOT)",
17031
- OBJROOT: import_node_path14.default.join(buildDir(ref.project), "Intermediates.noindex"),
18205
+ OBJROOT: import_node_path15.default.join(buildDir(ref.project), "Intermediates.noindex"),
17032
18206
  CONFIGURATION_BUILD_DIR: "$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)",
17033
18207
  BUILT_PRODUCTS_DIR: "$(CONFIGURATION_BUILD_DIR)",
17034
18208
  TARGET_BUILD_DIR: "$(CONFIGURATION_BUILD_DIR)",
@@ -17057,11 +18231,11 @@ function readXcodeAppTarget(input, targetName, configurationName, options = {})
17057
18231
  xcconfigs
17058
18232
  );
17059
18233
  const searchRules = recursiveSearchRules(settings2);
17060
- const absolute = (file) => import_node_path14.default.resolve(ref.project.projectDir, file);
18234
+ const absolute = (file) => import_node_path15.default.resolve(ref.project.projectDir, file);
17061
18235
  const framework = FRAMEWORK_PRODUCTS.has(str(ref.target.productType) ?? "");
17062
18236
  const product = settings2("PRODUCT_NAME");
17063
18237
  const building = options.prepareGeneratedSources && options.requireSources !== false;
17064
- const versioning = building && allSources.length > 0 && settings2("VERSIONING_SYSTEM") === "apple-generic" ? import_node_path14.default.join(settings2("DERIVED_FILE_DIR"), `${product}_vers.c`) : null;
18238
+ const versioning = building && allSources.length > 0 && settings2("VERSIONING_SYSTEM") === "apple-generic" ? import_node_path15.default.join(settings2("DERIVED_FILE_DIR"), `${product}_vers.c`) : null;
17065
18239
  if (versioning) {
17066
18240
  const version = settings2("CURRENT_PROJECT_VERSION");
17067
18241
  const custom = [
@@ -17074,7 +18248,7 @@ function readXcodeAppTarget(input, targetName, configurationName, options = {})
17074
18248
  ].filter((key) => settings2(key));
17075
18249
  if (!/^\d+$/.test(version) || !/^[A-Za-z_]\w*$/.test(product) || custom.length)
17076
18250
  throw new Error(
17077
- `${name2}: Xcode generates ${import_node_path14.default.basename(versioning)} for VERSIONING_SYSTEM=apple-generic; peach writes it only for an integer CURRENT_PROJECT_VERSION (${JSON.stringify(version)}), an identifier PRODUCT_NAME (${JSON.stringify(product)}) and no ${custom.length ? custom.join(", ") : "VERSION_INFO_* override"}`
18251
+ `${name2}: Xcode generates ${import_node_path15.default.basename(versioning)} for VERSIONING_SYSTEM=apple-generic; peach writes it only for an integer CURRENT_PROJECT_VERSION (${JSON.stringify(version)}), an identifier PRODUCT_NAME (${JSON.stringify(product)}) and no ${custom.length ? custom.join(", ") : "VERSION_INFO_* override"}`
17078
18252
  );
17079
18253
  const unit = [
17080
18254
  ` extern const unsigned char ${product}VersionString[];`,
@@ -17084,9 +18258,9 @@ function readXcodeAppTarget(input, targetName, configurationName, options = {})
17084
18258
  ` const double ${product}VersionNumber __attribute__ ((used)) = (double)${version}.;`,
17085
18259
  ""
17086
18260
  ].join("\n");
17087
- if (!import_node_fs14.default.existsSync(versioning) || import_node_fs14.default.readFileSync(versioning, "utf8") !== unit) {
17088
- import_node_fs14.default.mkdirSync(import_node_path14.default.dirname(versioning), { recursive: true });
17089
- import_node_fs14.default.writeFileSync(versioning, unit);
18261
+ if (!import_node_fs15.default.existsSync(versioning) || import_node_fs15.default.readFileSync(versioning, "utf8") !== unit) {
18262
+ import_node_fs15.default.mkdirSync(import_node_path15.default.dirname(versioning), { recursive: true });
18263
+ import_node_fs15.default.writeFileSync(versioning, unit);
17090
18264
  }
17091
18265
  allSources.push(versioning);
17092
18266
  }
@@ -17118,14 +18292,14 @@ function readXcodeAppTarget(input, targetName, configurationName, options = {})
17118
18292
  const headerFiles = headerPhase(ref);
17119
18293
  const ownHeaders = /* @__PURE__ */ new Map();
17120
18294
  for (const { file, visibility } of headerFiles) {
17121
- const name3 = import_node_path14.default.basename(file);
18295
+ const name3 = import_node_path15.default.basename(file);
17122
18296
  const published = framework && visibility !== "Project";
17123
18297
  if (!ownHeaders.has(name3))
17124
18298
  ownHeaders.set(name3, published ? `${product}/${name3}` : file);
17125
18299
  if (framework && !published && !ownHeaders.has(`${product}/${name3}`))
17126
18300
  ownHeaders.set(`${product}/${name3}`, file);
17127
18301
  }
17128
- const wrapper = import_node_path14.default.join(settings2("BUILT_PRODUCTS_DIR"), `${product}.framework`);
18302
+ const wrapper = import_node_path15.default.join(settings2("BUILT_PRODUCTS_DIR"), `${product}.framework`);
17129
18303
  const moduleMap = settings2("DEFINES_MODULE") === "YES" && settings2("MODULEMAP_FILE") ? absolute(settings2("MODULEMAP_FILE")) : null;
17130
18304
  const fileFlags = {};
17131
18305
  for (const phaseId of list(ref.target.buildPhases)) {
@@ -17165,7 +18339,7 @@ function readXcodeAppTarget(input, targetName, configurationName, options = {})
17165
18339
  ...headers,
17166
18340
  ...Object.keys(ref.project.objects).flatMap((id) => {
17167
18341
  const file = ref.project.resolvePath(id);
17168
- return file && HEADER_FILE.test(file) && import_node_fs14.default.existsSync(file) ? [file] : [];
18342
+ return file && HEADER_FILE.test(file) && import_node_fs15.default.existsSync(file) ? [file] : [];
17169
18343
  })
17170
18344
  ])
17171
18345
  ],
@@ -17174,15 +18348,15 @@ function readXcodeAppTarget(input, targetName, configurationName, options = {})
17174
18348
  // xcode searches its products' include directory before
17175
18349
  // HEADER_SEARCH_PATHS and the target's derived sources after.
17176
18350
  headerSearchPaths: [
17177
- import_node_path14.default.join(settings2("BUILT_PRODUCTS_DIR"), "include"),
18351
+ import_node_path15.default.join(settings2("BUILT_PRODUCTS_DIR"), "include"),
17178
18352
  ...settingList(settings2("HEADER_SEARCH_PATHS")).flatMap(
17179
18353
  (raw) => expandSearchPath(absolute(raw), searchRules)
17180
18354
  ),
17181
- import_node_path14.default.join(
18355
+ import_node_path15.default.join(
17182
18356
  `${settings2("DERIVED_FILE_DIR")}-normal`,
17183
18357
  settings2("CURRENT_ARCH")
17184
18358
  ),
17185
- import_node_path14.default.join(settings2("DERIVED_FILE_DIR"), settings2("CURRENT_ARCH")),
18359
+ import_node_path15.default.join(settings2("DERIVED_FILE_DIR"), settings2("CURRENT_ARCH")),
17186
18360
  settings2("DERIVED_FILE_DIR")
17187
18361
  ],
17188
18362
  userHeaderSearchPaths: settingList(
@@ -17221,16 +18395,16 @@ function readXcodeAppTarget(input, targetName, configurationName, options = {})
17221
18395
  ...headerFiles.flatMap(
17222
18396
  ({ file, visibility }) => visibility === "Project" ? [] : [
17223
18397
  [
17224
- import_node_path14.default.join(
18398
+ import_node_path15.default.join(
17225
18399
  wrapper,
17226
18400
  visibility === "Public" ? "Headers" : "PrivateHeaders",
17227
- import_node_path14.default.basename(file)
18401
+ import_node_path15.default.basename(file)
17228
18402
  ),
17229
18403
  file
17230
18404
  ]
17231
18405
  ]
17232
18406
  ),
17233
- ...moduleMap ? [[import_node_path14.default.join(wrapper, "Modules", "module.modulemap"), moduleMap]] : []
18407
+ ...moduleMap ? [[import_node_path15.default.join(wrapper, "Modules", "module.modulemap"), moduleMap]] : []
17234
18408
  ]) : {}
17235
18409
  }
17236
18410
  } : {}
@@ -17241,7 +18415,7 @@ function readXcodeAppTarget(input, targetName, configurationName, options = {})
17241
18415
  const frameworkTargets = order.slice(0, -1).map((ref) => ({ ref, framework: moduleTarget(ref).module }));
17242
18416
  const frameworks = frameworkTargets.map(({ framework }) => framework);
17243
18417
  const podSourceDirs = frameworkTargets.flatMap(
17244
- ({ ref, framework }) => isPodsProject(ref.project.xcodeproj) ? [...framework.allSources, ...framework.objc?.headers ?? []].map((file) => import_node_path14.default.dirname(file)).filter((dir) => import_node_fs14.default.existsSync(dir)) : []
18418
+ ({ ref, framework }) => isPodsProject(ref.project.xcodeproj) ? [...framework.allSources, ...framework.objc?.headers ?? []].map((file) => import_node_path15.default.dirname(file)).filter((dir) => import_node_fs15.default.existsSync(dir)) : []
17245
18419
  );
17246
18420
  const expandValue = (value) => {
17247
18421
  if (typeof value === "string") return expand(value, settings);
@@ -17253,8 +18427,8 @@ function readXcodeAppTarget(input, targetName, configurationName, options = {})
17253
18427
  }
17254
18428
  return value;
17255
18429
  };
17256
- const infoPlistFile = settings("INFOPLIST_FILE") ? import_node_path14.default.resolve(app.project.projectDir, settings("INFOPLIST_FILE")) : null;
17257
- const sourceInfo = infoPlistFile ? import_plist2.default.parse(import_node_fs14.default.readFileSync(infoPlistFile, "utf8")) : {};
18430
+ const infoPlistFile = settings("INFOPLIST_FILE") ? import_node_path15.default.resolve(app.project.projectDir, settings("INFOPLIST_FILE")) : null;
18431
+ const sourceInfo = infoPlistFile ? import_plist3.default.parse(import_node_fs15.default.readFileSync(infoPlistFile, "utf8")) : {};
17258
18432
  if (!sourceInfo || typeof sourceInfo !== "object" || Array.isArray(sourceInfo) || sourceInfo instanceof Date || Buffer.isBuffer(sourceInfo)) {
17259
18433
  throw new Error(`${module2.name} Info.plist must contain a dictionary`);
17260
18434
  }
@@ -17282,7 +18456,7 @@ function readXcodeAppTarget(input, targetName, configurationName, options = {})
17282
18456
  };
17283
18457
  }
17284
18458
  const localPackageDirs = [
17285
- ...listed.filter((reference) => import_node_fs14.default.existsSync(import_node_path14.default.join(reference, "Package.swift"))),
18459
+ ...listed.filter((reference) => import_node_fs15.default.existsSync(import_node_path15.default.join(reference, "Package.swift"))),
17286
18460
  ...projects.flatMap(
17287
18461
  (project) => Object.entries(project.objects).flatMap(([id, entry]) => {
17288
18462
  if (!isDict(entry)) return [];
@@ -17292,23 +18466,37 @@ function readXcodeAppTarget(input, targetName, configurationName, options = {})
17292
18466
  const packages = [];
17293
18467
  while (pending.length > 0) {
17294
18468
  const dir = pending.pop();
17295
- if (import_node_fs14.default.existsSync(import_node_path14.default.join(dir, "Package.swift"))) {
18469
+ if (import_node_fs15.default.existsSync(import_node_path15.default.join(dir, "Package.swift"))) {
17296
18470
  packages.push(dir);
17297
18471
  continue;
17298
18472
  }
17299
18473
  if (!isDirectory(dir)) continue;
17300
- for (const child of import_node_fs14.default.readdirSync(dir, { withFileTypes: true }))
18474
+ for (const child of import_node_fs15.default.readdirSync(dir, { withFileTypes: true }))
17301
18475
  if (child.isDirectory() && !child.name.startsWith("."))
17302
- pending.push(import_node_path14.default.join(dir, child.name));
18476
+ pending.push(import_node_path15.default.join(dir, child.name));
17303
18477
  }
17304
18478
  return packages;
17305
18479
  }
17306
- const candidate = entry.isa === "XCLocalSwiftPackageReference" ? import_node_path14.default.resolve(project.projectDir, str(entry.relativePath) ?? "") : entry.isa === "PBXFileReference" ? project.resolvePath(id) : null;
17307
- return candidate && import_node_fs14.default.existsSync(import_node_path14.default.join(candidate, "Package.swift")) ? [candidate] : [];
18480
+ const candidate = entry.isa === "XCLocalSwiftPackageReference" ? import_node_path15.default.resolve(project.projectDir, str(entry.relativePath) ?? "") : entry.isa === "PBXFileReference" ? project.resolvePath(id) : null;
18481
+ return candidate && import_node_fs15.default.existsSync(import_node_path15.default.join(candidate, "Package.swift")) ? [candidate] : [];
17308
18482
  })
17309
18483
  )
17310
18484
  ];
18485
+ const remotePackageUrls = [
18486
+ ...new Set(
18487
+ projects.flatMap(
18488
+ (project) => list(project.project.packageReferences).flatMap((id) => {
18489
+ const reference = project.object(id);
18490
+ const url = str(reference?.repositoryURL);
18491
+ return reference?.isa === "XCRemoteSwiftPackageReference" && url ? [url] : [];
18492
+ })
18493
+ )
18494
+ )
18495
+ ];
17311
18496
  const linkedProducts = [];
18497
+ const productReferences = [];
18498
+ const qualifiedProductKeys = /* @__PURE__ */ new Set();
18499
+ const linkedProductKeys = /* @__PURE__ */ new Set();
17312
18500
  const binaryFrameworks = /* @__PURE__ */ new Map();
17313
18501
  for (const { project, target } of order) {
17314
18502
  const productDependencies = [
@@ -17321,19 +18509,21 @@ function readXcodeAppTarget(input, targetName, configurationName, options = {})
17321
18509
  for (const dependencyId of productDependencies) {
17322
18510
  const dependency = project.object(dependencyId);
17323
18511
  const product = str(dependency?.productName)?.replace(/^plugin:/, "");
17324
- if (!dependency || !product || linkedProducts.some((entry) => entry.product === product))
17325
- continue;
18512
+ if (!dependency || !product) continue;
17326
18513
  const reference = project.object(str(dependency.package));
17327
- linkedProducts.push({
18514
+ const linked = {
17328
18515
  product,
17329
18516
  source: reference?.isa === "XCRemoteSwiftPackageReference" ? { kind: "remote", url: str(reference.repositoryURL) ?? "" } : reference?.isa === "XCLocalSwiftPackageReference" ? {
17330
18517
  kind: "local",
17331
- dir: import_node_path14.default.resolve(
18518
+ dir: import_node_path15.default.resolve(
17332
18519
  project.projectDir,
17333
18520
  str(reference.relativePath) ?? ""
17334
18521
  )
17335
- } : { kind: "unnamed" }
17336
- });
18522
+ } : { kind: "unnamed", remoteUrls: remotePackageUrls }
18523
+ };
18524
+ productReferences.push({ project: project.projectFile, linked });
18525
+ if (linked.source.kind !== "unnamed")
18526
+ qualifiedProductKeys.add(`${project.projectFile}\0${product}`);
17337
18527
  }
17338
18528
  for (const phaseId of list(target.buildPhases)) {
17339
18529
  const phase = project.object(phaseId);
@@ -17351,26 +18541,34 @@ function readXcodeAppTarget(input, targetName, configurationName, options = {})
17351
18541
  }
17352
18542
  }
17353
18543
  }
17354
- const resolvedFile = import_node_path14.default.join(
17355
- workspace ?? import_node_path14.default.join(xcodeprojOrWorkspace, "project.xcworkspace"),
18544
+ for (const { project, linked } of productReferences) {
18545
+ if (linked.source.kind === "unnamed" && qualifiedProductKeys.has(`${project}\0${linked.product}`))
18546
+ continue;
18547
+ const key = JSON.stringify(linked);
18548
+ if (linkedProductKeys.has(key)) continue;
18549
+ linkedProductKeys.add(key);
18550
+ linkedProducts.push(linked);
18551
+ }
18552
+ const resolvedFile = import_node_path15.default.join(
18553
+ workspace ?? import_node_path15.default.join(xcodeprojOrWorkspace, "project.xcworkspace"),
17356
18554
  "xcshareddata",
17357
18555
  "swiftpm",
17358
18556
  "Package.resolved"
17359
18557
  );
17360
- 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();
18558
+ const packageResolved = import_node_fs15.default.existsSync(resolvedFile) ? [import_node_fs15.default.realpathSync(resolvedFile)] : [...new Set(localPackageDirs.map((dir) => import_node_path15.default.join(dir, "Package.resolved")))].filter((file) => import_node_fs15.default.existsSync(file)).map((file) => import_node_fs15.default.realpathSync(file)).sort();
17361
18559
  const used = order.map((ref) => ref.project);
17362
18560
  return {
17363
18561
  ...module2,
17364
18562
  rootDir: commonAncestor(
17365
18563
  [
17366
- workspace ? import_node_path14.default.dirname(workspace) : app.project.projectDir,
18564
+ workspace ? import_node_path15.default.dirname(workspace) : app.project.projectDir,
17367
18565
  ...used.map((project) => project.projectDir),
17368
18566
  ...localPackageDirs,
17369
18567
  ...linkedProducts.flatMap(
17370
- ({ source }) => source.kind === "local" && import_node_fs14.default.existsSync(source.dir) ? [source.dir] : []
18568
+ ({ source }) => source.kind === "local" && import_node_fs15.default.existsSync(source.dir) ? [source.dir] : []
17371
18569
  ),
17372
18570
  ...new Set(podSourceDirs)
17373
- ].map((dir) => import_node_fs14.default.realpathSync(dir))
18571
+ ].map((dir) => import_node_fs15.default.realpathSync(dir))
17374
18572
  ),
17375
18573
  projectFiles: [
17376
18574
  .../* @__PURE__ */ new Set([
@@ -17379,13 +18577,14 @@ function readXcodeAppTarget(input, targetName, configurationName, options = {})
17379
18577
  ...cocoapods ? [cocoapods.podfileLock, cocoapods.manifestLock, ...cocoapods.localPodspecs] : []
17380
18578
  ])
17381
18579
  ].sort(),
18580
+ projectDirs: [...new Set(used.map((project) => project.projectDir))].sort(),
17382
18581
  appIconName: settings("ASSETCATALOG_COMPILER_APPICON_NAME"),
17383
- infoPlist: import_plist2.default.build(info),
18582
+ infoPlist: import_plist3.default.build(info),
17384
18583
  infoPlistFile,
17385
18584
  frameworks,
17386
18585
  linkedProducts,
17387
18586
  localPackageDirs: [
17388
- ...new Set(localPackageDirs.map((dir) => import_node_fs14.default.realpathSync(dir)))
18587
+ ...new Set(localPackageDirs.map((dir) => import_node_fs15.default.realpathSync(dir)))
17389
18588
  ].sort(),
17390
18589
  binaryFrameworks: [...binaryFrameworks].map(([name2, file]) => ({ name: name2, path: file })).sort((left, right) => left.name.localeCompare(right.name)),
17391
18590
  packageResolved,
@@ -17460,7 +18659,7 @@ function readNativeAppIdentityFromXcodeTarget(app, parseInfoPlist = parsePlistSo
17460
18659
  const rtcAppGroupIdentifier = nonEmptyString2(dictionary.RTCAppGroupIdentifier);
17461
18660
  const screenShareExtensionBundleId = typeof dictionary.ScreenShareExtensionBundleId === "string" ? dictionary.ScreenShareExtensionBundleId : void 0;
17462
18661
  const rootModuleName = readRootModuleName(
17463
- app.allSources.filter((file) => /\.(?:swift|mm|m)$/.test(file) && import_node_fs15.default.existsSync(file)).map((file) => import_node_fs15.default.readFileSync(file, "utf8"))
18662
+ app.allSources.filter((file) => /\.(?:swift|mm|m)$/.test(file) && import_node_fs16.default.existsSync(file)).map((file) => import_node_fs16.default.readFileSync(file, "utf8"))
17464
18663
  );
17465
18664
  return {
17466
18665
  applicationName,
@@ -17481,7 +18680,7 @@ function readNativeAppIdentityFromXcodeTarget(app, parseInfoPlist = parsePlistSo
17481
18680
  googleSignIn: readGoogleSignInConfiguration(
17482
18681
  dictionary,
17483
18682
  Object.fromEntries(
17484
- app.resources.filter((file) => file.endsWith(".plist")).map((file) => [file, parseInfoPlist(import_node_fs15.default.readFileSync(file, "utf8"))])
18683
+ app.resources.filter((file) => file.endsWith(".plist")).map((file) => [file, parseInfoPlist(import_node_fs16.default.readFileSync(file, "utf8"))])
17485
18684
  )
17486
18685
  ),
17487
18686
  supportedInterfaceOrientations,
@@ -17490,11 +18689,11 @@ function readNativeAppIdentityFromXcodeTarget(app, parseInfoPlist = parsePlistSo
17490
18689
  alternateIconNames: [...alternateIconNames],
17491
18690
  appIconArtwork: resolveNativeAppIconArtwork(
17492
18691
  app.resources,
17493
- (file) => import_node_fs15.default.readFileSync(file, "utf8"),
18692
+ (file) => import_node_fs16.default.readFileSync(file, "utf8"),
17494
18693
  (file) => {
17495
- const extension = import_node_path15.default.extname(file).toLowerCase();
18694
+ const extension = import_node_path16.default.extname(file).toLowerCase();
17496
18695
  const contentType = extension === ".jpg" || extension === ".jpeg" ? "image/jpeg" : extension === ".webp" ? "image/webp" : "image/png";
17497
- return `data:${contentType};base64,${import_node_fs15.default.readFileSync(file).toString("base64")}`;
18696
+ return `data:${contentType};base64,${import_node_fs16.default.readFileSync(file).toString("base64")}`;
17498
18697
  },
17499
18698
  icons,
17500
18699
  app.appIconName,
@@ -17525,22 +18724,22 @@ function readNativeAppIdentityFromSources(projectRoot, platform, parseInfoPlist,
17525
18724
  const read = selectNativeAppIdentityReader(platform, {
17526
18725
  android: () => null,
17527
18726
  ios: () => {
17528
- const iosRoot = import_node_path15.default.join(projectRoot, "ios");
17529
- if (!import_node_fs15.default.existsSync(iosRoot)) return null;
18727
+ const iosRoot = import_node_path16.default.join(projectRoot, "ios");
18728
+ if (!import_node_fs16.default.existsSync(iosRoot)) return null;
17530
18729
  const files = {};
17531
- for (const entry of import_node_fs15.default.readdirSync(iosRoot, { withFileTypes: true })) {
18730
+ for (const entry of import_node_fs16.default.readdirSync(iosRoot, { withFileTypes: true })) {
17532
18731
  if (entry.name === "Pods") continue;
17533
18732
  if (entry.isDirectory()) {
17534
18733
  const names = entry.name.endsWith(".xcodeproj") ? ["project.pbxproj"] : ["Info.plist", "AppDelegate.swift", "AppDelegate.mm", "AppDelegate.m"];
17535
18734
  for (const name2 of names) {
17536
18735
  const relative3 = `ios/${entry.name}/${name2}`;
17537
- const file = import_node_path15.default.join(projectRoot, relative3);
17538
- if (import_node_fs15.default.existsSync(file)) files[relative3] = import_node_fs15.default.readFileSync(file, "utf8");
18736
+ const file = import_node_path16.default.join(projectRoot, relative3);
18737
+ if (import_node_fs16.default.existsSync(file)) files[relative3] = import_node_fs16.default.readFileSync(file, "utf8");
17539
18738
  }
17540
18739
  } else if (/AppDelegate\.(?:swift|mm|m)$/.test(entry.name)) {
17541
18740
  const relative3 = `ios/${entry.name}`;
17542
- const file = import_node_path15.default.join(projectRoot, relative3);
17543
- if (import_node_fs15.default.existsSync(file)) files[relative3] = import_node_fs15.default.readFileSync(file, "utf8");
18741
+ const file = import_node_path16.default.join(projectRoot, relative3);
18742
+ if (import_node_fs16.default.existsSync(file)) files[relative3] = import_node_fs16.default.readFileSync(file, "utf8");
17544
18743
  }
17545
18744
  }
17546
18745
  return extractNativeAppIdentityFromFiles(files, "ios", parseInfoPlist, iosTarget);
@@ -17551,41 +18750,41 @@ function readNativeAppIdentityFromSources(projectRoot, platform, parseInfoPlist,
17551
18750
  function readAndroidNativeAppIdentity(projectRoot, androidMergedManifest) {
17552
18751
  const files = {};
17553
18752
  if (androidMergedManifest) {
17554
- const file = import_node_path15.default.resolve(projectRoot, androidMergedManifest);
17555
- if (!import_node_fs15.default.existsSync(file)) return null;
17556
- files[androidMergedManifest] = import_node_fs15.default.readFileSync(file, "utf8");
18753
+ const file = import_node_path16.default.resolve(projectRoot, androidMergedManifest);
18754
+ if (!import_node_fs16.default.existsSync(file)) return null;
18755
+ files[androidMergedManifest] = import_node_fs16.default.readFileSync(file, "utf8");
17557
18756
  } else {
17558
- const androidRoot = import_node_path15.default.join(projectRoot, "android");
17559
- if (!import_node_fs15.default.existsSync(androidRoot)) return null;
18757
+ const androidRoot = import_node_path16.default.join(projectRoot, "android");
18758
+ if (!import_node_fs16.default.existsSync(androidRoot)) return null;
17560
18759
  const collect = (directory) => {
17561
- for (const entry of import_node_fs15.default.readdirSync(directory, { withFileTypes: true })) {
17562
- const file = import_node_path15.default.join(directory, entry.name);
18760
+ for (const entry of import_node_fs16.default.readdirSync(directory, { withFileTypes: true })) {
18761
+ const file = import_node_path16.default.join(directory, entry.name);
17563
18762
  if (entry.isDirectory()) collect(file);
17564
18763
  else if (entry.isFile() && entry.name === "AndroidManifest.xml")
17565
- files[import_node_path15.default.relative(projectRoot, file).split(import_node_path15.default.sep).join("/")] = import_node_fs15.default.readFileSync(file, "utf8");
18764
+ files[import_node_path16.default.relative(projectRoot, file).split(import_node_path16.default.sep).join("/")] = import_node_fs16.default.readFileSync(file, "utf8");
17566
18765
  }
17567
18766
  };
17568
- for (const module2 of import_node_fs15.default.readdirSync(androidRoot, { withFileTypes: true })) {
18767
+ for (const module2 of import_node_fs16.default.readdirSync(androidRoot, { withFileTypes: true })) {
17569
18768
  if (!module2.isDirectory()) continue;
17570
- const outputs = import_node_path15.default.join(
18769
+ const outputs = import_node_path16.default.join(
17571
18770
  androidRoot,
17572
18771
  module2.name,
17573
18772
  "build/intermediates/merged_manifests"
17574
18773
  );
17575
- if (import_node_fs15.default.existsSync(outputs)) collect(outputs);
18774
+ if (import_node_fs16.default.existsSync(outputs)) collect(outputs);
17576
18775
  }
17577
18776
  }
17578
18777
  for (const manifest of Object.keys(files)) {
17579
18778
  const resourceDirectory = androidMergedResourceValuesDirectory(manifest);
17580
18779
  if (!resourceDirectory) continue;
17581
- const absolute = import_node_path15.default.resolve(projectRoot, resourceDirectory);
17582
- if (!import_node_fs15.default.existsSync(absolute)) continue;
17583
- for (const entry of import_node_fs15.default.readdirSync(absolute, { withFileTypes: true })) {
18780
+ const absolute = import_node_path16.default.resolve(projectRoot, resourceDirectory);
18781
+ if (!import_node_fs16.default.existsSync(absolute)) continue;
18782
+ for (const entry of import_node_fs16.default.readdirSync(absolute, { withFileTypes: true })) {
17584
18783
  if (!entry.isDirectory() || !/^values(?:-|$)/.test(entry.name)) continue;
17585
- for (const resource of import_node_fs15.default.readdirSync(import_node_path15.default.join(absolute, entry.name))) {
18784
+ for (const resource of import_node_fs16.default.readdirSync(import_node_path16.default.join(absolute, entry.name))) {
17586
18785
  if (!resource.endsWith(".xml")) continue;
17587
18786
  const file = `${resourceDirectory}/${entry.name}/${resource}`;
17588
- files[file] = import_node_fs15.default.readFileSync(import_node_path15.default.resolve(projectRoot, file), "utf8");
18787
+ files[file] = import_node_fs16.default.readFileSync(import_node_path16.default.resolve(projectRoot, file), "utf8");
17589
18788
  }
17590
18789
  }
17591
18790
  }
@@ -17602,7 +18801,7 @@ function readIosNativeAppIdentity(projectRoot, parseInfoPlist, iosTarget) {
17602
18801
  const app = readIosAppTarget(projectRoot, iosTarget);
17603
18802
  if (!app) return null;
17604
18803
  const identity = readNativeAppIdentityFromXcodeTarget(app, parseInfoPlist);
17605
- const projectManifestPath = import_node_path15.default.join(projectRoot, "package.json");
18804
+ const projectManifestPath = import_node_path16.default.join(projectRoot, "package.json");
17606
18805
  const projectRequire = (0, import_node_module4.createRequire)(projectManifestPath);
17607
18806
  let reanimatedManifestPath;
17608
18807
  try {
@@ -17616,22 +18815,22 @@ function readIosNativeAppIdentity(projectRoot, parseInfoPlist, iosTarget) {
17616
18815
  throw error;
17617
18816
  }
17618
18817
  const installedManifest = JSON.parse(
17619
- import_node_fs15.default.readFileSync(reanimatedManifestPath, "utf8")
18818
+ import_node_fs16.default.readFileSync(reanimatedManifestPath, "utf8")
17620
18819
  );
17621
18820
  const installedVersion = isRecord(installedManifest) ? nonEmptyString2(installedManifest.version) : void 0;
17622
18821
  if (!installedVersion) throw new Error("Reanimated package version is malformed");
17623
18822
  if (Number.parseInt(installedVersion, 10) < 4) return identity;
17624
18823
  const defaults = JSON.parse(
17625
- import_node_fs15.default.readFileSync(
17626
- import_node_path15.default.join(
17627
- import_node_path15.default.dirname(reanimatedManifestPath),
18824
+ import_node_fs16.default.readFileSync(
18825
+ import_node_path16.default.join(
18826
+ import_node_path16.default.dirname(reanimatedManifestPath),
17628
18827
  "src/featureFlags/staticFlags.json"
17629
18828
  ),
17630
18829
  "utf8"
17631
18830
  )
17632
18831
  );
17633
18832
  if (!isRecord(defaults)) throw new Error("Reanimated static flags are malformed");
17634
- const manifest = JSON.parse(import_node_fs15.default.readFileSync(projectManifestPath, "utf8"));
18833
+ const manifest = JSON.parse(import_node_fs16.default.readFileSync(projectManifestPath, "utf8"));
17635
18834
  const reanimated = isRecord(manifest) ? manifest.reanimated : void 0;
17636
18835
  const overrides = isRecord(reanimated) ? reanimated.staticFeatureFlags : void 0;
17637
18836
  if (overrides !== void 0 && !isRecord(overrides)) {
@@ -17654,9 +18853,9 @@ function readIosNativeAppIdentity(projectRoot, parseInfoPlist, iosTarget) {
17654
18853
  return { ...identity, reanimatedStaticFeatureFlags: flags };
17655
18854
  }
17656
18855
  function readIosAppTarget(projectRoot, iosTarget) {
17657
- const iosRoot = import_node_path15.default.join(projectRoot, "ios");
17658
- if (!import_node_fs15.default.existsSync(iosRoot)) return null;
17659
- const projects = import_node_fs15.default.readdirSync(iosRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory() && entry.name.endsWith(".xcodeproj"));
18856
+ const iosRoot = import_node_path16.default.join(projectRoot, "ios");
18857
+ if (!import_node_fs16.default.existsSync(iosRoot)) return null;
18858
+ const projects = import_node_fs16.default.readdirSync(iosRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory() && entry.name.endsWith(".xcodeproj"));
17660
18859
  if (projects.length === 0) return null;
17661
18860
  if (projects.length > 1 && !iosTarget) {
17662
18861
  throw new NativeAppTargetSelectionError(
@@ -17666,7 +18865,7 @@ function readIosAppTarget(projectRoot, iosTarget) {
17666
18865
  let project = projects[0];
17667
18866
  if (iosTarget && projects.length > 1) {
17668
18867
  const matches = projects.filter(
17669
- (entry) => listXcodeAppTargets(import_node_path15.default.join(iosRoot, entry.name), {
18868
+ (entry) => listXcodeAppTargets(import_node_path16.default.join(iosRoot, entry.name), {
17670
18869
  requireSources: false
17671
18870
  }).includes(iosTarget)
17672
18871
  );
@@ -17680,7 +18879,7 @@ function readIosAppTarget(projectRoot, iosTarget) {
17680
18879
  }
17681
18880
  project = matches[0];
17682
18881
  }
17683
- const xcodeproj = import_node_path15.default.join(iosRoot, project.name);
18882
+ const xcodeproj = import_node_path16.default.join(iosRoot, project.name);
17684
18883
  const appTargets = listXcodeAppTargets(xcodeproj, { requireSources: false });
17685
18884
  if (!iosTarget && appTargets.length > 1) {
17686
18885
  throw new NativeAppTargetSelectionError(
@@ -17695,9 +18894,9 @@ function readIosAppTarget(projectRoot, iosTarget) {
17695
18894
  // src/native-firebase-config.ts
17696
18895
  init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
17697
18896
  var import_node_child_process6 = require("node:child_process");
17698
- var import_node_fs16 = __toESM(require("node:fs"), 1);
17699
- var import_node_os3 = __toESM(require("node:os"), 1);
17700
- var import_node_path16 = __toESM(require("node:path"), 1);
18897
+ var import_node_fs17 = __toESM(require("node:fs"), 1);
18898
+ var import_node_os4 = __toESM(require("node:os"), 1);
18899
+ var import_node_path17 = __toESM(require("node:path"), 1);
17701
18900
  init_is_record();
17702
18901
  var EXPO_CONFIG_SCRIPT = `const { createRequire } = require('node:module');
17703
18902
  const { writeFileSync } = require('node:fs');
@@ -17708,13 +18907,13 @@ const result = JSON.stringify(getConfig(root, { skipSDKVersionRequirement: true
17708
18907
  if (Buffer.byteLength(result) > 1024 * 1024) throw new Error('Expo native configuration exceeds 1 MiB.');
17709
18908
  writeFileSync(process.argv[2], result, { mode: 0o600 });`;
17710
18909
  function hasExpoConfig(projectRoot) {
17711
- const appJsonPath = import_node_path16.default.join(projectRoot, "app.json");
17712
- const appJson = import_node_fs16.default.existsSync(appJsonPath) ? JSON.parse(import_node_fs16.default.readFileSync(appJsonPath, "utf8")) : null;
18910
+ const appJsonPath = import_node_path17.default.join(projectRoot, "app.json");
18911
+ const appJson = import_node_fs17.default.existsSync(appJsonPath) ? JSON.parse(import_node_fs17.default.readFileSync(appJsonPath, "utf8")) : null;
17713
18912
  const staticExpo = isRecord(appJson) && (isRecord(appJson.expo) || [appJson.ios, appJson.android].some(
17714
18913
  (value) => isRecord(value) && typeof value.googleServicesFile === "string"
17715
18914
  ));
17716
18915
  return staticExpo || ["app.config.js", "app.config.ts", "app.config.cjs", "app.config.mjs"].some(
17717
- (name2) => import_node_fs16.default.existsSync(import_node_path16.default.join(projectRoot, name2))
18916
+ (name2) => import_node_fs17.default.existsSync(import_node_path17.default.join(projectRoot, name2))
17718
18917
  );
17719
18918
  }
17720
18919
  function expoConfigArgs(projectRoot, resultPath) {
@@ -17722,22 +18921,22 @@ function expoConfigArgs(projectRoot, resultPath) {
17722
18921
  "--input-type=commonjs",
17723
18922
  "-e",
17724
18923
  EXPO_CONFIG_SCRIPT,
17725
- import_node_path16.default.resolve(projectRoot),
18924
+ import_node_path17.default.resolve(projectRoot),
17726
18925
  resultPath
17727
18926
  ];
17728
18927
  }
17729
18928
  function readExpoConfigResult(resultPath, status, stderr) {
17730
18929
  if (status !== 0)
17731
18930
  throw new Error(stderr || "Expo native configuration evaluation failed.");
17732
- const resolved = JSON.parse(import_node_fs16.default.readFileSync(resultPath, "utf8"));
18931
+ const resolved = JSON.parse(import_node_fs17.default.readFileSync(resultPath, "utf8"));
17733
18932
  if (!isRecord(resolved)) throw new Error("Expo native configuration is unavailable.");
17734
18933
  return resolved;
17735
18934
  }
17736
- var resultDirectory = () => import_node_fs16.default.mkdtempSync(import_node_path16.default.join(import_node_os3.default.tmpdir(), "peach-expo-config-"));
18935
+ var resultDirectory = () => import_node_fs17.default.mkdtempSync(import_node_path17.default.join(import_node_os4.default.tmpdir(), "peach-expo-config-"));
17737
18936
  function readExpoConfig(projectRoot) {
17738
18937
  if (!hasExpoConfig(projectRoot)) return {};
17739
18938
  const directory = resultDirectory();
17740
- const resultPath = import_node_path16.default.join(directory, "config.json");
18939
+ const resultPath = import_node_path17.default.join(directory, "config.json");
17741
18940
  try {
17742
18941
  const child = (0, import_node_child_process6.spawnSync)("node", expoConfigArgs(projectRoot, resultPath), {
17743
18942
  cwd: projectRoot,
@@ -17749,7 +18948,7 @@ function readExpoConfig(projectRoot) {
17749
18948
  if (child.error) throw child.error;
17750
18949
  return readExpoConfigResult(resultPath, child.status, child.stderr);
17751
18950
  } finally {
17752
- import_node_fs16.default.rmSync(directory, { recursive: true, force: true });
18951
+ import_node_fs17.default.rmSync(directory, { recursive: true, force: true });
17753
18952
  }
17754
18953
  }
17755
18954
  function evaluateFirebaseGuard(header, resources) {
@@ -17771,7 +18970,7 @@ function evaluateFirebaseGuard(header, resources) {
17771
18970
  }
17772
18971
  clauses.push(condition.slice(start).trim());
17773
18972
  const sources = resources.filter(
17774
- (file) => import_node_path16.default.basename(file) === "GoogleService-Info.plist"
18973
+ (file) => import_node_path17.default.basename(file) === "GoogleService-Info.plist"
17775
18974
  );
17776
18975
  const bound = /* @__PURE__ */ new Map();
17777
18976
  for (const clause of clauses) {
@@ -17787,7 +18986,7 @@ function evaluateFirebaseGuard(header, resources) {
17787
18986
  const dictionary = /^let\s+(\w+)\s*=\s*NSDictionary\s*\(\s*contentsOfFile:\s*(\w+)\s*\)$/.exec(clause);
17788
18987
  if (dictionary && typeof bound.get(dictionary[2]) === "string") {
17789
18988
  const parsed = parsePlistSource(
17790
- import_node_fs16.default.readFileSync(String(bound.get(dictionary[2])), "utf8")
18989
+ import_node_fs17.default.readFileSync(String(bound.get(dictionary[2])), "utf8")
17791
18990
  );
17792
18991
  if (!isRecord(parsed)) return false;
17793
18992
  bound.set(dictionary[1], parsed);
@@ -17869,7 +19068,7 @@ function findDefaultConfigureCall(body, sources) {
17869
19068
  const [, type, name2] = call;
17870
19069
  for (const file of sources) {
17871
19070
  if (!file.endsWith(".swift")) continue;
17872
- const source = blankSwiftObjcLiterals(import_node_fs16.default.readFileSync(file, "utf8"));
19071
+ const source = blankSwiftObjcLiterals(import_node_fs17.default.readFileSync(file, "utf8"));
17873
19072
  const declaration = new RegExp(
17874
19073
  `\\b(?:enum|struct|class)\\s+${type}\\b[^{]*\\{`
17875
19074
  ).exec(source);
@@ -17890,10 +19089,10 @@ function readTargetGoogleServicesFile(projectRoot, xcodeproj, target) {
17890
19089
  requireSources: false
17891
19090
  });
17892
19091
  const delegates = app.allSources.filter(
17893
- (file) => /^AppDelegate\.(swift|mm|m)$/.test(import_node_path16.default.basename(file))
19092
+ (file) => /^AppDelegate\.(swift|mm|m)$/.test(import_node_path17.default.basename(file))
17894
19093
  );
17895
19094
  const defaultConfigured = delegates.some((file) => {
17896
- const raw = import_node_fs16.default.readFileSync(file, "utf8");
19095
+ const raw = import_node_fs17.default.readFileSync(file, "utf8");
17897
19096
  const source = blankSwiftObjcLiterals(raw);
17898
19097
  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(
17899
19098
  source
@@ -17959,27 +19158,27 @@ function readTargetGoogleServicesFile(projectRoot, xcodeproj, target) {
17959
19158
  });
17960
19159
  if (!defaultConfigured) return null;
17961
19160
  const resources = app.resources.filter(
17962
- (file) => /^GoogleService-Info\.plist$/.test(import_node_path16.default.basename(file))
19161
+ (file) => /^GoogleService-Info\.plist$/.test(import_node_path17.default.basename(file))
17963
19162
  );
17964
19163
  if (resources.length !== 1)
17965
19164
  throw new Error(
17966
19165
  "native Firebase default initialization requires one GoogleService-Info.plist build resource"
17967
19166
  );
17968
- return import_node_path16.default.relative(import_node_fs16.default.realpathSync(projectRoot), resources[0]);
19167
+ return import_node_path17.default.relative(import_node_fs17.default.realpathSync(projectRoot), resources[0]);
17969
19168
  }
17970
19169
  function readNativeFirebaseConfig(projectRoot, platforms = ["ios", "android"], iosTarget, config = readExpoConfig(projectRoot)) {
17971
19170
  const result = {};
17972
19171
  const ios = config.ios;
17973
19172
  if (platforms.includes("ios") && (!isRecord(ios) || typeof ios.googleServicesFile !== "string")) {
17974
- const iosRoot = import_node_path16.default.join(projectRoot, "ios");
17975
- if (import_node_fs16.default.existsSync(iosRoot)) {
17976
- const projects = import_node_fs16.default.readdirSync(iosRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory() && entry.name.endsWith(".xcodeproj"));
19173
+ const iosRoot = import_node_path17.default.join(projectRoot, "ios");
19174
+ if (import_node_fs17.default.existsSync(iosRoot)) {
19175
+ const projects = import_node_fs17.default.readdirSync(iosRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory() && entry.name.endsWith(".xcodeproj"));
17977
19176
  if (projects.length > 1)
17978
19177
  throw new Error(
17979
19178
  `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(", ")}`
17980
19179
  );
17981
19180
  if (projects.length === 1) {
17982
- const xcodeproj = import_node_path16.default.join(iosRoot, projects[0].name);
19181
+ const xcodeproj = import_node_path17.default.join(iosRoot, projects[0].name);
17983
19182
  const appTargets = listXcodeAppTargets(xcodeproj, { requireSources: false });
17984
19183
  const files = new Set(
17985
19184
  (iosTarget ? [iosTarget] : appTargets).map(
@@ -17999,8 +19198,8 @@ function readNativeFirebaseConfig(projectRoot, platforms = ["ios", "android"], i
17999
19198
  const native = config[platform];
18000
19199
  if (!isRecord(native) || typeof native.googleServicesFile !== "string") continue;
18001
19200
  try {
18002
- const source = import_node_fs16.default.readFileSync(
18003
- import_node_path16.default.resolve(projectRoot, native.googleServicesFile),
19201
+ const source = import_node_fs17.default.readFileSync(
19202
+ import_node_path17.default.resolve(projectRoot, native.googleServicesFile),
18004
19203
  "utf8"
18005
19204
  );
18006
19205
  const parsed = platform === "ios" ? parsePlistSource(source) : JSON.parse(source);
@@ -18193,13 +19392,13 @@ function readCallableMetroExport(moduleValue, label) {
18193
19392
  }
18194
19393
  function createMetroDefaultSerializer(asyncRequireModulePath) {
18195
19394
  const projectRequire = (0, import_module2.createRequire)(asyncRequireModulePath);
18196
- const metroRoot = import_path5.default.dirname(projectRequire.resolve("metro/package.json"));
19395
+ const metroRoot = import_path6.default.dirname(projectRequire.resolve("metro/package.json"));
18197
19396
  const baseJSBundle = readCallableMetroExport(
18198
- projectRequire(import_path5.default.join(metroRoot, "src/DeltaBundler/Serializers/baseJSBundle.js")),
19397
+ projectRequire(import_path6.default.join(metroRoot, "src/DeltaBundler/Serializers/baseJSBundle.js")),
18199
19398
  "baseJSBundle"
18200
19399
  );
18201
19400
  const bundleToString = readCallableMetroExport(
18202
- projectRequire(import_path5.default.join(metroRoot, "src/lib/bundleToString.js")),
19401
+ projectRequire(import_path6.default.join(metroRoot, "src/lib/bundleToString.js")),
18203
19402
  "bundleToString"
18204
19403
  );
18205
19404
  return (entryPoint, preModules, graph, options) => {
@@ -18221,7 +19420,7 @@ async function appendRNXModulePaths(result, graph, options, projectRoot, emptyMo
18221
19420
  }
18222
19421
  const modulePaths = {};
18223
19422
  for (const module2 of dependencies.values()) {
18224
- modulePaths[String(createModuleId(module2.path))] = import_path5.default.relative(projectRoot, module2.path).replaceAll(import_path5.default.sep, "/");
19423
+ modulePaths[String(createModuleId(module2.path))] = import_path6.default.relative(projectRoot, module2.path).replaceAll(import_path6.default.sep, "/");
18225
19424
  }
18226
19425
  if (Object.keys(modulePaths).length !== dependencies.size) {
18227
19426
  throw new Error("peachsim: bundle module IDs were not unique");
@@ -18311,8 +19510,8 @@ function withPeach(config, options = {}) {
18311
19510
  graph,
18312
19511
  serializerOptions,
18313
19512
  cfgProjectRoot,
18314
- configuredEmptyModulePath ?? import_path5.default.join(
18315
- import_path5.default.dirname(serializerOptions.asyncRequireModulePath),
19513
+ configuredEmptyModulePath ?? import_path6.default.join(
19514
+ import_path6.default.dirname(serializerOptions.asyncRequireModulePath),
18316
19515
  "empty-module.js"
18317
19516
  )
18318
19517
  );
@@ -18423,6 +19622,7 @@ function withPeach(config, options = {}) {
18423
19622
  }
18424
19623
  return;
18425
19624
  }
19625
+ if (serveBrowserProxyRoute(req, res)) return;
18426
19626
  const url = req.url || "";
18427
19627
  const pathname = url.split("?")[0];
18428
19628
  const runtimeRoot = resolveRuntimeRootForRequestHost(req.headers?.host);
@@ -18453,14 +19653,13 @@ function withPeach(config, options = {}) {
18453
19653
  }
18454
19654
  }
18455
19655
  if (pathname === prefix || pathname === prefix + "/" || pathname.startsWith(prefix + "/")) {
18456
- const ext = import_path5.default.extname(pathname);
19656
+ const ext = import_path6.default.extname(pathname);
18457
19657
  if (!ext) {
18458
- const htmlPath = import_path5.default.join(runtimeRoot, "index.html");
18459
- let html = import_fs6.default.readFileSync(htmlPath, "utf8");
19658
+ const htmlPath = import_path6.default.join(runtimeRoot, "index.html");
19659
+ let html = import_fs7.default.readFileSync(htmlPath, "utf8");
18460
19660
  const script = `<script>(function(){var u=new URL(location.href);if(!u.searchParams.has('bundle'))u.searchParams.set('bundle',${JSON.stringify(bundleUrl)});history.replaceState(null,'','${prefix}/'+u.search)})()</script>`;
18461
19661
  html = html.includes("</head>") ? html.replace("</head>", `${script}</head>`) : `${html}${script}`;
18462
- res.setHeader("content-type", "text/html");
18463
- res.end(html);
19662
+ sendShellHtml(res, html);
18464
19663
  return;
18465
19664
  }
18466
19665
  }
@@ -18492,13 +19691,13 @@ var metro_plugin_default = withPeach;
18492
19691
 
18493
19692
  // src/jump-to-source-babel.ts
18494
19693
  init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
18495
- function normalizeSourcePath(path21) {
18496
- const queryStart = path21.indexOf("?");
18497
- const clean = queryStart >= 0 ? path21.slice(0, queryStart) : path21;
19694
+ function normalizeSourcePath(path22) {
19695
+ const queryStart = path22.indexOf("?");
19696
+ const clean = queryStart >= 0 ? path22.slice(0, queryStart) : path22;
18498
19697
  return clean.replace(/\\/g, "/");
18499
19698
  }
18500
- function matchesPath(path21, matcher) {
18501
- return typeof matcher === "string" ? path21.includes(matcher) : matcher.test(path21);
19699
+ function matchesPath(path22, matcher) {
19700
+ return typeof matcher === "string" ? path22.includes(matcher) : matcher.test(path22);
18502
19701
  }
18503
19702
  function shouldStampFile(filename, options) {
18504
19703
  const normalized = normalizeSourcePath(filename);
@@ -18518,11 +19717,11 @@ function sootsimJumpToSourceBabelPlugin(api, options = {}) {
18518
19717
  name: "sootsim-jump-to-source",
18519
19718
  visitor: {
18520
19719
  JSXElement: {
18521
- exit(path21, state) {
19720
+ exit(path22, state) {
18522
19721
  if (options.enabled === false) return;
18523
19722
  const filename = state.filename;
18524
19723
  if (!filename || !shouldStampFile(filename, options)) return;
18525
- const node = path21.node;
19724
+ const node = path22.node;
18526
19725
  if (stamped.has(node)) return;
18527
19726
  stamped.add(node);
18528
19727
  const opening = node.openingElement;
@@ -18541,12 +19740,12 @@ function sootsimJumpToSourceBabelPlugin(api, options = {}) {
18541
19740
  );
18542
19741
  return;
18543
19742
  }
18544
- const fn = path21.getFunctionParent();
19743
+ const fn = path22.getFunctionParent();
18545
19744
  const parameterDefault = Boolean(
18546
19745
  fn && opening.start != null && fn.node.body.start != null && opening.start < fn.node.body.start
18547
19746
  );
18548
- const type = path21.scope.generateUidIdentifier("PeachSourceType");
18549
- if (!parameterDefault) path21.scope.push({ id: type });
19747
+ const type = path22.scope.generateUidIdentifier("PeachSourceType");
19748
+ if (!parameterDefault) path22.scope.push({ id: type });
18550
19749
  function expression(tag) {
18551
19750
  return t.isJSXIdentifier(tag) ? t.identifier(tag.name) : t.memberExpression(
18552
19751
  expression(tag.object),
@@ -18581,10 +19780,10 @@ function sootsimJumpToSourceBabelPlugin(api, options = {}) {
18581
19780
  ),
18582
19781
  node
18583
19782
  );
18584
- if (path21.parentPath.isJSXElement() || path21.parentPath.isJSXFragment()) {
18585
- path21.replaceWith(t.jsxExpressionContainer(replacement));
19783
+ if (path22.parentPath.isJSXElement() || path22.parentPath.isJSXFragment()) {
19784
+ path22.replaceWith(t.jsxExpressionContainer(replacement));
18586
19785
  } else {
18587
- path21.replaceWith(replacement);
19786
+ path22.replaceWith(replacement);
18588
19787
  }
18589
19788
  }
18590
19789
  }