peachsim 0.1.2778 → 0.1.2780

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 (139) 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 +295 -480
  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-RWBIRNWO.mjs → acorn-SPK2673W.mjs} +3 -3
  27. package/dist-lib/esm-chunks/{chunk-ZWOS2EDN.mjs → chunk-3BAOVPYB.mjs} +118 -361
  28. package/dist-lib/esm-chunks/{chunk-MRIDS3GE.mjs → chunk-664T7XWT.mjs} +5 -5
  29. package/dist-lib/esm-chunks/{chunk-QKTKE4OX.mjs → chunk-7B4ZRXZW.mjs} +1 -1
  30. package/dist-lib/esm-chunks/{chunk-G7UJ4BAC.mjs → chunk-7UJZBQ6G.mjs} +1 -1
  31. package/dist-lib/esm-chunks/{chunk-EXU474NE.mjs → chunk-B4DO5WJD.mjs} +1 -1
  32. package/dist-lib/esm-chunks/{chunk-IQSFMB4R.mjs → chunk-DO3C6MOG.mjs} +4 -4
  33. package/dist-lib/esm-chunks/{chunk-K3ULPN2R.mjs → chunk-DZZZCBJY.mjs} +1 -1
  34. package/dist-lib/esm-chunks/{chunk-5TIUTQ55.mjs → chunk-EEN3DGCH.mjs} +1 -1
  35. package/dist-lib/esm-chunks/{chunk-ZDWMPXYI.mjs → chunk-JIGACUAS.mjs} +1 -1
  36. package/dist-lib/esm-chunks/{chunk-X25PQNNH.mjs → chunk-JIKQAODQ.mjs} +1 -1
  37. package/dist-lib/esm-chunks/{chunk-6YHF4VYF.mjs → chunk-MIESONPY.mjs} +1 -1
  38. package/dist-lib/esm-chunks/{chunk-3RPELUA2.mjs → chunk-NDMVV5PE.mjs} +6 -6
  39. package/dist-lib/esm-chunks/{chunk-KX7LV722.mjs → chunk-NLIWJ2AO.mjs} +1 -1
  40. package/dist-lib/esm-chunks/{chunk-5WASPTSS.mjs → chunk-P7DZLDBL.mjs} +1 -1
  41. package/dist-lib/esm-chunks/{chunk-F3OPIKJC.mjs → chunk-RDFBVP4E.mjs} +2 -2
  42. package/dist-lib/esm-chunks/{chunk-DLBUPWTI.mjs → chunk-SWCGFJ5A.mjs} +1 -1
  43. package/dist-lib/esm-chunks/{chunk-KLA74B7J.mjs → chunk-T6THDRRU.mjs} +1 -1
  44. package/dist-lib/esm-chunks/{chunk-3WQANOYY.mjs → chunk-TBKPPEGS.mjs} +1 -1
  45. package/dist-lib/esm-chunks/{chunk-QUVLFF6I.mjs → chunk-UHTFNN5A.mjs} +1 -1
  46. package/dist-lib/esm-chunks/{chunk-GSTHJQMW.mjs → chunk-VV2TNQK4.mjs} +115 -18
  47. package/dist-lib/esm-chunks/{chunk-VZ3NXXUC.mjs → chunk-WKE7Z3LU.mjs} +1 -1
  48. package/dist-lib/esm-chunks/{chunk-LQVLXDRN.mjs → chunk-WXCV7NSJ.mjs} +1 -1
  49. package/dist-lib/esm-chunks/{chunk-KBYVKTVK.mjs → chunk-X2OBXRGN.mjs} +3 -3
  50. package/dist-lib/esm-chunks/{chunk-N2PEXZGL.mjs → chunk-ZDW2NOAO.mjs} +1 -1
  51. package/dist-lib/esm-chunks/{metro-layout-parser-RRIZOLBE.mjs → metro-layout-parser-6N4ZZDLM.mjs} +3 -3
  52. package/dist-lib/esm-chunks/{swift-package-prebuilt-EIZ7MCKR.mjs → swift-package-prebuilt-GF27A4NU.mjs} +12 -12
  53. package/dist-lib/esm-chunks/{swift-sdk-app-module-S2LQ4OXD.mjs → swift-sdk-app-module-WWTSGAS7.mjs} +47 -69
  54. package/dist-lib/esm-chunks/{swift-sdk-image-77FFUGXI.mjs → swift-sdk-image-OQMMOQLZ.mjs} +16 -16
  55. package/dist-lib/esm-chunks/{swift-sdk-image-producer-XFSFUXQJ.mjs → swift-sdk-image-producer-NOH5SG6O.mjs} +5 -5
  56. package/dist-lib/expo-swift-bundle.cjs +295 -480
  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 +301 -486
  61. package/dist-lib/host/fetch-proxy-handler.cjs +22 -11
  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 +1 -1
  75. package/dist-lib/native-app-identity-project.mjs +15 -15
  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 +86 -86
  87. package/dist-lib/public-origins-lib.json +70 -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 +301 -486
  95. package/dist-lib/swift-compile.cjs +288 -465
  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/src/render-worker/compositor-protocol.d.ts +2 -0
  123. package/dist-types/packages/peach-engine/src/render-worker/worklet-runtime.d.ts +15 -2
  124. package/dist-types/packages/peach-engine/src/render-worker/worklet-wire.d.ts +10 -1
  125. package/package.json +1 -1
  126. package/src/swift-compiler-digest.ts +1 -0
  127. package/src/swift-guest-dyld-functions.ts +1 -11
  128. package/src/swift-guest-dyld-table.ts +2 -9
  129. package/src/swift-guest-image-ledger.ts +9 -35
  130. package/src/swift-guest-source-inputs.ts +5 -22
  131. package/src/swift-icu.ts +15 -28
  132. package/src/swift-link-roots.ts +4 -8
  133. package/src/swift-sdk-app-module.ts +5 -27
  134. package/src/swift-sdk-image-wasm.ts +12 -41
  135. package/src/swift-sdk-surface.ts +1 -0
  136. package/src/swift-shared-sdk.ts +1 -13
  137. package/src/swift-wasm-archive.ts +6 -11
  138. package/src/swift-wasm-prune.ts +22 -100
  139. package/src/wasm-binary-sections.ts +61 -7
@@ -1,10 +1,10 @@
1
- /*! peach v0.1.2778 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2780 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  import {
3
3
  acquireSwiftRootReadHold,
4
4
  hasLiveSwiftRootReaders,
5
5
  retainSwiftRootReadHold,
6
6
  withSwiftRootLock
7
- } from "./chunk-F3OPIKJC.mjs";
7
+ } from "./chunk-RDFBVP4E.mjs";
8
8
  import {
9
9
  CORE_FOUNDATION_OVERLAY_GLOBALS,
10
10
  NATIVE_GRAPH_SDK_VERSION,
@@ -20,6 +20,9 @@ import {
20
20
  clearCaseInsensitiveHeaderOverlayCache,
21
21
  clearSwiftSdkPathsCache,
22
22
  emptyMacroEnvironment,
23
+ encodeWasmName,
24
+ encodeWasmNumber,
25
+ encodeWasmSigned,
23
26
  foundationOwnerOf,
24
27
  installVerifiedTarball,
25
28
  iosDeploymentMinimum,
@@ -27,9 +30,13 @@ import {
27
30
  nativelyDeclaredFunctions,
28
31
  objcEnumerations,
29
32
  objcSdkIntakeFlags,
33
+ readSLEB,
34
+ readULEB,
35
+ readWasmSection,
30
36
  rnxHomeDir,
31
37
  sdkObjCDeclarationOwners,
32
38
  sha256Hex,
39
+ skipLEB,
33
40
  stripCCode,
34
41
  swiftBuildJobs,
35
42
  swiftCodeMask,
@@ -54,12 +61,13 @@ import {
54
61
  swiftSharedSdkRoot,
55
62
  swiftSharedSdkViewOptions,
56
63
  wasmMacroEnvironment,
64
+ wasmSections,
57
65
  weakenFoundationOverridesInArchive,
58
66
  withFrameworkCompanionImports,
59
67
  withoutImportedSdkEnumForwards,
60
68
  withoutSwiftDeclarations,
61
69
  writeBuildFile
62
- } from "./chunk-GSTHJQMW.mjs";
70
+ } from "./chunk-VV2TNQK4.mjs";
63
71
  import {
64
72
  SWIFT_AUTOLINK_LINKER,
65
73
  SWIFT_CACHE_HOLD_MARKER,
@@ -76,7 +84,7 @@ import {
76
84
  wasmThreadLinkFlags,
77
85
  windowAdmission,
78
86
  writeSwiftAutolinkLinker
79
- } from "./chunk-6YHF4VYF.mjs";
87
+ } from "./chunk-MIESONPY.mjs";
80
88
  import {
81
89
  SWIFT_BINARY_TREES_DIR,
82
90
  SWIFT_NATIVE_INPUT_ROOT,
@@ -91,7 +99,7 @@ import {
91
99
  isSwiftResourcePath,
92
100
  isSwiftSourceLinkGraph,
93
101
  swiftProjectFilesProblems
94
- } from "./chunk-ZDWMPXYI.mjs";
102
+ } from "./chunk-JIGACUAS.mjs";
95
103
  import {
96
104
  OBJC_RESOURCE_ACCESSOR_BODY,
97
105
  OBJC_RESOURCE_ACCESSOR_HEADER,
@@ -114,16 +122,16 @@ import {
114
122
  swiftPackagePartition,
115
123
  swiftTargetModuleName,
116
124
  withoutGlogModuleMap
117
- } from "./chunk-N2PEXZGL.mjs";
125
+ } from "./chunk-ZDW2NOAO.mjs";
118
126
  import {
119
127
  rnxPublicBrand
120
- } from "./chunk-G7UJ4BAC.mjs";
128
+ } from "./chunk-7UJZBQ6G.mjs";
121
129
  import {
122
130
  isRecord
123
- } from "./chunk-QUVLFF6I.mjs";
131
+ } from "./chunk-UHTFNN5A.mjs";
124
132
  import {
125
133
  __publicField
126
- } from "./chunk-DLBUPWTI.mjs";
134
+ } from "./chunk-SWCGFJ5A.mjs";
127
135
 
128
136
  // src/swift-compile.ts
129
137
  import {
@@ -2889,6 +2897,7 @@ var SWIFT_DIGEST_SOURCES = [
2889
2897
  "swift-objc-prebuilt-catalog.ts",
2890
2898
  "swift-toolchain.ts",
2891
2899
  "swift-shared-sdk.ts",
2900
+ "wasm-binary-sections.ts",
2892
2901
  "swift-distribution-mirror.ts",
2893
2902
  "swift-design-time.ts",
2894
2903
  "binaryen.lock.json",
@@ -4180,14 +4189,9 @@ import fs from "node:fs";
4180
4189
  import path6 from "node:path";
4181
4190
  var OBJC_RUNTIME_LOOKUP_SECTION = "peach_objc_runtime_lookup";
4182
4191
  var leb = (bytes, at) => {
4183
- let value = 0;
4184
- let scale = 1;
4185
- for (; ; ) {
4186
- const byte = bytes[at.offset++];
4187
- value += (byte & 127) * scale;
4188
- if (!(byte & 128)) return value;
4189
- scale *= 128;
4190
- }
4192
+ const [value, next] = readULEB(bytes, at.offset);
4193
+ at.offset = next;
4194
+ return value;
4191
4195
  };
4192
4196
  function objcRootInfo(bytes) {
4193
4197
  const at = { offset: 8 };
@@ -5093,63 +5097,6 @@ function takeGuestStartupData(wasm, address, length) {
5093
5097
  return { wasm: Buffer.concat(parts), bytes };
5094
5098
  }
5095
5099
 
5096
- // src/wasm-binary-sections.ts
5097
- function encodeWasmNumber(value) {
5098
- const bytes = [];
5099
- for (let rest = value; ; ) {
5100
- const byte = rest % 128;
5101
- rest = Math.floor(rest / 128);
5102
- if (rest === 0) return [...bytes, byte];
5103
- bytes.push(byte | 128);
5104
- }
5105
- }
5106
- function encodeWasmName(name) {
5107
- const bytes = new TextEncoder().encode(name);
5108
- return [...encodeWasmNumber(bytes.length), ...bytes];
5109
- }
5110
- function readWasmSection(bytes, start, end) {
5111
- let at = start;
5112
- const number3 = () => {
5113
- let value = 0;
5114
- for (let shift = 0; ; shift += 7) {
5115
- if (at >= end || shift > 63) throw new Error("invalid wasm integer");
5116
- const byte = bytes[at++];
5117
- value += (byte & 127) * 2 ** shift;
5118
- if (!(byte & 128)) return value;
5119
- }
5120
- };
5121
- return {
5122
- number: number3,
5123
- byte: () => {
5124
- if (at >= end) throw new Error("truncated wasm section");
5125
- return bytes[at++];
5126
- },
5127
- name: () => {
5128
- const length = number3();
5129
- at += length;
5130
- if (at > end) throw new Error("truncated wasm name");
5131
- return Buffer.from(bytes.buffer, bytes.byteOffset + at - length, length).toString();
5132
- },
5133
- position: () => at,
5134
- done: () => at === end
5135
- };
5136
- }
5137
- function wasmSections(bytes) {
5138
- if (Buffer.from(bytes.subarray(0, 8)).toString("hex") !== "0061736d01000000")
5139
- throw new Error("not a wasm module");
5140
- const found = [];
5141
- for (let at = 8; at < bytes.length; ) {
5142
- const header = readWasmSection(bytes, at, bytes.length);
5143
- const id = header.byte();
5144
- const size = header.number();
5145
- const start = header.position();
5146
- if (start + size > bytes.length) throw new Error("truncated wasm section");
5147
- found.push({ id, offset: at, start, end: start + size });
5148
- at = start + size;
5149
- }
5150
- return found;
5151
- }
5152
-
5153
5100
  // src/wasm-imports.ts
5154
5101
  function readWasmImports(bytes, section2, visit) {
5155
5102
  const input = readWasmSection(bytes, section2.start, section2.end);
@@ -5410,23 +5357,13 @@ function wasmReader(bytes, start) {
5410
5357
  const rawBuf = Buffer.isBuffer(bytes) ? bytes : Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
5411
5358
  let at = start;
5412
5359
  const u = () => {
5413
- let value = 0;
5414
- for (let shift = 0; ; shift += 7) {
5415
- const byte = bytes[at++];
5416
- value += (byte & 127) * 2 ** shift;
5417
- if (!(byte & 128)) return value;
5418
- }
5360
+ const [value, next] = readULEB(bytes, at);
5361
+ at = next;
5362
+ return value;
5419
5363
  };
5420
5364
  const s = () => {
5421
- let value = 0n;
5422
- let shift = 0n;
5423
- let byte = 0;
5424
- do {
5425
- byte = bytes[at++];
5426
- value |= BigInt(byte & 127) << shift;
5427
- shift += 7n;
5428
- } while (byte & 128);
5429
- if (byte & 64) value -= 1n << shift;
5365
+ const [value, next] = readSLEB(bytes, at);
5366
+ at = next;
5430
5367
  return value;
5431
5368
  };
5432
5369
  return {
@@ -5462,33 +5399,7 @@ function wasmSections2(bytes) {
5462
5399
  }
5463
5400
  return out;
5464
5401
  }
5465
- var uleb = (value) => {
5466
- const out = [];
5467
- do {
5468
- let byte = value % 128;
5469
- value = Math.floor(value / 128);
5470
- if (value) byte |= 128;
5471
- out.push(byte);
5472
- } while (value);
5473
- return out;
5474
- };
5475
- var sleb = (value) => {
5476
- const out = [];
5477
- for (; ; ) {
5478
- const byte = Number(value & 127n);
5479
- value >>= 7n;
5480
- if (value === 0n && !(byte & 64) || value === -1n && byte & 64) {
5481
- out.push(byte);
5482
- return out;
5483
- }
5484
- out.push(byte | 128);
5485
- }
5486
- };
5487
- var encodedName = (name) => {
5488
- const bytes = [...Buffer.from(name)];
5489
- return [...uleb(bytes.length), ...bytes];
5490
- };
5491
- var section = (id, payload) => Uint8Array.from([id, ...uleb(payload.length), ...payload]);
5402
+ var section = (id, payload) => Uint8Array.from([id, ...encodeWasmNumber(payload.length), ...payload]);
5492
5403
  function constant2(r) {
5493
5404
  const op = r.byte();
5494
5405
  if (op !== 65 && op !== 66) throw new Error(`sdk image constant op ${op}`);
@@ -5775,7 +5686,7 @@ function finishSdkImage(bytes, hostExports, libraries, guestMap) {
5775
5686
  else data[entry.name] = value;
5776
5687
  }
5777
5688
  if (entry.kind !== 0 && entry.kind !== 3 || host2.has(entry.name))
5778
- kept.push([...encodedName(entry.name), entry.kind, ...uleb(entry.index)]);
5689
+ kept.push([...encodeWasmName(entry.name), entry.kind, ...encodeWasmNumber(entry.index)]);
5779
5690
  }
5780
5691
  if (guestMap) {
5781
5692
  if (guestMap.code.length !== m.bodies.length)
@@ -5790,19 +5701,19 @@ function finishSdkImage(bytes, hostExports, libraries, guestMap) {
5790
5701
  const er = wasmReader(bytes, elements.start);
5791
5702
  const segments = er.u();
5792
5703
  const replaced = /* @__PURE__ */ new Map([
5793
- [4, [1, 112, 4, ...uleb(tableEnd + added.length)]],
5794
- [7, [...uleb(kept.length), ...kept.flat()]],
5704
+ [4, [1, 112, 4, ...encodeWasmNumber(tableEnd + added.length)]],
5705
+ [7, [...encodeWasmNumber(kept.length), ...kept.flat()]],
5795
5706
  [
5796
5707
  9,
5797
5708
  [
5798
- ...uleb(segments + 1),
5709
+ ...encodeWasmNumber(segments + 1),
5799
5710
  ...bytes.subarray(er.at, elements.end),
5800
5711
  0,
5801
5712
  66,
5802
- ...sleb(BigInt(tableEnd)),
5713
+ ...encodeWasmSigned(BigInt(tableEnd)),
5803
5714
  11,
5804
- ...uleb(added.length),
5805
- ...added.flatMap(uleb)
5715
+ ...encodeWasmNumber(added.length),
5716
+ ...added.flatMap(encodeWasmNumber)
5806
5717
  ]
5807
5718
  ]
5808
5719
  ]);
@@ -5908,33 +5819,33 @@ function codeOnlySdkImage(bytes, constructorMask) {
5908
5819
  if (drop) r.skip(1);
5909
5820
  gated.push(
5910
5821
  66,
5911
- ...sleb(BigInt(constructorMask + index++)),
5822
+ ...encodeWasmSigned(BigInt(constructorMask + index++)),
5912
5823
  45,
5913
5824
  0,
5914
5825
  0,
5915
5826
  4,
5916
5827
  64,
5917
5828
  16,
5918
- ...uleb(callee),
5829
+ ...encodeWasmNumber(callee),
5919
5830
  ...drop ? [26] : [],
5920
5831
  11
5921
5832
  );
5922
5833
  }
5923
5834
  if (index > SWIFT_SDK_CONSTRUCTOR_LIMIT)
5924
5835
  throw new Error(`${index} sdk constructors exceed the mask`);
5925
- gated.push(16, ...uleb(functionIndex("__peach_sdk_register")), 11);
5836
+ gated.push(16, ...encodeWasmNumber(functionIndex("__peach_sdk_register")), 11);
5926
5837
  bodies[constructors] = Uint8Array.from(gated);
5927
5838
  }
5928
- const codeParts = [Uint8Array.from(uleb(bodies.length))];
5929
- for (const body of bodies) codeParts.push(Uint8Array.from(uleb(body.length)), body);
5839
+ const codeParts = [Uint8Array.from(encodeWasmNumber(bodies.length))];
5840
+ for (const body of bodies) codeParts.push(Uint8Array.from(encodeWasmNumber(body.length)), body);
5930
5841
  const codeSize = codeParts.reduce((sum, part) => sum + part.length, 0);
5931
5842
  const tls = passiveSegments(bytes)[0];
5932
5843
  const out = [bytes.subarray(0, 8)];
5933
5844
  for (const s of m.sections) {
5934
5845
  if (s.id === 10) {
5935
- out.push(Uint8Array.from([10, ...uleb(codeSize)]));
5846
+ out.push(Uint8Array.from([10, ...encodeWasmNumber(codeSize)]));
5936
5847
  for (const part of codeParts) out.push(part);
5937
- } else if (s.id === 11) out.push(section(11, [1, 1, ...uleb(tls.length), ...tls]));
5848
+ } else if (s.id === 11) out.push(section(11, [1, 1, ...encodeWasmNumber(tls.length), ...tls]));
5938
5849
  else if (s.id === 12) out.push(section(12, [1]));
5939
5850
  else out.push(bytes.subarray(s.offset, s.end));
5940
5851
  }
@@ -6333,41 +6244,6 @@ function readArMembers(buf, includeBitcode = false) {
6333
6244
  }
6334
6245
 
6335
6246
  // src/swift-wasm-prune.ts
6336
- function readULEB(b, o) {
6337
- let res = 0;
6338
- let shift = 0;
6339
- let p = o;
6340
- while (true) {
6341
- const byte = b[p++];
6342
- res |= (byte & 127) << shift;
6343
- if ((byte & 128) === 0) break;
6344
- shift += 7;
6345
- }
6346
- return [res, p];
6347
- }
6348
- function readSLEB(b, o) {
6349
- let res = 0;
6350
- let shift = 0;
6351
- let p = o;
6352
- let byte = 0;
6353
- do {
6354
- byte = b[p++];
6355
- res |= (byte & 127) << shift;
6356
- shift += 7;
6357
- } while (byte & 128);
6358
- if (shift < 32 && byte & 64) res |= ~0 << shift;
6359
- return [res, p];
6360
- }
6361
- function encodeULEB(val) {
6362
- const out = [];
6363
- do {
6364
- let byte = val & 127;
6365
- val >>>= 7;
6366
- if (val !== 0) byte |= 128;
6367
- out.push(byte);
6368
- } while (val !== 0);
6369
- return out;
6370
- }
6371
6247
  var WIDE_DATA_RELOCS = /* @__PURE__ */ new Set([16, 19, 22, 27]);
6372
6248
  var ROOT_SEG_PREFIXES = [
6373
6249
  ".init_array",
@@ -6460,39 +6336,14 @@ function decodeRelocations(buf, sections) {
6460
6336
  for (let k = 0; k < sectionCount; k++, i++) {
6461
6337
  start[i] = length + cur - baseAt;
6462
6338
  const rType = buf[cur++];
6463
- let offset = buf[cur++];
6464
- if (offset >= 128) {
6465
- offset &= 127;
6466
- let shift = 7;
6467
- while (true) {
6468
- const byte = buf[cur++];
6469
- offset |= (byte & 127) << shift;
6470
- if (byte < 128) break;
6471
- shift += 7;
6472
- }
6473
- }
6474
- let symbol = buf[cur++];
6475
- if (symbol >= 128) {
6476
- symbol &= 127;
6477
- let shift = 7;
6478
- while (true) {
6479
- const byte = buf[cur++];
6480
- symbol |= (byte & 127) << shift;
6481
- if (byte < 128) break;
6482
- shift += 7;
6483
- }
6484
- }
6339
+ let offset;
6340
+ [offset, cur] = readULEB(buf, cur);
6341
+ let symbol;
6342
+ [symbol, cur] = readULEB(buf, cur);
6485
6343
  if (rType < 32 && (ADDEND_RELOC_MASK2 & 1 << rType) !== 0) {
6486
- let byte = buf[cur++];
6487
- let value = byte & 127;
6488
- let shift = 7;
6489
- while (byte >= 128) {
6490
- byte = buf[cur++];
6491
- value |= (byte & 127) << shift;
6492
- shift += 7;
6493
- }
6494
- if (shift < 32 && (byte & 64) !== 0) value |= ~0 << shift;
6495
- addend[i] = value;
6344
+ let value;
6345
+ [value, cur] = readSLEB(buf, cur);
6346
+ addend[i] = Number(BigInt.asIntN(32, value));
6496
6347
  }
6497
6348
  ro[i] = offset;
6498
6349
  rs[i] = symbol;
@@ -6609,8 +6460,7 @@ function patchSwiftrtObject(src) {
6609
6460
  }
6610
6461
  cur = c3;
6611
6462
  if (ADDEND_RELOCATIONS.has(rType)) {
6612
- const [, c4] = readSLEB(buf, cur);
6613
- cur = c4;
6463
+ cur = skipLEB(buf, cur);
6614
6464
  }
6615
6465
  }
6616
6466
  }
@@ -6624,25 +6474,14 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
6624
6474
  let pos = 8;
6625
6475
  let cur = 8;
6626
6476
  const readU = () => {
6627
- const b0 = buf[cur++];
6628
- if (b0 < 128) return b0;
6629
- let res = b0 & 127;
6630
- let shift = 7;
6631
- while (true) {
6632
- const byte = buf[cur++];
6633
- res |= (byte & 127) << shift;
6634
- if (byte < 128) return res;
6635
- shift += 7;
6636
- }
6477
+ const [res, next] = readULEB(buf, cur);
6478
+ cur = next;
6479
+ return res;
6637
6480
  };
6638
6481
  const skipU = () => {
6639
- while (buf[cur++] >= 128) {
6640
- }
6641
- };
6642
- const skipS = () => {
6643
- while (buf[cur++] >= 128) {
6644
- }
6482
+ cur = skipLEB(buf, cur);
6645
6483
  };
6484
+ const skipS = skipU;
6646
6485
  let numImportFuncs = 0;
6647
6486
  let importsDlsym = false;
6648
6487
  const importFuncNames = [];
@@ -7240,16 +7079,9 @@ function guestWasmSymbols(bytes) {
7240
7079
  const rawBuf = Buffer.isBuffer(bytes) ? bytes : Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
7241
7080
  let cur = 8;
7242
7081
  const readU = () => {
7243
- const b0 = bytes[cur++];
7244
- if (b0 < 128) return b0;
7245
- let res = b0 & 127;
7246
- let shift = 7;
7247
- while (true) {
7248
- const byte = bytes[cur++];
7249
- res |= (byte & 127) << shift;
7250
- if ((byte & 128) === 0) return res;
7251
- shift += 7;
7252
- }
7082
+ const [res, next] = readULEB(bytes, cur);
7083
+ cur = next;
7084
+ return res;
7253
7085
  };
7254
7086
  let importsDlsym = false;
7255
7087
  const importFuncNames = [];
@@ -8434,7 +8266,7 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
8434
8266
  zeroDataReloc(i);
8435
8267
  } else {
8436
8268
  const repl = firstLiveInSpecialSeg.get(segIdx);
8437
- const roBytes = encodeULEB(data.ro[i]);
8269
+ const roBytes = encodeWasmNumber(data.ro[i]);
8438
8270
  const out = new Uint8Array(1 + roBytes.length + repl.afterRo.length);
8439
8271
  out[0] = repl.rType;
8440
8272
  out.set(roBytes, 1);
@@ -8530,9 +8362,9 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
8530
8362
  }
8531
8363
  }
8532
8364
  if (entrySlices.length > 0) {
8533
- const cntBytes = Uint8Array.from(encodeULEB(entrySlices.length));
8365
+ const cntBytes = Uint8Array.from(encodeWasmNumber(entrySlices.length));
8534
8366
  const bodyLen = cntBytes.length + entrySlices.reduce((a, b) => a + b.length, 0);
8535
- const lenBytes = Uint8Array.from(encodeULEB(bodyLen));
8367
+ const lenBytes = Uint8Array.from(encodeWasmNumber(bodyLen));
8536
8368
  subChunks.push(Uint8Array.of(6), lenBytes, cntBytes);
8537
8369
  for (const entry of entrySlices) subChunks.push(entry);
8538
8370
  }
@@ -8589,17 +8421,17 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
8589
8421
  lp = subEnd;
8590
8422
  }
8591
8423
  const totalSubLen = subChunks.reduce((a, b) => a + b.length, 0);
8592
- outChunks.push(Uint8Array.of(0), Uint8Array.from(encodeULEB(totalSubLen)));
8424
+ outChunks.push(Uint8Array.of(0), Uint8Array.from(encodeWasmNumber(totalSubLen)));
8593
8425
  for (const chunk of subChunks) outChunks.push(chunk);
8594
8426
  } else if (name === "reloc.CODE") {
8595
8427
  const [, r1] = readULEB(buf, cp);
8596
8428
  const headerSlice = buf.subarray(p, r1);
8597
- const cntBytes = Uint8Array.from(encodeULEB(keptCodeRelocs.length));
8429
+ const cntBytes = Uint8Array.from(encodeWasmNumber(keptCodeRelocs.length));
8598
8430
  const relSlices = keptCodeRelocs.map((i) => relocationBytes(code, i));
8599
8431
  const totalLen = headerSlice.length + cntBytes.length + relSlices.reduce((a, b) => a + b.length, 0);
8600
8432
  outChunks.push(
8601
8433
  Uint8Array.of(0),
8602
- Uint8Array.from(encodeULEB(totalLen)),
8434
+ Uint8Array.from(encodeWasmNumber(totalLen)),
8603
8435
  headerSlice,
8604
8436
  cntBytes
8605
8437
  );
@@ -8607,11 +8439,11 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
8607
8439
  } else if (name === "reloc.DATA") {
8608
8440
  const [, r1] = readULEB(buf, cp);
8609
8441
  const headerSlice = buf.subarray(p, r1);
8610
- const cntBytes = Uint8Array.from(encodeULEB(keptDataRelocBytes.length));
8442
+ const cntBytes = Uint8Array.from(encodeWasmNumber(keptDataRelocBytes.length));
8611
8443
  const totalLen = headerSlice.length + cntBytes.length + keptDataRelocBytes.reduce((a, b) => a + b.length, 0);
8612
8444
  outChunks.push(
8613
8445
  Uint8Array.of(0),
8614
- Uint8Array.from(encodeULEB(totalLen)),
8446
+ Uint8Array.from(encodeWasmNumber(totalLen)),
8615
8447
  headerSlice,
8616
8448
  cntBytes
8617
8449
  );
@@ -8621,7 +8453,7 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
8621
8453
  const nameBytes = buf.subarray(p, cp);
8622
8454
  outChunks.push(
8623
8455
  Uint8Array.of(0),
8624
- Uint8Array.from(encodeULEB(nameBytes.length)),
8456
+ Uint8Array.from(encodeWasmNumber(nameBytes.length)),
8625
8457
  nameBytes
8626
8458
  );
8627
8459
  } else if (name.startsWith("reloc..debug_")) {
@@ -8629,7 +8461,7 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
8629
8461
  const headerSlice = buf.subarray(p, r1);
8630
8462
  outChunks.push(
8631
8463
  Uint8Array.of(0),
8632
- Uint8Array.from(encodeULEB(headerSlice.length + 1)),
8464
+ Uint8Array.from(encodeWasmNumber(headerSlice.length + 1)),
8633
8465
  headerSlice,
8634
8466
  Uint8Array.of(0)
8635
8467
  );
@@ -8882,16 +8714,13 @@ var ByteWriter = class {
8882
8714
  this.buf[this.pos++] = value;
8883
8715
  }
8884
8716
  uleb(value) {
8885
- this.ensure(10);
8886
- let pos = this.pos;
8887
- const buf = this.buf;
8888
- do {
8889
- let byte = value % 128;
8890
- value = Math.floor(value / 128);
8891
- if (value) byte |= 128;
8892
- buf[pos++] = byte;
8893
- } while (value);
8894
- this.pos = pos;
8717
+ if (value < 128) {
8718
+ this.byte(value);
8719
+ return;
8720
+ }
8721
+ const encoded = encodeWasmNumber(value);
8722
+ this.ensure(encoded.length);
8723
+ for (let i = 0; i < encoded.length; i++) this.buf[this.pos++] = encoded[i];
8895
8724
  }
8896
8725
  bytes(source, start = 0, end = source.length) {
8897
8726
  const len = end - start;
@@ -8913,34 +8742,11 @@ var ByteWriter = class {
8913
8742
  return this.buf.subarray(0, this.pos);
8914
8743
  }
8915
8744
  };
8916
- function readNumber(bytes, position) {
8917
- if (position < bytes.length) {
8918
- const first = bytes[position];
8919
- if (first < 128) return [first, position + 1];
8920
- }
8921
- let value = 0;
8922
- let shift = 0;
8923
- for (; ; ) {
8924
- if (position >= bytes.length || shift > 63) throw new Error("invalid wasm integer");
8925
- const byte = bytes[position++];
8926
- value += (byte & 127) * 2 ** shift;
8927
- if (!(byte & 128)) return [value, position];
8928
- shift += 7;
8929
- }
8930
- }
8931
8745
  function encodeNumber(value) {
8932
- if (value < 128) return Buffer.from([value]);
8933
- const bytes = [];
8934
- do {
8935
- let byte = value % 128;
8936
- value = Math.floor(value / 128);
8937
- if (value) byte |= 128;
8938
- bytes.push(byte);
8939
- } while (value);
8940
- return Buffer.from(bytes);
8746
+ return Buffer.from(encodeWasmNumber(value));
8941
8747
  }
8942
8748
  function readString(bytes, position) {
8943
- const [length, start] = readNumber(bytes, position);
8749
+ const [length, start] = readULEB(bytes, position);
8944
8750
  if (start + length > bytes.length) throw new Error("invalid wasm string");
8945
8751
  return [
8946
8752
  Buffer.from(bytes.buffer, bytes.byteOffset + start, length).toString("utf8"),
@@ -9269,13 +9075,13 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
9269
9075
  for (const subsection of subsections) {
9270
9076
  if (subsection.kind === 6 && objcLoader !== void 0) {
9271
9077
  const content = subsection.parts[0];
9272
- const [count, entriesStart] = readNumber(content, 0);
9078
+ const [count, entriesStart] = readULEB(content, 0);
9273
9079
  const initWriter = new ByteWriter(content.length + 16);
9274
9080
  initWriter.bytes(content, 0, entriesStart);
9275
9081
  let entryStart = entriesStart;
9276
9082
  for (let i = 0; i < count; i++) {
9277
- const [, symbolStart] = readNumber(content, entryStart);
9278
- const [symbol, entryEnd] = readNumber(content, symbolStart);
9083
+ const [, symbolStart] = readULEB(content, entryStart);
9084
+ const [symbol, entryEnd] = readULEB(content, symbolStart);
9279
9085
  if (symbol === objcLoader) {
9280
9086
  initWriter.uleb(1);
9281
9087
  initWriter.bytes(content, symbolStart, entryEnd);
@@ -9345,7 +9151,7 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
9345
9151
  if (position < bytes.length && bytes[position] < 128) {
9346
9152
  size = bytes[position++];
9347
9153
  } else {
9348
- const [val, next] = readNumber(bytes, position);
9154
+ const [val, next] = readULEB(bytes, position);
9349
9155
  size = val;
9350
9156
  position = next;
9351
9157
  }
@@ -10104,7 +9910,7 @@ function nameGuestImageAliases(wasm, symbols) {
10104
9910
  const parts = [wasm.subarray(0, 8)];
10105
9911
  let position = 8;
10106
9912
  while (position < wasm.length) {
10107
- const [size, start] = readNumber(wasm, position + 1);
9913
+ const [size, start] = readULEB(wasm, position + 1);
10108
9914
  const end = start + size;
10109
9915
  const custom = wasm[position] === 0 ? readString(wasm, start) : void 0;
10110
9916
  if (custom?.[0] !== "name") {
@@ -10115,17 +9921,17 @@ function nameGuestImageAliases(wasm, symbols) {
10115
9921
  const subsections = [encodedString("name")];
10116
9922
  let at = custom[1];
10117
9923
  while (at < end) {
10118
- const [subSize, subStart] = readNumber(wasm, at + 1);
9924
+ const [subSize, subStart] = readULEB(wasm, at + 1);
10119
9925
  const subEnd = subStart + subSize;
10120
9926
  if (wasm[at] !== 1) {
10121
9927
  subsections.push(wasm.subarray(at, subEnd));
10122
9928
  at = subEnd;
10123
9929
  continue;
10124
9930
  }
10125
- let [count, cursor] = readNumber(wasm, subStart);
9931
+ let [count, cursor] = readULEB(wasm, subStart);
10126
9932
  const entries2 = [encodeNumber(count)];
10127
9933
  for (; count > 0; count--) {
10128
- const [index, next] = readNumber(wasm, cursor);
9934
+ const [index, next] = readULEB(wasm, cursor);
10129
9935
  const [name, after] = readString(wasm, next);
10130
9936
  cursor = after;
10131
9937
  const symbol = symbols[Number(alias.exec(name)?.[1] ?? -1)];
@@ -10440,13 +10246,6 @@ function sha256Buffer(bytes) {
10440
10246
  return createHash5("sha256").update(bytes).digest();
10441
10247
  }
10442
10248
  var PACK_BYTES = 64 * 1024;
10443
- function uleb2(value) {
10444
- const bytes = [];
10445
- for (let rest = value; ; rest = Math.floor(rest / 128)) {
10446
- if (rest < 128) return [...bytes, rest];
10447
- bytes.push(rest % 128 | 128);
10448
- }
10449
- }
10450
10249
  function encodeGuestDyldTable(rows) {
10451
10250
  const encoded = rows.map((row) => ({ ...row, bytes: Buffer.from(row.name) })).sort((a, b) => Buffer.compare(a.bytes, b.bytes));
10452
10251
  const packs = [];
@@ -10459,7 +10258,7 @@ function encodeGuestDyldTable(rows) {
10459
10258
  value.writeBigUInt64LE(row.value);
10460
10259
  const bytes = Buffer.concat([
10461
10260
  row.bytes,
10462
- Buffer.from([0, ...uleb2(row.image), row.kind]),
10261
+ Buffer.from([0, ...encodeWasmNumber(row.image), row.kind]),
10463
10262
  value
10464
10263
  ]);
10465
10264
  if (!current.length) firsts.push(row.bytes);
@@ -10555,16 +10354,6 @@ async function mapLimit(items, limit, worker) {
10555
10354
  }
10556
10355
 
10557
10356
  // src/swift-guest-dyld-functions.ts
10558
- var uleb3 = (value) => {
10559
- const out = [];
10560
- do {
10561
- let byte = value % 128;
10562
- value = Math.floor(value / 128);
10563
- if (value) byte |= 128;
10564
- out.push(byte);
10565
- } while (value);
10566
- return out;
10567
- };
10568
10357
  var SECTION_ORDER = [1, 2, 3, 4, 5, 13, 6, 7, 8, 9, 12, 10, 11];
10569
10358
  function skipValueType(r) {
10570
10359
  const type = r.byte();
@@ -10609,8 +10398,8 @@ function readImports2(bytes, sections) {
10609
10398
  return { functions, table64 };
10610
10399
  }
10611
10400
  function vectorSection(id, count, parts) {
10612
- const body = Buffer.concat([Buffer.from(uleb3(count)), ...parts]);
10613
- return Buffer.concat([Buffer.from([id, ...uleb3(body.length)]), body]);
10401
+ const body = Buffer.concat([Buffer.from(encodeWasmNumber(count)), ...parts]);
10402
+ return Buffer.concat([Buffer.from([id, ...encodeWasmNumber(body.length)]), body]);
10614
10403
  }
10615
10404
  function rewriteSections(bytes, sections, changes) {
10616
10405
  const out = [bytes.subarray(0, 8)];
@@ -10671,9 +10460,9 @@ function appendLazyPlacement(bytes, functions, table) {
10671
10460
  vectorSection(2, count + 1, [
10672
10461
  found && header ? bytes.subarray(header.at, found.end) : new Uint8Array(),
10673
10462
  Buffer.from([
10674
- ...uleb3(module.length),
10463
+ ...encodeWasmNumber(module.length),
10675
10464
  ...module,
10676
- ...uleb3(name2.length),
10465
+ ...encodeWasmNumber(name2.length),
10677
10466
  ...name2,
10678
10467
  1,
10679
10468
  112,
@@ -10695,7 +10484,7 @@ function appendLazyPlacement(bytes, functions, table) {
10695
10484
  elements.splice(
10696
10485
  placementIndex,
10697
10486
  0,
10698
- Buffer.from([1, 0, ...uleb3(functions.length), ...functions.flatMap(uleb3)])
10487
+ Buffer.from([1, 0, ...encodeWasmNumber(functions.length), ...functions.flatMap(encodeWasmNumber)])
10699
10488
  );
10700
10489
  const place2 = imports.functions + declared.length;
10701
10490
  const instructions = [
@@ -10709,7 +10498,7 @@ function appendLazyPlacement(bytes, functions, table) {
10709
10498
  1,
10710
10499
  252,
10711
10500
  12,
10712
- ...uleb3(placementIndex),
10501
+ ...encodeWasmNumber(placementIndex),
10713
10502
  0,
10714
10503
  11
10715
10504
  ];
@@ -10730,14 +10519,14 @@ function appendLazyPlacement(bytes, functions, table) {
10730
10519
  3,
10731
10520
  vectorSection(3, declared.length + 1, [
10732
10521
  ...declared,
10733
- Buffer.from(uleb3(types.length))
10522
+ Buffer.from(encodeWasmNumber(types.length))
10734
10523
  ])
10735
10524
  ],
10736
10525
  [
10737
10526
  7,
10738
10527
  vectorSection(7, exports.length + 1, [
10739
10528
  ...exports,
10740
- Buffer.from([...uleb3(name.length), ...name, 0, ...uleb3(place2)])
10529
+ Buffer.from([...encodeWasmNumber(name.length), ...name, 0, ...encodeWasmNumber(place2)])
10741
10530
  ])
10742
10531
  ],
10743
10532
  [9, vectorSection(9, elements.length, elements)],
@@ -10745,7 +10534,7 @@ function appendLazyPlacement(bytes, functions, table) {
10745
10534
  10,
10746
10535
  vectorSection(10, bodies.length + 1, [
10747
10536
  ...bodies,
10748
- Buffer.from([...uleb3(instructions.length), ...instructions])
10537
+ Buffer.from([...encodeWasmNumber(instructions.length), ...instructions])
10749
10538
  ])
10750
10539
  ]
10751
10540
  ])
@@ -14082,30 +13871,12 @@ function wasmAutolinkEntries(bytes, out) {
14082
13871
  const len = bytes.length;
14083
13872
  while (pos < len) {
14084
13873
  const id = bytes[pos++];
14085
- let sz = bytes[pos++];
14086
- if (sz >= 128) {
14087
- sz &= 127;
14088
- let shift = 7;
14089
- while (true) {
14090
- const b = bytes[pos++];
14091
- sz |= (b & 127) << shift;
14092
- if (b < 128) break;
14093
- shift += 7;
14094
- }
14095
- }
13874
+ let sz;
13875
+ [sz, pos] = readULEB(bytes, pos, len);
14096
13876
  const end = pos + sz;
14097
13877
  if (id === 0) {
14098
- let nLen = bytes[pos++];
14099
- if (nLen >= 128) {
14100
- nLen &= 127;
14101
- let shift = 7;
14102
- while (true) {
14103
- const b = bytes[pos++];
14104
- nLen |= (b & 127) << shift;
14105
- if (b < 128) break;
14106
- shift += 7;
14107
- }
14108
- }
13878
+ let nLen;
13879
+ [nLen, pos] = readULEB(bytes, pos, end);
14109
13880
  if (nLen === 24 && raw2.toString("ascii", pos, pos + 24) === ".swift1_autolink_entries") {
14110
13881
  const payload = raw2.toString("utf8", pos + 24, end);
14111
13882
  for (const entry of payload.split("\0")) {
@@ -14666,7 +14437,7 @@ async function compileGuestLink(options) {
14666
14437
  };
14667
14438
  const sdk = options.sdkImage;
14668
14439
  const sdkCallers = sdk.sdkInterface.guestCallers;
14669
- const sdkObjects = (await import("./swift-sdk-image-77FFUGXI.mjs")).readSwiftSdkManifestIndex(
14440
+ const sdkObjects = (await import("./swift-sdk-image-OQMMOQLZ.mjs")).readSwiftSdkManifestIndex(
14670
14441
  sdk
14671
14442
  ).guestObjects;
14672
14443
  if (!sdkCallers || !sdkObjects)
@@ -14966,7 +14737,7 @@ async function compileGuestLink(options) {
14966
14737
  swiftAppModuleThunkSection,
14967
14738
  swiftSdkProjectionSpans,
14968
14739
  writeSwiftSdkAppLink
14969
- } = await import("./swift-sdk-app-module-S2LQ4OXD.mjs");
14740
+ } = await import("./swift-sdk-app-module-WWTSGAS7.mjs");
14970
14741
  const project = options.project;
14971
14742
  const work = project ? mkdtempSync2(path14.join(directory, "app-module-")) : path14.join(directory, "app-module");
14972
14743
  if (project) chownSync(work, project.uid, project.gid);
@@ -15652,36 +15423,22 @@ function archiveMember(archive, name) {
15652
15423
  throw new Error(`swift-icu: ${name} is not in the sdk's icu archive`);
15653
15424
  }
15654
15425
  function icuSegment(object2) {
15655
- let at = 8;
15656
- const leb2 = () => {
15657
- let result = 0;
15658
- let shift = 0;
15659
- let byte;
15660
- do {
15661
- byte = object2[at++];
15662
- result += (byte & 127) * 2 ** shift;
15663
- shift += 7;
15664
- } while (byte & 128);
15665
- return result;
15666
- };
15667
15426
  const found = [];
15668
- while (at < object2.length) {
15669
- const id = object2[at++];
15670
- const size = leb2();
15671
- const end = at + size;
15672
- if (id === 11) {
15673
- for (let count = leb2(); count > 0; count--) {
15674
- if (leb2() !== 0) throw new Error("swift-icu: unexpected data segment kind");
15675
- at++;
15676
- leb2();
15677
- at++;
15678
- const length = leb2();
15679
- const bytes = object2.subarray(at, at + length);
15680
- if (bytes[2] === 218 && bytes[3] === 39) found.push(bytes);
15681
- at += length;
15682
- }
15427
+ for (const section2 of wasmSections(object2)) {
15428
+ if (section2.id !== 11) continue;
15429
+ const reader = readWasmSection(object2, section2.start, section2.end);
15430
+ for (let count = reader.number(); count > 0; count--) {
15431
+ if (reader.number() !== 0)
15432
+ throw new Error("swift-icu: unexpected data segment kind");
15433
+ reader.byte();
15434
+ reader.number();
15435
+ reader.byte();
15436
+ const length = reader.number();
15437
+ const start = reader.position();
15438
+ const bytes = object2.subarray(start, start + length);
15439
+ if (bytes[2] === 218 && bytes[3] === 39) found.push(bytes);
15440
+ reader.skip(length);
15683
15441
  }
15684
- at = end;
15685
15442
  }
15686
15443
  if (found.length !== 1)
15687
15444
  throw new Error(`swift-icu: expected one icu data segment, found ${found.length}`);
@@ -16971,7 +16728,7 @@ var darwinRecordsRegion = (quoted2) => quoted2.length ? ["-Wl,--start-lib", ...q
16971
16728
  var REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
16972
16729
  var MULTI_MANIFEST_VERSION = 76;
16973
16730
  var SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
16974
- var compilerSourceDigest = true ? "3bdbb1d31ba7d202e612a91b60a3b588f9bc94a11990fb114585b3e2521857f5" : swiftCompilerSourceDigest(import.meta.dirname);
16731
+ var compilerSourceDigest = true ? "05ea8272883560029dae1c9aef2497d3f4d9e0d3418ef288c47c562673f5ba19" : swiftCompilerSourceDigest(import.meta.dirname);
16975
16732
  function swiftArtifactHash(input, release, moduleRoot) {
16976
16733
  return swiftCompileInputHash(input, release).update(swiftModuleDigest(moduleRoot)).digest("hex");
16977
16734
  }
@@ -21596,7 +21353,7 @@ async function compileSwiftProjectOnce(sources, options) {
21596
21353
  const distribution = swiftDistributionAt(moduleRoot);
21597
21354
  const mirrorDistribution = options.linkOnly || options.project ? null : distribution;
21598
21355
  if (distribution) refreshSwiftCacheHold(moduleRoot);
21599
- const input = distribution && !options.intermediates ? (await import("./swift-package-prebuilt-EIZ7MCKR.mjs")).useSwiftPackagePrebuilts(
21356
+ const input = distribution && !options.intermediates ? (await import("./swift-package-prebuilt-GF27A4NU.mjs")).useSwiftPackagePrebuilts(
21600
21357
  sources,
21601
21358
  moduleRoot,
21602
21359
  options.toolchainBin
@@ -21609,7 +21366,7 @@ async function compileSwiftProjectOnce(sources, options) {
21609
21366
  sources: path23.join(root, "Sources", "App"),
21610
21367
  multi: compileTargets(input).length > 0
21611
21368
  };
21612
- const sdkImage = options.linkOnly ? void 0 : await (await import("./swift-sdk-image-77FFUGXI.mjs")).buildSwiftSdkImage(
21369
+ const sdkImage = options.linkOnly ? void 0 : await (await import("./swift-sdk-image-OQMMOQLZ.mjs")).buildSwiftSdkImage(
21613
21370
  moduleRoot,
21614
21371
  !!guestGraph,
21615
21372
  distribution ? [] : linkedFrameworkTargets(moduleRoot, input).imports,
@@ -22348,7 +22105,7 @@ ${compatShape}` : "";
22348
22105
  });
22349
22106
  sdkAsset = { key: sdkImage.key, sha256: sdkImage.sha256, binding };
22350
22107
  } else {
22351
- const { buildSwiftAppModule } = await import("./swift-sdk-app-module-S2LQ4OXD.mjs");
22108
+ const { buildSwiftAppModule } = await import("./swift-sdk-app-module-WWTSGAS7.mjs");
22352
22109
  const binding = await buildSwiftAppModule({
22353
22110
  buildRoot: root2,
22354
22111
  toolchainBin: options.toolchainBin,