peachsim 0.1.2246 → 0.1.2247

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 (85) 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 +1 -1
  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 +1 -1
  11. package/dist-lib/bridge-contract.cjs +1 -1
  12. package/dist-lib/bridge-contract.mjs +1 -1
  13. package/dist-lib/bundle-channel.cjs +27 -6
  14. package/dist-lib/capture-contract.cjs +1 -1
  15. package/dist-lib/capture-contract.mjs +1 -1
  16. package/dist-lib/cloud-contract.cjs +1 -1
  17. package/dist-lib/cloud-contract.mjs +1 -1
  18. package/dist-lib/cloud-test-args.cjs +1 -1
  19. package/dist-lib/cloud-test-args.mjs +1 -1
  20. package/dist-lib/cloud.cjs +1 -1
  21. package/dist-lib/cloud.mjs +1 -1
  22. package/dist-lib/config.cjs +1 -1
  23. package/dist-lib/config.mjs +1 -1
  24. package/dist-lib/detox/index.cjs +1 -1
  25. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  26. package/dist-lib/expo-swift-bundle.cjs +26 -5
  27. package/dist-lib/expo-swift-metadata.cjs +1 -1
  28. package/dist-lib/expo-swift-metadata.mjs +1 -1
  29. package/dist-lib/home-paths.cjs +1 -1
  30. package/dist-lib/host/bridge-host.cjs +27 -6
  31. package/dist-lib/host/fetch-proxy-handler.cjs +3 -3
  32. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  33. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  34. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  35. package/dist-lib/host/websocket-proxy.cjs +1 -1
  36. package/dist-lib/index.cjs +3 -3
  37. package/dist-lib/jump-to-source-babel.cjs +1 -1
  38. package/dist-lib/jump-to-source-native.cjs +1 -1
  39. package/dist-lib/kotlin-host.cjs +1 -1
  40. package/dist-lib/menu.cjs +1 -1
  41. package/dist-lib/menu.mjs +1 -1
  42. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  43. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  44. package/dist-lib/metro-production-bundle.cjs +1 -1
  45. package/dist-lib/metro-production-bundle.mjs +1 -1
  46. package/dist-lib/metro.cjs +3 -3
  47. package/dist-lib/native-app-identity-project.cjs +2 -2
  48. package/dist-lib/native-app-identity-project.mjs +2 -2
  49. package/dist-lib/native-app-identity.cjs +1 -1
  50. package/dist-lib/native-app-identity.mjs +1 -1
  51. package/dist-lib/native-firebase-metadata.cjs +1 -1
  52. package/dist-lib/native-firebase-metadata.mjs +1 -1
  53. package/dist-lib/pdfium-raster.cjs +1 -1
  54. package/dist-lib/pdfium-raster.mjs +1 -1
  55. package/dist-lib/plist.cjs +1 -1
  56. package/dist-lib/plist.mjs +1 -1
  57. package/dist-lib/profiles.cjs +1 -1
  58. package/dist-lib/public-brand.cjs +1 -1
  59. package/dist-lib/public-origins-lib-esm.json +24 -24
  60. package/dist-lib/public-origins-lib.json +53 -53
  61. package/dist-lib/react-native-host-modules.cjs +1 -1
  62. package/dist-lib/react-native-host-modules.mjs +1 -1
  63. package/dist-lib/reap-browser.cjs +1 -1
  64. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  65. package/dist-lib/sdk.cjs +1 -1
  66. package/dist-lib/sdk.mjs +1 -1
  67. package/dist-lib/skills.cjs +27 -6
  68. package/dist-lib/swift-compile.cjs +24 -3
  69. package/dist-lib/swift-compile.mjs +24 -3
  70. package/dist-lib/swift-package.cjs +1 -1
  71. package/dist-lib/swift-package.mjs +1 -1
  72. package/dist-lib/swift-submit.cjs +1 -1
  73. package/dist-lib/swift-submit.mjs +1 -1
  74. package/dist-lib/swift-toolchain.cjs +1 -1
  75. package/dist-lib/swift.cjs +1 -1
  76. package/dist-lib/vite-swift.cjs +25 -4
  77. package/dist-lib/vite.cjs +3 -3
  78. package/dist-lib/worklet-executable.cjs +1 -1
  79. package/dist-lib/worklet-executable.mjs +1 -1
  80. package/dist-types/packages/peach-engine/src/engine/node.d.ts +1 -0
  81. package/dist-types/packages/peach-engine/src/engine/text-nested.d.ts +1 -1
  82. package/dist-types/packages/peach-engine/src/engine/types.d.ts +1 -0
  83. package/kotlin/sdk.tar.gz +0 -0
  84. package/package.json +1 -1
  85. package/src/swift-guest-linked-spans.ts +31 -1
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2246 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2247 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
 
3
3
  // src/swift-compile.ts
4
4
  import {
@@ -7554,10 +7554,17 @@ function layout(bytes) {
7554
7554
  }
7555
7555
  if (pos !== dataSection[1]) throw new Error("invalid wasm data section");
7556
7556
  }
7557
+ const dataByAddress = data.map((segment, order) => ({ ...segment, order, maximumEnd: 0 })).sort((a, b) => a.address - b.address || a.order - b.order);
7558
+ let maximumEnd = 0;
7559
+ for (const segment of dataByAddress) {
7560
+ maximumEnd = Math.max(maximumEnd, segment.address + segment.bytes.length);
7561
+ segment.maximumEnd = maximumEnd;
7562
+ }
7557
7563
  return {
7558
7564
  functionsByCodeOffset,
7559
7565
  functionsByTableSlot,
7560
7566
  data,
7567
+ dataByAddress,
7561
7568
  memoryBytes: memoryPages * 65536
7562
7569
  };
7563
7570
  }
@@ -7612,7 +7619,21 @@ function guestLinkedSpans(map, before, after, owners, sectionOwners = /* @__PURE
7612
7619
  const optimizedOwners = /* @__PURE__ */ new Map();
7613
7620
  const dataAt = (module, start, length) => {
7614
7621
  const result = Buffer.alloc(length);
7615
- for (const segment of module.data) {
7622
+ let low = 0;
7623
+ let high = module.dataByAddress.length;
7624
+ while (low < high) {
7625
+ const middle = Math.floor((low + high) / 2);
7626
+ if (module.dataByAddress[middle].maximumEnd <= start) low = middle + 1;
7627
+ else high = middle;
7628
+ }
7629
+ const matching = [];
7630
+ for (let index = low; index < module.dataByAddress.length; index++) {
7631
+ const segment = module.dataByAddress[index];
7632
+ if (segment.address >= start + length) break;
7633
+ if (segment.address + segment.bytes.length > start) matching.push(segment);
7634
+ }
7635
+ matching.sort((a, b) => a.order - b.order);
7636
+ for (const segment of matching) {
7616
7637
  const first = Math.max(start, segment.address);
7617
7638
  const last = Math.min(start + length, segment.address + segment.bytes.length);
7618
7639
  if (first < last)
@@ -13022,7 +13043,7 @@ var darwinRecordsRegion = (quoted2) => quoted2.length ? ["-Wl,--start-lib", ...q
13022
13043
  var REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
13023
13044
  var MULTI_MANIFEST_VERSION = 68;
13024
13045
  var SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
13025
- var compilerSourceDigest = true ? "cd22143ba7a25fbe9f28d0187e37d40819453c2914c0808fbb77c738ef7e105d" : swiftCompilerSourceDigest(import.meta.dirname);
13046
+ var compilerSourceDigest = true ? "c08bc25b20368e967d20bd07b2812d538ac73d60f4f4790ad0a59924bba3b684" : swiftCompilerSourceDigest(import.meta.dirname);
13026
13047
  function swiftArtifactHash(input, release, moduleRoot) {
13027
13048
  const hash = createHash13("sha256");
13028
13049
  hash.update(`swift-compile
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2246 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2247 | (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 __defProp = Object.defineProperty;
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2246 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2247 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
 
3
3
  // src/swift-package.ts
4
4
  function swiftManifestSettings(target) {
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2246 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2247 | (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 __defProp = Object.defineProperty;
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2246 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2247 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
 
3
3
  // src/is-record.ts
4
4
  function isRecord(value) {
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2246 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2247 | (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;
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2246 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2247 | (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 __defProp = Object.defineProperty;
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2246 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2247 | (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;
@@ -12590,10 +12590,17 @@ function layout(bytes) {
12590
12590
  }
12591
12591
  if (pos !== dataSection[1]) throw new Error("invalid wasm data section");
12592
12592
  }
12593
+ const dataByAddress = data.map((segment, order) => ({ ...segment, order, maximumEnd: 0 })).sort((a, b) => a.address - b.address || a.order - b.order);
12594
+ let maximumEnd = 0;
12595
+ for (const segment of dataByAddress) {
12596
+ maximumEnd = Math.max(maximumEnd, segment.address + segment.bytes.length);
12597
+ segment.maximumEnd = maximumEnd;
12598
+ }
12593
12599
  return {
12594
12600
  functionsByCodeOffset,
12595
12601
  functionsByTableSlot,
12596
12602
  data,
12603
+ dataByAddress,
12597
12604
  memoryBytes: memoryPages * 65536
12598
12605
  };
12599
12606
  }
@@ -12648,7 +12655,21 @@ function guestLinkedSpans(map, before, after, owners, sectionOwners = /* @__PURE
12648
12655
  const optimizedOwners = /* @__PURE__ */ new Map();
12649
12656
  const dataAt = (module2, start, length) => {
12650
12657
  const result = Buffer.alloc(length);
12651
- for (const segment of module2.data) {
12658
+ let low = 0;
12659
+ let high = module2.dataByAddress.length;
12660
+ while (low < high) {
12661
+ const middle = Math.floor((low + high) / 2);
12662
+ if (module2.dataByAddress[middle].maximumEnd <= start) low = middle + 1;
12663
+ else high = middle;
12664
+ }
12665
+ const matching = [];
12666
+ for (let index = low; index < module2.dataByAddress.length; index++) {
12667
+ const segment = module2.dataByAddress[index];
12668
+ if (segment.address >= start + length) break;
12669
+ if (segment.address + segment.bytes.length > start) matching.push(segment);
12670
+ }
12671
+ matching.sort((a, b) => a.order - b.order);
12672
+ for (const segment of matching) {
12652
12673
  const first = Math.max(start, segment.address);
12653
12674
  const last = Math.min(start + length, segment.address + segment.bytes.length);
12654
12675
  if (first < last)
@@ -17911,7 +17932,7 @@ var darwinRecordsRegion = (quoted2) => quoted2.length ? ["-Wl,--start-lib", ...q
17911
17932
  var REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
17912
17933
  var MULTI_MANIFEST_VERSION = 68;
17913
17934
  var SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
17914
- var compilerSourceDigest = true ? "cd22143ba7a25fbe9f28d0187e37d40819453c2914c0808fbb77c738ef7e105d" : swiftCompilerSourceDigest(__sootsim_import_meta_dirname);
17935
+ var compilerSourceDigest = true ? "c08bc25b20368e967d20bd07b2812d538ac73d60f4f4790ad0a59924bba3b684" : swiftCompilerSourceDigest(__sootsim_import_meta_dirname);
17915
17936
  function swiftArtifactHash(input, release, moduleRoot) {
17916
17937
  const hash = (0, import_node_crypto13.createHash)("sha256");
17917
17938
  hash.update(`swift-compile
@@ -31526,7 +31547,7 @@ function sourceClosureDigest(srcDir, entrypoints) {
31526
31547
  return hash.digest("hex");
31527
31548
  }
31528
31549
  var standinSourceDigest = (srcDir = __sootsim_import_meta_dirname) => sourceClosureDigest(srcDir, STANDIN_DIGEST_ENTRYPOINTS);
31529
- var STANDIN_SOURCE_DIGEST = true ? "ce843ce67154212aa53c70a7c36567dc28c70b6d5f1a3222fe7527693c0eabf8" : standinSourceDigest();
31550
+ var STANDIN_SOURCE_DIGEST = true ? "5060fb77e22fd3d9fa69d6e25dbc7bca5b3605d41a6bc164f40ccaee2a131504" : standinSourceDigest();
31530
31551
 
31531
31552
  // src/swift-standins.ts
31532
31553
  init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
package/dist-lib/vite.cjs CHANGED
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2246 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2247 | (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;
@@ -3228,7 +3228,7 @@ function readIosSdkTree(root) {
3228
3228
 
3229
3229
  // src/swift-standin-digest.ts
3230
3230
  init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
3231
- var STANDIN_SOURCE_DIGEST = true ? "ce843ce67154212aa53c70a7c36567dc28c70b6d5f1a3222fe7527693c0eabf8" : standinSourceDigest();
3231
+ var STANDIN_SOURCE_DIGEST = true ? "5060fb77e22fd3d9fa69d6e25dbc7bca5b3605d41a6bc164f40ccaee2a131504" : standinSourceDigest();
3232
3232
 
3233
3233
  // src/expo-native-workspace.ts
3234
3234
  init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
@@ -6790,7 +6790,7 @@ var FOUNDATION_IMPLICIT_MODULES = [
6790
6790
  var FOUNDATION_IMPLICIT_FLAGS = FOUNDATION_IMPLICIT_MODULES.map(
6791
6791
  (module2) => `, "-Xfrontend", "-import-module", "-Xfrontend", "${module2}"`
6792
6792
  ).join("");
6793
- var compilerSourceDigest = true ? "cd22143ba7a25fbe9f28d0187e37d40819453c2914c0808fbb77c738ef7e105d" : swiftCompilerSourceDigest2(__sootsim_import_meta_dirname);
6793
+ var compilerSourceDigest = true ? "c08bc25b20368e967d20bd07b2812d538ac73d60f4f4790ad0a59924bba3b684" : swiftCompilerSourceDigest2(__sootsim_import_meta_dirname);
6794
6794
  var CORE_FOUNDATION_HANDLE_IMPORTS = [
6795
6795
  "CFAllocator",
6796
6796
  "CFArray",
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2246 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2247 | (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 __defProp = Object.defineProperty;
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2246 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2247 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
 
3
3
  // src/worklet-executable.ts
4
4
  import { parse } from "acorn";
@@ -183,6 +183,7 @@ export declare function getNodeTransformedRect(node: SootSimNode, options?: {
183
183
  width: number;
184
184
  height: number;
185
185
  };
186
+ export declare function withNativePlacementMeasurementOrigin<T extends NodePoint>(node: SootSimNode, rect: T, options?: LayoutPositionOptions): T;
186
187
  export declare function writeScenePropFlags(node: SootSimNode): void;
187
188
  export declare class SootSimNode {
188
189
  readonly nativeRenderer: NativeRenderer;
@@ -49,7 +49,7 @@ export declare const TEXTKIT_UNATTRIBUTED_METRICS: {
49
49
  export declare function resolveTextKitAttachmentTop(node: SootSimNode, lineBottom: number, attachmentHeight: number): number | null;
50
50
  export declare function resolveUnattributedTextAttachment(node: SootSimNode | null | undefined, text: string, slots: readonly InlineEmbedSlot[]): InlineEmbedSlot | null;
51
51
  export declare function emitNestedTextRuns(builder: ParagraphBuilderLike, rootNode: SootSimNode, rootStyle: SootSimStyle, buildRunStyle: (mergedStyle: SootSimStyle, node: SootSimNode, natural: boolean) => Record<string, any> | null, rootStyles: TextRunStyles, embedPolicy?: {
52
- addPlaceholder: (width: number, height: number, offset: number, natural: boolean) => number;
52
+ addPlaceholder: (width: number, height: number, baselineOffset: number, natural: boolean) => number;
53
53
  embedSlots: InlineEmbedSlot[];
54
54
  naturalRootStyles?: TextRunStyles;
55
55
  }): InlineEmbedSlot[];
@@ -462,6 +462,7 @@ export interface SootSimStyle {
462
462
  _swiftUIWidthProposal?: number;
463
463
  _swiftUIHeightProposal?: number;
464
464
  _minimumScaleFactor?: number;
465
+ _baselineOffset?: number;
465
466
  _hyphenationLocale?: string;
466
467
  _hyphenationFactor?: number;
467
468
  _swiftUIText?: true;
package/kotlin/sdk.tar.gz CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "peachsim",
3
- "version": "0.1.2246",
3
+ "version": "0.1.2247",
4
4
  "description": "Vite and Metro plugins, testing drivers, and SDK exports for peach.",
5
5
  "author": "Tamagui LLC",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -13,6 +13,12 @@ interface WasmLayout {
13
13
  readonly functionsByCodeOffset: Map<number, number>
14
14
  readonly functionsByTableSlot: Map<number, number>
15
15
  readonly data: readonly { address: number; bytes: Uint8Array }[]
16
+ readonly dataByAddress: readonly {
17
+ address: number
18
+ bytes: Uint8Array
19
+ order: number
20
+ maximumEnd: number
21
+ }[]
16
22
  readonly memoryBytes: number
17
23
  }
18
24
 
@@ -205,10 +211,19 @@ function layout(bytes: Uint8Array): WasmLayout {
205
211
  }
206
212
  if (pos !== dataSection[1]) throw new Error('invalid wasm data section')
207
213
  }
214
+ const dataByAddress = data
215
+ .map((segment, order) => ({ ...segment, order, maximumEnd: 0 }))
216
+ .sort((a, b) => a.address - b.address || a.order - b.order)
217
+ let maximumEnd = 0
218
+ for (const segment of dataByAddress) {
219
+ maximumEnd = Math.max(maximumEnd, segment.address + segment.bytes.length)
220
+ segment.maximumEnd = maximumEnd
221
+ }
208
222
  return {
209
223
  functionsByCodeOffset,
210
224
  functionsByTableSlot,
211
225
  data,
226
+ dataByAddress,
212
227
  memoryBytes: memoryPages * 65536,
213
228
  }
214
229
  }
@@ -284,7 +299,22 @@ export function guestLinkedSpans(
284
299
  const optimizedOwners = new Map<number, number>()
285
300
  const dataAt = (module: WasmLayout, start: number, length: number): Buffer => {
286
301
  const result = Buffer.alloc(length)
287
- for (const segment of module.data) {
302
+ let low = 0
303
+ let high = module.dataByAddress.length
304
+ while (low < high) {
305
+ const middle = Math.floor((low + high) / 2)
306
+ if (module.dataByAddress[middle]!.maximumEnd <= start) low = middle + 1
307
+ else high = middle
308
+ }
309
+ const matching: (typeof module.dataByAddress)[number][] = []
310
+ for (let index = low; index < module.dataByAddress.length; index++) {
311
+ const segment = module.dataByAddress[index]!
312
+ if (segment.address >= start + length) break
313
+ if (segment.address + segment.bytes.length > start) matching.push(segment)
314
+ }
315
+ // active segments overwrite in module order even when their ranges overlap.
316
+ matching.sort((a, b) => a.order - b.order)
317
+ for (const segment of matching) {
288
318
  const first = Math.max(start, segment.address)
289
319
  const last = Math.min(start + length, segment.address + segment.bytes.length)
290
320
  if (first < last)