peachsim 0.1.2623 → 0.1.2624

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 (137) hide show
  1. package/dist-lib/agent-daemon-client.cjs +1 -1
  2. package/dist-lib/agent-events.cjs +1 -1
  3. package/dist-lib/attached-projects.cjs +1 -1
  4. package/dist-lib/auth/shared-session.cjs +1 -1
  5. package/dist-lib/backend-origin.cjs +1 -1
  6. package/dist-lib/beta.cjs +1 -1
  7. package/dist-lib/beta.mjs +2 -2
  8. package/dist-lib/bridge-constants.cjs +1 -1
  9. package/dist-lib/bridge-contract-input.cjs +1 -1
  10. package/dist-lib/bridge-contract-input.mjs +5 -5
  11. package/dist-lib/bridge-contract.cjs +1 -1
  12. package/dist-lib/bridge-contract.mjs +3 -3
  13. package/dist-lib/bundle-channel.cjs +693 -306
  14. package/dist-lib/capture-contract.cjs +1 -1
  15. package/dist-lib/capture-contract.mjs +3 -3
  16. package/dist-lib/cloud-contract.cjs +1 -1
  17. package/dist-lib/cloud-contract.mjs +3 -3
  18. package/dist-lib/cloud-test-args.cjs +1 -1
  19. package/dist-lib/cloud-test-args.mjs +2 -2
  20. package/dist-lib/cloud.cjs +1 -1
  21. package/dist-lib/cloud.mjs +7 -7
  22. package/dist-lib/config.cjs +1 -1
  23. package/dist-lib/config.mjs +5 -5
  24. package/dist-lib/detox/index.cjs +1 -1
  25. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  26. package/dist-lib/esm-chunks/{acorn-E6V72TM2.mjs → acorn-DH6VFUJ3.mjs} +3 -3
  27. package/dist-lib/esm-chunks/{chunk-RLWITQ5C.mjs → chunk-265THLTP.mjs} +1 -1
  28. package/dist-lib/esm-chunks/{chunk-PAEJF2JP.mjs → chunk-2YHIYKY2.mjs} +4 -4
  29. package/dist-lib/esm-chunks/{chunk-XOAOND7F.mjs → chunk-3XA5HYI5.mjs} +6 -6
  30. package/dist-lib/esm-chunks/{chunk-W3X7RP3H.mjs → chunk-A2WMBGJO.mjs} +3 -3
  31. package/dist-lib/esm-chunks/{chunk-UCW7ITXE.mjs → chunk-AV7G5PTE.mjs} +1 -1
  32. package/dist-lib/esm-chunks/{chunk-EIOVKQ2C.mjs → chunk-CM2NU5MS.mjs} +5 -5
  33. package/dist-lib/esm-chunks/{chunk-RVM3WWST.mjs → chunk-EFQFJ7M6.mjs} +1 -1
  34. package/dist-lib/esm-chunks/{chunk-RLWTJ6II.mjs → chunk-HKPKCJI5.mjs} +1 -1
  35. package/dist-lib/esm-chunks/{chunk-4GNQG2GT.mjs → chunk-IMI2NE4A.mjs} +1 -1
  36. package/dist-lib/esm-chunks/{chunk-Q7KCK4YO.mjs → chunk-JHMD4G4V.mjs} +1 -1
  37. package/dist-lib/esm-chunks/{chunk-4BJIJ3GP.mjs → chunk-LCO2EXKF.mjs} +1 -1
  38. package/dist-lib/esm-chunks/{chunk-CXNXKUNJ.mjs → chunk-LD7Z3NDO.mjs} +1 -1
  39. package/dist-lib/esm-chunks/{chunk-RBXTTEI6.mjs → chunk-LMWSFXYN.mjs} +1 -1
  40. package/dist-lib/esm-chunks/{chunk-IGB7TRLS.mjs → chunk-LOQBWIPM.mjs} +1 -1
  41. package/dist-lib/esm-chunks/{chunk-B4APPUTT.mjs → chunk-LT533AHJ.mjs} +1 -1
  42. package/dist-lib/esm-chunks/{chunk-KPG4FUTY.mjs → chunk-N4ZJZUCO.mjs} +1 -1
  43. package/dist-lib/esm-chunks/{chunk-NOM66H2G.mjs → chunk-OLAYY7SG.mjs} +1 -1
  44. package/dist-lib/esm-chunks/{chunk-GP3KL2GC.mjs → chunk-QNXV766K.mjs} +565 -290
  45. package/dist-lib/esm-chunks/{chunk-V2CHR3OI.mjs → chunk-QZ5HTMWV.mjs} +1 -1
  46. package/dist-lib/esm-chunks/{chunk-B5OQSD4B.mjs → chunk-T7C6Z5UH.mjs} +1 -1
  47. package/dist-lib/esm-chunks/{chunk-ISH6XB23.mjs → chunk-UJORQHAE.mjs} +1 -1
  48. package/dist-lib/esm-chunks/{chunk-Q4ZATFEN.mjs → chunk-VH4BJS5V.mjs} +1 -1
  49. package/dist-lib/esm-chunks/{chunk-6MNE57DC.mjs → chunk-XONCLAVA.mjs} +8 -7
  50. package/dist-lib/esm-chunks/{chunk-EI7CZDMR.mjs → chunk-YOD53JTM.mjs} +2 -2
  51. package/dist-lib/esm-chunks/{metro-layout-parser-OHVROLNJ.mjs → metro-layout-parser-MDVTDJ65.mjs} +3 -3
  52. package/dist-lib/esm-chunks/{swift-package-prebuilt-DRAUK6KR.mjs → swift-package-prebuilt-ZN7I4FYC.mjs} +12 -12
  53. package/dist-lib/esm-chunks/{swift-sdk-app-module-U2M7CMKA.mjs → swift-sdk-app-module-DUVE2OXH.mjs} +107 -20
  54. package/dist-lib/esm-chunks/{swift-sdk-image-ZHWSHCNI.mjs → swift-sdk-image-YSWQBCYV.mjs} +16 -16
  55. package/dist-lib/esm-chunks/{swift-sdk-image-producer-EOJUCK7N.mjs → swift-sdk-image-producer-MZ235WSK.mjs} +5 -5
  56. package/dist-lib/expo-swift-bundle.cjs +686 -299
  57. package/dist-lib/expo-swift-metadata.cjs +1 -1
  58. package/dist-lib/expo-swift-metadata.mjs +7 -7
  59. package/dist-lib/home-paths.cjs +1 -1
  60. package/dist-lib/host/bridge-host.cjs +691 -304
  61. package/dist-lib/host/fetch-proxy-handler.cjs +7 -7
  62. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  63. package/dist-lib/host/fetch-proxy-overrides.mjs +2 -2
  64. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  65. package/dist-lib/host/websocket-proxy.cjs +1 -1
  66. package/dist-lib/index.cjs +1 -1
  67. package/dist-lib/kotlin-host.cjs +1 -1
  68. package/dist-lib/menu.cjs +1 -1
  69. package/dist-lib/menu.mjs +3 -3
  70. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  71. package/dist-lib/metro-fingerprint-registry.mjs +3 -3
  72. package/dist-lib/metro-production-bundle.cjs +1 -1
  73. package/dist-lib/metro-production-bundle.mjs +4 -4
  74. package/dist-lib/native-app-identity-project.cjs +30 -15
  75. package/dist-lib/native-app-identity-project.mjs +44 -29
  76. package/dist-lib/native-app-identity.cjs +1 -1
  77. package/dist-lib/native-app-identity.mjs +6 -6
  78. package/dist-lib/native-firebase-metadata.cjs +1 -1
  79. package/dist-lib/native-firebase-metadata.mjs +3 -3
  80. package/dist-lib/pdfium-raster.cjs +1 -1
  81. package/dist-lib/pdfium-raster.mjs +2 -2
  82. package/dist-lib/plist.cjs +1 -1
  83. package/dist-lib/plist.mjs +3 -3
  84. package/dist-lib/profiles.cjs +1 -1
  85. package/dist-lib/public-brand.cjs +1 -1
  86. package/dist-lib/public-origins-lib-esm.json +85 -85
  87. package/dist-lib/public-origins-lib.json +64 -64
  88. package/dist-lib/react-native-host-modules.cjs +1 -1
  89. package/dist-lib/react-native-host-modules.mjs +2 -2
  90. package/dist-lib/reap-browser.cjs +1 -1
  91. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  92. package/dist-lib/sdk.cjs +1 -1
  93. package/dist-lib/sdk.mjs +8 -8
  94. package/dist-lib/skills.cjs +691 -304
  95. package/dist-lib/swift-compile.cjs +638 -280
  96. package/dist-lib/swift-compile.mjs +12 -12
  97. package/dist-lib/swift-package.cjs +1 -1
  98. package/dist-lib/swift-package.mjs +3 -3
  99. package/dist-lib/swift-submit.cjs +1 -1
  100. package/dist-lib/swift-submit.mjs +6 -6
  101. package/dist-lib/swift-svg-raster.cjs +1 -1
  102. package/dist-lib/swift-svg-raster.mjs +2 -2
  103. package/dist-lib/swift-toolchain.cjs +1 -1
  104. package/dist-lib/swift.cjs +1 -1
  105. package/dist-lib/vendor/@peculiar/x509.cjs +1 -1
  106. package/dist-lib/vendor/@ruby/prism/src/nodes.js.cjs +1 -1
  107. package/dist-lib/vendor/@ruby/prism/src/parsePrism.js.cjs +1 -1
  108. package/dist-lib/vendor/acorn.cjs +1 -1
  109. package/dist-lib/vendor/magic-string.cjs +1 -1
  110. package/dist-lib/vendor/stream-json.cjs +1 -1
  111. package/dist-lib/vendor/sucrase/dist/index.js.cjs +1 -1
  112. package/dist-lib/vendor/sucrase/dist/parser/index.js.cjs +1 -1
  113. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/index.js.cjs +1 -1
  114. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/types.js.cjs +1 -1
  115. package/dist-lib/vendor/sucrase.cjs +1 -1
  116. package/dist-lib/vendor/terser.cjs +1 -1
  117. package/dist-lib/vendor/valibot.cjs +1 -1
  118. package/dist-lib/vendor/ws.cjs +1 -1
  119. package/dist-lib/vendor/zod.cjs +1 -1
  120. package/dist-lib/worklet-executable.cjs +1 -1
  121. package/dist-lib/worklet-executable.mjs +3 -3
  122. package/package.json +1 -1
  123. package/src/bazel-project.ts +34 -18
  124. package/src/binaryen.lock.json +3 -3
  125. package/src/swift-compile.ts +8 -0
  126. package/src/swift-guest-compile.ts +170 -160
  127. package/src/swift-guest-dyld-table.ts +22 -9
  128. package/src/swift-guest-link.ts +116 -42
  129. package/src/swift-guest-linked-spans.ts +63 -14
  130. package/src/swift-guest-projection-storage.ts +7 -6
  131. package/src/swift-guest-source-inputs.ts +35 -21
  132. package/src/swift-objc-compile.ts +1 -0
  133. package/src/swift-sdk-app-module.ts +118 -15
  134. package/src/swift-sdk-image-wasm.ts +119 -17
  135. package/src/swift-sdk-image.ts +4 -1
  136. package/src/swift-wasm-prune.ts +71 -41
  137. package/src/wasm-narrow-boundary.ts +31 -6
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2623 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2624 | (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;
@@ -6000,13 +6000,13 @@ var init_swift_standin_digest = __esm({
6000
6000
  ];
6001
6001
  RUNTIME_IMPORT = /(?:^|[;\n])[ \t]*(?:import|export)\s+(?!type(?:\s|\{))([\s\S]*?)\s+from\s*['"]([^'"]+)['"]|(?:^|[;\n])[ \t]*import\s+['"]([^'"]+)['"]|import\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
6002
6002
  standinSourceDigest = (srcDir = __sootsim_import_meta_dirname) => sourceClosureDigest(srcDir, STANDIN_DIGEST_ENTRYPOINTS, STANDIN_DIGEST_EXCLUDED_FILES);
6003
- STANDIN_SOURCE_DIGEST = true ? "434280be603d7288671556bd3927e00632cd94beab9d58010000add5587f959b" : standinSourceDigest();
6003
+ STANDIN_SOURCE_DIGEST = true ? "7f9a1a548c5ea58c56b73bfc2a755a05031acbd1b10c1c79dc32b1d6c9bea9e4" : standinSourceDigest();
6004
6004
  }
6005
6005
  });
6006
6006
 
6007
6007
  // src/expo-native-compiler-digest.ts
6008
6008
  function expoNativeCompilerDigestValue() {
6009
- return true ? "9a5ff08be82d73a20a55678e521c09380974dc2204df641f1bd49dc8c06f1f83" : expoNativeCompilerDigest(__sootsim_import_meta_dirname);
6009
+ return true ? "ee97927d0c41fd6dd7d1290da2bbe36d7c9ec0fe81e3d5a7aa101cd4d446e5ab" : expoNativeCompilerDigest(__sootsim_import_meta_dirname);
6010
6010
  }
6011
6011
  var import_node_crypto11;
6012
6012
  var init_expo_native_compiler_digest = __esm({
@@ -28709,6 +28709,15 @@ function guestLinkedSpans(map2, before, after, owners, sectionOwners = /* @__PUR
28709
28709
  const unchanged = before === after;
28710
28710
  const original = layout(before, !unchanged, !importsLayout);
28711
28711
  const optimized = unchanged ? original : layout(after, true, !importsLayout);
28712
+ if (extra?.optimizedDataSegments) {
28713
+ for (const segment2 of optimized.data) {
28714
+ extra.optimizedDataSegments.push({
28715
+ address: segment2.address,
28716
+ offset: segment2.bytes.byteOffset - after.byteOffset,
28717
+ length: segment2.bytes.length
28718
+ });
28719
+ }
28720
+ }
28712
28721
  const collectSymbols = extra?.collectSymbols;
28713
28722
  const trackedObject = extra?.trackedObject;
28714
28723
  const trackedObjectOwner = extra?.trackedObjectOwner;
@@ -28877,12 +28886,39 @@ function guestLinkedSpans(map2, before, after, owners, sectionOwners = /* @__PUR
28877
28886
  }
28878
28887
  return result;
28879
28888
  };
28889
+ const singleSegmentSlice = (module2, start, length) => {
28890
+ const segs = module2.dataByAddress;
28891
+ let low = 0;
28892
+ let high = segs.length;
28893
+ while (low < high) {
28894
+ const middle = low + high >> 1;
28895
+ if (segs[middle].maximumEnd <= start) low = middle + 1;
28896
+ else high = middle;
28897
+ }
28898
+ let found2;
28899
+ const end = start + length;
28900
+ for (let index = low; index < segs.length; index++) {
28901
+ const segment2 = segs[index];
28902
+ if (segment2.address >= end) break;
28903
+ if (segment2.address + segment2.bytes.length > start) {
28904
+ if (found2) return void 0;
28905
+ found2 = segment2;
28906
+ }
28907
+ }
28908
+ if (!found2 || found2.address > start || found2.address + found2.bytes.length < end)
28909
+ return void 0;
28910
+ return found2.bytes.subarray(start - found2.address, end - found2.address);
28911
+ };
28912
+ const sameDataAt = (start, length) => {
28913
+ const origSlice = singleSegmentSlice(original, start, length);
28914
+ const optSlice = origSlice ? singleSegmentSlice(optimized, start, length) : void 0;
28915
+ if (origSlice && optSlice) return Buffer.compare(origSlice, optSlice) === 0;
28916
+ return dataAt(original, start, length).equals(dataAt(optimized, start, length));
28917
+ };
28880
28918
  for (const span of spans) {
28881
28919
  if (span.address + span.length > original.memoryBytes || span.address + span.length > optimized.memoryBytes)
28882
28920
  throw new Error(`linked data lies outside guest memory at ${span.address}`);
28883
- if (!unchanged && !dataAt(original, span.address, span.length).equals(
28884
- dataAt(optimized, span.address, span.length)
28885
- ))
28921
+ if (!unchanged && !sameDataAt(span.address, span.length))
28886
28922
  throw new Error(`optimization changed linked data at ${span.address}`);
28887
28923
  }
28888
28924
  let previous;
@@ -29016,7 +29052,7 @@ function takeGuestStartupData(wasm, address, length) {
29016
29052
  const bytes = new Uint8Array(length);
29017
29053
  const emptied = /* @__PURE__ */ new Set();
29018
29054
  let covered = 0;
29019
- const result = Buffer.from(wasm);
29055
+ const patchedBody = Buffer.from(wasm.subarray(body[0], body[1]));
29020
29056
  for (const initializer of startupDataInitializers(wasm.subarray(...body))) {
29021
29057
  const end = initializer.address + initializer.length;
29022
29058
  if (end <= address || initializer.address >= address + length || !initializer.length)
@@ -29031,19 +29067,18 @@ function takeGuestStartupData(wasm, address, length) {
29031
29067
  covered += segment2.length;
29032
29068
  emptied.add(initializer.segment);
29033
29069
  const [at, immediateEnd] = initializer.lengthImmediate;
29034
- result.fill(128, body[0] + at, body[0] + immediateEnd - 1);
29035
- result[body[0] + immediateEnd - 1] = 0;
29070
+ patchedBody.fill(128, at, immediateEnd - 1);
29071
+ patchedBody[immediateEnd - 1] = 0;
29036
29072
  }
29037
29073
  if (covered !== length)
29038
29074
  throw new Error("guest startup data does not initialize the whole range");
29039
- const parts2 = [result.subarray(0, data[0])];
29040
- const payload = [result.subarray(data[1], segments[0].header)];
29075
+ const payload = [wasm.subarray(data[1], segments[0].header)];
29041
29076
  for (const [index, segment2] of segments.entries()) {
29042
29077
  if (!emptied.has(index)) {
29043
- payload.push(result.subarray(segment2.header, segment2.payload + segment2.length));
29078
+ payload.push(wasm.subarray(segment2.header, segment2.payload + segment2.length));
29044
29079
  continue;
29045
29080
  }
29046
- payload.push(result.subarray(segment2.header, segment2.sizeAt), Uint8Array.of(0));
29081
+ payload.push(wasm.subarray(segment2.header, segment2.sizeAt), Uint8Array.of(0));
29047
29082
  }
29048
29083
  const section2 = Buffer.concat(payload);
29049
29084
  const size2 = [];
@@ -29054,7 +29089,14 @@ function takeGuestStartupData(wasm, address, length) {
29054
29089
  }
29055
29090
  size2.push(rest % 128 | 128);
29056
29091
  }
29057
- parts2.push(Uint8Array.of(11, ...size2), section2, result.subarray(data[2]));
29092
+ const parts2 = [
29093
+ wasm.subarray(0, body[0]),
29094
+ patchedBody,
29095
+ wasm.subarray(body[1], data[0]),
29096
+ Uint8Array.of(11, ...size2),
29097
+ section2,
29098
+ wasm.subarray(data[2])
29099
+ ];
29058
29100
  return { wasm: Buffer.concat(parts2), bytes };
29059
29101
  }
29060
29102
  var import_node_fs55, import_node_string_decoder, constant;
@@ -29363,6 +29405,32 @@ function readImports(bytes, imports2) {
29363
29405
  }
29364
29406
  return { functionTypes, importedGlobals, memoryPages };
29365
29407
  }
29408
+ function countImportedFunctions(bytes, imports2) {
29409
+ let count = 0;
29410
+ if (!imports2) return count;
29411
+ const r = wasmReader(bytes, imports2.start);
29412
+ for (let n = r.u(); n > 0; n--) {
29413
+ r.skip(r.u());
29414
+ r.skip(r.u());
29415
+ const kind = r.byte();
29416
+ if (kind === 0) {
29417
+ r.u();
29418
+ count++;
29419
+ } else if (kind === 1) {
29420
+ r.byte();
29421
+ skipLimits(r);
29422
+ } else if (kind === 2) {
29423
+ skipLimits(r);
29424
+ } else if (kind === 3) {
29425
+ r.byte();
29426
+ r.byte();
29427
+ } else if (kind === 4) {
29428
+ r.byte();
29429
+ r.u();
29430
+ } else throw new Error(`unknown wasm import kind ${kind}`);
29431
+ }
29432
+ return count;
29433
+ }
29366
29434
  function* readFunctionNames(bytes, names) {
29367
29435
  for (const r = wasmReader(bytes, names.start); r.at < names.end; ) {
29368
29436
  const id = r.byte();
@@ -29730,28 +29798,73 @@ function codeOnlySdkImage(bytes, constructorMask) {
29730
29798
  return Buffer.concat(out);
29731
29799
  }
29732
29800
  function constructorKeys(map2, bytes) {
29733
- const m = readModule(bytes);
29734
29801
  const first = map2.code[0];
29735
- if (!first || !m.bodies.length) throw new Error("link has no code");
29736
- const prefixes = m.bodies.map(({ prefix }) => prefix);
29737
- const delta = prefixes[0] - first.offset;
29738
- const byOffset = new Map(map2.code.map((chunk) => [chunk.offset + delta, chunk]));
29802
+ if (!first) throw new Error("link has no code");
29803
+ const sections = wasmSections(bytes);
29804
+ const code = sections.find((s) => s.id === 10);
29805
+ if (!code) throw new Error("link has no code");
29739
29806
  const ctors = map2.code.find((chunk) => chunk.section === "__wasm_call_ctors");
29740
29807
  if (!ctors) throw new Error("link has no constructors");
29741
- const index = prefixes.indexOf(ctors.offset + delta);
29742
- if (index < 0) throw new Error("constructor function not found by map offset");
29743
- const body = m.bodies[index];
29744
- const r = wasmReader(bytes, body.start);
29808
+ const importedFuncs = countImportedFunctions(
29809
+ bytes,
29810
+ sections.find((s) => s.id === 2)
29811
+ );
29812
+ const codeReader = wasmReader(bytes, code.start);
29813
+ const bodyCount = codeReader.u();
29814
+ if (!bodyCount) throw new Error("link has no code");
29815
+ const prefixes = new Uint32Array(bodyCount);
29816
+ let delta = 0;
29817
+ let ctorPrefix = -1;
29818
+ let ctorStart = -1;
29819
+ let ctorEnd = -1;
29820
+ for (let i = 0; i < bodyCount; i++) {
29821
+ const prefix = codeReader.at;
29822
+ const size2 = codeReader.u();
29823
+ prefixes[i] = prefix;
29824
+ if (i === 0) {
29825
+ delta = prefix - first.offset;
29826
+ ctorPrefix = ctors.offset + delta;
29827
+ }
29828
+ if (prefix === ctorPrefix) {
29829
+ ctorStart = codeReader.at;
29830
+ ctorEnd = ctorStart + size2;
29831
+ }
29832
+ codeReader.skip(size2);
29833
+ }
29834
+ if (ctorStart < 0) throw new Error("constructor function not found by map offset");
29835
+ let sorted2 = true;
29836
+ for (let i = 1; i < map2.code.length; i++) {
29837
+ if (map2.code[i].offset < map2.code[i - 1].offset) {
29838
+ sorted2 = false;
29839
+ break;
29840
+ }
29841
+ }
29842
+ const byOffset = sorted2 ? void 0 : new Map(map2.code.map((chunk) => [chunk.offset + delta, chunk]));
29843
+ const findChunk = (targetPrefix) => {
29844
+ if (byOffset) return byOffset.get(targetPrefix);
29845
+ const targetOffset = targetPrefix - delta;
29846
+ let lo = 0;
29847
+ let hi = map2.code.length - 1;
29848
+ while (lo <= hi) {
29849
+ const mid = lo + hi >> 1;
29850
+ const offset = map2.code[mid].offset;
29851
+ if (offset < targetOffset) lo = mid + 1;
29852
+ else if (offset > targetOffset) hi = mid - 1;
29853
+ else return map2.code[mid];
29854
+ }
29855
+ return void 0;
29856
+ };
29857
+ const r = wasmReader(bytes, ctorStart);
29745
29858
  for (let n = r.u(); n > 0; n--) {
29746
29859
  r.u();
29747
29860
  r.byte();
29748
29861
  }
29749
29862
  const keys = [];
29750
- while (r.at < body.end) {
29863
+ while (r.at < ctorEnd) {
29751
29864
  const op = r.byte();
29752
29865
  if (op === 16) {
29753
- const callee = r.u() - m.importedFuncs;
29754
- const chunk = byOffset.get(prefixes[callee]);
29866
+ const callee = r.u() - importedFuncs;
29867
+ const chunk = callee >= 0 && callee < bodyCount ? findChunk(prefixes[callee]) : void 0;
29755
29868
  if (!chunk) throw new Error("constructor without a map chunk");
29756
29869
  keys.push(chunkKey(chunk, ""));
29757
29870
  } else if (op !== 26 && op !== 11) throw new Error(`constructor op ${op}`);
@@ -29834,7 +29947,10 @@ function relocationEdges(bytes, segmentAddress) {
29834
29947
  r.skip(r.u());
29835
29948
  }
29836
29949
  }
29837
- const importedFunctions = readModule(bytes).importedFuncs;
29950
+ const importedFunctions = countImportedFunctions(
29951
+ bytes,
29952
+ sections.find((s) => s.id === 2)
29953
+ );
29838
29954
  const data = [];
29839
29955
  const dataFunctions = [];
29840
29956
  const bodyCount = bodyStarts.length;
@@ -29948,9 +30064,30 @@ function strongDefinitions(bytes) {
29948
30064
  ).map((s) => s.name);
29949
30065
  }
29950
30066
  function unslottedFunctions(bytes) {
29951
- const m = readModule(bytes);
29952
- const slotted = new Set([...m.slots.keys()].filter((index) => index >= m.importedFuncs));
29953
- return m.bodies.length - slotted.size;
30067
+ const sections = wasmSections(bytes);
30068
+ const importedFuncs = countImportedFunctions(
30069
+ bytes,
30070
+ sections.find((s) => s.id === 2)
30071
+ );
30072
+ const code = sections.find((s) => s.id === 10);
30073
+ const definedFuncs = code ? wasmReader(bytes, code.start).u() : 0;
30074
+ const slotted = /* @__PURE__ */ new Set();
30075
+ const elements = sections.find((s) => s.id === 9);
30076
+ if (elements) {
30077
+ const r = wasmReader(bytes, elements.start);
30078
+ for (let n = r.u(); n > 0; n--) {
30079
+ const flags = r.u();
30080
+ if (flags !== 0 && flags !== 2) throw new Error(`sdk image element flags ${flags}`);
30081
+ if (flags === 2) r.u();
30082
+ constant2(r);
30083
+ if (flags === 2) r.byte();
30084
+ for (let i = 0, count = r.u(); i < count; i++) {
30085
+ const index = r.u();
30086
+ if (index >= importedFuncs) slotted.add(index);
30087
+ }
30088
+ }
30089
+ }
30090
+ return definedFuncs - slotted.size;
29954
30091
  }
29955
30092
  var uleb, sleb, encodedName, section, PROCESS_EXPORTS, SWIFT_SDK_CONSTRUCTOR_LIMIT, FUNCTION_RELOCATIONS, MEMORY_RELOCATIONS, ADDEND_RELOCATIONS, FUNCTION_RELOC_MASK, MEMORY_RELOC_MASK, ADDEND_RELOC_MASK;
29956
30093
  var init_swift_sdk_image_wasm = __esm({
@@ -30334,6 +30471,11 @@ var init_swiftRuntimeProductContract = __esm({
30334
30471
  });
30335
30472
 
30336
30473
  // src/swift-wasm-prune.ts
30474
+ function sha256Hex(bytes) {
30475
+ if (typeof Bun !== "undefined")
30476
+ return new Bun.CryptoHasher("sha256").update(bytes).digest("hex");
30477
+ return (0, import_node_crypto29.createHash)("sha256").update(bytes).digest("hex");
30478
+ }
30337
30479
  function readULEB2(b, o) {
30338
30480
  let res = 0;
30339
30481
  let shift = 0;
@@ -31086,6 +31228,42 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
31086
31228
  }
31087
31229
  }
31088
31230
  }
31231
+ const segObjCClasses = /* @__PURE__ */ new Map();
31232
+ for (let segIdx = 0; segIdx < sEnds.length; segIdx++) {
31233
+ const rangeStart = dataStart + sPayloadStarts[segIdx];
31234
+ const rangeEnd = dataStart + sEnds[segIdx];
31235
+ const sliceLen = rangeEnd - rangeStart;
31236
+ if (sliceLen < 4) continue;
31237
+ const slice = Buffer.from(rawBuf.buffer, rawBuf.byteOffset + rangeStart, sliceLen);
31238
+ let segPos = 0;
31239
+ let classes;
31240
+ while (segPos < sliceLen - 3) {
31241
+ const at = slice.indexOf("So", segPos);
31242
+ if (at < 0 || at >= sliceLen - 2) break;
31243
+ let digitEnd = at + 2;
31244
+ let length = 0;
31245
+ while (digitEnd < sliceLen) {
31246
+ const ch = slice[digitEnd];
31247
+ if (ch < 48 || ch > 57) break;
31248
+ length = length * 10 + (ch - 48);
31249
+ digitEnd++;
31250
+ }
31251
+ if (digitEnd === at + 2) {
31252
+ segPos = at + 2;
31253
+ continue;
31254
+ }
31255
+ segPos = digitEnd;
31256
+ const nameEnd = digitEnd + length;
31257
+ if (nameEnd >= sliceLen || slice[nameEnd] !== 67) continue;
31258
+ const symbol2 = `._OBJC_CLASS_${slice.toString("latin1", digitEnd, nameEnd)}`;
31259
+ if (!classes) {
31260
+ classes = [symbol2];
31261
+ segObjCClasses.set(segIdx, classes);
31262
+ } else if (!classes.includes(symbol2)) {
31263
+ classes.push(symbol2);
31264
+ }
31265
+ }
31266
+ }
31089
31267
  return {
31090
31268
  file,
31091
31269
  isDist,
@@ -31115,10 +31293,7 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
31115
31293
  objcCategoryTargets,
31116
31294
  rootFuncs,
31117
31295
  rootSegs,
31118
- segPayloadRanges: sEnds.map((end, i) => [
31119
- dataStart + sPayloadStarts[i],
31120
- dataStart + end
31121
- ])
31296
+ segObjCClasses
31122
31297
  };
31123
31298
  }
31124
31299
  function parseWasmObjectFile(file, isDist) {
@@ -31486,16 +31661,26 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
31486
31661
  transformations.set(file, {
31487
31662
  output,
31488
31663
  inputSha256,
31489
- outputSha256: (0, import_node_crypto29.createHash)("sha256").update(result).digest("hex"),
31664
+ outputSha256: sha256Hex(result),
31490
31665
  kind
31491
31666
  });
31492
31667
  };
31493
31668
  const distFiles = [];
31494
31669
  const distBaseNames = /* @__PURE__ */ new Set();
31495
31670
  const eagerFiles = [];
31671
+ const parsedBuildObjects = /* @__PURE__ */ new Map();
31496
31672
  const lazyBuildObjects = /* @__PURE__ */ new Map();
31497
31673
  const extraArchiveObjs = [];
31498
31674
  const objectBytes = /* @__PURE__ */ new Map();
31675
+ const archiveMembers = /* @__PURE__ */ new Map();
31676
+ const readArchiveMembers = (archive) => {
31677
+ let members2 = archiveMembers.get(archive);
31678
+ if (!members2) {
31679
+ members2 = readArMembers(new Uint8Array(import_node_fs56.default.readFileSync(archive)));
31680
+ archiveMembers.set(archive, members2);
31681
+ }
31682
+ return members2;
31683
+ };
31499
31684
  let inStartLib = false;
31500
31685
  let swiftrtOrigPath = "";
31501
31686
  for (const t of tokens2) {
@@ -31532,8 +31717,10 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
31532
31717
  break;
31533
31718
  }
31534
31719
  }
31535
- if (definesObjCClassOrCategory) eagerFiles.push(t);
31536
- else lazyBuildObjects.set(t, obj);
31720
+ if (definesObjCClassOrCategory) {
31721
+ parsedBuildObjects.set(t, obj);
31722
+ eagerFiles.push(t);
31723
+ } else lazyBuildObjects.set(t, obj);
31537
31724
  } else {
31538
31725
  eagerFiles.push(t);
31539
31726
  }
@@ -31541,7 +31728,7 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
31541
31728
  lazyBuildObjects.set(t, parseWasmObjectFile(t, false));
31542
31729
  }
31543
31730
  } else if (!inStartLib && t.endsWith(".a") && !t.endsWith("libclang_rt.builtins-wasm64.a") && import_node_fs56.default.existsSync(t)) {
31544
- const members2 = readArMembers(new Uint8Array(import_node_fs56.default.readFileSync(t)));
31731
+ const members2 = readArchiveMembers(t);
31545
31732
  for (const m of members2) {
31546
31733
  const object9 = parseWasmObjectBytes(`${t}(${m.name})`, m.bytes, false);
31547
31734
  extraArchiveObjs.push(object9);
@@ -31564,7 +31751,7 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
31564
31751
  );
31565
31752
  const archiveOverlapsDist = (archive) => {
31566
31753
  if (!import_node_fs56.default.existsSync(archive)) return false;
31567
- const members2 = readArMembers(new Uint8Array(import_node_fs56.default.readFileSync(archive)));
31754
+ const members2 = readArchiveMembers(archive);
31568
31755
  return members2.some((m) => distBaseNames.has(m.name));
31569
31756
  };
31570
31757
  for (const t of tokens2) {
@@ -31586,7 +31773,7 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
31586
31773
  import_node_path57.default.basename(archive)
31587
31774
  );
31588
31775
  const ordinals = /* @__PURE__ */ new Map();
31589
- for (const m of readArMembers(new Uint8Array(import_node_fs56.default.readFileSync(archive)))) {
31776
+ for (const m of readArchiveMembers(archive)) {
31590
31777
  const ordinal = (ordinals.get(m.name) ?? 0) + 1;
31591
31778
  ordinals.set(m.name, ordinal);
31592
31779
  if (distBaseNames.has(m.name) || writtenLeftovers.has(m.name)) continue;
@@ -31620,7 +31807,7 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
31620
31807
  recordTransformation(
31621
31808
  swiftrtOrigPath,
31622
31809
  patchedSwiftrtPath,
31623
- link ? (0, import_node_crypto29.createHash)("sha256").update(input).digest("hex") : "",
31810
+ link ? sha256Hex(input) : "",
31624
31811
  result,
31625
31812
  "swiftrt"
31626
31813
  );
@@ -32107,7 +32294,7 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
32107
32294
  }
32108
32295
  for (const f of eagerFiles) {
32109
32296
  const isDist = f.startsWith(distDir);
32110
- const obj = distObjs.get(f) ?? parseWasmObjectFile(f, isDist);
32297
+ const obj = distObjs.get(f) ?? parsedBuildObjects.get(f) ?? parseWasmObjectFile(f, isDist);
32111
32298
  extractObject(obj);
32112
32299
  if (isDist) {
32113
32300
  const base2 = import_node_path57.default.basename(f);
@@ -32157,32 +32344,9 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
32157
32344
  "$s10Foundation6BundleC22preferredLocalizations4fromSaySSGAF_tFZTf4nd_n"
32158
32345
  ]);
32159
32346
  const keepObjCClassesNamedInSegment = (obj, segIdx) => {
32160
- const range3 = obj.segPayloadRanges[segIdx];
32161
- if (!range3) return;
32162
- const [rangeStart, rangeEnd] = range3;
32163
- if (rangeEnd - rangeStart < 4) return;
32164
- let bytes = objectBytes.get(obj);
32165
- if (!bytes) objectBytes.set(obj, bytes = import_node_fs56.default.readFileSync(obj.file));
32166
- let pos = rangeStart;
32167
- while (pos < rangeEnd - 3) {
32168
- const at = bytes.indexOf("So", pos);
32169
- if (at < 0 || at >= rangeEnd - 2) break;
32170
- let digitEnd = at + 2;
32171
- let length = 0;
32172
- while (digitEnd < rangeEnd) {
32173
- const ch = bytes[digitEnd];
32174
- if (ch < 48 || ch > 57) break;
32175
- length = length * 10 + (ch - 48);
32176
- digitEnd++;
32177
- }
32178
- if (digitEnd === at + 2) {
32179
- pos = at + 2;
32180
- continue;
32181
- }
32182
- pos = digitEnd;
32183
- const nameEnd = digitEnd + length;
32184
- if (nameEnd >= rangeEnd || bytes[nameEnd] !== 67) continue;
32185
- const symbol2 = `._OBJC_CLASS_${bytes.toString("latin1", digitEnd, nameEnd)}`;
32347
+ const symbols = obj.segObjCClasses.get(segIdx);
32348
+ if (!symbols) return;
32349
+ for (const symbol2 of symbols) {
32186
32350
  for (const provider of lazyProviders.get(symbol2) ?? []) {
32187
32351
  eagerDynamicObjects.add(provider);
32188
32352
  extractObject(provider);
@@ -32278,7 +32442,7 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
32278
32442
  const cached4 = objectBytes.get(obj);
32279
32443
  const buf = cached4 ? new Uint8Array(cached4) : new Uint8Array(import_node_fs56.default.readFileSync(obj.file));
32280
32444
  const rawBuf = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
32281
- const inputSha256 = link ? (0, import_node_crypto29.createHash)("sha256").update(buf).digest("hex") : "";
32445
+ const inputSha256 = link ? sha256Hex(buf) : "";
32282
32446
  const fLive = liveFuncs.get(obj);
32283
32447
  const sLive = liveSegs.get(obj);
32284
32448
  const dLive = liveDataSyms.get(obj);
@@ -34657,13 +34821,34 @@ function dropWasmCustomSection(bytes, name3) {
34657
34821
  }
34658
34822
  return Buffer.concat(parts2);
34659
34823
  }
34824
+ function writeWasmCustomSections(bytes, entries2) {
34825
+ if (entries2.length === 0) return Buffer.concat([bytes]);
34826
+ const replaced = new Set(entries2.map(([name3]) => name3));
34827
+ const parts2 = [];
34828
+ let sliceStart = 0;
34829
+ let sliceEnd = 8;
34830
+ for (const { id, start, end } of wasmSections2(bytes)) {
34831
+ if (id === 0 && replaced.has(readWasmSection(bytes, start, end).name())) {
34832
+ if (sliceEnd > sliceStart) parts2.push(bytes.subarray(sliceStart, sliceEnd));
34833
+ sliceStart = end;
34834
+ sliceEnd = end;
34835
+ } else {
34836
+ sliceEnd = end;
34837
+ }
34838
+ }
34839
+ if (sliceEnd > sliceStart) parts2.push(bytes.subarray(sliceStart, sliceEnd));
34840
+ for (const [name3, data] of entries2) {
34841
+ const nameBytes = Buffer.from(encodeWasmName(name3));
34842
+ parts2.push(
34843
+ Buffer.from([0, ...encodeWasmNumber(nameBytes.length + data.length)]),
34844
+ nameBytes,
34845
+ data
34846
+ );
34847
+ }
34848
+ return Buffer.concat(parts2);
34849
+ }
34660
34850
  function writeWasmCustomSection(bytes, name3, data) {
34661
- const section2 = Buffer.concat([Buffer.from(encodeWasmName(name3)), data]);
34662
- return Buffer.concat([
34663
- dropWasmCustomSection(bytes, name3),
34664
- Buffer.from([0, ...encodeWasmNumber(section2.length)]),
34665
- section2
34666
- ]);
34851
+ return writeWasmCustomSections(bytes, [[name3, data]]);
34667
34852
  }
34668
34853
  function readWasmFunctionNames(bytes) {
34669
34854
  const section2 = readWasmCustomSection(bytes, "name");
@@ -35093,6 +35278,16 @@ var init_wasm_narrow_boundary = __esm({
35093
35278
  });
35094
35279
 
35095
35280
  // src/swift-guest-dyld-table.ts
35281
+ function sha256Buffer(bytes) {
35282
+ if (typeof Bun !== "undefined")
35283
+ return Buffer.from(new Bun.CryptoHasher("sha256").update(bytes).digest());
35284
+ return (0, import_node_crypto32.createHash)("sha256").update(bytes).digest();
35285
+ }
35286
+ function sha256Hex2(bytes) {
35287
+ if (typeof Bun !== "undefined")
35288
+ return new Bun.CryptoHasher("sha256").update(bytes).digest("hex");
35289
+ return (0, import_node_crypto32.createHash)("sha256").update(bytes).digest("hex");
35290
+ }
35096
35291
  function uleb3(value) {
35097
35292
  const bytes = [];
35098
35293
  for (let rest = value; ; rest = Math.floor(rest / 128)) {
@@ -35127,7 +35322,7 @@ function encodeGuestDyldTable(rows) {
35127
35322
  }
35128
35323
  const file = Buffer.concat(packs);
35129
35324
  const header = Buffer.alloc(40 + packs.length * 8);
35130
- (0, import_node_crypto32.createHash)("sha256").update(file).digest().copy(header, 0);
35325
+ sha256Buffer(file).copy(header, 0);
35131
35326
  header.writeUInt32LE(file.length, 32);
35132
35327
  header.writeUInt32LE(packs.length, 36);
35133
35328
  let offset = 0;
@@ -35139,11 +35334,11 @@ function encodeGuestDyldTable(rows) {
35139
35334
  const names = firsts.flatMap((name3) => [name3, Buffer.of(0)]);
35140
35335
  return { index: Buffer.concat([header, ...names]), packs: file };
35141
35336
  }
35142
- function moveGuestDyldTable(map2, wasm, symbols, bindingValues = /* @__PURE__ */ new Map()) {
35337
+ function moveGuestDyldTable(map2, wasm, symbols, bindingValues = /* @__PURE__ */ new Map(), extraSections = []) {
35143
35338
  const range3 = guestDyldValueRange(map2);
35144
35339
  if (!range3) {
35145
35340
  if (symbols.length) throw new Error("link map has no dyld values");
35146
- return wasm;
35341
+ return extraSections.length ? writeWasmCustomSections(wasm, extraSections) : wasm;
35147
35342
  }
35148
35343
  if (range3.length !== symbols.length * 8)
35149
35344
  throw new Error("linked dyld values do not match the ledger rows");
@@ -35158,11 +35353,11 @@ function moveGuestDyldTable(map2, wasm, symbols, bindingValues = /* @__PURE__ */
35158
35353
  return binding === void 0 ? { name: name3, image, kind: 0, value: view.getBigUint64(index2 * 8, true) } : { name: name3, image, kind: 1, value: BigInt(binding) };
35159
35354
  });
35160
35355
  const { index, packs } = encodeGuestDyldTable(rows);
35161
- return writeWasmCustomSection(
35162
- writeWasmCustomSection(taken.wasm, NATIVE_DYLD_TABLE_SECTION, index),
35163
- NATIVE_DYLD_PACKS_SECTION,
35164
- packs
35165
- );
35356
+ return writeWasmCustomSections(taken.wasm, [
35357
+ [NATIVE_DYLD_TABLE_SECTION, index],
35358
+ [NATIVE_DYLD_PACKS_SECTION, packs],
35359
+ ...extraSections
35360
+ ]);
35166
35361
  }
35167
35362
  function guestDyldValueRange(map2) {
35168
35363
  const suffix = `:(${GUEST_DYLD_VALUES_SECTION})`;
@@ -35191,7 +35386,7 @@ function splitSwiftDyldTable(wasm) {
35191
35386
  const bytes = Buffer.from(packs);
35192
35387
  return {
35193
35388
  module: dropWasmCustomSection(wasm, NATIVE_DYLD_PACKS_SECTION),
35194
- table: { sha256: (0, import_node_crypto32.createHash)("sha256").update(bytes).digest("hex"), bytes }
35389
+ table: { sha256: sha256Hex2(bytes), bytes }
35195
35390
  };
35196
35391
  }
35197
35392
  var import_node_crypto32, import_node_zlib4, PACK_BYTES;
@@ -35727,6 +35922,7 @@ function finalizeGuestProjectionStorage(options2) {
35727
35922
  const owner = options2.owners.get(options2.projectionObject);
35728
35923
  if (owner === void 0) throw new Error("guest projection object has no image owner");
35729
35924
  const ranges = [];
35925
+ const data = [];
35730
35926
  const spans = guestLinkedSpans(
35731
35927
  options2.map,
35732
35928
  options2.linked,
@@ -35737,7 +35933,8 @@ function finalizeGuestProjectionStorage(options2) {
35737
35933
  {
35738
35934
  trackedObject: options2.projectionObject,
35739
35935
  trackedObjectOwner: owner,
35740
- trackedLinearSpans: ranges
35936
+ trackedLinearSpans: ranges,
35937
+ optimizedDataSegments: data
35741
35938
  }
35742
35939
  );
35743
35940
  const images = planGuestProjectionRegions(
@@ -35746,7 +35943,6 @@ function finalizeGuestProjectionStorage(options2) {
35746
35943
  options2.sdkSpans ? [...spans, ...options2.sdkSpans] : spans
35747
35944
  );
35748
35945
  const result = Buffer.from(options2.optimized);
35749
- const data = guestWasmDataSegments(options2.optimized, options2.sdkSpans === void 0);
35750
35946
  const locations = /* @__PURE__ */ new Map();
35751
35947
  const counts = /* @__PURE__ */ new Map();
35752
35948
  const uuids = /* @__PURE__ */ new Map();
@@ -36420,17 +36616,17 @@ var init_binaryen_lock = __esm({
36420
36616
  "linux-x64": {
36421
36617
  asset: "x86_64-linux",
36422
36618
  upstreamSha256: "195ddc94f9bc89f45abdabb0b9eea86023d727ba90eac8b35b80f2544fc30572",
36423
- sha256: "1024974f254c1c2edd738246ec6af5add16d3d36b5f58a94545febda3b33c869"
36619
+ sha256: "40062fb1ebbad7f04f361c1e3bb309dffb1d2318dd2e12235a0e7e820e18d6c9"
36424
36620
  },
36425
36621
  "linux-arm64": {
36426
36622
  asset: "aarch64-linux",
36427
36623
  upstreamSha256: "c58562417836c5d0493d89bdefc434933bdc097db641b483df86bcfa557a107f",
36428
- sha256: "7dedfc9f5cb32e75a28831f3b5aa053fd3e0bdd74f73dc4d1b1588947236daef"
36624
+ sha256: "d79b09d5b66f62f9e4bb691517b174b42bcdc0b7f40769d1993b7c565b0a54c7"
36429
36625
  },
36430
36626
  "darwin-arm64": {
36431
36627
  asset: "arm64-macos",
36432
36628
  upstreamSha256: "98aad827847af7ef990ed7098d885725c8e5b5aae75073403635617ae4e259aa",
36433
- sha256: "0b56e0a06b6a873877871537a120fd94e2121e67f4bce5f8b5252c47b615854a"
36629
+ sha256: "29342632a4fa52466c4feea846698fe5aa56ff46226a914d60b65b8735373d63"
36434
36630
  }
36435
36631
  }
36436
36632
  };
@@ -36924,6 +37120,7 @@ function outputPath(args) {
36924
37120
  }
36925
37121
  function withOutput(args, output, discovery) {
36926
37122
  const result = [];
37123
+ let stripsDebug = false;
36927
37124
  for (let i = 0; i < args.length; i++) {
36928
37125
  const arg = args[i];
36929
37126
  if (arg === "-o" || arg === "--output") {
@@ -36933,9 +37130,12 @@ function withOutput(args, output, discovery) {
36933
37130
  if (arg.startsWith("--output=")) continue;
36934
37131
  if (discovery && (arg.startsWith("--why-extract=") || arg.startsWith("--Map=")))
36935
37132
  continue;
37133
+ if (arg === "--strip-debug" || arg === "-S" || arg === "--strip-all" || arg === "-s")
37134
+ stripsDebug = true;
36936
37135
  result.push(arg);
36937
37136
  }
36938
37137
  if (discovery) result.push("--allow-multiple-definition");
37138
+ if (!stripsDebug) result.push("--strip-debug");
36939
37139
  result.push("-o", output);
36940
37140
  return result;
36941
37141
  }
@@ -36966,6 +37166,37 @@ async function linkGuestImages(options2) {
36966
37166
  }
36967
37167
  return import_node_fs61.default.readFileSync(trace, "utf8");
36968
37168
  };
37169
+ const runLinkAsync = async (name3, arguments_) => {
37170
+ const response = import_node_path61.default.join(directory2, `${name3}.rsp`);
37171
+ const trace = import_node_path61.default.join(directory2, `${name3}-inputs.txt`);
37172
+ import_node_fs61.default.writeFileSync(
37173
+ response,
37174
+ [...arguments_, "--trace"].map((argument2) => JSON.stringify(argument2)).join(" ")
37175
+ );
37176
+ const output = import_node_fs61.default.openSync(trace, "w");
37177
+ try {
37178
+ await new Promise((resolve11, reject) => {
37179
+ const child = (0, import_node_child_process28.spawn)(wasmLd, [`@${response}`], {
37180
+ stdio: ["ignore", output, "pipe"]
37181
+ });
37182
+ const stderr = [];
37183
+ child.stderr?.on("data", (chunk) => stderr.push(chunk));
37184
+ child.once("error", reject);
37185
+ child.once("close", (code, signal) => {
37186
+ if (code === 0) resolve11();
37187
+ else
37188
+ reject(
37189
+ new Error(
37190
+ `wasm-ld (${name3}) failed (${signal ?? code}): ${Buffer.concat(stderr).toString("utf8")}`
37191
+ )
37192
+ );
37193
+ });
37194
+ });
37195
+ } finally {
37196
+ import_node_fs61.default.closeSync(output);
37197
+ }
37198
+ return import_node_fs61.default.readFileSync(trace, "utf8");
37199
+ };
36969
37200
  const preselection = options2.projection && options2.preselectionDiscovery ? options2.preselectionDiscovery : void 0;
36970
37201
  let discoveryProjection;
36971
37202
  if (options2.projection) {
@@ -37195,6 +37426,7 @@ async function linkGuestImages(options2) {
37195
37426
  };
37196
37427
  const ledgerObjectPromise = compileLedgerAsync("ledger", ledger.llvmIR);
37197
37428
  const appLedgerObjectPromise = options2.onSplitInputs && ledger.appLLVMIR ? compileLedgerAsync("app-ledger", ledger.appLLVMIR) : void 0;
37429
+ let deferredFinalLink;
37198
37430
  try {
37199
37431
  const replacements = /* @__PURE__ */ new Map();
37200
37432
  const linkedOwners = /* @__PURE__ */ new Map();
@@ -37296,7 +37528,7 @@ async function linkGuestImages(options2) {
37296
37528
  });
37297
37529
  const finalOutput = import_node_path61.default.join(directory2, "final.wasm");
37298
37530
  const finalWhy = import_node_path61.default.join(directory2, "final-why-extract.txt");
37299
- const linkFinal = (projectionObject2, layoutMap) => runLink("final", [
37531
+ const finalLinkArgs = (projectionObject2, layoutMap) => [
37300
37532
  ...withOutput(finalArgs, finalOutput, false),
37301
37533
  ledgerObject,
37302
37534
  `@${lazyExports}`,
@@ -37304,10 +37536,38 @@ async function linkGuestImages(options2) {
37304
37536
  ...provider ? [`--undefined=${providerSymbol}`] : [],
37305
37537
  ...layoutMap ? [`--Map=${layoutMap}`] : [],
37306
37538
  `--why-extract=${finalWhy}`
37307
- ]);
37539
+ ];
37540
+ const linkFinal = (projectionObject2, layoutMap) => runLink("final", finalLinkArgs(projectionObject2, layoutMap));
37541
+ const finalizeFinalLink = (trace) => {
37542
+ const finalSelection = selectedGuestLinkInputs(
37543
+ remapGuestLinkPlan(plan, replacements),
37544
+ finalArgs,
37545
+ import_node_fs61.default.readFileSync(finalWhy, "utf8"),
37546
+ trace,
37547
+ finalArchives
37548
+ );
37549
+ const original = new Map(
37550
+ [...replacements].map(([before2, after2]) => [after2, before2])
37551
+ );
37552
+ const key2 = (item) => JSON.stringify([original.get(item.artifact) ?? item.artifact, item.member]);
37553
+ const before = new Set(selected.map(key2));
37554
+ const after = new Set(finalSelection.map(key2));
37555
+ const changed2 = [...before].filter((item) => !after.has(item));
37556
+ changed2.push(...[...after].filter((item) => !before.has(item)));
37557
+ if (changed2.length)
37558
+ throw new Error(
37559
+ `guest link selected different inputs after rewriting:
37560
+ ${changed2.join("\n")}`
37561
+ );
37562
+ import_node_fs61.default.renameSync(finalOutput, outputPath(args));
37563
+ if (KEEP_WASM_NAMES)
37564
+ import_node_fs61.default.writeFileSync(
37565
+ outputPath(args),
37566
+ nameGuestImageAliases(import_node_fs61.default.readFileSync(outputPath(args)), plan.symbols)
37567
+ );
37568
+ };
37308
37569
  let projectionObject;
37309
37570
  let projectionStorage;
37310
- let finalTrace;
37311
37571
  if (options2.projection) {
37312
37572
  const projection = options2.projection;
37313
37573
  if (!plan.images.some((image) => image.id === projection.image))
@@ -37360,8 +37620,18 @@ async function linkGuestImages(options2) {
37360
37620
  [...projection.clangOptions, "-c", projectionSource, "-o", projectionObject],
37361
37621
  { stdio: "pipe" }
37362
37622
  );
37363
- finalTrace = linkFinal(projectionObject, callerMap ? void 0 : layoutMap);
37364
- if (sharedSdk) break;
37623
+ if (sharedSdk && options2.onFinalLink && options2.onSplitInputs && appLedgerObjectPromise) {
37624
+ deferredFinalLink = runLinkAsync(
37625
+ "final",
37626
+ finalLinkArgs(projectionObject, callerMap ? void 0 : layoutMap)
37627
+ ).then((trace) => finalizeFinalLink(trace));
37628
+ break;
37629
+ }
37630
+ const finalTrace = linkFinal(projectionObject, callerMap ? void 0 : layoutMap);
37631
+ if (sharedSdk) {
37632
+ finalizeFinalLink(finalTrace);
37633
+ break;
37634
+ }
37365
37635
  const wasm = import_node_fs61.default.readFileSync(finalOutput);
37366
37636
  const actual = guestProjectionRegionCounts(
37367
37637
  images.length,
@@ -37373,38 +37643,17 @@ async function linkGuestImages(options2) {
37373
37643
  sectionOwners
37374
37644
  )
37375
37645
  );
37376
- if (actual.every((count, index) => count <= capacities[index].regions)) break;
37646
+ if (actual.every((count, index) => count <= capacities[index].regions)) {
37647
+ finalizeFinalLink(finalTrace);
37648
+ break;
37649
+ }
37377
37650
  capacities = capacities.map((capacity, index) => ({
37378
37651
  ...capacity,
37379
37652
  regions: Math.max(actual[index], capacity.regions)
37380
37653
  }));
37381
37654
  }
37382
37655
  linkedOwners.set(projectionObject, projection.image);
37383
- } else finalTrace = linkFinal();
37384
- const finalSelection = selectedGuestLinkInputs(
37385
- remapGuestLinkPlan(plan, replacements),
37386
- finalArgs,
37387
- import_node_fs61.default.readFileSync(finalWhy, "utf8"),
37388
- finalTrace,
37389
- finalArchives
37390
- );
37391
- const original = new Map([...replacements].map(([before2, after2]) => [after2, before2]));
37392
- const key2 = (item) => JSON.stringify([original.get(item.artifact) ?? item.artifact, item.member]);
37393
- const before = new Set(selected.map(key2));
37394
- const after = new Set(finalSelection.map(key2));
37395
- const changed2 = [...before].filter((item) => !after.has(item));
37396
- changed2.push(...[...after].filter((item) => !before.has(item)));
37397
- if (changed2.length)
37398
- throw new Error(
37399
- `guest link selected different inputs after rewriting:
37400
- ${changed2.join("\n")}`
37401
- );
37402
- import_node_fs61.default.renameSync(finalOutput, outputPath(args));
37403
- if (KEEP_WASM_NAMES)
37404
- import_node_fs61.default.writeFileSync(
37405
- outputPath(args),
37406
- nameGuestImageAliases(import_node_fs61.default.readFileSync(outputPath(args)), plan.symbols)
37407
- );
37656
+ } else finalizeFinalLink(linkFinal());
37408
37657
  if (projectionStorage && projectionObject)
37409
37658
  options2.projection.onReserved(projectionStorage, projectionObject);
37410
37659
  options2.onLinkedOwners?.(linkedOwners);
@@ -37440,11 +37689,13 @@ ${changed2.join("\n")}`
37440
37689
  appDefinedSymbols
37441
37690
  });
37442
37691
  }
37692
+ if (deferredFinalLink) options2.onFinalLink?.(deferredFinalLink);
37443
37693
  return selected;
37444
37694
  } catch (error) {
37445
37695
  await Promise.allSettled([
37446
37696
  ledgerObjectPromise,
37447
- ...appLedgerObjectPromise ? [appLedgerObjectPromise] : []
37697
+ ...appLedgerObjectPromise ? [appLedgerObjectPromise] : [],
37698
+ ...deferredFinalLink ? [deferredFinalLink] : []
37448
37699
  ]);
37449
37700
  throw error;
37450
37701
  }
@@ -38076,6 +38327,7 @@ async function linkPrunedGuestImages(options2) {
38076
38327
  identities: aliasGuestLinkIdentities(identities, prepared.archives)
38077
38328
  };
38078
38329
  }
38330
+ let finalLinkDone;
38079
38331
  const selected = await linkCompleteGuestImages({
38080
38332
  plan,
38081
38333
  args: [...linkedArgs, `--Map=${options2.mapPath}`],
@@ -38089,6 +38341,9 @@ async function linkPrunedGuestImages(options2) {
38089
38341
  resolvePlan: options2.resolvePlan,
38090
38342
  sharedSdk: options2.sharedSdk,
38091
38343
  onSplitInputs: options2.onSplitInputs,
38344
+ onFinalLink: options2.deferFinalLink ? (done) => {
38345
+ finalLinkDone = done;
38346
+ } : void 0,
38092
38347
  onDyldRows: options2.onDyldRows,
38093
38348
  onLinkedOwners: (value) => {
38094
38349
  owners = value;
@@ -38102,7 +38357,8 @@ async function linkPrunedGuestImages(options2) {
38102
38357
  owners,
38103
38358
  generatedSectionOwners,
38104
38359
  sdk: sdk2,
38105
- mapPath: options2.mapPath
38360
+ mapPath: options2.mapPath,
38361
+ finalLinkDone
38106
38362
  };
38107
38363
  }
38108
38364
  var import_node_child_process28, import_node_fs61, import_node_path61, import_node_util6, execFileAsync, WASM_MAGIC, BITCODE_MAGIC;
@@ -38171,8 +38427,13 @@ function clangBinaryStamp(file) {
38171
38427
  const stat2 = (0, import_node_fs62.statSync)(file, { bigint: true });
38172
38428
  return [file, stat2.size, stat2.mtimeNs].join(":");
38173
38429
  }
38430
+ function sha256Hex3(bytes) {
38431
+ if (typeof Bun !== "undefined")
38432
+ return new Bun.CryptoHasher("sha256").update(bytes).digest("hex");
38433
+ return (0, import_node_crypto36.createHash)("sha256").update(bytes).digest("hex");
38434
+ }
38174
38435
  function clangWrapperStamp(file) {
38175
- return (0, import_node_crypto36.createHash)("sha256").update((0, import_node_fs62.readFileSync)(file)).digest("hex");
38436
+ return sha256Hex3((0, import_node_fs62.readFileSync)(file));
38176
38437
  }
38177
38438
  function clangArgsNeedCwd(args) {
38178
38439
  const pathFlags = /* @__PURE__ */ new Set([
@@ -38322,22 +38583,35 @@ function sourceGuestClangLinkOptions(options2) {
38322
38583
  "SOURCE_DATE_EPOCH"
38323
38584
  ].map((name3) => process.env[name3] ?? "");
38324
38585
  const replays = [];
38586
+ const realPathCache = /* @__PURE__ */ new Map();
38587
+ const cachedRealpath = (file) => {
38588
+ let resolved = realPathCache.get(file);
38589
+ if (resolved === void 0) {
38590
+ resolved = (0, import_node_fs62.realpathSync)(file);
38591
+ realPathCache.set(file, resolved);
38592
+ }
38593
+ return resolved;
38594
+ };
38595
+ const resolvedSwiftCompiler = cachedRealpath(options2.swiftCompiler);
38325
38596
  let clang;
38597
+ let clangWrapper;
38326
38598
  let clangStamp;
38327
38599
  let wrapperStamp;
38328
38600
  for (const file of wanted) {
38329
38601
  const command = commands.get(file);
38330
38602
  if (!command) throw new Error(`missing source object producer ${file}`);
38331
38603
  if (command.tool === "shell") {
38332
- if (!command.args.length || (0, import_node_fs62.realpathSync)(command.args[0]) !== (0, import_node_fs62.realpathSync)(options2.swiftCompiler))
38604
+ if (!command.args.length || cachedRealpath(command.args[0]) !== resolvedSwiftCompiler)
38333
38605
  throw new Error(`unsupported source object producer ${file}`);
38334
38606
  continue;
38335
38607
  }
38336
- const compiler = command.args[0] ? (0, import_node_fs62.realpathSync)(command.args[0]) : "";
38337
- clang ??= (0, import_node_fs62.realpathSync)(import_node_path62.default.join(options2.toolchainBin, "clang"));
38338
- if (command.tool !== "clang" || compiler !== clang && compiler !== (0, import_node_fs62.realpathSync)(import_node_path62.default.join(options2.buildDirectory, CLANG_TARGET_MODULE_WRAPPER)))
38608
+ const compiler = command.args[0] ? cachedRealpath(command.args[0]) : "";
38609
+ clang ??= cachedRealpath(import_node_path62.default.join(options2.toolchainBin, "clang"));
38610
+ if (command.tool !== "clang" || compiler !== clang && compiler !== (clangWrapper ??= cachedRealpath(
38611
+ import_node_path62.default.join(options2.buildDirectory, CLANG_TARGET_MODULE_WRAPPER)
38612
+ )))
38339
38613
  throw new Error(`unsupported source object producer ${file}`);
38340
- const key2 = (0, import_node_crypto36.createHash)("sha256").update(
38614
+ const key2 = sha256Hex3(
38341
38615
  JSON.stringify([
38342
38616
  "clang-link-options/v2",
38343
38617
  clangArgsNeedCwd(command.args) ? process.cwd() : null,
@@ -38347,11 +38621,8 @@ function sourceGuestClangLinkOptions(options2) {
38347
38621
  compiler === clang ? null : wrapperStamp ??= clangWrapperStamp(compiler),
38348
38622
  clangProducerStamp(file)
38349
38623
  ])
38350
- ).digest("hex");
38351
- const cacheFile = import_node_path62.default.join(
38352
- cacheDirectory,
38353
- (0, import_node_crypto36.createHash)("sha256").update(file).digest("hex") + ".json"
38354
38624
  );
38625
+ const cacheFile = import_node_path62.default.join(cacheDirectory, sha256Hex3(file) + ".json");
38355
38626
  const cached4 = readClangLinkOptions(cacheFile, key2);
38356
38627
  if (cached4) {
38357
38628
  validateClangLinkOptions(cached4);
@@ -40574,7 +40845,7 @@ function headerClosure(roots) {
40574
40845
  ).filter((file) => !file.endsWith(`/${j.exclude}`));
40575
40846
  const nitroFiles = roots.nitroModules ? headerFiles2(roots.nitroModules, n.from, n.skip, new RegExp(n.keep)) : [];
40576
40847
  const hashes = (base2, files2) => Object.fromEntries(
40577
- files2.map((file) => [file, sha256Hex((0, import_node_fs66.readFileSync)(import_node_path66.default.join(base2, file)))])
40848
+ files2.map((file) => [file, sha256Hex4((0, import_node_fs66.readFileSync)(import_node_path66.default.join(base2, file)))])
40578
40849
  );
40579
40850
  return {
40580
40851
  jsi: hashes(roots.reactNative, jsiFiles),
@@ -40738,11 +41009,11 @@ function verifyInstalledAdapter(family, directory2, pin2) {
40738
41009
  if (JSON.stringify(recorded) !== JSON.stringify(pinned))
40739
41010
  throw new Error(`${label} manifest does not match the lock this build carries`);
40740
41011
  const bytes = (0, import_node_fs66.readFileSync)(import_node_path66.default.join(directory2, archive.path));
40741
- if (bytes.length !== archive.size || sha256Hex(bytes) !== archive.sha256)
41012
+ if (bytes.length !== archive.size || sha256Hex4(bytes) !== archive.sha256)
40742
41013
  throw new Error(`${label} library does not match its manifest`);
40743
41014
  return manifest;
40744
41015
  }
40745
- var import_node_crypto38, import_node_fs66, import_node_path66, ADAPTER_MANIFEST, ADAPTER_FAMILIES, TURBO_RUNTIME_HEADER, HEADER_STAGE, sha256Hex, hex64, sameHeaders;
41016
+ var import_node_crypto38, import_node_fs66, import_node_path66, ADAPTER_MANIFEST, ADAPTER_FAMILIES, TURBO_RUNTIME_HEADER, HEADER_STAGE, sha256Hex4, hex64, sameHeaders;
40746
41017
  var init_nitroAdapterContract = __esm({
40747
41018
  "src/nitroAdapterContract.ts"() {
40748
41019
  "use strict";
@@ -40792,7 +41063,7 @@ void scheduleDrain();
40792
41063
  to: ["core", "core/NitroModules"]
40793
41064
  }
40794
41065
  };
40795
- sha256Hex = (data) => (0, import_node_crypto38.createHash)("sha256").update(data).digest("hex");
41066
+ sha256Hex4 = (data) => (0, import_node_crypto38.createHash)("sha256").update(data).digest("hex");
40796
41067
  hex64 = (value) => typeof value === "string" && /^[a-f0-9]{64}$/.test(value);
40797
41068
  sameHeaders = (a, b) => JSON.stringify(a) === JSON.stringify(b);
40798
41069
  }
@@ -44277,6 +44548,7 @@ async function linkSwiftSdkImage(moduleRoot, key2, directory2, work, scopedLooku
44277
44548
  ].map((name3) => `--export=${name3}`),
44278
44549
  `@${import_node_path72.default.join(work, "exports.rsp")}`,
44279
44550
  "--gc-sections",
44551
+ "--strip-debug",
44280
44552
  // strings stay with their objects, so an app loads only the ones its pieces reference
44281
44553
  "-O0"
44282
44554
  ];
@@ -44337,7 +44609,7 @@ async function linkSwiftSdkImage(moduleRoot, key2, directory2, work, scopedLooku
44337
44609
  (0, import_node_fs72.writeFileSync)(import_node_path72.default.join(work, INTERFACE_FILE), JSON.stringify(sdkInterface));
44338
44610
  (0, import_node_fs72.writeFileSync)(
44339
44611
  import_node_path72.default.join(work, IMAGE_DIGEST),
44340
- (0, import_node_crypto43.createHash)("sha256").update(image).digest("hex")
44612
+ typeof Bun !== "undefined" ? new Bun.CryptoHasher("sha256").update(image).digest("hex") : (0, import_node_crypto43.createHash)("sha256").update(image).digest("hex")
44341
44613
  );
44342
44614
  if (swiftSdkImageKey(
44343
44615
  moduleRoot,
@@ -44895,6 +45167,7 @@ __export(swift_sdk_app_module_exports, {
44895
45167
  readSwiftSdkUsage: () => readSwiftSdkUsage,
44896
45168
  selectSwiftSdkData: () => selectSwiftSdkData,
44897
45169
  swiftAppModuleInputs: () => swiftAppModuleInputs,
45170
+ swiftAppModuleThunkSection: () => swiftAppModuleThunkSection,
44898
45171
  swiftSdkProjectionSpans: () => swiftSdkProjectionSpans,
44899
45172
  writeSwiftSdkAppLink: () => writeSwiftSdkAppLink
44900
45173
  });
@@ -44946,9 +45219,12 @@ async function buildSwiftAppModule(options2) {
44946
45219
  linkage: link.linkage,
44947
45220
  usage
44948
45221
  });
44949
- (0, import_node_fs73.writeFileSync)(options2.output, finishSwiftAppModule((0, import_node_fs73.readFileSync)(options2.output)));
45222
+ finishSwiftAppModuleFile(options2.output);
44950
45223
  return binding;
44951
45224
  }
45225
+ function swiftAppModuleThunkSection(lowered) {
45226
+ return [NATIVE_SDK_THUNK_SECTION, sdkImportThunks(lowered)];
45227
+ }
44952
45228
  function finishSwiftAppModule(lowered) {
44953
45229
  return writeWasmCustomSection(
44954
45230
  lowered,
@@ -44956,6 +45232,73 @@ function finishSwiftAppModule(lowered) {
44956
45232
  sdkImportThunks(lowered)
44957
45233
  );
44958
45234
  }
45235
+ function finishSwiftAppModuleFile(file) {
45236
+ const fd = (0, import_node_fs73.openSync)(file, "r");
45237
+ let prefixEnd = 8;
45238
+ let hasExistingThunk = false;
45239
+ let prefix;
45240
+ try {
45241
+ const total = (0, import_node_fs73.fstatSync)(fd).size;
45242
+ const probe = Buffer.allocUnsafe(16);
45243
+ let offset = 8;
45244
+ while (offset < total) {
45245
+ const read = (0, import_node_fs73.readSync)(fd, probe, 0, Math.min(16, total - offset), offset);
45246
+ if (read < 2) break;
45247
+ const id = probe[0];
45248
+ let size2 = 0;
45249
+ let shift = 0;
45250
+ let at = 1;
45251
+ for (; ; ) {
45252
+ const byte = probe[at++];
45253
+ size2 += (byte & 127) * 2 ** shift;
45254
+ if (!(byte & 128)) break;
45255
+ shift += 7;
45256
+ }
45257
+ const start = offset + at;
45258
+ const next = start + size2;
45259
+ if (id === 1 || id === 2) prefixEnd = next;
45260
+ else if (id === 0) {
45261
+ const nameBuf = Buffer.allocUnsafe(Math.min(128, size2));
45262
+ const nRead = (0, import_node_fs73.readSync)(fd, nameBuf, 0, nameBuf.length, start);
45263
+ let nLen = 0;
45264
+ let nShift = 0;
45265
+ let nAt = 0;
45266
+ for (; ; ) {
45267
+ if (nAt >= nRead) break;
45268
+ const byte = nameBuf[nAt++];
45269
+ nLen += (byte & 127) * 2 ** nShift;
45270
+ if (!(byte & 128)) break;
45271
+ nShift += 7;
45272
+ }
45273
+ if (nAt + nLen <= nRead && nameBuf.toString("utf8", nAt, nAt + nLen) === NATIVE_SDK_THUNK_SECTION) {
45274
+ hasExistingThunk = true;
45275
+ break;
45276
+ }
45277
+ }
45278
+ offset = next;
45279
+ }
45280
+ if (!hasExistingThunk) {
45281
+ prefix = Buffer.allocUnsafe(prefixEnd);
45282
+ let filled = 0;
45283
+ while (filled < prefixEnd) {
45284
+ const n = (0, import_node_fs73.readSync)(fd, prefix, filled, prefixEnd - filled, filled);
45285
+ if (n <= 0) break;
45286
+ filled += n;
45287
+ }
45288
+ prefix = prefix.subarray(0, filled);
45289
+ }
45290
+ } finally {
45291
+ (0, import_node_fs73.closeSync)(fd);
45292
+ }
45293
+ if (hasExistingThunk || !prefix) {
45294
+ (0, import_node_fs73.writeFileSync)(file, finishSwiftAppModule((0, import_node_fs73.readFileSync)(file)));
45295
+ return;
45296
+ }
45297
+ const thunks = sdkImportThunks(prefix);
45298
+ const nameBytes = Buffer.from(encodedName2(NATIVE_SDK_THUNK_SECTION));
45299
+ const header = Buffer.from([0, ...uleb4(nameBytes.length + thunks.length)]);
45300
+ (0, import_node_fs73.appendFileSync)(file, Buffer.concat([header, nameBytes, thunks]));
45301
+ }
44959
45302
  function swiftAppModuleInputs(tokens2, buildRoot, sdkLibraries) {
44960
45303
  const owned = (token) => import_node_path73.default.resolve(token).startsWith(`${buildRoot}/`) && (!token.includes("/.peach-pruned-objs/") || token.endsWith("/swiftrt-patched.o"));
44961
45304
  const inputs2 = [];
@@ -45170,6 +45513,7 @@ async function linkSwiftAppModule(options2) {
45170
45513
  "--unresolved-symbols=ignore-all",
45171
45514
  "--import-undefined",
45172
45515
  "--emit-relocs",
45516
+ "--strip-debug",
45173
45517
  "--gc-sections",
45174
45518
  "--keep-section=target_features",
45175
45519
  "--error-limit=0",
@@ -45192,7 +45536,16 @@ async function linkSwiftAppModule(options2) {
45192
45536
  const skipPasses = options2.layoutMap ? ["duplicate-function-elimination"] : void 0;
45193
45537
  const sdkTableEnd = sdk2.sdkInterface.layout.tableEnd;
45194
45538
  const { loweringCache } = options2;
45195
- const loweringKey = loweringCache && (0, import_node_crypto44.createHash)("sha256").update(
45539
+ const loweringKey = loweringCache && (typeof Bun !== "undefined" ? new Bun.CryptoHasher("sha256").update(
45540
+ JSON.stringify([
45541
+ loweringCache.compilerDigest,
45542
+ optimize,
45543
+ skipPasses,
45544
+ sdkTableEnd,
45545
+ lazy,
45546
+ KEEP_WASM_NAMES
45547
+ ])
45548
+ ).update(bytes).digest("hex") : (0, import_node_crypto44.createHash)("sha256").update(
45196
45549
  JSON.stringify([
45197
45550
  loweringCache.compilerDigest,
45198
45551
  optimize,
@@ -45201,7 +45554,7 @@ async function linkSwiftAppModule(options2) {
45201
45554
  lazy,
45202
45555
  KEEP_WASM_NAMES
45203
45556
  ])
45204
- ).update(bytes).digest("hex");
45557
+ ).update(bytes).digest("hex"));
45205
45558
  return {
45206
45559
  linkage,
45207
45560
  async lower() {
@@ -45811,7 +46164,8 @@ function createSwiftSdkBinding(linkage, sdk2, usage, projection) {
45811
46164
  bindSwiftAppModule(linkage, sdk2),
45812
46165
  selectSwiftSdkData(sdk2, usage, linkage, projection)
45813
46166
  ]);
45814
- return { bytes, sha256: (0, import_node_crypto44.createHash)("sha256").update(bytes).digest("hex") };
46167
+ const sha2565 = typeof Bun !== "undefined" ? new Bun.CryptoHasher("sha256").update(bytes).digest("hex") : (0, import_node_crypto44.createHash)("sha256").update(bytes).digest("hex");
46168
+ return { bytes, sha256: sha2565 };
45815
46169
  }
45816
46170
  function readSwiftSdkUsage(mapFile, linkedFile, sdkObjects) {
45817
46171
  const map2 = readWasmLinkMap(mapFile, false);
@@ -46567,6 +46921,7 @@ async function compileGuestLink(options2) {
46567
46921
  onSplitInputs: sdk2 ? (value) => {
46568
46922
  splitInputs = value;
46569
46923
  } : void 0,
46924
+ deferFinalLink: Boolean(sdk2),
46570
46925
  onDyldRows: (rows) => {
46571
46926
  lazyFunctions = rows.lazyFunctions;
46572
46927
  dyldSymbols = rows.dyldSymbols;
@@ -46835,156 +47190,164 @@ async function compileGuestLink(options2) {
46835
47190
  });
46836
47191
  if (!reserved2 || !projectionObject) throw new Error("guest projection was not reserved");
46837
47192
  if (sdk2) {
46838
- if (!splitInputs) throw new Error("guest link did not select shared SDK inputs");
46839
- const {
46840
- createSwiftSdkBinding: createSwiftSdkBinding2,
46841
- finishSwiftAppModule: finishSwiftAppModule2,
46842
- linkSwiftAppModule: linkSwiftAppModule2,
46843
- readSwiftSdkUsage: readSwiftSdkUsage2,
46844
- swiftSdkProjectionSpans: swiftSdkProjectionSpans2
46845
- } = await Promise.resolve().then(() => (init_swift_sdk_app_module(), swift_sdk_app_module_exports));
46846
- const project2 = options2.project;
46847
- const work = project2 ? (0, import_node_fs74.mkdtempSync)(import_node_path74.default.join(directory2, "app-module-")) : import_node_path74.default.join(directory2, "app-module");
46848
- if (project2) (0, import_node_fs74.chownSync)(work, project2.uid, project2.gid);
46849
- else (0, import_node_fs74.mkdirSync)(work, { recursive: true });
46850
- const layoutMap = import_node_path74.default.join(work, "app.map");
46851
- const owners = new Map(splitInputs.appObjects).set(projectionObject, 0);
46852
- const sdkObjectKeys = /* @__PURE__ */ new Map();
46853
- const sdkObjectImages = /* @__PURE__ */ new Map();
46854
- const sdkProductImages = new Map(prepared?.sdkProducts.images);
46855
- for (const [file, { image, product, identity: identity2 }] of splitInputs.sdkObjects) {
46856
- const key2 = sdkGuestObjectKey(identity2);
46857
- sdkObjectKeys.set(file, key2);
46858
- sdkObjectImages.set(key2, image);
46859
- const priorImage = sdkProductImages.get(product);
46860
- if (priorImage !== void 0 && priorImage !== image)
46861
- throw new Error(`SDK product ${product} has several guest images`);
46862
- sdkProductImages.set(product, image);
46863
- }
46864
- const usage = readSwiftSdkUsage2(result.mapPath, options2.output, sdkObjectKeys);
46865
- const linkedModule = import_node_path74.default.join(work, "app.wasm");
46866
- const sdkSpans = swiftSdkProjectionSpans2(
46867
- sdk2,
46868
- (object9, product) => sdkObjectImages.get(object9) ?? sdkProductImages.get(product)
46869
- );
46870
- let storage = reserved2;
46871
- if (sdkSpans.length > 0) {
46872
- const sdkCounts = guestProjectionRegionCounts(storage.images.length, sdkSpans);
46873
- storage = reserveGuestProjectionStorage(
46874
- storage.images,
46875
- storage.capacities.map((capacity, index) => ({
46876
- ...capacity,
46877
- regions: capacity.regions + sdkCounts[index] + 16
46878
- }))
46879
- );
46880
- const projectionSource = import_node_path74.default.join(work, "projection.c");
46881
- (0, import_node_fs74.writeFileSync)(projectionSource, storage.source);
46882
- (0, import_node_child_process39.execFileSync)(
46883
- import_node_path74.default.join(options2.toolchainBin, "clang"),
46884
- [...clangOptions, "-c", projectionSource, "-o", projectionObject],
46885
- { stdio: "pipe" }
46886
- );
46887
- }
46888
- let precomputedSymbols;
46889
- if (splitInputs.appReferencedSymbols && splitInputs.appDefinedSymbols) {
46890
- const referenced = new Set(splitInputs.appReferencedSymbols);
46891
- const defined = new Set(splitInputs.appDefinedSymbols);
46892
- const projSyms = guestWasmSymbols((0, import_node_fs74.readFileSync)(projectionObject));
46893
- for (const name3 of projSyms.undefined) referenced.add(name3);
46894
- for (const name3 of projSyms.defined) defined.add(name3);
46895
- precomputedSymbols = { referenced, defined };
46896
- }
46897
- for (; ; ) {
46898
- const link = await linkSwiftAppModule2({
46899
- objects: [...owners.keys()],
46900
- lazyFunctions: splitInputs.lazyFunctions,
46901
- toolchainBin: options2.toolchainBin,
46902
- sdk: sdk2,
46903
- work,
46904
- output: options2.optimized,
46905
- optimize: options2.optimize,
46906
- layoutMap,
46907
- project: project2,
46908
- precomputedSymbols,
46909
- loweringCache: project2 ? void 0 : {
46910
- file: import_node_path74.default.join(
46911
- options2.buildDirectory,
46912
- ".build",
46913
- "peach-app-module-lowered.wasm"
46914
- ),
46915
- compilerDigest: options2.compilerDigest
46916
- }
46917
- });
46918
- const map3 = (0, import_node_fs74.readFileSync)(
46919
- project2 ? projectOutputFile(work, layoutMap, project2) : layoutMap,
46920
- "utf8"
47193
+ try {
47194
+ if (!splitInputs) throw new Error("guest link did not select shared SDK inputs");
47195
+ const {
47196
+ createSwiftSdkBinding: createSwiftSdkBinding2,
47197
+ linkSwiftAppModule: linkSwiftAppModule2,
47198
+ readSwiftSdkUsage: readSwiftSdkUsage2,
47199
+ swiftAppModuleThunkSection: swiftAppModuleThunkSection2,
47200
+ swiftSdkProjectionSpans: swiftSdkProjectionSpans2
47201
+ } = await Promise.resolve().then(() => (init_swift_sdk_app_module(), swift_sdk_app_module_exports));
47202
+ const project2 = options2.project;
47203
+ const work = project2 ? (0, import_node_fs74.mkdtempSync)(import_node_path74.default.join(directory2, "app-module-")) : import_node_path74.default.join(directory2, "app-module");
47204
+ if (project2) (0, import_node_fs74.chownSync)(work, project2.uid, project2.gid);
47205
+ else (0, import_node_fs74.mkdirSync)(work, { recursive: true });
47206
+ const layoutMap = import_node_path74.default.join(work, "app.map");
47207
+ let appProjectionObject = projectionObject;
47208
+ const owners = new Map(splitInputs.appObjects).set(appProjectionObject, 0);
47209
+ const sdkObjectKeys = /* @__PURE__ */ new Map();
47210
+ const sdkObjectImages = /* @__PURE__ */ new Map();
47211
+ const sdkProductImages = new Map(prepared?.sdkProducts.images);
47212
+ for (const [file, { image, product, identity: identity2 }] of splitInputs.sdkObjects) {
47213
+ const key2 = sdkGuestObjectKey(identity2);
47214
+ sdkObjectKeys.set(file, key2);
47215
+ sdkObjectImages.set(key2, image);
47216
+ const priorImage = sdkProductImages.get(product);
47217
+ if (priorImage !== void 0 && priorImage !== image)
47218
+ throw new Error(`SDK product ${product} has several guest images`);
47219
+ sdkProductImages.set(product, image);
47220
+ }
47221
+ const linkedModule = import_node_path74.default.join(work, "app.wasm");
47222
+ const sdkSpans = swiftSdkProjectionSpans2(
47223
+ sdk2,
47224
+ (object9, product) => sdkObjectImages.get(object9) ?? sdkProductImages.get(product)
46921
47225
  );
46922
- const values = guestDyldValueRange(map3);
46923
- const bindingRows = /* @__PURE__ */ new Map();
46924
- const data = [];
46925
- for (let at = 0; at < link.linkage.data.length; at += 3) {
46926
- const address = link.linkage.data[at];
46927
- const size2 = link.linkage.data[at + 1];
46928
- const value = link.linkage.data[at + 2];
46929
- if (values && address >= values.address && address < values.address + values.length) {
46930
- if (size2 !== 8 || (address - values.address) % 8)
46931
- throw new Error("sdk binding splits a dyld value");
46932
- bindingRows.set((address - values.address) / 8, value);
46933
- } else data.push(address, size2, value);
46934
- }
46935
- const linked = (0, import_node_fs74.readFileSync)(
46936
- project2 ? projectOutputFile(work, linkedModule, project2) : linkedModule
46937
- );
46938
- const required = guestProjectionRegionCounts(storage.images.length, [
46939
- ...guestLinkedSpans(map3, linked, linked, owners, splitInputs.appSections, true),
46940
- ...sdkSpans
46941
- ]);
46942
- if (storage.capacities.some(({ regions }, index) => required[index] > regions)) {
46943
- storage = reserveGuestProjectionStorage(
46944
- storage.images,
46945
- storage.capacities.map((capacity, index) => {
46946
- const count = required[index];
46947
- return count > capacity.regions ? { ...capacity, regions: Math.max(count, capacity.regions * 2) } : capacity;
46948
- })
46949
- );
47226
+ const compileAppProjection = (source) => {
46950
47227
  const projectionSource = import_node_path74.default.join(work, "projection.c");
46951
- (0, import_node_fs74.writeFileSync)(projectionSource, storage.source);
47228
+ const nextObject = import_node_path74.default.join(work, "projection.o");
47229
+ (0, import_node_fs74.writeFileSync)(projectionSource, source);
46952
47230
  (0, import_node_child_process39.execFileSync)(
46953
47231
  import_node_path74.default.join(options2.toolchainBin, "clang"),
46954
- [...clangOptions, "-c", projectionSource, "-o", projectionObject],
47232
+ [...clangOptions, "-c", projectionSource, "-o", nextObject],
46955
47233
  { stdio: "pipe" }
46956
47234
  );
46957
- continue;
47235
+ if (nextObject !== appProjectionObject) {
47236
+ owners.delete(appProjectionObject);
47237
+ appProjectionObject = nextObject;
47238
+ owners.set(appProjectionObject, 0);
47239
+ }
47240
+ };
47241
+ let storage = reserved2;
47242
+ if (sdkSpans.length > 0) {
47243
+ const sdkCounts = guestProjectionRegionCounts(storage.images.length, sdkSpans);
47244
+ storage = reserveGuestProjectionStorage(
47245
+ storage.images,
47246
+ storage.capacities.map((capacity, index) => ({
47247
+ ...capacity,
47248
+ regions: capacity.regions + sdkCounts[index] + 16
47249
+ }))
47250
+ );
47251
+ compileAppProjection(storage.source);
46958
47252
  }
46959
- options2.onStage("lowering the app image");
46960
- const lowerPromise = link.lower();
46961
- await new Promise((resolve11) => setImmediate(resolve11));
46962
- let binding;
46963
- try {
46964
- binding = createSwiftSdkBinding2({ ...link.linkage, data }, sdk2, usage);
46965
- } catch (error) {
46966
- await lowerPromise.catch(() => {
47253
+ let precomputedSymbols;
47254
+ if (splitInputs.appReferencedSymbols && splitInputs.appDefinedSymbols) {
47255
+ const referenced = new Set(splitInputs.appReferencedSymbols);
47256
+ const defined = new Set(splitInputs.appDefinedSymbols);
47257
+ const projSyms = guestWasmSymbols((0, import_node_fs74.readFileSync)(appProjectionObject));
47258
+ for (const name3 of projSyms.undefined) referenced.add(name3);
47259
+ for (const name3 of projSyms.defined) defined.add(name3);
47260
+ precomputedSymbols = { referenced, defined };
47261
+ }
47262
+ for (; ; ) {
47263
+ const link = await linkSwiftAppModule2({
47264
+ objects: [...owners.keys()],
47265
+ lazyFunctions: splitInputs.lazyFunctions,
47266
+ toolchainBin: options2.toolchainBin,
47267
+ sdk: sdk2,
47268
+ work,
47269
+ output: options2.optimized,
47270
+ optimize: options2.optimize,
47271
+ layoutMap,
47272
+ project: project2,
47273
+ precomputedSymbols,
47274
+ loweringCache: project2 ? void 0 : {
47275
+ file: import_node_path74.default.join(
47276
+ options2.buildDirectory,
47277
+ ".build",
47278
+ "peach-app-module-lowered.wasm"
47279
+ ),
47280
+ compilerDigest: options2.compilerDigest
47281
+ }
46967
47282
  });
46968
- throw error;
47283
+ const map3 = (0, import_node_fs74.readFileSync)(
47284
+ project2 ? projectOutputFile(work, layoutMap, project2) : layoutMap,
47285
+ "utf8"
47286
+ );
47287
+ const values = guestDyldValueRange(map3);
47288
+ const bindingRows = /* @__PURE__ */ new Map();
47289
+ const data = [];
47290
+ for (let at = 0; at < link.linkage.data.length; at += 3) {
47291
+ const address = link.linkage.data[at];
47292
+ const size2 = link.linkage.data[at + 1];
47293
+ const value = link.linkage.data[at + 2];
47294
+ if (values && address >= values.address && address < values.address + values.length) {
47295
+ if (size2 !== 8 || (address - values.address) % 8)
47296
+ throw new Error("sdk binding splits a dyld value");
47297
+ bindingRows.set((address - values.address) / 8, value);
47298
+ } else data.push(address, size2, value);
47299
+ }
47300
+ const linked = (0, import_node_fs74.readFileSync)(
47301
+ project2 ? projectOutputFile(work, linkedModule, project2) : linkedModule
47302
+ );
47303
+ const required = guestProjectionRegionCounts(storage.images.length, [
47304
+ ...guestLinkedSpans(map3, linked, linked, owners, splitInputs.appSections, true),
47305
+ ...sdkSpans
47306
+ ]);
47307
+ if (storage.capacities.some(({ regions }, index) => required[index] > regions)) {
47308
+ storage = reserveGuestProjectionStorage(
47309
+ storage.images,
47310
+ storage.capacities.map((capacity, index) => {
47311
+ const count = required[index];
47312
+ return count > capacity.regions ? { ...capacity, regions: Math.max(count, capacity.regions * 2) } : capacity;
47313
+ })
47314
+ );
47315
+ compileAppProjection(storage.source);
47316
+ continue;
47317
+ }
47318
+ options2.onStage("lowering the app image");
47319
+ const lowerPromise = link.lower();
47320
+ await new Promise((resolve11) => setImmediate(resolve11));
47321
+ let binding;
47322
+ try {
47323
+ if (result.finalLinkDone) await result.finalLinkDone;
47324
+ const usage = readSwiftSdkUsage2(result.mapPath, options2.output, sdkObjectKeys);
47325
+ binding = createSwiftSdkBinding2({ ...link.linkage, data }, sdk2, usage);
47326
+ } catch (error) {
47327
+ await Promise.allSettled([lowerPromise]);
47328
+ throw error;
47329
+ }
47330
+ await lowerPromise;
47331
+ const finalized = finalizeGuestProjectionStorage({
47332
+ map: map3,
47333
+ linked,
47334
+ optimized: (0, import_node_fs74.readFileSync)(options2.optimized),
47335
+ owners,
47336
+ sectionOwners: splitInputs.appSections,
47337
+ projectionObject: appProjectionObject,
47338
+ reserved: storage,
47339
+ sdkSpans
47340
+ });
47341
+ (0, import_node_fs74.writeFileSync)(
47342
+ options2.optimized,
47343
+ moveGuestDyldTable(map3, finalized.wasm, splitInputs.dyldSymbols, bindingRows, [
47344
+ swiftAppModuleThunkSection2(finalized.wasm)
47345
+ ])
47346
+ );
47347
+ return binding;
46969
47348
  }
46970
- await lowerPromise;
46971
- const finalized = finalizeGuestProjectionStorage({
46972
- map: map3,
46973
- linked,
46974
- optimized: (0, import_node_fs74.readFileSync)(options2.optimized),
46975
- owners,
46976
- sectionOwners: splitInputs.appSections,
46977
- projectionObject,
46978
- reserved: storage,
46979
- sdkSpans
46980
- });
46981
- (0, import_node_fs74.writeFileSync)(
46982
- options2.optimized,
46983
- finishSwiftAppModule2(
46984
- moveGuestDyldTable(map3, finalized.wasm, splitInputs.dyldSymbols, bindingRows)
46985
- )
46986
- );
46987
- return binding;
47349
+ } finally {
47350
+ if (result.finalLinkDone) await Promise.allSettled([result.finalLinkDone]);
46988
47351
  }
46989
47352
  }
46990
47353
  options2.onStage("lowering the app image");
@@ -52402,6 +52765,10 @@ async function buildFrameworkProducts(scratch2, args) {
52402
52765
  // every framework target when callers alternate --cores.
52403
52766
  "-Xswiftc",
52404
52767
  "-gnone",
52768
+ "-Xcc",
52769
+ "-g0",
52770
+ "-Xcxx",
52771
+ "-g0",
52405
52772
  "-Xswiftc",
52406
52773
  "-num-threads",
52407
52774
  "-Xswiftc",
@@ -53292,6 +53659,10 @@ ${cap}` : "";
53292
53659
  // fan-out under high -j.
53293
53660
  "-Xswiftc",
53294
53661
  "-gnone",
53662
+ "-Xcc",
53663
+ "-g0",
53664
+ "-Xcxx",
53665
+ "-g0",
53295
53666
  ...incrementalPreview ? [] : [
53296
53667
  "-Xswiftc",
53297
53668
  "-num-threads",
@@ -53942,7 +54313,7 @@ ${wasmThreadLinkFlags.map((flag) => ` "-Xlinker", ${JSON.stringify(flag
53942
54313
  REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
53943
54314
  MULTI_MANIFEST_VERSION = 76;
53944
54315
  SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
53945
- compilerSourceDigest = true ? "67e8f8e0e47047534254dae36e13cda1c7694fb49b1d92c2d01a9e386dc59e59" : swiftCompilerSourceDigest2(__sootsim_import_meta_dirname);
54316
+ compilerSourceDigest = true ? "ab7e385f5b9ca10737de11d59802a2b57ee084a172b96aa971acb4c26a58a573" : swiftCompilerSourceDigest2(__sootsim_import_meta_dirname);
53946
54317
  nativeCxxCompilerFlags = ["-fno-cxx-modules"];
53947
54318
  MODULE_MAP_RESPONSE_FILE_RUN = 16;
53948
54319
  cFlagArray = (flags) => JSON.stringify(withoutGlogModuleMap(flags));
@@ -71622,6 +71993,11 @@ end
71622
71993
  });
71623
71994
 
71624
71995
  // src/bazel-project.ts
71996
+ function sha256Hex5(bytes) {
71997
+ if (typeof Bun !== "undefined")
71998
+ return new Bun.CryptoHasher("sha256").update(bytes).digest("hex");
71999
+ return (0, import_node_crypto53.createHash)("sha256").update(bytes).digest("hex");
72000
+ }
71625
72001
  function isBazelPackage(input) {
71626
72002
  return /^BUILD(?:\.bazel)?$/.test(import_node_path96.default.basename(input)) && import_node_fs93.default.statSync(input).isFile();
71627
72003
  }
@@ -72188,6 +72564,18 @@ ${published4.map(
72188
72564
  `bazel application has ${missing2.length} unbuilt inputs: ${missing2.slice(0, 5).map((file) => import_node_path96.default.relative(root, file)).join(", ")}`
72189
72565
  );
72190
72566
  const archives = /* @__PURE__ */ new Map();
72567
+ let outputOwner;
72568
+ const ownerOfOutput = (file) => {
72569
+ if (!outputOwner) {
72570
+ outputOwner = /* @__PURE__ */ new Map();
72571
+ for (const item of graph.rules.values())
72572
+ for (const output of item.outputs) {
72573
+ const outputPath2 = files2.path(output);
72574
+ if (!outputOwner.has(outputPath2)) outputOwner.set(outputPath2, item);
72575
+ }
72576
+ }
72577
+ return outputOwner.get(file);
72578
+ };
72191
72579
  for (const rule of order) {
72192
72580
  for (const dep of rule.attrs.get("deps")?.list ?? []) {
72193
72581
  const owner = ruleOf(dep, rule.label);
@@ -72205,9 +72593,7 @@ ${published4.map(
72205
72593
  for (const raw2 of rule.attrs.get("srcs")?.list ?? []) {
72206
72594
  const label2 = canonicalLabel(raw2, rule.label);
72207
72595
  for (const archive of files2.expand([raw2], rule.label).filter((file) => file.endsWith(".a"))) {
72208
- const owner = [...graph.rules.values()].find(
72209
- (item) => item.outputs.some((output) => files2.path(output) === archive)
72210
- );
72596
+ const owner = ownerOfOutput(archive);
72211
72597
  const key2 = owner?.label ?? label2;
72212
72598
  const entry = archives.get(key2) ?? {
72213
72599
  library: import_node_path96.default.basename(archive),
@@ -72233,6 +72619,13 @@ ${published4.map(
72233
72619
  )
72234
72620
  )
72235
72621
  );
72622
+ const matchesAppInclude = (name3) => {
72623
+ if (appIncludes.has(name3)) return true;
72624
+ for (let slash = name3.indexOf("/"); slash >= 0; slash = name3.indexOf("/", slash + 1)) {
72625
+ if (appIncludes.has(name3.slice(slash + 1))) return true;
72626
+ }
72627
+ return false;
72628
+ };
72236
72629
  let generatedBy;
72237
72630
  const generators = () => {
72238
72631
  if (!generatedBy) {
@@ -72313,9 +72706,7 @@ ${published4.map(
72313
72706
  [...linkers].filter((rule) => rule.attrs.get("module_name")?.value).flatMap((rule) => files2.expand(rule.attrs.get("hdrs")?.list ?? [], rule.label))
72314
72707
  );
72315
72708
  const entries2 = headers.filter(
72316
- (header) => imported.has(header.file) || [...appIncludes].some(
72317
- (include) => header.name === include || header.name.endsWith(`/${include}`)
72318
- )
72709
+ (header) => imported.has(header.file) || matchesAppInclude(header.name)
72319
72710
  );
72320
72711
  const bundle = import_node_path96.default.join(products, "archives", `${name3}.xcframework`);
72321
72712
  const slice = import_node_path96.default.join(bundle, "ios-arm64-simulator");
@@ -72361,14 +72752,9 @@ ${published4.map(
72361
72752
  ]
72362
72753
  )
72363
72754
  ]);
72364
- const digest3 = (0, import_node_crypto53.createHash)("sha256").update(
72365
- JSON.stringify(
72366
- [...contents2].map(([file, bytes]) => [
72367
- file,
72368
- (0, import_node_crypto53.createHash)("sha256").update(bytes).digest("hex")
72369
- ])
72370
- )
72371
- ).digest("hex");
72755
+ const digest3 = sha256Hex5(
72756
+ JSON.stringify([...contents2].map(([file, bytes]) => [file, sha256Hex5(bytes)]))
72757
+ );
72372
72758
  const stamp = import_node_path96.default.join(bundle, ".peach-digest");
72373
72759
  if (!import_node_fs93.default.existsSync(stamp) || import_node_fs93.default.readFileSync(stamp, "utf8") !== digest3) {
72374
72760
  import_node_fs93.default.rmSync(bundle, { recursive: true, force: true });
@@ -87176,7 +87562,7 @@ function compiledFrameworkImports(app, products) {
87176
87562
  }
87177
87563
  return imports2;
87178
87564
  }
87179
- function sha256Hex2(bytes) {
87565
+ function sha256Hex6(bytes) {
87180
87566
  if (typeof Bun !== "undefined")
87181
87567
  return new Bun.CryptoHasher("sha256").update(bytes).digest("hex");
87182
87568
  return (0, import_node_crypto72.createHash)("sha256").update(bytes).digest("hex");
@@ -87194,7 +87580,7 @@ function verifyRetainedFile(work, file, hash, stamps) {
87194
87580
  if (typeof expectedStamp === "string" && regularFileStamp(resolved) === expectedStamp)
87195
87581
  return true;
87196
87582
  if (!import_node_fs119.default.existsSync(resolved)) return false;
87197
- return sha256Hex2(readPackageFile(work, resolved, Infinity)) === hash;
87583
+ return sha256Hex6(readPackageFile(work, resolved, Infinity)) === hash;
87198
87584
  }
87199
87585
  function recordRetainedStamps(work, files2) {
87200
87586
  const stamps = {};
@@ -87211,7 +87597,7 @@ function cachedBinaryFileDigest(file) {
87211
87597
  const memory = binaryFileDigests.get(real);
87212
87598
  if (memory?.stamp === stamp) return memory.digest;
87213
87599
  const dir = import_node_path123.default.join(cacheDir(), "swift-binary-digests");
87214
- const record6 = import_node_path123.default.join(dir, `${sha256Hex2(real)}.json`);
87600
+ const record6 = import_node_path123.default.join(dir, `${sha256Hex6(real)}.json`);
87215
87601
  if (import_node_fs119.default.existsSync(record6)) {
87216
87602
  const saved = JSON.parse(import_node_fs119.default.readFileSync(record6, "utf8"));
87217
87603
  if (isRecord(saved) && saved.stamp === stamp && typeof saved.digest === "string") {
@@ -87219,7 +87605,7 @@ function cachedBinaryFileDigest(file) {
87219
87605
  return saved.digest;
87220
87606
  }
87221
87607
  }
87222
- const digest3 = sha256Hex2(import_node_fs119.default.readFileSync(real));
87608
+ const digest3 = sha256Hex6(import_node_fs119.default.readFileSync(real));
87223
87609
  binaryFileDigests.set(real, { stamp, digest: digest3 });
87224
87610
  import_node_fs119.default.mkdirSync(dir, { recursive: true });
87225
87611
  const partial = `${record6}.${process.pid}.${(0, import_node_crypto72.randomUUID)()}`;
@@ -87754,7 +88140,7 @@ function prepareXcodeSwiftProducts(app, binaries, moduleRoot) {
87754
88140
  const staged = withFrameworkCompanionImports(original);
87755
88141
  if (staged !== original) sources.set(file, Buffer.from(staged));
87756
88142
  }
87757
- const digest3 = sha256Hex2;
88143
+ const digest3 = sha256Hex6;
87758
88144
  const providers = /* @__PURE__ */ new Map();
87759
88145
  for (const target of targets) {
87760
88146
  if (!supplied.has(target.moduleName)) continue;
@@ -88110,7 +88496,7 @@ async function prepareXcodeNativeInputs(app, binaries, moduleRoot, purpose) {
88110
88496
  products
88111
88497
  );
88112
88498
  const checkouts = remoteSwiftCheckouts(app.rootDir);
88113
- const digest3 = sha256Hex2;
88499
+ const digest3 = sha256Hex6;
88114
88500
  const inputs2 = Object.fromEntries(
88115
88501
  [...sources].map(([file, bytes]) => [file, digest3(bytes)])
88116
88502
  );
@@ -88392,6 +88778,7 @@ async function prepareXcodeNativeInputs(app, binaries, moduleRoot, purpose) {
88392
88778
  ...flags,
88393
88779
  ...target.prefix ? ["-include", staged(target.prefix)] : [],
88394
88780
  "-Os",
88781
+ ...purpose === "objects" ? ["-g0"] : [],
88395
88782
  "-c",
88396
88783
  staged(file),
88397
88784
  "-o",
@@ -122771,7 +123158,7 @@ var init_nitro_superset = __esm({
122771
123158
  init_nitroContract();
122772
123159
  init_swift_standin_digest();
122773
123160
  NITRO_SUPERSET_ENTRY_NAME = "superset";
122774
- NITRO_COMPILER_DIGEST = true ? "d233e4dbe512fd98c3952dbb73147bb1a4402279259009f8b91cf67debb0d9f0" : nitroCompilerSourceDigest(__sootsim_import_meta_dirname, STANDIN_SOURCE_DIGEST2);
123161
+ NITRO_COMPILER_DIGEST = true ? "2b748ed5d0850b2ccb4eb8842bbcfdec5254b56ef63760418c6e2795f3b68e10" : nitroCompilerSourceDigest(__sootsim_import_meta_dirname, STANDIN_SOURCE_DIGEST2);
122775
123162
  nitroSupersetLock = parseLock(nitro_superset_lock_default);
122776
123163
  nitroSupersetKey = (inputs2) => nativeEntryKey({ ...inputs2, compiler: NITRO_COMPILER_DIGEST });
122777
123164
  published3 = /* @__PURE__ */ new Map();