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;
@@ -1297,7 +1297,7 @@ var init_src = __esm({
1297
1297
  var runtime_companion_default;
1298
1298
  var init_runtime_companion = __esm({
1299
1299
  "runtime-companion.json"() {
1300
- runtime_companion_default = { abi: 1, sha256: "7a60ab959af99bebbcef81dda2fe962c6eeb694ec491218da2b3b923a7e8e7a9", file: "node/cli-7a60ab959af99bebbcef81dda2fe962c6eeb694ec491218da2b3b923a7e8e7a9.cjs" };
1300
+ runtime_companion_default = { abi: 1, sha256: "e17fe1b370cc7ce9aa701cc8f0b17e1c72e6690873d4413656defc8b1504a2e8", file: "node/cli-e17fe1b370cc7ce9aa701cc8f0b17e1c72e6690873d4413656defc8b1504a2e8.cjs" };
1301
1301
  }
1302
1302
  });
1303
1303
 
@@ -5610,6 +5610,23 @@ function readCompiledMetadata(label, value, readPackage, names) {
5610
5610
  );
5611
5611
  return { platform: "ios", packages, url, hash, icuUrl: icuUrl2, bundleFiles };
5612
5612
  }
5613
+ function readSdkEntryMetadata(label, value) {
5614
+ const sdkUrl = Reflect.get(value, "sdkUrl");
5615
+ const sdkBindingUrl = Reflect.get(value, "sdkBindingUrl");
5616
+ if (sdkUrl === void 0 && sdkBindingUrl === void 0) return {};
5617
+ if (typeof sdkUrl === "string" && sdkUrl && typeof sdkBindingUrl === "string" && sdkBindingUrl)
5618
+ return { sdkUrl, sdkBindingUrl };
5619
+ throw new Error(`invalid ${label} SDK binding metadata`);
5620
+ }
5621
+ function readNitroMetadata(value) {
5622
+ const metadata = readCompiledMetadata(
5623
+ "Nitro",
5624
+ value,
5625
+ readNitroPackage,
5626
+ (entry) => entry.hybridObjects
5627
+ );
5628
+ return metadata && { ...metadata, ...readSdkEntryMetadata("Nitro", Object(value)) };
5629
+ }
5613
5630
  function readTurboMetadata(value) {
5614
5631
  if (value === null || value === void 0) return null;
5615
5632
  if (typeof value !== "object" || Array.isArray(value) || Reflect.get(value, "platform") !== NITRO_GUEST_PLATFORM)
@@ -5643,9 +5660,11 @@ function readTurboMetadata(value) {
5643
5660
  readCompiledPackage,
5644
5661
  () => []
5645
5662
  );
5646
- const sdk2 = sdkUrl === void 0 && sdkBindingUrl === void 0 ? {} : typeof sdkUrl === "string" && sdkUrl && typeof sdkBindingUrl === "string" && sdkBindingUrl ? { sdkUrl, sdkBindingUrl } : null;
5647
- if (sdk2 === null) throw new Error("invalid TurboModule SDK binding metadata");
5648
- return metadata && { ...metadata, ...sdk2, ...unavailable2 ? { unavailable: unavailable2 } : {} };
5663
+ return metadata && {
5664
+ ...metadata,
5665
+ ...readSdkEntryMetadata("TurboModule", value),
5666
+ ...unavailable2 ? { unavailable: unavailable2 } : {}
5667
+ };
5649
5668
  }
5650
5669
  function insertNitroFooter(source, metadata) {
5651
5670
  readNitroMetadata(metadata);
@@ -5655,7 +5674,7 @@ function insertTurboFooter(source, metadata) {
5655
5674
  readTurboMetadata(metadata);
5656
5675
  return insertBundleMetadataFooter(source, "turbo", metadata);
5657
5676
  }
5658
- var NITRO_GUEST_PLATFORM, readNitroMetadata;
5677
+ var NITRO_GUEST_PLATFORM;
5659
5678
  var init_nitroContract = __esm({
5660
5679
  "src/nitroContract.ts"() {
5661
5680
  "use strict";
@@ -5663,7 +5682,6 @@ var init_nitroContract = __esm({
5663
5682
  init_is_record();
5664
5683
  init_swiftContract();
5665
5684
  NITRO_GUEST_PLATFORM = "ios";
5666
- readNitroMetadata = (value) => readCompiledMetadata("Nitro", value, readNitroPackage, (entry) => entry.hybridObjects);
5667
5685
  }
5668
5686
  });
5669
5687
 
@@ -10018,9 +10036,6 @@ var init_retired_cache_directory = __esm({
10018
10036
  });
10019
10037
 
10020
10038
  // src/swift-compile-budget.ts
10021
- function swiftBuilderHopTimeoutMs(compileTimeoutMs) {
10022
- return SWIFT_LOCK_WAIT_TIMEOUT_MS + (compileTimeoutMs ?? SWIFT_COMPILE_TIMEOUT_MS) + SWIFT_TRANSPORT_MARGIN_MS;
10023
- }
10024
10039
  async function withSwiftCompileBudget(compileTimeoutMs, signal, work) {
10025
10040
  const deadline = new AbortController();
10026
10041
  const combined = signal ? AbortSignal.any([signal, deadline.signal]) : deadline.signal;
@@ -10060,13 +10075,12 @@ async function withSwiftCompileBudget(compileTimeoutMs, signal, work) {
10060
10075
  clearTimeout(timer);
10061
10076
  }
10062
10077
  }
10063
- var SWIFT_COMPILE_TIMEOUT_MS, SWIFT_LOCK_WAIT_TIMEOUT_MS, SWIFT_TRANSPORT_MARGIN_MS;
10078
+ var SWIFT_COMPILE_TIMEOUT_MS, SWIFT_LOCK_WAIT_TIMEOUT_MS;
10064
10079
  var init_swift_compile_budget = __esm({
10065
10080
  "src/swift-compile-budget.ts"() {
10066
10081
  "use strict";
10067
10082
  SWIFT_COMPILE_TIMEOUT_MS = 18e5;
10068
10083
  SWIFT_LOCK_WAIT_TIMEOUT_MS = 36e5;
10069
- SWIFT_TRANSPORT_MARGIN_MS = 3e5;
10070
10084
  }
10071
10085
  });
10072
10086
 
@@ -10091,7 +10105,7 @@ var init_swift_objc_sdk_tree = __esm({
10091
10105
 
10092
10106
  // src/swift-compiler-digest.ts
10093
10107
  function swiftArchiveCompilerDigestValue() {
10094
- return true ? "7ec504e1047ea0f31b14e25b8958c42fd1e55cb9c121db3f05e4dead6ef226eb" : swiftCompilerSourceDigest2(__sootsim_import_meta_dirname, "archive");
10108
+ return true ? "c304a2da11e2e676fe221d87209a1136a730fd7ea4bf5d094065fd377480ecef" : swiftCompilerSourceDigest2(__sootsim_import_meta_dirname, "archive");
10095
10109
  }
10096
10110
  var import_node_crypto9, import_node_fs20, import_node_path16, SWIFT_DIGEST_SOURCES, LINKED_IMAGE_SOURCES, SWIFT_ARCHIVE_DIGEST_SOURCES;
10097
10111
  var init_swift_compiler_digest = __esm({
@@ -20319,281 +20333,6 @@ var init_swift_guest_archive = __esm({
20319
20333
  }
20320
20334
  });
20321
20335
 
20322
- // ../peach-kit/src/nativeWasmContract.ts
20323
- 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;
20324
- var init_nativeWasmContract = __esm({
20325
- "../peach-kit/src/nativeWasmContract.ts"() {
20326
- "use strict";
20327
- NATIVE_IMAGE_SECTION = "peach.native-image-v1";
20328
- NATIVE_TABLE_ABI = "peach-native-table-v1";
20329
- NATIVE_TABLE_IMPORT_MODULE = "peach_thread";
20330
- NATIVE_DYLD_FUNCTION_IMPORT = "dyld_function";
20331
- NATIVE_DYLD_PLACE_EXPORT = "__peach_dyld_place";
20332
- NATIVE_LAZY_IMPORT_MODULE = "peach_lazy";
20333
- NATIVE_SDK_IMPORT_MODULE = "peach_sdk";
20334
- NATIVE_SDK_THUNK_SECTION = "peach.sdk-thunks";
20335
- NATIVE_LAZY_SLOT_IMPORT = "load_slot";
20336
- NATIVE_LAZY_SECTION = "peach.lazy-code-v2";
20337
- NATIVE_LAZY_DIGEST_BYTES = 32;
20338
- NATIVE_LAZY_PART_BYTES = NATIVE_LAZY_DIGEST_BYTES + 4;
20339
- NATIVE_TABLE_RESERVE_SLOTS = 4096;
20340
- }
20341
- });
20342
-
20343
- // src/swift-guest-dyld-functions.ts
20344
- function skipValueType(r) {
20345
- const type = r.byte();
20346
- if (type === 99 || type === 100) r.s();
20347
- }
20348
- function readImports2(bytes, sections) {
20349
- let functions = 0;
20350
- let table64;
20351
- const imports2 = sections.find((s) => s.id === 2);
20352
- if (imports2) {
20353
- const r = wasmReader(bytes, imports2.start);
20354
- for (let n = r.u(); n > 0; n--) {
20355
- r.name();
20356
- r.name();
20357
- const kind = r.byte();
20358
- if (kind === 0) {
20359
- functions++;
20360
- r.u();
20361
- } else if (kind === 1 || kind === 2) {
20362
- if (kind === 1) skipValueType(r);
20363
- const flags = r.u();
20364
- r.u();
20365
- if (flags & 1) r.u();
20366
- if (kind === 1) table64 ??= (flags & 4) !== 0;
20367
- } else if (kind === 3) {
20368
- skipValueType(r);
20369
- r.byte();
20370
- } else if (kind === 4) {
20371
- r.byte();
20372
- r.u();
20373
- } else throw new Error(`unsupported wasm import kind ${kind}`);
20374
- }
20375
- }
20376
- const tables = sections.find((s) => s.id === 4);
20377
- if (table64 === void 0 && tables) {
20378
- const r = wasmReader(bytes, tables.start);
20379
- if (r.u()) {
20380
- skipValueType(r);
20381
- table64 = (r.u() & 4) !== 0;
20382
- }
20383
- }
20384
- return { functions, table64 };
20385
- }
20386
- function vectorSection(id, count, parts) {
20387
- const body = Buffer.concat([Buffer.from(uleb2(count)), ...parts]);
20388
- return Buffer.concat([Buffer.from([id, ...uleb2(body.length)]), body]);
20389
- }
20390
- function rewriteSections(bytes, sections, changes) {
20391
- const out = [bytes.subarray(0, 8)];
20392
- const pending2 = new Map(changes);
20393
- const flushBefore = (id) => {
20394
- for (const [missing2, section2] of pending2) {
20395
- if (SECTION_ORDER.indexOf(missing2) >= SECTION_ORDER.indexOf(id)) continue;
20396
- if (section2) out.push(section2);
20397
- pending2.delete(missing2);
20398
- }
20399
- };
20400
- for (const s of sections) {
20401
- if (s.id !== 0) flushBefore(s.id);
20402
- if (!pending2.has(s.id)) {
20403
- out.push(bytes.subarray(s.offset, s.end));
20404
- continue;
20405
- }
20406
- const section2 = pending2.get(s.id);
20407
- pending2.delete(s.id);
20408
- if (section2) out.push(section2);
20409
- }
20410
- for (const section2 of pending2.values()) if (section2) out.push(section2);
20411
- return Buffer.concat(out);
20412
- }
20413
- function entries(bytes, section2, entry) {
20414
- if (!section2) return [];
20415
- const r = wasmReader(bytes, section2.start);
20416
- const out = [];
20417
- for (let n = r.u(); n > 0; n--) {
20418
- const begin = r.at;
20419
- entry(r);
20420
- out.push(bytes.subarray(begin, r.at));
20421
- }
20422
- if (r.at !== section2.end) throw new Error(`invalid wasm section ${section2.id}`);
20423
- return out;
20424
- }
20425
- function appendLazyPlacement(bytes, functions, table) {
20426
- const sections = wasmSections(bytes);
20427
- const section2 = (id) => sections.find((s) => s.id === id);
20428
- const imports2 = readImports2(bytes, sections);
20429
- const changes = /* @__PURE__ */ new Map();
20430
- let table64 = imports2.table64;
20431
- if (table64 === void 0) {
20432
- if (!table) throw new Error("native image has no function table");
20433
- table64 = table.table64;
20434
- const found = section2(2);
20435
- const header = found && wasmReader(bytes, found.start);
20436
- const count = header ? header.u() : 0;
20437
- const module2 = Buffer.from("primary");
20438
- const name4 = Buffer.from(table.name);
20439
- changes.set(
20440
- 2,
20441
- vectorSection(2, count + 1, [
20442
- found && header ? bytes.subarray(header.at, found.end) : new Uint8Array(),
20443
- Buffer.from([
20444
- ...uleb2(module2.length),
20445
- ...module2,
20446
- ...uleb2(name4.length),
20447
- ...name4,
20448
- 1,
20449
- 112,
20450
- table64 ? 4 : 0,
20451
- 0
20452
- ])
20453
- ])
20454
- );
20455
- }
20456
- const types2 = entries(bytes, section2(1), (r) => {
20457
- if (r.byte() !== 96) throw new Error("native image has a non-function type");
20458
- for (let side = 0; side < 2; side++) for (let n = r.u(); n > 0; n--) skipValueType(r);
20459
- });
20460
- const declared = entries(bytes, section2(3), (r) => r.u());
20461
- const bodies = entries(bytes, section2(10), (r) => r.skip(r.u()));
20462
- const exports2 = entries(bytes, section2(7), readExport);
20463
- const elements = entries(bytes, section2(9), skipElementSegment);
20464
- const placementIndex = lastTableElement(elements) + 1;
20465
- elements.splice(
20466
- placementIndex,
20467
- 0,
20468
- Buffer.from([1, 0, ...uleb2(functions.length), ...functions.flatMap(uleb2)])
20469
- );
20470
- const place2 = imports2.functions + declared.length;
20471
- const instructions = [
20472
- 0,
20473
- 32,
20474
- 1,
20475
- ...table64 ? [173] : [],
20476
- 32,
20477
- 0,
20478
- 65,
20479
- 1,
20480
- 252,
20481
- 12,
20482
- ...uleb2(placementIndex),
20483
- 0,
20484
- 11
20485
- ];
20486
- const name3 = Buffer.from(NATIVE_DYLD_PLACE_EXPORT);
20487
- return rewriteSections(
20488
- bytes,
20489
- sections,
20490
- new Map([
20491
- ...changes,
20492
- [
20493
- 1,
20494
- vectorSection(1, types2.length + 1, [
20495
- ...types2,
20496
- Buffer.from([96, 2, 127, 127, 0])
20497
- ])
20498
- ],
20499
- [
20500
- 3,
20501
- vectorSection(3, declared.length + 1, [
20502
- ...declared,
20503
- Buffer.from(uleb2(types2.length))
20504
- ])
20505
- ],
20506
- [
20507
- 7,
20508
- vectorSection(7, exports2.length + 1, [
20509
- ...exports2,
20510
- Buffer.from([...uleb2(name3.length), ...name3, 0, ...uleb2(place2)])
20511
- ])
20512
- ],
20513
- [9, vectorSection(9, elements.length, elements)],
20514
- [
20515
- 10,
20516
- vectorSection(10, bodies.length + 1, [
20517
- ...bodies,
20518
- Buffer.from([...uleb2(instructions.length), ...instructions])
20519
- ])
20520
- ]
20521
- ])
20522
- );
20523
- }
20524
- function skipConstant(r) {
20525
- for (let op = r.byte(); op !== 11; op = r.byte()) {
20526
- if (op === 65 || op === 66) r.s();
20527
- else if (op === 35 || op === 210) r.u();
20528
- else if (op === 208) r.s();
20529
- else if (![106, 107, 108, 124, 125, 126].includes(op))
20530
- throw new Error(`unsupported constant expression op ${op}`);
20531
- }
20532
- }
20533
- function skipElementSegment(r) {
20534
- const flags = r.u();
20535
- if (flags > 7) throw new Error(`unsupported element segment flags ${flags}`);
20536
- if ((flags & 3) === 2) r.u();
20537
- if (!(flags & 1)) skipConstant(r);
20538
- if (flags & 3) skipValueType(r);
20539
- for (let count = r.u(); count > 0; count--)
20540
- if (flags & 4) skipConstant(r);
20541
- else r.u();
20542
- }
20543
- function placeGuestLazyFunctions(bytes, lazy) {
20544
- const sections = wasmSections(bytes);
20545
- const lazyIndex = new Map(lazy.map((name3, index) => [name3, index]));
20546
- const functions = new Array(lazy.length);
20547
- let found = 0;
20548
- const kept = entries(
20549
- bytes,
20550
- sections.find((s) => s.id === 7),
20551
- readExport
20552
- ).filter((entry) => {
20553
- const r = wasmReader(entry, 0);
20554
- const position = lazyIndex.get(r.name());
20555
- const kind = r.byte();
20556
- if (kind !== 0 || position === void 0) return true;
20557
- functions[position] = r.u();
20558
- found++;
20559
- return false;
20560
- });
20561
- if (found !== lazy.length)
20562
- throw new Error("guest link lost a lazy dlsym function export");
20563
- return appendLazyPlacement(
20564
- rewriteSections(bytes, sections, /* @__PURE__ */ new Map([[7, vectorSection(7, kept.length, kept)]])),
20565
- functions
20566
- );
20567
- }
20568
- function guestLazyExports(lazy) {
20569
- return lazy.map((name3) => JSON.stringify(`--export=${name3}`)).join("\n");
20570
- }
20571
- var uleb2, SECTION_ORDER, readExport, lastTableElement;
20572
- var init_swift_guest_dyld_functions = __esm({
20573
- "src/swift-guest-dyld-functions.ts"() {
20574
- "use strict";
20575
- init_nativeWasmContract();
20576
- init_swift_sdk_image_wasm();
20577
- uleb2 = (value) => {
20578
- const out = [];
20579
- do {
20580
- let byte = value % 128;
20581
- value = Math.floor(value / 128);
20582
- if (value) byte |= 128;
20583
- out.push(byte);
20584
- } while (value);
20585
- return out;
20586
- };
20587
- SECTION_ORDER = [1, 2, 3, 4, 5, 13, 6, 7, 8, 9, 12, 10, 11];
20588
- readExport = (r) => {
20589
- r.name();
20590
- r.byte();
20591
- r.u();
20592
- };
20593
- lastTableElement = (segments) => segments.findLastIndex((segment3) => (segment3[0] & 3) !== 3);
20594
- }
20595
- });
20596
-
20597
20336
  // ../peach-kit/src/nativeDyldTableContract.ts
20598
20337
  function nativeDyldName(bytes) {
20599
20338
  let name3 = "";
@@ -20644,6 +20383,27 @@ var init_nativeDyldTableContract = __esm({
20644
20383
  }
20645
20384
  });
20646
20385
 
20386
+ // ../peach-kit/src/nativeWasmContract.ts
20387
+ 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;
20388
+ var init_nativeWasmContract = __esm({
20389
+ "../peach-kit/src/nativeWasmContract.ts"() {
20390
+ "use strict";
20391
+ NATIVE_IMAGE_SECTION = "peach.native-image-v1";
20392
+ NATIVE_TABLE_ABI = "peach-native-table-v1";
20393
+ NATIVE_TABLE_IMPORT_MODULE = "peach_thread";
20394
+ NATIVE_DYLD_FUNCTION_IMPORT = "dyld_function";
20395
+ NATIVE_DYLD_PLACE_EXPORT = "__peach_dyld_place";
20396
+ NATIVE_LAZY_IMPORT_MODULE = "peach_lazy";
20397
+ NATIVE_SDK_IMPORT_MODULE = "peach_sdk";
20398
+ NATIVE_SDK_THUNK_SECTION = "peach.sdk-thunks";
20399
+ NATIVE_LAZY_SLOT_IMPORT = "load_slot";
20400
+ NATIVE_LAZY_SECTION = "peach.lazy-code-v2";
20401
+ NATIVE_LAZY_DIGEST_BYTES = 32;
20402
+ NATIVE_LAZY_PART_BYTES = NATIVE_LAZY_DIGEST_BYTES + 4;
20403
+ NATIVE_TABLE_RESERVE_SLOTS = 4096;
20404
+ }
20405
+ });
20406
+
20647
20407
  // src/swift-guest-image-ledger.ts
20648
20408
  function readNumber(bytes, position) {
20649
20409
  if (position < bytes.length) {
@@ -22323,7 +22083,7 @@ function sha256Hex2(bytes) {
22323
22083
  return new Bun.CryptoHasher("sha256").update(bytes).digest("hex");
22324
22084
  return (0, import_node_crypto17.createHash)("sha256").update(bytes).digest("hex");
22325
22085
  }
22326
- function uleb3(value) {
22086
+ function uleb2(value) {
22327
22087
  const bytes = [];
22328
22088
  for (let rest = value; ; rest = Math.floor(rest / 128)) {
22329
22089
  if (rest < 128) return [...bytes, rest];
@@ -22342,7 +22102,7 @@ function encodeGuestDyldTable(rows) {
22342
22102
  value.writeBigUInt64LE(row.value);
22343
22103
  const bytes = Buffer.concat([
22344
22104
  row.bytes,
22345
- Buffer.from([0, ...uleb3(row.image), row.kind]),
22105
+ Buffer.from([0, ...uleb2(row.image), row.kind]),
22346
22106
  value
22347
22107
  ]);
22348
22108
  if (!current2.length) firsts.push(row.bytes);
@@ -22464,6 +22224,260 @@ var init_mapLimit = __esm({
22464
22224
  }
22465
22225
  });
22466
22226
 
22227
+ // src/swift-guest-dyld-functions.ts
22228
+ function skipValueType(r) {
22229
+ const type = r.byte();
22230
+ if (type === 99 || type === 100) r.s();
22231
+ }
22232
+ function readImports2(bytes, sections) {
22233
+ let functions = 0;
22234
+ let table64;
22235
+ const imports2 = sections.find((s) => s.id === 2);
22236
+ if (imports2) {
22237
+ const r = wasmReader(bytes, imports2.start);
22238
+ for (let n = r.u(); n > 0; n--) {
22239
+ r.name();
22240
+ r.name();
22241
+ const kind = r.byte();
22242
+ if (kind === 0) {
22243
+ functions++;
22244
+ r.u();
22245
+ } else if (kind === 1 || kind === 2) {
22246
+ if (kind === 1) skipValueType(r);
22247
+ const flags = r.u();
22248
+ r.u();
22249
+ if (flags & 1) r.u();
22250
+ if (kind === 1) table64 ??= (flags & 4) !== 0;
22251
+ } else if (kind === 3) {
22252
+ skipValueType(r);
22253
+ r.byte();
22254
+ } else if (kind === 4) {
22255
+ r.byte();
22256
+ r.u();
22257
+ } else throw new Error(`unsupported wasm import kind ${kind}`);
22258
+ }
22259
+ }
22260
+ const tables = sections.find((s) => s.id === 4);
22261
+ if (table64 === void 0 && tables) {
22262
+ const r = wasmReader(bytes, tables.start);
22263
+ if (r.u()) {
22264
+ skipValueType(r);
22265
+ table64 = (r.u() & 4) !== 0;
22266
+ }
22267
+ }
22268
+ return { functions, table64 };
22269
+ }
22270
+ function vectorSection(id, count, parts) {
22271
+ const body = Buffer.concat([Buffer.from(uleb3(count)), ...parts]);
22272
+ return Buffer.concat([Buffer.from([id, ...uleb3(body.length)]), body]);
22273
+ }
22274
+ function rewriteSections(bytes, sections, changes) {
22275
+ const out = [bytes.subarray(0, 8)];
22276
+ const pending2 = new Map(changes);
22277
+ const flushBefore = (id) => {
22278
+ for (const [missing2, section2] of pending2) {
22279
+ if (SECTION_ORDER.indexOf(missing2) >= SECTION_ORDER.indexOf(id)) continue;
22280
+ if (section2) out.push(section2);
22281
+ pending2.delete(missing2);
22282
+ }
22283
+ };
22284
+ for (const s of sections) {
22285
+ if (s.id !== 0) flushBefore(s.id);
22286
+ if (!pending2.has(s.id)) {
22287
+ out.push(bytes.subarray(s.offset, s.end));
22288
+ continue;
22289
+ }
22290
+ const section2 = pending2.get(s.id);
22291
+ pending2.delete(s.id);
22292
+ if (section2) out.push(section2);
22293
+ }
22294
+ for (const section2 of pending2.values()) if (section2) out.push(section2);
22295
+ return Buffer.concat(out);
22296
+ }
22297
+ function entries(bytes, section2, entry) {
22298
+ if (!section2) return [];
22299
+ const r = wasmReader(bytes, section2.start);
22300
+ const out = [];
22301
+ for (let n = r.u(); n > 0; n--) {
22302
+ const begin = r.at;
22303
+ entry(r);
22304
+ out.push(bytes.subarray(begin, r.at));
22305
+ }
22306
+ if (r.at !== section2.end) throw new Error(`invalid wasm section ${section2.id}`);
22307
+ return out;
22308
+ }
22309
+ function appendLazyPlacement(bytes, functions, table) {
22310
+ const sections = wasmSections(bytes);
22311
+ const section2 = (id) => sections.find((s) => s.id === id);
22312
+ const imports2 = readImports2(bytes, sections);
22313
+ const changes = /* @__PURE__ */ new Map();
22314
+ let table64 = imports2.table64;
22315
+ if (table64 === void 0) {
22316
+ if (!table) throw new Error("native image has no function table");
22317
+ table64 = table.table64;
22318
+ const found = section2(2);
22319
+ const header = found && wasmReader(bytes, found.start);
22320
+ const count = header ? header.u() : 0;
22321
+ const module2 = Buffer.from("primary");
22322
+ const name4 = Buffer.from(table.name);
22323
+ changes.set(
22324
+ 2,
22325
+ vectorSection(2, count + 1, [
22326
+ found && header ? bytes.subarray(header.at, found.end) : new Uint8Array(),
22327
+ Buffer.from([
22328
+ ...uleb3(module2.length),
22329
+ ...module2,
22330
+ ...uleb3(name4.length),
22331
+ ...name4,
22332
+ 1,
22333
+ 112,
22334
+ table64 ? 4 : 0,
22335
+ 0
22336
+ ])
22337
+ ])
22338
+ );
22339
+ }
22340
+ const types2 = entries(bytes, section2(1), (r) => {
22341
+ if (r.byte() !== 96) throw new Error("native image has a non-function type");
22342
+ for (let side = 0; side < 2; side++) for (let n = r.u(); n > 0; n--) skipValueType(r);
22343
+ });
22344
+ const declared = entries(bytes, section2(3), (r) => r.u());
22345
+ const bodies = entries(bytes, section2(10), (r) => r.skip(r.u()));
22346
+ const exports2 = entries(bytes, section2(7), readExport);
22347
+ const elements = entries(bytes, section2(9), skipElementSegment);
22348
+ const placementIndex = lastTableElement(elements) + 1;
22349
+ elements.splice(
22350
+ placementIndex,
22351
+ 0,
22352
+ Buffer.from([1, 0, ...uleb3(functions.length), ...functions.flatMap(uleb3)])
22353
+ );
22354
+ const place2 = imports2.functions + declared.length;
22355
+ const instructions = [
22356
+ 0,
22357
+ 32,
22358
+ 1,
22359
+ ...table64 ? [173] : [],
22360
+ 32,
22361
+ 0,
22362
+ 65,
22363
+ 1,
22364
+ 252,
22365
+ 12,
22366
+ ...uleb3(placementIndex),
22367
+ 0,
22368
+ 11
22369
+ ];
22370
+ const name3 = Buffer.from(NATIVE_DYLD_PLACE_EXPORT);
22371
+ return rewriteSections(
22372
+ bytes,
22373
+ sections,
22374
+ new Map([
22375
+ ...changes,
22376
+ [
22377
+ 1,
22378
+ vectorSection(1, types2.length + 1, [
22379
+ ...types2,
22380
+ Buffer.from([96, 2, 127, 127, 0])
22381
+ ])
22382
+ ],
22383
+ [
22384
+ 3,
22385
+ vectorSection(3, declared.length + 1, [
22386
+ ...declared,
22387
+ Buffer.from(uleb3(types2.length))
22388
+ ])
22389
+ ],
22390
+ [
22391
+ 7,
22392
+ vectorSection(7, exports2.length + 1, [
22393
+ ...exports2,
22394
+ Buffer.from([...uleb3(name3.length), ...name3, 0, ...uleb3(place2)])
22395
+ ])
22396
+ ],
22397
+ [9, vectorSection(9, elements.length, elements)],
22398
+ [
22399
+ 10,
22400
+ vectorSection(10, bodies.length + 1, [
22401
+ ...bodies,
22402
+ Buffer.from([...uleb3(instructions.length), ...instructions])
22403
+ ])
22404
+ ]
22405
+ ])
22406
+ );
22407
+ }
22408
+ function skipConstant(r) {
22409
+ for (let op = r.byte(); op !== 11; op = r.byte()) {
22410
+ if (op === 65 || op === 66) r.s();
22411
+ else if (op === 35 || op === 210) r.u();
22412
+ else if (op === 208) r.s();
22413
+ else if (![106, 107, 108, 124, 125, 126].includes(op))
22414
+ throw new Error(`unsupported constant expression op ${op}`);
22415
+ }
22416
+ }
22417
+ function skipElementSegment(r) {
22418
+ const flags = r.u();
22419
+ if (flags > 7) throw new Error(`unsupported element segment flags ${flags}`);
22420
+ if ((flags & 3) === 2) r.u();
22421
+ if (!(flags & 1)) skipConstant(r);
22422
+ if (flags & 3) skipValueType(r);
22423
+ for (let count = r.u(); count > 0; count--)
22424
+ if (flags & 4) skipConstant(r);
22425
+ else r.u();
22426
+ }
22427
+ function placeGuestLazyFunctions(bytes, lazy) {
22428
+ const sections = wasmSections(bytes);
22429
+ const lazyIndex = new Map(lazy.map((name3, index) => [name3, index]));
22430
+ const functions = new Array(lazy.length);
22431
+ let found = 0;
22432
+ const kept = entries(
22433
+ bytes,
22434
+ sections.find((s) => s.id === 7),
22435
+ readExport
22436
+ ).filter((entry) => {
22437
+ const r = wasmReader(entry, 0);
22438
+ const position = lazyIndex.get(r.name());
22439
+ const kind = r.byte();
22440
+ if (kind !== 0 || position === void 0) return true;
22441
+ functions[position] = r.u();
22442
+ found++;
22443
+ return false;
22444
+ });
22445
+ if (found !== lazy.length)
22446
+ throw new Error("guest link lost a lazy dlsym function export");
22447
+ return appendLazyPlacement(
22448
+ rewriteSections(bytes, sections, /* @__PURE__ */ new Map([[7, vectorSection(7, kept.length, kept)]])),
22449
+ functions
22450
+ );
22451
+ }
22452
+ function guestLazyExports(lazy) {
22453
+ return lazy.map((name3) => JSON.stringify(`--export=${name3}`)).join("\n");
22454
+ }
22455
+ var uleb3, SECTION_ORDER, readExport, lastTableElement;
22456
+ var init_swift_guest_dyld_functions = __esm({
22457
+ "src/swift-guest-dyld-functions.ts"() {
22458
+ "use strict";
22459
+ init_nativeWasmContract();
22460
+ init_swift_sdk_image_wasm();
22461
+ uleb3 = (value) => {
22462
+ const out = [];
22463
+ do {
22464
+ let byte = value % 128;
22465
+ value = Math.floor(value / 128);
22466
+ if (value) byte |= 128;
22467
+ out.push(byte);
22468
+ } while (value);
22469
+ return out;
22470
+ };
22471
+ SECTION_ORDER = [1, 2, 3, 4, 5, 13, 6, 7, 8, 9, 12, 10, 11];
22472
+ readExport = (r) => {
22473
+ r.name();
22474
+ r.byte();
22475
+ r.u();
22476
+ };
22477
+ lastTableElement = (segments) => segments.findLastIndex((segment3) => (segment3[0] & 3) !== 3);
22478
+ }
22479
+ });
22480
+
22467
22481
  // src/swift-guest-link-plan.ts
22468
22482
  function selectedGuestInputImage(artifact, member) {
22469
22483
  if (artifact.kind === "object" !== (member === null))
@@ -33966,9 +33980,11 @@ async function compileGuestLink(options2) {
33966
33980
  return [...source, ...runtime].sort((a, b) => a.image - b.image);
33967
33981
  };
33968
33982
  const sdk2 = options2.sdkImage;
33969
- const sdkCallers = sdk2?.sdkInterface.guestCallers;
33970
- const sdkObjects = sdk2 ? (await Promise.resolve().then(() => (init_swift_sdk_image(), swift_sdk_image_exports))).readSwiftSdkManifestIndex(sdk2).guestObjects : void 0;
33971
- if (sdk2 && (!sdkCallers || !sdkObjects))
33983
+ const sdkCallers = sdk2.sdkInterface.guestCallers;
33984
+ const sdkObjects = (await Promise.resolve().then(() => (init_swift_sdk_image(), swift_sdk_image_exports))).readSwiftSdkManifestIndex(
33985
+ sdk2
33986
+ ).guestObjects;
33987
+ if (!sdkCallers || !sdkObjects)
33972
33988
  throw new Error("the SDK image has no guest link manifest");
33973
33989
  const result = await linkPrunedGuestImages({
33974
33990
  buildDirectory: options2.buildDirectory,
@@ -33981,14 +33997,14 @@ async function compileGuestLink(options2) {
33981
33997
  ledgerDataImage: 0,
33982
33998
  framework: catalogs.framework,
33983
33999
  sdkProducts: null,
33984
- sharedSdk: sdkCallers && sdkObjects ? {
34000
+ sharedSdk: {
33985
34001
  callers: sdkCallers,
33986
34002
  hasContainingObject: (identity2) => sdkObjects[sdkGuestObjectKey(identity2)] !== void 0
33987
- } : void 0,
33988
- onSplitInputs: sdk2 ? (value) => {
34003
+ },
34004
+ onSplitInputs: (value) => {
33989
34005
  splitInputs = value;
33990
- } : void 0,
33991
- deferFinalLink: Boolean(sdk2),
34006
+ },
34007
+ deferFinalLink: true,
33992
34008
  onDyldRows: (rows) => {
33993
34009
  lazyFunctions = rows.lazyFunctions;
33994
34010
  dyldSymbols = rows.dyldSymbols;
@@ -34256,191 +34272,165 @@ async function compileGuestLink(options2) {
34256
34272
  }
34257
34273
  });
34258
34274
  if (!reserved2 || !projectionObject) throw new Error("guest projection was not reserved");
34259
- if (sdk2) {
34260
- try {
34261
- if (!splitInputs) throw new Error("guest link did not select shared SDK inputs");
34262
- const {
34263
- createSwiftSdkBinding: createSwiftSdkBinding2,
34264
- linkSwiftAppModule: linkSwiftAppModule2,
34265
- readSwiftSdkUsage: readSwiftSdkUsage2,
34266
- swiftAppModuleThunkSection: swiftAppModuleThunkSection2,
34267
- swiftSdkProjectionSpans: swiftSdkProjectionSpans2
34268
- } = await Promise.resolve().then(() => (init_swift_sdk_app_module(), swift_sdk_app_module_exports));
34269
- const project2 = options2.project;
34270
- const work = project2 ? (0, import_node_fs47.mkdtempSync)(import_node_path45.default.join(directory2, "app-module-")) : import_node_path45.default.join(directory2, "app-module");
34271
- if (project2) (0, import_node_fs47.chownSync)(work, project2.uid, project2.gid);
34272
- else (0, import_node_fs47.mkdirSync)(work, { recursive: true });
34273
- const layoutMap = import_node_path45.default.join(work, "app.map");
34274
- let appProjectionObject = projectionObject;
34275
- const owners = new Map(splitInputs.appObjects).set(appProjectionObject, 0);
34276
- const sdkObjectKeys = /* @__PURE__ */ new Map();
34277
- const sdkObjectImages = /* @__PURE__ */ new Map();
34278
- const sdkProductImages = new Map(prepared?.sdkProducts.images);
34279
- for (const [file, { image, product, identity: identity2 }] of splitInputs.sdkObjects) {
34280
- const key2 = sdkGuestObjectKey(identity2);
34281
- sdkObjectKeys.set(file, key2);
34282
- sdkObjectImages.set(key2, image);
34283
- const priorImage = sdkProductImages.get(product);
34284
- if (priorImage !== void 0 && priorImage !== image)
34285
- throw new Error(`SDK product ${product} has several guest images`);
34286
- sdkProductImages.set(product, image);
34287
- }
34288
- const linkedModule = import_node_path45.default.join(work, "app.wasm");
34289
- const sdkSpans = swiftSdkProjectionSpans2(
34290
- sdk2,
34291
- (object8, product) => sdkObjectImages.get(object8) ?? sdkProductImages.get(product)
34275
+ try {
34276
+ if (!splitInputs) throw new Error("guest link did not select shared SDK inputs");
34277
+ const {
34278
+ createSwiftSdkBinding: createSwiftSdkBinding2,
34279
+ linkSwiftAppModule: linkSwiftAppModule2,
34280
+ readSwiftSdkUsage: readSwiftSdkUsage2,
34281
+ swiftAppModuleThunkSection: swiftAppModuleThunkSection2,
34282
+ swiftSdkProjectionSpans: swiftSdkProjectionSpans2
34283
+ } = await Promise.resolve().then(() => (init_swift_sdk_app_module(), swift_sdk_app_module_exports));
34284
+ const project2 = options2.project;
34285
+ const work = project2 ? (0, import_node_fs47.mkdtempSync)(import_node_path45.default.join(directory2, "app-module-")) : import_node_path45.default.join(directory2, "app-module");
34286
+ if (project2) (0, import_node_fs47.chownSync)(work, project2.uid, project2.gid);
34287
+ else (0, import_node_fs47.mkdirSync)(work, { recursive: true });
34288
+ const layoutMap = import_node_path45.default.join(work, "app.map");
34289
+ let appProjectionObject = projectionObject;
34290
+ const owners = new Map(splitInputs.appObjects).set(appProjectionObject, 0);
34291
+ const sdkObjectKeys = /* @__PURE__ */ new Map();
34292
+ const sdkObjectImages = /* @__PURE__ */ new Map();
34293
+ const sdkProductImages = new Map(prepared?.sdkProducts.images);
34294
+ for (const [file, { image, product, identity: identity2 }] of splitInputs.sdkObjects) {
34295
+ const key2 = sdkGuestObjectKey(identity2);
34296
+ sdkObjectKeys.set(file, key2);
34297
+ sdkObjectImages.set(key2, image);
34298
+ const priorImage = sdkProductImages.get(product);
34299
+ if (priorImage !== void 0 && priorImage !== image)
34300
+ throw new Error(`SDK product ${product} has several guest images`);
34301
+ sdkProductImages.set(product, image);
34302
+ }
34303
+ const linkedModule = import_node_path45.default.join(work, "app.wasm");
34304
+ const sdkSpans = swiftSdkProjectionSpans2(
34305
+ sdk2,
34306
+ (object8, product) => sdkObjectImages.get(object8) ?? sdkProductImages.get(product)
34307
+ );
34308
+ const compileAppProjection = (source) => {
34309
+ const projectionSource = import_node_path45.default.join(work, "projection.c");
34310
+ const nextObject = import_node_path45.default.join(work, "projection.o");
34311
+ (0, import_node_fs47.writeFileSync)(projectionSource, source);
34312
+ (0, import_node_child_process30.execFileSync)(
34313
+ import_node_path45.default.join(options2.toolchainBin, "clang"),
34314
+ [...clangOptions, "-c", projectionSource, "-o", nextObject],
34315
+ { stdio: "pipe" }
34292
34316
  );
34293
- const compileAppProjection = (source) => {
34294
- const projectionSource = import_node_path45.default.join(work, "projection.c");
34295
- const nextObject = import_node_path45.default.join(work, "projection.o");
34296
- (0, import_node_fs47.writeFileSync)(projectionSource, source);
34297
- (0, import_node_child_process30.execFileSync)(
34298
- import_node_path45.default.join(options2.toolchainBin, "clang"),
34299
- [...clangOptions, "-c", projectionSource, "-o", nextObject],
34300
- { stdio: "pipe" }
34301
- );
34302
- if (nextObject !== appProjectionObject) {
34303
- owners.delete(appProjectionObject);
34304
- appProjectionObject = nextObject;
34305
- owners.set(appProjectionObject, 0);
34317
+ if (nextObject !== appProjectionObject) {
34318
+ owners.delete(appProjectionObject);
34319
+ appProjectionObject = nextObject;
34320
+ owners.set(appProjectionObject, 0);
34321
+ }
34322
+ };
34323
+ let storage = reserved2;
34324
+ if (sdkSpans.length > 0) {
34325
+ const sdkCounts = guestProjectionRegionCounts(storage.images.length, sdkSpans);
34326
+ storage = reserveGuestProjectionStorage(
34327
+ storage.images,
34328
+ storage.capacities.map((capacity, index) => ({
34329
+ ...capacity,
34330
+ regions: capacity.regions + sdkCounts[index] + 16
34331
+ }))
34332
+ );
34333
+ compileAppProjection(storage.source);
34334
+ }
34335
+ let precomputedSymbols;
34336
+ if (splitInputs.appReferencedSymbols && splitInputs.appDefinedSymbols) {
34337
+ const referenced = new Set(splitInputs.appReferencedSymbols);
34338
+ const defined = new Set(splitInputs.appDefinedSymbols);
34339
+ const projSyms = guestWasmSymbols((0, import_node_fs47.readFileSync)(appProjectionObject));
34340
+ for (const name3 of projSyms.undefined) referenced.add(name3);
34341
+ for (const name3 of projSyms.defined) defined.add(name3);
34342
+ precomputedSymbols = { referenced, defined };
34343
+ }
34344
+ for (; ; ) {
34345
+ const link = await linkSwiftAppModule2({
34346
+ objects: [...owners.keys()],
34347
+ lazyFunctions: splitInputs.lazyFunctions,
34348
+ toolchainBin: options2.toolchainBin,
34349
+ sdk: sdk2,
34350
+ work,
34351
+ output: options2.optimized,
34352
+ optimize: options2.optimize,
34353
+ layoutMap,
34354
+ project: project2,
34355
+ precomputedSymbols,
34356
+ loweringCache: project2 ? void 0 : {
34357
+ file: import_node_path45.default.join(
34358
+ options2.buildDirectory,
34359
+ ".build",
34360
+ "peach-app-module-lowered.wasm"
34361
+ ),
34362
+ compilerDigest: options2.compilerDigest
34306
34363
  }
34307
- };
34308
- let storage = reserved2;
34309
- if (sdkSpans.length > 0) {
34310
- const sdkCounts = guestProjectionRegionCounts(storage.images.length, sdkSpans);
34364
+ });
34365
+ const map2 = (0, import_node_fs47.readFileSync)(
34366
+ project2 ? projectOutputFile(work, layoutMap, project2) : layoutMap,
34367
+ "utf8"
34368
+ );
34369
+ const values = guestDyldValueRange(map2);
34370
+ const bindingRows = /* @__PURE__ */ new Map();
34371
+ const data = [];
34372
+ for (let at = 0; at < link.linkage.data.length; at += 3) {
34373
+ const address = link.linkage.data[at];
34374
+ const size2 = link.linkage.data[at + 1];
34375
+ const value = link.linkage.data[at + 2];
34376
+ if (values && address >= values.address && address < values.address + values.length) {
34377
+ if (size2 !== 8 || (address - values.address) % 8)
34378
+ throw new Error("sdk binding splits a dyld value");
34379
+ bindingRows.set((address - values.address) / 8, value);
34380
+ } else data.push(address, size2, value);
34381
+ }
34382
+ const linked = (0, import_node_fs47.readFileSync)(
34383
+ project2 ? projectOutputFile(work, linkedModule, project2) : linkedModule
34384
+ );
34385
+ const required = guestProjectionRegionCounts(storage.images.length, [
34386
+ ...guestLinkedSpans(map2, linked, linked, owners, splitInputs.appSections, true),
34387
+ ...sdkSpans
34388
+ ]);
34389
+ if (storage.capacities.some(({ regions }, index) => required[index] > regions)) {
34311
34390
  storage = reserveGuestProjectionStorage(
34312
34391
  storage.images,
34313
- storage.capacities.map((capacity, index) => ({
34314
- ...capacity,
34315
- regions: capacity.regions + sdkCounts[index] + 16
34316
- }))
34392
+ storage.capacities.map((capacity, index) => {
34393
+ const count = required[index];
34394
+ return count > capacity.regions ? { ...capacity, regions: Math.max(count, capacity.regions * 2) } : capacity;
34395
+ })
34317
34396
  );
34318
34397
  compileAppProjection(storage.source);
34398
+ continue;
34319
34399
  }
34320
- let precomputedSymbols;
34321
- if (splitInputs.appReferencedSymbols && splitInputs.appDefinedSymbols) {
34322
- const referenced = new Set(splitInputs.appReferencedSymbols);
34323
- const defined = new Set(splitInputs.appDefinedSymbols);
34324
- const projSyms = guestWasmSymbols((0, import_node_fs47.readFileSync)(appProjectionObject));
34325
- for (const name3 of projSyms.undefined) referenced.add(name3);
34326
- for (const name3 of projSyms.defined) defined.add(name3);
34327
- precomputedSymbols = { referenced, defined };
34328
- }
34329
- for (; ; ) {
34330
- const link = await linkSwiftAppModule2({
34331
- objects: [...owners.keys()],
34332
- lazyFunctions: splitInputs.lazyFunctions,
34333
- toolchainBin: options2.toolchainBin,
34334
- sdk: sdk2,
34335
- work,
34336
- output: options2.optimized,
34337
- optimize: options2.optimize,
34338
- layoutMap,
34339
- project: project2,
34340
- precomputedSymbols,
34341
- loweringCache: project2 ? void 0 : {
34342
- file: import_node_path45.default.join(
34343
- options2.buildDirectory,
34344
- ".build",
34345
- "peach-app-module-lowered.wasm"
34346
- ),
34347
- compilerDigest: options2.compilerDigest
34348
- }
34349
- });
34350
- const map3 = (0, import_node_fs47.readFileSync)(
34351
- project2 ? projectOutputFile(work, layoutMap, project2) : layoutMap,
34352
- "utf8"
34353
- );
34354
- const values = guestDyldValueRange(map3);
34355
- const bindingRows = /* @__PURE__ */ new Map();
34356
- const data = [];
34357
- for (let at = 0; at < link.linkage.data.length; at += 3) {
34358
- const address = link.linkage.data[at];
34359
- const size2 = link.linkage.data[at + 1];
34360
- const value = link.linkage.data[at + 2];
34361
- if (values && address >= values.address && address < values.address + values.length) {
34362
- if (size2 !== 8 || (address - values.address) % 8)
34363
- throw new Error("sdk binding splits a dyld value");
34364
- bindingRows.set((address - values.address) / 8, value);
34365
- } else data.push(address, size2, value);
34366
- }
34367
- const linked = (0, import_node_fs47.readFileSync)(
34368
- project2 ? projectOutputFile(work, linkedModule, project2) : linkedModule
34369
- );
34370
- const required = guestProjectionRegionCounts(storage.images.length, [
34371
- ...guestLinkedSpans(map3, linked, linked, owners, splitInputs.appSections, true),
34372
- ...sdkSpans
34373
- ]);
34374
- if (storage.capacities.some(({ regions }, index) => required[index] > regions)) {
34375
- storage = reserveGuestProjectionStorage(
34376
- storage.images,
34377
- storage.capacities.map((capacity, index) => {
34378
- const count = required[index];
34379
- return count > capacity.regions ? { ...capacity, regions: Math.max(count, capacity.regions * 2) } : capacity;
34380
- })
34381
- );
34382
- compileAppProjection(storage.source);
34383
- continue;
34384
- }
34385
- options2.onStage("lowering the app image");
34386
- const lowerPromise = link.lower();
34387
- await new Promise((resolve4) => setImmediate(resolve4));
34388
- let binding;
34389
- try {
34390
- if (result.finalLinkDone) await result.finalLinkDone;
34391
- const usage = readSwiftSdkUsage2(result.mapPath, options2.output, sdkObjectKeys);
34392
- binding = createSwiftSdkBinding2({ ...link.linkage, data }, sdk2, usage);
34393
- } catch (error) {
34394
- await Promise.allSettled([lowerPromise]);
34395
- throw error;
34396
- }
34397
- await lowerPromise;
34398
- const finalized = finalizeGuestProjectionStorage({
34399
- map: map3,
34400
- linked,
34401
- optimized: (0, import_node_fs47.readFileSync)(options2.optimized),
34402
- owners,
34403
- sectionOwners: splitInputs.appSections,
34404
- projectionObject: appProjectionObject,
34405
- reserved: storage,
34406
- sdkSpans
34407
- });
34408
- (0, import_node_fs47.writeFileSync)(
34409
- options2.optimized,
34410
- moveGuestDyldTable(map3, finalized.wasm, splitInputs.dyldSymbols, bindingRows, [
34411
- swiftAppModuleThunkSection2(finalized.wasm)
34412
- ])
34413
- );
34414
- return binding;
34400
+ options2.onStage("lowering the app image");
34401
+ const lowerPromise = link.lower();
34402
+ await new Promise((resolve4) => setImmediate(resolve4));
34403
+ let binding;
34404
+ try {
34405
+ if (result.finalLinkDone) await result.finalLinkDone;
34406
+ const usage = readSwiftSdkUsage2(result.mapPath, options2.output, sdkObjectKeys);
34407
+ binding = createSwiftSdkBinding2({ ...link.linkage, data }, sdk2, usage);
34408
+ } catch (error) {
34409
+ await Promise.allSettled([lowerPromise]);
34410
+ throw error;
34415
34411
  }
34416
- } finally {
34417
- if (result.finalLinkDone) await Promise.allSettled([result.finalLinkDone]);
34412
+ await lowerPromise;
34413
+ const finalized = finalizeGuestProjectionStorage({
34414
+ map: map2,
34415
+ linked,
34416
+ optimized: (0, import_node_fs47.readFileSync)(options2.optimized),
34417
+ owners,
34418
+ sectionOwners: splitInputs.appSections,
34419
+ projectionObject: appProjectionObject,
34420
+ reserved: storage,
34421
+ sdkSpans
34422
+ });
34423
+ (0, import_node_fs47.writeFileSync)(
34424
+ options2.optimized,
34425
+ moveGuestDyldTable(map2, finalized.wasm, splitInputs.dyldSymbols, bindingRows, [
34426
+ swiftAppModuleThunkSection2(finalized.wasm)
34427
+ ])
34428
+ );
34429
+ return binding;
34418
34430
  }
34431
+ } finally {
34432
+ if (result.finalLinkDone) await Promise.allSettled([result.finalLinkDone]);
34419
34433
  }
34420
- options2.onStage("lowering the app image");
34421
- await lowerWasm(options2.output, options2.optimized, {
34422
- optimize: options2.optimize,
34423
- skipPasses: ["duplicate-function-elimination"],
34424
- wideExports: lazyFunctions
34425
- });
34426
- if (lazyFunctions.length)
34427
- (0, import_node_fs47.writeFileSync)(
34428
- options2.optimized,
34429
- placeGuestLazyFunctions((0, import_node_fs47.readFileSync)(options2.optimized), lazyFunctions)
34430
- );
34431
- const map2 = (0, import_node_fs47.readFileSync)(result.mapPath, "utf8");
34432
- let optimized = (0, import_node_fs47.readFileSync)(options2.optimized);
34433
- if (/ __peach_guest_images$/m.test(map2))
34434
- optimized = finalizeGuestProjectionStorage({
34435
- map: map2,
34436
- linked: (0, import_node_fs47.readFileSync)(options2.output),
34437
- optimized,
34438
- owners: result.owners,
34439
- sectionOwners: result.generatedSectionOwners,
34440
- projectionObject,
34441
- reserved: reserved2
34442
- }).wasm;
34443
- (0, import_node_fs47.writeFileSync)(options2.optimized, moveGuestDyldTable(map2, optimized, dyldSymbols));
34444
34434
  }
34445
34435
  var import_node_child_process30, import_node_fs47, import_node_path45;
34446
34436
  var init_swift_guest_compile = __esm({
@@ -34450,7 +34440,6 @@ var init_swift_guest_compile = __esm({
34450
34440
  import_node_fs47 = require("node:fs");
34451
34441
  import_node_path45 = __toESM(require("node:path"), 1);
34452
34442
  init_swift_guest_archive();
34453
- init_swift_guest_dyld_functions();
34454
34443
  init_swift_guest_dyld_table();
34455
34444
  init_swift_guest_link();
34456
34445
  init_swift_guest_linked_spans();
@@ -34464,7 +34453,6 @@ var init_swift_guest_compile = __esm({
34464
34453
  init_swift_toolchain();
34465
34454
  init_swift_wasm_prune();
34466
34455
  init_swiftTargetContract();
34467
- init_wasm_optimize();
34468
34456
  }
34469
34457
  });
34470
34458
 
@@ -39444,20 +39432,17 @@ function readCompiledArtifact(directory2, hash) {
39444
39432
  const gzip2 = (0, import_node_fs55.readFileSync)(import_node_path55.default.join(directory2, "icu.gz"));
39445
39433
  if ((0, import_node_crypto35.createHash)("sha256").update(bytes).digest("hex") !== receipt.wasm || (0, import_node_crypto35.createHash)("sha256").update(gzip2).digest("hex") !== receipt.icu || bytes.length <= 8 || bytes.readUInt32LE(0) !== 1836278016 || bytes.readUInt32LE(4) !== 1)
39446
39434
  return null;
39447
- let sdk2;
39448
- if ("sdk" in receipt) {
39449
- const image = receipt.sdk;
39450
- if (!isRecord(image) || typeof image.key !== "string" || typeof image.sha256 !== "string" || typeof image.binding !== "string")
39451
- return null;
39452
- const binding = (0, import_node_fs55.readFileSync)(import_node_path55.default.join(directory2, "sdk-binding.bin"));
39453
- if ((0, import_node_crypto35.createHash)("sha256").update(binding).digest("hex") !== image.binding)
39454
- return null;
39455
- sdk2 = {
39456
- key: image.key,
39457
- sha256: image.sha256,
39458
- binding: { bytes: binding, sha256: image.binding }
39459
- };
39460
- }
39435
+ if (!("sdk" in receipt)) return null;
39436
+ const image = receipt.sdk;
39437
+ if (!isRecord(image) || typeof image.key !== "string" || typeof image.sha256 !== "string" || typeof image.binding !== "string")
39438
+ return null;
39439
+ const binding = (0, import_node_fs55.readFileSync)(import_node_path55.default.join(directory2, "sdk-binding.bin"));
39440
+ if ((0, import_node_crypto35.createHash)("sha256").update(binding).digest("hex") !== image.binding) return null;
39441
+ const sdk2 = {
39442
+ key: image.key,
39443
+ sha256: image.sha256,
39444
+ binding: { bytes: binding, sha256: image.binding }
39445
+ };
39461
39446
  return { hash, bytes, icu: { sha256: receipt.icu, gzip: gzip2 }, sdk: sdk2 };
39462
39447
  } catch (error) {
39463
39448
  if (error instanceof SyntaxError || error instanceof Error && "code" in error && error.code === "ENOENT")
@@ -40388,13 +40373,12 @@ async function compileSwiftProjectOnce(sources, options2) {
40388
40373
  sources: import_node_path55.default.join(root, "Sources", "App"),
40389
40374
  multi: compileTargets(input).length > 0
40390
40375
  };
40391
- const sdkModule = options2.sdkModule && !options2.linkOnly;
40392
- const sdkImage = sdkModule ? await (await Promise.resolve().then(() => (init_swift_sdk_image(), swift_sdk_image_exports))).buildSwiftSdkImage(
40376
+ const sdkImage = options2.linkOnly ? void 0 : await (await Promise.resolve().then(() => (init_swift_sdk_image(), swift_sdk_image_exports))).buildSwiftSdkImage(
40393
40377
  moduleRoot,
40394
40378
  !!guestGraph,
40395
40379
  distribution ? [] : linkedFrameworkTargets(moduleRoot, input).imports,
40396
40380
  { signal: options2.signal }
40397
- ) : void 0;
40381
+ );
40398
40382
  const inputHash = swiftCompileInputHash(input, options2.release);
40399
40383
  const moduleDigest = swiftModuleDigest(moduleRoot);
40400
40384
  const sourceHash = inputHash.copy().update(moduleDigest).digest("hex");
@@ -40425,79 +40409,10 @@ sdk module ${sdkImage.key}`).digest("hex") : sourceHash;
40425
40409
  return retain(root, previous);
40426
40410
  }
40427
40411
  }
40428
- if (!options2.intermediates && !sdkImage && process.platform === "darwin" && process.env.TM_SESSION && !windowAdmission() && process.env.CI !== "true" && moduleRoot === sourceSwiftCheckout() && !swiftDistributionAt(moduleRoot)) {
40429
- const requestRoot = (0, import_node_fs55.mkdtempSync)(`${root}.builder-request-`);
40430
- const output = import_node_path55.default.join(requestRoot, "output");
40431
- const request = import_node_path55.default.join(requestRoot, "request.json");
40432
- (0, import_node_fs55.writeFileSync)(
40433
- request,
40434
- JSON.stringify({
40435
- input,
40436
- hash,
40437
- release: options2.release,
40438
- timeoutMs: options2.timeoutMs,
40439
- // framework sources and compiler inputs own the shared object tree;
40440
- // unrelated app edits reuse it without retaining stale private ABI.
40441
- buildKey: frameworkKey
40442
- })
40443
- );
40444
- try {
40445
- const repo = import_node_path55.default.resolve(moduleRoot, "../..");
40446
- const timeout = swiftBuilderHopTimeoutMs(options2.timeoutMs);
40447
- report("requesting builder admission or cached result");
40448
- await runCompiler(
40449
- "bun",
40450
- [
40451
- import_node_path55.default.join(repo, "scripts/build/swift-project.ts"),
40452
- "--request",
40453
- request,
40454
- "--output",
40455
- output
40456
- ],
40457
- {
40458
- cwd: repo,
40459
- timeout,
40460
- maxBuffer: 64 * 1024 * 1024,
40461
- signal: options2.signal
40462
- },
40463
- true
40464
- ).catch((error) => {
40465
- if (options2.signal?.aborted) throw error;
40466
- const output2 = outputOf(error);
40467
- if (!(error instanceof Error) || Reflect.get(error, "exitCode") !== 124)
40468
- throw new Error(output2, { cause: error });
40469
- const prefix = `[swift-project ${hash.slice(0, 16)}] `;
40470
- const lines = output2.split("\n");
40471
- const stage = lines.findLast((line) => line.startsWith(prefix))?.slice(prefix.length);
40472
- const cap = lines.find(
40473
- (line) => line.startsWith("[remote] outer deadline leaves ")
40474
- );
40475
- const deadline = cap ? `
40476
- ${cap}` : "";
40477
- throw new Error(
40478
- `Swift builder deadline expired during ${stage ?? "builder preparation"} (requested ${Math.ceil(timeout / 1e3)}s for the builder hop).${deadline}`,
40479
- { cause: error }
40480
- );
40481
- });
40482
- const artifact = readCompiledArtifact(output, hash);
40483
- if (!artifact) {
40484
- throw new Error(
40485
- "swift-compile: builder artifact source, digest or wasm header is invalid"
40486
- );
40487
- }
40488
- saveCompiledArtifact(root, artifact);
40489
- saveSharedArtifact(sharedRoot, artifact);
40490
- report("builder artifact verified");
40491
- return retain(root, artifact);
40492
- } finally {
40493
- (0, import_node_fs55.rmSync)(requestRoot, { recursive: true, force: true });
40494
- }
40495
- }
40496
40412
  const baseRoot = root;
40497
40413
  const canPoolBuildRoot = !options2.intermediates && !options2.project && !options2.linkOnly && import_node_path55.default.basename(import_node_path55.default.dirname(baseRoot)) === "swift-builds";
40498
40414
  const compatShapeParts = canPoolBuildRoot ? [
40499
40415
  frameworkKey,
40500
- Boolean(sdkImage),
40501
40416
  compileTargets(input).map((target) => target.name).sort(),
40502
40417
  input.oneModule === true,
40503
40418
  input.optimize === true,
@@ -41135,7 +41050,8 @@ ${compatShape}` : "";
41135
41050
  }
41136
41051
  const output = options2.project ? projectOutputFile(root2, linked, options2.project) : linked;
41137
41052
  const optimized = `${output}.optimized`;
41138
- if (sdkImage && options2.project) (0, import_node_fs55.rmSync)(optimized, { force: true });
41053
+ if (!sdkImage) throw new Error("swift-compile: missing shared SDK image");
41054
+ if (options2.project) (0, import_node_fs55.rmSync)(optimized, { force: true });
41139
41055
  let sdkAsset;
41140
41056
  stage("linking the app image");
41141
41057
  if (guestGraph) {
@@ -41164,9 +41080,8 @@ ${compatShape}` : "";
41164
41080
  jobs: swiftBuildJobs(),
41165
41081
  onStage: stage
41166
41082
  });
41167
- if (sdkImage && binding)
41168
- sdkAsset = { key: sdkImage.key, sha256: sdkImage.sha256, binding };
41169
- } else if (sdkImage) {
41083
+ sdkAsset = { key: sdkImage.key, sha256: sdkImage.sha256, binding };
41084
+ } else {
41170
41085
  const { buildSwiftAppModule: buildSwiftAppModule2 } = await Promise.resolve().then(() => (init_swift_sdk_app_module(), swift_sdk_app_module_exports));
41171
41086
  const binding = await buildSwiftAppModule2({
41172
41087
  buildRoot: root2,
@@ -41184,19 +41099,7 @@ ${compatShape}` : "";
41184
41099
  }
41185
41100
  });
41186
41101
  sdkAsset = { key: sdkImage.key, sha256: sdkImage.sha256, binding };
41187
- } else {
41188
- const bytes = (0, import_node_fs55.readFileSync)(output);
41189
- const ordered = orderObjCConstructors(bytes);
41190
- if (ordered !== bytes) (0, import_node_fs55.writeFileSync)(output, ordered);
41191
- stage("lowering the app image");
41192
- await lowerWasm(output, optimized, { optimize: input.optimize === true });
41193
41102
  }
41194
- if (!sdkImage)
41195
- await runCompiler(
41196
- import_node_path55.default.join(options2.toolchainBin, "llvm-objcopy"),
41197
- ["--remove-section=.swift1_autolink_entries", optimized],
41198
- buildOptions
41199
- );
41200
41103
  const artifact = {
41201
41104
  hash,
41202
41105
  bytes: (0, import_node_fs55.readFileSync)(optimized),
@@ -41256,7 +41159,6 @@ var init_swift_compile = __esm({
41256
41159
  init_swift_project_user();
41257
41160
  init_swift_reproducible();
41258
41161
  init_swift_root_lock();
41259
- init_swift_sdk_image_wasm();
41260
41162
  init_swift_sdk_surface();
41261
41163
  init_swift_shared_sdk();
41262
41164
  init_swift_source_closure();
@@ -41451,7 +41353,7 @@ ${wasmThreadLinkFlags.map((flag) => ` "-Xlinker", ${JSON.stringify(flag
41451
41353
  REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
41452
41354
  MULTI_MANIFEST_VERSION = 76;
41453
41355
  SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
41454
- compilerSourceDigest = true ? "229f789297c5cb8e33a042e23ad3c1df20450a712a02dd0b50d2e78bc8ed3de6" : swiftCompilerSourceDigest(__sootsim_import_meta_dirname);
41356
+ compilerSourceDigest = true ? "dcd0189f8bf1a7fc415f2c92825f8b3bbc2089ae9697ffcb50cc9a7e65e99990" : swiftCompilerSourceDigest(__sootsim_import_meta_dirname);
41455
41357
  nativeCxxCompilerFlags = ["-fno-cxx-modules"];
41456
41358
  MODULE_MAP_RESPONSE_FILE_RUN = 16;
41457
41359
  cFlagArray = (flags) => JSON.stringify(withoutGlogModuleMap(flags));
@@ -97698,7 +97600,6 @@ function linkedModuleRoots(packagePath) {
97698
97600
  return [...roots].sort();
97699
97601
  }
97700
97602
  function updateSwiftConfigStamp(hash, packagePath) {
97701
- if (projects().get(packagePath)?.standalone) hash.update("standalone");
97702
97603
  const config = xcodeProjects().get(packagePath);
97703
97604
  hash.update(JSON.stringify(config?.behavior ?? {}));
97704
97605
  const gates = config?.swiftWasm64?.platformGates;
@@ -97775,9 +97676,9 @@ function moduleStamp(packagePath, moduleRootOverride, hosted) {
97775
97676
  }
97776
97677
  return hash.digest("hex");
97777
97678
  }
97778
- function otherInputs(input, standalone) {
97679
+ function otherInputs(input) {
97779
97680
  const { files: _files, ...rest } = input;
97780
- return (0, import_node_crypto70.createHash)("sha256").update(JSON.stringify({ ...rest, standalone })).digest("hex");
97681
+ return (0, import_node_crypto70.createHash)("sha256").update(JSON.stringify(rest)).digest("hex");
97781
97682
  }
97782
97683
  function icuUrl(origin, artifact) {
97783
97684
  return "url" in artifact.icu ? artifact.icu.url : `${origin}${ICU_PATH}${swiftIcuAddress(artifact.icu)}`;
@@ -97981,7 +97882,6 @@ async function packageSnapshot(project2, entry, moduleRoot) {
97981
97882
  return {
97982
97883
  files: files2,
97983
97884
  oneModule: project2.oneModule,
97984
- standalone: project2.standalone === true,
97985
97885
  binaryModules: {
97986
97886
  ...project2.binaryModules,
97987
97887
  ...Object.fromEntries(
@@ -98193,7 +98093,7 @@ async function compile(packagePath, stamp, moduleRootOverride, hosted, snapshot,
98193
98093
  const input = snapshotCompileInput(snapshot);
98194
98094
  const compiled = {
98195
98095
  files: input.files,
98196
- inputs: otherInputs(input, snapshot.standalone),
98096
+ inputs: otherInputs(input),
98197
98097
  module: moduleStamp(packagePath, moduleRootOverride, false)
98198
98098
  };
98199
98099
  const parsed2 = compileTargets(input);
@@ -98241,8 +98141,6 @@ async function compile(packagePath, stamp, moduleRootOverride, hosted, snapshot,
98241
98141
  buildRoot: swiftBuildRoot(packagePath, moduleRoot),
98242
98142
  moduleRoot,
98243
98143
  ...toolchain,
98244
- // the preview loads an app module beside the shared sdk image
98245
- sdkModule: !snapshot.standalone && (input.sourceLinkGraph !== void 0 || swiftApplicationEntry(input.entry, input.files[input.entry] ?? "")),
98246
98144
  signal
98247
98145
  }).catch((error) => {
98248
98146
  const report = error instanceof Error ? swiftApiGapReport(error.message) : null;
@@ -98391,8 +98289,7 @@ async function compileRemote(packagePath, snapshot, hosted, ownerSignal) {
98391
98289
  resources: snapshot.bundleFiles.files,
98392
98290
  images: snapshot.resources.images,
98393
98291
  entry: snapshot.entry,
98394
- packageId: descriptor?.packageId ?? swiftPackageId(packagePath),
98395
- sdkModule: !snapshot.standalone
98292
+ packageId: descriptor?.packageId ?? swiftPackageId(packagePath)
98396
98293
  },
98397
98294
  origin,
98398
98295
  signal,
@@ -98484,7 +98381,7 @@ function scopedArtifact(project2, entry, moduleRoot, signal) {
98484
98381
  const compiled = project2.artifact?.compiled;
98485
98382
  if (project2.artifact && compiled && compiled.module === moduleStamp(project2.packagePath, moduleRoot, false)) {
98486
98383
  const input = snapshotCompileInput(snapshot);
98487
- const values = otherInputs(input, snapshot.standalone) === compiled.inputs ? designTimeValues(compiled.files, input.files) : null;
98384
+ const values = otherInputs(input) === compiled.inputs ? designTimeValues(compiled.files, input.files) : null;
98488
98385
  if (values) return { ...project2.artifact, stamp, designTimeValues: values };
98489
98386
  }
98490
98387
  return compile(
@@ -104812,7 +104709,6 @@ async function compileTurboModule(options2) {
104812
104709
  );
104813
104710
  const project2 = projectFor(packagePath);
104814
104711
  project2.oneModule = false;
104815
- project2.standalone = true;
104816
104712
  project2.libraries = input.libraries;
104817
104713
  project2.binaryModules = input.binaryModules;
104818
104714
  project2.optimize = input.optimize;
@@ -105168,7 +105064,7 @@ var init_react_native_core = __esm({
105168
105064
  init_swift_distribution();
105169
105065
  init_swift_package();
105170
105066
  init_swiftContract();
105171
- recipe = true ? "db2c81d6628055a561c22667b098e4686f9d8924ffb229c4c7d9e15a25182502" : reactNativeCoreDigest(__sootsim_import_meta_dirname);
105067
+ recipe = true ? "d4161f11b10bfff3f21f57ca2352bf31c30f364e15fd7e1c385311c10033fa89" : reactNativeCoreDigest(__sootsim_import_meta_dirname);
105172
105068
  strings3 = (value) => isRecord(value) && Object.values(value).every((item) => typeof item === "string");
105173
105069
  building = /* @__PURE__ */ new Map();
105174
105070
  }
@@ -105526,7 +105422,12 @@ function collectNitroCompileInput(collection, adapter, dependencies, iosDeployme
105526
105422
  ].join("\n") : [
105527
105423
  ...swift ? ["@_spi(Peach) import PeachFoundation"] : [],
105528
105424
  ...imports2.map((name3) => `import ${name3}`),
105529
- ...swift ? ["PeachHostDriver.installExecutor()"] : [],
105425
+ ...swift ? [
105426
+ '@_expose(wasm, "peach_nitro_swift_host")',
105427
+ '@_cdecl("peach_nitro_swift_host")',
105428
+ "public func _peachNitroSwiftHost() {}",
105429
+ "PeachHostDriver.installExecutor()"
105430
+ ] : [],
105530
105431
  ...register,
105531
105432
  ""
105532
105433
  ].join("\n");
@@ -106097,7 +105998,6 @@ async function compileNitroModule(options2) {
106097
105998
  );
106098
105999
  const project2 = projectFor(packagePath);
106099
106000
  project2.oneModule = false;
106100
- project2.standalone = true;
106101
106001
  project2.libraries = input.libraries;
106102
106002
  project2.binaryModules = input.binaryModules;
106103
106003
  project2.optimize = input.optimize;
@@ -106387,7 +106287,7 @@ var init_nitro_superset = __esm({
106387
106287
  init_nitroContract();
106388
106288
  init_swift_standin_digest();
106389
106289
  NITRO_SUPERSET_ENTRY_NAME = "superset";
106390
- NITRO_COMPILER_DIGEST = true ? "744976c15724422db8f3bc8d1fdfdcf68c3f91b185210a50951930d2ea18c38e" : nitroCompilerSourceDigest(__sootsim_import_meta_dirname, STANDIN_SOURCE_DIGEST2);
106290
+ NITRO_COMPILER_DIGEST = true ? "9303a53709842e0a9107912bfca87f4a1731cfc09b9d252fac03c156eabf3836" : nitroCompilerSourceDigest(__sootsim_import_meta_dirname, STANDIN_SOURCE_DIGEST2);
106391
106291
  nitroSupersetLock = parseLock(nitro_superset_lock_default);
106392
106292
  nitroSupersetKey = (inputs2) => nativeEntryKey({ ...inputs2, compiler: NITRO_COMPILER_DIGEST });
106393
106293
  published = /* @__PURE__ */ new Map();
@@ -106458,6 +106358,7 @@ async function compileNitroApp(appRoot, origin, configure, moduleRoot, shared =
106458
106358
  views
106459
106359
  })),
106460
106360
  url: `${origin}/__peach/swift/${artifact.hash}.wasm`,
106361
+ ...await prepareSwiftSdkEntryAssets(origin, artifact),
106461
106362
  hash: artifact.hash,
106462
106363
  icuUrl: icuUrl(origin, artifact),
106463
106364
  bundleFiles: artifact.package.bundleFiles.files
@@ -107298,12 +107199,12 @@ let package = Package(name: "OneSDKGuest", targets: [
107298
107199
  );
107299
107200
  const project2 = projectFor(packagePath);
107300
107201
  project2.oneModule = false;
107301
- project2.standalone = true;
107302
107202
  project2.optimize = optimize;
107303
107203
  project2.unoptimized = !optimize;
107304
107204
  const artifact = await artifactFor(project2, "Sources/App/App.swift", moduleRoot);
107305
107205
  const metadata = {
107306
107206
  url: `${origin}/__peach/swift/${artifact.hash}.wasm`,
107207
+ ...await prepareSwiftSdkEntryAssets(origin, artifact),
107307
107208
  hash: artifact.hash,
107308
107209
  icuUrl: icuUrl(origin, artifact),
107309
107210
  rootId: `one-sdk-${artifact.hash.slice(0, 16)}`,
@@ -107366,7 +107267,7 @@ var init_expo_eager_seam_contract = __esm({
107366
107267
 
107367
107268
  // src/expo-native-compiler-digest.ts
107368
107269
  function expoNativeCompilerDigestValue() {
107369
- return true ? "dd69e490ecc79ee83e8cba98c4532818a62e9b0e93c21113e2d6c21ec60d8eee" : expoNativeCompilerDigest(__sootsim_import_meta_dirname);
107270
+ return true ? "13d332cac87de68ec66d60f9bb7b02f5fbfb1cf35a281ec222570bd0562878cd" : expoNativeCompilerDigest(__sootsim_import_meta_dirname);
107370
107271
  }
107371
107272
  var import_node_crypto81;
107372
107273
  var init_expo_native_compiler_digest = __esm({
@@ -111493,7 +111394,7 @@ async function compileTurboApp(appRoot, origin, moduleRoot, iosTarget, prepareRe
111493
111394
  url: `${origin}/__peach/swift/${artifact.hash}.wasm`,
111494
111395
  hash: artifact.hash,
111495
111396
  icuUrl: icuUrl(origin, artifact),
111496
- ...swiftSdkEntryAssets(origin, artifact),
111397
+ ...await prepareSwiftSdkEntryAssets(origin, artifact),
111497
111398
  bundleFiles: artifact.package.bundleFiles.files,
111498
111399
  ...unavailable2.length > 0 ? { unavailable: unavailable2 } : {}
111499
111400
  }
@@ -115548,7 +115449,13 @@ function insertNativeBundleFooters(source, natives, locate) {
115548
115449
  }
115549
115450
  if (natives.nitro) {
115550
115451
  const nitro = natives.nitro.metadata;
115551
- metadata.nitro = { ...nitro, url: served(nitro.url), icuUrl: served(nitro.icuUrl) };
115452
+ metadata.nitro = {
115453
+ ...nitro,
115454
+ url: served(nitro.url),
115455
+ icuUrl: served(nitro.icuUrl),
115456
+ ...nitro.sdkUrl ? { sdkUrl: served(nitro.sdkUrl) } : {},
115457
+ ...nitro.sdkBindingUrl ? { sdkBindingUrl: served(nitro.sdkBindingUrl) } : {}
115458
+ };
115552
115459
  source = insertNitroFooter(source, metadata.nitro);
115553
115460
  }
115554
115461
  if (natives.turbo) {
@@ -116067,7 +115974,7 @@ function packagedAssetDirectory(location) {
116067
115974
  }
116068
115975
  var channelKey = (platform2) => platform2 === "ios" ? "peach/channels/prod" : `peach/channels/${platform2}/prod`;
116069
115976
  var nativeAssetPath = {
116070
- ios: /^__peach\/(swift\/[a-f0-9]{64}\.wasm|swift-icu\/[a-f0-9]{64}\.picu[0-9]+)$/,
115977
+ ios: /^__peach\/(swift\/[a-f0-9]{64}\.(wasm|dyld)|swift-sdk\/[a-f0-9]{64}\.wasm|swift-sdk-bindings\/[a-f0-9]{64}\.bin|swift-icu\/[a-f0-9]{64}\.picu[0-9]+)$/,
116071
115978
  android: /^__peach\/kotlin\/[a-f0-9]+\/[A-Za-z0-9._-]+\.(mjs|wasm)$/
116072
115979
  };
116073
115980
  async function prepareBundleChannel({