peachsim 0.1.2777 → 0.1.2779

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 (154) 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 +669 -840
  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-M5O633NZ.mjs → acorn-SCZ56W4Q.mjs} +3 -3
  27. package/dist-lib/esm-chunks/{chunk-NJHTAVEI.mjs → chunk-6BNEOOBT.mjs} +124 -18
  28. package/dist-lib/esm-chunks/{chunk-LB2X5KYV.mjs → chunk-7VWBLM73.mjs} +1 -1
  29. package/dist-lib/esm-chunks/{chunk-V2I633CU.mjs → chunk-DX5V3733.mjs} +4 -4
  30. package/dist-lib/esm-chunks/{chunk-THHP5XKD.mjs → chunk-E56EZ3QT.mjs} +3 -3
  31. package/dist-lib/esm-chunks/{chunk-TRSHEQVJ.mjs → chunk-FNQXQNQK.mjs} +1 -1
  32. package/dist-lib/esm-chunks/{chunk-WSHBJUCP.mjs → chunk-H2V3ZZTO.mjs} +1 -1
  33. package/dist-lib/esm-chunks/{chunk-OVCIWUV2.mjs → chunk-H6JAFCAZ.mjs} +1 -1
  34. package/dist-lib/esm-chunks/{chunk-ZKPBT6FD.mjs → chunk-HMFIO57I.mjs} +1 -1
  35. package/dist-lib/esm-chunks/{chunk-DPL3I4WY.mjs → chunk-HWK2V6R4.mjs} +1 -1
  36. package/dist-lib/esm-chunks/{chunk-OSESKVWT.mjs → chunk-KAMO4C4X.mjs} +1 -1
  37. package/dist-lib/esm-chunks/{chunk-TONCJKKR.mjs → chunk-KFDP4372.mjs} +1 -1
  38. package/dist-lib/esm-chunks/{chunk-FHYWKCOZ.mjs → chunk-KOULWLTF.mjs} +2 -2
  39. package/dist-lib/esm-chunks/{chunk-Q42OLP7O.mjs → chunk-LVEDBGWX.mjs} +1 -1
  40. package/dist-lib/esm-chunks/{chunk-RX3WDTYI.mjs → chunk-MJXJYVF5.mjs} +1 -1
  41. package/dist-lib/esm-chunks/{chunk-GISUEYXO.mjs → chunk-MK4VAM4G.mjs} +1 -1
  42. package/dist-lib/esm-chunks/{chunk-AGWZKA24.mjs → chunk-Q6XMYYNV.mjs} +168 -421
  43. package/dist-lib/esm-chunks/{chunk-KCSUAVJQ.mjs → chunk-SFTGQN5D.mjs} +1 -1
  44. package/dist-lib/esm-chunks/{chunk-Q53QPYEU.mjs → chunk-SM5MJSQP.mjs} +1 -1
  45. package/dist-lib/esm-chunks/{chunk-3UJO4NG3.mjs → chunk-SNMGOZXQ.mjs} +1 -1
  46. package/dist-lib/esm-chunks/{chunk-OLCLLGZF.mjs → chunk-SZI5IZ76.mjs} +5 -5
  47. package/dist-lib/esm-chunks/{chunk-FB27T2JY.mjs → chunk-T7DTXCV5.mjs} +1 -1
  48. package/dist-lib/esm-chunks/{chunk-IPX66HMP.mjs → chunk-UBM772FD.mjs} +1 -1
  49. package/dist-lib/esm-chunks/{chunk-GMN43CNC.mjs → chunk-VJSHIZ7J.mjs} +1 -1
  50. package/dist-lib/esm-chunks/{chunk-GSTVX33B.mjs → chunk-Z42YJEC4.mjs} +36 -14
  51. package/dist-lib/esm-chunks/{metro-layout-parser-PFRFHGDY.mjs → metro-layout-parser-7S5M3EG6.mjs} +3 -3
  52. package/dist-lib/esm-chunks/{swift-package-prebuilt-NUAEDMSQ.mjs → swift-package-prebuilt-MJSFHIOP.mjs} +12 -12
  53. package/dist-lib/esm-chunks/{swift-sdk-app-module-P3BARE2W.mjs → swift-sdk-app-module-ZIN3LFLS.mjs} +47 -69
  54. package/dist-lib/esm-chunks/{swift-sdk-image-Y6XT7KI4.mjs → swift-sdk-image-MIWPBZEN.mjs} +16 -16
  55. package/dist-lib/esm-chunks/{swift-sdk-image-producer-DYR47O6H.mjs → swift-sdk-image-producer-OTH543HF.mjs} +5 -5
  56. package/dist-lib/expo-swift-bundle.cjs +592 -763
  57. package/dist-lib/expo-swift-metadata.cjs +1 -1
  58. package/dist-lib/expo-swift-metadata.mjs +7 -7
  59. package/dist-lib/home-paths.cjs +1 -1
  60. package/dist-lib/host/bridge-host.cjs +735 -901
  61. package/dist-lib/host/fetch-proxy-handler.cjs +117 -93
  62. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  63. package/dist-lib/host/fetch-proxy-overrides.mjs +2 -2
  64. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  65. package/dist-lib/host/websocket-proxy.cjs +1 -1
  66. package/dist-lib/index.cjs +1 -1
  67. package/dist-lib/kotlin-host.cjs +1 -1
  68. package/dist-lib/menu.cjs +1 -1
  69. package/dist-lib/menu.mjs +3 -3
  70. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  71. package/dist-lib/metro-fingerprint-registry.mjs +3 -3
  72. package/dist-lib/metro-production-bundle.cjs +1 -1
  73. package/dist-lib/metro-production-bundle.mjs +4 -4
  74. package/dist-lib/native-app-identity-project.cjs +20 -15
  75. package/dist-lib/native-app-identity-project.mjs +27 -32
  76. package/dist-lib/native-app-identity.cjs +1 -1
  77. package/dist-lib/native-app-identity.mjs +6 -6
  78. package/dist-lib/native-firebase-metadata.cjs +1 -1
  79. package/dist-lib/native-firebase-metadata.mjs +3 -3
  80. package/dist-lib/pdfium-raster.cjs +1 -1
  81. package/dist-lib/pdfium-raster.mjs +2 -2
  82. package/dist-lib/plist.cjs +1 -1
  83. package/dist-lib/plist.mjs +3 -3
  84. package/dist-lib/profiles.cjs +1 -1
  85. package/dist-lib/public-brand.cjs +1 -1
  86. package/dist-lib/public-origins-lib-esm.json +87 -86
  87. package/dist-lib/public-origins-lib.json +77 -70
  88. package/dist-lib/react-native-host-modules.cjs +1 -1
  89. package/dist-lib/react-native-host-modules.mjs +2 -2
  90. package/dist-lib/reap-browser.cjs +1 -1
  91. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  92. package/dist-lib/sdk.cjs +1 -1
  93. package/dist-lib/sdk.mjs +8 -8
  94. package/dist-lib/skills.cjs +774 -940
  95. package/dist-lib/swift-compile.cjs +376 -525
  96. package/dist-lib/swift-compile.mjs +12 -12
  97. package/dist-lib/swift-package.cjs +1 -1
  98. package/dist-lib/swift-package.mjs +3 -3
  99. package/dist-lib/swift-submit.cjs +1 -1
  100. package/dist-lib/swift-submit.mjs +6 -6
  101. package/dist-lib/swift-svg-raster.cjs +1 -1
  102. package/dist-lib/swift-svg-raster.mjs +2 -2
  103. package/dist-lib/swift-toolchain.cjs +1 -1
  104. package/dist-lib/swift.cjs +1 -1
  105. package/dist-lib/vendor/@peculiar/x509.cjs +1 -1
  106. package/dist-lib/vendor/@ruby/prism/src/nodes.js.cjs +1 -1
  107. package/dist-lib/vendor/@ruby/prism/src/parsePrism.js.cjs +1 -1
  108. package/dist-lib/vendor/acorn.cjs +1 -1
  109. package/dist-lib/vendor/magic-string.cjs +1 -1
  110. package/dist-lib/vendor/stream-json.cjs +1 -1
  111. package/dist-lib/vendor/sucrase/dist/index.js.cjs +1 -1
  112. package/dist-lib/vendor/sucrase/dist/parser/index.js.cjs +1 -1
  113. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/index.js.cjs +1 -1
  114. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/types.js.cjs +1 -1
  115. package/dist-lib/vendor/sucrase.cjs +1 -1
  116. package/dist-lib/vendor/terser.cjs +1 -1
  117. package/dist-lib/vendor/valibot.cjs +1 -1
  118. package/dist-lib/vendor/ws.cjs +1 -1
  119. package/dist-lib/vendor/zod.cjs +1 -1
  120. package/dist-lib/worklet-executable.cjs +1 -1
  121. package/dist-lib/worklet-executable.mjs +3 -3
  122. package/dist-types/packages/peach-engine/core-abi/web/sceneClientContract.d.ts +0 -6
  123. package/dist-types/packages/peach-engine/src/components/native-ui/webview-frame-bridge.d.ts +0 -3
  124. package/dist-types/packages/peach-engine/src/render-worker/worklet-runtime.d.ts +15 -2
  125. package/dist-types/packages/peach-engine/src/render-worker/worklet-wire.d.ts +10 -1
  126. package/dist-types/packages/peach-engine/src/webview-automation-host.d.ts +0 -4
  127. package/package.json +1 -1
  128. package/src/bazel-project.ts +2 -6
  129. package/src/build-cache.ts +3 -2
  130. package/src/sha256.ts +8 -0
  131. package/src/swift-compiler-digest.ts +1 -0
  132. package/src/swift-coverage/indexing.ts +3 -4
  133. package/src/swift-coverage/package.ts +1 -4
  134. package/src/swift-coverage/reader.ts +1 -4
  135. package/src/swift-coverage/source.ts +1 -4
  136. package/src/swift-coverage/xcode-assets.ts +1 -4
  137. package/src/swift-coverage/xcode-bridging.ts +1 -4
  138. package/src/swift-coverage/xcode-packages.ts +1 -4
  139. package/src/swift-coverage/xcode-strings.ts +1 -4
  140. package/src/swift-coverage/xcode.ts +1 -4
  141. package/src/swift-guest-dyld-functions.ts +1 -11
  142. package/src/swift-guest-dyld-table.ts +3 -15
  143. package/src/swift-guest-image-ledger.ts +9 -35
  144. package/src/swift-guest-source-inputs.ts +8 -37
  145. package/src/swift-icu.ts +15 -28
  146. package/src/swift-link-roots.ts +4 -8
  147. package/src/swift-objc-compile.ts +2 -7
  148. package/src/swift-sdk-app-module.ts +5 -27
  149. package/src/swift-sdk-image-wasm.ts +12 -41
  150. package/src/swift-sdk-image.ts +50 -12
  151. package/src/swift-shared-sdk.ts +1 -13
  152. package/src/swift-wasm-archive.ts +6 -11
  153. package/src/swift-wasm-prune.ts +25 -109
  154. package/src/wasm-binary-sections.ts +61 -7
@@ -1,3 +1,5 @@
1
+ import { readULEB, skipLEB } from './wasm-binary-sections'
2
+
1
3
  export function readArMembers(
2
4
  buf: Uint8Array,
3
5
  includeBitcode = false,
@@ -80,19 +82,12 @@ export function localizeDefinedWasmSymbols(
80
82
  const output = new Uint8Array(bytes)
81
83
  let cur = 8
82
84
  const readU = (): number => {
83
- const b0 = bytes[cur++]!
84
- if (b0 < 128) return b0
85
- let res = b0 & 0x7f
86
- let shift = 7
87
- while (true) {
88
- const byte = bytes[cur++]!
89
- res |= (byte & 0x7f) << shift
90
- if ((byte & 0x80) === 0) return res
91
- shift += 7
92
- }
85
+ const [res, next] = readULEB(bytes, cur)
86
+ cur = next
87
+ return res
93
88
  }
94
89
  const skipU = (): void => {
95
- while ((bytes[cur++]! & 0x80) !== 0) {}
90
+ cur = skipLEB(bytes, cur)
96
91
  }
97
92
  const importFuncNames: string[] = []
98
93
  const importGlobalNames: string[] = []
@@ -22,6 +22,7 @@ import { createHash } from 'node:crypto'
22
22
  import fs from 'node:fs'
23
23
  import path from 'node:path'
24
24
  import * as v from 'valibot'
25
+ import { sha256Hex } from './sha256'
25
26
  import { NATIVE_ARCHIVE_OBJECTS_DIR } from './swift-guest-source-plan'
26
27
  import { OBJC_RUNTIME_LOOKUP_SECTION } from './swift-link-roots'
27
28
  import { referencedResourceClasses } from './swift-resource-class-names'
@@ -36,53 +37,15 @@ import {
36
37
  SWIFT_FRAMEWORK_PRODUCT_FILE,
37
38
  swiftFrameworkProductSchema,
38
39
  } from './swiftRuntimeProductContract'
40
+ import {
41
+ encodeWasmNumber as encodeULEB,
42
+ readSLEB,
43
+ readULEB,
44
+ skipLEB,
45
+ } from './wasm-binary-sections'
39
46
 
40
47
  export { localizeDefinedWasmSymbols, readArMembers }
41
48
 
42
- function sha256Hex(bytes: Uint8Array | Buffer): string {
43
- if (typeof Bun !== 'undefined')
44
- return new Bun.CryptoHasher('sha256').update(bytes).digest('hex')
45
- return createHash('sha256').update(bytes).digest('hex')
46
- }
47
-
48
- function readULEB(b: Uint8Array, o: number): [number, number] {
49
- let res = 0
50
- let shift = 0
51
- let p = o
52
- while (true) {
53
- const byte = b[p++]!
54
- res |= (byte & 0x7f) << shift
55
- if ((byte & 0x80) === 0) break
56
- shift += 7
57
- }
58
- return [res, p]
59
- }
60
-
61
- function readSLEB(b: Uint8Array, o: number): [number, number] {
62
- let res = 0
63
- let shift = 0
64
- let p = o
65
- let byte = 0
66
- do {
67
- byte = b[p++]!
68
- res |= (byte & 0x7f) << shift
69
- shift += 7
70
- } while (byte & 0x80)
71
- if (shift < 32 && byte & 0x40) res |= ~0 << shift
72
- return [res, p]
73
- }
74
-
75
- function encodeULEB(val: number): number[] {
76
- const out: number[] = []
77
- do {
78
- let byte = val & 0x7f
79
- val >>>= 7
80
- if (val !== 0) byte |= 0x80
81
- out.push(byte)
82
- } while (val !== 0)
83
- return out
84
- }
85
-
86
49
  // the 64-bit address, table index and function offset relocations patch eight bytes.
87
50
  const WIDE_DATA_RELOCS = new Set([16, 19, 22, 27])
88
51
 
@@ -214,39 +177,14 @@ function decodeRelocations(
214
177
  for (let k = 0; k < sectionCount; k++, i++) {
215
178
  start[i] = length + cur - baseAt
216
179
  const rType = buf[cur++]!
217
- let offset = buf[cur++]!
218
- if (offset >= 128) {
219
- offset &= 0x7f
220
- let shift = 7
221
- while (true) {
222
- const byte = buf[cur++]!
223
- offset |= (byte & 0x7f) << shift
224
- if (byte < 128) break
225
- shift += 7
226
- }
227
- }
228
- let symbol = buf[cur++]!
229
- if (symbol >= 128) {
230
- symbol &= 0x7f
231
- let shift = 7
232
- while (true) {
233
- const byte = buf[cur++]!
234
- symbol |= (byte & 0x7f) << shift
235
- if (byte < 128) break
236
- shift += 7
237
- }
238
- }
180
+ let offset: number
181
+ ;[offset, cur] = readULEB(buf, cur)
182
+ let symbol: number
183
+ ;[symbol, cur] = readULEB(buf, cur)
239
184
  if (rType < 32 && (ADDEND_RELOC_MASK & (1 << rType)) !== 0) {
240
- let byte = buf[cur++]!
241
- let value = byte & 0x7f
242
- let shift = 7
243
- while (byte >= 128) {
244
- byte = buf[cur++]!
245
- value |= (byte & 0x7f) << shift
246
- shift += 7
247
- }
248
- if (shift < 32 && (byte & 0x40) !== 0) value |= ~0 << shift
249
- addend[i] = value
185
+ let value: bigint
186
+ ;[value, cur] = readSLEB(buf, cur)
187
+ addend[i] = Number(BigInt.asIntN(32, value))
250
188
  }
251
189
  ro[i] = offset
252
190
  rs[i] = symbol
@@ -415,8 +353,7 @@ export function patchSwiftrtObject(src: Uint8Array): Uint8Array {
415
353
  }
416
354
  cur = c3
417
355
  if (ADDEND_RELOCATIONS.has(rType)) {
418
- const [, c4] = readSLEB(buf, cur)
419
- cur = c4
356
+ cur = skipLEB(buf, cur)
420
357
  }
421
358
  }
422
359
  }
@@ -438,27 +375,14 @@ function parseWasmObjectBytes(
438
375
  let pos = 8
439
376
  let cur = 8
440
377
  const readU = (): number => {
441
- const b0 = buf[cur++]!
442
- if (b0 < 128) return b0
443
- let res = b0 & 0x7f
444
- let shift = 7
445
- while (true) {
446
- const byte = buf[cur++]!
447
- res |= (byte & 0x7f) << shift
448
- if (byte < 128) return res
449
- shift += 7
450
- }
378
+ const [res, next] = readULEB(buf, cur)
379
+ cur = next
380
+ return res
451
381
  }
452
382
  const skipU = (): void => {
453
- while (buf[cur++]! >= 128) {
454
- // advance past continuation bytes
455
- }
456
- }
457
- const skipS = (): void => {
458
- while (buf[cur++]! >= 128) {
459
- // advance past continuation bytes
460
- }
383
+ cur = skipLEB(buf, cur)
461
384
  }
385
+ const skipS = skipU
462
386
  let numImportFuncs = 0
463
387
  let importsDlsym = false
464
388
  const importFuncNames: string[] = []
@@ -1134,16 +1058,9 @@ export function guestWasmSymbols(bytes: Uint8Array): {
1134
1058
  : Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength)
1135
1059
  let cur = 8
1136
1060
  const readU = (): number => {
1137
- const b0 = bytes[cur++]!
1138
- if (b0 < 128) return b0
1139
- let res = b0 & 0x7f
1140
- let shift = 7
1141
- while (true) {
1142
- const byte = bytes[cur++]!
1143
- res |= (byte & 0x7f) << shift
1144
- if ((byte & 0x80) === 0) return res
1145
- shift += 7
1146
- }
1061
+ const [res, next] = readULEB(bytes, cur)
1062
+ cur = next
1063
+ return res
1147
1064
  }
1148
1065
  let importsDlsym = false
1149
1066
  const importFuncNames: string[] = []
@@ -1339,7 +1256,6 @@ export function swiftArchiveMemberProducts(
1339
1256
  }
1340
1257
  return result
1341
1258
  }
1342
- const hash = (bytes: Uint8Array) => createHash('sha256').update(bytes).digest('hex')
1343
1259
  const names = new Set(selected.map((origin) => origin.member))
1344
1260
  const matches = new Map<string, (SwiftArchiveProduct & { ordinal: number })[]>()
1345
1261
  for (const product of products) {
@@ -1348,7 +1264,7 @@ export function swiftArchiveMemberProducts(
1348
1264
  if (!names.has(member.name)) continue
1349
1265
  const ordinal = (counts.get(member.name) ?? 0) + 1
1350
1266
  counts.set(member.name, ordinal)
1351
- const key = `${member.name}\0${hash(member.bytes)}`
1267
+ const key = `${member.name}\0${sha256Hex(member.bytes)}`
1352
1268
  const group = matches.get(key) ?? []
1353
1269
  group.push({ ...product, ordinal })
1354
1270
  matches.set(key, group)
@@ -1362,7 +1278,7 @@ export function swiftArchiveMemberProducts(
1362
1278
  throw new Error(
1363
1279
  `missing SDK archive member ${original.archive}(${original.member})`,
1364
1280
  )
1365
- const sha256 = hash(source.bytes)
1281
+ const sha256 = sha256Hex(source.bytes)
1366
1282
  return {
1367
1283
  original,
1368
1284
  sha256,
@@ -8,21 +8,71 @@ export function encodeWasmNumber(value: number): number[] {
8
8
  }
9
9
  }
10
10
 
11
+ export function encodeWasmSigned(value: bigint): number[] {
12
+ const out: number[] = []
13
+ for (;;) {
14
+ const byte = Number(value & 127n)
15
+ value >>= 7n
16
+ if ((value === 0n && !(byte & 64)) || (value === -1n && byte & 64)) {
17
+ out.push(byte)
18
+ return out
19
+ }
20
+ out.push(byte | 128)
21
+ }
22
+ }
23
+
11
24
  export function encodeWasmName(name: string): number[] {
12
25
  const bytes = new TextEncoder().encode(name)
13
26
  return [...encodeWasmNumber(bytes.length), ...bytes]
14
27
  }
15
28
 
29
+ export function readULEB(
30
+ bytes: Uint8Array,
31
+ offset: number,
32
+ end = bytes.length,
33
+ ): [number, number] {
34
+ if (offset < end) {
35
+ const first = bytes[offset]!
36
+ if (first < 128) return [first, offset + 1]
37
+ }
38
+ let value = 0
39
+ for (let shift = 0; ; shift += 7) {
40
+ if (offset >= end || shift > 63) throw new Error('invalid wasm integer')
41
+ const byte = bytes[offset++]!
42
+ value += (byte & 127) * 2 ** shift
43
+ if (!(byte & 128)) return [value, offset]
44
+ }
45
+ }
46
+
47
+ export function readSLEB(
48
+ bytes: Uint8Array,
49
+ offset: number,
50
+ end = bytes.length,
51
+ ): [bigint, number] {
52
+ let value = 0n
53
+ let shift = 0n
54
+ let byte = 0
55
+ do {
56
+ if (offset >= end || shift > 70n) throw new Error('invalid wasm integer')
57
+ byte = bytes[offset++]!
58
+ value |= BigInt(byte & 0x7f) << shift
59
+ shift += 7n
60
+ } while (byte & 0x80)
61
+ if (byte & 0x40) value -= 1n << shift
62
+ return [value, offset]
63
+ }
64
+
65
+ export function skipLEB(bytes: Uint8Array, offset: number): number {
66
+ while ((bytes[offset++]! & 0x80) !== 0) {}
67
+ return offset
68
+ }
69
+
16
70
  export function readWasmSection(bytes: Uint8Array, start: number, end: number) {
17
71
  let at = start
18
72
  const number = () => {
19
- let value = 0
20
- for (let shift = 0; ; shift += 7) {
21
- if (at >= end || shift > 63) throw new Error('invalid wasm integer')
22
- const byte = bytes[at++]!
23
- value += (byte & 127) * 2 ** shift
24
- if (!(byte & 128)) return value
25
- }
73
+ const [value, next] = readULEB(bytes, at, end)
74
+ at = next
75
+ return value
26
76
  }
27
77
  return {
28
78
  number,
@@ -36,6 +86,10 @@ export function readWasmSection(bytes: Uint8Array, start: number, end: number) {
36
86
  if (at > end) throw new Error('truncated wasm name')
37
87
  return Buffer.from(bytes.buffer, bytes.byteOffset + at - length, length).toString()
38
88
  },
89
+ skip: (length: number) => {
90
+ at += length
91
+ if (at > end) throw new Error('truncated wasm section')
92
+ },
39
93
  position: () => at,
40
94
  done: () => at === end,
41
95
  }