peachsim 0.1.758 → 0.1.759
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/agent-identity.cjs +1 -1
- package/dist-lib/agent-sessions.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -1
- package/dist-lib/auth/shared-session.cjs +1 -1
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/beta.cjs +1 -1
- package/dist-lib/beta.mjs +1 -1
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/bridge-contract-input.cjs +1 -1
- package/dist-lib/bridge-contract-input.mjs +1 -1
- package/dist-lib/bridge-contract.cjs +1 -1
- package/dist-lib/bridge-contract.mjs +1 -1
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +1 -1
- package/dist-lib/cli-constants.cjs +1 -1
- package/dist-lib/cloud-contract.cjs +1 -1
- package/dist-lib/cloud-contract.mjs +1 -1
- package/dist-lib/cloud-test-args.cjs +1 -1
- package/dist-lib/cloud-test-args.mjs +1 -1
- package/dist-lib/cloud.cjs +1 -1
- package/dist-lib/cloud.mjs +1 -1
- package/dist-lib/config.cjs +1 -1
- package/dist-lib/detox/index.cjs +1 -1
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +729 -371
- 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 +2 -4
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +495 -139
- 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 +466 -110
- 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 +920 -557
- package/dist-lib/swift-compile.cjs +1 -1
- package/dist-lib/swift-compile.mjs +1 -1
- 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 +539 -179
- package/dist-lib/vite.cjs +2 -4
- package/package.json +1 -1
- package/src/host/replacement-module-handler.ts +2 -1
- package/src/swift-host.ts +4 -2
- package/src/xcode-json-project.ts +450 -0
- package/src/xcode-project.ts +55 -22
package/dist-lib/vite-swift.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.759 | (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;
|
|
@@ -288,7 +288,7 @@ __export(vite_plugin_swift_exports, {
|
|
|
288
288
|
});
|
|
289
289
|
module.exports = __toCommonJS(vite_plugin_swift_exports);
|
|
290
290
|
var import_node_fs10 = __toESM(require("node:fs"), 1);
|
|
291
|
-
var
|
|
291
|
+
var import_node_path12 = __toESM(require("node:path"), 1);
|
|
292
292
|
|
|
293
293
|
// ../sootsim-swift/src/entryModule.ts
|
|
294
294
|
function nativeExportLines(args, commonjs) {
|
|
@@ -548,7 +548,7 @@ var NAME = /\bname\s*:\s*"([^"]+)"/;
|
|
|
548
548
|
function listArgument(call, label) {
|
|
549
549
|
const start = new RegExp(`\\b${label}\\s*:\\s*\\[`).exec(call);
|
|
550
550
|
if (!start) return [];
|
|
551
|
-
const
|
|
551
|
+
const items2 = [];
|
|
552
552
|
let depth = 0;
|
|
553
553
|
let inString = false;
|
|
554
554
|
let item = "";
|
|
@@ -565,14 +565,14 @@ function listArgument(call, label) {
|
|
|
565
565
|
if (depth === 0) break;
|
|
566
566
|
depth--;
|
|
567
567
|
} else if (ch === "," && depth === 0) {
|
|
568
|
-
|
|
568
|
+
items2.push(item.trim());
|
|
569
569
|
item = "";
|
|
570
570
|
continue;
|
|
571
571
|
}
|
|
572
572
|
item += ch;
|
|
573
573
|
}
|
|
574
|
-
if (item.trim())
|
|
575
|
-
return
|
|
574
|
+
if (item.trim()) items2.push(item.trim());
|
|
575
|
+
return items2;
|
|
576
576
|
}
|
|
577
577
|
function swiftPackageIdentity(url) {
|
|
578
578
|
return (url.split("/").pop() ?? url).replace(/\.git$/, "").toLowerCase();
|
|
@@ -1072,21 +1072,21 @@ var CLASS_DECL = /^class\s+(?!(?:func|var|let|subscript)\b)([A-Za-z_]\w*)/;
|
|
|
1072
1072
|
var MODIFIERS = /(?:^|\s)(public|open|internal|fileprivate|private|final|nonisolated|@MainActor)(?=\s)/g;
|
|
1073
1073
|
var OVERRIDE_FUNC = /^override((?:\s+(?:public|open|internal|fileprivate|private|final|nonisolated|dynamic|@\w+))*)\s+func\s+([A-Za-z_]\w*)\s*(<[^>{}]*>)?\s*\(/;
|
|
1074
1074
|
var OVERRIDE_VAR = /^override((?:\s+(?:public|open|internal|fileprivate|private|final|nonisolated|dynamic|@\w+))*)\s+var\s+([A-Za-z_]\w*)\s*:\s*([^{=]+?)\s*\{/;
|
|
1075
|
-
function splitTopLevel(
|
|
1075
|
+
function splitTopLevel(text2) {
|
|
1076
1076
|
const parts = [];
|
|
1077
1077
|
let depth = 0;
|
|
1078
1078
|
let start = 0;
|
|
1079
|
-
for (let i = 0; i <
|
|
1080
|
-
const char =
|
|
1079
|
+
for (let i = 0; i < text2.length; i++) {
|
|
1080
|
+
const char = text2[i];
|
|
1081
1081
|
if (char === "(" || char === "[" || char === "<") depth++;
|
|
1082
|
-
else if (char === ")" || char === "]" || char === ">" &&
|
|
1082
|
+
else if (char === ")" || char === "]" || char === ">" && text2[i - 1] !== "-")
|
|
1083
1083
|
depth--;
|
|
1084
1084
|
else if (char === "," && depth === 0) {
|
|
1085
|
-
parts.push(
|
|
1085
|
+
parts.push(text2.slice(start, i));
|
|
1086
1086
|
start = i + 1;
|
|
1087
1087
|
}
|
|
1088
1088
|
}
|
|
1089
|
-
parts.push(
|
|
1089
|
+
parts.push(text2.slice(start));
|
|
1090
1090
|
return parts.map((part) => part.trim()).filter((part) => part !== "");
|
|
1091
1091
|
}
|
|
1092
1092
|
function forwardedArguments(parameters) {
|
|
@@ -2010,7 +2010,7 @@ function compileSwiftProjectUnit(input, options) {
|
|
|
2010
2010
|
var import_node_crypto4 = require("node:crypto");
|
|
2011
2011
|
var import_node_fs9 = __toESM(require("node:fs"), 1);
|
|
2012
2012
|
var import_node_os5 = __toESM(require("node:os"), 1);
|
|
2013
|
-
var
|
|
2013
|
+
var import_node_path11 = __toESM(require("node:path"), 1);
|
|
2014
2014
|
|
|
2015
2015
|
// ../sootsim-swift/src/bundleAssets.ts
|
|
2016
2016
|
var import_svgpath = __toESM(require("svgpath"), 1);
|
|
@@ -2044,14 +2044,14 @@ function pickImagesetFile(images) {
|
|
|
2044
2044
|
scale: pick.scale === "2x" ? 2 : pick.scale === "3x" ? 3 : 1
|
|
2045
2045
|
};
|
|
2046
2046
|
}
|
|
2047
|
-
function flatScale(
|
|
2048
|
-
const match = /@([23])x\.[^./]+$/.exec(
|
|
2047
|
+
function flatScale(path12) {
|
|
2048
|
+
const match = /@([23])x\.[^./]+$/.exec(path12);
|
|
2049
2049
|
return match ? Number(match[1]) : 1;
|
|
2050
2050
|
}
|
|
2051
|
-
function providesNamespace(
|
|
2052
|
-
if (
|
|
2051
|
+
function providesNamespace(text2) {
|
|
2052
|
+
if (text2 === null) return false;
|
|
2053
2053
|
try {
|
|
2054
|
-
const parsed = JSON.parse(
|
|
2054
|
+
const parsed = JSON.parse(text2);
|
|
2055
2055
|
return parsed?.properties?.["provides-namespace"] === true;
|
|
2056
2056
|
} catch {
|
|
2057
2057
|
return false;
|
|
@@ -2072,21 +2072,21 @@ function catalogEntryName(contentsPath, kind, readText) {
|
|
|
2072
2072
|
}
|
|
2073
2073
|
return segments.join("/");
|
|
2074
2074
|
}
|
|
2075
|
-
function isFlatResourceImage(
|
|
2076
|
-
return
|
|
2075
|
+
function isFlatResourceImage(path12) {
|
|
2076
|
+
return path12.split("/").includes("Resources") && RASTER_EXTENSIONS.has(extOf(path12));
|
|
2077
2077
|
}
|
|
2078
2078
|
function enumerateBundleImages(paths, readText) {
|
|
2079
2079
|
const table = [];
|
|
2080
2080
|
const seen = /* @__PURE__ */ new Set();
|
|
2081
|
-
const catalogs = paths.filter((
|
|
2081
|
+
const catalogs = paths.filter((path12) => baseOf(path12) === "Contents.json");
|
|
2082
2082
|
for (const contentsPath of catalogs) {
|
|
2083
2083
|
const name = catalogEntryName(contentsPath, ".imageset", readText);
|
|
2084
2084
|
if (name === null || seen.has(name)) continue;
|
|
2085
2085
|
let parsed;
|
|
2086
2086
|
try {
|
|
2087
|
-
const
|
|
2088
|
-
if (
|
|
2089
|
-
parsed = JSON.parse(
|
|
2087
|
+
const text2 = readText(contentsPath);
|
|
2088
|
+
if (text2 === null) continue;
|
|
2089
|
+
parsed = JSON.parse(text2);
|
|
2090
2090
|
} catch {
|
|
2091
2091
|
continue;
|
|
2092
2092
|
}
|
|
@@ -2099,12 +2099,12 @@ function enumerateBundleImages(paths, readText) {
|
|
|
2099
2099
|
seen.add(name);
|
|
2100
2100
|
table.push({ name, file: `${dir}/${pick.filename}`, scale: pick.scale });
|
|
2101
2101
|
}
|
|
2102
|
-
for (const
|
|
2103
|
-
if (!isFlatResourceImage(
|
|
2104
|
-
const name = baseOf(
|
|
2102
|
+
for (const path12 of paths) {
|
|
2103
|
+
if (!isFlatResourceImage(path12)) continue;
|
|
2104
|
+
const name = baseOf(path12).slice(0, -extOf(path12).length);
|
|
2105
2105
|
if (name === "" || seen.has(name)) continue;
|
|
2106
2106
|
seen.add(name);
|
|
2107
|
-
table.push({ name, file:
|
|
2107
|
+
table.push({ name, file: path12, scale: flatScale(path12) });
|
|
2108
2108
|
}
|
|
2109
2109
|
return table;
|
|
2110
2110
|
}
|
|
@@ -2133,14 +2133,14 @@ function colorsetValue(color) {
|
|
|
2133
2133
|
}
|
|
2134
2134
|
function enumerateBundleColors(paths, readText) {
|
|
2135
2135
|
const table = {};
|
|
2136
|
-
for (const contentsPath of paths.filter((
|
|
2136
|
+
for (const contentsPath of paths.filter((path12) => baseOf(path12) === "Contents.json")) {
|
|
2137
2137
|
const name = catalogEntryName(contentsPath, ".colorset", readText);
|
|
2138
2138
|
if (name === null || name in table) continue;
|
|
2139
2139
|
let colors;
|
|
2140
2140
|
try {
|
|
2141
|
-
const
|
|
2142
|
-
if (
|
|
2143
|
-
colors = Reflect.get(JSON.parse(
|
|
2141
|
+
const text2 = readText(contentsPath);
|
|
2142
|
+
if (text2 === null) continue;
|
|
2143
|
+
colors = Reflect.get(JSON.parse(text2), "colors");
|
|
2144
2144
|
} catch {
|
|
2145
2145
|
continue;
|
|
2146
2146
|
}
|
|
@@ -2198,8 +2198,8 @@ function axisExtremes(points) {
|
|
|
2198
2198
|
function pathBounds(d) {
|
|
2199
2199
|
const xs = [];
|
|
2200
2200
|
const ys = [];
|
|
2201
|
-
for (const
|
|
2202
|
-
(0, import_svgpath.default)(
|
|
2201
|
+
for (const path12 of d)
|
|
2202
|
+
(0, import_svgpath.default)(path12).abs().unshort().unarc().iterate((segment, _index, x, y) => {
|
|
2203
2203
|
const [command, ...args] = segment;
|
|
2204
2204
|
if (command === "M" || command === "L") {
|
|
2205
2205
|
xs.push(Number(args[0]));
|
|
@@ -2226,7 +2226,7 @@ function guide(svg, id, axis) {
|
|
|
2226
2226
|
}
|
|
2227
2227
|
function enumerateBundleSymbols(paths, readText) {
|
|
2228
2228
|
const table = {};
|
|
2229
|
-
for (const contentsPath of paths.filter((
|
|
2229
|
+
for (const contentsPath of paths.filter((path12) => baseOf(path12) === "Contents.json")) {
|
|
2230
2230
|
const name = catalogEntryName(contentsPath, ".symbolset", readText);
|
|
2231
2231
|
if (name === null || name in table) continue;
|
|
2232
2232
|
let symbols;
|
|
@@ -2259,8 +2259,8 @@ function enumerateBundleSymbols(paths, readText) {
|
|
|
2259
2259
|
viewBox: "0 0 24 24",
|
|
2260
2260
|
advance,
|
|
2261
2261
|
box: [12 - advance / 2, 12 - tall / 2, advance, tall],
|
|
2262
|
-
layers: d.map((
|
|
2263
|
-
d: (0, import_svgpath.default)(
|
|
2262
|
+
layers: d.map((path12) => ({
|
|
2263
|
+
d: (0, import_svgpath.default)(path12).abs().scale(scale).translate(translateX, translateY).round(3).toString()
|
|
2264
2264
|
}))
|
|
2265
2265
|
};
|
|
2266
2266
|
}
|
|
@@ -2270,7 +2270,7 @@ function enumerateBundleJson(paths) {
|
|
|
2270
2270
|
const found = [];
|
|
2271
2271
|
const seen = /* @__PURE__ */ new Set();
|
|
2272
2272
|
const ordered = [...paths].filter(
|
|
2273
|
-
(
|
|
2273
|
+
(path12) => path12.split("/").includes("Resources") && path12.split("/").every((segment) => segment !== "" && segment !== "..") && (extOf(path12) === ".json" || extOf(path12) === ".xcstrings")
|
|
2274
2274
|
).sort((a, b) => {
|
|
2275
2275
|
const aDepth = a.split("/").length;
|
|
2276
2276
|
const bDepth = b.split("/").length;
|
|
@@ -3070,25 +3070,360 @@ async function compileSwiftProject(submit, work, origin, signal) {
|
|
|
3070
3070
|
|
|
3071
3071
|
// src/xcode-project.ts
|
|
3072
3072
|
var import_node_fs8 = __toESM(require("node:fs"), 1);
|
|
3073
|
-
var
|
|
3073
|
+
var import_node_path10 = __toESM(require("node:path"), 1);
|
|
3074
3074
|
var import_plist = __toESM(require_plist(), 1);
|
|
3075
|
-
|
|
3075
|
+
|
|
3076
|
+
// src/xcode-json-project.ts
|
|
3077
|
+
var import_node_path9 = __toESM(require("node:path"), 1);
|
|
3078
|
+
var import_json5 = __toESM(require("json5"), 1);
|
|
3079
|
+
var isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3080
|
+
var text = (value) => typeof value === "string" ? value : void 0;
|
|
3081
|
+
var items = (value) => Array.isArray(value) ? value : [];
|
|
3082
|
+
var PHASE_ISA = {
|
|
3083
|
+
"compile-sources": "PBXSourcesBuildPhase",
|
|
3084
|
+
resources: "PBXResourcesBuildPhase",
|
|
3085
|
+
frameworks: "PBXFrameworksBuildPhase",
|
|
3086
|
+
headers: "PBXHeadersBuildPhase",
|
|
3087
|
+
copy: "PBXCopyFilesBuildPhase",
|
|
3088
|
+
script: "PBXShellScriptBuildPhase"
|
|
3089
|
+
};
|
|
3090
|
+
function readXcodeJsonProject(xcodeproj, source) {
|
|
3091
|
+
const json = import_json5.default.parse(source);
|
|
3092
|
+
if (!isJsonObject(json)) throw new Error(`${xcodeproj}/project.xcproj is not an object`);
|
|
3093
|
+
const projectDir = import_node_path9.default.dirname(xcodeproj);
|
|
3094
|
+
const objects = {};
|
|
3095
|
+
let next = 0;
|
|
3096
|
+
const add = (entry, id) => {
|
|
3097
|
+
const key = id ?? `XCPROJ${(next++).toString(16).toUpperCase().padStart(18, "0")}`;
|
|
3098
|
+
objects[key] = entry;
|
|
3099
|
+
return key;
|
|
3100
|
+
};
|
|
3101
|
+
const locate = (raw2, groupDir) => {
|
|
3102
|
+
if (raw2.startsWith("<USER:")) return null;
|
|
3103
|
+
const base = /^<([A-Z]+)>\/(.*)$/.exec(raw2);
|
|
3104
|
+
if (base) {
|
|
3105
|
+
if (base[1] === "PROJECT")
|
|
3106
|
+
return { sourceTree: "<absolute>", path: import_node_path9.default.join(projectDir, base[2]) };
|
|
3107
|
+
if (base[1] === "PRODUCTS")
|
|
3108
|
+
return { sourceTree: "BUILT_PRODUCTS_DIR", path: base[2] };
|
|
3109
|
+
return null;
|
|
3110
|
+
}
|
|
3111
|
+
const unescaped = raw2.replaceAll("\\<", "<");
|
|
3112
|
+
if (unescaped.startsWith("/")) return { sourceTree: "<absolute>", path: unescaped };
|
|
3113
|
+
if (unescaped.startsWith("~")) return null;
|
|
3114
|
+
return groupDir === null ? null : { sourceTree: "<absolute>", path: import_node_path9.default.join(groupDir, unescaped) };
|
|
3115
|
+
};
|
|
3116
|
+
const memberships = [];
|
|
3117
|
+
const folders = [];
|
|
3118
|
+
const projectFiles = [];
|
|
3119
|
+
const root = { id: "", name: "", dir: projectDir, parent: null, children: [] };
|
|
3120
|
+
const walk2 = (entries, parent) => entries.flatMap((entry) => {
|
|
3121
|
+
if (!isObject(entry)) return [];
|
|
3122
|
+
const kind = text(entry.kind) ?? "file-reference";
|
|
3123
|
+
const raw2 = text(entry.path) ?? "";
|
|
3124
|
+
const located = raw2 === "" ? null : locate(raw2, parent.dir);
|
|
3125
|
+
const name = text(entry.name) ?? import_node_path9.default.basename(raw2);
|
|
3126
|
+
const node = { id: "", name, dir: null, parent, children: [] };
|
|
3127
|
+
if (kind === "group" || kind === "variant-group" || kind === "version-group") {
|
|
3128
|
+
node.dir = raw2 === "" ? parent.dir : located?.sourceTree === "<absolute>" ? located.path : null;
|
|
3129
|
+
const childIds = walk2(items(entry.children), node);
|
|
3130
|
+
node.id = add(
|
|
3131
|
+
kind === "version-group" && located ? {
|
|
3132
|
+
isa: "PBXFileReference",
|
|
3133
|
+
...located,
|
|
3134
|
+
lastKnownFileType: "wrapper.xcdatamodel"
|
|
3135
|
+
} : {
|
|
3136
|
+
isa: kind === "variant-group" ? "PBXVariantGroup" : "PBXGroup",
|
|
3137
|
+
children: childIds,
|
|
3138
|
+
...kind === "variant-group" ? {} : { sourceTree: "<absolute>", path: node.dir ?? "" },
|
|
3139
|
+
name
|
|
3140
|
+
},
|
|
3141
|
+
text(entry.id)
|
|
3142
|
+
);
|
|
3143
|
+
} else if (kind === "folder") {
|
|
3144
|
+
node.id = add(
|
|
3145
|
+
{
|
|
3146
|
+
isa: "PBXFileSystemSynchronizedRootGroup",
|
|
3147
|
+
...located ?? { sourceTree: "SDKROOT", path: raw2 }
|
|
3148
|
+
},
|
|
3149
|
+
text(entry.id)
|
|
3150
|
+
);
|
|
3151
|
+
folders.push({ id: node.id, folder: entry });
|
|
3152
|
+
} else {
|
|
3153
|
+
node.id = add(
|
|
3154
|
+
{
|
|
3155
|
+
isa: "PBXFileReference",
|
|
3156
|
+
...located ?? { sourceTree: "SDKROOT", path: raw2 },
|
|
3157
|
+
name
|
|
3158
|
+
},
|
|
3159
|
+
text(entry.id)
|
|
3160
|
+
);
|
|
3161
|
+
if (located?.sourceTree === "<absolute>" && located.path.endsWith(".xcodeproj"))
|
|
3162
|
+
projectFiles.push(node.id);
|
|
3163
|
+
}
|
|
3164
|
+
parent.children.push(node);
|
|
3165
|
+
for (const membership of items(entry["target-membership"])) {
|
|
3166
|
+
if (kind !== "folder") memberships.push({ refId: node.id, entry: membership });
|
|
3167
|
+
}
|
|
3168
|
+
return [node.id];
|
|
3169
|
+
});
|
|
3170
|
+
const mainGroupChildren = walk2(items(json.files), root);
|
|
3171
|
+
const mainGroup = add({
|
|
3172
|
+
isa: "PBXGroup",
|
|
3173
|
+
children: mainGroupChildren,
|
|
3174
|
+
sourceTree: "<absolute>",
|
|
3175
|
+
path: projectDir
|
|
3176
|
+
});
|
|
3177
|
+
root.id = mainGroup;
|
|
3178
|
+
const lookup = (reference, from = root) => {
|
|
3179
|
+
if (isObject(reference)) {
|
|
3180
|
+
const anchor = lookupNode(reference.anchor, root);
|
|
3181
|
+
return anchor ? lookup(reference["relative-path"], anchor) : void 0;
|
|
3182
|
+
}
|
|
3183
|
+
if (Array.isArray(reference)) {
|
|
3184
|
+
return lookupNode(
|
|
3185
|
+
reference.map(
|
|
3186
|
+
(component) => isObject(component) ? text(component.name) ?? "" : text(component) ?? ""
|
|
3187
|
+
).join("/"),
|
|
3188
|
+
from
|
|
3189
|
+
)?.id;
|
|
3190
|
+
}
|
|
3191
|
+
return lookupNode(reference, from)?.id;
|
|
3192
|
+
};
|
|
3193
|
+
const lookupNode = (reference, from) => {
|
|
3194
|
+
const value = text(reference);
|
|
3195
|
+
if (value === void 0) return void 0;
|
|
3196
|
+
if (value.startsWith("id:")) {
|
|
3197
|
+
const id = value.slice(3);
|
|
3198
|
+
const find = (node2) => node2.id === id ? node2 : node2.children.map(find).find(Boolean);
|
|
3199
|
+
return find(root);
|
|
3200
|
+
}
|
|
3201
|
+
let node = from;
|
|
3202
|
+
for (const component of value.split("/")) {
|
|
3203
|
+
if (!node) return void 0;
|
|
3204
|
+
node = component === "." ? node : component === ".." ? node.parent ?? void 0 : node.children.find((child) => child.name === component);
|
|
3205
|
+
}
|
|
3206
|
+
return node;
|
|
3207
|
+
};
|
|
3208
|
+
const configurations = items(json.configurations).flatMap((entry) => {
|
|
3209
|
+
const name = isObject(entry) ? text(entry.name) : text(entry);
|
|
3210
|
+
return name ? [{ name, file: isObject(entry) ? entry.file : void 0 }] : [];
|
|
3211
|
+
});
|
|
3212
|
+
const settingsOf = (value) => Object.fromEntries(
|
|
3213
|
+
Object.entries(isObject(value) ? value : {}).flatMap(
|
|
3214
|
+
([key, setting]) => typeof setting === "string" ? [[key, setting]] : Array.isArray(setting) ? [
|
|
3215
|
+
[
|
|
3216
|
+
key,
|
|
3217
|
+
setting.filter((item) => typeof item === "string")
|
|
3218
|
+
]
|
|
3219
|
+
] : []
|
|
3220
|
+
)
|
|
3221
|
+
);
|
|
3222
|
+
const configurationList = (settings, specialized) => add({
|
|
3223
|
+
isa: "XCConfigurationList",
|
|
3224
|
+
defaultConfigurationName: text(json["default-configuration"]) ?? "Debug",
|
|
3225
|
+
buildConfigurations: configurations.map(({ name, file }) => {
|
|
3226
|
+
const base = lookup(specialized.has(name) ? specialized.get(name) : file);
|
|
3227
|
+
return add({
|
|
3228
|
+
isa: "XCBuildConfiguration",
|
|
3229
|
+
name,
|
|
3230
|
+
buildSettings: settings,
|
|
3231
|
+
...base ? { baseConfigurationReference: base } : {}
|
|
3232
|
+
});
|
|
3233
|
+
})
|
|
3234
|
+
});
|
|
3235
|
+
const packageIds = /* @__PURE__ */ new Map();
|
|
3236
|
+
for (const entry of items(json.packages)) {
|
|
3237
|
+
if (!isObject(entry)) continue;
|
|
3238
|
+
const repository = text(entry.repository);
|
|
3239
|
+
const local = text(entry.path);
|
|
3240
|
+
const name = local !== void 0 ? import_node_path9.default.basename(import_node_path9.default.resolve(import_node_path9.default.dirname(xcodeproj), local)) : import_node_path9.default.basename(repository ?? "").replace(/\.git$/, "");
|
|
3241
|
+
const id = text(entry.kind) === "local" && local !== void 0 ? add({ isa: "XCLocalSwiftPackageReference", relativePath: local }) : add({ isa: "XCRemoteSwiftPackageReference", repositoryURL: repository ?? "" });
|
|
3242
|
+
packageIds.set(name.toLowerCase(), id);
|
|
3243
|
+
}
|
|
3244
|
+
const productDependency = (entry) => add({
|
|
3245
|
+
isa: "XCSwiftPackageProductDependency",
|
|
3246
|
+
productName: text(entry["product-name"]) ?? "",
|
|
3247
|
+
// xcode finds a product by name across packages when none is named
|
|
3248
|
+
...packageIds.has(text(entry.package)?.toLowerCase() ?? "") ? { package: packageIds.get(text(entry.package).toLowerCase()) } : {}
|
|
3249
|
+
});
|
|
3250
|
+
const proxy = (entry, remote, proxyType) => add({
|
|
3251
|
+
isa: "PBXContainerItemProxy",
|
|
3252
|
+
containerPortal: lookup(entry.project) ?? "",
|
|
3253
|
+
proxyType,
|
|
3254
|
+
remoteGlobalIDString: remote ?? "",
|
|
3255
|
+
remoteInfo: text(entry.target) ?? ""
|
|
3256
|
+
});
|
|
3257
|
+
const phases = /* @__PURE__ */ new Map();
|
|
3258
|
+
const targetIds = /* @__PURE__ */ new Map();
|
|
3259
|
+
const targets = [];
|
|
3260
|
+
for (const entry of items(json.targets)) {
|
|
3261
|
+
if (!isObject(entry)) continue;
|
|
3262
|
+
const name = text(entry.name) ?? "";
|
|
3263
|
+
const productType = text(entry["product-type"]);
|
|
3264
|
+
const target = {
|
|
3265
|
+
isa: text(entry.kind) === "aggregate" ? "PBXAggregateTarget" : "PBXNativeTarget",
|
|
3266
|
+
name,
|
|
3267
|
+
productName: name,
|
|
3268
|
+
productType: productType ? `com.apple.product-type.${productType}` : text(entry["full-product-type"]) ?? "",
|
|
3269
|
+
buildPhases: [],
|
|
3270
|
+
dependencies: [],
|
|
3271
|
+
packageProductDependencies: [],
|
|
3272
|
+
fileSystemSynchronizedGroups: []
|
|
3273
|
+
};
|
|
3274
|
+
const product = lookup(entry.product);
|
|
3275
|
+
if (product) target.productReference = product;
|
|
3276
|
+
const id = add(target, text(entry.id));
|
|
3277
|
+
targetIds.set(name, id);
|
|
3278
|
+
targets.push({ id, target, entry });
|
|
3279
|
+
for (const phase of items(entry["build-phases"])) {
|
|
3280
|
+
const kind = isObject(phase) ? text(phase.kind) : text(phase);
|
|
3281
|
+
const isa = kind ? PHASE_ISA[kind] : void 0;
|
|
3282
|
+
if (!kind || !isa) continue;
|
|
3283
|
+
const phaseName = isObject(phase) ? text(phase.name) : void 0;
|
|
3284
|
+
const phaseId = add(
|
|
3285
|
+
{ isa, files: [] },
|
|
3286
|
+
isObject(phase) ? text(phase.id) : void 0
|
|
3287
|
+
);
|
|
3288
|
+
target.buildPhases.push(phaseId);
|
|
3289
|
+
phases.set([name, kind, phaseName].filter(Boolean).join("/"), phaseId);
|
|
3290
|
+
phases.set(`id:${phaseId}`, phaseId);
|
|
3291
|
+
}
|
|
3292
|
+
}
|
|
3293
|
+
const phaseFiles = (reference, targetName) => {
|
|
3294
|
+
const value = text(reference);
|
|
3295
|
+
if (value === void 0) return null;
|
|
3296
|
+
const key = value.startsWith("id:") || !targetName ? value : `${targetName}/${value}`;
|
|
3297
|
+
const phase = objects[phases.get(key) ?? ""];
|
|
3298
|
+
return phase && typeof phase === "object" && !Array.isArray(phase) && Array.isArray(phase.files) ? phase.files : null;
|
|
3299
|
+
};
|
|
3300
|
+
for (const { refId, entry } of memberships) {
|
|
3301
|
+
const files = phaseFiles(isObject(entry) ? entry["build-phase"] : entry);
|
|
3302
|
+
files?.push(add({ isa: "PBXBuildFile", fileRef: refId }));
|
|
3303
|
+
}
|
|
3304
|
+
for (const { target, entry } of targets) {
|
|
3305
|
+
const name = text(entry.name) ?? "";
|
|
3306
|
+
target.buildConfigurationList = configurationList(
|
|
3307
|
+
settingsOf(entry["build-settings"]),
|
|
3308
|
+
new Map(
|
|
3309
|
+
items(entry["specialized-configurations"]).flatMap(
|
|
3310
|
+
(configuration) => isObject(configuration) && text(configuration.name) ? [[text(configuration.name), configuration.file]] : []
|
|
3311
|
+
)
|
|
3312
|
+
)
|
|
3313
|
+
);
|
|
3314
|
+
for (const dependency of items(entry.dependencies)) {
|
|
3315
|
+
const kind = isObject(dependency) ? text(dependency.kind) ?? "localTarget" : "localTarget";
|
|
3316
|
+
if (kind === "package" && isObject(dependency)) {
|
|
3317
|
+
;
|
|
3318
|
+
target.dependencies.push(
|
|
3319
|
+
add({ isa: "PBXTargetDependency", productRef: productDependency(dependency) })
|
|
3320
|
+
);
|
|
3321
|
+
} else if (kind === "remoteTarget" && isObject(dependency)) {
|
|
3322
|
+
;
|
|
3323
|
+
target.dependencies.push(
|
|
3324
|
+
add({
|
|
3325
|
+
isa: "PBXTargetDependency",
|
|
3326
|
+
targetProxy: proxy(dependency, text(dependency["target-id"]), "1")
|
|
3327
|
+
})
|
|
3328
|
+
);
|
|
3329
|
+
} else {
|
|
3330
|
+
const local = isObject(dependency) ? text(dependency.target) : text(dependency);
|
|
3331
|
+
const id = local ? targetIds.get(local) : void 0;
|
|
3332
|
+
if (id)
|
|
3333
|
+
target.dependencies.push(
|
|
3334
|
+
add({ isa: "PBXTargetDependency", target: id })
|
|
3335
|
+
);
|
|
3336
|
+
}
|
|
3337
|
+
}
|
|
3338
|
+
for (const member of items(entry["package-product-members"])) {
|
|
3339
|
+
if (!isObject(member)) continue;
|
|
3340
|
+
const dependency = productDependency(member);
|
|
3341
|
+
target.packageProductDependencies.push(dependency);
|
|
3342
|
+
const buildFile = member["build-phase"];
|
|
3343
|
+
phaseFiles(isObject(buildFile) ? buildFile["build-phase"] : buildFile, name)?.push(
|
|
3344
|
+
add({ isa: "PBXBuildFile", productRef: dependency })
|
|
3345
|
+
);
|
|
3346
|
+
}
|
|
3347
|
+
}
|
|
3348
|
+
for (const imported of items(json["imported-products"])) {
|
|
3349
|
+
if (!isObject(imported)) continue;
|
|
3350
|
+
const reference = add({
|
|
3351
|
+
isa: "PBXReferenceProxy",
|
|
3352
|
+
path: text(imported.name) ?? text(imported.path) ?? "",
|
|
3353
|
+
sourceTree: "BUILT_PRODUCTS_DIR",
|
|
3354
|
+
remoteRef: proxy(imported, text(imported["product-id"]), "2")
|
|
3355
|
+
});
|
|
3356
|
+
for (const membership of items(imported["target-membership"])) {
|
|
3357
|
+
phaseFiles(isObject(membership) ? membership["build-phase"] : membership)?.push(
|
|
3358
|
+
add({ isa: "PBXBuildFile", fileRef: reference })
|
|
3359
|
+
);
|
|
3360
|
+
}
|
|
3361
|
+
}
|
|
3362
|
+
for (const { id, folder } of folders) {
|
|
3363
|
+
const exceptions = [];
|
|
3364
|
+
for (const exception of items(folder["membership-exceptions"])) {
|
|
3365
|
+
if (!isObject(exception)) continue;
|
|
3366
|
+
const target = targetIds.get(text(exception.target) ?? "");
|
|
3367
|
+
if (!target) continue;
|
|
3368
|
+
exceptions.push(
|
|
3369
|
+
add({
|
|
3370
|
+
isa: "PBXFileSystemSynchronizedBuildFileExceptionSet",
|
|
3371
|
+
target,
|
|
3372
|
+
membershipExceptions: [
|
|
3373
|
+
...items(exception.exclusions),
|
|
3374
|
+
...items(exception.inclusions)
|
|
3375
|
+
].flatMap((member) => typeof member === "string" ? [member] : [])
|
|
3376
|
+
})
|
|
3377
|
+
);
|
|
3378
|
+
}
|
|
3379
|
+
const group = objects[id];
|
|
3380
|
+
if (group && typeof group === "object" && !Array.isArray(group))
|
|
3381
|
+
group.exceptions = exceptions;
|
|
3382
|
+
for (const owner of items(folder["target-membership"])) {
|
|
3383
|
+
const target = targets.find(
|
|
3384
|
+
(candidate) => candidate.id === targetIds.get(text(owner) ?? "")
|
|
3385
|
+
);
|
|
3386
|
+
target?.target.fileSystemSynchronizedGroups?.push(id);
|
|
3387
|
+
}
|
|
3388
|
+
}
|
|
3389
|
+
const localizations = isObject(json.localizations) ? json.localizations : {};
|
|
3390
|
+
const project = add({
|
|
3391
|
+
isa: "PBXProject",
|
|
3392
|
+
mainGroup,
|
|
3393
|
+
projectDirPath: "",
|
|
3394
|
+
developmentRegion: text(localizations.development) ?? "en",
|
|
3395
|
+
buildConfigurationList: configurationList(
|
|
3396
|
+
settingsOf(json["build-settings"]),
|
|
3397
|
+
/* @__PURE__ */ new Map()
|
|
3398
|
+
),
|
|
3399
|
+
targets: targets.map((entry) => entry.id),
|
|
3400
|
+
packageReferences: [...packageIds.values()],
|
|
3401
|
+
projectReferences: projectFiles.map((ProjectRef) => ({ ProjectRef }))
|
|
3402
|
+
});
|
|
3403
|
+
return { objects, rootObject: project };
|
|
3404
|
+
}
|
|
3405
|
+
function isJsonObject(value) {
|
|
3406
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3407
|
+
}
|
|
3408
|
+
|
|
3409
|
+
// src/xcode-project.ts
|
|
3410
|
+
function parseOpenStepPlist(text2) {
|
|
3076
3411
|
let i = 0;
|
|
3077
3412
|
const fail = (message) => {
|
|
3078
|
-
const line =
|
|
3413
|
+
const line = text2.slice(0, i).split("\n").length;
|
|
3079
3414
|
throw new Error(`project.pbxproj line ${line}: ${message}`);
|
|
3080
3415
|
};
|
|
3081
3416
|
const skip = () => {
|
|
3082
3417
|
for (; ; ) {
|
|
3083
|
-
const ch =
|
|
3418
|
+
const ch = text2[i];
|
|
3084
3419
|
if (ch === " " || ch === " " || ch === "\n" || ch === "\r") i++;
|
|
3085
|
-
else if (ch === "/" &&
|
|
3086
|
-
const end =
|
|
3420
|
+
else if (ch === "/" && text2[i + 1] === "*") {
|
|
3421
|
+
const end = text2.indexOf("*/", i + 2);
|
|
3087
3422
|
if (end < 0) fail("unterminated comment");
|
|
3088
3423
|
i = end + 2;
|
|
3089
|
-
} else if (ch === "/" &&
|
|
3090
|
-
const end =
|
|
3091
|
-
i = end < 0 ?
|
|
3424
|
+
} else if (ch === "/" && text2[i + 1] === "/") {
|
|
3425
|
+
const end = text2.indexOf("\n", i);
|
|
3426
|
+
i = end < 0 ? text2.length : end + 1;
|
|
3092
3427
|
} else return;
|
|
3093
3428
|
}
|
|
3094
3429
|
};
|
|
@@ -3096,42 +3431,42 @@ function parseOpenStepPlist(text) {
|
|
|
3096
3431
|
i++;
|
|
3097
3432
|
let out = "";
|
|
3098
3433
|
for (; ; ) {
|
|
3099
|
-
const ch =
|
|
3434
|
+
const ch = text2[i++];
|
|
3100
3435
|
if (ch === void 0) fail("unterminated string");
|
|
3101
3436
|
if (ch === '"') return out;
|
|
3102
3437
|
if (ch !== "\\") {
|
|
3103
3438
|
out += ch;
|
|
3104
3439
|
continue;
|
|
3105
3440
|
}
|
|
3106
|
-
const next =
|
|
3441
|
+
const next = text2[i++];
|
|
3107
3442
|
if (next === "n") out += "\n";
|
|
3108
3443
|
else if (next === "t") out += " ";
|
|
3109
3444
|
else if (next === "r") out += "\r";
|
|
3110
3445
|
else if (next === "U") {
|
|
3111
|
-
out += String.fromCharCode(parseInt(
|
|
3446
|
+
out += String.fromCharCode(parseInt(text2.slice(i, i + 4), 16));
|
|
3112
3447
|
i += 4;
|
|
3113
3448
|
} else out += next;
|
|
3114
3449
|
}
|
|
3115
3450
|
};
|
|
3116
3451
|
const value = () => {
|
|
3117
3452
|
skip();
|
|
3118
|
-
const ch =
|
|
3453
|
+
const ch = text2[i];
|
|
3119
3454
|
if (ch === "{") {
|
|
3120
3455
|
i++;
|
|
3121
3456
|
const dict = {};
|
|
3122
3457
|
for (; ; ) {
|
|
3123
3458
|
skip();
|
|
3124
|
-
if (
|
|
3459
|
+
if (text2[i] === "}") {
|
|
3125
3460
|
i++;
|
|
3126
3461
|
return dict;
|
|
3127
3462
|
}
|
|
3128
3463
|
const key = value();
|
|
3129
3464
|
if (typeof key !== "string") fail("dictionary key is not a string");
|
|
3130
3465
|
skip();
|
|
3131
|
-
if (
|
|
3466
|
+
if (text2[i++] !== "=") fail("expected =");
|
|
3132
3467
|
dict[key] = value();
|
|
3133
3468
|
skip();
|
|
3134
|
-
if (
|
|
3469
|
+
if (text2[i++] !== ";") fail("expected ;");
|
|
3135
3470
|
}
|
|
3136
3471
|
}
|
|
3137
3472
|
if (ch === "(") {
|
|
@@ -3139,26 +3474,26 @@ function parseOpenStepPlist(text) {
|
|
|
3139
3474
|
const list2 = [];
|
|
3140
3475
|
for (; ; ) {
|
|
3141
3476
|
skip();
|
|
3142
|
-
if (
|
|
3477
|
+
if (text2[i] === ")") {
|
|
3143
3478
|
i++;
|
|
3144
3479
|
return list2;
|
|
3145
3480
|
}
|
|
3146
3481
|
list2.push(value());
|
|
3147
3482
|
skip();
|
|
3148
|
-
if (
|
|
3149
|
-
else if (
|
|
3483
|
+
if (text2[i] === ",") i++;
|
|
3484
|
+
else if (text2[i] !== ")") fail("expected , or )");
|
|
3150
3485
|
}
|
|
3151
3486
|
}
|
|
3152
3487
|
if (ch === '"') return quoted();
|
|
3153
3488
|
const start = i;
|
|
3154
|
-
while (i <
|
|
3489
|
+
while (i < text2.length && /[A-Za-z0-9_$+/:.\-<>]/.test(text2[i])) i++;
|
|
3155
3490
|
if (i === start) fail(`unexpected ${JSON.stringify(ch ?? "end of file")}`);
|
|
3156
|
-
return
|
|
3491
|
+
return text2.slice(start, i);
|
|
3157
3492
|
};
|
|
3158
|
-
if (
|
|
3493
|
+
if (text2.startsWith("// !$*UTF8*$!")) i = text2.indexOf("\n") + 1;
|
|
3159
3494
|
const root = value();
|
|
3160
3495
|
skip();
|
|
3161
|
-
if (i !==
|
|
3496
|
+
if (i !== text2.length) fail("trailing content");
|
|
3162
3497
|
return root;
|
|
3163
3498
|
}
|
|
3164
3499
|
var isDict = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -3183,7 +3518,7 @@ function walkFiles(dir) {
|
|
|
3183
3518
|
const out = [];
|
|
3184
3519
|
for (const entry of import_node_fs8.default.readdirSync(dir, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
|
|
3185
3520
|
if (entry.name.startsWith(".")) continue;
|
|
3186
|
-
const full =
|
|
3521
|
+
const full = import_node_path10.default.join(dir, entry.name);
|
|
3187
3522
|
if (entry.isDirectory()) out.push(...walkFiles(full));
|
|
3188
3523
|
else if (entry.isFile()) out.push(full);
|
|
3189
3524
|
}
|
|
@@ -3200,7 +3535,7 @@ function readXcconfig(file, seen = /* @__PURE__ */ new Set()) {
|
|
|
3200
3535
|
if (include) {
|
|
3201
3536
|
Object.assign(
|
|
3202
3537
|
settings,
|
|
3203
|
-
readXcconfig(
|
|
3538
|
+
readXcconfig(import_node_path10.default.resolve(import_node_path10.default.dirname(file), include[1]), seen)
|
|
3204
3539
|
);
|
|
3205
3540
|
continue;
|
|
3206
3541
|
}
|
|
@@ -3246,22 +3581,22 @@ function applyOperator(value, operator) {
|
|
|
3246
3581
|
}
|
|
3247
3582
|
throw new Error(`unsupported build setting operator :${operator}`);
|
|
3248
3583
|
}
|
|
3249
|
-
function decodeXml(
|
|
3250
|
-
return
|
|
3584
|
+
function decodeXml(text2) {
|
|
3585
|
+
return text2.replaceAll(""", '"').replaceAll("'", "'").replaceAll("<", "<").replaceAll(">", ">").replaceAll("&", "&");
|
|
3251
3586
|
}
|
|
3252
3587
|
function workspaceReferences(workspace) {
|
|
3253
|
-
const data =
|
|
3588
|
+
const data = import_node_path10.default.join(workspace, "contents.xcworkspacedata");
|
|
3254
3589
|
if (!import_node_fs8.default.existsSync(data))
|
|
3255
3590
|
throw new Error(`${workspace} has no contents.xcworkspacedata`);
|
|
3256
|
-
const container =
|
|
3591
|
+
const container = import_node_path10.default.dirname(workspace);
|
|
3257
3592
|
const locate = (location, base) => {
|
|
3258
3593
|
const colon = location.indexOf(":");
|
|
3259
3594
|
const kind = location.slice(0, colon);
|
|
3260
3595
|
const rest = location.slice(colon + 1);
|
|
3261
|
-
if (kind === "group") return
|
|
3262
|
-
if (kind === "container" || kind === "self") return
|
|
3263
|
-
if (kind === "absolute") return
|
|
3264
|
-
throw new Error(`${
|
|
3596
|
+
if (kind === "group") return import_node_path10.default.resolve(base, rest);
|
|
3597
|
+
if (kind === "container" || kind === "self") return import_node_path10.default.resolve(container, rest);
|
|
3598
|
+
if (kind === "absolute") return import_node_path10.default.resolve(rest);
|
|
3599
|
+
throw new Error(`${import_node_path10.default.basename(workspace)} has an unsupported location ${location}`);
|
|
3265
3600
|
};
|
|
3266
3601
|
const groups = [container];
|
|
3267
3602
|
const references = [];
|
|
@@ -3279,15 +3614,24 @@ function workspaceReferences(workspace) {
|
|
|
3279
3614
|
return references;
|
|
3280
3615
|
}
|
|
3281
3616
|
var loaded = /* @__PURE__ */ new Map();
|
|
3617
|
+
function xcodeProjectFile(xcodeproj) {
|
|
3618
|
+
for (const name of ["project.pbxproj", "project.xcproj"]) {
|
|
3619
|
+
const file = import_node_path10.default.join(xcodeproj, name);
|
|
3620
|
+
if (import_node_fs8.default.existsSync(file)) return file;
|
|
3621
|
+
}
|
|
3622
|
+
return null;
|
|
3623
|
+
}
|
|
3282
3624
|
function loadProject(xcodeproj) {
|
|
3283
|
-
const
|
|
3284
|
-
if (!
|
|
3285
|
-
|
|
3286
|
-
const
|
|
3625
|
+
const projectFile = xcodeProjectFile(xcodeproj);
|
|
3626
|
+
if (!projectFile)
|
|
3627
|
+
throw new Error(`${xcodeproj} has no project.pbxproj or project.xcproj`);
|
|
3628
|
+
const mtimeMs = import_node_fs8.default.statSync(projectFile).mtimeMs;
|
|
3629
|
+
const cached = loaded.get(projectFile);
|
|
3287
3630
|
if (cached?.mtimeMs === mtimeMs) return cached.project;
|
|
3288
|
-
const
|
|
3631
|
+
const source = import_node_fs8.default.readFileSync(projectFile, "utf8");
|
|
3632
|
+
const root = projectFile.endsWith(".xcproj") ? readXcodeJsonProject(xcodeproj, source) : parseOpenStepPlist(source);
|
|
3289
3633
|
if (!isDict(root) || !isDict(root.objects)) {
|
|
3290
|
-
throw new Error(`${
|
|
3634
|
+
throw new Error(`${projectFile} has no objects table`);
|
|
3291
3635
|
}
|
|
3292
3636
|
const objects = root.objects;
|
|
3293
3637
|
const object = (id) => {
|
|
@@ -3296,10 +3640,10 @@ function loadProject(xcodeproj) {
|
|
|
3296
3640
|
};
|
|
3297
3641
|
const project = object(str(root.rootObject));
|
|
3298
3642
|
if (!project || project.isa !== "PBXProject") {
|
|
3299
|
-
throw new Error(`${
|
|
3643
|
+
throw new Error(`${projectFile} has no PBXProject root`);
|
|
3300
3644
|
}
|
|
3301
3645
|
const projectDir = import_node_fs8.default.realpathSync(
|
|
3302
|
-
|
|
3646
|
+
import_node_path10.default.resolve(import_node_path10.default.dirname(xcodeproj), str(project.projectDirPath) ?? "")
|
|
3303
3647
|
);
|
|
3304
3648
|
const parent = /* @__PURE__ */ new Map();
|
|
3305
3649
|
for (const [id, entry] of Object.entries(objects)) {
|
|
@@ -3317,18 +3661,26 @@ function loadProject(xcodeproj) {
|
|
|
3317
3661
|
const own = str(entry.path) ?? "";
|
|
3318
3662
|
const tree = str(entry.sourceTree) ?? "<group>";
|
|
3319
3663
|
if (tree === "<absolute>") result2 = own;
|
|
3320
|
-
else if (tree === "SOURCE_ROOT") result2 =
|
|
3664
|
+
else if (tree === "SOURCE_ROOT") result2 = import_node_path10.default.join(projectDir, own);
|
|
3321
3665
|
else if (tree === "<group>") {
|
|
3322
3666
|
const up = parent.get(id);
|
|
3323
3667
|
const base = up ? resolvePath(up) : projectDir;
|
|
3324
|
-
result2 = base === null ? null :
|
|
3668
|
+
result2 = base === null ? null : import_node_path10.default.join(base, own);
|
|
3325
3669
|
}
|
|
3326
3670
|
}
|
|
3327
3671
|
resolvedPaths.set(id, result2);
|
|
3328
3672
|
return result2;
|
|
3329
3673
|
};
|
|
3330
|
-
const result = {
|
|
3331
|
-
|
|
3674
|
+
const result = {
|
|
3675
|
+
xcodeproj,
|
|
3676
|
+
projectFile,
|
|
3677
|
+
objects,
|
|
3678
|
+
project,
|
|
3679
|
+
projectDir,
|
|
3680
|
+
object,
|
|
3681
|
+
resolvePath
|
|
3682
|
+
};
|
|
3683
|
+
loaded.set(projectFile, { mtimeMs, project: result });
|
|
3332
3684
|
return result;
|
|
3333
3685
|
}
|
|
3334
3686
|
function targetSettings(ref, builtins) {
|
|
@@ -3442,7 +3794,7 @@ function targetMembers(ref) {
|
|
|
3442
3794
|
}
|
|
3443
3795
|
}
|
|
3444
3796
|
const addSynchronized = (folder, relative) => {
|
|
3445
|
-
const file =
|
|
3797
|
+
const file = import_node_path10.default.join(folder, relative);
|
|
3446
3798
|
if (NEVER_MEMBER.test(relative)) return;
|
|
3447
3799
|
if (file.endsWith(".swift")) {
|
|
3448
3800
|
if (!relative.split("/").some((segment) => BUNDLE_DIR.test(segment))) {
|
|
@@ -3467,7 +3819,7 @@ function targetMembers(ref) {
|
|
|
3467
3819
|
}
|
|
3468
3820
|
if (owned.has(groupId)) {
|
|
3469
3821
|
for (const file of walkFiles(folder)) {
|
|
3470
|
-
const relative =
|
|
3822
|
+
const relative = import_node_path10.default.relative(folder, file).split(import_node_path10.default.sep).join("/");
|
|
3471
3823
|
if ([...exceptions].some(
|
|
3472
3824
|
(exception) => relative === exception || relative.startsWith(`${exception}/`)
|
|
3473
3825
|
))
|
|
@@ -3476,12 +3828,12 @@ function targetMembers(ref) {
|
|
|
3476
3828
|
}
|
|
3477
3829
|
} else {
|
|
3478
3830
|
for (const relative of exceptions) {
|
|
3479
|
-
const file =
|
|
3831
|
+
const file = import_node_path10.default.join(folder, relative);
|
|
3480
3832
|
if (isDirectory(file)) {
|
|
3481
3833
|
for (const inner of walkFiles(file))
|
|
3482
3834
|
addSynchronized(
|
|
3483
3835
|
folder,
|
|
3484
|
-
|
|
3836
|
+
import_node_path10.default.relative(folder, inner).split(import_node_path10.default.sep).join("/")
|
|
3485
3837
|
);
|
|
3486
3838
|
} else if (import_node_fs8.default.existsSync(file)) addSynchronized(folder, relative);
|
|
3487
3839
|
}
|
|
@@ -3496,8 +3848,8 @@ function targetMembers(ref) {
|
|
|
3496
3848
|
function commonAncestor(dirs) {
|
|
3497
3849
|
let common = dirs[0];
|
|
3498
3850
|
for (const dir of dirs) {
|
|
3499
|
-
while (common !==
|
|
3500
|
-
common =
|
|
3851
|
+
while (common !== import_node_path10.default.dirname(common) && import_node_path10.default.relative(common, dir).startsWith(".."))
|
|
3852
|
+
common = import_node_path10.default.dirname(common);
|
|
3501
3853
|
}
|
|
3502
3854
|
return common;
|
|
3503
3855
|
}
|
|
@@ -3506,9 +3858,9 @@ function workspaceProjects(xcodeprojOrWorkspace) {
|
|
|
3506
3858
|
const projects2 = [];
|
|
3507
3859
|
const projectAt = /* @__PURE__ */ new Map();
|
|
3508
3860
|
const addProject = (xcodeproj) => {
|
|
3509
|
-
const key =
|
|
3510
|
-
if (projectAt.has(key) || key.split(
|
|
3511
|
-
if (!
|
|
3861
|
+
const key = import_node_path10.default.resolve(xcodeproj);
|
|
3862
|
+
if (projectAt.has(key) || key.split(import_node_path10.default.sep).includes("Pods")) return;
|
|
3863
|
+
if (!xcodeProjectFile(key)) return;
|
|
3512
3864
|
const project = loadProject(key);
|
|
3513
3865
|
projectAt.set(key, project);
|
|
3514
3866
|
projects2.push(project);
|
|
@@ -3524,21 +3876,29 @@ function workspaceProjects(xcodeprojOrWorkspace) {
|
|
|
3524
3876
|
for (const reference of listed)
|
|
3525
3877
|
if (reference.endsWith(".xcodeproj")) addProject(reference);
|
|
3526
3878
|
if (projects2.length === 0) {
|
|
3527
|
-
throw new Error(`${
|
|
3879
|
+
throw new Error(`${import_node_path10.default.basename(xcodeprojOrWorkspace)} lists no Xcode project`);
|
|
3528
3880
|
}
|
|
3529
3881
|
return { listed, projects: projects2, projectAt };
|
|
3530
3882
|
}
|
|
3531
|
-
var
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3883
|
+
var targetRefs = /* @__PURE__ */ new WeakMap();
|
|
3884
|
+
function nativeTargets(project) {
|
|
3885
|
+
let refs = targetRefs.get(project);
|
|
3886
|
+
if (!refs) {
|
|
3887
|
+
refs = list(project.project.targets).flatMap((id) => {
|
|
3888
|
+
const target = project.object(id);
|
|
3889
|
+
return target?.isa === "PBXNativeTarget" ? [{ project, id, target }] : [];
|
|
3890
|
+
});
|
|
3891
|
+
targetRefs.set(project, refs);
|
|
3892
|
+
}
|
|
3893
|
+
return refs;
|
|
3894
|
+
}
|
|
3535
3895
|
function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
3536
3896
|
const workspace = xcodeprojOrWorkspace.endsWith(".xcworkspace") ? xcodeprojOrWorkspace : null;
|
|
3537
3897
|
const { listed, projects: projects2, projectAt } = workspaceProjects(xcodeprojOrWorkspace);
|
|
3538
3898
|
const allTargets = projects2.flatMap(nativeTargets);
|
|
3539
3899
|
const appTargets = allTargets.filter((ref) => ref.target.productType === APPLICATION);
|
|
3540
3900
|
const appTargetNames = appTargets.map((ref) => str(ref.target.name) ?? ref.id);
|
|
3541
|
-
const container =
|
|
3901
|
+
const container = import_node_path10.default.basename(xcodeprojOrWorkspace);
|
|
3542
3902
|
const named = targetName ? appTargets.filter((ref) => ref.target.name === targetName) : appTargets;
|
|
3543
3903
|
if (named.length !== 1) {
|
|
3544
3904
|
throw new Error(
|
|
@@ -3550,14 +3910,14 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
3550
3910
|
for (const ref of allTargets) {
|
|
3551
3911
|
const product = ref.project.object(str(ref.target.productReference));
|
|
3552
3912
|
const file = str(product?.path);
|
|
3553
|
-
if (file && !byProduct.has(
|
|
3554
|
-
byProduct.set(
|
|
3913
|
+
if (file && !byProduct.has(import_node_path10.default.basename(file)))
|
|
3914
|
+
byProduct.set(import_node_path10.default.basename(file), ref);
|
|
3555
3915
|
}
|
|
3556
3916
|
const proxied = (project, proxyId) => {
|
|
3557
3917
|
const proxy = project.object(proxyId);
|
|
3558
3918
|
if (proxy?.isa !== "PBXContainerItemProxy") return void 0;
|
|
3559
3919
|
const portal = str(proxy.containerPortal);
|
|
3560
|
-
const owner = project.object(portal)?.isa === "PBXProject" ? project : projectAt.get(
|
|
3920
|
+
const owner = project.object(portal)?.isa === "PBXProject" ? project : projectAt.get(import_node_path10.default.resolve(project.resolvePath(portal ?? "") ?? ""));
|
|
3561
3921
|
const remote = str(proxy.remoteGlobalIDString);
|
|
3562
3922
|
if (!owner || !remote) return void 0;
|
|
3563
3923
|
return nativeTargets(owner).find(
|
|
@@ -3578,7 +3938,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
3578
3938
|
if (phase?.isa !== "PBXFrameworksBuildPhase") continue;
|
|
3579
3939
|
for (const buildFileId of list(phase.files)) {
|
|
3580
3940
|
const file = project.object(str(project.object(buildFileId)?.fileRef));
|
|
3581
|
-
const resolved = file?.isa === "PBXReferenceProxy" ? proxied(project, str(file.remoteRef)) : file && str(file.sourceTree) === "BUILT_PRODUCTS_DIR" ? byProduct.get(
|
|
3941
|
+
const resolved = file?.isa === "PBXReferenceProxy" ? proxied(project, str(file.remoteRef)) : file && str(file.sourceTree) === "BUILT_PRODUCTS_DIR" ? byProduct.get(import_node_path10.default.basename(str(file.path) ?? "")) : void 0;
|
|
3582
3942
|
if (resolved) found.push(resolved);
|
|
3583
3943
|
}
|
|
3584
3944
|
}
|
|
@@ -3599,7 +3959,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
3599
3959
|
const name = str(ref.target.name) ?? ref.id;
|
|
3600
3960
|
const { get: settings2, keys } = targetSettings(ref, {
|
|
3601
3961
|
TARGET_NAME: name,
|
|
3602
|
-
PROJECT_NAME:
|
|
3962
|
+
PROJECT_NAME: import_node_path10.default.basename(ref.project.xcodeproj, ".xcodeproj"),
|
|
3603
3963
|
SRCROOT: ref.project.projectDir,
|
|
3604
3964
|
SOURCE_ROOT: ref.project.projectDir,
|
|
3605
3965
|
PROJECT_DIR: ref.project.projectDir,
|
|
@@ -3630,7 +3990,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
3630
3990
|
}
|
|
3631
3991
|
return value;
|
|
3632
3992
|
};
|
|
3633
|
-
const infoPlistFile = settings("INFOPLIST_FILE") ?
|
|
3993
|
+
const infoPlistFile = settings("INFOPLIST_FILE") ? import_node_path10.default.resolve(app.project.projectDir, settings("INFOPLIST_FILE")) : null;
|
|
3634
3994
|
const sourceInfo = infoPlistFile ? import_plist.default.parse(import_node_fs8.default.readFileSync(infoPlistFile, "utf8")) : {};
|
|
3635
3995
|
if (!sourceInfo || typeof sourceInfo !== "object" || Array.isArray(sourceInfo) || sourceInfo instanceof Date || Buffer.isBuffer(sourceInfo)) {
|
|
3636
3996
|
throw new Error(`${module2.name} Info.plist must contain a dictionary`);
|
|
@@ -3649,12 +4009,12 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
3649
4009
|
};
|
|
3650
4010
|
}
|
|
3651
4011
|
const localPackageDirs = [
|
|
3652
|
-
...listed.filter((reference) => import_node_fs8.default.existsSync(
|
|
4012
|
+
...listed.filter((reference) => import_node_fs8.default.existsSync(import_node_path10.default.join(reference, "Package.swift"))),
|
|
3653
4013
|
...projects2.flatMap(
|
|
3654
4014
|
(project) => Object.entries(project.objects).flatMap(([id, entry]) => {
|
|
3655
4015
|
if (!isDict(entry)) return [];
|
|
3656
|
-
const candidate = entry.isa === "XCLocalSwiftPackageReference" ?
|
|
3657
|
-
return candidate && import_node_fs8.default.existsSync(
|
|
4016
|
+
const candidate = entry.isa === "XCLocalSwiftPackageReference" ? import_node_path10.default.resolve(project.projectDir, str(entry.relativePath) ?? "") : entry.isa === "PBXFileReference" ? project.resolvePath(id) : null;
|
|
4017
|
+
return candidate && import_node_fs8.default.existsSync(import_node_path10.default.join(candidate, "Package.swift")) ? [candidate] : [];
|
|
3658
4018
|
})
|
|
3659
4019
|
)
|
|
3660
4020
|
];
|
|
@@ -3663,7 +4023,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
3663
4023
|
const cached = graphs.get(dir);
|
|
3664
4024
|
if (cached) return cached;
|
|
3665
4025
|
const graph = swiftManifestGraph(
|
|
3666
|
-
import_node_fs8.default.readFileSync(
|
|
4026
|
+
import_node_fs8.default.readFileSync(import_node_path10.default.join(dir, "Package.swift"), "utf8")
|
|
3667
4027
|
);
|
|
3668
4028
|
graphs.set(dir, graph);
|
|
3669
4029
|
return graph;
|
|
@@ -3698,7 +4058,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
3698
4058
|
});
|
|
3699
4059
|
} else if (reference?.isa === "XCLocalSwiftPackageReference") {
|
|
3700
4060
|
localPackages.add(
|
|
3701
|
-
|
|
4061
|
+
import_node_path10.default.resolve(project.projectDir, str(reference.relativePath) ?? "")
|
|
3702
4062
|
);
|
|
3703
4063
|
} else if (localProducts.has(product)) {
|
|
3704
4064
|
localPackages.add(localProducts.get(product));
|
|
@@ -3710,8 +4070,8 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
3710
4070
|
const dir = pending.pop();
|
|
3711
4071
|
const graph = graphOf(dir);
|
|
3712
4072
|
for (const relative of graph.packagePaths) {
|
|
3713
|
-
const next =
|
|
3714
|
-
if (localPackages.has(next) || !import_node_fs8.default.existsSync(
|
|
4073
|
+
const next = import_node_path10.default.resolve(dir, relative);
|
|
4074
|
+
if (localPackages.has(next) || !import_node_fs8.default.existsSync(import_node_path10.default.join(next, "Package.swift")))
|
|
3715
4075
|
continue;
|
|
3716
4076
|
localPackages.add(next);
|
|
3717
4077
|
pending.push(next);
|
|
@@ -3725,8 +4085,8 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
3725
4085
|
}
|
|
3726
4086
|
}
|
|
3727
4087
|
}
|
|
3728
|
-
const resolvedFile =
|
|
3729
|
-
workspace ??
|
|
4088
|
+
const resolvedFile = import_node_path10.default.join(
|
|
4089
|
+
workspace ?? import_node_path10.default.join(xcodeprojOrWorkspace, "project.xcworkspace"),
|
|
3730
4090
|
"xcshareddata",
|
|
3731
4091
|
"swiftpm",
|
|
3732
4092
|
"Package.resolved"
|
|
@@ -3736,12 +4096,12 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
3736
4096
|
...module2,
|
|
3737
4097
|
rootDir: commonAncestor(
|
|
3738
4098
|
[
|
|
3739
|
-
workspace ?
|
|
4099
|
+
workspace ? import_node_path10.default.dirname(workspace) : app.project.projectDir,
|
|
3740
4100
|
...used.map((project) => project.projectDir),
|
|
3741
4101
|
...localPackages
|
|
3742
4102
|
].map((dir) => import_node_fs8.default.realpathSync(dir))
|
|
3743
4103
|
),
|
|
3744
|
-
|
|
4104
|
+
projectFiles: [...new Set(used.map((project) => project.projectFile))].sort(),
|
|
3745
4105
|
infoPlist: import_plist.default.build(info),
|
|
3746
4106
|
infoPlistFile,
|
|
3747
4107
|
frameworks,
|
|
@@ -3768,17 +4128,17 @@ var SKIP_SOURCE_DIRS = /* @__PURE__ */ new Set([
|
|
|
3768
4128
|
var NATIVE_DESCRIPTOR = ".one-native-source.json";
|
|
3769
4129
|
var NATIVE_GLUE = ".one-native-source.swift.txt";
|
|
3770
4130
|
function swiftPackageId(packagePath) {
|
|
3771
|
-
return
|
|
4131
|
+
return import_node_path11.default.basename(packagePath).replace(/[^A-Za-z0-9_]/g, "_").replace(/^(\d)/, "_$1");
|
|
3772
4132
|
}
|
|
3773
4133
|
function nativeSourceDescriptor(packagePath) {
|
|
3774
4134
|
packagePath = import_node_fs9.default.realpathSync(packagePath);
|
|
3775
|
-
const file =
|
|
4135
|
+
const file = import_node_path11.default.join(packagePath, NATIVE_DESCRIPTOR);
|
|
3776
4136
|
if (!import_node_fs9.default.existsSync(file)) return null;
|
|
3777
4137
|
const value = JSON.parse(
|
|
3778
4138
|
readPackageFile(packagePath, file, MAX_SWIFT_COMPILE_SOURCE_BYTES).toString("utf8")
|
|
3779
4139
|
);
|
|
3780
4140
|
const invalid = () => new Error(`${file}: invalid One native source descriptor; run one typegen`);
|
|
3781
|
-
if (!value || typeof value !== "object" || Reflect.get(value, "generatedBy") !== "one typegen" || !import_node_fs9.default.existsSync(
|
|
4141
|
+
if (!value || typeof value !== "object" || Reflect.get(value, "generatedBy") !== "one typegen" || !import_node_fs9.default.existsSync(import_node_path11.default.join(packagePath, NATIVE_GLUE))) {
|
|
3782
4142
|
throw invalid();
|
|
3783
4143
|
}
|
|
3784
4144
|
if (!isSwiftNativeModules(value) || value.packageId !== swiftPackageId(packagePath)) {
|
|
@@ -3788,7 +4148,7 @@ function nativeSourceDescriptor(packagePath) {
|
|
|
3788
4148
|
}
|
|
3789
4149
|
function nativeSourceFiles(packagePath) {
|
|
3790
4150
|
packagePath = import_node_fs9.default.realpathSync(packagePath);
|
|
3791
|
-
return [NATIVE_DESCRIPTOR, NATIVE_GLUE].map((name) =>
|
|
4151
|
+
return [NATIVE_DESCRIPTOR, NATIVE_GLUE].map((name) => import_node_path11.default.join(packagePath, name)).filter((file) => import_node_fs9.default.existsSync(file));
|
|
3792
4152
|
}
|
|
3793
4153
|
var projects = /* @__PURE__ */ new Map();
|
|
3794
4154
|
function projectFor(packagePath, hosted) {
|
|
@@ -3836,22 +4196,22 @@ function remotePackages(entry, app) {
|
|
|
3836
4196
|
var XCODE_APP_DIR = "__app__";
|
|
3837
4197
|
var XCODE_FRAMEWORKS_DIR = "__frameworks__";
|
|
3838
4198
|
var XCODE_PACKAGES_DIR = "__packages__";
|
|
3839
|
-
var CHECKOUTS_PREFIX = `${REMOTE_CHECKOUTS.split(
|
|
4199
|
+
var CHECKOUTS_PREFIX = `${REMOTE_CHECKOUTS.split(import_node_path11.default.sep).join(import_node_path11.default.posix.sep)}/`;
|
|
3840
4200
|
function xcodeInputKey(layout, file, relative) {
|
|
3841
4201
|
const owner = layout.targetDirs.get(file);
|
|
3842
|
-
if (owner) return
|
|
3843
|
-
return relative.startsWith(CHECKOUTS_PREFIX) ?
|
|
4202
|
+
if (owner) return import_node_path11.default.posix.join(owner, relative);
|
|
4203
|
+
return relative.startsWith(CHECKOUTS_PREFIX) ? import_node_path11.default.posix.join(XCODE_PACKAGES_DIR, relative.slice(CHECKOUTS_PREFIX.length)) : relative;
|
|
3844
4204
|
}
|
|
3845
4205
|
function xcodeLayout(root) {
|
|
3846
4206
|
const registered = xcodeProjects.get(root);
|
|
3847
4207
|
if (!registered) return null;
|
|
3848
4208
|
const app = readXcodeAppTarget(registered.xcodeproj, registered.target);
|
|
3849
|
-
const files = /* @__PURE__ */ new Set([...app.
|
|
4209
|
+
const files = /* @__PURE__ */ new Set([...app.projectFiles, ...app.sources, ...app.resources]);
|
|
3850
4210
|
if (app.infoPlistFile) files.add(app.infoPlistFile);
|
|
3851
4211
|
const targetDirs = new Map(app.sources.map((file) => [file, XCODE_APP_DIR]));
|
|
3852
4212
|
const targets = [];
|
|
3853
4213
|
for (const framework of app.frameworks) {
|
|
3854
|
-
const dir =
|
|
4214
|
+
const dir = import_node_path11.default.posix.join(XCODE_FRAMEWORKS_DIR, framework.moduleName);
|
|
3855
4215
|
for (const file of framework.sources) {
|
|
3856
4216
|
if (targetDirs.has(file)) continue;
|
|
3857
4217
|
targetDirs.set(file, dir);
|
|
@@ -3867,21 +4227,21 @@ function xcodeLayout(root) {
|
|
|
3867
4227
|
});
|
|
3868
4228
|
}
|
|
3869
4229
|
for (const dir of app.localPackages) {
|
|
3870
|
-
const manifestFile =
|
|
4230
|
+
const manifestFile = import_node_path11.default.join(dir, "Package.swift");
|
|
3871
4231
|
files.add(manifestFile);
|
|
3872
4232
|
const manifest = import_node_fs9.default.readFileSync(manifestFile, "utf8");
|
|
3873
|
-
const prefix =
|
|
4233
|
+
const prefix = import_node_path11.default.relative(root, dir).split(import_node_path11.default.sep).join(import_node_path11.default.posix.sep);
|
|
3874
4234
|
const declared = swiftManifestTargets(manifest).filter((target) => !target.executable);
|
|
3875
4235
|
const all = declared.flatMap(
|
|
3876
|
-
(target) => sourceTreeFiles(
|
|
3877
|
-
(file) =>
|
|
4236
|
+
(target) => sourceTreeFiles(import_node_path11.default.join(dir, target.path), root).map(
|
|
4237
|
+
(file) => import_node_path11.default.relative(dir, file).split(import_node_path11.default.sep).join(import_node_path11.default.posix.sep)
|
|
3878
4238
|
)
|
|
3879
4239
|
);
|
|
3880
4240
|
for (const target of swiftManifestTargets(manifest, all)) {
|
|
3881
4241
|
if (target.executable) continue;
|
|
3882
|
-
targets.push({ ...target, path:
|
|
4242
|
+
targets.push({ ...target, path: import_node_path11.default.posix.join(prefix, target.path) });
|
|
3883
4243
|
for (const relative of all) {
|
|
3884
|
-
if (relative.startsWith(`${target.path}/`)) files.add(
|
|
4244
|
+
if (relative.startsWith(`${target.path}/`)) files.add(import_node_path11.default.join(dir, relative));
|
|
3885
4245
|
}
|
|
3886
4246
|
}
|
|
3887
4247
|
}
|
|
@@ -3889,9 +4249,9 @@ function xcodeLayout(root) {
|
|
|
3889
4249
|
for (const target of remote.targets) {
|
|
3890
4250
|
targets.push({
|
|
3891
4251
|
...target,
|
|
3892
|
-
path:
|
|
4252
|
+
path: import_node_path11.default.posix.join(
|
|
3893
4253
|
XCODE_PACKAGES_DIR,
|
|
3894
|
-
|
|
4254
|
+
import_node_path11.default.relative(import_node_path11.default.join(root, REMOTE_CHECKOUTS), target.dir).split(import_node_path11.default.sep).join(import_node_path11.default.posix.sep)
|
|
3895
4255
|
)
|
|
3896
4256
|
});
|
|
3897
4257
|
for (const file of target.files) files.add(file);
|
|
@@ -3929,15 +4289,15 @@ function sourceTreeFiles(dir, canonicalRoot) {
|
|
|
3929
4289
|
for (const entry of import_node_fs9.default.readdirSync(dir2, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
|
|
3930
4290
|
if (entry.name.startsWith(".") && entry.name !== NATIVE_DESCRIPTOR && entry.name !== NATIVE_GLUE || SKIP_SOURCE_DIRS.has(entry.name))
|
|
3931
4291
|
continue;
|
|
3932
|
-
const full =
|
|
4292
|
+
const full = import_node_path11.default.join(dir2, entry.name);
|
|
3933
4293
|
if (entry.isSymbolicLink()) throw new Error(`swift input is a symlink: ${full}`);
|
|
3934
4294
|
const real = import_node_fs9.default.realpathSync(full);
|
|
3935
|
-
const relative =
|
|
3936
|
-
if (relative.startsWith(`..${
|
|
4295
|
+
const relative = import_node_path11.default.relative(canonicalRoot, real);
|
|
4296
|
+
if (relative.startsWith(`..${import_node_path11.default.sep}`) || relative === ".." || import_node_path11.default.isAbsolute(relative)) {
|
|
3937
4297
|
throw new Error(`swift input escapes the selected package: ${full}`);
|
|
3938
4298
|
}
|
|
3939
4299
|
if (entry.isDirectory()) {
|
|
3940
|
-
if (import_node_fs9.default.existsSync(
|
|
4300
|
+
if (import_node_fs9.default.existsSync(import_node_path11.default.join(full, "Package.swift"))) continue;
|
|
3941
4301
|
walk2(full);
|
|
3942
4302
|
} else if (entry.isFile()) {
|
|
3943
4303
|
found.push(full);
|
|
@@ -3950,16 +4310,16 @@ function sourceTreeFiles(dir, canonicalRoot) {
|
|
|
3950
4310
|
}
|
|
3951
4311
|
function readPackageFile(root, file, maxBytes) {
|
|
3952
4312
|
const canonicalRoot = import_node_fs9.default.realpathSync(root);
|
|
3953
|
-
const relative =
|
|
3954
|
-
if (relative === ".." || relative.startsWith(`..${
|
|
4313
|
+
const relative = import_node_path11.default.relative(canonicalRoot, import_node_fs9.default.realpathSync(file));
|
|
4314
|
+
if (relative === ".." || relative.startsWith(`..${import_node_path11.default.sep}`) || import_node_path11.default.isAbsolute(relative)) {
|
|
3955
4315
|
throw new Error(`swift input escapes the selected package: ${file}`);
|
|
3956
4316
|
}
|
|
3957
|
-
let ancestor =
|
|
4317
|
+
let ancestor = import_node_path11.default.resolve(file);
|
|
3958
4318
|
while (ancestor !== canonicalRoot) {
|
|
3959
4319
|
if (import_node_fs9.default.lstatSync(ancestor).isSymbolicLink()) {
|
|
3960
4320
|
throw new Error(`swift input is a symlink: ${ancestor}`);
|
|
3961
4321
|
}
|
|
3962
|
-
const parent =
|
|
4322
|
+
const parent = import_node_path11.default.dirname(ancestor);
|
|
3963
4323
|
if (parent === ancestor)
|
|
3964
4324
|
throw new Error(`swift input escapes the selected package: ${file}`);
|
|
3965
4325
|
ancestor = parent;
|
|
@@ -3994,7 +4354,7 @@ function sourceFiles(root) {
|
|
|
3994
4354
|
}
|
|
3995
4355
|
function resourceCandidateFiles(root) {
|
|
3996
4356
|
return packageFiles(root).filter(
|
|
3997
|
-
(file) => !file.endsWith(".swift") &&
|
|
4357
|
+
(file) => !file.endsWith(".swift") && !["project.pbxproj", "project.xcproj"].includes(import_node_path11.default.basename(file))
|
|
3998
4358
|
);
|
|
3999
4359
|
}
|
|
4000
4360
|
var HOSTED_LIMITS = {
|
|
@@ -4028,7 +4388,7 @@ function buildSwiftResourceTable(project, baseUrl) {
|
|
|
4028
4388
|
const limits = inputLimits(Boolean(project.hosted));
|
|
4029
4389
|
const absolute = resourceCandidateFiles(project.packagePath);
|
|
4030
4390
|
const relative = absolute.map(
|
|
4031
|
-
(file) =>
|
|
4391
|
+
(file) => import_node_path11.default.relative(project.packagePath, file).split(import_node_path11.default.sep).join(import_node_path11.default.posix.sep)
|
|
4032
4392
|
);
|
|
4033
4393
|
const byRelative = new Map(absolute.map((file, index) => [relative[index], file]));
|
|
4034
4394
|
const readContents = (candidate) => {
|
|
@@ -4056,10 +4416,10 @@ function buildSwiftResourceTable(project, baseUrl) {
|
|
|
4056
4416
|
const bytes = readPackageFile(project.packagePath, disk, limits.imageBytes);
|
|
4057
4417
|
imageBytes += bytes.length;
|
|
4058
4418
|
const hash = (0, import_node_crypto4.createHash)("sha256").update(bytes).digest("hex").slice(0, 16);
|
|
4059
|
-
const ext =
|
|
4419
|
+
const ext = import_node_path11.default.posix.extname(file).toLowerCase();
|
|
4060
4420
|
table[name] = { uri: `${baseUrl}${RESOURCE_PATH}${hash}${ext}`, scale };
|
|
4061
4421
|
images[name] = {
|
|
4062
|
-
file:
|
|
4422
|
+
file: import_node_path11.default.posix.basename(file),
|
|
4063
4423
|
data: bytes.toString("base64")
|
|
4064
4424
|
};
|
|
4065
4425
|
watched.push(file);
|
|
@@ -4086,7 +4446,7 @@ function buildSwiftBundleFiles(packagePath, hosted) {
|
|
|
4086
4446
|
packagePath = import_node_fs9.default.realpathSync(packagePath);
|
|
4087
4447
|
const limits = inputLimits(hosted);
|
|
4088
4448
|
const relative = resourceCandidateFiles(packagePath).map(
|
|
4089
|
-
(file) =>
|
|
4449
|
+
(file) => import_node_path11.default.relative(packagePath, file).split(import_node_path11.default.sep).join(import_node_path11.default.posix.sep)
|
|
4090
4450
|
);
|
|
4091
4451
|
const files = {};
|
|
4092
4452
|
const watched = [];
|
|
@@ -4100,12 +4460,12 @@ function buildSwiftBundleFiles(packagePath, hosted) {
|
|
|
4100
4460
|
total += bytes.length;
|
|
4101
4461
|
if (xcode.app.infoPlistFile)
|
|
4102
4462
|
watched.push(
|
|
4103
|
-
|
|
4463
|
+
import_node_path11.default.relative(packagePath, xcode.app.infoPlistFile).split(import_node_path11.default.sep).join("/")
|
|
4104
4464
|
);
|
|
4105
4465
|
}
|
|
4106
4466
|
for (const { base, file } of enumerateBundleJson(relative)) {
|
|
4107
4467
|
watched.push(file);
|
|
4108
|
-
const disk =
|
|
4468
|
+
const disk = import_node_path11.default.join(packagePath, ...file.split("/"));
|
|
4109
4469
|
if (Object.keys(files).length >= limits.resources || total + import_node_fs9.default.statSync(disk).size > limits.resourceTotalBytes) {
|
|
4110
4470
|
throw new Error(
|
|
4111
4471
|
`swift bundle pack exceeds ${limits.resources} files / ${limits.resourceTotalBytes} bytes`
|
|
@@ -4126,7 +4486,7 @@ function linkedModuleRoots(packagePath) {
|
|
|
4126
4486
|
try {
|
|
4127
4487
|
manifest = readPackageFile(
|
|
4128
4488
|
packagePath,
|
|
4129
|
-
|
|
4489
|
+
import_node_path11.default.join(packagePath, "Package.swift"),
|
|
4130
4490
|
MAX_SWIFT_COMPILE_SOURCE_BYTES
|
|
4131
4491
|
).toString("utf8");
|
|
4132
4492
|
} catch {
|
|
@@ -4135,8 +4495,8 @@ function linkedModuleRoots(packagePath) {
|
|
|
4135
4495
|
const roots = /* @__PURE__ */ new Set();
|
|
4136
4496
|
const dependency = /\.package\(\s*path:\s*"([^"]+)"\s*\)/g;
|
|
4137
4497
|
for (const match of manifest.replace(/^\s*\/\/.*$/gm, "").matchAll(dependency)) {
|
|
4138
|
-
const root =
|
|
4139
|
-
if (import_node_fs9.default.existsSync(
|
|
4498
|
+
const root = import_node_path11.default.resolve(packagePath, match[1]);
|
|
4499
|
+
if (import_node_fs9.default.existsSync(import_node_path11.default.join(root, "Package.swift"))) roots.add(root);
|
|
4140
4500
|
}
|
|
4141
4501
|
return [...roots].sort();
|
|
4142
4502
|
}
|
|
@@ -4145,25 +4505,25 @@ function sourceStamp(packagePath, moduleRootOverride, hosted = false) {
|
|
|
4145
4505
|
hash.update(packagePath);
|
|
4146
4506
|
const projectInputs = new Set(packageFiles(packagePath));
|
|
4147
4507
|
for (const file of [...projectInputs].sort()) {
|
|
4148
|
-
hash.update(
|
|
4508
|
+
hash.update(import_node_path11.default.relative(packagePath, file));
|
|
4149
4509
|
const stat = import_node_fs9.default.statSync(file);
|
|
4150
4510
|
hash.update(`${stat.mtimeMs}/${stat.ctimeMs}/${stat.size}`);
|
|
4151
4511
|
}
|
|
4152
4512
|
const moduleRoot = hosted ? void 0 : moduleRootOverride ?? linkedModuleRoots(packagePath).find(
|
|
4153
|
-
(root) => import_node_fs9.default.existsSync(
|
|
4513
|
+
(root) => import_node_fs9.default.existsSync(import_node_path11.default.join(root, "toolchain.json"))
|
|
4154
4514
|
);
|
|
4155
4515
|
if (moduleRoot) {
|
|
4156
4516
|
hash.update(moduleRoot);
|
|
4157
4517
|
for (const relative of swiftModuleInputFiles(moduleRoot)) {
|
|
4158
4518
|
hash.update(relative);
|
|
4159
|
-
hash.update(String(import_node_fs9.default.statSync(
|
|
4519
|
+
hash.update(String(import_node_fs9.default.statSync(import_node_path11.default.join(moduleRoot, relative)).mtimeMs));
|
|
4160
4520
|
}
|
|
4161
4521
|
}
|
|
4162
4522
|
return hash.digest("hex").slice(0, 16);
|
|
4163
4523
|
}
|
|
4164
4524
|
function entryRootId(packagePath, file) {
|
|
4165
|
-
const relative =
|
|
4166
|
-
return `${
|
|
4525
|
+
const relative = import_node_path11.default.relative(packagePath, file).split(import_node_path11.default.sep).join(import_node_path11.default.posix.sep);
|
|
4526
|
+
return `${import_node_path11.default.basename(packagePath)}${import_node_path11.default.posix.sep}${relative}`;
|
|
4167
4527
|
}
|
|
4168
4528
|
function icuUrl(origin, artifact) {
|
|
4169
4529
|
return "url" in artifact.icu ? artifact.icu.url : `${origin}${ICU_PATH}${artifact.icu.sha256}`;
|
|
@@ -4172,8 +4532,8 @@ function packageSources(packagePath) {
|
|
|
4172
4532
|
const xcode = xcodeLayout(packagePath);
|
|
4173
4533
|
const files = {};
|
|
4174
4534
|
for (const file of sourceFiles(packagePath)) {
|
|
4175
|
-
const relative =
|
|
4176
|
-
if (xcode &&
|
|
4535
|
+
const relative = import_node_path11.default.relative(packagePath, file).split(import_node_path11.default.sep).join(import_node_path11.default.posix.sep);
|
|
4536
|
+
if (xcode && import_node_path11.default.basename(file) === "Package.swift") continue;
|
|
4177
4537
|
files[xcode ? xcodeInputKey(xcode, file, relative) : relative] = readPackageFile(
|
|
4178
4538
|
packagePath,
|
|
4179
4539
|
file,
|
|
@@ -4190,7 +4550,7 @@ function packageSnapshot(project) {
|
|
|
4190
4550
|
files,
|
|
4191
4551
|
resourcePaths: swiftImplicitResourcePaths(
|
|
4192
4552
|
resourceCandidateFiles(project.packagePath).map(
|
|
4193
|
-
(file) =>
|
|
4553
|
+
(file) => import_node_path11.default.relative(project.packagePath, file).split(import_node_path11.default.sep).join(import_node_path11.default.posix.sep)
|
|
4194
4554
|
)
|
|
4195
4555
|
),
|
|
4196
4556
|
resources: buildSwiftResourceTable(project, ""),
|
|
@@ -4199,7 +4559,7 @@ function packageSnapshot(project) {
|
|
|
4199
4559
|
...native ? {
|
|
4200
4560
|
glue: readPackageFile(
|
|
4201
4561
|
project.packagePath,
|
|
4202
|
-
|
|
4562
|
+
import_node_path11.default.join(project.packagePath, NATIVE_GLUE),
|
|
4203
4563
|
MAX_SWIFT_COMPILE_SOURCE_BYTES
|
|
4204
4564
|
).toString("utf8")
|
|
4205
4565
|
} : {}
|
|
@@ -4238,7 +4598,7 @@ async function compile(packagePath, entry, stamp, moduleRootOverride, hosted, sn
|
|
|
4238
4598
|
package: content
|
|
4239
4599
|
};
|
|
4240
4600
|
const moduleRoot = moduleRootOverride ?? linkedModuleRoots(packagePath).find(
|
|
4241
|
-
(root) => import_node_fs9.default.existsSync(
|
|
4601
|
+
(root) => import_node_fs9.default.existsSync(import_node_path11.default.join(root, "toolchain.json"))
|
|
4242
4602
|
) ?? await swiftDistributionRoot();
|
|
4243
4603
|
if (!moduleRoot)
|
|
4244
4604
|
return {
|
|
@@ -4264,10 +4624,10 @@ async function compile(packagePath, entry, stamp, moduleRootOverride, hosted, sn
|
|
|
4264
4624
|
// server and a capture, or two checkouts) build each other's sources. so
|
|
4265
4625
|
// each app and module checkout gets its own root, which keeps the same
|
|
4266
4626
|
// app's incremental build across restarts.
|
|
4267
|
-
buildRoot: process.env.CONTRAST_SWIFT_BUILD_ROOT ??
|
|
4627
|
+
buildRoot: process.env.CONTRAST_SWIFT_BUILD_ROOT ?? import_node_path11.default.join(
|
|
4268
4628
|
import_node_os5.default.tmpdir(),
|
|
4269
4629
|
"contrast-swift-build",
|
|
4270
|
-
(0, import_node_crypto4.createHash)("sha256").update(`${moduleRoot}\0${
|
|
4630
|
+
(0, import_node_crypto4.createHash)("sha256").update(`${moduleRoot}\0${import_node_path11.default.resolve(packagePath)}`).digest("hex").slice(0, 16)
|
|
4271
4631
|
),
|
|
4272
4632
|
moduleRoot,
|
|
4273
4633
|
...toolchain
|
|
@@ -4352,7 +4712,7 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
|
|
|
4352
4712
|
const auth = hosted ? null : resolveCliAuth();
|
|
4353
4713
|
if (!hosted && (!auth || auth.kind === "github")) {
|
|
4354
4714
|
throw new Error(
|
|
4355
|
-
`compiling ${
|
|
4715
|
+
`compiling ${import_node_path11.default.basename(packagePath)} for Peach needs \`peach login\` or PEACH_API_KEY: this peachsim has no local SwiftUI module, so Contrast compiles it`
|
|
4356
4716
|
);
|
|
4357
4717
|
}
|
|
4358
4718
|
const origin = hosted?.origin ?? resolveContrastBackendOrigin(auth?.kind === "session" ? auth.origin : null);
|
|
@@ -4368,10 +4728,10 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
|
|
|
4368
4728
|
});
|
|
4369
4729
|
if (!submit) throw new Error("swift compile: no credential to submit with");
|
|
4370
4730
|
const sources = Object.values(snapshot.files);
|
|
4371
|
-
const bytes = sources.reduce((total2,
|
|
4731
|
+
const bytes = sources.reduce((total2, text2) => total2 + Buffer.byteLength(text2), 0);
|
|
4372
4732
|
if (sources.length > MAX_SWIFT_COMPILE_FILES || bytes > MAX_SWIFT_COMPILE_SOURCE_BYTES) {
|
|
4373
4733
|
throw new Error(
|
|
4374
|
-
`${
|
|
4734
|
+
`${import_node_path11.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`
|
|
4375
4735
|
);
|
|
4376
4736
|
}
|
|
4377
4737
|
const descriptor = snapshot.native;
|
|
@@ -4390,7 +4750,7 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
|
|
|
4390
4750
|
);
|
|
4391
4751
|
if (descriptor && address.native?.hash !== descriptor.hash) {
|
|
4392
4752
|
throw new Error(
|
|
4393
|
-
`${
|
|
4753
|
+
`${import_node_path11.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`
|
|
4394
4754
|
);
|
|
4395
4755
|
}
|
|
4396
4756
|
const response = await fetch(address.url, { signal });
|
|
@@ -4465,11 +4825,11 @@ function artifactFor(project, entry, moduleRoot) {
|
|
|
4465
4825
|
function swiftPackageWatchFiles(packagePath, moduleRoot) {
|
|
4466
4826
|
packagePath = import_node_fs9.default.realpathSync(packagePath);
|
|
4467
4827
|
return [
|
|
4468
|
-
...xcodeProjects.has(packagePath) ? [] : [
|
|
4828
|
+
...xcodeProjects.has(packagePath) ? [] : [import_node_path11.default.join(packagePath, "Package.swift")],
|
|
4469
4829
|
...sourceFiles(packagePath),
|
|
4470
4830
|
...nativeSourceFiles(packagePath),
|
|
4471
4831
|
...resourceCandidateFiles(packagePath),
|
|
4472
|
-
...moduleRoot ? swiftModuleInputFiles(moduleRoot).map((file) =>
|
|
4832
|
+
...moduleRoot ? swiftModuleInputFiles(moduleRoot).map((file) => import_node_path11.default.join(moduleRoot, file)) : []
|
|
4473
4833
|
];
|
|
4474
4834
|
}
|
|
4475
4835
|
async function swiftPackageMetadata(packagePath, packageName, moduleRoot, origin, hosted) {
|
|
@@ -4487,7 +4847,7 @@ async function swiftPackageMetadata(packagePath, packageName, moduleRoot, origin
|
|
|
4487
4847
|
);
|
|
4488
4848
|
}
|
|
4489
4849
|
const project = projectFor(packagePath, hosted);
|
|
4490
|
-
const entry = mains.length === 1 ?
|
|
4850
|
+
const entry = mains.length === 1 ? import_node_path11.default.relative(packagePath, mains[0]).split(import_node_path11.default.sep).join(import_node_path11.default.posix.sep) : Object.entries(native?.files ?? {}).find(
|
|
4491
4851
|
([_file, names]) => names.length > 0
|
|
4492
4852
|
)?.[0];
|
|
4493
4853
|
if (!entry) throw new Error(`swift package ${packageName} has no native module source`);
|
|
@@ -4576,12 +4936,12 @@ function artifactUrl(project, artifact) {
|
|
|
4576
4936
|
return `${serverOrigin()}${ARTIFACT_PATH2}${artifact.hash}.wasm`;
|
|
4577
4937
|
}
|
|
4578
4938
|
function packageFor(file) {
|
|
4579
|
-
let dir =
|
|
4939
|
+
let dir = import_node_path12.default.dirname(file);
|
|
4580
4940
|
const stop = devServer?.config.root;
|
|
4581
4941
|
for (; ; ) {
|
|
4582
|
-
if (import_node_fs10.default.existsSync(
|
|
4583
|
-
if (stop !== void 0 && dir === stop ||
|
|
4584
|
-
dir =
|
|
4942
|
+
if (import_node_fs10.default.existsSync(import_node_path12.default.join(dir, "Package.swift"))) return dir;
|
|
4943
|
+
if (stop !== void 0 && dir === stop || import_node_path12.default.dirname(dir) === dir) break;
|
|
4944
|
+
dir = import_node_path12.default.dirname(dir);
|
|
4585
4945
|
}
|
|
4586
4946
|
throw new Error(
|
|
4587
4947
|
`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`
|
|
@@ -4602,7 +4962,7 @@ function swiftPlugin(options = {}) {
|
|
|
4602
4962
|
if (!resolved) throw new Error(`cannot resolve swift source ${source}`);
|
|
4603
4963
|
let id = resolved.id;
|
|
4604
4964
|
if (importer && (source.startsWith("./") || source.startsWith("../"))) {
|
|
4605
|
-
const raw2 =
|
|
4965
|
+
const raw2 = import_node_path12.default.resolve(import_node_path12.default.dirname(importer.split("?")[0] ?? importer), source);
|
|
4606
4966
|
try {
|
|
4607
4967
|
if (import_node_fs10.default.realpathSync(raw2) === import_node_fs10.default.realpathSync(resolved.id)) id = raw2;
|
|
4608
4968
|
} catch {
|
|
@@ -4616,19 +4976,19 @@ function swiftPlugin(options = {}) {
|
|
|
4616
4976
|
if (!import_node_fs10.default.existsSync(file)) throw new Error(`swift source ${file} no longer exists`);
|
|
4617
4977
|
const packagePath = options.packagePath ?? packageFor(file);
|
|
4618
4978
|
const project = projectFor(packagePath);
|
|
4619
|
-
const entry =
|
|
4979
|
+
const entry = import_node_path12.default.relative(packagePath, file).split(import_node_path12.default.sep).join(import_node_path12.default.posix.sep);
|
|
4620
4980
|
for (const source of [
|
|
4621
4981
|
...sourceFiles(packagePath),
|
|
4622
4982
|
...nativeSourceFiles(packagePath)
|
|
4623
4983
|
])
|
|
4624
4984
|
this.addWatchFile(source);
|
|
4625
|
-
this.addWatchFile(
|
|
4985
|
+
this.addWatchFile(import_node_path12.default.join(packagePath, "Package.swift"));
|
|
4626
4986
|
const moduleRoot = linkedModuleRoots(packagePath).find(
|
|
4627
|
-
(root) => import_node_fs10.default.existsSync(
|
|
4987
|
+
(root) => import_node_fs10.default.existsSync(import_node_path12.default.join(root, "toolchain.json"))
|
|
4628
4988
|
);
|
|
4629
4989
|
if (moduleRoot)
|
|
4630
4990
|
for (const relative of swiftModuleInputFiles(moduleRoot))
|
|
4631
|
-
this.addWatchFile(
|
|
4991
|
+
this.addWatchFile(import_node_path12.default.join(moduleRoot, relative));
|
|
4632
4992
|
let artifact;
|
|
4633
4993
|
try {
|
|
4634
4994
|
artifact = await artifactFor(project, entry);
|
|
@@ -4647,7 +5007,7 @@ function swiftPlugin(options = {}) {
|
|
|
4647
5007
|
...artifact.package.resources.watched,
|
|
4648
5008
|
...artifact.package.bundleFiles.watched
|
|
4649
5009
|
])
|
|
4650
|
-
this.addWatchFile(
|
|
5010
|
+
this.addWatchFile(import_node_path12.default.join(packagePath, ...watched.split(import_node_path12.default.posix.sep)));
|
|
4651
5011
|
const colors = artifact.package.resources.colors;
|
|
4652
5012
|
const symbols = artifact.package.resources.symbols;
|
|
4653
5013
|
const bundleFiles = artifact.package.bundleFiles.files;
|