peachsim 0.1.2253 → 0.1.2257
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/bridge-flow-runner.ts +41 -0
- package/cli/commands/compat.ts +1 -1
- package/cli/commands/control.ts +9 -3
- package/cli/commands/flow.ts +9 -0
- package/cli/commands/package.ts +1 -1
- package/cli/commands/runtime.ts +1 -1
- package/cli/commands/swift.ts +5 -0
- package/cli/commands/upgrade.ts +2 -5
- package/cli/commands/version.ts +1 -1
- package/cli/current-sim.ts +23 -15
- package/cli/native-input.ts +1 -1
- package/cli/outbound-endpoints.ts +0 -2
- package/cli/secure-file.ts +8 -2
- 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 +1 -1
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/bridge-contract-input.cjs +1 -1
- package/dist-lib/bridge-contract-input.mjs +1 -1
- package/dist-lib/bridge-contract.cjs +1 -1
- package/dist-lib/bridge-contract.mjs +1 -1
- package/dist-lib/bundle-channel.cjs +3295 -2329
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +1 -1
- package/dist-lib/cloud-contract.cjs +1 -1
- package/dist-lib/cloud-contract.mjs +1 -1
- package/dist-lib/cloud-test-args.cjs +1 -1
- package/dist-lib/cloud-test-args.mjs +1 -1
- package/dist-lib/cloud.cjs +1 -1
- package/dist-lib/cloud.mjs +1 -1
- package/dist-lib/config.cjs +16 -1
- package/dist-lib/config.mjs +14 -1
- package/dist-lib/detox/index.cjs +16 -12
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/expo-swift-bundle.cjs +3345 -2401
- package/dist-lib/expo-swift-metadata.cjs +1 -1
- package/dist-lib/expo-swift-metadata.mjs +1 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +3869 -2832
- package/dist-lib/host/fetch-proxy-handler.cjs +3607 -1627
- package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
- package/dist-lib/host/replacement-module-handler.cjs +1 -1
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +14284 -12772
- package/dist-lib/jump-to-source-babel.cjs +1 -1
- package/dist-lib/jump-to-source-native.cjs +1 -1
- package/dist-lib/kotlin-host.cjs +6 -4
- package/dist-lib/menu.cjs +1 -1
- package/dist-lib/menu.mjs +1 -1
- package/dist-lib/metro-fingerprint-registry.cjs +1 -1
- package/dist-lib/metro-fingerprint-registry.mjs +1 -1
- package/dist-lib/metro-production-bundle.cjs +1 -1
- package/dist-lib/metro-production-bundle.mjs +1 -1
- package/dist-lib/metro.cjs +9796 -8347
- package/dist-lib/native-app-identity-project.cjs +2 -2
- package/dist-lib/native-app-identity-project.mjs +2 -3
- package/dist-lib/native-app-identity.cjs +1 -1
- package/dist-lib/native-app-identity.mjs +1 -1
- package/dist-lib/native-firebase-metadata.cjs +1 -1
- package/dist-lib/native-firebase-metadata.mjs +1 -1
- package/dist-lib/pdfium-raster.cjs +1 -1
- package/dist-lib/pdfium-raster.mjs +1 -1
- package/dist-lib/plist.cjs +1 -1
- package/dist-lib/plist.mjs +1 -1
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/public-origins-lib-esm.json +24 -24
- package/dist-lib/public-origins-lib.json +682 -292
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +1 -1
- 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 +1 -1
- package/dist-lib/skills.cjs +4580 -3494
- package/dist-lib/swift-compile.cjs +426 -126
- package/dist-lib/swift-compile.mjs +429 -126
- package/dist-lib/swift-package.cjs +1 -1
- package/dist-lib/swift-package.mjs +1 -1
- package/dist-lib/swift-submit.cjs +1 -1
- package/dist-lib/swift-submit.mjs +1 -1
- package/dist-lib/swift-toolchain.cjs +1 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +2529 -1611
- package/dist-lib/vite.cjs +7138 -4012
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +1 -1
- package/dist-types/packages/peach-engine/src/config.d.ts +1 -1
- package/dist-types/packages/peach-engine/src/engine/scene-table.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/engine/types.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/render-worker/compositor-protocol.d.ts +33 -1
- package/dist-types/packages/peach-engine/src/render-worker/reanimated-readiness.d.ts +1 -0
- package/dist-types/packages/peach-globals/src/appLifecycleBridgeContract.d.ts +1 -0
- package/dist-types/packages/peach-globals/src/index.d.ts +2 -1
- package/dist-types/packages/peach-globals/src/lockstepCaptureBridgeContract.d.ts +12 -0
- package/dist-types/packages/peach-kit/src/transitions/screen-transition-math.d.ts +6 -0
- package/java-platform/licenses/android.txt +183 -0
- package/java-platform/licenses/arm-optimized-routines.txt +256 -0
- package/java-platform/licenses/fdlibm.txt +72 -0
- package/java-platform/licenses/icu.txt +50 -0
- package/java-platform/licenses/openjdk.txt +395 -0
- package/java-platform/licenses/teavm.txt +182 -0
- package/java-platform/licenses/threeten-backport.txt +29 -0
- package/kotlin/README.md +1 -1
- package/kotlin/sdk.tar.gz +0 -0
- package/package.json +2 -1
- package/runtime-companion.json +1 -1
- package/sdk/ios/wasm/include/__typedef_time_t.h +5 -0
- package/sdk/ios/wasm/include/ifaddrs.h +75 -0
- package/sdk/ios/wasm/include/machine/_types.h +1 -1
- package/sdk/ios/wasm/include/pthread.h +4 -0
- package/sdk/ios/wasm/include/unistd.h +2 -0
- package/{cli → src}/app-config.ts +5 -5
- package/src/bundle-channel.mjs +1 -1
- package/src/config.ts +29 -0
- package/src/core-data-entity-classes.ts +2 -2
- package/src/core-data-model.ts +681 -0
- package/src/expo-autolinking.ts +47 -4
- package/src/expo-pod-prebuilt.ts +96 -9
- package/src/expo-swift-host.ts +30 -10
- package/src/kotlin-host.ts +4 -2
- package/src/kotlinSdkContract.ts +1 -0
- package/src/metro-plugin.ts +1 -3
- package/src/native-package-slice.ts +810 -0
- package/src/native-prebuilt.ts +4 -0
- package/src/native-seam-manifest.ts +0 -8
- package/src/nitro-adapter.lock.json +261 -261
- package/src/nitro-bundle.ts +1 -1
- package/src/nitro-superset.lock.json +4 -4
- package/src/plist-bytes.ts +113 -0
- package/src/swift-compile.ts +2 -0
- package/src/swift-distribution.lock.json +11 -11
- package/src/swift-guest-image-ledger.ts +2 -1
- package/src/swift-host.ts +14 -2
- package/src/swift-link-roots.ts +23 -22
- package/src/swift-wasm-prune.ts +436 -105
- package/src/turbo-bundle.ts +1 -1
- package/src/turbo-runtime.lock.json +22 -22
- package/src/vite-plugin-one.ts +68 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! peach v0.1.
|
|
1
|
+
/*! peach v0.1.2257 | (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;
|
|
@@ -5383,18 +5383,22 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
5383
5383
|
const [, r1] = readULEB2(buf, cp);
|
|
5384
5384
|
const [cnt, r2] = readULEB2(buf, r1);
|
|
5385
5385
|
let cur = r2;
|
|
5386
|
-
const
|
|
5386
|
+
const isData = name2 === "reloc.DATA";
|
|
5387
5387
|
for (let i = 0; i < cnt; i++) {
|
|
5388
5388
|
const rStart = cur;
|
|
5389
5389
|
const rType = buf[cur++];
|
|
5390
5390
|
const [ro, c2] = readULEB2(buf, cur);
|
|
5391
5391
|
const [rs, c3] = readULEB2(buf, c2);
|
|
5392
5392
|
cur = c3;
|
|
5393
|
+
let addend = 0;
|
|
5393
5394
|
if (HAS_ADDEND.has(rType)) {
|
|
5394
|
-
const [, c4] = readSLEB(buf, cur);
|
|
5395
|
+
const [val, c4] = readSLEB(buf, cur);
|
|
5396
|
+
addend = val;
|
|
5395
5397
|
cur = c4;
|
|
5396
5398
|
}
|
|
5397
|
-
|
|
5399
|
+
const rawBytes = new Uint8Array(buf.subarray(rStart, cur));
|
|
5400
|
+
if (isData) rawDataRelocs.push({ rawBytes, ro, rs, addend });
|
|
5401
|
+
else rawCodeRelocs.push({ rawBytes, ro, rs });
|
|
5398
5402
|
}
|
|
5399
5403
|
}
|
|
5400
5404
|
}
|
|
@@ -5548,6 +5552,80 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
5548
5552
|
rootSegs.push(i);
|
|
5549
5553
|
}
|
|
5550
5554
|
}
|
|
5555
|
+
const conformanceProtocols = /* @__PURE__ */ new Map();
|
|
5556
|
+
const objcCategoryTargets = [];
|
|
5557
|
+
if (isDist) {
|
|
5558
|
+
const relocAt = /* @__PURE__ */ new Map();
|
|
5559
|
+
for (const r of dataRelocList) {
|
|
5560
|
+
relocAt.set(`${r.segIdx}:${r.offInSeg}`, { rs: r.rs, addend: r.addend });
|
|
5561
|
+
}
|
|
5562
|
+
const confSegs = /* @__PURE__ */ new Set();
|
|
5563
|
+
let hasCatsSeg = false;
|
|
5564
|
+
for (let i = 0; i < segNames.length; i++) {
|
|
5565
|
+
if (segNames[i] === "swift5_protocol_conformances") confSegs.add(i);
|
|
5566
|
+
else if (segNames[i] === "__objc_cats") hasCatsSeg = true;
|
|
5567
|
+
}
|
|
5568
|
+
if (confSegs.size > 0) {
|
|
5569
|
+
const segOffToMpSym = /* @__PURE__ */ new Map();
|
|
5570
|
+
for (let i = 0; i < symKind.length; i++) {
|
|
5571
|
+
if (symKind[i] === 1 && (symFlags[i] & 16) === 0 && symElemIdx[i] >= 0 && symNames[i].startsWith("$s") && symNames[i].endsWith("Mp")) {
|
|
5572
|
+
segOffToMpSym.set(`${symElemIdx[i]}:${symOff[i]}`, symNames[i]);
|
|
5573
|
+
}
|
|
5574
|
+
}
|
|
5575
|
+
const dv = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
5576
|
+
for (const r of dataRelocList) {
|
|
5577
|
+
if (!confSegs.has(r.segIdx)) continue;
|
|
5578
|
+
const mcIdx = r.rs;
|
|
5579
|
+
if (symKind[mcIdx] !== 1 || (symFlags[mcIdx] & 16) !== 0 || symElemIdx[mcIdx] < 0) {
|
|
5580
|
+
continue;
|
|
5581
|
+
}
|
|
5582
|
+
const mcSeg = symElemIdx[mcIdx];
|
|
5583
|
+
const mcOff = symOff[mcIdx];
|
|
5584
|
+
const pr = relocAt.get(`${mcSeg}:${mcOff}`);
|
|
5585
|
+
let mp = "";
|
|
5586
|
+
if (pr) {
|
|
5587
|
+
const raw2 = symNames[pr.rs];
|
|
5588
|
+
const stripped = raw2.startsWith(".Lgot.") ? raw2.slice(6) : raw2;
|
|
5589
|
+
if (stripped.startsWith("$s") && stripped.endsWith("Mp")) {
|
|
5590
|
+
mp = stripped;
|
|
5591
|
+
} else if (symKind[pr.rs] === 3 || stripped === "") {
|
|
5592
|
+
mp = segOffToMpSym.get(`${mcSeg}:${pr.addend}`) ?? "";
|
|
5593
|
+
}
|
|
5594
|
+
} else {
|
|
5595
|
+
const fileOff = dataStart + sPayloadStarts[mcSeg] + mcOff;
|
|
5596
|
+
if (fileOff + 4 <= buf.length) {
|
|
5597
|
+
const delta = dv.getInt32(fileOff, true);
|
|
5598
|
+
mp = segOffToMpSym.get(`${mcSeg}:${mcOff + delta}`) ?? segOffToMpSym.get(`${mcSeg}:${mcOff + (delta & ~1)}`) ?? "";
|
|
5599
|
+
}
|
|
5600
|
+
}
|
|
5601
|
+
if (mp) conformanceProtocols.set(mcIdx, mp);
|
|
5602
|
+
}
|
|
5603
|
+
}
|
|
5604
|
+
if (hasCatsSeg) {
|
|
5605
|
+
const seenClasses = /* @__PURE__ */ new Set();
|
|
5606
|
+
for (let i = 0; i < symKind.length; i++) {
|
|
5607
|
+
if (symKind[i] !== 1 || (symFlags[i] & 16) !== 0 || symElemIdx[i] < 0 || segNames[symElemIdx[i]] !== "__objc_cats" || !symNames[i].startsWith(".objc_category_")) {
|
|
5608
|
+
continue;
|
|
5609
|
+
}
|
|
5610
|
+
const cSeg = symElemIdx[i];
|
|
5611
|
+
const cOff = symOff[i];
|
|
5612
|
+
const cr = relocAt.get(`${cSeg}:${cOff + 8}`);
|
|
5613
|
+
if (cr && symKind[cr.rs] === 1 && (symFlags[cr.rs] & 16) === 0 && symElemIdx[cr.rs] >= 0) {
|
|
5614
|
+
const tSeg = symElemIdx[cr.rs];
|
|
5615
|
+
const strOff = dataStart + sPayloadStarts[tSeg] + symOff[cr.rs] + cr.addend;
|
|
5616
|
+
let sEnd = strOff;
|
|
5617
|
+
while (sEnd < buf.length && buf[sEnd] !== 0) sEnd++;
|
|
5618
|
+
if (sEnd > strOff) {
|
|
5619
|
+
const clsName = Buffer.from(buf.subarray(strOff, sEnd)).toString("utf8");
|
|
5620
|
+
if (!seenClasses.has(clsName)) {
|
|
5621
|
+
seenClasses.add(clsName);
|
|
5622
|
+
objcCategoryTargets.push(clsName);
|
|
5623
|
+
}
|
|
5624
|
+
}
|
|
5625
|
+
}
|
|
5626
|
+
}
|
|
5627
|
+
}
|
|
5628
|
+
}
|
|
5551
5629
|
return {
|
|
5552
5630
|
file,
|
|
5553
5631
|
isDist,
|
|
@@ -5572,6 +5650,8 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
5572
5650
|
objcRegisterFuncToTypePrefix,
|
|
5573
5651
|
objcClassSymToTypePrefix,
|
|
5574
5652
|
typePrefixesInObj,
|
|
5653
|
+
conformanceProtocols,
|
|
5654
|
+
objcCategoryTargets,
|
|
5575
5655
|
rootFuncs,
|
|
5576
5656
|
rootSegs,
|
|
5577
5657
|
segPayloadRanges: sEnds.map((end, i) => [
|
|
@@ -5583,7 +5663,7 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
5583
5663
|
function parseWasmObjectCached(file, isDist, useCache) {
|
|
5584
5664
|
if (!useCache)
|
|
5585
5665
|
return parseWasmObjectBytes(file, new Uint8Array(import_node_fs8.default.readFileSync(file)), isDist);
|
|
5586
|
-
const key =
|
|
5666
|
+
const key = `v2:${isDist ? "1" : "0"}:${file}`;
|
|
5587
5667
|
const stat = import_node_fs8.default.statSync(file, { bigint: true });
|
|
5588
5668
|
const stamp = `${stat.ino}:${stat.size}:${stat.mtimeNs}:${stat.ctimeNs}`;
|
|
5589
5669
|
const hit = parsedObjectCache.get(key);
|
|
@@ -5743,6 +5823,18 @@ function getModulePrefix(file) {
|
|
|
5743
5823
|
const dash = base.indexOf("-");
|
|
5744
5824
|
return dash > 0 ? base.slice(0, dash) : base;
|
|
5745
5825
|
}
|
|
5826
|
+
function moduleFamily(file) {
|
|
5827
|
+
const mod = getModulePrefix(file);
|
|
5828
|
+
if (mod === "Foundation" || mod === "PeachFoundation" || mod === "PeachObjC" || mod === "PeachObjCRuntime" || mod === "ObjectiveC" || mod === "Darwin" || mod === "libFoundation" || mod === "libObjectiveC" || mod === "libDarwin" || mod === "libswiftCore") {
|
|
5829
|
+
return "Foundation";
|
|
5830
|
+
}
|
|
5831
|
+
if (mod.startsWith("UIKit")) return "UIKit";
|
|
5832
|
+
if (mod === "CoreData" || mod === "CoreDataConstants") return "CoreData";
|
|
5833
|
+
if (mod === "AVFoundation" || mod === "AVFoundationConstants" || mod === "AVFAudio") {
|
|
5834
|
+
return "AVFoundation";
|
|
5835
|
+
}
|
|
5836
|
+
return mod;
|
|
5837
|
+
}
|
|
5746
5838
|
var SWIFTUI_WRAPPER_HOST_PROTOCOLS = new Set(
|
|
5747
5839
|
[
|
|
5748
5840
|
"View",
|
|
@@ -5836,11 +5928,7 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
5836
5928
|
}
|
|
5837
5929
|
if (t.endsWith(".o")) {
|
|
5838
5930
|
if (import_node_path8.default.resolve(t).startsWith(distDir + import_node_path8.default.sep)) {
|
|
5839
|
-
|
|
5840
|
-
(name2) => import_node_path8.default.basename(t) === `Foundation-${name2}.o`
|
|
5841
|
-
)) {
|
|
5842
|
-
distFiles.push(t);
|
|
5843
|
-
}
|
|
5931
|
+
distFiles.push(t);
|
|
5844
5932
|
if (!inStartLib) eagerFiles.push(t);
|
|
5845
5933
|
} else if (!inStartLib) {
|
|
5846
5934
|
if (t.endsWith("/swiftrt.o")) {
|
|
@@ -5909,6 +5997,9 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
5909
5997
|
}
|
|
5910
5998
|
const allSdkObjFiles = import_node_fs8.default.readdirSync(sdkObjsDir).filter((f) => f.endsWith(".o") || f.endsWith(".obj")).sort();
|
|
5911
5999
|
const sdkFiles = allSdkObjFiles.map((f) => import_node_path8.default.join(sdkObjsDir, f));
|
|
6000
|
+
const extraSdkObjs = allSdkObjFiles.filter(
|
|
6001
|
+
(f) => f.startsWith("libDarwin__") || f.startsWith("libswiftCore__") && f !== "libswiftCore__Swift.o" || f.startsWith("libswift_Concurrency__") && f !== "libswift_Concurrency___Concurrency.o"
|
|
6002
|
+
).map((f) => import_node_path8.default.join(sdkObjsDir, f));
|
|
5912
6003
|
const distObjs = /* @__PURE__ */ new Map();
|
|
5913
6004
|
const lazyProviders = /* @__PURE__ */ new Map();
|
|
5914
6005
|
const registerLazyProvider = (obj) => {
|
|
@@ -5972,11 +6063,33 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
5972
6063
|
workQueue.push({ kind: "datasym", obj, symIdx });
|
|
5973
6064
|
};
|
|
5974
6065
|
const knownTypes = /* @__PURE__ */ new Set();
|
|
5975
|
-
|
|
6066
|
+
const knownProtocols = /* @__PURE__ */ new Set();
|
|
6067
|
+
const protoPrefixes = /* @__PURE__ */ new Set();
|
|
6068
|
+
for (const o of distObjs.values()) {
|
|
5976
6069
|
for (const t of o.typePrefixesInObj) knownTypes.add(t);
|
|
6070
|
+
for (let i = 0; i < o.symNames.length; i++) {
|
|
6071
|
+
if (o.symKind[i] === 1 && (o.symFlags[i] & 16) === 0 && o.symNames[i].startsWith("$s") && o.symNames[i].endsWith("Mp")) {
|
|
6072
|
+
const mp = o.symNames[i];
|
|
6073
|
+
knownProtocols.add(mp);
|
|
6074
|
+
protoPrefixes.add(mp.slice(0, -2));
|
|
6075
|
+
}
|
|
6076
|
+
}
|
|
6077
|
+
for (const mp of o.conformanceProtocols.values()) {
|
|
6078
|
+
knownProtocols.add(mp);
|
|
6079
|
+
protoPrefixes.add(mp.slice(0, -2));
|
|
6080
|
+
}
|
|
6081
|
+
}
|
|
5977
6082
|
const globalLiveTypes = /* @__PURE__ */ new Set();
|
|
5978
|
-
const
|
|
6083
|
+
const liveProtocols = /* @__PURE__ */ new Set();
|
|
6084
|
+
const liveObjCClasses = /* @__PURE__ */ new Set();
|
|
6085
|
+
const liveModuleFamilies = /* @__PURE__ */ new Set();
|
|
6086
|
+
const categoryOnlyExtracted = /* @__PURE__ */ new Set();
|
|
5979
6087
|
const eagerDynamicObjects = /* @__PURE__ */ new Set();
|
|
6088
|
+
const pendingBySwiftType = /* @__PURE__ */ new Map();
|
|
6089
|
+
const pendingByObjcClass = /* @__PURE__ */ new Map();
|
|
6090
|
+
const pendingByProto = /* @__PURE__ */ new Map();
|
|
6091
|
+
const pendingCategoriesByClass = /* @__PURE__ */ new Map();
|
|
6092
|
+
const pendingCategoriesByFamily = /* @__PURE__ */ new Map();
|
|
5980
6093
|
const conformingType = (name2) => {
|
|
5981
6094
|
for (let n = name2.length - 1; n > 2; n--) {
|
|
5982
6095
|
const prefix = name2.slice(0, n);
|
|
@@ -5984,23 +6097,114 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
5984
6097
|
}
|
|
5985
6098
|
return void 0;
|
|
5986
6099
|
};
|
|
6100
|
+
const objcClassOfConformance = (name2) => {
|
|
6101
|
+
const m = /^\$sSo(\d+)([A-Za-z0-9_]+)/.exec(name2);
|
|
6102
|
+
if (!m) return void 0;
|
|
6103
|
+
const len = Number(m[1]);
|
|
6104
|
+
const rest = m[2];
|
|
6105
|
+
if (rest.length <= len || rest[len] !== "C") return void 0;
|
|
6106
|
+
const cls = rest.slice(0, len);
|
|
6107
|
+
return lazyProviders.has(`._OBJC_CLASS_${cls}`) ? cls : void 0;
|
|
6108
|
+
};
|
|
6109
|
+
const objcClassFamilyOf = (cls) => {
|
|
6110
|
+
const providers = lazyProviders.get(`._OBJC_CLASS_${cls}`);
|
|
6111
|
+
if (!providers || providers.length === 0) return void 0;
|
|
6112
|
+
return moduleFamily(providers[0].file);
|
|
6113
|
+
};
|
|
6114
|
+
const tryActivateConformance = (entry) => {
|
|
6115
|
+
if (entry.activated) return;
|
|
6116
|
+
const typeReady = entry.typeKey === null ? true : entry.typeKey.kind === "swift" ? globalLiveTypes.has(entry.typeKey.value) : liveObjCClasses.has(entry.typeKey.value);
|
|
6117
|
+
if (!typeReady) return;
|
|
6118
|
+
if (entry.proto !== void 0 && !liveProtocols.has(entry.proto)) return;
|
|
6119
|
+
if (entry.isForeign) {
|
|
6120
|
+
eagerDynamicObjects.add(entry.obj);
|
|
6121
|
+
extractObject(entry.obj);
|
|
6122
|
+
} else if (!extractedObjs.has(entry.obj)) {
|
|
6123
|
+
return;
|
|
6124
|
+
}
|
|
6125
|
+
entry.activated = true;
|
|
6126
|
+
activateSymbolInObj(entry.obj, entry.symIdx);
|
|
6127
|
+
};
|
|
6128
|
+
const tryActivateCategory = (entry) => {
|
|
6129
|
+
if (entry.activated || !liveObjCClasses.has(entry.cls)) return;
|
|
6130
|
+
const allowed = entry.catFamily === "Foundation" || entry.classFamily !== void 0 && entry.classFamily !== "Foundation" || liveModuleFamilies.has(entry.catFamily);
|
|
6131
|
+
if (!allowed) return;
|
|
6132
|
+
entry.activated = true;
|
|
6133
|
+
eagerDynamicObjects.add(entry.obj);
|
|
6134
|
+
extractObject(entry.obj, true);
|
|
6135
|
+
};
|
|
6136
|
+
const markModuleFamilyLive = (family) => {
|
|
6137
|
+
if (liveModuleFamilies.has(family)) return;
|
|
6138
|
+
liveModuleFamilies.add(family);
|
|
6139
|
+
const waiting = pendingCategoriesByFamily.get(family);
|
|
6140
|
+
if (waiting) {
|
|
6141
|
+
pendingCategoriesByFamily.delete(family);
|
|
6142
|
+
for (const entry of waiting) tryActivateCategory(entry);
|
|
6143
|
+
}
|
|
6144
|
+
};
|
|
6145
|
+
const markObjCClassLive = (cls) => {
|
|
6146
|
+
if (!cls || liveObjCClasses.has(cls)) return;
|
|
6147
|
+
liveObjCClasses.add(cls);
|
|
6148
|
+
const confs = pendingByObjcClass.get(cls);
|
|
6149
|
+
if (confs) {
|
|
6150
|
+
for (const entry of confs) tryActivateConformance(entry);
|
|
6151
|
+
}
|
|
6152
|
+
const cats = pendingCategoriesByClass.get(cls);
|
|
6153
|
+
if (cats) {
|
|
6154
|
+
for (const entry of cats) tryActivateCategory(entry);
|
|
6155
|
+
}
|
|
6156
|
+
};
|
|
6157
|
+
const markProtocolLive = (mpName) => {
|
|
6158
|
+
if (!mpName || liveProtocols.has(mpName)) return;
|
|
6159
|
+
liveProtocols.add(mpName);
|
|
6160
|
+
const waiting = pendingByProto.get(mpName);
|
|
6161
|
+
if (waiting) {
|
|
6162
|
+
for (const entry of waiting) tryActivateConformance(entry);
|
|
6163
|
+
}
|
|
6164
|
+
};
|
|
6165
|
+
const checkProtocolTrigger = (rawSymName) => {
|
|
6166
|
+
if (!rawSymName) return;
|
|
6167
|
+
const sName = rawSymName.startsWith(".Lgot.") ? rawSymName.slice(6) : rawSymName;
|
|
6168
|
+
if (knownProtocols.has(sName)) {
|
|
6169
|
+
markProtocolLive(sName);
|
|
6170
|
+
return;
|
|
6171
|
+
}
|
|
6172
|
+
if (!sName.startsWith("$s") || sName.endsWith("Mc")) return;
|
|
6173
|
+
if (sName.endsWith("TL")) {
|
|
6174
|
+
const mp = `${sName.slice(0, -2)}Mp`;
|
|
6175
|
+
if (knownProtocols.has(mp)) {
|
|
6176
|
+
markProtocolLive(mp);
|
|
6177
|
+
return;
|
|
6178
|
+
}
|
|
6179
|
+
}
|
|
6180
|
+
if (sName.startsWith("$sS") && sName.length > 4) {
|
|
6181
|
+
const pref = sName.slice(0, 4);
|
|
6182
|
+
if (protoPrefixes.has(pref)) {
|
|
6183
|
+
const ch = sName[4];
|
|
6184
|
+
if (ch >= "0" && ch <= "9" || ch === "s" || ch === "P") {
|
|
6185
|
+
markProtocolLive(`${pref}Mp`);
|
|
6186
|
+
return;
|
|
6187
|
+
}
|
|
6188
|
+
}
|
|
6189
|
+
}
|
|
6190
|
+
for (let n = 5; n < sName.length; n++) {
|
|
6191
|
+
if (sName[n] === "P") {
|
|
6192
|
+
const pref = sName.slice(0, n);
|
|
6193
|
+
if (protoPrefixes.has(pref)) {
|
|
6194
|
+
markProtocolLive(`${pref}Mp`);
|
|
6195
|
+
return;
|
|
6196
|
+
}
|
|
6197
|
+
}
|
|
6198
|
+
}
|
|
6199
|
+
};
|
|
5987
6200
|
const markTypeLive = (obj, pref) => {
|
|
5988
6201
|
const set = liveTypes.get(obj);
|
|
5989
6202
|
if (set.has(pref)) return;
|
|
5990
6203
|
set.add(pref);
|
|
5991
6204
|
globalLiveTypes.add(pref);
|
|
5992
|
-
const waiting =
|
|
6205
|
+
const waiting = pendingBySwiftType.get(pref);
|
|
5993
6206
|
if (waiting) {
|
|
5994
|
-
|
|
5995
|
-
for (const w of waiting) {
|
|
5996
|
-
eagerDynamicObjects.add(w.obj);
|
|
5997
|
-
extractObject(w.obj);
|
|
5998
|
-
activateSymbolInObj(w.obj, w.symIdx);
|
|
5999
|
-
}
|
|
6000
|
-
}
|
|
6001
|
-
for (let n = pref.length - 1; n > 2; n--) {
|
|
6002
|
-
const outer = pref.slice(0, n);
|
|
6003
|
-
if (obj.typePrefixesInObj.has(outer)) markTypeLive(obj, outer);
|
|
6207
|
+
for (const entry of waiting) tryActivateConformance(entry);
|
|
6004
6208
|
}
|
|
6005
6209
|
for (let n = pref.length - 1; n > 2; n--) {
|
|
6006
6210
|
const outer = pref.slice(0, n);
|
|
@@ -6017,22 +6221,20 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
6017
6221
|
markFuncLive(obj, lf);
|
|
6018
6222
|
}
|
|
6019
6223
|
}
|
|
6020
|
-
for (
|
|
6021
|
-
if (
|
|
6022
|
-
|
|
6023
|
-
if (r.segIdx === sIdx) {
|
|
6024
|
-
const mcName = obj.symNames[r.rs];
|
|
6025
|
-
if (mcName.startsWith(pref)) {
|
|
6026
|
-
activateSymbolInObj(obj, r.rs);
|
|
6027
|
-
}
|
|
6028
|
-
}
|
|
6029
|
-
}
|
|
6224
|
+
for (const [classSym, p] of obj.objcClassSymToTypePrefix) {
|
|
6225
|
+
if (p === pref && classSym.startsWith("._OBJC_CLASS_")) {
|
|
6226
|
+
markObjCClassLive(classSym.slice("._OBJC_CLASS_".length));
|
|
6030
6227
|
}
|
|
6031
6228
|
}
|
|
6032
6229
|
};
|
|
6033
6230
|
const checkTypeTrigger = (obj, rawSymName) => {
|
|
6034
6231
|
if (!rawSymName) return;
|
|
6035
6232
|
const sName = rawSymName.startsWith(".Lgot.") ? rawSymName.slice(6) : rawSymName;
|
|
6233
|
+
if (sName.startsWith("._OBJC_CLASS_")) {
|
|
6234
|
+
markObjCClassLive(sName.slice("._OBJC_CLASS_".length));
|
|
6235
|
+
} else if (sName.startsWith("._OBJC_METACLASS_")) {
|
|
6236
|
+
markObjCClassLive(sName.slice("._OBJC_METACLASS_".length));
|
|
6237
|
+
}
|
|
6036
6238
|
const objcPref = obj.objcClassSymToTypePrefix.get(sName);
|
|
6037
6239
|
if (objcPref) {
|
|
6038
6240
|
markTypeLive(obj, objcPref);
|
|
@@ -6059,6 +6261,7 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
6059
6261
|
const activateGlobalName = (name2) => {
|
|
6060
6262
|
if (!name2) return;
|
|
6061
6263
|
if (!liveGlobalNames.has(name2)) liveGlobalNames.add(name2);
|
|
6264
|
+
checkProtocolTrigger(name2);
|
|
6062
6265
|
const defs = extractedSymbolDefs.get(name2);
|
|
6063
6266
|
if (defs) {
|
|
6064
6267
|
for (const d of defs) {
|
|
@@ -6073,7 +6276,12 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
6073
6276
|
const fl = obj.symFlags[symIdx];
|
|
6074
6277
|
const isUndef = (fl & 16) !== 0;
|
|
6075
6278
|
const isLocal = (fl & 3) === 2;
|
|
6279
|
+
if (obj.isDist && categoryOnlyExtracted.has(obj)) {
|
|
6280
|
+
categoryOnlyExtracted.delete(obj);
|
|
6281
|
+
markModuleFamilyLive(moduleFamily(obj.file));
|
|
6282
|
+
}
|
|
6076
6283
|
checkTypeTrigger(obj, sName);
|
|
6284
|
+
checkProtocolTrigger(sName);
|
|
6077
6285
|
if (!isUndef && !isLocal && sName && !liveGlobalNames.has(sName)) {
|
|
6078
6286
|
activateGlobalName(sName);
|
|
6079
6287
|
}
|
|
@@ -6085,13 +6293,25 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
6085
6293
|
markDataSymLive(obj, pIdx);
|
|
6086
6294
|
const parentName = obj.symNames[pIdx];
|
|
6087
6295
|
checkTypeTrigger(obj, parentName);
|
|
6296
|
+
checkProtocolTrigger(parentName);
|
|
6088
6297
|
}
|
|
6089
6298
|
markSegLive(obj, el);
|
|
6090
6299
|
}
|
|
6091
6300
|
}
|
|
6092
|
-
const extractObject = (obj) => {
|
|
6093
|
-
if (extractedObjs.has(obj))
|
|
6301
|
+
const extractObject = (obj, fromObjCCategory = false) => {
|
|
6302
|
+
if (extractedObjs.has(obj)) {
|
|
6303
|
+
if (!fromObjCCategory && categoryOnlyExtracted.has(obj)) {
|
|
6304
|
+
categoryOnlyExtracted.delete(obj);
|
|
6305
|
+
if (obj.isDist) markModuleFamilyLive(moduleFamily(obj.file));
|
|
6306
|
+
}
|
|
6307
|
+
return;
|
|
6308
|
+
}
|
|
6094
6309
|
extractedObjs.add(obj);
|
|
6310
|
+
if (fromObjCCategory && obj.isDist) {
|
|
6311
|
+
categoryOnlyExtracted.add(obj);
|
|
6312
|
+
} else if (obj.isDist) {
|
|
6313
|
+
markModuleFamilyLive(moduleFamily(obj.file));
|
|
6314
|
+
}
|
|
6095
6315
|
liveFuncs.set(obj, new Uint8Array(obj.numFuncs));
|
|
6096
6316
|
liveSegs.set(obj, new Uint8Array(obj.numSegments));
|
|
6097
6317
|
liveDataSyms.set(obj, /* @__PURE__ */ new Set());
|
|
@@ -6129,6 +6349,12 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
6129
6349
|
if (classSym !== -1 && (obj.symFlags[classSym] & 16) === 0)
|
|
6130
6350
|
activateSymbolInObj(obj, classSym);
|
|
6131
6351
|
}
|
|
6352
|
+
if (!obj.isDist) {
|
|
6353
|
+
for (let i = 0; i < obj.symNames.length; i++) {
|
|
6354
|
+
checkTypeTrigger(obj, obj.symNames[i]);
|
|
6355
|
+
checkProtocolTrigger(obj.symNames[i]);
|
|
6356
|
+
}
|
|
6357
|
+
}
|
|
6132
6358
|
if (obj.isDist) {
|
|
6133
6359
|
const isBuildSwift = !obj.file.startsWith(distDir) && obj.file.endsWith(".swift.o");
|
|
6134
6360
|
for (const [classSym, pref] of obj.objcClassSymToTypePrefix)
|
|
@@ -6143,48 +6369,77 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
6143
6369
|
}
|
|
6144
6370
|
}
|
|
6145
6371
|
if (obj.isDist) {
|
|
6146
|
-
for (
|
|
6147
|
-
|
|
6148
|
-
for (const r of obj.dataRelocList) {
|
|
6149
|
-
if (r.segIdx === sIdx) {
|
|
6150
|
-
const mcName = obj.symNames[r.rs];
|
|
6151
|
-
let matchesLocalType = false;
|
|
6152
|
-
for (const pref of obj.typePrefixesInObj) {
|
|
6153
|
-
if (mcName.startsWith(pref)) {
|
|
6154
|
-
matchesLocalType = true;
|
|
6155
|
-
break;
|
|
6156
|
-
}
|
|
6157
|
-
}
|
|
6158
|
-
if (!matchesLocalType) {
|
|
6159
|
-
const type = conformingType(mcName);
|
|
6160
|
-
if (type === void 0 || globalLiveTypes.has(type))
|
|
6161
|
-
activateSymbolInObj(obj, r.rs);
|
|
6162
|
-
}
|
|
6163
|
-
}
|
|
6164
|
-
}
|
|
6165
|
-
}
|
|
6372
|
+
for (const entries of pendingByObj.get(obj) ?? []) {
|
|
6373
|
+
tryActivateConformance(entries);
|
|
6166
6374
|
}
|
|
6167
6375
|
}
|
|
6168
6376
|
};
|
|
6377
|
+
const pendingByObj = /* @__PURE__ */ new Map();
|
|
6169
6378
|
for (const obj of distObjs.values()) {
|
|
6170
6379
|
if (!obj.isDist) continue;
|
|
6171
6380
|
for (const r of obj.dataRelocList) {
|
|
6172
6381
|
if (obj.segNames[r.segIdx] !== "swift5_protocol_conformances") continue;
|
|
6173
|
-
const
|
|
6174
|
-
|
|
6175
|
-
|
|
6176
|
-
|
|
6177
|
-
|
|
6382
|
+
const mcIdx = r.rs;
|
|
6383
|
+
const mcName = obj.symNames[mcIdx];
|
|
6384
|
+
const swiftType = conformingType(mcName);
|
|
6385
|
+
const objcType = swiftType === void 0 ? objcClassOfConformance(mcName) : void 0;
|
|
6386
|
+
const typeKey = swiftType !== void 0 ? { kind: "swift", value: swiftType } : objcType !== void 0 ? { kind: "objc", value: objcType } : null;
|
|
6387
|
+
const proto = obj.conformanceProtocols.get(mcIdx);
|
|
6388
|
+
const isForeign = swiftType !== void 0 ? !obj.typePrefixesInObj.has(swiftType) : objcType !== void 0 ? !obj.symNames.some(
|
|
6389
|
+
(n, i) => n === `._OBJC_CLASS_${objcType}` && (obj.symFlags[i] & 16) === 0
|
|
6390
|
+
) : false;
|
|
6391
|
+
const entry = {
|
|
6392
|
+
obj,
|
|
6393
|
+
symIdx: mcIdx,
|
|
6394
|
+
typeKey,
|
|
6395
|
+
proto,
|
|
6396
|
+
isForeign,
|
|
6397
|
+
activated: false
|
|
6398
|
+
};
|
|
6399
|
+
let objList = pendingByObj.get(obj);
|
|
6400
|
+
if (!objList) pendingByObj.set(obj, objList = []);
|
|
6401
|
+
objList.push(entry);
|
|
6402
|
+
if (swiftType !== void 0) {
|
|
6403
|
+
let list = pendingBySwiftType.get(swiftType);
|
|
6404
|
+
if (!list) pendingBySwiftType.set(swiftType, list = []);
|
|
6405
|
+
list.push(entry);
|
|
6406
|
+
} else if (objcType !== void 0) {
|
|
6407
|
+
let list = pendingByObjcClass.get(objcType);
|
|
6408
|
+
if (!list) pendingByObjcClass.set(objcType, list = []);
|
|
6409
|
+
list.push(entry);
|
|
6410
|
+
}
|
|
6411
|
+
if (proto !== void 0) {
|
|
6412
|
+
let list = pendingByProto.get(proto);
|
|
6413
|
+
if (!list) pendingByProto.set(proto, list = []);
|
|
6414
|
+
list.push(entry);
|
|
6415
|
+
}
|
|
6416
|
+
}
|
|
6417
|
+
if (obj.objcCategoryTargets.length > 0) {
|
|
6418
|
+
const catFamily = moduleFamily(obj.file);
|
|
6419
|
+
for (const cls of obj.objcCategoryTargets) {
|
|
6420
|
+
const classFamily = objcClassFamilyOf(cls);
|
|
6421
|
+
const entry = {
|
|
6422
|
+
obj,
|
|
6423
|
+
cls,
|
|
6424
|
+
catFamily,
|
|
6425
|
+
classFamily,
|
|
6426
|
+
activated: false
|
|
6427
|
+
};
|
|
6428
|
+
let byCls = pendingCategoriesByClass.get(cls);
|
|
6429
|
+
if (!byCls) pendingCategoriesByClass.set(cls, byCls = []);
|
|
6430
|
+
byCls.push(entry);
|
|
6431
|
+
if (catFamily !== "Foundation" && (classFamily === void 0 || classFamily === "Foundation")) {
|
|
6432
|
+
let byFam = pendingCategoriesByFamily.get(catFamily);
|
|
6433
|
+
if (!byFam) pendingCategoriesByFamily.set(catFamily, byFam = []);
|
|
6434
|
+
byFam.push(entry);
|
|
6435
|
+
}
|
|
6436
|
+
}
|
|
6178
6437
|
}
|
|
6179
6438
|
}
|
|
6180
|
-
let hasClangObjCEager = false;
|
|
6181
6439
|
for (const f of eagerFiles) {
|
|
6182
6440
|
const isDist = f.startsWith(distDir);
|
|
6183
6441
|
const obj = distObjs.get(f) ?? parseWasmObjectCached(f, isDist, false);
|
|
6184
6442
|
extractObject(obj);
|
|
6185
|
-
if (!isDist && !hasClangObjCEager && obj.symNames.includes("__objc_load")) {
|
|
6186
|
-
hasClangObjCEager = true;
|
|
6187
|
-
}
|
|
6188
6443
|
if (isDist) {
|
|
6189
6444
|
const base = import_node_path8.default.basename(f);
|
|
6190
6445
|
if (base.startsWith("PeachFoundation-") || base.startsWith("PeachObjC-") || base.startsWith("PeachICU-") || base.startsWith("Darwin-")) {
|
|
@@ -6207,19 +6462,6 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
6207
6462
|
activateSymbolInObj(provider, provider.symNames.indexOf(name2));
|
|
6208
6463
|
}
|
|
6209
6464
|
}
|
|
6210
|
-
const eagerSdkCategoryFiles = [];
|
|
6211
|
-
if (hasClangObjCEager) {
|
|
6212
|
-
for (const name2 of foundationCategoryObjects.map(
|
|
6213
|
-
(name3) => `libFoundation__${name3}.objc.o`
|
|
6214
|
-
)) {
|
|
6215
|
-
const sdkFile = import_node_path8.default.join(sdkObjsDir, name2);
|
|
6216
|
-
const obj = distObjs.get(sdkFile);
|
|
6217
|
-
if (obj) {
|
|
6218
|
-
extractObject(obj);
|
|
6219
|
-
eagerSdkCategoryFiles.push(sdkFile);
|
|
6220
|
-
}
|
|
6221
|
-
}
|
|
6222
|
-
}
|
|
6223
6465
|
for (const symName of ["_initialize", "__main_argc_argv", "main"]) {
|
|
6224
6466
|
const def = definedGlobalSyms.get(symName);
|
|
6225
6467
|
if (def) activateSymbolInObj(def.obj, def.symIdx);
|
|
@@ -6274,6 +6516,9 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
6274
6516
|
}
|
|
6275
6517
|
for (const symIdx of relocs) {
|
|
6276
6518
|
if (obj.isDist && dropsReflection(obj, obj.symNames[symIdx])) continue;
|
|
6519
|
+
const symName = obj.symNames[symIdx];
|
|
6520
|
+
checkTypeTrigger(obj, symName);
|
|
6521
|
+
checkProtocolTrigger(symName);
|
|
6277
6522
|
const fl = obj.symFlags[symIdx];
|
|
6278
6523
|
const isUndef = (fl & 16) !== 0;
|
|
6279
6524
|
const isLocal = (fl & 3) === 2;
|
|
@@ -6613,21 +6858,12 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
6613
6858
|
writePrunedObject(o, outPath);
|
|
6614
6859
|
prunedMap.set(o.file, outPath);
|
|
6615
6860
|
}
|
|
6616
|
-
const extraSdkObjs = allSdkObjFiles.filter(
|
|
6617
|
-
(f) => f.startsWith("libDarwin__") || f.startsWith("libswiftCore__") && f !== "libswiftCore__Swift.o" || f.startsWith("libswift_Concurrency__") && f !== "libswift_Concurrency___Concurrency.o"
|
|
6618
|
-
).map((f) => import_node_path8.default.join(sdkObjsDir, f));
|
|
6619
6861
|
const outTokens = [];
|
|
6620
6862
|
const emittedPruned = /* @__PURE__ */ new Set();
|
|
6621
6863
|
inStartLib = false;
|
|
6622
6864
|
for (const t of tokens) {
|
|
6623
6865
|
if (t === "--start-lib") {
|
|
6624
6866
|
inStartLib = true;
|
|
6625
|
-
for (const ef of eagerSdkCategoryFiles) {
|
|
6626
|
-
if (!emittedPruned.has(ef) && prunedMap.has(ef)) {
|
|
6627
|
-
outTokens.push(prunedMap.get(ef));
|
|
6628
|
-
emittedPruned.add(ef);
|
|
6629
|
-
}
|
|
6630
|
-
}
|
|
6631
6867
|
for (const obj of eagerDynamicObjects) {
|
|
6632
6868
|
if (!emittedPruned.has(obj.file) && prunedMap.has(obj.file)) {
|
|
6633
6869
|
outTokens.push(prunedMap.get(obj.file));
|
|
@@ -7195,7 +7431,7 @@ function createGuestImageLedger(input) {
|
|
|
7195
7431
|
const objects = units.map(({ image, object: object3, aliases, functionImports }) => {
|
|
7196
7432
|
const shared = bindingsByImage.get(image);
|
|
7197
7433
|
const own = startup.get(object3.path);
|
|
7198
|
-
|
|
7434
|
+
let bindings = own ? new Map([...shared, ...own]) : shared;
|
|
7199
7435
|
for (const [name2, type] of functionImports) {
|
|
7200
7436
|
const alias = bindings.get(name2);
|
|
7201
7437
|
const provider = alias === void 0 ? void 0 : definitionsByAlias.get(alias);
|
|
@@ -7211,6 +7447,7 @@ function createGuestImageLedger(input) {
|
|
|
7211
7447
|
};
|
|
7212
7448
|
resultWrappers.set(key, wrapper);
|
|
7213
7449
|
}
|
|
7450
|
+
if (bindings === shared) bindings = new Map(shared);
|
|
7214
7451
|
bindings.set(name2, wrapper.symbol);
|
|
7215
7452
|
}
|
|
7216
7453
|
return {
|
|
@@ -10161,7 +10398,6 @@ var import_node_crypto10 = __toESM(require("node:crypto"), 1);
|
|
|
10161
10398
|
var import_node_fs14 = __toESM(require("node:fs"), 1);
|
|
10162
10399
|
var import_node_os5 = __toESM(require("node:os"), 1);
|
|
10163
10400
|
var import_node_path14 = __toESM(require("node:path"), 1);
|
|
10164
|
-
var import_node_stream2 = require("node:stream");
|
|
10165
10401
|
var import_promises3 = require("node:stream/promises");
|
|
10166
10402
|
var import_node_zlib = __toESM(require("node:zlib"), 1);
|
|
10167
10403
|
async function installVerifiedTarball(tarball) {
|
|
@@ -10207,17 +10443,20 @@ async function installVerifiedTarballLocked(tarball, presentAtStart) {
|
|
|
10207
10443
|
import_node_path14.default.join(import_node_path14.default.dirname(destDir), `.installing-${import_node_path14.default.basename(destDir)}-`)
|
|
10208
10444
|
);
|
|
10209
10445
|
try {
|
|
10210
|
-
|
|
10211
|
-
|
|
10212
|
-
|
|
10213
|
-
|
|
10214
|
-
|
|
10215
|
-
|
|
10216
|
-
|
|
10217
|
-
if (actual !== digest.value) {
|
|
10218
|
-
throw new Error(
|
|
10219
|
-
`${digest.algorithm} mismatch for ${label}: expected ${digest.value}, actual ${actual}`
|
|
10446
|
+
for (let attempt = 1; ; attempt++) {
|
|
10447
|
+
await downloadToFile(url, archivePath, signal);
|
|
10448
|
+
const actual = await digestFile(
|
|
10449
|
+
archivePath,
|
|
10450
|
+
digest.algorithm,
|
|
10451
|
+
digest.encoding,
|
|
10452
|
+
signal
|
|
10220
10453
|
);
|
|
10454
|
+
if (actual === digest.value) break;
|
|
10455
|
+
if (attempt >= 2) {
|
|
10456
|
+
throw new Error(
|
|
10457
|
+
`${digest.algorithm} mismatch for ${label}: expected ${digest.value}, actual ${actual}`
|
|
10458
|
+
);
|
|
10459
|
+
}
|
|
10221
10460
|
}
|
|
10222
10461
|
const { pathname } = new URL(url);
|
|
10223
10462
|
if (pathname.endsWith(".zip")) await extractZip(archivePath, tmpDir, signal);
|
|
@@ -10268,27 +10507,87 @@ async function installVerifiedTarballLocked(tarball, presentAtStart) {
|
|
|
10268
10507
|
function isErrnoCode(err, ...codes) {
|
|
10269
10508
|
return err instanceof Error && "code" in err && codes.includes(String(err.code));
|
|
10270
10509
|
}
|
|
10271
|
-
|
|
10272
|
-
|
|
10273
|
-
|
|
10274
|
-
|
|
10510
|
+
var DownloadHttpError = class extends Error {
|
|
10511
|
+
retryable;
|
|
10512
|
+
constructor(status, statusText, url) {
|
|
10513
|
+
super(`download failed: ${status} ${statusText} (${url})`);
|
|
10514
|
+
this.retryable = status < 400 || status >= 500 || status === 408 || status === 429;
|
|
10275
10515
|
}
|
|
10516
|
+
};
|
|
10517
|
+
async function waitRetryDelay(ms, signal) {
|
|
10518
|
+
signal?.throwIfAborted();
|
|
10519
|
+
await new Promise((resolve, reject) => {
|
|
10520
|
+
const onAbort = () => {
|
|
10521
|
+
clearTimeout(timer);
|
|
10522
|
+
const reason = signal?.reason;
|
|
10523
|
+
reject(
|
|
10524
|
+
reason instanceof Error ? reason : new Error("Download canceled", { cause: reason })
|
|
10525
|
+
);
|
|
10526
|
+
};
|
|
10527
|
+
const timer = setTimeout(() => {
|
|
10528
|
+
signal?.removeEventListener("abort", onAbort);
|
|
10529
|
+
resolve();
|
|
10530
|
+
}, ms);
|
|
10531
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
10532
|
+
});
|
|
10533
|
+
}
|
|
10534
|
+
async function downloadToFile(url, destPath, signal) {
|
|
10276
10535
|
import_node_fs14.default.mkdirSync(import_node_path14.default.dirname(destPath), { recursive: true });
|
|
10277
10536
|
const tmp = `${destPath}.partial`;
|
|
10278
|
-
|
|
10279
|
-
await (0, import_promises3.pipeline)(
|
|
10280
|
-
import_node_stream2.Readable.fromWeb(res.body),
|
|
10281
|
-
import_node_fs14.default.createWriteStream(tmp),
|
|
10282
|
-
{ signal }
|
|
10283
|
-
);
|
|
10537
|
+
for (let attempt = 1; attempt <= 4; attempt++) {
|
|
10284
10538
|
signal?.throwIfAborted();
|
|
10285
|
-
|
|
10286
|
-
|
|
10539
|
+
let reader2;
|
|
10540
|
+
let handle;
|
|
10541
|
+
let completed = false;
|
|
10287
10542
|
try {
|
|
10288
|
-
|
|
10289
|
-
|
|
10543
|
+
const res = await fetch(url, { signal });
|
|
10544
|
+
if (!res.ok || !res.body) {
|
|
10545
|
+
throw new DownloadHttpError(res.status, res.statusText, url);
|
|
10546
|
+
}
|
|
10547
|
+
reader2 = res.body.getReader();
|
|
10548
|
+
handle = await import_node_fs14.default.promises.open(tmp, "w");
|
|
10549
|
+
let written = 0;
|
|
10550
|
+
for (; ; ) {
|
|
10551
|
+
signal?.throwIfAborted();
|
|
10552
|
+
const { done, value } = await reader2.read();
|
|
10553
|
+
if (done) break;
|
|
10554
|
+
let offset = 0;
|
|
10555
|
+
while (offset < value.byteLength) {
|
|
10556
|
+
const { bytesWritten } = await handle.write(
|
|
10557
|
+
value,
|
|
10558
|
+
offset,
|
|
10559
|
+
value.byteLength - offset
|
|
10560
|
+
);
|
|
10561
|
+
offset += bytesWritten;
|
|
10562
|
+
}
|
|
10563
|
+
written += value.byteLength;
|
|
10564
|
+
}
|
|
10565
|
+
await handle.close();
|
|
10566
|
+
handle = void 0;
|
|
10567
|
+
if (!res.headers.get("content-encoding")) {
|
|
10568
|
+
const header = res.headers.get("content-length");
|
|
10569
|
+
const expected = header ? Number(header) : Number.NaN;
|
|
10570
|
+
if (Number.isFinite(expected) && expected > 0 && written !== expected) {
|
|
10571
|
+
throw new Error(`incomplete download (${written}/${expected} bytes): ${url}`);
|
|
10572
|
+
}
|
|
10573
|
+
}
|
|
10574
|
+
signal?.throwIfAborted();
|
|
10575
|
+
import_node_fs14.default.renameSync(tmp, destPath);
|
|
10576
|
+
completed = true;
|
|
10577
|
+
return;
|
|
10578
|
+
} catch (err) {
|
|
10579
|
+
if (handle) await handle.close().catch(() => {
|
|
10580
|
+
});
|
|
10581
|
+
if (reader2 && !completed) await reader2.cancel().catch(() => {
|
|
10582
|
+
});
|
|
10583
|
+
try {
|
|
10584
|
+
import_node_fs14.default.unlinkSync(tmp);
|
|
10585
|
+
} catch {
|
|
10586
|
+
}
|
|
10587
|
+
const nonRetryable = err instanceof DownloadHttpError && !err.retryable;
|
|
10588
|
+
if (signal?.aborted || nonRetryable || attempt === 4) throw err;
|
|
10589
|
+
await waitRetryDelay(250 * attempt, signal);
|
|
10290
10590
|
}
|
|
10291
|
-
throw err;
|
|
10292
10591
|
}
|
|
10293
10592
|
}
|
|
10294
10593
|
async function digestFile(filePath, algorithm, encoding, signal) {
|
|
@@ -11341,10 +11640,6 @@ async function swiftIcuBundleAsset(icu) {
|
|
|
11341
11640
|
// src/swift-link-roots.ts
|
|
11342
11641
|
var import_node_fs18 = __toESM(require("node:fs"), 1);
|
|
11343
11642
|
var import_node_path19 = __toESM(require("node:path"), 1);
|
|
11344
|
-
var OBJC_SENTINELS = /* @__PURE__ */ new Map([
|
|
11345
|
-
["__objc_cats", ".objc_null_category"],
|
|
11346
|
-
["__objc_class_aliases", ".objc_null_class_alias"]
|
|
11347
|
-
]);
|
|
11348
11643
|
var leb = (bytes, at) => {
|
|
11349
11644
|
let value = 0;
|
|
11350
11645
|
let scale = 1;
|
|
@@ -11359,6 +11654,7 @@ function objcRootInfo(bytes) {
|
|
|
11359
11654
|
const at = { offset: 8 };
|
|
11360
11655
|
const names = [];
|
|
11361
11656
|
const dataSymbols = [];
|
|
11657
|
+
let hasNSObjectLoad = false;
|
|
11362
11658
|
let hasExportedSymbol = false;
|
|
11363
11659
|
while (at.offset < bytes.length) {
|
|
11364
11660
|
const id = bytes[at.offset++];
|
|
@@ -11395,6 +11691,12 @@ function objcRootInfo(bytes) {
|
|
|
11395
11691
|
leb(bytes, at);
|
|
11396
11692
|
if (!isUndef || isExplicitName) {
|
|
11397
11693
|
const sLen = leb(bytes, at);
|
|
11694
|
+
if (!isUndef && symKind === 0) {
|
|
11695
|
+
const name3 = Buffer.from(
|
|
11696
|
+
bytes.subarray(at.offset, at.offset + sLen)
|
|
11697
|
+
).toString();
|
|
11698
|
+
if (/^_c_NSObject_.*_load$/.test(name3)) hasNSObjectLoad = true;
|
|
11699
|
+
}
|
|
11398
11700
|
at.offset += sLen;
|
|
11399
11701
|
}
|
|
11400
11702
|
} else if (symKind === 1) {
|
|
@@ -11421,11 +11723,9 @@ function objcRootInfo(bytes) {
|
|
|
11421
11723
|
at.offset = end;
|
|
11422
11724
|
}
|
|
11423
11725
|
return {
|
|
11424
|
-
registration: dataSymbols.some(
|
|
11425
|
-
|
|
11426
|
-
|
|
11427
|
-
return sentinel !== void 0 && name2 !== sentinel;
|
|
11428
|
-
}),
|
|
11726
|
+
registration: hasNSObjectLoad || dataSymbols.some(
|
|
11727
|
+
({ segment, name: name2 }) => names[segment] === "__objc_class_aliases" && name2 !== ".objc_null_class_alias"
|
|
11728
|
+
),
|
|
11429
11729
|
exported: hasExportedSymbol
|
|
11430
11730
|
};
|
|
11431
11731
|
}
|
|
@@ -11438,9 +11738,7 @@ function swiftObjcRootObjects(id, root, objects) {
|
|
|
11438
11738
|
);
|
|
11439
11739
|
const roots = new Set(
|
|
11440
11740
|
measured.filter(
|
|
11441
|
-
([object3, info]) =>
|
|
11442
|
-
(name2) => object3 === `lib/Foundation-${name2}.o`
|
|
11443
|
-
) && object3 !== "lib/FoundationNetworking-Session.o" && object3 !== "lib/SwiftUI-MetalExecution.o" && object3 !== "lib/UIKitCore-NativeStub.o" && (info.registration || info.exported)
|
|
11741
|
+
([object3, info]) => object3 !== "lib/FoundationNetworking-Session.o" && object3 !== "lib/Metal-MetalExecution.o" && object3 !== "lib/PeachICU-icu.c.o" && object3 !== "lib/SwiftUI-MetalExecution.o" && object3 !== "lib/UIKitCore-NativeStub.o" && (info.registration || info.exported)
|
|
11444
11742
|
).map(([object3]) => object3)
|
|
11445
11743
|
);
|
|
11446
11744
|
rootsByDistribution.set(id, roots);
|
|
@@ -13117,6 +13415,8 @@ var executableLinkFlags = (root) => ` "-Xclang-linker", "-O0",
|
|
|
13117
13415
|
"-Xlinker", "--global-base=8372224",
|
|
13118
13416
|
"-Xlinker", "-lsetjmp",
|
|
13119
13417
|
"-Xlinker", "--export-table",
|
|
13418
|
+
"-Xlinker", "--export-if-defined=__cpp_exception",
|
|
13419
|
+
"-Xlinker", "--export-if-defined=__objc_wasm_terminate",
|
|
13120
13420
|
"-Xlinker", "--growable-table",
|
|
13121
13421
|
"-Xlinker", "--wrap=swift_udata_open",
|
|
13122
13422
|
"-Xlinker", "--wrap=swift_udata_openChoice",
|
|
@@ -13125,7 +13425,7 @@ var darwinRecordsRegion = (quoted2) => quoted2.length ? ["-Wl,--start-lib", ...q
|
|
|
13125
13425
|
var REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
|
|
13126
13426
|
var MULTI_MANIFEST_VERSION = 68;
|
|
13127
13427
|
var SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
|
|
13128
|
-
var compilerSourceDigest = true ? "
|
|
13428
|
+
var compilerSourceDigest = true ? "05dbb1273689060748700777894c639c73bea2e6da20eaf47e8040b26ff859cf" : swiftCompilerSourceDigest(__sootsim_import_meta_dirname);
|
|
13129
13429
|
function swiftArtifactHash(input, release, moduleRoot) {
|
|
13130
13430
|
const hash = (0, import_node_crypto13.createHash)("sha256");
|
|
13131
13431
|
hash.update(`swift-compile
|