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.
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -1
- package/dist-lib/auth/shared-session.cjs +1 -1
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/beta.cjs +1 -1
- package/dist-lib/beta.mjs +2 -2
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/bridge-contract-input.cjs +1 -1
- package/dist-lib/bridge-contract-input.mjs +5 -5
- package/dist-lib/bridge-contract.cjs +1 -1
- package/dist-lib/bridge-contract.mjs +3 -3
- package/dist-lib/bundle-channel.cjs +669 -840
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +3 -3
- package/dist-lib/cloud-contract.cjs +1 -1
- package/dist-lib/cloud-contract.mjs +3 -3
- package/dist-lib/cloud-test-args.cjs +1 -1
- package/dist-lib/cloud-test-args.mjs +2 -2
- package/dist-lib/cloud.cjs +1 -1
- package/dist-lib/cloud.mjs +7 -7
- package/dist-lib/config.cjs +1 -1
- package/dist-lib/config.mjs +5 -5
- package/dist-lib/detox/index.cjs +1 -1
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/esm-chunks/{acorn-M5O633NZ.mjs → acorn-SCZ56W4Q.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-NJHTAVEI.mjs → chunk-6BNEOOBT.mjs} +124 -18
- package/dist-lib/esm-chunks/{chunk-LB2X5KYV.mjs → chunk-7VWBLM73.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-V2I633CU.mjs → chunk-DX5V3733.mjs} +4 -4
- package/dist-lib/esm-chunks/{chunk-THHP5XKD.mjs → chunk-E56EZ3QT.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-TRSHEQVJ.mjs → chunk-FNQXQNQK.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-WSHBJUCP.mjs → chunk-H2V3ZZTO.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-OVCIWUV2.mjs → chunk-H6JAFCAZ.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-ZKPBT6FD.mjs → chunk-HMFIO57I.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-DPL3I4WY.mjs → chunk-HWK2V6R4.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-OSESKVWT.mjs → chunk-KAMO4C4X.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-TONCJKKR.mjs → chunk-KFDP4372.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-FHYWKCOZ.mjs → chunk-KOULWLTF.mjs} +2 -2
- package/dist-lib/esm-chunks/{chunk-Q42OLP7O.mjs → chunk-LVEDBGWX.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-RX3WDTYI.mjs → chunk-MJXJYVF5.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-GISUEYXO.mjs → chunk-MK4VAM4G.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-AGWZKA24.mjs → chunk-Q6XMYYNV.mjs} +168 -421
- package/dist-lib/esm-chunks/{chunk-KCSUAVJQ.mjs → chunk-SFTGQN5D.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-Q53QPYEU.mjs → chunk-SM5MJSQP.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-3UJO4NG3.mjs → chunk-SNMGOZXQ.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-OLCLLGZF.mjs → chunk-SZI5IZ76.mjs} +5 -5
- package/dist-lib/esm-chunks/{chunk-FB27T2JY.mjs → chunk-T7DTXCV5.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-IPX66HMP.mjs → chunk-UBM772FD.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-GMN43CNC.mjs → chunk-VJSHIZ7J.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-GSTVX33B.mjs → chunk-Z42YJEC4.mjs} +36 -14
- package/dist-lib/esm-chunks/{metro-layout-parser-PFRFHGDY.mjs → metro-layout-parser-7S5M3EG6.mjs} +3 -3
- package/dist-lib/esm-chunks/{swift-package-prebuilt-NUAEDMSQ.mjs → swift-package-prebuilt-MJSFHIOP.mjs} +12 -12
- package/dist-lib/esm-chunks/{swift-sdk-app-module-P3BARE2W.mjs → swift-sdk-app-module-ZIN3LFLS.mjs} +47 -69
- package/dist-lib/esm-chunks/{swift-sdk-image-Y6XT7KI4.mjs → swift-sdk-image-MIWPBZEN.mjs} +16 -16
- package/dist-lib/esm-chunks/{swift-sdk-image-producer-DYR47O6H.mjs → swift-sdk-image-producer-OTH543HF.mjs} +5 -5
- package/dist-lib/expo-swift-bundle.cjs +592 -763
- package/dist-lib/expo-swift-metadata.cjs +1 -1
- package/dist-lib/expo-swift-metadata.mjs +7 -7
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +735 -901
- package/dist-lib/host/fetch-proxy-handler.cjs +117 -93
- package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.mjs +2 -2
- package/dist-lib/host/replacement-module-handler.cjs +1 -1
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +1 -1
- package/dist-lib/kotlin-host.cjs +1 -1
- package/dist-lib/menu.cjs +1 -1
- package/dist-lib/menu.mjs +3 -3
- package/dist-lib/metro-fingerprint-registry.cjs +1 -1
- package/dist-lib/metro-fingerprint-registry.mjs +3 -3
- package/dist-lib/metro-production-bundle.cjs +1 -1
- package/dist-lib/metro-production-bundle.mjs +4 -4
- package/dist-lib/native-app-identity-project.cjs +20 -15
- package/dist-lib/native-app-identity-project.mjs +27 -32
- package/dist-lib/native-app-identity.cjs +1 -1
- package/dist-lib/native-app-identity.mjs +6 -6
- package/dist-lib/native-firebase-metadata.cjs +1 -1
- package/dist-lib/native-firebase-metadata.mjs +3 -3
- package/dist-lib/pdfium-raster.cjs +1 -1
- package/dist-lib/pdfium-raster.mjs +2 -2
- package/dist-lib/plist.cjs +1 -1
- package/dist-lib/plist.mjs +3 -3
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/public-origins-lib-esm.json +87 -86
- package/dist-lib/public-origins-lib.json +77 -70
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +2 -2
- package/dist-lib/reap-browser.cjs +1 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
- package/dist-lib/sdk.cjs +1 -1
- package/dist-lib/sdk.mjs +8 -8
- package/dist-lib/skills.cjs +774 -940
- package/dist-lib/swift-compile.cjs +376 -525
- package/dist-lib/swift-compile.mjs +12 -12
- package/dist-lib/swift-package.cjs +1 -1
- package/dist-lib/swift-package.mjs +3 -3
- package/dist-lib/swift-submit.cjs +1 -1
- package/dist-lib/swift-submit.mjs +6 -6
- package/dist-lib/swift-svg-raster.cjs +1 -1
- package/dist-lib/swift-svg-raster.mjs +2 -2
- package/dist-lib/swift-toolchain.cjs +1 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vendor/@peculiar/x509.cjs +1 -1
- package/dist-lib/vendor/@ruby/prism/src/nodes.js.cjs +1 -1
- package/dist-lib/vendor/@ruby/prism/src/parsePrism.js.cjs +1 -1
- package/dist-lib/vendor/acorn.cjs +1 -1
- package/dist-lib/vendor/magic-string.cjs +1 -1
- package/dist-lib/vendor/stream-json.cjs +1 -1
- package/dist-lib/vendor/sucrase/dist/index.js.cjs +1 -1
- package/dist-lib/vendor/sucrase/dist/parser/index.js.cjs +1 -1
- package/dist-lib/vendor/sucrase/dist/parser/tokenizer/index.js.cjs +1 -1
- package/dist-lib/vendor/sucrase/dist/parser/tokenizer/types.js.cjs +1 -1
- package/dist-lib/vendor/sucrase.cjs +1 -1
- package/dist-lib/vendor/terser.cjs +1 -1
- package/dist-lib/vendor/valibot.cjs +1 -1
- package/dist-lib/vendor/ws.cjs +1 -1
- package/dist-lib/vendor/zod.cjs +1 -1
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +3 -3
- package/dist-types/packages/peach-engine/core-abi/web/sceneClientContract.d.ts +0 -6
- package/dist-types/packages/peach-engine/src/components/native-ui/webview-frame-bridge.d.ts +0 -3
- package/dist-types/packages/peach-engine/src/render-worker/worklet-runtime.d.ts +15 -2
- package/dist-types/packages/peach-engine/src/render-worker/worklet-wire.d.ts +10 -1
- package/dist-types/packages/peach-engine/src/webview-automation-host.d.ts +0 -4
- package/package.json +1 -1
- package/src/bazel-project.ts +2 -6
- package/src/build-cache.ts +3 -2
- package/src/sha256.ts +8 -0
- package/src/swift-compiler-digest.ts +1 -0
- package/src/swift-coverage/indexing.ts +3 -4
- package/src/swift-coverage/package.ts +1 -4
- package/src/swift-coverage/reader.ts +1 -4
- package/src/swift-coverage/source.ts +1 -4
- package/src/swift-coverage/xcode-assets.ts +1 -4
- package/src/swift-coverage/xcode-bridging.ts +1 -4
- package/src/swift-coverage/xcode-packages.ts +1 -4
- package/src/swift-coverage/xcode-strings.ts +1 -4
- package/src/swift-coverage/xcode.ts +1 -4
- package/src/swift-guest-dyld-functions.ts +1 -11
- package/src/swift-guest-dyld-table.ts +3 -15
- package/src/swift-guest-image-ledger.ts +9 -35
- package/src/swift-guest-source-inputs.ts +8 -37
- package/src/swift-icu.ts +15 -28
- package/src/swift-link-roots.ts +4 -8
- package/src/swift-objc-compile.ts +2 -7
- package/src/swift-sdk-app-module.ts +5 -27
- package/src/swift-sdk-image-wasm.ts +12 -41
- package/src/swift-sdk-image.ts +50 -12
- package/src/swift-shared-sdk.ts +1 -13
- package/src/swift-wasm-archive.ts +6 -11
- package/src/swift-wasm-prune.ts +25 -109
- package/src/wasm-binary-sections.ts +61 -7
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! peach v0.1.
|
|
1
|
+
/*! peach v0.1.2779 | (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;
|
|
@@ -2707,6 +2707,7 @@ var init_swift_compiler_digest = __esm({
|
|
|
2707
2707
|
"swift-objc-prebuilt-catalog.ts",
|
|
2708
2708
|
"swift-toolchain.ts",
|
|
2709
2709
|
"swift-shared-sdk.ts",
|
|
2710
|
+
"wasm-binary-sections.ts",
|
|
2710
2711
|
"swift-distribution-mirror.ts",
|
|
2711
2712
|
"swift-design-time.ts",
|
|
2712
2713
|
"binaryen.lock.json",
|
|
@@ -4407,6 +4408,111 @@ var init_swift_objc_standin = __esm({
|
|
|
4407
4408
|
}
|
|
4408
4409
|
});
|
|
4409
4410
|
|
|
4411
|
+
// src/wasm-binary-sections.ts
|
|
4412
|
+
function encodeWasmNumber(value) {
|
|
4413
|
+
const bytes = [];
|
|
4414
|
+
for (let rest = value; ; ) {
|
|
4415
|
+
const byte = rest % 128;
|
|
4416
|
+
rest = Math.floor(rest / 128);
|
|
4417
|
+
if (rest === 0) return [...bytes, byte];
|
|
4418
|
+
bytes.push(byte | 128);
|
|
4419
|
+
}
|
|
4420
|
+
}
|
|
4421
|
+
function encodeWasmSigned(value) {
|
|
4422
|
+
const out = [];
|
|
4423
|
+
for (; ; ) {
|
|
4424
|
+
const byte = Number(value & 127n);
|
|
4425
|
+
value >>= 7n;
|
|
4426
|
+
if (value === 0n && !(byte & 64) || value === -1n && byte & 64) {
|
|
4427
|
+
out.push(byte);
|
|
4428
|
+
return out;
|
|
4429
|
+
}
|
|
4430
|
+
out.push(byte | 128);
|
|
4431
|
+
}
|
|
4432
|
+
}
|
|
4433
|
+
function encodeWasmName(name3) {
|
|
4434
|
+
const bytes = new TextEncoder().encode(name3);
|
|
4435
|
+
return [...encodeWasmNumber(bytes.length), ...bytes];
|
|
4436
|
+
}
|
|
4437
|
+
function readULEB(bytes, offset, end = bytes.length) {
|
|
4438
|
+
if (offset < end) {
|
|
4439
|
+
const first = bytes[offset];
|
|
4440
|
+
if (first < 128) return [first, offset + 1];
|
|
4441
|
+
}
|
|
4442
|
+
let value = 0;
|
|
4443
|
+
for (let shift = 0; ; shift += 7) {
|
|
4444
|
+
if (offset >= end || shift > 63) throw new Error("invalid wasm integer");
|
|
4445
|
+
const byte = bytes[offset++];
|
|
4446
|
+
value += (byte & 127) * 2 ** shift;
|
|
4447
|
+
if (!(byte & 128)) return [value, offset];
|
|
4448
|
+
}
|
|
4449
|
+
}
|
|
4450
|
+
function readSLEB(bytes, offset, end = bytes.length) {
|
|
4451
|
+
let value = 0n;
|
|
4452
|
+
let shift = 0n;
|
|
4453
|
+
let byte = 0;
|
|
4454
|
+
do {
|
|
4455
|
+
if (offset >= end || shift > 70n) throw new Error("invalid wasm integer");
|
|
4456
|
+
byte = bytes[offset++];
|
|
4457
|
+
value |= BigInt(byte & 127) << shift;
|
|
4458
|
+
shift += 7n;
|
|
4459
|
+
} while (byte & 128);
|
|
4460
|
+
if (byte & 64) value -= 1n << shift;
|
|
4461
|
+
return [value, offset];
|
|
4462
|
+
}
|
|
4463
|
+
function skipLEB(bytes, offset) {
|
|
4464
|
+
while ((bytes[offset++] & 128) !== 0) {
|
|
4465
|
+
}
|
|
4466
|
+
return offset;
|
|
4467
|
+
}
|
|
4468
|
+
function readWasmSection(bytes, start, end) {
|
|
4469
|
+
let at = start;
|
|
4470
|
+
const number3 = () => {
|
|
4471
|
+
const [value, next] = readULEB(bytes, at, end);
|
|
4472
|
+
at = next;
|
|
4473
|
+
return value;
|
|
4474
|
+
};
|
|
4475
|
+
return {
|
|
4476
|
+
number: number3,
|
|
4477
|
+
byte: () => {
|
|
4478
|
+
if (at >= end) throw new Error("truncated wasm section");
|
|
4479
|
+
return bytes[at++];
|
|
4480
|
+
},
|
|
4481
|
+
name: () => {
|
|
4482
|
+
const length = number3();
|
|
4483
|
+
at += length;
|
|
4484
|
+
if (at > end) throw new Error("truncated wasm name");
|
|
4485
|
+
return Buffer.from(bytes.buffer, bytes.byteOffset + at - length, length).toString();
|
|
4486
|
+
},
|
|
4487
|
+
skip: (length) => {
|
|
4488
|
+
at += length;
|
|
4489
|
+
if (at > end) throw new Error("truncated wasm section");
|
|
4490
|
+
},
|
|
4491
|
+
position: () => at,
|
|
4492
|
+
done: () => at === end
|
|
4493
|
+
};
|
|
4494
|
+
}
|
|
4495
|
+
function wasmSections(bytes) {
|
|
4496
|
+
if (Buffer.from(bytes.subarray(0, 8)).toString("hex") !== "0061736d01000000")
|
|
4497
|
+
throw new Error("not a wasm module");
|
|
4498
|
+
const found = [];
|
|
4499
|
+
for (let at = 8; at < bytes.length; ) {
|
|
4500
|
+
const header = readWasmSection(bytes, at, bytes.length);
|
|
4501
|
+
const id = header.byte();
|
|
4502
|
+
const size = header.number();
|
|
4503
|
+
const start = header.position();
|
|
4504
|
+
if (start + size > bytes.length) throw new Error("truncated wasm section");
|
|
4505
|
+
found.push({ id, offset: at, start, end: start + size });
|
|
4506
|
+
at = start + size;
|
|
4507
|
+
}
|
|
4508
|
+
return found;
|
|
4509
|
+
}
|
|
4510
|
+
var init_wasm_binary_sections = __esm({
|
|
4511
|
+
"src/wasm-binary-sections.ts"() {
|
|
4512
|
+
"use strict";
|
|
4513
|
+
}
|
|
4514
|
+
});
|
|
4515
|
+
|
|
4410
4516
|
// src/swift-shared-sdk.ts
|
|
4411
4517
|
function swiftSharedSdkSourceRoot(moduleRoot, distribution) {
|
|
4412
4518
|
return import_node_path11.default.resolve(moduleRoot, distribution ? "sdk/ios" : "../peachsim/sdk/ios");
|
|
@@ -4457,18 +4563,6 @@ function swiftSharedSdkFlags(moduleRoot, distribution) {
|
|
|
4457
4563
|
import_node_path11.default.join(root, "usr/include")
|
|
4458
4564
|
];
|
|
4459
4565
|
}
|
|
4460
|
-
function readULEB(b, o) {
|
|
4461
|
-
let res = 0;
|
|
4462
|
-
let shift = 0;
|
|
4463
|
-
let p = o;
|
|
4464
|
-
while (true) {
|
|
4465
|
-
const byte = b[p++];
|
|
4466
|
-
res |= (byte & 127) << shift;
|
|
4467
|
-
if ((byte & 128) === 0) break;
|
|
4468
|
-
shift += 7;
|
|
4469
|
-
}
|
|
4470
|
-
return [res, p];
|
|
4471
|
-
}
|
|
4472
4566
|
function weakenFoundationSymbolsInWasmObj(buf) {
|
|
4473
4567
|
let pos = 8;
|
|
4474
4568
|
while (pos < buf.length) {
|
|
@@ -4833,6 +4927,7 @@ var init_swift_shared_sdk = __esm({
|
|
|
4833
4927
|
import_node_path11 = __toESM(require("node:path"), 1);
|
|
4834
4928
|
init_swift_toolchain();
|
|
4835
4929
|
init_swiftTargetContract();
|
|
4930
|
+
init_wasm_binary_sections();
|
|
4836
4931
|
SWIFT_DISTRIBUTION_MIRROR_RECORD = ".peach-mirror.json";
|
|
4837
4932
|
distributionHeaderRoots = /* @__PURE__ */ new Map();
|
|
4838
4933
|
WEAKEN_FOUNDATION_SYMS = /* @__PURE__ */ new Set([
|
|
@@ -5999,6 +6094,21 @@ var init_swift_foundation = __esm({
|
|
|
5999
6094
|
}
|
|
6000
6095
|
});
|
|
6001
6096
|
|
|
6097
|
+
// src/sha256.ts
|
|
6098
|
+
function sha256Hex(input) {
|
|
6099
|
+
if (typeof Bun !== "undefined") {
|
|
6100
|
+
return new Bun.CryptoHasher("sha256").update(input).digest("hex");
|
|
6101
|
+
}
|
|
6102
|
+
return (0, import_node_crypto8.createHash)("sha256").update(input).digest("hex");
|
|
6103
|
+
}
|
|
6104
|
+
var import_node_crypto8;
|
|
6105
|
+
var init_sha256 = __esm({
|
|
6106
|
+
"src/sha256.ts"() {
|
|
6107
|
+
"use strict";
|
|
6108
|
+
import_node_crypto8 = require("node:crypto");
|
|
6109
|
+
}
|
|
6110
|
+
});
|
|
6111
|
+
|
|
6002
6112
|
// src/swift-guest-source-plan.ts
|
|
6003
6113
|
function swiftPackageLinkage(target) {
|
|
6004
6114
|
const linkage = target.machOType === "staticlib" ? "static" : target.machOType === "mh_dylib" ? "dynamic" : null;
|
|
@@ -6409,16 +6519,12 @@ var init_swift_link_roots = __esm({
|
|
|
6409
6519
|
"use strict";
|
|
6410
6520
|
import_node_fs14 = __toESM(require("node:fs"), 1);
|
|
6411
6521
|
import_node_path15 = __toESM(require("node:path"), 1);
|
|
6522
|
+
init_wasm_binary_sections();
|
|
6412
6523
|
OBJC_RUNTIME_LOOKUP_SECTION = "peach_objc_runtime_lookup";
|
|
6413
6524
|
leb = (bytes, at) => {
|
|
6414
|
-
|
|
6415
|
-
|
|
6416
|
-
|
|
6417
|
-
const byte = bytes[at.offset++];
|
|
6418
|
-
value += (byte & 127) * scale;
|
|
6419
|
-
if (!(byte & 128)) return value;
|
|
6420
|
-
scale *= 128;
|
|
6421
|
-
}
|
|
6525
|
+
const [value, next] = readULEB(bytes, at.offset);
|
|
6526
|
+
at.offset = next;
|
|
6527
|
+
return value;
|
|
6422
6528
|
};
|
|
6423
6529
|
rootsByDistribution = /* @__PURE__ */ new Map();
|
|
6424
6530
|
}
|
|
@@ -7247,68 +7353,6 @@ var init_swift_guest_linked_spans = __esm({
|
|
|
7247
7353
|
}
|
|
7248
7354
|
});
|
|
7249
7355
|
|
|
7250
|
-
// src/wasm-binary-sections.ts
|
|
7251
|
-
function encodeWasmNumber(value) {
|
|
7252
|
-
const bytes = [];
|
|
7253
|
-
for (let rest = value; ; ) {
|
|
7254
|
-
const byte = rest % 128;
|
|
7255
|
-
rest = Math.floor(rest / 128);
|
|
7256
|
-
if (rest === 0) return [...bytes, byte];
|
|
7257
|
-
bytes.push(byte | 128);
|
|
7258
|
-
}
|
|
7259
|
-
}
|
|
7260
|
-
function encodeWasmName(name3) {
|
|
7261
|
-
const bytes = new TextEncoder().encode(name3);
|
|
7262
|
-
return [...encodeWasmNumber(bytes.length), ...bytes];
|
|
7263
|
-
}
|
|
7264
|
-
function readWasmSection(bytes, start, end) {
|
|
7265
|
-
let at = start;
|
|
7266
|
-
const number3 = () => {
|
|
7267
|
-
let value = 0;
|
|
7268
|
-
for (let shift = 0; ; shift += 7) {
|
|
7269
|
-
if (at >= end || shift > 63) throw new Error("invalid wasm integer");
|
|
7270
|
-
const byte = bytes[at++];
|
|
7271
|
-
value += (byte & 127) * 2 ** shift;
|
|
7272
|
-
if (!(byte & 128)) return value;
|
|
7273
|
-
}
|
|
7274
|
-
};
|
|
7275
|
-
return {
|
|
7276
|
-
number: number3,
|
|
7277
|
-
byte: () => {
|
|
7278
|
-
if (at >= end) throw new Error("truncated wasm section");
|
|
7279
|
-
return bytes[at++];
|
|
7280
|
-
},
|
|
7281
|
-
name: () => {
|
|
7282
|
-
const length = number3();
|
|
7283
|
-
at += length;
|
|
7284
|
-
if (at > end) throw new Error("truncated wasm name");
|
|
7285
|
-
return Buffer.from(bytes.buffer, bytes.byteOffset + at - length, length).toString();
|
|
7286
|
-
},
|
|
7287
|
-
position: () => at,
|
|
7288
|
-
done: () => at === end
|
|
7289
|
-
};
|
|
7290
|
-
}
|
|
7291
|
-
function wasmSections(bytes) {
|
|
7292
|
-
if (Buffer.from(bytes.subarray(0, 8)).toString("hex") !== "0061736d01000000")
|
|
7293
|
-
throw new Error("not a wasm module");
|
|
7294
|
-
const found = [];
|
|
7295
|
-
for (let at = 8; at < bytes.length; ) {
|
|
7296
|
-
const header = readWasmSection(bytes, at, bytes.length);
|
|
7297
|
-
const id = header.byte();
|
|
7298
|
-
const size = header.number();
|
|
7299
|
-
const start = header.position();
|
|
7300
|
-
if (start + size > bytes.length) throw new Error("truncated wasm section");
|
|
7301
|
-
found.push({ id, offset: at, start, end: start + size });
|
|
7302
|
-
at = start + size;
|
|
7303
|
-
}
|
|
7304
|
-
return found;
|
|
7305
|
-
}
|
|
7306
|
-
var init_wasm_binary_sections = __esm({
|
|
7307
|
-
"src/wasm-binary-sections.ts"() {
|
|
7308
|
-
"use strict";
|
|
7309
|
-
}
|
|
7310
|
-
});
|
|
7311
|
-
|
|
7312
7356
|
// src/wasm-imports.ts
|
|
7313
7357
|
function readWasmImports(bytes, section2, visit) {
|
|
7314
7358
|
const input = readWasmSection(bytes, section2.start, section2.end);
|
|
@@ -7592,23 +7636,13 @@ function wasmReader(bytes, start) {
|
|
|
7592
7636
|
const rawBuf = Buffer.isBuffer(bytes) ? bytes : Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
7593
7637
|
let at = start;
|
|
7594
7638
|
const u = () => {
|
|
7595
|
-
|
|
7596
|
-
|
|
7597
|
-
|
|
7598
|
-
value += (byte & 127) * 2 ** shift;
|
|
7599
|
-
if (!(byte & 128)) return value;
|
|
7600
|
-
}
|
|
7639
|
+
const [value, next] = readULEB(bytes, at);
|
|
7640
|
+
at = next;
|
|
7641
|
+
return value;
|
|
7601
7642
|
};
|
|
7602
7643
|
const s = () => {
|
|
7603
|
-
|
|
7604
|
-
|
|
7605
|
-
let byte = 0;
|
|
7606
|
-
do {
|
|
7607
|
-
byte = bytes[at++];
|
|
7608
|
-
value |= BigInt(byte & 127) << shift;
|
|
7609
|
-
shift += 7n;
|
|
7610
|
-
} while (byte & 128);
|
|
7611
|
-
if (byte & 64) value -= 1n << shift;
|
|
7644
|
+
const [value, next] = readSLEB(bytes, at);
|
|
7645
|
+
at = next;
|
|
7612
7646
|
return value;
|
|
7613
7647
|
};
|
|
7614
7648
|
return {
|
|
@@ -7913,7 +7947,7 @@ function finishSdkImage(bytes, hostExports, libraries, guestMap) {
|
|
|
7913
7947
|
else data[entry.name] = value;
|
|
7914
7948
|
}
|
|
7915
7949
|
if (entry.kind !== 0 && entry.kind !== 3 || host2.has(entry.name))
|
|
7916
|
-
kept.push([...
|
|
7950
|
+
kept.push([...encodeWasmName(entry.name), entry.kind, ...encodeWasmNumber(entry.index)]);
|
|
7917
7951
|
}
|
|
7918
7952
|
if (guestMap) {
|
|
7919
7953
|
if (guestMap.code.length !== m.bodies.length)
|
|
@@ -7928,19 +7962,19 @@ function finishSdkImage(bytes, hostExports, libraries, guestMap) {
|
|
|
7928
7962
|
const er = wasmReader(bytes, elements.start);
|
|
7929
7963
|
const segments = er.u();
|
|
7930
7964
|
const replaced = /* @__PURE__ */ new Map([
|
|
7931
|
-
[4, [1, 112, 4, ...
|
|
7932
|
-
[7, [...
|
|
7965
|
+
[4, [1, 112, 4, ...encodeWasmNumber(tableEnd + added.length)]],
|
|
7966
|
+
[7, [...encodeWasmNumber(kept.length), ...kept.flat()]],
|
|
7933
7967
|
[
|
|
7934
7968
|
9,
|
|
7935
7969
|
[
|
|
7936
|
-
...
|
|
7970
|
+
...encodeWasmNumber(segments + 1),
|
|
7937
7971
|
...bytes.subarray(er.at, elements.end),
|
|
7938
7972
|
0,
|
|
7939
7973
|
66,
|
|
7940
|
-
...
|
|
7974
|
+
...encodeWasmSigned(BigInt(tableEnd)),
|
|
7941
7975
|
11,
|
|
7942
|
-
...
|
|
7943
|
-
...added.flatMap(
|
|
7976
|
+
...encodeWasmNumber(added.length),
|
|
7977
|
+
...added.flatMap(encodeWasmNumber)
|
|
7944
7978
|
]
|
|
7945
7979
|
]
|
|
7946
7980
|
]);
|
|
@@ -8046,33 +8080,33 @@ function codeOnlySdkImage(bytes, constructorMask) {
|
|
|
8046
8080
|
if (drop) r.skip(1);
|
|
8047
8081
|
gated.push(
|
|
8048
8082
|
66,
|
|
8049
|
-
...
|
|
8083
|
+
...encodeWasmSigned(BigInt(constructorMask + index++)),
|
|
8050
8084
|
45,
|
|
8051
8085
|
0,
|
|
8052
8086
|
0,
|
|
8053
8087
|
4,
|
|
8054
8088
|
64,
|
|
8055
8089
|
16,
|
|
8056
|
-
...
|
|
8090
|
+
...encodeWasmNumber(callee),
|
|
8057
8091
|
...drop ? [26] : [],
|
|
8058
8092
|
11
|
|
8059
8093
|
);
|
|
8060
8094
|
}
|
|
8061
8095
|
if (index > SWIFT_SDK_CONSTRUCTOR_LIMIT)
|
|
8062
8096
|
throw new Error(`${index} sdk constructors exceed the mask`);
|
|
8063
|
-
gated.push(16, ...
|
|
8097
|
+
gated.push(16, ...encodeWasmNumber(functionIndex("__peach_sdk_register")), 11);
|
|
8064
8098
|
bodies[constructors] = Uint8Array.from(gated);
|
|
8065
8099
|
}
|
|
8066
|
-
const codeParts = [Uint8Array.from(
|
|
8067
|
-
for (const body of bodies) codeParts.push(Uint8Array.from(
|
|
8100
|
+
const codeParts = [Uint8Array.from(encodeWasmNumber(bodies.length))];
|
|
8101
|
+
for (const body of bodies) codeParts.push(Uint8Array.from(encodeWasmNumber(body.length)), body);
|
|
8068
8102
|
const codeSize = codeParts.reduce((sum, part) => sum + part.length, 0);
|
|
8069
8103
|
const tls = passiveSegments(bytes)[0];
|
|
8070
8104
|
const out = [bytes.subarray(0, 8)];
|
|
8071
8105
|
for (const s of m.sections) {
|
|
8072
8106
|
if (s.id === 10) {
|
|
8073
|
-
out.push(Uint8Array.from([10, ...
|
|
8107
|
+
out.push(Uint8Array.from([10, ...encodeWasmNumber(codeSize)]));
|
|
8074
8108
|
for (const part of codeParts) out.push(part);
|
|
8075
|
-
} else if (s.id === 11) out.push(section(11, [1, 1, ...
|
|
8109
|
+
} else if (s.id === 11) out.push(section(11, [1, 1, ...encodeWasmNumber(tls.length), ...tls]));
|
|
8076
8110
|
else if (s.id === 12) out.push(section(12, [1]));
|
|
8077
8111
|
else out.push(bytes.subarray(s.offset, s.end));
|
|
8078
8112
|
}
|
|
@@ -8389,39 +8423,14 @@ function unslottedFunctions(bytes) {
|
|
|
8389
8423
|
}
|
|
8390
8424
|
return definedFuncs - slotted.size;
|
|
8391
8425
|
}
|
|
8392
|
-
var
|
|
8426
|
+
var section, PROCESS_EXPORTS, SWIFT_SDK_CONSTRUCTOR_LIMIT, FUNCTION_RELOCATIONS, MEMORY_RELOCATIONS, ADDEND_RELOCATIONS, FUNCTION_RELOC_MASK, MEMORY_RELOC_MASK, ADDEND_RELOC_MASK;
|
|
8393
8427
|
var init_swift_sdk_image_wasm = __esm({
|
|
8394
8428
|
"src/swift-sdk-image-wasm.ts"() {
|
|
8395
8429
|
"use strict";
|
|
8396
8430
|
init_swift_sdk_image_map();
|
|
8397
8431
|
init_swiftSdkLinkContract();
|
|
8398
|
-
|
|
8399
|
-
|
|
8400
|
-
do {
|
|
8401
|
-
let byte = value % 128;
|
|
8402
|
-
value = Math.floor(value / 128);
|
|
8403
|
-
if (value) byte |= 128;
|
|
8404
|
-
out.push(byte);
|
|
8405
|
-
} while (value);
|
|
8406
|
-
return out;
|
|
8407
|
-
};
|
|
8408
|
-
sleb = (value) => {
|
|
8409
|
-
const out = [];
|
|
8410
|
-
for (; ; ) {
|
|
8411
|
-
const byte = Number(value & 127n);
|
|
8412
|
-
value >>= 7n;
|
|
8413
|
-
if (value === 0n && !(byte & 64) || value === -1n && byte & 64) {
|
|
8414
|
-
out.push(byte);
|
|
8415
|
-
return out;
|
|
8416
|
-
}
|
|
8417
|
-
out.push(byte | 128);
|
|
8418
|
-
}
|
|
8419
|
-
};
|
|
8420
|
-
encodedName = (name3) => {
|
|
8421
|
-
const bytes = [...Buffer.from(name3)];
|
|
8422
|
-
return [...uleb(bytes.length), ...bytes];
|
|
8423
|
-
};
|
|
8424
|
-
section = (id, payload) => Uint8Array.from([id, ...uleb(payload.length), ...payload]);
|
|
8432
|
+
init_wasm_binary_sections();
|
|
8433
|
+
section = (id, payload) => Uint8Array.from([id, ...encodeWasmNumber(payload.length), ...payload]);
|
|
8425
8434
|
PROCESS_EXPORTS = [
|
|
8426
8435
|
"_initialize",
|
|
8427
8436
|
"__wasm_call_ctors",
|
|
@@ -8524,50 +8533,11 @@ function readArMembers(buf, includeBitcode = false) {
|
|
|
8524
8533
|
var init_swift_wasm_archive = __esm({
|
|
8525
8534
|
"src/swift-wasm-archive.ts"() {
|
|
8526
8535
|
"use strict";
|
|
8536
|
+
init_wasm_binary_sections();
|
|
8527
8537
|
}
|
|
8528
8538
|
});
|
|
8529
8539
|
|
|
8530
8540
|
// src/swift-wasm-prune.ts
|
|
8531
|
-
function sha256Hex(bytes) {
|
|
8532
|
-
if (typeof Bun !== "undefined")
|
|
8533
|
-
return new Bun.CryptoHasher("sha256").update(bytes).digest("hex");
|
|
8534
|
-
return (0, import_node_crypto8.createHash)("sha256").update(bytes).digest("hex");
|
|
8535
|
-
}
|
|
8536
|
-
function readULEB2(b, o) {
|
|
8537
|
-
let res = 0;
|
|
8538
|
-
let shift = 0;
|
|
8539
|
-
let p = o;
|
|
8540
|
-
while (true) {
|
|
8541
|
-
const byte = b[p++];
|
|
8542
|
-
res |= (byte & 127) << shift;
|
|
8543
|
-
if ((byte & 128) === 0) break;
|
|
8544
|
-
shift += 7;
|
|
8545
|
-
}
|
|
8546
|
-
return [res, p];
|
|
8547
|
-
}
|
|
8548
|
-
function readSLEB(b, o) {
|
|
8549
|
-
let res = 0;
|
|
8550
|
-
let shift = 0;
|
|
8551
|
-
let p = o;
|
|
8552
|
-
let byte = 0;
|
|
8553
|
-
do {
|
|
8554
|
-
byte = b[p++];
|
|
8555
|
-
res |= (byte & 127) << shift;
|
|
8556
|
-
shift += 7;
|
|
8557
|
-
} while (byte & 128);
|
|
8558
|
-
if (shift < 32 && byte & 64) res |= ~0 << shift;
|
|
8559
|
-
return [res, p];
|
|
8560
|
-
}
|
|
8561
|
-
function encodeULEB(val) {
|
|
8562
|
-
const out = [];
|
|
8563
|
-
do {
|
|
8564
|
-
let byte = val & 127;
|
|
8565
|
-
val >>>= 7;
|
|
8566
|
-
if (val !== 0) byte |= 128;
|
|
8567
|
-
out.push(byte);
|
|
8568
|
-
} while (val !== 0);
|
|
8569
|
-
return out;
|
|
8570
|
-
}
|
|
8571
8541
|
function isRootSegName(name3) {
|
|
8572
8542
|
for (const pref of ROOT_SEG_PREFIXES) {
|
|
8573
8543
|
if (name3 === pref || name3.startsWith(`${pref}.`)) return true;
|
|
@@ -8593,39 +8563,14 @@ function decodeRelocations(buf, sections) {
|
|
|
8593
8563
|
for (let k = 0; k < sectionCount; k++, i++) {
|
|
8594
8564
|
start[i] = length + cur - baseAt;
|
|
8595
8565
|
const rType = buf[cur++];
|
|
8596
|
-
let offset
|
|
8597
|
-
|
|
8598
|
-
|
|
8599
|
-
|
|
8600
|
-
while (true) {
|
|
8601
|
-
const byte = buf[cur++];
|
|
8602
|
-
offset |= (byte & 127) << shift;
|
|
8603
|
-
if (byte < 128) break;
|
|
8604
|
-
shift += 7;
|
|
8605
|
-
}
|
|
8606
|
-
}
|
|
8607
|
-
let symbol = buf[cur++];
|
|
8608
|
-
if (symbol >= 128) {
|
|
8609
|
-
symbol &= 127;
|
|
8610
|
-
let shift = 7;
|
|
8611
|
-
while (true) {
|
|
8612
|
-
const byte = buf[cur++];
|
|
8613
|
-
symbol |= (byte & 127) << shift;
|
|
8614
|
-
if (byte < 128) break;
|
|
8615
|
-
shift += 7;
|
|
8616
|
-
}
|
|
8617
|
-
}
|
|
8566
|
+
let offset;
|
|
8567
|
+
[offset, cur] = readULEB(buf, cur);
|
|
8568
|
+
let symbol;
|
|
8569
|
+
[symbol, cur] = readULEB(buf, cur);
|
|
8618
8570
|
if (rType < 32 && (ADDEND_RELOC_MASK2 & 1 << rType) !== 0) {
|
|
8619
|
-
let
|
|
8620
|
-
|
|
8621
|
-
|
|
8622
|
-
while (byte >= 128) {
|
|
8623
|
-
byte = buf[cur++];
|
|
8624
|
-
value |= (byte & 127) << shift;
|
|
8625
|
-
shift += 7;
|
|
8626
|
-
}
|
|
8627
|
-
if (shift < 32 && (byte & 64) !== 0) value |= ~0 << shift;
|
|
8628
|
-
addend[i] = value;
|
|
8571
|
+
let value;
|
|
8572
|
+
[value, cur] = readSLEB(buf, cur);
|
|
8573
|
+
addend[i] = Number(BigInt.asIntN(32, value));
|
|
8629
8574
|
}
|
|
8630
8575
|
ro[i] = offset;
|
|
8631
8576
|
rs[i] = symbol;
|
|
@@ -8660,36 +8605,36 @@ function patchSwiftrtObject(src) {
|
|
|
8660
8605
|
let pos = 8;
|
|
8661
8606
|
while (pos < buf.length) {
|
|
8662
8607
|
const id = buf[pos++];
|
|
8663
|
-
const [sz, p] =
|
|
8608
|
+
const [sz, p] = readULEB(buf, pos);
|
|
8664
8609
|
const end = p + sz;
|
|
8665
8610
|
if (id === 0) {
|
|
8666
|
-
const [nLen, np] =
|
|
8611
|
+
const [nLen, np] = readULEB(buf, p);
|
|
8667
8612
|
const name3 = Buffer.from(buf.subarray(np, np + nLen)).toString("utf8");
|
|
8668
8613
|
const cp = np + nLen;
|
|
8669
8614
|
if (name3 === "linking") {
|
|
8670
|
-
let [, lp] =
|
|
8615
|
+
let [, lp] = readULEB(buf, cp);
|
|
8671
8616
|
while (lp < end) {
|
|
8672
8617
|
const subId = buf[lp++];
|
|
8673
|
-
const [subLen, sp] =
|
|
8618
|
+
const [subLen, sp] = readULEB(buf, lp);
|
|
8674
8619
|
const subEnd = sp + subLen;
|
|
8675
8620
|
if (subId === 8) {
|
|
8676
|
-
let [cnt, cur] =
|
|
8621
|
+
let [cnt, cur] = readULEB(buf, sp);
|
|
8677
8622
|
for (let i = 0; i < cnt; i++) {
|
|
8678
8623
|
const kind = buf[cur++];
|
|
8679
8624
|
const flPos = cur;
|
|
8680
|
-
const [fl, c2] =
|
|
8625
|
+
const [fl, c2] = readULEB(buf, cur);
|
|
8681
8626
|
cur = c2;
|
|
8682
8627
|
const isUndef = (fl & 16) !== 0;
|
|
8683
8628
|
const isExplicitName = (fl & 64) !== 0;
|
|
8684
8629
|
if (kind === 0 || kind === 2 || kind === 4 || kind === 5) {
|
|
8685
|
-
const [, c3] =
|
|
8630
|
+
const [, c3] = readULEB(buf, cur);
|
|
8686
8631
|
cur = c3;
|
|
8687
8632
|
if (!isUndef || isExplicitName) {
|
|
8688
|
-
const [sLen, c4] =
|
|
8633
|
+
const [sLen, c4] = readULEB(buf, cur);
|
|
8689
8634
|
cur = c4 + sLen;
|
|
8690
8635
|
}
|
|
8691
8636
|
} else if (kind === 1) {
|
|
8692
|
-
const [sLen, c3] =
|
|
8637
|
+
const [sLen, c3] = readULEB(buf, cur);
|
|
8693
8638
|
const sName = Buffer.from(buf.subarray(c3, c3 + sLen)).toString("utf8");
|
|
8694
8639
|
if (sName === "_ZN12_GLOBAL__N_18sectionsE") fallbackSymIdx = i;
|
|
8695
8640
|
for (const prefix of ["__start_", "__stop_"]) {
|
|
@@ -8701,13 +8646,13 @@ function patchSwiftrtObject(src) {
|
|
|
8701
8646
|
}
|
|
8702
8647
|
cur = c3 + sLen;
|
|
8703
8648
|
if (!isUndef) {
|
|
8704
|
-
const [, c4] =
|
|
8705
|
-
const [, c5] =
|
|
8706
|
-
const [, c6] =
|
|
8649
|
+
const [, c4] = readULEB(buf, cur);
|
|
8650
|
+
const [, c5] = readULEB(buf, c4);
|
|
8651
|
+
const [, c6] = readULEB(buf, c5);
|
|
8707
8652
|
cur = c6;
|
|
8708
8653
|
}
|
|
8709
8654
|
} else if (kind === 3) {
|
|
8710
|
-
const [, c3] =
|
|
8655
|
+
const [, c3] = readULEB(buf, cur);
|
|
8711
8656
|
cur = c3;
|
|
8712
8657
|
}
|
|
8713
8658
|
}
|
|
@@ -8721,26 +8666,25 @@ function patchSwiftrtObject(src) {
|
|
|
8721
8666
|
pos = 8;
|
|
8722
8667
|
while (pos < buf.length) {
|
|
8723
8668
|
const id = buf[pos++];
|
|
8724
|
-
const [sz, p] =
|
|
8669
|
+
const [sz, p] = readULEB(buf, pos);
|
|
8725
8670
|
const end = p + sz;
|
|
8726
8671
|
if (id === 0) {
|
|
8727
|
-
const [nLen, np] =
|
|
8672
|
+
const [nLen, np] = readULEB(buf, p);
|
|
8728
8673
|
const name3 = Buffer.from(buf.subarray(np, np + nLen)).toString("utf8");
|
|
8729
8674
|
const cp = np + nLen;
|
|
8730
8675
|
if (name3 === "reloc.CODE") {
|
|
8731
|
-
const [, r1] =
|
|
8732
|
-
let [cnt, cur] =
|
|
8676
|
+
const [, r1] = readULEB(buf, cp);
|
|
8677
|
+
let [cnt, cur] = readULEB(buf, r1);
|
|
8733
8678
|
for (let i = 0; i < cnt; i++) {
|
|
8734
8679
|
const rType = buf[cur++];
|
|
8735
|
-
const [, c2] =
|
|
8736
|
-
const [rs, c3] =
|
|
8680
|
+
const [, c2] = readULEB(buf, cur);
|
|
8681
|
+
const [rs, c3] = readULEB(buf, c2);
|
|
8737
8682
|
if (neutralizedSyms.has(rs) && c3 - c2 === 1) {
|
|
8738
8683
|
buf[c2] = fallbackSymIdx;
|
|
8739
8684
|
}
|
|
8740
8685
|
cur = c3;
|
|
8741
8686
|
if (ADDEND_RELOCATIONS.has(rType)) {
|
|
8742
|
-
|
|
8743
|
-
cur = c4;
|
|
8687
|
+
cur = skipLEB(buf, cur);
|
|
8744
8688
|
}
|
|
8745
8689
|
}
|
|
8746
8690
|
}
|
|
@@ -8754,25 +8698,14 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
8754
8698
|
let pos = 8;
|
|
8755
8699
|
let cur = 8;
|
|
8756
8700
|
const readU = () => {
|
|
8757
|
-
const
|
|
8758
|
-
|
|
8759
|
-
|
|
8760
|
-
let shift = 7;
|
|
8761
|
-
while (true) {
|
|
8762
|
-
const byte = buf[cur++];
|
|
8763
|
-
res |= (byte & 127) << shift;
|
|
8764
|
-
if (byte < 128) return res;
|
|
8765
|
-
shift += 7;
|
|
8766
|
-
}
|
|
8701
|
+
const [res, next] = readULEB(buf, cur);
|
|
8702
|
+
cur = next;
|
|
8703
|
+
return res;
|
|
8767
8704
|
};
|
|
8768
8705
|
const skipU = () => {
|
|
8769
|
-
|
|
8770
|
-
}
|
|
8771
|
-
};
|
|
8772
|
-
const skipS = () => {
|
|
8773
|
-
while (buf[cur++] >= 128) {
|
|
8774
|
-
}
|
|
8706
|
+
cur = skipLEB(buf, cur);
|
|
8775
8707
|
};
|
|
8708
|
+
const skipS = skipU;
|
|
8776
8709
|
let numImportFuncs = 0;
|
|
8777
8710
|
let importsDlsym = false;
|
|
8778
8711
|
const importFuncNames = [];
|
|
@@ -9370,16 +9303,9 @@ function guestWasmSymbols(bytes) {
|
|
|
9370
9303
|
const rawBuf = Buffer.isBuffer(bytes) ? bytes : Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
9371
9304
|
let cur = 8;
|
|
9372
9305
|
const readU = () => {
|
|
9373
|
-
const
|
|
9374
|
-
|
|
9375
|
-
|
|
9376
|
-
let shift = 7;
|
|
9377
|
-
while (true) {
|
|
9378
|
-
const byte = bytes[cur++];
|
|
9379
|
-
res |= (byte & 127) << shift;
|
|
9380
|
-
if ((byte & 128) === 0) return res;
|
|
9381
|
-
shift += 7;
|
|
9382
|
-
}
|
|
9306
|
+
const [res, next] = readULEB(bytes, cur);
|
|
9307
|
+
cur = next;
|
|
9308
|
+
return res;
|
|
9383
9309
|
};
|
|
9384
9310
|
let importsDlsym = false;
|
|
9385
9311
|
const importFuncNames = [];
|
|
@@ -9569,7 +9495,7 @@ function swiftPrunedSdkObjectOrigins(sdk, args, rewritten) {
|
|
|
9569
9495
|
}
|
|
9570
9496
|
function ensureUnpackedSdkObjects(sdkWasiDir) {
|
|
9571
9497
|
const archives = import_node_fs16.default.readdirSync(sdkWasiDir).filter((file) => file.endsWith(".a")).sort();
|
|
9572
|
-
const hash = (0,
|
|
9498
|
+
const hash = (0, import_node_crypto9.createHash)("sha256");
|
|
9573
9499
|
for (const archive of archives) {
|
|
9574
9500
|
hash.update(archive + "\0");
|
|
9575
9501
|
hash.update(swiftFileChecksum(import_node_path17.default.join(sdkWasiDir, archive)));
|
|
@@ -10520,7 +10446,7 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
10520
10446
|
if (!deadSpecialSegs.has(sIdx)) continue;
|
|
10521
10447
|
if (!isSpecialSegRelocLive(obj, obj.segNames[sIdx], data.rs[i])) continue;
|
|
10522
10448
|
const first = relocationBytes(data, i);
|
|
10523
|
-
const [, afterRoOff] =
|
|
10449
|
+
const [, afterRoOff] = readULEB(first, 1);
|
|
10524
10450
|
firstLiveInSpecialSeg.set(sIdx, {
|
|
10525
10451
|
rType: first[0],
|
|
10526
10452
|
afterRo: first.subarray(afterRoOff)
|
|
@@ -10550,7 +10476,7 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
10550
10476
|
zeroDataReloc(i);
|
|
10551
10477
|
} else {
|
|
10552
10478
|
const repl = firstLiveInSpecialSeg.get(segIdx);
|
|
10553
|
-
const roBytes =
|
|
10479
|
+
const roBytes = encodeWasmNumber(data.ro[i]);
|
|
10554
10480
|
const out = new Uint8Array(1 + roBytes.length + repl.afterRo.length);
|
|
10555
10481
|
out[0] = repl.rType;
|
|
10556
10482
|
out.set(roBytes, 1);
|
|
@@ -10589,34 +10515,34 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
10589
10515
|
while (pos < buf.length) {
|
|
10590
10516
|
const secStart = pos;
|
|
10591
10517
|
const id = buf[pos++];
|
|
10592
|
-
const [sz, p] =
|
|
10518
|
+
const [sz, p] = readULEB(buf, pos);
|
|
10593
10519
|
const end = p + sz;
|
|
10594
10520
|
if (id === 0) {
|
|
10595
|
-
const [nLen, np] =
|
|
10521
|
+
const [nLen, np] = readULEB(buf, p);
|
|
10596
10522
|
const name3 = rawBuf.toString("utf8", np, np + nLen);
|
|
10597
10523
|
const cp = np + nLen;
|
|
10598
10524
|
if (name3 === "linking") {
|
|
10599
|
-
const [, lpStart] =
|
|
10525
|
+
const [, lpStart] = readULEB(buf, cp);
|
|
10600
10526
|
const subChunks = [buf.subarray(p, lpStart)];
|
|
10601
10527
|
let lp = lpStart;
|
|
10602
10528
|
while (lp < end) {
|
|
10603
10529
|
const subStart = lp;
|
|
10604
10530
|
const subId = buf[lp++];
|
|
10605
|
-
const [subLen, sp] =
|
|
10531
|
+
const [subLen, sp] = readULEB(buf, lp);
|
|
10606
10532
|
const subEnd = sp + subLen;
|
|
10607
10533
|
if (subId === 5) {
|
|
10608
10534
|
const subCopy = new Uint8Array(buf.subarray(subStart, subEnd));
|
|
10609
|
-
let [cnt, cur] =
|
|
10535
|
+
let [cnt, cur] = readULEB(buf, sp);
|
|
10610
10536
|
for (let i = 0; i < cnt; i++) {
|
|
10611
|
-
const [sLen, s2] =
|
|
10537
|
+
const [sLen, s2] = readULEB(buf, cur);
|
|
10612
10538
|
const segName = obj.segNames[i];
|
|
10613
10539
|
const repl = RECORD_SEGS.get(segName);
|
|
10614
10540
|
const isSpecial = repl !== void 0;
|
|
10615
10541
|
if (deadSpecialSegs.has(i) && repl !== void 0)
|
|
10616
10542
|
subCopy.set(Buffer.from(repl, "utf8"), s2 - subStart);
|
|
10617
10543
|
cur = s2 + sLen;
|
|
10618
|
-
const [, s3] =
|
|
10619
|
-
const [segFl, s4] =
|
|
10544
|
+
const [, s3] = readULEB(buf, cur);
|
|
10545
|
+
const [segFl, s4] = readULEB(buf, s3);
|
|
10620
10546
|
const sFlLen = s4 - s3;
|
|
10621
10547
|
const keepRetain = isSpecial ? !deadSpecialSegs.has(i) : isRootSegName(segName) && !segName.startsWith(".init_array") && sLive[i] === 1;
|
|
10622
10548
|
const newSegFl = keepRetain ? segFl | 4 : segFl & ~4;
|
|
@@ -10630,12 +10556,12 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
10630
10556
|
}
|
|
10631
10557
|
subChunks.push(subCopy);
|
|
10632
10558
|
} else if (subId === 6) {
|
|
10633
|
-
let [cnt, cur] =
|
|
10559
|
+
let [cnt, cur] = readULEB(buf, sp);
|
|
10634
10560
|
const entrySlices = [];
|
|
10635
10561
|
for (let i = 0; i < cnt; i++) {
|
|
10636
10562
|
const eStart = cur;
|
|
10637
|
-
const [, s2] =
|
|
10638
|
-
const [symIdx, s3] =
|
|
10563
|
+
const [, s2] = readULEB(buf, cur);
|
|
10564
|
+
const [symIdx, s3] = readULEB(buf, s2);
|
|
10639
10565
|
cur = s3;
|
|
10640
10566
|
if (obj.symKind[symIdx] === 0 && obj.symElemIdx[symIdx] >= obj.numImportFuncs) {
|
|
10641
10567
|
if (fLive[obj.symElemIdx[symIdx] - obj.numImportFuncs] === 1) {
|
|
@@ -10646,19 +10572,19 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
10646
10572
|
}
|
|
10647
10573
|
}
|
|
10648
10574
|
if (entrySlices.length > 0) {
|
|
10649
|
-
const cntBytes = Uint8Array.from(
|
|
10575
|
+
const cntBytes = Uint8Array.from(encodeWasmNumber(entrySlices.length));
|
|
10650
10576
|
const bodyLen = cntBytes.length + entrySlices.reduce((a, b) => a + b.length, 0);
|
|
10651
|
-
const lenBytes = Uint8Array.from(
|
|
10577
|
+
const lenBytes = Uint8Array.from(encodeWasmNumber(bodyLen));
|
|
10652
10578
|
subChunks.push(Uint8Array.of(6), lenBytes, cntBytes);
|
|
10653
10579
|
for (const entry of entrySlices) subChunks.push(entry);
|
|
10654
10580
|
}
|
|
10655
10581
|
} else if (subId === 8) {
|
|
10656
10582
|
const subCopy = new Uint8Array(buf.subarray(subStart, subEnd));
|
|
10657
|
-
let [cnt, cur] =
|
|
10583
|
+
let [cnt, cur] = readULEB(buf, sp);
|
|
10658
10584
|
for (let i = 0; i < cnt; i++) {
|
|
10659
10585
|
const kind = buf[cur++];
|
|
10660
10586
|
const flOffset = cur - subStart;
|
|
10661
|
-
const [fl, c2] =
|
|
10587
|
+
const [fl, c2] = readULEB(buf, cur);
|
|
10662
10588
|
cur = c2;
|
|
10663
10589
|
const isUndef = (fl & 16) !== 0;
|
|
10664
10590
|
const isExplicitName = (fl & 64) !== 0;
|
|
@@ -10678,23 +10604,23 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
10678
10604
|
subCopy[flOffset + 1] = 0;
|
|
10679
10605
|
}
|
|
10680
10606
|
if (kind === 0 || kind === 2 || kind === 4 || kind === 5) {
|
|
10681
|
-
const [, c3] =
|
|
10607
|
+
const [, c3] = readULEB(buf, cur);
|
|
10682
10608
|
cur = c3;
|
|
10683
10609
|
if (!isUndef || isExplicitName) {
|
|
10684
|
-
const [sLen, c4] =
|
|
10610
|
+
const [sLen, c4] = readULEB(buf, cur);
|
|
10685
10611
|
cur = c4 + sLen;
|
|
10686
10612
|
}
|
|
10687
10613
|
} else if (kind === 1) {
|
|
10688
|
-
const [sLen, c3] =
|
|
10614
|
+
const [sLen, c3] = readULEB(buf, cur);
|
|
10689
10615
|
cur = c3 + sLen;
|
|
10690
10616
|
if (!isUndef) {
|
|
10691
|
-
const [, c4] =
|
|
10692
|
-
const [, c5] =
|
|
10693
|
-
const [, c6] =
|
|
10617
|
+
const [, c4] = readULEB(buf, cur);
|
|
10618
|
+
const [, c5] = readULEB(buf, c4);
|
|
10619
|
+
const [, c6] = readULEB(buf, c5);
|
|
10694
10620
|
cur = c6;
|
|
10695
10621
|
}
|
|
10696
10622
|
} else if (kind === 3) {
|
|
10697
|
-
const [, c3] =
|
|
10623
|
+
const [, c3] = readULEB(buf, cur);
|
|
10698
10624
|
cur = c3;
|
|
10699
10625
|
}
|
|
10700
10626
|
}
|
|
@@ -10705,29 +10631,29 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
10705
10631
|
lp = subEnd;
|
|
10706
10632
|
}
|
|
10707
10633
|
const totalSubLen = subChunks.reduce((a, b) => a + b.length, 0);
|
|
10708
|
-
outChunks.push(Uint8Array.of(0), Uint8Array.from(
|
|
10634
|
+
outChunks.push(Uint8Array.of(0), Uint8Array.from(encodeWasmNumber(totalSubLen)));
|
|
10709
10635
|
for (const chunk of subChunks) outChunks.push(chunk);
|
|
10710
10636
|
} else if (name3 === "reloc.CODE") {
|
|
10711
|
-
const [, r1] =
|
|
10637
|
+
const [, r1] = readULEB(buf, cp);
|
|
10712
10638
|
const headerSlice = buf.subarray(p, r1);
|
|
10713
|
-
const cntBytes = Uint8Array.from(
|
|
10639
|
+
const cntBytes = Uint8Array.from(encodeWasmNumber(keptCodeRelocs.length));
|
|
10714
10640
|
const relSlices = keptCodeRelocs.map((i) => relocationBytes(code, i));
|
|
10715
10641
|
const totalLen = headerSlice.length + cntBytes.length + relSlices.reduce((a, b) => a + b.length, 0);
|
|
10716
10642
|
outChunks.push(
|
|
10717
10643
|
Uint8Array.of(0),
|
|
10718
|
-
Uint8Array.from(
|
|
10644
|
+
Uint8Array.from(encodeWasmNumber(totalLen)),
|
|
10719
10645
|
headerSlice,
|
|
10720
10646
|
cntBytes
|
|
10721
10647
|
);
|
|
10722
10648
|
for (const relocation of relSlices) outChunks.push(relocation);
|
|
10723
10649
|
} else if (name3 === "reloc.DATA") {
|
|
10724
|
-
const [, r1] =
|
|
10650
|
+
const [, r1] = readULEB(buf, cp);
|
|
10725
10651
|
const headerSlice = buf.subarray(p, r1);
|
|
10726
|
-
const cntBytes = Uint8Array.from(
|
|
10652
|
+
const cntBytes = Uint8Array.from(encodeWasmNumber(keptDataRelocBytes.length));
|
|
10727
10653
|
const totalLen = headerSlice.length + cntBytes.length + keptDataRelocBytes.reduce((a, b) => a + b.length, 0);
|
|
10728
10654
|
outChunks.push(
|
|
10729
10655
|
Uint8Array.of(0),
|
|
10730
|
-
Uint8Array.from(
|
|
10656
|
+
Uint8Array.from(encodeWasmNumber(totalLen)),
|
|
10731
10657
|
headerSlice,
|
|
10732
10658
|
cntBytes
|
|
10733
10659
|
);
|
|
@@ -10737,15 +10663,15 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
10737
10663
|
const nameBytes = buf.subarray(p, cp);
|
|
10738
10664
|
outChunks.push(
|
|
10739
10665
|
Uint8Array.of(0),
|
|
10740
|
-
Uint8Array.from(
|
|
10666
|
+
Uint8Array.from(encodeWasmNumber(nameBytes.length)),
|
|
10741
10667
|
nameBytes
|
|
10742
10668
|
);
|
|
10743
10669
|
} else if (name3.startsWith("reloc..debug_")) {
|
|
10744
|
-
const [, r1] =
|
|
10670
|
+
const [, r1] = readULEB(buf, cp);
|
|
10745
10671
|
const headerSlice = buf.subarray(p, r1);
|
|
10746
10672
|
outChunks.push(
|
|
10747
10673
|
Uint8Array.of(0),
|
|
10748
|
-
Uint8Array.from(
|
|
10674
|
+
Uint8Array.from(encodeWasmNumber(headerSlice.length + 1)),
|
|
10749
10675
|
headerSlice,
|
|
10750
10676
|
Uint8Array.of(0)
|
|
10751
10677
|
);
|
|
@@ -10858,15 +10784,16 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
10858
10784
|
);
|
|
10859
10785
|
import_node_fs16.default.rmSync(rspPath, { force: true });
|
|
10860
10786
|
}
|
|
10861
|
-
var import_node_child_process10,
|
|
10787
|
+
var import_node_child_process10, import_node_crypto9, import_node_fs16, import_node_path17, v3, WIDE_DATA_RELOCS, ROOT_SEG_PREFIXES, RECORD_SEGS, PARTITIONED_SEGS, PRUNED_SDK_ARCHIVES, OMIT_SDK_LIB_FLAGS, NEUTRALIZED_SWIFTRT_SECTIONS, ADDEND_RELOC_MASK2, relocationBytes, parsedObjectCache, PARSED_ROOTS, SWIFTUI_WRAPPER_HOST_PROTOCOLS, SWIFT_PRUNED_LINK_MAP, SWIFT_PRUNED_LINK_RESPONSE;
|
|
10862
10788
|
var init_swift_wasm_prune = __esm({
|
|
10863
10789
|
"src/swift-wasm-prune.ts"() {
|
|
10864
10790
|
"use strict";
|
|
10865
10791
|
import_node_child_process10 = require("node:child_process");
|
|
10866
|
-
|
|
10792
|
+
import_node_crypto9 = require("node:crypto");
|
|
10867
10793
|
import_node_fs16 = __toESM(require("node:fs"), 1);
|
|
10868
10794
|
import_node_path17 = __toESM(require("node:path"), 1);
|
|
10869
10795
|
v3 = __toESM(require("peachsim/vendor/valibot"), 1);
|
|
10796
|
+
init_sha256();
|
|
10870
10797
|
init_swift_guest_source_plan();
|
|
10871
10798
|
init_swift_link_roots();
|
|
10872
10799
|
init_swift_resource_class_names();
|
|
@@ -10874,6 +10801,7 @@ var init_swift_wasm_prune = __esm({
|
|
|
10874
10801
|
init_swift_toolchain();
|
|
10875
10802
|
init_swift_wasm_archive();
|
|
10876
10803
|
init_swiftRuntimeProductContract();
|
|
10804
|
+
init_wasm_binary_sections();
|
|
10877
10805
|
WIDE_DATA_RELOCS = /* @__PURE__ */ new Set([16, 19, 22, 27]);
|
|
10878
10806
|
ROOT_SEG_PREFIXES = [
|
|
10879
10807
|
".init_array",
|
|
@@ -10980,7 +10908,7 @@ function aliasGuestArchive(options) {
|
|
|
10980
10908
|
alias,
|
|
10981
10909
|
name: member.name,
|
|
10982
10910
|
ordinal,
|
|
10983
|
-
sha256: (0,
|
|
10911
|
+
sha256: (0, import_node_crypto10.createHash)("sha256").update(member.bytes).digest("hex")
|
|
10984
10912
|
};
|
|
10985
10913
|
});
|
|
10986
10914
|
const response = import_node_path18.default.join(options.directory, "members.rsp");
|
|
@@ -10993,7 +10921,7 @@ function aliasGuestArchive(options) {
|
|
|
10993
10921
|
(0, import_node_child_process11.execFileSync)(options.llvmAr, ["rcsD", archive, `@${response}`], { stdio: "pipe" });
|
|
10994
10922
|
const rewritten = readArMembers((0, import_node_fs17.readFileSync)(archive));
|
|
10995
10923
|
if (rewritten.length !== members.length || rewritten.some(
|
|
10996
|
-
(member, index) => member.name !== members[index].alias || (0,
|
|
10924
|
+
(member, index) => member.name !== members[index].alias || (0, import_node_crypto10.createHash)("sha256").update(member.bytes).digest("hex") !== members[index].sha256
|
|
10997
10925
|
))
|
|
10998
10926
|
throw new Error(`guest archive changed members ${options.archive}`);
|
|
10999
10927
|
return { source: options.archive, archive, members };
|
|
@@ -11053,12 +10981,12 @@ function aliasGuestLinkIdentities(identities, archives) {
|
|
|
11053
10981
|
}
|
|
11054
10982
|
return result;
|
|
11055
10983
|
}
|
|
11056
|
-
var import_node_child_process11,
|
|
10984
|
+
var import_node_child_process11, import_node_crypto10, import_node_fs17, import_node_path18;
|
|
11057
10985
|
var init_swift_guest_archive = __esm({
|
|
11058
10986
|
"src/swift-guest-archive.ts"() {
|
|
11059
10987
|
"use strict";
|
|
11060
10988
|
import_node_child_process11 = require("node:child_process");
|
|
11061
|
-
|
|
10989
|
+
import_node_crypto10 = require("node:crypto");
|
|
11062
10990
|
import_node_fs17 = require("node:fs");
|
|
11063
10991
|
import_node_path18 = __toESM(require("node:path"), 1);
|
|
11064
10992
|
init_swift_wasm_prune();
|
|
@@ -11096,34 +11024,11 @@ var init_nativeWasmContract = __esm({
|
|
|
11096
11024
|
});
|
|
11097
11025
|
|
|
11098
11026
|
// src/swift-guest-image-ledger.ts
|
|
11099
|
-
function readNumber(bytes, position) {
|
|
11100
|
-
if (position < bytes.length) {
|
|
11101
|
-
const first = bytes[position];
|
|
11102
|
-
if (first < 128) return [first, position + 1];
|
|
11103
|
-
}
|
|
11104
|
-
let value = 0;
|
|
11105
|
-
let shift = 0;
|
|
11106
|
-
for (; ; ) {
|
|
11107
|
-
if (position >= bytes.length || shift > 63) throw new Error("invalid wasm integer");
|
|
11108
|
-
const byte = bytes[position++];
|
|
11109
|
-
value += (byte & 127) * 2 ** shift;
|
|
11110
|
-
if (!(byte & 128)) return [value, position];
|
|
11111
|
-
shift += 7;
|
|
11112
|
-
}
|
|
11113
|
-
}
|
|
11114
11027
|
function encodeNumber(value) {
|
|
11115
|
-
|
|
11116
|
-
const bytes = [];
|
|
11117
|
-
do {
|
|
11118
|
-
let byte = value % 128;
|
|
11119
|
-
value = Math.floor(value / 128);
|
|
11120
|
-
if (value) byte |= 128;
|
|
11121
|
-
bytes.push(byte);
|
|
11122
|
-
} while (value);
|
|
11123
|
-
return Buffer.from(bytes);
|
|
11028
|
+
return Buffer.from(encodeWasmNumber(value));
|
|
11124
11029
|
}
|
|
11125
11030
|
function readString(bytes, position) {
|
|
11126
|
-
const [length, start] =
|
|
11031
|
+
const [length, start] = readULEB(bytes, position);
|
|
11127
11032
|
if (start + length > bytes.length) throw new Error("invalid wasm string");
|
|
11128
11033
|
return [
|
|
11129
11034
|
Buffer.from(bytes.buffer, bytes.byteOffset + start, length).toString("utf8"),
|
|
@@ -11449,13 +11354,13 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
11449
11354
|
for (const subsection of subsections) {
|
|
11450
11355
|
if (subsection.kind === 6 && objcLoader !== void 0) {
|
|
11451
11356
|
const content = subsection.parts[0];
|
|
11452
|
-
const [count, entriesStart] =
|
|
11357
|
+
const [count, entriesStart] = readULEB(content, 0);
|
|
11453
11358
|
const initWriter = new ByteWriter(content.length + 16);
|
|
11454
11359
|
initWriter.bytes(content, 0, entriesStart);
|
|
11455
11360
|
let entryStart = entriesStart;
|
|
11456
11361
|
for (let i = 0; i < count; i++) {
|
|
11457
|
-
const [, symbolStart] =
|
|
11458
|
-
const [symbol, entryEnd] =
|
|
11362
|
+
const [, symbolStart] = readULEB(content, entryStart);
|
|
11363
|
+
const [symbol, entryEnd] = readULEB(content, symbolStart);
|
|
11459
11364
|
if (symbol === objcLoader) {
|
|
11460
11365
|
initWriter.uleb(1);
|
|
11461
11366
|
initWriter.bytes(content, symbolStart, entryEnd);
|
|
@@ -11525,7 +11430,7 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
11525
11430
|
if (position < bytes.length && bytes[position] < 128) {
|
|
11526
11431
|
size = bytes[position++];
|
|
11527
11432
|
} else {
|
|
11528
|
-
const [val, next] =
|
|
11433
|
+
const [val, next] = readULEB(bytes, position);
|
|
11529
11434
|
size = val;
|
|
11530
11435
|
position = next;
|
|
11531
11436
|
}
|
|
@@ -12025,7 +11930,7 @@ function createGuestImageLedger(input) {
|
|
|
12025
11930
|
const digest = ({ object: object4 }) => {
|
|
12026
11931
|
let value = digests.get(object4);
|
|
12027
11932
|
if (value === void 0) {
|
|
12028
|
-
value = (0,
|
|
11933
|
+
value = (0, import_node_crypto11.createHash)("sha256").update(objects2.get(object4).bytes).digest("hex");
|
|
12029
11934
|
digests.set(object4, value);
|
|
12030
11935
|
}
|
|
12031
11936
|
return value;
|
|
@@ -12240,7 +12145,7 @@ done:
|
|
|
12240
12145
|
attributes #0 = { "wasm-import-module"="${NATIVE_TABLE_IMPORT_MODULE}" "wasm-import-name"="${NATIVE_DYLD_FUNCTION_IMPORT}" }`;
|
|
12241
12146
|
}
|
|
12242
12147
|
function sdkGuestCallerId(product) {
|
|
12243
|
-
const hash = (0,
|
|
12148
|
+
const hash = (0, import_node_crypto11.createHash)("sha256").update(product).digest().readUInt32LE(0);
|
|
12244
12149
|
return (hash | 2147483648) >>> 0;
|
|
12245
12150
|
}
|
|
12246
12151
|
function sdkGuestSymbolName(product, name3) {
|
|
@@ -12281,7 +12186,7 @@ function nameGuestImageAliases(wasm, symbols) {
|
|
|
12281
12186
|
const parts = [wasm.subarray(0, 8)];
|
|
12282
12187
|
let position = 8;
|
|
12283
12188
|
while (position < wasm.length) {
|
|
12284
|
-
const [size, start] =
|
|
12189
|
+
const [size, start] = readULEB(wasm, position + 1);
|
|
12285
12190
|
const end = start + size;
|
|
12286
12191
|
const custom = wasm[position] === 0 ? readString(wasm, start) : void 0;
|
|
12287
12192
|
if (custom?.[0] !== "name") {
|
|
@@ -12292,17 +12197,17 @@ function nameGuestImageAliases(wasm, symbols) {
|
|
|
12292
12197
|
const subsections = [encodedString("name")];
|
|
12293
12198
|
let at = custom[1];
|
|
12294
12199
|
while (at < end) {
|
|
12295
|
-
const [subSize, subStart] =
|
|
12200
|
+
const [subSize, subStart] = readULEB(wasm, at + 1);
|
|
12296
12201
|
const subEnd = subStart + subSize;
|
|
12297
12202
|
if (wasm[at] !== 1) {
|
|
12298
12203
|
subsections.push(wasm.subarray(at, subEnd));
|
|
12299
12204
|
at = subEnd;
|
|
12300
12205
|
continue;
|
|
12301
12206
|
}
|
|
12302
|
-
let [count, cursor] =
|
|
12207
|
+
let [count, cursor] = readULEB(wasm, subStart);
|
|
12303
12208
|
const entries2 = [encodeNumber(count)];
|
|
12304
12209
|
for (; count > 0; count--) {
|
|
12305
|
-
const [index, next] =
|
|
12210
|
+
const [index, next] = readULEB(wasm, cursor);
|
|
12306
12211
|
const [name3, after] = readString(wasm, next);
|
|
12307
12212
|
cursor = after;
|
|
12308
12213
|
const symbol = symbols[Number(alias.exec(name3)?.[1] ?? -1)];
|
|
@@ -12318,14 +12223,15 @@ function nameGuestImageAliases(wasm, symbols) {
|
|
|
12318
12223
|
}
|
|
12319
12224
|
return Buffer.concat(parts);
|
|
12320
12225
|
}
|
|
12321
|
-
var
|
|
12226
|
+
var import_node_crypto11, ByteWriter, OBJC_INIT_RECORD, TABLE_INDEX_RELOCATIONS, sha256PairHex, GUEST_DYLD_VALUES_SECTION, GUEST_LAZY_FUNCTION_BASE, SDK_DYLD_RESOLVER;
|
|
12322
12227
|
var init_swift_guest_image_ledger = __esm({
|
|
12323
12228
|
"src/swift-guest-image-ledger.ts"() {
|
|
12324
12229
|
"use strict";
|
|
12325
|
-
|
|
12230
|
+
import_node_crypto11 = require("node:crypto");
|
|
12326
12231
|
init_nativeWasmContract();
|
|
12327
12232
|
init_swift_sdk_image_wasm();
|
|
12328
12233
|
init_swiftSdkLinkContract();
|
|
12234
|
+
init_wasm_binary_sections();
|
|
12329
12235
|
ByteWriter = class {
|
|
12330
12236
|
buf;
|
|
12331
12237
|
pos = 0;
|
|
@@ -12346,16 +12252,13 @@ var init_swift_guest_image_ledger = __esm({
|
|
|
12346
12252
|
this.buf[this.pos++] = value;
|
|
12347
12253
|
}
|
|
12348
12254
|
uleb(value) {
|
|
12349
|
-
|
|
12350
|
-
|
|
12351
|
-
|
|
12352
|
-
|
|
12353
|
-
|
|
12354
|
-
|
|
12355
|
-
|
|
12356
|
-
buf[pos++] = byte;
|
|
12357
|
-
} while (value);
|
|
12358
|
-
this.pos = pos;
|
|
12255
|
+
if (value < 128) {
|
|
12256
|
+
this.byte(value);
|
|
12257
|
+
return;
|
|
12258
|
+
}
|
|
12259
|
+
const encoded = encodeWasmNumber(value);
|
|
12260
|
+
this.ensure(encoded.length);
|
|
12261
|
+
for (let i = 0; i < encoded.length; i++) this.buf[this.pos++] = encoded[i];
|
|
12359
12262
|
}
|
|
12360
12263
|
bytes(source, start = 0, end = source.length) {
|
|
12361
12264
|
const len = end - start;
|
|
@@ -12379,7 +12282,7 @@ var init_swift_guest_image_ledger = __esm({
|
|
|
12379
12282
|
};
|
|
12380
12283
|
OBJC_INIT_RECORD = ".objc_init";
|
|
12381
12284
|
TABLE_INDEX_RELOCATIONS = /* @__PURE__ */ new Set([1, 2, 12, 18, 19, 24]);
|
|
12382
|
-
sha256PairHex = typeof Bun !== "undefined" ? (first, second) => new Bun.CryptoHasher("sha256").update(first).update("\0").update(second).digest("hex") : (first, second) => (0,
|
|
12285
|
+
sha256PairHex = typeof Bun !== "undefined" ? (first, second) => new Bun.CryptoHasher("sha256").update(first).update("\0").update(second).digest("hex") : (first, second) => (0, import_node_crypto11.createHash)("sha256").update(first).update("\0").update(second).digest("hex");
|
|
12383
12286
|
GUEST_DYLD_VALUES_SECTION = "peach_dyld_values";
|
|
12384
12287
|
GUEST_LAZY_FUNCTION_BASE = 2 ** 32;
|
|
12385
12288
|
SDK_DYLD_RESOLVER = "__peach_sdk_dyld_resolve";
|
|
@@ -12689,14 +12592,7 @@ var init_wasm_narrow_boundary = __esm({
|
|
|
12689
12592
|
function sha256Buffer(bytes) {
|
|
12690
12593
|
if (typeof Bun !== "undefined")
|
|
12691
12594
|
return Buffer.from(new Bun.CryptoHasher("sha256").update(bytes).digest());
|
|
12692
|
-
return (0,
|
|
12693
|
-
}
|
|
12694
|
-
function uleb2(value) {
|
|
12695
|
-
const bytes = [];
|
|
12696
|
-
for (let rest = value; ; rest = Math.floor(rest / 128)) {
|
|
12697
|
-
if (rest < 128) return [...bytes, rest];
|
|
12698
|
-
bytes.push(rest % 128 | 128);
|
|
12699
|
-
}
|
|
12595
|
+
return (0, import_node_crypto12.createHash)("sha256").update(bytes).digest();
|
|
12700
12596
|
}
|
|
12701
12597
|
function encodeGuestDyldTable(rows) {
|
|
12702
12598
|
const encoded = rows.map((row) => ({ ...row, bytes: Buffer.from(row.name) })).sort((a, b) => Buffer.compare(a.bytes, b.bytes));
|
|
@@ -12710,7 +12606,7 @@ function encodeGuestDyldTable(rows) {
|
|
|
12710
12606
|
value.writeBigUInt64LE(row.value);
|
|
12711
12607
|
const bytes = Buffer.concat([
|
|
12712
12608
|
row.bytes,
|
|
12713
|
-
Buffer.from([0, ...
|
|
12609
|
+
Buffer.from([0, ...encodeWasmNumber(row.image), row.kind]),
|
|
12714
12610
|
value
|
|
12715
12611
|
]);
|
|
12716
12612
|
if (!current.length) firsts.push(row.bytes);
|
|
@@ -12777,15 +12673,17 @@ function guestDyldValueRange(map) {
|
|
|
12777
12673
|
}
|
|
12778
12674
|
return found;
|
|
12779
12675
|
}
|
|
12780
|
-
var
|
|
12676
|
+
var import_node_crypto12, import_node_zlib2, PACK_BYTES;
|
|
12781
12677
|
var init_swift_guest_dyld_table = __esm({
|
|
12782
12678
|
"src/swift-guest-dyld-table.ts"() {
|
|
12783
12679
|
"use strict";
|
|
12784
|
-
|
|
12680
|
+
import_node_crypto12 = require("node:crypto");
|
|
12785
12681
|
import_node_zlib2 = require("node:zlib");
|
|
12786
12682
|
init_nativeDyldTableContract();
|
|
12683
|
+
init_sha256();
|
|
12787
12684
|
init_swift_guest_image_ledger();
|
|
12788
12685
|
init_swift_guest_linked_spans();
|
|
12686
|
+
init_wasm_binary_sections();
|
|
12789
12687
|
init_wasm_narrow_boundary();
|
|
12790
12688
|
PACK_BYTES = 64 * 1024;
|
|
12791
12689
|
}
|
|
@@ -12861,8 +12759,8 @@ function readImports2(bytes, sections) {
|
|
|
12861
12759
|
return { functions, table64 };
|
|
12862
12760
|
}
|
|
12863
12761
|
function vectorSection(id, count, parts) {
|
|
12864
|
-
const body = Buffer.concat([Buffer.from(
|
|
12865
|
-
return Buffer.concat([Buffer.from([id, ...
|
|
12762
|
+
const body = Buffer.concat([Buffer.from(encodeWasmNumber(count)), ...parts]);
|
|
12763
|
+
return Buffer.concat([Buffer.from([id, ...encodeWasmNumber(body.length)]), body]);
|
|
12866
12764
|
}
|
|
12867
12765
|
function rewriteSections(bytes, sections, changes) {
|
|
12868
12766
|
const out = [bytes.subarray(0, 8)];
|
|
@@ -12918,9 +12816,9 @@ function appendLazyPlacement(bytes, functions, table) {
|
|
|
12918
12816
|
vectorSection(2, count + 1, [
|
|
12919
12817
|
found && header ? bytes.subarray(header.at, found.end) : new Uint8Array(),
|
|
12920
12818
|
Buffer.from([
|
|
12921
|
-
...
|
|
12819
|
+
...encodeWasmNumber(module2.length),
|
|
12922
12820
|
...module2,
|
|
12923
|
-
...
|
|
12821
|
+
...encodeWasmNumber(name4.length),
|
|
12924
12822
|
...name4,
|
|
12925
12823
|
1,
|
|
12926
12824
|
112,
|
|
@@ -12942,7 +12840,7 @@ function appendLazyPlacement(bytes, functions, table) {
|
|
|
12942
12840
|
elements.splice(
|
|
12943
12841
|
placementIndex,
|
|
12944
12842
|
0,
|
|
12945
|
-
Buffer.from([1, 0, ...
|
|
12843
|
+
Buffer.from([1, 0, ...encodeWasmNumber(functions.length), ...functions.flatMap(encodeWasmNumber)])
|
|
12946
12844
|
);
|
|
12947
12845
|
const place2 = imports.functions + declared.length;
|
|
12948
12846
|
const instructions = [
|
|
@@ -12956,7 +12854,7 @@ function appendLazyPlacement(bytes, functions, table) {
|
|
|
12956
12854
|
1,
|
|
12957
12855
|
252,
|
|
12958
12856
|
12,
|
|
12959
|
-
...
|
|
12857
|
+
...encodeWasmNumber(placementIndex),
|
|
12960
12858
|
0,
|
|
12961
12859
|
11
|
|
12962
12860
|
];
|
|
@@ -12977,14 +12875,14 @@ function appendLazyPlacement(bytes, functions, table) {
|
|
|
12977
12875
|
3,
|
|
12978
12876
|
vectorSection(3, declared.length + 1, [
|
|
12979
12877
|
...declared,
|
|
12980
|
-
Buffer.from(
|
|
12878
|
+
Buffer.from(encodeWasmNumber(types.length))
|
|
12981
12879
|
])
|
|
12982
12880
|
],
|
|
12983
12881
|
[
|
|
12984
12882
|
7,
|
|
12985
12883
|
vectorSection(7, exports2.length + 1, [
|
|
12986
12884
|
...exports2,
|
|
12987
|
-
Buffer.from([...
|
|
12885
|
+
Buffer.from([...encodeWasmNumber(name3.length), ...name3, 0, ...encodeWasmNumber(place2)])
|
|
12988
12886
|
])
|
|
12989
12887
|
],
|
|
12990
12888
|
[9, vectorSection(9, elements.length, elements)],
|
|
@@ -12992,7 +12890,7 @@ function appendLazyPlacement(bytes, functions, table) {
|
|
|
12992
12890
|
10,
|
|
12993
12891
|
vectorSection(10, bodies.length + 1, [
|
|
12994
12892
|
...bodies,
|
|
12995
|
-
Buffer.from([...
|
|
12893
|
+
Buffer.from([...encodeWasmNumber(instructions.length), ...instructions])
|
|
12996
12894
|
])
|
|
12997
12895
|
]
|
|
12998
12896
|
])
|
|
@@ -13045,22 +12943,13 @@ function placeGuestLazyFunctions(bytes, lazy) {
|
|
|
13045
12943
|
function guestLazyExports(lazy) {
|
|
13046
12944
|
return lazy.map((name3) => JSON.stringify(`--export=${name3}`)).join("\n");
|
|
13047
12945
|
}
|
|
13048
|
-
var
|
|
12946
|
+
var SECTION_ORDER, readExport, lastTableElement;
|
|
13049
12947
|
var init_swift_guest_dyld_functions = __esm({
|
|
13050
12948
|
"src/swift-guest-dyld-functions.ts"() {
|
|
13051
12949
|
"use strict";
|
|
13052
12950
|
init_nativeWasmContract();
|
|
13053
12951
|
init_swift_sdk_image_wasm();
|
|
13054
|
-
|
|
13055
|
-
const out = [];
|
|
13056
|
-
do {
|
|
13057
|
-
let byte = value % 128;
|
|
13058
|
-
value = Math.floor(value / 128);
|
|
13059
|
-
if (value) byte |= 128;
|
|
13060
|
-
out.push(byte);
|
|
13061
|
-
} while (value);
|
|
13062
|
-
return out;
|
|
13063
|
-
};
|
|
12952
|
+
init_wasm_binary_sections();
|
|
13064
12953
|
SECTION_ORDER = [1, 2, 3, 4, 5, 13, 6, 7, 8, 9, 12, 10, 11];
|
|
13065
12954
|
readExport = (r) => {
|
|
13066
12955
|
r.name();
|
|
@@ -13126,7 +13015,7 @@ function selectedGuestManifestInputs(plan, selection, identities, readSelected)
|
|
|
13126
13015
|
throw new Error(
|
|
13127
13016
|
`selected member has no original identity: ${item.artifact}(${item.member})`
|
|
13128
13017
|
);
|
|
13129
|
-
if (origin && (0,
|
|
13018
|
+
if (origin && (0, import_node_crypto13.createHash)("sha256").update(bytes).digest("hex") !== origin.sha256)
|
|
13130
13019
|
throw new Error(
|
|
13131
13020
|
`selected member differs from original: ${item.artifact}(${item.member})`
|
|
13132
13021
|
);
|
|
@@ -13173,7 +13062,7 @@ function createGuestImageManifest(image) {
|
|
|
13173
13062
|
cpuType: -1,
|
|
13174
13063
|
cpuSubtype: 0
|
|
13175
13064
|
};
|
|
13176
|
-
const digest = (0,
|
|
13065
|
+
const digest = (0, import_node_crypto13.createHash)("sha256");
|
|
13177
13066
|
const sizeBuf = Buffer.allocUnsafe(8);
|
|
13178
13067
|
const add = (bytes) => {
|
|
13179
13068
|
sizeBuf.writeBigUInt64BE(BigInt(bytes.byteLength));
|
|
@@ -13215,11 +13104,11 @@ function createGuestImageManifest(image) {
|
|
|
13215
13104
|
regions: image.regions
|
|
13216
13105
|
};
|
|
13217
13106
|
}
|
|
13218
|
-
var
|
|
13107
|
+
var import_node_crypto13, import_node_fs18, framedLinkOptionsCache;
|
|
13219
13108
|
var init_swift_guest_manifest = __esm({
|
|
13220
13109
|
"src/swift-guest-manifest.ts"() {
|
|
13221
13110
|
"use strict";
|
|
13222
|
-
|
|
13111
|
+
import_node_crypto13 = require("node:crypto");
|
|
13223
13112
|
import_node_fs18 = require("node:fs");
|
|
13224
13113
|
init_swift_guest_link_plan();
|
|
13225
13114
|
init_swift_wasm_prune();
|
|
@@ -13685,11 +13574,11 @@ var init_swift_guest_projection_storage = __esm({
|
|
|
13685
13574
|
function frameworkRuntimeProductId(product) {
|
|
13686
13575
|
return `swift-package/${product.packageName}/${product.product.name}`;
|
|
13687
13576
|
}
|
|
13688
|
-
var
|
|
13577
|
+
var import_node_crypto14, v4, packageSchema;
|
|
13689
13578
|
var init_swift_runtime_products = __esm({
|
|
13690
13579
|
"src/swift-runtime-products.ts"() {
|
|
13691
13580
|
"use strict";
|
|
13692
|
-
|
|
13581
|
+
import_node_crypto14 = require("node:crypto");
|
|
13693
13582
|
v4 = __toESM(require("peachsim/vendor/valibot"), 1);
|
|
13694
13583
|
init_is_record();
|
|
13695
13584
|
packageSchema = v4.object({
|
|
@@ -13720,7 +13609,7 @@ function canonicalArchivePath(file) {
|
|
|
13720
13609
|
function sdkArtifactBytes(root, artifact) {
|
|
13721
13610
|
const file = import_node_path19.default.resolve(root, artifact.path);
|
|
13722
13611
|
const linked = (0, import_node_fs19.readFileSync)(file);
|
|
13723
|
-
const hash = (bytes) => (0,
|
|
13612
|
+
const hash = (bytes) => (0, import_node_crypto15.createHash)("sha256").update(bytes).digest("hex");
|
|
13724
13613
|
if (hash(linked) === artifact.sha256) return { source: linked, linked };
|
|
13725
13614
|
if (artifact.kind !== "archive" || artifact.path !== `${SWIFT_SDK_PRODUCT_DIRECTORY}/libFoundation.a`)
|
|
13726
13615
|
throw new Error(`SDK product artifact changed ${file}`);
|
|
@@ -13746,9 +13635,9 @@ function indexSdkMembers(bytes) {
|
|
|
13746
13635
|
);
|
|
13747
13636
|
}
|
|
13748
13637
|
function verifySdkObjectTransform(source, linked, sourceSha256, transformation) {
|
|
13749
|
-
if ((0,
|
|
13638
|
+
if ((0, import_node_crypto15.createHash)("sha256").update(source).digest("hex") !== sourceSha256 || transformation.inputSha256 !== sourceSha256)
|
|
13750
13639
|
throw new Error("SDK object transform input changed");
|
|
13751
|
-
if ((0,
|
|
13640
|
+
if ((0, import_node_crypto15.createHash)("sha256").update(linked).digest("hex") !== transformation.outputSha256 || transformation.kind === "swiftrt" && !Buffer.from(patchSwiftrtObject(source)).equals(linked))
|
|
13752
13641
|
throw new Error("SDK object transform output changed");
|
|
13753
13642
|
}
|
|
13754
13643
|
function readGuestRuntimeCatalogs(sdkRoot, distributionRoot) {
|
|
@@ -14028,7 +13917,7 @@ function guestSdkProductLinkArtifacts(products, sdk, inputs, linkedArchives, rew
|
|
|
14028
13917
|
const digest = (file) => {
|
|
14029
13918
|
let value = hashes.get(file);
|
|
14030
13919
|
if (!value) {
|
|
14031
|
-
value = (0,
|
|
13920
|
+
value = (0, import_node_crypto15.createHash)("sha256").update((0, import_node_fs19.readFileSync)(file)).digest("hex");
|
|
14032
13921
|
hashes.set(file, value);
|
|
14033
13922
|
}
|
|
14034
13923
|
return value;
|
|
@@ -14106,7 +13995,7 @@ function guestSdkProductLinkArtifacts(products, sdk, inputs, linkedArchives, rew
|
|
|
14106
13995
|
archiveMembers.set(originalFile, records);
|
|
14107
13996
|
}
|
|
14108
13997
|
const bytes = records.filter((entry) => entry.name === name3)[ordinal - 1]?.bytes;
|
|
14109
|
-
if (!member || !bytes || (0,
|
|
13998
|
+
if (!member || !bytes || (0, import_node_crypto15.createHash)("sha256").update(bytes).digest("hex") !== sha2562)
|
|
14110
13999
|
throw new Error(`SDK input member changed ${originalFile}(${name3})`);
|
|
14111
14000
|
} else if (original.kind !== "object")
|
|
14112
14001
|
throw new Error(`SDK object input has no member ${originalFile}`);
|
|
@@ -14135,7 +14024,7 @@ function guestSdkProductLinkArtifacts(products, sdk, inputs, linkedArchives, rew
|
|
|
14135
14024
|
const member = members.get(key);
|
|
14136
14025
|
const source = indexed.source.get(key);
|
|
14137
14026
|
const linked2 = indexed.linked.get(key);
|
|
14138
|
-
if (!member || !source || !linked2 || (0,
|
|
14027
|
+
if (!member || !source || !linked2 || (0, import_node_crypto15.createHash)("sha256").update(source).digest("hex") !== member.sha256 || (0, import_node_crypto15.createHash)("sha256").update(linked2).digest("hex") !== digest(origin.original))
|
|
14139
14028
|
throw new Error(`SDK member differs from source product ${origin.original}`);
|
|
14140
14029
|
add({
|
|
14141
14030
|
path: origin.original,
|
|
@@ -14200,7 +14089,7 @@ function guestAliasedSdkArchiveArtifacts(options) {
|
|
|
14200
14089
|
const key = JSON.stringify([member.name, member.ordinal]);
|
|
14201
14090
|
const bytes = sourceMembers[index].get(key);
|
|
14202
14091
|
const linked = viewMembers[index].get(key);
|
|
14203
|
-
return bytes !== void 0 && linked !== void 0 && (0,
|
|
14092
|
+
return bytes !== void 0 && linked !== void 0 && (0, import_node_crypto15.createHash)("sha256").update(bytes).digest("hex") === entry.sha256 && (0, import_node_crypto15.createHash)("sha256").update(linked).digest("hex") === member.sha256;
|
|
14204
14093
|
}) ? [product2.id] : []
|
|
14205
14094
|
)
|
|
14206
14095
|
);
|
|
@@ -14233,11 +14122,11 @@ function guestAliasedSdkArchiveArtifacts(options) {
|
|
|
14233
14122
|
}
|
|
14234
14123
|
return result;
|
|
14235
14124
|
}
|
|
14236
|
-
var
|
|
14125
|
+
var import_node_crypto15, import_node_fs19, import_node_path19, v5, SDK_CONTAINING_IMAGE;
|
|
14237
14126
|
var init_swift_guest_runtime_plan = __esm({
|
|
14238
14127
|
"src/swift-guest-runtime-plan.ts"() {
|
|
14239
14128
|
"use strict";
|
|
14240
|
-
|
|
14129
|
+
import_node_crypto15 = require("node:crypto");
|
|
14241
14130
|
import_node_fs19 = require("node:fs");
|
|
14242
14131
|
import_node_path19 = __toESM(require("node:path"), 1);
|
|
14243
14132
|
v5 = __toESM(require("peachsim/vendor/valibot"), 1);
|
|
@@ -14460,7 +14349,7 @@ async function downloadToFile(url, destPath, signal) {
|
|
|
14460
14349
|
}
|
|
14461
14350
|
}
|
|
14462
14351
|
async function digestFile(filePath, algorithm, encoding, signal) {
|
|
14463
|
-
const hash =
|
|
14352
|
+
const hash = import_node_crypto16.default.createHash(algorithm);
|
|
14464
14353
|
await (0, import_promises4.pipeline)(import_node_fs21.default.createReadStream(filePath), hash, { signal });
|
|
14465
14354
|
return hash.digest(encoding);
|
|
14466
14355
|
}
|
|
@@ -14534,12 +14423,12 @@ async function runExtractor(command, args, signal, input) {
|
|
|
14534
14423
|
await stopping;
|
|
14535
14424
|
}
|
|
14536
14425
|
}
|
|
14537
|
-
var import_node_child_process12,
|
|
14426
|
+
var import_node_child_process12, import_node_crypto16, import_node_fs21, import_node_os5, import_node_path21, import_promises4, import_node_zlib3, DownloadHttpError;
|
|
14538
14427
|
var init_src = __esm({
|
|
14539
14428
|
"../contrast-runtime-delivery/src/index.ts"() {
|
|
14540
14429
|
"use strict";
|
|
14541
14430
|
import_node_child_process12 = require("node:child_process");
|
|
14542
|
-
|
|
14431
|
+
import_node_crypto16 = __toESM(require("node:crypto"), 1);
|
|
14543
14432
|
import_node_fs21 = __toESM(require("node:fs"), 1);
|
|
14544
14433
|
import_node_os5 = __toESM(require("node:os"), 1);
|
|
14545
14434
|
import_node_path21 = __toESM(require("node:path"), 1);
|
|
@@ -14599,11 +14488,11 @@ function rnxHomeDir() {
|
|
|
14599
14488
|
function cacheDir() {
|
|
14600
14489
|
return import_node_path22.default.join(rnxHomeDir(), "cache");
|
|
14601
14490
|
}
|
|
14602
|
-
var
|
|
14491
|
+
var import_node_crypto17, import_node_fs22, import_node_os6, import_node_path22, PEACH_HOME_ENV, DAEMON_LOCKFILE_MAX_BYTES;
|
|
14603
14492
|
var init_home_paths = __esm({
|
|
14604
14493
|
"src/home-paths.ts"() {
|
|
14605
14494
|
"use strict";
|
|
14606
|
-
|
|
14495
|
+
import_node_crypto17 = require("node:crypto");
|
|
14607
14496
|
import_node_fs22 = __toESM(require("node:fs"), 1);
|
|
14608
14497
|
import_node_os6 = require("node:os");
|
|
14609
14498
|
import_node_path22 = __toESM(require("node:path"), 1);
|
|
@@ -16415,13 +16304,8 @@ function clangBinaryStamp(file) {
|
|
|
16415
16304
|
const stat = (0, import_node_fs25.statSync)(file, { bigint: true });
|
|
16416
16305
|
return [file, stat.size, stat.mtimeNs].join(":");
|
|
16417
16306
|
}
|
|
16418
|
-
function sha256Hex2(bytes) {
|
|
16419
|
-
if (typeof Bun !== "undefined")
|
|
16420
|
-
return new Bun.CryptoHasher("sha256").update(bytes).digest("hex");
|
|
16421
|
-
return (0, import_node_crypto17.createHash)("sha256").update(bytes).digest("hex");
|
|
16422
|
-
}
|
|
16423
16307
|
function clangWrapperStamp(file) {
|
|
16424
|
-
return
|
|
16308
|
+
return sha256Hex((0, import_node_fs25.readFileSync)(file));
|
|
16425
16309
|
}
|
|
16426
16310
|
function clangArgsNeedCwd(args) {
|
|
16427
16311
|
const pathFlags = /* @__PURE__ */ new Set([
|
|
@@ -16599,7 +16483,7 @@ function sourceGuestClangLinkOptions(options) {
|
|
|
16599
16483
|
import_node_path25.default.join(options.buildDirectory, CLANG_TARGET_MODULE_WRAPPER)
|
|
16600
16484
|
)))
|
|
16601
16485
|
throw new Error(`unsupported source object producer ${file}`);
|
|
16602
|
-
const key =
|
|
16486
|
+
const key = sha256Hex(
|
|
16603
16487
|
JSON.stringify([
|
|
16604
16488
|
"clang-link-options/v2",
|
|
16605
16489
|
clangArgsNeedCwd(command.args) ? process.cwd() : null,
|
|
@@ -16610,7 +16494,7 @@ function sourceGuestClangLinkOptions(options) {
|
|
|
16610
16494
|
clangProducerStamp(file)
|
|
16611
16495
|
])
|
|
16612
16496
|
);
|
|
16613
|
-
const cacheFile = import_node_path25.default.join(cacheDirectory,
|
|
16497
|
+
const cacheFile = import_node_path25.default.join(cacheDirectory, sha256Hex(file) + ".json");
|
|
16614
16498
|
const cached2 = readClangLinkOptions(cacheFile, key);
|
|
16615
16499
|
if (cached2) {
|
|
16616
16500
|
validateClangLinkOptions(cached2);
|
|
@@ -16732,30 +16616,12 @@ function wasmAutolinkEntries(bytes, out) {
|
|
|
16732
16616
|
const len = bytes.length;
|
|
16733
16617
|
while (pos < len) {
|
|
16734
16618
|
const id = bytes[pos++];
|
|
16735
|
-
let sz
|
|
16736
|
-
|
|
16737
|
-
sz &= 127;
|
|
16738
|
-
let shift = 7;
|
|
16739
|
-
while (true) {
|
|
16740
|
-
const b = bytes[pos++];
|
|
16741
|
-
sz |= (b & 127) << shift;
|
|
16742
|
-
if (b < 128) break;
|
|
16743
|
-
shift += 7;
|
|
16744
|
-
}
|
|
16745
|
-
}
|
|
16619
|
+
let sz;
|
|
16620
|
+
[sz, pos] = readULEB(bytes, pos, len);
|
|
16746
16621
|
const end = pos + sz;
|
|
16747
16622
|
if (id === 0) {
|
|
16748
|
-
let nLen
|
|
16749
|
-
|
|
16750
|
-
nLen &= 127;
|
|
16751
|
-
let shift = 7;
|
|
16752
|
-
while (true) {
|
|
16753
|
-
const b = bytes[pos++];
|
|
16754
|
-
nLen |= (b & 127) << shift;
|
|
16755
|
-
if (b < 128) break;
|
|
16756
|
-
shift += 7;
|
|
16757
|
-
}
|
|
16758
|
-
}
|
|
16623
|
+
let nLen;
|
|
16624
|
+
[nLen, pos] = readULEB(bytes, pos, end);
|
|
16759
16625
|
if (nLen === 24 && raw2.toString("ascii", pos, pos + 24) === ".swift1_autolink_entries") {
|
|
16760
16626
|
const payload = raw2.toString("utf8", pos + 24, end);
|
|
16761
16627
|
for (const entry of payload.split("\0")) {
|
|
@@ -16823,7 +16689,7 @@ function sourceGuestRuntimeLinks(options) {
|
|
|
16823
16689
|
const file = import_node_path25.default.resolve(directory, alias.moduleMap);
|
|
16824
16690
|
if (!file.startsWith(directory + import_node_path25.default.sep))
|
|
16825
16691
|
throw new Error(`invalid framework module map ${alias.moduleMap}`);
|
|
16826
|
-
if ((
|
|
16692
|
+
if (sha256Hex((0, import_node_fs25.readFileSync)(file)) !== alias.moduleMapSha256)
|
|
16827
16693
|
throw new Error(`framework module map changed ${alias.moduleMap}`);
|
|
16828
16694
|
sdkAliases.set(alias.name, {
|
|
16829
16695
|
product: product.id,
|
|
@@ -16879,7 +16745,7 @@ function sourceGuestRuntimeLinks(options) {
|
|
|
16879
16745
|
const map = import_node_path25.default.resolve(root, alias.moduleMap);
|
|
16880
16746
|
if (!map.startsWith(root + import_node_path25.default.sep))
|
|
16881
16747
|
throw new Error(`invalid framework module map ${alias.moduleMap}`);
|
|
16882
|
-
if ((
|
|
16748
|
+
if (sha256Hex((0, import_node_fs25.readFileSync)(map)) !== alias.moduleMapSha256)
|
|
16883
16749
|
throw new Error(`framework module map changed ${alias.moduleMap}`);
|
|
16884
16750
|
frameworkAliases.set(alias.name, { kind: "package", targets: closure(alias.targets) });
|
|
16885
16751
|
}
|
|
@@ -16980,18 +16846,19 @@ function logicalGuestLinkOptions(args, identities, roots) {
|
|
|
16980
16846
|
}
|
|
16981
16847
|
return output;
|
|
16982
16848
|
}
|
|
16983
|
-
var import_node_child_process15,
|
|
16849
|
+
var import_node_child_process15, import_node_fs25, import_node_path25, CLANG_TARGET_MODULE_WRAPPER, PARALLEL_REPLAY;
|
|
16984
16850
|
var init_swift_guest_source_inputs = __esm({
|
|
16985
16851
|
"src/swift-guest-source-inputs.ts"() {
|
|
16986
16852
|
"use strict";
|
|
16987
16853
|
import_node_child_process15 = require("node:child_process");
|
|
16988
|
-
import_node_crypto17 = require("node:crypto");
|
|
16989
16854
|
import_node_fs25 = require("node:fs");
|
|
16990
16855
|
import_node_path25 = __toESM(require("node:path"), 1);
|
|
16991
16856
|
init_forked_script_contract();
|
|
16857
|
+
init_sha256();
|
|
16992
16858
|
init_swift_guest_source_plan();
|
|
16993
16859
|
init_swift_runtime_products();
|
|
16994
16860
|
init_swift_wasm_prune();
|
|
16861
|
+
init_wasm_binary_sections();
|
|
16995
16862
|
CLANG_TARGET_MODULE_WRAPPER = ".peach-clang";
|
|
16996
16863
|
PARALLEL_REPLAY = `
|
|
16997
16864
|
const { spawn } = require('node:child_process')
|
|
@@ -19740,6 +19607,10 @@ ${SWIFT_SDK_IMAGE_VERSION}
|
|
|
19740
19607
|
`).update(inputs).update(products.length === 0 ? "" : `
|
|
19741
19608
|
products ${products.join(" ")}`).digest("hex").slice(0, 32);
|
|
19742
19609
|
}
|
|
19610
|
+
function swiftSdkImageVariantKey(baseKey, required) {
|
|
19611
|
+
if (!required.length) return baseKey;
|
|
19612
|
+
return (0, import_node_crypto26.createHash)("sha256").update(baseKey).update(JSON.stringify(required)).digest("hex").slice(0, 32);
|
|
19613
|
+
}
|
|
19743
19614
|
function swiftSdkImageEntry(key, scopedLookups) {
|
|
19744
19615
|
const inputs = { image: key };
|
|
19745
19616
|
return {
|
|
@@ -19791,11 +19662,24 @@ function sdkImageAt(directory, key, sha2562) {
|
|
|
19791
19662
|
}
|
|
19792
19663
|
async function buildSwiftSdkImage(moduleRoot, scopedLookups = false, frameworkImports = [], options) {
|
|
19793
19664
|
const { imports, products } = swiftSdkImageProducts(moduleRoot, frameworkImports);
|
|
19794
|
-
const
|
|
19795
|
-
const
|
|
19665
|
+
const images = import_node_path37.default.join(swiftCacheDir(), "swift-sdk-images");
|
|
19666
|
+
const baseKey = swiftSdkImageKey(moduleRoot, scopedLookups, products);
|
|
19667
|
+
const required = [...new Set(options?.requiredGuestSymbols)].sort();
|
|
19668
|
+
const base = cached(import_node_path37.default.join(images, baseKey), baseKey);
|
|
19669
|
+
if (base) {
|
|
19670
|
+
if (!required.length) return base;
|
|
19671
|
+
const { functions, data, tls } = base.sdkInterface;
|
|
19672
|
+
if (required.every(
|
|
19673
|
+
(name3) => functions[name3] !== void 0 || data[name3] !== void 0 || tls[name3] !== void 0
|
|
19674
|
+
))
|
|
19675
|
+
return base;
|
|
19676
|
+
}
|
|
19677
|
+
const key = swiftSdkImageVariantKey(baseKey, required);
|
|
19678
|
+
const directory = import_node_path37.default.join(images, key);
|
|
19796
19679
|
const existing = cached(directory, key);
|
|
19797
19680
|
if (existing) return existing;
|
|
19798
|
-
|
|
19681
|
+
const distribution = swiftDistributionAt(moduleRoot);
|
|
19682
|
+
if (!options?.producer && !required.length && !distribution && import_node_path37.default.resolve(moduleRoot) === sourceSwiftCheckout() && process.platform === "linux" && process.env.TM_SESSION) {
|
|
19799
19683
|
const { produceSwiftSdkImage: produceSwiftSdkImage2 } = await Promise.resolve().then(() => (init_swift_sdk_image_producer(), swift_sdk_image_producer_exports));
|
|
19800
19684
|
await produceSwiftSdkImage2({
|
|
19801
19685
|
moduleRoot,
|
|
@@ -19816,7 +19700,7 @@ async function buildSwiftSdkImage(moduleRoot, scopedLookups = false, frameworkIm
|
|
|
19816
19700
|
return cached(directory, key) ?? withSwiftRootLock(directory, async () => {
|
|
19817
19701
|
const previous = cached(directory, key);
|
|
19818
19702
|
if (previous) return previous;
|
|
19819
|
-
if (
|
|
19703
|
+
if (distribution && !required.length) {
|
|
19820
19704
|
const entry = swiftSdkImageEntry(key, scopedLookups);
|
|
19821
19705
|
const fetched = fetchNativeEntry("sdk-image", entry.name, entry.key);
|
|
19822
19706
|
if (fetched) {
|
|
@@ -19853,6 +19737,7 @@ async function buildSwiftSdkImage(moduleRoot, scopedLookups = false, frameworkIm
|
|
|
19853
19737
|
work,
|
|
19854
19738
|
scopedLookups,
|
|
19855
19739
|
imports,
|
|
19740
|
+
required,
|
|
19856
19741
|
releaseFrameworks
|
|
19857
19742
|
)
|
|
19858
19743
|
);
|
|
@@ -19861,7 +19746,7 @@ async function buildSwiftSdkImage(moduleRoot, scopedLookups = false, frameworkIm
|
|
|
19861
19746
|
}
|
|
19862
19747
|
});
|
|
19863
19748
|
}
|
|
19864
|
-
async function linkSwiftSdkImage(moduleRoot, key, directory, work, scopedLookups, imports, releaseFrameworks) {
|
|
19749
|
+
async function linkSwiftSdkImage(moduleRoot, key, directory, work, scopedLookups, imports, required, releaseFrameworks) {
|
|
19865
19750
|
(0, import_node_fs37.rmSync)(work, { recursive: true, force: true });
|
|
19866
19751
|
(0, import_node_fs37.mkdirSync)(work, { recursive: true });
|
|
19867
19752
|
const toolchain = swiftModuleToolchain(moduleRoot);
|
|
@@ -20022,7 +19907,10 @@ async function linkSwiftSdkImage(moduleRoot, key, directory, work, scopedLookups
|
|
|
20022
19907
|
const quote2 = (value) => JSON.stringify(value);
|
|
20023
19908
|
(0, import_node_fs37.writeFileSync)(
|
|
20024
19909
|
import_node_path37.default.join(work, "exports.rsp"),
|
|
20025
|
-
[
|
|
19910
|
+
[
|
|
19911
|
+
...[...defined].map((name3) => quote2(`--export-if-defined=${name3}`)),
|
|
19912
|
+
...required.filter((name3) => !defined.has(name3)).map((name3) => quote2(`--export=${name3}`))
|
|
19913
|
+
].join("\n")
|
|
20026
19914
|
);
|
|
20027
19915
|
const guestServices = import_node_path37.default.join(work, "peach-guest-services.allow");
|
|
20028
19916
|
(0, import_node_fs37.writeFileSync)(guestServices, peachGuestServiceAllowlist);
|
|
@@ -20113,11 +20001,12 @@ async function linkSwiftSdkImage(moduleRoot, key, directory, work, scopedLookups
|
|
|
20113
20001
|
import_node_path37.default.join(work, IMAGE_DIGEST),
|
|
20114
20002
|
typeof Bun !== "undefined" ? new Bun.CryptoHasher("sha256").update(image).digest("hex") : (0, import_node_crypto26.createHash)("sha256").update(image).digest("hex")
|
|
20115
20003
|
);
|
|
20116
|
-
|
|
20004
|
+
const baseKey = swiftSdkImageKey(
|
|
20117
20005
|
moduleRoot,
|
|
20118
20006
|
scopedLookups,
|
|
20119
20007
|
swiftSdkImageProducts(moduleRoot, imports).products
|
|
20120
|
-
)
|
|
20008
|
+
);
|
|
20009
|
+
if (swiftSdkImageVariantKey(baseKey, required) !== key)
|
|
20121
20010
|
throw new Error("Swift SDK image inputs changed during compilation");
|
|
20122
20011
|
for (const name3 of (0, import_node_fs37.readdirSync)(work))
|
|
20123
20012
|
if (!SWIFT_SDK_IMAGE_FILES.includes(name3))
|
|
@@ -20681,8 +20570,8 @@ function finishSwiftAppModuleFile(file) {
|
|
|
20681
20570
|
return;
|
|
20682
20571
|
}
|
|
20683
20572
|
const thunks = sdkImportThunks(prefix);
|
|
20684
|
-
const nameBytes = Buffer.from(
|
|
20685
|
-
const header = Buffer.from([0, ...
|
|
20573
|
+
const nameBytes = Buffer.from(encodeWasmName(NATIVE_SDK_THUNK_SECTION));
|
|
20574
|
+
const header = Buffer.from([0, ...encodeWasmNumber(nameBytes.length + thunks.length)]);
|
|
20686
20575
|
(0, import_node_fs38.appendFileSync)(file, Buffer.concat([header, nameBytes, thunks]));
|
|
20687
20576
|
}
|
|
20688
20577
|
function swiftAppModuleInputs(tokens, buildRoot, sdkLibraries) {
|
|
@@ -21034,17 +20923,17 @@ function sdkImportThunks(bytes) {
|
|
|
21034
20923
|
for (const { type } of imports)
|
|
21035
20924
|
if (!typeIndex.has(type)) typeIndex.set(type, typeIndex.size + 1);
|
|
21036
20925
|
const loaderType = [96, 1, 127, 0];
|
|
21037
|
-
const vector = (items) => [...
|
|
21038
|
-
const sectionBytes = (id, body) => [id, ...
|
|
20926
|
+
const vector = (items) => [...encodeWasmNumber(items.length), ...items.flat()];
|
|
20927
|
+
const sectionBytes = (id, body) => [id, ...encodeWasmNumber(body.length), ...body];
|
|
21039
20928
|
const slotGlobals = imports.map(({ slot }) => [
|
|
21040
|
-
...
|
|
21041
|
-
...
|
|
20929
|
+
...encodeWasmName(NATIVE_SDK_IMPORT_MODULE),
|
|
20930
|
+
...encodeWasmName(String(slot)),
|
|
21042
20931
|
3,
|
|
21043
20932
|
127,
|
|
21044
20933
|
0
|
|
21045
20934
|
]);
|
|
21046
20935
|
const bodies = imports.map(({ type }, index) => {
|
|
21047
|
-
const slotValue = [35, ...
|
|
20936
|
+
const slotValue = [35, ...encodeWasmNumber(index)];
|
|
21048
20937
|
const code = [
|
|
21049
20938
|
0,
|
|
21050
20939
|
...slotValue,
|
|
@@ -21057,14 +20946,14 @@ function sdkImportThunks(bytes) {
|
|
|
21057
20946
|
16,
|
|
21058
20947
|
0,
|
|
21059
20948
|
11,
|
|
21060
|
-
...Array.from({ length: params[type] }, (_, i) => [32, ...
|
|
20949
|
+
...Array.from({ length: params[type] }, (_, i) => [32, ...encodeWasmNumber(i)]).flat(),
|
|
21061
20950
|
...slotValue,
|
|
21062
20951
|
17,
|
|
21063
|
-
...
|
|
20952
|
+
...encodeWasmNumber(typeIndex.get(type)),
|
|
21064
20953
|
0,
|
|
21065
20954
|
11
|
|
21066
20955
|
];
|
|
21067
|
-
return [...
|
|
20956
|
+
return [...encodeWasmNumber(code.length), ...code];
|
|
21068
20957
|
});
|
|
21069
20958
|
return Uint8Array.from([
|
|
21070
20959
|
0,
|
|
@@ -21082,21 +20971,21 @@ function sdkImportThunks(bytes) {
|
|
|
21082
20971
|
...sectionBytes(
|
|
21083
20972
|
2,
|
|
21084
20973
|
vector([
|
|
21085
|
-
[...
|
|
20974
|
+
[...encodeWasmName("env"), ...encodeWasmName("__indirect_function_table"), 1, ...table],
|
|
21086
20975
|
[
|
|
21087
|
-
...
|
|
21088
|
-
...
|
|
20976
|
+
...encodeWasmName(NATIVE_LAZY_IMPORT_MODULE),
|
|
20977
|
+
...encodeWasmName(NATIVE_LAZY_SLOT_IMPORT),
|
|
21089
20978
|
0,
|
|
21090
20979
|
0
|
|
21091
20980
|
],
|
|
21092
20981
|
...slotGlobals
|
|
21093
20982
|
])
|
|
21094
20983
|
),
|
|
21095
|
-
...sectionBytes(3, vector(imports.map(({ type }) =>
|
|
20984
|
+
...sectionBytes(3, vector(imports.map(({ type }) => encodeWasmNumber(typeIndex.get(type))))),
|
|
21096
20985
|
...sectionBytes(
|
|
21097
20986
|
7,
|
|
21098
20987
|
vector(
|
|
21099
|
-
imports.map(({ slot }, i) => [...
|
|
20988
|
+
imports.map(({ slot }, i) => [...encodeWasmName(String(slot)), 0, ...encodeWasmNumber(i + 1)])
|
|
21100
20989
|
)
|
|
21101
20990
|
),
|
|
21102
20991
|
...sectionBytes(10, vector(bodies))
|
|
@@ -21216,7 +21105,7 @@ function resolveSdkReferences(source, sdk, forwarders) {
|
|
|
21216
21105
|
syntheticGlobals.push(type);
|
|
21217
21106
|
got.set(index, value);
|
|
21218
21107
|
}
|
|
21219
|
-
return [35, ...
|
|
21108
|
+
return [35, ...encodeWasmNumber(index)];
|
|
21220
21109
|
};
|
|
21221
21110
|
const tlsHelpers = new Map(
|
|
21222
21111
|
symbols.filter((symbol) => symbol.kind === 0 && symbol.name.startsWith(SDK_TLS_HELPER)).map((symbol) => [symbol.name.slice(SDK_TLS_HELPER.length), symbol.index])
|
|
@@ -21268,7 +21157,7 @@ function resolveSdkReferences(source, sdk, forwarders) {
|
|
|
21268
21157
|
const code = [16];
|
|
21269
21158
|
for (let i = 0, rest = helper; i < 5; i++, rest >>>= 7)
|
|
21270
21159
|
code.push(i < 4 ? rest & 127 | 128 : rest & 127);
|
|
21271
|
-
if (addend) code.push(66, ...
|
|
21160
|
+
if (addend) code.push(66, ...encodeWasmSigned(addend), 124);
|
|
21272
21161
|
patchCode(at2, 11, code);
|
|
21273
21162
|
continue;
|
|
21274
21163
|
}
|
|
@@ -21342,7 +21231,7 @@ function resolveSdkReferences(source, sdk, forwarders) {
|
|
|
21342
21231
|
syntheticGlobals.push(valueType);
|
|
21343
21232
|
scratchGlobals.set(valueType, scratch2);
|
|
21344
21233
|
}
|
|
21345
|
-
const index =
|
|
21234
|
+
const index = encodeWasmNumber(scratch2);
|
|
21346
21235
|
patchCode(at - 2, 12, [
|
|
21347
21236
|
36,
|
|
21348
21237
|
...index,
|
|
@@ -21358,7 +21247,7 @@ function resolveSdkReferences(source, sdk, forwarders) {
|
|
|
21358
21247
|
}
|
|
21359
21248
|
const encodedNameBuf = (name3) => {
|
|
21360
21249
|
const raw2 = Buffer.from(name3, "utf8");
|
|
21361
|
-
const len =
|
|
21250
|
+
const len = encodeWasmNumber(raw2.length);
|
|
21362
21251
|
const out = Buffer.allocUnsafe(len.length + raw2.length);
|
|
21363
21252
|
for (let i = 0; i < len.length; i++) out[i] = len[i];
|
|
21364
21253
|
raw2.copy(out, len.length);
|
|
@@ -21403,7 +21292,7 @@ function resolveSdkReferences(source, sdk, forwarders) {
|
|
|
21403
21292
|
}
|
|
21404
21293
|
}
|
|
21405
21294
|
const globalParts = [
|
|
21406
|
-
Buffer.from(
|
|
21295
|
+
Buffer.from(encodeWasmNumber(globalCount - 1 + syntheticGlobals.length))
|
|
21407
21296
|
];
|
|
21408
21297
|
for (let index = 0; index < globalCount; index++) {
|
|
21409
21298
|
const start = gr.at;
|
|
@@ -21448,18 +21337,18 @@ function resolveSdkReferences(source, sdk, forwarders) {
|
|
|
21448
21337
|
}
|
|
21449
21338
|
}
|
|
21450
21339
|
const exportParts = [
|
|
21451
|
-
Buffer.from(
|
|
21340
|
+
Buffer.from(encodeWasmNumber(exportCount + 1 + got.size)),
|
|
21452
21341
|
bytes.subarray(originalExportsStart, exportSection.end)
|
|
21453
21342
|
];
|
|
21454
21343
|
for (const [index, value] of got) {
|
|
21455
21344
|
exportParts.push(
|
|
21456
21345
|
encodedNameBuf(`${NATIVE_SDK_GLOBAL_PREFIX}${value}.${index}`),
|
|
21457
|
-
Buffer.from([3, ...
|
|
21346
|
+
Buffer.from([3, ...encodeWasmNumber(index)])
|
|
21458
21347
|
);
|
|
21459
21348
|
}
|
|
21460
21349
|
exportParts.push(encodedNameBuf("__indirect_function_table"), Buffer.from([1, 0]));
|
|
21461
21350
|
const replaced = /* @__PURE__ */ new Map([
|
|
21462
|
-
[2, Buffer.concat([Buffer.from(
|
|
21351
|
+
[2, Buffer.concat([Buffer.from(encodeWasmNumber(importEntryCount)), ...importParts])],
|
|
21463
21352
|
[6, Buffer.concat(globalParts)],
|
|
21464
21353
|
[7, Buffer.concat(exportParts)]
|
|
21465
21354
|
]);
|
|
@@ -21476,7 +21365,7 @@ function resolveSdkReferences(source, sdk, forwarders) {
|
|
|
21476
21365
|
if (s.id === 10 && rebuiltCode) {
|
|
21477
21366
|
parts.push(rebuiltCode);
|
|
21478
21367
|
} else if (payload) {
|
|
21479
|
-
parts.push(Buffer.from([s.id, ...
|
|
21368
|
+
parts.push(Buffer.from([s.id, ...encodeWasmNumber(payload.length)]), payload);
|
|
21480
21369
|
} else {
|
|
21481
21370
|
parts.push(bytes.subarray(s.offset, s.end));
|
|
21482
21371
|
}
|
|
@@ -21492,7 +21381,7 @@ function expandSdkRelocations(bytes, section2, patches) {
|
|
|
21492
21381
|
patches.sort((a, b) => a.at - b.at);
|
|
21493
21382
|
const r = wasmReader(bytes, section2.start);
|
|
21494
21383
|
const count = r.u();
|
|
21495
|
-
const payload = [Uint8Array.from(
|
|
21384
|
+
const payload = [Uint8Array.from(encodeWasmNumber(count))];
|
|
21496
21385
|
let next = 0;
|
|
21497
21386
|
for (let i = 0; i < count; i++) {
|
|
21498
21387
|
const start = r.at;
|
|
@@ -21512,7 +21401,7 @@ function expandSdkRelocations(bytes, section2, patches) {
|
|
|
21512
21401
|
}
|
|
21513
21402
|
parts.push(bytes.subarray(at, end));
|
|
21514
21403
|
payload.push(
|
|
21515
|
-
Uint8Array.from(
|
|
21404
|
+
Uint8Array.from(encodeWasmNumber(parts.reduce((size2, part) => size2 + part.length, 0))),
|
|
21516
21405
|
...parts
|
|
21517
21406
|
);
|
|
21518
21407
|
}
|
|
@@ -21521,7 +21410,7 @@ function expandSdkRelocations(bytes, section2, patches) {
|
|
|
21521
21410
|
if (next !== patches.length || r.at !== section2.end)
|
|
21522
21411
|
throw new Error("Swift SDK code relocations exceed the code section");
|
|
21523
21412
|
return Buffer.concat([
|
|
21524
|
-
Uint8Array.from([10, ...
|
|
21413
|
+
Uint8Array.from([10, ...encodeWasmNumber(payload.reduce((size, part) => size + part.length, 0))]),
|
|
21525
21414
|
...payload
|
|
21526
21415
|
]);
|
|
21527
21416
|
}
|
|
@@ -22213,7 +22102,7 @@ function partitionParent(section2) {
|
|
|
22213
22102
|
"__objc_class_refs"
|
|
22214
22103
|
].find((name3) => section2 === name3 || section2.startsWith(`${name3}.`));
|
|
22215
22104
|
}
|
|
22216
|
-
var import_node_child_process25, import_node_crypto27, import_node_fs38, import_node_path38, import_node_util8, import_node_zlib4, run3, RELOCATION_WIDTHS, GLOBAL_INDEX, TLS_SLEB64, SDK_TLS_HELPER, SDK_TLS_DELTA, OBJC_SECTION_BOUNDARY,
|
|
22105
|
+
var import_node_child_process25, import_node_crypto27, import_node_fs38, import_node_path38, import_node_util8, import_node_zlib4, run3, RELOCATION_WIDTHS, GLOBAL_INDEX, TLS_SLEB64, SDK_TLS_HELPER, SDK_TLS_DELTA, OBJC_SECTION_BOUNDARY, SCANNED, RUN_GAP;
|
|
22217
22106
|
var init_swift_sdk_app_module = __esm({
|
|
22218
22107
|
"src/swift-sdk-app-module.ts"() {
|
|
22219
22108
|
"use strict";
|
|
@@ -22236,6 +22125,7 @@ var init_swift_sdk_app_module = __esm({
|
|
|
22236
22125
|
init_swift_wasm_prune();
|
|
22237
22126
|
init_swiftSdkLinkContract();
|
|
22238
22127
|
init_swiftTargetContract();
|
|
22128
|
+
init_wasm_binary_sections();
|
|
22239
22129
|
init_wasm_narrow_boundary();
|
|
22240
22130
|
init_wasm_optimize();
|
|
22241
22131
|
run3 = (0, import_node_util8.promisify)(import_node_child_process25.execFile);
|
|
@@ -22256,32 +22146,6 @@ var init_swift_sdk_app_module = __esm({
|
|
|
22256
22146
|
SDK_TLS_HELPER = "__peach_sdk_tls.";
|
|
22257
22147
|
SDK_TLS_DELTA = "__peach_sdk_tls_delta.";
|
|
22258
22148
|
OBJC_SECTION_BOUNDARY = /^__(?:start|stop)_(__objc_(?:selectors|classes|class_refs|cats|protocols|protocol_refs|class_aliases|constant_string))$/;
|
|
22259
|
-
uleb4 = (value) => {
|
|
22260
|
-
const out = [];
|
|
22261
|
-
do {
|
|
22262
|
-
let byte = value % 128;
|
|
22263
|
-
value = Math.floor(value / 128);
|
|
22264
|
-
if (value) byte |= 128;
|
|
22265
|
-
out.push(byte);
|
|
22266
|
-
} while (value);
|
|
22267
|
-
return out;
|
|
22268
|
-
};
|
|
22269
|
-
sleb2 = (value) => {
|
|
22270
|
-
const out = [];
|
|
22271
|
-
for (; ; ) {
|
|
22272
|
-
const byte = Number(value & 127n);
|
|
22273
|
-
value >>= 7n;
|
|
22274
|
-
if (value === 0n && !(byte & 64) || value === -1n && byte & 64) {
|
|
22275
|
-
out.push(byte);
|
|
22276
|
-
return out;
|
|
22277
|
-
}
|
|
22278
|
-
out.push(byte | 128);
|
|
22279
|
-
}
|
|
22280
|
-
};
|
|
22281
|
-
encodedName2 = (name3) => {
|
|
22282
|
-
const bytes = [...Buffer.from(name3)];
|
|
22283
|
-
return [...uleb4(bytes.length), ...bytes];
|
|
22284
|
-
};
|
|
22285
22149
|
SCANNED = /* @__PURE__ */ new Set([
|
|
22286
22150
|
"swift5_protocols",
|
|
22287
22151
|
"swift5_protocol_conformances",
|
|
@@ -23409,36 +23273,22 @@ function archiveMember(archive, name3) {
|
|
|
23409
23273
|
throw new Error(`swift-icu: ${name3} is not in the sdk's icu archive`);
|
|
23410
23274
|
}
|
|
23411
23275
|
function icuSegment(object4) {
|
|
23412
|
-
let at = 8;
|
|
23413
|
-
const leb2 = () => {
|
|
23414
|
-
let result = 0;
|
|
23415
|
-
let shift = 0;
|
|
23416
|
-
let byte;
|
|
23417
|
-
do {
|
|
23418
|
-
byte = object4[at++];
|
|
23419
|
-
result += (byte & 127) * 2 ** shift;
|
|
23420
|
-
shift += 7;
|
|
23421
|
-
} while (byte & 128);
|
|
23422
|
-
return result;
|
|
23423
|
-
};
|
|
23424
23276
|
const found = [];
|
|
23425
|
-
|
|
23426
|
-
|
|
23427
|
-
const
|
|
23428
|
-
|
|
23429
|
-
|
|
23430
|
-
|
|
23431
|
-
|
|
23432
|
-
|
|
23433
|
-
|
|
23434
|
-
|
|
23435
|
-
|
|
23436
|
-
|
|
23437
|
-
|
|
23438
|
-
|
|
23439
|
-
|
|
23440
|
-
}
|
|
23441
|
-
at = end;
|
|
23277
|
+
for (const section2 of wasmSections(object4)) {
|
|
23278
|
+
if (section2.id !== 11) continue;
|
|
23279
|
+
const reader = readWasmSection(object4, section2.start, section2.end);
|
|
23280
|
+
for (let count = reader.number(); count > 0; count--) {
|
|
23281
|
+
if (reader.number() !== 0)
|
|
23282
|
+
throw new Error("swift-icu: unexpected data segment kind");
|
|
23283
|
+
reader.byte();
|
|
23284
|
+
reader.number();
|
|
23285
|
+
reader.byte();
|
|
23286
|
+
const length = reader.number();
|
|
23287
|
+
const start = reader.position();
|
|
23288
|
+
const bytes = object4.subarray(start, start + length);
|
|
23289
|
+
if (bytes[2] === 218 && bytes[3] === 39) found.push(bytes);
|
|
23290
|
+
reader.skip(length);
|
|
23291
|
+
}
|
|
23442
23292
|
}
|
|
23443
23293
|
if (found.length !== 1)
|
|
23444
23294
|
throw new Error(`swift-icu: expected one icu data segment, found ${found.length}`);
|
|
@@ -23492,6 +23342,7 @@ var init_swift_icu = __esm({
|
|
|
23492
23342
|
init_icuData();
|
|
23493
23343
|
init_swift_toolchain();
|
|
23494
23344
|
init_swiftTargetContract();
|
|
23345
|
+
init_wasm_binary_sections();
|
|
23495
23346
|
run4 = (0, import_node_util9.promisify)(import_node_child_process27.execFile);
|
|
23496
23347
|
deflate = (0, import_node_util9.promisify)(import_node_zlib5.gzip);
|
|
23497
23348
|
compressBrotli = (0, import_node_util9.promisify)(import_node_zlib5.brotliCompress);
|
|
@@ -30345,7 +30196,7 @@ ${wasmThreadLinkFlags.map((flag) => ` "-Xlinker", ${JSON.stringify(flag
|
|
|
30345
30196
|
REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
|
|
30346
30197
|
MULTI_MANIFEST_VERSION = 76;
|
|
30347
30198
|
SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
|
|
30348
|
-
compilerSourceDigest = true ? "
|
|
30199
|
+
compilerSourceDigest = true ? "816651f27c8e6bad4746f2f90d840446903e3c4a2384095dcdf1c9ceb69ceba8" : swiftCompilerSourceDigest(__sootsim_import_meta_dirname);
|
|
30349
30200
|
nativeCxxCompilerFlags = ["-fno-cxx-modules"];
|
|
30350
30201
|
MODULE_MAP_RESPONSE_FILE_RUN = 16;
|
|
30351
30202
|
cFlagArray = (flags) => JSON.stringify(withoutGlogModuleMap(flags));
|