peachsim 0.1.2596 → 0.1.2598

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 (140) 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 +969 -423
  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-WGTQK4JN.mjs → acorn-KBQ33SLR.mjs} +3 -3
  27. package/dist-lib/esm-chunks/{chunk-ZVBBDMPW.mjs → chunk-37W5LRA3.mjs} +1 -1
  28. package/dist-lib/esm-chunks/{chunk-DY6PUVXF.mjs → chunk-54WIQP6N.mjs} +1 -1
  29. package/dist-lib/esm-chunks/{chunk-WPX7HLFR.mjs → chunk-B2DVYADK.mjs} +7 -6
  30. package/dist-lib/esm-chunks/{chunk-SPKD6UYK.mjs → chunk-C4NFHNW5.mjs} +3 -3
  31. package/dist-lib/esm-chunks/{chunk-BNXCKF2B.mjs → chunk-CQHPA2VS.mjs} +1 -1
  32. package/dist-lib/esm-chunks/{chunk-C3C5OJG4.mjs → chunk-FKSCP3EF.mjs} +5 -5
  33. package/dist-lib/esm-chunks/{chunk-4UUWP6NP.mjs → chunk-I7POLNK4.mjs} +1 -1
  34. package/dist-lib/esm-chunks/{chunk-SYCOZ2CT.mjs → chunk-IB7EAJUO.mjs} +4 -4
  35. package/dist-lib/esm-chunks/{chunk-4MMPS5YL.mjs → chunk-J2DSD5ZC.mjs} +1 -1
  36. package/dist-lib/esm-chunks/{chunk-HZPXGVY4.mjs → chunk-J5SU2CGP.mjs} +1 -1
  37. package/dist-lib/esm-chunks/{chunk-3C2YVQZH.mjs → chunk-J6DI5ND2.mjs} +1 -1
  38. package/dist-lib/esm-chunks/{chunk-UCIOSXXU.mjs → chunk-NTVANYOL.mjs} +963 -490
  39. package/dist-lib/esm-chunks/{chunk-FDMS7FWE.mjs → chunk-OQYMCUNM.mjs} +2 -2
  40. package/dist-lib/esm-chunks/{chunk-LZF4BVEY.mjs → chunk-PZDQUPFX.mjs} +1 -1
  41. package/dist-lib/esm-chunks/{chunk-BAEOHCN5.mjs → chunk-QPRSUFLC.mjs} +1 -1
  42. package/dist-lib/esm-chunks/{chunk-TNZG7SFG.mjs → chunk-SYTFW2W6.mjs} +1 -1
  43. package/dist-lib/esm-chunks/{chunk-ISZE675P.mjs → chunk-SYWNAT3Z.mjs} +1 -1
  44. package/dist-lib/esm-chunks/{chunk-TILPABC4.mjs → chunk-T2I3EXKH.mjs} +1 -1
  45. package/dist-lib/esm-chunks/{chunk-5NZPSLS4.mjs → chunk-U3X55VHR.mjs} +1 -1
  46. package/dist-lib/esm-chunks/{chunk-4PMXT2UO.mjs → chunk-UCLJ5PDG.mjs} +1 -1
  47. package/dist-lib/esm-chunks/{chunk-QEGUUPRI.mjs → chunk-UKE7QBBD.mjs} +1 -1
  48. package/dist-lib/esm-chunks/{chunk-IGMABYTC.mjs → chunk-Z7BYGNNX.mjs} +1 -1
  49. package/dist-lib/esm-chunks/{metro-layout-parser-QNM3HYV7.mjs → metro-layout-parser-SOAXKW5M.mjs} +3 -3
  50. package/dist-lib/esm-chunks/{swift-package-prebuilt-BXXQB7Q2.mjs → swift-package-prebuilt-KK3VRVOF.mjs} +10 -10
  51. package/dist-lib/esm-chunks/{swift-sdk-app-module-FKL3X2ZC.mjs → swift-sdk-app-module-TEOC7LDK.mjs} +126 -56
  52. package/dist-lib/esm-chunks/{swift-sdk-image-CCVWDFHB.mjs → swift-sdk-image-ZBA4EYBW.mjs} +14 -14
  53. package/dist-lib/esm-chunks/{swift-sdk-image-producer-OTMZVBDN.mjs → swift-sdk-image-producer-3VLSKMBD.mjs} +4 -4
  54. package/dist-lib/expo-swift-bundle.cjs +968 -422
  55. package/dist-lib/expo-swift-metadata.cjs +1 -1
  56. package/dist-lib/expo-swift-metadata.mjs +7 -7
  57. package/dist-lib/home-paths.cjs +1 -1
  58. package/dist-lib/host/bridge-host.cjs +969 -423
  59. package/dist-lib/host/fetch-proxy-handler.cjs +36 -6
  60. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  61. package/dist-lib/host/fetch-proxy-overrides.mjs +2 -2
  62. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  63. package/dist-lib/host/websocket-proxy.cjs +1 -1
  64. package/dist-lib/index.cjs +1 -1
  65. package/dist-lib/kotlin-host.cjs +1 -1
  66. package/dist-lib/menu.cjs +1 -1
  67. package/dist-lib/menu.mjs +3 -3
  68. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  69. package/dist-lib/metro-fingerprint-registry.mjs +3 -3
  70. package/dist-lib/metro-production-bundle.cjs +1 -1
  71. package/dist-lib/metro-production-bundle.mjs +4 -4
  72. package/dist-lib/native-app-identity-project.cjs +34 -4
  73. package/dist-lib/native-app-identity-project.mjs +16 -16
  74. package/dist-lib/native-app-identity.cjs +1 -1
  75. package/dist-lib/native-app-identity.mjs +6 -6
  76. package/dist-lib/native-firebase-metadata.cjs +1 -1
  77. package/dist-lib/native-firebase-metadata.mjs +3 -3
  78. package/dist-lib/pdfium-raster.cjs +1 -1
  79. package/dist-lib/pdfium-raster.mjs +2 -2
  80. package/dist-lib/plist.cjs +1 -1
  81. package/dist-lib/plist.mjs +3 -3
  82. package/dist-lib/profiles.cjs +1 -1
  83. package/dist-lib/public-brand.cjs +1 -1
  84. package/dist-lib/public-origins-lib-esm.json +81 -81
  85. package/dist-lib/public-origins-lib.json +69 -69
  86. package/dist-lib/react-native-host-modules.cjs +1 -1
  87. package/dist-lib/react-native-host-modules.mjs +2 -2
  88. package/dist-lib/reap-browser.cjs +1 -1
  89. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  90. package/dist-lib/sdk.cjs +1 -1
  91. package/dist-lib/sdk.mjs +8 -8
  92. package/dist-lib/skills.cjs +970 -424
  93. package/dist-lib/swift-compile.cjs +966 -420
  94. package/dist-lib/swift-compile.mjs +10 -10
  95. package/dist-lib/swift-package.cjs +1 -1
  96. package/dist-lib/swift-package.mjs +3 -3
  97. package/dist-lib/swift-submit.cjs +1 -1
  98. package/dist-lib/swift-submit.mjs +6 -6
  99. package/dist-lib/swift-svg-raster.cjs +1 -1
  100. package/dist-lib/swift-svg-raster.mjs +2 -2
  101. package/dist-lib/swift-toolchain.cjs +1 -1
  102. package/dist-lib/swift.cjs +1 -1
  103. package/dist-lib/vendor/@peculiar/x509.cjs +1 -1
  104. package/dist-lib/vendor/@ruby/prism/src/nodes.js.cjs +1 -1
  105. package/dist-lib/vendor/@ruby/prism/src/parsePrism.js.cjs +1 -1
  106. package/dist-lib/vendor/@xmldom/xmldom.cjs +1 -1
  107. package/dist-lib/vendor/acorn.cjs +1 -1
  108. package/dist-lib/vendor/bplist-parser.cjs +1 -1
  109. package/dist-lib/vendor/ignore.cjs +1 -1
  110. package/dist-lib/vendor/magic-string.cjs +1 -1
  111. package/dist-lib/vendor/plist.cjs +1 -1
  112. package/dist-lib/vendor/smol-toml.cjs +1 -1
  113. package/dist-lib/vendor/stream-json.cjs +1 -1
  114. package/dist-lib/vendor/sucrase/dist/index.js.cjs +1 -1
  115. package/dist-lib/vendor/sucrase/dist/parser/index.js.cjs +1 -1
  116. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/index.js.cjs +1 -1
  117. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/types.js.cjs +1 -1
  118. package/dist-lib/vendor/sucrase.cjs +1 -1
  119. package/dist-lib/vendor/terser.cjs +1 -1
  120. package/dist-lib/vendor/valibot.cjs +1 -1
  121. package/dist-lib/vendor/ws.cjs +1 -1
  122. package/dist-lib/vendor/zod.cjs +1 -1
  123. package/dist-lib/worklet-executable.cjs +1 -1
  124. package/dist-lib/worklet-executable.mjs +3 -3
  125. package/dist-types/packages/peach-engine/src/render-worker/compositor-protocol.d.ts +1 -0
  126. package/dist-types/packages/peach-engine/src/render-worker/native-hot-ops.d.ts +1 -0
  127. package/dist-types/packages/peach-engine/src/render-worker/nativeAnimMirrorContract.d.ts +0 -2
  128. package/package.json +1 -1
  129. package/src/swift-compile.ts +421 -175
  130. package/src/swift-guest-compile.ts +16 -0
  131. package/src/swift-guest-image-ledger.ts +65 -14
  132. package/src/swift-guest-link.ts +21 -0
  133. package/src/swift-guest-manifest.ts +27 -5
  134. package/src/swift-guest-source-inputs.ts +119 -14
  135. package/src/swift-sdk-app-module.ts +128 -55
  136. package/src/swift-sdk-image-wasm.ts +76 -39
  137. package/src/swift-sdk-image.ts +2 -1
  138. package/src/swift-wasm-prune.ts +282 -222
  139. package/src/wasm-optimize.ts +1 -1
  140. package/src/write-build-file.ts +9 -8
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2596 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2598 | (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;
@@ -18260,8 +18260,14 @@ var init_swift_objc_runtime = __esm({
18260
18260
 
18261
18261
  // src/write-build-file.ts
18262
18262
  function writeBuildFile(file, contents2) {
18263
- if ((0, import_node_fs21.existsSync)(file) && (typeof contents2 === "string" ? (0, import_node_fs21.readFileSync)(file, "utf8") === contents2 : (0, import_node_fs21.readFileSync)(file).equals(contents2)))
18264
- return;
18263
+ const stat = (0, import_node_fs21.statSync)(file, { throwIfNoEntry: false });
18264
+ if (stat?.isFile()) {
18265
+ if (typeof contents2 === "string") {
18266
+ if ((0, import_node_fs21.readFileSync)(file, "utf8") === contents2) return;
18267
+ } else if (stat.size === contents2.length && (0, import_node_fs21.readFileSync)(file).equals(contents2)) {
18268
+ return;
18269
+ }
18270
+ }
18265
18271
  (0, import_node_fs21.mkdirSync)(import_node_path18.default.dirname(file), { recursive: true });
18266
18272
  (0, import_node_fs21.writeFileSync)(file, contents2);
18267
18273
  }
@@ -25086,7 +25092,11 @@ function relocationEdges(bytes, segmentAddress) {
25086
25092
  const sections = wasmSections(bytes);
25087
25093
  const linking = sections.find((s) => s.name === "linking");
25088
25094
  if (!linking) throw new Error("relocation link has no linking section");
25089
- const symbols = [];
25095
+ let symKind = new Uint8Array(0);
25096
+ let symFlags = new Uint32Array(0);
25097
+ let symSegment = new Int32Array(0);
25098
+ let symOffset = new Int32Array(0);
25099
+ let symIndex = new Int32Array(0);
25090
25100
  const segmentNames = [];
25091
25101
  {
25092
25102
  const r = wasmReader(bytes, linking.start);
@@ -25094,27 +25104,31 @@ function relocationEdges(bytes, segmentAddress) {
25094
25104
  while (r.at < linking.end) {
25095
25105
  const type = r.byte();
25096
25106
  const end = r.u() + r.at;
25097
- if (type === 8)
25098
- for (let n = r.u(); n > 0; n--) {
25107
+ if (type === 8) {
25108
+ const count = r.u();
25109
+ symKind = new Uint8Array(count);
25110
+ symFlags = new Uint32Array(count);
25111
+ symSegment = new Int32Array(count).fill(-1);
25112
+ symOffset = new Int32Array(count);
25113
+ symIndex = new Int32Array(count).fill(-1);
25114
+ for (let i = 0; i < count; i++) {
25099
25115
  const kind = r.byte();
25100
25116
  const flags = r.u();
25101
- let segment3 = -1;
25102
- let offset = 0;
25103
- let index = -1;
25117
+ symKind[i] = kind;
25118
+ symFlags[i] = flags;
25104
25119
  if (kind === 0 || kind === 2 || kind === 4 || kind === 5) {
25105
- index = r.u();
25106
- if (!(flags & 16) || flags & 64) r.name();
25120
+ symIndex[i] = r.u();
25121
+ if (!(flags & 16) || flags & 64) r.skip(r.u());
25107
25122
  } else if (kind === 1) {
25108
- r.name();
25123
+ r.skip(r.u());
25109
25124
  if (!(flags & 16)) {
25110
- segment3 = r.u();
25111
- offset = r.u();
25125
+ symSegment[i] = r.u();
25126
+ symOffset[i] = r.u();
25112
25127
  r.u();
25113
25128
  }
25114
25129
  } else if (kind === 3) r.u();
25115
- symbols.push({ kind, flags, segment: segment3, offset, index });
25116
25130
  }
25117
- else if (type === 5)
25131
+ } else if (type === 5)
25118
25132
  for (let n = r.u(); n > 0; n--) {
25119
25133
  segmentNames.push(r.name());
25120
25134
  r.u();
@@ -25153,37 +25167,66 @@ function relocationEdges(bytes, segmentAddress) {
25153
25167
  const importedFunctions = readModule(bytes).importedFuncs;
25154
25168
  const data = [];
25155
25169
  const dataFunctions = [];
25156
- const code = bodyStarts.map(() => []);
25157
- const calls = bodyStarts.map(() => []);
25170
+ const bodyCount = bodyStarts.length;
25171
+ const code = Array.from({ length: bodyCount }, () => []);
25172
+ const calls = Array.from({ length: bodyCount }, () => []);
25158
25173
  for (const s of sections) {
25159
25174
  if (!s.name?.startsWith("reloc.")) continue;
25160
- const r = wasmReader(bytes, s.start);
25161
- const target = r.u();
25175
+ let cur = s.start;
25176
+ const readU = () => {
25177
+ const b0 = bytes[cur++];
25178
+ if (b0 < 128) return b0;
25179
+ let value = b0 & 127;
25180
+ let shift = 7;
25181
+ for (; ; ) {
25182
+ const byte = bytes[cur++];
25183
+ value += (byte & 127) * 2 ** shift;
25184
+ if (byte < 128) return value;
25185
+ shift += 7;
25186
+ }
25187
+ };
25188
+ const readS = () => {
25189
+ const b0 = bytes[cur++];
25190
+ if (b0 < 128) return b0 & 64 ? b0 - 128 : b0;
25191
+ let value = b0 & 127;
25192
+ let shift = 7;
25193
+ let byte = b0;
25194
+ while (byte >= 128) {
25195
+ byte = bytes[cur++];
25196
+ value += (byte & 127) * 2 ** shift;
25197
+ shift += 7;
25198
+ }
25199
+ if (byte & 64) value -= 2 ** shift;
25200
+ return value;
25201
+ };
25202
+ const target = readU();
25162
25203
  if (target !== dataIndex && target !== codeIndex) continue;
25163
25204
  let segment3 = 0;
25164
25205
  let body = 0;
25165
- for (let n = r.u(); n > 0; n--) {
25166
- const type = r.byte();
25167
- const offset = r.u();
25168
- const index = r.u();
25169
- const addend = ADDEND_RELOCATIONS.has(type) ? Number(r.s()) : 0;
25170
- const functionRelocation = FUNCTION_RELOCATIONS.has(type);
25171
- const memoryRelocation = MEMORY_RELOCATIONS.has(type);
25206
+ const isData = target === dataIndex;
25207
+ for (let n = readU(); n > 0; n--) {
25208
+ const type = bytes[cur++];
25209
+ const offset = readU();
25210
+ const index = readU();
25211
+ const bit = type < 32 ? 1 << type : 0;
25212
+ const addend = (ADDEND_RELOC_MASK & bit) !== 0 ? readS() : 0;
25213
+ const functionRelocation = (FUNCTION_RELOC_MASK & bit) !== 0;
25214
+ const memoryRelocation = (MEMORY_RELOC_MASK & bit) !== 0;
25172
25215
  if (!functionRelocation && !memoryRelocation) continue;
25173
- const symbol2 = symbols[index];
25174
- const functionReference = functionRelocation && symbol2.kind === 0;
25175
- if (symbol2.flags & 16) continue;
25176
- if (!functionReference && (!memoryRelocation || symbol2.kind !== 1 || symbol2.segment < 0))
25216
+ if (symFlags[index] & 16) continue;
25217
+ const kind = symKind[index];
25218
+ const functionReference = functionRelocation && kind === 0;
25219
+ if (!functionReference && (!memoryRelocation || kind !== 1 || symSegment[index] < 0))
25177
25220
  continue;
25178
- const to = functionReference ? symbol2.index - importedFunctions : addresses[symbol2.segment] + symbol2.offset + addend;
25179
- if (functionReference && (to < 0 || to >= bodyStarts.length)) continue;
25180
- if (target === dataIndex) {
25221
+ const to = functionReference ? symIndex[index] - importedFunctions : addresses[symSegment[index]] + symOffset[index] + addend;
25222
+ if (functionReference && (to < 0 || to >= bodyCount)) continue;
25223
+ if (isData) {
25181
25224
  while (payloads[segment3].end <= offset) segment3++;
25182
25225
  const payload = payloads[segment3];
25183
25226
  const edges = functionReference ? dataFunctions : data;
25184
25227
  edges.push(payload.address + offset - payload.start, to);
25185
25228
  } else {
25186
- while (body + 1 < bodyStarts.length && bodyStarts[body + 1] <= offset) body++;
25229
+ while (body + 1 < bodyCount && bodyStarts[body + 1] <= offset) body++;
25187
25230
  const edges = functionReference ? calls : code;
25188
25231
  edges[body].push(to);
25189
25232
  }
@@ -25239,7 +25282,7 @@ function unslottedFunctions(bytes) {
25239
25282
  const slotted = new Set([...m.slots.keys()].filter((index) => index >= m.importedFuncs));
25240
25283
  return m.bodies.length - slotted.size;
25241
25284
  }
25242
- var uleb, sleb, encodedName, section, PROCESS_EXPORTS, SWIFT_SDK_CONSTRUCTOR_LIMIT, FUNCTION_RELOCATIONS, MEMORY_RELOCATIONS, ADDEND_RELOCATIONS;
25285
+ 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;
25243
25286
  var init_swift_sdk_image_wasm = __esm({
25244
25287
  "src/swift-sdk-image-wasm.ts"() {
25245
25288
  "use strict";
@@ -25309,6 +25352,12 @@ var init_swift_sdk_image_wasm = __esm({
25309
25352
  25,
25310
25353
  27
25311
25354
  ]);
25355
+ FUNCTION_RELOC_MASK = 0;
25356
+ for (const type of FUNCTION_RELOCATIONS) FUNCTION_RELOC_MASK |= 1 << type;
25357
+ MEMORY_RELOC_MASK = 0;
25358
+ for (const type of MEMORY_RELOCATIONS) MEMORY_RELOC_MASK |= 1 << type;
25359
+ ADDEND_RELOC_MASK = 0;
25360
+ for (const type of ADDEND_RELOCATIONS) ADDEND_RELOC_MASK |= 1 << type;
25312
25361
  }
25313
25362
  });
25314
25363
 
@@ -25476,7 +25525,8 @@ function isRootSegName(name3) {
25476
25525
  return false;
25477
25526
  }
25478
25527
  function decodeRelocations(buf, sections) {
25479
- const count = sections.reduce((sum, section2) => sum + section2.count, 0);
25528
+ let count = 0;
25529
+ for (let s = 0; s < sections.length; s++) count += sections[s].count;
25480
25530
  const start = new Uint32Array(count);
25481
25531
  const end = new Uint32Array(count);
25482
25532
  const ro = new Int32Array(count);
@@ -25485,29 +25535,59 @@ function decodeRelocations(buf, sections) {
25485
25535
  const spans = [];
25486
25536
  let i = 0;
25487
25537
  let length = 0;
25488
- for (const section2 of sections) {
25489
- let cur = section2.at;
25490
- for (let k = 0; k < section2.count; k++, i++) {
25491
- start[i] = length + cur - section2.at;
25538
+ for (let s = 0; s < sections.length; s++) {
25539
+ const section2 = sections[s];
25540
+ const baseAt = section2.at;
25541
+ const sectionCount = section2.count;
25542
+ let cur = baseAt;
25543
+ for (let k = 0; k < sectionCount; k++, i++) {
25544
+ start[i] = length + cur - baseAt;
25492
25545
  const rType = buf[cur++];
25493
- const [offset, c2] = readULEB2(buf, cur);
25494
- const [symbol2, c3] = readULEB2(buf, c2);
25495
- cur = c3;
25496
- if (ADDEND_RELOCATIONS.has(rType)) {
25497
- const [value, c4] = readSLEB(buf, cur);
25546
+ let offset = buf[cur++];
25547
+ if (offset >= 128) {
25548
+ offset &= 127;
25549
+ let shift = 7;
25550
+ while (true) {
25551
+ const byte = buf[cur++];
25552
+ offset |= (byte & 127) << shift;
25553
+ if (byte < 128) break;
25554
+ shift += 7;
25555
+ }
25556
+ }
25557
+ let symbol2 = buf[cur++];
25558
+ if (symbol2 >= 128) {
25559
+ symbol2 &= 127;
25560
+ let shift = 7;
25561
+ while (true) {
25562
+ const byte = buf[cur++];
25563
+ symbol2 |= (byte & 127) << shift;
25564
+ if (byte < 128) break;
25565
+ shift += 7;
25566
+ }
25567
+ }
25568
+ if (rType < 32 && (ADDEND_RELOC_MASK2 & 1 << rType) !== 0) {
25569
+ let byte = buf[cur++];
25570
+ let value = byte & 127;
25571
+ let shift = 7;
25572
+ while (byte >= 128) {
25573
+ byte = buf[cur++];
25574
+ value |= (byte & 127) << shift;
25575
+ shift += 7;
25576
+ }
25577
+ if (shift < 32 && (byte & 64) !== 0) value |= ~0 << shift;
25498
25578
  addend[i] = value;
25499
- cur = c4;
25500
25579
  }
25501
25580
  ro[i] = offset;
25502
25581
  rs[i] = symbol2;
25503
- end[i] = length + cur - section2.at;
25582
+ end[i] = length + cur - baseAt;
25504
25583
  }
25505
- spans.push([section2.at, cur]);
25506
- length += cur - section2.at;
25584
+ spans.push([baseAt, cur]);
25585
+ length += cur - baseAt;
25507
25586
  }
25508
25587
  const bytes = new Uint8Array(length);
25509
25588
  let at = 0;
25510
- for (const [from, to] of spans) {
25589
+ for (let s = 0; s < spans.length; s++) {
25590
+ const [from, to] = spans[s];
25511
25591
  bytes.set(buf.subarray(from, to), at);
25512
25592
  at += to - from;
25513
25593
  }
@@ -25672,6 +25752,27 @@ function patchSwiftrtObject(src) {
25672
25752
  function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
25673
25753
  const rawBuf = Buffer.isBuffer(buf) ? buf : Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
25674
25754
  let pos = 8;
25755
+ let cur = 8;
25756
+ const readU = () => {
25757
+ const b0 = buf[cur++];
25758
+ if (b0 < 128) return b0;
25759
+ let res = b0 & 127;
25760
+ let shift = 7;
25761
+ while (true) {
25762
+ const byte = buf[cur++];
25763
+ res |= (byte & 127) << shift;
25764
+ if (byte < 128) return res;
25765
+ shift += 7;
25766
+ }
25767
+ };
25768
+ const skipU = () => {
25769
+ while (buf[cur++] >= 128) {
25770
+ }
25771
+ };
25772
+ const skipS = () => {
25773
+ while (buf[cur++] >= 128) {
25774
+ }
25775
+ };
25675
25776
  let numImportFuncs = 0;
25676
25777
  let importsDlsym = false;
25677
25778
  const importFuncNames = [];
@@ -25700,150 +25801,122 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
25700
25801
  const dataRelocSections = [];
25701
25802
  while (pos < buf.length) {
25702
25803
  const id = buf[pos++];
25703
- const [sz, p] = readULEB2(buf, pos);
25804
+ cur = pos;
25805
+ const sz = readU();
25806
+ const p = cur;
25704
25807
  const end = p + sz;
25705
25808
  if (id === 2) {
25706
- let [cnt, cp] = readULEB2(buf, p);
25809
+ const cnt = readU();
25707
25810
  for (let i = 0; i < cnt; i++) {
25708
- const [mLen, m2] = readULEB2(buf, cp);
25709
- const mName = rawBuf.toString("utf8", m2, m2 + mLen);
25710
- cp = m2 + mLen;
25711
- const [fLen, f2] = readULEB2(buf, cp);
25712
- const fName = rawBuf.toString("utf8", f2, f2 + fLen);
25713
- cp = f2 + fLen;
25714
- const kind = buf[cp++];
25811
+ const mLen = readU();
25812
+ const mName = rawBuf.toString("utf8", cur, cur + mLen);
25813
+ cur += mLen;
25814
+ const fLen = readU();
25815
+ const fName = rawBuf.toString("utf8", cur, cur + fLen);
25816
+ cur += fLen;
25817
+ const kind = buf[cur++];
25715
25818
  if (kind === 0) {
25716
- const [, c2] = readULEB2(buf, cp);
25717
- cp = c2;
25819
+ skipU();
25718
25820
  importFuncNames.push(fName);
25719
25821
  importFuncModules.push(mName);
25720
25822
  if (mName === "env" && fName === "dlsym") importsDlsym = true;
25721
25823
  numImportFuncs++;
25722
25824
  } else if (kind === 1) {
25723
- cp++;
25724
- const [fl, c2] = readULEB2(buf, cp);
25725
- cp = c2;
25726
- const [, c3] = readULEB2(buf, cp);
25727
- cp = c3;
25728
- if (fl & 1) {
25729
- const [, c4] = readULEB2(buf, cp);
25730
- cp = c4;
25731
- }
25825
+ cur++;
25826
+ const fl = readU();
25827
+ skipU();
25828
+ if (fl & 1) skipU();
25732
25829
  importTableNames.push(fName);
25733
25830
  } else if (kind === 2) {
25734
- const [fl, c2] = readULEB2(buf, cp);
25735
- cp = c2;
25736
- const [, c3] = readULEB2(buf, cp);
25737
- cp = c3;
25738
- if (fl & 1) {
25739
- const [, c4] = readULEB2(buf, cp);
25740
- cp = c4;
25741
- }
25831
+ const fl = readU();
25832
+ skipU();
25833
+ if (fl & 1) skipU();
25742
25834
  } else if (kind === 3) {
25743
- cp += 2;
25835
+ cur += 2;
25744
25836
  importGlobalNames.push(fName);
25745
25837
  } else if (kind === 4) {
25746
- cp++;
25747
- const [, c2] = readULEB2(buf, cp);
25748
- cp = c2;
25838
+ cur++;
25839
+ skipU();
25749
25840
  importEventNames.push(fName);
25750
25841
  }
25751
25842
  }
25752
25843
  } else if (id === 10) {
25753
25844
  codeStart = p;
25754
- let [cnt, cp] = readULEB2(buf, p);
25845
+ const cnt = readU();
25755
25846
  for (let i = 0; i < cnt; i++) {
25756
- const st = cp - codeStart;
25757
- const [bLen, b2] = readULEB2(buf, cp);
25758
- cp = b2 + bLen;
25847
+ const st = cur - codeStart;
25848
+ const bLen = readU();
25849
+ cur += bLen;
25759
25850
  fStarts.push(st);
25760
- fEnds.push(cp - codeStart);
25851
+ fEnds.push(cur - codeStart);
25761
25852
  }
25762
25853
  } else if (id === 11) {
25763
25854
  dataStart = p;
25764
- let [cnt, cp] = readULEB2(buf, p);
25855
+ const cnt = readU();
25765
25856
  for (let i = 0; i < cnt; i++) {
25766
- const st = cp - dataStart;
25767
- const [mode, m2] = readULEB2(buf, cp);
25768
- cp = m2;
25769
- if (mode === 2) {
25770
- const [, m3] = readULEB2(buf, cp);
25771
- cp = m3;
25772
- }
25857
+ const st = cur - dataStart;
25858
+ const mode = readU();
25859
+ if (mode === 2) skipU();
25773
25860
  if (mode === 0 || mode === 2) {
25774
- const op = buf[cp++];
25775
- if (op === 65 || op === 66) {
25776
- const [, m4] = readSLEB(buf, cp);
25777
- cp = m4;
25778
- } else if (op === 35) {
25779
- const [, m4] = readULEB2(buf, cp);
25780
- cp = m4;
25781
- }
25782
- cp++;
25861
+ const op = buf[cur++];
25862
+ if (op === 65 || op === 66) skipS();
25863
+ else if (op === 35) skipU();
25864
+ cur++;
25783
25865
  }
25784
- const [dLen, d2] = readULEB2(buf, cp);
25785
- sPayloadStarts.push(d2 - dataStart);
25786
- cp = d2 + dLen;
25866
+ const dLen = readU();
25867
+ sPayloadStarts.push(cur - dataStart);
25868
+ cur += dLen;
25787
25869
  sStarts.push(st);
25788
- sEnds.push(cp - dataStart);
25870
+ sEnds.push(cur - dataStart);
25789
25871
  }
25790
25872
  } else if (id === 0) {
25791
- const [nLen, np] = readULEB2(buf, p);
25792
- const name3 = rawBuf.toString("utf8", np, np + nLen);
25793
- const cp = np + nLen;
25873
+ const nLen = readU();
25874
+ const name3 = rawBuf.toString("utf8", cur, cur + nLen);
25875
+ cur += nLen;
25794
25876
  if (name3 === "linking") {
25795
- let [, lp] = readULEB2(buf, cp);
25796
- while (lp < end) {
25797
- const subId = buf[lp++];
25798
- const [subLen, sp] = readULEB2(buf, lp);
25799
- const subEnd = sp + subLen;
25877
+ skipU();
25878
+ while (cur < end) {
25879
+ const subId = buf[cur++];
25880
+ const subLen = readU();
25881
+ const subEnd = cur + subLen;
25800
25882
  if (subId === 5) {
25801
- const [cnt, p2] = readULEB2(buf, sp);
25802
- let cur = p2;
25883
+ const cnt = readU();
25803
25884
  for (let i = 0; i < cnt; i++) {
25804
- const [sLen, s2] = readULEB2(buf, cur);
25805
- segNames.push(rawBuf.toString("utf8", s2, s2 + sLen));
25806
- cur = s2 + sLen;
25807
- const [, s3] = readULEB2(buf, cur);
25808
- const [fl, s4] = readULEB2(buf, s3);
25809
- segFlags.push(fl);
25810
- cur = s4;
25885
+ const sLen = readU();
25886
+ segNames.push(rawBuf.toString("utf8", cur, cur + sLen));
25887
+ cur += sLen;
25888
+ skipU();
25889
+ segFlags.push(readU());
25811
25890
  }
25812
25891
  } else if (subId === 6) {
25813
- const [cnt, p2] = readULEB2(buf, sp);
25814
- let cur = p2;
25892
+ const cnt = readU();
25815
25893
  for (let i = 0; i < cnt; i++) {
25816
- const [, s2] = readULEB2(buf, cur);
25817
- const [symIdx, s3] = readULEB2(buf, s2);
25818
- initFuncs.push(symIdx);
25819
- cur = s3;
25894
+ skipU();
25895
+ initFuncs.push(readU());
25820
25896
  }
25821
25897
  } else if (subId === 8) {
25822
- const [cnt, p2] = readULEB2(buf, sp);
25898
+ const cnt = readU();
25823
25899
  symKind = new Uint8Array(cnt);
25824
25900
  symFlags = new Uint32Array(cnt);
25825
25901
  symElemIdx = new Int32Array(cnt).fill(-1);
25826
- symOff = new Int32Array(cnt).fill(0);
25827
- symSz = new Int32Array(cnt).fill(0);
25828
- let cur = p2;
25902
+ symOff = new Int32Array(cnt);
25903
+ symSz = new Int32Array(cnt);
25829
25904
  for (let i = 0; i < cnt; i++) {
25830
25905
  const kind = buf[cur++];
25831
25906
  if (symbolFlagOffsets) symbolFlagOffsets[i] = cur;
25832
- const [fl, c2] = readULEB2(buf, cur);
25833
- cur = c2;
25907
+ const fl = readU();
25834
25908
  symKind[i] = kind;
25835
25909
  symFlags[i] = fl;
25836
25910
  const isUndef = (fl & 16) !== 0;
25837
25911
  const isExplicitName = (fl & 64) !== 0;
25838
25912
  if (kind === 0 || kind === 2 || kind === 4 || kind === 5) {
25839
- const [el, c3] = readULEB2(buf, cur);
25840
- cur = c3;
25913
+ const el = readU();
25841
25914
  if (!isUndef && kind === 0) symElemIdx[i] = el;
25842
25915
  let sName = "";
25843
25916
  if (!isUndef || isExplicitName) {
25844
- const [sLen, c4] = readULEB2(buf, cur);
25845
- sName = rawBuf.toString("utf8", c4, c4 + sLen);
25846
- cur = c4 + sLen;
25917
+ const sLen = readU();
25918
+ sName = rawBuf.toString("utf8", cur, cur + sLen);
25919
+ cur += sLen;
25847
25920
  } else if (kind === 0) {
25848
25921
  sName = importFuncNames[el] ?? "";
25849
25922
  } else if (kind === 2) {
@@ -25857,33 +25930,28 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
25857
25930
  hostImportNames.add(sName);
25858
25931
  symNames.push(sName);
25859
25932
  } else if (kind === 1) {
25860
- const [sLen, c3] = readULEB2(buf, cur);
25861
- const sName = rawBuf.toString("utf8", c3, c3 + sLen);
25862
- cur = c3 + sLen;
25933
+ const sLen = readU();
25934
+ const sName = rawBuf.toString("utf8", cur, cur + sLen);
25935
+ cur += sLen;
25863
25936
  if (!isUndef) {
25864
- const [segIdx, c4] = readULEB2(buf, cur);
25865
- const [sOff, c5] = readULEB2(buf, c4);
25866
- const [sSz, c6] = readULEB2(buf, c5);
25867
- cur = c6;
25868
- symElemIdx[i] = segIdx;
25869
- symOff[i] = sOff;
25870
- symSz[i] = sSz;
25937
+ symElemIdx[i] = readU();
25938
+ symOff[i] = readU();
25939
+ symSz[i] = readU();
25871
25940
  }
25872
25941
  symNames.push(sName);
25873
25942
  } else if (kind === 3) {
25874
- const [, c3] = readULEB2(buf, cur);
25875
- cur = c3;
25943
+ skipU();
25876
25944
  symNames.push("");
25877
25945
  }
25878
25946
  }
25879
25947
  }
25880
- lp = subEnd;
25948
+ cur = subEnd;
25881
25949
  }
25882
25950
  } else if (name3 === "reloc.CODE" || name3 === "reloc.DATA") {
25883
- const [, r1] = readULEB2(buf, cp);
25884
- const [count, at] = readULEB2(buf, r1);
25951
+ skipU();
25952
+ const count = readU();
25885
25953
  (name3 === "reloc.DATA" ? dataRelocSections : codeRelocSections).push({
25886
- at,
25954
+ at: cur,
25887
25955
  count
25888
25956
  });
25889
25957
  }
@@ -25936,40 +26004,63 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
25936
26004
  segTopSyms.set(segIdx, dedupTop);
25937
26005
  }
25938
26006
  }
25939
- const funcRelocs = Array.from({ length: fEnds.length }, () => []);
25940
- const rawCode = decodeRelocations(buf, fEnds.length > 0 ? codeRelocSections : []);
26007
+ const funcCount = fEnds.length;
26008
+ const funcRelocs = Array.from({ length: funcCount }, () => []);
26009
+ const rawCode = decodeRelocations(buf, funcCount > 0 ? codeRelocSections : []);
25941
26010
  const codeRelocs = { ...rawCode, funcIdx: new Uint32Array(rawCode.count) };
26011
+ let fCursor = 0;
26012
+ let prevCodeRo = -1;
25942
26013
  for (let i = 0; i < codeRelocs.count; i++) {
25943
26014
  const ro = codeRelocs.ro[i];
25944
- let lo = 0;
25945
- let hi = fEnds.length - 1;
25946
- while (lo < hi) {
25947
- const mid = lo + hi >> 1;
25948
- if (fEnds[mid] <= ro) lo = mid + 1;
25949
- else hi = mid;
26015
+ let lo;
26016
+ if (ro >= prevCodeRo) {
26017
+ while (fCursor < funcCount - 1 && fEnds[fCursor] <= ro) fCursor++;
26018
+ lo = fCursor;
26019
+ } else {
26020
+ lo = 0;
26021
+ let hi = funcCount - 1;
26022
+ while (lo < hi) {
26023
+ const mid = lo + hi >> 1;
26024
+ if (fEnds[mid] <= ro) lo = mid + 1;
26025
+ else hi = mid;
26026
+ }
26027
+ fCursor = lo;
25950
26028
  }
26029
+ prevCodeRo = ro;
25951
26030
  if (codeRelocs.bytes[codeRelocs.start[i]] !== 6)
25952
26031
  funcRelocs[lo].push(codeRelocs.rs[i]);
25953
26032
  codeRelocs.funcIdx[i] = lo;
25954
26033
  }
25955
- const segRelocs = Array.from({ length: segNames.length }, () => []);
26034
+ const segCount = segNames.length;
26035
+ const segRelocs = Array.from({ length: segCount }, () => []);
25956
26036
  const symDataRelocs = /* @__PURE__ */ new Map();
25957
26037
  const rawData = decodeRelocations(buf, sEnds.length > 0 ? dataRelocSections : []);
25958
26038
  const dataSegIdx = new Uint32Array(rawData.count);
25959
26039
  const dataOffInSeg = new Int32Array(rawData.count);
25960
26040
  const dataOwnerSymIdx = new Int32Array(rawData.count);
25961
26041
  let kept = 0;
26042
+ let sCursor = 0;
26043
+ let prevDataRo = -1;
26044
+ const sEndLast = sEnds.length - 1;
25962
26045
  for (let i = 0; i < rawData.count; i++) {
25963
26046
  const ro = rawData.ro[i];
25964
26047
  const rs = rawData.rs[i];
25965
- let lo = 0;
25966
- let hi = sEnds.length - 1;
25967
- while (lo < hi) {
25968
- const mid = lo + hi >> 1;
25969
- if (sEnds[mid] <= ro) lo = mid + 1;
25970
- else hi = mid;
26048
+ let lo;
26049
+ if (ro >= prevDataRo) {
26050
+ while (sCursor < sEndLast && sEnds[sCursor] <= ro) sCursor++;
26051
+ lo = sCursor;
26052
+ } else {
26053
+ lo = 0;
26054
+ let hi = sEndLast;
26055
+ while (lo < hi) {
26056
+ const mid = lo + hi >> 1;
26057
+ if (sEnds[mid] <= ro) lo = mid + 1;
26058
+ else hi = mid;
26059
+ }
26060
+ sCursor = lo;
25971
26061
  }
25972
- if (lo >= segRelocs.length) continue;
26062
+ prevDataRo = ro;
26063
+ if (lo >= segCount) continue;
25973
26064
  const offInSeg = ro - (sPayloadStarts[lo] ?? 0);
25974
26065
  let ownerSymIdx = -1;
25975
26066
  const topList = segTopSyms.get(lo);
@@ -26116,74 +26207,78 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
26116
26207
  const conformanceProtocols = /* @__PURE__ */ new Map();
26117
26208
  const objcCategoryTargets = [];
26118
26209
  if (isDist) {
26119
- const relocAt = /* @__PURE__ */ new Map();
26120
- for (let i = 0; i < dataRelocs.count; i++) {
26121
- relocAt.set(`${dataRelocs.segIdx[i]}:${dataRelocs.offInSeg[i]}`, {
26122
- rs: dataRelocs.rs[i],
26123
- addend: dataRelocs.addend[i]
26124
- });
26125
- }
26126
26210
  const confSegs = /* @__PURE__ */ new Set();
26127
26211
  let hasCatsSeg = false;
26128
26212
  for (let i = 0; i < segNames.length; i++) {
26129
26213
  if (segNames[i] === "swift5_protocol_conformances") confSegs.add(i);
26130
26214
  else if (segNames[i] === "__objc_cats") hasCatsSeg = true;
26131
26215
  }
26132
- if (confSegs.size > 0) {
26133
- const segOffToMpSym = /* @__PURE__ */ new Map();
26134
- for (let i = 0; i < symKind.length; i++) {
26135
- if (symKind[i] === 1 && (symFlags[i] & 16) === 0 && symElemIdx[i] >= 0 && symNames[i].startsWith("$s") && symNames[i].endsWith("Mp")) {
26136
- segOffToMpSym.set(`${symElemIdx[i]}:${symOff[i]}`, symNames[i]);
26137
- }
26138
- }
26139
- const dv = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
26216
+ if (confSegs.size > 0 || hasCatsSeg) {
26217
+ const relocKey = (seg, off) => seg * 4294967296 + (off >>> 0);
26218
+ const relocAt = /* @__PURE__ */ new Map();
26140
26219
  for (let i = 0; i < dataRelocs.count; i++) {
26141
- if (!confSegs.has(dataRelocs.segIdx[i])) continue;
26142
- const mcIdx = dataRelocs.rs[i];
26143
- if (symKind[mcIdx] !== 1 || (symFlags[mcIdx] & 16) !== 0 || symElemIdx[mcIdx] < 0) {
26144
- continue;
26220
+ relocAt.set(relocKey(dataRelocs.segIdx[i], dataRelocs.offInSeg[i]), i);
26221
+ }
26222
+ if (confSegs.size > 0) {
26223
+ const segOffToMpSym = /* @__PURE__ */ new Map();
26224
+ for (let i = 0; i < symKind.length; i++) {
26225
+ if (symKind[i] === 1 && (symFlags[i] & 16) === 0 && symElemIdx[i] >= 0 && symNames[i].startsWith("$s") && symNames[i].endsWith("Mp")) {
26226
+ segOffToMpSym.set(relocKey(symElemIdx[i], symOff[i]), symNames[i]);
26227
+ }
26145
26228
  }
26146
- const mcSeg = symElemIdx[mcIdx];
26147
- const mcOff = symOff[mcIdx];
26148
- const pr = relocAt.get(`${mcSeg}:${mcOff}`);
26149
- let mp = "";
26150
- if (pr) {
26151
- const raw2 = symNames[pr.rs];
26152
- const stripped2 = raw2.startsWith(".Lgot.") ? raw2.slice(6) : raw2;
26153
- if (stripped2.startsWith("$s") && stripped2.endsWith("Mp")) {
26154
- mp = stripped2;
26155
- } else if (symKind[pr.rs] === 3 || stripped2 === "") {
26156
- mp = segOffToMpSym.get(`${mcSeg}:${pr.addend}`) ?? "";
26229
+ const dv = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
26230
+ for (let i = 0; i < dataRelocs.count; i++) {
26231
+ if (!confSegs.has(dataRelocs.segIdx[i])) continue;
26232
+ const mcIdx = dataRelocs.rs[i];
26233
+ if (symKind[mcIdx] !== 1 || (symFlags[mcIdx] & 16) !== 0 || symElemIdx[mcIdx] < 0) {
26234
+ continue;
26157
26235
  }
26158
- } else {
26159
- const fileOff = dataStart + sPayloadStarts[mcSeg] + mcOff;
26160
- if (fileOff + 4 <= buf.length) {
26161
- const delta = dv.getInt32(fileOff, true);
26162
- mp = segOffToMpSym.get(`${mcSeg}:${mcOff + delta}`) ?? segOffToMpSym.get(`${mcSeg}:${mcOff + (delta & ~1)}`) ?? "";
26236
+ const mcSeg = symElemIdx[mcIdx];
26237
+ const mcOff = symOff[mcIdx];
26238
+ const prIdx = relocAt.get(relocKey(mcSeg, mcOff));
26239
+ let mp = "";
26240
+ if (prIdx !== void 0) {
26241
+ const prRs = dataRelocs.rs[prIdx];
26242
+ const raw2 = symNames[prRs];
26243
+ const stripped2 = raw2.startsWith(".Lgot.") ? raw2.slice(6) : raw2;
26244
+ if (stripped2.startsWith("$s") && stripped2.endsWith("Mp")) {
26245
+ mp = stripped2;
26246
+ } else if (symKind[prRs] === 3 || stripped2 === "") {
26247
+ mp = segOffToMpSym.get(relocKey(mcSeg, dataRelocs.addend[prIdx])) ?? "";
26248
+ }
26249
+ } else {
26250
+ const fileOff = dataStart + sPayloadStarts[mcSeg] + mcOff;
26251
+ if (fileOff + 4 <= buf.length) {
26252
+ const delta = dv.getInt32(fileOff, true);
26253
+ mp = segOffToMpSym.get(relocKey(mcSeg, mcOff + delta)) ?? segOffToMpSym.get(relocKey(mcSeg, mcOff + (delta & ~1))) ?? "";
26254
+ }
26163
26255
  }
26256
+ if (mp) conformanceProtocols.set(mcIdx, mp);
26164
26257
  }
26165
- if (mp) conformanceProtocols.set(mcIdx, mp);
26166
26258
  }
26167
- }
26168
- if (hasCatsSeg) {
26169
- const seenClasses = /* @__PURE__ */ new Set();
26170
- for (let i = 0; i < symKind.length; i++) {
26171
- if (symKind[i] !== 1 || (symFlags[i] & 16) !== 0 || symElemIdx[i] < 0 || segNames[symElemIdx[i]] !== "__objc_cats" || !symNames[i].startsWith(".objc_category_")) {
26172
- continue;
26173
- }
26174
- const cSeg = symElemIdx[i];
26175
- const cOff = symOff[i];
26176
- const cr = relocAt.get(`${cSeg}:${cOff + 8}`);
26177
- if (cr && symKind[cr.rs] === 1 && (symFlags[cr.rs] & 16) === 0 && symElemIdx[cr.rs] >= 0) {
26178
- const tSeg = symElemIdx[cr.rs];
26179
- const strOff = dataStart + sPayloadStarts[tSeg] + symOff[cr.rs] + cr.addend;
26180
- let sEnd = strOff;
26181
- while (sEnd < buf.length && buf[sEnd] !== 0) sEnd++;
26182
- if (sEnd > strOff) {
26183
- const clsName = Buffer.from(buf.subarray(strOff, sEnd)).toString("utf8");
26184
- if (!seenClasses.has(clsName)) {
26185
- seenClasses.add(clsName);
26186
- objcCategoryTargets.push(clsName);
26259
+ if (hasCatsSeg) {
26260
+ const seenClasses = /* @__PURE__ */ new Set();
26261
+ for (let i = 0; i < symKind.length; i++) {
26262
+ if (symKind[i] !== 1 || (symFlags[i] & 16) !== 0 || symElemIdx[i] < 0 || segNames[symElemIdx[i]] !== "__objc_cats" || !symNames[i].startsWith(".objc_category_")) {
26263
+ continue;
26264
+ }
26265
+ const cSeg = symElemIdx[i];
26266
+ const cOff = symOff[i];
26267
+ const crIdx = relocAt.get(relocKey(cSeg, cOff + 8));
26268
+ if (crIdx !== void 0) {
26269
+ const crRs = dataRelocs.rs[crIdx];
26270
+ if (symKind[crRs] === 1 && (symFlags[crRs] & 16) === 0 && symElemIdx[crRs] >= 0) {
26271
+ const tSeg = symElemIdx[crRs];
26272
+ const strOff = dataStart + sPayloadStarts[tSeg] + symOff[crRs] + dataRelocs.addend[crIdx];
26273
+ let sEnd = strOff;
26274
+ while (sEnd < buf.length && buf[sEnd] !== 0) sEnd++;
26275
+ if (sEnd > strOff) {
26276
+ const clsName = rawBuf.toString("utf8", strOff, sEnd);
26277
+ if (!seenClasses.has(clsName)) {
26278
+ seenClasses.add(clsName);
26279
+ objcCategoryTargets.push(clsName);
26280
+ }
26281
+ }
26187
26282
  }
26188
26283
  }
26189
26284
  }
@@ -27396,7 +27491,9 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
27396
27491
  return true;
27397
27492
  };
27398
27493
  const writePrunedObject = (obj, outFile) => {
27399
- const buf = new Uint8Array(import_node_fs29.default.readFileSync(obj.file));
27494
+ const cached2 = objectBytes.get(obj);
27495
+ const buf = cached2 ? new Uint8Array(cached2) : new Uint8Array(import_node_fs29.default.readFileSync(obj.file));
27496
+ const rawBuf = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
27400
27497
  const inputSha256 = link ? (0, import_node_crypto14.createHash)("sha256").update(buf).digest("hex") : "";
27401
27498
  const fLive = liveFuncs.get(obj);
27402
27499
  const sLive = liveSegs.get(obj);
@@ -27488,7 +27585,7 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
27488
27585
  const end = p + sz;
27489
27586
  if (id === 0) {
27490
27587
  const [nLen, np] = readULEB2(buf, p);
27491
- const name3 = Buffer.from(buf.subarray(np, np + nLen)).toString("utf8");
27588
+ const name3 = rawBuf.toString("utf8", np, np + nLen);
27492
27589
  const cp = np + nLen;
27493
27590
  if (name3 === "linking") {
27494
27591
  const [, lpStart] = readULEB2(buf, cp);
@@ -27750,7 +27847,7 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
27750
27847
  );
27751
27848
  import_node_fs29.default.rmSync(rspPath, { force: true });
27752
27849
  }
27753
- var import_node_child_process16, import_node_crypto14, import_node_fs29, import_node_path28, v3, WIDE_DATA_RELOCS, ROOT_SEG_PREFIXES, RECORD_SEGS, PARTITIONED_SEGS, PRUNED_SDK_ARCHIVES, OMIT_SDK_LIB_FLAGS, NEUTRALIZED_SWIFTRT_SECTIONS, relocationBytes, parsedObjectCache, PARSED_ROOTS, SWIFTUI_WRAPPER_HOST_PROTOCOLS, SWIFT_PRUNED_LINK_MAP, SWIFT_PRUNED_LINK_RESPONSE;
27850
+ var import_node_child_process16, import_node_crypto14, import_node_fs29, import_node_path28, v3, WIDE_DATA_RELOCS, ROOT_SEG_PREFIXES, RECORD_SEGS, PARTITIONED_SEGS, PRUNED_SDK_ARCHIVES, OMIT_SDK_LIB_FLAGS, NEUTRALIZED_SWIFTRT_SECTIONS, ADDEND_RELOC_MASK2, relocationBytes, parsedObjectCache, PARSED_ROOTS, SWIFTUI_WRAPPER_HOST_PROTOCOLS, SWIFT_PRUNED_LINK_MAP, SWIFT_PRUNED_LINK_RESPONSE;
27754
27851
  var init_swift_wasm_prune = __esm({
27755
27852
  "src/swift-wasm-prune.ts"() {
27756
27853
  "use strict";
@@ -27830,6 +27927,8 @@ var init_swift_wasm_prune = __esm({
27830
27927
  "swift5_reflstr",
27831
27928
  "swift5_typeref"
27832
27929
  ]);
27930
+ ADDEND_RELOC_MASK2 = 0;
27931
+ for (const type of ADDEND_RELOCATIONS) ADDEND_RELOC_MASK2 |= 1 << type;
27833
27932
  relocationBytes = (relocs, i) => relocs.bytes.subarray(relocs.start[i], relocs.end[i]);
27834
27933
  parsedObjectCache = /* @__PURE__ */ new Map();
27835
27934
  PARSED_ROOTS = 2;
@@ -28337,7 +28436,7 @@ function llvmType(value) {
28337
28436
  function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLookups, preserveCanonical, options2 = {}) {
28338
28437
  if (!isWasmMagic(bytes)) throw new Error("expected wasm object");
28339
28438
  const rawBuf = Buffer.isBuffer(bytes) ? bytes : Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
28340
- const { sdkLookupOnly, sdkProduct } = options2;
28439
+ const { sdkLookupOnly, sdkProduct, collectRewrittenSymbols } = options2;
28341
28440
  const comdatScope = sdkProduct === void 0 ? callerAlias : `${callerAlias}:${sdkProduct}`;
28342
28441
  const rewrite = binding !== void 0;
28343
28442
  const sections = rewrite ? [bytes.subarray(0, 8)] : void 0;
@@ -28346,6 +28445,9 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
28346
28445
  const definitions = [];
28347
28446
  const functionImports = /* @__PURE__ */ new Map();
28348
28447
  const functionImportNames = [];
28448
+ const tableImportNames = [];
28449
+ const globalImportNames = [];
28450
+ const eventImportNames = [];
28349
28451
  const functionSymbols = [];
28350
28452
  const addressTaken = /* @__PURE__ */ new Set();
28351
28453
  let usesDlsym = false;
@@ -28467,12 +28569,18 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
28467
28569
  if (isDlsym) usesDlsym = true;
28468
28570
  if (isDlerror) usesDlerror = true;
28469
28571
  if (importWriter && binding) {
28572
+ const rewrittenName = isDlsym ? callerAlias : isDlerror ? dlerrorAlias : module2 === "env" && name3 !== "dlsym" && name3 !== "dlerror" ? binding(name3) ?? name3 : name3;
28470
28573
  importWriter.string(module2);
28471
- importWriter.string(
28472
- isDlsym ? callerAlias : isDlerror ? dlerrorAlias : module2 === "env" && name3 !== "dlsym" && name3 !== "dlerror" ? binding(name3) ?? name3 : name3
28473
- );
28574
+ importWriter.string(rewrittenName);
28474
28575
  importWriter.byte(kind);
28475
28576
  importWriter.bytes(bytes, typeStart, offset);
28577
+ if (collectRewrittenSymbols) {
28578
+ if (kind === 0)
28579
+ functionImportNames[functionImportNames.length - 1] = rewrittenName;
28580
+ else if (kind === 1) tableImportNames.push(rewrittenName);
28581
+ else if (kind === 3) globalImportNames.push(rewrittenName);
28582
+ else if (kind === 4) eventImportNames.push(rewrittenName);
28583
+ }
28476
28584
  }
28477
28585
  }
28478
28586
  if (offset !== end) throw new Error("invalid wasm import section");
@@ -28555,13 +28663,17 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
28555
28663
  if (!rewrite && flags & 16 && symbolKind === 1 && alias)
28556
28664
  usedSymbols.add(name3);
28557
28665
  if (entryWriter && binding) {
28666
+ let rewrittenSym = name3;
28667
+ let addedCanonical;
28558
28668
  if ((name3 === "dlsym" && usesDlsym || name3 === "dlerror" && usesDlerror) && flags & 16 && flags & 64 && symbolKind === 0) {
28669
+ rewrittenSym = name3 === "dlsym" ? callerAlias : dlerrorAlias;
28559
28670
  entryWriter.bytes(bytes, begin, nameStart);
28560
- entryWriter.string(name3 === "dlsym" ? callerAlias : dlerrorAlias);
28671
+ entryWriter.string(rewrittenSym);
28561
28672
  entryWriter.bytes(bytes, nameEnd, offset);
28562
28673
  } else if (flags & 16 && name3 !== "dlsym" && name3 !== "dlerror" && binding(name3) !== void 0) {
28674
+ rewrittenSym = binding(name3);
28563
28675
  entryWriter.bytes(bytes, begin, nameStart);
28564
- entryWriter.string(binding(name3));
28676
+ entryWriter.string(rewrittenSym);
28565
28677
  entryWriter.bytes(bytes, nameEnd, offset);
28566
28678
  } else if (alias && !(flags & 16) && (flags & 3) !== 2) {
28567
28679
  if (symbolKind !== 0 && symbolKind !== 1)
@@ -28575,7 +28687,9 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
28575
28687
  extraWriter.string(alias);
28576
28688
  extraWriter.bytes(bytes, nameEnd, offset);
28577
28689
  added++;
28690
+ addedCanonical = alias;
28578
28691
  } else {
28692
+ rewrittenSym = alias;
28579
28693
  entryWriter.bytes(bytes, begin, nameStart);
28580
28694
  entryWriter.string(alias);
28581
28695
  entryWriter.bytes(bytes, nameEnd, offset);
@@ -28583,6 +28697,16 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
28583
28697
  } else {
28584
28698
  entryWriter.bytes(bytes, begin, offset);
28585
28699
  }
28700
+ if (collectRewrittenSymbols) {
28701
+ if (flags & 16) {
28702
+ const resolved = flags & 64 || symbolKind === 1 ? rewrittenSym : symbolKind === 0 ? functionImportNames[index] ?? "" : symbolKind === 2 ? globalImportNames[index] ?? "" : symbolKind === 4 ? eventImportNames[index] ?? "" : symbolKind === 5 ? tableImportNames[index] ?? "" : "";
28703
+ if (resolved) collectRewrittenSymbols.referenced.add(resolved);
28704
+ } else if ((flags & 3) !== 2) {
28705
+ if (rewrittenSym) collectRewrittenSymbols.defined.add(rewrittenSym);
28706
+ if (addedCanonical)
28707
+ collectRewrittenSymbols.defined.add(addedCanonical);
28708
+ }
28709
+ }
28586
28710
  } else if (alias && !(flags & 16) && (flags & 3) !== 2) {
28587
28711
  if (symbolKind !== 0 && symbolKind !== 1)
28588
28712
  throw new Error(`unsupported symbol ${name3}`);
@@ -28946,6 +29070,7 @@ function createGuestImageLedger(input) {
28946
29070
  sdkGlobalBindings.set(name3, first.alias);
28947
29071
  }
28948
29072
  }
29073
+ const appSymbols = input.registerAppTables ? { referenced: /* @__PURE__ */ new Set(), defined: /* @__PURE__ */ new Set() } : void 0;
28949
29074
  const objects = units.map(({ image, object: object8, aliases, functionImports }) => {
28950
29075
  const shared = sharedLookupByImage.get(image);
28951
29076
  const own2 = startup.get(object8.path);
@@ -28980,7 +29105,10 @@ function createGuestImageLedger(input) {
28980
29105
  binding,
28981
29106
  object8.instrumentDynamicLookups,
28982
29107
  preserveCanonical,
28983
- { sdkProduct: object8.sdkProduct }
29108
+ {
29109
+ sdkProduct: object8.sdkProduct,
29110
+ collectRewrittenSymbols: object8.sdkProduct === void 0 ? appSymbols : void 0
29111
+ }
28984
29112
  ).bytes
28985
29113
  };
28986
29114
  });
@@ -29101,7 +29229,9 @@ function createGuestImageLedger(input) {
29101
29229
  llvmIR: render2(false, lazy),
29102
29230
  lazyFunctions: lazy,
29103
29231
  appLLVMIR: appLazy && render2(true, appLazy),
29104
- appLazyFunctions: appLazy
29232
+ appLazyFunctions: appLazy,
29233
+ appReferencedSymbols: appSymbols?.referenced,
29234
+ appDefinedSymbols: appSymbols?.defined
29105
29235
  };
29106
29236
  }
29107
29237
  function guestLazyFunctionRuntime(count) {
@@ -29829,6 +29959,26 @@ function selectedGuestManifestInputs(plan, selection, identities, readSelected)
29829
29959
  }
29830
29960
  return images;
29831
29961
  }
29962
+ function framedLinkOptions(options2) {
29963
+ const cached2 = framedLinkOptionsCache.get(options2);
29964
+ if (cached2) return cached2;
29965
+ const parts = new Array(options2.length * 2 + 2);
29966
+ const count = Buffer.from(String(options2.length), "utf8");
29967
+ const countSize = Buffer.allocUnsafe(8);
29968
+ countSize.writeBigUInt64BE(BigInt(count.byteLength));
29969
+ parts[0] = countSize;
29970
+ parts[1] = count;
29971
+ for (let i = 0; i < options2.length; i++) {
29972
+ const encoded = Buffer.from(options2[i], "utf8");
29973
+ const size2 = Buffer.allocUnsafe(8);
29974
+ size2.writeBigUInt64BE(BigInt(encoded.byteLength));
29975
+ parts[i * 2 + 2] = size2;
29976
+ parts[i * 2 + 3] = encoded;
29977
+ }
29978
+ const framed = Buffer.concat(parts);
29979
+ framedLinkOptionsCache.set(options2, framed);
29980
+ return framed;
29981
+ }
29832
29982
  function createGuestImageManifest(image) {
29833
29983
  const target = {
29834
29984
  triple: SWIFT_WASM_TRIPLE,
@@ -29838,10 +29988,10 @@ function createGuestImageManifest(image) {
29838
29988
  cpuSubtype: 0
29839
29989
  };
29840
29990
  const digest3 = (0, import_node_crypto18.createHash)("sha256");
29991
+ const sizeBuf = Buffer.allocUnsafe(8);
29841
29992
  const add = (bytes) => {
29842
- const size2 = Buffer.alloc(8);
29843
- size2.writeBigUInt64BE(BigInt(bytes.byteLength));
29844
- digest3.update(size2);
29993
+ sizeBuf.writeBigUInt64BE(BigInt(bytes.byteLength));
29994
+ digest3.update(sizeBuf);
29845
29995
  digest3.update(bytes);
29846
29996
  };
29847
29997
  const text7 = (value) => add(Buffer.from(value, "utf8"));
@@ -29858,8 +30008,7 @@ function createGuestImageManifest(image) {
29858
30008
  `${version2.platform}:${version2.minimum.major}:${version2.minimum.minor}:${version2.minimum.patch}`
29859
30009
  );
29860
30010
  text7(`${version2.sdk.major}:${version2.sdk.minor}:${version2.sdk.patch}`);
29861
- text7(String(image.linkOptions.length));
29862
- for (const option of image.linkOptions) text7(option);
30011
+ digest3.update(framedLinkOptions(image.linkOptions));
29863
30012
  text7(String(image.inputs.length));
29864
30013
  for (const input of image.inputs) {
29865
30014
  text7(input.identity);
@@ -29880,7 +30029,7 @@ function createGuestImageManifest(image) {
29880
30029
  regions: image.regions
29881
30030
  };
29882
30031
  }
29883
- var import_node_crypto18, import_node_fs31;
30032
+ var import_node_crypto18, import_node_fs31, framedLinkOptionsCache;
29884
30033
  var init_swift_guest_manifest = __esm({
29885
30034
  "src/swift-guest-manifest.ts"() {
29886
30035
  "use strict";
@@ -29889,6 +30038,7 @@ var init_swift_guest_manifest = __esm({
29889
30038
  init_swift_guest_link_plan();
29890
30039
  init_swift_wasm_prune();
29891
30040
  init_swiftTargetContract();
30041
+ framedLinkOptionsCache = /* @__PURE__ */ new WeakMap();
29892
30042
  }
29893
30043
  });
29894
30044
 
@@ -31191,7 +31341,7 @@ var init_wasm_optimize = __esm({
31191
31341
  ];
31192
31342
  BINARYEN_VERSION = binaryen_lock_default.version;
31193
31343
  runBinaryen = (0, import_node_util3.promisify)(import_node_child_process18.execFile);
31194
- WASM_LOWER_IDENTITY = `binaryen ${BINARYEN_VERSION} narrow ${LOWERING.join(" ")} ${FEATURES.join(",")} shared-stack-check-v2 native-image-v1 table-reserve-v2 ${NATIVE_TABLE_ABI} unoptimized-names`;
31344
+ WASM_LOWER_IDENTITY = `binaryen ${BINARYEN_VERSION} fused-pipeline-v1 narrow ${LOWERING.join(" ")} ${FEATURES.join(",")} shared-stack-check-v2 native-image-v1 table-reserve-v2 ${NATIVE_TABLE_ABI} unoptimized-names`;
31195
31345
  BINARYEN_RELEASES = new Map(Object.entries(binaryen_lock_default.platforms));
31196
31346
  }
31197
31347
  });
@@ -31636,6 +31786,7 @@ function linkGuestImages(options2) {
31636
31786
  const ledgerObjects = new Map(ledger.objects.map((item) => [item.path, item]));
31637
31787
  const appObjects = /* @__PURE__ */ new Map();
31638
31788
  const sdkObjects = /* @__PURE__ */ new Map();
31789
+ const finalArchives = /* @__PURE__ */ new Map();
31639
31790
  for (const [index, artifact] of plan.artifacts.entries()) {
31640
31791
  const prefix = `${artifact.path}(`;
31641
31792
  if (artifact.kind === "object") {
@@ -31689,6 +31840,10 @@ function linkGuestImages(options2) {
31689
31840
  const response = import_node_path32.default.join(memberDir, "members.rsp");
31690
31841
  import_node_fs34.default.writeFileSync(response, inputs2.map((input) => JSON.stringify(input)).join(" "));
31691
31842
  (0, import_node_child_process19.execFileSync)(llvmAr, ["rcs", output, `@${response}`], { stdio: "pipe" });
31843
+ finalArchives.set(
31844
+ output,
31845
+ members2.map((member) => ({ name: member.name, bytes: new Uint8Array(0) }))
31846
+ );
31692
31847
  replacements.set(artifact.path, output);
31693
31848
  }
31694
31849
  const compileLedger = (name3, source) => {
@@ -31820,7 +31975,8 @@ function linkGuestImages(options2) {
31820
31975
  remapGuestLinkPlan(plan, replacements),
31821
31976
  finalArgs,
31822
31977
  import_node_fs34.default.readFileSync(finalWhy, "utf8"),
31823
- finalTrace
31978
+ finalTrace,
31979
+ finalArchives
31824
31980
  );
31825
31981
  const original = new Map([...replacements].map(([before2, after2]) => [after2, before2]));
31826
31982
  const key2 = (item) => JSON.stringify([original.get(item.artifact) ?? item.artifact, item.member]);
@@ -31853,12 +32009,25 @@ ${changed.join("\n")}`
31853
32009
  ])
31854
32010
  );
31855
32011
  appObjects.set(appLedgerObject, options2.ledgerDataImage);
32012
+ let appReferencedSymbols;
32013
+ let appDefinedSymbols;
32014
+ if (ledger.appReferencedSymbols && ledger.appDefinedSymbols) {
32015
+ const referenced = new Set(ledger.appReferencedSymbols);
32016
+ const defined = new Set(ledger.appDefinedSymbols);
32017
+ const ledgerSyms = guestWasmSymbols(import_node_fs34.default.readFileSync(appLedgerObject));
32018
+ for (const name3 of ledgerSyms.undefined) referenced.add(name3);
32019
+ for (const name3 of ledgerSyms.defined) defined.add(name3);
32020
+ appReferencedSymbols = referenced;
32021
+ appDefinedSymbols = defined;
32022
+ }
31856
32023
  options2.onSplitInputs({
31857
32024
  appObjects,
31858
32025
  appSections,
31859
32026
  sdkObjects,
31860
32027
  lazyFunctions: ledger.appLazyFunctions ?? [],
31861
- dyldSymbols: ledger.dyldSymbols
32028
+ dyldSymbols: ledger.dyldSymbols,
32029
+ appReferencedSymbols,
32030
+ appDefinedSymbols
31862
32031
  });
31863
32032
  }
31864
32033
  return selected;
@@ -32850,6 +33019,93 @@ function sourceGuestInputIdentities(graph, buildDirectory, objects) {
32850
33019
  }
32851
33020
  return identities;
32852
33021
  }
33022
+ function wasmAutolinkEntries(bytes, out) {
33023
+ if (bytes.length < 8) return false;
33024
+ if (bytes[0] === 33 && bytes[1] === 60 && bytes[2] === 97 && bytes[3] === 114 && bytes[4] === 99 && bytes[5] === 104 && bytes[6] === 62 && bytes[7] === 10) {
33025
+ for (const member of readArMembers(bytes)) {
33026
+ if (!wasmAutolinkEntries(member.bytes, out)) return false;
33027
+ }
33028
+ return true;
33029
+ }
33030
+ if (bytes[0] !== 0 || bytes[1] !== 97 || bytes[2] !== 115 || bytes[3] !== 109)
33031
+ return false;
33032
+ const raw2 = Buffer.isBuffer(bytes) ? bytes : Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
33033
+ let pos = 8;
33034
+ const len = bytes.length;
33035
+ while (pos < len) {
33036
+ const id = bytes[pos++];
33037
+ let sz = bytes[pos++];
33038
+ if (sz >= 128) {
33039
+ sz &= 127;
33040
+ let shift = 7;
33041
+ while (true) {
33042
+ const b = bytes[pos++];
33043
+ sz |= (b & 127) << shift;
33044
+ if (b < 128) break;
33045
+ shift += 7;
33046
+ }
33047
+ }
33048
+ const end = pos + sz;
33049
+ if (id === 0) {
33050
+ let nLen = bytes[pos++];
33051
+ if (nLen >= 128) {
33052
+ nLen &= 127;
33053
+ let shift = 7;
33054
+ while (true) {
33055
+ const b = bytes[pos++];
33056
+ nLen |= (b & 127) << shift;
33057
+ if (b < 128) break;
33058
+ shift += 7;
33059
+ }
33060
+ }
33061
+ if (nLen === 24 && raw2.toString("ascii", pos, pos + 24) === ".swift1_autolink_entries") {
33062
+ const payload = raw2.toString("utf8", pos + 24, end);
33063
+ for (const entry of payload.split("\0")) {
33064
+ const trimmed = entry.trim();
33065
+ if (trimmed.length > 0) out.push(trimmed);
33066
+ }
33067
+ }
33068
+ }
33069
+ pos = end;
33070
+ }
33071
+ return true;
33072
+ }
33073
+ function readAutolinkFlags(objects, toolchainBin, responsePath) {
33074
+ if (!objects.length) return [];
33075
+ const rawFlags = [];
33076
+ for (const file of objects) {
33077
+ if (!wasmAutolinkEntries((0, import_node_fs35.readFileSync)(file), rawFlags)) {
33078
+ (0, import_node_fs35.writeFileSync)(
33079
+ responsePath,
33080
+ objects.map((entry) => JSON.stringify(entry)).join("\n") + "\n"
33081
+ );
33082
+ return (0, import_node_child_process20.execFileSync)(
33083
+ import_node_path33.default.join(toolchainBin, "swift-autolink-extract"),
33084
+ [`@${responsePath}`, "-o", "-"],
33085
+ { encoding: "utf8" }
33086
+ ).split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
33087
+ }
33088
+ }
33089
+ const seen = /* @__PURE__ */ new Set();
33090
+ const flags = [];
33091
+ for (let i = 0; i < rawFlags.length; i++) {
33092
+ const flag = rawFlags[i];
33093
+ if ((flag === "-framework" || flag === "-weak_framework" || flag === "-l" || flag === "--library") && i + 1 < rawFlags.length) {
33094
+ const value = rawFlags[++i];
33095
+ const key2 = `${flag}\0${value}`;
33096
+ if (!seen.has(key2)) {
33097
+ seen.add(key2);
33098
+ flags.push(flag, value);
33099
+ }
33100
+ continue;
33101
+ }
33102
+ if (!seen.has(flag)) {
33103
+ seen.add(flag);
33104
+ flags.push(flag);
33105
+ }
33106
+ }
33107
+ return flags;
33108
+ }
32853
33109
  function sourceGuestRuntimeLinks(options2) {
32854
33110
  const aliases = /* @__PURE__ */ new Map();
32855
33111
  const artifacts = /* @__PURE__ */ new Map();
@@ -32937,15 +33193,7 @@ function sourceGuestRuntimeLinks(options2) {
32937
33193
  for (const image of options2.images) {
32938
33194
  if (result.has(image.id)) throw new Error(`duplicate source image ${image.id}`);
32939
33195
  const response = import_node_path33.default.join(options2.directory, `image-${image.id}-autolink.rsp`);
32940
- (0, import_node_fs35.writeFileSync)(
32941
- response,
32942
- image.objects.map((file) => JSON.stringify(file)).join("\n") + "\n"
32943
- );
32944
- const autolink = image.objects.length ? (0, import_node_child_process20.execFileSync)(
32945
- import_node_path33.default.join(options2.toolchainBin, "swift-autolink-extract"),
32946
- [`@${response}`, "-o", "-"],
32947
- { encoding: "utf8" }
32948
- ).split("\n").map((line) => line.trim()).filter((line) => line.length > 0) : [];
33196
+ const autolink = readAutolinkFlags(image.objects, options2.toolchainBin, response);
32949
33197
  const links = [];
32950
33198
  const requests = [];
32951
33199
  const optionGroups = [
@@ -33045,6 +33293,7 @@ var init_swift_guest_source_inputs = __esm({
33045
33293
  init_forked_script_contract();
33046
33294
  init_swift_guest_source_plan();
33047
33295
  init_swift_runtime_products();
33296
+ init_swift_wasm_prune();
33048
33297
  CLANG_TARGET_MODULE_WRAPPER = ".peach-clang";
33049
33298
  PARALLEL_REPLAY = `
33050
33299
  const { spawn } = require('node:child_process')
@@ -36557,9 +36806,10 @@ function sdkHostExports(appRoot) {
36557
36806
  if (!(byte & 128)) return value;
36558
36807
  }
36559
36808
  };
36809
+ const raw2 = Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
36560
36810
  for (let n = u(); n > 0; n--) {
36561
36811
  const length = u();
36562
- names.push(Buffer.from(bytes.subarray(at, at + length)).toString());
36812
+ names.push(raw2.toString("utf8", at, at + length));
36563
36813
  at += length + 1;
36564
36814
  u();
36565
36815
  }
@@ -36985,56 +37235,109 @@ function swiftAppModuleInputs(tokens2, buildRoot, sdkLibraries) {
36985
37235
  }
36986
37236
  return inputs2;
36987
37237
  }
36988
- async function compileSdkForwarders(inputs2, sdk2, toolchainBin, output, project2, readInput) {
37238
+ function llvmQuoted(value) {
37239
+ const bytes = Buffer.from(value, "utf8");
37240
+ let out = '"';
37241
+ for (let i = 0; i < bytes.length; i++) {
37242
+ const b = bytes[i];
37243
+ if (b >= 32 && b <= 126 && b !== 34 && b !== 92) out += String.fromCharCode(b);
37244
+ else out += `\\${b.toString(16).toUpperCase().padStart(2, "0")}`;
37245
+ }
37246
+ return out + '"';
37247
+ }
37248
+ async function compileSdkForwarders(inputs2, sdk2, toolchainBin, output, project2, readInput, precomputedSymbols) {
36989
37249
  const { signatures, tls } = sdk2.sdkInterface;
36990
- const directories = inputs2.filter((input) => input.startsWith("-L")).map((input) => input.slice(2));
36991
- const referenced = /* @__PURE__ */ new Set();
36992
- const defined = /* @__PURE__ */ new Set();
36993
- const scan3 = (bytes) => {
36994
- const symbols = guestWasmSymbols(bytes);
36995
- for (const name3 of symbols.undefined) referenced.add(name3);
36996
- for (const name3 of symbols.defined) defined.add(name3);
37250
+ let referenced;
37251
+ let defined;
37252
+ if (precomputedSymbols) {
37253
+ referenced = precomputedSymbols.referenced;
37254
+ defined = precomputedSymbols.defined;
37255
+ } else {
37256
+ const directories = inputs2.filter((input) => input.startsWith("-L")).map((input) => input.slice(2));
37257
+ const refSet = /* @__PURE__ */ new Set();
37258
+ const defSet = /* @__PURE__ */ new Set();
37259
+ const scan3 = (bytes) => {
37260
+ const symbols = guestWasmSymbols(bytes);
37261
+ for (const name3 of symbols.undefined) refSet.add(name3);
37262
+ for (const name3 of symbols.defined) defSet.add(name3);
37263
+ };
37264
+ for (const input of inputs2) {
37265
+ const file = input.startsWith("-l") ? directories.map((directory2) => import_node_path42.default.join(directory2, `lib${input.slice(2)}.a`)).find((candidate) => (0, import_node_fs44.existsSync)(candidate)) : input.startsWith("-") ? void 0 : input;
37266
+ if (!file) continue;
37267
+ const bytes = readInput(file);
37268
+ if (file.endsWith(".a"))
37269
+ for (const member of readArMembers(bytes)) scan3(member.bytes);
37270
+ else scan3(bytes);
37271
+ }
37272
+ referenced = refSet;
37273
+ defined = defSet;
37274
+ }
37275
+ const irType = {
37276
+ i: "i32",
37277
+ j: "i64",
37278
+ f: "float",
37279
+ d: "double"
37280
+ };
37281
+ const type = (kinds) => {
37282
+ const out = new Array(kinds.length);
37283
+ for (let i = 0; i < kinds.length; i++) {
37284
+ const kind = kinds[i];
37285
+ const name3 = irType[kind];
37286
+ if (!name3) throw new Error(`sdk signature kind ${kind}`);
37287
+ out[i] = name3;
37288
+ }
37289
+ return out;
36997
37290
  };
36998
- for (const input of inputs2) {
36999
- const file = input.startsWith("-l") ? directories.map((directory2) => import_node_path42.default.join(directory2, `lib${input.slice(2)}.a`)).find((candidate) => (0, import_node_fs44.existsSync)(candidate)) : input.startsWith("-") ? void 0 : input;
37000
- if (!file) continue;
37001
- const bytes = readInput(file);
37002
- if (file.endsWith(".a")) for (const member of readArMembers(bytes)) scan3(member.bytes);
37003
- else scan3(bytes);
37004
- }
37005
- const c = { i: "int", j: "long long", f: "float", d: "double" };
37006
- const type = (kinds) => [...kinds].map((kind) => {
37007
- const name3 = c[kind];
37008
- if (!name3) throw new Error(`sdk signature kind ${kind}`);
37009
- return name3;
37010
- });
37011
- const literal3 = (name3) => JSON.stringify(name3);
37012
- const lines = [];
37013
- if (signatures.__objc_send_load_messages === ":")
37291
+ const lines = [`target triple = "${SWIFT_WASM_TRIPLE}"`];
37292
+ const attrs = [];
37293
+ const addImportAttr = (name3) => {
37294
+ const id = attrs.length;
37295
+ attrs.push(
37296
+ `attributes #${id} = { "wasm-import-module"="env" "wasm-import-name"=${llvmQuoted(name3)} }`
37297
+ );
37298
+ return id;
37299
+ };
37300
+ if (signatures.__objc_send_load_messages === ":") {
37301
+ const attr = addImportAttr("__objc_send_load_messages");
37014
37302
  lines.push(
37015
- '__attribute__((import_module("env"), import_name("__objc_send_load_messages"))) void sdk_send_load_messages(void);',
37016
- "__attribute__((constructor)) static void send_app_load_messages(void) { sdk_send_load_messages(); }"
37303
+ "@llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr @send_app_load_messages, ptr null }]",
37304
+ `declare void @sdk_send_load_messages() #${attr}`,
37305
+ "define internal void @send_app_load_messages() {",
37306
+ " tail call void @sdk_send_load_messages()",
37307
+ " ret void",
37308
+ "}"
37017
37309
  );
37310
+ }
37018
37311
  const forwarders = /* @__PURE__ */ new Set();
37019
37312
  let index = 0;
37020
37313
  for (const name3 of referenced) {
37021
37314
  const signature2 = signatures[name3];
37022
37315
  if (signature2 === void 0 || defined.has(name3)) continue;
37023
- const [params = "", results = ""] = signature2.split(":");
37316
+ const colon = signature2.indexOf(":");
37317
+ const params = colon < 0 ? signature2 : signature2.slice(0, colon);
37318
+ const results = colon < 0 ? "" : signature2.slice(colon + 1);
37024
37319
  if (results.length > 1) throw new Error(`sdk function ${name3} returns several values`);
37025
37320
  const result = results ? type(results)[0] : "void";
37026
- const declared = type(params).map((kind, at) => `${kind} a${at}`).join(", ") || "void";
37027
- const passed = type(params).map((_, at) => `a${at}`).join(", ");
37321
+ const paramTypes = type(params);
37322
+ const declParams = paramTypes.join(", ");
37323
+ const defParams = paramTypes.map((kind, at) => `${kind} %a${at}`).join(", ");
37324
+ const callArgs = paramTypes.map((kind, at) => `${kind} %a${at}`).join(", ");
37325
+ const attr = addImportAttr(name3);
37326
+ const quoted2 = llvmQuoted(name3);
37028
37327
  lines.push(
37029
- `__attribute__((import_module("env"), import_name(${literal3(name3)}))) ${result} i${index}(${declared});`,
37030
- `__attribute__((weak)) ${result} f${index}(${declared}) __asm__(${literal3(name3)});`,
37031
- `${result} f${index}(${declared}) { ${result === "void" ? "" : "return "}i${index}(${passed}); }`
37328
+ `declare ${result} @i${index}(${declParams}) #${attr}`,
37329
+ `define weak hidden ${result} @${quoted2}(${defParams}) {`,
37330
+ result === "void" ? ` tail call void @i${index}(${callArgs})
37331
+ ret void` : ` %r = tail call ${result} @i${index}(${callArgs})
37332
+ ret ${result} %r`,
37333
+ "}"
37032
37334
  );
37033
37335
  forwarders.add(name3);
37034
37336
  index++;
37035
37337
  }
37036
37338
  const errno = tls.errno;
37037
37339
  let declaredErrno = false;
37340
+ const usedHelpers = [];
37038
37341
  for (const name3 of referenced) {
37039
37342
  const offset = tls[name3];
37040
37343
  if (offset === void 0 || defined.has(name3)) continue;
@@ -37042,28 +37345,44 @@ async function compileSdkForwarders(inputs2, sdk2, toolchainBin, output, project
37042
37345
  throw new Error("the sdk image has no errno to find its thread block by");
37043
37346
  if (!declaredErrno) {
37044
37347
  declaredErrno = true;
37348
+ const attr = addImportAttr("__errno_location");
37045
37349
  lines.push(
37046
- `__attribute__((import_module("env"), import_name("__errno_location"))) char *__peach_errno(void);`
37350
+ `declare ptr @__peach_errno() #${attr}`,
37351
+ "declare ptr @llvm.wasm.tls.base()"
37047
37352
  );
37048
37353
  }
37354
+ const helper = `@${llvmQuoted(SDK_TLS_HELPER + name3)}`;
37355
+ const delta = `@${llvmQuoted(SDK_TLS_DELTA + name3)}`;
37356
+ usedHelpers.push(`ptr ${helper}`);
37049
37357
  lines.push(
37050
- `__attribute__((weak)) _Thread_local char t${index} __asm__(${literal3(name3)});`,
37051
- `__attribute__((used)) long long h${index}(void) __asm__(${literal3(SDK_TLS_HELPER + name3)});`,
37052
- `extern char d${index} __asm__(${literal3(SDK_TLS_DELTA + name3)});`,
37053
- `long long h${index}(void) { return (long long)__peach_errno() + (long long)&d${index} - (long long)__builtin_wasm_tls_base(); }`
37358
+ `@${llvmQuoted(name3)} = weak hidden thread_local global i8 0, align 1`,
37359
+ `${delta} = external global i8, align 1`,
37360
+ `define hidden i64 ${helper}() {`,
37361
+ " %e = tail call ptr @__peach_errno()",
37362
+ " %ei = ptrtoint ptr %e to i64",
37363
+ ` %di = ptrtoint ptr ${delta} to i64`,
37364
+ " %s = add i64 %ei, %di",
37365
+ " %b = tail call ptr @llvm.wasm.tls.base()",
37366
+ " %bi = ptrtoint ptr %b to i64",
37367
+ " %r = sub i64 %s, %bi",
37368
+ " ret i64 %r",
37369
+ "}"
37054
37370
  );
37055
37371
  index++;
37056
37372
  }
37057
- const source = `${output.slice(0, -2)}.c`;
37058
- (0, import_node_fs44.writeFileSync)(source, lines.join("\n") + "\n");
37373
+ if (usedHelpers.length > 0) {
37374
+ lines.push(
37375
+ `@llvm.used = appending global [${usedHelpers.length} x ptr] [${usedHelpers.join(", ")}], section "llvm.metadata"`
37376
+ );
37377
+ }
37378
+ const source = `${output.slice(0, -2)}.ll`;
37379
+ (0, import_node_fs44.writeFileSync)(source, [...lines, ...attrs].join("\n") + "\n");
37059
37380
  await run3(
37060
37381
  import_node_path42.default.join(toolchainBin, "clang"),
37061
37382
  [
37062
37383
  `--target=${SWIFT_WASM_TRIPLE}`,
37063
- "-O2",
37064
37384
  "-matomics",
37065
37385
  "-mbulk-memory",
37066
- "-ffreestanding",
37067
37386
  "-c",
37068
37387
  source,
37069
37388
  "-o",
@@ -37082,7 +37401,8 @@ async function linkSwiftAppModule(options2) {
37082
37401
  toolchainBin,
37083
37402
  forwarders,
37084
37403
  options2.project,
37085
- options2.readInput ?? import_node_fs44.readFileSync
37404
+ options2.readInput ?? import_node_fs44.readFileSync,
37405
+ options2.precomputedSymbols
37086
37406
  );
37087
37407
  const lazy = options2.lazyFunctions ?? [];
37088
37408
  const lazyExports = import_node_path42.default.join(work, "lazy-exports.rsp");
@@ -38826,6 +39146,15 @@ async function compileGuestLink(options2) {
38826
39146
  { stdio: "pipe" }
38827
39147
  );
38828
39148
  }
39149
+ let precomputedSymbols;
39150
+ if (splitInputs.appReferencedSymbols && splitInputs.appDefinedSymbols) {
39151
+ const referenced = new Set(splitInputs.appReferencedSymbols);
39152
+ const defined = new Set(splitInputs.appDefinedSymbols);
39153
+ const projSyms = guestWasmSymbols((0, import_node_fs45.readFileSync)(projectionObject));
39154
+ for (const name3 of projSyms.undefined) referenced.add(name3);
39155
+ for (const name3 of projSyms.defined) defined.add(name3);
39156
+ precomputedSymbols = { referenced, defined };
39157
+ }
38829
39158
  for (; ; ) {
38830
39159
  const link = await linkSwiftAppModule2({
38831
39160
  objects: [...owners.keys()],
@@ -38837,6 +39166,7 @@ async function compileGuestLink(options2) {
38837
39166
  optimize: options2.optimize,
38838
39167
  layoutMap,
38839
39168
  project: project2,
39169
+ precomputedSymbols,
38840
39170
  loweringCache: project2 ? void 0 : {
38841
39171
  file: import_node_path43.default.join(
38842
39172
  options2.buildDirectory,
@@ -38961,6 +39291,7 @@ var init_swift_guest_compile = __esm({
38961
39291
  init_swift_runtime_products();
38962
39292
  init_swift_sdk_guest_lookups();
38963
39293
  init_swift_toolchain();
39294
+ init_swift_wasm_prune();
38964
39295
  init_swiftTargetContract();
38965
39296
  init_wasm_optimize();
38966
39297
  }
@@ -40442,7 +40773,25 @@ function swiftBuildJobs() {
40442
40773
  return Math.min(cores, memoryJobs);
40443
40774
  }
40444
40775
  function swiftCompilerJobs() {
40445
- return Math.min(16, swiftBuildJobs(), Math.max(1, Math.floor(import_node_os12.default.totalmem() / 2 ** 31)));
40776
+ return Math.min(32, swiftBuildJobs(), Math.max(1, Math.floor(import_node_os12.default.totalmem() / 2 ** 31)));
40777
+ }
40778
+ function swiftCompilerBaseEnv(toolchainBin, sourceEnv, includePeachHome = false) {
40779
+ const env = {};
40780
+ for (const key2 of SWIFT_COMPILER_ENV_KEYS) {
40781
+ const value = sourceEnv[key2];
40782
+ if (value !== void 0) env[key2] = value;
40783
+ }
40784
+ if (includePeachHome && sourceEnv.PEACH_HOME !== void 0)
40785
+ env.PEACH_HOME = sourceEnv.PEACH_HOME;
40786
+ if (process.platform === "linux") {
40787
+ env.LD_LIBRARY_PATH = [
40788
+ import_node_path53.default.resolve(toolchainBin, "../lib/swift/linux"),
40789
+ import_node_path53.default.resolve(toolchainBin, "../lib/swift/host"),
40790
+ sourceEnv.LD_LIBRARY_PATH
40791
+ ].filter(Boolean).join(":");
40792
+ }
40793
+ env.PEACH_DEFER_WASM_LINK = "1";
40794
+ return env;
40446
40795
  }
40447
40796
  function assertSwiftBuildCores() {
40448
40797
  const admitted = windowAdmission()?.cores ?? Number(process.env.TM_EXEC_CPU_CORES);
@@ -41631,10 +41980,22 @@ function emitSwiftPackageManifest(args) {
41631
41980
  const available2 = distribution.objects.filter(
41632
41981
  (object8) => !isProvider(object8) && !replacedObjects.has(object8)
41633
41982
  );
41983
+ const targetNamesWithDash = targets.filter((target) => target.name.includes("-")).map((target) => `lib/${target.name}-`);
41984
+ const targetNameSet = new Set(targets.map((target) => target.name));
41985
+ const optionalSet = /* @__PURE__ */ new Set([...OPTIONAL_FRAMEWORKS, ...GAME_FAMILY, "PeachBox2D"]);
41986
+ const isTargetObject = (object8) => {
41987
+ const dash = object8.indexOf("-", 4);
41988
+ if (dash > 4 && targetNameSet.has(object8.slice(4, dash))) return true;
41989
+ return targetNamesWithDash.some((prefix) => object8.startsWith(prefix));
41990
+ };
41991
+ const isUnreachedOptional = (object8) => {
41992
+ const dash = object8.indexOf("-", 4);
41993
+ if (dash <= 4) return false;
41994
+ const name3 = object8.slice(4, dash);
41995
+ return optionalSet.has(name3) && !reachedFrameworks.has(name3);
41996
+ };
41634
41997
  const objects = available2.filter(
41635
- (object8) => !targets.some((target) => object8.startsWith(`lib/${target.name}-`)) && [...OPTIONAL_FRAMEWORKS, ...GAME_FAMILY, "PeachBox2D"].every(
41636
- (name3) => !object8.startsWith(`lib/${name3}-`) || reachedFrameworks.has(name3)
41637
- )
41998
+ (object8) => !isTargetObject(object8) && !isUnreachedOptional(object8)
41638
41999
  );
41639
42000
  const quoted2 = (object8) => `"${import_node_path53.default.join(moduleRoot, object8).replaceAll("\\", "\\\\").replaceAll('"', '\\"')}"`;
41640
42001
  const categoryObjects = new Set(
@@ -41715,18 +42076,53 @@ function emitSwiftPackageManifest(args) {
41715
42076
  args.files.set(file, content);
41716
42077
  return JSON.stringify([`@${file}`]);
41717
42078
  };
41718
- const frameworkDirectories = (name3, seen = /* @__PURE__ */ new Set()) => (siblings.get(name3) ?? []).flatMap((dependency) => {
41719
- if (seen.has(dependency)) return [];
41720
- seen.add(dependency);
41721
- const owner = args.targets.find((other) => other.name === dependency);
42079
+ const targetByName = new Map(targets.map((target) => [target.name, target]));
42080
+ const ownFrameworkDir = /* @__PURE__ */ new Map();
42081
+ for (const target of targets) {
41722
42082
  const framework = /^(.*)\/[^/]+\.framework\/Modules$/.exec(
41723
- owner?.publicHeadersPath ?? ""
42083
+ target.publicHeadersPath ?? ""
41724
42084
  );
41725
- return [
41726
- ...owner && framework ? [import_node_path53.default.posix.join(args.root, owner.path, framework[1])] : [],
41727
- ...frameworkDirectories(dependency, seen)
41728
- ];
41729
- });
42085
+ if (framework)
42086
+ ownFrameworkDir.set(
42087
+ target.name,
42088
+ import_node_path53.default.posix.join(args.root, target.path, framework[1])
42089
+ );
42090
+ }
42091
+ const frameworkDirectoriesCache = /* @__PURE__ */ new Map();
42092
+ const frameworkDirectories = (name3) => {
42093
+ if (ownFrameworkDir.size === 0) return [];
42094
+ const cached2 = frameworkDirectoriesCache.get(name3);
42095
+ if (cached2) return cached2;
42096
+ const dirs = [];
42097
+ const seen = /* @__PURE__ */ new Set();
42098
+ const visit3 = (current2) => {
42099
+ for (const dependency of siblings.get(current2) ?? []) {
42100
+ if (seen.has(dependency)) continue;
42101
+ seen.add(dependency);
42102
+ const dir = ownFrameworkDir.get(dependency);
42103
+ if (dir) dirs.push(dir);
42104
+ visit3(dependency);
42105
+ }
42106
+ };
42107
+ visit3(name3);
42108
+ frameworkDirectoriesCache.set(name3, dirs);
42109
+ return dirs;
42110
+ };
42111
+ const targetSwiftXccFlags = /* @__PURE__ */ new Map();
42112
+ for (const target of targets) {
42113
+ const flags = target.swiftFlags;
42114
+ if (!flags || flags.length === 0) continue;
42115
+ const xcc = [];
42116
+ for (let index = 1; index < flags.length; index++) {
42117
+ if (flags[index - 1] === "-Xcc")
42118
+ xcc.push(flags[index].replaceAll(SWIFT_NATIVE_INPUT_ROOT, args.root));
42119
+ }
42120
+ if (xcc.length > 0) targetSwiftXccFlags.set(target.name, xcc);
42121
+ }
42122
+ const binaryImports = args.binaryModules ? `, "-I", ${JSON.stringify(args.binaryModules)}` : "";
42123
+ const sharedImports = binaryImports + (distributionModules ? `, "-Isystem", ${JSON.stringify(
42124
+ providedModulesPath(args.root, distributionModules, args.moduleExcludes)
42125
+ )}${distributionClangModuleOptions(args.root, distributionModules).map((flag) => `, ${JSON.stringify(flag)}`).join("")}` : prebuilt ? `, "-Isystem", ${JSON.stringify(providedModulesPath(args.root, prebuilt.modules, args.moduleExcludes))}${prebuilt.moduleMaps.map((map2) => `, "-Xcc", ${JSON.stringify(`-fmodule-map-file=${map2}`)}`).join("")}` : "");
41730
42126
  const frameworkSearchFlags = (target, tool) => frameworkDirectories(target?.name ?? "").map((directory2) => ({
41731
42127
  tool,
41732
42128
  flags: ["-F", directory2]
@@ -41775,10 +42171,7 @@ function emitSwiftPackageManifest(args) {
41775
42171
  const upstream = (target.swiftFlags ?? []).map(
41776
42172
  (flag) => `, ${JSON.stringify(flag.replaceAll(SWIFT_NATIVE_INPUT_ROOT, args.root))}`
41777
42173
  ).join("");
41778
- const binaryImports = args.binaryModules ? `, "-I", ${JSON.stringify(args.binaryModules)}` : "";
41779
- const imports2 = binaryImports + (distributionModules ? `, "-Isystem", ${JSON.stringify(
41780
- providedModulesPath(args.root, distributionModules, args.moduleExcludes)
41781
- )}${distributionClangModuleOptions(args.root, distributionModules).map((flag) => `, ${JSON.stringify(flag)}`).join("")}` : prebuilt ? `, "-Isystem", ${JSON.stringify(providedModulesPath(args.root, prebuilt.modules, args.moduleExcludes))}${prebuilt.moduleMaps.map((map2) => `, "-Xcc", ${JSON.stringify(`-fmodule-map-file=${map2}`)}`).join("")}` : "");
42174
+ const imports2 = sharedImports;
41782
42175
  const nativeFlags = [
41783
42176
  ...args.nativeFlags?.get(target.name) ?? [],
41784
42177
  ...args.nativeHeaderFlags ?? []
@@ -41802,12 +42195,7 @@ function emitSwiftPackageManifest(args) {
41802
42195
  return map2 ? ["-fmodule-map-file=" + map2] : [];
41803
42196
  }),
41804
42197
  ...[...importContext].flatMap((name3) => args.native?.get(name3)?.importFlags ?? []),
41805
- ...[...importContext].flatMap((name3) => {
41806
- const flags = targets.find((target2) => target2.name === name3)?.swiftFlags ?? [];
41807
- return flags.flatMap(
41808
- (flag, index) => flags[index - 1] === "-Xcc" ? [flag.replaceAll(SWIFT_NATIVE_INPUT_ROOT, args.root)] : []
41809
- );
41810
- })
42198
+ ...[...importContext].flatMap((name3) => targetSwiftXccFlags.get(name3) ?? [])
41811
42199
  ];
41812
42200
  const nativeImportFlags = [
41813
42201
  ...frameworkDirectories(target.name).flatMap((directory2) => ["-F", directory2]),
@@ -41822,9 +42210,7 @@ function emitSwiftPackageManifest(args) {
41822
42210
  ...native?.swiftFlags ?? [],
41823
42211
  ...args.objcImplementationModules?.has(target.name) ? ["-enable-experimental-feature", "ObjCImplementation"] : []
41824
42212
  ].map((flag) => `, ${JSON.stringify(flag)}`).join("");
41825
- const header = args.headerDirectory && (args.nativeHeaderDeclarations?.[target.name] || [...args.native?.values() ?? []].some(
41826
- (value) => value.late?.producers.includes(target.name)
41827
- )) ? `, "-emit-objc-header-path", ${JSON.stringify(import_node_path53.default.join(args.headerDirectory, `${target.name}-Swift.original.h`))}` : "";
42213
+ const header = args.headerDirectory && (args.nativeHeaderDeclarations?.[target.name] || lateProducers.has(target.name)) ? `, "-emit-objc-header-path", ${JSON.stringify(import_node_path53.default.join(args.headerDirectory, `${target.name}-Swift.original.h`))}` : "";
41828
42214
  const clangMode = target.cxxInterop ? "" : ', "-Xcc", "-fno-cxx-modules"';
41829
42215
  const deployment = `, "-Xfrontend", "-peach-ios-deployment-target", "-Xfrontend", ${JSON.stringify(target.iosDeploymentTarget ?? SWIFTPM_DEFAULT_IOS_DEPLOYMENT_TARGET)}`;
41830
42216
  const swiftSettings = `swiftSettings: [.swiftLanguageMode(.v${target.languageMode}),${isolation}${interoperability}${defines}${features}${upcoming} .unsafeFlags(${swiftFlagArray(`["-Osize", "-Xfrontend", "-enable-cross-import-overlays"${overlayFlags}${oneModule ? ONE_IMPLICIT_FLAGS : ""}${imports2}${nativeImportFlags}${objcFlags}${header}${clangMode}${deployment}${upstream}]`)})]`;
@@ -41857,9 +42243,7 @@ function emitSwiftPackageManifest(args) {
41857
42243
  (dependency) => clang && // textual native headers can include one another without imposing
41858
42244
  // an object build order. the executable already links every native
41859
42245
  // target; only generated Swift headers require producer ordering.
41860
- (args.native?.get(dependency)?.clang || [...args.native?.values() ?? []].some(
41861
- (value) => value.late?.producers.includes(dependency)
41862
- )) ? [] : OPTIONAL_FRAMEWORKS.has(dependency) && !targets.some((candidate) => candidate.name === dependency) ? linkedObjects ? [] : [`.product(name: "${dependency}", package: "sootsim-swift")`] : [`"${dependency}"`]
42246
+ (args.native?.get(dependency)?.clang || lateProducers.has(dependency)) ? [] : OPTIONAL_FRAMEWORKS.has(dependency) && !targetNames.has(dependency) ? linkedObjects ? [] : [`.product(name: "${dependency}", package: "sootsim-swift")`] : [`"${dependency}"`]
41863
42247
  ),
41864
42248
  // a swift importer still needs the producers its clang dependencies
41865
42249
  // reached upstream, whose edges the clang targets above dropped.
@@ -41946,7 +42330,7 @@ function emitSwiftPackageManifest(args) {
41946
42330
  ...args.nativeFlags?.get(name3) ?? [],
41947
42331
  ...args.nativeHeaderFlags ?? []
41948
42332
  ];
41949
- const owner = targets.find((target) => target.name === name3);
42333
+ const owner = targetByName.get(name3);
41950
42334
  const context = /* @__PURE__ */ new Set();
41951
42335
  const visit3 = (dependency) => {
41952
42336
  if (context.has(dependency)) return;
@@ -42022,10 +42406,16 @@ ${declaration.replace(/,$/, "")}
42022
42406
  ""
42023
42407
  ].join("\n");
42024
42408
  }
42025
- function syncSwiftTree(base2, files2) {
42409
+ function syncSwiftTree(base2, files2, alreadySynced) {
42026
42410
  (0, import_node_fs53.mkdirSync)(base2, { recursive: true });
42027
- const kept = /* @__PURE__ */ new Set();
42028
- for (const file of files2.keys()) if ((0, import_node_fs53.existsSync)(file)) kept.add((0, import_node_fs53.statSync)(file).ino);
42411
+ let kept;
42412
+ if (process.platform !== "linux") {
42413
+ kept = /* @__PURE__ */ new Set();
42414
+ for (const file of files2.keys()) {
42415
+ const stat = (0, import_node_fs53.statSync)(file, { throwIfNoEntry: false });
42416
+ if (stat) kept.add(stat.ino);
42417
+ }
42418
+ }
42029
42419
  const walk4 = (dir) => {
42030
42420
  for (const entry of (0, import_node_fs53.readdirSync)(dir, { withFileTypes: true })) {
42031
42421
  const full = import_node_path53.default.join(dir, entry.name);
@@ -42034,12 +42424,13 @@ function syncSwiftTree(base2, files2) {
42034
42424
  entry.name === CLANG_DISTRIBUTION_MODULES || entry.name === SWIFT_DISTRIBUTION_MIRROR || entry.name === SWIFT_LINK_STAMP))
42035
42425
  continue;
42036
42426
  if (entry.isDirectory()) walk4(full);
42037
- else if (!files2.has(full) && !kept.has((0, import_node_fs53.lstatSync)(full).ino))
42427
+ else if (!files2.has(full) && (!kept || !kept.has((0, import_node_fs53.lstatSync)(full).ino)))
42038
42428
  (0, import_node_fs53.rmSync)(full, { force: true });
42039
42429
  }
42040
42430
  };
42041
42431
  walk4(base2);
42042
42432
  for (const [full, contents2] of files2) {
42433
+ if (alreadySynced?.get(full) === contents2) continue;
42043
42434
  writeBuildFile(full, contents2);
42044
42435
  }
42045
42436
  }
@@ -42147,25 +42538,59 @@ function swiftWasmCallGuards(source, unavailable2) {
42147
42538
  out = out.slice(0, at) + replacement + out.slice(at + width);
42148
42539
  return out;
42149
42540
  }
42541
+ function matchesPathPrefixSet(file, set2) {
42542
+ if (set2.has(file)) return true;
42543
+ for (let slash = file.lastIndexOf("/"); slash !== -1; slash = file.lastIndexOf("/", slash - 1)) {
42544
+ if (set2.has(file.slice(0, slash))) return true;
42545
+ }
42546
+ return false;
42547
+ }
42548
+ function indexTargetsByDirectory(targets) {
42549
+ const byDir = /* @__PURE__ */ new Map();
42550
+ for (const target of targets) {
42551
+ const key2 = target.path === "." ? "" : target.path.replace(/\/+$/, "");
42552
+ let list2 = byDir.get(key2);
42553
+ if (!list2) byDir.set(key2, list2 = []);
42554
+ list2.push(target);
42555
+ }
42556
+ return byDir;
42557
+ }
42558
+ function findTargetForFile(file, byDir, predicate) {
42559
+ for (let slash = file.lastIndexOf("/"); slash !== -1; slash = file.lastIndexOf("/", slash - 1)) {
42560
+ const candidates = byDir.get(file.slice(0, slash));
42561
+ if (!candidates) continue;
42562
+ const relative4 = file.slice(slash + 1);
42563
+ for (const target of candidates) if (predicate(target, relative4)) return target;
42564
+ }
42565
+ const rootCandidates = byDir.get("");
42566
+ if (rootCandidates) {
42567
+ for (const target of rootCandidates) if (predicate(target, file)) return target;
42568
+ }
42569
+ return void 0;
42570
+ }
42150
42571
  function compiledSwiftSources(files2, targets, overlayFrameworks, headers, nativeSourceGlue = false) {
42151
42572
  const ordered = [...targets].sort((a, b) => b.path.length - a.path.length);
42152
- const owners = new Map(
42153
- Object.entries(files2).filter(([file]) => file.endsWith(".swift")).map(([file, source]) => {
42154
- const owner = ordered.find((target) => {
42155
- const prefix = target.path === "." ? "" : target.path + "/";
42156
- if (!file.startsWith(prefix)) return false;
42157
- const relative4 = file.slice(prefix.length);
42158
- return !target.exclude?.some(
42159
- (excluded) => relative4 === excluded || relative4.startsWith(excluded + "/")
42160
- );
42161
- });
42162
- return [file, { source, owner }];
42163
- })
42164
- );
42573
+ const byDir = indexTargetsByDirectory(ordered);
42574
+ const excludeSets = /* @__PURE__ */ new Map();
42575
+ for (const target of ordered) {
42576
+ if (target.exclude?.length) excludeSets.set(target.name, new Set(target.exclude));
42577
+ }
42578
+ const owners = /* @__PURE__ */ new Map();
42579
+ for (const [file, source] of Object.entries(files2)) {
42580
+ if (!file.endsWith(".swift")) continue;
42581
+ const owner = findTargetForFile(file, byDir, (target, relative4) => {
42582
+ const excluded = excludeSets.get(target.name);
42583
+ return !excluded || !matchesPathPrefixSet(relative4, excluded);
42584
+ });
42585
+ owners.set(file, { source, owner });
42586
+ }
42165
42587
  const swiftSources = /* @__PURE__ */ new Map();
42166
- for (const { source, owner } of owners.values())
42167
- if (owner)
42168
- swiftSources.set(owner.name, [...swiftSources.get(owner.name) ?? [], source]);
42588
+ for (const { source, owner } of owners.values()) {
42589
+ if (!owner) continue;
42590
+ let list2 = swiftSources.get(owner.name);
42591
+ if (!list2) swiftSources.set(owner.name, list2 = []);
42592
+ list2.push(source);
42593
+ }
42169
42594
  const { onWasm, withoutWasm } = swiftTargetArchitectures(targets, swiftSources, headers);
42170
42595
  return new Map(
42171
42596
  [...owners].map(([file, { source, owner }]) => {
@@ -42945,18 +43370,46 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
42945
43370
  const bySourcePath = [...targets].sort(
42946
43371
  (left, right) => right.path.length - left.path.length
42947
43372
  );
43373
+ const targetsByDir = indexTargetsByDirectory(bySourcePath);
43374
+ const targetByName = new Map(targets.map((target) => [target.name, target]));
43375
+ const nativeTargets2 = input.nativeTargets ?? [];
43376
+ const nativeTargetByName = new Map(nativeTargets2.map((target) => [target.name, target]));
43377
+ const nativeTargetIndex = new Map(
43378
+ nativeTargets2.map((target, index) => [target.name, index])
43379
+ );
43380
+ const resourceTargetByName = new Map(
43381
+ resourceTargets.map((target) => [target.name, target])
43382
+ );
43383
+ const targetSourceSets = /* @__PURE__ */ new Map();
43384
+ const targetExcludeFullSets = /* @__PURE__ */ new Map();
43385
+ const targetExcludeExactSets = /* @__PURE__ */ new Map();
43386
+ for (const target of targets) {
43387
+ const prefix = target.path === "." ? "" : `${target.path}/`;
43388
+ if (target.sources !== void 0) {
43389
+ targetSourceSets.set(
43390
+ target.name,
43391
+ new Set(target.sources.map((source) => import_node_path53.default.posix.join(prefix, source)))
43392
+ );
43393
+ }
43394
+ if (target.exclude?.length) {
43395
+ targetExcludeFullSets.set(
43396
+ target.name,
43397
+ new Set(target.exclude.map((excluded) => `${prefix}${excluded}`))
43398
+ );
43399
+ targetExcludeExactSets.set(
43400
+ target.name,
43401
+ new Set(target.exclude.map((name3) => import_node_path53.default.posix.join(target.path, name3)))
43402
+ );
43403
+ }
43404
+ }
42948
43405
  const swiftTargets = /* @__PURE__ */ new Set();
42949
43406
  for (const file of Object.keys(input.files)) {
42950
43407
  if (!file.endsWith(".swift")) continue;
42951
- const target = bySourcePath.find(
42952
- (candidate) => (candidate.path === "." || file.startsWith(`${candidate.path}/`)) && (candidate.sources === void 0 || candidate.sources.some((source) => {
42953
- const selected = import_node_path53.default.posix.join(candidate.path, source);
42954
- return file === selected || file.startsWith(`${selected}/`);
42955
- }))
42956
- );
42957
- const excluded = target?.exclude?.some(
42958
- (name3) => file === import_node_path53.default.posix.join(target.path, name3)
42959
- );
43408
+ const target = findTargetForFile(file, targetsByDir, (candidate) => {
43409
+ const selected = targetSourceSets.get(candidate.name);
43410
+ return !selected || matchesPathPrefixSet(file, selected);
43411
+ });
43412
+ const excluded = target && targetExcludeExactSets.get(target.name)?.has(file);
42960
43413
  if (target && !excluded) swiftTargets.add(target.name);
42961
43414
  }
42962
43415
  const importedModules = /* @__PURE__ */ new Set();
@@ -42994,7 +43447,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
42994
43447
  checkedToolchain = swiftToolchain(pin2.release, swiftModuleSdk(moduleRoot));
42995
43448
  return checkedToolchain;
42996
43449
  };
42997
- const deploymentTarget = (name3) => input.nativeTargets?.find((value) => value.name === name3)?.deploymentTarget ?? targets.find((value) => value.name === name3)?.iosDeploymentTarget ?? null;
43450
+ const deploymentTarget = (name3) => nativeTargetByName.get(name3)?.deploymentTarget ?? targetByName.get(name3)?.iosDeploymentTarget ?? null;
42998
43451
  const targetStagedFiles = /* @__PURE__ */ new Map();
42999
43452
  const stageTargetFile = (target, file, contents2, options2) => {
43000
43453
  const relative4 = import_node_path53.default.relative(layout2.root, file).split(import_node_path53.default.sep).join(import_node_path53.default.posix.sep);
@@ -43006,18 +43459,41 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
43006
43459
  targetStagedFiles.set(target, staged);
43007
43460
  files2.set(file, contents2);
43008
43461
  };
43462
+ const entriesByPrefix = /* @__PURE__ */ new Map();
43463
+ for (const target of targets) {
43464
+ const prefix = target.path === "." ? "" : `${target.path}/`;
43465
+ if (!entriesByPrefix.has(prefix)) entriesByPrefix.set(prefix, []);
43466
+ }
43467
+ for (const entry of Object.entries(input.files)) {
43468
+ const [file] = entry;
43469
+ entriesByPrefix.get("")?.push(entry);
43470
+ for (let end = file.indexOf("/"); end !== -1; end = file.indexOf("/", end + 1)) {
43471
+ entriesByPrefix.get(file.slice(0, end + 1))?.push(entry);
43472
+ }
43473
+ }
43474
+ const targetEntriesCache = /* @__PURE__ */ new Map();
43009
43475
  const targetEntries = (target) => {
43476
+ const cached2 = targetEntriesCache.get(target.name);
43477
+ if (cached2) return cached2;
43010
43478
  const prefix = target.path === "." ? "" : `${target.path}/`;
43011
- return Object.entries(input.files).filter(
43012
- ([file]) => file.startsWith(prefix) && (target.sources === void 0 || !(file.endsWith(".swift") || isSwiftNativeTranslationUnit(file)) || target.sources.some((source) => {
43013
- const selected = import_node_path53.default.posix.join(prefix, source);
43014
- return file === selected || file.startsWith(`${selected}/`);
43015
- })) && !target.exclude?.some(
43016
- (excluded) => file === `${prefix}${excluded}` || file.startsWith(`${prefix}${excluded}/`)
43017
- ) && !targets.some(
43018
- (candidate) => candidate.name !== target.name && candidate.path !== "." && candidate.path.startsWith(prefix) && file.startsWith(`${candidate.path}/`)
43019
- )
43020
- );
43479
+ const selectedSources = targetSourceSets.get(target.name);
43480
+ const excludedPaths = targetExcludeFullSets.get(target.name);
43481
+ const nestedPrefixes = [];
43482
+ for (const candidate of targets) {
43483
+ if (candidate.name !== target.name && candidate.path !== "." && candidate.path.startsWith(prefix))
43484
+ nestedPrefixes.push(`${candidate.path}/`);
43485
+ }
43486
+ const matched = (entriesByPrefix.get(prefix) ?? []).filter(([file]) => {
43487
+ if (selectedSources !== void 0 && (file.endsWith(".swift") || isSwiftNativeTranslationUnit(file)) && !matchesPathPrefixSet(file, selectedSources))
43488
+ return false;
43489
+ if (excludedPaths !== void 0 && matchesPathPrefixSet(file, excludedPaths))
43490
+ return false;
43491
+ if (nestedPrefixes.length > 0 && nestedPrefixes.some((p) => file.startsWith(p)))
43492
+ return false;
43493
+ return true;
43494
+ });
43495
+ targetEntriesCache.set(target.name, matched);
43496
+ return matched;
43021
43497
  };
43022
43498
  const failTargetPreparation = (target, message) => {
43023
43499
  const prefix = target.path === "." ? "" : `${target.path}/`;
@@ -43062,19 +43538,21 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
43062
43538
  return value;
43063
43539
  };
43064
43540
  const podHeaders = /* @__PURE__ */ new Map();
43065
- for (const settings of input.nativeTargets ?? [])
43541
+ for (const settings of nativeTargets2)
43066
43542
  for (const file of settings.headers) {
43067
43543
  const owner = /\/Headers\/(?:Public|Private)\/([\w+-]+)\/(?:\1\/)?[^/]+\.h$/.exec(
43068
43544
  file
43069
43545
  )?.[1];
43070
- if (owner)
43071
- podHeaders.set(import_node_path53.default.basename(file), [
43072
- ...podHeaders.get(import_node_path53.default.basename(file)) ?? [],
43073
- { owner, content: input.files[file] }
43074
- ]);
43546
+ if (owner) {
43547
+ const base2 = import_node_path53.default.basename(file);
43548
+ let list2 = podHeaders.get(base2);
43549
+ if (!list2) podHeaders.set(base2, list2 = []);
43550
+ list2.push({ owner, content: input.files[file] });
43551
+ }
43075
43552
  }
43076
43553
  const podHeaderOwner = (file, content) => /\/Headers\/(?:Public|Private)\/([\w+-]+)\//.exec(file)?.[1] ?? podHeaders.get(import_node_path53.default.basename(file))?.find((header) => header.content === content)?.owner;
43077
- for (const settings of input.nativeTargets ?? []) {
43554
+ const alreadySynced = /* @__PURE__ */ new Map();
43555
+ for (const settings of nativeTargets2) {
43078
43556
  for (const file of settings.headers) {
43079
43557
  const destination = import_node_path53.default.join(layout2.root, file);
43080
43558
  if (files2.has(destination)) continue;
@@ -43091,10 +43569,10 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
43091
43569
  `#import <${interfaceOwner}/${interfaceOwner}-Swift.h>`
43092
43570
  ) : rawContents;
43093
43571
  writeBuildFile(destination, contents2);
43572
+ alreadySynced.set(destination, contents2);
43094
43573
  files2.set(destination, contents2);
43095
43574
  }
43096
43575
  }
43097
- const nativeTargets2 = input.nativeTargets ?? [];
43098
43576
  const fromInputRoot = (file) => file.startsWith(`${SWIFT_NATIVE_INPUT_ROOT}/`) ? import_node_path53.default.join(layout2.root, file.slice(SWIFT_NATIVE_INPUT_ROOT.length + 1)) : file;
43099
43577
  const inRoot = `${layout2.root}${import_node_path53.default.sep}`;
43100
43578
  const binaryTree = `${import_node_path53.default.sep}${SWIFT_BINARY_TREES_DIR}${import_node_path53.default.sep}`;
@@ -43159,12 +43637,10 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
43159
43637
  const prefix = target.path === "." ? "" : `${target.path}/`;
43160
43638
  const entries2 = targetEntries(target);
43161
43639
  const units = entries2.filter(([file]) => isSwiftNativeTranslationUnit(file));
43162
- if (units.length === 0 && !(entries2.some(([file]) => file.endsWith(".swift")) && input.nativeTargets?.some(
43163
- (settings2) => settings2.name === target.name && (settings2.publicHeaders.length > 0 || settings2.bridgingHeader !== null)
43164
- )))
43640
+ const settings = nativeTargetByName.get(target.name);
43641
+ if (units.length === 0 && !(entries2.some(([file]) => file.endsWith(".swift")) && settings !== void 0 && (settings.publicHeaders.length > 0 || settings.bridgingHeader !== null)))
43165
43642
  continue;
43166
43643
  const includes = `${prefix}include/`;
43167
- const settings = input.nativeTargets?.find((value) => value.name === target.name);
43168
43644
  const searchRoots = [
43169
43645
  ...settings?.userHeaderSearchPaths ?? [],
43170
43646
  ...settings?.headerSearchPaths ?? [],
@@ -43195,7 +43671,9 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
43195
43671
  ...searchRoots.map((root) => import_node_path53.default.posix.join(root, include))
43196
43672
  ].find((candidate) => input.files[candidate] !== void 0);
43197
43673
  if (local) {
43198
- reverse.set(local, [...reverse.get(local) ?? [], file]);
43674
+ let parents = reverse.get(local);
43675
+ if (!parents) reverse.set(local, parents = []);
43676
+ parents.push(file);
43199
43677
  if (xcodeTarget && !seenHeaders.has(local)) {
43200
43678
  seenHeaders.add(local);
43201
43679
  searchEntries.push([local, input.files[local]]);
@@ -43241,9 +43719,10 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
43241
43719
  const stageFlags = (flags2, sdkInclude2) => flags2.map(
43242
43720
  (flag) => flag.replaceAll(SWIFT_NATIVE_INPUT_ROOT, layout2.root).replaceAll(SWIFT_NATIVE_SDK_INCLUDE, sdkInclude2)
43243
43721
  );
43722
+ const settingsHeaderFlags = headerSearch.flags[nativeTargetIndex.get(settings.name)];
43244
43723
  const originalFlags = [
43245
43724
  ...settings.flags,
43246
- ...headerSearch.flags[nativeTargets2.indexOf(settings)],
43725
+ ...settingsHeaderFlags,
43247
43726
  ...search,
43248
43727
  ...(settings?.frameworkSearchPaths ?? []).flatMap((dir) => [
43249
43728
  "-F",
@@ -43254,7 +43733,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
43254
43733
  ];
43255
43734
  const importOriginalFlags = settings.flattensPublicHeaders ? [
43256
43735
  ...settings.importerFlags,
43257
- ...headerSearch.flags[nativeTargets2.indexOf(settings)],
43736
+ ...settingsHeaderFlags,
43258
43737
  ...search,
43259
43738
  ...settings.frameworkSearchPaths.flatMap((dir) => [
43260
43739
  "-F",
@@ -43279,7 +43758,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
43279
43758
  }
43280
43759
  return [
43281
43760
  ...kept,
43282
- ...headerSearch.flags[nativeTargets2.indexOf(settings)],
43761
+ ...settingsHeaderFlags,
43283
43762
  ...search,
43284
43763
  ...(settings?.frameworkSearchPaths ?? []).flatMap((dir) => [
43285
43764
  "-F",
@@ -43308,7 +43787,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
43308
43787
  const bundleName = entries2.some(([file]) => file.endsWith(".swift")) ? void 0 : swiftObjCResourceBundleName({
43309
43788
  target: target.name,
43310
43789
  path: target.path,
43311
- resources: resourceTargets.find((candidate) => candidate.name === target.name)?.resources ?? false,
43790
+ resources: resourceTargetByName.get(target.name)?.resources ?? false,
43312
43791
  usesBundleMacro: entries2.some(
43313
43792
  ([file, contents2]) => (isSwiftNativeTranslationUnit(file) || /\.(?:h|hpp|hh|hxx)$/.test(file)) && /\bSWIFTPM_MODULE_BUNDLE\b/.test(contents2)
43314
43793
  ),
@@ -43461,10 +43940,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
43461
43940
  .../\.mm?$/.test(file) ? ["-fobjc-exceptions"] : [],
43462
43941
  ...stageFlags(
43463
43942
  [...objcCxx ? settings.cxxFlags : [], ...fileFlags],
43464
- import_node_path53.default.join(
43465
- swiftSdkPaths(moduleRoot, toolchainBin).sysroot,
43466
- "darwin/usr/include"
43467
- )
43943
+ sdkInclude
43468
43944
  )
43469
43945
  ];
43470
43946
  const moduleFlag = perFile.some((flag) => flag.startsWith("-fmodule-name=")) ? [] : [`-fmodule-name=${swiftTargetModuleName(target.name)}`];
@@ -43504,13 +43980,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
43504
43980
  ...flags,
43505
43981
  ...prefixHeader,
43506
43982
  ...accessorFlags,
43507
- ...stageFlags(
43508
- cxx ? settings.cxxFlags : [],
43509
- import_node_path53.default.join(
43510
- swiftSdkPaths(moduleRoot, toolchainBin).sysroot,
43511
- "darwin/usr/include"
43512
- )
43513
- ),
43983
+ ...stageFlags(cxx ? settings.cxxFlags : [], sdkInclude),
43514
43984
  ...perFile,
43515
43985
  ...moduleFlag
43516
43986
  ]
@@ -43765,7 +44235,9 @@ module ${moduleName2}.Swift {
43765
44235
  }
43766
44236
  ` : swiftObjCModuleMap(
43767
44237
  moduleName2,
43768
- (input.nativeTargets?.find((target) => target.name === name3)?.publicHeaders ?? []).map((header) => import_node_path53.default.join(layout2.root, header)),
44238
+ (nativeTargetByName.get(name3)?.publicHeaders ?? []).map(
44239
+ (header) => import_node_path53.default.join(layout2.root, header)
44240
+ ),
43769
44241
  submoduleImports2.get(moduleName2),
43770
44242
  import_node_path53.default.join(headerDirectory, name3 + "-Swift.h")
43771
44243
  )
@@ -44315,6 +44787,7 @@ ${entry}`);
44315
44787
  files2.set(destination, Buffer.from(bytes, "base64"));
44316
44788
  }
44317
44789
  const targetToolset = nativeToolset || native.size > 0;
44790
+ let usesObjcPrebuilt = false;
44318
44791
  if (targetToolset) {
44319
44792
  const nativeToolsetFlags = [
44320
44793
  ...headerAliasFlags,
@@ -44335,6 +44808,7 @@ ${entry}`);
44335
44808
  [...native.keys()],
44336
44809
  objcPrebuiltStage
44337
44810
  ) : [];
44811
+ usesObjcPrebuilt = prebuiltCompiler.length > 0;
44338
44812
  files2.set(
44339
44813
  clangWrapper2,
44340
44814
  [
@@ -44643,17 +45117,39 @@ package.targets += [.target(name: ${JSON.stringify(name3)}, dependencies: ${JSON
44643
45117
  (name3) => !nativePrerequisiteSet.has(name3)
44644
45118
  );
44645
45119
  const nativeTargetUnitCount = /* @__PURE__ */ new Map();
45120
+ const nativeTargetSources = /* @__PURE__ */ new Map();
44646
45121
  for (const target of manifestTargets)
44647
- if (target.sources?.length)
45122
+ if (target.sources?.length) {
44648
45123
  nativeTargetUnitCount.set(target.name, target.sources.length);
45124
+ nativeTargetSources.set(target.name, target.sources);
45125
+ }
44649
45126
  for (const [name3, plan] of native) {
44650
- if (!plan.mixed && plan.sources.length > 0)
44651
- nativeTargetUnitCount.set(name3, plan.clang?.sources.length ?? plan.sources.length);
44652
- for (const group of plan.groups ?? [])
45127
+ if (!plan.mixed && plan.sources.length > 0) {
45128
+ const sources = plan.clang?.sources ?? plan.sources;
45129
+ nativeTargetUnitCount.set(name3, sources.length);
45130
+ nativeTargetSources.set(name3, sources);
45131
+ }
45132
+ for (const group of plan.groups ?? []) {
44653
45133
  nativeTargetUnitCount.set(group.name, group.sources.length);
44654
- if (plan.late && !plan.groups?.length)
45134
+ nativeTargetSources.set(group.name, group.sources);
45135
+ }
45136
+ if (plan.late && !plan.groups?.length) {
44655
45137
  nativeTargetUnitCount.set(plan.late.name, plan.sources.length);
45138
+ nativeTargetSources.set(plan.late.name, plan.lateSources);
45139
+ }
44656
45140
  }
45141
+ const nativeStageObjects = /* @__PURE__ */ new Map();
45142
+ const recordStageObjects = (stageTarget, members2) => {
45143
+ const objects = [];
45144
+ for (const member of members2) {
45145
+ const sources = nativeTargetSources.get(member);
45146
+ if (!sources || sources.length === 0) return stageTarget;
45147
+ for (const source of sources)
45148
+ objects.push(import_node_path53.default.join(`${member}.build`, `${source}.o`));
45149
+ }
45150
+ nativeStageObjects.set(stageTarget, objects);
45151
+ return stageTarget;
45152
+ };
44657
45153
  const MAX_NATIVE_STAGE_UNITS = 250;
44658
45154
  const chunkNativeStageTargets = (prefix, names) => {
44659
45155
  if (names.length === 0) return [];
@@ -44662,7 +45158,7 @@ package.targets += [.target(name: ${JSON.stringify(name3)}, dependencies: ${JSON
44662
45158
  0
44663
45159
  );
44664
45160
  if (names.length === 1 || total <= MAX_NATIVE_STAGE_UNITS)
44665
- return [buildProduct(prefix, names)];
45161
+ return [recordStageObjects(buildProduct(prefix, names), names)];
44666
45162
  const chunks = [];
44667
45163
  let current2 = [];
44668
45164
  let count = 0;
@@ -44677,7 +45173,9 @@ package.targets += [.target(name: ${JSON.stringify(name3)}, dependencies: ${JSON
44677
45173
  count += size2;
44678
45174
  }
44679
45175
  if (current2.length > 0) chunks.push(current2);
44680
- return chunks.map((members2, index) => buildProduct(`${prefix}${index + 1}`, members2));
45176
+ return chunks.map(
45177
+ (members2, index) => recordStageObjects(buildProduct(`${prefix}${index + 1}`, members2), members2)
45178
+ );
44681
45179
  };
44682
45180
  const nativePrerequisiteStageTargets = chunkNativeStageTargets(
44683
45181
  "PeachHeaderNativePrereqs",
@@ -44688,7 +45186,7 @@ package.targets += [.target(name: ${JSON.stringify(name3)}, dependencies: ${JSON
44688
45186
  remainingNativeBuildTargets
44689
45187
  );
44690
45188
  files2.set(manifestPath, manifest);
44691
- syncSwiftTree(layout2.root, files2);
45189
+ syncSwiftTree(layout2.root, files2, alreadySynced);
44692
45190
  if (layout2.multi)
44693
45191
  for (const target of targets)
44694
45192
  (0, import_node_fs53.mkdirSync)(import_node_path53.default.join(layout2.root, target.path), { recursive: true });
@@ -44703,7 +45201,9 @@ package.targets += [.target(name: ${JSON.stringify(name3)}, dependencies: ${JSON
44703
45201
  targetFailures,
44704
45202
  generatedOwners,
44705
45203
  targetToolset,
44706
- headerCompiler
45204
+ headerCompiler,
45205
+ usesObjcPrebuilt,
45206
+ nativeStageObjects
44707
45207
  };
44708
45208
  }
44709
45209
  function streamText(value) {
@@ -45789,8 +46289,8 @@ ${cap}` : "";
45789
46289
  work,
45790
46290
  unoptimized
45791
46291
  );
45792
- const baseBuildEnv = {
45793
- ...options2.project?.env ?? process.env,
46292
+ const baseBuildEnv = options2.project?.env ? {
46293
+ ...options2.project.env,
45794
46294
  // shipped host plugins resolve against the selected compiler's runtime.
45795
46295
  ...process.platform === "linux" ? {
45796
46296
  LD_LIBRARY_PATH: [
@@ -45800,7 +46300,7 @@ ${cap}` : "";
45800
46300
  ].filter(Boolean).join(":")
45801
46301
  } : {},
45802
46302
  PEACH_DEFER_WASM_LINK: "1"
45803
- };
46303
+ } : swiftCompilerBaseEnv(options2.toolchainBin, process.env);
45804
46304
  const {
45805
46305
  frameworkRoot,
45806
46306
  compileFrameworkRoot,
@@ -45944,7 +46444,11 @@ ${cap}` : "";
45944
46444
  } : {
45945
46445
  ...buildOptions,
45946
46446
  temporaryDirectory,
45947
- env: { ...buildOptions.env, ...compiler }
46447
+ env: {
46448
+ ...buildOptions.env,
46449
+ ...preparation.usesObjcPrebuilt && process.env.PEACH_HOME !== void 0 ? { PEACH_HOME: process.env.PEACH_HOME } : {},
46450
+ ...compiler
46451
+ }
45948
46452
  };
45949
46453
  const unprepared = preparation.targetFailures.map(
45950
46454
  (failure2) => `error: target ${failure2}`
@@ -45991,10 +46495,18 @@ ${cap}` : "";
45991
46495
  // the mirror finds a changed sdk header's readers in their
45992
46496
  // dependency files, which omit system headers by default
45993
46497
  ...mirrorDistribution ? ["-Xswiftc", "-track-system-dependencies"] : [],
45994
- // the link strips debug info, so none is generated (as for the framework)
46498
+ // the link strips debug info, so none is generated (as for the framework).
46499
+ // keep -num-threads fixed across caller core caps so llbuild does not
46500
+ // rebuild every target when callers alternate --cores, and bound backend
46501
+ // fan-out under high -j.
45995
46502
  "-Xswiftc",
45996
46503
  "-gnone",
45997
- ...incrementalPreview ? [] : ["-Xswiftc", "-num-threads", "-Xswiftc", String(perFile ? 1 : jobs)],
46504
+ ...incrementalPreview ? [] : [
46505
+ "-Xswiftc",
46506
+ "-num-threads",
46507
+ "-Xswiftc",
46508
+ String(perFile ? 1 : Math.min(8, import_node_os12.default.availableParallelism()))
46509
+ ],
45998
46510
  ...swiftReproducibleBuildFlags([
45999
46511
  [import_node_path53.default.dirname(options2.toolchainBin), "toolchain"],
46000
46512
  [compileFrameworkRoot, "framework"],
@@ -46169,7 +46681,18 @@ ${cap}` : "";
46169
46681
  }))
46170
46682
  ];
46171
46683
  const checkpoints = import_node_path53.default.join(root, ".build", "peach-product-checkpoints");
46684
+ const buildDbExists = (0, import_node_fs53.existsSync)(import_node_path53.default.join(root, ".build", "build.db"));
46685
+ const releaseDir = import_node_path53.default.dirname(linked);
46172
46686
  for (const { target, producers } of stages) {
46687
+ if (!options2.project && producers.length === 0 && buildDbExists) {
46688
+ const expectedObjects = preparation.nativeStageObjects.get(target);
46689
+ if (expectedObjects && expectedObjects.length > 0 && expectedObjects.every(
46690
+ (relative4) => (0, import_node_fs53.statSync)(import_node_path53.default.join(releaseDir, relative4), {
46691
+ throwIfNoEntry: false
46692
+ })?.isFile()
46693
+ ))
46694
+ continue;
46695
+ }
46173
46696
  const receipt = import_node_path53.default.join(
46174
46697
  checkpoints,
46175
46698
  (0, import_node_crypto32.createHash)("sha256").update(target).digest("hex")
@@ -46394,7 +46917,7 @@ ${cap}` : "";
46394
46917
  options2.signal
46395
46918
  );
46396
46919
  }
46397
- var import_node_child_process32, import_node_crypto32, import_node_fs53, import_node_os12, import_node_path53, v6, WASM_TRIPLE, SWIFTPM_PROGRESS, SWIFTPM_NOISE, distributionManifests, distributionCompileViews, REACH_STAGED_FRAMEWORKS, objcEnumerations, clangDeclarationEnumCache, objcEnumForward, sdkDeclarationOwners, swiftInterfaceDeclarations, linkedModuleDigests, compileSurfaces, SYSTEM_MODULE_LIBRARIES, SYSTEM_MODULE_IMPORT, OPTIONAL_FRAMEWORK_DEPENDENCIES, OPTIONAL_FRAMEWORKS, SWIFT_IMPORT, kleeneNot, kleeneAnd, kleeneOr, NON_IOS_MODULES, sdkPaths, availableModules, sdkOverlayFrameworks, DISTRIBUTION_CLANG_MODULES, CLANG_DISTRIBUTION_MODULES, ONE_PRODUCT, GAME_FAMILY, gameProducts, gameProduct, GAME_REACH, FOUNDATION_IMPLICIT_MODULES, FRAMEWORK_COMPANION_IMPORT, ONE_IMPLICIT_FLAGS, executableLinkFlags, darwinRecordsRegion, REACTOR_FLAG, MULTI_MANIFEST_VERSION, SWIFT_HEADER_PRODUCTS_TARGET, compilerSourceDigest, nativeCxxCompilerFlags, MODULE_MAP_RESPONSE_FILE_RUN, cFlagArray, cxxFlagArray, SWIFTPM_DEFAULT_IOS_DEPLOYMENT_TARGET, OS_IOS, ARCH_ARM64, NOT_ON_IOS, DELEGATE_CLASS, ARM64_MACRO, WASM_MACRO, ARCH_WASM32, C_WORDS, archEnvironments, codeMasks, codeMaskChars, CODE_MASK_CACHE_CHARS, FOUNDATION_NETWORKING_TYPES, FOUNDATION_OVERLAY_TYPES, FOUNDATION_OVERLAY_GLOBALS, CORE_FOUNDATION_OVERLAY_GLOBALS, CORE_FOUNDATION_GEOMETRY_TYPES, CORE_FOUNDATION_GRAPHICS_TYPES, CORE_FOUNDATION_HANDLE_IMPORTS, emptyMacroEnvironment, wasmMacroEnvironment, cPredefineTable, cPredefineCache, HIDDEN_UNITS, FIRST_WINS_PAIRS, LAST_WINS_PAIRS, VALUE_FLAGS, LIBXML_REFERENCE, LIBXML_SOURCE, ROOT_LOCKS, host, rootLocks, SHARED_ARTIFACT_BUDGET_BYTES, SHARED_ARTIFACT_GRACE_MS, RETIRED_PREFIX, retainedArtifacts, FRAMEWORK_LINK_TARGET, frameworkProductsReceiptSchema, SWIFT_LINK_STAMP, SWIFT_HOST_COMPILER_WRAPPER, SWIFT_FRAMEWORK_SLOTS, SWIFT_FRAMEWORK_UNOPTIMIZED_SLOTS, SWIFT_FRAMEWORK_SLOT_KEY, SWIFT_FRAMEWORK_SLOT_ORIGIN;
46920
+ var import_node_child_process32, import_node_crypto32, import_node_fs53, import_node_os12, import_node_path53, v6, WASM_TRIPLE, SWIFTPM_PROGRESS, SWIFTPM_NOISE, SWIFT_COMPILER_ENV_KEYS, distributionManifests, distributionCompileViews, REACH_STAGED_FRAMEWORKS, objcEnumerations, clangDeclarationEnumCache, objcEnumForward, sdkDeclarationOwners, swiftInterfaceDeclarations, linkedModuleDigests, compileSurfaces, SYSTEM_MODULE_LIBRARIES, SYSTEM_MODULE_IMPORT, OPTIONAL_FRAMEWORK_DEPENDENCIES, OPTIONAL_FRAMEWORKS, SWIFT_IMPORT, kleeneNot, kleeneAnd, kleeneOr, NON_IOS_MODULES, sdkPaths, availableModules, sdkOverlayFrameworks, DISTRIBUTION_CLANG_MODULES, CLANG_DISTRIBUTION_MODULES, ONE_PRODUCT, GAME_FAMILY, gameProducts, gameProduct, GAME_REACH, FOUNDATION_IMPLICIT_MODULES, FRAMEWORK_COMPANION_IMPORT, ONE_IMPLICIT_FLAGS, executableLinkFlags, darwinRecordsRegion, REACTOR_FLAG, MULTI_MANIFEST_VERSION, SWIFT_HEADER_PRODUCTS_TARGET, compilerSourceDigest, nativeCxxCompilerFlags, MODULE_MAP_RESPONSE_FILE_RUN, cFlagArray, cxxFlagArray, SWIFTPM_DEFAULT_IOS_DEPLOYMENT_TARGET, OS_IOS, ARCH_ARM64, NOT_ON_IOS, DELEGATE_CLASS, ARM64_MACRO, WASM_MACRO, ARCH_WASM32, C_WORDS, archEnvironments, codeMasks, codeMaskChars, CODE_MASK_CACHE_CHARS, FOUNDATION_NETWORKING_TYPES, FOUNDATION_OVERLAY_TYPES, FOUNDATION_OVERLAY_GLOBALS, CORE_FOUNDATION_OVERLAY_GLOBALS, CORE_FOUNDATION_GEOMETRY_TYPES, CORE_FOUNDATION_GRAPHICS_TYPES, CORE_FOUNDATION_HANDLE_IMPORTS, emptyMacroEnvironment, wasmMacroEnvironment, cPredefineTable, cPredefineCache, HIDDEN_UNITS, FIRST_WINS_PAIRS, LAST_WINS_PAIRS, VALUE_FLAGS, LIBXML_REFERENCE, LIBXML_SOURCE, ROOT_LOCKS, host, rootLocks, SHARED_ARTIFACT_BUDGET_BYTES, SHARED_ARTIFACT_GRACE_MS, RETIRED_PREFIX, retainedArtifacts, FRAMEWORK_LINK_TARGET, frameworkProductsReceiptSchema, SWIFT_LINK_STAMP, SWIFT_HOST_COMPILER_WRAPPER, SWIFT_FRAMEWORK_SLOTS, SWIFT_FRAMEWORK_UNOPTIMIZED_SLOTS, SWIFT_FRAMEWORK_SLOT_KEY, SWIFT_FRAMEWORK_SLOT_ORIGIN;
46398
46921
  var init_swift_compile = __esm({
46399
46922
  "src/swift-compile.ts"() {
46400
46923
  "use strict";
@@ -46447,6 +46970,29 @@ var init_swift_compile = __esm({
46447
46970
  WASM_TRIPLE = SWIFT_WASM_TRIPLE;
46448
46971
  SWIFTPM_PROGRESS = /^\[\d+\/\d+\] /;
46449
46972
  SWIFTPM_NOISE = /^(?:\[\d+\/\d+\] |Building for production\.\.\.$|warning: '--build-system native' has been deprecated)/;
46973
+ SWIFT_COMPILER_ENV_KEYS = [
46974
+ "PATH",
46975
+ "HOME",
46976
+ "USER",
46977
+ "LOGNAME",
46978
+ "LANG",
46979
+ "LC_ALL",
46980
+ "LC_CTYPE",
46981
+ "TZ",
46982
+ "SDKROOT",
46983
+ "DEVELOPER_DIR",
46984
+ "DYLD_LIBRARY_PATH",
46985
+ "SYSTEMROOT",
46986
+ "COMSPEC",
46987
+ "SSL_CERT_FILE",
46988
+ "SSL_CERT_DIR",
46989
+ "HTTP_PROXY",
46990
+ "HTTPS_PROXY",
46991
+ "NO_PROXY",
46992
+ "http_proxy",
46993
+ "https_proxy",
46994
+ "no_proxy"
46995
+ ];
46450
46996
  distributionManifests = /* @__PURE__ */ new Map();
46451
46997
  distributionCompileViews = /* @__PURE__ */ new WeakMap();
46452
46998
  REACH_STAGED_FRAMEWORKS = /* @__PURE__ */ new Set(["React"]);
@@ -46642,7 +47188,7 @@ ${wasmThreadLinkFlags.map((flag) => ` "-Xlinker", ${JSON.stringify(flag
46642
47188
  REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
46643
47189
  MULTI_MANIFEST_VERSION = 76;
46644
47190
  SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
46645
- compilerSourceDigest = true ? "84e8740a8ff00df2947e9a04dd004746185926dfa020e1e4c11e79eb39d1e566" : swiftCompilerSourceDigest(__sootsim_import_meta_dirname);
47191
+ compilerSourceDigest = true ? "4d55fa7cbb29586c08e4e51867226f96047bae2103c89f4fa59d9cf3ed3862fb" : swiftCompilerSourceDigest(__sootsim_import_meta_dirname);
46646
47192
  nativeCxxCompilerFlags = ["-fno-cxx-modules"];
46647
47193
  MODULE_MAP_RESPONSE_FILE_RUN = 16;
46648
47194
  cFlagArray = (flags) => JSON.stringify(withoutGlogModuleMap(flags));
@@ -87089,7 +87635,7 @@ var init_swift_standin_digest = __esm({
87089
87635
  STANDIN_DIGEST_ENTRYPOINTS = ["swift-standins.ts", "swift-objc-compile.ts"];
87090
87636
  SPECIFIER = /from\s*['"]([^'"]+)['"]|import\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
87091
87637
  standinSourceDigest = (srcDir = __sootsim_import_meta_dirname) => sourceClosureDigest(srcDir, STANDIN_DIGEST_ENTRYPOINTS);
87092
- STANDIN_SOURCE_DIGEST = true ? "1c18ee984fb850e9cae4edbd880543482bce4e531c8c17dab14608646edfe47d" : standinSourceDigest();
87638
+ STANDIN_SOURCE_DIGEST = true ? "803880cad876e27e4e621723b8eae85b3c486a882db0f0f745babaf80c070680" : standinSourceDigest();
87093
87639
  }
87094
87640
  });
87095
87641
 
@@ -103551,7 +104097,7 @@ var init_nitro_superset = __esm({
103551
104097
  init_nitroContract();
103552
104098
  init_swift_standin_digest();
103553
104099
  NITRO_SUPERSET_ENTRY_NAME = "superset";
103554
- NITRO_COMPILER_DIGEST = true ? "158901f2ad5a7ece41419fcbea1164e798d53f94d221ae642a58eb58a002a884" : nitroCompilerSourceDigest(__sootsim_import_meta_dirname, STANDIN_SOURCE_DIGEST2);
104100
+ NITRO_COMPILER_DIGEST = true ? "e035fd2365cc4b70f472d1b90eb9d912a775ab289e281922a22092c6945c4f46" : nitroCompilerSourceDigest(__sootsim_import_meta_dirname, STANDIN_SOURCE_DIGEST2);
103555
104101
  nitroSupersetLock = parseLock(nitro_superset_lock_default);
103556
104102
  nitroSupersetKey = (inputs2) => nativeEntryKey({ ...inputs2, compiler: NITRO_COMPILER_DIGEST });
103557
104103
  published = /* @__PURE__ */ new Map();
@@ -104419,7 +104965,7 @@ var init_expo_eager_seam_contract = __esm({
104419
104965
 
104420
104966
  // src/expo-native-compiler-digest.ts
104421
104967
  function expoNativeCompilerDigestValue() {
104422
- return true ? "56c5386e790e97ea00592b0a6a272d29e6c69ed548741daedd6e7ce9c3bcfca1" : expoNativeCompilerDigest(__sootsim_import_meta_dirname);
104968
+ return true ? "4e04e854647f1a1e167543007b405e6d43a936b2b02d7be227ac14a5bcb224f9" : expoNativeCompilerDigest(__sootsim_import_meta_dirname);
104423
104969
  }
104424
104970
  var import_node_crypto78;
104425
104971
  var init_expo_native_compiler_digest = __esm({