peachsim 0.1.2591 → 0.1.2593

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 (149) hide show
  1. package/dist-lib/agent-daemon-client.cjs +1 -1
  2. package/dist-lib/agent-events.cjs +1 -1
  3. package/dist-lib/attached-projects.cjs +1 -1
  4. package/dist-lib/auth/shared-session.cjs +1 -1
  5. package/dist-lib/backend-origin.cjs +1 -1
  6. package/dist-lib/beta.cjs +1 -1
  7. package/dist-lib/beta.mjs +2 -2
  8. package/dist-lib/bridge-constants.cjs +1 -1
  9. package/dist-lib/bridge-contract-input.cjs +1 -1
  10. package/dist-lib/bridge-contract-input.mjs +5 -5
  11. package/dist-lib/bridge-contract.cjs +1 -1
  12. package/dist-lib/bridge-contract.mjs +3 -3
  13. package/dist-lib/bundle-channel.cjs +5684 -5254
  14. package/dist-lib/capture-contract.cjs +1 -1
  15. package/dist-lib/capture-contract.mjs +3 -3
  16. package/dist-lib/cloud-contract.cjs +1 -1
  17. package/dist-lib/cloud-contract.mjs +3 -3
  18. package/dist-lib/cloud-test-args.cjs +1 -1
  19. package/dist-lib/cloud-test-args.mjs +2 -2
  20. package/dist-lib/cloud.cjs +1 -1
  21. package/dist-lib/cloud.mjs +7 -7
  22. package/dist-lib/config.cjs +1 -1
  23. package/dist-lib/config.mjs +5 -5
  24. package/dist-lib/detox/index.cjs +2 -2
  25. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  26. package/dist-lib/esm-chunks/{acorn-EMX4WZ72.mjs → acorn-DLENU3SM.mjs} +3 -3
  27. package/dist-lib/esm-chunks/{chunk-VYZ5DC3M.mjs → chunk-23D4W2EY.mjs} +1015 -703
  28. package/dist-lib/esm-chunks/{chunk-MC6NMYWY.mjs → chunk-2MWUVSRW.mjs} +1 -1
  29. package/dist-lib/esm-chunks/{chunk-UIVXVMS5.mjs → chunk-2UERF2EN.mjs} +2 -2
  30. package/dist-lib/esm-chunks/{chunk-VRVXRZI4.mjs → chunk-4YJJKKKF.mjs} +112 -58
  31. package/dist-lib/esm-chunks/{chunk-AKKHSVJ4.mjs → chunk-6O2M4J2Y.mjs} +1 -1
  32. package/dist-lib/esm-chunks/{chunk-EGKH2L6J.mjs → chunk-BMKI4WBL.mjs} +1 -1
  33. package/dist-lib/esm-chunks/{chunk-4QHHRGO4.mjs → chunk-DLSPHUHQ.mjs} +1 -1
  34. package/dist-lib/esm-chunks/{chunk-UYJXLDCG.mjs → chunk-E6OGMX3T.mjs} +1 -1
  35. package/dist-lib/esm-chunks/{chunk-VF5WVB3D.mjs → chunk-GFMQ5PNX.mjs} +1 -1
  36. package/dist-lib/esm-chunks/{chunk-JHXDM3YU.mjs → chunk-IT4CC3HU.mjs} +1 -1
  37. package/dist-lib/esm-chunks/{chunk-J676B57D.mjs → chunk-JPNUGMLE.mjs} +5 -5
  38. package/dist-lib/esm-chunks/{chunk-RKQZGWX2.mjs → chunk-KWMJUJJS.mjs} +1 -1
  39. package/dist-lib/esm-chunks/{chunk-QBMFX3J2.mjs → chunk-LK3KQ4X3.mjs} +1 -1
  40. package/dist-lib/esm-chunks/{chunk-ZL5N6ENT.mjs → chunk-LN7ZTBNS.mjs} +1 -1
  41. package/dist-lib/esm-chunks/{chunk-Q4NA6PUR.mjs → chunk-NIYJBFXV.mjs} +3 -3
  42. package/dist-lib/esm-chunks/{chunk-7627LKJK.mjs → chunk-OIHSBING.mjs} +1 -1
  43. package/dist-lib/esm-chunks/{chunk-YR6DNV76.mjs → chunk-P3A4MQHR.mjs} +1 -1
  44. package/dist-lib/esm-chunks/{chunk-VD27WNCT.mjs → chunk-TXBZEHNH.mjs} +4 -4
  45. package/dist-lib/esm-chunks/{chunk-TFG4LZ5T.mjs → chunk-UM4DCXPA.mjs} +1 -1
  46. package/dist-lib/esm-chunks/{chunk-ILWFGZWW.mjs → chunk-UZPLSN2V.mjs} +107 -6
  47. package/dist-lib/esm-chunks/{chunk-SOAYP72T.mjs → chunk-XFFPOSW2.mjs} +1 -1
  48. package/dist-lib/esm-chunks/{chunk-NX23AMX4.mjs → chunk-ZT5ZXQC2.mjs} +1 -1
  49. package/dist-lib/esm-chunks/{metro-layout-parser-ANKZARNW.mjs → metro-layout-parser-DHGC2DVE.mjs} +3 -3
  50. package/dist-lib/esm-chunks/{swift-package-prebuilt-4N5CXBOZ.mjs → swift-package-prebuilt-ROIDLGLU.mjs} +10 -10
  51. package/dist-lib/esm-chunks/{swift-sdk-app-module-5IUSRXYA.mjs → swift-sdk-app-module-5VU63S56.mjs} +30 -20
  52. package/dist-lib/esm-chunks/{swift-sdk-image-7T2LMQS5.mjs → swift-sdk-image-SNFZVUQ3.mjs} +14 -14
  53. package/dist-lib/esm-chunks/{swift-sdk-image-producer-7QJ3BF6E.mjs → swift-sdk-image-producer-5RQDIX53.mjs} +4 -4
  54. package/dist-lib/expo-swift-bundle.cjs +3561 -3134
  55. package/dist-lib/expo-swift-metadata.cjs +1 -1
  56. package/dist-lib/expo-swift-metadata.mjs +7 -7
  57. package/dist-lib/home-paths.cjs +1 -1
  58. package/dist-lib/host/bridge-host.cjs +6082 -5142
  59. package/dist-lib/host/fetch-proxy-handler.cjs +314 -301
  60. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  61. package/dist-lib/host/fetch-proxy-overrides.mjs +2 -2
  62. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  63. package/dist-lib/host/websocket-proxy.cjs +1 -1
  64. package/dist-lib/index.cjs +1 -1
  65. package/dist-lib/kotlin-host.cjs +1 -1
  66. package/dist-lib/menu.cjs +1 -1
  67. package/dist-lib/menu.mjs +3 -3
  68. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  69. package/dist-lib/metro-fingerprint-registry.mjs +3 -3
  70. package/dist-lib/metro-production-bundle.cjs +1 -1
  71. package/dist-lib/metro-production-bundle.mjs +4 -4
  72. package/dist-lib/native-app-identity-project.cjs +241 -226
  73. package/dist-lib/native-app-identity-project.mjs +17 -17
  74. package/dist-lib/native-app-identity.cjs +1 -1
  75. package/dist-lib/native-app-identity.mjs +6 -6
  76. package/dist-lib/native-firebase-metadata.cjs +1 -1
  77. package/dist-lib/native-firebase-metadata.mjs +3 -3
  78. package/dist-lib/pdfium-raster.cjs +1 -1
  79. package/dist-lib/pdfium-raster.mjs +2 -2
  80. package/dist-lib/plist.cjs +1 -1
  81. package/dist-lib/plist.mjs +3 -3
  82. package/dist-lib/profiles.cjs +1 -1
  83. package/dist-lib/public-brand.cjs +1 -1
  84. package/dist-lib/public-origins-lib-esm.json +81 -81
  85. package/dist-lib/public-origins-lib.json +75 -73
  86. package/dist-lib/react-native-host-modules.cjs +1 -1
  87. package/dist-lib/react-native-host-modules.mjs +2 -2
  88. package/dist-lib/reap-browser.cjs +1 -1
  89. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  90. package/dist-lib/sdk.cjs +1 -1
  91. package/dist-lib/sdk.mjs +8 -8
  92. package/dist-lib/skills.cjs +6704 -5764
  93. package/dist-lib/swift-compile.cjs +1333 -922
  94. package/dist-lib/swift-compile.mjs +10 -10
  95. package/dist-lib/swift-package.cjs +1 -1
  96. package/dist-lib/swift-package.mjs +3 -3
  97. package/dist-lib/swift-submit.cjs +1 -1
  98. package/dist-lib/swift-submit.mjs +6 -6
  99. package/dist-lib/swift-svg-raster.cjs +1 -1
  100. package/dist-lib/swift-svg-raster.mjs +2 -2
  101. package/dist-lib/swift-toolchain.cjs +12 -6
  102. package/dist-lib/swift.cjs +1 -1
  103. package/dist-lib/vendor/@peculiar/x509.cjs +1 -1
  104. package/dist-lib/vendor/@ruby/prism/src/nodes.js.cjs +1 -1
  105. package/dist-lib/vendor/@ruby/prism/src/parsePrism.js.cjs +1 -1
  106. package/dist-lib/vendor/@xmldom/xmldom.cjs +1 -1
  107. package/dist-lib/vendor/acorn.cjs +1 -1
  108. package/dist-lib/vendor/bplist-parser.cjs +1 -1
  109. package/dist-lib/vendor/ignore.cjs +1 -1
  110. package/dist-lib/vendor/magic-string.cjs +1 -1
  111. package/dist-lib/vendor/plist.cjs +1 -1
  112. package/dist-lib/vendor/smol-toml.cjs +1 -1
  113. package/dist-lib/vendor/stream-json.cjs +1 -1
  114. package/dist-lib/vendor/sucrase/dist/index.js.cjs +1 -1
  115. package/dist-lib/vendor/sucrase/dist/parser/index.js.cjs +1 -1
  116. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/index.js.cjs +1 -1
  117. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/types.js.cjs +1 -1
  118. package/dist-lib/vendor/sucrase.cjs +1 -1
  119. package/dist-lib/vendor/terser.cjs +1 -1
  120. package/dist-lib/vendor/valibot.cjs +1 -1
  121. package/dist-lib/vendor/ws.cjs +1 -1
  122. package/dist-lib/vendor/zod.cjs +1 -1
  123. package/dist-lib/worklet-executable.cjs +1 -1
  124. package/dist-lib/worklet-executable.mjs +3 -3
  125. package/dist-types/packages/peach-engine/src/engine/native-node-queries.d.ts +1 -0
  126. package/kotlin/sdk.tar.gz +0 -0
  127. package/package.json +1 -1
  128. package/runtime-companion.json +1 -1
  129. package/src/binaryen.lock.json +3 -3
  130. package/src/native-bundles.ts +2 -0
  131. package/src/one-native-controls-package.ts +235 -40
  132. package/src/one-sdk/source.ts +2 -1
  133. package/src/one-sdk-preparation.ts +40 -2
  134. package/src/oneSdkContract.ts +13 -2
  135. package/src/swift-compile.ts +301 -48
  136. package/src/swift-guest-compile.ts +11 -2
  137. package/src/swift-guest-projection-storage.ts +45 -26
  138. package/src/swift-guest-runtime-plan.ts +1 -1
  139. package/src/swift-host.ts +88 -16
  140. package/src/swift-reproducible.ts +16 -2
  141. package/src/swift-root-lock.ts +77 -5
  142. package/src/swift-sdk-app-module.ts +15 -6
  143. package/src/swift-sdk-image-wasm.ts +5 -2
  144. package/src/swift-sdk-image.ts +122 -59
  145. package/src/swift-startup-split.ts +65 -27
  146. package/src/swift-toolchain.ts +16 -5
  147. package/src/swift-wasm-prune.ts +51 -34
  148. package/src/wasm-lazy-split.ts +46 -40
  149. package/src/wasm-optimize.ts +146 -140
@@ -1,8 +1,10 @@
1
- /*! peach v0.1.2591 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2593 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  import {
3
3
  SWIFT_AUTOLINK_LINKER,
4
4
  SWIFT_CACHE_HOLD_MARKER,
5
5
  SWIFT_WASM_TRIPLE,
6
+ acquireSwiftRootReadHold,
7
+ hasLiveSwiftRootReaders,
6
8
  refreshSwiftCacheHold,
7
9
  sourceSwiftCheckout,
8
10
  swiftCacheDir,
@@ -13,12 +15,13 @@ import {
13
15
  swiftSourceSdk,
14
16
  swiftToolchain,
15
17
  terminateProcessGroup,
18
+ waitForNoSwiftRootReaders,
16
19
  wasmThreadFlags,
17
20
  wasmThreadLinkFlags,
18
21
  windowAdmission,
19
22
  withSwiftRootLock,
20
23
  writeSwiftAutolinkLinker
21
- } from "./chunk-ILWFGZWW.mjs";
24
+ } from "./chunk-UZPLSN2V.mjs";
22
25
  import {
23
26
  SWIFT_BINARY_TREES_DIR,
24
27
  SWIFT_NATIVE_INPUT_ROOT,
@@ -33,7 +36,7 @@ import {
33
36
  isSwiftResourcePath,
34
37
  isSwiftSourceLinkGraph,
35
38
  swiftProjectFilesProblems
36
- } from "./chunk-SOAYP72T.mjs";
39
+ } from "./chunk-XFFPOSW2.mjs";
37
40
  import {
38
41
  OBJC_RESOURCE_ACCESSOR_BODY,
39
42
  OBJC_RESOURCE_ACCESSOR_HEADER,
@@ -57,20 +60,21 @@ import {
57
60
  swiftPackagePartition,
58
61
  swiftTargetModuleName,
59
62
  withoutGlogModuleMap
60
- } from "./chunk-YR6DNV76.mjs";
63
+ } from "./chunk-P3A4MQHR.mjs";
61
64
  import {
62
65
  rnxPublicBrand
63
- } from "./chunk-JHXDM3YU.mjs";
66
+ } from "./chunk-IT4CC3HU.mjs";
64
67
  import {
65
68
  isRecord
66
- } from "./chunk-EGKH2L6J.mjs";
69
+ } from "./chunk-BMKI4WBL.mjs";
67
70
  import {
68
71
  __publicField
69
- } from "./chunk-4QHHRGO4.mjs";
72
+ } from "./chunk-DLSPHUHQ.mjs";
70
73
 
71
74
  // src/swift-compile.ts
72
75
  import {
73
76
  spawn as spawn2,
77
+ spawnSync as spawnSync5,
74
78
  execFileSync as execFileSync13
75
79
  } from "node:child_process";
76
80
  import { createHash as createHash18, randomUUID as randomUUID5 } from "node:crypto";
@@ -78,7 +82,7 @@ import {
78
82
  chmodSync as chmodSync3,
79
83
  copyFileSync as copyFileSync2,
80
84
  cpSync,
81
- existsSync as existsSync9,
85
+ existsSync as existsSync10,
82
86
  lstatSync,
83
87
  mkdirSync as mkdirSync8,
84
88
  mkdtempSync as mkdtempSync4,
@@ -86,7 +90,7 @@ import {
86
90
  readdirSync as readdirSync6,
87
91
  readlinkSync,
88
92
  realpathSync as realpathSync6,
89
- renameSync as renameSync6,
93
+ renameSync as renameSync5,
90
94
  rmSync as rmSync7,
91
95
  statSync as statSync4,
92
96
  symlinkSync as symlinkSync2,
@@ -94,7 +98,7 @@ import {
94
98
  writeFileSync as writeFileSync8
95
99
  } from "node:fs";
96
100
  import os4 from "node:os";
97
- import path32 from "node:path";
101
+ import path33 from "node:path";
98
102
 
99
103
  // ../../node_modules/valibot/dist/index.mjs
100
104
  var store$4;
@@ -511,6 +515,54 @@ function string(message$1) {
511
515
  };
512
516
  }
513
517
  // @__NO_SIDE_EFFECTS__
518
+ function tuple(items, message$1) {
519
+ return {
520
+ kind: "schema",
521
+ type: "tuple",
522
+ reference: tuple,
523
+ expects: "Array",
524
+ async: false,
525
+ items,
526
+ message: message$1,
527
+ get "~standard"() {
528
+ return /* @__PURE__ */ _getStandardProps(this);
529
+ },
530
+ "~run"(dataset, config$1) {
531
+ const input = dataset.value;
532
+ if (Array.isArray(input)) {
533
+ dataset.typed = true;
534
+ dataset.value = [];
535
+ for (let key = 0; key < this.items.length; key++) {
536
+ const value$1 = input[key];
537
+ const itemDataset = this.items[key]["~run"]({ value: value$1 }, config$1);
538
+ if (itemDataset.issues) {
539
+ const pathItem = {
540
+ type: "array",
541
+ origin: "value",
542
+ input,
543
+ key,
544
+ value: value$1
545
+ };
546
+ for (const issue of itemDataset.issues) {
547
+ if (issue.path) issue.path.unshift(pathItem);
548
+ else issue.path = [pathItem];
549
+ dataset.issues?.push(issue);
550
+ }
551
+ if (!dataset.issues) dataset.issues = itemDataset.issues;
552
+ if (config$1.abortEarly) {
553
+ dataset.typed = false;
554
+ break;
555
+ }
556
+ }
557
+ if (!itemDataset.typed) dataset.typed = false;
558
+ dataset.value.push(itemDataset.value);
559
+ }
560
+ } else _addIssue(this, "type", dataset, config$1);
561
+ return dataset;
562
+ }
563
+ };
564
+ }
565
+ // @__NO_SIDE_EFFECTS__
514
566
  function unknown() {
515
567
  return {
516
568
  kind: "schema",
@@ -3751,8 +3803,8 @@ function designTimeSites(source) {
3751
3803
  sites.push({ kind: "boolean", start: token.start, end: token.end, value: word });
3752
3804
  } else if (token.kind === "number") {
3753
3805
  const kind = numberKind(word);
3754
- const tuple = source[token.start - 1] === "." && source[token.start - 2] !== ".";
3755
- if (kind && !tuple) {
3806
+ const tuple2 = source[token.start - 1] === "." && source[token.start - 2] !== ".";
3807
+ if (kind && !tuple2) {
3756
3808
  const minus = tokens[t - 1];
3757
3809
  const negative = minus !== void 0 && text(source, minus) === "-" && minus.end === token.start && t - 1 >= from && !/[^\s([{,;:=]/.test(source[minus.start - 1] ?? " ");
3758
3810
  const start = negative ? minus.start : token.start;
@@ -3841,9 +3893,9 @@ var EXCERPT = /^(\s*)(\d+)( \| )(.*)$/;
3841
3893
  var MARKER = /^(\s*)( \| )(.*)$/;
3842
3894
  function designTimeDiagnostic(output, files) {
3843
3895
  const rewritten = /* @__PURE__ */ new Map();
3844
- const linesOf = (path33) => {
3896
+ const linesOf = (path34) => {
3845
3897
  const file = Object.keys(files).find(
3846
- (name) => name.endsWith(".swift") && (path33 === name || path33.endsWith(`/${name}`))
3898
+ (name) => name.endsWith(".swift") && (path34 === name || path34.endsWith(`/${name}`))
3847
3899
  );
3848
3900
  if (file === void 0) return null;
3849
3901
  let lines = rewritten.get(file);
@@ -5475,6 +5527,7 @@ var OBJC_LOAD_FUNCTION = ".objcv2_load_function";
5475
5527
 
5476
5528
  // src/swift-sdk-image-wasm.ts
5477
5529
  function wasmReader(bytes, start) {
5530
+ const rawBuf = Buffer.isBuffer(bytes) ? bytes : Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
5478
5531
  let at = start;
5479
5532
  const u = () => {
5480
5533
  let value = 0;
@@ -5503,7 +5556,7 @@ function wasmReader(bytes, start) {
5503
5556
  name: () => {
5504
5557
  const length = u();
5505
5558
  at += length;
5506
- return Buffer.from(bytes.subarray(at - length, at)).toString();
5559
+ return rawBuf.toString("utf8", at - length, at);
5507
5560
  },
5508
5561
  skip: (length) => {
5509
5562
  at += length;
@@ -5901,7 +5954,7 @@ function codeOnlySdkImage(bytes, constructorMask) {
5901
5954
  const bodies = m.bodies.map(({ start, end }) => bytes.subarray(start, end));
5902
5955
  const initMemory = functionIndex("__wasm_init_memory") - m.importedFuncs;
5903
5956
  {
5904
- const body = Uint8Array.from(bodies[initMemory]);
5957
+ const body = new Uint8Array(bodies[initMemory]);
5905
5958
  const r = wasmReader(body, 0);
5906
5959
  if (r.u() !== 0) throw new Error("sdk memory initializer has locals");
5907
5960
  while (r.at < body.length) {
@@ -6945,7 +6998,18 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
6945
6998
  dataOwnerSymIdx[kept] = ownerSymIdx;
6946
6999
  kept++;
6947
7000
  }
6948
- const dataRelocs = {
7001
+ const dataRelocs = kept === rawData.count ? {
7002
+ count: kept,
7003
+ bytes: rawData.bytes,
7004
+ start: rawData.start,
7005
+ end: rawData.end,
7006
+ ro: rawData.ro,
7007
+ rs: rawData.rs,
7008
+ addend: rawData.addend,
7009
+ segIdx: dataSegIdx,
7010
+ offInSeg: dataOffInSeg,
7011
+ ownerSymIdx: dataOwnerSymIdx
7012
+ } : {
6949
7013
  count: kept,
6950
7014
  bytes: rawData.bytes,
6951
7015
  start: rawData.start.slice(0, kept),
@@ -6957,26 +7021,29 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
6957
7021
  offInSeg: dataOffInSeg.slice(0, kept),
6958
7022
  ownerSymIdx: dataOwnerSymIdx.slice(0, kept)
6959
7023
  };
6960
- const relocatedWords = /* @__PURE__ */ new Map();
6961
- for (let i = 0; i < dataRelocs.count; i++) {
6962
- const segIdx = dataRelocs.segIdx[i];
6963
- let words = relocatedWords.get(segIdx);
6964
- if (!words) relocatedWords.set(segIdx, words = /* @__PURE__ */ new Set());
6965
- words.add(dataRelocs.offInSeg[i]);
6966
- }
6967
- for (const [segIdx, tops] of segTopSyms) {
6968
- const starts = new Map(tops.map((top) => [top.off, top.symIdx]));
6969
- const relocated = relocatedWords.get(segIdx);
6970
- const payload = dataStart + sPayloadStarts[segIdx];
6971
- const view = new DataView(buf.buffer, buf.byteOffset + payload);
6972
- for (const top of tops) {
6973
- for (let at = top.off; at + 4 <= top.end; at += 4) {
6974
- if (relocated?.has(at)) continue;
6975
- const target = starts.get(at + (view.getInt32(at, true) & ~3));
6976
- if (target === void 0 || target === top.symIdx) continue;
6977
- let list = symDataRelocs.get(top.symIdx);
6978
- if (!list) symDataRelocs.set(top.symIdx, list = []);
6979
- list.push(target);
7024
+ if (segTopSyms.size > 0) {
7025
+ const relocatedWords = /* @__PURE__ */ new Map();
7026
+ for (let i = 0; i < dataRelocs.count; i++) {
7027
+ const segIdx = dataRelocs.segIdx[i];
7028
+ if (!segTopSyms.has(segIdx)) continue;
7029
+ let words = relocatedWords.get(segIdx);
7030
+ if (!words) relocatedWords.set(segIdx, words = /* @__PURE__ */ new Set());
7031
+ words.add(dataRelocs.offInSeg[i]);
7032
+ }
7033
+ for (const [segIdx, tops] of segTopSyms) {
7034
+ const starts = new Map(tops.map((top) => [top.off, top.symIdx]));
7035
+ const relocated = relocatedWords.get(segIdx);
7036
+ const payload = dataStart + sPayloadStarts[segIdx];
7037
+ const view = new DataView(buf.buffer, buf.byteOffset + payload);
7038
+ for (const top of tops) {
7039
+ for (let at = top.off; at + 4 <= top.end; at += 4) {
7040
+ if (relocated?.has(at)) continue;
7041
+ const target = starts.get(at + (view.getInt32(at, true) & ~3));
7042
+ if (target === void 0 || target === top.symIdx) continue;
7043
+ let list = symDataRelocs.get(top.symIdx);
7044
+ if (!list) symDataRelocs.set(top.symIdx, list = []);
7045
+ list.push(target);
7046
+ }
6980
7047
  }
6981
7048
  }
6982
7049
  }
@@ -7148,7 +7215,7 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
7148
7215
  };
7149
7216
  }
7150
7217
  function parseWasmObjectFile(file, isDist) {
7151
- return parseWasmObjectBytes(file, new Uint8Array(fs5.readFileSync(file)), isDist);
7218
+ return parseWasmObjectBytes(file, fs5.readFileSync(file), isDist);
7152
7219
  }
7153
7220
  function parseWasmObjectCached(file, isDist, entries2) {
7154
7221
  const key = `${isDist ? "1" : "0"}:${file}`;
@@ -10164,18 +10231,6 @@ function readWasmMemoryAndTableImports(bytes, layout2) {
10164
10231
  }
10165
10232
  return { memory, tableImports };
10166
10233
  }
10167
- function hasWasmExport(bytes, name) {
10168
- const section2 = wasmSections2(bytes).find((value) => value.id === 7);
10169
- if (!section2) return false;
10170
- const input = readWasmSection(bytes, section2.start, section2.end);
10171
- for (let count = input.number(); count > 0; count--) {
10172
- const found = input.name();
10173
- input.byte();
10174
- input.number();
10175
- if (found === name) return true;
10176
- }
10177
- return false;
10178
- }
10179
10234
  function withSections(bytes, layout2, replacements) {
10180
10235
  const parts = [bytes.subarray(0, 8)];
10181
10236
  let at = 8;
@@ -10837,23 +10892,40 @@ function reserveGuestProjectionStorage(images, capacities) {
10837
10892
  };
10838
10893
  }
10839
10894
  function mergeGuestProjectionSpans(imageCount, spans) {
10840
- const sorted = [...spans].sort(
10841
- (a, b) => a.space.localeCompare(b.space) || a.address - b.address || a.image - b.image
10842
- );
10843
- const merged = [];
10844
- for (const span of sorted) {
10895
+ const tableSpans = [];
10896
+ const memorySpans = [];
10897
+ for (const span of spans) {
10845
10898
  if (!Number.isInteger(span.image) || span.image < 0 || span.image >= imageCount || !Number.isInteger(span.address) || !Number.isInteger(span.length) || span.address < 0 || span.length <= 0 || span.address + span.length > 4294967296)
10846
10899
  throw new Error("invalid linked guest span");
10847
- const previous = merged[merged.length - 1];
10848
- if (previous && previous.space === span.space && span.address < previous.address + previous.length && previous.image !== span.image)
10849
- throw new Error("linked guest span has ambiguous image ownership");
10850
- if (previous && previous.space === span.space && previous.image === span.image && span.address <= previous.address + previous.length) {
10851
- merged[merged.length - 1] = {
10852
- ...previous,
10853
- length: Math.max(previous.address + previous.length, span.address + span.length) - previous.address
10854
- };
10855
- } else merged.push(span);
10900
+ if (span.space === "function-table") tableSpans.push(span);
10901
+ else memorySpans.push(span);
10856
10902
  }
10903
+ const byAddress = (a, b) => a.address - b.address || a.image - b.image;
10904
+ tableSpans.sort(byAddress);
10905
+ memorySpans.sort(byAddress);
10906
+ const merged = [];
10907
+ const mergeGroup = (group) => {
10908
+ let previous = null;
10909
+ for (const span of group) {
10910
+ if (previous && span.address < previous.address + previous.length && previous.image !== span.image)
10911
+ throw new Error("linked guest span has ambiguous image ownership");
10912
+ if (previous && previous.image === span.image && span.address <= previous.address + previous.length) {
10913
+ const end = span.address + span.length;
10914
+ if (end > previous.address + previous.length)
10915
+ previous.length = end - previous.address;
10916
+ } else {
10917
+ previous = {
10918
+ image: span.image,
10919
+ space: span.space,
10920
+ address: span.address,
10921
+ length: span.length
10922
+ };
10923
+ merged.push(previous);
10924
+ }
10925
+ }
10926
+ };
10927
+ mergeGroup(tableSpans);
10928
+ mergeGroup(memorySpans);
10857
10929
  return merged;
10858
10930
  }
10859
10931
  function guestProjectionRegionCounts(imageCount, spans) {
@@ -11037,7 +11109,7 @@ function sdkArtifactBytes(root, artifact) {
11037
11109
  const source = readFileSync9(path16.join(sourceDirectory, "libFoundation.a"));
11038
11110
  if (hash(source) !== artifact.sha256)
11039
11111
  throw new Error(`SDK product artifact changed ${file}`);
11040
- const transformed = Uint8Array.from(source);
11112
+ const transformed = new Uint8Array(source);
11041
11113
  weakenFoundationOverridesInArchive(transformed);
11042
11114
  if (!linked.equals(transformed))
11043
11115
  throw new Error(`SDK view transformation changed ${file}`);
@@ -11550,7 +11622,16 @@ function guestAliasedSdkArchiveArtifacts(options) {
11550
11622
 
11551
11623
  // src/wasm-optimize.ts
11552
11624
  import { execFile } from "node:child_process";
11553
- import { existsSync as existsSync3, readFileSync as readFileSync10, renameSync as renameSync3, rmSync as rmSync4, writeFileSync as writeFileSync4 } from "node:fs";
11625
+ import {
11626
+ closeSync as closeSync2,
11627
+ existsSync as existsSync3,
11628
+ fstatSync,
11629
+ openSync as openSync2,
11630
+ readFileSync as readFileSync10,
11631
+ readSync as readSync2,
11632
+ rmSync as rmSync4,
11633
+ writeFileSync as writeFileSync4
11634
+ } from "node:fs";
11554
11635
  import { dirname, join } from "node:path";
11555
11636
  import { promisify } from "node:util";
11556
11637
 
@@ -11843,17 +11924,17 @@ var binaryen_lock_default = {
11843
11924
  "linux-x64": {
11844
11925
  asset: "x86_64-linux",
11845
11926
  upstreamSha256: "195ddc94f9bc89f45abdabb0b9eea86023d727ba90eac8b35b80f2544fc30572",
11846
- sha256: "feda0b3a5a24c902ec25e8d674f33c5771a0704e611a2e8e4800ab3c3fc591ca"
11927
+ sha256: "1024974f254c1c2edd738246ec6af5add16d3d36b5f58a94545febda3b33c869"
11847
11928
  },
11848
11929
  "linux-arm64": {
11849
11930
  asset: "aarch64-linux",
11850
11931
  upstreamSha256: "c58562417836c5d0493d89bdefc434933bdc097db641b483df86bcfa557a107f",
11851
- sha256: "0c67b9f36e9337afddf13b5150ab0e30bddf4f58633b02c4604f0cc87c2b89a2"
11932
+ sha256: "7dedfc9f5cb32e75a28831f3b5aa053fd3e0bdd74f73dc4d1b1588947236daef"
11852
11933
  },
11853
11934
  "darwin-arm64": {
11854
11935
  asset: "arm64-macos",
11855
11936
  upstreamSha256: "98aad827847af7ef990ed7098d885725c8e5b5aae75073403635617ae4e259aa",
11856
- sha256: "36373d0901b376c2868f09e0c2c303b1b7117b696e31dd661afa9711f31ea4a0"
11937
+ sha256: "0b56e0a06b6a873877871537a120fd94e2121e67f4bce5f8b5252c47b615854a"
11857
11938
  }
11858
11939
  }
11859
11940
  };
@@ -11924,6 +12005,45 @@ var BINARYEN_VERSION = binaryen_lock_default.version;
11924
12005
  var runBinaryen = promisify(execFile);
11925
12006
  var WASM_LOWER_IDENTITY = `binaryen ${BINARYEN_VERSION} narrow ${LOWERING.join(" ")} ${FEATURES.join(",")} shared-stack-check-v2 native-image-v1 table-reserve-v2 ${NATIVE_TABLE_ABI} unoptimized-names`;
11926
12007
  var BINARYEN_RELEASES = new Map(Object.entries(binaryen_lock_default.platforms));
12008
+ function readWasmMemoryFromFile(file) {
12009
+ const fd = openSync2(file, "r");
12010
+ try {
12011
+ const total = fstatSync(fd).size;
12012
+ const header = Buffer.allocUnsafe(8);
12013
+ if (total < 8 || readSync2(fd, header, 0, 8, 0) < 8) return void 0;
12014
+ let offset = 8;
12015
+ const probe = Buffer.allocUnsafe(16);
12016
+ let prefixEnd = 8;
12017
+ while (offset < total) {
12018
+ const read = readSync2(fd, probe, 0, Math.min(16, total - offset), offset);
12019
+ if (read < 2) break;
12020
+ const id = probe[0];
12021
+ let size = 0;
12022
+ let shift = 0;
12023
+ let at = 1;
12024
+ for (; ; ) {
12025
+ const byte = probe[at++];
12026
+ size += (byte & 127) * 2 ** shift;
12027
+ if (!(byte & 128)) break;
12028
+ shift += 7;
12029
+ }
12030
+ const next = offset + at + size;
12031
+ if (id === 2 || id === 5) prefixEnd = next;
12032
+ if (id > 5) break;
12033
+ offset = next;
12034
+ }
12035
+ const prefix = Buffer.allocUnsafe(prefixEnd);
12036
+ let filled = 0;
12037
+ while (filled < prefixEnd) {
12038
+ const n = readSync2(fd, prefix, filled, prefixEnd - filled, filled);
12039
+ if (n <= 0) break;
12040
+ filled += n;
12041
+ }
12042
+ return readWasmMemory(prefix.subarray(0, filled));
12043
+ } finally {
12044
+ closeSync2(fd);
12045
+ }
12046
+ }
11927
12047
  async function runWasmOpt(file, output, optimize, skipPasses, binary, sdkTableEnd, wideExports) {
11928
12048
  const admittedCores = windowAdmission()?.cores ?? Number(process.env.TM_EXEC_CPU_CORES);
11929
12049
  const requestedCores = Number(process.env.BINARYEN_CORES);
@@ -11940,25 +12060,75 @@ async function runWasmOpt(file, output, optimize, skipPasses, binary, sdkTableEn
11940
12060
  return;
11941
12061
  }
11942
12062
  const optimizeSize = optimize === true || optimize === "app-module";
11943
- const optimizeBeforeGuard = optimize === true;
11944
12063
  const relink = optimize === "relink";
11945
- const names = optimizeBeforeGuard && !KEEP_WASM_NAMES ? [] : ["-g"];
11946
- const outputNames = (optimizeSize || relink) && !KEEP_WASM_NAMES ? [] : names;
11947
- let input = readFileSync10(file);
11948
- const memory = readWasmMemory(input);
11949
- const checked = `${output}.stack-checked`;
12064
+ const keepNames = !optimizeSize && !relink || KEEP_WASM_NAMES;
12065
+ const memory = readWasmMemoryFromFile(file);
11950
12066
  if (memory?.shared && memory.maximumPages !== 65536)
11951
12067
  throw new Error("threaded native memory must declare a 65536-page maximum");
11952
- if (memory?.shared && optimizeBeforeGuard) {
11953
- await runBinaryen(binary, [...features, "-g", "--stack-check", file, "-o", checked], {
11954
- env: environment
11955
- });
11956
- input = readFileSync10(checked);
11957
- if (!hasWasmExport(input, "__set_stack_limits"))
11958
- throw new Error(
11959
- "threaded native artifact must retain its __stack_pointer name for bounds checks"
12068
+ if (memory?.shared) {
12069
+ const wideExportsFile = wideExports.size ? `${output}.wide-exports` : void 0;
12070
+ const tableTool = join(dirname(binary), "wasm-table-guard");
12071
+ try {
12072
+ if (wideExportsFile)
12073
+ writeFileSync4(wideExportsFile, [...wideExports].join("\n") + "\n");
12074
+ const pipelineArgs = [
12075
+ "--pipeline",
12076
+ "--in",
12077
+ file,
12078
+ "--out",
12079
+ output,
12080
+ "--narrow",
12081
+ ...wideExportsFile ? ["--wide-exports-file", wideExportsFile] : [],
12082
+ "--lower",
12083
+ "--shared",
12084
+ ...keepNames ? ["--debug"] : [],
12085
+ ...sdkTableEnd !== void 0 ? ["--slots-range", "1", String(sdkTableEnd), "--adapt"] : [],
12086
+ ...optimizeSize ? ["--optimize", "oz"] : relink ? ["--optimize", "relink"] : [],
12087
+ ...skipPasses.flatMap((pass) => ["--skip-pass", pass])
12088
+ ];
12089
+ const { stdout } = await runBinaryen(tableTool, pipelineArgs, { env: environment });
12090
+ const metadata = JSON.parse(stdout);
12091
+ if (typeof metadata !== "object" || metadata === null || !("tableMinimum" in metadata) || typeof metadata.tableMinimum !== "number" || !Number.isSafeInteger(metadata.tableMinimum) || metadata.tableMinimum < 0)
12092
+ throw new Error("native table tool returned an invalid table minimum");
12093
+ const sectionName = new TextEncoder().encode(NATIVE_IMAGE_SECTION);
12094
+ const layout2 = new TextEncoder().encode(
12095
+ JSON.stringify({
12096
+ initialPages: memory.initialPages,
12097
+ tableMinimum: metadata.tableMinimum
12098
+ })
12099
+ );
12100
+ const encode = (value) => {
12101
+ const bytes2 = [];
12102
+ do {
12103
+ const byte = value & 127;
12104
+ value >>>= 7;
12105
+ bytes2.push(byte | (value ? 128 : 0));
12106
+ } while (value);
12107
+ return bytes2;
12108
+ };
12109
+ const body = new Uint8Array([
12110
+ ...encode(sectionName.length),
12111
+ ...sectionName,
12112
+ ...layout2
12113
+ ]);
12114
+ const bytes = readFileSync10(output);
12115
+ writeFileSync4(
12116
+ output,
12117
+ Buffer.concat([
12118
+ sdkTableEnd === void 0 ? withWasmTableMinimum(
12119
+ bytes,
12120
+ metadata.tableMinimum + NATIVE_TABLE_RESERVE_SLOTS
12121
+ ) : bytes,
12122
+ Buffer.from([0, ...encode(body.length), ...body])
12123
+ ])
11960
12124
  );
12125
+ } finally {
12126
+ if (wideExportsFile) rmSync4(wideExportsFile, { force: true });
12127
+ }
12128
+ return;
11961
12129
  }
12130
+ const outputNames = keepNames ? ["-g"] : [];
12131
+ const input = readFileSync10(file);
11962
12132
  const narrowed = narrowWasmBoundary(input, wideExports);
11963
12133
  const merged = `${output}.narrowed`;
11964
12134
  if (narrowed) {
@@ -11970,7 +12140,7 @@ async function runWasmOpt(file, output, optimize, skipPasses, binary, sdkTableEn
11970
12140
  join(dirname(binary), "wasm-merge"),
11971
12141
  [
11972
12142
  ...features,
11973
- ...names,
12143
+ ...outputNames,
11974
12144
  guest,
11975
12145
  NARROW_MERGE_NAMES.guest,
11976
12146
  thunks,
@@ -11984,118 +12154,25 @@ async function runWasmOpt(file, output, optimize, skipPasses, binary, sdkTableEn
11984
12154
  rmSync4(guest);
11985
12155
  rmSync4(thunks);
11986
12156
  }
11987
- const lowered = memory?.shared ? `${output}.lowered` : output;
11988
- const compiled = narrowed ? merged : memory?.shared && optimizeBeforeGuard ? checked : file;
12157
+ const compiled = narrowed ? merged : file;
11989
12158
  const skip = skipPasses.flatMap((pass) => ["--skip-pass", pass]);
11990
12159
  try {
11991
- if (!memory?.shared || optimizeBeforeGuard)
11992
- await runBinaryen(
11993
- binary,
11994
- [
11995
- ...LOWERING,
11996
- ...optimizeSize ? ["-Oz"] : relink ? RELINK_PASSES : [],
11997
- ...outputNames,
11998
- ...skip,
11999
- ...features,
12000
- compiled,
12001
- "-o",
12002
- lowered
12003
- ],
12004
- { env: environment, maxBuffer: Infinity }
12005
- );
12006
- if (memory?.shared) {
12007
- const guarded = `${output}.table.wasm`;
12008
- const sdkGuarded = `${output}.sdk-table.wasm`;
12009
- const sdkSlots = `${output}.sdk-table-slots`;
12010
- const tableTool = join(dirname(binary), "wasm-table-guard");
12011
- try {
12012
- const { stdout } = await runBinaryen(
12013
- tableTool,
12014
- [
12015
- optimizeBeforeGuard ? lowered : compiled,
12016
- guarded,
12017
- names.length ? "1" : "0",
12018
- ...optimizeBeforeGuard ? [] : ["lower"]
12019
- ],
12020
- { env: environment }
12021
- );
12022
- const metadata = JSON.parse(stdout);
12023
- if (typeof metadata !== "object" || metadata === null || !("tableMinimum" in metadata) || typeof metadata.tableMinimum !== "number" || !Number.isSafeInteger(metadata.tableMinimum) || metadata.tableMinimum < 0)
12024
- throw new Error("native table tool returned an invalid table minimum");
12025
- if (sdkTableEnd !== void 0) {
12026
- writeFileSync4(
12027
- sdkSlots,
12028
- Array.from({ length: sdkTableEnd - 1 }, (_, index) => index + 1).join("\n")
12029
- );
12030
- await runBinaryen(
12031
- tableTool,
12032
- [guarded, sdkGuarded, names.length ? "1" : "0", "0", sdkSlots, "adapt"],
12033
- { env: environment }
12034
- );
12035
- renameSync3(sdkGuarded, guarded);
12036
- }
12037
- if (optimize)
12038
- await runBinaryen(
12039
- binary,
12040
- [
12041
- ...features,
12042
- // an adapted call tests its target's type with a typed function reference.
12043
- ...sdkTableEnd === void 0 ? [] : ["--enable-gc"],
12044
- ...optimizeSize ? ["-Oz"] : RELINK_PASSES,
12045
- ...outputNames,
12046
- ...skip,
12047
- guarded,
12048
- "-o",
12049
- output
12050
- ],
12051
- { env: environment }
12052
- );
12053
- const sectionName = new TextEncoder().encode(NATIVE_IMAGE_SECTION);
12054
- const layout2 = new TextEncoder().encode(
12055
- JSON.stringify({
12056
- initialPages: memory.initialPages,
12057
- tableMinimum: metadata.tableMinimum
12058
- })
12059
- );
12060
- const encode = (value) => {
12061
- const bytes2 = [];
12062
- do {
12063
- const byte = value & 127;
12064
- value >>>= 7;
12065
- bytes2.push(byte | (value ? 128 : 0));
12066
- } while (value);
12067
- return bytes2;
12068
- };
12069
- const body = new Uint8Array([
12070
- ...encode(sectionName.length),
12071
- ...sectionName,
12072
- ...layout2
12073
- ]);
12074
- const image = optimize ? output : guarded;
12075
- const bytes = readFileSync10(image);
12076
- writeFileSync4(
12077
- image,
12078
- Buffer.concat([
12079
- sdkTableEnd === void 0 ? withWasmTableMinimum(
12080
- bytes,
12081
- metadata.tableMinimum + NATIVE_TABLE_RESERVE_SLOTS
12082
- ) : bytes,
12083
- Buffer.from([0, ...encode(body.length), ...body])
12084
- ])
12085
- );
12086
- if (!optimize) renameSync3(guarded, output);
12087
- } finally {
12088
- rmSync4(guarded, { force: true });
12089
- rmSync4(sdkGuarded, { force: true });
12090
- rmSync4(sdkSlots, { force: true });
12091
- }
12092
- }
12160
+ await runBinaryen(
12161
+ binary,
12162
+ [
12163
+ ...LOWERING,
12164
+ ...optimizeSize ? ["-Oz"] : relink ? RELINK_PASSES : [],
12165
+ ...outputNames,
12166
+ ...skip,
12167
+ ...features,
12168
+ compiled,
12169
+ "-o",
12170
+ output
12171
+ ],
12172
+ { env: environment, maxBuffer: Infinity }
12173
+ );
12093
12174
  } finally {
12094
12175
  if (narrowed) rmSync4(merged, { force: true });
12095
- if (memory?.shared) {
12096
- rmSync4(checked, { force: true });
12097
- rmSync4(lowered, { force: true });
12098
- }
12099
12176
  }
12100
12177
  }
12101
12178
  async function installWasmOpt() {
@@ -13436,7 +13513,7 @@ import {
13436
13513
  mkdirSync as mkdirSync4,
13437
13514
  readFileSync as readFileSync11,
13438
13515
  realpathSync as realpathSync2,
13439
- renameSync as renameSync4,
13516
+ renameSync as renameSync3,
13440
13517
  statSync,
13441
13518
  writeFileSync as writeFileSync5
13442
13519
  } from "node:fs";
@@ -13779,7 +13856,7 @@ function sourceGuestClangLinkOptions(options) {
13779
13856
  validateClangLinkOptions(flags);
13780
13857
  const temporary = `${cacheFile}.${process.pid}`;
13781
13858
  writeFileSync5(temporary, JSON.stringify({ key, flags }));
13782
- renameSync4(temporary, cacheFile);
13859
+ renameSync3(temporary, cacheFile);
13783
13860
  result.set(file, flags);
13784
13861
  }
13785
13862
  return result;
@@ -14182,13 +14259,13 @@ function swiftSdkGuestLookups(moduleRoot, sdkRoot, objects) {
14182
14259
  const shared = /* @__PURE__ */ new Set();
14183
14260
  const sdkWeakReferences = /* @__PURE__ */ new Map();
14184
14261
  for (const objects2 of groups.values())
14185
- for (const { path: path33, bytes } of objects2) {
14262
+ for (const { path: path34, bytes } of objects2) {
14186
14263
  const defined = guestWasmSymbols(bytes);
14187
14264
  for (const name of defined.defined) symbols.add(name);
14188
14265
  for (const name of defined.tags) shared.add(name);
14189
14266
  for (const name of defined.globals) shared.add(name);
14190
14267
  if (defined.weakUndefined.length)
14191
- sdkWeakReferences.set(path33, new Set(defined.weakUndefined));
14268
+ sdkWeakReferences.set(path34, new Set(defined.weakUndefined));
14192
14269
  }
14193
14270
  return createGuestImageLedger({
14194
14271
  images,
@@ -14301,7 +14378,7 @@ async function compileGuestLink(options) {
14301
14378
  let lazyFunctions = [];
14302
14379
  let dyldSymbols = [];
14303
14380
  const bundlePaths = new Map(
14304
- options.resourceBundles.map(({ target, path: path33 }) => [target, path33])
14381
+ options.resourceBundles.map(({ target, path: path34 }) => [target, path34])
14305
14382
  );
14306
14383
  const imageMetadata = (products) => {
14307
14384
  const source = sourceImages.map((image) => {
@@ -14335,7 +14412,7 @@ async function compileGuestLink(options) {
14335
14412
  };
14336
14413
  const sdk = options.sdkImage;
14337
14414
  const sdkCallers = sdk?.sdkInterface.guestCallers;
14338
- const sdkObjects = sdk ? (await import("./swift-sdk-image-7T2LMQS5.mjs")).readSwiftSdkManifestIndex(sdk).guestObjects : void 0;
14415
+ const sdkObjects = sdk ? (await import("./swift-sdk-image-SNFZVUQ3.mjs")).readSwiftSdkManifestIndex(sdk).guestObjects : void 0;
14339
14416
  if (sdk && (!sdkCallers || !sdkObjects))
14340
14417
  throw new Error("the SDK image has no guest link manifest");
14341
14418
  const result = linkPrunedGuestImages({
@@ -14629,7 +14706,7 @@ async function compileGuestLink(options) {
14629
14706
  linkSwiftAppModule,
14630
14707
  readSwiftSdkUsage,
14631
14708
  swiftSdkProjectionSpans
14632
- } = await import("./swift-sdk-app-module-5IUSRXYA.mjs");
14709
+ } = await import("./swift-sdk-app-module-5VU63S56.mjs");
14633
14710
  const project = options.project;
14634
14711
  const work = project ? mkdtempSync2(path24.join(directory, "app-module-")) : path24.join(directory, "app-module");
14635
14712
  if (project) chownSync(work, project.uid, project.gid);
@@ -14709,7 +14786,6 @@ async function compileGuestLink(options) {
14709
14786
  bindingRows.set((address - values.address) / 8, value);
14710
14787
  } else data.push(address, size, value);
14711
14788
  }
14712
- const binding = createSwiftSdkBinding({ ...link.linkage, data }, sdk, usage);
14713
14789
  const linked = readFileSync13(
14714
14790
  project ? projectOutputFile(work, linkedModule, project) : linkedModule
14715
14791
  );
@@ -14734,7 +14810,17 @@ async function compileGuestLink(options) {
14734
14810
  );
14735
14811
  continue;
14736
14812
  }
14737
- await link.lower();
14813
+ const lowerPromise = link.lower();
14814
+ await new Promise((resolve) => setImmediate(resolve));
14815
+ let binding;
14816
+ try {
14817
+ binding = createSwiftSdkBinding({ ...link.linkage, data }, sdk, usage);
14818
+ } catch (error) {
14819
+ await lowerPromise.catch(() => {
14820
+ });
14821
+ throw error;
14822
+ }
14823
+ await lowerPromise;
14738
14824
  const finalized = finalizeGuestProjectionStorage({
14739
14825
  map: map2,
14740
14826
  linked,
@@ -14787,7 +14873,7 @@ import {
14787
14873
  mkdirSync as mkdirSync7,
14788
14874
  mkdtempSync as mkdtempSync3,
14789
14875
  readFileSync as readFileSync14,
14790
- renameSync as renameSync5,
14876
+ renameSync as renameSync4,
14791
14877
  rmSync as rmSync6,
14792
14878
  statSync as statSync3,
14793
14879
  writeFileSync as writeFileSync7
@@ -14920,7 +15006,7 @@ async function withSwiftHeaderCompiler(root, toolchainBin, recipe, producers, bu
14920
15006
  producer.publish();
14921
15007
  if (fingerprint) {
14922
15008
  writeFileSync7(`${receipt}.partial`, fingerprint);
14923
- renameSync5(`${receipt}.partial`, receipt);
15009
+ renameSync4(`${receipt}.partial`, receipt);
14924
15010
  }
14925
15011
  response.end();
14926
15012
  } catch (error) {
@@ -15625,8 +15711,8 @@ function sourceEntryPath() {
15625
15711
  return null;
15626
15712
  }
15627
15713
  }
15628
- function isCliEntry(path33) {
15629
- const name = basename2(path33);
15714
+ function isCliEntry(path34) {
15715
+ const name = basename2(path34);
15630
15716
  return name === "bin.ts" || name === "bin.js";
15631
15717
  }
15632
15718
  function rnxSelfInvocation() {
@@ -15751,10 +15837,20 @@ function swiftObjCPrebuiltCompiler(clang, root, sysroot, distribution, targets,
15751
15837
  }
15752
15838
 
15753
15839
  // src/swift-reproducible.ts
15754
- import { realpathSync as realpathSync5 } from "node:fs";
15840
+ import { existsSync as existsSync9, realpathSync as realpathSync5 } from "node:fs";
15755
15841
  import os3 from "node:os";
15842
+ import path30 from "node:path";
15843
+ function canonicalHomeDir() {
15844
+ const home = os3.homedir();
15845
+ const dotPeach = path30.join(home, ".peach");
15846
+ if (existsSync9(dotPeach)) {
15847
+ const realHome = path30.dirname(realpathSync5(dotPeach));
15848
+ if (home === realHome || home.startsWith(`${realHome}${path30.sep}`)) return realHome;
15849
+ }
15850
+ return home;
15851
+ }
15756
15852
  function swiftReproducibleBuildFlags(roots) {
15757
- return [[os3.homedir(), "home"], ...roots].flatMap(
15853
+ return [[canonicalHomeDir(), "home"], ...roots].flatMap(
15758
15854
  ([root, name]) => [.../* @__PURE__ */ new Set([root, realpathSync5(root)])].map((from) => `${from}=/peach/${name}`)
15759
15855
  ).flatMap((map) => [
15760
15856
  "-Xswiftc",
@@ -15819,12 +15915,12 @@ function collectSwiftSourceClosure(files, roots, swiftCodeMask2, extensionMember
15819
15915
 
15820
15916
  // src/swift-uniform-type-constants.ts
15821
15917
  import { execFileSync as execFileSync12 } from "node:child_process";
15822
- import path30 from "node:path";
15918
+ import path31 from "node:path";
15823
15919
  function compileUniformTypeConstants(args) {
15824
- const source = path30.join(args.packageRoot, "runtime/UniformTypeIdentifiersConstants.m");
15825
- const object2 = path30.join(args.out, "UniformTypeIdentifiers-NativeConstants.o");
15920
+ const source = path31.join(args.packageRoot, "runtime/UniformTypeIdentifiersConstants.m");
15921
+ const object2 = path31.join(args.out, "UniformTypeIdentifiers-NativeConstants.o");
15826
15922
  execFileSync12(
15827
- path30.join(args.bin, "clang"),
15923
+ path31.join(args.bin, "clang"),
15828
15924
  [
15829
15925
  "--target=wasm64-unknown-wasip1-threads",
15830
15926
  ...wasmThreadFlags,
@@ -15834,7 +15930,7 @@ function compileUniformTypeConstants(args) {
15834
15930
  ...swiftObjCRuntimeFlags,
15835
15931
  "-fwasm-exceptions",
15836
15932
  "-F",
15837
- path30.resolve(args.packageRoot, "../peachsim/sdk/ios/System/Library/Frameworks"),
15933
+ path31.resolve(args.packageRoot, "../peachsim/sdk/ios/System/Library/Frameworks"),
15838
15934
  ...objcSdkIntakeFlags(args.darwin, args.bin, args.minimum),
15839
15935
  "-c",
15840
15936
  source,
@@ -15848,12 +15944,12 @@ function compileUniformTypeConstants(args) {
15848
15944
 
15849
15945
  // src/xcode-header-search.ts
15850
15946
  import fs12 from "node:fs";
15851
- import path31 from "node:path";
15947
+ import path32 from "node:path";
15852
15948
  function coalescibleHeaderOverlays(files) {
15853
15949
  const aliases = /* @__PURE__ */ new Map();
15854
15950
  const key = (file) => file.replace(/[A-Z]/g, (letter) => letter.toLowerCase());
15855
15951
  const index = (directory, entry) => {
15856
- const name = path31.resolve(directory, entry.name);
15952
+ const name = path32.resolve(directory, entry.name);
15857
15953
  if (entry.type === "directory")
15858
15954
  return entry.contents.every((child) => index(name, child));
15859
15955
  const source = entry["external-contents"];
@@ -15864,11 +15960,11 @@ function coalescibleHeaderOverlays(files) {
15864
15960
  };
15865
15961
  for (const file of files) {
15866
15962
  const overlay = JSON.parse(fs12.readFileSync(file, "utf8"));
15867
- if (!overlay.roots.every((entry) => index(path31.dirname(file), entry)))
15963
+ if (!overlay.roots.every((entry) => index(path32.dirname(file), entry)))
15868
15964
  return /* @__PURE__ */ new Set();
15869
15965
  }
15870
15966
  for (const file of [...files, ...aliases.values()]) {
15871
- const source = aliases.get(key(path31.normalize(file)));
15967
+ const source = aliases.get(key(path32.normalize(file)));
15872
15968
  if (source !== void 0 && source !== file) return /* @__PURE__ */ new Set();
15873
15969
  }
15874
15970
  return files;
@@ -15928,11 +16024,11 @@ function writeXcodeHeaderSearch(directory, targets, headerAliases = {}, listed)
15928
16024
  seen.add(file);
15929
16025
  file = headerAliases[file];
15930
16026
  }
15931
- const listed2 = productDirectories.get(path31.dirname(product)) ?? [];
15932
- productDirectories.set(path31.dirname(product), listed2);
15933
- listed2.push({ name: path31.basename(product), file });
16027
+ const listed2 = productDirectories.get(path32.dirname(product)) ?? [];
16028
+ productDirectories.set(path32.dirname(product), listed2);
16029
+ listed2.push({ name: path32.basename(product), file });
15934
16030
  }
15935
- const overlay = path31.join(directory, "all-product-headers.yaml");
16031
+ const overlay = path32.join(directory, "all-product-headers.yaml");
15936
16032
  writeBuildFile(
15937
16033
  overlay,
15938
16034
  JSON.stringify({
@@ -15952,7 +16048,7 @@ function writeXcodeHeaderSearch(directory, targets, headerAliases = {}, listed)
15952
16048
  const files = [overlay];
15953
16049
  const flags = targets.map((target, index) => {
15954
16050
  const maps = target.headerMaps.map((map, order) => {
15955
- const file = path31.join(directory, `${index}-${order}.hmap`);
16051
+ const file = path32.join(directory, `${index}-${order}.hmap`);
15956
16052
  writeBuildFile(file, headerMap(map.entries));
15957
16053
  files.push(file);
15958
16054
  return { flag: map.flag, file };
@@ -16091,7 +16187,7 @@ function assertSwiftBuildCores() {
16091
16187
  );
16092
16188
  }
16093
16189
  function swiftDistributionAt(root) {
16094
- const file = path32.join(root, SWIFT_DISTRIBUTION_MANIFEST);
16190
+ const file = path33.join(root, SWIFT_DISTRIBUTION_MANIFEST);
16095
16191
  const stat = statSync4(file, { bigint: true, throwIfNoEntry: false });
16096
16192
  if (!stat) return null;
16097
16193
  const identity = `${stat.dev}:${stat.ino}:${stat.size}:${stat.mtimeNs}`;
@@ -16105,28 +16201,28 @@ var distributionManifests = /* @__PURE__ */ new Map();
16105
16201
  var distributionCompileViews = /* @__PURE__ */ new WeakMap();
16106
16202
  function swiftDistributionCompileView(moduleRoot, distribution) {
16107
16203
  let view = distributionCompileViews.get(distribution);
16108
- if (!view || !existsSync9(view)) {
16204
+ if (!view || !existsSync10(view)) {
16109
16205
  const inputs = Object.entries(distribution.files).filter(
16110
16206
  ([file]) => file.startsWith("host/") || file === SWIFT_DISTRIBUTION_OBJC_SELECTORS
16111
16207
  ).sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0);
16112
16208
  const digest = createHash18("sha256").update(JSON.stringify(inputs)).digest("hex");
16113
- view = path32.join(swiftCacheDir(), "swift-sdk-views", `compile-${digest}`);
16114
- if (!existsSync9(view)) {
16115
- mkdirSync8(path32.dirname(view), { recursive: true });
16209
+ view = path33.join(swiftCacheDir(), "swift-sdk-views", `compile-${digest}`);
16210
+ if (!existsSync10(view)) {
16211
+ mkdirSync8(path33.dirname(view), { recursive: true });
16116
16212
  const staging = mkdtempSync4(`${view}-`);
16117
16213
  try {
16118
16214
  chmodSync3(staging, 493);
16119
16215
  for (const [file] of inputs) {
16120
16216
  if (!isSwiftResourcePath(file))
16121
16217
  throw new Error(`invalid Swift distribution compile path ${file}`);
16122
- const destination = path32.join(staging, file);
16123
- mkdirSync8(path32.dirname(destination), { recursive: true });
16124
- copyFileSync2(path32.join(moduleRoot, file), destination);
16218
+ const destination = path33.join(staging, file);
16219
+ mkdirSync8(path33.dirname(destination), { recursive: true });
16220
+ copyFileSync2(path33.join(moduleRoot, file), destination);
16125
16221
  }
16126
16222
  try {
16127
- renameSync6(staging, view);
16223
+ renameSync5(staging, view);
16128
16224
  } catch (error) {
16129
- if (!existsSync9(view)) throw error;
16225
+ if (!existsSync10(view)) throw error;
16130
16226
  }
16131
16227
  } finally {
16132
16228
  rmSync7(staging, { recursive: true, force: true });
@@ -16143,19 +16239,19 @@ var REACH_STAGED_FRAMEWORKS = /* @__PURE__ */ new Set(["React"]);
16143
16239
  function swiftModuleInterface(moduleRoot, name) {
16144
16240
  if (REACH_STAGED_FRAMEWORKS.has(name)) return null;
16145
16241
  if (swiftDistributionAt(moduleRoot)) {
16146
- const file = path32.join(moduleRoot, "modules", `${name}-Swift.h`);
16147
- if (!existsSync9(file)) return null;
16242
+ const file = path33.join(moduleRoot, "modules", `${name}-Swift.h`);
16243
+ if (!existsSync10(file)) return null;
16148
16244
  const header = clangInterfaceHeader(readFileSync16(file, "utf8"), moduleRoot);
16149
16245
  return { declared: swiftInterfaceDeclarations(header), header };
16150
16246
  }
16151
- const sources = path32.join(moduleRoot, "Sources", name);
16152
- const built = path32.join(moduleRoot, ".build/host", `${name}-Swift.h`);
16153
- if (!existsSync9(sources) || !existsSync9(built)) return null;
16247
+ const sources = path33.join(moduleRoot, "Sources", name);
16248
+ const built = path33.join(moduleRoot, ".build/host", `${name}-Swift.h`);
16249
+ if (!existsSync10(sources) || !existsSync10(built)) return null;
16154
16250
  const declared = /* @__PURE__ */ new Set();
16155
16251
  for (const file of readdirSync6(sources, { recursive: true, encoding: "utf8" }))
16156
16252
  if (file.endsWith(".swift"))
16157
16253
  for (const [, objc, subclass] of readFileSync16(
16158
- path32.join(sources, file),
16254
+ path33.join(sources, file),
16159
16255
  "utf8"
16160
16256
  ).matchAll(
16161
16257
  /@objc\((\w+)\)\s+(?:\w+\s+)*?(?:protocol|class)\s|^(?:public|open)\s+(?:final\s+)?class\s+(\w+)\s*:\s*NSObject\b/gm
@@ -16169,7 +16265,7 @@ function swiftModuleInterface(moduleRoot, name) {
16169
16265
  }
16170
16266
  function clangInterfaceHeader(header, moduleRoot) {
16171
16267
  const distribution = swiftDistributionAt(moduleRoot) !== null;
16172
- const frameworks = path32.join(
16268
+ const frameworks = path33.join(
16173
16269
  swiftSharedSdkSourceRoot(moduleRoot, distribution),
16174
16270
  "System/Library/Frameworks"
16175
16271
  );
@@ -16182,8 +16278,8 @@ function clangInterfaceHeader(header, moduleRoot) {
16182
16278
  (_, module, framework) => {
16183
16279
  const imports = [`@import ${framework};`];
16184
16280
  imported.add(framework);
16185
- const directory = distribution ? path32.join(moduleRoot, "modules", module) : path32.join(moduleRoot, "Sources", module, "include");
16186
- if (!existsSync9(directory)) return imports[0];
16281
+ const directory = distribution ? path33.join(moduleRoot, "modules", module) : path33.join(moduleRoot, "Sources", module, "include");
16282
+ if (!existsSync10(directory)) return imports[0];
16187
16283
  if (!references) {
16188
16284
  references = new Set(header.match(/\b[A-Z]\w*\b/g));
16189
16285
  for (const name of objcEnumerations(header)) references.delete(name);
@@ -16211,7 +16307,7 @@ var clangDeclarationEnumCache = /* @__PURE__ */ new Map();
16211
16307
  function clangDeclarationEnums(directory) {
16212
16308
  const cached = clangDeclarationEnumCache.get(directory);
16213
16309
  if (cached) return cached;
16214
- const enums = readdirSync6(directory).filter((file) => file.endsWith(".h")).flatMap((file) => objcEnumerations(readFileSync16(path32.join(directory, file), "utf8")));
16310
+ const enums = readdirSync6(directory).filter((file) => file.endsWith(".h")).flatMap((file) => objcEnumerations(readFileSync16(path33.join(directory, file), "utf8")));
16215
16311
  clangDeclarationEnumCache.set(directory, enums);
16216
16312
  return enums;
16217
16313
  }
@@ -16246,11 +16342,11 @@ function sdkObjCDeclarationOwners(frameworks) {
16246
16342
  const owners = /* @__PURE__ */ new Map();
16247
16343
  for (const framework of readdirSync6(frameworks))
16248
16344
  if (framework.endsWith(".framework")) {
16249
- const headers = path32.join(frameworks, framework, "Headers");
16250
- if (existsSync9(headers)) {
16345
+ const headers = path33.join(frameworks, framework, "Headers");
16346
+ if (existsSync10(headers)) {
16251
16347
  for (const file of readdirSync6(headers, { recursive: true, encoding: "utf8" }))
16252
16348
  if (file.endsWith(".h")) {
16253
- const header = readFileSync16(path32.join(headers, file), "utf8");
16349
+ const header = readFileSync16(path33.join(headers, file), "utf8");
16254
16350
  for (const name of [
16255
16351
  ...swiftInterfaceDeclarations(header),
16256
16352
  ...objcEnumerations(header),
@@ -16349,7 +16445,7 @@ function swiftCompileSdkOptions(moduleRoot, toolchainBin) {
16349
16445
  }
16350
16446
  function swiftObjCSelectorOptions(moduleRoot) {
16351
16447
  const distribution = swiftDistributionAt(moduleRoot);
16352
- let map = path32.join(
16448
+ let map = path33.join(
16353
16449
  distribution ? swiftDistributionCompileView(moduleRoot, distribution) : moduleRoot,
16354
16450
  SWIFT_DISTRIBUTION_OBJC_SELECTORS
16355
16451
  );
@@ -16359,18 +16455,21 @@ function swiftObjCSelectorOptions(moduleRoot) {
16359
16455
  for (const [name, members] of Object.entries(
16360
16456
  JSON.parse(
16361
16457
  readFileSync16(
16362
- path32.join(moduleRoot, "Sources", framework, "ObjCSelectors.json"),
16458
+ path33.join(moduleRoot, "Sources", framework, "ObjCSelectors.json"),
16363
16459
  "utf8"
16364
16460
  )
16365
16461
  ).classes
16366
16462
  ))
16367
16463
  classes[name] = [...classes[name] ?? [], ...members];
16368
- map = path32.join(moduleRoot, ".build", SWIFT_DISTRIBUTION_OBJC_SELECTORS);
16369
- mkdirSync8(path32.dirname(map), { recursive: true });
16370
- const partial = `${map}.${randomUUID5()}`;
16371
- writeFileSync8(partial, `${JSON.stringify({ classes }, null, 2)}
16372
- `);
16373
- renameSync6(partial, map);
16464
+ map = path33.join(moduleRoot, ".build", SWIFT_DISTRIBUTION_OBJC_SELECTORS);
16465
+ const content = `${JSON.stringify({ classes }, null, 2)}
16466
+ `;
16467
+ if (!existsSync10(map) || readFileSync16(map, "utf8") !== content) {
16468
+ mkdirSync8(path33.dirname(map), { recursive: true });
16469
+ const partial = `${map}.${randomUUID5()}`;
16470
+ writeFileSync8(partial, content);
16471
+ renameSync5(partial, map);
16472
+ }
16374
16473
  }
16375
16474
  return ["-Xswiftc", "-Xllvm", "-Xswiftc", `-peach-objc-selector-map=${map}`];
16376
16475
  }
@@ -16408,7 +16507,7 @@ function swiftModuleInputFiles(root) {
16408
16507
  "toolchain.json"
16409
16508
  ];
16410
16509
  const walk = (dir) => {
16411
- for (const entry of readdirSync6(path32.join(root, dir), {
16510
+ for (const entry of readdirSync6(path33.join(root, dir), {
16412
16511
  withFileTypes: true
16413
16512
  })) {
16414
16513
  const relative = `${dir}/${entry.name}`;
@@ -16424,48 +16523,48 @@ function swiftModuleInputFiles(root) {
16424
16523
  walk("ios-simulator-stdlib");
16425
16524
  return files.sort();
16426
16525
  }
16427
- function swiftMacroPlugins(moduleRoot, dir = path32.join(moduleRoot, ".build/host/RnxPreviewMacros")) {
16526
+ function swiftMacroPlugins(moduleRoot, dir = path33.join(moduleRoot, ".build/host/RnxPreviewMacros")) {
16428
16527
  const distribution = swiftDistributionAt(moduleRoot);
16429
16528
  if (distribution) {
16430
16529
  const view = swiftDistributionCompileView(moduleRoot, distribution);
16431
16530
  return {
16432
- libraries: distribution.plugins.filter((plugin) => path32.basename(plugin) !== "ExpoModulesMacros").map((plugin) => path32.join(view, plugin)),
16433
- executables: distribution.plugins.filter((plugin) => path32.basename(plugin) === "ExpoModulesMacros").map((plugin) => path32.join(view, plugin)),
16531
+ libraries: distribution.plugins.filter((plugin) => path33.basename(plugin) !== "ExpoModulesMacros").map((plugin) => path33.join(view, plugin)),
16532
+ executables: distribution.plugins.filter((plugin) => path33.basename(plugin) === "ExpoModulesMacros").map((plugin) => path33.join(view, plugin)),
16434
16533
  stale: false
16435
16534
  };
16436
16535
  }
16437
16536
  const release = JSON.parse(
16438
- readFileSync16(path32.join(moduleRoot, "toolchain.json"), "utf8")
16537
+ readFileSync16(path33.join(moduleRoot, "toolchain.json"), "utf8")
16439
16538
  ).release;
16440
- const compilerStamp = path32.join(dir, "compiler-release");
16441
- const pluginScript = path32.join(moduleRoot, "scripts/build-preview-plugin.sh");
16442
- const expoPlugin = path32.join(dir, "ExpoModulesMacros");
16539
+ const compilerStamp = path33.join(dir, "compiler-release");
16540
+ const pluginScript = path33.join(moduleRoot, "scripts/build-preview-plugin.sh");
16541
+ const expoPlugin = path33.join(dir, "ExpoModulesMacros");
16443
16542
  const ext = process.platform === "darwin" ? "dylib" : "so";
16444
16543
  const plugins = [
16445
16544
  {
16446
- library: path32.join(dir, `libRnxPreviewMacros.${ext}`),
16447
- sources: [path32.join(moduleRoot, "Sources/RnxPreviewMacros/PreviewMacro.swift")]
16545
+ library: path33.join(dir, `libRnxPreviewMacros.${ext}`),
16546
+ sources: [path33.join(moduleRoot, "Sources/RnxPreviewMacros/PreviewMacro.swift")]
16448
16547
  },
16449
16548
  {
16450
- library: path32.join(dir, `libFoundationMacros.${ext}`),
16549
+ library: path33.join(dir, `libFoundationMacros.${ext}`),
16451
16550
  sources: [
16452
- path32.join(moduleRoot, "Sources/FoundationMacros/PredicateMacro.swift"),
16453
- path32.join(moduleRoot, "Sources/SwiftMacroSupport/PredicateExpression.swift")
16551
+ path33.join(moduleRoot, "Sources/FoundationMacros/PredicateMacro.swift"),
16552
+ path33.join(moduleRoot, "Sources/SwiftMacroSupport/PredicateExpression.swift")
16454
16553
  ]
16455
16554
  },
16456
16555
  {
16457
- library: path32.join(dir, `libTipKitMacros.${ext}`),
16556
+ library: path33.join(dir, `libTipKitMacros.${ext}`),
16458
16557
  sources: [
16459
- path32.join(moduleRoot, "Sources/TipKitMacros/TipKitMacros.swift"),
16460
- path32.join(moduleRoot, "Sources/SwiftMacroSupport/PredicateExpression.swift")
16558
+ path33.join(moduleRoot, "Sources/TipKitMacros/TipKitMacros.swift"),
16559
+ path33.join(moduleRoot, "Sources/SwiftMacroSupport/PredicateExpression.swift")
16461
16560
  ]
16462
16561
  }
16463
16562
  ];
16464
16563
  return {
16465
16564
  libraries: plugins.map(({ library }) => library),
16466
16565
  executables: [expoPlugin],
16467
- stale: !existsSync9(compilerStamp) || !existsSync9(expoPlugin) || statSync4(pluginScript).mtimeMs > statSync4(expoPlugin).mtimeMs || readFileSync16(compilerStamp, "utf8").trim() !== release || plugins.some(
16468
- ({ library, sources }) => !existsSync9(library) || sources.some((source) => statSync4(source).mtimeMs > statSync4(library).mtimeMs)
16566
+ stale: !existsSync10(compilerStamp) || !existsSync10(expoPlugin) || statSync4(pluginScript).mtimeMs > statSync4(expoPlugin).mtimeMs || readFileSync16(compilerStamp, "utf8").trim() !== release || plugins.some(
16567
+ ({ library, sources }) => !existsSync10(library) || sources.some((source) => statSync4(source).mtimeMs > statSync4(library).mtimeMs)
16469
16568
  )
16470
16569
  };
16471
16570
  }
@@ -16475,14 +16574,14 @@ async function ensureMacroPlugins(moduleRoot, toolchainBin, release, signal, lea
16475
16574
  await runCompiler(
16476
16575
  "sh",
16477
16576
  [
16478
- path32.join(moduleRoot, "scripts/build-preview-plugin.sh"),
16577
+ path33.join(moduleRoot, "scripts/build-preview-plugin.sh"),
16479
16578
  toolchainBin,
16480
16579
  libraries[0]
16481
16580
  ],
16482
16581
  { signal, lease }
16483
16582
  );
16484
16583
  writeFileSync8(
16485
- path32.join(path32.dirname(libraries[0]), "compiler-release"),
16584
+ path33.join(path33.dirname(libraries[0]), "compiler-release"),
16486
16585
  `${release}
16487
16586
  `
16488
16587
  );
@@ -16494,11 +16593,74 @@ function clearLinkedModuleDigests(root) {
16494
16593
  if (root === void 0) linkedModuleDigests.clear();
16495
16594
  else linkedModuleDigests.delete(root);
16496
16595
  }
16596
+ function gitCleanModuleInputsKey(root, files) {
16597
+ if (swiftDistributionAt(root)) return null;
16598
+ const top = spawnSync5("git", ["-C", root, "rev-parse", "--show-toplevel"], {
16599
+ encoding: "utf8",
16600
+ stdio: ["ignore", "pipe", "ignore"]
16601
+ });
16602
+ if (top.status !== 0) return null;
16603
+ const repoTop = top.stdout.trim();
16604
+ if (!repoTop) return null;
16605
+ const realTop = realpathSync6(repoTop);
16606
+ const realRoot = realpathSync6(root);
16607
+ const collapsedDirs = [
16608
+ path33.join(realRoot, "Sources"),
16609
+ path33.join(realRoot, "cross-import-overlays"),
16610
+ path33.join(realRoot, "ios-simulator-stdlib"),
16611
+ realpathSync6(path33.resolve(realRoot, "../peachsim/sdk/ios"))
16612
+ ];
16613
+ const scoped = /* @__PURE__ */ new Set();
16614
+ for (const dir of collapsedDirs) {
16615
+ const rel = path33.relative(realTop, dir).split(path33.sep).join("/");
16616
+ if (!rel || rel.startsWith("../")) return null;
16617
+ scoped.add(rel);
16618
+ }
16619
+ for (const file of files) {
16620
+ const full = path33.resolve(realRoot, file);
16621
+ if (collapsedDirs.some((dir) => full.startsWith(dir + path33.sep))) continue;
16622
+ const rel = path33.relative(realTop, full).split(path33.sep).join("/");
16623
+ if (!rel || rel.startsWith("../")) return null;
16624
+ scoped.add(rel);
16625
+ }
16626
+ const paths = [...scoped].sort();
16627
+ const status = spawnSync5(
16628
+ "git",
16629
+ [
16630
+ "-C",
16631
+ realTop,
16632
+ "status",
16633
+ "--porcelain",
16634
+ "--untracked-files=all",
16635
+ "--ignored=matching",
16636
+ "--",
16637
+ ...paths
16638
+ ],
16639
+ {
16640
+ encoding: "utf8",
16641
+ stdio: ["ignore", "pipe", "ignore"],
16642
+ maxBuffer: 16 * 1024 * 1024
16643
+ }
16644
+ );
16645
+ if (status.status !== 0 || status.stdout.trim().length > 0) return null;
16646
+ const oids = spawnSync5(
16647
+ "git",
16648
+ ["-C", realTop, "rev-parse", ...paths.map((entry) => `HEAD:${entry}`)],
16649
+ { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }
16650
+ );
16651
+ if (oids.status !== 0) return null;
16652
+ const keyHash = createHash18("sha256");
16653
+ keyHash.update("git-module-digest/v1\n");
16654
+ keyHash.update(oids.stdout);
16655
+ keyHash.update("\n");
16656
+ for (const file of files) keyHash.update(file).update("\n");
16657
+ return keyHash.digest("hex");
16658
+ }
16497
16659
  function swiftModuleDigest(root) {
16498
16660
  const files = swiftModuleInputFiles(root);
16499
16661
  const stampHash = createHash18("sha256");
16500
16662
  for (const file of files) {
16501
- const stat = statSync4(path32.join(root, file), { bigint: true });
16663
+ const stat = statSync4(path33.join(root, file), { bigint: true });
16502
16664
  stampHash.update(file);
16503
16665
  stampHash.update(
16504
16666
  `${stat.dev}:${stat.ino}:${stat.size}:${stat.mtimeNs}:${stat.ctimeNs}
@@ -16508,12 +16670,18 @@ function swiftModuleDigest(root) {
16508
16670
  const stamp = stampHash.digest("hex");
16509
16671
  const cached = linkedModuleDigests.get(root);
16510
16672
  if (cached?.stamp === stamp) return cached.digest;
16511
- const record = path32.join(
16512
- swiftCacheDir(),
16513
- "swift-module-digests",
16673
+ const digestDir = path33.join(swiftCacheDir(), "swift-module-digests");
16674
+ const record = path33.join(
16675
+ digestDir,
16514
16676
  `${createHash18("sha256").update(root).digest("hex")}.json`
16515
16677
  );
16516
- if (existsSync9(record)) {
16678
+ const writeRecord = (target, body) => {
16679
+ mkdirSync8(path33.dirname(target), { recursive: true });
16680
+ const partial = `${target}.${process.pid}.${randomUUID5()}`;
16681
+ writeFileSync8(partial, body);
16682
+ renameSync5(partial, target);
16683
+ };
16684
+ if (existsSync10(record)) {
16517
16685
  const saved = JSON.parse(readFileSync16(record, "utf8"));
16518
16686
  if (saved && typeof saved === "object" && Reflect.get(saved, "stamp") === stamp && typeof Reflect.get(saved, "digest") === "string") {
16519
16687
  const digest2 = Buffer.from(String(Reflect.get(saved, "digest")), "hex");
@@ -16521,19 +16689,30 @@ function swiftModuleDigest(root) {
16521
16689
  return digest2;
16522
16690
  }
16523
16691
  }
16692
+ const gitKey = gitCleanModuleInputsKey(root, files);
16693
+ const gitRecord = gitKey ? path33.join(digestDir, `git-${gitKey}.json`) : null;
16694
+ if (gitRecord && existsSync10(gitRecord)) {
16695
+ const saved = JSON.parse(readFileSync16(gitRecord, "utf8"));
16696
+ if (saved && typeof saved === "object" && typeof Reflect.get(saved, "digest") === "string") {
16697
+ const hex2 = String(Reflect.get(saved, "digest"));
16698
+ const digest2 = Buffer.from(hex2, "hex");
16699
+ linkedModuleDigests.set(root, { stamp, digest: digest2 });
16700
+ writeRecord(record, JSON.stringify({ stamp, digest: hex2 }));
16701
+ return digest2;
16702
+ }
16703
+ }
16524
16704
  const hash = createHash18("sha256");
16525
16705
  for (const file of files) {
16526
16706
  hash.update(createHash18("sha256").update(file).digest());
16527
16707
  hash.update(
16528
- createHash18("sha256").update(readFileSync16(path32.join(root, file))).digest()
16708
+ createHash18("sha256").update(readFileSync16(path33.join(root, file))).digest()
16529
16709
  );
16530
16710
  }
16531
16711
  const digest = hash.digest();
16712
+ const hex = digest.toString("hex");
16532
16713
  linkedModuleDigests.set(root, { stamp, digest });
16533
- mkdirSync8(path32.dirname(record), { recursive: true });
16534
- const partial = `${record}.${process.pid}.${randomUUID5()}`;
16535
- writeFileSync8(partial, JSON.stringify({ stamp, digest: digest.toString("hex") }));
16536
- renameSync6(partial, record);
16714
+ writeRecord(record, JSON.stringify({ stamp, digest: hex }));
16715
+ if (gitRecord) writeRecord(gitRecord, JSON.stringify({ digest: hex }));
16537
16716
  return digest;
16538
16717
  }
16539
16718
  var compileSurfaces = /* @__PURE__ */ new WeakMap();
@@ -16605,7 +16784,7 @@ function withNativeSourceGlue(input, glue) {
16605
16784
  ...input,
16606
16785
  files: {
16607
16786
  ...input.files,
16608
- [path32.posix.join(targetPath, "OneNativeSource.generated.swift")]: glue
16787
+ [path33.posix.join(targetPath, "OneNativeSource.generated.swift")]: glue
16609
16788
  },
16610
16789
  oneModule: true
16611
16790
  };
@@ -16763,7 +16942,7 @@ function swiftImportNames(contents2, available) {
16763
16942
  function swiftPeachModules(moduleRoot) {
16764
16943
  const distribution = swiftDistributionAt(moduleRoot);
16765
16944
  return distribution ? distribution.modules : swiftManifestDeclarations(
16766
- readFileSync16(path32.join(moduleRoot, "Package.swift"), "utf8")
16945
+ readFileSync16(path33.join(moduleRoot, "Package.swift"), "utf8")
16767
16946
  ).filter((target) => !target.executable && !target.path.startsWith("fixtures/")).map((target) => target.name);
16768
16947
  }
16769
16948
  var sdkPaths = /* @__PURE__ */ new Map();
@@ -16773,7 +16952,7 @@ function swiftSdkPaths(moduleRoot, toolchainBin, options = swiftCompileSdkOption
16773
16952
  const cached = sdkPaths.get(key);
16774
16953
  if (cached) return cached;
16775
16954
  const configuration = execFileSync13(
16776
- path32.join(toolchainBin, "swift"),
16955
+ path33.join(toolchainBin, "swift"),
16777
16956
  ["sdk", "configure", ...options, "--show-configuration", sdk, SWIFT_WASM_TRIPLE],
16778
16957
  { encoding: "utf8", env: swiftEnvironment(), stdio: ["ignore", "pipe", "pipe"] }
16779
16958
  );
@@ -16807,7 +16986,7 @@ function swiftSdkPaths(moduleRoot, toolchainBin, options = swiftCompileSdkOption
16807
16986
  if (flag !== "-fwasm-exceptions") cFlags.push(flag);
16808
16987
  if (flag === "-iframeworkwithsysroot" && options2[index + 2] === "-Xcc" && typeof options2[index + 3] === "string") {
16809
16988
  cFlags.push(options2[index + 3]);
16810
- frameworks.push(path32.join(sysroot, options2[index + 3]));
16989
+ frameworks.push(path33.join(sysroot, options2[index + 3]));
16811
16990
  index += 3;
16812
16991
  continue;
16813
16992
  }
@@ -16824,7 +17003,7 @@ function swiftSdkPaths(moduleRoot, toolchainBin, options = swiftCompileSdkOption
16824
17003
  }
16825
17004
  const paths = {
16826
17005
  sysroot,
16827
- darwin: path32.join(sysroot, "darwin"),
17006
+ darwin: path33.join(sysroot, "darwin"),
16828
17007
  resources: field("swiftResourcesPath"),
16829
17008
  frameworks,
16830
17009
  cFlags
@@ -16852,23 +17031,23 @@ function swiftOverlayFrameworks(moduleRoot, toolchainBin) {
16852
17031
  const { darwin, resources, frameworks } = swiftSdkPaths(moduleRoot, toolchainBin);
16853
17032
  const swiftModules = new Set(swiftPeachModules(moduleRoot));
16854
17033
  const result = /* @__PURE__ */ new Set();
16855
- const include = path32.join(darwin, "usr/include");
17034
+ const include = path33.join(darwin, "usr/include");
16856
17035
  for (const entry of readdirSync6(include))
16857
17036
  if (entry.endsWith(".modulemap"))
16858
17037
  addSwiftOverlayFrameworks(
16859
- readFileSync16(path32.join(include, entry), "utf8"),
17038
+ readFileSync16(path33.join(include, entry), "utf8"),
16860
17039
  swiftModules,
16861
17040
  result
16862
17041
  );
16863
17042
  for (const entry of readdirSync6(resources)) {
16864
- const map = path32.join(resources, entry, "module.modulemap");
16865
- if (existsSync9(map))
17043
+ const map = path33.join(resources, entry, "module.modulemap");
17044
+ if (existsSync10(map))
16866
17045
  addSwiftOverlayFrameworks(readFileSync16(map, "utf8"), swiftModules, result);
16867
17046
  }
16868
17047
  for (const directory of frameworks)
16869
17048
  for (const entry of readdirSync6(directory)) {
16870
- const map = path32.join(directory, entry, "Modules/module.modulemap");
16871
- if (existsSync9(map))
17049
+ const map = path33.join(directory, entry, "Modules/module.modulemap");
17050
+ if (existsSync10(map))
16872
17051
  addSwiftOverlayFrameworks(readFileSync16(map, "utf8"), swiftModules, result);
16873
17052
  }
16874
17053
  sdkOverlayFrameworks.set(key, result);
@@ -16885,50 +17064,50 @@ function swiftAvailableModules(moduleRoot, toolchainBin) {
16885
17064
  toolchainBin
16886
17065
  );
16887
17066
  const maps = /* @__PURE__ */ new Set([
16888
- path32.join(darwin, "usr/include/module.modulemap"),
17067
+ path33.join(darwin, "usr/include/module.modulemap"),
16889
17068
  ...cFlags.filter((flag) => flag.startsWith("-fmodule-map-file=")).map((flag) => {
16890
17069
  const file = flag.slice("-fmodule-map-file=".length);
16891
- return file.startsWith("=") ? path32.join(sysroot, file.slice(1)) : file;
17070
+ return file.startsWith("=") ? path33.join(sysroot, file.slice(1)) : file;
16892
17071
  })
16893
17072
  ]);
16894
17073
  for (const map of maps) {
16895
- if (!existsSync9(map)) continue;
17074
+ if (!existsSync10(map)) continue;
16896
17075
  const contents2 = readFileSync16(map, "utf8");
16897
17076
  for (const match of contents2.matchAll(
16898
17077
  /^(?:explicit\s+)?(?:framework\s+)?module\s+([A-Za-z_]\w*)/gm
16899
17078
  ))
16900
17079
  modules.add(match[1]);
16901
17080
  for (const match of contents2.matchAll(/^\s*extern\s+module\s+\w+\s+"([^"]+)"/gm))
16902
- maps.add(path32.resolve(path32.dirname(map), match[1]));
17081
+ maps.add(path33.resolve(path33.dirname(map), match[1]));
16903
17082
  }
16904
- for (const entry of readdirSync6(path32.join(resources, "wasi"))) {
17083
+ for (const entry of readdirSync6(path33.join(resources, "wasi"))) {
16905
17084
  if (entry.endsWith(".swiftmodule"))
16906
17085
  modules.add(entry.slice(0, -".swiftmodule".length));
16907
17086
  }
16908
17087
  for (const entry of readdirSync6(resources)) {
16909
- const map = path32.join(resources, entry, "module.modulemap");
16910
- if (!existsSync9(map)) continue;
17088
+ const map = path33.join(resources, entry, "module.modulemap");
17089
+ if (!existsSync10(map)) continue;
16911
17090
  for (const match of readFileSync16(map, "utf8").matchAll(/^module\s+([A-Za-z_]\w*)/gm))
16912
17091
  modules.add(match[1]);
16913
17092
  }
16914
17093
  for (const libc of [
16915
- path32.join(darwin, "usr/include"),
16916
- path32.join(
17094
+ path33.join(darwin, "usr/include"),
17095
+ path33.join(
16917
17096
  swiftSharedSdkRoot(moduleRoot, swiftDistributionAt(moduleRoot) !== null),
16918
17097
  "usr/include"
16919
17098
  )
16920
17099
  ])
16921
17100
  for (const entry of readdirSync6(libc)) {
16922
17101
  if (!entry.endsWith(".modulemap")) continue;
16923
- for (const match of readFileSync16(path32.join(libc, entry), "utf8").matchAll(
17102
+ for (const match of readFileSync16(path33.join(libc, entry), "utf8").matchAll(
16924
17103
  /^module\s+([A-Za-z_]\w*)/gm
16925
17104
  ))
16926
17105
  modules.add(match[1]);
16927
17106
  }
16928
17107
  for (const directory of frameworks) {
16929
17108
  for (const entry of readdirSync6(directory)) {
16930
- const map = path32.join(directory, entry, "Modules/module.modulemap");
16931
- if (!existsSync9(map)) continue;
17109
+ const map = path33.join(directory, entry, "Modules/module.modulemap");
17110
+ if (!existsSync10(map)) continue;
16932
17111
  for (const match of readFileSync16(map, "utf8").matchAll(
16933
17112
  /^framework\s+module\s+([A-Za-z_]\w*)/gm
16934
17113
  ))
@@ -17028,15 +17207,15 @@ int EXUpdatesApplyBSDiffPatch(const char * _Nonnull oldFilePath,
17028
17207
  ];
17029
17208
  var CLANG_DISTRIBUTION_MODULES = ".peach-clang-modules";
17030
17209
  function distributionClangModulePresent(modules, name) {
17031
- return existsSync9(path32.join(modules, `${name}.swiftmodule`)) || existsSync9(path32.join(modules, name, "module.modulemap"));
17210
+ return existsSync10(path33.join(modules, `${name}.swiftmodule`)) || existsSync10(path33.join(modules, name, "module.modulemap"));
17032
17211
  }
17033
17212
  function distributionClangModuleMap(root, modules) {
17034
17213
  const missing = DISTRIBUTION_CLANG_MODULES.filter(
17035
17214
  (mod) => !distributionClangModulePresent(modules, mod.name)
17036
17215
  );
17037
17216
  if (missing.length === 0) return null;
17038
- const directory = path32.join(root, CLANG_DISTRIBUTION_MODULES);
17039
- const mapPath = path32.join(directory, "module.modulemap");
17217
+ const directory = path33.join(root, CLANG_DISTRIBUTION_MODULES);
17218
+ const mapPath = path33.join(directory, "module.modulemap");
17040
17219
  const map = missing.map(
17041
17220
  (mod) => `module ${mod.name} {
17042
17221
  requires objc
@@ -17045,9 +17224,9 @@ function distributionClangModuleMap(root, modules) {
17045
17224
  }
17046
17225
  `
17047
17226
  ).join("\n");
17048
- if (existsSync9(mapPath) && readFileSync16(mapPath, "utf8") !== map)
17227
+ if (existsSync10(mapPath) && readFileSync16(mapPath, "utf8") !== map)
17049
17228
  rmSync7(directory, { recursive: true, force: true });
17050
- for (const mod of missing) writeBuildFile(path32.join(directory, mod.header), mod.source);
17229
+ for (const mod of missing) writeBuildFile(path33.join(directory, mod.header), mod.source);
17051
17230
  writeBuildFile(mapPath, map);
17052
17231
  return mapPath;
17053
17232
  }
@@ -17059,14 +17238,14 @@ function providedModulesPath(root, modules, excluded) {
17059
17238
  if (!excluded || excluded.size === 0) return modules;
17060
17239
  const entries2 = readdirSync6(modules).filter((entry) => !excluded.has(entry.replace(/\..*$/, ""))).sort();
17061
17240
  const key = createHash18("sha256").update(JSON.stringify([modules, entries2])).update([...excluded].sort().join("\0")).digest("hex").slice(0, 16);
17062
- const directory = path32.join(root, `.peach-modules-${key}`);
17063
- const complete = path32.join(directory, ".complete");
17064
- if (!existsSync9(complete)) {
17241
+ const directory = path33.join(root, `.peach-modules-${key}`);
17242
+ const complete = path33.join(directory, ".complete");
17243
+ if (!existsSync10(complete)) {
17065
17244
  mkdirSync8(directory, { recursive: true });
17066
17245
  for (const entry of readdirSync6(directory))
17067
- rmSync7(path32.join(directory, entry), { recursive: true, force: true });
17246
+ rmSync7(path33.join(directory, entry), { recursive: true, force: true });
17068
17247
  for (const entry of entries2) {
17069
- symlinkSync2(path32.join(modules, entry), path32.join(directory, entry));
17248
+ symlinkSync2(path33.join(modules, entry), path33.join(directory, entry));
17070
17249
  }
17071
17250
  writeFileSync8(complete, "");
17072
17251
  }
@@ -17080,7 +17259,7 @@ function swiftTargetDependencies(files, targets, frameworks = OPTIONAL_FRAMEWORK
17080
17259
  );
17081
17260
  const names = /* @__PURE__ */ new Set([...frameworks, ...targets.map((target) => target.name)]);
17082
17261
  const entriesByPrefix = new Map(
17083
- targets.map(({ path: path33 }) => [path33 === "." ? "" : `${path33}/`, []])
17262
+ targets.map(({ path: path34 }) => [path34 === "." ? "" : `${path34}/`, []])
17084
17263
  );
17085
17264
  for (const entry of Object.entries(files)) {
17086
17265
  const [file] = entry;
@@ -17115,7 +17294,7 @@ function swiftTargetDependencies(files, targets, frameworks = OPTIONAL_FRAMEWORK
17115
17294
  (excluded) => relative === excluded || relative.startsWith(`${excluded}/`)
17116
17295
  ))
17117
17296
  continue;
17118
- if (nested.some((path33) => file.startsWith(path33))) continue;
17297
+ if (nested.some((path34) => file.startsWith(path34))) continue;
17119
17298
  const imports = file.endsWith(".swift") ? swiftImportNames(contents2) : SWIFT_NATIVE_SOURCE_EXTENSIONS.some((extension) => file.endsWith(extension)) ? clangImportNames(contents2, ownsHeader) : [];
17120
17299
  for (const name of imports) {
17121
17300
  if (names.has(name) && name !== target.name && !(target.dependencies !== void 0 && localNames.has(name)))
@@ -17191,7 +17370,7 @@ ${imports.join("\n")}
17191
17370
  }
17192
17371
  var ONE_IMPLICIT_FLAGS = ', "-Xfrontend", "-import-module", "-Xfrontend", "One"';
17193
17372
  var executableLinkFlags = (root) => ` "-Xclang-linker", "-O0",
17194
- "-Xclang-linker", ${JSON.stringify(`-fuse-ld=${path32.join(root, SWIFT_AUTOLINK_LINKER)}`)},
17373
+ "-Xclang-linker", ${JSON.stringify(`-fuse-ld=${path33.join(root, SWIFT_AUTOLINK_LINKER)}`)},
17195
17374
  "-Xlinker", "-z", "-Xlinker", "stack-size=8372224",
17196
17375
  "-Xlinker", "--stack-first",
17197
17376
  "-Xlinker", "--global-base=8372224",
@@ -17206,7 +17385,7 @@ var darwinRecordsRegion = (quoted2) => quoted2.length ? ["-Wl,--start-lib", ...q
17206
17385
  var REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
17207
17386
  var MULTI_MANIFEST_VERSION = 76;
17208
17387
  var SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
17209
- var compilerSourceDigest = true ? "d4cf22b53d08266bf9bd0238bffe899805f62daeb3d628664ee351830e496cda" : swiftCompilerSourceDigest(import.meta.dirname);
17388
+ var compilerSourceDigest = true ? "834b5c28c27bc5807cbb3c4eed5c44f7de81d47db3e3a8819bea6e6635689b24" : swiftCompilerSourceDigest(import.meta.dirname);
17210
17389
  function swiftArtifactHash(input, release, moduleRoot) {
17211
17390
  return swiftCompileInputHash(input, release).update(swiftModuleDigest(moduleRoot)).digest("hex");
17212
17391
  }
@@ -17306,14 +17485,14 @@ var cFlagArray = (flags) => JSON.stringify(withoutGlogModuleMap(flags));
17306
17485
  var cxxFlagArray = (flags) => JSON.stringify([...nativeCxxCompilerFlags, ...withoutGlogModuleMap(flags)]);
17307
17486
  function swiftCrossImportFlags(moduleRoot, distribution) {
17308
17487
  const manifest = distribution ? swiftDistributionAt(moduleRoot) : null;
17309
- const overlayRoot = manifest ? path32.join(moduleRoot, "modules") : path32.join(moduleRoot, "cross-import-overlays");
17488
+ const overlayRoot = manifest ? path33.join(moduleRoot, "modules") : path33.join(moduleRoot, "cross-import-overlays");
17310
17489
  return readdirSync6(overlayRoot, { encoding: "utf8", recursive: true }).filter((file) => file.endsWith(".swiftoverlay")).sort((left, right) => left.localeCompare(right)).flatMap((file) => [
17311
17490
  "-Xfrontend",
17312
17491
  "-swift-module-cross-import",
17313
17492
  "-Xfrontend",
17314
- path32.basename(path32.dirname(file), ".swiftcrossimport"),
17493
+ path33.basename(path33.dirname(file), ".swiftcrossimport"),
17315
17494
  "-Xfrontend",
17316
- path32.join(overlayRoot, file)
17495
+ path33.join(overlayRoot, file)
17317
17496
  ]);
17318
17497
  }
17319
17498
  function withoutWasmOverlayIsystem(flags) {
@@ -17344,7 +17523,7 @@ function emitSwiftPackageManifest(args) {
17344
17523
  distribution
17345
17524
  } = args;
17346
17525
  const prebuilt = args.prebuilt;
17347
- const distributionModules = distribution ? path32.join(moduleRoot, "modules") : void 0;
17526
+ const distributionModules = distribution ? path33.join(moduleRoot, "modules") : void 0;
17348
17527
  const linkedObjects = Boolean(distribution || prebuilt);
17349
17528
  const cxxFlagsFor = (flags) => args.deferDarwinOverlay ? withoutWasmOverlayIsystem(flags) : flags;
17350
17529
  const packageModules = new Set(
@@ -17354,7 +17533,7 @@ function emitSwiftPackageManifest(args) {
17354
17533
  if (!flag.startsWith("-fmodule-map-file=")) return false;
17355
17534
  const file = flag.slice("-fmodule-map-file=".length).replaceAll(SWIFT_NATIVE_INPUT_ROOT, args.root);
17356
17535
  if (!file.includes("/Pods/Headers/")) return false;
17357
- const map = args.files.get(file) ?? (existsSync9(file) ? readFileSync16(file) : void 0);
17536
+ const map = args.files.get(file) ?? (existsSync10(file) ? readFileSync16(file) : void 0);
17358
17537
  const name = map === void 0 ? void 0 : moduleMapName(map.toString());
17359
17538
  return name !== void 0 && packageModules.has(name);
17360
17539
  };
@@ -17386,7 +17565,7 @@ function emitSwiftPackageManifest(args) {
17386
17565
  const product = parse(
17387
17566
  swiftFrameworkProductSchema,
17388
17567
  JSON.parse(
17389
- readFileSync16(path32.join(moduleRoot, SWIFT_FRAMEWORK_PRODUCT_FILE), "utf8")
17568
+ readFileSync16(path33.join(moduleRoot, SWIFT_FRAMEWORK_PRODUCT_FILE), "utf8")
17390
17569
  )
17391
17570
  );
17392
17571
  const replacedObjects = new Set(
@@ -17400,7 +17579,7 @@ function emitSwiftPackageManifest(args) {
17400
17579
  (name) => !object2.startsWith(`lib/${name}-`) || reachedFrameworks.has(name)
17401
17580
  )
17402
17581
  );
17403
- const quoted2 = (object2) => `"${path32.join(moduleRoot, object2).replaceAll("\\", "\\\\").replaceAll('"', '\\"')}"`;
17582
+ const quoted2 = (object2) => `"${path33.join(moduleRoot, object2).replaceAll("\\", "\\\\").replaceAll('"', '\\"')}"`;
17404
17583
  const categoryObjects = new Set(
17405
17584
  foundationCategoryObjects.map((name) => `lib/Foundation-${name}.o`)
17406
17585
  );
@@ -17439,7 +17618,7 @@ function emitSwiftPackageManifest(args) {
17439
17618
  if (run2.length >= MODULE_MAP_RESPONSE_FILE_RUN) {
17440
17619
  const lines = run2.map((flag) => JSON.stringify(flag)).join("\n") + "\n";
17441
17620
  const digest2 = createHash18("sha256").update(lines).digest("hex");
17442
- const file2 = path32.join(args.root, ".peach-clang-arguments", `${digest2}.rsp`);
17621
+ const file2 = path33.join(args.root, ".peach-clang-arguments", `${digest2}.rsp`);
17443
17622
  args.files.set(file2, lines);
17444
17623
  flags.push(`@${file2}`);
17445
17624
  } else flags.push(...run2);
@@ -17463,7 +17642,7 @@ function emitSwiftPackageManifest(args) {
17463
17642
  endRun();
17464
17643
  const content = JSON.stringify(flags);
17465
17644
  const digest = createHash18("sha256").update(content).digest("hex");
17466
- const file = path32.join(args.root, ".peach-manifest-arguments", `${digest}.json`);
17645
+ const file = path33.join(args.root, ".peach-manifest-arguments", `${digest}.json`);
17467
17646
  args.files.set(file, content);
17468
17647
  return `peachCompilerArguments(${JSON.stringify(file)})`;
17469
17648
  };
@@ -17475,7 +17654,7 @@ function emitSwiftPackageManifest(args) {
17475
17654
  const compact = args.coalescibleOverlays ? compactSwiftClangOverlays(macros, args.coalescibleOverlays) : macros;
17476
17655
  const content = compact.map((flag) => JSON.stringify(flag)).join("\n") + "\n";
17477
17656
  const digest = createHash18("sha256").update(content).digest("hex");
17478
- const file = path32.join(args.root, ".peach-swift-arguments", `${digest}.rsp`);
17657
+ const file = path33.join(args.root, ".peach-swift-arguments", `${digest}.rsp`);
17479
17658
  args.files.set(file, content);
17480
17659
  return JSON.stringify([`@${file}`]);
17481
17660
  };
@@ -17487,7 +17666,7 @@ function emitSwiftPackageManifest(args) {
17487
17666
  owner?.publicHeadersPath ?? ""
17488
17667
  );
17489
17668
  return [
17490
- ...owner && framework ? [path32.posix.join(args.root, owner.path, framework[1])] : [],
17669
+ ...owner && framework ? [path33.posix.join(args.root, owner.path, framework[1])] : [],
17491
17670
  ...frameworkDirectories(dependency, seen)
17492
17671
  ];
17493
17672
  });
@@ -17530,7 +17709,7 @@ function emitSwiftPackageManifest(args) {
17530
17709
  const stanza = (target) => {
17531
17710
  const native = args.native?.get(target.name);
17532
17711
  if (target.systemLibrary || native?.clang?.sources.length === 0)
17533
- return ` .systemLibrary(name: ${JSON.stringify(target.name)}, path: ${JSON.stringify(native?.clang ? path32.posix.dirname(native.clang.modulemap) : target.path)}),`;
17712
+ return ` .systemLibrary(name: ${JSON.stringify(target.name)}, path: ${JSON.stringify(native?.clang ? path33.posix.dirname(native.clang.modulemap) : target.path)}),`;
17534
17713
  const isolation = target.mainActorIsolation ? " .defaultIsolation(MainActor.self)," : "";
17535
17714
  const interoperability = target.cxxInterop ? " .interoperabilityMode(.Cxx)," : "";
17536
17715
  const defines = (target.defines ?? []).map((name) => ` .define(${JSON.stringify(name)}),`).join("");
@@ -17588,7 +17767,7 @@ function emitSwiftPackageManifest(args) {
17588
17767
  ].map((flag) => `, ${JSON.stringify(flag)}`).join("");
17589
17768
  const header = args.headerDirectory && (args.nativeHeaderDeclarations?.[target.name] || [...args.native?.values() ?? []].some(
17590
17769
  (value) => value.late?.producers.includes(target.name)
17591
- )) ? `, "-emit-objc-header-path", ${JSON.stringify(path32.join(args.headerDirectory, `${target.name}-Swift.original.h`))}` : "";
17770
+ )) ? `, "-emit-objc-header-path", ${JSON.stringify(path33.join(args.headerDirectory, `${target.name}-Swift.original.h`))}` : "";
17592
17771
  const clangMode = target.cxxInterop ? "" : ', "-Xcc", "-fno-cxx-modules"';
17593
17772
  const deployment = `, "-Xfrontend", "-peach-ios-deployment-target", "-Xfrontend", ${JSON.stringify(target.iosDeploymentTarget ?? SWIFTPM_DEFAULT_IOS_DEPLOYMENT_TARGET)}`;
17594
17773
  const swiftSettings = `swiftSettings: [.swiftLanguageMode(.v${target.languageMode}),${isolation}${interoperability}${defines}${features}${upcoming} .unsafeFlags(${swiftFlagArray(`["-Osize", "-Xfrontend", "-enable-cross-import-overlays"${overlayFlags}${oneModule ? ONE_IMPLICIT_FLAGS : ""}${imports}${nativeImportFlags}${objcFlags}${header}${clangMode}${deployment}${upstream}]`)})]`;
@@ -17789,10 +17968,10 @@ ${declaration.replace(/,$/, "")}
17789
17968
  function syncSwiftTree(base, files) {
17790
17969
  mkdirSync8(base, { recursive: true });
17791
17970
  const kept = /* @__PURE__ */ new Set();
17792
- for (const file of files.keys()) if (existsSync9(file)) kept.add(statSync4(file).ino);
17971
+ for (const file of files.keys()) if (existsSync10(file)) kept.add(statSync4(file).ino);
17793
17972
  const walk = (dir) => {
17794
17973
  for (const entry of readdirSync6(dir, { withFileTypes: true })) {
17795
- const full = path32.join(dir, entry.name);
17974
+ const full = path33.join(dir, entry.name);
17796
17975
  if (dir === base && (entry.name === ".build" || entry.name === SWIFT_CACHE_HOLD_MARKER || entry.name.startsWith(".peach-modules-") || // distribution clang maps are written beside the project, so a sync
17797
17976
  // must not remove them.
17798
17977
  entry.name === CLANG_DISTRIBUTION_MODULES || entry.name === SWIFT_DISTRIBUTION_MIRROR || entry.name === SWIFT_LINK_STAMP))
@@ -17949,7 +18128,7 @@ function compiledSwiftSources(files, targets, overlayFrameworks, headers, native
17949
18128
  const { onWasm, withoutWasm } = swiftTargetArchitectures(targets, swiftSources, headers);
17950
18129
  return new Map(
17951
18130
  [...owners].map(([file, { source, owner }]) => {
17952
- if (nativeSourceGlue && path32.posix.basename(file) === "OneNativeSource.generated.swift")
18131
+ if (nativeSourceGlue && path33.posix.basename(file) === "OneNativeSource.generated.swift")
17953
18132
  return [file, source];
17954
18133
  const manifest = /(?:^|\/)Package(?:@swift-[\d.]+)?\.swift$/.test(file);
17955
18134
  if (manifest && (!owner || /^Package(?:@swift-[\d.]+)?\.swift$/.test(file)))
@@ -18570,7 +18749,7 @@ function swiftApplicationEntry(file, source) {
18570
18749
  else if (source[at] === "}") depth--;
18571
18750
  else if (depth === 0 && /^@(?:main|UIApplicationMain)\b/.test(source.slice(at)))
18572
18751
  return true;
18573
- else if (depth === 0 && path32.basename(file) === "main.swift" && /^UIApplicationMain\s*\(/.test(source.slice(at)))
18752
+ else if (depth === 0 && path33.basename(file) === "main.swift" && /^UIApplicationMain\s*\(/.test(source.slice(at)))
18574
18753
  return true;
18575
18754
  }
18576
18755
  return false;
@@ -18966,17 +19145,17 @@ function prepareSwiftDependency(source, destination, overlayFrameworks) {
18966
19145
  for (const entry of readdirSync6(from, { withFileTypes: true })) {
18967
19146
  if (entry.name === ".git" || entry.name === ".build" || entry.name === ".swiftpm")
18968
19147
  continue;
18969
- const file = path32.join(from, entry.name);
19148
+ const file = path33.join(from, entry.name);
18970
19149
  if (entry.isDirectory()) gather(file);
18971
19150
  else if (entry.isFile() && entry.name.endsWith(".swift"))
18972
- origins[path32.relative(source, file)] = readFileSync16(file, "utf8");
19151
+ origins[path33.relative(source, file)] = readFileSync16(file, "utf8");
18973
19152
  else if (entry.isFile() && entry.name.endsWith(".modulemap"))
18974
19153
  moduleMaps.push(readFileSync16(file, "utf8"));
18975
19154
  }
18976
19155
  };
18977
19156
  gather(source);
18978
- const manifest = path32.join(source, "Package.swift");
18979
- const targets = existsSync9(manifest) ? swiftManifestTargets(
19157
+ const manifest = path33.join(source, "Package.swift");
19158
+ const targets = existsSync10(manifest) ? swiftManifestTargets(
18980
19159
  readFileSync16(manifest, "utf8"),
18981
19160
  [],
18982
19161
  (file) => readFileSync16(file, "utf8")
@@ -19007,11 +19186,11 @@ function prepareSwiftDependency(source, destination, overlayFrameworks) {
19007
19186
  for (const entry of readdirSync6(from, { withFileTypes: true })) {
19008
19187
  if (entry.name === ".git" || entry.name === ".build" || entry.name === ".swiftpm")
19009
19188
  continue;
19010
- const file = path32.join(from, entry.name);
19011
- const target = path32.join(to, entry.name);
19189
+ const file = path33.join(from, entry.name);
19190
+ const target = path33.join(to, entry.name);
19012
19191
  if (entry.isDirectory()) copy(file, target);
19013
19192
  else if (entry.isFile() && entry.name.endsWith(".swift"))
19014
- writeFileSync8(target, compiled.get(path32.relative(source, file)));
19193
+ writeFileSync8(target, compiled.get(path33.relative(source, file)));
19015
19194
  else cpSync(file, target, { verbatimSymlinks: true });
19016
19195
  }
19017
19196
  };
@@ -19089,18 +19268,18 @@ function withoutRepeatedClangFlags(flags) {
19089
19268
  }
19090
19269
  function clangImportModuleMapFlags(settings, layoutRoot, written, generated) {
19091
19270
  const searched = new Set(settings.headerSearchPaths);
19092
- const directory = path32.join(layoutRoot, ".build", "peach-clang-modulemaps");
19271
+ const directory = path33.join(layoutRoot, ".build", "peach-clang-modulemaps");
19093
19272
  return (settings.moduleMaps ?? []).flatMap((map) => {
19094
- const headers = path32.join(layoutRoot, map.headers);
19095
- if (!existsSync9(headers)) return [];
19096
- const published = path32.join(headers, "module.modulemap");
19097
- if (searched.has(map.headers) && existsSync9(published)) return [];
19098
- if (!searched.has(map.headers) && existsSync9(published))
19273
+ const headers = path33.join(layoutRoot, map.headers);
19274
+ if (!existsSync10(headers)) return [];
19275
+ const published = path33.join(headers, "module.modulemap");
19276
+ if (searched.has(map.headers) && existsSync10(published)) return [];
19277
+ if (!searched.has(map.headers) && existsSync10(published))
19099
19278
  return [`-fmodule-map-file=${published}`];
19100
19279
  const cached = written.get(headers);
19101
19280
  if (cached) return [cached];
19102
19281
  mkdirSync8(directory, { recursive: true });
19103
- const output = path32.join(directory, `module-${written.size}.modulemap`);
19282
+ const output = path33.join(directory, `module-${written.size}.modulemap`);
19104
19283
  writeBuildFile(
19105
19284
  output,
19106
19285
  swiftPackageClangModuleMap(swiftTargetModuleName(map.module), {
@@ -19162,11 +19341,11 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19162
19341
  input.resourcePaths
19163
19342
  );
19164
19343
  const distribution = swiftDistributionAt(moduleRoot);
19165
- const distributionModules = distribution ? path32.join(moduleRoot, "modules") : void 0;
19344
+ const distributionModules = distribution ? path33.join(moduleRoot, "modules") : void 0;
19166
19345
  const targets = distribution && compileTargets(input).length === 0 ? [
19167
19346
  {
19168
19347
  name: "App",
19169
- path: path32.relative(layout2.root, layout2.sources),
19348
+ path: path33.relative(layout2.root, layout2.sources),
19170
19349
  executable: true,
19171
19350
  languageMode: 5,
19172
19351
  mainActorIsolation: false,
@@ -19192,12 +19371,12 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19192
19371
  if (!file.endsWith(".swift")) continue;
19193
19372
  const target = bySourcePath.find(
19194
19373
  (candidate) => (candidate.path === "." || file.startsWith(`${candidate.path}/`)) && (candidate.sources === void 0 || candidate.sources.some((source) => {
19195
- const selected = path32.posix.join(candidate.path, source);
19374
+ const selected = path33.posix.join(candidate.path, source);
19196
19375
  return file === selected || file.startsWith(`${selected}/`);
19197
19376
  }))
19198
19377
  );
19199
19378
  const excluded = target?.exclude?.some(
19200
- (name) => file === path32.posix.join(target.path, name)
19379
+ (name) => file === path33.posix.join(target.path, name)
19201
19380
  );
19202
19381
  if (target && !excluded) swiftTargets.add(target.name);
19203
19382
  }
@@ -19223,23 +19402,23 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19223
19402
  ([file, contents2]) => /\.(?:swift|h|m|mm)$/.test(file) ? [contents2.toString()] : []
19224
19403
  )
19225
19404
  );
19226
- const headerDirectory = path32.join(layout2.root, ".build", "peach-cxx-headers");
19227
- if (existsSync9(headerDirectory)) {
19405
+ const headerDirectory = path33.join(layout2.root, ".build", "peach-cxx-headers");
19406
+ if (existsSync10(headerDirectory)) {
19228
19407
  for (const entry of readdirSync6(headerDirectory, { withFileTypes: true }))
19229
19408
  if (entry.isDirectory() && !targets.some((target) => target.name === entry.name))
19230
- rmSync7(path32.join(headerDirectory, entry.name), { recursive: true, force: true });
19409
+ rmSync7(path33.join(headerDirectory, entry.name), { recursive: true, force: true });
19231
19410
  }
19232
19411
  let checkedToolchain;
19233
19412
  const nativeToolchain = () => {
19234
19413
  if (checkedToolchain) return checkedToolchain;
19235
- const pin = distribution ?? JSON.parse(readFileSync16(path32.join(moduleRoot, "toolchain.json"), "utf8"));
19414
+ const pin = distribution ?? JSON.parse(readFileSync16(path33.join(moduleRoot, "toolchain.json"), "utf8"));
19236
19415
  checkedToolchain = swiftToolchain(pin.release, swiftModuleSdk(moduleRoot));
19237
19416
  return checkedToolchain;
19238
19417
  };
19239
19418
  const deploymentTarget = (name) => input.nativeTargets?.find((value) => value.name === name)?.deploymentTarget ?? targets.find((value) => value.name === name)?.iosDeploymentTarget ?? null;
19240
19419
  const targetStagedFiles = /* @__PURE__ */ new Map();
19241
19420
  const stageTargetFile = (target, file, contents2, options) => {
19242
- const relative = path32.relative(layout2.root, file).split(path32.sep).join(path32.posix.sep);
19421
+ const relative = path33.relative(layout2.root, file).split(path33.sep).join(path33.posix.sep);
19243
19422
  const prior = files.has(file) ? files.get(file) : Object.hasOwn(input.files, relative) ? input.files[relative] : void 0;
19244
19423
  if (!options?.allowExisting && prior !== void 0)
19245
19424
  throw new Error(`target ${target} already contains generated output ${relative}`);
@@ -19252,7 +19431,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19252
19431
  const prefix = target.path === "." ? "" : `${target.path}/`;
19253
19432
  return Object.entries(input.files).filter(
19254
19433
  ([file]) => file.startsWith(prefix) && (target.sources === void 0 || !(file.endsWith(".swift") || isSwiftNativeTranslationUnit(file)) || target.sources.some((source) => {
19255
- const selected = path32.posix.join(prefix, source);
19434
+ const selected = path33.posix.join(prefix, source);
19256
19435
  return file === selected || file.startsWith(`${selected}/`);
19257
19436
  })) && !target.exclude?.some(
19258
19437
  (excluded) => file === `${prefix}${excluded}` || file.startsWith(`${prefix}${excluded}/`)
@@ -19273,7 +19452,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19273
19452
  targetStagedFiles.delete(target.name);
19274
19453
  if (entries2.some(([file]) => isSwiftNativeTranslationUnit(file)) && (swift || input.nativeTargets?.some((value) => value.name === target.name))) {
19275
19454
  if (!swift) {
19276
- const unprepared = path32.join(
19455
+ const unprepared = path33.join(
19277
19456
  layout2.root,
19278
19457
  target.path,
19279
19458
  "PeachUnprepared.generated.swift"
@@ -19288,7 +19467,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19288
19467
  native.set(target.name, {
19289
19468
  mixed: true,
19290
19469
  path: target.path,
19291
- includeDirectory: path32.join(layout2.root, target.path, "include"),
19470
+ includeDirectory: path33.join(layout2.root, target.path, "include"),
19292
19471
  sources: [],
19293
19472
  lateSources: [],
19294
19473
  exclude: entries2.filter(([file]) => !file.endsWith(".swift") && !file.endsWith(".metal")).map(([file]) => file.slice(prefix.length))
@@ -19310,15 +19489,15 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19310
19489
  file
19311
19490
  )?.[1];
19312
19491
  if (owner)
19313
- podHeaders.set(path32.basename(file), [
19314
- ...podHeaders.get(path32.basename(file)) ?? [],
19492
+ podHeaders.set(path33.basename(file), [
19493
+ ...podHeaders.get(path33.basename(file)) ?? [],
19315
19494
  { owner, content: input.files[file] }
19316
19495
  ]);
19317
19496
  }
19318
- const podHeaderOwner = (file, content) => /\/Headers\/(?:Public|Private)\/([\w+-]+)\//.exec(file)?.[1] ?? podHeaders.get(path32.basename(file))?.find((header) => header.content === content)?.owner;
19497
+ const podHeaderOwner = (file, content) => /\/Headers\/(?:Public|Private)\/([\w+-]+)\//.exec(file)?.[1] ?? podHeaders.get(path33.basename(file))?.find((header) => header.content === content)?.owner;
19319
19498
  for (const settings of input.nativeTargets ?? []) {
19320
19499
  for (const file of settings.headers) {
19321
- const destination = path32.join(layout2.root, file);
19500
+ const destination = path33.join(layout2.root, file);
19322
19501
  if (files.has(destination)) continue;
19323
19502
  const interfaceModule = /(?:^|\/)(\w+)-Swift\.h$/.exec(file)?.[1];
19324
19503
  const frameworkHeader = !interfaceModule && /(?:^|\/)(\w+)\.framework\/Headers\/[\w+.-]+\.h$/.exec(file)?.[1];
@@ -19337,35 +19516,35 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19337
19516
  }
19338
19517
  }
19339
19518
  const nativeTargets = input.nativeTargets ?? [];
19340
- const fromInputRoot = (file) => file.startsWith(`${SWIFT_NATIVE_INPUT_ROOT}/`) ? path32.join(layout2.root, file.slice(SWIFT_NATIVE_INPUT_ROOT.length + 1)) : file;
19341
- const inRoot = `${layout2.root}${path32.sep}`;
19342
- const binaryTree = `${path32.sep}${SWIFT_BINARY_TREES_DIR}${path32.sep}`;
19519
+ const fromInputRoot = (file) => file.startsWith(`${SWIFT_NATIVE_INPUT_ROOT}/`) ? path33.join(layout2.root, file.slice(SWIFT_NATIVE_INPUT_ROOT.length + 1)) : file;
19520
+ const inRoot = `${layout2.root}${path33.sep}`;
19521
+ const binaryTree = `${path33.sep}${SWIFT_BINARY_TREES_DIR}${path33.sep}`;
19343
19522
  const headerSearch = writeXcodeHeaderSearch(
19344
- path32.join(layout2.root, ".build", "peach-xcode-headers"),
19523
+ path33.join(layout2.root, ".build", "peach-xcode-headers"),
19345
19524
  nativeTargets.map((settings) => {
19346
19525
  const productHeaders = {};
19347
19526
  const publishedHeaders = /* @__PURE__ */ new Set();
19348
19527
  const moduleName = swiftTargetModuleName(settings.name);
19349
19528
  for (const [product, file] of Object.entries(settings.productHeaders)) {
19350
- const header = path32.join(layout2.root, file);
19351
- productHeaders[path32.join(layout2.root, product)] = header;
19529
+ const header = path33.join(layout2.root, file);
19530
+ productHeaders[path33.join(layout2.root, product)] = header;
19352
19531
  const framework = /^(.+\.framework)\/((?:Private)?Headers\/.+)$/.exec(product);
19353
19532
  if (framework && Object.hasOwn(
19354
19533
  settings.productHeaders,
19355
19534
  `${framework[1]}/Modules/module.modulemap`
19356
19535
  )) {
19357
- productHeaders[path32.join(layout2.root, framework[1], "Modules", framework[2])] = header;
19358
- if (path32.posix.basename(framework[1]) === `${moduleName}.framework` && framework[2] === `Headers/${path32.posix.basename(file)}`)
19536
+ productHeaders[path33.join(layout2.root, framework[1], "Modules", framework[2])] = header;
19537
+ if (path33.posix.basename(framework[1]) === `${moduleName}.framework` && framework[2] === `Headers/${path33.posix.basename(file)}`)
19359
19538
  publishedHeaders.add(file);
19360
19539
  }
19361
19540
  }
19362
19541
  if (settings.flattensPublicHeaders)
19363
19542
  for (const file of settings.publicHeaders) {
19364
19543
  if (publishedHeaders.has(file)) continue;
19365
- const alias = path32.join(headerDirectory, settings.name, path32.basename(file));
19544
+ const alias = path33.join(headerDirectory, settings.name, path33.basename(file));
19366
19545
  if (Object.hasOwn(productHeaders, alias))
19367
19546
  throw new Error(`duplicate product header ${alias}`);
19368
- productHeaders[alias] = path32.join(layout2.root, file);
19547
+ productHeaders[alias] = path33.join(layout2.root, file);
19369
19548
  }
19370
19549
  return {
19371
19550
  headerMaps: settings.headerMaps.map((map) => ({
@@ -19377,18 +19556,18 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19377
19556
  })),
19378
19557
  productHeaders,
19379
19558
  userHeaderSearchPaths: settings.userHeaderSearchPaths.map(
19380
- (directory) => path32.join(layout2.root, directory)
19559
+ (directory) => path33.join(layout2.root, directory)
19381
19560
  ),
19382
19561
  searchDirectories: [
19383
19562
  ...settings.headerSearchPaths,
19384
19563
  ...settings.frameworkSearchPaths
19385
- ].map((directory) => path32.join(layout2.root, directory))
19564
+ ].map((directory) => path33.join(layout2.root, directory))
19386
19565
  };
19387
19566
  }),
19388
19567
  Object.fromEntries(
19389
19568
  Object.entries(input.headerAliases ?? {}).map(([alias, file]) => [
19390
- path32.join(layout2.root, alias),
19391
- path32.join(layout2.root, file)
19569
+ path33.join(layout2.root, alias),
19570
+ path33.join(layout2.root, file)
19392
19571
  ])
19393
19572
  ),
19394
19573
  (file) => !file.startsWith(inRoot) || files.has(file) || file.includes(binaryTree)
@@ -19432,9 +19611,9 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19432
19611
  const producer = /(?:^|\/)([^/]+)-Swift\.h$/.exec(include)?.[1];
19433
19612
  if (producer && swiftTargets.has(producer)) producers2.add(producer);
19434
19613
  const local = [
19435
- path32.posix.join(path32.posix.dirname(file), include),
19614
+ path33.posix.join(path33.posix.dirname(file), include),
19436
19615
  `${includes}${include}`,
19437
- ...searchRoots.map((root) => path32.posix.join(root, include))
19616
+ ...searchRoots.map((root) => path33.posix.join(root, include))
19438
19617
  ].find((candidate) => input.files[candidate] !== void 0);
19439
19618
  if (local) {
19440
19619
  reverse.set(local, [...reverse.get(local) ?? [], file]);
@@ -19477,7 +19656,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19477
19656
  );
19478
19657
  const roots2 = settings.bridgingHeader ? [settings.bridgingHeader] : entries2.some(([file]) => file.endsWith(".swift")) || importedModules.has(swiftTargetModuleName(target.name)) ? settings.publicHeaders : [];
19479
19658
  const search = [.../* @__PURE__ */ new Set([...settings?.headerSearchPaths ?? []])].flatMap(
19480
- (dir) => ["-I", path32.join(layout2.root, dir)]
19659
+ (dir) => ["-I", path33.join(layout2.root, dir)]
19481
19660
  );
19482
19661
  const toolchainBin = nativeToolchain();
19483
19662
  const stageFlags = (flags2, sdkInclude2) => flags2.map(
@@ -19489,7 +19668,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19489
19668
  ...search,
19490
19669
  ...(settings?.frameworkSearchPaths ?? []).flatMap((dir) => [
19491
19670
  "-F",
19492
- path32.join(layout2.root, dir)
19671
+ path33.join(layout2.root, dir)
19493
19672
  ]),
19494
19673
  "-I",
19495
19674
  headerDirectory
@@ -19500,7 +19679,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19500
19679
  ...search,
19501
19680
  ...settings.frameworkSearchPaths.flatMap((dir) => [
19502
19681
  "-F",
19503
- path32.join(layout2.root, dir)
19682
+ path33.join(layout2.root, dir)
19504
19683
  ]),
19505
19684
  "-I",
19506
19685
  headerDirectory
@@ -19510,13 +19689,13 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19510
19689
  const flag = settings.importerFlags[index];
19511
19690
  if (flag === "-I" || flag === "-iquote") {
19512
19691
  const directory = settings.importerFlags[index + 1];
19513
- if (directory === void 0 || !path32.isAbsolute(directory)) {
19692
+ if (directory === void 0 || !path33.isAbsolute(directory)) {
19514
19693
  index++;
19515
19694
  continue;
19516
19695
  }
19517
19696
  }
19518
19697
  const joined = /^-(?:I|iquote)(.+)$/.exec(flag);
19519
- if (joined && !path32.isAbsolute(joined[1])) continue;
19698
+ if (joined && !path33.isAbsolute(joined[1])) continue;
19520
19699
  kept.push(flag);
19521
19700
  }
19522
19701
  return [
@@ -19525,13 +19704,13 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19525
19704
  ...search,
19526
19705
  ...(settings?.frameworkSearchPaths ?? []).flatMap((dir) => [
19527
19706
  "-F",
19528
- path32.join(layout2.root, dir)
19707
+ path33.join(layout2.root, dir)
19529
19708
  ]),
19530
19709
  "-I",
19531
19710
  headerDirectory
19532
19711
  ];
19533
19712
  })();
19534
- const sdkInclude = path32.join(
19713
+ const sdkInclude = path33.join(
19535
19714
  swiftSdkPaths(moduleRoot, toolchainBin).sysroot,
19536
19715
  "darwin/usr/include"
19537
19716
  );
@@ -19546,7 +19725,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19546
19725
  ...dependencyModuleMaps,
19547
19726
  ...xcodeTarget && !target.defines?.includes("SWIFT_PACKAGE") ? ["-USWIFT_PACKAGE"] : []
19548
19727
  ];
19549
- const prefixHeader = settings?.prefixHeader ? ["-include", path32.join(layout2.root, settings.prefixHeader)] : [];
19728
+ const prefixHeader = settings?.prefixHeader ? ["-include", path33.join(layout2.root, settings.prefixHeader)] : [];
19550
19729
  const bundleName = entries2.some(([file]) => file.endsWith(".swift")) ? void 0 : swiftObjCResourceBundleName({
19551
19730
  target: target.name,
19552
19731
  path: target.path,
@@ -19557,7 +19736,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19557
19736
  bundles: input.resourceBundles
19558
19737
  });
19559
19738
  const accessor = bundleName === void 0 ? void 0 : swiftObjCResourceAccessor(bundleName);
19560
- const accessorHeader = path32.join(
19739
+ const accessorHeader = path33.join(
19561
19740
  layout2.root,
19562
19741
  target.path,
19563
19742
  OBJC_RESOURCE_ACCESSOR_HEADER
@@ -19568,7 +19747,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19568
19747
  const nativeUnits = accessor ? [...units, [accessorUnit, accessor.body]] : units;
19569
19748
  const unitSource = (file) => {
19570
19749
  const relative = file.slice(prefix.length);
19571
- return relative.split("/").some((part) => part.startsWith(".")) ? path32.posix.join(HIDDEN_UNITS, relative.replaceAll(/(^|\/)\./g, "$1%2E")) : relative;
19750
+ return relative.split("/").some((part) => part.startsWith(".")) ? path33.posix.join(HIDDEN_UNITS, relative.replaceAll(/(^|\/)\./g, "$1%2E")) : relative;
19572
19751
  };
19573
19752
  const accessorFlags = accessor ? ["-include", accessorHeader] : [];
19574
19753
  const nativeC = !entries2.some(([file]) => file.endsWith(".swift"));
@@ -19598,20 +19777,20 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19598
19777
  )
19599
19778
  ].sort();
19600
19779
  const topHeaders = settings.publicHeaders.filter(
19601
- (file) => path32.posix.dirname(file) === headerDir
19780
+ (file) => path33.posix.dirname(file) === headerDir
19602
19781
  );
19603
19782
  if (input.files[custom] !== void 0) {
19604
19783
  swiftpmModuleMap = { path: custom, contents: input.files[custom] };
19605
19784
  } else if (input.files[umbrella] !== void 0) {
19606
19785
  if (siblingDirs.length > 0)
19607
19786
  throw new Error(
19608
- `target ${target.name} has invalid header layout: umbrella header found at '${path32.join(layout2.root, umbrella)}', but directories exist next to it: ${siblingDirs.map((name) => path32.join(layout2.root, headerDir, name)).join(", ")}; consider removing them`
19787
+ `target ${target.name} has invalid header layout: umbrella header found at '${path33.join(layout2.root, umbrella)}', but directories exist next to it: ${siblingDirs.map((name) => path33.join(layout2.root, headerDir, name)).join(", ")}; consider removing them`
19609
19788
  );
19610
19789
  swiftpmModuleMap = {
19611
19790
  path: custom,
19612
19791
  contents: swiftPackageClangModuleMap(moduleName, {
19613
19792
  kind: "header",
19614
- path: path32.join(layout2.root, umbrella)
19793
+ path: path33.join(layout2.root, umbrella)
19615
19794
  })
19616
19795
  };
19617
19796
  } else if (input.files[nestedUmbrella] !== void 0 && siblingDirs.length === 1 && siblingDirs[0] === moduleName && topHeaders.length === 0) {
@@ -19619,7 +19798,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19619
19798
  path: custom,
19620
19799
  contents: swiftPackageClangModuleMap(moduleName, {
19621
19800
  kind: "header",
19622
- path: path32.join(layout2.root, nestedUmbrella)
19801
+ path: path33.join(layout2.root, nestedUmbrella)
19623
19802
  })
19624
19803
  };
19625
19804
  } else {
@@ -19627,12 +19806,12 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19627
19806
  path: custom,
19628
19807
  contents: swiftPackageClangModuleMap(moduleName, {
19629
19808
  kind: "directory",
19630
- path: path32.join(layout2.root, headerDir)
19809
+ path: path33.join(layout2.root, headerDir)
19631
19810
  })
19632
19811
  };
19633
19812
  }
19634
19813
  }
19635
- const modulemap = (originalModuleMap ? originalModuleMap[0].endsWith("/Modules/module.modulemap") ? originalModuleMap[0] : originalModuleMap[1] : void 0) ?? swiftpmModuleMap?.path ?? packageModuleMap?.[0] ?? path32.posix.join(
19814
+ const modulemap = (originalModuleMap ? originalModuleMap[0].endsWith("/Modules/module.modulemap") ? originalModuleMap[0] : originalModuleMap[1] : void 0) ?? swiftpmModuleMap?.path ?? packageModuleMap?.[0] ?? path33.posix.join(
19636
19815
  ".build",
19637
19816
  "peach-objc-originals",
19638
19817
  target.name,
@@ -19640,59 +19819,59 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19640
19819
  );
19641
19820
  const moduleContents = originalModuleMap ? input.files[originalModuleMap[1]] : swiftpmModuleMap?.contents ?? packageModuleMap?.[1] ?? swiftObjCModuleMap(
19642
19821
  swiftTargetModuleName(target.name),
19643
- roots2.map((file) => path32.join(layout2.root, file)),
19822
+ roots2.map((file) => path33.join(layout2.root, file)),
19644
19823
  submoduleImports2.get(swiftTargetModuleName(target.name))
19645
19824
  );
19646
19825
  if (moduleContents === void 0)
19647
19826
  throw new Error("missing original module map " + modulemap);
19648
19827
  const framework = nativeC && moduleMapTokens(moduleContents.toString())[0] === "framework" ? /^(.*)\/[^/]+\.framework\/Modules\/module\.modulemap$/.exec(modulemap) : null;
19649
- const frameworkDirectory = framework ? path32.join(layout2.root, framework[1]) : void 0;
19650
- stageTargetFile(target.name, path32.join(layout2.root, modulemap), moduleContents, {
19828
+ const frameworkDirectory = framework ? path33.join(layout2.root, framework[1]) : void 0;
19829
+ stageTargetFile(target.name, path33.join(layout2.root, modulemap), moduleContents, {
19651
19830
  allowExisting: true
19652
19831
  });
19653
19832
  sourceModuleMaps.set(swiftTargetModuleName(target.name), {
19654
- path: path32.join(layout2.root, modulemap),
19833
+ path: path33.join(layout2.root, modulemap),
19655
19834
  contents: moduleContents.toString()
19656
19835
  });
19657
- if (nativeC && path32.posix.basename(modulemap) !== "module.modulemap") {
19836
+ if (nativeC && path33.posix.basename(modulemap) !== "module.modulemap") {
19658
19837
  stageTargetFile(
19659
19838
  target.name,
19660
- path32.join(layout2.root, path32.posix.dirname(modulemap), "module.modulemap"),
19661
- `extern module ${swiftTargetModuleName(target.name)} ${JSON.stringify(path32.join(layout2.root, modulemap))}
19839
+ path33.join(layout2.root, path33.posix.dirname(modulemap), "module.modulemap"),
19840
+ `extern module ${swiftTargetModuleName(target.name)} ${JSON.stringify(path33.join(layout2.root, modulemap))}
19662
19841
  `
19663
19842
  );
19664
19843
  }
19665
19844
  const importFlags = [
19666
19845
  ...swiftClangImporterFlags(stageFlags(importOriginalFlags, sdkInclude)),
19667
- "-fmodule-map-file=" + path32.join(layout2.root, modulemap),
19846
+ "-fmodule-map-file=" + path33.join(layout2.root, modulemap),
19668
19847
  ...dependencyModuleMaps
19669
19848
  ];
19670
19849
  const groups = /* @__PURE__ */ new Map();
19671
19850
  for (const [file, contents2] of nativeUnits) {
19672
19851
  const origin = settings?.sourceDirectories[file];
19673
19852
  if (origin) {
19674
- const original = path32.join(layout2.root, origin, path32.posix.basename(file));
19675
- mkdirSync8(path32.dirname(original), { recursive: true });
19853
+ const original = path33.join(layout2.root, origin, path33.posix.basename(file));
19854
+ mkdirSync8(path33.dirname(original), { recursive: true });
19676
19855
  stageTargetFile(target.name, original, contents2, { allowExisting: true });
19677
19856
  }
19678
19857
  const source = unitSource(file);
19679
19858
  if (source !== file.slice(prefix.length))
19680
19859
  stageTargetFile(
19681
19860
  target.name,
19682
- path32.join(layout2.root, target.path, source),
19861
+ path33.join(layout2.root, target.path, source),
19683
19862
  contents2,
19684
19863
  {
19685
19864
  allowExisting: true
19686
19865
  }
19687
19866
  );
19688
- const stagedDir = path32.posix.dirname(file);
19867
+ const stagedDir = path33.posix.dirname(file);
19689
19868
  const quoteDirs = [
19690
19869
  ...stagedDir !== "." ? [stagedDir] : [],
19691
19870
  ...origin && origin !== stagedDir ? [origin] : []
19692
19871
  ];
19693
19872
  const quoteFlags = quoteDirs.flatMap((dir) => [
19694
19873
  "-iquote",
19695
- path32.join(layout2.root, dir)
19874
+ path33.join(layout2.root, dir)
19696
19875
  ]);
19697
19876
  const fileFlags = settings.fileFlags[file] ?? [];
19698
19877
  const objcCxx = fileFlags.includes(SWIFT_OBJCXX_LANGUAGE_FLAG);
@@ -19703,7 +19882,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19703
19882
  .../\.mm?$/.test(file) ? ["-fobjc-exceptions"] : [],
19704
19883
  ...stageFlags(
19705
19884
  [...objcCxx ? settings.cxxFlags : [], ...fileFlags],
19706
- path32.join(
19885
+ path33.join(
19707
19886
  swiftSdkPaths(moduleRoot, toolchainBin).sysroot,
19708
19887
  "darwin/usr/include"
19709
19888
  )
@@ -19714,17 +19893,17 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19714
19893
  JSON.stringify([
19715
19894
  cxx,
19716
19895
  quoteDirs,
19717
- perFile.map((flag) => flag.replaceAll(layout2.root + path32.sep, "")),
19896
+ perFile.map((flag) => flag.replaceAll(layout2.root + path33.sep, "")),
19718
19897
  (consumers.get(file)?.size ?? 0) > 0
19719
19898
  ])
19720
19899
  ).digest("hex").slice(0, 12);
19721
19900
  const name = `${target.name}${nativeC ? "Native" : "Swift"}Implementation_${identity}`;
19722
- const groupPath = path32.posix.join("PeachNativeSources", name);
19723
- const canonicalTargetPath = path32.posix.join("/peach/build", target.path);
19901
+ const groupPath = path33.posix.join("PeachNativeSources", name);
19902
+ const canonicalTargetPath = path33.posix.join("/peach/build", target.path);
19724
19903
  const sourceIdentity = [
19725
- `-ffile-prefix-map=${path32.join(layout2.root, groupPath)}=${canonicalTargetPath}`,
19904
+ `-ffile-prefix-map=${path33.join(layout2.root, groupPath)}=${canonicalTargetPath}`,
19726
19905
  ...nativeToolset ? [
19727
- `-ffile-prefix-map=${path32.posix.join("/peach/build", groupPath)}=${canonicalTargetPath}`
19906
+ `-ffile-prefix-map=${path33.posix.join("/peach/build", groupPath)}=${canonicalTargetPath}`
19728
19907
  ] : []
19729
19908
  ];
19730
19909
  const group = groups.get(identity) ?? {
@@ -19748,7 +19927,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19748
19927
  ...accessorFlags,
19749
19928
  ...stageFlags(
19750
19929
  cxx ? settings.cxxFlags : [],
19751
- path32.join(
19930
+ path33.join(
19752
19931
  swiftSdkPaths(moduleRoot, toolchainBin).sysroot,
19753
19932
  "darwin/usr/include"
19754
19933
  )
@@ -19759,12 +19938,12 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19759
19938
  };
19760
19939
  stageTargetFile(
19761
19940
  target.name,
19762
- path32.join(layout2.root, group.path, source),
19941
+ path33.join(layout2.root, group.path, source),
19763
19942
  contents2
19764
19943
  );
19765
19944
  stageTargetFile(
19766
19945
  target.name,
19767
- path32.join(layout2.root, group.path, "include/module.modulemap"),
19946
+ path33.join(layout2.root, group.path, "include/module.modulemap"),
19768
19947
  `module ${swiftTargetModuleName(group.name)} { export * }
19769
19948
  `,
19770
19949
  { allowExisting: true }
@@ -19782,7 +19961,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19782
19961
  stageTargetFile(target.name, accessorHeader, accessor.header);
19783
19962
  stageTargetFile(
19784
19963
  target.name,
19785
- path32.join(layout2.root, accessorUnit),
19964
+ path33.join(layout2.root, accessorUnit),
19786
19965
  accessor.body
19787
19966
  );
19788
19967
  }
@@ -19797,7 +19976,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19797
19976
  ].sort();
19798
19977
  native.set(target.name, {
19799
19978
  path: target.path,
19800
- includeDirectory: path32.dirname(path32.join(layout2.root, modulemap)),
19979
+ includeDirectory: path33.dirname(path33.join(layout2.root, modulemap)),
19801
19980
  importFlags,
19802
19981
  frameworkDirectory,
19803
19982
  sources: nativeUnits.map(([file]) => unitSource(file)),
@@ -19821,23 +20000,23 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19821
20000
  throw new Error(`original module map declares no module: ${modulemap}`);
19822
20001
  stageTargetFile(
19823
20002
  target.name,
19824
- path32.join(layout2.root, owner.path, "include/module.modulemap"),
19825
- `extern module ${exportedModule} ${JSON.stringify(path32.join(layout2.root, modulemap))}
20003
+ path33.join(layout2.root, owner.path, "include/module.modulemap"),
20004
+ `extern module ${exportedModule} ${JSON.stringify(path33.join(layout2.root, modulemap))}
19826
20005
  `,
19827
20006
  { allowExisting: true }
19828
20007
  );
19829
20008
  }
19830
20009
  continue;
19831
20010
  }
19832
- const implementationHeaders = path32.posix.join(
20011
+ const implementationHeaders = path33.posix.join(
19833
20012
  ".build",
19834
20013
  "peach-objc-implementations",
19835
20014
  target.name
19836
20015
  );
19837
- const include = path32.join(layout2.root, implementationHeaders);
20016
+ const include = path33.join(layout2.root, implementationHeaders);
19838
20017
  stageTargetFile(
19839
20018
  target.name,
19840
- path32.join(include, "module.modulemap"),
20019
+ path33.join(include, "module.modulemap"),
19841
20020
  `module ${target.name}ImplementationDeclarations { export * }
19842
20021
  `
19843
20022
  );
@@ -19847,7 +20026,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19847
20026
  includeDirectory: include,
19848
20027
  importFlags,
19849
20028
  swiftFlags: [
19850
- ...settings.bridgingHeader ? ["-import-objc-header", path32.join(layout2.root, settings.bridgingHeader)] : roots2.length ? ["-import-underlying-module"] : [],
20029
+ ...settings.bridgingHeader ? ["-import-objc-header", path33.join(layout2.root, settings.bridgingHeader)] : roots2.length ? ["-import-underlying-module"] : [],
19851
20030
  ...importFlags.flatMap((flag) => ["-Xcc", flag])
19852
20031
  ],
19853
20032
  sources: nativeUnits.map(([file]) => unitSource(file)),
@@ -19878,7 +20057,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19878
20057
  const textualIncludes = entries2.map(([file]) => file).filter((file) => /\.(?:inc|inl|ipp|def)$/.test(file));
19879
20058
  native.set(target.name, {
19880
20059
  path: target.path,
19881
- includeDirectory: path32.join(layout2.root, includes),
20060
+ includeDirectory: path33.join(layout2.root, includes),
19882
20061
  sources: units.map(([file]) => file.slice(prefix.length)),
19883
20062
  lateSources: late.map(([file]) => file.slice(prefix.length)),
19884
20063
  exclude: [
@@ -19895,21 +20074,21 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19895
20074
  } : {}
19896
20075
  });
19897
20076
  if (late.length === 0) {
19898
- const headers = path32.posix.join(target.path, target.publicHeadersPath ?? "include");
20077
+ const headers = path33.posix.join(target.path, target.publicHeadersPath ?? "include");
19899
20078
  const fragments = textualIncludes.filter(
19900
20079
  (file) => headers === "." || file.startsWith(`${headers}/`)
19901
20080
  );
19902
20081
  const name = swiftTargetModuleName(target.name);
19903
- const map = path32.posix.join(headers, "module.modulemap");
19904
- if (fragments.length > 0 && !Object.hasOwn(input.files, map) && !files.has(path32.join(layout2.root, map)) && !Object.hasOwn(input.files, path32.posix.join(headers, `${name}.h`)) && !Object.hasOwn(input.files, path32.posix.join(headers, name, `${name}.h`)))
20082
+ const map = path33.posix.join(headers, "module.modulemap");
20083
+ if (fragments.length > 0 && !Object.hasOwn(input.files, map) && !files.has(path33.join(layout2.root, map)) && !Object.hasOwn(input.files, path33.posix.join(headers, `${name}.h`)) && !Object.hasOwn(input.files, path33.posix.join(headers, name, `${name}.h`)))
19905
20084
  stageTargetFile(
19906
20085
  target.name,
19907
- path32.join(layout2.root, map),
20086
+ path33.join(layout2.root, map),
19908
20087
  [
19909
20088
  `module ${name} {`,
19910
20089
  ' umbrella "."',
19911
20090
  ...fragments.map(
19912
- (file) => ` textual header ${JSON.stringify(path32.posix.relative(headers, file))}`
20091
+ (file) => ` textual header ${JSON.stringify(path33.posix.relative(headers, file))}`
19913
20092
  ),
19914
20093
  " export *",
19915
20094
  "}",
@@ -19919,7 +20098,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19919
20098
  continue;
19920
20099
  }
19921
20100
  files.set(
19922
- path32.join(layout2.root, target.path, "PeachSwiftImplementation/module.modulemap"),
20101
+ path33.join(layout2.root, target.path, "PeachSwiftImplementation/module.modulemap"),
19923
20102
  `module ${swiftTargetModuleName(`${target.name}SwiftImplementation`)} { export * }
19924
20103
  `
19925
20104
  );
@@ -19931,7 +20110,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19931
20110
  ([file]) => file.startsWith(includes) && /\.(?:h|hpp|hh|hxx)$/.test(file) && consumers.get(file).size === 0
19932
20111
  );
19933
20112
  files.set(
19934
- path32.join(layout2.root, includes, "module.modulemap"),
20113
+ path33.join(layout2.root, includes, "module.modulemap"),
19935
20114
  [
19936
20115
  `module ${target.name} {`,
19937
20116
  ...roots.map(
@@ -19946,7 +20125,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19946
20125
  for (const map of generatedModuleMaps)
19947
20126
  if (files.has(map.published) || Object.hasOwn(
19948
20127
  input.files,
19949
- path32.relative(layout2.root, map.published).split(path32.sep).join(path32.posix.sep)
20128
+ path33.relative(layout2.root, map.published).split(path33.sep).join(path33.posix.sep)
19950
20129
  ))
19951
20130
  writeBuildFile(
19952
20131
  map.output,
@@ -19975,10 +20154,10 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19975
20154
  [...native.values()].flatMap((value) => value.late?.producers ?? [])
19976
20155
  )) {
19977
20156
  files.set(
19978
- path32.join(headerDirectory, name, name + "-Swift.h"),
20157
+ path33.join(headerDirectory, name, name + "-Swift.h"),
19979
20158
  '#include "../' + name + '-Swift.h"\n'
19980
20159
  );
19981
- const modulemap = path32.join(
20160
+ const modulemap = path33.join(
19982
20161
  layout2.root,
19983
20162
  ".build",
19984
20163
  "peach-objc-swift-headers",
@@ -19988,7 +20167,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19988
20167
  const moduleName = swiftTargetModuleName(name);
19989
20168
  const originalMap = originalMaps.get(moduleName);
19990
20169
  const stagedMap = sourceModuleMaps.get(moduleName);
19991
- const originalPath = stagedMap?.path ?? (originalMap ? path32.join(layout2.root, originalMap) : void 0);
20170
+ const originalPath = stagedMap?.path ?? (originalMap ? path33.join(layout2.root, originalMap) : void 0);
19992
20171
  const originalContents = stagedMap?.contents ?? (originalMap && input.files[originalMap]);
19993
20172
  const originalTokens = originalContents ? moduleMapTokens(originalContents) : [];
19994
20173
  if (originalPath && originalTokens.some(
@@ -20002,20 +20181,20 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
20002
20181
  modulemap,
20003
20182
  originalPath ? `extern module ${moduleName} ${JSON.stringify(originalPath)}
20004
20183
  module ${moduleName}.Swift {
20005
- header ${JSON.stringify(path32.join(headerDirectory, name + "-Swift.h"))}
20184
+ header ${JSON.stringify(path33.join(headerDirectory, name + "-Swift.h"))}
20006
20185
  requires objc
20007
20186
  }
20008
20187
  ` : swiftObjCModuleMap(
20009
20188
  moduleName,
20010
- (input.nativeTargets?.find((target) => target.name === name)?.publicHeaders ?? []).map((header) => path32.join(layout2.root, header)),
20189
+ (input.nativeTargets?.find((target) => target.name === name)?.publicHeaders ?? []).map((header) => path33.join(layout2.root, header)),
20011
20190
  submoduleImports2.get(moduleName),
20012
- path32.join(headerDirectory, name + "-Swift.h")
20191
+ path33.join(headerDirectory, name + "-Swift.h")
20013
20192
  )
20014
20193
  );
20015
20194
  nativeHeaderFlags.push("-fmodule-map-file=" + modulemap);
20016
20195
  nativeSwiftHeaderMaps.set(name, modulemap);
20017
20196
  }
20018
- const providedFrameworks = path32.join(layout2.root, ".build", "peach-provided-frameworks");
20197
+ const providedFrameworks = path33.join(layout2.root, ".build", "peach-provided-frameworks");
20019
20198
  const probedProducts = /* @__PURE__ */ new Set();
20020
20199
  if (distribution) {
20021
20200
  for (const [file, contents2] of Object.entries(input.files))
@@ -20041,10 +20220,10 @@ module ${moduleName}.Swift {
20041
20220
  continue;
20042
20221
  const providedInterface = moduleInterface(name);
20043
20222
  if (!providedInterface) continue;
20044
- const framework = path32.join(providedFrameworks, `${name}.framework`);
20045
- files.set(path32.join(framework, "Headers", `${name}.h`), providedInterface.header);
20223
+ const framework = path33.join(providedFrameworks, `${name}.framework`);
20224
+ files.set(path33.join(framework, "Headers", `${name}.h`), providedInterface.header);
20046
20225
  files.set(
20047
- path32.join(framework, "Modules", "module.modulemap"),
20226
+ path33.join(framework, "Modules", "module.modulemap"),
20048
20227
  `framework module ${name} {
20049
20228
  umbrella header "${name}.h"
20050
20229
  export *
@@ -20053,10 +20232,10 @@ module ${moduleName}.Swift {
20053
20232
  );
20054
20233
  stagedProducts.push(name);
20055
20234
  }
20056
- if (existsSync9(providedFrameworks)) {
20235
+ if (existsSync10(providedFrameworks)) {
20057
20236
  for (const entry of readdirSync6(providedFrameworks))
20058
20237
  if (!stagedProducts.includes(entry.replace(/\.framework$/, "")))
20059
- rmSync7(path32.join(providedFrameworks, entry), { recursive: true, force: true });
20238
+ rmSync7(path33.join(providedFrameworks, entry), { recursive: true, force: true });
20060
20239
  }
20061
20240
  const providedFrameworkFlags = stagedProducts.length ? ["-F", providedFrameworks] : [];
20062
20241
  const frameworkSearch = JSON.stringify([
@@ -20065,15 +20244,15 @@ module ${moduleName}.Swift {
20065
20244
  ...new Set(nativeTargets.flatMap((settings) => settings.frameworkSearchPaths))
20066
20245
  ].sort()
20067
20246
  ]);
20068
- const frameworkSearchRecord = path32.join(
20247
+ const frameworkSearchRecord = path33.join(
20069
20248
  layout2.root,
20070
20249
  ".build",
20071
20250
  "peach-framework-search.json"
20072
20251
  );
20073
- if (!existsSync9(frameworkSearchRecord) || readFileSync16(frameworkSearchRecord, "utf8") !== frameworkSearch)
20252
+ if (!existsSync10(frameworkSearchRecord) || readFileSync16(frameworkSearchRecord, "utf8") !== frameworkSearch)
20074
20253
  for (const cache of [
20075
- path32.join(layout2.root, ".build", "ModuleCache"),
20076
- path32.join(layout2.root, ".build", WASM_TRIPLE, "release", "ModuleCache")
20254
+ path33.join(layout2.root, ".build", "ModuleCache"),
20255
+ path33.join(layout2.root, ".build", WASM_TRIPLE, "release", "ModuleCache")
20077
20256
  ])
20078
20257
  rmSync7(cache, { recursive: true, force: true });
20079
20258
  files.set(frameworkSearchRecord, frameworkSearch);
@@ -20081,7 +20260,7 @@ module ${moduleName}.Swift {
20081
20260
  swiftModuleInputFiles(moduleRoot).join("\n")
20082
20261
  );
20083
20262
  if (!distribution) {
20084
- modulePlan.update(readFileSync16(path32.join(moduleRoot, "Package.swift")));
20263
+ modulePlan.update(readFileSync16(path33.join(moduleRoot, "Package.swift")));
20085
20264
  }
20086
20265
  modulePlan.update(
20087
20266
  Object.keys(input.files).filter((file) => file.endsWith(".swift")).sort().join("\n")
@@ -20136,7 +20315,7 @@ module ${moduleName}.Swift {
20136
20315
  (target) => {
20137
20316
  const native2 = input.nativeTargets?.find(({ name }) => name === target.name);
20138
20317
  if (native2) return native2.publicHeaders.map((file) => input.files[file] ?? "");
20139
- const directory = path32.posix.join(
20318
+ const directory = path33.posix.join(
20140
20319
  target.path,
20141
20320
  target.publicHeadersPath ?? "include"
20142
20321
  );
@@ -20172,7 +20351,7 @@ module ${moduleName}.Swift {
20172
20351
  `;
20173
20352
  } else if (mains.length === 0) {
20174
20353
  const procedural = entries2.filter(
20175
- ([file, source]) => path32.basename(file) === "main.swift" && swiftApplicationEntry(file, source)
20354
+ ([file, source]) => path33.basename(file) === "main.swift" && swiftApplicationEntry(file, source)
20176
20355
  );
20177
20356
  const wrapped = procedural.length === 1 ? wrapUIApplicationMainEntry(procedural[0][1]) : null;
20178
20357
  if (wrapped) {
@@ -20193,22 +20372,22 @@ module ${moduleName}.Swift {
20193
20372
  `mixed executable ${target.name} requires one typed Swift application entry`
20194
20373
  );
20195
20374
  const [file, source] = nativeMains[0];
20196
- const original = path32.join(layout2.root, file);
20375
+ const original = path33.join(layout2.root, file);
20197
20376
  const entry = neutralizedNativeMain(source);
20198
20377
  files.set(original, entry);
20199
20378
  const implementation = executableNativeUnits.get(file);
20200
20379
  if (implementation) {
20201
20380
  const unit = implementation.sources[implementation.index];
20202
- const extension = path32.posix.extname(unit);
20203
- const staged = path32.posix.basename(unit, extension) === "main" ? path32.posix.join(
20204
- path32.posix.dirname(unit),
20381
+ const extension = path33.posix.extname(unit);
20382
+ const staged = path33.posix.basename(unit, extension) === "main" ? path33.posix.join(
20383
+ path33.posix.dirname(unit),
20205
20384
  `PeachApplicationEntry.generated${extension}`
20206
20385
  ) : unit;
20207
- const directory = path32.join(layout2.root, implementation.path);
20208
- const destination = path32.join(directory, staged);
20386
+ const directory = path33.join(layout2.root, implementation.path);
20387
+ const destination = path33.join(directory, staged);
20209
20388
  if (staged !== unit && files.has(destination))
20210
20389
  throw new Error(`mixed application entry conflicts with ${destination}`);
20211
- files.delete(path32.join(directory, unit));
20390
+ files.delete(path33.join(directory, unit));
20212
20391
  files.set(destination, `#line 1 ${JSON.stringify(original)}
20213
20392
  ${entry}`);
20214
20393
  implementation.sources[implementation.index] = staged;
@@ -20222,9 +20401,9 @@ ${entry}`);
20222
20401
  }
20223
20402
  if (!nativeEntry) {
20224
20403
  compiled.set(entryFile, entrySource);
20225
- if (path32.basename(entryFile) === "main.swift") {
20226
- const libraryEntry = path32.posix.join(
20227
- path32.posix.dirname(entryFile),
20404
+ if (path33.basename(entryFile) === "main.swift") {
20405
+ const libraryEntry = path33.posix.join(
20406
+ path33.posix.dirname(entryFile),
20228
20407
  "PeachApplicationEntry.generated.swift"
20229
20408
  );
20230
20409
  if (Object.hasOwn(input.files, libraryEntry))
@@ -20248,7 +20427,7 @@ ${entry}`);
20248
20427
  exclude: []
20249
20428
  });
20250
20429
  files.set(
20251
- path32.join(layout2.root, `PeachApplication/${name}/Entry.swift`),
20430
+ path33.join(layout2.root, `PeachApplication/${name}/Entry.swift`),
20252
20431
  !nativeEntry ? `import ${swiftTargetModuleName(target.name)}
20253
20432
  @main struct __PeachApplicationEntry { @MainActor static func main() { __peachRunApplication() } }
20254
20433
  ` : `import ${swiftTargetModuleName(target.name)}
@@ -20280,7 +20459,7 @@ ${entry}`);
20280
20459
  );
20281
20460
  if (nativeFlags) {
20282
20461
  const toolchainBin = nativeToolchain();
20283
- const headers = path32.join(swiftSdkPaths(moduleRoot, toolchainBin).sysroot, "darwin");
20462
+ const headers = path33.join(swiftSdkPaths(moduleRoot, toolchainBin).sysroot, "darwin");
20284
20463
  const dependencies2 = swiftTargetDependencies(input.files, targets);
20285
20464
  const reachesNative = (name, seen = /* @__PURE__ */ new Set()) => {
20286
20465
  if (native.has(name)) return true;
@@ -20326,10 +20505,10 @@ ${entry}`);
20326
20505
  if (targets.length === 0 && !prebuilt) {
20327
20506
  for (const [file, contents2] of Object.entries(input.files)) {
20328
20507
  if (file === "Package.swift") continue;
20329
- files.set(path32.join(layout2.sources, file), compiled.get(file) ?? contents2);
20508
+ files.set(path33.join(layout2.sources, file), compiled.get(file) ?? contents2);
20330
20509
  }
20331
20510
  let manifest2 = readFileSync16(
20332
- path32.join(moduleRoot, "scripts/contrast-app-Package.swift"),
20511
+ path33.join(moduleRoot, "scripts/contrast-app-Package.swift"),
20333
20512
  "utf8"
20334
20513
  ).replaceAll("__SOOTSIM_SWIFT_PACKAGE__", moduleRoot);
20335
20514
  const reactor = ` ${REACTOR_FLAG}`;
@@ -20376,16 +20555,16 @@ ${entry}`);
20376
20555
  [anchor, ...games.map((name) => `${gameProduct(name)},`)].join("\n ")
20377
20556
  );
20378
20557
  }
20379
- files.set(path32.join(layout2.root, "Package.swift"), manifest2 + moduleFiles);
20558
+ files.set(path33.join(layout2.root, "Package.swift"), manifest2 + moduleFiles);
20380
20559
  } else {
20381
20560
  const base = layout2.multi ? layout2.root : layout2.sources;
20382
20561
  const libraries = /* @__PURE__ */ new Map();
20383
- const binaryModules = path32.join(layout2.root, ".peach-binary-modules");
20562
+ const binaryModules = path33.join(layout2.root, ".peach-binary-modules");
20384
20563
  for (const [name, data] of Object.entries(input.binaryModules ?? {})) {
20385
20564
  if (!/^[A-Za-z_]\w*$/.test(name) || !input.libraries?.[name])
20386
20565
  throw new Error(`invalid native Swift module ${name}: its library is required`);
20387
20566
  files.set(
20388
- path32.join(binaryModules, `${name}.swiftmodule`),
20567
+ path33.join(binaryModules, `${name}.swiftmodule`),
20389
20568
  Buffer.from(data, "base64")
20390
20569
  );
20391
20570
  }
@@ -20396,7 +20575,7 @@ ${entry}`);
20396
20575
  const bytes = Buffer.from(data, "base64");
20397
20576
  const digest = createHash18("sha256").update(bytes).digest("hex");
20398
20577
  if (input.binaryModules?.[target] && packageTargets.has(target)) {
20399
- const objects = path32.join(
20578
+ const objects = path33.join(
20400
20579
  layout2.root,
20401
20580
  NATIVE_ARCHIVE_OBJECTS_DIR,
20402
20581
  `${target}.build`
@@ -20407,13 +20586,13 @@ ${entry}`);
20407
20586
  libraries.set(
20408
20587
  target,
20409
20588
  members.map(({ name, bytes: bytes2 }, index) => {
20410
- const file = path32.join(objects, `${index}-${digest}-${path32.basename(name)}`);
20589
+ const file = path33.join(objects, `${index}-${digest}-${path33.basename(name)}`);
20411
20590
  files.set(file, Buffer.from(bytes2));
20412
20591
  return file;
20413
20592
  })
20414
20593
  );
20415
20594
  } else {
20416
- const file = path32.join(
20595
+ const file = path33.join(
20417
20596
  layout2.root,
20418
20597
  ".peach-libraries",
20419
20598
  `lib${target}-${digest}.a`
@@ -20424,13 +20603,13 @@ ${entry}`);
20424
20603
  }
20425
20604
  for (const [file, contents2] of Object.entries(input.files)) {
20426
20605
  if (file === "Package.swift") continue;
20427
- const destination = path32.join(base, libraryEntryFiles.get(file) ?? file);
20606
+ const destination = path33.join(base, libraryEntryFiles.get(file) ?? file);
20428
20607
  const interfaceModule = /(?:^|\/)(\w+)-Swift\.h$/.exec(file)?.[1];
20429
20608
  const localInterface = interfaceModule && swiftTargets.has(interfaceModule) ? `#include ${JSON.stringify(
20430
- path32.relative(
20431
- path32.dirname(destination),
20432
- path32.join(headerDirectory, `${interfaceModule}-Swift.h`)
20433
- ).split(path32.sep).join("/")
20609
+ path33.relative(
20610
+ path33.dirname(destination),
20611
+ path33.join(headerDirectory, `${interfaceModule}-Swift.h`)
20612
+ ).split(path33.sep).join("/")
20434
20613
  )}
20435
20614
  ` : void 0;
20436
20615
  files.set(
@@ -20441,7 +20620,7 @@ ${entry}`);
20441
20620
  const manifestTargets2 = targets.length > 0 ? targets : [
20442
20621
  {
20443
20622
  name: "App",
20444
- path: path32.relative(layout2.root, layout2.sources).split(path32.sep).join("/"),
20623
+ path: path33.relative(layout2.root, layout2.sources).split(path33.sep).join("/"),
20445
20624
  executable: true,
20446
20625
  languageMode: 5,
20447
20626
  mainActorIsolation: false,
@@ -20451,11 +20630,11 @@ ${entry}`);
20451
20630
  const reachesFrameworks = !distribution || swiftImportedModules.has("Foundation") || Object.entries(input.files).some(
20452
20631
  ([file, source]) => file.endsWith(".swift") && file !== input.entry && file !== "Package.swift" || /\.mm?$/.test(file) || source.includes("dispatch_")
20453
20632
  ) || [...importedModules].some(
20454
- (name) => distribution.modules.includes(name) && !targets.some((target) => target.name === name) && !(clangImportedModules.has(name) && !swiftImportedModules.has(name) && existsSync9(
20455
- path32.join(swiftSharedSdkRoot(moduleRoot, true), "usr/include", name)
20633
+ (name) => distribution.modules.includes(name) && !targets.some((target) => target.name === name) && !(clangImportedModules.has(name) && !swiftImportedModules.has(name) && existsSync10(
20634
+ path33.join(swiftSharedSdkRoot(moduleRoot, true), "usr/include", name)
20456
20635
  ))
20457
20636
  );
20458
- const frameworkLink = prebuilt ? path32.join(layout2.root, ".peach-framework-objects.rsp") : void 0;
20637
+ const frameworkLink = prebuilt ? path33.join(layout2.root, ".peach-framework-objects.rsp") : void 0;
20459
20638
  if (prebuilt && frameworkLink) {
20460
20639
  const quote2 = (object2) => `"${object2.replaceAll("\\", "\\\\").replaceAll('"', '\\"')}"`;
20461
20640
  files.set(
@@ -20482,15 +20661,15 @@ ${entry}`);
20482
20661
  }
20483
20662
  }
20484
20663
  files.set(
20485
- path32.join(layout2.root, "Package.swift"),
20664
+ path33.join(layout2.root, "Package.swift"),
20486
20665
  emitSwiftPackageManifest({
20487
20666
  root: layout2.root,
20488
20667
  files,
20489
20668
  targets: manifestTargets2.map((target) => ({
20490
20669
  ...target,
20491
20670
  sources: target.sources?.map((source) => {
20492
- const entry = libraryEntryFiles.get(path32.posix.join(target.path, source));
20493
- return entry ? path32.posix.relative(target.path, entry) : source;
20671
+ const entry = libraryEntryFiles.get(path33.posix.join(target.path, source));
20672
+ return entry ? path33.posix.relative(target.path, entry) : source;
20494
20673
  })
20495
20674
  })),
20496
20675
  packages,
@@ -20524,7 +20703,7 @@ ${entry}`);
20524
20703
  ),
20525
20704
  ...reachesFrameworks ? {
20526
20705
  distributionLink: {
20527
- path: path32.join(layout2.root, ".peach-distribution-objects.rsp"),
20706
+ path: path33.join(layout2.root, ".peach-distribution-objects.rsp"),
20528
20707
  files
20529
20708
  }
20530
20709
  } : {},
@@ -20545,14 +20724,14 @@ ${entry}`);
20545
20724
  for (const [file, bytes] of Object.entries(input.packageFiles ?? {})) {
20546
20725
  const contents2 = Buffer.from(bytes, "base64");
20547
20726
  files.set(
20548
- path32.join(layout2.root, file),
20727
+ path33.join(layout2.root, file),
20549
20728
  file.endsWith(".swift") && !/(?:^|\/)Package(?:@swift-[\d.]+)?\.swift$/.test(file) ? withFrameworkCompanionImports(
20550
20729
  swiftPackageSourceAsIOS(contents2.toString("utf8"))
20551
20730
  ) : contents2
20552
20731
  );
20553
20732
  }
20554
20733
  for (const [file, bytes] of Object.entries(input.projectFiles ?? {})) {
20555
- const destination = path32.join(layout2.root, file);
20734
+ const destination = path33.join(layout2.root, file);
20556
20735
  if (files.has(destination)) continue;
20557
20736
  files.set(destination, Buffer.from(bytes, "base64"));
20558
20737
  }
@@ -20561,14 +20740,14 @@ ${entry}`);
20561
20740
  const nativeToolsetFlags = [
20562
20741
  ...headerAliasFlags,
20563
20742
  ...native.size > 0 ? [
20564
- "-fmodule-map-file=" + path32.join(
20743
+ "-fmodule-map-file=" + path33.join(
20565
20744
  swiftSdkPaths(moduleRoot, nativeToolchain()).sysroot,
20566
20745
  "darwin/wasm/include/module.modulemap"
20567
20746
  )
20568
20747
  ] : []
20569
20748
  ];
20570
- const clangWrapper2 = path32.join(layout2.root, CLANG_TARGET_MODULE_WRAPPER);
20571
- const clang = path32.join(nativeToolchain(), "clang");
20749
+ const clangWrapper2 = path33.join(layout2.root, CLANG_TARGET_MODULE_WRAPPER);
20750
+ const clang = path33.join(nativeToolchain(), "clang");
20572
20751
  const prebuiltCompiler = distribution && objcPrebuiltStage !== false ? swiftObjCPrebuiltCompiler(
20573
20752
  clang,
20574
20753
  layout2.root,
@@ -20652,14 +20831,14 @@ ${entry}`);
20652
20831
  ].join("\n")
20653
20832
  );
20654
20833
  files.set(
20655
- path32.join(layout2.root, ".peach-target-toolset.json"),
20834
+ path33.join(layout2.root, ".peach-target-toolset.json"),
20656
20835
  JSON.stringify({
20657
20836
  schemaVersion: "1.0",
20658
20837
  cCompiler: {
20659
20838
  extraCLIOptions: [
20660
20839
  ...nativeToolsetFlags,
20661
20840
  "-fmodules",
20662
- `-fmodules-cache-path=${path32.join(layout2.root, ".build", "ModuleCache")}`
20841
+ `-fmodules-cache-path=${path33.join(layout2.root, ".build", "ModuleCache")}`
20663
20842
  ]
20664
20843
  },
20665
20844
  ...nativeToolsetFlags.length > 0 ? { cxxCompiler: { extraCLIOptions: nativeToolsetFlags } } : {},
@@ -20667,7 +20846,7 @@ ${entry}`);
20667
20846
  extraCLIOptions: [
20668
20847
  ...headerAliasFlags.flatMap((flag) => ["-Xcc", flag]),
20669
20848
  distribution || prebuilt ? "-Isystem" : "-I",
20670
- distributionModules ? providedModulesPath(layout2.root, distributionModules, moduleExcludes) : prebuilt ? providedModulesPath(layout2.root, prebuilt.modules, moduleExcludes) : path32.join(layout2.root, ".build", WASM_TRIPLE, "release", "Modules"),
20849
+ distributionModules ? providedModulesPath(layout2.root, distributionModules, moduleExcludes) : prebuilt ? providedModulesPath(layout2.root, prebuilt.modules, moduleExcludes) : path33.join(layout2.root, ".build", WASM_TRIPLE, "release", "Modules"),
20671
20850
  ...distributionModules ? distributionClangModuleOptions(layout2.root, distributionModules) : [],
20672
20851
  ...prebuilt?.moduleMaps.flatMap((map) => [
20673
20852
  "-Xcc",
@@ -20691,9 +20870,9 @@ ${entry}`);
20691
20870
  throw new Error(
20692
20871
  `swift resource target ${target.name} has no matching bundle assignment`
20693
20872
  );
20694
- const directory = layout2.multi ? path32.join(layout2.root, target.path) : layout2.sources;
20873
+ const directory = layout2.multi ? path33.join(layout2.root, target.path) : layout2.sources;
20695
20874
  files.set(
20696
- path32.join(directory, "ResourceBundleAccessor.generated.swift"),
20875
+ path33.join(directory, "ResourceBundleAccessor.generated.swift"),
20697
20876
  [
20698
20877
  "import Foundation",
20699
20878
  "",
@@ -20710,7 +20889,7 @@ ${entry}`);
20710
20889
  }
20711
20890
  for (const [file, source] of compiled)
20712
20891
  if (!Object.hasOwn(input.files, file))
20713
- files.set(path32.join(layout2.multi ? layout2.root : layout2.sources, file), source);
20892
+ files.set(path33.join(layout2.multi ? layout2.root : layout2.sources, file), source);
20714
20893
  const producers = [
20715
20894
  .../* @__PURE__ */ new Set([...[...native.values()].flatMap((value) => value.late?.producers ?? [])])
20716
20895
  ];
@@ -20723,7 +20902,7 @@ ${entry}`);
20723
20902
  generatedOwners.set(group.name, owner);
20724
20903
  }
20725
20904
  }
20726
- const manifestPath = path32.join(layout2.root, "Package.swift");
20905
+ const manifestPath = path33.join(layout2.root, "Package.swift");
20727
20906
  let manifest = files.get(manifestPath).toString();
20728
20907
  const manifestTargets = swiftManifestTargets(manifest, [], (file) => {
20729
20908
  const contents2 = files.get(file);
@@ -20823,7 +21002,7 @@ package.targets.first(where: { $0.name == ${JSON.stringify(target)} })!.dependen
20823
21002
  if (members.length === 1) return members[0];
20824
21003
  if (dependencies.has(name))
20825
21004
  throw new Error(`generated build target collides with ${name}`);
20826
- files.set(path32.join(layout2.root, name, "Products.swift"), "");
21005
+ files.set(path33.join(layout2.root, name, "Products.swift"), "");
20827
21006
  manifest += `
20828
21007
  package.targets += [.target(name: ${JSON.stringify(name)}, dependencies: ${JSON.stringify(members)}, path: ${JSON.stringify(name)}, swiftSettings: [.swiftLanguageMode(.v5)])]
20829
21008
  `;
@@ -20933,8 +21112,8 @@ package.targets += [.target(name: ${JSON.stringify(name)}, dependencies: ${JSON.
20933
21112
  syncSwiftTree(layout2.root, files);
20934
21113
  if (layout2.multi)
20935
21114
  for (const target of targets)
20936
- mkdirSync8(path32.join(layout2.root, target.path), { recursive: true });
20937
- const clangWrapper = path32.join(layout2.root, CLANG_TARGET_MODULE_WRAPPER);
21115
+ mkdirSync8(path33.join(layout2.root, target.path), { recursive: true });
21116
+ const clangWrapper = path33.join(layout2.root, CLANG_TARGET_MODULE_WRAPPER);
20938
21117
  if (files.has(clangWrapper) && (statSync4(clangWrapper).mode & 4095) !== 493)
20939
21118
  chmodSync3(clangWrapper, 493);
20940
21119
  return {
@@ -20965,8 +21144,8 @@ function outputOf(error) {
20965
21144
  return error instanceof Error ? error.message : String(error);
20966
21145
  }
20967
21146
  function builtArtifact(layout2) {
20968
- const binDir = path32.join(layout2.root, ".build", WASM_TRIPLE, "release");
20969
- const manifest = readFileSync16(path32.join(layout2.root, "Package.swift"), "utf8");
21147
+ const binDir = path33.join(layout2.root, ".build", WASM_TRIPLE, "release");
21148
+ const manifest = readFileSync16(path33.join(layout2.root, "Package.swift"), "utf8");
20970
21149
  const executable = swiftManifestTargets(
20971
21150
  manifest,
20972
21151
  [],
@@ -20975,11 +21154,11 @@ function builtArtifact(layout2) {
20975
21154
  if (executable === void 0) {
20976
21155
  throw new Error("swift-compile: the written manifest names no executable target");
20977
21156
  }
20978
- return path32.join(binDir, `${executable.name}.wasm`);
21157
+ return path33.join(binDir, `${executable.name}.wasm`);
20979
21158
  }
20980
21159
  function projectDiagnostic(output, layout2, files) {
20981
21160
  const base = layout2.multi ? layout2.root : layout2.sources;
20982
- const prefix = `${base}${path32.sep}`;
21161
+ const prefix = `${base}${path33.sep}`;
20983
21162
  return designTimeDiagnostic(output, files).split("\n").filter((line) => !SWIFTPM_NOISE.test(line)).map((line) => line.startsWith(prefix) ? line.slice(prefix.length) : line).join("\n").trim();
20984
21163
  }
20985
21164
  var ROOT_LOCKS = Symbol.for("peachsim.swiftCompile.rootLocks");
@@ -21015,12 +21194,12 @@ function serialize(root, work, signal) {
21015
21194
  function readCompiledArtifact(directory, hash) {
21016
21195
  try {
21017
21196
  const receipt = JSON.parse(
21018
- readFileSync16(path32.join(directory, "artifact.json"), "utf8")
21197
+ readFileSync16(path33.join(directory, "artifact.json"), "utf8")
21019
21198
  );
21020
21199
  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")
21021
21200
  return null;
21022
- const bytes = readFileSync16(path32.join(directory, "app.wasm"));
21023
- const gzip2 = readFileSync16(path32.join(directory, "icu.gz"));
21201
+ const bytes = readFileSync16(path33.join(directory, "app.wasm"));
21202
+ const gzip2 = readFileSync16(path33.join(directory, "icu.gz"));
21024
21203
  if (createHash18("sha256").update(bytes).digest("hex") !== receipt.wasm || createHash18("sha256").update(gzip2).digest("hex") !== receipt.icu || bytes.length <= 8 || bytes.readUInt32LE(0) !== 1836278016 || bytes.readUInt32LE(4) !== 1)
21025
21204
  return null;
21026
21205
  let sdk;
@@ -21028,7 +21207,7 @@ function readCompiledArtifact(directory, hash) {
21028
21207
  const image = receipt.sdk;
21029
21208
  if (!isRecord(image) || typeof image.key !== "string" || typeof image.sha256 !== "string" || typeof image.binding !== "string")
21030
21209
  return null;
21031
- const binding = readFileSync16(path32.join(directory, "sdk-binding.bin"));
21210
+ const binding = readFileSync16(path33.join(directory, "sdk-binding.bin"));
21032
21211
  if (createHash18("sha256").update(binding).digest("hex") !== image.binding)
21033
21212
  return null;
21034
21213
  sdk = {
@@ -21045,16 +21224,16 @@ function readCompiledArtifact(directory, hash) {
21045
21224
  }
21046
21225
  }
21047
21226
  function saveCompiledArtifact(root, artifact) {
21048
- const directory = path32.join(root, "artifact");
21227
+ const directory = path33.join(root, "artifact");
21049
21228
  mkdirSync8(directory, { recursive: true });
21050
- const pending = mkdtempSync4(path32.join(root, ".artifact-"));
21229
+ const pending = mkdtempSync4(path33.join(root, ".artifact-"));
21051
21230
  try {
21052
- writeFileSync8(path32.join(pending, "app.wasm"), artifact.bytes);
21053
- writeFileSync8(path32.join(pending, "icu.gz"), artifact.icu.gzip);
21231
+ writeFileSync8(path33.join(pending, "app.wasm"), artifact.bytes);
21232
+ writeFileSync8(path33.join(pending, "icu.gz"), artifact.icu.gzip);
21054
21233
  if (artifact.sdk)
21055
- writeFileSync8(path32.join(pending, "sdk-binding.bin"), artifact.sdk.binding.bytes);
21234
+ writeFileSync8(path33.join(pending, "sdk-binding.bin"), artifact.sdk.binding.bytes);
21056
21235
  writeFileSync8(
21057
- path32.join(pending, "artifact.json"),
21236
+ path33.join(pending, "artifact.json"),
21058
21237
  JSON.stringify({
21059
21238
  hash: artifact.hash,
21060
21239
  wasm: createHash18("sha256").update(artifact.bytes).digest("hex"),
@@ -21069,7 +21248,7 @@ function saveCompiledArtifact(root, artifact) {
21069
21248
  const outputs = ["app.wasm", "icu.gz"];
21070
21249
  if (artifact.sdk) outputs.push("sdk-binding.bin");
21071
21250
  for (const file of [...outputs, "artifact.json"]) {
21072
- renameSync6(path32.join(pending, file), path32.join(directory, file));
21251
+ renameSync5(path33.join(pending, file), path33.join(directory, file));
21073
21252
  }
21074
21253
  } finally {
21075
21254
  rmSync7(pending, { recursive: true, force: true });
@@ -21091,19 +21270,19 @@ function renewSharedArtifact(sharedRoot) {
21091
21270
  function pruneSharedArtifacts(parent, keep) {
21092
21271
  const entries2 = [];
21093
21272
  for (const name of readdirSync6(parent)) {
21094
- const directory = path32.join(parent, name);
21273
+ const directory = path33.join(parent, name);
21095
21274
  if (name.startsWith(RETIRED_PREFIX)) {
21096
21275
  reapRetiredCacheDirectory(parent, name);
21097
21276
  continue;
21098
21277
  }
21099
21278
  try {
21100
21279
  let bytes = 0;
21101
- for (const file of readdirSync6(path32.join(directory, "artifact"), {
21280
+ for (const file of readdirSync6(path33.join(directory, "artifact"), {
21102
21281
  recursive: true,
21103
21282
  encoding: "utf8"
21104
21283
  })) {
21105
21284
  try {
21106
- bytes += statSync4(path32.join(directory, "artifact", file)).size;
21285
+ bytes += statSync4(path33.join(directory, "artifact", file)).size;
21107
21286
  } catch (error) {
21108
21287
  if (!vanished(error)) throw error;
21109
21288
  }
@@ -21118,13 +21297,13 @@ function pruneSharedArtifacts(parent, keep) {
21118
21297
  if (total <= SHARED_ARTIFACT_BUDGET_BYTES) break;
21119
21298
  if (entry.directory === keep || Date.now() - entry.used < SHARED_ARTIFACT_GRACE_MS)
21120
21299
  continue;
21121
- const retired = path32.join(
21300
+ const retired = path33.join(
21122
21301
  parent,
21123
- `${RETIRED_PREFIX}${process.pid}-${path32.basename(entry.directory)}`
21302
+ `${RETIRED_PREFIX}${process.pid}-${path33.basename(entry.directory)}`
21124
21303
  );
21125
21304
  try {
21126
21305
  if (statSync4(entry.directory).mtimeMs !== entry.used) continue;
21127
- renameSync6(entry.directory, retired);
21306
+ renameSync5(entry.directory, retired);
21128
21307
  } catch (error) {
21129
21308
  if (vanished(error)) continue;
21130
21309
  throw error;
@@ -21136,7 +21315,7 @@ function pruneSharedArtifacts(parent, keep) {
21136
21315
  function saveSharedArtifact(sharedRoot, artifact) {
21137
21316
  saveCompiledArtifact(sharedRoot, artifact);
21138
21317
  renewSharedArtifact(sharedRoot);
21139
- pruneSharedArtifacts(path32.dirname(sharedRoot), sharedRoot);
21318
+ pruneSharedArtifacts(path33.dirname(sharedRoot), sharedRoot);
21140
21319
  }
21141
21320
  var retainedArtifacts = /* @__PURE__ */ new Map();
21142
21321
  function retain(root, artifact) {
@@ -21164,7 +21343,7 @@ function frameworkLibraryTargets(manifest) {
21164
21343
  }
21165
21344
  function linkedFrameworkTargets(moduleRoot, input) {
21166
21345
  const libraries = frameworkLibraryTargets(
21167
- readFileSync16(path32.join(moduleRoot, "Package.swift"), "utf8")
21346
+ readFileSync16(path33.join(moduleRoot, "Package.swift"), "utf8")
21168
21347
  );
21169
21348
  const targets = compileTargets(input);
21170
21349
  const planning = targets.length > 0 ? targets : [{ name: "App", path: "." }];
@@ -21190,7 +21369,7 @@ function linkedFrameworkTargets(moduleRoot, input) {
21190
21369
  imports.add(name);
21191
21370
  reach(name);
21192
21371
  }
21193
- const manifest = readFileSync16(path32.join(moduleRoot, "Package.swift"), "utf8");
21372
+ const manifest = readFileSync16(path33.join(moduleRoot, "Package.swift"), "utf8");
21194
21373
  const targetDependencies = /* @__PURE__ */ new Map();
21195
21374
  for (const match of manifest.matchAll(
21196
21375
  /\.target\(\s*name:\s*"([^"]+)"\s*,\s*dependencies:\s*\[([^\]]*)\]/g
@@ -21207,11 +21386,11 @@ function linkedFrameworkTargets(moduleRoot, input) {
21207
21386
  };
21208
21387
  for (const name of reached)
21209
21388
  for (const member of libraries.get(name) ?? []) build(member);
21210
- const overlays = path32.join(moduleRoot, "cross-import-overlays");
21389
+ const overlays = path33.join(moduleRoot, "cross-import-overlays");
21211
21390
  for (const directory of readdirSync6(overlays)) {
21212
- const companion = path32.basename(directory, ".swiftcrossimport");
21391
+ const companion = path33.basename(directory, ".swiftcrossimport");
21213
21392
  if (!built.has(companion)) continue;
21214
- const declaration = path32.join(overlays, directory, "SwiftUI.swiftoverlay");
21393
+ const declaration = path33.join(overlays, directory, "SwiftUI.swiftoverlay");
21215
21394
  for (const match of readFileSync16(declaration, "utf8").matchAll(
21216
21395
  /^\s*- name: ([A-Za-z_]\w*)\s*$/gm
21217
21396
  ))
@@ -21238,7 +21417,7 @@ function linkedFrameworkTargets(moduleRoot, input) {
21238
21417
  return { products: linked, targets: linkedMembers, imports: [...imports].sort() };
21239
21418
  }
21240
21419
  function writeFrameworkLinkPackage(linkRoot, moduleRoot, products) {
21241
- const identity = path32.basename(moduleRoot).toLowerCase();
21420
+ const identity = path33.basename(moduleRoot).toLowerCase();
21242
21421
  const swiftString = (value) => `"${value.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
21243
21422
  const dependencies = products.map(
21244
21423
  (name) => ` .product(name: ${swiftString(name)}, package: ${swiftString(identity)}),`
@@ -21260,13 +21439,13 @@ ${dependencies}
21260
21439
  ]
21261
21440
  )
21262
21441
  `;
21263
- const sourceDir = path32.join(linkRoot, "Sources", FRAMEWORK_LINK_TARGET);
21442
+ const sourceDir = path33.join(linkRoot, "Sources", FRAMEWORK_LINK_TARGET);
21264
21443
  mkdirSync8(sourceDir, { recursive: true });
21265
- const manifestPath = path32.join(linkRoot, "Package.swift");
21266
- if (!existsSync9(manifestPath) || readFileSync16(manifestPath, "utf8") !== manifest)
21444
+ const manifestPath = path33.join(linkRoot, "Package.swift");
21445
+ if (!existsSync10(manifestPath) || readFileSync16(manifestPath, "utf8") !== manifest)
21267
21446
  writeFileSync8(manifestPath, manifest);
21268
- const source = path32.join(sourceDir, "Link.swift");
21269
- if (!existsSync9(source)) writeFileSync8(source, "");
21447
+ const source = path33.join(sourceDir, "Link.swift");
21448
+ if (!existsSync10(source)) writeFileSync8(source, "");
21270
21449
  }
21271
21450
  function frameworkLinkClosure(scratch, roots) {
21272
21451
  const suffix = `${WASM_TRIPLE}-release`;
@@ -21278,7 +21457,7 @@ function frameworkLinkClosure(scratch, roots) {
21278
21457
  const objcHeaders = /* @__PURE__ */ new Map();
21279
21458
  let pending = null;
21280
21459
  let compiling = null;
21281
- for (const line of readFileSync16(path32.join(scratch, "release.yaml"), "utf8").split(
21460
+ for (const line of readFileSync16(path33.join(scratch, "release.yaml"), "utf8").split(
21282
21461
  "\n"
21283
21462
  )) {
21284
21463
  const phony = phonyHeader.exec(line);
@@ -21346,7 +21525,7 @@ function frameworkLinkClosure(scratch, roots) {
21346
21525
  owners.set(file, name);
21347
21526
  if (seen.has(file)) continue;
21348
21527
  seen.add(file);
21349
- if (!existsSync9(file))
21528
+ if (!existsSync10(file))
21350
21529
  throw new Error(`swift-compile: framework object ${file} was not built`);
21351
21530
  files.push(file);
21352
21531
  }
@@ -21362,22 +21541,94 @@ function frameworkLinkClosure(scratch, roots) {
21362
21541
  };
21363
21542
  }
21364
21543
  function removeCaseCollidingModuleArtifacts(modulesDir, keep) {
21365
- if (!existsSync9(modulesDir)) return;
21544
+ if (!existsSync10(modulesDir)) return;
21366
21545
  const folded = new Set([...keep].map((name) => name.toLowerCase()));
21367
21546
  for (const name of readdirSync6(modulesDir)) {
21368
21547
  const dot = name.indexOf(".");
21369
21548
  if (dot <= 0) continue;
21370
21549
  const module = name.slice(0, dot);
21371
21550
  if (keep.has(module) || !folded.has(module.toLowerCase())) continue;
21372
- rmSync7(path32.join(modulesDir, name), { recursive: true, force: true });
21551
+ rmSync7(path33.join(modulesDir, name), { recursive: true, force: true });
21552
+ }
21553
+ }
21554
+ var frameworkProductsReceiptSchema = object({
21555
+ modules: string(),
21556
+ objects: array(string()),
21557
+ lazyObjects: array(string()),
21558
+ owners: array(tuple([string(), string()])),
21559
+ providers: array(string()),
21560
+ link: array(string()),
21561
+ moduleMaps: array(string()),
21562
+ objcHeaders: array(tuple([string(), string()])),
21563
+ archived: array(tuple([string(), string()]))
21564
+ });
21565
+ function readFrameworkProductsReceipt(scratch, receiptKey) {
21566
+ const receiptFile = path33.join(scratch, "products-ready", `${receiptKey}.json`);
21567
+ if (!existsSync10(receiptFile)) return null;
21568
+ let parsed;
21569
+ try {
21570
+ parsed = parse(
21571
+ frameworkProductsReceiptSchema,
21572
+ JSON.parse(readFileSync16(receiptFile, "utf8"))
21573
+ );
21574
+ } catch {
21575
+ return null;
21373
21576
  }
21577
+ const archive = path33.join(scratch, "lib");
21578
+ const archiveStamp = path33.join(archive, ".receipt");
21579
+ const archiveMatches = existsSync10(archiveStamp) && readFileSync16(archiveStamp, "utf8") === receiptKey;
21580
+ if (!existsSync10(parsed.modules)) return null;
21581
+ for (const [object2] of parsed.archived) if (!existsSync10(object2)) return null;
21582
+ for (const file of parsed.providers) if (!existsSync10(file)) return null;
21583
+ for (const file of parsed.moduleMaps) if (!existsSync10(file)) return null;
21584
+ if (!archiveMatches) {
21585
+ rmSync7(archive, { recursive: true, force: true });
21586
+ mkdirSync8(archive, { recursive: true });
21587
+ for (const [object2, rel] of parsed.archived)
21588
+ symlinkSync2(object2, path33.join(scratch, rel));
21589
+ writeFileSync8(archiveStamp, receiptKey);
21590
+ }
21591
+ for (const file of parsed.objects) if (!existsSync10(file)) return null;
21592
+ for (const file of parsed.lazyObjects) if (!existsSync10(file)) return null;
21593
+ return {
21594
+ root: scratch,
21595
+ modules: parsed.modules,
21596
+ objects: parsed.objects,
21597
+ lazyObjects: parsed.lazyObjects,
21598
+ owners: new Map(parsed.owners),
21599
+ providers: parsed.providers,
21600
+ link: parsed.link,
21601
+ moduleMaps: parsed.moduleMaps,
21602
+ objcHeaders: new Map(parsed.objcHeaders)
21603
+ };
21374
21604
  }
21375
21605
  async function buildFrameworkProducts(scratch, args) {
21376
21606
  const linkedTargets = linkedFrameworkTargets(args.moduleRoot, args.input);
21377
- const linkRoot = path32.join(scratch, "link");
21607
+ const unoptimized = args.input.unoptimized === true;
21608
+ const sdkOptions = swiftCompileSdkOptions(args.moduleRoot, args.toolchainBin);
21609
+ const selectorOptions = swiftObjCSelectorOptions(args.moduleRoot);
21610
+ const receiptKey = createHash18("sha256").update(
21611
+ JSON.stringify([
21612
+ "framework-products/v1",
21613
+ args.frameworkKey,
21614
+ unoptimized,
21615
+ args.sdk,
21616
+ args.toolchainBin,
21617
+ [...linkedTargets.products].sort(),
21618
+ darwinRecordsMinimum(),
21619
+ args.plugins,
21620
+ sdkOptions,
21621
+ selectorOptions
21622
+ ])
21623
+ ).digest("hex").slice(0, 32);
21624
+ const ready = readFrameworkProductsReceipt(scratch, receiptKey);
21625
+ if (ready) return ready;
21626
+ await waitForNoSwiftRootReaders(scratch, args.buildOptions.signal);
21627
+ const linkRoot = path33.join(scratch, "link");
21378
21628
  writeFrameworkLinkPackage(linkRoot, args.moduleRoot, linkedTargets.products);
21629
+ const frameworkTmp = path33.join(scratch, "peach-compiler-tmp");
21630
+ mkdirSync8(frameworkTmp, { recursive: true });
21379
21631
  const jobs = swiftCompilerJobs();
21380
- const unoptimized = args.input.unoptimized === true;
21381
21632
  const targetJobs = unoptimized ? jobs >= 4 ? 2 : 1 : jobs;
21382
21633
  const driverJobs = unoptimized ? Math.max(1, Math.floor(jobs / targetJobs)) : jobs;
21383
21634
  await runCompiler(
@@ -21395,8 +21646,8 @@ async function buildFrameworkProducts(scratch, args) {
21395
21646
  scratch,
21396
21647
  "--target",
21397
21648
  FRAMEWORK_LINK_TARGET,
21398
- ...swiftCompileSdkOptions(args.moduleRoot, args.toolchainBin),
21399
- ...swiftObjCSelectorOptions(args.moduleRoot),
21649
+ ...sdkOptions,
21650
+ ...selectorOptions,
21400
21651
  "--swift-sdk",
21401
21652
  args.sdk,
21402
21653
  "-c",
@@ -21415,15 +21666,17 @@ async function buildFrameworkProducts(scratch, args) {
21415
21666
  "-Xswiftc",
21416
21667
  String(driverJobs)
21417
21668
  ] : ["-Xswiftc", "-Osize"],
21418
- // the release link strips all debug info, so none is generated
21669
+ // the release link strips all debug info, so none is generated. keep
21670
+ // -num-threads fixed across caller core caps so llbuild does not rebuild
21671
+ // every framework target when callers alternate --cores.
21419
21672
  "-Xswiftc",
21420
21673
  "-gnone",
21421
21674
  "-Xswiftc",
21422
21675
  "-num-threads",
21423
21676
  "-Xswiftc",
21424
- String(unoptimized ? 1 : jobs),
21677
+ String(unoptimized ? 1 : Math.min(4, os4.availableParallelism())),
21425
21678
  ...swiftReproducibleBuildFlags([
21426
- [path32.dirname(args.toolchainBin), "toolchain"],
21679
+ [path33.dirname(args.toolchainBin), "toolchain"],
21427
21680
  [args.moduleRoot, "framework"],
21428
21681
  [scratch, "framework-scratch"]
21429
21682
  ]),
@@ -21440,22 +21693,27 @@ async function buildFrameworkProducts(scratch, args) {
21440
21693
  `${plugin}#ExpoModulesMacros`
21441
21694
  ])
21442
21695
  ],
21696
+ // swiftpm hashes TMPDIR into its plan; keep one stable compiler scratch inside the locked slot.
21443
21697
  // the framework build's warnings alone pass the default 1 MiB cap, which kills
21444
21698
  // the build one step from the end.
21445
- { ...args.buildOptions, maxBuffer: 64 * 1024 * 1024 },
21699
+ {
21700
+ ...args.buildOptions,
21701
+ temporaryDirectory: frameworkTmp,
21702
+ maxBuffer: 64 * 1024 * 1024
21703
+ },
21446
21704
  SWIFTPM_PROGRESS,
21447
21705
  SWIFTPM_NOISE
21448
21706
  ).catch((error) => {
21449
21707
  throw new Error(outputOf(error), { cause: error });
21450
21708
  });
21451
- const release = path32.join(scratch, WASM_TRIPLE, "release");
21709
+ const release = path33.join(scratch, WASM_TRIPLE, "release");
21452
21710
  const linked = frameworkLinkClosure(scratch, linkedTargets.targets);
21453
21711
  const objects = linked.objects;
21454
21712
  if (linked.modules.has("UniformTypeIdentifiers")) {
21455
- const constantsDir = path32.join(scratch, "uniform-type-constants");
21456
- const constantsStamp = path32.join(constantsDir, ".complete");
21457
- const object2 = path32.join(constantsDir, "UniformTypeIdentifiers-NativeConstants.o");
21458
- if (!existsSync9(constantsStamp) || readFileSync16(constantsStamp, "utf8") !== args.frameworkKey) {
21713
+ const constantsDir = path33.join(scratch, "uniform-type-constants");
21714
+ const constantsStamp = path33.join(constantsDir, ".complete");
21715
+ const object2 = path33.join(constantsDir, "UniformTypeIdentifiers-NativeConstants.o");
21716
+ if (!existsSync10(constantsStamp) || readFileSync16(constantsStamp, "utf8") !== args.frameworkKey) {
21459
21717
  rmSync7(constantsDir, { recursive: true, force: true });
21460
21718
  mkdirSync8(constantsDir);
21461
21719
  const sdkPaths2 = swiftSdkPaths(args.moduleRoot, args.toolchainBin);
@@ -21472,11 +21730,11 @@ async function buildFrameworkProducts(scratch, args) {
21472
21730
  objects.push(object2);
21473
21731
  linked.owners.set(object2, "UniformTypeIdentifiers");
21474
21732
  }
21475
- removeCaseCollidingModuleArtifacts(path32.join(release, "Modules"), linked.modules);
21476
- const response = path32.join(scratch, "autolink-objects.rsp");
21733
+ removeCaseCollidingModuleArtifacts(path33.join(release, "Modules"), linked.modules);
21734
+ const response = path33.join(scratch, "autolink-objects.rsp");
21477
21735
  writeFileSync8(response, objects.map((file) => JSON.stringify(file)).join("\n") + "\n");
21478
21736
  const extracted = await runCompiler(
21479
- path32.join(args.toolchainBin, "swift-autolink-extract"),
21737
+ path33.join(args.toolchainBin, "swift-autolink-extract"),
21480
21738
  [`@${response}`, "-o", "-"],
21481
21739
  args.buildOptions
21482
21740
  );
@@ -21484,16 +21742,16 @@ async function buildFrameworkProducts(scratch, args) {
21484
21742
  const link = extracted.split("\n").map((line) => line.trim()).filter((flag, index, all) => flag.length > 0 && all.indexOf(flag) === index);
21485
21743
  if (link.includes("-lFoundation"))
21486
21744
  for (const name of foundationCategoryObjects) {
21487
- const object2 = path32.join(
21745
+ const object2 = path33.join(
21488
21746
  swiftSdkPaths(args.moduleRoot, args.toolchainBin).resources,
21489
21747
  `wasi/${name}.objc.o`
21490
21748
  );
21491
21749
  objects.push(object2);
21492
21750
  linked.owners.set(object2, "Foundation");
21493
21751
  }
21494
- const providerDir = path32.join(scratch, "darwin-records");
21495
- const providerStamp = path32.join(providerDir, ".complete");
21496
- if (!existsSync9(providerStamp) || readFileSync16(providerStamp, "utf8") !== args.frameworkKey) {
21752
+ const providerDir = path33.join(scratch, "darwin-records");
21753
+ const providerStamp = path33.join(providerDir, ".complete");
21754
+ if (!existsSync10(providerStamp) || readFileSync16(providerStamp, "utf8") !== args.frameworkKey) {
21497
21755
  rmSync7(providerDir, { recursive: true, force: true });
21498
21756
  mkdirSync8(providerDir);
21499
21757
  const sdkPaths2 = swiftSdkPaths(args.moduleRoot, args.toolchainBin);
@@ -21507,18 +21765,18 @@ async function buildFrameworkProducts(scratch, args) {
21507
21765
  });
21508
21766
  writeFileSync8(providerStamp, args.frameworkKey);
21509
21767
  }
21510
- const providers = readdirSync6(providerDir).filter((file) => file.endsWith(".o")).sort().map((file) => path32.join(providerDir, file));
21768
+ const providers = readdirSync6(providerDir).filter((file) => file.endsWith(".o")).sort().map((file) => path33.join(providerDir, file));
21511
21769
  for (const provider of providers) linked.owners.set(provider, "DarwinRecords");
21512
- const archive = path32.join(scratch, "lib");
21770
+ const archive = path33.join(scratch, "lib");
21513
21771
  rmSync7(archive, { recursive: true, force: true });
21514
21772
  mkdirSync8(archive);
21515
21773
  const archived = /* @__PURE__ */ new Map();
21516
21774
  for (const object2 of objects) {
21517
21775
  const target = linked.owners.get(object2);
21518
- const dir = path32.join(release, `${target}.build`);
21519
- if (!target || target === "Darwin" || !object2.startsWith(dir + path32.sep)) continue;
21520
- const name = `${target}-${path32.relative(dir, object2).replaceAll(path32.sep, "-").replace(/\.swift\.o$/, ".o")}`;
21521
- symlinkSync2(object2, path32.join(archive, name));
21776
+ const dir = path33.join(release, `${target}.build`);
21777
+ if (!target || target === "Darwin" || !object2.startsWith(dir + path33.sep)) continue;
21778
+ const name = `${target}-${path33.relative(dir, object2).replaceAll(path33.sep, "-").replace(/\.swift\.o$/, ".o")}`;
21779
+ symlinkSync2(object2, path33.join(archive, name));
21522
21780
  archived.set(object2, `lib/${name}`);
21523
21781
  }
21524
21782
  const roots = swiftObjcRootObjects(`${scratch}
@@ -21527,11 +21785,11 @@ ${args.frameworkKey}`, scratch, [
21527
21785
  ]);
21528
21786
  const linkedObjects = objects.map((object2) => {
21529
21787
  const name = archived.get(object2);
21530
- return name ? { path: path32.join(scratch, name), lazy: !roots.has(name) } : { path: object2, lazy: false };
21788
+ return name ? { path: path33.join(scratch, name), lazy: !roots.has(name) } : { path: object2, lazy: false };
21531
21789
  });
21532
- return {
21790
+ const result = {
21533
21791
  root: scratch,
21534
- modules: path32.join(release, "Modules"),
21792
+ modules: path33.join(release, "Modules"),
21535
21793
  objects: linkedObjects.filter((object2) => !object2.lazy).map((object2) => object2.path),
21536
21794
  lazyObjects: linkedObjects.filter((object2) => object2.lazy).map((object2) => object2.path),
21537
21795
  owners: linked.owners,
@@ -21540,6 +21798,27 @@ ${args.frameworkKey}`, scratch, [
21540
21798
  moduleMaps: linked.moduleMaps,
21541
21799
  objcHeaders: linked.objcHeaders
21542
21800
  };
21801
+ writeFileSync8(path33.join(archive, ".receipt"), receiptKey);
21802
+ const receiptsDir = path33.join(scratch, "products-ready");
21803
+ mkdirSync8(receiptsDir, { recursive: true });
21804
+ const receiptFile = path33.join(receiptsDir, `${receiptKey}.json`);
21805
+ const partialReceipt = `${receiptFile}.${process.pid}.${randomUUID5()}`;
21806
+ writeFileSync8(
21807
+ partialReceipt,
21808
+ JSON.stringify({
21809
+ modules: result.modules,
21810
+ objects: result.objects,
21811
+ lazyObjects: result.lazyObjects,
21812
+ owners: [...result.owners.entries()],
21813
+ providers: result.providers,
21814
+ link: result.link,
21815
+ moduleMaps: result.moduleMaps,
21816
+ objcHeaders: [...result.objcHeaders.entries()],
21817
+ archived: [...archived.entries()]
21818
+ })
21819
+ );
21820
+ renameSync5(partialReceipt, receiptFile);
21821
+ return result;
21543
21822
  }
21544
21823
  var SWIFT_LINK_STAMP = ".peach-link-stamp";
21545
21824
  var SWIFT_HOST_COMPILER_WRAPPER = ".peach-swiftc";
@@ -21548,14 +21827,14 @@ var SWIFT_FRAMEWORK_UNOPTIMIZED_SLOTS = 4;
21548
21827
  var SWIFT_FRAMEWORK_SLOT_KEY = ".peach-framework-key";
21549
21828
  var SWIFT_FRAMEWORK_SLOT_ORIGIN = ".peach-framework-origin";
21550
21829
  function swiftFrameworksDir(unoptimized = false) {
21551
- return path32.join(
21830
+ return path33.join(
21552
21831
  swiftCacheDir(),
21553
21832
  unoptimized ? "swift-frameworks-unoptimized" : "swift-frameworks"
21554
21833
  );
21555
21834
  }
21556
21835
  function swiftFrameworkSlotRecord(slot, record) {
21557
21836
  try {
21558
- return readFileSync16(path32.join(slot, record), "utf8").trim();
21837
+ return readFileSync16(path33.join(slot, record), "utf8").trim();
21559
21838
  } catch (error) {
21560
21839
  if (!vanished(error)) throw error;
21561
21840
  return null;
@@ -21568,7 +21847,7 @@ async function withSwiftFrameworkSlot(frameworkKey, moduleRoot, signal, work, un
21568
21847
  const slotCount = unoptimized ? SWIFT_FRAMEWORK_UNOPTIMIZED_SLOTS : SWIFT_FRAMEWORK_SLOTS;
21569
21848
  const slotsDir = swiftFrameworksDir(unoptimized);
21570
21849
  const slots = Array.from({ length: slotCount }, (_, index) => {
21571
- const slot = path32.join(slotsDir, `slot-${index}`);
21850
+ const slot = path33.join(slotsDir, `slot-${index}`);
21572
21851
  mkdirSync8(slot, { recursive: true });
21573
21852
  return slot;
21574
21853
  });
@@ -21584,16 +21863,18 @@ async function withSwiftFrameworkSlot(frameworkKey, moduleRoot, signal, work, un
21584
21863
  const inputs = new Map(
21585
21864
  swiftModuleInputFiles(moduleRoot).map((file) => [
21586
21865
  file,
21587
- readFileSync16(path32.join(moduleRoot, file))
21866
+ readFileSync16(path33.join(moduleRoot, file))
21588
21867
  ])
21589
21868
  );
21590
21869
  const ranked = slots.map((slot) => {
21591
21870
  let changes = 0;
21592
21871
  if (swiftFrameworkSlotKey(slot) === null) return { slot, changes: Infinity };
21593
- const source = path32.join(slot, "source", "packages", path32.basename(moduleRoot));
21872
+ const source = path33.join(slot, "source", "packages", path33.basename(moduleRoot));
21594
21873
  for (const [file, contents2] of inputs) {
21595
21874
  try {
21596
- if (!readFileSync16(path32.join(source, file)).equals(contents2)) changes++;
21875
+ const candidate = path33.join(source, file);
21876
+ if (statSync4(candidate).size !== contents2.length || !readFileSync16(candidate).equals(contents2))
21877
+ changes++;
21597
21878
  } catch (error) {
21598
21879
  if (!vanished(error)) throw error;
21599
21880
  changes++;
@@ -21604,11 +21885,13 @@ async function withSwiftFrameworkSlot(frameworkKey, moduleRoot, signal, work, un
21604
21885
  (left, right) => left.changes - right.changes || Number(own(right.slot)) - Number(own(left.slot)) || (built.get(right.slot) ?? 0) - (built.get(left.slot) ?? 0)
21605
21886
  );
21606
21887
  for (const { slot, changes } of ranked) {
21888
+ if (await hasLiveSwiftRootReaders(slot, signal)) continue;
21607
21889
  const result = await withSwiftRootLock(
21608
21890
  slot,
21609
21891
  async (lease) => {
21892
+ if (await hasLiveSwiftRootReaders(slot, signal)) return void 0;
21610
21893
  console.error(
21611
- `[swift-framework-cache] ${path32.basename(slot)} changedInputs=${changes} totalInputs=${inputs.size}`
21894
+ `[swift-framework-cache] ${path33.basename(slot)} changedInputs=${changes} totalInputs=${inputs.size}`
21612
21895
  );
21613
21896
  return { value: await run2(slot)(lease) };
21614
21897
  },
@@ -21627,8 +21910,8 @@ function mirrorTree2(source, target, skip) {
21627
21910
  for (const entry of readdirSync6(source, { withFileTypes: true })) {
21628
21911
  if (entry.name === skip) continue;
21629
21912
  wanted.add(entry.name);
21630
- const from = path32.join(source, entry.name);
21631
- const to = path32.join(target, entry.name);
21913
+ const from = path33.join(source, entry.name);
21914
+ const to = path33.join(target, entry.name);
21632
21915
  let existing = null;
21633
21916
  try {
21634
21917
  existing = lstatSync(to);
@@ -21652,52 +21935,54 @@ function mirrorTree2(source, target, skip) {
21652
21935
  const partial = `${to}.${randomUUID5()}`;
21653
21936
  copyFileSync2(from, partial);
21654
21937
  if (stat.mtimeMs > Date.now()) utimesSync(partial, stat.atime, stat.mtime);
21655
- renameSync6(partial, to);
21938
+ renameSync5(partial, to);
21656
21939
  }
21657
21940
  }
21658
21941
  for (const name of readdirSync6(target))
21659
21942
  if (!wanted.has(name) && name !== skip) {
21660
- rmSync7(path32.join(target, name), { recursive: true, force: true });
21943
+ rmSync7(path33.join(target, name), { recursive: true, force: true });
21661
21944
  restructured = true;
21662
21945
  }
21663
21946
  return restructured;
21664
21947
  }
21665
21948
  function stageFrameworkSource(moduleRoot, slot, frameworkKey, release) {
21666
21949
  if (!slot) return moduleRoot;
21667
- const staged = path32.join(slot, "source");
21668
- const stagedModule = path32.join(staged, "packages", path32.basename(moduleRoot));
21950
+ const staged = path33.join(slot, "source");
21951
+ const stagedModule = path33.join(staged, "packages", path33.basename(moduleRoot));
21669
21952
  const hadKey = swiftFrameworkSlotKey(slot);
21670
21953
  if (hadKey !== frameworkKey) {
21671
- rmSync7(path32.join(slot, SWIFT_FRAMEWORK_SLOT_KEY), { force: true });
21954
+ rmSync7(path33.join(slot, SWIFT_FRAMEWORK_SLOT_KEY), { force: true });
21955
+ rmSync7(path33.join(slot, "products-ready"), { recursive: true, force: true });
21956
+ rmSync7(path33.join(slot, "lib", ".receipt"), { force: true });
21672
21957
  const moduleRestructured = mirrorTree2(moduleRoot, stagedModule, ".build");
21673
21958
  const sdkRestructured = mirrorTree2(
21674
21959
  swiftSharedSdkRoot(moduleRoot, false),
21675
- path32.join(staged, "packages/peachsim/sdk/ios")
21960
+ path33.join(staged, "packages/peachsim/sdk/ios")
21676
21961
  );
21677
21962
  if (moduleRestructured || sdkRestructured || hadKey === null) {
21678
- rmSync7(path32.join(slot, "release.yaml"), { force: true });
21679
- rmSync7(path32.join(slot, WASM_TRIPLE, "release", "description.json"), {
21963
+ rmSync7(path33.join(slot, "release.yaml"), { force: true });
21964
+ rmSync7(path33.join(slot, WASM_TRIPLE, "release", "description.json"), {
21680
21965
  force: true
21681
21966
  });
21682
21967
  }
21683
21968
  for (const file of swiftModuleInputFiles(moduleRoot)) {
21684
21969
  if (!file.startsWith("../")) continue;
21685
- const from = path32.resolve(moduleRoot, file);
21686
- const to = path32.resolve(stagedModule, file);
21687
- if (existsSync9(to) && readFileSync16(from).equals(readFileSync16(to))) continue;
21688
- mkdirSync8(path32.dirname(to), { recursive: true });
21970
+ const from = path33.resolve(moduleRoot, file);
21971
+ const to = path33.resolve(stagedModule, file);
21972
+ if (existsSync10(to) && readFileSync16(from).equals(readFileSync16(to))) continue;
21973
+ mkdirSync8(path33.dirname(to), { recursive: true });
21689
21974
  copyFileSync2(from, to);
21690
21975
  }
21691
21976
  if (swiftProjectBuildKey(stagedModule, release) !== frameworkKey)
21692
21977
  throw new Error("Swift staged framework source differs from the caller");
21693
- const modules = path32.join(staged, "node_modules");
21694
- const target = realpathSync6(path32.join(moduleRoot, "../../node_modules"));
21695
- if (!existsSync9(modules) || readlinkSync(modules) !== target) {
21978
+ const modules = path33.join(staged, "node_modules");
21979
+ const target = realpathSync6(path33.join(moduleRoot, "../../node_modules"));
21980
+ if (!existsSync10(modules) || readlinkSync(modules) !== target) {
21696
21981
  rmSync7(modules, { recursive: true, force: true });
21697
21982
  symlinkSync2(target, modules);
21698
21983
  }
21699
- writeFileSync8(path32.join(slot, SWIFT_FRAMEWORK_SLOT_KEY), frameworkKey);
21700
- writeFileSync8(path32.join(slot, SWIFT_FRAMEWORK_SLOT_ORIGIN), moduleRoot);
21984
+ writeFileSync8(path33.join(slot, SWIFT_FRAMEWORK_SLOT_KEY), frameworkKey);
21985
+ writeFileSync8(path33.join(slot, SWIFT_FRAMEWORK_SLOT_ORIGIN), moduleRoot);
21701
21986
  }
21702
21987
  return stagedModule;
21703
21988
  }
@@ -21737,7 +22022,7 @@ ${args.prebuilt.modules}
21737
22022
  `);
21738
22023
  for (const entry of readdirSync6(args.prebuilt.modules).sort())
21739
22024
  hash.update(`${entry}
21740
- ${statOf(path32.join(args.prebuilt.modules, entry))}`);
22025
+ ${statOf(path33.join(args.prebuilt.modules, entry))}`);
21741
22026
  return hash.digest("hex");
21742
22027
  }
21743
22028
  function retireSwiftLinkTargets(retired) {
@@ -21746,13 +22031,13 @@ function retireSwiftLinkTargets(retired) {
21746
22031
  "peach-product-checkpoints",
21747
22032
  "peach-swift-header-checkpoints"
21748
22033
  ]) {
21749
- rmSync7(path32.join(retired, name), { recursive: true, force: true });
22034
+ rmSync7(path33.join(retired, name), { recursive: true, force: true });
21750
22035
  }
21751
- const releaseLink = path32.join(retired, "release");
21752
- if (!existsSync9(releaseLink)) return;
22036
+ const releaseLink = path33.join(retired, "release");
22037
+ if (!existsSync10(releaseLink)) return;
21753
22038
  const releaseDir = realpathSync6(releaseLink);
21754
22039
  for (const entry of readdirSync6(releaseDir, { withFileTypes: true })) {
21755
- const targetPath = path32.join(releaseDir, entry.name);
22040
+ const targetPath = path33.join(releaseDir, entry.name);
21756
22041
  if (entry.name === "ModuleCache" || entry.name === "Modules" || entry.name.endsWith(".product") || entry.name.endsWith(".wasm")) {
21757
22042
  rmSync7(targetPath, { recursive: true, force: true });
21758
22043
  continue;
@@ -21765,7 +22050,7 @@ function retireSwiftLinkTargets(retired) {
21765
22050
  }
21766
22051
  }
21767
22052
  function retireStaleSwiftLink(root, baseStamp, stamp, preserveClangObjects = false) {
21768
- const receipt = path32.join(root, SWIFT_LINK_STAMP);
22053
+ const receipt = path33.join(root, SWIFT_LINK_STAMP);
21769
22054
  let previous = null;
21770
22055
  try {
21771
22056
  previous = readFileSync16(receipt, "utf8").trim();
@@ -21777,8 +22062,8 @@ function retireStaleSwiftLink(root, baseStamp, stamp, preserveClangObjects = fal
21777
22062
  ${stamp}`;
21778
22063
  writeFileSync8(receipt, `${combined}
21779
22064
  `);
21780
- const retired = path32.join(root, ".build");
21781
- if (previous === combined || !existsSync9(retired)) return false;
22065
+ const retired = path33.join(root, ".build");
22066
+ if (previous === combined || !existsSync10(retired)) return false;
21782
22067
  const [previousBase] = previous?.split("\n") ?? [];
21783
22068
  if (preserveClangObjects && previousBase === baseStamp) {
21784
22069
  retireSwiftLinkTargets(retired);
@@ -21803,11 +22088,11 @@ async function compileSwiftProjectOnce(sources, options) {
21803
22088
  mkdirSync8(options.buildRoot, { recursive: true });
21804
22089
  const root = realpathSync6(options.buildRoot);
21805
22090
  refreshSwiftCacheHold(root);
21806
- const moduleRoot = path32.resolve(options.moduleRoot);
22091
+ const moduleRoot = path33.resolve(options.moduleRoot);
21807
22092
  const distribution = swiftDistributionAt(moduleRoot);
21808
22093
  const mirrorDistribution = options.linkOnly || options.project ? null : distribution;
21809
22094
  if (distribution) refreshSwiftCacheHold(moduleRoot);
21810
- const input = distribution && !options.intermediates ? (await import("./swift-package-prebuilt-4N5CXBOZ.mjs")).useSwiftPackagePrebuilts(
22095
+ const input = distribution && !options.intermediates ? (await import("./swift-package-prebuilt-ROIDLGLU.mjs")).useSwiftPackagePrebuilts(
21811
22096
  sources,
21812
22097
  moduleRoot,
21813
22098
  options.toolchainBin
@@ -21817,11 +22102,11 @@ async function compileSwiftProjectOnce(sources, options) {
21817
22102
  throw new Error("swift-compile: link-only builds do not support guest image graphs");
21818
22103
  const layout2 = {
21819
22104
  root,
21820
- sources: path32.join(root, "Sources", "App"),
22105
+ sources: path33.join(root, "Sources", "App"),
21821
22106
  multi: compileTargets(input).length > 0
21822
22107
  };
21823
22108
  const sdkModule = options.sdkModule && !options.linkOnly;
21824
- const sdkImage = sdkModule ? await (await import("./swift-sdk-image-7T2LMQS5.mjs")).buildSwiftSdkImage(
22109
+ const sdkImage = sdkModule ? await (await import("./swift-sdk-image-SNFZVUQ3.mjs")).buildSwiftSdkImage(
21825
22110
  moduleRoot,
21826
22111
  !!guestGraph,
21827
22112
  distribution ? [] : linkedFrameworkTargets(moduleRoot, input).imports,
@@ -21833,7 +22118,7 @@ async function compileSwiftProjectOnce(sources, options) {
21833
22118
  const hash = sdkImage ? createHash18("sha256").update(`${sourceHash}
21834
22119
  sdk module ${sdkImage.key}`).digest("hex") : sourceHash;
21835
22120
  const frameworkKey = swiftProjectBuildKey(moduleRoot, options.release);
21836
- const sharedRoot = path32.join(swiftCacheDir(), "swift-projects", hash);
22121
+ const sharedRoot = path33.join(swiftCacheDir(), "swift-projects", hash);
21837
22122
  const report = (message) => {
21838
22123
  console.error(`[swift-project ${hash.slice(0, 16)}] ${message}`);
21839
22124
  options.onStage?.(message);
@@ -21848,8 +22133,8 @@ sdk module ${sdkImage.key}`).digest("hex") : sourceHash;
21848
22133
  report("reusing memory artifact");
21849
22134
  return retain(root, retained);
21850
22135
  }
21851
- const cached = readCompiledArtifact(path32.join(sharedRoot, "artifact"), hash);
21852
- const previous = cached ?? (options.project ? null : readCompiledArtifact(path32.join(root, "artifact"), hash));
22136
+ const cached = readCompiledArtifact(path33.join(sharedRoot, "artifact"), hash);
22137
+ const previous = cached ?? (options.project ? null : readCompiledArtifact(path33.join(root, "artifact"), hash));
21853
22138
  if (previous) {
21854
22139
  if (cached) renewSharedArtifact(sharedRoot);
21855
22140
  else saveSharedArtifact(sharedRoot, previous);
@@ -21859,8 +22144,8 @@ sdk module ${sdkImage.key}`).digest("hex") : sourceHash;
21859
22144
  }
21860
22145
  if (!options.intermediates && !sdkImage && process.platform === "darwin" && process.env.TM_SESSION && !windowAdmission() && process.env.CI !== "true" && moduleRoot === sourceSwiftCheckout() && !swiftDistributionAt(moduleRoot)) {
21861
22146
  const requestRoot = mkdtempSync4(`${root}.builder-request-`);
21862
- const output = path32.join(requestRoot, "output");
21863
- const request = path32.join(requestRoot, "request.json");
22147
+ const output = path33.join(requestRoot, "output");
22148
+ const request = path33.join(requestRoot, "request.json");
21864
22149
  writeFileSync8(
21865
22150
  request,
21866
22151
  JSON.stringify({
@@ -21874,13 +22159,13 @@ sdk module ${sdkImage.key}`).digest("hex") : sourceHash;
21874
22159
  })
21875
22160
  );
21876
22161
  try {
21877
- const repo = path32.resolve(moduleRoot, "../..");
22162
+ const repo = path33.resolve(moduleRoot, "../..");
21878
22163
  const timeout = swiftBuilderHopTimeoutMs(options.timeoutMs);
21879
22164
  report("requesting builder admission or cached result");
21880
22165
  await runCompiler(
21881
22166
  "bun",
21882
22167
  [
21883
- path32.join(repo, "scripts/build/swift-project.ts"),
22168
+ path33.join(repo, "scripts/build/swift-project.ts"),
21884
22169
  "--request",
21885
22170
  request,
21886
22171
  "--output",
@@ -21930,14 +22215,14 @@ ${cap}` : "";
21930
22215
  root,
21931
22216
  async (lease) => {
21932
22217
  if (!options.intermediates) {
21933
- const built = readCompiledArtifact(path32.join(sharedRoot, "artifact"), hash);
22218
+ const built = readCompiledArtifact(path33.join(sharedRoot, "artifact"), hash);
21934
22219
  if (built) {
21935
22220
  report("reusing verified disk artifact");
21936
22221
  return retain(root, built);
21937
22222
  }
21938
22223
  }
21939
- const swift = path32.join(options.toolchainBin, "swift");
21940
- if (!existsSync9(swift)) {
22224
+ const swift = path33.join(options.toolchainBin, "swift");
22225
+ if (!existsSync10(swift)) {
21941
22226
  throw new Error(
21942
22227
  `swift-compile: no swift.org toolchain at ${options.toolchainBin}; install ${options.release} and its matching wasm sdk`
21943
22228
  );
@@ -21950,54 +22235,82 @@ ${cap}` : "";
21950
22235
  work,
21951
22236
  unoptimized
21952
22237
  );
21953
- return withFrameworkLock(async (slot, frameworkLease) => {
22238
+ const baseBuildEnv = {
22239
+ ...options.project?.env ?? process.env,
22240
+ // shipped host plugins resolve against the selected compiler's runtime.
22241
+ ...process.platform === "linux" ? {
22242
+ LD_LIBRARY_PATH: [
22243
+ path33.resolve(options.toolchainBin, "../lib/swift/linux"),
22244
+ path33.resolve(options.toolchainBin, "../lib/swift/host"),
22245
+ process.env.LD_LIBRARY_PATH
22246
+ ].filter(Boolean).join(":")
22247
+ } : {},
22248
+ PEACH_DEFER_WASM_LINK: "1"
22249
+ };
22250
+ const {
22251
+ frameworkRoot,
22252
+ compileFrameworkRoot,
22253
+ macroPlugins,
22254
+ sdk,
22255
+ icu,
22256
+ prebuilt,
22257
+ readHold
22258
+ } = await withFrameworkLock(async (slot, frameworkLease) => {
21954
22259
  budget.startCompile();
21955
- const frameworkRoot = mirrorDistribution ? syncSwiftDistributionMirror(root, moduleRoot, mirrorDistribution) : distribution ? moduleRoot : stageFrameworkSource(moduleRoot, slot, frameworkKey, options.release);
21956
- if (!swiftModuleDigest(frameworkRoot).equals(moduleDigest))
22260
+ if (slot && swiftFrameworkSlotKey(slot) !== frameworkKey)
22261
+ await waitForNoSwiftRootReaders(slot, budget.signal);
22262
+ const frameworkRoot2 = mirrorDistribution ? syncSwiftDistributionMirror(root, moduleRoot, mirrorDistribution) : distribution ? moduleRoot : stageFrameworkSource(moduleRoot, slot, frameworkKey, options.release);
22263
+ if (!swiftModuleDigest(frameworkRoot2).equals(moduleDigest))
21957
22264
  throw new Error("Swift staged project source differs from the caller");
21958
22265
  report("preparing compiler plugins");
21959
- const macroPlugins = await ensureMacroPlugins(
21960
- frameworkRoot,
22266
+ const macroPlugins2 = await ensureMacroPlugins(
22267
+ frameworkRoot2,
21961
22268
  options.toolchainBin,
21962
22269
  options.release,
21963
22270
  budget.signal,
21964
22271
  frameworkLease
21965
22272
  );
21966
- const compileFrameworkRoot = distribution ? swiftDistributionCompileView(frameworkRoot, distribution) : frameworkRoot;
21967
- const sdk = swiftModuleSdk(frameworkRoot).wasmSdkId;
21968
- const icu = options.linkOnly ? null : swiftIcuAsset(options.toolchainBin, sdk);
21969
- const buildOptions = {
21970
- env: {
21971
- ...options.project?.env ?? process.env,
21972
- // shipped host plugins resolve against the selected compiler's runtime.
21973
- ...process.platform === "linux" ? {
21974
- LD_LIBRARY_PATH: [
21975
- path32.resolve(options.toolchainBin, "../lib/swift/linux"),
21976
- path32.resolve(options.toolchainBin, "../lib/swift/host"),
21977
- process.env.LD_LIBRARY_PATH
21978
- ].filter(Boolean).join(":")
21979
- } : {},
21980
- PEACH_DEFER_WASM_LINK: "1"
21981
- },
21982
- maxBuffer: 64 * 1024 * 1024,
21983
- signal: budget.signal,
21984
- lease,
21985
- frameworkLease
21986
- };
21987
- let prebuilt;
22273
+ const compileFrameworkRoot2 = distribution ? swiftDistributionCompileView(frameworkRoot2, distribution) : frameworkRoot2;
22274
+ const sdk2 = swiftModuleSdk(frameworkRoot2).wasmSdkId;
22275
+ const icu2 = options.linkOnly ? null : swiftIcuAsset(options.toolchainBin, sdk2);
22276
+ let prebuilt2;
21988
22277
  if (!distribution) {
21989
22278
  report("compiling framework products");
21990
- prebuilt = await buildFrameworkProducts(slot, {
21991
- moduleRoot: frameworkRoot,
22279
+ prebuilt2 = await buildFrameworkProducts(slot, {
22280
+ moduleRoot: frameworkRoot2,
21992
22281
  frameworkKey,
21993
22282
  input,
21994
22283
  swift,
21995
- sdk,
22284
+ sdk: sdk2,
21996
22285
  toolchainBin: options.toolchainBin,
21997
- plugins: macroPlugins,
21998
- buildOptions
22286
+ plugins: macroPlugins2,
22287
+ buildOptions: {
22288
+ env: baseBuildEnv,
22289
+ maxBuffer: 64 * 1024 * 1024,
22290
+ signal: budget.signal,
22291
+ lease,
22292
+ frameworkLease
22293
+ }
21999
22294
  });
22000
22295
  }
22296
+ const readHold2 = slot ? acquireSwiftRootReadHold(slot) : void 0;
22297
+ return {
22298
+ frameworkRoot: frameworkRoot2,
22299
+ compileFrameworkRoot: compileFrameworkRoot2,
22300
+ macroPlugins: macroPlugins2,
22301
+ sdk: sdk2,
22302
+ icu: icu2,
22303
+ prebuilt: prebuilt2,
22304
+ readHold: readHold2
22305
+ };
22306
+ });
22307
+ const buildOptions = {
22308
+ env: baseBuildEnv,
22309
+ maxBuffer: 64 * 1024 * 1024,
22310
+ signal: budget.signal,
22311
+ lease
22312
+ };
22313
+ try {
22001
22314
  if (options.project) removeProjectLinks(root);
22002
22315
  const packageHostMacros = process.platform === "linux" ? input.packageHostMacros : void 0;
22003
22316
  if (retireStaleSwiftLink(
@@ -22025,20 +22338,20 @@ ${cap}` : "";
22025
22338
  !options.project,
22026
22339
  options.project ? false : options.objcPrebuiltStage ?? (options.intermediates ? false : void 0)
22027
22340
  );
22028
- const productFile = path32.join(frameworkRoot, SWIFT_FRAMEWORK_PRODUCT_FILE);
22341
+ const productFile = path33.join(frameworkRoot, SWIFT_FRAMEWORK_PRODUCT_FILE);
22029
22342
  writeSwiftAutolinkLinker(
22030
22343
  root,
22031
22344
  options.toolchainBin,
22032
- existsSync9(productFile) ? [
22345
+ existsSync10(productFile) ? [
22033
22346
  parse(
22034
22347
  swiftFrameworkProductSchema,
22035
22348
  JSON.parse(readFileSync16(productFile, "utf8"))
22036
22349
  ).product.name
22037
22350
  ] : []
22038
22351
  );
22039
- const compiler = preparation.targetToolset ? { CC: path32.join(root, CLANG_TARGET_MODULE_WRAPPER) } : {};
22352
+ const compiler = preparation.targetToolset ? { CC: path33.join(root, CLANG_TARGET_MODULE_WRAPPER) } : {};
22040
22353
  if (packageHostMacros?.length) {
22041
- const swiftc = path32.join(root, SWIFT_HOST_COMPILER_WRAPPER);
22354
+ const swiftc = path33.join(root, SWIFT_HOST_COMPILER_WRAPPER);
22042
22355
  writeBuildFile(
22043
22356
  swiftc,
22044
22357
  [
@@ -22065,10 +22378,10 @@ ${cap}` : "";
22065
22378
  chmodSync3(swiftc, 493);
22066
22379
  compiler.SWIFT_EXEC = swiftc;
22067
22380
  compiler.PEACH_SWIFT_HOST_MACROS = packageHostMacros.join(",");
22068
- compiler.PEACH_SWIFTC = path32.join(options.toolchainBin, "swiftc");
22381
+ compiler.PEACH_SWIFTC = path33.join(options.toolchainBin, "swiftc");
22069
22382
  }
22070
22383
  const projectProcess = options.project ? prepareSwiftProjectProcess(root, options.project) : void 0;
22071
- const temporaryDirectory = projectProcess ? void 0 : path32.join(root, ".build", "peach-compiler-tmp");
22384
+ const temporaryDirectory = projectProcess ? void 0 : path33.join(root, ".build", "peach-compiler-tmp");
22072
22385
  const appOptions = projectProcess ? {
22073
22386
  ...buildOptions,
22074
22387
  uid: projectProcess.uid,
@@ -22086,10 +22399,10 @@ ${cap}` : "";
22086
22399
  for (const [file, text2] of Object.entries(input.files)) {
22087
22400
  const parents = /^#include "((?:\.\.\/)+)[^"\n]+"\n$/.exec(text2)?.[1];
22088
22401
  if (!parents) continue;
22089
- const directory = path32.posix.dirname(file);
22402
+ const directory = path33.posix.dirname(file);
22090
22403
  forwarders.set(
22091
- `${path32.join(root, directory)}/${parents.slice(0, -1)}`,
22092
- path32.posix.join("build", directory, parents).replace(/\/$/, "")
22404
+ `${path33.join(root, directory)}/${parents.slice(0, -1)}`,
22405
+ path33.posix.join("build", directory, parents).replace(/\/$/, "")
22093
22406
  );
22094
22407
  }
22095
22408
  const jobs = swiftCompilerJobs();
@@ -22108,7 +22421,7 @@ ${cap}` : "";
22108
22421
  ...swiftObjCSelectorOptions(frameworkRoot),
22109
22422
  "--swift-sdk",
22110
22423
  sdk,
22111
- ...preparation.targetToolset ? ["--toolset", path32.join(root, ".peach-target-toolset.json")] : [],
22424
+ ...preparation.targetToolset ? ["--toolset", path33.join(root, ".peach-target-toolset.json")] : [],
22112
22425
  "-c",
22113
22426
  "release",
22114
22427
  ...input.unoptimized ? ["-Xswiftc", "-Onone"] : [],
@@ -22127,19 +22440,16 @@ ${cap}` : "";
22127
22440
  // the link strips debug info, so none is generated (as for the framework)
22128
22441
  "-Xswiftc",
22129
22442
  "-gnone",
22130
- "-Xswiftc",
22131
- "-num-threads",
22132
- "-Xswiftc",
22133
- String(perFile ? 1 : jobs),
22443
+ ...incrementalPreview ? [] : ["-Xswiftc", "-num-threads", "-Xswiftc", String(perFile ? 1 : jobs)],
22134
22444
  ...swiftReproducibleBuildFlags([
22135
- [path32.dirname(options.toolchainBin), "toolchain"],
22445
+ [path33.dirname(options.toolchainBin), "toolchain"],
22136
22446
  [compileFrameworkRoot, "framework"],
22137
22447
  [root, "build"],
22138
22448
  ...forwarders
22139
22449
  ]).flatMap((flag, index, flags) => {
22140
22450
  if (!nativeToolset || !flag.startsWith("-ffile-prefix-map="))
22141
22451
  return [flag];
22142
- const toolchainDir = path32.dirname(options.toolchainBin);
22452
+ const toolchainDir = path33.dirname(options.toolchainBin);
22143
22453
  let mapped = flag;
22144
22454
  for (const [dir, target] of [
22145
22455
  [root, "/peach/build"],
@@ -22168,12 +22478,12 @@ ${cap}` : "";
22168
22478
  ])
22169
22479
  ];
22170
22480
  const linked = builtArtifact(layout2);
22171
- rmSync7(path32.join(root, ".peach-link.rsp"), { force: true });
22172
- if (options.linkOnly || existsSync9(linked) && statSync4(linked).size <= 8)
22481
+ rmSync7(path33.join(root, ".peach-link.rsp"), { force: true });
22482
+ if (options.linkOnly || existsSync10(linked) && statSync4(linked).size <= 8)
22173
22483
  rmSync7(linked, { force: true });
22174
22484
  report("compiling and linking Swift modules");
22175
22485
  const frameworkInterfaces = /* @__PURE__ */ new Map();
22176
- const sdkFrameworks = path32.join(
22486
+ const sdkFrameworks = path33.join(
22177
22487
  swiftSdkPaths(frameworkRoot, options.toolchainBin).darwin,
22178
22488
  "System/Library/Frameworks"
22179
22489
  );
@@ -22188,39 +22498,39 @@ ${cap}` : "";
22188
22498
  const name = moduleMapName(contents2);
22189
22499
  const umbrella = /\bumbrella\s+header\s+"([^"]+)"/.exec(contents2)?.[1];
22190
22500
  if (!name || !umbrella) continue;
22191
- const header = input.files[path32.posix.join(path32.posix.dirname(file), umbrella)];
22501
+ const header = input.files[path33.posix.join(path33.posix.dirname(file), umbrella)];
22192
22502
  if (header === void 0) continue;
22193
22503
  const included = new Set(
22194
22504
  [
22195
22505
  ...header.matchAll(/^\s*#\s*(?:import|include)\s*[<"]([^">]+)[">]/gm)
22196
- ].map((match) => path32.posix.basename(match[1]))
22506
+ ].map((match) => path33.posix.basename(match[1]))
22197
22507
  );
22198
22508
  const declarations = nativeDeclarations.get(name) ?? /* @__PURE__ */ new Set();
22199
22509
  for (const declaration of swiftInterfaceDeclarations(header))
22200
22510
  declarations.add(declaration);
22201
22511
  for (const [candidate, source] of Object.entries(input.files))
22202
- if (included.has(path32.posix.basename(candidate)))
22512
+ if (included.has(path33.posix.basename(candidate)))
22203
22513
  for (const declaration of swiftInterfaceDeclarations(source))
22204
22514
  declarations.add(declaration);
22205
22515
  nativeDeclarations.set(name, declarations);
22206
22516
  }
22207
22517
  const frameworkInterface = (name) => {
22208
22518
  if (frameworkInterfaces.has(name)) return frameworkInterfaces.get(name);
22209
- const source = distribution ? path32.join(frameworkRoot, "modules", `${name}-Swift.h`) : prebuilt.objcHeaders.get(name);
22210
- if (!source || !existsSync9(source)) {
22519
+ const source = distribution ? path33.join(frameworkRoot, "modules", `${name}-Swift.h`) : prebuilt.objcHeaders.get(name);
22520
+ if (!source || !existsSync10(source)) {
22211
22521
  frameworkInterfaces.set(name, null);
22212
22522
  return null;
22213
22523
  }
22214
- const headers = path32.join(sdkFrameworks, `${name}.framework/Headers`);
22524
+ const headers = path33.join(sdkFrameworks, `${name}.framework/Headers`);
22215
22525
  const declared = /* @__PURE__ */ new Set();
22216
- if (existsSync9(headers)) {
22526
+ if (existsSync10(headers)) {
22217
22527
  for (const file of readdirSync6(headers, {
22218
22528
  recursive: true,
22219
22529
  encoding: "utf8"
22220
22530
  }))
22221
22531
  if (file.endsWith(".h"))
22222
22532
  for (const name2 of swiftInterfaceDeclarations(
22223
- readFileSync16(path32.join(headers, file), "utf8")
22533
+ readFileSync16(path33.join(headers, file), "utf8")
22224
22534
  ))
22225
22535
  declared.add(name2);
22226
22536
  }
@@ -22249,20 +22559,20 @@ ${cap}` : "";
22249
22559
  [...new Set(foreign.values())].map((owner) => `#import <${owner}/${owner}.h>`).join("\n")
22250
22560
  ) : own;
22251
22561
  const value = {
22252
- file: path32.join(root, ".build/peach-framework-objc", `${name}-Swift.h`),
22562
+ file: path33.join(root, ".build/peach-framework-objc", `${name}-Swift.h`),
22253
22563
  header,
22254
- module: existsSync9(headers)
22564
+ module: existsSync10(headers)
22255
22565
  };
22256
22566
  frameworkInterfaces.set(name, value);
22257
22567
  writeBuildFile(
22258
22568
  value.file,
22259
- (existsSync9(path32.join(headers, `${name}.h`)) ? `#import <${name}/${name}.h>
22569
+ (existsSync10(path33.join(headers, `${name}.h`)) ? `#import <${name}/${name}.h>
22260
22570
  ` : "") + swiftHeaderWithSuperclassImports(header, frameworkInterface)
22261
22571
  );
22262
22572
  return value;
22263
22573
  };
22264
22574
  const headerPaths = (producer) => {
22265
- const stem = path32.join(
22575
+ const stem = path33.join(
22266
22576
  root,
22267
22577
  ".build",
22268
22578
  "peach-cxx-headers",
@@ -22290,7 +22600,7 @@ ${cap}` : "";
22290
22600
  };
22291
22601
  const recipe = inputHash.copy().update(
22292
22602
  distribution ? swiftCompileSurfaceDigest(frameworkRoot) : moduleDigest
22293
- ).update(readFileSync16(path32.join(root, "Package.swift"))).update(JSON.stringify(buildArgs)).digest("hex");
22603
+ ).update(readFileSync16(path33.join(root, "Package.swift"))).update(JSON.stringify(buildArgs)).digest("hex");
22294
22604
  const runApp = async (compiler2) => {
22295
22605
  const optionsWithCompiler = compiler2 ? { ...appOptions, env: { ...appOptions.env, ...compiler2 } } : appOptions;
22296
22606
  const stages = [
@@ -22304,33 +22614,33 @@ ${cap}` : "";
22304
22614
  producers: []
22305
22615
  }))
22306
22616
  ];
22307
- const checkpoints = path32.join(root, ".build", "peach-product-checkpoints");
22617
+ const checkpoints = path33.join(root, ".build", "peach-product-checkpoints");
22308
22618
  for (const { target, producers } of stages) {
22309
- const receipt = path32.join(
22619
+ const receipt = path33.join(
22310
22620
  checkpoints,
22311
22621
  createHash18("sha256").update(target).digest("hex")
22312
22622
  );
22313
22623
  const headers = producers.map(headerPaths);
22314
22624
  for (const header of headers)
22315
- if (existsSync9(header.original)) publishHeader(header);
22625
+ if (existsSync10(header.original)) publishHeader(header);
22316
22626
  const fingerprint = () => {
22317
22627
  const digest = createHash18("sha256").update(recipe);
22318
22628
  for (const { original, emitted } of headers) {
22319
- if (!existsSync9(original) || !existsSync9(emitted)) return;
22629
+ if (!existsSync10(original) || !existsSync10(emitted)) return;
22320
22630
  digest.update(
22321
22631
  createHash18("sha256").update(readFileSync16(emitted)).digest()
22322
22632
  );
22323
22633
  }
22324
22634
  return digest.digest("hex");
22325
22635
  };
22326
- if (!options.project && existsSync9(receipt) && readFileSync16(receipt, "utf8") === fingerprint())
22636
+ if (!options.project && existsSync10(receipt) && readFileSync16(receipt, "utf8") === fingerprint())
22327
22637
  continue;
22328
22638
  if (!options.project) rmSync7(receipt, { force: true });
22329
22639
  for (const header of headers) {
22330
- if (!existsSync9(header.original))
22640
+ if (!existsSync10(header.original))
22331
22641
  rmSync7(
22332
- path32.join(
22333
- path32.dirname(linked),
22642
+ path33.join(
22643
+ path33.dirname(linked),
22334
22644
  "Modules",
22335
22645
  `${swiftTargetModuleName(header.producer)}.swiftmodule`
22336
22646
  ),
@@ -22351,7 +22661,7 @@ ${cap}` : "";
22351
22661
  throw new Error(`missing Swift headers after building ${target}`);
22352
22662
  mkdirSync8(checkpoints, { recursive: true });
22353
22663
  writeFileSync8(`${receipt}.partial`, checkpoint);
22354
- renameSync6(`${receipt}.partial`, receipt);
22664
+ renameSync5(`${receipt}.partial`, receipt);
22355
22665
  }
22356
22666
  }
22357
22667
  await runCompiler(
@@ -22385,14 +22695,14 @@ ${cap}` : "";
22385
22695
  await compileApp();
22386
22696
  } catch (error) {
22387
22697
  const output2 = outputOf(error);
22388
- const moduleCache = path32.join(
22698
+ const moduleCache = path33.join(
22389
22699
  root,
22390
22700
  ".build",
22391
22701
  WASM_TRIPLE,
22392
22702
  "release",
22393
22703
  "ModuleCache"
22394
22704
  );
22395
- if (output2.includes("was compiled with module cache path") && existsSync9(moduleCache)) {
22705
+ if (output2.includes("was compiled with module cache path") && existsSync10(moduleCache)) {
22396
22706
  rmSync7(moduleCache, { recursive: true, force: true });
22397
22707
  try {
22398
22708
  await compileApp();
@@ -22419,11 +22729,11 @@ ${cap}` : "";
22419
22729
  if (options.project) endSwiftProjectProcesses(options.project);
22420
22730
  }
22421
22731
  if (unprepared.length) throw new Error(unprepared.join("\n"));
22422
- if (!existsSync9(linked)) {
22423
- const binDir = path32.dirname(linked);
22424
- const found = existsSync9(binDir) ? readdirSync6(binDir).filter((name) => name.endsWith(".wasm")).sort() : [];
22732
+ if (!existsSync10(linked)) {
22733
+ const binDir = path33.dirname(linked);
22734
+ const found = existsSync10(binDir) ? readdirSync6(binDir).filter((name) => name.endsWith(".wasm")).sort() : [];
22425
22735
  throw new Error(
22426
- `swift-compile: the build produced no ${path32.basename(linked)} (found: ${found.join(", ") || "none"})`
22736
+ `swift-compile: the build produced no ${path33.basename(linked)} (found: ${found.join(", ") || "none"})`
22427
22737
  );
22428
22738
  }
22429
22739
  if (options.project) removeProjectLinks(root);
@@ -22454,10 +22764,10 @@ ${cap}` : "";
22454
22764
  const binding = await compileGuestLink({
22455
22765
  graph: guestGraph,
22456
22766
  buildDirectory: root,
22457
- releaseDirectory: path32.dirname(linked),
22767
+ releaseDirectory: path33.dirname(linked),
22458
22768
  moduleRoot: frameworkRoot,
22459
22769
  toolchainBin: options.toolchainBin,
22460
- swiftCompiler: preparation.headerCompiler ? path32.join(root, SWIFT_HEADER_COMPILER_WRAPPER) : compiler.SWIFT_EXEC ?? path32.join(options.toolchainBin, "swiftc"),
22770
+ swiftCompiler: preparation.headerCompiler ? path33.join(root, SWIFT_HEADER_COMPILER_WRAPPER) : compiler.SWIFT_EXEC ?? path33.join(options.toolchainBin, "swiftc"),
22461
22771
  sysroot: swiftSdkPaths(frameworkRoot, options.toolchainBin).sysroot,
22462
22772
  sdk: swiftModuleSdk(frameworkRoot),
22463
22773
  sdkImage,
@@ -22478,7 +22788,7 @@ ${cap}` : "";
22478
22788
  if (sdkImage && binding)
22479
22789
  sdkAsset = { key: sdkImage.key, sha256: sdkImage.sha256, binding };
22480
22790
  } else if (sdkImage) {
22481
- const { buildSwiftAppModule } = await import("./swift-sdk-app-module-5IUSRXYA.mjs");
22791
+ const { buildSwiftAppModule } = await import("./swift-sdk-app-module-5VU63S56.mjs");
22482
22792
  const binding = await buildSwiftAppModule({
22483
22793
  buildRoot: root,
22484
22794
  toolchainBin: options.toolchainBin,
@@ -22488,7 +22798,7 @@ ${cap}` : "";
22488
22798
  project: options.project && {
22489
22799
  ...options.project,
22490
22800
  env: { ...options.project.env, ...projectProcess?.env },
22491
- sdkRoot: path32.dirname(
22801
+ sdkRoot: path33.dirname(
22492
22802
  swiftSdkPaths(frameworkRoot, options.toolchainBin).sysroot
22493
22803
  ),
22494
22804
  linked: output
@@ -22503,7 +22813,7 @@ ${cap}` : "";
22503
22813
  }
22504
22814
  if (!sdkImage)
22505
22815
  await runCompiler(
22506
- path32.join(options.toolchainBin, "llvm-objcopy"),
22816
+ path33.join(options.toolchainBin, "llvm-objcopy"),
22507
22817
  ["--remove-section=.swift1_autolink_entries", optimized],
22508
22818
  buildOptions
22509
22819
  );
@@ -22519,7 +22829,9 @@ ${cap}` : "";
22519
22829
  saveSharedArtifact(sharedRoot, artifact);
22520
22830
  report("compiled artifact verified");
22521
22831
  return retain(root, artifact);
22522
- });
22832
+ } finally {
22833
+ readHold?.release();
22834
+ }
22523
22835
  },
22524
22836
  budget.signal
22525
22837
  );