peachsim 0.1.2406 → 0.1.2409

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