peachsim 0.1.1716 → 0.1.1738

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 (282) hide show
  1. package/README.md +21 -3
  2. package/cli/app-bundle-resources.ts +2 -1
  3. package/cli/app-fonts.ts +4 -4
  4. package/cli/app-splash.ts +4 -4
  5. package/cli/app-stubs.ts +17 -0
  6. package/cli/command-registry.ts +1 -0
  7. package/cli/commands/control.ts +83 -822
  8. package/cli/commands/coverage-swift.ts +112 -4
  9. package/cli/commands/daemon.ts +8 -0
  10. package/cli/commands/detox.ts +3 -0
  11. package/cli/commands/doctor.ts +19 -2
  12. package/cli/commands/inspect/actions.ts +74 -14
  13. package/cli/commands/inspect/core.ts +5 -1
  14. package/cli/commands/inspect/settling.ts +5 -2
  15. package/cli/commands/inspect/wait-ready.ts +6 -0
  16. package/cli/commands/inspect.ts +48 -45
  17. package/cli/commands/kotlin.ts +12 -2
  18. package/cli/commands/package.ts +760 -0
  19. package/cli/commands/serve.ts +6 -0
  20. package/cli/commands/shell-url.ts +838 -0
  21. package/cli/commands/swift.ts +42 -102
  22. package/cli/commands/test.ts +20 -0
  23. package/cli/commands/upload.ts +1 -1
  24. package/cli/device-option.ts +1 -1
  25. package/cli/main.ts +13 -1
  26. package/cli/native-input.ts +199 -0
  27. package/cli/outbound-endpoints.ts +26 -1
  28. package/cli/packaged-app-launcher.ts +95 -0
  29. package/cli/scene-video.ts +36 -12
  30. package/detox/index.ts +196 -24
  31. package/dist-lib/agent-daemon-client.cjs +1 -1
  32. package/dist-lib/agent-events.cjs +1 -1
  33. package/dist-lib/attached-projects.cjs +5 -2
  34. package/dist-lib/auth/shared-session.cjs +5 -2
  35. package/dist-lib/backend-origin.cjs +1 -1
  36. package/dist-lib/beta.cjs +1 -1
  37. package/dist-lib/beta.mjs +1 -1
  38. package/dist-lib/bridge-constants.cjs +1 -1
  39. package/dist-lib/bridge-contract-input.cjs +1 -1
  40. package/dist-lib/bridge-contract-input.mjs +1 -1
  41. package/dist-lib/bridge-contract.cjs +1 -1
  42. package/dist-lib/bridge-contract.mjs +1 -1
  43. package/dist-lib/bundle-channel.cjs +39889 -31873
  44. package/dist-lib/capture-contract.cjs +1 -1
  45. package/dist-lib/capture-contract.mjs +1 -1
  46. package/dist-lib/cloud-contract.cjs +1 -1
  47. package/dist-lib/cloud-contract.mjs +1 -1
  48. package/dist-lib/cloud-test-args.cjs +1 -1
  49. package/dist-lib/cloud-test-args.mjs +1 -1
  50. package/dist-lib/cloud.cjs +1 -1
  51. package/dist-lib/cloud.mjs +1 -1
  52. package/dist-lib/config.cjs +1 -1
  53. package/dist-lib/config.mjs +1 -1
  54. package/dist-lib/detox/index.cjs +195 -63
  55. package/dist-lib/dev-bundle-resolution.cjs +14 -13
  56. package/dist-lib/expo-swift-bundle.cjs +18507 -11835
  57. package/dist-lib/expo-swift-metadata.cjs +4 -1
  58. package/dist-lib/expo-swift-metadata.mjs +3 -1
  59. package/dist-lib/home-paths.cjs +27 -3
  60. package/dist-lib/host/bridge-host.cjs +28373 -24090
  61. package/dist-lib/host/fetch-proxy-handler.cjs +235 -225
  62. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  63. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  64. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  65. package/dist-lib/host/websocket-proxy.cjs +1 -1
  66. package/dist-lib/index.cjs +915 -399
  67. package/dist-lib/jump-to-source-babel.cjs +1 -1
  68. package/dist-lib/jump-to-source-native.cjs +1 -1
  69. package/dist-lib/kotlin-host.cjs +335 -47
  70. package/dist-lib/menu.cjs +13 -1
  71. package/dist-lib/menu.mjs +13 -1
  72. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  73. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  74. package/dist-lib/metro-production-bundle.cjs +1 -1
  75. package/dist-lib/metro-production-bundle.mjs +1 -1
  76. package/dist-lib/metro.cjs +918 -411
  77. package/dist-lib/native-app-identity-project.cjs +703 -283
  78. package/dist-lib/native-app-identity-project.mjs +500 -87
  79. package/dist-lib/native-app-identity.cjs +13 -2
  80. package/dist-lib/native-app-identity.mjs +13 -2
  81. package/dist-lib/native-firebase-metadata.cjs +1 -1
  82. package/dist-lib/native-firebase-metadata.mjs +1 -1
  83. package/dist-lib/plist.cjs +1 -1
  84. package/dist-lib/plist.mjs +1 -1
  85. package/dist-lib/profiles.cjs +5 -2
  86. package/dist-lib/public-brand.cjs +1 -1
  87. package/dist-lib/public-origins-lib-esm.json +28 -23
  88. package/dist-lib/public-origins-lib.json +418 -224
  89. package/dist-lib/react-native-host-modules.cjs +35 -2
  90. package/dist-lib/react-native-host-modules.mjs +35 -2
  91. package/dist-lib/reap-browser.cjs +12 -4
  92. package/dist-lib/scripts/dev-server-scanner.cjs +15 -8
  93. package/dist-lib/sdk.cjs +17 -7
  94. package/dist-lib/sdk.mjs +16 -7
  95. package/dist-lib/skills.cjs +44825 -29141
  96. package/dist-lib/swift-compile.cjs +616 -400
  97. package/dist-lib/swift-compile.mjs +528 -315
  98. package/dist-lib/swift-package.cjs +1 -1
  99. package/dist-lib/swift-package.mjs +1 -1
  100. package/dist-lib/swift-submit.cjs +2 -2
  101. package/dist-lib/swift-submit.mjs +2 -2
  102. package/dist-lib/swift-toolchain.cjs +105 -17
  103. package/dist-lib/swift.cjs +1 -1
  104. package/dist-lib/vite-swift.cjs +4660 -2252
  105. package/dist-lib/vite.cjs +248 -234
  106. package/dist-lib/worklet-executable.cjs +1 -1
  107. package/dist-lib/worklet-executable.mjs +1 -1
  108. package/dist-types/packages/peach-compat/src/stubs/native-seams/react-native-cookies.d.ts +17 -8
  109. package/dist-types/packages/peach-engine/src/engine/canvaskit-renderer.d.ts +1 -0
  110. package/dist-types/packages/peach-engine/src/engine/font-config.d.ts +7 -4
  111. package/dist-types/packages/peach-engine/src/engine/image-loader.d.ts +9 -6
  112. package/dist-types/packages/peach-engine/src/engine/liquid-glass.d.ts +0 -5
  113. package/dist-types/packages/peach-engine/src/engine/memory-counts.d.ts +11 -1
  114. package/dist-types/packages/peach-engine/src/engine/node.d.ts +5 -12
  115. package/dist-types/packages/peach-engine/src/engine/render-damage.d.ts +2 -2
  116. package/dist-types/packages/peach-engine/src/engine/text-first-baseline.d.ts +5 -0
  117. package/dist-types/packages/peach-engine/src/engine/text-paragraph.d.ts +1 -0
  118. package/dist-types/packages/peach-engine/src/engine/types.d.ts +3 -0
  119. package/dist-types/packages/peach-engine/src/native-preview-bundle.d.ts +2 -0
  120. package/dist-types/packages/peach-engine/src/render-worker/compositor-protocol.d.ts +9 -0
  121. package/dist-types/packages/peach-engine/src/render-worker/host-service-protocol.d.ts +3 -0
  122. package/dist-types/packages/peach-engine/src/render-worker/native-ui-commandContract.d.ts +1 -1
  123. package/dist-types/packages/peach-engine/src/render-worker/protocol.d.ts +7 -2
  124. package/dist-types/packages/peach-engine/src/render-worker/shell-protocol.d.ts +5 -0
  125. package/dist-types/packages/peach-engine/src/render-worker/tree-sync-port.d.ts +1 -1
  126. package/dist-types/packages/peach-engine/src/render-worker/worklet-runtime.d.ts +36 -2
  127. package/dist-types/packages/peach-engine/src/shell-events.d.ts +1 -0
  128. package/dist-types/packages/peach-globals/src/audioBridgeContract.d.ts +5 -0
  129. package/dist-types/packages/peach-globals/src/index.d.ts +1 -1
  130. package/dist-types/packages/peach-globals/src/keyboardBridgeContract.d.ts +11 -0
  131. package/dist-types/packages/peach-globals/src/shellBridgeContract.d.ts +1 -0
  132. package/dist-types/packages/peach-globals/src/testBridgeContract.d.ts +9 -2
  133. package/dist-types/packages/peach-kit/src/capabilities.d.ts +1 -0
  134. package/kotlin/README.md +3 -0
  135. package/kotlin/sdk.tar.gz +0 -0
  136. package/package.json +1 -1
  137. package/runtime-companion.json +1 -1
  138. package/scripts/dev-server-scanner.ts +12 -25
  139. package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/ACAccount.h +55 -0
  140. package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/ACAccountCredential.h +35 -0
  141. package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/ACAccountStore.h +94 -0
  142. package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/ACAccountType.h +53 -0
  143. package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/ACError.h +37 -0
  144. package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/Accounts.h +13 -0
  145. package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/AccountsDefines.h +13 -0
  146. package/sdk/ios/System/Library/Frameworks/Accounts.framework/Modules/module.modulemap +5 -0
  147. package/sdk/ios/System/Library/Frameworks/AuthenticationServices.framework/Headers/ASFoundation.h +52 -0
  148. package/sdk/ios/System/Library/Frameworks/AuthenticationServices.framework/Headers/ASWebAuthenticationSession.h +128 -0
  149. package/sdk/ios/System/Library/Frameworks/AuthenticationServices.framework/Headers/ASWebAuthenticationSessionCallback.h +35 -0
  150. package/sdk/ios/System/Library/Frameworks/AuthenticationServices.framework/Headers/AuthenticationServices.h +3 -0
  151. package/sdk/ios/System/Library/Frameworks/AuthenticationServices.framework/Modules/module.modulemap +5 -0
  152. package/sdk/ios/System/Library/Frameworks/CFNetwork.framework/Headers/CFHTTPMessage.h +724 -0
  153. package/sdk/ios/System/Library/Frameworks/CFNetwork.framework/Headers/CFNetwork.h +4 -0
  154. package/sdk/ios/System/Library/Frameworks/CFNetwork.framework/Headers/CFNetworkDefs.h +27 -0
  155. package/sdk/ios/System/Library/Frameworks/CFNetwork.framework/Modules/module.modulemap +5 -0
  156. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFURL.h +1301 -0
  157. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.h +3 -1
  158. package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLLocationManager.h +21 -50
  159. package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLRegion.h +6 -6
  160. package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes +58 -3
  161. package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h +711 -46
  162. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIApplication.h +12 -0
  163. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIInterface.h +23 -0
  164. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h +7 -9
  165. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIOrientation.h +14 -0
  166. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIStringDrawing.h +12 -0
  167. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIView.h +14 -0
  168. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIViewAnimating.h +12 -0
  169. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIViewController.h +16 -0
  170. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIWindow.h +2 -0
  171. package/sdk/ios/usr/include/ConditionalMacros.h +619 -0
  172. package/sdk/ios/usr/include/module.modulemap +1 -0
  173. package/sdk/ios/usr/include/objc/objc-sync.h +59 -0
  174. package/sdk/ios/usr/include/os/signpost.h +414 -0
  175. package/sdk/ios/usr/include/os.modulemap +10 -0
  176. package/sdk/ios/usr/include/sys/cdefs.h +5 -0
  177. package/sdk/ios/usr/include/sys/ioccom.h +99 -0
  178. package/sdk/ios/usr/include/sys/syslog.h +236 -0
  179. package/sdk/ios/usr/include/syslog.h +24 -0
  180. package/sdk/ios/wasm/include/errno.h +4 -20
  181. package/sdk/ios/wasm/include/fcntl.h +4 -2
  182. package/sdk/ios/wasm/include/pthread.h +3 -0
  183. package/sdk/ios/wasm/include/setjmp.h +57 -0
  184. package/sdk/ios/wasm/include/stdio.h +24 -0
  185. package/sdk/ios/wasm/include/stdlib.h +32 -7
  186. package/sdk/ios/wasm/include/sys/file.h +7 -0
  187. package/sdk/ios/wasm/include/sys/ioctl.h +6 -0
  188. package/sdk/ios/wasm/include/sys/resource.h +2 -2
  189. package/sdk/ios/wasm/include/sys/syscall.h +9 -0
  190. package/sdk/ios/wasm/include/sys/time.h +10 -0
  191. package/sdk/ios/wasm/include/unistd.h +12 -3
  192. package/sdk/native-hashes.json +4 -3
  193. package/skills/contrast/SKILL.md +2 -1
  194. package/skills/peach-debug/SKILL.md +0 -1
  195. package/skills/peach-perf/SKILL.md +0 -1
  196. package/skills/peach-setup/SKILL.md +0 -1
  197. package/skills/peach-test/SKILL.md +7 -4
  198. package/skills/peach-visual/SKILL.md +0 -1
  199. package/src/admitted-mac-build.ts +3 -0
  200. package/src/android-app-identity.ts +18 -0
  201. package/src/android-autolinking.ts +1 -0
  202. package/src/android-bridge-packages.ts +279 -0
  203. package/src/android-root-module.ts +9 -9
  204. package/src/appPackageContract.ts +83 -0
  205. package/src/bridge-contract.ts +50 -0
  206. package/src/bundle-channel.mjs +41 -6
  207. package/src/cli-runtime.ts +9 -5
  208. package/src/dev-bundle-resolution.ts +7 -27
  209. package/src/dom-source-reference.ts +15 -0
  210. package/src/expo-discovery-cache.ts +134 -26
  211. package/src/expo-kotlin-host.ts +97 -26
  212. package/src/expo-manifest-body.ts +33 -0
  213. package/src/expo-native-workspace.ts +158 -38
  214. package/src/expo-swift-host.ts +350 -75
  215. package/src/expo-swift-ready.ts +5 -1
  216. package/src/expoKotlinContract.ts +12 -2
  217. package/src/expoSwiftContract.ts +10 -0
  218. package/src/generated/swift-c-predefines.json +1 -1
  219. package/src/home-paths.ts +41 -2
  220. package/src/host/app-package-handler.ts +47 -0
  221. package/src/host/bridge-host.ts +8 -0
  222. package/src/host/fetch-proxy-handler.ts +10 -0
  223. package/src/host/staged-host-files.ts +18 -0
  224. package/src/index.ts +3 -0
  225. package/src/kotlin-host.ts +225 -48
  226. package/src/kotlin-instance-source.ts +126 -0
  227. package/src/kotlinSdkContract.ts +2 -1
  228. package/src/menu.ts +14 -0
  229. package/src/native-app-identity-project.ts +7 -2
  230. package/src/native-app-identity.ts +11 -0
  231. package/src/native-firebase-config.ts +24 -1
  232. package/src/native-prebuilt.ts +154 -0
  233. package/src/nitro-adapter.lock.json +270 -270
  234. package/src/nitro-adapter.ts +56 -50
  235. package/src/nitro-bundle.ts +92 -74
  236. package/src/nitro-compile.ts +45 -14
  237. package/src/nitro-dependencies.ts +63 -46
  238. package/src/nitro-source.ts +64 -26
  239. package/src/nitroAdapterContract.ts +146 -98
  240. package/src/nitroContract.ts +71 -21
  241. package/src/react-native-bridge-modules.ts +70 -42
  242. package/src/react-native-host-modules.ts +34 -1
  243. package/src/reactNativeConfigurationContract.ts +14 -0
  244. package/src/reap-browser.ts +15 -3
  245. package/src/sdk.ts +5 -0
  246. package/src/settingsContract.ts +38 -1
  247. package/src/sim-client.ts +4 -1
  248. package/src/storageSnapshotContract.ts +32 -81
  249. package/src/swift-compile.ts +268 -89
  250. package/src/swift-coverage/indexdump.ts +22 -6
  251. package/src/swift-coverage/indexing.ts +4 -4
  252. package/src/swift-coverage/provenance.ts +1 -0
  253. package/src/swift-coverage/sdk.ts +104 -20
  254. package/src/swift-coverage/types.ts +34 -0
  255. package/src/swift-coverage/xcode-asset-symbols.ts +922 -0
  256. package/src/swift-coverage/xcode-assets.ts +89 -131
  257. package/src/swift-coverage/xcode.ts +10 -2
  258. package/src/swift-cxx-reachable.ts +2 -1
  259. package/src/swift-distribution.lock.json +20 -16
  260. package/src/swift-host.ts +98 -22
  261. package/src/swift-icu.ts +1 -1
  262. package/src/swift-link-roots.ts +118 -0
  263. package/src/swift-objc-compile.ts +144 -22
  264. package/src/swift-objc-import.ts +6 -0
  265. package/src/swift-objc-standin.ts +2 -14
  266. package/src/swift-package-manifest.ts +14 -6
  267. package/src/swift-packages.ts +75 -11
  268. package/src/swift-pdf-raster.ts +1 -0
  269. package/src/swift-root-lock.ts +17 -1
  270. package/src/swift-source-pods.ts +2 -10
  271. package/src/swift-standin-emit.ts +597 -57
  272. package/src/swift-standins.ts +599 -56
  273. package/src/swift-submit.ts +7 -1
  274. package/src/swift-toolchain.ts +140 -17
  275. package/src/turbo-bundle.ts +81 -0
  276. package/src/turbo-codegen-intake.ts +91 -0
  277. package/src/turbo-compile.ts +120 -0
  278. package/src/turbo-runtime.lock.json +69 -0
  279. package/src/turbo-source.ts +754 -0
  280. package/src/vite-plugin-one.ts +17 -12
  281. package/src/vite-plugin.ts +28 -15
  282. package/src/xcode-project.ts +223 -22
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.1716 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1738 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
 
3
3
  // src/swift-compile.ts
4
4
  import {
@@ -17,11 +17,12 @@ import {
17
17
  renameSync,
18
18
  rmSync as rmSync3,
19
19
  statSync,
20
+ symlinkSync,
20
21
  utimesSync,
21
22
  writeFileSync as writeFileSync3
22
23
  } from "node:fs";
23
24
  import os2 from "node:os";
24
- import path12 from "node:path";
25
+ import path13 from "node:path";
25
26
 
26
27
  // src/admitted-mac-build.ts
27
28
  import { spawnSync } from "node:child_process";
@@ -30,6 +31,8 @@ function windowAdmission() {
30
31
  encoding: "utf8",
31
32
  stdio: ["ignore", "pipe", "inherit"]
32
33
  });
34
+ if (result.error && "code" in result.error && result.error.code === "ENOENT")
35
+ return null;
33
36
  if (result.error) throw result.error;
34
37
  if (result.status === 1) return null;
35
38
  if (result.status !== 0) throw new Error(`tm window ancestor exited ${result.status}`);
@@ -51,7 +54,7 @@ function admittedMacBuilderSlot(env = process.env) {
51
54
 
52
55
  // src/generated/swift-c-predefines.json
53
56
  var swift_c_predefines_default = {
54
- release: "swift-6.4.0-RELEASE-custom-ecd2ad9d3fe59329",
57
+ release: "swift-6.4.0-RELEASE-custom-81b2c791c27276bf",
55
58
  languages: {
56
59
  c: {
57
60
  TARGET_IPHONE_SIMULATOR: "1",
@@ -2101,16 +2104,28 @@ import fs from "node:fs";
2101
2104
  import { homedir } from "node:os";
2102
2105
  import path from "node:path";
2103
2106
  var PEACH_HOME_ENV = "PEACH_HOME";
2107
+ function ambientHomeDir() {
2108
+ return path.join(homedir(), ".peach");
2109
+ }
2104
2110
  function rnxHomeDir() {
2105
2111
  const override = process.env[PEACH_HOME_ENV];
2106
2112
  if (override && override.length > 0) return path.resolve(override);
2107
- return path.join(homedir(), ".peach");
2113
+ return ambientHomeDir();
2108
2114
  }
2109
2115
  function cacheDir() {
2110
2116
  return path.join(rnxHomeDir(), "cache");
2111
2117
  }
2118
+ var BUILDERS_ROOT_ENV = "CONTRAST_BUILDERS_ROOT";
2119
+ function buildersRootEnv() {
2120
+ const root = process.env[BUILDERS_ROOT_ENV]?.trim();
2121
+ return root ? root : null;
2122
+ }
2123
+ function swiftCacheDir() {
2124
+ const root = buildersRootEnv();
2125
+ return root ? path.join(root, "peach-cache") : cacheDir();
2126
+ }
2112
2127
  function swiftPackageCacheOptions() {
2113
- const root = path.join(cacheDir(), "swiftpm");
2128
+ const root = path.join(swiftCacheDir(), "swiftpm");
2114
2129
  return ["cache", "config", "security"].flatMap((name2) => [
2115
2130
  `--${name2}-path`,
2116
2131
  path.join(root, name2)
@@ -2810,9 +2825,9 @@ var EXCERPT = /^(\s*)(\d+)( \| )(.*)$/;
2810
2825
  var MARKER = /^(\s*)( \| )(.*)$/;
2811
2826
  function designTimeDiagnostic(output, files) {
2812
2827
  const rewritten = /* @__PURE__ */ new Map();
2813
- const linesOf = (path13) => {
2828
+ const linesOf = (path14) => {
2814
2829
  const file = Object.keys(files).find(
2815
- (name2) => name2.endsWith(".swift") && (path13 === name2 || path13.endsWith(`/${name2}`))
2830
+ (name2) => name2.endsWith(".swift") && (path14 === name2 || path14.endsWith(`/${name2}`))
2816
2831
  );
2817
2832
  if (file === void 0) return null;
2818
2833
  let lines = rewritten.get(file);
@@ -2929,31 +2944,53 @@ function swiftSdkOptions() {
2929
2944
  }
2930
2945
  return [];
2931
2946
  }
2932
- var SWIFT_HOST_COMPILER_RELEASE = "swift-6.4.0-RELEASE-custom-ecd2ad9d3fe59329";
2933
- var SWIFT_HOST_COMPILER_ID = "ecd2ad9d3fe59329";
2947
+ var SWIFT_HOST_COMPILER_RELEASE = "swift-6.4.0-RELEASE-custom-81b2c791c27276bf";
2948
+ var SWIFT_HOST_COMPILER_ID = "81b2c791c27276bf";
2934
2949
  var compilerArchives = {
2935
- "darwin-arm64": {
2936
- checksum: "ab42a13b34e410ca09737420d1ee1d6af417eec039ab44f9a60502bdb5c76506",
2937
- manifest: "8a93b6b1e6ff577f6dacd81a511d415ca3b396698f9b0c4abc35a4ca807e9d1a"
2938
- },
2939
- "linux-x64": {
2940
- checksum: "b174baa2c578fb32f09c79590d65d03951b04cdec52101b23a46c0b274249fc3",
2941
- manifest: "330e6cbae5890111c22a58e645049a971eff30334c3f240c650fcfedfeab4ef6"
2950
+ "swift-6.4.0-RELEASE-custom-0b2d0a9011c88e66": {
2951
+ identity: "0b2d0a9011c88e66",
2952
+ hosts: {
2953
+ "darwin-arm64": {
2954
+ checksum: "dc6a494227297ea657e8e5f7c5b4a861cb5e142bdbcfcb028ace2aeb19db90cc",
2955
+ manifest: "d8e9eee0fb9b847f1e9350525d6c68606df46101745f553332309ed026b3c26a"
2956
+ },
2957
+ "linux-x64": {
2958
+ checksum: "85c04b4496aea1657c21a47f448e01d6ccc1c7920d130a566db37fb8350a7be2",
2959
+ manifest: "8451659e74235ad53b700c1afbe293512197900eb98cb1f79e36df2f5c85d511"
2960
+ },
2961
+ "linux-arm64": {
2962
+ checksum: "196606ed62c5c926d18e6ef0769cb1ab21c9943f9084070ddf14a7bc696768b8",
2963
+ manifest: "85fb8d5b6527bd75003a6dbd25b68b22540665cf9df9b13f41f82e5d8acdbf1d"
2964
+ }
2965
+ }
2942
2966
  },
2943
- "linux-arm64": {
2944
- checksum: "25f722334dd9d79391cb2e47301165e9ef98dd9a8036927652f3c5db3c56b2ae",
2945
- manifest: "94e5667febf26f8a4ee8c5456f83f62d17453e503d261a4c46d2b80f872470ab"
2967
+ [SWIFT_HOST_COMPILER_RELEASE]: {
2968
+ identity: SWIFT_HOST_COMPILER_ID,
2969
+ hosts: {
2970
+ "darwin-arm64": {
2971
+ checksum: "bc51b83d9e2e01c9873875326544734486d3ff3a868d650379c304045e8838d3",
2972
+ manifest: "a26eb9cb4fbd1dbd7faac20cced1ec5e67745bd358aa1180cc4abc1a0d21d6e6"
2973
+ },
2974
+ "linux-x64": {
2975
+ checksum: "ea63bbdecae14ff8e9e3f535b521fedc65d51b31521c5d10cc332cb91882d058",
2976
+ manifest: "b22b321ce3eb3fe044fa2122484a15c061f262c45d88a05b3fbace0a5bf038b6"
2977
+ },
2978
+ "linux-arm64": {
2979
+ checksum: "3eef4ed57830908515d8def2882e312f7cabeea57ccda5b2a7585401ef98cc48",
2980
+ manifest: "cfab342b8090fa83a697a391a7563cba14b771c24f07e1f8e19977f913ac88be"
2981
+ }
2982
+ }
2946
2983
  }
2947
2984
  };
2948
2985
  function swiftHostCompilerArchive(release, host2 = `${process.platform}-${process.arch}`) {
2949
- if (release !== SWIFT_HOST_COMPILER_RELEASE)
2950
- throw new Error(`unqualified host compiler ${release}`);
2951
- const archive = compilerArchives[host2];
2986
+ const compiler = compilerArchives[release];
2987
+ if (!compiler) throw new Error(`unqualified host compiler ${release}`);
2988
+ const archive = compiler.hosts[host2];
2952
2989
  if (!archive) throw new Error(`unsupported Swift compiler host ${host2}`);
2953
2990
  return {
2954
2991
  ...archive,
2955
- identity: SWIFT_HOST_COMPILER_ID,
2956
- url: `https://r2.sootsim.com/swift-host-compiler/${SWIFT_HOST_COMPILER_ID}/${release}-${host2}.tar.gz`
2992
+ identity: compiler.identity,
2993
+ url: `https://r2.sootsim.com/swift-host-compiler/${compiler.identity}/${release}-${host2}.tar.gz`
2957
2994
  };
2958
2995
  }
2959
2996
  function swiftUpstreamRelease(release) {
@@ -3316,7 +3353,7 @@ function archiveMember(archive, name2) {
3316
3353
  }
3317
3354
  function icuSegment(object) {
3318
3355
  let at = 8;
3319
- const leb = () => {
3356
+ const leb2 = () => {
3320
3357
  let result = 0;
3321
3358
  let shift = 0;
3322
3359
  let byte;
@@ -3330,15 +3367,15 @@ function icuSegment(object) {
3330
3367
  const found = [];
3331
3368
  while (at < object.length) {
3332
3369
  const id = object[at++];
3333
- const size = leb();
3370
+ const size = leb2();
3334
3371
  const end = at + size;
3335
3372
  if (id === 11) {
3336
- for (let count = leb(); count > 0; count--) {
3337
- if (leb() !== 0) throw new Error("swift-icu: unexpected data segment kind");
3373
+ for (let count = leb2(); count > 0; count--) {
3374
+ if (leb2() !== 0) throw new Error("swift-icu: unexpected data segment kind");
3338
3375
  at++;
3339
- leb();
3376
+ leb2();
3340
3377
  at++;
3341
- const length = leb();
3378
+ const length = leb2();
3342
3379
  const bytes = object.subarray(at, at + length);
3343
3380
  if (bytes[2] === 218 && bytes[3] === 39) found.push(bytes);
3344
3381
  at += length;
@@ -3351,6 +3388,100 @@ function icuSegment(object) {
3351
3388
  return found[0];
3352
3389
  }
3353
3390
 
3391
+ // src/swift-link-roots.ts
3392
+ import fs3 from "node:fs";
3393
+ import path6 from "node:path";
3394
+ var OBJC_SEGMENTS = [
3395
+ "__objc_classes",
3396
+ "__objc_protocols",
3397
+ "__objc_cats",
3398
+ "__objc_class_aliases"
3399
+ ];
3400
+ var leb = (bytes, at) => {
3401
+ let value = 0;
3402
+ let scale = 1;
3403
+ for (; ; ) {
3404
+ const byte = bytes[at.offset++];
3405
+ value += (byte & 127) * scale;
3406
+ if (!(byte & 128)) return value;
3407
+ scale *= 128;
3408
+ }
3409
+ };
3410
+ function objcSegmentSizes(bytes) {
3411
+ const at = { offset: 8 };
3412
+ const names = [];
3413
+ const sizes = [];
3414
+ while (at.offset < bytes.length) {
3415
+ const id = bytes[at.offset++];
3416
+ const size = leb(bytes, at);
3417
+ const end = at.offset + size;
3418
+ if (id === 0) {
3419
+ const length = leb(bytes, at);
3420
+ const name2 = Buffer.from(bytes.subarray(at.offset, at.offset + length)).toString();
3421
+ at.offset += length;
3422
+ if (name2 === "linking") {
3423
+ leb(bytes, at);
3424
+ while (at.offset < end) {
3425
+ const kind = bytes[at.offset++];
3426
+ const length2 = leb(bytes, at);
3427
+ const next = at.offset + length2;
3428
+ if (kind === 5) {
3429
+ for (let count = leb(bytes, at); count > 0; count--) {
3430
+ const nameLength = leb(bytes, at);
3431
+ names.push(
3432
+ Buffer.from(bytes.subarray(at.offset, at.offset + nameLength)).toString()
3433
+ );
3434
+ at.offset += nameLength;
3435
+ leb(bytes, at);
3436
+ leb(bytes, at);
3437
+ }
3438
+ }
3439
+ at.offset = next;
3440
+ }
3441
+ }
3442
+ } else if (id === 11) {
3443
+ for (let count = leb(bytes, at); count > 0; count--) {
3444
+ const flags = leb(bytes, at);
3445
+ if (flags === 2) leb(bytes, at);
3446
+ if (flags !== 1) {
3447
+ at.offset++;
3448
+ leb(bytes, at);
3449
+ at.offset++;
3450
+ }
3451
+ const length = leb(bytes, at);
3452
+ sizes.push(length);
3453
+ at.offset += length;
3454
+ }
3455
+ }
3456
+ at.offset = end;
3457
+ }
3458
+ const result = /* @__PURE__ */ new Map();
3459
+ names.forEach((name2, index) => {
3460
+ if (OBJC_SEGMENTS.includes(name2))
3461
+ result.set(name2, (result.get(name2) ?? 0) + (sizes[index] ?? 0));
3462
+ });
3463
+ return result;
3464
+ }
3465
+ var rootsByDistribution = /* @__PURE__ */ new Map();
3466
+ function swiftObjcRootObjects(id, root, objects) {
3467
+ const cached = rootsByDistribution.get(id);
3468
+ if (cached) return cached;
3469
+ const measured = objects.map(
3470
+ (object) => [object, objcSegmentSizes(fs3.readFileSync(path6.join(root, object)))]
3471
+ );
3472
+ const empty = /* @__PURE__ */ new Map();
3473
+ for (const [, sizes] of measured)
3474
+ for (const [name2, size] of sizes)
3475
+ empty.set(name2, Math.min(empty.get(name2) ?? size, size));
3476
+ const roots = new Set(
3477
+ measured.filter(
3478
+ ([, sizes]) => [...sizes].some(([name2, size]) => size > (empty.get(name2) ?? 0))
3479
+ ).map(([object]) => object)
3480
+ );
3481
+ rootsByDistribution.set(id, roots);
3482
+ return roots;
3483
+ }
3484
+
3354
3485
  // src/swift-objc-import.ts
3355
3486
  var SWIFT_OBJC_INTEROP_FLAGS = [
3356
3487
  "-Xfrontend",
@@ -3362,6 +3493,9 @@ var SWIFT_OBJC_INTEROP_FLAGS = [
3362
3493
  "-Xcc",
3363
3494
  "-fblocks"
3364
3495
  ];
3496
+ function swiftClangImporterFlags(flags) {
3497
+ return flags.filter((flag) => flag !== "-fobjc-arc" && flag !== "-fno-objc-arc");
3498
+ }
3365
3499
  function swiftObjCModuleMap(module, headers) {
3366
3500
  return [
3367
3501
  `module ${module} {`,
@@ -3383,12 +3517,12 @@ var swiftObjCRuntimeFlags = [
3383
3517
  // src/swift-objc-standin.ts
3384
3518
  import { execFileSync as execFileSync2, spawnSync as spawnSync4 } from "node:child_process";
3385
3519
  import { createHash as createHash4 } from "node:crypto";
3386
- import fs3 from "node:fs";
3387
- import path8 from "node:path";
3520
+ import fs4 from "node:fs";
3521
+ import path9 from "node:path";
3388
3522
 
3389
3523
  // src/swift-objc-platform.ts
3390
3524
  import { spawnSync as spawnSync3 } from "node:child_process";
3391
- import path6 from "node:path";
3525
+ import path7 from "node:path";
3392
3526
  var platforms = /* @__PURE__ */ new Map();
3393
3527
  function swiftObjCPlatformFlags(toolchainBin, minimum) {
3394
3528
  const key = `${toolchainBin}:${minimum}`;
@@ -3400,7 +3534,7 @@ function swiftObjCPlatformFlags(toolchainBin, minimum) {
3400
3534
  minimum % 100
3401
3535
  ].join(".");
3402
3536
  const result = spawnSync3(
3403
- path6.join(toolchainBin, "clang"),
3537
+ path7.join(toolchainBin, "clang"),
3404
3538
  [
3405
3539
  "-target",
3406
3540
  `arm64-apple-ios${version}-simulator`,
@@ -3434,10 +3568,10 @@ function swiftObjCPlatformFlags(toolchainBin, minimum) {
3434
3568
  }
3435
3569
 
3436
3570
  // src/swift-objc-sdk.ts
3437
- import path7 from "node:path";
3571
+ import path8 from "node:path";
3438
3572
  var IOS_SDK_TARGET = "arm64-apple-ios16.0-simulator";
3439
3573
  var OVERLAY_PATH = /^usr\/lib\/swift\/([^/]+)\.swiftmodule\/arm64-apple-ios-simulator\.swiftinterface$/;
3440
- var tree = typeof __PEACH_BUNDLED_IOS_SDK__ === "undefined" ? readIosSdkTree(path7.join(peachsimPackageRoot(), "sdk", "ios")) : Object.entries(__PEACH_BUNDLED_IOS_SDK__).sort(([a], [b]) => a < b ? -1 : 1);
3574
+ var tree = typeof __PEACH_BUNDLED_IOS_SDK__ === "undefined" ? readIosSdkTree(path8.join(peachsimPackageRoot(), "sdk", "ios")) : Object.entries(__PEACH_BUNDLED_IOS_SDK__).sort(([a], [b]) => a < b ? -1 : 1);
3441
3575
  var IOS_SDK_HEADERS = {};
3442
3576
  var IOS_SDK_OVERLAYS = {};
3443
3577
  for (const [file, text2] of tree) {
@@ -3941,13 +4075,7 @@ function iosSdkEntries() {
3941
4075
  ${text2}`
3942
4076
  ]
3943
4077
  );
3944
- const osMap = IOS_SDK_HEADERS["usr/include/os.modulemap"];
3945
- if (osMap === void 0)
3946
- throw new Error("sdk intake has no usr/include/os.modulemap for clang-import");
3947
- const clangImport = [
3948
- ["clang-import/module.modulemap", osMap]
3949
- ];
3950
- return [...Object.entries(IOS_SDK_HEADERS), ...overlays, ...clangImport].sort(
4078
+ return [...Object.entries(IOS_SDK_HEADERS), ...overlays].sort(
3951
4079
  ([a], [b]) => a < b ? -1 : 1
3952
4080
  );
3953
4081
  }
@@ -3970,11 +4098,11 @@ function objcSdkIntakeFlags(headers, toolchainBin, minimum) {
3970
4098
  "-DU_DISABLE_RENAMING=0",
3971
4099
  ...WASI_EMULATION_FLAGS,
3972
4100
  "-iframework",
3973
- path8.join(headers, "System/Library/Frameworks"),
4101
+ path9.join(headers, "System/Library/Frameworks"),
3974
4102
  "-isystem",
3975
- path8.join(headers, "wasm/include"),
4103
+ path9.join(headers, "wasm/include"),
3976
4104
  "-idirafter",
3977
- path8.join(headers, "usr/include")
4105
+ path9.join(headers, "usr/include")
3978
4106
  ];
3979
4107
  }
3980
4108
  function iosDeploymentMinimum(version) {
@@ -3997,7 +4125,7 @@ import {
3997
4125
  rmSync as rmSync2,
3998
4126
  writeFileSync as writeFileSync2
3999
4127
  } from "node:fs";
4000
- import path9 from "node:path";
4128
+ import path10 from "node:path";
4001
4129
  var POLL_MS = 250;
4002
4130
  var START_TOLERANCE_MS = 2e3;
4003
4131
  function errorCode(error) {
@@ -4072,7 +4200,7 @@ function generationNumbers(directory) {
4072
4200
  function readGeneration(directory, number) {
4073
4201
  let owner;
4074
4202
  try {
4075
- owner = readFileSync5(path9.join(directory, name(number, "owner")), "utf8");
4203
+ owner = readFileSync5(path10.join(directory, name(number, "owner")), "utf8");
4076
4204
  } catch (error) {
4077
4205
  if (errorCode(error) === "ENOENT") return null;
4078
4206
  throw error;
@@ -4085,15 +4213,15 @@ function readGeneration(directory, number) {
4085
4213
  }
4086
4214
  function readChildren(directory, number) {
4087
4215
  const prefix = name(number, "child.");
4088
- return readdirSync3(directory).filter((entry) => entry.startsWith(prefix)).map((entry) => parseIdentity(readFileSync5(path9.join(directory, entry), "utf8")));
4216
+ return readdirSync3(directory).filter((entry) => entry.startsWith(prefix)).map((entry) => parseIdentity(readFileSync5(path10.join(directory, entry), "utf8")));
4089
4217
  }
4090
4218
  function groupAlive(table, leader) {
4091
4219
  const row = table.find((candidate) => candidate.pid === leader.pid);
4092
4220
  if (row && !sameProcess(row, leader)) return false;
4093
4221
  return table.some((candidate) => candidate.pgid === leader.pid && !candidate.zombie);
4094
4222
  }
4095
- async function withSwiftRootLock(root, work, signal) {
4096
- const directory = path9.join(
4223
+ async function withSwiftRootLock(root, work, signal, wait = true) {
4224
+ const directory = path10.join(
4097
4225
  rnxHomeDir(),
4098
4226
  "cache",
4099
4227
  "swift-root-locks",
@@ -4102,7 +4230,7 @@ async function withSwiftRootLock(root, work, signal) {
4102
4230
  mkdirSync(directory, { recursive: true });
4103
4231
  const token = randomUUID2();
4104
4232
  const owner = JSON.stringify(ownIdentity(process.pid));
4105
- const pending = path9.join(directory, `pending.${token}`);
4233
+ const pending = path10.join(directory, `pending.${token}`);
4106
4234
  let held = 0;
4107
4235
  for (; ; ) {
4108
4236
  signal?.throwIfAborted();
@@ -4112,18 +4240,20 @@ async function withSwiftRootLock(root, work, signal) {
4112
4240
  if (current && !current.released) {
4113
4241
  const table = processTable();
4114
4242
  if (table.some((row) => !row.zombie && sameProcess(row, current.holder))) {
4243
+ if (!wait) return void 0;
4115
4244
  await pause(POLL_MS, signal);
4116
4245
  continue;
4117
4246
  }
4118
4247
  const children2 = readChildren(directory, newest);
4119
4248
  if (children2.some((child) => groupAlive(table, child))) {
4249
+ if (!wait) return void 0;
4120
4250
  await pause(POLL_MS, signal);
4121
4251
  continue;
4122
4252
  }
4123
4253
  }
4124
4254
  writeFileSync2(pending, owner);
4125
4255
  try {
4126
- linkSync(pending, path9.join(directory, name(newest + 1, "owner")));
4256
+ linkSync(pending, path10.join(directory, name(newest + 1, "owner")));
4127
4257
  } catch (error) {
4128
4258
  if (errorCode(error) === "EEXIST") continue;
4129
4259
  throw error;
@@ -4132,7 +4262,7 @@ async function withSwiftRootLock(root, work, signal) {
4132
4262
  }
4133
4263
  const numbers = generationNumbers(directory);
4134
4264
  if (numbers.at(-1) !== newest + 1) {
4135
- rmSync2(path9.join(directory, name(newest + 1, "owner")), { force: true });
4265
+ rmSync2(path10.join(directory, name(newest + 1, "owner")), { force: true });
4136
4266
  continue;
4137
4267
  }
4138
4268
  held = newest + 1;
@@ -4140,7 +4270,7 @@ async function withSwiftRootLock(root, work, signal) {
4140
4270
  if (number < held) {
4141
4271
  for (const entry of readdirSync3(directory))
4142
4272
  if (entry.startsWith(name(number, "")))
4143
- rmSync2(path9.join(directory, entry), { force: true });
4273
+ rmSync2(path10.join(directory, entry), { force: true });
4144
4274
  }
4145
4275
  break;
4146
4276
  }
@@ -4164,7 +4294,7 @@ async function withSwiftRootLock(root, work, signal) {
4164
4294
  const childPending = `${pending}.child.${child.pid}`;
4165
4295
  try {
4166
4296
  writeFileSync2(childPending, JSON.stringify(ownIdentity(child.pid)));
4167
- linkSync(childPending, path9.join(directory, name(held, `child.${child.pid}`)));
4297
+ linkSync(childPending, path10.join(directory, name(held, `child.${child.pid}`)));
4168
4298
  } finally {
4169
4299
  rmSync2(childPending, { force: true });
4170
4300
  }
@@ -4180,19 +4310,19 @@ async function withSwiftRootLock(root, work, signal) {
4180
4310
  return await work(lease);
4181
4311
  } finally {
4182
4312
  await Promise.all(children.map((child) => terminateProcessGroup(child, "SIGKILL", 0)));
4183
- writeFileSync2(path9.join(directory, name(held, "released")), "");
4313
+ writeFileSync2(path10.join(directory, name(held, "released")), "");
4184
4314
  }
4185
4315
  }
4186
4316
 
4187
4317
  // src/swift-shared-sdk.ts
4188
4318
  import { readdirSync as readdirSync4, readFileSync as readFileSync6 } from "node:fs";
4189
- import path10 from "node:path";
4319
+ import path11 from "node:path";
4190
4320
  function swiftSharedSdkRoot(moduleRoot, distribution) {
4191
- return path10.resolve(moduleRoot, distribution ? "sdk/ios" : "../peachsim/sdk/ios");
4321
+ return path11.resolve(moduleRoot, distribution ? "sdk/ios" : "../peachsim/sdk/ios");
4192
4322
  }
4193
4323
  function swiftSharedSdkInputFiles(moduleRoot) {
4194
4324
  const root = swiftSharedSdkRoot(moduleRoot, false);
4195
- return readdirSync4(root, { recursive: true, withFileTypes: true }).filter((entry) => entry.isFile()).map((entry) => path10.relative(moduleRoot, path10.join(entry.parentPath, entry.name))).sort();
4325
+ return readdirSync4(root, { recursive: true, withFileTypes: true }).filter((entry) => entry.isFile()).map((entry) => path11.relative(moduleRoot, path11.join(entry.parentPath, entry.name))).sort();
4196
4326
  }
4197
4327
 
4198
4328
  // src/swiftContract.ts
@@ -4298,8 +4428,8 @@ function isSwiftResourceBundles(value) {
4298
4428
  }
4299
4429
 
4300
4430
  // src/xcode-header-search.ts
4301
- import fs4 from "node:fs";
4302
- import path11 from "node:path";
4431
+ import fs5 from "node:fs";
4432
+ import path12 from "node:path";
4303
4433
  function headerMap(entries) {
4304
4434
  const unique = /* @__PURE__ */ new Map();
4305
4435
  for (const entry of entries)
@@ -4342,16 +4472,16 @@ function headerMap(entries) {
4342
4472
  return Buffer.concat([table, ...strings]);
4343
4473
  }
4344
4474
  function writeXcodeHeaderSearch(directory, targets) {
4345
- fs4.mkdirSync(directory, { recursive: true });
4475
+ fs5.mkdirSync(directory, { recursive: true });
4346
4476
  const productDirectories = /* @__PURE__ */ new Map();
4347
4477
  for (const target of targets)
4348
4478
  for (const [product, file] of Object.entries(target.productHeaders)) {
4349
- const listed = productDirectories.get(path11.dirname(product)) ?? [];
4350
- productDirectories.set(path11.dirname(product), listed);
4351
- listed.push({ name: path11.basename(product), file });
4479
+ const listed = productDirectories.get(path12.dirname(product)) ?? [];
4480
+ productDirectories.set(path12.dirname(product), listed);
4481
+ listed.push({ name: path12.basename(product), file });
4352
4482
  }
4353
- const overlay = path11.join(directory, "all-product-headers.yaml");
4354
- fs4.writeFileSync(
4483
+ const overlay = path12.join(directory, "all-product-headers.yaml");
4484
+ fs5.writeFileSync(
4355
4485
  overlay,
4356
4486
  JSON.stringify({
4357
4487
  "case-sensitive": "false",
@@ -4370,8 +4500,8 @@ function writeXcodeHeaderSearch(directory, targets) {
4370
4500
  const files = [overlay];
4371
4501
  const flags = targets.map((target, index) => {
4372
4502
  const maps = target.headerMaps.map((map, order) => {
4373
- const file = path11.join(directory, `${index}-${order}.hmap`);
4374
- fs4.writeFileSync(file, headerMap(map.entries));
4503
+ const file = path12.join(directory, `${index}-${order}.hmap`);
4504
+ fs5.writeFileSync(file, headerMap(map.entries));
4375
4505
  files.push(file);
4376
4506
  return { flag: map.flag, file };
4377
4507
  });
@@ -4487,7 +4617,7 @@ function swiftBuilderHopTimeoutMs(compileTimeoutMs) {
4487
4617
  return (compileTimeoutMs ?? SWIFT_BUILDER_DEFAULT_COMPILE_MS) + SWIFT_BUILDER_TRANSPORT_MARGIN_MS;
4488
4618
  }
4489
4619
  function swiftDistributionAt(root) {
4490
- const file = path12.join(root, SWIFT_DISTRIBUTION_MANIFEST);
4620
+ const file = path13.join(root, SWIFT_DISTRIBUTION_MANIFEST);
4491
4621
  if (!existsSync2(file)) return null;
4492
4622
  return parseSwiftDistributionManifest(JSON.parse(readFileSync7(file, "utf8")));
4493
4623
  }
@@ -4505,6 +4635,7 @@ function swiftModuleInputFiles(root) {
4505
4635
  ...swiftSharedSdkInputFiles(root),
4506
4636
  "../peachsim/src/swift-shared-sdk.ts",
4507
4637
  "../../scripts/generate/swift-sdk-module/darwin-mach.json",
4638
+ "../../scripts/ops/swift-distribution-publish.ts",
4508
4639
  "Package.swift",
4509
4640
  "scripts/contrast-app-Package.swift",
4510
4641
  "scripts/build-distribution.ts",
@@ -4519,7 +4650,7 @@ function swiftModuleInputFiles(root) {
4519
4650
  "toolchain.json"
4520
4651
  ];
4521
4652
  const walk = (dir) => {
4522
- for (const entry of readdirSync5(path12.join(root, dir), {
4653
+ for (const entry of readdirSync5(path13.join(root, dir), {
4523
4654
  withFileTypes: true
4524
4655
  })) {
4525
4656
  const relative = `${dir}/${entry.name}`;
@@ -4537,35 +4668,35 @@ function swiftMacroPlugins(moduleRoot) {
4537
4668
  const distribution = swiftDistributionAt(moduleRoot);
4538
4669
  if (distribution)
4539
4670
  return {
4540
- libraries: distribution.plugins.filter((plugin) => path12.basename(plugin) !== "ExpoModulesMacros").map((plugin) => path12.join(moduleRoot, plugin)),
4541
- executables: distribution.plugins.filter((plugin) => path12.basename(plugin) === "ExpoModulesMacros").map((plugin) => path12.join(moduleRoot, plugin)),
4671
+ libraries: distribution.plugins.filter((plugin) => path13.basename(plugin) !== "ExpoModulesMacros").map((plugin) => path13.join(moduleRoot, plugin)),
4672
+ executables: distribution.plugins.filter((plugin) => path13.basename(plugin) === "ExpoModulesMacros").map((plugin) => path13.join(moduleRoot, plugin)),
4542
4673
  stale: false
4543
4674
  };
4544
- const dir = path12.join(moduleRoot, ".build/host/RnxPreviewMacros");
4675
+ const dir = path13.join(moduleRoot, ".build/host/RnxPreviewMacros");
4545
4676
  const release = JSON.parse(
4546
- readFileSync7(path12.join(moduleRoot, "toolchain.json"), "utf8")
4677
+ readFileSync7(path13.join(moduleRoot, "toolchain.json"), "utf8")
4547
4678
  ).release;
4548
- const compilerStamp = path12.join(dir, "compiler-release");
4549
- const pluginScript = path12.join(moduleRoot, "scripts/build-preview-plugin.sh");
4550
- const expoPlugin = path12.join(dir, "ExpoModulesMacros");
4679
+ const compilerStamp = path13.join(dir, "compiler-release");
4680
+ const pluginScript = path13.join(moduleRoot, "scripts/build-preview-plugin.sh");
4681
+ const expoPlugin = path13.join(dir, "ExpoModulesMacros");
4551
4682
  const ext = process.platform === "darwin" ? "dylib" : "so";
4552
4683
  const plugins = [
4553
4684
  {
4554
- library: path12.join(dir, `libRnxPreviewMacros.${ext}`),
4555
- sources: [path12.join(moduleRoot, "Sources/RnxPreviewMacros/PreviewMacro.swift")]
4685
+ library: path13.join(dir, `libRnxPreviewMacros.${ext}`),
4686
+ sources: [path13.join(moduleRoot, "Sources/RnxPreviewMacros/PreviewMacro.swift")]
4556
4687
  },
4557
4688
  {
4558
- library: path12.join(dir, `libFoundationMacros.${ext}`),
4689
+ library: path13.join(dir, `libFoundationMacros.${ext}`),
4559
4690
  sources: [
4560
- path12.join(moduleRoot, "Sources/FoundationMacros/PredicateMacro.swift"),
4561
- path12.join(moduleRoot, "Sources/SwiftMacroSupport/PredicateExpression.swift")
4691
+ path13.join(moduleRoot, "Sources/FoundationMacros/PredicateMacro.swift"),
4692
+ path13.join(moduleRoot, "Sources/SwiftMacroSupport/PredicateExpression.swift")
4562
4693
  ]
4563
4694
  },
4564
4695
  {
4565
- library: path12.join(dir, `libTipKitMacros.${ext}`),
4696
+ library: path13.join(dir, `libTipKitMacros.${ext}`),
4566
4697
  sources: [
4567
- path12.join(moduleRoot, "Sources/TipKitMacros/TipKitMacros.swift"),
4568
- path12.join(moduleRoot, "Sources/SwiftMacroSupport/PredicateExpression.swift")
4698
+ path13.join(moduleRoot, "Sources/TipKitMacros/TipKitMacros.swift"),
4699
+ path13.join(moduleRoot, "Sources/SwiftMacroSupport/PredicateExpression.swift")
4569
4700
  ]
4570
4701
  }
4571
4702
  ];
@@ -4583,14 +4714,14 @@ async function ensureMacroPlugins(moduleRoot, toolchainBin, release, signal) {
4583
4714
  await runCompiler(
4584
4715
  "sh",
4585
4716
  [
4586
- path12.join(moduleRoot, "scripts/build-preview-plugin.sh"),
4717
+ path13.join(moduleRoot, "scripts/build-preview-plugin.sh"),
4587
4718
  toolchainBin,
4588
4719
  libraries[0]
4589
4720
  ],
4590
4721
  { signal }
4591
4722
  );
4592
4723
  writeFileSync3(
4593
- path12.join(path12.dirname(libraries[0]), "compiler-release"),
4724
+ path13.join(path13.dirname(libraries[0]), "compiler-release"),
4594
4725
  `${release}
4595
4726
  `
4596
4727
  );
@@ -4606,7 +4737,7 @@ function swiftModuleDigest(root) {
4606
4737
  const files = swiftModuleInputFiles(root);
4607
4738
  const stampHash = createHash6("sha256");
4608
4739
  for (const file of files) {
4609
- const stat = statSync(path12.join(root, file), { bigint: true });
4740
+ const stat = statSync(path13.join(root, file), { bigint: true });
4610
4741
  stampHash.update(file);
4611
4742
  stampHash.update(
4612
4743
  `${stat.dev}:${stat.ino}:${stat.size}:${stat.mtimeNs}:${stat.ctimeNs}
@@ -4620,7 +4751,7 @@ function swiftModuleDigest(root) {
4620
4751
  for (const file of files) {
4621
4752
  hash.update(createHash6("sha256").update(file).digest());
4622
4753
  hash.update(
4623
- createHash6("sha256").update(readFileSync7(path12.join(root, file))).digest()
4754
+ createHash6("sha256").update(readFileSync7(path13.join(root, file))).digest()
4624
4755
  );
4625
4756
  }
4626
4757
  const digest = hash.digest();
@@ -4644,7 +4775,7 @@ function withNativeSourceGlue(input, glue) {
4644
4775
  ...input,
4645
4776
  files: {
4646
4777
  ...input.files,
4647
- [path12.posix.join(targetPath, "OneNativeSource.generated.swift")]: glue
4778
+ [path13.posix.join(targetPath, "OneNativeSource.generated.swift")]: glue
4648
4779
  },
4649
4780
  oneModule: true
4650
4781
  };
@@ -4660,9 +4791,8 @@ var OPTIONAL_FRAMEWORK_DEPENDENCIES = {
4660
4791
  ImagePlayground: [],
4661
4792
  QuickLookThumbnailing: [],
4662
4793
  libxml2: [],
4663
- Compression: ["PeachCodec"],
4664
- zlib: ["PeachCodec"],
4665
- PeachCodec: [],
4794
+ Compression: [],
4795
+ zlib: [],
4666
4796
  TikTokBusinessSDK: [],
4667
4797
  nSure: [],
4668
4798
  Statsig: [],
@@ -4785,7 +4915,7 @@ function swiftImportNames(contents, available) {
4785
4915
  function swiftPeachModules(moduleRoot) {
4786
4916
  const distribution = swiftDistributionAt(moduleRoot);
4787
4917
  return distribution ? distribution.modules : swiftManifestDeclarations(
4788
- readFileSync7(path12.join(moduleRoot, "Package.swift"), "utf8")
4918
+ readFileSync7(path13.join(moduleRoot, "Package.swift"), "utf8")
4789
4919
  ).filter((target) => !target.executable && !target.path.startsWith("fixtures/")).map((target) => target.name);
4790
4920
  }
4791
4921
  var sdkPaths = /* @__PURE__ */ new Map();
@@ -4795,7 +4925,7 @@ function swiftSdkPaths(moduleRoot, toolchainBin) {
4795
4925
  const cached = sdkPaths.get(key);
4796
4926
  if (cached) return cached;
4797
4927
  const configuration = execFileSync3(
4798
- path12.join(toolchainBin, "swift"),
4928
+ path13.join(toolchainBin, "swift"),
4799
4929
  [
4800
4930
  "sdk",
4801
4931
  "configure",
@@ -4836,7 +4966,7 @@ function swiftSdkPaths(moduleRoot, toolchainBin) {
4836
4966
  if (flag !== "-fwasm-exceptions") cFlags.push(flag);
4837
4967
  if (flag === "-iframeworkwithsysroot" && options[index + 2] === "-Xcc" && typeof options[index + 3] === "string") {
4838
4968
  cFlags.push(options[index + 3]);
4839
- frameworks.push(path12.join(sysroot, options[index + 3]));
4969
+ frameworks.push(path13.join(sysroot, options[index + 3]));
4840
4970
  index += 3;
4841
4971
  continue;
4842
4972
  }
@@ -4853,7 +4983,7 @@ function swiftSdkPaths(moduleRoot, toolchainBin) {
4853
4983
  }
4854
4984
  const paths = {
4855
4985
  sysroot,
4856
- darwin: path12.join(sysroot, "darwin"),
4986
+ darwin: path13.join(sysroot, "darwin"),
4857
4987
  resources: field("swiftResourcesPath"),
4858
4988
  frameworks,
4859
4989
  cFlags
@@ -4869,19 +4999,19 @@ function swiftAvailableModules(moduleRoot, toolchainBin) {
4869
4999
  if (cached) return cached;
4870
5000
  const modules = new Set(swiftPeachModules(moduleRoot));
4871
5001
  const { resources, frameworks } = swiftSdkPaths(moduleRoot, toolchainBin);
4872
- for (const entry of readdirSync5(path12.join(resources, "wasi"))) {
5002
+ for (const entry of readdirSync5(path13.join(resources, "wasi"))) {
4873
5003
  if (entry.endsWith(".swiftmodule"))
4874
5004
  modules.add(entry.slice(0, -".swiftmodule".length));
4875
5005
  }
4876
5006
  for (const entry of readdirSync5(resources)) {
4877
- const map = path12.join(resources, entry, "module.modulemap");
5007
+ const map = path13.join(resources, entry, "module.modulemap");
4878
5008
  if (!existsSync2(map)) continue;
4879
5009
  for (const match of readFileSync7(map, "utf8").matchAll(/^module\s+([A-Za-z_]\w*)/gm))
4880
5010
  modules.add(match[1]);
4881
5011
  }
4882
5012
  for (const directory of frameworks) {
4883
5013
  for (const entry of readdirSync5(directory)) {
4884
- const map = path12.join(directory, entry, "Modules/module.modulemap");
5014
+ const map = path13.join(directory, entry, "Modules/module.modulemap");
4885
5015
  if (!existsSync2(map)) continue;
4886
5016
  for (const match of readFileSync7(map, "utf8").matchAll(
4887
5017
  /^framework\s+module\s+([A-Za-z_]\w*)/gm
@@ -4905,6 +5035,52 @@ function missingSwiftModules(files, available, providedByFile = () => []) {
4905
5035
  }
4906
5036
  return new Map([...missing].sort(([left], [right]) => left.localeCompare(right)));
4907
5037
  }
5038
+ function swiftSystemLibrarySurface(files, targets) {
5039
+ const modules = /* @__PURE__ */ new Set();
5040
+ const headers = /* @__PURE__ */ new Set();
5041
+ for (const target of targets) {
5042
+ if (!target.systemLibrary) continue;
5043
+ const prefix = target.path === "." ? "" : `${target.path.replace(/\/+$/, "")}/`;
5044
+ for (const [file, contents] of Object.entries(files)) {
5045
+ if (!file.startsWith(prefix) || !file.endsWith(".modulemap")) continue;
5046
+ for (const match of contents.matchAll(/^\s*module\s+([A-Za-z_]\w*)/gm))
5047
+ modules.add(match[1]);
5048
+ for (const match of contents.matchAll(/^\s*(?:umbrella\s+)?header\s+"([^"]+)"/gm)) {
5049
+ const header = files[`${prefix}${match[1]}`];
5050
+ if (header === void 0) continue;
5051
+ for (const include of header.matchAll(/#\s*(?:include|import)\s*<([^>/]+)>/g))
5052
+ headers.add(include[1].replace(/\.h$/, ""));
5053
+ }
5054
+ }
5055
+ }
5056
+ return { modules, headers };
5057
+ }
5058
+ function swiftSystemLibraryExclusions(files, targets, distributionModules) {
5059
+ const surface = swiftSystemLibrarySurface(files, targets);
5060
+ return new Set(
5061
+ distributionModules.filter(
5062
+ (name2) => surface.modules.has(name2) || surface.headers.has(name2)
5063
+ )
5064
+ );
5065
+ }
5066
+ function distributionModulesPath(root, moduleRoot, excluded) {
5067
+ const modules = path13.join(moduleRoot, "modules");
5068
+ if (!excluded || excluded.size === 0) return modules;
5069
+ const key = createHash6("sha256").update([...excluded].sort().join("\0")).digest("hex").slice(0, 16);
5070
+ const directory = path13.join(root, `.peach-modules-${key}`);
5071
+ const complete = path13.join(directory, ".complete");
5072
+ if (!existsSync2(complete)) {
5073
+ mkdirSync2(directory, { recursive: true });
5074
+ for (const entry of readdirSync5(directory))
5075
+ rmSync3(path13.join(directory, entry), { recursive: true, force: true });
5076
+ for (const entry of readdirSync5(modules)) {
5077
+ if (excluded.has(entry.replace(/\.swiftmodule$/, ""))) continue;
5078
+ symlinkSync(path13.join(modules, entry), path13.join(directory, entry));
5079
+ }
5080
+ writeFileSync3(complete, "");
5081
+ }
5082
+ return directory;
5083
+ }
4908
5084
  function swiftTargetDependencies(files, targets) {
4909
5085
  const names = /* @__PURE__ */ new Set([...OPTIONAL_FRAMEWORKS, ...targets.map((target) => target.name)]);
4910
5086
  const siblings = /* @__PURE__ */ new Map();
@@ -4946,15 +5122,17 @@ var FOUNDATION_IMPLICIT_FLAGS = FOUNDATION_IMPLICIT_MODULES.map(
4946
5122
  ).join("");
4947
5123
  var ONE_IMPLICIT_FLAGS = ', "-Xfrontend", "-import-module", "-Xfrontend", "One"';
4948
5124
  var executableLinkFlags = (root) => ` "-Xclang-linker", "-O0",
4949
- "-Xclang-linker", ${JSON.stringify(`-fuse-ld=${path12.join(root, SWIFT_AUTOLINK_LINKER)}`)},
5125
+ "-Xclang-linker", ${JSON.stringify(`-fuse-ld=${path13.join(root, SWIFT_AUTOLINK_LINKER)}`)},
4950
5126
  "-Xlinker", "-z", "-Xlinker", "stack-size=8372224",
4951
5127
  "-Xlinker", "--stack-first",
4952
5128
  "-Xlinker", "--global-base=8372224",
4953
5129
  "-Xlinker", "-lsetjmp",
5130
+ "-Xlinker", "--export-table",
5131
+ "-Xlinker", "--growable-table",
4954
5132
  `;
4955
5133
  var REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
4956
- var MULTI_MANIFEST_VERSION = 46;
4957
- var compilerSourceDigest = true ? "5df98b2ce6152133e55499b786f6b6a1f9f86b4f6b50270401b30b9c782091e3" : swiftCompilerSourceDigest(import.meta.dirname);
5134
+ var MULTI_MANIFEST_VERSION = 50;
5135
+ var compilerSourceDigest = true ? "ef5dd306e582a1e4457110943c56b962bf338a0800b8065a7e15eaaa8a25a9ae" : swiftCompilerSourceDigest(import.meta.dirname);
4958
5136
  function swiftArtifactHash(input, release, moduleRoot) {
4959
5137
  const hash = createHash6("sha256");
4960
5138
  hash.update(`swift-compile
@@ -4963,6 +5141,7 @@ ${release}
4963
5141
  hash.update(compilerSourceDigest);
4964
5142
  if (input.oneModule) hash.update("one-module\n");
4965
5143
  hash.update(swiftModuleDigest(moduleRoot));
5144
+ if (input.lazyDistribution) hash.update("lazy-distribution\n");
4966
5145
  for (const file of Object.keys(input.files).sort()) {
4967
5146
  hash.update(createHash6("sha256").update(file).digest());
4968
5147
  hash.update(createHash6("sha256").update(input.files[file]).digest());
@@ -4998,6 +5177,10 @@ ${release}
4998
5177
  );
4999
5178
  hash.update(JSON.stringify(input.nativeTargets ?? []));
5000
5179
  hash.update(JSON.stringify(input.packageGuestImports ?? []));
5180
+ if (input.defaultLocalization)
5181
+ hash.update(`default-localization
5182
+ ${input.defaultLocalization}
5183
+ `);
5001
5184
  for (const file of Object.keys(input.packageFiles ?? {}).sort()) {
5002
5185
  hash.update(`package-file\0${file}\0`);
5003
5186
  hash.update(createHash6("sha256").update(input.packageFiles[file]).digest());
@@ -5030,7 +5213,7 @@ ${target}
5030
5213
  return hash.digest("hex");
5031
5214
  }
5032
5215
  function swiftCrossImportFlags(moduleRoot, distribution) {
5033
- const overlayRoot = path12.join(
5216
+ const overlayRoot = path13.join(
5034
5217
  moduleRoot,
5035
5218
  distribution ? "modules" : "cross-import-overlays"
5036
5219
  );
@@ -5038,9 +5221,9 @@ function swiftCrossImportFlags(moduleRoot, distribution) {
5038
5221
  "-Xfrontend",
5039
5222
  "-swift-module-cross-import",
5040
5223
  "-Xfrontend",
5041
- path12.basename(path12.dirname(file), ".swiftcrossimport"),
5224
+ path13.basename(path13.dirname(file), ".swiftcrossimport"),
5042
5225
  "-Xfrontend",
5043
- path12.join(overlayRoot, file)
5226
+ path13.join(overlayRoot, file)
5044
5227
  ]);
5045
5228
  }
5046
5229
  function withoutWasmOverlayIsystem(flags) {
@@ -5078,23 +5261,27 @@ function emitSwiftPackageManifest(args) {
5078
5261
  if (spriteKit) {
5079
5262
  for (const name2 of ["SpriteKit", "PeachBox2D", "simd", "GLKit"]) reach(name2);
5080
5263
  }
5264
+ let distributionLinkPath;
5081
5265
  const distributionLink = args.distributionLink;
5082
- if (distribution && !distributionLink)
5083
- throw new Error(
5084
- "swift-compile: distribution linking requires its object response file"
5085
- );
5086
5266
  if (distribution && distributionLink) {
5087
5267
  const objects = distribution.objects.filter(
5088
5268
  (object) => [...OPTIONAL_FRAMEWORKS, "SpriteKit", "PeachBox2D"].every(
5089
5269
  (name2) => !object.startsWith(`lib/${name2}-`) || reachedFrameworks.has(name2)
5090
5270
  )
5091
5271
  );
5092
- distributionLink.files.set(
5093
- distributionLink.path,
5094
- objects.map(
5095
- (object) => `"${path12.join(moduleRoot, object).replaceAll("\\", "\\\\").replaceAll('"', '\\"')}"`
5096
- ).join("\n") + "\n"
5272
+ const quoted = (object) => `"${path13.join(moduleRoot, object).replaceAll("\\", "\\\\").replaceAll('"', '\\"')}"`;
5273
+ const roots = args.lazyDistribution ? swiftObjcRootObjects(distribution.id, moduleRoot, distribution.objects) : null;
5274
+ const list = (roots ? [
5275
+ ...objects.filter((object) => roots.has(object)).map(quoted),
5276
+ "-Wl,--start-lib",
5277
+ ...objects.filter((object) => !roots.has(object)).map(quoted),
5278
+ "-Wl,--end-lib"
5279
+ ] : objects.map(quoted)).join("\n") + "\n";
5280
+ distributionLinkPath = distributionLink.path.replace(
5281
+ /\.rsp$/,
5282
+ `-${createHash6("sha256").update(list).digest("hex").slice(0, 12)}.rsp`
5097
5283
  );
5284
+ distributionLink.files.set(distributionLinkPath, list);
5098
5285
  }
5099
5286
  const overlayFlags = swiftCrossImportFlags(moduleRoot, Boolean(distribution)).map((flag) => `, ${JSON.stringify(flag)}`).join("");
5100
5287
  const executable = targets.find((target) => target.executable);
@@ -5106,14 +5293,16 @@ function emitSwiftPackageManifest(args) {
5106
5293
  const stanza = (target) => {
5107
5294
  const native = args.native?.get(target.name);
5108
5295
  if (target.systemLibrary || native?.clang?.sources.length === 0)
5109
- return ` .systemLibrary(name: ${JSON.stringify(target.name)}, path: ${JSON.stringify(native?.clang ? path12.posix.dirname(native.clang.modulemap) : target.path)}),`;
5296
+ return ` .systemLibrary(name: ${JSON.stringify(target.name)}, path: ${JSON.stringify(native?.clang ? path13.posix.dirname(native.clang.modulemap) : target.path)}),`;
5110
5297
  const isolation = target.mainActorIsolation ? " .defaultIsolation(MainActor.self)," : "";
5111
5298
  const interoperability = target.cxxInterop ? " .interoperabilityMode(.Cxx)," : "";
5112
5299
  const defines = (target.defines ?? []).map((name2) => ` .define(${JSON.stringify(name2)}),`).join("");
5113
5300
  const features = (target.experimentalFeatures ?? []).map((name2) => ` .enableExperimentalFeature(${JSON.stringify(name2)}),`).join("");
5114
5301
  const upcoming = (target.upcomingFeatures ?? []).map((name2) => ` .enableUpcomingFeature(${JSON.stringify(name2)}),`).join("");
5115
5302
  const upstream = (target.swiftFlags ?? []).map((flag) => `, ${JSON.stringify(flag)}`).join("");
5116
- const imports = distribution ? `, "-I", ${JSON.stringify(path12.join(moduleRoot, "modules"))}` : prebuilt ? `, "-I", ${JSON.stringify(prebuilt.modules)}${prebuilt.moduleMaps.map((map) => `, "-Xcc", ${JSON.stringify(`-fmodule-map-file=${map}`)}`).join("")}` : "";
5303
+ const imports = distribution ? `, "-I", ${JSON.stringify(
5304
+ distributionModulesPath(args.root, moduleRoot, args.distributionExcludes)
5305
+ )}` : prebuilt ? `, "-I", ${JSON.stringify(prebuilt.modules)}${prebuilt.moduleMaps.map((map) => `, "-Xcc", ${JSON.stringify(`-fmodule-map-file=${map}`)}`).join("")}` : "";
5117
5306
  const nativeFlags = [
5118
5307
  ...args.nativeFlags?.get(target.name) ?? [],
5119
5308
  ...args.nativeHeaderFlags ?? []
@@ -5145,12 +5334,12 @@ function emitSwiftPackageManifest(args) {
5145
5334
  ].map((flag) => `, ${JSON.stringify(flag)}`).join("");
5146
5335
  const header = args.headerDirectory && [...args.native?.values() ?? []].some(
5147
5336
  (value) => value.late?.producers.includes(target.name)
5148
- ) ? `, "-emit-objc-header-path", ${JSON.stringify(path12.join(args.headerDirectory, `${target.name}-Swift.h`))}` : "";
5337
+ ) ? `, "-emit-objc-header-path", ${JSON.stringify(path13.join(args.headerDirectory, `${target.name}-Swift.h`))}` : "";
5149
5338
  const swiftSettings = `swiftSettings: [.swiftLanguageMode(.v${target.languageMode}),${isolation}${interoperability}${defines}${features}${upcoming} .unsafeFlags(["-Osize", "-Xfrontend", "-enable-cross-import-overlays"${overlayFlags}${FOUNDATION_IMPLICIT_FLAGS}${oneModule ? ONE_IMPLICIT_FLAGS : ""}${imports}${nativeImports}${nativeImportFlags}${objcFlags}${header}${upstream}])]`;
5150
5339
  const deps = [
5151
5340
  .../* @__PURE__ */ new Set([
5152
5341
  ...(target.dependencies ?? []).flatMap(
5153
- (dependency) => dependency.kind === "product" && !(linkedObjects && dependency.package === path12.basename(moduleRoot).toLowerCase()) ? [
5342
+ (dependency) => dependency.kind === "product" && !(linkedObjects && dependency.package === path13.basename(moduleRoot).toLowerCase()) ? [
5154
5343
  `.product(name: ${JSON.stringify(dependency.name)}, package: ${JSON.stringify(dependency.package)})`
5155
5344
  ] : []
5156
5345
  ),
@@ -5179,7 +5368,10 @@ function emitSwiftPackageManifest(args) {
5179
5368
  )
5180
5369
  ])
5181
5370
  ].join(", ");
5182
- const library = distribution && distributionLink ? ["-Xclang-linker", `--config=${distributionLink.path}`, ...distribution.link].map((flag) => `, ${JSON.stringify(flag)}`).join("") : prebuilt ? ["-Xclang-linker", `--config=${prebuilt.linkFile}`, ...prebuilt.link].map((flag) => `, ${JSON.stringify(flag)}`).join("") : "";
5371
+ const library = distribution ? [
5372
+ ...distributionLinkPath ? ["-Xclang-linker", `--config=${distributionLinkPath}`] : [],
5373
+ ...distribution.link
5374
+ ].map((flag) => `, ${JSON.stringify(flag)}`).join("") : prebuilt ? ["-Xclang-linker", `--config=${prebuilt.linkFile}`, ...prebuilt.link].map((flag) => `, ${JSON.stringify(flag)}`).join("") : "";
5183
5375
  const kind = target.executable ? ".executableTarget" : ".target";
5184
5376
  const linkedLibraries = (target.linkedLibraries ?? []).map(
5185
5377
  (name2) => `.linkedLibrary(${JSON.stringify(name2)})`
@@ -5218,8 +5410,8 @@ function emitSwiftPackageManifest(args) {
5218
5410
  ` path: ${JSON.stringify(native?.clang ? "." : target.path)},`,
5219
5411
  ...exclusions.length ? [` exclude: ${JSON.stringify(exclusions)},`] : [],
5220
5412
  ...native?.clang ? [
5221
- ` sources: ${JSON.stringify(native.clang.sources.map((source) => path12.posix.join(native.path, source)))},`,
5222
- ` publicHeadersPath: ${JSON.stringify(path12.posix.dirname(native.clang.modulemap))},`
5413
+ ` sources: ${JSON.stringify(native.clang.sources.map((source) => path13.posix.join(native.path, source)))},`,
5414
+ ` publicHeadersPath: ${JSON.stringify(path13.posix.dirname(native.clang.modulemap))},`
5223
5415
  ] : native?.flags ? [` sources: ${JSON.stringify(native.sources)},`] : [],
5224
5416
  ...!native?.clang && target.publicHeadersPath !== void 0 ? [` publicHeadersPath: ${JSON.stringify(target.publicHeadersPath)},`] : [],
5225
5417
  // the native backend supplies dependency module maps without their
@@ -5235,6 +5427,7 @@ function emitSwiftPackageManifest(args) {
5235
5427
  "// generated by swift-compile from the project package partition.",
5236
5428
  "let package = Package(",
5237
5429
  ' name: "app",',
5430
+ ...args.defaultLocalization ? [` defaultLocalization: ${JSON.stringify(args.defaultLocalization)},`] : [],
5238
5431
  ` products: [.executable(name: "${executable.name}", targets: ["${executable.name}"])],`,
5239
5432
  ` dependencies: [${[
5240
5433
  ...linkedObjects ? [] : [`.package(path: ${JSON.stringify(moduleRoot)})`],
@@ -5262,8 +5455,8 @@ function emitSwiftPackageManifest(args) {
5262
5455
  ` .target(name: ${JSON.stringify(group.name)},`,
5263
5456
  ` dependencies: ${JSON.stringify(native.mixed ? [] : [name2])},`,
5264
5457
  ` path: ${JSON.stringify(native.clang || native.mixed ? "." : native.path)},`,
5265
- ` sources: ${JSON.stringify(native.clang || native.mixed ? group.sources.map((source) => path12.posix.join(native.path, source)) : group.sources)},`,
5266
- ` publicHeadersPath: ${JSON.stringify(native.clang ? path12.posix.dirname(native.clang.modulemap) : native.implementationHeaders ?? "include")},`,
5458
+ ` sources: ${JSON.stringify(native.clang || native.mixed ? group.sources.map((source) => path13.posix.join(native.path, source)) : group.sources)},`,
5459
+ ` publicHeadersPath: ${JSON.stringify(native.clang ? path13.posix.dirname(native.clang.modulemap) : native.implementationHeaders ?? "include")},`,
5267
5460
  ` cSettings: [${macroSettings(owner?.cDefines)} .unsafeFlags(${JSON.stringify([...nativeFlags, ...group.flags])})],`,
5268
5461
  ` cxxSettings: [${macroSettings(owner?.cxxDefines)} .unsafeFlags(${JSON.stringify(["-fno-cxx-modules", ...cxxFlagsFor(nativeFlags), "-I", native.includeDirectory, "-I", args.headerDirectory, ...group.cxxFlags])})]),`
5269
5462
  ]) : [];
@@ -5278,8 +5471,8 @@ function syncSwiftTree(base, files) {
5278
5471
  mkdirSync2(base, { recursive: true });
5279
5472
  const walk = (dir) => {
5280
5473
  for (const entry of readdirSync5(dir, { withFileTypes: true })) {
5281
- const full = path12.join(dir, entry.name);
5282
- if (dir === base && (entry.name === ".build" || entry.name === SWIFT_LINK_STAMP || entry.name === SWIFT_FRAMEWORK_KEY))
5474
+ const full = path13.join(dir, entry.name);
5475
+ if (dir === base && (entry.name === ".build" || entry.name.startsWith(".peach-modules-") || entry.name === SWIFT_LINK_STAMP || entry.name === SWIFT_FRAMEWORK_KEY))
5283
5476
  continue;
5284
5477
  if (entry.isDirectory()) walk(full);
5285
5478
  else if (!files.has(full)) rmSync3(full, { force: true });
@@ -5289,14 +5482,14 @@ function syncSwiftTree(base, files) {
5289
5482
  for (const [full, contents] of files) {
5290
5483
  if (existsSync2(full) && (typeof contents === "string" ? readFileSync7(full, "utf8") === contents : readFileSync7(full).equals(contents)))
5291
5484
  continue;
5292
- mkdirSync2(path12.dirname(full), { recursive: true });
5485
+ mkdirSync2(path13.dirname(full), { recursive: true });
5293
5486
  writeFileSync3(full, contents);
5294
5487
  }
5295
5488
  }
5296
5489
  var DIRECTIVE = /^[ \t]*#(?:if|elseif)\b/;
5297
5490
  var OS_IOS = /\b(?:os\(\s*iOS\s*\)|targetEnvironment\(\s*simulator\s*\))/g;
5298
5491
  var DELEGATE_CLASS = /^class\s+[A-Za-z_]\w*\s*(?:<[^>{]*>)?\s*:[^{]*\b(?:UIApplicationDelegate|UISceneDelegate|UIWindowSceneDelegate)\b[^{]*\{/;
5299
- var REUSABLE_INIT = /^override(?=\s+init\s*\(\s*(?:style\s*:[^,)]*,\s*reuseIdentifier|reuseIdentifier)\s*:)/;
5492
+ var REUSABLE_INIT = /^override(?=\s+(?:(?:public|open|internal)\s+)?init\s*\(\s*(?:style\s*:[^,)]*,\s*reuseIdentifier|reuseIdentifier)\s*:)/;
5300
5493
  var REUSABLE_VIEW_BASES = [
5301
5494
  "UICollectionReusableView",
5302
5495
  "UICollectionViewCell",
@@ -5452,34 +5645,12 @@ function swiftCodeMask(source) {
5452
5645
  return chars.join("");
5453
5646
  }
5454
5647
  var FOUNDATION_NETWORKING_TYPES = /* @__PURE__ */ new Set([
5455
- "CachedURLResponse",
5456
- "HTTPCookieStorage",
5457
- "NSMutableURLRequest",
5458
5648
  "NSURLConnection",
5459
5649
  "NSURLConnectionDataDelegate",
5460
5650
  "NSURLConnectionDelegate",
5461
5651
  "NSURLConnectionDownloadDelegate",
5462
- "URLCache",
5463
- "URLCredentialStorage",
5464
5652
  "URLProtocol",
5465
- "URLProtocolClient",
5466
- "URLRequest",
5467
- "URLSession",
5468
- "URLSessionConfiguration",
5469
- "URLSessionDataDelegate",
5470
- "URLSessionDataTask",
5471
- "URLSessionDelegate",
5472
- "URLSessionDownloadDelegate",
5473
- "URLSessionDownloadTask",
5474
- "URLSessionStreamDelegate",
5475
- "URLSessionStreamTask",
5476
- "URLSessionTask",
5477
- "URLSessionTaskDelegate",
5478
- "URLSessionTaskMetrics",
5479
- "URLSessionTaskTransactionMetrics",
5480
- "URLSessionUploadTask",
5481
- "URLSessionWebSocketDelegate",
5482
- "URLSessionWebSocketTask"
5653
+ "URLProtocolClient"
5483
5654
  ]);
5484
5655
  var FOUNDATION_OVERLAY_TYPES = /* @__PURE__ */ new Set([
5485
5656
  "AsyncCharacterSequence",
@@ -5505,6 +5676,7 @@ var FOUNDATION_OVERLAY_TYPES = /* @__PURE__ */ new Set([
5505
5676
  "NSCollectionChangeType",
5506
5677
  "NSConditionLock",
5507
5678
  "NSDataDetector",
5679
+ "NSErrorPointer",
5508
5680
  "NSException",
5509
5681
  "NSExtensionContext",
5510
5682
  "NSExtensionItem",
@@ -6133,6 +6305,15 @@ var CORE_FOUNDATION_HANDLE_IMPORTS = [
6133
6305
  "import typealias CoreFoundation.CFTypeRef",
6134
6306
  "import CoreGraphics"
6135
6307
  ]).join("; ");
6308
+ function foundationOwnerOf(name2) {
6309
+ if (name2 === "NSClassFromString" || name2 === "NSKeyValueChange" || name2 === "NSKeyValueObservedChange" || name2 === "NSKeyValueObservation")
6310
+ return "PeachObjC";
6311
+ if (name2 === "DispatchData") return "Dispatch";
6312
+ if (FOUNDATION_NETWORKING_TYPES.has(name2)) return "FoundationNetworking";
6313
+ if (FOUNDATION_OVERLAY_TYPES.has(name2) || FOUNDATION_OVERLAY_GLOBALS.has(name2) || CORE_FOUNDATION_OVERLAY_GLOBALS.has(name2))
6314
+ return "PeachFoundation";
6315
+ return void 0;
6316
+ }
6136
6317
  function swiftSourceAsIOS(source) {
6137
6318
  const { lineStarts, tokens } = swiftCodeScan(source);
6138
6319
  let offset = 0;
@@ -6188,16 +6369,7 @@ function swiftSourceAsIOS(source) {
6188
6369
  }
6189
6370
  const foundationMember = /^Foundation\s*\.\s*(?:`([A-Za-z_]\w*)`|([A-Za-z_]\w*)\b)/.exec(rest);
6190
6371
  const foundationName = foundationMember?.[1] ?? foundationMember?.[2];
6191
- let foundationOwner;
6192
- if (foundationName !== void 0) {
6193
- if (foundationName === "NSClassFromString" || foundationName === "NSKeyValueChange" || foundationName === "NSKeyValueObservedChange" || foundationName === "NSKeyValueObservation")
6194
- foundationOwner = "PeachObjC";
6195
- else if (foundationName === "DispatchData") foundationOwner = "Dispatch";
6196
- else if (FOUNDATION_NETWORKING_TYPES.has(foundationName))
6197
- foundationOwner = "FoundationNetworking";
6198
- else if (FOUNDATION_OVERLAY_TYPES.has(foundationName) || FOUNDATION_OVERLAY_GLOBALS.has(foundationName) || CORE_FOUNDATION_OVERLAY_GLOBALS.has(foundationName))
6199
- foundationOwner = "PeachFoundation";
6200
- }
6372
+ const foundationOwner = foundationName === void 0 ? void 0 : foundationOwnerOf(foundationName);
6201
6373
  if (foundationOwner !== void 0) {
6202
6374
  out += conditioned.slice(copied, at) + foundationOwner;
6203
6375
  copied = at + "Foundation".length;
@@ -6309,11 +6481,16 @@ function swiftApplicationEntry(file, source) {
6309
6481
  else if (source[at] === "}") depth--;
6310
6482
  else if (depth === 0 && /^@(?:main|UIApplicationMain)\b/.test(source.slice(at)))
6311
6483
  return true;
6312
- else if (depth === 0 && path12.basename(file) === "main.swift" && /^UIApplicationMain\s*\(/.test(source.slice(at)))
6484
+ else if (depth === 0 && path13.basename(file) === "main.swift" && /^UIApplicationMain\s*\(/.test(source.slice(at)))
6313
6485
  return true;
6314
6486
  }
6315
6487
  return false;
6316
6488
  }
6489
+ function swiftTypedApplicationEntry(source) {
6490
+ const code = [...swiftConditionalLines(swiftCodeMask(source))].map(({ line, active }) => active === false ? " ".repeat(line.length) : line).join("\n");
6491
+ const match = /@main\b[\s\S]*?\b(?:struct|class|enum)\s+([A-Za-z_]\w*)/.exec(code);
6492
+ return match ? { index: match.index, name: match[1] } : null;
6493
+ }
6317
6494
  function wrapUIApplicationMainEntry(source) {
6318
6495
  const code = [...swiftConditionalLines(swiftCodeMask(source))].map(({ line, active }) => active === false ? " ".repeat(line.length) : line).join("\n");
6319
6496
  const { tokens } = swiftCodeScan(code);
@@ -6665,14 +6842,14 @@ function prepareSwiftDependency(source, destination) {
6665
6842
  for (const entry of readdirSync5(from, { withFileTypes: true })) {
6666
6843
  if (entry.name === ".git" || entry.name === ".build" || entry.name === ".swiftpm")
6667
6844
  continue;
6668
- const file = path12.join(from, entry.name);
6845
+ const file = path13.join(from, entry.name);
6669
6846
  if (entry.isDirectory()) gather(file);
6670
6847
  else if (entry.isFile() && entry.name.endsWith(".swift"))
6671
- origins[path12.relative(source, file)] = readFileSync7(file, "utf8");
6848
+ origins[path13.relative(source, file)] = readFileSync7(file, "utf8");
6672
6849
  }
6673
6850
  };
6674
6851
  gather(source);
6675
- const manifest = path12.join(source, "Package.swift");
6852
+ const manifest = path13.join(source, "Package.swift");
6676
6853
  const targets = existsSync2(manifest) ? swiftManifestTargets(readFileSync7(manifest, "utf8")) : [];
6677
6854
  const compiled = compiledSwiftSources(origins, targets);
6678
6855
  const copy = (from, to) => {
@@ -6680,11 +6857,11 @@ function prepareSwiftDependency(source, destination) {
6680
6857
  for (const entry of readdirSync5(from, { withFileTypes: true })) {
6681
6858
  if (entry.name === ".git" || entry.name === ".build" || entry.name === ".swiftpm")
6682
6859
  continue;
6683
- const file = path12.join(from, entry.name);
6684
- const target = path12.join(to, entry.name);
6860
+ const file = path13.join(from, entry.name);
6861
+ const target = path13.join(to, entry.name);
6685
6862
  if (entry.isDirectory()) copy(file, target);
6686
6863
  else if (entry.isFile() && entry.name.endsWith(".swift"))
6687
- writeFileSync3(target, compiled.get(path12.relative(source, file)));
6864
+ writeFileSync3(target, compiled.get(path13.relative(source, file)));
6688
6865
  else cpSync(file, target, { verbatimSymlinks: true });
6689
6866
  }
6690
6867
  };
@@ -6693,18 +6870,18 @@ function prepareSwiftDependency(source, destination) {
6693
6870
  var HIDDEN_UNITS = "PeachHiddenUnits";
6694
6871
  function clangImportModuleMapFlags(settings, layoutRoot, written) {
6695
6872
  const searched = new Set(settings.headerSearchPaths);
6696
- const directory = path12.join(layoutRoot, ".build", "peach-clang-modulemaps");
6873
+ const directory = path13.join(layoutRoot, ".build", "peach-clang-modulemaps");
6697
6874
  return (settings.moduleMaps ?? []).flatMap((map) => {
6698
- const headers = path12.join(layoutRoot, map.headers);
6875
+ const headers = path13.join(layoutRoot, map.headers);
6699
6876
  if (!existsSync2(headers)) return [];
6700
- const published = path12.join(headers, "module.modulemap");
6877
+ const published = path13.join(headers, "module.modulemap");
6701
6878
  if (searched.has(map.headers) && existsSync2(published)) return [];
6702
6879
  if (!searched.has(map.headers) && existsSync2(published))
6703
6880
  return [`-fmodule-map-file=${published}`];
6704
6881
  const cached = written.get(headers);
6705
6882
  if (cached) return [cached];
6706
6883
  mkdirSync2(directory, { recursive: true });
6707
- const output = path12.join(directory, `module-${written.size}.modulemap`);
6884
+ const output = path13.join(directory, `module-${written.size}.modulemap`);
6708
6885
  writeFileSync3(
6709
6886
  output,
6710
6887
  swiftPackageClangModuleMap(swiftTargetModuleName(map.module), {
@@ -6740,13 +6917,14 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
6740
6917
  const targets = distribution && compileTargets(input).length === 0 ? [
6741
6918
  {
6742
6919
  name: "App",
6743
- path: path12.relative(layout.root, layout.sources),
6920
+ path: path13.relative(layout.root, layout.sources),
6744
6921
  executable: true,
6745
6922
  languageMode: 5,
6746
6923
  mainActorIsolation: false,
6747
6924
  resources: false
6748
6925
  }
6749
6926
  ] : compileTargets(input);
6927
+ const distributionExcludes = distribution ? swiftSystemLibraryExclusions(input.files, targets, distribution.modules) : void 0;
6750
6928
  const files = /* @__PURE__ */ new Map();
6751
6929
  const native = /* @__PURE__ */ new Map();
6752
6930
  const targetFailures = [];
@@ -6762,26 +6940,34 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
6762
6940
  if (target) swiftTargets.add(target.name);
6763
6941
  }
6764
6942
  const importedModules = /* @__PURE__ */ new Set();
6943
+ const swiftImportedModules = /* @__PURE__ */ new Set();
6944
+ const clangImportedModules = /* @__PURE__ */ new Set();
6765
6945
  for (const [file, contents] of Object.entries(input.files)) {
6766
6946
  if (file.endsWith(".swift"))
6767
- for (const name2 of swiftImportNames(contents)) importedModules.add(name2);
6947
+ for (const name2 of swiftImportNames(contents)) {
6948
+ importedModules.add(name2);
6949
+ swiftImportedModules.add(name2);
6950
+ }
6768
6951
  else if (SWIFT_NATIVE_SOURCE_EXTENSIONS.some(
6769
6952
  (extension) => extension !== ".modulemap" && file.endsWith(extension)
6770
6953
  ))
6771
- for (const name2 of clangImportNames(contents)) importedModules.add(name2);
6954
+ for (const name2 of clangImportNames(contents)) {
6955
+ importedModules.add(name2);
6956
+ clangImportedModules.add(name2);
6957
+ }
6772
6958
  }
6773
- const headerDirectory = path12.join(layout.root, ".build", "peach-cxx-headers");
6959
+ const headerDirectory = path13.join(layout.root, ".build", "peach-cxx-headers");
6774
6960
  let checkedToolchain;
6775
6961
  const nativeToolchain = () => {
6776
6962
  if (checkedToolchain) return checkedToolchain;
6777
- const pin = distribution ?? JSON.parse(readFileSync7(path12.join(moduleRoot, "toolchain.json"), "utf8"));
6963
+ const pin = distribution ?? JSON.parse(readFileSync7(path13.join(moduleRoot, "toolchain.json"), "utf8"));
6778
6964
  checkedToolchain = swiftToolchain(pin.release, swiftModuleSdk(moduleRoot));
6779
6965
  return checkedToolchain;
6780
6966
  };
6781
6967
  const deploymentTarget = (name2) => input.nativeTargets?.find((value) => value.name === name2)?.deploymentTarget ?? targets.find((value) => value.name === name2)?.iosDeploymentTarget ?? null;
6782
6968
  const targetStagedFiles = /* @__PURE__ */ new Map();
6783
6969
  const stageTargetFile = (target, file, contents, options) => {
6784
- const relative = path12.relative(layout.root, file).split(path12.sep).join(path12.posix.sep);
6970
+ const relative = path13.relative(layout.root, file).split(path13.sep).join(path13.posix.sep);
6785
6971
  const prior = files.has(file) ? files.get(file) : Object.hasOwn(input.files, relative) ? input.files[relative] : void 0;
6786
6972
  if (!options?.allowExisting && prior !== void 0)
6787
6973
  throw new Error(`target ${target} already contains generated output ${relative}`);
@@ -6810,7 +6996,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
6810
6996
  targetStagedFiles.delete(target.name);
6811
6997
  if (entries.some(([file]) => isSwiftNativeTranslationUnit(file)) && (swift || input.nativeTargets?.some((value) => value.name === target.name))) {
6812
6998
  if (!swift) {
6813
- const unprepared = path12.join(
6999
+ const unprepared = path13.join(
6814
7000
  layout.root,
6815
7001
  target.path,
6816
7002
  "PeachUnprepared.generated.swift"
@@ -6825,7 +7011,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
6825
7011
  native.set(target.name, {
6826
7012
  mixed: true,
6827
7013
  path: target.path,
6828
- includeDirectory: path12.join(layout.root, target.path, "include"),
7014
+ includeDirectory: path13.join(layout.root, target.path, "include"),
6829
7015
  sources: [],
6830
7016
  lateSources: [],
6831
7017
  exclude: entries.filter(([file]) => !file.endsWith(".swift") && !file.endsWith(".metal")).map(([file]) => file.slice(prefix.length))
@@ -6837,27 +7023,27 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
6837
7023
  const contents = input.files[file];
6838
7024
  if (contents === void 0)
6839
7025
  throw new Error(`missing original Objective-C header ${file}`);
6840
- const destination = path12.join(layout.root, file);
6841
- mkdirSync2(path12.dirname(destination), { recursive: true });
7026
+ const destination = path13.join(layout.root, file);
7027
+ mkdirSync2(path13.dirname(destination), { recursive: true });
6842
7028
  writeFileSync3(destination, contents);
6843
7029
  files.set(destination, contents);
6844
7030
  }
6845
7031
  if (!settings.flattensPublicHeaders) continue;
6846
7032
  for (const header of settings.publicHeaders) {
6847
- const destination = path12.join(headerDirectory, settings.name, path12.basename(header));
7033
+ const destination = path13.join(headerDirectory, settings.name, path13.basename(header));
6848
7034
  if (files.has(destination))
6849
7035
  throw new Error(`duplicate product header ${destination}`);
6850
- const contents = `#import ${JSON.stringify(path12.join(layout.root, header))}
7036
+ const contents = `#import ${JSON.stringify(path13.join(layout.root, header))}
6851
7037
  `;
6852
7038
  files.set(destination, contents);
6853
- mkdirSync2(path12.dirname(destination), { recursive: true });
7039
+ mkdirSync2(path13.dirname(destination), { recursive: true });
6854
7040
  writeFileSync3(destination, contents);
6855
7041
  }
6856
7042
  }
6857
7043
  const nativeTargets = input.nativeTargets ?? [];
6858
- const fromInputRoot = (file) => file.startsWith(`${SWIFT_NATIVE_INPUT_ROOT}/`) ? path12.join(layout.root, file.slice(SWIFT_NATIVE_INPUT_ROOT.length + 1)) : file;
7044
+ const fromInputRoot = (file) => file.startsWith(`${SWIFT_NATIVE_INPUT_ROOT}/`) ? path13.join(layout.root, file.slice(SWIFT_NATIVE_INPUT_ROOT.length + 1)) : file;
6859
7045
  const headerSearch = writeXcodeHeaderSearch(
6860
- path12.join(layout.root, ".build", "peach-xcode-headers"),
7046
+ path13.join(layout.root, ".build", "peach-xcode-headers"),
6861
7047
  nativeTargets.map((settings) => ({
6862
7048
  headerMaps: settings.headerMaps.map((map) => ({
6863
7049
  flag: map.flag,
@@ -6868,12 +7054,12 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
6868
7054
  })),
6869
7055
  productHeaders: Object.fromEntries(
6870
7056
  Object.entries(settings.productHeaders).map(([product, file]) => [
6871
- path12.join(layout.root, product),
6872
- path12.join(layout.root, file)
7057
+ path13.join(layout.root, product),
7058
+ path13.join(layout.root, file)
6873
7059
  ])
6874
7060
  ),
6875
7061
  userHeaderSearchPaths: settings.userHeaderSearchPaths.map(
6876
- (directory) => path12.join(layout.root, directory)
7062
+ (directory) => path13.join(layout.root, directory)
6877
7063
  )
6878
7064
  }))
6879
7065
  );
@@ -6897,7 +7083,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
6897
7083
  if (producer && targets.some((value) => value.name === producer))
6898
7084
  producers2.add(producer);
6899
7085
  const local = [
6900
- path12.posix.join(path12.posix.dirname(file), include2),
7086
+ path13.posix.join(path13.posix.dirname(file), include2),
6901
7087
  `${includes}${include2}`
6902
7088
  ].find((candidate) => input.files[candidate] !== void 0);
6903
7089
  if (local) {
@@ -6931,12 +7117,12 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
6931
7117
  const headers = settings.headers;
6932
7118
  const roots2 = settings.bridgingHeader ? [settings.bridgingHeader] : entries.some(([file]) => file.endsWith(".swift")) || importedModules.has(swiftTargetModuleName(target.name)) ? settings.publicHeaders : [];
6933
7119
  for (const file of headers) {
6934
- const destination = path12.join(layout.root, file);
6935
- mkdirSync2(path12.dirname(destination), { recursive: true });
7120
+ const destination = path13.join(layout.root, file);
7121
+ mkdirSync2(path13.dirname(destination), { recursive: true });
6936
7122
  writeFileSync3(destination, input.files[file]);
6937
7123
  }
6938
7124
  const search = [.../* @__PURE__ */ new Set([...settings?.headerSearchPaths ?? []])].flatMap(
6939
- (dir) => ["-I", path12.join(layout.root, dir)]
7125
+ (dir) => ["-I", path13.join(layout.root, dir)]
6940
7126
  );
6941
7127
  const toolchainBin = nativeToolchain();
6942
7128
  const stageFlags = (flags2, sdkInclude2) => flags2.map(
@@ -6948,7 +7134,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
6948
7134
  ...search,
6949
7135
  ...(settings?.frameworkSearchPaths ?? []).flatMap((dir) => [
6950
7136
  "-F",
6951
- path12.join(layout.root, dir)
7137
+ path13.join(layout.root, dir)
6952
7138
  ]),
6953
7139
  "-I",
6954
7140
  headerDirectory
@@ -6959,13 +7145,13 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
6959
7145
  const flag = settings.flags[index];
6960
7146
  if (flag === "-I" || flag === "-iquote") {
6961
7147
  const directory = settings.flags[index + 1];
6962
- if (directory === void 0 || !path12.isAbsolute(directory)) {
7148
+ if (directory === void 0 || !path13.isAbsolute(directory)) {
6963
7149
  index++;
6964
7150
  continue;
6965
7151
  }
6966
7152
  }
6967
7153
  const joined = /^-(?:I|iquote)(.+)$/.exec(flag);
6968
- if (joined && !path12.isAbsolute(joined[1])) continue;
7154
+ if (joined && !path13.isAbsolute(joined[1])) continue;
6969
7155
  kept.push(flag);
6970
7156
  }
6971
7157
  return [
@@ -6974,18 +7160,18 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
6974
7160
  ...search,
6975
7161
  ...(settings?.frameworkSearchPaths ?? []).flatMap((dir) => [
6976
7162
  "-F",
6977
- path12.join(layout.root, dir)
7163
+ path13.join(layout.root, dir)
6978
7164
  ]),
6979
7165
  "-I",
6980
7166
  headerDirectory
6981
7167
  ];
6982
7168
  })();
6983
- const sdkInclude = path12.join(
7169
+ const sdkInclude = path13.join(
6984
7170
  swiftSdkPaths(moduleRoot, toolchainBin).sysroot,
6985
7171
  "darwin/usr/include"
6986
7172
  );
6987
7173
  const flags = stageFlags(originalFlags, sdkInclude);
6988
- const prefixHeader = settings?.prefixHeader ? ["-include", path12.join(layout.root, settings.prefixHeader)] : [];
7174
+ const prefixHeader = settings?.prefixHeader ? ["-include", path13.join(layout.root, settings.prefixHeader)] : [];
6989
7175
  const bundleName = entries.some(([file]) => file.endsWith(".swift")) ? void 0 : swiftObjCResourceBundleName({
6990
7176
  target: target.name,
6991
7177
  path: target.path,
@@ -6996,7 +7182,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
6996
7182
  bundles: input.resourceBundles
6997
7183
  });
6998
7184
  const accessor = bundleName === void 0 ? void 0 : swiftObjCResourceAccessor(bundleName);
6999
- const accessorHeader = path12.join(
7185
+ const accessorHeader = path13.join(
7000
7186
  layout.root,
7001
7187
  target.path,
7002
7188
  OBJC_RESOURCE_ACCESSOR_HEADER
@@ -7007,7 +7193,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
7007
7193
  const nativeUnits = accessor ? [...units, [accessorUnit, accessor.body]] : units;
7008
7194
  const unitSource = (file) => {
7009
7195
  const relative = file.slice(prefix.length);
7010
- return relative.split("/").some((part) => part.startsWith(".")) ? path12.posix.join(HIDDEN_UNITS, relative.replaceAll(/(^|\/)\./g, "$1%2E")) : relative;
7196
+ return relative.split("/").some((part) => part.startsWith(".")) ? path13.posix.join(HIDDEN_UNITS, relative.replaceAll(/(^|\/)\./g, "$1%2E")) : relative;
7011
7197
  };
7012
7198
  const accessorFlags = accessor ? ["-include", accessorHeader] : [];
7013
7199
  const nativeC = !entries.some(([file]) => file.endsWith(".swift"));
@@ -7037,20 +7223,20 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
7037
7223
  )
7038
7224
  ].sort();
7039
7225
  const topHeaders = settings.publicHeaders.filter(
7040
- (file) => path12.posix.dirname(file) === headerDir
7226
+ (file) => path13.posix.dirname(file) === headerDir
7041
7227
  );
7042
7228
  if (input.files[custom] !== void 0) {
7043
7229
  swiftpmModuleMap = { path: custom, contents: input.files[custom] };
7044
7230
  } else if (input.files[umbrella] !== void 0) {
7045
7231
  if (siblingDirs.length > 0)
7046
7232
  throw new Error(
7047
- `target ${target.name} has invalid header layout: umbrella header found at '${path12.join(layout.root, umbrella)}', but directories exist next to it: ${siblingDirs.map((name2) => path12.join(layout.root, headerDir, name2)).join(", ")}; consider removing them`
7233
+ `target ${target.name} has invalid header layout: umbrella header found at '${path13.join(layout.root, umbrella)}', but directories exist next to it: ${siblingDirs.map((name2) => path13.join(layout.root, headerDir, name2)).join(", ")}; consider removing them`
7048
7234
  );
7049
7235
  swiftpmModuleMap = {
7050
7236
  path: custom,
7051
7237
  contents: swiftPackageClangModuleMap(moduleName, {
7052
7238
  kind: "header",
7053
- path: path12.join(layout.root, umbrella)
7239
+ path: path13.join(layout.root, umbrella)
7054
7240
  })
7055
7241
  };
7056
7242
  } else if (input.files[nestedUmbrella] !== void 0 && siblingDirs.length === 1 && siblingDirs[0] === moduleName && topHeaders.length === 0) {
@@ -7058,7 +7244,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
7058
7244
  path: custom,
7059
7245
  contents: swiftPackageClangModuleMap(moduleName, {
7060
7246
  kind: "header",
7061
- path: path12.join(layout.root, nestedUmbrella)
7247
+ path: path13.join(layout.root, nestedUmbrella)
7062
7248
  })
7063
7249
  };
7064
7250
  } else {
@@ -7066,12 +7252,12 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
7066
7252
  path: custom,
7067
7253
  contents: swiftPackageClangModuleMap(moduleName, {
7068
7254
  kind: "directory",
7069
- path: path12.join(layout.root, headerDir)
7255
+ path: path13.join(layout.root, headerDir)
7070
7256
  })
7071
7257
  };
7072
7258
  }
7073
7259
  }
7074
- const modulemap = originalModuleMap?.[0] ?? swiftpmModuleMap?.path ?? packageModuleMap?.[0] ?? path12.posix.join(
7260
+ const modulemap = originalModuleMap?.[0] ?? swiftpmModuleMap?.path ?? packageModuleMap?.[0] ?? path13.posix.join(
7075
7261
  ".build",
7076
7262
  "peach-objc-originals",
7077
7263
  target.name,
@@ -7079,41 +7265,41 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
7079
7265
  );
7080
7266
  const moduleContents = originalModuleMap ? input.files[originalModuleMap[1]] : swiftpmModuleMap?.contents ?? packageModuleMap?.[1] ?? swiftObjCModuleMap(
7081
7267
  swiftTargetModuleName(target.name),
7082
- roots2.map((file) => path12.join(layout.root, file))
7268
+ roots2.map((file) => path13.join(layout.root, file))
7083
7269
  );
7084
7270
  if (moduleContents === void 0)
7085
7271
  throw new Error("missing original module map " + modulemap);
7086
- stageTargetFile(target.name, path12.join(layout.root, modulemap), moduleContents, {
7272
+ stageTargetFile(target.name, path13.join(layout.root, modulemap), moduleContents, {
7087
7273
  allowExisting: true
7088
7274
  });
7089
7275
  const importFlags = [
7090
- ...stageFlags(importOriginalFlags, sdkInclude),
7091
- "-fmodule-map-file=" + path12.join(layout.root, modulemap),
7276
+ ...swiftClangImporterFlags(stageFlags(importOriginalFlags, sdkInclude)),
7277
+ "-fmodule-map-file=" + path13.join(layout.root, modulemap),
7092
7278
  ...clangImportModuleMapFlags(settings, layout.root, importModuleMaps)
7093
7279
  ];
7094
7280
  const groups = /* @__PURE__ */ new Map();
7095
7281
  for (const [file, contents] of nativeUnits) {
7096
7282
  const origin = settings?.sourceDirectories[file];
7097
7283
  if (origin) {
7098
- const original = path12.join(layout.root, origin, path12.posix.basename(file));
7099
- mkdirSync2(path12.dirname(original), { recursive: true });
7284
+ const original = path13.join(layout.root, origin, path13.posix.basename(file));
7285
+ mkdirSync2(path13.dirname(original), { recursive: true });
7100
7286
  stageTargetFile(target.name, original, contents, { allowExisting: true });
7101
7287
  }
7102
7288
  const source = unitSource(file);
7103
7289
  if (source !== file.slice(prefix.length))
7104
7290
  stageTargetFile(
7105
7291
  target.name,
7106
- path12.join(layout.root, target.path, source),
7292
+ path13.join(layout.root, target.path, source),
7107
7293
  contents,
7108
7294
  {
7109
7295
  allowExisting: true
7110
7296
  }
7111
7297
  );
7112
7298
  const perFile = [
7113
- ...origin ? ["-iquote", path12.join(layout.root, origin)] : [],
7299
+ ...origin ? ["-iquote", path13.join(layout.root, origin)] : [],
7114
7300
  ...stageFlags(
7115
7301
  settings?.fileFlags[file] ?? [],
7116
- path12.join(
7302
+ path13.join(
7117
7303
  swiftSdkPaths(moduleRoot, toolchainBin).sysroot,
7118
7304
  "darwin/usr/include"
7119
7305
  )
@@ -7131,7 +7317,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
7131
7317
  ...accessorFlags,
7132
7318
  ...stageFlags(
7133
7319
  cxx ? settings.cxxFlags : [],
7134
- path12.join(
7320
+ path13.join(
7135
7321
  swiftSdkPaths(moduleRoot, toolchainBin).sysroot,
7136
7322
  "darwin/usr/include"
7137
7323
  )
@@ -7146,7 +7332,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
7146
7332
  stageTargetFile(target.name, accessorHeader, accessor.header);
7147
7333
  stageTargetFile(
7148
7334
  target.name,
7149
- path12.join(layout.root, accessorUnit),
7335
+ path13.join(layout.root, accessorUnit),
7150
7336
  accessor.body
7151
7337
  );
7152
7338
  }
@@ -7161,7 +7347,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
7161
7347
  ].sort();
7162
7348
  native.set(target.name, {
7163
7349
  path: target.path,
7164
- includeDirectory: path12.dirname(path12.join(layout.root, modulemap)),
7350
+ includeDirectory: path13.dirname(path13.join(layout.root, modulemap)),
7165
7351
  importFlags,
7166
7352
  sources: nativeUnits.map(([file]) => unitSource(file)),
7167
7353
  lateSources: implementations.flatMap((group) => group.sources),
@@ -7179,15 +7365,15 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
7179
7365
  });
7180
7366
  continue;
7181
7367
  }
7182
- const implementationHeaders = path12.posix.join(
7368
+ const implementationHeaders = path13.posix.join(
7183
7369
  ".build",
7184
7370
  "peach-objc-implementations",
7185
7371
  target.name
7186
7372
  );
7187
- const include2 = path12.join(layout.root, implementationHeaders);
7373
+ const include2 = path13.join(layout.root, implementationHeaders);
7188
7374
  stageTargetFile(
7189
7375
  target.name,
7190
- path12.join(include2, "module.modulemap"),
7376
+ path13.join(include2, "module.modulemap"),
7191
7377
  `module ${target.name}ImplementationDeclarations { export * }
7192
7378
  `
7193
7379
  );
@@ -7198,7 +7384,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
7198
7384
  implementationHeaders,
7199
7385
  importFlags,
7200
7386
  swiftFlags: [
7201
- ...settings.bridgingHeader ? ["-import-objc-header", path12.join(layout.root, settings.bridgingHeader)] : roots2.length ? ["-import-underlying-module"] : [],
7387
+ ...settings.bridgingHeader ? ["-import-objc-header", path13.join(layout.root, settings.bridgingHeader)] : roots2.length ? ["-import-underlying-module"] : [],
7202
7388
  ...importFlags.flatMap((flag) => ["-Xcc", flag])
7203
7389
  ],
7204
7390
  sources: nativeUnits.map(([file]) => unitSource(file)),
@@ -7228,7 +7414,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
7228
7414
  }
7229
7415
  native.set(target.name, {
7230
7416
  path: target.path,
7231
- includeDirectory: path12.join(layout.root, includes),
7417
+ includeDirectory: path13.join(layout.root, includes),
7232
7418
  sources: units.map(([file]) => file.slice(prefix.length)),
7233
7419
  lateSources: late.map(([file]) => file.slice(prefix.length)),
7234
7420
  ...late.length > 0 ? {
@@ -7246,7 +7432,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
7246
7432
  ([file]) => file.startsWith(includes) && /\.(?:h|hpp|hh|hxx)$/.test(file) && consumers.get(file).size === 0
7247
7433
  );
7248
7434
  files.set(
7249
- path12.join(layout.root, includes, "module.modulemap"),
7435
+ path13.join(layout.root, includes, "module.modulemap"),
7250
7436
  [
7251
7437
  `module ${target.name} {`,
7252
7438
  ...roots.map(
@@ -7264,10 +7450,10 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
7264
7450
  [...native.values()].flatMap((value) => value.late?.producers ?? [])
7265
7451
  )) {
7266
7452
  files.set(
7267
- path12.join(headerDirectory, name2, name2 + "-Swift.h"),
7453
+ path13.join(headerDirectory, name2, name2 + "-Swift.h"),
7268
7454
  '#include "../' + name2 + '-Swift.h"\n'
7269
7455
  );
7270
- const modulemap = path12.join(
7456
+ const modulemap = path13.join(
7271
7457
  layout.root,
7272
7458
  ".build",
7273
7459
  "peach-objc-swift-headers",
@@ -7277,8 +7463,8 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
7277
7463
  files.set(
7278
7464
  modulemap,
7279
7465
  swiftObjCModuleMap(swiftTargetModuleName(name2), [
7280
- ...(input.nativeTargets?.find((target) => target.name === name2)?.publicHeaders ?? []).map((header) => path12.join(layout.root, header)),
7281
- path12.join(headerDirectory, name2 + "-Swift.h")
7466
+ ...(input.nativeTargets?.find((target) => target.name === name2)?.publicHeaders ?? []).map((header) => path13.join(layout.root, header)),
7467
+ path13.join(headerDirectory, name2 + "-Swift.h")
7282
7468
  ])
7283
7469
  );
7284
7470
  nativeHeaderFlags.push("-fmodule-map-file=" + modulemap);
@@ -7287,7 +7473,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
7287
7473
  swiftModuleInputFiles(moduleRoot).join("\n")
7288
7474
  );
7289
7475
  if (!distribution) {
7290
- modulePlan.update(readFileSync7(path12.join(moduleRoot, "Package.swift")));
7476
+ modulePlan.update(readFileSync7(path13.join(moduleRoot, "Package.swift")));
7291
7477
  }
7292
7478
  const resourcePlan = createHash6("sha256").update(
7293
7479
  JSON.stringify(
@@ -7321,22 +7507,20 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
7321
7507
  )
7322
7508
  );
7323
7509
  const mains = entries.flatMap(([file, source]) => {
7324
- const match = /@main\b[\s\S]*?\b(?:struct|class|enum)\s+([A-Za-z_]\w*)/.exec(
7325
- swiftCodeMask(source)
7326
- );
7327
- return match ? [{ file, source, match }] : [];
7510
+ const entry = swiftTypedApplicationEntry(source);
7511
+ return entry ? [{ file, source, ...entry }] : [];
7328
7512
  });
7329
7513
  let entryFile;
7330
7514
  let entrySource;
7331
7515
  if (mains.length === 1) {
7332
7516
  const main = mains[0];
7333
7517
  entryFile = main.file;
7334
- entrySource = main.source.slice(0, main.match.index) + " " + main.source.slice(main.match.index + 5) + `
7335
- @MainActor public func __peachRunApplication() { ${main.match[1]}.main() }
7518
+ entrySource = main.source.slice(0, main.index) + " " + main.source.slice(main.index + 5) + `
7519
+ @MainActor public func __peachRunApplication() { ${main.name}.main() }
7336
7520
  `;
7337
7521
  } else if (mains.length === 0) {
7338
7522
  const procedural = entries.filter(
7339
- ([file, source]) => path12.basename(file) === "main.swift" && swiftApplicationEntry(file, source)
7523
+ ([file, source]) => path13.basename(file) === "main.swift" && swiftApplicationEntry(file, source)
7340
7524
  );
7341
7525
  const wrapped = procedural.length === 1 ? wrapUIApplicationMainEntry(procedural[0][1]) : null;
7342
7526
  if (!wrapped)
@@ -7365,7 +7549,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
7365
7549
  exclude: []
7366
7550
  });
7367
7551
  files.set(
7368
- path12.join(layout.root, `PeachApplication/${name2}/Entry.swift`),
7552
+ path13.join(layout.root, `PeachApplication/${name2}/Entry.swift`),
7369
7553
  `import ${swiftTargetModuleName(target.name)}
7370
7554
  @main struct __PeachApplicationEntry { @MainActor static func main() { __peachRunApplication() } }
7371
7555
  `
@@ -7375,7 +7559,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
7375
7559
  const nativeFlags = native.size > 0 ? /* @__PURE__ */ new Map() : void 0;
7376
7560
  if (nativeFlags) {
7377
7561
  const toolchainBin = nativeToolchain();
7378
- const headers = path12.join(swiftSdkPaths(moduleRoot, toolchainBin).sysroot, "darwin");
7562
+ const headers = path13.join(swiftSdkPaths(moduleRoot, toolchainBin).sysroot, "darwin");
7379
7563
  for (const target of targets) {
7380
7564
  const version = deploymentTarget(target.name);
7381
7565
  const minimum = iosDeploymentMinimum(version);
@@ -7394,6 +7578,10 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
7394
7578
  "-fobjc-exceptions",
7395
7579
  "-fexceptions",
7396
7580
  "-fwasm-exceptions",
7581
+ // the backend lowers direct setjmp-family calls; -lsetjmp is already
7582
+ // linked. no-op for units without setjmp calls (byte-identical).
7583
+ "-mllvm",
7584
+ "-wasm-enable-sjlj",
7397
7585
  "-fobjc-arc",
7398
7586
  ...intake
7399
7587
  ]);
@@ -7402,10 +7590,10 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
7402
7590
  if (targets.length === 0 && !prebuilt) {
7403
7591
  for (const [file, contents] of Object.entries(input.files)) {
7404
7592
  if (file === "Package.swift") continue;
7405
- files.set(path12.join(layout.sources, file), compiled.get(file) ?? contents);
7593
+ files.set(path13.join(layout.sources, file), compiled.get(file) ?? contents);
7406
7594
  }
7407
7595
  let manifest = readFileSync7(
7408
- path12.join(moduleRoot, "scripts/contrast-app-Package.swift"),
7596
+ path13.join(moduleRoot, "scripts/contrast-app-Package.swift"),
7409
7597
  "utf8"
7410
7598
  ).replaceAll("__SOOTSIM_SWIFT_PACKAGE__", moduleRoot);
7411
7599
  const reactor = ` ${REACTOR_FLAG}`;
@@ -7449,30 +7637,39 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
7449
7637
  manifest = manifest.replace(anchor, `${anchor}
7450
7638
  ${SPRITEKIT_PRODUCT},`);
7451
7639
  }
7452
- files.set(path12.join(layout.root, "Package.swift"), manifest + moduleFiles);
7640
+ files.set(path13.join(layout.root, "Package.swift"), manifest + moduleFiles);
7453
7641
  } else {
7454
7642
  const base = layout.multi ? layout.root : layout.sources;
7455
7643
  const libraries = /* @__PURE__ */ new Map();
7456
7644
  for (const [target, data] of Object.entries(input.libraries ?? {})) {
7457
- const file = path12.join(layout.root, ".peach-libraries", `lib${target}.a`);
7458
- files.set(file, Buffer.from(data, "base64"));
7645
+ const bytes = Buffer.from(data, "base64");
7646
+ const digest = createHash6("sha256").update(bytes).digest("hex");
7647
+ const file = path13.join(layout.root, ".peach-libraries", `lib${target}-${digest}.a`);
7648
+ files.set(file, bytes);
7459
7649
  libraries.set(target, file);
7460
7650
  }
7461
7651
  for (const [file, contents] of Object.entries(input.files)) {
7462
7652
  if (file === "Package.swift") continue;
7463
- files.set(path12.join(base, file), compiled.get(file) ?? contents);
7653
+ files.set(path13.join(base, file), compiled.get(file) ?? contents);
7464
7654
  }
7465
7655
  const manifestTargets = targets.length > 0 ? targets : [
7466
7656
  {
7467
7657
  name: "App",
7468
- path: path12.relative(layout.root, layout.sources).split(path12.sep).join("/"),
7658
+ path: path13.relative(layout.root, layout.sources).split(path13.sep).join("/"),
7469
7659
  executable: true,
7470
7660
  languageMode: 5,
7471
7661
  mainActorIsolation: false,
7472
7662
  resources: false
7473
7663
  }
7474
7664
  ];
7475
- const frameworkLink = prebuilt ? path12.join(layout.root, ".peach-framework-objects.rsp") : void 0;
7665
+ const reachesFrameworks = !distribution || Object.entries(input.files).some(
7666
+ ([file, source]) => file.endsWith(".swift") && file !== input.entry && file !== "Package.swift" || /\.mm?$/.test(file) || source.includes("dispatch_")
7667
+ ) || [...importedModules].some(
7668
+ (name2) => distribution.modules.includes(name2) && !targets.some((target) => target.name === name2) && !(clangImportedModules.has(name2) && !swiftImportedModules.has(name2) && existsSync2(
7669
+ path13.join(swiftSharedSdkRoot(moduleRoot, true), "usr/include", name2)
7670
+ ))
7671
+ );
7672
+ const frameworkLink = prebuilt ? path13.join(layout.root, ".peach-framework-objects.rsp") : void 0;
7476
7673
  if (prebuilt && frameworkLink) {
7477
7674
  files.set(
7478
7675
  frameworkLink,
@@ -7480,7 +7677,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
7480
7677
  );
7481
7678
  }
7482
7679
  files.set(
7483
- path12.join(layout.root, "Package.swift"),
7680
+ path13.join(layout.root, "Package.swift"),
7484
7681
  emitSwiftPackageManifest({
7485
7682
  root: layout.root,
7486
7683
  targets: manifestTargets,
@@ -7508,13 +7705,17 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
7508
7705
  oneModule: input.oneModule,
7509
7706
  spriteKit: importsSpriteKit(input.files),
7510
7707
  distribution: distribution ?? void 0,
7708
+ distributionExcludes,
7511
7709
  deferDarwinOverlay: native.size > 0 && toolsetOrdersLibcxxBeforeDarwinOverlay(
7512
7710
  swiftSdkPaths(moduleRoot, nativeToolchain()).cFlags
7513
7711
  ),
7514
- distributionLink: {
7515
- path: path12.join(layout.root, ".peach-distribution-objects.rsp"),
7516
- files
7517
- },
7712
+ ...reachesFrameworks ? {
7713
+ distributionLink: {
7714
+ path: path13.join(layout.root, ".peach-distribution-objects.rsp"),
7715
+ files
7716
+ },
7717
+ lazyDistribution: input.lazyDistribution
7718
+ } : {},
7518
7719
  ...prebuilt && frameworkLink ? {
7519
7720
  prebuilt: {
7520
7721
  modules: prebuilt.modules,
@@ -7523,26 +7724,27 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
7523
7724
  moduleMaps: prebuilt.moduleMaps
7524
7725
  }
7525
7726
  } : {},
7526
- libraries
7727
+ libraries,
7728
+ ...input.defaultLocalization ? { defaultLocalization: input.defaultLocalization } : {}
7527
7729
  }) + moduleFiles
7528
7730
  );
7529
7731
  }
7530
7732
  for (const [file, bytes] of Object.entries(input.packageFiles ?? {}))
7531
- files.set(path12.join(layout.root, file), Buffer.from(bytes, "base64"));
7733
+ files.set(path13.join(layout.root, file), Buffer.from(bytes, "base64"));
7532
7734
  for (const [file, bytes] of Object.entries(input.projectFiles ?? {})) {
7533
- const destination = path12.join(layout.root, file);
7735
+ const destination = path13.join(layout.root, file);
7534
7736
  if (files.has(destination)) continue;
7535
7737
  files.set(destination, Buffer.from(bytes, "base64"));
7536
7738
  }
7537
7739
  if (input.packageFiles || prebuilt) {
7538
7740
  files.set(
7539
- path12.join(layout.root, ".peach-target-toolset.json"),
7741
+ path13.join(layout.root, ".peach-target-toolset.json"),
7540
7742
  JSON.stringify({
7541
7743
  schemaVersion: "1.0",
7542
7744
  swiftCompiler: {
7543
7745
  extraCLIOptions: [
7544
7746
  "-I",
7545
- distribution ? path12.join(moduleRoot, "modules") : prebuilt ? prebuilt.modules : path12.join(layout.root, ".build", WASM_TRIPLE, "release", "Modules"),
7747
+ distribution ? distributionModulesPath(layout.root, moduleRoot, distributionExcludes) : prebuilt ? prebuilt.modules : path13.join(layout.root, ".build", WASM_TRIPLE, "release", "Modules"),
7546
7748
  ...prebuilt?.moduleMaps.flatMap((map) => [
7547
7749
  "-Xcc",
7548
7750
  `-fmodule-map-file=${map}`
@@ -7571,9 +7773,9 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
7571
7773
  throw new Error(
7572
7774
  `swift resource target ${target.name} has no matching bundle assignment`
7573
7775
  );
7574
- const directory = layout.multi ? path12.join(layout.root, target.path) : layout.sources;
7776
+ const directory = layout.multi ? path13.join(layout.root, target.path) : layout.sources;
7575
7777
  files.set(
7576
- path12.join(directory, "ResourceBundleAccessor.generated.swift"),
7778
+ path13.join(directory, "ResourceBundleAccessor.generated.swift"),
7577
7779
  [
7578
7780
  "import Foundation",
7579
7781
  "",
@@ -7590,7 +7792,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
7590
7792
  }
7591
7793
  for (const [file, source] of compiled)
7592
7794
  if (!Object.hasOwn(input.files, file))
7593
- files.set(path12.join(layout.multi ? layout.root : layout.sources, file), source);
7795
+ files.set(path13.join(layout.multi ? layout.root : layout.sources, file), source);
7594
7796
  syncSwiftTree(layout.root, files);
7595
7797
  const producers = [
7596
7798
  .../* @__PURE__ */ new Set([...[...native.values()].flatMap((value) => value.late?.producers ?? [])])
@@ -7625,13 +7827,13 @@ function outputOf(error) {
7625
7827
  return error instanceof Error ? error.message : String(error);
7626
7828
  }
7627
7829
  function builtArtifact(layout) {
7628
- const binDir = path12.join(layout.root, ".build", WASM_TRIPLE, "release");
7629
- const manifest = readFileSync7(path12.join(layout.root, "Package.swift"), "utf8");
7830
+ const binDir = path13.join(layout.root, ".build", WASM_TRIPLE, "release");
7831
+ const manifest = readFileSync7(path13.join(layout.root, "Package.swift"), "utf8");
7630
7832
  const executable = swiftManifestTargets(manifest).find((target) => target.executable);
7631
7833
  if (executable === void 0) {
7632
7834
  throw new Error("swift-compile: the written manifest names no executable target");
7633
7835
  }
7634
- const file = path12.join(binDir, `${executable.name}.wasm`);
7836
+ const file = path13.join(binDir, `${executable.name}.wasm`);
7635
7837
  if (!existsSync2(file)) {
7636
7838
  const found = existsSync2(binDir) ? readdirSync5(binDir).filter((name2) => name2.endsWith(".wasm")).sort() : [];
7637
7839
  throw new Error(
@@ -7642,7 +7844,7 @@ function builtArtifact(layout) {
7642
7844
  }
7643
7845
  function projectDiagnostic(output, layout, files) {
7644
7846
  const base = layout.multi ? layout.root : layout.sources;
7645
- const prefix = `${base}${path12.sep}`;
7847
+ const prefix = `${base}${path13.sep}`;
7646
7848
  return designTimeDiagnostic(output, files).split("\n").filter((line) => !SWIFTPM_NOISE.test(line)).map((line) => line.startsWith(prefix) ? line.slice(prefix.length) : line).join("\n").trim();
7647
7849
  }
7648
7850
  var ROOT_LOCKS = Symbol.for("peachsim.swiftCompile.rootLocks");
@@ -7678,12 +7880,12 @@ function serialize(root, work, signal) {
7678
7880
  function readCompiledArtifact(directory, hash) {
7679
7881
  try {
7680
7882
  const receipt = JSON.parse(
7681
- readFileSync7(path12.join(directory, "artifact.json"), "utf8")
7883
+ readFileSync7(path13.join(directory, "artifact.json"), "utf8")
7682
7884
  );
7683
7885
  if (!receipt || typeof receipt !== "object" || !("hash" in receipt) || receipt.hash !== hash || !("icu" in receipt) || typeof receipt.icu !== "string" || !("wasm" in receipt) || typeof receipt.wasm !== "string")
7684
7886
  return null;
7685
- const bytes = readFileSync7(path12.join(directory, "app.wasm"));
7686
- const gzip2 = readFileSync7(path12.join(directory, "icu.gz"));
7887
+ const bytes = readFileSync7(path13.join(directory, "app.wasm"));
7888
+ const gzip2 = readFileSync7(path13.join(directory, "icu.gz"));
7687
7889
  if (createHash6("sha256").update(bytes).digest("hex") !== receipt.wasm || createHash6("sha256").update(gzip2).digest("hex") !== receipt.icu || bytes.length < 8 || bytes.readUInt32LE(0) !== 1836278016 || bytes.readUInt32LE(4) !== 1)
7688
7890
  return null;
7689
7891
  return { hash, bytes, icu: { sha256: receipt.icu, gzip: gzip2 } };
@@ -7694,14 +7896,14 @@ function readCompiledArtifact(directory, hash) {
7694
7896
  }
7695
7897
  }
7696
7898
  function saveCompiledArtifact(root, artifact) {
7697
- const directory = path12.join(root, "artifact");
7899
+ const directory = path13.join(root, "artifact");
7698
7900
  mkdirSync2(directory, { recursive: true });
7699
- const pending = mkdtempSync2(path12.join(root, ".artifact-"));
7901
+ const pending = mkdtempSync2(path13.join(root, ".artifact-"));
7700
7902
  try {
7701
- writeFileSync3(path12.join(pending, "app.wasm"), artifact.bytes);
7702
- writeFileSync3(path12.join(pending, "icu.gz"), artifact.icu.gzip);
7903
+ writeFileSync3(path13.join(pending, "app.wasm"), artifact.bytes);
7904
+ writeFileSync3(path13.join(pending, "icu.gz"), artifact.icu.gzip);
7703
7905
  writeFileSync3(
7704
- path12.join(pending, "artifact.json"),
7906
+ path13.join(pending, "artifact.json"),
7705
7907
  JSON.stringify({
7706
7908
  hash: artifact.hash,
7707
7909
  wasm: createHash6("sha256").update(artifact.bytes).digest("hex"),
@@ -7709,7 +7911,7 @@ function saveCompiledArtifact(root, artifact) {
7709
7911
  })
7710
7912
  );
7711
7913
  for (const file of ["app.wasm", "icu.gz", "artifact.json"]) {
7712
- renameSync(path12.join(pending, file), path12.join(directory, file));
7914
+ renameSync(path13.join(pending, file), path13.join(directory, file));
7713
7915
  }
7714
7916
  } finally {
7715
7917
  rmSync3(pending, { recursive: true, force: true });
@@ -7731,16 +7933,16 @@ function renewSharedArtifact(sharedRoot) {
7731
7933
  function pruneSharedArtifacts(parent, keep) {
7732
7934
  const entries = [];
7733
7935
  for (const name2 of readdirSync5(parent)) {
7734
- const directory = path12.join(parent, name2);
7936
+ const directory = path13.join(parent, name2);
7735
7937
  if (name2.startsWith(RETIRED_PREFIX)) {
7736
7938
  rmSync3(directory, { recursive: true, force: true });
7737
7939
  continue;
7738
7940
  }
7739
7941
  try {
7740
7942
  let bytes = 0;
7741
- for (const file of readdirSync5(path12.join(directory, "artifact"))) {
7943
+ for (const file of readdirSync5(path13.join(directory, "artifact"))) {
7742
7944
  try {
7743
- bytes += statSync(path12.join(directory, "artifact", file)).size;
7945
+ bytes += statSync(path13.join(directory, "artifact", file)).size;
7744
7946
  } catch (error) {
7745
7947
  if (!vanished(error)) throw error;
7746
7948
  }
@@ -7755,9 +7957,9 @@ function pruneSharedArtifacts(parent, keep) {
7755
7957
  if (total <= SHARED_ARTIFACT_BUDGET_BYTES) break;
7756
7958
  if (entry.directory === keep || Date.now() - entry.used < SHARED_ARTIFACT_GRACE_MS)
7757
7959
  continue;
7758
- const retired = path12.join(
7960
+ const retired = path13.join(
7759
7961
  parent,
7760
- `${RETIRED_PREFIX}${process.pid}-${path12.basename(entry.directory)}`
7962
+ `${RETIRED_PREFIX}${process.pid}-${path13.basename(entry.directory)}`
7761
7963
  );
7762
7964
  try {
7763
7965
  if (statSync(entry.directory).mtimeMs !== entry.used) continue;
@@ -7773,7 +7975,7 @@ function pruneSharedArtifacts(parent, keep) {
7773
7975
  function saveSharedArtifact(sharedRoot, artifact) {
7774
7976
  saveCompiledArtifact(sharedRoot, artifact);
7775
7977
  renewSharedArtifact(sharedRoot);
7776
- pruneSharedArtifacts(path12.dirname(sharedRoot), sharedRoot);
7978
+ pruneSharedArtifacts(path13.dirname(sharedRoot), sharedRoot);
7777
7979
  }
7778
7980
  var retainedArtifacts = /* @__PURE__ */ new Map();
7779
7981
  function retain(root, artifact) {
@@ -7801,7 +8003,7 @@ function frameworkLibraryTargets(manifest) {
7801
8003
  }
7802
8004
  function linkedFrameworkTargets(moduleRoot, input) {
7803
8005
  const libraries = frameworkLibraryTargets(
7804
- readFileSync7(path12.join(moduleRoot, "Package.swift"), "utf8")
8006
+ readFileSync7(path13.join(moduleRoot, "Package.swift"), "utf8")
7805
8007
  );
7806
8008
  const targets = compileTargets(input);
7807
8009
  const planning = targets.length > 0 ? targets : [{ name: "App", path: "." }];
@@ -7842,7 +8044,7 @@ function linkedFrameworkTargets(moduleRoot, input) {
7842
8044
  return { products: linked, targets: linkedMembers };
7843
8045
  }
7844
8046
  function writeFrameworkLinkPackage(linkRoot, moduleRoot, products) {
7845
- const identity = path12.basename(moduleRoot).toLowerCase();
8047
+ const identity = path13.basename(moduleRoot).toLowerCase();
7846
8048
  const swiftString = (value) => `"${value.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
7847
8049
  const dependencies = products.map(
7848
8050
  (name2) => ` .product(name: ${swiftString(name2)}, package: ${swiftString(identity)}),`
@@ -7864,12 +8066,12 @@ ${dependencies}
7864
8066
  ]
7865
8067
  )
7866
8068
  `;
7867
- const sourceDir = path12.join(linkRoot, "Sources", FRAMEWORK_LINK_TARGET);
8069
+ const sourceDir = path13.join(linkRoot, "Sources", FRAMEWORK_LINK_TARGET);
7868
8070
  mkdirSync2(sourceDir, { recursive: true });
7869
- const manifestPath = path12.join(linkRoot, "Package.swift");
8071
+ const manifestPath = path13.join(linkRoot, "Package.swift");
7870
8072
  if (!existsSync2(manifestPath) || readFileSync7(manifestPath, "utf8") !== manifest)
7871
8073
  writeFileSync3(manifestPath, manifest);
7872
- const source = path12.join(sourceDir, "Link.swift");
8074
+ const source = path13.join(sourceDir, "Link.swift");
7873
8075
  if (!existsSync2(source)) writeFileSync3(source, "");
7874
8076
  }
7875
8077
  function frameworkLinkClosure(scratch2, roots) {
@@ -7881,7 +8083,7 @@ function frameworkLinkClosure(scratch2, roots) {
7881
8083
  const moduleMaps = /* @__PURE__ */ new Map();
7882
8084
  let pending = null;
7883
8085
  let compiling = null;
7884
- for (const line of readFileSync7(path12.join(scratch2, "release.yaml"), "utf8").split(
8086
+ for (const line of readFileSync7(path13.join(scratch2, "release.yaml"), "utf8").split(
7885
8087
  "\n"
7886
8088
  )) {
7887
8089
  const phony = phonyHeader.exec(line);
@@ -7955,14 +8157,14 @@ function removeUnbuiltModuleArtifacts(modulesDir, keep) {
7955
8157
  const dot = name2.indexOf(".");
7956
8158
  if (dot <= 0) continue;
7957
8159
  if (keep.has(name2.slice(0, dot))) continue;
7958
- rmSync3(path12.join(modulesDir, name2), { recursive: true, force: true });
8160
+ rmSync3(path13.join(modulesDir, name2), { recursive: true, force: true });
7959
8161
  }
7960
8162
  }
7961
8163
  async function compileFrameworkProducts(args) {
7962
8164
  const scratch2 = swiftFrameworkScratch(args.appRoot);
7963
8165
  mkdirSync2(scratch2, { recursive: true });
7964
8166
  const linkedTargets = linkedFrameworkTargets(args.moduleRoot, args.input);
7965
- const linkRoot = path12.join(scratch2, "link");
8167
+ const linkRoot = path13.join(scratch2, "link");
7966
8168
  writeFrameworkLinkPackage(linkRoot, args.moduleRoot, linkedTargets.products);
7967
8169
  await runCompiler(
7968
8170
  args.swift,
@@ -8007,21 +8209,28 @@ async function compileFrameworkProducts(args) {
8007
8209
  SWIFTPM_PROGRESS,
8008
8210
  SWIFTPM_NOISE
8009
8211
  );
8010
- const release = path12.join(scratch2, WASM_TRIPLE, "release");
8212
+ const release = path13.join(scratch2, WASM_TRIPLE, "release");
8011
8213
  const linked = frameworkLinkClosure(scratch2, linkedTargets.targets);
8012
8214
  const objects = linked.objects;
8013
- removeUnbuiltModuleArtifacts(path12.join(release, "Modules"), linked.modules);
8014
- const response = path12.join(scratch2, "autolink-objects.rsp");
8215
+ removeUnbuiltModuleArtifacts(path13.join(release, "Modules"), linked.modules);
8216
+ const response = path13.join(scratch2, "autolink-objects.rsp");
8015
8217
  writeFileSync3(response, objects.map((file) => JSON.stringify(file)).join("\n") + "\n");
8016
8218
  const extracted = await runCompiler(
8017
- path12.join(args.toolchainBin, "swift-autolink-extract"),
8219
+ path13.join(args.toolchainBin, "swift-autolink-extract"),
8018
8220
  [`@${response}`, "-o", "-"],
8019
8221
  args.buildOptions
8020
8222
  );
8021
8223
  rmSync3(response, { force: true });
8022
8224
  const link = extracted.split("\n").map((line) => line.trim()).filter((flag, index, all) => flag.length > 0 && all.indexOf(flag) === index);
8225
+ if (link.includes("-lFoundation"))
8226
+ objects.push(
8227
+ path13.join(
8228
+ swiftSdkPaths(args.moduleRoot, args.toolchainBin).resources,
8229
+ "wasi/NSStringFormatting.objc.o"
8230
+ )
8231
+ );
8023
8232
  return {
8024
- modules: path12.join(release, "Modules"),
8233
+ modules: path13.join(release, "Modules"),
8025
8234
  objects,
8026
8235
  link,
8027
8236
  moduleMaps: linked.moduleMaps
@@ -8030,7 +8239,7 @@ async function compileFrameworkProducts(args) {
8030
8239
  var SWIFT_LINK_STAMP = ".peach-link-stamp";
8031
8240
  var SWIFT_FRAMEWORK_KEY = ".peach-framework-key";
8032
8241
  function swiftFrameworkScratch(appRoot) {
8033
- return path12.join(path12.dirname(appRoot), `${path12.basename(appRoot)}.packages`);
8242
+ return path13.join(path13.dirname(appRoot), `${path13.basename(appRoot)}.packages`);
8034
8243
  }
8035
8244
  function swiftLinkStamp(args) {
8036
8245
  const hash = createHash6("sha256");
@@ -8058,11 +8267,11 @@ ${args.prebuilt.modules}
8058
8267
  `);
8059
8268
  for (const entry of readdirSync5(args.prebuilt.modules).sort())
8060
8269
  hash.update(`${entry}
8061
- ${statOf(path12.join(args.prebuilt.modules, entry))}`);
8270
+ ${statOf(path13.join(args.prebuilt.modules, entry))}`);
8062
8271
  return hash.digest("hex");
8063
8272
  }
8064
8273
  function retireStaleSwiftFrameworks(root, key) {
8065
- const receipt = path12.join(root, SWIFT_FRAMEWORK_KEY);
8274
+ const receipt = path13.join(root, SWIFT_FRAMEWORK_KEY);
8066
8275
  let previous = null;
8067
8276
  try {
8068
8277
  previous = readFileSync7(receipt, "utf8").trim();
@@ -8077,7 +8286,7 @@ function retireStaleSwiftFrameworks(root, key) {
8077
8286
  return true;
8078
8287
  }
8079
8288
  function retireStaleSwiftLink(root, stamp) {
8080
- const receipt = path12.join(root, SWIFT_LINK_STAMP);
8289
+ const receipt = path13.join(root, SWIFT_LINK_STAMP);
8081
8290
  let previous = null;
8082
8291
  try {
8083
8292
  previous = readFileSync7(receipt, "utf8").trim();
@@ -8086,7 +8295,7 @@ function retireStaleSwiftLink(root, stamp) {
8086
8295
  }
8087
8296
  writeFileSync3(receipt, `${stamp}
8088
8297
  `);
8089
- const retired = path12.join(root, ".build");
8298
+ const retired = path13.join(root, ".build");
8090
8299
  if (previous === stamp || !existsSync2(retired)) return false;
8091
8300
  rmSync3(retired, { recursive: true, force: true });
8092
8301
  return true;
@@ -8095,15 +8304,15 @@ function compileSwiftProjectUnit(input, options) {
8095
8304
  options.signal?.throwIfAborted();
8096
8305
  mkdirSync2(options.buildRoot, { recursive: true });
8097
8306
  const root = realpathSync(options.buildRoot);
8098
- const moduleRoot = path12.resolve(options.moduleRoot);
8307
+ const moduleRoot = path13.resolve(options.moduleRoot);
8099
8308
  const layout = {
8100
8309
  root,
8101
- sources: path12.join(root, "Sources", "App"),
8310
+ sources: path13.join(root, "Sources", "App"),
8102
8311
  multi: compileTargets(input).length > 0
8103
8312
  };
8104
8313
  const hash = swiftArtifactHash(input, options.release, moduleRoot);
8105
8314
  const frameworkKey = swiftProjectBuildKey(moduleRoot, options.release);
8106
- const sharedRoot = path12.join(rnxHomeDir(), "cache", "swift-projects", hash);
8315
+ const sharedRoot = path13.join(swiftCacheDir(), "swift-projects", hash);
8107
8316
  const report = (message) => {
8108
8317
  console.error(`[swift-project ${hash.slice(0, 16)}] ${message}`);
8109
8318
  options.onStage?.(message);
@@ -8117,8 +8326,8 @@ function compileSwiftProjectUnit(input, options) {
8117
8326
  report("reusing memory artifact");
8118
8327
  return retain(root, retained);
8119
8328
  }
8120
- const cached = readCompiledArtifact(path12.join(sharedRoot, "artifact"), hash);
8121
- const previous = cached ?? readCompiledArtifact(path12.join(root, "artifact"), hash);
8329
+ const cached = readCompiledArtifact(path13.join(sharedRoot, "artifact"), hash);
8330
+ const previous = cached ?? readCompiledArtifact(path13.join(root, "artifact"), hash);
8122
8331
  if (previous) {
8123
8332
  if (cached) renewSharedArtifact(sharedRoot);
8124
8333
  else saveSharedArtifact(sharedRoot, previous);
@@ -8127,8 +8336,8 @@ function compileSwiftProjectUnit(input, options) {
8127
8336
  }
8128
8337
  if (process.platform === "darwin" && process.env.TM_SESSION && !admittedMacBuilderSlot() && process.env.CI !== "true" && moduleRoot === sourceSwiftCheckout() && !swiftDistributionAt(moduleRoot)) {
8129
8338
  const requestRoot = mkdtempSync2(`${root}.builder-request-`);
8130
- const output = path12.join(requestRoot, "output");
8131
- const request = path12.join(requestRoot, "request.json");
8339
+ const output = path13.join(requestRoot, "output");
8340
+ const request = path13.join(requestRoot, "request.json");
8132
8341
  writeFileSync3(
8133
8342
  request,
8134
8343
  JSON.stringify({
@@ -8142,12 +8351,12 @@ function compileSwiftProjectUnit(input, options) {
8142
8351
  })
8143
8352
  );
8144
8353
  try {
8145
- const repo = path12.resolve(moduleRoot, "../..");
8354
+ const repo = path13.resolve(moduleRoot, "../..");
8146
8355
  report("requesting builder admission or cached result");
8147
8356
  await runCompiler(
8148
8357
  "bun",
8149
8358
  [
8150
- path12.join(repo, "scripts/build/swift-project.ts"),
8359
+ path13.join(repo, "scripts/build/swift-project.ts"),
8151
8360
  "--request",
8152
8361
  request,
8153
8362
  "--output",
@@ -8181,12 +8390,12 @@ function compileSwiftProjectUnit(input, options) {
8181
8390
  return withSwiftRootLock(
8182
8391
  root,
8183
8392
  async (lease) => {
8184
- const built = readCompiledArtifact(path12.join(sharedRoot, "artifact"), hash);
8393
+ const built = readCompiledArtifact(path13.join(sharedRoot, "artifact"), hash);
8185
8394
  if (built) {
8186
8395
  report("reusing verified disk artifact");
8187
8396
  return retain(root, built);
8188
8397
  }
8189
- const swift = path12.join(options.toolchainBin, "swift");
8398
+ const swift = path13.join(options.toolchainBin, "swift");
8190
8399
  if (!existsSync2(swift)) {
8191
8400
  throw new Error(
8192
8401
  `swift-compile: no swift.org toolchain at ${options.toolchainBin}; install ${options.release} and its matching wasm sdk`
@@ -8209,8 +8418,8 @@ function compileSwiftProjectUnit(input, options) {
8209
8418
  // shipped host plugins resolve against the selected compiler's runtime.
8210
8419
  ...process.platform === "linux" ? {
8211
8420
  LD_LIBRARY_PATH: [
8212
- path12.resolve(options.toolchainBin, "../lib/swift/linux"),
8213
- path12.resolve(options.toolchainBin, "../lib/swift/host"),
8421
+ path13.resolve(options.toolchainBin, "../lib/swift/linux"),
8422
+ path13.resolve(options.toolchainBin, "../lib/swift/host"),
8214
8423
  process.env.LD_LIBRARY_PATH
8215
8424
  ].filter(Boolean).join(":")
8216
8425
  } : {}
@@ -8259,7 +8468,7 @@ function compileSwiftProjectUnit(input, options) {
8259
8468
  ...swiftSdkOptions(),
8260
8469
  "--swift-sdk",
8261
8470
  sdk,
8262
- ...input.packageFiles || prebuilt ? ["--toolset", path12.join(root, ".peach-target-toolset.json")] : [],
8471
+ ...input.packageFiles || prebuilt ? ["--toolset", path13.join(root, ".peach-target-toolset.json")] : [],
8263
8472
  "-c",
8264
8473
  "release",
8265
8474
  "-Xswiftc",
@@ -8301,7 +8510,7 @@ function compileSwiftProjectUnit(input, options) {
8301
8510
  );
8302
8511
  } catch (error) {
8303
8512
  const output = outputOf(error);
8304
- const moduleCache = path12.join(
8513
+ const moduleCache = path13.join(
8305
8514
  root,
8306
8515
  ".build",
8307
8516
  WASM_TRIPLE,
@@ -8362,6 +8571,7 @@ export {
8362
8571
  compileTargets,
8363
8572
  emitSwiftPackageManifest,
8364
8573
  ensureMacroPlugins,
8574
+ foundationOwnerOf,
8365
8575
  lowerAVAssetURLCluster,
8366
8576
  lowerNSValueTimeBox,
8367
8577
  missingSwiftModules,
@@ -8386,7 +8596,10 @@ export {
8386
8596
  swiftSdkPaths,
8387
8597
  swiftSourceAsIOS,
8388
8598
  swiftSourceClosure,
8599
+ swiftSystemLibraryExclusions,
8600
+ swiftSystemLibrarySurface,
8389
8601
  swiftTargetDependencies,
8602
+ swiftTypedApplicationEntry,
8390
8603
  syncSwiftTree,
8391
8604
  withNativeSourceGlue,
8392
8605
  wrapUIApplicationMainEntry,