peachsim 0.1.2682 → 0.1.2683
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/cli/commands/package.ts +7 -1
- 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 +505 -598
- 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 +15 -5
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/esm-chunks/{acorn-V7B4X5PR.mjs → acorn-IKX32JM5.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-GNZDVDDX.mjs → chunk-2I4ZO225.mjs} +6 -6
- package/dist-lib/esm-chunks/{chunk-AXBK3CA4.mjs → chunk-4QC7XPTA.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-UTI6VCYT.mjs → chunk-5SA2UPEO.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-Y6WPXDCC.mjs → chunk-5SZETTJV.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-R2WPUKVT.mjs → chunk-73CUMN63.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-X37OP27I.mjs → chunk-7LXBDQQH.mjs} +678 -790
- package/dist-lib/esm-chunks/{chunk-LV55WJFQ.mjs → chunk-AYSUZBC3.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-EK36QRGX.mjs → chunk-BC4OWNHZ.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-KYIRROKJ.mjs → chunk-BXFBASQX.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-BJHQOPWO.mjs → chunk-CQ4J5VV3.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-YKGS4NSG.mjs → chunk-DG7RT7A7.mjs} +5 -5
- package/dist-lib/esm-chunks/{chunk-3UQZATB5.mjs → chunk-EZ64444V.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-SZ5UPZE4.mjs → chunk-HEN6NPXJ.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-DU3VOY6S.mjs → chunk-HLISQIRP.mjs} +6 -6
- package/dist-lib/esm-chunks/{chunk-IOLISFIO.mjs → chunk-JTBC65YO.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-3VAFU4BM.mjs → chunk-JVSMJ5IO.mjs} +4 -4
- package/dist-lib/esm-chunks/{chunk-EC5RY4HR.mjs → chunk-LGV6BWY5.mjs} +2 -2
- package/dist-lib/esm-chunks/{chunk-64UA6DQO.mjs → chunk-OGWPMZSB.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-Z6R2HZIH.mjs → chunk-OTWOI3OW.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-VTJTOL53.mjs → chunk-QEV3YRKL.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-6PSNFREM.mjs → chunk-RNZ65XZE.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-5SWSDDXC.mjs → chunk-S4OXEZXM.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-ZYD227CX.mjs → chunk-UYWI2SM5.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-PE7HDZNI.mjs → chunk-WBAH2CS4.mjs} +1 -1
- package/dist-lib/esm-chunks/{metro-layout-parser-5RTSOQCS.mjs → metro-layout-parser-6IOBG67O.mjs} +3 -3
- package/dist-lib/esm-chunks/{swift-package-prebuilt-EH5JIX6L.mjs → swift-package-prebuilt-NBARV44W.mjs} +12 -12
- package/dist-lib/esm-chunks/{swift-sdk-app-module-VHAOCBXW.mjs → swift-sdk-app-module-5K76OLA6.mjs} +16 -16
- package/dist-lib/esm-chunks/{swift-sdk-image-3NCWCGQZ.mjs → swift-sdk-image-WJMMMWZH.mjs} +16 -16
- package/dist-lib/esm-chunks/{swift-sdk-image-producer-5S4IKSJ2.mjs → swift-sdk-image-producer-M23OLZGS.mjs} +5 -5
- package/dist-lib/expo-swift-bundle.cjs +495 -593
- 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 +620 -715
- package/dist-lib/host/fetch-proxy-handler.cjs +22 -24
- 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 +1 -1
- package/dist-lib/native-app-identity-project.mjs +15 -15
- 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 -87
- package/dist-lib/public-origins-lib.json +76 -76
- 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 +622 -717
- package/dist-lib/swift-compile.cjs +502 -618
- 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/src/engine/image-fetch.d.ts +1 -0
- package/package.json +1 -1
- package/runtime-companion.json +1 -1
- package/src/native-bundles.ts +7 -1
- package/src/native-package-slice.ts +28 -12
- package/src/nitro-bundle.ts +1 -0
- package/src/nitro-compile.ts +8 -2
- package/src/nitroContract.ts +35 -14
- package/src/one-sdk-bundle.ts +2 -2
- package/src/swift-compile.ts +25 -131
- package/src/swift-guest-compile.ts +184 -218
- package/src/swift-host.ts +13 -23
- package/src/swift-submit.ts +0 -2
- package/src/turbo-bundle.ts +2 -2
- package/src/turbo-compile.ts +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! peach v0.1.
|
|
1
|
+
/*! peach v0.1.2683 | (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;
|
|
@@ -2621,9 +2621,6 @@ var init_retired_cache_directory = __esm({
|
|
|
2621
2621
|
});
|
|
2622
2622
|
|
|
2623
2623
|
// src/swift-compile-budget.ts
|
|
2624
|
-
function swiftBuilderHopTimeoutMs(compileTimeoutMs) {
|
|
2625
|
-
return SWIFT_LOCK_WAIT_TIMEOUT_MS + (compileTimeoutMs ?? SWIFT_COMPILE_TIMEOUT_MS) + SWIFT_TRANSPORT_MARGIN_MS;
|
|
2626
|
-
}
|
|
2627
2624
|
async function withSwiftCompileBudget(compileTimeoutMs, signal, work) {
|
|
2628
2625
|
const deadline = new AbortController();
|
|
2629
2626
|
const combined = signal ? AbortSignal.any([signal, deadline.signal]) : deadline.signal;
|
|
@@ -2663,13 +2660,12 @@ async function withSwiftCompileBudget(compileTimeoutMs, signal, work) {
|
|
|
2663
2660
|
clearTimeout(timer);
|
|
2664
2661
|
}
|
|
2665
2662
|
}
|
|
2666
|
-
var SWIFT_COMPILE_TIMEOUT_MS, SWIFT_LOCK_WAIT_TIMEOUT_MS
|
|
2663
|
+
var SWIFT_COMPILE_TIMEOUT_MS, SWIFT_LOCK_WAIT_TIMEOUT_MS;
|
|
2667
2664
|
var init_swift_compile_budget = __esm({
|
|
2668
2665
|
"src/swift-compile-budget.ts"() {
|
|
2669
2666
|
"use strict";
|
|
2670
2667
|
SWIFT_COMPILE_TIMEOUT_MS = 18e5;
|
|
2671
2668
|
SWIFT_LOCK_WAIT_TIMEOUT_MS = 36e5;
|
|
2672
|
-
SWIFT_TRANSPORT_MARGIN_MS = 3e5;
|
|
2673
2669
|
}
|
|
2674
2670
|
});
|
|
2675
2671
|
|
|
@@ -10679,6 +10675,16 @@ var init_swift_guest_archive = __esm({
|
|
|
10679
10675
|
}
|
|
10680
10676
|
});
|
|
10681
10677
|
|
|
10678
|
+
// ../peach-kit/src/nativeDyldTableContract.ts
|
|
10679
|
+
var NATIVE_DYLD_TABLE_SECTION, NATIVE_DYLD_PACKS_SECTION;
|
|
10680
|
+
var init_nativeDyldTableContract = __esm({
|
|
10681
|
+
"../peach-kit/src/nativeDyldTableContract.ts"() {
|
|
10682
|
+
"use strict";
|
|
10683
|
+
NATIVE_DYLD_TABLE_SECTION = "peach.dyld-table-v1";
|
|
10684
|
+
NATIVE_DYLD_PACKS_SECTION = "peach.dyld-packs-v1";
|
|
10685
|
+
}
|
|
10686
|
+
});
|
|
10687
|
+
|
|
10682
10688
|
// ../peach-kit/src/nativeWasmContract.ts
|
|
10683
10689
|
var NATIVE_IMAGE_SECTION, NATIVE_TABLE_ABI, NATIVE_TABLE_IMPORT_MODULE, NATIVE_DYLD_FUNCTION_IMPORT, NATIVE_DYLD_PLACE_EXPORT, NATIVE_LAZY_IMPORT_MODULE, NATIVE_SDK_IMPORT_MODULE, NATIVE_SDK_THUNK_SECTION, NATIVE_LAZY_SLOT_IMPORT, NATIVE_LAZY_DIGEST_BYTES, NATIVE_LAZY_PART_BYTES, NATIVE_TABLE_RESERVE_SLOTS;
|
|
10684
10690
|
var init_nativeWasmContract = __esm({
|
|
@@ -10699,270 +10705,6 @@ var init_nativeWasmContract = __esm({
|
|
|
10699
10705
|
}
|
|
10700
10706
|
});
|
|
10701
10707
|
|
|
10702
|
-
// src/swift-guest-dyld-functions.ts
|
|
10703
|
-
function skipValueType(r) {
|
|
10704
|
-
const type = r.byte();
|
|
10705
|
-
if (type === 99 || type === 100) r.s();
|
|
10706
|
-
}
|
|
10707
|
-
function readImports2(bytes, sections) {
|
|
10708
|
-
let functions = 0;
|
|
10709
|
-
let table64;
|
|
10710
|
-
const imports = sections.find((s) => s.id === 2);
|
|
10711
|
-
if (imports) {
|
|
10712
|
-
const r = wasmReader(bytes, imports.start);
|
|
10713
|
-
for (let n = r.u(); n > 0; n--) {
|
|
10714
|
-
r.name();
|
|
10715
|
-
r.name();
|
|
10716
|
-
const kind = r.byte();
|
|
10717
|
-
if (kind === 0) {
|
|
10718
|
-
functions++;
|
|
10719
|
-
r.u();
|
|
10720
|
-
} else if (kind === 1 || kind === 2) {
|
|
10721
|
-
if (kind === 1) skipValueType(r);
|
|
10722
|
-
const flags = r.u();
|
|
10723
|
-
r.u();
|
|
10724
|
-
if (flags & 1) r.u();
|
|
10725
|
-
if (kind === 1) table64 ??= (flags & 4) !== 0;
|
|
10726
|
-
} else if (kind === 3) {
|
|
10727
|
-
skipValueType(r);
|
|
10728
|
-
r.byte();
|
|
10729
|
-
} else if (kind === 4) {
|
|
10730
|
-
r.byte();
|
|
10731
|
-
r.u();
|
|
10732
|
-
} else throw new Error(`unsupported wasm import kind ${kind}`);
|
|
10733
|
-
}
|
|
10734
|
-
}
|
|
10735
|
-
const tables = sections.find((s) => s.id === 4);
|
|
10736
|
-
if (table64 === void 0 && tables) {
|
|
10737
|
-
const r = wasmReader(bytes, tables.start);
|
|
10738
|
-
if (r.u()) {
|
|
10739
|
-
skipValueType(r);
|
|
10740
|
-
table64 = (r.u() & 4) !== 0;
|
|
10741
|
-
}
|
|
10742
|
-
}
|
|
10743
|
-
return { functions, table64 };
|
|
10744
|
-
}
|
|
10745
|
-
function vectorSection(id, count, parts) {
|
|
10746
|
-
const body = Buffer.concat([Buffer.from(uleb2(count)), ...parts]);
|
|
10747
|
-
return Buffer.concat([Buffer.from([id, ...uleb2(body.length)]), body]);
|
|
10748
|
-
}
|
|
10749
|
-
function rewriteSections(bytes, sections, changes) {
|
|
10750
|
-
const out = [bytes.subarray(0, 8)];
|
|
10751
|
-
const pending = new Map(changes);
|
|
10752
|
-
const flushBefore = (id) => {
|
|
10753
|
-
for (const [missing, section2] of pending) {
|
|
10754
|
-
if (SECTION_ORDER.indexOf(missing) >= SECTION_ORDER.indexOf(id)) continue;
|
|
10755
|
-
if (section2) out.push(section2);
|
|
10756
|
-
pending.delete(missing);
|
|
10757
|
-
}
|
|
10758
|
-
};
|
|
10759
|
-
for (const s of sections) {
|
|
10760
|
-
if (s.id !== 0) flushBefore(s.id);
|
|
10761
|
-
if (!pending.has(s.id)) {
|
|
10762
|
-
out.push(bytes.subarray(s.offset, s.end));
|
|
10763
|
-
continue;
|
|
10764
|
-
}
|
|
10765
|
-
const section2 = pending.get(s.id);
|
|
10766
|
-
pending.delete(s.id);
|
|
10767
|
-
if (section2) out.push(section2);
|
|
10768
|
-
}
|
|
10769
|
-
for (const section2 of pending.values()) if (section2) out.push(section2);
|
|
10770
|
-
return Buffer.concat(out);
|
|
10771
|
-
}
|
|
10772
|
-
function entries(bytes, section2, entry) {
|
|
10773
|
-
if (!section2) return [];
|
|
10774
|
-
const r = wasmReader(bytes, section2.start);
|
|
10775
|
-
const out = [];
|
|
10776
|
-
for (let n = r.u(); n > 0; n--) {
|
|
10777
|
-
const begin = r.at;
|
|
10778
|
-
entry(r);
|
|
10779
|
-
out.push(bytes.subarray(begin, r.at));
|
|
10780
|
-
}
|
|
10781
|
-
if (r.at !== section2.end) throw new Error(`invalid wasm section ${section2.id}`);
|
|
10782
|
-
return out;
|
|
10783
|
-
}
|
|
10784
|
-
function appendLazyPlacement(bytes, functions, table) {
|
|
10785
|
-
const sections = wasmSections(bytes);
|
|
10786
|
-
const section2 = (id) => sections.find((s) => s.id === id);
|
|
10787
|
-
const imports = readImports2(bytes, sections);
|
|
10788
|
-
const changes = /* @__PURE__ */ new Map();
|
|
10789
|
-
let table64 = imports.table64;
|
|
10790
|
-
if (table64 === void 0) {
|
|
10791
|
-
if (!table) throw new Error("native image has no function table");
|
|
10792
|
-
table64 = table.table64;
|
|
10793
|
-
const found = section2(2);
|
|
10794
|
-
const header = found && wasmReader(bytes, found.start);
|
|
10795
|
-
const count = header ? header.u() : 0;
|
|
10796
|
-
const module2 = Buffer.from("primary");
|
|
10797
|
-
const name4 = Buffer.from(table.name);
|
|
10798
|
-
changes.set(
|
|
10799
|
-
2,
|
|
10800
|
-
vectorSection(2, count + 1, [
|
|
10801
|
-
found && header ? bytes.subarray(header.at, found.end) : new Uint8Array(),
|
|
10802
|
-
Buffer.from([
|
|
10803
|
-
...uleb2(module2.length),
|
|
10804
|
-
...module2,
|
|
10805
|
-
...uleb2(name4.length),
|
|
10806
|
-
...name4,
|
|
10807
|
-
1,
|
|
10808
|
-
112,
|
|
10809
|
-
table64 ? 4 : 0,
|
|
10810
|
-
0
|
|
10811
|
-
])
|
|
10812
|
-
])
|
|
10813
|
-
);
|
|
10814
|
-
}
|
|
10815
|
-
const types = entries(bytes, section2(1), (r) => {
|
|
10816
|
-
if (r.byte() !== 96) throw new Error("native image has a non-function type");
|
|
10817
|
-
for (let side = 0; side < 2; side++) for (let n = r.u(); n > 0; n--) skipValueType(r);
|
|
10818
|
-
});
|
|
10819
|
-
const declared = entries(bytes, section2(3), (r) => r.u());
|
|
10820
|
-
const bodies = entries(bytes, section2(10), (r) => r.skip(r.u()));
|
|
10821
|
-
const exports2 = entries(bytes, section2(7), readExport);
|
|
10822
|
-
const elements = entries(bytes, section2(9), skipElementSegment);
|
|
10823
|
-
const placementIndex = lastTableElement(elements) + 1;
|
|
10824
|
-
elements.splice(
|
|
10825
|
-
placementIndex,
|
|
10826
|
-
0,
|
|
10827
|
-
Buffer.from([1, 0, ...uleb2(functions.length), ...functions.flatMap(uleb2)])
|
|
10828
|
-
);
|
|
10829
|
-
const place2 = imports.functions + declared.length;
|
|
10830
|
-
const instructions = [
|
|
10831
|
-
0,
|
|
10832
|
-
32,
|
|
10833
|
-
1,
|
|
10834
|
-
...table64 ? [173] : [],
|
|
10835
|
-
32,
|
|
10836
|
-
0,
|
|
10837
|
-
65,
|
|
10838
|
-
1,
|
|
10839
|
-
252,
|
|
10840
|
-
12,
|
|
10841
|
-
...uleb2(placementIndex),
|
|
10842
|
-
0,
|
|
10843
|
-
11
|
|
10844
|
-
];
|
|
10845
|
-
const name3 = Buffer.from(NATIVE_DYLD_PLACE_EXPORT);
|
|
10846
|
-
return rewriteSections(
|
|
10847
|
-
bytes,
|
|
10848
|
-
sections,
|
|
10849
|
-
new Map([
|
|
10850
|
-
...changes,
|
|
10851
|
-
[
|
|
10852
|
-
1,
|
|
10853
|
-
vectorSection(1, types.length + 1, [
|
|
10854
|
-
...types,
|
|
10855
|
-
Buffer.from([96, 2, 127, 127, 0])
|
|
10856
|
-
])
|
|
10857
|
-
],
|
|
10858
|
-
[
|
|
10859
|
-
3,
|
|
10860
|
-
vectorSection(3, declared.length + 1, [
|
|
10861
|
-
...declared,
|
|
10862
|
-
Buffer.from(uleb2(types.length))
|
|
10863
|
-
])
|
|
10864
|
-
],
|
|
10865
|
-
[
|
|
10866
|
-
7,
|
|
10867
|
-
vectorSection(7, exports2.length + 1, [
|
|
10868
|
-
...exports2,
|
|
10869
|
-
Buffer.from([...uleb2(name3.length), ...name3, 0, ...uleb2(place2)])
|
|
10870
|
-
])
|
|
10871
|
-
],
|
|
10872
|
-
[9, vectorSection(9, elements.length, elements)],
|
|
10873
|
-
[
|
|
10874
|
-
10,
|
|
10875
|
-
vectorSection(10, bodies.length + 1, [
|
|
10876
|
-
...bodies,
|
|
10877
|
-
Buffer.from([...uleb2(instructions.length), ...instructions])
|
|
10878
|
-
])
|
|
10879
|
-
]
|
|
10880
|
-
])
|
|
10881
|
-
);
|
|
10882
|
-
}
|
|
10883
|
-
function skipConstant(r) {
|
|
10884
|
-
for (let op = r.byte(); op !== 11; op = r.byte()) {
|
|
10885
|
-
if (op === 65 || op === 66) r.s();
|
|
10886
|
-
else if (op === 35 || op === 210) r.u();
|
|
10887
|
-
else if (op === 208) r.s();
|
|
10888
|
-
else if (![106, 107, 108, 124, 125, 126].includes(op))
|
|
10889
|
-
throw new Error(`unsupported constant expression op ${op}`);
|
|
10890
|
-
}
|
|
10891
|
-
}
|
|
10892
|
-
function skipElementSegment(r) {
|
|
10893
|
-
const flags = r.u();
|
|
10894
|
-
if (flags > 7) throw new Error(`unsupported element segment flags ${flags}`);
|
|
10895
|
-
if ((flags & 3) === 2) r.u();
|
|
10896
|
-
if (!(flags & 1)) skipConstant(r);
|
|
10897
|
-
if (flags & 3) skipValueType(r);
|
|
10898
|
-
for (let count = r.u(); count > 0; count--)
|
|
10899
|
-
if (flags & 4) skipConstant(r);
|
|
10900
|
-
else r.u();
|
|
10901
|
-
}
|
|
10902
|
-
function placeGuestLazyFunctions(bytes, lazy) {
|
|
10903
|
-
const sections = wasmSections(bytes);
|
|
10904
|
-
const lazyIndex = new Map(lazy.map((name3, index) => [name3, index]));
|
|
10905
|
-
const functions = new Array(lazy.length);
|
|
10906
|
-
let found = 0;
|
|
10907
|
-
const kept = entries(
|
|
10908
|
-
bytes,
|
|
10909
|
-
sections.find((s) => s.id === 7),
|
|
10910
|
-
readExport
|
|
10911
|
-
).filter((entry) => {
|
|
10912
|
-
const r = wasmReader(entry, 0);
|
|
10913
|
-
const position = lazyIndex.get(r.name());
|
|
10914
|
-
const kind = r.byte();
|
|
10915
|
-
if (kind !== 0 || position === void 0) return true;
|
|
10916
|
-
functions[position] = r.u();
|
|
10917
|
-
found++;
|
|
10918
|
-
return false;
|
|
10919
|
-
});
|
|
10920
|
-
if (found !== lazy.length)
|
|
10921
|
-
throw new Error("guest link lost a lazy dlsym function export");
|
|
10922
|
-
return appendLazyPlacement(
|
|
10923
|
-
rewriteSections(bytes, sections, /* @__PURE__ */ new Map([[7, vectorSection(7, kept.length, kept)]])),
|
|
10924
|
-
functions
|
|
10925
|
-
);
|
|
10926
|
-
}
|
|
10927
|
-
function guestLazyExports(lazy) {
|
|
10928
|
-
return lazy.map((name3) => JSON.stringify(`--export=${name3}`)).join("\n");
|
|
10929
|
-
}
|
|
10930
|
-
var uleb2, SECTION_ORDER, readExport, lastTableElement;
|
|
10931
|
-
var init_swift_guest_dyld_functions = __esm({
|
|
10932
|
-
"src/swift-guest-dyld-functions.ts"() {
|
|
10933
|
-
"use strict";
|
|
10934
|
-
init_nativeWasmContract();
|
|
10935
|
-
init_swift_sdk_image_wasm();
|
|
10936
|
-
uleb2 = (value) => {
|
|
10937
|
-
const out = [];
|
|
10938
|
-
do {
|
|
10939
|
-
let byte = value % 128;
|
|
10940
|
-
value = Math.floor(value / 128);
|
|
10941
|
-
if (value) byte |= 128;
|
|
10942
|
-
out.push(byte);
|
|
10943
|
-
} while (value);
|
|
10944
|
-
return out;
|
|
10945
|
-
};
|
|
10946
|
-
SECTION_ORDER = [1, 2, 3, 4, 5, 13, 6, 7, 8, 9, 12, 10, 11];
|
|
10947
|
-
readExport = (r) => {
|
|
10948
|
-
r.name();
|
|
10949
|
-
r.byte();
|
|
10950
|
-
r.u();
|
|
10951
|
-
};
|
|
10952
|
-
lastTableElement = (segments) => segments.findLastIndex((segment) => (segment[0] & 3) !== 3);
|
|
10953
|
-
}
|
|
10954
|
-
});
|
|
10955
|
-
|
|
10956
|
-
// ../peach-kit/src/nativeDyldTableContract.ts
|
|
10957
|
-
var NATIVE_DYLD_TABLE_SECTION, NATIVE_DYLD_PACKS_SECTION;
|
|
10958
|
-
var init_nativeDyldTableContract = __esm({
|
|
10959
|
-
"../peach-kit/src/nativeDyldTableContract.ts"() {
|
|
10960
|
-
"use strict";
|
|
10961
|
-
NATIVE_DYLD_TABLE_SECTION = "peach.dyld-table-v1";
|
|
10962
|
-
NATIVE_DYLD_PACKS_SECTION = "peach.dyld-packs-v1";
|
|
10963
|
-
}
|
|
10964
|
-
});
|
|
10965
|
-
|
|
10966
10708
|
// src/swift-guest-image-ledger.ts
|
|
10967
10709
|
function readNumber(bytes, position) {
|
|
10968
10710
|
if (position < bytes.length) {
|
|
@@ -12621,7 +12363,7 @@ function sha256Buffer(bytes) {
|
|
|
12621
12363
|
return Buffer.from(new Bun.CryptoHasher("sha256").update(bytes).digest());
|
|
12622
12364
|
return (0, import_node_crypto11.createHash)("sha256").update(bytes).digest();
|
|
12623
12365
|
}
|
|
12624
|
-
function
|
|
12366
|
+
function uleb2(value) {
|
|
12625
12367
|
const bytes = [];
|
|
12626
12368
|
for (let rest = value; ; rest = Math.floor(rest / 128)) {
|
|
12627
12369
|
if (rest < 128) return [...bytes, rest];
|
|
@@ -12640,7 +12382,7 @@ function encodeGuestDyldTable(rows) {
|
|
|
12640
12382
|
value.writeBigUInt64LE(row.value);
|
|
12641
12383
|
const bytes = Buffer.concat([
|
|
12642
12384
|
row.bytes,
|
|
12643
|
-
Buffer.from([0, ...
|
|
12385
|
+
Buffer.from([0, ...uleb2(row.image), row.kind]),
|
|
12644
12386
|
value
|
|
12645
12387
|
]);
|
|
12646
12388
|
if (!current.length) firsts.push(row.bytes);
|
|
@@ -12681,69 +12423,323 @@ function moveGuestDyldTable(map, wasm, symbols, bindingValues = /* @__PURE__ */
|
|
|
12681
12423
|
taken.bytes.byteOffset,
|
|
12682
12424
|
taken.bytes.length
|
|
12683
12425
|
);
|
|
12684
|
-
const rows = symbols.map(({ name: name3, image }, index2) => {
|
|
12685
|
-
const binding = bindingValues.get(index2);
|
|
12686
|
-
return binding === void 0 ? { name: name3, image, kind: 0, value: view.getBigUint64(index2 * 8, true) } : { name: name3, image, kind: 1, value: BigInt(binding) };
|
|
12687
|
-
});
|
|
12688
|
-
const { index, packs } = encodeGuestDyldTable(rows);
|
|
12689
|
-
return writeWasmCustomSections(taken.wasm, [
|
|
12690
|
-
[NATIVE_DYLD_TABLE_SECTION, index],
|
|
12691
|
-
[NATIVE_DYLD_PACKS_SECTION, packs],
|
|
12692
|
-
...extraSections
|
|
12693
|
-
]);
|
|
12426
|
+
const rows = symbols.map(({ name: name3, image }, index2) => {
|
|
12427
|
+
const binding = bindingValues.get(index2);
|
|
12428
|
+
return binding === void 0 ? { name: name3, image, kind: 0, value: view.getBigUint64(index2 * 8, true) } : { name: name3, image, kind: 1, value: BigInt(binding) };
|
|
12429
|
+
});
|
|
12430
|
+
const { index, packs } = encodeGuestDyldTable(rows);
|
|
12431
|
+
return writeWasmCustomSections(taken.wasm, [
|
|
12432
|
+
[NATIVE_DYLD_TABLE_SECTION, index],
|
|
12433
|
+
[NATIVE_DYLD_PACKS_SECTION, packs],
|
|
12434
|
+
...extraSections
|
|
12435
|
+
]);
|
|
12436
|
+
}
|
|
12437
|
+
function guestDyldValueRange(map) {
|
|
12438
|
+
const suffix = `:(${GUEST_DYLD_VALUES_SECTION})`;
|
|
12439
|
+
let found;
|
|
12440
|
+
for (let at = map.indexOf(suffix); at !== -1; at = map.indexOf(suffix, at + suffix.length)) {
|
|
12441
|
+
const lineEnd = at + suffix.length;
|
|
12442
|
+
if (lineEnd < map.length && map.charCodeAt(lineEnd) !== 10) continue;
|
|
12443
|
+
const lineStart = map.lastIndexOf("\n", at) + 1;
|
|
12444
|
+
const line = map.slice(lineStart, lineEnd);
|
|
12445
|
+
const match = /^\s*([\da-f]+)\s+[\da-f]+\s+([\da-f]+)\s/.exec(line);
|
|
12446
|
+
if (!match) throw new Error("unreadable dyld values map line");
|
|
12447
|
+
if (found) throw new Error("link map has several dyld value sections");
|
|
12448
|
+
found = { address: parseInt(match[1], 16), length: parseInt(match[2], 16) };
|
|
12449
|
+
}
|
|
12450
|
+
return found;
|
|
12451
|
+
}
|
|
12452
|
+
var import_node_crypto11, import_node_zlib2, PACK_BYTES;
|
|
12453
|
+
var init_swift_guest_dyld_table = __esm({
|
|
12454
|
+
"src/swift-guest-dyld-table.ts"() {
|
|
12455
|
+
"use strict";
|
|
12456
|
+
import_node_crypto11 = require("node:crypto");
|
|
12457
|
+
import_node_zlib2 = require("node:zlib");
|
|
12458
|
+
init_nativeDyldTableContract();
|
|
12459
|
+
init_swift_guest_image_ledger();
|
|
12460
|
+
init_swift_guest_linked_spans();
|
|
12461
|
+
init_wasm_narrow_boundary();
|
|
12462
|
+
PACK_BYTES = 64 * 1024;
|
|
12463
|
+
}
|
|
12464
|
+
});
|
|
12465
|
+
|
|
12466
|
+
// ../../src/helpers/mapLimit.ts
|
|
12467
|
+
async function mapLimit(items, limit, worker) {
|
|
12468
|
+
const results = new Array(items.length);
|
|
12469
|
+
let next = 0;
|
|
12470
|
+
let failure;
|
|
12471
|
+
await Promise.all(
|
|
12472
|
+
Array.from({ length: Math.min(limit, items.length) }, async () => {
|
|
12473
|
+
while (!failure && next < items.length) {
|
|
12474
|
+
const index = next++;
|
|
12475
|
+
try {
|
|
12476
|
+
results[index] = await worker(items[index], index);
|
|
12477
|
+
} catch (error) {
|
|
12478
|
+
failure ??= { error };
|
|
12479
|
+
}
|
|
12480
|
+
}
|
|
12481
|
+
})
|
|
12482
|
+
);
|
|
12483
|
+
if (failure) throw failure.error;
|
|
12484
|
+
return results;
|
|
12485
|
+
}
|
|
12486
|
+
var init_mapLimit = __esm({
|
|
12487
|
+
"../../src/helpers/mapLimit.ts"() {
|
|
12488
|
+
"use strict";
|
|
12489
|
+
}
|
|
12490
|
+
});
|
|
12491
|
+
|
|
12492
|
+
// src/swift-guest-dyld-functions.ts
|
|
12493
|
+
function skipValueType(r) {
|
|
12494
|
+
const type = r.byte();
|
|
12495
|
+
if (type === 99 || type === 100) r.s();
|
|
12496
|
+
}
|
|
12497
|
+
function readImports2(bytes, sections) {
|
|
12498
|
+
let functions = 0;
|
|
12499
|
+
let table64;
|
|
12500
|
+
const imports = sections.find((s) => s.id === 2);
|
|
12501
|
+
if (imports) {
|
|
12502
|
+
const r = wasmReader(bytes, imports.start);
|
|
12503
|
+
for (let n = r.u(); n > 0; n--) {
|
|
12504
|
+
r.name();
|
|
12505
|
+
r.name();
|
|
12506
|
+
const kind = r.byte();
|
|
12507
|
+
if (kind === 0) {
|
|
12508
|
+
functions++;
|
|
12509
|
+
r.u();
|
|
12510
|
+
} else if (kind === 1 || kind === 2) {
|
|
12511
|
+
if (kind === 1) skipValueType(r);
|
|
12512
|
+
const flags = r.u();
|
|
12513
|
+
r.u();
|
|
12514
|
+
if (flags & 1) r.u();
|
|
12515
|
+
if (kind === 1) table64 ??= (flags & 4) !== 0;
|
|
12516
|
+
} else if (kind === 3) {
|
|
12517
|
+
skipValueType(r);
|
|
12518
|
+
r.byte();
|
|
12519
|
+
} else if (kind === 4) {
|
|
12520
|
+
r.byte();
|
|
12521
|
+
r.u();
|
|
12522
|
+
} else throw new Error(`unsupported wasm import kind ${kind}`);
|
|
12523
|
+
}
|
|
12524
|
+
}
|
|
12525
|
+
const tables = sections.find((s) => s.id === 4);
|
|
12526
|
+
if (table64 === void 0 && tables) {
|
|
12527
|
+
const r = wasmReader(bytes, tables.start);
|
|
12528
|
+
if (r.u()) {
|
|
12529
|
+
skipValueType(r);
|
|
12530
|
+
table64 = (r.u() & 4) !== 0;
|
|
12531
|
+
}
|
|
12532
|
+
}
|
|
12533
|
+
return { functions, table64 };
|
|
12534
|
+
}
|
|
12535
|
+
function vectorSection(id, count, parts) {
|
|
12536
|
+
const body = Buffer.concat([Buffer.from(uleb3(count)), ...parts]);
|
|
12537
|
+
return Buffer.concat([Buffer.from([id, ...uleb3(body.length)]), body]);
|
|
12538
|
+
}
|
|
12539
|
+
function rewriteSections(bytes, sections, changes) {
|
|
12540
|
+
const out = [bytes.subarray(0, 8)];
|
|
12541
|
+
const pending = new Map(changes);
|
|
12542
|
+
const flushBefore = (id) => {
|
|
12543
|
+
for (const [missing, section2] of pending) {
|
|
12544
|
+
if (SECTION_ORDER.indexOf(missing) >= SECTION_ORDER.indexOf(id)) continue;
|
|
12545
|
+
if (section2) out.push(section2);
|
|
12546
|
+
pending.delete(missing);
|
|
12547
|
+
}
|
|
12548
|
+
};
|
|
12549
|
+
for (const s of sections) {
|
|
12550
|
+
if (s.id !== 0) flushBefore(s.id);
|
|
12551
|
+
if (!pending.has(s.id)) {
|
|
12552
|
+
out.push(bytes.subarray(s.offset, s.end));
|
|
12553
|
+
continue;
|
|
12554
|
+
}
|
|
12555
|
+
const section2 = pending.get(s.id);
|
|
12556
|
+
pending.delete(s.id);
|
|
12557
|
+
if (section2) out.push(section2);
|
|
12558
|
+
}
|
|
12559
|
+
for (const section2 of pending.values()) if (section2) out.push(section2);
|
|
12560
|
+
return Buffer.concat(out);
|
|
12561
|
+
}
|
|
12562
|
+
function entries(bytes, section2, entry) {
|
|
12563
|
+
if (!section2) return [];
|
|
12564
|
+
const r = wasmReader(bytes, section2.start);
|
|
12565
|
+
const out = [];
|
|
12566
|
+
for (let n = r.u(); n > 0; n--) {
|
|
12567
|
+
const begin = r.at;
|
|
12568
|
+
entry(r);
|
|
12569
|
+
out.push(bytes.subarray(begin, r.at));
|
|
12570
|
+
}
|
|
12571
|
+
if (r.at !== section2.end) throw new Error(`invalid wasm section ${section2.id}`);
|
|
12572
|
+
return out;
|
|
12573
|
+
}
|
|
12574
|
+
function appendLazyPlacement(bytes, functions, table) {
|
|
12575
|
+
const sections = wasmSections(bytes);
|
|
12576
|
+
const section2 = (id) => sections.find((s) => s.id === id);
|
|
12577
|
+
const imports = readImports2(bytes, sections);
|
|
12578
|
+
const changes = /* @__PURE__ */ new Map();
|
|
12579
|
+
let table64 = imports.table64;
|
|
12580
|
+
if (table64 === void 0) {
|
|
12581
|
+
if (!table) throw new Error("native image has no function table");
|
|
12582
|
+
table64 = table.table64;
|
|
12583
|
+
const found = section2(2);
|
|
12584
|
+
const header = found && wasmReader(bytes, found.start);
|
|
12585
|
+
const count = header ? header.u() : 0;
|
|
12586
|
+
const module2 = Buffer.from("primary");
|
|
12587
|
+
const name4 = Buffer.from(table.name);
|
|
12588
|
+
changes.set(
|
|
12589
|
+
2,
|
|
12590
|
+
vectorSection(2, count + 1, [
|
|
12591
|
+
found && header ? bytes.subarray(header.at, found.end) : new Uint8Array(),
|
|
12592
|
+
Buffer.from([
|
|
12593
|
+
...uleb3(module2.length),
|
|
12594
|
+
...module2,
|
|
12595
|
+
...uleb3(name4.length),
|
|
12596
|
+
...name4,
|
|
12597
|
+
1,
|
|
12598
|
+
112,
|
|
12599
|
+
table64 ? 4 : 0,
|
|
12600
|
+
0
|
|
12601
|
+
])
|
|
12602
|
+
])
|
|
12603
|
+
);
|
|
12604
|
+
}
|
|
12605
|
+
const types = entries(bytes, section2(1), (r) => {
|
|
12606
|
+
if (r.byte() !== 96) throw new Error("native image has a non-function type");
|
|
12607
|
+
for (let side = 0; side < 2; side++) for (let n = r.u(); n > 0; n--) skipValueType(r);
|
|
12608
|
+
});
|
|
12609
|
+
const declared = entries(bytes, section2(3), (r) => r.u());
|
|
12610
|
+
const bodies = entries(bytes, section2(10), (r) => r.skip(r.u()));
|
|
12611
|
+
const exports2 = entries(bytes, section2(7), readExport);
|
|
12612
|
+
const elements = entries(bytes, section2(9), skipElementSegment);
|
|
12613
|
+
const placementIndex = lastTableElement(elements) + 1;
|
|
12614
|
+
elements.splice(
|
|
12615
|
+
placementIndex,
|
|
12616
|
+
0,
|
|
12617
|
+
Buffer.from([1, 0, ...uleb3(functions.length), ...functions.flatMap(uleb3)])
|
|
12618
|
+
);
|
|
12619
|
+
const place2 = imports.functions + declared.length;
|
|
12620
|
+
const instructions = [
|
|
12621
|
+
0,
|
|
12622
|
+
32,
|
|
12623
|
+
1,
|
|
12624
|
+
...table64 ? [173] : [],
|
|
12625
|
+
32,
|
|
12626
|
+
0,
|
|
12627
|
+
65,
|
|
12628
|
+
1,
|
|
12629
|
+
252,
|
|
12630
|
+
12,
|
|
12631
|
+
...uleb3(placementIndex),
|
|
12632
|
+
0,
|
|
12633
|
+
11
|
|
12634
|
+
];
|
|
12635
|
+
const name3 = Buffer.from(NATIVE_DYLD_PLACE_EXPORT);
|
|
12636
|
+
return rewriteSections(
|
|
12637
|
+
bytes,
|
|
12638
|
+
sections,
|
|
12639
|
+
new Map([
|
|
12640
|
+
...changes,
|
|
12641
|
+
[
|
|
12642
|
+
1,
|
|
12643
|
+
vectorSection(1, types.length + 1, [
|
|
12644
|
+
...types,
|
|
12645
|
+
Buffer.from([96, 2, 127, 127, 0])
|
|
12646
|
+
])
|
|
12647
|
+
],
|
|
12648
|
+
[
|
|
12649
|
+
3,
|
|
12650
|
+
vectorSection(3, declared.length + 1, [
|
|
12651
|
+
...declared,
|
|
12652
|
+
Buffer.from(uleb3(types.length))
|
|
12653
|
+
])
|
|
12654
|
+
],
|
|
12655
|
+
[
|
|
12656
|
+
7,
|
|
12657
|
+
vectorSection(7, exports2.length + 1, [
|
|
12658
|
+
...exports2,
|
|
12659
|
+
Buffer.from([...uleb3(name3.length), ...name3, 0, ...uleb3(place2)])
|
|
12660
|
+
])
|
|
12661
|
+
],
|
|
12662
|
+
[9, vectorSection(9, elements.length, elements)],
|
|
12663
|
+
[
|
|
12664
|
+
10,
|
|
12665
|
+
vectorSection(10, bodies.length + 1, [
|
|
12666
|
+
...bodies,
|
|
12667
|
+
Buffer.from([...uleb3(instructions.length), ...instructions])
|
|
12668
|
+
])
|
|
12669
|
+
]
|
|
12670
|
+
])
|
|
12671
|
+
);
|
|
12694
12672
|
}
|
|
12695
|
-
function
|
|
12696
|
-
|
|
12697
|
-
|
|
12698
|
-
|
|
12699
|
-
|
|
12700
|
-
if (
|
|
12701
|
-
|
|
12702
|
-
const line = map.slice(lineStart, lineEnd);
|
|
12703
|
-
const match = /^\s*([\da-f]+)\s+[\da-f]+\s+([\da-f]+)\s/.exec(line);
|
|
12704
|
-
if (!match) throw new Error("unreadable dyld values map line");
|
|
12705
|
-
if (found) throw new Error("link map has several dyld value sections");
|
|
12706
|
-
found = { address: parseInt(match[1], 16), length: parseInt(match[2], 16) };
|
|
12673
|
+
function skipConstant(r) {
|
|
12674
|
+
for (let op = r.byte(); op !== 11; op = r.byte()) {
|
|
12675
|
+
if (op === 65 || op === 66) r.s();
|
|
12676
|
+
else if (op === 35 || op === 210) r.u();
|
|
12677
|
+
else if (op === 208) r.s();
|
|
12678
|
+
else if (![106, 107, 108, 124, 125, 126].includes(op))
|
|
12679
|
+
throw new Error(`unsupported constant expression op ${op}`);
|
|
12707
12680
|
}
|
|
12708
|
-
return found;
|
|
12709
12681
|
}
|
|
12710
|
-
|
|
12711
|
-
|
|
12712
|
-
|
|
12713
|
-
|
|
12714
|
-
|
|
12715
|
-
|
|
12716
|
-
|
|
12717
|
-
|
|
12718
|
-
|
|
12719
|
-
|
|
12720
|
-
|
|
12721
|
-
|
|
12722
|
-
|
|
12723
|
-
|
|
12724
|
-
|
|
12725
|
-
|
|
12726
|
-
|
|
12727
|
-
|
|
12728
|
-
|
|
12729
|
-
|
|
12730
|
-
|
|
12731
|
-
|
|
12732
|
-
|
|
12733
|
-
|
|
12734
|
-
|
|
12735
|
-
|
|
12736
|
-
|
|
12737
|
-
|
|
12738
|
-
|
|
12739
|
-
|
|
12682
|
+
function skipElementSegment(r) {
|
|
12683
|
+
const flags = r.u();
|
|
12684
|
+
if (flags > 7) throw new Error(`unsupported element segment flags ${flags}`);
|
|
12685
|
+
if ((flags & 3) === 2) r.u();
|
|
12686
|
+
if (!(flags & 1)) skipConstant(r);
|
|
12687
|
+
if (flags & 3) skipValueType(r);
|
|
12688
|
+
for (let count = r.u(); count > 0; count--)
|
|
12689
|
+
if (flags & 4) skipConstant(r);
|
|
12690
|
+
else r.u();
|
|
12691
|
+
}
|
|
12692
|
+
function placeGuestLazyFunctions(bytes, lazy) {
|
|
12693
|
+
const sections = wasmSections(bytes);
|
|
12694
|
+
const lazyIndex = new Map(lazy.map((name3, index) => [name3, index]));
|
|
12695
|
+
const functions = new Array(lazy.length);
|
|
12696
|
+
let found = 0;
|
|
12697
|
+
const kept = entries(
|
|
12698
|
+
bytes,
|
|
12699
|
+
sections.find((s) => s.id === 7),
|
|
12700
|
+
readExport
|
|
12701
|
+
).filter((entry) => {
|
|
12702
|
+
const r = wasmReader(entry, 0);
|
|
12703
|
+
const position = lazyIndex.get(r.name());
|
|
12704
|
+
const kind = r.byte();
|
|
12705
|
+
if (kind !== 0 || position === void 0) return true;
|
|
12706
|
+
functions[position] = r.u();
|
|
12707
|
+
found++;
|
|
12708
|
+
return false;
|
|
12709
|
+
});
|
|
12710
|
+
if (found !== lazy.length)
|
|
12711
|
+
throw new Error("guest link lost a lazy dlsym function export");
|
|
12712
|
+
return appendLazyPlacement(
|
|
12713
|
+
rewriteSections(bytes, sections, /* @__PURE__ */ new Map([[7, vectorSection(7, kept.length, kept)]])),
|
|
12714
|
+
functions
|
|
12740
12715
|
);
|
|
12741
|
-
if (failure) throw failure.error;
|
|
12742
|
-
return results;
|
|
12743
12716
|
}
|
|
12744
|
-
|
|
12745
|
-
|
|
12717
|
+
function guestLazyExports(lazy) {
|
|
12718
|
+
return lazy.map((name3) => JSON.stringify(`--export=${name3}`)).join("\n");
|
|
12719
|
+
}
|
|
12720
|
+
var uleb3, SECTION_ORDER, readExport, lastTableElement;
|
|
12721
|
+
var init_swift_guest_dyld_functions = __esm({
|
|
12722
|
+
"src/swift-guest-dyld-functions.ts"() {
|
|
12746
12723
|
"use strict";
|
|
12724
|
+
init_nativeWasmContract();
|
|
12725
|
+
init_swift_sdk_image_wasm();
|
|
12726
|
+
uleb3 = (value) => {
|
|
12727
|
+
const out = [];
|
|
12728
|
+
do {
|
|
12729
|
+
let byte = value % 128;
|
|
12730
|
+
value = Math.floor(value / 128);
|
|
12731
|
+
if (value) byte |= 128;
|
|
12732
|
+
out.push(byte);
|
|
12733
|
+
} while (value);
|
|
12734
|
+
return out;
|
|
12735
|
+
};
|
|
12736
|
+
SECTION_ORDER = [1, 2, 3, 4, 5, 13, 6, 7, 8, 9, 12, 10, 11];
|
|
12737
|
+
readExport = (r) => {
|
|
12738
|
+
r.name();
|
|
12739
|
+
r.byte();
|
|
12740
|
+
r.u();
|
|
12741
|
+
};
|
|
12742
|
+
lastTableElement = (segments) => segments.findLastIndex((segment) => (segment[0] & 3) !== 3);
|
|
12747
12743
|
}
|
|
12748
12744
|
});
|
|
12749
12745
|
|
|
@@ -21921,9 +21917,11 @@ async function compileGuestLink(options) {
|
|
|
21921
21917
|
return [...source, ...runtime].sort((a, b) => a.image - b.image);
|
|
21922
21918
|
};
|
|
21923
21919
|
const sdk = options.sdkImage;
|
|
21924
|
-
const sdkCallers = sdk
|
|
21925
|
-
const sdkObjects =
|
|
21926
|
-
|
|
21920
|
+
const sdkCallers = sdk.sdkInterface.guestCallers;
|
|
21921
|
+
const sdkObjects = (await Promise.resolve().then(() => (init_swift_sdk_image(), swift_sdk_image_exports))).readSwiftSdkManifestIndex(
|
|
21922
|
+
sdk
|
|
21923
|
+
).guestObjects;
|
|
21924
|
+
if (!sdkCallers || !sdkObjects)
|
|
21927
21925
|
throw new Error("the SDK image has no guest link manifest");
|
|
21928
21926
|
const result = await linkPrunedGuestImages({
|
|
21929
21927
|
buildDirectory: options.buildDirectory,
|
|
@@ -21936,14 +21934,14 @@ async function compileGuestLink(options) {
|
|
|
21936
21934
|
ledgerDataImage: 0,
|
|
21937
21935
|
framework: catalogs.framework,
|
|
21938
21936
|
sdkProducts: null,
|
|
21939
|
-
sharedSdk:
|
|
21937
|
+
sharedSdk: {
|
|
21940
21938
|
callers: sdkCallers,
|
|
21941
21939
|
hasContainingObject: (identity) => sdkObjects[sdkGuestObjectKey(identity)] !== void 0
|
|
21942
|
-
}
|
|
21943
|
-
onSplitInputs:
|
|
21940
|
+
},
|
|
21941
|
+
onSplitInputs: (value) => {
|
|
21944
21942
|
splitInputs = value;
|
|
21945
|
-
}
|
|
21946
|
-
deferFinalLink:
|
|
21943
|
+
},
|
|
21944
|
+
deferFinalLink: true,
|
|
21947
21945
|
onDyldRows: (rows) => {
|
|
21948
21946
|
lazyFunctions = rows.lazyFunctions;
|
|
21949
21947
|
dyldSymbols = rows.dyldSymbols;
|
|
@@ -22211,191 +22209,165 @@ async function compileGuestLink(options) {
|
|
|
22211
22209
|
}
|
|
22212
22210
|
});
|
|
22213
22211
|
if (!reserved || !projectionObject) throw new Error("guest projection was not reserved");
|
|
22214
|
-
|
|
22215
|
-
|
|
22216
|
-
|
|
22217
|
-
|
|
22218
|
-
|
|
22219
|
-
|
|
22220
|
-
|
|
22221
|
-
|
|
22222
|
-
|
|
22223
|
-
|
|
22224
|
-
|
|
22225
|
-
|
|
22226
|
-
|
|
22227
|
-
|
|
22228
|
-
|
|
22229
|
-
|
|
22230
|
-
|
|
22231
|
-
|
|
22232
|
-
|
|
22233
|
-
|
|
22234
|
-
|
|
22235
|
-
|
|
22236
|
-
|
|
22237
|
-
|
|
22238
|
-
|
|
22239
|
-
|
|
22240
|
-
|
|
22241
|
-
|
|
22242
|
-
|
|
22243
|
-
|
|
22244
|
-
|
|
22245
|
-
|
|
22246
|
-
|
|
22212
|
+
try {
|
|
22213
|
+
if (!splitInputs) throw new Error("guest link did not select shared SDK inputs");
|
|
22214
|
+
const {
|
|
22215
|
+
createSwiftSdkBinding: createSwiftSdkBinding2,
|
|
22216
|
+
linkSwiftAppModule: linkSwiftAppModule2,
|
|
22217
|
+
readSwiftSdkUsage: readSwiftSdkUsage2,
|
|
22218
|
+
swiftAppModuleThunkSection: swiftAppModuleThunkSection2,
|
|
22219
|
+
swiftSdkProjectionSpans: swiftSdkProjectionSpans2
|
|
22220
|
+
} = await Promise.resolve().then(() => (init_swift_sdk_app_module(), swift_sdk_app_module_exports));
|
|
22221
|
+
const project = options.project;
|
|
22222
|
+
const work = project ? (0, import_node_fs39.mkdtempSync)(import_node_path39.default.join(directory, "app-module-")) : import_node_path39.default.join(directory, "app-module");
|
|
22223
|
+
if (project) (0, import_node_fs39.chownSync)(work, project.uid, project.gid);
|
|
22224
|
+
else (0, import_node_fs39.mkdirSync)(work, { recursive: true });
|
|
22225
|
+
const layoutMap = import_node_path39.default.join(work, "app.map");
|
|
22226
|
+
let appProjectionObject = projectionObject;
|
|
22227
|
+
const owners = new Map(splitInputs.appObjects).set(appProjectionObject, 0);
|
|
22228
|
+
const sdkObjectKeys = /* @__PURE__ */ new Map();
|
|
22229
|
+
const sdkObjectImages = /* @__PURE__ */ new Map();
|
|
22230
|
+
const sdkProductImages = new Map(prepared?.sdkProducts.images);
|
|
22231
|
+
for (const [file, { image, product, identity }] of splitInputs.sdkObjects) {
|
|
22232
|
+
const key = sdkGuestObjectKey(identity);
|
|
22233
|
+
sdkObjectKeys.set(file, key);
|
|
22234
|
+
sdkObjectImages.set(key, image);
|
|
22235
|
+
const priorImage = sdkProductImages.get(product);
|
|
22236
|
+
if (priorImage !== void 0 && priorImage !== image)
|
|
22237
|
+
throw new Error(`SDK product ${product} has several guest images`);
|
|
22238
|
+
sdkProductImages.set(product, image);
|
|
22239
|
+
}
|
|
22240
|
+
const linkedModule = import_node_path39.default.join(work, "app.wasm");
|
|
22241
|
+
const sdkSpans = swiftSdkProjectionSpans2(
|
|
22242
|
+
sdk,
|
|
22243
|
+
(object4, product) => sdkObjectImages.get(object4) ?? sdkProductImages.get(product)
|
|
22244
|
+
);
|
|
22245
|
+
const compileAppProjection = (source) => {
|
|
22246
|
+
const projectionSource = import_node_path39.default.join(work, "projection.c");
|
|
22247
|
+
const nextObject = import_node_path39.default.join(work, "projection.o");
|
|
22248
|
+
(0, import_node_fs39.writeFileSync)(projectionSource, source);
|
|
22249
|
+
(0, import_node_child_process26.execFileSync)(
|
|
22250
|
+
import_node_path39.default.join(options.toolchainBin, "clang"),
|
|
22251
|
+
[...clangOptions, "-c", projectionSource, "-o", nextObject],
|
|
22252
|
+
{ stdio: "pipe" }
|
|
22247
22253
|
);
|
|
22248
|
-
|
|
22249
|
-
|
|
22250
|
-
|
|
22251
|
-
|
|
22252
|
-
|
|
22253
|
-
|
|
22254
|
-
|
|
22255
|
-
|
|
22256
|
-
|
|
22257
|
-
|
|
22258
|
-
|
|
22259
|
-
|
|
22260
|
-
|
|
22254
|
+
if (nextObject !== appProjectionObject) {
|
|
22255
|
+
owners.delete(appProjectionObject);
|
|
22256
|
+
appProjectionObject = nextObject;
|
|
22257
|
+
owners.set(appProjectionObject, 0);
|
|
22258
|
+
}
|
|
22259
|
+
};
|
|
22260
|
+
let storage = reserved;
|
|
22261
|
+
if (sdkSpans.length > 0) {
|
|
22262
|
+
const sdkCounts = guestProjectionRegionCounts(storage.images.length, sdkSpans);
|
|
22263
|
+
storage = reserveGuestProjectionStorage(
|
|
22264
|
+
storage.images,
|
|
22265
|
+
storage.capacities.map((capacity, index) => ({
|
|
22266
|
+
...capacity,
|
|
22267
|
+
regions: capacity.regions + sdkCounts[index] + 16
|
|
22268
|
+
}))
|
|
22269
|
+
);
|
|
22270
|
+
compileAppProjection(storage.source);
|
|
22271
|
+
}
|
|
22272
|
+
let precomputedSymbols;
|
|
22273
|
+
if (splitInputs.appReferencedSymbols && splitInputs.appDefinedSymbols) {
|
|
22274
|
+
const referenced = new Set(splitInputs.appReferencedSymbols);
|
|
22275
|
+
const defined = new Set(splitInputs.appDefinedSymbols);
|
|
22276
|
+
const projSyms = guestWasmSymbols((0, import_node_fs39.readFileSync)(appProjectionObject));
|
|
22277
|
+
for (const name3 of projSyms.undefined) referenced.add(name3);
|
|
22278
|
+
for (const name3 of projSyms.defined) defined.add(name3);
|
|
22279
|
+
precomputedSymbols = { referenced, defined };
|
|
22280
|
+
}
|
|
22281
|
+
for (; ; ) {
|
|
22282
|
+
const link = await linkSwiftAppModule2({
|
|
22283
|
+
objects: [...owners.keys()],
|
|
22284
|
+
lazyFunctions: splitInputs.lazyFunctions,
|
|
22285
|
+
toolchainBin: options.toolchainBin,
|
|
22286
|
+
sdk,
|
|
22287
|
+
work,
|
|
22288
|
+
output: options.optimized,
|
|
22289
|
+
optimize: options.optimize,
|
|
22290
|
+
layoutMap,
|
|
22291
|
+
project,
|
|
22292
|
+
precomputedSymbols,
|
|
22293
|
+
loweringCache: project ? void 0 : {
|
|
22294
|
+
file: import_node_path39.default.join(
|
|
22295
|
+
options.buildDirectory,
|
|
22296
|
+
".build",
|
|
22297
|
+
"peach-app-module-lowered.wasm"
|
|
22298
|
+
),
|
|
22299
|
+
compilerDigest: options.compilerDigest
|
|
22261
22300
|
}
|
|
22262
|
-
};
|
|
22263
|
-
|
|
22264
|
-
|
|
22265
|
-
|
|
22301
|
+
});
|
|
22302
|
+
const map = (0, import_node_fs39.readFileSync)(
|
|
22303
|
+
project ? projectOutputFile(work, layoutMap, project) : layoutMap,
|
|
22304
|
+
"utf8"
|
|
22305
|
+
);
|
|
22306
|
+
const values = guestDyldValueRange(map);
|
|
22307
|
+
const bindingRows = /* @__PURE__ */ new Map();
|
|
22308
|
+
const data = [];
|
|
22309
|
+
for (let at = 0; at < link.linkage.data.length; at += 3) {
|
|
22310
|
+
const address = link.linkage.data[at];
|
|
22311
|
+
const size = link.linkage.data[at + 1];
|
|
22312
|
+
const value = link.linkage.data[at + 2];
|
|
22313
|
+
if (values && address >= values.address && address < values.address + values.length) {
|
|
22314
|
+
if (size !== 8 || (address - values.address) % 8)
|
|
22315
|
+
throw new Error("sdk binding splits a dyld value");
|
|
22316
|
+
bindingRows.set((address - values.address) / 8, value);
|
|
22317
|
+
} else data.push(address, size, value);
|
|
22318
|
+
}
|
|
22319
|
+
const linked = (0, import_node_fs39.readFileSync)(
|
|
22320
|
+
project ? projectOutputFile(work, linkedModule, project) : linkedModule
|
|
22321
|
+
);
|
|
22322
|
+
const required = guestProjectionRegionCounts(storage.images.length, [
|
|
22323
|
+
...guestLinkedSpans(map, linked, linked, owners, splitInputs.appSections, true),
|
|
22324
|
+
...sdkSpans
|
|
22325
|
+
]);
|
|
22326
|
+
if (storage.capacities.some(({ regions }, index) => required[index] > regions)) {
|
|
22266
22327
|
storage = reserveGuestProjectionStorage(
|
|
22267
22328
|
storage.images,
|
|
22268
|
-
storage.capacities.map((capacity, index) =>
|
|
22269
|
-
|
|
22270
|
-
regions: capacity.regions
|
|
22271
|
-
})
|
|
22329
|
+
storage.capacities.map((capacity, index) => {
|
|
22330
|
+
const count = required[index];
|
|
22331
|
+
return count > capacity.regions ? { ...capacity, regions: Math.max(count, capacity.regions * 2) } : capacity;
|
|
22332
|
+
})
|
|
22272
22333
|
);
|
|
22273
22334
|
compileAppProjection(storage.source);
|
|
22335
|
+
continue;
|
|
22274
22336
|
}
|
|
22275
|
-
|
|
22276
|
-
|
|
22277
|
-
|
|
22278
|
-
|
|
22279
|
-
|
|
22280
|
-
|
|
22281
|
-
|
|
22282
|
-
|
|
22283
|
-
}
|
|
22284
|
-
|
|
22285
|
-
|
|
22286
|
-
objects: [...owners.keys()],
|
|
22287
|
-
lazyFunctions: splitInputs.lazyFunctions,
|
|
22288
|
-
toolchainBin: options.toolchainBin,
|
|
22289
|
-
sdk,
|
|
22290
|
-
work,
|
|
22291
|
-
output: options.optimized,
|
|
22292
|
-
optimize: options.optimize,
|
|
22293
|
-
layoutMap,
|
|
22294
|
-
project,
|
|
22295
|
-
precomputedSymbols,
|
|
22296
|
-
loweringCache: project ? void 0 : {
|
|
22297
|
-
file: import_node_path39.default.join(
|
|
22298
|
-
options.buildDirectory,
|
|
22299
|
-
".build",
|
|
22300
|
-
"peach-app-module-lowered.wasm"
|
|
22301
|
-
),
|
|
22302
|
-
compilerDigest: options.compilerDigest
|
|
22303
|
-
}
|
|
22304
|
-
});
|
|
22305
|
-
const map2 = (0, import_node_fs39.readFileSync)(
|
|
22306
|
-
project ? projectOutputFile(work, layoutMap, project) : layoutMap,
|
|
22307
|
-
"utf8"
|
|
22308
|
-
);
|
|
22309
|
-
const values = guestDyldValueRange(map2);
|
|
22310
|
-
const bindingRows = /* @__PURE__ */ new Map();
|
|
22311
|
-
const data = [];
|
|
22312
|
-
for (let at = 0; at < link.linkage.data.length; at += 3) {
|
|
22313
|
-
const address = link.linkage.data[at];
|
|
22314
|
-
const size = link.linkage.data[at + 1];
|
|
22315
|
-
const value = link.linkage.data[at + 2];
|
|
22316
|
-
if (values && address >= values.address && address < values.address + values.length) {
|
|
22317
|
-
if (size !== 8 || (address - values.address) % 8)
|
|
22318
|
-
throw new Error("sdk binding splits a dyld value");
|
|
22319
|
-
bindingRows.set((address - values.address) / 8, value);
|
|
22320
|
-
} else data.push(address, size, value);
|
|
22321
|
-
}
|
|
22322
|
-
const linked = (0, import_node_fs39.readFileSync)(
|
|
22323
|
-
project ? projectOutputFile(work, linkedModule, project) : linkedModule
|
|
22324
|
-
);
|
|
22325
|
-
const required = guestProjectionRegionCounts(storage.images.length, [
|
|
22326
|
-
...guestLinkedSpans(map2, linked, linked, owners, splitInputs.appSections, true),
|
|
22327
|
-
...sdkSpans
|
|
22328
|
-
]);
|
|
22329
|
-
if (storage.capacities.some(({ regions }, index) => required[index] > regions)) {
|
|
22330
|
-
storage = reserveGuestProjectionStorage(
|
|
22331
|
-
storage.images,
|
|
22332
|
-
storage.capacities.map((capacity, index) => {
|
|
22333
|
-
const count = required[index];
|
|
22334
|
-
return count > capacity.regions ? { ...capacity, regions: Math.max(count, capacity.regions * 2) } : capacity;
|
|
22335
|
-
})
|
|
22336
|
-
);
|
|
22337
|
-
compileAppProjection(storage.source);
|
|
22338
|
-
continue;
|
|
22339
|
-
}
|
|
22340
|
-
options.onStage("lowering the app image");
|
|
22341
|
-
const lowerPromise = link.lower();
|
|
22342
|
-
await new Promise((resolve) => setImmediate(resolve));
|
|
22343
|
-
let binding;
|
|
22344
|
-
try {
|
|
22345
|
-
if (result.finalLinkDone) await result.finalLinkDone;
|
|
22346
|
-
const usage = readSwiftSdkUsage2(result.mapPath, options.output, sdkObjectKeys);
|
|
22347
|
-
binding = createSwiftSdkBinding2({ ...link.linkage, data }, sdk, usage);
|
|
22348
|
-
} catch (error) {
|
|
22349
|
-
await Promise.allSettled([lowerPromise]);
|
|
22350
|
-
throw error;
|
|
22351
|
-
}
|
|
22352
|
-
await lowerPromise;
|
|
22353
|
-
const finalized = finalizeGuestProjectionStorage({
|
|
22354
|
-
map: map2,
|
|
22355
|
-
linked,
|
|
22356
|
-
optimized: (0, import_node_fs39.readFileSync)(options.optimized),
|
|
22357
|
-
owners,
|
|
22358
|
-
sectionOwners: splitInputs.appSections,
|
|
22359
|
-
projectionObject: appProjectionObject,
|
|
22360
|
-
reserved: storage,
|
|
22361
|
-
sdkSpans
|
|
22362
|
-
});
|
|
22363
|
-
(0, import_node_fs39.writeFileSync)(
|
|
22364
|
-
options.optimized,
|
|
22365
|
-
moveGuestDyldTable(map2, finalized.wasm, splitInputs.dyldSymbols, bindingRows, [
|
|
22366
|
-
swiftAppModuleThunkSection2(finalized.wasm)
|
|
22367
|
-
])
|
|
22368
|
-
);
|
|
22369
|
-
return binding;
|
|
22337
|
+
options.onStage("lowering the app image");
|
|
22338
|
+
const lowerPromise = link.lower();
|
|
22339
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
22340
|
+
let binding;
|
|
22341
|
+
try {
|
|
22342
|
+
if (result.finalLinkDone) await result.finalLinkDone;
|
|
22343
|
+
const usage = readSwiftSdkUsage2(result.mapPath, options.output, sdkObjectKeys);
|
|
22344
|
+
binding = createSwiftSdkBinding2({ ...link.linkage, data }, sdk, usage);
|
|
22345
|
+
} catch (error) {
|
|
22346
|
+
await Promise.allSettled([lowerPromise]);
|
|
22347
|
+
throw error;
|
|
22370
22348
|
}
|
|
22371
|
-
|
|
22372
|
-
|
|
22349
|
+
await lowerPromise;
|
|
22350
|
+
const finalized = finalizeGuestProjectionStorage({
|
|
22351
|
+
map,
|
|
22352
|
+
linked,
|
|
22353
|
+
optimized: (0, import_node_fs39.readFileSync)(options.optimized),
|
|
22354
|
+
owners,
|
|
22355
|
+
sectionOwners: splitInputs.appSections,
|
|
22356
|
+
projectionObject: appProjectionObject,
|
|
22357
|
+
reserved: storage,
|
|
22358
|
+
sdkSpans
|
|
22359
|
+
});
|
|
22360
|
+
(0, import_node_fs39.writeFileSync)(
|
|
22361
|
+
options.optimized,
|
|
22362
|
+
moveGuestDyldTable(map, finalized.wasm, splitInputs.dyldSymbols, bindingRows, [
|
|
22363
|
+
swiftAppModuleThunkSection2(finalized.wasm)
|
|
22364
|
+
])
|
|
22365
|
+
);
|
|
22366
|
+
return binding;
|
|
22373
22367
|
}
|
|
22368
|
+
} finally {
|
|
22369
|
+
if (result.finalLinkDone) await Promise.allSettled([result.finalLinkDone]);
|
|
22374
22370
|
}
|
|
22375
|
-
options.onStage("lowering the app image");
|
|
22376
|
-
await lowerWasm(options.output, options.optimized, {
|
|
22377
|
-
optimize: options.optimize,
|
|
22378
|
-
skipPasses: ["duplicate-function-elimination"],
|
|
22379
|
-
wideExports: lazyFunctions
|
|
22380
|
-
});
|
|
22381
|
-
if (lazyFunctions.length)
|
|
22382
|
-
(0, import_node_fs39.writeFileSync)(
|
|
22383
|
-
options.optimized,
|
|
22384
|
-
placeGuestLazyFunctions((0, import_node_fs39.readFileSync)(options.optimized), lazyFunctions)
|
|
22385
|
-
);
|
|
22386
|
-
const map = (0, import_node_fs39.readFileSync)(result.mapPath, "utf8");
|
|
22387
|
-
let optimized = (0, import_node_fs39.readFileSync)(options.optimized);
|
|
22388
|
-
if (/ __peach_guest_images$/m.test(map))
|
|
22389
|
-
optimized = finalizeGuestProjectionStorage({
|
|
22390
|
-
map,
|
|
22391
|
-
linked: (0, import_node_fs39.readFileSync)(options.output),
|
|
22392
|
-
optimized,
|
|
22393
|
-
owners: result.owners,
|
|
22394
|
-
sectionOwners: result.generatedSectionOwners,
|
|
22395
|
-
projectionObject,
|
|
22396
|
-
reserved
|
|
22397
|
-
}).wasm;
|
|
22398
|
-
(0, import_node_fs39.writeFileSync)(options.optimized, moveGuestDyldTable(map, optimized, dyldSymbols));
|
|
22399
22371
|
}
|
|
22400
22372
|
var import_node_child_process26, import_node_fs39, import_node_path39;
|
|
22401
22373
|
var init_swift_guest_compile = __esm({
|
|
@@ -22405,7 +22377,6 @@ var init_swift_guest_compile = __esm({
|
|
|
22405
22377
|
import_node_fs39 = require("node:fs");
|
|
22406
22378
|
import_node_path39 = __toESM(require("node:path"), 1);
|
|
22407
22379
|
init_swift_guest_archive();
|
|
22408
|
-
init_swift_guest_dyld_functions();
|
|
22409
22380
|
init_swift_guest_dyld_table();
|
|
22410
22381
|
init_swift_guest_link();
|
|
22411
22382
|
init_swift_guest_linked_spans();
|
|
@@ -22419,7 +22390,6 @@ var init_swift_guest_compile = __esm({
|
|
|
22419
22390
|
init_swift_toolchain();
|
|
22420
22391
|
init_swift_wasm_prune();
|
|
22421
22392
|
init_swiftTargetContract();
|
|
22422
|
-
init_wasm_optimize();
|
|
22423
22393
|
}
|
|
22424
22394
|
});
|
|
22425
22395
|
|
|
@@ -27566,20 +27536,17 @@ function readCompiledArtifact(directory, hash) {
|
|
|
27566
27536
|
const gzip2 = (0, import_node_fs47.readFileSync)(import_node_path49.default.join(directory, "icu.gz"));
|
|
27567
27537
|
if ((0, import_node_crypto32.createHash)("sha256").update(bytes).digest("hex") !== receipt.wasm || (0, import_node_crypto32.createHash)("sha256").update(gzip2).digest("hex") !== receipt.icu || bytes.length <= 8 || bytes.readUInt32LE(0) !== 1836278016 || bytes.readUInt32LE(4) !== 1)
|
|
27568
27538
|
return null;
|
|
27569
|
-
|
|
27570
|
-
|
|
27571
|
-
|
|
27572
|
-
|
|
27573
|
-
|
|
27574
|
-
|
|
27575
|
-
|
|
27576
|
-
|
|
27577
|
-
|
|
27578
|
-
|
|
27579
|
-
|
|
27580
|
-
binding: { bytes: binding, sha256: image.binding }
|
|
27581
|
-
};
|
|
27582
|
-
}
|
|
27539
|
+
if (!("sdk" in receipt)) return null;
|
|
27540
|
+
const image = receipt.sdk;
|
|
27541
|
+
if (!isRecord(image) || typeof image.key !== "string" || typeof image.sha256 !== "string" || typeof image.binding !== "string")
|
|
27542
|
+
return null;
|
|
27543
|
+
const binding = (0, import_node_fs47.readFileSync)(import_node_path49.default.join(directory, "sdk-binding.bin"));
|
|
27544
|
+
if ((0, import_node_crypto32.createHash)("sha256").update(binding).digest("hex") !== image.binding) return null;
|
|
27545
|
+
const sdk = {
|
|
27546
|
+
key: image.key,
|
|
27547
|
+
sha256: image.sha256,
|
|
27548
|
+
binding: { bytes: binding, sha256: image.binding }
|
|
27549
|
+
};
|
|
27583
27550
|
return { hash, bytes, icu: { sha256: receipt.icu, gzip: gzip2 }, sdk };
|
|
27584
27551
|
} catch (error) {
|
|
27585
27552
|
if (error instanceof SyntaxError || error instanceof Error && "code" in error && error.code === "ENOENT")
|
|
@@ -28510,13 +28477,12 @@ async function compileSwiftProjectOnce(sources, options) {
|
|
|
28510
28477
|
sources: import_node_path49.default.join(root, "Sources", "App"),
|
|
28511
28478
|
multi: compileTargets(input).length > 0
|
|
28512
28479
|
};
|
|
28513
|
-
const
|
|
28514
|
-
const sdkImage = sdkModule ? await (await Promise.resolve().then(() => (init_swift_sdk_image(), swift_sdk_image_exports))).buildSwiftSdkImage(
|
|
28480
|
+
const sdkImage = options.linkOnly ? void 0 : await (await Promise.resolve().then(() => (init_swift_sdk_image(), swift_sdk_image_exports))).buildSwiftSdkImage(
|
|
28515
28481
|
moduleRoot,
|
|
28516
28482
|
!!guestGraph,
|
|
28517
28483
|
distribution ? [] : linkedFrameworkTargets(moduleRoot, input).imports,
|
|
28518
28484
|
{ signal: options.signal }
|
|
28519
|
-
)
|
|
28485
|
+
);
|
|
28520
28486
|
const inputHash = swiftCompileInputHash(input, options.release);
|
|
28521
28487
|
const moduleDigest = swiftModuleDigest(moduleRoot);
|
|
28522
28488
|
const sourceHash = inputHash.copy().update(moduleDigest).digest("hex");
|
|
@@ -28547,79 +28513,10 @@ sdk module ${sdkImage.key}`).digest("hex") : sourceHash;
|
|
|
28547
28513
|
return retain(root, previous);
|
|
28548
28514
|
}
|
|
28549
28515
|
}
|
|
28550
|
-
if (!options.intermediates && !sdkImage && process.platform === "darwin" && process.env.TM_SESSION && !windowAdmission() && process.env.CI !== "true" && moduleRoot === sourceSwiftCheckout() && !swiftDistributionAt(moduleRoot)) {
|
|
28551
|
-
const requestRoot = (0, import_node_fs47.mkdtempSync)(`${root}.builder-request-`);
|
|
28552
|
-
const output = import_node_path49.default.join(requestRoot, "output");
|
|
28553
|
-
const request = import_node_path49.default.join(requestRoot, "request.json");
|
|
28554
|
-
(0, import_node_fs47.writeFileSync)(
|
|
28555
|
-
request,
|
|
28556
|
-
JSON.stringify({
|
|
28557
|
-
input,
|
|
28558
|
-
hash,
|
|
28559
|
-
release: options.release,
|
|
28560
|
-
timeoutMs: options.timeoutMs,
|
|
28561
|
-
// framework sources and compiler inputs own the shared object tree;
|
|
28562
|
-
// unrelated app edits reuse it without retaining stale private ABI.
|
|
28563
|
-
buildKey: frameworkKey
|
|
28564
|
-
})
|
|
28565
|
-
);
|
|
28566
|
-
try {
|
|
28567
|
-
const repo = import_node_path49.default.resolve(moduleRoot, "../..");
|
|
28568
|
-
const timeout = swiftBuilderHopTimeoutMs(options.timeoutMs);
|
|
28569
|
-
report("requesting builder admission or cached result");
|
|
28570
|
-
await runCompiler(
|
|
28571
|
-
"bun",
|
|
28572
|
-
[
|
|
28573
|
-
import_node_path49.default.join(repo, "scripts/build/swift-project.ts"),
|
|
28574
|
-
"--request",
|
|
28575
|
-
request,
|
|
28576
|
-
"--output",
|
|
28577
|
-
output
|
|
28578
|
-
],
|
|
28579
|
-
{
|
|
28580
|
-
cwd: repo,
|
|
28581
|
-
timeout,
|
|
28582
|
-
maxBuffer: 64 * 1024 * 1024,
|
|
28583
|
-
signal: options.signal
|
|
28584
|
-
},
|
|
28585
|
-
true
|
|
28586
|
-
).catch((error) => {
|
|
28587
|
-
if (options.signal?.aborted) throw error;
|
|
28588
|
-
const output2 = outputOf(error);
|
|
28589
|
-
if (!(error instanceof Error) || Reflect.get(error, "exitCode") !== 124)
|
|
28590
|
-
throw new Error(output2, { cause: error });
|
|
28591
|
-
const prefix = `[swift-project ${hash.slice(0, 16)}] `;
|
|
28592
|
-
const lines = output2.split("\n");
|
|
28593
|
-
const stage = lines.findLast((line) => line.startsWith(prefix))?.slice(prefix.length);
|
|
28594
|
-
const cap = lines.find(
|
|
28595
|
-
(line) => line.startsWith("[remote] outer deadline leaves ")
|
|
28596
|
-
);
|
|
28597
|
-
const deadline = cap ? `
|
|
28598
|
-
${cap}` : "";
|
|
28599
|
-
throw new Error(
|
|
28600
|
-
`Swift builder deadline expired during ${stage ?? "builder preparation"} (requested ${Math.ceil(timeout / 1e3)}s for the builder hop).${deadline}`,
|
|
28601
|
-
{ cause: error }
|
|
28602
|
-
);
|
|
28603
|
-
});
|
|
28604
|
-
const artifact = readCompiledArtifact(output, hash);
|
|
28605
|
-
if (!artifact) {
|
|
28606
|
-
throw new Error(
|
|
28607
|
-
"swift-compile: builder artifact source, digest or wasm header is invalid"
|
|
28608
|
-
);
|
|
28609
|
-
}
|
|
28610
|
-
saveCompiledArtifact(root, artifact);
|
|
28611
|
-
saveSharedArtifact(sharedRoot, artifact);
|
|
28612
|
-
report("builder artifact verified");
|
|
28613
|
-
return retain(root, artifact);
|
|
28614
|
-
} finally {
|
|
28615
|
-
(0, import_node_fs47.rmSync)(requestRoot, { recursive: true, force: true });
|
|
28616
|
-
}
|
|
28617
|
-
}
|
|
28618
28516
|
const baseRoot = root;
|
|
28619
28517
|
const canPoolBuildRoot = !options.intermediates && !options.project && !options.linkOnly && import_node_path49.default.basename(import_node_path49.default.dirname(baseRoot)) === "swift-builds";
|
|
28620
28518
|
const compatShapeParts = canPoolBuildRoot ? [
|
|
28621
28519
|
frameworkKey,
|
|
28622
|
-
Boolean(sdkImage),
|
|
28623
28520
|
compileTargets(input).map((target) => target.name).sort(),
|
|
28624
28521
|
input.oneModule === true,
|
|
28625
28522
|
input.optimize === true,
|
|
@@ -29257,7 +29154,8 @@ ${compatShape}` : "";
|
|
|
29257
29154
|
}
|
|
29258
29155
|
const output = options.project ? projectOutputFile(root2, linked, options.project) : linked;
|
|
29259
29156
|
const optimized = `${output}.optimized`;
|
|
29260
|
-
if (sdkImage
|
|
29157
|
+
if (!sdkImage) throw new Error("swift-compile: missing shared SDK image");
|
|
29158
|
+
if (options.project) (0, import_node_fs47.rmSync)(optimized, { force: true });
|
|
29261
29159
|
let sdkAsset;
|
|
29262
29160
|
stage("linking the app image");
|
|
29263
29161
|
if (guestGraph) {
|
|
@@ -29286,9 +29184,8 @@ ${compatShape}` : "";
|
|
|
29286
29184
|
jobs: swiftBuildJobs(),
|
|
29287
29185
|
onStage: stage
|
|
29288
29186
|
});
|
|
29289
|
-
|
|
29290
|
-
|
|
29291
|
-
} else if (sdkImage) {
|
|
29187
|
+
sdkAsset = { key: sdkImage.key, sha256: sdkImage.sha256, binding };
|
|
29188
|
+
} else {
|
|
29292
29189
|
const { buildSwiftAppModule: buildSwiftAppModule2 } = await Promise.resolve().then(() => (init_swift_sdk_app_module(), swift_sdk_app_module_exports));
|
|
29293
29190
|
const binding = await buildSwiftAppModule2({
|
|
29294
29191
|
buildRoot: root2,
|
|
@@ -29306,19 +29203,7 @@ ${compatShape}` : "";
|
|
|
29306
29203
|
}
|
|
29307
29204
|
});
|
|
29308
29205
|
sdkAsset = { key: sdkImage.key, sha256: sdkImage.sha256, binding };
|
|
29309
|
-
} else {
|
|
29310
|
-
const bytes = (0, import_node_fs47.readFileSync)(output);
|
|
29311
|
-
const ordered = orderObjCConstructors(bytes);
|
|
29312
|
-
if (ordered !== bytes) (0, import_node_fs47.writeFileSync)(output, ordered);
|
|
29313
|
-
stage("lowering the app image");
|
|
29314
|
-
await lowerWasm(output, optimized, { optimize: input.optimize === true });
|
|
29315
29206
|
}
|
|
29316
|
-
if (!sdkImage)
|
|
29317
|
-
await runCompiler(
|
|
29318
|
-
import_node_path49.default.join(options.toolchainBin, "llvm-objcopy"),
|
|
29319
|
-
["--remove-section=.swift1_autolink_entries", optimized],
|
|
29320
|
-
buildOptions
|
|
29321
|
-
);
|
|
29322
29207
|
const artifact = {
|
|
29323
29208
|
hash,
|
|
29324
29209
|
bytes: (0, import_node_fs47.readFileSync)(optimized),
|
|
@@ -29377,7 +29262,6 @@ var init_swift_compile = __esm({
|
|
|
29377
29262
|
init_swift_project_user();
|
|
29378
29263
|
init_swift_reproducible();
|
|
29379
29264
|
init_swift_root_lock();
|
|
29380
|
-
init_swift_sdk_image_wasm();
|
|
29381
29265
|
init_swift_sdk_surface();
|
|
29382
29266
|
init_swift_shared_sdk();
|
|
29383
29267
|
init_swift_source_closure();
|
|
@@ -29572,7 +29456,7 @@ ${wasmThreadLinkFlags.map((flag) => ` "-Xlinker", ${JSON.stringify(flag
|
|
|
29572
29456
|
REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
|
|
29573
29457
|
MULTI_MANIFEST_VERSION = 76;
|
|
29574
29458
|
SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
|
|
29575
|
-
compilerSourceDigest = true ? "
|
|
29459
|
+
compilerSourceDigest = true ? "dcd0189f8bf1a7fc415f2c92825f8b3bbc2089ae9697ffcb50cc9a7e65e99990" : swiftCompilerSourceDigest(__sootsim_import_meta_dirname);
|
|
29576
29460
|
nativeCxxCompilerFlags = ["-fno-cxx-modules"];
|
|
29577
29461
|
MODULE_MAP_RESPONSE_FILE_RUN = 16;
|
|
29578
29462
|
cFlagArray = (flags) => JSON.stringify(withoutGlogModuleMap(flags));
|