peachsim 0.1.2682 → 0.1.2684

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/cli/commands/package.ts +277 -118
  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 +506 -599
  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-RMQKXS5S.mjs} +3 -3
  28. package/dist-lib/esm-chunks/{chunk-UTI6VCYT.mjs → chunk-3DE27JA4.mjs} +1 -1
  29. package/dist-lib/esm-chunks/{chunk-YKGS4NSG.mjs → chunk-42JSAQWG.mjs} +5 -5
  30. package/dist-lib/esm-chunks/{chunk-5SWSDDXC.mjs → chunk-5KWWKCPH.mjs} +1 -1
  31. package/dist-lib/esm-chunks/{chunk-Z6R2HZIH.mjs → chunk-6BWHCTIS.mjs} +1 -1
  32. package/dist-lib/esm-chunks/{chunk-64UA6DQO.mjs → chunk-7IBMZCMJ.mjs} +3 -3
  33. package/dist-lib/esm-chunks/{chunk-Y6WPXDCC.mjs → chunk-AF35PBIZ.mjs} +1 -1
  34. package/dist-lib/esm-chunks/{chunk-IOLISFIO.mjs → chunk-AYPGNUZY.mjs} +1 -1
  35. package/dist-lib/esm-chunks/{chunk-3UQZATB5.mjs → chunk-DBGGJL5W.mjs} +1 -1
  36. package/dist-lib/esm-chunks/{chunk-PE7HDZNI.mjs → chunk-DJQKYIHE.mjs} +1 -1
  37. package/dist-lib/esm-chunks/{chunk-6PSNFREM.mjs → chunk-DJSSFQTJ.mjs} +1 -1
  38. package/dist-lib/esm-chunks/{chunk-LV55WJFQ.mjs → chunk-HGTEJIU2.mjs} +1 -1
  39. package/dist-lib/esm-chunks/{chunk-BJHQOPWO.mjs → chunk-HSNC4SEX.mjs} +1 -1
  40. package/dist-lib/esm-chunks/{chunk-KYIRROKJ.mjs → chunk-I6KUV3AU.mjs} +1 -1
  41. package/dist-lib/esm-chunks/{chunk-VTJTOL53.mjs → chunk-M25SODH7.mjs} +1 -1
  42. package/dist-lib/esm-chunks/{chunk-AXBK3CA4.mjs → chunk-MEV5LY7S.mjs} +1 -1
  43. package/dist-lib/esm-chunks/{chunk-R2WPUKVT.mjs → chunk-ONY3LDGP.mjs} +1 -1
  44. package/dist-lib/esm-chunks/{chunk-ZYD227CX.mjs → chunk-PKGSIT4N.mjs} +1 -1
  45. package/dist-lib/esm-chunks/{chunk-SZ5UPZE4.mjs → chunk-QA6WIBFG.mjs} +1 -1
  46. package/dist-lib/esm-chunks/{chunk-DU3VOY6S.mjs → chunk-QUNZ325E.mjs} +6 -6
  47. package/dist-lib/esm-chunks/{chunk-3VAFU4BM.mjs → chunk-TN42RBSW.mjs} +4 -4
  48. package/dist-lib/esm-chunks/{chunk-X37OP27I.mjs → chunk-TTUUDIZL.mjs} +678 -790
  49. package/dist-lib/esm-chunks/{chunk-EK36QRGX.mjs → chunk-V4RWDRKK.mjs} +1 -1
  50. package/dist-lib/esm-chunks/{chunk-EC5RY4HR.mjs → chunk-XYDK4MKL.mjs} +2 -2
  51. package/dist-lib/esm-chunks/{chunk-GNZDVDDX.mjs → chunk-YOVFAB5L.mjs} +6 -6
  52. package/dist-lib/esm-chunks/{metro-layout-parser-5RTSOQCS.mjs → metro-layout-parser-UX26SYJA.mjs} +3 -3
  53. package/dist-lib/esm-chunks/{swift-package-prebuilt-EH5JIX6L.mjs → swift-package-prebuilt-TFU7Q54I.mjs} +12 -12
  54. package/dist-lib/esm-chunks/{swift-sdk-app-module-VHAOCBXW.mjs → swift-sdk-app-module-PT7D7AOM.mjs} +16 -16
  55. package/dist-lib/esm-chunks/{swift-sdk-image-3NCWCGQZ.mjs → swift-sdk-image-HZG64EBF.mjs} +16 -16
  56. package/dist-lib/esm-chunks/{swift-sdk-image-producer-5S4IKSJ2.mjs → swift-sdk-image-producer-MUVFVMXM.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/dist-types/packages/peach-engine/src/settings/devices.d.ts +1 -1
  125. package/kotlin/sdk.tar.gz +0 -0
  126. package/package.json +2 -1
  127. package/runtime-companion.json +1 -1
  128. package/src/bundle-channel.mjs +1 -1
  129. package/src/native-bundles.ts +7 -1
  130. package/src/native-package-slice.ts +28 -12
  131. package/src/nitro-bundle.ts +1 -0
  132. package/src/nitro-compile.ts +8 -2
  133. package/src/nitroContract.ts +35 -14
  134. package/src/one-sdk-bundle.ts +2 -2
  135. package/src/swift-compile.ts +25 -131
  136. package/src/swift-guest-compile.ts +184 -218
  137. package/src/swift-host.ts +13 -23
  138. package/src/swift-submit.ts +0 -2
  139. package/src/turbo-bundle.ts +2 -2
  140. 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.2684 | (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;
@@ -30666,7 +30666,7 @@ var init_process_liveness = __esm({
30666
30666
  var runtime_companion_default;
30667
30667
  var init_runtime_companion = __esm({
30668
30668
  "runtime-companion.json"() {
30669
- runtime_companion_default = { abi: 1, sha256: "7a60ab959af99bebbcef81dda2fe962c6eeb694ec491218da2b3b923a7e8e7a9", file: "node/cli-7a60ab959af99bebbcef81dda2fe962c6eeb694ec491218da2b3b923a7e8e7a9.cjs" };
30669
+ runtime_companion_default = { abi: 1, sha256: "e17fe1b370cc7ce9aa701cc8f0b17e1c72e6690873d4413656defc8b1504a2e8", file: "node/cli-e17fe1b370cc7ce9aa701cc8f0b17e1c72e6690873d4413656defc8b1504a2e8.cjs" };
30670
30670
  }
30671
30671
  });
30672
30672
 
@@ -36017,7 +36017,7 @@ var init_swift_objc_sdk_tree = __esm({
36017
36017
 
36018
36018
  // src/swift-compiler-digest.ts
36019
36019
  function swiftArchiveCompilerDigestValue() {
36020
- return true ? "7ec504e1047ea0f31b14e25b8958c42fd1e55cb9c121db3f05e4dead6ef226eb" : swiftCompilerSourceDigest(__sootsim_import_meta_dirname, "archive");
36020
+ return true ? "c304a2da11e2e676fe221d87209a1136a730fd7ea4bf5d094065fd377480ecef" : swiftCompilerSourceDigest(__sootsim_import_meta_dirname, "archive");
36021
36021
  }
36022
36022
  var import_node_crypto11, import_node_fs27, import_node_path25, SWIFT_DIGEST_SOURCES, LINKED_IMAGE_SOURCES, SWIFT_ARCHIVE_DIGEST_SOURCES;
36023
36023
  var init_swift_compiler_digest = __esm({
@@ -36168,7 +36168,7 @@ var init_swift_standin_digest = __esm({
36168
36168
 
36169
36169
  // src/expo-native-compiler-digest.ts
36170
36170
  function expoNativeCompilerDigestValue() {
36171
- return true ? "dd69e490ecc79ee83e8cba98c4532818a62e9b0e93c21113e2d6c21ec60d8eee" : expoNativeCompilerDigest(__sootsim_import_meta_dirname);
36171
+ return true ? "13d332cac87de68ec66d60f9bb7b02f5fbfb1cf35a281ec222570bd0562878cd" : expoNativeCompilerDigest(__sootsim_import_meta_dirname);
36172
36172
  }
36173
36173
  var import_node_crypto13;
36174
36174
  var init_expo_native_compiler_digest = __esm({
@@ -57120,9 +57120,6 @@ var init_retired_cache_directory = __esm({
57120
57120
  });
57121
57121
 
57122
57122
  // src/swift-compile-budget.ts
57123
- function swiftBuilderHopTimeoutMs(compileTimeoutMs) {
57124
- return SWIFT_LOCK_WAIT_TIMEOUT_MS + (compileTimeoutMs ?? SWIFT_COMPILE_TIMEOUT_MS) + SWIFT_TRANSPORT_MARGIN_MS;
57125
- }
57126
57123
  async function withSwiftCompileBudget(compileTimeoutMs, signal, work) {
57127
57124
  const deadline = new AbortController();
57128
57125
  const combined = signal ? AbortSignal.any([signal, deadline.signal]) : deadline.signal;
@@ -57162,13 +57159,12 @@ async function withSwiftCompileBudget(compileTimeoutMs, signal, work) {
57162
57159
  clearTimeout(timer);
57163
57160
  }
57164
57161
  }
57165
- var SWIFT_COMPILE_TIMEOUT_MS, SWIFT_LOCK_WAIT_TIMEOUT_MS, SWIFT_TRANSPORT_MARGIN_MS;
57162
+ var SWIFT_COMPILE_TIMEOUT_MS, SWIFT_LOCK_WAIT_TIMEOUT_MS;
57166
57163
  var init_swift_compile_budget = __esm({
57167
57164
  "src/swift-compile-budget.ts"() {
57168
57165
  "use strict";
57169
57166
  SWIFT_COMPILE_TIMEOUT_MS = 18e5;
57170
57167
  SWIFT_LOCK_WAIT_TIMEOUT_MS = 36e5;
57171
- SWIFT_TRANSPORT_MARGIN_MS = 3e5;
57172
57168
  }
57173
57169
  });
57174
57170
 
@@ -63403,397 +63399,6 @@ var init_swift_guest_archive = __esm({
63403
63399
  }
63404
63400
  });
63405
63401
 
63406
- // ../peach-kit/src/nativeWasmContract.ts
63407
- var NATIVE_IMAGE_SECTION, NATIVE_TABLE_ABI, NATIVE_TABLE_IMPORT_MODULE, NATIVE_TABLE_ADAPT_IMPORT, NATIVE_DYLD_FUNCTION_IMPORT, NATIVE_DYLD_PLACE_EXPORT, NATIVE_DYLD_SECTION, 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_LAZY_MAX_PARTS, NATIVE_PROFILE_SECTION, NATIVE_PROFILE_IMPORT, NATIVE_PROFILE_MEMORY, NATIVE_PROFILE_DUMP, NATIVE_PROFILE_ENDPOINT, SWIFT_ARTIFACT_SHA256_HEADER, NATIVE_TABLE_RESERVE_SLOTS;
63408
- var init_nativeWasmContract = __esm({
63409
- "../peach-kit/src/nativeWasmContract.ts"() {
63410
- "use strict";
63411
- NATIVE_IMAGE_SECTION = "peach.native-image-v1";
63412
- NATIVE_TABLE_ABI = "peach-native-table-v1";
63413
- NATIVE_TABLE_IMPORT_MODULE = "peach_thread";
63414
- NATIVE_TABLE_ADAPT_IMPORT = "adapt_function";
63415
- NATIVE_DYLD_FUNCTION_IMPORT = "dyld_function";
63416
- NATIVE_DYLD_PLACE_EXPORT = "__peach_dyld_place";
63417
- NATIVE_DYLD_SECTION = "peach.lazy-dyld-v1";
63418
- NATIVE_LAZY_IMPORT_MODULE = "peach_lazy";
63419
- NATIVE_SDK_IMPORT_MODULE = "peach_sdk";
63420
- NATIVE_SDK_THUNK_SECTION = "peach.sdk-thunks";
63421
- NATIVE_LAZY_SLOT_IMPORT = "load_slot";
63422
- NATIVE_LAZY_SECTION = "peach.lazy-code-v2";
63423
- NATIVE_LAZY_DIGEST_BYTES = 32;
63424
- NATIVE_LAZY_PART_BYTES = NATIVE_LAZY_DIGEST_BYTES + 4;
63425
- NATIVE_LAZY_MAX_PARTS = 65535;
63426
- NATIVE_PROFILE_SECTION = "peach.startup-profile-v1";
63427
- NATIVE_PROFILE_IMPORT = "peach_profile";
63428
- NATIVE_PROFILE_MEMORY = "profile-data";
63429
- NATIVE_PROFILE_DUMP = "__write_profile";
63430
- NATIVE_PROFILE_ENDPOINT = "/__peach/swift-startup-profile";
63431
- SWIFT_ARTIFACT_SHA256_HEADER = "x-peach-swift-sha256";
63432
- NATIVE_TABLE_RESERVE_SLOTS = 4096;
63433
- }
63434
- });
63435
-
63436
- // src/swift-guest-dyld-functions.ts
63437
- function skipValueType(r) {
63438
- const type = r.byte();
63439
- if (type === 99 || type === 100) r.s();
63440
- }
63441
- function readImports2(bytes, sections) {
63442
- let functions = 0;
63443
- let table64;
63444
- const imports2 = sections.find((s) => s.id === 2);
63445
- if (imports2) {
63446
- const r = wasmReader(bytes, imports2.start);
63447
- for (let n = r.u(); n > 0; n--) {
63448
- r.name();
63449
- r.name();
63450
- const kind = r.byte();
63451
- if (kind === 0) {
63452
- functions++;
63453
- r.u();
63454
- } else if (kind === 1 || kind === 2) {
63455
- if (kind === 1) skipValueType(r);
63456
- const flags = r.u();
63457
- r.u();
63458
- if (flags & 1) r.u();
63459
- if (kind === 1) table64 ??= (flags & 4) !== 0;
63460
- } else if (kind === 3) {
63461
- skipValueType(r);
63462
- r.byte();
63463
- } else if (kind === 4) {
63464
- r.byte();
63465
- r.u();
63466
- } else throw new Error(`unsupported wasm import kind ${kind}`);
63467
- }
63468
- }
63469
- const tables = sections.find((s) => s.id === 4);
63470
- if (table64 === void 0 && tables) {
63471
- const r = wasmReader(bytes, tables.start);
63472
- if (r.u()) {
63473
- skipValueType(r);
63474
- table64 = (r.u() & 4) !== 0;
63475
- }
63476
- }
63477
- return { functions, table64 };
63478
- }
63479
- function hasFunctionTable(bytes) {
63480
- return readImports2(bytes, wasmSections(bytes)).table64 !== void 0;
63481
- }
63482
- function primaryFunctionTable(bytes) {
63483
- const sections = wasmSections(bytes);
63484
- const { table64 } = readImports2(bytes, sections);
63485
- const exported2 = entries(
63486
- bytes,
63487
- sections.find((s) => s.id === 7),
63488
- readExport
63489
- ).find((entry) => {
63490
- const r = wasmReader(entry, 0);
63491
- r.name();
63492
- return r.byte() === 1;
63493
- });
63494
- if (table64 === void 0 || !exported2)
63495
- throw new Error("native primary exports no function table");
63496
- return { name: wasmReader(exported2, 0).name(), table64 };
63497
- }
63498
- function vectorSection(id, count, parts2) {
63499
- const body = Buffer.concat([Buffer.from(uleb2(count)), ...parts2]);
63500
- return Buffer.concat([Buffer.from([id, ...uleb2(body.length)]), body]);
63501
- }
63502
- function rewriteSections(bytes, sections, changes) {
63503
- const out = [bytes.subarray(0, 8)];
63504
- const pending2 = new Map(changes);
63505
- const flushBefore = (id) => {
63506
- for (const [missing2, section2] of pending2) {
63507
- if (SECTION_ORDER.indexOf(missing2) >= SECTION_ORDER.indexOf(id)) continue;
63508
- if (section2) out.push(section2);
63509
- pending2.delete(missing2);
63510
- }
63511
- };
63512
- for (const s of sections) {
63513
- if (s.id !== 0) flushBefore(s.id);
63514
- if (!pending2.has(s.id)) {
63515
- out.push(bytes.subarray(s.offset, s.end));
63516
- continue;
63517
- }
63518
- const section2 = pending2.get(s.id);
63519
- pending2.delete(s.id);
63520
- if (section2) out.push(section2);
63521
- }
63522
- for (const section2 of pending2.values()) if (section2) out.push(section2);
63523
- return Buffer.concat(out);
63524
- }
63525
- function entries(bytes, section2, entry) {
63526
- if (!section2) return [];
63527
- const r = wasmReader(bytes, section2.start);
63528
- const out = [];
63529
- for (let n = r.u(); n > 0; n--) {
63530
- const begin = r.at;
63531
- entry(r);
63532
- out.push(bytes.subarray(begin, r.at));
63533
- }
63534
- if (r.at !== section2.end) throw new Error(`invalid wasm section ${section2.id}`);
63535
- return out;
63536
- }
63537
- function appendLazyPlacement(bytes, functions, table) {
63538
- const sections = wasmSections(bytes);
63539
- const section2 = (id) => sections.find((s) => s.id === id);
63540
- const imports2 = readImports2(bytes, sections);
63541
- const changes = /* @__PURE__ */ new Map();
63542
- let table64 = imports2.table64;
63543
- if (table64 === void 0) {
63544
- if (!table) throw new Error("native image has no function table");
63545
- table64 = table.table64;
63546
- const found2 = section2(2);
63547
- const header = found2 && wasmReader(bytes, found2.start);
63548
- const count = header ? header.u() : 0;
63549
- const module2 = Buffer.from("primary");
63550
- const name4 = Buffer.from(table.name);
63551
- changes.set(
63552
- 2,
63553
- vectorSection(2, count + 1, [
63554
- found2 && header ? bytes.subarray(header.at, found2.end) : new Uint8Array(),
63555
- Buffer.from([
63556
- ...uleb2(module2.length),
63557
- ...module2,
63558
- ...uleb2(name4.length),
63559
- ...name4,
63560
- 1,
63561
- 112,
63562
- table64 ? 4 : 0,
63563
- 0
63564
- ])
63565
- ])
63566
- );
63567
- }
63568
- const types2 = entries(bytes, section2(1), (r) => {
63569
- if (r.byte() !== 96) throw new Error("native image has a non-function type");
63570
- for (let side = 0; side < 2; side++) for (let n = r.u(); n > 0; n--) skipValueType(r);
63571
- });
63572
- const declared = entries(bytes, section2(3), (r) => r.u());
63573
- const bodies = entries(bytes, section2(10), (r) => r.skip(r.u()));
63574
- const exports2 = entries(bytes, section2(7), readExport);
63575
- const elements = entries(bytes, section2(9), skipElementSegment);
63576
- const placementIndex = lastTableElement(elements) + 1;
63577
- elements.splice(
63578
- placementIndex,
63579
- 0,
63580
- Buffer.from([1, 0, ...uleb2(functions.length), ...functions.flatMap(uleb2)])
63581
- );
63582
- const place2 = imports2.functions + declared.length;
63583
- const instructions = [
63584
- 0,
63585
- 32,
63586
- 1,
63587
- ...table64 ? [173] : [],
63588
- 32,
63589
- 0,
63590
- 65,
63591
- 1,
63592
- 252,
63593
- 12,
63594
- ...uleb2(placementIndex),
63595
- 0,
63596
- 11
63597
- ];
63598
- const name3 = Buffer.from(NATIVE_DYLD_PLACE_EXPORT);
63599
- return rewriteSections(
63600
- bytes,
63601
- sections,
63602
- new Map([
63603
- ...changes,
63604
- [
63605
- 1,
63606
- vectorSection(1, types2.length + 1, [
63607
- ...types2,
63608
- Buffer.from([96, 2, 127, 127, 0])
63609
- ])
63610
- ],
63611
- [
63612
- 3,
63613
- vectorSection(3, declared.length + 1, [
63614
- ...declared,
63615
- Buffer.from(uleb2(types2.length))
63616
- ])
63617
- ],
63618
- [
63619
- 7,
63620
- vectorSection(7, exports2.length + 1, [
63621
- ...exports2,
63622
- Buffer.from([...uleb2(name3.length), ...name3, 0, ...uleb2(place2)])
63623
- ])
63624
- ],
63625
- [9, vectorSection(9, elements.length, elements)],
63626
- [
63627
- 10,
63628
- vectorSection(10, bodies.length + 1, [
63629
- ...bodies,
63630
- Buffer.from([...uleb2(instructions.length), ...instructions])
63631
- ])
63632
- ]
63633
- ])
63634
- );
63635
- }
63636
- function skipConstant(r) {
63637
- for (let op = r.byte(); op !== 11; op = r.byte()) {
63638
- if (op === 65 || op === 66) r.s();
63639
- else if (op === 35 || op === 210) r.u();
63640
- else if (op === 208) r.s();
63641
- else if (![106, 107, 108, 124, 125, 126].includes(op))
63642
- throw new Error(`unsupported constant expression op ${op}`);
63643
- }
63644
- }
63645
- function skipElementSegment(r) {
63646
- const flags = r.u();
63647
- if (flags > 7) throw new Error(`unsupported element segment flags ${flags}`);
63648
- if ((flags & 3) === 2) r.u();
63649
- if (!(flags & 1)) skipConstant(r);
63650
- if (flags & 3) skipValueType(r);
63651
- for (let count = r.u(); count > 0; count--)
63652
- if (flags & 4) skipConstant(r);
63653
- else r.u();
63654
- }
63655
- function takeLazyPlacement(bytes) {
63656
- const sections = wasmSections(bytes);
63657
- const section2 = (id) => sections.find((s) => s.id === id);
63658
- const exports2 = entries(bytes, section2(7), readExport);
63659
- const placeExport = exports2.find(
63660
- (entry) => exportName(entry) === NATIVE_DYLD_PLACE_EXPORT
63661
- );
63662
- if (!placeExport) return void 0;
63663
- const imports2 = readImports2(bytes, sections);
63664
- const declared = entries(bytes, section2(3), (r2) => r2.u());
63665
- const bodies = entries(bytes, section2(10), (r2) => r2.skip(r2.u()));
63666
- const p = wasmReader(placeExport, 0);
63667
- p.name();
63668
- if (p.byte() !== 0 || p.u() !== imports2.functions + declared.length - 1)
63669
- throw new Error(`${NATIVE_DYLD_PLACE_EXPORT} is not the last function`);
63670
- const elements = entries(bytes, section2(9), skipElementSegment);
63671
- const placementIndex = lastTableElement(elements);
63672
- const placement = elements[placementIndex];
63673
- if (!placement) throw new Error("lazy function placement has no element segment");
63674
- const r = wasmReader(placement, 0);
63675
- if (r.u() !== 1 || r.byte() !== 0)
63676
- throw new Error("lazy function segment is not a passive function list");
63677
- const functions = [];
63678
- for (let count = r.u(); count > 0; count--) functions.push(r.u());
63679
- elements.splice(placementIndex, 1);
63680
- const kept = exports2.filter((entry) => entry !== placeExport);
63681
- return {
63682
- bytes: rewriteSections(
63683
- bytes,
63684
- sections,
63685
- /* @__PURE__ */ new Map([
63686
- [3, vectorSection(3, declared.length - 1, declared.slice(0, -1))],
63687
- [7, vectorSection(7, kept.length, kept)],
63688
- [9, elements.length ? vectorSection(9, elements.length, elements) : null],
63689
- [10, vectorSection(10, bodies.length - 1, bodies.slice(0, -1))]
63690
- ])
63691
- ),
63692
- functions
63693
- };
63694
- }
63695
- function placeGuestLazyFunctions(bytes, lazy) {
63696
- const sections = wasmSections(bytes);
63697
- const lazyIndex = new Map(lazy.map((name3, index) => [name3, index]));
63698
- const functions = new Array(lazy.length);
63699
- let found2 = 0;
63700
- const kept = entries(
63701
- bytes,
63702
- sections.find((s) => s.id === 7),
63703
- readExport
63704
- ).filter((entry) => {
63705
- const r = wasmReader(entry, 0);
63706
- const position = lazyIndex.get(r.name());
63707
- const kind = r.byte();
63708
- if (kind !== 0 || position === void 0) return true;
63709
- functions[position] = r.u();
63710
- found2++;
63711
- return false;
63712
- });
63713
- if (found2 !== lazy.length)
63714
- throw new Error("guest link lost a lazy dlsym function export");
63715
- return appendLazyPlacement(
63716
- rewriteSections(bytes, sections, /* @__PURE__ */ new Map([[7, vectorSection(7, kept.length, kept)]])),
63717
- functions
63718
- );
63719
- }
63720
- function guestLazyExports(lazy) {
63721
- return lazy.map((name3) => JSON.stringify(`--export=${name3}`)).join("\n");
63722
- }
63723
- function nameLazyFunctions(bytes, functions) {
63724
- const sections = wasmSections(bytes);
63725
- const { functions: imported } = readImports2(bytes, sections);
63726
- const custom = sections.find((s) => s.id === 0 && s.name === "name");
63727
- const subsections = [];
63728
- const names = /* @__PURE__ */ new Map();
63729
- if (custom) {
63730
- const r = wasmReader(bytes, custom.start);
63731
- while (r.at < custom.end) {
63732
- const id = r.byte();
63733
- const size2 = r.u();
63734
- const body = bytes.subarray(r.at, r.at + size2);
63735
- r.skip(size2);
63736
- if (id !== 1) {
63737
- subsections.push({ id, body });
63738
- continue;
63739
- }
63740
- const f = wasmReader(body, 0);
63741
- for (let n = f.u(); n > 0; n--) {
63742
- const index = f.u();
63743
- const start = f.at;
63744
- f.skip(f.u());
63745
- names.set(index, body.subarray(start, f.at));
63746
- }
63747
- }
63748
- }
63749
- for (const index of functions) {
63750
- if (names.has(index)) continue;
63751
- const name3 = Buffer.from(String(index - imported));
63752
- names.set(index, Buffer.from([...uleb2(name3.length), ...name3]));
63753
- }
63754
- const ordered = [...names].sort(([a], [b]) => a - b);
63755
- const functionNames = Buffer.concat([
63756
- Buffer.from(uleb2(ordered.length)),
63757
- ...ordered.flatMap(([index, name3]) => [Buffer.from(uleb2(index)), name3])
63758
- ]);
63759
- const content = [...subsections, { id: 1, body: functionNames }].sort((a, b) => a.id - b.id).flatMap(({ id, body }) => [Buffer.from([id, ...uleb2(body.length)]), body]);
63760
- const label = Buffer.from("name");
63761
- const payload = Buffer.concat([
63762
- Buffer.from([...uleb2(label.length), ...label]),
63763
- ...content
63764
- ]);
63765
- const out = [bytes.subarray(0, 8)];
63766
- for (const s of sections) if (s !== custom) out.push(bytes.subarray(s.offset, s.end));
63767
- out.push(Buffer.from([0, ...uleb2(payload.length)]), payload);
63768
- return Buffer.concat(out);
63769
- }
63770
- var uleb2, SECTION_ORDER, readExport, lastTableElement, exportName;
63771
- var init_swift_guest_dyld_functions = __esm({
63772
- "src/swift-guest-dyld-functions.ts"() {
63773
- "use strict";
63774
- init_nativeWasmContract();
63775
- init_swift_sdk_image_wasm();
63776
- uleb2 = (value) => {
63777
- const out = [];
63778
- do {
63779
- let byte = value % 128;
63780
- value = Math.floor(value / 128);
63781
- if (value) byte |= 128;
63782
- out.push(byte);
63783
- } while (value);
63784
- return out;
63785
- };
63786
- SECTION_ORDER = [1, 2, 3, 4, 5, 13, 6, 7, 8, 9, 12, 10, 11];
63787
- readExport = (r) => {
63788
- r.name();
63789
- r.byte();
63790
- r.u();
63791
- };
63792
- lastTableElement = (segments) => segments.findLastIndex((segment2) => (segment2[0] & 3) !== 3);
63793
- exportName = (entry) => wasmReader(entry, 0).name();
63794
- }
63795
- });
63796
-
63797
63402
  // ../peach-kit/src/nativeDyldTableContract.ts
63798
63403
  function nativeDyldName(bytes) {
63799
63404
  let name3 = "";
@@ -63844,6 +63449,36 @@ var init_nativeDyldTableContract = __esm({
63844
63449
  }
63845
63450
  });
63846
63451
 
63452
+ // ../peach-kit/src/nativeWasmContract.ts
63453
+ var NATIVE_IMAGE_SECTION, NATIVE_TABLE_ABI, NATIVE_TABLE_IMPORT_MODULE, NATIVE_TABLE_ADAPT_IMPORT, NATIVE_DYLD_FUNCTION_IMPORT, NATIVE_DYLD_PLACE_EXPORT, NATIVE_DYLD_SECTION, 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_LAZY_MAX_PARTS, NATIVE_PROFILE_SECTION, NATIVE_PROFILE_IMPORT, NATIVE_PROFILE_MEMORY, NATIVE_PROFILE_DUMP, NATIVE_PROFILE_ENDPOINT, SWIFT_ARTIFACT_SHA256_HEADER, NATIVE_TABLE_RESERVE_SLOTS;
63454
+ var init_nativeWasmContract = __esm({
63455
+ "../peach-kit/src/nativeWasmContract.ts"() {
63456
+ "use strict";
63457
+ NATIVE_IMAGE_SECTION = "peach.native-image-v1";
63458
+ NATIVE_TABLE_ABI = "peach-native-table-v1";
63459
+ NATIVE_TABLE_IMPORT_MODULE = "peach_thread";
63460
+ NATIVE_TABLE_ADAPT_IMPORT = "adapt_function";
63461
+ NATIVE_DYLD_FUNCTION_IMPORT = "dyld_function";
63462
+ NATIVE_DYLD_PLACE_EXPORT = "__peach_dyld_place";
63463
+ NATIVE_DYLD_SECTION = "peach.lazy-dyld-v1";
63464
+ NATIVE_LAZY_IMPORT_MODULE = "peach_lazy";
63465
+ NATIVE_SDK_IMPORT_MODULE = "peach_sdk";
63466
+ NATIVE_SDK_THUNK_SECTION = "peach.sdk-thunks";
63467
+ NATIVE_LAZY_SLOT_IMPORT = "load_slot";
63468
+ NATIVE_LAZY_SECTION = "peach.lazy-code-v2";
63469
+ NATIVE_LAZY_DIGEST_BYTES = 32;
63470
+ NATIVE_LAZY_PART_BYTES = NATIVE_LAZY_DIGEST_BYTES + 4;
63471
+ NATIVE_LAZY_MAX_PARTS = 65535;
63472
+ NATIVE_PROFILE_SECTION = "peach.startup-profile-v1";
63473
+ NATIVE_PROFILE_IMPORT = "peach_profile";
63474
+ NATIVE_PROFILE_MEMORY = "profile-data";
63475
+ NATIVE_PROFILE_DUMP = "__write_profile";
63476
+ NATIVE_PROFILE_ENDPOINT = "/__peach/swift-startup-profile";
63477
+ SWIFT_ARTIFACT_SHA256_HEADER = "x-peach-swift-sha256";
63478
+ NATIVE_TABLE_RESERVE_SLOTS = 4096;
63479
+ }
63480
+ });
63481
+
63847
63482
  // src/swift-guest-image-ledger.ts
63848
63483
  function readNumber(bytes, position) {
63849
63484
  if (position < bytes.length) {
@@ -65689,7 +65324,7 @@ function sha256Hex3(bytes) {
65689
65324
  return new Bun.CryptoHasher("sha256").update(bytes).digest("hex");
65690
65325
  return (0, import_node_crypto34.createHash)("sha256").update(bytes).digest("hex");
65691
65326
  }
65692
- function uleb3(value) {
65327
+ function uleb2(value) {
65693
65328
  const bytes = [];
65694
65329
  for (let rest = value; ; rest = Math.floor(rest / 128)) {
65695
65330
  if (rest < 128) return [...bytes, rest];
@@ -65708,7 +65343,7 @@ function encodeGuestDyldTable(rows) {
65708
65343
  value.writeBigUInt64LE(row.value);
65709
65344
  const bytes = Buffer.concat([
65710
65345
  row.bytes,
65711
- Buffer.from([0, ...uleb3(row.image), row.kind]),
65346
+ Buffer.from([0, ...uleb2(row.image), row.kind]),
65712
65347
  value
65713
65348
  ]);
65714
65349
  if (!current2.length) firsts.push(row.bytes);
@@ -65830,6 +65465,367 @@ var init_mapLimit = __esm({
65830
65465
  }
65831
65466
  });
65832
65467
 
65468
+ // src/swift-guest-dyld-functions.ts
65469
+ function skipValueType(r) {
65470
+ const type = r.byte();
65471
+ if (type === 99 || type === 100) r.s();
65472
+ }
65473
+ function readImports2(bytes, sections) {
65474
+ let functions = 0;
65475
+ let table64;
65476
+ const imports2 = sections.find((s) => s.id === 2);
65477
+ if (imports2) {
65478
+ const r = wasmReader(bytes, imports2.start);
65479
+ for (let n = r.u(); n > 0; n--) {
65480
+ r.name();
65481
+ r.name();
65482
+ const kind = r.byte();
65483
+ if (kind === 0) {
65484
+ functions++;
65485
+ r.u();
65486
+ } else if (kind === 1 || kind === 2) {
65487
+ if (kind === 1) skipValueType(r);
65488
+ const flags = r.u();
65489
+ r.u();
65490
+ if (flags & 1) r.u();
65491
+ if (kind === 1) table64 ??= (flags & 4) !== 0;
65492
+ } else if (kind === 3) {
65493
+ skipValueType(r);
65494
+ r.byte();
65495
+ } else if (kind === 4) {
65496
+ r.byte();
65497
+ r.u();
65498
+ } else throw new Error(`unsupported wasm import kind ${kind}`);
65499
+ }
65500
+ }
65501
+ const tables = sections.find((s) => s.id === 4);
65502
+ if (table64 === void 0 && tables) {
65503
+ const r = wasmReader(bytes, tables.start);
65504
+ if (r.u()) {
65505
+ skipValueType(r);
65506
+ table64 = (r.u() & 4) !== 0;
65507
+ }
65508
+ }
65509
+ return { functions, table64 };
65510
+ }
65511
+ function hasFunctionTable(bytes) {
65512
+ return readImports2(bytes, wasmSections(bytes)).table64 !== void 0;
65513
+ }
65514
+ function primaryFunctionTable(bytes) {
65515
+ const sections = wasmSections(bytes);
65516
+ const { table64 } = readImports2(bytes, sections);
65517
+ const exported2 = entries(
65518
+ bytes,
65519
+ sections.find((s) => s.id === 7),
65520
+ readExport
65521
+ ).find((entry) => {
65522
+ const r = wasmReader(entry, 0);
65523
+ r.name();
65524
+ return r.byte() === 1;
65525
+ });
65526
+ if (table64 === void 0 || !exported2)
65527
+ throw new Error("native primary exports no function table");
65528
+ return { name: wasmReader(exported2, 0).name(), table64 };
65529
+ }
65530
+ function vectorSection(id, count, parts2) {
65531
+ const body = Buffer.concat([Buffer.from(uleb3(count)), ...parts2]);
65532
+ return Buffer.concat([Buffer.from([id, ...uleb3(body.length)]), body]);
65533
+ }
65534
+ function rewriteSections(bytes, sections, changes) {
65535
+ const out = [bytes.subarray(0, 8)];
65536
+ const pending2 = new Map(changes);
65537
+ const flushBefore = (id) => {
65538
+ for (const [missing2, section2] of pending2) {
65539
+ if (SECTION_ORDER.indexOf(missing2) >= SECTION_ORDER.indexOf(id)) continue;
65540
+ if (section2) out.push(section2);
65541
+ pending2.delete(missing2);
65542
+ }
65543
+ };
65544
+ for (const s of sections) {
65545
+ if (s.id !== 0) flushBefore(s.id);
65546
+ if (!pending2.has(s.id)) {
65547
+ out.push(bytes.subarray(s.offset, s.end));
65548
+ continue;
65549
+ }
65550
+ const section2 = pending2.get(s.id);
65551
+ pending2.delete(s.id);
65552
+ if (section2) out.push(section2);
65553
+ }
65554
+ for (const section2 of pending2.values()) if (section2) out.push(section2);
65555
+ return Buffer.concat(out);
65556
+ }
65557
+ function entries(bytes, section2, entry) {
65558
+ if (!section2) return [];
65559
+ const r = wasmReader(bytes, section2.start);
65560
+ const out = [];
65561
+ for (let n = r.u(); n > 0; n--) {
65562
+ const begin = r.at;
65563
+ entry(r);
65564
+ out.push(bytes.subarray(begin, r.at));
65565
+ }
65566
+ if (r.at !== section2.end) throw new Error(`invalid wasm section ${section2.id}`);
65567
+ return out;
65568
+ }
65569
+ function appendLazyPlacement(bytes, functions, table) {
65570
+ const sections = wasmSections(bytes);
65571
+ const section2 = (id) => sections.find((s) => s.id === id);
65572
+ const imports2 = readImports2(bytes, sections);
65573
+ const changes = /* @__PURE__ */ new Map();
65574
+ let table64 = imports2.table64;
65575
+ if (table64 === void 0) {
65576
+ if (!table) throw new Error("native image has no function table");
65577
+ table64 = table.table64;
65578
+ const found2 = section2(2);
65579
+ const header = found2 && wasmReader(bytes, found2.start);
65580
+ const count = header ? header.u() : 0;
65581
+ const module2 = Buffer.from("primary");
65582
+ const name4 = Buffer.from(table.name);
65583
+ changes.set(
65584
+ 2,
65585
+ vectorSection(2, count + 1, [
65586
+ found2 && header ? bytes.subarray(header.at, found2.end) : new Uint8Array(),
65587
+ Buffer.from([
65588
+ ...uleb3(module2.length),
65589
+ ...module2,
65590
+ ...uleb3(name4.length),
65591
+ ...name4,
65592
+ 1,
65593
+ 112,
65594
+ table64 ? 4 : 0,
65595
+ 0
65596
+ ])
65597
+ ])
65598
+ );
65599
+ }
65600
+ const types2 = entries(bytes, section2(1), (r) => {
65601
+ if (r.byte() !== 96) throw new Error("native image has a non-function type");
65602
+ for (let side = 0; side < 2; side++) for (let n = r.u(); n > 0; n--) skipValueType(r);
65603
+ });
65604
+ const declared = entries(bytes, section2(3), (r) => r.u());
65605
+ const bodies = entries(bytes, section2(10), (r) => r.skip(r.u()));
65606
+ const exports2 = entries(bytes, section2(7), readExport);
65607
+ const elements = entries(bytes, section2(9), skipElementSegment);
65608
+ const placementIndex = lastTableElement(elements) + 1;
65609
+ elements.splice(
65610
+ placementIndex,
65611
+ 0,
65612
+ Buffer.from([1, 0, ...uleb3(functions.length), ...functions.flatMap(uleb3)])
65613
+ );
65614
+ const place2 = imports2.functions + declared.length;
65615
+ const instructions = [
65616
+ 0,
65617
+ 32,
65618
+ 1,
65619
+ ...table64 ? [173] : [],
65620
+ 32,
65621
+ 0,
65622
+ 65,
65623
+ 1,
65624
+ 252,
65625
+ 12,
65626
+ ...uleb3(placementIndex),
65627
+ 0,
65628
+ 11
65629
+ ];
65630
+ const name3 = Buffer.from(NATIVE_DYLD_PLACE_EXPORT);
65631
+ return rewriteSections(
65632
+ bytes,
65633
+ sections,
65634
+ new Map([
65635
+ ...changes,
65636
+ [
65637
+ 1,
65638
+ vectorSection(1, types2.length + 1, [
65639
+ ...types2,
65640
+ Buffer.from([96, 2, 127, 127, 0])
65641
+ ])
65642
+ ],
65643
+ [
65644
+ 3,
65645
+ vectorSection(3, declared.length + 1, [
65646
+ ...declared,
65647
+ Buffer.from(uleb3(types2.length))
65648
+ ])
65649
+ ],
65650
+ [
65651
+ 7,
65652
+ vectorSection(7, exports2.length + 1, [
65653
+ ...exports2,
65654
+ Buffer.from([...uleb3(name3.length), ...name3, 0, ...uleb3(place2)])
65655
+ ])
65656
+ ],
65657
+ [9, vectorSection(9, elements.length, elements)],
65658
+ [
65659
+ 10,
65660
+ vectorSection(10, bodies.length + 1, [
65661
+ ...bodies,
65662
+ Buffer.from([...uleb3(instructions.length), ...instructions])
65663
+ ])
65664
+ ]
65665
+ ])
65666
+ );
65667
+ }
65668
+ function skipConstant(r) {
65669
+ for (let op = r.byte(); op !== 11; op = r.byte()) {
65670
+ if (op === 65 || op === 66) r.s();
65671
+ else if (op === 35 || op === 210) r.u();
65672
+ else if (op === 208) r.s();
65673
+ else if (![106, 107, 108, 124, 125, 126].includes(op))
65674
+ throw new Error(`unsupported constant expression op ${op}`);
65675
+ }
65676
+ }
65677
+ function skipElementSegment(r) {
65678
+ const flags = r.u();
65679
+ if (flags > 7) throw new Error(`unsupported element segment flags ${flags}`);
65680
+ if ((flags & 3) === 2) r.u();
65681
+ if (!(flags & 1)) skipConstant(r);
65682
+ if (flags & 3) skipValueType(r);
65683
+ for (let count = r.u(); count > 0; count--)
65684
+ if (flags & 4) skipConstant(r);
65685
+ else r.u();
65686
+ }
65687
+ function takeLazyPlacement(bytes) {
65688
+ const sections = wasmSections(bytes);
65689
+ const section2 = (id) => sections.find((s) => s.id === id);
65690
+ const exports2 = entries(bytes, section2(7), readExport);
65691
+ const placeExport = exports2.find(
65692
+ (entry) => exportName(entry) === NATIVE_DYLD_PLACE_EXPORT
65693
+ );
65694
+ if (!placeExport) return void 0;
65695
+ const imports2 = readImports2(bytes, sections);
65696
+ const declared = entries(bytes, section2(3), (r2) => r2.u());
65697
+ const bodies = entries(bytes, section2(10), (r2) => r2.skip(r2.u()));
65698
+ const p = wasmReader(placeExport, 0);
65699
+ p.name();
65700
+ if (p.byte() !== 0 || p.u() !== imports2.functions + declared.length - 1)
65701
+ throw new Error(`${NATIVE_DYLD_PLACE_EXPORT} is not the last function`);
65702
+ const elements = entries(bytes, section2(9), skipElementSegment);
65703
+ const placementIndex = lastTableElement(elements);
65704
+ const placement = elements[placementIndex];
65705
+ if (!placement) throw new Error("lazy function placement has no element segment");
65706
+ const r = wasmReader(placement, 0);
65707
+ if (r.u() !== 1 || r.byte() !== 0)
65708
+ throw new Error("lazy function segment is not a passive function list");
65709
+ const functions = [];
65710
+ for (let count = r.u(); count > 0; count--) functions.push(r.u());
65711
+ elements.splice(placementIndex, 1);
65712
+ const kept = exports2.filter((entry) => entry !== placeExport);
65713
+ return {
65714
+ bytes: rewriteSections(
65715
+ bytes,
65716
+ sections,
65717
+ /* @__PURE__ */ new Map([
65718
+ [3, vectorSection(3, declared.length - 1, declared.slice(0, -1))],
65719
+ [7, vectorSection(7, kept.length, kept)],
65720
+ [9, elements.length ? vectorSection(9, elements.length, elements) : null],
65721
+ [10, vectorSection(10, bodies.length - 1, bodies.slice(0, -1))]
65722
+ ])
65723
+ ),
65724
+ functions
65725
+ };
65726
+ }
65727
+ function placeGuestLazyFunctions(bytes, lazy) {
65728
+ const sections = wasmSections(bytes);
65729
+ const lazyIndex = new Map(lazy.map((name3, index) => [name3, index]));
65730
+ const functions = new Array(lazy.length);
65731
+ let found2 = 0;
65732
+ const kept = entries(
65733
+ bytes,
65734
+ sections.find((s) => s.id === 7),
65735
+ readExport
65736
+ ).filter((entry) => {
65737
+ const r = wasmReader(entry, 0);
65738
+ const position = lazyIndex.get(r.name());
65739
+ const kind = r.byte();
65740
+ if (kind !== 0 || position === void 0) return true;
65741
+ functions[position] = r.u();
65742
+ found2++;
65743
+ return false;
65744
+ });
65745
+ if (found2 !== lazy.length)
65746
+ throw new Error("guest link lost a lazy dlsym function export");
65747
+ return appendLazyPlacement(
65748
+ rewriteSections(bytes, sections, /* @__PURE__ */ new Map([[7, vectorSection(7, kept.length, kept)]])),
65749
+ functions
65750
+ );
65751
+ }
65752
+ function guestLazyExports(lazy) {
65753
+ return lazy.map((name3) => JSON.stringify(`--export=${name3}`)).join("\n");
65754
+ }
65755
+ function nameLazyFunctions(bytes, functions) {
65756
+ const sections = wasmSections(bytes);
65757
+ const { functions: imported } = readImports2(bytes, sections);
65758
+ const custom = sections.find((s) => s.id === 0 && s.name === "name");
65759
+ const subsections = [];
65760
+ const names = /* @__PURE__ */ new Map();
65761
+ if (custom) {
65762
+ const r = wasmReader(bytes, custom.start);
65763
+ while (r.at < custom.end) {
65764
+ const id = r.byte();
65765
+ const size2 = r.u();
65766
+ const body = bytes.subarray(r.at, r.at + size2);
65767
+ r.skip(size2);
65768
+ if (id !== 1) {
65769
+ subsections.push({ id, body });
65770
+ continue;
65771
+ }
65772
+ const f = wasmReader(body, 0);
65773
+ for (let n = f.u(); n > 0; n--) {
65774
+ const index = f.u();
65775
+ const start = f.at;
65776
+ f.skip(f.u());
65777
+ names.set(index, body.subarray(start, f.at));
65778
+ }
65779
+ }
65780
+ }
65781
+ for (const index of functions) {
65782
+ if (names.has(index)) continue;
65783
+ const name3 = Buffer.from(String(index - imported));
65784
+ names.set(index, Buffer.from([...uleb3(name3.length), ...name3]));
65785
+ }
65786
+ const ordered = [...names].sort(([a], [b]) => a - b);
65787
+ const functionNames = Buffer.concat([
65788
+ Buffer.from(uleb3(ordered.length)),
65789
+ ...ordered.flatMap(([index, name3]) => [Buffer.from(uleb3(index)), name3])
65790
+ ]);
65791
+ const content = [...subsections, { id: 1, body: functionNames }].sort((a, b) => a.id - b.id).flatMap(({ id, body }) => [Buffer.from([id, ...uleb3(body.length)]), body]);
65792
+ const label = Buffer.from("name");
65793
+ const payload = Buffer.concat([
65794
+ Buffer.from([...uleb3(label.length), ...label]),
65795
+ ...content
65796
+ ]);
65797
+ const out = [bytes.subarray(0, 8)];
65798
+ for (const s of sections) if (s !== custom) out.push(bytes.subarray(s.offset, s.end));
65799
+ out.push(Buffer.from([0, ...uleb3(payload.length)]), payload);
65800
+ return Buffer.concat(out);
65801
+ }
65802
+ var uleb3, SECTION_ORDER, readExport, lastTableElement, exportName;
65803
+ var init_swift_guest_dyld_functions = __esm({
65804
+ "src/swift-guest-dyld-functions.ts"() {
65805
+ "use strict";
65806
+ init_nativeWasmContract();
65807
+ init_swift_sdk_image_wasm();
65808
+ uleb3 = (value) => {
65809
+ const out = [];
65810
+ do {
65811
+ let byte = value % 128;
65812
+ value = Math.floor(value / 128);
65813
+ if (value) byte |= 128;
65814
+ out.push(byte);
65815
+ } while (value);
65816
+ return out;
65817
+ };
65818
+ SECTION_ORDER = [1, 2, 3, 4, 5, 13, 6, 7, 8, 9, 12, 10, 11];
65819
+ readExport = (r) => {
65820
+ r.name();
65821
+ r.byte();
65822
+ r.u();
65823
+ };
65824
+ lastTableElement = (segments) => segments.findLastIndex((segment2) => (segment2[0] & 3) !== 3);
65825
+ exportName = (entry) => wasmReader(entry, 0).name();
65826
+ }
65827
+ });
65828
+
65833
65829
  // src/swift-guest-link-plan.ts
65834
65830
  function selectedGuestInputImage(artifact, member) {
65835
65831
  if (artifact.kind === "object" !== (member === null))
@@ -77002,9 +76998,11 @@ async function compileGuestLink(options2) {
77002
76998
  return [...source, ...runtime].sort((a, b) => a.image - b.image);
77003
76999
  };
77004
77000
  const sdk2 = options2.sdkImage;
77005
- const sdkCallers = sdk2?.sdkInterface.guestCallers;
77006
- const sdkObjects = sdk2 ? (await Promise.resolve().then(() => (init_swift_sdk_image(), swift_sdk_image_exports))).readSwiftSdkManifestIndex(sdk2).guestObjects : void 0;
77007
- if (sdk2 && (!sdkCallers || !sdkObjects))
77001
+ const sdkCallers = sdk2.sdkInterface.guestCallers;
77002
+ const sdkObjects = (await Promise.resolve().then(() => (init_swift_sdk_image(), swift_sdk_image_exports))).readSwiftSdkManifestIndex(
77003
+ sdk2
77004
+ ).guestObjects;
77005
+ if (!sdkCallers || !sdkObjects)
77008
77006
  throw new Error("the SDK image has no guest link manifest");
77009
77007
  const result = await linkPrunedGuestImages({
77010
77008
  buildDirectory: options2.buildDirectory,
@@ -77017,14 +77015,14 @@ async function compileGuestLink(options2) {
77017
77015
  ledgerDataImage: 0,
77018
77016
  framework: catalogs.framework,
77019
77017
  sdkProducts: null,
77020
- sharedSdk: sdkCallers && sdkObjects ? {
77018
+ sharedSdk: {
77021
77019
  callers: sdkCallers,
77022
77020
  hasContainingObject: (identity2) => sdkObjects[sdkGuestObjectKey(identity2)] !== void 0
77023
- } : void 0,
77024
- onSplitInputs: sdk2 ? (value) => {
77021
+ },
77022
+ onSplitInputs: (value) => {
77025
77023
  splitInputs = value;
77026
- } : void 0,
77027
- deferFinalLink: Boolean(sdk2),
77024
+ },
77025
+ deferFinalLink: true,
77028
77026
  onDyldRows: (rows) => {
77029
77027
  lazyFunctions = rows.lazyFunctions;
77030
77028
  dyldSymbols = rows.dyldSymbols;
@@ -77292,191 +77290,165 @@ async function compileGuestLink(options2) {
77292
77290
  }
77293
77291
  });
77294
77292
  if (!reserved2 || !projectionObject) throw new Error("guest projection was not reserved");
77295
- if (sdk2) {
77296
- try {
77297
- if (!splitInputs) throw new Error("guest link did not select shared SDK inputs");
77298
- const {
77299
- createSwiftSdkBinding: createSwiftSdkBinding2,
77300
- linkSwiftAppModule: linkSwiftAppModule2,
77301
- readSwiftSdkUsage: readSwiftSdkUsage2,
77302
- swiftAppModuleThunkSection: swiftAppModuleThunkSection2,
77303
- swiftSdkProjectionSpans: swiftSdkProjectionSpans2
77304
- } = await Promise.resolve().then(() => (init_swift_sdk_app_module(), swift_sdk_app_module_exports));
77305
- const project2 = options2.project;
77306
- const work = project2 ? (0, import_node_fs77.mkdtempSync)(import_node_path75.default.join(directory2, "app-module-")) : import_node_path75.default.join(directory2, "app-module");
77307
- if (project2) (0, import_node_fs77.chownSync)(work, project2.uid, project2.gid);
77308
- else (0, import_node_fs77.mkdirSync)(work, { recursive: true });
77309
- const layoutMap = import_node_path75.default.join(work, "app.map");
77310
- let appProjectionObject = projectionObject;
77311
- const owners = new Map(splitInputs.appObjects).set(appProjectionObject, 0);
77312
- const sdkObjectKeys = /* @__PURE__ */ new Map();
77313
- const sdkObjectImages = /* @__PURE__ */ new Map();
77314
- const sdkProductImages = new Map(prepared?.sdkProducts.images);
77315
- for (const [file, { image, product, identity: identity2 }] of splitInputs.sdkObjects) {
77316
- const key2 = sdkGuestObjectKey(identity2);
77317
- sdkObjectKeys.set(file, key2);
77318
- sdkObjectImages.set(key2, image);
77319
- const priorImage = sdkProductImages.get(product);
77320
- if (priorImage !== void 0 && priorImage !== image)
77321
- throw new Error(`SDK product ${product} has several guest images`);
77322
- sdkProductImages.set(product, image);
77323
- }
77324
- const linkedModule = import_node_path75.default.join(work, "app.wasm");
77325
- const sdkSpans = swiftSdkProjectionSpans2(
77326
- sdk2,
77327
- (object9, product) => sdkObjectImages.get(object9) ?? sdkProductImages.get(product)
77328
- );
77329
- const compileAppProjection = (source) => {
77330
- const projectionSource = import_node_path75.default.join(work, "projection.c");
77331
- const nextObject = import_node_path75.default.join(work, "projection.o");
77332
- (0, import_node_fs77.writeFileSync)(projectionSource, source);
77333
- (0, import_node_child_process41.execFileSync)(
77334
- import_node_path75.default.join(options2.toolchainBin, "clang"),
77335
- [...clangOptions, "-c", projectionSource, "-o", nextObject],
77336
- { stdio: "pipe" }
77337
- );
77338
- if (nextObject !== appProjectionObject) {
77339
- owners.delete(appProjectionObject);
77340
- appProjectionObject = nextObject;
77341
- owners.set(appProjectionObject, 0);
77293
+ try {
77294
+ if (!splitInputs) throw new Error("guest link did not select shared SDK inputs");
77295
+ const {
77296
+ createSwiftSdkBinding: createSwiftSdkBinding2,
77297
+ linkSwiftAppModule: linkSwiftAppModule2,
77298
+ readSwiftSdkUsage: readSwiftSdkUsage2,
77299
+ swiftAppModuleThunkSection: swiftAppModuleThunkSection2,
77300
+ swiftSdkProjectionSpans: swiftSdkProjectionSpans2
77301
+ } = await Promise.resolve().then(() => (init_swift_sdk_app_module(), swift_sdk_app_module_exports));
77302
+ const project2 = options2.project;
77303
+ const work = project2 ? (0, import_node_fs77.mkdtempSync)(import_node_path75.default.join(directory2, "app-module-")) : import_node_path75.default.join(directory2, "app-module");
77304
+ if (project2) (0, import_node_fs77.chownSync)(work, project2.uid, project2.gid);
77305
+ else (0, import_node_fs77.mkdirSync)(work, { recursive: true });
77306
+ const layoutMap = import_node_path75.default.join(work, "app.map");
77307
+ let appProjectionObject = projectionObject;
77308
+ const owners = new Map(splitInputs.appObjects).set(appProjectionObject, 0);
77309
+ const sdkObjectKeys = /* @__PURE__ */ new Map();
77310
+ const sdkObjectImages = /* @__PURE__ */ new Map();
77311
+ const sdkProductImages = new Map(prepared?.sdkProducts.images);
77312
+ for (const [file, { image, product, identity: identity2 }] of splitInputs.sdkObjects) {
77313
+ const key2 = sdkGuestObjectKey(identity2);
77314
+ sdkObjectKeys.set(file, key2);
77315
+ sdkObjectImages.set(key2, image);
77316
+ const priorImage = sdkProductImages.get(product);
77317
+ if (priorImage !== void 0 && priorImage !== image)
77318
+ throw new Error(`SDK product ${product} has several guest images`);
77319
+ sdkProductImages.set(product, image);
77320
+ }
77321
+ const linkedModule = import_node_path75.default.join(work, "app.wasm");
77322
+ const sdkSpans = swiftSdkProjectionSpans2(
77323
+ sdk2,
77324
+ (object9, product) => sdkObjectImages.get(object9) ?? sdkProductImages.get(product)
77325
+ );
77326
+ const compileAppProjection = (source) => {
77327
+ const projectionSource = import_node_path75.default.join(work, "projection.c");
77328
+ const nextObject = import_node_path75.default.join(work, "projection.o");
77329
+ (0, import_node_fs77.writeFileSync)(projectionSource, source);
77330
+ (0, import_node_child_process41.execFileSync)(
77331
+ import_node_path75.default.join(options2.toolchainBin, "clang"),
77332
+ [...clangOptions, "-c", projectionSource, "-o", nextObject],
77333
+ { stdio: "pipe" }
77334
+ );
77335
+ if (nextObject !== appProjectionObject) {
77336
+ owners.delete(appProjectionObject);
77337
+ appProjectionObject = nextObject;
77338
+ owners.set(appProjectionObject, 0);
77339
+ }
77340
+ };
77341
+ let storage = reserved2;
77342
+ if (sdkSpans.length > 0) {
77343
+ const sdkCounts = guestProjectionRegionCounts(storage.images.length, sdkSpans);
77344
+ storage = reserveGuestProjectionStorage(
77345
+ storage.images,
77346
+ storage.capacities.map((capacity, index) => ({
77347
+ ...capacity,
77348
+ regions: capacity.regions + sdkCounts[index] + 16
77349
+ }))
77350
+ );
77351
+ compileAppProjection(storage.source);
77352
+ }
77353
+ let precomputedSymbols;
77354
+ if (splitInputs.appReferencedSymbols && splitInputs.appDefinedSymbols) {
77355
+ const referenced = new Set(splitInputs.appReferencedSymbols);
77356
+ const defined = new Set(splitInputs.appDefinedSymbols);
77357
+ const projSyms = guestWasmSymbols((0, import_node_fs77.readFileSync)(appProjectionObject));
77358
+ for (const name3 of projSyms.undefined) referenced.add(name3);
77359
+ for (const name3 of projSyms.defined) defined.add(name3);
77360
+ precomputedSymbols = { referenced, defined };
77361
+ }
77362
+ for (; ; ) {
77363
+ const link = await linkSwiftAppModule2({
77364
+ objects: [...owners.keys()],
77365
+ lazyFunctions: splitInputs.lazyFunctions,
77366
+ toolchainBin: options2.toolchainBin,
77367
+ sdk: sdk2,
77368
+ work,
77369
+ output: options2.optimized,
77370
+ optimize: options2.optimize,
77371
+ layoutMap,
77372
+ project: project2,
77373
+ precomputedSymbols,
77374
+ loweringCache: project2 ? void 0 : {
77375
+ file: import_node_path75.default.join(
77376
+ options2.buildDirectory,
77377
+ ".build",
77378
+ "peach-app-module-lowered.wasm"
77379
+ ),
77380
+ compilerDigest: options2.compilerDigest
77342
77381
  }
77343
- };
77344
- let storage = reserved2;
77345
- if (sdkSpans.length > 0) {
77346
- const sdkCounts = guestProjectionRegionCounts(storage.images.length, sdkSpans);
77382
+ });
77383
+ const map2 = (0, import_node_fs77.readFileSync)(
77384
+ project2 ? projectOutputFile(work, layoutMap, project2) : layoutMap,
77385
+ "utf8"
77386
+ );
77387
+ const values = guestDyldValueRange(map2);
77388
+ const bindingRows = /* @__PURE__ */ new Map();
77389
+ const data = [];
77390
+ for (let at = 0; at < link.linkage.data.length; at += 3) {
77391
+ const address = link.linkage.data[at];
77392
+ const size2 = link.linkage.data[at + 1];
77393
+ const value = link.linkage.data[at + 2];
77394
+ if (values && address >= values.address && address < values.address + values.length) {
77395
+ if (size2 !== 8 || (address - values.address) % 8)
77396
+ throw new Error("sdk binding splits a dyld value");
77397
+ bindingRows.set((address - values.address) / 8, value);
77398
+ } else data.push(address, size2, value);
77399
+ }
77400
+ const linked = (0, import_node_fs77.readFileSync)(
77401
+ project2 ? projectOutputFile(work, linkedModule, project2) : linkedModule
77402
+ );
77403
+ const required = guestProjectionRegionCounts(storage.images.length, [
77404
+ ...guestLinkedSpans(map2, linked, linked, owners, splitInputs.appSections, true),
77405
+ ...sdkSpans
77406
+ ]);
77407
+ if (storage.capacities.some(({ regions }, index) => required[index] > regions)) {
77347
77408
  storage = reserveGuestProjectionStorage(
77348
77409
  storage.images,
77349
- storage.capacities.map((capacity, index) => ({
77350
- ...capacity,
77351
- regions: capacity.regions + sdkCounts[index] + 16
77352
- }))
77410
+ storage.capacities.map((capacity, index) => {
77411
+ const count = required[index];
77412
+ return count > capacity.regions ? { ...capacity, regions: Math.max(count, capacity.regions * 2) } : capacity;
77413
+ })
77353
77414
  );
77354
77415
  compileAppProjection(storage.source);
77416
+ continue;
77355
77417
  }
77356
- let precomputedSymbols;
77357
- if (splitInputs.appReferencedSymbols && splitInputs.appDefinedSymbols) {
77358
- const referenced = new Set(splitInputs.appReferencedSymbols);
77359
- const defined = new Set(splitInputs.appDefinedSymbols);
77360
- const projSyms = guestWasmSymbols((0, import_node_fs77.readFileSync)(appProjectionObject));
77361
- for (const name3 of projSyms.undefined) referenced.add(name3);
77362
- for (const name3 of projSyms.defined) defined.add(name3);
77363
- precomputedSymbols = { referenced, defined };
77364
- }
77365
- for (; ; ) {
77366
- const link = await linkSwiftAppModule2({
77367
- objects: [...owners.keys()],
77368
- lazyFunctions: splitInputs.lazyFunctions,
77369
- toolchainBin: options2.toolchainBin,
77370
- sdk: sdk2,
77371
- work,
77372
- output: options2.optimized,
77373
- optimize: options2.optimize,
77374
- layoutMap,
77375
- project: project2,
77376
- precomputedSymbols,
77377
- loweringCache: project2 ? void 0 : {
77378
- file: import_node_path75.default.join(
77379
- options2.buildDirectory,
77380
- ".build",
77381
- "peach-app-module-lowered.wasm"
77382
- ),
77383
- compilerDigest: options2.compilerDigest
77384
- }
77385
- });
77386
- const map3 = (0, import_node_fs77.readFileSync)(
77387
- project2 ? projectOutputFile(work, layoutMap, project2) : layoutMap,
77388
- "utf8"
77389
- );
77390
- const values = guestDyldValueRange(map3);
77391
- const bindingRows = /* @__PURE__ */ new Map();
77392
- const data = [];
77393
- for (let at = 0; at < link.linkage.data.length; at += 3) {
77394
- const address = link.linkage.data[at];
77395
- const size2 = link.linkage.data[at + 1];
77396
- const value = link.linkage.data[at + 2];
77397
- if (values && address >= values.address && address < values.address + values.length) {
77398
- if (size2 !== 8 || (address - values.address) % 8)
77399
- throw new Error("sdk binding splits a dyld value");
77400
- bindingRows.set((address - values.address) / 8, value);
77401
- } else data.push(address, size2, value);
77402
- }
77403
- const linked = (0, import_node_fs77.readFileSync)(
77404
- project2 ? projectOutputFile(work, linkedModule, project2) : linkedModule
77405
- );
77406
- const required = guestProjectionRegionCounts(storage.images.length, [
77407
- ...guestLinkedSpans(map3, linked, linked, owners, splitInputs.appSections, true),
77408
- ...sdkSpans
77409
- ]);
77410
- if (storage.capacities.some(({ regions }, index) => required[index] > regions)) {
77411
- storage = reserveGuestProjectionStorage(
77412
- storage.images,
77413
- storage.capacities.map((capacity, index) => {
77414
- const count = required[index];
77415
- return count > capacity.regions ? { ...capacity, regions: Math.max(count, capacity.regions * 2) } : capacity;
77416
- })
77417
- );
77418
- compileAppProjection(storage.source);
77419
- continue;
77420
- }
77421
- options2.onStage("lowering the app image");
77422
- const lowerPromise = link.lower();
77423
- await new Promise((resolve16) => setImmediate(resolve16));
77424
- let binding;
77425
- try {
77426
- if (result.finalLinkDone) await result.finalLinkDone;
77427
- const usage = readSwiftSdkUsage2(result.mapPath, options2.output, sdkObjectKeys);
77428
- binding = createSwiftSdkBinding2({ ...link.linkage, data }, sdk2, usage);
77429
- } catch (error) {
77430
- await Promise.allSettled([lowerPromise]);
77431
- throw error;
77432
- }
77433
- await lowerPromise;
77434
- const finalized = finalizeGuestProjectionStorage({
77435
- map: map3,
77436
- linked,
77437
- optimized: (0, import_node_fs77.readFileSync)(options2.optimized),
77438
- owners,
77439
- sectionOwners: splitInputs.appSections,
77440
- projectionObject: appProjectionObject,
77441
- reserved: storage,
77442
- sdkSpans
77443
- });
77444
- (0, import_node_fs77.writeFileSync)(
77445
- options2.optimized,
77446
- moveGuestDyldTable(map3, finalized.wasm, splitInputs.dyldSymbols, bindingRows, [
77447
- swiftAppModuleThunkSection2(finalized.wasm)
77448
- ])
77449
- );
77450
- return binding;
77418
+ options2.onStage("lowering the app image");
77419
+ const lowerPromise = link.lower();
77420
+ await new Promise((resolve16) => setImmediate(resolve16));
77421
+ let binding;
77422
+ try {
77423
+ if (result.finalLinkDone) await result.finalLinkDone;
77424
+ const usage = readSwiftSdkUsage2(result.mapPath, options2.output, sdkObjectKeys);
77425
+ binding = createSwiftSdkBinding2({ ...link.linkage, data }, sdk2, usage);
77426
+ } catch (error) {
77427
+ await Promise.allSettled([lowerPromise]);
77428
+ throw error;
77451
77429
  }
77452
- } finally {
77453
- if (result.finalLinkDone) await Promise.allSettled([result.finalLinkDone]);
77454
- }
77455
- }
77456
- options2.onStage("lowering the app image");
77457
- await lowerWasm(options2.output, options2.optimized, {
77458
- optimize: options2.optimize,
77459
- skipPasses: ["duplicate-function-elimination"],
77460
- wideExports: lazyFunctions
77461
- });
77462
- if (lazyFunctions.length)
77463
- (0, import_node_fs77.writeFileSync)(
77464
- options2.optimized,
77465
- placeGuestLazyFunctions((0, import_node_fs77.readFileSync)(options2.optimized), lazyFunctions)
77466
- );
77467
- const map2 = (0, import_node_fs77.readFileSync)(result.mapPath, "utf8");
77468
- let optimized = (0, import_node_fs77.readFileSync)(options2.optimized);
77469
- if (/ __peach_guest_images$/m.test(map2))
77470
- optimized = finalizeGuestProjectionStorage({
77471
- map: map2,
77472
- linked: (0, import_node_fs77.readFileSync)(options2.output),
77473
- optimized,
77474
- owners: result.owners,
77475
- sectionOwners: result.generatedSectionOwners,
77476
- projectionObject,
77477
- reserved: reserved2
77478
- }).wasm;
77479
- (0, import_node_fs77.writeFileSync)(options2.optimized, moveGuestDyldTable(map2, optimized, dyldSymbols));
77430
+ await lowerPromise;
77431
+ const finalized = finalizeGuestProjectionStorage({
77432
+ map: map2,
77433
+ linked,
77434
+ optimized: (0, import_node_fs77.readFileSync)(options2.optimized),
77435
+ owners,
77436
+ sectionOwners: splitInputs.appSections,
77437
+ projectionObject: appProjectionObject,
77438
+ reserved: storage,
77439
+ sdkSpans
77440
+ });
77441
+ (0, import_node_fs77.writeFileSync)(
77442
+ options2.optimized,
77443
+ moveGuestDyldTable(map2, finalized.wasm, splitInputs.dyldSymbols, bindingRows, [
77444
+ swiftAppModuleThunkSection2(finalized.wasm)
77445
+ ])
77446
+ );
77447
+ return binding;
77448
+ }
77449
+ } finally {
77450
+ if (result.finalLinkDone) await Promise.allSettled([result.finalLinkDone]);
77451
+ }
77480
77452
  }
77481
77453
  var import_node_child_process41, import_node_fs77, import_node_path75;
77482
77454
  var init_swift_guest_compile = __esm({
@@ -77486,7 +77458,6 @@ var init_swift_guest_compile = __esm({
77486
77458
  import_node_fs77 = require("node:fs");
77487
77459
  import_node_path75 = __toESM(require("node:path"), 1);
77488
77460
  init_swift_guest_archive();
77489
- init_swift_guest_dyld_functions();
77490
77461
  init_swift_guest_dyld_table();
77491
77462
  init_swift_guest_link();
77492
77463
  init_swift_guest_linked_spans();
@@ -77500,7 +77471,6 @@ var init_swift_guest_compile = __esm({
77500
77471
  init_swift_toolchain();
77501
77472
  init_swift_wasm_prune();
77502
77473
  init_swiftTargetContract();
77503
- init_wasm_optimize();
77504
77474
  }
77505
77475
  });
77506
77476
 
@@ -82450,20 +82420,17 @@ function readCompiledArtifact(directory2, hash) {
82450
82420
  const gzip2 = (0, import_node_fs84.readFileSync)(import_node_path84.default.join(directory2, "icu.gz"));
82451
82421
  if ((0, import_node_crypto51.createHash)("sha256").update(bytes).digest("hex") !== receipt.wasm || (0, import_node_crypto51.createHash)("sha256").update(gzip2).digest("hex") !== receipt.icu || bytes.length <= 8 || bytes.readUInt32LE(0) !== 1836278016 || bytes.readUInt32LE(4) !== 1)
82452
82422
  return null;
82453
- let sdk2;
82454
- if ("sdk" in receipt) {
82455
- const image = receipt.sdk;
82456
- if (!isRecord(image) || typeof image.key !== "string" || typeof image.sha256 !== "string" || typeof image.binding !== "string")
82457
- return null;
82458
- const binding = (0, import_node_fs84.readFileSync)(import_node_path84.default.join(directory2, "sdk-binding.bin"));
82459
- if ((0, import_node_crypto51.createHash)("sha256").update(binding).digest("hex") !== image.binding)
82460
- return null;
82461
- sdk2 = {
82462
- key: image.key,
82463
- sha256: image.sha256,
82464
- binding: { bytes: binding, sha256: image.binding }
82465
- };
82466
- }
82423
+ if (!("sdk" in receipt)) return null;
82424
+ const image = receipt.sdk;
82425
+ if (!isRecord(image) || typeof image.key !== "string" || typeof image.sha256 !== "string" || typeof image.binding !== "string")
82426
+ return null;
82427
+ const binding = (0, import_node_fs84.readFileSync)(import_node_path84.default.join(directory2, "sdk-binding.bin"));
82428
+ if ((0, import_node_crypto51.createHash)("sha256").update(binding).digest("hex") !== image.binding) return null;
82429
+ const sdk2 = {
82430
+ key: image.key,
82431
+ sha256: image.sha256,
82432
+ binding: { bytes: binding, sha256: image.binding }
82433
+ };
82467
82434
  return { hash, bytes, icu: { sha256: receipt.icu, gzip: gzip2 }, sdk: sdk2 };
82468
82435
  } catch (error) {
82469
82436
  if (error instanceof SyntaxError || error instanceof Error && "code" in error && error.code === "ENOENT")
@@ -83394,13 +83361,12 @@ async function compileSwiftProjectOnce(sources, options2) {
83394
83361
  sources: import_node_path84.default.join(root, "Sources", "App"),
83395
83362
  multi: compileTargets(input).length > 0
83396
83363
  };
83397
- const sdkModule = options2.sdkModule && !options2.linkOnly;
83398
- const sdkImage = sdkModule ? await (await Promise.resolve().then(() => (init_swift_sdk_image(), swift_sdk_image_exports))).buildSwiftSdkImage(
83364
+ const sdkImage = options2.linkOnly ? void 0 : await (await Promise.resolve().then(() => (init_swift_sdk_image(), swift_sdk_image_exports))).buildSwiftSdkImage(
83399
83365
  moduleRoot,
83400
83366
  !!guestGraph,
83401
83367
  distribution ? [] : linkedFrameworkTargets(moduleRoot, input).imports,
83402
83368
  { signal: options2.signal }
83403
- ) : void 0;
83369
+ );
83404
83370
  const inputHash = swiftCompileInputHash(input, options2.release);
83405
83371
  const moduleDigest = swiftModuleDigest(moduleRoot);
83406
83372
  const sourceHash = inputHash.copy().update(moduleDigest).digest("hex");
@@ -83431,79 +83397,10 @@ sdk module ${sdkImage.key}`).digest("hex") : sourceHash;
83431
83397
  return retain(root, previous);
83432
83398
  }
83433
83399
  }
83434
- if (!options2.intermediates && !sdkImage && process.platform === "darwin" && process.env.TM_SESSION && !windowAdmission() && process.env.CI !== "true" && moduleRoot === sourceSwiftCheckout() && !swiftDistributionAt(moduleRoot)) {
83435
- const requestRoot = (0, import_node_fs84.mkdtempSync)(`${root}.builder-request-`);
83436
- const output = import_node_path84.default.join(requestRoot, "output");
83437
- const request = import_node_path84.default.join(requestRoot, "request.json");
83438
- (0, import_node_fs84.writeFileSync)(
83439
- request,
83440
- JSON.stringify({
83441
- input,
83442
- hash,
83443
- release: options2.release,
83444
- timeoutMs: options2.timeoutMs,
83445
- // framework sources and compiler inputs own the shared object tree;
83446
- // unrelated app edits reuse it without retaining stale private ABI.
83447
- buildKey: frameworkKey
83448
- })
83449
- );
83450
- try {
83451
- const repo = import_node_path84.default.resolve(moduleRoot, "../..");
83452
- const timeout = swiftBuilderHopTimeoutMs(options2.timeoutMs);
83453
- report("requesting builder admission or cached result");
83454
- await runCompiler(
83455
- "bun",
83456
- [
83457
- import_node_path84.default.join(repo, "scripts/build/swift-project.ts"),
83458
- "--request",
83459
- request,
83460
- "--output",
83461
- output
83462
- ],
83463
- {
83464
- cwd: repo,
83465
- timeout,
83466
- maxBuffer: 64 * 1024 * 1024,
83467
- signal: options2.signal
83468
- },
83469
- true
83470
- ).catch((error) => {
83471
- if (options2.signal?.aborted) throw error;
83472
- const output2 = outputOf(error);
83473
- if (!(error instanceof Error) || Reflect.get(error, "exitCode") !== 124)
83474
- throw new Error(output2, { cause: error });
83475
- const prefix = `[swift-project ${hash.slice(0, 16)}] `;
83476
- const lines = output2.split("\n");
83477
- const stage = lines.findLast((line) => line.startsWith(prefix))?.slice(prefix.length);
83478
- const cap = lines.find(
83479
- (line) => line.startsWith("[remote] outer deadline leaves ")
83480
- );
83481
- const deadline = cap ? `
83482
- ${cap}` : "";
83483
- throw new Error(
83484
- `Swift builder deadline expired during ${stage ?? "builder preparation"} (requested ${Math.ceil(timeout / 1e3)}s for the builder hop).${deadline}`,
83485
- { cause: error }
83486
- );
83487
- });
83488
- const artifact = readCompiledArtifact(output, hash);
83489
- if (!artifact) {
83490
- throw new Error(
83491
- "swift-compile: builder artifact source, digest or wasm header is invalid"
83492
- );
83493
- }
83494
- saveCompiledArtifact(root, artifact);
83495
- saveSharedArtifact(sharedRoot, artifact);
83496
- report("builder artifact verified");
83497
- return retain(root, artifact);
83498
- } finally {
83499
- (0, import_node_fs84.rmSync)(requestRoot, { recursive: true, force: true });
83500
- }
83501
- }
83502
83400
  const baseRoot = root;
83503
83401
  const canPoolBuildRoot = !options2.intermediates && !options2.project && !options2.linkOnly && import_node_path84.default.basename(import_node_path84.default.dirname(baseRoot)) === "swift-builds";
83504
83402
  const compatShapeParts = canPoolBuildRoot ? [
83505
83403
  frameworkKey,
83506
- Boolean(sdkImage),
83507
83404
  compileTargets(input).map((target) => target.name).sort(),
83508
83405
  input.oneModule === true,
83509
83406
  input.optimize === true,
@@ -84141,7 +84038,8 @@ ${compatShape}` : "";
84141
84038
  }
84142
84039
  const output = options2.project ? projectOutputFile(root2, linked, options2.project) : linked;
84143
84040
  const optimized = `${output}.optimized`;
84144
- if (sdkImage && options2.project) (0, import_node_fs84.rmSync)(optimized, { force: true });
84041
+ if (!sdkImage) throw new Error("swift-compile: missing shared SDK image");
84042
+ if (options2.project) (0, import_node_fs84.rmSync)(optimized, { force: true });
84145
84043
  let sdkAsset;
84146
84044
  stage("linking the app image");
84147
84045
  if (guestGraph) {
@@ -84170,9 +84068,8 @@ ${compatShape}` : "";
84170
84068
  jobs: swiftBuildJobs(),
84171
84069
  onStage: stage
84172
84070
  });
84173
- if (sdkImage && binding)
84174
- sdkAsset = { key: sdkImage.key, sha256: sdkImage.sha256, binding };
84175
- } else if (sdkImage) {
84071
+ sdkAsset = { key: sdkImage.key, sha256: sdkImage.sha256, binding };
84072
+ } else {
84176
84073
  const { buildSwiftAppModule: buildSwiftAppModule2 } = await Promise.resolve().then(() => (init_swift_sdk_app_module(), swift_sdk_app_module_exports));
84177
84074
  const binding = await buildSwiftAppModule2({
84178
84075
  buildRoot: root2,
@@ -84190,19 +84087,7 @@ ${compatShape}` : "";
84190
84087
  }
84191
84088
  });
84192
84089
  sdkAsset = { key: sdkImage.key, sha256: sdkImage.sha256, binding };
84193
- } else {
84194
- const bytes = (0, import_node_fs84.readFileSync)(output);
84195
- const ordered = orderObjCConstructors(bytes);
84196
- if (ordered !== bytes) (0, import_node_fs84.writeFileSync)(output, ordered);
84197
- stage("lowering the app image");
84198
- await lowerWasm(output, optimized, { optimize: input.optimize === true });
84199
84090
  }
84200
- if (!sdkImage)
84201
- await runCompiler(
84202
- import_node_path84.default.join(options2.toolchainBin, "llvm-objcopy"),
84203
- ["--remove-section=.swift1_autolink_entries", optimized],
84204
- buildOptions
84205
- );
84206
84091
  const artifact = {
84207
84092
  hash,
84208
84093
  bytes: (0, import_node_fs84.readFileSync)(optimized),
@@ -84262,7 +84147,6 @@ var init_swift_compile = __esm({
84262
84147
  init_swift_project_user();
84263
84148
  init_swift_reproducible();
84264
84149
  init_swift_root_lock();
84265
- init_swift_sdk_image_wasm();
84266
84150
  init_swift_sdk_surface();
84267
84151
  init_swift_shared_sdk();
84268
84152
  init_swift_source_closure();
@@ -84457,7 +84341,7 @@ ${wasmThreadLinkFlags.map((flag) => ` "-Xlinker", ${JSON.stringify(flag
84457
84341
  REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
84458
84342
  MULTI_MANIFEST_VERSION = 76;
84459
84343
  SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
84460
- compilerSourceDigest = true ? "229f789297c5cb8e33a042e23ad3c1df20450a712a02dd0b50d2e78bc8ed3de6" : swiftCompilerSourceDigest2(__sootsim_import_meta_dirname);
84344
+ compilerSourceDigest = true ? "dcd0189f8bf1a7fc415f2c92825f8b3bbc2089ae9697ffcb50cc9a7e65e99990" : swiftCompilerSourceDigest2(__sootsim_import_meta_dirname);
84461
84345
  nativeCxxCompilerFlags = ["-fno-cxx-modules"];
84462
84346
  MODULE_MAP_RESPONSE_FILE_RUN = 16;
84463
84347
  cFlagArray = (flags) => JSON.stringify(withoutGlogModuleMap(flags));
@@ -106106,6 +105990,23 @@ function readCompiledMetadata(label, value, readPackage, names) {
106106
105990
  );
106107
105991
  return { platform: "ios", packages, url, hash, icuUrl: icuUrl2, bundleFiles };
106108
105992
  }
105993
+ function readSdkEntryMetadata(label, value) {
105994
+ const sdkUrl = Reflect.get(value, "sdkUrl");
105995
+ const sdkBindingUrl = Reflect.get(value, "sdkBindingUrl");
105996
+ if (sdkUrl === void 0 && sdkBindingUrl === void 0) return {};
105997
+ if (typeof sdkUrl === "string" && sdkUrl && typeof sdkBindingUrl === "string" && sdkBindingUrl)
105998
+ return { sdkUrl, sdkBindingUrl };
105999
+ throw new Error(`invalid ${label} SDK binding metadata`);
106000
+ }
106001
+ function readNitroMetadata(value) {
106002
+ const metadata = readCompiledMetadata(
106003
+ "Nitro",
106004
+ value,
106005
+ readNitroPackage,
106006
+ (entry) => entry.hybridObjects
106007
+ );
106008
+ return metadata && { ...metadata, ...readSdkEntryMetadata("Nitro", Object(value)) };
106009
+ }
106109
106010
  function readTurboMetadata(value) {
106110
106011
  if (value === null || value === void 0) return null;
106111
106012
  if (typeof value !== "object" || Array.isArray(value) || Reflect.get(value, "platform") !== NITRO_GUEST_PLATFORM)
@@ -106139,11 +106040,13 @@ function readTurboMetadata(value) {
106139
106040
  readCompiledPackage,
106140
106041
  () => []
106141
106042
  );
106142
- const sdk2 = sdkUrl === void 0 && sdkBindingUrl === void 0 ? {} : typeof sdkUrl === "string" && sdkUrl && typeof sdkBindingUrl === "string" && sdkBindingUrl ? { sdkUrl, sdkBindingUrl } : null;
106143
- if (sdk2 === null) throw new Error("invalid TurboModule SDK binding metadata");
106144
- return metadata && { ...metadata, ...sdk2, ...unavailable2 ? { unavailable: unavailable2 } : {} };
106043
+ return metadata && {
106044
+ ...metadata,
106045
+ ...readSdkEntryMetadata("TurboModule", value),
106046
+ ...unavailable2 ? { unavailable: unavailable2 } : {}
106047
+ };
106145
106048
  }
106146
- var NITRO_GUEST_PLATFORM, readNitroMetadata;
106049
+ var NITRO_GUEST_PLATFORM;
106147
106050
  var init_nitroContract = __esm({
106148
106051
  "src/nitroContract.ts"() {
106149
106052
  "use strict";
@@ -106151,7 +106054,6 @@ var init_nitroContract = __esm({
106151
106054
  init_is_record();
106152
106055
  init_swiftContract();
106153
106056
  NITRO_GUEST_PLATFORM = "ios";
106154
- readNitroMetadata = (value) => readCompiledMetadata("Nitro", value, readNitroPackage, (entry) => entry.hybridObjects);
106155
106057
  }
106156
106058
  });
106157
106059
 
@@ -126285,7 +126187,6 @@ function linkedModuleRoots(packagePath) {
126285
126187
  return [...roots].sort();
126286
126188
  }
126287
126189
  function updateSwiftConfigStamp(hash, packagePath) {
126288
- if (projects().get(packagePath)?.standalone) hash.update("standalone");
126289
126190
  const config = xcodeProjects().get(packagePath);
126290
126191
  hash.update(JSON.stringify(config?.behavior ?? {}));
126291
126192
  const gates = config?.swiftWasm64?.platformGates;
@@ -126362,9 +126263,9 @@ function moduleStamp(packagePath, moduleRootOverride, hosted) {
126362
126263
  }
126363
126264
  return hash.digest("hex");
126364
126265
  }
126365
- function otherInputs(input, standalone) {
126266
+ function otherInputs(input) {
126366
126267
  const { files: _files, ...rest } = input;
126367
- return (0, import_node_crypto82.createHash)("sha256").update(JSON.stringify({ ...rest, standalone })).digest("hex");
126268
+ return (0, import_node_crypto82.createHash)("sha256").update(JSON.stringify(rest)).digest("hex");
126368
126269
  }
126369
126270
  function entryRootId(packagePath, file) {
126370
126271
  const relative7 = import_node_path137.default.relative(packagePath, file).split(import_node_path137.default.sep).join(import_node_path137.default.posix.sep);
@@ -126575,7 +126476,6 @@ async function packageSnapshot(project2, entry, moduleRoot) {
126575
126476
  return {
126576
126477
  files: files2,
126577
126478
  oneModule: project2.oneModule,
126578
- standalone: project2.standalone === true,
126579
126479
  binaryModules: {
126580
126480
  ...project2.binaryModules,
126581
126481
  ...Object.fromEntries(
@@ -126787,7 +126687,7 @@ async function compile(packagePath, stamp, moduleRootOverride, hosted, snapshot,
126787
126687
  const input = snapshotCompileInput(snapshot);
126788
126688
  const compiled = {
126789
126689
  files: input.files,
126790
- inputs: otherInputs(input, snapshot.standalone),
126690
+ inputs: otherInputs(input),
126791
126691
  module: moduleStamp(packagePath, moduleRootOverride, false)
126792
126692
  };
126793
126693
  const parsed2 = compileTargets(input);
@@ -126835,8 +126735,6 @@ async function compile(packagePath, stamp, moduleRootOverride, hosted, snapshot,
126835
126735
  buildRoot: swiftBuildRoot(packagePath, moduleRoot),
126836
126736
  moduleRoot,
126837
126737
  ...toolchain,
126838
- // the preview loads an app module beside the shared sdk image
126839
- sdkModule: !snapshot.standalone && (input.sourceLinkGraph !== void 0 || swiftApplicationEntry(input.entry, input.files[input.entry] ?? "")),
126840
126738
  signal
126841
126739
  }).catch((error) => {
126842
126740
  const report = error instanceof Error ? swiftApiGapReport(error.message) : null;
@@ -126985,8 +126883,7 @@ async function compileRemote(packagePath, snapshot, hosted, ownerSignal) {
126985
126883
  resources: snapshot.bundleFiles.files,
126986
126884
  images: snapshot.resources.images,
126987
126885
  entry: snapshot.entry,
126988
- packageId: descriptor?.packageId ?? swiftPackageId(packagePath),
126989
- sdkModule: !snapshot.standalone
126886
+ packageId: descriptor?.packageId ?? swiftPackageId(packagePath)
126990
126887
  },
126991
126888
  origin,
126992
126889
  signal,
@@ -127078,7 +126975,7 @@ function scopedArtifact(project2, entry, moduleRoot, signal) {
127078
126975
  const compiled = project2.artifact?.compiled;
127079
126976
  if (project2.artifact && compiled && compiled.module === moduleStamp(project2.packagePath, moduleRoot, false)) {
127080
126977
  const input = snapshotCompileInput(snapshot);
127081
- const values = otherInputs(input, snapshot.standalone) === compiled.inputs ? designTimeValues(compiled.files, input.files) : null;
126978
+ const values = otherInputs(input) === compiled.inputs ? designTimeValues(compiled.files, input.files) : null;
127082
126979
  if (values) return { ...project2.artifact, stamp, designTimeValues: values };
127083
126980
  }
127084
126981
  return compile(
@@ -127216,7 +127113,10 @@ async function swiftPackageMetadata(packagePath, packageName2, moduleRoot, origi
127216
127113
  defaultView: mains.length === 1
127217
127114
  } : void 0
127218
127115
  });
127219
- if (mains.length === 0) return metadata(origin, artifact);
127116
+ if (mains.length === 0) {
127117
+ await prepareSwiftSdkEntryAssets(origin, artifact);
127118
+ return metadata(origin, artifact);
127119
+ }
127220
127120
  const publishedSdk = artifact.sdk && publishedSwiftSdk(artifact.sdk.sha256);
127221
127121
  const sdkDigest = artifact.sdk && !publishedSdk ? await swiftSdkStartup(
127222
127122
  artifact.sdk,
@@ -134074,7 +133974,6 @@ async function compileTurboModule(options2) {
134074
133974
  );
134075
133975
  const project2 = projectFor(packagePath);
134076
133976
  project2.oneModule = false;
134077
- project2.standalone = true;
134078
133977
  project2.libraries = input.libraries;
134079
133978
  project2.binaryModules = input.binaryModules;
134080
133979
  project2.optimize = input.optimize;
@@ -134430,7 +134329,7 @@ var init_react_native_core = __esm({
134430
134329
  init_swift_distribution();
134431
134330
  init_swift_package();
134432
134331
  init_swiftContract();
134433
- recipe = true ? "db2c81d6628055a561c22667b098e4686f9d8924ffb229c4c7d9e15a25182502" : reactNativeCoreDigest2(__sootsim_import_meta_dirname);
134332
+ recipe = true ? "d4161f11b10bfff3f21f57ca2352bf31c30f364e15fd7e1c385311c10033fa89" : reactNativeCoreDigest2(__sootsim_import_meta_dirname);
134434
134333
  strings4 = (value) => isRecord(value) && Object.values(value).every((item) => typeof item === "string");
134435
134334
  building = /* @__PURE__ */ new Map();
134436
134335
  }
@@ -137199,6 +137098,7 @@ var init_native_package_slice = __esm({
137199
137098
  init_native_prebuilt();
137200
137099
  init_swift_compile();
137201
137100
  init_swift_distribution();
137101
+ init_swift_host();
137202
137102
  init_swift_icu();
137203
137103
  init_swift_native_pin();
137204
137104
  init_swift_package();
@@ -150805,7 +150705,12 @@ function collectNitroCompileInput(collection, adapter, dependencies, iosDeployme
150805
150705
  ].join("\n") : [
150806
150706
  ...swift ? ["@_spi(Peach) import PeachFoundation"] : [],
150807
150707
  ...imports2.map((name3) => `import ${name3}`),
150808
- ...swift ? ["PeachHostDriver.installExecutor()"] : [],
150708
+ ...swift ? [
150709
+ '@_expose(wasm, "peach_nitro_swift_host")',
150710
+ '@_cdecl("peach_nitro_swift_host")',
150711
+ "public func _peachNitroSwiftHost() {}",
150712
+ "PeachHostDriver.installExecutor()"
150713
+ ] : [],
150809
150714
  ...register,
150810
150715
  ""
150811
150716
  ].join("\n");
@@ -151376,7 +151281,6 @@ async function compileNitroModule(options2) {
151376
151281
  );
151377
151282
  const project2 = projectFor(packagePath);
151378
151283
  project2.oneModule = false;
151379
- project2.standalone = true;
151380
151284
  project2.libraries = input.libraries;
151381
151285
  project2.binaryModules = input.binaryModules;
151382
151286
  project2.optimize = input.optimize;
@@ -151625,7 +151529,7 @@ var init_nitro_superset = __esm({
151625
151529
  init_nitroContract();
151626
151530
  init_swift_standin_digest();
151627
151531
  NITRO_SUPERSET_ENTRY_NAME = "superset";
151628
- NITRO_COMPILER_DIGEST = true ? "744976c15724422db8f3bc8d1fdfdcf68c3f91b185210a50951930d2ea18c38e" : nitroCompilerSourceDigest(__sootsim_import_meta_dirname, STANDIN_SOURCE_DIGEST2);
151532
+ NITRO_COMPILER_DIGEST = true ? "9303a53709842e0a9107912bfca87f4a1731cfc09b9d252fac03c156eabf3836" : nitroCompilerSourceDigest(__sootsim_import_meta_dirname, STANDIN_SOURCE_DIGEST2);
151629
151533
  nitroSupersetLock = parseLock(nitro_superset_lock_default);
151630
151534
  nitroSupersetKey = (inputs2) => nativeEntryKey({ ...inputs2, compiler: NITRO_COMPILER_DIGEST });
151631
151535
  published3 = /* @__PURE__ */ new Map();
@@ -151696,6 +151600,7 @@ async function compileNitroApp(appRoot, origin, configure, moduleRoot, shared =
151696
151600
  views
151697
151601
  })),
151698
151602
  url: `${origin}/__peach/swift/${artifact.hash}.wasm`,
151603
+ ...await prepareSwiftSdkEntryAssets(origin, artifact),
151699
151604
  hash: artifact.hash,
151700
151605
  icuUrl: icuUrl(origin, artifact),
151701
151606
  bundleFiles: artifact.package.bundleFiles.files
@@ -152016,12 +151921,12 @@ let package = Package(name: "OneSDKGuest", targets: [
152016
151921
  );
152017
151922
  const project2 = projectFor(packagePath);
152018
151923
  project2.oneModule = false;
152019
- project2.standalone = true;
152020
151924
  project2.optimize = optimize;
152021
151925
  project2.unoptimized = !optimize;
152022
151926
  const artifact = await artifactFor(project2, "Sources/App/App.swift", moduleRoot);
152023
151927
  const metadata = {
152024
151928
  url: `${origin}/__peach/swift/${artifact.hash}.wasm`,
151929
+ ...await prepareSwiftSdkEntryAssets(origin, artifact),
152025
151930
  hash: artifact.hash,
152026
151931
  icuUrl: icuUrl(origin, artifact),
152027
151932
  rootId: `one-sdk-${artifact.hash.slice(0, 16)}`,
@@ -152139,7 +152044,7 @@ async function compileTurboApp(appRoot, origin, moduleRoot, iosTarget, prepareRe
152139
152044
  url: `${origin}/__peach/swift/${artifact.hash}.wasm`,
152140
152045
  hash: artifact.hash,
152141
152046
  icuUrl: icuUrl(origin, artifact),
152142
- ...swiftSdkEntryAssets(origin, artifact),
152047
+ ...await prepareSwiftSdkEntryAssets(origin, artifact),
152143
152048
  bundleFiles: artifact.package.bundleFiles.files,
152144
152049
  ...unavailable2.length > 0 ? { unavailable: unavailable2 } : {}
152145
152050
  }