peachsim 0.1.2421 → 0.1.2422

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 (94) 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 +1 -1
  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 +1 -1
  11. package/dist-lib/bridge-contract.cjs +1 -1
  12. package/dist-lib/bridge-contract.mjs +1 -1
  13. package/dist-lib/bundle-channel.cjs +4317 -3935
  14. package/dist-lib/capture-contract.cjs +1 -1
  15. package/dist-lib/capture-contract.mjs +1 -1
  16. package/dist-lib/cloud-contract.cjs +1 -1
  17. package/dist-lib/cloud-contract.mjs +1 -1
  18. package/dist-lib/cloud-test-args.cjs +1 -1
  19. package/dist-lib/cloud-test-args.mjs +1 -1
  20. package/dist-lib/cloud.cjs +1 -1
  21. package/dist-lib/cloud.mjs +1 -1
  22. package/dist-lib/config.cjs +1 -1
  23. package/dist-lib/config.mjs +1 -1
  24. package/dist-lib/detox/index.cjs +1 -1
  25. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  26. package/dist-lib/expo-swift-bundle.cjs +3343 -2961
  27. package/dist-lib/expo-swift-metadata.cjs +1 -1
  28. package/dist-lib/expo-swift-metadata.mjs +1 -1
  29. package/dist-lib/home-paths.cjs +1 -1
  30. package/dist-lib/host/bridge-host.cjs +4199 -3817
  31. package/dist-lib/host/fetch-proxy-handler.cjs +24 -3
  32. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  33. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  34. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  35. package/dist-lib/host/websocket-proxy.cjs +1 -1
  36. package/dist-lib/index.cjs +24 -3
  37. package/dist-lib/jump-to-source-babel.cjs +1 -1
  38. package/dist-lib/jump-to-source-native.cjs +1 -1
  39. package/dist-lib/kotlin-host.cjs +1 -1
  40. package/dist-lib/menu.cjs +1 -1
  41. package/dist-lib/menu.mjs +1 -1
  42. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  43. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  44. package/dist-lib/metro-production-bundle.cjs +1 -1
  45. package/dist-lib/metro-production-bundle.mjs +1 -1
  46. package/dist-lib/metro.cjs +24 -3
  47. package/dist-lib/native-app-identity-project.cjs +2 -2
  48. package/dist-lib/native-app-identity-project.mjs +231 -212
  49. package/dist-lib/native-app-identity.cjs +1 -1
  50. package/dist-lib/native-app-identity.mjs +1 -1
  51. package/dist-lib/native-firebase-metadata.cjs +1 -1
  52. package/dist-lib/native-firebase-metadata.mjs +1 -1
  53. package/dist-lib/pdfium-raster.cjs +1 -1
  54. package/dist-lib/pdfium-raster.mjs +1 -1
  55. package/dist-lib/plist.cjs +1 -1
  56. package/dist-lib/plist.mjs +1 -1
  57. package/dist-lib/profiles.cjs +1 -1
  58. package/dist-lib/public-brand.cjs +1 -1
  59. package/dist-lib/public-origins-lib-esm.json +30 -25
  60. package/dist-lib/public-origins-lib.json +77 -56
  61. package/dist-lib/react-native-host-modules.cjs +1 -1
  62. package/dist-lib/react-native-host-modules.mjs +1 -1
  63. package/dist-lib/reap-browser.cjs +1 -1
  64. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  65. package/dist-lib/sdk.cjs +1 -1
  66. package/dist-lib/sdk.mjs +1 -1
  67. package/dist-lib/skills.cjs +4851 -4468
  68. package/dist-lib/swift-compile.cjs +1261 -888
  69. package/dist-lib/swift-compile.mjs +1231 -848
  70. package/dist-lib/swift-package.cjs +1 -1
  71. package/dist-lib/swift-package.mjs +1 -1
  72. package/dist-lib/swift-submit.cjs +1 -1
  73. package/dist-lib/swift-submit.mjs +1 -1
  74. package/dist-lib/swift-toolchain.cjs +1 -1
  75. package/dist-lib/swift.cjs +1 -1
  76. package/dist-lib/vite-swift.cjs +2712 -2347
  77. package/dist-lib/vite.cjs +24 -3
  78. package/dist-lib/worklet-executable.cjs +1 -1
  79. package/dist-lib/worklet-executable.mjs +1 -1
  80. package/dist-types/packages/peach-engine/src/engine/native-layout.d.ts +1 -1
  81. package/dist-types/packages/peach-engine/src/render-worker/compositor-protocol.d.ts +0 -10
  82. package/dist-types/packages/peach-engine/src/render-worker/compositor-runtime/layer-claims.d.ts +2 -1
  83. package/kotlin/sdk.tar.gz +0 -0
  84. package/package.json +1 -1
  85. package/src/expo-kotlin-bundle.ts +1 -1
  86. package/src/native-static-libraries.ts +51 -4
  87. package/src/swift-compile.ts +184 -107
  88. package/src/swift-compiler-digest.ts +2 -0
  89. package/src/swift-guest-compile.ts +2 -0
  90. package/src/swift-guest-source-inputs.ts +2 -2
  91. package/src/swift-header-compiler.ts +185 -0
  92. package/src/swift-header-dependencies.ts +174 -0
  93. package/src/swift-objc-compile.ts +18 -24
  94. package/dist-types/packages/peach-engine/src/render-worker/accessibilityHostContract.d.ts +0 -65
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2421 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2422 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  var __defProp = Object.defineProperty;
3
3
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
4
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
@@ -8,28 +8,28 @@ import {
8
8
  spawn as spawn5,
9
9
  execFileSync as execFileSync12
10
10
  } from "node:child_process";
11
- import { createHash as createHash14, randomUUID as randomUUID5 } from "node:crypto";
11
+ import { createHash as createHash15, randomUUID as randomUUID5 } from "node:crypto";
12
12
  import {
13
- chmodSync as chmodSync2,
13
+ chmodSync as chmodSync3,
14
14
  copyFileSync,
15
15
  cpSync,
16
- existsSync as existsSync6,
16
+ existsSync as existsSync7,
17
17
  lstatSync,
18
- mkdirSync as mkdirSync7,
19
- mkdtempSync as mkdtempSync3,
20
- readFileSync as readFileSync17,
18
+ mkdirSync as mkdirSync8,
19
+ mkdtempSync as mkdtempSync4,
20
+ readFileSync as readFileSync18,
21
21
  readdirSync as readdirSync8,
22
22
  readlinkSync,
23
23
  realpathSync as realpathSync6,
24
- renameSync as renameSync2,
25
- rmSync as rmSync7,
26
- statSync as statSync2,
24
+ renameSync as renameSync3,
25
+ rmSync as rmSync8,
26
+ statSync as statSync3,
27
27
  symlinkSync as symlinkSync2,
28
28
  utimesSync,
29
- writeFileSync as writeFileSync8
29
+ writeFileSync as writeFileSync9
30
30
  } from "node:fs";
31
31
  import os5 from "node:os";
32
- import path28 from "node:path";
32
+ import path30 from "node:path";
33
33
  import * as v5 from "valibot";
34
34
 
35
35
  // src/admitted-mac-build.ts
@@ -3653,7 +3653,7 @@ function swiftManifestTargets(manifest, resourcePaths = [], readArguments) {
3653
3653
  const targets = [];
3654
3654
  const packageCall = manifestCalls(manifest, ["Package"])[0];
3655
3655
  const platformArgument = packageCall ? splitManifestArguments(packageCall.call.slice(0, -1)).find(
3656
- (argument) => /^platforms\s*:/.test(argument)
3656
+ (argument2) => /^platforms\s*:/.test(argument2)
3657
3657
  ) : void 0;
3658
3658
  const platformList = /^platforms\s*:\s*\[([\s\S]*)\]$/.exec(platformArgument ?? "")?.[1];
3659
3659
  const iosPlatforms = [
@@ -3694,7 +3694,7 @@ function swiftManifestTargets(manifest, resourcePaths = [], readArguments) {
3694
3694
  );
3695
3695
  const targetArguments = splitManifestArguments(call.slice(0, -1));
3696
3696
  const sourceArgument = targetArguments.find(
3697
- (argument) => /^sources\s*:/.test(argument)
3697
+ (argument2) => /^sources\s*:/.test(argument2)
3698
3698
  );
3699
3699
  const sourceList = sourceArgument?.replace(/^sources\s*:\s*/, "").trim();
3700
3700
  if (sourceList && sourceList !== "nil" && !(sourceList.startsWith("[") && sourceList.endsWith("]")))
@@ -3708,7 +3708,7 @@ function swiftManifestTargets(manifest, resourcePaths = [], readArguments) {
3708
3708
  return swiftStringValue(literal2[1], `a source of target ${name2}`).replace(/^\.\//, "").replace(/\/+$/, "");
3709
3709
  }) : void 0;
3710
3710
  const dependencyArgument = targetArguments.find(
3711
- (argument) => /^dependencies\s*:/.test(argument)
3711
+ (argument2) => /^dependencies\s*:/.test(argument2)
3712
3712
  );
3713
3713
  const dependencyList = dependencyArgument?.replace(/^dependencies\s*:\s*/, "").trim();
3714
3714
  const dependencies = [];
@@ -4685,9 +4685,9 @@ var EXCERPT = /^(\s*)(\d+)( \| )(.*)$/;
4685
4685
  var MARKER = /^(\s*)( \| )(.*)$/;
4686
4686
  function designTimeDiagnostic(output, files) {
4687
4687
  const rewritten = /* @__PURE__ */ new Map();
4688
- const linesOf = (path29) => {
4688
+ const linesOf = (path31) => {
4689
4689
  const file = Object.keys(files).find(
4690
- (name2) => name2.endsWith(".swift") && (path29 === name2 || path29.endsWith(`/${name2}`))
4690
+ (name2) => name2.endsWith(".swift") && (path31 === name2 || path31.endsWith(`/${name2}`))
4691
4691
  );
4692
4692
  if (file === void 0) return null;
4693
4693
  let lines = rewritten.get(file);
@@ -9321,7 +9321,7 @@ function linkGuestImages(options) {
9321
9321
  const trace = path16.join(directory, `${name2}-inputs.txt`);
9322
9322
  fs6.writeFileSync(
9323
9323
  response,
9324
- [...arguments_, "--trace"].map((argument) => JSON.stringify(argument)).join(" ")
9324
+ [...arguments_, "--trace"].map((argument2) => JSON.stringify(argument2)).join(" ")
9325
9325
  );
9326
9326
  const output = fs6.openSync(trace, "w");
9327
9327
  try {
@@ -10199,7 +10199,7 @@ function sourceGuestClangLinkOptions(options) {
10199
10199
  const command = commands.get(file);
10200
10200
  if (!command) throw new Error(`missing source object producer ${file}`);
10201
10201
  if (command.tool === "shell") {
10202
- if (!command.args.length || realpathSync2(command.args[0]) !== realpathSync2(path17.join(options.toolchainBin, "swiftc")))
10202
+ if (!command.args.length || realpathSync2(command.args[0]) !== realpathSync2(options.swiftCompiler))
10203
10203
  throw new Error(`unsupported source object producer ${file}`);
10204
10204
  continue;
10205
10205
  }
@@ -11301,6 +11301,7 @@ async function compileGuestLink(options) {
11301
11301
  buildDirectory: options.buildDirectory,
11302
11302
  directory,
11303
11303
  toolchainBin: options.toolchainBin,
11304
+ swiftCompiler: options.swiftCompiler,
11304
11305
  objects: selectedSource.map((artifact) => artifact.path)
11305
11306
  });
11306
11307
  const links = sourceGuestRuntimeLinks({
@@ -11493,13 +11494,482 @@ async function compileGuestLink(options) {
11493
11494
  writeFileSync6(options.optimized, finalized.wasm);
11494
11495
  }
11495
11496
 
11497
+ // src/swift-header-compiler.ts
11498
+ import { createHash as createHash12 } from "node:crypto";
11499
+ import {
11500
+ chmodSync,
11501
+ existsSync as existsSync3,
11502
+ mkdirSync as mkdirSync5,
11503
+ mkdtempSync as mkdtempSync3,
11504
+ readFileSync as readFileSync14,
11505
+ renameSync as renameSync2,
11506
+ rmSync as rmSync5,
11507
+ statSync,
11508
+ writeFileSync as writeFileSync7
11509
+ } from "node:fs";
11510
+ import { createServer } from "node:http";
11511
+ import path22 from "node:path";
11512
+
11513
+ // src/forked-script-contract.ts
11514
+ var PEACH_FORKED_SCRIPT_ENV = "PEACH_RUNS_FORKED_SCRIPTS";
11515
+
11516
+ // src/swift-header-compiler.ts
11517
+ var SWIFT_HEADER_COMPILER_WRAPPER = ".build/peach-swiftc";
11518
+ var argument = (value) => `'${value.replaceAll("'", `'"'"'`)}'`;
11519
+ var client = `const { request } = require('node:http')
11520
+ const { spawnSync } = require('node:child_process')
11521
+ const { existsSync } = require('node:fs')
11522
+ const [socketPath, moduleName, swiftc, receipt, ...args] = process.argv.slice(2)
11523
+ const body = JSON.stringify(args)
11524
+ const notify = (method) => new Promise((resolve, reject) => {
11525
+ const req = request({ socketPath, path: '/' + moduleName, method }, response => {
11526
+ let message = ''
11527
+ response.setEncoding('utf8').on('data', data => { message += data })
11528
+ response.on('end', () => {
11529
+ if (response.statusCode === 200 || response.statusCode === 204) resolve(response.statusCode === 200)
11530
+ else reject(new Error(message))
11531
+ })
11532
+ response.on('error', reject)
11533
+ })
11534
+ req.on('error', reject)
11535
+ req.end(body)
11536
+ })
11537
+ async function compile() {
11538
+ if (existsSync(receipt) && await notify('PUT')) return
11539
+ const result = spawnSync(swiftc, args, { stdio: 'inherit' })
11540
+ if (result.error) throw result.error
11541
+ if (result.status !== 0) { process.exitCode = result.status ?? 1; return }
11542
+ await notify('POST')
11543
+ }
11544
+ compile().catch(error => {
11545
+ process.stderr.write(String(error) + '\\n')
11546
+ process.exitCode = 1
11547
+ })
11548
+ `;
11549
+ function compilerCheckpoint(root, recipe, args, header) {
11550
+ const value = (flag) => {
11551
+ const index = args.lastIndexOf(flag);
11552
+ return index < 0 ? void 0 : args[index + 1];
11553
+ };
11554
+ const outputMap = value("-output-file-map");
11555
+ const module = value("-emit-module-path");
11556
+ if (!outputMap || !module || !args.includes("-whole-module-optimization")) return;
11557
+ const mapText = readFileSync14(outputMap, "utf8");
11558
+ const map = JSON.parse(mapText);
11559
+ if (!isRecord(map) || !isRecord(map[""]) || typeof map[""].dependencies !== "string")
11560
+ return;
11561
+ const objects = [];
11562
+ for (const [source, outputs2] of Object.entries(map)) {
11563
+ if (!source) continue;
11564
+ if (!isRecord(outputs2) || typeof outputs2.object !== "string") return;
11565
+ objects.push(outputs2.object);
11566
+ }
11567
+ if (!objects.length) return;
11568
+ const outputs = [module, header, map[""].dependencies, ...objects];
11569
+ const digest = createHash12("sha256").update(recipe).update(JSON.stringify(args)).update(mapText);
11570
+ for (const flag of args) {
11571
+ if (!flag.startsWith("@")) continue;
11572
+ const response = flag.slice(1);
11573
+ if (!path22.isAbsolute(response) || !existsSync3(response)) return;
11574
+ digest.update(readFileSync14(response));
11575
+ }
11576
+ for (const file of outputs) {
11577
+ if (!file.startsWith(path22.join(root, ".build") + path22.sep)) return;
11578
+ const stat = statSync(file, { bigint: true, throwIfNoEntry: false });
11579
+ if (!stat?.isFile() || stat.size === 0n) return;
11580
+ digest.update(JSON.stringify([file, String(stat.size), String(stat.mtimeNs)]));
11581
+ }
11582
+ return digest.digest("hex");
11583
+ }
11584
+ async function withSwiftHeaderCompiler(root, toolchainBin, recipe, producers, build) {
11585
+ const wrapper = path22.join(root, SWIFT_HEADER_COMPILER_WRAPPER);
11586
+ const script = path22.join(root, ".build", "peach-swift-header.cjs");
11587
+ const checkpoints = path22.join(root, ".build", "peach-swift-header-checkpoints");
11588
+ mkdirSync5(checkpoints, { recursive: true });
11589
+ const swiftc = argument(path22.join(toolchainBin, "swiftc"));
11590
+ writeBuildFile(script, client);
11591
+ writeBuildFile(
11592
+ wrapper,
11593
+ [
11594
+ "#!/bin/sh",
11595
+ "module=; compile=; previous=",
11596
+ 'for flag in "$@"; do',
11597
+ ' if [ "$previous" = -module-name ]; then module=$flag; fi',
11598
+ ' if [ "$flag" = -c ]; then compile=1; fi',
11599
+ " previous=$flag",
11600
+ "done",
11601
+ 'case "$compile:$module" in',
11602
+ ` ${[...producers.keys()].map((name2) => argument(`1:${name2}`)).join("|")})`,
11603
+ ` ${PEACH_FORKED_SCRIPT_ENV}=1 exec ${argument(process.execPath)} ${argument(script)} "$PEACH_SWIFT_HEADER_SOCKET" "$module" ${swiftc} ${argument(checkpoints)}/"$module" "$@" ;;`,
11604
+ "esac",
11605
+ `exec ${swiftc} "$@"`,
11606
+ ""
11607
+ ].join("\n")
11608
+ );
11609
+ chmodSync(wrapper, 493);
11610
+ const directory = mkdtempSync3("/tmp/peach-headers-");
11611
+ const socket = path22.join(directory, "compile");
11612
+ const server = createServer(async (request, response) => {
11613
+ const module = request.url?.slice(1) ?? "";
11614
+ const producer = producers.get(module);
11615
+ if (!producer) {
11616
+ response.writeHead(404).end("unknown Swift header producer");
11617
+ return;
11618
+ }
11619
+ try {
11620
+ const chunks = [];
11621
+ for await (const chunk of request) chunks.push(chunk);
11622
+ const args = JSON.parse(Buffer.concat(chunks).toString());
11623
+ if (!Array.isArray(args) || !args.every((arg) => typeof arg === "string"))
11624
+ throw new Error("invalid Swift compiler arguments");
11625
+ const receipt = path22.join(checkpoints, module);
11626
+ const fingerprint = compilerCheckpoint(root, recipe, args, producer.header);
11627
+ if (request.method === "PUT") {
11628
+ if (!fingerprint || !existsSync3(receipt) || readFileSync14(receipt, "utf8") !== fingerprint) {
11629
+ response.writeHead(204).end();
11630
+ return;
11631
+ }
11632
+ producer.publish();
11633
+ response.end();
11634
+ return;
11635
+ }
11636
+ if (request.method !== "POST")
11637
+ throw new Error("invalid Swift compiler checkpoint method");
11638
+ producer.publish();
11639
+ if (fingerprint) {
11640
+ writeFileSync7(`${receipt}.partial`, fingerprint);
11641
+ renameSync2(`${receipt}.partial`, receipt);
11642
+ }
11643
+ response.end();
11644
+ } catch (error) {
11645
+ response.writeHead(500).end(String(error));
11646
+ }
11647
+ });
11648
+ try {
11649
+ await new Promise((resolve, reject) => {
11650
+ server.once("error", reject);
11651
+ server.listen(socket, resolve);
11652
+ });
11653
+ return await build({ SWIFT_EXEC: wrapper, PEACH_SWIFT_HEADER_SOCKET: socket });
11654
+ } finally {
11655
+ server.close();
11656
+ server.closeAllConnections();
11657
+ rmSync5(directory, { recursive: true, force: true });
11658
+ }
11659
+ }
11660
+
11661
+ // src/swift-header-dependencies.ts
11662
+ import path23 from "node:path";
11663
+
11664
+ // src/swiftContract.ts
11665
+ function isSwiftSourceLinkGraph(value) {
11666
+ if (!value || typeof value !== "object") return false;
11667
+ const text2 = (value2) => typeof value2 === "string" && value2.length > 0 && value2.length <= 4096 && !value2.includes("\0");
11668
+ const entry = Reflect.get(value, "entry");
11669
+ const targets = Reflect.get(value, "targets");
11670
+ if (!text2(entry) || !Array.isArray(targets) || targets.length > 1024) return false;
11671
+ const ids = /* @__PURE__ */ new Set();
11672
+ for (const target of targets) {
11673
+ if (!target || typeof target !== "object") return false;
11674
+ const id = Reflect.get(target, "id");
11675
+ const source = Reflect.get(target, "sourceTarget");
11676
+ const flags = Reflect.get(target, "linkerFlags");
11677
+ const dependencies = Reflect.get(target, "dependencies");
11678
+ const build = Reflect.get(target, "buildVersion");
11679
+ const nullableText = (value2) => value2 === null || text2(value2);
11680
+ if (!text2(id) || ids.has(id) || !(source === null || text2(source)) || !text2(Reflect.get(target, "productName")) || !text2(Reflect.get(target, "productType")) || !nullableText(Reflect.get(target, "installName")) || !build || typeof build !== "object" || !["platform", "minimumOS", "sdk"].every(
11681
+ (key) => nullableText(Reflect.get(build, key))
11682
+ ) || !(Reflect.get(target, "machOType") === null || text2(Reflect.get(target, "machOType"))) || !Array.isArray(flags) || !flags.every(text2) || !Array.isArray(dependencies) || !dependencies.every(
11683
+ (link) => link && typeof link === "object" && text2(Reflect.get(link, "target")) && Array.isArray(Reflect.get(link, "attributes")) && Reflect.get(link, "attributes").every(text2)
11684
+ ))
11685
+ return false;
11686
+ ids.add(id);
11687
+ }
11688
+ return ids.has(entry) && targets.every(
11689
+ (target) => Reflect.get(target, "dependencies").every(
11690
+ (link) => ids.has(link.target)
11691
+ )
11692
+ );
11693
+ }
11694
+ var SWIFT_REMOTE_PACKAGES_DIR = "__packages__";
11695
+ var SWIFT_LOCAL_PACKAGES_DIR = "__local_packages__";
11696
+ var SWIFT_XCODE_BUILD_CONDITION = "__PEACH_XCODE_BUILD";
11697
+ function isBase64Bytes(value) {
11698
+ return value.length % 4 === 0 && /^[A-Za-z0-9+/]*={0,2}(?![\s\S])/.test(value);
11699
+ }
11700
+ function isSwiftPackageFiles(value) {
11701
+ return value !== null && typeof value === "object" && !Array.isArray(value) && Object.entries(value).every(
11702
+ ([file, bytes]) => isSwiftResourcePath(file) && (file.startsWith(`${SWIFT_REMOTE_PACKAGES_DIR}/`) || file.startsWith(`${SWIFT_LOCAL_PACKAGES_DIR}/`)) && typeof bytes === "string" && isBase64Bytes(bytes)
11703
+ );
11704
+ }
11705
+ function swiftProjectFileProblem(file) {
11706
+ if (!isSwiftResourcePath(file)) return "not a relative path of plain segments";
11707
+ if (file === "Package.swift") return "would replace the generated manifest";
11708
+ if (file.split("/").includes(".build")) return "is build output (.build)";
11709
+ if (file.startsWith(".")) return 'starts with "." (hidden file or peach output)';
11710
+ if (file.startsWith(`${SWIFT_REMOTE_PACKAGES_DIR}/`) || file.startsWith(`${SWIFT_LOCAL_PACKAGES_DIR}/`))
11711
+ return "collides with a transported package checkout";
11712
+ return void 0;
11713
+ }
11714
+ function swiftProjectEntryProblem(file, bytes) {
11715
+ return swiftProjectFileProblem(file) ?? (typeof bytes === "string" && isBase64Bytes(bytes) ? void 0 : "bytes are not base64");
11716
+ }
11717
+ function isSwiftProjectFiles(value) {
11718
+ return value !== null && typeof value === "object" && !Array.isArray(value) && Object.entries(value).every(
11719
+ ([file, bytes]) => swiftProjectEntryProblem(file, bytes) === void 0
11720
+ );
11721
+ }
11722
+ function swiftProjectFilesProblems(value) {
11723
+ if (value === null || typeof value !== "object" || Array.isArray(value))
11724
+ return ["projectFiles is not an object"];
11725
+ return Object.entries(value).flatMap(([file, bytes]) => {
11726
+ const problem = swiftProjectEntryProblem(file, bytes);
11727
+ return problem ? [`${file}: ${problem}`] : [];
11728
+ });
11729
+ }
11730
+ var SWIFT_NATIVE_INPUT_ROOT = "$(PEACH_INPUT_ROOT)";
11731
+ var SWIFT_NATIVE_SDK_INCLUDE = "$(PEACH_SDK_INCLUDE)";
11732
+ function isSwiftHeaderAliases(value) {
11733
+ return value !== null && typeof value === "object" && !Array.isArray(value) && Object.entries(value).every(
11734
+ ([alias, file]) => isSwiftResourcePath(alias) && isSwiftResourcePath(file)
11735
+ );
11736
+ }
11737
+ function isSwiftNativeTargets(value) {
11738
+ return swiftNativeTargetsRefusal(value) === null;
11739
+ }
11740
+ function swiftNativeTargetsRefusal(value) {
11741
+ const strings = (value2) => Array.isArray(value2) && value2.every((item) => typeof item === "string" && !item.includes("\0"));
11742
+ const paths = (value2) => strings(value2) && value2.every(isSwiftResourcePath);
11743
+ if (!Array.isArray(value)) return "nativeTargets";
11744
+ if (value.length > 128) return "nativeTargets:length";
11745
+ for (const target of value) {
11746
+ if (!target || typeof target !== "object") return "nativeTargets:shape";
11747
+ const field = (name3) => Reflect.get(target, name3);
11748
+ const name2 = typeof field("name") === "string" ? String(field("name")) : "?";
11749
+ const at = (shape) => `nativeTargets:${name2}:${shape}`;
11750
+ const nullablePath = (key) => field(key) === null || isSwiftResourcePath(field(key));
11751
+ const perFile = field("fileFlags");
11752
+ const directories = field("sourceDirectories");
11753
+ const searches = field("headerSearchPaths");
11754
+ const userSearches = field("userHeaderSearchPaths");
11755
+ const frameworks = field("frameworkSearchPaths");
11756
+ const maps = field("headerMaps");
11757
+ const products = field("productHeaders");
11758
+ const inputPath = (value2) => typeof value2 === "string" && value2.startsWith(`${SWIFT_NATIVE_INPUT_ROOT}/`) && isSwiftResourcePath(value2.slice(SWIFT_NATIVE_INPUT_ROOT.length + 1));
11759
+ const deployment = field("deploymentTarget");
11760
+ const targetName = field("name");
11761
+ if (typeof targetName !== "string" || targetName.length === 0 || targetName.length > 4096 || targetName.includes("\0") || targetName.includes("/") || targetName.includes("\\") || targetName === "." || targetName === "..")
11762
+ return at("name");
11763
+ if (!(deployment === null || typeof deployment === "string" && /^\d+(?:\.\d+){0,2}$/.test(deployment)))
11764
+ return at("deploymentTarget");
11765
+ if (!paths(field("headers"))) return at("headers");
11766
+ if (!paths(field("publicHeaders"))) return at("publicHeaders");
11767
+ if (typeof field("flattensPublicHeaders") !== "boolean")
11768
+ return at("flattensPublicHeaders");
11769
+ if (!nullablePath("bridgingHeader")) return at("bridgingHeader");
11770
+ if (!nullablePath("prefixHeader")) return at("prefixHeader");
11771
+ if (!strings(searches) || !searches.every((item) => item === "." || isSwiftResourcePath(item)))
11772
+ return at("headerSearchPaths");
11773
+ const moduleMaps = field("moduleMaps");
11774
+ if (moduleMaps !== void 0 && (!Array.isArray(moduleMaps) || moduleMaps.length > 128 || !moduleMaps.every((map) => {
11775
+ if (!map || typeof map !== "object") return false;
11776
+ const module = Reflect.get(map, "module");
11777
+ const headers = Reflect.get(map, "headers");
11778
+ return typeof module === "string" && module.length > 0 && module.length <= 4096 && !module.includes("\0") && (headers === "." || isSwiftResourcePath(headers));
11779
+ })))
11780
+ return at("moduleMaps");
11781
+ if (!strings(userSearches) || !userSearches.every((item) => item === "." || isSwiftResourcePath(item)))
11782
+ return at("userHeaderSearchPaths");
11783
+ if (!strings(frameworks) || !frameworks.every((item) => item === "." || isSwiftResourcePath(item)))
11784
+ return at("frameworkSearchPaths");
11785
+ if (!Array.isArray(maps) || !maps.every((map) => {
11786
+ if (!map || typeof map !== "object") return false;
11787
+ const flag = Reflect.get(map, "flag");
11788
+ const entries = Reflect.get(map, "entries");
11789
+ return (flag === "-I" || flag === "-iquote") && Array.isArray(entries) && entries.every(
11790
+ (entry) => Array.isArray(entry) && entry.length === 2 && typeof entry[0] === "string" && !entry[0].includes("\0") && (inputPath(entry[1]) || isSwiftResourcePath(entry[1]))
11791
+ );
11792
+ }))
11793
+ return at("headerMaps");
11794
+ if (!products || typeof products !== "object" || Array.isArray(products) || !Object.entries(products).every(
11795
+ ([product, file]) => isSwiftResourcePath(product) && isSwiftResourcePath(file)
11796
+ ))
11797
+ return at("productHeaders");
11798
+ if (!strings(field("flags"))) return at("flags");
11799
+ if (!strings(field("importerFlags"))) return at("importerFlags");
11800
+ if (!strings(field("cxxFlags"))) return at("cxxFlags");
11801
+ if (!perFile || typeof perFile !== "object" || Array.isArray(perFile) || !Object.entries(perFile).every(
11802
+ ([file, flags]) => isSwiftResourcePath(file) && strings(flags)
11803
+ ))
11804
+ return at("fileFlags");
11805
+ if (!directories || typeof directories !== "object" || Array.isArray(directories) || !Object.entries(directories).every(
11806
+ ([file, directory]) => isSwiftResourcePath(file) && (directory === "." || isSwiftResourcePath(directory))
11807
+ ))
11808
+ return at("sourceDirectories");
11809
+ }
11810
+ return null;
11811
+ }
11812
+ function isSwiftResourcePath(value) {
11813
+ return typeof value === "string" && value.length <= 4096 && !value.startsWith("/") && !value.includes("\\") && !value.includes("\0") && value.split("/").every((part) => part !== "" && part !== "." && part !== "..");
11814
+ }
11815
+ function isSwiftBundlePath(value) {
11816
+ return typeof value === "string" && (value === "." || isSwiftResourcePath(value) && /\.(bundle|framework)$/.test(value));
11817
+ }
11818
+ function isSwiftResourceBundles(value) {
11819
+ return Array.isArray(value) && value.every(
11820
+ (bundle) => typeof bundle === "object" && bundle !== null && typeof bundle.target === "string" && /^[A-Za-z_][A-Za-z0-9_-]*$/.test(bundle.target) && (bundle.sourcePath === "." || isSwiftResourcePath(bundle.sourcePath)) && isSwiftBundlePath(bundle.path)
11821
+ ) && new Set(value.map((bundle) => bundle.target)).size === value.length && new Set(value.map((bundle) => bundle.path)).size === value.length;
11822
+ }
11823
+
11824
+ // src/swift-header-dependencies.ts
11825
+ function* nativeHeaderIncludes(source) {
11826
+ for (const match of source.replace(/\/\*[\s\S]*?\*\//g, "").matchAll(/^\s*#\s*(?:include|import)\s*[<"]([^>"]+)[>"]/gm))
11827
+ yield match[1];
11828
+ }
11829
+ function swiftHeaderDependencies(root, files, targets, nativeTargets, producers, aliases) {
11830
+ const headers = /* @__PURE__ */ new Map();
11831
+ for (const file of files.keys())
11832
+ if (/\.(?:h|hh|hpp|hxx|inc|inl|ipp|def|modulemap)$/.test(file))
11833
+ headers.set(file, /* @__PURE__ */ new Set());
11834
+ const byDirectory = /* @__PURE__ */ new Map();
11835
+ for (const target of targets) {
11836
+ const directory = path23.resolve(root, target.path);
11837
+ const owners = byDirectory.get(directory) ?? /* @__PURE__ */ new Set();
11838
+ owners.add(target.name);
11839
+ byDirectory.set(directory, owners);
11840
+ }
11841
+ const settings = new Map(nativeTargets.map((native) => [native.name, native]));
11842
+ const physicalHeaders = new Map(
11843
+ Object.entries(aliases).map(([alias, file]) => [
11844
+ path23.resolve(root, alias),
11845
+ path23.resolve(root, file)
11846
+ ])
11847
+ );
11848
+ const lookup = new Map(
11849
+ targets.map((target) => {
11850
+ const native = settings.get(target.name);
11851
+ const directory = path23.resolve(root, target.path);
11852
+ const inputPrefix = `${SWIFT_NATIVE_INPUT_ROOT}/`;
11853
+ const flags = native?.importerFlags ?? [];
11854
+ const search = [
11855
+ path23.resolve(directory, target.publicHeadersPath ?? "include"),
11856
+ ...(native?.userHeaderSearchPaths ?? []).map((file) => path23.resolve(root, file)),
11857
+ ...(native?.headerSearchPaths ?? []).map((file) => path23.resolve(root, file)),
11858
+ ...(target.clangSettings ?? []).flatMap(
11859
+ (setting) => "headerSearchPath" in setting ? [path23.resolve(directory, setting.headerSearchPath)] : []
11860
+ ),
11861
+ ...flags.flatMap(
11862
+ (flag, index) => (flags[index - 1] === "-I" || flags[index - 1] === "-iquote") && flag.startsWith(inputPrefix) ? [path23.resolve(root, flag.slice(inputPrefix.length))] : []
11863
+ )
11864
+ ];
11865
+ const mapped = /* @__PURE__ */ new Map();
11866
+ const map = (include, file) => {
11867
+ const key = include.toLowerCase();
11868
+ const files2 = mapped.get(key) ?? [];
11869
+ files2.push(path23.resolve(root, file));
11870
+ mapped.set(key, files2);
11871
+ };
11872
+ for (const headerMap2 of native?.headerMaps ?? []) {
11873
+ for (const [alias, file] of headerMap2.entries) {
11874
+ if (file.startsWith(inputPrefix)) map(alias, file.slice(inputPrefix.length));
11875
+ else {
11876
+ const product = native?.productHeaders[file];
11877
+ if (product) map(alias, product);
11878
+ }
11879
+ }
11880
+ }
11881
+ for (const [alias, file] of Object.entries(native?.productHeaders ?? {}))
11882
+ map(alias, file);
11883
+ if (native?.flattensPublicHeaders)
11884
+ for (const file of native.publicHeaders)
11885
+ map(`${target.name}/${path23.basename(file)}`, file);
11886
+ return [target.name, { search, mapped }];
11887
+ })
11888
+ );
11889
+ const headersByTarget = /* @__PURE__ */ new Map();
11890
+ const ownersOf = (file) => {
11891
+ for (let directory = path23.dirname(file); ; directory = path23.dirname(directory)) {
11892
+ const owners = byDirectory.get(directory);
11893
+ if (owners) return owners;
11894
+ if (directory === root || !directory.startsWith(root + path23.sep)) break;
11895
+ }
11896
+ return /* @__PURE__ */ new Set();
11897
+ };
11898
+ const includers = /* @__PURE__ */ new Map();
11899
+ const enqueue = [];
11900
+ for (const [file, edges] of headers) {
11901
+ const source = files.get(file).toString();
11902
+ const owners = ownersOf(file);
11903
+ for (const owner of owners) {
11904
+ const files2 = headersByTarget.get(owner) ?? /* @__PURE__ */ new Set();
11905
+ files2.add(file);
11906
+ headersByTarget.set(owner, files2);
11907
+ }
11908
+ const moduleMap = file.endsWith(".modulemap");
11909
+ const tokens = moduleMap ? moduleMapTokens(source) : [];
11910
+ const includes = moduleMap ? tokens.flatMap(
11911
+ (token, index) => tokens[index - 1] === "header" && tokens[index - 2] !== "exclude" && token.startsWith('"') ? [token.slice(1, -1)] : []
11912
+ ) : nativeHeaderIncludes(source);
11913
+ for (const include of includes) {
11914
+ const producer = /(?:^|\/)([^/]+)-Swift\.h$/.exec(include)?.[1];
11915
+ if (producer && producers.has(producer)) edges.add(producer);
11916
+ const local = path23.resolve(path23.dirname(file), include);
11917
+ const frameworkHeader = moduleMap && /\.framework\/Modules\//.test(file) ? ["../Headers", "../PrivateHeaders"].map(
11918
+ (directory) => path23.resolve(path23.dirname(file), directory, include)
11919
+ ) : [];
11920
+ const searchPaths = [...owners].flatMap((owner) => {
11921
+ const { search, mapped } = lookup.get(owner);
11922
+ return [
11923
+ ...search.map((directory) => path23.resolve(directory, include)),
11924
+ ...mapped.get(include.toLowerCase()) ?? []
11925
+ ];
11926
+ });
11927
+ for (const qualified of [local, ...frameworkHeader, ...searchPaths]) {
11928
+ const candidate = physicalHeaders.get(qualified) ?? qualified;
11929
+ if (!headers.has(candidate)) continue;
11930
+ const parents = includers.get(candidate) ?? /* @__PURE__ */ new Set();
11931
+ parents.add(file);
11932
+ includers.set(candidate, parents);
11933
+ }
11934
+ }
11935
+ if (edges.size) enqueue.push(file);
11936
+ }
11937
+ for (let index = 0; index < enqueue.length; index++) {
11938
+ const file = enqueue[index];
11939
+ for (const parent of includers.get(file) ?? []) {
11940
+ const edges = headers.get(parent);
11941
+ const before = edges.size;
11942
+ for (const producer of headers.get(file)) edges.add(producer);
11943
+ if (edges.size > before) enqueue.push(parent);
11944
+ }
11945
+ }
11946
+ return new Map(
11947
+ targets.map((target) => {
11948
+ const native = settings.get(target.name);
11949
+ const publicHeaders = [
11950
+ ...native?.headers ?? [],
11951
+ ...native?.publicHeaders ?? [],
11952
+ ...Object.values(native?.productHeaders ?? {}),
11953
+ ...native?.bridgingHeader ? [native.bridgingHeader] : [],
11954
+ ...native?.prefixHeader ? [native.prefixHeader] : []
11955
+ ].map((file) => path23.resolve(root, file));
11956
+ return [
11957
+ target.name,
11958
+ new Set(
11959
+ [...headersByTarget.get(target.name) ?? [], ...publicHeaders].flatMap((file) => [...headers.get(file) ?? []]).filter((producer) => producer !== target.name)
11960
+ )
11961
+ ];
11962
+ })
11963
+ );
11964
+ }
11965
+
11496
11966
  // src/swift-icu.ts
11497
11967
  import { execFile as execFile3 } from "node:child_process";
11498
- import { createHash as createHash12, randomUUID as randomUUID3 } from "node:crypto";
11499
- import { existsSync as existsSync3, readFileSync as readFileSync14 } from "node:fs";
11968
+ import { createHash as createHash13, randomUUID as randomUUID3 } from "node:crypto";
11969
+ import { existsSync as existsSync4, readFileSync as readFileSync15 } from "node:fs";
11500
11970
  import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
11501
11971
  import os3 from "node:os";
11502
- import path22 from "node:path";
11972
+ import path24 from "node:path";
11503
11973
  import { promisify as promisify3 } from "node:util";
11504
11974
  import {
11505
11975
  brotliCompress,
@@ -11574,12 +12044,12 @@ var raw = /* @__PURE__ */ new Map();
11574
12044
  var assets = /* @__PURE__ */ new Map();
11575
12045
  var brotliMemoryCache = /* @__PURE__ */ new Map();
11576
12046
  async function cachedBrotli(bytes, quality, cacheKey) {
11577
- const key = cacheKey && /^[a-f0-9]{64}$/.test(cacheKey) ? cacheKey : createHash12("sha256").update(bytes).digest("hex");
12047
+ const key = cacheKey && /^[a-f0-9]{64}$/.test(cacheKey) ? cacheKey : createHash13("sha256").update(bytes).digest("hex");
11578
12048
  const cacheId = `${quality}:${key}`;
11579
12049
  const cached = brotliMemoryCache.get(cacheId);
11580
12050
  if (cached) return cached;
11581
- const dir = path22.join(os3.homedir(), ".peach", "cache", "swift-brotli");
11582
- const file = path22.join(dir, `${key}${quality === 11 ? "" : "-q4"}.br`);
12051
+ const dir = path24.join(os3.homedir(), ".peach", "cache", "swift-brotli");
12052
+ const file = path24.join(dir, `${key}${quality === 11 ? "" : "-q4"}.br`);
11583
12053
  let compressed;
11584
12054
  try {
11585
12055
  compressed = await readFile(file);
@@ -11627,13 +12097,13 @@ function swiftIcuAsset(toolchainBin, sdk) {
11627
12097
  JSON.stringify([toolchainBin, sdk, swiftSdkOptions()]),
11628
12098
  async () => {
11629
12099
  const zipped = await deflate(await swiftIcuData(toolchainBin, sdk));
11630
- return { sha256: createHash12("sha256").update(zipped).digest("hex"), gzip: zipped };
12100
+ return { sha256: createHash13("sha256").update(zipped).digest("hex"), gzip: zipped };
11631
12101
  }
11632
12102
  );
11633
12103
  }
11634
12104
  async function load(toolchainBin, sdk) {
11635
- const swift = path22.join(toolchainBin, "swift");
11636
- if (!existsSync3(swift))
12105
+ const swift = path24.join(toolchainBin, "swift");
12106
+ if (!existsSync4(swift))
11637
12107
  throw new Error(`swift-icu: no swift at ${swift} for the ${sdk} SDK's icu data`);
11638
12108
  const { stdout: listed } = await run(swift, ["sdk", "list", ...swiftSdkOptions()], {
11639
12109
  env: swiftEnvironment()
@@ -11655,7 +12125,7 @@ async function load(toolchainBin, sdk) {
11655
12125
  const resources = /^swiftStaticResourcesPath: (.+)$/m.exec(stdout)?.[1]?.trim();
11656
12126
  if (!resources) throw new Error(`swift-icu: ${sdk} names no static resources`);
11657
12127
  return Buffer.from(
11658
- icuSegment(archiveMember(readFileSync14(path22.join(resources, ARCHIVE)), MEMBER))
12128
+ icuSegment(archiveMember(readFileSync15(path24.join(resources, ARCHIVE)), MEMBER))
11659
12129
  );
11660
12130
  }
11661
12131
  function archiveMember(archive, name2) {
@@ -11715,21 +12185,21 @@ function swiftIcuAddress(icu) {
11715
12185
  var packedFiles = /* @__PURE__ */ new Map();
11716
12186
  function swiftIcuPacked(icu) {
11717
12187
  return memo(packedFiles, icu.sha256, async () => {
11718
- const file = path22.join(
12188
+ const file = path24.join(
11719
12189
  os3.homedir(),
11720
12190
  ".peach",
11721
12191
  "cache",
11722
12192
  "swift-brotli",
11723
12193
  swiftIcuAddress(icu)
11724
12194
  );
11725
- if (existsSync3(file)) return readFile(file);
12195
+ if (existsSync4(file)) return readFile(file);
11726
12196
  const packed = Buffer.from(
11727
12197
  swiftIcuPack(
11728
12198
  await inflateGzip(icu.gzip),
11729
12199
  (bytes) => deflateRawSync(bytes, { level: 9 })
11730
12200
  )
11731
12201
  );
11732
- await mkdir(path22.dirname(file), { recursive: true });
12202
+ await mkdir(path24.dirname(file), { recursive: true });
11733
12203
  const tmp = `${file}.${randomUUID3()}.tmp`;
11734
12204
  await writeFile(tmp, packed);
11735
12205
  await rename(tmp, file);
@@ -11746,7 +12216,7 @@ async function swiftIcuBundleAsset(icu) {
11746
12216
 
11747
12217
  // src/swift-link-roots.ts
11748
12218
  import fs10 from "node:fs";
11749
- import path23 from "node:path";
12219
+ import path25 from "node:path";
11750
12220
  var leb = (bytes, at) => {
11751
12221
  let value = 0;
11752
12222
  let scale = 1;
@@ -11841,7 +12311,7 @@ function swiftObjcRootObjects(id, root, objects) {
11841
12311
  const cached = rootsByDistribution.get(id);
11842
12312
  if (cached) return cached;
11843
12313
  const measured = objects.map(
11844
- (object3) => [object3, objcRootInfo(fs10.readFileSync(path23.join(root, object3)))]
12314
+ (object3) => [object3, objcRootInfo(fs10.readFileSync(path25.join(root, object3)))]
11845
12315
  );
11846
12316
  const roots = new Set(
11847
12317
  measured.filter(
@@ -11969,41 +12439,41 @@ function swiftObjCModuleMap(module, headers, submodules = /* @__PURE__ */ new Se
11969
12439
  // src/swift-project-user.ts
11970
12440
  import { execFileSync as execFileSync10 } from "node:child_process";
11971
12441
  import {
11972
- chmodSync,
11973
- existsSync as existsSync4,
11974
- mkdirSync as mkdirSync5,
12442
+ chmodSync as chmodSync2,
12443
+ existsSync as existsSync5,
12444
+ mkdirSync as mkdirSync6,
11975
12445
  readdirSync as readdirSync6,
11976
- readFileSync as readFileSync15,
12446
+ readFileSync as readFileSync16,
11977
12447
  realpathSync as realpathSync3,
11978
- rmSync as rmSync5,
11979
- statSync
12448
+ rmSync as rmSync6,
12449
+ statSync as statSync2
11980
12450
  } from "node:fs";
11981
- import path24 from "node:path";
12451
+ import path26 from "node:path";
11982
12452
  function prepareSwiftProjectProcess(root, user) {
11983
12453
  const home = `${root}.project-home`;
11984
- rmSync5(home, { recursive: true, force: true });
11985
- const tmp = path24.join(home, "tmp");
11986
- const swiftpm = path24.join(home, "swiftpm");
11987
- mkdirSync5(tmp, { recursive: true });
11988
- const caches = ["cache", "config", "security"].map((name2) => path24.join(swiftpm, name2));
11989
- for (const directory of caches) mkdirSync5(directory, { recursive: true });
12454
+ rmSync6(home, { recursive: true, force: true });
12455
+ const tmp = path26.join(home, "tmp");
12456
+ const swiftpm = path26.join(home, "swiftpm");
12457
+ mkdirSync6(tmp, { recursive: true });
12458
+ const caches = ["cache", "config", "security"].map((name2) => path26.join(swiftpm, name2));
12459
+ for (const directory of caches) mkdirSync6(directory, { recursive: true });
11990
12460
  execFileSync10("chown", ["-R", "-P", `${user.uid}:${user.gid}`, root, home]);
11991
- chmodSync(root, 448);
11992
- chmodSync(home, 448);
12461
+ chmodSync2(root, 448);
12462
+ chmodSync2(home, 448);
11993
12463
  return {
11994
12464
  uid: user.uid,
11995
12465
  gid: user.gid,
11996
12466
  env: {
11997
12467
  HOME: home,
11998
12468
  TMPDIR: tmp,
11999
- XDG_CONFIG_HOME: path24.join(home, ".config"),
12000
- XDG_CACHE_HOME: path24.join(home, ".cache"),
12001
- XDG_DATA_HOME: path24.join(home, ".local", "share")
12469
+ XDG_CONFIG_HOME: path26.join(home, ".config"),
12470
+ XDG_CACHE_HOME: path26.join(home, ".cache"),
12471
+ XDG_DATA_HOME: path26.join(home, ".local", "share")
12002
12472
  },
12003
12473
  cacheOptions: [
12004
12474
  ...["cache", "config", "security"].flatMap((name2) => [
12005
12475
  `--${name2}-path`,
12006
- path24.join(swiftpm, name2)
12476
+ path26.join(swiftpm, name2)
12007
12477
  ]),
12008
12478
  "--disable-keychain"
12009
12479
  ]
@@ -12018,8 +12488,8 @@ function endSwiftProjectProcesses(user) {
12018
12488
  function projectOutputFile(root, file, user) {
12019
12489
  const real = realpathSync3(file);
12020
12490
  const base = realpathSync3(root);
12021
- const stat = statSync(real);
12022
- if (!real.startsWith(base + path24.sep) || !stat.isFile() || stat.uid !== user.uid) {
12491
+ const stat = statSync2(real);
12492
+ if (!real.startsWith(base + path26.sep) || !stat.isFile() || stat.uid !== user.uid) {
12023
12493
  throw new Error(`swift-compile: project output ${file} is not a file of its build`);
12024
12494
  }
12025
12495
  return real;
@@ -12028,11 +12498,11 @@ function removeProjectLinks(root) {
12028
12498
  const pending = [root];
12029
12499
  for (let directory = pending.pop(); directory; directory = pending.pop()) {
12030
12500
  for (const entry of readdirSync6(directory, { withFileTypes: true })) {
12031
- const full = path24.join(directory, entry.name);
12501
+ const full = path26.join(directory, entry.name);
12032
12502
  if (directory === root && entry.name === ".build") continue;
12033
12503
  if (directory === root && entry.name.startsWith(".peach-modules-")) {
12034
- rmSync5(full, { recursive: true, force: true });
12035
- } else if (entry.isSymbolicLink()) rmSync5(full);
12504
+ rmSync6(full, { recursive: true, force: true });
12505
+ } else if (entry.isSymbolicLink()) rmSync6(full);
12036
12506
  else if (entry.isDirectory()) pending.push(full);
12037
12507
  }
12038
12508
  }
@@ -12060,19 +12530,19 @@ function swiftReproducibleBuildFlags(roots) {
12060
12530
  import {
12061
12531
  spawn as spawn4
12062
12532
  } from "node:child_process";
12063
- import { createHash as createHash13, randomUUID as randomUUID4 } from "node:crypto";
12533
+ import { createHash as createHash14, randomUUID as randomUUID4 } from "node:crypto";
12064
12534
  import {
12065
- existsSync as existsSync5,
12535
+ existsSync as existsSync6,
12066
12536
  linkSync,
12067
- mkdirSync as mkdirSync6,
12537
+ mkdirSync as mkdirSync7,
12068
12538
  readdirSync as readdirSync7,
12069
- readFileSync as readFileSync16,
12539
+ readFileSync as readFileSync17,
12070
12540
  realpathSync as realpathSync5,
12071
- rmSync as rmSync6,
12072
- writeFileSync as writeFileSync7
12541
+ rmSync as rmSync7,
12542
+ writeFileSync as writeFileSync8
12073
12543
  } from "node:fs";
12074
12544
  import { homedir as homedir2 } from "node:os";
12075
- import path25 from "node:path";
12545
+ import path27 from "node:path";
12076
12546
  var POLL_MS = 250;
12077
12547
  var INSPECT_ATTEMPTS = 5;
12078
12548
  var START_TOLERANCE_MS = 2e3;
@@ -12138,7 +12608,7 @@ function generationNumbers(directory) {
12138
12608
  function readGeneration(directory, number3) {
12139
12609
  let owner;
12140
12610
  try {
12141
- owner = readFileSync16(path25.join(directory, name(number3, "owner")), "utf8");
12611
+ owner = readFileSync17(path27.join(directory, name(number3, "owner")), "utf8");
12142
12612
  } catch (error) {
12143
12613
  if (errorCode(error) === "ENOENT") return null;
12144
12614
  throw error;
@@ -12151,7 +12621,7 @@ function readGeneration(directory, number3) {
12151
12621
  }
12152
12622
  function readChildren(directory, number3) {
12153
12623
  const prefix = name(number3, "child.");
12154
- return readdirSync7(directory).filter((entry) => entry.startsWith(prefix)).map((entry) => parseIdentity(readFileSync16(path25.join(directory, entry), "utf8")));
12624
+ return readdirSync7(directory).filter((entry) => entry.startsWith(prefix)).map((entry) => parseIdentity(readFileSync17(path27.join(directory, entry), "utf8")));
12155
12625
  }
12156
12626
  function groupAlive(table, leader) {
12157
12627
  const row = table.find((candidate) => candidate.pid === leader.pid);
@@ -12159,30 +12629,30 @@ function groupAlive(table, leader) {
12159
12629
  return table.some((candidate) => candidate.pgid === leader.pid && !candidate.zombie);
12160
12630
  }
12161
12631
  function canonicalRoot(root) {
12162
- let existing = path25.resolve(root);
12632
+ let existing = path27.resolve(root);
12163
12633
  const missing = [];
12164
- while (!existsSync5(existing) && path25.dirname(existing) !== existing) {
12165
- missing.unshift(path25.basename(existing));
12166
- existing = path25.dirname(existing);
12634
+ while (!existsSync6(existing) && path27.dirname(existing) !== existing) {
12635
+ missing.unshift(path27.basename(existing));
12636
+ existing = path27.dirname(existing);
12167
12637
  }
12168
- return path25.join(realpathSync5(existing), ...missing);
12638
+ return path27.join(realpathSync5(existing), ...missing);
12169
12639
  }
12170
12640
  function swiftRootLocksDir() {
12171
- return path25.join(homedir2(), ".peach", "cache", "swift-root-locks");
12641
+ return path27.join(homedir2(), ".peach", "cache", "swift-root-locks");
12172
12642
  }
12173
12643
  async function withSwiftRootLock(root, work, signal, wait = true) {
12174
- const directory = path25.join(
12644
+ const directory = path27.join(
12175
12645
  swiftRootLocksDir(),
12176
- createHash13("sha256").update(canonicalRoot(root)).digest("hex").slice(0, 32)
12646
+ createHash14("sha256").update(canonicalRoot(root)).digest("hex").slice(0, 32)
12177
12647
  );
12178
- mkdirSync6(directory, { recursive: true });
12648
+ mkdirSync7(directory, { recursive: true });
12179
12649
  const token = randomUUID4();
12180
12650
  const ownRow = (await processTableWithRetry(process.pid, signal)).find(
12181
12651
  (candidate) => candidate.pid === process.pid && !candidate.zombie
12182
12652
  );
12183
12653
  if (!ownRow) throw new Error(`swift root lock cannot find process ${process.pid}`);
12184
12654
  const owner = JSON.stringify({ pid: process.pid, start: ownRow.start });
12185
- const pending = path25.join(directory, `pending.${token}`);
12655
+ const pending = path27.join(directory, `pending.${token}`);
12186
12656
  let held = 0;
12187
12657
  let announced = 0;
12188
12658
  let current = null;
@@ -12221,18 +12691,18 @@ async function withSwiftRootLock(root, work, signal, wait = true) {
12221
12691
  }
12222
12692
  }
12223
12693
  }
12224
- writeFileSync7(pending, owner);
12694
+ writeFileSync8(pending, owner);
12225
12695
  try {
12226
- linkSync(pending, path25.join(directory, name(newest + 1, "owner")));
12696
+ linkSync(pending, path27.join(directory, name(newest + 1, "owner")));
12227
12697
  } catch (error) {
12228
12698
  if (errorCode(error) === "EEXIST") continue;
12229
12699
  throw error;
12230
12700
  } finally {
12231
- rmSync6(pending, { force: true });
12701
+ rmSync7(pending, { force: true });
12232
12702
  }
12233
12703
  const numbers = generationNumbers(directory);
12234
12704
  if (numbers.at(-1) !== newest + 1) {
12235
- rmSync6(path25.join(directory, name(newest + 1, "owner")), { force: true });
12705
+ rmSync7(path27.join(directory, name(newest + 1, "owner")), { force: true });
12236
12706
  continue;
12237
12707
  }
12238
12708
  held = newest + 1;
@@ -12240,7 +12710,7 @@ async function withSwiftRootLock(root, work, signal, wait = true) {
12240
12710
  if (number3 < held) {
12241
12711
  for (const entry of readdirSync7(directory))
12242
12712
  if (entry.startsWith(name(number3, "")))
12243
- rmSync6(path25.join(directory, entry), { force: true });
12713
+ rmSync7(path27.join(directory, entry), { force: true });
12244
12714
  }
12245
12715
  break;
12246
12716
  }
@@ -12251,10 +12721,10 @@ async function withSwiftRootLock(root, work, signal, wait = true) {
12251
12721
  if (child.pid === void 0) throw new Error("could not register compiler process");
12252
12722
  const childPending = `${pending}.child.${index}`;
12253
12723
  try {
12254
- writeFileSync7(childPending, JSON.stringify(ownIdentity(child.pid)));
12255
- linkSync(childPending, path25.join(directory, name(held, `child.${index}`)));
12724
+ writeFileSync8(childPending, JSON.stringify(ownIdentity(child.pid)));
12725
+ linkSync(childPending, path27.join(directory, name(held, `child.${index}`)));
12256
12726
  } finally {
12257
- rmSync6(childPending, { force: true });
12727
+ rmSync7(childPending, { force: true });
12258
12728
  }
12259
12729
  },
12260
12730
  spawn(command, args, options, companion) {
@@ -12284,18 +12754,18 @@ async function withSwiftRootLock(root, work, signal, wait = true) {
12284
12754
  return await work(lease);
12285
12755
  } finally {
12286
12756
  await Promise.all(children.map((child) => terminateProcessGroup(child, "SIGKILL", 0)));
12287
- writeFileSync7(path25.join(directory, name(held, "released")), "");
12757
+ writeFileSync8(path27.join(directory, name(held, "released")), "");
12288
12758
  }
12289
12759
  }
12290
12760
 
12291
12761
  // src/swift-uniform-type-constants.ts
12292
12762
  import { execFileSync as execFileSync11 } from "node:child_process";
12293
- import path26 from "node:path";
12763
+ import path28 from "node:path";
12294
12764
  function compileUniformTypeConstants(args) {
12295
- const source = path26.join(args.packageRoot, "runtime/UniformTypeIdentifiersConstants.m");
12296
- const object3 = path26.join(args.out, "UniformTypeIdentifiers-NativeConstants.o");
12765
+ const source = path28.join(args.packageRoot, "runtime/UniformTypeIdentifiersConstants.m");
12766
+ const object3 = path28.join(args.out, "UniformTypeIdentifiers-NativeConstants.o");
12297
12767
  execFileSync11(
12298
- path26.join(args.bin, "clang"),
12768
+ path28.join(args.bin, "clang"),
12299
12769
  [
12300
12770
  "--target=wasm64-unknown-wasip1",
12301
12771
  `--sysroot=${args.sysroot}`,
@@ -12304,7 +12774,7 @@ function compileUniformTypeConstants(args) {
12304
12774
  ...swiftObjCRuntimeFlags,
12305
12775
  "-fwasm-exceptions",
12306
12776
  "-F",
12307
- path26.resolve(args.packageRoot, "../peachsim/sdk/ios/System/Library/Frameworks"),
12777
+ path28.resolve(args.packageRoot, "../peachsim/sdk/ios/System/Library/Frameworks"),
12308
12778
  ...objcSdkIntakeFlags(args.darwin, args.bin, args.minimum),
12309
12779
  "-c",
12310
12780
  source,
@@ -12316,174 +12786,14 @@ function compileUniformTypeConstants(args) {
12316
12786
  return object3;
12317
12787
  }
12318
12788
 
12319
- // src/swiftContract.ts
12320
- function isSwiftSourceLinkGraph(value) {
12321
- if (!value || typeof value !== "object") return false;
12322
- const text2 = (value2) => typeof value2 === "string" && value2.length > 0 && value2.length <= 4096 && !value2.includes("\0");
12323
- const entry = Reflect.get(value, "entry");
12324
- const targets = Reflect.get(value, "targets");
12325
- if (!text2(entry) || !Array.isArray(targets) || targets.length > 1024) return false;
12326
- const ids = /* @__PURE__ */ new Set();
12327
- for (const target of targets) {
12328
- if (!target || typeof target !== "object") return false;
12329
- const id = Reflect.get(target, "id");
12330
- const source = Reflect.get(target, "sourceTarget");
12331
- const flags = Reflect.get(target, "linkerFlags");
12332
- const dependencies = Reflect.get(target, "dependencies");
12333
- const build = Reflect.get(target, "buildVersion");
12334
- const nullableText = (value2) => value2 === null || text2(value2);
12335
- if (!text2(id) || ids.has(id) || !(source === null || text2(source)) || !text2(Reflect.get(target, "productName")) || !text2(Reflect.get(target, "productType")) || !nullableText(Reflect.get(target, "installName")) || !build || typeof build !== "object" || !["platform", "minimumOS", "sdk"].every(
12336
- (key) => nullableText(Reflect.get(build, key))
12337
- ) || !(Reflect.get(target, "machOType") === null || text2(Reflect.get(target, "machOType"))) || !Array.isArray(flags) || !flags.every(text2) || !Array.isArray(dependencies) || !dependencies.every(
12338
- (link) => link && typeof link === "object" && text2(Reflect.get(link, "target")) && Array.isArray(Reflect.get(link, "attributes")) && Reflect.get(link, "attributes").every(text2)
12339
- ))
12340
- return false;
12341
- ids.add(id);
12342
- }
12343
- return ids.has(entry) && targets.every(
12344
- (target) => Reflect.get(target, "dependencies").every(
12345
- (link) => ids.has(link.target)
12346
- )
12347
- );
12348
- }
12349
- var SWIFT_REMOTE_PACKAGES_DIR = "__packages__";
12350
- var SWIFT_LOCAL_PACKAGES_DIR = "__local_packages__";
12351
- var SWIFT_XCODE_BUILD_CONDITION = "__PEACH_XCODE_BUILD";
12352
- function isBase64Bytes(value) {
12353
- return value.length % 4 === 0 && /^[A-Za-z0-9+/]*={0,2}(?![\s\S])/.test(value);
12354
- }
12355
- function isSwiftPackageFiles(value) {
12356
- return value !== null && typeof value === "object" && !Array.isArray(value) && Object.entries(value).every(
12357
- ([file, bytes]) => isSwiftResourcePath(file) && (file.startsWith(`${SWIFT_REMOTE_PACKAGES_DIR}/`) || file.startsWith(`${SWIFT_LOCAL_PACKAGES_DIR}/`)) && typeof bytes === "string" && isBase64Bytes(bytes)
12358
- );
12359
- }
12360
- function swiftProjectFileProblem(file) {
12361
- if (!isSwiftResourcePath(file)) return "not a relative path of plain segments";
12362
- if (file === "Package.swift") return "would replace the generated manifest";
12363
- if (file.split("/").includes(".build")) return "is build output (.build)";
12364
- if (file.startsWith(".")) return 'starts with "." (hidden file or peach output)';
12365
- if (file.startsWith(`${SWIFT_REMOTE_PACKAGES_DIR}/`) || file.startsWith(`${SWIFT_LOCAL_PACKAGES_DIR}/`))
12366
- return "collides with a transported package checkout";
12367
- return void 0;
12368
- }
12369
- function swiftProjectEntryProblem(file, bytes) {
12370
- return swiftProjectFileProblem(file) ?? (typeof bytes === "string" && isBase64Bytes(bytes) ? void 0 : "bytes are not base64");
12371
- }
12372
- function isSwiftProjectFiles(value) {
12373
- return value !== null && typeof value === "object" && !Array.isArray(value) && Object.entries(value).every(
12374
- ([file, bytes]) => swiftProjectEntryProblem(file, bytes) === void 0
12375
- );
12376
- }
12377
- function swiftProjectFilesProblems(value) {
12378
- if (value === null || typeof value !== "object" || Array.isArray(value))
12379
- return ["projectFiles is not an object"];
12380
- return Object.entries(value).flatMap(([file, bytes]) => {
12381
- const problem = swiftProjectEntryProblem(file, bytes);
12382
- return problem ? [`${file}: ${problem}`] : [];
12383
- });
12384
- }
12385
- var SWIFT_NATIVE_INPUT_ROOT = "$(PEACH_INPUT_ROOT)";
12386
- var SWIFT_NATIVE_SDK_INCLUDE = "$(PEACH_SDK_INCLUDE)";
12387
- function isSwiftHeaderAliases(value) {
12388
- return value !== null && typeof value === "object" && !Array.isArray(value) && Object.entries(value).every(
12389
- ([alias, file]) => isSwiftResourcePath(alias) && isSwiftResourcePath(file)
12390
- );
12391
- }
12392
- function isSwiftNativeTargets(value) {
12393
- return swiftNativeTargetsRefusal(value) === null;
12394
- }
12395
- function swiftNativeTargetsRefusal(value) {
12396
- const strings = (value2) => Array.isArray(value2) && value2.every((item) => typeof item === "string" && !item.includes("\0"));
12397
- const paths = (value2) => strings(value2) && value2.every(isSwiftResourcePath);
12398
- if (!Array.isArray(value)) return "nativeTargets";
12399
- if (value.length > 128) return "nativeTargets:length";
12400
- for (const target of value) {
12401
- if (!target || typeof target !== "object") return "nativeTargets:shape";
12402
- const field = (name3) => Reflect.get(target, name3);
12403
- const name2 = typeof field("name") === "string" ? String(field("name")) : "?";
12404
- const at = (shape) => `nativeTargets:${name2}:${shape}`;
12405
- const nullablePath = (key) => field(key) === null || isSwiftResourcePath(field(key));
12406
- const perFile = field("fileFlags");
12407
- const directories = field("sourceDirectories");
12408
- const searches = field("headerSearchPaths");
12409
- const userSearches = field("userHeaderSearchPaths");
12410
- const frameworks = field("frameworkSearchPaths");
12411
- const maps = field("headerMaps");
12412
- const products = field("productHeaders");
12413
- const inputPath = (value2) => typeof value2 === "string" && value2.startsWith(`${SWIFT_NATIVE_INPUT_ROOT}/`) && isSwiftResourcePath(value2.slice(SWIFT_NATIVE_INPUT_ROOT.length + 1));
12414
- const deployment = field("deploymentTarget");
12415
- const targetName = field("name");
12416
- if (typeof targetName !== "string" || targetName.length === 0 || targetName.length > 4096 || targetName.includes("\0") || targetName.includes("/") || targetName.includes("\\") || targetName === "." || targetName === "..")
12417
- return at("name");
12418
- if (!(deployment === null || typeof deployment === "string" && /^\d+(?:\.\d+){0,2}$/.test(deployment)))
12419
- return at("deploymentTarget");
12420
- if (!paths(field("headers"))) return at("headers");
12421
- if (!paths(field("publicHeaders"))) return at("publicHeaders");
12422
- if (typeof field("flattensPublicHeaders") !== "boolean")
12423
- return at("flattensPublicHeaders");
12424
- if (!nullablePath("bridgingHeader")) return at("bridgingHeader");
12425
- if (!nullablePath("prefixHeader")) return at("prefixHeader");
12426
- if (!strings(searches) || !searches.every((item) => item === "." || isSwiftResourcePath(item)))
12427
- return at("headerSearchPaths");
12428
- const moduleMaps = field("moduleMaps");
12429
- if (moduleMaps !== void 0 && (!Array.isArray(moduleMaps) || moduleMaps.length > 128 || !moduleMaps.every((map) => {
12430
- if (!map || typeof map !== "object") return false;
12431
- const module = Reflect.get(map, "module");
12432
- const headers = Reflect.get(map, "headers");
12433
- return typeof module === "string" && module.length > 0 && module.length <= 4096 && !module.includes("\0") && (headers === "." || isSwiftResourcePath(headers));
12434
- })))
12435
- return at("moduleMaps");
12436
- if (!strings(userSearches) || !userSearches.every((item) => item === "." || isSwiftResourcePath(item)))
12437
- return at("userHeaderSearchPaths");
12438
- if (!strings(frameworks) || !frameworks.every((item) => item === "." || isSwiftResourcePath(item)))
12439
- return at("frameworkSearchPaths");
12440
- if (!Array.isArray(maps) || !maps.every((map) => {
12441
- if (!map || typeof map !== "object") return false;
12442
- const flag = Reflect.get(map, "flag");
12443
- const entries = Reflect.get(map, "entries");
12444
- return (flag === "-I" || flag === "-iquote") && Array.isArray(entries) && entries.every(
12445
- (entry) => Array.isArray(entry) && entry.length === 2 && typeof entry[0] === "string" && !entry[0].includes("\0") && (inputPath(entry[1]) || isSwiftResourcePath(entry[1]))
12446
- );
12447
- }))
12448
- return at("headerMaps");
12449
- if (!products || typeof products !== "object" || Array.isArray(products) || !Object.entries(products).every(
12450
- ([product, file]) => isSwiftResourcePath(product) && isSwiftResourcePath(file)
12451
- ))
12452
- return at("productHeaders");
12453
- if (!strings(field("flags"))) return at("flags");
12454
- if (!strings(field("importerFlags"))) return at("importerFlags");
12455
- if (!strings(field("cxxFlags"))) return at("cxxFlags");
12456
- if (!perFile || typeof perFile !== "object" || Array.isArray(perFile) || !Object.entries(perFile).every(
12457
- ([file, flags]) => isSwiftResourcePath(file) && strings(flags)
12458
- ))
12459
- return at("fileFlags");
12460
- if (!directories || typeof directories !== "object" || Array.isArray(directories) || !Object.entries(directories).every(
12461
- ([file, directory]) => isSwiftResourcePath(file) && (directory === "." || isSwiftResourcePath(directory))
12462
- ))
12463
- return at("sourceDirectories");
12464
- }
12465
- return null;
12466
- }
12467
- function isSwiftResourcePath(value) {
12468
- return typeof value === "string" && value.length <= 4096 && !value.startsWith("/") && !value.includes("\\") && !value.includes("\0") && value.split("/").every((part) => part !== "" && part !== "." && part !== "..");
12469
- }
12470
- function isSwiftBundlePath(value) {
12471
- return typeof value === "string" && (value === "." || isSwiftResourcePath(value) && /\.(bundle|framework)$/.test(value));
12472
- }
12473
- function isSwiftResourceBundles(value) {
12474
- return Array.isArray(value) && value.every(
12475
- (bundle) => typeof bundle === "object" && bundle !== null && typeof bundle.target === "string" && /^[A-Za-z_][A-Za-z0-9_-]*$/.test(bundle.target) && (bundle.sourcePath === "." || isSwiftResourcePath(bundle.sourcePath)) && isSwiftBundlePath(bundle.path)
12476
- ) && new Set(value.map((bundle) => bundle.target)).size === value.length && new Set(value.map((bundle) => bundle.path)).size === value.length;
12477
- }
12478
-
12479
12789
  // src/xcode-header-search.ts
12480
12790
  import fs11 from "node:fs";
12481
- import path27 from "node:path";
12791
+ import path29 from "node:path";
12482
12792
  function coalescibleHeaderOverlays(files) {
12483
12793
  const aliases = /* @__PURE__ */ new Map();
12484
12794
  const key = (file) => file.replace(/[A-Z]/g, (letter) => letter.toLowerCase());
12485
12795
  const index = (directory, entry) => {
12486
- const name2 = path27.resolve(directory, entry.name);
12796
+ const name2 = path29.resolve(directory, entry.name);
12487
12797
  if (entry.type === "directory")
12488
12798
  return entry.contents.every((child) => index(name2, child));
12489
12799
  const source = entry["external-contents"];
@@ -12494,11 +12804,11 @@ function coalescibleHeaderOverlays(files) {
12494
12804
  };
12495
12805
  for (const file of files) {
12496
12806
  const overlay = JSON.parse(fs11.readFileSync(file, "utf8"));
12497
- if (!overlay.roots.every((entry) => index(path27.dirname(file), entry)))
12807
+ if (!overlay.roots.every((entry) => index(path29.dirname(file), entry)))
12498
12808
  return /* @__PURE__ */ new Set();
12499
12809
  }
12500
12810
  for (const file of [...files, ...aliases.values()]) {
12501
- const source = aliases.get(key(path27.normalize(file)));
12811
+ const source = aliases.get(key(path29.normalize(file)));
12502
12812
  if (source !== void 0 && source !== file) return /* @__PURE__ */ new Set();
12503
12813
  }
12504
12814
  return files;
@@ -12558,11 +12868,11 @@ function writeXcodeHeaderSearch(directory, targets, headerAliases = {}) {
12558
12868
  seen.add(file);
12559
12869
  file = headerAliases[file];
12560
12870
  }
12561
- const listed = productDirectories.get(path27.dirname(product)) ?? [];
12562
- productDirectories.set(path27.dirname(product), listed);
12563
- listed.push({ name: path27.basename(product), file });
12871
+ const listed = productDirectories.get(path29.dirname(product)) ?? [];
12872
+ productDirectories.set(path29.dirname(product), listed);
12873
+ listed.push({ name: path29.basename(product), file });
12564
12874
  }
12565
- const overlay = path27.join(directory, "all-product-headers.yaml");
12875
+ const overlay = path29.join(directory, "all-product-headers.yaml");
12566
12876
  writeBuildFile(
12567
12877
  overlay,
12568
12878
  JSON.stringify({
@@ -12582,7 +12892,7 @@ function writeXcodeHeaderSearch(directory, targets, headerAliases = {}) {
12582
12892
  const files = [overlay];
12583
12893
  const flags = targets.map((target, index) => {
12584
12894
  const maps = target.headerMaps.map((map, order) => {
12585
- const file = path27.join(directory, `${index}-${order}.hmap`);
12895
+ const file = path29.join(directory, `${index}-${order}.hmap`);
12586
12896
  writeBuildFile(file, headerMap(map.entries));
12587
12897
  files.push(file);
12588
12898
  return { flag: map.flag, file };
@@ -12702,37 +13012,37 @@ function swiftBuildJobs() {
12702
13012
  );
12703
13013
  }
12704
13014
  function swiftDistributionAt(root) {
12705
- const file = path28.join(root, SWIFT_DISTRIBUTION_MANIFEST);
12706
- if (!existsSync6(file)) return null;
12707
- return parseSwiftDistributionManifest(JSON.parse(readFileSync17(file, "utf8")));
13015
+ const file = path30.join(root, SWIFT_DISTRIBUTION_MANIFEST);
13016
+ if (!existsSync7(file)) return null;
13017
+ return parseSwiftDistributionManifest(JSON.parse(readFileSync18(file, "utf8")));
12708
13018
  }
12709
13019
  var REACH_STAGED_FRAMEWORKS = /* @__PURE__ */ new Set(["React"]);
12710
13020
  function swiftModuleInterface(moduleRoot, name2, interfaceRoot) {
12711
13021
  if (REACH_STAGED_FRAMEWORKS.has(name2)) return null;
12712
13022
  if (swiftDistributionAt(moduleRoot)) {
12713
- const file = path28.join(
12714
- interfaceRoot ?? path28.join(moduleRoot, "modules"),
13023
+ const file = path30.join(
13024
+ interfaceRoot ?? path30.join(moduleRoot, "modules"),
12715
13025
  `${name2}-Swift.h`
12716
13026
  );
12717
- if (!existsSync6(file)) return null;
12718
- const header = clangInterfaceHeader(readFileSync17(file, "utf8"));
13027
+ if (!existsSync7(file)) return null;
13028
+ const header = clangInterfaceHeader(readFileSync18(file, "utf8"));
12719
13029
  return { declared: swiftInterfaceDeclarations(header), header };
12720
13030
  }
12721
- const sources = path28.join(moduleRoot, "Sources", name2);
12722
- const built = path28.join(moduleRoot, ".build/host", `${name2}-Swift.h`);
12723
- if (!existsSync6(sources) || !existsSync6(built)) return null;
13031
+ const sources = path30.join(moduleRoot, "Sources", name2);
13032
+ const built = path30.join(moduleRoot, ".build/host", `${name2}-Swift.h`);
13033
+ if (!existsSync7(sources) || !existsSync7(built)) return null;
12724
13034
  const declared = /* @__PURE__ */ new Set();
12725
13035
  for (const file of readdirSync8(sources, { recursive: true, encoding: "utf8" }))
12726
13036
  if (file.endsWith(".swift"))
12727
- for (const [, objc, subclass] of readFileSync17(
12728
- path28.join(sources, file),
13037
+ for (const [, objc, subclass] of readFileSync18(
13038
+ path30.join(sources, file),
12729
13039
  "utf8"
12730
13040
  ).matchAll(
12731
13041
  /@objc\((\w+)\)\s+(?:\w+\s+)*?(?:protocol|class)\s|^(?:public|open)\s+(?:final\s+)?class\s+(\w+)\s*:\s*NSObject\b/gm
12732
13042
  ))
12733
13043
  declared.add(objc ?? subclass);
12734
13044
  if (declared.size === 0) return null;
12735
- return { declared, header: clangInterfaceHeader(readFileSync17(built, "utf8")) };
13045
+ return { declared, header: clangInterfaceHeader(readFileSync18(built, "utf8")) };
12736
13046
  }
12737
13047
  var clangInterfaceHeader = (header) => header.replace(/^@import (?:UIKitCore|UIKitText);$/gm, "@import UIKit;").replace(
12738
13048
  /^@import (?:CoreFoundation|FoundationNetworking);$/gm,
@@ -12765,11 +13075,11 @@ function sdkObjCDeclarationOwners(frameworks) {
12765
13075
  const owners = /* @__PURE__ */ new Map();
12766
13076
  for (const framework of readdirSync8(frameworks))
12767
13077
  if (framework.endsWith(".framework")) {
12768
- const headers = path28.join(frameworks, framework, "Headers");
12769
- if (existsSync6(headers)) {
13078
+ const headers = path30.join(frameworks, framework, "Headers");
13079
+ if (existsSync7(headers)) {
12770
13080
  for (const file of readdirSync8(headers, { recursive: true, encoding: "utf8" }))
12771
13081
  if (file.endsWith(".h")) {
12772
- const header = readFileSync17(path28.join(headers, file), "utf8");
13082
+ const header = readFileSync18(path30.join(headers, file), "utf8");
12773
13083
  for (const name2 of [
12774
13084
  ...swiftInterfaceDeclarations(header),
12775
13085
  ...objcEnumerations(header),
@@ -12865,25 +13175,25 @@ function swiftCompileSdkOptions(moduleRoot, toolchainBin) {
12865
13175
  );
12866
13176
  }
12867
13177
  function swiftObjCSelectorOptions(moduleRoot) {
12868
- let map = path28.join(moduleRoot, SWIFT_DISTRIBUTION_OBJC_SELECTORS);
13178
+ let map = path30.join(moduleRoot, SWIFT_DISTRIBUTION_OBJC_SELECTORS);
12869
13179
  if (!swiftDistributionAt(moduleRoot)) {
12870
13180
  const classes = {};
12871
13181
  for (const framework of ["UIKitCore", "WebKit"])
12872
13182
  for (const [name2, members] of Object.entries(
12873
13183
  JSON.parse(
12874
- readFileSync17(
12875
- path28.join(moduleRoot, "Sources", framework, "ObjCSelectors.json"),
13184
+ readFileSync18(
13185
+ path30.join(moduleRoot, "Sources", framework, "ObjCSelectors.json"),
12876
13186
  "utf8"
12877
13187
  )
12878
13188
  ).classes
12879
13189
  ))
12880
13190
  classes[name2] = [...classes[name2] ?? [], ...members];
12881
- map = path28.join(moduleRoot, ".build", SWIFT_DISTRIBUTION_OBJC_SELECTORS);
12882
- mkdirSync7(path28.dirname(map), { recursive: true });
13191
+ map = path30.join(moduleRoot, ".build", SWIFT_DISTRIBUTION_OBJC_SELECTORS);
13192
+ mkdirSync8(path30.dirname(map), { recursive: true });
12883
13193
  const partial = `${map}.${randomUUID5()}`;
12884
- writeFileSync8(partial, `${JSON.stringify({ classes }, null, 2)}
13194
+ writeFileSync9(partial, `${JSON.stringify({ classes }, null, 2)}
12885
13195
  `);
12886
- renameSync2(partial, map);
13196
+ renameSync3(partial, map);
12887
13197
  }
12888
13198
  return ["-Xswiftc", "-Xllvm", "-Xswiftc", `-peach-objc-selector-map=${map}`];
12889
13199
  }
@@ -12917,7 +13227,7 @@ function swiftModuleInputFiles(root) {
12917
13227
  "toolchain.json"
12918
13228
  ];
12919
13229
  const walk = (dir) => {
12920
- for (const entry of readdirSync8(path28.join(root, dir), {
13230
+ for (const entry of readdirSync8(path30.join(root, dir), {
12921
13231
  withFileTypes: true
12922
13232
  })) {
12923
13233
  const relative = `${dir}/${entry.name}`;
@@ -12931,46 +13241,46 @@ function swiftModuleInputFiles(root) {
12931
13241
  walk("ios-simulator-stdlib");
12932
13242
  return files.sort();
12933
13243
  }
12934
- function swiftMacroPlugins(moduleRoot, dir = path28.join(moduleRoot, ".build/host/RnxPreviewMacros")) {
13244
+ function swiftMacroPlugins(moduleRoot, dir = path30.join(moduleRoot, ".build/host/RnxPreviewMacros")) {
12935
13245
  const distribution = swiftDistributionAt(moduleRoot);
12936
13246
  if (distribution)
12937
13247
  return {
12938
- libraries: distribution.plugins.filter((plugin) => path28.basename(plugin) !== "ExpoModulesMacros").map((plugin) => path28.join(moduleRoot, plugin)),
12939
- executables: distribution.plugins.filter((plugin) => path28.basename(plugin) === "ExpoModulesMacros").map((plugin) => path28.join(moduleRoot, plugin)),
13248
+ libraries: distribution.plugins.filter((plugin) => path30.basename(plugin) !== "ExpoModulesMacros").map((plugin) => path30.join(moduleRoot, plugin)),
13249
+ executables: distribution.plugins.filter((plugin) => path30.basename(plugin) === "ExpoModulesMacros").map((plugin) => path30.join(moduleRoot, plugin)),
12940
13250
  stale: false
12941
13251
  };
12942
13252
  const release = JSON.parse(
12943
- readFileSync17(path28.join(moduleRoot, "toolchain.json"), "utf8")
13253
+ readFileSync18(path30.join(moduleRoot, "toolchain.json"), "utf8")
12944
13254
  ).release;
12945
- const compilerStamp = path28.join(dir, "compiler-release");
12946
- const pluginScript = path28.join(moduleRoot, "scripts/build-preview-plugin.sh");
12947
- const expoPlugin = path28.join(dir, "ExpoModulesMacros");
13255
+ const compilerStamp = path30.join(dir, "compiler-release");
13256
+ const pluginScript = path30.join(moduleRoot, "scripts/build-preview-plugin.sh");
13257
+ const expoPlugin = path30.join(dir, "ExpoModulesMacros");
12948
13258
  const ext = process.platform === "darwin" ? "dylib" : "so";
12949
13259
  const plugins = [
12950
13260
  {
12951
- library: path28.join(dir, `libRnxPreviewMacros.${ext}`),
12952
- sources: [path28.join(moduleRoot, "Sources/RnxPreviewMacros/PreviewMacro.swift")]
13261
+ library: path30.join(dir, `libRnxPreviewMacros.${ext}`),
13262
+ sources: [path30.join(moduleRoot, "Sources/RnxPreviewMacros/PreviewMacro.swift")]
12953
13263
  },
12954
13264
  {
12955
- library: path28.join(dir, `libFoundationMacros.${ext}`),
13265
+ library: path30.join(dir, `libFoundationMacros.${ext}`),
12956
13266
  sources: [
12957
- path28.join(moduleRoot, "Sources/FoundationMacros/PredicateMacro.swift"),
12958
- path28.join(moduleRoot, "Sources/SwiftMacroSupport/PredicateExpression.swift")
13267
+ path30.join(moduleRoot, "Sources/FoundationMacros/PredicateMacro.swift"),
13268
+ path30.join(moduleRoot, "Sources/SwiftMacroSupport/PredicateExpression.swift")
12959
13269
  ]
12960
13270
  },
12961
13271
  {
12962
- library: path28.join(dir, `libTipKitMacros.${ext}`),
13272
+ library: path30.join(dir, `libTipKitMacros.${ext}`),
12963
13273
  sources: [
12964
- path28.join(moduleRoot, "Sources/TipKitMacros/TipKitMacros.swift"),
12965
- path28.join(moduleRoot, "Sources/SwiftMacroSupport/PredicateExpression.swift")
13274
+ path30.join(moduleRoot, "Sources/TipKitMacros/TipKitMacros.swift"),
13275
+ path30.join(moduleRoot, "Sources/SwiftMacroSupport/PredicateExpression.swift")
12966
13276
  ]
12967
13277
  }
12968
13278
  ];
12969
13279
  return {
12970
13280
  libraries: plugins.map(({ library }) => library),
12971
13281
  executables: [expoPlugin],
12972
- stale: !existsSync6(compilerStamp) || !existsSync6(expoPlugin) || statSync2(pluginScript).mtimeMs > statSync2(expoPlugin).mtimeMs || readFileSync17(compilerStamp, "utf8").trim() !== release || plugins.some(
12973
- ({ library, sources }) => !existsSync6(library) || sources.some((source) => statSync2(source).mtimeMs > statSync2(library).mtimeMs)
13282
+ stale: !existsSync7(compilerStamp) || !existsSync7(expoPlugin) || statSync3(pluginScript).mtimeMs > statSync3(expoPlugin).mtimeMs || readFileSync18(compilerStamp, "utf8").trim() !== release || plugins.some(
13283
+ ({ library, sources }) => !existsSync7(library) || sources.some((source) => statSync3(source).mtimeMs > statSync3(library).mtimeMs)
12974
13284
  )
12975
13285
  };
12976
13286
  }
@@ -12980,14 +13290,14 @@ async function ensureMacroPlugins(moduleRoot, toolchainBin, release, signal, lea
12980
13290
  await runCompiler(
12981
13291
  "sh",
12982
13292
  [
12983
- path28.join(moduleRoot, "scripts/build-preview-plugin.sh"),
13293
+ path30.join(moduleRoot, "scripts/build-preview-plugin.sh"),
12984
13294
  toolchainBin,
12985
13295
  libraries[0]
12986
13296
  ],
12987
13297
  { signal, lease }
12988
13298
  );
12989
- writeFileSync8(
12990
- path28.join(path28.dirname(libraries[0]), "compiler-release"),
13299
+ writeFileSync9(
13300
+ path30.join(path30.dirname(libraries[0]), "compiler-release"),
12991
13301
  `${release}
12992
13302
  `
12993
13303
  );
@@ -13001,9 +13311,9 @@ function clearLinkedModuleDigests(root) {
13001
13311
  }
13002
13312
  function swiftModuleDigest(root) {
13003
13313
  const files = swiftModuleInputFiles(root);
13004
- const stampHash = createHash14("sha256");
13314
+ const stampHash = createHash15("sha256");
13005
13315
  for (const file of files) {
13006
- const stat = statSync2(path28.join(root, file), { bigint: true });
13316
+ const stat = statSync3(path30.join(root, file), { bigint: true });
13007
13317
  stampHash.update(file);
13008
13318
  stampHash.update(
13009
13319
  `${stat.dev}:${stat.ino}:${stat.size}:${stat.mtimeNs}:${stat.ctimeNs}
@@ -13013,36 +13323,36 @@ function swiftModuleDigest(root) {
13013
13323
  const stamp = stampHash.digest("hex");
13014
13324
  const cached = linkedModuleDigests.get(root);
13015
13325
  if (cached?.stamp === stamp) return cached.digest;
13016
- const record = path28.join(
13326
+ const record = path30.join(
13017
13327
  swiftCacheDir(),
13018
13328
  "swift-module-digests",
13019
- `${createHash14("sha256").update(root).digest("hex")}.json`
13329
+ `${createHash15("sha256").update(root).digest("hex")}.json`
13020
13330
  );
13021
- if (existsSync6(record)) {
13022
- const saved = JSON.parse(readFileSync17(record, "utf8"));
13331
+ if (existsSync7(record)) {
13332
+ const saved = JSON.parse(readFileSync18(record, "utf8"));
13023
13333
  if (saved && typeof saved === "object" && Reflect.get(saved, "stamp") === stamp && typeof Reflect.get(saved, "digest") === "string") {
13024
13334
  const digest2 = Buffer.from(String(Reflect.get(saved, "digest")), "hex");
13025
13335
  linkedModuleDigests.set(root, { stamp, digest: digest2 });
13026
13336
  return digest2;
13027
13337
  }
13028
13338
  }
13029
- const hash = createHash14("sha256");
13339
+ const hash = createHash15("sha256");
13030
13340
  for (const file of files) {
13031
- hash.update(createHash14("sha256").update(file).digest());
13341
+ hash.update(createHash15("sha256").update(file).digest());
13032
13342
  hash.update(
13033
- createHash14("sha256").update(readFileSync17(path28.join(root, file))).digest()
13343
+ createHash15("sha256").update(readFileSync18(path30.join(root, file))).digest()
13034
13344
  );
13035
13345
  }
13036
13346
  const digest = hash.digest();
13037
13347
  linkedModuleDigests.set(root, { stamp, digest });
13038
- mkdirSync7(path28.dirname(record), { recursive: true });
13348
+ mkdirSync8(path30.dirname(record), { recursive: true });
13039
13349
  const partial = `${record}.${process.pid}.${randomUUID5()}`;
13040
- writeFileSync8(partial, JSON.stringify({ stamp, digest: digest.toString("hex") }));
13041
- renameSync2(partial, record);
13350
+ writeFileSync9(partial, JSON.stringify({ stamp, digest: digest.toString("hex") }));
13351
+ renameSync3(partial, record);
13042
13352
  return digest;
13043
13353
  }
13044
13354
  function swiftProjectBuildKey(moduleRoot, release) {
13045
- return createHash14("sha256").update(`swift-framework/v2\0${release}\0${swiftModuleSdk(moduleRoot).wasmSdkId}`).update(swiftModuleDigest(moduleRoot)).digest("hex").slice(0, 32);
13355
+ return createHash15("sha256").update(`swift-framework/v2\0${release}\0${swiftModuleSdk(moduleRoot).wasmSdkId}`).update(swiftModuleDigest(moduleRoot)).digest("hex").slice(0, 32);
13046
13356
  }
13047
13357
  var SYSTEM_MODULE_LIBRARIES = {
13048
13358
  "sqlite3.h": "sqlite3",
@@ -13089,7 +13399,7 @@ function withNativeSourceGlue(input, glue) {
13089
13399
  ...input,
13090
13400
  files: {
13091
13401
  ...input.files,
13092
- [path28.posix.join(targetPath, "OneNativeSource.generated.swift")]: glue
13402
+ [path30.posix.join(targetPath, "OneNativeSource.generated.swift")]: glue
13093
13403
  },
13094
13404
  oneModule: true
13095
13405
  };
@@ -13181,12 +13491,12 @@ function swiftCondition(text2, available) {
13181
13491
  if (token === "false") return false;
13182
13492
  const call = /^(\w+)\s*\(\s*([^,()]*?)\s*(?:,[^()]*)?\)$/.exec(token ?? "");
13183
13493
  if (!call) return void 0;
13184
- const [, name2, argument] = call;
13185
- if (name2 === "os") return argument === "iOS";
13494
+ const [, name2, argument2] = call;
13495
+ if (name2 === "os") return argument2 === "iOS";
13186
13496
  if (name2 === "canImport")
13187
- return argument !== "FoundationNetworking" && available?.has(argument);
13188
- if (name2 === "targetEnvironment") return argument === "simulator";
13189
- if (name2 === "arch") return argument === "wasm64" || argument === "arm64";
13497
+ return argument2 !== "FoundationNetworking" && available?.has(argument2);
13498
+ if (name2 === "targetEnvironment") return argument2 === "simulator";
13499
+ if (name2 === "arch") return argument2 === "wasm64" || argument2 === "arm64";
13190
13500
  return void 0;
13191
13501
  };
13192
13502
  const both = () => {
@@ -13245,7 +13555,7 @@ function swiftImportNames(contents2, available) {
13245
13555
  function swiftPeachModules(moduleRoot) {
13246
13556
  const distribution = swiftDistributionAt(moduleRoot);
13247
13557
  return distribution ? distribution.modules : swiftManifestDeclarations(
13248
- readFileSync17(path28.join(moduleRoot, "Package.swift"), "utf8")
13558
+ readFileSync18(path30.join(moduleRoot, "Package.swift"), "utf8")
13249
13559
  ).filter((target) => !target.executable && !target.path.startsWith("fixtures/")).map((target) => target.name);
13250
13560
  }
13251
13561
  var sdkPaths = /* @__PURE__ */ new Map();
@@ -13256,7 +13566,7 @@ function swiftSdkPaths(moduleRoot, toolchainBin) {
13256
13566
  const cached = sdkPaths.get(key);
13257
13567
  if (cached) return cached;
13258
13568
  const configuration = execFileSync12(
13259
- path28.join(toolchainBin, "swift"),
13569
+ path30.join(toolchainBin, "swift"),
13260
13570
  [
13261
13571
  "sdk",
13262
13572
  "configure",
@@ -13281,7 +13591,7 @@ function swiftSdkPaths(moduleRoot, toolchainBin) {
13281
13591
  if (!Array.isArray(toolsets) || !toolsets.every((value) => typeof value === "string"))
13282
13592
  throw new Error(`swift sdk ${sdk} reports invalid toolset paths`);
13283
13593
  for (const toolset of toolsets) {
13284
- const config = JSON.parse(readFileSync17(toolset, "utf8"));
13594
+ const config = JSON.parse(readFileSync18(toolset, "utf8"));
13285
13595
  if (!config || typeof config !== "object" || !("swiftCompiler" in config)) continue;
13286
13596
  const compiler = config.swiftCompiler;
13287
13597
  if (!compiler || typeof compiler !== "object" || !("extraCLIOptions" in compiler))
@@ -13297,7 +13607,7 @@ function swiftSdkPaths(moduleRoot, toolchainBin) {
13297
13607
  if (flag !== "-fwasm-exceptions") cFlags.push(flag);
13298
13608
  if (flag === "-iframeworkwithsysroot" && options2[index + 2] === "-Xcc" && typeof options2[index + 3] === "string") {
13299
13609
  cFlags.push(options2[index + 3]);
13300
- frameworks.push(path28.join(sysroot, options2[index + 3]));
13610
+ frameworks.push(path30.join(sysroot, options2[index + 3]));
13301
13611
  index += 3;
13302
13612
  continue;
13303
13613
  }
@@ -13314,7 +13624,7 @@ function swiftSdkPaths(moduleRoot, toolchainBin) {
13314
13624
  }
13315
13625
  const paths = {
13316
13626
  sysroot,
13317
- darwin: path28.join(sysroot, "darwin"),
13627
+ darwin: path30.join(sysroot, "darwin"),
13318
13628
  resources: field("swiftResourcesPath"),
13319
13629
  frameworks,
13320
13630
  cFlags
@@ -13342,24 +13652,24 @@ function swiftOverlayFrameworks(moduleRoot, toolchainBin) {
13342
13652
  const { darwin, resources, frameworks } = swiftSdkPaths(moduleRoot, toolchainBin);
13343
13653
  const swiftModules = new Set(swiftPeachModules(moduleRoot));
13344
13654
  const result = /* @__PURE__ */ new Set();
13345
- const include = path28.join(darwin, "usr/include");
13655
+ const include = path30.join(darwin, "usr/include");
13346
13656
  for (const entry of readdirSync8(include))
13347
13657
  if (entry.endsWith(".modulemap"))
13348
13658
  addSwiftOverlayFrameworks(
13349
- readFileSync17(path28.join(include, entry), "utf8"),
13659
+ readFileSync18(path30.join(include, entry), "utf8"),
13350
13660
  swiftModules,
13351
13661
  result
13352
13662
  );
13353
13663
  for (const entry of readdirSync8(resources)) {
13354
- const map = path28.join(resources, entry, "module.modulemap");
13355
- if (existsSync6(map))
13356
- addSwiftOverlayFrameworks(readFileSync17(map, "utf8"), swiftModules, result);
13664
+ const map = path30.join(resources, entry, "module.modulemap");
13665
+ if (existsSync7(map))
13666
+ addSwiftOverlayFrameworks(readFileSync18(map, "utf8"), swiftModules, result);
13357
13667
  }
13358
13668
  for (const directory of frameworks)
13359
13669
  for (const entry of readdirSync8(directory)) {
13360
- const map = path28.join(directory, entry, "Modules/module.modulemap");
13361
- if (existsSync6(map))
13362
- addSwiftOverlayFrameworks(readFileSync17(map, "utf8"), swiftModules, result);
13670
+ const map = path30.join(directory, entry, "Modules/module.modulemap");
13671
+ if (existsSync7(map))
13672
+ addSwiftOverlayFrameworks(readFileSync18(map, "utf8"), swiftModules, result);
13363
13673
  }
13364
13674
  sdkOverlayFrameworks.set(key, result);
13365
13675
  return result;
@@ -13375,51 +13685,51 @@ function swiftAvailableModules(moduleRoot, toolchainBin) {
13375
13685
  toolchainBin
13376
13686
  );
13377
13687
  const maps = /* @__PURE__ */ new Set([
13378
- path28.join(darwin, "usr/include/module.modulemap"),
13688
+ path30.join(darwin, "usr/include/module.modulemap"),
13379
13689
  ...cFlags.filter((flag) => flag.startsWith("-fmodule-map-file=")).map((flag) => {
13380
13690
  const file = flag.slice("-fmodule-map-file=".length);
13381
- return file.startsWith("=") ? path28.join(sysroot, file.slice(1)) : file;
13691
+ return file.startsWith("=") ? path30.join(sysroot, file.slice(1)) : file;
13382
13692
  })
13383
13693
  ]);
13384
13694
  for (const map of maps) {
13385
- if (!existsSync6(map)) continue;
13386
- const contents2 = readFileSync17(map, "utf8");
13695
+ if (!existsSync7(map)) continue;
13696
+ const contents2 = readFileSync18(map, "utf8");
13387
13697
  for (const match of contents2.matchAll(
13388
13698
  /^(?:explicit\s+)?(?:framework\s+)?module\s+([A-Za-z_]\w*)/gm
13389
13699
  ))
13390
13700
  modules.add(match[1]);
13391
13701
  for (const match of contents2.matchAll(/^\s*extern\s+module\s+\w+\s+"([^"]+)"/gm))
13392
- maps.add(path28.resolve(path28.dirname(map), match[1]));
13702
+ maps.add(path30.resolve(path30.dirname(map), match[1]));
13393
13703
  }
13394
- for (const entry of readdirSync8(path28.join(resources, "wasi"))) {
13704
+ for (const entry of readdirSync8(path30.join(resources, "wasi"))) {
13395
13705
  if (entry.endsWith(".swiftmodule"))
13396
13706
  modules.add(entry.slice(0, -".swiftmodule".length));
13397
13707
  }
13398
13708
  for (const entry of readdirSync8(resources)) {
13399
- const map = path28.join(resources, entry, "module.modulemap");
13400
- if (!existsSync6(map)) continue;
13401
- for (const match of readFileSync17(map, "utf8").matchAll(/^module\s+([A-Za-z_]\w*)/gm))
13709
+ const map = path30.join(resources, entry, "module.modulemap");
13710
+ if (!existsSync7(map)) continue;
13711
+ for (const match of readFileSync18(map, "utf8").matchAll(/^module\s+([A-Za-z_]\w*)/gm))
13402
13712
  modules.add(match[1]);
13403
13713
  }
13404
13714
  for (const libc of [
13405
- path28.join(darwin, "usr/include"),
13406
- path28.join(
13715
+ path30.join(darwin, "usr/include"),
13716
+ path30.join(
13407
13717
  swiftSharedSdkRoot(moduleRoot, swiftDistributionAt(moduleRoot) !== null),
13408
13718
  "usr/include"
13409
13719
  )
13410
13720
  ])
13411
13721
  for (const entry of readdirSync8(libc)) {
13412
13722
  if (!entry.endsWith(".modulemap")) continue;
13413
- for (const match of readFileSync17(path28.join(libc, entry), "utf8").matchAll(
13723
+ for (const match of readFileSync18(path30.join(libc, entry), "utf8").matchAll(
13414
13724
  /^module\s+([A-Za-z_]\w*)/gm
13415
13725
  ))
13416
13726
  modules.add(match[1]);
13417
13727
  }
13418
13728
  for (const directory of frameworks) {
13419
13729
  for (const entry of readdirSync8(directory)) {
13420
- const map = path28.join(directory, entry, "Modules/module.modulemap");
13421
- if (!existsSync6(map)) continue;
13422
- for (const match of readFileSync17(map, "utf8").matchAll(
13730
+ const map = path30.join(directory, entry, "Modules/module.modulemap");
13731
+ if (!existsSync7(map)) continue;
13732
+ for (const match of readFileSync18(map, "utf8").matchAll(
13423
13733
  /^framework\s+module\s+([A-Za-z_]\w*)/gm
13424
13734
  ))
13425
13735
  modules.add(match[1]);
@@ -13517,23 +13827,23 @@ int EXUpdatesApplyBSDiffPatch(const char * _Nonnull oldFilePath,
13517
13827
  }
13518
13828
  ];
13519
13829
  function distributionClangModulePresent(modules, name2) {
13520
- return existsSync6(path28.join(modules, `${name2}.swiftmodule`)) || existsSync6(path28.join(modules, name2, "module.modulemap"));
13830
+ return existsSync7(path30.join(modules, `${name2}.swiftmodule`)) || existsSync7(path30.join(modules, name2, "module.modulemap"));
13521
13831
  }
13522
13832
  function distributionClangModuleMap(root, modules) {
13523
13833
  const missing = DISTRIBUTION_CLANG_MODULES.filter(
13524
13834
  (mod) => !distributionClangModulePresent(modules, mod.name)
13525
13835
  );
13526
13836
  if (missing.length === 0) return null;
13527
- const key = createHash14("sha256").update(modules).update(missing.map((mod) => `${mod.name}\0${mod.source}`).join("\0")).digest("hex").slice(0, 16);
13528
- const directory = path28.join(root, `.peach-clang-modules-${key}`);
13529
- const mapPath = path28.join(directory, "module.modulemap");
13530
- if (!existsSync6(mapPath)) {
13531
- mkdirSync7(directory, { recursive: true });
13837
+ const key = createHash15("sha256").update(modules).update(missing.map((mod) => `${mod.name}\0${mod.source}`).join("\0")).digest("hex").slice(0, 16);
13838
+ const directory = path30.join(root, `.peach-clang-modules-${key}`);
13839
+ const mapPath = path30.join(directory, "module.modulemap");
13840
+ if (!existsSync7(mapPath)) {
13841
+ mkdirSync8(directory, { recursive: true });
13532
13842
  const parts = [];
13533
13843
  for (const mod of missing) {
13534
- const destination = path28.join(directory, mod.header);
13535
- mkdirSync7(path28.dirname(destination), { recursive: true });
13536
- writeFileSync8(destination, mod.source);
13844
+ const destination = path30.join(directory, mod.header);
13845
+ mkdirSync8(path30.dirname(destination), { recursive: true });
13846
+ writeFileSync9(destination, mod.source);
13537
13847
  parts.push(
13538
13848
  `module ${mod.name} {
13539
13849
  requires objc
@@ -13543,7 +13853,7 @@ function distributionClangModuleMap(root, modules) {
13543
13853
  `
13544
13854
  );
13545
13855
  }
13546
- writeFileSync8(mapPath, parts.join("\n"));
13856
+ writeFileSync9(mapPath, parts.join("\n"));
13547
13857
  }
13548
13858
  return mapPath;
13549
13859
  }
@@ -13554,17 +13864,17 @@ function distributionClangModuleOptions(root, modules) {
13554
13864
  function providedModulesPath(root, modules, excluded) {
13555
13865
  if (!excluded || excluded.size === 0) return modules;
13556
13866
  const entries = readdirSync8(modules).filter((entry) => !excluded.has(entry.replace(/\..*$/, ""))).sort();
13557
- const key = createHash14("sha256").update(JSON.stringify([modules, entries])).update([...excluded].sort().join("\0")).digest("hex").slice(0, 16);
13558
- const directory = path28.join(root, `.peach-modules-${key}`);
13559
- const complete = path28.join(directory, ".complete");
13560
- if (!existsSync6(complete)) {
13561
- mkdirSync7(directory, { recursive: true });
13867
+ const key = createHash15("sha256").update(JSON.stringify([modules, entries])).update([...excluded].sort().join("\0")).digest("hex").slice(0, 16);
13868
+ const directory = path30.join(root, `.peach-modules-${key}`);
13869
+ const complete = path30.join(directory, ".complete");
13870
+ if (!existsSync7(complete)) {
13871
+ mkdirSync8(directory, { recursive: true });
13562
13872
  for (const entry of readdirSync8(directory))
13563
- rmSync7(path28.join(directory, entry), { recursive: true, force: true });
13873
+ rmSync8(path30.join(directory, entry), { recursive: true, force: true });
13564
13874
  for (const entry of entries) {
13565
- symlinkSync2(path28.join(modules, entry), path28.join(directory, entry));
13875
+ symlinkSync2(path30.join(modules, entry), path30.join(directory, entry));
13566
13876
  }
13567
- writeFileSync8(complete, "");
13877
+ writeFileSync9(complete, "");
13568
13878
  }
13569
13879
  return directory;
13570
13880
  }
@@ -13576,7 +13886,7 @@ function swiftTargetDependencies(files, targets, frameworks = OPTIONAL_FRAMEWORK
13576
13886
  );
13577
13887
  const names = /* @__PURE__ */ new Set([...frameworks, ...targets.map((target) => target.name)]);
13578
13888
  const entriesByPrefix = new Map(
13579
- targets.map(({ path: path29 }) => [path29 === "." ? "" : `${path29}/`, []])
13889
+ targets.map(({ path: path31 }) => [path31 === "." ? "" : `${path31}/`, []])
13580
13890
  );
13581
13891
  for (const entry of Object.entries(files)) {
13582
13892
  const [file] = entry;
@@ -13611,7 +13921,7 @@ function swiftTargetDependencies(files, targets, frameworks = OPTIONAL_FRAMEWORK
13611
13921
  (excluded) => relative === excluded || relative.startsWith(`${excluded}/`)
13612
13922
  ))
13613
13923
  continue;
13614
- if (nested.some((path29) => file.startsWith(path29))) continue;
13924
+ if (nested.some((path31) => file.startsWith(path31))) continue;
13615
13925
  const imports = file.endsWith(".swift") ? swiftImportNames(contents2) : SWIFT_NATIVE_SOURCE_EXTENSIONS.some((extension) => file.endsWith(extension)) ? clangImportNames(contents2, ownsHeader) : [];
13616
13926
  for (const name2 of imports) {
13617
13927
  if (names.has(name2) && name2 !== target.name && !(target.dependencies !== void 0 && localNames.has(name2)))
@@ -13658,7 +13968,7 @@ var FOUNDATION_IMPLICIT_FLAGS = FOUNDATION_IMPLICIT_MODULES.map(
13658
13968
  ).join("");
13659
13969
  var ONE_IMPLICIT_FLAGS = ', "-Xfrontend", "-import-module", "-Xfrontend", "One"';
13660
13970
  var executableLinkFlags = (root) => ` "-Xclang-linker", "-O0",
13661
- "-Xclang-linker", ${JSON.stringify(`-fuse-ld=${path28.join(root, SWIFT_AUTOLINK_LINKER)}`)},
13971
+ "-Xclang-linker", ${JSON.stringify(`-fuse-ld=${path30.join(root, SWIFT_AUTOLINK_LINKER)}`)},
13662
13972
  "-Xlinker", "-z", "-Xlinker", "stack-size=8372224",
13663
13973
  "-Xlinker", "--stack-first",
13664
13974
  "-Xlinker", "--global-base=8372224",
@@ -13672,11 +13982,11 @@ var executableLinkFlags = (root) => ` "-Xclang-linker", "-O0",
13672
13982
  `;
13673
13983
  var darwinRecordsRegion = (quoted2) => quoted2.length ? ["-Wl,--start-lib", ...quoted2, "-Wl,--end-lib"] : [];
13674
13984
  var REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
13675
- var MULTI_MANIFEST_VERSION = 71;
13985
+ var MULTI_MANIFEST_VERSION = 72;
13676
13986
  var SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
13677
- var compilerSourceDigest = true ? "558e865561d0b74b1a3016abec937fd19f725375fe7e014dc1f140a17a31bc68" : swiftCompilerSourceDigest(import.meta.dirname);
13987
+ var compilerSourceDigest = true ? "63f37c4a87253305166cb52435207eb3f74394734f1a77e562d79ab7d5d7dfc1" : swiftCompilerSourceDigest(import.meta.dirname);
13678
13988
  function swiftArtifactHash(input, release, moduleRoot) {
13679
- const hash = createHash14("sha256");
13989
+ const hash = createHash15("sha256");
13680
13990
  hash.update(`swift-compile
13681
13991
  ${release}
13682
13992
  `);
@@ -13689,32 +13999,32 @@ ${WASM_LOWER_IDENTITY}
13689
13999
  `);
13690
14000
  if (input.optimize) hash.update("optimize\n");
13691
14001
  for (const file of Object.keys(input.files).sort()) {
13692
- hash.update(createHash14("sha256").update(file).digest());
13693
- hash.update(createHash14("sha256").update(input.files[file]).digest());
14002
+ hash.update(createHash15("sha256").update(file).digest());
14003
+ hash.update(createHash15("sha256").update(input.files[file]).digest());
13694
14004
  }
13695
14005
  for (const file of Object.keys(input.metalSources ?? {}).sort()) {
13696
14006
  hash.update("metal-source\n");
13697
- hash.update(createHash14("sha256").update(file).digest());
14007
+ hash.update(createHash15("sha256").update(file).digest());
13698
14008
  hash.update(
13699
- createHash14("sha256").update(input.metalSources?.[file] ?? "").digest()
14009
+ createHash15("sha256").update(input.metalSources?.[file] ?? "").digest()
13700
14010
  );
13701
14011
  }
13702
14012
  for (const base of Object.keys(input.resources ?? {}).sort()) {
13703
- hash.update(createHash14("sha256").update(base).digest());
14013
+ hash.update(createHash15("sha256").update(base).digest());
13704
14014
  hash.update(
13705
- createHash14("sha256").update(input.resources?.[base] ?? "").digest()
14015
+ createHash15("sha256").update(input.resources?.[base] ?? "").digest()
13706
14016
  );
13707
14017
  }
13708
14018
  for (const name2 of Object.keys(input.images ?? {}).sort()) {
13709
14019
  const image = input.images?.[name2];
13710
14020
  if (!image) continue;
13711
- hash.update(createHash14("sha256").update(name2).digest());
13712
- hash.update(createHash14("sha256").update(image.file).digest());
13713
- hash.update(createHash14("sha256").update(image.data).digest());
14021
+ hash.update(createHash15("sha256").update(name2).digest());
14022
+ hash.update(createHash15("sha256").update(image.file).digest());
14023
+ hash.update(createHash15("sha256").update(image.data).digest());
13714
14024
  }
13715
14025
  for (const file of [...new Set(input.resourcePaths ?? [])].sort()) {
13716
14026
  hash.update("resource-path\n");
13717
- hash.update(createHash14("sha256").update(file).digest());
14027
+ hash.update(createHash15("sha256").update(file).digest());
13718
14028
  }
13719
14029
  hash.update(
13720
14030
  JSON.stringify(
@@ -13732,18 +14042,18 @@ ${input.defaultLocalization}
13732
14042
  `);
13733
14043
  for (const file of Object.keys(input.packageFiles ?? {}).sort()) {
13734
14044
  hash.update(`package-file\0${file}\0`);
13735
- hash.update(createHash14("sha256").update(input.packageFiles[file]).digest());
14045
+ hash.update(createHash15("sha256").update(input.packageFiles[file]).digest());
13736
14046
  }
13737
14047
  for (const file of Object.keys(input.projectFiles ?? {}).sort()) {
13738
14048
  hash.update(`project-file\0${file}\0`);
13739
- hash.update(createHash14("sha256").update(input.projectFiles[file]).digest());
14049
+ hash.update(createHash15("sha256").update(input.projectFiles[file]).digest());
13740
14050
  }
13741
14051
  for (const target of Object.keys(input.libraries ?? {}).sort()) {
13742
14052
  hash.update(`library
13743
14053
  ${target}
13744
14054
  `);
13745
14055
  hash.update(
13746
- createHash14("sha256").update(input.libraries?.[target] ?? "").digest()
14056
+ createHash15("sha256").update(input.libraries?.[target] ?? "").digest()
13747
14057
  );
13748
14058
  }
13749
14059
  for (const [name2, bytes] of Object.entries(input.binaryModules ?? {}).sort())
@@ -13767,7 +14077,7 @@ var nativeCxxCompilerFlags = ["-fno-cxx-modules"];
13767
14077
  var cFlagArray = (flags) => JSON.stringify(withoutGlogModuleMap(flags));
13768
14078
  var cxxFlagArray = (flags) => JSON.stringify([...nativeCxxCompilerFlags, ...withoutGlogModuleMap(flags)]);
13769
14079
  function swiftCrossImportFlags(moduleRoot, distribution) {
13770
- const overlayRoot = path28.join(
14080
+ const overlayRoot = path30.join(
13771
14081
  moduleRoot,
13772
14082
  distribution ? "modules" : "cross-import-overlays"
13773
14083
  );
@@ -13775,9 +14085,9 @@ function swiftCrossImportFlags(moduleRoot, distribution) {
13775
14085
  "-Xfrontend",
13776
14086
  "-swift-module-cross-import",
13777
14087
  "-Xfrontend",
13778
- path28.basename(path28.dirname(file), ".swiftcrossimport"),
14088
+ path30.basename(path30.dirname(file), ".swiftcrossimport"),
13779
14089
  "-Xfrontend",
13780
- path28.join(overlayRoot, file)
14090
+ path30.join(overlayRoot, file)
13781
14091
  ]);
13782
14092
  }
13783
14093
  function withoutWasmOverlayIsystem(flags) {
@@ -13817,7 +14127,7 @@ function emitSwiftPackageManifest(args) {
13817
14127
  if (!flag.startsWith("-fmodule-map-file=")) return false;
13818
14128
  const file = flag.slice("-fmodule-map-file=".length).replaceAll(SWIFT_NATIVE_INPUT_ROOT, args.root);
13819
14129
  if (!file.includes("/Pods/Headers/")) return false;
13820
- const map = args.files.get(file) ?? (existsSync6(file) ? readFileSync17(file) : void 0);
14130
+ const map = args.files.get(file) ?? (existsSync7(file) ? readFileSync18(file) : void 0);
13821
14131
  const name2 = map === void 0 ? void 0 : moduleMapName(map.toString());
13822
14132
  return name2 !== void 0 && packageModules.has(name2);
13823
14133
  };
@@ -13849,7 +14159,7 @@ function emitSwiftPackageManifest(args) {
13849
14159
  const product = v5.parse(
13850
14160
  swiftFrameworkProductSchema,
13851
14161
  JSON.parse(
13852
- readFileSync17(path28.join(moduleRoot, SWIFT_FRAMEWORK_PRODUCT_FILE), "utf8")
14162
+ readFileSync18(path30.join(moduleRoot, SWIFT_FRAMEWORK_PRODUCT_FILE), "utf8")
13853
14163
  )
13854
14164
  );
13855
14165
  const replacedObjects = new Set(
@@ -13863,7 +14173,7 @@ function emitSwiftPackageManifest(args) {
13863
14173
  (name2) => !object3.startsWith(`lib/${name2}-`) || reachedFrameworks.has(name2)
13864
14174
  )
13865
14175
  );
13866
- const quoted2 = (object3) => `"${path28.join(moduleRoot, object3).replaceAll("\\", "\\\\").replaceAll('"', '\\"')}"`;
14176
+ const quoted2 = (object3) => `"${path30.join(moduleRoot, object3).replaceAll("\\", "\\\\").replaceAll('"', '\\"')}"`;
13867
14177
  const categoryObjects = new Set(
13868
14178
  foundationCategoryObjects.map((name2) => `lib/Foundation-${name2}.o`)
13869
14179
  );
@@ -13880,7 +14190,7 @@ function emitSwiftPackageManifest(args) {
13880
14190
  ].join("\n") + "\n";
13881
14191
  distributionLinkPath = distributionLink.path.replace(
13882
14192
  /\.rsp$/,
13883
- `-${createHash14("sha256").update(list).digest("hex").slice(0, 12)}.rsp`
14193
+ `-${createHash15("sha256").update(list).digest("hex").slice(0, 12)}.rsp`
13884
14194
  );
13885
14195
  distributionLink.files.set(distributionLinkPath, list);
13886
14196
  }
@@ -13897,8 +14207,8 @@ function emitSwiftPackageManifest(args) {
13897
14207
  const macroSettings = (values) => (values ?? []).map((value) => ` ${clangMacroSetting(value)},`).join("");
13898
14208
  const flagArray = (literal2) => {
13899
14209
  const content = literal2.replace(/,\s*]$/, "]");
13900
- const digest = createHash14("sha256").update(content).digest("hex");
13901
- const file = path28.join(args.root, ".peach-manifest-arguments", `${digest}.json`);
14210
+ const digest = createHash15("sha256").update(content).digest("hex");
14211
+ const file = path30.join(args.root, ".peach-manifest-arguments", `${digest}.json`);
13902
14212
  args.files.set(file, content);
13903
14213
  return `peachCompilerArguments(${JSON.stringify(file)})`;
13904
14214
  };
@@ -13909,8 +14219,8 @@ function emitSwiftPackageManifest(args) {
13909
14219
  const macros = compactSwiftClangDefines(flags);
13910
14220
  const compact = args.coalescibleOverlays ? compactSwiftClangOverlays(macros, args.coalescibleOverlays) : macros;
13911
14221
  const content = compact.map((flag) => JSON.stringify(flag)).join("\n") + "\n";
13912
- const digest = createHash14("sha256").update(content).digest("hex");
13913
- const file = path28.join(args.root, ".peach-swift-arguments", `${digest}.rsp`);
14222
+ const digest = createHash15("sha256").update(content).digest("hex");
14223
+ const file = path30.join(args.root, ".peach-swift-arguments", `${digest}.rsp`);
13914
14224
  args.files.set(file, content);
13915
14225
  return JSON.stringify([`@${file}`]);
13916
14226
  };
@@ -13922,7 +14232,7 @@ function emitSwiftPackageManifest(args) {
13922
14232
  owner?.publicHeadersPath ?? ""
13923
14233
  );
13924
14234
  return [
13925
- ...owner && framework ? [path28.posix.join(args.root, owner.path, framework[1])] : [],
14235
+ ...owner && framework ? [path30.posix.join(args.root, owner.path, framework[1])] : [],
13926
14236
  ...frameworkDirectories(dependency, seen)
13927
14237
  ];
13928
14238
  });
@@ -13944,7 +14254,7 @@ function emitSwiftPackageManifest(args) {
13944
14254
  const stanza = (target) => {
13945
14255
  const native = args.native?.get(target.name);
13946
14256
  if (target.systemLibrary || native?.clang?.sources.length === 0)
13947
- return ` .systemLibrary(name: ${JSON.stringify(target.name)}, path: ${JSON.stringify(native?.clang ? path28.posix.dirname(native.clang.modulemap) : target.path)}),`;
14257
+ return ` .systemLibrary(name: ${JSON.stringify(target.name)}, path: ${JSON.stringify(native?.clang ? path30.posix.dirname(native.clang.modulemap) : target.path)}),`;
13948
14258
  const isolation = target.mainActorIsolation ? " .defaultIsolation(MainActor.self)," : "";
13949
14259
  const interoperability = target.cxxInterop ? " .interoperabilityMode(.Cxx)," : "";
13950
14260
  const defines = (target.defines ?? []).map((name2) => ` .define(${JSON.stringify(name2)}),`).join("");
@@ -13957,10 +14267,10 @@ function emitSwiftPackageManifest(args) {
13957
14267
  const imports = binaryImports + (distribution ? `, "-Isystem", ${JSON.stringify(
13958
14268
  providedModulesPath(
13959
14269
  args.root,
13960
- path28.join(moduleRoot, "modules"),
14270
+ path30.join(moduleRoot, "modules"),
13961
14271
  args.moduleExcludes
13962
14272
  )
13963
- )}${distributionClangModuleOptions(args.root, path28.join(moduleRoot, "modules")).map((flag) => `, ${JSON.stringify(flag)}`).join("")}` : prebuilt ? `, "-Isystem", ${JSON.stringify(providedModulesPath(args.root, prebuilt.modules, args.moduleExcludes))}${prebuilt.moduleMaps.map((map) => `, "-Xcc", ${JSON.stringify(`-fmodule-map-file=${map}`)}`).join("")}` : "");
14273
+ )}${distributionClangModuleOptions(args.root, path30.join(moduleRoot, "modules")).map((flag) => `, ${JSON.stringify(flag)}`).join("")}` : prebuilt ? `, "-Isystem", ${JSON.stringify(providedModulesPath(args.root, prebuilt.modules, args.moduleExcludes))}${prebuilt.moduleMaps.map((map) => `, "-Xcc", ${JSON.stringify(`-fmodule-map-file=${map}`)}`).join("")}` : "");
13964
14274
  const nativeFlags = [
13965
14275
  ...args.nativeFlags?.get(target.name) ?? [],
13966
14276
  ...args.nativeHeaderFlags ?? []
@@ -13999,7 +14309,7 @@ function emitSwiftPackageManifest(args) {
13999
14309
  ].map((flag) => `, ${JSON.stringify(flag)}`).join("");
14000
14310
  const header = args.headerDirectory && (args.nativeHeaderDeclarations?.[target.name] || [...args.native?.values() ?? []].some(
14001
14311
  (value) => value.late?.producers.includes(target.name)
14002
- )) ? `, "-emit-objc-header-path", ${JSON.stringify(path28.join(args.headerDirectory, `${target.name}-Swift.original.h`))}` : "";
14312
+ )) ? `, "-emit-objc-header-path", ${JSON.stringify(path30.join(args.headerDirectory, `${target.name}-Swift.original.h`))}` : "";
14003
14313
  const clangMode = target.cxxInterop ? "" : ', "-Xcc", "-fno-cxx-modules"';
14004
14314
  const deployment = `, "-Xfrontend", "-peach-ios-deployment-target", "-Xfrontend", ${JSON.stringify(target.iosDeploymentTarget ?? SWIFTPM_DEFAULT_IOS_DEPLOYMENT_TARGET)}`;
14005
14315
  const swiftSettings = `swiftSettings: [.swiftLanguageMode(.v${target.languageMode}),${isolation}${interoperability}${defines}${features}${upcoming} .unsafeFlags(${swiftFlagArray(`["-Osize", "-Xfrontend", "-enable-cross-import-overlays"${overlayFlags}${FOUNDATION_IMPLICIT_FLAGS}${oneModule ? ONE_IMPLICIT_FLAGS : ""}${imports}${nativeImportFlags}${objcFlags}${header}${clangMode}${deployment}${upstream}]`)})]`;
@@ -14168,19 +14478,19 @@ function emitSwiftPackageManifest(args) {
14168
14478
  ].join("\n");
14169
14479
  }
14170
14480
  function syncSwiftTree(base, files) {
14171
- mkdirSync7(base, { recursive: true });
14481
+ mkdirSync8(base, { recursive: true });
14172
14482
  const kept = /* @__PURE__ */ new Set();
14173
- for (const file of files.keys()) if (existsSync6(file)) kept.add(statSync2(file).ino);
14483
+ for (const file of files.keys()) if (existsSync7(file)) kept.add(statSync3(file).ino);
14174
14484
  const walk = (dir) => {
14175
14485
  for (const entry of readdirSync8(dir, { withFileTypes: true })) {
14176
- const full = path28.join(dir, entry.name);
14486
+ const full = path30.join(dir, entry.name);
14177
14487
  if (dir === base && (entry.name === ".build" || entry.name.startsWith(".peach-modules-") || // distribution clang maps are written beside the project and named
14178
14488
  // from the compiler flags, so a sync must not remove them.
14179
14489
  entry.name.startsWith(".peach-clang-modules-") || entry.name === SWIFT_LINK_STAMP))
14180
14490
  continue;
14181
14491
  if (entry.isDirectory()) walk(full);
14182
14492
  else if (!files.has(full) && !kept.has(lstatSync(full).ino))
14183
- rmSync7(full, { force: true });
14493
+ rmSync8(full, { force: true });
14184
14494
  }
14185
14495
  };
14186
14496
  walk(base);
@@ -14328,7 +14638,7 @@ function compiledSwiftSources(files, targets, overlayFrameworks, headers, native
14328
14638
  const { onWasm, withoutWasm } = swiftTargetArchitectures(targets, swiftSources, headers);
14329
14639
  return new Map(
14330
14640
  [...owners].map(([file, { source, owner }]) => {
14331
- if (nativeSourceGlue && path28.posix.basename(file) === "OneNativeSource.generated.swift")
14641
+ if (nativeSourceGlue && path30.posix.basename(file) === "OneNativeSource.generated.swift")
14332
14642
  return [file, source];
14333
14643
  const manifest = /(?:^|\/)Package(?:@swift-[\d.]+)?\.swift$/.test(file);
14334
14644
  if (manifest && (!owner || /^Package(?:@swift-[\d.]+)?\.swift$/.test(file)))
@@ -14548,7 +14858,6 @@ var FOUNDATION_OVERLAY_TYPES = /* @__PURE__ */ new Set([
14548
14858
  ]);
14549
14859
  var FOUNDATION_OVERLAY_GLOBALS = /* @__PURE__ */ new Set([
14550
14860
  "CFBridgingRetain",
14551
- "NSASCIIStringEncoding",
14552
14861
  "NSAllHashTableObjects",
14553
14862
  "NSAllMapTableKeys",
14554
14863
  "NSAllMapTableValues",
@@ -14627,21 +14936,16 @@ var FOUNDATION_OVERLAY_GLOBALS = /* @__PURE__ */ new Set([
14627
14936
  "NSHashTableWeakMemory",
14628
14937
  "NSHebrewCalendar",
14629
14938
  "NSHostByteOrder",
14630
- "NSISO2022JPStringEncoding",
14631
14939
  "NSISO8601Calendar",
14632
- "NSISOLatin1StringEncoding",
14633
- "NSISOLatin2StringEncoding",
14634
14940
  "NSIndianCalendar",
14635
14941
  "NSIslamicCalendar",
14636
14942
  "NSIslamicCivilCalendar",
14637
14943
  "NSItemProviderPreferredImageSizeKey",
14638
14944
  "NSJapaneseCalendar",
14639
- "NSJapaneseEUCStringEncoding",
14640
14945
  "NSLoadedClasses",
14641
14946
  "NSLocalizedFailureErrorKey",
14642
14947
  "NSLogPageSize",
14643
14948
  "NSMACHOperatingSystem",
14644
- "NSMacOSRomanStringEncoding",
14645
14949
  "NSMapGet",
14646
14950
  "NSMapInsert",
14647
14951
  "NSMapInsertIfAbsent",
@@ -14653,10 +14957,8 @@ var FOUNDATION_OVERLAY_GLOBALS = /* @__PURE__ */ new Set([
14653
14957
  "NSMapTableStrongMemory",
14654
14958
  "NSMapTableWeakMemory",
14655
14959
  "NSMultipleUnderlyingErrorsKey",
14656
- "NSNEXTSTEPStringEncoding",
14657
14960
  "NSNextHashEnumeratorItem",
14658
14961
  "NSNextMapEnumeratorPair",
14659
- "NSNonLossyASCIIStringEncoding",
14660
14962
  "NSNonOwnedPointerHashCallBacks",
14661
14963
  "NSNonOwnedPointerMapKeyCallBacks",
14662
14964
  "NSNonOwnedPointerMapValueCallBacks",
@@ -14678,12 +14980,10 @@ var FOUNDATION_OVERLAY_GLOBALS = /* @__PURE__ */ new Set([
14678
14980
  "NSPointerToStructHashCallBacks",
14679
14981
  "NSPropertyListErrorMaximum",
14680
14982
  "NSPropertyListErrorMinimum",
14681
- "NSProprietaryStringEncoding",
14682
14983
  "NSProtocolFromString",
14683
14984
  "NSRepublicOfChinaCalendar",
14684
14985
  "NSResetHashTable",
14685
14986
  "NSResetMapTable",
14686
- "NSShiftJISStringEncoding",
14687
14987
  "NSSolarisOperatingSystem",
14688
14988
  "NSStringFromHashTable",
14689
14989
  "NSStringFromMapTable",
@@ -14719,7 +15019,6 @@ var FOUNDATION_OVERLAY_GLOBALS = /* @__PURE__ */ new Set([
14719
15019
  "NSSwapLong",
14720
15020
  "NSSwapLongLong",
14721
15021
  "NSSwapShort",
14722
- "NSSymbolStringEncoding",
14723
15022
  "NSTextCheckingAllCustomTypes",
14724
15023
  "NSTextCheckingAllSystemTypes",
14725
15024
  "NSTextCheckingAllTypes",
@@ -14737,13 +15036,6 @@ var FOUNDATION_OVERLAY_GLOBALS = /* @__PURE__ */ new Set([
14737
15036
  "NSURLProtectionSpaceHTTPSProxy",
14738
15037
  "NSURLProtectionSpaceSOCKSProxy",
14739
15038
  "NSURLSessionUploadTaskResumeData",
14740
- "NSUTF16BigEndianStringEncoding",
14741
- "NSUTF16LittleEndianStringEncoding",
14742
- "NSUTF16StringEncoding",
14743
- "NSUTF32BigEndianStringEncoding",
14744
- "NSUTF32LittleEndianStringEncoding",
14745
- "NSUTF32StringEncoding",
14746
- "NSUTF8StringEncoding",
14747
15039
  "NSUbiquitousFileErrorMaximum",
14748
15040
  "NSUbiquitousFileErrorMinimum",
14749
15041
  "NSUbiquitousKeyValueStoreAccountChange",
@@ -14755,17 +15047,11 @@ var FOUNDATION_OVERLAY_GLOBALS = /* @__PURE__ */ new Set([
14755
15047
  "NSUndefinedDateComponent",
14756
15048
  "NSUndoCloseGroupingRunLoopOrdering",
14757
15049
  "NSUndoManagerGroupIsDiscardableKey",
14758
- "NSUnicodeStringEncoding",
14759
15050
  "NSUserActivityErrorMaximum",
14760
15051
  "NSUserActivityErrorMinimum",
14761
15052
  "NSValidationErrorMaximum",
14762
15053
  "NSValidationErrorMinimum",
14763
15054
  "NSWindows95OperatingSystem",
14764
- "NSWindowsCP1250StringEncoding",
14765
- "NSWindowsCP1251StringEncoding",
14766
- "NSWindowsCP1252StringEncoding",
14767
- "NSWindowsCP1253StringEncoding",
14768
- "NSWindowsCP1254StringEncoding",
14769
15055
  "NSWindowsNTOperatingSystem",
14770
15056
  "NSWrapCalendarComponents",
14771
15057
  "NSXPCConnectionCodeSigningRequirementFailure",
@@ -15086,7 +15372,7 @@ function swiftApplicationEntry(file, source) {
15086
15372
  else if (source[at] === "}") depth--;
15087
15373
  else if (depth === 0 && /^@(?:main|UIApplicationMain)\b/.test(source.slice(at)))
15088
15374
  return true;
15089
- else if (depth === 0 && path28.basename(file) === "main.swift" && /^UIApplicationMain\s*\(/.test(source.slice(at)))
15375
+ else if (depth === 0 && path30.basename(file) === "main.swift" && /^UIApplicationMain\s*\(/.test(source.slice(at)))
15090
15376
  return true;
15091
15377
  }
15092
15378
  return false;
@@ -15201,11 +15487,11 @@ function objcApplicationMainCall(source) {
15201
15487
  if (principal === null || delegate === null) return null;
15202
15488
  return { principal, delegate };
15203
15489
  }
15204
- function objcMainCallArgument(argument) {
15205
- if (/^(?:nil|NULL|Nil)$/.test(argument)) return "nil";
15206
- const literal2 = /^@"((?:[^"\\]|\\.)*)"$/.exec(argument);
15490
+ function objcMainCallArgument(argument2) {
15491
+ if (/^(?:nil|NULL|Nil)$/.test(argument2)) return "nil";
15492
+ const literal2 = /^@"((?:[^"\\]|\\.)*)"$/.exec(argument2);
15207
15493
  if (literal2) return `"${literal2[1]}"`;
15208
- const name2 = /^NSStringFromClass\(\[([A-Za-z_]\w*) class\]\)$/.exec(argument);
15494
+ const name2 = /^NSStringFromClass\(\[([A-Za-z_]\w*) class\]\)$/.exec(argument2);
15209
15495
  if (name2) return `"${name2[1]}"`;
15210
15496
  return null;
15211
15497
  }
@@ -15474,6 +15760,18 @@ function swiftCMainEntry(file, source, env = emptyMacroEnvironment) {
15474
15760
  }
15475
15761
  return false;
15476
15762
  }
15763
+ var SWIFT_SCAN_KEYWORDS = {
15764
+ c: "class",
15765
+ e: "extension",
15766
+ o: "override",
15767
+ i: "import",
15768
+ f: "func",
15769
+ U: "UIApplicationMain",
15770
+ F: "Foundation",
15771
+ C: "CoreFoundation",
15772
+ O: "ObjectiveC",
15773
+ _: "_LocationEssentials"
15774
+ };
15477
15775
  function swiftCodeScan(source) {
15478
15776
  const starts = /* @__PURE__ */ new Set();
15479
15777
  const tokens = [];
@@ -15556,8 +15854,8 @@ function swiftCodeScan(source) {
15556
15854
  else top.parens--;
15557
15855
  i++;
15558
15856
  } else {
15559
- const keyword = source.startsWith("class", i) ? "class" : source.startsWith("extension", i) ? "extension" : source.startsWith("override", i) ? "override" : source.startsWith("import", i) ? "import" : source.startsWith("func", i) ? "func" : source.startsWith("UIApplicationMain", i) ? "UIApplicationMain" : source.startsWith("Foundation", i) ? "Foundation" : source.startsWith("CoreFoundation", i) ? "CoreFoundation" : source.startsWith("ObjectiveC", i) ? "ObjectiveC" : source.startsWith("_LocationEssentials", i) ? "_LocationEssentials" : null;
15560
- if (keyword && !/[\w$]/.test(source[i - 1] ?? "") && !/[\w$]/.test(source[i + keyword.length] ?? "")) {
15857
+ const keyword = SWIFT_SCAN_KEYWORDS[char];
15858
+ if (keyword && source.startsWith(keyword, i) && !/[\w$]/.test(source[i - 1] ?? "") && !/[\w$]/.test(source[i + keyword.length] ?? "")) {
15561
15859
  tokens.push(i);
15562
15860
  i += keyword.length;
15563
15861
  } else {
@@ -15569,27 +15867,27 @@ function swiftCodeScan(source) {
15569
15867
  return { lineStarts: starts, tokens };
15570
15868
  }
15571
15869
  function prepareSwiftDependency(source, destination, overlayFrameworks) {
15572
- rmSync7(destination, { recursive: true, force: true });
15870
+ rmSync8(destination, { recursive: true, force: true });
15573
15871
  const origins = {};
15574
15872
  const moduleMaps = [];
15575
15873
  const gather = (from) => {
15576
15874
  for (const entry of readdirSync8(from, { withFileTypes: true })) {
15577
15875
  if (entry.name === ".git" || entry.name === ".build" || entry.name === ".swiftpm")
15578
15876
  continue;
15579
- const file = path28.join(from, entry.name);
15877
+ const file = path30.join(from, entry.name);
15580
15878
  if (entry.isDirectory()) gather(file);
15581
15879
  else if (entry.isFile() && entry.name.endsWith(".swift"))
15582
- origins[path28.relative(source, file)] = readFileSync17(file, "utf8");
15880
+ origins[path30.relative(source, file)] = readFileSync18(file, "utf8");
15583
15881
  else if (entry.isFile() && entry.name.endsWith(".modulemap"))
15584
- moduleMaps.push(readFileSync17(file, "utf8"));
15882
+ moduleMaps.push(readFileSync18(file, "utf8"));
15585
15883
  }
15586
15884
  };
15587
15885
  gather(source);
15588
- const manifest = path28.join(source, "Package.swift");
15589
- const targets = existsSync6(manifest) ? swiftManifestTargets(
15590
- readFileSync17(manifest, "utf8"),
15886
+ const manifest = path30.join(source, "Package.swift");
15887
+ const targets = existsSync7(manifest) ? swiftManifestTargets(
15888
+ readFileSync18(manifest, "utf8"),
15591
15889
  [],
15592
- (file) => readFileSync17(file, "utf8")
15890
+ (file) => readFileSync18(file, "utf8")
15593
15891
  ) : [];
15594
15892
  let dependencyOverlays;
15595
15893
  const compiled = compiledSwiftSources(
@@ -15613,15 +15911,15 @@ function prepareSwiftDependency(source, destination, overlayFrameworks) {
15613
15911
  () => []
15614
15912
  );
15615
15913
  const copy = (from, to) => {
15616
- mkdirSync7(to, { recursive: true });
15914
+ mkdirSync8(to, { recursive: true });
15617
15915
  for (const entry of readdirSync8(from, { withFileTypes: true })) {
15618
15916
  if (entry.name === ".git" || entry.name === ".build" || entry.name === ".swiftpm")
15619
15917
  continue;
15620
- const file = path28.join(from, entry.name);
15621
- const target = path28.join(to, entry.name);
15918
+ const file = path30.join(from, entry.name);
15919
+ const target = path30.join(to, entry.name);
15622
15920
  if (entry.isDirectory()) copy(file, target);
15623
15921
  else if (entry.isFile() && entry.name.endsWith(".swift"))
15624
- writeFileSync8(target, compiled.get(path28.relative(source, file)));
15922
+ writeFileSync9(target, compiled.get(path30.relative(source, file)));
15625
15923
  else cpSync(file, target, { verbatimSymlinks: true });
15626
15924
  }
15627
15925
  };
@@ -15643,18 +15941,18 @@ function swiftWholeFileArm64Guard(source) {
15643
15941
  }
15644
15942
  function clangImportModuleMapFlags(settings, layoutRoot, written, generated) {
15645
15943
  const searched = new Set(settings.headerSearchPaths);
15646
- const directory = path28.join(layoutRoot, ".build", "peach-clang-modulemaps");
15944
+ const directory = path30.join(layoutRoot, ".build", "peach-clang-modulemaps");
15647
15945
  return (settings.moduleMaps ?? []).flatMap((map) => {
15648
- const headers = path28.join(layoutRoot, map.headers);
15649
- if (!existsSync6(headers)) return [];
15650
- const published = path28.join(headers, "module.modulemap");
15651
- if (searched.has(map.headers) && existsSync6(published)) return [];
15652
- if (!searched.has(map.headers) && existsSync6(published))
15946
+ const headers = path30.join(layoutRoot, map.headers);
15947
+ if (!existsSync7(headers)) return [];
15948
+ const published = path30.join(headers, "module.modulemap");
15949
+ if (searched.has(map.headers) && existsSync7(published)) return [];
15950
+ if (!searched.has(map.headers) && existsSync7(published))
15653
15951
  return [`-fmodule-map-file=${published}`];
15654
15952
  const cached = written.get(headers);
15655
15953
  if (cached) return [cached];
15656
- mkdirSync7(directory, { recursive: true });
15657
- const output = path28.join(directory, `module-${written.size}.modulemap`);
15954
+ mkdirSync8(directory, { recursive: true });
15955
+ const output = path30.join(directory, `module-${written.size}.modulemap`);
15658
15956
  writeBuildFile(
15659
15957
  output,
15660
15958
  swiftPackageClangModuleMap(swiftTargetModuleName(map.module), {
@@ -15688,7 +15986,7 @@ function needsNativeToolset(input, prebuilt) {
15688
15986
  input.packageFiles || prebuilt || Object.keys(input.files).some(isSwiftNativeTranslationUnit)
15689
15987
  );
15690
15988
  }
15691
- function writeSwiftProject(layout2, input, moduleRoot, prebuilt) {
15989
+ function writeSwiftProject(layout2, input, moduleRoot, prebuilt, allowHeaderCompiler = false) {
15692
15990
  const nativeToolset = needsNativeToolset(input, prebuilt);
15693
15991
  if (input.headerAliases !== void 0 && !isSwiftHeaderAliases(input.headerAliases))
15694
15992
  throw new Error("swift compile input has invalid original header aliases");
@@ -15719,7 +16017,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
15719
16017
  const targets = distribution && compileTargets(input).length === 0 ? [
15720
16018
  {
15721
16019
  name: "App",
15722
- path: path28.relative(layout2.root, layout2.sources),
16020
+ path: path30.relative(layout2.root, layout2.sources),
15723
16021
  executable: true,
15724
16022
  languageMode: 5,
15725
16023
  mainActorIsolation: false,
@@ -15745,12 +16043,12 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
15745
16043
  if (!file.endsWith(".swift")) continue;
15746
16044
  const target = bySourcePath.find(
15747
16045
  (candidate) => (candidate.path === "." || file.startsWith(`${candidate.path}/`)) && (candidate.sources === void 0 || candidate.sources.some((source) => {
15748
- const selected = path28.posix.join(candidate.path, source);
16046
+ const selected = path30.posix.join(candidate.path, source);
15749
16047
  return file === selected || file.startsWith(`${selected}/`);
15750
16048
  }))
15751
16049
  );
15752
16050
  const excluded = target?.exclude?.some(
15753
- (name2) => file === path28.posix.join(target.path, name2)
16051
+ (name2) => file === path30.posix.join(target.path, name2)
15754
16052
  );
15755
16053
  if (target && !excluded) swiftTargets.add(target.name);
15756
16054
  }
@@ -15776,24 +16074,24 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
15776
16074
  ([file, contents2]) => file.endsWith(".swift") ? [contents2] : []
15777
16075
  )
15778
16076
  );
15779
- const headerDirectory = path28.join(layout2.root, ".build", "peach-cxx-headers");
16077
+ const headerDirectory = path30.join(layout2.root, ".build", "peach-cxx-headers");
15780
16078
  const flattenedHeaders = /* @__PURE__ */ new Set();
15781
- if (existsSync6(headerDirectory)) {
16079
+ if (existsSync7(headerDirectory)) {
15782
16080
  for (const entry of readdirSync8(headerDirectory, { withFileTypes: true }))
15783
16081
  if (entry.isDirectory() && !targets.some((target) => target.name === entry.name))
15784
- rmSync7(path28.join(headerDirectory, entry.name), { recursive: true, force: true });
16082
+ rmSync8(path30.join(headerDirectory, entry.name), { recursive: true, force: true });
15785
16083
  }
15786
16084
  let checkedToolchain;
15787
16085
  const nativeToolchain = () => {
15788
16086
  if (checkedToolchain) return checkedToolchain;
15789
- const pin = distribution ?? JSON.parse(readFileSync17(path28.join(moduleRoot, "toolchain.json"), "utf8"));
16087
+ const pin = distribution ?? JSON.parse(readFileSync18(path30.join(moduleRoot, "toolchain.json"), "utf8"));
15790
16088
  checkedToolchain = swiftToolchain(pin.release, swiftModuleSdk(moduleRoot));
15791
16089
  return checkedToolchain;
15792
16090
  };
15793
16091
  const deploymentTarget = (name2) => input.nativeTargets?.find((value) => value.name === name2)?.deploymentTarget ?? targets.find((value) => value.name === name2)?.iosDeploymentTarget ?? null;
15794
16092
  const targetStagedFiles = /* @__PURE__ */ new Map();
15795
16093
  const stageTargetFile = (target, file, contents2, options) => {
15796
- const relative = path28.relative(layout2.root, file).split(path28.sep).join(path28.posix.sep);
16094
+ const relative = path30.relative(layout2.root, file).split(path30.sep).join(path30.posix.sep);
15797
16095
  const prior = files.has(file) ? files.get(file) : Object.hasOwn(input.files, relative) ? input.files[relative] : void 0;
15798
16096
  if (!options?.allowExisting && prior !== void 0)
15799
16097
  throw new Error(`target ${target} already contains generated output ${relative}`);
@@ -15806,7 +16104,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
15806
16104
  const prefix = target.path === "." ? "" : `${target.path}/`;
15807
16105
  return Object.entries(input.files).filter(
15808
16106
  ([file]) => file.startsWith(prefix) && (target.sources === void 0 || !(file.endsWith(".swift") || isSwiftNativeTranslationUnit(file)) || target.sources.some((source) => {
15809
- const selected = path28.posix.join(prefix, source);
16107
+ const selected = path30.posix.join(prefix, source);
15810
16108
  return file === selected || file.startsWith(`${selected}/`);
15811
16109
  })) && !target.exclude?.some(
15812
16110
  (excluded) => file === `${prefix}${excluded}` || file.startsWith(`${prefix}${excluded}/`)
@@ -15827,7 +16125,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
15827
16125
  targetStagedFiles.delete(target.name);
15828
16126
  if (entries.some(([file]) => isSwiftNativeTranslationUnit(file)) && (swift || input.nativeTargets?.some((value) => value.name === target.name))) {
15829
16127
  if (!swift) {
15830
- const unprepared = path28.join(
16128
+ const unprepared = path30.join(
15831
16129
  layout2.root,
15832
16130
  target.path,
15833
16131
  "PeachUnprepared.generated.swift"
@@ -15842,7 +16140,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
15842
16140
  native.set(target.name, {
15843
16141
  mixed: true,
15844
16142
  path: target.path,
15845
- includeDirectory: path28.join(layout2.root, target.path, "include"),
16143
+ includeDirectory: path30.join(layout2.root, target.path, "include"),
15846
16144
  sources: [],
15847
16145
  lateSources: [],
15848
16146
  exclude: entries.filter(([file]) => !file.endsWith(".swift") && !file.endsWith(".metal")).map(([file]) => file.slice(prefix.length))
@@ -15864,15 +16162,15 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
15864
16162
  file
15865
16163
  )?.[1];
15866
16164
  if (owner)
15867
- podHeaders.set(path28.basename(file), [
15868
- ...podHeaders.get(path28.basename(file)) ?? [],
16165
+ podHeaders.set(path30.basename(file), [
16166
+ ...podHeaders.get(path30.basename(file)) ?? [],
15869
16167
  { owner, content: input.files[file] }
15870
16168
  ]);
15871
16169
  }
15872
- const podHeaderOwner = (file, content) => /\/Headers\/(?:Public|Private)\/([\w+-]+)\//.exec(file)?.[1] ?? podHeaders.get(path28.basename(file))?.find((header) => header.content === content)?.owner;
16170
+ const podHeaderOwner = (file, content) => /\/Headers\/(?:Public|Private)\/([\w+-]+)\//.exec(file)?.[1] ?? podHeaders.get(path30.basename(file))?.find((header) => header.content === content)?.owner;
15873
16171
  for (const settings of input.nativeTargets ?? []) {
15874
16172
  for (const file of settings.headers) {
15875
- const destination = path28.join(layout2.root, file);
16173
+ const destination = path30.join(layout2.root, file);
15876
16174
  if (files.has(destination)) continue;
15877
16175
  const interfaceModule = /(?:^|\/)(\w+)-Swift\.h$/.exec(file)?.[1];
15878
16176
  const frameworkHeader = !interfaceModule && /(?:^|\/)(\w+)\.framework\/Headers\/[\w+.-]+\.h$/.exec(file)?.[1];
@@ -15891,10 +16189,10 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
15891
16189
  }
15892
16190
  if (settings.flattensPublicHeaders)
15893
16191
  for (const header of settings.publicHeaders) {
15894
- const destination = path28.join(
16192
+ const destination = path30.join(
15895
16193
  headerDirectory,
15896
16194
  settings.name,
15897
- path28.basename(header)
16195
+ path30.basename(header)
15898
16196
  );
15899
16197
  if (flattenedHeaders.has(destination))
15900
16198
  throw new Error(`duplicate product header ${destination}`);
@@ -15902,9 +16200,9 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
15902
16200
  }
15903
16201
  }
15904
16202
  const nativeTargets = input.nativeTargets ?? [];
15905
- const fromInputRoot = (file) => file.startsWith(`${SWIFT_NATIVE_INPUT_ROOT}/`) ? path28.join(layout2.root, file.slice(SWIFT_NATIVE_INPUT_ROOT.length + 1)) : file;
16203
+ const fromInputRoot = (file) => file.startsWith(`${SWIFT_NATIVE_INPUT_ROOT}/`) ? path30.join(layout2.root, file.slice(SWIFT_NATIVE_INPUT_ROOT.length + 1)) : file;
15906
16204
  const headerSearch = writeXcodeHeaderSearch(
15907
- path28.join(layout2.root, ".build", "peach-xcode-headers"),
16205
+ path30.join(layout2.root, ".build", "peach-xcode-headers"),
15908
16206
  nativeTargets.map((settings) => ({
15909
16207
  headerMaps: settings.headerMaps.map((map) => ({
15910
16208
  flag: map.flag,
@@ -15915,26 +16213,26 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
15915
16213
  })),
15916
16214
  productHeaders: Object.fromEntries([
15917
16215
  ...Object.entries(settings.productHeaders).map(([product, file]) => [
15918
- path28.join(layout2.root, product),
15919
- path28.join(layout2.root, file)
16216
+ path30.join(layout2.root, product),
16217
+ path30.join(layout2.root, file)
15920
16218
  ]),
15921
16219
  ...settings.flattensPublicHeaders ? settings.publicHeaders.map((header) => [
15922
- path28.join(headerDirectory, settings.name, path28.basename(header)),
15923
- path28.join(layout2.root, header)
16220
+ path30.join(headerDirectory, settings.name, path30.basename(header)),
16221
+ path30.join(layout2.root, header)
15924
16222
  ]) : []
15925
16223
  ]),
15926
16224
  userHeaderSearchPaths: settings.userHeaderSearchPaths.map(
15927
- (directory) => path28.join(layout2.root, directory)
16225
+ (directory) => path30.join(layout2.root, directory)
15928
16226
  ),
15929
16227
  searchDirectories: [
15930
16228
  ...settings.headerSearchPaths,
15931
16229
  ...settings.frameworkSearchPaths
15932
- ].map((directory) => path28.join(layout2.root, directory))
16230
+ ].map((directory) => path30.join(layout2.root, directory))
15933
16231
  })),
15934
16232
  Object.fromEntries(
15935
16233
  Object.entries(input.headerAliases ?? {}).map(([alias, file]) => [
15936
- path28.join(layout2.root, alias),
15937
- path28.join(layout2.root, file)
16234
+ path30.join(layout2.root, alias),
16235
+ path30.join(layout2.root, file)
15938
16236
  ])
15939
16237
  )
15940
16238
  );
@@ -15963,16 +16261,13 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
15963
16261
  for (const [file, contents2] of entries) {
15964
16262
  const producers2 = /* @__PURE__ */ new Set();
15965
16263
  const source = contents2.replace(/\/\*[\s\S]*?\*\//g, "");
15966
- for (const match of source.matchAll(
15967
- /^\s*#\s*(?:include|import)\s*[<"]([^>"]+)[>"]/gm
15968
- )) {
15969
- const include = match[1];
16264
+ for (const include of nativeHeaderIncludes(contents2)) {
15970
16265
  const producer = /(?:^|\/)([^/]+)-Swift\.h$/.exec(include)?.[1];
15971
16266
  if (producer && swiftTargets.has(producer)) producers2.add(producer);
15972
16267
  const local = [
15973
- path28.posix.join(path28.posix.dirname(file), include),
16268
+ path30.posix.join(path30.posix.dirname(file), include),
15974
16269
  `${includes}${include}`,
15975
- ...searchRoots.map((root) => path28.posix.join(root, include))
16270
+ ...searchRoots.map((root) => path30.posix.join(root, include))
15976
16271
  ].find((candidate) => input.files[candidate] !== void 0);
15977
16272
  if (local) {
15978
16273
  reverse.set(local, [...reverse.get(local) ?? [], file]);
@@ -16003,7 +16298,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
16003
16298
  );
16004
16299
  const roots2 = settings.bridgingHeader ? [settings.bridgingHeader] : entries.some(([file]) => file.endsWith(".swift")) || importedModules.has(swiftTargetModuleName(target.name)) ? settings.publicHeaders : [];
16005
16300
  const search = [.../* @__PURE__ */ new Set([...settings?.headerSearchPaths ?? []])].flatMap(
16006
- (dir) => ["-I", path28.join(layout2.root, dir)]
16301
+ (dir) => ["-I", path30.join(layout2.root, dir)]
16007
16302
  );
16008
16303
  const toolchainBin = nativeToolchain();
16009
16304
  const stageFlags = (flags2, sdkInclude2) => flags2.map(
@@ -16015,7 +16310,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
16015
16310
  ...search,
16016
16311
  ...(settings?.frameworkSearchPaths ?? []).flatMap((dir) => [
16017
16312
  "-F",
16018
- path28.join(layout2.root, dir)
16313
+ path30.join(layout2.root, dir)
16019
16314
  ]),
16020
16315
  "-I",
16021
16316
  headerDirectory
@@ -16026,7 +16321,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
16026
16321
  ...search,
16027
16322
  ...settings.frameworkSearchPaths.flatMap((dir) => [
16028
16323
  "-F",
16029
- path28.join(layout2.root, dir)
16324
+ path30.join(layout2.root, dir)
16030
16325
  ]),
16031
16326
  "-I",
16032
16327
  headerDirectory
@@ -16036,13 +16331,13 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
16036
16331
  const flag = settings.importerFlags[index];
16037
16332
  if (flag === "-I" || flag === "-iquote") {
16038
16333
  const directory = settings.importerFlags[index + 1];
16039
- if (directory === void 0 || !path28.isAbsolute(directory)) {
16334
+ if (directory === void 0 || !path30.isAbsolute(directory)) {
16040
16335
  index++;
16041
16336
  continue;
16042
16337
  }
16043
16338
  }
16044
16339
  const joined = /^-(?:I|iquote)(.+)$/.exec(flag);
16045
- if (joined && !path28.isAbsolute(joined[1])) continue;
16340
+ if (joined && !path30.isAbsolute(joined[1])) continue;
16046
16341
  kept.push(flag);
16047
16342
  }
16048
16343
  return [
@@ -16051,13 +16346,13 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
16051
16346
  ...search,
16052
16347
  ...(settings?.frameworkSearchPaths ?? []).flatMap((dir) => [
16053
16348
  "-F",
16054
- path28.join(layout2.root, dir)
16349
+ path30.join(layout2.root, dir)
16055
16350
  ]),
16056
16351
  "-I",
16057
16352
  headerDirectory
16058
16353
  ];
16059
16354
  })();
16060
- const sdkInclude = path28.join(
16355
+ const sdkInclude = path30.join(
16061
16356
  swiftSdkPaths(moduleRoot, toolchainBin).sysroot,
16062
16357
  "darwin/usr/include"
16063
16358
  );
@@ -16072,7 +16367,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
16072
16367
  ...dependencyModuleMaps,
16073
16368
  ...target.defines?.includes(SWIFT_XCODE_BUILD_CONDITION) && !target.defines.includes("SWIFT_PACKAGE") ? ["-USWIFT_PACKAGE"] : []
16074
16369
  ];
16075
- const prefixHeader = settings?.prefixHeader ? ["-include", path28.join(layout2.root, settings.prefixHeader)] : [];
16370
+ const prefixHeader = settings?.prefixHeader ? ["-include", path30.join(layout2.root, settings.prefixHeader)] : [];
16076
16371
  const bundleName = entries.some(([file]) => file.endsWith(".swift")) ? void 0 : swiftObjCResourceBundleName({
16077
16372
  target: target.name,
16078
16373
  path: target.path,
@@ -16083,7 +16378,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
16083
16378
  bundles: input.resourceBundles
16084
16379
  });
16085
16380
  const accessor = bundleName === void 0 ? void 0 : swiftObjCResourceAccessor(bundleName);
16086
- const accessorHeader = path28.join(
16381
+ const accessorHeader = path30.join(
16087
16382
  layout2.root,
16088
16383
  target.path,
16089
16384
  OBJC_RESOURCE_ACCESSOR_HEADER
@@ -16094,7 +16389,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
16094
16389
  const nativeUnits = accessor ? [...units, [accessorUnit, accessor.body]] : units;
16095
16390
  const unitSource = (file) => {
16096
16391
  const relative = file.slice(prefix.length);
16097
- return relative.split("/").some((part) => part.startsWith(".")) ? path28.posix.join(HIDDEN_UNITS, relative.replaceAll(/(^|\/)\./g, "$1%2E")) : relative;
16392
+ return relative.split("/").some((part) => part.startsWith(".")) ? path30.posix.join(HIDDEN_UNITS, relative.replaceAll(/(^|\/)\./g, "$1%2E")) : relative;
16098
16393
  };
16099
16394
  const accessorFlags = accessor ? ["-include", accessorHeader] : [];
16100
16395
  const nativeC = !entries.some(([file]) => file.endsWith(".swift"));
@@ -16124,20 +16419,20 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
16124
16419
  )
16125
16420
  ].sort();
16126
16421
  const topHeaders = settings.publicHeaders.filter(
16127
- (file) => path28.posix.dirname(file) === headerDir
16422
+ (file) => path30.posix.dirname(file) === headerDir
16128
16423
  );
16129
16424
  if (input.files[custom] !== void 0) {
16130
16425
  swiftpmModuleMap = { path: custom, contents: input.files[custom] };
16131
16426
  } else if (input.files[umbrella] !== void 0) {
16132
16427
  if (siblingDirs.length > 0)
16133
16428
  throw new Error(
16134
- `target ${target.name} has invalid header layout: umbrella header found at '${path28.join(layout2.root, umbrella)}', but directories exist next to it: ${siblingDirs.map((name2) => path28.join(layout2.root, headerDir, name2)).join(", ")}; consider removing them`
16429
+ `target ${target.name} has invalid header layout: umbrella header found at '${path30.join(layout2.root, umbrella)}', but directories exist next to it: ${siblingDirs.map((name2) => path30.join(layout2.root, headerDir, name2)).join(", ")}; consider removing them`
16135
16430
  );
16136
16431
  swiftpmModuleMap = {
16137
16432
  path: custom,
16138
16433
  contents: swiftPackageClangModuleMap(moduleName, {
16139
16434
  kind: "header",
16140
- path: path28.join(layout2.root, umbrella)
16435
+ path: path30.join(layout2.root, umbrella)
16141
16436
  })
16142
16437
  };
16143
16438
  } else if (input.files[nestedUmbrella] !== void 0 && siblingDirs.length === 1 && siblingDirs[0] === moduleName && topHeaders.length === 0) {
@@ -16145,7 +16440,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
16145
16440
  path: custom,
16146
16441
  contents: swiftPackageClangModuleMap(moduleName, {
16147
16442
  kind: "header",
16148
- path: path28.join(layout2.root, nestedUmbrella)
16443
+ path: path30.join(layout2.root, nestedUmbrella)
16149
16444
  })
16150
16445
  };
16151
16446
  } else {
@@ -16153,12 +16448,12 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
16153
16448
  path: custom,
16154
16449
  contents: swiftPackageClangModuleMap(moduleName, {
16155
16450
  kind: "directory",
16156
- path: path28.join(layout2.root, headerDir)
16451
+ path: path30.join(layout2.root, headerDir)
16157
16452
  })
16158
16453
  };
16159
16454
  }
16160
16455
  }
16161
- const modulemap = (originalModuleMap ? originalModuleMap[0].endsWith("/Modules/module.modulemap") ? originalModuleMap[0] : originalModuleMap[1] : void 0) ?? swiftpmModuleMap?.path ?? packageModuleMap?.[0] ?? path28.posix.join(
16456
+ const modulemap = (originalModuleMap ? originalModuleMap[0].endsWith("/Modules/module.modulemap") ? originalModuleMap[0] : originalModuleMap[1] : void 0) ?? swiftpmModuleMap?.path ?? packageModuleMap?.[0] ?? path30.posix.join(
16162
16457
  ".build",
16163
16458
  "peach-objc-originals",
16164
16459
  target.name,
@@ -16166,79 +16461,79 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
16166
16461
  );
16167
16462
  const moduleContents = originalModuleMap ? input.files[originalModuleMap[1]] : swiftpmModuleMap?.contents ?? packageModuleMap?.[1] ?? swiftObjCModuleMap(
16168
16463
  swiftTargetModuleName(target.name),
16169
- roots2.map((file) => path28.join(layout2.root, file)),
16464
+ roots2.map((file) => path30.join(layout2.root, file)),
16170
16465
  submoduleImports.get(swiftTargetModuleName(target.name))
16171
16466
  );
16172
16467
  if (moduleContents === void 0)
16173
16468
  throw new Error("missing original module map " + modulemap);
16174
- stageTargetFile(target.name, path28.join(layout2.root, modulemap), moduleContents, {
16469
+ stageTargetFile(target.name, path30.join(layout2.root, modulemap), moduleContents, {
16175
16470
  allowExisting: true
16176
16471
  });
16177
16472
  sourceModuleMaps.set(swiftTargetModuleName(target.name), {
16178
- path: path28.join(layout2.root, modulemap),
16473
+ path: path30.join(layout2.root, modulemap),
16179
16474
  contents: moduleContents.toString()
16180
16475
  });
16181
16476
  if (modulemap.endsWith("/Modules/module.modulemap")) {
16182
- const framework = path28.posix.dirname(path28.posix.dirname(modulemap));
16477
+ const framework = path30.posix.dirname(path30.posix.dirname(modulemap));
16183
16478
  for (const [, header] of moduleContents.toString().matchAll(/\bheader\s+"([^"]+)"/g))
16184
16479
  for (const folder of ["Headers", "PrivateHeaders"]) {
16185
- const source = settings.productHeaders[path28.posix.join(framework, folder, header)];
16480
+ const source = settings.productHeaders[path30.posix.join(framework, folder, header)];
16186
16481
  const contents2 = source === void 0 ? void 0 : input.files[source];
16187
16482
  if (contents2 !== void 0)
16188
16483
  stageTargetFile(
16189
16484
  target.name,
16190
- path28.join(layout2.root, path28.posix.dirname(modulemap), folder, header),
16485
+ path30.join(layout2.root, path30.posix.dirname(modulemap), folder, header),
16191
16486
  contents2,
16192
16487
  { allowExisting: true }
16193
16488
  );
16194
16489
  }
16195
16490
  }
16196
- if (nativeC && path28.posix.basename(modulemap) !== "module.modulemap") {
16491
+ if (nativeC && path30.posix.basename(modulemap) !== "module.modulemap") {
16197
16492
  stageTargetFile(
16198
16493
  target.name,
16199
- path28.join(layout2.root, path28.posix.dirname(modulemap), "module.modulemap"),
16200
- `extern module ${swiftTargetModuleName(target.name)} ${JSON.stringify(path28.join(layout2.root, modulemap))}
16494
+ path30.join(layout2.root, path30.posix.dirname(modulemap), "module.modulemap"),
16495
+ `extern module ${swiftTargetModuleName(target.name)} ${JSON.stringify(path30.join(layout2.root, modulemap))}
16201
16496
  `
16202
16497
  );
16203
16498
  }
16204
16499
  const importFlags = [
16205
16500
  ...swiftClangImporterFlags(stageFlags(importOriginalFlags, sdkInclude)),
16206
- "-fmodule-map-file=" + path28.join(layout2.root, modulemap),
16501
+ "-fmodule-map-file=" + path30.join(layout2.root, modulemap),
16207
16502
  ...dependencyModuleMaps
16208
16503
  ];
16209
16504
  const groups = /* @__PURE__ */ new Map();
16210
16505
  for (const [file, contents2] of nativeUnits) {
16211
16506
  const origin = settings?.sourceDirectories[file];
16212
16507
  if (origin) {
16213
- const original = path28.join(layout2.root, origin, path28.posix.basename(file));
16214
- mkdirSync7(path28.dirname(original), { recursive: true });
16508
+ const original = path30.join(layout2.root, origin, path30.posix.basename(file));
16509
+ mkdirSync8(path30.dirname(original), { recursive: true });
16215
16510
  stageTargetFile(target.name, original, contents2, { allowExisting: true });
16216
16511
  }
16217
16512
  const source = unitSource(file);
16218
16513
  if (source !== file.slice(prefix.length))
16219
16514
  stageTargetFile(
16220
16515
  target.name,
16221
- path28.join(layout2.root, target.path, source),
16516
+ path30.join(layout2.root, target.path, source),
16222
16517
  contents2,
16223
16518
  {
16224
16519
  allowExisting: true
16225
16520
  }
16226
16521
  );
16227
- const stagedDir = path28.posix.dirname(file);
16522
+ const stagedDir = path30.posix.dirname(file);
16228
16523
  const quoteDirs = [
16229
16524
  ...stagedDir !== "." ? [stagedDir] : [],
16230
16525
  ...origin && origin !== stagedDir ? [origin] : []
16231
16526
  ];
16232
16527
  const quoteFlags = quoteDirs.flatMap((dir) => [
16233
16528
  "-iquote",
16234
- path28.join(layout2.root, dir)
16529
+ path30.join(layout2.root, dir)
16235
16530
  ]);
16236
16531
  const perFile = [
16237
16532
  ...file.endsWith(".c") && swiftWholeFileArm64Guard(contents2) ? ["-D__arm64__=1"] : [],
16238
16533
  .../\.mm?$/.test(file) ? ["-fobjc-exceptions"] : [],
16239
16534
  ...stageFlags(
16240
16535
  settings?.fileFlags[file] ?? [],
16241
- path28.join(
16536
+ path30.join(
16242
16537
  swiftSdkPaths(moduleRoot, toolchainBin).sysroot,
16243
16538
  "darwin/usr/include"
16244
16539
  )
@@ -16246,7 +16541,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
16246
16541
  ];
16247
16542
  const cxx = /\.(?:cc|cpp|cxx|mm)$/.test(file);
16248
16543
  const moduleFlag = perFile.some((flag) => flag.startsWith("-fmodule-name=")) ? [] : [`-fmodule-name=${swiftTargetModuleName(target.name)}`];
16249
- const identity = createHash14("sha256").update(
16544
+ const identity = createHash15("sha256").update(
16250
16545
  JSON.stringify([
16251
16546
  cxx,
16252
16547
  quoteFlags,
@@ -16255,12 +16550,12 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
16255
16550
  ])
16256
16551
  ).digest("hex").slice(0, 12);
16257
16552
  const name2 = `${target.name}${nativeC ? "Native" : "Swift"}Implementation_${identity}`;
16258
- const groupPath = path28.posix.join("PeachNativeSources", name2);
16259
- const canonicalTargetPath = path28.posix.join("/peach/build", target.path);
16553
+ const groupPath = path30.posix.join("PeachNativeSources", name2);
16554
+ const canonicalTargetPath = path30.posix.join("/peach/build", target.path);
16260
16555
  const sourceIdentity = [
16261
- `-ffile-prefix-map=${path28.join(layout2.root, groupPath)}=${canonicalTargetPath}`,
16556
+ `-ffile-prefix-map=${path30.join(layout2.root, groupPath)}=${canonicalTargetPath}`,
16262
16557
  ...nativeToolset ? [
16263
- `-ffile-prefix-map=${path28.posix.join("/peach/build", groupPath)}=${canonicalTargetPath}`
16558
+ `-ffile-prefix-map=${path30.posix.join("/peach/build", groupPath)}=${canonicalTargetPath}`
16264
16559
  ] : []
16265
16560
  ];
16266
16561
  const group = groups.get(identity) ?? {
@@ -16284,7 +16579,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
16284
16579
  ...accessorFlags,
16285
16580
  ...stageFlags(
16286
16581
  cxx ? settings.cxxFlags : [],
16287
- path28.join(
16582
+ path30.join(
16288
16583
  swiftSdkPaths(moduleRoot, toolchainBin).sysroot,
16289
16584
  "darwin/usr/include"
16290
16585
  )
@@ -16295,12 +16590,12 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
16295
16590
  };
16296
16591
  stageTargetFile(
16297
16592
  target.name,
16298
- path28.join(layout2.root, group.path, source),
16593
+ path30.join(layout2.root, group.path, source),
16299
16594
  contents2
16300
16595
  );
16301
16596
  stageTargetFile(
16302
16597
  target.name,
16303
- path28.join(layout2.root, group.path, "include/module.modulemap"),
16598
+ path30.join(layout2.root, group.path, "include/module.modulemap"),
16304
16599
  `module ${swiftTargetModuleName(group.name)} { export * }
16305
16600
  `,
16306
16601
  { allowExisting: true }
@@ -16312,7 +16607,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
16312
16607
  stageTargetFile(target.name, accessorHeader, accessor.header);
16313
16608
  stageTargetFile(
16314
16609
  target.name,
16315
- path28.join(layout2.root, accessorUnit),
16610
+ path30.join(layout2.root, accessorUnit),
16316
16611
  accessor.body
16317
16612
  );
16318
16613
  }
@@ -16327,7 +16622,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
16327
16622
  ].sort();
16328
16623
  native.set(target.name, {
16329
16624
  path: target.path,
16330
- includeDirectory: path28.dirname(path28.join(layout2.root, modulemap)),
16625
+ includeDirectory: path30.dirname(path30.join(layout2.root, modulemap)),
16331
16626
  importFlags,
16332
16627
  sources: nativeUnits.map(([file]) => unitSource(file)),
16333
16628
  lateSources: implementations.flatMap((group) => group.sources),
@@ -16350,23 +16645,23 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
16350
16645
  throw new Error(`original module map declares no module: ${modulemap}`);
16351
16646
  stageTargetFile(
16352
16647
  target.name,
16353
- path28.join(layout2.root, owner.path, "include/module.modulemap"),
16354
- `extern module ${exportedModule} ${JSON.stringify(path28.join(layout2.root, modulemap))}
16648
+ path30.join(layout2.root, owner.path, "include/module.modulemap"),
16649
+ `extern module ${exportedModule} ${JSON.stringify(path30.join(layout2.root, modulemap))}
16355
16650
  `,
16356
16651
  { allowExisting: true }
16357
16652
  );
16358
16653
  }
16359
16654
  continue;
16360
16655
  }
16361
- const implementationHeaders = path28.posix.join(
16656
+ const implementationHeaders = path30.posix.join(
16362
16657
  ".build",
16363
16658
  "peach-objc-implementations",
16364
16659
  target.name
16365
16660
  );
16366
- const include = path28.join(layout2.root, implementationHeaders);
16661
+ const include = path30.join(layout2.root, implementationHeaders);
16367
16662
  stageTargetFile(
16368
16663
  target.name,
16369
- path28.join(include, "module.modulemap"),
16664
+ path30.join(include, "module.modulemap"),
16370
16665
  `module ${target.name}ImplementationDeclarations { export * }
16371
16666
  `
16372
16667
  );
@@ -16376,7 +16671,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
16376
16671
  includeDirectory: include,
16377
16672
  importFlags,
16378
16673
  swiftFlags: [
16379
- ...settings.bridgingHeader ? ["-import-objc-header", path28.join(layout2.root, settings.bridgingHeader)] : roots2.length ? ["-import-underlying-module"] : [],
16674
+ ...settings.bridgingHeader ? ["-import-objc-header", path30.join(layout2.root, settings.bridgingHeader)] : roots2.length ? ["-import-underlying-module"] : [],
16380
16675
  ...importFlags.flatMap((flag) => ["-Xcc", flag])
16381
16676
  ],
16382
16677
  sources: nativeUnits.map(([file]) => unitSource(file)),
@@ -16406,7 +16701,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
16406
16701
  }
16407
16702
  native.set(target.name, {
16408
16703
  path: target.path,
16409
- includeDirectory: path28.join(layout2.root, includes),
16704
+ includeDirectory: path30.join(layout2.root, includes),
16410
16705
  sources: units.map(([file]) => file.slice(prefix.length)),
16411
16706
  lateSources: late.map(([file]) => file.slice(prefix.length)),
16412
16707
  ...late.length > 0 ? {
@@ -16420,7 +16715,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
16420
16715
  });
16421
16716
  if (late.length > 0)
16422
16717
  files.set(
16423
- path28.join(layout2.root, target.path, "PeachSwiftImplementation/module.modulemap"),
16718
+ path30.join(layout2.root, target.path, "PeachSwiftImplementation/module.modulemap"),
16424
16719
  `module ${swiftTargetModuleName(`${target.name}SwiftImplementation`)} { export * }
16425
16720
  `
16426
16721
  );
@@ -16432,7 +16727,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
16432
16727
  ([file]) => file.startsWith(includes) && /\.(?:h|hpp|hh|hxx)$/.test(file) && consumers.get(file).size === 0
16433
16728
  );
16434
16729
  files.set(
16435
- path28.join(layout2.root, includes, "module.modulemap"),
16730
+ path30.join(layout2.root, includes, "module.modulemap"),
16436
16731
  [
16437
16732
  `module ${target.name} {`,
16438
16733
  ...roots.map(
@@ -16447,14 +16742,14 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
16447
16742
  for (const map of generatedModuleMaps)
16448
16743
  if (files.has(map.published) || Object.hasOwn(
16449
16744
  input.files,
16450
- path28.relative(layout2.root, map.published).split(path28.sep).join(path28.posix.sep)
16745
+ path30.relative(layout2.root, map.published).split(path30.sep).join(path30.posix.sep)
16451
16746
  ))
16452
16747
  writeBuildFile(
16453
16748
  map.output,
16454
16749
  `extern module ${map.module} ${JSON.stringify(map.published)}
16455
16750
  `
16456
16751
  );
16457
- if (native.size > 0) mkdirSync7(headerDirectory, { recursive: true });
16752
+ if (native.size > 0) mkdirSync8(headerDirectory, { recursive: true });
16458
16753
  const headerAliasFlags = Object.keys(input.headerAliases ?? {}).length > 0 ? ["-ivfsoverlay", headerSearch.files[0]] : [];
16459
16754
  const nativeHeaderFlags = [...headerAliasFlags];
16460
16755
  const nativeSwiftHeaderMaps = /* @__PURE__ */ new Map();
@@ -16476,10 +16771,10 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
16476
16771
  [...native.values()].flatMap((value) => value.late?.producers ?? [])
16477
16772
  )) {
16478
16773
  files.set(
16479
- path28.join(headerDirectory, name2, name2 + "-Swift.h"),
16774
+ path30.join(headerDirectory, name2, name2 + "-Swift.h"),
16480
16775
  '#include "../' + name2 + '-Swift.h"\n'
16481
16776
  );
16482
- const modulemap = path28.join(
16777
+ const modulemap = path30.join(
16483
16778
  layout2.root,
16484
16779
  ".build",
16485
16780
  "peach-objc-swift-headers",
@@ -16489,7 +16784,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
16489
16784
  const moduleName = swiftTargetModuleName(name2);
16490
16785
  const originalMap = originalMaps.get(moduleName);
16491
16786
  const stagedMap = sourceModuleMaps.get(moduleName);
16492
- const originalPath = stagedMap?.path ?? (originalMap ? path28.join(layout2.root, originalMap) : void 0);
16787
+ const originalPath = stagedMap?.path ?? (originalMap ? path30.join(layout2.root, originalMap) : void 0);
16493
16788
  const originalContents = stagedMap?.contents ?? (originalMap && input.files[originalMap]);
16494
16789
  const originalTokens = originalContents ? moduleMapTokens(originalContents) : [];
16495
16790
  if (originalPath && originalTokens.some(
@@ -16503,29 +16798,29 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
16503
16798
  modulemap,
16504
16799
  originalPath ? `extern module ${moduleName} ${JSON.stringify(originalPath)}
16505
16800
  module ${moduleName}.Swift {
16506
- header ${JSON.stringify(path28.join(headerDirectory, name2 + "-Swift.h"))}
16801
+ header ${JSON.stringify(path30.join(headerDirectory, name2 + "-Swift.h"))}
16507
16802
  requires objc
16508
16803
  }
16509
16804
  ` : swiftObjCModuleMap(
16510
16805
  moduleName,
16511
- (input.nativeTargets?.find((target) => target.name === name2)?.publicHeaders ?? []).map((header) => path28.join(layout2.root, header)),
16806
+ (input.nativeTargets?.find((target) => target.name === name2)?.publicHeaders ?? []).map((header) => path30.join(layout2.root, header)),
16512
16807
  submoduleImports.get(moduleName),
16513
- path28.join(headerDirectory, name2 + "-Swift.h")
16808
+ path30.join(headerDirectory, name2 + "-Swift.h")
16514
16809
  )
16515
16810
  );
16516
16811
  nativeHeaderFlags.push("-fmodule-map-file=" + modulemap);
16517
16812
  nativeSwiftHeaderMaps.set(name2, modulemap);
16518
16813
  }
16519
- const modulePlan = createHash14("sha256").update(
16814
+ const modulePlan = createHash15("sha256").update(
16520
16815
  swiftModuleInputFiles(moduleRoot).join("\n")
16521
16816
  );
16522
16817
  if (!distribution) {
16523
- modulePlan.update(readFileSync17(path28.join(moduleRoot, "Package.swift")));
16818
+ modulePlan.update(readFileSync18(path30.join(moduleRoot, "Package.swift")));
16524
16819
  }
16525
16820
  modulePlan.update(
16526
16821
  Object.keys(input.files).filter((file) => file.endsWith(".swift")).sort().join("\n")
16527
16822
  );
16528
- const resourcePlan = createHash14("sha256").update(
16823
+ const resourcePlan = createHash15("sha256").update(
16529
16824
  JSON.stringify(
16530
16825
  resourceTargets.filter((target) => target.resources).map((target) => [
16531
16826
  target.name,
@@ -16575,7 +16870,7 @@ module ${moduleName}.Swift {
16575
16870
  (target) => {
16576
16871
  const native2 = input.nativeTargets?.find(({ name: name2 }) => name2 === target.name);
16577
16872
  if (native2) return native2.publicHeaders.map((file) => input.files[file] ?? "");
16578
- const directory = path28.posix.join(
16873
+ const directory = path30.posix.join(
16579
16874
  target.path,
16580
16875
  target.publicHeadersPath ?? "include"
16581
16876
  );
@@ -16611,7 +16906,7 @@ module ${moduleName}.Swift {
16611
16906
  `;
16612
16907
  } else if (mains.length === 0) {
16613
16908
  const procedural = entries.filter(
16614
- ([file, source]) => path28.basename(file) === "main.swift" && swiftApplicationEntry(file, source)
16909
+ ([file, source]) => path30.basename(file) === "main.swift" && swiftApplicationEntry(file, source)
16615
16910
  );
16616
16911
  const wrapped = procedural.length === 1 ? wrapUIApplicationMainEntry(procedural[0][1]) : null;
16617
16912
  if (wrapped) {
@@ -16632,7 +16927,7 @@ module ${moduleName}.Swift {
16632
16927
  `mixed executable ${target.name} requires one typed Swift application entry`
16633
16928
  );
16634
16929
  files.set(
16635
- path28.join(layout2.root, nativeMains[0][0]),
16930
+ path30.join(layout2.root, nativeMains[0][0]),
16636
16931
  neutralizedNativeMain(nativeMains[0][1])
16637
16932
  );
16638
16933
  nativeEntry = true;
@@ -16644,9 +16939,9 @@ module ${moduleName}.Swift {
16644
16939
  }
16645
16940
  if (!nativeEntry) {
16646
16941
  compiled.set(entryFile, entrySource);
16647
- if (path28.basename(entryFile) === "main.swift") {
16648
- const libraryEntry = path28.posix.join(
16649
- path28.posix.dirname(entryFile),
16942
+ if (path30.basename(entryFile) === "main.swift") {
16943
+ const libraryEntry = path30.posix.join(
16944
+ path30.posix.dirname(entryFile),
16650
16945
  "PeachApplicationEntry.generated.swift"
16651
16946
  );
16652
16947
  if (Object.hasOwn(input.files, libraryEntry))
@@ -16670,7 +16965,7 @@ module ${moduleName}.Swift {
16670
16965
  exclude: []
16671
16966
  });
16672
16967
  files.set(
16673
- path28.join(layout2.root, `PeachApplication/${name2}/Entry.swift`),
16968
+ path30.join(layout2.root, `PeachApplication/${name2}/Entry.swift`),
16674
16969
  !nativeEntry ? `import ${swiftTargetModuleName(target.name)}
16675
16970
  @main struct __PeachApplicationEntry { @MainActor static func main() { __peachRunApplication() } }
16676
16971
  ` : `import ${swiftTargetModuleName(target.name)}
@@ -16702,7 +16997,7 @@ module ${moduleName}.Swift {
16702
16997
  );
16703
16998
  if (nativeFlags) {
16704
16999
  const toolchainBin = nativeToolchain();
16705
- const headers = path28.join(swiftSdkPaths(moduleRoot, toolchainBin).sysroot, "darwin");
17000
+ const headers = path30.join(swiftSdkPaths(moduleRoot, toolchainBin).sysroot, "darwin");
16706
17001
  const dependencies2 = swiftTargetDependencies(input.files, targets);
16707
17002
  const reachesNative = (name2, seen = /* @__PURE__ */ new Set()) => {
16708
17003
  if (native.has(name2)) return true;
@@ -16747,10 +17042,10 @@ module ${moduleName}.Swift {
16747
17042
  if (targets.length === 0 && !prebuilt) {
16748
17043
  for (const [file, contents2] of Object.entries(input.files)) {
16749
17044
  if (file === "Package.swift") continue;
16750
- files.set(path28.join(layout2.sources, file), compiled.get(file) ?? contents2);
17045
+ files.set(path30.join(layout2.sources, file), compiled.get(file) ?? contents2);
16751
17046
  }
16752
- let manifest2 = readFileSync17(
16753
- path28.join(moduleRoot, "scripts/contrast-app-Package.swift"),
17047
+ let manifest2 = readFileSync18(
17048
+ path30.join(moduleRoot, "scripts/contrast-app-Package.swift"),
16754
17049
  "utf8"
16755
17050
  ).replaceAll("__SOOTSIM_SWIFT_PACKAGE__", moduleRoot);
16756
17051
  const reactor = ` ${REACTOR_FLAG}`;
@@ -16797,35 +17092,35 @@ module ${moduleName}.Swift {
16797
17092
  [anchor, ...games.map((name2) => `${gameProduct(name2)},`)].join("\n ")
16798
17093
  );
16799
17094
  }
16800
- files.set(path28.join(layout2.root, "Package.swift"), manifest2 + moduleFiles);
17095
+ files.set(path30.join(layout2.root, "Package.swift"), manifest2 + moduleFiles);
16801
17096
  } else {
16802
17097
  const base = layout2.multi ? layout2.root : layout2.sources;
16803
17098
  const libraries = /* @__PURE__ */ new Map();
16804
- const binaryModules = path28.join(layout2.root, ".peach-binary-modules");
17099
+ const binaryModules = path30.join(layout2.root, ".peach-binary-modules");
16805
17100
  for (const [name2, data] of Object.entries(input.binaryModules ?? {})) {
16806
17101
  if (!/^[A-Za-z_]\w*$/.test(name2) || !input.libraries?.[name2])
16807
17102
  throw new Error(`invalid native Swift module ${name2}: its library is required`);
16808
17103
  files.set(
16809
- path28.join(binaryModules, `${name2}.swiftmodule`),
17104
+ path30.join(binaryModules, `${name2}.swiftmodule`),
16810
17105
  Buffer.from(data, "base64")
16811
17106
  );
16812
17107
  }
16813
17108
  for (const [target, data] of Object.entries(input.libraries ?? {})) {
16814
17109
  const bytes = Buffer.from(data, "base64");
16815
- const digest = createHash14("sha256").update(bytes).digest("hex");
16816
- const file = path28.join(layout2.root, ".peach-libraries", `lib${target}-${digest}.a`);
17110
+ const digest = createHash15("sha256").update(bytes).digest("hex");
17111
+ const file = path30.join(layout2.root, ".peach-libraries", `lib${target}-${digest}.a`);
16817
17112
  files.set(file, bytes);
16818
17113
  libraries.set(target, file);
16819
17114
  }
16820
17115
  for (const [file, contents2] of Object.entries(input.files)) {
16821
17116
  if (file === "Package.swift") continue;
16822
- const destination = path28.join(base, libraryEntryFiles.get(file) ?? file);
17117
+ const destination = path30.join(base, libraryEntryFiles.get(file) ?? file);
16823
17118
  const interfaceModule = /(?:^|\/)(\w+)-Swift\.h$/.exec(file)?.[1];
16824
17119
  const localInterface = interfaceModule && swiftTargets.has(interfaceModule) ? `#include ${JSON.stringify(
16825
- path28.relative(
16826
- path28.dirname(destination),
16827
- path28.join(headerDirectory, `${interfaceModule}-Swift.h`)
16828
- ).split(path28.sep).join("/")
17120
+ path30.relative(
17121
+ path30.dirname(destination),
17122
+ path30.join(headerDirectory, `${interfaceModule}-Swift.h`)
17123
+ ).split(path30.sep).join("/")
16829
17124
  )}
16830
17125
  ` : void 0;
16831
17126
  files.set(
@@ -16833,10 +17128,10 @@ module ${moduleName}.Swift {
16833
17128
  localInterface ?? compiled.get(file) ?? files.get(destination) ?? (interfaceModule && moduleInterface(interfaceModule)?.header) ?? contents2
16834
17129
  );
16835
17130
  }
16836
- const manifestTargets = targets.length > 0 ? targets : [
17131
+ const manifestTargets2 = targets.length > 0 ? targets : [
16837
17132
  {
16838
17133
  name: "App",
16839
- path: path28.relative(layout2.root, layout2.sources).split(path28.sep).join("/"),
17134
+ path: path30.relative(layout2.root, layout2.sources).split(path30.sep).join("/"),
16840
17135
  executable: true,
16841
17136
  languageMode: 5,
16842
17137
  mainActorIsolation: false,
@@ -16846,11 +17141,11 @@ module ${moduleName}.Swift {
16846
17141
  const reachesFrameworks = !distribution || swiftImportedModules.has("Foundation") || Object.entries(input.files).some(
16847
17142
  ([file, source]) => file.endsWith(".swift") && file !== input.entry && file !== "Package.swift" || /\.mm?$/.test(file) || source.includes("dispatch_")
16848
17143
  ) || [...importedModules].some(
16849
- (name2) => distribution.modules.includes(name2) && !targets.some((target) => target.name === name2) && !(clangImportedModules.has(name2) && !swiftImportedModules.has(name2) && existsSync6(
16850
- path28.join(swiftSharedSdkRoot(moduleRoot, true), "usr/include", name2)
17144
+ (name2) => distribution.modules.includes(name2) && !targets.some((target) => target.name === name2) && !(clangImportedModules.has(name2) && !swiftImportedModules.has(name2) && existsSync7(
17145
+ path30.join(swiftSharedSdkRoot(moduleRoot, true), "usr/include", name2)
16851
17146
  ))
16852
17147
  );
16853
- const frameworkLink = prebuilt ? path28.join(layout2.root, ".peach-framework-objects.rsp") : void 0;
17148
+ const frameworkLink = prebuilt ? path30.join(layout2.root, ".peach-framework-objects.rsp") : void 0;
16854
17149
  if (prebuilt && frameworkLink) {
16855
17150
  const quote = (object3) => `"${object3.replaceAll("\\", "\\\\").replaceAll('"', '\\"')}"`;
16856
17151
  files.set(
@@ -16866,10 +17161,10 @@ module ${moduleName}.Swift {
16866
17161
  }
16867
17162
  const moduleSiblings = swiftTargetDependencies(
16868
17163
  input.files,
16869
- layout2.multi ? manifestTargets : manifestTargets.map((target) => ({ ...target, path: "." }))
17164
+ layout2.multi ? manifestTargets2 : manifestTargets2.map((target) => ({ ...target, path: "." }))
16870
17165
  );
16871
- if (namesLibxml2(input) && !manifestTargets.some((target) => target.name === "libxml2")) {
16872
- const executable = manifestTargets.find((target) => target.executable);
17166
+ if (namesLibxml2(input) && !manifestTargets2.some((target) => target.name === "libxml2")) {
17167
+ const executable = manifestTargets2.find((target) => target.executable);
16873
17168
  if (executable) {
16874
17169
  const reached = moduleSiblings.get(executable.name) ?? [];
16875
17170
  if (!reached.includes("libxml2"))
@@ -16877,15 +17172,15 @@ module ${moduleName}.Swift {
16877
17172
  }
16878
17173
  }
16879
17174
  files.set(
16880
- path28.join(layout2.root, "Package.swift"),
17175
+ path30.join(layout2.root, "Package.swift"),
16881
17176
  emitSwiftPackageManifest({
16882
17177
  root: layout2.root,
16883
17178
  files,
16884
- targets: manifestTargets.map((target) => ({
17179
+ targets: manifestTargets2.map((target) => ({
16885
17180
  ...target,
16886
17181
  sources: target.sources?.map((source) => {
16887
- const entry = libraryEntryFiles.get(path28.posix.join(target.path, source));
16888
- return entry ? path28.posix.relative(target.path, entry) : source;
17182
+ const entry = libraryEntryFiles.get(path30.posix.join(target.path, source));
17183
+ return entry ? path30.posix.relative(target.path, entry) : source;
16889
17184
  })
16890
17185
  })),
16891
17186
  packages,
@@ -16919,7 +17214,7 @@ module ${moduleName}.Swift {
16919
17214
  ),
16920
17215
  ...reachesFrameworks ? {
16921
17216
  distributionLink: {
16922
- path: path28.join(layout2.root, ".peach-distribution-objects.rsp"),
17217
+ path: path30.join(layout2.root, ".peach-distribution-objects.rsp"),
16923
17218
  files
16924
17219
  }
16925
17220
  } : {},
@@ -16940,14 +17235,14 @@ module ${moduleName}.Swift {
16940
17235
  for (const [file, bytes] of Object.entries(input.packageFiles ?? {})) {
16941
17236
  const contents2 = Buffer.from(bytes, "base64");
16942
17237
  files.set(
16943
- path28.join(layout2.root, file),
17238
+ path30.join(layout2.root, file),
16944
17239
  file.endsWith(".swift") && !/(?:^|\/)Package(?:@swift-[\d.]+)?\.swift$/.test(file) ? withPreconcurrencyFoundationModules(
16945
17240
  swiftPackageSourceAsIOS(contents2.toString("utf8"))
16946
17241
  ) : contents2
16947
17242
  );
16948
17243
  }
16949
17244
  for (const [file, bytes] of Object.entries(input.projectFiles ?? {})) {
16950
- const destination = path28.join(layout2.root, file);
17245
+ const destination = path30.join(layout2.root, file);
16951
17246
  if (files.has(destination)) continue;
16952
17247
  files.set(destination, Buffer.from(bytes, "base64"));
16953
17248
  }
@@ -16956,13 +17251,13 @@ module ${moduleName}.Swift {
16956
17251
  const nativeToolsetFlags = [
16957
17252
  ...headerAliasFlags,
16958
17253
  ...native.size > 0 ? [
16959
- "-fmodule-map-file=" + path28.join(
17254
+ "-fmodule-map-file=" + path30.join(
16960
17255
  swiftSdkPaths(moduleRoot, nativeToolchain()).sysroot,
16961
17256
  "darwin/wasm/include/module.modulemap"
16962
17257
  )
16963
17258
  ] : []
16964
17259
  ];
16965
- const clangWrapper2 = path28.join(layout2.root, CLANG_TARGET_MODULE_WRAPPER);
17260
+ const clangWrapper2 = path30.join(layout2.root, CLANG_TARGET_MODULE_WRAPPER);
16966
17261
  files.set(
16967
17262
  clangWrapper2,
16968
17263
  [
@@ -17003,21 +17298,21 @@ module ${moduleName}.Swift {
17003
17298
  " done",
17004
17299
  "fi",
17005
17300
  'if [ -n "$name" ] && [ -z "$explicit" ]; then',
17006
- ` exec '${path28.join(nativeToolchain(), "clang")}' "-fmodule-name=$name" "$@"`,
17301
+ ` exec '${path30.join(nativeToolchain(), "clang")}' "-fmodule-name=$name" "$@"`,
17007
17302
  "fi",
17008
- `exec '${path28.join(nativeToolchain(), "clang")}' "$@"`,
17303
+ `exec '${path30.join(nativeToolchain(), "clang")}' "$@"`,
17009
17304
  ""
17010
17305
  ].join("\n")
17011
17306
  );
17012
17307
  files.set(
17013
- path28.join(layout2.root, ".peach-target-toolset.json"),
17308
+ path30.join(layout2.root, ".peach-target-toolset.json"),
17014
17309
  JSON.stringify({
17015
17310
  schemaVersion: "1.0",
17016
17311
  cCompiler: {
17017
17312
  extraCLIOptions: [
17018
17313
  ...nativeToolsetFlags,
17019
17314
  "-fmodules",
17020
- `-fmodules-cache-path=${path28.join(layout2.root, ".build", "ModuleCache")}`
17315
+ `-fmodules-cache-path=${path30.join(layout2.root, ".build", "ModuleCache")}`
17021
17316
  ]
17022
17317
  },
17023
17318
  ...nativeToolsetFlags.length > 0 ? { cxxCompiler: { extraCLIOptions: nativeToolsetFlags } } : {},
@@ -17027,12 +17322,12 @@ module ${moduleName}.Swift {
17027
17322
  distribution || prebuilt ? "-Isystem" : "-I",
17028
17323
  distribution ? providedModulesPath(
17029
17324
  layout2.root,
17030
- path28.join(moduleRoot, "modules"),
17325
+ path30.join(moduleRoot, "modules"),
17031
17326
  moduleExcludes
17032
- ) : prebuilt ? providedModulesPath(layout2.root, prebuilt.modules, moduleExcludes) : path28.join(layout2.root, ".build", WASM_TRIPLE, "release", "Modules"),
17327
+ ) : prebuilt ? providedModulesPath(layout2.root, prebuilt.modules, moduleExcludes) : path30.join(layout2.root, ".build", WASM_TRIPLE, "release", "Modules"),
17033
17328
  ...distribution ? distributionClangModuleOptions(
17034
17329
  layout2.root,
17035
- path28.join(moduleRoot, "modules")
17330
+ path30.join(moduleRoot, "modules")
17036
17331
  ) : [],
17037
17332
  ...prebuilt?.moduleMaps.flatMap((map) => [
17038
17333
  "-Xcc",
@@ -17062,9 +17357,9 @@ module ${moduleName}.Swift {
17062
17357
  throw new Error(
17063
17358
  `swift resource target ${target.name} has no matching bundle assignment`
17064
17359
  );
17065
- const directory = layout2.multi ? path28.join(layout2.root, target.path) : layout2.sources;
17360
+ const directory = layout2.multi ? path30.join(layout2.root, target.path) : layout2.sources;
17066
17361
  files.set(
17067
- path28.join(directory, "ResourceBundleAccessor.generated.swift"),
17362
+ path30.join(directory, "ResourceBundleAccessor.generated.swift"),
17068
17363
  [
17069
17364
  "import Foundation",
17070
17365
  "",
@@ -17081,7 +17376,7 @@ module ${moduleName}.Swift {
17081
17376
  }
17082
17377
  for (const [file, source] of compiled)
17083
17378
  if (!Object.hasOwn(input.files, file))
17084
- files.set(path28.join(layout2.multi ? layout2.root : layout2.sources, file), source);
17379
+ files.set(path30.join(layout2.multi ? layout2.root : layout2.sources, file), source);
17085
17380
  const producers = [
17086
17381
  .../* @__PURE__ */ new Set([...[...native.values()].flatMap((value) => value.late?.producers ?? [])])
17087
17382
  ];
@@ -17094,14 +17389,15 @@ module ${moduleName}.Swift {
17094
17389
  generatedOwners.set(group.name, owner);
17095
17390
  }
17096
17391
  }
17097
- const manifestPath = path28.join(layout2.root, "Package.swift");
17392
+ const manifestPath = path30.join(layout2.root, "Package.swift");
17098
17393
  let manifest = files.get(manifestPath).toString();
17394
+ const manifestTargets = swiftManifestTargets(manifest, [], (file) => {
17395
+ const contents2 = files.get(file);
17396
+ if (contents2 === void 0) throw new Error(`missing compiler arguments ${file}`);
17397
+ return contents2.toString();
17398
+ });
17099
17399
  const dependencies = new Map(
17100
- swiftManifestTargets(manifest, [], (file) => {
17101
- const contents2 = files.get(file);
17102
- if (contents2 === void 0) throw new Error(`missing compiler arguments ${file}`);
17103
- return contents2.toString();
17104
- }).map((target) => [
17400
+ manifestTargets.map((target) => [
17105
17401
  target.name,
17106
17402
  (target.dependencies ?? []).flatMap(
17107
17403
  (dependency) => dependency.kind === "target" ? [dependency.name] : []
@@ -17109,6 +17405,62 @@ module ${moduleName}.Swift {
17109
17405
  ])
17110
17406
  );
17111
17407
  const producerSet = /* @__PURE__ */ new Set([...Object.keys(nativeHeaderDeclarations), ...producers]);
17408
+ let headerCompiler = allowHeaderCompiler && packages.size === 0 && producerSet.size > 0;
17409
+ if (headerCompiler) {
17410
+ const clang = new Set(
17411
+ manifestTargets.filter(
17412
+ (target) => target.systemLibrary || !swiftTargets.has(target.name) && native.has(target.name)
17413
+ ).map(({ name: name2 }) => name2)
17414
+ );
17415
+ const headers = swiftHeaderDependencies(
17416
+ layout2.root,
17417
+ files,
17418
+ manifestTargets,
17419
+ nativeTargets,
17420
+ producerSet,
17421
+ input.headerAliases ?? {}
17422
+ );
17423
+ const nativeEdges = /* @__PURE__ */ new Map();
17424
+ const dependsOn = (from, to, seen = /* @__PURE__ */ new Set()) => {
17425
+ if (from === to) return true;
17426
+ if (seen.has(from)) return false;
17427
+ seen.add(from);
17428
+ return [...dependencies.get(from) ?? [], ...nativeEdges.get(from) ?? []].some(
17429
+ (dependency) => dependsOn(dependency, to, seen)
17430
+ );
17431
+ };
17432
+ for (const target of manifestTargets) {
17433
+ if (target.systemLibrary) continue;
17434
+ const required = new Set(headers.get(target.name));
17435
+ const visited = /* @__PURE__ */ new Set();
17436
+ const imports = (name2) => {
17437
+ if (!clang.has(name2) || visited.has(name2)) return;
17438
+ visited.add(name2);
17439
+ for (const header of headers.get(name2) ?? []) required.add(header);
17440
+ for (const dependency of dependencies.get(name2) ?? []) imports(dependency);
17441
+ };
17442
+ for (const dependency of dependencies.get(target.name) ?? []) imports(dependency);
17443
+ for (const producer of required) {
17444
+ if (dependsOn(target.name, producer)) continue;
17445
+ if (dependsOn(producer, target.name)) {
17446
+ headerCompiler = false;
17447
+ break;
17448
+ }
17449
+ const edges = nativeEdges.get(target.name) ?? [];
17450
+ edges.push(producer);
17451
+ nativeEdges.set(target.name, edges);
17452
+ }
17453
+ if (!headerCompiler) break;
17454
+ }
17455
+ if (headerCompiler)
17456
+ for (const [target, producers2] of nativeEdges) {
17457
+ const additions = producers2.map((producer) => `.target(name: ${JSON.stringify(producer)})`).join(", ");
17458
+ manifest += `
17459
+ package.targets.first(where: { $0.name == ${JSON.stringify(target)} })!.dependencies += [${additions}]
17460
+ `;
17461
+ dependencies.get(target).push(...producers2);
17462
+ }
17463
+ }
17112
17464
  const depths = /* @__PURE__ */ new Map();
17113
17465
  const orderedProducers = [];
17114
17466
  const depth = (name2) => {
@@ -17137,13 +17489,18 @@ module ${moduleName}.Swift {
17137
17489
  if (members.length === 1) return members[0];
17138
17490
  if (dependencies.has(name2))
17139
17491
  throw new Error(`generated build target collides with ${name2}`);
17140
- files.set(path28.join(layout2.root, name2, "Products.swift"), "");
17492
+ files.set(path30.join(layout2.root, name2, "Products.swift"), "");
17141
17493
  manifest += `
17142
17494
  package.targets += [.target(name: ${JSON.stringify(name2)}, dependencies: ${JSON.stringify(members)}, path: ${JSON.stringify(name2)}, swiftSettings: [.swiftLanguageMode(.v5)])]
17143
17495
  `;
17144
17496
  return name2;
17145
17497
  };
17146
- const headerBuilds = [...stages].sort(([left], [right]) => left - right).map(([level, producers2]) => ({
17498
+ const headerBuilds = headerCompiler ? [
17499
+ {
17500
+ target: buildProduct(SWIFT_HEADER_PRODUCTS_TARGET, orderedProducers),
17501
+ producers: orderedProducers
17502
+ }
17503
+ ] : [...stages].sort(([left], [right]) => left - right).map(([level, producers2]) => ({
17147
17504
  target: buildProduct(`${SWIFT_HEADER_PRODUCTS_TARGET}${level}`, producers2),
17148
17505
  producers: producers2
17149
17506
  }));
@@ -17161,16 +17518,17 @@ package.targets += [.target(name: ${JSON.stringify(name2)}, dependencies: ${JSON
17161
17518
  syncSwiftTree(layout2.root, files);
17162
17519
  if (layout2.multi)
17163
17520
  for (const target of targets)
17164
- mkdirSync7(path28.join(layout2.root, target.path), { recursive: true });
17165
- const clangWrapper = path28.join(layout2.root, CLANG_TARGET_MODULE_WRAPPER);
17166
- if (files.has(clangWrapper)) chmodSync2(clangWrapper, 493);
17521
+ mkdirSync8(path30.join(layout2.root, target.path), { recursive: true });
17522
+ const clangWrapper = path30.join(layout2.root, CLANG_TARGET_MODULE_WRAPPER);
17523
+ if (files.has(clangWrapper)) chmodSync3(clangWrapper, 493);
17167
17524
  return {
17168
17525
  headerBuilds,
17169
17526
  nativeHeaderDeclarations,
17170
17527
  nativeProductTarget,
17171
17528
  targetFailures,
17172
17529
  generatedOwners,
17173
- targetToolset
17530
+ targetToolset,
17531
+ headerCompiler
17174
17532
  };
17175
17533
  }
17176
17534
  function streamText(value) {
@@ -17190,21 +17548,21 @@ function outputOf(error) {
17190
17548
  return error instanceof Error ? error.message : String(error);
17191
17549
  }
17192
17550
  function builtArtifact(layout2) {
17193
- const binDir = path28.join(layout2.root, ".build", WASM_TRIPLE, "release");
17194
- const manifest = readFileSync17(path28.join(layout2.root, "Package.swift"), "utf8");
17551
+ const binDir = path30.join(layout2.root, ".build", WASM_TRIPLE, "release");
17552
+ const manifest = readFileSync18(path30.join(layout2.root, "Package.swift"), "utf8");
17195
17553
  const executable = swiftManifestTargets(
17196
17554
  manifest,
17197
17555
  [],
17198
- (file) => readFileSync17(file, "utf8")
17556
+ (file) => readFileSync18(file, "utf8")
17199
17557
  ).find((target) => target.executable);
17200
17558
  if (executable === void 0) {
17201
17559
  throw new Error("swift-compile: the written manifest names no executable target");
17202
17560
  }
17203
- return path28.join(binDir, `${executable.name}.wasm`);
17561
+ return path30.join(binDir, `${executable.name}.wasm`);
17204
17562
  }
17205
17563
  function projectDiagnostic(output, layout2, files) {
17206
17564
  const base = layout2.multi ? layout2.root : layout2.sources;
17207
- const prefix = `${base}${path28.sep}`;
17565
+ const prefix = `${base}${path30.sep}`;
17208
17566
  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();
17209
17567
  }
17210
17568
  var ROOT_LOCKS = Symbol.for("peachsim.swiftCompile.rootLocks");
@@ -17240,13 +17598,13 @@ function serialize(root, work, signal) {
17240
17598
  function readCompiledArtifact(directory, hash) {
17241
17599
  try {
17242
17600
  const receipt = JSON.parse(
17243
- readFileSync17(path28.join(directory, "artifact.json"), "utf8")
17601
+ readFileSync18(path30.join(directory, "artifact.json"), "utf8")
17244
17602
  );
17245
17603
  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")
17246
17604
  return null;
17247
- const bytes = readFileSync17(path28.join(directory, "app.wasm"));
17248
- const gzip2 = readFileSync17(path28.join(directory, "icu.gz"));
17249
- if (createHash14("sha256").update(bytes).digest("hex") !== receipt.wasm || createHash14("sha256").update(gzip2).digest("hex") !== receipt.icu || bytes.length <= 8 || bytes.readUInt32LE(0) !== 1836278016 || bytes.readUInt32LE(4) !== 1)
17605
+ const bytes = readFileSync18(path30.join(directory, "app.wasm"));
17606
+ const gzip2 = readFileSync18(path30.join(directory, "icu.gz"));
17607
+ if (createHash15("sha256").update(bytes).digest("hex") !== receipt.wasm || createHash15("sha256").update(gzip2).digest("hex") !== receipt.icu || bytes.length <= 8 || bytes.readUInt32LE(0) !== 1836278016 || bytes.readUInt32LE(4) !== 1)
17250
17608
  return null;
17251
17609
  return { hash, bytes, icu: { sha256: receipt.icu, gzip: gzip2 } };
17252
17610
  } catch (error) {
@@ -17256,25 +17614,25 @@ function readCompiledArtifact(directory, hash) {
17256
17614
  }
17257
17615
  }
17258
17616
  function saveCompiledArtifact(root, artifact) {
17259
- const directory = path28.join(root, "artifact");
17260
- mkdirSync7(directory, { recursive: true });
17261
- const pending = mkdtempSync3(path28.join(root, ".artifact-"));
17617
+ const directory = path30.join(root, "artifact");
17618
+ mkdirSync8(directory, { recursive: true });
17619
+ const pending = mkdtempSync4(path30.join(root, ".artifact-"));
17262
17620
  try {
17263
- writeFileSync8(path28.join(pending, "app.wasm"), artifact.bytes);
17264
- writeFileSync8(path28.join(pending, "icu.gz"), artifact.icu.gzip);
17265
- writeFileSync8(
17266
- path28.join(pending, "artifact.json"),
17621
+ writeFileSync9(path30.join(pending, "app.wasm"), artifact.bytes);
17622
+ writeFileSync9(path30.join(pending, "icu.gz"), artifact.icu.gzip);
17623
+ writeFileSync9(
17624
+ path30.join(pending, "artifact.json"),
17267
17625
  JSON.stringify({
17268
17626
  hash: artifact.hash,
17269
- wasm: createHash14("sha256").update(artifact.bytes).digest("hex"),
17627
+ wasm: createHash15("sha256").update(artifact.bytes).digest("hex"),
17270
17628
  icu: artifact.icu.sha256
17271
17629
  })
17272
17630
  );
17273
17631
  for (const file of ["app.wasm", "icu.gz", "artifact.json"]) {
17274
- renameSync2(path28.join(pending, file), path28.join(directory, file));
17632
+ renameSync3(path30.join(pending, file), path30.join(directory, file));
17275
17633
  }
17276
17634
  } finally {
17277
- rmSync7(pending, { recursive: true, force: true });
17635
+ rmSync8(pending, { recursive: true, force: true });
17278
17636
  }
17279
17637
  }
17280
17638
  var SHARED_ARTIFACT_BUDGET_BYTES = 4 * 1024 ** 3;
@@ -17293,21 +17651,21 @@ function renewSharedArtifact(sharedRoot) {
17293
17651
  function pruneSharedArtifacts(parent, keep) {
17294
17652
  const entries = [];
17295
17653
  for (const name2 of readdirSync8(parent)) {
17296
- const directory = path28.join(parent, name2);
17654
+ const directory = path30.join(parent, name2);
17297
17655
  if (name2.startsWith(RETIRED_PREFIX)) {
17298
17656
  reapRetiredCacheDirectory(parent, name2);
17299
17657
  continue;
17300
17658
  }
17301
17659
  try {
17302
17660
  let bytes = 0;
17303
- for (const file of readdirSync8(path28.join(directory, "artifact"))) {
17661
+ for (const file of readdirSync8(path30.join(directory, "artifact"))) {
17304
17662
  try {
17305
- bytes += statSync2(path28.join(directory, "artifact", file)).size;
17663
+ bytes += statSync3(path30.join(directory, "artifact", file)).size;
17306
17664
  } catch (error) {
17307
17665
  if (!vanished(error)) throw error;
17308
17666
  }
17309
17667
  }
17310
- entries.push({ directory, used: statSync2(directory).mtimeMs, bytes });
17668
+ entries.push({ directory, used: statSync3(directory).mtimeMs, bytes });
17311
17669
  } catch (error) {
17312
17670
  if (!vanished(error)) throw error;
17313
17671
  }
@@ -17317,13 +17675,13 @@ function pruneSharedArtifacts(parent, keep) {
17317
17675
  if (total <= SHARED_ARTIFACT_BUDGET_BYTES) break;
17318
17676
  if (entry.directory === keep || Date.now() - entry.used < SHARED_ARTIFACT_GRACE_MS)
17319
17677
  continue;
17320
- const retired = path28.join(
17678
+ const retired = path30.join(
17321
17679
  parent,
17322
- `${RETIRED_PREFIX}${process.pid}-${path28.basename(entry.directory)}`
17680
+ `${RETIRED_PREFIX}${process.pid}-${path30.basename(entry.directory)}`
17323
17681
  );
17324
17682
  try {
17325
- if (statSync2(entry.directory).mtimeMs !== entry.used) continue;
17326
- renameSync2(entry.directory, retired);
17683
+ if (statSync3(entry.directory).mtimeMs !== entry.used) continue;
17684
+ renameSync3(entry.directory, retired);
17327
17685
  } catch (error) {
17328
17686
  if (vanished(error)) continue;
17329
17687
  throw error;
@@ -17335,7 +17693,7 @@ function pruneSharedArtifacts(parent, keep) {
17335
17693
  function saveSharedArtifact(sharedRoot, artifact) {
17336
17694
  saveCompiledArtifact(sharedRoot, artifact);
17337
17695
  renewSharedArtifact(sharedRoot);
17338
- pruneSharedArtifacts(path28.dirname(sharedRoot), sharedRoot);
17696
+ pruneSharedArtifacts(path30.dirname(sharedRoot), sharedRoot);
17339
17697
  }
17340
17698
  var retainedArtifacts = /* @__PURE__ */ new Map();
17341
17699
  function retain(root, artifact) {
@@ -17363,7 +17721,7 @@ function frameworkLibraryTargets(manifest) {
17363
17721
  }
17364
17722
  function linkedFrameworkTargets(moduleRoot, input) {
17365
17723
  const libraries = frameworkLibraryTargets(
17366
- readFileSync17(path28.join(moduleRoot, "Package.swift"), "utf8")
17724
+ readFileSync18(path30.join(moduleRoot, "Package.swift"), "utf8")
17367
17725
  );
17368
17726
  const targets = compileTargets(input);
17369
17727
  const planning = targets.length > 0 ? targets : [{ name: "App", path: "." }];
@@ -17386,7 +17744,7 @@ function linkedFrameworkTargets(moduleRoot, input) {
17386
17744
  for (const name2 of [...siblings.values()].flat())
17387
17745
  if (libraries.has(name2) && !planning.some((target) => target.name === name2))
17388
17746
  reach(name2);
17389
- const manifest = readFileSync17(path28.join(moduleRoot, "Package.swift"), "utf8");
17747
+ const manifest = readFileSync18(path30.join(moduleRoot, "Package.swift"), "utf8");
17390
17748
  const targetDependencies = /* @__PURE__ */ new Map();
17391
17749
  for (const match of manifest.matchAll(
17392
17750
  /\.target\(\s*name:\s*"([^"]+)"\s*,\s*dependencies:\s*\[([^\]]*)\]/g
@@ -17403,12 +17761,12 @@ function linkedFrameworkTargets(moduleRoot, input) {
17403
17761
  };
17404
17762
  for (const name2 of reached)
17405
17763
  for (const member of libraries.get(name2) ?? []) build(member);
17406
- const overlays = path28.join(moduleRoot, "cross-import-overlays");
17764
+ const overlays = path30.join(moduleRoot, "cross-import-overlays");
17407
17765
  for (const directory of readdirSync8(overlays)) {
17408
- const companion = path28.basename(directory, ".swiftcrossimport");
17766
+ const companion = path30.basename(directory, ".swiftcrossimport");
17409
17767
  if (!built.has(companion)) continue;
17410
- const declaration = path28.join(overlays, directory, "SwiftUI.swiftoverlay");
17411
- for (const match of readFileSync17(declaration, "utf8").matchAll(
17768
+ const declaration = path30.join(overlays, directory, "SwiftUI.swiftoverlay");
17769
+ for (const match of readFileSync18(declaration, "utf8").matchAll(
17412
17770
  /^\s*- name: ([A-Za-z_]\w*)\s*$/gm
17413
17771
  ))
17414
17772
  reach(match[1]);
@@ -17434,7 +17792,7 @@ function linkedFrameworkTargets(moduleRoot, input) {
17434
17792
  return { products: linked, targets: linkedMembers };
17435
17793
  }
17436
17794
  function writeFrameworkLinkPackage(linkRoot, moduleRoot, products) {
17437
- const identity = path28.basename(moduleRoot).toLowerCase();
17795
+ const identity = path30.basename(moduleRoot).toLowerCase();
17438
17796
  const swiftString = (value) => `"${value.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
17439
17797
  const dependencies = products.map(
17440
17798
  (name2) => ` .product(name: ${swiftString(name2)}, package: ${swiftString(identity)}),`
@@ -17456,13 +17814,13 @@ ${dependencies}
17456
17814
  ]
17457
17815
  )
17458
17816
  `;
17459
- const sourceDir = path28.join(linkRoot, "Sources", FRAMEWORK_LINK_TARGET);
17460
- mkdirSync7(sourceDir, { recursive: true });
17461
- const manifestPath = path28.join(linkRoot, "Package.swift");
17462
- if (!existsSync6(manifestPath) || readFileSync17(manifestPath, "utf8") !== manifest)
17463
- writeFileSync8(manifestPath, manifest);
17464
- const source = path28.join(sourceDir, "Link.swift");
17465
- if (!existsSync6(source)) writeFileSync8(source, "");
17817
+ const sourceDir = path30.join(linkRoot, "Sources", FRAMEWORK_LINK_TARGET);
17818
+ mkdirSync8(sourceDir, { recursive: true });
17819
+ const manifestPath = path30.join(linkRoot, "Package.swift");
17820
+ if (!existsSync7(manifestPath) || readFileSync18(manifestPath, "utf8") !== manifest)
17821
+ writeFileSync9(manifestPath, manifest);
17822
+ const source = path30.join(sourceDir, "Link.swift");
17823
+ if (!existsSync7(source)) writeFileSync9(source, "");
17466
17824
  }
17467
17825
  function frameworkLinkClosure(scratch2, roots) {
17468
17826
  const suffix = `${WASM_TRIPLE}-release`;
@@ -17473,7 +17831,7 @@ function frameworkLinkClosure(scratch2, roots) {
17473
17831
  const moduleMaps = /* @__PURE__ */ new Map();
17474
17832
  let pending = null;
17475
17833
  let compiling = null;
17476
- for (const line of readFileSync17(path28.join(scratch2, "release.yaml"), "utf8").split(
17834
+ for (const line of readFileSync18(path30.join(scratch2, "release.yaml"), "utf8").split(
17477
17835
  "\n"
17478
17836
  )) {
17479
17837
  const phony = phonyHeader.exec(line);
@@ -17537,7 +17895,7 @@ function frameworkLinkClosure(scratch2, roots) {
17537
17895
  owners.set(file, name2);
17538
17896
  if (seen.has(file)) continue;
17539
17897
  seen.add(file);
17540
- if (!existsSync6(file))
17898
+ if (!existsSync7(file))
17541
17899
  throw new Error(`swift-compile: framework object ${file} was not built`);
17542
17900
  files.push(file);
17543
17901
  }
@@ -17547,19 +17905,19 @@ function frameworkLinkClosure(scratch2, roots) {
17547
17905
  return { objects: files, owners, modules, moduleMaps: [...maps].sort() };
17548
17906
  }
17549
17907
  function removeCaseCollidingModuleArtifacts(modulesDir, keep) {
17550
- if (!existsSync6(modulesDir)) return;
17908
+ if (!existsSync7(modulesDir)) return;
17551
17909
  const folded = new Set([...keep].map((name2) => name2.toLowerCase()));
17552
17910
  for (const name2 of readdirSync8(modulesDir)) {
17553
17911
  const dot = name2.indexOf(".");
17554
17912
  if (dot <= 0) continue;
17555
17913
  const module = name2.slice(0, dot);
17556
17914
  if (keep.has(module) || !folded.has(module.toLowerCase())) continue;
17557
- rmSync7(path28.join(modulesDir, name2), { recursive: true, force: true });
17915
+ rmSync8(path30.join(modulesDir, name2), { recursive: true, force: true });
17558
17916
  }
17559
17917
  }
17560
17918
  async function buildFrameworkProducts(scratch2, args) {
17561
17919
  const linkedTargets = linkedFrameworkTargets(args.moduleRoot, args.input);
17562
- const linkRoot = path28.join(scratch2, "link");
17920
+ const linkRoot = path30.join(scratch2, "link");
17563
17921
  writeFrameworkLinkPackage(linkRoot, args.moduleRoot, linkedTargets.products);
17564
17922
  await runCompiler(
17565
17923
  args.swift,
@@ -17592,7 +17950,7 @@ async function buildFrameworkProducts(scratch2, args) {
17592
17950
  "-Xswiftc",
17593
17951
  String(swiftBuildJobs()),
17594
17952
  ...swiftReproducibleBuildFlags([
17595
- [path28.dirname(args.toolchainBin), "toolchain"],
17953
+ [path30.dirname(args.toolchainBin), "toolchain"],
17596
17954
  [args.moduleRoot, "framework"],
17597
17955
  [scratch2, "framework-scratch"]
17598
17956
  ]),
@@ -17617,16 +17975,16 @@ async function buildFrameworkProducts(scratch2, args) {
17617
17975
  ).catch((error) => {
17618
17976
  throw new Error(outputOf(error), { cause: error });
17619
17977
  });
17620
- const release = path28.join(scratch2, WASM_TRIPLE, "release");
17978
+ const release = path30.join(scratch2, WASM_TRIPLE, "release");
17621
17979
  const linked = frameworkLinkClosure(scratch2, linkedTargets.targets);
17622
17980
  const objects = linked.objects;
17623
17981
  if (linked.modules.has("UniformTypeIdentifiers")) {
17624
- const constantsDir = path28.join(scratch2, "uniform-type-constants");
17625
- const constantsStamp = path28.join(constantsDir, ".complete");
17626
- const object3 = path28.join(constantsDir, "UniformTypeIdentifiers-NativeConstants.o");
17627
- if (!existsSync6(constantsStamp) || readFileSync17(constantsStamp, "utf8") !== args.frameworkKey) {
17628
- rmSync7(constantsDir, { recursive: true, force: true });
17629
- mkdirSync7(constantsDir);
17982
+ const constantsDir = path30.join(scratch2, "uniform-type-constants");
17983
+ const constantsStamp = path30.join(constantsDir, ".complete");
17984
+ const object3 = path30.join(constantsDir, "UniformTypeIdentifiers-NativeConstants.o");
17985
+ if (!existsSync7(constantsStamp) || readFileSync18(constantsStamp, "utf8") !== args.frameworkKey) {
17986
+ rmSync8(constantsDir, { recursive: true, force: true });
17987
+ mkdirSync8(constantsDir);
17630
17988
  const sdkPaths2 = swiftSdkPaths(args.moduleRoot, args.toolchainBin);
17631
17989
  compileUniformTypeConstants({
17632
17990
  bin: args.toolchainBin,
@@ -17636,35 +17994,35 @@ async function buildFrameworkProducts(scratch2, args) {
17636
17994
  minimum: darwinRecordsMinimum(),
17637
17995
  out: constantsDir
17638
17996
  });
17639
- writeFileSync8(constantsStamp, args.frameworkKey);
17997
+ writeFileSync9(constantsStamp, args.frameworkKey);
17640
17998
  }
17641
17999
  objects.push(object3);
17642
18000
  linked.owners.set(object3, "UniformTypeIdentifiers");
17643
18001
  }
17644
- removeCaseCollidingModuleArtifacts(path28.join(release, "Modules"), linked.modules);
17645
- const response = path28.join(scratch2, "autolink-objects.rsp");
17646
- writeFileSync8(response, objects.map((file) => JSON.stringify(file)).join("\n") + "\n");
18002
+ removeCaseCollidingModuleArtifacts(path30.join(release, "Modules"), linked.modules);
18003
+ const response = path30.join(scratch2, "autolink-objects.rsp");
18004
+ writeFileSync9(response, objects.map((file) => JSON.stringify(file)).join("\n") + "\n");
17647
18005
  const extracted = await runCompiler(
17648
- path28.join(args.toolchainBin, "swift-autolink-extract"),
18006
+ path30.join(args.toolchainBin, "swift-autolink-extract"),
17649
18007
  [`@${response}`, "-o", "-"],
17650
18008
  args.buildOptions
17651
18009
  );
17652
- rmSync7(response, { force: true });
18010
+ rmSync8(response, { force: true });
17653
18011
  const link = extracted.split("\n").map((line) => line.trim()).filter((flag, index, all) => flag.length > 0 && all.indexOf(flag) === index);
17654
18012
  if (link.includes("-lFoundation"))
17655
18013
  for (const name2 of foundationCategoryObjects) {
17656
- const object3 = path28.join(
18014
+ const object3 = path30.join(
17657
18015
  swiftSdkPaths(args.moduleRoot, args.toolchainBin).resources,
17658
18016
  `wasi/${name2}.objc.o`
17659
18017
  );
17660
18018
  objects.push(object3);
17661
18019
  linked.owners.set(object3, "Foundation");
17662
18020
  }
17663
- const providerDir = path28.join(scratch2, "darwin-records");
17664
- const providerStamp = path28.join(providerDir, ".complete");
17665
- if (!existsSync6(providerStamp) || readFileSync17(providerStamp, "utf8") !== args.frameworkKey) {
17666
- rmSync7(providerDir, { recursive: true, force: true });
17667
- mkdirSync7(providerDir);
18021
+ const providerDir = path30.join(scratch2, "darwin-records");
18022
+ const providerStamp = path30.join(providerDir, ".complete");
18023
+ if (!existsSync7(providerStamp) || readFileSync18(providerStamp, "utf8") !== args.frameworkKey) {
18024
+ rmSync8(providerDir, { recursive: true, force: true });
18025
+ mkdirSync8(providerDir);
17668
18026
  const sdkPaths2 = swiftSdkPaths(args.moduleRoot, args.toolchainBin);
17669
18027
  compileDarwinRecords({
17670
18028
  bin: args.toolchainBin,
@@ -17674,20 +18032,20 @@ async function buildFrameworkProducts(scratch2, args) {
17674
18032
  minimum: darwinRecordsMinimum(),
17675
18033
  out: providerDir
17676
18034
  });
17677
- writeFileSync8(providerStamp, args.frameworkKey);
18035
+ writeFileSync9(providerStamp, args.frameworkKey);
17678
18036
  }
17679
- const providers = readdirSync8(providerDir).filter((file) => file.endsWith(".o")).sort().map((file) => path28.join(providerDir, file));
18037
+ const providers = readdirSync8(providerDir).filter((file) => file.endsWith(".o")).sort().map((file) => path30.join(providerDir, file));
17680
18038
  for (const provider of providers) linked.owners.set(provider, "DarwinRecords");
17681
- const archive = path28.join(scratch2, "lib");
17682
- rmSync7(archive, { recursive: true, force: true });
17683
- mkdirSync7(archive);
18039
+ const archive = path30.join(scratch2, "lib");
18040
+ rmSync8(archive, { recursive: true, force: true });
18041
+ mkdirSync8(archive);
17684
18042
  const archived = /* @__PURE__ */ new Map();
17685
18043
  for (const object3 of objects) {
17686
18044
  const target = linked.owners.get(object3);
17687
- const dir = path28.join(release, `${target}.build`);
17688
- if (!target || target === "Darwin" || !object3.startsWith(dir + path28.sep)) continue;
17689
- const name2 = `${target}-${path28.relative(dir, object3).replaceAll(path28.sep, "-").replace(/\.swift\.o$/, ".o")}`;
17690
- symlinkSync2(object3, path28.join(archive, name2));
18045
+ const dir = path30.join(release, `${target}.build`);
18046
+ if (!target || target === "Darwin" || !object3.startsWith(dir + path30.sep)) continue;
18047
+ const name2 = `${target}-${path30.relative(dir, object3).replaceAll(path30.sep, "-").replace(/\.swift\.o$/, ".o")}`;
18048
+ symlinkSync2(object3, path30.join(archive, name2));
17691
18049
  archived.set(object3, `lib/${name2}`);
17692
18050
  }
17693
18051
  const roots = swiftObjcRootObjects(`${scratch2}
@@ -17696,11 +18054,11 @@ ${args.frameworkKey}`, scratch2, [
17696
18054
  ]);
17697
18055
  const linkedObjects = objects.map((object3) => {
17698
18056
  const name2 = archived.get(object3);
17699
- return name2 ? { path: path28.join(scratch2, name2), lazy: !roots.has(name2) } : { path: object3, lazy: false };
18057
+ return name2 ? { path: path30.join(scratch2, name2), lazy: !roots.has(name2) } : { path: object3, lazy: false };
17700
18058
  });
17701
18059
  return {
17702
18060
  root: scratch2,
17703
- modules: path28.join(release, "Modules"),
18061
+ modules: path30.join(release, "Modules"),
17704
18062
  objects: linkedObjects.filter((object3) => !object3.lazy).map((object3) => object3.path),
17705
18063
  lazyObjects: linkedObjects.filter((object3) => object3.lazy).map((object3) => object3.path),
17706
18064
  owners: linked.owners,
@@ -17714,14 +18072,14 @@ var SWIFT_FRAMEWORK_SLOTS = 8;
17714
18072
  var SWIFT_FRAMEWORK_SLOT_KEY = ".peach-framework-key";
17715
18073
  var SWIFT_FRAMEWORK_SLOT_ORIGIN = ".peach-framework-origin";
17716
18074
  function swiftFrameworksDir() {
17717
- return path28.join(swiftCacheDir(), "swift-frameworks");
18075
+ return path30.join(swiftCacheDir(), "swift-frameworks");
17718
18076
  }
17719
18077
  function swiftFrameworkScratch(frameworkKey) {
17720
- return path28.join(swiftFrameworksDir(), frameworkKey);
18078
+ return path30.join(swiftFrameworksDir(), frameworkKey);
17721
18079
  }
17722
18080
  function swiftFrameworkSlotRecord(slot, record) {
17723
18081
  try {
17724
- return readFileSync17(path28.join(slot, record), "utf8").trim();
18082
+ return readFileSync18(path30.join(slot, record), "utf8").trim();
17725
18083
  } catch (error) {
17726
18084
  if (!vanished(error)) throw error;
17727
18085
  return null;
@@ -17732,8 +18090,8 @@ function swiftFrameworkSlotKey(slot) {
17732
18090
  }
17733
18091
  async function withSwiftFrameworkSlot(frameworkKey, moduleRoot, signal, work) {
17734
18092
  const slots = Array.from({ length: SWIFT_FRAMEWORK_SLOTS }, (_, index) => {
17735
- const slot = path28.join(swiftFrameworksDir(), `slot-${index}`);
17736
- mkdirSync7(slot, { recursive: true });
18093
+ const slot = path30.join(swiftFrameworksDir(), `slot-${index}`);
18094
+ mkdirSync8(slot, { recursive: true });
17737
18095
  return slot;
17738
18096
  });
17739
18097
  const run2 = (slot) => (lease) => {
@@ -17743,21 +18101,21 @@ async function withSwiftFrameworkSlot(frameworkKey, moduleRoot, signal, work) {
17743
18101
  };
17744
18102
  const staged = slots.find((slot) => swiftFrameworkSlotKey(slot) === frameworkKey);
17745
18103
  if (staged) return withSwiftRootLock(staged, run2(staged), signal);
17746
- const built = new Map(slots.map((slot) => [slot, statSync2(slot).mtimeMs]));
18104
+ const built = new Map(slots.map((slot) => [slot, statSync3(slot).mtimeMs]));
17747
18105
  const own = (slot) => swiftFrameworkSlotRecord(slot, SWIFT_FRAMEWORK_SLOT_ORIGIN) === moduleRoot;
17748
18106
  const inputs = new Map(
17749
18107
  swiftModuleInputFiles(moduleRoot).map((file) => [
17750
18108
  file,
17751
- readFileSync17(path28.join(moduleRoot, file))
18109
+ readFileSync18(path30.join(moduleRoot, file))
17752
18110
  ])
17753
18111
  );
17754
18112
  const ranked = slots.map((slot) => {
17755
18113
  let changes = 0;
17756
18114
  if (swiftFrameworkSlotKey(slot) === null) return { slot, changes: Infinity };
17757
- const source = path28.join(slot, "source", "packages", path28.basename(moduleRoot));
18115
+ const source = path30.join(slot, "source", "packages", path30.basename(moduleRoot));
17758
18116
  for (const [file, contents2] of inputs) {
17759
18117
  try {
17760
- if (!readFileSync17(path28.join(source, file)).equals(contents2)) changes++;
18118
+ if (!readFileSync18(path30.join(source, file)).equals(contents2)) changes++;
17761
18119
  } catch (error) {
17762
18120
  if (!vanished(error)) throw error;
17763
18121
  changes++;
@@ -17772,7 +18130,7 @@ async function withSwiftFrameworkSlot(frameworkKey, moduleRoot, signal, work) {
17772
18130
  slot,
17773
18131
  async (lease) => {
17774
18132
  console.error(
17775
- `[swift-framework-cache] ${path28.basename(slot)} changedInputs=${changes} totalInputs=${inputs.size}`
18133
+ `[swift-framework-cache] ${path30.basename(slot)} changedInputs=${changes} totalInputs=${inputs.size}`
17776
18134
  );
17777
18135
  return { value: await run2(slot)(lease) };
17778
18136
  },
@@ -17785,14 +18143,14 @@ async function withSwiftFrameworkSlot(frameworkKey, moduleRoot, signal, work) {
17785
18143
  return withSwiftRootLock(nearest, run2(nearest), signal);
17786
18144
  }
17787
18145
  function mirrorTree2(source, target, skip) {
17788
- mkdirSync7(target, { recursive: true });
18146
+ mkdirSync8(target, { recursive: true });
17789
18147
  const wanted = /* @__PURE__ */ new Set();
17790
18148
  let restructured = false;
17791
18149
  for (const entry of readdirSync8(source, { withFileTypes: true })) {
17792
18150
  if (entry.name === skip) continue;
17793
18151
  wanted.add(entry.name);
17794
- const from = path28.join(source, entry.name);
17795
- const to = path28.join(target, entry.name);
18152
+ const from = path30.join(source, entry.name);
18153
+ const to = path30.join(target, entry.name);
17796
18154
  let existing = null;
17797
18155
  try {
17798
18156
  existing = lstatSync(to);
@@ -17801,75 +18159,75 @@ function mirrorTree2(source, target, skip) {
17801
18159
  }
17802
18160
  if (!existing) restructured = true;
17803
18161
  if (entry.isDirectory()) {
17804
- if (existing && !existing.isDirectory()) rmSync7(to, { force: true });
18162
+ if (existing && !existing.isDirectory()) rmSync8(to, { force: true });
17805
18163
  if (mirrorTree2(from, to)) restructured = true;
17806
18164
  } else if (entry.isSymbolicLink()) {
17807
18165
  const link = readlinkSync(from);
17808
18166
  if (existing?.isSymbolicLink() && readlinkSync(to) === link) continue;
17809
- if (existing) rmSync7(to, { recursive: true, force: true });
18167
+ if (existing) rmSync8(to, { recursive: true, force: true });
17810
18168
  symlinkSync2(link, to);
17811
18169
  } else {
17812
- const stat = statSync2(from);
17813
- if (existing?.isFile() && existing.size === stat.size && (existing.mtimeMs === stat.mtimeMs || readFileSync17(from).equals(readFileSync17(to))))
18170
+ const stat = statSync3(from);
18171
+ if (existing?.isFile() && existing.size === stat.size && (existing.mtimeMs === stat.mtimeMs || readFileSync18(from).equals(readFileSync18(to))))
17814
18172
  continue;
17815
- if (existing) rmSync7(to, { recursive: true, force: true });
18173
+ if (existing) rmSync8(to, { recursive: true, force: true });
17816
18174
  const partial = `${to}.${randomUUID5()}`;
17817
18175
  copyFileSync(from, partial);
17818
18176
  utimesSync(partial, stat.atime, stat.mtime);
17819
- renameSync2(partial, to);
18177
+ renameSync3(partial, to);
17820
18178
  }
17821
18179
  }
17822
18180
  for (const name2 of readdirSync8(target))
17823
18181
  if (!wanted.has(name2) && name2 !== skip) {
17824
- rmSync7(path28.join(target, name2), { recursive: true, force: true });
18182
+ rmSync8(path30.join(target, name2), { recursive: true, force: true });
17825
18183
  restructured = true;
17826
18184
  }
17827
18185
  return restructured;
17828
18186
  }
17829
18187
  function stageFrameworkSource(moduleRoot, slot, frameworkKey, release) {
17830
18188
  if (!slot) return moduleRoot;
17831
- const staged = path28.join(slot, "source");
17832
- const stagedModule = path28.join(staged, "packages", path28.basename(moduleRoot));
18189
+ const staged = path30.join(slot, "source");
18190
+ const stagedModule = path30.join(staged, "packages", path30.basename(moduleRoot));
17833
18191
  if (swiftFrameworkSlotKey(slot) !== frameworkKey) {
17834
- rmSync7(path28.join(slot, SWIFT_FRAMEWORK_SLOT_KEY), { force: true });
18192
+ rmSync8(path30.join(slot, SWIFT_FRAMEWORK_SLOT_KEY), { force: true });
17835
18193
  const moduleRestructured = mirrorTree2(moduleRoot, stagedModule, ".build");
17836
18194
  const sdkRestructured = mirrorTree2(
17837
18195
  swiftSharedSdkRoot(moduleRoot, false),
17838
- path28.join(staged, "packages/peachsim/sdk/ios")
18196
+ path30.join(staged, "packages/peachsim/sdk/ios")
17839
18197
  );
17840
18198
  if (moduleRestructured || sdkRestructured) {
17841
- rmSync7(path28.join(slot, "release.yaml"), { force: true });
17842
- rmSync7(path28.join(slot, "release", "description.json"), { force: true });
18199
+ rmSync8(path30.join(slot, "release.yaml"), { force: true });
18200
+ rmSync8(path30.join(slot, "release", "description.json"), { force: true });
17843
18201
  }
17844
18202
  for (const file of swiftModuleInputFiles(moduleRoot)) {
17845
18203
  if (!file.startsWith("../")) continue;
17846
- const from = path28.resolve(moduleRoot, file);
17847
- const to = path28.resolve(stagedModule, file);
17848
- if (existsSync6(to) && readFileSync17(from).equals(readFileSync17(to))) continue;
17849
- mkdirSync7(path28.dirname(to), { recursive: true });
18204
+ const from = path30.resolve(moduleRoot, file);
18205
+ const to = path30.resolve(stagedModule, file);
18206
+ if (existsSync7(to) && readFileSync18(from).equals(readFileSync18(to))) continue;
18207
+ mkdirSync8(path30.dirname(to), { recursive: true });
17850
18208
  copyFileSync(from, to);
17851
18209
  }
17852
18210
  if (swiftProjectBuildKey(stagedModule, release) !== frameworkKey)
17853
18211
  throw new Error("Swift staged framework source differs from the caller");
17854
- const modules = path28.join(staged, "node_modules");
17855
- const target = realpathSync6(path28.join(moduleRoot, "../../node_modules"));
17856
- if (!existsSync6(modules) || readlinkSync(modules) !== target) {
17857
- rmSync7(modules, { recursive: true, force: true });
18212
+ const modules = path30.join(staged, "node_modules");
18213
+ const target = realpathSync6(path30.join(moduleRoot, "../../node_modules"));
18214
+ if (!existsSync7(modules) || readlinkSync(modules) !== target) {
18215
+ rmSync8(modules, { recursive: true, force: true });
17858
18216
  symlinkSync2(target, modules);
17859
18217
  }
17860
- writeFileSync8(path28.join(slot, SWIFT_FRAMEWORK_SLOT_KEY), frameworkKey);
17861
- writeFileSync8(path28.join(slot, SWIFT_FRAMEWORK_SLOT_ORIGIN), moduleRoot);
18218
+ writeFileSync9(path30.join(slot, SWIFT_FRAMEWORK_SLOT_KEY), frameworkKey);
18219
+ writeFileSync9(path30.join(slot, SWIFT_FRAMEWORK_SLOT_ORIGIN), moduleRoot);
17862
18220
  }
17863
18221
  return stagedModule;
17864
18222
  }
17865
18223
  function swiftLinkStamp(args) {
17866
- const hash = createHash14("sha256");
18224
+ const hash = createHash15("sha256");
17867
18225
  hash.update(`swift-link/v1
17868
18226
  ${args.frameworkKey}
17869
18227
  `);
17870
18228
  if (!args.prebuilt) return hash.digest("hex");
17871
18229
  const statOf = (file) => {
17872
- const stat = statSync2(file, { bigint: true });
18230
+ const stat = statSync3(file, { bigint: true });
17873
18231
  return `${stat.size}:${stat.mtimeNs}`;
17874
18232
  };
17875
18233
  for (const object3 of args.prebuilt.objects)
@@ -17896,23 +18254,23 @@ ${args.prebuilt.modules}
17896
18254
  `);
17897
18255
  for (const entry of readdirSync8(args.prebuilt.modules).sort())
17898
18256
  hash.update(`${entry}
17899
- ${statOf(path28.join(args.prebuilt.modules, entry))}`);
18257
+ ${statOf(path30.join(args.prebuilt.modules, entry))}`);
17900
18258
  return hash.digest("hex");
17901
18259
  }
17902
18260
  function retireStaleSwiftLink(root, stamp) {
17903
- const receipt = path28.join(root, SWIFT_LINK_STAMP);
18261
+ const receipt = path30.join(root, SWIFT_LINK_STAMP);
17904
18262
  let previous = null;
17905
18263
  try {
17906
- previous = readFileSync17(receipt, "utf8").trim();
18264
+ previous = readFileSync18(receipt, "utf8").trim();
17907
18265
  } catch (error) {
17908
18266
  if (!vanished(error)) throw error;
17909
18267
  }
17910
- mkdirSync7(root, { recursive: true });
17911
- writeFileSync8(receipt, `${stamp}
18268
+ mkdirSync8(root, { recursive: true });
18269
+ writeFileSync9(receipt, `${stamp}
17912
18270
  `);
17913
- const retired = path28.join(root, ".build");
17914
- if (previous === stamp || !existsSync6(retired)) return false;
17915
- rmSync7(retired, { recursive: true, force: true });
18271
+ const retired = path30.join(root, ".build");
18272
+ if (previous === stamp || !existsSync7(retired)) return false;
18273
+ rmSync8(retired, { recursive: true, force: true });
17916
18274
  return true;
17917
18275
  }
17918
18276
  async function compileSwiftProjectUnit(input, options) {
@@ -17927,21 +18285,21 @@ async function compileSwiftProjectUnit(input, options) {
17927
18285
  }
17928
18286
  function compileSwiftProjectOnce(input, options) {
17929
18287
  options.signal?.throwIfAborted();
17930
- mkdirSync7(options.buildRoot, { recursive: true });
18288
+ mkdirSync8(options.buildRoot, { recursive: true });
17931
18289
  const root = realpathSync6(options.buildRoot);
17932
- const moduleRoot = path28.resolve(options.moduleRoot);
18290
+ const moduleRoot = path30.resolve(options.moduleRoot);
17933
18291
  const distribution = swiftDistributionAt(moduleRoot);
17934
18292
  const guestGraph = distribution ? input.sourceLinkGraph : void 0;
17935
18293
  if (options.linkOnly && guestGraph)
17936
18294
  throw new Error("swift-compile: link-only builds do not support guest image graphs");
17937
18295
  const layout2 = {
17938
18296
  root,
17939
- sources: path28.join(root, "Sources", "App"),
18297
+ sources: path30.join(root, "Sources", "App"),
17940
18298
  multi: compileTargets(input).length > 0
17941
18299
  };
17942
18300
  const hash = swiftArtifactHash(input, options.release, moduleRoot);
17943
18301
  const frameworkKey = swiftProjectBuildKey(moduleRoot, options.release);
17944
- const sharedRoot = path28.join(swiftCacheDir(), "swift-projects", hash);
18302
+ const sharedRoot = path30.join(swiftCacheDir(), "swift-projects", hash);
17945
18303
  const report = (message) => {
17946
18304
  console.error(`[swift-project ${hash.slice(0, 16)}] ${message}`);
17947
18305
  options.onStage?.(message);
@@ -17956,8 +18314,8 @@ function compileSwiftProjectOnce(input, options) {
17956
18314
  report("reusing memory artifact");
17957
18315
  return retain(root, retained);
17958
18316
  }
17959
- const cached = readCompiledArtifact(path28.join(sharedRoot, "artifact"), hash);
17960
- const previous = cached ?? (options.project ? null : readCompiledArtifact(path28.join(root, "artifact"), hash));
18317
+ const cached = readCompiledArtifact(path30.join(sharedRoot, "artifact"), hash);
18318
+ const previous = cached ?? (options.project ? null : readCompiledArtifact(path30.join(root, "artifact"), hash));
17961
18319
  if (previous) {
17962
18320
  if (cached) renewSharedArtifact(sharedRoot);
17963
18321
  else saveSharedArtifact(sharedRoot, previous);
@@ -17966,10 +18324,10 @@ function compileSwiftProjectOnce(input, options) {
17966
18324
  }
17967
18325
  }
17968
18326
  if (!options.intermediates && process.platform === "darwin" && process.env.TM_SESSION && !windowAdmission() && process.env.CI !== "true" && moduleRoot === sourceSwiftCheckout() && !swiftDistributionAt(moduleRoot)) {
17969
- const requestRoot = mkdtempSync3(`${root}.builder-request-`);
17970
- const output = path28.join(requestRoot, "output");
17971
- const request = path28.join(requestRoot, "request.json");
17972
- writeFileSync8(
18327
+ const requestRoot = mkdtempSync4(`${root}.builder-request-`);
18328
+ const output = path30.join(requestRoot, "output");
18329
+ const request = path30.join(requestRoot, "request.json");
18330
+ writeFileSync9(
17973
18331
  request,
17974
18332
  JSON.stringify({
17975
18333
  input,
@@ -17982,12 +18340,12 @@ function compileSwiftProjectOnce(input, options) {
17982
18340
  })
17983
18341
  );
17984
18342
  try {
17985
- const repo = path28.resolve(moduleRoot, "../..");
18343
+ const repo = path30.resolve(moduleRoot, "../..");
17986
18344
  report("requesting builder admission or cached result");
17987
18345
  await runCompiler(
17988
18346
  "bun",
17989
18347
  [
17990
- path28.join(repo, "scripts/build/swift-project.ts"),
18348
+ path30.join(repo, "scripts/build/swift-project.ts"),
17991
18349
  "--request",
17992
18350
  request,
17993
18351
  "--output",
@@ -18015,7 +18373,7 @@ function compileSwiftProjectOnce(input, options) {
18015
18373
  report("builder artifact verified");
18016
18374
  return retain(root, artifact);
18017
18375
  } finally {
18018
- rmSync7(requestRoot, { recursive: true, force: true });
18376
+ rmSync8(requestRoot, { recursive: true, force: true });
18019
18377
  }
18020
18378
  }
18021
18379
  return withSwiftCompileBudget(options.timeoutMs, options.signal, async (budget) => {
@@ -18023,14 +18381,14 @@ function compileSwiftProjectOnce(input, options) {
18023
18381
  root,
18024
18382
  async (lease) => {
18025
18383
  if (!options.intermediates) {
18026
- const built = readCompiledArtifact(path28.join(sharedRoot, "artifact"), hash);
18384
+ const built = readCompiledArtifact(path30.join(sharedRoot, "artifact"), hash);
18027
18385
  if (built) {
18028
18386
  report("reusing verified disk artifact");
18029
18387
  return retain(root, built);
18030
18388
  }
18031
18389
  }
18032
- const swift = path28.join(options.toolchainBin, "swift");
18033
- if (!existsSync6(swift)) {
18390
+ const swift = path30.join(options.toolchainBin, "swift");
18391
+ if (!existsSync7(swift)) {
18034
18392
  throw new Error(
18035
18393
  `swift-compile: no swift.org toolchain at ${options.toolchainBin}; install ${options.release} and its matching wasm sdk`
18036
18394
  );
@@ -18064,8 +18422,8 @@ function compileSwiftProjectOnce(input, options) {
18064
18422
  // shipped host plugins resolve against the selected compiler's runtime.
18065
18423
  ...process.platform === "linux" ? {
18066
18424
  LD_LIBRARY_PATH: [
18067
- path28.resolve(options.toolchainBin, "../lib/swift/linux"),
18068
- path28.resolve(options.toolchainBin, "../lib/swift/host"),
18425
+ path30.resolve(options.toolchainBin, "../lib/swift/linux"),
18426
+ path30.resolve(options.toolchainBin, "../lib/swift/host"),
18069
18427
  process.env.LD_LIBRARY_PATH
18070
18428
  ].filter(Boolean).join(":")
18071
18429
  } : {},
@@ -18104,21 +18462,22 @@ function compileSwiftProjectOnce(input, options) {
18104
18462
  layout2,
18105
18463
  input,
18106
18464
  frameworkRoot,
18107
- prebuilt
18465
+ prebuilt,
18466
+ !options.project
18108
18467
  );
18109
- const productFile = path28.join(frameworkRoot, SWIFT_FRAMEWORK_PRODUCT_FILE);
18468
+ const productFile = path30.join(frameworkRoot, SWIFT_FRAMEWORK_PRODUCT_FILE);
18110
18469
  writeSwiftAutolinkLinker(
18111
18470
  root,
18112
18471
  options.toolchainBin,
18113
- existsSync6(productFile) ? [
18472
+ existsSync7(productFile) ? [
18114
18473
  v5.parse(
18115
18474
  swiftFrameworkProductSchema,
18116
- JSON.parse(readFileSync17(productFile, "utf8"))
18475
+ JSON.parse(readFileSync18(productFile, "utf8"))
18117
18476
  ).product.name
18118
18477
  ] : []
18119
18478
  );
18120
18479
  const projectProcess = options.project ? prepareSwiftProjectProcess(root, options.project) : void 0;
18121
- const compiler = preparation.targetToolset ? { CC: path28.join(root, CLANG_TARGET_MODULE_WRAPPER) } : {};
18480
+ const compiler = preparation.targetToolset ? { CC: path30.join(root, CLANG_TARGET_MODULE_WRAPPER) } : {};
18122
18481
  const appOptions = projectProcess ? {
18123
18482
  ...buildOptions,
18124
18483
  uid: projectProcess.uid,
@@ -18132,10 +18491,10 @@ function compileSwiftProjectOnce(input, options) {
18132
18491
  for (const [file, text2] of Object.entries(input.files)) {
18133
18492
  const parents = /^#include "((?:\.\.\/)+)[^"\n]+"\n$/.exec(text2)?.[1];
18134
18493
  if (!parents) continue;
18135
- const directory = path28.posix.dirname(file);
18494
+ const directory = path30.posix.dirname(file);
18136
18495
  forwarders.set(
18137
- `${path28.join(root, directory)}/${parents.slice(0, -1)}`,
18138
- path28.posix.join("build", directory, parents).replace(/\/$/, "")
18496
+ `${path30.join(root, directory)}/${parents.slice(0, -1)}`,
18497
+ path30.posix.join("build", directory, parents).replace(/\/$/, "")
18139
18498
  );
18140
18499
  }
18141
18500
  const buildArgs = [
@@ -18151,7 +18510,7 @@ function compileSwiftProjectOnce(input, options) {
18151
18510
  ...swiftObjCSelectorOptions(frameworkRoot),
18152
18511
  "--swift-sdk",
18153
18512
  sdk,
18154
- ...preparation.targetToolset ? ["--toolset", path28.join(root, ".peach-target-toolset.json")] : [],
18513
+ ...preparation.targetToolset ? ["--toolset", path30.join(root, ".peach-target-toolset.json")] : [],
18155
18514
  "-c",
18156
18515
  "release",
18157
18516
  // the link strips debug info, so none is generated (as for the framework)
@@ -18162,14 +18521,14 @@ function compileSwiftProjectOnce(input, options) {
18162
18521
  "-Xswiftc",
18163
18522
  String(swiftBuildJobs()),
18164
18523
  ...swiftReproducibleBuildFlags([
18165
- [path28.dirname(options.toolchainBin), "toolchain"],
18524
+ [path30.dirname(options.toolchainBin), "toolchain"],
18166
18525
  [frameworkRoot, "framework"],
18167
18526
  [root, "build"],
18168
18527
  ...forwarders
18169
18528
  ]).flatMap((flag, index, flags) => {
18170
18529
  if (!nativeToolset || !flag.startsWith("-ffile-prefix-map="))
18171
18530
  return [flag];
18172
- const toolchainDir = path28.dirname(options.toolchainBin);
18531
+ const toolchainDir = path30.dirname(options.toolchainBin);
18173
18532
  let mapped = flag;
18174
18533
  for (const [dir, target] of [
18175
18534
  [root, "/peach/build"],
@@ -18198,9 +18557,9 @@ function compileSwiftProjectOnce(input, options) {
18198
18557
  ])
18199
18558
  ];
18200
18559
  const linked = builtArtifact(layout2);
18201
- rmSync7(path28.join(root, ".peach-link.rsp"), { force: true });
18202
- if (options.linkOnly || existsSync6(linked) && statSync2(linked).size <= 8)
18203
- rmSync7(linked, { force: true });
18560
+ rmSync8(path30.join(root, ".peach-link.rsp"), { force: true });
18561
+ if (options.linkOnly || existsSync7(linked) && statSync3(linked).size <= 8)
18562
+ rmSync8(linked, { force: true });
18204
18563
  report("compiling and linking Swift modules");
18205
18564
  const frameworkInterfaces = /* @__PURE__ */ new Map();
18206
18565
  const nativeDeclarations = /* @__PURE__ */ new Map();
@@ -18210,58 +18569,58 @@ function compileSwiftProjectOnce(input, options) {
18210
18569
  const name2 = moduleMapName(contents2);
18211
18570
  const umbrella = /\bumbrella\s+header\s+"([^"]+)"/.exec(contents2)?.[1];
18212
18571
  if (!name2 || !umbrella) continue;
18213
- const header = input.files[path28.posix.join(path28.posix.dirname(file), umbrella)];
18572
+ const header = input.files[path30.posix.join(path30.posix.dirname(file), umbrella)];
18214
18573
  if (header === void 0) continue;
18215
18574
  const included = new Set(
18216
18575
  [
18217
18576
  ...header.matchAll(/^\s*#\s*(?:import|include)\s*[<"]([^">]+)[">]/gm)
18218
- ].map((match) => path28.posix.basename(match[1]))
18577
+ ].map((match) => path30.posix.basename(match[1]))
18219
18578
  );
18220
18579
  const declarations = nativeDeclarations.get(name2) ?? /* @__PURE__ */ new Set();
18221
18580
  for (const declaration of swiftInterfaceDeclarations(header))
18222
18581
  declarations.add(declaration);
18223
18582
  for (const [candidate, source] of Object.entries(input.files))
18224
- if (included.has(path28.posix.basename(candidate)))
18583
+ if (included.has(path30.posix.basename(candidate)))
18225
18584
  for (const declaration of swiftInterfaceDeclarations(source))
18226
18585
  declarations.add(declaration);
18227
18586
  nativeDeclarations.set(name2, declarations);
18228
18587
  }
18229
18588
  const frameworkInterface = (name2) => {
18230
18589
  if (frameworkInterfaces.has(name2)) return frameworkInterfaces.get(name2);
18231
- const source = distribution ? path28.join(frameworkRoot, "modules", `${name2}-Swift.h`) : path28.join(
18590
+ const source = distribution ? path30.join(frameworkRoot, "modules", `${name2}-Swift.h`) : path30.join(
18232
18591
  prebuilt.modules,
18233
18592
  "..",
18234
18593
  `${name2}.build/include/${name2}-Swift.h`
18235
18594
  );
18236
- if (!existsSync6(source)) {
18595
+ if (!existsSync7(source)) {
18237
18596
  frameworkInterfaces.set(name2, null);
18238
18597
  return null;
18239
18598
  }
18240
- const headers = path28.join(
18599
+ const headers = path30.join(
18241
18600
  swiftSdkPaths(frameworkRoot, options.toolchainBin).darwin,
18242
18601
  `System/Library/Frameworks/${name2}.framework/Headers`
18243
18602
  );
18244
18603
  const declared = /* @__PURE__ */ new Set();
18245
- if (existsSync6(headers)) {
18604
+ if (existsSync7(headers)) {
18246
18605
  for (const file of readdirSync8(headers, {
18247
18606
  recursive: true,
18248
18607
  encoding: "utf8"
18249
18608
  }))
18250
18609
  if (file.endsWith(".h"))
18251
18610
  for (const name3 of swiftInterfaceDeclarations(
18252
- readFileSync17(path28.join(headers, file), "utf8")
18611
+ readFileSync18(path30.join(headers, file), "utf8")
18253
18612
  ))
18254
18613
  declared.add(name3);
18255
18614
  }
18256
18615
  for (const declaration of nativeDeclarations.get(name2) ?? [])
18257
18616
  declared.add(declaration);
18258
18617
  const own = withoutSwiftDeclarations(
18259
- clangInterfaceHeader(readFileSync17(source, "utf8")),
18618
+ clangInterfaceHeader(readFileSync18(source, "utf8")),
18260
18619
  declared,
18261
18620
  nativeDeclarations.has(name2) ? `@import ${name2};` : `#import <${name2}/${name2}.h>`
18262
18621
  );
18263
18622
  const owners = sdkObjCDeclarationOwners(
18264
- path28.dirname(path28.dirname(headers))
18623
+ path30.dirname(path30.dirname(headers))
18265
18624
  );
18266
18625
  const foreign = /* @__PURE__ */ new Map();
18267
18626
  for (const declaration of [
@@ -18280,117 +18639,140 @@ function compileSwiftProjectOnce(input, options) {
18280
18639
  [...new Set(foreign.values())].map((owner) => `#import <${owner}/${owner}.h>`).join("\n")
18281
18640
  ) : own;
18282
18641
  const value = {
18283
- file: path28.join(root, ".build/peach-framework-objc", `${name2}-Swift.h`),
18642
+ file: path30.join(root, ".build/peach-framework-objc", `${name2}-Swift.h`),
18284
18643
  header,
18285
- module: existsSync6(headers)
18644
+ module: existsSync7(headers)
18286
18645
  };
18287
18646
  frameworkInterfaces.set(name2, value);
18288
18647
  writeBuildFile(
18289
18648
  value.file,
18290
- (existsSync6(path28.join(headers, `${name2}.h`)) ? `#import <${name2}/${name2}.h>
18649
+ (existsSync7(path30.join(headers, `${name2}.h`)) ? `#import <${name2}/${name2}.h>
18291
18650
  ` : "") + swiftHeaderWithSuperclassImports(header, frameworkInterface)
18292
18651
  );
18293
18652
  return value;
18294
18653
  };
18295
- const compileApp = async () => {
18654
+ const headerPaths = (producer) => {
18655
+ const stem = path30.join(
18656
+ root,
18657
+ ".build",
18658
+ "peach-cxx-headers",
18659
+ `${producer}-Swift`
18660
+ );
18661
+ return { producer, original: `${stem}.original.h`, emitted: `${stem}.h` };
18662
+ };
18663
+ const publishHeader = ({
18664
+ producer,
18665
+ original,
18666
+ emitted
18667
+ }) => {
18668
+ const generated = clangInterfaceHeader(readFileSync18(original, "utf8"));
18669
+ writeBuildFile(
18670
+ emitted,
18671
+ withoutSwiftDeclarations(
18672
+ swiftHeaderWithSuperclassImports(generated, frameworkInterface),
18673
+ /* @__PURE__ */ new Set([
18674
+ ...preparation.nativeHeaderDeclarations[producer] ?? [],
18675
+ ...nativelyDeclaredFunctions(generated, nativeHeaders)
18676
+ ]),
18677
+ `#import <${producer}/${producer}.h>`
18678
+ )
18679
+ );
18680
+ };
18681
+ const recipe = createHash15("sha256").update(hash).update(readFileSync18(path30.join(root, "Package.swift"))).update(JSON.stringify(buildArgs)).digest("hex");
18682
+ const runApp = async (compiler2) => {
18683
+ const optionsWithCompiler = compiler2 ? { ...appOptions, env: { ...appOptions.env, ...compiler2 } } : appOptions;
18296
18684
  const stages = [
18297
18685
  ...preparation.headerBuilds,
18298
18686
  ...preparation.nativeProductTarget ? [{ target: preparation.nativeProductTarget, producers: [] }] : []
18299
18687
  ];
18300
- const checkpoints = path28.join(root, ".build", "peach-product-checkpoints");
18301
- const recipe = createHash14("sha256").update(hash).update(readFileSync17(path28.join(root, "Package.swift"))).update(JSON.stringify(buildArgs)).digest("hex");
18688
+ const checkpoints = path30.join(root, ".build", "peach-product-checkpoints");
18302
18689
  for (const { target, producers } of stages) {
18303
- const receipt = path28.join(
18690
+ const receipt = path30.join(
18304
18691
  checkpoints,
18305
- createHash14("sha256").update(target).digest("hex")
18692
+ createHash15("sha256").update(target).digest("hex")
18306
18693
  );
18307
- const headers = producers.map((producer) => {
18308
- const stem = path28.join(
18309
- root,
18310
- ".build",
18311
- "peach-cxx-headers",
18312
- `${producer}-Swift`
18313
- );
18314
- return {
18315
- producer,
18316
- original: `${stem}.original.h`,
18317
- emitted: `${stem}.h`
18318
- };
18319
- });
18694
+ const headers = producers.map(headerPaths);
18320
18695
  const fingerprint = () => {
18321
- const digest = createHash14("sha256").update(recipe);
18322
- for (const { emitted } of headers) {
18323
- if (!existsSync6(emitted)) return;
18696
+ const digest = createHash15("sha256").update(recipe);
18697
+ for (const { original, emitted } of headers) {
18698
+ if (!existsSync7(original) || !existsSync7(emitted)) return;
18324
18699
  digest.update(
18325
- createHash14("sha256").update(readFileSync17(emitted)).digest()
18700
+ createHash15("sha256").update(readFileSync18(emitted)).digest()
18326
18701
  );
18327
18702
  }
18328
18703
  return digest.digest("hex");
18329
18704
  };
18330
- if (!options.project && existsSync6(receipt) && readFileSync17(receipt, "utf8") === fingerprint())
18705
+ if (!options.project && existsSync7(receipt) && readFileSync18(receipt, "utf8") === fingerprint())
18331
18706
  continue;
18332
- if (!options.project) rmSync7(receipt, { force: true });
18333
- for (const { producer, original } of headers)
18334
- if (!existsSync6(original))
18335
- rmSync7(
18336
- path28.join(
18337
- root,
18338
- ".build",
18339
- WASM_TRIPLE,
18340
- "release",
18707
+ if (!options.project) rmSync8(receipt, { force: true });
18708
+ for (const header of headers) {
18709
+ if (compiler2 && existsSync7(header.original)) publishHeader(header);
18710
+ if (!existsSync7(header.original))
18711
+ rmSync8(
18712
+ path30.join(
18713
+ path30.dirname(linked),
18341
18714
  "Modules",
18342
- `${swiftTargetModuleName(producer)}.swiftmodule`
18715
+ `${swiftTargetModuleName(header.producer)}.swiftmodule`
18343
18716
  ),
18344
18717
  { force: true }
18345
18718
  );
18719
+ }
18346
18720
  await runCompiler(
18347
18721
  swift,
18348
18722
  [...buildArgs, "--target", target],
18349
- appOptions,
18723
+ optionsWithCompiler,
18350
18724
  SWIFTPM_PROGRESS,
18351
18725
  SWIFTPM_NOISE
18352
18726
  );
18353
- for (const { producer, original, emitted } of headers) {
18354
- const generated = clangInterfaceHeader(readFileSync17(original, "utf8"));
18355
- writeBuildFile(
18356
- emitted,
18357
- withoutSwiftDeclarations(
18358
- swiftHeaderWithSuperclassImports(generated, frameworkInterface),
18359
- /* @__PURE__ */ new Set([
18360
- ...preparation.nativeHeaderDeclarations[producer] ?? [],
18361
- ...nativelyDeclaredFunctions(generated, nativeHeaders)
18362
- ]),
18363
- `#import <${producer}/${producer}.h>`
18364
- )
18365
- );
18366
- }
18727
+ if (!compiler2) for (const header of headers) publishHeader(header);
18367
18728
  if (!options.project) {
18368
- mkdirSync7(checkpoints, { recursive: true });
18369
- writeFileSync8(`${receipt}.partial`, fingerprint());
18370
- renameSync2(`${receipt}.partial`, receipt);
18729
+ const checkpoint = fingerprint();
18730
+ if (checkpoint === void 0)
18731
+ throw new Error(`missing Swift headers after building ${target}`);
18732
+ mkdirSync8(checkpoints, { recursive: true });
18733
+ writeFileSync9(`${receipt}.partial`, checkpoint);
18734
+ renameSync3(`${receipt}.partial`, receipt);
18371
18735
  }
18372
18736
  }
18373
18737
  await runCompiler(
18374
18738
  swift,
18375
18739
  buildArgs,
18376
- appOptions,
18740
+ optionsWithCompiler,
18377
18741
  SWIFTPM_PROGRESS,
18378
18742
  SWIFTPM_NOISE
18379
18743
  );
18380
18744
  };
18745
+ const compileApp = () => preparation.headerCompiler ? withSwiftHeaderCompiler(
18746
+ root,
18747
+ options.toolchainBin,
18748
+ recipe,
18749
+ new Map(
18750
+ preparation.headerBuilds[0].producers.map((producer) => {
18751
+ const paths = headerPaths(producer);
18752
+ return [
18753
+ swiftTargetModuleName(producer),
18754
+ {
18755
+ header: paths.original,
18756
+ publish: () => publishHeader(paths)
18757
+ }
18758
+ ];
18759
+ })
18760
+ ),
18761
+ runApp
18762
+ ) : runApp();
18381
18763
  try {
18382
18764
  await compileApp();
18383
18765
  } catch (error) {
18384
18766
  const output2 = outputOf(error);
18385
- const moduleCache = path28.join(
18767
+ const moduleCache = path30.join(
18386
18768
  root,
18387
18769
  ".build",
18388
18770
  WASM_TRIPLE,
18389
18771
  "release",
18390
18772
  "ModuleCache"
18391
18773
  );
18392
- if (output2.includes("was compiled with module cache path") && existsSync6(moduleCache)) {
18393
- rmSync7(moduleCache, { recursive: true, force: true });
18774
+ if (output2.includes("was compiled with module cache path") && existsSync7(moduleCache)) {
18775
+ rmSync8(moduleCache, { recursive: true, force: true });
18394
18776
  try {
18395
18777
  await compileApp();
18396
18778
  } catch (retryError) {
@@ -18414,11 +18796,11 @@ function compileSwiftProjectOnce(input, options) {
18414
18796
  if (options.project) endSwiftProjectProcesses(options.project);
18415
18797
  }
18416
18798
  if (unprepared.length) throw new Error(unprepared.join("\n"));
18417
- if (!existsSync6(linked)) {
18418
- const binDir = path28.dirname(linked);
18419
- const found = existsSync6(binDir) ? readdirSync8(binDir).filter((name2) => name2.endsWith(".wasm")).sort() : [];
18799
+ if (!existsSync7(linked)) {
18800
+ const binDir = path30.dirname(linked);
18801
+ const found = existsSync7(binDir) ? readdirSync8(binDir).filter((name2) => name2.endsWith(".wasm")).sort() : [];
18420
18802
  throw new Error(
18421
- `swift-compile: the build produced no ${path28.basename(linked)} (found: ${found.join(", ") || "none"})`
18803
+ `swift-compile: the build produced no ${path30.basename(linked)} (found: ${found.join(", ") || "none"})`
18422
18804
  );
18423
18805
  }
18424
18806
  if (options.project) removeProjectLinks(root);
@@ -18436,7 +18818,7 @@ function compileSwiftProjectOnce(input, options) {
18436
18818
  resourceReferences
18437
18819
  );
18438
18820
  if (options.linkOnly) {
18439
- if (statSync2(linked).size <= 8)
18821
+ if (statSync3(linked).size <= 8)
18440
18822
  throw new Error("swift-compile: deferred linker produced no executable");
18441
18823
  report("project link verified");
18442
18824
  return;
@@ -18447,9 +18829,10 @@ function compileSwiftProjectOnce(input, options) {
18447
18829
  await compileGuestLink({
18448
18830
  graph: guestGraph,
18449
18831
  buildDirectory: root,
18450
- releaseDirectory: path28.dirname(linked),
18832
+ releaseDirectory: path30.dirname(linked),
18451
18833
  moduleRoot: frameworkRoot,
18452
18834
  toolchainBin: options.toolchainBin,
18835
+ swiftCompiler: preparation.headerCompiler ? path30.join(root, SWIFT_HEADER_COMPILER_WRAPPER) : path30.join(options.toolchainBin, "swiftc"),
18453
18836
  sysroot: swiftSdkPaths(frameworkRoot, options.toolchainBin).sysroot,
18454
18837
  sdk: swiftModuleSdk(frameworkRoot),
18455
18838
  staticClangTargets: input.staticClangTargets ?? [],
@@ -18462,13 +18845,13 @@ function compileSwiftProjectOnce(input, options) {
18462
18845
  else
18463
18846
  await lowerWasm(output, optimized, { optimize: input.optimize === true });
18464
18847
  await runCompiler(
18465
- path28.join(options.toolchainBin, "llvm-objcopy"),
18848
+ path30.join(options.toolchainBin, "llvm-objcopy"),
18466
18849
  ["--remove-section=.swift1_autolink_entries", optimized],
18467
18850
  buildOptions
18468
18851
  );
18469
18852
  const artifact = {
18470
18853
  hash,
18471
- bytes: readFileSync17(optimized),
18854
+ bytes: readFileSync18(optimized),
18472
18855
  icu: await icu
18473
18856
  };
18474
18857
  if (artifact.bytes.length <= 8)