peachsim 0.1.758 → 0.1.760
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/agent-identity.cjs +1 -1
- package/dist-lib/agent-sessions.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -1
- package/dist-lib/auth/shared-session.cjs +1 -1
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/beta.cjs +1 -1
- package/dist-lib/beta.mjs +1 -1
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/bridge-contract-input.cjs +1 -1
- package/dist-lib/bridge-contract-input.mjs +1 -1
- package/dist-lib/bridge-contract.cjs +1 -1
- package/dist-lib/bridge-contract.mjs +1 -1
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +1 -1
- package/dist-lib/cli-constants.cjs +1 -1
- package/dist-lib/cloud-contract.cjs +1 -1
- package/dist-lib/cloud-contract.mjs +1 -1
- package/dist-lib/cloud-test-args.cjs +1 -1
- package/dist-lib/cloud-test-args.mjs +1 -1
- package/dist-lib/cloud.cjs +1 -1
- package/dist-lib/cloud.mjs +1 -1
- package/dist-lib/config.cjs +1 -1
- package/dist-lib/detox/index.cjs +1 -1
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +1316 -863
- 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 +509 -336
- 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 +480 -307
- 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 +1637 -1173
- package/dist-lib/swift-compile.cjs +1 -1
- package/dist-lib/swift-compile.mjs +1 -1
- package/dist-lib/swift-package.cjs +1 -110
- package/dist-lib/swift-package.mjs +1 -109
- package/dist-lib/swift-submit.cjs +1 -1
- package/dist-lib/swift-submit.mjs +1 -1
- package/dist-lib/swift-toolchain.cjs +1 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +1013 -558
- package/dist-lib/vite.cjs +2 -4
- package/package.json +1 -1
- package/src/host/replacement-module-handler.ts +2 -1
- package/src/native-seam-manifest.ts +8 -0
- package/src/swift-host.ts +68 -66
- package/src/swift-package-manifest.ts +307 -0
- package/src/swift-package.ts +2 -135
- package/src/swift-packages.ts +341 -0
- package/src/xcode-json-project.ts +450 -0
- package/src/xcode-project.ts +112 -92
- package/src/swift-remote-packages.ts +0 -255
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.760 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
|
@@ -2156,35 +2156,35 @@ function identifierStart(character) {
|
|
|
2156
2156
|
function identifierPart(character) {
|
|
2157
2157
|
return character != null && /[A-Za-z0-9_$]/.test(character);
|
|
2158
2158
|
}
|
|
2159
|
-
function skipLineComment(
|
|
2159
|
+
function skipLineComment(text2, start, end) {
|
|
2160
2160
|
let cursor = start + 2;
|
|
2161
|
-
while (cursor < end &&
|
|
2161
|
+
while (cursor < end && text2[cursor] !== "\n" && text2[cursor] !== "\r") cursor++;
|
|
2162
2162
|
return cursor;
|
|
2163
2163
|
}
|
|
2164
|
-
function skipBlockComment(
|
|
2165
|
-
const close =
|
|
2164
|
+
function skipBlockComment(text2, start, end) {
|
|
2165
|
+
const close = text2.indexOf("*/", start + 2);
|
|
2166
2166
|
return close === -1 || close >= end ? end : close + 2;
|
|
2167
2167
|
}
|
|
2168
|
-
function skipTrivia(
|
|
2168
|
+
function skipTrivia(text2, start, end) {
|
|
2169
2169
|
let cursor = start;
|
|
2170
2170
|
for (; ; ) {
|
|
2171
|
-
while (cursor < end && /\s/.test(
|
|
2172
|
-
if (
|
|
2173
|
-
cursor = skipLineComment(
|
|
2171
|
+
while (cursor < end && /\s/.test(text2[cursor] ?? "")) cursor++;
|
|
2172
|
+
if (text2[cursor] === "/" && text2[cursor + 1] === "/") {
|
|
2173
|
+
cursor = skipLineComment(text2, cursor, end);
|
|
2174
2174
|
continue;
|
|
2175
2175
|
}
|
|
2176
|
-
if (
|
|
2177
|
-
cursor = skipBlockComment(
|
|
2176
|
+
if (text2[cursor] === "/" && text2[cursor + 1] === "*") {
|
|
2177
|
+
cursor = skipBlockComment(text2, cursor, end);
|
|
2178
2178
|
continue;
|
|
2179
2179
|
}
|
|
2180
2180
|
return cursor;
|
|
2181
2181
|
}
|
|
2182
2182
|
}
|
|
2183
|
-
function quotedEnd(
|
|
2184
|
-
const quote =
|
|
2183
|
+
function quotedEnd(text2, start, end) {
|
|
2184
|
+
const quote = text2[start];
|
|
2185
2185
|
let cursor = start + 1;
|
|
2186
2186
|
while (cursor < end) {
|
|
2187
|
-
const character =
|
|
2187
|
+
const character = text2[cursor];
|
|
2188
2188
|
if (character === "\\") {
|
|
2189
2189
|
cursor += 2;
|
|
2190
2190
|
continue;
|
|
@@ -2243,38 +2243,38 @@ function decodeSingleQuoted(contents) {
|
|
|
2243
2243
|
}
|
|
2244
2244
|
return value;
|
|
2245
2245
|
}
|
|
2246
|
-
function readQuoted(
|
|
2247
|
-
const quote =
|
|
2246
|
+
function readQuoted(text2, start, end) {
|
|
2247
|
+
const quote = text2[start];
|
|
2248
2248
|
if (quote !== '"' && quote !== "'") return null;
|
|
2249
|
-
const after = quotedEnd(
|
|
2250
|
-
if (after > end ||
|
|
2251
|
-
const contents =
|
|
2249
|
+
const after = quotedEnd(text2, start, end);
|
|
2250
|
+
if (after > end || text2[after - 1] !== quote) return null;
|
|
2251
|
+
const contents = text2.slice(start + 1, after - 1);
|
|
2252
2252
|
if (quote === "'") {
|
|
2253
2253
|
const value = decodeSingleQuoted(contents);
|
|
2254
2254
|
return value == null ? null : { value, end: after };
|
|
2255
2255
|
}
|
|
2256
2256
|
try {
|
|
2257
|
-
const value = JSON.parse(
|
|
2257
|
+
const value = JSON.parse(text2.slice(start, after));
|
|
2258
2258
|
return typeof value === "string" ? { value, end: after } : null;
|
|
2259
2259
|
} catch {
|
|
2260
2260
|
return null;
|
|
2261
2261
|
}
|
|
2262
2262
|
}
|
|
2263
|
-
function skipTemplate(
|
|
2263
|
+
function skipTemplate(text2, start, end) {
|
|
2264
2264
|
let cursor = start + 1;
|
|
2265
2265
|
while (cursor < end) {
|
|
2266
|
-
const character =
|
|
2266
|
+
const character = text2[cursor];
|
|
2267
2267
|
if (character === "\\") cursor += 2;
|
|
2268
2268
|
else if (character === "`") return cursor + 1;
|
|
2269
2269
|
else cursor++;
|
|
2270
2270
|
}
|
|
2271
2271
|
return end;
|
|
2272
2272
|
}
|
|
2273
|
-
function skipRegex(
|
|
2273
|
+
function skipRegex(text2, start, end) {
|
|
2274
2274
|
let cursor = start + 1;
|
|
2275
2275
|
let inClass = false;
|
|
2276
2276
|
while (cursor < end) {
|
|
2277
|
-
const character =
|
|
2277
|
+
const character = text2[cursor];
|
|
2278
2278
|
if (character === "\\") cursor += 2;
|
|
2279
2279
|
else if (character === "[") {
|
|
2280
2280
|
inClass = true;
|
|
@@ -2284,7 +2284,7 @@ function skipRegex(text, start, end) {
|
|
|
2284
2284
|
cursor++;
|
|
2285
2285
|
} else if (character === "/" && !inClass) {
|
|
2286
2286
|
cursor++;
|
|
2287
|
-
while (/[A-Za-z]/.test(
|
|
2287
|
+
while (/[A-Za-z]/.test(text2[cursor] ?? "")) cursor++;
|
|
2288
2288
|
return cursor;
|
|
2289
2289
|
} else if (character === "\n" || character === "\r") {
|
|
2290
2290
|
return cursor;
|
|
@@ -2292,43 +2292,43 @@ function skipRegex(text, start, end) {
|
|
|
2292
2292
|
}
|
|
2293
2293
|
return end;
|
|
2294
2294
|
}
|
|
2295
|
-
function readStringArray(
|
|
2296
|
-
if (
|
|
2295
|
+
function readStringArray(text2, start, end) {
|
|
2296
|
+
if (text2[start] !== "[") return null;
|
|
2297
2297
|
const values = [];
|
|
2298
2298
|
let cursor = start + 1;
|
|
2299
2299
|
for (; ; ) {
|
|
2300
|
-
cursor = skipTrivia(
|
|
2301
|
-
if (
|
|
2302
|
-
const parsed = readQuoted(
|
|
2300
|
+
cursor = skipTrivia(text2, cursor, end);
|
|
2301
|
+
if (text2[cursor] === "]") return { values, end: cursor + 1 };
|
|
2302
|
+
const parsed = readQuoted(text2, cursor, end);
|
|
2303
2303
|
if (!parsed) return null;
|
|
2304
2304
|
values.push(parsed.value);
|
|
2305
|
-
cursor = skipTrivia(
|
|
2306
|
-
if (
|
|
2307
|
-
if (
|
|
2305
|
+
cursor = skipTrivia(text2, parsed.end, end);
|
|
2306
|
+
if (text2[cursor] === "]") return { values, end: cursor + 1 };
|
|
2307
|
+
if (text2[cursor] !== ",") return null;
|
|
2308
2308
|
cursor++;
|
|
2309
2309
|
}
|
|
2310
2310
|
}
|
|
2311
|
-
function readNumberArray(
|
|
2312
|
-
if (
|
|
2311
|
+
function readNumberArray(text2, start, end) {
|
|
2312
|
+
if (text2[start] !== "[") return null;
|
|
2313
2313
|
const values = [];
|
|
2314
2314
|
let cursor = start + 1;
|
|
2315
2315
|
for (; ; ) {
|
|
2316
|
-
cursor = skipTrivia(
|
|
2317
|
-
if (
|
|
2316
|
+
cursor = skipTrivia(text2, cursor, end);
|
|
2317
|
+
if (text2[cursor] === "]") return { values, end: cursor + 1 };
|
|
2318
2318
|
const match = /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?/i.exec(
|
|
2319
|
-
|
|
2319
|
+
text2.slice(cursor, end)
|
|
2320
2320
|
);
|
|
2321
2321
|
if (!match) return null;
|
|
2322
2322
|
const value = Number(match[0]);
|
|
2323
2323
|
if (!Number.isFinite(value)) return null;
|
|
2324
2324
|
values.push(value);
|
|
2325
|
-
cursor = skipTrivia(
|
|
2326
|
-
if (
|
|
2327
|
-
if (
|
|
2325
|
+
cursor = skipTrivia(text2, cursor + match[0].length, end);
|
|
2326
|
+
if (text2[cursor] === "]") return { values, end: cursor + 1 };
|
|
2327
|
+
if (text2[cursor] !== ",") return null;
|
|
2328
2328
|
cursor++;
|
|
2329
2329
|
}
|
|
2330
2330
|
}
|
|
2331
|
-
function readDescriptorObject(
|
|
2331
|
+
function readDescriptorObject(text2, start, end, pairSpans) {
|
|
2332
2332
|
const strings = {};
|
|
2333
2333
|
let scales;
|
|
2334
2334
|
let fileUris;
|
|
@@ -2339,27 +2339,27 @@ function readDescriptorObject(text, start, end, pairSpans) {
|
|
|
2339
2339
|
let parenDepth = 0;
|
|
2340
2340
|
let canStartRegex = true;
|
|
2341
2341
|
while (cursor < end - 1) {
|
|
2342
|
-
cursor = skipTrivia(
|
|
2343
|
-
const character =
|
|
2342
|
+
cursor = skipTrivia(text2, cursor, end - 1);
|
|
2343
|
+
const character = text2[cursor];
|
|
2344
2344
|
if (character == null) break;
|
|
2345
2345
|
if (braceDepth === 1 && bracketDepth === 0 && parenDepth === 0) {
|
|
2346
2346
|
let key = null;
|
|
2347
2347
|
const pairStart = cursor;
|
|
2348
2348
|
let afterKey = cursor;
|
|
2349
|
-
const quoted = readQuoted(
|
|
2349
|
+
const quoted = readQuoted(text2, cursor, end - 1);
|
|
2350
2350
|
if (quoted) {
|
|
2351
2351
|
key = quoted.value;
|
|
2352
2352
|
afterKey = quoted.end;
|
|
2353
2353
|
} else if (identifierStart(character)) {
|
|
2354
2354
|
afterKey++;
|
|
2355
|
-
while (identifierPart(
|
|
2356
|
-
key =
|
|
2355
|
+
while (identifierPart(text2[afterKey])) afterKey++;
|
|
2356
|
+
key = text2.slice(cursor, afterKey);
|
|
2357
2357
|
}
|
|
2358
|
-
const colon = key == null ? afterKey : skipTrivia(
|
|
2359
|
-
if (key != null &&
|
|
2360
|
-
const valueStart = skipTrivia(
|
|
2358
|
+
const colon = key == null ? afterKey : skipTrivia(text2, afterKey, end - 1);
|
|
2359
|
+
if (key != null && text2[colon] === ":") {
|
|
2360
|
+
const valueStart = skipTrivia(text2, colon + 1, end - 1);
|
|
2361
2361
|
if (key === "httpServerLocation" || key === "name" || key === "type" || key === "hash") {
|
|
2362
|
-
const value = readQuoted(
|
|
2362
|
+
const value = readQuoted(text2, valueStart, end - 1);
|
|
2363
2363
|
if (!value) return null;
|
|
2364
2364
|
strings[key] = value.value;
|
|
2365
2365
|
cursor = value.end;
|
|
@@ -2367,7 +2367,7 @@ function readDescriptorObject(text, start, end, pairSpans) {
|
|
|
2367
2367
|
continue;
|
|
2368
2368
|
}
|
|
2369
2369
|
if (key === "scales") {
|
|
2370
|
-
const value = readNumberArray(
|
|
2370
|
+
const value = readNumberArray(text2, valueStart, end - 1);
|
|
2371
2371
|
if (!value) return null;
|
|
2372
2372
|
scales = value.values;
|
|
2373
2373
|
if (pairSpans) pairSpans.scales = { start: pairStart, end: value.end };
|
|
@@ -2376,7 +2376,7 @@ function readDescriptorObject(text, start, end, pairSpans) {
|
|
|
2376
2376
|
continue;
|
|
2377
2377
|
}
|
|
2378
2378
|
if (key === "fileUris" || key === "fileHashes") {
|
|
2379
|
-
const value = readStringArray(
|
|
2379
|
+
const value = readStringArray(text2, valueStart, end - 1);
|
|
2380
2380
|
if (!value) return null;
|
|
2381
2381
|
if (key === "fileUris") fileUris = value.values;
|
|
2382
2382
|
else fileHashes = value.values;
|
|
@@ -2388,24 +2388,24 @@ function readDescriptorObject(text, start, end, pairSpans) {
|
|
|
2388
2388
|
}
|
|
2389
2389
|
}
|
|
2390
2390
|
if (character === '"' || character === "'") {
|
|
2391
|
-
cursor = quotedEnd(
|
|
2391
|
+
cursor = quotedEnd(text2, cursor, end - 1);
|
|
2392
2392
|
canStartRegex = false;
|
|
2393
2393
|
continue;
|
|
2394
2394
|
}
|
|
2395
2395
|
if (character === "`") {
|
|
2396
|
-
cursor = skipTemplate(
|
|
2396
|
+
cursor = skipTemplate(text2, cursor, end - 1);
|
|
2397
2397
|
canStartRegex = false;
|
|
2398
2398
|
continue;
|
|
2399
2399
|
}
|
|
2400
2400
|
if (character === "/" && canStartRegex) {
|
|
2401
|
-
cursor = skipRegex(
|
|
2401
|
+
cursor = skipRegex(text2, cursor, end - 1);
|
|
2402
2402
|
canStartRegex = false;
|
|
2403
2403
|
continue;
|
|
2404
2404
|
}
|
|
2405
2405
|
if (identifierStart(character)) {
|
|
2406
2406
|
const tokenStart = cursor++;
|
|
2407
|
-
while (identifierPart(
|
|
2408
|
-
canStartRegex = EXPRESSION_KEYWORDS.has(
|
|
2407
|
+
while (identifierPart(text2[cursor])) cursor++;
|
|
2408
|
+
canStartRegex = EXPRESSION_KEYWORDS.has(text2.slice(tokenStart, cursor));
|
|
2409
2409
|
continue;
|
|
2410
2410
|
}
|
|
2411
2411
|
if (character === "{") braceDepth++;
|
|
@@ -2689,8 +2689,8 @@ function metroIosAssetDestRelatives(httpServerLocation, filename) {
|
|
|
2689
2689
|
}
|
|
2690
2690
|
const out = [];
|
|
2691
2691
|
for (const dir of dirs) {
|
|
2692
|
-
const
|
|
2693
|
-
if (!out.includes(
|
|
2692
|
+
const path22 = `${dir}/${filename}`;
|
|
2693
|
+
if (!out.includes(path22)) out.push(path22);
|
|
2694
2694
|
}
|
|
2695
2695
|
if (!out.includes(filename)) out.push(filename);
|
|
2696
2696
|
return out;
|
|
@@ -2820,10 +2820,10 @@ async function embedMetroAssetFiles(bundle, read) {
|
|
|
2820
2820
|
}
|
|
2821
2821
|
};
|
|
2822
2822
|
}
|
|
2823
|
-
function countNewlines(
|
|
2823
|
+
function countNewlines(text2) {
|
|
2824
2824
|
let total = 0;
|
|
2825
|
-
for (let index = 0; index <
|
|
2826
|
-
if (
|
|
2825
|
+
for (let index = 0; index < text2.length; index++) {
|
|
2826
|
+
if (text2.charCodeAt(index) === 10) total++;
|
|
2827
2827
|
}
|
|
2828
2828
|
return total;
|
|
2829
2829
|
}
|
|
@@ -2999,10 +2999,10 @@ function encodedAssetBytes(bundle) {
|
|
|
2999
2999
|
}
|
|
3000
3000
|
return total;
|
|
3001
3001
|
}
|
|
3002
|
-
function countLines(
|
|
3002
|
+
function countLines(text2) {
|
|
3003
3003
|
let lines = 0;
|
|
3004
|
-
for (let index = 0; index <
|
|
3005
|
-
if (
|
|
3004
|
+
for (let index = 0; index < text2.length; index++) {
|
|
3005
|
+
if (text2.charCodeAt(index) === 10) lines++;
|
|
3006
3006
|
}
|
|
3007
3007
|
return lines;
|
|
3008
3008
|
}
|
|
@@ -3051,14 +3051,14 @@ async function buildRnxCloudArtifact(bundle, options = {}) {
|
|
|
3051
3051
|
const pieces = await Promise.all([
|
|
3052
3052
|
minify(layout.prelude, 0, MINIFY_OPTIONS, development),
|
|
3053
3053
|
...layout.statements.map((statement) => {
|
|
3054
|
-
const
|
|
3054
|
+
const text2 = identity.source.slice(statement.start, statement.end);
|
|
3055
3055
|
return statement.kind === "define" ? minifyDefine(
|
|
3056
|
-
|
|
3056
|
+
text2,
|
|
3057
3057
|
statement.moduleId,
|
|
3058
3058
|
statement.lineIndex,
|
|
3059
3059
|
MINIFY_OPTIONS,
|
|
3060
3060
|
development
|
|
3061
|
-
) : minify(
|
|
3061
|
+
) : minify(text2, statement.lineIndex, MINIFY_OPTIONS, development);
|
|
3062
3062
|
})
|
|
3063
3063
|
]);
|
|
3064
3064
|
const body = pieces.map((piece) => piece.code).join("\n");
|
|
@@ -3644,13 +3644,13 @@ function readFactoryStringLiterals(factory) {
|
|
|
3644
3644
|
return literals;
|
|
3645
3645
|
}
|
|
3646
3646
|
function normalizeFingerprintLiteral(literal) {
|
|
3647
|
-
const
|
|
3647
|
+
const path22 = literal.replaceAll("\\\\", "/").replaceAll("\\/", "/");
|
|
3648
3648
|
const nodeModulesMarker = "/node_modules/";
|
|
3649
|
-
const nodeModulesIndex =
|
|
3649
|
+
const nodeModulesIndex = path22.lastIndexOf(nodeModulesMarker);
|
|
3650
3650
|
if (nodeModulesIndex >= 0) {
|
|
3651
|
-
return `node_modules/${
|
|
3651
|
+
return `node_modules/${path22.slice(nodeModulesIndex + nodeModulesMarker.length)}`;
|
|
3652
3652
|
}
|
|
3653
|
-
if ((
|
|
3653
|
+
if ((path22.startsWith("/") || /^[A-Za-z]:\//.test(path22) || path22.startsWith("file:/")) && /\.[cm]?[jt]sx?(?::\d+(?::\d+)?)?$/.test(path22)) {
|
|
3654
3654
|
return null;
|
|
3655
3655
|
}
|
|
3656
3656
|
return literal;
|
|
@@ -3888,10 +3888,10 @@ function templateAssignment(template, embeddings) {
|
|
|
3888
3888
|
if (existingNode !== void 0 && existingNode !== nodeIndex) return null;
|
|
3889
3889
|
nodesByModuleId.set(moduleId, nodeIndex);
|
|
3890
3890
|
const node = template.nodes[nodeIndex];
|
|
3891
|
-
const
|
|
3891
|
+
const path22 = node.landmarkPath ?? `node_modules/${template.packageName}/__rnx_inferred__/${moduleId}.js`;
|
|
3892
3892
|
const existingPath = pathsByModuleId.get(moduleId);
|
|
3893
|
-
if (existingPath !== void 0 && existingPath !==
|
|
3894
|
-
pathsByModuleId.set(moduleId,
|
|
3893
|
+
if (existingPath !== void 0 && existingPath !== path22) return null;
|
|
3894
|
+
pathsByModuleId.set(moduleId, path22);
|
|
3895
3895
|
}
|
|
3896
3896
|
}
|
|
3897
3897
|
return {
|
|
@@ -4053,14 +4053,14 @@ async function inferMetroModuleIdentity(args) {
|
|
|
4053
4053
|
const packageClaims = claimsByPackage.values().next().value;
|
|
4054
4054
|
if (!packageClaims) continue;
|
|
4055
4055
|
const exactClaims = packageClaims.filter((assignment2) => {
|
|
4056
|
-
const
|
|
4057
|
-
return
|
|
4056
|
+
const path22 = assignment2.pathsByModuleId.get(moduleId);
|
|
4057
|
+
return path22 !== void 0 && !path22.includes("/__rnx_inferred__/");
|
|
4058
4058
|
});
|
|
4059
4059
|
const preferredClaims = exactClaims.length > 0 ? exactClaims : packageClaims;
|
|
4060
4060
|
const routes = new Set(
|
|
4061
4061
|
preferredClaims.flatMap((assignment2) => {
|
|
4062
|
-
const
|
|
4063
|
-
return
|
|
4062
|
+
const path22 = assignment2.pathsByModuleId.get(moduleId);
|
|
4063
|
+
return path22 ? [metroFingerprintModuleClaimRoute(assignment2.packageName, path22)] : [];
|
|
4064
4064
|
})
|
|
4065
4065
|
);
|
|
4066
4066
|
if (routes.size !== 1) continue;
|
|
@@ -4260,8 +4260,8 @@ function detectFramework(deps) {
|
|
|
4260
4260
|
return "unknown";
|
|
4261
4261
|
}
|
|
4262
4262
|
function detectProject(dir) {
|
|
4263
|
-
const pkgPath = (0,
|
|
4264
|
-
if (!(0,
|
|
4263
|
+
const pkgPath = (0, import_node_path26.join)(dir, "package.json");
|
|
4264
|
+
if (!(0, import_node_fs25.existsSync)(pkgPath)) return null;
|
|
4265
4265
|
const pkg = readProjectManifest(dir);
|
|
4266
4266
|
if (!pkg) return null;
|
|
4267
4267
|
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
@@ -4273,25 +4273,25 @@ function detectProject(dir) {
|
|
|
4273
4273
|
if (framework === "unknown") return null;
|
|
4274
4274
|
return {
|
|
4275
4275
|
dir,
|
|
4276
|
-
name: pkg.name || (0,
|
|
4276
|
+
name: pkg.name || (0, import_node_path26.basename)(dir),
|
|
4277
4277
|
framework,
|
|
4278
4278
|
// a config file is a config file whatever module system it declares. real
|
|
4279
4279
|
// apps write .cjs as often as .js, and missing one reads as "this project
|
|
4280
4280
|
// has no bundler config" and sends the user to create a second one.
|
|
4281
4281
|
hasViteConfig: CONFIG_EXTENSIONS.some(
|
|
4282
|
-
(ext) => (0,
|
|
4282
|
+
(ext) => (0, import_node_fs25.existsSync)((0, import_node_path26.join)(dir, `vite.config.${ext}`))
|
|
4283
4283
|
),
|
|
4284
4284
|
hasMetroConfig: CONFIG_EXTENSIONS.some(
|
|
4285
|
-
(ext) => (0,
|
|
4285
|
+
(ext) => (0, import_node_fs25.existsSync)((0, import_node_path26.join)(dir, `metro.config.${ext}`))
|
|
4286
4286
|
),
|
|
4287
4287
|
devCommand: typeof devCommand === "string" ? devCommand : null
|
|
4288
4288
|
};
|
|
4289
4289
|
}
|
|
4290
|
-
function readProjectMetadata(
|
|
4290
|
+
function readProjectMetadata(path22) {
|
|
4291
4291
|
try {
|
|
4292
|
-
const info = (0,
|
|
4292
|
+
const info = (0, import_node_fs25.lstatSync)(path22);
|
|
4293
4293
|
if (!info.isFile() || info.size > 4 * 1024 * 1024) return null;
|
|
4294
|
-
return (0,
|
|
4294
|
+
return (0, import_node_fs25.readFileSync)(path22, "utf8");
|
|
4295
4295
|
} catch {
|
|
4296
4296
|
return null;
|
|
4297
4297
|
}
|
|
@@ -4300,20 +4300,20 @@ function metadataValue(value, key) {
|
|
|
4300
4300
|
if (!value || typeof value !== "object") return void 0;
|
|
4301
4301
|
return Object.getOwnPropertyDescriptor(value, key)?.value;
|
|
4302
4302
|
}
|
|
4303
|
-
function readProjectJson(
|
|
4304
|
-
const
|
|
4305
|
-
if (
|
|
4303
|
+
function readProjectJson(path22) {
|
|
4304
|
+
const text2 = readProjectMetadata(path22);
|
|
4305
|
+
if (text2 === null) return null;
|
|
4306
4306
|
try {
|
|
4307
|
-
const value = JSON.parse(
|
|
4307
|
+
const value = JSON.parse(text2);
|
|
4308
4308
|
return value;
|
|
4309
4309
|
} catch {
|
|
4310
4310
|
return null;
|
|
4311
4311
|
}
|
|
4312
4312
|
}
|
|
4313
4313
|
function readProjectManifest(dir) {
|
|
4314
|
-
const parsed = readProjectJson((0,
|
|
4314
|
+
const parsed = readProjectJson((0, import_node_path26.join)(dir, "package.json"));
|
|
4315
4315
|
if (!parsed || typeof parsed !== "object") return null;
|
|
4316
|
-
const
|
|
4316
|
+
const record2 = (value) => {
|
|
4317
4317
|
if (!value || typeof value !== "object") return {};
|
|
4318
4318
|
return Object.fromEntries(
|
|
4319
4319
|
Object.entries(value).filter(
|
|
@@ -4324,27 +4324,27 @@ function readProjectManifest(dir) {
|
|
|
4324
4324
|
const name2 = metadataValue(parsed, "name");
|
|
4325
4325
|
return {
|
|
4326
4326
|
...typeof name2 === "string" ? { name: name2 } : {},
|
|
4327
|
-
dependencies:
|
|
4328
|
-
devDependencies:
|
|
4327
|
+
dependencies: record2(metadataValue(parsed, "dependencies")),
|
|
4328
|
+
devDependencies: record2(metadataValue(parsed, "devDependencies"))
|
|
4329
4329
|
};
|
|
4330
4330
|
}
|
|
4331
|
-
var
|
|
4331
|
+
var import_node_fs25, import_node_path26, import_json52, import_yaml, CONFIG_EXTENSIONS;
|
|
4332
4332
|
var init_detect = __esm({
|
|
4333
4333
|
"cli/commands/detect.ts"() {
|
|
4334
4334
|
"use strict";
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
|
|
4335
|
+
import_node_fs25 = require("node:fs");
|
|
4336
|
+
import_node_path26 = require("node:path");
|
|
4337
|
+
import_json52 = __toESM(require("json5"), 1);
|
|
4338
4338
|
import_yaml = require("yaml");
|
|
4339
4339
|
CONFIG_EXTENSIONS = ["ts", "js", "cjs", "mjs", "mts", "cts"];
|
|
4340
4340
|
}
|
|
4341
4341
|
});
|
|
4342
4342
|
|
|
4343
4343
|
// cli/cloud-client.ts
|
|
4344
|
-
function failureSentence(
|
|
4344
|
+
function failureSentence(text2) {
|
|
4345
4345
|
let parsed;
|
|
4346
4346
|
try {
|
|
4347
|
-
parsed = JSON.parse(
|
|
4347
|
+
parsed = JSON.parse(text2);
|
|
4348
4348
|
} catch {
|
|
4349
4349
|
return null;
|
|
4350
4350
|
}
|
|
@@ -4357,11 +4357,11 @@ function failureSentence(text) {
|
|
|
4357
4357
|
if (typeof parsed.error === "string") return parsed.error;
|
|
4358
4358
|
return null;
|
|
4359
4359
|
}
|
|
4360
|
-
function responseError(status,
|
|
4361
|
-
const parsed =
|
|
4360
|
+
function responseError(status, text2) {
|
|
4361
|
+
const parsed = text2 ? failureSentence(text2) : null;
|
|
4362
4362
|
const sentence = parsed && ACCOUNT_CHOICE_REFUSALS.has(parsed) ? CHOOSE_ACCOUNT_HINT : parsed;
|
|
4363
4363
|
return new Error(
|
|
4364
|
-
`remote simulator request failed (${status})${sentence ? `: ${sentence}` :
|
|
4364
|
+
`remote simulator request failed (${status})${sentence ? `: ${sentence}` : text2.trim() ? `: ${text2.trim()}` : ""}`
|
|
4365
4365
|
);
|
|
4366
4366
|
}
|
|
4367
4367
|
function resolveCloudOrigin(value) {
|
|
@@ -4370,21 +4370,21 @@ function resolveCloudOrigin(value) {
|
|
|
4370
4370
|
return normalizeCloudOrigin(source);
|
|
4371
4371
|
}
|
|
4372
4372
|
function readImmutableBundleSource(bundlePath) {
|
|
4373
|
-
const filepath = (0,
|
|
4374
|
-
if ((0,
|
|
4373
|
+
const filepath = (0, import_node_path27.resolve)(bundlePath);
|
|
4374
|
+
if ((0, import_node_path27.extname)(filepath) !== ".js") {
|
|
4375
4375
|
throw new Error(`${REMOTE_COMMAND} requires one local Metro .js bundle`);
|
|
4376
4376
|
}
|
|
4377
|
-
const descriptor = (0,
|
|
4377
|
+
const descriptor = (0, import_node_fs26.openSync)(filepath, "r");
|
|
4378
4378
|
try {
|
|
4379
|
-
const before = (0,
|
|
4379
|
+
const before = (0, import_node_fs26.fstatSync)(descriptor, { bigint: true });
|
|
4380
4380
|
if (!before.isFile()) {
|
|
4381
4381
|
throw new Error(`${REMOTE_COMMAND} bundle must be a regular local file`);
|
|
4382
4382
|
}
|
|
4383
4383
|
if (before.size <= 0n) {
|
|
4384
4384
|
throw new Error(`${REMOTE_COMMAND} bundle is empty`);
|
|
4385
4385
|
}
|
|
4386
|
-
const bytes = (0,
|
|
4387
|
-
const after = (0,
|
|
4386
|
+
const bytes = (0, import_node_fs26.readFileSync)(descriptor);
|
|
4387
|
+
const after = (0, import_node_fs26.fstatSync)(descriptor, { bigint: true });
|
|
4388
4388
|
if (before.dev !== after.dev || before.ino !== after.ino || before.size !== after.size || before.mtimeNs !== after.mtimeNs || bytes.length !== Number(before.size)) {
|
|
4389
4389
|
throw new Error(`${REMOTE_COMMAND} bundle changed while it was being read`);
|
|
4390
4390
|
}
|
|
@@ -4399,7 +4399,7 @@ function readImmutableBundleSource(bundlePath) {
|
|
|
4399
4399
|
}
|
|
4400
4400
|
return source;
|
|
4401
4401
|
} finally {
|
|
4402
|
-
(0,
|
|
4402
|
+
(0, import_node_fs26.closeSync)(descriptor);
|
|
4403
4403
|
}
|
|
4404
4404
|
}
|
|
4405
4405
|
async function fetchBundleSource(bundleUrl) {
|
|
@@ -4416,14 +4416,14 @@ async function fetchBundleSource(bundleUrl) {
|
|
|
4416
4416
|
`${REMOTE_COMMAND} could not fetch bundle from ${bundleUrl}: HTTP ${response.status}${response.statusText ? ` ${response.statusText}` : ""}`
|
|
4417
4417
|
);
|
|
4418
4418
|
}
|
|
4419
|
-
const
|
|
4420
|
-
if (
|
|
4419
|
+
const text2 = await response.text();
|
|
4420
|
+
if (text2.length === 0) {
|
|
4421
4421
|
throw new Error(`${REMOTE_COMMAND} bundle is empty`);
|
|
4422
4422
|
}
|
|
4423
|
-
if (
|
|
4423
|
+
if (text2.includes("\0") || !text2.includes("__d(") || !text2.includes("__r(")) {
|
|
4424
4424
|
throw new Error(`${REMOTE_COMMAND} requires a Metro JavaScript bundle`);
|
|
4425
4425
|
}
|
|
4426
|
-
return
|
|
4426
|
+
return text2;
|
|
4427
4427
|
}
|
|
4428
4428
|
function isLoopbackBundleUrl(bundleInput) {
|
|
4429
4429
|
if (!bundleInput.startsWith("http://")) return false;
|
|
@@ -4446,15 +4446,15 @@ async function loadBundleSource(bundleInput) {
|
|
|
4446
4446
|
return readImmutableBundleSource(bundleInput);
|
|
4447
4447
|
}
|
|
4448
4448
|
function listMetroAssetDest(assetsPath) {
|
|
4449
|
-
const directory = (0,
|
|
4450
|
-
if (!(0,
|
|
4451
|
-
const skipNested = (0,
|
|
4449
|
+
const directory = (0, import_node_path27.resolve)(assetsPath);
|
|
4450
|
+
if (!(0, import_node_fs26.existsSync)(directory)) return { directory, files: [], truncated: false };
|
|
4451
|
+
const skipNested = (0, import_node_fs26.existsSync)((0, import_node_path27.join)(directory, "package.json"));
|
|
4452
4452
|
const files = [];
|
|
4453
4453
|
let truncated = false;
|
|
4454
4454
|
const walk2 = (dir, prefix) => {
|
|
4455
4455
|
let entries;
|
|
4456
4456
|
try {
|
|
4457
|
-
entries = (0,
|
|
4457
|
+
entries = (0, import_node_fs26.readdirSync)(dir, { withFileTypes: true });
|
|
4458
4458
|
} catch {
|
|
4459
4459
|
return;
|
|
4460
4460
|
}
|
|
@@ -4466,7 +4466,7 @@ function listMetroAssetDest(assetsPath) {
|
|
|
4466
4466
|
if (entry.isDirectory()) {
|
|
4467
4467
|
if (entry.name === ".git") continue;
|
|
4468
4468
|
if (skipNested && PROJECT_ONLY_DIRECTORIES.has(entry.name)) continue;
|
|
4469
|
-
walk2((0,
|
|
4469
|
+
walk2((0, import_node_path27.join)(dir, entry.name), prefix ? `${prefix}/${entry.name}` : entry.name);
|
|
4470
4470
|
} else if (entry.isFile()) {
|
|
4471
4471
|
files.push(prefix ? `${prefix}/${entry.name}` : entry.name);
|
|
4472
4472
|
}
|
|
@@ -4476,7 +4476,7 @@ function listMetroAssetDest(assetsPath) {
|
|
|
4476
4476
|
return { directory, files, truncated };
|
|
4477
4477
|
}
|
|
4478
4478
|
function metroDescriptorHash(scaleBytes) {
|
|
4479
|
-
const hasher = (0,
|
|
4479
|
+
const hasher = (0, import_node_crypto12.createHash)("md5");
|
|
4480
4480
|
for (const bytes of scaleBytes) hasher.update(bytes);
|
|
4481
4481
|
return hasher.digest("hex");
|
|
4482
4482
|
}
|
|
@@ -4501,11 +4501,11 @@ function distinctByContent(directory, options) {
|
|
|
4501
4501
|
for (const relative2 of options) {
|
|
4502
4502
|
let bytes;
|
|
4503
4503
|
try {
|
|
4504
|
-
bytes = (0,
|
|
4504
|
+
bytes = (0, import_node_fs26.readFileSync)((0, import_node_path27.join)(directory, relative2));
|
|
4505
4505
|
} catch {
|
|
4506
4506
|
continue;
|
|
4507
4507
|
}
|
|
4508
|
-
const digest = (0,
|
|
4508
|
+
const digest = (0, import_node_crypto12.createHash)("md5").update(bytes).digest("hex");
|
|
4509
4509
|
if (!byContent.has(digest)) byContent.set(digest, relative2);
|
|
4510
4510
|
}
|
|
4511
4511
|
return [...byContent.values()];
|
|
@@ -4533,13 +4533,13 @@ function placeMetroDescriptor(listing, descriptor) {
|
|
|
4533
4533
|
let bytes;
|
|
4534
4534
|
try {
|
|
4535
4535
|
bytes = combination.map(
|
|
4536
|
-
(relative2) => (0,
|
|
4536
|
+
(relative2) => (0, import_node_fs26.readFileSync)((0, import_node_path27.join)(listing.directory, relative2))
|
|
4537
4537
|
);
|
|
4538
4538
|
} catch {
|
|
4539
4539
|
continue;
|
|
4540
4540
|
}
|
|
4541
4541
|
const identical = fileHashes ? bytes.every((file, index) => {
|
|
4542
|
-
const digest = (0,
|
|
4542
|
+
const digest = (0, import_node_crypto12.createHash)("md5").update(file).digest("hex");
|
|
4543
4543
|
return descriptor.scales.some(
|
|
4544
4544
|
(scale, declared) => scale === scales[index] && fileHashes[declared] === digest
|
|
4545
4545
|
);
|
|
@@ -4561,10 +4561,10 @@ function unverifiedContentKey(dest, fileDigests) {
|
|
|
4561
4561
|
return JSON.stringify(
|
|
4562
4562
|
dest.placements.map(
|
|
4563
4563
|
(placement) => placement.verified ? null : [...placement.files].map(([scale, relative2]) => {
|
|
4564
|
-
const file = (0,
|
|
4564
|
+
const file = (0, import_node_path27.join)(dest.directory, relative2);
|
|
4565
4565
|
let digest = fileDigests.get(file);
|
|
4566
4566
|
if (digest === void 0) {
|
|
4567
|
-
digest = (0,
|
|
4567
|
+
digest = (0, import_node_crypto12.createHash)("sha256").update((0, import_node_fs26.readFileSync)(file)).digest("hex");
|
|
4568
4568
|
fileDigests.set(file, digest);
|
|
4569
4569
|
}
|
|
4570
4570
|
return [scale, digest];
|
|
@@ -4573,22 +4573,22 @@ function unverifiedContentKey(dest, fileDigests) {
|
|
|
4573
4573
|
);
|
|
4574
4574
|
}
|
|
4575
4575
|
function searchMetroAssetDest(bundlePath, descriptors) {
|
|
4576
|
-
const bundleDirectory = (0,
|
|
4576
|
+
const bundleDirectory = (0, import_node_path27.dirname)((0, import_node_path27.resolve)(bundlePath));
|
|
4577
4577
|
const candidates = [
|
|
4578
|
-
(0,
|
|
4578
|
+
(0, import_node_path27.join)(bundleDirectory, "assets"),
|
|
4579
4579
|
bundleDirectory,
|
|
4580
|
-
(0,
|
|
4580
|
+
(0, import_node_path27.resolve)(bundleDirectory, "..", "assets")
|
|
4581
4581
|
];
|
|
4582
4582
|
const cwd = process.cwd();
|
|
4583
4583
|
let projectDirectory = null;
|
|
4584
4584
|
for (const start of [bundleDirectory, cwd]) {
|
|
4585
|
-
let directory = (0,
|
|
4585
|
+
let directory = (0, import_node_path27.resolve)(start);
|
|
4586
4586
|
while (true) {
|
|
4587
4587
|
if (detectProject(directory)?.hasMetroConfig) {
|
|
4588
4588
|
projectDirectory = directory;
|
|
4589
4589
|
break;
|
|
4590
4590
|
}
|
|
4591
|
-
const parent = (0,
|
|
4591
|
+
const parent = (0, import_node_path27.dirname)(directory);
|
|
4592
4592
|
if (parent === directory) break;
|
|
4593
4593
|
directory = parent;
|
|
4594
4594
|
}
|
|
@@ -4596,11 +4596,11 @@ function searchMetroAssetDest(bundlePath, descriptors) {
|
|
|
4596
4596
|
}
|
|
4597
4597
|
if (projectDirectory) {
|
|
4598
4598
|
candidates.push(
|
|
4599
|
-
(0,
|
|
4600
|
-
(0,
|
|
4601
|
-
(0,
|
|
4602
|
-
(0,
|
|
4603
|
-
(0,
|
|
4599
|
+
(0, import_node_path27.join)(projectDirectory, "assets"),
|
|
4600
|
+
(0, import_node_path27.join)(projectDirectory, "dist"),
|
|
4601
|
+
(0, import_node_path27.join)(projectDirectory, "dist", "assets"),
|
|
4602
|
+
(0, import_node_path27.join)(projectDirectory, "build"),
|
|
4603
|
+
(0, import_node_path27.join)(projectDirectory, "build", "assets")
|
|
4604
4604
|
);
|
|
4605
4605
|
}
|
|
4606
4606
|
const searched = [];
|
|
@@ -4608,7 +4608,7 @@ function searchMetroAssetDest(bundlePath, descriptors) {
|
|
|
4608
4608
|
const stale = [];
|
|
4609
4609
|
let truncated = false;
|
|
4610
4610
|
for (const candidate of candidates) {
|
|
4611
|
-
const directory = (0,
|
|
4611
|
+
const directory = (0, import_node_path27.resolve)(candidate);
|
|
4612
4612
|
if (searched.includes(directory)) continue;
|
|
4613
4613
|
searched.push(directory);
|
|
4614
4614
|
const listing = listMetroAssetDest(directory);
|
|
@@ -4717,7 +4717,7 @@ async function embedBundleAssets(bundlePath, command, assetPolicy) {
|
|
|
4717
4717
|
);
|
|
4718
4718
|
}
|
|
4719
4719
|
const relative2 = placement?.files.get(variant.scale);
|
|
4720
|
-
if (relative2 && dest) return (0,
|
|
4720
|
+
if (relative2 && dest) return (0, import_node_fs26.readFileSync)((0, import_node_path27.join)(dest.directory, relative2));
|
|
4721
4721
|
if (placement && placement.files.size > 0) return null;
|
|
4722
4722
|
if (placement && placement.ambiguous.length > 0 && dest) {
|
|
4723
4723
|
throw new Error(
|
|
@@ -4746,7 +4746,7 @@ async function embedBundleAssets(bundlePath, command, assetPolicy) {
|
|
|
4746
4746
|
);
|
|
4747
4747
|
const classic = metroIosAssetDestRelatives(variant.descriptor.httpServerLocation, filename)[0] ?? filename;
|
|
4748
4748
|
throw new Error(
|
|
4749
|
-
`${command} could not read ${(0,
|
|
4749
|
+
`${command} could not read ${(0, import_node_path27.join)(dest?.directory ?? ".", classic)} for ${variant.descriptor.name}.${variant.descriptor.type} at scale ${variant.scale}, and has no stand-in for a .${variant.descriptor.type} asset. Rebuild with \`react-native bundle --assets-dest\`.`
|
|
4750
4750
|
);
|
|
4751
4751
|
});
|
|
4752
4752
|
return {
|
|
@@ -4787,7 +4787,7 @@ async function produceArtifact(bundlePath, maxBytes, command, assetPolicy) {
|
|
|
4787
4787
|
}
|
|
4788
4788
|
return {
|
|
4789
4789
|
bytes,
|
|
4790
|
-
sha256: (0,
|
|
4790
|
+
sha256: (0, import_node_crypto12.createHash)("sha256").update(bytes).digest("hex"),
|
|
4791
4791
|
receipt: artifact.receipt,
|
|
4792
4792
|
assetsDirectory: prepared.dest?.directory ?? null,
|
|
4793
4793
|
warnings
|
|
@@ -4892,13 +4892,13 @@ async function createCloudBox(options) {
|
|
|
4892
4892
|
warnings: artifact.warnings
|
|
4893
4893
|
};
|
|
4894
4894
|
}
|
|
4895
|
-
var
|
|
4895
|
+
var import_node_crypto12, import_node_fs26, import_node_path27, DEFAULT_RNX_CLOUD_ORIGIN, MAX_RNX_CLOUD_BUNDLE_BYTES, REMOTE_COMMAND, MAX_ASSET_DEST_FILES, ACCOUNT_CHOICE_REFUSALS, PROJECT_ONLY_DIRECTORIES, MAX_PLACEMENT_COMBINATIONS;
|
|
4896
4896
|
var init_cloud_client = __esm({
|
|
4897
4897
|
"cli/cloud-client.ts"() {
|
|
4898
4898
|
"use strict";
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
|
|
4899
|
+
import_node_crypto12 = require("node:crypto");
|
|
4900
|
+
import_node_fs26 = require("node:fs");
|
|
4901
|
+
import_node_path27 = require("node:path");
|
|
4902
4902
|
init_metroAssetArtifact();
|
|
4903
4903
|
init_metroCloudArtifact();
|
|
4904
4904
|
init_metro_fingerprint_registry_client();
|
|
@@ -5336,9 +5336,9 @@ function safeChildPlistName(value) {
|
|
|
5336
5336
|
name: file.toLowerCase().endsWith(".plist") ? file : `${file}.plist`
|
|
5337
5337
|
};
|
|
5338
5338
|
}
|
|
5339
|
-
async function readableSettingsBundle(
|
|
5339
|
+
async function readableSettingsBundle(path22) {
|
|
5340
5340
|
try {
|
|
5341
|
-
const root = await (0, import_promises.stat)((0, import_node_path.join)(
|
|
5341
|
+
const root = await (0, import_promises.stat)((0, import_node_path.join)(path22, "Root.plist"));
|
|
5342
5342
|
return root.isFile() && root.size <= MAX_PLIST_BYTES;
|
|
5343
5343
|
} catch {
|
|
5344
5344
|
return false;
|
|
@@ -5383,11 +5383,11 @@ async function settingsBundleFingerprint(bundlePath) {
|
|
|
5383
5383
|
return null;
|
|
5384
5384
|
}
|
|
5385
5385
|
}
|
|
5386
|
-
async function parsePlistRecord(
|
|
5386
|
+
async function parsePlistRecord(path22) {
|
|
5387
5387
|
try {
|
|
5388
|
-
const metadata = await (0, import_promises.stat)(
|
|
5388
|
+
const metadata = await (0, import_promises.stat)(path22);
|
|
5389
5389
|
if (!metadata.isFile() || metadata.size > MAX_PLIST_BYTES) return null;
|
|
5390
|
-
const source = await (0, import_promises.readFile)(
|
|
5390
|
+
const source = await (0, import_promises.readFile)(path22, "utf8");
|
|
5391
5391
|
const parsed = parsePlistSource(source);
|
|
5392
5392
|
return isRecord2(parsed) ? parsed : null;
|
|
5393
5393
|
} catch {
|
|
@@ -5649,7 +5649,7 @@ async function tcpPing(port, timeout = TCP_GATE_MS) {
|
|
|
5649
5649
|
return null;
|
|
5650
5650
|
}
|
|
5651
5651
|
}
|
|
5652
|
-
function httpGet(hostname, port,
|
|
5652
|
+
function httpGet(hostname, port, path22, method = "GET", timeout = TIMEOUT_MS, headers = {}) {
|
|
5653
5653
|
return new Promise((resolve5) => {
|
|
5654
5654
|
let settled = false;
|
|
5655
5655
|
let killing = false;
|
|
@@ -5658,7 +5658,7 @@ function httpGet(hostname, port, path20, method = "GET", timeout = TIMEOUT_MS, h
|
|
|
5658
5658
|
settled = true;
|
|
5659
5659
|
resolve5(value);
|
|
5660
5660
|
};
|
|
5661
|
-
const req = import_http.default.request({ hostname, port, path:
|
|
5661
|
+
const req = import_http.default.request({ hostname, port, path: path22, method, headers }, (res) => {
|
|
5662
5662
|
let body = "";
|
|
5663
5663
|
res.on("data", (c) => body += c.toString());
|
|
5664
5664
|
const contentType = (() => {
|
|
@@ -6337,12 +6337,12 @@ function getCliVersion() {
|
|
|
6337
6337
|
}
|
|
6338
6338
|
|
|
6339
6339
|
// src/expo-swift-host.ts
|
|
6340
|
-
var
|
|
6341
|
-
var
|
|
6342
|
-
var
|
|
6340
|
+
var import_node_child_process8 = require("node:child_process");
|
|
6341
|
+
var import_node_crypto7 = require("node:crypto");
|
|
6342
|
+
var import_node_fs17 = __toESM(require("node:fs"), 1);
|
|
6343
6343
|
var import_node_module = require("node:module");
|
|
6344
|
-
var
|
|
6345
|
-
var
|
|
6344
|
+
var import_node_os7 = __toESM(require("node:os"), 1);
|
|
6345
|
+
var import_node_path18 = __toESM(require("node:path"), 1);
|
|
6346
6346
|
var import_node_util3 = require("node:util");
|
|
6347
6347
|
|
|
6348
6348
|
// cli/internal-child.ts
|
|
@@ -6580,116 +6580,9 @@ function manifestCalls(manifest, kinds) {
|
|
|
6580
6580
|
}
|
|
6581
6581
|
return calls;
|
|
6582
6582
|
}
|
|
6583
|
-
var NAME = /\bname\s*:\s*"([^"]+)"/;
|
|
6584
|
-
function listArgument(call, label) {
|
|
6585
|
-
const start = new RegExp(`\\b${label}\\s*:\\s*\\[`).exec(call);
|
|
6586
|
-
if (!start) return [];
|
|
6587
|
-
const items = [];
|
|
6588
|
-
let depth = 0;
|
|
6589
|
-
let inString = false;
|
|
6590
|
-
let item = "";
|
|
6591
|
-
for (let i = start.index + start[0].length; i < call.length; i++) {
|
|
6592
|
-
const ch = call[i];
|
|
6593
|
-
if (inString) {
|
|
6594
|
-
item += ch;
|
|
6595
|
-
if (ch === '"' && call[i - 1] !== "\\") inString = false;
|
|
6596
|
-
continue;
|
|
6597
|
-
}
|
|
6598
|
-
if (ch === '"') inString = true;
|
|
6599
|
-
else if (ch === "(" || ch === "[") depth++;
|
|
6600
|
-
else if (ch === ")" || ch === "]") {
|
|
6601
|
-
if (depth === 0) break;
|
|
6602
|
-
depth--;
|
|
6603
|
-
} else if (ch === "," && depth === 0) {
|
|
6604
|
-
items.push(item.trim());
|
|
6605
|
-
item = "";
|
|
6606
|
-
continue;
|
|
6607
|
-
}
|
|
6608
|
-
item += ch;
|
|
6609
|
-
}
|
|
6610
|
-
if (item.trim()) items.push(item.trim());
|
|
6611
|
-
return items;
|
|
6612
|
-
}
|
|
6613
6583
|
function swiftPackageIdentity(url) {
|
|
6614
6584
|
return (url.split("/").pop() ?? url).replace(/\.git$/, "").toLowerCase();
|
|
6615
6585
|
}
|
|
6616
|
-
function swiftManifestGraph(manifest) {
|
|
6617
|
-
const graph = {
|
|
6618
|
-
products: /* @__PURE__ */ new Map(),
|
|
6619
|
-
dependencies: /* @__PURE__ */ new Map(),
|
|
6620
|
-
binaryTargets: /* @__PURE__ */ new Set(),
|
|
6621
|
-
systemLibraries: /* @__PURE__ */ new Set(),
|
|
6622
|
-
packageURLs: /* @__PURE__ */ new Map(),
|
|
6623
|
-
packagePaths: []
|
|
6624
|
-
};
|
|
6625
|
-
for (const { kind, flat, call } of manifestCalls(manifest, [
|
|
6626
|
-
"library",
|
|
6627
|
-
"executableTarget",
|
|
6628
|
-
"target",
|
|
6629
|
-
"binaryTarget",
|
|
6630
|
-
"systemLibrary",
|
|
6631
|
-
"package"
|
|
6632
|
-
])) {
|
|
6633
|
-
if (kind === "package") {
|
|
6634
|
-
const local = /\bpath\s*:\s*"([^"]+)"/.exec(flat)?.[1];
|
|
6635
|
-
if (local) graph.packagePaths.push(local);
|
|
6636
|
-
const url = /\burl\s*:\s*"([^"]+)"/.exec(flat)?.[1];
|
|
6637
|
-
if (!url) continue;
|
|
6638
|
-
graph.packageURLs.set(swiftPackageIdentity(url), url);
|
|
6639
|
-
const name3 = NAME.exec(flat)?.[1];
|
|
6640
|
-
if (name3) graph.packageURLs.set(name3.toLowerCase(), url);
|
|
6641
|
-
continue;
|
|
6642
|
-
}
|
|
6643
|
-
const name2 = NAME.exec(flat)?.[1];
|
|
6644
|
-
if (!name2) continue;
|
|
6645
|
-
if (kind === "library") {
|
|
6646
|
-
graph.products.set(
|
|
6647
|
-
name2,
|
|
6648
|
-
listArgument(call, "targets").flatMap(
|
|
6649
|
-
(item) => /^"([^"]+)"$/.exec(item)?.[1] ?? []
|
|
6650
|
-
)
|
|
6651
|
-
);
|
|
6652
|
-
continue;
|
|
6653
|
-
}
|
|
6654
|
-
if (kind === "binaryTarget") graph.binaryTargets.add(name2);
|
|
6655
|
-
if (kind === "systemLibrary") graph.systemLibraries.add(name2);
|
|
6656
|
-
const dependencies = [];
|
|
6657
|
-
for (const item of listArgument(call, "dependencies")) {
|
|
6658
|
-
const platforms = /condition\s*:\s*\.when\(\s*platforms\s*:\s*\[([^\]]*)\]/.exec(
|
|
6659
|
-
item
|
|
6660
|
-
)?.[1];
|
|
6661
|
-
if (platforms !== void 0 && !/\.iOS\b/.test(platforms)) continue;
|
|
6662
|
-
if (/condition\s*:\s*\.when\([^)]*\btraits\s*:/.test(item)) continue;
|
|
6663
|
-
const plain = /^"([^"]+)"$/.exec(item)?.[1];
|
|
6664
|
-
const product = /^\.product(?:Item)?\(\s*name\s*:\s*"([^"]+)"\s*,\s*package\s*:\s*"([^"]+)"/.exec(
|
|
6665
|
-
item
|
|
6666
|
-
);
|
|
6667
|
-
const target = /^\.(?:target|byName)(?:Item)?\(\s*name\s*:\s*"([^"]+)"/.exec(
|
|
6668
|
-
item
|
|
6669
|
-
)?.[1];
|
|
6670
|
-
if (plain) dependencies.push({ kind: "target", name: plain });
|
|
6671
|
-
else if (product)
|
|
6672
|
-
dependencies.push({
|
|
6673
|
-
kind: "product",
|
|
6674
|
-
name: product[1],
|
|
6675
|
-
package: product[2].toLowerCase()
|
|
6676
|
-
});
|
|
6677
|
-
else if (target) dependencies.push({ kind: "target", name: target });
|
|
6678
|
-
}
|
|
6679
|
-
graph.dependencies.set(name2, dependencies);
|
|
6680
|
-
}
|
|
6681
|
-
for (const dependencies of graph.dependencies.values()) {
|
|
6682
|
-
for (const [index, dependency] of dependencies.entries()) {
|
|
6683
|
-
if (dependency.kind === "target" && !graph.dependencies.has(dependency.name))
|
|
6684
|
-
dependencies[index] = {
|
|
6685
|
-
kind: "product",
|
|
6686
|
-
name: dependency.name,
|
|
6687
|
-
package: dependency.name.toLowerCase()
|
|
6688
|
-
};
|
|
6689
|
-
}
|
|
6690
|
-
}
|
|
6691
|
-
return graph;
|
|
6692
|
-
}
|
|
6693
6586
|
function swiftManifestTargets(manifest, resourcePaths = []) {
|
|
6694
6587
|
const implicitResources = swiftImplicitResourcePaths(resourcePaths);
|
|
6695
6588
|
const targets = [];
|
|
@@ -7108,21 +7001,21 @@ var CLASS_DECL = /^class\s+(?!(?:func|var|let|subscript)\b)([A-Za-z_]\w*)/;
|
|
|
7108
7001
|
var MODIFIERS = /(?:^|\s)(public|open|internal|fileprivate|private|final|nonisolated|@MainActor)(?=\s)/g;
|
|
7109
7002
|
var OVERRIDE_FUNC = /^override((?:\s+(?:public|open|internal|fileprivate|private|final|nonisolated|dynamic|@\w+))*)\s+func\s+([A-Za-z_]\w*)\s*(<[^>{}]*>)?\s*\(/;
|
|
7110
7003
|
var OVERRIDE_VAR = /^override((?:\s+(?:public|open|internal|fileprivate|private|final|nonisolated|dynamic|@\w+))*)\s+var\s+([A-Za-z_]\w*)\s*:\s*([^{=]+?)\s*\{/;
|
|
7111
|
-
function splitTopLevel(
|
|
7004
|
+
function splitTopLevel(text2) {
|
|
7112
7005
|
const parts = [];
|
|
7113
7006
|
let depth = 0;
|
|
7114
7007
|
let start = 0;
|
|
7115
|
-
for (let i = 0; i <
|
|
7116
|
-
const char =
|
|
7008
|
+
for (let i = 0; i < text2.length; i++) {
|
|
7009
|
+
const char = text2[i];
|
|
7117
7010
|
if (char === "(" || char === "[" || char === "<") depth++;
|
|
7118
|
-
else if (char === ")" || char === "]" || char === ">" &&
|
|
7011
|
+
else if (char === ")" || char === "]" || char === ">" && text2[i - 1] !== "-")
|
|
7119
7012
|
depth--;
|
|
7120
7013
|
else if (char === "," && depth === 0) {
|
|
7121
|
-
parts.push(
|
|
7014
|
+
parts.push(text2.slice(start, i));
|
|
7122
7015
|
start = i + 1;
|
|
7123
7016
|
}
|
|
7124
7017
|
}
|
|
7125
|
-
parts.push(
|
|
7018
|
+
parts.push(text2.slice(start));
|
|
7126
7019
|
return parts.map((part) => part.trim()).filter((part) => part !== "");
|
|
7127
7020
|
}
|
|
7128
7021
|
function forwardedArguments(parameters) {
|
|
@@ -7149,21 +7042,21 @@ function scanObjCExtensionMembers(source, tokens, records) {
|
|
|
7149
7042
|
const masked = swiftCodeMask(source);
|
|
7150
7043
|
const found = /* @__PURE__ */ new Map();
|
|
7151
7044
|
const member = /\b(func|var)\s+([A-Za-z_]\w*)/g;
|
|
7152
|
-
for (const
|
|
7153
|
-
const close = closingBrace(source, tokens,
|
|
7154
|
-
const body = masked.slice(
|
|
7045
|
+
for (const record2 of records) {
|
|
7046
|
+
const close = closingBrace(source, tokens, record2.open);
|
|
7047
|
+
const body = masked.slice(record2.open, close);
|
|
7155
7048
|
member.lastIndex = 0;
|
|
7156
7049
|
for (let match = member.exec(body); match; match = member.exec(body)) {
|
|
7157
|
-
const at =
|
|
7050
|
+
const at = record2.open + match.index + match[0].indexOf(match[1]);
|
|
7158
7051
|
let depth = 0;
|
|
7159
7052
|
for (const token of tokens) {
|
|
7160
|
-
if (token <=
|
|
7053
|
+
if (token <= record2.open) continue;
|
|
7161
7054
|
if (token >= at) break;
|
|
7162
7055
|
if (source[token] === "{") depth++;
|
|
7163
7056
|
else if (source[token] === "}") depth--;
|
|
7164
7057
|
}
|
|
7165
7058
|
if (depth > 0) continue;
|
|
7166
|
-
const head = masked.slice(
|
|
7059
|
+
const head = masked.slice(record2.open, at);
|
|
7167
7060
|
const bound = Math.max(
|
|
7168
7061
|
head.lastIndexOf(";"),
|
|
7169
7062
|
head.lastIndexOf("{"),
|
|
@@ -7174,11 +7067,11 @@ function scanObjCExtensionMembers(source, tokens, records) {
|
|
|
7174
7067
|
prefix
|
|
7175
7068
|
))
|
|
7176
7069
|
continue;
|
|
7177
|
-
if (!/@objc\b/.test(prefix) && !/@IBAction\b/.test(prefix) && !
|
|
7070
|
+
if (!/@objc\b/.test(prefix) && !/@IBAction\b/.test(prefix) && !record2.objcMembers)
|
|
7178
7071
|
continue;
|
|
7179
|
-
const members = found.get(
|
|
7072
|
+
const members = found.get(record2.type) ?? /* @__PURE__ */ new Set();
|
|
7180
7073
|
members.add(match[2]);
|
|
7181
|
-
found.set(
|
|
7074
|
+
found.set(record2.type, members);
|
|
7182
7075
|
}
|
|
7183
7076
|
}
|
|
7184
7077
|
return found;
|
|
@@ -8646,10 +8539,10 @@ function swiftModuleToolchain(root) {
|
|
|
8646
8539
|
}
|
|
8647
8540
|
|
|
8648
8541
|
// src/swift-host.ts
|
|
8649
|
-
var
|
|
8650
|
-
var
|
|
8651
|
-
var
|
|
8652
|
-
var
|
|
8542
|
+
var import_node_crypto6 = require("node:crypto");
|
|
8543
|
+
var import_node_fs16 = __toESM(require("node:fs"), 1);
|
|
8544
|
+
var import_node_os6 = __toESM(require("node:os"), 1);
|
|
8545
|
+
var import_node_path17 = __toESM(require("node:path"), 1);
|
|
8653
8546
|
|
|
8654
8547
|
// ../sootsim-swift/src/bundleAssets.ts
|
|
8655
8548
|
var import_svgpath = __toESM(require("svgpath"), 1);
|
|
@@ -8683,14 +8576,14 @@ function pickImagesetFile(images) {
|
|
|
8683
8576
|
scale: pick.scale === "2x" ? 2 : pick.scale === "3x" ? 3 : 1
|
|
8684
8577
|
};
|
|
8685
8578
|
}
|
|
8686
|
-
function flatScale(
|
|
8687
|
-
const match = /@([23])x\.[^./]+$/.exec(
|
|
8579
|
+
function flatScale(path22) {
|
|
8580
|
+
const match = /@([23])x\.[^./]+$/.exec(path22);
|
|
8688
8581
|
return match ? Number(match[1]) : 1;
|
|
8689
8582
|
}
|
|
8690
|
-
function providesNamespace(
|
|
8691
|
-
if (
|
|
8583
|
+
function providesNamespace(text2) {
|
|
8584
|
+
if (text2 === null) return false;
|
|
8692
8585
|
try {
|
|
8693
|
-
const parsed = JSON.parse(
|
|
8586
|
+
const parsed = JSON.parse(text2);
|
|
8694
8587
|
return parsed?.properties?.["provides-namespace"] === true;
|
|
8695
8588
|
} catch {
|
|
8696
8589
|
return false;
|
|
@@ -8711,21 +8604,21 @@ function catalogEntryName(contentsPath, kind, readText) {
|
|
|
8711
8604
|
}
|
|
8712
8605
|
return segments.join("/");
|
|
8713
8606
|
}
|
|
8714
|
-
function isFlatResourceImage(
|
|
8715
|
-
return
|
|
8607
|
+
function isFlatResourceImage(path22) {
|
|
8608
|
+
return path22.split("/").includes("Resources") && RASTER_EXTENSIONS.has(extOf(path22));
|
|
8716
8609
|
}
|
|
8717
8610
|
function enumerateBundleImages(paths, readText) {
|
|
8718
8611
|
const table = [];
|
|
8719
8612
|
const seen = /* @__PURE__ */ new Set();
|
|
8720
|
-
const catalogs = paths.filter((
|
|
8613
|
+
const catalogs = paths.filter((path22) => baseOf(path22) === "Contents.json");
|
|
8721
8614
|
for (const contentsPath of catalogs) {
|
|
8722
8615
|
const name2 = catalogEntryName(contentsPath, ".imageset", readText);
|
|
8723
8616
|
if (name2 === null || seen.has(name2)) continue;
|
|
8724
8617
|
let parsed;
|
|
8725
8618
|
try {
|
|
8726
|
-
const
|
|
8727
|
-
if (
|
|
8728
|
-
parsed = JSON.parse(
|
|
8619
|
+
const text2 = readText(contentsPath);
|
|
8620
|
+
if (text2 === null) continue;
|
|
8621
|
+
parsed = JSON.parse(text2);
|
|
8729
8622
|
} catch {
|
|
8730
8623
|
continue;
|
|
8731
8624
|
}
|
|
@@ -8738,12 +8631,12 @@ function enumerateBundleImages(paths, readText) {
|
|
|
8738
8631
|
seen.add(name2);
|
|
8739
8632
|
table.push({ name: name2, file: `${dir}/${pick.filename}`, scale: pick.scale });
|
|
8740
8633
|
}
|
|
8741
|
-
for (const
|
|
8742
|
-
if (!isFlatResourceImage(
|
|
8743
|
-
const name2 = baseOf(
|
|
8634
|
+
for (const path22 of paths) {
|
|
8635
|
+
if (!isFlatResourceImage(path22)) continue;
|
|
8636
|
+
const name2 = baseOf(path22).slice(0, -extOf(path22).length);
|
|
8744
8637
|
if (name2 === "" || seen.has(name2)) continue;
|
|
8745
8638
|
seen.add(name2);
|
|
8746
|
-
table.push({ name: name2, file:
|
|
8639
|
+
table.push({ name: name2, file: path22, scale: flatScale(path22) });
|
|
8747
8640
|
}
|
|
8748
8641
|
return table;
|
|
8749
8642
|
}
|
|
@@ -8772,14 +8665,14 @@ function colorsetValue(color) {
|
|
|
8772
8665
|
}
|
|
8773
8666
|
function enumerateBundleColors(paths, readText) {
|
|
8774
8667
|
const table = {};
|
|
8775
|
-
for (const contentsPath of paths.filter((
|
|
8668
|
+
for (const contentsPath of paths.filter((path22) => baseOf(path22) === "Contents.json")) {
|
|
8776
8669
|
const name2 = catalogEntryName(contentsPath, ".colorset", readText);
|
|
8777
8670
|
if (name2 === null || name2 in table) continue;
|
|
8778
8671
|
let colors;
|
|
8779
8672
|
try {
|
|
8780
|
-
const
|
|
8781
|
-
if (
|
|
8782
|
-
colors = Reflect.get(JSON.parse(
|
|
8673
|
+
const text2 = readText(contentsPath);
|
|
8674
|
+
if (text2 === null) continue;
|
|
8675
|
+
colors = Reflect.get(JSON.parse(text2), "colors");
|
|
8783
8676
|
} catch {
|
|
8784
8677
|
continue;
|
|
8785
8678
|
}
|
|
@@ -8812,11 +8705,11 @@ var SYMBOL_CAP_HEIGHT_EM = 1443 / 2048;
|
|
|
8812
8705
|
function axisExtremes(points) {
|
|
8813
8706
|
const [a = 0, b = 0, c = 0, d] = points;
|
|
8814
8707
|
const out = [a, d ?? c];
|
|
8815
|
-
const
|
|
8708
|
+
const within2 = (t) => t > 0 && t < 1;
|
|
8816
8709
|
if (d === void 0) {
|
|
8817
8710
|
const denom = a - 2 * b + c;
|
|
8818
8711
|
const t = denom === 0 ? -1 : (a - b) / denom;
|
|
8819
|
-
if (
|
|
8712
|
+
if (within2(t)) out.push((1 - t) ** 2 * a + 2 * (1 - t) * t * b + t ** 2 * c);
|
|
8820
8713
|
return out;
|
|
8821
8714
|
}
|
|
8822
8715
|
const qa = 3 * (-a + 3 * b - 3 * c + d);
|
|
@@ -8828,7 +8721,7 @@ function axisExtremes(points) {
|
|
|
8828
8721
|
const root = Math.sqrt(disc);
|
|
8829
8722
|
return [(-qb + root) / (2 * qa), (-qb - root) / (2 * qa)];
|
|
8830
8723
|
})();
|
|
8831
|
-
for (const t of roots.filter(
|
|
8724
|
+
for (const t of roots.filter(within2))
|
|
8832
8725
|
out.push(
|
|
8833
8726
|
(1 - t) ** 3 * a + 3 * (1 - t) ** 2 * t * b + 3 * (1 - t) * t ** 2 * c + t ** 3 * d
|
|
8834
8727
|
);
|
|
@@ -8837,8 +8730,8 @@ function axisExtremes(points) {
|
|
|
8837
8730
|
function pathBounds(d) {
|
|
8838
8731
|
const xs = [];
|
|
8839
8732
|
const ys = [];
|
|
8840
|
-
for (const
|
|
8841
|
-
(0, import_svgpath.default)(
|
|
8733
|
+
for (const path22 of d)
|
|
8734
|
+
(0, import_svgpath.default)(path22).abs().unshort().unarc().iterate((segment, _index, x, y) => {
|
|
8842
8735
|
const [command, ...args] = segment;
|
|
8843
8736
|
if (command === "M" || command === "L") {
|
|
8844
8737
|
xs.push(Number(args[0]));
|
|
@@ -8865,7 +8758,7 @@ function guide(svg, id, axis) {
|
|
|
8865
8758
|
}
|
|
8866
8759
|
function enumerateBundleSymbols(paths, readText) {
|
|
8867
8760
|
const table = {};
|
|
8868
|
-
for (const contentsPath of paths.filter((
|
|
8761
|
+
for (const contentsPath of paths.filter((path22) => baseOf(path22) === "Contents.json")) {
|
|
8869
8762
|
const name2 = catalogEntryName(contentsPath, ".symbolset", readText);
|
|
8870
8763
|
if (name2 === null || name2 in table) continue;
|
|
8871
8764
|
let symbols;
|
|
@@ -8898,8 +8791,8 @@ function enumerateBundleSymbols(paths, readText) {
|
|
|
8898
8791
|
viewBox: "0 0 24 24",
|
|
8899
8792
|
advance,
|
|
8900
8793
|
box: [12 - advance / 2, 12 - tall / 2, advance, tall],
|
|
8901
|
-
layers: d.map((
|
|
8902
|
-
d: (0, import_svgpath.default)(
|
|
8794
|
+
layers: d.map((path22) => ({
|
|
8795
|
+
d: (0, import_svgpath.default)(path22).abs().scale(scale).translate(translateX, translateY).round(3).toString()
|
|
8903
8796
|
}))
|
|
8904
8797
|
};
|
|
8905
8798
|
}
|
|
@@ -8909,7 +8802,7 @@ function enumerateBundleJson(paths) {
|
|
|
8909
8802
|
const found = [];
|
|
8910
8803
|
const seen = /* @__PURE__ */ new Set();
|
|
8911
8804
|
const ordered = [...paths].filter(
|
|
8912
|
-
(
|
|
8805
|
+
(path22) => path22.split("/").includes("Resources") && path22.split("/").every((segment) => segment !== "" && segment !== "..") && (extOf(path22) === ".json" || extOf(path22) === ".xcstrings")
|
|
8913
8806
|
).sort((a, b) => {
|
|
8914
8807
|
const aDepth = a.split("/").length;
|
|
8915
8808
|
const bDepth = b.split("/").length;
|
|
@@ -8928,14 +8821,225 @@ function enumerateBundleJson(paths) {
|
|
|
8928
8821
|
init_auth();
|
|
8929
8822
|
init_backend_origin();
|
|
8930
8823
|
|
|
8931
|
-
// src/swift-
|
|
8824
|
+
// src/swift-packages.ts
|
|
8825
|
+
var import_node_child_process7 = require("node:child_process");
|
|
8826
|
+
var import_node_fs14 = __toESM(require("node:fs"), 1);
|
|
8827
|
+
var import_node_path14 = __toESM(require("node:path"), 1);
|
|
8828
|
+
|
|
8829
|
+
// src/swift-package-manifest.ts
|
|
8932
8830
|
var import_node_child_process6 = require("node:child_process");
|
|
8831
|
+
var import_node_crypto5 = require("node:crypto");
|
|
8933
8832
|
var import_node_fs13 = __toESM(require("node:fs"), 1);
|
|
8833
|
+
var import_node_os5 = __toESM(require("node:os"), 1);
|
|
8934
8834
|
var import_node_path13 = __toESM(require("node:path"), 1);
|
|
8935
|
-
var
|
|
8835
|
+
var TARGET_TYPES = [
|
|
8836
|
+
"regular",
|
|
8837
|
+
"executable",
|
|
8838
|
+
"test",
|
|
8839
|
+
"binary",
|
|
8840
|
+
"system",
|
|
8841
|
+
"macro",
|
|
8842
|
+
"plugin"
|
|
8843
|
+
];
|
|
8844
|
+
var isTargetType = (value) => TARGET_TYPES.some((type) => type === value);
|
|
8845
|
+
var record = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
8846
|
+
var array = (value) => Array.isArray(value) ? value : [];
|
|
8847
|
+
var string = (value) => typeof value === "string" ? value : void 0;
|
|
8848
|
+
function swiftCommand() {
|
|
8849
|
+
return process.platform === "darwin" ? { file: "xcrun", args: ["swift"] } : { file: import_node_path13.default.join(swiftToolchainBin(swift_distribution_lock_default.release), "swift"), args: [] };
|
|
8850
|
+
}
|
|
8851
|
+
var cacheDir2 = import_node_path13.default.join(import_node_os5.default.tmpdir(), "peach-swift-manifests");
|
|
8852
|
+
var evaluated = /* @__PURE__ */ new Map();
|
|
8853
|
+
function dump(dir) {
|
|
8854
|
+
const manifests = import_node_fs13.default.readdirSync(dir).filter((name2) => /^Package(@swift-[\d.]+)?\.swift$/.test(name2)).sort();
|
|
8855
|
+
const command = swiftCommand();
|
|
8856
|
+
const key = (0, import_node_crypto5.createHash)("sha256").update(JSON.stringify([command, import_node_path13.default.resolve(dir)])).update(
|
|
8857
|
+
manifests.map((name2) => `${name2}\0${import_node_fs13.default.readFileSync(import_node_path13.default.join(dir, name2), "utf8")}`).join("\0")
|
|
8858
|
+
).digest("hex").slice(0, 32);
|
|
8859
|
+
const cached3 = import_node_path13.default.join(cacheDir2, `${key}.json`);
|
|
8860
|
+
if (import_node_fs13.default.existsSync(cached3))
|
|
8861
|
+
return { key, raw: record(JSON.parse(import_node_fs13.default.readFileSync(cached3, "utf8"))) };
|
|
8862
|
+
let output;
|
|
8863
|
+
try {
|
|
8864
|
+
output = (0, import_node_child_process6.execFileSync)(
|
|
8865
|
+
command.file,
|
|
8866
|
+
[
|
|
8867
|
+
...command.args,
|
|
8868
|
+
"package",
|
|
8869
|
+
"--package-path",
|
|
8870
|
+
dir,
|
|
8871
|
+
// swiftpm's scratch files never land in the app's own package
|
|
8872
|
+
"--scratch-path",
|
|
8873
|
+
import_node_path13.default.join(cacheDir2, `${key}.build`),
|
|
8874
|
+
"dump-package"
|
|
8875
|
+
],
|
|
8876
|
+
{
|
|
8877
|
+
encoding: "utf8",
|
|
8878
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
8879
|
+
maxBuffer: 64 * 1024 * 1024
|
|
8880
|
+
}
|
|
8881
|
+
);
|
|
8882
|
+
} catch (error) {
|
|
8883
|
+
const stderr = error instanceof Error && "stderr" in error ? String(error.stderr).trim() : "";
|
|
8884
|
+
throw new Error(
|
|
8885
|
+
`swiftpm could not evaluate ${import_node_path13.default.join(dir, "Package.swift")}${stderr ? `: ${stderr}` : ""}`
|
|
8886
|
+
);
|
|
8887
|
+
}
|
|
8888
|
+
import_node_fs13.default.mkdirSync(cacheDir2, { recursive: true });
|
|
8889
|
+
import_node_fs13.default.writeFileSync(cached3, output);
|
|
8890
|
+
return { key, raw: record(JSON.parse(output)) };
|
|
8891
|
+
}
|
|
8892
|
+
function defaultTraits(manifest) {
|
|
8893
|
+
const traits = new Map(
|
|
8894
|
+
array(manifest.traits).map((trait) => [
|
|
8895
|
+
string(record(trait).name) ?? "",
|
|
8896
|
+
array(record(trait).enabledTraits).flatMap((name2) => string(name2) ?? [])
|
|
8897
|
+
])
|
|
8898
|
+
);
|
|
8899
|
+
const enabled = /* @__PURE__ */ new Set();
|
|
8900
|
+
const pending = [...traits.get("default") ?? []];
|
|
8901
|
+
while (pending.length > 0) {
|
|
8902
|
+
const name2 = pending.pop();
|
|
8903
|
+
if (enabled.has(name2)) continue;
|
|
8904
|
+
enabled.add(name2);
|
|
8905
|
+
pending.push(...traits.get(name2) ?? []);
|
|
8906
|
+
}
|
|
8907
|
+
return enabled;
|
|
8908
|
+
}
|
|
8909
|
+
function linksOnIOS(condition, traits) {
|
|
8910
|
+
const { platformNames, traits: needed } = record(condition);
|
|
8911
|
+
const platforms = array(platformNames);
|
|
8912
|
+
if (platforms.length > 0 && !platforms.includes("ios")) return false;
|
|
8913
|
+
const gates = array(needed);
|
|
8914
|
+
return gates.length === 0 || gates.some((name2) => traits.has(string(name2) ?? ""));
|
|
8915
|
+
}
|
|
8916
|
+
function swiftPackageManifest(dir) {
|
|
8917
|
+
dir = import_node_fs13.default.realpathSync(dir);
|
|
8918
|
+
const { key, raw: raw2 } = dump(dir);
|
|
8919
|
+
const known = evaluated.get(key);
|
|
8920
|
+
if (known) return known;
|
|
8921
|
+
const traits = defaultTraits(raw2);
|
|
8922
|
+
const tools = Number(
|
|
8923
|
+
/^(\d+)/.exec(string(record(raw2.toolsVersion)._version) ?? "5")?.[1] ?? 5
|
|
8924
|
+
);
|
|
8925
|
+
const declaredModes = array(raw2.swiftLanguageVersions).flatMap((mode) => {
|
|
8926
|
+
const major = Number(/^(\d+)/.exec(string(mode) ?? "")?.[1]);
|
|
8927
|
+
return Number.isFinite(major) ? [major] : [];
|
|
8928
|
+
});
|
|
8929
|
+
const packageMode = Math.max(
|
|
8930
|
+
5,
|
|
8931
|
+
declaredModes.length > 0 ? Math.max(...declaredModes) : tools >= 6 ? 6 : 5
|
|
8932
|
+
);
|
|
8933
|
+
const packages = /* @__PURE__ */ new Map();
|
|
8934
|
+
for (const entry of array(raw2.dependencies)) {
|
|
8935
|
+
const { sourceControl, fileSystem } = record(entry);
|
|
8936
|
+
const source = record(array(sourceControl ?? fileSystem)[0]);
|
|
8937
|
+
const identity = string(source.identity);
|
|
8938
|
+
if (!identity) continue;
|
|
8939
|
+
const url = string(record(array(record(source.location).remote)[0]).urlString);
|
|
8940
|
+
const local = string(source.path);
|
|
8941
|
+
const value = url ? { url } : local ? { dir: local } : null;
|
|
8942
|
+
if (!value) continue;
|
|
8943
|
+
packages.set(identity, value);
|
|
8944
|
+
const alias = string(source.nameForTargetDependencyResolutionOnly);
|
|
8945
|
+
if (alias) packages.set(alias.toLowerCase(), value);
|
|
8946
|
+
}
|
|
8947
|
+
const products = /* @__PURE__ */ new Map();
|
|
8948
|
+
for (const product of array(raw2.products)) {
|
|
8949
|
+
const { name: name2, targets: targets2, type } = record(product);
|
|
8950
|
+
if (!string(name2) || !("library" in record(type))) continue;
|
|
8951
|
+
products.set(
|
|
8952
|
+
string(name2),
|
|
8953
|
+
array(targets2).flatMap((target) => string(target) ?? [])
|
|
8954
|
+
);
|
|
8955
|
+
}
|
|
8956
|
+
const targets = /* @__PURE__ */ new Map();
|
|
8957
|
+
const names = new Set(array(raw2.targets).map((target) => string(record(target).name)));
|
|
8958
|
+
for (const entry of array(raw2.targets)) {
|
|
8959
|
+
const target = record(entry);
|
|
8960
|
+
const name2 = string(target.name);
|
|
8961
|
+
const kind = string(target.type);
|
|
8962
|
+
if (!name2 || !isTargetType(kind)) continue;
|
|
8963
|
+
const declared = string(target.path);
|
|
8964
|
+
const roots = kind === "test" ? ["Tests"] : ["Sources", "Source", "src", "srcs"];
|
|
8965
|
+
const targetDir = declared ? import_node_path13.default.resolve(dir, declared) : roots.map((root) => import_node_path13.default.join(dir, root, name2)).find((candidate) => import_node_fs13.default.existsSync(candidate)) ?? import_node_path13.default.join(dir, roots[0], name2);
|
|
8966
|
+
const dependencies = [];
|
|
8967
|
+
for (const dependency of array(target.dependencies)) {
|
|
8968
|
+
const { target: local, product, byName } = record(dependency);
|
|
8969
|
+
const payload = array(local ?? product ?? byName);
|
|
8970
|
+
if (!linksOnIOS(payload[payload.length - 1], traits)) continue;
|
|
8971
|
+
const dependencyName = string(payload[0]);
|
|
8972
|
+
if (!dependencyName) continue;
|
|
8973
|
+
if (product)
|
|
8974
|
+
dependencies.push({
|
|
8975
|
+
kind: "product",
|
|
8976
|
+
name: dependencyName,
|
|
8977
|
+
package: (string(payload[1]) ?? "").toLowerCase()
|
|
8978
|
+
});
|
|
8979
|
+
else if (local || names.has(dependencyName))
|
|
8980
|
+
dependencies.push({ kind: "target", name: dependencyName });
|
|
8981
|
+
else
|
|
8982
|
+
dependencies.push({
|
|
8983
|
+
kind: "product",
|
|
8984
|
+
name: dependencyName,
|
|
8985
|
+
package: dependencyName.toLowerCase()
|
|
8986
|
+
});
|
|
8987
|
+
}
|
|
8988
|
+
let languageMode = packageMode;
|
|
8989
|
+
let mainActorIsolation = false;
|
|
8990
|
+
for (const setting of array(target.settings)) {
|
|
8991
|
+
const settingKind = record(record(setting).kind);
|
|
8992
|
+
const mode = string(record(settingKind.swiftLanguageMode)._0);
|
|
8993
|
+
if (mode)
|
|
8994
|
+
languageMode = Math.max(5, Number(/^(\d+)/.exec(mode)?.[1] ?? languageMode));
|
|
8995
|
+
if (string(record(settingKind.defaultIsolation)._0) === "MainActor")
|
|
8996
|
+
mainActorIsolation = true;
|
|
8997
|
+
}
|
|
8998
|
+
targets.set(name2, {
|
|
8999
|
+
name: name2,
|
|
9000
|
+
type: kind,
|
|
9001
|
+
dir: targetDir,
|
|
9002
|
+
sources: target.sources == null ? null : array(target.sources).flatMap((file) => string(file) ?? []),
|
|
9003
|
+
exclude: array(target.exclude).flatMap((file) => string(file) ?? []),
|
|
9004
|
+
dependencies,
|
|
9005
|
+
languageMode,
|
|
9006
|
+
mainActorIsolation,
|
|
9007
|
+
declaresResources: array(target.resources).length > 0
|
|
9008
|
+
});
|
|
9009
|
+
}
|
|
9010
|
+
const manifest = { dir, products, targets, packages };
|
|
9011
|
+
evaluated.set(key, manifest);
|
|
9012
|
+
return manifest;
|
|
9013
|
+
}
|
|
9014
|
+
var within = (file, roots) => roots.some((root) => file === root || file.startsWith(`${root}${import_node_path13.default.sep}`));
|
|
9015
|
+
function walk(dir) {
|
|
9016
|
+
if (!import_node_fs13.default.existsSync(dir)) return [];
|
|
9017
|
+
if (import_node_fs13.default.statSync(dir).isFile()) return [dir];
|
|
9018
|
+
const out = [];
|
|
9019
|
+
for (const entry of import_node_fs13.default.readdirSync(dir, { withFileTypes: true })) {
|
|
9020
|
+
if (entry.name.startsWith(".")) continue;
|
|
9021
|
+
const full = import_node_path13.default.join(dir, entry.name);
|
|
9022
|
+
if (entry.isDirectory()) out.push(...walk(full));
|
|
9023
|
+
else if (entry.isFile()) out.push(full);
|
|
9024
|
+
}
|
|
9025
|
+
return out;
|
|
9026
|
+
}
|
|
9027
|
+
function swiftTargetFiles(manifest, target) {
|
|
9028
|
+
const included = target.sources ? target.sources.map((source) => import_node_path13.default.resolve(target.dir, source)) : [target.dir];
|
|
9029
|
+
const excluded = [
|
|
9030
|
+
...target.exclude.map((file) => import_node_path13.default.resolve(target.dir, file)),
|
|
9031
|
+
...[...manifest.targets.values()].flatMap(
|
|
9032
|
+
(other) => other !== target && within(other.dir, [target.dir]) && other.dir !== target.dir ? [other.dir] : []
|
|
9033
|
+
)
|
|
9034
|
+
];
|
|
9035
|
+
return included.flatMap(walk).filter((file) => !within(file, excluded)).sort();
|
|
9036
|
+
}
|
|
9037
|
+
|
|
9038
|
+
// src/swift-packages.ts
|
|
9039
|
+
var REMOTE_CHECKOUTS = import_node_path14.default.join(".build", "peach", "checkouts");
|
|
8936
9040
|
var C_FAMILY = /\.(c|cc|cpp|cxx|m|mm|s|S)$/;
|
|
8937
9041
|
function readPins(resolved) {
|
|
8938
|
-
const data = JSON.parse(
|
|
9042
|
+
const data = JSON.parse(import_node_fs14.default.readFileSync(resolved, "utf8"));
|
|
8939
9043
|
const pins = data && typeof data === "object" && "pins" in data && Array.isArray(data.pins) ? data.pins : null;
|
|
8940
9044
|
if (!pins)
|
|
8941
9045
|
throw new Error(`${resolved} has no pins; resolve packages in a current Xcode`);
|
|
@@ -8949,36 +9053,25 @@ function readPins(resolved) {
|
|
|
8949
9053
|
}
|
|
8950
9054
|
return out;
|
|
8951
9055
|
}
|
|
8952
|
-
function walk(dir) {
|
|
8953
|
-
if (!import_node_fs13.default.existsSync(dir)) return [];
|
|
8954
|
-
const out = [];
|
|
8955
|
-
for (const entry of import_node_fs13.default.readdirSync(dir, { withFileTypes: true })) {
|
|
8956
|
-
if (entry.name.startsWith(".")) continue;
|
|
8957
|
-
const full = import_node_path13.default.join(dir, entry.name);
|
|
8958
|
-
if (entry.isDirectory()) out.push(...walk(full));
|
|
8959
|
-
else if (entry.isFile()) out.push(full);
|
|
8960
|
-
}
|
|
8961
|
-
return out.sort();
|
|
8962
|
-
}
|
|
8963
9056
|
var verified2 = /* @__PURE__ */ new Set();
|
|
8964
9057
|
function checkout(checkouts, identity, pin) {
|
|
8965
|
-
const dir =
|
|
9058
|
+
const dir = import_node_path14.default.join(checkouts, identity);
|
|
8966
9059
|
const key = `${dir}\0${pin.revision}`;
|
|
8967
9060
|
if (verified2.has(key)) return dir;
|
|
8968
|
-
const git = (...args) => (0,
|
|
9061
|
+
const git = (...args) => (0, import_node_child_process7.execFileSync)("git", ["-C", dir, ...args], {
|
|
8969
9062
|
encoding: "utf8",
|
|
8970
9063
|
stdio: ["ignore", "pipe", "pipe"]
|
|
8971
9064
|
}).trim();
|
|
8972
|
-
const current =
|
|
9065
|
+
const current = import_node_fs14.default.existsSync(import_node_path14.default.join(dir, ".git")) ? git("rev-parse", "HEAD") : "";
|
|
8973
9066
|
if (current !== pin.revision) {
|
|
8974
|
-
|
|
8975
|
-
|
|
9067
|
+
import_node_fs14.default.rmSync(dir, { recursive: true, force: true });
|
|
9068
|
+
import_node_fs14.default.mkdirSync(dir, { recursive: true });
|
|
8976
9069
|
try {
|
|
8977
9070
|
git("init", "-q");
|
|
8978
9071
|
git("fetch", "-q", "--depth", "1", pin.location, pin.revision);
|
|
8979
9072
|
git("checkout", "-q", "FETCH_HEAD");
|
|
8980
9073
|
} catch (error) {
|
|
8981
|
-
|
|
9074
|
+
import_node_fs14.default.rmSync(dir, { recursive: true, force: true });
|
|
8982
9075
|
const stderr = error instanceof Error && "stderr" in error ? String(error.stderr).trim() : "";
|
|
8983
9076
|
throw new Error(
|
|
8984
9077
|
`could not fetch ${pin.location} at ${pin.revision}${stderr ? `: ${stderr}` : ""}`
|
|
@@ -8988,127 +9081,153 @@ function checkout(checkouts, identity, pin) {
|
|
|
8988
9081
|
verified2.add(key);
|
|
8989
9082
|
return dir;
|
|
8990
9083
|
}
|
|
8991
|
-
function
|
|
8992
|
-
const
|
|
8993
|
-
const
|
|
8994
|
-
|
|
8995
|
-
|
|
8996
|
-
|
|
8997
|
-
|
|
8998
|
-
|
|
8999
|
-
|
|
9000
|
-
|
|
9001
|
-
return result;
|
|
9002
|
-
}
|
|
9003
|
-
const pins = readPins(resolved);
|
|
9004
|
-
const checkouts = import_node_path13.default.join(projectDir, REMOTE_CHECKOUTS);
|
|
9005
|
-
import_node_fs13.default.mkdirSync(checkouts, { recursive: true });
|
|
9006
|
-
import_node_fs13.default.writeFileSync(import_node_path13.default.join(import_node_path13.default.dirname(checkouts), ".gitignore"), "*\n");
|
|
9084
|
+
function resolveSwiftPackages(options) {
|
|
9085
|
+
const { rootDir, resolved, products, localDirs } = options;
|
|
9086
|
+
const provided = options.provided ?? /* @__PURE__ */ new Set();
|
|
9087
|
+
const result = {
|
|
9088
|
+
targets: [],
|
|
9089
|
+
unavailable: /* @__PURE__ */ new Map(),
|
|
9090
|
+
modules: /* @__PURE__ */ new Map()
|
|
9091
|
+
};
|
|
9092
|
+
const pins = resolved ? readPins(resolved) : null;
|
|
9093
|
+
const checkouts = import_node_path14.default.join(rootDir, REMOTE_CHECKOUTS);
|
|
9007
9094
|
const packages = /* @__PURE__ */ new Map();
|
|
9008
|
-
const load2 = (
|
|
9009
|
-
const
|
|
9010
|
-
|
|
9011
|
-
|
|
9012
|
-
|
|
9013
|
-
|
|
9014
|
-
|
|
9015
|
-
|
|
9016
|
-
|
|
9095
|
+
const load2 = (source) => {
|
|
9096
|
+
const key = source.kind === "local" ? import_node_path14.default.resolve(source.dir) : source.url;
|
|
9097
|
+
const cached3 = packages.get(key);
|
|
9098
|
+
if (cached3 !== void 0) return cached3;
|
|
9099
|
+
let loaded2;
|
|
9100
|
+
if (source.kind === "local") {
|
|
9101
|
+
loaded2 = { source: key, remote: false, manifest: swiftPackageManifest(key) };
|
|
9102
|
+
} else {
|
|
9103
|
+
const identity = swiftPackageIdentity(source.url);
|
|
9104
|
+
const pin = pins?.get(identity);
|
|
9105
|
+
if (!pin) {
|
|
9106
|
+
loaded2 = pins ? `package ${identity} is not pinned in Package.resolved` : "no Package.resolved pins it; resolve packages in Xcode once";
|
|
9107
|
+
} else {
|
|
9108
|
+
import_node_fs14.default.mkdirSync(checkouts, { recursive: true });
|
|
9109
|
+
import_node_fs14.default.writeFileSync(import_node_path14.default.join(import_node_path14.default.dirname(checkouts), ".gitignore"), "*\n");
|
|
9110
|
+
loaded2 = {
|
|
9111
|
+
source: source.url,
|
|
9112
|
+
remote: true,
|
|
9113
|
+
manifest: swiftPackageManifest(checkout(checkouts, identity, pin))
|
|
9114
|
+
};
|
|
9115
|
+
}
|
|
9116
|
+
}
|
|
9117
|
+
packages.set(key, loaded2);
|
|
9017
9118
|
return loaded2;
|
|
9018
9119
|
};
|
|
9019
9120
|
const targets = /* @__PURE__ */ new Map();
|
|
9020
|
-
const
|
|
9021
|
-
const
|
|
9022
|
-
const key = `${
|
|
9023
|
-
if (
|
|
9024
|
-
|
|
9025
|
-
const
|
|
9026
|
-
|
|
9027
|
-
|
|
9028
|
-
return
|
|
9029
|
-
|
|
9030
|
-
|
|
9031
|
-
|
|
9032
|
-
|
|
9033
|
-
|
|
9034
|
-
|
|
9035
|
-
|
|
9036
|
-
|
|
9037
|
-
|
|
9038
|
-
|
|
9039
|
-
|
|
9040
|
-
const pending = [...roots];
|
|
9041
|
-
let reason = null;
|
|
9042
|
-
while (pending.length > 0 && !reason) {
|
|
9043
|
-
const name2 = pending.pop();
|
|
9044
|
-
if (seen.has(name2) || provided.has(name2)) continue;
|
|
9045
|
-
seen.add(name2);
|
|
9046
|
-
if (pkg.graph.binaryTargets.has(name2)) {
|
|
9047
|
-
reason = `${name2} is a binary framework`;
|
|
9048
|
-
break;
|
|
9049
|
-
}
|
|
9050
|
-
if (pkg.graph.systemLibraries.has(name2)) {
|
|
9051
|
-
reason = `${name2} is a system C library`;
|
|
9052
|
-
break;
|
|
9053
|
-
}
|
|
9054
|
-
const target = declared.get(name2);
|
|
9055
|
-
if (!target) {
|
|
9056
|
-
reason = `${identity} declares no target ${name2}`;
|
|
9057
|
-
break;
|
|
9058
|
-
}
|
|
9059
|
-
const files = walk(import_node_path13.default.join(pkg.dir, target.path));
|
|
9060
|
-
if (files.some((file) => C_FAMILY.test(file))) {
|
|
9061
|
-
reason = `${name2} is a C or Objective-C target`;
|
|
9062
|
-
break;
|
|
9063
|
-
}
|
|
9064
|
-
reached.push(target);
|
|
9065
|
-
for (const dependency of pkg.graph.dependencies.get(name2) ?? []) {
|
|
9066
|
-
if (dependency.kind === "target") pending.push(dependency.name);
|
|
9067
|
-
else if (!provided.has(dependency.name)) {
|
|
9068
|
-
const url = pkg.graph.packageURLs.get(dependency.package);
|
|
9069
|
-
const nested = resolveProduct(
|
|
9070
|
-
url ? swiftPackageIdentity(url) : dependency.package,
|
|
9071
|
-
dependency.name
|
|
9072
|
-
);
|
|
9073
|
-
if (nested) reason = `${dependency.name}: ${nested}`;
|
|
9121
|
+
const targetOutcomes = /* @__PURE__ */ new Map();
|
|
9122
|
+
const resolveTarget = (pkg, name2) => {
|
|
9123
|
+
const key = `${pkg.manifest.dir}\0${name2}`;
|
|
9124
|
+
if (targetOutcomes.has(key)) return targetOutcomes.get(key);
|
|
9125
|
+
targetOutcomes.set(key, null);
|
|
9126
|
+
const outcome = (() => {
|
|
9127
|
+
if (provided.has(name2)) return null;
|
|
9128
|
+
const target = pkg.manifest.targets.get(name2);
|
|
9129
|
+
if (!target) return `${import_node_path14.default.basename(pkg.manifest.dir)} declares no target ${name2}`;
|
|
9130
|
+
if (target.type === "binary") return `${name2} is a binary framework`;
|
|
9131
|
+
if (target.type === "system") return `${name2} is a system C library`;
|
|
9132
|
+
if (target.type !== "regular") return `${name2} is a ${target.type} target`;
|
|
9133
|
+
const files = swiftTargetFiles(pkg.manifest, target);
|
|
9134
|
+
if (files.some((file) => C_FAMILY.test(file)))
|
|
9135
|
+
return `${name2} is a C or Objective-C target`;
|
|
9136
|
+
for (const dependency of target.dependencies) {
|
|
9137
|
+
if (dependency.kind === "target") {
|
|
9138
|
+
const nested2 = resolveTarget(pkg, dependency.name);
|
|
9139
|
+
if (nested2) return nested2;
|
|
9140
|
+
continue;
|
|
9074
9141
|
}
|
|
9142
|
+
const nested = resolveDependencyProduct(pkg, dependency.package, dependency.name);
|
|
9143
|
+
if (nested) return `${dependency.name}: ${nested}`;
|
|
9075
9144
|
}
|
|
9076
|
-
|
|
9077
|
-
|
|
9078
|
-
|
|
9079
|
-
|
|
9080
|
-
|
|
9081
|
-
|
|
9082
|
-
|
|
9083
|
-
|
|
9084
|
-
)
|
|
9085
|
-
);
|
|
9086
|
-
const withResources = new Map(
|
|
9087
|
-
swiftManifestTargets(pkg.manifest, relative2).map((target) => [target.name, target])
|
|
9088
|
-
);
|
|
9089
|
-
for (const target of reached) {
|
|
9090
|
-
const dir = import_node_path13.default.join(pkg.dir, target.path);
|
|
9091
|
-
targets.set(target.name, {
|
|
9092
|
-
...withResources.get(target.name) ?? target,
|
|
9145
|
+
const relative2 = files.map((file) => import_node_path14.default.relative(target.dir, file));
|
|
9146
|
+
targets.set(`${pkg.manifest.dir}\0${name2}`, {
|
|
9147
|
+
name: name2,
|
|
9148
|
+
path: "",
|
|
9149
|
+
dir: target.dir,
|
|
9150
|
+
files,
|
|
9151
|
+
packageDir: pkg.manifest.dir,
|
|
9152
|
+
remote: pkg.remote,
|
|
9093
9153
|
executable: false,
|
|
9094
|
-
|
|
9095
|
-
|
|
9154
|
+
languageMode: target.languageMode,
|
|
9155
|
+
mainActorIsolation: target.mainActorIsolation,
|
|
9156
|
+
resources: target.declaresResources || swiftImplicitResourcePaths(relative2).length > 0
|
|
9096
9157
|
});
|
|
9158
|
+
return null;
|
|
9159
|
+
})();
|
|
9160
|
+
targetOutcomes.set(key, outcome);
|
|
9161
|
+
return outcome;
|
|
9162
|
+
};
|
|
9163
|
+
const resolveProduct = (pkg, product) => {
|
|
9164
|
+
if (provided.has(product)) return null;
|
|
9165
|
+
const roots = pkg.manifest.products.get(product);
|
|
9166
|
+
if (!roots) return `${import_node_path14.default.basename(pkg.manifest.dir)} has no library ${product}`;
|
|
9167
|
+
for (const name2 of roots) {
|
|
9168
|
+
const reason = resolveTarget(pkg, name2);
|
|
9169
|
+
if (reason) return reason;
|
|
9097
9170
|
}
|
|
9098
9171
|
return null;
|
|
9099
9172
|
};
|
|
9100
|
-
|
|
9101
|
-
|
|
9102
|
-
|
|
9103
|
-
|
|
9104
|
-
|
|
9173
|
+
const resolveDependencyProduct = (pkg, packageName, product) => {
|
|
9174
|
+
if (provided.has(product)) return null;
|
|
9175
|
+
const dependency = pkg.manifest.packages.get(packageName);
|
|
9176
|
+
if (!dependency)
|
|
9177
|
+
return `${import_node_path14.default.basename(pkg.manifest.dir)} names no package ${packageName}`;
|
|
9178
|
+
if ("dir" in dependency) {
|
|
9179
|
+
const loaded3 = load2({ kind: "local", dir: dependency.dir });
|
|
9180
|
+
return typeof loaded3 === "string" ? loaded3 : resolveProduct(loaded3, product);
|
|
9181
|
+
}
|
|
9182
|
+
if (!options.provided) return null;
|
|
9183
|
+
const loaded2 = load2({ kind: "remote", url: dependency.url });
|
|
9184
|
+
return typeof loaded2 === "string" ? loaded2 : resolveProduct(loaded2, product);
|
|
9185
|
+
};
|
|
9186
|
+
const unnamed = () => localDirs.map((dir) => load2({ kind: "local", dir })).filter((pkg) => typeof pkg !== "string");
|
|
9187
|
+
for (const { product, source } of products) {
|
|
9188
|
+
if (provided.has(product)) continue;
|
|
9189
|
+
if (source.kind === "remote" && !options.provided) continue;
|
|
9190
|
+
const pkg = source.kind === "unnamed" ? unnamed().find((candidate) => candidate.manifest.products.has(product)) : load2(source);
|
|
9191
|
+
const reason = pkg === void 0 ? "no package the workspace references vends it" : typeof pkg === "string" ? pkg : resolveProduct(pkg, product);
|
|
9105
9192
|
if (reason)
|
|
9106
|
-
result.unavailable.set(
|
|
9107
|
-
|
|
9193
|
+
result.unavailable.set(product, {
|
|
9194
|
+
source: source.kind === "remote" ? source.url : typeof pkg === "object" ? pkg.source : source.kind === "local" ? source.dir : "the workspace",
|
|
9108
9195
|
reason
|
|
9109
9196
|
});
|
|
9110
9197
|
}
|
|
9111
|
-
|
|
9198
|
+
for (const pkg of packages.values()) {
|
|
9199
|
+
if (typeof pkg === "string") continue;
|
|
9200
|
+
for (const [name2, target] of pkg.manifest.targets) {
|
|
9201
|
+
if (target.type === "test" || target.type === "plugin" || target.type === "macro")
|
|
9202
|
+
continue;
|
|
9203
|
+
if (target.type === "executable") continue;
|
|
9204
|
+
const reason = resolveTarget(pkg, name2);
|
|
9205
|
+
if (reason && !result.modules.has(name2))
|
|
9206
|
+
result.modules.set(name2, { source: pkg.source, reason });
|
|
9207
|
+
}
|
|
9208
|
+
}
|
|
9209
|
+
const reached = /* @__PURE__ */ new Set();
|
|
9210
|
+
const reach = (pkg, name2) => {
|
|
9211
|
+
const key = `${pkg.manifest.dir}\0${name2}`;
|
|
9212
|
+
if (reached.has(key) || !targets.has(key)) return;
|
|
9213
|
+
reached.add(key);
|
|
9214
|
+
for (const dependency of pkg.manifest.targets.get(name2)?.dependencies ?? []) {
|
|
9215
|
+
if (dependency.kind === "target") reach(pkg, dependency.name);
|
|
9216
|
+
else {
|
|
9217
|
+
const source = pkg.manifest.packages.get(dependency.package);
|
|
9218
|
+
const nested = source && ("dir" in source ? packages.get(import_node_path14.default.resolve(source.dir)) : packages.get(source.url));
|
|
9219
|
+
if (nested && typeof nested !== "string")
|
|
9220
|
+
for (const root of nested.manifest.products.get(dependency.name) ?? [])
|
|
9221
|
+
reach(nested, root);
|
|
9222
|
+
}
|
|
9223
|
+
}
|
|
9224
|
+
};
|
|
9225
|
+
for (const { product, source } of products) {
|
|
9226
|
+
const pkg = source.kind === "unnamed" ? unnamed().find((candidate) => candidate.manifest.products.has(product)) : packages.get(source.kind === "local" ? import_node_path14.default.resolve(source.dir) : source.url);
|
|
9227
|
+
if (!pkg || typeof pkg === "string" || result.unavailable.has(product)) continue;
|
|
9228
|
+
for (const root of pkg.manifest.products.get(product) ?? []) reach(pkg, root);
|
|
9229
|
+
}
|
|
9230
|
+
result.targets = [...targets.entries()].filter(([key]) => reached.has(key)).map(([, target]) => target);
|
|
9112
9231
|
return result;
|
|
9113
9232
|
}
|
|
9114
9233
|
|
|
@@ -9239,26 +9358,361 @@ async function compileSwiftProject(submit, work, origin, signal) {
|
|
|
9239
9358
|
}
|
|
9240
9359
|
|
|
9241
9360
|
// src/xcode-project.ts
|
|
9242
|
-
var
|
|
9243
|
-
var
|
|
9361
|
+
var import_node_fs15 = __toESM(require("node:fs"), 1);
|
|
9362
|
+
var import_node_path16 = __toESM(require("node:path"), 1);
|
|
9244
9363
|
var import_plist3 = __toESM(require_plist(), 1);
|
|
9245
|
-
|
|
9364
|
+
|
|
9365
|
+
// src/xcode-json-project.ts
|
|
9366
|
+
var import_node_path15 = __toESM(require("node:path"), 1);
|
|
9367
|
+
var import_json5 = __toESM(require("json5"), 1);
|
|
9368
|
+
var isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9369
|
+
var text = (value) => typeof value === "string" ? value : void 0;
|
|
9370
|
+
var items = (value) => Array.isArray(value) ? value : [];
|
|
9371
|
+
var PHASE_ISA = {
|
|
9372
|
+
"compile-sources": "PBXSourcesBuildPhase",
|
|
9373
|
+
resources: "PBXResourcesBuildPhase",
|
|
9374
|
+
frameworks: "PBXFrameworksBuildPhase",
|
|
9375
|
+
headers: "PBXHeadersBuildPhase",
|
|
9376
|
+
copy: "PBXCopyFilesBuildPhase",
|
|
9377
|
+
script: "PBXShellScriptBuildPhase"
|
|
9378
|
+
};
|
|
9379
|
+
function readXcodeJsonProject(xcodeproj, source) {
|
|
9380
|
+
const json = import_json5.default.parse(source);
|
|
9381
|
+
if (!isJsonObject(json)) throw new Error(`${xcodeproj}/project.xcproj is not an object`);
|
|
9382
|
+
const projectDir = import_node_path15.default.dirname(xcodeproj);
|
|
9383
|
+
const objects = {};
|
|
9384
|
+
let next = 0;
|
|
9385
|
+
const add = (entry, id) => {
|
|
9386
|
+
const key = id ?? `XCPROJ${(next++).toString(16).toUpperCase().padStart(18, "0")}`;
|
|
9387
|
+
objects[key] = entry;
|
|
9388
|
+
return key;
|
|
9389
|
+
};
|
|
9390
|
+
const locate = (raw2, groupDir) => {
|
|
9391
|
+
if (raw2.startsWith("<USER:")) return null;
|
|
9392
|
+
const base = /^<([A-Z]+)>\/(.*)$/.exec(raw2);
|
|
9393
|
+
if (base) {
|
|
9394
|
+
if (base[1] === "PROJECT")
|
|
9395
|
+
return { sourceTree: "<absolute>", path: import_node_path15.default.join(projectDir, base[2]) };
|
|
9396
|
+
if (base[1] === "PRODUCTS")
|
|
9397
|
+
return { sourceTree: "BUILT_PRODUCTS_DIR", path: base[2] };
|
|
9398
|
+
return null;
|
|
9399
|
+
}
|
|
9400
|
+
const unescaped = raw2.replaceAll("\\<", "<");
|
|
9401
|
+
if (unescaped.startsWith("/")) return { sourceTree: "<absolute>", path: unescaped };
|
|
9402
|
+
if (unescaped.startsWith("~")) return null;
|
|
9403
|
+
return groupDir === null ? null : { sourceTree: "<absolute>", path: import_node_path15.default.join(groupDir, unescaped) };
|
|
9404
|
+
};
|
|
9405
|
+
const memberships = [];
|
|
9406
|
+
const folders = [];
|
|
9407
|
+
const projectFiles = [];
|
|
9408
|
+
const root = { id: "", name: "", dir: projectDir, parent: null, children: [] };
|
|
9409
|
+
const walk2 = (entries, parent) => entries.flatMap((entry) => {
|
|
9410
|
+
if (!isObject(entry)) return [];
|
|
9411
|
+
const kind = text(entry.kind) ?? "file-reference";
|
|
9412
|
+
const raw2 = text(entry.path) ?? "";
|
|
9413
|
+
const located = raw2 === "" ? null : locate(raw2, parent.dir);
|
|
9414
|
+
const name2 = text(entry.name) ?? import_node_path15.default.basename(raw2);
|
|
9415
|
+
const node = { id: "", name: name2, dir: null, parent, children: [] };
|
|
9416
|
+
if (kind === "group" || kind === "variant-group" || kind === "version-group") {
|
|
9417
|
+
node.dir = raw2 === "" ? parent.dir : located?.sourceTree === "<absolute>" ? located.path : null;
|
|
9418
|
+
const childIds = walk2(items(entry.children), node);
|
|
9419
|
+
node.id = add(
|
|
9420
|
+
kind === "version-group" && located ? {
|
|
9421
|
+
isa: "PBXFileReference",
|
|
9422
|
+
...located,
|
|
9423
|
+
lastKnownFileType: "wrapper.xcdatamodel"
|
|
9424
|
+
} : {
|
|
9425
|
+
isa: kind === "variant-group" ? "PBXVariantGroup" : "PBXGroup",
|
|
9426
|
+
children: childIds,
|
|
9427
|
+
...kind === "variant-group" ? {} : { sourceTree: "<absolute>", path: node.dir ?? "" },
|
|
9428
|
+
name: name2
|
|
9429
|
+
},
|
|
9430
|
+
text(entry.id)
|
|
9431
|
+
);
|
|
9432
|
+
} else if (kind === "folder") {
|
|
9433
|
+
node.id = add(
|
|
9434
|
+
{
|
|
9435
|
+
isa: "PBXFileSystemSynchronizedRootGroup",
|
|
9436
|
+
...located ?? { sourceTree: "SDKROOT", path: raw2 }
|
|
9437
|
+
},
|
|
9438
|
+
text(entry.id)
|
|
9439
|
+
);
|
|
9440
|
+
folders.push({ id: node.id, folder: entry });
|
|
9441
|
+
} else {
|
|
9442
|
+
node.id = add(
|
|
9443
|
+
{
|
|
9444
|
+
isa: "PBXFileReference",
|
|
9445
|
+
...located ?? { sourceTree: "SDKROOT", path: raw2 },
|
|
9446
|
+
name: name2
|
|
9447
|
+
},
|
|
9448
|
+
text(entry.id)
|
|
9449
|
+
);
|
|
9450
|
+
if (located?.sourceTree === "<absolute>" && located.path.endsWith(".xcodeproj"))
|
|
9451
|
+
projectFiles.push(node.id);
|
|
9452
|
+
}
|
|
9453
|
+
parent.children.push(node);
|
|
9454
|
+
for (const membership of items(entry["target-membership"])) {
|
|
9455
|
+
if (kind !== "folder") memberships.push({ refId: node.id, entry: membership });
|
|
9456
|
+
}
|
|
9457
|
+
return [node.id];
|
|
9458
|
+
});
|
|
9459
|
+
const mainGroupChildren = walk2(items(json.files), root);
|
|
9460
|
+
const mainGroup = add({
|
|
9461
|
+
isa: "PBXGroup",
|
|
9462
|
+
children: mainGroupChildren,
|
|
9463
|
+
sourceTree: "<absolute>",
|
|
9464
|
+
path: projectDir
|
|
9465
|
+
});
|
|
9466
|
+
root.id = mainGroup;
|
|
9467
|
+
const lookup = (reference, from = root) => {
|
|
9468
|
+
if (isObject(reference)) {
|
|
9469
|
+
const anchor = lookupNode(reference.anchor, root);
|
|
9470
|
+
return anchor ? lookup(reference["relative-path"], anchor) : void 0;
|
|
9471
|
+
}
|
|
9472
|
+
if (Array.isArray(reference)) {
|
|
9473
|
+
return lookupNode(
|
|
9474
|
+
reference.map(
|
|
9475
|
+
(component) => isObject(component) ? text(component.name) ?? "" : text(component) ?? ""
|
|
9476
|
+
).join("/"),
|
|
9477
|
+
from
|
|
9478
|
+
)?.id;
|
|
9479
|
+
}
|
|
9480
|
+
return lookupNode(reference, from)?.id;
|
|
9481
|
+
};
|
|
9482
|
+
const lookupNode = (reference, from) => {
|
|
9483
|
+
const value = text(reference);
|
|
9484
|
+
if (value === void 0) return void 0;
|
|
9485
|
+
if (value.startsWith("id:")) {
|
|
9486
|
+
const id = value.slice(3);
|
|
9487
|
+
const find = (node2) => node2.id === id ? node2 : node2.children.map(find).find(Boolean);
|
|
9488
|
+
return find(root);
|
|
9489
|
+
}
|
|
9490
|
+
let node = from;
|
|
9491
|
+
for (const component of value.split("/")) {
|
|
9492
|
+
if (!node) return void 0;
|
|
9493
|
+
node = component === "." ? node : component === ".." ? node.parent ?? void 0 : node.children.find((child) => child.name === component);
|
|
9494
|
+
}
|
|
9495
|
+
return node;
|
|
9496
|
+
};
|
|
9497
|
+
const configurations = items(json.configurations).flatMap((entry) => {
|
|
9498
|
+
const name2 = isObject(entry) ? text(entry.name) : text(entry);
|
|
9499
|
+
return name2 ? [{ name: name2, file: isObject(entry) ? entry.file : void 0 }] : [];
|
|
9500
|
+
});
|
|
9501
|
+
const settingsOf = (value) => Object.fromEntries(
|
|
9502
|
+
Object.entries(isObject(value) ? value : {}).flatMap(
|
|
9503
|
+
([key, setting]) => typeof setting === "string" ? [[key, setting]] : Array.isArray(setting) ? [
|
|
9504
|
+
[
|
|
9505
|
+
key,
|
|
9506
|
+
setting.filter((item) => typeof item === "string")
|
|
9507
|
+
]
|
|
9508
|
+
] : []
|
|
9509
|
+
)
|
|
9510
|
+
);
|
|
9511
|
+
const configurationList = (settings, specialized) => add({
|
|
9512
|
+
isa: "XCConfigurationList",
|
|
9513
|
+
defaultConfigurationName: text(json["default-configuration"]) ?? "Debug",
|
|
9514
|
+
buildConfigurations: configurations.map(({ name: name2, file }) => {
|
|
9515
|
+
const base = lookup(specialized.has(name2) ? specialized.get(name2) : file);
|
|
9516
|
+
return add({
|
|
9517
|
+
isa: "XCBuildConfiguration",
|
|
9518
|
+
name: name2,
|
|
9519
|
+
buildSettings: settings,
|
|
9520
|
+
...base ? { baseConfigurationReference: base } : {}
|
|
9521
|
+
});
|
|
9522
|
+
})
|
|
9523
|
+
});
|
|
9524
|
+
const packageIds = /* @__PURE__ */ new Map();
|
|
9525
|
+
for (const entry of items(json.packages)) {
|
|
9526
|
+
if (!isObject(entry)) continue;
|
|
9527
|
+
const repository = text(entry.repository);
|
|
9528
|
+
const local = text(entry.path);
|
|
9529
|
+
const name2 = local !== void 0 ? import_node_path15.default.basename(import_node_path15.default.resolve(import_node_path15.default.dirname(xcodeproj), local)) : import_node_path15.default.basename(repository ?? "").replace(/\.git$/, "");
|
|
9530
|
+
const id = text(entry.kind) === "local" && local !== void 0 ? add({ isa: "XCLocalSwiftPackageReference", relativePath: local }) : add({ isa: "XCRemoteSwiftPackageReference", repositoryURL: repository ?? "" });
|
|
9531
|
+
packageIds.set(name2.toLowerCase(), id);
|
|
9532
|
+
}
|
|
9533
|
+
const productDependency = (entry) => add({
|
|
9534
|
+
isa: "XCSwiftPackageProductDependency",
|
|
9535
|
+
productName: text(entry["product-name"]) ?? "",
|
|
9536
|
+
// xcode finds a product by name across packages when none is named
|
|
9537
|
+
...packageIds.has(text(entry.package)?.toLowerCase() ?? "") ? { package: packageIds.get(text(entry.package).toLowerCase()) } : {}
|
|
9538
|
+
});
|
|
9539
|
+
const proxy = (entry, remote, proxyType) => add({
|
|
9540
|
+
isa: "PBXContainerItemProxy",
|
|
9541
|
+
containerPortal: lookup(entry.project) ?? "",
|
|
9542
|
+
proxyType,
|
|
9543
|
+
remoteGlobalIDString: remote ?? "",
|
|
9544
|
+
remoteInfo: text(entry.target) ?? ""
|
|
9545
|
+
});
|
|
9546
|
+
const phases = /* @__PURE__ */ new Map();
|
|
9547
|
+
const targetIds = /* @__PURE__ */ new Map();
|
|
9548
|
+
const targets = [];
|
|
9549
|
+
for (const entry of items(json.targets)) {
|
|
9550
|
+
if (!isObject(entry)) continue;
|
|
9551
|
+
const name2 = text(entry.name) ?? "";
|
|
9552
|
+
const productType = text(entry["product-type"]);
|
|
9553
|
+
const target = {
|
|
9554
|
+
isa: text(entry.kind) === "aggregate" ? "PBXAggregateTarget" : "PBXNativeTarget",
|
|
9555
|
+
name: name2,
|
|
9556
|
+
productName: name2,
|
|
9557
|
+
productType: productType ? `com.apple.product-type.${productType}` : text(entry["full-product-type"]) ?? "",
|
|
9558
|
+
buildPhases: [],
|
|
9559
|
+
dependencies: [],
|
|
9560
|
+
packageProductDependencies: [],
|
|
9561
|
+
fileSystemSynchronizedGroups: []
|
|
9562
|
+
};
|
|
9563
|
+
const product = lookup(entry.product);
|
|
9564
|
+
if (product) target.productReference = product;
|
|
9565
|
+
const id = add(target, text(entry.id));
|
|
9566
|
+
targetIds.set(name2, id);
|
|
9567
|
+
targets.push({ id, target, entry });
|
|
9568
|
+
for (const phase of items(entry["build-phases"])) {
|
|
9569
|
+
const kind = isObject(phase) ? text(phase.kind) : text(phase);
|
|
9570
|
+
const isa = kind ? PHASE_ISA[kind] : void 0;
|
|
9571
|
+
if (!kind || !isa) continue;
|
|
9572
|
+
const phaseName = isObject(phase) ? text(phase.name) : void 0;
|
|
9573
|
+
const phaseId = add(
|
|
9574
|
+
{ isa, files: [] },
|
|
9575
|
+
isObject(phase) ? text(phase.id) : void 0
|
|
9576
|
+
);
|
|
9577
|
+
target.buildPhases.push(phaseId);
|
|
9578
|
+
phases.set([name2, kind, phaseName].filter(Boolean).join("/"), phaseId);
|
|
9579
|
+
phases.set(`id:${phaseId}`, phaseId);
|
|
9580
|
+
}
|
|
9581
|
+
}
|
|
9582
|
+
const phaseFiles = (reference, targetName) => {
|
|
9583
|
+
const value = text(reference);
|
|
9584
|
+
if (value === void 0) return null;
|
|
9585
|
+
const key = value.startsWith("id:") || !targetName ? value : `${targetName}/${value}`;
|
|
9586
|
+
const phase = objects[phases.get(key) ?? ""];
|
|
9587
|
+
return phase && typeof phase === "object" && !Array.isArray(phase) && Array.isArray(phase.files) ? phase.files : null;
|
|
9588
|
+
};
|
|
9589
|
+
for (const { refId, entry } of memberships) {
|
|
9590
|
+
const files = phaseFiles(isObject(entry) ? entry["build-phase"] : entry);
|
|
9591
|
+
files?.push(add({ isa: "PBXBuildFile", fileRef: refId }));
|
|
9592
|
+
}
|
|
9593
|
+
for (const { target, entry } of targets) {
|
|
9594
|
+
const name2 = text(entry.name) ?? "";
|
|
9595
|
+
target.buildConfigurationList = configurationList(
|
|
9596
|
+
settingsOf(entry["build-settings"]),
|
|
9597
|
+
new Map(
|
|
9598
|
+
items(entry["specialized-configurations"]).flatMap(
|
|
9599
|
+
(configuration) => isObject(configuration) && text(configuration.name) ? [[text(configuration.name), configuration.file]] : []
|
|
9600
|
+
)
|
|
9601
|
+
)
|
|
9602
|
+
);
|
|
9603
|
+
for (const dependency of items(entry.dependencies)) {
|
|
9604
|
+
const kind = isObject(dependency) ? text(dependency.kind) ?? "localTarget" : "localTarget";
|
|
9605
|
+
if (kind === "package" && isObject(dependency)) {
|
|
9606
|
+
;
|
|
9607
|
+
target.dependencies.push(
|
|
9608
|
+
add({ isa: "PBXTargetDependency", productRef: productDependency(dependency) })
|
|
9609
|
+
);
|
|
9610
|
+
} else if (kind === "remoteTarget" && isObject(dependency)) {
|
|
9611
|
+
;
|
|
9612
|
+
target.dependencies.push(
|
|
9613
|
+
add({
|
|
9614
|
+
isa: "PBXTargetDependency",
|
|
9615
|
+
targetProxy: proxy(dependency, text(dependency["target-id"]), "1")
|
|
9616
|
+
})
|
|
9617
|
+
);
|
|
9618
|
+
} else {
|
|
9619
|
+
const local = isObject(dependency) ? text(dependency.target) : text(dependency);
|
|
9620
|
+
const id = local ? targetIds.get(local) : void 0;
|
|
9621
|
+
if (id)
|
|
9622
|
+
target.dependencies.push(
|
|
9623
|
+
add({ isa: "PBXTargetDependency", target: id })
|
|
9624
|
+
);
|
|
9625
|
+
}
|
|
9626
|
+
}
|
|
9627
|
+
for (const member of items(entry["package-product-members"])) {
|
|
9628
|
+
if (!isObject(member)) continue;
|
|
9629
|
+
const dependency = productDependency(member);
|
|
9630
|
+
target.packageProductDependencies.push(dependency);
|
|
9631
|
+
const buildFile = member["build-phase"];
|
|
9632
|
+
phaseFiles(isObject(buildFile) ? buildFile["build-phase"] : buildFile, name2)?.push(
|
|
9633
|
+
add({ isa: "PBXBuildFile", productRef: dependency })
|
|
9634
|
+
);
|
|
9635
|
+
}
|
|
9636
|
+
}
|
|
9637
|
+
for (const imported of items(json["imported-products"])) {
|
|
9638
|
+
if (!isObject(imported)) continue;
|
|
9639
|
+
const reference = add({
|
|
9640
|
+
isa: "PBXReferenceProxy",
|
|
9641
|
+
path: text(imported.name) ?? text(imported.path) ?? "",
|
|
9642
|
+
sourceTree: "BUILT_PRODUCTS_DIR",
|
|
9643
|
+
remoteRef: proxy(imported, text(imported["product-id"]), "2")
|
|
9644
|
+
});
|
|
9645
|
+
for (const membership of items(imported["target-membership"])) {
|
|
9646
|
+
phaseFiles(isObject(membership) ? membership["build-phase"] : membership)?.push(
|
|
9647
|
+
add({ isa: "PBXBuildFile", fileRef: reference })
|
|
9648
|
+
);
|
|
9649
|
+
}
|
|
9650
|
+
}
|
|
9651
|
+
for (const { id, folder } of folders) {
|
|
9652
|
+
const exceptions = [];
|
|
9653
|
+
for (const exception of items(folder["membership-exceptions"])) {
|
|
9654
|
+
if (!isObject(exception)) continue;
|
|
9655
|
+
const target = targetIds.get(text(exception.target) ?? "");
|
|
9656
|
+
if (!target) continue;
|
|
9657
|
+
exceptions.push(
|
|
9658
|
+
add({
|
|
9659
|
+
isa: "PBXFileSystemSynchronizedBuildFileExceptionSet",
|
|
9660
|
+
target,
|
|
9661
|
+
membershipExceptions: [
|
|
9662
|
+
...items(exception.exclusions),
|
|
9663
|
+
...items(exception.inclusions)
|
|
9664
|
+
].flatMap((member) => typeof member === "string" ? [member] : [])
|
|
9665
|
+
})
|
|
9666
|
+
);
|
|
9667
|
+
}
|
|
9668
|
+
const group = objects[id];
|
|
9669
|
+
if (group && typeof group === "object" && !Array.isArray(group))
|
|
9670
|
+
group.exceptions = exceptions;
|
|
9671
|
+
for (const owner of items(folder["target-membership"])) {
|
|
9672
|
+
const target = targets.find(
|
|
9673
|
+
(candidate) => candidate.id === targetIds.get(text(owner) ?? "")
|
|
9674
|
+
);
|
|
9675
|
+
target?.target.fileSystemSynchronizedGroups?.push(id);
|
|
9676
|
+
}
|
|
9677
|
+
}
|
|
9678
|
+
const localizations = isObject(json.localizations) ? json.localizations : {};
|
|
9679
|
+
const project = add({
|
|
9680
|
+
isa: "PBXProject",
|
|
9681
|
+
mainGroup,
|
|
9682
|
+
projectDirPath: "",
|
|
9683
|
+
developmentRegion: text(localizations.development) ?? "en",
|
|
9684
|
+
buildConfigurationList: configurationList(
|
|
9685
|
+
settingsOf(json["build-settings"]),
|
|
9686
|
+
/* @__PURE__ */ new Map()
|
|
9687
|
+
),
|
|
9688
|
+
targets: targets.map((entry) => entry.id),
|
|
9689
|
+
packageReferences: [...packageIds.values()],
|
|
9690
|
+
projectReferences: projectFiles.map((ProjectRef) => ({ ProjectRef }))
|
|
9691
|
+
});
|
|
9692
|
+
return { objects, rootObject: project };
|
|
9693
|
+
}
|
|
9694
|
+
function isJsonObject(value) {
|
|
9695
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9696
|
+
}
|
|
9697
|
+
|
|
9698
|
+
// src/xcode-project.ts
|
|
9699
|
+
function parseOpenStepPlist(text2) {
|
|
9246
9700
|
let i = 0;
|
|
9247
9701
|
const fail = (message) => {
|
|
9248
|
-
const line =
|
|
9702
|
+
const line = text2.slice(0, i).split("\n").length;
|
|
9249
9703
|
throw new Error(`project.pbxproj line ${line}: ${message}`);
|
|
9250
9704
|
};
|
|
9251
9705
|
const skip = () => {
|
|
9252
9706
|
for (; ; ) {
|
|
9253
|
-
const ch =
|
|
9707
|
+
const ch = text2[i];
|
|
9254
9708
|
if (ch === " " || ch === " " || ch === "\n" || ch === "\r") i++;
|
|
9255
|
-
else if (ch === "/" &&
|
|
9256
|
-
const end =
|
|
9709
|
+
else if (ch === "/" && text2[i + 1] === "*") {
|
|
9710
|
+
const end = text2.indexOf("*/", i + 2);
|
|
9257
9711
|
if (end < 0) fail("unterminated comment");
|
|
9258
9712
|
i = end + 2;
|
|
9259
|
-
} else if (ch === "/" &&
|
|
9260
|
-
const end =
|
|
9261
|
-
i = end < 0 ?
|
|
9713
|
+
} else if (ch === "/" && text2[i + 1] === "/") {
|
|
9714
|
+
const end = text2.indexOf("\n", i);
|
|
9715
|
+
i = end < 0 ? text2.length : end + 1;
|
|
9262
9716
|
} else return;
|
|
9263
9717
|
}
|
|
9264
9718
|
};
|
|
@@ -9266,42 +9720,42 @@ function parseOpenStepPlist(text) {
|
|
|
9266
9720
|
i++;
|
|
9267
9721
|
let out = "";
|
|
9268
9722
|
for (; ; ) {
|
|
9269
|
-
const ch =
|
|
9723
|
+
const ch = text2[i++];
|
|
9270
9724
|
if (ch === void 0) fail("unterminated string");
|
|
9271
9725
|
if (ch === '"') return out;
|
|
9272
9726
|
if (ch !== "\\") {
|
|
9273
9727
|
out += ch;
|
|
9274
9728
|
continue;
|
|
9275
9729
|
}
|
|
9276
|
-
const next =
|
|
9730
|
+
const next = text2[i++];
|
|
9277
9731
|
if (next === "n") out += "\n";
|
|
9278
9732
|
else if (next === "t") out += " ";
|
|
9279
9733
|
else if (next === "r") out += "\r";
|
|
9280
9734
|
else if (next === "U") {
|
|
9281
|
-
out += String.fromCharCode(parseInt(
|
|
9735
|
+
out += String.fromCharCode(parseInt(text2.slice(i, i + 4), 16));
|
|
9282
9736
|
i += 4;
|
|
9283
9737
|
} else out += next;
|
|
9284
9738
|
}
|
|
9285
9739
|
};
|
|
9286
9740
|
const value = () => {
|
|
9287
9741
|
skip();
|
|
9288
|
-
const ch =
|
|
9742
|
+
const ch = text2[i];
|
|
9289
9743
|
if (ch === "{") {
|
|
9290
9744
|
i++;
|
|
9291
9745
|
const dict = {};
|
|
9292
9746
|
for (; ; ) {
|
|
9293
9747
|
skip();
|
|
9294
|
-
if (
|
|
9748
|
+
if (text2[i] === "}") {
|
|
9295
9749
|
i++;
|
|
9296
9750
|
return dict;
|
|
9297
9751
|
}
|
|
9298
9752
|
const key = value();
|
|
9299
9753
|
if (typeof key !== "string") fail("dictionary key is not a string");
|
|
9300
9754
|
skip();
|
|
9301
|
-
if (
|
|
9755
|
+
if (text2[i++] !== "=") fail("expected =");
|
|
9302
9756
|
dict[key] = value();
|
|
9303
9757
|
skip();
|
|
9304
|
-
if (
|
|
9758
|
+
if (text2[i++] !== ";") fail("expected ;");
|
|
9305
9759
|
}
|
|
9306
9760
|
}
|
|
9307
9761
|
if (ch === "(") {
|
|
@@ -9309,26 +9763,26 @@ function parseOpenStepPlist(text) {
|
|
|
9309
9763
|
const list2 = [];
|
|
9310
9764
|
for (; ; ) {
|
|
9311
9765
|
skip();
|
|
9312
|
-
if (
|
|
9766
|
+
if (text2[i] === ")") {
|
|
9313
9767
|
i++;
|
|
9314
9768
|
return list2;
|
|
9315
9769
|
}
|
|
9316
9770
|
list2.push(value());
|
|
9317
9771
|
skip();
|
|
9318
|
-
if (
|
|
9319
|
-
else if (
|
|
9772
|
+
if (text2[i] === ",") i++;
|
|
9773
|
+
else if (text2[i] !== ")") fail("expected , or )");
|
|
9320
9774
|
}
|
|
9321
9775
|
}
|
|
9322
9776
|
if (ch === '"') return quoted();
|
|
9323
9777
|
const start = i;
|
|
9324
|
-
while (i <
|
|
9778
|
+
while (i < text2.length && /[A-Za-z0-9_$+/:.\-<>]/.test(text2[i])) i++;
|
|
9325
9779
|
if (i === start) fail(`unexpected ${JSON.stringify(ch ?? "end of file")}`);
|
|
9326
|
-
return
|
|
9780
|
+
return text2.slice(start, i);
|
|
9327
9781
|
};
|
|
9328
|
-
if (
|
|
9782
|
+
if (text2.startsWith("// !$*UTF8*$!")) i = text2.indexOf("\n") + 1;
|
|
9329
9783
|
const root = value();
|
|
9330
9784
|
skip();
|
|
9331
|
-
if (i !==
|
|
9785
|
+
if (i !== text2.length) fail("trailing content");
|
|
9332
9786
|
return root;
|
|
9333
9787
|
}
|
|
9334
9788
|
var isDict = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -9349,28 +9803,28 @@ var CONDITIONS = {
|
|
|
9349
9803
|
variant: "normal"
|
|
9350
9804
|
};
|
|
9351
9805
|
function walkFiles(dir) {
|
|
9352
|
-
if (!
|
|
9806
|
+
if (!import_node_fs15.default.existsSync(dir)) return [];
|
|
9353
9807
|
const out = [];
|
|
9354
|
-
for (const entry of
|
|
9808
|
+
for (const entry of import_node_fs15.default.readdirSync(dir, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
|
|
9355
9809
|
if (entry.name.startsWith(".")) continue;
|
|
9356
|
-
const full =
|
|
9810
|
+
const full = import_node_path16.default.join(dir, entry.name);
|
|
9357
9811
|
if (entry.isDirectory()) out.push(...walkFiles(full));
|
|
9358
9812
|
else if (entry.isFile()) out.push(full);
|
|
9359
9813
|
}
|
|
9360
9814
|
return out;
|
|
9361
9815
|
}
|
|
9362
|
-
var isDirectory = (dir) =>
|
|
9816
|
+
var isDirectory = (dir) => import_node_fs15.default.existsSync(dir) && import_node_fs15.default.statSync(dir).isDirectory();
|
|
9363
9817
|
function readXcconfig(file, seen = /* @__PURE__ */ new Set()) {
|
|
9364
|
-
if (seen.has(file) || !
|
|
9818
|
+
if (seen.has(file) || !import_node_fs15.default.existsSync(file)) return {};
|
|
9365
9819
|
seen.add(file);
|
|
9366
9820
|
const settings = {};
|
|
9367
|
-
for (const raw2 of
|
|
9821
|
+
for (const raw2 of import_node_fs15.default.readFileSync(file, "utf8").split("\n")) {
|
|
9368
9822
|
const line = raw2.replace(/\/\/.*$/, "").trim();
|
|
9369
9823
|
const include = /^#include\??\s+"([^"]+)"/.exec(line);
|
|
9370
9824
|
if (include) {
|
|
9371
9825
|
Object.assign(
|
|
9372
9826
|
settings,
|
|
9373
|
-
readXcconfig(
|
|
9827
|
+
readXcconfig(import_node_path16.default.resolve(import_node_path16.default.dirname(file), include[1]), seen)
|
|
9374
9828
|
);
|
|
9375
9829
|
continue;
|
|
9376
9830
|
}
|
|
@@ -9416,26 +9870,26 @@ function applyOperator(value, operator) {
|
|
|
9416
9870
|
}
|
|
9417
9871
|
throw new Error(`unsupported build setting operator :${operator}`);
|
|
9418
9872
|
}
|
|
9419
|
-
function decodeXml(
|
|
9420
|
-
return
|
|
9873
|
+
function decodeXml(text2) {
|
|
9874
|
+
return text2.replaceAll(""", '"').replaceAll("'", "'").replaceAll("<", "<").replaceAll(">", ">").replaceAll("&", "&");
|
|
9421
9875
|
}
|
|
9422
9876
|
function workspaceReferences(workspace) {
|
|
9423
|
-
const data =
|
|
9424
|
-
if (!
|
|
9877
|
+
const data = import_node_path16.default.join(workspace, "contents.xcworkspacedata");
|
|
9878
|
+
if (!import_node_fs15.default.existsSync(data))
|
|
9425
9879
|
throw new Error(`${workspace} has no contents.xcworkspacedata`);
|
|
9426
|
-
const container =
|
|
9880
|
+
const container = import_node_path16.default.dirname(workspace);
|
|
9427
9881
|
const locate = (location2, base) => {
|
|
9428
9882
|
const colon = location2.indexOf(":");
|
|
9429
9883
|
const kind = location2.slice(0, colon);
|
|
9430
9884
|
const rest = location2.slice(colon + 1);
|
|
9431
|
-
if (kind === "group") return
|
|
9432
|
-
if (kind === "container" || kind === "self") return
|
|
9433
|
-
if (kind === "absolute") return
|
|
9434
|
-
throw new Error(`${
|
|
9885
|
+
if (kind === "group") return import_node_path16.default.resolve(base, rest);
|
|
9886
|
+
if (kind === "container" || kind === "self") return import_node_path16.default.resolve(container, rest);
|
|
9887
|
+
if (kind === "absolute") return import_node_path16.default.resolve(rest);
|
|
9888
|
+
throw new Error(`${import_node_path16.default.basename(workspace)} has an unsupported location ${location2}`);
|
|
9435
9889
|
};
|
|
9436
9890
|
const groups = [container];
|
|
9437
9891
|
const references = [];
|
|
9438
|
-
for (const [, closing, tag, attributes, selfClosing] of
|
|
9892
|
+
for (const [, closing, tag, attributes, selfClosing] of import_node_fs15.default.readFileSync(data, "utf8").matchAll(/<(\/?)(Group|FileRef)\b([^>]*?)(\/?)>/g)) {
|
|
9439
9893
|
if (closing) {
|
|
9440
9894
|
if (tag === "Group") groups.pop();
|
|
9441
9895
|
continue;
|
|
@@ -9449,15 +9903,24 @@ function workspaceReferences(workspace) {
|
|
|
9449
9903
|
return references;
|
|
9450
9904
|
}
|
|
9451
9905
|
var loaded = /* @__PURE__ */ new Map();
|
|
9906
|
+
function xcodeProjectFile(xcodeproj) {
|
|
9907
|
+
for (const name2 of ["project.pbxproj", "project.xcproj"]) {
|
|
9908
|
+
const file = import_node_path16.default.join(xcodeproj, name2);
|
|
9909
|
+
if (import_node_fs15.default.existsSync(file)) return file;
|
|
9910
|
+
}
|
|
9911
|
+
return null;
|
|
9912
|
+
}
|
|
9452
9913
|
function loadProject(xcodeproj) {
|
|
9453
|
-
const
|
|
9454
|
-
if (!
|
|
9455
|
-
|
|
9456
|
-
const
|
|
9914
|
+
const projectFile = xcodeProjectFile(xcodeproj);
|
|
9915
|
+
if (!projectFile)
|
|
9916
|
+
throw new Error(`${xcodeproj} has no project.pbxproj or project.xcproj`);
|
|
9917
|
+
const mtimeMs = import_node_fs15.default.statSync(projectFile).mtimeMs;
|
|
9918
|
+
const cached3 = loaded.get(projectFile);
|
|
9457
9919
|
if (cached3?.mtimeMs === mtimeMs) return cached3.project;
|
|
9458
|
-
const
|
|
9920
|
+
const source = import_node_fs15.default.readFileSync(projectFile, "utf8");
|
|
9921
|
+
const root = projectFile.endsWith(".xcproj") ? readXcodeJsonProject(xcodeproj, source) : parseOpenStepPlist(source);
|
|
9459
9922
|
if (!isDict(root) || !isDict(root.objects)) {
|
|
9460
|
-
throw new Error(`${
|
|
9923
|
+
throw new Error(`${projectFile} has no objects table`);
|
|
9461
9924
|
}
|
|
9462
9925
|
const objects = root.objects;
|
|
9463
9926
|
const object = (id) => {
|
|
@@ -9466,10 +9929,10 @@ function loadProject(xcodeproj) {
|
|
|
9466
9929
|
};
|
|
9467
9930
|
const project = object(str(root.rootObject));
|
|
9468
9931
|
if (!project || project.isa !== "PBXProject") {
|
|
9469
|
-
throw new Error(`${
|
|
9932
|
+
throw new Error(`${projectFile} has no PBXProject root`);
|
|
9470
9933
|
}
|
|
9471
|
-
const projectDir =
|
|
9472
|
-
|
|
9934
|
+
const projectDir = import_node_fs15.default.realpathSync(
|
|
9935
|
+
import_node_path16.default.resolve(import_node_path16.default.dirname(xcodeproj), str(project.projectDirPath) ?? "")
|
|
9473
9936
|
);
|
|
9474
9937
|
const parent = /* @__PURE__ */ new Map();
|
|
9475
9938
|
for (const [id, entry] of Object.entries(objects)) {
|
|
@@ -9487,18 +9950,26 @@ function loadProject(xcodeproj) {
|
|
|
9487
9950
|
const own = str(entry.path) ?? "";
|
|
9488
9951
|
const tree = str(entry.sourceTree) ?? "<group>";
|
|
9489
9952
|
if (tree === "<absolute>") result2 = own;
|
|
9490
|
-
else if (tree === "SOURCE_ROOT") result2 =
|
|
9953
|
+
else if (tree === "SOURCE_ROOT") result2 = import_node_path16.default.join(projectDir, own);
|
|
9491
9954
|
else if (tree === "<group>") {
|
|
9492
9955
|
const up = parent.get(id);
|
|
9493
9956
|
const base = up ? resolvePath(up) : projectDir;
|
|
9494
|
-
result2 = base === null ? null :
|
|
9957
|
+
result2 = base === null ? null : import_node_path16.default.join(base, own);
|
|
9495
9958
|
}
|
|
9496
9959
|
}
|
|
9497
9960
|
resolvedPaths.set(id, result2);
|
|
9498
9961
|
return result2;
|
|
9499
9962
|
};
|
|
9500
|
-
const result = {
|
|
9501
|
-
|
|
9963
|
+
const result = {
|
|
9964
|
+
xcodeproj,
|
|
9965
|
+
projectFile,
|
|
9966
|
+
objects,
|
|
9967
|
+
project,
|
|
9968
|
+
projectDir,
|
|
9969
|
+
object,
|
|
9970
|
+
resolvePath
|
|
9971
|
+
};
|
|
9972
|
+
loaded.set(projectFile, { mtimeMs, project: result });
|
|
9502
9973
|
return result;
|
|
9503
9974
|
}
|
|
9504
9975
|
function targetSettings(ref, builtins) {
|
|
@@ -9583,7 +10054,7 @@ function targetMembers(ref) {
|
|
|
9583
10054
|
const addResource = (file) => {
|
|
9584
10055
|
if (isDirectory(file)) {
|
|
9585
10056
|
for (const inner of walkFiles(file)) resources.add(inner);
|
|
9586
|
-
} else if (
|
|
10057
|
+
} else if (import_node_fs15.default.existsSync(file)) resources.add(file);
|
|
9587
10058
|
};
|
|
9588
10059
|
const fileRefPaths = (refId) => {
|
|
9589
10060
|
const entry = project.object(refId);
|
|
@@ -9604,7 +10075,7 @@ function targetMembers(ref) {
|
|
|
9604
10075
|
for (const buildFileId of list(phase.files)) {
|
|
9605
10076
|
for (const file of fileRefPaths(str(project.object(buildFileId)?.fileRef) ?? "")) {
|
|
9606
10077
|
if (phase.isa === "PBXSourcesBuildPhase") {
|
|
9607
|
-
if (!
|
|
10078
|
+
if (!import_node_fs15.default.existsSync(file)) continue;
|
|
9608
10079
|
allSources.add(file);
|
|
9609
10080
|
if (file.endsWith(".swift")) sources.add(file);
|
|
9610
10081
|
} else if (phase.isa === "PBXResourcesBuildPhase") addResource(file);
|
|
@@ -9612,7 +10083,7 @@ function targetMembers(ref) {
|
|
|
9612
10083
|
}
|
|
9613
10084
|
}
|
|
9614
10085
|
const addSynchronized = (folder, relative2) => {
|
|
9615
|
-
const file =
|
|
10086
|
+
const file = import_node_path16.default.join(folder, relative2);
|
|
9616
10087
|
if (NEVER_MEMBER.test(relative2)) return;
|
|
9617
10088
|
if (file.endsWith(".swift")) {
|
|
9618
10089
|
if (!relative2.split("/").some((segment) => BUNDLE_DIR.test(segment))) {
|
|
@@ -9637,7 +10108,7 @@ function targetMembers(ref) {
|
|
|
9637
10108
|
}
|
|
9638
10109
|
if (owned.has(groupId)) {
|
|
9639
10110
|
for (const file of walkFiles(folder)) {
|
|
9640
|
-
const relative2 =
|
|
10111
|
+
const relative2 = import_node_path16.default.relative(folder, file).split(import_node_path16.default.sep).join("/");
|
|
9641
10112
|
if ([...exceptions].some(
|
|
9642
10113
|
(exception) => relative2 === exception || relative2.startsWith(`${exception}/`)
|
|
9643
10114
|
))
|
|
@@ -9646,14 +10117,14 @@ function targetMembers(ref) {
|
|
|
9646
10117
|
}
|
|
9647
10118
|
} else {
|
|
9648
10119
|
for (const relative2 of exceptions) {
|
|
9649
|
-
const file =
|
|
10120
|
+
const file = import_node_path16.default.join(folder, relative2);
|
|
9650
10121
|
if (isDirectory(file)) {
|
|
9651
10122
|
for (const inner of walkFiles(file))
|
|
9652
10123
|
addSynchronized(
|
|
9653
10124
|
folder,
|
|
9654
|
-
|
|
10125
|
+
import_node_path16.default.relative(folder, inner).split(import_node_path16.default.sep).join("/")
|
|
9655
10126
|
);
|
|
9656
|
-
} else if (
|
|
10127
|
+
} else if (import_node_fs15.default.existsSync(file)) addSynchronized(folder, relative2);
|
|
9657
10128
|
}
|
|
9658
10129
|
}
|
|
9659
10130
|
}
|
|
@@ -9666,8 +10137,8 @@ function targetMembers(ref) {
|
|
|
9666
10137
|
function commonAncestor(dirs) {
|
|
9667
10138
|
let common = dirs[0];
|
|
9668
10139
|
for (const dir of dirs) {
|
|
9669
|
-
while (common !==
|
|
9670
|
-
common =
|
|
10140
|
+
while (common !== import_node_path16.default.dirname(common) && import_node_path16.default.relative(common, dir).startsWith(".."))
|
|
10141
|
+
common = import_node_path16.default.dirname(common);
|
|
9671
10142
|
}
|
|
9672
10143
|
return common;
|
|
9673
10144
|
}
|
|
@@ -9676,9 +10147,9 @@ function workspaceProjects(xcodeprojOrWorkspace) {
|
|
|
9676
10147
|
const projects2 = [];
|
|
9677
10148
|
const projectAt = /* @__PURE__ */ new Map();
|
|
9678
10149
|
const addProject = (xcodeproj) => {
|
|
9679
|
-
const key =
|
|
9680
|
-
if (projectAt.has(key) || key.split(
|
|
9681
|
-
if (!
|
|
10150
|
+
const key = import_node_path16.default.resolve(xcodeproj);
|
|
10151
|
+
if (projectAt.has(key) || key.split(import_node_path16.default.sep).includes("Pods")) return;
|
|
10152
|
+
if (!xcodeProjectFile(key)) return;
|
|
9682
10153
|
const project = loadProject(key);
|
|
9683
10154
|
projectAt.set(key, project);
|
|
9684
10155
|
projects2.push(project);
|
|
@@ -9694,21 +10165,29 @@ function workspaceProjects(xcodeprojOrWorkspace) {
|
|
|
9694
10165
|
for (const reference of listed)
|
|
9695
10166
|
if (reference.endsWith(".xcodeproj")) addProject(reference);
|
|
9696
10167
|
if (projects2.length === 0) {
|
|
9697
|
-
throw new Error(`${
|
|
10168
|
+
throw new Error(`${import_node_path16.default.basename(xcodeprojOrWorkspace)} lists no Xcode project`);
|
|
9698
10169
|
}
|
|
9699
10170
|
return { listed, projects: projects2, projectAt };
|
|
9700
10171
|
}
|
|
9701
|
-
var
|
|
9702
|
-
|
|
9703
|
-
|
|
9704
|
-
|
|
10172
|
+
var targetRefs = /* @__PURE__ */ new WeakMap();
|
|
10173
|
+
function nativeTargets(project) {
|
|
10174
|
+
let refs = targetRefs.get(project);
|
|
10175
|
+
if (!refs) {
|
|
10176
|
+
refs = list(project.project.targets).flatMap((id) => {
|
|
10177
|
+
const target = project.object(id);
|
|
10178
|
+
return target?.isa === "PBXNativeTarget" ? [{ project, id, target }] : [];
|
|
10179
|
+
});
|
|
10180
|
+
targetRefs.set(project, refs);
|
|
10181
|
+
}
|
|
10182
|
+
return refs;
|
|
10183
|
+
}
|
|
9705
10184
|
function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
9706
10185
|
const workspace = xcodeprojOrWorkspace.endsWith(".xcworkspace") ? xcodeprojOrWorkspace : null;
|
|
9707
10186
|
const { listed, projects: projects2, projectAt } = workspaceProjects(xcodeprojOrWorkspace);
|
|
9708
10187
|
const allTargets = projects2.flatMap(nativeTargets);
|
|
9709
10188
|
const appTargets = allTargets.filter((ref) => ref.target.productType === APPLICATION);
|
|
9710
10189
|
const appTargetNames = appTargets.map((ref) => str(ref.target.name) ?? ref.id);
|
|
9711
|
-
const container =
|
|
10190
|
+
const container = import_node_path16.default.basename(xcodeprojOrWorkspace);
|
|
9712
10191
|
const named = targetName ? appTargets.filter((ref) => ref.target.name === targetName) : appTargets;
|
|
9713
10192
|
if (named.length !== 1) {
|
|
9714
10193
|
throw new Error(
|
|
@@ -9720,14 +10199,14 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
9720
10199
|
for (const ref of allTargets) {
|
|
9721
10200
|
const product = ref.project.object(str(ref.target.productReference));
|
|
9722
10201
|
const file = str(product?.path);
|
|
9723
|
-
if (file && !byProduct.has(
|
|
9724
|
-
byProduct.set(
|
|
10202
|
+
if (file && !byProduct.has(import_node_path16.default.basename(file)))
|
|
10203
|
+
byProduct.set(import_node_path16.default.basename(file), ref);
|
|
9725
10204
|
}
|
|
9726
10205
|
const proxied = (project, proxyId) => {
|
|
9727
10206
|
const proxy = project.object(proxyId);
|
|
9728
10207
|
if (proxy?.isa !== "PBXContainerItemProxy") return void 0;
|
|
9729
10208
|
const portal = str(proxy.containerPortal);
|
|
9730
|
-
const owner = project.object(portal)?.isa === "PBXProject" ? project : projectAt.get(
|
|
10209
|
+
const owner = project.object(portal)?.isa === "PBXProject" ? project : projectAt.get(import_node_path16.default.resolve(project.resolvePath(portal ?? "") ?? ""));
|
|
9731
10210
|
const remote = str(proxy.remoteGlobalIDString);
|
|
9732
10211
|
if (!owner || !remote) return void 0;
|
|
9733
10212
|
return nativeTargets(owner).find(
|
|
@@ -9748,7 +10227,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
9748
10227
|
if (phase?.isa !== "PBXFrameworksBuildPhase") continue;
|
|
9749
10228
|
for (const buildFileId of list(phase.files)) {
|
|
9750
10229
|
const file = project.object(str(project.object(buildFileId)?.fileRef));
|
|
9751
|
-
const resolved = file?.isa === "PBXReferenceProxy" ? proxied(project, str(file.remoteRef)) : file && str(file.sourceTree) === "BUILT_PRODUCTS_DIR" ? byProduct.get(
|
|
10230
|
+
const resolved = file?.isa === "PBXReferenceProxy" ? proxied(project, str(file.remoteRef)) : file && str(file.sourceTree) === "BUILT_PRODUCTS_DIR" ? byProduct.get(import_node_path16.default.basename(str(file.path) ?? "")) : void 0;
|
|
9752
10231
|
if (resolved) found.push(resolved);
|
|
9753
10232
|
}
|
|
9754
10233
|
}
|
|
@@ -9769,7 +10248,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
9769
10248
|
const name2 = str(ref.target.name) ?? ref.id;
|
|
9770
10249
|
const { get: settings2, keys } = targetSettings(ref, {
|
|
9771
10250
|
TARGET_NAME: name2,
|
|
9772
|
-
PROJECT_NAME:
|
|
10251
|
+
PROJECT_NAME: import_node_path16.default.basename(ref.project.xcodeproj, ".xcodeproj"),
|
|
9773
10252
|
SRCROOT: ref.project.projectDir,
|
|
9774
10253
|
SOURCE_ROOT: ref.project.projectDir,
|
|
9775
10254
|
PROJECT_DIR: ref.project.projectDir,
|
|
@@ -9800,8 +10279,8 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
9800
10279
|
}
|
|
9801
10280
|
return value;
|
|
9802
10281
|
};
|
|
9803
|
-
const infoPlistFile = settings("INFOPLIST_FILE") ?
|
|
9804
|
-
const sourceInfo = infoPlistFile ? import_plist3.default.parse(
|
|
10282
|
+
const infoPlistFile = settings("INFOPLIST_FILE") ? import_node_path16.default.resolve(app.project.projectDir, settings("INFOPLIST_FILE")) : null;
|
|
10283
|
+
const sourceInfo = infoPlistFile ? import_plist3.default.parse(import_node_fs15.default.readFileSync(infoPlistFile, "utf8")) : {};
|
|
9805
10284
|
if (!sourceInfo || typeof sourceInfo !== "object" || Array.isArray(sourceInfo) || sourceInfo instanceof Date || Buffer.isBuffer(sourceInfo)) {
|
|
9806
10285
|
throw new Error(`${module2.name} Info.plist must contain a dictionary`);
|
|
9807
10286
|
}
|
|
@@ -9819,34 +10298,17 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
9819
10298
|
};
|
|
9820
10299
|
}
|
|
9821
10300
|
const localPackageDirs = [
|
|
9822
|
-
...listed.filter((reference) =>
|
|
10301
|
+
...listed.filter((reference) => import_node_fs15.default.existsSync(import_node_path16.default.join(reference, "Package.swift"))),
|
|
9823
10302
|
...projects2.flatMap(
|
|
9824
10303
|
(project) => Object.entries(project.objects).flatMap(([id, entry]) => {
|
|
9825
10304
|
if (!isDict(entry)) return [];
|
|
9826
|
-
const candidate = entry.isa === "XCLocalSwiftPackageReference" ?
|
|
9827
|
-
return candidate &&
|
|
10305
|
+
const candidate = entry.isa === "XCLocalSwiftPackageReference" ? import_node_path16.default.resolve(project.projectDir, str(entry.relativePath) ?? "") : entry.isa === "PBXFileReference" ? project.resolvePath(id) : null;
|
|
10306
|
+
return candidate && import_node_fs15.default.existsSync(import_node_path16.default.join(candidate, "Package.swift")) ? [candidate] : [];
|
|
9828
10307
|
})
|
|
9829
10308
|
)
|
|
9830
10309
|
];
|
|
9831
|
-
const
|
|
9832
|
-
const
|
|
9833
|
-
const cached3 = graphs.get(dir);
|
|
9834
|
-
if (cached3) return cached3;
|
|
9835
|
-
const graph = swiftManifestGraph(
|
|
9836
|
-
import_node_fs14.default.readFileSync(import_node_path14.default.join(dir, "Package.swift"), "utf8")
|
|
9837
|
-
);
|
|
9838
|
-
graphs.set(dir, graph);
|
|
9839
|
-
return graph;
|
|
9840
|
-
};
|
|
9841
|
-
const localProducts = /* @__PURE__ */ new Map();
|
|
9842
|
-
for (const dir of localPackageDirs) {
|
|
9843
|
-
for (const product of graphOf(dir).products.keys()) {
|
|
9844
|
-
if (!localProducts.has(product)) localProducts.set(product, dir);
|
|
9845
|
-
}
|
|
9846
|
-
}
|
|
9847
|
-
const localPackages = /* @__PURE__ */ new Set();
|
|
9848
|
-
const remoteProducts = [];
|
|
9849
|
-
const unresolvedProducts = [];
|
|
10310
|
+
const linkedProducts = [];
|
|
10311
|
+
const binaryFrameworks = /* @__PURE__ */ new Set();
|
|
9850
10312
|
for (const { project, target } of order) {
|
|
9851
10313
|
const productDependencies = [
|
|
9852
10314
|
...list(target.packageProductDependencies),
|
|
@@ -9858,45 +10320,37 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
9858
10320
|
for (const dependencyId of productDependencies) {
|
|
9859
10321
|
const dependency = project.object(dependencyId);
|
|
9860
10322
|
const product = str(dependency?.productName)?.replace(/^plugin:/, "");
|
|
9861
|
-
if (!dependency || !product)
|
|
9862
|
-
const reference = project.object(str(dependency.package));
|
|
9863
|
-
if (reference?.isa === "XCRemoteSwiftPackageReference") {
|
|
9864
|
-
if (!remoteProducts.some((entry) => entry.product === product))
|
|
9865
|
-
remoteProducts.push({
|
|
9866
|
-
product,
|
|
9867
|
-
repositoryURL: str(reference.repositoryURL) ?? ""
|
|
9868
|
-
});
|
|
9869
|
-
} else if (reference?.isa === "XCLocalSwiftPackageReference") {
|
|
9870
|
-
localPackages.add(
|
|
9871
|
-
import_node_path14.default.resolve(project.projectDir, str(reference.relativePath) ?? "")
|
|
9872
|
-
);
|
|
9873
|
-
} else if (localProducts.has(product)) {
|
|
9874
|
-
localPackages.add(localProducts.get(product));
|
|
9875
|
-
} else if (!unresolvedProducts.includes(product)) unresolvedProducts.push(product);
|
|
9876
|
-
}
|
|
9877
|
-
}
|
|
9878
|
-
const pending = [...localPackages];
|
|
9879
|
-
while (pending.length > 0) {
|
|
9880
|
-
const dir = pending.pop();
|
|
9881
|
-
const graph = graphOf(dir);
|
|
9882
|
-
for (const relative2 of graph.packagePaths) {
|
|
9883
|
-
const next = import_node_path14.default.resolve(dir, relative2);
|
|
9884
|
-
if (localPackages.has(next) || !import_node_fs14.default.existsSync(import_node_path14.default.join(next, "Package.swift")))
|
|
10323
|
+
if (!dependency || !product || linkedProducts.some((entry) => entry.product === product))
|
|
9885
10324
|
continue;
|
|
9886
|
-
|
|
9887
|
-
|
|
10325
|
+
const reference = project.object(str(dependency.package));
|
|
10326
|
+
linkedProducts.push({
|
|
10327
|
+
product,
|
|
10328
|
+
source: reference?.isa === "XCRemoteSwiftPackageReference" ? { kind: "remote", url: str(reference.repositoryURL) ?? "" } : reference?.isa === "XCLocalSwiftPackageReference" ? {
|
|
10329
|
+
kind: "local",
|
|
10330
|
+
dir: import_node_path16.default.resolve(
|
|
10331
|
+
project.projectDir,
|
|
10332
|
+
str(reference.relativePath) ?? ""
|
|
10333
|
+
)
|
|
10334
|
+
} : { kind: "unnamed" }
|
|
10335
|
+
});
|
|
9888
10336
|
}
|
|
9889
|
-
for (const
|
|
9890
|
-
|
|
9891
|
-
|
|
9892
|
-
|
|
9893
|
-
|
|
9894
|
-
|
|
10337
|
+
for (const phaseId of list(target.buildPhases)) {
|
|
10338
|
+
const phase = project.object(phaseId);
|
|
10339
|
+
if (phase?.isa !== "PBXFrameworksBuildPhase") continue;
|
|
10340
|
+
for (const buildFileId of list(phase.files)) {
|
|
10341
|
+
const fileId = str(project.object(buildFileId)?.fileRef);
|
|
10342
|
+
const file = project.object(fileId);
|
|
10343
|
+
const tree = str(file?.sourceTree);
|
|
10344
|
+
const name2 = /([^/]+)\.(xc)?framework$/.exec(str(file?.path) ?? "")?.[1];
|
|
10345
|
+
if (file?.isa !== "PBXFileReference" || !name2) continue;
|
|
10346
|
+
if (tree === "BUILT_PRODUCTS_DIR" || tree === "SDKROOT" || tree === "DEVELOPER_DIR")
|
|
10347
|
+
continue;
|
|
10348
|
+
binaryFrameworks.add(name2);
|
|
9895
10349
|
}
|
|
9896
10350
|
}
|
|
9897
10351
|
}
|
|
9898
|
-
const resolvedFile =
|
|
9899
|
-
workspace ??
|
|
10352
|
+
const resolvedFile = import_node_path16.default.join(
|
|
10353
|
+
workspace ?? import_node_path16.default.join(xcodeprojOrWorkspace, "project.xcworkspace"),
|
|
9900
10354
|
"xcshareddata",
|
|
9901
10355
|
"swiftpm",
|
|
9902
10356
|
"Package.resolved"
|
|
@@ -9906,19 +10360,24 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
9906
10360
|
...module2,
|
|
9907
10361
|
rootDir: commonAncestor(
|
|
9908
10362
|
[
|
|
9909
|
-
workspace ?
|
|
10363
|
+
workspace ? import_node_path16.default.dirname(workspace) : app.project.projectDir,
|
|
9910
10364
|
...used.map((project) => project.projectDir),
|
|
9911
|
-
...
|
|
9912
|
-
|
|
10365
|
+
...localPackageDirs,
|
|
10366
|
+
...linkedProducts.flatMap(
|
|
10367
|
+
({ source }) => source.kind === "local" && import_node_fs15.default.existsSync(source.dir) ? [source.dir] : []
|
|
10368
|
+
)
|
|
10369
|
+
].map((dir) => import_node_fs15.default.realpathSync(dir))
|
|
9913
10370
|
),
|
|
9914
|
-
|
|
10371
|
+
projectFiles: [...new Set(used.map((project) => project.projectFile))].sort(),
|
|
9915
10372
|
infoPlist: import_plist3.default.build(info),
|
|
9916
10373
|
infoPlistFile,
|
|
9917
10374
|
frameworks,
|
|
9918
|
-
|
|
9919
|
-
|
|
9920
|
-
|
|
9921
|
-
|
|
10375
|
+
linkedProducts,
|
|
10376
|
+
localPackageDirs: [
|
|
10377
|
+
...new Set(localPackageDirs.map((dir) => import_node_fs15.default.realpathSync(dir)))
|
|
10378
|
+
].sort(),
|
|
10379
|
+
binaryFrameworks: [...binaryFrameworks].sort(),
|
|
10380
|
+
packageResolved: import_node_fs15.default.existsSync(resolvedFile) ? resolvedFile : null,
|
|
9922
10381
|
appTargets: appTargetNames
|
|
9923
10382
|
};
|
|
9924
10383
|
}
|
|
@@ -9938,17 +10397,17 @@ var SKIP_SOURCE_DIRS = /* @__PURE__ */ new Set([
|
|
|
9938
10397
|
var NATIVE_DESCRIPTOR = ".one-native-source.json";
|
|
9939
10398
|
var NATIVE_GLUE = ".one-native-source.swift.txt";
|
|
9940
10399
|
function swiftPackageId(packagePath) {
|
|
9941
|
-
return
|
|
10400
|
+
return import_node_path17.default.basename(packagePath).replace(/[^A-Za-z0-9_]/g, "_").replace(/^(\d)/, "_$1");
|
|
9942
10401
|
}
|
|
9943
10402
|
function nativeSourceDescriptor(packagePath) {
|
|
9944
|
-
packagePath =
|
|
9945
|
-
const file =
|
|
9946
|
-
if (!
|
|
10403
|
+
packagePath = import_node_fs16.default.realpathSync(packagePath);
|
|
10404
|
+
const file = import_node_path17.default.join(packagePath, NATIVE_DESCRIPTOR);
|
|
10405
|
+
if (!import_node_fs16.default.existsSync(file)) return null;
|
|
9947
10406
|
const value = JSON.parse(
|
|
9948
10407
|
readPackageFile(packagePath, file, MAX_SWIFT_COMPILE_SOURCE_BYTES).toString("utf8")
|
|
9949
10408
|
);
|
|
9950
10409
|
const invalid = () => new Error(`${file}: invalid One native source descriptor; run one typegen`);
|
|
9951
|
-
if (!value || typeof value !== "object" || Reflect.get(value, "generatedBy") !== "one typegen" || !
|
|
10410
|
+
if (!value || typeof value !== "object" || Reflect.get(value, "generatedBy") !== "one typegen" || !import_node_fs16.default.existsSync(import_node_path17.default.join(packagePath, NATIVE_GLUE))) {
|
|
9952
10411
|
throw invalid();
|
|
9953
10412
|
}
|
|
9954
10413
|
if (!isSwiftNativeModules(value) || value.packageId !== swiftPackageId(packagePath)) {
|
|
@@ -9958,7 +10417,7 @@ function nativeSourceDescriptor(packagePath) {
|
|
|
9958
10417
|
}
|
|
9959
10418
|
var projects = /* @__PURE__ */ new Map();
|
|
9960
10419
|
function projectFor(packagePath, hosted) {
|
|
9961
|
-
packagePath =
|
|
10420
|
+
packagePath = import_node_fs16.default.realpathSync(packagePath);
|
|
9962
10421
|
const existing = projects.get(packagePath);
|
|
9963
10422
|
if (existing) {
|
|
9964
10423
|
if (hosted && !existing.hosted) {
|
|
@@ -9979,45 +10438,50 @@ function projectFor(packagePath, hosted) {
|
|
|
9979
10438
|
return created;
|
|
9980
10439
|
}
|
|
9981
10440
|
var xcodeProjects = /* @__PURE__ */ new Map();
|
|
9982
|
-
function
|
|
9983
|
-
|
|
10441
|
+
function swiftPackages(entry, app) {
|
|
10442
|
+
const stamp = (file) => file && import_node_fs16.default.existsSync(file) ? import_node_fs16.default.statSync(file).mtimeMs : 0;
|
|
9984
10443
|
const key = JSON.stringify([
|
|
9985
|
-
app.
|
|
10444
|
+
app.linkedProducts,
|
|
9986
10445
|
app.packageResolved,
|
|
9987
|
-
|
|
10446
|
+
stamp(app.packageResolved),
|
|
10447
|
+
app.localPackageDirs.map((dir) => stamp(import_node_path17.default.join(dir, "Package.swift"))),
|
|
10448
|
+
app.linkedProducts.map(
|
|
10449
|
+
({ source }) => source.kind === "local" ? stamp(import_node_path17.default.join(source.dir, "Package.swift")) : 0
|
|
10450
|
+
)
|
|
9988
10451
|
]);
|
|
9989
|
-
if (entry.
|
|
9990
|
-
entry.
|
|
10452
|
+
if (entry.packages?.key !== key) {
|
|
10453
|
+
entry.packages = {
|
|
9991
10454
|
key,
|
|
9992
|
-
packages:
|
|
9993
|
-
app.rootDir,
|
|
9994
|
-
app.packageResolved,
|
|
9995
|
-
app.
|
|
9996
|
-
|
|
9997
|
-
|
|
10455
|
+
packages: resolveSwiftPackages({
|
|
10456
|
+
rootDir: app.rootDir,
|
|
10457
|
+
resolved: app.packageResolved,
|
|
10458
|
+
products: app.linkedProducts,
|
|
10459
|
+
localDirs: app.localPackageDirs,
|
|
10460
|
+
provided: entry.provided
|
|
10461
|
+
})
|
|
9998
10462
|
};
|
|
9999
10463
|
}
|
|
10000
|
-
return entry.
|
|
10464
|
+
return entry.packages.packages;
|
|
10001
10465
|
}
|
|
10002
10466
|
var XCODE_APP_DIR = "__app__";
|
|
10003
10467
|
var XCODE_FRAMEWORKS_DIR = "__frameworks__";
|
|
10004
10468
|
var XCODE_PACKAGES_DIR = "__packages__";
|
|
10005
|
-
var CHECKOUTS_PREFIX = `${REMOTE_CHECKOUTS.split(
|
|
10469
|
+
var CHECKOUTS_PREFIX = `${REMOTE_CHECKOUTS.split(import_node_path17.default.sep).join(import_node_path17.default.posix.sep)}/`;
|
|
10006
10470
|
function xcodeInputKey(layout, file, relative2) {
|
|
10007
10471
|
const owner = layout.targetDirs.get(file);
|
|
10008
|
-
if (owner) return
|
|
10009
|
-
return relative2.startsWith(CHECKOUTS_PREFIX) ?
|
|
10472
|
+
if (owner) return import_node_path17.default.posix.join(owner, relative2);
|
|
10473
|
+
return relative2.startsWith(CHECKOUTS_PREFIX) ? import_node_path17.default.posix.join(XCODE_PACKAGES_DIR, relative2.slice(CHECKOUTS_PREFIX.length)) : relative2;
|
|
10010
10474
|
}
|
|
10011
10475
|
function xcodeLayout(root) {
|
|
10012
10476
|
const registered = xcodeProjects.get(root);
|
|
10013
10477
|
if (!registered) return null;
|
|
10014
10478
|
const app = readXcodeAppTarget(registered.xcodeproj, registered.target);
|
|
10015
|
-
const files = /* @__PURE__ */ new Set([...app.
|
|
10479
|
+
const files = /* @__PURE__ */ new Set([...app.projectFiles, ...app.sources, ...app.resources]);
|
|
10016
10480
|
if (app.infoPlistFile) files.add(app.infoPlistFile);
|
|
10017
10481
|
const targetDirs = new Map(app.sources.map((file) => [file, XCODE_APP_DIR]));
|
|
10018
10482
|
const targets = [];
|
|
10019
10483
|
for (const framework of app.frameworks) {
|
|
10020
|
-
const dir =
|
|
10484
|
+
const dir = import_node_path17.default.posix.join(XCODE_FRAMEWORKS_DIR, framework.moduleName);
|
|
10021
10485
|
for (const file of framework.sources) {
|
|
10022
10486
|
if (targetDirs.has(file)) continue;
|
|
10023
10487
|
targetDirs.set(file, dir);
|
|
@@ -10028,44 +10492,35 @@ function xcodeLayout(root) {
|
|
|
10028
10492
|
path: dir,
|
|
10029
10493
|
executable: false,
|
|
10030
10494
|
resources: false,
|
|
10495
|
+
exclude: [],
|
|
10031
10496
|
languageMode: framework.languageMode,
|
|
10032
10497
|
mainActorIsolation: framework.mainActorIsolation
|
|
10033
10498
|
});
|
|
10034
10499
|
}
|
|
10035
|
-
|
|
10036
|
-
|
|
10037
|
-
|
|
10038
|
-
|
|
10039
|
-
|
|
10040
|
-
const declared = swiftManifestTargets(manifest).filter((target) => !target.executable);
|
|
10041
|
-
const all = declared.flatMap(
|
|
10042
|
-
(target) => sourceTreeFiles(import_node_path15.default.join(dir, target.path), root).map(
|
|
10043
|
-
(file) => import_node_path15.default.relative(dir, file).split(import_node_path15.default.sep).join(import_node_path15.default.posix.sep)
|
|
10044
|
-
)
|
|
10500
|
+
const packages = swiftPackages(registered, app);
|
|
10501
|
+
for (const target of packages.targets) {
|
|
10502
|
+
const relative2 = import_node_path17.default.relative(
|
|
10503
|
+
target.remote ? import_node_path17.default.join(root, REMOTE_CHECKOUTS) : root,
|
|
10504
|
+
target.dir
|
|
10045
10505
|
);
|
|
10046
|
-
|
|
10047
|
-
|
|
10048
|
-
|
|
10049
|
-
for (const relative2 of all) {
|
|
10050
|
-
if (relative2.startsWith(`${target.path}/`)) files.add(import_node_path15.default.join(dir, relative2));
|
|
10051
|
-
}
|
|
10052
|
-
}
|
|
10053
|
-
}
|
|
10054
|
-
const remote = remotePackages(registered, app);
|
|
10055
|
-
for (const target of remote.targets) {
|
|
10506
|
+
if (relative2 === ".." || relative2.startsWith(`..${import_node_path17.default.sep}`) || import_node_path17.default.isAbsolute(relative2))
|
|
10507
|
+
throw new Error(`swift input escapes the selected package: ${target.dir}`);
|
|
10508
|
+
const posix2 = relative2.split(import_node_path17.default.sep).join(import_node_path17.default.posix.sep);
|
|
10056
10509
|
targets.push({
|
|
10057
10510
|
...target,
|
|
10058
|
-
path:
|
|
10059
|
-
|
|
10060
|
-
import_node_path15.default.relative(import_node_path15.default.join(root, REMOTE_CHECKOUTS), target.dir).split(import_node_path15.default.sep).join(import_node_path15.default.posix.sep)
|
|
10061
|
-
)
|
|
10511
|
+
path: target.remote ? import_node_path17.default.posix.join(XCODE_PACKAGES_DIR, posix2) : posix2,
|
|
10512
|
+
exclude: []
|
|
10062
10513
|
});
|
|
10514
|
+
if (!target.remote) files.add(import_node_path17.default.join(target.packageDir, "Package.swift"));
|
|
10063
10515
|
for (const file of target.files) files.add(file);
|
|
10064
10516
|
}
|
|
10517
|
+
for (const target of targets) {
|
|
10518
|
+
target.exclude = targets.filter((other) => other.path.startsWith(`${target.path}/`)).map((other) => other.path.slice(target.path.length + 1));
|
|
10519
|
+
}
|
|
10065
10520
|
return {
|
|
10066
10521
|
app,
|
|
10067
10522
|
targets,
|
|
10068
|
-
|
|
10523
|
+
packages,
|
|
10069
10524
|
targetDirs,
|
|
10070
10525
|
files: [...files].sort()
|
|
10071
10526
|
};
|
|
@@ -10078,32 +10533,32 @@ function xcodeManifest(layout) {
|
|
|
10078
10533
|
'let package = Package(name: "app", targets: [',
|
|
10079
10534
|
` .executableTarget(name: "${layout.app.moduleName}", path: "${XCODE_APP_DIR}", ${settings(layout.app.languageMode, layout.app.mainActorIsolation)}),`,
|
|
10080
10535
|
...layout.targets.map(
|
|
10081
|
-
(target) => ` .target(name: "${target.name}", path: "${target.path}", ${target.resources ? "resources: [], " : ""}${settings(target.languageMode, target.mainActorIsolation)}),`
|
|
10536
|
+
(target) => ` .target(name: "${target.name}", path: "${target.path}", ${target.exclude.length > 0 ? `exclude: ${JSON.stringify(target.exclude)}, ` : ""}${target.resources ? "resources: [], " : ""}${settings(target.languageMode, target.mainActorIsolation)}),`
|
|
10082
10537
|
),
|
|
10083
10538
|
"])",
|
|
10084
10539
|
""
|
|
10085
10540
|
].join("\n");
|
|
10086
10541
|
}
|
|
10087
10542
|
function packageFiles(root) {
|
|
10088
|
-
const canonicalRoot =
|
|
10543
|
+
const canonicalRoot = import_node_fs16.default.realpathSync(root);
|
|
10089
10544
|
const xcode = xcodeLayout(canonicalRoot);
|
|
10090
10545
|
return xcode ? xcode.files : sourceTreeFiles(canonicalRoot, canonicalRoot);
|
|
10091
10546
|
}
|
|
10092
10547
|
function sourceTreeFiles(dir, canonicalRoot) {
|
|
10093
10548
|
const found = [];
|
|
10094
10549
|
const walk2 = (dir2) => {
|
|
10095
|
-
for (const entry of
|
|
10550
|
+
for (const entry of import_node_fs16.default.readdirSync(dir2, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
|
|
10096
10551
|
if (entry.name.startsWith(".") && entry.name !== NATIVE_DESCRIPTOR && entry.name !== NATIVE_GLUE || SKIP_SOURCE_DIRS.has(entry.name))
|
|
10097
10552
|
continue;
|
|
10098
|
-
const full =
|
|
10553
|
+
const full = import_node_path17.default.join(dir2, entry.name);
|
|
10099
10554
|
if (entry.isSymbolicLink()) throw new Error(`swift input is a symlink: ${full}`);
|
|
10100
|
-
const real =
|
|
10101
|
-
const relative2 =
|
|
10102
|
-
if (relative2.startsWith(`..${
|
|
10555
|
+
const real = import_node_fs16.default.realpathSync(full);
|
|
10556
|
+
const relative2 = import_node_path17.default.relative(canonicalRoot, real);
|
|
10557
|
+
if (relative2.startsWith(`..${import_node_path17.default.sep}`) || relative2 === ".." || import_node_path17.default.isAbsolute(relative2)) {
|
|
10103
10558
|
throw new Error(`swift input escapes the selected package: ${full}`);
|
|
10104
10559
|
}
|
|
10105
10560
|
if (entry.isDirectory()) {
|
|
10106
|
-
if (
|
|
10561
|
+
if (import_node_fs16.default.existsSync(import_node_path17.default.join(full, "Package.swift"))) continue;
|
|
10107
10562
|
walk2(full);
|
|
10108
10563
|
} else if (entry.isFile()) {
|
|
10109
10564
|
found.push(full);
|
|
@@ -10111,29 +10566,29 @@ function sourceTreeFiles(dir, canonicalRoot) {
|
|
|
10111
10566
|
}
|
|
10112
10567
|
}
|
|
10113
10568
|
};
|
|
10114
|
-
if (
|
|
10569
|
+
if (import_node_fs16.default.existsSync(dir)) walk2(import_node_fs16.default.realpathSync(dir));
|
|
10115
10570
|
return found;
|
|
10116
10571
|
}
|
|
10117
10572
|
function readPackageFile(root, file, maxBytes) {
|
|
10118
|
-
const canonicalRoot =
|
|
10119
|
-
const relative2 =
|
|
10120
|
-
if (relative2 === ".." || relative2.startsWith(`..${
|
|
10573
|
+
const canonicalRoot = import_node_fs16.default.realpathSync(root);
|
|
10574
|
+
const relative2 = import_node_path17.default.relative(canonicalRoot, import_node_fs16.default.realpathSync(file));
|
|
10575
|
+
if (relative2 === ".." || relative2.startsWith(`..${import_node_path17.default.sep}`) || import_node_path17.default.isAbsolute(relative2)) {
|
|
10121
10576
|
throw new Error(`swift input escapes the selected package: ${file}`);
|
|
10122
10577
|
}
|
|
10123
|
-
let ancestor =
|
|
10578
|
+
let ancestor = import_node_path17.default.resolve(file);
|
|
10124
10579
|
while (ancestor !== canonicalRoot) {
|
|
10125
|
-
if (
|
|
10580
|
+
if (import_node_fs16.default.lstatSync(ancestor).isSymbolicLink()) {
|
|
10126
10581
|
throw new Error(`swift input is a symlink: ${ancestor}`);
|
|
10127
10582
|
}
|
|
10128
|
-
const parent =
|
|
10583
|
+
const parent = import_node_path17.default.dirname(ancestor);
|
|
10129
10584
|
if (parent === ancestor)
|
|
10130
10585
|
throw new Error(`swift input escapes the selected package: ${file}`);
|
|
10131
10586
|
ancestor = parent;
|
|
10132
10587
|
}
|
|
10133
|
-
const expected =
|
|
10134
|
-
const fd =
|
|
10588
|
+
const expected = import_node_fs16.default.statSync(file);
|
|
10589
|
+
const fd = import_node_fs16.default.openSync(file, import_node_fs16.default.constants.O_RDONLY | import_node_fs16.default.constants.O_NOFOLLOW);
|
|
10135
10590
|
try {
|
|
10136
|
-
const stat2 =
|
|
10591
|
+
const stat2 = import_node_fs16.default.fstatSync(fd);
|
|
10137
10592
|
if (stat2.dev !== expected.dev || stat2.ino !== expected.ino) {
|
|
10138
10593
|
throw new Error(`swift input changed while opening: ${file}`);
|
|
10139
10594
|
}
|
|
@@ -10143,16 +10598,16 @@ function readPackageFile(root, file, maxBytes) {
|
|
|
10143
10598
|
const bytes = Buffer.alloc(stat2.size + 1);
|
|
10144
10599
|
let offset = 0;
|
|
10145
10600
|
while (offset < bytes.length) {
|
|
10146
|
-
const count =
|
|
10601
|
+
const count = import_node_fs16.default.readSync(fd, bytes, offset, bytes.length - offset, null);
|
|
10147
10602
|
if (count === 0) break;
|
|
10148
10603
|
offset += count;
|
|
10149
10604
|
}
|
|
10150
|
-
if (offset !== stat2.size ||
|
|
10605
|
+
if (offset !== stat2.size || import_node_fs16.default.fstatSync(fd).size !== stat2.size) {
|
|
10151
10606
|
throw new Error(`swift input changed while reading: ${file}`);
|
|
10152
10607
|
}
|
|
10153
10608
|
return bytes.subarray(0, offset);
|
|
10154
10609
|
} finally {
|
|
10155
|
-
|
|
10610
|
+
import_node_fs16.default.closeSync(fd);
|
|
10156
10611
|
}
|
|
10157
10612
|
}
|
|
10158
10613
|
function sourceFiles(root) {
|
|
@@ -10160,7 +10615,7 @@ function sourceFiles(root) {
|
|
|
10160
10615
|
}
|
|
10161
10616
|
function resourceCandidateFiles(root) {
|
|
10162
10617
|
return packageFiles(root).filter(
|
|
10163
|
-
(file) => !file.endsWith(".swift") &&
|
|
10618
|
+
(file) => !file.endsWith(".swift") && !["project.pbxproj", "project.xcproj"].includes(import_node_path17.default.basename(file))
|
|
10164
10619
|
);
|
|
10165
10620
|
}
|
|
10166
10621
|
var HOSTED_LIMITS = {
|
|
@@ -10194,7 +10649,7 @@ function buildSwiftResourceTable(project, baseUrl) {
|
|
|
10194
10649
|
const limits = inputLimits(Boolean(project.hosted));
|
|
10195
10650
|
const absolute = resourceCandidateFiles(project.packagePath);
|
|
10196
10651
|
const relative2 = absolute.map(
|
|
10197
|
-
(file) =>
|
|
10652
|
+
(file) => import_node_path17.default.relative(project.packagePath, file).split(import_node_path17.default.sep).join(import_node_path17.default.posix.sep)
|
|
10198
10653
|
);
|
|
10199
10654
|
const byRelative = new Map(absolute.map((file, index) => [relative2[index], file]));
|
|
10200
10655
|
const readContents = (candidate) => {
|
|
@@ -10216,16 +10671,16 @@ function buildSwiftResourceTable(project, baseUrl) {
|
|
|
10216
10671
|
for (const { name: name2, file, scale } of found) {
|
|
10217
10672
|
const disk = byRelative.get(file);
|
|
10218
10673
|
if (!disk) continue;
|
|
10219
|
-
if (Object.keys(images).length >= limits.images || imageBytes +
|
|
10674
|
+
if (Object.keys(images).length >= limits.images || imageBytes + import_node_fs16.default.statSync(disk).size > limits.imageTotalBytes) {
|
|
10220
10675
|
throw new Error("swift image pack exceeds the compile service caps");
|
|
10221
10676
|
}
|
|
10222
10677
|
const bytes = readPackageFile(project.packagePath, disk, limits.imageBytes);
|
|
10223
10678
|
imageBytes += bytes.length;
|
|
10224
|
-
const hash = (0,
|
|
10225
|
-
const ext =
|
|
10679
|
+
const hash = (0, import_node_crypto6.createHash)("sha256").update(bytes).digest("hex").slice(0, 16);
|
|
10680
|
+
const ext = import_node_path17.default.posix.extname(file).toLowerCase();
|
|
10226
10681
|
table[name2] = { uri: `${baseUrl}${RESOURCE_PATH}${hash}${ext}`, scale };
|
|
10227
10682
|
images[name2] = {
|
|
10228
|
-
file:
|
|
10683
|
+
file: import_node_path17.default.posix.basename(file),
|
|
10229
10684
|
data: bytes.toString("base64")
|
|
10230
10685
|
};
|
|
10231
10686
|
watched.push(file);
|
|
@@ -10249,10 +10704,10 @@ function buildSwiftResourceTable(project, baseUrl) {
|
|
|
10249
10704
|
return { table, images, colors, symbols, watched };
|
|
10250
10705
|
}
|
|
10251
10706
|
function buildSwiftBundleFiles(packagePath, hosted) {
|
|
10252
|
-
packagePath =
|
|
10707
|
+
packagePath = import_node_fs16.default.realpathSync(packagePath);
|
|
10253
10708
|
const limits = inputLimits(hosted);
|
|
10254
10709
|
const relative2 = resourceCandidateFiles(packagePath).map(
|
|
10255
|
-
(file) =>
|
|
10710
|
+
(file) => import_node_path17.default.relative(packagePath, file).split(import_node_path17.default.sep).join(import_node_path17.default.posix.sep)
|
|
10256
10711
|
);
|
|
10257
10712
|
const files = {};
|
|
10258
10713
|
const watched = [];
|
|
@@ -10266,13 +10721,13 @@ function buildSwiftBundleFiles(packagePath, hosted) {
|
|
|
10266
10721
|
total += bytes.length;
|
|
10267
10722
|
if (xcode.app.infoPlistFile)
|
|
10268
10723
|
watched.push(
|
|
10269
|
-
|
|
10724
|
+
import_node_path17.default.relative(packagePath, xcode.app.infoPlistFile).split(import_node_path17.default.sep).join("/")
|
|
10270
10725
|
);
|
|
10271
10726
|
}
|
|
10272
10727
|
for (const { base, file } of enumerateBundleJson(relative2)) {
|
|
10273
10728
|
watched.push(file);
|
|
10274
|
-
const disk =
|
|
10275
|
-
if (Object.keys(files).length >= limits.resources || total +
|
|
10729
|
+
const disk = import_node_path17.default.join(packagePath, ...file.split("/"));
|
|
10730
|
+
if (Object.keys(files).length >= limits.resources || total + import_node_fs16.default.statSync(disk).size > limits.resourceTotalBytes) {
|
|
10276
10731
|
throw new Error(
|
|
10277
10732
|
`swift bundle pack exceeds ${limits.resources} files / ${limits.resourceTotalBytes} bytes`
|
|
10278
10733
|
);
|
|
@@ -10287,12 +10742,12 @@ function serveSwiftResource(project, key) {
|
|
|
10287
10742
|
return project.resourceFiles.get(key) ?? project.resourcesPrevious.get(key) ?? null;
|
|
10288
10743
|
}
|
|
10289
10744
|
function linkedModuleRoots(packagePath) {
|
|
10290
|
-
packagePath =
|
|
10745
|
+
packagePath = import_node_fs16.default.realpathSync(packagePath);
|
|
10291
10746
|
let manifest;
|
|
10292
10747
|
try {
|
|
10293
10748
|
manifest = readPackageFile(
|
|
10294
10749
|
packagePath,
|
|
10295
|
-
|
|
10750
|
+
import_node_path17.default.join(packagePath, "Package.swift"),
|
|
10296
10751
|
MAX_SWIFT_COMPILE_SOURCE_BYTES
|
|
10297
10752
|
).toString("utf8");
|
|
10298
10753
|
} catch {
|
|
@@ -10301,28 +10756,28 @@ function linkedModuleRoots(packagePath) {
|
|
|
10301
10756
|
const roots = /* @__PURE__ */ new Set();
|
|
10302
10757
|
const dependency = /\.package\(\s*path:\s*"([^"]+)"\s*\)/g;
|
|
10303
10758
|
for (const match of manifest.replace(/^\s*\/\/.*$/gm, "").matchAll(dependency)) {
|
|
10304
|
-
const root =
|
|
10305
|
-
if (
|
|
10759
|
+
const root = import_node_path17.default.resolve(packagePath, match[1]);
|
|
10760
|
+
if (import_node_fs16.default.existsSync(import_node_path17.default.join(root, "Package.swift"))) roots.add(root);
|
|
10306
10761
|
}
|
|
10307
10762
|
return [...roots].sort();
|
|
10308
10763
|
}
|
|
10309
10764
|
function sourceStamp(packagePath, moduleRootOverride, hosted = false) {
|
|
10310
|
-
const hash = (0,
|
|
10765
|
+
const hash = (0, import_node_crypto6.createHash)("sha256");
|
|
10311
10766
|
hash.update(packagePath);
|
|
10312
10767
|
const projectInputs = new Set(packageFiles(packagePath));
|
|
10313
10768
|
for (const file of [...projectInputs].sort()) {
|
|
10314
|
-
hash.update(
|
|
10315
|
-
const stat2 =
|
|
10769
|
+
hash.update(import_node_path17.default.relative(packagePath, file));
|
|
10770
|
+
const stat2 = import_node_fs16.default.statSync(file);
|
|
10316
10771
|
hash.update(`${stat2.mtimeMs}/${stat2.ctimeMs}/${stat2.size}`);
|
|
10317
10772
|
}
|
|
10318
10773
|
const moduleRoot = hosted ? void 0 : moduleRootOverride ?? linkedModuleRoots(packagePath).find(
|
|
10319
|
-
(root) =>
|
|
10774
|
+
(root) => import_node_fs16.default.existsSync(import_node_path17.default.join(root, "toolchain.json"))
|
|
10320
10775
|
);
|
|
10321
10776
|
if (moduleRoot) {
|
|
10322
10777
|
hash.update(moduleRoot);
|
|
10323
10778
|
for (const relative2 of swiftModuleInputFiles(moduleRoot)) {
|
|
10324
10779
|
hash.update(relative2);
|
|
10325
|
-
hash.update(String(
|
|
10780
|
+
hash.update(String(import_node_fs16.default.statSync(import_node_path17.default.join(moduleRoot, relative2)).mtimeMs));
|
|
10326
10781
|
}
|
|
10327
10782
|
}
|
|
10328
10783
|
return hash.digest("hex").slice(0, 16);
|
|
@@ -10334,8 +10789,8 @@ function packageSources(packagePath) {
|
|
|
10334
10789
|
const xcode = xcodeLayout(packagePath);
|
|
10335
10790
|
const files = {};
|
|
10336
10791
|
for (const file of sourceFiles(packagePath)) {
|
|
10337
|
-
const relative2 =
|
|
10338
|
-
if (xcode &&
|
|
10792
|
+
const relative2 = import_node_path17.default.relative(packagePath, file).split(import_node_path17.default.sep).join(import_node_path17.default.posix.sep);
|
|
10793
|
+
if (xcode && import_node_path17.default.basename(file) === "Package.swift") continue;
|
|
10339
10794
|
files[xcode ? xcodeInputKey(xcode, file, relative2) : relative2] = readPackageFile(
|
|
10340
10795
|
packagePath,
|
|
10341
10796
|
file,
|
|
@@ -10352,7 +10807,7 @@ function packageSnapshot(project) {
|
|
|
10352
10807
|
files,
|
|
10353
10808
|
resourcePaths: swiftImplicitResourcePaths(
|
|
10354
10809
|
resourceCandidateFiles(project.packagePath).map(
|
|
10355
|
-
(file) =>
|
|
10810
|
+
(file) => import_node_path17.default.relative(project.packagePath, file).split(import_node_path17.default.sep).join(import_node_path17.default.posix.sep)
|
|
10356
10811
|
)
|
|
10357
10812
|
),
|
|
10358
10813
|
resources: buildSwiftResourceTable(project, ""),
|
|
@@ -10361,7 +10816,7 @@ function packageSnapshot(project) {
|
|
|
10361
10816
|
...native ? {
|
|
10362
10817
|
glue: readPackageFile(
|
|
10363
10818
|
project.packagePath,
|
|
10364
|
-
|
|
10819
|
+
import_node_path17.default.join(project.packagePath, NATIVE_GLUE),
|
|
10365
10820
|
MAX_SWIFT_COMPILE_SOURCE_BYTES
|
|
10366
10821
|
).toString("utf8")
|
|
10367
10822
|
} : {}
|
|
@@ -10397,7 +10852,7 @@ async function compile(packagePath, entry, stamp, moduleRootOverride, hosted, sn
|
|
|
10397
10852
|
package: content
|
|
10398
10853
|
};
|
|
10399
10854
|
const moduleRoot = moduleRootOverride ?? linkedModuleRoots(packagePath).find(
|
|
10400
|
-
(root) =>
|
|
10855
|
+
(root) => import_node_fs16.default.existsSync(import_node_path17.default.join(root, "toolchain.json"))
|
|
10401
10856
|
) ?? await swiftDistributionRoot();
|
|
10402
10857
|
if (!moduleRoot)
|
|
10403
10858
|
return {
|
|
@@ -10423,10 +10878,10 @@ async function compile(packagePath, entry, stamp, moduleRootOverride, hosted, sn
|
|
|
10423
10878
|
// server and a capture, or two checkouts) build each other's sources. so
|
|
10424
10879
|
// each app and module checkout gets its own root, which keeps the same
|
|
10425
10880
|
// app's incremental build across restarts.
|
|
10426
|
-
buildRoot: process.env.CONTRAST_SWIFT_BUILD_ROOT ??
|
|
10427
|
-
|
|
10881
|
+
buildRoot: process.env.CONTRAST_SWIFT_BUILD_ROOT ?? import_node_path17.default.join(
|
|
10882
|
+
import_node_os6.default.tmpdir(),
|
|
10428
10883
|
"contrast-swift-build",
|
|
10429
|
-
(0,
|
|
10884
|
+
(0, import_node_crypto6.createHash)("sha256").update(`${moduleRoot}\0${import_node_path17.default.resolve(packagePath)}`).digest("hex").slice(0, 16)
|
|
10430
10885
|
),
|
|
10431
10886
|
moduleRoot,
|
|
10432
10887
|
...toolchain
|
|
@@ -10491,19 +10946,19 @@ function swiftApiGapReport(output) {
|
|
|
10491
10946
|
}
|
|
10492
10947
|
function missingModulesMessage(packagePath, missing) {
|
|
10493
10948
|
const layout = xcodeLayout(packagePath);
|
|
10494
|
-
const
|
|
10495
|
-
(layout?.app.
|
|
10496
|
-
|
|
10497
|
-
|
|
10498
|
-
]
|
|
10499
|
-
|
|
10949
|
+
const gaps = new Map([
|
|
10950
|
+
...(layout?.app.binaryFrameworks ?? []).map(
|
|
10951
|
+
(name2) => [name2, { source: "the project", reason: "a vendored binary framework" }]
|
|
10952
|
+
),
|
|
10953
|
+
...layout?.packages.modules ?? [],
|
|
10954
|
+
...layout?.packages.unavailable ?? []
|
|
10955
|
+
]);
|
|
10500
10956
|
const width = Math.max(...[...missing.keys()].map((name2) => name2.length));
|
|
10501
10957
|
return [
|
|
10502
10958
|
`Peach does not provide ${missing.size} module${missing.size === 1 ? "" : "s"} this app imports:`,
|
|
10503
10959
|
...[...missing].map(([name2, files]) => {
|
|
10504
|
-
const
|
|
10505
|
-
|
|
10506
|
-
return ` ${name2.padEnd(width)} ${files.length} file${files.length === 1 ? "" : "s"}${source ? `, package ${source}` : ""}${reason ? ` (${reason})` : ""}`;
|
|
10960
|
+
const gap = gaps.get(name2);
|
|
10961
|
+
return ` ${name2.padEnd(width)} ${files.length} file${files.length === 1 ? "" : "s"}${gap ? `, ${gap.source.includes("://") ? `package ${gap.source}` : gap.source.startsWith("/") ? `package ${import_node_path17.default.relative(packagePath, gap.source) || "."}` : gap.source} (${gap.reason})` : ""}`;
|
|
10507
10962
|
})
|
|
10508
10963
|
].join("\n");
|
|
10509
10964
|
}
|
|
@@ -10511,7 +10966,7 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
|
|
|
10511
10966
|
const auth = hosted ? null : resolveCliAuth();
|
|
10512
10967
|
if (!hosted && (!auth || auth.kind === "github")) {
|
|
10513
10968
|
throw new Error(
|
|
10514
|
-
`compiling ${
|
|
10969
|
+
`compiling ${import_node_path17.default.basename(packagePath)} for Peach needs \`peach login\` or PEACH_API_KEY: this peachsim has no local SwiftUI module, so Contrast compiles it`
|
|
10515
10970
|
);
|
|
10516
10971
|
}
|
|
10517
10972
|
const origin = hosted?.origin ?? resolveContrastBackendOrigin(auth?.kind === "session" ? auth.origin : null);
|
|
@@ -10527,10 +10982,10 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
|
|
|
10527
10982
|
});
|
|
10528
10983
|
if (!submit) throw new Error("swift compile: no credential to submit with");
|
|
10529
10984
|
const sources = Object.values(snapshot.files);
|
|
10530
|
-
const bytes = sources.reduce((total2,
|
|
10985
|
+
const bytes = sources.reduce((total2, text2) => total2 + Buffer.byteLength(text2), 0);
|
|
10531
10986
|
if (sources.length > MAX_SWIFT_COMPILE_FILES || bytes > MAX_SWIFT_COMPILE_SOURCE_BYTES) {
|
|
10532
10987
|
throw new Error(
|
|
10533
|
-
`${
|
|
10988
|
+
`${import_node_path17.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`
|
|
10534
10989
|
);
|
|
10535
10990
|
}
|
|
10536
10991
|
const descriptor = snapshot.native;
|
|
@@ -10549,7 +11004,7 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
|
|
|
10549
11004
|
);
|
|
10550
11005
|
if (descriptor && address.native?.hash !== descriptor.hash) {
|
|
10551
11006
|
throw new Error(
|
|
10552
|
-
`${
|
|
11007
|
+
`${import_node_path17.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`
|
|
10553
11008
|
);
|
|
10554
11009
|
}
|
|
10555
11010
|
const response = await fetch(address.url, { signal });
|
|
@@ -10668,13 +11123,13 @@ function serveSwiftPackageAsset(pathname, res) {
|
|
|
10668
11123
|
}
|
|
10669
11124
|
|
|
10670
11125
|
// src/expo-swift-host.ts
|
|
10671
|
-
var run3 = (0, import_node_util3.promisify)(
|
|
11126
|
+
var run3 = (0, import_node_util3.promisify)(import_node_child_process8.execFile);
|
|
10672
11127
|
var scriptEnv = { ...process.env, [RNX_FORKED_SCRIPT_ENV]: "1" };
|
|
10673
11128
|
var EXPO_SWIFT_ROUTE = "/__peach/expo-swift";
|
|
10674
11129
|
var EXPO_SWIFT_ENTRY = "Sources/PeachExpoApp/PeachExpoEntry.swift";
|
|
10675
11130
|
async function collectExpoSwiftSources(appRoot) {
|
|
10676
|
-
appRoot =
|
|
10677
|
-
const appRequire = (0, import_node_module.createRequire)(
|
|
11131
|
+
appRoot = import_node_fs17.default.realpathSync(appRoot);
|
|
11132
|
+
const appRequire = (0, import_node_module.createRequire)(import_node_path18.default.join(appRoot, "package.json"));
|
|
10678
11133
|
let autolinker;
|
|
10679
11134
|
try {
|
|
10680
11135
|
autolinker = appRequire.resolve("expo-modules-autolinking/package.json");
|
|
@@ -10688,7 +11143,7 @@ async function collectExpoSwiftSources(appRoot) {
|
|
|
10688
11143
|
(command) => run3(
|
|
10689
11144
|
process.execPath,
|
|
10690
11145
|
[
|
|
10691
|
-
|
|
11146
|
+
import_node_path18.default.join(import_node_path18.default.dirname(autolinker), "bin/expo-modules-autolinking.js"),
|
|
10692
11147
|
command,
|
|
10693
11148
|
"--platform",
|
|
10694
11149
|
"apple",
|
|
@@ -10719,8 +11174,8 @@ async function collectExpoSwiftSources(appRoot) {
|
|
|
10719
11174
|
const sourceRoot = Reflect.get(entry, "path");
|
|
10720
11175
|
if (typeof sourceRoot !== "string")
|
|
10721
11176
|
throw new Error("Expo autolinking entry has no path");
|
|
10722
|
-
const canonical =
|
|
10723
|
-
if (canonical.split(
|
|
11177
|
+
const canonical = import_node_fs17.default.realpathSync(sourceRoot);
|
|
11178
|
+
if (canonical.split(import_node_path18.default.sep).includes("node_modules")) continue;
|
|
10724
11179
|
const resolution = resolutions.find(
|
|
10725
11180
|
(candidate) => candidate && typeof candidate === "object" && Reflect.get(candidate, "packageName") === Reflect.get(entry, "name")
|
|
10726
11181
|
);
|
|
@@ -10746,12 +11201,12 @@ async function collectExpoSwiftSources(appRoot) {
|
|
|
10746
11201
|
`(${className.includes(".") ? className : `${namespace}.${className}`}.self, ${name2 === null ? "nil" : JSON.stringify(name2)})`
|
|
10747
11202
|
);
|
|
10748
11203
|
}
|
|
10749
|
-
const ios =
|
|
10750
|
-
if (
|
|
11204
|
+
const ios = import_node_path18.default.join(canonical, "ios");
|
|
11205
|
+
if (import_node_fs17.default.lstatSync(ios).isSymbolicLink())
|
|
10751
11206
|
throw new Error(`Expo Swift source directory is a symlink: ${ios}`);
|
|
10752
11207
|
const walk2 = (dir) => {
|
|
10753
|
-
for (const child of
|
|
10754
|
-
const file =
|
|
11208
|
+
for (const child of import_node_fs17.default.readdirSync(dir, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
11209
|
+
const file = import_node_path18.default.join(dir, child.name);
|
|
10755
11210
|
if (child.isSymbolicLink())
|
|
10756
11211
|
throw new Error(`Expo Swift source is a symlink: ${file}`);
|
|
10757
11212
|
if (child.isDirectory()) {
|
|
@@ -10759,13 +11214,13 @@ async function collectExpoSwiftSources(appRoot) {
|
|
|
10759
11214
|
continue;
|
|
10760
11215
|
}
|
|
10761
11216
|
if (!child.name.endsWith(".swift")) continue;
|
|
10762
|
-
const size =
|
|
11217
|
+
const size = import_node_fs17.default.statSync(file).size;
|
|
10763
11218
|
bytes += size;
|
|
10764
11219
|
fileCount++;
|
|
10765
11220
|
if (fileCount > MAX_SWIFT_COMPILE_FILES - 2 || bytes > MAX_SWIFT_COMPILE_SOURCE_BYTES)
|
|
10766
11221
|
throw new Error("Expo Swift sources exceed compile service caps");
|
|
10767
|
-
files[`Sources/${namespace}/${
|
|
10768
|
-
${
|
|
11222
|
+
files[`Sources/${namespace}/${import_node_path18.default.relative(ios, file).split(import_node_path18.default.sep).join("/")}`] = `#sourceLocation(file: ${JSON.stringify(file)}, line: 1)
|
|
11223
|
+
${import_node_fs17.default.readFileSync(file, "utf8")}`;
|
|
10769
11224
|
}
|
|
10770
11225
|
};
|
|
10771
11226
|
walk2(ios);
|
|
@@ -10850,7 +11305,7 @@ async function handleExpoSwiftRequest(req, res) {
|
|
|
10850
11305
|
return true;
|
|
10851
11306
|
}
|
|
10852
11307
|
const root = url.searchParams.get("root");
|
|
10853
|
-
if (!root || !
|
|
11308
|
+
if (!root || !import_node_path18.default.isAbsolute(root)) {
|
|
10854
11309
|
res.writeHead(400);
|
|
10855
11310
|
res.end("missing absolute app root");
|
|
10856
11311
|
return true;
|
|
@@ -10867,7 +11322,7 @@ async function handleExpoSwiftRequest(req, res) {
|
|
|
10867
11322
|
modules: [],
|
|
10868
11323
|
failures: []
|
|
10869
11324
|
};
|
|
10870
|
-
const key = (0,
|
|
11325
|
+
const key = (0, import_node_crypto7.createHash)("sha256").update(import_node_fs17.default.realpathSync(root)).digest("hex");
|
|
10871
11326
|
const host2 = req.headers.host;
|
|
10872
11327
|
if (!host2) throw new Error("Expo Swift request has no host");
|
|
10873
11328
|
const base = `http://${host2}`;
|
|
@@ -10881,8 +11336,8 @@ async function handleExpoSwiftRequest(req, res) {
|
|
|
10881
11336
|
continue;
|
|
10882
11337
|
}
|
|
10883
11338
|
try {
|
|
10884
|
-
const packagePath =
|
|
10885
|
-
|
|
11339
|
+
const packagePath = import_node_path18.default.join(
|
|
11340
|
+
import_node_os7.default.tmpdir(),
|
|
10886
11341
|
"peach-expo-swift",
|
|
10887
11342
|
key,
|
|
10888
11343
|
unit.namespace
|
|
@@ -10891,7 +11346,7 @@ async function handleExpoSwiftRequest(req, res) {
|
|
|
10891
11346
|
packagePath,
|
|
10892
11347
|
new Map(
|
|
10893
11348
|
Object.entries(unit.files).map(([name2, source]) => [
|
|
10894
|
-
|
|
11349
|
+
import_node_path18.default.join(packagePath, name2),
|
|
10895
11350
|
source
|
|
10896
11351
|
])
|
|
10897
11352
|
)
|
|
@@ -10942,8 +11397,8 @@ async function handleExpoSwiftRequest(req, res) {
|
|
|
10942
11397
|
import PackageDescription
|
|
10943
11398
|
let package = Package(name: "PeachExpo", targets: [${targets.map((name2) => `.target(name: ${JSON.stringify(name2)}, path: ${JSON.stringify(`Sources/${name2}`)})`).join(", ")}, .executableTarget(name: "PeachExpoApp", path: "Sources/PeachExpoApp")])
|
|
10944
11399
|
`;
|
|
10945
|
-
const packagePath =
|
|
10946
|
-
|
|
11400
|
+
const packagePath = import_node_path18.default.join(
|
|
11401
|
+
import_node_os7.default.tmpdir(),
|
|
10947
11402
|
"peach-expo-swift",
|
|
10948
11403
|
key,
|
|
10949
11404
|
"linked-app"
|
|
@@ -10952,7 +11407,7 @@ let package = Package(name: "PeachExpo", targets: [${targets.map((name2) => `.ta
|
|
|
10952
11407
|
packagePath,
|
|
10953
11408
|
new Map(
|
|
10954
11409
|
Object.entries(files).map(([name2, source]) => [
|
|
10955
|
-
|
|
11410
|
+
import_node_path18.default.join(packagePath, name2),
|
|
10956
11411
|
source
|
|
10957
11412
|
])
|
|
10958
11413
|
)
|
|
@@ -11125,20 +11580,20 @@ var RNX_RUNTIME_PRODUCT = {
|
|
|
11125
11580
|
var rnxRuntime = createRuntimeDelivery(RNX_RUNTIME_PRODUCT);
|
|
11126
11581
|
|
|
11127
11582
|
// src/host/agent-host.ts
|
|
11128
|
-
var
|
|
11129
|
-
var
|
|
11130
|
-
var
|
|
11583
|
+
var import_node_crypto10 = require("node:crypto");
|
|
11584
|
+
var import_node_fs21 = __toESM(require("node:fs"), 1);
|
|
11585
|
+
var import_node_path22 = __toESM(require("node:path"), 1);
|
|
11131
11586
|
|
|
11132
11587
|
// src/agent-sessions.ts
|
|
11133
|
-
var
|
|
11134
|
-
var
|
|
11135
|
-
var
|
|
11136
|
-
var
|
|
11588
|
+
var import_node_child_process9 = require("node:child_process");
|
|
11589
|
+
var import_node_crypto9 = require("node:crypto");
|
|
11590
|
+
var import_node_fs20 = __toESM(require("node:fs"), 1);
|
|
11591
|
+
var import_node_path21 = __toESM(require("node:path"), 1);
|
|
11137
11592
|
var import_node_readline = __toESM(require("node:readline"), 1);
|
|
11138
11593
|
|
|
11139
11594
|
// cli/self-invocation.ts
|
|
11140
|
-
var
|
|
11141
|
-
var
|
|
11595
|
+
var import_node_fs18 = require("node:fs");
|
|
11596
|
+
var import_node_path19 = require("node:path");
|
|
11142
11597
|
var import_node_url3 = require("node:url");
|
|
11143
11598
|
init_public_brand();
|
|
11144
11599
|
|
|
@@ -11148,14 +11603,14 @@ var IS_STANDALONE = typeof __SOOTSIM_STANDALONE__ !== "undefined" && __SOOTSIM_S
|
|
|
11148
11603
|
// cli/self-invocation.ts
|
|
11149
11604
|
function sourceEntryPath() {
|
|
11150
11605
|
try {
|
|
11151
|
-
const candidate = (0,
|
|
11152
|
-
return (0,
|
|
11606
|
+
const candidate = (0, import_node_path19.join)((0, import_node_path19.dirname)((0, import_node_url3.fileURLToPath)(__sootsim_import_meta_url)), "bin.ts");
|
|
11607
|
+
return (0, import_node_fs18.existsSync)(candidate) ? candidate : null;
|
|
11153
11608
|
} catch {
|
|
11154
11609
|
return null;
|
|
11155
11610
|
}
|
|
11156
11611
|
}
|
|
11157
|
-
function isCliEntry(
|
|
11158
|
-
const name2 = (0,
|
|
11612
|
+
function isCliEntry(path22) {
|
|
11613
|
+
const name2 = (0, import_node_path19.basename)(path22);
|
|
11159
11614
|
return name2 === "bin.ts" || name2 === "bin.js";
|
|
11160
11615
|
}
|
|
11161
11616
|
function rnxSelfInvocation() {
|
|
@@ -11197,16 +11652,16 @@ function cleanPromptText(value) {
|
|
|
11197
11652
|
return typeof value === "string" ? value.trim() : "";
|
|
11198
11653
|
}
|
|
11199
11654
|
function encodeAgentPromptEnvelope(input) {
|
|
11200
|
-
const
|
|
11201
|
-
if (!
|
|
11655
|
+
const text2 = cleanPromptText(input.text);
|
|
11656
|
+
if (!text2) return "";
|
|
11202
11657
|
const displayText = cleanPromptText(input.displayText);
|
|
11203
11658
|
const inspectSummary = cleanPromptText(input.inspectSummary);
|
|
11204
11659
|
const inspectTrace = cleanPromptText(input.inspectTrace);
|
|
11205
|
-
const needsEnvelope = !!inspectSummary || !!inspectTrace || /[\r\n]/.test(
|
|
11206
|
-
if (!needsEnvelope) return
|
|
11660
|
+
const needsEnvelope = !!inspectSummary || !!inspectTrace || /[\r\n]/.test(text2) || !!displayText && displayText !== text2;
|
|
11661
|
+
if (!needsEnvelope) return text2;
|
|
11207
11662
|
return JSON.stringify({
|
|
11208
11663
|
__sootsimAgentPrompt: ENVELOPE_MARKER,
|
|
11209
|
-
text,
|
|
11664
|
+
text: text2,
|
|
11210
11665
|
displayText,
|
|
11211
11666
|
inspectSummary,
|
|
11212
11667
|
inspectTrace
|
|
@@ -11214,9 +11669,9 @@ function encodeAgentPromptEnvelope(input) {
|
|
|
11214
11669
|
}
|
|
11215
11670
|
|
|
11216
11671
|
// src/attached-projects.ts
|
|
11217
|
-
var
|
|
11218
|
-
var
|
|
11219
|
-
var
|
|
11672
|
+
var import_node_crypto8 = require("node:crypto");
|
|
11673
|
+
var import_node_fs19 = __toESM(require("node:fs"), 1);
|
|
11674
|
+
var import_node_path20 = __toESM(require("node:path"), 1);
|
|
11220
11675
|
init_home_paths();
|
|
11221
11676
|
var overrideDir = null;
|
|
11222
11677
|
function userDataDir() {
|
|
@@ -11229,7 +11684,7 @@ function getUserDataDir() {
|
|
|
11229
11684
|
return userDataDir();
|
|
11230
11685
|
}
|
|
11231
11686
|
function storeFile() {
|
|
11232
|
-
return
|
|
11687
|
+
return import_node_path20.default.join(userDataDir(), "attached-projects.json");
|
|
11233
11688
|
}
|
|
11234
11689
|
function cloneEmpty() {
|
|
11235
11690
|
return {
|
|
@@ -11243,7 +11698,7 @@ function loadStore() {
|
|
|
11243
11698
|
const file = storeFile();
|
|
11244
11699
|
let raw2;
|
|
11245
11700
|
try {
|
|
11246
|
-
raw2 =
|
|
11701
|
+
raw2 = import_node_fs19.default.readFileSync(file, "utf8");
|
|
11247
11702
|
} catch (err) {
|
|
11248
11703
|
if (err.code === "ENOENT") return cloneEmpty();
|
|
11249
11704
|
throw err;
|
|
@@ -11260,7 +11715,7 @@ function loadStore() {
|
|
|
11260
11715
|
} catch (err) {
|
|
11261
11716
|
const quarantine = `${file}.corrupt-${Date.now()}`;
|
|
11262
11717
|
try {
|
|
11263
|
-
|
|
11718
|
+
import_node_fs19.default.renameSync(file, quarantine);
|
|
11264
11719
|
console.warn(
|
|
11265
11720
|
`[sootsim] attached-projects.json was unparseable; quarantined to ${quarantine}. original error: ${err.message}`
|
|
11266
11721
|
);
|
|
@@ -11271,16 +11726,16 @@ function loadStore() {
|
|
|
11271
11726
|
}
|
|
11272
11727
|
function writeStore(store) {
|
|
11273
11728
|
const file = storeFile();
|
|
11274
|
-
|
|
11729
|
+
import_node_fs19.default.mkdirSync(import_node_path20.default.dirname(file), { recursive: true });
|
|
11275
11730
|
const tmp = `${file}.tmp-${process.pid}-${Date.now()}`;
|
|
11276
|
-
const fd =
|
|
11731
|
+
const fd = import_node_fs19.default.openSync(tmp, "w", 384);
|
|
11277
11732
|
try {
|
|
11278
|
-
|
|
11279
|
-
|
|
11733
|
+
import_node_fs19.default.writeFileSync(fd, JSON.stringify(store, null, 2));
|
|
11734
|
+
import_node_fs19.default.fsyncSync(fd);
|
|
11280
11735
|
} finally {
|
|
11281
|
-
|
|
11736
|
+
import_node_fs19.default.closeSync(fd);
|
|
11282
11737
|
}
|
|
11283
|
-
|
|
11738
|
+
import_node_fs19.default.renameSync(tmp, file);
|
|
11284
11739
|
}
|
|
11285
11740
|
function mutateStore(fn) {
|
|
11286
11741
|
const store = loadStore();
|
|
@@ -11289,13 +11744,13 @@ function mutateStore(fn) {
|
|
|
11289
11744
|
return store;
|
|
11290
11745
|
}
|
|
11291
11746
|
function projectIdForCwd(cwd) {
|
|
11292
|
-
return (0,
|
|
11747
|
+
return (0, import_node_crypto8.createHash)("sha256").update(import_node_path20.default.resolve(cwd)).digest("hex").slice(0, 16);
|
|
11293
11748
|
}
|
|
11294
11749
|
function newSessionId() {
|
|
11295
|
-
return `s_${(0,
|
|
11750
|
+
return `s_${(0, import_node_crypto8.randomBytes)(10).toString("hex")}`;
|
|
11296
11751
|
}
|
|
11297
11752
|
function upsertProject(input) {
|
|
11298
|
-
const cwd =
|
|
11753
|
+
const cwd = import_node_path20.default.resolve(input.cwd);
|
|
11299
11754
|
const id = projectIdForCwd(cwd);
|
|
11300
11755
|
let result;
|
|
11301
11756
|
mutateStore((store) => {
|
|
@@ -11321,7 +11776,7 @@ function upsertProject(input) {
|
|
|
11321
11776
|
const now = Date.now();
|
|
11322
11777
|
const created = {
|
|
11323
11778
|
id,
|
|
11324
|
-
name: input.name ??
|
|
11779
|
+
name: input.name ?? import_node_path20.default.basename(cwd),
|
|
11325
11780
|
cwd,
|
|
11326
11781
|
repoRoot: input.repoRoot,
|
|
11327
11782
|
sourceRoots: input.sourceRoots ?? [cwd],
|
|
@@ -11467,8 +11922,8 @@ async function seedFromDemoAppRegistry() {
|
|
|
11467
11922
|
if (apps.length === 0) return;
|
|
11468
11923
|
mutateStore((store) => {
|
|
11469
11924
|
for (const app of apps) {
|
|
11470
|
-
if (!
|
|
11471
|
-
const cwd =
|
|
11925
|
+
if (!import_node_fs19.default.existsSync(app.dir)) continue;
|
|
11926
|
+
const cwd = import_node_path20.default.resolve(app.dir);
|
|
11472
11927
|
const id = projectIdForCwd(cwd);
|
|
11473
11928
|
if (store.attachedProjects.some((p) => p.id === id)) continue;
|
|
11474
11929
|
const now = Date.now();
|
|
@@ -11493,16 +11948,16 @@ async function seedFromDemoAppRegistry() {
|
|
|
11493
11948
|
// src/agent-sessions.ts
|
|
11494
11949
|
init_public_brand();
|
|
11495
11950
|
function sessionDir(sessionId) {
|
|
11496
|
-
return
|
|
11951
|
+
return import_node_path21.default.join(getUserDataDir(), "sessions", sessionId);
|
|
11497
11952
|
}
|
|
11498
11953
|
function promptFifoPath(sessionId) {
|
|
11499
|
-
return
|
|
11954
|
+
return import_node_path21.default.join(sessionDir(sessionId), "prompt.in");
|
|
11500
11955
|
}
|
|
11501
11956
|
function eventsFifoPath(sessionId) {
|
|
11502
|
-
return
|
|
11957
|
+
return import_node_path21.default.join(sessionDir(sessionId), "events.out");
|
|
11503
11958
|
}
|
|
11504
11959
|
function transcriptPath(sessionId) {
|
|
11505
|
-
return
|
|
11960
|
+
return import_node_path21.default.join(getUserDataDir(), "transcripts", `${sessionId}.log`);
|
|
11506
11961
|
}
|
|
11507
11962
|
function pidIsAlive(pid, sessionId) {
|
|
11508
11963
|
if (!pid) return false;
|
|
@@ -11512,7 +11967,7 @@ function pidIsAlive(pid, sessionId) {
|
|
|
11512
11967
|
return false;
|
|
11513
11968
|
}
|
|
11514
11969
|
if (sessionId) {
|
|
11515
|
-
if (!
|
|
11970
|
+
if (!import_node_fs20.default.existsSync(sessionDir(sessionId))) return false;
|
|
11516
11971
|
}
|
|
11517
11972
|
return true;
|
|
11518
11973
|
}
|
|
@@ -11525,11 +11980,11 @@ function resolveSootsimInvocation() {
|
|
|
11525
11980
|
const resourcesPath = process.resourcesPath;
|
|
11526
11981
|
if (resourcesPath) {
|
|
11527
11982
|
const candidates = [
|
|
11528
|
-
|
|
11529
|
-
|
|
11983
|
+
import_node_path21.default.join(resourcesPath, "bin", "sootsim"),
|
|
11984
|
+
import_node_path21.default.join(resourcesPath, "bin", `sootsim-${process.platform}-${process.arch}`)
|
|
11530
11985
|
];
|
|
11531
11986
|
for (const c of candidates) {
|
|
11532
|
-
if (
|
|
11987
|
+
if (import_node_fs20.default.existsSync(c)) return { executable: c, prefixArgs: [] };
|
|
11533
11988
|
}
|
|
11534
11989
|
}
|
|
11535
11990
|
}
|
|
@@ -11548,15 +12003,15 @@ function tryWorkspaceSootsim() {
|
|
|
11548
12003
|
const sootsimDir = resolveSootsimPackageDir();
|
|
11549
12004
|
if (!sootsimDir) return null;
|
|
11550
12005
|
const binaryName = `peach-${process.platform === "win32" ? "windows" : process.platform}-${process.arch}${process.platform === "win32" ? ".exe" : ""}`;
|
|
11551
|
-
const distBinary =
|
|
11552
|
-
if (
|
|
11553
|
-
const distBin =
|
|
11554
|
-
if (
|
|
12006
|
+
const distBinary = import_node_path21.default.join(sootsimDir, "dist-bin", binaryName);
|
|
12007
|
+
if (import_node_fs20.default.existsSync(distBinary)) return { executable: distBinary, prefixArgs: [] };
|
|
12008
|
+
const distBin = import_node_path21.default.join(sootsimDir, "dist-cli", "bin.js");
|
|
12009
|
+
if (import_node_fs20.default.existsSync(distBin)) {
|
|
11555
12010
|
try {
|
|
11556
|
-
const src =
|
|
11557
|
-
if (
|
|
11558
|
-
const srcMtime =
|
|
11559
|
-
const buildMtime =
|
|
12011
|
+
const src = import_node_path21.default.join(sootsimDir, "cli", "commands", "agent-wrapper.ts");
|
|
12012
|
+
if (import_node_fs20.default.existsSync(src)) {
|
|
12013
|
+
const srcMtime = import_node_fs20.default.statSync(src).mtimeMs;
|
|
12014
|
+
const buildMtime = import_node_fs20.default.statSync(distBin).mtimeMs;
|
|
11560
12015
|
if (buildMtime < srcMtime) {
|
|
11561
12016
|
console.warn(
|
|
11562
12017
|
`[peach] dist-cli/bin.js is older than agent-wrapper.ts \u2014 rebuild with \`bun run --cwd packages/peachsim build:cli\`.`
|
|
@@ -11575,22 +12030,22 @@ function tryWorkspaceSootsim() {
|
|
|
11575
12030
|
function resolveSootsimPackageDir() {
|
|
11576
12031
|
try {
|
|
11577
12032
|
const resolved = require.resolve(`${rnxPublicBrand.packageName}/package.json`);
|
|
11578
|
-
return
|
|
12033
|
+
return import_node_path21.default.dirname(resolved);
|
|
11579
12034
|
} catch {
|
|
11580
12035
|
}
|
|
11581
12036
|
const here = fileFromImportMeta();
|
|
11582
12037
|
if (!here) return null;
|
|
11583
|
-
let cur =
|
|
12038
|
+
let cur = import_node_path21.default.dirname(here);
|
|
11584
12039
|
for (let i = 0; i < 8; i++) {
|
|
11585
|
-
const pkg =
|
|
12040
|
+
const pkg = import_node_path21.default.join(cur, "package.json");
|
|
11586
12041
|
try {
|
|
11587
|
-
if (
|
|
11588
|
-
const parsed = JSON.parse(
|
|
12042
|
+
if (import_node_fs20.default.existsSync(pkg)) {
|
|
12043
|
+
const parsed = JSON.parse(import_node_fs20.default.readFileSync(pkg, "utf8"));
|
|
11589
12044
|
if (parsed.name === rnxPublicBrand.packageName) return cur;
|
|
11590
12045
|
}
|
|
11591
12046
|
} catch {
|
|
11592
12047
|
}
|
|
11593
|
-
const parent =
|
|
12048
|
+
const parent = import_node_path21.default.dirname(cur);
|
|
11594
12049
|
if (parent === cur) break;
|
|
11595
12050
|
cur = parent;
|
|
11596
12051
|
}
|
|
@@ -11606,28 +12061,28 @@ function fileFromImportMeta() {
|
|
|
11606
12061
|
}
|
|
11607
12062
|
}
|
|
11608
12063
|
async function withStartLock(projectId, provider, fn) {
|
|
11609
|
-
const lockDir =
|
|
11610
|
-
|
|
12064
|
+
const lockDir = import_node_path21.default.join(getUserDataDir(), "locks");
|
|
12065
|
+
import_node_fs20.default.mkdirSync(lockDir, { recursive: true });
|
|
11611
12066
|
try {
|
|
11612
|
-
|
|
12067
|
+
import_node_fs20.default.chmodSync(lockDir, 448);
|
|
11613
12068
|
} catch {
|
|
11614
12069
|
}
|
|
11615
|
-
const lockPath =
|
|
12070
|
+
const lockPath = import_node_path21.default.join(lockDir, `start-${projectId}-${provider}.lock`);
|
|
11616
12071
|
const deadline = Date.now() + 4e3;
|
|
11617
12072
|
let fd = null;
|
|
11618
12073
|
while (fd === null) {
|
|
11619
12074
|
try {
|
|
11620
|
-
fd =
|
|
12075
|
+
fd = import_node_fs20.default.openSync(
|
|
11621
12076
|
lockPath,
|
|
11622
|
-
|
|
12077
|
+
import_node_fs20.constants.O_WRONLY | import_node_fs20.constants.O_CREAT | import_node_fs20.constants.O_EXCL,
|
|
11623
12078
|
384
|
|
11624
12079
|
);
|
|
11625
12080
|
} catch (err) {
|
|
11626
12081
|
if (err.code !== "EEXIST") throw err;
|
|
11627
12082
|
try {
|
|
11628
|
-
const stale = Number(
|
|
12083
|
+
const stale = Number(import_node_fs20.default.readFileSync(lockPath, "utf8").trim());
|
|
11629
12084
|
if (stale && !isProcessAlive(stale)) {
|
|
11630
|
-
|
|
12085
|
+
import_node_fs20.default.unlinkSync(lockPath);
|
|
11631
12086
|
continue;
|
|
11632
12087
|
}
|
|
11633
12088
|
} catch {
|
|
@@ -11641,15 +12096,15 @@ async function withStartLock(projectId, provider, fn) {
|
|
|
11641
12096
|
}
|
|
11642
12097
|
}
|
|
11643
12098
|
try {
|
|
11644
|
-
|
|
12099
|
+
import_node_fs20.default.writeFileSync(fd, String(process.pid));
|
|
11645
12100
|
return await fn();
|
|
11646
12101
|
} finally {
|
|
11647
12102
|
try {
|
|
11648
|
-
|
|
12103
|
+
import_node_fs20.default.closeSync(fd);
|
|
11649
12104
|
} catch {
|
|
11650
12105
|
}
|
|
11651
12106
|
try {
|
|
11652
|
-
|
|
12107
|
+
import_node_fs20.default.unlinkSync(lockPath);
|
|
11653
12108
|
} catch {
|
|
11654
12109
|
}
|
|
11655
12110
|
}
|
|
@@ -11663,28 +12118,28 @@ function isProcessAlive(pid) {
|
|
|
11663
12118
|
}
|
|
11664
12119
|
}
|
|
11665
12120
|
function mkfifoSync(p) {
|
|
11666
|
-
const parent =
|
|
11667
|
-
|
|
12121
|
+
const parent = import_node_path21.default.dirname(p);
|
|
12122
|
+
import_node_fs20.default.mkdirSync(parent, { recursive: true });
|
|
11668
12123
|
try {
|
|
11669
|
-
|
|
12124
|
+
import_node_fs20.default.chmodSync(parent, 448);
|
|
11670
12125
|
} catch {
|
|
11671
12126
|
}
|
|
11672
|
-
if (
|
|
12127
|
+
if (import_node_fs20.default.existsSync(p)) {
|
|
11673
12128
|
try {
|
|
11674
|
-
const stat2 =
|
|
12129
|
+
const stat2 = import_node_fs20.default.statSync(p);
|
|
11675
12130
|
if (stat2.isFIFO()) {
|
|
11676
12131
|
try {
|
|
11677
|
-
|
|
12132
|
+
import_node_fs20.default.chmodSync(p, 384);
|
|
11678
12133
|
} catch {
|
|
11679
12134
|
}
|
|
11680
12135
|
return;
|
|
11681
12136
|
}
|
|
11682
|
-
|
|
12137
|
+
import_node_fs20.default.unlinkSync(p);
|
|
11683
12138
|
} catch {
|
|
11684
|
-
|
|
12139
|
+
import_node_fs20.default.unlinkSync(p);
|
|
11685
12140
|
}
|
|
11686
12141
|
}
|
|
11687
|
-
const result = (0,
|
|
12142
|
+
const result = (0, import_node_child_process9.spawnSync)("mkfifo", ["-m", "600", p]);
|
|
11688
12143
|
if (result.status !== 0) {
|
|
11689
12144
|
throw new Error(
|
|
11690
12145
|
`mkfifo(${p}) failed: ${result.stderr?.toString().trim() || "unknown error"}`
|
|
@@ -11714,7 +12169,7 @@ async function startSession(opts) {
|
|
|
11714
12169
|
`session already running for project=${project.id} provider=${provider} (session ${existingLive.id}, pid ${existingLive.wrapperPid}). end it first with \`peach agent end <sessionId>\`.`
|
|
11715
12170
|
);
|
|
11716
12171
|
}
|
|
11717
|
-
const claudeSessionUuid = provider === "claude" ? (0,
|
|
12172
|
+
const claudeSessionUuid = provider === "claude" ? (0, import_node_crypto9.randomUUID)() : void 0;
|
|
11718
12173
|
const session = upsertSession({
|
|
11719
12174
|
projectId: project.id,
|
|
11720
12175
|
provider,
|
|
@@ -11728,10 +12183,10 @@ async function startSession(opts) {
|
|
|
11728
12183
|
const transcript = transcriptPath(session.id);
|
|
11729
12184
|
mkfifoSync(promptIn);
|
|
11730
12185
|
mkfifoSync(eventsOut);
|
|
11731
|
-
const transcriptDir =
|
|
11732
|
-
|
|
12186
|
+
const transcriptDir = import_node_path21.default.dirname(transcript);
|
|
12187
|
+
import_node_fs20.default.mkdirSync(transcriptDir, { recursive: true });
|
|
11733
12188
|
try {
|
|
11734
|
-
|
|
12189
|
+
import_node_fs20.default.chmodSync(transcriptDir, 448);
|
|
11735
12190
|
} catch {
|
|
11736
12191
|
}
|
|
11737
12192
|
const { executable, prefixArgs } = resolveSootsimInvocation();
|
|
@@ -11759,7 +12214,7 @@ async function startSession(opts) {
|
|
|
11759
12214
|
if (claudeSessionUuid) {
|
|
11760
12215
|
wrapperArgs.push("--claude-session-uuid", claudeSessionUuid);
|
|
11761
12216
|
}
|
|
11762
|
-
const child = (0,
|
|
12217
|
+
const child = (0, import_node_child_process9.spawn)(executable, wrapperArgs, {
|
|
11763
12218
|
detached: true,
|
|
11764
12219
|
stdio: "ignore",
|
|
11765
12220
|
env: {
|
|
@@ -11782,7 +12237,7 @@ async function startSession(opts) {
|
|
|
11782
12237
|
}
|
|
11783
12238
|
}
|
|
11784
12239
|
try {
|
|
11785
|
-
|
|
12240
|
+
import_node_fs20.default.rmSync(sessionDir(session.id), { recursive: true, force: true });
|
|
11786
12241
|
} catch {
|
|
11787
12242
|
}
|
|
11788
12243
|
updateSessionStatus(session.id, { status: "ended" });
|
|
@@ -11810,18 +12265,18 @@ async function sendPrompt(sessionId, prompt) {
|
|
|
11810
12265
|
);
|
|
11811
12266
|
}
|
|
11812
12267
|
const fifo = promptFifoPath(sessionId);
|
|
11813
|
-
if (!
|
|
12268
|
+
if (!import_node_fs20.default.existsSync(fifo)) {
|
|
11814
12269
|
throw new AgentSessionError("NO_FIFO", `prompt FIFO missing: ${fifo}`);
|
|
11815
12270
|
}
|
|
11816
|
-
const fd =
|
|
12271
|
+
const fd = import_node_fs20.default.openSync(fifo, import_node_fs20.constants.O_WRONLY);
|
|
11817
12272
|
try {
|
|
11818
12273
|
const wireText = encodeAgentPromptEnvelope(prompt);
|
|
11819
12274
|
if (!wireText) {
|
|
11820
12275
|
throw new AgentSessionError("EMPTY_PROMPT", "prompt text is empty");
|
|
11821
12276
|
}
|
|
11822
|
-
|
|
12277
|
+
import_node_fs20.default.writeSync(fd, wireText + "\n");
|
|
11823
12278
|
} finally {
|
|
11824
|
-
|
|
12279
|
+
import_node_fs20.default.closeSync(fd);
|
|
11825
12280
|
}
|
|
11826
12281
|
updateSessionStatus(sessionId, {
|
|
11827
12282
|
lastPrompt: prompt.displayText ?? prompt.text,
|
|
@@ -11843,7 +12298,7 @@ async function endSession(sessionId) {
|
|
|
11843
12298
|
const base = getUserDataDir();
|
|
11844
12299
|
if (dir.startsWith(base)) {
|
|
11845
12300
|
try {
|
|
11846
|
-
|
|
12301
|
+
import_node_fs20.default.rmSync(dir, { recursive: true, force: true });
|
|
11847
12302
|
} catch {
|
|
11848
12303
|
}
|
|
11849
12304
|
}
|
|
@@ -11851,11 +12306,11 @@ async function endSession(sessionId) {
|
|
|
11851
12306
|
}
|
|
11852
12307
|
function subscribeEvents(sessionId, onEvent) {
|
|
11853
12308
|
const fifo = eventsFifoPath(sessionId);
|
|
11854
|
-
if (!
|
|
12309
|
+
if (!import_node_fs20.default.existsSync(fifo)) {
|
|
11855
12310
|
throw new AgentSessionError("NO_FIFO", `events FIFO missing: ${fifo}`);
|
|
11856
12311
|
}
|
|
11857
|
-
const fd =
|
|
11858
|
-
const stream =
|
|
12312
|
+
const fd = import_node_fs20.default.openSync(fifo, import_node_fs20.constants.O_RDWR);
|
|
12313
|
+
const stream = import_node_fs20.default.createReadStream("", { fd, autoClose: true });
|
|
11859
12314
|
const rl = import_node_readline.default.createInterface({ input: stream, crlfDelay: Infinity });
|
|
11860
12315
|
rl.on("line", (line) => {
|
|
11861
12316
|
const event = parseAgentEventLine(line);
|
|
@@ -11866,7 +12321,7 @@ function subscribeEvents(sessionId, onEvent) {
|
|
|
11866
12321
|
if (closed) return;
|
|
11867
12322
|
closed = true;
|
|
11868
12323
|
try {
|
|
11869
|
-
|
|
12324
|
+
import_node_fs20.default.writeSync(fd, "\n");
|
|
11870
12325
|
} catch {
|
|
11871
12326
|
}
|
|
11872
12327
|
try {
|
|
@@ -11880,7 +12335,7 @@ function subscribeEvents(sessionId, onEvent) {
|
|
|
11880
12335
|
};
|
|
11881
12336
|
}
|
|
11882
12337
|
async function waitForFirstEvent(fifo, predicate, timeoutMs) {
|
|
11883
|
-
const fd =
|
|
12338
|
+
const fd = import_node_fs20.default.openSync(fifo, import_node_fs20.constants.O_RDWR | import_node_fs20.constants.O_NONBLOCK);
|
|
11884
12339
|
const buf = Buffer.alloc(8192);
|
|
11885
12340
|
let leftover = "";
|
|
11886
12341
|
const deadline = Date.now() + timeoutMs;
|
|
@@ -11888,7 +12343,7 @@ async function waitForFirstEvent(fifo, predicate, timeoutMs) {
|
|
|
11888
12343
|
while (Date.now() < deadline) {
|
|
11889
12344
|
let n = 0;
|
|
11890
12345
|
try {
|
|
11891
|
-
n =
|
|
12346
|
+
n = import_node_fs20.default.readSync(fd, buf, 0, buf.length, null);
|
|
11892
12347
|
} catch (err) {
|
|
11893
12348
|
if (err.code !== "EAGAIN") throw err;
|
|
11894
12349
|
n = 0;
|
|
@@ -11908,7 +12363,7 @@ async function waitForFirstEvent(fifo, predicate, timeoutMs) {
|
|
|
11908
12363
|
}
|
|
11909
12364
|
return null;
|
|
11910
12365
|
} finally {
|
|
11911
|
-
|
|
12366
|
+
import_node_fs20.default.closeSync(fd);
|
|
11912
12367
|
}
|
|
11913
12368
|
}
|
|
11914
12369
|
|
|
@@ -12116,7 +12571,7 @@ var AgentHost = class {
|
|
|
12116
12571
|
throw new AgentSessionError("EMPTY_PROMPT", "inspect message cannot be empty");
|
|
12117
12572
|
}
|
|
12118
12573
|
const message = {
|
|
12119
|
-
id: `inspect-${(0,
|
|
12574
|
+
id: `inspect-${(0, import_node_crypto10.randomUUID)()}`,
|
|
12120
12575
|
simId,
|
|
12121
12576
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
12122
12577
|
prompt
|
|
@@ -12162,7 +12617,7 @@ var AgentHost = class {
|
|
|
12162
12617
|
);
|
|
12163
12618
|
const project = upsertProject({
|
|
12164
12619
|
cwd: match.cwd,
|
|
12165
|
-
name: match.projectName ??
|
|
12620
|
+
name: match.projectName ?? import_node_path22.default.basename(match.cwd),
|
|
12166
12621
|
preferredProvider: input.provider ?? existing?.preferredProvider,
|
|
12167
12622
|
sourceRoots: existing?.sourceRoots ?? [match.cwd],
|
|
12168
12623
|
knownBundleUrls,
|
|
@@ -12173,18 +12628,18 @@ var AgentHost = class {
|
|
|
12173
12628
|
}
|
|
12174
12629
|
getTranscript(sessionId) {
|
|
12175
12630
|
const p = transcriptPath(sessionId);
|
|
12176
|
-
if (!
|
|
12631
|
+
if (!import_node_fs21.default.existsSync(p)) {
|
|
12177
12632
|
return { error: "transcript not found", code: "NO_TRANSCRIPT" };
|
|
12178
12633
|
}
|
|
12179
|
-
return
|
|
12634
|
+
return import_node_fs21.default.readFileSync(p, "utf8");
|
|
12180
12635
|
}
|
|
12181
12636
|
getPaths() {
|
|
12182
12637
|
const dir = getUserDataDir();
|
|
12183
12638
|
return {
|
|
12184
12639
|
userDataDir: dir,
|
|
12185
|
-
storeFile:
|
|
12186
|
-
sessionsDir:
|
|
12187
|
-
transcriptsDir:
|
|
12640
|
+
storeFile: import_node_path22.default.join(dir, "attached-projects.json"),
|
|
12641
|
+
sessionsDir: import_node_path22.default.join(dir, "sessions"),
|
|
12642
|
+
transcriptsDir: import_node_path22.default.join(dir, "transcripts")
|
|
12188
12643
|
};
|
|
12189
12644
|
}
|
|
12190
12645
|
// --- subscription management ---
|
|
@@ -12885,7 +13340,7 @@ function handleAppApiRequest(req, res) {
|
|
|
12885
13340
|
}
|
|
12886
13341
|
|
|
12887
13342
|
// src/host/fetch-proxy-transport.ts
|
|
12888
|
-
var
|
|
13343
|
+
var import_node_crypto11 = require("node:crypto");
|
|
12889
13344
|
var import_node_http22 = require("node:http2");
|
|
12890
13345
|
var import_x509 = require("@peculiar/x509");
|
|
12891
13346
|
async function startFetchProxyTransport() {
|
|
@@ -12893,7 +13348,7 @@ async function startFetchProxyTransport() {
|
|
|
12893
13348
|
const keys = await crypto.subtle.generateKey(algorithm, true, ["sign", "verify"]);
|
|
12894
13349
|
const certificate = await import_x509.X509CertificateGenerator.createSelfSigned(
|
|
12895
13350
|
{
|
|
12896
|
-
serialNumber: (0,
|
|
13351
|
+
serialNumber: (0, import_node_crypto11.randomBytes)(16).toString("hex"),
|
|
12897
13352
|
name: "CN=localhost",
|
|
12898
13353
|
notBefore: new Date(Date.now() - 6e4),
|
|
12899
13354
|
notAfter: new Date(Date.now() + 365 * 24 * 60 * 6e4),
|
|
@@ -12906,7 +13361,7 @@ async function startFetchProxyTransport() {
|
|
|
12906
13361
|
crypto
|
|
12907
13362
|
);
|
|
12908
13363
|
const privateKey = Buffer.from(await crypto.subtle.exportKey("pkcs8", keys.privateKey));
|
|
12909
|
-
const spki = (0,
|
|
13364
|
+
const spki = (0, import_node_crypto11.createHash)("sha256").update(Buffer.from(await crypto.subtle.exportKey("spki", keys.publicKey))).digest("base64");
|
|
12910
13365
|
const sessions = /* @__PURE__ */ new Set();
|
|
12911
13366
|
const server = (0, import_node_http22.createSecureServer)(
|
|
12912
13367
|
{
|
|
@@ -13028,8 +13483,8 @@ async function openUrl(url, options = {}) {
|
|
|
13028
13483
|
}
|
|
13029
13484
|
|
|
13030
13485
|
// src/host/plane-host.ts
|
|
13031
|
-
var
|
|
13032
|
-
var
|
|
13486
|
+
var import_node_fs23 = __toESM(require("node:fs"), 1);
|
|
13487
|
+
var import_node_path24 = __toESM(require("node:path"), 1);
|
|
13033
13488
|
|
|
13034
13489
|
// ../peach-box/src/planeProtocol.ts
|
|
13035
13490
|
var PLANE_FLAG_READ_ONLY = 1;
|
|
@@ -13108,9 +13563,9 @@ async function dispatchPlaneCommand(plane, type, msg, mutationOptions) {
|
|
|
13108
13563
|
}
|
|
13109
13564
|
|
|
13110
13565
|
// cli/commands/box/checkout-plane.ts
|
|
13111
|
-
var
|
|
13112
|
-
var
|
|
13113
|
-
var
|
|
13566
|
+
var import_node_child_process10 = require("node:child_process");
|
|
13567
|
+
var import_node_fs22 = __toESM(require("node:fs"), 1);
|
|
13568
|
+
var import_node_path23 = __toESM(require("node:path"), 1);
|
|
13114
13569
|
var CheckoutRequiresGitError = class extends Error {
|
|
13115
13570
|
};
|
|
13116
13571
|
var BINARY_SNIFF_BYTES = 8192;
|
|
@@ -13121,14 +13576,14 @@ function looksBinary(filePath, size) {
|
|
|
13121
13576
|
if (size === 0) return false;
|
|
13122
13577
|
let fd;
|
|
13123
13578
|
try {
|
|
13124
|
-
fd =
|
|
13579
|
+
fd = import_node_fs22.default.openSync(filePath, "r");
|
|
13125
13580
|
const buffer = Buffer.alloc(Math.min(BINARY_SNIFF_BYTES, size));
|
|
13126
|
-
const read =
|
|
13581
|
+
const read = import_node_fs22.default.readSync(fd, buffer, 0, buffer.length, 0);
|
|
13127
13582
|
return buffer.subarray(0, read).includes(0);
|
|
13128
13583
|
} catch {
|
|
13129
13584
|
return false;
|
|
13130
13585
|
} finally {
|
|
13131
|
-
if (fd !== void 0)
|
|
13586
|
+
if (fd !== void 0) import_node_fs22.default.closeSync(fd);
|
|
13132
13587
|
}
|
|
13133
13588
|
}
|
|
13134
13589
|
var CheckoutFilePlane = class {
|
|
@@ -13141,7 +13596,7 @@ var CheckoutFilePlane = class {
|
|
|
13141
13596
|
listTimeoutMs;
|
|
13142
13597
|
trackedOnly;
|
|
13143
13598
|
constructor(root, options = {}) {
|
|
13144
|
-
this.root =
|
|
13599
|
+
this.root = import_node_path23.default.resolve(root);
|
|
13145
13600
|
this.listTimeoutMs = options.listTimeoutMs ?? LIST_FILES_TIMEOUT_MS;
|
|
13146
13601
|
this.trackedOnly = options.trackedOnly ?? false;
|
|
13147
13602
|
}
|
|
@@ -13150,7 +13605,7 @@ var CheckoutFilePlane = class {
|
|
|
13150
13605
|
}
|
|
13151
13606
|
listFiles() {
|
|
13152
13607
|
const args = this.trackedOnly ? ["ls-files", "-z"] : ["ls-files", "-co", "--exclude-standard", "-z"];
|
|
13153
|
-
const stdout = (0,
|
|
13608
|
+
const stdout = (0, import_node_child_process10.execFileSync)("git", args, {
|
|
13154
13609
|
cwd: this.root,
|
|
13155
13610
|
encoding: "utf8",
|
|
13156
13611
|
maxBuffer: 64 * 1024 * 1024,
|
|
@@ -13203,13 +13658,13 @@ var CheckoutFilePlane = class {
|
|
|
13203
13658
|
if (!relative2) continue;
|
|
13204
13659
|
let stat2;
|
|
13205
13660
|
try {
|
|
13206
|
-
stat2 =
|
|
13661
|
+
stat2 = import_node_fs22.default.statSync(import_node_path23.default.join(this.root, relative2));
|
|
13207
13662
|
} catch {
|
|
13208
13663
|
continue;
|
|
13209
13664
|
}
|
|
13210
13665
|
if (!stat2.isFile()) continue;
|
|
13211
13666
|
const seen = this.sniffed.get(relative2);
|
|
13212
|
-
const binary = seen && seen.size === stat2.size && seen.mtimeMs === stat2.mtimeMs ? seen.binary : looksBinary(
|
|
13667
|
+
const binary = seen && seen.size === stat2.size && seen.mtimeMs === stat2.mtimeMs ? seen.binary : looksBinary(import_node_path23.default.join(this.root, relative2), stat2.size);
|
|
13213
13668
|
nextSniffed.set(relative2, { size: stat2.size, mtimeMs: stat2.mtimeMs, binary });
|
|
13214
13669
|
next.set(relative2, {
|
|
13215
13670
|
size: stat2.size,
|
|
@@ -13223,22 +13678,22 @@ var CheckoutFilePlane = class {
|
|
|
13223
13678
|
this.sniffed = nextSniffed;
|
|
13224
13679
|
}
|
|
13225
13680
|
absolute(planePath) {
|
|
13226
|
-
const resolved =
|
|
13227
|
-
if (resolved !== this.root && !resolved.startsWith(`${this.root}${
|
|
13681
|
+
const resolved = import_node_path23.default.resolve(this.root, planePath);
|
|
13682
|
+
if (resolved !== this.root && !resolved.startsWith(`${this.root}${import_node_path23.default.sep}`)) {
|
|
13228
13683
|
throw new Error(`path escapes the project: ${planePath}`);
|
|
13229
13684
|
}
|
|
13230
13685
|
return resolved;
|
|
13231
13686
|
}
|
|
13232
13687
|
async read(planePath) {
|
|
13233
|
-
return
|
|
13688
|
+
return import_node_fs22.default.promises.readFile(this.absolute(planePath), "utf8");
|
|
13234
13689
|
}
|
|
13235
13690
|
async readBytes(planePath) {
|
|
13236
|
-
return
|
|
13691
|
+
return import_node_fs22.default.promises.readFile(this.absolute(planePath));
|
|
13237
13692
|
}
|
|
13238
13693
|
async write(planePath, content) {
|
|
13239
13694
|
const absolute = this.absolute(planePath);
|
|
13240
|
-
await
|
|
13241
|
-
await
|
|
13695
|
+
await import_node_fs22.default.promises.mkdir(import_node_path23.default.dirname(absolute), { recursive: true });
|
|
13696
|
+
await import_node_fs22.default.promises.writeFile(absolute, content);
|
|
13242
13697
|
this.entries.set(planePath, {
|
|
13243
13698
|
size: content.byteLength,
|
|
13244
13699
|
readOnly: false,
|
|
@@ -13247,7 +13702,7 @@ var CheckoutFilePlane = class {
|
|
|
13247
13702
|
});
|
|
13248
13703
|
}
|
|
13249
13704
|
async delete(planePath) {
|
|
13250
|
-
await
|
|
13705
|
+
await import_node_fs22.default.promises.rm(this.absolute(planePath), { force: true });
|
|
13251
13706
|
this.entries.delete(planePath);
|
|
13252
13707
|
}
|
|
13253
13708
|
};
|
|
@@ -13265,12 +13720,12 @@ var PlaneHost = class {
|
|
|
13265
13720
|
/** handle a plane:* message. returns true iff it was one. */
|
|
13266
13721
|
async handleMessage(ws, msg) {
|
|
13267
13722
|
if (typeof msg !== "object" || msg === null) return false;
|
|
13268
|
-
const
|
|
13269
|
-
const type =
|
|
13723
|
+
const record2 = { ...msg };
|
|
13724
|
+
const type = record2.type;
|
|
13270
13725
|
if (typeof type !== "string" || !type.startsWith("plane:")) return false;
|
|
13271
|
-
const id =
|
|
13726
|
+
const id = record2.id;
|
|
13272
13727
|
try {
|
|
13273
|
-
this.respond(ws, id, await this.dispatch(ws, type,
|
|
13728
|
+
this.respond(ws, id, await this.dispatch(ws, type, record2));
|
|
13274
13729
|
} catch (err) {
|
|
13275
13730
|
const code = err instanceof PlaneNotRegisteredError ? "plane-not-registered" : void 0;
|
|
13276
13731
|
this.respondError(ws, id, err instanceof Error ? err.message : String(err), code);
|
|
@@ -13373,14 +13828,14 @@ var PlaneHost = class {
|
|
|
13373
13828
|
// root and an opened one cannot disagree about the same directory.
|
|
13374
13829
|
realRoot(root) {
|
|
13375
13830
|
if (!root) throw new Error("root is required");
|
|
13376
|
-
const resolved =
|
|
13831
|
+
const resolved = import_node_path24.default.resolve(root);
|
|
13377
13832
|
let real;
|
|
13378
13833
|
try {
|
|
13379
|
-
real =
|
|
13834
|
+
real = import_node_fs23.default.realpathSync(resolved);
|
|
13380
13835
|
} catch {
|
|
13381
13836
|
throw new Error(`no such directory: ${resolved}`);
|
|
13382
13837
|
}
|
|
13383
|
-
if (!
|
|
13838
|
+
if (!import_node_fs23.default.statSync(real).isDirectory()) throw new Error(`not a directory: ${real}`);
|
|
13384
13839
|
return real;
|
|
13385
13840
|
}
|
|
13386
13841
|
respond(ws, id, result) {
|
|
@@ -13400,9 +13855,9 @@ var PlaneHost = class {
|
|
|
13400
13855
|
};
|
|
13401
13856
|
|
|
13402
13857
|
// src/host/replacement-module-handler.ts
|
|
13403
|
-
var
|
|
13858
|
+
var import_node_fs24 = require("node:fs");
|
|
13404
13859
|
var import_promises5 = __toESM(require("node:fs/promises"), 1);
|
|
13405
|
-
var
|
|
13860
|
+
var import_node_path25 = __toESM(require("node:path"), 1);
|
|
13406
13861
|
|
|
13407
13862
|
// ../contrast-bundler/src/replacementModule.ts
|
|
13408
13863
|
var import_dist = require("sucrase/dist/index.js");
|
|
@@ -13730,16 +14185,16 @@ function sendJavaScript(req, res, source) {
|
|
|
13730
14185
|
res.end(req.method === "HEAD" ? void 0 : source);
|
|
13731
14186
|
}
|
|
13732
14187
|
function resolveReplacementModuleFile(fromFile, specifier) {
|
|
13733
|
-
const base =
|
|
14188
|
+
const base = import_node_path25.default.resolve(import_node_path25.default.dirname(fromFile), specifier);
|
|
13734
14189
|
const candidates = [
|
|
13735
14190
|
...REPLACEMENT_MODULE_EXTENSIONS.some(
|
|
13736
|
-
(ext) => ext ===
|
|
14191
|
+
(ext) => ext === import_node_path25.default.extname(base).toLowerCase()
|
|
13737
14192
|
) ? [base] : [],
|
|
13738
14193
|
...REPLACEMENT_MODULE_EXTENSIONS.map((ext) => base + ext),
|
|
13739
|
-
...REPLACEMENT_MODULE_EXTENSIONS.map((ext) =>
|
|
14194
|
+
...REPLACEMENT_MODULE_EXTENSIONS.map((ext) => import_node_path25.default.join(base, `index${ext}`))
|
|
13740
14195
|
];
|
|
13741
14196
|
const found = candidates.find(
|
|
13742
|
-
(candidate) => (0,
|
|
14197
|
+
(candidate) => (0, import_node_fs24.statSync)(candidate, { throwIfNoEntry: false })?.isFile()
|
|
13743
14198
|
);
|
|
13744
14199
|
if (!found) {
|
|
13745
14200
|
throw new Error(
|
|
@@ -13794,13 +14249,13 @@ async function handleReplacementModuleRequest(req, res, options = {}) {
|
|
|
13794
14249
|
res.end("missing path param");
|
|
13795
14250
|
return true;
|
|
13796
14251
|
}
|
|
13797
|
-
const extension =
|
|
14252
|
+
const extension = import_node_path25.default.extname(targetPath).toLowerCase();
|
|
13798
14253
|
if (!REPLACEMENT_MODULE_EXTENSIONS.some((allowed) => allowed === extension)) {
|
|
13799
14254
|
res.writeHead(400, { "Content-Type": "text/plain; charset=utf-8" });
|
|
13800
14255
|
res.end(`replacement files must be ${REPLACEMENT_MODULE_EXTENSIONS.join(", ")}`);
|
|
13801
14256
|
return true;
|
|
13802
14257
|
}
|
|
13803
|
-
if (!
|
|
14258
|
+
if (!import_node_path25.default.isAbsolute(targetPath)) {
|
|
13804
14259
|
res.writeHead(400, { "Content-Type": "text/plain; charset=utf-8" });
|
|
13805
14260
|
res.end("replacement file path must be absolute");
|
|
13806
14261
|
return true;
|
|
@@ -13808,10 +14263,10 @@ async function handleReplacementModuleRequest(req, res, options = {}) {
|
|
|
13808
14263
|
const runtimePackages = new Set(url.searchParams.getAll("runtimePackage"));
|
|
13809
14264
|
let resolvedProjectRoot;
|
|
13810
14265
|
if (options.projectRoot) {
|
|
13811
|
-
const lexicalProjectRoot =
|
|
14266
|
+
const lexicalProjectRoot = import_node_path25.default.resolve(options.projectRoot);
|
|
13812
14267
|
resolvedProjectRoot = await import_promises5.default.realpath(options.projectRoot);
|
|
13813
|
-
const lexicalTarget =
|
|
13814
|
-
if (lexicalTarget.startsWith("..") ||
|
|
14268
|
+
const lexicalTarget = import_node_path25.default.relative(lexicalProjectRoot, targetPath);
|
|
14269
|
+
if (lexicalTarget.startsWith("..") || import_node_path25.default.isAbsolute(lexicalTarget)) {
|
|
13815
14270
|
res.writeHead(403, { "Content-Type": "text/plain; charset=utf-8" });
|
|
13816
14271
|
res.end("replacement file must be inside the project root");
|
|
13817
14272
|
return true;
|
|
@@ -13827,8 +14282,8 @@ async function handleReplacementModuleRequest(req, res, options = {}) {
|
|
|
13827
14282
|
return true;
|
|
13828
14283
|
}
|
|
13829
14284
|
if (resolvedProjectRoot) {
|
|
13830
|
-
const relativeTarget =
|
|
13831
|
-
if (relativeTarget.startsWith("..") ||
|
|
14285
|
+
const relativeTarget = import_node_path25.default.relative(resolvedProjectRoot, resolvedTargetPath);
|
|
14286
|
+
if (relativeTarget.startsWith("..") || import_node_path25.default.isAbsolute(relativeTarget)) {
|
|
13832
14287
|
res.writeHead(403, { "Content-Type": "text/plain; charset=utf-8" });
|
|
13833
14288
|
res.end("replacement file must be inside the project root");
|
|
13834
14289
|
return true;
|
|
@@ -13854,9 +14309,7 @@ async function handleReplacementModuleRequest(req, res, options = {}) {
|
|
|
13854
14309
|
sendJavaScript(
|
|
13855
14310
|
req,
|
|
13856
14311
|
res,
|
|
13857
|
-
|
|
13858
|
-
//# sourceMappingURL=data:application/json;base64,${map}
|
|
13859
|
-
`
|
|
14312
|
+
compiled.code + "\n//# sourceMappingURL=data:application/json;base64," + map + "\n"
|
|
13860
14313
|
);
|
|
13861
14314
|
} catch (error) {
|
|
13862
14315
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -15278,8 +15731,8 @@ var SootSimBridgeHost = class _SootSimBridgeHost {
|
|
|
15278
15731
|
for await (const chunk of req) {
|
|
15279
15732
|
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
15280
15733
|
}
|
|
15281
|
-
const
|
|
15282
|
-
const parsed =
|
|
15734
|
+
const text2 = Buffer.concat(chunks).toString("utf8").trim();
|
|
15735
|
+
const parsed = text2 ? JSON.parse(text2) : {};
|
|
15283
15736
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
15284
15737
|
throw new Error("send to box needs a json object body");
|
|
15285
15738
|
}
|