peachsim 0.1.769 → 0.1.771
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/main.ts +5 -1
- package/cli/outbound-endpoints.ts +14 -0
- 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 +563 -439
- 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 +1 -1
- 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 +1 -1
- 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 +832 -701
- package/dist-lib/swift-compile.cjs +18 -4
- package/dist-lib/swift-compile.mjs +17 -4
- package/dist-lib/swift-package.cjs +1 -1
- package/dist-lib/swift-package.mjs +1 -1
- package/dist-lib/swift-submit.cjs +1 -1
- package/dist-lib/swift-submit.mjs +1 -1
- package/dist-lib/swift-toolchain.cjs +1 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +396 -272
- package/dist-lib/vite.cjs +1 -1
- package/package.json +1 -1
- package/src/swift-binary-modules.ts +116 -0
- package/src/swift-compile.ts +28 -3
- package/src/swift-host.ts +28 -4
- package/src/swift-package-manifest.ts +3 -0
- package/src/swift-packages.ts +32 -4
package/dist-lib/vite-swift.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.771 | (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_fs12 = __toESM(require("node:fs"), 1);
|
|
291
|
+
var import_node_path14 = __toESM(require("node:path"), 1);
|
|
292
292
|
|
|
293
293
|
// ../sootsim-swift/src/entryModule.ts
|
|
294
294
|
function nativeExportLines(args, commonjs) {
|
|
@@ -879,7 +879,7 @@ var ONE_IMPLICIT_FLAGS = ', "-Xfrontend", "-import-module", "-Xfrontend", "One"'
|
|
|
879
879
|
var MULTI_MANIFEST_VERSION = 11;
|
|
880
880
|
function swiftArtifactHash(input, release, moduleRoot) {
|
|
881
881
|
const hash = (0, import_node_crypto2.createHash)("sha256");
|
|
882
|
-
hash.update(`swift-compile/
|
|
882
|
+
hash.update(`swift-compile/v18
|
|
883
883
|
${release}
|
|
884
884
|
`);
|
|
885
885
|
if (input.oneModule) hash.update("one-module\n");
|
|
@@ -1227,14 +1227,14 @@ function liftExtensionOverrides(source, extraObjCExtensions) {
|
|
|
1227
1227
|
const args = forwardedArguments(source.slice(open + 1, close));
|
|
1228
1228
|
if (args === null) continue;
|
|
1229
1229
|
const call = (clause.includes("->") ? "return " : "") + (/\b(?:throws|rethrows)\b/.test(clause) ? "try " : "") + (/\basync\b/.test(clause) ? "await " : "") + `__peach_ext_${name}(${args})`;
|
|
1230
|
-
const
|
|
1230
|
+
const signature2 = `func ${name}${func[3] ?? ""}${source.slice(open, close + 1)}${clause ? ` ${clause}` : ""}`;
|
|
1231
1231
|
const nameAt = at + rest.indexOf(name, rest.indexOf("func", "override".length + func[1].length) + 4);
|
|
1232
1232
|
lifted.push({
|
|
1233
1233
|
type: top.name,
|
|
1234
1234
|
member: name,
|
|
1235
1235
|
at,
|
|
1236
1236
|
modifiers,
|
|
1237
|
-
decl:
|
|
1237
|
+
decl: signature2,
|
|
1238
1238
|
forward: `{ ${call} };`,
|
|
1239
1239
|
nameAt,
|
|
1240
1240
|
edits: [
|
|
@@ -1410,6 +1410,18 @@ function lowerAVAssetURLCluster(source) {
|
|
|
1410
1410
|
out = out.slice(0, at) + insert + out.slice(at + remove);
|
|
1411
1411
|
return out;
|
|
1412
1412
|
}
|
|
1413
|
+
function lowerNSValueTimeBox(source) {
|
|
1414
|
+
const masked = swiftCodeMask(source);
|
|
1415
|
+
const pattern = /\bNSValue\s*\(\s*time\s*:/g;
|
|
1416
|
+
const edits = [];
|
|
1417
|
+
let hit;
|
|
1418
|
+
while ((hit = pattern.exec(masked)) !== null)
|
|
1419
|
+
edits.push([hit.index, "NSValue".length, "NSValue.boxedTime"]);
|
|
1420
|
+
let out = source;
|
|
1421
|
+
for (const [at, remove, insert] of edits.sort((a, b) => b[0] - a[0]))
|
|
1422
|
+
out = out.slice(0, at) + insert + out.slice(at + remove);
|
|
1423
|
+
return out;
|
|
1424
|
+
}
|
|
1413
1425
|
function swiftCodeMask(source) {
|
|
1414
1426
|
const chars = source.split("");
|
|
1415
1427
|
const blank = (from, to) => {
|
|
@@ -1613,8 +1625,8 @@ function swiftSourceAsIOS(original, extraObjCExtensions) {
|
|
|
1613
1625
|
out += conditioned.slice(copied, at) + replacement;
|
|
1614
1626
|
copied = at + match[0].length;
|
|
1615
1627
|
}
|
|
1616
|
-
return
|
|
1617
|
-
lowerAnyObjectDoubleValue(out + conditioned.slice(copied))
|
|
1628
|
+
return lowerNSValueTimeBox(
|
|
1629
|
+
lowerAVAssetURLCluster(lowerAnyObjectDoubleValue(out + conditioned.slice(copied)))
|
|
1618
1630
|
);
|
|
1619
1631
|
}
|
|
1620
1632
|
function swiftApplicationEntry(file, source) {
|
|
@@ -1958,10 +1970,10 @@ function compileSwiftProjectUnit(input, options) {
|
|
|
1958
1970
|
}
|
|
1959
1971
|
|
|
1960
1972
|
// src/swift-host.ts
|
|
1961
|
-
var
|
|
1962
|
-
var
|
|
1963
|
-
var
|
|
1964
|
-
var
|
|
1973
|
+
var import_node_crypto6 = require("node:crypto");
|
|
1974
|
+
var import_node_fs11 = __toESM(require("node:fs"), 1);
|
|
1975
|
+
var import_node_os7 = __toESM(require("node:os"), 1);
|
|
1976
|
+
var import_node_path13 = __toESM(require("node:path"), 1);
|
|
1965
1977
|
|
|
1966
1978
|
// ../sootsim-swift/src/bundleAssets.ts
|
|
1967
1979
|
var import_svgpath = __toESM(require("svgpath"), 1);
|
|
@@ -1995,8 +2007,8 @@ function pickImagesetFile(images) {
|
|
|
1995
2007
|
scale: pick.scale === "2x" ? 2 : pick.scale === "3x" ? 3 : 1
|
|
1996
2008
|
};
|
|
1997
2009
|
}
|
|
1998
|
-
function flatScale(
|
|
1999
|
-
const match = /@([23])x\.[^./]+$/.exec(
|
|
2010
|
+
function flatScale(path14) {
|
|
2011
|
+
const match = /@([23])x\.[^./]+$/.exec(path14);
|
|
2000
2012
|
return match ? Number(match[1]) : 1;
|
|
2001
2013
|
}
|
|
2002
2014
|
function providesNamespace(text2) {
|
|
@@ -2023,13 +2035,13 @@ function catalogEntryName(contentsPath, kind, readText) {
|
|
|
2023
2035
|
}
|
|
2024
2036
|
return segments.join("/");
|
|
2025
2037
|
}
|
|
2026
|
-
function isFlatResourceImage(
|
|
2027
|
-
return
|
|
2038
|
+
function isFlatResourceImage(path14) {
|
|
2039
|
+
return path14.split("/").includes("Resources") && RASTER_EXTENSIONS.has(extOf(path14));
|
|
2028
2040
|
}
|
|
2029
2041
|
function enumerateBundleImages(paths, readText) {
|
|
2030
2042
|
const table = [];
|
|
2031
2043
|
const seen = /* @__PURE__ */ new Set();
|
|
2032
|
-
const catalogs = paths.filter((
|
|
2044
|
+
const catalogs = paths.filter((path14) => baseOf(path14) === "Contents.json");
|
|
2033
2045
|
for (const contentsPath of catalogs) {
|
|
2034
2046
|
const name = catalogEntryName(contentsPath, ".imageset", readText);
|
|
2035
2047
|
if (name === null || seen.has(name)) continue;
|
|
@@ -2050,12 +2062,12 @@ function enumerateBundleImages(paths, readText) {
|
|
|
2050
2062
|
seen.add(name);
|
|
2051
2063
|
table.push({ name, file: `${dir}/${pick.filename}`, scale: pick.scale });
|
|
2052
2064
|
}
|
|
2053
|
-
for (const
|
|
2054
|
-
if (!isFlatResourceImage(
|
|
2055
|
-
const name = baseOf(
|
|
2065
|
+
for (const path14 of paths) {
|
|
2066
|
+
if (!isFlatResourceImage(path14)) continue;
|
|
2067
|
+
const name = baseOf(path14).slice(0, -extOf(path14).length);
|
|
2056
2068
|
if (name === "" || seen.has(name)) continue;
|
|
2057
2069
|
seen.add(name);
|
|
2058
|
-
table.push({ name, file:
|
|
2070
|
+
table.push({ name, file: path14, scale: flatScale(path14) });
|
|
2059
2071
|
}
|
|
2060
2072
|
return table;
|
|
2061
2073
|
}
|
|
@@ -2084,7 +2096,7 @@ function colorsetValue(color) {
|
|
|
2084
2096
|
}
|
|
2085
2097
|
function enumerateBundleColors(paths, readText) {
|
|
2086
2098
|
const table = {};
|
|
2087
|
-
for (const contentsPath of paths.filter((
|
|
2099
|
+
for (const contentsPath of paths.filter((path14) => baseOf(path14) === "Contents.json")) {
|
|
2088
2100
|
const name = catalogEntryName(contentsPath, ".colorset", readText);
|
|
2089
2101
|
if (name === null || name in table) continue;
|
|
2090
2102
|
let colors;
|
|
@@ -2149,8 +2161,8 @@ function axisExtremes(points) {
|
|
|
2149
2161
|
function pathBounds(d) {
|
|
2150
2162
|
const xs = [];
|
|
2151
2163
|
const ys = [];
|
|
2152
|
-
for (const
|
|
2153
|
-
(0, import_svgpath.default)(
|
|
2164
|
+
for (const path14 of d)
|
|
2165
|
+
(0, import_svgpath.default)(path14).abs().unshort().unarc().iterate((segment, _index, x, y) => {
|
|
2154
2166
|
const [command, ...args] = segment;
|
|
2155
2167
|
if (command === "M" || command === "L") {
|
|
2156
2168
|
xs.push(Number(args[0]));
|
|
@@ -2177,7 +2189,7 @@ function guide(svg, id, axis) {
|
|
|
2177
2189
|
}
|
|
2178
2190
|
function enumerateBundleSymbols(paths, readText) {
|
|
2179
2191
|
const table = {};
|
|
2180
|
-
for (const contentsPath of paths.filter((
|
|
2192
|
+
for (const contentsPath of paths.filter((path14) => baseOf(path14) === "Contents.json")) {
|
|
2181
2193
|
const name = catalogEntryName(contentsPath, ".symbolset", readText);
|
|
2182
2194
|
if (name === null || name in table) continue;
|
|
2183
2195
|
let symbols;
|
|
@@ -2210,8 +2222,8 @@ function enumerateBundleSymbols(paths, readText) {
|
|
|
2210
2222
|
viewBox: "0 0 24 24",
|
|
2211
2223
|
advance,
|
|
2212
2224
|
box: [12 - advance / 2, 12 - tall / 2, advance, tall],
|
|
2213
|
-
layers: d.map((
|
|
2214
|
-
d: (0, import_svgpath.default)(
|
|
2225
|
+
layers: d.map((path14) => ({
|
|
2226
|
+
d: (0, import_svgpath.default)(path14).abs().scale(scale).translate(translateX, translateY).round(3).toString()
|
|
2215
2227
|
}))
|
|
2216
2228
|
};
|
|
2217
2229
|
}
|
|
@@ -2221,7 +2233,7 @@ function enumerateBundleJson(paths) {
|
|
|
2221
2233
|
const found = [];
|
|
2222
2234
|
const seen = /* @__PURE__ */ new Set();
|
|
2223
2235
|
const ordered = [...paths].filter(
|
|
2224
|
-
(
|
|
2236
|
+
(path14) => path14.split("/").includes("Resources") && path14.split("/").every((segment) => segment !== "" && segment !== "..") && (extOf(path14) === ".json" || extOf(path14) === ".xcstrings")
|
|
2225
2237
|
).sort((a, b) => {
|
|
2226
2238
|
const aDepth = a.split("/").length;
|
|
2227
2239
|
const bDepth = b.split("/").length;
|
|
@@ -2727,25 +2739,109 @@ var ios_sdk_frameworks_default = {
|
|
|
2727
2739
|
]
|
|
2728
2740
|
};
|
|
2729
2741
|
|
|
2742
|
+
// src/swift-binary-modules.ts
|
|
2743
|
+
var import_node_crypto3 = require("node:crypto");
|
|
2744
|
+
var import_node_fs4 = __toESM(require("node:fs"), 1);
|
|
2745
|
+
var import_node_os3 = __toESM(require("node:os"), 1);
|
|
2746
|
+
var import_node_path5 = __toESM(require("node:path"), 1);
|
|
2747
|
+
var cacheDir = import_node_path5.default.join(import_node_os3.default.tmpdir(), "peach-swift-binary-modules");
|
|
2748
|
+
function frameworkModules(paths) {
|
|
2749
|
+
const modules = /* @__PURE__ */ new Set();
|
|
2750
|
+
for (const file of paths) {
|
|
2751
|
+
const segment = file.split("/").find((part) => part.endsWith(".framework"));
|
|
2752
|
+
if (segment) modules.add(segment.slice(0, -".framework".length));
|
|
2753
|
+
}
|
|
2754
|
+
return [...modules].sort();
|
|
2755
|
+
}
|
|
2756
|
+
async function range(url, spec) {
|
|
2757
|
+
const response = await fetch(url, {
|
|
2758
|
+
headers: { range: `bytes=${spec}` },
|
|
2759
|
+
signal: AbortSignal.timeout(2e4)
|
|
2760
|
+
});
|
|
2761
|
+
const match = /^bytes (\d+)-\d+\/(\d+)$/.exec(
|
|
2762
|
+
response.headers.get("content-range") ?? ""
|
|
2763
|
+
);
|
|
2764
|
+
if (response.status !== 206 || !match)
|
|
2765
|
+
throw new Error(`${url} answered ${response.status} to a range request`);
|
|
2766
|
+
return {
|
|
2767
|
+
bytes: Buffer.from(await response.arrayBuffer()),
|
|
2768
|
+
start: Number(match[1]),
|
|
2769
|
+
total: Number(match[2])
|
|
2770
|
+
};
|
|
2771
|
+
}
|
|
2772
|
+
var signature = (bytes, value) => {
|
|
2773
|
+
const needle = Buffer.alloc(4);
|
|
2774
|
+
needle.writeUInt32LE(value);
|
|
2775
|
+
return bytes.lastIndexOf(needle);
|
|
2776
|
+
};
|
|
2777
|
+
async function zipEntries(url) {
|
|
2778
|
+
const { total } = await range(url, "0-0");
|
|
2779
|
+
const tail = await range(url, `${Math.max(0, total - 65558)}-${total - 1}`);
|
|
2780
|
+
const end = signature(tail.bytes, 101010256);
|
|
2781
|
+
if (end < 0) throw new Error(`${url} has no zip end record`);
|
|
2782
|
+
let size = tail.bytes.readUInt32LE(end + 12);
|
|
2783
|
+
let offset = tail.bytes.readUInt32LE(end + 16);
|
|
2784
|
+
if (offset === 4294967295 || size === 4294967295) {
|
|
2785
|
+
const locator = end - 20;
|
|
2786
|
+
if (locator < 0 || tail.bytes.readUInt32LE(locator) !== 117853008)
|
|
2787
|
+
throw new Error(`${url} has no zip64 locator`);
|
|
2788
|
+
const recordAt = Number(tail.bytes.readBigUInt64LE(locator + 8));
|
|
2789
|
+
const record2 = recordAt >= tail.start ? tail.bytes.subarray(recordAt - tail.start) : (await range(url, `${recordAt}-${recordAt + 55}`)).bytes;
|
|
2790
|
+
size = Number(record2.readBigUInt64LE(40));
|
|
2791
|
+
offset = Number(record2.readBigUInt64LE(48));
|
|
2792
|
+
}
|
|
2793
|
+
const directory = offset >= tail.start ? tail.bytes.subarray(offset - tail.start, offset - tail.start + size) : (await range(url, `${offset}-${offset + size - 1}`)).bytes;
|
|
2794
|
+
const names = [];
|
|
2795
|
+
for (let at = 0; at + 46 <= directory.length; ) {
|
|
2796
|
+
if (directory.readUInt32LE(at) !== 33639248) break;
|
|
2797
|
+
const nameLength = directory.readUInt16LE(at + 28);
|
|
2798
|
+
names.push(directory.toString("utf8", at + 46, at + 46 + nameLength));
|
|
2799
|
+
at += 46 + nameLength + directory.readUInt16LE(at + 30) + directory.readUInt16LE(at + 32);
|
|
2800
|
+
}
|
|
2801
|
+
return names;
|
|
2802
|
+
}
|
|
2803
|
+
function localEntries(dir) {
|
|
2804
|
+
if (!import_node_fs4.default.existsSync(dir)) return [];
|
|
2805
|
+
return import_node_fs4.default.readdirSync(dir, { withFileTypes: true }).filter((slice) => slice.isDirectory()).flatMap(
|
|
2806
|
+
(slice) => import_node_fs4.default.readdirSync(import_node_path5.default.join(dir, slice.name)).map((entry) => `${slice.name}/${entry}`)
|
|
2807
|
+
);
|
|
2808
|
+
}
|
|
2809
|
+
async function swiftBinaryModules(binary) {
|
|
2810
|
+
if (!binary.url) return frameworkModules(localEntries(binary.dir));
|
|
2811
|
+
const cached = import_node_path5.default.join(
|
|
2812
|
+
cacheDir,
|
|
2813
|
+
`${(0, import_node_crypto3.createHash)("sha256").update(binary.url).digest("hex").slice(0, 32)}.json`
|
|
2814
|
+
);
|
|
2815
|
+
if (import_node_fs4.default.existsSync(cached)) {
|
|
2816
|
+
const value = JSON.parse(import_node_fs4.default.readFileSync(cached, "utf8"));
|
|
2817
|
+
if (Array.isArray(value) && value.every((name) => typeof name === "string"))
|
|
2818
|
+
return value;
|
|
2819
|
+
}
|
|
2820
|
+
const modules = frameworkModules(await zipEntries(binary.url));
|
|
2821
|
+
import_node_fs4.default.mkdirSync(cacheDir, { recursive: true });
|
|
2822
|
+
import_node_fs4.default.writeFileSync(cached, JSON.stringify(modules));
|
|
2823
|
+
return modules;
|
|
2824
|
+
}
|
|
2825
|
+
|
|
2730
2826
|
// src/swift-distribution.ts
|
|
2731
|
-
var
|
|
2732
|
-
var
|
|
2827
|
+
var import_node_fs7 = __toESM(require("node:fs"), 1);
|
|
2828
|
+
var import_node_path8 = __toESM(require("node:path"), 1);
|
|
2733
2829
|
|
|
2734
2830
|
// ../contrast-runtime-delivery/src/index.ts
|
|
2735
2831
|
var import_node_child_process3 = require("node:child_process");
|
|
2736
|
-
var
|
|
2737
|
-
var
|
|
2738
|
-
var
|
|
2739
|
-
var
|
|
2832
|
+
var import_node_crypto4 = __toESM(require("node:crypto"), 1);
|
|
2833
|
+
var import_node_fs5 = __toESM(require("node:fs"), 1);
|
|
2834
|
+
var import_node_os4 = __toESM(require("node:os"), 1);
|
|
2835
|
+
var import_node_path6 = __toESM(require("node:path"), 1);
|
|
2740
2836
|
var import_node_stream = require("node:stream");
|
|
2741
2837
|
var import_promises = require("node:stream/promises");
|
|
2742
2838
|
async function installVerifiedTarball(tarball) {
|
|
2743
2839
|
const { url, digest, destDir, installedMarker, label } = tarball;
|
|
2744
|
-
const downloadDir =
|
|
2745
|
-
const archivePath =
|
|
2746
|
-
|
|
2747
|
-
const tmpDir =
|
|
2748
|
-
|
|
2840
|
+
const downloadDir = import_node_fs5.default.mkdtempSync(import_node_path6.default.join(import_node_os4.default.tmpdir(), "runtime-delivery-download-"));
|
|
2841
|
+
const archivePath = import_node_path6.default.join(downloadDir, "archive");
|
|
2842
|
+
import_node_fs5.default.mkdirSync(import_node_path6.default.dirname(destDir), { recursive: true });
|
|
2843
|
+
const tmpDir = import_node_fs5.default.mkdtempSync(
|
|
2844
|
+
import_node_path6.default.join(import_node_path6.default.dirname(destDir), `.installing-${import_node_path6.default.basename(destDir)}-`)
|
|
2749
2845
|
);
|
|
2750
2846
|
try {
|
|
2751
2847
|
await downloadToFile(url, archivePath);
|
|
@@ -2757,33 +2853,33 @@ async function installVerifiedTarball(tarball) {
|
|
|
2757
2853
|
}
|
|
2758
2854
|
if (new URL(url).pathname.endsWith(".zip")) await extractZip(archivePath, tmpDir);
|
|
2759
2855
|
else await extractTarball(archivePath, tmpDir, tarball.stripComponents ?? 0);
|
|
2760
|
-
if (!
|
|
2856
|
+
if (!import_node_fs5.default.existsSync(import_node_path6.default.join(tmpDir, installedMarker))) {
|
|
2761
2857
|
throw new Error(`extracted tarball for ${label} is missing ${installedMarker}`);
|
|
2762
2858
|
}
|
|
2763
2859
|
tarball.verify?.(tmpDir);
|
|
2764
2860
|
try {
|
|
2765
|
-
|
|
2861
|
+
import_node_fs5.default.renameSync(tmpDir, destDir);
|
|
2766
2862
|
} catch (err) {
|
|
2767
2863
|
if (!isErrnoCode(err, "ENOTEMPTY", "EEXIST")) throw err;
|
|
2768
2864
|
const aside = `${tmpDir}-replaced`;
|
|
2769
2865
|
try {
|
|
2770
|
-
|
|
2866
|
+
import_node_fs5.default.renameSync(destDir, aside);
|
|
2771
2867
|
} catch (moveErr) {
|
|
2772
2868
|
if (!isErrnoCode(moveErr, "ENOENT")) throw moveErr;
|
|
2773
2869
|
}
|
|
2774
2870
|
try {
|
|
2775
|
-
|
|
2871
|
+
import_node_fs5.default.renameSync(tmpDir, destDir);
|
|
2776
2872
|
} catch (landErr) {
|
|
2777
|
-
if (!isErrnoCode(landErr, "ENOTEMPTY", "EEXIST") || !
|
|
2873
|
+
if (!isErrnoCode(landErr, "ENOTEMPTY", "EEXIST") || !import_node_fs5.default.existsSync(import_node_path6.default.join(destDir, installedMarker))) {
|
|
2778
2874
|
throw landErr;
|
|
2779
2875
|
}
|
|
2780
2876
|
} finally {
|
|
2781
|
-
|
|
2877
|
+
import_node_fs5.default.rmSync(aside, { recursive: true, force: true });
|
|
2782
2878
|
}
|
|
2783
2879
|
}
|
|
2784
2880
|
} finally {
|
|
2785
|
-
|
|
2786
|
-
|
|
2881
|
+
import_node_fs5.default.rmSync(tmpDir, { recursive: true, force: true });
|
|
2882
|
+
import_node_fs5.default.rmSync(downloadDir, { recursive: true, force: true });
|
|
2787
2883
|
}
|
|
2788
2884
|
}
|
|
2789
2885
|
function isErrnoCode(err, ...codes) {
|
|
@@ -2794,17 +2890,17 @@ async function downloadToFile(url, destPath) {
|
|
|
2794
2890
|
if (!res.ok || !res.body) {
|
|
2795
2891
|
throw new Error(`download failed: ${res.status} ${res.statusText} (${url})`);
|
|
2796
2892
|
}
|
|
2797
|
-
|
|
2893
|
+
import_node_fs5.default.mkdirSync(import_node_path6.default.dirname(destPath), { recursive: true });
|
|
2798
2894
|
const tmp = `${destPath}.partial`;
|
|
2799
2895
|
try {
|
|
2800
2896
|
await (0, import_promises.pipeline)(
|
|
2801
2897
|
import_node_stream.Readable.fromWeb(res.body),
|
|
2802
|
-
|
|
2898
|
+
import_node_fs5.default.createWriteStream(tmp)
|
|
2803
2899
|
);
|
|
2804
|
-
|
|
2900
|
+
import_node_fs5.default.renameSync(tmp, destPath);
|
|
2805
2901
|
} catch (err) {
|
|
2806
2902
|
try {
|
|
2807
|
-
|
|
2903
|
+
import_node_fs5.default.unlinkSync(tmp);
|
|
2808
2904
|
} catch {
|
|
2809
2905
|
}
|
|
2810
2906
|
throw err;
|
|
@@ -2812,8 +2908,8 @@ async function downloadToFile(url, destPath) {
|
|
|
2812
2908
|
}
|
|
2813
2909
|
function digestFile(filePath, algorithm, encoding) {
|
|
2814
2910
|
return new Promise((resolve2, reject) => {
|
|
2815
|
-
const hash =
|
|
2816
|
-
const stream =
|
|
2911
|
+
const hash = import_node_crypto4.default.createHash(algorithm);
|
|
2912
|
+
const stream = import_node_fs5.default.createReadStream(filePath);
|
|
2817
2913
|
stream.on("data", (chunk) => hash.update(chunk));
|
|
2818
2914
|
stream.on("error", reject);
|
|
2819
2915
|
stream.on("end", () => resolve2(hash.digest(encoding)));
|
|
@@ -2866,30 +2962,30 @@ var swift_distribution_lock_default = {
|
|
|
2866
2962
|
|
|
2867
2963
|
// src/swift-toolchain.ts
|
|
2868
2964
|
var import_node_child_process4 = require("node:child_process");
|
|
2869
|
-
var
|
|
2870
|
-
var
|
|
2871
|
-
var
|
|
2965
|
+
var import_node_fs6 = __toESM(require("node:fs"), 1);
|
|
2966
|
+
var import_node_os5 = __toESM(require("node:os"), 1);
|
|
2967
|
+
var import_node_path7 = __toESM(require("node:path"), 1);
|
|
2872
2968
|
function swiftToolchainBin(release) {
|
|
2873
2969
|
if (process.platform === "darwin") {
|
|
2874
|
-
const dirs = [
|
|
2875
|
-
(base) =>
|
|
2970
|
+
const dirs = [import_node_os5.default.homedir(), "/"].map(
|
|
2971
|
+
(base) => import_node_path7.default.join(base, `Library/Developer/Toolchains/${release}.xctoolchain/usr/bin`)
|
|
2876
2972
|
);
|
|
2877
|
-
return dirs.find((dir) =>
|
|
2973
|
+
return dirs.find((dir) => import_node_fs6.default.existsSync(import_node_path7.default.join(dir, "swift"))) ?? dirs[0];
|
|
2878
2974
|
}
|
|
2879
2975
|
if (process.env.CONTRAST_SWIFT_TOOLCHAINS) {
|
|
2880
|
-
return
|
|
2976
|
+
return import_node_path7.default.join(process.env.CONTRAST_SWIFT_TOOLCHAINS, release, "usr/bin");
|
|
2881
2977
|
}
|
|
2882
|
-
const image =
|
|
2883
|
-
if (
|
|
2884
|
-
return (process.env.PATH ?? "").split(
|
|
2978
|
+
const image = import_node_path7.default.join("/opt/swift", release, "usr/bin");
|
|
2979
|
+
if (import_node_fs6.default.existsSync(import_node_path7.default.join(image, "swift"))) return image;
|
|
2980
|
+
return (process.env.PATH ?? "").split(import_node_path7.default.delimiter).find((dir) => dir && import_node_fs6.default.existsSync(import_node_path7.default.join(dir, "swift"))) ?? image;
|
|
2885
2981
|
}
|
|
2886
2982
|
var verified = /* @__PURE__ */ new Map();
|
|
2887
2983
|
function swiftToolchain(release, sdk) {
|
|
2888
2984
|
const cached = verified.get(`${release}\0${sdk.wasmSdkId}`);
|
|
2889
2985
|
if (cached) return cached;
|
|
2890
2986
|
const bin = swiftToolchainBin(release);
|
|
2891
|
-
const swift =
|
|
2892
|
-
const version =
|
|
2987
|
+
const swift = import_node_path7.default.join(bin, "swift");
|
|
2988
|
+
const version = import_node_fs6.default.existsSync(swift) ? (0, import_node_child_process4.execFileSync)(swift, ["--version"], {
|
|
2893
2989
|
encoding: "utf8",
|
|
2894
2990
|
stdio: ["ignore", "pipe", "pipe"]
|
|
2895
2991
|
}) : "";
|
|
@@ -2950,11 +3046,11 @@ function swiftDistributionRoot() {
|
|
|
2950
3046
|
);
|
|
2951
3047
|
}
|
|
2952
3048
|
swiftToolchain(lock.release, lock);
|
|
2953
|
-
const dir =
|
|
3049
|
+
const dir = import_node_path8.default.join(rnxHomeDir(), "swift", `${lock.id}-${host2}`);
|
|
2954
3050
|
let pending = installs.get(dir);
|
|
2955
3051
|
if (!pending) {
|
|
2956
3052
|
pending = (async () => {
|
|
2957
|
-
if (!
|
|
3053
|
+
if (!import_node_fs7.default.existsSync(import_node_path8.default.join(dir, SWIFT_DISTRIBUTION_MANIFEST))) {
|
|
2958
3054
|
process.stderr.write(
|
|
2959
3055
|
`peach: downloading Swift distribution ${lock.id} (${host2})\u2026
|
|
2960
3056
|
`
|
|
@@ -2983,7 +3079,7 @@ function swiftDistributionRoot() {
|
|
|
2983
3079
|
return pending;
|
|
2984
3080
|
}
|
|
2985
3081
|
function swiftModuleToolchain(root) {
|
|
2986
|
-
const pin = swiftDistributionAt(root) ?? JSON.parse(
|
|
3082
|
+
const pin = swiftDistributionAt(root) ?? JSON.parse(import_node_fs7.default.readFileSync(import_node_path8.default.join(root, "toolchain.json"), "utf8"));
|
|
2987
3083
|
return {
|
|
2988
3084
|
release: pin.release,
|
|
2989
3085
|
toolchainBin: swiftToolchain(pin.release, swiftModuleSdk(root))
|
|
@@ -2992,15 +3088,15 @@ function swiftModuleToolchain(root) {
|
|
|
2992
3088
|
|
|
2993
3089
|
// src/swift-packages.ts
|
|
2994
3090
|
var import_node_child_process6 = require("node:child_process");
|
|
2995
|
-
var
|
|
2996
|
-
var
|
|
3091
|
+
var import_node_fs9 = __toESM(require("node:fs"), 1);
|
|
3092
|
+
var import_node_path10 = __toESM(require("node:path"), 1);
|
|
2997
3093
|
|
|
2998
3094
|
// src/swift-package-manifest.ts
|
|
2999
3095
|
var import_node_child_process5 = require("node:child_process");
|
|
3000
|
-
var
|
|
3001
|
-
var
|
|
3002
|
-
var
|
|
3003
|
-
var
|
|
3096
|
+
var import_node_crypto5 = require("node:crypto");
|
|
3097
|
+
var import_node_fs8 = __toESM(require("node:fs"), 1);
|
|
3098
|
+
var import_node_os6 = __toESM(require("node:os"), 1);
|
|
3099
|
+
var import_node_path9 = __toESM(require("node:path"), 1);
|
|
3004
3100
|
var TARGET_TYPES = [
|
|
3005
3101
|
"regular",
|
|
3006
3102
|
"executable",
|
|
@@ -3015,19 +3111,19 @@ var record = (value) => value && typeof value === "object" && !Array.isArray(val
|
|
|
3015
3111
|
var array = (value) => Array.isArray(value) ? value : [];
|
|
3016
3112
|
var string = (value) => typeof value === "string" ? value : void 0;
|
|
3017
3113
|
function swiftCommand() {
|
|
3018
|
-
return process.platform === "darwin" ? { file: "xcrun", args: ["swift"] } : { file:
|
|
3114
|
+
return process.platform === "darwin" ? { file: "xcrun", args: ["swift"] } : { file: import_node_path9.default.join(swiftToolchainBin(swift_distribution_lock_default.release), "swift"), args: [] };
|
|
3019
3115
|
}
|
|
3020
|
-
var
|
|
3116
|
+
var cacheDir2 = import_node_path9.default.join(import_node_os6.default.tmpdir(), "peach-swift-manifests");
|
|
3021
3117
|
var evaluated = /* @__PURE__ */ new Map();
|
|
3022
3118
|
function dump(dir) {
|
|
3023
|
-
const manifests =
|
|
3119
|
+
const manifests = import_node_fs8.default.readdirSync(dir).filter((name) => /^Package(@swift-[\d.]+)?\.swift$/.test(name)).sort();
|
|
3024
3120
|
const command = swiftCommand();
|
|
3025
|
-
const key = (0,
|
|
3026
|
-
manifests.map((name) => `${name}\0${
|
|
3121
|
+
const key = (0, import_node_crypto5.createHash)("sha256").update(JSON.stringify([command, import_node_path9.default.resolve(dir)])).update(
|
|
3122
|
+
manifests.map((name) => `${name}\0${import_node_fs8.default.readFileSync(import_node_path9.default.join(dir, name), "utf8")}`).join("\0")
|
|
3027
3123
|
).digest("hex").slice(0, 32);
|
|
3028
|
-
const cached =
|
|
3029
|
-
if (
|
|
3030
|
-
return { key, raw: record(JSON.parse(
|
|
3124
|
+
const cached = import_node_path9.default.join(cacheDir2, `${key}.json`);
|
|
3125
|
+
if (import_node_fs8.default.existsSync(cached))
|
|
3126
|
+
return { key, raw: record(JSON.parse(import_node_fs8.default.readFileSync(cached, "utf8"))) };
|
|
3031
3127
|
let output;
|
|
3032
3128
|
try {
|
|
3033
3129
|
output = (0, import_node_child_process5.execFileSync)(
|
|
@@ -3039,7 +3135,7 @@ function dump(dir) {
|
|
|
3039
3135
|
dir,
|
|
3040
3136
|
// swiftpm's scratch files never land in the app's own package
|
|
3041
3137
|
"--scratch-path",
|
|
3042
|
-
|
|
3138
|
+
import_node_path9.default.join(cacheDir2, `${key}.build`),
|
|
3043
3139
|
"dump-package"
|
|
3044
3140
|
],
|
|
3045
3141
|
{
|
|
@@ -3051,11 +3147,11 @@ function dump(dir) {
|
|
|
3051
3147
|
} catch (error) {
|
|
3052
3148
|
const stderr = error instanceof Error && "stderr" in error ? String(error.stderr).trim() : "";
|
|
3053
3149
|
throw new Error(
|
|
3054
|
-
`swiftpm could not evaluate ${
|
|
3150
|
+
`swiftpm could not evaluate ${import_node_path9.default.join(dir, "Package.swift")}${stderr ? `: ${stderr}` : ""}`
|
|
3055
3151
|
);
|
|
3056
3152
|
}
|
|
3057
|
-
|
|
3058
|
-
|
|
3153
|
+
import_node_fs8.default.mkdirSync(cacheDir2, { recursive: true });
|
|
3154
|
+
import_node_fs8.default.writeFileSync(cached, output);
|
|
3059
3155
|
return { key, raw: record(JSON.parse(output)) };
|
|
3060
3156
|
}
|
|
3061
3157
|
function defaultTraits(manifest) {
|
|
@@ -3083,7 +3179,7 @@ function linksOnIOS(condition, traits) {
|
|
|
3083
3179
|
return gates.length === 0 || gates.some((name) => traits.has(string(name) ?? ""));
|
|
3084
3180
|
}
|
|
3085
3181
|
function swiftPackageManifest(dir) {
|
|
3086
|
-
dir =
|
|
3182
|
+
dir = import_node_fs8.default.realpathSync(dir);
|
|
3087
3183
|
const { key, raw: raw2 } = dump(dir);
|
|
3088
3184
|
const known = evaluated.get(key);
|
|
3089
3185
|
if (known) return known;
|
|
@@ -3131,7 +3227,7 @@ function swiftPackageManifest(dir) {
|
|
|
3131
3227
|
if (!name || !isTargetType(kind)) continue;
|
|
3132
3228
|
const declared = string(target.path);
|
|
3133
3229
|
const roots = kind === "test" ? ["Tests"] : ["Sources", "Source", "src", "srcs"];
|
|
3134
|
-
const targetDir = declared ?
|
|
3230
|
+
const targetDir = declared ? import_node_path9.default.resolve(dir, declared) : roots.map((root) => import_node_path9.default.join(dir, root, name)).find((candidate) => import_node_fs8.default.existsSync(candidate)) ?? import_node_path9.default.join(dir, roots[0], name);
|
|
3135
3231
|
const dependencies = [];
|
|
3136
3232
|
for (const dependency of array(target.dependencies)) {
|
|
3137
3233
|
const { target: local, product, byName } = record(dependency);
|
|
@@ -3173,30 +3269,31 @@ function swiftPackageManifest(dir) {
|
|
|
3173
3269
|
dependencies,
|
|
3174
3270
|
languageMode,
|
|
3175
3271
|
mainActorIsolation,
|
|
3176
|
-
declaresResources: array(target.resources).length > 0
|
|
3272
|
+
declaresResources: array(target.resources).length > 0,
|
|
3273
|
+
url: string(target.url) ?? null
|
|
3177
3274
|
});
|
|
3178
3275
|
}
|
|
3179
3276
|
const manifest = { dir, products, targets, packages };
|
|
3180
3277
|
evaluated.set(key, manifest);
|
|
3181
3278
|
return manifest;
|
|
3182
3279
|
}
|
|
3183
|
-
var within = (file, roots) => roots.some((root) => file === root || file.startsWith(`${root}${
|
|
3280
|
+
var within = (file, roots) => roots.some((root) => file === root || file.startsWith(`${root}${import_node_path9.default.sep}`));
|
|
3184
3281
|
function walk(dir) {
|
|
3185
|
-
if (!
|
|
3186
|
-
if (
|
|
3282
|
+
if (!import_node_fs8.default.existsSync(dir)) return [];
|
|
3283
|
+
if (import_node_fs8.default.statSync(dir).isFile()) return [dir];
|
|
3187
3284
|
const out = [];
|
|
3188
|
-
for (const entry of
|
|
3285
|
+
for (const entry of import_node_fs8.default.readdirSync(dir, { withFileTypes: true })) {
|
|
3189
3286
|
if (entry.name.startsWith(".")) continue;
|
|
3190
|
-
const full =
|
|
3287
|
+
const full = import_node_path9.default.join(dir, entry.name);
|
|
3191
3288
|
if (entry.isDirectory()) out.push(...walk(full));
|
|
3192
3289
|
else if (entry.isFile()) out.push(full);
|
|
3193
3290
|
}
|
|
3194
3291
|
return out;
|
|
3195
3292
|
}
|
|
3196
3293
|
function swiftTargetFiles(manifest, target) {
|
|
3197
|
-
const included = target.sources ? target.sources.map((source) =>
|
|
3294
|
+
const included = target.sources ? target.sources.map((source) => import_node_path9.default.resolve(target.dir, source)) : [target.dir];
|
|
3198
3295
|
const excluded = [
|
|
3199
|
-
...target.exclude.map((file) =>
|
|
3296
|
+
...target.exclude.map((file) => import_node_path9.default.resolve(target.dir, file)),
|
|
3200
3297
|
...[...manifest.targets.values()].flatMap(
|
|
3201
3298
|
(other) => other !== target && within(other.dir, [target.dir]) && other.dir !== target.dir ? [other.dir] : []
|
|
3202
3299
|
)
|
|
@@ -3205,10 +3302,12 @@ function swiftTargetFiles(manifest, target) {
|
|
|
3205
3302
|
}
|
|
3206
3303
|
|
|
3207
3304
|
// src/swift-packages.ts
|
|
3208
|
-
var REMOTE_CHECKOUTS =
|
|
3305
|
+
var REMOTE_CHECKOUTS = import_node_path10.default.join(".build", "peach", "checkouts");
|
|
3209
3306
|
var C_FAMILY = /\.(c|cc|cpp|cxx|m|mm|s|S)$/;
|
|
3307
|
+
var BINARY = "is a binary framework";
|
|
3308
|
+
var blocker = (reasons) => reasons.find((reason) => reason?.includes(BINARY)) ?? reasons.find((reason) => reason !== null) ?? null;
|
|
3210
3309
|
function readPins(resolved) {
|
|
3211
|
-
const data = JSON.parse(
|
|
3310
|
+
const data = JSON.parse(import_node_fs9.default.readFileSync(resolved, "utf8"));
|
|
3212
3311
|
const pins = data && typeof data === "object" && "pins" in data && Array.isArray(data.pins) ? data.pins : null;
|
|
3213
3312
|
if (!pins)
|
|
3214
3313
|
throw new Error(`${resolved} has no pins; resolve packages in a current Xcode`);
|
|
@@ -3224,23 +3323,23 @@ function readPins(resolved) {
|
|
|
3224
3323
|
}
|
|
3225
3324
|
var verified2 = /* @__PURE__ */ new Set();
|
|
3226
3325
|
function checkout(checkouts, identity, pin) {
|
|
3227
|
-
const dir =
|
|
3326
|
+
const dir = import_node_path10.default.join(checkouts, identity);
|
|
3228
3327
|
const key = `${dir}\0${pin.revision}`;
|
|
3229
3328
|
if (verified2.has(key)) return dir;
|
|
3230
3329
|
const git = (...args) => (0, import_node_child_process6.execFileSync)("git", ["-C", dir, ...args], {
|
|
3231
3330
|
encoding: "utf8",
|
|
3232
3331
|
stdio: ["ignore", "pipe", "pipe"]
|
|
3233
3332
|
}).trim();
|
|
3234
|
-
const current =
|
|
3333
|
+
const current = import_node_fs9.default.existsSync(import_node_path10.default.join(dir, ".git")) ? git("rev-parse", "HEAD") : "";
|
|
3235
3334
|
if (current !== pin.revision) {
|
|
3236
|
-
|
|
3237
|
-
|
|
3335
|
+
import_node_fs9.default.rmSync(dir, { recursive: true, force: true });
|
|
3336
|
+
import_node_fs9.default.mkdirSync(dir, { recursive: true });
|
|
3238
3337
|
try {
|
|
3239
3338
|
git("init", "-q");
|
|
3240
3339
|
git("fetch", "-q", "--depth", "1", pin.location, pin.revision);
|
|
3241
3340
|
git("checkout", "-q", "FETCH_HEAD");
|
|
3242
3341
|
} catch (error) {
|
|
3243
|
-
|
|
3342
|
+
import_node_fs9.default.rmSync(dir, { recursive: true, force: true });
|
|
3244
3343
|
const stderr = error instanceof Error && "stderr" in error ? String(error.stderr).trim() : "";
|
|
3245
3344
|
throw new Error(
|
|
3246
3345
|
`could not fetch ${pin.location} at ${pin.revision}${stderr ? `: ${stderr}` : ""}`
|
|
@@ -3256,13 +3355,14 @@ function resolveSwiftPackages(options) {
|
|
|
3256
3355
|
const result = {
|
|
3257
3356
|
targets: [],
|
|
3258
3357
|
unavailable: /* @__PURE__ */ new Map(),
|
|
3259
|
-
modules: /* @__PURE__ */ new Map()
|
|
3358
|
+
modules: /* @__PURE__ */ new Map(),
|
|
3359
|
+
binaries: []
|
|
3260
3360
|
};
|
|
3261
3361
|
const pins = resolved ? readPins(resolved) : null;
|
|
3262
|
-
const checkouts =
|
|
3362
|
+
const checkouts = import_node_path10.default.join(rootDir, REMOTE_CHECKOUTS);
|
|
3263
3363
|
const packages = /* @__PURE__ */ new Map();
|
|
3264
3364
|
const load2 = (source) => {
|
|
3265
|
-
const key = source.kind === "local" ?
|
|
3365
|
+
const key = source.kind === "local" ? import_node_path10.default.resolve(source.dir) : source.url;
|
|
3266
3366
|
const cached = packages.get(key);
|
|
3267
3367
|
if (cached !== void 0) return cached;
|
|
3268
3368
|
let loaded2;
|
|
@@ -3274,8 +3374,8 @@ function resolveSwiftPackages(options) {
|
|
|
3274
3374
|
if (!pin) {
|
|
3275
3375
|
loaded2 = pins ? `package ${identity} is not pinned in Package.resolved` : "no Package.resolved pins it; resolve packages in Xcode once";
|
|
3276
3376
|
} else {
|
|
3277
|
-
|
|
3278
|
-
|
|
3377
|
+
import_node_fs9.default.mkdirSync(checkouts, { recursive: true });
|
|
3378
|
+
import_node_fs9.default.writeFileSync(import_node_path10.default.join(import_node_path10.default.dirname(checkouts), ".gitignore"), "*\n");
|
|
3279
3379
|
loaded2 = {
|
|
3280
3380
|
source: source.url,
|
|
3281
3381
|
remote: true,
|
|
@@ -3295,8 +3395,8 @@ function resolveSwiftPackages(options) {
|
|
|
3295
3395
|
const outcome = (() => {
|
|
3296
3396
|
if (provided.has(name)) return null;
|
|
3297
3397
|
const target = pkg.manifest.targets.get(name);
|
|
3298
|
-
if (!target) return `${
|
|
3299
|
-
if (target.type === "binary") return `${name}
|
|
3398
|
+
if (!target) return `${import_node_path10.default.basename(pkg.manifest.dir)} declares no target ${name}`;
|
|
3399
|
+
if (target.type === "binary") return `${name} ${BINARY}`;
|
|
3300
3400
|
if (target.type === "system") return `${name} is a system C library`;
|
|
3301
3401
|
if (target.type !== "regular") return `${name} is a ${target.type} target`;
|
|
3302
3402
|
const files = swiftTargetFiles(pkg.manifest, target);
|
|
@@ -3307,9 +3407,9 @@ function resolveSwiftPackages(options) {
|
|
|
3307
3407
|
const nested = resolveDependencyProduct(pkg, dependency.package, dependency.name);
|
|
3308
3408
|
return nested && `${dependency.name}: ${nested}`;
|
|
3309
3409
|
});
|
|
3310
|
-
const blocked = reasons
|
|
3410
|
+
const blocked = blocker(reasons);
|
|
3311
3411
|
if (blocked) return blocked;
|
|
3312
|
-
const relative = files.map((file) =>
|
|
3412
|
+
const relative = files.map((file) => import_node_path10.default.relative(target.dir, file));
|
|
3313
3413
|
targets.set(`${pkg.manifest.dir}\0${name}`, {
|
|
3314
3414
|
name,
|
|
3315
3415
|
path: "",
|
|
@@ -3331,7 +3431,7 @@ function resolveSwiftPackages(options) {
|
|
|
3331
3431
|
const resolveProduct = (pkg, product) => {
|
|
3332
3432
|
if (provided.has(product)) return null;
|
|
3333
3433
|
const roots = pkg.manifest.products.get(product);
|
|
3334
|
-
const reason = !roots ? `${
|
|
3434
|
+
const reason = !roots ? `${import_node_path10.default.basename(pkg.manifest.dir)} has no library ${product}` : blocker(roots.map((name) => resolveTarget(pkg, name)));
|
|
3335
3435
|
productOutcomes.set(`${pkg.manifest.dir}\0${product}`, { pkg, reason });
|
|
3336
3436
|
return reason;
|
|
3337
3437
|
};
|
|
@@ -3339,7 +3439,7 @@ function resolveSwiftPackages(options) {
|
|
|
3339
3439
|
if (provided.has(product)) return null;
|
|
3340
3440
|
const dependency = pkg.manifest.packages.get(packageName);
|
|
3341
3441
|
if (!dependency)
|
|
3342
|
-
return `${
|
|
3442
|
+
return `${import_node_path10.default.basename(pkg.manifest.dir)} names no package ${packageName}`;
|
|
3343
3443
|
if ("dir" in dependency) {
|
|
3344
3444
|
const loaded3 = load2({ kind: "local", dir: dependency.dir });
|
|
3345
3445
|
return typeof loaded3 === "string" ? loaded3 : resolveProduct(loaded3, product);
|
|
@@ -3366,6 +3466,13 @@ function resolveSwiftPackages(options) {
|
|
|
3366
3466
|
if (target.type === "test" || target.type === "plugin" || target.type === "macro")
|
|
3367
3467
|
continue;
|
|
3368
3468
|
if (target.type === "executable") continue;
|
|
3469
|
+
if (target.type === "binary")
|
|
3470
|
+
result.binaries.push({
|
|
3471
|
+
target: name,
|
|
3472
|
+
source: pkg.source,
|
|
3473
|
+
url: target.url,
|
|
3474
|
+
dir: target.dir
|
|
3475
|
+
});
|
|
3369
3476
|
const reason = resolveTarget(pkg, name);
|
|
3370
3477
|
if (reason && !result.modules.has(name))
|
|
3371
3478
|
result.modules.set(name, { source: pkg.source, reason });
|
|
@@ -3385,7 +3492,7 @@ function resolveSwiftPackages(options) {
|
|
|
3385
3492
|
if (dependency.kind === "target") reach(pkg, dependency.name);
|
|
3386
3493
|
else {
|
|
3387
3494
|
const source = pkg.manifest.packages.get(dependency.package);
|
|
3388
|
-
const nested = source && ("dir" in source ? packages.get(
|
|
3495
|
+
const nested = source && ("dir" in source ? packages.get(import_node_path10.default.resolve(source.dir)) : packages.get(source.url));
|
|
3389
3496
|
if (nested && typeof nested !== "string")
|
|
3390
3497
|
for (const root of nested.manifest.products.get(dependency.name) ?? [])
|
|
3391
3498
|
reach(nested, root);
|
|
@@ -3393,7 +3500,7 @@ function resolveSwiftPackages(options) {
|
|
|
3393
3500
|
}
|
|
3394
3501
|
};
|
|
3395
3502
|
for (const { product, source } of products) {
|
|
3396
|
-
const pkg = source.kind === "unnamed" ? unnamed().find((candidate) => candidate.manifest.products.has(product)) : packages.get(source.kind === "local" ?
|
|
3503
|
+
const pkg = source.kind === "unnamed" ? unnamed().find((candidate) => candidate.manifest.products.has(product)) : packages.get(source.kind === "local" ? import_node_path10.default.resolve(source.dir) : source.url);
|
|
3397
3504
|
if (!pkg || typeof pkg === "string") continue;
|
|
3398
3505
|
for (const root of pkg.manifest.products.get(product) ?? []) reach(pkg, root);
|
|
3399
3506
|
}
|
|
@@ -3538,12 +3645,12 @@ async function compileSwiftProject(submit, work, origin, signal) {
|
|
|
3538
3645
|
}
|
|
3539
3646
|
|
|
3540
3647
|
// src/xcode-project.ts
|
|
3541
|
-
var
|
|
3542
|
-
var
|
|
3648
|
+
var import_node_fs10 = __toESM(require("node:fs"), 1);
|
|
3649
|
+
var import_node_path12 = __toESM(require("node:path"), 1);
|
|
3543
3650
|
var import_plist = __toESM(require_plist(), 1);
|
|
3544
3651
|
|
|
3545
3652
|
// src/xcode-json-project.ts
|
|
3546
|
-
var
|
|
3653
|
+
var import_node_path11 = __toESM(require("node:path"), 1);
|
|
3547
3654
|
var import_json5 = __toESM(require("json5"), 1);
|
|
3548
3655
|
var isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3549
3656
|
var text = (value) => typeof value === "string" ? value : void 0;
|
|
@@ -3559,7 +3666,7 @@ var PHASE_ISA = {
|
|
|
3559
3666
|
function readXcodeJsonProject(xcodeproj, source) {
|
|
3560
3667
|
const json = import_json5.default.parse(source);
|
|
3561
3668
|
if (!isJsonObject(json)) throw new Error(`${xcodeproj}/project.xcproj is not an object`);
|
|
3562
|
-
const projectDir =
|
|
3669
|
+
const projectDir = import_node_path11.default.dirname(xcodeproj);
|
|
3563
3670
|
const objects = {};
|
|
3564
3671
|
let next = 0;
|
|
3565
3672
|
const add = (entry, id) => {
|
|
@@ -3572,7 +3679,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
3572
3679
|
const base = /^<([A-Z]+)>\/(.*)$/.exec(raw2);
|
|
3573
3680
|
if (base) {
|
|
3574
3681
|
if (base[1] === "PROJECT")
|
|
3575
|
-
return { sourceTree: "<absolute>", path:
|
|
3682
|
+
return { sourceTree: "<absolute>", path: import_node_path11.default.join(projectDir, base[2]) };
|
|
3576
3683
|
if (base[1] === "PRODUCTS")
|
|
3577
3684
|
return { sourceTree: "BUILT_PRODUCTS_DIR", path: base[2] };
|
|
3578
3685
|
return null;
|
|
@@ -3580,7 +3687,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
3580
3687
|
const unescaped = raw2.replaceAll("\\<", "<");
|
|
3581
3688
|
if (unescaped.startsWith("/")) return { sourceTree: "<absolute>", path: unescaped };
|
|
3582
3689
|
if (unescaped.startsWith("~")) return null;
|
|
3583
|
-
return groupDir === null ? null : { sourceTree: "<absolute>", path:
|
|
3690
|
+
return groupDir === null ? null : { sourceTree: "<absolute>", path: import_node_path11.default.join(groupDir, unescaped) };
|
|
3584
3691
|
};
|
|
3585
3692
|
const memberships = [];
|
|
3586
3693
|
const folders = [];
|
|
@@ -3591,7 +3698,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
3591
3698
|
const kind = text(entry.kind) ?? "file-reference";
|
|
3592
3699
|
const raw2 = text(entry.path) ?? "";
|
|
3593
3700
|
const located = raw2 === "" ? null : locate(raw2, parent.dir);
|
|
3594
|
-
const name = text(entry.name) ??
|
|
3701
|
+
const name = text(entry.name) ?? import_node_path11.default.basename(raw2);
|
|
3595
3702
|
const node = { id: "", name, dir: null, parent, children: [] };
|
|
3596
3703
|
if (kind === "group" || kind === "variant-group" || kind === "version-group") {
|
|
3597
3704
|
node.dir = raw2 === "" ? parent.dir : located?.sourceTree === "<absolute>" ? located.path : null;
|
|
@@ -3706,7 +3813,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
3706
3813
|
if (!isObject(entry)) continue;
|
|
3707
3814
|
const repository = text(entry.repository);
|
|
3708
3815
|
const local = text(entry.path);
|
|
3709
|
-
const name = local !== void 0 ?
|
|
3816
|
+
const name = local !== void 0 ? import_node_path11.default.basename(import_node_path11.default.resolve(import_node_path11.default.dirname(xcodeproj), local)) : import_node_path11.default.basename(repository ?? "").replace(/\.git$/, "");
|
|
3710
3817
|
const id = text(entry.kind) === "local" && local !== void 0 ? add({ isa: "XCLocalSwiftPackageReference", relativePath: local }) : add({ isa: "XCRemoteSwiftPackageReference", repositoryURL: repository ?? "" });
|
|
3711
3818
|
packageIds.set(name.toLowerCase(), id);
|
|
3712
3819
|
}
|
|
@@ -3983,28 +4090,28 @@ var CONDITIONS = {
|
|
|
3983
4090
|
variant: "normal"
|
|
3984
4091
|
};
|
|
3985
4092
|
function walkFiles(dir) {
|
|
3986
|
-
if (!
|
|
4093
|
+
if (!import_node_fs10.default.existsSync(dir)) return [];
|
|
3987
4094
|
const out = [];
|
|
3988
|
-
for (const entry of
|
|
4095
|
+
for (const entry of import_node_fs10.default.readdirSync(dir, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
|
|
3989
4096
|
if (entry.name.startsWith(".")) continue;
|
|
3990
|
-
const full =
|
|
4097
|
+
const full = import_node_path12.default.join(dir, entry.name);
|
|
3991
4098
|
if (entry.isDirectory()) out.push(...walkFiles(full));
|
|
3992
4099
|
else if (entry.isFile()) out.push(full);
|
|
3993
4100
|
}
|
|
3994
4101
|
return out;
|
|
3995
4102
|
}
|
|
3996
|
-
var isDirectory = (dir) =>
|
|
4103
|
+
var isDirectory = (dir) => import_node_fs10.default.existsSync(dir) && import_node_fs10.default.statSync(dir).isDirectory();
|
|
3997
4104
|
function readXcconfig(file, seen = /* @__PURE__ */ new Set()) {
|
|
3998
|
-
if (seen.has(file) || !
|
|
4105
|
+
if (seen.has(file) || !import_node_fs10.default.existsSync(file)) return {};
|
|
3999
4106
|
seen.add(file);
|
|
4000
4107
|
const settings = {};
|
|
4001
|
-
for (const raw2 of
|
|
4108
|
+
for (const raw2 of import_node_fs10.default.readFileSync(file, "utf8").split("\n")) {
|
|
4002
4109
|
const line = raw2.replace(/\/\/.*$/, "").trim();
|
|
4003
4110
|
const include = /^#include\??\s+"([^"]+)"/.exec(line);
|
|
4004
4111
|
if (include) {
|
|
4005
4112
|
Object.assign(
|
|
4006
4113
|
settings,
|
|
4007
|
-
readXcconfig(
|
|
4114
|
+
readXcconfig(import_node_path12.default.resolve(import_node_path12.default.dirname(file), include[1]), seen)
|
|
4008
4115
|
);
|
|
4009
4116
|
continue;
|
|
4010
4117
|
}
|
|
@@ -4054,22 +4161,22 @@ function decodeXml(text2) {
|
|
|
4054
4161
|
return text2.replaceAll(""", '"').replaceAll("'", "'").replaceAll("<", "<").replaceAll(">", ">").replaceAll("&", "&");
|
|
4055
4162
|
}
|
|
4056
4163
|
function workspaceReferences(workspace) {
|
|
4057
|
-
const data =
|
|
4058
|
-
if (!
|
|
4164
|
+
const data = import_node_path12.default.join(workspace, "contents.xcworkspacedata");
|
|
4165
|
+
if (!import_node_fs10.default.existsSync(data))
|
|
4059
4166
|
throw new Error(`${workspace} has no contents.xcworkspacedata`);
|
|
4060
|
-
const container =
|
|
4167
|
+
const container = import_node_path12.default.dirname(workspace);
|
|
4061
4168
|
const locate = (location, base) => {
|
|
4062
4169
|
const colon = location.indexOf(":");
|
|
4063
4170
|
const kind = location.slice(0, colon);
|
|
4064
4171
|
const rest = location.slice(colon + 1);
|
|
4065
|
-
if (kind === "group") return
|
|
4066
|
-
if (kind === "container" || kind === "self") return
|
|
4067
|
-
if (kind === "absolute") return
|
|
4068
|
-
throw new Error(`${
|
|
4172
|
+
if (kind === "group") return import_node_path12.default.resolve(base, rest);
|
|
4173
|
+
if (kind === "container" || kind === "self") return import_node_path12.default.resolve(container, rest);
|
|
4174
|
+
if (kind === "absolute") return import_node_path12.default.resolve(rest);
|
|
4175
|
+
throw new Error(`${import_node_path12.default.basename(workspace)} has an unsupported location ${location}`);
|
|
4069
4176
|
};
|
|
4070
4177
|
const groups = [container];
|
|
4071
4178
|
const references = [];
|
|
4072
|
-
for (const [, closing, tag, attributes, selfClosing] of
|
|
4179
|
+
for (const [, closing, tag, attributes, selfClosing] of import_node_fs10.default.readFileSync(data, "utf8").matchAll(/<(\/?)(Group|FileRef)\b([^>]*?)(\/?)>/g)) {
|
|
4073
4180
|
if (closing) {
|
|
4074
4181
|
if (tag === "Group") groups.pop();
|
|
4075
4182
|
continue;
|
|
@@ -4085,8 +4192,8 @@ function workspaceReferences(workspace) {
|
|
|
4085
4192
|
var loaded = /* @__PURE__ */ new Map();
|
|
4086
4193
|
function xcodeProjectFile(xcodeproj) {
|
|
4087
4194
|
for (const name of ["project.pbxproj", "project.xcproj"]) {
|
|
4088
|
-
const file =
|
|
4089
|
-
if (
|
|
4195
|
+
const file = import_node_path12.default.join(xcodeproj, name);
|
|
4196
|
+
if (import_node_fs10.default.existsSync(file)) return file;
|
|
4090
4197
|
}
|
|
4091
4198
|
return null;
|
|
4092
4199
|
}
|
|
@@ -4094,10 +4201,10 @@ function loadProject(xcodeproj) {
|
|
|
4094
4201
|
const projectFile = xcodeProjectFile(xcodeproj);
|
|
4095
4202
|
if (!projectFile)
|
|
4096
4203
|
throw new Error(`${xcodeproj} has no project.pbxproj or project.xcproj`);
|
|
4097
|
-
const mtimeMs =
|
|
4204
|
+
const mtimeMs = import_node_fs10.default.statSync(projectFile).mtimeMs;
|
|
4098
4205
|
const cached = loaded.get(projectFile);
|
|
4099
4206
|
if (cached?.mtimeMs === mtimeMs) return cached.project;
|
|
4100
|
-
const source =
|
|
4207
|
+
const source = import_node_fs10.default.readFileSync(projectFile, "utf8");
|
|
4101
4208
|
const root = projectFile.endsWith(".xcproj") ? readXcodeJsonProject(xcodeproj, source) : parseOpenStepPlist(source);
|
|
4102
4209
|
if (!isDict(root) || !isDict(root.objects)) {
|
|
4103
4210
|
throw new Error(`${projectFile} has no objects table`);
|
|
@@ -4111,8 +4218,8 @@ function loadProject(xcodeproj) {
|
|
|
4111
4218
|
if (!project || project.isa !== "PBXProject") {
|
|
4112
4219
|
throw new Error(`${projectFile} has no PBXProject root`);
|
|
4113
4220
|
}
|
|
4114
|
-
const projectDir =
|
|
4115
|
-
|
|
4221
|
+
const projectDir = import_node_fs10.default.realpathSync(
|
|
4222
|
+
import_node_path12.default.resolve(import_node_path12.default.dirname(xcodeproj), str(project.projectDirPath) ?? "")
|
|
4116
4223
|
);
|
|
4117
4224
|
const parent = /* @__PURE__ */ new Map();
|
|
4118
4225
|
for (const [id, entry] of Object.entries(objects)) {
|
|
@@ -4130,11 +4237,11 @@ function loadProject(xcodeproj) {
|
|
|
4130
4237
|
const own = str(entry.path) ?? "";
|
|
4131
4238
|
const tree = str(entry.sourceTree) ?? "<group>";
|
|
4132
4239
|
if (tree === "<absolute>") result2 = own;
|
|
4133
|
-
else if (tree === "SOURCE_ROOT") result2 =
|
|
4240
|
+
else if (tree === "SOURCE_ROOT") result2 = import_node_path12.default.join(projectDir, own);
|
|
4134
4241
|
else if (tree === "<group>") {
|
|
4135
4242
|
const up = parent.get(id);
|
|
4136
4243
|
const base = up ? resolvePath(up) : projectDir;
|
|
4137
|
-
result2 = base === null ? null :
|
|
4244
|
+
result2 = base === null ? null : import_node_path12.default.join(base, own);
|
|
4138
4245
|
}
|
|
4139
4246
|
}
|
|
4140
4247
|
resolvedPaths.set(id, result2);
|
|
@@ -4234,7 +4341,7 @@ function targetMembers(ref) {
|
|
|
4234
4341
|
const addResource = (file) => {
|
|
4235
4342
|
if (isDirectory(file)) {
|
|
4236
4343
|
for (const inner of walkFiles(file)) resources.add(inner);
|
|
4237
|
-
} else if (
|
|
4344
|
+
} else if (import_node_fs10.default.existsSync(file)) resources.add(file);
|
|
4238
4345
|
};
|
|
4239
4346
|
const fileRefPaths = (refId) => {
|
|
4240
4347
|
const entry = project.object(refId);
|
|
@@ -4255,7 +4362,7 @@ function targetMembers(ref) {
|
|
|
4255
4362
|
for (const buildFileId of list(phase.files)) {
|
|
4256
4363
|
for (const file of fileRefPaths(str(project.object(buildFileId)?.fileRef) ?? "")) {
|
|
4257
4364
|
if (phase.isa === "PBXSourcesBuildPhase") {
|
|
4258
|
-
if (!
|
|
4365
|
+
if (!import_node_fs10.default.existsSync(file)) continue;
|
|
4259
4366
|
allSources.add(file);
|
|
4260
4367
|
if (file.endsWith(".swift")) sources.add(file);
|
|
4261
4368
|
} else if (phase.isa === "PBXResourcesBuildPhase") addResource(file);
|
|
@@ -4263,7 +4370,7 @@ function targetMembers(ref) {
|
|
|
4263
4370
|
}
|
|
4264
4371
|
}
|
|
4265
4372
|
const addSynchronized = (folder, relative) => {
|
|
4266
|
-
const file =
|
|
4373
|
+
const file = import_node_path12.default.join(folder, relative);
|
|
4267
4374
|
if (NEVER_MEMBER.test(relative)) return;
|
|
4268
4375
|
if (file.endsWith(".swift")) {
|
|
4269
4376
|
if (!relative.split("/").some((segment) => BUNDLE_DIR.test(segment))) {
|
|
@@ -4288,7 +4395,7 @@ function targetMembers(ref) {
|
|
|
4288
4395
|
}
|
|
4289
4396
|
if (owned.has(groupId)) {
|
|
4290
4397
|
for (const file of walkFiles(folder)) {
|
|
4291
|
-
const relative =
|
|
4398
|
+
const relative = import_node_path12.default.relative(folder, file).split(import_node_path12.default.sep).join("/");
|
|
4292
4399
|
if ([...exceptions].some(
|
|
4293
4400
|
(exception) => relative === exception || relative.startsWith(`${exception}/`)
|
|
4294
4401
|
))
|
|
@@ -4297,14 +4404,14 @@ function targetMembers(ref) {
|
|
|
4297
4404
|
}
|
|
4298
4405
|
} else {
|
|
4299
4406
|
for (const relative of exceptions) {
|
|
4300
|
-
const file =
|
|
4407
|
+
const file = import_node_path12.default.join(folder, relative);
|
|
4301
4408
|
if (isDirectory(file)) {
|
|
4302
4409
|
for (const inner of walkFiles(file))
|
|
4303
4410
|
addSynchronized(
|
|
4304
4411
|
folder,
|
|
4305
|
-
|
|
4412
|
+
import_node_path12.default.relative(folder, inner).split(import_node_path12.default.sep).join("/")
|
|
4306
4413
|
);
|
|
4307
|
-
} else if (
|
|
4414
|
+
} else if (import_node_fs10.default.existsSync(file)) addSynchronized(folder, relative);
|
|
4308
4415
|
}
|
|
4309
4416
|
}
|
|
4310
4417
|
}
|
|
@@ -4317,8 +4424,8 @@ function targetMembers(ref) {
|
|
|
4317
4424
|
function commonAncestor(dirs) {
|
|
4318
4425
|
let common = dirs[0];
|
|
4319
4426
|
for (const dir of dirs) {
|
|
4320
|
-
while (common !==
|
|
4321
|
-
common =
|
|
4427
|
+
while (common !== import_node_path12.default.dirname(common) && import_node_path12.default.relative(common, dir).startsWith(".."))
|
|
4428
|
+
common = import_node_path12.default.dirname(common);
|
|
4322
4429
|
}
|
|
4323
4430
|
return common;
|
|
4324
4431
|
}
|
|
@@ -4327,8 +4434,8 @@ function workspaceProjects(xcodeprojOrWorkspace) {
|
|
|
4327
4434
|
const projects2 = [];
|
|
4328
4435
|
const projectAt = /* @__PURE__ */ new Map();
|
|
4329
4436
|
const addProject = (xcodeproj) => {
|
|
4330
|
-
const key =
|
|
4331
|
-
if (projectAt.has(key) || key.split(
|
|
4437
|
+
const key = import_node_path12.default.resolve(xcodeproj);
|
|
4438
|
+
if (projectAt.has(key) || key.split(import_node_path12.default.sep).includes("Pods")) return;
|
|
4332
4439
|
if (!xcodeProjectFile(key)) return;
|
|
4333
4440
|
const project = loadProject(key);
|
|
4334
4441
|
projectAt.set(key, project);
|
|
@@ -4345,7 +4452,7 @@ function workspaceProjects(xcodeprojOrWorkspace) {
|
|
|
4345
4452
|
for (const reference of listed)
|
|
4346
4453
|
if (reference.endsWith(".xcodeproj")) addProject(reference);
|
|
4347
4454
|
if (projects2.length === 0) {
|
|
4348
|
-
throw new Error(`${
|
|
4455
|
+
throw new Error(`${import_node_path12.default.basename(xcodeprojOrWorkspace)} lists no Xcode project`);
|
|
4349
4456
|
}
|
|
4350
4457
|
return { listed, projects: projects2, projectAt };
|
|
4351
4458
|
}
|
|
@@ -4367,7 +4474,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
4367
4474
|
const allTargets = projects2.flatMap(nativeTargets);
|
|
4368
4475
|
const appTargets = allTargets.filter((ref) => ref.target.productType === APPLICATION);
|
|
4369
4476
|
const appTargetNames = appTargets.map((ref) => str(ref.target.name) ?? ref.id);
|
|
4370
|
-
const container =
|
|
4477
|
+
const container = import_node_path12.default.basename(xcodeprojOrWorkspace);
|
|
4371
4478
|
const named = targetName ? appTargets.filter((ref) => ref.target.name === targetName) : appTargets;
|
|
4372
4479
|
if (named.length !== 1) {
|
|
4373
4480
|
throw new Error(
|
|
@@ -4379,14 +4486,14 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
4379
4486
|
for (const ref of allTargets) {
|
|
4380
4487
|
const product = ref.project.object(str(ref.target.productReference));
|
|
4381
4488
|
const file = str(product?.path);
|
|
4382
|
-
if (file && !byProduct.has(
|
|
4383
|
-
byProduct.set(
|
|
4489
|
+
if (file && !byProduct.has(import_node_path12.default.basename(file)))
|
|
4490
|
+
byProduct.set(import_node_path12.default.basename(file), ref);
|
|
4384
4491
|
}
|
|
4385
4492
|
const proxied = (project, proxyId) => {
|
|
4386
4493
|
const proxy = project.object(proxyId);
|
|
4387
4494
|
if (proxy?.isa !== "PBXContainerItemProxy") return void 0;
|
|
4388
4495
|
const portal = str(proxy.containerPortal);
|
|
4389
|
-
const owner = project.object(portal)?.isa === "PBXProject" ? project : projectAt.get(
|
|
4496
|
+
const owner = project.object(portal)?.isa === "PBXProject" ? project : projectAt.get(import_node_path12.default.resolve(project.resolvePath(portal ?? "") ?? ""));
|
|
4390
4497
|
const remote = str(proxy.remoteGlobalIDString);
|
|
4391
4498
|
if (!owner || !remote) return void 0;
|
|
4392
4499
|
return nativeTargets(owner).find(
|
|
@@ -4407,7 +4514,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
4407
4514
|
if (phase?.isa !== "PBXFrameworksBuildPhase") continue;
|
|
4408
4515
|
for (const buildFileId of list(phase.files)) {
|
|
4409
4516
|
const file = project.object(str(project.object(buildFileId)?.fileRef));
|
|
4410
|
-
const resolved = file?.isa === "PBXReferenceProxy" ? proxied(project, str(file.remoteRef)) : file && str(file.sourceTree) === "BUILT_PRODUCTS_DIR" ? byProduct.get(
|
|
4517
|
+
const resolved = file?.isa === "PBXReferenceProxy" ? proxied(project, str(file.remoteRef)) : file && str(file.sourceTree) === "BUILT_PRODUCTS_DIR" ? byProduct.get(import_node_path12.default.basename(str(file.path) ?? "")) : void 0;
|
|
4411
4518
|
if (resolved) found.push(resolved);
|
|
4412
4519
|
}
|
|
4413
4520
|
}
|
|
@@ -4428,7 +4535,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
4428
4535
|
const name = str(ref.target.name) ?? ref.id;
|
|
4429
4536
|
const { get: settings2, keys } = targetSettings(ref, {
|
|
4430
4537
|
TARGET_NAME: name,
|
|
4431
|
-
PROJECT_NAME:
|
|
4538
|
+
PROJECT_NAME: import_node_path12.default.basename(ref.project.xcodeproj, ".xcodeproj"),
|
|
4432
4539
|
SRCROOT: ref.project.projectDir,
|
|
4433
4540
|
SOURCE_ROOT: ref.project.projectDir,
|
|
4434
4541
|
PROJECT_DIR: ref.project.projectDir,
|
|
@@ -4459,8 +4566,8 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
4459
4566
|
}
|
|
4460
4567
|
return value;
|
|
4461
4568
|
};
|
|
4462
|
-
const infoPlistFile = settings("INFOPLIST_FILE") ?
|
|
4463
|
-
const sourceInfo = infoPlistFile ? import_plist.default.parse(
|
|
4569
|
+
const infoPlistFile = settings("INFOPLIST_FILE") ? import_node_path12.default.resolve(app.project.projectDir, settings("INFOPLIST_FILE")) : null;
|
|
4570
|
+
const sourceInfo = infoPlistFile ? import_plist.default.parse(import_node_fs10.default.readFileSync(infoPlistFile, "utf8")) : {};
|
|
4464
4571
|
if (!sourceInfo || typeof sourceInfo !== "object" || Array.isArray(sourceInfo) || sourceInfo instanceof Date || Buffer.isBuffer(sourceInfo)) {
|
|
4465
4572
|
throw new Error(`${module2.name} Info.plist must contain a dictionary`);
|
|
4466
4573
|
}
|
|
@@ -4478,12 +4585,12 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
4478
4585
|
};
|
|
4479
4586
|
}
|
|
4480
4587
|
const localPackageDirs = [
|
|
4481
|
-
...listed.filter((reference) =>
|
|
4588
|
+
...listed.filter((reference) => import_node_fs10.default.existsSync(import_node_path12.default.join(reference, "Package.swift"))),
|
|
4482
4589
|
...projects2.flatMap(
|
|
4483
4590
|
(project) => Object.entries(project.objects).flatMap(([id, entry]) => {
|
|
4484
4591
|
if (!isDict(entry)) return [];
|
|
4485
|
-
const candidate = entry.isa === "XCLocalSwiftPackageReference" ?
|
|
4486
|
-
return candidate &&
|
|
4592
|
+
const candidate = entry.isa === "XCLocalSwiftPackageReference" ? import_node_path12.default.resolve(project.projectDir, str(entry.relativePath) ?? "") : entry.isa === "PBXFileReference" ? project.resolvePath(id) : null;
|
|
4593
|
+
return candidate && import_node_fs10.default.existsSync(import_node_path12.default.join(candidate, "Package.swift")) ? [candidate] : [];
|
|
4487
4594
|
})
|
|
4488
4595
|
)
|
|
4489
4596
|
];
|
|
@@ -4507,7 +4614,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
4507
4614
|
product,
|
|
4508
4615
|
source: reference?.isa === "XCRemoteSwiftPackageReference" ? { kind: "remote", url: str(reference.repositoryURL) ?? "" } : reference?.isa === "XCLocalSwiftPackageReference" ? {
|
|
4509
4616
|
kind: "local",
|
|
4510
|
-
dir:
|
|
4617
|
+
dir: import_node_path12.default.resolve(
|
|
4511
4618
|
project.projectDir,
|
|
4512
4619
|
str(reference.relativePath) ?? ""
|
|
4513
4620
|
)
|
|
@@ -4529,8 +4636,8 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
4529
4636
|
}
|
|
4530
4637
|
}
|
|
4531
4638
|
}
|
|
4532
|
-
const resolvedFile =
|
|
4533
|
-
workspace ??
|
|
4639
|
+
const resolvedFile = import_node_path12.default.join(
|
|
4640
|
+
workspace ?? import_node_path12.default.join(xcodeprojOrWorkspace, "project.xcworkspace"),
|
|
4534
4641
|
"xcshareddata",
|
|
4535
4642
|
"swiftpm",
|
|
4536
4643
|
"Package.resolved"
|
|
@@ -4540,13 +4647,13 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
4540
4647
|
...module2,
|
|
4541
4648
|
rootDir: commonAncestor(
|
|
4542
4649
|
[
|
|
4543
|
-
workspace ?
|
|
4650
|
+
workspace ? import_node_path12.default.dirname(workspace) : app.project.projectDir,
|
|
4544
4651
|
...used.map((project) => project.projectDir),
|
|
4545
4652
|
...localPackageDirs,
|
|
4546
4653
|
...linkedProducts.flatMap(
|
|
4547
|
-
({ source }) => source.kind === "local" &&
|
|
4654
|
+
({ source }) => source.kind === "local" && import_node_fs10.default.existsSync(source.dir) ? [source.dir] : []
|
|
4548
4655
|
)
|
|
4549
|
-
].map((dir) =>
|
|
4656
|
+
].map((dir) => import_node_fs10.default.realpathSync(dir))
|
|
4550
4657
|
),
|
|
4551
4658
|
projectFiles: [...new Set(used.map((project) => project.projectFile))].sort(),
|
|
4552
4659
|
infoPlist: import_plist.default.build(info),
|
|
@@ -4554,10 +4661,10 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
4554
4661
|
frameworks,
|
|
4555
4662
|
linkedProducts,
|
|
4556
4663
|
localPackageDirs: [
|
|
4557
|
-
...new Set(localPackageDirs.map((dir) =>
|
|
4664
|
+
...new Set(localPackageDirs.map((dir) => import_node_fs10.default.realpathSync(dir)))
|
|
4558
4665
|
].sort(),
|
|
4559
4666
|
binaryFrameworks: [...binaryFrameworks].sort(),
|
|
4560
|
-
packageResolved:
|
|
4667
|
+
packageResolved: import_node_fs10.default.existsSync(resolvedFile) ? resolvedFile : null,
|
|
4561
4668
|
appTargets: appTargetNames
|
|
4562
4669
|
};
|
|
4563
4670
|
}
|
|
@@ -4577,17 +4684,17 @@ var SKIP_SOURCE_DIRS = /* @__PURE__ */ new Set([
|
|
|
4577
4684
|
var NATIVE_DESCRIPTOR = ".one-native-source.json";
|
|
4578
4685
|
var NATIVE_GLUE = ".one-native-source.swift.txt";
|
|
4579
4686
|
function swiftPackageId(packagePath) {
|
|
4580
|
-
return
|
|
4687
|
+
return import_node_path13.default.basename(packagePath).replace(/[^A-Za-z0-9_]/g, "_").replace(/^(\d)/, "_$1");
|
|
4581
4688
|
}
|
|
4582
4689
|
function nativeSourceDescriptor(packagePath) {
|
|
4583
|
-
packagePath =
|
|
4584
|
-
const file =
|
|
4585
|
-
if (!
|
|
4690
|
+
packagePath = import_node_fs11.default.realpathSync(packagePath);
|
|
4691
|
+
const file = import_node_path13.default.join(packagePath, NATIVE_DESCRIPTOR);
|
|
4692
|
+
if (!import_node_fs11.default.existsSync(file)) return null;
|
|
4586
4693
|
const value = JSON.parse(
|
|
4587
4694
|
readPackageFile(packagePath, file, MAX_SWIFT_COMPILE_SOURCE_BYTES).toString("utf8")
|
|
4588
4695
|
);
|
|
4589
4696
|
const invalid = () => new Error(`${file}: invalid One native source descriptor; run one typegen`);
|
|
4590
|
-
if (!value || typeof value !== "object" || Reflect.get(value, "generatedBy") !== "one typegen" || !
|
|
4697
|
+
if (!value || typeof value !== "object" || Reflect.get(value, "generatedBy") !== "one typegen" || !import_node_fs11.default.existsSync(import_node_path13.default.join(packagePath, NATIVE_GLUE))) {
|
|
4591
4698
|
throw invalid();
|
|
4592
4699
|
}
|
|
4593
4700
|
if (!isSwiftNativeModules(value) || value.packageId !== swiftPackageId(packagePath)) {
|
|
@@ -4596,12 +4703,12 @@ function nativeSourceDescriptor(packagePath) {
|
|
|
4596
4703
|
return value;
|
|
4597
4704
|
}
|
|
4598
4705
|
function nativeSourceFiles(packagePath) {
|
|
4599
|
-
packagePath =
|
|
4600
|
-
return [NATIVE_DESCRIPTOR, NATIVE_GLUE].map((name) =>
|
|
4706
|
+
packagePath = import_node_fs11.default.realpathSync(packagePath);
|
|
4707
|
+
return [NATIVE_DESCRIPTOR, NATIVE_GLUE].map((name) => import_node_path13.default.join(packagePath, name)).filter((file) => import_node_fs11.default.existsSync(file));
|
|
4601
4708
|
}
|
|
4602
4709
|
var projects = /* @__PURE__ */ new Map();
|
|
4603
4710
|
function projectFor(packagePath, hosted) {
|
|
4604
|
-
packagePath =
|
|
4711
|
+
packagePath = import_node_fs11.default.realpathSync(packagePath);
|
|
4605
4712
|
const existing = projects.get(packagePath);
|
|
4606
4713
|
if (existing) {
|
|
4607
4714
|
if (hosted && !existing.hosted) {
|
|
@@ -4623,14 +4730,14 @@ function projectFor(packagePath, hosted) {
|
|
|
4623
4730
|
}
|
|
4624
4731
|
var xcodeProjects = /* @__PURE__ */ new Map();
|
|
4625
4732
|
function swiftPackages(entry, app) {
|
|
4626
|
-
const stamp = (file) => file &&
|
|
4733
|
+
const stamp = (file) => file && import_node_fs11.default.existsSync(file) ? import_node_fs11.default.statSync(file).mtimeMs : 0;
|
|
4627
4734
|
const key = JSON.stringify([
|
|
4628
4735
|
app.linkedProducts,
|
|
4629
4736
|
app.packageResolved,
|
|
4630
4737
|
stamp(app.packageResolved),
|
|
4631
|
-
app.localPackageDirs.map((dir) => stamp(
|
|
4738
|
+
app.localPackageDirs.map((dir) => stamp(import_node_path13.default.join(dir, "Package.swift"))),
|
|
4632
4739
|
app.linkedProducts.map(
|
|
4633
|
-
({ source }) => source.kind === "local" ? stamp(
|
|
4740
|
+
({ source }) => source.kind === "local" ? stamp(import_node_path13.default.join(source.dir, "Package.swift")) : 0
|
|
4634
4741
|
)
|
|
4635
4742
|
]);
|
|
4636
4743
|
if (entry.packages?.key !== key) {
|
|
@@ -4650,11 +4757,11 @@ function swiftPackages(entry, app) {
|
|
|
4650
4757
|
var XCODE_APP_DIR = "__app__";
|
|
4651
4758
|
var XCODE_FRAMEWORKS_DIR = "__frameworks__";
|
|
4652
4759
|
var XCODE_PACKAGES_DIR = "__packages__";
|
|
4653
|
-
var CHECKOUTS_PREFIX = `${REMOTE_CHECKOUTS.split(
|
|
4760
|
+
var CHECKOUTS_PREFIX = `${REMOTE_CHECKOUTS.split(import_node_path13.default.sep).join(import_node_path13.default.posix.sep)}/`;
|
|
4654
4761
|
function xcodeInputKey(layout, file, relative) {
|
|
4655
4762
|
const owner = layout.targetDirs.get(file);
|
|
4656
|
-
if (owner) return
|
|
4657
|
-
return relative.startsWith(CHECKOUTS_PREFIX) ?
|
|
4763
|
+
if (owner) return import_node_path13.default.posix.join(owner, relative);
|
|
4764
|
+
return relative.startsWith(CHECKOUTS_PREFIX) ? import_node_path13.default.posix.join(XCODE_PACKAGES_DIR, relative.slice(CHECKOUTS_PREFIX.length)) : relative;
|
|
4658
4765
|
}
|
|
4659
4766
|
function xcodeLayout(root) {
|
|
4660
4767
|
const registered = xcodeProjects.get(root);
|
|
@@ -4665,7 +4772,7 @@ function xcodeLayout(root) {
|
|
|
4665
4772
|
const targetDirs = new Map(app.sources.map((file) => [file, XCODE_APP_DIR]));
|
|
4666
4773
|
const targets = [];
|
|
4667
4774
|
for (const framework of app.frameworks) {
|
|
4668
|
-
const dir =
|
|
4775
|
+
const dir = import_node_path13.default.posix.join(XCODE_FRAMEWORKS_DIR, framework.moduleName);
|
|
4669
4776
|
for (const file of framework.sources) {
|
|
4670
4777
|
if (targetDirs.has(file)) continue;
|
|
4671
4778
|
targetDirs.set(file, dir);
|
|
@@ -4683,19 +4790,19 @@ function xcodeLayout(root) {
|
|
|
4683
4790
|
}
|
|
4684
4791
|
const packages = swiftPackages(registered, app);
|
|
4685
4792
|
for (const target of packages.targets) {
|
|
4686
|
-
const relative =
|
|
4687
|
-
target.remote ?
|
|
4793
|
+
const relative = import_node_path13.default.relative(
|
|
4794
|
+
target.remote ? import_node_path13.default.join(root, REMOTE_CHECKOUTS) : root,
|
|
4688
4795
|
target.dir
|
|
4689
4796
|
);
|
|
4690
|
-
if (relative === ".." || relative.startsWith(`..${
|
|
4797
|
+
if (relative === ".." || relative.startsWith(`..${import_node_path13.default.sep}`) || import_node_path13.default.isAbsolute(relative))
|
|
4691
4798
|
throw new Error(`swift input escapes the selected package: ${target.dir}`);
|
|
4692
|
-
const posix = relative.split(
|
|
4799
|
+
const posix = relative.split(import_node_path13.default.sep).join(import_node_path13.default.posix.sep);
|
|
4693
4800
|
targets.push({
|
|
4694
4801
|
...target,
|
|
4695
|
-
path: target.remote ?
|
|
4802
|
+
path: target.remote ? import_node_path13.default.posix.join(XCODE_PACKAGES_DIR, posix) : posix,
|
|
4696
4803
|
exclude: []
|
|
4697
4804
|
});
|
|
4698
|
-
if (!target.remote) files.add(
|
|
4805
|
+
if (!target.remote) files.add(import_node_path13.default.join(target.packageDir, "Package.swift"));
|
|
4699
4806
|
for (const file of target.files) files.add(file);
|
|
4700
4807
|
}
|
|
4701
4808
|
for (const target of targets) {
|
|
@@ -4724,25 +4831,25 @@ function xcodeManifest(layout) {
|
|
|
4724
4831
|
].join("\n");
|
|
4725
4832
|
}
|
|
4726
4833
|
function packageFiles(root) {
|
|
4727
|
-
const canonicalRoot =
|
|
4834
|
+
const canonicalRoot = import_node_fs11.default.realpathSync(root);
|
|
4728
4835
|
const xcode = xcodeLayout(canonicalRoot);
|
|
4729
4836
|
return xcode ? xcode.files : sourceTreeFiles(canonicalRoot, canonicalRoot);
|
|
4730
4837
|
}
|
|
4731
4838
|
function sourceTreeFiles(dir, canonicalRoot) {
|
|
4732
4839
|
const found = [];
|
|
4733
4840
|
const walk2 = (dir2) => {
|
|
4734
|
-
for (const entry of
|
|
4841
|
+
for (const entry of import_node_fs11.default.readdirSync(dir2, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
|
|
4735
4842
|
if (entry.name.startsWith(".") && entry.name !== NATIVE_DESCRIPTOR && entry.name !== NATIVE_GLUE || SKIP_SOURCE_DIRS.has(entry.name))
|
|
4736
4843
|
continue;
|
|
4737
|
-
const full =
|
|
4844
|
+
const full = import_node_path13.default.join(dir2, entry.name);
|
|
4738
4845
|
if (entry.isSymbolicLink()) throw new Error(`swift input is a symlink: ${full}`);
|
|
4739
|
-
const real =
|
|
4740
|
-
const relative =
|
|
4741
|
-
if (relative.startsWith(`..${
|
|
4846
|
+
const real = import_node_fs11.default.realpathSync(full);
|
|
4847
|
+
const relative = import_node_path13.default.relative(canonicalRoot, real);
|
|
4848
|
+
if (relative.startsWith(`..${import_node_path13.default.sep}`) || relative === ".." || import_node_path13.default.isAbsolute(relative)) {
|
|
4742
4849
|
throw new Error(`swift input escapes the selected package: ${full}`);
|
|
4743
4850
|
}
|
|
4744
4851
|
if (entry.isDirectory()) {
|
|
4745
|
-
if (
|
|
4852
|
+
if (import_node_fs11.default.existsSync(import_node_path13.default.join(full, "Package.swift"))) continue;
|
|
4746
4853
|
walk2(full);
|
|
4747
4854
|
} else if (entry.isFile()) {
|
|
4748
4855
|
found.push(full);
|
|
@@ -4750,29 +4857,29 @@ function sourceTreeFiles(dir, canonicalRoot) {
|
|
|
4750
4857
|
}
|
|
4751
4858
|
}
|
|
4752
4859
|
};
|
|
4753
|
-
if (
|
|
4860
|
+
if (import_node_fs11.default.existsSync(dir)) walk2(import_node_fs11.default.realpathSync(dir));
|
|
4754
4861
|
return found;
|
|
4755
4862
|
}
|
|
4756
4863
|
function readPackageFile(root, file, maxBytes) {
|
|
4757
|
-
const canonicalRoot =
|
|
4758
|
-
const relative =
|
|
4759
|
-
if (relative === ".." || relative.startsWith(`..${
|
|
4864
|
+
const canonicalRoot = import_node_fs11.default.realpathSync(root);
|
|
4865
|
+
const relative = import_node_path13.default.relative(canonicalRoot, import_node_fs11.default.realpathSync(file));
|
|
4866
|
+
if (relative === ".." || relative.startsWith(`..${import_node_path13.default.sep}`) || import_node_path13.default.isAbsolute(relative)) {
|
|
4760
4867
|
throw new Error(`swift input escapes the selected package: ${file}`);
|
|
4761
4868
|
}
|
|
4762
|
-
let ancestor =
|
|
4869
|
+
let ancestor = import_node_path13.default.resolve(file);
|
|
4763
4870
|
while (ancestor !== canonicalRoot) {
|
|
4764
|
-
if (
|
|
4871
|
+
if (import_node_fs11.default.lstatSync(ancestor).isSymbolicLink()) {
|
|
4765
4872
|
throw new Error(`swift input is a symlink: ${ancestor}`);
|
|
4766
4873
|
}
|
|
4767
|
-
const parent =
|
|
4874
|
+
const parent = import_node_path13.default.dirname(ancestor);
|
|
4768
4875
|
if (parent === ancestor)
|
|
4769
4876
|
throw new Error(`swift input escapes the selected package: ${file}`);
|
|
4770
4877
|
ancestor = parent;
|
|
4771
4878
|
}
|
|
4772
|
-
const expected =
|
|
4773
|
-
const fd =
|
|
4879
|
+
const expected = import_node_fs11.default.statSync(file);
|
|
4880
|
+
const fd = import_node_fs11.default.openSync(file, import_node_fs11.default.constants.O_RDONLY | import_node_fs11.default.constants.O_NOFOLLOW);
|
|
4774
4881
|
try {
|
|
4775
|
-
const stat =
|
|
4882
|
+
const stat = import_node_fs11.default.fstatSync(fd);
|
|
4776
4883
|
if (stat.dev !== expected.dev || stat.ino !== expected.ino) {
|
|
4777
4884
|
throw new Error(`swift input changed while opening: ${file}`);
|
|
4778
4885
|
}
|
|
@@ -4782,16 +4889,16 @@ function readPackageFile(root, file, maxBytes) {
|
|
|
4782
4889
|
const bytes = Buffer.alloc(stat.size + 1);
|
|
4783
4890
|
let offset = 0;
|
|
4784
4891
|
while (offset < bytes.length) {
|
|
4785
|
-
const count =
|
|
4892
|
+
const count = import_node_fs11.default.readSync(fd, bytes, offset, bytes.length - offset, null);
|
|
4786
4893
|
if (count === 0) break;
|
|
4787
4894
|
offset += count;
|
|
4788
4895
|
}
|
|
4789
|
-
if (offset !== stat.size ||
|
|
4896
|
+
if (offset !== stat.size || import_node_fs11.default.fstatSync(fd).size !== stat.size) {
|
|
4790
4897
|
throw new Error(`swift input changed while reading: ${file}`);
|
|
4791
4898
|
}
|
|
4792
4899
|
return bytes.subarray(0, offset);
|
|
4793
4900
|
} finally {
|
|
4794
|
-
|
|
4901
|
+
import_node_fs11.default.closeSync(fd);
|
|
4795
4902
|
}
|
|
4796
4903
|
}
|
|
4797
4904
|
function sourceFiles(root) {
|
|
@@ -4799,7 +4906,7 @@ function sourceFiles(root) {
|
|
|
4799
4906
|
}
|
|
4800
4907
|
function resourceCandidateFiles(root) {
|
|
4801
4908
|
return packageFiles(root).filter(
|
|
4802
|
-
(file) => !file.endsWith(".swift") && !["project.pbxproj", "project.xcproj"].includes(
|
|
4909
|
+
(file) => !file.endsWith(".swift") && !["project.pbxproj", "project.xcproj"].includes(import_node_path13.default.basename(file))
|
|
4803
4910
|
);
|
|
4804
4911
|
}
|
|
4805
4912
|
var HOSTED_LIMITS = {
|
|
@@ -4833,7 +4940,7 @@ function buildSwiftResourceTable(project, baseUrl) {
|
|
|
4833
4940
|
const limits = inputLimits(Boolean(project.hosted));
|
|
4834
4941
|
const absolute = resourceCandidateFiles(project.packagePath);
|
|
4835
4942
|
const relative = absolute.map(
|
|
4836
|
-
(file) =>
|
|
4943
|
+
(file) => import_node_path13.default.relative(project.packagePath, file).split(import_node_path13.default.sep).join(import_node_path13.default.posix.sep)
|
|
4837
4944
|
);
|
|
4838
4945
|
const byRelative = new Map(absolute.map((file, index) => [relative[index], file]));
|
|
4839
4946
|
const readContents = (candidate) => {
|
|
@@ -4855,16 +4962,16 @@ function buildSwiftResourceTable(project, baseUrl) {
|
|
|
4855
4962
|
for (const { name, file, scale } of found) {
|
|
4856
4963
|
const disk = byRelative.get(file);
|
|
4857
4964
|
if (!disk) continue;
|
|
4858
|
-
if (Object.keys(images).length >= limits.images || imageBytes +
|
|
4965
|
+
if (Object.keys(images).length >= limits.images || imageBytes + import_node_fs11.default.statSync(disk).size > limits.imageTotalBytes) {
|
|
4859
4966
|
throw new Error("swift image pack exceeds the compile service caps");
|
|
4860
4967
|
}
|
|
4861
4968
|
const bytes = readPackageFile(project.packagePath, disk, limits.imageBytes);
|
|
4862
4969
|
imageBytes += bytes.length;
|
|
4863
|
-
const hash = (0,
|
|
4864
|
-
const ext =
|
|
4970
|
+
const hash = (0, import_node_crypto6.createHash)("sha256").update(bytes).digest("hex").slice(0, 16);
|
|
4971
|
+
const ext = import_node_path13.default.posix.extname(file).toLowerCase();
|
|
4865
4972
|
table[name] = { uri: `${baseUrl}${RESOURCE_PATH}${hash}${ext}`, scale };
|
|
4866
4973
|
images[name] = {
|
|
4867
|
-
file:
|
|
4974
|
+
file: import_node_path13.default.posix.basename(file),
|
|
4868
4975
|
data: bytes.toString("base64")
|
|
4869
4976
|
};
|
|
4870
4977
|
watched.push(file);
|
|
@@ -4888,10 +4995,10 @@ function buildSwiftResourceTable(project, baseUrl) {
|
|
|
4888
4995
|
return { table, images, colors, symbols, watched };
|
|
4889
4996
|
}
|
|
4890
4997
|
function buildSwiftBundleFiles(packagePath, hosted) {
|
|
4891
|
-
packagePath =
|
|
4998
|
+
packagePath = import_node_fs11.default.realpathSync(packagePath);
|
|
4892
4999
|
const limits = inputLimits(hosted);
|
|
4893
5000
|
const relative = resourceCandidateFiles(packagePath).map(
|
|
4894
|
-
(file) =>
|
|
5001
|
+
(file) => import_node_path13.default.relative(packagePath, file).split(import_node_path13.default.sep).join(import_node_path13.default.posix.sep)
|
|
4895
5002
|
);
|
|
4896
5003
|
const files = {};
|
|
4897
5004
|
const watched = [];
|
|
@@ -4905,13 +5012,13 @@ function buildSwiftBundleFiles(packagePath, hosted) {
|
|
|
4905
5012
|
total += bytes.length;
|
|
4906
5013
|
if (xcode.app.infoPlistFile)
|
|
4907
5014
|
watched.push(
|
|
4908
|
-
|
|
5015
|
+
import_node_path13.default.relative(packagePath, xcode.app.infoPlistFile).split(import_node_path13.default.sep).join("/")
|
|
4909
5016
|
);
|
|
4910
5017
|
}
|
|
4911
5018
|
for (const { base, file } of enumerateBundleJson(relative)) {
|
|
4912
5019
|
watched.push(file);
|
|
4913
|
-
const disk =
|
|
4914
|
-
if (Object.keys(files).length >= limits.resources || total +
|
|
5020
|
+
const disk = import_node_path13.default.join(packagePath, ...file.split("/"));
|
|
5021
|
+
if (Object.keys(files).length >= limits.resources || total + import_node_fs11.default.statSync(disk).size > limits.resourceTotalBytes) {
|
|
4915
5022
|
throw new Error(
|
|
4916
5023
|
`swift bundle pack exceeds ${limits.resources} files / ${limits.resourceTotalBytes} bytes`
|
|
4917
5024
|
);
|
|
@@ -4926,12 +5033,12 @@ function serveSwiftResource(project, key) {
|
|
|
4926
5033
|
return project.resourceFiles.get(key) ?? project.resourcesPrevious.get(key) ?? null;
|
|
4927
5034
|
}
|
|
4928
5035
|
function linkedModuleRoots(packagePath) {
|
|
4929
|
-
packagePath =
|
|
5036
|
+
packagePath = import_node_fs11.default.realpathSync(packagePath);
|
|
4930
5037
|
let manifest;
|
|
4931
5038
|
try {
|
|
4932
5039
|
manifest = readPackageFile(
|
|
4933
5040
|
packagePath,
|
|
4934
|
-
|
|
5041
|
+
import_node_path13.default.join(packagePath, "Package.swift"),
|
|
4935
5042
|
MAX_SWIFT_COMPILE_SOURCE_BYTES
|
|
4936
5043
|
).toString("utf8");
|
|
4937
5044
|
} catch {
|
|
@@ -4940,35 +5047,35 @@ function linkedModuleRoots(packagePath) {
|
|
|
4940
5047
|
const roots = /* @__PURE__ */ new Set();
|
|
4941
5048
|
const dependency = /\.package\(\s*path:\s*"([^"]+)"\s*\)/g;
|
|
4942
5049
|
for (const match of manifest.replace(/^\s*\/\/.*$/gm, "").matchAll(dependency)) {
|
|
4943
|
-
const root =
|
|
4944
|
-
if (
|
|
5050
|
+
const root = import_node_path13.default.resolve(packagePath, match[1]);
|
|
5051
|
+
if (import_node_fs11.default.existsSync(import_node_path13.default.join(root, "Package.swift"))) roots.add(root);
|
|
4945
5052
|
}
|
|
4946
5053
|
return [...roots].sort();
|
|
4947
5054
|
}
|
|
4948
5055
|
function sourceStamp(packagePath, moduleRootOverride, hosted = false) {
|
|
4949
|
-
const hash = (0,
|
|
5056
|
+
const hash = (0, import_node_crypto6.createHash)("sha256");
|
|
4950
5057
|
hash.update(packagePath);
|
|
4951
5058
|
const projectInputs = new Set(packageFiles(packagePath));
|
|
4952
5059
|
for (const file of [...projectInputs].sort()) {
|
|
4953
|
-
hash.update(
|
|
4954
|
-
const stat =
|
|
5060
|
+
hash.update(import_node_path13.default.relative(packagePath, file));
|
|
5061
|
+
const stat = import_node_fs11.default.statSync(file);
|
|
4955
5062
|
hash.update(`${stat.mtimeMs}/${stat.ctimeMs}/${stat.size}`);
|
|
4956
5063
|
}
|
|
4957
5064
|
const moduleRoot = hosted ? void 0 : moduleRootOverride ?? linkedModuleRoots(packagePath).find(
|
|
4958
|
-
(root) =>
|
|
5065
|
+
(root) => import_node_fs11.default.existsSync(import_node_path13.default.join(root, "toolchain.json"))
|
|
4959
5066
|
);
|
|
4960
5067
|
if (moduleRoot) {
|
|
4961
5068
|
hash.update(moduleRoot);
|
|
4962
5069
|
for (const relative of swiftModuleInputFiles(moduleRoot)) {
|
|
4963
5070
|
hash.update(relative);
|
|
4964
|
-
hash.update(String(
|
|
5071
|
+
hash.update(String(import_node_fs11.default.statSync(import_node_path13.default.join(moduleRoot, relative)).mtimeMs));
|
|
4965
5072
|
}
|
|
4966
5073
|
}
|
|
4967
5074
|
return hash.digest("hex").slice(0, 16);
|
|
4968
5075
|
}
|
|
4969
5076
|
function entryRootId(packagePath, file) {
|
|
4970
|
-
const relative =
|
|
4971
|
-
return `${
|
|
5077
|
+
const relative = import_node_path13.default.relative(packagePath, file).split(import_node_path13.default.sep).join(import_node_path13.default.posix.sep);
|
|
5078
|
+
return `${import_node_path13.default.basename(packagePath)}${import_node_path13.default.posix.sep}${relative}`;
|
|
4972
5079
|
}
|
|
4973
5080
|
function icuUrl(origin, artifact) {
|
|
4974
5081
|
return "url" in artifact.icu ? artifact.icu.url : `${origin}${ICU_PATH}${artifact.icu.sha256}`;
|
|
@@ -4977,8 +5084,8 @@ function packageSources(packagePath) {
|
|
|
4977
5084
|
const xcode = xcodeLayout(packagePath);
|
|
4978
5085
|
const files = {};
|
|
4979
5086
|
for (const file of sourceFiles(packagePath)) {
|
|
4980
|
-
const relative =
|
|
4981
|
-
if (xcode &&
|
|
5087
|
+
const relative = import_node_path13.default.relative(packagePath, file).split(import_node_path13.default.sep).join(import_node_path13.default.posix.sep);
|
|
5088
|
+
if (xcode && import_node_path13.default.basename(file) === "Package.swift") continue;
|
|
4982
5089
|
files[xcode ? xcodeInputKey(xcode, file, relative) : relative] = readPackageFile(
|
|
4983
5090
|
packagePath,
|
|
4984
5091
|
file,
|
|
@@ -4995,7 +5102,7 @@ function packageSnapshot(project) {
|
|
|
4995
5102
|
files,
|
|
4996
5103
|
resourcePaths: swiftImplicitResourcePaths(
|
|
4997
5104
|
resourceCandidateFiles(project.packagePath).map(
|
|
4998
|
-
(file) =>
|
|
5105
|
+
(file) => import_node_path13.default.relative(project.packagePath, file).split(import_node_path13.default.sep).join(import_node_path13.default.posix.sep)
|
|
4999
5106
|
)
|
|
5000
5107
|
),
|
|
5001
5108
|
resources: buildSwiftResourceTable(project, ""),
|
|
@@ -5004,7 +5111,7 @@ function packageSnapshot(project) {
|
|
|
5004
5111
|
...native ? {
|
|
5005
5112
|
glue: readPackageFile(
|
|
5006
5113
|
project.packagePath,
|
|
5007
|
-
|
|
5114
|
+
import_node_path13.default.join(project.packagePath, NATIVE_GLUE),
|
|
5008
5115
|
MAX_SWIFT_COMPILE_SOURCE_BYTES
|
|
5009
5116
|
).toString("utf8")
|
|
5010
5117
|
} : {}
|
|
@@ -5043,7 +5150,7 @@ async function compile(packagePath, entry, stamp, moduleRootOverride, hosted, sn
|
|
|
5043
5150
|
package: content
|
|
5044
5151
|
};
|
|
5045
5152
|
const moduleRoot = moduleRootOverride ?? linkedModuleRoots(packagePath).find(
|
|
5046
|
-
(root) =>
|
|
5153
|
+
(root) => import_node_fs11.default.existsSync(import_node_path13.default.join(root, "toolchain.json"))
|
|
5047
5154
|
) ?? await swiftDistributionRoot();
|
|
5048
5155
|
if (!moduleRoot)
|
|
5049
5156
|
return {
|
|
@@ -5062,17 +5169,17 @@ async function compile(packagePath, entry, stamp, moduleRootOverride, hosted, sn
|
|
|
5062
5169
|
...targets.length > 0 ? targets : ["App"]
|
|
5063
5170
|
])
|
|
5064
5171
|
);
|
|
5065
|
-
if (missing.size > 0) throw new Error(missingModulesMessage(packagePath, missing));
|
|
5172
|
+
if (missing.size > 0) throw new Error(await missingModulesMessage(packagePath, missing));
|
|
5066
5173
|
const artifact = await compileSwiftProjectUnit(input, {
|
|
5067
5174
|
// the compile rewrites Sources/App in its root before swiftpm builds, and
|
|
5068
5175
|
// its lock orders one process only: two vites on one root (a lane's dev
|
|
5069
5176
|
// server and a capture, or two checkouts) build each other's sources. so
|
|
5070
5177
|
// each app and module checkout gets its own root, which keeps the same
|
|
5071
5178
|
// app's incremental build across restarts.
|
|
5072
|
-
buildRoot: process.env.CONTRAST_SWIFT_BUILD_ROOT ??
|
|
5073
|
-
|
|
5179
|
+
buildRoot: process.env.CONTRAST_SWIFT_BUILD_ROOT ?? import_node_path13.default.join(
|
|
5180
|
+
import_node_os7.default.tmpdir(),
|
|
5074
5181
|
"contrast-swift-build",
|
|
5075
|
-
(0,
|
|
5182
|
+
(0, import_node_crypto6.createHash)("sha256").update(`${moduleRoot}\0${import_node_path13.default.resolve(packagePath)}`).digest("hex").slice(0, 16)
|
|
5076
5183
|
),
|
|
5077
5184
|
moduleRoot,
|
|
5078
5185
|
...toolchain
|
|
@@ -5140,7 +5247,7 @@ var UNPROVIDED_PLATFORM_MODULES = {
|
|
|
5140
5247
|
MachO: "Peach compiles for WebAssembly, which has no Mach-O images"
|
|
5141
5248
|
};
|
|
5142
5249
|
var IOS_SDK_FRAMEWORKS = new Set(ios_sdk_frameworks_default.frameworks);
|
|
5143
|
-
function missingModulesMessage(packagePath, missing) {
|
|
5250
|
+
async function missingModulesMessage(packagePath, missing) {
|
|
5144
5251
|
const layout = xcodeLayout(packagePath);
|
|
5145
5252
|
const gaps = new Map([
|
|
5146
5253
|
...(layout?.app.binaryFrameworks ?? []).map(
|
|
@@ -5162,12 +5269,29 @@ function missingModulesMessage(packagePath, missing) {
|
|
|
5162
5269
|
...layout?.packages.modules ?? [],
|
|
5163
5270
|
...layout?.packages.unavailable ?? []
|
|
5164
5271
|
]);
|
|
5272
|
+
const packaged = new Set(
|
|
5273
|
+
[...missing.keys()].filter(
|
|
5274
|
+
(name) => !UNPROVIDED_PLATFORM_MODULES[name] && !IOS_SDK_FRAMEWORKS.has(name)
|
|
5275
|
+
)
|
|
5276
|
+
);
|
|
5277
|
+
if (packaged.size > 0)
|
|
5278
|
+
await Promise.all(
|
|
5279
|
+
(layout?.packages.binaries ?? []).map(async (binary) => {
|
|
5280
|
+
const modules = await swiftBinaryModules(binary).catch(() => []);
|
|
5281
|
+
for (const name of modules)
|
|
5282
|
+
if (packaged.has(name))
|
|
5283
|
+
gaps.set(name, {
|
|
5284
|
+
source: binary.source,
|
|
5285
|
+
reason: `${binary.target} is a binary framework`
|
|
5286
|
+
});
|
|
5287
|
+
})
|
|
5288
|
+
);
|
|
5165
5289
|
const width = Math.max(...[...missing.keys()].map((name) => name.length));
|
|
5166
5290
|
return [
|
|
5167
5291
|
`Peach does not provide ${missing.size} module${missing.size === 1 ? "" : "s"} this app imports:`,
|
|
5168
5292
|
...[...missing].map(([name, files]) => {
|
|
5169
5293
|
const gap = gaps.get(name);
|
|
5170
|
-
return ` ${name.padEnd(width)} ${files.length} file${files.length === 1 ? "" : "s"}${gap ? `, ${gap.source.includes("://") ? `package ${gap.source}` : gap.source.startsWith("/") ? `package ${
|
|
5294
|
+
return ` ${name.padEnd(width)} ${files.length} file${files.length === 1 ? "" : "s"}${gap ? `, ${gap.source.includes("://") ? `package ${gap.source}` : gap.source.startsWith("/") ? `package ${import_node_path13.default.relative(packagePath, gap.source) || "."}` : gap.source} (${gap.reason})` : ""}`;
|
|
5171
5295
|
})
|
|
5172
5296
|
].join("\n");
|
|
5173
5297
|
}
|
|
@@ -5175,7 +5299,7 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
|
|
|
5175
5299
|
const auth = hosted ? null : resolveCliAuth();
|
|
5176
5300
|
if (!hosted && (!auth || auth.kind === "github")) {
|
|
5177
5301
|
throw new Error(
|
|
5178
|
-
`compiling ${
|
|
5302
|
+
`compiling ${import_node_path13.default.basename(packagePath)} for Peach needs \`peach login\` or PEACH_API_KEY: this peachsim has no local SwiftUI module, so Contrast compiles it`
|
|
5179
5303
|
);
|
|
5180
5304
|
}
|
|
5181
5305
|
const origin = hosted?.origin ?? resolveContrastBackendOrigin(auth?.kind === "session" ? auth.origin : null);
|
|
@@ -5194,7 +5318,7 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
|
|
|
5194
5318
|
const bytes = sources.reduce((total2, text2) => total2 + Buffer.byteLength(text2), 0);
|
|
5195
5319
|
if (sources.length > MAX_SWIFT_COMPILE_FILES || bytes > MAX_SWIFT_COMPILE_SOURCE_BYTES) {
|
|
5196
5320
|
throw new Error(
|
|
5197
|
-
`${
|
|
5321
|
+
`${import_node_path13.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`
|
|
5198
5322
|
);
|
|
5199
5323
|
}
|
|
5200
5324
|
const descriptor = snapshot.native;
|
|
@@ -5213,7 +5337,7 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
|
|
|
5213
5337
|
);
|
|
5214
5338
|
if (descriptor && address.native?.hash !== descriptor.hash) {
|
|
5215
5339
|
throw new Error(
|
|
5216
|
-
`${
|
|
5340
|
+
`${import_node_path13.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`
|
|
5217
5341
|
);
|
|
5218
5342
|
}
|
|
5219
5343
|
const response = await fetch(address.url, { signal });
|
|
@@ -5286,17 +5410,17 @@ function artifactFor(project, entry, moduleRoot) {
|
|
|
5286
5410
|
return fresh;
|
|
5287
5411
|
}
|
|
5288
5412
|
function swiftPackageWatchFiles(packagePath, moduleRoot) {
|
|
5289
|
-
packagePath =
|
|
5413
|
+
packagePath = import_node_fs11.default.realpathSync(packagePath);
|
|
5290
5414
|
return [
|
|
5291
|
-
...xcodeProjects.has(packagePath) ? [] : [
|
|
5415
|
+
...xcodeProjects.has(packagePath) ? [] : [import_node_path13.default.join(packagePath, "Package.swift")],
|
|
5292
5416
|
...sourceFiles(packagePath),
|
|
5293
5417
|
...nativeSourceFiles(packagePath),
|
|
5294
5418
|
...resourceCandidateFiles(packagePath),
|
|
5295
|
-
...moduleRoot ? swiftModuleInputFiles(moduleRoot).map((file) =>
|
|
5419
|
+
...moduleRoot ? swiftModuleInputFiles(moduleRoot).map((file) => import_node_path13.default.join(moduleRoot, file)) : []
|
|
5296
5420
|
];
|
|
5297
5421
|
}
|
|
5298
5422
|
async function swiftPackageMetadata(packagePath, packageName, moduleRoot, origin, hosted) {
|
|
5299
|
-
packagePath =
|
|
5423
|
+
packagePath = import_node_fs11.default.realpathSync(packagePath);
|
|
5300
5424
|
const mains = sourceFiles(packagePath).filter(
|
|
5301
5425
|
(file) => swiftApplicationEntry(
|
|
5302
5426
|
file,
|
|
@@ -5310,7 +5434,7 @@ async function swiftPackageMetadata(packagePath, packageName, moduleRoot, origin
|
|
|
5310
5434
|
);
|
|
5311
5435
|
}
|
|
5312
5436
|
const project = projectFor(packagePath, hosted);
|
|
5313
|
-
const entry = mains.length === 1 ?
|
|
5437
|
+
const entry = mains.length === 1 ? import_node_path13.default.relative(packagePath, mains[0]).split(import_node_path13.default.sep).join(import_node_path13.default.posix.sep) : Object.entries(native?.files ?? {}).find(
|
|
5314
5438
|
([_file, names]) => names.length > 0
|
|
5315
5439
|
)?.[0];
|
|
5316
5440
|
if (!entry) throw new Error(`swift package ${packageName} has no native module source`);
|
|
@@ -5399,12 +5523,12 @@ function artifactUrl(project, artifact) {
|
|
|
5399
5523
|
return `${serverOrigin()}${ARTIFACT_PATH2}${artifact.hash}.wasm`;
|
|
5400
5524
|
}
|
|
5401
5525
|
function packageFor(file) {
|
|
5402
|
-
let dir =
|
|
5526
|
+
let dir = import_node_path14.default.dirname(file);
|
|
5403
5527
|
const stop = devServer?.config.root;
|
|
5404
5528
|
for (; ; ) {
|
|
5405
|
-
if (
|
|
5406
|
-
if (stop !== void 0 && dir === stop ||
|
|
5407
|
-
dir =
|
|
5529
|
+
if (import_node_fs12.default.existsSync(import_node_path14.default.join(dir, "Package.swift"))) return dir;
|
|
5530
|
+
if (stop !== void 0 && dir === stop || import_node_path14.default.dirname(dir) === dir) break;
|
|
5531
|
+
dir = import_node_path14.default.dirname(dir);
|
|
5408
5532
|
}
|
|
5409
5533
|
throw new Error(
|
|
5410
5534
|
`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`
|
|
@@ -5425,9 +5549,9 @@ function swiftPlugin(options = {}) {
|
|
|
5425
5549
|
if (!resolved) throw new Error(`cannot resolve swift source ${source}`);
|
|
5426
5550
|
let id = resolved.id;
|
|
5427
5551
|
if (importer && (source.startsWith("./") || source.startsWith("../"))) {
|
|
5428
|
-
const raw2 =
|
|
5552
|
+
const raw2 = import_node_path14.default.resolve(import_node_path14.default.dirname(importer.split("?")[0] ?? importer), source);
|
|
5429
5553
|
try {
|
|
5430
|
-
if (
|
|
5554
|
+
if (import_node_fs12.default.realpathSync(raw2) === import_node_fs12.default.realpathSync(resolved.id)) id = raw2;
|
|
5431
5555
|
} catch {
|
|
5432
5556
|
}
|
|
5433
5557
|
}
|
|
@@ -5436,22 +5560,22 @@ function swiftPlugin(options = {}) {
|
|
|
5436
5560
|
async load(id) {
|
|
5437
5561
|
if (!id.startsWith(VIRTUAL_PREFIX)) return null;
|
|
5438
5562
|
const file = id.slice(VIRTUAL_PREFIX.length);
|
|
5439
|
-
if (!
|
|
5563
|
+
if (!import_node_fs12.default.existsSync(file)) throw new Error(`swift source ${file} no longer exists`);
|
|
5440
5564
|
const packagePath = options.packagePath ?? packageFor(file);
|
|
5441
5565
|
const project = projectFor(packagePath);
|
|
5442
|
-
const entry =
|
|
5566
|
+
const entry = import_node_path14.default.relative(packagePath, file).split(import_node_path14.default.sep).join(import_node_path14.default.posix.sep);
|
|
5443
5567
|
for (const source of [
|
|
5444
5568
|
...sourceFiles(packagePath),
|
|
5445
5569
|
...nativeSourceFiles(packagePath)
|
|
5446
5570
|
])
|
|
5447
5571
|
this.addWatchFile(source);
|
|
5448
|
-
this.addWatchFile(
|
|
5572
|
+
this.addWatchFile(import_node_path14.default.join(packagePath, "Package.swift"));
|
|
5449
5573
|
const moduleRoot = linkedModuleRoots(packagePath).find(
|
|
5450
|
-
(root) =>
|
|
5574
|
+
(root) => import_node_fs12.default.existsSync(import_node_path14.default.join(root, "toolchain.json"))
|
|
5451
5575
|
);
|
|
5452
5576
|
if (moduleRoot)
|
|
5453
5577
|
for (const relative of swiftModuleInputFiles(moduleRoot))
|
|
5454
|
-
this.addWatchFile(
|
|
5578
|
+
this.addWatchFile(import_node_path14.default.join(moduleRoot, relative));
|
|
5455
5579
|
let artifact;
|
|
5456
5580
|
try {
|
|
5457
5581
|
artifact = await artifactFor(project, entry);
|
|
@@ -5470,7 +5594,7 @@ function swiftPlugin(options = {}) {
|
|
|
5470
5594
|
...artifact.package.resources.watched,
|
|
5471
5595
|
...artifact.package.bundleFiles.watched
|
|
5472
5596
|
])
|
|
5473
|
-
this.addWatchFile(
|
|
5597
|
+
this.addWatchFile(import_node_path14.default.join(packagePath, ...watched.split(import_node_path14.default.posix.sep)));
|
|
5474
5598
|
const colors = artifact.package.resources.colors;
|
|
5475
5599
|
const symbols = artifact.package.resources.symbols;
|
|
5476
5600
|
const bundleFiles = artifact.package.bundleFiles.files;
|