peachsim 0.1.1808 → 0.1.1812

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 (236) hide show
  1. package/README.md +4 -2
  2. package/cli/app-bundle-resources.ts +15 -2
  3. package/cli/cloud-box-artifact.ts +115 -0
  4. package/cli/cloud-client.ts +148 -76
  5. package/cli/cloud-dispatch.ts +4 -4
  6. package/cli/cloud-session.ts +60 -22
  7. package/cli/commands/box.ts +8 -2
  8. package/cli/commands/compat.ts +7 -4
  9. package/cli/commands/control.ts +69 -3
  10. package/cli/commands/coverage.ts +14 -4
  11. package/cli/commands/daemon.ts +41 -0
  12. package/cli/commands/no-bridge-hint.ts +9 -0
  13. package/cli/commands/package.ts +31 -56
  14. package/cli/commands/platform.ts +71 -60
  15. package/cli/commands/preview.ts +73 -24
  16. package/cli/commands/record.ts +10 -2
  17. package/cli/commands/screenshot.ts +17 -60
  18. package/cli/commands/setup.ts +3 -1
  19. package/cli/commands/three-mode.ts +22 -12
  20. package/cli/commands/upload.ts +2 -1
  21. package/cli/desktop-companion.ts +6 -1
  22. package/cli/drivers/desktop.ts +4 -1
  23. package/cli/main.ts +12 -2
  24. package/cli/metro-bundle-assets.ts +14 -4
  25. package/cli/outbound-endpoints.ts +7 -3
  26. package/cli/output-redaction.ts +38 -0
  27. package/cli/privacy.ts +2 -2
  28. package/cli/recording-access.ts +5 -0
  29. package/cli/remote-project-bundle.ts +83 -0
  30. package/cli/shell-init.ts +7 -11
  31. package/cli/telemetry.ts +41 -4
  32. package/cli/usage-error.ts +3 -0
  33. package/cli/ws-bridge.ts +42 -6
  34. package/dist-lib/agent-daemon-client.cjs +1 -1
  35. package/dist-lib/agent-events.cjs +1 -1
  36. package/dist-lib/attached-projects.cjs +1 -1
  37. package/dist-lib/auth/shared-session.cjs +1 -1
  38. package/dist-lib/backend-origin.cjs +1 -1
  39. package/dist-lib/beta.cjs +1 -1
  40. package/dist-lib/beta.mjs +1 -1
  41. package/dist-lib/bridge-constants.cjs +1 -1
  42. package/dist-lib/bridge-contract-input.cjs +1 -1
  43. package/dist-lib/bridge-contract-input.mjs +1 -1
  44. package/dist-lib/bridge-contract.cjs +1 -1
  45. package/dist-lib/bridge-contract.mjs +1 -1
  46. package/dist-lib/bundle-channel.cjs +42897 -40755
  47. package/dist-lib/capture-contract.cjs +7 -8
  48. package/dist-lib/capture-contract.mjs +7 -8
  49. package/dist-lib/cloud-contract.cjs +1 -1
  50. package/dist-lib/cloud-contract.mjs +1 -1
  51. package/dist-lib/cloud-test-args.cjs +1 -1
  52. package/dist-lib/cloud-test-args.mjs +1 -1
  53. package/dist-lib/cloud.cjs +1 -1
  54. package/dist-lib/cloud.mjs +1 -1
  55. package/dist-lib/config.cjs +1 -1
  56. package/dist-lib/config.mjs +1 -1
  57. package/dist-lib/detox/index.cjs +13 -7
  58. package/dist-lib/dev-bundle-resolution.cjs +10 -4
  59. package/dist-lib/expo-swift-bundle.cjs +15889 -15553
  60. package/dist-lib/expo-swift-metadata.cjs +2 -1
  61. package/dist-lib/expo-swift-metadata.mjs +2 -1
  62. package/dist-lib/home-paths.cjs +2 -33
  63. package/dist-lib/host/bridge-host.cjs +20891 -18714
  64. package/dist-lib/host/fetch-proxy-handler.cjs +10 -11
  65. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  66. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  67. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  68. package/dist-lib/host/websocket-proxy.cjs +1 -1
  69. package/dist-lib/index.cjs +620 -553
  70. package/dist-lib/jump-to-source-babel.cjs +1 -1
  71. package/dist-lib/jump-to-source-native.cjs +1 -1
  72. package/dist-lib/kotlin-host.cjs +1 -1
  73. package/dist-lib/menu.cjs +1 -1
  74. package/dist-lib/menu.mjs +1 -1
  75. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  76. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  77. package/dist-lib/metro-production-bundle.cjs +1 -1
  78. package/dist-lib/metro-production-bundle.mjs +1 -1
  79. package/dist-lib/metro.cjs +57 -28
  80. package/dist-lib/native-app-identity-project.cjs +47 -14
  81. package/dist-lib/native-app-identity-project.mjs +55 -20
  82. package/dist-lib/native-app-identity.cjs +1 -1
  83. package/dist-lib/native-app-identity.mjs +1 -1
  84. package/dist-lib/native-firebase-metadata.cjs +1 -1
  85. package/dist-lib/native-firebase-metadata.mjs +1 -1
  86. package/dist-lib/pdfium-raster.cjs +1 -1
  87. package/dist-lib/pdfium-raster.mjs +1 -1
  88. package/dist-lib/plist.cjs +1 -1
  89. package/dist-lib/plist.mjs +1 -1
  90. package/dist-lib/profiles.cjs +1 -1
  91. package/dist-lib/public-brand.cjs +1 -1
  92. package/dist-lib/public-origins-lib-esm.json +27 -26
  93. package/dist-lib/public-origins-lib.json +104 -81
  94. package/dist-lib/react-native-host-modules.cjs +1 -1
  95. package/dist-lib/react-native-host-modules.mjs +1 -1
  96. package/dist-lib/reap-browser.cjs +1 -1
  97. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  98. package/dist-lib/sdk.cjs +1 -1
  99. package/dist-lib/sdk.mjs +1 -1
  100. package/dist-lib/skills.cjs +30700 -24410
  101. package/dist-lib/swift-compile.cjs +336 -222
  102. package/dist-lib/swift-compile.mjs +378 -263
  103. package/dist-lib/swift-package.cjs +19 -7
  104. package/dist-lib/swift-package.mjs +16 -6
  105. package/dist-lib/swift-submit.cjs +1 -1
  106. package/dist-lib/swift-submit.mjs +1 -1
  107. package/dist-lib/swift-toolchain.cjs +49 -1
  108. package/dist-lib/swift.cjs +1 -1
  109. package/dist-lib/vite-swift.cjs +19213 -18937
  110. package/dist-lib/vite.cjs +11 -12
  111. package/dist-lib/worklet-executable.cjs +1 -1
  112. package/dist-lib/worklet-executable.mjs +1 -1
  113. package/dist-types/packages/peach-engine/src/engine/animated.d.ts +4 -0
  114. package/dist-types/packages/peach-engine/src/engine/animation-graph.d.ts +1 -0
  115. package/dist-types/packages/peach-engine/src/engine/expo-manifest.d.ts +1 -0
  116. package/dist-types/packages/peach-engine/src/engine/image-loader.d.ts +1 -1
  117. package/dist-types/packages/peach-engine/src/preview/upload-protocol.d.ts +1 -0
  118. package/dist-types/packages/peach-engine/src/render-worker/worklet-runtime.d.ts +8 -1
  119. package/dist-types/packages/peach-globals/src/electronBridgeContract.d.ts +2 -1
  120. package/dist-types/packages/peach-kit/src/capabilities.d.ts +1 -0
  121. package/kotlin/sdk.tar.gz +0 -0
  122. package/package.json +1 -1
  123. package/runtime-companion.json +1 -1
  124. package/sdk/ios/System/Library/Frameworks/CoreTelephony.framework/Headers/CTCall.h +1 -1
  125. package/sdk/ios/System/Library/Frameworks/CoreTelephony.framework/Headers/CTCallCenter.h +1 -1
  126. package/sdk/ios/System/Library/Frameworks/CoreTelephony.framework/Headers/CTCarrier.h +1 -1
  127. package/sdk/ios/System/Library/Frameworks/CoreTelephony.framework/Headers/CTSubscriber.h +1 -1
  128. package/sdk/ios/System/Library/Frameworks/CoreTelephony.framework/Headers/CTSubscriberInfo.h +1 -1
  129. package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/NSArray.h +1 -1
  130. package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/NSDictionary.h +1 -1
  131. package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/NSExtensionItem.h +1 -1
  132. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/AVFoundation+MPNowPlayingInfoLanguageOptionAdditions.h +39 -0
  133. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/AVPlayerItem+MediaPlayerAdditions.h +26 -0
  134. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPContentItem.h +67 -0
  135. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPError.h +33 -0
  136. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaEntity.h +53 -0
  137. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaItem.h +346 -0
  138. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaItemCollection.h +42 -0
  139. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaLibrary.h +76 -0
  140. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaPickerController.h +64 -0
  141. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaPlayback.h +47 -0
  142. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaPlaylist.h +82 -0
  143. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaQuery.h +120 -0
  144. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaQuerySection.h +26 -0
  145. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMoviePlayerController.h +444 -0
  146. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMoviePlayerViewController.h +43 -0
  147. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMusicPlayerApplicationController.h +47 -0
  148. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMusicPlayerController.h +147 -0
  149. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMusicPlayerQueueDescriptor.h +75 -0
  150. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPNowPlayingInfoCenter.h +197 -0
  151. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPNowPlayingInfoLanguageOption.h +107 -0
  152. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPNowPlayingSession.h +89 -0
  153. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPPlayableContentDataSource.h +59 -0
  154. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPPlayableContentDelegate.h +64 -0
  155. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPPlayableContentManager.h +46 -0
  156. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPPlayableContentManagerContext.h +32 -0
  157. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPRemoteCommand.h +143 -0
  158. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPRemoteCommandCenter.h +66 -0
  159. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPRemoteCommandEvent.h +128 -0
  160. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPRemoteControlTypes.h +27 -0
  161. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPVolumeSettings.h +20 -0
  162. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPVolumeView.h +82 -0
  163. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MediaPlayer.apinotes +74 -0
  164. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MediaPlayer.h +40 -0
  165. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MediaPlayerDefines.h +84 -0
  166. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/NSUserActivity+MediaPlayerAdditions.h +20 -0
  167. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Modules/module.modulemap +5 -0
  168. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIAccessibilityCustomRotor.h +2 -2
  169. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIAction.h +1 -1
  170. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIBackgroundConfiguration.h +1 -1
  171. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIButtonConfiguration.h +1 -1
  172. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIContextMenuConfiguration.h +1 -1
  173. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIContextMenuInteraction.h +1 -1
  174. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIDeferredMenuElement.h +1 -1
  175. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIMenu.h +1 -1
  176. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIPointerStyle.h +5 -5
  177. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UISlider.h +1 -1
  178. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UISplitViewController.h +12 -50
  179. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UISplitViewControllerLayoutEnvironment.h +2 -8
  180. package/sdk/ios/System/Library/Frameworks/UIKitTypes.framework/Headers/UIKitTypes.h +62 -0
  181. package/sdk/ios/usr/include/dispatch.modulemap +22 -0
  182. package/sdk/ios/usr/include/module.modulemap +8 -3
  183. package/sdk/ios/usr/include/net/if.h +24 -0
  184. package/sdk/ios/usr/include/sys/time.h +1 -1
  185. package/sdk/ios/usr/lib/swift/Foundation.swiftmodule/arm64-apple-ios-simulator.swiftinterface +265 -0
  186. package/sdk/ios/usr/lib/swift/ObjectiveC.swiftmodule/arm64-apple-ios-simulator.swiftinterface +2 -0
  187. package/sdk/ios/wasm/include/fcntl.h +2 -0
  188. package/sdk/ios/wasm/include/pthread.h +3 -0
  189. package/sdk/ios/wasm/include/stdlib.h +2 -0
  190. package/sdk/ios/wasm/include/unistd.h +2 -2
  191. package/skills/contrast/SKILL.md +2 -2
  192. package/src/bundle-channel.mjs +9 -72
  193. package/src/capture-contract.ts +12 -9
  194. package/src/desktop-host-delivery.ts +16 -2
  195. package/src/dev-bundle-resolution.ts +12 -3
  196. package/src/expo-native-workspace.ts +113 -46
  197. package/src/expo-swift-host.ts +17 -12
  198. package/src/expo-swift-ready.ts +4 -1
  199. package/src/expoSwiftContract.ts +1 -0
  200. package/src/home-paths.ts +4 -48
  201. package/src/host/bridge-host.ts +1 -0
  202. package/src/installed-native-libraries.ts +2 -8
  203. package/src/metro-project-root.ts +2 -1
  204. package/src/native-bundles.ts +122 -0
  205. package/src/native-static-libraries.ts +65 -8
  206. package/src/nitro-adapter.lock.json +272 -272
  207. package/src/nitro-bundle.ts +2 -2
  208. package/src/nitro-compile.ts +68 -28
  209. package/src/nitro-source.ts +24 -6
  210. package/src/nitro-superset.lock.json +94 -34
  211. package/src/nitroContract.ts +3 -0
  212. package/src/podspec-sources.ts +1966 -0
  213. package/src/storageSnapshotContract.ts +40 -0
  214. package/src/swift-compile.ts +77 -26
  215. package/src/swift-design-time.ts +18 -1
  216. package/src/swift-distribution.lock.json +12 -12
  217. package/src/swift-distribution.ts +9 -6
  218. package/src/swift-host.ts +1 -2
  219. package/src/swift-link-roots.ts +13 -2
  220. package/src/swift-objc-compile.ts +12 -0
  221. package/src/swift-objc-standin.ts +321 -114
  222. package/src/swift-package-manifest.ts +4 -3
  223. package/src/swift-package.ts +31 -4
  224. package/src/swift-root-lock.ts +11 -0
  225. package/src/swift-shared-sdk.ts +10 -9
  226. package/src/swift-source-pods.ts +2 -2
  227. package/src/swift-standins.ts +40 -143
  228. package/src/swift-toolchain.ts +59 -0
  229. package/src/swift-wasm-prune.ts +53 -21
  230. package/src/turbo-bundle.ts +4 -5
  231. package/src/turbo-codegen-intake.ts +111 -108
  232. package/src/turbo-compile.ts +63 -33
  233. package/src/turbo-runtime.lock.json +22 -22
  234. package/src/turbo-source.ts +171 -76
  235. package/src/wasm-optimize.ts +31 -2
  236. package/src/xcode-project.ts +65 -15
@@ -1,9 +1,9 @@
1
- /*! peach v0.1.1808 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1812 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
 
3
3
  // src/swift-compile.ts
4
4
  import {
5
5
  spawn as spawn3,
6
- execFileSync as execFileSync8
6
+ execFileSync as execFileSync9
7
7
  } from "node:child_process";
8
8
  import { createHash as createHash8, randomUUID as randomUUID4 } from "node:crypto";
9
9
  import {
@@ -2094,44 +2094,6 @@ var swift_c_predefines_default = {
2094
2094
  }
2095
2095
  };
2096
2096
 
2097
- // src/home-paths.ts
2098
- import { randomUUID } from "node:crypto";
2099
- import fs from "node:fs";
2100
- import { homedir } from "node:os";
2101
- import path from "node:path";
2102
- var PEACH_HOME_ENV = "PEACH_HOME";
2103
- function ambientHomeDir() {
2104
- return path.join(homedir(), ".peach");
2105
- }
2106
- function rnxHomeDir() {
2107
- const override = process.env[PEACH_HOME_ENV];
2108
- if (override && override.length > 0) return path.resolve(override);
2109
- return ambientHomeDir();
2110
- }
2111
- function cacheDir() {
2112
- return path.join(rnxHomeDir(), "cache");
2113
- }
2114
- var BUILDERS_ROOT_ENV = "CONTRAST_BUILDERS_ROOT";
2115
- function buildersRootEnv() {
2116
- const root = process.env[BUILDERS_ROOT_ENV]?.trim();
2117
- return root ? root : null;
2118
- }
2119
- function swiftCacheDir() {
2120
- const root = buildersRootEnv();
2121
- return root ? path.join(root, "peach-cache") : cacheDir();
2122
- }
2123
- function swiftPackageCacheOptions() {
2124
- const root = path.join(swiftCacheDir(), "swiftpm");
2125
- return [
2126
- ...["cache", "config", "security"].flatMap((name2) => [
2127
- `--${name2}-path`,
2128
- path.join(root, name2)
2129
- ]),
2130
- "--disable-keychain"
2131
- ];
2132
- }
2133
- var DAEMON_LOCKFILE_MAX_BYTES = 16 * 1024;
2134
-
2135
2097
  // src/process-group.ts
2136
2098
  import { spawn, spawnSync as spawnSync3 } from "node:child_process";
2137
2099
  import {
@@ -2547,10 +2509,10 @@ async function terminateProcessGroup(child, signal = "SIGTERM", gracefulTimeoutM
2547
2509
  }
2548
2510
 
2549
2511
  // src/retired-cache-directory.ts
2550
- import { randomUUID as randomUUID2 } from "node:crypto";
2512
+ import { randomUUID } from "node:crypto";
2551
2513
  import { renameSync } from "node:fs";
2552
2514
  import { rm } from "node:fs/promises";
2553
- import path2 from "node:path";
2515
+ import path from "node:path";
2554
2516
 
2555
2517
  // src/process-liveness.ts
2556
2518
  import { readFileSync as readFileSync3 } from "node:fs";
@@ -2583,8 +2545,8 @@ function removeRetiredDirectory(directory) {
2583
2545
  function reapRetiredCacheDirectory(parent, name2) {
2584
2546
  const owner = /^\.retired-(\d+)-/.exec(name2);
2585
2547
  if (!owner || isProcessRunning(Number(owner[1]))) return;
2586
- const directory = path2.join(parent, name2);
2587
- const claimed = path2.join(parent, `.retired-${process.pid}-${randomUUID2()}`);
2548
+ const directory = path.join(parent, name2);
2549
+ const claimed = path.join(parent, `.retired-${process.pid}-${randomUUID()}`);
2588
2550
  try {
2589
2551
  renameSync(directory, claimed);
2590
2552
  } catch (error) {
@@ -2597,16 +2559,16 @@ function reapRetiredCacheDirectory(parent, name2) {
2597
2559
  // src/swift-compiler-digest.ts
2598
2560
  import { createHash } from "node:crypto";
2599
2561
  import { readFileSync as readFileSync5 } from "node:fs";
2600
- import path4 from "node:path";
2562
+ import path3 from "node:path";
2601
2563
 
2602
2564
  // src/swift-objc-sdk-tree.ts
2603
2565
  import { readdirSync as readdirSync3, readFileSync as readFileSync4 } from "node:fs";
2604
- import path3 from "node:path";
2566
+ import path2 from "node:path";
2605
2567
  function readIosSdkTree(root) {
2606
2568
  return readdirSync3(root, { recursive: true, withFileTypes: true }).filter((entry) => entry.isFile()).map((entry) => {
2607
- const file = path3.join(entry.parentPath, entry.name);
2569
+ const file = path2.join(entry.parentPath, entry.name);
2608
2570
  return [
2609
- path3.relative(root, file).split(path3.sep).join("/"),
2571
+ path2.relative(root, file).split(path2.sep).join("/"),
2610
2572
  readFileSync4(file, "utf8")
2611
2573
  ];
2612
2574
  }).sort(([a], [b]) => a < b ? -1 : 1);
@@ -2616,39 +2578,39 @@ function readIosSdkTree(root) {
2616
2578
  import { execFileSync as execFileSync4 } from "node:child_process";
2617
2579
  import { mkdtempSync as mkdtempSync2, readdirSync as readdirSync5, rmSync as rmSync2, symlinkSync } from "node:fs";
2618
2580
  import { tmpdir as tmpdir2 } from "node:os";
2619
- import path10 from "node:path";
2581
+ import path9 from "node:path";
2620
2582
 
2621
2583
  // src/swift-objc-platform.ts
2622
2584
  import { spawnSync as spawnSync4 } from "node:child_process";
2623
- import path6 from "node:path";
2585
+ import path5 from "node:path";
2624
2586
 
2625
2587
  // src/swift-toolchain.ts
2626
2588
  import { execFile, execFileSync } from "node:child_process";
2627
2589
  import { createHash as createHash2 } from "node:crypto";
2628
- import fs2 from "node:fs";
2590
+ import fs from "node:fs";
2629
2591
  import os from "node:os";
2630
- import path5 from "node:path";
2592
+ import path4 from "node:path";
2631
2593
  import { fileURLToPath } from "node:url";
2632
2594
  import { promisify } from "node:util";
2633
2595
  function peachsimPackageRoot() {
2634
2596
  let dir = import.meta.dirname;
2635
- while (!fs2.existsSync(path5.join(dir, "package.json")) && dir !== path5.dirname(dir))
2636
- dir = path5.dirname(dir);
2597
+ while (!fs.existsSync(path4.join(dir, "package.json")) && dir !== path4.dirname(dir))
2598
+ dir = path4.dirname(dir);
2637
2599
  return dir;
2638
2600
  }
2639
2601
  function sourceSwiftCheckout() {
2640
- return path5.resolve(peachsimPackageRoot(), "../sootsim-swift");
2602
+ return path4.resolve(peachsimPackageRoot(), "../sootsim-swift");
2641
2603
  }
2642
2604
  function swiftSdkOptions() {
2643
2605
  const directory = process.env.PEACH_SWIFT_SDKS_PATH;
2644
- if (directory) return ["--swift-sdks-path", path5.resolve(directory)];
2606
+ if (directory) return ["--swift-sdks-path", path4.resolve(directory)];
2645
2607
  if (scratch && process.platform === "linux") {
2646
2608
  const config = process.env.XDG_CONFIG_HOME;
2647
- if (config !== void 0 && !path5.isAbsolute(config))
2609
+ if (config !== void 0 && !path4.isAbsolute(config))
2648
2610
  throw new Error("XDG_CONFIG_HOME must be an absolute path");
2649
2611
  return [
2650
2612
  "--swift-sdks-path",
2651
- config === void 0 ? path5.join(os.userInfo().homedir, ".swiftpm", "swift-sdks") : path5.join(config, "swiftpm", "swift-sdks")
2613
+ config === void 0 ? path4.join(os.userInfo().homedir, ".swiftpm", "swift-sdks") : path4.join(config, "swiftpm", "swift-sdks")
2652
2614
  ];
2653
2615
  }
2654
2616
  return [];
@@ -2792,6 +2754,23 @@ var compilerArchives = {
2792
2754
  }
2793
2755
  }
2794
2756
  },
2757
+ "swift-6.4.0-RELEASE-custom-a560ff35bf882b5c": {
2758
+ identity: "a560ff35bf882b5c",
2759
+ hosts: {
2760
+ "darwin-arm64": {
2761
+ checksum: "ec20a41851ac558fe663d78def6b93d0d47c5a0cb69688ee270fd85de637a522",
2762
+ manifest: "253e891527d2213f54eace768b902de89de5e9495a3c5f4018de1985516bd553"
2763
+ },
2764
+ "linux-x64": {
2765
+ checksum: "f0126a2e63d275895036d02d75a901070da0343dbf03bf17342e10cb6f893dee",
2766
+ manifest: "6f951cc4071dd0d6054d85711a7c5fe272273658847831b477a8b24be7254ca0"
2767
+ },
2768
+ "linux-arm64": {
2769
+ checksum: "315fa766559a6e69bfd10dcddf40e04c91155f0db3047d210d74ac87652fb7e6",
2770
+ manifest: "b6f62fca2ec37593e274ee5bac474f21ffc5db14cd82f492ccbc774f8e9b75d8"
2771
+ }
2772
+ }
2773
+ },
2795
2774
  [SWIFT_HOST_COMPILER_RELEASE]: {
2796
2775
  identity: SWIFT_HOST_COMPILER_ID,
2797
2776
  hosts: {
@@ -2813,13 +2792,13 @@ var compilerArchives = {
2813
2792
  var SWIFT_PRIVATE_DISTRIBUTION_ENV = "PEACH_SWIFT_PRIVATE_DISTRIBUTION";
2814
2793
  function privateSwiftDistributionRoot() {
2815
2794
  const root = process.env[SWIFT_PRIVATE_DISTRIBUTION_ENV]?.trim();
2816
- return root ? path5.resolve(root) : null;
2795
+ return root ? path4.resolve(root) : null;
2817
2796
  }
2818
2797
  function privateSwiftRelease() {
2819
2798
  const root = privateSwiftDistributionRoot();
2820
2799
  if (!root) return null;
2821
2800
  const manifest = JSON.parse(
2822
- fs2.readFileSync(path5.join(root, "distribution.json"), "utf8")
2801
+ fs.readFileSync(path4.join(root, "distribution.json"), "utf8")
2823
2802
  );
2824
2803
  const release = manifest && typeof manifest === "object" && Reflect.get(manifest, "release");
2825
2804
  if (typeof release !== "string")
@@ -2849,22 +2828,22 @@ function swiftCompilerRelease(release) {
2849
2828
  function swiftToolchainBin(release) {
2850
2829
  if (process.platform === "darwin") {
2851
2830
  const dirs = [os.homedir(), "/"].map(
2852
- (base) => path5.join(base, `Library/Developer/Toolchains/${release}.xctoolchain/usr/bin`)
2831
+ (base) => path4.join(base, `Library/Developer/Toolchains/${release}.xctoolchain/usr/bin`)
2853
2832
  );
2854
- return dirs.find((dir) => fs2.existsSync(path5.join(dir, "swift"))) ?? dirs[0];
2833
+ return dirs.find((dir) => fs.existsSync(path4.join(dir, "swift"))) ?? dirs[0];
2855
2834
  }
2856
2835
  if (process.env.CONTRAST_SWIFT_TOOLCHAINS) {
2857
- return path5.join(process.env.CONTRAST_SWIFT_TOOLCHAINS, release, "usr/bin");
2836
+ return path4.join(process.env.CONTRAST_SWIFT_TOOLCHAINS, release, "usr/bin");
2858
2837
  }
2859
- const image = path5.join("/opt/swift", release, "usr/bin");
2860
- if (fs2.existsSync(path5.join(image, "swift"))) return image;
2838
+ const image = path4.join("/opt/swift", release, "usr/bin");
2839
+ if (fs.existsSync(path4.join(image, "swift"))) return image;
2861
2840
  if (release.includes("-custom-"))
2862
- return path5.join(peachHome(), "swift", "toolchains", release, "usr/bin");
2863
- return (process.env.PATH ?? "").split(path5.delimiter).find((dir) => dir && fs2.existsSync(path5.join(dir, "swift"))) ?? image;
2841
+ return path4.join(peachHome(), "swift", "toolchains", release, "usr/bin");
2842
+ return (process.env.PATH ?? "").split(path4.delimiter).find((dir) => dir && fs.existsSync(path4.join(dir, "swift"))) ?? image;
2864
2843
  }
2865
2844
  var SWIFT_AUTOLINK_LINKER = ".peach-wasm-ld";
2866
2845
  function writeSwiftAutolinkLinker(directory, toolchainBin) {
2867
- const linker = path5.join(directory, SWIFT_AUTOLINK_LINKER);
2846
+ const linker = path4.join(directory, SWIFT_AUTOLINK_LINKER);
2868
2847
  const script = `#!/bin/sh
2869
2848
  set -eu
2870
2849
  for arg in "$@"; do
@@ -2874,7 +2853,7 @@ for arg in "$@"; do
2874
2853
  awk 'BEGIN { RS = " "; ORS = " " } /^"-l/ { if (seen[$0]++) next } { print }' "$rsp" > "$rsp.dedup"
2875
2854
  mv "$rsp.dedup" "$rsp"
2876
2855
  if [ "\${PEACH_DEFER_WASM_LINK:-}" = "1" ] && grep -q '"--start-lib"' "$rsp"; then
2877
- cp "$rsp" ${JSON.stringify(path5.join(directory, ".peach-link.rsp"))}
2856
+ cp "$rsp" ${JSON.stringify(path4.join(directory, ".peach-link.rsp"))}
2878
2857
  out=$(awk 'BEGIN { RS = " " } prev == "\\"'-o'\\"" { gsub(/^"|"[[:space:]]*$/, ""); print; exit } { prev = $0 }' "$rsp")
2879
2858
  if [ -n "$out" ]; then
2880
2859
  printf '\\000asm\\001\\000\\000\\000' > "$out"
@@ -2884,18 +2863,37 @@ for arg in "$@"; do
2884
2863
  ;;
2885
2864
  esac
2886
2865
  done
2887
- exec ${JSON.stringify(path5.join(toolchainBin, "wasm-ld"))} "$@"
2866
+ exec ${JSON.stringify(path4.join(toolchainBin, "wasm-ld"))} "$@"
2888
2867
  `;
2889
- if (fs2.existsSync(linker) && fs2.readFileSync(linker, "utf8") === script) return linker;
2890
- fs2.mkdirSync(directory, { recursive: true });
2868
+ if (fs.existsSync(linker) && fs.readFileSync(linker, "utf8") === script) return linker;
2869
+ fs.mkdirSync(directory, { recursive: true });
2891
2870
  const next = `${linker}.${process.pid}`;
2892
- fs2.writeFileSync(next, script, { mode: 493 });
2893
- fs2.renameSync(next, linker);
2871
+ fs.writeFileSync(next, script, { mode: 493 });
2872
+ fs.renameSync(next, linker);
2894
2873
  return linker;
2895
2874
  }
2896
2875
  function peachHome() {
2897
2876
  const override = process.env.PEACH_HOME;
2898
- return override ? path5.resolve(override) : path5.join(os.homedir(), ".peach");
2877
+ return override ? path4.resolve(override) : path4.join(os.homedir(), ".peach");
2878
+ }
2879
+ var BUILDERS_ROOT_ENV = "CONTRAST_BUILDERS_ROOT";
2880
+ function buildersRootEnv() {
2881
+ const root = process.env[BUILDERS_ROOT_ENV]?.trim();
2882
+ return root ? root : null;
2883
+ }
2884
+ function swiftCacheDir() {
2885
+ const root = buildersRootEnv();
2886
+ return root ? path4.join(root, "peach-cache") : path4.join(peachHome(), "cache");
2887
+ }
2888
+ function swiftPackageCacheOptions() {
2889
+ const root = path4.join(swiftCacheDir(), "swiftpm");
2890
+ return [
2891
+ ...["cache", "config", "security"].flatMap((name2) => [
2892
+ `--${name2}-path`,
2893
+ path4.join(root, name2)
2894
+ ]),
2895
+ "--disable-keychain"
2896
+ ];
2899
2897
  }
2900
2898
  var scratch;
2901
2899
  var linuxLibraryPath;
@@ -2909,16 +2907,16 @@ function swiftEnvironment(base = process.env) {
2909
2907
  } : {},
2910
2908
  ...scratch ? {
2911
2909
  TMPDIR: scratch.directory,
2912
- XDG_CONFIG_HOME: path5.join(scratch.home, ".config"),
2913
- XDG_CACHE_HOME: path5.join(scratch.home, ".cache"),
2914
- XDG_DATA_HOME: path5.join(scratch.home, ".local", "share"),
2910
+ XDG_CONFIG_HOME: path4.join(scratch.home, ".config"),
2911
+ XDG_CACHE_HOME: path4.join(scratch.home, ".cache"),
2912
+ XDG_DATA_HOME: path4.join(scratch.home, ".local", "share"),
2915
2913
  ...process.platform === "linux" ? { HOME: scratch.home } : {}
2916
2914
  } : {}
2917
2915
  };
2918
2916
  }
2919
2917
  function swiftSourceSdk(root) {
2920
2918
  const pin = JSON.parse(
2921
- fs2.readFileSync(path5.join(root, "toolchain.json"), "utf8")
2919
+ fs.readFileSync(path4.join(root, "toolchain.json"), "utf8")
2922
2920
  );
2923
2921
  if (!pin || typeof pin !== "object" || typeof Reflect.get(pin, "wasmSdkId") !== "string" || typeof Reflect.get(pin, "wasmSdkUrl") !== "string" || typeof Reflect.get(pin, "wasmSdkChecksum") !== "string")
2924
2922
  throw new Error(`${root} pins no wasm SDK id, url and checksum`);
@@ -2940,7 +2938,7 @@ function swiftToolchain(release, sdk) {
2940
2938
  ${swiftInstallSteps(release, sdk)}`
2941
2939
  );
2942
2940
  }
2943
- const swift = path5.join(bin, "swift");
2941
+ const swift = path4.join(bin, "swift");
2944
2942
  const sdks = execFileSync(swift, ["sdk", "list", ...swiftSdkOptions()], {
2945
2943
  encoding: "utf8",
2946
2944
  env: swiftEnvironment(),
@@ -2972,31 +2970,31 @@ function swiftSdkBundle(swift, id, options) {
2972
2970
  { encoding: "utf8", env: swiftEnvironment(), stdio: ["ignore", "pipe", "pipe"] }
2973
2971
  );
2974
2972
  const sysroot = /^sdkRootPath: (.+)$/m.exec(configuration)?.[1]?.trim();
2975
- if (!sysroot || !path5.isAbsolute(sysroot))
2973
+ if (!sysroot || !path4.isAbsolute(sysroot))
2976
2974
  throw new Error(`Swift SDK ${id} reports no absolute sdkRootPath`);
2977
2975
  let bundle = sysroot;
2978
2976
  while (!bundle.endsWith(".artifactbundle")) {
2979
- const parent = path5.dirname(bundle);
2977
+ const parent = path4.dirname(bundle);
2980
2978
  if (parent === bundle)
2981
2979
  throw new Error(`Swift SDK ${id} is outside an artifact bundle`);
2982
2980
  bundle = parent;
2983
2981
  }
2984
- return fs2.realpathSync(bundle);
2982
+ return fs.realpathSync(bundle);
2985
2983
  }
2986
2984
  var sdkFileHashes = /* @__PURE__ */ new Map();
2987
2985
  function swiftSdkPayloadChecksum(bundle) {
2988
2986
  const hash = createHash2("sha256");
2989
2987
  function visit(relative) {
2990
- const file = path5.join(bundle, relative);
2991
- const stat = fs2.lstatSync(file, { bigint: true });
2988
+ const file = path4.join(bundle, relative);
2989
+ const stat = fs.lstatSync(file, { bigint: true });
2992
2990
  if (stat.isSymbolicLink()) {
2993
- const resolved = path5.relative(bundle, fs2.realpathSync(file));
2994
- if (resolved === ".." || resolved.startsWith(`..${path5.sep}`) || path5.isAbsolute(resolved))
2991
+ const resolved = path4.relative(bundle, fs.realpathSync(file));
2992
+ if (resolved === ".." || resolved.startsWith(`..${path4.sep}`) || path4.isAbsolute(resolved))
2995
2993
  throw new Error(`Swift SDK symlink escapes its bundle: ${relative}`);
2996
- hash.update(JSON.stringify([relative, "link", fs2.readlinkSync(file)]) + "\n");
2994
+ hash.update(JSON.stringify([relative, "link", fs.readlinkSync(file)]) + "\n");
2997
2995
  } else if (stat.isDirectory()) {
2998
2996
  hash.update(JSON.stringify([relative, "directory"]) + "\n");
2999
- for (const name2 of fs2.readdirSync(file).sort()) visit(path5.join(relative, name2));
2997
+ for (const name2 of fs.readdirSync(file).sort()) visit(path4.join(relative, name2));
3000
2998
  } else if (stat.isFile()) {
3001
2999
  const stamp = [stat.dev, stat.ino, stat.size, stat.mtimeNs, stat.ctimeNs].join(":");
3002
3000
  let cached = sdkFileHashes.get(file);
@@ -3013,8 +3011,8 @@ function swiftSdkPayloadChecksum(bundle) {
3013
3011
  return hash.digest("hex");
3014
3012
  }
3015
3013
  function swiftSdkVerificationFile(bundle, sdk) {
3016
- return path5.join(
3017
- path5.dirname(bundle),
3014
+ return path4.join(
3015
+ path4.dirname(bundle),
3018
3016
  ".peach-sdk-checksums",
3019
3017
  `${sdk.wasmSdkId}-${sdk.wasmSdkChecksum}.json`
3020
3018
  );
@@ -3022,11 +3020,11 @@ function swiftSdkVerificationFile(bundle, sdk) {
3022
3020
  function verifySwiftSdk(swift, sdk) {
3023
3021
  const bundle = swiftSdkBundle(swift, sdk.wasmSdkId, swiftSdkOptions());
3024
3022
  const file = swiftSdkVerificationFile(bundle, sdk);
3025
- if (!fs2.existsSync(file))
3023
+ if (!fs.existsSync(file))
3026
3024
  throw new Error(
3027
3025
  `Swift SDK ${sdk.wasmSdkId} has no verified archive binding for ${sdk.wasmSdkChecksum}. Hydrate it with installSwiftWasmSdk before compiling.`
3028
3026
  );
3029
- const receipt = JSON.parse(fs2.readFileSync(file, "utf8"));
3027
+ const receipt = JSON.parse(fs.readFileSync(file, "utf8"));
3030
3028
  if (!receipt || typeof receipt !== "object" || !("wasmSdkId" in receipt) || receipt.wasmSdkId !== sdk.wasmSdkId || !("wasmSdkChecksum" in receipt) || receipt.wasmSdkChecksum !== sdk.wasmSdkChecksum || !("payloadChecksum" in receipt) || receipt.payloadChecksum !== swiftSdkPayloadChecksum(bundle))
3031
3029
  throw new Error(
3032
3030
  `Swift SDK ${sdk.wasmSdkId} installed payload differs from its verified archive ${sdk.wasmSdkChecksum}`
@@ -3034,28 +3032,28 @@ function verifySwiftSdk(swift, sdk) {
3034
3032
  }
3035
3033
  function swiftFileChecksum(file) {
3036
3034
  const hash = createHash2("sha256");
3037
- const fd = fs2.openSync(file, "r");
3035
+ const fd = fs.openSync(file, "r");
3038
3036
  const buffer = Buffer.allocUnsafe(1024 * 1024);
3039
3037
  try {
3040
- let size = fs2.readSync(fd, buffer, 0, buffer.length, null);
3038
+ let size = fs.readSync(fd, buffer, 0, buffer.length, null);
3041
3039
  while (size > 0) {
3042
3040
  hash.update(buffer.subarray(0, size));
3043
- size = fs2.readSync(fd, buffer, 0, buffer.length, null);
3041
+ size = fs.readSync(fd, buffer, 0, buffer.length, null);
3044
3042
  }
3045
3043
  } finally {
3046
- fs2.closeSync(fd);
3044
+ fs.closeSync(fd);
3047
3045
  }
3048
3046
  return hash.digest("hex");
3049
3047
  }
3050
3048
  function swiftHostCompilerFiles(release, root) {
3051
- const file = path5.join(root, "compiler.json");
3049
+ const file = path4.join(root, "compiler.json");
3052
3050
  const pin = release === privateSwiftRelease() ? {
3053
3051
  identity: release.replace(/^.*-custom-/, ""),
3054
3052
  manifest: swiftFileChecksum(file)
3055
3053
  } : swiftHostCompilerArchive(release);
3056
3054
  if (swiftFileChecksum(file) !== pin.manifest)
3057
3055
  throw new Error(`Swift compiler manifest mismatch at ${root}`);
3058
- const manifest = JSON.parse(fs2.readFileSync(file, "utf8"));
3056
+ const manifest = JSON.parse(fs.readFileSync(file, "utf8"));
3059
3057
  if (!manifest || typeof manifest !== "object" || !("identity" in manifest) || manifest.identity !== pin.identity || !("host" in manifest) || manifest.host !== `${process.platform}-${process.arch}` || !("files" in manifest) || !manifest.files || typeof manifest.files !== "object") {
3060
3058
  throw new Error(`Swift compiler identity mismatch at ${root}`);
3061
3059
  }
@@ -3069,7 +3067,7 @@ function swiftHostCompilerFiles(release, root) {
3069
3067
  }
3070
3068
  function verifySwiftHostCompiler(release, root) {
3071
3069
  for (const [relative, checksum] of swiftHostCompilerFiles(release, root)) {
3072
- if (swiftFileChecksum(path5.join(root, relative)) !== checksum)
3070
+ if (swiftFileChecksum(path4.join(root, relative)) !== checksum)
3073
3071
  throw new Error(`Swift compiler binary mismatch: ${relative}`);
3074
3072
  }
3075
3073
  }
@@ -3079,8 +3077,8 @@ function swiftCompiler(release) {
3079
3077
  if (cached) return cached;
3080
3078
  const bin = swiftToolchainBin(release);
3081
3079
  if (release.includes("-custom-"))
3082
- verifySwiftHostCompiler(release, path5.resolve(bin, "../.."));
3083
- const version = execFileSync(path5.join(bin, "swift"), ["--version"], {
3080
+ verifySwiftHostCompiler(release, path4.resolve(bin, "../.."));
3081
+ const version = execFileSync(path4.join(bin, "swift"), ["--version"], {
3084
3082
  encoding: "utf8",
3085
3083
  env: swiftEnvironment(),
3086
3084
  stdio: ["ignore", "pipe", "pipe"]
@@ -3098,7 +3096,7 @@ function swiftSdkInstallCommand(release, wasmSdk) {
3098
3096
  const { wasmSdkId, wasmSdkUrl, wasmSdkChecksum } = wasmSdk;
3099
3097
  const program = `import { installSwiftWasmSdk } from "peachsim/swift-toolchain"; installSwiftWasmSdk(${JSON.stringify(release)}, ${JSON.stringify({ wasmSdkId, wasmSdkUrl, wasmSdkChecksum })})`;
3100
3098
  const directory = process.env.PEACH_SWIFT_SDKS_PATH;
3101
- const environment = directory ? `PEACH_SWIFT_SDKS_PATH='${path5.resolve(directory).replaceAll("'", "'\\''")}' ` : "";
3099
+ const environment = directory ? `PEACH_SWIFT_SDKS_PATH='${path4.resolve(directory).replaceAll("'", "'\\''")}' ` : "";
3102
3100
  return `${environment}node --input-type=module -e '${program.replaceAll("'", "'\\''")}'`;
3103
3101
  }
3104
3102
  function swiftInstallSteps(release, wasmSdk) {
@@ -3113,7 +3111,7 @@ function swiftCompilerInstall(release) {
3113
3111
  return { note: " (private: its builder installs it)", commands: [] };
3114
3112
  if (release.includes("-custom-")) {
3115
3113
  const archive = swiftHostCompilerArchive(release);
3116
- const directory = path5.resolve(swiftToolchainBin(release), "../..");
3114
+ const directory = path4.resolve(swiftToolchainBin(release), "../..");
3117
3115
  return {
3118
3116
  note: "",
3119
3117
  commands: [
@@ -3158,7 +3156,7 @@ function swiftObjCPlatformFlags(toolchainBin, minimum) {
3158
3156
  minimum % 100
3159
3157
  ].join(".");
3160
3158
  const result = spawnSync4(
3161
- path6.join(toolchainBin, "clang"),
3159
+ path5.join(toolchainBin, "clang"),
3162
3160
  [
3163
3161
  "-target",
3164
3162
  `arm64-apple-ios${version}-simulator`,
@@ -3202,14 +3200,19 @@ var swiftObjCRuntimeFlags = [
3202
3200
  // src/swift-objc-standin.ts
3203
3201
  import { execFileSync as execFileSync2, spawnSync as spawnSync5 } from "node:child_process";
3204
3202
  import { createHash as createHash3 } from "node:crypto";
3205
- import fs3 from "node:fs";
3206
- import path8 from "node:path";
3203
+ import fs2 from "node:fs";
3204
+ import path7 from "node:path";
3205
+
3206
+ // src/is-record.ts
3207
+ function isRecord(value) {
3208
+ return typeof value === "object" && value !== null && !Array.isArray(value);
3209
+ }
3207
3210
 
3208
3211
  // src/swift-objc-sdk.ts
3209
- import path7 from "node:path";
3212
+ import path6 from "node:path";
3210
3213
  var IOS_SDK_TARGET = "arm64-apple-ios16.0-simulator";
3211
3214
  var OVERLAY_PATH = /^usr\/lib\/swift\/([^/]+)\.swiftmodule\/arm64-apple-ios-simulator\.swiftinterface$/;
3212
- 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);
3215
+ var tree = typeof __PEACH_BUNDLED_IOS_SDK__ === "undefined" ? readIosSdkTree(path6.join(peachsimPackageRoot(), "sdk", "ios")) : Object.entries(__PEACH_BUNDLED_IOS_SDK__).sort(([a], [b]) => a < b ? -1 : 1);
3213
3216
  var IOS_SDK_HEADERS = {};
3214
3217
  var IOS_SDK_OVERLAYS = {};
3215
3218
  for (const [file, text2] of tree) {
@@ -3359,10 +3362,14 @@ var SWIFT_NATIVE_SOURCE_EXTENSIONS = [
3359
3362
  ".def",
3360
3363
  ".modulemap"
3361
3364
  ];
3362
- function clangImportNames(text2) {
3365
+ function clangImportNames(text2, isLocalHeader) {
3363
3366
  return [
3364
- ...text2.matchAll(/^\s*(?:#\s*(?:import|include)\s*<(\w+)\/|@import\s+(\w+))/gm)
3365
- ].map((match) => match[1] ?? match[2]);
3367
+ ...text2.matchAll(
3368
+ /^\s*(?:#\s*(?:import|include)\s*<((\w+)\/[^>]+)>|@import\s+(\w+))/gm
3369
+ )
3370
+ ].flatMap(
3371
+ (match) => match[1] && isLocalHeader?.(match[1]) ? [] : [match[2] ?? match[3]]
3372
+ );
3366
3373
  }
3367
3374
  function moduleMapTokens(text2) {
3368
3375
  return (text2.match(/\/\*[\s\S]*?\*\/|\/\/[^\n]*|"[^"]*"|[\w.*]+|[{}\[\]]/g) ?? []).filter((token) => !token.startsWith("/"));
@@ -3385,9 +3392,13 @@ ${declaration}
3385
3392
  export *
3386
3393
  }`;
3387
3394
  }
3395
+ var fmtConstantInterpreterFlags = (flags) => flags.some((flag) => flag.includes("/fmt/")) ? ["-fexperimental-new-constant-interpreter"] : [];
3396
+ var withoutGlogModuleMap = (flags) => flags.filter(
3397
+ (flag) => !(flag.startsWith("-fmodule-map-file=") && flag.endsWith("/glog.modulemap"))
3398
+ );
3388
3399
  function clangSettingEntries(settings, tool) {
3389
3400
  return (settings ?? []).flatMap(
3390
- (setting) => setting.tool !== tool ? [] : "headerSearchPath" in setting ? [`.headerSearchPath(${JSON.stringify(setting.headerSearchPath)})`] : [`.unsafeFlags(${JSON.stringify(setting.flags)})`]
3401
+ (setting) => setting.tool !== tool ? [] : "headerSearchPath" in setting ? [`.headerSearchPath(${JSON.stringify(setting.headerSearchPath)})`] : [`.unsafeFlags(${JSON.stringify(withoutGlogModuleMap(setting.flags))})`]
3391
3402
  );
3392
3403
  }
3393
3404
  function clangMacroSetting(macro) {
@@ -3756,9 +3767,12 @@ var IOS_SDK_ID = createHash3("sha256").update(JSON.stringify(iosSdkEntries())).d
3756
3767
  function objcSdkIntakeFlags(headers, toolchainBin, minimum) {
3757
3768
  return [
3758
3769
  ...swiftObjCPlatformFlags(toolchainBin, minimum),
3759
- // AvailabilityInternal.h derives this through __is_target_os(ios), which
3760
- // is false for wasm32.
3770
+ // AvailabilityInternal.h derives these through __is_target_os(ios), which
3771
+ // is false for wasm32. the maximum is the sdk the headers come from, as
3772
+ // xcode defines it, so `#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_26_0`
3773
+ // sources see the members the sdk declares instead of a 17.0 default.
3761
3774
  `-D__IPHONE_OS_VERSION_MIN_REQUIRED=${minimum}`,
3775
+ `-D__IPHONE_OS_VERSION_MAX_ALLOWED=__IPHONE_${NATIVE_GRAPH_SDK_VERSION.replace(".", "_")}`,
3762
3776
  // apple's build setting for a 32-bit target to keep NSInteger and
3763
3777
  // NSUInteger long, the nominal types they have on arm64.
3764
3778
  "-DNS_BUILD_32_LIKE_64=1",
@@ -3774,15 +3788,15 @@ function objcSdkIntakeFlags(headers, toolchainBin, minimum) {
3774
3788
  "-fblocks",
3775
3789
  ...WASI_EMULATION_FLAGS,
3776
3790
  "-iframework",
3777
- path8.join(headers, "System/Library/Frameworks"),
3791
+ path7.join(headers, "System/Library/Frameworks"),
3778
3792
  "-isystem",
3779
- path8.join(headers, "wasm/include"),
3793
+ path7.join(headers, "wasm/include"),
3780
3794
  // libxml2 headers sit one level deeper, as in the iOS sdk: a unit
3781
3795
  // includes <libxml/parser.h> through usr/include/libxml2, never the parent.
3782
3796
  "-I",
3783
- path8.join(headers, "usr/include/libxml2"),
3797
+ path7.join(headers, "usr/include/libxml2"),
3784
3798
  "-idirafter",
3785
- path8.join(headers, "usr/include")
3799
+ path7.join(headers, "usr/include")
3786
3800
  ];
3787
3801
  }
3788
3802
  function iosDeploymentMinimum(version) {
@@ -3794,49 +3808,49 @@ function iosDeploymentMinimum(version) {
3794
3808
  // src/swift-shared-sdk.ts
3795
3809
  import { execFileSync as execFileSync3 } from "node:child_process";
3796
3810
  import { createHash as createHash4 } from "node:crypto";
3797
- import fs4, { readdirSync as readdirSync4, readFileSync as readFileSync6 } from "node:fs";
3798
- import path9 from "node:path";
3811
+ import fs3, { readdirSync as readdirSync4, readFileSync as readFileSync6 } from "node:fs";
3812
+ import path8 from "node:path";
3799
3813
  var distributionHeaderRoots = /* @__PURE__ */ new Map();
3800
3814
  function swiftSharedSdkRoot(moduleRoot, distribution) {
3801
- const root = path9.resolve(moduleRoot, distribution ? "sdk/ios" : "../peachsim/sdk/ios");
3815
+ const root = path8.resolve(moduleRoot, distribution ? "sdk/ios" : "../peachsim/sdk/ios");
3802
3816
  if (!distribution) return root;
3803
3817
  let headers = distributionHeaderRoots.get(root);
3804
- if (!headers || !fs4.existsSync(headers)) {
3805
- const files = readdirSync4(root, { recursive: true, withFileTypes: true }).filter((entry) => entry.isFile()).map((entry) => path9.relative(root, path9.join(entry.parentPath, entry.name))).sort();
3818
+ if (!headers || !fs3.existsSync(headers)) {
3819
+ const files = readdirSync4(root, { recursive: true, withFileTypes: true }).filter((entry) => entry.isFile()).map((entry) => path8.relative(root, path8.join(entry.parentPath, entry.name))).sort();
3806
3820
  const hash = createHash4("sha256");
3807
3821
  for (const file of files) {
3808
- const bytes = readFileSync6(path9.join(root, file));
3822
+ const bytes = readFileSync6(path8.join(root, file));
3809
3823
  hash.update(JSON.stringify([file, bytes.length])).update(bytes);
3810
3824
  }
3811
- headers = path9.join(
3825
+ headers = path8.join(
3812
3826
  swiftCacheDir(),
3813
3827
  "swift-sdk-views",
3814
3828
  `headers-${hash.digest("hex")}`
3815
3829
  );
3816
- if (!fs4.existsSync(headers)) {
3817
- fs4.mkdirSync(path9.dirname(headers), { recursive: true });
3818
- const staging = fs4.mkdtempSync(`${headers}-`);
3819
- fs4.cpSync(root, staging, { recursive: true, preserveTimestamps: true });
3830
+ if (!fs3.existsSync(headers)) {
3831
+ fs3.mkdirSync(path8.dirname(headers), { recursive: true });
3832
+ const staging = fs3.mkdtempSync(`${headers}-`);
3833
+ fs3.cpSync(root, staging, { recursive: true, preserveTimestamps: true });
3820
3834
  try {
3821
- fs4.renameSync(staging, headers);
3835
+ fs3.renameSync(staging, headers);
3822
3836
  } catch (error) {
3823
- fs4.rmSync(staging, { recursive: true, force: true });
3824
- if (!fs4.existsSync(headers)) throw error;
3837
+ fs3.rmSync(staging, { recursive: true, force: true });
3838
+ if (!fs3.existsSync(headers)) throw error;
3825
3839
  }
3826
3840
  }
3827
3841
  distributionHeaderRoots.set(root, headers);
3828
3842
  }
3829
3843
  const now = /* @__PURE__ */ new Date();
3830
- fs4.utimesSync(headers, now, now);
3844
+ fs3.utimesSync(headers, now, now);
3831
3845
  return headers;
3832
3846
  }
3833
3847
  function swiftSharedSdkFlags(moduleRoot, distribution) {
3834
3848
  const root = swiftSharedSdkRoot(moduleRoot, distribution);
3835
3849
  return [
3836
3850
  "-isystem",
3837
- path9.join(root, "wasm/storage-include"),
3851
+ path8.join(root, "wasm/storage-include"),
3838
3852
  "-idirafter",
3839
- path9.join(root, "usr/include")
3853
+ path8.join(root, "usr/include")
3840
3854
  ];
3841
3855
  }
3842
3856
  function readULEB(b, o) {
@@ -3959,53 +3973,53 @@ function weakenBundleInArchive(arBuf) {
3959
3973
  }
3960
3974
  }
3961
3975
  function mirrorTree(real, mirror, overrides) {
3962
- fs4.mkdirSync(mirror);
3963
- for (const entry of fs4.readdirSync(real, { withFileTypes: true })) {
3964
- const from = path9.join(real, entry.name);
3965
- const to = path9.join(mirror, entry.name);
3976
+ fs3.mkdirSync(mirror);
3977
+ for (const entry of fs3.readdirSync(real, { withFileTypes: true })) {
3978
+ const from = path8.join(real, entry.name);
3979
+ const to = path8.join(mirror, entry.name);
3966
3980
  const override = overrides.get(from);
3967
- if (override) fs4.symlinkSync(override, to);
3968
- else if (fs4.statSync(from).isDirectory()) mirrorTree(from, to, overrides);
3969
- else fs4.symlinkSync(from, to);
3981
+ if (override) fs3.symlinkSync(override, to);
3982
+ else if (fs3.statSync(from).isDirectory()) mirrorTree(from, to, overrides);
3983
+ else fs3.symlinkSync(from, to);
3970
3984
  }
3971
3985
  }
3972
3986
  function stageOverlaySlot(realRoot, stagingRoot, relPath) {
3973
- const segments = relPath.split(path9.sep);
3987
+ const segments = relPath.split(path8.sep);
3974
3988
  let real = realRoot;
3975
3989
  let mirror = stagingRoot;
3976
3990
  for (let i = 0; i < segments.length; i++) {
3977
3991
  const segment = segments[i];
3978
3992
  for (const entry of readdirSync4(real)) {
3979
3993
  if (entry === segment) continue;
3980
- const dest = path9.join(mirror, entry);
3981
- if (!fs4.lstatSync(dest, { throwIfNoEntry: false })) {
3982
- fs4.symlinkSync(path9.join(real, entry), dest);
3994
+ const dest = path8.join(mirror, entry);
3995
+ if (!fs3.lstatSync(dest, { throwIfNoEntry: false })) {
3996
+ fs3.symlinkSync(path8.join(real, entry), dest);
3983
3997
  }
3984
3998
  }
3985
- real = path9.join(real, segment);
3986
- mirror = path9.join(mirror, segment);
3999
+ real = path8.join(real, segment);
4000
+ mirror = path8.join(mirror, segment);
3987
4001
  if (i < segments.length - 1) {
3988
- if (fs4.lstatSync(mirror, { throwIfNoEntry: false })?.isSymbolicLink()) {
3989
- fs4.unlinkSync(mirror);
4002
+ if (fs3.lstatSync(mirror, { throwIfNoEntry: false })?.isSymbolicLink()) {
4003
+ fs3.unlinkSync(mirror);
3990
4004
  }
3991
- fs4.mkdirSync(mirror, { recursive: true });
4005
+ fs3.mkdirSync(mirror, { recursive: true });
3992
4006
  }
3993
4007
  }
3994
- if (fs4.lstatSync(mirror, { throwIfNoEntry: false })?.isSymbolicLink()) {
3995
- fs4.unlinkSync(mirror);
4008
+ if (fs3.lstatSync(mirror, { throwIfNoEntry: false })?.isSymbolicLink()) {
4009
+ fs3.unlinkSync(mirror);
3996
4010
  }
3997
4011
  return mirror;
3998
4012
  }
3999
4013
  var sdkViews = /* @__PURE__ */ new Map();
4000
4014
  function swiftSharedSdkViewOptions(moduleRoot, distribution, toolchainBin, sdk) {
4001
- const frameworks = path9.join(
4015
+ const frameworks = path8.join(
4002
4016
  swiftSharedSdkRoot(moduleRoot, distribution),
4003
4017
  "System/Library/Frameworks"
4004
4018
  );
4005
- const overlay = path9.join(swiftSharedSdkRoot(moduleRoot, distribution), "wasm/include");
4006
- const overlayFiles = readdirSync4(overlay, { recursive: true, withFileTypes: true }).filter((entry) => entry.isFile()).map((entry) => path9.join(entry.parentPath, entry.name)).sort();
4019
+ const overlay = path8.join(swiftSharedSdkRoot(moduleRoot, distribution), "wasm/include");
4020
+ const overlayFiles = readdirSync4(overlay, { recursive: true, withFileTypes: true }).filter((entry) => entry.isFile()).map((entry) => path8.join(entry.parentPath, entry.name)).sort();
4007
4021
  const key = JSON.stringify([
4008
- "v10",
4022
+ "v11",
4009
4023
  toolchainBin,
4010
4024
  sdk,
4011
4025
  frameworks,
@@ -4013,9 +4027,9 @@ function swiftSharedSdkViewOptions(moduleRoot, distribution, toolchainBin, sdk)
4013
4027
  swiftSdkOptions()
4014
4028
  ]);
4015
4029
  const cached = sdkViews.get(key);
4016
- if (cached && fs4.existsSync(cached.manifest)) return touchSdkView(cached.options);
4030
+ if (cached && fs3.existsSync(cached.manifest)) return touchSdkView(cached.options);
4017
4031
  const configuration = execFileSync3(
4018
- path9.join(toolchainBin, "swift"),
4032
+ path8.join(toolchainBin, "swift"),
4019
4033
  [
4020
4034
  "sdk",
4021
4035
  "configure",
@@ -4027,67 +4041,67 @@ function swiftSharedSdkViewOptions(moduleRoot, distribution, toolchainBin, sdk)
4027
4041
  { encoding: "utf8", env: swiftEnvironment(), stdio: ["ignore", "pipe", "pipe"] }
4028
4042
  );
4029
4043
  const sysroot = /^sdkRootPath: (.+)$/m.exec(configuration)?.[1]?.trim();
4030
- if (!sysroot || !path9.isAbsolute(sysroot))
4044
+ if (!sysroot || !path8.isAbsolute(sysroot))
4031
4045
  throw new Error(`swift sdk ${sdk} reports no absolute sdkRootPath`);
4032
4046
  let bundle = sysroot;
4033
4047
  while (!bundle.endsWith(".artifactbundle")) {
4034
- if (path9.dirname(bundle) === bundle)
4048
+ if (path8.dirname(bundle) === bundle)
4035
4049
  throw new Error(`swift sdk ${sdk} is outside an artifact bundle`);
4036
- bundle = path9.dirname(bundle);
4050
+ bundle = path8.dirname(bundle);
4037
4051
  }
4038
- const view = path9.join(
4052
+ const view = path8.join(
4039
4053
  swiftCacheDir(),
4040
4054
  "swift-sdk-views",
4041
4055
  createHash4("sha256").update(key).digest("hex").slice(0, 16)
4042
4056
  );
4043
- const manifest = path9.join(view, path9.basename(bundle), "info.json");
4044
- if (!fs4.existsSync(manifest)) {
4045
- fs4.mkdirSync(path9.dirname(view), { recursive: true });
4046
- const staging = fs4.mkdtempSync(`${view}-`);
4047
- const realRoot = path9.dirname(bundle);
4048
- const overrides = /* @__PURE__ */ new Map([
4049
- [path9.join(sysroot, "darwin/System/Library/Frameworks"), frameworks],
4050
- [
4051
- path9.join(sysroot, "darwin/usr/include/MacTypes.h"),
4052
- path9.join(swiftSharedSdkRoot(moduleRoot, distribution), "usr/include/MacTypes.h")
4053
- ]
4057
+ const manifest = path8.join(view, path8.basename(bundle), "info.json");
4058
+ if (!fs3.existsSync(manifest)) {
4059
+ fs3.mkdirSync(path8.dirname(view), { recursive: true });
4060
+ const staging = fs3.mkdtempSync(`${view}-`);
4061
+ const realRoot = path8.dirname(bundle);
4062
+ const overrides = new Map([
4063
+ [path8.join(sysroot, "darwin/System/Library/Frameworks"), frameworks],
4064
+ ...["MacTypes.h", "net/if.h"].map((header) => [
4065
+ path8.join(sysroot, "darwin/usr/include", header),
4066
+ path8.join(swiftSharedSdkRoot(moduleRoot, distribution), "usr/include", header)
4067
+ ])
4054
4068
  ]);
4055
4069
  for (const file of overlayFiles) {
4056
4070
  overrides.set(
4057
- path9.join(sysroot, "darwin/wasm/include", path9.relative(overlay, file)),
4071
+ path8.join(sysroot, "darwin/wasm/include", path8.relative(overlay, file)),
4058
4072
  file
4059
4073
  );
4060
4074
  }
4061
4075
  mirrorTree(
4062
4076
  sysroot,
4063
- stageOverlaySlot(realRoot, staging, path9.relative(realRoot, sysroot)),
4077
+ stageOverlaySlot(realRoot, staging, path8.relative(realRoot, sysroot)),
4064
4078
  overrides
4065
4079
  );
4066
4080
  for (const [file, shared] of overrides) {
4067
- const destination = path9.join(staging, path9.relative(realRoot, file));
4068
- if (fs4.lstatSync(destination, { throwIfNoEntry: false })) continue;
4069
- fs4.mkdirSync(path9.dirname(destination), { recursive: true });
4070
- fs4.symlinkSync(shared, destination);
4081
+ const destination = path8.join(staging, path8.relative(realRoot, file));
4082
+ if (fs3.lstatSync(destination, { throwIfNoEntry: false })) continue;
4083
+ fs3.mkdirSync(path8.dirname(destination), { recursive: true });
4084
+ fs3.symlinkSync(shared, destination);
4071
4085
  }
4072
- const foundationArchive = path9.join(
4073
- path9.dirname(sysroot),
4086
+ const foundationArchive = path8.join(
4087
+ path8.dirname(sysroot),
4074
4088
  "swift.xctoolchain/usr/lib/swift_static/wasi/libFoundation.a"
4075
4089
  );
4076
- if (fs4.existsSync(foundationArchive)) {
4090
+ if (fs3.existsSync(foundationArchive)) {
4077
4091
  const foundationSlot = stageOverlaySlot(
4078
4092
  realRoot,
4079
4093
  staging,
4080
- path9.relative(realRoot, foundationArchive)
4094
+ path8.relative(realRoot, foundationArchive)
4081
4095
  );
4082
- const arBuf = new Uint8Array(fs4.readFileSync(foundationArchive));
4096
+ const arBuf = new Uint8Array(fs3.readFileSync(foundationArchive));
4083
4097
  weakenBundleInArchive(arBuf);
4084
- fs4.writeFileSync(foundationSlot, arBuf);
4098
+ fs3.writeFileSync(foundationSlot, arBuf);
4085
4099
  }
4086
4100
  try {
4087
- fs4.renameSync(staging, view);
4101
+ fs3.renameSync(staging, view);
4088
4102
  } catch (error) {
4089
- fs4.rmSync(staging, { recursive: true, force: true });
4090
- if (!fs4.existsSync(manifest)) throw error;
4103
+ fs3.rmSync(staging, { recursive: true, force: true });
4104
+ if (!fs3.existsSync(manifest)) throw error;
4091
4105
  }
4092
4106
  }
4093
4107
  const options = ["--swift-sdks-path", view];
@@ -4096,28 +4110,28 @@ function swiftSharedSdkViewOptions(moduleRoot, distribution, toolchainBin, sdk)
4096
4110
  }
4097
4111
  function touchSdkView(options) {
4098
4112
  const now = /* @__PURE__ */ new Date();
4099
- fs4.utimesSync(options[1], now, now);
4113
+ fs3.utimesSync(options[1], now, now);
4100
4114
  return options;
4101
4115
  }
4102
4116
  function swiftSharedSdkInputFiles(moduleRoot) {
4103
4117
  const root = swiftSharedSdkRoot(moduleRoot, false);
4104
- return readdirSync4(root, { recursive: true, withFileTypes: true }).filter((entry) => entry.isFile()).map((entry) => path9.relative(moduleRoot, path9.join(entry.parentPath, entry.name))).sort();
4118
+ return readdirSync4(root, { recursive: true, withFileTypes: true }).filter((entry) => entry.isFile()).map((entry) => path8.relative(moduleRoot, path8.join(entry.parentPath, entry.name))).sort();
4105
4119
  }
4106
4120
 
4107
4121
  // src/swift-darwin-records.ts
4108
4122
  var DARWIN_RECORDS_PREFIX = "DarwinRecords-";
4109
4123
  var darwinRecordsMinimum = () => iosDeploymentMinimum(NATIVE_GRAPH_SDK_VERSION) ?? 0;
4110
4124
  function compileDarwinRecords(args) {
4111
- const records = path10.join(args.packageRoot, "Sources/DarwinRecords");
4112
- const runtime = mkdtempSync2(path10.join(tmpdir2(), "peach-objc-runtime-"));
4113
- symlinkSync(path10.join(args.darwin, "usr/include/objc"), path10.join(runtime, "objc"));
4125
+ const records = path9.join(args.packageRoot, "Sources/DarwinRecords");
4126
+ const runtime = mkdtempSync2(path9.join(tmpdir2(), "peach-objc-runtime-"));
4127
+ symlinkSync(path9.join(args.darwin, "usr/include/objc"), path9.join(runtime, "objc"));
4114
4128
  const objects = readdirSync5(records).filter((file) => file.endsWith(".c") || file.endsWith(".m")).sort((a, b) => a < b ? -1 : a > b ? 1 : 0).map((file) => {
4115
- const object = path10.join(
4129
+ const object = path9.join(
4116
4130
  args.out,
4117
4131
  `${DARWIN_RECORDS_PREFIX}${file.replace(/\.[cm]$/, ".o")}`
4118
4132
  );
4119
4133
  execFileSync4(
4120
- path10.join(args.bin, "clang"),
4134
+ path9.join(args.bin, "clang"),
4121
4135
  [
4122
4136
  "--target=wasm32-unknown-wasip1",
4123
4137
  `--sysroot=${args.sysroot}`,
@@ -4127,7 +4141,7 @@ function compileDarwinRecords(args) {
4127
4141
  // __BLOCKS__, as ios builds libmalloc
4128
4142
  ...file.endsWith(".m") ? [...swiftObjCRuntimeFlags, "-fwasm-exceptions"] : ["-fblocks"],
4129
4143
  // assert() keeps __FILE__, which would carry the builder's checkout
4130
- `-ffile-prefix-map=${records}${path10.sep}=DarwinRecords/`,
4144
+ `-ffile-prefix-map=${records}${path9.sep}=DarwinRecords/`,
4131
4145
  // apple's headers select on the ios identity original units compile
4132
4146
  // with, and TargetConditionals.h refuses a compiler without it
4133
4147
  ...file.endsWith(".m") ? objcSdkIntakeFlags(args.darwin, args.bin, args.minimum) : [
@@ -4140,7 +4154,7 @@ function compileDarwinRecords(args) {
4140
4154
  ...swiftSharedSdkFlags(args.packageRoot, false)
4141
4155
  ],
4142
4156
  "-c",
4143
- path10.join(records, file),
4157
+ path9.join(records, file),
4144
4158
  "-o",
4145
4159
  object
4146
4160
  ],
@@ -4376,7 +4390,18 @@ function designTimeSites(source) {
4376
4390
  while (t < to && tokens[t].kind !== "newline") t++;
4377
4391
  continue;
4378
4392
  }
4379
- t = text(source, tokens[t + 1]) === "(" ? skipGroup(t + 1) : t + 1;
4393
+ const availability = word === "#available" || word === "#unavailable";
4394
+ t++;
4395
+ if (!availability && text(source, tokens[t]) === "<" && tokens[t].start === token.end) {
4396
+ let depth = 0;
4397
+ do {
4398
+ const p = text(source, tokens[t++]);
4399
+ if (p === "<") depth++;
4400
+ else if (p === ">") depth--;
4401
+ } while (t < to && depth > 0);
4402
+ }
4403
+ if (text(source, tokens[t]) === "(") t = skipGroup(t);
4404
+ if (!availability && text(source, tokens[t]) === "{") t = skipGroup(t);
4380
4405
  continue;
4381
4406
  }
4382
4407
  if (token.kind === "at") {
@@ -4543,11 +4568,6 @@ function designTimeDiagnostic(output, files) {
4543
4568
  }).join("\n");
4544
4569
  }
4545
4570
 
4546
- // src/is-record.ts
4547
- function isRecord(value) {
4548
- return typeof value === "object" && value !== null && !Array.isArray(value);
4549
- }
4550
-
4551
4571
  // src/swift-distribution-contract.ts
4552
4572
  var SWIFT_DISTRIBUTION_MANIFEST = "distribution.json";
4553
4573
  var SWIFT_DISTRIBUTION_HOSTS = [
@@ -4595,7 +4615,7 @@ import { createHash as createHash5 } from "node:crypto";
4595
4615
  import { existsSync, readFileSync as readFileSync7 } from "node:fs";
4596
4616
  import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
4597
4617
  import os2 from "node:os";
4598
- import path11 from "node:path";
4618
+ import path10 from "node:path";
4599
4619
  import { promisify as promisify2 } from "node:util";
4600
4620
  import { brotliCompress, constants as zlibConstants, gunzip, gzip } from "node:zlib";
4601
4621
  var run = promisify2(execFile2);
@@ -4612,8 +4632,8 @@ function cachedBrotli(bytes, quality, cacheKey) {
4612
4632
  const cacheId = `${quality}:${key}`;
4613
4633
  const cached = brotliMemoryCache.get(cacheId);
4614
4634
  if (cached) return cached;
4615
- const dir = path11.join(os2.homedir(), ".peach", "cache", "swift-brotli");
4616
- const file = path11.join(dir, `${key}${quality === 11 ? "" : "-q4"}.br`);
4635
+ const dir = path10.join(os2.homedir(), ".peach", "cache", "swift-brotli");
4636
+ const file = path10.join(dir, `${key}${quality === 11 ? "" : "-q4"}.br`);
4617
4637
  const pending = (async () => {
4618
4638
  try {
4619
4639
  return await readFile(file);
@@ -4677,7 +4697,7 @@ function swiftIcuAsset(toolchainBin, sdk) {
4677
4697
  );
4678
4698
  }
4679
4699
  async function load(toolchainBin, sdk) {
4680
- const swift = path11.join(toolchainBin, "swift");
4700
+ const swift = path10.join(toolchainBin, "swift");
4681
4701
  if (!existsSync(swift))
4682
4702
  throw new Error(`swift-icu: no swift at ${swift} for the ${sdk} SDK's icu data`);
4683
4703
  const { stdout: listed } = await run(swift, ["sdk", "list", ...swiftSdkOptions()], {
@@ -4700,7 +4720,7 @@ async function load(toolchainBin, sdk) {
4700
4720
  const resources = /^swiftStaticResourcesPath: (.+)$/m.exec(stdout)?.[1]?.trim();
4701
4721
  if (!resources) throw new Error(`swift-icu: ${sdk} names no static resources`);
4702
4722
  return Buffer.from(
4703
- icuSegment(archiveMember(readFileSync7(path11.join(resources, ARCHIVE)), MEMBER))
4723
+ icuSegment(archiveMember(readFileSync7(path10.join(resources, ARCHIVE)), MEMBER))
4704
4724
  );
4705
4725
  }
4706
4726
  function archiveMember(archive, name2) {
@@ -4756,8 +4776,8 @@ function icuSegment(object) {
4756
4776
  }
4757
4777
 
4758
4778
  // src/swift-link-roots.ts
4759
- import fs5 from "node:fs";
4760
- import path12 from "node:path";
4779
+ import fs4 from "node:fs";
4780
+ import path11 from "node:path";
4761
4781
  var OBJC_SEGMENTS = ["__objc_cats", "__objc_class_aliases"];
4762
4782
  var leb = (bytes, at) => {
4763
4783
  let value = 0;
@@ -4774,6 +4794,7 @@ function objcSegmentSizes(bytes) {
4774
4794
  const names = [];
4775
4795
  const sizes = [];
4776
4796
  let hasExportedSymbol = false;
4797
+ let definesCategory = false;
4777
4798
  while (at.offset < bytes.length) {
4778
4799
  const id = bytes[at.offset++];
4779
4800
  const size = leb(bytes, at);
@@ -4813,6 +4834,8 @@ function objcSegmentSizes(bytes) {
4813
4834
  }
4814
4835
  } else if (symKind === 1) {
4815
4836
  const sLen = leb(bytes, at);
4837
+ if (!isUndef && Buffer.from(bytes.subarray(at.offset, at.offset + sLen)).toString().startsWith(".objc_category_"))
4838
+ definesCategory = true;
4816
4839
  at.offset += sLen;
4817
4840
  if (!isUndef) {
4818
4841
  leb(bytes, at);
@@ -4849,6 +4872,7 @@ function objcSegmentSizes(bytes) {
4849
4872
  result.set(name2, (result.get(name2) ?? 0) + (sizes[index] ?? 0));
4850
4873
  });
4851
4874
  result.set("__wasm_exported", hasExportedSymbol ? 1 : 0);
4875
+ result.set("__objc_category", definesCategory ? 1 : 0);
4852
4876
  return result;
4853
4877
  }
4854
4878
  var rootsByDistribution = /* @__PURE__ */ new Map();
@@ -4856,7 +4880,7 @@ function swiftObjcRootObjects(id, root, objects) {
4856
4880
  const cached = rootsByDistribution.get(id);
4857
4881
  if (cached) return cached;
4858
4882
  const measured = objects.map(
4859
- (object) => [object, objcSegmentSizes(fs5.readFileSync(path12.join(root, object)))]
4883
+ (object) => [object, objcSegmentSizes(fs4.readFileSync(path11.join(root, object)))]
4860
4884
  );
4861
4885
  const empty = /* @__PURE__ */ new Map();
4862
4886
  for (const [, sizes] of measured)
@@ -4911,14 +4935,14 @@ import {
4911
4935
  rmSync as rmSync3,
4912
4936
  statSync
4913
4937
  } from "node:fs";
4914
- import path13 from "node:path";
4938
+ import path12 from "node:path";
4915
4939
  function prepareSwiftProjectProcess(root, user) {
4916
4940
  const home = `${root}.project-home`;
4917
4941
  rmSync3(home, { recursive: true, force: true });
4918
- const tmp = path13.join(home, "tmp");
4919
- const swiftpm = path13.join(home, "swiftpm");
4942
+ const tmp = path12.join(home, "tmp");
4943
+ const swiftpm = path12.join(home, "swiftpm");
4920
4944
  mkdirSync(tmp, { recursive: true });
4921
- const caches = ["cache", "config", "security"].map((name2) => path13.join(swiftpm, name2));
4945
+ const caches = ["cache", "config", "security"].map((name2) => path12.join(swiftpm, name2));
4922
4946
  for (const directory of caches) mkdirSync(directory, { recursive: true });
4923
4947
  execFileSync5("chown", ["-R", "-P", `${user.uid}:${user.gid}`, root, home]);
4924
4948
  chmodSync(root, 448);
@@ -4929,14 +4953,14 @@ function prepareSwiftProjectProcess(root, user) {
4929
4953
  env: {
4930
4954
  HOME: home,
4931
4955
  TMPDIR: tmp,
4932
- XDG_CONFIG_HOME: path13.join(home, ".config"),
4933
- XDG_CACHE_HOME: path13.join(home, ".cache"),
4934
- XDG_DATA_HOME: path13.join(home, ".local", "share")
4956
+ XDG_CONFIG_HOME: path12.join(home, ".config"),
4957
+ XDG_CACHE_HOME: path12.join(home, ".cache"),
4958
+ XDG_DATA_HOME: path12.join(home, ".local", "share")
4935
4959
  },
4936
4960
  cacheOptions: [
4937
4961
  ...["cache", "config", "security"].flatMap((name2) => [
4938
4962
  `--${name2}-path`,
4939
- path13.join(swiftpm, name2)
4963
+ path12.join(swiftpm, name2)
4940
4964
  ]),
4941
4965
  "--disable-keychain"
4942
4966
  ]
@@ -4952,7 +4976,7 @@ function projectOutputFile(root, file, user) {
4952
4976
  const real = realpathSync(file);
4953
4977
  const base = realpathSync(root);
4954
4978
  const stat = statSync(real);
4955
- if (!real.startsWith(base + path13.sep) || !stat.isFile() || stat.uid !== user.uid) {
4979
+ if (!real.startsWith(base + path12.sep) || !stat.isFile() || stat.uid !== user.uid) {
4956
4980
  throw new Error(`swift-compile: project output ${file} is not a file of its build`);
4957
4981
  }
4958
4982
  return real;
@@ -4961,7 +4985,7 @@ function removeProjectLinks(root) {
4961
4985
  const pending = [root];
4962
4986
  for (let directory = pending.pop(); directory; directory = pending.pop()) {
4963
4987
  for (const entry of readdirSync6(directory, { withFileTypes: true })) {
4964
- const full = path13.join(directory, entry.name);
4988
+ const full = path12.join(directory, entry.name);
4965
4989
  if (directory === root && entry.name === ".build") continue;
4966
4990
  if (directory === root && entry.name.startsWith(".peach-modules-")) {
4967
4991
  rmSync3(full, { recursive: true, force: true });
@@ -5002,7 +5026,26 @@ import {
5002
5026
  rmSync as rmSync4,
5003
5027
  writeFileSync as writeFileSync2
5004
5028
  } from "node:fs";
5029
+ import { homedir as homedir2 } from "node:os";
5005
5030
  import path14 from "node:path";
5031
+
5032
+ // src/home-paths.ts
5033
+ import { randomUUID as randomUUID2 } from "node:crypto";
5034
+ import fs5 from "node:fs";
5035
+ import { homedir } from "node:os";
5036
+ import path13 from "node:path";
5037
+ var PEACH_HOME_ENV = "PEACH_HOME";
5038
+ function ambientHomeDir() {
5039
+ return path13.join(homedir(), ".peach");
5040
+ }
5041
+ function rnxHomeDir() {
5042
+ const override = process.env[PEACH_HOME_ENV];
5043
+ if (override && override.length > 0) return path13.resolve(override);
5044
+ return ambientHomeDir();
5045
+ }
5046
+ var DAEMON_LOCKFILE_MAX_BYTES = 16 * 1024;
5047
+
5048
+ // src/swift-root-lock.ts
5006
5049
  var POLL_MS = 250;
5007
5050
  var START_TOLERANCE_MS = 2e3;
5008
5051
  function errorCode(error) {
@@ -5775,11 +5818,9 @@ function parseWasmObjectBytes(file, buf, isDist) {
5775
5818
  }
5776
5819
  }
5777
5820
  const typePrefixesInObj = /* @__PURE__ */ new Set();
5778
- if (isDist) {
5779
- for (let i = 0; i < symKind.length; i++) {
5780
- if ((symFlags[i] & 16) === 0 && symNames[i].startsWith("$s") && symNames[i].endsWith("Mn")) {
5781
- typePrefixesInObj.add(symNames[i].slice(0, -2));
5782
- }
5821
+ for (let i = 0; i < symKind.length; i++) {
5822
+ if ((symFlags[i] & 16) === 0 && symNames[i].startsWith("$s") && symNames[i].endsWith("Mn")) {
5823
+ typePrefixesInObj.add(symNames[i].slice(0, -2));
5783
5824
  }
5784
5825
  }
5785
5826
  const objcRegisterFuncToTypePrefix = /* @__PURE__ */ new Map();
@@ -6061,15 +6102,16 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
6061
6102
  set.add(symIdx);
6062
6103
  workQueue.push({ kind: "datasym", obj, symIdx });
6063
6104
  };
6064
- const prunableTypes = /* @__PURE__ */ new Set();
6105
+ const knownTypes = /* @__PURE__ */ new Set();
6065
6106
  for (const o of distObjs.values())
6066
- for (const t of o.typePrefixesInObj) prunableTypes.add(t);
6107
+ for (const t of o.typePrefixesInObj) knownTypes.add(t);
6067
6108
  const globalLiveTypes = /* @__PURE__ */ new Set();
6068
6109
  const pendingConformances = /* @__PURE__ */ new Map();
6110
+ const eagerConformanceObjects = /* @__PURE__ */ new Set();
6069
6111
  const conformingType = (name2) => {
6070
6112
  for (let n = name2.length - 1; n > 2; n--) {
6071
6113
  const prefix = name2.slice(0, n);
6072
- if (prunableTypes.has(prefix)) return prefix;
6114
+ if (knownTypes.has(prefix)) return prefix;
6073
6115
  }
6074
6116
  return void 0;
6075
6117
  };
@@ -6081,7 +6123,11 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
6081
6123
  const waiting = pendingConformances.get(pref);
6082
6124
  if (waiting) {
6083
6125
  pendingConformances.delete(pref);
6084
- for (const w of waiting) activateSymbolInObj(w.obj, w.symIdx);
6126
+ for (const w of waiting) {
6127
+ eagerConformanceObjects.add(w.obj);
6128
+ extractObject(w.obj);
6129
+ activateSymbolInObj(w.obj, w.symIdx);
6130
+ }
6085
6131
  }
6086
6132
  const mnName = `${pref}Mn`;
6087
6133
  for (let i = 0; i < obj.symNames.length; i++) {
@@ -6108,7 +6154,7 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
6108
6154
  }
6109
6155
  };
6110
6156
  const checkTypeTrigger = (obj, rawSymName) => {
6111
- if (!obj.isDist || !rawSymName) return;
6157
+ if (!rawSymName) return;
6112
6158
  const sName = rawSymName.startsWith(".Lgot.") ? rawSymName.slice(6) : rawSymName;
6113
6159
  const objcPref = obj.objcClassSymToTypePrefix.get(sName);
6114
6160
  if (objcPref) {
@@ -6199,6 +6245,13 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
6199
6245
  }
6200
6246
  for (const fIdx of obj.rootFuncs) markFuncLive(obj, fIdx);
6201
6247
  for (const sIdx of obj.rootSegs) markSegLive(obj, sIdx);
6248
+ for (const name2 of obj.symNames) {
6249
+ const loaded = name2?.match(/^_c_(\w+)__load$/)?.[1];
6250
+ if (!loaded) continue;
6251
+ const classSym = obj.symNames.indexOf(`._OBJC_CLASS_${loaded}`);
6252
+ if (classSym !== -1 && (obj.symFlags[classSym] & 16) === 0)
6253
+ activateSymbolInObj(obj, classSym);
6254
+ }
6202
6255
  if (obj.file.endsWith("libswiftCore__Swift.o")) {
6203
6256
  for (const pref of obj.typePrefixesInObj) {
6204
6257
  if (!pref.startsWith("$ss")) {
@@ -6223,11 +6276,6 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
6223
6276
  const type = conformingType(mcName);
6224
6277
  if (type === void 0 || globalLiveTypes.has(type))
6225
6278
  activateSymbolInObj(obj, r.rs);
6226
- else {
6227
- let list = pendingConformances.get(type);
6228
- if (!list) pendingConformances.set(type, list = []);
6229
- list.push({ obj, symIdx: r.rs });
6230
- }
6231
6279
  }
6232
6280
  }
6233
6281
  }
@@ -6235,6 +6283,17 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
6235
6283
  }
6236
6284
  }
6237
6285
  };
6286
+ for (const obj of distObjs.values()) {
6287
+ if (!obj.isDist) continue;
6288
+ for (const r of obj.dataRelocList) {
6289
+ if (obj.segNames[r.segIdx] !== "swift5_protocol_conformances") continue;
6290
+ const type = conformingType(obj.symNames[r.rs]);
6291
+ if (type === void 0 || obj.typePrefixesInObj.has(type)) continue;
6292
+ let list = pendingConformances.get(type);
6293
+ if (!list) pendingConformances.set(type, list = []);
6294
+ list.push({ obj, symIdx: r.rs });
6295
+ }
6296
+ }
6238
6297
  let hasClangObjCEager = false;
6239
6298
  const eagerBuildPrunable = [];
6240
6299
  for (const f of eagerFiles) {
@@ -6653,6 +6712,12 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
6653
6712
  emittedPruned.add(ef);
6654
6713
  }
6655
6714
  }
6715
+ for (const obj of eagerConformanceObjects) {
6716
+ if (!emittedPruned.has(obj.file) && prunedMap.has(obj.file)) {
6717
+ outTokens.push(prunedMap.get(obj.file));
6718
+ emittedPruned.add(obj.file);
6719
+ }
6720
+ }
6656
6721
  outTokens.push("--start-lib");
6657
6722
  for (const rf of prunableCandidates) {
6658
6723
  if (emittedPruned.has(rf)) continue;
@@ -6828,7 +6893,8 @@ function isSwiftResourceBundles(value) {
6828
6893
  }
6829
6894
 
6830
6895
  // src/wasm-optimize.ts
6831
- import { BINARYEN_VERSION, wasmOpt } from "wasm-opt";
6896
+ import { execFileSync as execFileSync8 } from "node:child_process";
6897
+ import { BinaryNotFoundError, BINARYEN_VERSION, wasmOpt } from "wasm-opt";
6832
6898
  var FEATURES = [
6833
6899
  "threads",
6834
6900
  "bulk-memory",
@@ -6842,7 +6908,7 @@ var FEATURES = [
6842
6908
  "sign-ext"
6843
6909
  ];
6844
6910
  var WASM_OPTIMIZE_IDENTITY = `wasm-opt ${BINARYEN_VERSION} -Oz ${FEATURES.join(",")}`;
6845
- async function optimizeWasm(file, output) {
6911
+ async function runWasmOpt(file, output) {
6846
6912
  const result = await wasmOpt([
6847
6913
  "-Oz",
6848
6914
  ...FEATURES.map((feature) => `--enable-${feature}`),
@@ -6853,6 +6919,29 @@ async function optimizeWasm(file, output) {
6853
6919
  if (result.status !== 0)
6854
6920
  throw new Error(`wasm-opt exited ${result.status}: ${result.stderr}`);
6855
6921
  }
6922
+ function installWasmOpt() {
6923
+ try {
6924
+ execFileSync8("npx", ["-y", "wasm-opt", "--wasm-opt-install"], {
6925
+ timeout: 6e5,
6926
+ stdio: ["ignore", "pipe", "pipe"],
6927
+ env: { ...process.env, WASM_OPT_VERSION: BINARYEN_VERSION }
6928
+ });
6929
+ } catch (error) {
6930
+ const detail = error instanceof Error ? error.message : String(error);
6931
+ throw new Error(`wasm-opt binary missing and on-demand install failed: ${detail}`, {
6932
+ cause: error
6933
+ });
6934
+ }
6935
+ }
6936
+ async function optimizeWasm(file, output) {
6937
+ try {
6938
+ await runWasmOpt(file, output);
6939
+ } catch (error) {
6940
+ if (!(error instanceof BinaryNotFoundError)) throw error;
6941
+ installWasmOpt();
6942
+ await runWasmOpt(file, output);
6943
+ }
6944
+ }
6856
6945
 
6857
6946
  // src/write-build-file.ts
6858
6947
  import { existsSync as existsSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync10, writeFileSync as writeFileSync3 } from "node:fs";
@@ -7079,21 +7168,20 @@ function swiftModuleInterface(moduleRoot, name2, interfaceRoot) {
7079
7168
  return { declared: swiftInterfaceDeclarations(header), header };
7080
7169
  }
7081
7170
  const sources = path19.join(moduleRoot, "Sources", name2);
7082
- if (!existsSync4(sources)) return null;
7171
+ const built = path19.join(moduleRoot, ".build/host", `${name2}-Swift.h`);
7172
+ if (!existsSync4(sources) || !existsSync4(built)) return null;
7083
7173
  const declared = /* @__PURE__ */ new Set();
7084
7174
  for (const file of readdirSync8(sources, { recursive: true, encoding: "utf8" }))
7085
7175
  if (file.endsWith(".swift"))
7086
- for (const [, objc] of readFileSync11(path19.join(sources, file), "utf8").matchAll(
7087
- /@objc\((\w+)\)\s+(?:\w+\s+)*?(?:protocol|class)\s/g
7176
+ for (const [, objc, subclass] of readFileSync11(
7177
+ path19.join(sources, file),
7178
+ "utf8"
7179
+ ).matchAll(
7180
+ /@objc\((\w+)\)\s+(?:\w+\s+)*?(?:protocol|class)\s|^(?:public|open)\s+(?:final\s+)?class\s+(\w+)\s*:\s*NSObject\b/gm
7088
7181
  ))
7089
- declared.add(objc);
7182
+ declared.add(objc ?? subclass);
7090
7183
  if (declared.size === 0) return null;
7091
- const built = path19.join(moduleRoot, ".build/host", `${name2}-Swift.h`);
7092
- return {
7093
- declared,
7094
- header: existsSync4(built) ? clangInterfaceHeader(readFileSync11(built, "utf8")) : `// ${name2}-Swift.h is generated when ${name2} builds
7095
- `
7096
- };
7184
+ return { declared, header: clangInterfaceHeader(readFileSync11(built, "utf8")) };
7097
7185
  }
7098
7186
  var clangInterfaceHeader = (header) => header.replace(/^@import (?:UIKitCore|UIKitText);$/gm, "@import UIKit;").replace(/^@import CoreFoundation;$/gm, "@import Foundation;").replace(/\b_TtC10Foundation\d+(NS\w+)\b/g, "$1");
7099
7187
  var swiftInterfaceDeclarations = (header) => /* @__PURE__ */ new Set([
@@ -7309,9 +7397,10 @@ function swiftProjectBuildKey(moduleRoot, release) {
7309
7397
  var SYSTEM_MODULE_LIBRARIES = {
7310
7398
  "sqlite3.h": "sqlite3",
7311
7399
  "sqlite3ext.h": "sqlite3",
7400
+ "bzlib.h": "bz2",
7312
7401
  SQLite3: "sqlite3"
7313
7402
  };
7314
- var SYSTEM_MODULE_IMPORT = /^\s*(?:#\s*(?:import|include)\s*<(sqlite3(?:ext)?\.h)>|@import\s+(SQLite3)\b)/gm;
7403
+ var SYSTEM_MODULE_IMPORT = /^\s*(?:#\s*(?:import|include)\s*<(sqlite3(?:ext)?\.h|bzlib\.h)>|@import\s+(SQLite3)\b)/gm;
7315
7404
  function compileTargets(input) {
7316
7405
  const manifest = input.files["Package.swift"];
7317
7406
  if (manifest === void 0) return [];
@@ -7507,7 +7596,7 @@ function swiftSdkPaths(moduleRoot, toolchainBin) {
7507
7596
  const key = JSON.stringify([toolchainBin, sdk, options]);
7508
7597
  const cached = sdkPaths.get(key);
7509
7598
  if (cached) return cached;
7510
- const configuration = execFileSync8(
7599
+ const configuration = execFileSync9(
7511
7600
  path19.join(toolchainBin, "swift"),
7512
7601
  [
7513
7602
  "sdk",
@@ -7677,6 +7766,11 @@ function swiftTargetDependencies(files, targets) {
7677
7766
  const siblings = /* @__PURE__ */ new Map();
7678
7767
  for (const target of targets) {
7679
7768
  const prefix = target.path === "." ? "" : `${target.path}/`;
7769
+ const ownsHeader = (header) => [`${prefix}${header}`, `${prefix}include/${header}`].some(
7770
+ (file) => Object.hasOwn(files, file) && !targets.some(
7771
+ (candidate) => candidate.name !== target.name && candidate.path !== "." && file.startsWith(`${candidate.path}/`)
7772
+ )
7773
+ );
7680
7774
  const deps = new Set(
7681
7775
  (target.dependencies ?? []).flatMap(
7682
7776
  (dependency) => dependency.kind === "target" && dependency.name !== target.name && names.has(dependency.name) ? [dependency.name] : []
@@ -7688,7 +7782,7 @@ function swiftTargetDependencies(files, targets) {
7688
7782
  (candidate) => candidate.name !== target.name && candidate.path !== "." && candidate.path.startsWith(prefix) && file.startsWith(`${candidate.path}/`)
7689
7783
  ))
7690
7784
  continue;
7691
- const imports = file.endsWith(".swift") ? swiftImportNames(contents) : SWIFT_NATIVE_SOURCE_EXTENSIONS.some((extension) => file.endsWith(extension)) ? clangImportNames(contents) : [];
7785
+ const imports = file.endsWith(".swift") ? swiftImportNames(contents) : SWIFT_NATIVE_SOURCE_EXTENSIONS.some((extension) => file.endsWith(extension)) ? clangImportNames(contents, ownsHeader) : [];
7692
7786
  for (const name2 of imports) {
7693
7787
  if (names.has(name2) && name2 !== target.name) deps.add(name2);
7694
7788
  }
@@ -7724,9 +7818,9 @@ var executableLinkFlags = (root) => ` "-Xclang-linker", "-O0",
7724
7818
  `;
7725
7819
  var darwinRecordsRegion = (quoted) => quoted.length ? ["-Wl,--start-lib", ...quoted, "-Wl,--end-lib"] : [];
7726
7820
  var REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
7727
- var MULTI_MANIFEST_VERSION = 64;
7821
+ var MULTI_MANIFEST_VERSION = 65;
7728
7822
  var SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
7729
- var compilerSourceDigest = true ? "c30b94c39ef2c57dd0f163385e565e0340acb99365cc16c5091e712d04e7fe68" : swiftCompilerSourceDigest(import.meta.dirname);
7823
+ var compilerSourceDigest = true ? "c1407efb75c18328e37b50abfe396dce388c41563443b4c3a1485a800114a92c" : swiftCompilerSourceDigest(import.meta.dirname);
7730
7824
  function swiftArtifactHash(input, release, moduleRoot) {
7731
7825
  const hash = createHash8("sha256");
7732
7826
  hash.update(`swift-compile
@@ -7811,6 +7905,13 @@ ${target}
7811
7905
  }
7812
7906
  return hash.digest("hex");
7813
7907
  }
7908
+ var nativeCxxCompilerFlags = ["-fno-cxx-modules"];
7909
+ var cFlagArray = (flags) => JSON.stringify(withoutGlogModuleMap(flags));
7910
+ var cxxFlagArray = (flags) => JSON.stringify([
7911
+ ...nativeCxxCompilerFlags,
7912
+ ...fmtConstantInterpreterFlags(flags),
7913
+ ...withoutGlogModuleMap(flags)
7914
+ ]);
7814
7915
  function swiftCrossImportFlags(moduleRoot, distribution) {
7815
7916
  const overlayRoot = path19.join(
7816
7917
  moduleRoot,
@@ -8043,13 +8144,13 @@ function emitSwiftPackageManifest(args) {
8043
8144
  (source) => /\.(?:cc|cpp|cxx|mm)$/.test(source)
8044
8145
  );
8045
8146
  const nativeSettings = native?.clang ? [
8046
- `cSettings: [${cDefines} .unsafeFlags(${flagArray(JSON.stringify([...nativeFlags, ...native.clang.flags]))})]`,
8147
+ `cSettings: [${cDefines} .unsafeFlags(${flagArray(cFlagArray([...nativeFlags, ...native.clang.flags]))})]`,
8047
8148
  ...nativeCxx ? [
8048
- `cxxSettings: [${cxxDefines} .unsafeFlags(${flagArray(JSON.stringify(["-fno-cxx-modules", ...cxxFlagsFor(nativeFlags), ...native.clang.cxxFlags]))})]`
8149
+ `cxxSettings: [${cxxDefines} .unsafeFlags(${flagArray(cxxFlagArray([...cxxFlagsFor(nativeFlags), ...native.clang.cxxFlags]))})]`
8049
8150
  ] : []
8050
8151
  ].join(", ") : [
8051
- `cSettings: [${cDefines}${declaredClangSettings(target, "c")} .unsafeFlags(${flagArray(JSON.stringify([...nativeFlags, ...native?.flags ?? []]))})]`,
8052
- `cxxSettings: [${cxxDefines}${declaredClangSettings(target, "cxx")} .unsafeFlags(${flagArray(JSON.stringify(["-fno-cxx-modules", ...cxxFlagsFor(nativeFlags), ...native?.cxxFlags ?? []]))})]`
8152
+ `cSettings: [${cDefines}${declaredClangSettings(target, "c")} .unsafeFlags(${flagArray(cFlagArray([...nativeFlags, ...native?.flags ?? []]))})]`,
8153
+ `cxxSettings: [${cxxDefines}${declaredClangSettings(target, "cxx")} .unsafeFlags(${flagArray(cxxFlagArray([...cxxFlagsFor(nativeFlags), ...native?.cxxFlags ?? []]))})]`
8053
8154
  ].join(", ");
8054
8155
  const exclusions = native?.clang ? [] : [
8055
8156
  ...native ? native.exclude ?? native.lateSources : [],
@@ -8118,9 +8219,9 @@ function emitSwiftPackageManifest(args) {
8118
8219
  ` path: ${JSON.stringify(group.path)},`,
8119
8220
  ` sources: ${JSON.stringify(group.sources)},`,
8120
8221
  ' publicHeadersPath: "include",',
8121
- ` cSettings: [${macroSettings(owner?.cDefines)}${declaredClangSettings(owner, "c")} .unsafeFlags(${flagArray(JSON.stringify([...nativeFlags, "-I", native.includeDirectory, "-I", args.headerDirectory, ...group.flags]))})],`,
8222
+ ` cSettings: [${macroSettings(owner?.cDefines)}${declaredClangSettings(owner, "c")} .unsafeFlags(${flagArray(cFlagArray([...nativeFlags, "-I", native.includeDirectory, ...args.headerDirectory ? ["-I", args.headerDirectory] : [], ...group.flags]))})],`,
8122
8223
  ...group.sources.some((source) => /\.(?:cc|cpp|cxx|mm)$/.test(source)) ? [
8123
- ` cxxSettings: [${macroSettings(owner?.cxxDefines)}${declaredClangSettings(owner, "cxx")} .unsafeFlags(${flagArray(JSON.stringify(["-fno-cxx-modules", ...cxxFlagsFor(nativeFlags), ...group.cxxFlags]))})]),`
8224
+ ` cxxSettings: [${macroSettings(owner?.cxxDefines)}${declaredClangSettings(owner, "cxx")} .unsafeFlags(${flagArray(cxxFlagArray([...cxxFlagsFor(nativeFlags), ...group.cxxFlags]))})]),`
8124
8225
  ] : [" ),"]
8125
8226
  ]) : [];
8126
8227
  }),
@@ -9828,20 +9929,34 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
9828
9929
  moduleInterfaces.set(name2, value);
9829
9930
  return value;
9830
9931
  };
9932
+ const podHeaders = /* @__PURE__ */ new Map();
9933
+ for (const settings of input.nativeTargets ?? [])
9934
+ for (const file of settings.headers) {
9935
+ const owner = /\/Headers\/(?:Public|Private)\/([\w+-]+)\/(?:\1\/)?[^/]+\.h$/.exec(
9936
+ file
9937
+ )?.[1];
9938
+ if (owner)
9939
+ podHeaders.set(path19.basename(file), [
9940
+ ...podHeaders.get(path19.basename(file)) ?? [],
9941
+ { owner, content: input.files[file] }
9942
+ ]);
9943
+ }
9944
+ const podHeaderOwner = (file, content) => /\/Headers\/(?:Public|Private)\/([\w+-]+)\//.exec(file)?.[1] ?? podHeaders.get(path19.basename(file))?.find((header) => header.content === content)?.owner;
9831
9945
  for (const settings of input.nativeTargets ?? []) {
9832
9946
  for (const file of settings.headers) {
9833
9947
  const destination = path19.join(layout.root, file);
9834
9948
  if (files.has(destination)) continue;
9835
9949
  const interfaceModule = /(?:^|\/)(\w+)-Swift\.h$/.exec(file)?.[1];
9836
9950
  const frameworkHeader = !interfaceModule && /(?:^|\/)(\w+)\.framework\/Headers\/[\w+.-]+\.h$/.exec(file)?.[1];
9837
- const frameworkInterface = frameworkHeader ? moduleInterface(frameworkHeader) : null;
9951
+ const interfaceOwner = frameworkHeader || (interfaceModule ? void 0 : podHeaderOwner(file, input.files[file]));
9952
+ const frameworkInterface = interfaceOwner ? moduleInterface(interfaceOwner) : null;
9838
9953
  const rawContents = interfaceModule && moduleInterface(interfaceModule)?.header || input.files[file];
9839
9954
  if (rawContents === void 0)
9840
9955
  throw new Error(`missing original Objective-C header ${file}`);
9841
9956
  const contents = frameworkInterface && typeof rawContents === "string" ? withoutSwiftDeclarations(
9842
9957
  rawContents,
9843
9958
  frameworkInterface.declared,
9844
- `#import <${frameworkHeader}/${frameworkHeader}-Swift.h>`
9959
+ `#import <${interfaceOwner}/${interfaceOwner}-Swift.h>`
9845
9960
  ) : rawContents;
9846
9961
  writeBuildFile(destination, contents);
9847
9962
  files.set(destination, contents);