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,7 @@
|
|
|
1
|
-
/*! peach v0.1.
|
|
1
|
+
/*! peach v0.1.2257 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
2
5
|
|
|
3
6
|
// src/swift-compile.ts
|
|
4
7
|
import {
|
|
@@ -5333,18 +5336,22 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
5333
5336
|
const [, r1] = readULEB2(buf, cp);
|
|
5334
5337
|
const [cnt, r2] = readULEB2(buf, r1);
|
|
5335
5338
|
let cur = r2;
|
|
5336
|
-
const
|
|
5339
|
+
const isData = name2 === "reloc.DATA";
|
|
5337
5340
|
for (let i = 0; i < cnt; i++) {
|
|
5338
5341
|
const rStart = cur;
|
|
5339
5342
|
const rType = buf[cur++];
|
|
5340
5343
|
const [ro, c2] = readULEB2(buf, cur);
|
|
5341
5344
|
const [rs, c3] = readULEB2(buf, c2);
|
|
5342
5345
|
cur = c3;
|
|
5346
|
+
let addend = 0;
|
|
5343
5347
|
if (HAS_ADDEND.has(rType)) {
|
|
5344
|
-
const [, c4] = readSLEB(buf, cur);
|
|
5348
|
+
const [val, c4] = readSLEB(buf, cur);
|
|
5349
|
+
addend = val;
|
|
5345
5350
|
cur = c4;
|
|
5346
5351
|
}
|
|
5347
|
-
|
|
5352
|
+
const rawBytes = new Uint8Array(buf.subarray(rStart, cur));
|
|
5353
|
+
if (isData) rawDataRelocs.push({ rawBytes, ro, rs, addend });
|
|
5354
|
+
else rawCodeRelocs.push({ rawBytes, ro, rs });
|
|
5348
5355
|
}
|
|
5349
5356
|
}
|
|
5350
5357
|
}
|
|
@@ -5498,6 +5505,80 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
5498
5505
|
rootSegs.push(i);
|
|
5499
5506
|
}
|
|
5500
5507
|
}
|
|
5508
|
+
const conformanceProtocols = /* @__PURE__ */ new Map();
|
|
5509
|
+
const objcCategoryTargets = [];
|
|
5510
|
+
if (isDist) {
|
|
5511
|
+
const relocAt = /* @__PURE__ */ new Map();
|
|
5512
|
+
for (const r of dataRelocList) {
|
|
5513
|
+
relocAt.set(`${r.segIdx}:${r.offInSeg}`, { rs: r.rs, addend: r.addend });
|
|
5514
|
+
}
|
|
5515
|
+
const confSegs = /* @__PURE__ */ new Set();
|
|
5516
|
+
let hasCatsSeg = false;
|
|
5517
|
+
for (let i = 0; i < segNames.length; i++) {
|
|
5518
|
+
if (segNames[i] === "swift5_protocol_conformances") confSegs.add(i);
|
|
5519
|
+
else if (segNames[i] === "__objc_cats") hasCatsSeg = true;
|
|
5520
|
+
}
|
|
5521
|
+
if (confSegs.size > 0) {
|
|
5522
|
+
const segOffToMpSym = /* @__PURE__ */ new Map();
|
|
5523
|
+
for (let i = 0; i < symKind.length; i++) {
|
|
5524
|
+
if (symKind[i] === 1 && (symFlags[i] & 16) === 0 && symElemIdx[i] >= 0 && symNames[i].startsWith("$s") && symNames[i].endsWith("Mp")) {
|
|
5525
|
+
segOffToMpSym.set(`${symElemIdx[i]}:${symOff[i]}`, symNames[i]);
|
|
5526
|
+
}
|
|
5527
|
+
}
|
|
5528
|
+
const dv = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
5529
|
+
for (const r of dataRelocList) {
|
|
5530
|
+
if (!confSegs.has(r.segIdx)) continue;
|
|
5531
|
+
const mcIdx = r.rs;
|
|
5532
|
+
if (symKind[mcIdx] !== 1 || (symFlags[mcIdx] & 16) !== 0 || symElemIdx[mcIdx] < 0) {
|
|
5533
|
+
continue;
|
|
5534
|
+
}
|
|
5535
|
+
const mcSeg = symElemIdx[mcIdx];
|
|
5536
|
+
const mcOff = symOff[mcIdx];
|
|
5537
|
+
const pr = relocAt.get(`${mcSeg}:${mcOff}`);
|
|
5538
|
+
let mp = "";
|
|
5539
|
+
if (pr) {
|
|
5540
|
+
const raw2 = symNames[pr.rs];
|
|
5541
|
+
const stripped = raw2.startsWith(".Lgot.") ? raw2.slice(6) : raw2;
|
|
5542
|
+
if (stripped.startsWith("$s") && stripped.endsWith("Mp")) {
|
|
5543
|
+
mp = stripped;
|
|
5544
|
+
} else if (symKind[pr.rs] === 3 || stripped === "") {
|
|
5545
|
+
mp = segOffToMpSym.get(`${mcSeg}:${pr.addend}`) ?? "";
|
|
5546
|
+
}
|
|
5547
|
+
} else {
|
|
5548
|
+
const fileOff = dataStart + sPayloadStarts[mcSeg] + mcOff;
|
|
5549
|
+
if (fileOff + 4 <= buf.length) {
|
|
5550
|
+
const delta = dv.getInt32(fileOff, true);
|
|
5551
|
+
mp = segOffToMpSym.get(`${mcSeg}:${mcOff + delta}`) ?? segOffToMpSym.get(`${mcSeg}:${mcOff + (delta & ~1)}`) ?? "";
|
|
5552
|
+
}
|
|
5553
|
+
}
|
|
5554
|
+
if (mp) conformanceProtocols.set(mcIdx, mp);
|
|
5555
|
+
}
|
|
5556
|
+
}
|
|
5557
|
+
if (hasCatsSeg) {
|
|
5558
|
+
const seenClasses = /* @__PURE__ */ new Set();
|
|
5559
|
+
for (let i = 0; i < symKind.length; i++) {
|
|
5560
|
+
if (symKind[i] !== 1 || (symFlags[i] & 16) !== 0 || symElemIdx[i] < 0 || segNames[symElemIdx[i]] !== "__objc_cats" || !symNames[i].startsWith(".objc_category_")) {
|
|
5561
|
+
continue;
|
|
5562
|
+
}
|
|
5563
|
+
const cSeg = symElemIdx[i];
|
|
5564
|
+
const cOff = symOff[i];
|
|
5565
|
+
const cr = relocAt.get(`${cSeg}:${cOff + 8}`);
|
|
5566
|
+
if (cr && symKind[cr.rs] === 1 && (symFlags[cr.rs] & 16) === 0 && symElemIdx[cr.rs] >= 0) {
|
|
5567
|
+
const tSeg = symElemIdx[cr.rs];
|
|
5568
|
+
const strOff = dataStart + sPayloadStarts[tSeg] + symOff[cr.rs] + cr.addend;
|
|
5569
|
+
let sEnd = strOff;
|
|
5570
|
+
while (sEnd < buf.length && buf[sEnd] !== 0) sEnd++;
|
|
5571
|
+
if (sEnd > strOff) {
|
|
5572
|
+
const clsName = Buffer.from(buf.subarray(strOff, sEnd)).toString("utf8");
|
|
5573
|
+
if (!seenClasses.has(clsName)) {
|
|
5574
|
+
seenClasses.add(clsName);
|
|
5575
|
+
objcCategoryTargets.push(clsName);
|
|
5576
|
+
}
|
|
5577
|
+
}
|
|
5578
|
+
}
|
|
5579
|
+
}
|
|
5580
|
+
}
|
|
5581
|
+
}
|
|
5501
5582
|
return {
|
|
5502
5583
|
file,
|
|
5503
5584
|
isDist,
|
|
@@ -5522,6 +5603,8 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
5522
5603
|
objcRegisterFuncToTypePrefix,
|
|
5523
5604
|
objcClassSymToTypePrefix,
|
|
5524
5605
|
typePrefixesInObj,
|
|
5606
|
+
conformanceProtocols,
|
|
5607
|
+
objcCategoryTargets,
|
|
5525
5608
|
rootFuncs,
|
|
5526
5609
|
rootSegs,
|
|
5527
5610
|
segPayloadRanges: sEnds.map((end, i) => [
|
|
@@ -5533,7 +5616,7 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
5533
5616
|
function parseWasmObjectCached(file, isDist, useCache) {
|
|
5534
5617
|
if (!useCache)
|
|
5535
5618
|
return parseWasmObjectBytes(file, new Uint8Array(fs4.readFileSync(file)), isDist);
|
|
5536
|
-
const key =
|
|
5619
|
+
const key = `v2:${isDist ? "1" : "0"}:${file}`;
|
|
5537
5620
|
const stat = fs4.statSync(file, { bigint: true });
|
|
5538
5621
|
const stamp = `${stat.ino}:${stat.size}:${stat.mtimeNs}:${stat.ctimeNs}`;
|
|
5539
5622
|
const hit = parsedObjectCache.get(key);
|
|
@@ -5693,6 +5776,18 @@ function getModulePrefix(file) {
|
|
|
5693
5776
|
const dash = base.indexOf("-");
|
|
5694
5777
|
return dash > 0 ? base.slice(0, dash) : base;
|
|
5695
5778
|
}
|
|
5779
|
+
function moduleFamily(file) {
|
|
5780
|
+
const mod = getModulePrefix(file);
|
|
5781
|
+
if (mod === "Foundation" || mod === "PeachFoundation" || mod === "PeachObjC" || mod === "PeachObjCRuntime" || mod === "ObjectiveC" || mod === "Darwin" || mod === "libFoundation" || mod === "libObjectiveC" || mod === "libDarwin" || mod === "libswiftCore") {
|
|
5782
|
+
return "Foundation";
|
|
5783
|
+
}
|
|
5784
|
+
if (mod.startsWith("UIKit")) return "UIKit";
|
|
5785
|
+
if (mod === "CoreData" || mod === "CoreDataConstants") return "CoreData";
|
|
5786
|
+
if (mod === "AVFoundation" || mod === "AVFoundationConstants" || mod === "AVFAudio") {
|
|
5787
|
+
return "AVFoundation";
|
|
5788
|
+
}
|
|
5789
|
+
return mod;
|
|
5790
|
+
}
|
|
5696
5791
|
var SWIFTUI_WRAPPER_HOST_PROTOCOLS = new Set(
|
|
5697
5792
|
[
|
|
5698
5793
|
"View",
|
|
@@ -5786,11 +5881,7 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
5786
5881
|
}
|
|
5787
5882
|
if (t.endsWith(".o")) {
|
|
5788
5883
|
if (path10.resolve(t).startsWith(distDir + path10.sep)) {
|
|
5789
|
-
|
|
5790
|
-
(name2) => path10.basename(t) === `Foundation-${name2}.o`
|
|
5791
|
-
)) {
|
|
5792
|
-
distFiles.push(t);
|
|
5793
|
-
}
|
|
5884
|
+
distFiles.push(t);
|
|
5794
5885
|
if (!inStartLib) eagerFiles.push(t);
|
|
5795
5886
|
} else if (!inStartLib) {
|
|
5796
5887
|
if (t.endsWith("/swiftrt.o")) {
|
|
@@ -5859,6 +5950,9 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
5859
5950
|
}
|
|
5860
5951
|
const allSdkObjFiles = fs4.readdirSync(sdkObjsDir).filter((f) => f.endsWith(".o") || f.endsWith(".obj")).sort();
|
|
5861
5952
|
const sdkFiles = allSdkObjFiles.map((f) => path10.join(sdkObjsDir, f));
|
|
5953
|
+
const extraSdkObjs = allSdkObjFiles.filter(
|
|
5954
|
+
(f) => f.startsWith("libDarwin__") || f.startsWith("libswiftCore__") && f !== "libswiftCore__Swift.o" || f.startsWith("libswift_Concurrency__") && f !== "libswift_Concurrency___Concurrency.o"
|
|
5955
|
+
).map((f) => path10.join(sdkObjsDir, f));
|
|
5862
5956
|
const distObjs = /* @__PURE__ */ new Map();
|
|
5863
5957
|
const lazyProviders = /* @__PURE__ */ new Map();
|
|
5864
5958
|
const registerLazyProvider = (obj) => {
|
|
@@ -5922,11 +6016,33 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
5922
6016
|
workQueue.push({ kind: "datasym", obj, symIdx });
|
|
5923
6017
|
};
|
|
5924
6018
|
const knownTypes = /* @__PURE__ */ new Set();
|
|
5925
|
-
|
|
6019
|
+
const knownProtocols = /* @__PURE__ */ new Set();
|
|
6020
|
+
const protoPrefixes = /* @__PURE__ */ new Set();
|
|
6021
|
+
for (const o of distObjs.values()) {
|
|
5926
6022
|
for (const t of o.typePrefixesInObj) knownTypes.add(t);
|
|
6023
|
+
for (let i = 0; i < o.symNames.length; i++) {
|
|
6024
|
+
if (o.symKind[i] === 1 && (o.symFlags[i] & 16) === 0 && o.symNames[i].startsWith("$s") && o.symNames[i].endsWith("Mp")) {
|
|
6025
|
+
const mp = o.symNames[i];
|
|
6026
|
+
knownProtocols.add(mp);
|
|
6027
|
+
protoPrefixes.add(mp.slice(0, -2));
|
|
6028
|
+
}
|
|
6029
|
+
}
|
|
6030
|
+
for (const mp of o.conformanceProtocols.values()) {
|
|
6031
|
+
knownProtocols.add(mp);
|
|
6032
|
+
protoPrefixes.add(mp.slice(0, -2));
|
|
6033
|
+
}
|
|
6034
|
+
}
|
|
5927
6035
|
const globalLiveTypes = /* @__PURE__ */ new Set();
|
|
5928
|
-
const
|
|
6036
|
+
const liveProtocols = /* @__PURE__ */ new Set();
|
|
6037
|
+
const liveObjCClasses = /* @__PURE__ */ new Set();
|
|
6038
|
+
const liveModuleFamilies = /* @__PURE__ */ new Set();
|
|
6039
|
+
const categoryOnlyExtracted = /* @__PURE__ */ new Set();
|
|
5929
6040
|
const eagerDynamicObjects = /* @__PURE__ */ new Set();
|
|
6041
|
+
const pendingBySwiftType = /* @__PURE__ */ new Map();
|
|
6042
|
+
const pendingByObjcClass = /* @__PURE__ */ new Map();
|
|
6043
|
+
const pendingByProto = /* @__PURE__ */ new Map();
|
|
6044
|
+
const pendingCategoriesByClass = /* @__PURE__ */ new Map();
|
|
6045
|
+
const pendingCategoriesByFamily = /* @__PURE__ */ new Map();
|
|
5930
6046
|
const conformingType = (name2) => {
|
|
5931
6047
|
for (let n = name2.length - 1; n > 2; n--) {
|
|
5932
6048
|
const prefix = name2.slice(0, n);
|
|
@@ -5934,23 +6050,114 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
5934
6050
|
}
|
|
5935
6051
|
return void 0;
|
|
5936
6052
|
};
|
|
6053
|
+
const objcClassOfConformance = (name2) => {
|
|
6054
|
+
const m = /^\$sSo(\d+)([A-Za-z0-9_]+)/.exec(name2);
|
|
6055
|
+
if (!m) return void 0;
|
|
6056
|
+
const len = Number(m[1]);
|
|
6057
|
+
const rest = m[2];
|
|
6058
|
+
if (rest.length <= len || rest[len] !== "C") return void 0;
|
|
6059
|
+
const cls = rest.slice(0, len);
|
|
6060
|
+
return lazyProviders.has(`._OBJC_CLASS_${cls}`) ? cls : void 0;
|
|
6061
|
+
};
|
|
6062
|
+
const objcClassFamilyOf = (cls) => {
|
|
6063
|
+
const providers = lazyProviders.get(`._OBJC_CLASS_${cls}`);
|
|
6064
|
+
if (!providers || providers.length === 0) return void 0;
|
|
6065
|
+
return moduleFamily(providers[0].file);
|
|
6066
|
+
};
|
|
6067
|
+
const tryActivateConformance = (entry) => {
|
|
6068
|
+
if (entry.activated) return;
|
|
6069
|
+
const typeReady = entry.typeKey === null ? true : entry.typeKey.kind === "swift" ? globalLiveTypes.has(entry.typeKey.value) : liveObjCClasses.has(entry.typeKey.value);
|
|
6070
|
+
if (!typeReady) return;
|
|
6071
|
+
if (entry.proto !== void 0 && !liveProtocols.has(entry.proto)) return;
|
|
6072
|
+
if (entry.isForeign) {
|
|
6073
|
+
eagerDynamicObjects.add(entry.obj);
|
|
6074
|
+
extractObject(entry.obj);
|
|
6075
|
+
} else if (!extractedObjs.has(entry.obj)) {
|
|
6076
|
+
return;
|
|
6077
|
+
}
|
|
6078
|
+
entry.activated = true;
|
|
6079
|
+
activateSymbolInObj(entry.obj, entry.symIdx);
|
|
6080
|
+
};
|
|
6081
|
+
const tryActivateCategory = (entry) => {
|
|
6082
|
+
if (entry.activated || !liveObjCClasses.has(entry.cls)) return;
|
|
6083
|
+
const allowed = entry.catFamily === "Foundation" || entry.classFamily !== void 0 && entry.classFamily !== "Foundation" || liveModuleFamilies.has(entry.catFamily);
|
|
6084
|
+
if (!allowed) return;
|
|
6085
|
+
entry.activated = true;
|
|
6086
|
+
eagerDynamicObjects.add(entry.obj);
|
|
6087
|
+
extractObject(entry.obj, true);
|
|
6088
|
+
};
|
|
6089
|
+
const markModuleFamilyLive = (family) => {
|
|
6090
|
+
if (liveModuleFamilies.has(family)) return;
|
|
6091
|
+
liveModuleFamilies.add(family);
|
|
6092
|
+
const waiting = pendingCategoriesByFamily.get(family);
|
|
6093
|
+
if (waiting) {
|
|
6094
|
+
pendingCategoriesByFamily.delete(family);
|
|
6095
|
+
for (const entry of waiting) tryActivateCategory(entry);
|
|
6096
|
+
}
|
|
6097
|
+
};
|
|
6098
|
+
const markObjCClassLive = (cls) => {
|
|
6099
|
+
if (!cls || liveObjCClasses.has(cls)) return;
|
|
6100
|
+
liveObjCClasses.add(cls);
|
|
6101
|
+
const confs = pendingByObjcClass.get(cls);
|
|
6102
|
+
if (confs) {
|
|
6103
|
+
for (const entry of confs) tryActivateConformance(entry);
|
|
6104
|
+
}
|
|
6105
|
+
const cats = pendingCategoriesByClass.get(cls);
|
|
6106
|
+
if (cats) {
|
|
6107
|
+
for (const entry of cats) tryActivateCategory(entry);
|
|
6108
|
+
}
|
|
6109
|
+
};
|
|
6110
|
+
const markProtocolLive = (mpName) => {
|
|
6111
|
+
if (!mpName || liveProtocols.has(mpName)) return;
|
|
6112
|
+
liveProtocols.add(mpName);
|
|
6113
|
+
const waiting = pendingByProto.get(mpName);
|
|
6114
|
+
if (waiting) {
|
|
6115
|
+
for (const entry of waiting) tryActivateConformance(entry);
|
|
6116
|
+
}
|
|
6117
|
+
};
|
|
6118
|
+
const checkProtocolTrigger = (rawSymName) => {
|
|
6119
|
+
if (!rawSymName) return;
|
|
6120
|
+
const sName = rawSymName.startsWith(".Lgot.") ? rawSymName.slice(6) : rawSymName;
|
|
6121
|
+
if (knownProtocols.has(sName)) {
|
|
6122
|
+
markProtocolLive(sName);
|
|
6123
|
+
return;
|
|
6124
|
+
}
|
|
6125
|
+
if (!sName.startsWith("$s") || sName.endsWith("Mc")) return;
|
|
6126
|
+
if (sName.endsWith("TL")) {
|
|
6127
|
+
const mp = `${sName.slice(0, -2)}Mp`;
|
|
6128
|
+
if (knownProtocols.has(mp)) {
|
|
6129
|
+
markProtocolLive(mp);
|
|
6130
|
+
return;
|
|
6131
|
+
}
|
|
6132
|
+
}
|
|
6133
|
+
if (sName.startsWith("$sS") && sName.length > 4) {
|
|
6134
|
+
const pref = sName.slice(0, 4);
|
|
6135
|
+
if (protoPrefixes.has(pref)) {
|
|
6136
|
+
const ch = sName[4];
|
|
6137
|
+
if (ch >= "0" && ch <= "9" || ch === "s" || ch === "P") {
|
|
6138
|
+
markProtocolLive(`${pref}Mp`);
|
|
6139
|
+
return;
|
|
6140
|
+
}
|
|
6141
|
+
}
|
|
6142
|
+
}
|
|
6143
|
+
for (let n = 5; n < sName.length; n++) {
|
|
6144
|
+
if (sName[n] === "P") {
|
|
6145
|
+
const pref = sName.slice(0, n);
|
|
6146
|
+
if (protoPrefixes.has(pref)) {
|
|
6147
|
+
markProtocolLive(`${pref}Mp`);
|
|
6148
|
+
return;
|
|
6149
|
+
}
|
|
6150
|
+
}
|
|
6151
|
+
}
|
|
6152
|
+
};
|
|
5937
6153
|
const markTypeLive = (obj, pref) => {
|
|
5938
6154
|
const set = liveTypes.get(obj);
|
|
5939
6155
|
if (set.has(pref)) return;
|
|
5940
6156
|
set.add(pref);
|
|
5941
6157
|
globalLiveTypes.add(pref);
|
|
5942
|
-
const waiting =
|
|
6158
|
+
const waiting = pendingBySwiftType.get(pref);
|
|
5943
6159
|
if (waiting) {
|
|
5944
|
-
|
|
5945
|
-
for (const w of waiting) {
|
|
5946
|
-
eagerDynamicObjects.add(w.obj);
|
|
5947
|
-
extractObject(w.obj);
|
|
5948
|
-
activateSymbolInObj(w.obj, w.symIdx);
|
|
5949
|
-
}
|
|
5950
|
-
}
|
|
5951
|
-
for (let n = pref.length - 1; n > 2; n--) {
|
|
5952
|
-
const outer = pref.slice(0, n);
|
|
5953
|
-
if (obj.typePrefixesInObj.has(outer)) markTypeLive(obj, outer);
|
|
6160
|
+
for (const entry of waiting) tryActivateConformance(entry);
|
|
5954
6161
|
}
|
|
5955
6162
|
for (let n = pref.length - 1; n > 2; n--) {
|
|
5956
6163
|
const outer = pref.slice(0, n);
|
|
@@ -5967,22 +6174,20 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
5967
6174
|
markFuncLive(obj, lf);
|
|
5968
6175
|
}
|
|
5969
6176
|
}
|
|
5970
|
-
for (
|
|
5971
|
-
if (
|
|
5972
|
-
|
|
5973
|
-
if (r.segIdx === sIdx) {
|
|
5974
|
-
const mcName = obj.symNames[r.rs];
|
|
5975
|
-
if (mcName.startsWith(pref)) {
|
|
5976
|
-
activateSymbolInObj(obj, r.rs);
|
|
5977
|
-
}
|
|
5978
|
-
}
|
|
5979
|
-
}
|
|
6177
|
+
for (const [classSym, p] of obj.objcClassSymToTypePrefix) {
|
|
6178
|
+
if (p === pref && classSym.startsWith("._OBJC_CLASS_")) {
|
|
6179
|
+
markObjCClassLive(classSym.slice("._OBJC_CLASS_".length));
|
|
5980
6180
|
}
|
|
5981
6181
|
}
|
|
5982
6182
|
};
|
|
5983
6183
|
const checkTypeTrigger = (obj, rawSymName) => {
|
|
5984
6184
|
if (!rawSymName) return;
|
|
5985
6185
|
const sName = rawSymName.startsWith(".Lgot.") ? rawSymName.slice(6) : rawSymName;
|
|
6186
|
+
if (sName.startsWith("._OBJC_CLASS_")) {
|
|
6187
|
+
markObjCClassLive(sName.slice("._OBJC_CLASS_".length));
|
|
6188
|
+
} else if (sName.startsWith("._OBJC_METACLASS_")) {
|
|
6189
|
+
markObjCClassLive(sName.slice("._OBJC_METACLASS_".length));
|
|
6190
|
+
}
|
|
5986
6191
|
const objcPref = obj.objcClassSymToTypePrefix.get(sName);
|
|
5987
6192
|
if (objcPref) {
|
|
5988
6193
|
markTypeLive(obj, objcPref);
|
|
@@ -6009,6 +6214,7 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
6009
6214
|
const activateGlobalName = (name2) => {
|
|
6010
6215
|
if (!name2) return;
|
|
6011
6216
|
if (!liveGlobalNames.has(name2)) liveGlobalNames.add(name2);
|
|
6217
|
+
checkProtocolTrigger(name2);
|
|
6012
6218
|
const defs = extractedSymbolDefs.get(name2);
|
|
6013
6219
|
if (defs) {
|
|
6014
6220
|
for (const d of defs) {
|
|
@@ -6023,7 +6229,12 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
6023
6229
|
const fl = obj.symFlags[symIdx];
|
|
6024
6230
|
const isUndef = (fl & 16) !== 0;
|
|
6025
6231
|
const isLocal = (fl & 3) === 2;
|
|
6232
|
+
if (obj.isDist && categoryOnlyExtracted.has(obj)) {
|
|
6233
|
+
categoryOnlyExtracted.delete(obj);
|
|
6234
|
+
markModuleFamilyLive(moduleFamily(obj.file));
|
|
6235
|
+
}
|
|
6026
6236
|
checkTypeTrigger(obj, sName);
|
|
6237
|
+
checkProtocolTrigger(sName);
|
|
6027
6238
|
if (!isUndef && !isLocal && sName && !liveGlobalNames.has(sName)) {
|
|
6028
6239
|
activateGlobalName(sName);
|
|
6029
6240
|
}
|
|
@@ -6035,13 +6246,25 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
6035
6246
|
markDataSymLive(obj, pIdx);
|
|
6036
6247
|
const parentName = obj.symNames[pIdx];
|
|
6037
6248
|
checkTypeTrigger(obj, parentName);
|
|
6249
|
+
checkProtocolTrigger(parentName);
|
|
6038
6250
|
}
|
|
6039
6251
|
markSegLive(obj, el);
|
|
6040
6252
|
}
|
|
6041
6253
|
}
|
|
6042
|
-
const extractObject = (obj) => {
|
|
6043
|
-
if (extractedObjs.has(obj))
|
|
6254
|
+
const extractObject = (obj, fromObjCCategory = false) => {
|
|
6255
|
+
if (extractedObjs.has(obj)) {
|
|
6256
|
+
if (!fromObjCCategory && categoryOnlyExtracted.has(obj)) {
|
|
6257
|
+
categoryOnlyExtracted.delete(obj);
|
|
6258
|
+
if (obj.isDist) markModuleFamilyLive(moduleFamily(obj.file));
|
|
6259
|
+
}
|
|
6260
|
+
return;
|
|
6261
|
+
}
|
|
6044
6262
|
extractedObjs.add(obj);
|
|
6263
|
+
if (fromObjCCategory && obj.isDist) {
|
|
6264
|
+
categoryOnlyExtracted.add(obj);
|
|
6265
|
+
} else if (obj.isDist) {
|
|
6266
|
+
markModuleFamilyLive(moduleFamily(obj.file));
|
|
6267
|
+
}
|
|
6045
6268
|
liveFuncs.set(obj, new Uint8Array(obj.numFuncs));
|
|
6046
6269
|
liveSegs.set(obj, new Uint8Array(obj.numSegments));
|
|
6047
6270
|
liveDataSyms.set(obj, /* @__PURE__ */ new Set());
|
|
@@ -6079,6 +6302,12 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
6079
6302
|
if (classSym !== -1 && (obj.symFlags[classSym] & 16) === 0)
|
|
6080
6303
|
activateSymbolInObj(obj, classSym);
|
|
6081
6304
|
}
|
|
6305
|
+
if (!obj.isDist) {
|
|
6306
|
+
for (let i = 0; i < obj.symNames.length; i++) {
|
|
6307
|
+
checkTypeTrigger(obj, obj.symNames[i]);
|
|
6308
|
+
checkProtocolTrigger(obj.symNames[i]);
|
|
6309
|
+
}
|
|
6310
|
+
}
|
|
6082
6311
|
if (obj.isDist) {
|
|
6083
6312
|
const isBuildSwift = !obj.file.startsWith(distDir) && obj.file.endsWith(".swift.o");
|
|
6084
6313
|
for (const [classSym, pref] of obj.objcClassSymToTypePrefix)
|
|
@@ -6093,48 +6322,77 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
6093
6322
|
}
|
|
6094
6323
|
}
|
|
6095
6324
|
if (obj.isDist) {
|
|
6096
|
-
for (
|
|
6097
|
-
|
|
6098
|
-
for (const r of obj.dataRelocList) {
|
|
6099
|
-
if (r.segIdx === sIdx) {
|
|
6100
|
-
const mcName = obj.symNames[r.rs];
|
|
6101
|
-
let matchesLocalType = false;
|
|
6102
|
-
for (const pref of obj.typePrefixesInObj) {
|
|
6103
|
-
if (mcName.startsWith(pref)) {
|
|
6104
|
-
matchesLocalType = true;
|
|
6105
|
-
break;
|
|
6106
|
-
}
|
|
6107
|
-
}
|
|
6108
|
-
if (!matchesLocalType) {
|
|
6109
|
-
const type = conformingType(mcName);
|
|
6110
|
-
if (type === void 0 || globalLiveTypes.has(type))
|
|
6111
|
-
activateSymbolInObj(obj, r.rs);
|
|
6112
|
-
}
|
|
6113
|
-
}
|
|
6114
|
-
}
|
|
6115
|
-
}
|
|
6325
|
+
for (const entries of pendingByObj.get(obj) ?? []) {
|
|
6326
|
+
tryActivateConformance(entries);
|
|
6116
6327
|
}
|
|
6117
6328
|
}
|
|
6118
6329
|
};
|
|
6330
|
+
const pendingByObj = /* @__PURE__ */ new Map();
|
|
6119
6331
|
for (const obj of distObjs.values()) {
|
|
6120
6332
|
if (!obj.isDist) continue;
|
|
6121
6333
|
for (const r of obj.dataRelocList) {
|
|
6122
6334
|
if (obj.segNames[r.segIdx] !== "swift5_protocol_conformances") continue;
|
|
6123
|
-
const
|
|
6124
|
-
|
|
6125
|
-
|
|
6126
|
-
|
|
6127
|
-
|
|
6335
|
+
const mcIdx = r.rs;
|
|
6336
|
+
const mcName = obj.symNames[mcIdx];
|
|
6337
|
+
const swiftType = conformingType(mcName);
|
|
6338
|
+
const objcType = swiftType === void 0 ? objcClassOfConformance(mcName) : void 0;
|
|
6339
|
+
const typeKey = swiftType !== void 0 ? { kind: "swift", value: swiftType } : objcType !== void 0 ? { kind: "objc", value: objcType } : null;
|
|
6340
|
+
const proto = obj.conformanceProtocols.get(mcIdx);
|
|
6341
|
+
const isForeign = swiftType !== void 0 ? !obj.typePrefixesInObj.has(swiftType) : objcType !== void 0 ? !obj.symNames.some(
|
|
6342
|
+
(n, i) => n === `._OBJC_CLASS_${objcType}` && (obj.symFlags[i] & 16) === 0
|
|
6343
|
+
) : false;
|
|
6344
|
+
const entry = {
|
|
6345
|
+
obj,
|
|
6346
|
+
symIdx: mcIdx,
|
|
6347
|
+
typeKey,
|
|
6348
|
+
proto,
|
|
6349
|
+
isForeign,
|
|
6350
|
+
activated: false
|
|
6351
|
+
};
|
|
6352
|
+
let objList = pendingByObj.get(obj);
|
|
6353
|
+
if (!objList) pendingByObj.set(obj, objList = []);
|
|
6354
|
+
objList.push(entry);
|
|
6355
|
+
if (swiftType !== void 0) {
|
|
6356
|
+
let list = pendingBySwiftType.get(swiftType);
|
|
6357
|
+
if (!list) pendingBySwiftType.set(swiftType, list = []);
|
|
6358
|
+
list.push(entry);
|
|
6359
|
+
} else if (objcType !== void 0) {
|
|
6360
|
+
let list = pendingByObjcClass.get(objcType);
|
|
6361
|
+
if (!list) pendingByObjcClass.set(objcType, list = []);
|
|
6362
|
+
list.push(entry);
|
|
6363
|
+
}
|
|
6364
|
+
if (proto !== void 0) {
|
|
6365
|
+
let list = pendingByProto.get(proto);
|
|
6366
|
+
if (!list) pendingByProto.set(proto, list = []);
|
|
6367
|
+
list.push(entry);
|
|
6368
|
+
}
|
|
6369
|
+
}
|
|
6370
|
+
if (obj.objcCategoryTargets.length > 0) {
|
|
6371
|
+
const catFamily = moduleFamily(obj.file);
|
|
6372
|
+
for (const cls of obj.objcCategoryTargets) {
|
|
6373
|
+
const classFamily = objcClassFamilyOf(cls);
|
|
6374
|
+
const entry = {
|
|
6375
|
+
obj,
|
|
6376
|
+
cls,
|
|
6377
|
+
catFamily,
|
|
6378
|
+
classFamily,
|
|
6379
|
+
activated: false
|
|
6380
|
+
};
|
|
6381
|
+
let byCls = pendingCategoriesByClass.get(cls);
|
|
6382
|
+
if (!byCls) pendingCategoriesByClass.set(cls, byCls = []);
|
|
6383
|
+
byCls.push(entry);
|
|
6384
|
+
if (catFamily !== "Foundation" && (classFamily === void 0 || classFamily === "Foundation")) {
|
|
6385
|
+
let byFam = pendingCategoriesByFamily.get(catFamily);
|
|
6386
|
+
if (!byFam) pendingCategoriesByFamily.set(catFamily, byFam = []);
|
|
6387
|
+
byFam.push(entry);
|
|
6388
|
+
}
|
|
6389
|
+
}
|
|
6128
6390
|
}
|
|
6129
6391
|
}
|
|
6130
|
-
let hasClangObjCEager = false;
|
|
6131
6392
|
for (const f of eagerFiles) {
|
|
6132
6393
|
const isDist = f.startsWith(distDir);
|
|
6133
6394
|
const obj = distObjs.get(f) ?? parseWasmObjectCached(f, isDist, false);
|
|
6134
6395
|
extractObject(obj);
|
|
6135
|
-
if (!isDist && !hasClangObjCEager && obj.symNames.includes("__objc_load")) {
|
|
6136
|
-
hasClangObjCEager = true;
|
|
6137
|
-
}
|
|
6138
6396
|
if (isDist) {
|
|
6139
6397
|
const base = path10.basename(f);
|
|
6140
6398
|
if (base.startsWith("PeachFoundation-") || base.startsWith("PeachObjC-") || base.startsWith("PeachICU-") || base.startsWith("Darwin-")) {
|
|
@@ -6157,19 +6415,6 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
6157
6415
|
activateSymbolInObj(provider, provider.symNames.indexOf(name2));
|
|
6158
6416
|
}
|
|
6159
6417
|
}
|
|
6160
|
-
const eagerSdkCategoryFiles = [];
|
|
6161
|
-
if (hasClangObjCEager) {
|
|
6162
|
-
for (const name2 of foundationCategoryObjects.map(
|
|
6163
|
-
(name3) => `libFoundation__${name3}.objc.o`
|
|
6164
|
-
)) {
|
|
6165
|
-
const sdkFile = path10.join(sdkObjsDir, name2);
|
|
6166
|
-
const obj = distObjs.get(sdkFile);
|
|
6167
|
-
if (obj) {
|
|
6168
|
-
extractObject(obj);
|
|
6169
|
-
eagerSdkCategoryFiles.push(sdkFile);
|
|
6170
|
-
}
|
|
6171
|
-
}
|
|
6172
|
-
}
|
|
6173
6418
|
for (const symName of ["_initialize", "__main_argc_argv", "main"]) {
|
|
6174
6419
|
const def = definedGlobalSyms.get(symName);
|
|
6175
6420
|
if (def) activateSymbolInObj(def.obj, def.symIdx);
|
|
@@ -6224,6 +6469,9 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
6224
6469
|
}
|
|
6225
6470
|
for (const symIdx of relocs) {
|
|
6226
6471
|
if (obj.isDist && dropsReflection(obj, obj.symNames[symIdx])) continue;
|
|
6472
|
+
const symName = obj.symNames[symIdx];
|
|
6473
|
+
checkTypeTrigger(obj, symName);
|
|
6474
|
+
checkProtocolTrigger(symName);
|
|
6227
6475
|
const fl = obj.symFlags[symIdx];
|
|
6228
6476
|
const isUndef = (fl & 16) !== 0;
|
|
6229
6477
|
const isLocal = (fl & 3) === 2;
|
|
@@ -6563,21 +6811,12 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
6563
6811
|
writePrunedObject(o, outPath);
|
|
6564
6812
|
prunedMap.set(o.file, outPath);
|
|
6565
6813
|
}
|
|
6566
|
-
const extraSdkObjs = allSdkObjFiles.filter(
|
|
6567
|
-
(f) => f.startsWith("libDarwin__") || f.startsWith("libswiftCore__") && f !== "libswiftCore__Swift.o" || f.startsWith("libswift_Concurrency__") && f !== "libswift_Concurrency___Concurrency.o"
|
|
6568
|
-
).map((f) => path10.join(sdkObjsDir, f));
|
|
6569
6814
|
const outTokens = [];
|
|
6570
6815
|
const emittedPruned = /* @__PURE__ */ new Set();
|
|
6571
6816
|
inStartLib = false;
|
|
6572
6817
|
for (const t of tokens) {
|
|
6573
6818
|
if (t === "--start-lib") {
|
|
6574
6819
|
inStartLib = true;
|
|
6575
|
-
for (const ef of eagerSdkCategoryFiles) {
|
|
6576
|
-
if (!emittedPruned.has(ef) && prunedMap.has(ef)) {
|
|
6577
|
-
outTokens.push(prunedMap.get(ef));
|
|
6578
|
-
emittedPruned.add(ef);
|
|
6579
|
-
}
|
|
6580
|
-
}
|
|
6581
6820
|
for (const obj of eagerDynamicObjects) {
|
|
6582
6821
|
if (!emittedPruned.has(obj.file) && prunedMap.has(obj.file)) {
|
|
6583
6822
|
outTokens.push(prunedMap.get(obj.file));
|
|
@@ -7145,7 +7384,7 @@ function createGuestImageLedger(input) {
|
|
|
7145
7384
|
const objects = units.map(({ image, object: object3, aliases, functionImports }) => {
|
|
7146
7385
|
const shared = bindingsByImage.get(image);
|
|
7147
7386
|
const own = startup.get(object3.path);
|
|
7148
|
-
|
|
7387
|
+
let bindings = own ? new Map([...shared, ...own]) : shared;
|
|
7149
7388
|
for (const [name2, type] of functionImports) {
|
|
7150
7389
|
const alias = bindings.get(name2);
|
|
7151
7390
|
const provider = alias === void 0 ? void 0 : definitionsByAlias.get(alias);
|
|
@@ -7161,6 +7400,7 @@ function createGuestImageLedger(input) {
|
|
|
7161
7400
|
};
|
|
7162
7401
|
resultWrappers.set(key, wrapper);
|
|
7163
7402
|
}
|
|
7403
|
+
if (bindings === shared) bindings = new Map(shared);
|
|
7164
7404
|
bindings.set(name2, wrapper.symbol);
|
|
7165
7405
|
}
|
|
7166
7406
|
return {
|
|
@@ -10112,7 +10352,6 @@ import crypto from "node:crypto";
|
|
|
10112
10352
|
import fs7 from "node:fs";
|
|
10113
10353
|
import os2 from "node:os";
|
|
10114
10354
|
import path17 from "node:path";
|
|
10115
|
-
import { Readable } from "node:stream";
|
|
10116
10355
|
import { pipeline as pipeline2 } from "node:stream/promises";
|
|
10117
10356
|
import zlib2 from "node:zlib";
|
|
10118
10357
|
|
|
@@ -10164,17 +10403,20 @@ async function installVerifiedTarballLocked(tarball, presentAtStart) {
|
|
|
10164
10403
|
path17.join(path17.dirname(destDir), `.installing-${path17.basename(destDir)}-`)
|
|
10165
10404
|
);
|
|
10166
10405
|
try {
|
|
10167
|
-
|
|
10168
|
-
|
|
10169
|
-
|
|
10170
|
-
|
|
10171
|
-
|
|
10172
|
-
|
|
10173
|
-
|
|
10174
|
-
if (actual !== digest.value) {
|
|
10175
|
-
throw new Error(
|
|
10176
|
-
`${digest.algorithm} mismatch for ${label}: expected ${digest.value}, actual ${actual}`
|
|
10406
|
+
for (let attempt = 1; ; attempt++) {
|
|
10407
|
+
await downloadToFile(url, archivePath, signal);
|
|
10408
|
+
const actual = await digestFile(
|
|
10409
|
+
archivePath,
|
|
10410
|
+
digest.algorithm,
|
|
10411
|
+
digest.encoding,
|
|
10412
|
+
signal
|
|
10177
10413
|
);
|
|
10414
|
+
if (actual === digest.value) break;
|
|
10415
|
+
if (attempt >= 2) {
|
|
10416
|
+
throw new Error(
|
|
10417
|
+
`${digest.algorithm} mismatch for ${label}: expected ${digest.value}, actual ${actual}`
|
|
10418
|
+
);
|
|
10419
|
+
}
|
|
10178
10420
|
}
|
|
10179
10421
|
const { pathname } = new URL(url);
|
|
10180
10422
|
if (pathname.endsWith(".zip")) await extractZip(archivePath, tmpDir, signal);
|
|
@@ -10225,27 +10467,87 @@ async function installVerifiedTarballLocked(tarball, presentAtStart) {
|
|
|
10225
10467
|
function isErrnoCode(err, ...codes) {
|
|
10226
10468
|
return err instanceof Error && "code" in err && codes.includes(String(err.code));
|
|
10227
10469
|
}
|
|
10228
|
-
|
|
10229
|
-
|
|
10230
|
-
|
|
10231
|
-
|
|
10470
|
+
var DownloadHttpError = class extends Error {
|
|
10471
|
+
constructor(status, statusText, url) {
|
|
10472
|
+
super(`download failed: ${status} ${statusText} (${url})`);
|
|
10473
|
+
__publicField(this, "retryable");
|
|
10474
|
+
this.retryable = status < 400 || status >= 500 || status === 408 || status === 429;
|
|
10232
10475
|
}
|
|
10476
|
+
};
|
|
10477
|
+
async function waitRetryDelay(ms, signal) {
|
|
10478
|
+
signal?.throwIfAborted();
|
|
10479
|
+
await new Promise((resolve, reject) => {
|
|
10480
|
+
const onAbort = () => {
|
|
10481
|
+
clearTimeout(timer);
|
|
10482
|
+
const reason = signal?.reason;
|
|
10483
|
+
reject(
|
|
10484
|
+
reason instanceof Error ? reason : new Error("Download canceled", { cause: reason })
|
|
10485
|
+
);
|
|
10486
|
+
};
|
|
10487
|
+
const timer = setTimeout(() => {
|
|
10488
|
+
signal?.removeEventListener("abort", onAbort);
|
|
10489
|
+
resolve();
|
|
10490
|
+
}, ms);
|
|
10491
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
10492
|
+
});
|
|
10493
|
+
}
|
|
10494
|
+
async function downloadToFile(url, destPath, signal) {
|
|
10233
10495
|
fs7.mkdirSync(path17.dirname(destPath), { recursive: true });
|
|
10234
10496
|
const tmp = `${destPath}.partial`;
|
|
10235
|
-
|
|
10236
|
-
await pipeline2(
|
|
10237
|
-
Readable.fromWeb(res.body),
|
|
10238
|
-
fs7.createWriteStream(tmp),
|
|
10239
|
-
{ signal }
|
|
10240
|
-
);
|
|
10497
|
+
for (let attempt = 1; attempt <= 4; attempt++) {
|
|
10241
10498
|
signal?.throwIfAborted();
|
|
10242
|
-
|
|
10243
|
-
|
|
10499
|
+
let reader2;
|
|
10500
|
+
let handle;
|
|
10501
|
+
let completed = false;
|
|
10244
10502
|
try {
|
|
10245
|
-
|
|
10246
|
-
|
|
10503
|
+
const res = await fetch(url, { signal });
|
|
10504
|
+
if (!res.ok || !res.body) {
|
|
10505
|
+
throw new DownloadHttpError(res.status, res.statusText, url);
|
|
10506
|
+
}
|
|
10507
|
+
reader2 = res.body.getReader();
|
|
10508
|
+
handle = await fs7.promises.open(tmp, "w");
|
|
10509
|
+
let written = 0;
|
|
10510
|
+
for (; ; ) {
|
|
10511
|
+
signal?.throwIfAborted();
|
|
10512
|
+
const { done, value } = await reader2.read();
|
|
10513
|
+
if (done) break;
|
|
10514
|
+
let offset = 0;
|
|
10515
|
+
while (offset < value.byteLength) {
|
|
10516
|
+
const { bytesWritten } = await handle.write(
|
|
10517
|
+
value,
|
|
10518
|
+
offset,
|
|
10519
|
+
value.byteLength - offset
|
|
10520
|
+
);
|
|
10521
|
+
offset += bytesWritten;
|
|
10522
|
+
}
|
|
10523
|
+
written += value.byteLength;
|
|
10524
|
+
}
|
|
10525
|
+
await handle.close();
|
|
10526
|
+
handle = void 0;
|
|
10527
|
+
if (!res.headers.get("content-encoding")) {
|
|
10528
|
+
const header = res.headers.get("content-length");
|
|
10529
|
+
const expected = header ? Number(header) : Number.NaN;
|
|
10530
|
+
if (Number.isFinite(expected) && expected > 0 && written !== expected) {
|
|
10531
|
+
throw new Error(`incomplete download (${written}/${expected} bytes): ${url}`);
|
|
10532
|
+
}
|
|
10533
|
+
}
|
|
10534
|
+
signal?.throwIfAborted();
|
|
10535
|
+
fs7.renameSync(tmp, destPath);
|
|
10536
|
+
completed = true;
|
|
10537
|
+
return;
|
|
10538
|
+
} catch (err) {
|
|
10539
|
+
if (handle) await handle.close().catch(() => {
|
|
10540
|
+
});
|
|
10541
|
+
if (reader2 && !completed) await reader2.cancel().catch(() => {
|
|
10542
|
+
});
|
|
10543
|
+
try {
|
|
10544
|
+
fs7.unlinkSync(tmp);
|
|
10545
|
+
} catch {
|
|
10546
|
+
}
|
|
10547
|
+
const nonRetryable = err instanceof DownloadHttpError && !err.retryable;
|
|
10548
|
+
if (signal?.aborted || nonRetryable || attempt === 4) throw err;
|
|
10549
|
+
await waitRetryDelay(250 * attempt, signal);
|
|
10247
10550
|
}
|
|
10248
|
-
throw err;
|
|
10249
10551
|
}
|
|
10250
10552
|
}
|
|
10251
10553
|
async function digestFile(filePath, algorithm, encoding, signal) {
|
|
@@ -11306,10 +11608,6 @@ async function swiftIcuBundleAsset(icu) {
|
|
|
11306
11608
|
// src/swift-link-roots.ts
|
|
11307
11609
|
import fs9 from "node:fs";
|
|
11308
11610
|
import path21 from "node:path";
|
|
11309
|
-
var OBJC_SENTINELS = /* @__PURE__ */ new Map([
|
|
11310
|
-
["__objc_cats", ".objc_null_category"],
|
|
11311
|
-
["__objc_class_aliases", ".objc_null_class_alias"]
|
|
11312
|
-
]);
|
|
11313
11611
|
var leb = (bytes, at) => {
|
|
11314
11612
|
let value = 0;
|
|
11315
11613
|
let scale = 1;
|
|
@@ -11324,6 +11622,7 @@ function objcRootInfo(bytes) {
|
|
|
11324
11622
|
const at = { offset: 8 };
|
|
11325
11623
|
const names = [];
|
|
11326
11624
|
const dataSymbols = [];
|
|
11625
|
+
let hasNSObjectLoad = false;
|
|
11327
11626
|
let hasExportedSymbol = false;
|
|
11328
11627
|
while (at.offset < bytes.length) {
|
|
11329
11628
|
const id = bytes[at.offset++];
|
|
@@ -11360,6 +11659,12 @@ function objcRootInfo(bytes) {
|
|
|
11360
11659
|
leb(bytes, at);
|
|
11361
11660
|
if (!isUndef || isExplicitName) {
|
|
11362
11661
|
const sLen = leb(bytes, at);
|
|
11662
|
+
if (!isUndef && symKind === 0) {
|
|
11663
|
+
const name3 = Buffer.from(
|
|
11664
|
+
bytes.subarray(at.offset, at.offset + sLen)
|
|
11665
|
+
).toString();
|
|
11666
|
+
if (/^_c_NSObject_.*_load$/.test(name3)) hasNSObjectLoad = true;
|
|
11667
|
+
}
|
|
11363
11668
|
at.offset += sLen;
|
|
11364
11669
|
}
|
|
11365
11670
|
} else if (symKind === 1) {
|
|
@@ -11386,11 +11691,9 @@ function objcRootInfo(bytes) {
|
|
|
11386
11691
|
at.offset = end;
|
|
11387
11692
|
}
|
|
11388
11693
|
return {
|
|
11389
|
-
registration: dataSymbols.some(
|
|
11390
|
-
|
|
11391
|
-
|
|
11392
|
-
return sentinel !== void 0 && name2 !== sentinel;
|
|
11393
|
-
}),
|
|
11694
|
+
registration: hasNSObjectLoad || dataSymbols.some(
|
|
11695
|
+
({ segment, name: name2 }) => names[segment] === "__objc_class_aliases" && name2 !== ".objc_null_class_alias"
|
|
11696
|
+
),
|
|
11394
11697
|
exported: hasExportedSymbol
|
|
11395
11698
|
};
|
|
11396
11699
|
}
|
|
@@ -11403,9 +11706,7 @@ function swiftObjcRootObjects(id, root, objects) {
|
|
|
11403
11706
|
);
|
|
11404
11707
|
const roots = new Set(
|
|
11405
11708
|
measured.filter(
|
|
11406
|
-
([object3, info]) =>
|
|
11407
|
-
(name2) => object3 === `lib/Foundation-${name2}.o`
|
|
11408
|
-
) && object3 !== "lib/FoundationNetworking-Session.o" && object3 !== "lib/SwiftUI-MetalExecution.o" && object3 !== "lib/UIKitCore-NativeStub.o" && (info.registration || info.exported)
|
|
11709
|
+
([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)
|
|
11409
11710
|
).map(([object3]) => object3)
|
|
11410
11711
|
);
|
|
11411
11712
|
rootsByDistribution.set(id, roots);
|
|
@@ -13100,6 +13401,8 @@ var executableLinkFlags = (root) => ` "-Xclang-linker", "-O0",
|
|
|
13100
13401
|
"-Xlinker", "--global-base=8372224",
|
|
13101
13402
|
"-Xlinker", "-lsetjmp",
|
|
13102
13403
|
"-Xlinker", "--export-table",
|
|
13404
|
+
"-Xlinker", "--export-if-defined=__cpp_exception",
|
|
13405
|
+
"-Xlinker", "--export-if-defined=__objc_wasm_terminate",
|
|
13103
13406
|
"-Xlinker", "--growable-table",
|
|
13104
13407
|
"-Xlinker", "--wrap=swift_udata_open",
|
|
13105
13408
|
"-Xlinker", "--wrap=swift_udata_openChoice",
|
|
@@ -13108,7 +13411,7 @@ var darwinRecordsRegion = (quoted2) => quoted2.length ? ["-Wl,--start-lib", ...q
|
|
|
13108
13411
|
var REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
|
|
13109
13412
|
var MULTI_MANIFEST_VERSION = 68;
|
|
13110
13413
|
var SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
|
|
13111
|
-
var compilerSourceDigest = true ? "
|
|
13414
|
+
var compilerSourceDigest = true ? "05dbb1273689060748700777894c639c73bea2e6da20eaf47e8040b26ff859cf" : swiftCompilerSourceDigest(import.meta.dirname);
|
|
13112
13415
|
function swiftArtifactHash(input, release, moduleRoot) {
|
|
13113
13416
|
const hash = createHash13("sha256");
|
|
13114
13417
|
hash.update(`swift-compile
|