peachsim 0.1.2224 → 0.1.2228

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 (171) hide show
  1. package/cli/bridge-flow-runner.ts +56 -3
  2. package/cli/commands/control.ts +27 -1
  3. package/cli/commands/flow.ts +26 -0
  4. package/cli/commands/package.ts +9 -2
  5. package/cli/drivers/playwright.ts +1 -0
  6. package/cli/drivers/types.ts +3 -0
  7. package/cli/internal-child.ts +4 -2
  8. package/dist-lib/agent-daemon-client.cjs +1 -1
  9. package/dist-lib/agent-events.cjs +1 -1
  10. package/dist-lib/attached-projects.cjs +1 -1
  11. package/dist-lib/auth/shared-session.cjs +1 -1
  12. package/dist-lib/backend-origin.cjs +1 -1
  13. package/dist-lib/beta.cjs +1 -1
  14. package/dist-lib/beta.mjs +1 -1
  15. package/dist-lib/bridge-constants.cjs +1 -1
  16. package/dist-lib/bridge-contract-input.cjs +1 -1
  17. package/dist-lib/bridge-contract-input.mjs +1 -1
  18. package/dist-lib/bridge-contract.cjs +1 -1
  19. package/dist-lib/bridge-contract.mjs +1 -1
  20. package/dist-lib/bundle-channel.cjs +931 -455
  21. package/dist-lib/capture-contract.cjs +1 -1
  22. package/dist-lib/capture-contract.mjs +1 -1
  23. package/dist-lib/cloud-contract.cjs +1 -1
  24. package/dist-lib/cloud-contract.mjs +1 -1
  25. package/dist-lib/cloud-test-args.cjs +1 -1
  26. package/dist-lib/cloud-test-args.mjs +1 -1
  27. package/dist-lib/cloud.cjs +1 -1
  28. package/dist-lib/cloud.mjs +1 -1
  29. package/dist-lib/config.cjs +1 -1
  30. package/dist-lib/config.mjs +1 -1
  31. package/dist-lib/detox/index.cjs +2 -2
  32. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  33. package/dist-lib/expo-swift-bundle.cjs +867 -391
  34. package/dist-lib/expo-swift-metadata.cjs +1 -1
  35. package/dist-lib/expo-swift-metadata.mjs +1 -1
  36. package/dist-lib/home-paths.cjs +1 -1
  37. package/dist-lib/host/bridge-host.cjs +926 -450
  38. package/dist-lib/host/fetch-proxy-handler.cjs +55 -12
  39. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  40. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  41. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  42. package/dist-lib/host/websocket-proxy.cjs +1 -1
  43. package/dist-lib/index.cjs +60 -16
  44. package/dist-lib/jump-to-source-babel.cjs +1 -1
  45. package/dist-lib/jump-to-source-native.cjs +1 -1
  46. package/dist-lib/kotlin-host.cjs +1 -1
  47. package/dist-lib/menu.cjs +1 -1
  48. package/dist-lib/menu.mjs +1 -1
  49. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  50. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  51. package/dist-lib/metro-production-bundle.cjs +11 -4
  52. package/dist-lib/metro-production-bundle.mjs +10 -4
  53. package/dist-lib/metro.cjs +60 -16
  54. package/dist-lib/native-app-identity-project.cjs +53 -9
  55. package/dist-lib/native-app-identity-project.mjs +84 -37
  56. package/dist-lib/native-app-identity.cjs +1 -1
  57. package/dist-lib/native-app-identity.mjs +1 -1
  58. package/dist-lib/native-firebase-metadata.cjs +1 -1
  59. package/dist-lib/native-firebase-metadata.mjs +1 -1
  60. package/dist-lib/pdfium-raster.cjs +1 -1
  61. package/dist-lib/pdfium-raster.mjs +1 -1
  62. package/dist-lib/plist.cjs +1 -1
  63. package/dist-lib/plist.mjs +1 -1
  64. package/dist-lib/profiles.cjs +1 -1
  65. package/dist-lib/public-brand.cjs +1 -1
  66. package/dist-lib/public-origins-lib-esm.json +26 -24
  67. package/dist-lib/public-origins-lib.json +66 -54
  68. package/dist-lib/react-native-host-modules.cjs +1 -1
  69. package/dist-lib/react-native-host-modules.mjs +1 -1
  70. package/dist-lib/reap-browser.cjs +1 -1
  71. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  72. package/dist-lib/sdk.cjs +1 -1
  73. package/dist-lib/sdk.mjs +1 -1
  74. package/dist-lib/skills.cjs +1049 -512
  75. package/dist-lib/swift-compile.cjs +557 -121
  76. package/dist-lib/swift-compile.mjs +693 -258
  77. package/dist-lib/swift-package.cjs +1 -1
  78. package/dist-lib/swift-package.mjs +1 -1
  79. package/dist-lib/swift-submit.cjs +1 -1
  80. package/dist-lib/swift-submit.mjs +1 -1
  81. package/dist-lib/swift-toolchain.cjs +38 -2
  82. package/dist-lib/swift.cjs +1 -1
  83. package/dist-lib/vite-swift.cjs +1726 -1209
  84. package/dist-lib/vite.cjs +55 -12
  85. package/dist-lib/worklet-executable.cjs +1 -1
  86. package/dist-lib/worklet-executable.mjs +1 -1
  87. package/dist-types/packages/peach-engine/src/bundle-parse-receipt.d.ts +17 -0
  88. package/dist-types/packages/peach-engine/src/engine/canvaskit-api.d.ts +2 -1
  89. package/dist-types/packages/peach-engine/src/engine/font-config.d.ts +2 -2
  90. package/dist-types/packages/peach-engine/src/engine/native-layout.d.ts +1 -0
  91. package/dist-types/packages/peach-engine/src/engine/native-paragraph.d.ts +4 -0
  92. package/dist-types/packages/peach-engine/src/engine/node.d.ts +2 -0
  93. package/dist-types/packages/peach-engine/src/engine/scene-table.d.ts +1 -1
  94. package/dist-types/packages/peach-engine/src/engine/types.d.ts +7 -0
  95. package/dist-types/packages/peach-engine/src/engine/yoga-layout.d.ts +2 -0
  96. package/dist-types/packages/peach-engine/src/metro-fingerprint.d.ts +3 -2
  97. package/dist-types/packages/peach-engine/src/preview/preview-room-contract.d.ts +6 -0
  98. package/dist-types/packages/peach-engine/src/render-worker/compositor-protocol.d.ts +1 -0
  99. package/dist-types/packages/peach-engine/src/render-worker/protocol.d.ts +15 -3
  100. package/dist-types/packages/peach-engine/src/rolldown-bundle-inventory.d.ts +0 -5
  101. package/dist-types/packages/peach-kit/src/capabilities.d.ts +2 -0
  102. package/dist-types/packages/peach-kit/src/internal.d.ts +1 -1
  103. package/dist-types/packages/peach-kit/src/ios-tint.d.ts +2 -0
  104. package/kotlin/sdk.tar.gz +0 -0
  105. package/package.json +1 -1
  106. package/runtime-companion.json +1 -1
  107. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFCGTypes.h +0 -6
  108. package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/NSCharacterSet.h +1 -1
  109. package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/NSURL.h +1 -1
  110. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIControl.h +0 -26
  111. package/sdk/ios/System/Library/Frameworks/UIKitTypes.framework/Headers/UIKitTypes.h +27 -0
  112. package/sdk/ios/usr/include/AvailabilityInternal.h +2 -2
  113. package/sdk/ios/usr/include/ObjectiveC.apinotes +380 -7
  114. package/sdk/ios/usr/include/peach/pthread.h +1 -7
  115. package/sdk/ios/wasm/include/TargetConditionals.h +2 -3
  116. package/sdk/ios/wasm/include/__struct_timeval.h +15 -0
  117. package/sdk/ios/wasm/include/__typedef_suseconds_t.h +9 -0
  118. package/sdk/ios/wasm/include/limits.h +1 -1
  119. package/sdk/ios/wasm/include/machine/_types.h +1 -1
  120. package/sdk/ios/wasm/include/machine/limits.h +1 -1
  121. package/sdk/ios/wasm/include/machine/param.h +2 -2
  122. package/sdk/ios/wasm/include/math.h +13 -0
  123. package/sdk/ios/wasm/include/pthread.h +1 -13
  124. package/sdk/ios/wasm/include/sys/resource.h +3 -0
  125. package/sdk/ios/wasm/include/sys/socket.h +0 -10
  126. package/sdk/ios/wasm/include/sys/stat.h +5 -2
  127. package/sdk/ios/wasm/include/sys/time.h +16 -3
  128. package/sdk/ios/wasm/include/sys/types.h +4 -1
  129. package/sdk/ios/wasm/include/time.h +2 -0
  130. package/sdk/ios/wasm/storage-include/TargetConditionals.h +2 -3
  131. package/sdk/native-hashes.json +14 -14
  132. package/src/metro-production-bundle.ts +15 -2
  133. package/src/native-slices.ts +3 -2
  134. package/src/native-static-libraries.ts +23 -23
  135. package/src/native-swift-slices.ts +2 -2
  136. package/src/nitro-adapter.lock.json +288 -288
  137. package/src/nitro-compiler-digest.ts +0 -1
  138. package/src/nitro-dependencies.ts +8 -9
  139. package/src/nitro-superset.lock.json +4 -4
  140. package/src/react-native-core-build.ts +2 -2
  141. package/src/swift-compile.ts +209 -47
  142. package/src/swift-compiler-digest.ts +2 -0
  143. package/src/swift-cxx-standin.ts +1 -1
  144. package/src/swift-darwin-records.ts +4 -4
  145. package/src/swift-distribution-contract.ts +2 -2
  146. package/src/swift-distribution.lock.json +13 -12
  147. package/src/swift-guest-compile.ts +6 -5
  148. package/src/swift-guest-image-ledger.ts +5 -5
  149. package/src/swift-guest-link.ts +1 -1
  150. package/src/swift-guest-linked-spans.ts +7 -4
  151. package/src/swift-guest-manifest.ts +2 -2
  152. package/src/swift-guest-source-inputs.ts +16 -5
  153. package/src/swift-host.ts +10 -5
  154. package/src/swift-icu.ts +1 -1
  155. package/src/swift-objc-compile.ts +9 -4
  156. package/src/swift-objc-standin.ts +1 -4
  157. package/src/swift-package-manifest.ts +5 -1
  158. package/src/swift-packages.ts +2 -2
  159. package/src/swift-shared-sdk.ts +1 -1
  160. package/src/swift-standin-emit.ts +3 -16
  161. package/src/swift-standins.ts +119 -87
  162. package/src/swift-toolchain.ts +37 -1
  163. package/src/swift-uniform-type-constants.ts +1 -1
  164. package/src/swift-wasm-prune.ts +17 -12
  165. package/src/swiftGuestImageContract.ts +4 -4
  166. package/src/swiftNativePinContract.ts +1 -1
  167. package/src/swiftRuntimeProductContract.ts +1 -1
  168. package/src/turbo-runtime.lock.json +28 -28
  169. package/src/wasm-narrow-boundary.ts +296 -0
  170. package/src/wasm-optimize.ts +59 -14
  171. package/src/xcode-project.ts +6 -4
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2224 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2228 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
 
3
3
  // src/swift-compile.ts
4
4
  import {
@@ -7,22 +7,23 @@ import {
7
7
  } from "node:child_process";
8
8
  import { createHash as createHash13, randomUUID as randomUUID5 } from "node:crypto";
9
9
  import {
10
+ chmodSync as chmodSync2,
10
11
  copyFileSync,
11
12
  cpSync,
12
13
  existsSync as existsSync5,
13
14
  lstatSync,
14
- mkdirSync as mkdirSync6,
15
+ mkdirSync as mkdirSync7,
15
16
  mkdtempSync as mkdtempSync3,
16
- readFileSync as readFileSync16,
17
+ readFileSync as readFileSync17,
17
18
  readdirSync as readdirSync8,
18
19
  readlinkSync,
19
20
  realpathSync as realpathSync5,
20
21
  renameSync as renameSync2,
21
- rmSync as rmSync6,
22
+ rmSync as rmSync7,
22
23
  statSync as statSync2,
23
24
  symlinkSync as symlinkSync2,
24
25
  utimesSync,
25
- writeFileSync as writeFileSync7
26
+ writeFileSync as writeFileSync8
26
27
  } from "node:fs";
27
28
  import os6 from "node:os";
28
29
  import path27 from "node:path";
@@ -2621,6 +2622,42 @@ function swiftSdkOptions() {
2621
2622
  var SWIFT_HOST_COMPILER_RELEASE = "swift-6.4.0-RELEASE-custom-81b2c791c27276bf";
2622
2623
  var SWIFT_HOST_COMPILER_ID = "81b2c791c27276bf";
2623
2624
  var compilerArchives = {
2625
+ "swift-6.4.0-RELEASE-custom-fb42d2535739dfd2": {
2626
+ identity: "fb42d2535739dfd2",
2627
+ archive: "tar.zst",
2628
+ hosts: {
2629
+ "darwin-arm64": {
2630
+ checksum: "5e417d415ca74a435755e298a1d2d19ec47637fd03479de7a7d958eb382941f1",
2631
+ manifest: "eb5a0356aebabe89c7b2780f8809e13d6e2ad6f342fed87cf99f9a5834344363"
2632
+ },
2633
+ "linux-arm64": {
2634
+ checksum: "8ac7ad97f3d68bf485423001d1ce3cd92a8d4625313c47c8071867a9aeed3af9",
2635
+ manifest: "6126266dd65b43c43d719e4dc4d33c4ea6a3267f99f34e3638637439a995af2e"
2636
+ },
2637
+ "linux-x64": {
2638
+ checksum: "7d76463079619ba822123d250601bd35f6744ed5f8054a657ce472ce4dac76c8",
2639
+ manifest: "f1a6c0c61d15eddb2ecfa4c3a72a5154621881ac2f0c413162ff1d0f4343bd0e"
2640
+ }
2641
+ }
2642
+ },
2643
+ "swift-6.4.0-RELEASE-custom-44ecd25f163bb359": {
2644
+ identity: "44ecd25f163bb359",
2645
+ archive: "tar.zst",
2646
+ hosts: {
2647
+ "darwin-arm64": {
2648
+ checksum: "d06dda4435f99d8376179cc7a3804907aa7305513135ece6288fd8e6d4695ae6",
2649
+ manifest: "bc0d8b955f923f096dda2aa8bbb1d56176a73f3d4a4df4cc9a1f59d31417061a"
2650
+ },
2651
+ "linux-x64": {
2652
+ checksum: "f95b56440693c5de7995f10ea14c57fc7e659a161018a17f17a74b61a98e88a4",
2653
+ manifest: "c18a60b14d5c89a8b2e1dbb2b4b52342c5fb92c7f3069fdc55c985bce61683a7"
2654
+ },
2655
+ "linux-arm64": {
2656
+ checksum: "afb74ae60df2b5bd7792bfbcf29bcea03675a5c814b758dd6cb91a760c220cd2",
2657
+ manifest: "ac037f6b0fdc4a6ae582eebc22bcf811fa2becdc30d083057137fc857f3c456a"
2658
+ }
2659
+ }
2660
+ },
2624
2661
  "swift-6.4.0-RELEASE-custom-11345d60dca47496": {
2625
2662
  identity: "11345d60dca47496",
2626
2663
  archive: "tar.zst",
@@ -3028,7 +3065,7 @@ function validateSwiftSdkIdentity(sdk) {
3028
3065
  function swiftSdkBundle(swift, id, options) {
3029
3066
  const configuration = execFileSync(
3030
3067
  swift,
3031
- ["sdk", "configure", ...options, "--show-configuration", id, "wasm32-unknown-wasip1"],
3068
+ ["sdk", "configure", ...options, "--show-configuration", id, "wasm64-unknown-wasip1"],
3032
3069
  { encoding: "utf8", env: swiftEnvironment(), stdio: ["ignore", "pipe", "pipe"] }
3033
3070
  );
3034
3071
  const sysroot = /^sdkRootPath: (.+)$/m.exec(configuration)?.[1]?.trim();
@@ -3834,14 +3871,11 @@ function objcSdkIntakeFlags(headers, toolchainBin, minimum) {
3834
3871
  return [
3835
3872
  ...swiftObjCPlatformFlags(toolchainBin, minimum),
3836
3873
  // AvailabilityInternal.h derives these through __is_target_os(ios), which
3837
- // is false for wasm32. the maximum is the sdk the headers come from, as
3874
+ // is false for wasm64. the maximum is the sdk the headers come from, as
3838
3875
  // xcode defines it, so `#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_26_0`
3839
3876
  // sources see the members the sdk declares instead of a 17.0 default.
3840
3877
  `-D__IPHONE_OS_VERSION_MIN_REQUIRED=${minimum}`,
3841
3878
  `-D__IPHONE_OS_VERSION_MAX_ALLOWED=__IPHONE_${NATIVE_GRAPH_SDK_VERSION.replace(".", "_")}`,
3842
- // apple's build setting for a 32-bit target to keep NSInteger and
3843
- // NSUInteger long, the nominal types they have on arm64.
3844
- "-DNS_BUILD_32_LIKE_64=1",
3845
3879
  // the installed libc's default feature set otherwise defines
3846
3880
  // _XOPEN_SOURCE, which darwin's sys/cdefs.h turns into a strict posix
3847
3881
  // level; iOS compiles at darwin's full level with neither defined.
@@ -4111,7 +4145,7 @@ function swiftSharedSdkViewOptions(moduleRoot, distribution, toolchainBin, sdk)
4111
4145
  ...swiftSdkOptions(),
4112
4146
  "--show-configuration",
4113
4147
  sdk,
4114
- "wasm32-unknown-wasip1"
4148
+ "wasm64-unknown-wasip1"
4115
4149
  ],
4116
4150
  { encoding: "utf8", env: swiftEnvironment(), stdio: ["ignore", "pipe", "pipe"] }
4117
4151
  );
@@ -4248,7 +4282,7 @@ function compileDarwinRecords(args) {
4248
4282
  execFileSync4(
4249
4283
  path9.join(args.bin, "clang"),
4250
4284
  [
4251
- "--target=wasm32-unknown-wasip1",
4285
+ "--target=wasm64-unknown-wasip1",
4252
4286
  `--sysroot=${args.sysroot}`,
4253
4287
  "-Oz",
4254
4288
  "-g0",
@@ -4259,7 +4293,7 @@ function compileDarwinRecords(args) {
4259
4293
  `-ffile-prefix-map=${records}${path9.sep}=DarwinRecords/`,
4260
4294
  // apple's headers select on the ios identity original units compile
4261
4295
  // with, and TargetConditionals.h refuses a compiler without it
4262
- ...file.endsWith(".m") ? objcSdkIntakeFlags(args.darwin, args.bin, args.minimum) : [
4296
+ ...file === "sysctl.c" || file.endsWith(".m") ? objcSdkIntakeFlags(args.darwin, args.bin, args.minimum) : [
4263
4297
  ...swiftObjCPlatformFlags(args.bin, args.minimum),
4264
4298
  ...WASI_EMULATION_FLAGS,
4265
4299
  // the sdk build compiles these with libobjc2's headers in
@@ -4727,7 +4761,7 @@ var foundationCategoryObjects = [
4727
4761
 
4728
4762
  // src/swift-guest-compile.ts
4729
4763
  import { execFileSync as execFileSync9 } from "node:child_process";
4730
- import { mkdirSync as mkdirSync2, readFileSync as readFileSync11, writeFileSync as writeFileSync4 } from "node:fs";
4764
+ import { mkdirSync as mkdirSync3, readFileSync as readFileSync12, writeFileSync as writeFileSync5 } from "node:fs";
4731
4765
  import path19 from "node:path";
4732
4766
 
4733
4767
  // src/swift-guest-archive.ts
@@ -4785,7 +4819,7 @@ var swiftSdkProductSchema = v.pipe(
4785
4819
  v.object({
4786
4820
  id: v.string(),
4787
4821
  installName: v.string(),
4788
- target: v.literal("wasm32-unknown-wasip1"),
4822
+ target: v.literal("wasm64-unknown-wasip1"),
4789
4823
  linkNames: v.array(v.string()),
4790
4824
  // absent records declare no framework namespace, even when a library name matches.
4791
4825
  frameworkAliases: v.optional(
@@ -4894,7 +4928,8 @@ function encodeULEB(val) {
4894
4928
  } while (val !== 0);
4895
4929
  return out;
4896
4930
  }
4897
- var HAS_ADDEND = /* @__PURE__ */ new Set([3, 4, 5, 8, 9, 11, 13, 14, 15, 16, 21, 22, 23, 24, 25]);
4931
+ var HAS_ADDEND = /* @__PURE__ */ new Set([3, 4, 5, 8, 9, 11, 14, 15, 16, 17, 21, 22, 23, 25]);
4932
+ var WIDE_DATA_RELOCS = /* @__PURE__ */ new Set([16, 19, 22]);
4898
4933
  var ROOT_SEG_PREFIXES = [
4899
4934
  ".init_array",
4900
4935
  "__objc_init_func",
@@ -5790,7 +5825,7 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
5790
5825
  } else {
5791
5826
  lazyBuildObjects.set(t, parseWasmObjectCached(t, false, false));
5792
5827
  }
5793
- } else if (!inStartLib && t.endsWith(".a") && !t.endsWith("libclang_rt.builtins-wasm32.a") && fs4.existsSync(t)) {
5828
+ } else if (!inStartLib && t.endsWith(".a") && !t.endsWith("libclang_rt.builtins-wasm64.a") && fs4.existsSync(t)) {
5794
5829
  const members = readArMembers(new Uint8Array(fs4.readFileSync(t)));
5795
5830
  for (const m of members) {
5796
5831
  extraArchiveObjs.push(parseWasmObjectBytes(`${t}(${m.name})`, m.bytes, false));
@@ -6272,7 +6307,11 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
6272
6307
  }
6273
6308
  }
6274
6309
  const keptDataRelocBytes = [];
6275
- const zeroDataRelocOffsets = [];
6310
+ const zeroDataRelocs = [];
6311
+ const zeroDataReloc = (r) => zeroDataRelocs.push({
6312
+ ro: r.ro,
6313
+ width: WIDE_DATA_RELOCS.has(r.rawBytes[0]) ? 8 : 4
6314
+ });
6276
6315
  const usedSyms = /* @__PURE__ */ new Set();
6277
6316
  for (const r of keptCodeRelocs) if (r.rawBytes[0] !== 6) usedSyms.add(r.rs);
6278
6317
  for (const r of obj.dataRelocList) {
@@ -6283,7 +6322,7 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
6283
6322
  keptDataRelocBytes.push(r.rawBytes);
6284
6323
  usedSyms.add(r.rs);
6285
6324
  } else if (sName === "__objc_classes") {
6286
- zeroDataRelocOffsets.push(r.ro);
6325
+ zeroDataReloc(r);
6287
6326
  } else {
6288
6327
  const repl = firstLiveInSpecialSeg.get(r.segIdx);
6289
6328
  const roBytes = encodeULEB(r.ro);
@@ -6296,17 +6335,17 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
6296
6335
  } else if (r.ownerSymIdx !== -1) {
6297
6336
  if (dLive.has(r.ownerSymIdx)) {
6298
6337
  if (obj.isDist && dropsReflection(obj, obj.symNames[r.rs])) {
6299
- zeroDataRelocOffsets.push(r.ro);
6338
+ zeroDataReloc(r);
6300
6339
  } else {
6301
6340
  keptDataRelocBytes.push(r.rawBytes);
6302
6341
  usedSyms.add(r.rs);
6303
6342
  }
6304
6343
  } else if (sName === "__objc_class_refs") {
6305
- zeroDataRelocOffsets.push(r.ro);
6344
+ zeroDataReloc(r);
6306
6345
  }
6307
6346
  } else if (sLive[r.segIdx] === 1) {
6308
6347
  if (obj.isDist && obj.symNames[r.rs]?.startsWith("l__swift5_reflection_descriptor") && dropsReflection(obj, obj.symNames[r.rs])) {
6309
- zeroDataRelocOffsets.push(r.ro);
6348
+ zeroDataReloc(r);
6310
6349
  } else {
6311
6350
  keptDataRelocBytes.push(r.rawBytes);
6312
6351
  usedSyms.add(r.rs);
@@ -6489,11 +6528,8 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
6489
6528
  outChunks.push(buf.subarray(secStart, end));
6490
6529
  }
6491
6530
  } else {
6492
- if (id === 11 && zeroDataRelocOffsets.length > 0) {
6493
- for (const ro of zeroDataRelocOffsets) {
6494
- buf.fill(0, p + ro, p + ro + 4);
6495
- }
6496
- }
6531
+ if (id === 11)
6532
+ for (const { ro, width } of zeroDataRelocs) buf.fill(0, p + ro, p + ro + width);
6497
6533
  outChunks.push(buf.subarray(secStart, end));
6498
6534
  }
6499
6535
  pos = end;
@@ -6669,7 +6705,7 @@ function readNumber(bytes, position) {
6669
6705
  let value = 0;
6670
6706
  let shift = 0;
6671
6707
  for (; ; ) {
6672
- if (position >= bytes.length || shift > 28) throw new Error("invalid wasm integer");
6708
+ if (position >= bytes.length || shift > 63) throw new Error("invalid wasm integer");
6673
6709
  const byte = bytes[position++];
6674
6710
  value += (byte & 127) * 2 ** shift;
6675
6711
  if (!(byte & 128)) return [value, position];
@@ -6716,7 +6752,7 @@ var OBJC_INIT_RECORD = ".objc_init";
6716
6752
  function rewriteObject(bytes, names, callerAlias, bindings, instrumentDynamicLookups, preserveCanonical) {
6717
6753
  if (Buffer.from(bytes.subarray(0, 8)).toString("hex") !== "0061736d01000000")
6718
6754
  throw new Error("expected wasm object");
6719
- const sections = [Buffer.from(bytes.subarray(0, 8))];
6755
+ const sections2 = [Buffer.from(bytes.subarray(0, 8))];
6720
6756
  const types = [];
6721
6757
  const functionTypes = [];
6722
6758
  const definitions = [];
@@ -6773,12 +6809,12 @@ function rewriteObject(bytes, names, callerAlias, bindings, instrumentDynamicLoo
6773
6809
  if (referenceType !== 112 && referenceType !== 111)
6774
6810
  throw new Error("unsupported table type");
6775
6811
  const flags = number3();
6776
- if (flags & ~3) throw new Error("unsupported table limits");
6812
+ if (flags & ~7) throw new Error("unsupported table limits");
6777
6813
  number3();
6778
6814
  if (flags & 1) number3();
6779
6815
  } else if (kind === 2) {
6780
6816
  const flags = number3();
6781
- if (flags & ~3) throw new Error("unsupported memory limits");
6817
+ if (flags & ~7) throw new Error("unsupported memory limits");
6782
6818
  number3();
6783
6819
  if (flags & 1) number3();
6784
6820
  } else if (kind === 3) offset += 2;
@@ -6791,7 +6827,7 @@ function rewriteObject(bytes, names, callerAlias, bindings, instrumentDynamicLoo
6791
6827
  if (module === "env" && names.has(name2)) usedSymbols.add(name2);
6792
6828
  if (isDlsym || isDlerror) {
6793
6829
  const type = types[functionType];
6794
- const expected = isDlsym ? "127,127:127" : ":127";
6830
+ const expected = isDlsym ? "126,126:126" : ":126";
6795
6831
  if (!type || `${type.parameters.join(",")}:${type.results.join(",")}` !== expected)
6796
6832
  throw new Error(`unexpected ${name2} import type`);
6797
6833
  }
@@ -6933,10 +6969,10 @@ function rewriteObject(bytes, names, callerAlias, bindings, instrumentDynamicLoo
6933
6969
  section = Buffer.concat(parts);
6934
6970
  }
6935
6971
  }
6936
- sections.push(Buffer.from([id]), encodeNumber(section.length), section);
6972
+ sections2.push(Buffer.from([id]), encodeNumber(section.length), section);
6937
6973
  }
6938
6974
  return {
6939
- bytes: Buffer.concat(sections),
6975
+ bytes: Buffer.concat(sections2),
6940
6976
  definitions,
6941
6977
  usesDlsym,
6942
6978
  usedSymbols: [...usedSymbols]
@@ -7103,7 +7139,7 @@ function createGuestImageLedger(input) {
7103
7139
  return [...bytes].map((byte) => `\\${byte.toString(16).padStart(2, "0")}`).join("");
7104
7140
  }).join("");
7105
7141
  const ir = [
7106
- 'target triple = "wasm32-unknown-wasip1"',
7142
+ 'target triple = "wasm64-unknown-wasip1"',
7107
7143
  `@.names = private constant [${nameSize} x i8] c"${nameContents}"`
7108
7144
  ];
7109
7145
  for (const definition of exported.values()) {
@@ -7222,8 +7258,8 @@ function selectedGuestManifestInputs(plan, selection, identities) {
7222
7258
  }
7223
7259
  function createGuestImageManifest(image) {
7224
7260
  const target = {
7225
- triple: "wasm32-unknown-wasip1",
7226
- pointerWidth: 32,
7261
+ triple: "wasm64-unknown-wasip1",
7262
+ pointerWidth: 64,
7227
7263
  byteOrder: "little",
7228
7264
  cpuType: -1,
7229
7265
  cpuSubtype: 0
@@ -7283,6 +7319,7 @@ function number2(bytes, start) {
7283
7319
  shift += 7;
7284
7320
  }
7285
7321
  }
7322
+ var constant = (opcode) => opcode === 65 || opcode === 66;
7286
7323
  function signedAddress(bytes, start) {
7287
7324
  const [value, end] = number2(bytes, start);
7288
7325
  const bits = (end - start) * 7;
@@ -7292,16 +7329,16 @@ function signedAddress(bytes, start) {
7292
7329
  function layout(bytes) {
7293
7330
  if (Buffer.from(bytes.subarray(0, 8)).toString("hex") !== "0061736d01000000")
7294
7331
  throw new Error("expected linked wasm module");
7295
- const sections = /* @__PURE__ */ new Map();
7332
+ const sections2 = /* @__PURE__ */ new Map();
7296
7333
  let offset = 8;
7297
7334
  while (offset < bytes.length) {
7298
7335
  const id = bytes[offset++];
7299
7336
  const [size, start] = number2(bytes, offset);
7300
7337
  if (start + size > bytes.length) throw new Error("invalid wasm section");
7301
- if (id) sections.set(id, [start, start + size]);
7338
+ if (id) sections2.set(id, [start, start + size]);
7302
7339
  offset = start + size;
7303
7340
  }
7304
- const exports = sections.get(7);
7341
+ const exports = sections2.get(7);
7305
7342
  if (!exports) throw new Error("guest wasm does not export memory and table");
7306
7343
  let exportPosition = exports[0];
7307
7344
  const readExport = () => {
@@ -7322,7 +7359,7 @@ function layout(bytes) {
7322
7359
  throw new Error("guest wasm does not export memory and table");
7323
7360
  let imports = 0;
7324
7361
  let memoryPages;
7325
- const section = sections.get(2);
7362
+ const section = sections2.get(2);
7326
7363
  if (section) {
7327
7364
  let pos = section[0];
7328
7365
  const read = () => {
@@ -7337,7 +7374,7 @@ function layout(bytes) {
7337
7374
  };
7338
7375
  const limits = () => {
7339
7376
  const flags = read();
7340
- if (flags & ~3) throw new Error("unsupported wasm limits");
7377
+ if (flags & ~7) throw new Error("unsupported wasm limits");
7341
7378
  const minimum = read();
7342
7379
  if (flags & 1) read();
7343
7380
  return minimum;
@@ -7365,7 +7402,7 @@ function layout(bytes) {
7365
7402
  }
7366
7403
  if (pos !== section[1]) throw new Error("invalid wasm imports");
7367
7404
  }
7368
- const memory = sections.get(5);
7405
+ const memory = sections2.get(5);
7369
7406
  if (memory) {
7370
7407
  let pos = memory[0];
7371
7408
  const read = () => {
@@ -7376,14 +7413,14 @@ function layout(bytes) {
7376
7413
  if (read() !== 1 || memoryPages !== void 0)
7377
7414
  throw new Error("unsupported wasm memories");
7378
7415
  const flags = read();
7379
- if (flags & ~3) throw new Error("unsupported wasm memory limits");
7416
+ if (flags & ~7) throw new Error("unsupported wasm memory limits");
7380
7417
  memoryPages = read();
7381
7418
  if (flags & 1) read();
7382
7419
  if (pos !== memory[1]) throw new Error("invalid wasm memory section");
7383
7420
  }
7384
7421
  if (memoryPages === void 0) throw new Error("guest wasm has no memory");
7385
7422
  const functionsByCodeOffset = /* @__PURE__ */ new Map();
7386
- const code = sections.get(10);
7423
+ const code = sections2.get(10);
7387
7424
  if (code) {
7388
7425
  let pos = code[0];
7389
7426
  let count;
@@ -7399,7 +7436,7 @@ function layout(bytes) {
7399
7436
  if (pos !== code[1]) throw new Error("invalid wasm code section");
7400
7437
  }
7401
7438
  const functionsByTableSlot = /* @__PURE__ */ new Map();
7402
- const elements = sections.get(9);
7439
+ const elements = sections2.get(9);
7403
7440
  if (elements) {
7404
7441
  let pos = elements[0];
7405
7442
  const read = () => {
@@ -7413,7 +7450,7 @@ function layout(bytes) {
7413
7450
  if (flags !== 0 && flags !== 2)
7414
7451
  throw new Error(`unsupported wasm element segment ${flags}`);
7415
7452
  if (flags === 2 && read() !== 0) throw new Error("unsupported wasm table index");
7416
- if (bytes[pos++] !== 65) throw new Error("nonconstant wasm table offset");
7453
+ if (!constant(bytes[pos++])) throw new Error("nonconstant wasm table offset");
7417
7454
  let base;
7418
7455
  [base, pos] = signedAddress(bytes, pos);
7419
7456
  if (bytes[pos++] !== 11) throw new Error("invalid wasm table offset");
@@ -7430,7 +7467,7 @@ function layout(bytes) {
7430
7467
  if (pos !== elements[1]) throw new Error("invalid wasm element section");
7431
7468
  }
7432
7469
  const data = [];
7433
- const dataSection = sections.get(11);
7470
+ const dataSection = sections2.get(11);
7434
7471
  if (dataSection) {
7435
7472
  let pos = dataSection[0];
7436
7473
  const read = () => {
@@ -7444,7 +7481,7 @@ function layout(bytes) {
7444
7481
  if (flags !== 0 && flags !== 2)
7445
7482
  throw new Error(`unsupported wasm data segment ${flags}`);
7446
7483
  if (flags === 2 && read() !== 0) throw new Error("unsupported wasm memory index");
7447
- if (bytes[pos++] !== 65) throw new Error("nonconstant wasm data offset");
7484
+ if (!constant(bytes[pos++])) throw new Error("nonconstant wasm data offset");
7448
7485
  let address;
7449
7486
  [address, pos] = signedAddress(bytes, pos);
7450
7487
  if (bytes[pos++] !== 11) throw new Error("invalid wasm data offset");
@@ -7566,7 +7603,7 @@ function isSwiftGuestImageManifest(value) {
7566
7603
  const text2 = (value2) => typeof value2 === "string" && value2.length > 0 && value2.length <= 4096 && !value2.includes("\0");
7567
7604
  const name2 = (value2) => text2(value2) && new TextEncoder().encode(value2).length <= 16;
7568
7605
  const version2 = (value2) => isRecord(value2) && uint(value2.major, 65535) && uint(value2.minor, 255) && uint(value2.patch, 255);
7569
- if (!isRecord(value) || value.version !== 1 || !text2(value.id) || !text2(value.installName) || value.fileType !== "executable" && value.fileType !== "dylib" || !isRecord(value.target) || value.target.triple !== "wasm32-unknown-wasip1" || value.target.pointerWidth !== 32 || value.target.byteOrder !== "little" || value.target.cpuType !== -1 || value.target.cpuSubtype !== 0 || typeof value.inputsSha256 !== "string" || !/^[a-f0-9]{64}$/.test(value.inputsSha256) || value.uuid !== value.inputsSha256.slice(0, 32) || !isRecord(value.buildVersion) || !uint(value.buildVersion.platform, 4294967295) || !version2(value.buildVersion.minimum) || !version2(value.buildVersion.sdk) || !Array.isArray(value.regions))
7606
+ if (!isRecord(value) || value.version !== 1 || !text2(value.id) || !text2(value.installName) || value.fileType !== "executable" && value.fileType !== "dylib" || !isRecord(value.target) || value.target.triple !== "wasm64-unknown-wasip1" || value.target.pointerWidth !== 64 || value.target.byteOrder !== "little" || value.target.cpuType !== -1 || value.target.cpuSubtype !== 0 || typeof value.inputsSha256 !== "string" || !/^[a-f0-9]{64}$/.test(value.inputsSha256) || value.uuid !== value.inputsSha256.slice(0, 32) || !isRecord(value.buildVersion) || !uint(value.buildVersion.platform, 4294967295) || !version2(value.buildVersion.minimum) || !version2(value.buildVersion.sdk) || !Array.isArray(value.regions))
7570
7607
  return false;
7571
7608
  return value.regions.every((region) => {
7572
7609
  if (!isRecord(region) || !name2(region.name) || region.space !== "linear-memory" && region.space !== "function-table" || !uint(region.address, 4294967295) || !uint(region.length, 4294967295) || region.address + region.length > 4294967296 || !uint(region.initialProtection, 7) || !uint(region.maximumProtection, 7) || (region.initialProtection & region.maximumProtection) !== region.initialProtection || !Array.isArray(region.sections))
@@ -8999,7 +9036,7 @@ function linkGuestImages(options) {
8999
9036
  fs5.writeFileSync(irPath, ledger.llvmIR);
9000
9037
  execFileSync7(
9001
9038
  clang,
9002
- ["--target=wasm32-unknown-wasip1", "-c", irPath, "-o", ledgerObject],
9039
+ ["--target=wasm64-unknown-wasip1", "-c", irPath, "-o", ledgerObject],
9003
9040
  { stdio: "pipe" }
9004
9041
  );
9005
9042
  linkedOwners.set(ledgerObject, options.ledgerDataImage);
@@ -9641,7 +9678,7 @@ function linkPrunedGuestImages(options) {
9641
9678
  // src/swift-guest-source-inputs.ts
9642
9679
  import { execFileSync as execFileSync8 } from "node:child_process";
9643
9680
  import { createHash as createHash10 } from "node:crypto";
9644
- import { readFileSync as readFileSync10, realpathSync as realpathSync2, writeFileSync as writeFileSync3 } from "node:fs";
9681
+ import { mkdirSync as mkdirSync2, readFileSync as readFileSync10, realpathSync as realpathSync2, writeFileSync as writeFileSync3 } from "node:fs";
9645
9682
  import path15 from "node:path";
9646
9683
  function clangIrLinkOptions(ir) {
9647
9684
  const list = /^!llvm\.linker\.options = !\{([^\n]*)\}$/m.exec(ir);
@@ -9672,6 +9709,7 @@ function clangIrLinkOptions(ir) {
9672
9709
  }
9673
9710
  return result;
9674
9711
  }
9712
+ var CLANG_TARGET_MODULE_WRAPPER = ".peach-clang";
9675
9713
  function sourceGuestClangLinkOptions(options) {
9676
9714
  const wanted = new Set(options.objects.map((file) => path15.resolve(file)));
9677
9715
  const commands = /* @__PURE__ */ new Map();
@@ -9714,10 +9752,16 @@ function sourceGuestClangLinkOptions(options) {
9714
9752
  throw new Error(`unsupported source object producer ${file}`);
9715
9753
  continue;
9716
9754
  }
9717
- if (command.tool !== "clang" || !command.args.length || realpathSync2(command.args[0]) !== realpathSync2(path15.join(options.toolchainBin, "clang")))
9755
+ const compiler = command.args[0] ? realpathSync2(command.args[0]) : "";
9756
+ if (command.tool !== "clang" || compiler !== realpathSync2(path15.join(options.toolchainBin, "clang")) && compiler !== realpathSync2(path15.join(options.buildDirectory, CLANG_TARGET_MODULE_WRAPPER)))
9718
9757
  throw new Error(`unsupported source object producer ${file}`);
9719
9758
  const args = command.args.slice(1).filter((arg) => arg !== "-c");
9720
- const output = path15.join(options.directory, `clang-link-${index}.ll`);
9759
+ const outputDirectory = path15.join(
9760
+ options.directory,
9761
+ path15.basename(path15.dirname(file))
9762
+ );
9763
+ mkdirSync2(outputDirectory, { recursive: true });
9764
+ const output = path15.join(outputDirectory, `clang-link-${index}.ll`);
9721
9765
  for (const flag of ["-o", "-MF"]) {
9722
9766
  const index2 = args.lastIndexOf(flag);
9723
9767
  if (index2 < 0 || index2 + 1 >= args.length)
@@ -9957,8 +10001,10 @@ function logicalGuestLinkOptions(args, identities, roots) {
9957
10001
  }
9958
10002
 
9959
10003
  // src/wasm-optimize.ts
9960
- import { existsSync } from "node:fs";
9961
- import { join as join2 } from "node:path";
10004
+ import { execFile as execFile2 } from "node:child_process";
10005
+ import { existsSync, readFileSync as readFileSync11, rmSync as rmSync4, writeFileSync as writeFileSync4 } from "node:fs";
10006
+ import { dirname, join as join2 } from "node:path";
10007
+ import { promisify as promisify2 } from "node:util";
9962
10008
 
9963
10009
  // ../contrast-runtime-delivery/src/index.ts
9964
10010
  import { spawn as spawn3 } from "node:child_process";
@@ -10196,8 +10242,244 @@ function rnxHomeDir() {
10196
10242
  }
10197
10243
  var DAEMON_LOCKFILE_MAX_BYTES = 16 * 1024;
10198
10244
 
10245
+ // src/wasm-narrow-boundary.ts
10246
+ var I64 = 126;
10247
+ var VALUE_TYPES = /* @__PURE__ */ new Map([
10248
+ [127, "i32"],
10249
+ [I64, "i64"],
10250
+ [125, "f32"],
10251
+ [124, "f64"],
10252
+ [123, "v128"],
10253
+ [112, "funcref"],
10254
+ [111, "externref"]
10255
+ ]);
10256
+ var GUEST = "guest";
10257
+ var BOUNDARY = "boundary";
10258
+ var WIDE = "$wide.";
10259
+ var NARROW = "$narrow.";
10260
+ function encodeNumber2(value) {
10261
+ const bytes = [];
10262
+ for (let rest = value; ; ) {
10263
+ const byte = rest % 128;
10264
+ rest = Math.floor(rest / 128);
10265
+ if (rest === 0) return [...bytes, byte];
10266
+ bytes.push(byte | 128);
10267
+ }
10268
+ }
10269
+ function encodeName(name2) {
10270
+ const bytes = [...Buffer.from(name2)];
10271
+ return [...encodeNumber2(bytes.length), ...bytes];
10272
+ }
10273
+ function reader(bytes, start, end) {
10274
+ let at = start;
10275
+ const number3 = () => {
10276
+ let value = 0;
10277
+ for (let shift = 0; ; shift += 7) {
10278
+ if (at >= end || shift > 63) throw new Error("invalid wasm integer");
10279
+ const byte = bytes[at++];
10280
+ value += (byte & 127) * 2 ** shift;
10281
+ if (!(byte & 128)) return value;
10282
+ }
10283
+ };
10284
+ return {
10285
+ number: number3,
10286
+ byte: () => {
10287
+ if (at >= end) throw new Error("truncated wasm section");
10288
+ return bytes[at++];
10289
+ },
10290
+ name: () => {
10291
+ const length = number3();
10292
+ at += length;
10293
+ if (at > end) throw new Error("truncated wasm name");
10294
+ return Buffer.from(bytes.subarray(at - length, at)).toString();
10295
+ },
10296
+ position: () => at,
10297
+ done: () => at === end
10298
+ };
10299
+ }
10300
+ function sections(bytes) {
10301
+ if (Buffer.from(bytes.subarray(0, 8)).toString("hex") !== "0061736d01000000")
10302
+ throw new Error("not a wasm module");
10303
+ const found = [];
10304
+ for (let at = 8; at < bytes.length; ) {
10305
+ const header = reader(bytes, at, bytes.length);
10306
+ const id = header.byte();
10307
+ const size = header.number();
10308
+ const start = header.position();
10309
+ found.push({ id, start, end: start + size });
10310
+ at = start + size;
10311
+ }
10312
+ return found;
10313
+ }
10314
+ function withSections(bytes, layout2, replacements) {
10315
+ const parts = [bytes.subarray(0, 8)];
10316
+ let at = 8;
10317
+ for (const section of layout2) {
10318
+ const body = replacements.get(section.id);
10319
+ parts.push(
10320
+ body ? Uint8Array.from([section.id, ...encodeNumber2(body.length), ...body]) : bytes.subarray(at, section.end)
10321
+ );
10322
+ at = section.end;
10323
+ }
10324
+ return Buffer.concat(parts);
10325
+ }
10326
+ var quoted = (name2) => `"${[...Buffer.from(name2)].map((byte) => `\\${byte.toString(16).padStart(2, "0")}`).join("")}"`;
10327
+ var signature = (types, keyword, narrow) => types.length === 0 ? "" : ` (${keyword} ${types.map((type) => {
10328
+ const name2 = VALUE_TYPES.get(narrow && type === I64 ? 127 : type);
10329
+ if (!name2) throw new Error(`unsupported wasm boundary type ${type}`);
10330
+ return name2;
10331
+ }).join(" ")})`;
10332
+ var wide = (type) => type.parameters.includes(I64) || type.results.includes(I64);
10333
+ function narrowWasmBoundary(bytes) {
10334
+ const layout2 = sections(bytes);
10335
+ const section = (id) => {
10336
+ const found = layout2.find((entry) => entry.id === id);
10337
+ return found && reader(bytes, found.start, found.end);
10338
+ };
10339
+ const types = [];
10340
+ const typeSection = section(1);
10341
+ if (typeSection) {
10342
+ for (let count = typeSection.number(); count > 0; count--) {
10343
+ if (typeSection.byte() !== 96) throw new Error("unsupported wasm type");
10344
+ const values = () => Array.from({ length: typeSection.number() }, () => typeSection.byte());
10345
+ types.push({ parameters: values(), results: values() });
10346
+ }
10347
+ }
10348
+ const typeAt = (index) => {
10349
+ const type = types[index];
10350
+ if (!type) throw new Error("invalid wasm type index");
10351
+ return type;
10352
+ };
10353
+ const thunks = [];
10354
+ const functionTypes = [];
10355
+ const importBody = [];
10356
+ const importSection = section(2);
10357
+ if (importSection) {
10358
+ const count = importSection.number();
10359
+ importBody.push(...encodeNumber2(count));
10360
+ for (let index = 0; index < count; index++) {
10361
+ const module = importSection.name();
10362
+ const name2 = importSection.name();
10363
+ const start = importSection.position();
10364
+ const kind = importSection.byte();
10365
+ const limits = () => {
10366
+ const flags = importSection.number();
10367
+ importSection.number();
10368
+ if (flags & 1) importSection.number();
10369
+ };
10370
+ let type;
10371
+ if (kind === 0) {
10372
+ type = typeAt(importSection.number());
10373
+ functionTypes.push(type);
10374
+ } else if (kind === 1) {
10375
+ importSection.byte();
10376
+ limits();
10377
+ } else if (kind === 2) limits();
10378
+ else if (kind === 3) {
10379
+ importSection.byte();
10380
+ importSection.byte();
10381
+ } else if (kind === 4) {
10382
+ importSection.byte();
10383
+ importSection.number();
10384
+ } else throw new Error("unsupported wasm import");
10385
+ const scalar64 = (parameter) => module === "wasi_snapshot_preview1" && (!name2.startsWith("peach_") || name2 === "peach_fs_path_birthtime_set" && parameter === 2) || module === "peach" && name2 === "hw_memsize" && parameter === null || module === "peach_notify" && name2 === "set" && parameter === 1;
10386
+ const parameters = type?.parameters.map(
10387
+ (value, index2) => value === I64 && !scalar64(index2) ? 127 : value
10388
+ );
10389
+ const results = type?.results.map(
10390
+ (value) => value === I64 && !scalar64(null) ? 127 : value
10391
+ );
10392
+ if (type && parameters && results && (parameters.some((value, index2) => value !== type.parameters[index2]) || results.some((value, index2) => value !== type.results[index2]))) {
10393
+ if (type.results.length > 1)
10394
+ throw new Error(`import ${module}.${name2} returns several values`);
10395
+ const id = thunks.length;
10396
+ const call = `(call $host${id}${type.parameters.map(
10397
+ (value, at) => value !== parameters[at] ? ` (i32.wrap_i64 (local.get ${at}))` : ` (local.get ${at})`
10398
+ ).join("")})`;
10399
+ thunks.push(
10400
+ `(import ${quoted(module)} ${quoted(name2)} (func $host${id}${signature(parameters, "param", false)}${signature(results, "result", false)}))`,
10401
+ `(func (export "${NARROW}${id}")${signature(type.parameters, "param", false)}${signature(type.results, "result", false)} ${type.results[0] !== results[0] ? `(i64.extend_i32_u ${call})` : call})`
10402
+ );
10403
+ importBody.push(...encodeName(BOUNDARY), ...encodeName(`${NARROW}${id}`));
10404
+ } else importBody.push(...encodeName(module), ...encodeName(name2));
10405
+ importBody.push(...bytes.subarray(start, importSection.position()));
10406
+ }
10407
+ if (!importSection.done()) throw new Error("invalid wasm imports");
10408
+ }
10409
+ const functionSection = section(3);
10410
+ if (functionSection)
10411
+ for (let count = functionSection.number(); count > 0; count--)
10412
+ functionTypes.push(typeAt(functionSection.number()));
10413
+ const exportBody = [];
10414
+ const exportSection = section(7);
10415
+ if (exportSection) {
10416
+ const count = exportSection.number();
10417
+ exportBody.push(...encodeNumber2(count));
10418
+ for (let index = 0; index < count; index++) {
10419
+ const name2 = exportSection.name();
10420
+ const kind = exportSection.byte();
10421
+ const target = exportSection.number();
10422
+ const type = kind === 0 ? functionTypes[target] : void 0;
10423
+ if (kind === 0 && !type) throw new Error("invalid wasm export");
10424
+ if (type && wide(type)) {
10425
+ if (type.results.length > 1)
10426
+ throw new Error(`export ${name2} returns several values`);
10427
+ const id = thunks.length;
10428
+ const call = `(call $guest${id}${type.parameters.map(
10429
+ (value, at) => value === I64 ? ` (i64.extend_i32_u (local.get ${at}))` : ` (local.get ${at})`
10430
+ ).join("")})`;
10431
+ thunks.push(
10432
+ `(import "${GUEST}" "${WIDE}${id}" (func $guest${id}${signature(type.parameters, "param", false)}${signature(type.results, "result", false)}))`,
10433
+ `(func (export ${quoted(name2)})${signature(type.parameters, "param", true)}${signature(type.results, "result", true)} ${type.results[0] === I64 ? `(i32.wrap_i64 ${call})` : call})`
10434
+ );
10435
+ exportBody.push(...encodeName(`${WIDE}${id}`));
10436
+ } else exportBody.push(...encodeName(name2));
10437
+ exportBody.push(kind, ...encodeNumber2(target));
10438
+ }
10439
+ if (!exportSection.done()) throw new Error("invalid wasm exports");
10440
+ }
10441
+ if (thunks.length === 0) return void 0;
10442
+ const imports = thunks.filter((line) => line.startsWith("(import"));
10443
+ const functions = thunks.filter((line) => !line.startsWith("(import"));
10444
+ return {
10445
+ module: withSections(
10446
+ bytes,
10447
+ layout2,
10448
+ /* @__PURE__ */ new Map([
10449
+ [2, importBody],
10450
+ [7, exportBody]
10451
+ ])
10452
+ ),
10453
+ thunks: `(module
10454
+ ${[...imports, ...functions].join("\n")}
10455
+ )
10456
+ `
10457
+ };
10458
+ }
10459
+ var NARROW_MERGE_NAMES = { guest: GUEST, boundary: BOUNDARY };
10460
+ function dropBoundaryExports(bytes) {
10461
+ const layout2 = sections(bytes);
10462
+ const found = layout2.find((entry) => entry.id === 7);
10463
+ if (!found) throw new Error("merged module has no exports");
10464
+ const exportSection = reader(bytes, found.start, found.end);
10465
+ const kept = [];
10466
+ for (let count = exportSection.number(); count > 0; count--) {
10467
+ const name2 = exportSection.name();
10468
+ const kind = exportSection.byte();
10469
+ const target = exportSection.number();
10470
+ if (!name2.startsWith(WIDE) && !name2.startsWith(NARROW))
10471
+ kept.push([...encodeName(name2), kind, ...encodeNumber2(target)]);
10472
+ }
10473
+ return withSections(
10474
+ bytes,
10475
+ layout2,
10476
+ /* @__PURE__ */ new Map([[7, [...encodeNumber2(kept.length), ...kept.flat()]]])
10477
+ );
10478
+ }
10479
+
10199
10480
  // src/wasm-optimize.ts
10200
10481
  var FEATURES = [
10482
+ "memory64",
10201
10483
  "threads",
10202
10484
  "bulk-memory",
10203
10485
  "bulk-memory-opt",
@@ -10210,7 +10492,8 @@ var FEATURES = [
10210
10492
  "sign-ext"
10211
10493
  ];
10212
10494
  var KEEP_WASM_NAMES = process.env.PEACH_SWIFT_NAMES === "1";
10213
- var WASM_OPTIMIZE_IDENTITY = `wasm-opt ${BINARYEN_VERSION} -Oz ${FEATURES.join(",")}${KEEP_WASM_NAMES ? " -g" : ""}`;
10495
+ var LOWERING = ["--memory64-lowering", "--table64-lowering"];
10496
+ var WASM_LOWER_IDENTITY = `binaryen ${BINARYEN_VERSION} narrow ${LOWERING.join(" ")} ${FEATURES.join(",")} unoptimized-names`;
10214
10497
  var PINNED_BINARYEN_VERSION = "132";
10215
10498
  var BINARYEN_RELEASES = /* @__PURE__ */ new Map([
10216
10499
  [
@@ -10235,7 +10518,7 @@ var BINARYEN_RELEASES = /* @__PURE__ */ new Map([
10235
10518
  }
10236
10519
  ]
10237
10520
  ]);
10238
- async function runWasmOpt(file, output, skipPasses, binary) {
10521
+ async function runWasmOpt(file, output, optimize, skipPasses, binary) {
10239
10522
  const admittedCores = windowAdmission()?.cores ?? Number(process.env.TM_EXEC_CPU_CORES);
10240
10523
  const requestedCores = Number(process.env.BINARYEN_CORES);
10241
10524
  const environment = { ...process.env, WASM_OPT_PATH: binary };
@@ -10243,18 +10526,43 @@ async function runWasmOpt(file, output, skipPasses, binary) {
10243
10526
  environment.BINARYEN_CORES = String(
10244
10527
  Number.isInteger(requestedCores) && requestedCores > 0 ? Math.min(admittedCores, requestedCores) : admittedCores
10245
10528
  );
10529
+ const features = FEATURES.map((feature) => `--enable-${feature}`);
10530
+ const names = optimize && !KEEP_WASM_NAMES ? [] : ["-g"];
10531
+ const narrowed = narrowWasmBoundary(readFileSync11(file));
10532
+ const merged = `${output}.narrowed`;
10533
+ if (narrowed) {
10534
+ const guest = `${output}.guest`;
10535
+ const thunks = `${output}.thunks.wat`;
10536
+ writeFileSync4(guest, narrowed.module);
10537
+ writeFileSync4(thunks, narrowed.thunks);
10538
+ await promisify2(execFile2)(join2(dirname(binary), "wasm-merge"), [
10539
+ ...features,
10540
+ ...names,
10541
+ guest,
10542
+ NARROW_MERGE_NAMES.guest,
10543
+ thunks,
10544
+ NARROW_MERGE_NAMES.boundary,
10545
+ "-o",
10546
+ merged
10547
+ ]);
10548
+ writeFileSync4(merged, dropBoundaryExports(readFileSync11(merged)));
10549
+ rmSync4(guest);
10550
+ rmSync4(thunks);
10551
+ }
10246
10552
  const result = await wasmOpt(
10247
10553
  [
10248
- "-Oz",
10249
- ...KEEP_WASM_NAMES ? ["-g"] : [],
10554
+ ...LOWERING,
10555
+ ...optimize ? ["-Oz"] : [],
10556
+ ...names,
10250
10557
  ...skipPasses.flatMap((pass) => ["--skip-pass", pass]),
10251
- ...FEATURES.map((feature) => `--enable-${feature}`),
10252
- file,
10558
+ ...features,
10559
+ narrowed ? merged : file,
10253
10560
  "-o",
10254
10561
  output
10255
10562
  ],
10256
10563
  { env: environment }
10257
10564
  );
10565
+ if (narrowed) rmSync4(merged);
10258
10566
  if (result.status !== 0)
10259
10567
  throw new Error(`wasm-opt exited ${result.status}: ${result.stderr}`);
10260
10568
  }
@@ -10277,8 +10585,14 @@ async function installWasmOpt() {
10277
10585
  });
10278
10586
  return binary;
10279
10587
  }
10280
- async function optimizeWasm(file, output, skipPasses = []) {
10281
- await runWasmOpt(file, output, skipPasses, await installWasmOpt());
10588
+ async function lowerWasm(file, output, options) {
10589
+ await runWasmOpt(
10590
+ file,
10591
+ output,
10592
+ options.optimize,
10593
+ options.skipPasses ?? [],
10594
+ await installWasmOpt()
10595
+ );
10282
10596
  }
10283
10597
 
10284
10598
  // src/swift-guest-compile.ts
@@ -10293,7 +10607,7 @@ function version(value) {
10293
10607
  }
10294
10608
  async function compileGuestLink(options) {
10295
10609
  const directory = path19.join(options.buildDirectory, ".peach-guest-link");
10296
- mkdirSync2(directory, { recursive: true });
10610
+ mkdirSync3(directory, { recursive: true });
10297
10611
  const sdkRoot = path19.dirname(options.sysroot);
10298
10612
  const catalogs = readGuestRuntimeCatalogs(sdkRoot, options.moduleRoot);
10299
10613
  const sourceImages = guestSourceImages(options.graph);
@@ -10312,13 +10626,13 @@ async function compileGuestLink(options) {
10312
10626
  };
10313
10627
  const buildVersion = imageBuildVersion(entry.buildVersion);
10314
10628
  const clangOptions = [
10315
- "--target=wasm32-unknown-wasip1",
10629
+ "--target=wasm64-unknown-wasip1",
10316
10630
  `--sysroot=${options.sysroot}`,
10317
10631
  `-I${path19.join(options.moduleRoot, "include")}`
10318
10632
  ];
10319
10633
  const stubSource = path19.join(directory, "preselection-projection.c");
10320
10634
  const stub = path19.join(directory, "preselection-projection.o");
10321
- writeFileSync4(
10635
+ writeFileSync5(
10322
10636
  stubSource,
10323
10637
  '#include "guest-image-projection.h"\nconst struct peach_guest_image __peach_guest_images[] = {{0}};\nconst uint32_t __peach_guest_image_count = 0;\n'
10324
10638
  );
@@ -10620,31 +10934,32 @@ async function compileGuestLink(options) {
10620
10934
  }
10621
10935
  });
10622
10936
  if (!reserved || !projectionObject) throw new Error("guest projection was not reserved");
10623
- await optimizeWasm(options.output, options.optimized, [
10624
- "duplicate-function-elimination"
10625
- ]);
10626
- const map = readFileSync11(result.mapPath, "utf8");
10937
+ await lowerWasm(options.output, options.optimized, {
10938
+ optimize: true,
10939
+ skipPasses: ["duplicate-function-elimination"]
10940
+ });
10941
+ const map = readFileSync12(result.mapPath, "utf8");
10627
10942
  if (!/ __peach_guest_images$/m.test(map)) return;
10628
10943
  const finalized = finalizeGuestProjectionStorage({
10629
10944
  map,
10630
- linked: readFileSync11(options.output),
10631
- optimized: readFileSync11(options.optimized),
10945
+ linked: readFileSync12(options.output),
10946
+ optimized: readFileSync12(options.optimized),
10632
10947
  owners: result.owners,
10633
10948
  sectionOwners: result.generatedSectionOwners,
10634
10949
  projectionObject,
10635
10950
  reserved
10636
10951
  });
10637
- writeFileSync4(options.optimized, finalized.wasm);
10952
+ writeFileSync5(options.optimized, finalized.wasm);
10638
10953
  }
10639
10954
 
10640
10955
  // src/swift-icu.ts
10641
- import { execFile as execFile2 } from "node:child_process";
10956
+ import { execFile as execFile3 } from "node:child_process";
10642
10957
  import { createHash as createHash11, randomUUID as randomUUID3 } from "node:crypto";
10643
- import { existsSync as existsSync2, readFileSync as readFileSync12 } from "node:fs";
10958
+ import { existsSync as existsSync2, readFileSync as readFileSync13 } from "node:fs";
10644
10959
  import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
10645
10960
  import os4 from "node:os";
10646
10961
  import path20 from "node:path";
10647
- import { promisify as promisify2 } from "node:util";
10962
+ import { promisify as promisify3 } from "node:util";
10648
10963
  import {
10649
10964
  brotliCompress,
10650
10965
  constants as zlibConstants,
@@ -10708,10 +11023,10 @@ function swiftIcuPack(blob, deflate2) {
10708
11023
  }
10709
11024
 
10710
11025
  // src/swift-icu.ts
10711
- var run = promisify2(execFile2);
10712
- var deflate = promisify2(gzip);
10713
- var compressBrotli = promisify2(brotliCompress);
10714
- var inflateGzip = promisify2(gunzip);
11026
+ var run = promisify3(execFile3);
11027
+ var deflate = promisify3(gzip);
11028
+ var compressBrotli = promisify3(brotliCompress);
11029
+ var inflateGzip = promisify3(gunzip);
10715
11030
  var ARCHIVE = "wasi/lib_FoundationICU.a";
10716
11031
  var MEMBER = "icu_packaged_data.cpp.obj";
10717
11032
  var raw = /* @__PURE__ */ new Map();
@@ -10792,14 +11107,14 @@ async function load(toolchainBin, sdk) {
10792
11107
  ...swiftSdkOptions(),
10793
11108
  "--show-configuration",
10794
11109
  sdk,
10795
- "wasm32-unknown-wasip1"
11110
+ "wasm64-unknown-wasip1"
10796
11111
  ],
10797
11112
  { env: swiftEnvironment() }
10798
11113
  );
10799
11114
  const resources = /^swiftStaticResourcesPath: (.+)$/m.exec(stdout)?.[1]?.trim();
10800
11115
  if (!resources) throw new Error(`swift-icu: ${sdk} names no static resources`);
10801
11116
  return Buffer.from(
10802
- icuSegment(archiveMember(readFileSync12(path20.join(resources, ARCHIVE)), MEMBER))
11117
+ icuSegment(archiveMember(readFileSync13(path20.join(resources, ARCHIVE)), MEMBER))
10803
11118
  );
10804
11119
  }
10805
11120
  function archiveMember(archive, name2) {
@@ -11044,22 +11359,22 @@ import { execFileSync as execFileSync10 } from "node:child_process";
11044
11359
  import {
11045
11360
  chmodSync,
11046
11361
  existsSync as existsSync3,
11047
- mkdirSync as mkdirSync3,
11362
+ mkdirSync as mkdirSync4,
11048
11363
  readdirSync as readdirSync6,
11049
- readFileSync as readFileSync13,
11364
+ readFileSync as readFileSync14,
11050
11365
  realpathSync as realpathSync3,
11051
- rmSync as rmSync4,
11366
+ rmSync as rmSync5,
11052
11367
  statSync
11053
11368
  } from "node:fs";
11054
11369
  import path22 from "node:path";
11055
11370
  function prepareSwiftProjectProcess(root, user) {
11056
11371
  const home = `${root}.project-home`;
11057
- rmSync4(home, { recursive: true, force: true });
11372
+ rmSync5(home, { recursive: true, force: true });
11058
11373
  const tmp = path22.join(home, "tmp");
11059
11374
  const swiftpm = path22.join(home, "swiftpm");
11060
- mkdirSync3(tmp, { recursive: true });
11375
+ mkdirSync4(tmp, { recursive: true });
11061
11376
  const caches = ["cache", "config", "security"].map((name2) => path22.join(swiftpm, name2));
11062
- for (const directory of caches) mkdirSync3(directory, { recursive: true });
11377
+ for (const directory of caches) mkdirSync4(directory, { recursive: true });
11063
11378
  execFileSync10("chown", ["-R", "-P", `${user.uid}:${user.gid}`, root, home]);
11064
11379
  chmodSync(root, 448);
11065
11380
  chmodSync(home, 448);
@@ -11104,8 +11419,8 @@ function removeProjectLinks(root) {
11104
11419
  const full = path22.join(directory, entry.name);
11105
11420
  if (directory === root && entry.name === ".build") continue;
11106
11421
  if (directory === root && entry.name.startsWith(".peach-modules-")) {
11107
- rmSync4(full, { recursive: true, force: true });
11108
- } else if (entry.isSymbolicLink()) rmSync4(full);
11422
+ rmSync5(full, { recursive: true, force: true });
11423
+ } else if (entry.isSymbolicLink()) rmSync5(full);
11109
11424
  else if (entry.isDirectory()) pending.push(full);
11110
11425
  }
11111
11426
  }
@@ -11136,11 +11451,11 @@ import {
11136
11451
  import { createHash as createHash12, randomUUID as randomUUID4 } from "node:crypto";
11137
11452
  import {
11138
11453
  linkSync,
11139
- mkdirSync as mkdirSync4,
11454
+ mkdirSync as mkdirSync5,
11140
11455
  readdirSync as readdirSync7,
11141
- readFileSync as readFileSync14,
11142
- rmSync as rmSync5,
11143
- writeFileSync as writeFileSync5
11456
+ readFileSync as readFileSync15,
11457
+ rmSync as rmSync6,
11458
+ writeFileSync as writeFileSync6
11144
11459
  } from "node:fs";
11145
11460
  import { homedir as homedir2 } from "node:os";
11146
11461
  import path23 from "node:path";
@@ -11209,7 +11524,7 @@ function generationNumbers(directory) {
11209
11524
  function readGeneration(directory, number3) {
11210
11525
  let owner;
11211
11526
  try {
11212
- owner = readFileSync14(path23.join(directory, name(number3, "owner")), "utf8");
11527
+ owner = readFileSync15(path23.join(directory, name(number3, "owner")), "utf8");
11213
11528
  } catch (error) {
11214
11529
  if (errorCode(error) === "ENOENT") return null;
11215
11530
  throw error;
@@ -11222,7 +11537,7 @@ function readGeneration(directory, number3) {
11222
11537
  }
11223
11538
  function readChildren(directory, number3) {
11224
11539
  const prefix = name(number3, "child.");
11225
- return readdirSync7(directory).filter((entry) => entry.startsWith(prefix)).map((entry) => parseIdentity(readFileSync14(path23.join(directory, entry), "utf8")));
11540
+ return readdirSync7(directory).filter((entry) => entry.startsWith(prefix)).map((entry) => parseIdentity(readFileSync15(path23.join(directory, entry), "utf8")));
11226
11541
  }
11227
11542
  function groupAlive(table, leader) {
11228
11543
  const row = table.find((candidate) => candidate.pid === leader.pid);
@@ -11237,7 +11552,7 @@ async function withSwiftRootLock(root, work, signal, wait = true) {
11237
11552
  swiftRootLocksDir(),
11238
11553
  createHash12("sha256").update(root).digest("hex").slice(0, 32)
11239
11554
  );
11240
- mkdirSync4(directory, { recursive: true });
11555
+ mkdirSync5(directory, { recursive: true });
11241
11556
  const token = randomUUID4();
11242
11557
  const ownRow = (await processTableWithRetry(process.pid, signal)).find(
11243
11558
  (candidate) => candidate.pid === process.pid && !candidate.zombie
@@ -11268,18 +11583,18 @@ async function withSwiftRootLock(root, work, signal, wait = true) {
11268
11583
  }
11269
11584
  }
11270
11585
  }
11271
- writeFileSync5(pending, owner);
11586
+ writeFileSync6(pending, owner);
11272
11587
  try {
11273
11588
  linkSync(pending, path23.join(directory, name(newest + 1, "owner")));
11274
11589
  } catch (error) {
11275
11590
  if (errorCode(error) === "EEXIST") continue;
11276
11591
  throw error;
11277
11592
  } finally {
11278
- rmSync5(pending, { force: true });
11593
+ rmSync6(pending, { force: true });
11279
11594
  }
11280
11595
  const numbers = generationNumbers(directory);
11281
11596
  if (numbers.at(-1) !== newest + 1) {
11282
- rmSync5(path23.join(directory, name(newest + 1, "owner")), { force: true });
11597
+ rmSync6(path23.join(directory, name(newest + 1, "owner")), { force: true });
11283
11598
  continue;
11284
11599
  }
11285
11600
  held = newest + 1;
@@ -11287,7 +11602,7 @@ async function withSwiftRootLock(root, work, signal, wait = true) {
11287
11602
  if (number3 < held) {
11288
11603
  for (const entry of readdirSync7(directory))
11289
11604
  if (entry.startsWith(name(number3, "")))
11290
- rmSync5(path23.join(directory, entry), { force: true });
11605
+ rmSync6(path23.join(directory, entry), { force: true });
11291
11606
  }
11292
11607
  break;
11293
11608
  }
@@ -11298,10 +11613,10 @@ async function withSwiftRootLock(root, work, signal, wait = true) {
11298
11613
  if (child.pid === void 0) throw new Error("could not register compiler process");
11299
11614
  const childPending = `${pending}.child.${index}`;
11300
11615
  try {
11301
- writeFileSync5(childPending, JSON.stringify(ownIdentity(child.pid)));
11616
+ writeFileSync6(childPending, JSON.stringify(ownIdentity(child.pid)));
11302
11617
  linkSync(childPending, path23.join(directory, name(held, `child.${index}`)));
11303
11618
  } finally {
11304
- rmSync5(childPending, { force: true });
11619
+ rmSync6(childPending, { force: true });
11305
11620
  }
11306
11621
  },
11307
11622
  spawn(command, args, options, companion) {
@@ -11332,7 +11647,7 @@ async function withSwiftRootLock(root, work, signal, wait = true) {
11332
11647
  return await work(lease);
11333
11648
  } finally {
11334
11649
  await Promise.all(children.map((child) => terminateProcessGroup(child, "SIGKILL", 0)));
11335
- writeFileSync5(path23.join(directory, name(held, "released")), "");
11650
+ writeFileSync6(path23.join(directory, name(held, "released")), "");
11336
11651
  }
11337
11652
  }
11338
11653
 
@@ -11345,7 +11660,7 @@ function compileUniformTypeConstants(args) {
11345
11660
  execFileSync11(
11346
11661
  path24.join(args.bin, "clang"),
11347
11662
  [
11348
- "--target=wasm32-unknown-wasip1",
11663
+ "--target=wasm64-unknown-wasip1",
11349
11664
  `--sysroot=${args.sysroot}`,
11350
11665
  "-Oz",
11351
11666
  "-g0",
@@ -11525,13 +11840,13 @@ function isSwiftResourceBundles(value) {
11525
11840
  }
11526
11841
 
11527
11842
  // src/write-build-file.ts
11528
- import { existsSync as existsSync4, mkdirSync as mkdirSync5, readFileSync as readFileSync15, writeFileSync as writeFileSync6 } from "node:fs";
11843
+ import { existsSync as existsSync4, mkdirSync as mkdirSync6, readFileSync as readFileSync16, writeFileSync as writeFileSync7 } from "node:fs";
11529
11844
  import path25 from "node:path";
11530
11845
  function writeBuildFile(file, contents) {
11531
- if (existsSync4(file) && (typeof contents === "string" ? readFileSync15(file, "utf8") === contents : readFileSync15(file).equals(contents)))
11846
+ if (existsSync4(file) && (typeof contents === "string" ? readFileSync16(file, "utf8") === contents : readFileSync16(file).equals(contents)))
11532
11847
  return;
11533
- mkdirSync5(path25.dirname(file), { recursive: true });
11534
- writeFileSync6(file, contents);
11848
+ mkdirSync6(path25.dirname(file), { recursive: true });
11849
+ writeFileSync7(file, contents);
11535
11850
  }
11536
11851
 
11537
11852
  // src/xcode-header-search.ts
@@ -11718,7 +12033,7 @@ async function runCompiler(command, args, options, stream = false, quiet) {
11718
12033
  await stopping;
11719
12034
  }
11720
12035
  }
11721
- var WASM_TRIPLE = "wasm32-unknown-wasip1";
12036
+ var WASM_TRIPLE = "wasm64-unknown-wasip1";
11722
12037
  var SWIFTPM_PROGRESS = /^\[\d+\/\d+\] /;
11723
12038
  var SWIFTPM_NOISE = /^(?:\[\d+\/\d+\] |Building for production\.\.\.$|warning: '--build-system native' has been deprecated)/;
11724
12039
  function swiftBuildJobs() {
@@ -11737,7 +12052,7 @@ function swiftBuilderHopTimeoutMs(compileTimeoutMs) {
11737
12052
  function swiftDistributionAt(root) {
11738
12053
  const file = path27.join(root, SWIFT_DISTRIBUTION_MANIFEST);
11739
12054
  if (!existsSync5(file)) return null;
11740
- return parseSwiftDistributionManifest(JSON.parse(readFileSync16(file, "utf8")));
12055
+ return parseSwiftDistributionManifest(JSON.parse(readFileSync17(file, "utf8")));
11741
12056
  }
11742
12057
  function swiftModuleInterface(moduleRoot, name2, interfaceRoot) {
11743
12058
  if (swiftDistributionAt(moduleRoot)) {
@@ -11746,7 +12061,7 @@ function swiftModuleInterface(moduleRoot, name2, interfaceRoot) {
11746
12061
  `${name2}-Swift.h`
11747
12062
  );
11748
12063
  if (!existsSync5(file)) return null;
11749
- const header = clangInterfaceHeader(readFileSync16(file, "utf8"));
12064
+ const header = clangInterfaceHeader(readFileSync17(file, "utf8"));
11750
12065
  return { declared: swiftInterfaceDeclarations(header), header };
11751
12066
  }
11752
12067
  const sources = path27.join(moduleRoot, "Sources", name2);
@@ -11755,7 +12070,7 @@ function swiftModuleInterface(moduleRoot, name2, interfaceRoot) {
11755
12070
  const declared = /* @__PURE__ */ new Set();
11756
12071
  for (const file of readdirSync8(sources, { recursive: true, encoding: "utf8" }))
11757
12072
  if (file.endsWith(".swift"))
11758
- for (const [, objc, subclass] of readFileSync16(
12073
+ for (const [, objc, subclass] of readFileSync17(
11759
12074
  path27.join(sources, file),
11760
12075
  "utf8"
11761
12076
  ).matchAll(
@@ -11763,12 +12078,26 @@ function swiftModuleInterface(moduleRoot, name2, interfaceRoot) {
11763
12078
  ))
11764
12079
  declared.add(objc ?? subclass);
11765
12080
  if (declared.size === 0) return null;
11766
- return { declared, header: clangInterfaceHeader(readFileSync16(built, "utf8")) };
12081
+ return { declared, header: clangInterfaceHeader(readFileSync17(built, "utf8")) };
11767
12082
  }
11768
12083
  var clangInterfaceHeader = (header) => header.replace(/^@import (?:UIKitCore|UIKitText);$/gm, "@import UIKit;").replace(
11769
12084
  /^@import (?:CoreFoundation|FoundationNetworking);$/gm,
11770
12085
  "@import Foundation;"
11771
12086
  ).replace(/\b_TtC10Foundation\d+(NS\w+)\b/g, "$1").replace(/\b__attribute__\(\(objc_subclassing_restricted\)\)\s*/g, "");
12087
+ function swiftHeaderWithSuperclassImports(header, interfaceFor) {
12088
+ const superclasses = new Set(
12089
+ [...header.matchAll(/@interface\s+\w+\s*:\s*(\w+)/g)].map((match) => match[1])
12090
+ );
12091
+ return header.replace(/^@import (\w+);$/gm, (statement, name2) => {
12092
+ const dependency = interfaceFor(name2);
12093
+ if (!dependency || ![...swiftInterfaceDeclarations(dependency.header)].some(
12094
+ (name3) => superclasses.has(name3)
12095
+ ))
12096
+ return statement;
12097
+ return `${statement}
12098
+ #import ${JSON.stringify(dependency.file)}`;
12099
+ });
12100
+ }
11772
12101
  var swiftInterfaceDeclarations = (header) => /* @__PURE__ */ new Set([
11773
12102
  ...[
11774
12103
  ...header.matchAll(
@@ -11836,7 +12165,7 @@ function swiftObjCSelectorOptions(moduleRoot) {
11836
12165
  for (const framework of ["UIKitCore", "WebKit"])
11837
12166
  for (const [name2, members] of Object.entries(
11838
12167
  JSON.parse(
11839
- readFileSync16(
12168
+ readFileSync17(
11840
12169
  path27.join(moduleRoot, "Sources", framework, "ObjCSelectors.json"),
11841
12170
  "utf8"
11842
12171
  )
@@ -11844,9 +12173,9 @@ function swiftObjCSelectorOptions(moduleRoot) {
11844
12173
  ))
11845
12174
  classes[name2] = [...classes[name2] ?? [], ...members];
11846
12175
  map = path27.join(moduleRoot, ".build", SWIFT_DISTRIBUTION_OBJC_SELECTORS);
11847
- mkdirSync6(path27.dirname(map), { recursive: true });
12176
+ mkdirSync7(path27.dirname(map), { recursive: true });
11848
12177
  const partial = `${map}.${randomUUID5()}`;
11849
- writeFileSync7(partial, `${JSON.stringify({ classes }, null, 2)}
12178
+ writeFileSync8(partial, `${JSON.stringify({ classes }, null, 2)}
11850
12179
  `);
11851
12180
  renameSync2(partial, map);
11852
12181
  }
@@ -11905,7 +12234,7 @@ function swiftMacroPlugins(moduleRoot, dir = path27.join(moduleRoot, ".build/hos
11905
12234
  stale: false
11906
12235
  };
11907
12236
  const release = JSON.parse(
11908
- readFileSync16(path27.join(moduleRoot, "toolchain.json"), "utf8")
12237
+ readFileSync17(path27.join(moduleRoot, "toolchain.json"), "utf8")
11909
12238
  ).release;
11910
12239
  const compilerStamp = path27.join(dir, "compiler-release");
11911
12240
  const pluginScript = path27.join(moduleRoot, "scripts/build-preview-plugin.sh");
@@ -11934,7 +12263,7 @@ function swiftMacroPlugins(moduleRoot, dir = path27.join(moduleRoot, ".build/hos
11934
12263
  return {
11935
12264
  libraries: plugins.map(({ library }) => library),
11936
12265
  executables: [expoPlugin],
11937
- stale: !existsSync5(compilerStamp) || !existsSync5(expoPlugin) || statSync2(pluginScript).mtimeMs > statSync2(expoPlugin).mtimeMs || readFileSync16(compilerStamp, "utf8").trim() !== release || plugins.some(
12266
+ stale: !existsSync5(compilerStamp) || !existsSync5(expoPlugin) || statSync2(pluginScript).mtimeMs > statSync2(expoPlugin).mtimeMs || readFileSync17(compilerStamp, "utf8").trim() !== release || plugins.some(
11938
12267
  ({ library, sources }) => !existsSync5(library) || sources.some((source) => statSync2(source).mtimeMs > statSync2(library).mtimeMs)
11939
12268
  )
11940
12269
  };
@@ -11951,7 +12280,7 @@ async function ensureMacroPlugins(moduleRoot, toolchainBin, release, signal, lea
11951
12280
  ],
11952
12281
  { signal, lease }
11953
12282
  );
11954
- writeFileSync7(
12283
+ writeFileSync8(
11955
12284
  path27.join(path27.dirname(libraries[0]), "compiler-release"),
11956
12285
  `${release}
11957
12286
  `
@@ -11984,7 +12313,7 @@ function swiftModuleDigest(root) {
11984
12313
  `${createHash13("sha256").update(root).digest("hex")}.json`
11985
12314
  );
11986
12315
  if (existsSync5(record)) {
11987
- const saved = JSON.parse(readFileSync16(record, "utf8"));
12316
+ const saved = JSON.parse(readFileSync17(record, "utf8"));
11988
12317
  if (saved && typeof saved === "object" && Reflect.get(saved, "stamp") === stamp && typeof Reflect.get(saved, "digest") === "string") {
11989
12318
  const digest2 = Buffer.from(String(Reflect.get(saved, "digest")), "hex");
11990
12319
  linkedModuleDigests.set(root, { stamp, digest: digest2 });
@@ -11995,14 +12324,14 @@ function swiftModuleDigest(root) {
11995
12324
  for (const file of files) {
11996
12325
  hash.update(createHash13("sha256").update(file).digest());
11997
12326
  hash.update(
11998
- createHash13("sha256").update(readFileSync16(path27.join(root, file))).digest()
12327
+ createHash13("sha256").update(readFileSync17(path27.join(root, file))).digest()
11999
12328
  );
12000
12329
  }
12001
12330
  const digest = hash.digest();
12002
12331
  linkedModuleDigests.set(root, { stamp, digest });
12003
- mkdirSync6(path27.dirname(record), { recursive: true });
12332
+ mkdirSync7(path27.dirname(record), { recursive: true });
12004
12333
  const partial = `${record}.${process.pid}.${randomUUID5()}`;
12005
- writeFileSync7(partial, JSON.stringify({ stamp, digest: digest.toString("hex") }));
12334
+ writeFileSync8(partial, JSON.stringify({ stamp, digest: digest.toString("hex") }));
12006
12335
  renameSync2(partial, record);
12007
12336
  return digest;
12008
12337
  }
@@ -12126,7 +12455,7 @@ var OPTIONAL_FRAMEWORKS = new Set(Object.keys(OPTIONAL_FRAMEWORK_DEPENDENCIES));
12126
12455
  function swiftOptionalFramework(name2) {
12127
12456
  return OPTIONAL_FRAMEWORKS.has(name2);
12128
12457
  }
12129
- var SWIFT_IMPORT = /^\s*(?:@\w+(?:\([^)]*\))?\s+)*import\s+(?:(?:typealias|struct|class|enum|protocol|let|var|func)\s+)?([A-Za-z_][A-Za-z0-9_]*)/;
12458
+ var SWIFT_IMPORT = /^\s*(?:@\w+(?:\([^)]*\))?\s+|(?:public|package|internal|fileprivate|private)\s+)*import\s+(?:(?:typealias|struct|class|enum|protocol|let|var|func)\s+)?([A-Za-z_][A-Za-z0-9_]*)/;
12130
12459
  var kleeneNot = (value) => value === void 0 ? void 0 : !value;
12131
12460
  var kleeneAnd = (left, right) => left === false || right === false ? false : left === true && right === true ? true : void 0;
12132
12461
  var kleeneOr = (left, right) => left === true || right === true ? true : left === false && right === false ? false : void 0;
@@ -12146,10 +12475,11 @@ function swiftCondition(text2, available) {
12146
12475
  const call = /^(\w+)\s*\(\s*([^,()]*?)\s*(?:,[^()]*)?\)$/.exec(token ?? "");
12147
12476
  if (!call) return void 0;
12148
12477
  const [, name2, argument] = call;
12149
- if (name2 === "os") return argument === "iOS" || argument === "WASI";
12150
- if (name2 === "canImport") return available?.has(argument);
12478
+ if (name2 === "os") return argument === "iOS";
12479
+ if (name2 === "canImport")
12480
+ return argument !== "FoundationNetworking" && available?.has(argument);
12151
12481
  if (name2 === "targetEnvironment") return argument === "simulator";
12152
- if (name2 === "arch") return argument === "wasm32";
12482
+ if (name2 === "arch") return argument === "wasm64";
12153
12483
  return void 0;
12154
12484
  };
12155
12485
  const both = () => {
@@ -12208,7 +12538,7 @@ function swiftImportNames(contents, available) {
12208
12538
  function swiftPeachModules(moduleRoot) {
12209
12539
  const distribution = swiftDistributionAt(moduleRoot);
12210
12540
  return distribution ? distribution.modules : swiftManifestDeclarations(
12211
- readFileSync16(path27.join(moduleRoot, "Package.swift"), "utf8")
12541
+ readFileSync17(path27.join(moduleRoot, "Package.swift"), "utf8")
12212
12542
  ).filter((target) => !target.executable && !target.path.startsWith("fixtures/")).map((target) => target.name);
12213
12543
  }
12214
12544
  var sdkPaths = /* @__PURE__ */ new Map();
@@ -12226,7 +12556,7 @@ function swiftSdkPaths(moduleRoot, toolchainBin) {
12226
12556
  ...options,
12227
12557
  "--show-configuration",
12228
12558
  sdk,
12229
- "wasm32-unknown-wasip1"
12559
+ "wasm64-unknown-wasip1"
12230
12560
  ],
12231
12561
  { encoding: "utf8", env: swiftEnvironment(), stdio: ["ignore", "pipe", "pipe"] }
12232
12562
  );
@@ -12244,7 +12574,7 @@ function swiftSdkPaths(moduleRoot, toolchainBin) {
12244
12574
  if (!Array.isArray(toolsets) || !toolsets.every((value) => typeof value === "string"))
12245
12575
  throw new Error(`swift sdk ${sdk} reports invalid toolset paths`);
12246
12576
  for (const toolset of toolsets) {
12247
- const config = JSON.parse(readFileSync16(toolset, "utf8"));
12577
+ const config = JSON.parse(readFileSync17(toolset, "utf8"));
12248
12578
  if (!config || typeof config !== "object" || !("swiftCompiler" in config)) continue;
12249
12579
  const compiler = config.swiftCompiler;
12250
12580
  if (!compiler || typeof compiler !== "object" || !("extraCLIOptions" in compiler))
@@ -12309,20 +12639,20 @@ function swiftOverlayFrameworks(moduleRoot, toolchainBin) {
12309
12639
  for (const entry of readdirSync8(include))
12310
12640
  if (entry.endsWith(".modulemap"))
12311
12641
  addSwiftOverlayFrameworks(
12312
- readFileSync16(path27.join(include, entry), "utf8"),
12642
+ readFileSync17(path27.join(include, entry), "utf8"),
12313
12643
  swiftModules,
12314
12644
  result
12315
12645
  );
12316
12646
  for (const entry of readdirSync8(resources)) {
12317
12647
  const map = path27.join(resources, entry, "module.modulemap");
12318
12648
  if (existsSync5(map))
12319
- addSwiftOverlayFrameworks(readFileSync16(map, "utf8"), swiftModules, result);
12649
+ addSwiftOverlayFrameworks(readFileSync17(map, "utf8"), swiftModules, result);
12320
12650
  }
12321
12651
  for (const directory of frameworks)
12322
12652
  for (const entry of readdirSync8(directory)) {
12323
12653
  const map = path27.join(directory, entry, "Modules/module.modulemap");
12324
12654
  if (existsSync5(map))
12325
- addSwiftOverlayFrameworks(readFileSync16(map, "utf8"), swiftModules, result);
12655
+ addSwiftOverlayFrameworks(readFileSync17(map, "utf8"), swiftModules, result);
12326
12656
  }
12327
12657
  sdkOverlayFrameworks.set(key, result);
12328
12658
  return result;
@@ -12346,7 +12676,7 @@ function swiftAvailableModules(moduleRoot, toolchainBin) {
12346
12676
  ]);
12347
12677
  for (const map of maps) {
12348
12678
  if (!existsSync5(map)) continue;
12349
- const contents = readFileSync16(map, "utf8");
12679
+ const contents = readFileSync17(map, "utf8");
12350
12680
  for (const match of contents.matchAll(
12351
12681
  /^(?:explicit\s+)?(?:framework\s+)?module\s+([A-Za-z_]\w*)/gm
12352
12682
  ))
@@ -12361,7 +12691,7 @@ function swiftAvailableModules(moduleRoot, toolchainBin) {
12361
12691
  for (const entry of readdirSync8(resources)) {
12362
12692
  const map = path27.join(resources, entry, "module.modulemap");
12363
12693
  if (!existsSync5(map)) continue;
12364
- for (const match of readFileSync16(map, "utf8").matchAll(/^module\s+([A-Za-z_]\w*)/gm))
12694
+ for (const match of readFileSync17(map, "utf8").matchAll(/^module\s+([A-Za-z_]\w*)/gm))
12365
12695
  modules.add(match[1]);
12366
12696
  }
12367
12697
  for (const libc of [
@@ -12373,7 +12703,7 @@ function swiftAvailableModules(moduleRoot, toolchainBin) {
12373
12703
  ])
12374
12704
  for (const entry of readdirSync8(libc)) {
12375
12705
  if (!entry.endsWith(".modulemap")) continue;
12376
- for (const match of readFileSync16(path27.join(libc, entry), "utf8").matchAll(
12706
+ for (const match of readFileSync17(path27.join(libc, entry), "utf8").matchAll(
12377
12707
  /^module\s+([A-Za-z_]\w*)/gm
12378
12708
  ))
12379
12709
  modules.add(match[1]);
@@ -12382,7 +12712,7 @@ function swiftAvailableModules(moduleRoot, toolchainBin) {
12382
12712
  for (const entry of readdirSync8(directory)) {
12383
12713
  const map = path27.join(directory, entry, "Modules/module.modulemap");
12384
12714
  if (!existsSync5(map)) continue;
12385
- for (const match of readFileSync16(map, "utf8").matchAll(
12715
+ for (const match of readFileSync17(map, "utf8").matchAll(
12386
12716
  /^framework\s+module\s+([A-Za-z_]\w*)/gm
12387
12717
  ))
12388
12718
  modules.add(match[1]);
@@ -12491,12 +12821,12 @@ function distributionClangModuleMap(root, modules) {
12491
12821
  const directory = path27.join(root, `.peach-clang-modules-${key}`);
12492
12822
  const mapPath = path27.join(directory, "module.modulemap");
12493
12823
  if (!existsSync5(mapPath)) {
12494
- mkdirSync6(directory, { recursive: true });
12824
+ mkdirSync7(directory, { recursive: true });
12495
12825
  const parts = [];
12496
12826
  for (const mod of missing) {
12497
12827
  const destination = path27.join(directory, mod.header);
12498
- mkdirSync6(path27.dirname(destination), { recursive: true });
12499
- writeFileSync7(destination, mod.source);
12828
+ mkdirSync7(path27.dirname(destination), { recursive: true });
12829
+ writeFileSync8(destination, mod.source);
12500
12830
  parts.push(
12501
12831
  `module ${mod.name} {
12502
12832
  requires objc
@@ -12506,7 +12836,7 @@ function distributionClangModuleMap(root, modules) {
12506
12836
  `
12507
12837
  );
12508
12838
  }
12509
- writeFileSync7(mapPath, parts.join("\n"));
12839
+ writeFileSync8(mapPath, parts.join("\n"));
12510
12840
  }
12511
12841
  return mapPath;
12512
12842
  }
@@ -12521,13 +12851,13 @@ function providedModulesPath(root, modules, excluded) {
12521
12851
  const directory = path27.join(root, `.peach-modules-${key}`);
12522
12852
  const complete = path27.join(directory, ".complete");
12523
12853
  if (!existsSync5(complete)) {
12524
- mkdirSync6(directory, { recursive: true });
12854
+ mkdirSync7(directory, { recursive: true });
12525
12855
  for (const entry of readdirSync8(directory))
12526
- rmSync6(path27.join(directory, entry), { recursive: true, force: true });
12856
+ rmSync7(path27.join(directory, entry), { recursive: true, force: true });
12527
12857
  for (const entry of entries) {
12528
12858
  symlinkSync2(path27.join(modules, entry), path27.join(directory, entry));
12529
12859
  }
12530
- writeFileSync7(complete, "");
12860
+ writeFileSync8(complete, "");
12531
12861
  }
12532
12862
  return directory;
12533
12863
  }
@@ -12599,6 +12929,14 @@ var FOUNDATION_IMPLICIT_MODULES = [
12599
12929
  "PeachFoundationCombine",
12600
12930
  "Darwin"
12601
12931
  ];
12932
+ var PRECONCURRENCY_FOUNDATION_IMPORT = /^[ \t]*@preconcurrency[ \t]+(?:(?:public|package|internal|fileprivate|private)[ \t]+)?import[ \t]+(?:Foundation|UIKit|SwiftUI)[ \t]*(?:\/\/.*)?$/m;
12933
+ function withPreconcurrencyFoundationModules(source) {
12934
+ if (!PRECONCURRENCY_FOUNDATION_IMPORT.test(source)) return source;
12935
+ return `${source}${source.endsWith("\n") ? "" : "\n"}#if canImport(PeachObjC)
12936
+ ${["ObjectiveC", ...FOUNDATION_IMPLICIT_MODULES].map((module) => `@preconcurrency import ${module}
12937
+ `).join("")}#endif
12938
+ `;
12939
+ }
12602
12940
  var FOUNDATION_IMPLICIT_FLAGS = FOUNDATION_IMPLICIT_MODULES.map(
12603
12941
  (module) => `, "-Xfrontend", "-import-module", "-Xfrontend", "${module}"`
12604
12942
  ).join("");
@@ -12614,11 +12952,11 @@ var executableLinkFlags = (root) => ` "-Xclang-linker", "-O0",
12614
12952
  "-Xlinker", "--wrap=swift_udata_open",
12615
12953
  "-Xlinker", "--wrap=swift_udata_openChoice",
12616
12954
  `;
12617
- var darwinRecordsRegion = (quoted) => quoted.length ? ["-Wl,--start-lib", ...quoted, "-Wl,--end-lib"] : [];
12955
+ var darwinRecordsRegion = (quoted2) => quoted2.length ? ["-Wl,--start-lib", ...quoted2, "-Wl,--end-lib"] : [];
12618
12956
  var REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
12619
12957
  var MULTI_MANIFEST_VERSION = 68;
12620
12958
  var SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
12621
- var compilerSourceDigest = true ? "ae9e08389e6ab1901846342a7b347d7c10f8074172cf5d4d6505f7e955879ad4" : swiftCompilerSourceDigest(import.meta.dirname);
12959
+ var compilerSourceDigest = true ? "280e858b01b1c1393d3765c8d6ff1b3ce4a1a93d7fb7e3dd2d4d3e5f1d5f1ac2" : swiftCompilerSourceDigest(import.meta.dirname);
12622
12960
  function swiftArtifactHash(input, release, moduleRoot) {
12623
12961
  const hash = createHash13("sha256");
12624
12962
  hash.update(`swift-compile
@@ -12628,9 +12966,10 @@ ${release}
12628
12966
  if (input.oneModule) hash.update("one-module\n");
12629
12967
  if (KEEP_WASM_NAMES) hash.update("names\n");
12630
12968
  hash.update(swiftModuleDigest(moduleRoot));
12631
- if (input.optimize) hash.update(`optimize
12632
- ${WASM_OPTIMIZE_IDENTITY}
12969
+ hash.update(`lower
12970
+ ${WASM_LOWER_IDENTITY}
12633
12971
  `);
12972
+ if (input.optimize) hash.update("optimize\n");
12634
12973
  for (const file of Object.keys(input.files).sort()) {
12635
12974
  hash.update(createHash13("sha256").update(file).digest());
12636
12975
  hash.update(createHash13("sha256").update(input.files[file]).digest());
@@ -12740,6 +13079,7 @@ function toolsetOrdersLibcxxBeforeDarwinOverlay(options) {
12740
13079
  const overlay = options.indexOf("=/darwin/wasm/include");
12741
13080
  return libcxx >= 0 && overlay > libcxx;
12742
13081
  }
13082
+ var SWIFTPM_DEFAULT_IOS_DEPLOYMENT_TARGET = "12.0";
12743
13083
  function emitSwiftPackageManifest(args) {
12744
13084
  const {
12745
13085
  targets,
@@ -12759,7 +13099,7 @@ function emitSwiftPackageManifest(args) {
12759
13099
  if (!flag.startsWith("-fmodule-map-file=")) return false;
12760
13100
  const file = flag.slice("-fmodule-map-file=".length).replaceAll(SWIFT_NATIVE_INPUT_ROOT, args.root);
12761
13101
  if (!file.includes("/Pods/Headers/")) return false;
12762
- const map = args.files.get(file) ?? (existsSync5(file) ? readFileSync16(file) : void 0);
13102
+ const map = args.files.get(file) ?? (existsSync5(file) ? readFileSync17(file) : void 0);
12763
13103
  const name2 = map === void 0 ? void 0 : moduleMapName(map.toString());
12764
13104
  return name2 !== void 0 && packageModules.has(name2);
12765
13105
  };
@@ -12791,7 +13131,7 @@ function emitSwiftPackageManifest(args) {
12791
13131
  const product = v5.parse(
12792
13132
  swiftFrameworkProductSchema,
12793
13133
  JSON.parse(
12794
- readFileSync16(path27.join(moduleRoot, SWIFT_FRAMEWORK_PRODUCT_FILE), "utf8")
13134
+ readFileSync17(path27.join(moduleRoot, SWIFT_FRAMEWORK_PRODUCT_FILE), "utf8")
12795
13135
  )
12796
13136
  );
12797
13137
  const replacedObjects = new Set(
@@ -12805,7 +13145,7 @@ function emitSwiftPackageManifest(args) {
12805
13145
  (name2) => !object3.startsWith(`lib/${name2}-`) || reachedFrameworks.has(name2)
12806
13146
  )
12807
13147
  );
12808
- const quoted = (object3) => `"${path27.join(moduleRoot, object3).replaceAll("\\", "\\\\").replaceAll('"', '\\"')}"`;
13148
+ const quoted2 = (object3) => `"${path27.join(moduleRoot, object3).replaceAll("\\", "\\\\").replaceAll('"', '\\"')}"`;
12809
13149
  const categoryObjects = new Set(
12810
13150
  foundationCategoryObjects.map((name2) => `lib/Foundation-${name2}.o`)
12811
13151
  );
@@ -12814,11 +13154,11 @@ function emitSwiftPackageManifest(args) {
12814
13154
  objects.filter((object3) => roots.has(object3) || categoryObjects.has(object3))
12815
13155
  );
12816
13156
  const list = [
12817
- ...[...eager].map(quoted),
13157
+ ...[...eager].map(quoted2),
12818
13158
  "-Wl,--start-lib",
12819
- ...available.filter((object3) => !eager.has(object3)).map(quoted),
13159
+ ...available.filter((object3) => !eager.has(object3)).map(quoted2),
12820
13160
  "-Wl,--end-lib",
12821
- ...darwinRecordsRegion(distribution.objects.filter(isProvider).map(quoted))
13161
+ ...darwinRecordsRegion(distribution.objects.filter(isProvider).map(quoted2))
12822
13162
  ].join("\n") + "\n";
12823
13163
  distributionLinkPath = distributionLink.path.replace(
12824
13164
  /\.rsp$/,
@@ -12940,7 +13280,8 @@ function emitSwiftPackageManifest(args) {
12940
13280
  (value) => value.late?.producers.includes(target.name)
12941
13281
  )) ? `, "-emit-objc-header-path", ${JSON.stringify(path27.join(args.headerDirectory, `${target.name}-Swift${args.nativeHeaderDeclarations?.[target.name] ? ".original" : ""}.h`))}` : "";
12942
13282
  const clangMode = target.cxxInterop ? "" : ', "-Xcc", "-fno-cxx-modules"';
12943
- const swiftSettings = `swiftSettings: [.swiftLanguageMode(.v${target.languageMode}),${isolation}${interoperability}${defines}${features}${upcoming} .unsafeFlags(${swiftFlagArray(`["-Osize", "-Xfrontend", "-enable-cross-import-overlays"${overlayFlags}${FOUNDATION_IMPLICIT_FLAGS}${oneModule ? ONE_IMPLICIT_FLAGS : ""}${imports}${nativeImportFlags}${objcFlags}${header}${clangMode}${upstream}]`)})]`;
13283
+ const deployment = `, "-Xfrontend", "-peach-ios-deployment-target", "-Xfrontend", ${JSON.stringify(target.iosDeploymentTarget ?? SWIFTPM_DEFAULT_IOS_DEPLOYMENT_TARGET)}`;
13284
+ const swiftSettings = `swiftSettings: [.swiftLanguageMode(.v${target.languageMode}),${isolation}${interoperability}${defines}${features}${upcoming} .unsafeFlags(${swiftFlagArray(`["-Osize", "-Xfrontend", "-enable-cross-import-overlays"${overlayFlags}${FOUNDATION_IMPLICIT_FLAGS}${oneModule ? ONE_IMPLICIT_FLAGS : ""}${imports}${nativeImportFlags}${objcFlags}${header}${clangMode}${deployment}${upstream}]`)})]`;
12944
13285
  const deps = [
12945
13286
  .../* @__PURE__ */ new Set([
12946
13287
  ...(target.dependencies ?? []).flatMap(
@@ -13106,7 +13447,7 @@ function emitSwiftPackageManifest(args) {
13106
13447
  ].join("\n");
13107
13448
  }
13108
13449
  function syncSwiftTree(base, files) {
13109
- mkdirSync6(base, { recursive: true });
13450
+ mkdirSync7(base, { recursive: true });
13110
13451
  const walk = (dir) => {
13111
13452
  for (const entry of readdirSync8(dir, { withFileTypes: true })) {
13112
13453
  const full = path27.join(dir, entry.name);
@@ -13115,7 +13456,7 @@ function syncSwiftTree(base, files) {
13115
13456
  entry.name.startsWith(".peach-clang-modules-") || entry.name === SWIFT_LINK_STAMP))
13116
13457
  continue;
13117
13458
  if (entry.isDirectory()) walk(full);
13118
- else if (!files.has(full)) rmSync6(full, { force: true });
13459
+ else if (!files.has(full)) rmSync7(full, { force: true });
13119
13460
  }
13120
13461
  };
13121
13462
  walk(base);
@@ -13125,6 +13466,7 @@ function syncSwiftTree(base, files) {
13125
13466
  }
13126
13467
  var DIRECTIVE = /^[ \t]*#(?:if|elseif)\b/;
13127
13468
  var OS_IOS = /\b(?:os\(\s*iOS\s*\)|targetEnvironment\(\s*simulator\s*\))/g;
13469
+ var NOT_ON_IOS = /\b(?:os\(\s*WASI\s*\)|canImport\(\s*FoundationNetworking\s*\))/g;
13128
13470
  var DELEGATE_CLASS = /^class\s+[A-Za-z_]\w*\s*(?:<[^>{]*>)?\s*:[^{]*\b(?:UIApplicationDelegate|UISceneDelegate|UIWindowSceneDelegate)\b[^{]*\{/;
13129
13471
  function compiledSwiftSources(files, targets, overlayFrameworks) {
13130
13472
  const ordered = [...targets].sort((a, b) => b.path.length - a.path.length);
@@ -13139,14 +13481,14 @@ function compiledSwiftSources(files, targets, overlayFrameworks) {
13139
13481
  );
13140
13482
  });
13141
13483
  const manifest = /(?:^|\/)Package(?:@swift-[\d.]+)?\.swift$/.test(file);
13142
- return [
13143
- file,
13144
- manifest && (!owner || /^Package(?:@swift-[\d.]+)?\.swift$/.test(file)) ? source : swiftSourceAsIOS(
13145
- source,
13146
- overlayFrameworks,
13147
- owner?.defines?.includes(SWIFT_XCODE_BUILD_CONDITION) && !owner.defines.includes("SWIFT_PACKAGE") ? false : void 0
13148
- )
13149
- ];
13484
+ if (manifest && (!owner || /^Package(?:@swift-[\d.]+)?\.swift$/.test(file)))
13485
+ return [file, source];
13486
+ const ios = swiftSourceAsIOS(
13487
+ source,
13488
+ overlayFrameworks,
13489
+ owner?.defines?.includes(SWIFT_XCODE_BUILD_CONDITION) && !owner.defines.includes("SWIFT_PACKAGE") ? false : void 0
13490
+ );
13491
+ return [file, withPreconcurrencyFoundationModules(ios)];
13150
13492
  })
13151
13493
  );
13152
13494
  }
@@ -13797,16 +14139,22 @@ function foundationOwnerOf(name2) {
13797
14139
  return "PeachFoundation";
13798
14140
  return void 0;
13799
14141
  }
13800
- function swiftSourceAsIOS(source, overlayFrameworks, swiftPackage) {
13801
- const { lineStarts, tokens } = swiftCodeScan(source);
14142
+ function swiftPackageSourceAsIOS(source) {
14143
+ return swiftConditionsAsIOS(source, swiftCodeScan(source).lineStarts);
14144
+ }
14145
+ function swiftConditionsAsIOS(source, lineStarts, swiftPackage) {
13802
14146
  let offset = 0;
13803
- const conditioned = source.split("\n").map((line) => {
14147
+ return source.split("\n").map((line) => {
13804
14148
  const start = offset;
13805
14149
  offset += line.length + 1;
13806
14150
  if (!lineStarts.has(start) || !DIRECTIVE.test(line)) return line;
13807
- const platform = line.replace(OS_IOS, (match) => "true".padEnd(match.length));
14151
+ const platform = line.replace(OS_IOS, (match) => "true".padEnd(match.length)).replace(NOT_ON_IOS, (match) => "false".padEnd(match.length));
13808
14152
  return swiftPackage === false ? platform.replace(/\bSWIFT_PACKAGE\b/g, (match) => "false".padEnd(match.length)) : platform;
13809
14153
  }).join("\n");
14154
+ }
14155
+ function swiftSourceAsIOS(source, overlayFrameworks, swiftPackage) {
14156
+ const { lineStarts, tokens } = swiftCodeScan(source);
14157
+ const conditioned = swiftConditionsAsIOS(source, lineStarts, swiftPackage);
13810
14158
  let out = "";
13811
14159
  let copied = 0;
13812
14160
  const sceneLifecycleBodies = /* @__PURE__ */ new Set();
@@ -14263,7 +14611,7 @@ var wasmMacroEnvironment = {
14263
14611
  ...emptyMacroEnvironment,
14264
14612
  defines: /* @__PURE__ */ new Map([
14265
14613
  ["__wasm__", "1"],
14266
- ["__wasm32__", "1"],
14614
+ ["__wasm64__", "1"],
14267
14615
  ["__wasi__", "1"]
14268
14616
  ])
14269
14617
  };
@@ -14427,7 +14775,7 @@ function swiftCodeScan(source) {
14427
14775
  return { lineStarts: starts, tokens };
14428
14776
  }
14429
14777
  function prepareSwiftDependency(source, destination, overlayFrameworks) {
14430
- rmSync6(destination, { recursive: true, force: true });
14778
+ rmSync7(destination, { recursive: true, force: true });
14431
14779
  const origins = {};
14432
14780
  const moduleMaps = [];
14433
14781
  const gather = (from) => {
@@ -14437,14 +14785,14 @@ function prepareSwiftDependency(source, destination, overlayFrameworks) {
14437
14785
  const file = path27.join(from, entry.name);
14438
14786
  if (entry.isDirectory()) gather(file);
14439
14787
  else if (entry.isFile() && entry.name.endsWith(".swift"))
14440
- origins[path27.relative(source, file)] = readFileSync16(file, "utf8");
14788
+ origins[path27.relative(source, file)] = readFileSync17(file, "utf8");
14441
14789
  else if (entry.isFile() && entry.name.endsWith(".modulemap"))
14442
- moduleMaps.push(readFileSync16(file, "utf8"));
14790
+ moduleMaps.push(readFileSync17(file, "utf8"));
14443
14791
  }
14444
14792
  };
14445
14793
  gather(source);
14446
14794
  const manifest = path27.join(source, "Package.swift");
14447
- const targets = existsSync5(manifest) ? swiftManifestTargets(readFileSync16(manifest, "utf8")) : [];
14795
+ const targets = existsSync5(manifest) ? swiftManifestTargets(readFileSync17(manifest, "utf8")) : [];
14448
14796
  let dependencyOverlays;
14449
14797
  const compiled = compiledSwiftSources(origins, targets, () => {
14450
14798
  if (dependencyOverlays) return dependencyOverlays;
@@ -14462,7 +14810,7 @@ function prepareSwiftDependency(source, destination, overlayFrameworks) {
14462
14810
  return dependencyOverlays;
14463
14811
  });
14464
14812
  const copy = (from, to) => {
14465
- mkdirSync6(to, { recursive: true });
14813
+ mkdirSync7(to, { recursive: true });
14466
14814
  for (const entry of readdirSync8(from, { withFileTypes: true })) {
14467
14815
  if (entry.name === ".git" || entry.name === ".build" || entry.name === ".swiftpm")
14468
14816
  continue;
@@ -14470,7 +14818,7 @@ function prepareSwiftDependency(source, destination, overlayFrameworks) {
14470
14818
  const target = path27.join(to, entry.name);
14471
14819
  if (entry.isDirectory()) copy(file, target);
14472
14820
  else if (entry.isFile() && entry.name.endsWith(".swift"))
14473
- writeFileSync7(target, compiled.get(path27.relative(source, file)));
14821
+ writeFileSync8(target, compiled.get(path27.relative(source, file)));
14474
14822
  else cpSync(file, target, { verbatimSymlinks: true });
14475
14823
  }
14476
14824
  };
@@ -14502,7 +14850,7 @@ function clangImportModuleMapFlags(settings, layoutRoot, written, generated) {
14502
14850
  return [`-fmodule-map-file=${published}`];
14503
14851
  const cached = written.get(headers);
14504
14852
  if (cached) return [cached];
14505
- mkdirSync6(directory, { recursive: true });
14853
+ mkdirSync7(directory, { recursive: true });
14506
14854
  const output = path27.join(directory, `module-${written.size}.modulemap`);
14507
14855
  writeBuildFile(
14508
14856
  output,
@@ -14630,12 +14978,12 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
14630
14978
  if (existsSync5(headerDirectory)) {
14631
14979
  for (const entry of readdirSync8(headerDirectory, { withFileTypes: true }))
14632
14980
  if (entry.isDirectory() && !targets.some((target) => target.name === entry.name))
14633
- rmSync6(path27.join(headerDirectory, entry.name), { recursive: true, force: true });
14981
+ rmSync7(path27.join(headerDirectory, entry.name), { recursive: true, force: true });
14634
14982
  }
14635
14983
  let checkedToolchain;
14636
14984
  const nativeToolchain = () => {
14637
14985
  if (checkedToolchain) return checkedToolchain;
14638
- const pin = distribution ?? JSON.parse(readFileSync16(path27.join(moduleRoot, "toolchain.json"), "utf8"));
14986
+ const pin = distribution ?? JSON.parse(readFileSync17(path27.join(moduleRoot, "toolchain.json"), "utf8"));
14639
14987
  checkedToolchain = swiftToolchain(pin.release, swiftModuleSdk(moduleRoot));
14640
14988
  return checkedToolchain;
14641
14989
  };
@@ -15056,7 +15404,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
15056
15404
  const origin = settings?.sourceDirectories[file];
15057
15405
  if (origin) {
15058
15406
  const original = path27.join(layout2.root, origin, path27.posix.basename(file));
15059
- mkdirSync6(path27.dirname(original), { recursive: true });
15407
+ mkdirSync7(path27.dirname(original), { recursive: true });
15060
15408
  stageTargetFile(target.name, original, contents, { allowExisting: true });
15061
15409
  }
15062
15410
  const source = unitSource(file);
@@ -15294,7 +15642,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
15294
15642
  `extern module ${map.module} ${JSON.stringify(map.published)}
15295
15643
  `
15296
15644
  );
15297
- if (native.size > 0) mkdirSync6(headerDirectory, { recursive: true });
15645
+ if (native.size > 0) mkdirSync7(headerDirectory, { recursive: true });
15298
15646
  const headerAliasFlags = Object.keys(input.headerAliases ?? {}).length > 0 ? ["-ivfsoverlay", headerSearch.files[0]] : [];
15299
15647
  const nativeHeaderFlags = [...headerAliasFlags];
15300
15648
  const nativeSwiftHeaderMaps = /* @__PURE__ */ new Map();
@@ -15360,7 +15708,7 @@ module ${moduleName}.Swift {
15360
15708
  swiftModuleInputFiles(moduleRoot).join("\n")
15361
15709
  );
15362
15710
  if (!distribution) {
15363
- modulePlan.update(readFileSync16(path27.join(moduleRoot, "Package.swift")));
15711
+ modulePlan.update(readFileSync17(path27.join(moduleRoot, "Package.swift")));
15364
15712
  }
15365
15713
  modulePlan.update(
15366
15714
  Object.keys(input.files).filter((file) => file.endsWith(".swift")).sort().join("\n")
@@ -15569,7 +15917,7 @@ module ${moduleName}.Swift {
15569
15917
  if (file === "Package.swift") continue;
15570
15918
  files.set(path27.join(layout2.sources, file), compiled.get(file) ?? contents);
15571
15919
  }
15572
- let manifest = readFileSync16(
15920
+ let manifest = readFileSync17(
15573
15921
  path27.join(moduleRoot, "scripts/contrast-app-Package.swift"),
15574
15922
  "utf8"
15575
15923
  ).replaceAll("__SOOTSIM_SWIFT_PACKAGE__", moduleRoot);
@@ -15756,8 +16104,15 @@ module ${moduleName}.Swift {
15756
16104
  }) + moduleFiles
15757
16105
  );
15758
16106
  }
15759
- for (const [file, bytes] of Object.entries(input.packageFiles ?? {}))
15760
- files.set(path27.join(layout2.root, file), Buffer.from(bytes, "base64"));
16107
+ for (const [file, bytes] of Object.entries(input.packageFiles ?? {})) {
16108
+ const contents = Buffer.from(bytes, "base64");
16109
+ files.set(
16110
+ path27.join(layout2.root, file),
16111
+ file.endsWith(".swift") && !/(?:^|\/)Package(?:@swift-[\d.]+)?\.swift$/.test(file) ? withPreconcurrencyFoundationModules(
16112
+ swiftPackageSourceAsIOS(contents.toString("utf8"))
16113
+ ) : contents
16114
+ );
16115
+ }
15761
16116
  for (const [file, bytes] of Object.entries(input.projectFiles ?? {})) {
15762
16117
  const destination = path27.join(layout2.root, file);
15763
16118
  if (files.has(destination)) continue;
@@ -15774,14 +16129,36 @@ module ${moduleName}.Swift {
15774
16129
  )
15775
16130
  ] : []
15776
16131
  ];
16132
+ const clangWrapper2 = path27.join(layout2.root, CLANG_TARGET_MODULE_WRAPPER);
16133
+ files.set(
16134
+ clangWrapper2,
16135
+ [
16136
+ "#!/bin/sh",
16137
+ "name=",
16138
+ "prev=",
16139
+ 'for arg in "$@"; do',
16140
+ ' if [ "$prev" = -o ]; then name=${arg%/*}; name=${name##*/}; fi',
16141
+ " prev=$arg",
16142
+ "done",
16143
+ "case $name in",
16144
+ ` *.build) exec '${path27.join(nativeToolchain(), "clang")}' "-fmodule-name=\${name%.build}" "$@" ;;`,
16145
+ ` *) exec '${path27.join(nativeToolchain(), "clang")}' "$@" ;;`,
16146
+ "esac",
16147
+ ""
16148
+ ].join("\n")
16149
+ );
15777
16150
  files.set(
15778
16151
  path27.join(layout2.root, ".peach-target-toolset.json"),
15779
16152
  JSON.stringify({
15780
16153
  schemaVersion: "1.0",
15781
- ...nativeToolsetFlags.length > 0 ? {
15782
- cCompiler: { extraCLIOptions: nativeToolsetFlags },
15783
- cxxCompiler: { extraCLIOptions: nativeToolsetFlags }
15784
- } : {},
16154
+ cCompiler: {
16155
+ extraCLIOptions: [
16156
+ ...nativeToolsetFlags,
16157
+ "-fmodules",
16158
+ `-fmodules-cache-path=${path27.join(layout2.root, ".build", "ModuleCache")}`
16159
+ ]
16160
+ },
16161
+ ...nativeToolsetFlags.length > 0 ? { cxxCompiler: { extraCLIOptions: nativeToolsetFlags } } : {},
15785
16162
  swiftCompiler: {
15786
16163
  extraCLIOptions: [
15787
16164
  ...headerAliasFlags.flatMap((flag) => ["-Xcc", flag]),
@@ -15862,9 +16239,11 @@ module ${moduleName}.Swift {
15862
16239
  "// dependency targets emit their native compatibility headers.\n"
15863
16240
  );
15864
16241
  syncSwiftTree(layout2.root, files);
16242
+ const clangWrapper = path27.join(layout2.root, CLANG_TARGET_MODULE_WRAPPER);
16243
+ if (files.has(clangWrapper)) chmodSync2(clangWrapper, 493);
15865
16244
  const dependencies = new Map(
15866
16245
  swiftManifestTargets(
15867
- readFileSync16(path27.join(layout2.root, "Package.swift"), "utf8")
16246
+ readFileSync17(path27.join(layout2.root, "Package.swift"), "utf8")
15868
16247
  ).map((target) => [
15869
16248
  target.name,
15870
16249
  (target.dependencies ?? []).flatMap(
@@ -15919,7 +16298,7 @@ function outputOf(error) {
15919
16298
  }
15920
16299
  function builtArtifact(layout2) {
15921
16300
  const binDir = path27.join(layout2.root, ".build", WASM_TRIPLE, "release");
15922
- const manifest = readFileSync16(path27.join(layout2.root, "Package.swift"), "utf8");
16301
+ const manifest = readFileSync17(path27.join(layout2.root, "Package.swift"), "utf8");
15923
16302
  const executable = swiftManifestTargets(manifest).find((target) => target.executable);
15924
16303
  if (executable === void 0) {
15925
16304
  throw new Error("swift-compile: the written manifest names no executable target");
@@ -15964,12 +16343,12 @@ function serialize(root, work, signal) {
15964
16343
  function readCompiledArtifact(directory, hash) {
15965
16344
  try {
15966
16345
  const receipt = JSON.parse(
15967
- readFileSync16(path27.join(directory, "artifact.json"), "utf8")
16346
+ readFileSync17(path27.join(directory, "artifact.json"), "utf8")
15968
16347
  );
15969
16348
  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")
15970
16349
  return null;
15971
- const bytes = readFileSync16(path27.join(directory, "app.wasm"));
15972
- const gzip2 = readFileSync16(path27.join(directory, "icu.gz"));
16350
+ const bytes = readFileSync17(path27.join(directory, "app.wasm"));
16351
+ const gzip2 = readFileSync17(path27.join(directory, "icu.gz"));
15973
16352
  if (createHash13("sha256").update(bytes).digest("hex") !== receipt.wasm || createHash13("sha256").update(gzip2).digest("hex") !== receipt.icu || bytes.length <= 8 || bytes.readUInt32LE(0) !== 1836278016 || bytes.readUInt32LE(4) !== 1)
15974
16353
  return null;
15975
16354
  return { hash, bytes, icu: { sha256: receipt.icu, gzip: gzip2 } };
@@ -15981,12 +16360,12 @@ function readCompiledArtifact(directory, hash) {
15981
16360
  }
15982
16361
  function saveCompiledArtifact(root, artifact) {
15983
16362
  const directory = path27.join(root, "artifact");
15984
- mkdirSync6(directory, { recursive: true });
16363
+ mkdirSync7(directory, { recursive: true });
15985
16364
  const pending = mkdtempSync3(path27.join(root, ".artifact-"));
15986
16365
  try {
15987
- writeFileSync7(path27.join(pending, "app.wasm"), artifact.bytes);
15988
- writeFileSync7(path27.join(pending, "icu.gz"), artifact.icu.gzip);
15989
- writeFileSync7(
16366
+ writeFileSync8(path27.join(pending, "app.wasm"), artifact.bytes);
16367
+ writeFileSync8(path27.join(pending, "icu.gz"), artifact.icu.gzip);
16368
+ writeFileSync8(
15990
16369
  path27.join(pending, "artifact.json"),
15991
16370
  JSON.stringify({
15992
16371
  hash: artifact.hash,
@@ -15998,7 +16377,7 @@ function saveCompiledArtifact(root, artifact) {
15998
16377
  renameSync2(path27.join(pending, file), path27.join(directory, file));
15999
16378
  }
16000
16379
  } finally {
16001
- rmSync6(pending, { recursive: true, force: true });
16380
+ rmSync7(pending, { recursive: true, force: true });
16002
16381
  }
16003
16382
  }
16004
16383
  var SHARED_ARTIFACT_BUDGET_BYTES = 4 * 1024 ** 3;
@@ -16087,7 +16466,7 @@ function frameworkLibraryTargets(manifest) {
16087
16466
  }
16088
16467
  function linkedFrameworkTargets(moduleRoot, input) {
16089
16468
  const libraries = frameworkLibraryTargets(
16090
- readFileSync16(path27.join(moduleRoot, "Package.swift"), "utf8")
16469
+ readFileSync17(path27.join(moduleRoot, "Package.swift"), "utf8")
16091
16470
  );
16092
16471
  const targets = compileTargets(input);
16093
16472
  const planning = targets.length > 0 ? targets : [{ name: "App", path: "." }];
@@ -16110,7 +16489,7 @@ function linkedFrameworkTargets(moduleRoot, input) {
16110
16489
  for (const name2 of [...siblings.values()].flat())
16111
16490
  if (libraries.has(name2) && !planning.some((target) => target.name === name2))
16112
16491
  reach(name2);
16113
- const manifest = readFileSync16(path27.join(moduleRoot, "Package.swift"), "utf8");
16492
+ const manifest = readFileSync17(path27.join(moduleRoot, "Package.swift"), "utf8");
16114
16493
  const targetDependencies = /* @__PURE__ */ new Map();
16115
16494
  for (const match of manifest.matchAll(
16116
16495
  /\.target\(\s*name:\s*"([^"]+)"\s*,\s*dependencies:\s*\[([^\]]*)\]/g
@@ -16132,7 +16511,7 @@ function linkedFrameworkTargets(moduleRoot, input) {
16132
16511
  const companion = path27.basename(directory, ".swiftcrossimport");
16133
16512
  if (!built.has(companion)) continue;
16134
16513
  const declaration = path27.join(overlays, directory, "SwiftUI.swiftoverlay");
16135
- for (const match of readFileSync16(declaration, "utf8").matchAll(
16514
+ for (const match of readFileSync17(declaration, "utf8").matchAll(
16136
16515
  /^\s*- name: ([A-Za-z_]\w*)\s*$/gm
16137
16516
  ))
16138
16517
  reach(match[1]);
@@ -16181,12 +16560,12 @@ ${dependencies}
16181
16560
  )
16182
16561
  `;
16183
16562
  const sourceDir = path27.join(linkRoot, "Sources", FRAMEWORK_LINK_TARGET);
16184
- mkdirSync6(sourceDir, { recursive: true });
16563
+ mkdirSync7(sourceDir, { recursive: true });
16185
16564
  const manifestPath = path27.join(linkRoot, "Package.swift");
16186
- if (!existsSync5(manifestPath) || readFileSync16(manifestPath, "utf8") !== manifest)
16187
- writeFileSync7(manifestPath, manifest);
16565
+ if (!existsSync5(manifestPath) || readFileSync17(manifestPath, "utf8") !== manifest)
16566
+ writeFileSync8(manifestPath, manifest);
16188
16567
  const source = path27.join(sourceDir, "Link.swift");
16189
- if (!existsSync5(source)) writeFileSync7(source, "");
16568
+ if (!existsSync5(source)) writeFileSync8(source, "");
16190
16569
  }
16191
16570
  function frameworkLinkClosure(scratch2, roots) {
16192
16571
  const suffix = `${WASM_TRIPLE}-release`;
@@ -16197,7 +16576,7 @@ function frameworkLinkClosure(scratch2, roots) {
16197
16576
  const moduleMaps = /* @__PURE__ */ new Map();
16198
16577
  let pending = null;
16199
16578
  let compiling = null;
16200
- for (const line of readFileSync16(path27.join(scratch2, "release.yaml"), "utf8").split(
16579
+ for (const line of readFileSync17(path27.join(scratch2, "release.yaml"), "utf8").split(
16201
16580
  "\n"
16202
16581
  )) {
16203
16582
  const phony = phonyHeader.exec(line);
@@ -16278,7 +16657,7 @@ function removeCaseCollidingModuleArtifacts(modulesDir, keep) {
16278
16657
  if (dot <= 0) continue;
16279
16658
  const module = name2.slice(0, dot);
16280
16659
  if (keep.has(module) || !folded.has(module.toLowerCase())) continue;
16281
- rmSync6(path27.join(modulesDir, name2), { recursive: true, force: true });
16660
+ rmSync7(path27.join(modulesDir, name2), { recursive: true, force: true });
16282
16661
  }
16283
16662
  }
16284
16663
  async function buildFrameworkProducts(scratch2, args) {
@@ -16308,6 +16687,9 @@ async function buildFrameworkProducts(scratch2, args) {
16308
16687
  "release",
16309
16688
  "-Xswiftc",
16310
16689
  "-Osize",
16690
+ // the release link strips all debug info, so none is generated
16691
+ "-Xswiftc",
16692
+ "-gnone",
16311
16693
  "-Xswiftc",
16312
16694
  "-num-threads",
16313
16695
  "-Xswiftc",
@@ -16345,9 +16727,9 @@ async function buildFrameworkProducts(scratch2, args) {
16345
16727
  const constantsDir = path27.join(scratch2, "uniform-type-constants");
16346
16728
  const constantsStamp = path27.join(constantsDir, ".complete");
16347
16729
  const object3 = path27.join(constantsDir, "UniformTypeIdentifiers-NativeConstants.o");
16348
- if (!existsSync5(constantsStamp) || readFileSync16(constantsStamp, "utf8") !== args.frameworkKey) {
16349
- rmSync6(constantsDir, { recursive: true, force: true });
16350
- mkdirSync6(constantsDir);
16730
+ if (!existsSync5(constantsStamp) || readFileSync17(constantsStamp, "utf8") !== args.frameworkKey) {
16731
+ rmSync7(constantsDir, { recursive: true, force: true });
16732
+ mkdirSync7(constantsDir);
16351
16733
  const sdkPaths2 = swiftSdkPaths(args.moduleRoot, args.toolchainBin);
16352
16734
  compileUniformTypeConstants({
16353
16735
  bin: args.toolchainBin,
@@ -16357,20 +16739,20 @@ async function buildFrameworkProducts(scratch2, args) {
16357
16739
  minimum: darwinRecordsMinimum(),
16358
16740
  out: constantsDir
16359
16741
  });
16360
- writeFileSync7(constantsStamp, args.frameworkKey);
16742
+ writeFileSync8(constantsStamp, args.frameworkKey);
16361
16743
  }
16362
16744
  objects.push(object3);
16363
16745
  linked.owners.set(object3, "UniformTypeIdentifiers");
16364
16746
  }
16365
16747
  removeCaseCollidingModuleArtifacts(path27.join(release, "Modules"), linked.modules);
16366
16748
  const response = path27.join(scratch2, "autolink-objects.rsp");
16367
- writeFileSync7(response, objects.map((file) => JSON.stringify(file)).join("\n") + "\n");
16749
+ writeFileSync8(response, objects.map((file) => JSON.stringify(file)).join("\n") + "\n");
16368
16750
  const extracted = await runCompiler(
16369
16751
  path27.join(args.toolchainBin, "swift-autolink-extract"),
16370
16752
  [`@${response}`, "-o", "-"],
16371
16753
  args.buildOptions
16372
16754
  );
16373
- rmSync6(response, { force: true });
16755
+ rmSync7(response, { force: true });
16374
16756
  const link = extracted.split("\n").map((line) => line.trim()).filter((flag, index, all) => flag.length > 0 && all.indexOf(flag) === index);
16375
16757
  if (link.includes("-lFoundation"))
16376
16758
  for (const name2 of foundationCategoryObjects) {
@@ -16383,9 +16765,9 @@ async function buildFrameworkProducts(scratch2, args) {
16383
16765
  }
16384
16766
  const providerDir = path27.join(scratch2, "darwin-records");
16385
16767
  const providerStamp = path27.join(providerDir, ".complete");
16386
- if (!existsSync5(providerStamp) || readFileSync16(providerStamp, "utf8") !== args.frameworkKey) {
16387
- rmSync6(providerDir, { recursive: true, force: true });
16388
- mkdirSync6(providerDir);
16768
+ if (!existsSync5(providerStamp) || readFileSync17(providerStamp, "utf8") !== args.frameworkKey) {
16769
+ rmSync7(providerDir, { recursive: true, force: true });
16770
+ mkdirSync7(providerDir);
16389
16771
  const sdkPaths2 = swiftSdkPaths(args.moduleRoot, args.toolchainBin);
16390
16772
  compileDarwinRecords({
16391
16773
  bin: args.toolchainBin,
@@ -16395,13 +16777,13 @@ async function buildFrameworkProducts(scratch2, args) {
16395
16777
  minimum: darwinRecordsMinimum(),
16396
16778
  out: providerDir
16397
16779
  });
16398
- writeFileSync7(providerStamp, args.frameworkKey);
16780
+ writeFileSync8(providerStamp, args.frameworkKey);
16399
16781
  }
16400
16782
  const providers = readdirSync8(providerDir).filter((file) => file.endsWith(".o")).sort().map((file) => path27.join(providerDir, file));
16401
16783
  for (const provider of providers) linked.owners.set(provider, "DarwinRecords");
16402
16784
  const archive = path27.join(scratch2, "lib");
16403
- rmSync6(archive, { recursive: true, force: true });
16404
- mkdirSync6(archive);
16785
+ rmSync7(archive, { recursive: true, force: true });
16786
+ mkdirSync7(archive);
16405
16787
  const archived = /* @__PURE__ */ new Map();
16406
16788
  for (const object3 of objects) {
16407
16789
  const target = linked.owners.get(object3);
@@ -16442,7 +16824,7 @@ function swiftFrameworkScratch(frameworkKey) {
16442
16824
  }
16443
16825
  function swiftFrameworkSlotRecord(slot, record) {
16444
16826
  try {
16445
- return readFileSync16(path27.join(slot, record), "utf8").trim();
16827
+ return readFileSync17(path27.join(slot, record), "utf8").trim();
16446
16828
  } catch (error) {
16447
16829
  if (!vanished(error)) throw error;
16448
16830
  return null;
@@ -16454,7 +16836,7 @@ function swiftFrameworkSlotKey(slot) {
16454
16836
  async function withSwiftFrameworkSlot(frameworkKey, moduleRoot, signal, work) {
16455
16837
  const slots = Array.from({ length: SWIFT_FRAMEWORK_SLOTS }, (_, index) => {
16456
16838
  const slot = path27.join(swiftFrameworksDir(), `slot-${index}`);
16457
- mkdirSync6(slot, { recursive: true });
16839
+ mkdirSync7(slot, { recursive: true });
16458
16840
  return slot;
16459
16841
  });
16460
16842
  const run2 = (slot) => (lease) => {
@@ -16487,7 +16869,7 @@ async function withSwiftFrameworkSlot(frameworkKey, moduleRoot, signal, work) {
16487
16869
  return withSwiftRootLock(oldest[0], run2(oldest[0]), signal);
16488
16870
  }
16489
16871
  function mirrorTree2(source, target, skip) {
16490
- mkdirSync6(target, { recursive: true });
16872
+ mkdirSync7(target, { recursive: true });
16491
16873
  const wanted = /* @__PURE__ */ new Set();
16492
16874
  let restructured = false;
16493
16875
  for (const entry of readdirSync8(source, { withFileTypes: true })) {
@@ -16503,18 +16885,18 @@ function mirrorTree2(source, target, skip) {
16503
16885
  }
16504
16886
  if (!existing) restructured = true;
16505
16887
  if (entry.isDirectory()) {
16506
- if (existing && !existing.isDirectory()) rmSync6(to, { force: true });
16888
+ if (existing && !existing.isDirectory()) rmSync7(to, { force: true });
16507
16889
  if (mirrorTree2(from, to)) restructured = true;
16508
16890
  } else if (entry.isSymbolicLink()) {
16509
16891
  const link = readlinkSync(from);
16510
16892
  if (existing?.isSymbolicLink() && readlinkSync(to) === link) continue;
16511
- if (existing) rmSync6(to, { recursive: true, force: true });
16893
+ if (existing) rmSync7(to, { recursive: true, force: true });
16512
16894
  symlinkSync2(link, to);
16513
16895
  } else {
16514
16896
  const stat = statSync2(from);
16515
- if (existing?.isFile() && existing.size === stat.size && (existing.mtimeMs === stat.mtimeMs || readFileSync16(from).equals(readFileSync16(to))))
16897
+ if (existing?.isFile() && existing.size === stat.size && (existing.mtimeMs === stat.mtimeMs || readFileSync17(from).equals(readFileSync17(to))))
16516
16898
  continue;
16517
- if (existing) rmSync6(to, { recursive: true, force: true });
16899
+ if (existing) rmSync7(to, { recursive: true, force: true });
16518
16900
  const partial = `${to}.${randomUUID5()}`;
16519
16901
  copyFileSync(from, partial);
16520
16902
  utimesSync(partial, stat.atime, stat.mtime);
@@ -16523,7 +16905,7 @@ function mirrorTree2(source, target, skip) {
16523
16905
  }
16524
16906
  for (const name2 of readdirSync8(target))
16525
16907
  if (!wanted.has(name2) && name2 !== skip) {
16526
- rmSync6(path27.join(target, name2), { recursive: true, force: true });
16908
+ rmSync7(path27.join(target, name2), { recursive: true, force: true });
16527
16909
  restructured = true;
16528
16910
  }
16529
16911
  return restructured;
@@ -16533,22 +16915,22 @@ function stageFrameworkSource(moduleRoot, slot, frameworkKey, release) {
16533
16915
  const staged = path27.join(slot, "source");
16534
16916
  const stagedModule = path27.join(staged, "packages", path27.basename(moduleRoot));
16535
16917
  if (swiftFrameworkSlotKey(slot) !== frameworkKey) {
16536
- rmSync6(path27.join(slot, SWIFT_FRAMEWORK_SLOT_KEY), { force: true });
16918
+ rmSync7(path27.join(slot, SWIFT_FRAMEWORK_SLOT_KEY), { force: true });
16537
16919
  const moduleRestructured = mirrorTree2(moduleRoot, stagedModule, ".build");
16538
16920
  const sdkRestructured = mirrorTree2(
16539
16921
  swiftSharedSdkRoot(moduleRoot, false),
16540
16922
  path27.join(staged, "packages/peachsim/sdk/ios")
16541
16923
  );
16542
16924
  if (moduleRestructured || sdkRestructured) {
16543
- rmSync6(path27.join(slot, "release.yaml"), { force: true });
16544
- rmSync6(path27.join(slot, "release", "description.json"), { force: true });
16925
+ rmSync7(path27.join(slot, "release.yaml"), { force: true });
16926
+ rmSync7(path27.join(slot, "release", "description.json"), { force: true });
16545
16927
  }
16546
16928
  for (const file of swiftModuleInputFiles(moduleRoot)) {
16547
16929
  if (!file.startsWith("../")) continue;
16548
16930
  const from = path27.resolve(moduleRoot, file);
16549
16931
  const to = path27.resolve(stagedModule, file);
16550
- if (existsSync5(to) && readFileSync16(from).equals(readFileSync16(to))) continue;
16551
- mkdirSync6(path27.dirname(to), { recursive: true });
16932
+ if (existsSync5(to) && readFileSync17(from).equals(readFileSync17(to))) continue;
16933
+ mkdirSync7(path27.dirname(to), { recursive: true });
16552
16934
  copyFileSync(from, to);
16553
16935
  }
16554
16936
  if (swiftProjectBuildKey(stagedModule, release) !== frameworkKey)
@@ -16556,11 +16938,11 @@ function stageFrameworkSource(moduleRoot, slot, frameworkKey, release) {
16556
16938
  const modules = path27.join(staged, "node_modules");
16557
16939
  const target = realpathSync5(path27.join(moduleRoot, "../../node_modules"));
16558
16940
  if (!existsSync5(modules) || readlinkSync(modules) !== target) {
16559
- rmSync6(modules, { recursive: true, force: true });
16941
+ rmSync7(modules, { recursive: true, force: true });
16560
16942
  symlinkSync2(target, modules);
16561
16943
  }
16562
- writeFileSync7(path27.join(slot, SWIFT_FRAMEWORK_SLOT_KEY), frameworkKey);
16563
- writeFileSync7(path27.join(slot, SWIFT_FRAMEWORK_SLOT_ORIGIN), moduleRoot);
16944
+ writeFileSync8(path27.join(slot, SWIFT_FRAMEWORK_SLOT_KEY), frameworkKey);
16945
+ writeFileSync8(path27.join(slot, SWIFT_FRAMEWORK_SLOT_ORIGIN), moduleRoot);
16564
16946
  }
16565
16947
  return stagedModule;
16566
16948
  }
@@ -16605,15 +16987,15 @@ function retireStaleSwiftLink(root, stamp) {
16605
16987
  const receipt = path27.join(root, SWIFT_LINK_STAMP);
16606
16988
  let previous = null;
16607
16989
  try {
16608
- previous = readFileSync16(receipt, "utf8").trim();
16990
+ previous = readFileSync17(receipt, "utf8").trim();
16609
16991
  } catch (error) {
16610
16992
  if (!vanished(error)) throw error;
16611
16993
  }
16612
- writeFileSync7(receipt, `${stamp}
16994
+ writeFileSync8(receipt, `${stamp}
16613
16995
  `);
16614
16996
  const retired = path27.join(root, ".build");
16615
16997
  if (previous === stamp || !existsSync5(retired)) return false;
16616
- rmSync6(retired, { recursive: true, force: true });
16998
+ rmSync7(retired, { recursive: true, force: true });
16617
16999
  return true;
16618
17000
  }
16619
17001
  async function compileSwiftProjectUnit(input, options) {
@@ -16628,7 +17010,7 @@ async function compileSwiftProjectUnit(input, options) {
16628
17010
  }
16629
17011
  function compileSwiftProjectOnce(input, options) {
16630
17012
  options.signal?.throwIfAborted();
16631
- mkdirSync6(options.buildRoot, { recursive: true });
17013
+ mkdirSync7(options.buildRoot, { recursive: true });
16632
17014
  const root = realpathSync5(options.buildRoot);
16633
17015
  const moduleRoot = path27.resolve(options.moduleRoot);
16634
17016
  const distribution = swiftDistributionAt(moduleRoot);
@@ -16667,7 +17049,7 @@ function compileSwiftProjectOnce(input, options) {
16667
17049
  const requestRoot = mkdtempSync3(`${root}.builder-request-`);
16668
17050
  const output = path27.join(requestRoot, "output");
16669
17051
  const request = path27.join(requestRoot, "request.json");
16670
- writeFileSync7(
17052
+ writeFileSync8(
16671
17053
  request,
16672
17054
  JSON.stringify({
16673
17055
  input,
@@ -16713,7 +17095,7 @@ function compileSwiftProjectOnce(input, options) {
16713
17095
  report("builder artifact verified");
16714
17096
  return retain(root, artifact);
16715
17097
  } finally {
16716
- rmSync6(requestRoot, { recursive: true, force: true });
17098
+ rmSync7(requestRoot, { recursive: true, force: true });
16717
17099
  }
16718
17100
  }
16719
17101
  return withSwiftRootLock(
@@ -16803,17 +17185,18 @@ function compileSwiftProjectOnce(input, options) {
16803
17185
  existsSync5(productFile) ? [
16804
17186
  v5.parse(
16805
17187
  swiftFrameworkProductSchema,
16806
- JSON.parse(readFileSync16(productFile, "utf8"))
17188
+ JSON.parse(readFileSync17(productFile, "utf8"))
16807
17189
  ).product.name
16808
17190
  ] : []
16809
17191
  );
16810
17192
  const projectProcess = options.project ? prepareSwiftProjectProcess(root, options.project) : void 0;
17193
+ const compiler = preparation.targetToolset ? { CC: path27.join(root, CLANG_TARGET_MODULE_WRAPPER) } : {};
16811
17194
  const appOptions = projectProcess ? {
16812
17195
  ...buildOptions,
16813
17196
  uid: projectProcess.uid,
16814
17197
  gid: projectProcess.gid,
16815
- confined: projectProcess.env
16816
- } : buildOptions;
17198
+ confined: { ...projectProcess.env, ...compiler }
17199
+ } : { ...buildOptions, env: { ...buildOptions.env, ...compiler } };
16817
17200
  const unprepared = preparation.targetFailures.map(
16818
17201
  (failure) => `error: target ${failure}`
16819
17202
  );
@@ -16843,6 +17226,9 @@ function compileSwiftProjectOnce(input, options) {
16843
17226
  ...preparation.targetToolset ? ["--toolset", path27.join(root, ".peach-target-toolset.json")] : [],
16844
17227
  "-c",
16845
17228
  "release",
17229
+ // the link strips debug info, so none is generated (as for the framework)
17230
+ "-Xswiftc",
17231
+ "-gnone",
16846
17232
  "-Xswiftc",
16847
17233
  "-num-threads",
16848
17234
  "-Xswiftc",
@@ -16872,10 +17258,55 @@ function compileSwiftProjectOnce(input, options) {
16872
17258
  ])
16873
17259
  ];
16874
17260
  const linked = builtArtifact(layout2);
16875
- rmSync6(path27.join(root, ".peach-link.rsp"), { force: true });
17261
+ rmSync7(path27.join(root, ".peach-link.rsp"), { force: true });
16876
17262
  if (existsSync5(linked) && statSync2(linked).size <= 8)
16877
- rmSync6(linked, { force: true });
17263
+ rmSync7(linked, { force: true });
16878
17264
  report("compiling and linking Swift modules");
17265
+ const frameworkInterfaces = /* @__PURE__ */ new Map();
17266
+ const frameworkInterface = (name2) => {
17267
+ if (frameworkInterfaces.has(name2)) return frameworkInterfaces.get(name2);
17268
+ const source = distribution ? path27.join(frameworkRoot, "modules", `${name2}-Swift.h`) : path27.join(
17269
+ prebuilt.modules,
17270
+ "..",
17271
+ `${name2}.build/include/${name2}-Swift.h`
17272
+ );
17273
+ if (!existsSync5(source)) {
17274
+ frameworkInterfaces.set(name2, null);
17275
+ return null;
17276
+ }
17277
+ const headers = path27.join(
17278
+ swiftSdkPaths(frameworkRoot, options.toolchainBin).darwin,
17279
+ `System/Library/Frameworks/${name2}.framework/Headers`
17280
+ );
17281
+ const declared = /* @__PURE__ */ new Set();
17282
+ if (existsSync5(headers)) {
17283
+ for (const file of readdirSync8(headers, {
17284
+ recursive: true,
17285
+ encoding: "utf8"
17286
+ }))
17287
+ if (file.endsWith(".h"))
17288
+ for (const name3 of swiftInterfaceDeclarations(
17289
+ readFileSync17(path27.join(headers, file), "utf8")
17290
+ ))
17291
+ declared.add(name3);
17292
+ }
17293
+ const header = withoutSwiftDeclarations(
17294
+ clangInterfaceHeader(readFileSync17(source, "utf8")),
17295
+ declared,
17296
+ `#import <${name2}/${name2}.h>`
17297
+ );
17298
+ const value = {
17299
+ file: path27.join(root, ".build/peach-framework-objc", `${name2}-Swift.h`),
17300
+ header
17301
+ };
17302
+ frameworkInterfaces.set(name2, value);
17303
+ writeBuildFile(
17304
+ value.file,
17305
+ (existsSync5(path27.join(headers, `${name2}.h`)) ? `#import <${name2}/${name2}.h>
17306
+ ` : "") + swiftHeaderWithSuperclassImports(header, frameworkInterface)
17307
+ );
17308
+ return value;
17309
+ };
16879
17310
  try {
16880
17311
  const headerBuilds = preparation.headerProductTarget ? [
16881
17312
  ...Object.keys(preparation.nativeHeaderDeclarations),
@@ -16903,7 +17334,10 @@ function compileSwiftProjectOnce(input, options) {
16903
17334
  writeBuildFile(
16904
17335
  emitted,
16905
17336
  withoutSwiftDeclarations(
16906
- clangInterfaceHeader(readFileSync16(original, "utf8")),
17337
+ swiftHeaderWithSuperclassImports(
17338
+ clangInterfaceHeader(readFileSync17(original, "utf8")),
17339
+ frameworkInterface
17340
+ ),
16907
17341
  new Set(preparation.nativeHeaderDeclarations[producer]),
16908
17342
  `#import <${producer}/${producer}.h>`
16909
17343
  )
@@ -16914,9 +17348,9 @@ function compileSwiftProjectOnce(input, options) {
16914
17348
  root,
16915
17349
  ".build",
16916
17350
  "peach-native-targets",
16917
- createHash13("sha256").update(readFileSync16(path27.join(root, "Package.swift"))).digest("hex")
17351
+ createHash13("sha256").update(readFileSync17(path27.join(root, "Package.swift"))).digest("hex")
16918
17352
  );
16919
- mkdirSync6(checkpoints, { recursive: true });
17353
+ mkdirSync7(checkpoints, { recursive: true });
16920
17354
  for (const target of /* @__PURE__ */ new Set([
16921
17355
  ...input.staticClangTargets ?? [],
16922
17356
  ...preparation.nativeBuildTargets
@@ -16933,7 +17367,7 @@ function compileSwiftProjectOnce(input, options) {
16933
17367
  SWIFTPM_PROGRESS,
16934
17368
  SWIFTPM_NOISE
16935
17369
  );
16936
- writeFileSync7(checkpoint, "");
17370
+ writeFileSync8(checkpoint, "");
16937
17371
  }
16938
17372
  await runCompiler(
16939
17373
  swift,
@@ -16952,7 +17386,7 @@ function compileSwiftProjectOnce(input, options) {
16952
17386
  "ModuleCache"
16953
17387
  );
16954
17388
  if (output2.includes("was compiled with module cache path") && existsSync5(moduleCache)) {
16955
- rmSync6(moduleCache, { recursive: true, force: true });
17389
+ rmSync7(moduleCache, { recursive: true, force: true });
16956
17390
  try {
16957
17391
  await runCompiler(
16958
17392
  swift,
@@ -17020,16 +17454,15 @@ function compileSwiftProjectOnce(input, options) {
17020
17454
  output,
17021
17455
  optimized
17022
17456
  });
17023
- else if (input.optimize) await optimizeWasm(output, optimized);
17024
- const executable = input.optimize ? optimized : output;
17457
+ else await lowerWasm(output, optimized, { optimize: input.optimize === true });
17025
17458
  await runCompiler(
17026
17459
  path27.join(options.toolchainBin, "llvm-objcopy"),
17027
- ["--remove-section=.swift1_autolink_entries", executable],
17460
+ ["--remove-section=.swift1_autolink_entries", optimized],
17028
17461
  buildOptions
17029
17462
  );
17030
17463
  const artifact = {
17031
17464
  hash,
17032
- bytes: readFileSync16(executable),
17465
+ bytes: readFileSync17(optimized),
17033
17466
  icu: await icu
17034
17467
  };
17035
17468
  if (artifact.bytes.length <= 8)
@@ -17079,6 +17512,7 @@ export {
17079
17512
  swiftCompileSdkOptions,
17080
17513
  swiftCrossImportFlags,
17081
17514
  swiftDistributionAt,
17515
+ swiftHeaderWithSuperclassImports,
17082
17516
  swiftIcuAddress,
17083
17517
  swiftIcuAsset,
17084
17518
  swiftIcuBundleAsset,
@@ -17103,6 +17537,7 @@ export {
17103
17537
  swiftTypedApplicationEntry,
17104
17538
  syncSwiftTree,
17105
17539
  withNativeSourceGlue,
17540
+ withPreconcurrencyFoundationModules,
17106
17541
  withoutSwiftDeclarations,
17107
17542
  wrapUIApplicationMainEntry,
17108
17543
  writeSwiftProject