peachsim 0.1.2592 → 0.1.2593

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/dist-lib/agent-daemon-client.cjs +1 -1
  2. package/dist-lib/agent-events.cjs +1 -1
  3. package/dist-lib/attached-projects.cjs +1 -1
  4. package/dist-lib/auth/shared-session.cjs +1 -1
  5. package/dist-lib/backend-origin.cjs +1 -1
  6. package/dist-lib/beta.cjs +1 -1
  7. package/dist-lib/beta.mjs +2 -2
  8. package/dist-lib/bridge-constants.cjs +1 -1
  9. package/dist-lib/bridge-contract-input.cjs +1 -1
  10. package/dist-lib/bridge-contract-input.mjs +5 -5
  11. package/dist-lib/bridge-contract.cjs +1 -1
  12. package/dist-lib/bridge-contract.mjs +3 -3
  13. package/dist-lib/bundle-channel.cjs +1737 -1648
  14. package/dist-lib/capture-contract.cjs +1 -1
  15. package/dist-lib/capture-contract.mjs +3 -3
  16. package/dist-lib/cloud-contract.cjs +1 -1
  17. package/dist-lib/cloud-contract.mjs +3 -3
  18. package/dist-lib/cloud-test-args.cjs +1 -1
  19. package/dist-lib/cloud-test-args.mjs +2 -2
  20. package/dist-lib/cloud.cjs +1 -1
  21. package/dist-lib/cloud.mjs +7 -7
  22. package/dist-lib/config.cjs +1 -1
  23. package/dist-lib/config.mjs +5 -5
  24. package/dist-lib/detox/index.cjs +1 -1
  25. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  26. package/dist-lib/esm-chunks/{acorn-67PU73QE.mjs → acorn-DLENU3SM.mjs} +3 -3
  27. package/dist-lib/esm-chunks/{chunk-L5T3HBPO.mjs → chunk-23D4W2EY.mjs} +240 -206
  28. package/dist-lib/esm-chunks/{chunk-D4LYKRRB.mjs → chunk-2MWUVSRW.mjs} +1 -1
  29. package/dist-lib/esm-chunks/{chunk-PITO2NI2.mjs → chunk-2UERF2EN.mjs} +2 -2
  30. package/dist-lib/esm-chunks/{chunk-XSQH4R5E.mjs → chunk-4YJJKKKF.mjs} +69 -48
  31. package/dist-lib/esm-chunks/{chunk-FYXXFYML.mjs → chunk-6O2M4J2Y.mjs} +1 -1
  32. package/dist-lib/esm-chunks/{chunk-CF3MTPMY.mjs → chunk-BMKI4WBL.mjs} +1 -1
  33. package/dist-lib/esm-chunks/{chunk-EITX573K.mjs → chunk-DLSPHUHQ.mjs} +1 -1
  34. package/dist-lib/esm-chunks/{chunk-5FTHILIE.mjs → chunk-E6OGMX3T.mjs} +1 -1
  35. package/dist-lib/esm-chunks/{chunk-TJZPNFVF.mjs → chunk-GFMQ5PNX.mjs} +1 -1
  36. package/dist-lib/esm-chunks/{chunk-6DB5FR7S.mjs → chunk-IT4CC3HU.mjs} +1 -1
  37. package/dist-lib/esm-chunks/{chunk-EWHA6X3Z.mjs → chunk-JPNUGMLE.mjs} +5 -5
  38. package/dist-lib/esm-chunks/{chunk-XZ3FX3HW.mjs → chunk-KWMJUJJS.mjs} +1 -1
  39. package/dist-lib/esm-chunks/{chunk-DFF5XZ5M.mjs → chunk-LK3KQ4X3.mjs} +1 -1
  40. package/dist-lib/esm-chunks/{chunk-RV4ACE6R.mjs → chunk-LN7ZTBNS.mjs} +1 -1
  41. package/dist-lib/esm-chunks/{chunk-EHRSWFTD.mjs → chunk-NIYJBFXV.mjs} +3 -3
  42. package/dist-lib/esm-chunks/{chunk-M4QLI2SY.mjs → chunk-OIHSBING.mjs} +1 -1
  43. package/dist-lib/esm-chunks/{chunk-SW4PSSTF.mjs → chunk-P3A4MQHR.mjs} +1 -1
  44. package/dist-lib/esm-chunks/{chunk-GY6TE4B4.mjs → chunk-TXBZEHNH.mjs} +4 -4
  45. package/dist-lib/esm-chunks/{chunk-R3WTQB5J.mjs → chunk-UM4DCXPA.mjs} +1 -1
  46. package/dist-lib/esm-chunks/{chunk-GQ3EO2UV.mjs → chunk-UZPLSN2V.mjs} +1 -1
  47. package/dist-lib/esm-chunks/{chunk-QSFWBVUO.mjs → chunk-XFFPOSW2.mjs} +1 -1
  48. package/dist-lib/esm-chunks/{chunk-KDI5YYQ6.mjs → chunk-ZT5ZXQC2.mjs} +1 -1
  49. package/dist-lib/esm-chunks/{metro-layout-parser-EX65MARK.mjs → metro-layout-parser-DHGC2DVE.mjs} +3 -3
  50. package/dist-lib/esm-chunks/{swift-package-prebuilt-3BPDQVA7.mjs → swift-package-prebuilt-ROIDLGLU.mjs} +10 -10
  51. package/dist-lib/esm-chunks/{swift-sdk-app-module-CRX6E3TR.mjs → swift-sdk-app-module-5VU63S56.mjs} +30 -20
  52. package/dist-lib/esm-chunks/{swift-sdk-image-EJD5TPQH.mjs → swift-sdk-image-SNFZVUQ3.mjs} +14 -14
  53. package/dist-lib/esm-chunks/{swift-sdk-image-producer-QAZOSLTZ.mjs → swift-sdk-image-producer-5RQDIX53.mjs} +4 -4
  54. package/dist-lib/expo-swift-bundle.cjs +324 -235
  55. package/dist-lib/expo-swift-metadata.cjs +1 -1
  56. package/dist-lib/expo-swift-metadata.mjs +7 -7
  57. package/dist-lib/home-paths.cjs +1 -1
  58. package/dist-lib/host/bridge-host.cjs +421 -246
  59. package/dist-lib/host/fetch-proxy-handler.cjs +8 -7
  60. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  61. package/dist-lib/host/fetch-proxy-overrides.mjs +2 -2
  62. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  63. package/dist-lib/host/websocket-proxy.cjs +1 -1
  64. package/dist-lib/index.cjs +1 -1
  65. package/dist-lib/kotlin-host.cjs +1 -1
  66. package/dist-lib/menu.cjs +1 -1
  67. package/dist-lib/menu.mjs +3 -3
  68. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  69. package/dist-lib/metro-fingerprint-registry.mjs +3 -3
  70. package/dist-lib/metro-production-bundle.cjs +1 -1
  71. package/dist-lib/metro-production-bundle.mjs +4 -4
  72. package/dist-lib/native-app-identity-project.cjs +5 -5
  73. package/dist-lib/native-app-identity-project.mjs +16 -16
  74. package/dist-lib/native-app-identity.cjs +1 -1
  75. package/dist-lib/native-app-identity.mjs +6 -6
  76. package/dist-lib/native-firebase-metadata.cjs +1 -1
  77. package/dist-lib/native-firebase-metadata.mjs +3 -3
  78. package/dist-lib/pdfium-raster.cjs +1 -1
  79. package/dist-lib/pdfium-raster.mjs +2 -2
  80. package/dist-lib/plist.cjs +1 -1
  81. package/dist-lib/plist.mjs +3 -3
  82. package/dist-lib/profiles.cjs +1 -1
  83. package/dist-lib/public-brand.cjs +1 -1
  84. package/dist-lib/public-origins-lib-esm.json +81 -81
  85. package/dist-lib/public-origins-lib.json +71 -71
  86. package/dist-lib/react-native-host-modules.cjs +1 -1
  87. package/dist-lib/react-native-host-modules.mjs +2 -2
  88. package/dist-lib/reap-browser.cjs +1 -1
  89. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  90. package/dist-lib/sdk.cjs +1 -1
  91. package/dist-lib/sdk.mjs +8 -8
  92. package/dist-lib/skills.cjs +421 -246
  93. package/dist-lib/swift-compile.cjs +286 -230
  94. package/dist-lib/swift-compile.mjs +10 -10
  95. package/dist-lib/swift-package.cjs +1 -1
  96. package/dist-lib/swift-package.mjs +3 -3
  97. package/dist-lib/swift-submit.cjs +1 -1
  98. package/dist-lib/swift-submit.mjs +6 -6
  99. package/dist-lib/swift-svg-raster.cjs +1 -1
  100. package/dist-lib/swift-svg-raster.mjs +2 -2
  101. package/dist-lib/swift-toolchain.cjs +1 -1
  102. package/dist-lib/swift.cjs +1 -1
  103. package/dist-lib/vendor/@peculiar/x509.cjs +1 -1
  104. package/dist-lib/vendor/@ruby/prism/src/nodes.js.cjs +1 -1
  105. package/dist-lib/vendor/@ruby/prism/src/parsePrism.js.cjs +1 -1
  106. package/dist-lib/vendor/@xmldom/xmldom.cjs +1 -1
  107. package/dist-lib/vendor/acorn.cjs +1 -1
  108. package/dist-lib/vendor/bplist-parser.cjs +1 -1
  109. package/dist-lib/vendor/ignore.cjs +1 -1
  110. package/dist-lib/vendor/magic-string.cjs +1 -1
  111. package/dist-lib/vendor/plist.cjs +1 -1
  112. package/dist-lib/vendor/smol-toml.cjs +1 -1
  113. package/dist-lib/vendor/stream-json.cjs +1 -1
  114. package/dist-lib/vendor/sucrase/dist/index.js.cjs +1 -1
  115. package/dist-lib/vendor/sucrase/dist/parser/index.js.cjs +1 -1
  116. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/index.js.cjs +1 -1
  117. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/types.js.cjs +1 -1
  118. package/dist-lib/vendor/sucrase.cjs +1 -1
  119. package/dist-lib/vendor/terser.cjs +1 -1
  120. package/dist-lib/vendor/valibot.cjs +1 -1
  121. package/dist-lib/vendor/ws.cjs +1 -1
  122. package/dist-lib/vendor/zod.cjs +1 -1
  123. package/dist-lib/worklet-executable.cjs +1 -1
  124. package/dist-lib/worklet-executable.mjs +3 -3
  125. package/kotlin/sdk.tar.gz +0 -0
  126. package/package.json +1 -1
  127. package/src/binaryen.lock.json +3 -3
  128. package/src/one-native-controls-package.ts +95 -10
  129. package/src/one-sdk-preparation.ts +40 -2
  130. package/src/swift-guest-compile.ts +11 -2
  131. package/src/swift-guest-projection-storage.ts +45 -26
  132. package/src/swift-guest-runtime-plan.ts +1 -1
  133. package/src/swift-sdk-app-module.ts +15 -6
  134. package/src/swift-sdk-image-wasm.ts +5 -2
  135. package/src/swift-sdk-image.ts +69 -49
  136. package/src/swift-wasm-prune.ts +51 -34
  137. package/src/wasm-optimize.ts +146 -140
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2592 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2593 | (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;
@@ -5712,13 +5712,13 @@ var init_swift_standin_digest = __esm({
5712
5712
  STANDIN_DIGEST_ENTRYPOINTS = ["swift-standins.ts", "swift-objc-compile.ts"];
5713
5713
  SPECIFIER = /from\s*['"]([^'"]+)['"]|import\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
5714
5714
  standinSourceDigest = (srcDir = __sootsim_import_meta_dirname) => sourceClosureDigest(srcDir, STANDIN_DIGEST_ENTRYPOINTS);
5715
- STANDIN_SOURCE_DIGEST = true ? "b7465e4180ef2be70330a5488deb331c0846752c0495581fcd000574c0aa480a" : standinSourceDigest();
5715
+ STANDIN_SOURCE_DIGEST = true ? "63adfed92cb0f03f7e74bd25588e866da41eaddd5ff8c13d50802edd65706617" : standinSourceDigest();
5716
5716
  }
5717
5717
  });
5718
5718
 
5719
5719
  // src/expo-native-compiler-digest.ts
5720
5720
  function expoNativeCompilerDigestValue() {
5721
- return true ? "6dd152b897024269db5b53a1f9c613429fd3fd15506a4914a77c3b2638fe2018" : expoNativeCompilerDigest(__sootsim_import_meta_dirname);
5721
+ return true ? "f789d146b1dafe1d68a49954dc5d223e9c982fc7b6602945b530568758babb0a" : expoNativeCompilerDigest(__sootsim_import_meta_dirname);
5722
5722
  }
5723
5723
  var import_node_crypto11;
5724
5724
  var init_expo_native_compiler_digest = __esm({
@@ -31923,7 +31923,9 @@ async function selectOneSDK(appRoot) {
31923
31923
  const imports2 = /* @__PURE__ */ new Set();
31924
31924
  const skipped = /* @__PURE__ */ new Set(["node_modules", "ios", "android", "dist", "build", "types"]);
31925
31925
  async function scan3(directory2) {
31926
+ if (imports2.has("one")) return;
31926
31927
  for (const entry of import_node_fs49.default.readdirSync(directory2, { withFileTypes: true })) {
31928
+ if (imports2.has("one")) return;
31927
31929
  if (entry.name.startsWith(".") || skipped.has(entry.name)) continue;
31928
31930
  const file = import_node_path49.default.join(directory2, entry.name);
31929
31931
  if (entry.isDirectory()) await scan3(file);
@@ -31937,8 +31939,10 @@ async function selectOneSDK(appRoot) {
31937
31939
  });
31938
31940
  for (const match of code.matchAll(
31939
31941
  /(?:\bfrom\s*|\bimport\s*\(?\s*|\brequire\s*\(\s*)['"](one(?:\/ios\/[A-Za-z_][A-Za-z0-9_]*)?)(?:\/[^'"]*)?['"]/g
31940
- ))
31942
+ )) {
31941
31943
  imports2.add(match[1]);
31944
+ if (match[1] === "one") return;
31945
+ }
31942
31946
  }
31943
31947
  }
31944
31948
  }
@@ -32004,6 +32008,22 @@ async function prepareOneSDKSources(appRoot, output) {
32004
32008
  import_node_fs49.default.copyFileSync(import_node_path49.default.join(published4, name3), import_node_path49.default.join(directory2, name3));
32005
32009
  return;
32006
32010
  }
32011
+ const localCache = import_node_path49.default.join(swiftCacheDir(), "one-sdk-sources", entry.key);
32012
+ const localManifestPath = import_node_path49.default.join(localCache, "manifest.json");
32013
+ if (import_node_fs49.default.existsSync(localManifestPath)) {
32014
+ const manifest2 = readOneSDKSourceManifest(
32015
+ JSON.parse(import_node_fs49.default.readFileSync(localManifestPath, "utf8"))
32016
+ );
32017
+ if (manifest2.generation === generation && JSON.stringify(manifest2.frameworks) === JSON.stringify(selected.frameworks) && selected.frameworks.every(
32018
+ (name3) => manifest2.selection[name3] === selected.selection[name3]
32019
+ ) && manifest2.files.every((name3) => import_node_fs49.default.existsSync(import_node_path49.default.join(localCache, name3)))) {
32020
+ import_node_fs49.default.rmSync(directory2, { recursive: true, force: true });
32021
+ import_node_fs49.default.mkdirSync(directory2, { recursive: true });
32022
+ for (const name3 of [...manifest2.files, "manifest.json"])
32023
+ import_node_fs49.default.copyFileSync(import_node_path49.default.join(localCache, name3), import_node_path49.default.join(directory2, name3));
32024
+ return;
32025
+ }
32026
+ }
32007
32027
  const generated = await generateAppSdkInChild(
32008
32028
  import_node_path49.default.join(selected.one, "dist/sdk/app.mjs"),
32009
32029
  selected.frameworks,
@@ -32021,7 +32041,19 @@ async function prepareOneSDKSources(appRoot, output) {
32021
32041
  selection: selected.selection,
32022
32042
  files: [...generated.files.keys()]
32023
32043
  };
32024
- import_node_fs49.default.writeFileSync(import_node_path49.default.join(directory2, "manifest.json"), JSON.stringify(manifest));
32044
+ const manifestJson = JSON.stringify(manifest);
32045
+ import_node_fs49.default.writeFileSync(import_node_path49.default.join(directory2, "manifest.json"), manifestJson);
32046
+ import_node_fs49.default.mkdirSync(import_node_path49.default.dirname(localCache), { recursive: true });
32047
+ const staging = import_node_fs49.default.mkdtempSync(`${localCache}.tmp-`);
32048
+ try {
32049
+ for (const [name3, from] of generated.files)
32050
+ import_node_fs49.default.copyFileSync(from, import_node_path49.default.join(staging, name3));
32051
+ import_node_fs49.default.writeFileSync(import_node_path49.default.join(staging, "manifest.json"), manifestJson);
32052
+ import_node_fs49.default.renameSync(staging, localCache);
32053
+ } catch (error) {
32054
+ import_node_fs49.default.rmSync(staging, { recursive: true, force: true });
32055
+ if (!import_node_fs49.default.existsSync(localManifestPath)) throw error;
32056
+ }
32025
32057
  }
32026
32058
  var import_node_child_process21, import_node_crypto24, import_node_fs49, import_node_module8, import_node_os10, import_node_path49, import_node_url6, import_sucrase2, GENERATE_SCRIPT;
32027
32059
  var init_one_sdk_preparation = __esm({
@@ -32037,6 +32069,7 @@ var init_one_sdk_preparation = __esm({
32037
32069
  import_sucrase2 = require("peachsim/vendor/sucrase");
32038
32070
  init_native_prebuilt();
32039
32071
  init_oneSdkContract();
32072
+ init_swift_toolchain();
32040
32073
  GENERATE_SCRIPT = `
32041
32074
  import { writeFileSync } from 'node:fs'
32042
32075
  import { pathToFileURL } from 'node:url'
@@ -37042,6 +37075,7 @@ var init_swiftSdkLinkContract = __esm({
37042
37075
 
37043
37076
  // src/swift-sdk-image-wasm.ts
37044
37077
  function wasmReader(bytes, start) {
37078
+ const rawBuf = Buffer.isBuffer(bytes) ? bytes : Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
37045
37079
  let at = start;
37046
37080
  const u = () => {
37047
37081
  let value = 0;
@@ -37070,7 +37104,7 @@ function wasmReader(bytes, start) {
37070
37104
  name: () => {
37071
37105
  const length = u();
37072
37106
  at += length;
37073
- return Buffer.from(bytes.subarray(at - length, at)).toString();
37107
+ return rawBuf.toString("utf8", at - length, at);
37074
37108
  },
37075
37109
  skip: (length) => {
37076
37110
  at += length;
@@ -37424,7 +37458,7 @@ function codeOnlySdkImage(bytes, constructorMask) {
37424
37458
  const bodies = m.bodies.map(({ start, end }) => bytes.subarray(start, end));
37425
37459
  const initMemory = functionIndex("__wasm_init_memory") - m.importedFuncs;
37426
37460
  {
37427
- const body = Uint8Array.from(bodies[initMemory]);
37461
+ const body = new Uint8Array(bodies[initMemory]);
37428
37462
  const r = wasmReader(body, 0);
37429
37463
  if (r.u() !== 0) throw new Error("sdk memory initializer has locals");
37430
37464
  while (r.at < body.length) {
@@ -38460,7 +38494,18 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
38460
38494
  dataOwnerSymIdx[kept] = ownerSymIdx;
38461
38495
  kept++;
38462
38496
  }
38463
- const dataRelocs = {
38497
+ const dataRelocs = kept === rawData.count ? {
38498
+ count: kept,
38499
+ bytes: rawData.bytes,
38500
+ start: rawData.start,
38501
+ end: rawData.end,
38502
+ ro: rawData.ro,
38503
+ rs: rawData.rs,
38504
+ addend: rawData.addend,
38505
+ segIdx: dataSegIdx,
38506
+ offInSeg: dataOffInSeg,
38507
+ ownerSymIdx: dataOwnerSymIdx
38508
+ } : {
38464
38509
  count: kept,
38465
38510
  bytes: rawData.bytes,
38466
38511
  start: rawData.start.slice(0, kept),
@@ -38472,26 +38517,29 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
38472
38517
  offInSeg: dataOffInSeg.slice(0, kept),
38473
38518
  ownerSymIdx: dataOwnerSymIdx.slice(0, kept)
38474
38519
  };
38475
- const relocatedWords = /* @__PURE__ */ new Map();
38476
- for (let i = 0; i < dataRelocs.count; i++) {
38477
- const segIdx = dataRelocs.segIdx[i];
38478
- let words2 = relocatedWords.get(segIdx);
38479
- if (!words2) relocatedWords.set(segIdx, words2 = /* @__PURE__ */ new Set());
38480
- words2.add(dataRelocs.offInSeg[i]);
38481
- }
38482
- for (const [segIdx, tops] of segTopSyms) {
38483
- const starts = new Map(tops.map((top) => [top.off, top.symIdx]));
38484
- const relocated = relocatedWords.get(segIdx);
38485
- const payload = dataStart + sPayloadStarts[segIdx];
38486
- const view = new DataView(buf.buffer, buf.byteOffset + payload);
38487
- for (const top of tops) {
38488
- for (let at = top.off; at + 4 <= top.end; at += 4) {
38489
- if (relocated?.has(at)) continue;
38490
- const target = starts.get(at + (view.getInt32(at, true) & ~3));
38491
- if (target === void 0 || target === top.symIdx) continue;
38492
- let list2 = symDataRelocs.get(top.symIdx);
38493
- if (!list2) symDataRelocs.set(top.symIdx, list2 = []);
38494
- list2.push(target);
38520
+ if (segTopSyms.size > 0) {
38521
+ const relocatedWords = /* @__PURE__ */ new Map();
38522
+ for (let i = 0; i < dataRelocs.count; i++) {
38523
+ const segIdx = dataRelocs.segIdx[i];
38524
+ if (!segTopSyms.has(segIdx)) continue;
38525
+ let words2 = relocatedWords.get(segIdx);
38526
+ if (!words2) relocatedWords.set(segIdx, words2 = /* @__PURE__ */ new Set());
38527
+ words2.add(dataRelocs.offInSeg[i]);
38528
+ }
38529
+ for (const [segIdx, tops] of segTopSyms) {
38530
+ const starts = new Map(tops.map((top) => [top.off, top.symIdx]));
38531
+ const relocated = relocatedWords.get(segIdx);
38532
+ const payload = dataStart + sPayloadStarts[segIdx];
38533
+ const view = new DataView(buf.buffer, buf.byteOffset + payload);
38534
+ for (const top of tops) {
38535
+ for (let at = top.off; at + 4 <= top.end; at += 4) {
38536
+ if (relocated?.has(at)) continue;
38537
+ const target = starts.get(at + (view.getInt32(at, true) & ~3));
38538
+ if (target === void 0 || target === top.symIdx) continue;
38539
+ let list2 = symDataRelocs.get(top.symIdx);
38540
+ if (!list2) symDataRelocs.set(top.symIdx, list2 = []);
38541
+ list2.push(target);
38542
+ }
38495
38543
  }
38496
38544
  }
38497
38545
  }
@@ -38663,7 +38711,7 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
38663
38711
  };
38664
38712
  }
38665
38713
  function parseWasmObjectFile(file, isDist) {
38666
- return parseWasmObjectBytes(file, new Uint8Array(import_node_fs56.default.readFileSync(file)), isDist);
38714
+ return parseWasmObjectBytes(file, import_node_fs56.default.readFileSync(file), isDist);
38667
38715
  }
38668
38716
  function parseWasmObjectCached(file, isDist, entries2) {
38669
38717
  const key2 = `${isDist ? "1" : "0"}:${file}`;
@@ -38678,7 +38726,7 @@ function parseWasmObjectCached(file, isDist, entries2) {
38678
38726
  function localizeDefinedWasmSymbols(bytes, names) {
38679
38727
  const offsets = [];
38680
38728
  const object9 = parseWasmObjectBytes("", bytes, false, offsets);
38681
- const output = Uint8Array.from(bytes);
38729
+ const output = new Uint8Array(bytes);
38682
38730
  let changed2 = 0;
38683
38731
  for (let index = 0; index < object9.symNames.length; index++) {
38684
38732
  if (!names.has(object9.symNames[index])) continue;
@@ -42139,18 +42187,6 @@ function compactSparseWasmTable(bytes) {
42139
42187
  bytes.subarray(elements.end)
42140
42188
  ]);
42141
42189
  }
42142
- function hasWasmExport(bytes, name3) {
42143
- const section2 = wasmSections2(bytes).find((value) => value.id === 7);
42144
- if (!section2) return false;
42145
- const input = readWasmSection(bytes, section2.start, section2.end);
42146
- for (let count = input.number(); count > 0; count--) {
42147
- const found2 = input.name();
42148
- input.byte();
42149
- input.number();
42150
- if (found2 === name3) return true;
42151
- }
42152
- return false;
42153
- }
42154
42190
  function withSections(bytes, layout2, replacements) {
42155
42191
  const parts2 = [bytes.subarray(0, 8)];
42156
42192
  let at = 8;
@@ -42884,23 +42920,40 @@ function reserveGuestProjectionStorage(images, capacities) {
42884
42920
  };
42885
42921
  }
42886
42922
  function mergeGuestProjectionSpans(imageCount, spans) {
42887
- const sorted2 = [...spans].sort(
42888
- (a, b) => a.space.localeCompare(b.space) || a.address - b.address || a.image - b.image
42889
- );
42890
- const merged = [];
42891
- for (const span of sorted2) {
42923
+ const tableSpans = [];
42924
+ const memorySpans = [];
42925
+ for (const span of spans) {
42892
42926
  if (!Number.isInteger(span.image) || span.image < 0 || span.image >= imageCount || !Number.isInteger(span.address) || !Number.isInteger(span.length) || span.address < 0 || span.length <= 0 || span.address + span.length > 4294967296)
42893
42927
  throw new Error("invalid linked guest span");
42894
- const previous = merged[merged.length - 1];
42895
- if (previous && previous.space === span.space && span.address < previous.address + previous.length && previous.image !== span.image)
42896
- throw new Error("linked guest span has ambiguous image ownership");
42897
- if (previous && previous.space === span.space && previous.image === span.image && span.address <= previous.address + previous.length) {
42898
- merged[merged.length - 1] = {
42899
- ...previous,
42900
- length: Math.max(previous.address + previous.length, span.address + span.length) - previous.address
42901
- };
42902
- } else merged.push(span);
42928
+ if (span.space === "function-table") tableSpans.push(span);
42929
+ else memorySpans.push(span);
42903
42930
  }
42931
+ const byAddress = (a, b) => a.address - b.address || a.image - b.image;
42932
+ tableSpans.sort(byAddress);
42933
+ memorySpans.sort(byAddress);
42934
+ const merged = [];
42935
+ const mergeGroup = (group) => {
42936
+ let previous = null;
42937
+ for (const span of group) {
42938
+ if (previous && span.address < previous.address + previous.length && previous.image !== span.image)
42939
+ throw new Error("linked guest span has ambiguous image ownership");
42940
+ if (previous && previous.image === span.image && span.address <= previous.address + previous.length) {
42941
+ const end = span.address + span.length;
42942
+ if (end > previous.address + previous.length)
42943
+ previous.length = end - previous.address;
42944
+ } else {
42945
+ previous = {
42946
+ image: span.image,
42947
+ space: span.space,
42948
+ address: span.address,
42949
+ length: span.length
42950
+ };
42951
+ merged.push(previous);
42952
+ }
42953
+ }
42954
+ };
42955
+ mergeGroup(tableSpans);
42956
+ mergeGroup(memorySpans);
42904
42957
  return merged;
42905
42958
  }
42906
42959
  function guestProjectionRegionCounts(imageCount, spans) {
@@ -43096,7 +43149,7 @@ function sdkArtifactBytes(root, artifact) {
43096
43149
  const source = (0, import_node_fs59.readFileSync)(import_node_path59.default.join(sourceDirectory, "libFoundation.a"));
43097
43150
  if (hash(source) !== artifact.sha256)
43098
43151
  throw new Error(`SDK product artifact changed ${file}`);
43099
- const transformed = Uint8Array.from(source);
43152
+ const transformed = new Uint8Array(source);
43100
43153
  weakenFoundationOverridesInArchive(transformed);
43101
43154
  if (!linked.equals(transformed))
43102
43155
  throw new Error(`SDK view transformation changed ${file}`);
@@ -43636,17 +43689,17 @@ var init_binaryen_lock = __esm({
43636
43689
  "linux-x64": {
43637
43690
  asset: "x86_64-linux",
43638
43691
  upstreamSha256: "195ddc94f9bc89f45abdabb0b9eea86023d727ba90eac8b35b80f2544fc30572",
43639
- sha256: "feda0b3a5a24c902ec25e8d674f33c5771a0704e611a2e8e4800ab3c3fc591ca"
43692
+ sha256: "1024974f254c1c2edd738246ec6af5add16d3d36b5f58a94545febda3b33c869"
43640
43693
  },
43641
43694
  "linux-arm64": {
43642
43695
  asset: "aarch64-linux",
43643
43696
  upstreamSha256: "c58562417836c5d0493d89bdefc434933bdc097db641b483df86bcfa557a107f",
43644
- sha256: "0c67b9f36e9337afddf13b5150ab0e30bddf4f58633b02c4604f0cc87c2b89a2"
43697
+ sha256: "7dedfc9f5cb32e75a28831f3b5aa053fd3e0bdd74f73dc4d1b1588947236daef"
43645
43698
  },
43646
43699
  "darwin-arm64": {
43647
43700
  asset: "arm64-macos",
43648
43701
  upstreamSha256: "98aad827847af7ef990ed7098d885725c8e5b5aae75073403635617ae4e259aa",
43649
- sha256: "36373d0901b376c2868f09e0c2c303b1b7117b696e31dd661afa9711f31ea4a0"
43702
+ sha256: "0b56e0a06b6a873877871537a120fd94e2121e67f4bce5f8b5252c47b615854a"
43650
43703
  }
43651
43704
  }
43652
43705
  };
@@ -43675,6 +43728,45 @@ var init_wasm_features = __esm({
43675
43728
  });
43676
43729
 
43677
43730
  // src/wasm-optimize.ts
43731
+ function readWasmMemoryFromFile(file) {
43732
+ const fd = (0, import_node_fs60.openSync)(file, "r");
43733
+ try {
43734
+ const total = (0, import_node_fs60.fstatSync)(fd).size;
43735
+ const header = Buffer.allocUnsafe(8);
43736
+ if (total < 8 || (0, import_node_fs60.readSync)(fd, header, 0, 8, 0) < 8) return void 0;
43737
+ let offset = 8;
43738
+ const probe = Buffer.allocUnsafe(16);
43739
+ let prefixEnd = 8;
43740
+ while (offset < total) {
43741
+ const read = (0, import_node_fs60.readSync)(fd, probe, 0, Math.min(16, total - offset), offset);
43742
+ if (read < 2) break;
43743
+ const id = probe[0];
43744
+ let size2 = 0;
43745
+ let shift = 0;
43746
+ let at = 1;
43747
+ for (; ; ) {
43748
+ const byte = probe[at++];
43749
+ size2 += (byte & 127) * 2 ** shift;
43750
+ if (!(byte & 128)) break;
43751
+ shift += 7;
43752
+ }
43753
+ const next = offset + at + size2;
43754
+ if (id === 2 || id === 5) prefixEnd = next;
43755
+ if (id > 5) break;
43756
+ offset = next;
43757
+ }
43758
+ const prefix = Buffer.allocUnsafe(prefixEnd);
43759
+ let filled = 0;
43760
+ while (filled < prefixEnd) {
43761
+ const n = (0, import_node_fs60.readSync)(fd, prefix, filled, prefixEnd - filled, filled);
43762
+ if (n <= 0) break;
43763
+ filled += n;
43764
+ }
43765
+ return readWasmMemory(prefix.subarray(0, filled));
43766
+ } finally {
43767
+ (0, import_node_fs60.closeSync)(fd);
43768
+ }
43769
+ }
43678
43770
  async function runWasmOpt(file, output, optimize, skipPasses, binary2, sdkTableEnd, wideExports) {
43679
43771
  const admittedCores = windowAdmission()?.cores ?? Number(process.env.TM_EXEC_CPU_CORES);
43680
43772
  const requestedCores = Number(process.env.BINARYEN_CORES);
@@ -43691,25 +43783,75 @@ async function runWasmOpt(file, output, optimize, skipPasses, binary2, sdkTableE
43691
43783
  return;
43692
43784
  }
43693
43785
  const optimizeSize = optimize === true || optimize === "app-module";
43694
- const optimizeBeforeGuard = optimize === true;
43695
43786
  const relink = optimize === "relink";
43696
- const names = optimizeBeforeGuard && !KEEP_WASM_NAMES ? [] : ["-g"];
43697
- const outputNames = (optimizeSize || relink) && !KEEP_WASM_NAMES ? [] : names;
43698
- let input = (0, import_node_fs60.readFileSync)(file);
43699
- const memory = readWasmMemory(input);
43700
- const checked = `${output}.stack-checked`;
43787
+ const keepNames = !optimizeSize && !relink || KEEP_WASM_NAMES;
43788
+ const memory = readWasmMemoryFromFile(file);
43701
43789
  if (memory?.shared && memory.maximumPages !== 65536)
43702
43790
  throw new Error("threaded native memory must declare a 65536-page maximum");
43703
- if (memory?.shared && optimizeBeforeGuard) {
43704
- await runBinaryen(binary2, [...features, "-g", "--stack-check", file, "-o", checked], {
43705
- env: environment
43706
- });
43707
- input = (0, import_node_fs60.readFileSync)(checked);
43708
- if (!hasWasmExport(input, "__set_stack_limits"))
43709
- throw new Error(
43710
- "threaded native artifact must retain its __stack_pointer name for bounds checks"
43791
+ if (memory?.shared) {
43792
+ const wideExportsFile = wideExports.size ? `${output}.wide-exports` : void 0;
43793
+ const tableTool = (0, import_node_path60.join)((0, import_node_path60.dirname)(binary2), "wasm-table-guard");
43794
+ try {
43795
+ if (wideExportsFile)
43796
+ (0, import_node_fs60.writeFileSync)(wideExportsFile, [...wideExports].join("\n") + "\n");
43797
+ const pipelineArgs = [
43798
+ "--pipeline",
43799
+ "--in",
43800
+ file,
43801
+ "--out",
43802
+ output,
43803
+ "--narrow",
43804
+ ...wideExportsFile ? ["--wide-exports-file", wideExportsFile] : [],
43805
+ "--lower",
43806
+ "--shared",
43807
+ ...keepNames ? ["--debug"] : [],
43808
+ ...sdkTableEnd !== void 0 ? ["--slots-range", "1", String(sdkTableEnd), "--adapt"] : [],
43809
+ ...optimizeSize ? ["--optimize", "oz"] : relink ? ["--optimize", "relink"] : [],
43810
+ ...skipPasses.flatMap((pass) => ["--skip-pass", pass])
43811
+ ];
43812
+ const { stdout } = await runBinaryen(tableTool, pipelineArgs, { env: environment });
43813
+ const metadata = JSON.parse(stdout);
43814
+ if (typeof metadata !== "object" || metadata === null || !("tableMinimum" in metadata) || typeof metadata.tableMinimum !== "number" || !Number.isSafeInteger(metadata.tableMinimum) || metadata.tableMinimum < 0)
43815
+ throw new Error("native table tool returned an invalid table minimum");
43816
+ const sectionName = new TextEncoder().encode(NATIVE_IMAGE_SECTION);
43817
+ const layout2 = new TextEncoder().encode(
43818
+ JSON.stringify({
43819
+ initialPages: memory.initialPages,
43820
+ tableMinimum: metadata.tableMinimum
43821
+ })
43711
43822
  );
43823
+ const encode2 = (value) => {
43824
+ const bytes2 = [];
43825
+ do {
43826
+ const byte = value & 127;
43827
+ value >>>= 7;
43828
+ bytes2.push(byte | (value ? 128 : 0));
43829
+ } while (value);
43830
+ return bytes2;
43831
+ };
43832
+ const body = new Uint8Array([
43833
+ ...encode2(sectionName.length),
43834
+ ...sectionName,
43835
+ ...layout2
43836
+ ]);
43837
+ const bytes = (0, import_node_fs60.readFileSync)(output);
43838
+ (0, import_node_fs60.writeFileSync)(
43839
+ output,
43840
+ Buffer.concat([
43841
+ sdkTableEnd === void 0 ? withWasmTableMinimum(
43842
+ bytes,
43843
+ metadata.tableMinimum + NATIVE_TABLE_RESERVE_SLOTS
43844
+ ) : bytes,
43845
+ Buffer.from([0, ...encode2(body.length), ...body])
43846
+ ])
43847
+ );
43848
+ } finally {
43849
+ if (wideExportsFile) (0, import_node_fs60.rmSync)(wideExportsFile, { force: true });
43850
+ }
43851
+ return;
43712
43852
  }
43853
+ const outputNames = keepNames ? ["-g"] : [];
43854
+ const input = (0, import_node_fs60.readFileSync)(file);
43713
43855
  const narrowed = narrowWasmBoundary(input, wideExports);
43714
43856
  const merged = `${output}.narrowed`;
43715
43857
  if (narrowed) {
@@ -43721,7 +43863,7 @@ async function runWasmOpt(file, output, optimize, skipPasses, binary2, sdkTableE
43721
43863
  (0, import_node_path60.join)((0, import_node_path60.dirname)(binary2), "wasm-merge"),
43722
43864
  [
43723
43865
  ...features,
43724
- ...names,
43866
+ ...outputNames,
43725
43867
  guest,
43726
43868
  NARROW_MERGE_NAMES.guest,
43727
43869
  thunks,
@@ -43735,118 +43877,25 @@ async function runWasmOpt(file, output, optimize, skipPasses, binary2, sdkTableE
43735
43877
  (0, import_node_fs60.rmSync)(guest);
43736
43878
  (0, import_node_fs60.rmSync)(thunks);
43737
43879
  }
43738
- const lowered = memory?.shared ? `${output}.lowered` : output;
43739
- const compiled = narrowed ? merged : memory?.shared && optimizeBeforeGuard ? checked : file;
43880
+ const compiled = narrowed ? merged : file;
43740
43881
  const skip = skipPasses.flatMap((pass) => ["--skip-pass", pass]);
43741
43882
  try {
43742
- if (!memory?.shared || optimizeBeforeGuard)
43743
- await runBinaryen(
43744
- binary2,
43745
- [
43746
- ...LOWERING,
43747
- ...optimizeSize ? ["-Oz"] : relink ? RELINK_PASSES : [],
43748
- ...outputNames,
43749
- ...skip,
43750
- ...features,
43751
- compiled,
43752
- "-o",
43753
- lowered
43754
- ],
43755
- { env: environment, maxBuffer: Infinity }
43756
- );
43757
- if (memory?.shared) {
43758
- const guarded = `${output}.table.wasm`;
43759
- const sdkGuarded = `${output}.sdk-table.wasm`;
43760
- const sdkSlots = `${output}.sdk-table-slots`;
43761
- const tableTool = (0, import_node_path60.join)((0, import_node_path60.dirname)(binary2), "wasm-table-guard");
43762
- try {
43763
- const { stdout } = await runBinaryen(
43764
- tableTool,
43765
- [
43766
- optimizeBeforeGuard ? lowered : compiled,
43767
- guarded,
43768
- names.length ? "1" : "0",
43769
- ...optimizeBeforeGuard ? [] : ["lower"]
43770
- ],
43771
- { env: environment }
43772
- );
43773
- const metadata = JSON.parse(stdout);
43774
- if (typeof metadata !== "object" || metadata === null || !("tableMinimum" in metadata) || typeof metadata.tableMinimum !== "number" || !Number.isSafeInteger(metadata.tableMinimum) || metadata.tableMinimum < 0)
43775
- throw new Error("native table tool returned an invalid table minimum");
43776
- if (sdkTableEnd !== void 0) {
43777
- (0, import_node_fs60.writeFileSync)(
43778
- sdkSlots,
43779
- Array.from({ length: sdkTableEnd - 1 }, (_, index) => index + 1).join("\n")
43780
- );
43781
- await runBinaryen(
43782
- tableTool,
43783
- [guarded, sdkGuarded, names.length ? "1" : "0", "0", sdkSlots, "adapt"],
43784
- { env: environment }
43785
- );
43786
- (0, import_node_fs60.renameSync)(sdkGuarded, guarded);
43787
- }
43788
- if (optimize)
43789
- await runBinaryen(
43790
- binary2,
43791
- [
43792
- ...features,
43793
- // an adapted call tests its target's type with a typed function reference.
43794
- ...sdkTableEnd === void 0 ? [] : ["--enable-gc"],
43795
- ...optimizeSize ? ["-Oz"] : RELINK_PASSES,
43796
- ...outputNames,
43797
- ...skip,
43798
- guarded,
43799
- "-o",
43800
- output
43801
- ],
43802
- { env: environment }
43803
- );
43804
- const sectionName = new TextEncoder().encode(NATIVE_IMAGE_SECTION);
43805
- const layout2 = new TextEncoder().encode(
43806
- JSON.stringify({
43807
- initialPages: memory.initialPages,
43808
- tableMinimum: metadata.tableMinimum
43809
- })
43810
- );
43811
- const encode2 = (value) => {
43812
- const bytes2 = [];
43813
- do {
43814
- const byte = value & 127;
43815
- value >>>= 7;
43816
- bytes2.push(byte | (value ? 128 : 0));
43817
- } while (value);
43818
- return bytes2;
43819
- };
43820
- const body = new Uint8Array([
43821
- ...encode2(sectionName.length),
43822
- ...sectionName,
43823
- ...layout2
43824
- ]);
43825
- const image = optimize ? output : guarded;
43826
- const bytes = (0, import_node_fs60.readFileSync)(image);
43827
- (0, import_node_fs60.writeFileSync)(
43828
- image,
43829
- Buffer.concat([
43830
- sdkTableEnd === void 0 ? withWasmTableMinimum(
43831
- bytes,
43832
- metadata.tableMinimum + NATIVE_TABLE_RESERVE_SLOTS
43833
- ) : bytes,
43834
- Buffer.from([0, ...encode2(body.length), ...body])
43835
- ])
43836
- );
43837
- if (!optimize) (0, import_node_fs60.renameSync)(guarded, output);
43838
- } finally {
43839
- (0, import_node_fs60.rmSync)(guarded, { force: true });
43840
- (0, import_node_fs60.rmSync)(sdkGuarded, { force: true });
43841
- (0, import_node_fs60.rmSync)(sdkSlots, { force: true });
43842
- }
43843
- }
43883
+ await runBinaryen(
43884
+ binary2,
43885
+ [
43886
+ ...LOWERING,
43887
+ ...optimizeSize ? ["-Oz"] : relink ? RELINK_PASSES : [],
43888
+ ...outputNames,
43889
+ ...skip,
43890
+ ...features,
43891
+ compiled,
43892
+ "-o",
43893
+ output
43894
+ ],
43895
+ { env: environment, maxBuffer: Infinity }
43896
+ );
43844
43897
  } finally {
43845
43898
  if (narrowed) (0, import_node_fs60.rmSync)(merged, { force: true });
43846
- if (memory?.shared) {
43847
- (0, import_node_fs60.rmSync)(checked, { force: true });
43848
- (0, import_node_fs60.rmSync)(lowered, { force: true });
43849
- }
43850
43899
  }
43851
43900
  }
43852
43901
  async function installWasmOpt() {
@@ -48993,9 +49042,11 @@ async function linkSwiftSdkImage(moduleRoot, key2, directory2, work, scopedLooku
48993
49042
  objects.push({ path: object9, bytes, instrumentDynamicLookups: false });
48994
49043
  guestObjects.set(product, objects);
48995
49044
  };
48996
- const classifyFile = (file) => {
49045
+ const classifyFile = (file, collectAutolink = false) => {
48997
49046
  const bytes = (0, import_node_fs70.readFileSync)(file);
48998
49047
  if (!file.endsWith(".a")) {
49048
+ if (collectAutolink)
49049
+ for (const library of autolinkLibraries(bytes)) libraries.add(library);
48999
49050
  const scoped = lookups2?.rewrite(file, bytes) ?? bytes;
49000
49051
  return addObject(file, scoped, file);
49001
49052
  }
@@ -49003,6 +49054,8 @@ async function linkSwiftSdkImage(moduleRoot, key2, directory2, work, scopedLooku
49003
49054
  (0, import_node_fs70.mkdirSync)(import_node_path70.default.join(members2, archive));
49004
49055
  const ordinals = /* @__PURE__ */ new Map();
49005
49056
  readArMembers(bytes).forEach((member, index) => {
49057
+ if (collectAutolink)
49058
+ for (const library of autolinkLibraries(member.bytes)) libraries.add(library);
49006
49059
  const object9 = import_node_path70.default.join(members2, archive, `${index}-${import_node_path70.default.basename(member.name)}`);
49007
49060
  const ordinal = (ordinals.get(member.name) ?? 0) + 1;
49008
49061
  ordinals.set(member.name, ordinal);
@@ -49017,9 +49070,7 @@ async function linkSwiftSdkImage(moduleRoot, key2, directory2, work, scopedLooku
49017
49070
  });
49018
49071
  };
49019
49072
  for (const object9 of [...link.objects, ...link.providers]) {
49020
- classifyFile(object9);
49021
- for (const bytes of objectMembers(object9))
49022
- for (const library of autolinkLibraries(bytes)) libraries.add(library);
49073
+ classifyFile(object9, true);
49023
49074
  }
49024
49075
  for (const library of libraries) {
49025
49076
  if (unpacked.has(library.slice(2))) continue;
@@ -49032,6 +49083,7 @@ async function linkSwiftSdkImage(moduleRoot, key2, directory2, work, scopedLooku
49032
49083
  const hostExports = sdkHostExports(appRoot);
49033
49084
  const guestMap = /* @__PURE__ */ new Map();
49034
49085
  const guestMetadataNames = {};
49086
+ const compiles = [];
49035
49087
  if (lookups2) {
49036
49088
  const ledger = lookups2.link(guestObjects, [
49037
49089
  ...hostExports,
@@ -49067,33 +49119,38 @@ async function linkSwiftSdkImage(moduleRoot, key2, directory2, work, scopedLooku
49067
49119
  const scopeLedger = import_node_path70.default.join(work, "guest-ledger.ll");
49068
49120
  const scopeObject = import_node_path70.default.join(work, "guest-ledger.o");
49069
49121
  (0, import_node_fs70.writeFileSync)(scopeLedger, ledger.llvmIR);
49070
- await run4(import_node_path70.default.join(toolchain.toolchainBin, "clang"), [
49071
- `--target=${SWIFT_WASM_TRIPLE}`,
49072
- "-matomics",
49073
- "-mbulk-memory",
49074
- "-c",
49075
- scopeLedger,
49076
- "-o",
49077
- scopeObject
49078
- ]);
49122
+ compiles.push(
49123
+ run4(import_node_path70.default.join(toolchain.toolchainBin, "clang"), [
49124
+ `--target=${SWIFT_WASM_TRIPLE}`,
49125
+ "-matomics",
49126
+ "-mbulk-memory",
49127
+ "-c",
49128
+ scopeLedger,
49129
+ "-o",
49130
+ scopeObject
49131
+ ])
49132
+ );
49079
49133
  eager.push(scopeObject);
49080
49134
  }
49081
49135
  (0, import_node_fs70.writeFileSync)(
49082
49136
  import_node_path70.default.join(work, "image-tables.c"),
49083
49137
  IMAGE_TABLES + (guestLookups?.source ?? "")
49084
49138
  );
49085
- await run4(import_node_path70.default.join(toolchain.toolchainBin, "clang"), [
49086
- `--target=${SWIFT_WASM_TRIPLE}`,
49087
- "-O2",
49088
- "-matomics",
49089
- "-mbulk-memory",
49090
- "-ffreestanding",
49091
- ...lookups2 ? ["-DPEACH_SDK_GUEST_LINK"] : [],
49092
- "-c",
49093
- import_node_path70.default.join(work, "image-tables.c"),
49094
- "-o",
49095
- tables
49096
- ]);
49139
+ compiles.push(
49140
+ run4(import_node_path70.default.join(toolchain.toolchainBin, "clang"), [
49141
+ `--target=${SWIFT_WASM_TRIPLE}`,
49142
+ "-O2",
49143
+ "-matomics",
49144
+ "-mbulk-memory",
49145
+ "-ffreestanding",
49146
+ ...lookups2 ? ["-DPEACH_SDK_GUEST_LINK"] : [],
49147
+ "-c",
49148
+ import_node_path70.default.join(work, "image-tables.c"),
49149
+ "-o",
49150
+ tables
49151
+ ])
49152
+ );
49153
+ await Promise.all(compiles);
49097
49154
  const quote3 = (value) => JSON.stringify(value);
49098
49155
  (0, import_node_fs70.writeFileSync)(
49099
49156
  import_node_path70.default.join(work, "exports.rsp"),
@@ -49152,23 +49209,31 @@ async function linkSwiftSdkImage(moduleRoot, key2, directory2, work, scopedLooku
49152
49209
  if (mask === void 0) throw new Error("sdk image lacks its constructor mask");
49153
49210
  const code = import_node_path70.default.join(work, "code.wasm");
49154
49211
  (0, import_node_fs70.writeFileSync)(code, codeOnlySdkImage(finished2, mask));
49155
- await lowerWasm(code, import_node_path70.default.join(work, IMAGE_FILE), {
49212
+ const lowerPromise = lowerWasm(code, import_node_path70.default.join(work, IMAGE_FILE), {
49156
49213
  optimize: true,
49157
49214
  skipPasses: lookups2 ? ["duplicate-function-elimination"] : void 0
49158
49215
  });
49216
+ await new Promise((resolve11) => setImmediate(resolve11));
49217
+ try {
49218
+ writeSdkManifest(
49219
+ work,
49220
+ linkMap,
49221
+ linkedBytes,
49222
+ finished2,
49223
+ (0, import_node_fs70.readFileSync)(withRelocs),
49224
+ functionSlots,
49225
+ lookups2 && { inputs: guestMap, metadataNames: guestMetadataNames }
49226
+ );
49227
+ } catch (error) {
49228
+ await lowerPromise.catch(() => {
49229
+ });
49230
+ throw error;
49231
+ }
49232
+ await lowerPromise;
49159
49233
  const image = (0, import_node_fs70.readFileSync)(import_node_path70.default.join(work, IMAGE_FILE));
49160
49234
  sdkInterface.layout.tableEnd += unslottedFunctions(image);
49161
49235
  if (sdkInterface.layout.tableEnd > SWIFT_SDK_APP_TABLE_BASE)
49162
49236
  throw new Error("Swift SDK image exceeds its reserved function table range");
49163
- writeSdkManifest(
49164
- work,
49165
- linkMap,
49166
- linkedBytes,
49167
- finished2,
49168
- (0, import_node_fs70.readFileSync)(withRelocs),
49169
- functionSlots,
49170
- lookups2 && { inputs: guestMap, metadataNames: guestMetadataNames }
49171
- );
49172
49237
  (0, import_node_fs70.writeFileSync)(import_node_path70.default.join(work, INTERFACE_FILE), JSON.stringify(sdkInterface));
49173
49238
  (0, import_node_fs70.writeFileSync)(
49174
49239
  import_node_path70.default.join(work, IMAGE_DIGEST),
@@ -49237,14 +49302,11 @@ function sdkLinkInputs(appRoot) {
49237
49302
  if (!crt) throw new Error("the sdk image link found no reactor startup object");
49238
49303
  return { flags, libraries, objects: [crt, ...objects], providers };
49239
49304
  }
49240
- function objectMembers(file) {
49241
- const bytes = (0, import_node_fs70.readFileSync)(file);
49242
- return file.endsWith(".a") ? readArMembers(bytes).map((member) => member.bytes) : [bytes];
49243
- }
49244
49305
  function autolinkLibraries(bytes) {
49245
49306
  const entries2 = wasmSections(bytes).find((s) => s.name === ".swift1_autolink_entries");
49246
49307
  if (!entries2) return [];
49247
- return Buffer.from(bytes.subarray(entries2.start, entries2.end)).toString().split("\0").filter((entry) => entry.startsWith("-l"));
49308
+ const raw2 = Buffer.isBuffer(bytes) ? bytes : Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
49309
+ return raw2.toString("utf8", entries2.start, entries2.end).split("\0").filter((entry) => entry.startsWith("-l"));
49248
49310
  }
49249
49311
  function sdkHostExports(appRoot) {
49250
49312
  const release = import_node_path70.default.join(appRoot, ".build", SWIFT_WASM_TRIPLE, "release");
@@ -49330,9 +49392,17 @@ function writeSdkManifest(work, map2, linked, finished2, withRelocs, functionSlo
49330
49392
  return { starts, targets };
49331
49393
  };
49332
49394
  const byAddress = (edges2) => {
49333
- const pairs2 = [];
49334
- for (let i = 0; i < edges2.length; i += 2) pairs2.push([edges2[i], edges2[i + 1]]);
49335
- return pairs2.sort((a, b) => a[0] - b[0]).flat();
49395
+ const count = edges2.length >>> 1;
49396
+ const order = new Uint32Array(count);
49397
+ for (let i = 0; i < count; i++) order[i] = i;
49398
+ order.sort((a, b) => edges2[a * 2] - edges2[b * 2]);
49399
+ const sorted2 = new Uint32Array(edges2.length);
49400
+ for (let i = 0; i < count; i++) {
49401
+ const src = order[i] * 2;
49402
+ sorted2[i * 2] = edges2[src];
49403
+ sorted2[i * 2 + 1] = edges2[src + 1];
49404
+ }
49405
+ return sorted2;
49336
49406
  };
49337
49407
  const functionData = flatten2(edges.code);
49338
49408
  const functionCalls = flatten2(edges.calls);
@@ -49754,12 +49824,22 @@ async function buildSwiftAppModule(options2) {
49754
49824
  work,
49755
49825
  readInput
49756
49826
  });
49757
- await link.lower();
49758
- const usage = readSwiftSdkUsage(
49759
- project2 ? projectOutputFile(buildRoot, map2, project2) : map2,
49760
- pruned
49761
- );
49762
- const binding = createSwiftSdkBinding(link.linkage, sdk2, usage);
49827
+ const lowerPromise = link.lower();
49828
+ await new Promise((resolve11) => setImmediate(resolve11));
49829
+ let usage;
49830
+ let binding;
49831
+ try {
49832
+ usage = readSwiftSdkUsage(
49833
+ project2 ? projectOutputFile(buildRoot, map2, project2) : map2,
49834
+ pruned
49835
+ );
49836
+ binding = createSwiftSdkBinding(link.linkage, sdk2, usage);
49837
+ } catch (error) {
49838
+ await lowerPromise.catch(() => {
49839
+ });
49840
+ throw error;
49841
+ }
49842
+ await lowerPromise;
49763
49843
  if (!project2)
49764
49844
  writeSwiftSdkAppLink(import_node_path71.default.join(work, "app-link.json.gz"), {
49765
49845
  linkage: link.linkage,
@@ -51669,7 +51749,6 @@ async function compileGuestLink(options2) {
51669
51749
  bindingRows.set((address - values.address) / 8, value);
51670
51750
  } else data.push(address, size2, value);
51671
51751
  }
51672
- const binding = createSwiftSdkBinding2({ ...link.linkage, data }, sdk2, usage);
51673
51752
  const linked = (0, import_node_fs72.readFileSync)(
51674
51753
  project2 ? projectOutputFile(work, linkedModule, project2) : linkedModule
51675
51754
  );
@@ -51694,7 +51773,17 @@ async function compileGuestLink(options2) {
51694
51773
  );
51695
51774
  continue;
51696
51775
  }
51697
- await link.lower();
51776
+ const lowerPromise = link.lower();
51777
+ await new Promise((resolve11) => setImmediate(resolve11));
51778
+ let binding;
51779
+ try {
51780
+ binding = createSwiftSdkBinding2({ ...link.linkage, data }, sdk2, usage);
51781
+ } catch (error) {
51782
+ await lowerPromise.catch(() => {
51783
+ });
51784
+ throw error;
51785
+ }
51786
+ await lowerPromise;
51698
51787
  const finalized = finalizeGuestProjectionStorage({
51699
51788
  map: map3,
51700
51789
  linked,
@@ -59418,7 +59507,7 @@ ${wasmThreadLinkFlags.map((flag) => ` "-Xlinker", ${JSON.stringify(flag
59418
59507
  REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
59419
59508
  MULTI_MANIFEST_VERSION = 76;
59420
59509
  SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
59421
- compilerSourceDigest = true ? "57c5faa7bb7758647030422e32db0f4a53fbab724723e220c14fea1e41d2391e" : swiftCompilerSourceDigest2(__sootsim_import_meta_dirname);
59510
+ compilerSourceDigest = true ? "834b5c28c27bc5807cbb3c4eed5c44f7de81d47db3e3a8819bea6e6635689b24" : swiftCompilerSourceDigest2(__sootsim_import_meta_dirname);
59422
59511
  nativeCxxCompilerFlags = ["-fno-cxx-modules"];
59423
59512
  MODULE_MAP_RESPONSE_FILE_RUN = 16;
59424
59513
  cFlagArray = (flags) => JSON.stringify(withoutGlogModuleMap(flags));
@@ -115389,6 +115478,7 @@ function swiftGuestControls(one, names, linkedGroups) {
115389
115478
  return {
115390
115479
  source: [
115391
115480
  "import UIKit",
115481
+ ...names.includes("OneNativePicker") ? ["extension OneNativePickerView: OneGuestIncrementalContainer {}"] : [],
115392
115482
  "let guestControls: [String: (UIView?, Spec, Spec?, Spec, @escaping (String, Spec) -> Void) -> UIView] = [",
115393
115483
  ...entries2,
115394
115484
  "]",
@@ -116077,11 +116167,55 @@ private func normalizeStyle(_ raw: Spec?) -> Spec {
116077
116167
  return style
116078
116168
  }
116079
116169
 
116170
+ protocol OneGuestIncrementalContainer: AnyObject {
116171
+ func insertChild(_ child: UIView, at index: Int)
116172
+ func removeChild(_ child: UIView)
116173
+ func reset()
116174
+ }
116175
+
116176
+ private final class DeferredControl {
116177
+ private let composition = ControlComposition()
116178
+ private var node: Spec
116179
+ private lazy var realized = OneNativeDeferredRow(
116180
+ createView: { [weak self] in self?.render() },
116181
+ releaseView: { [weak self] _ in self?.composition.prune(keeping: []) }
116182
+ )
116183
+
116184
+ init(node: Spec, owner: ControlComposition) {
116185
+ self.node = node
116186
+ composition.emit = { [weak owner] name, fields in owner?.emit?(name, fields) }
116187
+ }
116188
+
116189
+ func update(_ node: Spec, content: Spec) -> OneNativeDeferredRow {
116190
+ self.node = node
116191
+ realized.configureListRowModifiers(
116192
+ styleModifiers(node),
116193
+ contentModifiers: styleModifiers(content)
116194
+ )
116195
+ if !composition.views.isEmpty { _ = render() }
116196
+ return realized
116197
+ }
116198
+
116199
+ private func styleModifiers(_ node: Spec) -> String? {
116200
+ let spec = node["spec"] as? Spec
116201
+ let style = spec?["swiftStyle"] as? Spec
116202
+ return style?["sdkModifiers"] as? String
116203
+ }
116204
+
116205
+ private func render() -> UIView {
116206
+ var visited = Set<String>()
116207
+ let view = composition.render(node, visited: &visited)
116208
+ composition.prune(keeping: visited)
116209
+ return view
116210
+ }
116211
+ }
116212
+
116080
116213
  private class ControlComposition {
116081
116214
  private static let reconciledContainers: Set<String> = [
116082
116215
  "OneNativeLazyVStack", "OneNativeLazyHStack", "OneNativeLazyVGrid", "OneNativeLazyHGrid",
116083
116216
  "OneNativeList", "OneNativeSection", "OneNativeForm",
116084
116217
  ]
116218
+ private var deferredRows: [String: DeferredControl] = [:]
116085
116219
  var views: [String: UIView] = [:]
116086
116220
  var specs: [String: Spec] = [:]
116087
116221
  var children: [String: [UIView]] = [:]
@@ -116117,6 +116251,7 @@ private class ControlComposition {
116117
116251
  }
116118
116252
  let view: UIView
116119
116253
  visited.insert(id)
116254
+ deferredRows.removeValue(forKey: id)
116120
116255
  switch control {
116121
116256
  case "OneNativeToolbar":
116122
116257
  view = views[id] ?? OneNativeToolbarView()
@@ -116161,25 +116296,63 @@ private class ControlComposition {
116161
116296
  if let container = view as? OneNativeContainerView {
116162
116297
  container.configureSwiftStyle(style)
116163
116298
  container.onSwiftStyleEvent = visit
116164
- let nested = (node["children"] as? [Spec] ?? []).map { render($0, visited: &visited) }
116299
+ let nodes = node["children"] as? [Spec] ?? []
116165
116300
  if Self.reconciledContainers.contains(control) {
116301
+ let nested = nodes.map { child -> NSObject in
116302
+ if control == "OneNativeSection", let content = deferredContent(child) {
116303
+ let childID = child["id"] as! String
116304
+ visited.insert(childID)
116305
+ let deferred = deferredRows[childID] ?? DeferredControl(node: child, owner: self)
116306
+ deferredRows[childID] = deferred
116307
+ if let previous = views.removeValue(forKey: childID) {
116308
+ (previous as? OneNativeContainerView)?.reset()
116309
+ specs.removeValue(forKey: childID)
116310
+ children.removeValue(forKey: childID)
116311
+ }
116312
+ return deferred.update(child, content: content)
116313
+ }
116314
+ return render(child, visited: &visited)
116315
+ }
116166
116316
  container.reconcileComposedChildren(nested)
116167
116317
  } else {
116168
- reconcile(
116169
- nested,
116170
- previous: children[id] ?? [],
116171
- remove: container.removeChild,
116172
- insert: container.insertChild
116173
- )
116318
+ placeIncrementally(node, id: id, visited: &visited, remove: container.removeChild, insert: container.insertChild)
116174
116319
  }
116175
- children[id] = nested
116320
+ } else if let container = view as? OneGuestIncrementalContainer {
116321
+ placeIncrementally(node, id: id, visited: &visited, remove: container.removeChild, insert: container.insertChild)
116176
116322
  }
116177
116323
  return view
116178
116324
  }
116179
116325
 
116326
+ private func deferredContent(_ node: Spec) -> Spec? {
116327
+ guard (node["spec"] as? Spec)?["control"] as? String == "OneNativeSwipeActions" else { return nil }
116328
+ let content = (node["children"] as? [Spec] ?? []).filter {
116329
+ ($0["spec"] as? Spec)?["control"] as? String != "OneNativeSwipeActionsActions"
116330
+ }
116331
+ guard content.count == 1, (content[0]["spec"] as? Spec)?["control"] as? String == "OneNativeButton" else {
116332
+ return nil
116333
+ }
116334
+ return content[0]
116335
+ }
116336
+
116337
+ private func placeIncrementally(
116338
+ _ node: Spec,
116339
+ id: String,
116340
+ visited: inout Set<String>,
116341
+ remove: (UIView) -> Void,
116342
+ insert: (UIView, Int) -> Void
116343
+ ) {
116344
+ let nested = (node["children"] as? [Spec] ?? []).map { render($0, visited: &visited) }
116345
+ reconcile(nested, previous: children[id] ?? [], remove: remove, insert: insert)
116346
+ children[id] = nested
116347
+ }
116348
+
116180
116349
  func prune(keeping visited: Set<String>) {
116350
+ for id in deferredRows.keys where !visited.contains(id) {
116351
+ deferredRows.removeValue(forKey: id)
116352
+ }
116181
116353
  for (id, view) in views where !visited.contains(id) {
116182
116354
  if let container = view as? OneNativeContainerView { container.reset() }
116355
+ if let container = view as? OneGuestIncrementalContainer { container.reset() }
116183
116356
  views.removeValue(forKey: id)
116184
116357
  specs.removeValue(forKey: id)
116185
116358
  children.removeValue(forKey: id)
@@ -116490,8 +116663,10 @@ private struct NavigationSplitViewBridge: UIViewRepresentable {
116490
116663
  default:
116491
116664
  let root = spec["root"] as! Spec
116492
116665
  precondition((root["spec"] as? Spec)?["control"] as? String == view)
116493
- return AnyView(ControlBridge(root: root, emit: emit)
116494
- .frame(minWidth: 0, maxWidth: .infinity, maxHeight: .infinity))
116666
+ let bridge = ControlBridge(root: root, emit: emit)
116667
+ .frame(minWidth: 0, maxWidth: .infinity, maxHeight: .infinity)
116668
+ let height = (spec["height"] as? Double).map { CGFloat($0) }
116669
+ return AnyView(bridge.frame(height: height))
116495
116670
  }
116496
116671
  }
116497
116672
  }
@@ -120927,7 +121102,7 @@ var init_nitro_superset = __esm({
120927
121102
  init_nitroContract();
120928
121103
  init_swift_standin_digest();
120929
121104
  NITRO_SUPERSET_ENTRY_NAME = "superset";
120930
- NITRO_COMPILER_DIGEST = true ? "e01e1c3d6e35736e741ffd0453be8034714f762be77301de80740ac116cde52b" : nitroCompilerSourceDigest(__sootsim_import_meta_dirname, STANDIN_SOURCE_DIGEST2);
121105
+ NITRO_COMPILER_DIGEST = true ? "dc3119a2538cec9d009fc6b45b9a7c5729812bb7e7f263707bd7410c45a4719e" : nitroCompilerSourceDigest(__sootsim_import_meta_dirname, STANDIN_SOURCE_DIGEST2);
120931
121106
  nitroSupersetLock = parseLock(nitro_superset_lock_default);
120932
121107
  nitroSupersetKey = (inputs2) => nativeEntryKey({ ...inputs2, compiler: NITRO_COMPILER_DIGEST });
120933
121108
  published3 = /* @__PURE__ */ new Map();