peachsim 0.1.759 → 0.1.760
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/agent-identity.cjs +1 -1
- package/dist-lib/agent-sessions.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/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +1 -1
- package/dist-lib/cli-constants.cjs +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 +1 -1
- package/dist-lib/detox/index.cjs +1 -1
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +823 -728
- package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
- 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 +37 -220
- 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 +1 -1
- 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 +37 -220
- 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/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/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +1 -1
- package/dist-lib/render-mode.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 +1120 -1019
- package/dist-lib/swift-compile.cjs +1 -1
- package/dist-lib/swift-compile.mjs +1 -1
- package/dist-lib/swift-package.cjs +1 -110
- package/dist-lib/swift-package.mjs +1 -109
- 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 +607 -512
- package/dist-lib/vite.cjs +1 -1
- package/package.json +1 -1
- package/src/native-seam-manifest.ts +8 -0
- package/src/swift-host.ts +64 -64
- package/src/swift-package-manifest.ts +307 -0
- package/src/swift-package.ts +2 -135
- package/src/swift-packages.ts +341 -0
- package/src/xcode-project.ts +57 -70
- package/src/swift-remote-packages.ts +0 -255
package/dist-lib/vite-swift.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.760 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
|
@@ -287,8 +287,8 @@ __export(vite_plugin_swift_exports, {
|
|
|
287
287
|
swiftPlugin: () => swiftPlugin
|
|
288
288
|
});
|
|
289
289
|
module.exports = __toCommonJS(vite_plugin_swift_exports);
|
|
290
|
-
var
|
|
291
|
-
var
|
|
290
|
+
var import_node_fs11 = __toESM(require("node:fs"), 1);
|
|
291
|
+
var import_node_path13 = __toESM(require("node:path"), 1);
|
|
292
292
|
|
|
293
293
|
// ../sootsim-swift/src/entryModule.ts
|
|
294
294
|
function nativeExportLines(args, commonjs) {
|
|
@@ -544,116 +544,9 @@ function manifestCalls(manifest, kinds) {
|
|
|
544
544
|
}
|
|
545
545
|
return calls;
|
|
546
546
|
}
|
|
547
|
-
var NAME = /\bname\s*:\s*"([^"]+)"/;
|
|
548
|
-
function listArgument(call, label) {
|
|
549
|
-
const start = new RegExp(`\\b${label}\\s*:\\s*\\[`).exec(call);
|
|
550
|
-
if (!start) return [];
|
|
551
|
-
const items2 = [];
|
|
552
|
-
let depth = 0;
|
|
553
|
-
let inString = false;
|
|
554
|
-
let item = "";
|
|
555
|
-
for (let i = start.index + start[0].length; i < call.length; i++) {
|
|
556
|
-
const ch = call[i];
|
|
557
|
-
if (inString) {
|
|
558
|
-
item += ch;
|
|
559
|
-
if (ch === '"' && call[i - 1] !== "\\") inString = false;
|
|
560
|
-
continue;
|
|
561
|
-
}
|
|
562
|
-
if (ch === '"') inString = true;
|
|
563
|
-
else if (ch === "(" || ch === "[") depth++;
|
|
564
|
-
else if (ch === ")" || ch === "]") {
|
|
565
|
-
if (depth === 0) break;
|
|
566
|
-
depth--;
|
|
567
|
-
} else if (ch === "," && depth === 0) {
|
|
568
|
-
items2.push(item.trim());
|
|
569
|
-
item = "";
|
|
570
|
-
continue;
|
|
571
|
-
}
|
|
572
|
-
item += ch;
|
|
573
|
-
}
|
|
574
|
-
if (item.trim()) items2.push(item.trim());
|
|
575
|
-
return items2;
|
|
576
|
-
}
|
|
577
547
|
function swiftPackageIdentity(url) {
|
|
578
548
|
return (url.split("/").pop() ?? url).replace(/\.git$/, "").toLowerCase();
|
|
579
549
|
}
|
|
580
|
-
function swiftManifestGraph(manifest) {
|
|
581
|
-
const graph = {
|
|
582
|
-
products: /* @__PURE__ */ new Map(),
|
|
583
|
-
dependencies: /* @__PURE__ */ new Map(),
|
|
584
|
-
binaryTargets: /* @__PURE__ */ new Set(),
|
|
585
|
-
systemLibraries: /* @__PURE__ */ new Set(),
|
|
586
|
-
packageURLs: /* @__PURE__ */ new Map(),
|
|
587
|
-
packagePaths: []
|
|
588
|
-
};
|
|
589
|
-
for (const { kind, flat, call } of manifestCalls(manifest, [
|
|
590
|
-
"library",
|
|
591
|
-
"executableTarget",
|
|
592
|
-
"target",
|
|
593
|
-
"binaryTarget",
|
|
594
|
-
"systemLibrary",
|
|
595
|
-
"package"
|
|
596
|
-
])) {
|
|
597
|
-
if (kind === "package") {
|
|
598
|
-
const local = /\bpath\s*:\s*"([^"]+)"/.exec(flat)?.[1];
|
|
599
|
-
if (local) graph.packagePaths.push(local);
|
|
600
|
-
const url = /\burl\s*:\s*"([^"]+)"/.exec(flat)?.[1];
|
|
601
|
-
if (!url) continue;
|
|
602
|
-
graph.packageURLs.set(swiftPackageIdentity(url), url);
|
|
603
|
-
const name2 = NAME.exec(flat)?.[1];
|
|
604
|
-
if (name2) graph.packageURLs.set(name2.toLowerCase(), url);
|
|
605
|
-
continue;
|
|
606
|
-
}
|
|
607
|
-
const name = NAME.exec(flat)?.[1];
|
|
608
|
-
if (!name) continue;
|
|
609
|
-
if (kind === "library") {
|
|
610
|
-
graph.products.set(
|
|
611
|
-
name,
|
|
612
|
-
listArgument(call, "targets").flatMap(
|
|
613
|
-
(item) => /^"([^"]+)"$/.exec(item)?.[1] ?? []
|
|
614
|
-
)
|
|
615
|
-
);
|
|
616
|
-
continue;
|
|
617
|
-
}
|
|
618
|
-
if (kind === "binaryTarget") graph.binaryTargets.add(name);
|
|
619
|
-
if (kind === "systemLibrary") graph.systemLibraries.add(name);
|
|
620
|
-
const dependencies = [];
|
|
621
|
-
for (const item of listArgument(call, "dependencies")) {
|
|
622
|
-
const platforms = /condition\s*:\s*\.when\(\s*platforms\s*:\s*\[([^\]]*)\]/.exec(
|
|
623
|
-
item
|
|
624
|
-
)?.[1];
|
|
625
|
-
if (platforms !== void 0 && !/\.iOS\b/.test(platforms)) continue;
|
|
626
|
-
if (/condition\s*:\s*\.when\([^)]*\btraits\s*:/.test(item)) continue;
|
|
627
|
-
const plain = /^"([^"]+)"$/.exec(item)?.[1];
|
|
628
|
-
const product = /^\.product(?:Item)?\(\s*name\s*:\s*"([^"]+)"\s*,\s*package\s*:\s*"([^"]+)"/.exec(
|
|
629
|
-
item
|
|
630
|
-
);
|
|
631
|
-
const target = /^\.(?:target|byName)(?:Item)?\(\s*name\s*:\s*"([^"]+)"/.exec(
|
|
632
|
-
item
|
|
633
|
-
)?.[1];
|
|
634
|
-
if (plain) dependencies.push({ kind: "target", name: plain });
|
|
635
|
-
else if (product)
|
|
636
|
-
dependencies.push({
|
|
637
|
-
kind: "product",
|
|
638
|
-
name: product[1],
|
|
639
|
-
package: product[2].toLowerCase()
|
|
640
|
-
});
|
|
641
|
-
else if (target) dependencies.push({ kind: "target", name: target });
|
|
642
|
-
}
|
|
643
|
-
graph.dependencies.set(name, dependencies);
|
|
644
|
-
}
|
|
645
|
-
for (const dependencies of graph.dependencies.values()) {
|
|
646
|
-
for (const [index, dependency] of dependencies.entries()) {
|
|
647
|
-
if (dependency.kind === "target" && !graph.dependencies.has(dependency.name))
|
|
648
|
-
dependencies[index] = {
|
|
649
|
-
kind: "product",
|
|
650
|
-
name: dependency.name,
|
|
651
|
-
package: dependency.name.toLowerCase()
|
|
652
|
-
};
|
|
653
|
-
}
|
|
654
|
-
}
|
|
655
|
-
return graph;
|
|
656
|
-
}
|
|
657
550
|
function swiftManifestTargets(manifest, resourcePaths = []) {
|
|
658
551
|
const implicitResources = swiftImplicitResourcePaths(resourcePaths);
|
|
659
552
|
const targets = [];
|
|
@@ -1113,21 +1006,21 @@ function scanObjCExtensionMembers(source, tokens, records) {
|
|
|
1113
1006
|
const masked = swiftCodeMask(source);
|
|
1114
1007
|
const found = /* @__PURE__ */ new Map();
|
|
1115
1008
|
const member = /\b(func|var)\s+([A-Za-z_]\w*)/g;
|
|
1116
|
-
for (const
|
|
1117
|
-
const close = closingBrace(source, tokens,
|
|
1118
|
-
const body = masked.slice(
|
|
1009
|
+
for (const record2 of records) {
|
|
1010
|
+
const close = closingBrace(source, tokens, record2.open);
|
|
1011
|
+
const body = masked.slice(record2.open, close);
|
|
1119
1012
|
member.lastIndex = 0;
|
|
1120
1013
|
for (let match = member.exec(body); match; match = member.exec(body)) {
|
|
1121
|
-
const at =
|
|
1014
|
+
const at = record2.open + match.index + match[0].indexOf(match[1]);
|
|
1122
1015
|
let depth = 0;
|
|
1123
1016
|
for (const token of tokens) {
|
|
1124
|
-
if (token <=
|
|
1017
|
+
if (token <= record2.open) continue;
|
|
1125
1018
|
if (token >= at) break;
|
|
1126
1019
|
if (source[token] === "{") depth++;
|
|
1127
1020
|
else if (source[token] === "}") depth--;
|
|
1128
1021
|
}
|
|
1129
1022
|
if (depth > 0) continue;
|
|
1130
|
-
const head = masked.slice(
|
|
1023
|
+
const head = masked.slice(record2.open, at);
|
|
1131
1024
|
const bound = Math.max(
|
|
1132
1025
|
head.lastIndexOf(";"),
|
|
1133
1026
|
head.lastIndexOf("{"),
|
|
@@ -1138,11 +1031,11 @@ function scanObjCExtensionMembers(source, tokens, records) {
|
|
|
1138
1031
|
prefix
|
|
1139
1032
|
))
|
|
1140
1033
|
continue;
|
|
1141
|
-
if (!/@objc\b/.test(prefix) && !/@IBAction\b/.test(prefix) && !
|
|
1034
|
+
if (!/@objc\b/.test(prefix) && !/@IBAction\b/.test(prefix) && !record2.objcMembers)
|
|
1142
1035
|
continue;
|
|
1143
|
-
const members = found.get(
|
|
1036
|
+
const members = found.get(record2.type) ?? /* @__PURE__ */ new Set();
|
|
1144
1037
|
members.add(match[2]);
|
|
1145
|
-
found.set(
|
|
1038
|
+
found.set(record2.type, members);
|
|
1146
1039
|
}
|
|
1147
1040
|
}
|
|
1148
1041
|
return found;
|
|
@@ -2007,10 +1900,10 @@ function compileSwiftProjectUnit(input, options) {
|
|
|
2007
1900
|
}
|
|
2008
1901
|
|
|
2009
1902
|
// src/swift-host.ts
|
|
2010
|
-
var
|
|
2011
|
-
var
|
|
2012
|
-
var
|
|
2013
|
-
var
|
|
1903
|
+
var import_node_crypto5 = require("node:crypto");
|
|
1904
|
+
var import_node_fs10 = __toESM(require("node:fs"), 1);
|
|
1905
|
+
var import_node_os6 = __toESM(require("node:os"), 1);
|
|
1906
|
+
var import_node_path12 = __toESM(require("node:path"), 1);
|
|
2014
1907
|
|
|
2015
1908
|
// ../sootsim-swift/src/bundleAssets.ts
|
|
2016
1909
|
var import_svgpath = __toESM(require("svgpath"), 1);
|
|
@@ -2044,8 +1937,8 @@ function pickImagesetFile(images) {
|
|
|
2044
1937
|
scale: pick.scale === "2x" ? 2 : pick.scale === "3x" ? 3 : 1
|
|
2045
1938
|
};
|
|
2046
1939
|
}
|
|
2047
|
-
function flatScale(
|
|
2048
|
-
const match = /@([23])x\.[^./]+$/.exec(
|
|
1940
|
+
function flatScale(path13) {
|
|
1941
|
+
const match = /@([23])x\.[^./]+$/.exec(path13);
|
|
2049
1942
|
return match ? Number(match[1]) : 1;
|
|
2050
1943
|
}
|
|
2051
1944
|
function providesNamespace(text2) {
|
|
@@ -2072,13 +1965,13 @@ function catalogEntryName(contentsPath, kind, readText) {
|
|
|
2072
1965
|
}
|
|
2073
1966
|
return segments.join("/");
|
|
2074
1967
|
}
|
|
2075
|
-
function isFlatResourceImage(
|
|
2076
|
-
return
|
|
1968
|
+
function isFlatResourceImage(path13) {
|
|
1969
|
+
return path13.split("/").includes("Resources") && RASTER_EXTENSIONS.has(extOf(path13));
|
|
2077
1970
|
}
|
|
2078
1971
|
function enumerateBundleImages(paths, readText) {
|
|
2079
1972
|
const table = [];
|
|
2080
1973
|
const seen = /* @__PURE__ */ new Set();
|
|
2081
|
-
const catalogs = paths.filter((
|
|
1974
|
+
const catalogs = paths.filter((path13) => baseOf(path13) === "Contents.json");
|
|
2082
1975
|
for (const contentsPath of catalogs) {
|
|
2083
1976
|
const name = catalogEntryName(contentsPath, ".imageset", readText);
|
|
2084
1977
|
if (name === null || seen.has(name)) continue;
|
|
@@ -2099,12 +1992,12 @@ function enumerateBundleImages(paths, readText) {
|
|
|
2099
1992
|
seen.add(name);
|
|
2100
1993
|
table.push({ name, file: `${dir}/${pick.filename}`, scale: pick.scale });
|
|
2101
1994
|
}
|
|
2102
|
-
for (const
|
|
2103
|
-
if (!isFlatResourceImage(
|
|
2104
|
-
const name = baseOf(
|
|
1995
|
+
for (const path13 of paths) {
|
|
1996
|
+
if (!isFlatResourceImage(path13)) continue;
|
|
1997
|
+
const name = baseOf(path13).slice(0, -extOf(path13).length);
|
|
2105
1998
|
if (name === "" || seen.has(name)) continue;
|
|
2106
1999
|
seen.add(name);
|
|
2107
|
-
table.push({ name, file:
|
|
2000
|
+
table.push({ name, file: path13, scale: flatScale(path13) });
|
|
2108
2001
|
}
|
|
2109
2002
|
return table;
|
|
2110
2003
|
}
|
|
@@ -2133,7 +2026,7 @@ function colorsetValue(color) {
|
|
|
2133
2026
|
}
|
|
2134
2027
|
function enumerateBundleColors(paths, readText) {
|
|
2135
2028
|
const table = {};
|
|
2136
|
-
for (const contentsPath of paths.filter((
|
|
2029
|
+
for (const contentsPath of paths.filter((path13) => baseOf(path13) === "Contents.json")) {
|
|
2137
2030
|
const name = catalogEntryName(contentsPath, ".colorset", readText);
|
|
2138
2031
|
if (name === null || name in table) continue;
|
|
2139
2032
|
let colors;
|
|
@@ -2173,11 +2066,11 @@ var SYMBOL_CAP_HEIGHT_EM = 1443 / 2048;
|
|
|
2173
2066
|
function axisExtremes(points) {
|
|
2174
2067
|
const [a = 0, b = 0, c = 0, d] = points;
|
|
2175
2068
|
const out = [a, d ?? c];
|
|
2176
|
-
const
|
|
2069
|
+
const within2 = (t) => t > 0 && t < 1;
|
|
2177
2070
|
if (d === void 0) {
|
|
2178
2071
|
const denom = a - 2 * b + c;
|
|
2179
2072
|
const t = denom === 0 ? -1 : (a - b) / denom;
|
|
2180
|
-
if (
|
|
2073
|
+
if (within2(t)) out.push((1 - t) ** 2 * a + 2 * (1 - t) * t * b + t ** 2 * c);
|
|
2181
2074
|
return out;
|
|
2182
2075
|
}
|
|
2183
2076
|
const qa = 3 * (-a + 3 * b - 3 * c + d);
|
|
@@ -2189,7 +2082,7 @@ function axisExtremes(points) {
|
|
|
2189
2082
|
const root = Math.sqrt(disc);
|
|
2190
2083
|
return [(-qb + root) / (2 * qa), (-qb - root) / (2 * qa)];
|
|
2191
2084
|
})();
|
|
2192
|
-
for (const t of roots.filter(
|
|
2085
|
+
for (const t of roots.filter(within2))
|
|
2193
2086
|
out.push(
|
|
2194
2087
|
(1 - t) ** 3 * a + 3 * (1 - t) ** 2 * t * b + 3 * (1 - t) * t ** 2 * c + t ** 3 * d
|
|
2195
2088
|
);
|
|
@@ -2198,8 +2091,8 @@ function axisExtremes(points) {
|
|
|
2198
2091
|
function pathBounds(d) {
|
|
2199
2092
|
const xs = [];
|
|
2200
2093
|
const ys = [];
|
|
2201
|
-
for (const
|
|
2202
|
-
(0, import_svgpath.default)(
|
|
2094
|
+
for (const path13 of d)
|
|
2095
|
+
(0, import_svgpath.default)(path13).abs().unshort().unarc().iterate((segment, _index, x, y) => {
|
|
2203
2096
|
const [command, ...args] = segment;
|
|
2204
2097
|
if (command === "M" || command === "L") {
|
|
2205
2098
|
xs.push(Number(args[0]));
|
|
@@ -2226,7 +2119,7 @@ function guide(svg, id, axis) {
|
|
|
2226
2119
|
}
|
|
2227
2120
|
function enumerateBundleSymbols(paths, readText) {
|
|
2228
2121
|
const table = {};
|
|
2229
|
-
for (const contentsPath of paths.filter((
|
|
2122
|
+
for (const contentsPath of paths.filter((path13) => baseOf(path13) === "Contents.json")) {
|
|
2230
2123
|
const name = catalogEntryName(contentsPath, ".symbolset", readText);
|
|
2231
2124
|
if (name === null || name in table) continue;
|
|
2232
2125
|
let symbols;
|
|
@@ -2259,8 +2152,8 @@ function enumerateBundleSymbols(paths, readText) {
|
|
|
2259
2152
|
viewBox: "0 0 24 24",
|
|
2260
2153
|
advance,
|
|
2261
2154
|
box: [12 - advance / 2, 12 - tall / 2, advance, tall],
|
|
2262
|
-
layers: d.map((
|
|
2263
|
-
d: (0, import_svgpath.default)(
|
|
2155
|
+
layers: d.map((path13) => ({
|
|
2156
|
+
d: (0, import_svgpath.default)(path13).abs().scale(scale).translate(translateX, translateY).round(3).toString()
|
|
2264
2157
|
}))
|
|
2265
2158
|
};
|
|
2266
2159
|
}
|
|
@@ -2270,7 +2163,7 @@ function enumerateBundleJson(paths) {
|
|
|
2270
2163
|
const found = [];
|
|
2271
2164
|
const seen = /* @__PURE__ */ new Set();
|
|
2272
2165
|
const ordered = [...paths].filter(
|
|
2273
|
-
(
|
|
2166
|
+
(path13) => path13.split("/").includes("Resources") && path13.split("/").every((segment) => segment !== "" && segment !== "..") && (extOf(path13) === ".json" || extOf(path13) === ".xcstrings")
|
|
2274
2167
|
).sort((a, b) => {
|
|
2275
2168
|
const aDepth = a.split("/").length;
|
|
2276
2169
|
const bDepth = b.split("/").length;
|
|
@@ -2748,14 +2641,225 @@ function swiftModuleToolchain(root) {
|
|
|
2748
2641
|
};
|
|
2749
2642
|
}
|
|
2750
2643
|
|
|
2751
|
-
// src/swift-
|
|
2644
|
+
// src/swift-packages.ts
|
|
2645
|
+
var import_node_child_process6 = require("node:child_process");
|
|
2646
|
+
var import_node_fs8 = __toESM(require("node:fs"), 1);
|
|
2647
|
+
var import_node_path9 = __toESM(require("node:path"), 1);
|
|
2648
|
+
|
|
2649
|
+
// src/swift-package-manifest.ts
|
|
2752
2650
|
var import_node_child_process5 = require("node:child_process");
|
|
2651
|
+
var import_node_crypto4 = require("node:crypto");
|
|
2753
2652
|
var import_node_fs7 = __toESM(require("node:fs"), 1);
|
|
2653
|
+
var import_node_os5 = __toESM(require("node:os"), 1);
|
|
2754
2654
|
var import_node_path8 = __toESM(require("node:path"), 1);
|
|
2755
|
-
var
|
|
2655
|
+
var TARGET_TYPES = [
|
|
2656
|
+
"regular",
|
|
2657
|
+
"executable",
|
|
2658
|
+
"test",
|
|
2659
|
+
"binary",
|
|
2660
|
+
"system",
|
|
2661
|
+
"macro",
|
|
2662
|
+
"plugin"
|
|
2663
|
+
];
|
|
2664
|
+
var isTargetType = (value) => TARGET_TYPES.some((type) => type === value);
|
|
2665
|
+
var record = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
2666
|
+
var array = (value) => Array.isArray(value) ? value : [];
|
|
2667
|
+
var string = (value) => typeof value === "string" ? value : void 0;
|
|
2668
|
+
function swiftCommand() {
|
|
2669
|
+
return process.platform === "darwin" ? { file: "xcrun", args: ["swift"] } : { file: import_node_path8.default.join(swiftToolchainBin(swift_distribution_lock_default.release), "swift"), args: [] };
|
|
2670
|
+
}
|
|
2671
|
+
var cacheDir = import_node_path8.default.join(import_node_os5.default.tmpdir(), "peach-swift-manifests");
|
|
2672
|
+
var evaluated = /* @__PURE__ */ new Map();
|
|
2673
|
+
function dump(dir) {
|
|
2674
|
+
const manifests = import_node_fs7.default.readdirSync(dir).filter((name) => /^Package(@swift-[\d.]+)?\.swift$/.test(name)).sort();
|
|
2675
|
+
const command = swiftCommand();
|
|
2676
|
+
const key = (0, import_node_crypto4.createHash)("sha256").update(JSON.stringify([command, import_node_path8.default.resolve(dir)])).update(
|
|
2677
|
+
manifests.map((name) => `${name}\0${import_node_fs7.default.readFileSync(import_node_path8.default.join(dir, name), "utf8")}`).join("\0")
|
|
2678
|
+
).digest("hex").slice(0, 32);
|
|
2679
|
+
const cached = import_node_path8.default.join(cacheDir, `${key}.json`);
|
|
2680
|
+
if (import_node_fs7.default.existsSync(cached))
|
|
2681
|
+
return { key, raw: record(JSON.parse(import_node_fs7.default.readFileSync(cached, "utf8"))) };
|
|
2682
|
+
let output;
|
|
2683
|
+
try {
|
|
2684
|
+
output = (0, import_node_child_process5.execFileSync)(
|
|
2685
|
+
command.file,
|
|
2686
|
+
[
|
|
2687
|
+
...command.args,
|
|
2688
|
+
"package",
|
|
2689
|
+
"--package-path",
|
|
2690
|
+
dir,
|
|
2691
|
+
// swiftpm's scratch files never land in the app's own package
|
|
2692
|
+
"--scratch-path",
|
|
2693
|
+
import_node_path8.default.join(cacheDir, `${key}.build`),
|
|
2694
|
+
"dump-package"
|
|
2695
|
+
],
|
|
2696
|
+
{
|
|
2697
|
+
encoding: "utf8",
|
|
2698
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
2699
|
+
maxBuffer: 64 * 1024 * 1024
|
|
2700
|
+
}
|
|
2701
|
+
);
|
|
2702
|
+
} catch (error) {
|
|
2703
|
+
const stderr = error instanceof Error && "stderr" in error ? String(error.stderr).trim() : "";
|
|
2704
|
+
throw new Error(
|
|
2705
|
+
`swiftpm could not evaluate ${import_node_path8.default.join(dir, "Package.swift")}${stderr ? `: ${stderr}` : ""}`
|
|
2706
|
+
);
|
|
2707
|
+
}
|
|
2708
|
+
import_node_fs7.default.mkdirSync(cacheDir, { recursive: true });
|
|
2709
|
+
import_node_fs7.default.writeFileSync(cached, output);
|
|
2710
|
+
return { key, raw: record(JSON.parse(output)) };
|
|
2711
|
+
}
|
|
2712
|
+
function defaultTraits(manifest) {
|
|
2713
|
+
const traits = new Map(
|
|
2714
|
+
array(manifest.traits).map((trait) => [
|
|
2715
|
+
string(record(trait).name) ?? "",
|
|
2716
|
+
array(record(trait).enabledTraits).flatMap((name) => string(name) ?? [])
|
|
2717
|
+
])
|
|
2718
|
+
);
|
|
2719
|
+
const enabled = /* @__PURE__ */ new Set();
|
|
2720
|
+
const pending = [...traits.get("default") ?? []];
|
|
2721
|
+
while (pending.length > 0) {
|
|
2722
|
+
const name = pending.pop();
|
|
2723
|
+
if (enabled.has(name)) continue;
|
|
2724
|
+
enabled.add(name);
|
|
2725
|
+
pending.push(...traits.get(name) ?? []);
|
|
2726
|
+
}
|
|
2727
|
+
return enabled;
|
|
2728
|
+
}
|
|
2729
|
+
function linksOnIOS(condition, traits) {
|
|
2730
|
+
const { platformNames, traits: needed } = record(condition);
|
|
2731
|
+
const platforms = array(platformNames);
|
|
2732
|
+
if (platforms.length > 0 && !platforms.includes("ios")) return false;
|
|
2733
|
+
const gates = array(needed);
|
|
2734
|
+
return gates.length === 0 || gates.some((name) => traits.has(string(name) ?? ""));
|
|
2735
|
+
}
|
|
2736
|
+
function swiftPackageManifest(dir) {
|
|
2737
|
+
dir = import_node_fs7.default.realpathSync(dir);
|
|
2738
|
+
const { key, raw: raw2 } = dump(dir);
|
|
2739
|
+
const known = evaluated.get(key);
|
|
2740
|
+
if (known) return known;
|
|
2741
|
+
const traits = defaultTraits(raw2);
|
|
2742
|
+
const tools = Number(
|
|
2743
|
+
/^(\d+)/.exec(string(record(raw2.toolsVersion)._version) ?? "5")?.[1] ?? 5
|
|
2744
|
+
);
|
|
2745
|
+
const declaredModes = array(raw2.swiftLanguageVersions).flatMap((mode) => {
|
|
2746
|
+
const major = Number(/^(\d+)/.exec(string(mode) ?? "")?.[1]);
|
|
2747
|
+
return Number.isFinite(major) ? [major] : [];
|
|
2748
|
+
});
|
|
2749
|
+
const packageMode = Math.max(
|
|
2750
|
+
5,
|
|
2751
|
+
declaredModes.length > 0 ? Math.max(...declaredModes) : tools >= 6 ? 6 : 5
|
|
2752
|
+
);
|
|
2753
|
+
const packages = /* @__PURE__ */ new Map();
|
|
2754
|
+
for (const entry of array(raw2.dependencies)) {
|
|
2755
|
+
const { sourceControl, fileSystem } = record(entry);
|
|
2756
|
+
const source = record(array(sourceControl ?? fileSystem)[0]);
|
|
2757
|
+
const identity = string(source.identity);
|
|
2758
|
+
if (!identity) continue;
|
|
2759
|
+
const url = string(record(array(record(source.location).remote)[0]).urlString);
|
|
2760
|
+
const local = string(source.path);
|
|
2761
|
+
const value = url ? { url } : local ? { dir: local } : null;
|
|
2762
|
+
if (!value) continue;
|
|
2763
|
+
packages.set(identity, value);
|
|
2764
|
+
const alias = string(source.nameForTargetDependencyResolutionOnly);
|
|
2765
|
+
if (alias) packages.set(alias.toLowerCase(), value);
|
|
2766
|
+
}
|
|
2767
|
+
const products = /* @__PURE__ */ new Map();
|
|
2768
|
+
for (const product of array(raw2.products)) {
|
|
2769
|
+
const { name, targets: targets2, type } = record(product);
|
|
2770
|
+
if (!string(name) || !("library" in record(type))) continue;
|
|
2771
|
+
products.set(
|
|
2772
|
+
string(name),
|
|
2773
|
+
array(targets2).flatMap((target) => string(target) ?? [])
|
|
2774
|
+
);
|
|
2775
|
+
}
|
|
2776
|
+
const targets = /* @__PURE__ */ new Map();
|
|
2777
|
+
const names = new Set(array(raw2.targets).map((target) => string(record(target).name)));
|
|
2778
|
+
for (const entry of array(raw2.targets)) {
|
|
2779
|
+
const target = record(entry);
|
|
2780
|
+
const name = string(target.name);
|
|
2781
|
+
const kind = string(target.type);
|
|
2782
|
+
if (!name || !isTargetType(kind)) continue;
|
|
2783
|
+
const declared = string(target.path);
|
|
2784
|
+
const roots = kind === "test" ? ["Tests"] : ["Sources", "Source", "src", "srcs"];
|
|
2785
|
+
const targetDir = declared ? import_node_path8.default.resolve(dir, declared) : roots.map((root) => import_node_path8.default.join(dir, root, name)).find((candidate) => import_node_fs7.default.existsSync(candidate)) ?? import_node_path8.default.join(dir, roots[0], name);
|
|
2786
|
+
const dependencies = [];
|
|
2787
|
+
for (const dependency of array(target.dependencies)) {
|
|
2788
|
+
const { target: local, product, byName } = record(dependency);
|
|
2789
|
+
const payload = array(local ?? product ?? byName);
|
|
2790
|
+
if (!linksOnIOS(payload[payload.length - 1], traits)) continue;
|
|
2791
|
+
const dependencyName = string(payload[0]);
|
|
2792
|
+
if (!dependencyName) continue;
|
|
2793
|
+
if (product)
|
|
2794
|
+
dependencies.push({
|
|
2795
|
+
kind: "product",
|
|
2796
|
+
name: dependencyName,
|
|
2797
|
+
package: (string(payload[1]) ?? "").toLowerCase()
|
|
2798
|
+
});
|
|
2799
|
+
else if (local || names.has(dependencyName))
|
|
2800
|
+
dependencies.push({ kind: "target", name: dependencyName });
|
|
2801
|
+
else
|
|
2802
|
+
dependencies.push({
|
|
2803
|
+
kind: "product",
|
|
2804
|
+
name: dependencyName,
|
|
2805
|
+
package: dependencyName.toLowerCase()
|
|
2806
|
+
});
|
|
2807
|
+
}
|
|
2808
|
+
let languageMode = packageMode;
|
|
2809
|
+
let mainActorIsolation = false;
|
|
2810
|
+
for (const setting of array(target.settings)) {
|
|
2811
|
+
const settingKind = record(record(setting).kind);
|
|
2812
|
+
const mode = string(record(settingKind.swiftLanguageMode)._0);
|
|
2813
|
+
if (mode)
|
|
2814
|
+
languageMode = Math.max(5, Number(/^(\d+)/.exec(mode)?.[1] ?? languageMode));
|
|
2815
|
+
if (string(record(settingKind.defaultIsolation)._0) === "MainActor")
|
|
2816
|
+
mainActorIsolation = true;
|
|
2817
|
+
}
|
|
2818
|
+
targets.set(name, {
|
|
2819
|
+
name,
|
|
2820
|
+
type: kind,
|
|
2821
|
+
dir: targetDir,
|
|
2822
|
+
sources: target.sources == null ? null : array(target.sources).flatMap((file) => string(file) ?? []),
|
|
2823
|
+
exclude: array(target.exclude).flatMap((file) => string(file) ?? []),
|
|
2824
|
+
dependencies,
|
|
2825
|
+
languageMode,
|
|
2826
|
+
mainActorIsolation,
|
|
2827
|
+
declaresResources: array(target.resources).length > 0
|
|
2828
|
+
});
|
|
2829
|
+
}
|
|
2830
|
+
const manifest = { dir, products, targets, packages };
|
|
2831
|
+
evaluated.set(key, manifest);
|
|
2832
|
+
return manifest;
|
|
2833
|
+
}
|
|
2834
|
+
var within = (file, roots) => roots.some((root) => file === root || file.startsWith(`${root}${import_node_path8.default.sep}`));
|
|
2835
|
+
function walk(dir) {
|
|
2836
|
+
if (!import_node_fs7.default.existsSync(dir)) return [];
|
|
2837
|
+
if (import_node_fs7.default.statSync(dir).isFile()) return [dir];
|
|
2838
|
+
const out = [];
|
|
2839
|
+
for (const entry of import_node_fs7.default.readdirSync(dir, { withFileTypes: true })) {
|
|
2840
|
+
if (entry.name.startsWith(".")) continue;
|
|
2841
|
+
const full = import_node_path8.default.join(dir, entry.name);
|
|
2842
|
+
if (entry.isDirectory()) out.push(...walk(full));
|
|
2843
|
+
else if (entry.isFile()) out.push(full);
|
|
2844
|
+
}
|
|
2845
|
+
return out;
|
|
2846
|
+
}
|
|
2847
|
+
function swiftTargetFiles(manifest, target) {
|
|
2848
|
+
const included = target.sources ? target.sources.map((source) => import_node_path8.default.resolve(target.dir, source)) : [target.dir];
|
|
2849
|
+
const excluded = [
|
|
2850
|
+
...target.exclude.map((file) => import_node_path8.default.resolve(target.dir, file)),
|
|
2851
|
+
...[...manifest.targets.values()].flatMap(
|
|
2852
|
+
(other) => other !== target && within(other.dir, [target.dir]) && other.dir !== target.dir ? [other.dir] : []
|
|
2853
|
+
)
|
|
2854
|
+
];
|
|
2855
|
+
return included.flatMap(walk).filter((file) => !within(file, excluded)).sort();
|
|
2856
|
+
}
|
|
2857
|
+
|
|
2858
|
+
// src/swift-packages.ts
|
|
2859
|
+
var REMOTE_CHECKOUTS = import_node_path9.default.join(".build", "peach", "checkouts");
|
|
2756
2860
|
var C_FAMILY = /\.(c|cc|cpp|cxx|m|mm|s|S)$/;
|
|
2757
2861
|
function readPins(resolved) {
|
|
2758
|
-
const data = JSON.parse(
|
|
2862
|
+
const data = JSON.parse(import_node_fs8.default.readFileSync(resolved, "utf8"));
|
|
2759
2863
|
const pins = data && typeof data === "object" && "pins" in data && Array.isArray(data.pins) ? data.pins : null;
|
|
2760
2864
|
if (!pins)
|
|
2761
2865
|
throw new Error(`${resolved} has no pins; resolve packages in a current Xcode`);
|
|
@@ -2769,36 +2873,25 @@ function readPins(resolved) {
|
|
|
2769
2873
|
}
|
|
2770
2874
|
return out;
|
|
2771
2875
|
}
|
|
2772
|
-
function walk(dir) {
|
|
2773
|
-
if (!import_node_fs7.default.existsSync(dir)) return [];
|
|
2774
|
-
const out = [];
|
|
2775
|
-
for (const entry of import_node_fs7.default.readdirSync(dir, { withFileTypes: true })) {
|
|
2776
|
-
if (entry.name.startsWith(".")) continue;
|
|
2777
|
-
const full = import_node_path8.default.join(dir, entry.name);
|
|
2778
|
-
if (entry.isDirectory()) out.push(...walk(full));
|
|
2779
|
-
else if (entry.isFile()) out.push(full);
|
|
2780
|
-
}
|
|
2781
|
-
return out.sort();
|
|
2782
|
-
}
|
|
2783
2876
|
var verified2 = /* @__PURE__ */ new Set();
|
|
2784
2877
|
function checkout(checkouts, identity, pin) {
|
|
2785
|
-
const dir =
|
|
2878
|
+
const dir = import_node_path9.default.join(checkouts, identity);
|
|
2786
2879
|
const key = `${dir}\0${pin.revision}`;
|
|
2787
2880
|
if (verified2.has(key)) return dir;
|
|
2788
|
-
const git = (...args) => (0,
|
|
2881
|
+
const git = (...args) => (0, import_node_child_process6.execFileSync)("git", ["-C", dir, ...args], {
|
|
2789
2882
|
encoding: "utf8",
|
|
2790
2883
|
stdio: ["ignore", "pipe", "pipe"]
|
|
2791
2884
|
}).trim();
|
|
2792
|
-
const current =
|
|
2885
|
+
const current = import_node_fs8.default.existsSync(import_node_path9.default.join(dir, ".git")) ? git("rev-parse", "HEAD") : "";
|
|
2793
2886
|
if (current !== pin.revision) {
|
|
2794
|
-
|
|
2795
|
-
|
|
2887
|
+
import_node_fs8.default.rmSync(dir, { recursive: true, force: true });
|
|
2888
|
+
import_node_fs8.default.mkdirSync(dir, { recursive: true });
|
|
2796
2889
|
try {
|
|
2797
2890
|
git("init", "-q");
|
|
2798
2891
|
git("fetch", "-q", "--depth", "1", pin.location, pin.revision);
|
|
2799
2892
|
git("checkout", "-q", "FETCH_HEAD");
|
|
2800
2893
|
} catch (error) {
|
|
2801
|
-
|
|
2894
|
+
import_node_fs8.default.rmSync(dir, { recursive: true, force: true });
|
|
2802
2895
|
const stderr = error instanceof Error && "stderr" in error ? String(error.stderr).trim() : "";
|
|
2803
2896
|
throw new Error(
|
|
2804
2897
|
`could not fetch ${pin.location} at ${pin.revision}${stderr ? `: ${stderr}` : ""}`
|
|
@@ -2808,127 +2901,153 @@ function checkout(checkouts, identity, pin) {
|
|
|
2808
2901
|
verified2.add(key);
|
|
2809
2902
|
return dir;
|
|
2810
2903
|
}
|
|
2811
|
-
function
|
|
2812
|
-
const
|
|
2813
|
-
const
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
return result;
|
|
2822
|
-
}
|
|
2823
|
-
const pins = readPins(resolved);
|
|
2824
|
-
const checkouts = import_node_path8.default.join(projectDir, REMOTE_CHECKOUTS);
|
|
2825
|
-
import_node_fs7.default.mkdirSync(checkouts, { recursive: true });
|
|
2826
|
-
import_node_fs7.default.writeFileSync(import_node_path8.default.join(import_node_path8.default.dirname(checkouts), ".gitignore"), "*\n");
|
|
2904
|
+
function resolveSwiftPackages(options) {
|
|
2905
|
+
const { rootDir, resolved, products, localDirs } = options;
|
|
2906
|
+
const provided = options.provided ?? /* @__PURE__ */ new Set();
|
|
2907
|
+
const result = {
|
|
2908
|
+
targets: [],
|
|
2909
|
+
unavailable: /* @__PURE__ */ new Map(),
|
|
2910
|
+
modules: /* @__PURE__ */ new Map()
|
|
2911
|
+
};
|
|
2912
|
+
const pins = resolved ? readPins(resolved) : null;
|
|
2913
|
+
const checkouts = import_node_path9.default.join(rootDir, REMOTE_CHECKOUTS);
|
|
2827
2914
|
const packages = /* @__PURE__ */ new Map();
|
|
2828
|
-
const load2 = (
|
|
2829
|
-
const
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2915
|
+
const load2 = (source) => {
|
|
2916
|
+
const key = source.kind === "local" ? import_node_path9.default.resolve(source.dir) : source.url;
|
|
2917
|
+
const cached = packages.get(key);
|
|
2918
|
+
if (cached !== void 0) return cached;
|
|
2919
|
+
let loaded2;
|
|
2920
|
+
if (source.kind === "local") {
|
|
2921
|
+
loaded2 = { source: key, remote: false, manifest: swiftPackageManifest(key) };
|
|
2922
|
+
} else {
|
|
2923
|
+
const identity = swiftPackageIdentity(source.url);
|
|
2924
|
+
const pin = pins?.get(identity);
|
|
2925
|
+
if (!pin) {
|
|
2926
|
+
loaded2 = pins ? `package ${identity} is not pinned in Package.resolved` : "no Package.resolved pins it; resolve packages in Xcode once";
|
|
2927
|
+
} else {
|
|
2928
|
+
import_node_fs8.default.mkdirSync(checkouts, { recursive: true });
|
|
2929
|
+
import_node_fs8.default.writeFileSync(import_node_path9.default.join(import_node_path9.default.dirname(checkouts), ".gitignore"), "*\n");
|
|
2930
|
+
loaded2 = {
|
|
2931
|
+
source: source.url,
|
|
2932
|
+
remote: true,
|
|
2933
|
+
manifest: swiftPackageManifest(checkout(checkouts, identity, pin))
|
|
2934
|
+
};
|
|
2935
|
+
}
|
|
2936
|
+
}
|
|
2937
|
+
packages.set(key, loaded2);
|
|
2837
2938
|
return loaded2;
|
|
2838
2939
|
};
|
|
2839
2940
|
const targets = /* @__PURE__ */ new Map();
|
|
2840
|
-
const
|
|
2841
|
-
const
|
|
2842
|
-
const key = `${
|
|
2843
|
-
if (
|
|
2844
|
-
|
|
2845
|
-
const
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
return
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
const pending = [...roots];
|
|
2861
|
-
let reason = null;
|
|
2862
|
-
while (pending.length > 0 && !reason) {
|
|
2863
|
-
const name = pending.pop();
|
|
2864
|
-
if (seen.has(name) || provided.has(name)) continue;
|
|
2865
|
-
seen.add(name);
|
|
2866
|
-
if (pkg.graph.binaryTargets.has(name)) {
|
|
2867
|
-
reason = `${name} is a binary framework`;
|
|
2868
|
-
break;
|
|
2869
|
-
}
|
|
2870
|
-
if (pkg.graph.systemLibraries.has(name)) {
|
|
2871
|
-
reason = `${name} is a system C library`;
|
|
2872
|
-
break;
|
|
2873
|
-
}
|
|
2874
|
-
const target = declared.get(name);
|
|
2875
|
-
if (!target) {
|
|
2876
|
-
reason = `${identity} declares no target ${name}`;
|
|
2877
|
-
break;
|
|
2878
|
-
}
|
|
2879
|
-
const files = walk(import_node_path8.default.join(pkg.dir, target.path));
|
|
2880
|
-
if (files.some((file) => C_FAMILY.test(file))) {
|
|
2881
|
-
reason = `${name} is a C or Objective-C target`;
|
|
2882
|
-
break;
|
|
2883
|
-
}
|
|
2884
|
-
reached.push(target);
|
|
2885
|
-
for (const dependency of pkg.graph.dependencies.get(name) ?? []) {
|
|
2886
|
-
if (dependency.kind === "target") pending.push(dependency.name);
|
|
2887
|
-
else if (!provided.has(dependency.name)) {
|
|
2888
|
-
const url = pkg.graph.packageURLs.get(dependency.package);
|
|
2889
|
-
const nested = resolveProduct(
|
|
2890
|
-
url ? swiftPackageIdentity(url) : dependency.package,
|
|
2891
|
-
dependency.name
|
|
2892
|
-
);
|
|
2893
|
-
if (nested) reason = `${dependency.name}: ${nested}`;
|
|
2941
|
+
const targetOutcomes = /* @__PURE__ */ new Map();
|
|
2942
|
+
const resolveTarget = (pkg, name) => {
|
|
2943
|
+
const key = `${pkg.manifest.dir}\0${name}`;
|
|
2944
|
+
if (targetOutcomes.has(key)) return targetOutcomes.get(key);
|
|
2945
|
+
targetOutcomes.set(key, null);
|
|
2946
|
+
const outcome = (() => {
|
|
2947
|
+
if (provided.has(name)) return null;
|
|
2948
|
+
const target = pkg.manifest.targets.get(name);
|
|
2949
|
+
if (!target) return `${import_node_path9.default.basename(pkg.manifest.dir)} declares no target ${name}`;
|
|
2950
|
+
if (target.type === "binary") return `${name} is a binary framework`;
|
|
2951
|
+
if (target.type === "system") return `${name} is a system C library`;
|
|
2952
|
+
if (target.type !== "regular") return `${name} is a ${target.type} target`;
|
|
2953
|
+
const files = swiftTargetFiles(pkg.manifest, target);
|
|
2954
|
+
if (files.some((file) => C_FAMILY.test(file)))
|
|
2955
|
+
return `${name} is a C or Objective-C target`;
|
|
2956
|
+
for (const dependency of target.dependencies) {
|
|
2957
|
+
if (dependency.kind === "target") {
|
|
2958
|
+
const nested2 = resolveTarget(pkg, dependency.name);
|
|
2959
|
+
if (nested2) return nested2;
|
|
2960
|
+
continue;
|
|
2894
2961
|
}
|
|
2962
|
+
const nested = resolveDependencyProduct(pkg, dependency.package, dependency.name);
|
|
2963
|
+
if (nested) return `${dependency.name}: ${nested}`;
|
|
2895
2964
|
}
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
)
|
|
2905
|
-
);
|
|
2906
|
-
const withResources = new Map(
|
|
2907
|
-
swiftManifestTargets(pkg.manifest, relative).map((target) => [target.name, target])
|
|
2908
|
-
);
|
|
2909
|
-
for (const target of reached) {
|
|
2910
|
-
const dir = import_node_path8.default.join(pkg.dir, target.path);
|
|
2911
|
-
targets.set(target.name, {
|
|
2912
|
-
...withResources.get(target.name) ?? target,
|
|
2965
|
+
const relative = files.map((file) => import_node_path9.default.relative(target.dir, file));
|
|
2966
|
+
targets.set(`${pkg.manifest.dir}\0${name}`, {
|
|
2967
|
+
name,
|
|
2968
|
+
path: "",
|
|
2969
|
+
dir: target.dir,
|
|
2970
|
+
files,
|
|
2971
|
+
packageDir: pkg.manifest.dir,
|
|
2972
|
+
remote: pkg.remote,
|
|
2913
2973
|
executable: false,
|
|
2914
|
-
|
|
2915
|
-
|
|
2974
|
+
languageMode: target.languageMode,
|
|
2975
|
+
mainActorIsolation: target.mainActorIsolation,
|
|
2976
|
+
resources: target.declaresResources || swiftImplicitResourcePaths(relative).length > 0
|
|
2916
2977
|
});
|
|
2978
|
+
return null;
|
|
2979
|
+
})();
|
|
2980
|
+
targetOutcomes.set(key, outcome);
|
|
2981
|
+
return outcome;
|
|
2982
|
+
};
|
|
2983
|
+
const resolveProduct = (pkg, product) => {
|
|
2984
|
+
if (provided.has(product)) return null;
|
|
2985
|
+
const roots = pkg.manifest.products.get(product);
|
|
2986
|
+
if (!roots) return `${import_node_path9.default.basename(pkg.manifest.dir)} has no library ${product}`;
|
|
2987
|
+
for (const name of roots) {
|
|
2988
|
+
const reason = resolveTarget(pkg, name);
|
|
2989
|
+
if (reason) return reason;
|
|
2917
2990
|
}
|
|
2918
2991
|
return null;
|
|
2919
2992
|
};
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2993
|
+
const resolveDependencyProduct = (pkg, packageName, product) => {
|
|
2994
|
+
if (provided.has(product)) return null;
|
|
2995
|
+
const dependency = pkg.manifest.packages.get(packageName);
|
|
2996
|
+
if (!dependency)
|
|
2997
|
+
return `${import_node_path9.default.basename(pkg.manifest.dir)} names no package ${packageName}`;
|
|
2998
|
+
if ("dir" in dependency) {
|
|
2999
|
+
const loaded3 = load2({ kind: "local", dir: dependency.dir });
|
|
3000
|
+
return typeof loaded3 === "string" ? loaded3 : resolveProduct(loaded3, product);
|
|
3001
|
+
}
|
|
3002
|
+
if (!options.provided) return null;
|
|
3003
|
+
const loaded2 = load2({ kind: "remote", url: dependency.url });
|
|
3004
|
+
return typeof loaded2 === "string" ? loaded2 : resolveProduct(loaded2, product);
|
|
3005
|
+
};
|
|
3006
|
+
const unnamed = () => localDirs.map((dir) => load2({ kind: "local", dir })).filter((pkg) => typeof pkg !== "string");
|
|
3007
|
+
for (const { product, source } of products) {
|
|
3008
|
+
if (provided.has(product)) continue;
|
|
3009
|
+
if (source.kind === "remote" && !options.provided) continue;
|
|
3010
|
+
const pkg = source.kind === "unnamed" ? unnamed().find((candidate) => candidate.manifest.products.has(product)) : load2(source);
|
|
3011
|
+
const reason = pkg === void 0 ? "no package the workspace references vends it" : typeof pkg === "string" ? pkg : resolveProduct(pkg, product);
|
|
2925
3012
|
if (reason)
|
|
2926
|
-
result.unavailable.set(
|
|
2927
|
-
|
|
3013
|
+
result.unavailable.set(product, {
|
|
3014
|
+
source: source.kind === "remote" ? source.url : typeof pkg === "object" ? pkg.source : source.kind === "local" ? source.dir : "the workspace",
|
|
2928
3015
|
reason
|
|
2929
3016
|
});
|
|
2930
3017
|
}
|
|
2931
|
-
|
|
3018
|
+
for (const pkg of packages.values()) {
|
|
3019
|
+
if (typeof pkg === "string") continue;
|
|
3020
|
+
for (const [name, target] of pkg.manifest.targets) {
|
|
3021
|
+
if (target.type === "test" || target.type === "plugin" || target.type === "macro")
|
|
3022
|
+
continue;
|
|
3023
|
+
if (target.type === "executable") continue;
|
|
3024
|
+
const reason = resolveTarget(pkg, name);
|
|
3025
|
+
if (reason && !result.modules.has(name))
|
|
3026
|
+
result.modules.set(name, { source: pkg.source, reason });
|
|
3027
|
+
}
|
|
3028
|
+
}
|
|
3029
|
+
const reached = /* @__PURE__ */ new Set();
|
|
3030
|
+
const reach = (pkg, name) => {
|
|
3031
|
+
const key = `${pkg.manifest.dir}\0${name}`;
|
|
3032
|
+
if (reached.has(key) || !targets.has(key)) return;
|
|
3033
|
+
reached.add(key);
|
|
3034
|
+
for (const dependency of pkg.manifest.targets.get(name)?.dependencies ?? []) {
|
|
3035
|
+
if (dependency.kind === "target") reach(pkg, dependency.name);
|
|
3036
|
+
else {
|
|
3037
|
+
const source = pkg.manifest.packages.get(dependency.package);
|
|
3038
|
+
const nested = source && ("dir" in source ? packages.get(import_node_path9.default.resolve(source.dir)) : packages.get(source.url));
|
|
3039
|
+
if (nested && typeof nested !== "string")
|
|
3040
|
+
for (const root of nested.manifest.products.get(dependency.name) ?? [])
|
|
3041
|
+
reach(nested, root);
|
|
3042
|
+
}
|
|
3043
|
+
}
|
|
3044
|
+
};
|
|
3045
|
+
for (const { product, source } of products) {
|
|
3046
|
+
const pkg = source.kind === "unnamed" ? unnamed().find((candidate) => candidate.manifest.products.has(product)) : packages.get(source.kind === "local" ? import_node_path9.default.resolve(source.dir) : source.url);
|
|
3047
|
+
if (!pkg || typeof pkg === "string" || result.unavailable.has(product)) continue;
|
|
3048
|
+
for (const root of pkg.manifest.products.get(product) ?? []) reach(pkg, root);
|
|
3049
|
+
}
|
|
3050
|
+
result.targets = [...targets.entries()].filter(([key]) => reached.has(key)).map(([, target]) => target);
|
|
2932
3051
|
return result;
|
|
2933
3052
|
}
|
|
2934
3053
|
|
|
@@ -3069,12 +3188,12 @@ async function compileSwiftProject(submit, work, origin, signal) {
|
|
|
3069
3188
|
}
|
|
3070
3189
|
|
|
3071
3190
|
// src/xcode-project.ts
|
|
3072
|
-
var
|
|
3073
|
-
var
|
|
3191
|
+
var import_node_fs9 = __toESM(require("node:fs"), 1);
|
|
3192
|
+
var import_node_path11 = __toESM(require("node:path"), 1);
|
|
3074
3193
|
var import_plist = __toESM(require_plist(), 1);
|
|
3075
3194
|
|
|
3076
3195
|
// src/xcode-json-project.ts
|
|
3077
|
-
var
|
|
3196
|
+
var import_node_path10 = __toESM(require("node:path"), 1);
|
|
3078
3197
|
var import_json5 = __toESM(require("json5"), 1);
|
|
3079
3198
|
var isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3080
3199
|
var text = (value) => typeof value === "string" ? value : void 0;
|
|
@@ -3090,7 +3209,7 @@ var PHASE_ISA = {
|
|
|
3090
3209
|
function readXcodeJsonProject(xcodeproj, source) {
|
|
3091
3210
|
const json = import_json5.default.parse(source);
|
|
3092
3211
|
if (!isJsonObject(json)) throw new Error(`${xcodeproj}/project.xcproj is not an object`);
|
|
3093
|
-
const projectDir =
|
|
3212
|
+
const projectDir = import_node_path10.default.dirname(xcodeproj);
|
|
3094
3213
|
const objects = {};
|
|
3095
3214
|
let next = 0;
|
|
3096
3215
|
const add = (entry, id) => {
|
|
@@ -3103,7 +3222,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
3103
3222
|
const base = /^<([A-Z]+)>\/(.*)$/.exec(raw2);
|
|
3104
3223
|
if (base) {
|
|
3105
3224
|
if (base[1] === "PROJECT")
|
|
3106
|
-
return { sourceTree: "<absolute>", path:
|
|
3225
|
+
return { sourceTree: "<absolute>", path: import_node_path10.default.join(projectDir, base[2]) };
|
|
3107
3226
|
if (base[1] === "PRODUCTS")
|
|
3108
3227
|
return { sourceTree: "BUILT_PRODUCTS_DIR", path: base[2] };
|
|
3109
3228
|
return null;
|
|
@@ -3111,7 +3230,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
3111
3230
|
const unescaped = raw2.replaceAll("\\<", "<");
|
|
3112
3231
|
if (unescaped.startsWith("/")) return { sourceTree: "<absolute>", path: unescaped };
|
|
3113
3232
|
if (unescaped.startsWith("~")) return null;
|
|
3114
|
-
return groupDir === null ? null : { sourceTree: "<absolute>", path:
|
|
3233
|
+
return groupDir === null ? null : { sourceTree: "<absolute>", path: import_node_path10.default.join(groupDir, unescaped) };
|
|
3115
3234
|
};
|
|
3116
3235
|
const memberships = [];
|
|
3117
3236
|
const folders = [];
|
|
@@ -3122,7 +3241,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
3122
3241
|
const kind = text(entry.kind) ?? "file-reference";
|
|
3123
3242
|
const raw2 = text(entry.path) ?? "";
|
|
3124
3243
|
const located = raw2 === "" ? null : locate(raw2, parent.dir);
|
|
3125
|
-
const name = text(entry.name) ??
|
|
3244
|
+
const name = text(entry.name) ?? import_node_path10.default.basename(raw2);
|
|
3126
3245
|
const node = { id: "", name, dir: null, parent, children: [] };
|
|
3127
3246
|
if (kind === "group" || kind === "variant-group" || kind === "version-group") {
|
|
3128
3247
|
node.dir = raw2 === "" ? parent.dir : located?.sourceTree === "<absolute>" ? located.path : null;
|
|
@@ -3237,7 +3356,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
3237
3356
|
if (!isObject(entry)) continue;
|
|
3238
3357
|
const repository = text(entry.repository);
|
|
3239
3358
|
const local = text(entry.path);
|
|
3240
|
-
const name = local !== void 0 ?
|
|
3359
|
+
const name = local !== void 0 ? import_node_path10.default.basename(import_node_path10.default.resolve(import_node_path10.default.dirname(xcodeproj), local)) : import_node_path10.default.basename(repository ?? "").replace(/\.git$/, "");
|
|
3241
3360
|
const id = text(entry.kind) === "local" && local !== void 0 ? add({ isa: "XCLocalSwiftPackageReference", relativePath: local }) : add({ isa: "XCRemoteSwiftPackageReference", repositoryURL: repository ?? "" });
|
|
3242
3361
|
packageIds.set(name.toLowerCase(), id);
|
|
3243
3362
|
}
|
|
@@ -3514,28 +3633,28 @@ var CONDITIONS = {
|
|
|
3514
3633
|
variant: "normal"
|
|
3515
3634
|
};
|
|
3516
3635
|
function walkFiles(dir) {
|
|
3517
|
-
if (!
|
|
3636
|
+
if (!import_node_fs9.default.existsSync(dir)) return [];
|
|
3518
3637
|
const out = [];
|
|
3519
|
-
for (const entry of
|
|
3638
|
+
for (const entry of import_node_fs9.default.readdirSync(dir, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
|
|
3520
3639
|
if (entry.name.startsWith(".")) continue;
|
|
3521
|
-
const full =
|
|
3640
|
+
const full = import_node_path11.default.join(dir, entry.name);
|
|
3522
3641
|
if (entry.isDirectory()) out.push(...walkFiles(full));
|
|
3523
3642
|
else if (entry.isFile()) out.push(full);
|
|
3524
3643
|
}
|
|
3525
3644
|
return out;
|
|
3526
3645
|
}
|
|
3527
|
-
var isDirectory = (dir) =>
|
|
3646
|
+
var isDirectory = (dir) => import_node_fs9.default.existsSync(dir) && import_node_fs9.default.statSync(dir).isDirectory();
|
|
3528
3647
|
function readXcconfig(file, seen = /* @__PURE__ */ new Set()) {
|
|
3529
|
-
if (seen.has(file) || !
|
|
3648
|
+
if (seen.has(file) || !import_node_fs9.default.existsSync(file)) return {};
|
|
3530
3649
|
seen.add(file);
|
|
3531
3650
|
const settings = {};
|
|
3532
|
-
for (const raw2 of
|
|
3651
|
+
for (const raw2 of import_node_fs9.default.readFileSync(file, "utf8").split("\n")) {
|
|
3533
3652
|
const line = raw2.replace(/\/\/.*$/, "").trim();
|
|
3534
3653
|
const include = /^#include\??\s+"([^"]+)"/.exec(line);
|
|
3535
3654
|
if (include) {
|
|
3536
3655
|
Object.assign(
|
|
3537
3656
|
settings,
|
|
3538
|
-
readXcconfig(
|
|
3657
|
+
readXcconfig(import_node_path11.default.resolve(import_node_path11.default.dirname(file), include[1]), seen)
|
|
3539
3658
|
);
|
|
3540
3659
|
continue;
|
|
3541
3660
|
}
|
|
@@ -3585,22 +3704,22 @@ function decodeXml(text2) {
|
|
|
3585
3704
|
return text2.replaceAll(""", '"').replaceAll("'", "'").replaceAll("<", "<").replaceAll(">", ">").replaceAll("&", "&");
|
|
3586
3705
|
}
|
|
3587
3706
|
function workspaceReferences(workspace) {
|
|
3588
|
-
const data =
|
|
3589
|
-
if (!
|
|
3707
|
+
const data = import_node_path11.default.join(workspace, "contents.xcworkspacedata");
|
|
3708
|
+
if (!import_node_fs9.default.existsSync(data))
|
|
3590
3709
|
throw new Error(`${workspace} has no contents.xcworkspacedata`);
|
|
3591
|
-
const container =
|
|
3710
|
+
const container = import_node_path11.default.dirname(workspace);
|
|
3592
3711
|
const locate = (location, base) => {
|
|
3593
3712
|
const colon = location.indexOf(":");
|
|
3594
3713
|
const kind = location.slice(0, colon);
|
|
3595
3714
|
const rest = location.slice(colon + 1);
|
|
3596
|
-
if (kind === "group") return
|
|
3597
|
-
if (kind === "container" || kind === "self") return
|
|
3598
|
-
if (kind === "absolute") return
|
|
3599
|
-
throw new Error(`${
|
|
3715
|
+
if (kind === "group") return import_node_path11.default.resolve(base, rest);
|
|
3716
|
+
if (kind === "container" || kind === "self") return import_node_path11.default.resolve(container, rest);
|
|
3717
|
+
if (kind === "absolute") return import_node_path11.default.resolve(rest);
|
|
3718
|
+
throw new Error(`${import_node_path11.default.basename(workspace)} has an unsupported location ${location}`);
|
|
3600
3719
|
};
|
|
3601
3720
|
const groups = [container];
|
|
3602
3721
|
const references = [];
|
|
3603
|
-
for (const [, closing, tag, attributes, selfClosing] of
|
|
3722
|
+
for (const [, closing, tag, attributes, selfClosing] of import_node_fs9.default.readFileSync(data, "utf8").matchAll(/<(\/?)(Group|FileRef)\b([^>]*?)(\/?)>/g)) {
|
|
3604
3723
|
if (closing) {
|
|
3605
3724
|
if (tag === "Group") groups.pop();
|
|
3606
3725
|
continue;
|
|
@@ -3616,8 +3735,8 @@ function workspaceReferences(workspace) {
|
|
|
3616
3735
|
var loaded = /* @__PURE__ */ new Map();
|
|
3617
3736
|
function xcodeProjectFile(xcodeproj) {
|
|
3618
3737
|
for (const name of ["project.pbxproj", "project.xcproj"]) {
|
|
3619
|
-
const file =
|
|
3620
|
-
if (
|
|
3738
|
+
const file = import_node_path11.default.join(xcodeproj, name);
|
|
3739
|
+
if (import_node_fs9.default.existsSync(file)) return file;
|
|
3621
3740
|
}
|
|
3622
3741
|
return null;
|
|
3623
3742
|
}
|
|
@@ -3625,10 +3744,10 @@ function loadProject(xcodeproj) {
|
|
|
3625
3744
|
const projectFile = xcodeProjectFile(xcodeproj);
|
|
3626
3745
|
if (!projectFile)
|
|
3627
3746
|
throw new Error(`${xcodeproj} has no project.pbxproj or project.xcproj`);
|
|
3628
|
-
const mtimeMs =
|
|
3747
|
+
const mtimeMs = import_node_fs9.default.statSync(projectFile).mtimeMs;
|
|
3629
3748
|
const cached = loaded.get(projectFile);
|
|
3630
3749
|
if (cached?.mtimeMs === mtimeMs) return cached.project;
|
|
3631
|
-
const source =
|
|
3750
|
+
const source = import_node_fs9.default.readFileSync(projectFile, "utf8");
|
|
3632
3751
|
const root = projectFile.endsWith(".xcproj") ? readXcodeJsonProject(xcodeproj, source) : parseOpenStepPlist(source);
|
|
3633
3752
|
if (!isDict(root) || !isDict(root.objects)) {
|
|
3634
3753
|
throw new Error(`${projectFile} has no objects table`);
|
|
@@ -3642,8 +3761,8 @@ function loadProject(xcodeproj) {
|
|
|
3642
3761
|
if (!project || project.isa !== "PBXProject") {
|
|
3643
3762
|
throw new Error(`${projectFile} has no PBXProject root`);
|
|
3644
3763
|
}
|
|
3645
|
-
const projectDir =
|
|
3646
|
-
|
|
3764
|
+
const projectDir = import_node_fs9.default.realpathSync(
|
|
3765
|
+
import_node_path11.default.resolve(import_node_path11.default.dirname(xcodeproj), str(project.projectDirPath) ?? "")
|
|
3647
3766
|
);
|
|
3648
3767
|
const parent = /* @__PURE__ */ new Map();
|
|
3649
3768
|
for (const [id, entry] of Object.entries(objects)) {
|
|
@@ -3661,11 +3780,11 @@ function loadProject(xcodeproj) {
|
|
|
3661
3780
|
const own = str(entry.path) ?? "";
|
|
3662
3781
|
const tree = str(entry.sourceTree) ?? "<group>";
|
|
3663
3782
|
if (tree === "<absolute>") result2 = own;
|
|
3664
|
-
else if (tree === "SOURCE_ROOT") result2 =
|
|
3783
|
+
else if (tree === "SOURCE_ROOT") result2 = import_node_path11.default.join(projectDir, own);
|
|
3665
3784
|
else if (tree === "<group>") {
|
|
3666
3785
|
const up = parent.get(id);
|
|
3667
3786
|
const base = up ? resolvePath(up) : projectDir;
|
|
3668
|
-
result2 = base === null ? null :
|
|
3787
|
+
result2 = base === null ? null : import_node_path11.default.join(base, own);
|
|
3669
3788
|
}
|
|
3670
3789
|
}
|
|
3671
3790
|
resolvedPaths.set(id, result2);
|
|
@@ -3765,7 +3884,7 @@ function targetMembers(ref) {
|
|
|
3765
3884
|
const addResource = (file) => {
|
|
3766
3885
|
if (isDirectory(file)) {
|
|
3767
3886
|
for (const inner of walkFiles(file)) resources.add(inner);
|
|
3768
|
-
} else if (
|
|
3887
|
+
} else if (import_node_fs9.default.existsSync(file)) resources.add(file);
|
|
3769
3888
|
};
|
|
3770
3889
|
const fileRefPaths = (refId) => {
|
|
3771
3890
|
const entry = project.object(refId);
|
|
@@ -3786,7 +3905,7 @@ function targetMembers(ref) {
|
|
|
3786
3905
|
for (const buildFileId of list(phase.files)) {
|
|
3787
3906
|
for (const file of fileRefPaths(str(project.object(buildFileId)?.fileRef) ?? "")) {
|
|
3788
3907
|
if (phase.isa === "PBXSourcesBuildPhase") {
|
|
3789
|
-
if (!
|
|
3908
|
+
if (!import_node_fs9.default.existsSync(file)) continue;
|
|
3790
3909
|
allSources.add(file);
|
|
3791
3910
|
if (file.endsWith(".swift")) sources.add(file);
|
|
3792
3911
|
} else if (phase.isa === "PBXResourcesBuildPhase") addResource(file);
|
|
@@ -3794,7 +3913,7 @@ function targetMembers(ref) {
|
|
|
3794
3913
|
}
|
|
3795
3914
|
}
|
|
3796
3915
|
const addSynchronized = (folder, relative) => {
|
|
3797
|
-
const file =
|
|
3916
|
+
const file = import_node_path11.default.join(folder, relative);
|
|
3798
3917
|
if (NEVER_MEMBER.test(relative)) return;
|
|
3799
3918
|
if (file.endsWith(".swift")) {
|
|
3800
3919
|
if (!relative.split("/").some((segment) => BUNDLE_DIR.test(segment))) {
|
|
@@ -3819,7 +3938,7 @@ function targetMembers(ref) {
|
|
|
3819
3938
|
}
|
|
3820
3939
|
if (owned.has(groupId)) {
|
|
3821
3940
|
for (const file of walkFiles(folder)) {
|
|
3822
|
-
const relative =
|
|
3941
|
+
const relative = import_node_path11.default.relative(folder, file).split(import_node_path11.default.sep).join("/");
|
|
3823
3942
|
if ([...exceptions].some(
|
|
3824
3943
|
(exception) => relative === exception || relative.startsWith(`${exception}/`)
|
|
3825
3944
|
))
|
|
@@ -3828,14 +3947,14 @@ function targetMembers(ref) {
|
|
|
3828
3947
|
}
|
|
3829
3948
|
} else {
|
|
3830
3949
|
for (const relative of exceptions) {
|
|
3831
|
-
const file =
|
|
3950
|
+
const file = import_node_path11.default.join(folder, relative);
|
|
3832
3951
|
if (isDirectory(file)) {
|
|
3833
3952
|
for (const inner of walkFiles(file))
|
|
3834
3953
|
addSynchronized(
|
|
3835
3954
|
folder,
|
|
3836
|
-
|
|
3955
|
+
import_node_path11.default.relative(folder, inner).split(import_node_path11.default.sep).join("/")
|
|
3837
3956
|
);
|
|
3838
|
-
} else if (
|
|
3957
|
+
} else if (import_node_fs9.default.existsSync(file)) addSynchronized(folder, relative);
|
|
3839
3958
|
}
|
|
3840
3959
|
}
|
|
3841
3960
|
}
|
|
@@ -3848,8 +3967,8 @@ function targetMembers(ref) {
|
|
|
3848
3967
|
function commonAncestor(dirs) {
|
|
3849
3968
|
let common = dirs[0];
|
|
3850
3969
|
for (const dir of dirs) {
|
|
3851
|
-
while (common !==
|
|
3852
|
-
common =
|
|
3970
|
+
while (common !== import_node_path11.default.dirname(common) && import_node_path11.default.relative(common, dir).startsWith(".."))
|
|
3971
|
+
common = import_node_path11.default.dirname(common);
|
|
3853
3972
|
}
|
|
3854
3973
|
return common;
|
|
3855
3974
|
}
|
|
@@ -3858,8 +3977,8 @@ function workspaceProjects(xcodeprojOrWorkspace) {
|
|
|
3858
3977
|
const projects2 = [];
|
|
3859
3978
|
const projectAt = /* @__PURE__ */ new Map();
|
|
3860
3979
|
const addProject = (xcodeproj) => {
|
|
3861
|
-
const key =
|
|
3862
|
-
if (projectAt.has(key) || key.split(
|
|
3980
|
+
const key = import_node_path11.default.resolve(xcodeproj);
|
|
3981
|
+
if (projectAt.has(key) || key.split(import_node_path11.default.sep).includes("Pods")) return;
|
|
3863
3982
|
if (!xcodeProjectFile(key)) return;
|
|
3864
3983
|
const project = loadProject(key);
|
|
3865
3984
|
projectAt.set(key, project);
|
|
@@ -3876,7 +3995,7 @@ function workspaceProjects(xcodeprojOrWorkspace) {
|
|
|
3876
3995
|
for (const reference of listed)
|
|
3877
3996
|
if (reference.endsWith(".xcodeproj")) addProject(reference);
|
|
3878
3997
|
if (projects2.length === 0) {
|
|
3879
|
-
throw new Error(`${
|
|
3998
|
+
throw new Error(`${import_node_path11.default.basename(xcodeprojOrWorkspace)} lists no Xcode project`);
|
|
3880
3999
|
}
|
|
3881
4000
|
return { listed, projects: projects2, projectAt };
|
|
3882
4001
|
}
|
|
@@ -3898,7 +4017,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
3898
4017
|
const allTargets = projects2.flatMap(nativeTargets);
|
|
3899
4018
|
const appTargets = allTargets.filter((ref) => ref.target.productType === APPLICATION);
|
|
3900
4019
|
const appTargetNames = appTargets.map((ref) => str(ref.target.name) ?? ref.id);
|
|
3901
|
-
const container =
|
|
4020
|
+
const container = import_node_path11.default.basename(xcodeprojOrWorkspace);
|
|
3902
4021
|
const named = targetName ? appTargets.filter((ref) => ref.target.name === targetName) : appTargets;
|
|
3903
4022
|
if (named.length !== 1) {
|
|
3904
4023
|
throw new Error(
|
|
@@ -3910,14 +4029,14 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
3910
4029
|
for (const ref of allTargets) {
|
|
3911
4030
|
const product = ref.project.object(str(ref.target.productReference));
|
|
3912
4031
|
const file = str(product?.path);
|
|
3913
|
-
if (file && !byProduct.has(
|
|
3914
|
-
byProduct.set(
|
|
4032
|
+
if (file && !byProduct.has(import_node_path11.default.basename(file)))
|
|
4033
|
+
byProduct.set(import_node_path11.default.basename(file), ref);
|
|
3915
4034
|
}
|
|
3916
4035
|
const proxied = (project, proxyId) => {
|
|
3917
4036
|
const proxy = project.object(proxyId);
|
|
3918
4037
|
if (proxy?.isa !== "PBXContainerItemProxy") return void 0;
|
|
3919
4038
|
const portal = str(proxy.containerPortal);
|
|
3920
|
-
const owner = project.object(portal)?.isa === "PBXProject" ? project : projectAt.get(
|
|
4039
|
+
const owner = project.object(portal)?.isa === "PBXProject" ? project : projectAt.get(import_node_path11.default.resolve(project.resolvePath(portal ?? "") ?? ""));
|
|
3921
4040
|
const remote = str(proxy.remoteGlobalIDString);
|
|
3922
4041
|
if (!owner || !remote) return void 0;
|
|
3923
4042
|
return nativeTargets(owner).find(
|
|
@@ -3938,7 +4057,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
3938
4057
|
if (phase?.isa !== "PBXFrameworksBuildPhase") continue;
|
|
3939
4058
|
for (const buildFileId of list(phase.files)) {
|
|
3940
4059
|
const file = project.object(str(project.object(buildFileId)?.fileRef));
|
|
3941
|
-
const resolved = file?.isa === "PBXReferenceProxy" ? proxied(project, str(file.remoteRef)) : file && str(file.sourceTree) === "BUILT_PRODUCTS_DIR" ? byProduct.get(
|
|
4060
|
+
const resolved = file?.isa === "PBXReferenceProxy" ? proxied(project, str(file.remoteRef)) : file && str(file.sourceTree) === "BUILT_PRODUCTS_DIR" ? byProduct.get(import_node_path11.default.basename(str(file.path) ?? "")) : void 0;
|
|
3942
4061
|
if (resolved) found.push(resolved);
|
|
3943
4062
|
}
|
|
3944
4063
|
}
|
|
@@ -3959,7 +4078,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
3959
4078
|
const name = str(ref.target.name) ?? ref.id;
|
|
3960
4079
|
const { get: settings2, keys } = targetSettings(ref, {
|
|
3961
4080
|
TARGET_NAME: name,
|
|
3962
|
-
PROJECT_NAME:
|
|
4081
|
+
PROJECT_NAME: import_node_path11.default.basename(ref.project.xcodeproj, ".xcodeproj"),
|
|
3963
4082
|
SRCROOT: ref.project.projectDir,
|
|
3964
4083
|
SOURCE_ROOT: ref.project.projectDir,
|
|
3965
4084
|
PROJECT_DIR: ref.project.projectDir,
|
|
@@ -3990,8 +4109,8 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
3990
4109
|
}
|
|
3991
4110
|
return value;
|
|
3992
4111
|
};
|
|
3993
|
-
const infoPlistFile = settings("INFOPLIST_FILE") ?
|
|
3994
|
-
const sourceInfo = infoPlistFile ? import_plist.default.parse(
|
|
4112
|
+
const infoPlistFile = settings("INFOPLIST_FILE") ? import_node_path11.default.resolve(app.project.projectDir, settings("INFOPLIST_FILE")) : null;
|
|
4113
|
+
const sourceInfo = infoPlistFile ? import_plist.default.parse(import_node_fs9.default.readFileSync(infoPlistFile, "utf8")) : {};
|
|
3995
4114
|
if (!sourceInfo || typeof sourceInfo !== "object" || Array.isArray(sourceInfo) || sourceInfo instanceof Date || Buffer.isBuffer(sourceInfo)) {
|
|
3996
4115
|
throw new Error(`${module2.name} Info.plist must contain a dictionary`);
|
|
3997
4116
|
}
|
|
@@ -4009,34 +4128,17 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
4009
4128
|
};
|
|
4010
4129
|
}
|
|
4011
4130
|
const localPackageDirs = [
|
|
4012
|
-
...listed.filter((reference) =>
|
|
4131
|
+
...listed.filter((reference) => import_node_fs9.default.existsSync(import_node_path11.default.join(reference, "Package.swift"))),
|
|
4013
4132
|
...projects2.flatMap(
|
|
4014
4133
|
(project) => Object.entries(project.objects).flatMap(([id, entry]) => {
|
|
4015
4134
|
if (!isDict(entry)) return [];
|
|
4016
|
-
const candidate = entry.isa === "XCLocalSwiftPackageReference" ?
|
|
4017
|
-
return candidate &&
|
|
4135
|
+
const candidate = entry.isa === "XCLocalSwiftPackageReference" ? import_node_path11.default.resolve(project.projectDir, str(entry.relativePath) ?? "") : entry.isa === "PBXFileReference" ? project.resolvePath(id) : null;
|
|
4136
|
+
return candidate && import_node_fs9.default.existsSync(import_node_path11.default.join(candidate, "Package.swift")) ? [candidate] : [];
|
|
4018
4137
|
})
|
|
4019
4138
|
)
|
|
4020
4139
|
];
|
|
4021
|
-
const
|
|
4022
|
-
const
|
|
4023
|
-
const cached = graphs.get(dir);
|
|
4024
|
-
if (cached) return cached;
|
|
4025
|
-
const graph = swiftManifestGraph(
|
|
4026
|
-
import_node_fs8.default.readFileSync(import_node_path10.default.join(dir, "Package.swift"), "utf8")
|
|
4027
|
-
);
|
|
4028
|
-
graphs.set(dir, graph);
|
|
4029
|
-
return graph;
|
|
4030
|
-
};
|
|
4031
|
-
const localProducts = /* @__PURE__ */ new Map();
|
|
4032
|
-
for (const dir of localPackageDirs) {
|
|
4033
|
-
for (const product of graphOf(dir).products.keys()) {
|
|
4034
|
-
if (!localProducts.has(product)) localProducts.set(product, dir);
|
|
4035
|
-
}
|
|
4036
|
-
}
|
|
4037
|
-
const localPackages = /* @__PURE__ */ new Set();
|
|
4038
|
-
const remoteProducts = [];
|
|
4039
|
-
const unresolvedProducts = [];
|
|
4140
|
+
const linkedProducts = [];
|
|
4141
|
+
const binaryFrameworks = /* @__PURE__ */ new Set();
|
|
4040
4142
|
for (const { project, target } of order) {
|
|
4041
4143
|
const productDependencies = [
|
|
4042
4144
|
...list(target.packageProductDependencies),
|
|
@@ -4048,45 +4150,37 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
4048
4150
|
for (const dependencyId of productDependencies) {
|
|
4049
4151
|
const dependency = project.object(dependencyId);
|
|
4050
4152
|
const product = str(dependency?.productName)?.replace(/^plugin:/, "");
|
|
4051
|
-
if (!dependency || !product)
|
|
4153
|
+
if (!dependency || !product || linkedProducts.some((entry) => entry.product === product))
|
|
4154
|
+
continue;
|
|
4052
4155
|
const reference = project.object(str(dependency.package));
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
} else if (localProducts.has(product)) {
|
|
4064
|
-
localPackages.add(localProducts.get(product));
|
|
4065
|
-
} else if (!unresolvedProducts.includes(product)) unresolvedProducts.push(product);
|
|
4156
|
+
linkedProducts.push({
|
|
4157
|
+
product,
|
|
4158
|
+
source: reference?.isa === "XCRemoteSwiftPackageReference" ? { kind: "remote", url: str(reference.repositoryURL) ?? "" } : reference?.isa === "XCLocalSwiftPackageReference" ? {
|
|
4159
|
+
kind: "local",
|
|
4160
|
+
dir: import_node_path11.default.resolve(
|
|
4161
|
+
project.projectDir,
|
|
4162
|
+
str(reference.relativePath) ?? ""
|
|
4163
|
+
)
|
|
4164
|
+
} : { kind: "unnamed" }
|
|
4165
|
+
});
|
|
4066
4166
|
}
|
|
4067
|
-
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
continue;
|
|
4076
|
-
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
for (const dependencies of graph.dependencies.values()) {
|
|
4080
|
-
for (const dependency of dependencies) {
|
|
4081
|
-
if (dependency.kind !== "product") continue;
|
|
4082
|
-
const url = graph.packageURLs.get(dependency.package);
|
|
4083
|
-
if (url && !remoteProducts.some((entry) => entry.product === dependency.name))
|
|
4084
|
-
remoteProducts.push({ product: dependency.name, repositoryURL: url });
|
|
4167
|
+
for (const phaseId of list(target.buildPhases)) {
|
|
4168
|
+
const phase = project.object(phaseId);
|
|
4169
|
+
if (phase?.isa !== "PBXFrameworksBuildPhase") continue;
|
|
4170
|
+
for (const buildFileId of list(phase.files)) {
|
|
4171
|
+
const fileId = str(project.object(buildFileId)?.fileRef);
|
|
4172
|
+
const file = project.object(fileId);
|
|
4173
|
+
const tree = str(file?.sourceTree);
|
|
4174
|
+
const name = /([^/]+)\.(xc)?framework$/.exec(str(file?.path) ?? "")?.[1];
|
|
4175
|
+
if (file?.isa !== "PBXFileReference" || !name) continue;
|
|
4176
|
+
if (tree === "BUILT_PRODUCTS_DIR" || tree === "SDKROOT" || tree === "DEVELOPER_DIR")
|
|
4177
|
+
continue;
|
|
4178
|
+
binaryFrameworks.add(name);
|
|
4085
4179
|
}
|
|
4086
4180
|
}
|
|
4087
4181
|
}
|
|
4088
|
-
const resolvedFile =
|
|
4089
|
-
workspace ??
|
|
4182
|
+
const resolvedFile = import_node_path11.default.join(
|
|
4183
|
+
workspace ?? import_node_path11.default.join(xcodeprojOrWorkspace, "project.xcworkspace"),
|
|
4090
4184
|
"xcshareddata",
|
|
4091
4185
|
"swiftpm",
|
|
4092
4186
|
"Package.resolved"
|
|
@@ -4096,19 +4190,24 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
4096
4190
|
...module2,
|
|
4097
4191
|
rootDir: commonAncestor(
|
|
4098
4192
|
[
|
|
4099
|
-
workspace ?
|
|
4193
|
+
workspace ? import_node_path11.default.dirname(workspace) : app.project.projectDir,
|
|
4100
4194
|
...used.map((project) => project.projectDir),
|
|
4101
|
-
...
|
|
4102
|
-
|
|
4195
|
+
...localPackageDirs,
|
|
4196
|
+
...linkedProducts.flatMap(
|
|
4197
|
+
({ source }) => source.kind === "local" && import_node_fs9.default.existsSync(source.dir) ? [source.dir] : []
|
|
4198
|
+
)
|
|
4199
|
+
].map((dir) => import_node_fs9.default.realpathSync(dir))
|
|
4103
4200
|
),
|
|
4104
4201
|
projectFiles: [...new Set(used.map((project) => project.projectFile))].sort(),
|
|
4105
4202
|
infoPlist: import_plist.default.build(info),
|
|
4106
4203
|
infoPlistFile,
|
|
4107
4204
|
frameworks,
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4205
|
+
linkedProducts,
|
|
4206
|
+
localPackageDirs: [
|
|
4207
|
+
...new Set(localPackageDirs.map((dir) => import_node_fs9.default.realpathSync(dir)))
|
|
4208
|
+
].sort(),
|
|
4209
|
+
binaryFrameworks: [...binaryFrameworks].sort(),
|
|
4210
|
+
packageResolved: import_node_fs9.default.existsSync(resolvedFile) ? resolvedFile : null,
|
|
4112
4211
|
appTargets: appTargetNames
|
|
4113
4212
|
};
|
|
4114
4213
|
}
|
|
@@ -4128,17 +4227,17 @@ var SKIP_SOURCE_DIRS = /* @__PURE__ */ new Set([
|
|
|
4128
4227
|
var NATIVE_DESCRIPTOR = ".one-native-source.json";
|
|
4129
4228
|
var NATIVE_GLUE = ".one-native-source.swift.txt";
|
|
4130
4229
|
function swiftPackageId(packagePath) {
|
|
4131
|
-
return
|
|
4230
|
+
return import_node_path12.default.basename(packagePath).replace(/[^A-Za-z0-9_]/g, "_").replace(/^(\d)/, "_$1");
|
|
4132
4231
|
}
|
|
4133
4232
|
function nativeSourceDescriptor(packagePath) {
|
|
4134
|
-
packagePath =
|
|
4135
|
-
const file =
|
|
4136
|
-
if (!
|
|
4233
|
+
packagePath = import_node_fs10.default.realpathSync(packagePath);
|
|
4234
|
+
const file = import_node_path12.default.join(packagePath, NATIVE_DESCRIPTOR);
|
|
4235
|
+
if (!import_node_fs10.default.existsSync(file)) return null;
|
|
4137
4236
|
const value = JSON.parse(
|
|
4138
4237
|
readPackageFile(packagePath, file, MAX_SWIFT_COMPILE_SOURCE_BYTES).toString("utf8")
|
|
4139
4238
|
);
|
|
4140
4239
|
const invalid = () => new Error(`${file}: invalid One native source descriptor; run one typegen`);
|
|
4141
|
-
if (!value || typeof value !== "object" || Reflect.get(value, "generatedBy") !== "one typegen" || !
|
|
4240
|
+
if (!value || typeof value !== "object" || Reflect.get(value, "generatedBy") !== "one typegen" || !import_node_fs10.default.existsSync(import_node_path12.default.join(packagePath, NATIVE_GLUE))) {
|
|
4142
4241
|
throw invalid();
|
|
4143
4242
|
}
|
|
4144
4243
|
if (!isSwiftNativeModules(value) || value.packageId !== swiftPackageId(packagePath)) {
|
|
@@ -4147,12 +4246,12 @@ function nativeSourceDescriptor(packagePath) {
|
|
|
4147
4246
|
return value;
|
|
4148
4247
|
}
|
|
4149
4248
|
function nativeSourceFiles(packagePath) {
|
|
4150
|
-
packagePath =
|
|
4151
|
-
return [NATIVE_DESCRIPTOR, NATIVE_GLUE].map((name) =>
|
|
4249
|
+
packagePath = import_node_fs10.default.realpathSync(packagePath);
|
|
4250
|
+
return [NATIVE_DESCRIPTOR, NATIVE_GLUE].map((name) => import_node_path12.default.join(packagePath, name)).filter((file) => import_node_fs10.default.existsSync(file));
|
|
4152
4251
|
}
|
|
4153
4252
|
var projects = /* @__PURE__ */ new Map();
|
|
4154
4253
|
function projectFor(packagePath, hosted) {
|
|
4155
|
-
packagePath =
|
|
4254
|
+
packagePath = import_node_fs10.default.realpathSync(packagePath);
|
|
4156
4255
|
const existing = projects.get(packagePath);
|
|
4157
4256
|
if (existing) {
|
|
4158
4257
|
if (hosted && !existing.hosted) {
|
|
@@ -4173,34 +4272,39 @@ function projectFor(packagePath, hosted) {
|
|
|
4173
4272
|
return created;
|
|
4174
4273
|
}
|
|
4175
4274
|
var xcodeProjects = /* @__PURE__ */ new Map();
|
|
4176
|
-
function
|
|
4177
|
-
|
|
4275
|
+
function swiftPackages(entry, app) {
|
|
4276
|
+
const stamp = (file) => file && import_node_fs10.default.existsSync(file) ? import_node_fs10.default.statSync(file).mtimeMs : 0;
|
|
4178
4277
|
const key = JSON.stringify([
|
|
4179
|
-
app.
|
|
4278
|
+
app.linkedProducts,
|
|
4180
4279
|
app.packageResolved,
|
|
4181
|
-
|
|
4280
|
+
stamp(app.packageResolved),
|
|
4281
|
+
app.localPackageDirs.map((dir) => stamp(import_node_path12.default.join(dir, "Package.swift"))),
|
|
4282
|
+
app.linkedProducts.map(
|
|
4283
|
+
({ source }) => source.kind === "local" ? stamp(import_node_path12.default.join(source.dir, "Package.swift")) : 0
|
|
4284
|
+
)
|
|
4182
4285
|
]);
|
|
4183
|
-
if (entry.
|
|
4184
|
-
entry.
|
|
4286
|
+
if (entry.packages?.key !== key) {
|
|
4287
|
+
entry.packages = {
|
|
4185
4288
|
key,
|
|
4186
|
-
packages:
|
|
4187
|
-
app.rootDir,
|
|
4188
|
-
app.packageResolved,
|
|
4189
|
-
app.
|
|
4190
|
-
|
|
4191
|
-
|
|
4289
|
+
packages: resolveSwiftPackages({
|
|
4290
|
+
rootDir: app.rootDir,
|
|
4291
|
+
resolved: app.packageResolved,
|
|
4292
|
+
products: app.linkedProducts,
|
|
4293
|
+
localDirs: app.localPackageDirs,
|
|
4294
|
+
provided: entry.provided
|
|
4295
|
+
})
|
|
4192
4296
|
};
|
|
4193
4297
|
}
|
|
4194
|
-
return entry.
|
|
4298
|
+
return entry.packages.packages;
|
|
4195
4299
|
}
|
|
4196
4300
|
var XCODE_APP_DIR = "__app__";
|
|
4197
4301
|
var XCODE_FRAMEWORKS_DIR = "__frameworks__";
|
|
4198
4302
|
var XCODE_PACKAGES_DIR = "__packages__";
|
|
4199
|
-
var CHECKOUTS_PREFIX = `${REMOTE_CHECKOUTS.split(
|
|
4303
|
+
var CHECKOUTS_PREFIX = `${REMOTE_CHECKOUTS.split(import_node_path12.default.sep).join(import_node_path12.default.posix.sep)}/`;
|
|
4200
4304
|
function xcodeInputKey(layout, file, relative) {
|
|
4201
4305
|
const owner = layout.targetDirs.get(file);
|
|
4202
|
-
if (owner) return
|
|
4203
|
-
return relative.startsWith(CHECKOUTS_PREFIX) ?
|
|
4306
|
+
if (owner) return import_node_path12.default.posix.join(owner, relative);
|
|
4307
|
+
return relative.startsWith(CHECKOUTS_PREFIX) ? import_node_path12.default.posix.join(XCODE_PACKAGES_DIR, relative.slice(CHECKOUTS_PREFIX.length)) : relative;
|
|
4204
4308
|
}
|
|
4205
4309
|
function xcodeLayout(root) {
|
|
4206
4310
|
const registered = xcodeProjects.get(root);
|
|
@@ -4211,7 +4315,7 @@ function xcodeLayout(root) {
|
|
|
4211
4315
|
const targetDirs = new Map(app.sources.map((file) => [file, XCODE_APP_DIR]));
|
|
4212
4316
|
const targets = [];
|
|
4213
4317
|
for (const framework of app.frameworks) {
|
|
4214
|
-
const dir =
|
|
4318
|
+
const dir = import_node_path12.default.posix.join(XCODE_FRAMEWORKS_DIR, framework.moduleName);
|
|
4215
4319
|
for (const file of framework.sources) {
|
|
4216
4320
|
if (targetDirs.has(file)) continue;
|
|
4217
4321
|
targetDirs.set(file, dir);
|
|
@@ -4222,44 +4326,35 @@ function xcodeLayout(root) {
|
|
|
4222
4326
|
path: dir,
|
|
4223
4327
|
executable: false,
|
|
4224
4328
|
resources: false,
|
|
4329
|
+
exclude: [],
|
|
4225
4330
|
languageMode: framework.languageMode,
|
|
4226
4331
|
mainActorIsolation: framework.mainActorIsolation
|
|
4227
4332
|
});
|
|
4228
4333
|
}
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
4232
|
-
|
|
4233
|
-
|
|
4234
|
-
const declared = swiftManifestTargets(manifest).filter((target) => !target.executable);
|
|
4235
|
-
const all = declared.flatMap(
|
|
4236
|
-
(target) => sourceTreeFiles(import_node_path11.default.join(dir, target.path), root).map(
|
|
4237
|
-
(file) => import_node_path11.default.relative(dir, file).split(import_node_path11.default.sep).join(import_node_path11.default.posix.sep)
|
|
4238
|
-
)
|
|
4334
|
+
const packages = swiftPackages(registered, app);
|
|
4335
|
+
for (const target of packages.targets) {
|
|
4336
|
+
const relative = import_node_path12.default.relative(
|
|
4337
|
+
target.remote ? import_node_path12.default.join(root, REMOTE_CHECKOUTS) : root,
|
|
4338
|
+
target.dir
|
|
4239
4339
|
);
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
for (const relative of all) {
|
|
4244
|
-
if (relative.startsWith(`${target.path}/`)) files.add(import_node_path11.default.join(dir, relative));
|
|
4245
|
-
}
|
|
4246
|
-
}
|
|
4247
|
-
}
|
|
4248
|
-
const remote = remotePackages(registered, app);
|
|
4249
|
-
for (const target of remote.targets) {
|
|
4340
|
+
if (relative === ".." || relative.startsWith(`..${import_node_path12.default.sep}`) || import_node_path12.default.isAbsolute(relative))
|
|
4341
|
+
throw new Error(`swift input escapes the selected package: ${target.dir}`);
|
|
4342
|
+
const posix = relative.split(import_node_path12.default.sep).join(import_node_path12.default.posix.sep);
|
|
4250
4343
|
targets.push({
|
|
4251
4344
|
...target,
|
|
4252
|
-
path:
|
|
4253
|
-
|
|
4254
|
-
import_node_path11.default.relative(import_node_path11.default.join(root, REMOTE_CHECKOUTS), target.dir).split(import_node_path11.default.sep).join(import_node_path11.default.posix.sep)
|
|
4255
|
-
)
|
|
4345
|
+
path: target.remote ? import_node_path12.default.posix.join(XCODE_PACKAGES_DIR, posix) : posix,
|
|
4346
|
+
exclude: []
|
|
4256
4347
|
});
|
|
4348
|
+
if (!target.remote) files.add(import_node_path12.default.join(target.packageDir, "Package.swift"));
|
|
4257
4349
|
for (const file of target.files) files.add(file);
|
|
4258
4350
|
}
|
|
4351
|
+
for (const target of targets) {
|
|
4352
|
+
target.exclude = targets.filter((other) => other.path.startsWith(`${target.path}/`)).map((other) => other.path.slice(target.path.length + 1));
|
|
4353
|
+
}
|
|
4259
4354
|
return {
|
|
4260
4355
|
app,
|
|
4261
4356
|
targets,
|
|
4262
|
-
|
|
4357
|
+
packages,
|
|
4263
4358
|
targetDirs,
|
|
4264
4359
|
files: [...files].sort()
|
|
4265
4360
|
};
|
|
@@ -4272,32 +4367,32 @@ function xcodeManifest(layout) {
|
|
|
4272
4367
|
'let package = Package(name: "app", targets: [',
|
|
4273
4368
|
` .executableTarget(name: "${layout.app.moduleName}", path: "${XCODE_APP_DIR}", ${settings(layout.app.languageMode, layout.app.mainActorIsolation)}),`,
|
|
4274
4369
|
...layout.targets.map(
|
|
4275
|
-
(target) => ` .target(name: "${target.name}", path: "${target.path}", ${target.resources ? "resources: [], " : ""}${settings(target.languageMode, target.mainActorIsolation)}),`
|
|
4370
|
+
(target) => ` .target(name: "${target.name}", path: "${target.path}", ${target.exclude.length > 0 ? `exclude: ${JSON.stringify(target.exclude)}, ` : ""}${target.resources ? "resources: [], " : ""}${settings(target.languageMode, target.mainActorIsolation)}),`
|
|
4276
4371
|
),
|
|
4277
4372
|
"])",
|
|
4278
4373
|
""
|
|
4279
4374
|
].join("\n");
|
|
4280
4375
|
}
|
|
4281
4376
|
function packageFiles(root) {
|
|
4282
|
-
const canonicalRoot =
|
|
4377
|
+
const canonicalRoot = import_node_fs10.default.realpathSync(root);
|
|
4283
4378
|
const xcode = xcodeLayout(canonicalRoot);
|
|
4284
4379
|
return xcode ? xcode.files : sourceTreeFiles(canonicalRoot, canonicalRoot);
|
|
4285
4380
|
}
|
|
4286
4381
|
function sourceTreeFiles(dir, canonicalRoot) {
|
|
4287
4382
|
const found = [];
|
|
4288
4383
|
const walk2 = (dir2) => {
|
|
4289
|
-
for (const entry of
|
|
4384
|
+
for (const entry of import_node_fs10.default.readdirSync(dir2, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
|
|
4290
4385
|
if (entry.name.startsWith(".") && entry.name !== NATIVE_DESCRIPTOR && entry.name !== NATIVE_GLUE || SKIP_SOURCE_DIRS.has(entry.name))
|
|
4291
4386
|
continue;
|
|
4292
|
-
const full =
|
|
4387
|
+
const full = import_node_path12.default.join(dir2, entry.name);
|
|
4293
4388
|
if (entry.isSymbolicLink()) throw new Error(`swift input is a symlink: ${full}`);
|
|
4294
|
-
const real =
|
|
4295
|
-
const relative =
|
|
4296
|
-
if (relative.startsWith(`..${
|
|
4389
|
+
const real = import_node_fs10.default.realpathSync(full);
|
|
4390
|
+
const relative = import_node_path12.default.relative(canonicalRoot, real);
|
|
4391
|
+
if (relative.startsWith(`..${import_node_path12.default.sep}`) || relative === ".." || import_node_path12.default.isAbsolute(relative)) {
|
|
4297
4392
|
throw new Error(`swift input escapes the selected package: ${full}`);
|
|
4298
4393
|
}
|
|
4299
4394
|
if (entry.isDirectory()) {
|
|
4300
|
-
if (
|
|
4395
|
+
if (import_node_fs10.default.existsSync(import_node_path12.default.join(full, "Package.swift"))) continue;
|
|
4301
4396
|
walk2(full);
|
|
4302
4397
|
} else if (entry.isFile()) {
|
|
4303
4398
|
found.push(full);
|
|
@@ -4305,29 +4400,29 @@ function sourceTreeFiles(dir, canonicalRoot) {
|
|
|
4305
4400
|
}
|
|
4306
4401
|
}
|
|
4307
4402
|
};
|
|
4308
|
-
if (
|
|
4403
|
+
if (import_node_fs10.default.existsSync(dir)) walk2(import_node_fs10.default.realpathSync(dir));
|
|
4309
4404
|
return found;
|
|
4310
4405
|
}
|
|
4311
4406
|
function readPackageFile(root, file, maxBytes) {
|
|
4312
|
-
const canonicalRoot =
|
|
4313
|
-
const relative =
|
|
4314
|
-
if (relative === ".." || relative.startsWith(`..${
|
|
4407
|
+
const canonicalRoot = import_node_fs10.default.realpathSync(root);
|
|
4408
|
+
const relative = import_node_path12.default.relative(canonicalRoot, import_node_fs10.default.realpathSync(file));
|
|
4409
|
+
if (relative === ".." || relative.startsWith(`..${import_node_path12.default.sep}`) || import_node_path12.default.isAbsolute(relative)) {
|
|
4315
4410
|
throw new Error(`swift input escapes the selected package: ${file}`);
|
|
4316
4411
|
}
|
|
4317
|
-
let ancestor =
|
|
4412
|
+
let ancestor = import_node_path12.default.resolve(file);
|
|
4318
4413
|
while (ancestor !== canonicalRoot) {
|
|
4319
|
-
if (
|
|
4414
|
+
if (import_node_fs10.default.lstatSync(ancestor).isSymbolicLink()) {
|
|
4320
4415
|
throw new Error(`swift input is a symlink: ${ancestor}`);
|
|
4321
4416
|
}
|
|
4322
|
-
const parent =
|
|
4417
|
+
const parent = import_node_path12.default.dirname(ancestor);
|
|
4323
4418
|
if (parent === ancestor)
|
|
4324
4419
|
throw new Error(`swift input escapes the selected package: ${file}`);
|
|
4325
4420
|
ancestor = parent;
|
|
4326
4421
|
}
|
|
4327
|
-
const expected =
|
|
4328
|
-
const fd =
|
|
4422
|
+
const expected = import_node_fs10.default.statSync(file);
|
|
4423
|
+
const fd = import_node_fs10.default.openSync(file, import_node_fs10.default.constants.O_RDONLY | import_node_fs10.default.constants.O_NOFOLLOW);
|
|
4329
4424
|
try {
|
|
4330
|
-
const stat =
|
|
4425
|
+
const stat = import_node_fs10.default.fstatSync(fd);
|
|
4331
4426
|
if (stat.dev !== expected.dev || stat.ino !== expected.ino) {
|
|
4332
4427
|
throw new Error(`swift input changed while opening: ${file}`);
|
|
4333
4428
|
}
|
|
@@ -4337,16 +4432,16 @@ function readPackageFile(root, file, maxBytes) {
|
|
|
4337
4432
|
const bytes = Buffer.alloc(stat.size + 1);
|
|
4338
4433
|
let offset = 0;
|
|
4339
4434
|
while (offset < bytes.length) {
|
|
4340
|
-
const count =
|
|
4435
|
+
const count = import_node_fs10.default.readSync(fd, bytes, offset, bytes.length - offset, null);
|
|
4341
4436
|
if (count === 0) break;
|
|
4342
4437
|
offset += count;
|
|
4343
4438
|
}
|
|
4344
|
-
if (offset !== stat.size ||
|
|
4439
|
+
if (offset !== stat.size || import_node_fs10.default.fstatSync(fd).size !== stat.size) {
|
|
4345
4440
|
throw new Error(`swift input changed while reading: ${file}`);
|
|
4346
4441
|
}
|
|
4347
4442
|
return bytes.subarray(0, offset);
|
|
4348
4443
|
} finally {
|
|
4349
|
-
|
|
4444
|
+
import_node_fs10.default.closeSync(fd);
|
|
4350
4445
|
}
|
|
4351
4446
|
}
|
|
4352
4447
|
function sourceFiles(root) {
|
|
@@ -4354,7 +4449,7 @@ function sourceFiles(root) {
|
|
|
4354
4449
|
}
|
|
4355
4450
|
function resourceCandidateFiles(root) {
|
|
4356
4451
|
return packageFiles(root).filter(
|
|
4357
|
-
(file) => !file.endsWith(".swift") && !["project.pbxproj", "project.xcproj"].includes(
|
|
4452
|
+
(file) => !file.endsWith(".swift") && !["project.pbxproj", "project.xcproj"].includes(import_node_path12.default.basename(file))
|
|
4358
4453
|
);
|
|
4359
4454
|
}
|
|
4360
4455
|
var HOSTED_LIMITS = {
|
|
@@ -4388,7 +4483,7 @@ function buildSwiftResourceTable(project, baseUrl) {
|
|
|
4388
4483
|
const limits = inputLimits(Boolean(project.hosted));
|
|
4389
4484
|
const absolute = resourceCandidateFiles(project.packagePath);
|
|
4390
4485
|
const relative = absolute.map(
|
|
4391
|
-
(file) =>
|
|
4486
|
+
(file) => import_node_path12.default.relative(project.packagePath, file).split(import_node_path12.default.sep).join(import_node_path12.default.posix.sep)
|
|
4392
4487
|
);
|
|
4393
4488
|
const byRelative = new Map(absolute.map((file, index) => [relative[index], file]));
|
|
4394
4489
|
const readContents = (candidate) => {
|
|
@@ -4410,16 +4505,16 @@ function buildSwiftResourceTable(project, baseUrl) {
|
|
|
4410
4505
|
for (const { name, file, scale } of found) {
|
|
4411
4506
|
const disk = byRelative.get(file);
|
|
4412
4507
|
if (!disk) continue;
|
|
4413
|
-
if (Object.keys(images).length >= limits.images || imageBytes +
|
|
4508
|
+
if (Object.keys(images).length >= limits.images || imageBytes + import_node_fs10.default.statSync(disk).size > limits.imageTotalBytes) {
|
|
4414
4509
|
throw new Error("swift image pack exceeds the compile service caps");
|
|
4415
4510
|
}
|
|
4416
4511
|
const bytes = readPackageFile(project.packagePath, disk, limits.imageBytes);
|
|
4417
4512
|
imageBytes += bytes.length;
|
|
4418
|
-
const hash = (0,
|
|
4419
|
-
const ext =
|
|
4513
|
+
const hash = (0, import_node_crypto5.createHash)("sha256").update(bytes).digest("hex").slice(0, 16);
|
|
4514
|
+
const ext = import_node_path12.default.posix.extname(file).toLowerCase();
|
|
4420
4515
|
table[name] = { uri: `${baseUrl}${RESOURCE_PATH}${hash}${ext}`, scale };
|
|
4421
4516
|
images[name] = {
|
|
4422
|
-
file:
|
|
4517
|
+
file: import_node_path12.default.posix.basename(file),
|
|
4423
4518
|
data: bytes.toString("base64")
|
|
4424
4519
|
};
|
|
4425
4520
|
watched.push(file);
|
|
@@ -4443,10 +4538,10 @@ function buildSwiftResourceTable(project, baseUrl) {
|
|
|
4443
4538
|
return { table, images, colors, symbols, watched };
|
|
4444
4539
|
}
|
|
4445
4540
|
function buildSwiftBundleFiles(packagePath, hosted) {
|
|
4446
|
-
packagePath =
|
|
4541
|
+
packagePath = import_node_fs10.default.realpathSync(packagePath);
|
|
4447
4542
|
const limits = inputLimits(hosted);
|
|
4448
4543
|
const relative = resourceCandidateFiles(packagePath).map(
|
|
4449
|
-
(file) =>
|
|
4544
|
+
(file) => import_node_path12.default.relative(packagePath, file).split(import_node_path12.default.sep).join(import_node_path12.default.posix.sep)
|
|
4450
4545
|
);
|
|
4451
4546
|
const files = {};
|
|
4452
4547
|
const watched = [];
|
|
@@ -4460,13 +4555,13 @@ function buildSwiftBundleFiles(packagePath, hosted) {
|
|
|
4460
4555
|
total += bytes.length;
|
|
4461
4556
|
if (xcode.app.infoPlistFile)
|
|
4462
4557
|
watched.push(
|
|
4463
|
-
|
|
4558
|
+
import_node_path12.default.relative(packagePath, xcode.app.infoPlistFile).split(import_node_path12.default.sep).join("/")
|
|
4464
4559
|
);
|
|
4465
4560
|
}
|
|
4466
4561
|
for (const { base, file } of enumerateBundleJson(relative)) {
|
|
4467
4562
|
watched.push(file);
|
|
4468
|
-
const disk =
|
|
4469
|
-
if (Object.keys(files).length >= limits.resources || total +
|
|
4563
|
+
const disk = import_node_path12.default.join(packagePath, ...file.split("/"));
|
|
4564
|
+
if (Object.keys(files).length >= limits.resources || total + import_node_fs10.default.statSync(disk).size > limits.resourceTotalBytes) {
|
|
4470
4565
|
throw new Error(
|
|
4471
4566
|
`swift bundle pack exceeds ${limits.resources} files / ${limits.resourceTotalBytes} bytes`
|
|
4472
4567
|
);
|
|
@@ -4481,12 +4576,12 @@ function serveSwiftResource(project, key) {
|
|
|
4481
4576
|
return project.resourceFiles.get(key) ?? project.resourcesPrevious.get(key) ?? null;
|
|
4482
4577
|
}
|
|
4483
4578
|
function linkedModuleRoots(packagePath) {
|
|
4484
|
-
packagePath =
|
|
4579
|
+
packagePath = import_node_fs10.default.realpathSync(packagePath);
|
|
4485
4580
|
let manifest;
|
|
4486
4581
|
try {
|
|
4487
4582
|
manifest = readPackageFile(
|
|
4488
4583
|
packagePath,
|
|
4489
|
-
|
|
4584
|
+
import_node_path12.default.join(packagePath, "Package.swift"),
|
|
4490
4585
|
MAX_SWIFT_COMPILE_SOURCE_BYTES
|
|
4491
4586
|
).toString("utf8");
|
|
4492
4587
|
} catch {
|
|
@@ -4495,35 +4590,35 @@ function linkedModuleRoots(packagePath) {
|
|
|
4495
4590
|
const roots = /* @__PURE__ */ new Set();
|
|
4496
4591
|
const dependency = /\.package\(\s*path:\s*"([^"]+)"\s*\)/g;
|
|
4497
4592
|
for (const match of manifest.replace(/^\s*\/\/.*$/gm, "").matchAll(dependency)) {
|
|
4498
|
-
const root =
|
|
4499
|
-
if (
|
|
4593
|
+
const root = import_node_path12.default.resolve(packagePath, match[1]);
|
|
4594
|
+
if (import_node_fs10.default.existsSync(import_node_path12.default.join(root, "Package.swift"))) roots.add(root);
|
|
4500
4595
|
}
|
|
4501
4596
|
return [...roots].sort();
|
|
4502
4597
|
}
|
|
4503
4598
|
function sourceStamp(packagePath, moduleRootOverride, hosted = false) {
|
|
4504
|
-
const hash = (0,
|
|
4599
|
+
const hash = (0, import_node_crypto5.createHash)("sha256");
|
|
4505
4600
|
hash.update(packagePath);
|
|
4506
4601
|
const projectInputs = new Set(packageFiles(packagePath));
|
|
4507
4602
|
for (const file of [...projectInputs].sort()) {
|
|
4508
|
-
hash.update(
|
|
4509
|
-
const stat =
|
|
4603
|
+
hash.update(import_node_path12.default.relative(packagePath, file));
|
|
4604
|
+
const stat = import_node_fs10.default.statSync(file);
|
|
4510
4605
|
hash.update(`${stat.mtimeMs}/${stat.ctimeMs}/${stat.size}`);
|
|
4511
4606
|
}
|
|
4512
4607
|
const moduleRoot = hosted ? void 0 : moduleRootOverride ?? linkedModuleRoots(packagePath).find(
|
|
4513
|
-
(root) =>
|
|
4608
|
+
(root) => import_node_fs10.default.existsSync(import_node_path12.default.join(root, "toolchain.json"))
|
|
4514
4609
|
);
|
|
4515
4610
|
if (moduleRoot) {
|
|
4516
4611
|
hash.update(moduleRoot);
|
|
4517
4612
|
for (const relative of swiftModuleInputFiles(moduleRoot)) {
|
|
4518
4613
|
hash.update(relative);
|
|
4519
|
-
hash.update(String(
|
|
4614
|
+
hash.update(String(import_node_fs10.default.statSync(import_node_path12.default.join(moduleRoot, relative)).mtimeMs));
|
|
4520
4615
|
}
|
|
4521
4616
|
}
|
|
4522
4617
|
return hash.digest("hex").slice(0, 16);
|
|
4523
4618
|
}
|
|
4524
4619
|
function entryRootId(packagePath, file) {
|
|
4525
|
-
const relative =
|
|
4526
|
-
return `${
|
|
4620
|
+
const relative = import_node_path12.default.relative(packagePath, file).split(import_node_path12.default.sep).join(import_node_path12.default.posix.sep);
|
|
4621
|
+
return `${import_node_path12.default.basename(packagePath)}${import_node_path12.default.posix.sep}${relative}`;
|
|
4527
4622
|
}
|
|
4528
4623
|
function icuUrl(origin, artifact) {
|
|
4529
4624
|
return "url" in artifact.icu ? artifact.icu.url : `${origin}${ICU_PATH}${artifact.icu.sha256}`;
|
|
@@ -4532,8 +4627,8 @@ function packageSources(packagePath) {
|
|
|
4532
4627
|
const xcode = xcodeLayout(packagePath);
|
|
4533
4628
|
const files = {};
|
|
4534
4629
|
for (const file of sourceFiles(packagePath)) {
|
|
4535
|
-
const relative =
|
|
4536
|
-
if (xcode &&
|
|
4630
|
+
const relative = import_node_path12.default.relative(packagePath, file).split(import_node_path12.default.sep).join(import_node_path12.default.posix.sep);
|
|
4631
|
+
if (xcode && import_node_path12.default.basename(file) === "Package.swift") continue;
|
|
4537
4632
|
files[xcode ? xcodeInputKey(xcode, file, relative) : relative] = readPackageFile(
|
|
4538
4633
|
packagePath,
|
|
4539
4634
|
file,
|
|
@@ -4550,7 +4645,7 @@ function packageSnapshot(project) {
|
|
|
4550
4645
|
files,
|
|
4551
4646
|
resourcePaths: swiftImplicitResourcePaths(
|
|
4552
4647
|
resourceCandidateFiles(project.packagePath).map(
|
|
4553
|
-
(file) =>
|
|
4648
|
+
(file) => import_node_path12.default.relative(project.packagePath, file).split(import_node_path12.default.sep).join(import_node_path12.default.posix.sep)
|
|
4554
4649
|
)
|
|
4555
4650
|
),
|
|
4556
4651
|
resources: buildSwiftResourceTable(project, ""),
|
|
@@ -4559,7 +4654,7 @@ function packageSnapshot(project) {
|
|
|
4559
4654
|
...native ? {
|
|
4560
4655
|
glue: readPackageFile(
|
|
4561
4656
|
project.packagePath,
|
|
4562
|
-
|
|
4657
|
+
import_node_path12.default.join(project.packagePath, NATIVE_GLUE),
|
|
4563
4658
|
MAX_SWIFT_COMPILE_SOURCE_BYTES
|
|
4564
4659
|
).toString("utf8")
|
|
4565
4660
|
} : {}
|
|
@@ -4598,7 +4693,7 @@ async function compile(packagePath, entry, stamp, moduleRootOverride, hosted, sn
|
|
|
4598
4693
|
package: content
|
|
4599
4694
|
};
|
|
4600
4695
|
const moduleRoot = moduleRootOverride ?? linkedModuleRoots(packagePath).find(
|
|
4601
|
-
(root) =>
|
|
4696
|
+
(root) => import_node_fs10.default.existsSync(import_node_path12.default.join(root, "toolchain.json"))
|
|
4602
4697
|
) ?? await swiftDistributionRoot();
|
|
4603
4698
|
if (!moduleRoot)
|
|
4604
4699
|
return {
|
|
@@ -4624,10 +4719,10 @@ async function compile(packagePath, entry, stamp, moduleRootOverride, hosted, sn
|
|
|
4624
4719
|
// server and a capture, or two checkouts) build each other's sources. so
|
|
4625
4720
|
// each app and module checkout gets its own root, which keeps the same
|
|
4626
4721
|
// app's incremental build across restarts.
|
|
4627
|
-
buildRoot: process.env.CONTRAST_SWIFT_BUILD_ROOT ??
|
|
4628
|
-
|
|
4722
|
+
buildRoot: process.env.CONTRAST_SWIFT_BUILD_ROOT ?? import_node_path12.default.join(
|
|
4723
|
+
import_node_os6.default.tmpdir(),
|
|
4629
4724
|
"contrast-swift-build",
|
|
4630
|
-
(0,
|
|
4725
|
+
(0, import_node_crypto5.createHash)("sha256").update(`${moduleRoot}\0${import_node_path12.default.resolve(packagePath)}`).digest("hex").slice(0, 16)
|
|
4631
4726
|
),
|
|
4632
4727
|
moduleRoot,
|
|
4633
4728
|
...toolchain
|
|
@@ -4692,19 +4787,19 @@ function swiftApiGapReport(output) {
|
|
|
4692
4787
|
}
|
|
4693
4788
|
function missingModulesMessage(packagePath, missing) {
|
|
4694
4789
|
const layout = xcodeLayout(packagePath);
|
|
4695
|
-
const
|
|
4696
|
-
(layout?.app.
|
|
4697
|
-
|
|
4698
|
-
|
|
4699
|
-
]
|
|
4700
|
-
|
|
4790
|
+
const gaps = new Map([
|
|
4791
|
+
...(layout?.app.binaryFrameworks ?? []).map(
|
|
4792
|
+
(name) => [name, { source: "the project", reason: "a vendored binary framework" }]
|
|
4793
|
+
),
|
|
4794
|
+
...layout?.packages.modules ?? [],
|
|
4795
|
+
...layout?.packages.unavailable ?? []
|
|
4796
|
+
]);
|
|
4701
4797
|
const width = Math.max(...[...missing.keys()].map((name) => name.length));
|
|
4702
4798
|
return [
|
|
4703
4799
|
`Peach does not provide ${missing.size} module${missing.size === 1 ? "" : "s"} this app imports:`,
|
|
4704
4800
|
...[...missing].map(([name, files]) => {
|
|
4705
|
-
const
|
|
4706
|
-
|
|
4707
|
-
return ` ${name.padEnd(width)} ${files.length} file${files.length === 1 ? "" : "s"}${source ? `, package ${source}` : ""}${reason ? ` (${reason})` : ""}`;
|
|
4801
|
+
const gap = gaps.get(name);
|
|
4802
|
+
return ` ${name.padEnd(width)} ${files.length} file${files.length === 1 ? "" : "s"}${gap ? `, ${gap.source.includes("://") ? `package ${gap.source}` : gap.source.startsWith("/") ? `package ${import_node_path12.default.relative(packagePath, gap.source) || "."}` : gap.source} (${gap.reason})` : ""}`;
|
|
4708
4803
|
})
|
|
4709
4804
|
].join("\n");
|
|
4710
4805
|
}
|
|
@@ -4712,7 +4807,7 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
|
|
|
4712
4807
|
const auth = hosted ? null : resolveCliAuth();
|
|
4713
4808
|
if (!hosted && (!auth || auth.kind === "github")) {
|
|
4714
4809
|
throw new Error(
|
|
4715
|
-
`compiling ${
|
|
4810
|
+
`compiling ${import_node_path12.default.basename(packagePath)} for Peach needs \`peach login\` or PEACH_API_KEY: this peachsim has no local SwiftUI module, so Contrast compiles it`
|
|
4716
4811
|
);
|
|
4717
4812
|
}
|
|
4718
4813
|
const origin = hosted?.origin ?? resolveContrastBackendOrigin(auth?.kind === "session" ? auth.origin : null);
|
|
@@ -4731,7 +4826,7 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
|
|
|
4731
4826
|
const bytes = sources.reduce((total2, text2) => total2 + Buffer.byteLength(text2), 0);
|
|
4732
4827
|
if (sources.length > MAX_SWIFT_COMPILE_FILES || bytes > MAX_SWIFT_COMPILE_SOURCE_BYTES) {
|
|
4733
4828
|
throw new Error(
|
|
4734
|
-
`${
|
|
4829
|
+
`${import_node_path12.default.basename(packagePath)} has ${sources.length} Swift files (${bytes} bytes), over Contrast's compile limits of ${MAX_SWIFT_COMPILE_FILES} files and ${MAX_SWIFT_COMPILE_SOURCE_BYTES} bytes; compile it on this machine with the Swift distribution instead`
|
|
4735
4830
|
);
|
|
4736
4831
|
}
|
|
4737
4832
|
const descriptor = snapshot.native;
|
|
@@ -4750,7 +4845,7 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
|
|
|
4750
4845
|
);
|
|
4751
4846
|
if (descriptor && address.native?.hash !== descriptor.hash) {
|
|
4752
4847
|
throw new Error(
|
|
4753
|
-
`${
|
|
4848
|
+
`${import_node_path12.default.basename(packagePath)}: Contrast compiled native contract ${address.native?.hash ?? "none"} but one typegen wrote ${descriptor.hash}; the app's One and the compile host's differ, or the compile host is older than this peachsim`
|
|
4754
4849
|
);
|
|
4755
4850
|
}
|
|
4756
4851
|
const response = await fetch(address.url, { signal });
|
|
@@ -4823,17 +4918,17 @@ function artifactFor(project, entry, moduleRoot) {
|
|
|
4823
4918
|
return fresh;
|
|
4824
4919
|
}
|
|
4825
4920
|
function swiftPackageWatchFiles(packagePath, moduleRoot) {
|
|
4826
|
-
packagePath =
|
|
4921
|
+
packagePath = import_node_fs10.default.realpathSync(packagePath);
|
|
4827
4922
|
return [
|
|
4828
|
-
...xcodeProjects.has(packagePath) ? [] : [
|
|
4923
|
+
...xcodeProjects.has(packagePath) ? [] : [import_node_path12.default.join(packagePath, "Package.swift")],
|
|
4829
4924
|
...sourceFiles(packagePath),
|
|
4830
4925
|
...nativeSourceFiles(packagePath),
|
|
4831
4926
|
...resourceCandidateFiles(packagePath),
|
|
4832
|
-
...moduleRoot ? swiftModuleInputFiles(moduleRoot).map((file) =>
|
|
4927
|
+
...moduleRoot ? swiftModuleInputFiles(moduleRoot).map((file) => import_node_path12.default.join(moduleRoot, file)) : []
|
|
4833
4928
|
];
|
|
4834
4929
|
}
|
|
4835
4930
|
async function swiftPackageMetadata(packagePath, packageName, moduleRoot, origin, hosted) {
|
|
4836
|
-
packagePath =
|
|
4931
|
+
packagePath = import_node_fs10.default.realpathSync(packagePath);
|
|
4837
4932
|
const mains = sourceFiles(packagePath).filter(
|
|
4838
4933
|
(file) => swiftApplicationEntry(
|
|
4839
4934
|
file,
|
|
@@ -4847,7 +4942,7 @@ async function swiftPackageMetadata(packagePath, packageName, moduleRoot, origin
|
|
|
4847
4942
|
);
|
|
4848
4943
|
}
|
|
4849
4944
|
const project = projectFor(packagePath, hosted);
|
|
4850
|
-
const entry = mains.length === 1 ?
|
|
4945
|
+
const entry = mains.length === 1 ? import_node_path12.default.relative(packagePath, mains[0]).split(import_node_path12.default.sep).join(import_node_path12.default.posix.sep) : Object.entries(native?.files ?? {}).find(
|
|
4851
4946
|
([_file, names]) => names.length > 0
|
|
4852
4947
|
)?.[0];
|
|
4853
4948
|
if (!entry) throw new Error(`swift package ${packageName} has no native module source`);
|
|
@@ -4936,12 +5031,12 @@ function artifactUrl(project, artifact) {
|
|
|
4936
5031
|
return `${serverOrigin()}${ARTIFACT_PATH2}${artifact.hash}.wasm`;
|
|
4937
5032
|
}
|
|
4938
5033
|
function packageFor(file) {
|
|
4939
|
-
let dir =
|
|
5034
|
+
let dir = import_node_path13.default.dirname(file);
|
|
4940
5035
|
const stop = devServer?.config.root;
|
|
4941
5036
|
for (; ; ) {
|
|
4942
|
-
if (
|
|
4943
|
-
if (stop !== void 0 && dir === stop ||
|
|
4944
|
-
dir =
|
|
5037
|
+
if (import_node_fs11.default.existsSync(import_node_path13.default.join(dir, "Package.swift"))) return dir;
|
|
5038
|
+
if (stop !== void 0 && dir === stop || import_node_path13.default.dirname(dir) === dir) break;
|
|
5039
|
+
dir = import_node_path13.default.dirname(dir);
|
|
4945
5040
|
}
|
|
4946
5041
|
throw new Error(
|
|
4947
5042
|
`no Package.swift above ${file}${stop === void 0 ? "" : ` (searched up to ${stop})`}; a .swift import needs a swiftpm package like the one in packages/sootsim-swift/example`
|
|
@@ -4962,9 +5057,9 @@ function swiftPlugin(options = {}) {
|
|
|
4962
5057
|
if (!resolved) throw new Error(`cannot resolve swift source ${source}`);
|
|
4963
5058
|
let id = resolved.id;
|
|
4964
5059
|
if (importer && (source.startsWith("./") || source.startsWith("../"))) {
|
|
4965
|
-
const raw2 =
|
|
5060
|
+
const raw2 = import_node_path13.default.resolve(import_node_path13.default.dirname(importer.split("?")[0] ?? importer), source);
|
|
4966
5061
|
try {
|
|
4967
|
-
if (
|
|
5062
|
+
if (import_node_fs11.default.realpathSync(raw2) === import_node_fs11.default.realpathSync(resolved.id)) id = raw2;
|
|
4968
5063
|
} catch {
|
|
4969
5064
|
}
|
|
4970
5065
|
}
|
|
@@ -4973,22 +5068,22 @@ function swiftPlugin(options = {}) {
|
|
|
4973
5068
|
async load(id) {
|
|
4974
5069
|
if (!id.startsWith(VIRTUAL_PREFIX)) return null;
|
|
4975
5070
|
const file = id.slice(VIRTUAL_PREFIX.length);
|
|
4976
|
-
if (!
|
|
5071
|
+
if (!import_node_fs11.default.existsSync(file)) throw new Error(`swift source ${file} no longer exists`);
|
|
4977
5072
|
const packagePath = options.packagePath ?? packageFor(file);
|
|
4978
5073
|
const project = projectFor(packagePath);
|
|
4979
|
-
const entry =
|
|
5074
|
+
const entry = import_node_path13.default.relative(packagePath, file).split(import_node_path13.default.sep).join(import_node_path13.default.posix.sep);
|
|
4980
5075
|
for (const source of [
|
|
4981
5076
|
...sourceFiles(packagePath),
|
|
4982
5077
|
...nativeSourceFiles(packagePath)
|
|
4983
5078
|
])
|
|
4984
5079
|
this.addWatchFile(source);
|
|
4985
|
-
this.addWatchFile(
|
|
5080
|
+
this.addWatchFile(import_node_path13.default.join(packagePath, "Package.swift"));
|
|
4986
5081
|
const moduleRoot = linkedModuleRoots(packagePath).find(
|
|
4987
|
-
(root) =>
|
|
5082
|
+
(root) => import_node_fs11.default.existsSync(import_node_path13.default.join(root, "toolchain.json"))
|
|
4988
5083
|
);
|
|
4989
5084
|
if (moduleRoot)
|
|
4990
5085
|
for (const relative of swiftModuleInputFiles(moduleRoot))
|
|
4991
|
-
this.addWatchFile(
|
|
5086
|
+
this.addWatchFile(import_node_path13.default.join(moduleRoot, relative));
|
|
4992
5087
|
let artifact;
|
|
4993
5088
|
try {
|
|
4994
5089
|
artifact = await artifactFor(project, entry);
|
|
@@ -5007,7 +5102,7 @@ function swiftPlugin(options = {}) {
|
|
|
5007
5102
|
...artifact.package.resources.watched,
|
|
5008
5103
|
...artifact.package.bundleFiles.watched
|
|
5009
5104
|
])
|
|
5010
|
-
this.addWatchFile(
|
|
5105
|
+
this.addWatchFile(import_node_path13.default.join(packagePath, ...watched.split(import_node_path13.default.posix.sep)));
|
|
5011
5106
|
const colors = artifact.package.resources.colors;
|
|
5012
5107
|
const symbols = artifact.package.resources.symbols;
|
|
5013
5108
|
const bundleFiles = artifact.package.bundleFiles.files;
|