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;
@@ -35538,13 +35538,13 @@ var init_swift_standin_digest = __esm({
35538
35538
  STANDIN_DIGEST_ENTRYPOINTS = ["swift-standins.ts", "swift-objc-compile.ts"];
35539
35539
  SPECIFIER = /from\s*['"]([^'"]+)['"]|import\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
35540
35540
  standinSourceDigest = (srcDir = __sootsim_import_meta_dirname) => sourceClosureDigest(srcDir, STANDIN_DIGEST_ENTRYPOINTS);
35541
- STANDIN_SOURCE_DIGEST = true ? "b7465e4180ef2be70330a5488deb331c0846752c0495581fcd000574c0aa480a" : standinSourceDigest();
35541
+ STANDIN_SOURCE_DIGEST = true ? "63adfed92cb0f03f7e74bd25588e866da41eaddd5ff8c13d50802edd65706617" : standinSourceDigest();
35542
35542
  }
35543
35543
  });
35544
35544
 
35545
35545
  // src/expo-native-compiler-digest.ts
35546
35546
  function expoNativeCompilerDigestValue() {
35547
- return true ? "6dd152b897024269db5b53a1f9c613429fd3fd15506a4914a77c3b2638fe2018" : expoNativeCompilerDigest(__sootsim_import_meta_dirname);
35547
+ return true ? "f789d146b1dafe1d68a49954dc5d223e9c982fc7b6602945b530568758babb0a" : expoNativeCompilerDigest(__sootsim_import_meta_dirname);
35548
35548
  }
35549
35549
  var import_node_crypto12;
35550
35550
  var init_expo_native_compiler_digest = __esm({
@@ -54528,7 +54528,9 @@ async function selectOneSDK(appRoot) {
54528
54528
  const imports2 = /* @__PURE__ */ new Set();
54529
54529
  const skipped = /* @__PURE__ */ new Set(["node_modules", "ios", "android", "dist", "build", "types"]);
54530
54530
  async function scan3(directory2) {
54531
+ if (imports2.has("one")) return;
54531
54532
  for (const entry of import_node_fs51.default.readdirSync(directory2, { withFileTypes: true })) {
54533
+ if (imports2.has("one")) return;
54532
54534
  if (entry.name.startsWith(".") || skipped.has(entry.name)) continue;
54533
54535
  const file = import_node_path49.default.join(directory2, entry.name);
54534
54536
  if (entry.isDirectory()) await scan3(file);
@@ -54542,8 +54544,10 @@ async function selectOneSDK(appRoot) {
54542
54544
  });
54543
54545
  for (const match of code.matchAll(
54544
54546
  /(?:\bfrom\s*|\bimport\s*\(?\s*|\brequire\s*\(\s*)['"](one(?:\/ios\/[A-Za-z_][A-Za-z0-9_]*)?)(?:\/[^'"]*)?['"]/g
54545
- ))
54547
+ )) {
54546
54548
  imports2.add(match[1]);
54549
+ if (match[1] === "one") return;
54550
+ }
54547
54551
  }
54548
54552
  }
54549
54553
  }
@@ -54609,6 +54613,22 @@ async function prepareOneSDKSources(appRoot, output) {
54609
54613
  import_node_fs51.default.copyFileSync(import_node_path49.default.join(published4, name3), import_node_path49.default.join(directory2, name3));
54610
54614
  return;
54611
54615
  }
54616
+ const localCache = import_node_path49.default.join(swiftCacheDir(), "one-sdk-sources", entry.key);
54617
+ const localManifestPath = import_node_path49.default.join(localCache, "manifest.json");
54618
+ if (import_node_fs51.default.existsSync(localManifestPath)) {
54619
+ const manifest2 = readOneSDKSourceManifest(
54620
+ JSON.parse(import_node_fs51.default.readFileSync(localManifestPath, "utf8"))
54621
+ );
54622
+ if (manifest2.generation === generation && JSON.stringify(manifest2.frameworks) === JSON.stringify(selected.frameworks) && selected.frameworks.every(
54623
+ (name3) => manifest2.selection[name3] === selected.selection[name3]
54624
+ ) && manifest2.files.every((name3) => import_node_fs51.default.existsSync(import_node_path49.default.join(localCache, name3)))) {
54625
+ import_node_fs51.default.rmSync(directory2, { recursive: true, force: true });
54626
+ import_node_fs51.default.mkdirSync(directory2, { recursive: true });
54627
+ for (const name3 of [...manifest2.files, "manifest.json"])
54628
+ import_node_fs51.default.copyFileSync(import_node_path49.default.join(localCache, name3), import_node_path49.default.join(directory2, name3));
54629
+ return;
54630
+ }
54631
+ }
54612
54632
  const generated = await generateAppSdkInChild(
54613
54633
  import_node_path49.default.join(selected.one, "dist/sdk/app.mjs"),
54614
54634
  selected.frameworks,
@@ -54626,7 +54646,19 @@ async function prepareOneSDKSources(appRoot, output) {
54626
54646
  selection: selected.selection,
54627
54647
  files: [...generated.files.keys()]
54628
54648
  };
54629
- import_node_fs51.default.writeFileSync(import_node_path49.default.join(directory2, "manifest.json"), JSON.stringify(manifest));
54649
+ const manifestJson = JSON.stringify(manifest);
54650
+ import_node_fs51.default.writeFileSync(import_node_path49.default.join(directory2, "manifest.json"), manifestJson);
54651
+ import_node_fs51.default.mkdirSync(import_node_path49.default.dirname(localCache), { recursive: true });
54652
+ const staging = import_node_fs51.default.mkdtempSync(`${localCache}.tmp-`);
54653
+ try {
54654
+ for (const [name3, from] of generated.files)
54655
+ import_node_fs51.default.copyFileSync(from, import_node_path49.default.join(staging, name3));
54656
+ import_node_fs51.default.writeFileSync(import_node_path49.default.join(staging, "manifest.json"), manifestJson);
54657
+ import_node_fs51.default.renameSync(staging, localCache);
54658
+ } catch (error) {
54659
+ import_node_fs51.default.rmSync(staging, { recursive: true, force: true });
54660
+ if (!import_node_fs51.default.existsSync(localManifestPath)) throw error;
54661
+ }
54630
54662
  }
54631
54663
  var import_node_child_process23, import_node_crypto25, import_node_fs51, import_node_module8, import_node_os10, import_node_path49, import_node_url6, import_sucrase2, GENERATE_SCRIPT;
54632
54664
  var init_one_sdk_preparation = __esm({
@@ -54642,6 +54674,7 @@ var init_one_sdk_preparation = __esm({
54642
54674
  import_sucrase2 = require("peachsim/vendor/sucrase");
54643
54675
  init_native_prebuilt();
54644
54676
  init_oneSdkContract();
54677
+ init_swift_toolchain();
54645
54678
  GENERATE_SCRIPT = `
54646
54679
  import { writeFileSync } from 'node:fs'
54647
54680
  import { pathToFileURL } from 'node:url'
@@ -59647,6 +59680,7 @@ var init_swiftSdkLinkContract = __esm({
59647
59680
 
59648
59681
  // src/swift-sdk-image-wasm.ts
59649
59682
  function wasmReader(bytes, start) {
59683
+ const rawBuf = Buffer.isBuffer(bytes) ? bytes : Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
59650
59684
  let at = start;
59651
59685
  const u = () => {
59652
59686
  let value = 0;
@@ -59675,7 +59709,7 @@ function wasmReader(bytes, start) {
59675
59709
  name: () => {
59676
59710
  const length = u();
59677
59711
  at += length;
59678
- return Buffer.from(bytes.subarray(at - length, at)).toString();
59712
+ return rawBuf.toString("utf8", at - length, at);
59679
59713
  },
59680
59714
  skip: (length) => {
59681
59715
  at += length;
@@ -60029,7 +60063,7 @@ function codeOnlySdkImage(bytes, constructorMask) {
60029
60063
  const bodies = m.bodies.map(({ start, end }) => bytes.subarray(start, end));
60030
60064
  const initMemory = functionIndex("__wasm_init_memory") - m.importedFuncs;
60031
60065
  {
60032
- const body = Uint8Array.from(bodies[initMemory]);
60066
+ const body = new Uint8Array(bodies[initMemory]);
60033
60067
  const r = wasmReader(body, 0);
60034
60068
  if (r.u() !== 0) throw new Error("sdk memory initializer has locals");
60035
60069
  while (r.at < body.length) {
@@ -61065,7 +61099,18 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
61065
61099
  dataOwnerSymIdx[kept] = ownerSymIdx;
61066
61100
  kept++;
61067
61101
  }
61068
- const dataRelocs = {
61102
+ const dataRelocs = kept === rawData.count ? {
61103
+ count: kept,
61104
+ bytes: rawData.bytes,
61105
+ start: rawData.start,
61106
+ end: rawData.end,
61107
+ ro: rawData.ro,
61108
+ rs: rawData.rs,
61109
+ addend: rawData.addend,
61110
+ segIdx: dataSegIdx,
61111
+ offInSeg: dataOffInSeg,
61112
+ ownerSymIdx: dataOwnerSymIdx
61113
+ } : {
61069
61114
  count: kept,
61070
61115
  bytes: rawData.bytes,
61071
61116
  start: rawData.start.slice(0, kept),
@@ -61077,26 +61122,29 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
61077
61122
  offInSeg: dataOffInSeg.slice(0, kept),
61078
61123
  ownerSymIdx: dataOwnerSymIdx.slice(0, kept)
61079
61124
  };
61080
- const relocatedWords = /* @__PURE__ */ new Map();
61081
- for (let i = 0; i < dataRelocs.count; i++) {
61082
- const segIdx = dataRelocs.segIdx[i];
61083
- let words2 = relocatedWords.get(segIdx);
61084
- if (!words2) relocatedWords.set(segIdx, words2 = /* @__PURE__ */ new Set());
61085
- words2.add(dataRelocs.offInSeg[i]);
61086
- }
61087
- for (const [segIdx, tops] of segTopSyms) {
61088
- const starts = new Map(tops.map((top) => [top.off, top.symIdx]));
61089
- const relocated = relocatedWords.get(segIdx);
61090
- const payload = dataStart + sPayloadStarts[segIdx];
61091
- const view = new DataView(buf.buffer, buf.byteOffset + payload);
61092
- for (const top of tops) {
61093
- for (let at = top.off; at + 4 <= top.end; at += 4) {
61094
- if (relocated?.has(at)) continue;
61095
- const target = starts.get(at + (view.getInt32(at, true) & ~3));
61096
- if (target === void 0 || target === top.symIdx) continue;
61097
- let list2 = symDataRelocs.get(top.symIdx);
61098
- if (!list2) symDataRelocs.set(top.symIdx, list2 = []);
61099
- list2.push(target);
61125
+ if (segTopSyms.size > 0) {
61126
+ const relocatedWords = /* @__PURE__ */ new Map();
61127
+ for (let i = 0; i < dataRelocs.count; i++) {
61128
+ const segIdx = dataRelocs.segIdx[i];
61129
+ if (!segTopSyms.has(segIdx)) continue;
61130
+ let words2 = relocatedWords.get(segIdx);
61131
+ if (!words2) relocatedWords.set(segIdx, words2 = /* @__PURE__ */ new Set());
61132
+ words2.add(dataRelocs.offInSeg[i]);
61133
+ }
61134
+ for (const [segIdx, tops] of segTopSyms) {
61135
+ const starts = new Map(tops.map((top) => [top.off, top.symIdx]));
61136
+ const relocated = relocatedWords.get(segIdx);
61137
+ const payload = dataStart + sPayloadStarts[segIdx];
61138
+ const view = new DataView(buf.buffer, buf.byteOffset + payload);
61139
+ for (const top of tops) {
61140
+ for (let at = top.off; at + 4 <= top.end; at += 4) {
61141
+ if (relocated?.has(at)) continue;
61142
+ const target = starts.get(at + (view.getInt32(at, true) & ~3));
61143
+ if (target === void 0 || target === top.symIdx) continue;
61144
+ let list2 = symDataRelocs.get(top.symIdx);
61145
+ if (!list2) symDataRelocs.set(top.symIdx, list2 = []);
61146
+ list2.push(target);
61147
+ }
61100
61148
  }
61101
61149
  }
61102
61150
  }
@@ -61268,7 +61316,7 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
61268
61316
  };
61269
61317
  }
61270
61318
  function parseWasmObjectFile(file, isDist) {
61271
- return parseWasmObjectBytes(file, new Uint8Array(import_node_fs58.default.readFileSync(file)), isDist);
61319
+ return parseWasmObjectBytes(file, import_node_fs58.default.readFileSync(file), isDist);
61272
61320
  }
61273
61321
  function parseWasmObjectCached(file, isDist, entries2) {
61274
61322
  const key2 = `${isDist ? "1" : "0"}:${file}`;
@@ -61283,7 +61331,7 @@ function parseWasmObjectCached(file, isDist, entries2) {
61283
61331
  function localizeDefinedWasmSymbols(bytes, names) {
61284
61332
  const offsets = [];
61285
61333
  const object9 = parseWasmObjectBytes("", bytes, false, offsets);
61286
- const output = Uint8Array.from(bytes);
61334
+ const output = new Uint8Array(bytes);
61287
61335
  let changed2 = 0;
61288
61336
  for (let index = 0; index < object9.symNames.length; index++) {
61289
61337
  if (!names.has(object9.symNames[index])) continue;
@@ -64744,18 +64792,6 @@ function compactSparseWasmTable(bytes) {
64744
64792
  bytes.subarray(elements.end)
64745
64793
  ]);
64746
64794
  }
64747
- function hasWasmExport(bytes, name3) {
64748
- const section2 = wasmSections2(bytes).find((value) => value.id === 7);
64749
- if (!section2) return false;
64750
- const input = readWasmSection(bytes, section2.start, section2.end);
64751
- for (let count = input.number(); count > 0; count--) {
64752
- const found2 = input.name();
64753
- input.byte();
64754
- input.number();
64755
- if (found2 === name3) return true;
64756
- }
64757
- return false;
64758
- }
64759
64795
  function withSections(bytes, layout2, replacements) {
64760
64796
  const parts2 = [bytes.subarray(0, 8)];
64761
64797
  let at = 8;
@@ -65489,23 +65525,40 @@ function reserveGuestProjectionStorage(images, capacities) {
65489
65525
  };
65490
65526
  }
65491
65527
  function mergeGuestProjectionSpans(imageCount, spans) {
65492
- const sorted3 = [...spans].sort(
65493
- (a, b) => a.space.localeCompare(b.space) || a.address - b.address || a.image - b.image
65494
- );
65495
- const merged = [];
65496
- for (const span of sorted3) {
65528
+ const tableSpans = [];
65529
+ const memorySpans = [];
65530
+ for (const span of spans) {
65497
65531
  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)
65498
65532
  throw new Error("invalid linked guest span");
65499
- const previous = merged[merged.length - 1];
65500
- if (previous && previous.space === span.space && span.address < previous.address + previous.length && previous.image !== span.image)
65501
- throw new Error("linked guest span has ambiguous image ownership");
65502
- if (previous && previous.space === span.space && previous.image === span.image && span.address <= previous.address + previous.length) {
65503
- merged[merged.length - 1] = {
65504
- ...previous,
65505
- length: Math.max(previous.address + previous.length, span.address + span.length) - previous.address
65506
- };
65507
- } else merged.push(span);
65533
+ if (span.space === "function-table") tableSpans.push(span);
65534
+ else memorySpans.push(span);
65508
65535
  }
65536
+ const byAddress = (a, b) => a.address - b.address || a.image - b.image;
65537
+ tableSpans.sort(byAddress);
65538
+ memorySpans.sort(byAddress);
65539
+ const merged = [];
65540
+ const mergeGroup = (group) => {
65541
+ let previous = null;
65542
+ for (const span of group) {
65543
+ if (previous && span.address < previous.address + previous.length && previous.image !== span.image)
65544
+ throw new Error("linked guest span has ambiguous image ownership");
65545
+ if (previous && previous.image === span.image && span.address <= previous.address + previous.length) {
65546
+ const end = span.address + span.length;
65547
+ if (end > previous.address + previous.length)
65548
+ previous.length = end - previous.address;
65549
+ } else {
65550
+ previous = {
65551
+ image: span.image,
65552
+ space: span.space,
65553
+ address: span.address,
65554
+ length: span.length
65555
+ };
65556
+ merged.push(previous);
65557
+ }
65558
+ }
65559
+ };
65560
+ mergeGroup(tableSpans);
65561
+ mergeGroup(memorySpans);
65509
65562
  return merged;
65510
65563
  }
65511
65564
  function guestProjectionRegionCounts(imageCount, spans) {
@@ -65701,7 +65754,7 @@ function sdkArtifactBytes(root, artifact) {
65701
65754
  const source = (0, import_node_fs61.readFileSync)(import_node_path59.default.join(sourceDirectory, "libFoundation.a"));
65702
65755
  if (hash(source) !== artifact.sha256)
65703
65756
  throw new Error(`SDK product artifact changed ${file}`);
65704
- const transformed = Uint8Array.from(source);
65757
+ const transformed = new Uint8Array(source);
65705
65758
  weakenFoundationOverridesInArchive(transformed);
65706
65759
  if (!linked.equals(transformed))
65707
65760
  throw new Error(`SDK view transformation changed ${file}`);
@@ -66241,17 +66294,17 @@ var init_binaryen_lock = __esm({
66241
66294
  "linux-x64": {
66242
66295
  asset: "x86_64-linux",
66243
66296
  upstreamSha256: "195ddc94f9bc89f45abdabb0b9eea86023d727ba90eac8b35b80f2544fc30572",
66244
- sha256: "feda0b3a5a24c902ec25e8d674f33c5771a0704e611a2e8e4800ab3c3fc591ca"
66297
+ sha256: "1024974f254c1c2edd738246ec6af5add16d3d36b5f58a94545febda3b33c869"
66245
66298
  },
66246
66299
  "linux-arm64": {
66247
66300
  asset: "aarch64-linux",
66248
66301
  upstreamSha256: "c58562417836c5d0493d89bdefc434933bdc097db641b483df86bcfa557a107f",
66249
- sha256: "0c67b9f36e9337afddf13b5150ab0e30bddf4f58633b02c4604f0cc87c2b89a2"
66302
+ sha256: "7dedfc9f5cb32e75a28831f3b5aa053fd3e0bdd74f73dc4d1b1588947236daef"
66250
66303
  },
66251
66304
  "darwin-arm64": {
66252
66305
  asset: "arm64-macos",
66253
66306
  upstreamSha256: "98aad827847af7ef990ed7098d885725c8e5b5aae75073403635617ae4e259aa",
66254
- sha256: "36373d0901b376c2868f09e0c2c303b1b7117b696e31dd661afa9711f31ea4a0"
66307
+ sha256: "0b56e0a06b6a873877871537a120fd94e2121e67f4bce5f8b5252c47b615854a"
66255
66308
  }
66256
66309
  }
66257
66310
  };
@@ -66280,6 +66333,45 @@ var init_wasm_features = __esm({
66280
66333
  });
66281
66334
 
66282
66335
  // src/wasm-optimize.ts
66336
+ function readWasmMemoryFromFile(file) {
66337
+ const fd = (0, import_node_fs62.openSync)(file, "r");
66338
+ try {
66339
+ const total = (0, import_node_fs62.fstatSync)(fd).size;
66340
+ const header = Buffer.allocUnsafe(8);
66341
+ if (total < 8 || (0, import_node_fs62.readSync)(fd, header, 0, 8, 0) < 8) return void 0;
66342
+ let offset = 8;
66343
+ const probe2 = Buffer.allocUnsafe(16);
66344
+ let prefixEnd = 8;
66345
+ while (offset < total) {
66346
+ const read = (0, import_node_fs62.readSync)(fd, probe2, 0, Math.min(16, total - offset), offset);
66347
+ if (read < 2) break;
66348
+ const id = probe2[0];
66349
+ let size2 = 0;
66350
+ let shift = 0;
66351
+ let at = 1;
66352
+ for (; ; ) {
66353
+ const byte = probe2[at++];
66354
+ size2 += (byte & 127) * 2 ** shift;
66355
+ if (!(byte & 128)) break;
66356
+ shift += 7;
66357
+ }
66358
+ const next = offset + at + size2;
66359
+ if (id === 2 || id === 5) prefixEnd = next;
66360
+ if (id > 5) break;
66361
+ offset = next;
66362
+ }
66363
+ const prefix = Buffer.allocUnsafe(prefixEnd);
66364
+ let filled = 0;
66365
+ while (filled < prefixEnd) {
66366
+ const n = (0, import_node_fs62.readSync)(fd, prefix, filled, prefixEnd - filled, filled);
66367
+ if (n <= 0) break;
66368
+ filled += n;
66369
+ }
66370
+ return readWasmMemory(prefix.subarray(0, filled));
66371
+ } finally {
66372
+ (0, import_node_fs62.closeSync)(fd);
66373
+ }
66374
+ }
66283
66375
  async function runWasmOpt(file, output, optimize, skipPasses, binary2, sdkTableEnd, wideExports) {
66284
66376
  const admittedCores = windowAdmission()?.cores ?? Number(process.env.TM_EXEC_CPU_CORES);
66285
66377
  const requestedCores = Number(process.env.BINARYEN_CORES);
@@ -66296,25 +66388,75 @@ async function runWasmOpt(file, output, optimize, skipPasses, binary2, sdkTableE
66296
66388
  return;
66297
66389
  }
66298
66390
  const optimizeSize = optimize === true || optimize === "app-module";
66299
- const optimizeBeforeGuard = optimize === true;
66300
66391
  const relink = optimize === "relink";
66301
- const names = optimizeBeforeGuard && !KEEP_WASM_NAMES ? [] : ["-g"];
66302
- const outputNames = (optimizeSize || relink) && !KEEP_WASM_NAMES ? [] : names;
66303
- let input = (0, import_node_fs62.readFileSync)(file);
66304
- const memory = readWasmMemory(input);
66305
- const checked = `${output}.stack-checked`;
66392
+ const keepNames = !optimizeSize && !relink || KEEP_WASM_NAMES;
66393
+ const memory = readWasmMemoryFromFile(file);
66306
66394
  if (memory?.shared && memory.maximumPages !== 65536)
66307
66395
  throw new Error("threaded native memory must declare a 65536-page maximum");
66308
- if (memory?.shared && optimizeBeforeGuard) {
66309
- await runBinaryen(binary2, [...features, "-g", "--stack-check", file, "-o", checked], {
66310
- env: environment
66311
- });
66312
- input = (0, import_node_fs62.readFileSync)(checked);
66313
- if (!hasWasmExport(input, "__set_stack_limits"))
66314
- throw new Error(
66315
- "threaded native artifact must retain its __stack_pointer name for bounds checks"
66396
+ if (memory?.shared) {
66397
+ const wideExportsFile = wideExports.size ? `${output}.wide-exports` : void 0;
66398
+ const tableTool = (0, import_node_path60.join)((0, import_node_path60.dirname)(binary2), "wasm-table-guard");
66399
+ try {
66400
+ if (wideExportsFile)
66401
+ (0, import_node_fs62.writeFileSync)(wideExportsFile, [...wideExports].join("\n") + "\n");
66402
+ const pipelineArgs = [
66403
+ "--pipeline",
66404
+ "--in",
66405
+ file,
66406
+ "--out",
66407
+ output,
66408
+ "--narrow",
66409
+ ...wideExportsFile ? ["--wide-exports-file", wideExportsFile] : [],
66410
+ "--lower",
66411
+ "--shared",
66412
+ ...keepNames ? ["--debug"] : [],
66413
+ ...sdkTableEnd !== void 0 ? ["--slots-range", "1", String(sdkTableEnd), "--adapt"] : [],
66414
+ ...optimizeSize ? ["--optimize", "oz"] : relink ? ["--optimize", "relink"] : [],
66415
+ ...skipPasses.flatMap((pass) => ["--skip-pass", pass])
66416
+ ];
66417
+ const { stdout } = await runBinaryen(tableTool, pipelineArgs, { env: environment });
66418
+ const metadata = JSON.parse(stdout);
66419
+ if (typeof metadata !== "object" || metadata === null || !("tableMinimum" in metadata) || typeof metadata.tableMinimum !== "number" || !Number.isSafeInteger(metadata.tableMinimum) || metadata.tableMinimum < 0)
66420
+ throw new Error("native table tool returned an invalid table minimum");
66421
+ const sectionName = new TextEncoder().encode(NATIVE_IMAGE_SECTION);
66422
+ const layout2 = new TextEncoder().encode(
66423
+ JSON.stringify({
66424
+ initialPages: memory.initialPages,
66425
+ tableMinimum: metadata.tableMinimum
66426
+ })
66316
66427
  );
66428
+ const encode2 = (value) => {
66429
+ const bytes2 = [];
66430
+ do {
66431
+ const byte = value & 127;
66432
+ value >>>= 7;
66433
+ bytes2.push(byte | (value ? 128 : 0));
66434
+ } while (value);
66435
+ return bytes2;
66436
+ };
66437
+ const body = new Uint8Array([
66438
+ ...encode2(sectionName.length),
66439
+ ...sectionName,
66440
+ ...layout2
66441
+ ]);
66442
+ const bytes = (0, import_node_fs62.readFileSync)(output);
66443
+ (0, import_node_fs62.writeFileSync)(
66444
+ output,
66445
+ Buffer.concat([
66446
+ sdkTableEnd === void 0 ? withWasmTableMinimum(
66447
+ bytes,
66448
+ metadata.tableMinimum + NATIVE_TABLE_RESERVE_SLOTS
66449
+ ) : bytes,
66450
+ Buffer.from([0, ...encode2(body.length), ...body])
66451
+ ])
66452
+ );
66453
+ } finally {
66454
+ if (wideExportsFile) (0, import_node_fs62.rmSync)(wideExportsFile, { force: true });
66455
+ }
66456
+ return;
66317
66457
  }
66458
+ const outputNames = keepNames ? ["-g"] : [];
66459
+ const input = (0, import_node_fs62.readFileSync)(file);
66318
66460
  const narrowed = narrowWasmBoundary(input, wideExports);
66319
66461
  const merged = `${output}.narrowed`;
66320
66462
  if (narrowed) {
@@ -66326,7 +66468,7 @@ async function runWasmOpt(file, output, optimize, skipPasses, binary2, sdkTableE
66326
66468
  (0, import_node_path60.join)((0, import_node_path60.dirname)(binary2), "wasm-merge"),
66327
66469
  [
66328
66470
  ...features,
66329
- ...names,
66471
+ ...outputNames,
66330
66472
  guest,
66331
66473
  NARROW_MERGE_NAMES.guest,
66332
66474
  thunks,
@@ -66340,118 +66482,25 @@ async function runWasmOpt(file, output, optimize, skipPasses, binary2, sdkTableE
66340
66482
  (0, import_node_fs62.rmSync)(guest);
66341
66483
  (0, import_node_fs62.rmSync)(thunks);
66342
66484
  }
66343
- const lowered = memory?.shared ? `${output}.lowered` : output;
66344
- const compiled = narrowed ? merged : memory?.shared && optimizeBeforeGuard ? checked : file;
66485
+ const compiled = narrowed ? merged : file;
66345
66486
  const skip = skipPasses.flatMap((pass) => ["--skip-pass", pass]);
66346
66487
  try {
66347
- if (!memory?.shared || optimizeBeforeGuard)
66348
- await runBinaryen(
66349
- binary2,
66350
- [
66351
- ...LOWERING,
66352
- ...optimizeSize ? ["-Oz"] : relink ? RELINK_PASSES : [],
66353
- ...outputNames,
66354
- ...skip,
66355
- ...features,
66356
- compiled,
66357
- "-o",
66358
- lowered
66359
- ],
66360
- { env: environment, maxBuffer: Infinity }
66361
- );
66362
- if (memory?.shared) {
66363
- const guarded = `${output}.table.wasm`;
66364
- const sdkGuarded = `${output}.sdk-table.wasm`;
66365
- const sdkSlots = `${output}.sdk-table-slots`;
66366
- const tableTool = (0, import_node_path60.join)((0, import_node_path60.dirname)(binary2), "wasm-table-guard");
66367
- try {
66368
- const { stdout } = await runBinaryen(
66369
- tableTool,
66370
- [
66371
- optimizeBeforeGuard ? lowered : compiled,
66372
- guarded,
66373
- names.length ? "1" : "0",
66374
- ...optimizeBeforeGuard ? [] : ["lower"]
66375
- ],
66376
- { env: environment }
66377
- );
66378
- const metadata = JSON.parse(stdout);
66379
- if (typeof metadata !== "object" || metadata === null || !("tableMinimum" in metadata) || typeof metadata.tableMinimum !== "number" || !Number.isSafeInteger(metadata.tableMinimum) || metadata.tableMinimum < 0)
66380
- throw new Error("native table tool returned an invalid table minimum");
66381
- if (sdkTableEnd !== void 0) {
66382
- (0, import_node_fs62.writeFileSync)(
66383
- sdkSlots,
66384
- Array.from({ length: sdkTableEnd - 1 }, (_, index) => index + 1).join("\n")
66385
- );
66386
- await runBinaryen(
66387
- tableTool,
66388
- [guarded, sdkGuarded, names.length ? "1" : "0", "0", sdkSlots, "adapt"],
66389
- { env: environment }
66390
- );
66391
- (0, import_node_fs62.renameSync)(sdkGuarded, guarded);
66392
- }
66393
- if (optimize)
66394
- await runBinaryen(
66395
- binary2,
66396
- [
66397
- ...features,
66398
- // an adapted call tests its target's type with a typed function reference.
66399
- ...sdkTableEnd === void 0 ? [] : ["--enable-gc"],
66400
- ...optimizeSize ? ["-Oz"] : RELINK_PASSES,
66401
- ...outputNames,
66402
- ...skip,
66403
- guarded,
66404
- "-o",
66405
- output
66406
- ],
66407
- { env: environment }
66408
- );
66409
- const sectionName = new TextEncoder().encode(NATIVE_IMAGE_SECTION);
66410
- const layout2 = new TextEncoder().encode(
66411
- JSON.stringify({
66412
- initialPages: memory.initialPages,
66413
- tableMinimum: metadata.tableMinimum
66414
- })
66415
- );
66416
- const encode2 = (value) => {
66417
- const bytes2 = [];
66418
- do {
66419
- const byte = value & 127;
66420
- value >>>= 7;
66421
- bytes2.push(byte | (value ? 128 : 0));
66422
- } while (value);
66423
- return bytes2;
66424
- };
66425
- const body = new Uint8Array([
66426
- ...encode2(sectionName.length),
66427
- ...sectionName,
66428
- ...layout2
66429
- ]);
66430
- const image = optimize ? output : guarded;
66431
- const bytes = (0, import_node_fs62.readFileSync)(image);
66432
- (0, import_node_fs62.writeFileSync)(
66433
- image,
66434
- Buffer.concat([
66435
- sdkTableEnd === void 0 ? withWasmTableMinimum(
66436
- bytes,
66437
- metadata.tableMinimum + NATIVE_TABLE_RESERVE_SLOTS
66438
- ) : bytes,
66439
- Buffer.from([0, ...encode2(body.length), ...body])
66440
- ])
66441
- );
66442
- if (!optimize) (0, import_node_fs62.renameSync)(guarded, output);
66443
- } finally {
66444
- (0, import_node_fs62.rmSync)(guarded, { force: true });
66445
- (0, import_node_fs62.rmSync)(sdkGuarded, { force: true });
66446
- (0, import_node_fs62.rmSync)(sdkSlots, { force: true });
66447
- }
66448
- }
66488
+ await runBinaryen(
66489
+ binary2,
66490
+ [
66491
+ ...LOWERING,
66492
+ ...optimizeSize ? ["-Oz"] : relink ? RELINK_PASSES : [],
66493
+ ...outputNames,
66494
+ ...skip,
66495
+ ...features,
66496
+ compiled,
66497
+ "-o",
66498
+ output
66499
+ ],
66500
+ { env: environment, maxBuffer: Infinity }
66501
+ );
66449
66502
  } finally {
66450
66503
  if (narrowed) (0, import_node_fs62.rmSync)(merged, { force: true });
66451
- if (memory?.shared) {
66452
- (0, import_node_fs62.rmSync)(checked, { force: true });
66453
- (0, import_node_fs62.rmSync)(lowered, { force: true });
66454
- }
66455
66504
  }
66456
66505
  }
66457
66506
  async function installWasmOpt() {
@@ -71598,9 +71647,11 @@ async function linkSwiftSdkImage(moduleRoot, key2, directory2, work, scopedLooku
71598
71647
  objects.push({ path: object9, bytes, instrumentDynamicLookups: false });
71599
71648
  guestObjects.set(product, objects);
71600
71649
  };
71601
- const classifyFile = (file) => {
71650
+ const classifyFile = (file, collectAutolink = false) => {
71602
71651
  const bytes = (0, import_node_fs72.readFileSync)(file);
71603
71652
  if (!file.endsWith(".a")) {
71653
+ if (collectAutolink)
71654
+ for (const library of autolinkLibraries(bytes)) libraries.add(library);
71604
71655
  const scoped = lookups2?.rewrite(file, bytes) ?? bytes;
71605
71656
  return addObject(file, scoped, file);
71606
71657
  }
@@ -71608,6 +71659,8 @@ async function linkSwiftSdkImage(moduleRoot, key2, directory2, work, scopedLooku
71608
71659
  (0, import_node_fs72.mkdirSync)(import_node_path70.default.join(members2, archive));
71609
71660
  const ordinals = /* @__PURE__ */ new Map();
71610
71661
  readArMembers(bytes).forEach((member, index) => {
71662
+ if (collectAutolink)
71663
+ for (const library of autolinkLibraries(member.bytes)) libraries.add(library);
71611
71664
  const object9 = import_node_path70.default.join(members2, archive, `${index}-${import_node_path70.default.basename(member.name)}`);
71612
71665
  const ordinal = (ordinals.get(member.name) ?? 0) + 1;
71613
71666
  ordinals.set(member.name, ordinal);
@@ -71622,9 +71675,7 @@ async function linkSwiftSdkImage(moduleRoot, key2, directory2, work, scopedLooku
71622
71675
  });
71623
71676
  };
71624
71677
  for (const object9 of [...link.objects, ...link.providers]) {
71625
- classifyFile(object9);
71626
- for (const bytes of objectMembers(object9))
71627
- for (const library of autolinkLibraries(bytes)) libraries.add(library);
71678
+ classifyFile(object9, true);
71628
71679
  }
71629
71680
  for (const library of libraries) {
71630
71681
  if (unpacked.has(library.slice(2))) continue;
@@ -71637,6 +71688,7 @@ async function linkSwiftSdkImage(moduleRoot, key2, directory2, work, scopedLooku
71637
71688
  const hostExports = sdkHostExports(appRoot);
71638
71689
  const guestMap = /* @__PURE__ */ new Map();
71639
71690
  const guestMetadataNames = {};
71691
+ const compiles = [];
71640
71692
  if (lookups2) {
71641
71693
  const ledger = lookups2.link(guestObjects, [
71642
71694
  ...hostExports,
@@ -71672,33 +71724,38 @@ async function linkSwiftSdkImage(moduleRoot, key2, directory2, work, scopedLooku
71672
71724
  const scopeLedger = import_node_path70.default.join(work, "guest-ledger.ll");
71673
71725
  const scopeObject = import_node_path70.default.join(work, "guest-ledger.o");
71674
71726
  (0, import_node_fs72.writeFileSync)(scopeLedger, ledger.llvmIR);
71675
- await run5(import_node_path70.default.join(toolchain.toolchainBin, "clang"), [
71676
- `--target=${SWIFT_WASM_TRIPLE}`,
71677
- "-matomics",
71678
- "-mbulk-memory",
71679
- "-c",
71680
- scopeLedger,
71681
- "-o",
71682
- scopeObject
71683
- ]);
71727
+ compiles.push(
71728
+ run5(import_node_path70.default.join(toolchain.toolchainBin, "clang"), [
71729
+ `--target=${SWIFT_WASM_TRIPLE}`,
71730
+ "-matomics",
71731
+ "-mbulk-memory",
71732
+ "-c",
71733
+ scopeLedger,
71734
+ "-o",
71735
+ scopeObject
71736
+ ])
71737
+ );
71684
71738
  eager.push(scopeObject);
71685
71739
  }
71686
71740
  (0, import_node_fs72.writeFileSync)(
71687
71741
  import_node_path70.default.join(work, "image-tables.c"),
71688
71742
  IMAGE_TABLES + (guestLookups?.source ?? "")
71689
71743
  );
71690
- await run5(import_node_path70.default.join(toolchain.toolchainBin, "clang"), [
71691
- `--target=${SWIFT_WASM_TRIPLE}`,
71692
- "-O2",
71693
- "-matomics",
71694
- "-mbulk-memory",
71695
- "-ffreestanding",
71696
- ...lookups2 ? ["-DPEACH_SDK_GUEST_LINK"] : [],
71697
- "-c",
71698
- import_node_path70.default.join(work, "image-tables.c"),
71699
- "-o",
71700
- tables
71701
- ]);
71744
+ compiles.push(
71745
+ run5(import_node_path70.default.join(toolchain.toolchainBin, "clang"), [
71746
+ `--target=${SWIFT_WASM_TRIPLE}`,
71747
+ "-O2",
71748
+ "-matomics",
71749
+ "-mbulk-memory",
71750
+ "-ffreestanding",
71751
+ ...lookups2 ? ["-DPEACH_SDK_GUEST_LINK"] : [],
71752
+ "-c",
71753
+ import_node_path70.default.join(work, "image-tables.c"),
71754
+ "-o",
71755
+ tables
71756
+ ])
71757
+ );
71758
+ await Promise.all(compiles);
71702
71759
  const quote3 = (value) => JSON.stringify(value);
71703
71760
  (0, import_node_fs72.writeFileSync)(
71704
71761
  import_node_path70.default.join(work, "exports.rsp"),
@@ -71757,23 +71814,31 @@ async function linkSwiftSdkImage(moduleRoot, key2, directory2, work, scopedLooku
71757
71814
  if (mask2 === void 0) throw new Error("sdk image lacks its constructor mask");
71758
71815
  const code = import_node_path70.default.join(work, "code.wasm");
71759
71816
  (0, import_node_fs72.writeFileSync)(code, codeOnlySdkImage(finished2, mask2));
71760
- await lowerWasm(code, import_node_path70.default.join(work, IMAGE_FILE), {
71817
+ const lowerPromise = lowerWasm(code, import_node_path70.default.join(work, IMAGE_FILE), {
71761
71818
  optimize: true,
71762
71819
  skipPasses: lookups2 ? ["duplicate-function-elimination"] : void 0
71763
71820
  });
71821
+ await new Promise((resolve16) => setImmediate(resolve16));
71822
+ try {
71823
+ writeSdkManifest(
71824
+ work,
71825
+ linkMap,
71826
+ linkedBytes,
71827
+ finished2,
71828
+ (0, import_node_fs72.readFileSync)(withRelocs),
71829
+ functionSlots,
71830
+ lookups2 && { inputs: guestMap, metadataNames: guestMetadataNames }
71831
+ );
71832
+ } catch (error) {
71833
+ await lowerPromise.catch(() => {
71834
+ });
71835
+ throw error;
71836
+ }
71837
+ await lowerPromise;
71764
71838
  const image = (0, import_node_fs72.readFileSync)(import_node_path70.default.join(work, IMAGE_FILE));
71765
71839
  sdkInterface.layout.tableEnd += unslottedFunctions(image);
71766
71840
  if (sdkInterface.layout.tableEnd > SWIFT_SDK_APP_TABLE_BASE)
71767
71841
  throw new Error("Swift SDK image exceeds its reserved function table range");
71768
- writeSdkManifest(
71769
- work,
71770
- linkMap,
71771
- linkedBytes,
71772
- finished2,
71773
- (0, import_node_fs72.readFileSync)(withRelocs),
71774
- functionSlots,
71775
- lookups2 && { inputs: guestMap, metadataNames: guestMetadataNames }
71776
- );
71777
71842
  (0, import_node_fs72.writeFileSync)(import_node_path70.default.join(work, INTERFACE_FILE), JSON.stringify(sdkInterface));
71778
71843
  (0, import_node_fs72.writeFileSync)(
71779
71844
  import_node_path70.default.join(work, IMAGE_DIGEST),
@@ -71842,14 +71907,11 @@ function sdkLinkInputs(appRoot) {
71842
71907
  if (!crt) throw new Error("the sdk image link found no reactor startup object");
71843
71908
  return { flags, libraries, objects: [crt, ...objects], providers };
71844
71909
  }
71845
- function objectMembers(file) {
71846
- const bytes = (0, import_node_fs72.readFileSync)(file);
71847
- return file.endsWith(".a") ? readArMembers(bytes).map((member) => member.bytes) : [bytes];
71848
- }
71849
71910
  function autolinkLibraries(bytes) {
71850
71911
  const entries2 = wasmSections(bytes).find((s) => s.name === ".swift1_autolink_entries");
71851
71912
  if (!entries2) return [];
71852
- return Buffer.from(bytes.subarray(entries2.start, entries2.end)).toString().split("\0").filter((entry) => entry.startsWith("-l"));
71913
+ const raw2 = Buffer.isBuffer(bytes) ? bytes : Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
71914
+ return raw2.toString("utf8", entries2.start, entries2.end).split("\0").filter((entry) => entry.startsWith("-l"));
71853
71915
  }
71854
71916
  function sdkHostExports(appRoot) {
71855
71917
  const release = import_node_path70.default.join(appRoot, ".build", SWIFT_WASM_TRIPLE, "release");
@@ -71935,9 +71997,17 @@ function writeSdkManifest(work, map2, linked, finished2, withRelocs, functionSlo
71935
71997
  return { starts, targets };
71936
71998
  };
71937
71999
  const byAddress = (edges2) => {
71938
- const pairs2 = [];
71939
- for (let i = 0; i < edges2.length; i += 2) pairs2.push([edges2[i], edges2[i + 1]]);
71940
- return pairs2.sort((a, b) => a[0] - b[0]).flat();
72000
+ const count = edges2.length >>> 1;
72001
+ const order = new Uint32Array(count);
72002
+ for (let i = 0; i < count; i++) order[i] = i;
72003
+ order.sort((a, b) => edges2[a * 2] - edges2[b * 2]);
72004
+ const sorted3 = new Uint32Array(edges2.length);
72005
+ for (let i = 0; i < count; i++) {
72006
+ const src = order[i] * 2;
72007
+ sorted3[i * 2] = edges2[src];
72008
+ sorted3[i * 2 + 1] = edges2[src + 1];
72009
+ }
72010
+ return sorted3;
71941
72011
  };
71942
72012
  const functionData = flatten2(edges.code);
71943
72013
  const functionCalls = flatten2(edges.calls);
@@ -72359,12 +72429,22 @@ async function buildSwiftAppModule(options2) {
72359
72429
  work,
72360
72430
  readInput
72361
72431
  });
72362
- await link.lower();
72363
- const usage = readSwiftSdkUsage(
72364
- project2 ? projectOutputFile(buildRoot, map2, project2) : map2,
72365
- pruned
72366
- );
72367
- const binding = createSwiftSdkBinding(link.linkage, sdk2, usage);
72432
+ const lowerPromise = link.lower();
72433
+ await new Promise((resolve16) => setImmediate(resolve16));
72434
+ let usage;
72435
+ let binding;
72436
+ try {
72437
+ usage = readSwiftSdkUsage(
72438
+ project2 ? projectOutputFile(buildRoot, map2, project2) : map2,
72439
+ pruned
72440
+ );
72441
+ binding = createSwiftSdkBinding(link.linkage, sdk2, usage);
72442
+ } catch (error) {
72443
+ await lowerPromise.catch(() => {
72444
+ });
72445
+ throw error;
72446
+ }
72447
+ await lowerPromise;
72368
72448
  if (!project2)
72369
72449
  writeSwiftSdkAppLink(import_node_path71.default.join(work, "app-link.json.gz"), {
72370
72450
  linkage: link.linkage,
@@ -74274,7 +74354,6 @@ async function compileGuestLink(options2) {
74274
74354
  bindingRows.set((address - values.address) / 8, value);
74275
74355
  } else data.push(address, size2, value);
74276
74356
  }
74277
- const binding = createSwiftSdkBinding2({ ...link.linkage, data }, sdk2, usage);
74278
74357
  const linked = (0, import_node_fs74.readFileSync)(
74279
74358
  project2 ? projectOutputFile(work, linkedModule, project2) : linkedModule
74280
74359
  );
@@ -74299,7 +74378,17 @@ async function compileGuestLink(options2) {
74299
74378
  );
74300
74379
  continue;
74301
74380
  }
74302
- await link.lower();
74381
+ const lowerPromise = link.lower();
74382
+ await new Promise((resolve16) => setImmediate(resolve16));
74383
+ let binding;
74384
+ try {
74385
+ binding = createSwiftSdkBinding2({ ...link.linkage, data }, sdk2, usage);
74386
+ } catch (error) {
74387
+ await lowerPromise.catch(() => {
74388
+ });
74389
+ throw error;
74390
+ }
74391
+ await lowerPromise;
74303
74392
  const finalized = finalizeGuestProjectionStorage({
74304
74393
  map: map3,
74305
74394
  linked,
@@ -82023,7 +82112,7 @@ ${wasmThreadLinkFlags.map((flag) => ` "-Xlinker", ${JSON.stringify(flag
82023
82112
  REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
82024
82113
  MULTI_MANIFEST_VERSION = 76;
82025
82114
  SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
82026
- compilerSourceDigest = true ? "57c5faa7bb7758647030422e32db0f4a53fbab724723e220c14fea1e41d2391e" : swiftCompilerSourceDigest2(__sootsim_import_meta_dirname);
82115
+ compilerSourceDigest = true ? "834b5c28c27bc5807cbb3c4eed5c44f7de81d47db3e3a8819bea6e6635689b24" : swiftCompilerSourceDigest2(__sootsim_import_meta_dirname);
82027
82116
  nativeCxxCompilerFlags = ["-fno-cxx-modules"];
82028
82117
  MODULE_MAP_RESPONSE_FILE_RUN = 16;
82029
82118
  cFlagArray = (flags) => JSON.stringify(withoutGlogModuleMap(flags));
@@ -139608,6 +139697,7 @@ function swiftGuestControls(one, names, linkedGroups) {
139608
139697
  return {
139609
139698
  source: [
139610
139699
  "import UIKit",
139700
+ ...names.includes("OneNativePicker") ? ["extension OneNativePickerView: OneGuestIncrementalContainer {}"] : [],
139611
139701
  "let guestControls: [String: (UIView?, Spec, Spec?, Spec, @escaping (String, Spec) -> Void) -> UIView] = [",
139612
139702
  ...entries2,
139613
139703
  "]",
@@ -140296,11 +140386,55 @@ private func normalizeStyle(_ raw: Spec?) -> Spec {
140296
140386
  return style
140297
140387
  }
140298
140388
 
140389
+ protocol OneGuestIncrementalContainer: AnyObject {
140390
+ func insertChild(_ child: UIView, at index: Int)
140391
+ func removeChild(_ child: UIView)
140392
+ func reset()
140393
+ }
140394
+
140395
+ private final class DeferredControl {
140396
+ private let composition = ControlComposition()
140397
+ private var node: Spec
140398
+ private lazy var realized = OneNativeDeferredRow(
140399
+ createView: { [weak self] in self?.render() },
140400
+ releaseView: { [weak self] _ in self?.composition.prune(keeping: []) }
140401
+ )
140402
+
140403
+ init(node: Spec, owner: ControlComposition) {
140404
+ self.node = node
140405
+ composition.emit = { [weak owner] name, fields in owner?.emit?(name, fields) }
140406
+ }
140407
+
140408
+ func update(_ node: Spec, content: Spec) -> OneNativeDeferredRow {
140409
+ self.node = node
140410
+ realized.configureListRowModifiers(
140411
+ styleModifiers(node),
140412
+ contentModifiers: styleModifiers(content)
140413
+ )
140414
+ if !composition.views.isEmpty { _ = render() }
140415
+ return realized
140416
+ }
140417
+
140418
+ private func styleModifiers(_ node: Spec) -> String? {
140419
+ let spec = node["spec"] as? Spec
140420
+ let style = spec?["swiftStyle"] as? Spec
140421
+ return style?["sdkModifiers"] as? String
140422
+ }
140423
+
140424
+ private func render() -> UIView {
140425
+ var visited = Set<String>()
140426
+ let view = composition.render(node, visited: &visited)
140427
+ composition.prune(keeping: visited)
140428
+ return view
140429
+ }
140430
+ }
140431
+
140299
140432
  private class ControlComposition {
140300
140433
  private static let reconciledContainers: Set<String> = [
140301
140434
  "OneNativeLazyVStack", "OneNativeLazyHStack", "OneNativeLazyVGrid", "OneNativeLazyHGrid",
140302
140435
  "OneNativeList", "OneNativeSection", "OneNativeForm",
140303
140436
  ]
140437
+ private var deferredRows: [String: DeferredControl] = [:]
140304
140438
  var views: [String: UIView] = [:]
140305
140439
  var specs: [String: Spec] = [:]
140306
140440
  var children: [String: [UIView]] = [:]
@@ -140336,6 +140470,7 @@ private class ControlComposition {
140336
140470
  }
140337
140471
  let view: UIView
140338
140472
  visited.insert(id)
140473
+ deferredRows.removeValue(forKey: id)
140339
140474
  switch control {
140340
140475
  case "OneNativeToolbar":
140341
140476
  view = views[id] ?? OneNativeToolbarView()
@@ -140380,25 +140515,63 @@ private class ControlComposition {
140380
140515
  if let container = view as? OneNativeContainerView {
140381
140516
  container.configureSwiftStyle(style)
140382
140517
  container.onSwiftStyleEvent = visit
140383
- let nested = (node["children"] as? [Spec] ?? []).map { render($0, visited: &visited) }
140518
+ let nodes = node["children"] as? [Spec] ?? []
140384
140519
  if Self.reconciledContainers.contains(control) {
140520
+ let nested = nodes.map { child -> NSObject in
140521
+ if control == "OneNativeSection", let content = deferredContent(child) {
140522
+ let childID = child["id"] as! String
140523
+ visited.insert(childID)
140524
+ let deferred = deferredRows[childID] ?? DeferredControl(node: child, owner: self)
140525
+ deferredRows[childID] = deferred
140526
+ if let previous = views.removeValue(forKey: childID) {
140527
+ (previous as? OneNativeContainerView)?.reset()
140528
+ specs.removeValue(forKey: childID)
140529
+ children.removeValue(forKey: childID)
140530
+ }
140531
+ return deferred.update(child, content: content)
140532
+ }
140533
+ return render(child, visited: &visited)
140534
+ }
140385
140535
  container.reconcileComposedChildren(nested)
140386
140536
  } else {
140387
- reconcile(
140388
- nested,
140389
- previous: children[id] ?? [],
140390
- remove: container.removeChild,
140391
- insert: container.insertChild
140392
- )
140537
+ placeIncrementally(node, id: id, visited: &visited, remove: container.removeChild, insert: container.insertChild)
140393
140538
  }
140394
- children[id] = nested
140539
+ } else if let container = view as? OneGuestIncrementalContainer {
140540
+ placeIncrementally(node, id: id, visited: &visited, remove: container.removeChild, insert: container.insertChild)
140395
140541
  }
140396
140542
  return view
140397
140543
  }
140398
140544
 
140545
+ private func deferredContent(_ node: Spec) -> Spec? {
140546
+ guard (node["spec"] as? Spec)?["control"] as? String == "OneNativeSwipeActions" else { return nil }
140547
+ let content = (node["children"] as? [Spec] ?? []).filter {
140548
+ ($0["spec"] as? Spec)?["control"] as? String != "OneNativeSwipeActionsActions"
140549
+ }
140550
+ guard content.count == 1, (content[0]["spec"] as? Spec)?["control"] as? String == "OneNativeButton" else {
140551
+ return nil
140552
+ }
140553
+ return content[0]
140554
+ }
140555
+
140556
+ private func placeIncrementally(
140557
+ _ node: Spec,
140558
+ id: String,
140559
+ visited: inout Set<String>,
140560
+ remove: (UIView) -> Void,
140561
+ insert: (UIView, Int) -> Void
140562
+ ) {
140563
+ let nested = (node["children"] as? [Spec] ?? []).map { render($0, visited: &visited) }
140564
+ reconcile(nested, previous: children[id] ?? [], remove: remove, insert: insert)
140565
+ children[id] = nested
140566
+ }
140567
+
140399
140568
  func prune(keeping visited: Set<String>) {
140569
+ for id in deferredRows.keys where !visited.contains(id) {
140570
+ deferredRows.removeValue(forKey: id)
140571
+ }
140400
140572
  for (id, view) in views where !visited.contains(id) {
140401
140573
  if let container = view as? OneNativeContainerView { container.reset() }
140574
+ if let container = view as? OneGuestIncrementalContainer { container.reset() }
140402
140575
  views.removeValue(forKey: id)
140403
140576
  specs.removeValue(forKey: id)
140404
140577
  children.removeValue(forKey: id)
@@ -140709,8 +140882,10 @@ private struct NavigationSplitViewBridge: UIViewRepresentable {
140709
140882
  default:
140710
140883
  let root = spec["root"] as! Spec
140711
140884
  precondition((root["spec"] as? Spec)?["control"] as? String == view)
140712
- return AnyView(ControlBridge(root: root, emit: emit)
140713
- .frame(minWidth: 0, maxWidth: .infinity, maxHeight: .infinity))
140885
+ let bridge = ControlBridge(root: root, emit: emit)
140886
+ .frame(minWidth: 0, maxWidth: .infinity, maxHeight: .infinity)
140887
+ let height = (spec["height"] as? Double).map { CGFloat($0) }
140888
+ return AnyView(bridge.frame(height: height))
140714
140889
  }
140715
140890
  }
140716
140891
  }
@@ -145251,7 +145426,7 @@ var init_nitro_superset = __esm({
145251
145426
  init_nitroContract();
145252
145427
  init_swift_standin_digest();
145253
145428
  NITRO_SUPERSET_ENTRY_NAME = "superset";
145254
- NITRO_COMPILER_DIGEST = true ? "e01e1c3d6e35736e741ffd0453be8034714f762be77301de80740ac116cde52b" : nitroCompilerSourceDigest(__sootsim_import_meta_dirname, STANDIN_SOURCE_DIGEST2);
145429
+ NITRO_COMPILER_DIGEST = true ? "dc3119a2538cec9d009fc6b45b9a7c5729812bb7e7f263707bd7410c45a4719e" : nitroCompilerSourceDigest(__sootsim_import_meta_dirname, STANDIN_SOURCE_DIGEST2);
145255
145430
  nitroSupersetLock = parseLock(nitro_superset_lock_default);
145256
145431
  nitroSupersetKey = (inputs2) => nativeEntryKey({ ...inputs2, compiler: NITRO_COMPILER_DIGEST });
145257
145432
  published3 = /* @__PURE__ */ new Map();