peachsim 0.1.2591 → 0.1.2592

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 (139) 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 +3872 -3531
  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-67PU73QE.mjs} +3 -3
  27. package/dist-lib/esm-chunks/{chunk-UYJXLDCG.mjs → chunk-5FTHILIE.mjs} +1 -1
  28. package/dist-lib/esm-chunks/{chunk-JHXDM3YU.mjs → chunk-6DB5FR7S.mjs} +1 -1
  29. package/dist-lib/esm-chunks/{chunk-EGKH2L6J.mjs → chunk-CF3MTPMY.mjs} +1 -1
  30. package/dist-lib/esm-chunks/{chunk-MC6NMYWY.mjs → chunk-D4LYKRRB.mjs} +1 -1
  31. package/dist-lib/esm-chunks/{chunk-QBMFX3J2.mjs → chunk-DFF5XZ5M.mjs} +1 -1
  32. package/dist-lib/esm-chunks/{chunk-Q4NA6PUR.mjs → chunk-EHRSWFTD.mjs} +3 -3
  33. package/dist-lib/esm-chunks/{chunk-4QHHRGO4.mjs → chunk-EITX573K.mjs} +1 -1
  34. package/dist-lib/esm-chunks/{chunk-J676B57D.mjs → chunk-EWHA6X3Z.mjs} +5 -5
  35. package/dist-lib/esm-chunks/{chunk-AKKHSVJ4.mjs → chunk-FYXXFYML.mjs} +1 -1
  36. package/dist-lib/esm-chunks/{chunk-ILWFGZWW.mjs → chunk-GQ3EO2UV.mjs} +107 -6
  37. package/dist-lib/esm-chunks/{chunk-VD27WNCT.mjs → chunk-GY6TE4B4.mjs} +4 -4
  38. package/dist-lib/esm-chunks/{chunk-NX23AMX4.mjs → chunk-KDI5YYQ6.mjs} +1 -1
  39. package/dist-lib/esm-chunks/{chunk-VYZ5DC3M.mjs → chunk-L5T3HBPO.mjs} +792 -514
  40. package/dist-lib/esm-chunks/{chunk-7627LKJK.mjs → chunk-M4QLI2SY.mjs} +1 -1
  41. package/dist-lib/esm-chunks/{chunk-UIVXVMS5.mjs → chunk-PITO2NI2.mjs} +2 -2
  42. package/dist-lib/esm-chunks/{chunk-SOAYP72T.mjs → chunk-QSFWBVUO.mjs} +1 -1
  43. package/dist-lib/esm-chunks/{chunk-TFG4LZ5T.mjs → chunk-R3WTQB5J.mjs} +1 -1
  44. package/dist-lib/esm-chunks/{chunk-ZL5N6ENT.mjs → chunk-RV4ACE6R.mjs} +1 -1
  45. package/dist-lib/esm-chunks/{chunk-YR6DNV76.mjs → chunk-SW4PSSTF.mjs} +1 -1
  46. package/dist-lib/esm-chunks/{chunk-VF5WVB3D.mjs → chunk-TJZPNFVF.mjs} +1 -1
  47. package/dist-lib/esm-chunks/{chunk-VRVXRZI4.mjs → chunk-XSQH4R5E.mjs} +48 -15
  48. package/dist-lib/esm-chunks/{chunk-RKQZGWX2.mjs → chunk-XZ3FX3HW.mjs} +1 -1
  49. package/dist-lib/esm-chunks/{metro-layout-parser-ANKZARNW.mjs → metro-layout-parser-EX65MARK.mjs} +3 -3
  50. package/dist-lib/esm-chunks/{swift-package-prebuilt-4N5CXBOZ.mjs → swift-package-prebuilt-3BPDQVA7.mjs} +10 -10
  51. package/dist-lib/esm-chunks/{swift-sdk-app-module-5IUSRXYA.mjs → swift-sdk-app-module-CRX6E3TR.mjs} +14 -14
  52. package/dist-lib/esm-chunks/{swift-sdk-image-7T2LMQS5.mjs → swift-sdk-image-EJD5TPQH.mjs} +14 -14
  53. package/dist-lib/esm-chunks/{swift-sdk-image-producer-7QJ3BF6E.mjs → swift-sdk-image-producer-QAZOSLTZ.mjs} +4 -4
  54. package/dist-lib/expo-swift-bundle.cjs +3243 -2905
  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 +5669 -4904
  59. package/dist-lib/host/fetch-proxy-handler.cjs +310 -298
  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 +238 -223
  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 +73 -71
  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 +6291 -5526
  93. package/dist-lib/swift-compile.cjs +1051 -696
  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/package.json +1 -1
  127. package/runtime-companion.json +1 -1
  128. package/src/native-bundles.ts +2 -0
  129. package/src/one-native-controls-package.ts +141 -31
  130. package/src/one-sdk/source.ts +2 -1
  131. package/src/oneSdkContract.ts +13 -2
  132. package/src/swift-compile.ts +301 -48
  133. package/src/swift-host.ts +88 -16
  134. package/src/swift-reproducible.ts +16 -2
  135. package/src/swift-root-lock.ts +77 -5
  136. package/src/swift-sdk-image.ts +53 -10
  137. package/src/swift-startup-split.ts +65 -27
  138. package/src/swift-toolchain.ts +16 -5
  139. package/src/wasm-lazy-split.ts +46 -40
@@ -1,8 +1,10 @@
1
- /*! peach v0.1.2591 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2592 | (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-GQ3EO2UV.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-QSFWBVUO.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-SW4PSSTF.mjs";
61
64
  import {
62
65
  rnxPublicBrand
63
- } from "./chunk-JHXDM3YU.mjs";
66
+ } from "./chunk-6DB5FR7S.mjs";
64
67
  import {
65
68
  isRecord
66
- } from "./chunk-EGKH2L6J.mjs";
69
+ } from "./chunk-CF3MTPMY.mjs";
67
70
  import {
68
71
  __publicField
69
- } from "./chunk-4QHHRGO4.mjs";
72
+ } from "./chunk-EITX573K.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,
@@ -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);
@@ -14182,13 +14234,13 @@ function swiftSdkGuestLookups(moduleRoot, sdkRoot, objects) {
14182
14234
  const shared = /* @__PURE__ */ new Set();
14183
14235
  const sdkWeakReferences = /* @__PURE__ */ new Map();
14184
14236
  for (const objects2 of groups.values())
14185
- for (const { path: path33, bytes } of objects2) {
14237
+ for (const { path: path34, bytes } of objects2) {
14186
14238
  const defined = guestWasmSymbols(bytes);
14187
14239
  for (const name of defined.defined) symbols.add(name);
14188
14240
  for (const name of defined.tags) shared.add(name);
14189
14241
  for (const name of defined.globals) shared.add(name);
14190
14242
  if (defined.weakUndefined.length)
14191
- sdkWeakReferences.set(path33, new Set(defined.weakUndefined));
14243
+ sdkWeakReferences.set(path34, new Set(defined.weakUndefined));
14192
14244
  }
14193
14245
  return createGuestImageLedger({
14194
14246
  images,
@@ -14301,7 +14353,7 @@ async function compileGuestLink(options) {
14301
14353
  let lazyFunctions = [];
14302
14354
  let dyldSymbols = [];
14303
14355
  const bundlePaths = new Map(
14304
- options.resourceBundles.map(({ target, path: path33 }) => [target, path33])
14356
+ options.resourceBundles.map(({ target, path: path34 }) => [target, path34])
14305
14357
  );
14306
14358
  const imageMetadata = (products) => {
14307
14359
  const source = sourceImages.map((image) => {
@@ -14335,7 +14387,7 @@ async function compileGuestLink(options) {
14335
14387
  };
14336
14388
  const sdk = options.sdkImage;
14337
14389
  const sdkCallers = sdk?.sdkInterface.guestCallers;
14338
- const sdkObjects = sdk ? (await import("./swift-sdk-image-7T2LMQS5.mjs")).readSwiftSdkManifestIndex(sdk).guestObjects : void 0;
14390
+ const sdkObjects = sdk ? (await import("./swift-sdk-image-EJD5TPQH.mjs")).readSwiftSdkManifestIndex(sdk).guestObjects : void 0;
14339
14391
  if (sdk && (!sdkCallers || !sdkObjects))
14340
14392
  throw new Error("the SDK image has no guest link manifest");
14341
14393
  const result = linkPrunedGuestImages({
@@ -14629,7 +14681,7 @@ async function compileGuestLink(options) {
14629
14681
  linkSwiftAppModule,
14630
14682
  readSwiftSdkUsage,
14631
14683
  swiftSdkProjectionSpans
14632
- } = await import("./swift-sdk-app-module-5IUSRXYA.mjs");
14684
+ } = await import("./swift-sdk-app-module-CRX6E3TR.mjs");
14633
14685
  const project = options.project;
14634
14686
  const work = project ? mkdtempSync2(path24.join(directory, "app-module-")) : path24.join(directory, "app-module");
14635
14687
  if (project) chownSync(work, project.uid, project.gid);
@@ -15625,8 +15677,8 @@ function sourceEntryPath() {
15625
15677
  return null;
15626
15678
  }
15627
15679
  }
15628
- function isCliEntry(path33) {
15629
- const name = basename2(path33);
15680
+ function isCliEntry(path34) {
15681
+ const name = basename2(path34);
15630
15682
  return name === "bin.ts" || name === "bin.js";
15631
15683
  }
15632
15684
  function rnxSelfInvocation() {
@@ -15751,10 +15803,20 @@ function swiftObjCPrebuiltCompiler(clang, root, sysroot, distribution, targets,
15751
15803
  }
15752
15804
 
15753
15805
  // src/swift-reproducible.ts
15754
- import { realpathSync as realpathSync5 } from "node:fs";
15806
+ import { existsSync as existsSync9, realpathSync as realpathSync5 } from "node:fs";
15755
15807
  import os3 from "node:os";
15808
+ import path30 from "node:path";
15809
+ function canonicalHomeDir() {
15810
+ const home = os3.homedir();
15811
+ const dotPeach = path30.join(home, ".peach");
15812
+ if (existsSync9(dotPeach)) {
15813
+ const realHome = path30.dirname(realpathSync5(dotPeach));
15814
+ if (home === realHome || home.startsWith(`${realHome}${path30.sep}`)) return realHome;
15815
+ }
15816
+ return home;
15817
+ }
15756
15818
  function swiftReproducibleBuildFlags(roots) {
15757
- return [[os3.homedir(), "home"], ...roots].flatMap(
15819
+ return [[canonicalHomeDir(), "home"], ...roots].flatMap(
15758
15820
  ([root, name]) => [.../* @__PURE__ */ new Set([root, realpathSync5(root)])].map((from) => `${from}=/peach/${name}`)
15759
15821
  ).flatMap((map) => [
15760
15822
  "-Xswiftc",
@@ -15819,12 +15881,12 @@ function collectSwiftSourceClosure(files, roots, swiftCodeMask2, extensionMember
15819
15881
 
15820
15882
  // src/swift-uniform-type-constants.ts
15821
15883
  import { execFileSync as execFileSync12 } from "node:child_process";
15822
- import path30 from "node:path";
15884
+ import path31 from "node:path";
15823
15885
  function compileUniformTypeConstants(args) {
15824
- const source = path30.join(args.packageRoot, "runtime/UniformTypeIdentifiersConstants.m");
15825
- const object2 = path30.join(args.out, "UniformTypeIdentifiers-NativeConstants.o");
15886
+ const source = path31.join(args.packageRoot, "runtime/UniformTypeIdentifiersConstants.m");
15887
+ const object2 = path31.join(args.out, "UniformTypeIdentifiers-NativeConstants.o");
15826
15888
  execFileSync12(
15827
- path30.join(args.bin, "clang"),
15889
+ path31.join(args.bin, "clang"),
15828
15890
  [
15829
15891
  "--target=wasm64-unknown-wasip1-threads",
15830
15892
  ...wasmThreadFlags,
@@ -15834,7 +15896,7 @@ function compileUniformTypeConstants(args) {
15834
15896
  ...swiftObjCRuntimeFlags,
15835
15897
  "-fwasm-exceptions",
15836
15898
  "-F",
15837
- path30.resolve(args.packageRoot, "../peachsim/sdk/ios/System/Library/Frameworks"),
15899
+ path31.resolve(args.packageRoot, "../peachsim/sdk/ios/System/Library/Frameworks"),
15838
15900
  ...objcSdkIntakeFlags(args.darwin, args.bin, args.minimum),
15839
15901
  "-c",
15840
15902
  source,
@@ -15848,12 +15910,12 @@ function compileUniformTypeConstants(args) {
15848
15910
 
15849
15911
  // src/xcode-header-search.ts
15850
15912
  import fs12 from "node:fs";
15851
- import path31 from "node:path";
15913
+ import path32 from "node:path";
15852
15914
  function coalescibleHeaderOverlays(files) {
15853
15915
  const aliases = /* @__PURE__ */ new Map();
15854
15916
  const key = (file) => file.replace(/[A-Z]/g, (letter) => letter.toLowerCase());
15855
15917
  const index = (directory, entry) => {
15856
- const name = path31.resolve(directory, entry.name);
15918
+ const name = path32.resolve(directory, entry.name);
15857
15919
  if (entry.type === "directory")
15858
15920
  return entry.contents.every((child) => index(name, child));
15859
15921
  const source = entry["external-contents"];
@@ -15864,11 +15926,11 @@ function coalescibleHeaderOverlays(files) {
15864
15926
  };
15865
15927
  for (const file of files) {
15866
15928
  const overlay = JSON.parse(fs12.readFileSync(file, "utf8"));
15867
- if (!overlay.roots.every((entry) => index(path31.dirname(file), entry)))
15929
+ if (!overlay.roots.every((entry) => index(path32.dirname(file), entry)))
15868
15930
  return /* @__PURE__ */ new Set();
15869
15931
  }
15870
15932
  for (const file of [...files, ...aliases.values()]) {
15871
- const source = aliases.get(key(path31.normalize(file)));
15933
+ const source = aliases.get(key(path32.normalize(file)));
15872
15934
  if (source !== void 0 && source !== file) return /* @__PURE__ */ new Set();
15873
15935
  }
15874
15936
  return files;
@@ -15928,11 +15990,11 @@ function writeXcodeHeaderSearch(directory, targets, headerAliases = {}, listed)
15928
15990
  seen.add(file);
15929
15991
  file = headerAliases[file];
15930
15992
  }
15931
- const listed2 = productDirectories.get(path31.dirname(product)) ?? [];
15932
- productDirectories.set(path31.dirname(product), listed2);
15933
- listed2.push({ name: path31.basename(product), file });
15993
+ const listed2 = productDirectories.get(path32.dirname(product)) ?? [];
15994
+ productDirectories.set(path32.dirname(product), listed2);
15995
+ listed2.push({ name: path32.basename(product), file });
15934
15996
  }
15935
- const overlay = path31.join(directory, "all-product-headers.yaml");
15997
+ const overlay = path32.join(directory, "all-product-headers.yaml");
15936
15998
  writeBuildFile(
15937
15999
  overlay,
15938
16000
  JSON.stringify({
@@ -15952,7 +16014,7 @@ function writeXcodeHeaderSearch(directory, targets, headerAliases = {}, listed)
15952
16014
  const files = [overlay];
15953
16015
  const flags = targets.map((target, index) => {
15954
16016
  const maps = target.headerMaps.map((map, order) => {
15955
- const file = path31.join(directory, `${index}-${order}.hmap`);
16017
+ const file = path32.join(directory, `${index}-${order}.hmap`);
15956
16018
  writeBuildFile(file, headerMap(map.entries));
15957
16019
  files.push(file);
15958
16020
  return { flag: map.flag, file };
@@ -16091,7 +16153,7 @@ function assertSwiftBuildCores() {
16091
16153
  );
16092
16154
  }
16093
16155
  function swiftDistributionAt(root) {
16094
- const file = path32.join(root, SWIFT_DISTRIBUTION_MANIFEST);
16156
+ const file = path33.join(root, SWIFT_DISTRIBUTION_MANIFEST);
16095
16157
  const stat = statSync4(file, { bigint: true, throwIfNoEntry: false });
16096
16158
  if (!stat) return null;
16097
16159
  const identity = `${stat.dev}:${stat.ino}:${stat.size}:${stat.mtimeNs}`;
@@ -16105,28 +16167,28 @@ var distributionManifests = /* @__PURE__ */ new Map();
16105
16167
  var distributionCompileViews = /* @__PURE__ */ new WeakMap();
16106
16168
  function swiftDistributionCompileView(moduleRoot, distribution) {
16107
16169
  let view = distributionCompileViews.get(distribution);
16108
- if (!view || !existsSync9(view)) {
16170
+ if (!view || !existsSync10(view)) {
16109
16171
  const inputs = Object.entries(distribution.files).filter(
16110
16172
  ([file]) => file.startsWith("host/") || file === SWIFT_DISTRIBUTION_OBJC_SELECTORS
16111
16173
  ).sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0);
16112
16174
  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 });
16175
+ view = path33.join(swiftCacheDir(), "swift-sdk-views", `compile-${digest}`);
16176
+ if (!existsSync10(view)) {
16177
+ mkdirSync8(path33.dirname(view), { recursive: true });
16116
16178
  const staging = mkdtempSync4(`${view}-`);
16117
16179
  try {
16118
16180
  chmodSync3(staging, 493);
16119
16181
  for (const [file] of inputs) {
16120
16182
  if (!isSwiftResourcePath(file))
16121
16183
  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);
16184
+ const destination = path33.join(staging, file);
16185
+ mkdirSync8(path33.dirname(destination), { recursive: true });
16186
+ copyFileSync2(path33.join(moduleRoot, file), destination);
16125
16187
  }
16126
16188
  try {
16127
16189
  renameSync6(staging, view);
16128
16190
  } catch (error) {
16129
- if (!existsSync9(view)) throw error;
16191
+ if (!existsSync10(view)) throw error;
16130
16192
  }
16131
16193
  } finally {
16132
16194
  rmSync7(staging, { recursive: true, force: true });
@@ -16143,19 +16205,19 @@ var REACH_STAGED_FRAMEWORKS = /* @__PURE__ */ new Set(["React"]);
16143
16205
  function swiftModuleInterface(moduleRoot, name) {
16144
16206
  if (REACH_STAGED_FRAMEWORKS.has(name)) return null;
16145
16207
  if (swiftDistributionAt(moduleRoot)) {
16146
- const file = path32.join(moduleRoot, "modules", `${name}-Swift.h`);
16147
- if (!existsSync9(file)) return null;
16208
+ const file = path33.join(moduleRoot, "modules", `${name}-Swift.h`);
16209
+ if (!existsSync10(file)) return null;
16148
16210
  const header = clangInterfaceHeader(readFileSync16(file, "utf8"), moduleRoot);
16149
16211
  return { declared: swiftInterfaceDeclarations(header), header };
16150
16212
  }
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;
16213
+ const sources = path33.join(moduleRoot, "Sources", name);
16214
+ const built = path33.join(moduleRoot, ".build/host", `${name}-Swift.h`);
16215
+ if (!existsSync10(sources) || !existsSync10(built)) return null;
16154
16216
  const declared = /* @__PURE__ */ new Set();
16155
16217
  for (const file of readdirSync6(sources, { recursive: true, encoding: "utf8" }))
16156
16218
  if (file.endsWith(".swift"))
16157
16219
  for (const [, objc, subclass] of readFileSync16(
16158
- path32.join(sources, file),
16220
+ path33.join(sources, file),
16159
16221
  "utf8"
16160
16222
  ).matchAll(
16161
16223
  /@objc\((\w+)\)\s+(?:\w+\s+)*?(?:protocol|class)\s|^(?:public|open)\s+(?:final\s+)?class\s+(\w+)\s*:\s*NSObject\b/gm
@@ -16169,7 +16231,7 @@ function swiftModuleInterface(moduleRoot, name) {
16169
16231
  }
16170
16232
  function clangInterfaceHeader(header, moduleRoot) {
16171
16233
  const distribution = swiftDistributionAt(moduleRoot) !== null;
16172
- const frameworks = path32.join(
16234
+ const frameworks = path33.join(
16173
16235
  swiftSharedSdkSourceRoot(moduleRoot, distribution),
16174
16236
  "System/Library/Frameworks"
16175
16237
  );
@@ -16182,8 +16244,8 @@ function clangInterfaceHeader(header, moduleRoot) {
16182
16244
  (_, module, framework) => {
16183
16245
  const imports = [`@import ${framework};`];
16184
16246
  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];
16247
+ const directory = distribution ? path33.join(moduleRoot, "modules", module) : path33.join(moduleRoot, "Sources", module, "include");
16248
+ if (!existsSync10(directory)) return imports[0];
16187
16249
  if (!references) {
16188
16250
  references = new Set(header.match(/\b[A-Z]\w*\b/g));
16189
16251
  for (const name of objcEnumerations(header)) references.delete(name);
@@ -16211,7 +16273,7 @@ var clangDeclarationEnumCache = /* @__PURE__ */ new Map();
16211
16273
  function clangDeclarationEnums(directory) {
16212
16274
  const cached = clangDeclarationEnumCache.get(directory);
16213
16275
  if (cached) return cached;
16214
- const enums = readdirSync6(directory).filter((file) => file.endsWith(".h")).flatMap((file) => objcEnumerations(readFileSync16(path32.join(directory, file), "utf8")));
16276
+ const enums = readdirSync6(directory).filter((file) => file.endsWith(".h")).flatMap((file) => objcEnumerations(readFileSync16(path33.join(directory, file), "utf8")));
16215
16277
  clangDeclarationEnumCache.set(directory, enums);
16216
16278
  return enums;
16217
16279
  }
@@ -16246,11 +16308,11 @@ function sdkObjCDeclarationOwners(frameworks) {
16246
16308
  const owners = /* @__PURE__ */ new Map();
16247
16309
  for (const framework of readdirSync6(frameworks))
16248
16310
  if (framework.endsWith(".framework")) {
16249
- const headers = path32.join(frameworks, framework, "Headers");
16250
- if (existsSync9(headers)) {
16311
+ const headers = path33.join(frameworks, framework, "Headers");
16312
+ if (existsSync10(headers)) {
16251
16313
  for (const file of readdirSync6(headers, { recursive: true, encoding: "utf8" }))
16252
16314
  if (file.endsWith(".h")) {
16253
- const header = readFileSync16(path32.join(headers, file), "utf8");
16315
+ const header = readFileSync16(path33.join(headers, file), "utf8");
16254
16316
  for (const name of [
16255
16317
  ...swiftInterfaceDeclarations(header),
16256
16318
  ...objcEnumerations(header),
@@ -16349,7 +16411,7 @@ function swiftCompileSdkOptions(moduleRoot, toolchainBin) {
16349
16411
  }
16350
16412
  function swiftObjCSelectorOptions(moduleRoot) {
16351
16413
  const distribution = swiftDistributionAt(moduleRoot);
16352
- let map = path32.join(
16414
+ let map = path33.join(
16353
16415
  distribution ? swiftDistributionCompileView(moduleRoot, distribution) : moduleRoot,
16354
16416
  SWIFT_DISTRIBUTION_OBJC_SELECTORS
16355
16417
  );
@@ -16359,18 +16421,21 @@ function swiftObjCSelectorOptions(moduleRoot) {
16359
16421
  for (const [name, members] of Object.entries(
16360
16422
  JSON.parse(
16361
16423
  readFileSync16(
16362
- path32.join(moduleRoot, "Sources", framework, "ObjCSelectors.json"),
16424
+ path33.join(moduleRoot, "Sources", framework, "ObjCSelectors.json"),
16363
16425
  "utf8"
16364
16426
  )
16365
16427
  ).classes
16366
16428
  ))
16367
16429
  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);
16430
+ map = path33.join(moduleRoot, ".build", SWIFT_DISTRIBUTION_OBJC_SELECTORS);
16431
+ const content = `${JSON.stringify({ classes }, null, 2)}
16432
+ `;
16433
+ if (!existsSync10(map) || readFileSync16(map, "utf8") !== content) {
16434
+ mkdirSync8(path33.dirname(map), { recursive: true });
16435
+ const partial = `${map}.${randomUUID5()}`;
16436
+ writeFileSync8(partial, content);
16437
+ renameSync6(partial, map);
16438
+ }
16374
16439
  }
16375
16440
  return ["-Xswiftc", "-Xllvm", "-Xswiftc", `-peach-objc-selector-map=${map}`];
16376
16441
  }
@@ -16408,7 +16473,7 @@ function swiftModuleInputFiles(root) {
16408
16473
  "toolchain.json"
16409
16474
  ];
16410
16475
  const walk = (dir) => {
16411
- for (const entry of readdirSync6(path32.join(root, dir), {
16476
+ for (const entry of readdirSync6(path33.join(root, dir), {
16412
16477
  withFileTypes: true
16413
16478
  })) {
16414
16479
  const relative = `${dir}/${entry.name}`;
@@ -16424,48 +16489,48 @@ function swiftModuleInputFiles(root) {
16424
16489
  walk("ios-simulator-stdlib");
16425
16490
  return files.sort();
16426
16491
  }
16427
- function swiftMacroPlugins(moduleRoot, dir = path32.join(moduleRoot, ".build/host/RnxPreviewMacros")) {
16492
+ function swiftMacroPlugins(moduleRoot, dir = path33.join(moduleRoot, ".build/host/RnxPreviewMacros")) {
16428
16493
  const distribution = swiftDistributionAt(moduleRoot);
16429
16494
  if (distribution) {
16430
16495
  const view = swiftDistributionCompileView(moduleRoot, distribution);
16431
16496
  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)),
16497
+ libraries: distribution.plugins.filter((plugin) => path33.basename(plugin) !== "ExpoModulesMacros").map((plugin) => path33.join(view, plugin)),
16498
+ executables: distribution.plugins.filter((plugin) => path33.basename(plugin) === "ExpoModulesMacros").map((plugin) => path33.join(view, plugin)),
16434
16499
  stale: false
16435
16500
  };
16436
16501
  }
16437
16502
  const release = JSON.parse(
16438
- readFileSync16(path32.join(moduleRoot, "toolchain.json"), "utf8")
16503
+ readFileSync16(path33.join(moduleRoot, "toolchain.json"), "utf8")
16439
16504
  ).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");
16505
+ const compilerStamp = path33.join(dir, "compiler-release");
16506
+ const pluginScript = path33.join(moduleRoot, "scripts/build-preview-plugin.sh");
16507
+ const expoPlugin = path33.join(dir, "ExpoModulesMacros");
16443
16508
  const ext = process.platform === "darwin" ? "dylib" : "so";
16444
16509
  const plugins = [
16445
16510
  {
16446
- library: path32.join(dir, `libRnxPreviewMacros.${ext}`),
16447
- sources: [path32.join(moduleRoot, "Sources/RnxPreviewMacros/PreviewMacro.swift")]
16511
+ library: path33.join(dir, `libRnxPreviewMacros.${ext}`),
16512
+ sources: [path33.join(moduleRoot, "Sources/RnxPreviewMacros/PreviewMacro.swift")]
16448
16513
  },
16449
16514
  {
16450
- library: path32.join(dir, `libFoundationMacros.${ext}`),
16515
+ library: path33.join(dir, `libFoundationMacros.${ext}`),
16451
16516
  sources: [
16452
- path32.join(moduleRoot, "Sources/FoundationMacros/PredicateMacro.swift"),
16453
- path32.join(moduleRoot, "Sources/SwiftMacroSupport/PredicateExpression.swift")
16517
+ path33.join(moduleRoot, "Sources/FoundationMacros/PredicateMacro.swift"),
16518
+ path33.join(moduleRoot, "Sources/SwiftMacroSupport/PredicateExpression.swift")
16454
16519
  ]
16455
16520
  },
16456
16521
  {
16457
- library: path32.join(dir, `libTipKitMacros.${ext}`),
16522
+ library: path33.join(dir, `libTipKitMacros.${ext}`),
16458
16523
  sources: [
16459
- path32.join(moduleRoot, "Sources/TipKitMacros/TipKitMacros.swift"),
16460
- path32.join(moduleRoot, "Sources/SwiftMacroSupport/PredicateExpression.swift")
16524
+ path33.join(moduleRoot, "Sources/TipKitMacros/TipKitMacros.swift"),
16525
+ path33.join(moduleRoot, "Sources/SwiftMacroSupport/PredicateExpression.swift")
16461
16526
  ]
16462
16527
  }
16463
16528
  ];
16464
16529
  return {
16465
16530
  libraries: plugins.map(({ library }) => library),
16466
16531
  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)
16532
+ stale: !existsSync10(compilerStamp) || !existsSync10(expoPlugin) || statSync4(pluginScript).mtimeMs > statSync4(expoPlugin).mtimeMs || readFileSync16(compilerStamp, "utf8").trim() !== release || plugins.some(
16533
+ ({ library, sources }) => !existsSync10(library) || sources.some((source) => statSync4(source).mtimeMs > statSync4(library).mtimeMs)
16469
16534
  )
16470
16535
  };
16471
16536
  }
@@ -16475,14 +16540,14 @@ async function ensureMacroPlugins(moduleRoot, toolchainBin, release, signal, lea
16475
16540
  await runCompiler(
16476
16541
  "sh",
16477
16542
  [
16478
- path32.join(moduleRoot, "scripts/build-preview-plugin.sh"),
16543
+ path33.join(moduleRoot, "scripts/build-preview-plugin.sh"),
16479
16544
  toolchainBin,
16480
16545
  libraries[0]
16481
16546
  ],
16482
16547
  { signal, lease }
16483
16548
  );
16484
16549
  writeFileSync8(
16485
- path32.join(path32.dirname(libraries[0]), "compiler-release"),
16550
+ path33.join(path33.dirname(libraries[0]), "compiler-release"),
16486
16551
  `${release}
16487
16552
  `
16488
16553
  );
@@ -16494,11 +16559,74 @@ function clearLinkedModuleDigests(root) {
16494
16559
  if (root === void 0) linkedModuleDigests.clear();
16495
16560
  else linkedModuleDigests.delete(root);
16496
16561
  }
16562
+ function gitCleanModuleInputsKey(root, files) {
16563
+ if (swiftDistributionAt(root)) return null;
16564
+ const top = spawnSync5("git", ["-C", root, "rev-parse", "--show-toplevel"], {
16565
+ encoding: "utf8",
16566
+ stdio: ["ignore", "pipe", "ignore"]
16567
+ });
16568
+ if (top.status !== 0) return null;
16569
+ const repoTop = top.stdout.trim();
16570
+ if (!repoTop) return null;
16571
+ const realTop = realpathSync6(repoTop);
16572
+ const realRoot = realpathSync6(root);
16573
+ const collapsedDirs = [
16574
+ path33.join(realRoot, "Sources"),
16575
+ path33.join(realRoot, "cross-import-overlays"),
16576
+ path33.join(realRoot, "ios-simulator-stdlib"),
16577
+ realpathSync6(path33.resolve(realRoot, "../peachsim/sdk/ios"))
16578
+ ];
16579
+ const scoped = /* @__PURE__ */ new Set();
16580
+ for (const dir of collapsedDirs) {
16581
+ const rel = path33.relative(realTop, dir).split(path33.sep).join("/");
16582
+ if (!rel || rel.startsWith("../")) return null;
16583
+ scoped.add(rel);
16584
+ }
16585
+ for (const file of files) {
16586
+ const full = path33.resolve(realRoot, file);
16587
+ if (collapsedDirs.some((dir) => full.startsWith(dir + path33.sep))) continue;
16588
+ const rel = path33.relative(realTop, full).split(path33.sep).join("/");
16589
+ if (!rel || rel.startsWith("../")) return null;
16590
+ scoped.add(rel);
16591
+ }
16592
+ const paths = [...scoped].sort();
16593
+ const status = spawnSync5(
16594
+ "git",
16595
+ [
16596
+ "-C",
16597
+ realTop,
16598
+ "status",
16599
+ "--porcelain",
16600
+ "--untracked-files=all",
16601
+ "--ignored=matching",
16602
+ "--",
16603
+ ...paths
16604
+ ],
16605
+ {
16606
+ encoding: "utf8",
16607
+ stdio: ["ignore", "pipe", "ignore"],
16608
+ maxBuffer: 16 * 1024 * 1024
16609
+ }
16610
+ );
16611
+ if (status.status !== 0 || status.stdout.trim().length > 0) return null;
16612
+ const oids = spawnSync5(
16613
+ "git",
16614
+ ["-C", realTop, "rev-parse", ...paths.map((entry) => `HEAD:${entry}`)],
16615
+ { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }
16616
+ );
16617
+ if (oids.status !== 0) return null;
16618
+ const keyHash = createHash18("sha256");
16619
+ keyHash.update("git-module-digest/v1\n");
16620
+ keyHash.update(oids.stdout);
16621
+ keyHash.update("\n");
16622
+ for (const file of files) keyHash.update(file).update("\n");
16623
+ return keyHash.digest("hex");
16624
+ }
16497
16625
  function swiftModuleDigest(root) {
16498
16626
  const files = swiftModuleInputFiles(root);
16499
16627
  const stampHash = createHash18("sha256");
16500
16628
  for (const file of files) {
16501
- const stat = statSync4(path32.join(root, file), { bigint: true });
16629
+ const stat = statSync4(path33.join(root, file), { bigint: true });
16502
16630
  stampHash.update(file);
16503
16631
  stampHash.update(
16504
16632
  `${stat.dev}:${stat.ino}:${stat.size}:${stat.mtimeNs}:${stat.ctimeNs}
@@ -16508,12 +16636,18 @@ function swiftModuleDigest(root) {
16508
16636
  const stamp = stampHash.digest("hex");
16509
16637
  const cached = linkedModuleDigests.get(root);
16510
16638
  if (cached?.stamp === stamp) return cached.digest;
16511
- const record = path32.join(
16512
- swiftCacheDir(),
16513
- "swift-module-digests",
16639
+ const digestDir = path33.join(swiftCacheDir(), "swift-module-digests");
16640
+ const record = path33.join(
16641
+ digestDir,
16514
16642
  `${createHash18("sha256").update(root).digest("hex")}.json`
16515
16643
  );
16516
- if (existsSync9(record)) {
16644
+ const writeRecord = (target, body) => {
16645
+ mkdirSync8(path33.dirname(target), { recursive: true });
16646
+ const partial = `${target}.${process.pid}.${randomUUID5()}`;
16647
+ writeFileSync8(partial, body);
16648
+ renameSync6(partial, target);
16649
+ };
16650
+ if (existsSync10(record)) {
16517
16651
  const saved = JSON.parse(readFileSync16(record, "utf8"));
16518
16652
  if (saved && typeof saved === "object" && Reflect.get(saved, "stamp") === stamp && typeof Reflect.get(saved, "digest") === "string") {
16519
16653
  const digest2 = Buffer.from(String(Reflect.get(saved, "digest")), "hex");
@@ -16521,19 +16655,30 @@ function swiftModuleDigest(root) {
16521
16655
  return digest2;
16522
16656
  }
16523
16657
  }
16658
+ const gitKey = gitCleanModuleInputsKey(root, files);
16659
+ const gitRecord = gitKey ? path33.join(digestDir, `git-${gitKey}.json`) : null;
16660
+ if (gitRecord && existsSync10(gitRecord)) {
16661
+ const saved = JSON.parse(readFileSync16(gitRecord, "utf8"));
16662
+ if (saved && typeof saved === "object" && typeof Reflect.get(saved, "digest") === "string") {
16663
+ const hex2 = String(Reflect.get(saved, "digest"));
16664
+ const digest2 = Buffer.from(hex2, "hex");
16665
+ linkedModuleDigests.set(root, { stamp, digest: digest2 });
16666
+ writeRecord(record, JSON.stringify({ stamp, digest: hex2 }));
16667
+ return digest2;
16668
+ }
16669
+ }
16524
16670
  const hash = createHash18("sha256");
16525
16671
  for (const file of files) {
16526
16672
  hash.update(createHash18("sha256").update(file).digest());
16527
16673
  hash.update(
16528
- createHash18("sha256").update(readFileSync16(path32.join(root, file))).digest()
16674
+ createHash18("sha256").update(readFileSync16(path33.join(root, file))).digest()
16529
16675
  );
16530
16676
  }
16531
16677
  const digest = hash.digest();
16678
+ const hex = digest.toString("hex");
16532
16679
  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);
16680
+ writeRecord(record, JSON.stringify({ stamp, digest: hex }));
16681
+ if (gitRecord) writeRecord(gitRecord, JSON.stringify({ digest: hex }));
16537
16682
  return digest;
16538
16683
  }
16539
16684
  var compileSurfaces = /* @__PURE__ */ new WeakMap();
@@ -16605,7 +16750,7 @@ function withNativeSourceGlue(input, glue) {
16605
16750
  ...input,
16606
16751
  files: {
16607
16752
  ...input.files,
16608
- [path32.posix.join(targetPath, "OneNativeSource.generated.swift")]: glue
16753
+ [path33.posix.join(targetPath, "OneNativeSource.generated.swift")]: glue
16609
16754
  },
16610
16755
  oneModule: true
16611
16756
  };
@@ -16763,7 +16908,7 @@ function swiftImportNames(contents2, available) {
16763
16908
  function swiftPeachModules(moduleRoot) {
16764
16909
  const distribution = swiftDistributionAt(moduleRoot);
16765
16910
  return distribution ? distribution.modules : swiftManifestDeclarations(
16766
- readFileSync16(path32.join(moduleRoot, "Package.swift"), "utf8")
16911
+ readFileSync16(path33.join(moduleRoot, "Package.swift"), "utf8")
16767
16912
  ).filter((target) => !target.executable && !target.path.startsWith("fixtures/")).map((target) => target.name);
16768
16913
  }
16769
16914
  var sdkPaths = /* @__PURE__ */ new Map();
@@ -16773,7 +16918,7 @@ function swiftSdkPaths(moduleRoot, toolchainBin, options = swiftCompileSdkOption
16773
16918
  const cached = sdkPaths.get(key);
16774
16919
  if (cached) return cached;
16775
16920
  const configuration = execFileSync13(
16776
- path32.join(toolchainBin, "swift"),
16921
+ path33.join(toolchainBin, "swift"),
16777
16922
  ["sdk", "configure", ...options, "--show-configuration", sdk, SWIFT_WASM_TRIPLE],
16778
16923
  { encoding: "utf8", env: swiftEnvironment(), stdio: ["ignore", "pipe", "pipe"] }
16779
16924
  );
@@ -16807,7 +16952,7 @@ function swiftSdkPaths(moduleRoot, toolchainBin, options = swiftCompileSdkOption
16807
16952
  if (flag !== "-fwasm-exceptions") cFlags.push(flag);
16808
16953
  if (flag === "-iframeworkwithsysroot" && options2[index + 2] === "-Xcc" && typeof options2[index + 3] === "string") {
16809
16954
  cFlags.push(options2[index + 3]);
16810
- frameworks.push(path32.join(sysroot, options2[index + 3]));
16955
+ frameworks.push(path33.join(sysroot, options2[index + 3]));
16811
16956
  index += 3;
16812
16957
  continue;
16813
16958
  }
@@ -16824,7 +16969,7 @@ function swiftSdkPaths(moduleRoot, toolchainBin, options = swiftCompileSdkOption
16824
16969
  }
16825
16970
  const paths = {
16826
16971
  sysroot,
16827
- darwin: path32.join(sysroot, "darwin"),
16972
+ darwin: path33.join(sysroot, "darwin"),
16828
16973
  resources: field("swiftResourcesPath"),
16829
16974
  frameworks,
16830
16975
  cFlags
@@ -16852,23 +16997,23 @@ function swiftOverlayFrameworks(moduleRoot, toolchainBin) {
16852
16997
  const { darwin, resources, frameworks } = swiftSdkPaths(moduleRoot, toolchainBin);
16853
16998
  const swiftModules = new Set(swiftPeachModules(moduleRoot));
16854
16999
  const result = /* @__PURE__ */ new Set();
16855
- const include = path32.join(darwin, "usr/include");
17000
+ const include = path33.join(darwin, "usr/include");
16856
17001
  for (const entry of readdirSync6(include))
16857
17002
  if (entry.endsWith(".modulemap"))
16858
17003
  addSwiftOverlayFrameworks(
16859
- readFileSync16(path32.join(include, entry), "utf8"),
17004
+ readFileSync16(path33.join(include, entry), "utf8"),
16860
17005
  swiftModules,
16861
17006
  result
16862
17007
  );
16863
17008
  for (const entry of readdirSync6(resources)) {
16864
- const map = path32.join(resources, entry, "module.modulemap");
16865
- if (existsSync9(map))
17009
+ const map = path33.join(resources, entry, "module.modulemap");
17010
+ if (existsSync10(map))
16866
17011
  addSwiftOverlayFrameworks(readFileSync16(map, "utf8"), swiftModules, result);
16867
17012
  }
16868
17013
  for (const directory of frameworks)
16869
17014
  for (const entry of readdirSync6(directory)) {
16870
- const map = path32.join(directory, entry, "Modules/module.modulemap");
16871
- if (existsSync9(map))
17015
+ const map = path33.join(directory, entry, "Modules/module.modulemap");
17016
+ if (existsSync10(map))
16872
17017
  addSwiftOverlayFrameworks(readFileSync16(map, "utf8"), swiftModules, result);
16873
17018
  }
16874
17019
  sdkOverlayFrameworks.set(key, result);
@@ -16885,50 +17030,50 @@ function swiftAvailableModules(moduleRoot, toolchainBin) {
16885
17030
  toolchainBin
16886
17031
  );
16887
17032
  const maps = /* @__PURE__ */ new Set([
16888
- path32.join(darwin, "usr/include/module.modulemap"),
17033
+ path33.join(darwin, "usr/include/module.modulemap"),
16889
17034
  ...cFlags.filter((flag) => flag.startsWith("-fmodule-map-file=")).map((flag) => {
16890
17035
  const file = flag.slice("-fmodule-map-file=".length);
16891
- return file.startsWith("=") ? path32.join(sysroot, file.slice(1)) : file;
17036
+ return file.startsWith("=") ? path33.join(sysroot, file.slice(1)) : file;
16892
17037
  })
16893
17038
  ]);
16894
17039
  for (const map of maps) {
16895
- if (!existsSync9(map)) continue;
17040
+ if (!existsSync10(map)) continue;
16896
17041
  const contents2 = readFileSync16(map, "utf8");
16897
17042
  for (const match of contents2.matchAll(
16898
17043
  /^(?:explicit\s+)?(?:framework\s+)?module\s+([A-Za-z_]\w*)/gm
16899
17044
  ))
16900
17045
  modules.add(match[1]);
16901
17046
  for (const match of contents2.matchAll(/^\s*extern\s+module\s+\w+\s+"([^"]+)"/gm))
16902
- maps.add(path32.resolve(path32.dirname(map), match[1]));
17047
+ maps.add(path33.resolve(path33.dirname(map), match[1]));
16903
17048
  }
16904
- for (const entry of readdirSync6(path32.join(resources, "wasi"))) {
17049
+ for (const entry of readdirSync6(path33.join(resources, "wasi"))) {
16905
17050
  if (entry.endsWith(".swiftmodule"))
16906
17051
  modules.add(entry.slice(0, -".swiftmodule".length));
16907
17052
  }
16908
17053
  for (const entry of readdirSync6(resources)) {
16909
- const map = path32.join(resources, entry, "module.modulemap");
16910
- if (!existsSync9(map)) continue;
17054
+ const map = path33.join(resources, entry, "module.modulemap");
17055
+ if (!existsSync10(map)) continue;
16911
17056
  for (const match of readFileSync16(map, "utf8").matchAll(/^module\s+([A-Za-z_]\w*)/gm))
16912
17057
  modules.add(match[1]);
16913
17058
  }
16914
17059
  for (const libc of [
16915
- path32.join(darwin, "usr/include"),
16916
- path32.join(
17060
+ path33.join(darwin, "usr/include"),
17061
+ path33.join(
16917
17062
  swiftSharedSdkRoot(moduleRoot, swiftDistributionAt(moduleRoot) !== null),
16918
17063
  "usr/include"
16919
17064
  )
16920
17065
  ])
16921
17066
  for (const entry of readdirSync6(libc)) {
16922
17067
  if (!entry.endsWith(".modulemap")) continue;
16923
- for (const match of readFileSync16(path32.join(libc, entry), "utf8").matchAll(
17068
+ for (const match of readFileSync16(path33.join(libc, entry), "utf8").matchAll(
16924
17069
  /^module\s+([A-Za-z_]\w*)/gm
16925
17070
  ))
16926
17071
  modules.add(match[1]);
16927
17072
  }
16928
17073
  for (const directory of frameworks) {
16929
17074
  for (const entry of readdirSync6(directory)) {
16930
- const map = path32.join(directory, entry, "Modules/module.modulemap");
16931
- if (!existsSync9(map)) continue;
17075
+ const map = path33.join(directory, entry, "Modules/module.modulemap");
17076
+ if (!existsSync10(map)) continue;
16932
17077
  for (const match of readFileSync16(map, "utf8").matchAll(
16933
17078
  /^framework\s+module\s+([A-Za-z_]\w*)/gm
16934
17079
  ))
@@ -17028,15 +17173,15 @@ int EXUpdatesApplyBSDiffPatch(const char * _Nonnull oldFilePath,
17028
17173
  ];
17029
17174
  var CLANG_DISTRIBUTION_MODULES = ".peach-clang-modules";
17030
17175
  function distributionClangModulePresent(modules, name) {
17031
- return existsSync9(path32.join(modules, `${name}.swiftmodule`)) || existsSync9(path32.join(modules, name, "module.modulemap"));
17176
+ return existsSync10(path33.join(modules, `${name}.swiftmodule`)) || existsSync10(path33.join(modules, name, "module.modulemap"));
17032
17177
  }
17033
17178
  function distributionClangModuleMap(root, modules) {
17034
17179
  const missing = DISTRIBUTION_CLANG_MODULES.filter(
17035
17180
  (mod) => !distributionClangModulePresent(modules, mod.name)
17036
17181
  );
17037
17182
  if (missing.length === 0) return null;
17038
- const directory = path32.join(root, CLANG_DISTRIBUTION_MODULES);
17039
- const mapPath = path32.join(directory, "module.modulemap");
17183
+ const directory = path33.join(root, CLANG_DISTRIBUTION_MODULES);
17184
+ const mapPath = path33.join(directory, "module.modulemap");
17040
17185
  const map = missing.map(
17041
17186
  (mod) => `module ${mod.name} {
17042
17187
  requires objc
@@ -17045,9 +17190,9 @@ function distributionClangModuleMap(root, modules) {
17045
17190
  }
17046
17191
  `
17047
17192
  ).join("\n");
17048
- if (existsSync9(mapPath) && readFileSync16(mapPath, "utf8") !== map)
17193
+ if (existsSync10(mapPath) && readFileSync16(mapPath, "utf8") !== map)
17049
17194
  rmSync7(directory, { recursive: true, force: true });
17050
- for (const mod of missing) writeBuildFile(path32.join(directory, mod.header), mod.source);
17195
+ for (const mod of missing) writeBuildFile(path33.join(directory, mod.header), mod.source);
17051
17196
  writeBuildFile(mapPath, map);
17052
17197
  return mapPath;
17053
17198
  }
@@ -17059,14 +17204,14 @@ function providedModulesPath(root, modules, excluded) {
17059
17204
  if (!excluded || excluded.size === 0) return modules;
17060
17205
  const entries2 = readdirSync6(modules).filter((entry) => !excluded.has(entry.replace(/\..*$/, ""))).sort();
17061
17206
  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)) {
17207
+ const directory = path33.join(root, `.peach-modules-${key}`);
17208
+ const complete = path33.join(directory, ".complete");
17209
+ if (!existsSync10(complete)) {
17065
17210
  mkdirSync8(directory, { recursive: true });
17066
17211
  for (const entry of readdirSync6(directory))
17067
- rmSync7(path32.join(directory, entry), { recursive: true, force: true });
17212
+ rmSync7(path33.join(directory, entry), { recursive: true, force: true });
17068
17213
  for (const entry of entries2) {
17069
- symlinkSync2(path32.join(modules, entry), path32.join(directory, entry));
17214
+ symlinkSync2(path33.join(modules, entry), path33.join(directory, entry));
17070
17215
  }
17071
17216
  writeFileSync8(complete, "");
17072
17217
  }
@@ -17080,7 +17225,7 @@ function swiftTargetDependencies(files, targets, frameworks = OPTIONAL_FRAMEWORK
17080
17225
  );
17081
17226
  const names = /* @__PURE__ */ new Set([...frameworks, ...targets.map((target) => target.name)]);
17082
17227
  const entriesByPrefix = new Map(
17083
- targets.map(({ path: path33 }) => [path33 === "." ? "" : `${path33}/`, []])
17228
+ targets.map(({ path: path34 }) => [path34 === "." ? "" : `${path34}/`, []])
17084
17229
  );
17085
17230
  for (const entry of Object.entries(files)) {
17086
17231
  const [file] = entry;
@@ -17115,7 +17260,7 @@ function swiftTargetDependencies(files, targets, frameworks = OPTIONAL_FRAMEWORK
17115
17260
  (excluded) => relative === excluded || relative.startsWith(`${excluded}/`)
17116
17261
  ))
17117
17262
  continue;
17118
- if (nested.some((path33) => file.startsWith(path33))) continue;
17263
+ if (nested.some((path34) => file.startsWith(path34))) continue;
17119
17264
  const imports = file.endsWith(".swift") ? swiftImportNames(contents2) : SWIFT_NATIVE_SOURCE_EXTENSIONS.some((extension) => file.endsWith(extension)) ? clangImportNames(contents2, ownsHeader) : [];
17120
17265
  for (const name of imports) {
17121
17266
  if (names.has(name) && name !== target.name && !(target.dependencies !== void 0 && localNames.has(name)))
@@ -17191,7 +17336,7 @@ ${imports.join("\n")}
17191
17336
  }
17192
17337
  var ONE_IMPLICIT_FLAGS = ', "-Xfrontend", "-import-module", "-Xfrontend", "One"';
17193
17338
  var executableLinkFlags = (root) => ` "-Xclang-linker", "-O0",
17194
- "-Xclang-linker", ${JSON.stringify(`-fuse-ld=${path32.join(root, SWIFT_AUTOLINK_LINKER)}`)},
17339
+ "-Xclang-linker", ${JSON.stringify(`-fuse-ld=${path33.join(root, SWIFT_AUTOLINK_LINKER)}`)},
17195
17340
  "-Xlinker", "-z", "-Xlinker", "stack-size=8372224",
17196
17341
  "-Xlinker", "--stack-first",
17197
17342
  "-Xlinker", "--global-base=8372224",
@@ -17206,7 +17351,7 @@ var darwinRecordsRegion = (quoted2) => quoted2.length ? ["-Wl,--start-lib", ...q
17206
17351
  var REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
17207
17352
  var MULTI_MANIFEST_VERSION = 76;
17208
17353
  var SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
17209
- var compilerSourceDigest = true ? "d4cf22b53d08266bf9bd0238bffe899805f62daeb3d628664ee351830e496cda" : swiftCompilerSourceDigest(import.meta.dirname);
17354
+ var compilerSourceDigest = true ? "57c5faa7bb7758647030422e32db0f4a53fbab724723e220c14fea1e41d2391e" : swiftCompilerSourceDigest(import.meta.dirname);
17210
17355
  function swiftArtifactHash(input, release, moduleRoot) {
17211
17356
  return swiftCompileInputHash(input, release).update(swiftModuleDigest(moduleRoot)).digest("hex");
17212
17357
  }
@@ -17306,14 +17451,14 @@ var cFlagArray = (flags) => JSON.stringify(withoutGlogModuleMap(flags));
17306
17451
  var cxxFlagArray = (flags) => JSON.stringify([...nativeCxxCompilerFlags, ...withoutGlogModuleMap(flags)]);
17307
17452
  function swiftCrossImportFlags(moduleRoot, distribution) {
17308
17453
  const manifest = distribution ? swiftDistributionAt(moduleRoot) : null;
17309
- const overlayRoot = manifest ? path32.join(moduleRoot, "modules") : path32.join(moduleRoot, "cross-import-overlays");
17454
+ const overlayRoot = manifest ? path33.join(moduleRoot, "modules") : path33.join(moduleRoot, "cross-import-overlays");
17310
17455
  return readdirSync6(overlayRoot, { encoding: "utf8", recursive: true }).filter((file) => file.endsWith(".swiftoverlay")).sort((left, right) => left.localeCompare(right)).flatMap((file) => [
17311
17456
  "-Xfrontend",
17312
17457
  "-swift-module-cross-import",
17313
17458
  "-Xfrontend",
17314
- path32.basename(path32.dirname(file), ".swiftcrossimport"),
17459
+ path33.basename(path33.dirname(file), ".swiftcrossimport"),
17315
17460
  "-Xfrontend",
17316
- path32.join(overlayRoot, file)
17461
+ path33.join(overlayRoot, file)
17317
17462
  ]);
17318
17463
  }
17319
17464
  function withoutWasmOverlayIsystem(flags) {
@@ -17344,7 +17489,7 @@ function emitSwiftPackageManifest(args) {
17344
17489
  distribution
17345
17490
  } = args;
17346
17491
  const prebuilt = args.prebuilt;
17347
- const distributionModules = distribution ? path32.join(moduleRoot, "modules") : void 0;
17492
+ const distributionModules = distribution ? path33.join(moduleRoot, "modules") : void 0;
17348
17493
  const linkedObjects = Boolean(distribution || prebuilt);
17349
17494
  const cxxFlagsFor = (flags) => args.deferDarwinOverlay ? withoutWasmOverlayIsystem(flags) : flags;
17350
17495
  const packageModules = new Set(
@@ -17354,7 +17499,7 @@ function emitSwiftPackageManifest(args) {
17354
17499
  if (!flag.startsWith("-fmodule-map-file=")) return false;
17355
17500
  const file = flag.slice("-fmodule-map-file=".length).replaceAll(SWIFT_NATIVE_INPUT_ROOT, args.root);
17356
17501
  if (!file.includes("/Pods/Headers/")) return false;
17357
- const map = args.files.get(file) ?? (existsSync9(file) ? readFileSync16(file) : void 0);
17502
+ const map = args.files.get(file) ?? (existsSync10(file) ? readFileSync16(file) : void 0);
17358
17503
  const name = map === void 0 ? void 0 : moduleMapName(map.toString());
17359
17504
  return name !== void 0 && packageModules.has(name);
17360
17505
  };
@@ -17386,7 +17531,7 @@ function emitSwiftPackageManifest(args) {
17386
17531
  const product = parse(
17387
17532
  swiftFrameworkProductSchema,
17388
17533
  JSON.parse(
17389
- readFileSync16(path32.join(moduleRoot, SWIFT_FRAMEWORK_PRODUCT_FILE), "utf8")
17534
+ readFileSync16(path33.join(moduleRoot, SWIFT_FRAMEWORK_PRODUCT_FILE), "utf8")
17390
17535
  )
17391
17536
  );
17392
17537
  const replacedObjects = new Set(
@@ -17400,7 +17545,7 @@ function emitSwiftPackageManifest(args) {
17400
17545
  (name) => !object2.startsWith(`lib/${name}-`) || reachedFrameworks.has(name)
17401
17546
  )
17402
17547
  );
17403
- const quoted2 = (object2) => `"${path32.join(moduleRoot, object2).replaceAll("\\", "\\\\").replaceAll('"', '\\"')}"`;
17548
+ const quoted2 = (object2) => `"${path33.join(moduleRoot, object2).replaceAll("\\", "\\\\").replaceAll('"', '\\"')}"`;
17404
17549
  const categoryObjects = new Set(
17405
17550
  foundationCategoryObjects.map((name) => `lib/Foundation-${name}.o`)
17406
17551
  );
@@ -17439,7 +17584,7 @@ function emitSwiftPackageManifest(args) {
17439
17584
  if (run2.length >= MODULE_MAP_RESPONSE_FILE_RUN) {
17440
17585
  const lines = run2.map((flag) => JSON.stringify(flag)).join("\n") + "\n";
17441
17586
  const digest2 = createHash18("sha256").update(lines).digest("hex");
17442
- const file2 = path32.join(args.root, ".peach-clang-arguments", `${digest2}.rsp`);
17587
+ const file2 = path33.join(args.root, ".peach-clang-arguments", `${digest2}.rsp`);
17443
17588
  args.files.set(file2, lines);
17444
17589
  flags.push(`@${file2}`);
17445
17590
  } else flags.push(...run2);
@@ -17463,7 +17608,7 @@ function emitSwiftPackageManifest(args) {
17463
17608
  endRun();
17464
17609
  const content = JSON.stringify(flags);
17465
17610
  const digest = createHash18("sha256").update(content).digest("hex");
17466
- const file = path32.join(args.root, ".peach-manifest-arguments", `${digest}.json`);
17611
+ const file = path33.join(args.root, ".peach-manifest-arguments", `${digest}.json`);
17467
17612
  args.files.set(file, content);
17468
17613
  return `peachCompilerArguments(${JSON.stringify(file)})`;
17469
17614
  };
@@ -17475,7 +17620,7 @@ function emitSwiftPackageManifest(args) {
17475
17620
  const compact = args.coalescibleOverlays ? compactSwiftClangOverlays(macros, args.coalescibleOverlays) : macros;
17476
17621
  const content = compact.map((flag) => JSON.stringify(flag)).join("\n") + "\n";
17477
17622
  const digest = createHash18("sha256").update(content).digest("hex");
17478
- const file = path32.join(args.root, ".peach-swift-arguments", `${digest}.rsp`);
17623
+ const file = path33.join(args.root, ".peach-swift-arguments", `${digest}.rsp`);
17479
17624
  args.files.set(file, content);
17480
17625
  return JSON.stringify([`@${file}`]);
17481
17626
  };
@@ -17487,7 +17632,7 @@ function emitSwiftPackageManifest(args) {
17487
17632
  owner?.publicHeadersPath ?? ""
17488
17633
  );
17489
17634
  return [
17490
- ...owner && framework ? [path32.posix.join(args.root, owner.path, framework[1])] : [],
17635
+ ...owner && framework ? [path33.posix.join(args.root, owner.path, framework[1])] : [],
17491
17636
  ...frameworkDirectories(dependency, seen)
17492
17637
  ];
17493
17638
  });
@@ -17530,7 +17675,7 @@ function emitSwiftPackageManifest(args) {
17530
17675
  const stanza = (target) => {
17531
17676
  const native = args.native?.get(target.name);
17532
17677
  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)}),`;
17678
+ return ` .systemLibrary(name: ${JSON.stringify(target.name)}, path: ${JSON.stringify(native?.clang ? path33.posix.dirname(native.clang.modulemap) : target.path)}),`;
17534
17679
  const isolation = target.mainActorIsolation ? " .defaultIsolation(MainActor.self)," : "";
17535
17680
  const interoperability = target.cxxInterop ? " .interoperabilityMode(.Cxx)," : "";
17536
17681
  const defines = (target.defines ?? []).map((name) => ` .define(${JSON.stringify(name)}),`).join("");
@@ -17588,7 +17733,7 @@ function emitSwiftPackageManifest(args) {
17588
17733
  ].map((flag) => `, ${JSON.stringify(flag)}`).join("");
17589
17734
  const header = args.headerDirectory && (args.nativeHeaderDeclarations?.[target.name] || [...args.native?.values() ?? []].some(
17590
17735
  (value) => value.late?.producers.includes(target.name)
17591
- )) ? `, "-emit-objc-header-path", ${JSON.stringify(path32.join(args.headerDirectory, `${target.name}-Swift.original.h`))}` : "";
17736
+ )) ? `, "-emit-objc-header-path", ${JSON.stringify(path33.join(args.headerDirectory, `${target.name}-Swift.original.h`))}` : "";
17592
17737
  const clangMode = target.cxxInterop ? "" : ', "-Xcc", "-fno-cxx-modules"';
17593
17738
  const deployment = `, "-Xfrontend", "-peach-ios-deployment-target", "-Xfrontend", ${JSON.stringify(target.iosDeploymentTarget ?? SWIFTPM_DEFAULT_IOS_DEPLOYMENT_TARGET)}`;
17594
17739
  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 +17934,10 @@ ${declaration.replace(/,$/, "")}
17789
17934
  function syncSwiftTree(base, files) {
17790
17935
  mkdirSync8(base, { recursive: true });
17791
17936
  const kept = /* @__PURE__ */ new Set();
17792
- for (const file of files.keys()) if (existsSync9(file)) kept.add(statSync4(file).ino);
17937
+ for (const file of files.keys()) if (existsSync10(file)) kept.add(statSync4(file).ino);
17793
17938
  const walk = (dir) => {
17794
17939
  for (const entry of readdirSync6(dir, { withFileTypes: true })) {
17795
- const full = path32.join(dir, entry.name);
17940
+ const full = path33.join(dir, entry.name);
17796
17941
  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
17942
  // must not remove them.
17798
17943
  entry.name === CLANG_DISTRIBUTION_MODULES || entry.name === SWIFT_DISTRIBUTION_MIRROR || entry.name === SWIFT_LINK_STAMP))
@@ -17949,7 +18094,7 @@ function compiledSwiftSources(files, targets, overlayFrameworks, headers, native
17949
18094
  const { onWasm, withoutWasm } = swiftTargetArchitectures(targets, swiftSources, headers);
17950
18095
  return new Map(
17951
18096
  [...owners].map(([file, { source, owner }]) => {
17952
- if (nativeSourceGlue && path32.posix.basename(file) === "OneNativeSource.generated.swift")
18097
+ if (nativeSourceGlue && path33.posix.basename(file) === "OneNativeSource.generated.swift")
17953
18098
  return [file, source];
17954
18099
  const manifest = /(?:^|\/)Package(?:@swift-[\d.]+)?\.swift$/.test(file);
17955
18100
  if (manifest && (!owner || /^Package(?:@swift-[\d.]+)?\.swift$/.test(file)))
@@ -18570,7 +18715,7 @@ function swiftApplicationEntry(file, source) {
18570
18715
  else if (source[at] === "}") depth--;
18571
18716
  else if (depth === 0 && /^@(?:main|UIApplicationMain)\b/.test(source.slice(at)))
18572
18717
  return true;
18573
- else if (depth === 0 && path32.basename(file) === "main.swift" && /^UIApplicationMain\s*\(/.test(source.slice(at)))
18718
+ else if (depth === 0 && path33.basename(file) === "main.swift" && /^UIApplicationMain\s*\(/.test(source.slice(at)))
18574
18719
  return true;
18575
18720
  }
18576
18721
  return false;
@@ -18966,17 +19111,17 @@ function prepareSwiftDependency(source, destination, overlayFrameworks) {
18966
19111
  for (const entry of readdirSync6(from, { withFileTypes: true })) {
18967
19112
  if (entry.name === ".git" || entry.name === ".build" || entry.name === ".swiftpm")
18968
19113
  continue;
18969
- const file = path32.join(from, entry.name);
19114
+ const file = path33.join(from, entry.name);
18970
19115
  if (entry.isDirectory()) gather(file);
18971
19116
  else if (entry.isFile() && entry.name.endsWith(".swift"))
18972
- origins[path32.relative(source, file)] = readFileSync16(file, "utf8");
19117
+ origins[path33.relative(source, file)] = readFileSync16(file, "utf8");
18973
19118
  else if (entry.isFile() && entry.name.endsWith(".modulemap"))
18974
19119
  moduleMaps.push(readFileSync16(file, "utf8"));
18975
19120
  }
18976
19121
  };
18977
19122
  gather(source);
18978
- const manifest = path32.join(source, "Package.swift");
18979
- const targets = existsSync9(manifest) ? swiftManifestTargets(
19123
+ const manifest = path33.join(source, "Package.swift");
19124
+ const targets = existsSync10(manifest) ? swiftManifestTargets(
18980
19125
  readFileSync16(manifest, "utf8"),
18981
19126
  [],
18982
19127
  (file) => readFileSync16(file, "utf8")
@@ -19007,11 +19152,11 @@ function prepareSwiftDependency(source, destination, overlayFrameworks) {
19007
19152
  for (const entry of readdirSync6(from, { withFileTypes: true })) {
19008
19153
  if (entry.name === ".git" || entry.name === ".build" || entry.name === ".swiftpm")
19009
19154
  continue;
19010
- const file = path32.join(from, entry.name);
19011
- const target = path32.join(to, entry.name);
19155
+ const file = path33.join(from, entry.name);
19156
+ const target = path33.join(to, entry.name);
19012
19157
  if (entry.isDirectory()) copy(file, target);
19013
19158
  else if (entry.isFile() && entry.name.endsWith(".swift"))
19014
- writeFileSync8(target, compiled.get(path32.relative(source, file)));
19159
+ writeFileSync8(target, compiled.get(path33.relative(source, file)));
19015
19160
  else cpSync(file, target, { verbatimSymlinks: true });
19016
19161
  }
19017
19162
  };
@@ -19089,18 +19234,18 @@ function withoutRepeatedClangFlags(flags) {
19089
19234
  }
19090
19235
  function clangImportModuleMapFlags(settings, layoutRoot, written, generated) {
19091
19236
  const searched = new Set(settings.headerSearchPaths);
19092
- const directory = path32.join(layoutRoot, ".build", "peach-clang-modulemaps");
19237
+ const directory = path33.join(layoutRoot, ".build", "peach-clang-modulemaps");
19093
19238
  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))
19239
+ const headers = path33.join(layoutRoot, map.headers);
19240
+ if (!existsSync10(headers)) return [];
19241
+ const published = path33.join(headers, "module.modulemap");
19242
+ if (searched.has(map.headers) && existsSync10(published)) return [];
19243
+ if (!searched.has(map.headers) && existsSync10(published))
19099
19244
  return [`-fmodule-map-file=${published}`];
19100
19245
  const cached = written.get(headers);
19101
19246
  if (cached) return [cached];
19102
19247
  mkdirSync8(directory, { recursive: true });
19103
- const output = path32.join(directory, `module-${written.size}.modulemap`);
19248
+ const output = path33.join(directory, `module-${written.size}.modulemap`);
19104
19249
  writeBuildFile(
19105
19250
  output,
19106
19251
  swiftPackageClangModuleMap(swiftTargetModuleName(map.module), {
@@ -19162,11 +19307,11 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19162
19307
  input.resourcePaths
19163
19308
  );
19164
19309
  const distribution = swiftDistributionAt(moduleRoot);
19165
- const distributionModules = distribution ? path32.join(moduleRoot, "modules") : void 0;
19310
+ const distributionModules = distribution ? path33.join(moduleRoot, "modules") : void 0;
19166
19311
  const targets = distribution && compileTargets(input).length === 0 ? [
19167
19312
  {
19168
19313
  name: "App",
19169
- path: path32.relative(layout2.root, layout2.sources),
19314
+ path: path33.relative(layout2.root, layout2.sources),
19170
19315
  executable: true,
19171
19316
  languageMode: 5,
19172
19317
  mainActorIsolation: false,
@@ -19192,12 +19337,12 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19192
19337
  if (!file.endsWith(".swift")) continue;
19193
19338
  const target = bySourcePath.find(
19194
19339
  (candidate) => (candidate.path === "." || file.startsWith(`${candidate.path}/`)) && (candidate.sources === void 0 || candidate.sources.some((source) => {
19195
- const selected = path32.posix.join(candidate.path, source);
19340
+ const selected = path33.posix.join(candidate.path, source);
19196
19341
  return file === selected || file.startsWith(`${selected}/`);
19197
19342
  }))
19198
19343
  );
19199
19344
  const excluded = target?.exclude?.some(
19200
- (name) => file === path32.posix.join(target.path, name)
19345
+ (name) => file === path33.posix.join(target.path, name)
19201
19346
  );
19202
19347
  if (target && !excluded) swiftTargets.add(target.name);
19203
19348
  }
@@ -19223,23 +19368,23 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19223
19368
  ([file, contents2]) => /\.(?:swift|h|m|mm)$/.test(file) ? [contents2.toString()] : []
19224
19369
  )
19225
19370
  );
19226
- const headerDirectory = path32.join(layout2.root, ".build", "peach-cxx-headers");
19227
- if (existsSync9(headerDirectory)) {
19371
+ const headerDirectory = path33.join(layout2.root, ".build", "peach-cxx-headers");
19372
+ if (existsSync10(headerDirectory)) {
19228
19373
  for (const entry of readdirSync6(headerDirectory, { withFileTypes: true }))
19229
19374
  if (entry.isDirectory() && !targets.some((target) => target.name === entry.name))
19230
- rmSync7(path32.join(headerDirectory, entry.name), { recursive: true, force: true });
19375
+ rmSync7(path33.join(headerDirectory, entry.name), { recursive: true, force: true });
19231
19376
  }
19232
19377
  let checkedToolchain;
19233
19378
  const nativeToolchain = () => {
19234
19379
  if (checkedToolchain) return checkedToolchain;
19235
- const pin = distribution ?? JSON.parse(readFileSync16(path32.join(moduleRoot, "toolchain.json"), "utf8"));
19380
+ const pin = distribution ?? JSON.parse(readFileSync16(path33.join(moduleRoot, "toolchain.json"), "utf8"));
19236
19381
  checkedToolchain = swiftToolchain(pin.release, swiftModuleSdk(moduleRoot));
19237
19382
  return checkedToolchain;
19238
19383
  };
19239
19384
  const deploymentTarget = (name) => input.nativeTargets?.find((value) => value.name === name)?.deploymentTarget ?? targets.find((value) => value.name === name)?.iosDeploymentTarget ?? null;
19240
19385
  const targetStagedFiles = /* @__PURE__ */ new Map();
19241
19386
  const stageTargetFile = (target, file, contents2, options) => {
19242
- const relative = path32.relative(layout2.root, file).split(path32.sep).join(path32.posix.sep);
19387
+ const relative = path33.relative(layout2.root, file).split(path33.sep).join(path33.posix.sep);
19243
19388
  const prior = files.has(file) ? files.get(file) : Object.hasOwn(input.files, relative) ? input.files[relative] : void 0;
19244
19389
  if (!options?.allowExisting && prior !== void 0)
19245
19390
  throw new Error(`target ${target} already contains generated output ${relative}`);
@@ -19252,7 +19397,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19252
19397
  const prefix = target.path === "." ? "" : `${target.path}/`;
19253
19398
  return Object.entries(input.files).filter(
19254
19399
  ([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);
19400
+ const selected = path33.posix.join(prefix, source);
19256
19401
  return file === selected || file.startsWith(`${selected}/`);
19257
19402
  })) && !target.exclude?.some(
19258
19403
  (excluded) => file === `${prefix}${excluded}` || file.startsWith(`${prefix}${excluded}/`)
@@ -19273,7 +19418,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19273
19418
  targetStagedFiles.delete(target.name);
19274
19419
  if (entries2.some(([file]) => isSwiftNativeTranslationUnit(file)) && (swift || input.nativeTargets?.some((value) => value.name === target.name))) {
19275
19420
  if (!swift) {
19276
- const unprepared = path32.join(
19421
+ const unprepared = path33.join(
19277
19422
  layout2.root,
19278
19423
  target.path,
19279
19424
  "PeachUnprepared.generated.swift"
@@ -19288,7 +19433,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19288
19433
  native.set(target.name, {
19289
19434
  mixed: true,
19290
19435
  path: target.path,
19291
- includeDirectory: path32.join(layout2.root, target.path, "include"),
19436
+ includeDirectory: path33.join(layout2.root, target.path, "include"),
19292
19437
  sources: [],
19293
19438
  lateSources: [],
19294
19439
  exclude: entries2.filter(([file]) => !file.endsWith(".swift") && !file.endsWith(".metal")).map(([file]) => file.slice(prefix.length))
@@ -19310,15 +19455,15 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19310
19455
  file
19311
19456
  )?.[1];
19312
19457
  if (owner)
19313
- podHeaders.set(path32.basename(file), [
19314
- ...podHeaders.get(path32.basename(file)) ?? [],
19458
+ podHeaders.set(path33.basename(file), [
19459
+ ...podHeaders.get(path33.basename(file)) ?? [],
19315
19460
  { owner, content: input.files[file] }
19316
19461
  ]);
19317
19462
  }
19318
- const podHeaderOwner = (file, content) => /\/Headers\/(?:Public|Private)\/([\w+-]+)\//.exec(file)?.[1] ?? podHeaders.get(path32.basename(file))?.find((header) => header.content === content)?.owner;
19463
+ const podHeaderOwner = (file, content) => /\/Headers\/(?:Public|Private)\/([\w+-]+)\//.exec(file)?.[1] ?? podHeaders.get(path33.basename(file))?.find((header) => header.content === content)?.owner;
19319
19464
  for (const settings of input.nativeTargets ?? []) {
19320
19465
  for (const file of settings.headers) {
19321
- const destination = path32.join(layout2.root, file);
19466
+ const destination = path33.join(layout2.root, file);
19322
19467
  if (files.has(destination)) continue;
19323
19468
  const interfaceModule = /(?:^|\/)(\w+)-Swift\.h$/.exec(file)?.[1];
19324
19469
  const frameworkHeader = !interfaceModule && /(?:^|\/)(\w+)\.framework\/Headers\/[\w+.-]+\.h$/.exec(file)?.[1];
@@ -19337,35 +19482,35 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19337
19482
  }
19338
19483
  }
19339
19484
  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}`;
19485
+ const fromInputRoot = (file) => file.startsWith(`${SWIFT_NATIVE_INPUT_ROOT}/`) ? path33.join(layout2.root, file.slice(SWIFT_NATIVE_INPUT_ROOT.length + 1)) : file;
19486
+ const inRoot = `${layout2.root}${path33.sep}`;
19487
+ const binaryTree = `${path33.sep}${SWIFT_BINARY_TREES_DIR}${path33.sep}`;
19343
19488
  const headerSearch = writeXcodeHeaderSearch(
19344
- path32.join(layout2.root, ".build", "peach-xcode-headers"),
19489
+ path33.join(layout2.root, ".build", "peach-xcode-headers"),
19345
19490
  nativeTargets.map((settings) => {
19346
19491
  const productHeaders = {};
19347
19492
  const publishedHeaders = /* @__PURE__ */ new Set();
19348
19493
  const moduleName = swiftTargetModuleName(settings.name);
19349
19494
  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;
19495
+ const header = path33.join(layout2.root, file);
19496
+ productHeaders[path33.join(layout2.root, product)] = header;
19352
19497
  const framework = /^(.+\.framework)\/((?:Private)?Headers\/.+)$/.exec(product);
19353
19498
  if (framework && Object.hasOwn(
19354
19499
  settings.productHeaders,
19355
19500
  `${framework[1]}/Modules/module.modulemap`
19356
19501
  )) {
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)}`)
19502
+ productHeaders[path33.join(layout2.root, framework[1], "Modules", framework[2])] = header;
19503
+ if (path33.posix.basename(framework[1]) === `${moduleName}.framework` && framework[2] === `Headers/${path33.posix.basename(file)}`)
19359
19504
  publishedHeaders.add(file);
19360
19505
  }
19361
19506
  }
19362
19507
  if (settings.flattensPublicHeaders)
19363
19508
  for (const file of settings.publicHeaders) {
19364
19509
  if (publishedHeaders.has(file)) continue;
19365
- const alias = path32.join(headerDirectory, settings.name, path32.basename(file));
19510
+ const alias = path33.join(headerDirectory, settings.name, path33.basename(file));
19366
19511
  if (Object.hasOwn(productHeaders, alias))
19367
19512
  throw new Error(`duplicate product header ${alias}`);
19368
- productHeaders[alias] = path32.join(layout2.root, file);
19513
+ productHeaders[alias] = path33.join(layout2.root, file);
19369
19514
  }
19370
19515
  return {
19371
19516
  headerMaps: settings.headerMaps.map((map) => ({
@@ -19377,18 +19522,18 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19377
19522
  })),
19378
19523
  productHeaders,
19379
19524
  userHeaderSearchPaths: settings.userHeaderSearchPaths.map(
19380
- (directory) => path32.join(layout2.root, directory)
19525
+ (directory) => path33.join(layout2.root, directory)
19381
19526
  ),
19382
19527
  searchDirectories: [
19383
19528
  ...settings.headerSearchPaths,
19384
19529
  ...settings.frameworkSearchPaths
19385
- ].map((directory) => path32.join(layout2.root, directory))
19530
+ ].map((directory) => path33.join(layout2.root, directory))
19386
19531
  };
19387
19532
  }),
19388
19533
  Object.fromEntries(
19389
19534
  Object.entries(input.headerAliases ?? {}).map(([alias, file]) => [
19390
- path32.join(layout2.root, alias),
19391
- path32.join(layout2.root, file)
19535
+ path33.join(layout2.root, alias),
19536
+ path33.join(layout2.root, file)
19392
19537
  ])
19393
19538
  ),
19394
19539
  (file) => !file.startsWith(inRoot) || files.has(file) || file.includes(binaryTree)
@@ -19432,9 +19577,9 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19432
19577
  const producer = /(?:^|\/)([^/]+)-Swift\.h$/.exec(include)?.[1];
19433
19578
  if (producer && swiftTargets.has(producer)) producers2.add(producer);
19434
19579
  const local = [
19435
- path32.posix.join(path32.posix.dirname(file), include),
19580
+ path33.posix.join(path33.posix.dirname(file), include),
19436
19581
  `${includes}${include}`,
19437
- ...searchRoots.map((root) => path32.posix.join(root, include))
19582
+ ...searchRoots.map((root) => path33.posix.join(root, include))
19438
19583
  ].find((candidate) => input.files[candidate] !== void 0);
19439
19584
  if (local) {
19440
19585
  reverse.set(local, [...reverse.get(local) ?? [], file]);
@@ -19477,7 +19622,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19477
19622
  );
19478
19623
  const roots2 = settings.bridgingHeader ? [settings.bridgingHeader] : entries2.some(([file]) => file.endsWith(".swift")) || importedModules.has(swiftTargetModuleName(target.name)) ? settings.publicHeaders : [];
19479
19624
  const search = [.../* @__PURE__ */ new Set([...settings?.headerSearchPaths ?? []])].flatMap(
19480
- (dir) => ["-I", path32.join(layout2.root, dir)]
19625
+ (dir) => ["-I", path33.join(layout2.root, dir)]
19481
19626
  );
19482
19627
  const toolchainBin = nativeToolchain();
19483
19628
  const stageFlags = (flags2, sdkInclude2) => flags2.map(
@@ -19489,7 +19634,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19489
19634
  ...search,
19490
19635
  ...(settings?.frameworkSearchPaths ?? []).flatMap((dir) => [
19491
19636
  "-F",
19492
- path32.join(layout2.root, dir)
19637
+ path33.join(layout2.root, dir)
19493
19638
  ]),
19494
19639
  "-I",
19495
19640
  headerDirectory
@@ -19500,7 +19645,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19500
19645
  ...search,
19501
19646
  ...settings.frameworkSearchPaths.flatMap((dir) => [
19502
19647
  "-F",
19503
- path32.join(layout2.root, dir)
19648
+ path33.join(layout2.root, dir)
19504
19649
  ]),
19505
19650
  "-I",
19506
19651
  headerDirectory
@@ -19510,13 +19655,13 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19510
19655
  const flag = settings.importerFlags[index];
19511
19656
  if (flag === "-I" || flag === "-iquote") {
19512
19657
  const directory = settings.importerFlags[index + 1];
19513
- if (directory === void 0 || !path32.isAbsolute(directory)) {
19658
+ if (directory === void 0 || !path33.isAbsolute(directory)) {
19514
19659
  index++;
19515
19660
  continue;
19516
19661
  }
19517
19662
  }
19518
19663
  const joined = /^-(?:I|iquote)(.+)$/.exec(flag);
19519
- if (joined && !path32.isAbsolute(joined[1])) continue;
19664
+ if (joined && !path33.isAbsolute(joined[1])) continue;
19520
19665
  kept.push(flag);
19521
19666
  }
19522
19667
  return [
@@ -19525,13 +19670,13 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19525
19670
  ...search,
19526
19671
  ...(settings?.frameworkSearchPaths ?? []).flatMap((dir) => [
19527
19672
  "-F",
19528
- path32.join(layout2.root, dir)
19673
+ path33.join(layout2.root, dir)
19529
19674
  ]),
19530
19675
  "-I",
19531
19676
  headerDirectory
19532
19677
  ];
19533
19678
  })();
19534
- const sdkInclude = path32.join(
19679
+ const sdkInclude = path33.join(
19535
19680
  swiftSdkPaths(moduleRoot, toolchainBin).sysroot,
19536
19681
  "darwin/usr/include"
19537
19682
  );
@@ -19546,7 +19691,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19546
19691
  ...dependencyModuleMaps,
19547
19692
  ...xcodeTarget && !target.defines?.includes("SWIFT_PACKAGE") ? ["-USWIFT_PACKAGE"] : []
19548
19693
  ];
19549
- const prefixHeader = settings?.prefixHeader ? ["-include", path32.join(layout2.root, settings.prefixHeader)] : [];
19694
+ const prefixHeader = settings?.prefixHeader ? ["-include", path33.join(layout2.root, settings.prefixHeader)] : [];
19550
19695
  const bundleName = entries2.some(([file]) => file.endsWith(".swift")) ? void 0 : swiftObjCResourceBundleName({
19551
19696
  target: target.name,
19552
19697
  path: target.path,
@@ -19557,7 +19702,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19557
19702
  bundles: input.resourceBundles
19558
19703
  });
19559
19704
  const accessor = bundleName === void 0 ? void 0 : swiftObjCResourceAccessor(bundleName);
19560
- const accessorHeader = path32.join(
19705
+ const accessorHeader = path33.join(
19561
19706
  layout2.root,
19562
19707
  target.path,
19563
19708
  OBJC_RESOURCE_ACCESSOR_HEADER
@@ -19568,7 +19713,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19568
19713
  const nativeUnits = accessor ? [...units, [accessorUnit, accessor.body]] : units;
19569
19714
  const unitSource = (file) => {
19570
19715
  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;
19716
+ return relative.split("/").some((part) => part.startsWith(".")) ? path33.posix.join(HIDDEN_UNITS, relative.replaceAll(/(^|\/)\./g, "$1%2E")) : relative;
19572
19717
  };
19573
19718
  const accessorFlags = accessor ? ["-include", accessorHeader] : [];
19574
19719
  const nativeC = !entries2.some(([file]) => file.endsWith(".swift"));
@@ -19598,20 +19743,20 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19598
19743
  )
19599
19744
  ].sort();
19600
19745
  const topHeaders = settings.publicHeaders.filter(
19601
- (file) => path32.posix.dirname(file) === headerDir
19746
+ (file) => path33.posix.dirname(file) === headerDir
19602
19747
  );
19603
19748
  if (input.files[custom] !== void 0) {
19604
19749
  swiftpmModuleMap = { path: custom, contents: input.files[custom] };
19605
19750
  } else if (input.files[umbrella] !== void 0) {
19606
19751
  if (siblingDirs.length > 0)
19607
19752
  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`
19753
+ `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
19754
  );
19610
19755
  swiftpmModuleMap = {
19611
19756
  path: custom,
19612
19757
  contents: swiftPackageClangModuleMap(moduleName, {
19613
19758
  kind: "header",
19614
- path: path32.join(layout2.root, umbrella)
19759
+ path: path33.join(layout2.root, umbrella)
19615
19760
  })
19616
19761
  };
19617
19762
  } else if (input.files[nestedUmbrella] !== void 0 && siblingDirs.length === 1 && siblingDirs[0] === moduleName && topHeaders.length === 0) {
@@ -19619,7 +19764,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19619
19764
  path: custom,
19620
19765
  contents: swiftPackageClangModuleMap(moduleName, {
19621
19766
  kind: "header",
19622
- path: path32.join(layout2.root, nestedUmbrella)
19767
+ path: path33.join(layout2.root, nestedUmbrella)
19623
19768
  })
19624
19769
  };
19625
19770
  } else {
@@ -19627,12 +19772,12 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19627
19772
  path: custom,
19628
19773
  contents: swiftPackageClangModuleMap(moduleName, {
19629
19774
  kind: "directory",
19630
- path: path32.join(layout2.root, headerDir)
19775
+ path: path33.join(layout2.root, headerDir)
19631
19776
  })
19632
19777
  };
19633
19778
  }
19634
19779
  }
19635
- const modulemap = (originalModuleMap ? originalModuleMap[0].endsWith("/Modules/module.modulemap") ? originalModuleMap[0] : originalModuleMap[1] : void 0) ?? swiftpmModuleMap?.path ?? packageModuleMap?.[0] ?? path32.posix.join(
19780
+ const modulemap = (originalModuleMap ? originalModuleMap[0].endsWith("/Modules/module.modulemap") ? originalModuleMap[0] : originalModuleMap[1] : void 0) ?? swiftpmModuleMap?.path ?? packageModuleMap?.[0] ?? path33.posix.join(
19636
19781
  ".build",
19637
19782
  "peach-objc-originals",
19638
19783
  target.name,
@@ -19640,59 +19785,59 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19640
19785
  );
19641
19786
  const moduleContents = originalModuleMap ? input.files[originalModuleMap[1]] : swiftpmModuleMap?.contents ?? packageModuleMap?.[1] ?? swiftObjCModuleMap(
19642
19787
  swiftTargetModuleName(target.name),
19643
- roots2.map((file) => path32.join(layout2.root, file)),
19788
+ roots2.map((file) => path33.join(layout2.root, file)),
19644
19789
  submoduleImports2.get(swiftTargetModuleName(target.name))
19645
19790
  );
19646
19791
  if (moduleContents === void 0)
19647
19792
  throw new Error("missing original module map " + modulemap);
19648
19793
  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, {
19794
+ const frameworkDirectory = framework ? path33.join(layout2.root, framework[1]) : void 0;
19795
+ stageTargetFile(target.name, path33.join(layout2.root, modulemap), moduleContents, {
19651
19796
  allowExisting: true
19652
19797
  });
19653
19798
  sourceModuleMaps.set(swiftTargetModuleName(target.name), {
19654
- path: path32.join(layout2.root, modulemap),
19799
+ path: path33.join(layout2.root, modulemap),
19655
19800
  contents: moduleContents.toString()
19656
19801
  });
19657
- if (nativeC && path32.posix.basename(modulemap) !== "module.modulemap") {
19802
+ if (nativeC && path33.posix.basename(modulemap) !== "module.modulemap") {
19658
19803
  stageTargetFile(
19659
19804
  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))}
19805
+ path33.join(layout2.root, path33.posix.dirname(modulemap), "module.modulemap"),
19806
+ `extern module ${swiftTargetModuleName(target.name)} ${JSON.stringify(path33.join(layout2.root, modulemap))}
19662
19807
  `
19663
19808
  );
19664
19809
  }
19665
19810
  const importFlags = [
19666
19811
  ...swiftClangImporterFlags(stageFlags(importOriginalFlags, sdkInclude)),
19667
- "-fmodule-map-file=" + path32.join(layout2.root, modulemap),
19812
+ "-fmodule-map-file=" + path33.join(layout2.root, modulemap),
19668
19813
  ...dependencyModuleMaps
19669
19814
  ];
19670
19815
  const groups = /* @__PURE__ */ new Map();
19671
19816
  for (const [file, contents2] of nativeUnits) {
19672
19817
  const origin = settings?.sourceDirectories[file];
19673
19818
  if (origin) {
19674
- const original = path32.join(layout2.root, origin, path32.posix.basename(file));
19675
- mkdirSync8(path32.dirname(original), { recursive: true });
19819
+ const original = path33.join(layout2.root, origin, path33.posix.basename(file));
19820
+ mkdirSync8(path33.dirname(original), { recursive: true });
19676
19821
  stageTargetFile(target.name, original, contents2, { allowExisting: true });
19677
19822
  }
19678
19823
  const source = unitSource(file);
19679
19824
  if (source !== file.slice(prefix.length))
19680
19825
  stageTargetFile(
19681
19826
  target.name,
19682
- path32.join(layout2.root, target.path, source),
19827
+ path33.join(layout2.root, target.path, source),
19683
19828
  contents2,
19684
19829
  {
19685
19830
  allowExisting: true
19686
19831
  }
19687
19832
  );
19688
- const stagedDir = path32.posix.dirname(file);
19833
+ const stagedDir = path33.posix.dirname(file);
19689
19834
  const quoteDirs = [
19690
19835
  ...stagedDir !== "." ? [stagedDir] : [],
19691
19836
  ...origin && origin !== stagedDir ? [origin] : []
19692
19837
  ];
19693
19838
  const quoteFlags = quoteDirs.flatMap((dir) => [
19694
19839
  "-iquote",
19695
- path32.join(layout2.root, dir)
19840
+ path33.join(layout2.root, dir)
19696
19841
  ]);
19697
19842
  const fileFlags = settings.fileFlags[file] ?? [];
19698
19843
  const objcCxx = fileFlags.includes(SWIFT_OBJCXX_LANGUAGE_FLAG);
@@ -19703,7 +19848,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19703
19848
  .../\.mm?$/.test(file) ? ["-fobjc-exceptions"] : [],
19704
19849
  ...stageFlags(
19705
19850
  [...objcCxx ? settings.cxxFlags : [], ...fileFlags],
19706
- path32.join(
19851
+ path33.join(
19707
19852
  swiftSdkPaths(moduleRoot, toolchainBin).sysroot,
19708
19853
  "darwin/usr/include"
19709
19854
  )
@@ -19714,17 +19859,17 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19714
19859
  JSON.stringify([
19715
19860
  cxx,
19716
19861
  quoteDirs,
19717
- perFile.map((flag) => flag.replaceAll(layout2.root + path32.sep, "")),
19862
+ perFile.map((flag) => flag.replaceAll(layout2.root + path33.sep, "")),
19718
19863
  (consumers.get(file)?.size ?? 0) > 0
19719
19864
  ])
19720
19865
  ).digest("hex").slice(0, 12);
19721
19866
  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);
19867
+ const groupPath = path33.posix.join("PeachNativeSources", name);
19868
+ const canonicalTargetPath = path33.posix.join("/peach/build", target.path);
19724
19869
  const sourceIdentity = [
19725
- `-ffile-prefix-map=${path32.join(layout2.root, groupPath)}=${canonicalTargetPath}`,
19870
+ `-ffile-prefix-map=${path33.join(layout2.root, groupPath)}=${canonicalTargetPath}`,
19726
19871
  ...nativeToolset ? [
19727
- `-ffile-prefix-map=${path32.posix.join("/peach/build", groupPath)}=${canonicalTargetPath}`
19872
+ `-ffile-prefix-map=${path33.posix.join("/peach/build", groupPath)}=${canonicalTargetPath}`
19728
19873
  ] : []
19729
19874
  ];
19730
19875
  const group = groups.get(identity) ?? {
@@ -19748,7 +19893,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19748
19893
  ...accessorFlags,
19749
19894
  ...stageFlags(
19750
19895
  cxx ? settings.cxxFlags : [],
19751
- path32.join(
19896
+ path33.join(
19752
19897
  swiftSdkPaths(moduleRoot, toolchainBin).sysroot,
19753
19898
  "darwin/usr/include"
19754
19899
  )
@@ -19759,12 +19904,12 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19759
19904
  };
19760
19905
  stageTargetFile(
19761
19906
  target.name,
19762
- path32.join(layout2.root, group.path, source),
19907
+ path33.join(layout2.root, group.path, source),
19763
19908
  contents2
19764
19909
  );
19765
19910
  stageTargetFile(
19766
19911
  target.name,
19767
- path32.join(layout2.root, group.path, "include/module.modulemap"),
19912
+ path33.join(layout2.root, group.path, "include/module.modulemap"),
19768
19913
  `module ${swiftTargetModuleName(group.name)} { export * }
19769
19914
  `,
19770
19915
  { allowExisting: true }
@@ -19782,7 +19927,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19782
19927
  stageTargetFile(target.name, accessorHeader, accessor.header);
19783
19928
  stageTargetFile(
19784
19929
  target.name,
19785
- path32.join(layout2.root, accessorUnit),
19930
+ path33.join(layout2.root, accessorUnit),
19786
19931
  accessor.body
19787
19932
  );
19788
19933
  }
@@ -19797,7 +19942,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19797
19942
  ].sort();
19798
19943
  native.set(target.name, {
19799
19944
  path: target.path,
19800
- includeDirectory: path32.dirname(path32.join(layout2.root, modulemap)),
19945
+ includeDirectory: path33.dirname(path33.join(layout2.root, modulemap)),
19801
19946
  importFlags,
19802
19947
  frameworkDirectory,
19803
19948
  sources: nativeUnits.map(([file]) => unitSource(file)),
@@ -19821,23 +19966,23 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19821
19966
  throw new Error(`original module map declares no module: ${modulemap}`);
19822
19967
  stageTargetFile(
19823
19968
  target.name,
19824
- path32.join(layout2.root, owner.path, "include/module.modulemap"),
19825
- `extern module ${exportedModule} ${JSON.stringify(path32.join(layout2.root, modulemap))}
19969
+ path33.join(layout2.root, owner.path, "include/module.modulemap"),
19970
+ `extern module ${exportedModule} ${JSON.stringify(path33.join(layout2.root, modulemap))}
19826
19971
  `,
19827
19972
  { allowExisting: true }
19828
19973
  );
19829
19974
  }
19830
19975
  continue;
19831
19976
  }
19832
- const implementationHeaders = path32.posix.join(
19977
+ const implementationHeaders = path33.posix.join(
19833
19978
  ".build",
19834
19979
  "peach-objc-implementations",
19835
19980
  target.name
19836
19981
  );
19837
- const include = path32.join(layout2.root, implementationHeaders);
19982
+ const include = path33.join(layout2.root, implementationHeaders);
19838
19983
  stageTargetFile(
19839
19984
  target.name,
19840
- path32.join(include, "module.modulemap"),
19985
+ path33.join(include, "module.modulemap"),
19841
19986
  `module ${target.name}ImplementationDeclarations { export * }
19842
19987
  `
19843
19988
  );
@@ -19847,7 +19992,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19847
19992
  includeDirectory: include,
19848
19993
  importFlags,
19849
19994
  swiftFlags: [
19850
- ...settings.bridgingHeader ? ["-import-objc-header", path32.join(layout2.root, settings.bridgingHeader)] : roots2.length ? ["-import-underlying-module"] : [],
19995
+ ...settings.bridgingHeader ? ["-import-objc-header", path33.join(layout2.root, settings.bridgingHeader)] : roots2.length ? ["-import-underlying-module"] : [],
19851
19996
  ...importFlags.flatMap((flag) => ["-Xcc", flag])
19852
19997
  ],
19853
19998
  sources: nativeUnits.map(([file]) => unitSource(file)),
@@ -19878,7 +20023,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19878
20023
  const textualIncludes = entries2.map(([file]) => file).filter((file) => /\.(?:inc|inl|ipp|def)$/.test(file));
19879
20024
  native.set(target.name, {
19880
20025
  path: target.path,
19881
- includeDirectory: path32.join(layout2.root, includes),
20026
+ includeDirectory: path33.join(layout2.root, includes),
19882
20027
  sources: units.map(([file]) => file.slice(prefix.length)),
19883
20028
  lateSources: late.map(([file]) => file.slice(prefix.length)),
19884
20029
  exclude: [
@@ -19895,21 +20040,21 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19895
20040
  } : {}
19896
20041
  });
19897
20042
  if (late.length === 0) {
19898
- const headers = path32.posix.join(target.path, target.publicHeadersPath ?? "include");
20043
+ const headers = path33.posix.join(target.path, target.publicHeadersPath ?? "include");
19899
20044
  const fragments = textualIncludes.filter(
19900
20045
  (file) => headers === "." || file.startsWith(`${headers}/`)
19901
20046
  );
19902
20047
  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`)))
20048
+ const map = path33.posix.join(headers, "module.modulemap");
20049
+ 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
20050
  stageTargetFile(
19906
20051
  target.name,
19907
- path32.join(layout2.root, map),
20052
+ path33.join(layout2.root, map),
19908
20053
  [
19909
20054
  `module ${name} {`,
19910
20055
  ' umbrella "."',
19911
20056
  ...fragments.map(
19912
- (file) => ` textual header ${JSON.stringify(path32.posix.relative(headers, file))}`
20057
+ (file) => ` textual header ${JSON.stringify(path33.posix.relative(headers, file))}`
19913
20058
  ),
19914
20059
  " export *",
19915
20060
  "}",
@@ -19919,7 +20064,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19919
20064
  continue;
19920
20065
  }
19921
20066
  files.set(
19922
- path32.join(layout2.root, target.path, "PeachSwiftImplementation/module.modulemap"),
20067
+ path33.join(layout2.root, target.path, "PeachSwiftImplementation/module.modulemap"),
19923
20068
  `module ${swiftTargetModuleName(`${target.name}SwiftImplementation`)} { export * }
19924
20069
  `
19925
20070
  );
@@ -19931,7 +20076,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19931
20076
  ([file]) => file.startsWith(includes) && /\.(?:h|hpp|hh|hxx)$/.test(file) && consumers.get(file).size === 0
19932
20077
  );
19933
20078
  files.set(
19934
- path32.join(layout2.root, includes, "module.modulemap"),
20079
+ path33.join(layout2.root, includes, "module.modulemap"),
19935
20080
  [
19936
20081
  `module ${target.name} {`,
19937
20082
  ...roots.map(
@@ -19946,7 +20091,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19946
20091
  for (const map of generatedModuleMaps)
19947
20092
  if (files.has(map.published) || Object.hasOwn(
19948
20093
  input.files,
19949
- path32.relative(layout2.root, map.published).split(path32.sep).join(path32.posix.sep)
20094
+ path33.relative(layout2.root, map.published).split(path33.sep).join(path33.posix.sep)
19950
20095
  ))
19951
20096
  writeBuildFile(
19952
20097
  map.output,
@@ -19975,10 +20120,10 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19975
20120
  [...native.values()].flatMap((value) => value.late?.producers ?? [])
19976
20121
  )) {
19977
20122
  files.set(
19978
- path32.join(headerDirectory, name, name + "-Swift.h"),
20123
+ path33.join(headerDirectory, name, name + "-Swift.h"),
19979
20124
  '#include "../' + name + '-Swift.h"\n'
19980
20125
  );
19981
- const modulemap = path32.join(
20126
+ const modulemap = path33.join(
19982
20127
  layout2.root,
19983
20128
  ".build",
19984
20129
  "peach-objc-swift-headers",
@@ -19988,7 +20133,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
19988
20133
  const moduleName = swiftTargetModuleName(name);
19989
20134
  const originalMap = originalMaps.get(moduleName);
19990
20135
  const stagedMap = sourceModuleMaps.get(moduleName);
19991
- const originalPath = stagedMap?.path ?? (originalMap ? path32.join(layout2.root, originalMap) : void 0);
20136
+ const originalPath = stagedMap?.path ?? (originalMap ? path33.join(layout2.root, originalMap) : void 0);
19992
20137
  const originalContents = stagedMap?.contents ?? (originalMap && input.files[originalMap]);
19993
20138
  const originalTokens = originalContents ? moduleMapTokens(originalContents) : [];
19994
20139
  if (originalPath && originalTokens.some(
@@ -20002,20 +20147,20 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
20002
20147
  modulemap,
20003
20148
  originalPath ? `extern module ${moduleName} ${JSON.stringify(originalPath)}
20004
20149
  module ${moduleName}.Swift {
20005
- header ${JSON.stringify(path32.join(headerDirectory, name + "-Swift.h"))}
20150
+ header ${JSON.stringify(path33.join(headerDirectory, name + "-Swift.h"))}
20006
20151
  requires objc
20007
20152
  }
20008
20153
  ` : swiftObjCModuleMap(
20009
20154
  moduleName,
20010
- (input.nativeTargets?.find((target) => target.name === name)?.publicHeaders ?? []).map((header) => path32.join(layout2.root, header)),
20155
+ (input.nativeTargets?.find((target) => target.name === name)?.publicHeaders ?? []).map((header) => path33.join(layout2.root, header)),
20011
20156
  submoduleImports2.get(moduleName),
20012
- path32.join(headerDirectory, name + "-Swift.h")
20157
+ path33.join(headerDirectory, name + "-Swift.h")
20013
20158
  )
20014
20159
  );
20015
20160
  nativeHeaderFlags.push("-fmodule-map-file=" + modulemap);
20016
20161
  nativeSwiftHeaderMaps.set(name, modulemap);
20017
20162
  }
20018
- const providedFrameworks = path32.join(layout2.root, ".build", "peach-provided-frameworks");
20163
+ const providedFrameworks = path33.join(layout2.root, ".build", "peach-provided-frameworks");
20019
20164
  const probedProducts = /* @__PURE__ */ new Set();
20020
20165
  if (distribution) {
20021
20166
  for (const [file, contents2] of Object.entries(input.files))
@@ -20041,10 +20186,10 @@ module ${moduleName}.Swift {
20041
20186
  continue;
20042
20187
  const providedInterface = moduleInterface(name);
20043
20188
  if (!providedInterface) continue;
20044
- const framework = path32.join(providedFrameworks, `${name}.framework`);
20045
- files.set(path32.join(framework, "Headers", `${name}.h`), providedInterface.header);
20189
+ const framework = path33.join(providedFrameworks, `${name}.framework`);
20190
+ files.set(path33.join(framework, "Headers", `${name}.h`), providedInterface.header);
20046
20191
  files.set(
20047
- path32.join(framework, "Modules", "module.modulemap"),
20192
+ path33.join(framework, "Modules", "module.modulemap"),
20048
20193
  `framework module ${name} {
20049
20194
  umbrella header "${name}.h"
20050
20195
  export *
@@ -20053,10 +20198,10 @@ module ${moduleName}.Swift {
20053
20198
  );
20054
20199
  stagedProducts.push(name);
20055
20200
  }
20056
- if (existsSync9(providedFrameworks)) {
20201
+ if (existsSync10(providedFrameworks)) {
20057
20202
  for (const entry of readdirSync6(providedFrameworks))
20058
20203
  if (!stagedProducts.includes(entry.replace(/\.framework$/, "")))
20059
- rmSync7(path32.join(providedFrameworks, entry), { recursive: true, force: true });
20204
+ rmSync7(path33.join(providedFrameworks, entry), { recursive: true, force: true });
20060
20205
  }
20061
20206
  const providedFrameworkFlags = stagedProducts.length ? ["-F", providedFrameworks] : [];
20062
20207
  const frameworkSearch = JSON.stringify([
@@ -20065,15 +20210,15 @@ module ${moduleName}.Swift {
20065
20210
  ...new Set(nativeTargets.flatMap((settings) => settings.frameworkSearchPaths))
20066
20211
  ].sort()
20067
20212
  ]);
20068
- const frameworkSearchRecord = path32.join(
20213
+ const frameworkSearchRecord = path33.join(
20069
20214
  layout2.root,
20070
20215
  ".build",
20071
20216
  "peach-framework-search.json"
20072
20217
  );
20073
- if (!existsSync9(frameworkSearchRecord) || readFileSync16(frameworkSearchRecord, "utf8") !== frameworkSearch)
20218
+ if (!existsSync10(frameworkSearchRecord) || readFileSync16(frameworkSearchRecord, "utf8") !== frameworkSearch)
20074
20219
  for (const cache of [
20075
- path32.join(layout2.root, ".build", "ModuleCache"),
20076
- path32.join(layout2.root, ".build", WASM_TRIPLE, "release", "ModuleCache")
20220
+ path33.join(layout2.root, ".build", "ModuleCache"),
20221
+ path33.join(layout2.root, ".build", WASM_TRIPLE, "release", "ModuleCache")
20077
20222
  ])
20078
20223
  rmSync7(cache, { recursive: true, force: true });
20079
20224
  files.set(frameworkSearchRecord, frameworkSearch);
@@ -20081,7 +20226,7 @@ module ${moduleName}.Swift {
20081
20226
  swiftModuleInputFiles(moduleRoot).join("\n")
20082
20227
  );
20083
20228
  if (!distribution) {
20084
- modulePlan.update(readFileSync16(path32.join(moduleRoot, "Package.swift")));
20229
+ modulePlan.update(readFileSync16(path33.join(moduleRoot, "Package.swift")));
20085
20230
  }
20086
20231
  modulePlan.update(
20087
20232
  Object.keys(input.files).filter((file) => file.endsWith(".swift")).sort().join("\n")
@@ -20136,7 +20281,7 @@ module ${moduleName}.Swift {
20136
20281
  (target) => {
20137
20282
  const native2 = input.nativeTargets?.find(({ name }) => name === target.name);
20138
20283
  if (native2) return native2.publicHeaders.map((file) => input.files[file] ?? "");
20139
- const directory = path32.posix.join(
20284
+ const directory = path33.posix.join(
20140
20285
  target.path,
20141
20286
  target.publicHeadersPath ?? "include"
20142
20287
  );
@@ -20172,7 +20317,7 @@ module ${moduleName}.Swift {
20172
20317
  `;
20173
20318
  } else if (mains.length === 0) {
20174
20319
  const procedural = entries2.filter(
20175
- ([file, source]) => path32.basename(file) === "main.swift" && swiftApplicationEntry(file, source)
20320
+ ([file, source]) => path33.basename(file) === "main.swift" && swiftApplicationEntry(file, source)
20176
20321
  );
20177
20322
  const wrapped = procedural.length === 1 ? wrapUIApplicationMainEntry(procedural[0][1]) : null;
20178
20323
  if (wrapped) {
@@ -20193,22 +20338,22 @@ module ${moduleName}.Swift {
20193
20338
  `mixed executable ${target.name} requires one typed Swift application entry`
20194
20339
  );
20195
20340
  const [file, source] = nativeMains[0];
20196
- const original = path32.join(layout2.root, file);
20341
+ const original = path33.join(layout2.root, file);
20197
20342
  const entry = neutralizedNativeMain(source);
20198
20343
  files.set(original, entry);
20199
20344
  const implementation = executableNativeUnits.get(file);
20200
20345
  if (implementation) {
20201
20346
  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),
20347
+ const extension = path33.posix.extname(unit);
20348
+ const staged = path33.posix.basename(unit, extension) === "main" ? path33.posix.join(
20349
+ path33.posix.dirname(unit),
20205
20350
  `PeachApplicationEntry.generated${extension}`
20206
20351
  ) : unit;
20207
- const directory = path32.join(layout2.root, implementation.path);
20208
- const destination = path32.join(directory, staged);
20352
+ const directory = path33.join(layout2.root, implementation.path);
20353
+ const destination = path33.join(directory, staged);
20209
20354
  if (staged !== unit && files.has(destination))
20210
20355
  throw new Error(`mixed application entry conflicts with ${destination}`);
20211
- files.delete(path32.join(directory, unit));
20356
+ files.delete(path33.join(directory, unit));
20212
20357
  files.set(destination, `#line 1 ${JSON.stringify(original)}
20213
20358
  ${entry}`);
20214
20359
  implementation.sources[implementation.index] = staged;
@@ -20222,9 +20367,9 @@ ${entry}`);
20222
20367
  }
20223
20368
  if (!nativeEntry) {
20224
20369
  compiled.set(entryFile, entrySource);
20225
- if (path32.basename(entryFile) === "main.swift") {
20226
- const libraryEntry = path32.posix.join(
20227
- path32.posix.dirname(entryFile),
20370
+ if (path33.basename(entryFile) === "main.swift") {
20371
+ const libraryEntry = path33.posix.join(
20372
+ path33.posix.dirname(entryFile),
20228
20373
  "PeachApplicationEntry.generated.swift"
20229
20374
  );
20230
20375
  if (Object.hasOwn(input.files, libraryEntry))
@@ -20248,7 +20393,7 @@ ${entry}`);
20248
20393
  exclude: []
20249
20394
  });
20250
20395
  files.set(
20251
- path32.join(layout2.root, `PeachApplication/${name}/Entry.swift`),
20396
+ path33.join(layout2.root, `PeachApplication/${name}/Entry.swift`),
20252
20397
  !nativeEntry ? `import ${swiftTargetModuleName(target.name)}
20253
20398
  @main struct __PeachApplicationEntry { @MainActor static func main() { __peachRunApplication() } }
20254
20399
  ` : `import ${swiftTargetModuleName(target.name)}
@@ -20280,7 +20425,7 @@ ${entry}`);
20280
20425
  );
20281
20426
  if (nativeFlags) {
20282
20427
  const toolchainBin = nativeToolchain();
20283
- const headers = path32.join(swiftSdkPaths(moduleRoot, toolchainBin).sysroot, "darwin");
20428
+ const headers = path33.join(swiftSdkPaths(moduleRoot, toolchainBin).sysroot, "darwin");
20284
20429
  const dependencies2 = swiftTargetDependencies(input.files, targets);
20285
20430
  const reachesNative = (name, seen = /* @__PURE__ */ new Set()) => {
20286
20431
  if (native.has(name)) return true;
@@ -20326,10 +20471,10 @@ ${entry}`);
20326
20471
  if (targets.length === 0 && !prebuilt) {
20327
20472
  for (const [file, contents2] of Object.entries(input.files)) {
20328
20473
  if (file === "Package.swift") continue;
20329
- files.set(path32.join(layout2.sources, file), compiled.get(file) ?? contents2);
20474
+ files.set(path33.join(layout2.sources, file), compiled.get(file) ?? contents2);
20330
20475
  }
20331
20476
  let manifest2 = readFileSync16(
20332
- path32.join(moduleRoot, "scripts/contrast-app-Package.swift"),
20477
+ path33.join(moduleRoot, "scripts/contrast-app-Package.swift"),
20333
20478
  "utf8"
20334
20479
  ).replaceAll("__SOOTSIM_SWIFT_PACKAGE__", moduleRoot);
20335
20480
  const reactor = ` ${REACTOR_FLAG}`;
@@ -20376,16 +20521,16 @@ ${entry}`);
20376
20521
  [anchor, ...games.map((name) => `${gameProduct(name)},`)].join("\n ")
20377
20522
  );
20378
20523
  }
20379
- files.set(path32.join(layout2.root, "Package.swift"), manifest2 + moduleFiles);
20524
+ files.set(path33.join(layout2.root, "Package.swift"), manifest2 + moduleFiles);
20380
20525
  } else {
20381
20526
  const base = layout2.multi ? layout2.root : layout2.sources;
20382
20527
  const libraries = /* @__PURE__ */ new Map();
20383
- const binaryModules = path32.join(layout2.root, ".peach-binary-modules");
20528
+ const binaryModules = path33.join(layout2.root, ".peach-binary-modules");
20384
20529
  for (const [name, data] of Object.entries(input.binaryModules ?? {})) {
20385
20530
  if (!/^[A-Za-z_]\w*$/.test(name) || !input.libraries?.[name])
20386
20531
  throw new Error(`invalid native Swift module ${name}: its library is required`);
20387
20532
  files.set(
20388
- path32.join(binaryModules, `${name}.swiftmodule`),
20533
+ path33.join(binaryModules, `${name}.swiftmodule`),
20389
20534
  Buffer.from(data, "base64")
20390
20535
  );
20391
20536
  }
@@ -20396,7 +20541,7 @@ ${entry}`);
20396
20541
  const bytes = Buffer.from(data, "base64");
20397
20542
  const digest = createHash18("sha256").update(bytes).digest("hex");
20398
20543
  if (input.binaryModules?.[target] && packageTargets.has(target)) {
20399
- const objects = path32.join(
20544
+ const objects = path33.join(
20400
20545
  layout2.root,
20401
20546
  NATIVE_ARCHIVE_OBJECTS_DIR,
20402
20547
  `${target}.build`
@@ -20407,13 +20552,13 @@ ${entry}`);
20407
20552
  libraries.set(
20408
20553
  target,
20409
20554
  members.map(({ name, bytes: bytes2 }, index) => {
20410
- const file = path32.join(objects, `${index}-${digest}-${path32.basename(name)}`);
20555
+ const file = path33.join(objects, `${index}-${digest}-${path33.basename(name)}`);
20411
20556
  files.set(file, Buffer.from(bytes2));
20412
20557
  return file;
20413
20558
  })
20414
20559
  );
20415
20560
  } else {
20416
- const file = path32.join(
20561
+ const file = path33.join(
20417
20562
  layout2.root,
20418
20563
  ".peach-libraries",
20419
20564
  `lib${target}-${digest}.a`
@@ -20424,13 +20569,13 @@ ${entry}`);
20424
20569
  }
20425
20570
  for (const [file, contents2] of Object.entries(input.files)) {
20426
20571
  if (file === "Package.swift") continue;
20427
- const destination = path32.join(base, libraryEntryFiles.get(file) ?? file);
20572
+ const destination = path33.join(base, libraryEntryFiles.get(file) ?? file);
20428
20573
  const interfaceModule = /(?:^|\/)(\w+)-Swift\.h$/.exec(file)?.[1];
20429
20574
  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("/")
20575
+ path33.relative(
20576
+ path33.dirname(destination),
20577
+ path33.join(headerDirectory, `${interfaceModule}-Swift.h`)
20578
+ ).split(path33.sep).join("/")
20434
20579
  )}
20435
20580
  ` : void 0;
20436
20581
  files.set(
@@ -20441,7 +20586,7 @@ ${entry}`);
20441
20586
  const manifestTargets2 = targets.length > 0 ? targets : [
20442
20587
  {
20443
20588
  name: "App",
20444
- path: path32.relative(layout2.root, layout2.sources).split(path32.sep).join("/"),
20589
+ path: path33.relative(layout2.root, layout2.sources).split(path33.sep).join("/"),
20445
20590
  executable: true,
20446
20591
  languageMode: 5,
20447
20592
  mainActorIsolation: false,
@@ -20451,11 +20596,11 @@ ${entry}`);
20451
20596
  const reachesFrameworks = !distribution || swiftImportedModules.has("Foundation") || Object.entries(input.files).some(
20452
20597
  ([file, source]) => file.endsWith(".swift") && file !== input.entry && file !== "Package.swift" || /\.mm?$/.test(file) || source.includes("dispatch_")
20453
20598
  ) || [...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)
20599
+ (name) => distribution.modules.includes(name) && !targets.some((target) => target.name === name) && !(clangImportedModules.has(name) && !swiftImportedModules.has(name) && existsSync10(
20600
+ path33.join(swiftSharedSdkRoot(moduleRoot, true), "usr/include", name)
20456
20601
  ))
20457
20602
  );
20458
- const frameworkLink = prebuilt ? path32.join(layout2.root, ".peach-framework-objects.rsp") : void 0;
20603
+ const frameworkLink = prebuilt ? path33.join(layout2.root, ".peach-framework-objects.rsp") : void 0;
20459
20604
  if (prebuilt && frameworkLink) {
20460
20605
  const quote2 = (object2) => `"${object2.replaceAll("\\", "\\\\").replaceAll('"', '\\"')}"`;
20461
20606
  files.set(
@@ -20482,15 +20627,15 @@ ${entry}`);
20482
20627
  }
20483
20628
  }
20484
20629
  files.set(
20485
- path32.join(layout2.root, "Package.swift"),
20630
+ path33.join(layout2.root, "Package.swift"),
20486
20631
  emitSwiftPackageManifest({
20487
20632
  root: layout2.root,
20488
20633
  files,
20489
20634
  targets: manifestTargets2.map((target) => ({
20490
20635
  ...target,
20491
20636
  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;
20637
+ const entry = libraryEntryFiles.get(path33.posix.join(target.path, source));
20638
+ return entry ? path33.posix.relative(target.path, entry) : source;
20494
20639
  })
20495
20640
  })),
20496
20641
  packages,
@@ -20524,7 +20669,7 @@ ${entry}`);
20524
20669
  ),
20525
20670
  ...reachesFrameworks ? {
20526
20671
  distributionLink: {
20527
- path: path32.join(layout2.root, ".peach-distribution-objects.rsp"),
20672
+ path: path33.join(layout2.root, ".peach-distribution-objects.rsp"),
20528
20673
  files
20529
20674
  }
20530
20675
  } : {},
@@ -20545,14 +20690,14 @@ ${entry}`);
20545
20690
  for (const [file, bytes] of Object.entries(input.packageFiles ?? {})) {
20546
20691
  const contents2 = Buffer.from(bytes, "base64");
20547
20692
  files.set(
20548
- path32.join(layout2.root, file),
20693
+ path33.join(layout2.root, file),
20549
20694
  file.endsWith(".swift") && !/(?:^|\/)Package(?:@swift-[\d.]+)?\.swift$/.test(file) ? withFrameworkCompanionImports(
20550
20695
  swiftPackageSourceAsIOS(contents2.toString("utf8"))
20551
20696
  ) : contents2
20552
20697
  );
20553
20698
  }
20554
20699
  for (const [file, bytes] of Object.entries(input.projectFiles ?? {})) {
20555
- const destination = path32.join(layout2.root, file);
20700
+ const destination = path33.join(layout2.root, file);
20556
20701
  if (files.has(destination)) continue;
20557
20702
  files.set(destination, Buffer.from(bytes, "base64"));
20558
20703
  }
@@ -20561,14 +20706,14 @@ ${entry}`);
20561
20706
  const nativeToolsetFlags = [
20562
20707
  ...headerAliasFlags,
20563
20708
  ...native.size > 0 ? [
20564
- "-fmodule-map-file=" + path32.join(
20709
+ "-fmodule-map-file=" + path33.join(
20565
20710
  swiftSdkPaths(moduleRoot, nativeToolchain()).sysroot,
20566
20711
  "darwin/wasm/include/module.modulemap"
20567
20712
  )
20568
20713
  ] : []
20569
20714
  ];
20570
- const clangWrapper2 = path32.join(layout2.root, CLANG_TARGET_MODULE_WRAPPER);
20571
- const clang = path32.join(nativeToolchain(), "clang");
20715
+ const clangWrapper2 = path33.join(layout2.root, CLANG_TARGET_MODULE_WRAPPER);
20716
+ const clang = path33.join(nativeToolchain(), "clang");
20572
20717
  const prebuiltCompiler = distribution && objcPrebuiltStage !== false ? swiftObjCPrebuiltCompiler(
20573
20718
  clang,
20574
20719
  layout2.root,
@@ -20652,14 +20797,14 @@ ${entry}`);
20652
20797
  ].join("\n")
20653
20798
  );
20654
20799
  files.set(
20655
- path32.join(layout2.root, ".peach-target-toolset.json"),
20800
+ path33.join(layout2.root, ".peach-target-toolset.json"),
20656
20801
  JSON.stringify({
20657
20802
  schemaVersion: "1.0",
20658
20803
  cCompiler: {
20659
20804
  extraCLIOptions: [
20660
20805
  ...nativeToolsetFlags,
20661
20806
  "-fmodules",
20662
- `-fmodules-cache-path=${path32.join(layout2.root, ".build", "ModuleCache")}`
20807
+ `-fmodules-cache-path=${path33.join(layout2.root, ".build", "ModuleCache")}`
20663
20808
  ]
20664
20809
  },
20665
20810
  ...nativeToolsetFlags.length > 0 ? { cxxCompiler: { extraCLIOptions: nativeToolsetFlags } } : {},
@@ -20667,7 +20812,7 @@ ${entry}`);
20667
20812
  extraCLIOptions: [
20668
20813
  ...headerAliasFlags.flatMap((flag) => ["-Xcc", flag]),
20669
20814
  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"),
20815
+ distributionModules ? providedModulesPath(layout2.root, distributionModules, moduleExcludes) : prebuilt ? providedModulesPath(layout2.root, prebuilt.modules, moduleExcludes) : path33.join(layout2.root, ".build", WASM_TRIPLE, "release", "Modules"),
20671
20816
  ...distributionModules ? distributionClangModuleOptions(layout2.root, distributionModules) : [],
20672
20817
  ...prebuilt?.moduleMaps.flatMap((map) => [
20673
20818
  "-Xcc",
@@ -20691,9 +20836,9 @@ ${entry}`);
20691
20836
  throw new Error(
20692
20837
  `swift resource target ${target.name} has no matching bundle assignment`
20693
20838
  );
20694
- const directory = layout2.multi ? path32.join(layout2.root, target.path) : layout2.sources;
20839
+ const directory = layout2.multi ? path33.join(layout2.root, target.path) : layout2.sources;
20695
20840
  files.set(
20696
- path32.join(directory, "ResourceBundleAccessor.generated.swift"),
20841
+ path33.join(directory, "ResourceBundleAccessor.generated.swift"),
20697
20842
  [
20698
20843
  "import Foundation",
20699
20844
  "",
@@ -20710,7 +20855,7 @@ ${entry}`);
20710
20855
  }
20711
20856
  for (const [file, source] of compiled)
20712
20857
  if (!Object.hasOwn(input.files, file))
20713
- files.set(path32.join(layout2.multi ? layout2.root : layout2.sources, file), source);
20858
+ files.set(path33.join(layout2.multi ? layout2.root : layout2.sources, file), source);
20714
20859
  const producers = [
20715
20860
  .../* @__PURE__ */ new Set([...[...native.values()].flatMap((value) => value.late?.producers ?? [])])
20716
20861
  ];
@@ -20723,7 +20868,7 @@ ${entry}`);
20723
20868
  generatedOwners.set(group.name, owner);
20724
20869
  }
20725
20870
  }
20726
- const manifestPath = path32.join(layout2.root, "Package.swift");
20871
+ const manifestPath = path33.join(layout2.root, "Package.swift");
20727
20872
  let manifest = files.get(manifestPath).toString();
20728
20873
  const manifestTargets = swiftManifestTargets(manifest, [], (file) => {
20729
20874
  const contents2 = files.get(file);
@@ -20823,7 +20968,7 @@ package.targets.first(where: { $0.name == ${JSON.stringify(target)} })!.dependen
20823
20968
  if (members.length === 1) return members[0];
20824
20969
  if (dependencies.has(name))
20825
20970
  throw new Error(`generated build target collides with ${name}`);
20826
- files.set(path32.join(layout2.root, name, "Products.swift"), "");
20971
+ files.set(path33.join(layout2.root, name, "Products.swift"), "");
20827
20972
  manifest += `
20828
20973
  package.targets += [.target(name: ${JSON.stringify(name)}, dependencies: ${JSON.stringify(members)}, path: ${JSON.stringify(name)}, swiftSettings: [.swiftLanguageMode(.v5)])]
20829
20974
  `;
@@ -20933,8 +21078,8 @@ package.targets += [.target(name: ${JSON.stringify(name)}, dependencies: ${JSON.
20933
21078
  syncSwiftTree(layout2.root, files);
20934
21079
  if (layout2.multi)
20935
21080
  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);
21081
+ mkdirSync8(path33.join(layout2.root, target.path), { recursive: true });
21082
+ const clangWrapper = path33.join(layout2.root, CLANG_TARGET_MODULE_WRAPPER);
20938
21083
  if (files.has(clangWrapper) && (statSync4(clangWrapper).mode & 4095) !== 493)
20939
21084
  chmodSync3(clangWrapper, 493);
20940
21085
  return {
@@ -20965,8 +21110,8 @@ function outputOf(error) {
20965
21110
  return error instanceof Error ? error.message : String(error);
20966
21111
  }
20967
21112
  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");
21113
+ const binDir = path33.join(layout2.root, ".build", WASM_TRIPLE, "release");
21114
+ const manifest = readFileSync16(path33.join(layout2.root, "Package.swift"), "utf8");
20970
21115
  const executable = swiftManifestTargets(
20971
21116
  manifest,
20972
21117
  [],
@@ -20975,11 +21120,11 @@ function builtArtifact(layout2) {
20975
21120
  if (executable === void 0) {
20976
21121
  throw new Error("swift-compile: the written manifest names no executable target");
20977
21122
  }
20978
- return path32.join(binDir, `${executable.name}.wasm`);
21123
+ return path33.join(binDir, `${executable.name}.wasm`);
20979
21124
  }
20980
21125
  function projectDiagnostic(output, layout2, files) {
20981
21126
  const base = layout2.multi ? layout2.root : layout2.sources;
20982
- const prefix = `${base}${path32.sep}`;
21127
+ const prefix = `${base}${path33.sep}`;
20983
21128
  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
21129
  }
20985
21130
  var ROOT_LOCKS = Symbol.for("peachsim.swiftCompile.rootLocks");
@@ -21015,12 +21160,12 @@ function serialize(root, work, signal) {
21015
21160
  function readCompiledArtifact(directory, hash) {
21016
21161
  try {
21017
21162
  const receipt = JSON.parse(
21018
- readFileSync16(path32.join(directory, "artifact.json"), "utf8")
21163
+ readFileSync16(path33.join(directory, "artifact.json"), "utf8")
21019
21164
  );
21020
21165
  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
21166
  return null;
21022
- const bytes = readFileSync16(path32.join(directory, "app.wasm"));
21023
- const gzip2 = readFileSync16(path32.join(directory, "icu.gz"));
21167
+ const bytes = readFileSync16(path33.join(directory, "app.wasm"));
21168
+ const gzip2 = readFileSync16(path33.join(directory, "icu.gz"));
21024
21169
  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
21170
  return null;
21026
21171
  let sdk;
@@ -21028,7 +21173,7 @@ function readCompiledArtifact(directory, hash) {
21028
21173
  const image = receipt.sdk;
21029
21174
  if (!isRecord(image) || typeof image.key !== "string" || typeof image.sha256 !== "string" || typeof image.binding !== "string")
21030
21175
  return null;
21031
- const binding = readFileSync16(path32.join(directory, "sdk-binding.bin"));
21176
+ const binding = readFileSync16(path33.join(directory, "sdk-binding.bin"));
21032
21177
  if (createHash18("sha256").update(binding).digest("hex") !== image.binding)
21033
21178
  return null;
21034
21179
  sdk = {
@@ -21045,16 +21190,16 @@ function readCompiledArtifact(directory, hash) {
21045
21190
  }
21046
21191
  }
21047
21192
  function saveCompiledArtifact(root, artifact) {
21048
- const directory = path32.join(root, "artifact");
21193
+ const directory = path33.join(root, "artifact");
21049
21194
  mkdirSync8(directory, { recursive: true });
21050
- const pending = mkdtempSync4(path32.join(root, ".artifact-"));
21195
+ const pending = mkdtempSync4(path33.join(root, ".artifact-"));
21051
21196
  try {
21052
- writeFileSync8(path32.join(pending, "app.wasm"), artifact.bytes);
21053
- writeFileSync8(path32.join(pending, "icu.gz"), artifact.icu.gzip);
21197
+ writeFileSync8(path33.join(pending, "app.wasm"), artifact.bytes);
21198
+ writeFileSync8(path33.join(pending, "icu.gz"), artifact.icu.gzip);
21054
21199
  if (artifact.sdk)
21055
- writeFileSync8(path32.join(pending, "sdk-binding.bin"), artifact.sdk.binding.bytes);
21200
+ writeFileSync8(path33.join(pending, "sdk-binding.bin"), artifact.sdk.binding.bytes);
21056
21201
  writeFileSync8(
21057
- path32.join(pending, "artifact.json"),
21202
+ path33.join(pending, "artifact.json"),
21058
21203
  JSON.stringify({
21059
21204
  hash: artifact.hash,
21060
21205
  wasm: createHash18("sha256").update(artifact.bytes).digest("hex"),
@@ -21069,7 +21214,7 @@ function saveCompiledArtifact(root, artifact) {
21069
21214
  const outputs = ["app.wasm", "icu.gz"];
21070
21215
  if (artifact.sdk) outputs.push("sdk-binding.bin");
21071
21216
  for (const file of [...outputs, "artifact.json"]) {
21072
- renameSync6(path32.join(pending, file), path32.join(directory, file));
21217
+ renameSync6(path33.join(pending, file), path33.join(directory, file));
21073
21218
  }
21074
21219
  } finally {
21075
21220
  rmSync7(pending, { recursive: true, force: true });
@@ -21091,19 +21236,19 @@ function renewSharedArtifact(sharedRoot) {
21091
21236
  function pruneSharedArtifacts(parent, keep) {
21092
21237
  const entries2 = [];
21093
21238
  for (const name of readdirSync6(parent)) {
21094
- const directory = path32.join(parent, name);
21239
+ const directory = path33.join(parent, name);
21095
21240
  if (name.startsWith(RETIRED_PREFIX)) {
21096
21241
  reapRetiredCacheDirectory(parent, name);
21097
21242
  continue;
21098
21243
  }
21099
21244
  try {
21100
21245
  let bytes = 0;
21101
- for (const file of readdirSync6(path32.join(directory, "artifact"), {
21246
+ for (const file of readdirSync6(path33.join(directory, "artifact"), {
21102
21247
  recursive: true,
21103
21248
  encoding: "utf8"
21104
21249
  })) {
21105
21250
  try {
21106
- bytes += statSync4(path32.join(directory, "artifact", file)).size;
21251
+ bytes += statSync4(path33.join(directory, "artifact", file)).size;
21107
21252
  } catch (error) {
21108
21253
  if (!vanished(error)) throw error;
21109
21254
  }
@@ -21118,9 +21263,9 @@ function pruneSharedArtifacts(parent, keep) {
21118
21263
  if (total <= SHARED_ARTIFACT_BUDGET_BYTES) break;
21119
21264
  if (entry.directory === keep || Date.now() - entry.used < SHARED_ARTIFACT_GRACE_MS)
21120
21265
  continue;
21121
- const retired = path32.join(
21266
+ const retired = path33.join(
21122
21267
  parent,
21123
- `${RETIRED_PREFIX}${process.pid}-${path32.basename(entry.directory)}`
21268
+ `${RETIRED_PREFIX}${process.pid}-${path33.basename(entry.directory)}`
21124
21269
  );
21125
21270
  try {
21126
21271
  if (statSync4(entry.directory).mtimeMs !== entry.used) continue;
@@ -21136,7 +21281,7 @@ function pruneSharedArtifacts(parent, keep) {
21136
21281
  function saveSharedArtifact(sharedRoot, artifact) {
21137
21282
  saveCompiledArtifact(sharedRoot, artifact);
21138
21283
  renewSharedArtifact(sharedRoot);
21139
- pruneSharedArtifacts(path32.dirname(sharedRoot), sharedRoot);
21284
+ pruneSharedArtifacts(path33.dirname(sharedRoot), sharedRoot);
21140
21285
  }
21141
21286
  var retainedArtifacts = /* @__PURE__ */ new Map();
21142
21287
  function retain(root, artifact) {
@@ -21164,7 +21309,7 @@ function frameworkLibraryTargets(manifest) {
21164
21309
  }
21165
21310
  function linkedFrameworkTargets(moduleRoot, input) {
21166
21311
  const libraries = frameworkLibraryTargets(
21167
- readFileSync16(path32.join(moduleRoot, "Package.swift"), "utf8")
21312
+ readFileSync16(path33.join(moduleRoot, "Package.swift"), "utf8")
21168
21313
  );
21169
21314
  const targets = compileTargets(input);
21170
21315
  const planning = targets.length > 0 ? targets : [{ name: "App", path: "." }];
@@ -21190,7 +21335,7 @@ function linkedFrameworkTargets(moduleRoot, input) {
21190
21335
  imports.add(name);
21191
21336
  reach(name);
21192
21337
  }
21193
- const manifest = readFileSync16(path32.join(moduleRoot, "Package.swift"), "utf8");
21338
+ const manifest = readFileSync16(path33.join(moduleRoot, "Package.swift"), "utf8");
21194
21339
  const targetDependencies = /* @__PURE__ */ new Map();
21195
21340
  for (const match of manifest.matchAll(
21196
21341
  /\.target\(\s*name:\s*"([^"]+)"\s*,\s*dependencies:\s*\[([^\]]*)\]/g
@@ -21207,11 +21352,11 @@ function linkedFrameworkTargets(moduleRoot, input) {
21207
21352
  };
21208
21353
  for (const name of reached)
21209
21354
  for (const member of libraries.get(name) ?? []) build(member);
21210
- const overlays = path32.join(moduleRoot, "cross-import-overlays");
21355
+ const overlays = path33.join(moduleRoot, "cross-import-overlays");
21211
21356
  for (const directory of readdirSync6(overlays)) {
21212
- const companion = path32.basename(directory, ".swiftcrossimport");
21357
+ const companion = path33.basename(directory, ".swiftcrossimport");
21213
21358
  if (!built.has(companion)) continue;
21214
- const declaration = path32.join(overlays, directory, "SwiftUI.swiftoverlay");
21359
+ const declaration = path33.join(overlays, directory, "SwiftUI.swiftoverlay");
21215
21360
  for (const match of readFileSync16(declaration, "utf8").matchAll(
21216
21361
  /^\s*- name: ([A-Za-z_]\w*)\s*$/gm
21217
21362
  ))
@@ -21238,7 +21383,7 @@ function linkedFrameworkTargets(moduleRoot, input) {
21238
21383
  return { products: linked, targets: linkedMembers, imports: [...imports].sort() };
21239
21384
  }
21240
21385
  function writeFrameworkLinkPackage(linkRoot, moduleRoot, products) {
21241
- const identity = path32.basename(moduleRoot).toLowerCase();
21386
+ const identity = path33.basename(moduleRoot).toLowerCase();
21242
21387
  const swiftString = (value) => `"${value.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
21243
21388
  const dependencies = products.map(
21244
21389
  (name) => ` .product(name: ${swiftString(name)}, package: ${swiftString(identity)}),`
@@ -21260,13 +21405,13 @@ ${dependencies}
21260
21405
  ]
21261
21406
  )
21262
21407
  `;
21263
- const sourceDir = path32.join(linkRoot, "Sources", FRAMEWORK_LINK_TARGET);
21408
+ const sourceDir = path33.join(linkRoot, "Sources", FRAMEWORK_LINK_TARGET);
21264
21409
  mkdirSync8(sourceDir, { recursive: true });
21265
- const manifestPath = path32.join(linkRoot, "Package.swift");
21266
- if (!existsSync9(manifestPath) || readFileSync16(manifestPath, "utf8") !== manifest)
21410
+ const manifestPath = path33.join(linkRoot, "Package.swift");
21411
+ if (!existsSync10(manifestPath) || readFileSync16(manifestPath, "utf8") !== manifest)
21267
21412
  writeFileSync8(manifestPath, manifest);
21268
- const source = path32.join(sourceDir, "Link.swift");
21269
- if (!existsSync9(source)) writeFileSync8(source, "");
21413
+ const source = path33.join(sourceDir, "Link.swift");
21414
+ if (!existsSync10(source)) writeFileSync8(source, "");
21270
21415
  }
21271
21416
  function frameworkLinkClosure(scratch, roots) {
21272
21417
  const suffix = `${WASM_TRIPLE}-release`;
@@ -21278,7 +21423,7 @@ function frameworkLinkClosure(scratch, roots) {
21278
21423
  const objcHeaders = /* @__PURE__ */ new Map();
21279
21424
  let pending = null;
21280
21425
  let compiling = null;
21281
- for (const line of readFileSync16(path32.join(scratch, "release.yaml"), "utf8").split(
21426
+ for (const line of readFileSync16(path33.join(scratch, "release.yaml"), "utf8").split(
21282
21427
  "\n"
21283
21428
  )) {
21284
21429
  const phony = phonyHeader.exec(line);
@@ -21346,7 +21491,7 @@ function frameworkLinkClosure(scratch, roots) {
21346
21491
  owners.set(file, name);
21347
21492
  if (seen.has(file)) continue;
21348
21493
  seen.add(file);
21349
- if (!existsSync9(file))
21494
+ if (!existsSync10(file))
21350
21495
  throw new Error(`swift-compile: framework object ${file} was not built`);
21351
21496
  files.push(file);
21352
21497
  }
@@ -21362,22 +21507,94 @@ function frameworkLinkClosure(scratch, roots) {
21362
21507
  };
21363
21508
  }
21364
21509
  function removeCaseCollidingModuleArtifacts(modulesDir, keep) {
21365
- if (!existsSync9(modulesDir)) return;
21510
+ if (!existsSync10(modulesDir)) return;
21366
21511
  const folded = new Set([...keep].map((name) => name.toLowerCase()));
21367
21512
  for (const name of readdirSync6(modulesDir)) {
21368
21513
  const dot = name.indexOf(".");
21369
21514
  if (dot <= 0) continue;
21370
21515
  const module = name.slice(0, dot);
21371
21516
  if (keep.has(module) || !folded.has(module.toLowerCase())) continue;
21372
- rmSync7(path32.join(modulesDir, name), { recursive: true, force: true });
21517
+ rmSync7(path33.join(modulesDir, name), { recursive: true, force: true });
21518
+ }
21519
+ }
21520
+ var frameworkProductsReceiptSchema = object({
21521
+ modules: string(),
21522
+ objects: array(string()),
21523
+ lazyObjects: array(string()),
21524
+ owners: array(tuple([string(), string()])),
21525
+ providers: array(string()),
21526
+ link: array(string()),
21527
+ moduleMaps: array(string()),
21528
+ objcHeaders: array(tuple([string(), string()])),
21529
+ archived: array(tuple([string(), string()]))
21530
+ });
21531
+ function readFrameworkProductsReceipt(scratch, receiptKey) {
21532
+ const receiptFile = path33.join(scratch, "products-ready", `${receiptKey}.json`);
21533
+ if (!existsSync10(receiptFile)) return null;
21534
+ let parsed;
21535
+ try {
21536
+ parsed = parse(
21537
+ frameworkProductsReceiptSchema,
21538
+ JSON.parse(readFileSync16(receiptFile, "utf8"))
21539
+ );
21540
+ } catch {
21541
+ return null;
21373
21542
  }
21543
+ const archive = path33.join(scratch, "lib");
21544
+ const archiveStamp = path33.join(archive, ".receipt");
21545
+ const archiveMatches = existsSync10(archiveStamp) && readFileSync16(archiveStamp, "utf8") === receiptKey;
21546
+ if (!existsSync10(parsed.modules)) return null;
21547
+ for (const [object2] of parsed.archived) if (!existsSync10(object2)) return null;
21548
+ for (const file of parsed.providers) if (!existsSync10(file)) return null;
21549
+ for (const file of parsed.moduleMaps) if (!existsSync10(file)) return null;
21550
+ if (!archiveMatches) {
21551
+ rmSync7(archive, { recursive: true, force: true });
21552
+ mkdirSync8(archive, { recursive: true });
21553
+ for (const [object2, rel] of parsed.archived)
21554
+ symlinkSync2(object2, path33.join(scratch, rel));
21555
+ writeFileSync8(archiveStamp, receiptKey);
21556
+ }
21557
+ for (const file of parsed.objects) if (!existsSync10(file)) return null;
21558
+ for (const file of parsed.lazyObjects) if (!existsSync10(file)) return null;
21559
+ return {
21560
+ root: scratch,
21561
+ modules: parsed.modules,
21562
+ objects: parsed.objects,
21563
+ lazyObjects: parsed.lazyObjects,
21564
+ owners: new Map(parsed.owners),
21565
+ providers: parsed.providers,
21566
+ link: parsed.link,
21567
+ moduleMaps: parsed.moduleMaps,
21568
+ objcHeaders: new Map(parsed.objcHeaders)
21569
+ };
21374
21570
  }
21375
21571
  async function buildFrameworkProducts(scratch, args) {
21376
21572
  const linkedTargets = linkedFrameworkTargets(args.moduleRoot, args.input);
21377
- const linkRoot = path32.join(scratch, "link");
21573
+ const unoptimized = args.input.unoptimized === true;
21574
+ const sdkOptions = swiftCompileSdkOptions(args.moduleRoot, args.toolchainBin);
21575
+ const selectorOptions = swiftObjCSelectorOptions(args.moduleRoot);
21576
+ const receiptKey = createHash18("sha256").update(
21577
+ JSON.stringify([
21578
+ "framework-products/v1",
21579
+ args.frameworkKey,
21580
+ unoptimized,
21581
+ args.sdk,
21582
+ args.toolchainBin,
21583
+ [...linkedTargets.products].sort(),
21584
+ darwinRecordsMinimum(),
21585
+ args.plugins,
21586
+ sdkOptions,
21587
+ selectorOptions
21588
+ ])
21589
+ ).digest("hex").slice(0, 32);
21590
+ const ready = readFrameworkProductsReceipt(scratch, receiptKey);
21591
+ if (ready) return ready;
21592
+ await waitForNoSwiftRootReaders(scratch, args.buildOptions.signal);
21593
+ const linkRoot = path33.join(scratch, "link");
21378
21594
  writeFrameworkLinkPackage(linkRoot, args.moduleRoot, linkedTargets.products);
21595
+ const frameworkTmp = path33.join(scratch, "peach-compiler-tmp");
21596
+ mkdirSync8(frameworkTmp, { recursive: true });
21379
21597
  const jobs = swiftCompilerJobs();
21380
- const unoptimized = args.input.unoptimized === true;
21381
21598
  const targetJobs = unoptimized ? jobs >= 4 ? 2 : 1 : jobs;
21382
21599
  const driverJobs = unoptimized ? Math.max(1, Math.floor(jobs / targetJobs)) : jobs;
21383
21600
  await runCompiler(
@@ -21395,8 +21612,8 @@ async function buildFrameworkProducts(scratch, args) {
21395
21612
  scratch,
21396
21613
  "--target",
21397
21614
  FRAMEWORK_LINK_TARGET,
21398
- ...swiftCompileSdkOptions(args.moduleRoot, args.toolchainBin),
21399
- ...swiftObjCSelectorOptions(args.moduleRoot),
21615
+ ...sdkOptions,
21616
+ ...selectorOptions,
21400
21617
  "--swift-sdk",
21401
21618
  args.sdk,
21402
21619
  "-c",
@@ -21415,15 +21632,17 @@ async function buildFrameworkProducts(scratch, args) {
21415
21632
  "-Xswiftc",
21416
21633
  String(driverJobs)
21417
21634
  ] : ["-Xswiftc", "-Osize"],
21418
- // the release link strips all debug info, so none is generated
21635
+ // the release link strips all debug info, so none is generated. keep
21636
+ // -num-threads fixed across caller core caps so llbuild does not rebuild
21637
+ // every framework target when callers alternate --cores.
21419
21638
  "-Xswiftc",
21420
21639
  "-gnone",
21421
21640
  "-Xswiftc",
21422
21641
  "-num-threads",
21423
21642
  "-Xswiftc",
21424
- String(unoptimized ? 1 : jobs),
21643
+ String(unoptimized ? 1 : Math.min(4, os4.availableParallelism())),
21425
21644
  ...swiftReproducibleBuildFlags([
21426
- [path32.dirname(args.toolchainBin), "toolchain"],
21645
+ [path33.dirname(args.toolchainBin), "toolchain"],
21427
21646
  [args.moduleRoot, "framework"],
21428
21647
  [scratch, "framework-scratch"]
21429
21648
  ]),
@@ -21440,22 +21659,27 @@ async function buildFrameworkProducts(scratch, args) {
21440
21659
  `${plugin}#ExpoModulesMacros`
21441
21660
  ])
21442
21661
  ],
21662
+ // swiftpm hashes TMPDIR into its plan; keep one stable compiler scratch inside the locked slot.
21443
21663
  // the framework build's warnings alone pass the default 1 MiB cap, which kills
21444
21664
  // the build one step from the end.
21445
- { ...args.buildOptions, maxBuffer: 64 * 1024 * 1024 },
21665
+ {
21666
+ ...args.buildOptions,
21667
+ temporaryDirectory: frameworkTmp,
21668
+ maxBuffer: 64 * 1024 * 1024
21669
+ },
21446
21670
  SWIFTPM_PROGRESS,
21447
21671
  SWIFTPM_NOISE
21448
21672
  ).catch((error) => {
21449
21673
  throw new Error(outputOf(error), { cause: error });
21450
21674
  });
21451
- const release = path32.join(scratch, WASM_TRIPLE, "release");
21675
+ const release = path33.join(scratch, WASM_TRIPLE, "release");
21452
21676
  const linked = frameworkLinkClosure(scratch, linkedTargets.targets);
21453
21677
  const objects = linked.objects;
21454
21678
  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) {
21679
+ const constantsDir = path33.join(scratch, "uniform-type-constants");
21680
+ const constantsStamp = path33.join(constantsDir, ".complete");
21681
+ const object2 = path33.join(constantsDir, "UniformTypeIdentifiers-NativeConstants.o");
21682
+ if (!existsSync10(constantsStamp) || readFileSync16(constantsStamp, "utf8") !== args.frameworkKey) {
21459
21683
  rmSync7(constantsDir, { recursive: true, force: true });
21460
21684
  mkdirSync8(constantsDir);
21461
21685
  const sdkPaths2 = swiftSdkPaths(args.moduleRoot, args.toolchainBin);
@@ -21472,11 +21696,11 @@ async function buildFrameworkProducts(scratch, args) {
21472
21696
  objects.push(object2);
21473
21697
  linked.owners.set(object2, "UniformTypeIdentifiers");
21474
21698
  }
21475
- removeCaseCollidingModuleArtifacts(path32.join(release, "Modules"), linked.modules);
21476
- const response = path32.join(scratch, "autolink-objects.rsp");
21699
+ removeCaseCollidingModuleArtifacts(path33.join(release, "Modules"), linked.modules);
21700
+ const response = path33.join(scratch, "autolink-objects.rsp");
21477
21701
  writeFileSync8(response, objects.map((file) => JSON.stringify(file)).join("\n") + "\n");
21478
21702
  const extracted = await runCompiler(
21479
- path32.join(args.toolchainBin, "swift-autolink-extract"),
21703
+ path33.join(args.toolchainBin, "swift-autolink-extract"),
21480
21704
  [`@${response}`, "-o", "-"],
21481
21705
  args.buildOptions
21482
21706
  );
@@ -21484,16 +21708,16 @@ async function buildFrameworkProducts(scratch, args) {
21484
21708
  const link = extracted.split("\n").map((line) => line.trim()).filter((flag, index, all) => flag.length > 0 && all.indexOf(flag) === index);
21485
21709
  if (link.includes("-lFoundation"))
21486
21710
  for (const name of foundationCategoryObjects) {
21487
- const object2 = path32.join(
21711
+ const object2 = path33.join(
21488
21712
  swiftSdkPaths(args.moduleRoot, args.toolchainBin).resources,
21489
21713
  `wasi/${name}.objc.o`
21490
21714
  );
21491
21715
  objects.push(object2);
21492
21716
  linked.owners.set(object2, "Foundation");
21493
21717
  }
21494
- const providerDir = path32.join(scratch, "darwin-records");
21495
- const providerStamp = path32.join(providerDir, ".complete");
21496
- if (!existsSync9(providerStamp) || readFileSync16(providerStamp, "utf8") !== args.frameworkKey) {
21718
+ const providerDir = path33.join(scratch, "darwin-records");
21719
+ const providerStamp = path33.join(providerDir, ".complete");
21720
+ if (!existsSync10(providerStamp) || readFileSync16(providerStamp, "utf8") !== args.frameworkKey) {
21497
21721
  rmSync7(providerDir, { recursive: true, force: true });
21498
21722
  mkdirSync8(providerDir);
21499
21723
  const sdkPaths2 = swiftSdkPaths(args.moduleRoot, args.toolchainBin);
@@ -21507,18 +21731,18 @@ async function buildFrameworkProducts(scratch, args) {
21507
21731
  });
21508
21732
  writeFileSync8(providerStamp, args.frameworkKey);
21509
21733
  }
21510
- const providers = readdirSync6(providerDir).filter((file) => file.endsWith(".o")).sort().map((file) => path32.join(providerDir, file));
21734
+ const providers = readdirSync6(providerDir).filter((file) => file.endsWith(".o")).sort().map((file) => path33.join(providerDir, file));
21511
21735
  for (const provider of providers) linked.owners.set(provider, "DarwinRecords");
21512
- const archive = path32.join(scratch, "lib");
21736
+ const archive = path33.join(scratch, "lib");
21513
21737
  rmSync7(archive, { recursive: true, force: true });
21514
21738
  mkdirSync8(archive);
21515
21739
  const archived = /* @__PURE__ */ new Map();
21516
21740
  for (const object2 of objects) {
21517
21741
  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));
21742
+ const dir = path33.join(release, `${target}.build`);
21743
+ if (!target || target === "Darwin" || !object2.startsWith(dir + path33.sep)) continue;
21744
+ const name = `${target}-${path33.relative(dir, object2).replaceAll(path33.sep, "-").replace(/\.swift\.o$/, ".o")}`;
21745
+ symlinkSync2(object2, path33.join(archive, name));
21522
21746
  archived.set(object2, `lib/${name}`);
21523
21747
  }
21524
21748
  const roots = swiftObjcRootObjects(`${scratch}
@@ -21527,11 +21751,11 @@ ${args.frameworkKey}`, scratch, [
21527
21751
  ]);
21528
21752
  const linkedObjects = objects.map((object2) => {
21529
21753
  const name = archived.get(object2);
21530
- return name ? { path: path32.join(scratch, name), lazy: !roots.has(name) } : { path: object2, lazy: false };
21754
+ return name ? { path: path33.join(scratch, name), lazy: !roots.has(name) } : { path: object2, lazy: false };
21531
21755
  });
21532
- return {
21756
+ const result = {
21533
21757
  root: scratch,
21534
- modules: path32.join(release, "Modules"),
21758
+ modules: path33.join(release, "Modules"),
21535
21759
  objects: linkedObjects.filter((object2) => !object2.lazy).map((object2) => object2.path),
21536
21760
  lazyObjects: linkedObjects.filter((object2) => object2.lazy).map((object2) => object2.path),
21537
21761
  owners: linked.owners,
@@ -21540,6 +21764,27 @@ ${args.frameworkKey}`, scratch, [
21540
21764
  moduleMaps: linked.moduleMaps,
21541
21765
  objcHeaders: linked.objcHeaders
21542
21766
  };
21767
+ writeFileSync8(path33.join(archive, ".receipt"), receiptKey);
21768
+ const receiptsDir = path33.join(scratch, "products-ready");
21769
+ mkdirSync8(receiptsDir, { recursive: true });
21770
+ const receiptFile = path33.join(receiptsDir, `${receiptKey}.json`);
21771
+ const partialReceipt = `${receiptFile}.${process.pid}.${randomUUID5()}`;
21772
+ writeFileSync8(
21773
+ partialReceipt,
21774
+ JSON.stringify({
21775
+ modules: result.modules,
21776
+ objects: result.objects,
21777
+ lazyObjects: result.lazyObjects,
21778
+ owners: [...result.owners.entries()],
21779
+ providers: result.providers,
21780
+ link: result.link,
21781
+ moduleMaps: result.moduleMaps,
21782
+ objcHeaders: [...result.objcHeaders.entries()],
21783
+ archived: [...archived.entries()]
21784
+ })
21785
+ );
21786
+ renameSync6(partialReceipt, receiptFile);
21787
+ return result;
21543
21788
  }
21544
21789
  var SWIFT_LINK_STAMP = ".peach-link-stamp";
21545
21790
  var SWIFT_HOST_COMPILER_WRAPPER = ".peach-swiftc";
@@ -21548,14 +21793,14 @@ var SWIFT_FRAMEWORK_UNOPTIMIZED_SLOTS = 4;
21548
21793
  var SWIFT_FRAMEWORK_SLOT_KEY = ".peach-framework-key";
21549
21794
  var SWIFT_FRAMEWORK_SLOT_ORIGIN = ".peach-framework-origin";
21550
21795
  function swiftFrameworksDir(unoptimized = false) {
21551
- return path32.join(
21796
+ return path33.join(
21552
21797
  swiftCacheDir(),
21553
21798
  unoptimized ? "swift-frameworks-unoptimized" : "swift-frameworks"
21554
21799
  );
21555
21800
  }
21556
21801
  function swiftFrameworkSlotRecord(slot, record) {
21557
21802
  try {
21558
- return readFileSync16(path32.join(slot, record), "utf8").trim();
21803
+ return readFileSync16(path33.join(slot, record), "utf8").trim();
21559
21804
  } catch (error) {
21560
21805
  if (!vanished(error)) throw error;
21561
21806
  return null;
@@ -21568,7 +21813,7 @@ async function withSwiftFrameworkSlot(frameworkKey, moduleRoot, signal, work, un
21568
21813
  const slotCount = unoptimized ? SWIFT_FRAMEWORK_UNOPTIMIZED_SLOTS : SWIFT_FRAMEWORK_SLOTS;
21569
21814
  const slotsDir = swiftFrameworksDir(unoptimized);
21570
21815
  const slots = Array.from({ length: slotCount }, (_, index) => {
21571
- const slot = path32.join(slotsDir, `slot-${index}`);
21816
+ const slot = path33.join(slotsDir, `slot-${index}`);
21572
21817
  mkdirSync8(slot, { recursive: true });
21573
21818
  return slot;
21574
21819
  });
@@ -21584,16 +21829,18 @@ async function withSwiftFrameworkSlot(frameworkKey, moduleRoot, signal, work, un
21584
21829
  const inputs = new Map(
21585
21830
  swiftModuleInputFiles(moduleRoot).map((file) => [
21586
21831
  file,
21587
- readFileSync16(path32.join(moduleRoot, file))
21832
+ readFileSync16(path33.join(moduleRoot, file))
21588
21833
  ])
21589
21834
  );
21590
21835
  const ranked = slots.map((slot) => {
21591
21836
  let changes = 0;
21592
21837
  if (swiftFrameworkSlotKey(slot) === null) return { slot, changes: Infinity };
21593
- const source = path32.join(slot, "source", "packages", path32.basename(moduleRoot));
21838
+ const source = path33.join(slot, "source", "packages", path33.basename(moduleRoot));
21594
21839
  for (const [file, contents2] of inputs) {
21595
21840
  try {
21596
- if (!readFileSync16(path32.join(source, file)).equals(contents2)) changes++;
21841
+ const candidate = path33.join(source, file);
21842
+ if (statSync4(candidate).size !== contents2.length || !readFileSync16(candidate).equals(contents2))
21843
+ changes++;
21597
21844
  } catch (error) {
21598
21845
  if (!vanished(error)) throw error;
21599
21846
  changes++;
@@ -21604,11 +21851,13 @@ async function withSwiftFrameworkSlot(frameworkKey, moduleRoot, signal, work, un
21604
21851
  (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
21852
  );
21606
21853
  for (const { slot, changes } of ranked) {
21854
+ if (await hasLiveSwiftRootReaders(slot, signal)) continue;
21607
21855
  const result = await withSwiftRootLock(
21608
21856
  slot,
21609
21857
  async (lease) => {
21858
+ if (await hasLiveSwiftRootReaders(slot, signal)) return void 0;
21610
21859
  console.error(
21611
- `[swift-framework-cache] ${path32.basename(slot)} changedInputs=${changes} totalInputs=${inputs.size}`
21860
+ `[swift-framework-cache] ${path33.basename(slot)} changedInputs=${changes} totalInputs=${inputs.size}`
21612
21861
  );
21613
21862
  return { value: await run2(slot)(lease) };
21614
21863
  },
@@ -21627,8 +21876,8 @@ function mirrorTree2(source, target, skip) {
21627
21876
  for (const entry of readdirSync6(source, { withFileTypes: true })) {
21628
21877
  if (entry.name === skip) continue;
21629
21878
  wanted.add(entry.name);
21630
- const from = path32.join(source, entry.name);
21631
- const to = path32.join(target, entry.name);
21879
+ const from = path33.join(source, entry.name);
21880
+ const to = path33.join(target, entry.name);
21632
21881
  let existing = null;
21633
21882
  try {
21634
21883
  existing = lstatSync(to);
@@ -21657,47 +21906,49 @@ function mirrorTree2(source, target, skip) {
21657
21906
  }
21658
21907
  for (const name of readdirSync6(target))
21659
21908
  if (!wanted.has(name) && name !== skip) {
21660
- rmSync7(path32.join(target, name), { recursive: true, force: true });
21909
+ rmSync7(path33.join(target, name), { recursive: true, force: true });
21661
21910
  restructured = true;
21662
21911
  }
21663
21912
  return restructured;
21664
21913
  }
21665
21914
  function stageFrameworkSource(moduleRoot, slot, frameworkKey, release) {
21666
21915
  if (!slot) return moduleRoot;
21667
- const staged = path32.join(slot, "source");
21668
- const stagedModule = path32.join(staged, "packages", path32.basename(moduleRoot));
21916
+ const staged = path33.join(slot, "source");
21917
+ const stagedModule = path33.join(staged, "packages", path33.basename(moduleRoot));
21669
21918
  const hadKey = swiftFrameworkSlotKey(slot);
21670
21919
  if (hadKey !== frameworkKey) {
21671
- rmSync7(path32.join(slot, SWIFT_FRAMEWORK_SLOT_KEY), { force: true });
21920
+ rmSync7(path33.join(slot, SWIFT_FRAMEWORK_SLOT_KEY), { force: true });
21921
+ rmSync7(path33.join(slot, "products-ready"), { recursive: true, force: true });
21922
+ rmSync7(path33.join(slot, "lib", ".receipt"), { force: true });
21672
21923
  const moduleRestructured = mirrorTree2(moduleRoot, stagedModule, ".build");
21673
21924
  const sdkRestructured = mirrorTree2(
21674
21925
  swiftSharedSdkRoot(moduleRoot, false),
21675
- path32.join(staged, "packages/peachsim/sdk/ios")
21926
+ path33.join(staged, "packages/peachsim/sdk/ios")
21676
21927
  );
21677
21928
  if (moduleRestructured || sdkRestructured || hadKey === null) {
21678
- rmSync7(path32.join(slot, "release.yaml"), { force: true });
21679
- rmSync7(path32.join(slot, WASM_TRIPLE, "release", "description.json"), {
21929
+ rmSync7(path33.join(slot, "release.yaml"), { force: true });
21930
+ rmSync7(path33.join(slot, WASM_TRIPLE, "release", "description.json"), {
21680
21931
  force: true
21681
21932
  });
21682
21933
  }
21683
21934
  for (const file of swiftModuleInputFiles(moduleRoot)) {
21684
21935
  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 });
21936
+ const from = path33.resolve(moduleRoot, file);
21937
+ const to = path33.resolve(stagedModule, file);
21938
+ if (existsSync10(to) && readFileSync16(from).equals(readFileSync16(to))) continue;
21939
+ mkdirSync8(path33.dirname(to), { recursive: true });
21689
21940
  copyFileSync2(from, to);
21690
21941
  }
21691
21942
  if (swiftProjectBuildKey(stagedModule, release) !== frameworkKey)
21692
21943
  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) {
21944
+ const modules = path33.join(staged, "node_modules");
21945
+ const target = realpathSync6(path33.join(moduleRoot, "../../node_modules"));
21946
+ if (!existsSync10(modules) || readlinkSync(modules) !== target) {
21696
21947
  rmSync7(modules, { recursive: true, force: true });
21697
21948
  symlinkSync2(target, modules);
21698
21949
  }
21699
- writeFileSync8(path32.join(slot, SWIFT_FRAMEWORK_SLOT_KEY), frameworkKey);
21700
- writeFileSync8(path32.join(slot, SWIFT_FRAMEWORK_SLOT_ORIGIN), moduleRoot);
21950
+ writeFileSync8(path33.join(slot, SWIFT_FRAMEWORK_SLOT_KEY), frameworkKey);
21951
+ writeFileSync8(path33.join(slot, SWIFT_FRAMEWORK_SLOT_ORIGIN), moduleRoot);
21701
21952
  }
21702
21953
  return stagedModule;
21703
21954
  }
@@ -21737,7 +21988,7 @@ ${args.prebuilt.modules}
21737
21988
  `);
21738
21989
  for (const entry of readdirSync6(args.prebuilt.modules).sort())
21739
21990
  hash.update(`${entry}
21740
- ${statOf(path32.join(args.prebuilt.modules, entry))}`);
21991
+ ${statOf(path33.join(args.prebuilt.modules, entry))}`);
21741
21992
  return hash.digest("hex");
21742
21993
  }
21743
21994
  function retireSwiftLinkTargets(retired) {
@@ -21746,13 +21997,13 @@ function retireSwiftLinkTargets(retired) {
21746
21997
  "peach-product-checkpoints",
21747
21998
  "peach-swift-header-checkpoints"
21748
21999
  ]) {
21749
- rmSync7(path32.join(retired, name), { recursive: true, force: true });
22000
+ rmSync7(path33.join(retired, name), { recursive: true, force: true });
21750
22001
  }
21751
- const releaseLink = path32.join(retired, "release");
21752
- if (!existsSync9(releaseLink)) return;
22002
+ const releaseLink = path33.join(retired, "release");
22003
+ if (!existsSync10(releaseLink)) return;
21753
22004
  const releaseDir = realpathSync6(releaseLink);
21754
22005
  for (const entry of readdirSync6(releaseDir, { withFileTypes: true })) {
21755
- const targetPath = path32.join(releaseDir, entry.name);
22006
+ const targetPath = path33.join(releaseDir, entry.name);
21756
22007
  if (entry.name === "ModuleCache" || entry.name === "Modules" || entry.name.endsWith(".product") || entry.name.endsWith(".wasm")) {
21757
22008
  rmSync7(targetPath, { recursive: true, force: true });
21758
22009
  continue;
@@ -21765,7 +22016,7 @@ function retireSwiftLinkTargets(retired) {
21765
22016
  }
21766
22017
  }
21767
22018
  function retireStaleSwiftLink(root, baseStamp, stamp, preserveClangObjects = false) {
21768
- const receipt = path32.join(root, SWIFT_LINK_STAMP);
22019
+ const receipt = path33.join(root, SWIFT_LINK_STAMP);
21769
22020
  let previous = null;
21770
22021
  try {
21771
22022
  previous = readFileSync16(receipt, "utf8").trim();
@@ -21777,8 +22028,8 @@ function retireStaleSwiftLink(root, baseStamp, stamp, preserveClangObjects = fal
21777
22028
  ${stamp}`;
21778
22029
  writeFileSync8(receipt, `${combined}
21779
22030
  `);
21780
- const retired = path32.join(root, ".build");
21781
- if (previous === combined || !existsSync9(retired)) return false;
22031
+ const retired = path33.join(root, ".build");
22032
+ if (previous === combined || !existsSync10(retired)) return false;
21782
22033
  const [previousBase] = previous?.split("\n") ?? [];
21783
22034
  if (preserveClangObjects && previousBase === baseStamp) {
21784
22035
  retireSwiftLinkTargets(retired);
@@ -21803,11 +22054,11 @@ async function compileSwiftProjectOnce(sources, options) {
21803
22054
  mkdirSync8(options.buildRoot, { recursive: true });
21804
22055
  const root = realpathSync6(options.buildRoot);
21805
22056
  refreshSwiftCacheHold(root);
21806
- const moduleRoot = path32.resolve(options.moduleRoot);
22057
+ const moduleRoot = path33.resolve(options.moduleRoot);
21807
22058
  const distribution = swiftDistributionAt(moduleRoot);
21808
22059
  const mirrorDistribution = options.linkOnly || options.project ? null : distribution;
21809
22060
  if (distribution) refreshSwiftCacheHold(moduleRoot);
21810
- const input = distribution && !options.intermediates ? (await import("./swift-package-prebuilt-4N5CXBOZ.mjs")).useSwiftPackagePrebuilts(
22061
+ const input = distribution && !options.intermediates ? (await import("./swift-package-prebuilt-3BPDQVA7.mjs")).useSwiftPackagePrebuilts(
21811
22062
  sources,
21812
22063
  moduleRoot,
21813
22064
  options.toolchainBin
@@ -21817,11 +22068,11 @@ async function compileSwiftProjectOnce(sources, options) {
21817
22068
  throw new Error("swift-compile: link-only builds do not support guest image graphs");
21818
22069
  const layout2 = {
21819
22070
  root,
21820
- sources: path32.join(root, "Sources", "App"),
22071
+ sources: path33.join(root, "Sources", "App"),
21821
22072
  multi: compileTargets(input).length > 0
21822
22073
  };
21823
22074
  const sdkModule = options.sdkModule && !options.linkOnly;
21824
- const sdkImage = sdkModule ? await (await import("./swift-sdk-image-7T2LMQS5.mjs")).buildSwiftSdkImage(
22075
+ const sdkImage = sdkModule ? await (await import("./swift-sdk-image-EJD5TPQH.mjs")).buildSwiftSdkImage(
21825
22076
  moduleRoot,
21826
22077
  !!guestGraph,
21827
22078
  distribution ? [] : linkedFrameworkTargets(moduleRoot, input).imports,
@@ -21833,7 +22084,7 @@ async function compileSwiftProjectOnce(sources, options) {
21833
22084
  const hash = sdkImage ? createHash18("sha256").update(`${sourceHash}
21834
22085
  sdk module ${sdkImage.key}`).digest("hex") : sourceHash;
21835
22086
  const frameworkKey = swiftProjectBuildKey(moduleRoot, options.release);
21836
- const sharedRoot = path32.join(swiftCacheDir(), "swift-projects", hash);
22087
+ const sharedRoot = path33.join(swiftCacheDir(), "swift-projects", hash);
21837
22088
  const report = (message) => {
21838
22089
  console.error(`[swift-project ${hash.slice(0, 16)}] ${message}`);
21839
22090
  options.onStage?.(message);
@@ -21848,8 +22099,8 @@ sdk module ${sdkImage.key}`).digest("hex") : sourceHash;
21848
22099
  report("reusing memory artifact");
21849
22100
  return retain(root, retained);
21850
22101
  }
21851
- const cached = readCompiledArtifact(path32.join(sharedRoot, "artifact"), hash);
21852
- const previous = cached ?? (options.project ? null : readCompiledArtifact(path32.join(root, "artifact"), hash));
22102
+ const cached = readCompiledArtifact(path33.join(sharedRoot, "artifact"), hash);
22103
+ const previous = cached ?? (options.project ? null : readCompiledArtifact(path33.join(root, "artifact"), hash));
21853
22104
  if (previous) {
21854
22105
  if (cached) renewSharedArtifact(sharedRoot);
21855
22106
  else saveSharedArtifact(sharedRoot, previous);
@@ -21859,8 +22110,8 @@ sdk module ${sdkImage.key}`).digest("hex") : sourceHash;
21859
22110
  }
21860
22111
  if (!options.intermediates && !sdkImage && process.platform === "darwin" && process.env.TM_SESSION && !windowAdmission() && process.env.CI !== "true" && moduleRoot === sourceSwiftCheckout() && !swiftDistributionAt(moduleRoot)) {
21861
22112
  const requestRoot = mkdtempSync4(`${root}.builder-request-`);
21862
- const output = path32.join(requestRoot, "output");
21863
- const request = path32.join(requestRoot, "request.json");
22113
+ const output = path33.join(requestRoot, "output");
22114
+ const request = path33.join(requestRoot, "request.json");
21864
22115
  writeFileSync8(
21865
22116
  request,
21866
22117
  JSON.stringify({
@@ -21874,13 +22125,13 @@ sdk module ${sdkImage.key}`).digest("hex") : sourceHash;
21874
22125
  })
21875
22126
  );
21876
22127
  try {
21877
- const repo = path32.resolve(moduleRoot, "../..");
22128
+ const repo = path33.resolve(moduleRoot, "../..");
21878
22129
  const timeout = swiftBuilderHopTimeoutMs(options.timeoutMs);
21879
22130
  report("requesting builder admission or cached result");
21880
22131
  await runCompiler(
21881
22132
  "bun",
21882
22133
  [
21883
- path32.join(repo, "scripts/build/swift-project.ts"),
22134
+ path33.join(repo, "scripts/build/swift-project.ts"),
21884
22135
  "--request",
21885
22136
  request,
21886
22137
  "--output",
@@ -21930,14 +22181,14 @@ ${cap}` : "";
21930
22181
  root,
21931
22182
  async (lease) => {
21932
22183
  if (!options.intermediates) {
21933
- const built = readCompiledArtifact(path32.join(sharedRoot, "artifact"), hash);
22184
+ const built = readCompiledArtifact(path33.join(sharedRoot, "artifact"), hash);
21934
22185
  if (built) {
21935
22186
  report("reusing verified disk artifact");
21936
22187
  return retain(root, built);
21937
22188
  }
21938
22189
  }
21939
- const swift = path32.join(options.toolchainBin, "swift");
21940
- if (!existsSync9(swift)) {
22190
+ const swift = path33.join(options.toolchainBin, "swift");
22191
+ if (!existsSync10(swift)) {
21941
22192
  throw new Error(
21942
22193
  `swift-compile: no swift.org toolchain at ${options.toolchainBin}; install ${options.release} and its matching wasm sdk`
21943
22194
  );
@@ -21950,54 +22201,82 @@ ${cap}` : "";
21950
22201
  work,
21951
22202
  unoptimized
21952
22203
  );
21953
- return withFrameworkLock(async (slot, frameworkLease) => {
22204
+ const baseBuildEnv = {
22205
+ ...options.project?.env ?? process.env,
22206
+ // shipped host plugins resolve against the selected compiler's runtime.
22207
+ ...process.platform === "linux" ? {
22208
+ LD_LIBRARY_PATH: [
22209
+ path33.resolve(options.toolchainBin, "../lib/swift/linux"),
22210
+ path33.resolve(options.toolchainBin, "../lib/swift/host"),
22211
+ process.env.LD_LIBRARY_PATH
22212
+ ].filter(Boolean).join(":")
22213
+ } : {},
22214
+ PEACH_DEFER_WASM_LINK: "1"
22215
+ };
22216
+ const {
22217
+ frameworkRoot,
22218
+ compileFrameworkRoot,
22219
+ macroPlugins,
22220
+ sdk,
22221
+ icu,
22222
+ prebuilt,
22223
+ readHold
22224
+ } = await withFrameworkLock(async (slot, frameworkLease) => {
21954
22225
  budget.startCompile();
21955
- const frameworkRoot = mirrorDistribution ? syncSwiftDistributionMirror(root, moduleRoot, mirrorDistribution) : distribution ? moduleRoot : stageFrameworkSource(moduleRoot, slot, frameworkKey, options.release);
21956
- if (!swiftModuleDigest(frameworkRoot).equals(moduleDigest))
22226
+ if (slot && swiftFrameworkSlotKey(slot) !== frameworkKey)
22227
+ await waitForNoSwiftRootReaders(slot, budget.signal);
22228
+ const frameworkRoot2 = mirrorDistribution ? syncSwiftDistributionMirror(root, moduleRoot, mirrorDistribution) : distribution ? moduleRoot : stageFrameworkSource(moduleRoot, slot, frameworkKey, options.release);
22229
+ if (!swiftModuleDigest(frameworkRoot2).equals(moduleDigest))
21957
22230
  throw new Error("Swift staged project source differs from the caller");
21958
22231
  report("preparing compiler plugins");
21959
- const macroPlugins = await ensureMacroPlugins(
21960
- frameworkRoot,
22232
+ const macroPlugins2 = await ensureMacroPlugins(
22233
+ frameworkRoot2,
21961
22234
  options.toolchainBin,
21962
22235
  options.release,
21963
22236
  budget.signal,
21964
22237
  frameworkLease
21965
22238
  );
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;
22239
+ const compileFrameworkRoot2 = distribution ? swiftDistributionCompileView(frameworkRoot2, distribution) : frameworkRoot2;
22240
+ const sdk2 = swiftModuleSdk(frameworkRoot2).wasmSdkId;
22241
+ const icu2 = options.linkOnly ? null : swiftIcuAsset(options.toolchainBin, sdk2);
22242
+ let prebuilt2;
21988
22243
  if (!distribution) {
21989
22244
  report("compiling framework products");
21990
- prebuilt = await buildFrameworkProducts(slot, {
21991
- moduleRoot: frameworkRoot,
22245
+ prebuilt2 = await buildFrameworkProducts(slot, {
22246
+ moduleRoot: frameworkRoot2,
21992
22247
  frameworkKey,
21993
22248
  input,
21994
22249
  swift,
21995
- sdk,
22250
+ sdk: sdk2,
21996
22251
  toolchainBin: options.toolchainBin,
21997
- plugins: macroPlugins,
21998
- buildOptions
22252
+ plugins: macroPlugins2,
22253
+ buildOptions: {
22254
+ env: baseBuildEnv,
22255
+ maxBuffer: 64 * 1024 * 1024,
22256
+ signal: budget.signal,
22257
+ lease,
22258
+ frameworkLease
22259
+ }
21999
22260
  });
22000
22261
  }
22262
+ const readHold2 = slot ? acquireSwiftRootReadHold(slot) : void 0;
22263
+ return {
22264
+ frameworkRoot: frameworkRoot2,
22265
+ compileFrameworkRoot: compileFrameworkRoot2,
22266
+ macroPlugins: macroPlugins2,
22267
+ sdk: sdk2,
22268
+ icu: icu2,
22269
+ prebuilt: prebuilt2,
22270
+ readHold: readHold2
22271
+ };
22272
+ });
22273
+ const buildOptions = {
22274
+ env: baseBuildEnv,
22275
+ maxBuffer: 64 * 1024 * 1024,
22276
+ signal: budget.signal,
22277
+ lease
22278
+ };
22279
+ try {
22001
22280
  if (options.project) removeProjectLinks(root);
22002
22281
  const packageHostMacros = process.platform === "linux" ? input.packageHostMacros : void 0;
22003
22282
  if (retireStaleSwiftLink(
@@ -22025,20 +22304,20 @@ ${cap}` : "";
22025
22304
  !options.project,
22026
22305
  options.project ? false : options.objcPrebuiltStage ?? (options.intermediates ? false : void 0)
22027
22306
  );
22028
- const productFile = path32.join(frameworkRoot, SWIFT_FRAMEWORK_PRODUCT_FILE);
22307
+ const productFile = path33.join(frameworkRoot, SWIFT_FRAMEWORK_PRODUCT_FILE);
22029
22308
  writeSwiftAutolinkLinker(
22030
22309
  root,
22031
22310
  options.toolchainBin,
22032
- existsSync9(productFile) ? [
22311
+ existsSync10(productFile) ? [
22033
22312
  parse(
22034
22313
  swiftFrameworkProductSchema,
22035
22314
  JSON.parse(readFileSync16(productFile, "utf8"))
22036
22315
  ).product.name
22037
22316
  ] : []
22038
22317
  );
22039
- const compiler = preparation.targetToolset ? { CC: path32.join(root, CLANG_TARGET_MODULE_WRAPPER) } : {};
22318
+ const compiler = preparation.targetToolset ? { CC: path33.join(root, CLANG_TARGET_MODULE_WRAPPER) } : {};
22040
22319
  if (packageHostMacros?.length) {
22041
- const swiftc = path32.join(root, SWIFT_HOST_COMPILER_WRAPPER);
22320
+ const swiftc = path33.join(root, SWIFT_HOST_COMPILER_WRAPPER);
22042
22321
  writeBuildFile(
22043
22322
  swiftc,
22044
22323
  [
@@ -22065,10 +22344,10 @@ ${cap}` : "";
22065
22344
  chmodSync3(swiftc, 493);
22066
22345
  compiler.SWIFT_EXEC = swiftc;
22067
22346
  compiler.PEACH_SWIFT_HOST_MACROS = packageHostMacros.join(",");
22068
- compiler.PEACH_SWIFTC = path32.join(options.toolchainBin, "swiftc");
22347
+ compiler.PEACH_SWIFTC = path33.join(options.toolchainBin, "swiftc");
22069
22348
  }
22070
22349
  const projectProcess = options.project ? prepareSwiftProjectProcess(root, options.project) : void 0;
22071
- const temporaryDirectory = projectProcess ? void 0 : path32.join(root, ".build", "peach-compiler-tmp");
22350
+ const temporaryDirectory = projectProcess ? void 0 : path33.join(root, ".build", "peach-compiler-tmp");
22072
22351
  const appOptions = projectProcess ? {
22073
22352
  ...buildOptions,
22074
22353
  uid: projectProcess.uid,
@@ -22086,10 +22365,10 @@ ${cap}` : "";
22086
22365
  for (const [file, text2] of Object.entries(input.files)) {
22087
22366
  const parents = /^#include "((?:\.\.\/)+)[^"\n]+"\n$/.exec(text2)?.[1];
22088
22367
  if (!parents) continue;
22089
- const directory = path32.posix.dirname(file);
22368
+ const directory = path33.posix.dirname(file);
22090
22369
  forwarders.set(
22091
- `${path32.join(root, directory)}/${parents.slice(0, -1)}`,
22092
- path32.posix.join("build", directory, parents).replace(/\/$/, "")
22370
+ `${path33.join(root, directory)}/${parents.slice(0, -1)}`,
22371
+ path33.posix.join("build", directory, parents).replace(/\/$/, "")
22093
22372
  );
22094
22373
  }
22095
22374
  const jobs = swiftCompilerJobs();
@@ -22108,7 +22387,7 @@ ${cap}` : "";
22108
22387
  ...swiftObjCSelectorOptions(frameworkRoot),
22109
22388
  "--swift-sdk",
22110
22389
  sdk,
22111
- ...preparation.targetToolset ? ["--toolset", path32.join(root, ".peach-target-toolset.json")] : [],
22390
+ ...preparation.targetToolset ? ["--toolset", path33.join(root, ".peach-target-toolset.json")] : [],
22112
22391
  "-c",
22113
22392
  "release",
22114
22393
  ...input.unoptimized ? ["-Xswiftc", "-Onone"] : [],
@@ -22127,19 +22406,16 @@ ${cap}` : "";
22127
22406
  // the link strips debug info, so none is generated (as for the framework)
22128
22407
  "-Xswiftc",
22129
22408
  "-gnone",
22130
- "-Xswiftc",
22131
- "-num-threads",
22132
- "-Xswiftc",
22133
- String(perFile ? 1 : jobs),
22409
+ ...incrementalPreview ? [] : ["-Xswiftc", "-num-threads", "-Xswiftc", String(perFile ? 1 : jobs)],
22134
22410
  ...swiftReproducibleBuildFlags([
22135
- [path32.dirname(options.toolchainBin), "toolchain"],
22411
+ [path33.dirname(options.toolchainBin), "toolchain"],
22136
22412
  [compileFrameworkRoot, "framework"],
22137
22413
  [root, "build"],
22138
22414
  ...forwarders
22139
22415
  ]).flatMap((flag, index, flags) => {
22140
22416
  if (!nativeToolset || !flag.startsWith("-ffile-prefix-map="))
22141
22417
  return [flag];
22142
- const toolchainDir = path32.dirname(options.toolchainBin);
22418
+ const toolchainDir = path33.dirname(options.toolchainBin);
22143
22419
  let mapped = flag;
22144
22420
  for (const [dir, target] of [
22145
22421
  [root, "/peach/build"],
@@ -22168,12 +22444,12 @@ ${cap}` : "";
22168
22444
  ])
22169
22445
  ];
22170
22446
  const linked = builtArtifact(layout2);
22171
- rmSync7(path32.join(root, ".peach-link.rsp"), { force: true });
22172
- if (options.linkOnly || existsSync9(linked) && statSync4(linked).size <= 8)
22447
+ rmSync7(path33.join(root, ".peach-link.rsp"), { force: true });
22448
+ if (options.linkOnly || existsSync10(linked) && statSync4(linked).size <= 8)
22173
22449
  rmSync7(linked, { force: true });
22174
22450
  report("compiling and linking Swift modules");
22175
22451
  const frameworkInterfaces = /* @__PURE__ */ new Map();
22176
- const sdkFrameworks = path32.join(
22452
+ const sdkFrameworks = path33.join(
22177
22453
  swiftSdkPaths(frameworkRoot, options.toolchainBin).darwin,
22178
22454
  "System/Library/Frameworks"
22179
22455
  );
@@ -22188,39 +22464,39 @@ ${cap}` : "";
22188
22464
  const name = moduleMapName(contents2);
22189
22465
  const umbrella = /\bumbrella\s+header\s+"([^"]+)"/.exec(contents2)?.[1];
22190
22466
  if (!name || !umbrella) continue;
22191
- const header = input.files[path32.posix.join(path32.posix.dirname(file), umbrella)];
22467
+ const header = input.files[path33.posix.join(path33.posix.dirname(file), umbrella)];
22192
22468
  if (header === void 0) continue;
22193
22469
  const included = new Set(
22194
22470
  [
22195
22471
  ...header.matchAll(/^\s*#\s*(?:import|include)\s*[<"]([^">]+)[">]/gm)
22196
- ].map((match) => path32.posix.basename(match[1]))
22472
+ ].map((match) => path33.posix.basename(match[1]))
22197
22473
  );
22198
22474
  const declarations = nativeDeclarations.get(name) ?? /* @__PURE__ */ new Set();
22199
22475
  for (const declaration of swiftInterfaceDeclarations(header))
22200
22476
  declarations.add(declaration);
22201
22477
  for (const [candidate, source] of Object.entries(input.files))
22202
- if (included.has(path32.posix.basename(candidate)))
22478
+ if (included.has(path33.posix.basename(candidate)))
22203
22479
  for (const declaration of swiftInterfaceDeclarations(source))
22204
22480
  declarations.add(declaration);
22205
22481
  nativeDeclarations.set(name, declarations);
22206
22482
  }
22207
22483
  const frameworkInterface = (name) => {
22208
22484
  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)) {
22485
+ const source = distribution ? path33.join(frameworkRoot, "modules", `${name}-Swift.h`) : prebuilt.objcHeaders.get(name);
22486
+ if (!source || !existsSync10(source)) {
22211
22487
  frameworkInterfaces.set(name, null);
22212
22488
  return null;
22213
22489
  }
22214
- const headers = path32.join(sdkFrameworks, `${name}.framework/Headers`);
22490
+ const headers = path33.join(sdkFrameworks, `${name}.framework/Headers`);
22215
22491
  const declared = /* @__PURE__ */ new Set();
22216
- if (existsSync9(headers)) {
22492
+ if (existsSync10(headers)) {
22217
22493
  for (const file of readdirSync6(headers, {
22218
22494
  recursive: true,
22219
22495
  encoding: "utf8"
22220
22496
  }))
22221
22497
  if (file.endsWith(".h"))
22222
22498
  for (const name2 of swiftInterfaceDeclarations(
22223
- readFileSync16(path32.join(headers, file), "utf8")
22499
+ readFileSync16(path33.join(headers, file), "utf8")
22224
22500
  ))
22225
22501
  declared.add(name2);
22226
22502
  }
@@ -22249,20 +22525,20 @@ ${cap}` : "";
22249
22525
  [...new Set(foreign.values())].map((owner) => `#import <${owner}/${owner}.h>`).join("\n")
22250
22526
  ) : own;
22251
22527
  const value = {
22252
- file: path32.join(root, ".build/peach-framework-objc", `${name}-Swift.h`),
22528
+ file: path33.join(root, ".build/peach-framework-objc", `${name}-Swift.h`),
22253
22529
  header,
22254
- module: existsSync9(headers)
22530
+ module: existsSync10(headers)
22255
22531
  };
22256
22532
  frameworkInterfaces.set(name, value);
22257
22533
  writeBuildFile(
22258
22534
  value.file,
22259
- (existsSync9(path32.join(headers, `${name}.h`)) ? `#import <${name}/${name}.h>
22535
+ (existsSync10(path33.join(headers, `${name}.h`)) ? `#import <${name}/${name}.h>
22260
22536
  ` : "") + swiftHeaderWithSuperclassImports(header, frameworkInterface)
22261
22537
  );
22262
22538
  return value;
22263
22539
  };
22264
22540
  const headerPaths = (producer) => {
22265
- const stem = path32.join(
22541
+ const stem = path33.join(
22266
22542
  root,
22267
22543
  ".build",
22268
22544
  "peach-cxx-headers",
@@ -22290,7 +22566,7 @@ ${cap}` : "";
22290
22566
  };
22291
22567
  const recipe = inputHash.copy().update(
22292
22568
  distribution ? swiftCompileSurfaceDigest(frameworkRoot) : moduleDigest
22293
- ).update(readFileSync16(path32.join(root, "Package.swift"))).update(JSON.stringify(buildArgs)).digest("hex");
22569
+ ).update(readFileSync16(path33.join(root, "Package.swift"))).update(JSON.stringify(buildArgs)).digest("hex");
22294
22570
  const runApp = async (compiler2) => {
22295
22571
  const optionsWithCompiler = compiler2 ? { ...appOptions, env: { ...appOptions.env, ...compiler2 } } : appOptions;
22296
22572
  const stages = [
@@ -22304,33 +22580,33 @@ ${cap}` : "";
22304
22580
  producers: []
22305
22581
  }))
22306
22582
  ];
22307
- const checkpoints = path32.join(root, ".build", "peach-product-checkpoints");
22583
+ const checkpoints = path33.join(root, ".build", "peach-product-checkpoints");
22308
22584
  for (const { target, producers } of stages) {
22309
- const receipt = path32.join(
22585
+ const receipt = path33.join(
22310
22586
  checkpoints,
22311
22587
  createHash18("sha256").update(target).digest("hex")
22312
22588
  );
22313
22589
  const headers = producers.map(headerPaths);
22314
22590
  for (const header of headers)
22315
- if (existsSync9(header.original)) publishHeader(header);
22591
+ if (existsSync10(header.original)) publishHeader(header);
22316
22592
  const fingerprint = () => {
22317
22593
  const digest = createHash18("sha256").update(recipe);
22318
22594
  for (const { original, emitted } of headers) {
22319
- if (!existsSync9(original) || !existsSync9(emitted)) return;
22595
+ if (!existsSync10(original) || !existsSync10(emitted)) return;
22320
22596
  digest.update(
22321
22597
  createHash18("sha256").update(readFileSync16(emitted)).digest()
22322
22598
  );
22323
22599
  }
22324
22600
  return digest.digest("hex");
22325
22601
  };
22326
- if (!options.project && existsSync9(receipt) && readFileSync16(receipt, "utf8") === fingerprint())
22602
+ if (!options.project && existsSync10(receipt) && readFileSync16(receipt, "utf8") === fingerprint())
22327
22603
  continue;
22328
22604
  if (!options.project) rmSync7(receipt, { force: true });
22329
22605
  for (const header of headers) {
22330
- if (!existsSync9(header.original))
22606
+ if (!existsSync10(header.original))
22331
22607
  rmSync7(
22332
- path32.join(
22333
- path32.dirname(linked),
22608
+ path33.join(
22609
+ path33.dirname(linked),
22334
22610
  "Modules",
22335
22611
  `${swiftTargetModuleName(header.producer)}.swiftmodule`
22336
22612
  ),
@@ -22385,14 +22661,14 @@ ${cap}` : "";
22385
22661
  await compileApp();
22386
22662
  } catch (error) {
22387
22663
  const output2 = outputOf(error);
22388
- const moduleCache = path32.join(
22664
+ const moduleCache = path33.join(
22389
22665
  root,
22390
22666
  ".build",
22391
22667
  WASM_TRIPLE,
22392
22668
  "release",
22393
22669
  "ModuleCache"
22394
22670
  );
22395
- if (output2.includes("was compiled with module cache path") && existsSync9(moduleCache)) {
22671
+ if (output2.includes("was compiled with module cache path") && existsSync10(moduleCache)) {
22396
22672
  rmSync7(moduleCache, { recursive: true, force: true });
22397
22673
  try {
22398
22674
  await compileApp();
@@ -22419,11 +22695,11 @@ ${cap}` : "";
22419
22695
  if (options.project) endSwiftProjectProcesses(options.project);
22420
22696
  }
22421
22697
  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() : [];
22698
+ if (!existsSync10(linked)) {
22699
+ const binDir = path33.dirname(linked);
22700
+ const found = existsSync10(binDir) ? readdirSync6(binDir).filter((name) => name.endsWith(".wasm")).sort() : [];
22425
22701
  throw new Error(
22426
- `swift-compile: the build produced no ${path32.basename(linked)} (found: ${found.join(", ") || "none"})`
22702
+ `swift-compile: the build produced no ${path33.basename(linked)} (found: ${found.join(", ") || "none"})`
22427
22703
  );
22428
22704
  }
22429
22705
  if (options.project) removeProjectLinks(root);
@@ -22454,10 +22730,10 @@ ${cap}` : "";
22454
22730
  const binding = await compileGuestLink({
22455
22731
  graph: guestGraph,
22456
22732
  buildDirectory: root,
22457
- releaseDirectory: path32.dirname(linked),
22733
+ releaseDirectory: path33.dirname(linked),
22458
22734
  moduleRoot: frameworkRoot,
22459
22735
  toolchainBin: options.toolchainBin,
22460
- swiftCompiler: preparation.headerCompiler ? path32.join(root, SWIFT_HEADER_COMPILER_WRAPPER) : compiler.SWIFT_EXEC ?? path32.join(options.toolchainBin, "swiftc"),
22736
+ swiftCompiler: preparation.headerCompiler ? path33.join(root, SWIFT_HEADER_COMPILER_WRAPPER) : compiler.SWIFT_EXEC ?? path33.join(options.toolchainBin, "swiftc"),
22461
22737
  sysroot: swiftSdkPaths(frameworkRoot, options.toolchainBin).sysroot,
22462
22738
  sdk: swiftModuleSdk(frameworkRoot),
22463
22739
  sdkImage,
@@ -22478,7 +22754,7 @@ ${cap}` : "";
22478
22754
  if (sdkImage && binding)
22479
22755
  sdkAsset = { key: sdkImage.key, sha256: sdkImage.sha256, binding };
22480
22756
  } else if (sdkImage) {
22481
- const { buildSwiftAppModule } = await import("./swift-sdk-app-module-5IUSRXYA.mjs");
22757
+ const { buildSwiftAppModule } = await import("./swift-sdk-app-module-CRX6E3TR.mjs");
22482
22758
  const binding = await buildSwiftAppModule({
22483
22759
  buildRoot: root,
22484
22760
  toolchainBin: options.toolchainBin,
@@ -22488,7 +22764,7 @@ ${cap}` : "";
22488
22764
  project: options.project && {
22489
22765
  ...options.project,
22490
22766
  env: { ...options.project.env, ...projectProcess?.env },
22491
- sdkRoot: path32.dirname(
22767
+ sdkRoot: path33.dirname(
22492
22768
  swiftSdkPaths(frameworkRoot, options.toolchainBin).sysroot
22493
22769
  ),
22494
22770
  linked: output
@@ -22503,7 +22779,7 @@ ${cap}` : "";
22503
22779
  }
22504
22780
  if (!sdkImage)
22505
22781
  await runCompiler(
22506
- path32.join(options.toolchainBin, "llvm-objcopy"),
22782
+ path33.join(options.toolchainBin, "llvm-objcopy"),
22507
22783
  ["--remove-section=.swift1_autolink_entries", optimized],
22508
22784
  buildOptions
22509
22785
  );
@@ -22519,7 +22795,9 @@ ${cap}` : "";
22519
22795
  saveSharedArtifact(sharedRoot, artifact);
22520
22796
  report("compiled artifact verified");
22521
22797
  return retain(root, artifact);
22522
- });
22798
+ } finally {
22799
+ readHold?.release();
22800
+ }
22523
22801
  },
22524
22802
  budget.signal
22525
22803
  );