peachsim 0.1.2682 → 0.1.2683

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/cli/commands/package.ts +7 -1
  2. package/dist-lib/agent-daemon-client.cjs +1 -1
  3. package/dist-lib/agent-events.cjs +1 -1
  4. package/dist-lib/attached-projects.cjs +1 -1
  5. package/dist-lib/auth/shared-session.cjs +1 -1
  6. package/dist-lib/backend-origin.cjs +1 -1
  7. package/dist-lib/beta.cjs +1 -1
  8. package/dist-lib/beta.mjs +2 -2
  9. package/dist-lib/bridge-constants.cjs +1 -1
  10. package/dist-lib/bridge-contract-input.cjs +1 -1
  11. package/dist-lib/bridge-contract-input.mjs +5 -5
  12. package/dist-lib/bridge-contract.cjs +1 -1
  13. package/dist-lib/bridge-contract.mjs +3 -3
  14. package/dist-lib/bundle-channel.cjs +505 -598
  15. package/dist-lib/capture-contract.cjs +1 -1
  16. package/dist-lib/capture-contract.mjs +3 -3
  17. package/dist-lib/cloud-contract.cjs +1 -1
  18. package/dist-lib/cloud-contract.mjs +3 -3
  19. package/dist-lib/cloud-test-args.cjs +1 -1
  20. package/dist-lib/cloud-test-args.mjs +2 -2
  21. package/dist-lib/cloud.cjs +1 -1
  22. package/dist-lib/cloud.mjs +7 -7
  23. package/dist-lib/config.cjs +1 -1
  24. package/dist-lib/config.mjs +5 -5
  25. package/dist-lib/detox/index.cjs +15 -5
  26. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  27. package/dist-lib/esm-chunks/{acorn-V7B4X5PR.mjs → acorn-IKX32JM5.mjs} +3 -3
  28. package/dist-lib/esm-chunks/{chunk-GNZDVDDX.mjs → chunk-2I4ZO225.mjs} +6 -6
  29. package/dist-lib/esm-chunks/{chunk-AXBK3CA4.mjs → chunk-4QC7XPTA.mjs} +1 -1
  30. package/dist-lib/esm-chunks/{chunk-UTI6VCYT.mjs → chunk-5SA2UPEO.mjs} +1 -1
  31. package/dist-lib/esm-chunks/{chunk-Y6WPXDCC.mjs → chunk-5SZETTJV.mjs} +1 -1
  32. package/dist-lib/esm-chunks/{chunk-R2WPUKVT.mjs → chunk-73CUMN63.mjs} +1 -1
  33. package/dist-lib/esm-chunks/{chunk-X37OP27I.mjs → chunk-7LXBDQQH.mjs} +678 -790
  34. package/dist-lib/esm-chunks/{chunk-LV55WJFQ.mjs → chunk-AYSUZBC3.mjs} +1 -1
  35. package/dist-lib/esm-chunks/{chunk-EK36QRGX.mjs → chunk-BC4OWNHZ.mjs} +1 -1
  36. package/dist-lib/esm-chunks/{chunk-KYIRROKJ.mjs → chunk-BXFBASQX.mjs} +1 -1
  37. package/dist-lib/esm-chunks/{chunk-BJHQOPWO.mjs → chunk-CQ4J5VV3.mjs} +1 -1
  38. package/dist-lib/esm-chunks/{chunk-YKGS4NSG.mjs → chunk-DG7RT7A7.mjs} +5 -5
  39. package/dist-lib/esm-chunks/{chunk-3UQZATB5.mjs → chunk-EZ64444V.mjs} +1 -1
  40. package/dist-lib/esm-chunks/{chunk-SZ5UPZE4.mjs → chunk-HEN6NPXJ.mjs} +1 -1
  41. package/dist-lib/esm-chunks/{chunk-DU3VOY6S.mjs → chunk-HLISQIRP.mjs} +6 -6
  42. package/dist-lib/esm-chunks/{chunk-IOLISFIO.mjs → chunk-JTBC65YO.mjs} +1 -1
  43. package/dist-lib/esm-chunks/{chunk-3VAFU4BM.mjs → chunk-JVSMJ5IO.mjs} +4 -4
  44. package/dist-lib/esm-chunks/{chunk-EC5RY4HR.mjs → chunk-LGV6BWY5.mjs} +2 -2
  45. package/dist-lib/esm-chunks/{chunk-64UA6DQO.mjs → chunk-OGWPMZSB.mjs} +3 -3
  46. package/dist-lib/esm-chunks/{chunk-Z6R2HZIH.mjs → chunk-OTWOI3OW.mjs} +1 -1
  47. package/dist-lib/esm-chunks/{chunk-VTJTOL53.mjs → chunk-QEV3YRKL.mjs} +1 -1
  48. package/dist-lib/esm-chunks/{chunk-6PSNFREM.mjs → chunk-RNZ65XZE.mjs} +1 -1
  49. package/dist-lib/esm-chunks/{chunk-5SWSDDXC.mjs → chunk-S4OXEZXM.mjs} +1 -1
  50. package/dist-lib/esm-chunks/{chunk-ZYD227CX.mjs → chunk-UYWI2SM5.mjs} +1 -1
  51. package/dist-lib/esm-chunks/{chunk-PE7HDZNI.mjs → chunk-WBAH2CS4.mjs} +1 -1
  52. package/dist-lib/esm-chunks/{metro-layout-parser-5RTSOQCS.mjs → metro-layout-parser-6IOBG67O.mjs} +3 -3
  53. package/dist-lib/esm-chunks/{swift-package-prebuilt-EH5JIX6L.mjs → swift-package-prebuilt-NBARV44W.mjs} +12 -12
  54. package/dist-lib/esm-chunks/{swift-sdk-app-module-VHAOCBXW.mjs → swift-sdk-app-module-5K76OLA6.mjs} +16 -16
  55. package/dist-lib/esm-chunks/{swift-sdk-image-3NCWCGQZ.mjs → swift-sdk-image-WJMMMWZH.mjs} +16 -16
  56. package/dist-lib/esm-chunks/{swift-sdk-image-producer-5S4IKSJ2.mjs → swift-sdk-image-producer-M23OLZGS.mjs} +5 -5
  57. package/dist-lib/expo-swift-bundle.cjs +495 -593
  58. package/dist-lib/expo-swift-metadata.cjs +1 -1
  59. package/dist-lib/expo-swift-metadata.mjs +7 -7
  60. package/dist-lib/home-paths.cjs +1 -1
  61. package/dist-lib/host/bridge-host.cjs +620 -715
  62. package/dist-lib/host/fetch-proxy-handler.cjs +22 -24
  63. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  64. package/dist-lib/host/fetch-proxy-overrides.mjs +2 -2
  65. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  66. package/dist-lib/host/websocket-proxy.cjs +1 -1
  67. package/dist-lib/index.cjs +1 -1
  68. package/dist-lib/kotlin-host.cjs +1 -1
  69. package/dist-lib/menu.cjs +1 -1
  70. package/dist-lib/menu.mjs +3 -3
  71. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  72. package/dist-lib/metro-fingerprint-registry.mjs +3 -3
  73. package/dist-lib/metro-production-bundle.cjs +1 -1
  74. package/dist-lib/metro-production-bundle.mjs +4 -4
  75. package/dist-lib/native-app-identity-project.cjs +1 -1
  76. package/dist-lib/native-app-identity-project.mjs +15 -15
  77. package/dist-lib/native-app-identity.cjs +1 -1
  78. package/dist-lib/native-app-identity.mjs +6 -6
  79. package/dist-lib/native-firebase-metadata.cjs +1 -1
  80. package/dist-lib/native-firebase-metadata.mjs +3 -3
  81. package/dist-lib/pdfium-raster.cjs +1 -1
  82. package/dist-lib/pdfium-raster.mjs +2 -2
  83. package/dist-lib/plist.cjs +1 -1
  84. package/dist-lib/plist.mjs +3 -3
  85. package/dist-lib/profiles.cjs +1 -1
  86. package/dist-lib/public-brand.cjs +1 -1
  87. package/dist-lib/public-origins-lib-esm.json +87 -87
  88. package/dist-lib/public-origins-lib.json +76 -76
  89. package/dist-lib/react-native-host-modules.cjs +1 -1
  90. package/dist-lib/react-native-host-modules.mjs +2 -2
  91. package/dist-lib/reap-browser.cjs +1 -1
  92. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  93. package/dist-lib/sdk.cjs +1 -1
  94. package/dist-lib/sdk.mjs +8 -8
  95. package/dist-lib/skills.cjs +622 -717
  96. package/dist-lib/swift-compile.cjs +502 -618
  97. package/dist-lib/swift-compile.mjs +12 -12
  98. package/dist-lib/swift-package.cjs +1 -1
  99. package/dist-lib/swift-package.mjs +3 -3
  100. package/dist-lib/swift-submit.cjs +1 -1
  101. package/dist-lib/swift-submit.mjs +6 -6
  102. package/dist-lib/swift-svg-raster.cjs +1 -1
  103. package/dist-lib/swift-svg-raster.mjs +2 -2
  104. package/dist-lib/swift-toolchain.cjs +1 -1
  105. package/dist-lib/swift.cjs +1 -1
  106. package/dist-lib/vendor/@peculiar/x509.cjs +1 -1
  107. package/dist-lib/vendor/@ruby/prism/src/nodes.js.cjs +1 -1
  108. package/dist-lib/vendor/@ruby/prism/src/parsePrism.js.cjs +1 -1
  109. package/dist-lib/vendor/acorn.cjs +1 -1
  110. package/dist-lib/vendor/magic-string.cjs +1 -1
  111. package/dist-lib/vendor/stream-json.cjs +1 -1
  112. package/dist-lib/vendor/sucrase/dist/index.js.cjs +1 -1
  113. package/dist-lib/vendor/sucrase/dist/parser/index.js.cjs +1 -1
  114. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/index.js.cjs +1 -1
  115. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/types.js.cjs +1 -1
  116. package/dist-lib/vendor/sucrase.cjs +1 -1
  117. package/dist-lib/vendor/terser.cjs +1 -1
  118. package/dist-lib/vendor/valibot.cjs +1 -1
  119. package/dist-lib/vendor/ws.cjs +1 -1
  120. package/dist-lib/vendor/zod.cjs +1 -1
  121. package/dist-lib/worklet-executable.cjs +1 -1
  122. package/dist-lib/worklet-executable.mjs +3 -3
  123. package/dist-types/packages/peach-engine/src/engine/image-fetch.d.ts +1 -0
  124. package/package.json +1 -1
  125. package/runtime-companion.json +1 -1
  126. package/src/native-bundles.ts +7 -1
  127. package/src/native-package-slice.ts +28 -12
  128. package/src/nitro-bundle.ts +1 -0
  129. package/src/nitro-compile.ts +8 -2
  130. package/src/nitroContract.ts +35 -14
  131. package/src/one-sdk-bundle.ts +2 -2
  132. package/src/swift-compile.ts +25 -131
  133. package/src/swift-guest-compile.ts +184 -218
  134. package/src/swift-host.ts +13 -23
  135. package/src/swift-submit.ts +0 -2
  136. package/src/turbo-bundle.ts +2 -2
  137. package/src/turbo-compile.ts +0 -1
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2682 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2683 | (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;
@@ -19553,7 +19553,7 @@ var init_react_native_core_digest = __esm({
19553
19553
 
19554
19554
  // src/swift-compiler-digest.ts
19555
19555
  function swiftArchiveCompilerDigestValue() {
19556
- return true ? "7ec504e1047ea0f31b14e25b8958c42fd1e55cb9c121db3f05e4dead6ef226eb" : swiftCompilerSourceDigest(__sootsim_import_meta_dirname, "archive");
19556
+ return true ? "c304a2da11e2e676fe221d87209a1136a730fd7ea4bf5d094065fd377480ecef" : swiftCompilerSourceDigest(__sootsim_import_meta_dirname, "archive");
19557
19557
  }
19558
19558
  var import_node_crypto16, import_node_fs32, import_node_path31, SWIFT_DIGEST_SOURCES, LINKED_IMAGE_SOURCES, SWIFT_ARCHIVE_DIGEST_SOURCES;
19559
19559
  var init_swift_compiler_digest = __esm({
@@ -19704,7 +19704,7 @@ var init_swift_standin_digest = __esm({
19704
19704
 
19705
19705
  // src/expo-native-compiler-digest.ts
19706
19706
  function expoNativeCompilerDigestValue() {
19707
- return true ? "dd69e490ecc79ee83e8cba98c4532818a62e9b0e93c21113e2d6c21ec60d8eee" : expoNativeCompilerDigest(__sootsim_import_meta_dirname);
19707
+ return true ? "13d332cac87de68ec66d60f9bb7b02f5fbfb1cf35a281ec222570bd0562878cd" : expoNativeCompilerDigest(__sootsim_import_meta_dirname);
19708
19708
  }
19709
19709
  var import_node_crypto18;
19710
19710
  var init_expo_native_compiler_digest = __esm({
@@ -22859,9 +22859,6 @@ var init_retired_cache_directory = __esm({
22859
22859
  });
22860
22860
 
22861
22861
  // src/swift-compile-budget.ts
22862
- function swiftBuilderHopTimeoutMs(compileTimeoutMs) {
22863
- return SWIFT_LOCK_WAIT_TIMEOUT_MS + (compileTimeoutMs ?? SWIFT_COMPILE_TIMEOUT_MS) + SWIFT_TRANSPORT_MARGIN_MS;
22864
- }
22865
22862
  async function withSwiftCompileBudget(compileTimeoutMs, signal, work) {
22866
22863
  const deadline = new AbortController();
22867
22864
  const combined = signal ? AbortSignal.any([signal, deadline.signal]) : deadline.signal;
@@ -22901,13 +22898,12 @@ async function withSwiftCompileBudget(compileTimeoutMs, signal, work) {
22901
22898
  clearTimeout(timer);
22902
22899
  }
22903
22900
  }
22904
- var SWIFT_COMPILE_TIMEOUT_MS, SWIFT_LOCK_WAIT_TIMEOUT_MS, SWIFT_TRANSPORT_MARGIN_MS;
22901
+ var SWIFT_COMPILE_TIMEOUT_MS, SWIFT_LOCK_WAIT_TIMEOUT_MS;
22905
22902
  var init_swift_compile_budget = __esm({
22906
22903
  "src/swift-compile-budget.ts"() {
22907
22904
  "use strict";
22908
22905
  SWIFT_COMPILE_TIMEOUT_MS = 18e5;
22909
22906
  SWIFT_LOCK_WAIT_TIMEOUT_MS = 36e5;
22910
- SWIFT_TRANSPORT_MARGIN_MS = 3e5;
22911
22907
  }
22912
22908
  });
22913
22909
 
@@ -29142,281 +29138,6 @@ var init_swift_guest_archive = __esm({
29142
29138
  }
29143
29139
  });
29144
29140
 
29145
- // ../peach-kit/src/nativeWasmContract.ts
29146
- var NATIVE_IMAGE_SECTION, NATIVE_TABLE_ABI, NATIVE_TABLE_IMPORT_MODULE, NATIVE_DYLD_FUNCTION_IMPORT, NATIVE_DYLD_PLACE_EXPORT, NATIVE_LAZY_IMPORT_MODULE, NATIVE_SDK_IMPORT_MODULE, NATIVE_SDK_THUNK_SECTION, NATIVE_LAZY_SLOT_IMPORT, NATIVE_LAZY_SECTION, NATIVE_LAZY_DIGEST_BYTES, NATIVE_LAZY_PART_BYTES, NATIVE_TABLE_RESERVE_SLOTS;
29147
- var init_nativeWasmContract = __esm({
29148
- "../peach-kit/src/nativeWasmContract.ts"() {
29149
- "use strict";
29150
- NATIVE_IMAGE_SECTION = "peach.native-image-v1";
29151
- NATIVE_TABLE_ABI = "peach-native-table-v1";
29152
- NATIVE_TABLE_IMPORT_MODULE = "peach_thread";
29153
- NATIVE_DYLD_FUNCTION_IMPORT = "dyld_function";
29154
- NATIVE_DYLD_PLACE_EXPORT = "__peach_dyld_place";
29155
- NATIVE_LAZY_IMPORT_MODULE = "peach_lazy";
29156
- NATIVE_SDK_IMPORT_MODULE = "peach_sdk";
29157
- NATIVE_SDK_THUNK_SECTION = "peach.sdk-thunks";
29158
- NATIVE_LAZY_SLOT_IMPORT = "load_slot";
29159
- NATIVE_LAZY_SECTION = "peach.lazy-code-v2";
29160
- NATIVE_LAZY_DIGEST_BYTES = 32;
29161
- NATIVE_LAZY_PART_BYTES = NATIVE_LAZY_DIGEST_BYTES + 4;
29162
- NATIVE_TABLE_RESERVE_SLOTS = 4096;
29163
- }
29164
- });
29165
-
29166
- // src/swift-guest-dyld-functions.ts
29167
- function skipValueType(r) {
29168
- const type = r.byte();
29169
- if (type === 99 || type === 100) r.s();
29170
- }
29171
- function readImports2(bytes, sections) {
29172
- let functions = 0;
29173
- let table64;
29174
- const imports2 = sections.find((s) => s.id === 2);
29175
- if (imports2) {
29176
- const r = wasmReader(bytes, imports2.start);
29177
- for (let n = r.u(); n > 0; n--) {
29178
- r.name();
29179
- r.name();
29180
- const kind = r.byte();
29181
- if (kind === 0) {
29182
- functions++;
29183
- r.u();
29184
- } else if (kind === 1 || kind === 2) {
29185
- if (kind === 1) skipValueType(r);
29186
- const flags = r.u();
29187
- r.u();
29188
- if (flags & 1) r.u();
29189
- if (kind === 1) table64 ??= (flags & 4) !== 0;
29190
- } else if (kind === 3) {
29191
- skipValueType(r);
29192
- r.byte();
29193
- } else if (kind === 4) {
29194
- r.byte();
29195
- r.u();
29196
- } else throw new Error(`unsupported wasm import kind ${kind}`);
29197
- }
29198
- }
29199
- const tables = sections.find((s) => s.id === 4);
29200
- if (table64 === void 0 && tables) {
29201
- const r = wasmReader(bytes, tables.start);
29202
- if (r.u()) {
29203
- skipValueType(r);
29204
- table64 = (r.u() & 4) !== 0;
29205
- }
29206
- }
29207
- return { functions, table64 };
29208
- }
29209
- function vectorSection(id, count, parts) {
29210
- const body = Buffer.concat([Buffer.from(uleb2(count)), ...parts]);
29211
- return Buffer.concat([Buffer.from([id, ...uleb2(body.length)]), body]);
29212
- }
29213
- function rewriteSections(bytes, sections, changes) {
29214
- const out = [bytes.subarray(0, 8)];
29215
- const pending = new Map(changes);
29216
- const flushBefore = (id) => {
29217
- for (const [missing, section2] of pending) {
29218
- if (SECTION_ORDER.indexOf(missing) >= SECTION_ORDER.indexOf(id)) continue;
29219
- if (section2) out.push(section2);
29220
- pending.delete(missing);
29221
- }
29222
- };
29223
- for (const s of sections) {
29224
- if (s.id !== 0) flushBefore(s.id);
29225
- if (!pending.has(s.id)) {
29226
- out.push(bytes.subarray(s.offset, s.end));
29227
- continue;
29228
- }
29229
- const section2 = pending.get(s.id);
29230
- pending.delete(s.id);
29231
- if (section2) out.push(section2);
29232
- }
29233
- for (const section2 of pending.values()) if (section2) out.push(section2);
29234
- return Buffer.concat(out);
29235
- }
29236
- function entries(bytes, section2, entry) {
29237
- if (!section2) return [];
29238
- const r = wasmReader(bytes, section2.start);
29239
- const out = [];
29240
- for (let n = r.u(); n > 0; n--) {
29241
- const begin = r.at;
29242
- entry(r);
29243
- out.push(bytes.subarray(begin, r.at));
29244
- }
29245
- if (r.at !== section2.end) throw new Error(`invalid wasm section ${section2.id}`);
29246
- return out;
29247
- }
29248
- function appendLazyPlacement(bytes, functions, table) {
29249
- const sections = wasmSections(bytes);
29250
- const section2 = (id) => sections.find((s) => s.id === id);
29251
- const imports2 = readImports2(bytes, sections);
29252
- const changes = /* @__PURE__ */ new Map();
29253
- let table64 = imports2.table64;
29254
- if (table64 === void 0) {
29255
- if (!table) throw new Error("native image has no function table");
29256
- table64 = table.table64;
29257
- const found = section2(2);
29258
- const header = found && wasmReader(bytes, found.start);
29259
- const count = header ? header.u() : 0;
29260
- const module2 = Buffer.from("primary");
29261
- const name4 = Buffer.from(table.name);
29262
- changes.set(
29263
- 2,
29264
- vectorSection(2, count + 1, [
29265
- found && header ? bytes.subarray(header.at, found.end) : new Uint8Array(),
29266
- Buffer.from([
29267
- ...uleb2(module2.length),
29268
- ...module2,
29269
- ...uleb2(name4.length),
29270
- ...name4,
29271
- 1,
29272
- 112,
29273
- table64 ? 4 : 0,
29274
- 0
29275
- ])
29276
- ])
29277
- );
29278
- }
29279
- const types2 = entries(bytes, section2(1), (r) => {
29280
- if (r.byte() !== 96) throw new Error("native image has a non-function type");
29281
- for (let side = 0; side < 2; side++) for (let n = r.u(); n > 0; n--) skipValueType(r);
29282
- });
29283
- const declared = entries(bytes, section2(3), (r) => r.u());
29284
- const bodies = entries(bytes, section2(10), (r) => r.skip(r.u()));
29285
- const exports2 = entries(bytes, section2(7), readExport);
29286
- const elements = entries(bytes, section2(9), skipElementSegment);
29287
- const placementIndex = lastTableElement(elements) + 1;
29288
- elements.splice(
29289
- placementIndex,
29290
- 0,
29291
- Buffer.from([1, 0, ...uleb2(functions.length), ...functions.flatMap(uleb2)])
29292
- );
29293
- const place2 = imports2.functions + declared.length;
29294
- const instructions = [
29295
- 0,
29296
- 32,
29297
- 1,
29298
- ...table64 ? [173] : [],
29299
- 32,
29300
- 0,
29301
- 65,
29302
- 1,
29303
- 252,
29304
- 12,
29305
- ...uleb2(placementIndex),
29306
- 0,
29307
- 11
29308
- ];
29309
- const name3 = Buffer.from(NATIVE_DYLD_PLACE_EXPORT);
29310
- return rewriteSections(
29311
- bytes,
29312
- sections,
29313
- new Map([
29314
- ...changes,
29315
- [
29316
- 1,
29317
- vectorSection(1, types2.length + 1, [
29318
- ...types2,
29319
- Buffer.from([96, 2, 127, 127, 0])
29320
- ])
29321
- ],
29322
- [
29323
- 3,
29324
- vectorSection(3, declared.length + 1, [
29325
- ...declared,
29326
- Buffer.from(uleb2(types2.length))
29327
- ])
29328
- ],
29329
- [
29330
- 7,
29331
- vectorSection(7, exports2.length + 1, [
29332
- ...exports2,
29333
- Buffer.from([...uleb2(name3.length), ...name3, 0, ...uleb2(place2)])
29334
- ])
29335
- ],
29336
- [9, vectorSection(9, elements.length, elements)],
29337
- [
29338
- 10,
29339
- vectorSection(10, bodies.length + 1, [
29340
- ...bodies,
29341
- Buffer.from([...uleb2(instructions.length), ...instructions])
29342
- ])
29343
- ]
29344
- ])
29345
- );
29346
- }
29347
- function skipConstant(r) {
29348
- for (let op = r.byte(); op !== 11; op = r.byte()) {
29349
- if (op === 65 || op === 66) r.s();
29350
- else if (op === 35 || op === 210) r.u();
29351
- else if (op === 208) r.s();
29352
- else if (![106, 107, 108, 124, 125, 126].includes(op))
29353
- throw new Error(`unsupported constant expression op ${op}`);
29354
- }
29355
- }
29356
- function skipElementSegment(r) {
29357
- const flags = r.u();
29358
- if (flags > 7) throw new Error(`unsupported element segment flags ${flags}`);
29359
- if ((flags & 3) === 2) r.u();
29360
- if (!(flags & 1)) skipConstant(r);
29361
- if (flags & 3) skipValueType(r);
29362
- for (let count = r.u(); count > 0; count--)
29363
- if (flags & 4) skipConstant(r);
29364
- else r.u();
29365
- }
29366
- function placeGuestLazyFunctions(bytes, lazy) {
29367
- const sections = wasmSections(bytes);
29368
- const lazyIndex = new Map(lazy.map((name3, index) => [name3, index]));
29369
- const functions = new Array(lazy.length);
29370
- let found = 0;
29371
- const kept = entries(
29372
- bytes,
29373
- sections.find((s) => s.id === 7),
29374
- readExport
29375
- ).filter((entry) => {
29376
- const r = wasmReader(entry, 0);
29377
- const position = lazyIndex.get(r.name());
29378
- const kind = r.byte();
29379
- if (kind !== 0 || position === void 0) return true;
29380
- functions[position] = r.u();
29381
- found++;
29382
- return false;
29383
- });
29384
- if (found !== lazy.length)
29385
- throw new Error("guest link lost a lazy dlsym function export");
29386
- return appendLazyPlacement(
29387
- rewriteSections(bytes, sections, /* @__PURE__ */ new Map([[7, vectorSection(7, kept.length, kept)]])),
29388
- functions
29389
- );
29390
- }
29391
- function guestLazyExports(lazy) {
29392
- return lazy.map((name3) => JSON.stringify(`--export=${name3}`)).join("\n");
29393
- }
29394
- var uleb2, SECTION_ORDER, readExport, lastTableElement;
29395
- var init_swift_guest_dyld_functions = __esm({
29396
- "src/swift-guest-dyld-functions.ts"() {
29397
- "use strict";
29398
- init_nativeWasmContract();
29399
- init_swift_sdk_image_wasm();
29400
- uleb2 = (value) => {
29401
- const out = [];
29402
- do {
29403
- let byte = value % 128;
29404
- value = Math.floor(value / 128);
29405
- if (value) byte |= 128;
29406
- out.push(byte);
29407
- } while (value);
29408
- return out;
29409
- };
29410
- SECTION_ORDER = [1, 2, 3, 4, 5, 13, 6, 7, 8, 9, 12, 10, 11];
29411
- readExport = (r) => {
29412
- r.name();
29413
- r.byte();
29414
- r.u();
29415
- };
29416
- lastTableElement = (segments) => segments.findLastIndex((segment2) => (segment2[0] & 3) !== 3);
29417
- }
29418
- });
29419
-
29420
29141
  // ../peach-kit/src/nativeDyldTableContract.ts
29421
29142
  function nativeDyldName(bytes) {
29422
29143
  let name3 = "";
@@ -29467,6 +29188,27 @@ var init_nativeDyldTableContract = __esm({
29467
29188
  }
29468
29189
  });
29469
29190
 
29191
+ // ../peach-kit/src/nativeWasmContract.ts
29192
+ var NATIVE_IMAGE_SECTION, NATIVE_TABLE_ABI, NATIVE_TABLE_IMPORT_MODULE, NATIVE_DYLD_FUNCTION_IMPORT, NATIVE_DYLD_PLACE_EXPORT, NATIVE_LAZY_IMPORT_MODULE, NATIVE_SDK_IMPORT_MODULE, NATIVE_SDK_THUNK_SECTION, NATIVE_LAZY_SLOT_IMPORT, NATIVE_LAZY_SECTION, NATIVE_LAZY_DIGEST_BYTES, NATIVE_LAZY_PART_BYTES, NATIVE_TABLE_RESERVE_SLOTS;
29193
+ var init_nativeWasmContract = __esm({
29194
+ "../peach-kit/src/nativeWasmContract.ts"() {
29195
+ "use strict";
29196
+ NATIVE_IMAGE_SECTION = "peach.native-image-v1";
29197
+ NATIVE_TABLE_ABI = "peach-native-table-v1";
29198
+ NATIVE_TABLE_IMPORT_MODULE = "peach_thread";
29199
+ NATIVE_DYLD_FUNCTION_IMPORT = "dyld_function";
29200
+ NATIVE_DYLD_PLACE_EXPORT = "__peach_dyld_place";
29201
+ NATIVE_LAZY_IMPORT_MODULE = "peach_lazy";
29202
+ NATIVE_SDK_IMPORT_MODULE = "peach_sdk";
29203
+ NATIVE_SDK_THUNK_SECTION = "peach.sdk-thunks";
29204
+ NATIVE_LAZY_SLOT_IMPORT = "load_slot";
29205
+ NATIVE_LAZY_SECTION = "peach.lazy-code-v2";
29206
+ NATIVE_LAZY_DIGEST_BYTES = 32;
29207
+ NATIVE_LAZY_PART_BYTES = NATIVE_LAZY_DIGEST_BYTES + 4;
29208
+ NATIVE_TABLE_RESERVE_SLOTS = 4096;
29209
+ }
29210
+ });
29211
+
29470
29212
  // src/swift-guest-image-ledger.ts
29471
29213
  function readNumber(bytes, position) {
29472
29214
  if (position < bytes.length) {
@@ -31146,7 +30888,7 @@ function sha256Hex3(bytes) {
31146
30888
  return new Bun.CryptoHasher("sha256").update(bytes).digest("hex");
31147
30889
  return (0, import_node_crypto28.createHash)("sha256").update(bytes).digest("hex");
31148
30890
  }
31149
- function uleb3(value) {
30891
+ function uleb2(value) {
31150
30892
  const bytes = [];
31151
30893
  for (let rest = value; ; rest = Math.floor(rest / 128)) {
31152
30894
  if (rest < 128) return [...bytes, rest];
@@ -31165,7 +30907,7 @@ function encodeGuestDyldTable(rows) {
31165
30907
  value.writeBigUInt64LE(row.value);
31166
30908
  const bytes = Buffer.concat([
31167
30909
  row.bytes,
31168
- Buffer.from([0, ...uleb3(row.image), row.kind]),
30910
+ Buffer.from([0, ...uleb2(row.image), row.kind]),
31169
30911
  value
31170
30912
  ]);
31171
30913
  if (!current2.length) firsts.push(row.bytes);
@@ -31287,6 +31029,260 @@ var init_mapLimit = __esm({
31287
31029
  }
31288
31030
  });
31289
31031
 
31032
+ // src/swift-guest-dyld-functions.ts
31033
+ function skipValueType(r) {
31034
+ const type = r.byte();
31035
+ if (type === 99 || type === 100) r.s();
31036
+ }
31037
+ function readImports2(bytes, sections) {
31038
+ let functions = 0;
31039
+ let table64;
31040
+ const imports2 = sections.find((s) => s.id === 2);
31041
+ if (imports2) {
31042
+ const r = wasmReader(bytes, imports2.start);
31043
+ for (let n = r.u(); n > 0; n--) {
31044
+ r.name();
31045
+ r.name();
31046
+ const kind = r.byte();
31047
+ if (kind === 0) {
31048
+ functions++;
31049
+ r.u();
31050
+ } else if (kind === 1 || kind === 2) {
31051
+ if (kind === 1) skipValueType(r);
31052
+ const flags = r.u();
31053
+ r.u();
31054
+ if (flags & 1) r.u();
31055
+ if (kind === 1) table64 ??= (flags & 4) !== 0;
31056
+ } else if (kind === 3) {
31057
+ skipValueType(r);
31058
+ r.byte();
31059
+ } else if (kind === 4) {
31060
+ r.byte();
31061
+ r.u();
31062
+ } else throw new Error(`unsupported wasm import kind ${kind}`);
31063
+ }
31064
+ }
31065
+ const tables = sections.find((s) => s.id === 4);
31066
+ if (table64 === void 0 && tables) {
31067
+ const r = wasmReader(bytes, tables.start);
31068
+ if (r.u()) {
31069
+ skipValueType(r);
31070
+ table64 = (r.u() & 4) !== 0;
31071
+ }
31072
+ }
31073
+ return { functions, table64 };
31074
+ }
31075
+ function vectorSection(id, count, parts) {
31076
+ const body = Buffer.concat([Buffer.from(uleb3(count)), ...parts]);
31077
+ return Buffer.concat([Buffer.from([id, ...uleb3(body.length)]), body]);
31078
+ }
31079
+ function rewriteSections(bytes, sections, changes) {
31080
+ const out = [bytes.subarray(0, 8)];
31081
+ const pending = new Map(changes);
31082
+ const flushBefore = (id) => {
31083
+ for (const [missing, section2] of pending) {
31084
+ if (SECTION_ORDER.indexOf(missing) >= SECTION_ORDER.indexOf(id)) continue;
31085
+ if (section2) out.push(section2);
31086
+ pending.delete(missing);
31087
+ }
31088
+ };
31089
+ for (const s of sections) {
31090
+ if (s.id !== 0) flushBefore(s.id);
31091
+ if (!pending.has(s.id)) {
31092
+ out.push(bytes.subarray(s.offset, s.end));
31093
+ continue;
31094
+ }
31095
+ const section2 = pending.get(s.id);
31096
+ pending.delete(s.id);
31097
+ if (section2) out.push(section2);
31098
+ }
31099
+ for (const section2 of pending.values()) if (section2) out.push(section2);
31100
+ return Buffer.concat(out);
31101
+ }
31102
+ function entries(bytes, section2, entry) {
31103
+ if (!section2) return [];
31104
+ const r = wasmReader(bytes, section2.start);
31105
+ const out = [];
31106
+ for (let n = r.u(); n > 0; n--) {
31107
+ const begin = r.at;
31108
+ entry(r);
31109
+ out.push(bytes.subarray(begin, r.at));
31110
+ }
31111
+ if (r.at !== section2.end) throw new Error(`invalid wasm section ${section2.id}`);
31112
+ return out;
31113
+ }
31114
+ function appendLazyPlacement(bytes, functions, table) {
31115
+ const sections = wasmSections(bytes);
31116
+ const section2 = (id) => sections.find((s) => s.id === id);
31117
+ const imports2 = readImports2(bytes, sections);
31118
+ const changes = /* @__PURE__ */ new Map();
31119
+ let table64 = imports2.table64;
31120
+ if (table64 === void 0) {
31121
+ if (!table) throw new Error("native image has no function table");
31122
+ table64 = table.table64;
31123
+ const found = section2(2);
31124
+ const header = found && wasmReader(bytes, found.start);
31125
+ const count = header ? header.u() : 0;
31126
+ const module2 = Buffer.from("primary");
31127
+ const name4 = Buffer.from(table.name);
31128
+ changes.set(
31129
+ 2,
31130
+ vectorSection(2, count + 1, [
31131
+ found && header ? bytes.subarray(header.at, found.end) : new Uint8Array(),
31132
+ Buffer.from([
31133
+ ...uleb3(module2.length),
31134
+ ...module2,
31135
+ ...uleb3(name4.length),
31136
+ ...name4,
31137
+ 1,
31138
+ 112,
31139
+ table64 ? 4 : 0,
31140
+ 0
31141
+ ])
31142
+ ])
31143
+ );
31144
+ }
31145
+ const types2 = entries(bytes, section2(1), (r) => {
31146
+ if (r.byte() !== 96) throw new Error("native image has a non-function type");
31147
+ for (let side = 0; side < 2; side++) for (let n = r.u(); n > 0; n--) skipValueType(r);
31148
+ });
31149
+ const declared = entries(bytes, section2(3), (r) => r.u());
31150
+ const bodies = entries(bytes, section2(10), (r) => r.skip(r.u()));
31151
+ const exports2 = entries(bytes, section2(7), readExport);
31152
+ const elements = entries(bytes, section2(9), skipElementSegment);
31153
+ const placementIndex = lastTableElement(elements) + 1;
31154
+ elements.splice(
31155
+ placementIndex,
31156
+ 0,
31157
+ Buffer.from([1, 0, ...uleb3(functions.length), ...functions.flatMap(uleb3)])
31158
+ );
31159
+ const place2 = imports2.functions + declared.length;
31160
+ const instructions = [
31161
+ 0,
31162
+ 32,
31163
+ 1,
31164
+ ...table64 ? [173] : [],
31165
+ 32,
31166
+ 0,
31167
+ 65,
31168
+ 1,
31169
+ 252,
31170
+ 12,
31171
+ ...uleb3(placementIndex),
31172
+ 0,
31173
+ 11
31174
+ ];
31175
+ const name3 = Buffer.from(NATIVE_DYLD_PLACE_EXPORT);
31176
+ return rewriteSections(
31177
+ bytes,
31178
+ sections,
31179
+ new Map([
31180
+ ...changes,
31181
+ [
31182
+ 1,
31183
+ vectorSection(1, types2.length + 1, [
31184
+ ...types2,
31185
+ Buffer.from([96, 2, 127, 127, 0])
31186
+ ])
31187
+ ],
31188
+ [
31189
+ 3,
31190
+ vectorSection(3, declared.length + 1, [
31191
+ ...declared,
31192
+ Buffer.from(uleb3(types2.length))
31193
+ ])
31194
+ ],
31195
+ [
31196
+ 7,
31197
+ vectorSection(7, exports2.length + 1, [
31198
+ ...exports2,
31199
+ Buffer.from([...uleb3(name3.length), ...name3, 0, ...uleb3(place2)])
31200
+ ])
31201
+ ],
31202
+ [9, vectorSection(9, elements.length, elements)],
31203
+ [
31204
+ 10,
31205
+ vectorSection(10, bodies.length + 1, [
31206
+ ...bodies,
31207
+ Buffer.from([...uleb3(instructions.length), ...instructions])
31208
+ ])
31209
+ ]
31210
+ ])
31211
+ );
31212
+ }
31213
+ function skipConstant(r) {
31214
+ for (let op = r.byte(); op !== 11; op = r.byte()) {
31215
+ if (op === 65 || op === 66) r.s();
31216
+ else if (op === 35 || op === 210) r.u();
31217
+ else if (op === 208) r.s();
31218
+ else if (![106, 107, 108, 124, 125, 126].includes(op))
31219
+ throw new Error(`unsupported constant expression op ${op}`);
31220
+ }
31221
+ }
31222
+ function skipElementSegment(r) {
31223
+ const flags = r.u();
31224
+ if (flags > 7) throw new Error(`unsupported element segment flags ${flags}`);
31225
+ if ((flags & 3) === 2) r.u();
31226
+ if (!(flags & 1)) skipConstant(r);
31227
+ if (flags & 3) skipValueType(r);
31228
+ for (let count = r.u(); count > 0; count--)
31229
+ if (flags & 4) skipConstant(r);
31230
+ else r.u();
31231
+ }
31232
+ function placeGuestLazyFunctions(bytes, lazy) {
31233
+ const sections = wasmSections(bytes);
31234
+ const lazyIndex = new Map(lazy.map((name3, index) => [name3, index]));
31235
+ const functions = new Array(lazy.length);
31236
+ let found = 0;
31237
+ const kept = entries(
31238
+ bytes,
31239
+ sections.find((s) => s.id === 7),
31240
+ readExport
31241
+ ).filter((entry) => {
31242
+ const r = wasmReader(entry, 0);
31243
+ const position = lazyIndex.get(r.name());
31244
+ const kind = r.byte();
31245
+ if (kind !== 0 || position === void 0) return true;
31246
+ functions[position] = r.u();
31247
+ found++;
31248
+ return false;
31249
+ });
31250
+ if (found !== lazy.length)
31251
+ throw new Error("guest link lost a lazy dlsym function export");
31252
+ return appendLazyPlacement(
31253
+ rewriteSections(bytes, sections, /* @__PURE__ */ new Map([[7, vectorSection(7, kept.length, kept)]])),
31254
+ functions
31255
+ );
31256
+ }
31257
+ function guestLazyExports(lazy) {
31258
+ return lazy.map((name3) => JSON.stringify(`--export=${name3}`)).join("\n");
31259
+ }
31260
+ var uleb3, SECTION_ORDER, readExport, lastTableElement;
31261
+ var init_swift_guest_dyld_functions = __esm({
31262
+ "src/swift-guest-dyld-functions.ts"() {
31263
+ "use strict";
31264
+ init_nativeWasmContract();
31265
+ init_swift_sdk_image_wasm();
31266
+ uleb3 = (value) => {
31267
+ const out = [];
31268
+ do {
31269
+ let byte = value % 128;
31270
+ value = Math.floor(value / 128);
31271
+ if (value) byte |= 128;
31272
+ out.push(byte);
31273
+ } while (value);
31274
+ return out;
31275
+ };
31276
+ SECTION_ORDER = [1, 2, 3, 4, 5, 13, 6, 7, 8, 9, 12, 10, 11];
31277
+ readExport = (r) => {
31278
+ r.name();
31279
+ r.byte();
31280
+ r.u();
31281
+ };
31282
+ lastTableElement = (segments) => segments.findLastIndex((segment2) => (segment2[0] & 3) !== 3);
31283
+ }
31284
+ });
31285
+
31290
31286
  // src/swift-guest-link-plan.ts
31291
31287
  function selectedGuestInputImage(artifact, member) {
31292
31288
  if (artifact.kind === "object" !== (member === null))
@@ -42440,9 +42436,11 @@ async function compileGuestLink(options2) {
42440
42436
  return [...source, ...runtime].sort((a, b) => a.image - b.image);
42441
42437
  };
42442
42438
  const sdk2 = options2.sdkImage;
42443
- const sdkCallers = sdk2?.sdkInterface.guestCallers;
42444
- const sdkObjects = sdk2 ? (await Promise.resolve().then(() => (init_swift_sdk_image(), swift_sdk_image_exports))).readSwiftSdkManifestIndex(sdk2).guestObjects : void 0;
42445
- if (sdk2 && (!sdkCallers || !sdkObjects))
42439
+ const sdkCallers = sdk2.sdkInterface.guestCallers;
42440
+ const sdkObjects = (await Promise.resolve().then(() => (init_swift_sdk_image(), swift_sdk_image_exports))).readSwiftSdkManifestIndex(
42441
+ sdk2
42442
+ ).guestObjects;
42443
+ if (!sdkCallers || !sdkObjects)
42446
42444
  throw new Error("the SDK image has no guest link manifest");
42447
42445
  const result = await linkPrunedGuestImages({
42448
42446
  buildDirectory: options2.buildDirectory,
@@ -42455,14 +42453,14 @@ async function compileGuestLink(options2) {
42455
42453
  ledgerDataImage: 0,
42456
42454
  framework: catalogs.framework,
42457
42455
  sdkProducts: null,
42458
- sharedSdk: sdkCallers && sdkObjects ? {
42456
+ sharedSdk: {
42459
42457
  callers: sdkCallers,
42460
42458
  hasContainingObject: (identity2) => sdkObjects[sdkGuestObjectKey(identity2)] !== void 0
42461
- } : void 0,
42462
- onSplitInputs: sdk2 ? (value) => {
42459
+ },
42460
+ onSplitInputs: (value) => {
42463
42461
  splitInputs = value;
42464
- } : void 0,
42465
- deferFinalLink: Boolean(sdk2),
42462
+ },
42463
+ deferFinalLink: true,
42466
42464
  onDyldRows: (rows) => {
42467
42465
  lazyFunctions = rows.lazyFunctions;
42468
42466
  dyldSymbols = rows.dyldSymbols;
@@ -42730,191 +42728,165 @@ async function compileGuestLink(options2) {
42730
42728
  }
42731
42729
  });
42732
42730
  if (!reserved2 || !projectionObject) throw new Error("guest projection was not reserved");
42733
- if (sdk2) {
42734
- try {
42735
- if (!splitInputs) throw new Error("guest link did not select shared SDK inputs");
42736
- const {
42737
- createSwiftSdkBinding: createSwiftSdkBinding2,
42738
- linkSwiftAppModule: linkSwiftAppModule2,
42739
- readSwiftSdkUsage: readSwiftSdkUsage2,
42740
- swiftAppModuleThunkSection: swiftAppModuleThunkSection2,
42741
- swiftSdkProjectionSpans: swiftSdkProjectionSpans2
42742
- } = await Promise.resolve().then(() => (init_swift_sdk_app_module(), swift_sdk_app_module_exports));
42743
- const project2 = options2.project;
42744
- const work = project2 ? (0, import_node_fs62.mkdtempSync)(import_node_path60.default.join(directory2, "app-module-")) : import_node_path60.default.join(directory2, "app-module");
42745
- if (project2) (0, import_node_fs62.chownSync)(work, project2.uid, project2.gid);
42746
- else (0, import_node_fs62.mkdirSync)(work, { recursive: true });
42747
- const layoutMap = import_node_path60.default.join(work, "app.map");
42748
- let appProjectionObject = projectionObject;
42749
- const owners = new Map(splitInputs.appObjects).set(appProjectionObject, 0);
42750
- const sdkObjectKeys = /* @__PURE__ */ new Map();
42751
- const sdkObjectImages = /* @__PURE__ */ new Map();
42752
- const sdkProductImages = new Map(prepared?.sdkProducts.images);
42753
- for (const [file, { image, product, identity: identity2 }] of splitInputs.sdkObjects) {
42754
- const key2 = sdkGuestObjectKey(identity2);
42755
- sdkObjectKeys.set(file, key2);
42756
- sdkObjectImages.set(key2, image);
42757
- const priorImage = sdkProductImages.get(product);
42758
- if (priorImage !== void 0 && priorImage !== image)
42759
- throw new Error(`SDK product ${product} has several guest images`);
42760
- sdkProductImages.set(product, image);
42761
- }
42762
- const linkedModule = import_node_path60.default.join(work, "app.wasm");
42763
- const sdkSpans = swiftSdkProjectionSpans2(
42764
- sdk2,
42765
- (object8, product) => sdkObjectImages.get(object8) ?? sdkProductImages.get(product)
42731
+ try {
42732
+ if (!splitInputs) throw new Error("guest link did not select shared SDK inputs");
42733
+ const {
42734
+ createSwiftSdkBinding: createSwiftSdkBinding2,
42735
+ linkSwiftAppModule: linkSwiftAppModule2,
42736
+ readSwiftSdkUsage: readSwiftSdkUsage2,
42737
+ swiftAppModuleThunkSection: swiftAppModuleThunkSection2,
42738
+ swiftSdkProjectionSpans: swiftSdkProjectionSpans2
42739
+ } = await Promise.resolve().then(() => (init_swift_sdk_app_module(), swift_sdk_app_module_exports));
42740
+ const project2 = options2.project;
42741
+ const work = project2 ? (0, import_node_fs62.mkdtempSync)(import_node_path60.default.join(directory2, "app-module-")) : import_node_path60.default.join(directory2, "app-module");
42742
+ if (project2) (0, import_node_fs62.chownSync)(work, project2.uid, project2.gid);
42743
+ else (0, import_node_fs62.mkdirSync)(work, { recursive: true });
42744
+ const layoutMap = import_node_path60.default.join(work, "app.map");
42745
+ let appProjectionObject = projectionObject;
42746
+ const owners = new Map(splitInputs.appObjects).set(appProjectionObject, 0);
42747
+ const sdkObjectKeys = /* @__PURE__ */ new Map();
42748
+ const sdkObjectImages = /* @__PURE__ */ new Map();
42749
+ const sdkProductImages = new Map(prepared?.sdkProducts.images);
42750
+ for (const [file, { image, product, identity: identity2 }] of splitInputs.sdkObjects) {
42751
+ const key2 = sdkGuestObjectKey(identity2);
42752
+ sdkObjectKeys.set(file, key2);
42753
+ sdkObjectImages.set(key2, image);
42754
+ const priorImage = sdkProductImages.get(product);
42755
+ if (priorImage !== void 0 && priorImage !== image)
42756
+ throw new Error(`SDK product ${product} has several guest images`);
42757
+ sdkProductImages.set(product, image);
42758
+ }
42759
+ const linkedModule = import_node_path60.default.join(work, "app.wasm");
42760
+ const sdkSpans = swiftSdkProjectionSpans2(
42761
+ sdk2,
42762
+ (object8, product) => sdkObjectImages.get(object8) ?? sdkProductImages.get(product)
42763
+ );
42764
+ const compileAppProjection = (source) => {
42765
+ const projectionSource = import_node_path60.default.join(work, "projection.c");
42766
+ const nextObject = import_node_path60.default.join(work, "projection.o");
42767
+ (0, import_node_fs62.writeFileSync)(projectionSource, source);
42768
+ (0, import_node_child_process36.execFileSync)(
42769
+ import_node_path60.default.join(options2.toolchainBin, "clang"),
42770
+ [...clangOptions, "-c", projectionSource, "-o", nextObject],
42771
+ { stdio: "pipe" }
42766
42772
  );
42767
- const compileAppProjection = (source) => {
42768
- const projectionSource = import_node_path60.default.join(work, "projection.c");
42769
- const nextObject = import_node_path60.default.join(work, "projection.o");
42770
- (0, import_node_fs62.writeFileSync)(projectionSource, source);
42771
- (0, import_node_child_process36.execFileSync)(
42772
- import_node_path60.default.join(options2.toolchainBin, "clang"),
42773
- [...clangOptions, "-c", projectionSource, "-o", nextObject],
42774
- { stdio: "pipe" }
42775
- );
42776
- if (nextObject !== appProjectionObject) {
42777
- owners.delete(appProjectionObject);
42778
- appProjectionObject = nextObject;
42779
- owners.set(appProjectionObject, 0);
42773
+ if (nextObject !== appProjectionObject) {
42774
+ owners.delete(appProjectionObject);
42775
+ appProjectionObject = nextObject;
42776
+ owners.set(appProjectionObject, 0);
42777
+ }
42778
+ };
42779
+ let storage = reserved2;
42780
+ if (sdkSpans.length > 0) {
42781
+ const sdkCounts = guestProjectionRegionCounts(storage.images.length, sdkSpans);
42782
+ storage = reserveGuestProjectionStorage(
42783
+ storage.images,
42784
+ storage.capacities.map((capacity, index) => ({
42785
+ ...capacity,
42786
+ regions: capacity.regions + sdkCounts[index] + 16
42787
+ }))
42788
+ );
42789
+ compileAppProjection(storage.source);
42790
+ }
42791
+ let precomputedSymbols;
42792
+ if (splitInputs.appReferencedSymbols && splitInputs.appDefinedSymbols) {
42793
+ const referenced = new Set(splitInputs.appReferencedSymbols);
42794
+ const defined = new Set(splitInputs.appDefinedSymbols);
42795
+ const projSyms = guestWasmSymbols((0, import_node_fs62.readFileSync)(appProjectionObject));
42796
+ for (const name3 of projSyms.undefined) referenced.add(name3);
42797
+ for (const name3 of projSyms.defined) defined.add(name3);
42798
+ precomputedSymbols = { referenced, defined };
42799
+ }
42800
+ for (; ; ) {
42801
+ const link = await linkSwiftAppModule2({
42802
+ objects: [...owners.keys()],
42803
+ lazyFunctions: splitInputs.lazyFunctions,
42804
+ toolchainBin: options2.toolchainBin,
42805
+ sdk: sdk2,
42806
+ work,
42807
+ output: options2.optimized,
42808
+ optimize: options2.optimize,
42809
+ layoutMap,
42810
+ project: project2,
42811
+ precomputedSymbols,
42812
+ loweringCache: project2 ? void 0 : {
42813
+ file: import_node_path60.default.join(
42814
+ options2.buildDirectory,
42815
+ ".build",
42816
+ "peach-app-module-lowered.wasm"
42817
+ ),
42818
+ compilerDigest: options2.compilerDigest
42780
42819
  }
42781
- };
42782
- let storage = reserved2;
42783
- if (sdkSpans.length > 0) {
42784
- const sdkCounts = guestProjectionRegionCounts(storage.images.length, sdkSpans);
42820
+ });
42821
+ const map2 = (0, import_node_fs62.readFileSync)(
42822
+ project2 ? projectOutputFile(work, layoutMap, project2) : layoutMap,
42823
+ "utf8"
42824
+ );
42825
+ const values = guestDyldValueRange(map2);
42826
+ const bindingRows = /* @__PURE__ */ new Map();
42827
+ const data = [];
42828
+ for (let at = 0; at < link.linkage.data.length; at += 3) {
42829
+ const address = link.linkage.data[at];
42830
+ const size2 = link.linkage.data[at + 1];
42831
+ const value = link.linkage.data[at + 2];
42832
+ if (values && address >= values.address && address < values.address + values.length) {
42833
+ if (size2 !== 8 || (address - values.address) % 8)
42834
+ throw new Error("sdk binding splits a dyld value");
42835
+ bindingRows.set((address - values.address) / 8, value);
42836
+ } else data.push(address, size2, value);
42837
+ }
42838
+ const linked = (0, import_node_fs62.readFileSync)(
42839
+ project2 ? projectOutputFile(work, linkedModule, project2) : linkedModule
42840
+ );
42841
+ const required = guestProjectionRegionCounts(storage.images.length, [
42842
+ ...guestLinkedSpans(map2, linked, linked, owners, splitInputs.appSections, true),
42843
+ ...sdkSpans
42844
+ ]);
42845
+ if (storage.capacities.some(({ regions }, index) => required[index] > regions)) {
42785
42846
  storage = reserveGuestProjectionStorage(
42786
42847
  storage.images,
42787
- storage.capacities.map((capacity, index) => ({
42788
- ...capacity,
42789
- regions: capacity.regions + sdkCounts[index] + 16
42790
- }))
42848
+ storage.capacities.map((capacity, index) => {
42849
+ const count = required[index];
42850
+ return count > capacity.regions ? { ...capacity, regions: Math.max(count, capacity.regions * 2) } : capacity;
42851
+ })
42791
42852
  );
42792
42853
  compileAppProjection(storage.source);
42854
+ continue;
42793
42855
  }
42794
- let precomputedSymbols;
42795
- if (splitInputs.appReferencedSymbols && splitInputs.appDefinedSymbols) {
42796
- const referenced = new Set(splitInputs.appReferencedSymbols);
42797
- const defined = new Set(splitInputs.appDefinedSymbols);
42798
- const projSyms = guestWasmSymbols((0, import_node_fs62.readFileSync)(appProjectionObject));
42799
- for (const name3 of projSyms.undefined) referenced.add(name3);
42800
- for (const name3 of projSyms.defined) defined.add(name3);
42801
- precomputedSymbols = { referenced, defined };
42802
- }
42803
- for (; ; ) {
42804
- const link = await linkSwiftAppModule2({
42805
- objects: [...owners.keys()],
42806
- lazyFunctions: splitInputs.lazyFunctions,
42807
- toolchainBin: options2.toolchainBin,
42808
- sdk: sdk2,
42809
- work,
42810
- output: options2.optimized,
42811
- optimize: options2.optimize,
42812
- layoutMap,
42813
- project: project2,
42814
- precomputedSymbols,
42815
- loweringCache: project2 ? void 0 : {
42816
- file: import_node_path60.default.join(
42817
- options2.buildDirectory,
42818
- ".build",
42819
- "peach-app-module-lowered.wasm"
42820
- ),
42821
- compilerDigest: options2.compilerDigest
42822
- }
42823
- });
42824
- const map3 = (0, import_node_fs62.readFileSync)(
42825
- project2 ? projectOutputFile(work, layoutMap, project2) : layoutMap,
42826
- "utf8"
42827
- );
42828
- const values = guestDyldValueRange(map3);
42829
- const bindingRows = /* @__PURE__ */ new Map();
42830
- const data = [];
42831
- for (let at = 0; at < link.linkage.data.length; at += 3) {
42832
- const address = link.linkage.data[at];
42833
- const size2 = link.linkage.data[at + 1];
42834
- const value = link.linkage.data[at + 2];
42835
- if (values && address >= values.address && address < values.address + values.length) {
42836
- if (size2 !== 8 || (address - values.address) % 8)
42837
- throw new Error("sdk binding splits a dyld value");
42838
- bindingRows.set((address - values.address) / 8, value);
42839
- } else data.push(address, size2, value);
42840
- }
42841
- const linked = (0, import_node_fs62.readFileSync)(
42842
- project2 ? projectOutputFile(work, linkedModule, project2) : linkedModule
42843
- );
42844
- const required = guestProjectionRegionCounts(storage.images.length, [
42845
- ...guestLinkedSpans(map3, linked, linked, owners, splitInputs.appSections, true),
42846
- ...sdkSpans
42847
- ]);
42848
- if (storage.capacities.some(({ regions }, index) => required[index] > regions)) {
42849
- storage = reserveGuestProjectionStorage(
42850
- storage.images,
42851
- storage.capacities.map((capacity, index) => {
42852
- const count = required[index];
42853
- return count > capacity.regions ? { ...capacity, regions: Math.max(count, capacity.regions * 2) } : capacity;
42854
- })
42855
- );
42856
- compileAppProjection(storage.source);
42857
- continue;
42858
- }
42859
- options2.onStage("lowering the app image");
42860
- const lowerPromise = link.lower();
42861
- await new Promise((resolve3) => setImmediate(resolve3));
42862
- let binding;
42863
- try {
42864
- if (result.finalLinkDone) await result.finalLinkDone;
42865
- const usage = readSwiftSdkUsage2(result.mapPath, options2.output, sdkObjectKeys);
42866
- binding = createSwiftSdkBinding2({ ...link.linkage, data }, sdk2, usage);
42867
- } catch (error) {
42868
- await Promise.allSettled([lowerPromise]);
42869
- throw error;
42870
- }
42871
- await lowerPromise;
42872
- const finalized = finalizeGuestProjectionStorage({
42873
- map: map3,
42874
- linked,
42875
- optimized: (0, import_node_fs62.readFileSync)(options2.optimized),
42876
- owners,
42877
- sectionOwners: splitInputs.appSections,
42878
- projectionObject: appProjectionObject,
42879
- reserved: storage,
42880
- sdkSpans
42881
- });
42882
- (0, import_node_fs62.writeFileSync)(
42883
- options2.optimized,
42884
- moveGuestDyldTable(map3, finalized.wasm, splitInputs.dyldSymbols, bindingRows, [
42885
- swiftAppModuleThunkSection2(finalized.wasm)
42886
- ])
42887
- );
42888
- return binding;
42856
+ options2.onStage("lowering the app image");
42857
+ const lowerPromise = link.lower();
42858
+ await new Promise((resolve3) => setImmediate(resolve3));
42859
+ let binding;
42860
+ try {
42861
+ if (result.finalLinkDone) await result.finalLinkDone;
42862
+ const usage = readSwiftSdkUsage2(result.mapPath, options2.output, sdkObjectKeys);
42863
+ binding = createSwiftSdkBinding2({ ...link.linkage, data }, sdk2, usage);
42864
+ } catch (error) {
42865
+ await Promise.allSettled([lowerPromise]);
42866
+ throw error;
42889
42867
  }
42890
- } finally {
42891
- if (result.finalLinkDone) await Promise.allSettled([result.finalLinkDone]);
42868
+ await lowerPromise;
42869
+ const finalized = finalizeGuestProjectionStorage({
42870
+ map: map2,
42871
+ linked,
42872
+ optimized: (0, import_node_fs62.readFileSync)(options2.optimized),
42873
+ owners,
42874
+ sectionOwners: splitInputs.appSections,
42875
+ projectionObject: appProjectionObject,
42876
+ reserved: storage,
42877
+ sdkSpans
42878
+ });
42879
+ (0, import_node_fs62.writeFileSync)(
42880
+ options2.optimized,
42881
+ moveGuestDyldTable(map2, finalized.wasm, splitInputs.dyldSymbols, bindingRows, [
42882
+ swiftAppModuleThunkSection2(finalized.wasm)
42883
+ ])
42884
+ );
42885
+ return binding;
42892
42886
  }
42887
+ } finally {
42888
+ if (result.finalLinkDone) await Promise.allSettled([result.finalLinkDone]);
42893
42889
  }
42894
- options2.onStage("lowering the app image");
42895
- await lowerWasm(options2.output, options2.optimized, {
42896
- optimize: options2.optimize,
42897
- skipPasses: ["duplicate-function-elimination"],
42898
- wideExports: lazyFunctions
42899
- });
42900
- if (lazyFunctions.length)
42901
- (0, import_node_fs62.writeFileSync)(
42902
- options2.optimized,
42903
- placeGuestLazyFunctions((0, import_node_fs62.readFileSync)(options2.optimized), lazyFunctions)
42904
- );
42905
- const map2 = (0, import_node_fs62.readFileSync)(result.mapPath, "utf8");
42906
- let optimized = (0, import_node_fs62.readFileSync)(options2.optimized);
42907
- if (/ __peach_guest_images$/m.test(map2))
42908
- optimized = finalizeGuestProjectionStorage({
42909
- map: map2,
42910
- linked: (0, import_node_fs62.readFileSync)(options2.output),
42911
- optimized,
42912
- owners: result.owners,
42913
- sectionOwners: result.generatedSectionOwners,
42914
- projectionObject,
42915
- reserved: reserved2
42916
- }).wasm;
42917
- (0, import_node_fs62.writeFileSync)(options2.optimized, moveGuestDyldTable(map2, optimized, dyldSymbols));
42918
42890
  }
42919
42891
  var import_node_child_process36, import_node_fs62, import_node_path60;
42920
42892
  var init_swift_guest_compile = __esm({
@@ -42924,7 +42896,6 @@ var init_swift_guest_compile = __esm({
42924
42896
  import_node_fs62 = require("node:fs");
42925
42897
  import_node_path60 = __toESM(require("node:path"), 1);
42926
42898
  init_swift_guest_archive();
42927
- init_swift_guest_dyld_functions();
42928
42899
  init_swift_guest_dyld_table();
42929
42900
  init_swift_guest_link();
42930
42901
  init_swift_guest_linked_spans();
@@ -42938,7 +42909,6 @@ var init_swift_guest_compile = __esm({
42938
42909
  init_swift_toolchain();
42939
42910
  init_swift_wasm_prune();
42940
42911
  init_swiftTargetContract();
42941
- init_wasm_optimize();
42942
42912
  }
42943
42913
  });
42944
42914
 
@@ -47900,20 +47870,17 @@ function readCompiledArtifact(directory2, hash) {
47900
47870
  const gzip2 = (0, import_node_fs70.readFileSync)(import_node_path70.default.join(directory2, "icu.gz"));
47901
47871
  if ((0, import_node_crypto45.createHash)("sha256").update(bytes).digest("hex") !== receipt.wasm || (0, import_node_crypto45.createHash)("sha256").update(gzip2).digest("hex") !== receipt.icu || bytes.length <= 8 || bytes.readUInt32LE(0) !== 1836278016 || bytes.readUInt32LE(4) !== 1)
47902
47872
  return null;
47903
- let sdk2;
47904
- if ("sdk" in receipt) {
47905
- const image = receipt.sdk;
47906
- if (!isRecord(image) || typeof image.key !== "string" || typeof image.sha256 !== "string" || typeof image.binding !== "string")
47907
- return null;
47908
- const binding = (0, import_node_fs70.readFileSync)(import_node_path70.default.join(directory2, "sdk-binding.bin"));
47909
- if ((0, import_node_crypto45.createHash)("sha256").update(binding).digest("hex") !== image.binding)
47910
- return null;
47911
- sdk2 = {
47912
- key: image.key,
47913
- sha256: image.sha256,
47914
- binding: { bytes: binding, sha256: image.binding }
47915
- };
47916
- }
47873
+ if (!("sdk" in receipt)) return null;
47874
+ const image = receipt.sdk;
47875
+ if (!isRecord(image) || typeof image.key !== "string" || typeof image.sha256 !== "string" || typeof image.binding !== "string")
47876
+ return null;
47877
+ const binding = (0, import_node_fs70.readFileSync)(import_node_path70.default.join(directory2, "sdk-binding.bin"));
47878
+ if ((0, import_node_crypto45.createHash)("sha256").update(binding).digest("hex") !== image.binding) return null;
47879
+ const sdk2 = {
47880
+ key: image.key,
47881
+ sha256: image.sha256,
47882
+ binding: { bytes: binding, sha256: image.binding }
47883
+ };
47917
47884
  return { hash, bytes, icu: { sha256: receipt.icu, gzip: gzip2 }, sdk: sdk2 };
47918
47885
  } catch (error) {
47919
47886
  if (error instanceof SyntaxError || error instanceof Error && "code" in error && error.code === "ENOENT")
@@ -48844,13 +48811,12 @@ async function compileSwiftProjectOnce(sources, options2) {
48844
48811
  sources: import_node_path70.default.join(root, "Sources", "App"),
48845
48812
  multi: compileTargets(input).length > 0
48846
48813
  };
48847
- const sdkModule = options2.sdkModule && !options2.linkOnly;
48848
- const sdkImage = sdkModule ? await (await Promise.resolve().then(() => (init_swift_sdk_image(), swift_sdk_image_exports))).buildSwiftSdkImage(
48814
+ const sdkImage = options2.linkOnly ? void 0 : await (await Promise.resolve().then(() => (init_swift_sdk_image(), swift_sdk_image_exports))).buildSwiftSdkImage(
48849
48815
  moduleRoot,
48850
48816
  !!guestGraph,
48851
48817
  distribution ? [] : linkedFrameworkTargets(moduleRoot, input).imports,
48852
48818
  { signal: options2.signal }
48853
- ) : void 0;
48819
+ );
48854
48820
  const inputHash = swiftCompileInputHash(input, options2.release);
48855
48821
  const moduleDigest = swiftModuleDigest(moduleRoot);
48856
48822
  const sourceHash = inputHash.copy().update(moduleDigest).digest("hex");
@@ -48881,79 +48847,10 @@ sdk module ${sdkImage.key}`).digest("hex") : sourceHash;
48881
48847
  return retain(root, previous);
48882
48848
  }
48883
48849
  }
48884
- if (!options2.intermediates && !sdkImage && process.platform === "darwin" && process.env.TM_SESSION && !windowAdmission() && process.env.CI !== "true" && moduleRoot === sourceSwiftCheckout() && !swiftDistributionAt(moduleRoot)) {
48885
- const requestRoot = (0, import_node_fs70.mkdtempSync)(`${root}.builder-request-`);
48886
- const output = import_node_path70.default.join(requestRoot, "output");
48887
- const request = import_node_path70.default.join(requestRoot, "request.json");
48888
- (0, import_node_fs70.writeFileSync)(
48889
- request,
48890
- JSON.stringify({
48891
- input,
48892
- hash,
48893
- release: options2.release,
48894
- timeoutMs: options2.timeoutMs,
48895
- // framework sources and compiler inputs own the shared object tree;
48896
- // unrelated app edits reuse it without retaining stale private ABI.
48897
- buildKey: frameworkKey
48898
- })
48899
- );
48900
- try {
48901
- const repo = import_node_path70.default.resolve(moduleRoot, "../..");
48902
- const timeout = swiftBuilderHopTimeoutMs(options2.timeoutMs);
48903
- report("requesting builder admission or cached result");
48904
- await runCompiler(
48905
- "bun",
48906
- [
48907
- import_node_path70.default.join(repo, "scripts/build/swift-project.ts"),
48908
- "--request",
48909
- request,
48910
- "--output",
48911
- output
48912
- ],
48913
- {
48914
- cwd: repo,
48915
- timeout,
48916
- maxBuffer: 64 * 1024 * 1024,
48917
- signal: options2.signal
48918
- },
48919
- true
48920
- ).catch((error) => {
48921
- if (options2.signal?.aborted) throw error;
48922
- const output2 = outputOf(error);
48923
- if (!(error instanceof Error) || Reflect.get(error, "exitCode") !== 124)
48924
- throw new Error(output2, { cause: error });
48925
- const prefix = `[swift-project ${hash.slice(0, 16)}] `;
48926
- const lines = output2.split("\n");
48927
- const stage = lines.findLast((line) => line.startsWith(prefix))?.slice(prefix.length);
48928
- const cap = lines.find(
48929
- (line) => line.startsWith("[remote] outer deadline leaves ")
48930
- );
48931
- const deadline = cap ? `
48932
- ${cap}` : "";
48933
- throw new Error(
48934
- `Swift builder deadline expired during ${stage ?? "builder preparation"} (requested ${Math.ceil(timeout / 1e3)}s for the builder hop).${deadline}`,
48935
- { cause: error }
48936
- );
48937
- });
48938
- const artifact = readCompiledArtifact(output, hash);
48939
- if (!artifact) {
48940
- throw new Error(
48941
- "swift-compile: builder artifact source, digest or wasm header is invalid"
48942
- );
48943
- }
48944
- saveCompiledArtifact(root, artifact);
48945
- saveSharedArtifact(sharedRoot, artifact);
48946
- report("builder artifact verified");
48947
- return retain(root, artifact);
48948
- } finally {
48949
- (0, import_node_fs70.rmSync)(requestRoot, { recursive: true, force: true });
48950
- }
48951
- }
48952
48850
  const baseRoot = root;
48953
48851
  const canPoolBuildRoot = !options2.intermediates && !options2.project && !options2.linkOnly && import_node_path70.default.basename(import_node_path70.default.dirname(baseRoot)) === "swift-builds";
48954
48852
  const compatShapeParts = canPoolBuildRoot ? [
48955
48853
  frameworkKey,
48956
- Boolean(sdkImage),
48957
48854
  compileTargets(input).map((target) => target.name).sort(),
48958
48855
  input.oneModule === true,
48959
48856
  input.optimize === true,
@@ -49591,7 +49488,8 @@ ${compatShape}` : "";
49591
49488
  }
49592
49489
  const output = options2.project ? projectOutputFile(root2, linked, options2.project) : linked;
49593
49490
  const optimized = `${output}.optimized`;
49594
- if (sdkImage && options2.project) (0, import_node_fs70.rmSync)(optimized, { force: true });
49491
+ if (!sdkImage) throw new Error("swift-compile: missing shared SDK image");
49492
+ if (options2.project) (0, import_node_fs70.rmSync)(optimized, { force: true });
49595
49493
  let sdkAsset;
49596
49494
  stage("linking the app image");
49597
49495
  if (guestGraph) {
@@ -49620,9 +49518,8 @@ ${compatShape}` : "";
49620
49518
  jobs: swiftBuildJobs(),
49621
49519
  onStage: stage
49622
49520
  });
49623
- if (sdkImage && binding)
49624
- sdkAsset = { key: sdkImage.key, sha256: sdkImage.sha256, binding };
49625
- } else if (sdkImage) {
49521
+ sdkAsset = { key: sdkImage.key, sha256: sdkImage.sha256, binding };
49522
+ } else {
49626
49523
  const { buildSwiftAppModule: buildSwiftAppModule2 } = await Promise.resolve().then(() => (init_swift_sdk_app_module(), swift_sdk_app_module_exports));
49627
49524
  const binding = await buildSwiftAppModule2({
49628
49525
  buildRoot: root2,
@@ -49640,19 +49537,7 @@ ${compatShape}` : "";
49640
49537
  }
49641
49538
  });
49642
49539
  sdkAsset = { key: sdkImage.key, sha256: sdkImage.sha256, binding };
49643
- } else {
49644
- const bytes = (0, import_node_fs70.readFileSync)(output);
49645
- const ordered = orderObjCConstructors(bytes);
49646
- if (ordered !== bytes) (0, import_node_fs70.writeFileSync)(output, ordered);
49647
- stage("lowering the app image");
49648
- await lowerWasm(output, optimized, { optimize: input.optimize === true });
49649
49540
  }
49650
- if (!sdkImage)
49651
- await runCompiler(
49652
- import_node_path70.default.join(options2.toolchainBin, "llvm-objcopy"),
49653
- ["--remove-section=.swift1_autolink_entries", optimized],
49654
- buildOptions
49655
- );
49656
49541
  const artifact = {
49657
49542
  hash,
49658
49543
  bytes: (0, import_node_fs70.readFileSync)(optimized),
@@ -49712,7 +49597,6 @@ var init_swift_compile = __esm({
49712
49597
  init_swift_project_user();
49713
49598
  init_swift_reproducible();
49714
49599
  init_swift_root_lock();
49715
- init_swift_sdk_image_wasm();
49716
49600
  init_swift_sdk_surface();
49717
49601
  init_swift_shared_sdk();
49718
49602
  init_swift_source_closure();
@@ -49907,7 +49791,7 @@ ${wasmThreadLinkFlags.map((flag) => ` "-Xlinker", ${JSON.stringify(flag
49907
49791
  REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
49908
49792
  MULTI_MANIFEST_VERSION = 76;
49909
49793
  SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
49910
- compilerSourceDigest = true ? "229f789297c5cb8e33a042e23ad3c1df20450a712a02dd0b50d2e78bc8ed3de6" : swiftCompilerSourceDigest2(__sootsim_import_meta_dirname);
49794
+ compilerSourceDigest = true ? "dcd0189f8bf1a7fc415f2c92825f8b3bbc2089ae9697ffcb50cc9a7e65e99990" : swiftCompilerSourceDigest2(__sootsim_import_meta_dirname);
49911
49795
  nativeCxxCompilerFlags = ["-fno-cxx-modules"];
49912
49796
  MODULE_MAP_RESPONSE_FILE_RUN = 16;
49913
49797
  cFlagArray = (flags) => JSON.stringify(withoutGlogModuleMap(flags));
@@ -77580,6 +77464,23 @@ function readCompiledMetadata(label, value, readPackage, names) {
77580
77464
  );
77581
77465
  return { platform: "ios", packages, url, hash, icuUrl: icuUrl2, bundleFiles };
77582
77466
  }
77467
+ function readSdkEntryMetadata(label, value) {
77468
+ const sdkUrl = Reflect.get(value, "sdkUrl");
77469
+ const sdkBindingUrl = Reflect.get(value, "sdkBindingUrl");
77470
+ if (sdkUrl === void 0 && sdkBindingUrl === void 0) return {};
77471
+ if (typeof sdkUrl === "string" && sdkUrl && typeof sdkBindingUrl === "string" && sdkBindingUrl)
77472
+ return { sdkUrl, sdkBindingUrl };
77473
+ throw new Error(`invalid ${label} SDK binding metadata`);
77474
+ }
77475
+ function readNitroMetadata(value) {
77476
+ const metadata = readCompiledMetadata(
77477
+ "Nitro",
77478
+ value,
77479
+ readNitroPackage,
77480
+ (entry) => entry.hybridObjects
77481
+ );
77482
+ return metadata && { ...metadata, ...readSdkEntryMetadata("Nitro", Object(value)) };
77483
+ }
77583
77484
  function readTurboMetadata(value) {
77584
77485
  if (value === null || value === void 0) return null;
77585
77486
  if (typeof value !== "object" || Array.isArray(value) || Reflect.get(value, "platform") !== NITRO_GUEST_PLATFORM)
@@ -77613,11 +77514,13 @@ function readTurboMetadata(value) {
77613
77514
  readCompiledPackage,
77614
77515
  () => []
77615
77516
  );
77616
- const sdk2 = sdkUrl === void 0 && sdkBindingUrl === void 0 ? {} : typeof sdkUrl === "string" && sdkUrl && typeof sdkBindingUrl === "string" && sdkBindingUrl ? { sdkUrl, sdkBindingUrl } : null;
77617
- if (sdk2 === null) throw new Error("invalid TurboModule SDK binding metadata");
77618
- return metadata && { ...metadata, ...sdk2, ...unavailable2 ? { unavailable: unavailable2 } : {} };
77517
+ return metadata && {
77518
+ ...metadata,
77519
+ ...readSdkEntryMetadata("TurboModule", value),
77520
+ ...unavailable2 ? { unavailable: unavailable2 } : {}
77521
+ };
77619
77522
  }
77620
- var NITRO_GUEST_PLATFORM, readNitroMetadata;
77523
+ var NITRO_GUEST_PLATFORM;
77621
77524
  var init_nitroContract = __esm({
77622
77525
  "src/nitroContract.ts"() {
77623
77526
  "use strict";
@@ -77625,7 +77528,6 @@ var init_nitroContract = __esm({
77625
77528
  init_is_record();
77626
77529
  init_swiftContract();
77627
77530
  NITRO_GUEST_PLATFORM = "ios";
77628
- readNitroMetadata = (value) => readCompiledMetadata("Nitro", value, readNitroPackage, (entry) => entry.hybridObjects);
77629
77531
  }
77630
77532
  });
77631
77533
 
@@ -95145,7 +95047,6 @@ function linkedModuleRoots(packagePath) {
95145
95047
  return [...roots].sort();
95146
95048
  }
95147
95049
  function updateSwiftConfigStamp(hash, packagePath) {
95148
- if (projects().get(packagePath)?.standalone) hash.update("standalone");
95149
95050
  const config = xcodeProjects().get(packagePath);
95150
95051
  hash.update(JSON.stringify(config?.behavior ?? {}));
95151
95052
  const gates = config?.swiftWasm64?.platformGates;
@@ -95222,9 +95123,9 @@ function moduleStamp(packagePath, moduleRootOverride, hosted) {
95222
95123
  }
95223
95124
  return hash.digest("hex");
95224
95125
  }
95225
- function otherInputs(input, standalone) {
95126
+ function otherInputs(input) {
95226
95127
  const { files: _files, ...rest } = input;
95227
- return (0, import_node_crypto73.createHash)("sha256").update(JSON.stringify({ ...rest, standalone })).digest("hex");
95128
+ return (0, import_node_crypto73.createHash)("sha256").update(JSON.stringify(rest)).digest("hex");
95228
95129
  }
95229
95130
  function icuUrl(origin, artifact) {
95230
95131
  return "url" in artifact.icu ? artifact.icu.url : `${origin}${ICU_PATH}${swiftIcuAddress(artifact.icu)}`;
@@ -95428,7 +95329,6 @@ async function packageSnapshot(project2, entry, moduleRoot) {
95428
95329
  return {
95429
95330
  files: files2,
95430
95331
  oneModule: project2.oneModule,
95431
- standalone: project2.standalone === true,
95432
95332
  binaryModules: {
95433
95333
  ...project2.binaryModules,
95434
95334
  ...Object.fromEntries(
@@ -95640,7 +95540,7 @@ async function compile(packagePath, stamp, moduleRootOverride, hosted, snapshot,
95640
95540
  const input = snapshotCompileInput(snapshot);
95641
95541
  const compiled = {
95642
95542
  files: input.files,
95643
- inputs: otherInputs(input, snapshot.standalone),
95543
+ inputs: otherInputs(input),
95644
95544
  module: moduleStamp(packagePath, moduleRootOverride, false)
95645
95545
  };
95646
95546
  const parsed2 = compileTargets(input);
@@ -95688,8 +95588,6 @@ async function compile(packagePath, stamp, moduleRootOverride, hosted, snapshot,
95688
95588
  buildRoot: swiftBuildRoot(packagePath, moduleRoot),
95689
95589
  moduleRoot,
95690
95590
  ...toolchain,
95691
- // the preview loads an app module beside the shared sdk image
95692
- sdkModule: !snapshot.standalone && (input.sourceLinkGraph !== void 0 || swiftApplicationEntry(input.entry, input.files[input.entry] ?? "")),
95693
95591
  signal
95694
95592
  }).catch((error) => {
95695
95593
  const report = error instanceof Error ? swiftApiGapReport(error.message) : null;
@@ -95838,8 +95736,7 @@ async function compileRemote(packagePath, snapshot, hosted, ownerSignal) {
95838
95736
  resources: snapshot.bundleFiles.files,
95839
95737
  images: snapshot.resources.images,
95840
95738
  entry: snapshot.entry,
95841
- packageId: descriptor?.packageId ?? swiftPackageId(packagePath),
95842
- sdkModule: !snapshot.standalone
95739
+ packageId: descriptor?.packageId ?? swiftPackageId(packagePath)
95843
95740
  },
95844
95741
  origin,
95845
95742
  signal,
@@ -95931,7 +95828,7 @@ function scopedArtifact(project2, entry, moduleRoot, signal) {
95931
95828
  const compiled = project2.artifact?.compiled;
95932
95829
  if (project2.artifact && compiled && compiled.module === moduleStamp(project2.packagePath, moduleRoot, false)) {
95933
95830
  const input = snapshotCompileInput(snapshot);
95934
- const values = otherInputs(input, snapshot.standalone) === compiled.inputs ? designTimeValues(compiled.files, input.files) : null;
95831
+ const values = otherInputs(input) === compiled.inputs ? designTimeValues(compiled.files, input.files) : null;
95935
95832
  if (values) return { ...project2.artifact, stamp, designTimeValues: values };
95936
95833
  }
95937
95834
  return compile(
@@ -102516,7 +102413,7 @@ var init_react_native_core = __esm({
102516
102413
  init_swift_distribution();
102517
102414
  init_swift_package();
102518
102415
  init_swiftContract();
102519
- recipe = true ? "db2c81d6628055a561c22667b098e4686f9d8924ffb229c4c7d9e15a25182502" : reactNativeCoreDigest2(__sootsim_import_meta_dirname);
102416
+ recipe = true ? "d4161f11b10bfff3f21f57ca2352bf31c30f364e15fd7e1c385311c10033fa89" : reactNativeCoreDigest2(__sootsim_import_meta_dirname);
102520
102417
  strings4 = (value) => isRecord(value) && Object.values(value).every((item) => typeof item === "string");
102521
102418
  building = /* @__PURE__ */ new Map();
102522
102419
  }
@@ -105275,7 +105172,7 @@ var init_nitro_superset = __esm({
105275
105172
  init_nitroContract();
105276
105173
  init_swift_standin_digest();
105277
105174
  NITRO_SUPERSET_ENTRY_NAME = "superset";
105278
- NITRO_COMPILER_DIGEST = true ? "744976c15724422db8f3bc8d1fdfdcf68c3f91b185210a50951930d2ea18c38e" : nitroCompilerSourceDigest(__sootsim_import_meta_dirname, STANDIN_SOURCE_DIGEST2);
105175
+ NITRO_COMPILER_DIGEST = true ? "9303a53709842e0a9107912bfca87f4a1731cfc09b9d252fac03c156eabf3836" : nitroCompilerSourceDigest(__sootsim_import_meta_dirname, STANDIN_SOURCE_DIGEST2);
105279
105176
  nitroSupersetLock = parseLock(nitro_superset_lock_default);
105280
105177
  nitroSupersetKey = (inputs2) => nativeEntryKey({ ...inputs2, compiler: NITRO_COMPILER_DIGEST });
105281
105178
  published2 = /* @__PURE__ */ new Map();
@@ -105706,7 +105603,12 @@ function collectNitroCompileInput(collection, adapter, dependencies, iosDeployme
105706
105603
  ].join("\n") : [
105707
105604
  ...swift ? ["@_spi(Peach) import PeachFoundation"] : [],
105708
105605
  ...imports2.map((name3) => `import ${name3}`),
105709
- ...swift ? ["PeachHostDriver.installExecutor()"] : [],
105606
+ ...swift ? [
105607
+ '@_expose(wasm, "peach_nitro_swift_host")',
105608
+ '@_cdecl("peach_nitro_swift_host")',
105609
+ "public func _peachNitroSwiftHost() {}",
105610
+ "PeachHostDriver.installExecutor()"
105611
+ ] : [],
105710
105612
  ...register,
105711
105613
  ""
105712
105614
  ].join("\n");
@@ -106326,7 +106228,6 @@ async function compileNitroModule(options2) {
106326
106228
  );
106327
106229
  const project2 = projectFor(packagePath);
106328
106230
  project2.oneModule = false;
106329
- project2.standalone = true;
106330
106231
  project2.libraries = input.libraries;
106331
106232
  project2.binaryModules = input.binaryModules;
106332
106233
  project2.optimize = input.optimize;
@@ -106400,6 +106301,7 @@ async function compileNitroApp(appRoot, origin, configure, moduleRoot, shared =
106400
106301
  views
106401
106302
  })),
106402
106303
  url: `${origin}/__peach/swift/${artifact.hash}.wasm`,
106304
+ ...await prepareSwiftSdkEntryAssets(origin, artifact),
106403
106305
  hash: artifact.hash,
106404
106306
  icuUrl: icuUrl(origin, artifact),
106405
106307
  bundleFiles: artifact.package.bundleFiles.files