peachsim 0.1.2623 → 0.1.2624
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 +693 -306
- 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-E6V72TM2.mjs → acorn-DH6VFUJ3.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-RLWITQ5C.mjs → chunk-265THLTP.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-PAEJF2JP.mjs → chunk-2YHIYKY2.mjs} +4 -4
- package/dist-lib/esm-chunks/{chunk-XOAOND7F.mjs → chunk-3XA5HYI5.mjs} +6 -6
- package/dist-lib/esm-chunks/{chunk-W3X7RP3H.mjs → chunk-A2WMBGJO.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-UCW7ITXE.mjs → chunk-AV7G5PTE.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-EIOVKQ2C.mjs → chunk-CM2NU5MS.mjs} +5 -5
- package/dist-lib/esm-chunks/{chunk-RVM3WWST.mjs → chunk-EFQFJ7M6.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-RLWTJ6II.mjs → chunk-HKPKCJI5.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-4GNQG2GT.mjs → chunk-IMI2NE4A.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-Q7KCK4YO.mjs → chunk-JHMD4G4V.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-4BJIJ3GP.mjs → chunk-LCO2EXKF.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-CXNXKUNJ.mjs → chunk-LD7Z3NDO.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-RBXTTEI6.mjs → chunk-LMWSFXYN.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-IGB7TRLS.mjs → chunk-LOQBWIPM.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-B4APPUTT.mjs → chunk-LT533AHJ.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-KPG4FUTY.mjs → chunk-N4ZJZUCO.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-NOM66H2G.mjs → chunk-OLAYY7SG.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-GP3KL2GC.mjs → chunk-QNXV766K.mjs} +565 -290
- package/dist-lib/esm-chunks/{chunk-V2CHR3OI.mjs → chunk-QZ5HTMWV.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-B5OQSD4B.mjs → chunk-T7C6Z5UH.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-ISH6XB23.mjs → chunk-UJORQHAE.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-Q4ZATFEN.mjs → chunk-VH4BJS5V.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-6MNE57DC.mjs → chunk-XONCLAVA.mjs} +8 -7
- package/dist-lib/esm-chunks/{chunk-EI7CZDMR.mjs → chunk-YOD53JTM.mjs} +2 -2
- package/dist-lib/esm-chunks/{metro-layout-parser-OHVROLNJ.mjs → metro-layout-parser-MDVTDJ65.mjs} +3 -3
- package/dist-lib/esm-chunks/{swift-package-prebuilt-DRAUK6KR.mjs → swift-package-prebuilt-ZN7I4FYC.mjs} +12 -12
- package/dist-lib/esm-chunks/{swift-sdk-app-module-U2M7CMKA.mjs → swift-sdk-app-module-DUVE2OXH.mjs} +107 -20
- package/dist-lib/esm-chunks/{swift-sdk-image-ZHWSHCNI.mjs → swift-sdk-image-YSWQBCYV.mjs} +16 -16
- package/dist-lib/esm-chunks/{swift-sdk-image-producer-EOJUCK7N.mjs → swift-sdk-image-producer-MZ235WSK.mjs} +5 -5
- package/dist-lib/expo-swift-bundle.cjs +686 -299
- 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 +691 -304
- package/dist-lib/host/fetch-proxy-handler.cjs +7 -7
- 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 +30 -15
- package/dist-lib/native-app-identity-project.mjs +44 -29
- 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 +85 -85
- package/dist-lib/public-origins-lib.json +64 -64
- 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 +691 -304
- package/dist-lib/swift-compile.cjs +638 -280
- 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/package.json +1 -1
- package/src/bazel-project.ts +34 -18
- package/src/binaryen.lock.json +3 -3
- package/src/swift-compile.ts +8 -0
- package/src/swift-guest-compile.ts +170 -160
- package/src/swift-guest-dyld-table.ts +22 -9
- package/src/swift-guest-link.ts +116 -42
- package/src/swift-guest-linked-spans.ts +63 -14
- package/src/swift-guest-projection-storage.ts +7 -6
- package/src/swift-guest-source-inputs.ts +35 -21
- package/src/swift-objc-compile.ts +1 -0
- package/src/swift-sdk-app-module.ts +118 -15
- package/src/swift-sdk-image-wasm.ts +119 -17
- package/src/swift-sdk-image.ts +4 -1
- package/src/swift-wasm-prune.ts +71 -41
- package/src/wasm-narrow-boundary.ts +31 -6
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! peach v0.1.
|
|
1
|
+
/*! peach v0.1.2624 | (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;
|
|
@@ -15928,6 +15928,15 @@ function guestLinkedSpans(map2, before, after, owners, sectionOwners = /* @__PUR
|
|
|
15928
15928
|
const unchanged = before === after;
|
|
15929
15929
|
const original = layout(before, !unchanged, !importsLayout);
|
|
15930
15930
|
const optimized = unchanged ? original : layout(after, true, !importsLayout);
|
|
15931
|
+
if (extra?.optimizedDataSegments) {
|
|
15932
|
+
for (const segment3 of optimized.data) {
|
|
15933
|
+
extra.optimizedDataSegments.push({
|
|
15934
|
+
address: segment3.address,
|
|
15935
|
+
offset: segment3.bytes.byteOffset - after.byteOffset,
|
|
15936
|
+
length: segment3.bytes.length
|
|
15937
|
+
});
|
|
15938
|
+
}
|
|
15939
|
+
}
|
|
15931
15940
|
const collectSymbols = extra?.collectSymbols;
|
|
15932
15941
|
const trackedObject = extra?.trackedObject;
|
|
15933
15942
|
const trackedObjectOwner = extra?.trackedObjectOwner;
|
|
@@ -16096,12 +16105,39 @@ function guestLinkedSpans(map2, before, after, owners, sectionOwners = /* @__PUR
|
|
|
16096
16105
|
}
|
|
16097
16106
|
return result;
|
|
16098
16107
|
};
|
|
16108
|
+
const singleSegmentSlice = (module2, start, length) => {
|
|
16109
|
+
const segs = module2.dataByAddress;
|
|
16110
|
+
let low = 0;
|
|
16111
|
+
let high = segs.length;
|
|
16112
|
+
while (low < high) {
|
|
16113
|
+
const middle = low + high >> 1;
|
|
16114
|
+
if (segs[middle].maximumEnd <= start) low = middle + 1;
|
|
16115
|
+
else high = middle;
|
|
16116
|
+
}
|
|
16117
|
+
let found;
|
|
16118
|
+
const end = start + length;
|
|
16119
|
+
for (let index = low; index < segs.length; index++) {
|
|
16120
|
+
const segment3 = segs[index];
|
|
16121
|
+
if (segment3.address >= end) break;
|
|
16122
|
+
if (segment3.address + segment3.bytes.length > start) {
|
|
16123
|
+
if (found) return void 0;
|
|
16124
|
+
found = segment3;
|
|
16125
|
+
}
|
|
16126
|
+
}
|
|
16127
|
+
if (!found || found.address > start || found.address + found.bytes.length < end)
|
|
16128
|
+
return void 0;
|
|
16129
|
+
return found.bytes.subarray(start - found.address, end - found.address);
|
|
16130
|
+
};
|
|
16131
|
+
const sameDataAt = (start, length) => {
|
|
16132
|
+
const origSlice = singleSegmentSlice(original, start, length);
|
|
16133
|
+
const optSlice = origSlice ? singleSegmentSlice(optimized, start, length) : void 0;
|
|
16134
|
+
if (origSlice && optSlice) return Buffer.compare(origSlice, optSlice) === 0;
|
|
16135
|
+
return dataAt(original, start, length).equals(dataAt(optimized, start, length));
|
|
16136
|
+
};
|
|
16099
16137
|
for (const span of spans) {
|
|
16100
16138
|
if (span.address + span.length > original.memoryBytes || span.address + span.length > optimized.memoryBytes)
|
|
16101
16139
|
throw new Error(`linked data lies outside guest memory at ${span.address}`);
|
|
16102
|
-
if (!unchanged && !
|
|
16103
|
-
dataAt(optimized, span.address, span.length)
|
|
16104
|
-
))
|
|
16140
|
+
if (!unchanged && !sameDataAt(span.address, span.length))
|
|
16105
16141
|
throw new Error(`optimization changed linked data at ${span.address}`);
|
|
16106
16142
|
}
|
|
16107
16143
|
let previous;
|
|
@@ -16235,7 +16271,7 @@ function takeGuestStartupData(wasm, address, length) {
|
|
|
16235
16271
|
const bytes = new Uint8Array(length);
|
|
16236
16272
|
const emptied = /* @__PURE__ */ new Set();
|
|
16237
16273
|
let covered = 0;
|
|
16238
|
-
const
|
|
16274
|
+
const patchedBody = Buffer.from(wasm.subarray(body[0], body[1]));
|
|
16239
16275
|
for (const initializer of startupDataInitializers(wasm.subarray(...body))) {
|
|
16240
16276
|
const end = initializer.address + initializer.length;
|
|
16241
16277
|
if (end <= address || initializer.address >= address + length || !initializer.length)
|
|
@@ -16250,19 +16286,18 @@ function takeGuestStartupData(wasm, address, length) {
|
|
|
16250
16286
|
covered += segment3.length;
|
|
16251
16287
|
emptied.add(initializer.segment);
|
|
16252
16288
|
const [at, immediateEnd] = initializer.lengthImmediate;
|
|
16253
|
-
|
|
16254
|
-
|
|
16289
|
+
patchedBody.fill(128, at, immediateEnd - 1);
|
|
16290
|
+
patchedBody[immediateEnd - 1] = 0;
|
|
16255
16291
|
}
|
|
16256
16292
|
if (covered !== length)
|
|
16257
16293
|
throw new Error("guest startup data does not initialize the whole range");
|
|
16258
|
-
const
|
|
16259
|
-
const payload = [result.subarray(data[1], segments[0].header)];
|
|
16294
|
+
const payload = [wasm.subarray(data[1], segments[0].header)];
|
|
16260
16295
|
for (const [index, segment3] of segments.entries()) {
|
|
16261
16296
|
if (!emptied.has(index)) {
|
|
16262
|
-
payload.push(
|
|
16297
|
+
payload.push(wasm.subarray(segment3.header, segment3.payload + segment3.length));
|
|
16263
16298
|
continue;
|
|
16264
16299
|
}
|
|
16265
|
-
payload.push(
|
|
16300
|
+
payload.push(wasm.subarray(segment3.header, segment3.sizeAt), Uint8Array.of(0));
|
|
16266
16301
|
}
|
|
16267
16302
|
const section2 = Buffer.concat(payload);
|
|
16268
16303
|
const size2 = [];
|
|
@@ -16273,7 +16308,14 @@ function takeGuestStartupData(wasm, address, length) {
|
|
|
16273
16308
|
}
|
|
16274
16309
|
size2.push(rest % 128 | 128);
|
|
16275
16310
|
}
|
|
16276
|
-
parts
|
|
16311
|
+
const parts = [
|
|
16312
|
+
wasm.subarray(0, body[0]),
|
|
16313
|
+
patchedBody,
|
|
16314
|
+
wasm.subarray(body[1], data[0]),
|
|
16315
|
+
Uint8Array.of(11, ...size2),
|
|
16316
|
+
section2,
|
|
16317
|
+
wasm.subarray(data[2])
|
|
16318
|
+
];
|
|
16277
16319
|
return { wasm: Buffer.concat(parts), bytes };
|
|
16278
16320
|
}
|
|
16279
16321
|
var import_node_fs28, import_node_string_decoder, constant;
|
|
@@ -16582,6 +16624,32 @@ function readImports(bytes, imports2) {
|
|
|
16582
16624
|
}
|
|
16583
16625
|
return { functionTypes, importedGlobals, memoryPages };
|
|
16584
16626
|
}
|
|
16627
|
+
function countImportedFunctions(bytes, imports2) {
|
|
16628
|
+
let count = 0;
|
|
16629
|
+
if (!imports2) return count;
|
|
16630
|
+
const r = wasmReader(bytes, imports2.start);
|
|
16631
|
+
for (let n = r.u(); n > 0; n--) {
|
|
16632
|
+
r.skip(r.u());
|
|
16633
|
+
r.skip(r.u());
|
|
16634
|
+
const kind = r.byte();
|
|
16635
|
+
if (kind === 0) {
|
|
16636
|
+
r.u();
|
|
16637
|
+
count++;
|
|
16638
|
+
} else if (kind === 1) {
|
|
16639
|
+
r.byte();
|
|
16640
|
+
skipLimits(r);
|
|
16641
|
+
} else if (kind === 2) {
|
|
16642
|
+
skipLimits(r);
|
|
16643
|
+
} else if (kind === 3) {
|
|
16644
|
+
r.byte();
|
|
16645
|
+
r.byte();
|
|
16646
|
+
} else if (kind === 4) {
|
|
16647
|
+
r.byte();
|
|
16648
|
+
r.u();
|
|
16649
|
+
} else throw new Error(`unknown wasm import kind ${kind}`);
|
|
16650
|
+
}
|
|
16651
|
+
return count;
|
|
16652
|
+
}
|
|
16585
16653
|
function* readFunctionNames(bytes, names) {
|
|
16586
16654
|
for (const r = wasmReader(bytes, names.start); r.at < names.end; ) {
|
|
16587
16655
|
const id = r.byte();
|
|
@@ -16949,28 +17017,73 @@ function codeOnlySdkImage(bytes, constructorMask) {
|
|
|
16949
17017
|
return Buffer.concat(out);
|
|
16950
17018
|
}
|
|
16951
17019
|
function constructorKeys(map2, bytes) {
|
|
16952
|
-
const m = readModule(bytes);
|
|
16953
17020
|
const first = map2.code[0];
|
|
16954
|
-
if (!first
|
|
16955
|
-
const
|
|
16956
|
-
const
|
|
16957
|
-
|
|
17021
|
+
if (!first) throw new Error("link has no code");
|
|
17022
|
+
const sections = wasmSections(bytes);
|
|
17023
|
+
const code = sections.find((s) => s.id === 10);
|
|
17024
|
+
if (!code) throw new Error("link has no code");
|
|
16958
17025
|
const ctors = map2.code.find((chunk) => chunk.section === "__wasm_call_ctors");
|
|
16959
17026
|
if (!ctors) throw new Error("link has no constructors");
|
|
16960
|
-
const
|
|
16961
|
-
|
|
16962
|
-
|
|
16963
|
-
|
|
17027
|
+
const importedFuncs = countImportedFunctions(
|
|
17028
|
+
bytes,
|
|
17029
|
+
sections.find((s) => s.id === 2)
|
|
17030
|
+
);
|
|
17031
|
+
const codeReader = wasmReader(bytes, code.start);
|
|
17032
|
+
const bodyCount = codeReader.u();
|
|
17033
|
+
if (!bodyCount) throw new Error("link has no code");
|
|
17034
|
+
const prefixes = new Uint32Array(bodyCount);
|
|
17035
|
+
let delta = 0;
|
|
17036
|
+
let ctorPrefix = -1;
|
|
17037
|
+
let ctorStart = -1;
|
|
17038
|
+
let ctorEnd = -1;
|
|
17039
|
+
for (let i = 0; i < bodyCount; i++) {
|
|
17040
|
+
const prefix = codeReader.at;
|
|
17041
|
+
const size2 = codeReader.u();
|
|
17042
|
+
prefixes[i] = prefix;
|
|
17043
|
+
if (i === 0) {
|
|
17044
|
+
delta = prefix - first.offset;
|
|
17045
|
+
ctorPrefix = ctors.offset + delta;
|
|
17046
|
+
}
|
|
17047
|
+
if (prefix === ctorPrefix) {
|
|
17048
|
+
ctorStart = codeReader.at;
|
|
17049
|
+
ctorEnd = ctorStart + size2;
|
|
17050
|
+
}
|
|
17051
|
+
codeReader.skip(size2);
|
|
17052
|
+
}
|
|
17053
|
+
if (ctorStart < 0) throw new Error("constructor function not found by map offset");
|
|
17054
|
+
let sorted2 = true;
|
|
17055
|
+
for (let i = 1; i < map2.code.length; i++) {
|
|
17056
|
+
if (map2.code[i].offset < map2.code[i - 1].offset) {
|
|
17057
|
+
sorted2 = false;
|
|
17058
|
+
break;
|
|
17059
|
+
}
|
|
17060
|
+
}
|
|
17061
|
+
const byOffset = sorted2 ? void 0 : new Map(map2.code.map((chunk) => [chunk.offset + delta, chunk]));
|
|
17062
|
+
const findChunk = (targetPrefix) => {
|
|
17063
|
+
if (byOffset) return byOffset.get(targetPrefix);
|
|
17064
|
+
const targetOffset = targetPrefix - delta;
|
|
17065
|
+
let lo = 0;
|
|
17066
|
+
let hi = map2.code.length - 1;
|
|
17067
|
+
while (lo <= hi) {
|
|
17068
|
+
const mid = lo + hi >> 1;
|
|
17069
|
+
const offset = map2.code[mid].offset;
|
|
17070
|
+
if (offset < targetOffset) lo = mid + 1;
|
|
17071
|
+
else if (offset > targetOffset) hi = mid - 1;
|
|
17072
|
+
else return map2.code[mid];
|
|
17073
|
+
}
|
|
17074
|
+
return void 0;
|
|
17075
|
+
};
|
|
17076
|
+
const r = wasmReader(bytes, ctorStart);
|
|
16964
17077
|
for (let n = r.u(); n > 0; n--) {
|
|
16965
17078
|
r.u();
|
|
16966
17079
|
r.byte();
|
|
16967
17080
|
}
|
|
16968
17081
|
const keys = [];
|
|
16969
|
-
while (r.at <
|
|
17082
|
+
while (r.at < ctorEnd) {
|
|
16970
17083
|
const op = r.byte();
|
|
16971
17084
|
if (op === 16) {
|
|
16972
|
-
const callee = r.u() -
|
|
16973
|
-
const chunk =
|
|
17085
|
+
const callee = r.u() - importedFuncs;
|
|
17086
|
+
const chunk = callee >= 0 && callee < bodyCount ? findChunk(prefixes[callee]) : void 0;
|
|
16974
17087
|
if (!chunk) throw new Error("constructor without a map chunk");
|
|
16975
17088
|
keys.push(chunkKey(chunk, ""));
|
|
16976
17089
|
} else if (op !== 26 && op !== 11) throw new Error(`constructor op ${op}`);
|
|
@@ -17053,7 +17166,10 @@ function relocationEdges(bytes, segmentAddress) {
|
|
|
17053
17166
|
r.skip(r.u());
|
|
17054
17167
|
}
|
|
17055
17168
|
}
|
|
17056
|
-
const importedFunctions =
|
|
17169
|
+
const importedFunctions = countImportedFunctions(
|
|
17170
|
+
bytes,
|
|
17171
|
+
sections.find((s) => s.id === 2)
|
|
17172
|
+
);
|
|
17057
17173
|
const data = [];
|
|
17058
17174
|
const dataFunctions = [];
|
|
17059
17175
|
const bodyCount = bodyStarts.length;
|
|
@@ -17167,9 +17283,30 @@ function strongDefinitions(bytes) {
|
|
|
17167
17283
|
).map((s) => s.name);
|
|
17168
17284
|
}
|
|
17169
17285
|
function unslottedFunctions(bytes) {
|
|
17170
|
-
const
|
|
17171
|
-
const
|
|
17172
|
-
|
|
17286
|
+
const sections = wasmSections(bytes);
|
|
17287
|
+
const importedFuncs = countImportedFunctions(
|
|
17288
|
+
bytes,
|
|
17289
|
+
sections.find((s) => s.id === 2)
|
|
17290
|
+
);
|
|
17291
|
+
const code = sections.find((s) => s.id === 10);
|
|
17292
|
+
const definedFuncs = code ? wasmReader(bytes, code.start).u() : 0;
|
|
17293
|
+
const slotted = /* @__PURE__ */ new Set();
|
|
17294
|
+
const elements = sections.find((s) => s.id === 9);
|
|
17295
|
+
if (elements) {
|
|
17296
|
+
const r = wasmReader(bytes, elements.start);
|
|
17297
|
+
for (let n = r.u(); n > 0; n--) {
|
|
17298
|
+
const flags = r.u();
|
|
17299
|
+
if (flags !== 0 && flags !== 2) throw new Error(`sdk image element flags ${flags}`);
|
|
17300
|
+
if (flags === 2) r.u();
|
|
17301
|
+
constant2(r);
|
|
17302
|
+
if (flags === 2) r.byte();
|
|
17303
|
+
for (let i = 0, count = r.u(); i < count; i++) {
|
|
17304
|
+
const index = r.u();
|
|
17305
|
+
if (index >= importedFuncs) slotted.add(index);
|
|
17306
|
+
}
|
|
17307
|
+
}
|
|
17308
|
+
}
|
|
17309
|
+
return definedFuncs - slotted.size;
|
|
17173
17310
|
}
|
|
17174
17311
|
var uleb, sleb, encodedName, section, PROCESS_EXPORTS, SWIFT_SDK_CONSTRUCTOR_LIMIT, FUNCTION_RELOCATIONS, MEMORY_RELOCATIONS, ADDEND_RELOCATIONS, FUNCTION_RELOC_MASK, MEMORY_RELOC_MASK, ADDEND_RELOC_MASK;
|
|
17175
17312
|
var init_swift_sdk_image_wasm = __esm({
|
|
@@ -17553,6 +17690,11 @@ var init_swiftRuntimeProductContract = __esm({
|
|
|
17553
17690
|
});
|
|
17554
17691
|
|
|
17555
17692
|
// src/swift-wasm-prune.ts
|
|
17693
|
+
function sha256Hex(bytes) {
|
|
17694
|
+
if (typeof Bun !== "undefined")
|
|
17695
|
+
return new Bun.CryptoHasher("sha256").update(bytes).digest("hex");
|
|
17696
|
+
return (0, import_node_crypto14.createHash)("sha256").update(bytes).digest("hex");
|
|
17697
|
+
}
|
|
17556
17698
|
function readULEB2(b, o) {
|
|
17557
17699
|
let res = 0;
|
|
17558
17700
|
let shift = 0;
|
|
@@ -18305,6 +18447,42 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
18305
18447
|
}
|
|
18306
18448
|
}
|
|
18307
18449
|
}
|
|
18450
|
+
const segObjCClasses = /* @__PURE__ */ new Map();
|
|
18451
|
+
for (let segIdx = 0; segIdx < sEnds.length; segIdx++) {
|
|
18452
|
+
const rangeStart = dataStart + sPayloadStarts[segIdx];
|
|
18453
|
+
const rangeEnd = dataStart + sEnds[segIdx];
|
|
18454
|
+
const sliceLen = rangeEnd - rangeStart;
|
|
18455
|
+
if (sliceLen < 4) continue;
|
|
18456
|
+
const slice = Buffer.from(rawBuf.buffer, rawBuf.byteOffset + rangeStart, sliceLen);
|
|
18457
|
+
let segPos = 0;
|
|
18458
|
+
let classes;
|
|
18459
|
+
while (segPos < sliceLen - 3) {
|
|
18460
|
+
const at = slice.indexOf("So", segPos);
|
|
18461
|
+
if (at < 0 || at >= sliceLen - 2) break;
|
|
18462
|
+
let digitEnd = at + 2;
|
|
18463
|
+
let length = 0;
|
|
18464
|
+
while (digitEnd < sliceLen) {
|
|
18465
|
+
const ch = slice[digitEnd];
|
|
18466
|
+
if (ch < 48 || ch > 57) break;
|
|
18467
|
+
length = length * 10 + (ch - 48);
|
|
18468
|
+
digitEnd++;
|
|
18469
|
+
}
|
|
18470
|
+
if (digitEnd === at + 2) {
|
|
18471
|
+
segPos = at + 2;
|
|
18472
|
+
continue;
|
|
18473
|
+
}
|
|
18474
|
+
segPos = digitEnd;
|
|
18475
|
+
const nameEnd = digitEnd + length;
|
|
18476
|
+
if (nameEnd >= sliceLen || slice[nameEnd] !== 67) continue;
|
|
18477
|
+
const symbol2 = `._OBJC_CLASS_${slice.toString("latin1", digitEnd, nameEnd)}`;
|
|
18478
|
+
if (!classes) {
|
|
18479
|
+
classes = [symbol2];
|
|
18480
|
+
segObjCClasses.set(segIdx, classes);
|
|
18481
|
+
} else if (!classes.includes(symbol2)) {
|
|
18482
|
+
classes.push(symbol2);
|
|
18483
|
+
}
|
|
18484
|
+
}
|
|
18485
|
+
}
|
|
18308
18486
|
return {
|
|
18309
18487
|
file,
|
|
18310
18488
|
isDist,
|
|
@@ -18334,10 +18512,7 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
18334
18512
|
objcCategoryTargets,
|
|
18335
18513
|
rootFuncs,
|
|
18336
18514
|
rootSegs,
|
|
18337
|
-
|
|
18338
|
-
dataStart + sPayloadStarts[i],
|
|
18339
|
-
dataStart + end
|
|
18340
|
-
])
|
|
18515
|
+
segObjCClasses
|
|
18341
18516
|
};
|
|
18342
18517
|
}
|
|
18343
18518
|
function parseWasmObjectFile(file, isDist) {
|
|
@@ -18705,16 +18880,26 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
|
|
|
18705
18880
|
transformations.set(file, {
|
|
18706
18881
|
output,
|
|
18707
18882
|
inputSha256,
|
|
18708
|
-
outputSha256: (
|
|
18883
|
+
outputSha256: sha256Hex(result),
|
|
18709
18884
|
kind
|
|
18710
18885
|
});
|
|
18711
18886
|
};
|
|
18712
18887
|
const distFiles = [];
|
|
18713
18888
|
const distBaseNames = /* @__PURE__ */ new Set();
|
|
18714
18889
|
const eagerFiles = [];
|
|
18890
|
+
const parsedBuildObjects = /* @__PURE__ */ new Map();
|
|
18715
18891
|
const lazyBuildObjects = /* @__PURE__ */ new Map();
|
|
18716
18892
|
const extraArchiveObjs = [];
|
|
18717
18893
|
const objectBytes = /* @__PURE__ */ new Map();
|
|
18894
|
+
const archiveMembers = /* @__PURE__ */ new Map();
|
|
18895
|
+
const readArchiveMembers = (archive) => {
|
|
18896
|
+
let members2 = archiveMembers.get(archive);
|
|
18897
|
+
if (!members2) {
|
|
18898
|
+
members2 = readArMembers(new Uint8Array(import_node_fs29.default.readFileSync(archive)));
|
|
18899
|
+
archiveMembers.set(archive, members2);
|
|
18900
|
+
}
|
|
18901
|
+
return members2;
|
|
18902
|
+
};
|
|
18718
18903
|
let inStartLib = false;
|
|
18719
18904
|
let swiftrtOrigPath = "";
|
|
18720
18905
|
for (const t of tokens2) {
|
|
@@ -18751,8 +18936,10 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
|
|
|
18751
18936
|
break;
|
|
18752
18937
|
}
|
|
18753
18938
|
}
|
|
18754
|
-
if (definesObjCClassOrCategory)
|
|
18755
|
-
|
|
18939
|
+
if (definesObjCClassOrCategory) {
|
|
18940
|
+
parsedBuildObjects.set(t, obj);
|
|
18941
|
+
eagerFiles.push(t);
|
|
18942
|
+
} else lazyBuildObjects.set(t, obj);
|
|
18756
18943
|
} else {
|
|
18757
18944
|
eagerFiles.push(t);
|
|
18758
18945
|
}
|
|
@@ -18760,7 +18947,7 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
|
|
|
18760
18947
|
lazyBuildObjects.set(t, parseWasmObjectFile(t, false));
|
|
18761
18948
|
}
|
|
18762
18949
|
} else if (!inStartLib && t.endsWith(".a") && !t.endsWith("libclang_rt.builtins-wasm64.a") && import_node_fs29.default.existsSync(t)) {
|
|
18763
|
-
const members2 =
|
|
18950
|
+
const members2 = readArchiveMembers(t);
|
|
18764
18951
|
for (const m of members2) {
|
|
18765
18952
|
const object8 = parseWasmObjectBytes(`${t}(${m.name})`, m.bytes, false);
|
|
18766
18953
|
extraArchiveObjs.push(object8);
|
|
@@ -18783,7 +18970,7 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
|
|
|
18783
18970
|
);
|
|
18784
18971
|
const archiveOverlapsDist = (archive) => {
|
|
18785
18972
|
if (!import_node_fs29.default.existsSync(archive)) return false;
|
|
18786
|
-
const members2 =
|
|
18973
|
+
const members2 = readArchiveMembers(archive);
|
|
18787
18974
|
return members2.some((m) => distBaseNames.has(m.name));
|
|
18788
18975
|
};
|
|
18789
18976
|
for (const t of tokens2) {
|
|
@@ -18805,7 +18992,7 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
|
|
|
18805
18992
|
import_node_path28.default.basename(archive)
|
|
18806
18993
|
);
|
|
18807
18994
|
const ordinals = /* @__PURE__ */ new Map();
|
|
18808
|
-
for (const m of
|
|
18995
|
+
for (const m of readArchiveMembers(archive)) {
|
|
18809
18996
|
const ordinal = (ordinals.get(m.name) ?? 0) + 1;
|
|
18810
18997
|
ordinals.set(m.name, ordinal);
|
|
18811
18998
|
if (distBaseNames.has(m.name) || writtenLeftovers.has(m.name)) continue;
|
|
@@ -18839,7 +19026,7 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
|
|
|
18839
19026
|
recordTransformation(
|
|
18840
19027
|
swiftrtOrigPath,
|
|
18841
19028
|
patchedSwiftrtPath,
|
|
18842
|
-
link ? (
|
|
19029
|
+
link ? sha256Hex(input) : "",
|
|
18843
19030
|
result,
|
|
18844
19031
|
"swiftrt"
|
|
18845
19032
|
);
|
|
@@ -19326,7 +19513,7 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
|
|
|
19326
19513
|
}
|
|
19327
19514
|
for (const f of eagerFiles) {
|
|
19328
19515
|
const isDist = f.startsWith(distDir);
|
|
19329
|
-
const obj = distObjs.get(f) ?? parseWasmObjectFile(f, isDist);
|
|
19516
|
+
const obj = distObjs.get(f) ?? parsedBuildObjects.get(f) ?? parseWasmObjectFile(f, isDist);
|
|
19330
19517
|
extractObject(obj);
|
|
19331
19518
|
if (isDist) {
|
|
19332
19519
|
const base2 = import_node_path28.default.basename(f);
|
|
@@ -19376,32 +19563,9 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
|
|
|
19376
19563
|
"$s10Foundation6BundleC22preferredLocalizations4fromSaySSGAF_tFZTf4nd_n"
|
|
19377
19564
|
]);
|
|
19378
19565
|
const keepObjCClassesNamedInSegment = (obj, segIdx) => {
|
|
19379
|
-
const
|
|
19380
|
-
if (!
|
|
19381
|
-
const
|
|
19382
|
-
if (rangeEnd - rangeStart < 4) return;
|
|
19383
|
-
let bytes = objectBytes.get(obj);
|
|
19384
|
-
if (!bytes) objectBytes.set(obj, bytes = import_node_fs29.default.readFileSync(obj.file));
|
|
19385
|
-
let pos = rangeStart;
|
|
19386
|
-
while (pos < rangeEnd - 3) {
|
|
19387
|
-
const at = bytes.indexOf("So", pos);
|
|
19388
|
-
if (at < 0 || at >= rangeEnd - 2) break;
|
|
19389
|
-
let digitEnd = at + 2;
|
|
19390
|
-
let length = 0;
|
|
19391
|
-
while (digitEnd < rangeEnd) {
|
|
19392
|
-
const ch = bytes[digitEnd];
|
|
19393
|
-
if (ch < 48 || ch > 57) break;
|
|
19394
|
-
length = length * 10 + (ch - 48);
|
|
19395
|
-
digitEnd++;
|
|
19396
|
-
}
|
|
19397
|
-
if (digitEnd === at + 2) {
|
|
19398
|
-
pos = at + 2;
|
|
19399
|
-
continue;
|
|
19400
|
-
}
|
|
19401
|
-
pos = digitEnd;
|
|
19402
|
-
const nameEnd = digitEnd + length;
|
|
19403
|
-
if (nameEnd >= rangeEnd || bytes[nameEnd] !== 67) continue;
|
|
19404
|
-
const symbol2 = `._OBJC_CLASS_${bytes.toString("latin1", digitEnd, nameEnd)}`;
|
|
19566
|
+
const symbols = obj.segObjCClasses.get(segIdx);
|
|
19567
|
+
if (!symbols) return;
|
|
19568
|
+
for (const symbol2 of symbols) {
|
|
19405
19569
|
for (const provider of lazyProviders.get(symbol2) ?? []) {
|
|
19406
19570
|
eagerDynamicObjects.add(provider);
|
|
19407
19571
|
extractObject(provider);
|
|
@@ -19497,7 +19661,7 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
|
|
|
19497
19661
|
const cached2 = objectBytes.get(obj);
|
|
19498
19662
|
const buf = cached2 ? new Uint8Array(cached2) : new Uint8Array(import_node_fs29.default.readFileSync(obj.file));
|
|
19499
19663
|
const rawBuf = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
19500
|
-
const inputSha256 = link ? (
|
|
19664
|
+
const inputSha256 = link ? sha256Hex(buf) : "";
|
|
19501
19665
|
const fLive = liveFuncs.get(obj);
|
|
19502
19666
|
const sLive = liveSegs.get(obj);
|
|
19503
19667
|
const dLive = liveDataSyms.get(obj);
|
|
@@ -21751,13 +21915,34 @@ function dropWasmCustomSection(bytes, name3) {
|
|
|
21751
21915
|
}
|
|
21752
21916
|
return Buffer.concat(parts);
|
|
21753
21917
|
}
|
|
21918
|
+
function writeWasmCustomSections(bytes, entries2) {
|
|
21919
|
+
if (entries2.length === 0) return Buffer.concat([bytes]);
|
|
21920
|
+
const replaced = new Set(entries2.map(([name3]) => name3));
|
|
21921
|
+
const parts = [];
|
|
21922
|
+
let sliceStart = 0;
|
|
21923
|
+
let sliceEnd = 8;
|
|
21924
|
+
for (const { id, start, end } of wasmSections2(bytes)) {
|
|
21925
|
+
if (id === 0 && replaced.has(readWasmSection(bytes, start, end).name())) {
|
|
21926
|
+
if (sliceEnd > sliceStart) parts.push(bytes.subarray(sliceStart, sliceEnd));
|
|
21927
|
+
sliceStart = end;
|
|
21928
|
+
sliceEnd = end;
|
|
21929
|
+
} else {
|
|
21930
|
+
sliceEnd = end;
|
|
21931
|
+
}
|
|
21932
|
+
}
|
|
21933
|
+
if (sliceEnd > sliceStart) parts.push(bytes.subarray(sliceStart, sliceEnd));
|
|
21934
|
+
for (const [name3, data] of entries2) {
|
|
21935
|
+
const nameBytes = Buffer.from(encodeWasmName(name3));
|
|
21936
|
+
parts.push(
|
|
21937
|
+
Buffer.from([0, ...encodeWasmNumber(nameBytes.length + data.length)]),
|
|
21938
|
+
nameBytes,
|
|
21939
|
+
data
|
|
21940
|
+
);
|
|
21941
|
+
}
|
|
21942
|
+
return Buffer.concat(parts);
|
|
21943
|
+
}
|
|
21754
21944
|
function writeWasmCustomSection(bytes, name3, data) {
|
|
21755
|
-
|
|
21756
|
-
return Buffer.concat([
|
|
21757
|
-
dropWasmCustomSection(bytes, name3),
|
|
21758
|
-
Buffer.from([0, ...encodeWasmNumber(section2.length)]),
|
|
21759
|
-
section2
|
|
21760
|
-
]);
|
|
21945
|
+
return writeWasmCustomSections(bytes, [[name3, data]]);
|
|
21761
21946
|
}
|
|
21762
21947
|
function readWasmMemory(bytes) {
|
|
21763
21948
|
return readWasmMemoryAndTableImports(bytes, wasmSections2(bytes)).memory;
|
|
@@ -22029,6 +22214,16 @@ var init_wasm_narrow_boundary = __esm({
|
|
|
22029
22214
|
});
|
|
22030
22215
|
|
|
22031
22216
|
// src/swift-guest-dyld-table.ts
|
|
22217
|
+
function sha256Buffer(bytes) {
|
|
22218
|
+
if (typeof Bun !== "undefined")
|
|
22219
|
+
return Buffer.from(new Bun.CryptoHasher("sha256").update(bytes).digest());
|
|
22220
|
+
return (0, import_node_crypto17.createHash)("sha256").update(bytes).digest();
|
|
22221
|
+
}
|
|
22222
|
+
function sha256Hex2(bytes) {
|
|
22223
|
+
if (typeof Bun !== "undefined")
|
|
22224
|
+
return new Bun.CryptoHasher("sha256").update(bytes).digest("hex");
|
|
22225
|
+
return (0, import_node_crypto17.createHash)("sha256").update(bytes).digest("hex");
|
|
22226
|
+
}
|
|
22032
22227
|
function uleb3(value) {
|
|
22033
22228
|
const bytes = [];
|
|
22034
22229
|
for (let rest = value; ; rest = Math.floor(rest / 128)) {
|
|
@@ -22063,7 +22258,7 @@ function encodeGuestDyldTable(rows) {
|
|
|
22063
22258
|
}
|
|
22064
22259
|
const file = Buffer.concat(packs);
|
|
22065
22260
|
const header = Buffer.alloc(40 + packs.length * 8);
|
|
22066
|
-
(
|
|
22261
|
+
sha256Buffer(file).copy(header, 0);
|
|
22067
22262
|
header.writeUInt32LE(file.length, 32);
|
|
22068
22263
|
header.writeUInt32LE(packs.length, 36);
|
|
22069
22264
|
let offset = 0;
|
|
@@ -22075,11 +22270,11 @@ function encodeGuestDyldTable(rows) {
|
|
|
22075
22270
|
const names = firsts.flatMap((name3) => [name3, Buffer.of(0)]);
|
|
22076
22271
|
return { index: Buffer.concat([header, ...names]), packs: file };
|
|
22077
22272
|
}
|
|
22078
|
-
function moveGuestDyldTable(map2, wasm, symbols, bindingValues = /* @__PURE__ */ new Map()) {
|
|
22273
|
+
function moveGuestDyldTable(map2, wasm, symbols, bindingValues = /* @__PURE__ */ new Map(), extraSections = []) {
|
|
22079
22274
|
const range3 = guestDyldValueRange(map2);
|
|
22080
22275
|
if (!range3) {
|
|
22081
22276
|
if (symbols.length) throw new Error("link map has no dyld values");
|
|
22082
|
-
return wasm;
|
|
22277
|
+
return extraSections.length ? writeWasmCustomSections(wasm, extraSections) : wasm;
|
|
22083
22278
|
}
|
|
22084
22279
|
if (range3.length !== symbols.length * 8)
|
|
22085
22280
|
throw new Error("linked dyld values do not match the ledger rows");
|
|
@@ -22094,11 +22289,11 @@ function moveGuestDyldTable(map2, wasm, symbols, bindingValues = /* @__PURE__ */
|
|
|
22094
22289
|
return binding === void 0 ? { name: name3, image, kind: 0, value: view.getBigUint64(index2 * 8, true) } : { name: name3, image, kind: 1, value: BigInt(binding) };
|
|
22095
22290
|
});
|
|
22096
22291
|
const { index, packs } = encodeGuestDyldTable(rows);
|
|
22097
|
-
return
|
|
22098
|
-
|
|
22099
|
-
NATIVE_DYLD_PACKS_SECTION,
|
|
22100
|
-
|
|
22101
|
-
);
|
|
22292
|
+
return writeWasmCustomSections(taken.wasm, [
|
|
22293
|
+
[NATIVE_DYLD_TABLE_SECTION, index],
|
|
22294
|
+
[NATIVE_DYLD_PACKS_SECTION, packs],
|
|
22295
|
+
...extraSections
|
|
22296
|
+
]);
|
|
22102
22297
|
}
|
|
22103
22298
|
function guestDyldValueRange(map2) {
|
|
22104
22299
|
const suffix = `:(${GUEST_DYLD_VALUES_SECTION})`;
|
|
@@ -22127,7 +22322,7 @@ function splitSwiftDyldTable(wasm) {
|
|
|
22127
22322
|
const bytes = Buffer.from(packs);
|
|
22128
22323
|
return {
|
|
22129
22324
|
module: dropWasmCustomSection(wasm, NATIVE_DYLD_PACKS_SECTION),
|
|
22130
|
-
table: { sha256: (
|
|
22325
|
+
table: { sha256: sha256Hex2(bytes), bytes }
|
|
22131
22326
|
};
|
|
22132
22327
|
}
|
|
22133
22328
|
var import_node_crypto17, import_node_zlib4, PACK_BYTES;
|
|
@@ -22663,6 +22858,7 @@ function finalizeGuestProjectionStorage(options2) {
|
|
|
22663
22858
|
const owner = options2.owners.get(options2.projectionObject);
|
|
22664
22859
|
if (owner === void 0) throw new Error("guest projection object has no image owner");
|
|
22665
22860
|
const ranges = [];
|
|
22861
|
+
const data = [];
|
|
22666
22862
|
const spans = guestLinkedSpans(
|
|
22667
22863
|
options2.map,
|
|
22668
22864
|
options2.linked,
|
|
@@ -22673,7 +22869,8 @@ function finalizeGuestProjectionStorage(options2) {
|
|
|
22673
22869
|
{
|
|
22674
22870
|
trackedObject: options2.projectionObject,
|
|
22675
22871
|
trackedObjectOwner: owner,
|
|
22676
|
-
trackedLinearSpans: ranges
|
|
22872
|
+
trackedLinearSpans: ranges,
|
|
22873
|
+
optimizedDataSegments: data
|
|
22677
22874
|
}
|
|
22678
22875
|
);
|
|
22679
22876
|
const images = planGuestProjectionRegions(
|
|
@@ -22682,7 +22879,6 @@ function finalizeGuestProjectionStorage(options2) {
|
|
|
22682
22879
|
options2.sdkSpans ? [...spans, ...options2.sdkSpans] : spans
|
|
22683
22880
|
);
|
|
22684
22881
|
const result = Buffer.from(options2.optimized);
|
|
22685
|
-
const data = guestWasmDataSegments(options2.optimized, options2.sdkSpans === void 0);
|
|
22686
22882
|
const locations = /* @__PURE__ */ new Map();
|
|
22687
22883
|
const counts = /* @__PURE__ */ new Map();
|
|
22688
22884
|
const uuids = /* @__PURE__ */ new Map();
|
|
@@ -23356,17 +23552,17 @@ var init_binaryen_lock = __esm({
|
|
|
23356
23552
|
"linux-x64": {
|
|
23357
23553
|
asset: "x86_64-linux",
|
|
23358
23554
|
upstreamSha256: "195ddc94f9bc89f45abdabb0b9eea86023d727ba90eac8b35b80f2544fc30572",
|
|
23359
|
-
sha256: "
|
|
23555
|
+
sha256: "40062fb1ebbad7f04f361c1e3bb309dffb1d2318dd2e12235a0e7e820e18d6c9"
|
|
23360
23556
|
},
|
|
23361
23557
|
"linux-arm64": {
|
|
23362
23558
|
asset: "aarch64-linux",
|
|
23363
23559
|
upstreamSha256: "c58562417836c5d0493d89bdefc434933bdc097db641b483df86bcfa557a107f",
|
|
23364
|
-
sha256: "
|
|
23560
|
+
sha256: "d79b09d5b66f62f9e4bb691517b174b42bcdc0b7f40769d1993b7c565b0a54c7"
|
|
23365
23561
|
},
|
|
23366
23562
|
"darwin-arm64": {
|
|
23367
23563
|
asset: "arm64-macos",
|
|
23368
23564
|
upstreamSha256: "98aad827847af7ef990ed7098d885725c8e5b5aae75073403635617ae4e259aa",
|
|
23369
|
-
sha256: "
|
|
23565
|
+
sha256: "29342632a4fa52466c4feea846698fe5aa56ff46226a914d60b65b8735373d63"
|
|
23370
23566
|
}
|
|
23371
23567
|
}
|
|
23372
23568
|
};
|
|
@@ -23860,6 +24056,7 @@ function outputPath(args) {
|
|
|
23860
24056
|
}
|
|
23861
24057
|
function withOutput(args, output, discovery) {
|
|
23862
24058
|
const result = [];
|
|
24059
|
+
let stripsDebug = false;
|
|
23863
24060
|
for (let i = 0; i < args.length; i++) {
|
|
23864
24061
|
const arg = args[i];
|
|
23865
24062
|
if (arg === "-o" || arg === "--output") {
|
|
@@ -23869,9 +24066,12 @@ function withOutput(args, output, discovery) {
|
|
|
23869
24066
|
if (arg.startsWith("--output=")) continue;
|
|
23870
24067
|
if (discovery && (arg.startsWith("--why-extract=") || arg.startsWith("--Map=")))
|
|
23871
24068
|
continue;
|
|
24069
|
+
if (arg === "--strip-debug" || arg === "-S" || arg === "--strip-all" || arg === "-s")
|
|
24070
|
+
stripsDebug = true;
|
|
23872
24071
|
result.push(arg);
|
|
23873
24072
|
}
|
|
23874
24073
|
if (discovery) result.push("--allow-multiple-definition");
|
|
24074
|
+
if (!stripsDebug) result.push("--strip-debug");
|
|
23875
24075
|
result.push("-o", output);
|
|
23876
24076
|
return result;
|
|
23877
24077
|
}
|
|
@@ -23902,6 +24102,37 @@ async function linkGuestImages(options2) {
|
|
|
23902
24102
|
}
|
|
23903
24103
|
return import_node_fs34.default.readFileSync(trace, "utf8");
|
|
23904
24104
|
};
|
|
24105
|
+
const runLinkAsync = async (name3, arguments_) => {
|
|
24106
|
+
const response = import_node_path32.default.join(directory2, `${name3}.rsp`);
|
|
24107
|
+
const trace = import_node_path32.default.join(directory2, `${name3}-inputs.txt`);
|
|
24108
|
+
import_node_fs34.default.writeFileSync(
|
|
24109
|
+
response,
|
|
24110
|
+
[...arguments_, "--trace"].map((argument2) => JSON.stringify(argument2)).join(" ")
|
|
24111
|
+
);
|
|
24112
|
+
const output = import_node_fs34.default.openSync(trace, "w");
|
|
24113
|
+
try {
|
|
24114
|
+
await new Promise((resolve4, reject) => {
|
|
24115
|
+
const child = (0, import_node_child_process19.spawn)(wasmLd, [`@${response}`], {
|
|
24116
|
+
stdio: ["ignore", output, "pipe"]
|
|
24117
|
+
});
|
|
24118
|
+
const stderr = [];
|
|
24119
|
+
child.stderr?.on("data", (chunk) => stderr.push(chunk));
|
|
24120
|
+
child.once("error", reject);
|
|
24121
|
+
child.once("close", (code, signal) => {
|
|
24122
|
+
if (code === 0) resolve4();
|
|
24123
|
+
else
|
|
24124
|
+
reject(
|
|
24125
|
+
new Error(
|
|
24126
|
+
`wasm-ld (${name3}) failed (${signal ?? code}): ${Buffer.concat(stderr).toString("utf8")}`
|
|
24127
|
+
)
|
|
24128
|
+
);
|
|
24129
|
+
});
|
|
24130
|
+
});
|
|
24131
|
+
} finally {
|
|
24132
|
+
import_node_fs34.default.closeSync(output);
|
|
24133
|
+
}
|
|
24134
|
+
return import_node_fs34.default.readFileSync(trace, "utf8");
|
|
24135
|
+
};
|
|
23905
24136
|
const preselection = options2.projection && options2.preselectionDiscovery ? options2.preselectionDiscovery : void 0;
|
|
23906
24137
|
let discoveryProjection;
|
|
23907
24138
|
if (options2.projection) {
|
|
@@ -24131,6 +24362,7 @@ async function linkGuestImages(options2) {
|
|
|
24131
24362
|
};
|
|
24132
24363
|
const ledgerObjectPromise = compileLedgerAsync("ledger", ledger.llvmIR);
|
|
24133
24364
|
const appLedgerObjectPromise = options2.onSplitInputs && ledger.appLLVMIR ? compileLedgerAsync("app-ledger", ledger.appLLVMIR) : void 0;
|
|
24365
|
+
let deferredFinalLink;
|
|
24134
24366
|
try {
|
|
24135
24367
|
const replacements = /* @__PURE__ */ new Map();
|
|
24136
24368
|
const linkedOwners = /* @__PURE__ */ new Map();
|
|
@@ -24232,7 +24464,7 @@ async function linkGuestImages(options2) {
|
|
|
24232
24464
|
});
|
|
24233
24465
|
const finalOutput = import_node_path32.default.join(directory2, "final.wasm");
|
|
24234
24466
|
const finalWhy = import_node_path32.default.join(directory2, "final-why-extract.txt");
|
|
24235
|
-
const
|
|
24467
|
+
const finalLinkArgs = (projectionObject2, layoutMap) => [
|
|
24236
24468
|
...withOutput(finalArgs, finalOutput, false),
|
|
24237
24469
|
ledgerObject,
|
|
24238
24470
|
`@${lazyExports}`,
|
|
@@ -24240,10 +24472,38 @@ async function linkGuestImages(options2) {
|
|
|
24240
24472
|
...provider ? [`--undefined=${providerSymbol}`] : [],
|
|
24241
24473
|
...layoutMap ? [`--Map=${layoutMap}`] : [],
|
|
24242
24474
|
`--why-extract=${finalWhy}`
|
|
24243
|
-
]
|
|
24475
|
+
];
|
|
24476
|
+
const linkFinal = (projectionObject2, layoutMap) => runLink("final", finalLinkArgs(projectionObject2, layoutMap));
|
|
24477
|
+
const finalizeFinalLink = (trace) => {
|
|
24478
|
+
const finalSelection = selectedGuestLinkInputs(
|
|
24479
|
+
remapGuestLinkPlan(plan, replacements),
|
|
24480
|
+
finalArgs,
|
|
24481
|
+
import_node_fs34.default.readFileSync(finalWhy, "utf8"),
|
|
24482
|
+
trace,
|
|
24483
|
+
finalArchives
|
|
24484
|
+
);
|
|
24485
|
+
const original = new Map(
|
|
24486
|
+
[...replacements].map(([before2, after2]) => [after2, before2])
|
|
24487
|
+
);
|
|
24488
|
+
const key2 = (item) => JSON.stringify([original.get(item.artifact) ?? item.artifact, item.member]);
|
|
24489
|
+
const before = new Set(selected.map(key2));
|
|
24490
|
+
const after = new Set(finalSelection.map(key2));
|
|
24491
|
+
const changed = [...before].filter((item) => !after.has(item));
|
|
24492
|
+
changed.push(...[...after].filter((item) => !before.has(item)));
|
|
24493
|
+
if (changed.length)
|
|
24494
|
+
throw new Error(
|
|
24495
|
+
`guest link selected different inputs after rewriting:
|
|
24496
|
+
${changed.join("\n")}`
|
|
24497
|
+
);
|
|
24498
|
+
import_node_fs34.default.renameSync(finalOutput, outputPath(args));
|
|
24499
|
+
if (KEEP_WASM_NAMES)
|
|
24500
|
+
import_node_fs34.default.writeFileSync(
|
|
24501
|
+
outputPath(args),
|
|
24502
|
+
nameGuestImageAliases(import_node_fs34.default.readFileSync(outputPath(args)), plan.symbols)
|
|
24503
|
+
);
|
|
24504
|
+
};
|
|
24244
24505
|
let projectionObject;
|
|
24245
24506
|
let projectionStorage;
|
|
24246
|
-
let finalTrace;
|
|
24247
24507
|
if (options2.projection) {
|
|
24248
24508
|
const projection = options2.projection;
|
|
24249
24509
|
if (!plan.images.some((image) => image.id === projection.image))
|
|
@@ -24296,8 +24556,18 @@ async function linkGuestImages(options2) {
|
|
|
24296
24556
|
[...projection.clangOptions, "-c", projectionSource, "-o", projectionObject],
|
|
24297
24557
|
{ stdio: "pipe" }
|
|
24298
24558
|
);
|
|
24299
|
-
|
|
24300
|
-
|
|
24559
|
+
if (sharedSdk && options2.onFinalLink && options2.onSplitInputs && appLedgerObjectPromise) {
|
|
24560
|
+
deferredFinalLink = runLinkAsync(
|
|
24561
|
+
"final",
|
|
24562
|
+
finalLinkArgs(projectionObject, callerMap ? void 0 : layoutMap)
|
|
24563
|
+
).then((trace) => finalizeFinalLink(trace));
|
|
24564
|
+
break;
|
|
24565
|
+
}
|
|
24566
|
+
const finalTrace = linkFinal(projectionObject, callerMap ? void 0 : layoutMap);
|
|
24567
|
+
if (sharedSdk) {
|
|
24568
|
+
finalizeFinalLink(finalTrace);
|
|
24569
|
+
break;
|
|
24570
|
+
}
|
|
24301
24571
|
const wasm = import_node_fs34.default.readFileSync(finalOutput);
|
|
24302
24572
|
const actual = guestProjectionRegionCounts(
|
|
24303
24573
|
images.length,
|
|
@@ -24309,38 +24579,17 @@ async function linkGuestImages(options2) {
|
|
|
24309
24579
|
sectionOwners
|
|
24310
24580
|
)
|
|
24311
24581
|
);
|
|
24312
|
-
if (actual.every((count, index) => count <= capacities[index].regions))
|
|
24582
|
+
if (actual.every((count, index) => count <= capacities[index].regions)) {
|
|
24583
|
+
finalizeFinalLink(finalTrace);
|
|
24584
|
+
break;
|
|
24585
|
+
}
|
|
24313
24586
|
capacities = capacities.map((capacity, index) => ({
|
|
24314
24587
|
...capacity,
|
|
24315
24588
|
regions: Math.max(actual[index], capacity.regions)
|
|
24316
24589
|
}));
|
|
24317
24590
|
}
|
|
24318
24591
|
linkedOwners.set(projectionObject, projection.image);
|
|
24319
|
-
} else
|
|
24320
|
-
const finalSelection = selectedGuestLinkInputs(
|
|
24321
|
-
remapGuestLinkPlan(plan, replacements),
|
|
24322
|
-
finalArgs,
|
|
24323
|
-
import_node_fs34.default.readFileSync(finalWhy, "utf8"),
|
|
24324
|
-
finalTrace,
|
|
24325
|
-
finalArchives
|
|
24326
|
-
);
|
|
24327
|
-
const original = new Map([...replacements].map(([before2, after2]) => [after2, before2]));
|
|
24328
|
-
const key2 = (item) => JSON.stringify([original.get(item.artifact) ?? item.artifact, item.member]);
|
|
24329
|
-
const before = new Set(selected.map(key2));
|
|
24330
|
-
const after = new Set(finalSelection.map(key2));
|
|
24331
|
-
const changed = [...before].filter((item) => !after.has(item));
|
|
24332
|
-
changed.push(...[...after].filter((item) => !before.has(item)));
|
|
24333
|
-
if (changed.length)
|
|
24334
|
-
throw new Error(
|
|
24335
|
-
`guest link selected different inputs after rewriting:
|
|
24336
|
-
${changed.join("\n")}`
|
|
24337
|
-
);
|
|
24338
|
-
import_node_fs34.default.renameSync(finalOutput, outputPath(args));
|
|
24339
|
-
if (KEEP_WASM_NAMES)
|
|
24340
|
-
import_node_fs34.default.writeFileSync(
|
|
24341
|
-
outputPath(args),
|
|
24342
|
-
nameGuestImageAliases(import_node_fs34.default.readFileSync(outputPath(args)), plan.symbols)
|
|
24343
|
-
);
|
|
24592
|
+
} else finalizeFinalLink(linkFinal());
|
|
24344
24593
|
if (projectionStorage && projectionObject)
|
|
24345
24594
|
options2.projection.onReserved(projectionStorage, projectionObject);
|
|
24346
24595
|
options2.onLinkedOwners?.(linkedOwners);
|
|
@@ -24376,11 +24625,13 @@ ${changed.join("\n")}`
|
|
|
24376
24625
|
appDefinedSymbols
|
|
24377
24626
|
});
|
|
24378
24627
|
}
|
|
24628
|
+
if (deferredFinalLink) options2.onFinalLink?.(deferredFinalLink);
|
|
24379
24629
|
return selected;
|
|
24380
24630
|
} catch (error) {
|
|
24381
24631
|
await Promise.allSettled([
|
|
24382
24632
|
ledgerObjectPromise,
|
|
24383
|
-
...appLedgerObjectPromise ? [appLedgerObjectPromise] : []
|
|
24633
|
+
...appLedgerObjectPromise ? [appLedgerObjectPromise] : [],
|
|
24634
|
+
...deferredFinalLink ? [deferredFinalLink] : []
|
|
24384
24635
|
]);
|
|
24385
24636
|
throw error;
|
|
24386
24637
|
}
|
|
@@ -25012,6 +25263,7 @@ async function linkPrunedGuestImages(options2) {
|
|
|
25012
25263
|
identities: aliasGuestLinkIdentities(identities, prepared.archives)
|
|
25013
25264
|
};
|
|
25014
25265
|
}
|
|
25266
|
+
let finalLinkDone;
|
|
25015
25267
|
const selected = await linkCompleteGuestImages({
|
|
25016
25268
|
plan,
|
|
25017
25269
|
args: [...linkedArgs, `--Map=${options2.mapPath}`],
|
|
@@ -25025,6 +25277,9 @@ async function linkPrunedGuestImages(options2) {
|
|
|
25025
25277
|
resolvePlan: options2.resolvePlan,
|
|
25026
25278
|
sharedSdk: options2.sharedSdk,
|
|
25027
25279
|
onSplitInputs: options2.onSplitInputs,
|
|
25280
|
+
onFinalLink: options2.deferFinalLink ? (done) => {
|
|
25281
|
+
finalLinkDone = done;
|
|
25282
|
+
} : void 0,
|
|
25028
25283
|
onDyldRows: options2.onDyldRows,
|
|
25029
25284
|
onLinkedOwners: (value) => {
|
|
25030
25285
|
owners = value;
|
|
@@ -25038,7 +25293,8 @@ async function linkPrunedGuestImages(options2) {
|
|
|
25038
25293
|
owners,
|
|
25039
25294
|
generatedSectionOwners,
|
|
25040
25295
|
sdk: sdk2,
|
|
25041
|
-
mapPath: options2.mapPath
|
|
25296
|
+
mapPath: options2.mapPath,
|
|
25297
|
+
finalLinkDone
|
|
25042
25298
|
};
|
|
25043
25299
|
}
|
|
25044
25300
|
var import_node_child_process19, import_node_fs34, import_node_path32, import_node_util4, execFileAsync, WASM_MAGIC, BITCODE_MAGIC;
|
|
@@ -25116,8 +25372,13 @@ function clangBinaryStamp(file) {
|
|
|
25116
25372
|
const stat = (0, import_node_fs35.statSync)(file, { bigint: true });
|
|
25117
25373
|
return [file, stat.size, stat.mtimeNs].join(":");
|
|
25118
25374
|
}
|
|
25375
|
+
function sha256Hex3(bytes) {
|
|
25376
|
+
if (typeof Bun !== "undefined")
|
|
25377
|
+
return new Bun.CryptoHasher("sha256").update(bytes).digest("hex");
|
|
25378
|
+
return (0, import_node_crypto21.createHash)("sha256").update(bytes).digest("hex");
|
|
25379
|
+
}
|
|
25119
25380
|
function clangWrapperStamp(file) {
|
|
25120
|
-
return (
|
|
25381
|
+
return sha256Hex3((0, import_node_fs35.readFileSync)(file));
|
|
25121
25382
|
}
|
|
25122
25383
|
function clangArgsNeedCwd(args) {
|
|
25123
25384
|
const pathFlags = /* @__PURE__ */ new Set([
|
|
@@ -25267,22 +25528,35 @@ function sourceGuestClangLinkOptions(options2) {
|
|
|
25267
25528
|
"SOURCE_DATE_EPOCH"
|
|
25268
25529
|
].map((name3) => process.env[name3] ?? "");
|
|
25269
25530
|
const replays = [];
|
|
25531
|
+
const realPathCache = /* @__PURE__ */ new Map();
|
|
25532
|
+
const cachedRealpath = (file) => {
|
|
25533
|
+
let resolved = realPathCache.get(file);
|
|
25534
|
+
if (resolved === void 0) {
|
|
25535
|
+
resolved = (0, import_node_fs35.realpathSync)(file);
|
|
25536
|
+
realPathCache.set(file, resolved);
|
|
25537
|
+
}
|
|
25538
|
+
return resolved;
|
|
25539
|
+
};
|
|
25540
|
+
const resolvedSwiftCompiler = cachedRealpath(options2.swiftCompiler);
|
|
25270
25541
|
let clang;
|
|
25542
|
+
let clangWrapper;
|
|
25271
25543
|
let clangStamp;
|
|
25272
25544
|
let wrapperStamp;
|
|
25273
25545
|
for (const file of wanted) {
|
|
25274
25546
|
const command = commands.get(file);
|
|
25275
25547
|
if (!command) throw new Error(`missing source object producer ${file}`);
|
|
25276
25548
|
if (command.tool === "shell") {
|
|
25277
|
-
if (!command.args.length || (
|
|
25549
|
+
if (!command.args.length || cachedRealpath(command.args[0]) !== resolvedSwiftCompiler)
|
|
25278
25550
|
throw new Error(`unsupported source object producer ${file}`);
|
|
25279
25551
|
continue;
|
|
25280
25552
|
}
|
|
25281
|
-
const compiler = command.args[0] ? (
|
|
25282
|
-
clang ??= (
|
|
25283
|
-
if (command.tool !== "clang" || compiler !== clang && compiler !== (
|
|
25553
|
+
const compiler = command.args[0] ? cachedRealpath(command.args[0]) : "";
|
|
25554
|
+
clang ??= cachedRealpath(import_node_path33.default.join(options2.toolchainBin, "clang"));
|
|
25555
|
+
if (command.tool !== "clang" || compiler !== clang && compiler !== (clangWrapper ??= cachedRealpath(
|
|
25556
|
+
import_node_path33.default.join(options2.buildDirectory, CLANG_TARGET_MODULE_WRAPPER)
|
|
25557
|
+
)))
|
|
25284
25558
|
throw new Error(`unsupported source object producer ${file}`);
|
|
25285
|
-
const key2 = (
|
|
25559
|
+
const key2 = sha256Hex3(
|
|
25286
25560
|
JSON.stringify([
|
|
25287
25561
|
"clang-link-options/v2",
|
|
25288
25562
|
clangArgsNeedCwd(command.args) ? process.cwd() : null,
|
|
@@ -25292,11 +25566,8 @@ function sourceGuestClangLinkOptions(options2) {
|
|
|
25292
25566
|
compiler === clang ? null : wrapperStamp ??= clangWrapperStamp(compiler),
|
|
25293
25567
|
clangProducerStamp(file)
|
|
25294
25568
|
])
|
|
25295
|
-
).digest("hex");
|
|
25296
|
-
const cacheFile = import_node_path33.default.join(
|
|
25297
|
-
cacheDirectory,
|
|
25298
|
-
(0, import_node_crypto21.createHash)("sha256").update(file).digest("hex") + ".json"
|
|
25299
25569
|
);
|
|
25570
|
+
const cacheFile = import_node_path33.default.join(cacheDirectory, sha256Hex3(file) + ".json");
|
|
25300
25571
|
const cached2 = readClangLinkOptions(cacheFile, key2);
|
|
25301
25572
|
if (cached2) {
|
|
25302
25573
|
validateClangLinkOptions(cached2);
|
|
@@ -27519,7 +27790,7 @@ function headerClosure(roots) {
|
|
|
27519
27790
|
).filter((file) => !file.endsWith(`/${j.exclude}`));
|
|
27520
27791
|
const nitroFiles = roots.nitroModules ? headerFiles2(roots.nitroModules, n.from, n.skip, new RegExp(n.keep)) : [];
|
|
27521
27792
|
const hashes = (base2, files2) => Object.fromEntries(
|
|
27522
|
-
files2.map((file) => [file,
|
|
27793
|
+
files2.map((file) => [file, sha256Hex4((0, import_node_fs39.readFileSync)(import_node_path37.default.join(base2, file)))])
|
|
27523
27794
|
);
|
|
27524
27795
|
return {
|
|
27525
27796
|
jsi: hashes(roots.reactNative, jsiFiles),
|
|
@@ -27683,11 +27954,11 @@ function verifyInstalledAdapter(family, directory2, pin2) {
|
|
|
27683
27954
|
if (JSON.stringify(recorded) !== JSON.stringify(pinned))
|
|
27684
27955
|
throw new Error(`${label} manifest does not match the lock this build carries`);
|
|
27685
27956
|
const bytes = (0, import_node_fs39.readFileSync)(import_node_path37.default.join(directory2, archive.path));
|
|
27686
|
-
if (bytes.length !== archive.size ||
|
|
27957
|
+
if (bytes.length !== archive.size || sha256Hex4(bytes) !== archive.sha256)
|
|
27687
27958
|
throw new Error(`${label} library does not match its manifest`);
|
|
27688
27959
|
return manifest;
|
|
27689
27960
|
}
|
|
27690
|
-
var import_node_crypto23, import_node_fs39, import_node_path37, ADAPTER_MANIFEST, ADAPTER_FAMILIES, TURBO_RUNTIME_HEADER, HEADER_STAGE,
|
|
27961
|
+
var import_node_crypto23, import_node_fs39, import_node_path37, ADAPTER_MANIFEST, ADAPTER_FAMILIES, TURBO_RUNTIME_HEADER, HEADER_STAGE, sha256Hex4, hex64, sameHeaders;
|
|
27691
27962
|
var init_nitroAdapterContract = __esm({
|
|
27692
27963
|
"src/nitroAdapterContract.ts"() {
|
|
27693
27964
|
"use strict";
|
|
@@ -27737,7 +28008,7 @@ void scheduleDrain();
|
|
|
27737
28008
|
to: ["core", "core/NitroModules"]
|
|
27738
28009
|
}
|
|
27739
28010
|
};
|
|
27740
|
-
|
|
28011
|
+
sha256Hex4 = (data) => (0, import_node_crypto23.createHash)("sha256").update(data).digest("hex");
|
|
27741
28012
|
hex64 = (value) => typeof value === "string" && /^[a-f0-9]{64}$/.test(value);
|
|
27742
28013
|
sameHeaders = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
27743
28014
|
}
|
|
@@ -31199,6 +31470,7 @@ async function linkSwiftSdkImage(moduleRoot, key2, directory2, work, scopedLooku
|
|
|
31199
31470
|
].map((name3) => `--export=${name3}`),
|
|
31200
31471
|
`@${import_node_path43.default.join(work, "exports.rsp")}`,
|
|
31201
31472
|
"--gc-sections",
|
|
31473
|
+
"--strip-debug",
|
|
31202
31474
|
// strings stay with their objects, so an app loads only the ones its pieces reference
|
|
31203
31475
|
"-O0"
|
|
31204
31476
|
];
|
|
@@ -31259,7 +31531,7 @@ async function linkSwiftSdkImage(moduleRoot, key2, directory2, work, scopedLooku
|
|
|
31259
31531
|
(0, import_node_fs45.writeFileSync)(import_node_path43.default.join(work, INTERFACE_FILE), JSON.stringify(sdkInterface));
|
|
31260
31532
|
(0, import_node_fs45.writeFileSync)(
|
|
31261
31533
|
import_node_path43.default.join(work, IMAGE_DIGEST),
|
|
31262
|
-
(0, import_node_crypto28.createHash)("sha256").update(image).digest("hex")
|
|
31534
|
+
typeof Bun !== "undefined" ? new Bun.CryptoHasher("sha256").update(image).digest("hex") : (0, import_node_crypto28.createHash)("sha256").update(image).digest("hex")
|
|
31263
31535
|
);
|
|
31264
31536
|
if (swiftSdkImageKey(
|
|
31265
31537
|
moduleRoot,
|
|
@@ -31699,6 +31971,7 @@ __export(swift_sdk_app_module_exports, {
|
|
|
31699
31971
|
readSwiftSdkUsage: () => readSwiftSdkUsage,
|
|
31700
31972
|
selectSwiftSdkData: () => selectSwiftSdkData,
|
|
31701
31973
|
swiftAppModuleInputs: () => swiftAppModuleInputs,
|
|
31974
|
+
swiftAppModuleThunkSection: () => swiftAppModuleThunkSection,
|
|
31702
31975
|
swiftSdkProjectionSpans: () => swiftSdkProjectionSpans,
|
|
31703
31976
|
writeSwiftSdkAppLink: () => writeSwiftSdkAppLink
|
|
31704
31977
|
});
|
|
@@ -31750,9 +32023,12 @@ async function buildSwiftAppModule(options2) {
|
|
|
31750
32023
|
linkage: link.linkage,
|
|
31751
32024
|
usage
|
|
31752
32025
|
});
|
|
31753
|
-
(
|
|
32026
|
+
finishSwiftAppModuleFile(options2.output);
|
|
31754
32027
|
return binding;
|
|
31755
32028
|
}
|
|
32029
|
+
function swiftAppModuleThunkSection(lowered) {
|
|
32030
|
+
return [NATIVE_SDK_THUNK_SECTION, sdkImportThunks(lowered)];
|
|
32031
|
+
}
|
|
31756
32032
|
function finishSwiftAppModule(lowered) {
|
|
31757
32033
|
return writeWasmCustomSection(
|
|
31758
32034
|
lowered,
|
|
@@ -31760,6 +32036,73 @@ function finishSwiftAppModule(lowered) {
|
|
|
31760
32036
|
sdkImportThunks(lowered)
|
|
31761
32037
|
);
|
|
31762
32038
|
}
|
|
32039
|
+
function finishSwiftAppModuleFile(file) {
|
|
32040
|
+
const fd = (0, import_node_fs46.openSync)(file, "r");
|
|
32041
|
+
let prefixEnd = 8;
|
|
32042
|
+
let hasExistingThunk = false;
|
|
32043
|
+
let prefix;
|
|
32044
|
+
try {
|
|
32045
|
+
const total = (0, import_node_fs46.fstatSync)(fd).size;
|
|
32046
|
+
const probe = Buffer.allocUnsafe(16);
|
|
32047
|
+
let offset = 8;
|
|
32048
|
+
while (offset < total) {
|
|
32049
|
+
const read = (0, import_node_fs46.readSync)(fd, probe, 0, Math.min(16, total - offset), offset);
|
|
32050
|
+
if (read < 2) break;
|
|
32051
|
+
const id = probe[0];
|
|
32052
|
+
let size2 = 0;
|
|
32053
|
+
let shift = 0;
|
|
32054
|
+
let at = 1;
|
|
32055
|
+
for (; ; ) {
|
|
32056
|
+
const byte = probe[at++];
|
|
32057
|
+
size2 += (byte & 127) * 2 ** shift;
|
|
32058
|
+
if (!(byte & 128)) break;
|
|
32059
|
+
shift += 7;
|
|
32060
|
+
}
|
|
32061
|
+
const start = offset + at;
|
|
32062
|
+
const next = start + size2;
|
|
32063
|
+
if (id === 1 || id === 2) prefixEnd = next;
|
|
32064
|
+
else if (id === 0) {
|
|
32065
|
+
const nameBuf = Buffer.allocUnsafe(Math.min(128, size2));
|
|
32066
|
+
const nRead = (0, import_node_fs46.readSync)(fd, nameBuf, 0, nameBuf.length, start);
|
|
32067
|
+
let nLen = 0;
|
|
32068
|
+
let nShift = 0;
|
|
32069
|
+
let nAt = 0;
|
|
32070
|
+
for (; ; ) {
|
|
32071
|
+
if (nAt >= nRead) break;
|
|
32072
|
+
const byte = nameBuf[nAt++];
|
|
32073
|
+
nLen += (byte & 127) * 2 ** nShift;
|
|
32074
|
+
if (!(byte & 128)) break;
|
|
32075
|
+
nShift += 7;
|
|
32076
|
+
}
|
|
32077
|
+
if (nAt + nLen <= nRead && nameBuf.toString("utf8", nAt, nAt + nLen) === NATIVE_SDK_THUNK_SECTION) {
|
|
32078
|
+
hasExistingThunk = true;
|
|
32079
|
+
break;
|
|
32080
|
+
}
|
|
32081
|
+
}
|
|
32082
|
+
offset = next;
|
|
32083
|
+
}
|
|
32084
|
+
if (!hasExistingThunk) {
|
|
32085
|
+
prefix = Buffer.allocUnsafe(prefixEnd);
|
|
32086
|
+
let filled = 0;
|
|
32087
|
+
while (filled < prefixEnd) {
|
|
32088
|
+
const n = (0, import_node_fs46.readSync)(fd, prefix, filled, prefixEnd - filled, filled);
|
|
32089
|
+
if (n <= 0) break;
|
|
32090
|
+
filled += n;
|
|
32091
|
+
}
|
|
32092
|
+
prefix = prefix.subarray(0, filled);
|
|
32093
|
+
}
|
|
32094
|
+
} finally {
|
|
32095
|
+
(0, import_node_fs46.closeSync)(fd);
|
|
32096
|
+
}
|
|
32097
|
+
if (hasExistingThunk || !prefix) {
|
|
32098
|
+
(0, import_node_fs46.writeFileSync)(file, finishSwiftAppModule((0, import_node_fs46.readFileSync)(file)));
|
|
32099
|
+
return;
|
|
32100
|
+
}
|
|
32101
|
+
const thunks = sdkImportThunks(prefix);
|
|
32102
|
+
const nameBytes = Buffer.from(encodedName2(NATIVE_SDK_THUNK_SECTION));
|
|
32103
|
+
const header = Buffer.from([0, ...uleb4(nameBytes.length + thunks.length)]);
|
|
32104
|
+
(0, import_node_fs46.appendFileSync)(file, Buffer.concat([header, nameBytes, thunks]));
|
|
32105
|
+
}
|
|
31763
32106
|
function swiftAppModuleInputs(tokens2, buildRoot, sdkLibraries) {
|
|
31764
32107
|
const owned = (token) => import_node_path44.default.resolve(token).startsWith(`${buildRoot}/`) && (!token.includes("/.peach-pruned-objs/") || token.endsWith("/swiftrt-patched.o"));
|
|
31765
32108
|
const inputs2 = [];
|
|
@@ -31974,6 +32317,7 @@ async function linkSwiftAppModule(options2) {
|
|
|
31974
32317
|
"--unresolved-symbols=ignore-all",
|
|
31975
32318
|
"--import-undefined",
|
|
31976
32319
|
"--emit-relocs",
|
|
32320
|
+
"--strip-debug",
|
|
31977
32321
|
"--gc-sections",
|
|
31978
32322
|
"--keep-section=target_features",
|
|
31979
32323
|
"--error-limit=0",
|
|
@@ -31996,7 +32340,16 @@ async function linkSwiftAppModule(options2) {
|
|
|
31996
32340
|
const skipPasses = options2.layoutMap ? ["duplicate-function-elimination"] : void 0;
|
|
31997
32341
|
const sdkTableEnd = sdk2.sdkInterface.layout.tableEnd;
|
|
31998
32342
|
const { loweringCache } = options2;
|
|
31999
|
-
const loweringKey = loweringCache && (
|
|
32343
|
+
const loweringKey = loweringCache && (typeof Bun !== "undefined" ? new Bun.CryptoHasher("sha256").update(
|
|
32344
|
+
JSON.stringify([
|
|
32345
|
+
loweringCache.compilerDigest,
|
|
32346
|
+
optimize,
|
|
32347
|
+
skipPasses,
|
|
32348
|
+
sdkTableEnd,
|
|
32349
|
+
lazy,
|
|
32350
|
+
KEEP_WASM_NAMES
|
|
32351
|
+
])
|
|
32352
|
+
).update(bytes).digest("hex") : (0, import_node_crypto29.createHash)("sha256").update(
|
|
32000
32353
|
JSON.stringify([
|
|
32001
32354
|
loweringCache.compilerDigest,
|
|
32002
32355
|
optimize,
|
|
@@ -32005,7 +32358,7 @@ async function linkSwiftAppModule(options2) {
|
|
|
32005
32358
|
lazy,
|
|
32006
32359
|
KEEP_WASM_NAMES
|
|
32007
32360
|
])
|
|
32008
|
-
).update(bytes).digest("hex");
|
|
32361
|
+
).update(bytes).digest("hex"));
|
|
32009
32362
|
return {
|
|
32010
32363
|
linkage,
|
|
32011
32364
|
async lower() {
|
|
@@ -32615,7 +32968,8 @@ function createSwiftSdkBinding(linkage, sdk2, usage, projection) {
|
|
|
32615
32968
|
bindSwiftAppModule(linkage, sdk2),
|
|
32616
32969
|
selectSwiftSdkData(sdk2, usage, linkage, projection)
|
|
32617
32970
|
]);
|
|
32618
|
-
|
|
32971
|
+
const sha2565 = typeof Bun !== "undefined" ? new Bun.CryptoHasher("sha256").update(bytes).digest("hex") : (0, import_node_crypto29.createHash)("sha256").update(bytes).digest("hex");
|
|
32972
|
+
return { bytes, sha256: sha2565 };
|
|
32619
32973
|
}
|
|
32620
32974
|
function readSwiftSdkUsage(mapFile, linkedFile, sdkObjects) {
|
|
32621
32975
|
const map2 = readWasmLinkMap(mapFile, false);
|
|
@@ -33371,6 +33725,7 @@ async function compileGuestLink(options2) {
|
|
|
33371
33725
|
onSplitInputs: sdk2 ? (value) => {
|
|
33372
33726
|
splitInputs = value;
|
|
33373
33727
|
} : void 0,
|
|
33728
|
+
deferFinalLink: Boolean(sdk2),
|
|
33374
33729
|
onDyldRows: (rows) => {
|
|
33375
33730
|
lazyFunctions = rows.lazyFunctions;
|
|
33376
33731
|
dyldSymbols = rows.dyldSymbols;
|
|
@@ -33639,156 +33994,164 @@ async function compileGuestLink(options2) {
|
|
|
33639
33994
|
});
|
|
33640
33995
|
if (!reserved2 || !projectionObject) throw new Error("guest projection was not reserved");
|
|
33641
33996
|
if (sdk2) {
|
|
33642
|
-
|
|
33643
|
-
|
|
33644
|
-
|
|
33645
|
-
|
|
33646
|
-
|
|
33647
|
-
|
|
33648
|
-
|
|
33649
|
-
|
|
33650
|
-
|
|
33651
|
-
|
|
33652
|
-
|
|
33653
|
-
|
|
33654
|
-
|
|
33655
|
-
|
|
33656
|
-
|
|
33657
|
-
|
|
33658
|
-
|
|
33659
|
-
|
|
33660
|
-
const
|
|
33661
|
-
|
|
33662
|
-
|
|
33663
|
-
|
|
33664
|
-
|
|
33665
|
-
|
|
33666
|
-
|
|
33667
|
-
|
|
33668
|
-
|
|
33669
|
-
|
|
33670
|
-
|
|
33671
|
-
|
|
33672
|
-
|
|
33673
|
-
|
|
33674
|
-
let storage = reserved2;
|
|
33675
|
-
if (sdkSpans.length > 0) {
|
|
33676
|
-
const sdkCounts = guestProjectionRegionCounts(storage.images.length, sdkSpans);
|
|
33677
|
-
storage = reserveGuestProjectionStorage(
|
|
33678
|
-
storage.images,
|
|
33679
|
-
storage.capacities.map((capacity, index) => ({
|
|
33680
|
-
...capacity,
|
|
33681
|
-
regions: capacity.regions + sdkCounts[index] + 16
|
|
33682
|
-
}))
|
|
33683
|
-
);
|
|
33684
|
-
const projectionSource = import_node_path45.default.join(work, "projection.c");
|
|
33685
|
-
(0, import_node_fs47.writeFileSync)(projectionSource, storage.source);
|
|
33686
|
-
(0, import_node_child_process30.execFileSync)(
|
|
33687
|
-
import_node_path45.default.join(options2.toolchainBin, "clang"),
|
|
33688
|
-
[...clangOptions, "-c", projectionSource, "-o", projectionObject],
|
|
33689
|
-
{ stdio: "pipe" }
|
|
33690
|
-
);
|
|
33691
|
-
}
|
|
33692
|
-
let precomputedSymbols;
|
|
33693
|
-
if (splitInputs.appReferencedSymbols && splitInputs.appDefinedSymbols) {
|
|
33694
|
-
const referenced = new Set(splitInputs.appReferencedSymbols);
|
|
33695
|
-
const defined = new Set(splitInputs.appDefinedSymbols);
|
|
33696
|
-
const projSyms = guestWasmSymbols((0, import_node_fs47.readFileSync)(projectionObject));
|
|
33697
|
-
for (const name3 of projSyms.undefined) referenced.add(name3);
|
|
33698
|
-
for (const name3 of projSyms.defined) defined.add(name3);
|
|
33699
|
-
precomputedSymbols = { referenced, defined };
|
|
33700
|
-
}
|
|
33701
|
-
for (; ; ) {
|
|
33702
|
-
const link = await linkSwiftAppModule2({
|
|
33703
|
-
objects: [...owners.keys()],
|
|
33704
|
-
lazyFunctions: splitInputs.lazyFunctions,
|
|
33705
|
-
toolchainBin: options2.toolchainBin,
|
|
33706
|
-
sdk: sdk2,
|
|
33707
|
-
work,
|
|
33708
|
-
output: options2.optimized,
|
|
33709
|
-
optimize: options2.optimize,
|
|
33710
|
-
layoutMap,
|
|
33711
|
-
project: project2,
|
|
33712
|
-
precomputedSymbols,
|
|
33713
|
-
loweringCache: project2 ? void 0 : {
|
|
33714
|
-
file: import_node_path45.default.join(
|
|
33715
|
-
options2.buildDirectory,
|
|
33716
|
-
".build",
|
|
33717
|
-
"peach-app-module-lowered.wasm"
|
|
33718
|
-
),
|
|
33719
|
-
compilerDigest: options2.compilerDigest
|
|
33720
|
-
}
|
|
33721
|
-
});
|
|
33722
|
-
const map3 = (0, import_node_fs47.readFileSync)(
|
|
33723
|
-
project2 ? projectOutputFile(work, layoutMap, project2) : layoutMap,
|
|
33724
|
-
"utf8"
|
|
33725
|
-
);
|
|
33726
|
-
const values = guestDyldValueRange(map3);
|
|
33727
|
-
const bindingRows = /* @__PURE__ */ new Map();
|
|
33728
|
-
const data = [];
|
|
33729
|
-
for (let at = 0; at < link.linkage.data.length; at += 3) {
|
|
33730
|
-
const address = link.linkage.data[at];
|
|
33731
|
-
const size2 = link.linkage.data[at + 1];
|
|
33732
|
-
const value = link.linkage.data[at + 2];
|
|
33733
|
-
if (values && address >= values.address && address < values.address + values.length) {
|
|
33734
|
-
if (size2 !== 8 || (address - values.address) % 8)
|
|
33735
|
-
throw new Error("sdk binding splits a dyld value");
|
|
33736
|
-
bindingRows.set((address - values.address) / 8, value);
|
|
33737
|
-
} else data.push(address, size2, value);
|
|
33738
|
-
}
|
|
33739
|
-
const linked = (0, import_node_fs47.readFileSync)(
|
|
33740
|
-
project2 ? projectOutputFile(work, linkedModule, project2) : linkedModule
|
|
33997
|
+
try {
|
|
33998
|
+
if (!splitInputs) throw new Error("guest link did not select shared SDK inputs");
|
|
33999
|
+
const {
|
|
34000
|
+
createSwiftSdkBinding: createSwiftSdkBinding2,
|
|
34001
|
+
linkSwiftAppModule: linkSwiftAppModule2,
|
|
34002
|
+
readSwiftSdkUsage: readSwiftSdkUsage2,
|
|
34003
|
+
swiftAppModuleThunkSection: swiftAppModuleThunkSection2,
|
|
34004
|
+
swiftSdkProjectionSpans: swiftSdkProjectionSpans2
|
|
34005
|
+
} = await Promise.resolve().then(() => (init_swift_sdk_app_module(), swift_sdk_app_module_exports));
|
|
34006
|
+
const project2 = options2.project;
|
|
34007
|
+
const work = project2 ? (0, import_node_fs47.mkdtempSync)(import_node_path45.default.join(directory2, "app-module-")) : import_node_path45.default.join(directory2, "app-module");
|
|
34008
|
+
if (project2) (0, import_node_fs47.chownSync)(work, project2.uid, project2.gid);
|
|
34009
|
+
else (0, import_node_fs47.mkdirSync)(work, { recursive: true });
|
|
34010
|
+
const layoutMap = import_node_path45.default.join(work, "app.map");
|
|
34011
|
+
let appProjectionObject = projectionObject;
|
|
34012
|
+
const owners = new Map(splitInputs.appObjects).set(appProjectionObject, 0);
|
|
34013
|
+
const sdkObjectKeys = /* @__PURE__ */ new Map();
|
|
34014
|
+
const sdkObjectImages = /* @__PURE__ */ new Map();
|
|
34015
|
+
const sdkProductImages = new Map(prepared?.sdkProducts.images);
|
|
34016
|
+
for (const [file, { image, product, identity: identity2 }] of splitInputs.sdkObjects) {
|
|
34017
|
+
const key2 = sdkGuestObjectKey(identity2);
|
|
34018
|
+
sdkObjectKeys.set(file, key2);
|
|
34019
|
+
sdkObjectImages.set(key2, image);
|
|
34020
|
+
const priorImage = sdkProductImages.get(product);
|
|
34021
|
+
if (priorImage !== void 0 && priorImage !== image)
|
|
34022
|
+
throw new Error(`SDK product ${product} has several guest images`);
|
|
34023
|
+
sdkProductImages.set(product, image);
|
|
34024
|
+
}
|
|
34025
|
+
const linkedModule = import_node_path45.default.join(work, "app.wasm");
|
|
34026
|
+
const sdkSpans = swiftSdkProjectionSpans2(
|
|
34027
|
+
sdk2,
|
|
34028
|
+
(object8, product) => sdkObjectImages.get(object8) ?? sdkProductImages.get(product)
|
|
33741
34029
|
);
|
|
33742
|
-
const
|
|
33743
|
-
...guestLinkedSpans(map3, linked, linked, owners, splitInputs.appSections, true),
|
|
33744
|
-
...sdkSpans
|
|
33745
|
-
]);
|
|
33746
|
-
if (storage.capacities.some(({ regions }, index) => required[index] > regions)) {
|
|
33747
|
-
storage = reserveGuestProjectionStorage(
|
|
33748
|
-
storage.images,
|
|
33749
|
-
storage.capacities.map((capacity, index) => {
|
|
33750
|
-
const count = required[index];
|
|
33751
|
-
return count > capacity.regions ? { ...capacity, regions: Math.max(count, capacity.regions * 2) } : capacity;
|
|
33752
|
-
})
|
|
33753
|
-
);
|
|
34030
|
+
const compileAppProjection = (source) => {
|
|
33754
34031
|
const projectionSource = import_node_path45.default.join(work, "projection.c");
|
|
33755
|
-
|
|
34032
|
+
const nextObject = import_node_path45.default.join(work, "projection.o");
|
|
34033
|
+
(0, import_node_fs47.writeFileSync)(projectionSource, source);
|
|
33756
34034
|
(0, import_node_child_process30.execFileSync)(
|
|
33757
34035
|
import_node_path45.default.join(options2.toolchainBin, "clang"),
|
|
33758
|
-
[...clangOptions, "-c", projectionSource, "-o",
|
|
34036
|
+
[...clangOptions, "-c", projectionSource, "-o", nextObject],
|
|
33759
34037
|
{ stdio: "pipe" }
|
|
33760
34038
|
);
|
|
33761
|
-
|
|
34039
|
+
if (nextObject !== appProjectionObject) {
|
|
34040
|
+
owners.delete(appProjectionObject);
|
|
34041
|
+
appProjectionObject = nextObject;
|
|
34042
|
+
owners.set(appProjectionObject, 0);
|
|
34043
|
+
}
|
|
34044
|
+
};
|
|
34045
|
+
let storage = reserved2;
|
|
34046
|
+
if (sdkSpans.length > 0) {
|
|
34047
|
+
const sdkCounts = guestProjectionRegionCounts(storage.images.length, sdkSpans);
|
|
34048
|
+
storage = reserveGuestProjectionStorage(
|
|
34049
|
+
storage.images,
|
|
34050
|
+
storage.capacities.map((capacity, index) => ({
|
|
34051
|
+
...capacity,
|
|
34052
|
+
regions: capacity.regions + sdkCounts[index] + 16
|
|
34053
|
+
}))
|
|
34054
|
+
);
|
|
34055
|
+
compileAppProjection(storage.source);
|
|
33762
34056
|
}
|
|
33763
|
-
|
|
33764
|
-
|
|
33765
|
-
|
|
33766
|
-
|
|
33767
|
-
|
|
33768
|
-
|
|
33769
|
-
|
|
33770
|
-
|
|
34057
|
+
let precomputedSymbols;
|
|
34058
|
+
if (splitInputs.appReferencedSymbols && splitInputs.appDefinedSymbols) {
|
|
34059
|
+
const referenced = new Set(splitInputs.appReferencedSymbols);
|
|
34060
|
+
const defined = new Set(splitInputs.appDefinedSymbols);
|
|
34061
|
+
const projSyms = guestWasmSymbols((0, import_node_fs47.readFileSync)(appProjectionObject));
|
|
34062
|
+
for (const name3 of projSyms.undefined) referenced.add(name3);
|
|
34063
|
+
for (const name3 of projSyms.defined) defined.add(name3);
|
|
34064
|
+
precomputedSymbols = { referenced, defined };
|
|
34065
|
+
}
|
|
34066
|
+
for (; ; ) {
|
|
34067
|
+
const link = await linkSwiftAppModule2({
|
|
34068
|
+
objects: [...owners.keys()],
|
|
34069
|
+
lazyFunctions: splitInputs.lazyFunctions,
|
|
34070
|
+
toolchainBin: options2.toolchainBin,
|
|
34071
|
+
sdk: sdk2,
|
|
34072
|
+
work,
|
|
34073
|
+
output: options2.optimized,
|
|
34074
|
+
optimize: options2.optimize,
|
|
34075
|
+
layoutMap,
|
|
34076
|
+
project: project2,
|
|
34077
|
+
precomputedSymbols,
|
|
34078
|
+
loweringCache: project2 ? void 0 : {
|
|
34079
|
+
file: import_node_path45.default.join(
|
|
34080
|
+
options2.buildDirectory,
|
|
34081
|
+
".build",
|
|
34082
|
+
"peach-app-module-lowered.wasm"
|
|
34083
|
+
),
|
|
34084
|
+
compilerDigest: options2.compilerDigest
|
|
34085
|
+
}
|
|
33771
34086
|
});
|
|
33772
|
-
|
|
34087
|
+
const map3 = (0, import_node_fs47.readFileSync)(
|
|
34088
|
+
project2 ? projectOutputFile(work, layoutMap, project2) : layoutMap,
|
|
34089
|
+
"utf8"
|
|
34090
|
+
);
|
|
34091
|
+
const values = guestDyldValueRange(map3);
|
|
34092
|
+
const bindingRows = /* @__PURE__ */ new Map();
|
|
34093
|
+
const data = [];
|
|
34094
|
+
for (let at = 0; at < link.linkage.data.length; at += 3) {
|
|
34095
|
+
const address = link.linkage.data[at];
|
|
34096
|
+
const size2 = link.linkage.data[at + 1];
|
|
34097
|
+
const value = link.linkage.data[at + 2];
|
|
34098
|
+
if (values && address >= values.address && address < values.address + values.length) {
|
|
34099
|
+
if (size2 !== 8 || (address - values.address) % 8)
|
|
34100
|
+
throw new Error("sdk binding splits a dyld value");
|
|
34101
|
+
bindingRows.set((address - values.address) / 8, value);
|
|
34102
|
+
} else data.push(address, size2, value);
|
|
34103
|
+
}
|
|
34104
|
+
const linked = (0, import_node_fs47.readFileSync)(
|
|
34105
|
+
project2 ? projectOutputFile(work, linkedModule, project2) : linkedModule
|
|
34106
|
+
);
|
|
34107
|
+
const required = guestProjectionRegionCounts(storage.images.length, [
|
|
34108
|
+
...guestLinkedSpans(map3, linked, linked, owners, splitInputs.appSections, true),
|
|
34109
|
+
...sdkSpans
|
|
34110
|
+
]);
|
|
34111
|
+
if (storage.capacities.some(({ regions }, index) => required[index] > regions)) {
|
|
34112
|
+
storage = reserveGuestProjectionStorage(
|
|
34113
|
+
storage.images,
|
|
34114
|
+
storage.capacities.map((capacity, index) => {
|
|
34115
|
+
const count = required[index];
|
|
34116
|
+
return count > capacity.regions ? { ...capacity, regions: Math.max(count, capacity.regions * 2) } : capacity;
|
|
34117
|
+
})
|
|
34118
|
+
);
|
|
34119
|
+
compileAppProjection(storage.source);
|
|
34120
|
+
continue;
|
|
34121
|
+
}
|
|
34122
|
+
options2.onStage("lowering the app image");
|
|
34123
|
+
const lowerPromise = link.lower();
|
|
34124
|
+
await new Promise((resolve4) => setImmediate(resolve4));
|
|
34125
|
+
let binding;
|
|
34126
|
+
try {
|
|
34127
|
+
if (result.finalLinkDone) await result.finalLinkDone;
|
|
34128
|
+
const usage = readSwiftSdkUsage2(result.mapPath, options2.output, sdkObjectKeys);
|
|
34129
|
+
binding = createSwiftSdkBinding2({ ...link.linkage, data }, sdk2, usage);
|
|
34130
|
+
} catch (error) {
|
|
34131
|
+
await Promise.allSettled([lowerPromise]);
|
|
34132
|
+
throw error;
|
|
34133
|
+
}
|
|
34134
|
+
await lowerPromise;
|
|
34135
|
+
const finalized = finalizeGuestProjectionStorage({
|
|
34136
|
+
map: map3,
|
|
34137
|
+
linked,
|
|
34138
|
+
optimized: (0, import_node_fs47.readFileSync)(options2.optimized),
|
|
34139
|
+
owners,
|
|
34140
|
+
sectionOwners: splitInputs.appSections,
|
|
34141
|
+
projectionObject: appProjectionObject,
|
|
34142
|
+
reserved: storage,
|
|
34143
|
+
sdkSpans
|
|
34144
|
+
});
|
|
34145
|
+
(0, import_node_fs47.writeFileSync)(
|
|
34146
|
+
options2.optimized,
|
|
34147
|
+
moveGuestDyldTable(map3, finalized.wasm, splitInputs.dyldSymbols, bindingRows, [
|
|
34148
|
+
swiftAppModuleThunkSection2(finalized.wasm)
|
|
34149
|
+
])
|
|
34150
|
+
);
|
|
34151
|
+
return binding;
|
|
33773
34152
|
}
|
|
33774
|
-
|
|
33775
|
-
|
|
33776
|
-
map: map3,
|
|
33777
|
-
linked,
|
|
33778
|
-
optimized: (0, import_node_fs47.readFileSync)(options2.optimized),
|
|
33779
|
-
owners,
|
|
33780
|
-
sectionOwners: splitInputs.appSections,
|
|
33781
|
-
projectionObject,
|
|
33782
|
-
reserved: storage,
|
|
33783
|
-
sdkSpans
|
|
33784
|
-
});
|
|
33785
|
-
(0, import_node_fs47.writeFileSync)(
|
|
33786
|
-
options2.optimized,
|
|
33787
|
-
finishSwiftAppModule2(
|
|
33788
|
-
moveGuestDyldTable(map3, finalized.wasm, splitInputs.dyldSymbols, bindingRows)
|
|
33789
|
-
)
|
|
33790
|
-
);
|
|
33791
|
-
return binding;
|
|
34153
|
+
} finally {
|
|
34154
|
+
if (result.finalLinkDone) await Promise.allSettled([result.finalLinkDone]);
|
|
33792
34155
|
}
|
|
33793
34156
|
}
|
|
33794
34157
|
options2.onStage("lowering the app image");
|
|
@@ -39236,6 +39599,10 @@ async function buildFrameworkProducts(scratch2, args) {
|
|
|
39236
39599
|
// every framework target when callers alternate --cores.
|
|
39237
39600
|
"-Xswiftc",
|
|
39238
39601
|
"-gnone",
|
|
39602
|
+
"-Xcc",
|
|
39603
|
+
"-g0",
|
|
39604
|
+
"-Xcxx",
|
|
39605
|
+
"-g0",
|
|
39239
39606
|
"-Xswiftc",
|
|
39240
39607
|
"-num-threads",
|
|
39241
39608
|
"-Xswiftc",
|
|
@@ -40126,6 +40493,10 @@ ${cap}` : "";
|
|
|
40126
40493
|
// fan-out under high -j.
|
|
40127
40494
|
"-Xswiftc",
|
|
40128
40495
|
"-gnone",
|
|
40496
|
+
"-Xcc",
|
|
40497
|
+
"-g0",
|
|
40498
|
+
"-Xcxx",
|
|
40499
|
+
"-g0",
|
|
40129
40500
|
...incrementalPreview ? [] : [
|
|
40130
40501
|
"-Xswiftc",
|
|
40131
40502
|
"-num-threads",
|
|
@@ -40776,7 +41147,7 @@ ${wasmThreadLinkFlags.map((flag) => ` "-Xlinker", ${JSON.stringify(flag
|
|
|
40776
41147
|
REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
|
|
40777
41148
|
MULTI_MANIFEST_VERSION = 76;
|
|
40778
41149
|
SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
|
|
40779
|
-
compilerSourceDigest = true ? "
|
|
41150
|
+
compilerSourceDigest = true ? "ab7e385f5b9ca10737de11d59802a2b57ee084a172b96aa971acb4c26a58a573" : swiftCompilerSourceDigest(__sootsim_import_meta_dirname);
|
|
40780
41151
|
nativeCxxCompilerFlags = ["-fno-cxx-modules"];
|
|
40781
41152
|
MODULE_MAP_RESPONSE_FILE_RUN = 16;
|
|
40782
41153
|
cFlagArray = (flags) => JSON.stringify(withoutGlogModuleMap(flags));
|
|
@@ -66431,6 +66802,11 @@ var init_podspec_sources = __esm({
|
|
|
66431
66802
|
});
|
|
66432
66803
|
|
|
66433
66804
|
// src/bazel-project.ts
|
|
66805
|
+
function sha256Hex5(bytes) {
|
|
66806
|
+
if (typeof Bun !== "undefined")
|
|
66807
|
+
return new Bun.CryptoHasher("sha256").update(bytes).digest("hex");
|
|
66808
|
+
return (0, import_node_crypto42.createHash)("sha256").update(bytes).digest("hex");
|
|
66809
|
+
}
|
|
66434
66810
|
function isBazelPackage(input) {
|
|
66435
66811
|
return /^BUILD(?:\.bazel)?$/.test(import_node_path73.default.basename(input)) && import_node_fs73.default.statSync(input).isFile();
|
|
66436
66812
|
}
|
|
@@ -66997,6 +67373,18 @@ ${published3.map(
|
|
|
66997
67373
|
`bazel application has ${missing2.length} unbuilt inputs: ${missing2.slice(0, 5).map((file) => import_node_path73.default.relative(root, file)).join(", ")}`
|
|
66998
67374
|
);
|
|
66999
67375
|
const archives = /* @__PURE__ */ new Map();
|
|
67376
|
+
let outputOwner;
|
|
67377
|
+
const ownerOfOutput = (file) => {
|
|
67378
|
+
if (!outputOwner) {
|
|
67379
|
+
outputOwner = /* @__PURE__ */ new Map();
|
|
67380
|
+
for (const item of graph.rules.values())
|
|
67381
|
+
for (const output of item.outputs) {
|
|
67382
|
+
const outputPath2 = files2.path(output);
|
|
67383
|
+
if (!outputOwner.has(outputPath2)) outputOwner.set(outputPath2, item);
|
|
67384
|
+
}
|
|
67385
|
+
}
|
|
67386
|
+
return outputOwner.get(file);
|
|
67387
|
+
};
|
|
67000
67388
|
for (const rule of order) {
|
|
67001
67389
|
for (const dep of rule.attrs.get("deps")?.list ?? []) {
|
|
67002
67390
|
const owner = ruleOf(dep, rule.label);
|
|
@@ -67014,9 +67402,7 @@ ${published3.map(
|
|
|
67014
67402
|
for (const raw2 of rule.attrs.get("srcs")?.list ?? []) {
|
|
67015
67403
|
const label2 = canonicalLabel(raw2, rule.label);
|
|
67016
67404
|
for (const archive of files2.expand([raw2], rule.label).filter((file) => file.endsWith(".a"))) {
|
|
67017
|
-
const owner =
|
|
67018
|
-
(item) => item.outputs.some((output) => files2.path(output) === archive)
|
|
67019
|
-
);
|
|
67405
|
+
const owner = ownerOfOutput(archive);
|
|
67020
67406
|
const key2 = owner?.label ?? label2;
|
|
67021
67407
|
const entry = archives.get(key2) ?? {
|
|
67022
67408
|
library: import_node_path73.default.basename(archive),
|
|
@@ -67042,6 +67428,13 @@ ${published3.map(
|
|
|
67042
67428
|
)
|
|
67043
67429
|
)
|
|
67044
67430
|
);
|
|
67431
|
+
const matchesAppInclude = (name3) => {
|
|
67432
|
+
if (appIncludes.has(name3)) return true;
|
|
67433
|
+
for (let slash = name3.indexOf("/"); slash >= 0; slash = name3.indexOf("/", slash + 1)) {
|
|
67434
|
+
if (appIncludes.has(name3.slice(slash + 1))) return true;
|
|
67435
|
+
}
|
|
67436
|
+
return false;
|
|
67437
|
+
};
|
|
67045
67438
|
let generatedBy;
|
|
67046
67439
|
const generators = () => {
|
|
67047
67440
|
if (!generatedBy) {
|
|
@@ -67122,9 +67515,7 @@ ${published3.map(
|
|
|
67122
67515
|
[...linkers].filter((rule) => rule.attrs.get("module_name")?.value).flatMap((rule) => files2.expand(rule.attrs.get("hdrs")?.list ?? [], rule.label))
|
|
67123
67516
|
);
|
|
67124
67517
|
const entries2 = headers.filter(
|
|
67125
|
-
(header) => imported.has(header.file) ||
|
|
67126
|
-
(include) => header.name === include || header.name.endsWith(`/${include}`)
|
|
67127
|
-
)
|
|
67518
|
+
(header) => imported.has(header.file) || matchesAppInclude(header.name)
|
|
67128
67519
|
);
|
|
67129
67520
|
const bundle = import_node_path73.default.join(products, "archives", `${name3}.xcframework`);
|
|
67130
67521
|
const slice = import_node_path73.default.join(bundle, "ios-arm64-simulator");
|
|
@@ -67170,14 +67561,9 @@ ${published3.map(
|
|
|
67170
67561
|
]
|
|
67171
67562
|
)
|
|
67172
67563
|
]);
|
|
67173
|
-
const digest3 = (
|
|
67174
|
-
JSON.stringify(
|
|
67175
|
-
|
|
67176
|
-
file,
|
|
67177
|
-
(0, import_node_crypto42.createHash)("sha256").update(bytes).digest("hex")
|
|
67178
|
-
])
|
|
67179
|
-
)
|
|
67180
|
-
).digest("hex");
|
|
67564
|
+
const digest3 = sha256Hex5(
|
|
67565
|
+
JSON.stringify([...contents2].map(([file, bytes]) => [file, sha256Hex5(bytes)]))
|
|
67566
|
+
);
|
|
67181
67567
|
const stamp = import_node_path73.default.join(bundle, ".peach-digest");
|
|
67182
67568
|
if (!import_node_fs73.default.existsSync(stamp) || import_node_fs73.default.readFileSync(stamp, "utf8") !== digest3) {
|
|
67183
67569
|
import_node_fs73.default.rmSync(bundle, { recursive: true, force: true });
|
|
@@ -86433,7 +86819,7 @@ var init_swift_standin_digest = __esm({
|
|
|
86433
86819
|
];
|
|
86434
86820
|
RUNTIME_IMPORT = /(?:^|[;\n])[ \t]*(?:import|export)\s+(?!type(?:\s|\{))([\s\S]*?)\s+from\s*['"]([^'"]+)['"]|(?:^|[;\n])[ \t]*import\s+['"]([^'"]+)['"]|import\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
|
|
86435
86821
|
standinSourceDigest = (srcDir = __sootsim_import_meta_dirname) => sourceClosureDigest(srcDir, STANDIN_DIGEST_ENTRYPOINTS, STANDIN_DIGEST_EXCLUDED_FILES);
|
|
86436
|
-
STANDIN_SOURCE_DIGEST = true ? "
|
|
86822
|
+
STANDIN_SOURCE_DIGEST = true ? "7f9a1a548c5ea58c56b73bfc2a755a05031acbd1b10c1c79dc32b1d6c9bea9e4" : standinSourceDigest();
|
|
86437
86823
|
}
|
|
86438
86824
|
});
|
|
86439
86825
|
|
|
@@ -91541,7 +91927,7 @@ function compiledFrameworkImports(app, products) {
|
|
|
91541
91927
|
}
|
|
91542
91928
|
return imports2;
|
|
91543
91929
|
}
|
|
91544
|
-
function
|
|
91930
|
+
function sha256Hex6(bytes) {
|
|
91545
91931
|
if (typeof Bun !== "undefined")
|
|
91546
91932
|
return new Bun.CryptoHasher("sha256").update(bytes).digest("hex");
|
|
91547
91933
|
return (0, import_node_crypto65.createHash)("sha256").update(bytes).digest("hex");
|
|
@@ -91559,7 +91945,7 @@ function verifyRetainedFile(work, file, hash, stamps) {
|
|
|
91559
91945
|
if (typeof expectedStamp === "string" && regularFileStamp(resolved) === expectedStamp)
|
|
91560
91946
|
return true;
|
|
91561
91947
|
if (!import_node_fs109.default.existsSync(resolved)) return false;
|
|
91562
|
-
return
|
|
91948
|
+
return sha256Hex6(readPackageFile(work, resolved, Infinity)) === hash;
|
|
91563
91949
|
}
|
|
91564
91950
|
function recordRetainedStamps(work, files2) {
|
|
91565
91951
|
const stamps = {};
|
|
@@ -91576,7 +91962,7 @@ function cachedBinaryFileDigest(file) {
|
|
|
91576
91962
|
const memory = binaryFileDigests.get(real);
|
|
91577
91963
|
if (memory?.stamp === stamp) return memory.digest;
|
|
91578
91964
|
const dir = import_node_path111.default.join(cacheDir(), "swift-binary-digests");
|
|
91579
|
-
const record5 = import_node_path111.default.join(dir, `${
|
|
91965
|
+
const record5 = import_node_path111.default.join(dir, `${sha256Hex6(real)}.json`);
|
|
91580
91966
|
if (import_node_fs109.default.existsSync(record5)) {
|
|
91581
91967
|
const saved = JSON.parse(import_node_fs109.default.readFileSync(record5, "utf8"));
|
|
91582
91968
|
if (isRecord(saved) && saved.stamp === stamp && typeof saved.digest === "string") {
|
|
@@ -91584,7 +91970,7 @@ function cachedBinaryFileDigest(file) {
|
|
|
91584
91970
|
return saved.digest;
|
|
91585
91971
|
}
|
|
91586
91972
|
}
|
|
91587
|
-
const digest3 =
|
|
91973
|
+
const digest3 = sha256Hex6(import_node_fs109.default.readFileSync(real));
|
|
91588
91974
|
binaryFileDigests.set(real, { stamp, digest: digest3 });
|
|
91589
91975
|
import_node_fs109.default.mkdirSync(dir, { recursive: true });
|
|
91590
91976
|
const partial = `${record5}.${process.pid}.${(0, import_node_crypto65.randomUUID)()}`;
|
|
@@ -92119,7 +92505,7 @@ function prepareXcodeSwiftProducts(app, binaries, moduleRoot) {
|
|
|
92119
92505
|
const staged = withFrameworkCompanionImports(original);
|
|
92120
92506
|
if (staged !== original) sources.set(file, Buffer.from(staged));
|
|
92121
92507
|
}
|
|
92122
|
-
const digest3 =
|
|
92508
|
+
const digest3 = sha256Hex6;
|
|
92123
92509
|
const providers = /* @__PURE__ */ new Map();
|
|
92124
92510
|
for (const target of targets) {
|
|
92125
92511
|
if (!supplied.has(target.moduleName)) continue;
|
|
@@ -92475,7 +92861,7 @@ async function prepareXcodeNativeInputs(app, binaries, moduleRoot, purpose) {
|
|
|
92475
92861
|
products
|
|
92476
92862
|
);
|
|
92477
92863
|
const checkouts = remoteSwiftCheckouts(app.rootDir);
|
|
92478
|
-
const digest3 =
|
|
92864
|
+
const digest3 = sha256Hex6;
|
|
92479
92865
|
const inputs2 = Object.fromEntries(
|
|
92480
92866
|
[...sources].map(([file, bytes]) => [file, digest3(bytes)])
|
|
92481
92867
|
);
|
|
@@ -92757,6 +93143,7 @@ async function prepareXcodeNativeInputs(app, binaries, moduleRoot, purpose) {
|
|
|
92757
93143
|
...flags,
|
|
92758
93144
|
...target.prefix ? ["-include", staged(target.prefix)] : [],
|
|
92759
93145
|
"-Os",
|
|
93146
|
+
...purpose === "objects" ? ["-g0"] : [],
|
|
92760
93147
|
"-c",
|
|
92761
93148
|
staged(file),
|
|
92762
93149
|
"-o",
|
|
@@ -104204,7 +104591,7 @@ var init_nitro_superset = __esm({
|
|
|
104204
104591
|
init_nitroContract();
|
|
104205
104592
|
init_swift_standin_digest();
|
|
104206
104593
|
NITRO_SUPERSET_ENTRY_NAME = "superset";
|
|
104207
|
-
NITRO_COMPILER_DIGEST = true ? "
|
|
104594
|
+
NITRO_COMPILER_DIGEST = true ? "2b748ed5d0850b2ccb4eb8842bbcfdec5254b56ef63760418c6e2795f3b68e10" : nitroCompilerSourceDigest(__sootsim_import_meta_dirname, STANDIN_SOURCE_DIGEST2);
|
|
104208
104595
|
nitroSupersetLock = parseLock(nitro_superset_lock_default);
|
|
104209
104596
|
nitroSupersetKey = (inputs2) => nativeEntryKey({ ...inputs2, compiler: NITRO_COMPILER_DIGEST });
|
|
104210
104597
|
published = /* @__PURE__ */ new Map();
|
|
@@ -105072,7 +105459,7 @@ var init_expo_eager_seam_contract = __esm({
|
|
|
105072
105459
|
|
|
105073
105460
|
// src/expo-native-compiler-digest.ts
|
|
105074
105461
|
function expoNativeCompilerDigestValue() {
|
|
105075
|
-
return true ? "
|
|
105462
|
+
return true ? "ee97927d0c41fd6dd7d1290da2bbe36d7c9ec0fe81e3d5a7aa101cd4d446e5ab" : expoNativeCompilerDigest(__sootsim_import_meta_dirname);
|
|
105076
105463
|
}
|
|
105077
105464
|
var import_node_crypto78;
|
|
105078
105465
|
var init_expo_native_compiler_digest = __esm({
|
|
@@ -114068,7 +114455,7 @@ async function snapshotOneProductionBundle(projectRoot, entryFile, env = {}, { r
|
|
|
114068
114455
|
return { platforms: snapshots };
|
|
114069
114456
|
}
|
|
114070
114457
|
async function snapshotOneDevBundle(projectRoot, env = {}, { runtimeExecutable = process.execPath, platforms: platforms2 = ["ios", "android"] } = {}) {
|
|
114071
|
-
const { spawn:
|
|
114458
|
+
const { spawn: spawn15 } = await import("node:child_process");
|
|
114072
114459
|
const { createServer: createServer2 } = await import("node:net");
|
|
114073
114460
|
const { createRequire: createRequire24 } = await import("node:module");
|
|
114074
114461
|
const onePackage = createRequire24((0, import_node_path156.join)(projectRoot, "package.json")).resolve(
|
|
@@ -114084,7 +114471,7 @@ async function snapshotOneDevBundle(projectRoot, env = {}, { runtimeExecutable =
|
|
|
114084
114471
|
server.close(() => resolve4(port2));
|
|
114085
114472
|
}).on("error", reject);
|
|
114086
114473
|
});
|
|
114087
|
-
const child =
|
|
114474
|
+
const child = spawn15(runtimeExecutable, [oneBin, "dev", "--port", String(port)], {
|
|
114088
114475
|
cwd: projectRoot,
|
|
114089
114476
|
env: { ...process.env, ...env, CI: "1", PEACH_NO_OPEN: "1" },
|
|
114090
114477
|
stdio: ["ignore", "inherit", "inherit"],
|