peachsim 0.1.2405 → 0.1.2408

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 (98) hide show
  1. package/cli/agent-note.ts +231 -0
  2. package/cli/cli-update.ts +2 -2
  3. package/cli/cloud-dispatch.ts +1 -1
  4. package/cli/commands/agent.ts +29 -26
  5. package/cli/commands/stream.ts +11 -7
  6. package/cli/main.ts +16 -2
  7. package/cli/outbound-endpoints.ts +16 -1
  8. package/dist-lib/agent-daemon-client.cjs +23 -3
  9. package/dist-lib/agent-events.cjs +1 -1
  10. package/dist-lib/attached-projects.cjs +1 -1
  11. package/dist-lib/auth/shared-session.cjs +1 -1
  12. package/dist-lib/backend-origin.cjs +1 -1
  13. package/dist-lib/beta.cjs +1 -1
  14. package/dist-lib/beta.mjs +1 -1
  15. package/dist-lib/bridge-constants.cjs +1 -1
  16. package/dist-lib/bridge-contract-input.cjs +1 -1
  17. package/dist-lib/bridge-contract-input.mjs +1 -1
  18. package/dist-lib/bridge-contract.cjs +1 -1
  19. package/dist-lib/bridge-contract.mjs +1 -1
  20. package/dist-lib/bundle-channel.cjs +201 -60
  21. package/dist-lib/capture-contract.cjs +1 -1
  22. package/dist-lib/capture-contract.mjs +1 -1
  23. package/dist-lib/cloud-contract.cjs +1 -1
  24. package/dist-lib/cloud-contract.mjs +1 -1
  25. package/dist-lib/cloud-test-args.cjs +1 -1
  26. package/dist-lib/cloud-test-args.mjs +1 -1
  27. package/dist-lib/cloud.cjs +1 -1
  28. package/dist-lib/cloud.mjs +1 -1
  29. package/dist-lib/config.cjs +1 -1
  30. package/dist-lib/config.mjs +1 -1
  31. package/dist-lib/detox/index.cjs +1 -1
  32. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  33. package/dist-lib/expo-swift-bundle.cjs +200 -59
  34. package/dist-lib/expo-swift-metadata.cjs +1 -1
  35. package/dist-lib/expo-swift-metadata.mjs +1 -1
  36. package/dist-lib/home-paths.cjs +1 -1
  37. package/dist-lib/host/bridge-host.cjs +356 -100
  38. package/dist-lib/host/fetch-proxy-handler.cjs +4 -4
  39. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  40. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  41. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  42. package/dist-lib/host/websocket-proxy.cjs +1 -1
  43. package/dist-lib/index.cjs +4 -4
  44. package/dist-lib/jump-to-source-babel.cjs +1 -1
  45. package/dist-lib/jump-to-source-native.cjs +1 -1
  46. package/dist-lib/kotlin-host.cjs +1 -1
  47. package/dist-lib/menu.cjs +1 -1
  48. package/dist-lib/menu.mjs +1 -1
  49. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  50. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  51. package/dist-lib/metro-production-bundle.cjs +1 -1
  52. package/dist-lib/metro-production-bundle.mjs +1 -1
  53. package/dist-lib/metro.cjs +4 -4
  54. package/dist-lib/native-app-identity-project.cjs +3 -3
  55. package/dist-lib/native-app-identity-project.mjs +3 -3
  56. package/dist-lib/native-app-identity.cjs +1 -1
  57. package/dist-lib/native-app-identity.mjs +1 -1
  58. package/dist-lib/native-firebase-metadata.cjs +1 -1
  59. package/dist-lib/native-firebase-metadata.mjs +1 -1
  60. package/dist-lib/pdfium-raster.cjs +1 -1
  61. package/dist-lib/pdfium-raster.mjs +1 -1
  62. package/dist-lib/plist.cjs +1 -1
  63. package/dist-lib/plist.mjs +1 -1
  64. package/dist-lib/profiles.cjs +1 -1
  65. package/dist-lib/public-brand.cjs +1 -1
  66. package/dist-lib/public-origins-lib-esm.json +24 -24
  67. package/dist-lib/public-origins-lib.json +56 -55
  68. package/dist-lib/react-native-host-modules.cjs +1 -1
  69. package/dist-lib/react-native-host-modules.mjs +1 -1
  70. package/dist-lib/reap-browser.cjs +1 -1
  71. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  72. package/dist-lib/sdk.cjs +1 -1
  73. package/dist-lib/sdk.mjs +1 -1
  74. package/dist-lib/skills.cjs +367 -106
  75. package/dist-lib/swift-compile.cjs +195 -54
  76. package/dist-lib/swift-compile.mjs +195 -54
  77. package/dist-lib/swift-package.cjs +1 -1
  78. package/dist-lib/swift-package.mjs +1 -1
  79. package/dist-lib/swift-submit.cjs +1 -1
  80. package/dist-lib/swift-submit.mjs +1 -1
  81. package/dist-lib/swift-toolchain.cjs +1 -1
  82. package/dist-lib/swift.cjs +1 -1
  83. package/dist-lib/vite-swift.cjs +198 -57
  84. package/dist-lib/vite.cjs +4 -4
  85. package/dist-lib/worklet-executable.cjs +1 -1
  86. package/dist-lib/worklet-executable.mjs +1 -1
  87. package/install.sh +1 -1
  88. package/kotlin/sdk.tar.gz +0 -0
  89. package/package.json +1 -1
  90. package/skills/peach-setup/SKILL.md +8 -3
  91. package/src/agent-daemon-client.ts +35 -2
  92. package/src/agent-prompt.ts +68 -0
  93. package/src/canvas-agent-note-delivery.ts +83 -0
  94. package/src/host/agent-host.ts +128 -18
  95. package/src/swift-compile.ts +124 -66
  96. package/src/swift-host.ts +2 -1
  97. package/src/swift-objc-import.ts +99 -0
  98. package/src/xcode-header-search.ts +33 -0
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2405 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2408 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
3
3
  "use strict";
4
4
  var __create = Object.create;
@@ -12079,6 +12079,78 @@ function swiftClangImporterFlags(flags) {
12079
12079
  (flag) => flag !== "-fobjc-arc" && flag !== "-fno-objc-arc" && !/^-std=(?:c(?!\+\+)|gnu(?!\+\+)|iso9899:)/.test(flag)
12080
12080
  );
12081
12081
  }
12082
+ var CLANG_PATH_OPTIONS = /* @__PURE__ */ new Set([
12083
+ "-I",
12084
+ "-F",
12085
+ "-idirafter",
12086
+ "-iframework",
12087
+ "-iframeworkwithsysroot",
12088
+ "-imacros",
12089
+ "-include",
12090
+ "-iprefix",
12091
+ "-iquote",
12092
+ "-isystem",
12093
+ "-isysroot",
12094
+ "-ivfsoverlay",
12095
+ "-iwithprefix",
12096
+ "-iwithprefixbefore",
12097
+ "--sysroot"
12098
+ ]);
12099
+ function compactSwiftClangDefines(flags) {
12100
+ const definitions = /* @__PURE__ */ new Map();
12101
+ const macros = [];
12102
+ for (let index = 0; index < flags.length; index++) {
12103
+ if (flags[index].startsWith("@")) return flags;
12104
+ if (flags[index] !== "-Xcc") continue;
12105
+ const flag = flags[++index];
12106
+ if (flag === void 0 || flags[index - 2] === "-Xfrontend" || flag === "-Xclang" || flag === "-Xpreprocessor" || flag.startsWith("-Wp,") || flag.startsWith("--config") || flag.startsWith("@"))
12107
+ return flags;
12108
+ if (CLANG_PATH_OPTIONS.has(flag) && flags[index + 1] === "-Xcc") {
12109
+ index += 2;
12110
+ continue;
12111
+ }
12112
+ if (!flag.startsWith("-D") && !flag.startsWith("-U")) continue;
12113
+ const name2 = /^-[DU]([A-Za-z_$][\w$]*)(?=[(=]|$)/.exec(flag)?.[1];
12114
+ if (!name2) return flags;
12115
+ const previous = definitions.get(name2);
12116
+ definitions.set(name2, previous === void 0 || previous === flag ? flag : null);
12117
+ macros.push({ index, name: name2, flag });
12118
+ }
12119
+ const seen = /* @__PURE__ */ new Set();
12120
+ const duplicates = /* @__PURE__ */ new Set();
12121
+ for (const { index, name: name2, flag } of macros) {
12122
+ if (definitions.get(name2) !== flag) continue;
12123
+ if (seen.has(name2)) {
12124
+ duplicates.add(index - 1);
12125
+ duplicates.add(index);
12126
+ }
12127
+ seen.add(name2);
12128
+ }
12129
+ return duplicates.size === 0 ? flags : flags.filter((_, index) => !duplicates.has(index));
12130
+ }
12131
+ function compactSwiftClangOverlays(flags, generated) {
12132
+ if (generated.size === 0) return flags;
12133
+ const overlays = /* @__PURE__ */ new Map();
12134
+ const duplicates = /* @__PURE__ */ new Set();
12135
+ for (let index = 0; index < flags.length; index++) {
12136
+ const flag = flags[index];
12137
+ if (flag.startsWith("@")) return flags;
12138
+ if (flag === "-Xcc" && flags[index - 1] === "-Xfrontend") return flags;
12139
+ if (flags[index - 1] === "-Xcc" && (flag.startsWith("--config") || flag === "-Xclang"))
12140
+ return flags;
12141
+ if (!flag.startsWith("-ivfsoverlay") && !flag.startsWith("-vfsoverlay")) continue;
12142
+ if (flag !== "-ivfsoverlay" || flags[index - 1] !== "-Xcc" || flags[index + 1] !== "-Xcc")
12143
+ return flags;
12144
+ const file = flags[index + 2];
12145
+ if (file === void 0 || !generated.has(file)) return flags;
12146
+ const previous = overlays.get(file);
12147
+ if (previous !== void 0)
12148
+ for (let offset = -1; offset < 3; offset++) duplicates.add(previous + offset);
12149
+ overlays.set(file, index);
12150
+ index += 2;
12151
+ }
12152
+ return duplicates.size === 0 ? flags : flags.filter((_, index) => !duplicates.has(index));
12153
+ }
12082
12154
  var SWIFT_SUBMODULE_IMPORT = /^[ \t]*(?:@\w+(?:\([^)]*\))?[ \t]+)*import[ \t]+([A-Za-z_]\w*)\.([A-Za-z_]\w*)[ \t]*(?:\/\/.*)?$/gm;
12083
12155
  function swiftSubmoduleImports(sources) {
12084
12156
  const imports = /* @__PURE__ */ new Map();
@@ -12598,6 +12670,30 @@ function isSwiftResourceBundles(value) {
12598
12670
  // src/xcode-header-search.ts
12599
12671
  var import_node_fs24 = __toESM(require("node:fs"), 1);
12600
12672
  var import_node_path25 = __toESM(require("node:path"), 1);
12673
+ function coalescibleHeaderOverlays(files) {
12674
+ const aliases = /* @__PURE__ */ new Map();
12675
+ const key = (file) => file.replace(/[A-Z]/g, (letter) => letter.toLowerCase());
12676
+ const index = (directory, entry) => {
12677
+ const name2 = import_node_path25.default.resolve(directory, entry.name);
12678
+ if (entry.type === "directory")
12679
+ return entry.contents.every((child) => index(name2, child));
12680
+ const source = entry["external-contents"];
12681
+ const previous = aliases.get(key(name2));
12682
+ if (previous !== void 0 && previous !== source) return false;
12683
+ aliases.set(key(name2), source);
12684
+ return true;
12685
+ };
12686
+ for (const file of files) {
12687
+ const overlay = JSON.parse(import_node_fs24.default.readFileSync(file, "utf8"));
12688
+ if (!overlay.roots.every((entry) => index(import_node_path25.default.dirname(file), entry)))
12689
+ return /* @__PURE__ */ new Set();
12690
+ }
12691
+ for (const file of [...files, ...aliases.values()]) {
12692
+ const source = aliases.get(key(import_node_path25.default.normalize(file)));
12693
+ if (source !== void 0 && source !== file) return /* @__PURE__ */ new Set();
12694
+ }
12695
+ return files;
12696
+ }
12601
12697
  function headerMap(entries) {
12602
12698
  const unique = /* @__PURE__ */ new Map();
12603
12699
  for (const entry of entries)
@@ -13670,6 +13766,15 @@ function swiftTargetDependencies(files, targets, frameworks = OPTIONAL_FRAMEWORK
13670
13766
  )
13671
13767
  );
13672
13768
  const names = /* @__PURE__ */ new Set([...frameworks, ...targets.map((target) => target.name)]);
13769
+ const entriesByPrefix = new Map(
13770
+ targets.map(({ path: path25 }) => [path25 === "." ? "" : `${path25}/`, []])
13771
+ );
13772
+ for (const entry of Object.entries(files)) {
13773
+ const [file] = entry;
13774
+ entriesByPrefix.get("")?.push(entry);
13775
+ for (let end = file.indexOf("/"); end !== -1; end = file.indexOf("/", end + 1))
13776
+ entriesByPrefix.get(file.slice(0, end + 1))?.push(entry);
13777
+ }
13673
13778
  const siblings = /* @__PURE__ */ new Map();
13674
13779
  for (const target of targets) {
13675
13780
  const prefix = target.path === "." ? "" : `${target.path}/`;
@@ -13683,8 +13788,11 @@ function swiftTargetDependencies(files, targets, frameworks = OPTIONAL_FRAMEWORK
13683
13788
  (dependency) => dependency.kind === "target" && dependency.name !== target.name && names.has(dependency.name) || dependency.kind === "product" && dependency.package === "sootsim-swift" && OPTIONAL_FRAMEWORKS.has(dependency.name) ? [dependency.name] : []
13684
13789
  )
13685
13790
  );
13686
- for (const [file, contents2] of Object.entries(files)) {
13687
- if (file === "Package.swift" || !file.startsWith(prefix)) continue;
13791
+ const nested = target.sources === void 0 ? targets.flatMap(
13792
+ (candidate) => candidate.name !== target.name && candidate.path !== "." && candidate.path.startsWith(prefix) ? [`${candidate.path}/`] : []
13793
+ ) : [];
13794
+ for (const [file, contents2] of entriesByPrefix.get(prefix) ?? []) {
13795
+ if (file === "Package.swift") continue;
13688
13796
  const relative = file.slice(prefix.length);
13689
13797
  if (target.sources !== void 0 && !target.sources.some(
13690
13798
  (source) => source === "." || relative === source || relative.startsWith(`${source}/`)
@@ -13694,10 +13802,7 @@ function swiftTargetDependencies(files, targets, frameworks = OPTIONAL_FRAMEWORK
13694
13802
  (excluded) => relative === excluded || relative.startsWith(`${excluded}/`)
13695
13803
  ))
13696
13804
  continue;
13697
- if (target.sources === void 0 && targets.some(
13698
- (candidate) => candidate.name !== target.name && candidate.path !== "." && candidate.path.startsWith(prefix) && file.startsWith(`${candidate.path}/`)
13699
- ))
13700
- continue;
13805
+ if (nested.some((path25) => file.startsWith(path25))) continue;
13701
13806
  const imports = file.endsWith(".swift") ? swiftImportNames(contents2) : SWIFT_NATIVE_SOURCE_EXTENSIONS.some((extension) => file.endsWith(extension)) ? clangImportNames(contents2, ownsHeader) : [];
13702
13807
  for (const name2 of imports) {
13703
13808
  if (names.has(name2) && name2 !== target.name && !(target.dependencies !== void 0 && localNames.has(name2)))
@@ -13758,9 +13863,9 @@ var executableLinkFlags = (root) => ` "-Xclang-linker", "-O0",
13758
13863
  `;
13759
13864
  var darwinRecordsRegion = (quoted2) => quoted2.length ? ["-Wl,--start-lib", ...quoted2, "-Wl,--end-lib"] : [];
13760
13865
  var REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
13761
- var MULTI_MANIFEST_VERSION = 69;
13866
+ var MULTI_MANIFEST_VERSION = 71;
13762
13867
  var SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
13763
- var compilerSourceDigest = true ? "5f7b13ec00e56a1f8e36b1e4f1688c4eb10836e9afffb80f5e63e4fbf23e9070" : swiftCompilerSourceDigest(__sootsim_import_meta_dirname);
13868
+ var compilerSourceDigest = true ? "36b1496faf39a688e5ab3ee63bdab89a3afde2b9c6355443c3162f4b1e3b9144" : swiftCompilerSourceDigest(__sootsim_import_meta_dirname);
13764
13869
  function swiftArtifactHash(input, release, moduleRoot) {
13765
13870
  const hash = (0, import_node_crypto14.createHash)("sha256");
13766
13871
  hash.update(`swift-compile
@@ -13992,7 +14097,9 @@ function emitSwiftPackageManifest(args) {
13992
14097
  const flags = JSON.parse(literal2.replace(/,\s*]$/, "]")).filter(
13993
14098
  (flag, index, all) => !mapsPackageModule(flag) && !(flag === "-Xcc" && mapsPackageModule(all[index + 1] ?? ""))
13994
14099
  );
13995
- const content = flags.map((flag) => JSON.stringify(flag)).join("\n") + "\n";
14100
+ const macros = compactSwiftClangDefines(flags);
14101
+ const compact = args.coalescibleOverlays ? compactSwiftClangOverlays(macros, args.coalescibleOverlays) : macros;
14102
+ const content = compact.map((flag) => JSON.stringify(flag)).join("\n") + "\n";
13996
14103
  const digest = (0, import_node_crypto14.createHash)("sha256").update(content).digest("hex");
13997
14104
  const file = import_node_path26.default.join(args.root, ".peach-swift-arguments", `${digest}.rsp`);
13998
14105
  args.files.set(file, content);
@@ -14083,7 +14190,7 @@ function emitSwiftPackageManifest(args) {
14083
14190
  ].map((flag) => `, ${JSON.stringify(flag)}`).join("");
14084
14191
  const header = args.headerDirectory && (args.nativeHeaderDeclarations?.[target.name] || [...args.native?.values() ?? []].some(
14085
14192
  (value) => value.late?.producers.includes(target.name)
14086
- )) ? `, "-emit-objc-header-path", ${JSON.stringify(import_node_path26.default.join(args.headerDirectory, `${target.name}-Swift${args.nativeHeaderDeclarations?.[target.name] ? ".original" : ""}.h`))}` : "";
14193
+ )) ? `, "-emit-objc-header-path", ${JSON.stringify(import_node_path26.default.join(args.headerDirectory, `${target.name}-Swift.original.h`))}` : "";
14087
14194
  const clangMode = target.cxxInterop ? "" : ', "-Xcc", "-fno-cxx-modules"';
14088
14195
  const deployment = `, "-Xfrontend", "-peach-ios-deployment-target", "-Xfrontend", ${JSON.stringify(target.iosDeploymentTarget ?? SWIFTPM_DEFAULT_IOS_DEPLOYMENT_TARGET)}`;
14089
14196
  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}]`)})]`;
@@ -16731,6 +16838,9 @@ module ${moduleName}.Swift {
16731
16838
  nativeHeaderDeclarations[module2] = [...declared];
16732
16839
  }
16733
16840
  const nativeFlags = native.size > 0 ? /* @__PURE__ */ new Map() : void 0;
16841
+ const generatedOverlays = new Set(
16842
+ headerSearch.files.filter((file) => file.endsWith(".yaml"))
16843
+ );
16734
16844
  if (nativeFlags) {
16735
16845
  const toolchainBin = nativeToolchain();
16736
16846
  const headers = import_node_path26.default.join(swiftSdkPaths(moduleRoot, toolchainBin).sysroot, "darwin");
@@ -16751,8 +16861,11 @@ module ${moduleName}.Swift {
16751
16861
  throw new Error(
16752
16862
  target.name + ": missing or unsupported declared iOS deployment target " + JSON.stringify(version2)
16753
16863
  );
16864
+ const sdkIntake = objcSdkIntakeFlags(headers, toolchainBin, minimum);
16865
+ const sdkOverlay = sdkIntake.indexOf("-ivfsoverlay");
16866
+ if (sdkOverlay >= 0) generatedOverlays.add(sdkIntake[sdkOverlay + 1]);
16754
16867
  const intake = [
16755
- ...objcSdkIntakeFlags(headers, toolchainBin, minimum),
16868
+ ...sdkIntake,
16756
16869
  "-ivfsoverlay",
16757
16870
  headerSearch.files[0],
16758
16871
  "-I",
@@ -16921,6 +17034,7 @@ module ${moduleName}.Swift {
16921
17034
  sourceSwiftTargets: swiftTargets,
16922
17035
  nativeFlags,
16923
17036
  nativeImportFlags,
17037
+ coalescibleOverlays: nativeFlags ? coalescibleHeaderOverlays(generatedOverlays) : void 0,
16924
17038
  nativeHeaderFlags,
16925
17039
  nativeSwiftHeaderMaps,
16926
17040
  nativeHeaderDeclarations,
@@ -18231,6 +18345,7 @@ function compileSwiftProjectOnce(input, options) {
18231
18345
  report("compiling and linking Swift modules");
18232
18346
  const frameworkInterfaces = /* @__PURE__ */ new Map();
18233
18347
  const nativeDeclarations = /* @__PURE__ */ new Map();
18348
+ const nativeHeaders = Object.entries(input.files).filter(([name2]) => name2.endsWith(".h") && !name2.endsWith("-Swift.h")).map(([, source]) => source);
18234
18349
  for (const [file, contents2] of Object.entries(input.files)) {
18235
18350
  if (!file.endsWith(".modulemap")) continue;
18236
18351
  const name2 = moduleMapName(contents2);
@@ -18318,54 +18433,83 @@ function compileSwiftProjectOnce(input, options) {
18318
18433
  );
18319
18434
  return value;
18320
18435
  };
18321
- try {
18322
- for (const build of preparation.headerBuilds) {
18323
- await runCompiler(
18324
- swift,
18325
- [...buildArgs, "--target", build.target],
18326
- appOptions,
18327
- SWIFTPM_PROGRESS,
18328
- SWIFTPM_NOISE
18436
+ const compileApp = async () => {
18437
+ const stages = [
18438
+ ...preparation.headerBuilds,
18439
+ ...preparation.nativeProductTarget ? [{ target: preparation.nativeProductTarget, producers: [] }] : []
18440
+ ];
18441
+ const checkpoints = import_node_path26.default.join(root, ".build", "peach-product-checkpoints");
18442
+ const recipe = (0, import_node_crypto14.createHash)("sha256").update(hash).update((0, import_node_fs25.readFileSync)(import_node_path26.default.join(root, "Package.swift"))).update(JSON.stringify(buildArgs)).digest("hex");
18443
+ for (const { target, producers } of stages) {
18444
+ const receipt = import_node_path26.default.join(
18445
+ checkpoints,
18446
+ (0, import_node_crypto14.createHash)("sha256").update(target).digest("hex")
18329
18447
  );
18330
- for (const producer of build.producers) {
18331
- const emitted = import_node_path26.default.join(
18448
+ const headers = producers.map((producer) => {
18449
+ const stem = import_node_path26.default.join(
18332
18450
  root,
18333
18451
  ".build",
18334
18452
  "peach-cxx-headers",
18335
- `${producer}-Swift.h`
18453
+ `${producer}-Swift`
18336
18454
  );
18337
- const original = preparation.nativeHeaderDeclarations[producer] ? emitted.replace(/-Swift\.h$/, "-Swift.original.h") : emitted;
18338
- if ((0, import_node_fs25.existsSync)(original)) {
18339
- const generated = clangInterfaceHeader(
18340
- (0, import_node_fs25.readFileSync)(original, "utf8")
18341
- );
18342
- writeBuildFile(
18343
- emitted,
18344
- withoutSwiftDeclarations(
18345
- swiftHeaderWithSuperclassImports(generated, frameworkInterface),
18346
- /* @__PURE__ */ new Set([
18347
- ...preparation.nativeHeaderDeclarations[producer] ?? [],
18348
- ...nativelyDeclaredFunctions(
18349
- generated,
18350
- Object.entries(input.files).filter(
18351
- ([name2]) => name2.endsWith(".h") && !name2.endsWith("-Swift.h")
18352
- ).map(([, source]) => source)
18353
- )
18354
- ]),
18355
- `#import <${producer}/${producer}.h>`
18356
- )
18455
+ return {
18456
+ producer,
18457
+ original: `${stem}.original.h`,
18458
+ emitted: `${stem}.h`
18459
+ };
18460
+ });
18461
+ const fingerprint = () => {
18462
+ const digest = (0, import_node_crypto14.createHash)("sha256").update(recipe);
18463
+ for (const { emitted } of headers) {
18464
+ if (!(0, import_node_fs25.existsSync)(emitted)) return;
18465
+ digest.update(
18466
+ (0, import_node_crypto14.createHash)("sha256").update((0, import_node_fs25.readFileSync)(emitted)).digest()
18357
18467
  );
18358
18468
  }
18359
- }
18360
- }
18361
- if (preparation.nativeProductTarget) {
18469
+ return digest.digest("hex");
18470
+ };
18471
+ if (!options.project && (0, import_node_fs25.existsSync)(receipt) && (0, import_node_fs25.readFileSync)(receipt, "utf8") === fingerprint())
18472
+ continue;
18473
+ if (!options.project) (0, import_node_fs25.rmSync)(receipt, { force: true });
18474
+ for (const { producer, original } of headers)
18475
+ if (!(0, import_node_fs25.existsSync)(original))
18476
+ (0, import_node_fs25.rmSync)(
18477
+ import_node_path26.default.join(
18478
+ root,
18479
+ ".build",
18480
+ WASM_TRIPLE,
18481
+ "release",
18482
+ "Modules",
18483
+ `${swiftTargetModuleName(producer)}.swiftmodule`
18484
+ ),
18485
+ { force: true }
18486
+ );
18362
18487
  await runCompiler(
18363
18488
  swift,
18364
- [...buildArgs, "--target", preparation.nativeProductTarget],
18489
+ [...buildArgs, "--target", target],
18365
18490
  appOptions,
18366
18491
  SWIFTPM_PROGRESS,
18367
18492
  SWIFTPM_NOISE
18368
18493
  );
18494
+ for (const { producer, original, emitted } of headers) {
18495
+ const generated = clangInterfaceHeader((0, import_node_fs25.readFileSync)(original, "utf8"));
18496
+ writeBuildFile(
18497
+ emitted,
18498
+ withoutSwiftDeclarations(
18499
+ swiftHeaderWithSuperclassImports(generated, frameworkInterface),
18500
+ /* @__PURE__ */ new Set([
18501
+ ...preparation.nativeHeaderDeclarations[producer] ?? [],
18502
+ ...nativelyDeclaredFunctions(generated, nativeHeaders)
18503
+ ]),
18504
+ `#import <${producer}/${producer}.h>`
18505
+ )
18506
+ );
18507
+ }
18508
+ if (!options.project) {
18509
+ (0, import_node_fs25.mkdirSync)(checkpoints, { recursive: true });
18510
+ (0, import_node_fs25.writeFileSync)(`${receipt}.partial`, fingerprint());
18511
+ (0, import_node_fs25.renameSync)(`${receipt}.partial`, receipt);
18512
+ }
18369
18513
  }
18370
18514
  await runCompiler(
18371
18515
  swift,
@@ -18374,6 +18518,9 @@ function compileSwiftProjectOnce(input, options) {
18374
18518
  SWIFTPM_PROGRESS,
18375
18519
  SWIFTPM_NOISE
18376
18520
  );
18521
+ };
18522
+ try {
18523
+ await compileApp();
18377
18524
  } catch (error) {
18378
18525
  const output2 = outputOf(error);
18379
18526
  const moduleCache = import_node_path26.default.join(
@@ -18386,13 +18533,7 @@ function compileSwiftProjectOnce(input, options) {
18386
18533
  if (output2.includes("was compiled with module cache path") && (0, import_node_fs25.existsSync)(moduleCache)) {
18387
18534
  (0, import_node_fs25.rmSync)(moduleCache, { recursive: true, force: true });
18388
18535
  try {
18389
- await runCompiler(
18390
- swift,
18391
- buildArgs,
18392
- appOptions,
18393
- SWIFTPM_PROGRESS,
18394
- SWIFTPM_NOISE
18395
- );
18536
+ await compileApp();
18396
18537
  } catch (retryError) {
18397
18538
  throw new Error(
18398
18539
  [