peachsim 0.1.759 → 0.1.760
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/agent-identity.cjs +1 -1
- package/dist-lib/agent-sessions.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -1
- package/dist-lib/auth/shared-session.cjs +1 -1
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/beta.cjs +1 -1
- package/dist-lib/beta.mjs +1 -1
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/bridge-contract-input.cjs +1 -1
- package/dist-lib/bridge-contract-input.mjs +1 -1
- package/dist-lib/bridge-contract.cjs +1 -1
- package/dist-lib/bridge-contract.mjs +1 -1
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +1 -1
- package/dist-lib/cli-constants.cjs +1 -1
- package/dist-lib/cloud-contract.cjs +1 -1
- package/dist-lib/cloud-contract.mjs +1 -1
- package/dist-lib/cloud-test-args.cjs +1 -1
- package/dist-lib/cloud-test-args.mjs +1 -1
- package/dist-lib/cloud.cjs +1 -1
- package/dist-lib/cloud.mjs +1 -1
- package/dist-lib/config.cjs +1 -1
- package/dist-lib/detox/index.cjs +1 -1
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +823 -728
- package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
- package/dist-lib/host/replacement-module-handler.cjs +1 -1
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +37 -220
- package/dist-lib/jump-to-source-babel.cjs +1 -1
- package/dist-lib/jump-to-source-native.cjs +1 -1
- package/dist-lib/kotlin-host.cjs +1 -1
- package/dist-lib/menu.cjs +1 -1
- package/dist-lib/menu.mjs +1 -1
- package/dist-lib/metro-fingerprint-registry.cjs +1 -1
- package/dist-lib/metro-fingerprint-registry.mjs +1 -1
- package/dist-lib/metro-production-bundle.cjs +1 -1
- package/dist-lib/metro-production-bundle.mjs +1 -1
- package/dist-lib/metro.cjs +37 -220
- package/dist-lib/native-app-identity.cjs +1 -1
- package/dist-lib/native-app-identity.mjs +1 -1
- package/dist-lib/native-firebase-metadata.cjs +1 -1
- package/dist-lib/native-firebase-metadata.mjs +1 -1
- package/dist-lib/plist.cjs +1 -1
- package/dist-lib/plist.mjs +1 -1
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +1 -1
- package/dist-lib/render-mode.cjs +1 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
- package/dist-lib/sdk.cjs +1 -1
- package/dist-lib/sdk.mjs +1 -1
- package/dist-lib/skills.cjs +1120 -1019
- package/dist-lib/swift-compile.cjs +1 -1
- package/dist-lib/swift-compile.mjs +1 -1
- package/dist-lib/swift-package.cjs +1 -110
- package/dist-lib/swift-package.mjs +1 -109
- package/dist-lib/swift-submit.cjs +1 -1
- package/dist-lib/swift-submit.mjs +1 -1
- package/dist-lib/swift-toolchain.cjs +1 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +607 -512
- package/dist-lib/vite.cjs +1 -1
- package/package.json +1 -1
- package/src/native-seam-manifest.ts +8 -0
- package/src/swift-host.ts +64 -64
- package/src/swift-package-manifest.ts +307 -0
- package/src/swift-package.ts +2 -135
- package/src/swift-packages.ts +341 -0
- package/src/xcode-project.ts +57 -70
- package/src/swift-remote-packages.ts +0 -255
|
@@ -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;
|
|
@@ -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;
|
|
@@ -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,8 +4300,8 @@ 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 text2 = readProjectMetadata(
|
|
4303
|
+
function readProjectJson(path22) {
|
|
4304
|
+
const text2 = readProjectMetadata(path22);
|
|
4305
4305
|
if (text2 === null) return null;
|
|
4306
4306
|
try {
|
|
4307
4307
|
const value = JSON.parse(text2);
|
|
@@ -4311,9 +4311,9 @@ function readProjectJson(path21) {
|
|
|
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,16 +4324,16 @@ 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
|
-
|
|
4335
|
+
import_node_fs25 = require("node:fs");
|
|
4336
|
+
import_node_path26 = require("node:path");
|
|
4337
4337
|
import_json52 = __toESM(require("json5"), 1);
|
|
4338
4338
|
import_yaml = require("yaml");
|
|
4339
4339
|
CONFIG_EXTENSIONS = ["ts", "js", "cjs", "mjs", "mts", "cts"];
|
|
@@ -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) {
|
|
@@ -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, path21, 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 items2 = [];
|
|
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
|
-
items2.push(item.trim());
|
|
6605
|
-
item = "";
|
|
6606
|
-
continue;
|
|
6607
|
-
}
|
|
6608
|
-
item += ch;
|
|
6609
|
-
}
|
|
6610
|
-
if (item.trim()) items2.push(item.trim());
|
|
6611
|
-
return items2;
|
|
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 = [];
|
|
@@ -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,8 +8576,8 @@ 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
8583
|
function providesNamespace(text2) {
|
|
@@ -8711,13 +8604,13 @@ 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;
|
|
@@ -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,7 +8665,7 @@ 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;
|
|
@@ -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,12 +9358,12 @@ 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
|
|
|
9246
9365
|
// src/xcode-json-project.ts
|
|
9247
|
-
var
|
|
9366
|
+
var import_node_path15 = __toESM(require("node:path"), 1);
|
|
9248
9367
|
var import_json5 = __toESM(require("json5"), 1);
|
|
9249
9368
|
var isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9250
9369
|
var text = (value) => typeof value === "string" ? value : void 0;
|
|
@@ -9260,7 +9379,7 @@ var PHASE_ISA = {
|
|
|
9260
9379
|
function readXcodeJsonProject(xcodeproj, source) {
|
|
9261
9380
|
const json = import_json5.default.parse(source);
|
|
9262
9381
|
if (!isJsonObject(json)) throw new Error(`${xcodeproj}/project.xcproj is not an object`);
|
|
9263
|
-
const projectDir =
|
|
9382
|
+
const projectDir = import_node_path15.default.dirname(xcodeproj);
|
|
9264
9383
|
const objects = {};
|
|
9265
9384
|
let next = 0;
|
|
9266
9385
|
const add = (entry, id) => {
|
|
@@ -9273,7 +9392,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
9273
9392
|
const base = /^<([A-Z]+)>\/(.*)$/.exec(raw2);
|
|
9274
9393
|
if (base) {
|
|
9275
9394
|
if (base[1] === "PROJECT")
|
|
9276
|
-
return { sourceTree: "<absolute>", path:
|
|
9395
|
+
return { sourceTree: "<absolute>", path: import_node_path15.default.join(projectDir, base[2]) };
|
|
9277
9396
|
if (base[1] === "PRODUCTS")
|
|
9278
9397
|
return { sourceTree: "BUILT_PRODUCTS_DIR", path: base[2] };
|
|
9279
9398
|
return null;
|
|
@@ -9281,7 +9400,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
9281
9400
|
const unescaped = raw2.replaceAll("\\<", "<");
|
|
9282
9401
|
if (unescaped.startsWith("/")) return { sourceTree: "<absolute>", path: unescaped };
|
|
9283
9402
|
if (unescaped.startsWith("~")) return null;
|
|
9284
|
-
return groupDir === null ? null : { sourceTree: "<absolute>", path:
|
|
9403
|
+
return groupDir === null ? null : { sourceTree: "<absolute>", path: import_node_path15.default.join(groupDir, unescaped) };
|
|
9285
9404
|
};
|
|
9286
9405
|
const memberships = [];
|
|
9287
9406
|
const folders = [];
|
|
@@ -9292,7 +9411,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
9292
9411
|
const kind = text(entry.kind) ?? "file-reference";
|
|
9293
9412
|
const raw2 = text(entry.path) ?? "";
|
|
9294
9413
|
const located = raw2 === "" ? null : locate(raw2, parent.dir);
|
|
9295
|
-
const name2 = text(entry.name) ??
|
|
9414
|
+
const name2 = text(entry.name) ?? import_node_path15.default.basename(raw2);
|
|
9296
9415
|
const node = { id: "", name: name2, dir: null, parent, children: [] };
|
|
9297
9416
|
if (kind === "group" || kind === "variant-group" || kind === "version-group") {
|
|
9298
9417
|
node.dir = raw2 === "" ? parent.dir : located?.sourceTree === "<absolute>" ? located.path : null;
|
|
@@ -9407,7 +9526,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
9407
9526
|
if (!isObject(entry)) continue;
|
|
9408
9527
|
const repository = text(entry.repository);
|
|
9409
9528
|
const local = text(entry.path);
|
|
9410
|
-
const name2 = local !== void 0 ?
|
|
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$/, "");
|
|
9411
9530
|
const id = text(entry.kind) === "local" && local !== void 0 ? add({ isa: "XCLocalSwiftPackageReference", relativePath: local }) : add({ isa: "XCRemoteSwiftPackageReference", repositoryURL: repository ?? "" });
|
|
9412
9531
|
packageIds.set(name2.toLowerCase(), id);
|
|
9413
9532
|
}
|
|
@@ -9684,28 +9803,28 @@ var CONDITIONS = {
|
|
|
9684
9803
|
variant: "normal"
|
|
9685
9804
|
};
|
|
9686
9805
|
function walkFiles(dir) {
|
|
9687
|
-
if (!
|
|
9806
|
+
if (!import_node_fs15.default.existsSync(dir)) return [];
|
|
9688
9807
|
const out = [];
|
|
9689
|
-
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))) {
|
|
9690
9809
|
if (entry.name.startsWith(".")) continue;
|
|
9691
|
-
const full =
|
|
9810
|
+
const full = import_node_path16.default.join(dir, entry.name);
|
|
9692
9811
|
if (entry.isDirectory()) out.push(...walkFiles(full));
|
|
9693
9812
|
else if (entry.isFile()) out.push(full);
|
|
9694
9813
|
}
|
|
9695
9814
|
return out;
|
|
9696
9815
|
}
|
|
9697
|
-
var isDirectory = (dir) =>
|
|
9816
|
+
var isDirectory = (dir) => import_node_fs15.default.existsSync(dir) && import_node_fs15.default.statSync(dir).isDirectory();
|
|
9698
9817
|
function readXcconfig(file, seen = /* @__PURE__ */ new Set()) {
|
|
9699
|
-
if (seen.has(file) || !
|
|
9818
|
+
if (seen.has(file) || !import_node_fs15.default.existsSync(file)) return {};
|
|
9700
9819
|
seen.add(file);
|
|
9701
9820
|
const settings = {};
|
|
9702
|
-
for (const raw2 of
|
|
9821
|
+
for (const raw2 of import_node_fs15.default.readFileSync(file, "utf8").split("\n")) {
|
|
9703
9822
|
const line = raw2.replace(/\/\/.*$/, "").trim();
|
|
9704
9823
|
const include = /^#include\??\s+"([^"]+)"/.exec(line);
|
|
9705
9824
|
if (include) {
|
|
9706
9825
|
Object.assign(
|
|
9707
9826
|
settings,
|
|
9708
|
-
readXcconfig(
|
|
9827
|
+
readXcconfig(import_node_path16.default.resolve(import_node_path16.default.dirname(file), include[1]), seen)
|
|
9709
9828
|
);
|
|
9710
9829
|
continue;
|
|
9711
9830
|
}
|
|
@@ -9755,22 +9874,22 @@ function decodeXml(text2) {
|
|
|
9755
9874
|
return text2.replaceAll(""", '"').replaceAll("'", "'").replaceAll("<", "<").replaceAll(">", ">").replaceAll("&", "&");
|
|
9756
9875
|
}
|
|
9757
9876
|
function workspaceReferences(workspace) {
|
|
9758
|
-
const data =
|
|
9759
|
-
if (!
|
|
9877
|
+
const data = import_node_path16.default.join(workspace, "contents.xcworkspacedata");
|
|
9878
|
+
if (!import_node_fs15.default.existsSync(data))
|
|
9760
9879
|
throw new Error(`${workspace} has no contents.xcworkspacedata`);
|
|
9761
|
-
const container =
|
|
9880
|
+
const container = import_node_path16.default.dirname(workspace);
|
|
9762
9881
|
const locate = (location2, base) => {
|
|
9763
9882
|
const colon = location2.indexOf(":");
|
|
9764
9883
|
const kind = location2.slice(0, colon);
|
|
9765
9884
|
const rest = location2.slice(colon + 1);
|
|
9766
|
-
if (kind === "group") return
|
|
9767
|
-
if (kind === "container" || kind === "self") return
|
|
9768
|
-
if (kind === "absolute") return
|
|
9769
|
-
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}`);
|
|
9770
9889
|
};
|
|
9771
9890
|
const groups = [container];
|
|
9772
9891
|
const references = [];
|
|
9773
|
-
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)) {
|
|
9774
9893
|
if (closing) {
|
|
9775
9894
|
if (tag === "Group") groups.pop();
|
|
9776
9895
|
continue;
|
|
@@ -9786,8 +9905,8 @@ function workspaceReferences(workspace) {
|
|
|
9786
9905
|
var loaded = /* @__PURE__ */ new Map();
|
|
9787
9906
|
function xcodeProjectFile(xcodeproj) {
|
|
9788
9907
|
for (const name2 of ["project.pbxproj", "project.xcproj"]) {
|
|
9789
|
-
const file =
|
|
9790
|
-
if (
|
|
9908
|
+
const file = import_node_path16.default.join(xcodeproj, name2);
|
|
9909
|
+
if (import_node_fs15.default.existsSync(file)) return file;
|
|
9791
9910
|
}
|
|
9792
9911
|
return null;
|
|
9793
9912
|
}
|
|
@@ -9795,10 +9914,10 @@ function loadProject(xcodeproj) {
|
|
|
9795
9914
|
const projectFile = xcodeProjectFile(xcodeproj);
|
|
9796
9915
|
if (!projectFile)
|
|
9797
9916
|
throw new Error(`${xcodeproj} has no project.pbxproj or project.xcproj`);
|
|
9798
|
-
const mtimeMs =
|
|
9917
|
+
const mtimeMs = import_node_fs15.default.statSync(projectFile).mtimeMs;
|
|
9799
9918
|
const cached3 = loaded.get(projectFile);
|
|
9800
9919
|
if (cached3?.mtimeMs === mtimeMs) return cached3.project;
|
|
9801
|
-
const source =
|
|
9920
|
+
const source = import_node_fs15.default.readFileSync(projectFile, "utf8");
|
|
9802
9921
|
const root = projectFile.endsWith(".xcproj") ? readXcodeJsonProject(xcodeproj, source) : parseOpenStepPlist(source);
|
|
9803
9922
|
if (!isDict(root) || !isDict(root.objects)) {
|
|
9804
9923
|
throw new Error(`${projectFile} has no objects table`);
|
|
@@ -9812,8 +9931,8 @@ function loadProject(xcodeproj) {
|
|
|
9812
9931
|
if (!project || project.isa !== "PBXProject") {
|
|
9813
9932
|
throw new Error(`${projectFile} has no PBXProject root`);
|
|
9814
9933
|
}
|
|
9815
|
-
const projectDir =
|
|
9816
|
-
|
|
9934
|
+
const projectDir = import_node_fs15.default.realpathSync(
|
|
9935
|
+
import_node_path16.default.resolve(import_node_path16.default.dirname(xcodeproj), str(project.projectDirPath) ?? "")
|
|
9817
9936
|
);
|
|
9818
9937
|
const parent = /* @__PURE__ */ new Map();
|
|
9819
9938
|
for (const [id, entry] of Object.entries(objects)) {
|
|
@@ -9831,11 +9950,11 @@ function loadProject(xcodeproj) {
|
|
|
9831
9950
|
const own = str(entry.path) ?? "";
|
|
9832
9951
|
const tree = str(entry.sourceTree) ?? "<group>";
|
|
9833
9952
|
if (tree === "<absolute>") result2 = own;
|
|
9834
|
-
else if (tree === "SOURCE_ROOT") result2 =
|
|
9953
|
+
else if (tree === "SOURCE_ROOT") result2 = import_node_path16.default.join(projectDir, own);
|
|
9835
9954
|
else if (tree === "<group>") {
|
|
9836
9955
|
const up = parent.get(id);
|
|
9837
9956
|
const base = up ? resolvePath(up) : projectDir;
|
|
9838
|
-
result2 = base === null ? null :
|
|
9957
|
+
result2 = base === null ? null : import_node_path16.default.join(base, own);
|
|
9839
9958
|
}
|
|
9840
9959
|
}
|
|
9841
9960
|
resolvedPaths.set(id, result2);
|
|
@@ -9935,7 +10054,7 @@ function targetMembers(ref) {
|
|
|
9935
10054
|
const addResource = (file) => {
|
|
9936
10055
|
if (isDirectory(file)) {
|
|
9937
10056
|
for (const inner of walkFiles(file)) resources.add(inner);
|
|
9938
|
-
} else if (
|
|
10057
|
+
} else if (import_node_fs15.default.existsSync(file)) resources.add(file);
|
|
9939
10058
|
};
|
|
9940
10059
|
const fileRefPaths = (refId) => {
|
|
9941
10060
|
const entry = project.object(refId);
|
|
@@ -9956,7 +10075,7 @@ function targetMembers(ref) {
|
|
|
9956
10075
|
for (const buildFileId of list(phase.files)) {
|
|
9957
10076
|
for (const file of fileRefPaths(str(project.object(buildFileId)?.fileRef) ?? "")) {
|
|
9958
10077
|
if (phase.isa === "PBXSourcesBuildPhase") {
|
|
9959
|
-
if (!
|
|
10078
|
+
if (!import_node_fs15.default.existsSync(file)) continue;
|
|
9960
10079
|
allSources.add(file);
|
|
9961
10080
|
if (file.endsWith(".swift")) sources.add(file);
|
|
9962
10081
|
} else if (phase.isa === "PBXResourcesBuildPhase") addResource(file);
|
|
@@ -9964,7 +10083,7 @@ function targetMembers(ref) {
|
|
|
9964
10083
|
}
|
|
9965
10084
|
}
|
|
9966
10085
|
const addSynchronized = (folder, relative2) => {
|
|
9967
|
-
const file =
|
|
10086
|
+
const file = import_node_path16.default.join(folder, relative2);
|
|
9968
10087
|
if (NEVER_MEMBER.test(relative2)) return;
|
|
9969
10088
|
if (file.endsWith(".swift")) {
|
|
9970
10089
|
if (!relative2.split("/").some((segment) => BUNDLE_DIR.test(segment))) {
|
|
@@ -9989,7 +10108,7 @@ function targetMembers(ref) {
|
|
|
9989
10108
|
}
|
|
9990
10109
|
if (owned.has(groupId)) {
|
|
9991
10110
|
for (const file of walkFiles(folder)) {
|
|
9992
|
-
const relative2 =
|
|
10111
|
+
const relative2 = import_node_path16.default.relative(folder, file).split(import_node_path16.default.sep).join("/");
|
|
9993
10112
|
if ([...exceptions].some(
|
|
9994
10113
|
(exception) => relative2 === exception || relative2.startsWith(`${exception}/`)
|
|
9995
10114
|
))
|
|
@@ -9998,14 +10117,14 @@ function targetMembers(ref) {
|
|
|
9998
10117
|
}
|
|
9999
10118
|
} else {
|
|
10000
10119
|
for (const relative2 of exceptions) {
|
|
10001
|
-
const file =
|
|
10120
|
+
const file = import_node_path16.default.join(folder, relative2);
|
|
10002
10121
|
if (isDirectory(file)) {
|
|
10003
10122
|
for (const inner of walkFiles(file))
|
|
10004
10123
|
addSynchronized(
|
|
10005
10124
|
folder,
|
|
10006
|
-
|
|
10125
|
+
import_node_path16.default.relative(folder, inner).split(import_node_path16.default.sep).join("/")
|
|
10007
10126
|
);
|
|
10008
|
-
} else if (
|
|
10127
|
+
} else if (import_node_fs15.default.existsSync(file)) addSynchronized(folder, relative2);
|
|
10009
10128
|
}
|
|
10010
10129
|
}
|
|
10011
10130
|
}
|
|
@@ -10018,8 +10137,8 @@ function targetMembers(ref) {
|
|
|
10018
10137
|
function commonAncestor(dirs) {
|
|
10019
10138
|
let common = dirs[0];
|
|
10020
10139
|
for (const dir of dirs) {
|
|
10021
|
-
while (common !==
|
|
10022
|
-
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);
|
|
10023
10142
|
}
|
|
10024
10143
|
return common;
|
|
10025
10144
|
}
|
|
@@ -10028,8 +10147,8 @@ function workspaceProjects(xcodeprojOrWorkspace) {
|
|
|
10028
10147
|
const projects2 = [];
|
|
10029
10148
|
const projectAt = /* @__PURE__ */ new Map();
|
|
10030
10149
|
const addProject = (xcodeproj) => {
|
|
10031
|
-
const key =
|
|
10032
|
-
if (projectAt.has(key) || key.split(
|
|
10150
|
+
const key = import_node_path16.default.resolve(xcodeproj);
|
|
10151
|
+
if (projectAt.has(key) || key.split(import_node_path16.default.sep).includes("Pods")) return;
|
|
10033
10152
|
if (!xcodeProjectFile(key)) return;
|
|
10034
10153
|
const project = loadProject(key);
|
|
10035
10154
|
projectAt.set(key, project);
|
|
@@ -10046,7 +10165,7 @@ function workspaceProjects(xcodeprojOrWorkspace) {
|
|
|
10046
10165
|
for (const reference of listed)
|
|
10047
10166
|
if (reference.endsWith(".xcodeproj")) addProject(reference);
|
|
10048
10167
|
if (projects2.length === 0) {
|
|
10049
|
-
throw new Error(`${
|
|
10168
|
+
throw new Error(`${import_node_path16.default.basename(xcodeprojOrWorkspace)} lists no Xcode project`);
|
|
10050
10169
|
}
|
|
10051
10170
|
return { listed, projects: projects2, projectAt };
|
|
10052
10171
|
}
|
|
@@ -10068,7 +10187,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
10068
10187
|
const allTargets = projects2.flatMap(nativeTargets);
|
|
10069
10188
|
const appTargets = allTargets.filter((ref) => ref.target.productType === APPLICATION);
|
|
10070
10189
|
const appTargetNames = appTargets.map((ref) => str(ref.target.name) ?? ref.id);
|
|
10071
|
-
const container =
|
|
10190
|
+
const container = import_node_path16.default.basename(xcodeprojOrWorkspace);
|
|
10072
10191
|
const named = targetName ? appTargets.filter((ref) => ref.target.name === targetName) : appTargets;
|
|
10073
10192
|
if (named.length !== 1) {
|
|
10074
10193
|
throw new Error(
|
|
@@ -10080,14 +10199,14 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
10080
10199
|
for (const ref of allTargets) {
|
|
10081
10200
|
const product = ref.project.object(str(ref.target.productReference));
|
|
10082
10201
|
const file = str(product?.path);
|
|
10083
|
-
if (file && !byProduct.has(
|
|
10084
|
-
byProduct.set(
|
|
10202
|
+
if (file && !byProduct.has(import_node_path16.default.basename(file)))
|
|
10203
|
+
byProduct.set(import_node_path16.default.basename(file), ref);
|
|
10085
10204
|
}
|
|
10086
10205
|
const proxied = (project, proxyId) => {
|
|
10087
10206
|
const proxy = project.object(proxyId);
|
|
10088
10207
|
if (proxy?.isa !== "PBXContainerItemProxy") return void 0;
|
|
10089
10208
|
const portal = str(proxy.containerPortal);
|
|
10090
|
-
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 ?? "") ?? ""));
|
|
10091
10210
|
const remote = str(proxy.remoteGlobalIDString);
|
|
10092
10211
|
if (!owner || !remote) return void 0;
|
|
10093
10212
|
return nativeTargets(owner).find(
|
|
@@ -10108,7 +10227,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
10108
10227
|
if (phase?.isa !== "PBXFrameworksBuildPhase") continue;
|
|
10109
10228
|
for (const buildFileId of list(phase.files)) {
|
|
10110
10229
|
const file = project.object(str(project.object(buildFileId)?.fileRef));
|
|
10111
|
-
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;
|
|
10112
10231
|
if (resolved) found.push(resolved);
|
|
10113
10232
|
}
|
|
10114
10233
|
}
|
|
@@ -10129,7 +10248,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
10129
10248
|
const name2 = str(ref.target.name) ?? ref.id;
|
|
10130
10249
|
const { get: settings2, keys } = targetSettings(ref, {
|
|
10131
10250
|
TARGET_NAME: name2,
|
|
10132
|
-
PROJECT_NAME:
|
|
10251
|
+
PROJECT_NAME: import_node_path16.default.basename(ref.project.xcodeproj, ".xcodeproj"),
|
|
10133
10252
|
SRCROOT: ref.project.projectDir,
|
|
10134
10253
|
SOURCE_ROOT: ref.project.projectDir,
|
|
10135
10254
|
PROJECT_DIR: ref.project.projectDir,
|
|
@@ -10160,8 +10279,8 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
10160
10279
|
}
|
|
10161
10280
|
return value;
|
|
10162
10281
|
};
|
|
10163
|
-
const infoPlistFile = settings("INFOPLIST_FILE") ?
|
|
10164
|
-
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")) : {};
|
|
10165
10284
|
if (!sourceInfo || typeof sourceInfo !== "object" || Array.isArray(sourceInfo) || sourceInfo instanceof Date || Buffer.isBuffer(sourceInfo)) {
|
|
10166
10285
|
throw new Error(`${module2.name} Info.plist must contain a dictionary`);
|
|
10167
10286
|
}
|
|
@@ -10179,34 +10298,17 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
10179
10298
|
};
|
|
10180
10299
|
}
|
|
10181
10300
|
const localPackageDirs = [
|
|
10182
|
-
...listed.filter((reference) =>
|
|
10301
|
+
...listed.filter((reference) => import_node_fs15.default.existsSync(import_node_path16.default.join(reference, "Package.swift"))),
|
|
10183
10302
|
...projects2.flatMap(
|
|
10184
10303
|
(project) => Object.entries(project.objects).flatMap(([id, entry]) => {
|
|
10185
10304
|
if (!isDict(entry)) return [];
|
|
10186
|
-
const candidate = entry.isa === "XCLocalSwiftPackageReference" ?
|
|
10187
|
-
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] : [];
|
|
10188
10307
|
})
|
|
10189
10308
|
)
|
|
10190
10309
|
];
|
|
10191
|
-
const
|
|
10192
|
-
const
|
|
10193
|
-
const cached3 = graphs.get(dir);
|
|
10194
|
-
if (cached3) return cached3;
|
|
10195
|
-
const graph = swiftManifestGraph(
|
|
10196
|
-
import_node_fs14.default.readFileSync(import_node_path15.default.join(dir, "Package.swift"), "utf8")
|
|
10197
|
-
);
|
|
10198
|
-
graphs.set(dir, graph);
|
|
10199
|
-
return graph;
|
|
10200
|
-
};
|
|
10201
|
-
const localProducts = /* @__PURE__ */ new Map();
|
|
10202
|
-
for (const dir of localPackageDirs) {
|
|
10203
|
-
for (const product of graphOf(dir).products.keys()) {
|
|
10204
|
-
if (!localProducts.has(product)) localProducts.set(product, dir);
|
|
10205
|
-
}
|
|
10206
|
-
}
|
|
10207
|
-
const localPackages = /* @__PURE__ */ new Set();
|
|
10208
|
-
const remoteProducts = [];
|
|
10209
|
-
const unresolvedProducts = [];
|
|
10310
|
+
const linkedProducts = [];
|
|
10311
|
+
const binaryFrameworks = /* @__PURE__ */ new Set();
|
|
10210
10312
|
for (const { project, target } of order) {
|
|
10211
10313
|
const productDependencies = [
|
|
10212
10314
|
...list(target.packageProductDependencies),
|
|
@@ -10218,45 +10320,37 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
10218
10320
|
for (const dependencyId of productDependencies) {
|
|
10219
10321
|
const dependency = project.object(dependencyId);
|
|
10220
10322
|
const product = str(dependency?.productName)?.replace(/^plugin:/, "");
|
|
10221
|
-
if (!dependency || !product)
|
|
10323
|
+
if (!dependency || !product || linkedProducts.some((entry) => entry.product === product))
|
|
10324
|
+
continue;
|
|
10222
10325
|
const reference = project.object(str(dependency.package));
|
|
10223
|
-
|
|
10224
|
-
|
|
10225
|
-
|
|
10226
|
-
|
|
10227
|
-
|
|
10228
|
-
|
|
10229
|
-
|
|
10230
|
-
|
|
10231
|
-
|
|
10232
|
-
|
|
10233
|
-
} else if (localProducts.has(product)) {
|
|
10234
|
-
localPackages.add(localProducts.get(product));
|
|
10235
|
-
} else if (!unresolvedProducts.includes(product)) unresolvedProducts.push(product);
|
|
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
|
+
});
|
|
10236
10336
|
}
|
|
10237
|
-
|
|
10238
|
-
|
|
10239
|
-
|
|
10240
|
-
|
|
10241
|
-
|
|
10242
|
-
|
|
10243
|
-
|
|
10244
|
-
|
|
10245
|
-
continue;
|
|
10246
|
-
|
|
10247
|
-
|
|
10248
|
-
|
|
10249
|
-
for (const dependencies of graph.dependencies.values()) {
|
|
10250
|
-
for (const dependency of dependencies) {
|
|
10251
|
-
if (dependency.kind !== "product") continue;
|
|
10252
|
-
const url = graph.packageURLs.get(dependency.package);
|
|
10253
|
-
if (url && !remoteProducts.some((entry) => entry.product === dependency.name))
|
|
10254
|
-
remoteProducts.push({ product: dependency.name, repositoryURL: url });
|
|
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);
|
|
10255
10349
|
}
|
|
10256
10350
|
}
|
|
10257
10351
|
}
|
|
10258
|
-
const resolvedFile =
|
|
10259
|
-
workspace ??
|
|
10352
|
+
const resolvedFile = import_node_path16.default.join(
|
|
10353
|
+
workspace ?? import_node_path16.default.join(xcodeprojOrWorkspace, "project.xcworkspace"),
|
|
10260
10354
|
"xcshareddata",
|
|
10261
10355
|
"swiftpm",
|
|
10262
10356
|
"Package.resolved"
|
|
@@ -10266,19 +10360,24 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
10266
10360
|
...module2,
|
|
10267
10361
|
rootDir: commonAncestor(
|
|
10268
10362
|
[
|
|
10269
|
-
workspace ?
|
|
10363
|
+
workspace ? import_node_path16.default.dirname(workspace) : app.project.projectDir,
|
|
10270
10364
|
...used.map((project) => project.projectDir),
|
|
10271
|
-
...
|
|
10272
|
-
|
|
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))
|
|
10273
10370
|
),
|
|
10274
10371
|
projectFiles: [...new Set(used.map((project) => project.projectFile))].sort(),
|
|
10275
10372
|
infoPlist: import_plist3.default.build(info),
|
|
10276
10373
|
infoPlistFile,
|
|
10277
10374
|
frameworks,
|
|
10278
|
-
|
|
10279
|
-
|
|
10280
|
-
|
|
10281
|
-
|
|
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,
|
|
10282
10381
|
appTargets: appTargetNames
|
|
10283
10382
|
};
|
|
10284
10383
|
}
|
|
@@ -10298,17 +10397,17 @@ var SKIP_SOURCE_DIRS = /* @__PURE__ */ new Set([
|
|
|
10298
10397
|
var NATIVE_DESCRIPTOR = ".one-native-source.json";
|
|
10299
10398
|
var NATIVE_GLUE = ".one-native-source.swift.txt";
|
|
10300
10399
|
function swiftPackageId(packagePath) {
|
|
10301
|
-
return
|
|
10400
|
+
return import_node_path17.default.basename(packagePath).replace(/[^A-Za-z0-9_]/g, "_").replace(/^(\d)/, "_$1");
|
|
10302
10401
|
}
|
|
10303
10402
|
function nativeSourceDescriptor(packagePath) {
|
|
10304
|
-
packagePath =
|
|
10305
|
-
const file =
|
|
10306
|
-
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;
|
|
10307
10406
|
const value = JSON.parse(
|
|
10308
10407
|
readPackageFile(packagePath, file, MAX_SWIFT_COMPILE_SOURCE_BYTES).toString("utf8")
|
|
10309
10408
|
);
|
|
10310
10409
|
const invalid = () => new Error(`${file}: invalid One native source descriptor; run one typegen`);
|
|
10311
|
-
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))) {
|
|
10312
10411
|
throw invalid();
|
|
10313
10412
|
}
|
|
10314
10413
|
if (!isSwiftNativeModules(value) || value.packageId !== swiftPackageId(packagePath)) {
|
|
@@ -10318,7 +10417,7 @@ function nativeSourceDescriptor(packagePath) {
|
|
|
10318
10417
|
}
|
|
10319
10418
|
var projects = /* @__PURE__ */ new Map();
|
|
10320
10419
|
function projectFor(packagePath, hosted) {
|
|
10321
|
-
packagePath =
|
|
10420
|
+
packagePath = import_node_fs16.default.realpathSync(packagePath);
|
|
10322
10421
|
const existing = projects.get(packagePath);
|
|
10323
10422
|
if (existing) {
|
|
10324
10423
|
if (hosted && !existing.hosted) {
|
|
@@ -10339,34 +10438,39 @@ function projectFor(packagePath, hosted) {
|
|
|
10339
10438
|
return created;
|
|
10340
10439
|
}
|
|
10341
10440
|
var xcodeProjects = /* @__PURE__ */ new Map();
|
|
10342
|
-
function
|
|
10343
|
-
|
|
10441
|
+
function swiftPackages(entry, app) {
|
|
10442
|
+
const stamp = (file) => file && import_node_fs16.default.existsSync(file) ? import_node_fs16.default.statSync(file).mtimeMs : 0;
|
|
10344
10443
|
const key = JSON.stringify([
|
|
10345
|
-
app.
|
|
10444
|
+
app.linkedProducts,
|
|
10346
10445
|
app.packageResolved,
|
|
10347
|
-
|
|
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
|
+
)
|
|
10348
10451
|
]);
|
|
10349
|
-
if (entry.
|
|
10350
|
-
entry.
|
|
10452
|
+
if (entry.packages?.key !== key) {
|
|
10453
|
+
entry.packages = {
|
|
10351
10454
|
key,
|
|
10352
|
-
packages:
|
|
10353
|
-
app.rootDir,
|
|
10354
|
-
app.packageResolved,
|
|
10355
|
-
app.
|
|
10356
|
-
|
|
10357
|
-
|
|
10455
|
+
packages: resolveSwiftPackages({
|
|
10456
|
+
rootDir: app.rootDir,
|
|
10457
|
+
resolved: app.packageResolved,
|
|
10458
|
+
products: app.linkedProducts,
|
|
10459
|
+
localDirs: app.localPackageDirs,
|
|
10460
|
+
provided: entry.provided
|
|
10461
|
+
})
|
|
10358
10462
|
};
|
|
10359
10463
|
}
|
|
10360
|
-
return entry.
|
|
10464
|
+
return entry.packages.packages;
|
|
10361
10465
|
}
|
|
10362
10466
|
var XCODE_APP_DIR = "__app__";
|
|
10363
10467
|
var XCODE_FRAMEWORKS_DIR = "__frameworks__";
|
|
10364
10468
|
var XCODE_PACKAGES_DIR = "__packages__";
|
|
10365
|
-
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)}/`;
|
|
10366
10470
|
function xcodeInputKey(layout, file, relative2) {
|
|
10367
10471
|
const owner = layout.targetDirs.get(file);
|
|
10368
|
-
if (owner) return
|
|
10369
|
-
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;
|
|
10370
10474
|
}
|
|
10371
10475
|
function xcodeLayout(root) {
|
|
10372
10476
|
const registered = xcodeProjects.get(root);
|
|
@@ -10377,7 +10481,7 @@ function xcodeLayout(root) {
|
|
|
10377
10481
|
const targetDirs = new Map(app.sources.map((file) => [file, XCODE_APP_DIR]));
|
|
10378
10482
|
const targets = [];
|
|
10379
10483
|
for (const framework of app.frameworks) {
|
|
10380
|
-
const dir =
|
|
10484
|
+
const dir = import_node_path17.default.posix.join(XCODE_FRAMEWORKS_DIR, framework.moduleName);
|
|
10381
10485
|
for (const file of framework.sources) {
|
|
10382
10486
|
if (targetDirs.has(file)) continue;
|
|
10383
10487
|
targetDirs.set(file, dir);
|
|
@@ -10388,44 +10492,35 @@ function xcodeLayout(root) {
|
|
|
10388
10492
|
path: dir,
|
|
10389
10493
|
executable: false,
|
|
10390
10494
|
resources: false,
|
|
10495
|
+
exclude: [],
|
|
10391
10496
|
languageMode: framework.languageMode,
|
|
10392
10497
|
mainActorIsolation: framework.mainActorIsolation
|
|
10393
10498
|
});
|
|
10394
10499
|
}
|
|
10395
|
-
|
|
10396
|
-
|
|
10397
|
-
|
|
10398
|
-
|
|
10399
|
-
|
|
10400
|
-
const declared = swiftManifestTargets(manifest).filter((target) => !target.executable);
|
|
10401
|
-
const all = declared.flatMap(
|
|
10402
|
-
(target) => sourceTreeFiles(import_node_path16.default.join(dir, target.path), root).map(
|
|
10403
|
-
(file) => import_node_path16.default.relative(dir, file).split(import_node_path16.default.sep).join(import_node_path16.default.posix.sep)
|
|
10404
|
-
)
|
|
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
|
|
10405
10505
|
);
|
|
10406
|
-
|
|
10407
|
-
|
|
10408
|
-
|
|
10409
|
-
for (const relative2 of all) {
|
|
10410
|
-
if (relative2.startsWith(`${target.path}/`)) files.add(import_node_path16.default.join(dir, relative2));
|
|
10411
|
-
}
|
|
10412
|
-
}
|
|
10413
|
-
}
|
|
10414
|
-
const remote = remotePackages(registered, app);
|
|
10415
|
-
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);
|
|
10416
10509
|
targets.push({
|
|
10417
10510
|
...target,
|
|
10418
|
-
path:
|
|
10419
|
-
|
|
10420
|
-
import_node_path16.default.relative(import_node_path16.default.join(root, REMOTE_CHECKOUTS), target.dir).split(import_node_path16.default.sep).join(import_node_path16.default.posix.sep)
|
|
10421
|
-
)
|
|
10511
|
+
path: target.remote ? import_node_path17.default.posix.join(XCODE_PACKAGES_DIR, posix2) : posix2,
|
|
10512
|
+
exclude: []
|
|
10422
10513
|
});
|
|
10514
|
+
if (!target.remote) files.add(import_node_path17.default.join(target.packageDir, "Package.swift"));
|
|
10423
10515
|
for (const file of target.files) files.add(file);
|
|
10424
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
|
+
}
|
|
10425
10520
|
return {
|
|
10426
10521
|
app,
|
|
10427
10522
|
targets,
|
|
10428
|
-
|
|
10523
|
+
packages,
|
|
10429
10524
|
targetDirs,
|
|
10430
10525
|
files: [...files].sort()
|
|
10431
10526
|
};
|
|
@@ -10438,32 +10533,32 @@ function xcodeManifest(layout) {
|
|
|
10438
10533
|
'let package = Package(name: "app", targets: [',
|
|
10439
10534
|
` .executableTarget(name: "${layout.app.moduleName}", path: "${XCODE_APP_DIR}", ${settings(layout.app.languageMode, layout.app.mainActorIsolation)}),`,
|
|
10440
10535
|
...layout.targets.map(
|
|
10441
|
-
(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)}),`
|
|
10442
10537
|
),
|
|
10443
10538
|
"])",
|
|
10444
10539
|
""
|
|
10445
10540
|
].join("\n");
|
|
10446
10541
|
}
|
|
10447
10542
|
function packageFiles(root) {
|
|
10448
|
-
const canonicalRoot =
|
|
10543
|
+
const canonicalRoot = import_node_fs16.default.realpathSync(root);
|
|
10449
10544
|
const xcode = xcodeLayout(canonicalRoot);
|
|
10450
10545
|
return xcode ? xcode.files : sourceTreeFiles(canonicalRoot, canonicalRoot);
|
|
10451
10546
|
}
|
|
10452
10547
|
function sourceTreeFiles(dir, canonicalRoot) {
|
|
10453
10548
|
const found = [];
|
|
10454
10549
|
const walk2 = (dir2) => {
|
|
10455
|
-
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))) {
|
|
10456
10551
|
if (entry.name.startsWith(".") && entry.name !== NATIVE_DESCRIPTOR && entry.name !== NATIVE_GLUE || SKIP_SOURCE_DIRS.has(entry.name))
|
|
10457
10552
|
continue;
|
|
10458
|
-
const full =
|
|
10553
|
+
const full = import_node_path17.default.join(dir2, entry.name);
|
|
10459
10554
|
if (entry.isSymbolicLink()) throw new Error(`swift input is a symlink: ${full}`);
|
|
10460
|
-
const real =
|
|
10461
|
-
const relative2 =
|
|
10462
|
-
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)) {
|
|
10463
10558
|
throw new Error(`swift input escapes the selected package: ${full}`);
|
|
10464
10559
|
}
|
|
10465
10560
|
if (entry.isDirectory()) {
|
|
10466
|
-
if (
|
|
10561
|
+
if (import_node_fs16.default.existsSync(import_node_path17.default.join(full, "Package.swift"))) continue;
|
|
10467
10562
|
walk2(full);
|
|
10468
10563
|
} else if (entry.isFile()) {
|
|
10469
10564
|
found.push(full);
|
|
@@ -10471,29 +10566,29 @@ function sourceTreeFiles(dir, canonicalRoot) {
|
|
|
10471
10566
|
}
|
|
10472
10567
|
}
|
|
10473
10568
|
};
|
|
10474
|
-
if (
|
|
10569
|
+
if (import_node_fs16.default.existsSync(dir)) walk2(import_node_fs16.default.realpathSync(dir));
|
|
10475
10570
|
return found;
|
|
10476
10571
|
}
|
|
10477
10572
|
function readPackageFile(root, file, maxBytes) {
|
|
10478
|
-
const canonicalRoot =
|
|
10479
|
-
const relative2 =
|
|
10480
|
-
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)) {
|
|
10481
10576
|
throw new Error(`swift input escapes the selected package: ${file}`);
|
|
10482
10577
|
}
|
|
10483
|
-
let ancestor =
|
|
10578
|
+
let ancestor = import_node_path17.default.resolve(file);
|
|
10484
10579
|
while (ancestor !== canonicalRoot) {
|
|
10485
|
-
if (
|
|
10580
|
+
if (import_node_fs16.default.lstatSync(ancestor).isSymbolicLink()) {
|
|
10486
10581
|
throw new Error(`swift input is a symlink: ${ancestor}`);
|
|
10487
10582
|
}
|
|
10488
|
-
const parent =
|
|
10583
|
+
const parent = import_node_path17.default.dirname(ancestor);
|
|
10489
10584
|
if (parent === ancestor)
|
|
10490
10585
|
throw new Error(`swift input escapes the selected package: ${file}`);
|
|
10491
10586
|
ancestor = parent;
|
|
10492
10587
|
}
|
|
10493
|
-
const expected =
|
|
10494
|
-
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);
|
|
10495
10590
|
try {
|
|
10496
|
-
const stat2 =
|
|
10591
|
+
const stat2 = import_node_fs16.default.fstatSync(fd);
|
|
10497
10592
|
if (stat2.dev !== expected.dev || stat2.ino !== expected.ino) {
|
|
10498
10593
|
throw new Error(`swift input changed while opening: ${file}`);
|
|
10499
10594
|
}
|
|
@@ -10503,16 +10598,16 @@ function readPackageFile(root, file, maxBytes) {
|
|
|
10503
10598
|
const bytes = Buffer.alloc(stat2.size + 1);
|
|
10504
10599
|
let offset = 0;
|
|
10505
10600
|
while (offset < bytes.length) {
|
|
10506
|
-
const count =
|
|
10601
|
+
const count = import_node_fs16.default.readSync(fd, bytes, offset, bytes.length - offset, null);
|
|
10507
10602
|
if (count === 0) break;
|
|
10508
10603
|
offset += count;
|
|
10509
10604
|
}
|
|
10510
|
-
if (offset !== stat2.size ||
|
|
10605
|
+
if (offset !== stat2.size || import_node_fs16.default.fstatSync(fd).size !== stat2.size) {
|
|
10511
10606
|
throw new Error(`swift input changed while reading: ${file}`);
|
|
10512
10607
|
}
|
|
10513
10608
|
return bytes.subarray(0, offset);
|
|
10514
10609
|
} finally {
|
|
10515
|
-
|
|
10610
|
+
import_node_fs16.default.closeSync(fd);
|
|
10516
10611
|
}
|
|
10517
10612
|
}
|
|
10518
10613
|
function sourceFiles(root) {
|
|
@@ -10520,7 +10615,7 @@ function sourceFiles(root) {
|
|
|
10520
10615
|
}
|
|
10521
10616
|
function resourceCandidateFiles(root) {
|
|
10522
10617
|
return packageFiles(root).filter(
|
|
10523
|
-
(file) => !file.endsWith(".swift") && !["project.pbxproj", "project.xcproj"].includes(
|
|
10618
|
+
(file) => !file.endsWith(".swift") && !["project.pbxproj", "project.xcproj"].includes(import_node_path17.default.basename(file))
|
|
10524
10619
|
);
|
|
10525
10620
|
}
|
|
10526
10621
|
var HOSTED_LIMITS = {
|
|
@@ -10554,7 +10649,7 @@ function buildSwiftResourceTable(project, baseUrl) {
|
|
|
10554
10649
|
const limits = inputLimits(Boolean(project.hosted));
|
|
10555
10650
|
const absolute = resourceCandidateFiles(project.packagePath);
|
|
10556
10651
|
const relative2 = absolute.map(
|
|
10557
|
-
(file) =>
|
|
10652
|
+
(file) => import_node_path17.default.relative(project.packagePath, file).split(import_node_path17.default.sep).join(import_node_path17.default.posix.sep)
|
|
10558
10653
|
);
|
|
10559
10654
|
const byRelative = new Map(absolute.map((file, index) => [relative2[index], file]));
|
|
10560
10655
|
const readContents = (candidate) => {
|
|
@@ -10576,16 +10671,16 @@ function buildSwiftResourceTable(project, baseUrl) {
|
|
|
10576
10671
|
for (const { name: name2, file, scale } of found) {
|
|
10577
10672
|
const disk = byRelative.get(file);
|
|
10578
10673
|
if (!disk) continue;
|
|
10579
|
-
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) {
|
|
10580
10675
|
throw new Error("swift image pack exceeds the compile service caps");
|
|
10581
10676
|
}
|
|
10582
10677
|
const bytes = readPackageFile(project.packagePath, disk, limits.imageBytes);
|
|
10583
10678
|
imageBytes += bytes.length;
|
|
10584
|
-
const hash = (0,
|
|
10585
|
-
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();
|
|
10586
10681
|
table[name2] = { uri: `${baseUrl}${RESOURCE_PATH}${hash}${ext}`, scale };
|
|
10587
10682
|
images[name2] = {
|
|
10588
|
-
file:
|
|
10683
|
+
file: import_node_path17.default.posix.basename(file),
|
|
10589
10684
|
data: bytes.toString("base64")
|
|
10590
10685
|
};
|
|
10591
10686
|
watched.push(file);
|
|
@@ -10609,10 +10704,10 @@ function buildSwiftResourceTable(project, baseUrl) {
|
|
|
10609
10704
|
return { table, images, colors, symbols, watched };
|
|
10610
10705
|
}
|
|
10611
10706
|
function buildSwiftBundleFiles(packagePath, hosted) {
|
|
10612
|
-
packagePath =
|
|
10707
|
+
packagePath = import_node_fs16.default.realpathSync(packagePath);
|
|
10613
10708
|
const limits = inputLimits(hosted);
|
|
10614
10709
|
const relative2 = resourceCandidateFiles(packagePath).map(
|
|
10615
|
-
(file) =>
|
|
10710
|
+
(file) => import_node_path17.default.relative(packagePath, file).split(import_node_path17.default.sep).join(import_node_path17.default.posix.sep)
|
|
10616
10711
|
);
|
|
10617
10712
|
const files = {};
|
|
10618
10713
|
const watched = [];
|
|
@@ -10626,13 +10721,13 @@ function buildSwiftBundleFiles(packagePath, hosted) {
|
|
|
10626
10721
|
total += bytes.length;
|
|
10627
10722
|
if (xcode.app.infoPlistFile)
|
|
10628
10723
|
watched.push(
|
|
10629
|
-
|
|
10724
|
+
import_node_path17.default.relative(packagePath, xcode.app.infoPlistFile).split(import_node_path17.default.sep).join("/")
|
|
10630
10725
|
);
|
|
10631
10726
|
}
|
|
10632
10727
|
for (const { base, file } of enumerateBundleJson(relative2)) {
|
|
10633
10728
|
watched.push(file);
|
|
10634
|
-
const disk =
|
|
10635
|
-
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) {
|
|
10636
10731
|
throw new Error(
|
|
10637
10732
|
`swift bundle pack exceeds ${limits.resources} files / ${limits.resourceTotalBytes} bytes`
|
|
10638
10733
|
);
|
|
@@ -10647,12 +10742,12 @@ function serveSwiftResource(project, key) {
|
|
|
10647
10742
|
return project.resourceFiles.get(key) ?? project.resourcesPrevious.get(key) ?? null;
|
|
10648
10743
|
}
|
|
10649
10744
|
function linkedModuleRoots(packagePath) {
|
|
10650
|
-
packagePath =
|
|
10745
|
+
packagePath = import_node_fs16.default.realpathSync(packagePath);
|
|
10651
10746
|
let manifest;
|
|
10652
10747
|
try {
|
|
10653
10748
|
manifest = readPackageFile(
|
|
10654
10749
|
packagePath,
|
|
10655
|
-
|
|
10750
|
+
import_node_path17.default.join(packagePath, "Package.swift"),
|
|
10656
10751
|
MAX_SWIFT_COMPILE_SOURCE_BYTES
|
|
10657
10752
|
).toString("utf8");
|
|
10658
10753
|
} catch {
|
|
@@ -10661,28 +10756,28 @@ function linkedModuleRoots(packagePath) {
|
|
|
10661
10756
|
const roots = /* @__PURE__ */ new Set();
|
|
10662
10757
|
const dependency = /\.package\(\s*path:\s*"([^"]+)"\s*\)/g;
|
|
10663
10758
|
for (const match of manifest.replace(/^\s*\/\/.*$/gm, "").matchAll(dependency)) {
|
|
10664
|
-
const root =
|
|
10665
|
-
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);
|
|
10666
10761
|
}
|
|
10667
10762
|
return [...roots].sort();
|
|
10668
10763
|
}
|
|
10669
10764
|
function sourceStamp(packagePath, moduleRootOverride, hosted = false) {
|
|
10670
|
-
const hash = (0,
|
|
10765
|
+
const hash = (0, import_node_crypto6.createHash)("sha256");
|
|
10671
10766
|
hash.update(packagePath);
|
|
10672
10767
|
const projectInputs = new Set(packageFiles(packagePath));
|
|
10673
10768
|
for (const file of [...projectInputs].sort()) {
|
|
10674
|
-
hash.update(
|
|
10675
|
-
const stat2 =
|
|
10769
|
+
hash.update(import_node_path17.default.relative(packagePath, file));
|
|
10770
|
+
const stat2 = import_node_fs16.default.statSync(file);
|
|
10676
10771
|
hash.update(`${stat2.mtimeMs}/${stat2.ctimeMs}/${stat2.size}`);
|
|
10677
10772
|
}
|
|
10678
10773
|
const moduleRoot = hosted ? void 0 : moduleRootOverride ?? linkedModuleRoots(packagePath).find(
|
|
10679
|
-
(root) =>
|
|
10774
|
+
(root) => import_node_fs16.default.existsSync(import_node_path17.default.join(root, "toolchain.json"))
|
|
10680
10775
|
);
|
|
10681
10776
|
if (moduleRoot) {
|
|
10682
10777
|
hash.update(moduleRoot);
|
|
10683
10778
|
for (const relative2 of swiftModuleInputFiles(moduleRoot)) {
|
|
10684
10779
|
hash.update(relative2);
|
|
10685
|
-
hash.update(String(
|
|
10780
|
+
hash.update(String(import_node_fs16.default.statSync(import_node_path17.default.join(moduleRoot, relative2)).mtimeMs));
|
|
10686
10781
|
}
|
|
10687
10782
|
}
|
|
10688
10783
|
return hash.digest("hex").slice(0, 16);
|
|
@@ -10694,8 +10789,8 @@ function packageSources(packagePath) {
|
|
|
10694
10789
|
const xcode = xcodeLayout(packagePath);
|
|
10695
10790
|
const files = {};
|
|
10696
10791
|
for (const file of sourceFiles(packagePath)) {
|
|
10697
|
-
const relative2 =
|
|
10698
|
-
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;
|
|
10699
10794
|
files[xcode ? xcodeInputKey(xcode, file, relative2) : relative2] = readPackageFile(
|
|
10700
10795
|
packagePath,
|
|
10701
10796
|
file,
|
|
@@ -10712,7 +10807,7 @@ function packageSnapshot(project) {
|
|
|
10712
10807
|
files,
|
|
10713
10808
|
resourcePaths: swiftImplicitResourcePaths(
|
|
10714
10809
|
resourceCandidateFiles(project.packagePath).map(
|
|
10715
|
-
(file) =>
|
|
10810
|
+
(file) => import_node_path17.default.relative(project.packagePath, file).split(import_node_path17.default.sep).join(import_node_path17.default.posix.sep)
|
|
10716
10811
|
)
|
|
10717
10812
|
),
|
|
10718
10813
|
resources: buildSwiftResourceTable(project, ""),
|
|
@@ -10721,7 +10816,7 @@ function packageSnapshot(project) {
|
|
|
10721
10816
|
...native ? {
|
|
10722
10817
|
glue: readPackageFile(
|
|
10723
10818
|
project.packagePath,
|
|
10724
|
-
|
|
10819
|
+
import_node_path17.default.join(project.packagePath, NATIVE_GLUE),
|
|
10725
10820
|
MAX_SWIFT_COMPILE_SOURCE_BYTES
|
|
10726
10821
|
).toString("utf8")
|
|
10727
10822
|
} : {}
|
|
@@ -10757,7 +10852,7 @@ async function compile(packagePath, entry, stamp, moduleRootOverride, hosted, sn
|
|
|
10757
10852
|
package: content
|
|
10758
10853
|
};
|
|
10759
10854
|
const moduleRoot = moduleRootOverride ?? linkedModuleRoots(packagePath).find(
|
|
10760
|
-
(root) =>
|
|
10855
|
+
(root) => import_node_fs16.default.existsSync(import_node_path17.default.join(root, "toolchain.json"))
|
|
10761
10856
|
) ?? await swiftDistributionRoot();
|
|
10762
10857
|
if (!moduleRoot)
|
|
10763
10858
|
return {
|
|
@@ -10783,10 +10878,10 @@ async function compile(packagePath, entry, stamp, moduleRootOverride, hosted, sn
|
|
|
10783
10878
|
// server and a capture, or two checkouts) build each other's sources. so
|
|
10784
10879
|
// each app and module checkout gets its own root, which keeps the same
|
|
10785
10880
|
// app's incremental build across restarts.
|
|
10786
|
-
buildRoot: process.env.CONTRAST_SWIFT_BUILD_ROOT ??
|
|
10787
|
-
|
|
10881
|
+
buildRoot: process.env.CONTRAST_SWIFT_BUILD_ROOT ?? import_node_path17.default.join(
|
|
10882
|
+
import_node_os6.default.tmpdir(),
|
|
10788
10883
|
"contrast-swift-build",
|
|
10789
|
-
(0,
|
|
10884
|
+
(0, import_node_crypto6.createHash)("sha256").update(`${moduleRoot}\0${import_node_path17.default.resolve(packagePath)}`).digest("hex").slice(0, 16)
|
|
10790
10885
|
),
|
|
10791
10886
|
moduleRoot,
|
|
10792
10887
|
...toolchain
|
|
@@ -10851,19 +10946,19 @@ function swiftApiGapReport(output) {
|
|
|
10851
10946
|
}
|
|
10852
10947
|
function missingModulesMessage(packagePath, missing) {
|
|
10853
10948
|
const layout = xcodeLayout(packagePath);
|
|
10854
|
-
const
|
|
10855
|
-
(layout?.app.
|
|
10856
|
-
|
|
10857
|
-
|
|
10858
|
-
]
|
|
10859
|
-
|
|
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
|
+
]);
|
|
10860
10956
|
const width = Math.max(...[...missing.keys()].map((name2) => name2.length));
|
|
10861
10957
|
return [
|
|
10862
10958
|
`Peach does not provide ${missing.size} module${missing.size === 1 ? "" : "s"} this app imports:`,
|
|
10863
10959
|
...[...missing].map(([name2, files]) => {
|
|
10864
|
-
const
|
|
10865
|
-
|
|
10866
|
-
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})` : ""}`;
|
|
10867
10962
|
})
|
|
10868
10963
|
].join("\n");
|
|
10869
10964
|
}
|
|
@@ -10871,7 +10966,7 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
|
|
|
10871
10966
|
const auth = hosted ? null : resolveCliAuth();
|
|
10872
10967
|
if (!hosted && (!auth || auth.kind === "github")) {
|
|
10873
10968
|
throw new Error(
|
|
10874
|
-
`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`
|
|
10875
10970
|
);
|
|
10876
10971
|
}
|
|
10877
10972
|
const origin = hosted?.origin ?? resolveContrastBackendOrigin(auth?.kind === "session" ? auth.origin : null);
|
|
@@ -10890,7 +10985,7 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
|
|
|
10890
10985
|
const bytes = sources.reduce((total2, text2) => total2 + Buffer.byteLength(text2), 0);
|
|
10891
10986
|
if (sources.length > MAX_SWIFT_COMPILE_FILES || bytes > MAX_SWIFT_COMPILE_SOURCE_BYTES) {
|
|
10892
10987
|
throw new Error(
|
|
10893
|
-
`${
|
|
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`
|
|
10894
10989
|
);
|
|
10895
10990
|
}
|
|
10896
10991
|
const descriptor = snapshot.native;
|
|
@@ -10909,7 +11004,7 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
|
|
|
10909
11004
|
);
|
|
10910
11005
|
if (descriptor && address.native?.hash !== descriptor.hash) {
|
|
10911
11006
|
throw new Error(
|
|
10912
|
-
`${
|
|
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`
|
|
10913
11008
|
);
|
|
10914
11009
|
}
|
|
10915
11010
|
const response = await fetch(address.url, { signal });
|
|
@@ -11028,13 +11123,13 @@ function serveSwiftPackageAsset(pathname, res) {
|
|
|
11028
11123
|
}
|
|
11029
11124
|
|
|
11030
11125
|
// src/expo-swift-host.ts
|
|
11031
|
-
var run3 = (0, import_node_util3.promisify)(
|
|
11126
|
+
var run3 = (0, import_node_util3.promisify)(import_node_child_process8.execFile);
|
|
11032
11127
|
var scriptEnv = { ...process.env, [RNX_FORKED_SCRIPT_ENV]: "1" };
|
|
11033
11128
|
var EXPO_SWIFT_ROUTE = "/__peach/expo-swift";
|
|
11034
11129
|
var EXPO_SWIFT_ENTRY = "Sources/PeachExpoApp/PeachExpoEntry.swift";
|
|
11035
11130
|
async function collectExpoSwiftSources(appRoot) {
|
|
11036
|
-
appRoot =
|
|
11037
|
-
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"));
|
|
11038
11133
|
let autolinker;
|
|
11039
11134
|
try {
|
|
11040
11135
|
autolinker = appRequire.resolve("expo-modules-autolinking/package.json");
|
|
@@ -11048,7 +11143,7 @@ async function collectExpoSwiftSources(appRoot) {
|
|
|
11048
11143
|
(command) => run3(
|
|
11049
11144
|
process.execPath,
|
|
11050
11145
|
[
|
|
11051
|
-
|
|
11146
|
+
import_node_path18.default.join(import_node_path18.default.dirname(autolinker), "bin/expo-modules-autolinking.js"),
|
|
11052
11147
|
command,
|
|
11053
11148
|
"--platform",
|
|
11054
11149
|
"apple",
|
|
@@ -11079,8 +11174,8 @@ async function collectExpoSwiftSources(appRoot) {
|
|
|
11079
11174
|
const sourceRoot = Reflect.get(entry, "path");
|
|
11080
11175
|
if (typeof sourceRoot !== "string")
|
|
11081
11176
|
throw new Error("Expo autolinking entry has no path");
|
|
11082
|
-
const canonical =
|
|
11083
|
-
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;
|
|
11084
11179
|
const resolution = resolutions.find(
|
|
11085
11180
|
(candidate) => candidate && typeof candidate === "object" && Reflect.get(candidate, "packageName") === Reflect.get(entry, "name")
|
|
11086
11181
|
);
|
|
@@ -11106,12 +11201,12 @@ async function collectExpoSwiftSources(appRoot) {
|
|
|
11106
11201
|
`(${className.includes(".") ? className : `${namespace}.${className}`}.self, ${name2 === null ? "nil" : JSON.stringify(name2)})`
|
|
11107
11202
|
);
|
|
11108
11203
|
}
|
|
11109
|
-
const ios =
|
|
11110
|
-
if (
|
|
11204
|
+
const ios = import_node_path18.default.join(canonical, "ios");
|
|
11205
|
+
if (import_node_fs17.default.lstatSync(ios).isSymbolicLink())
|
|
11111
11206
|
throw new Error(`Expo Swift source directory is a symlink: ${ios}`);
|
|
11112
11207
|
const walk2 = (dir) => {
|
|
11113
|
-
for (const child of
|
|
11114
|
-
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);
|
|
11115
11210
|
if (child.isSymbolicLink())
|
|
11116
11211
|
throw new Error(`Expo Swift source is a symlink: ${file}`);
|
|
11117
11212
|
if (child.isDirectory()) {
|
|
@@ -11119,13 +11214,13 @@ async function collectExpoSwiftSources(appRoot) {
|
|
|
11119
11214
|
continue;
|
|
11120
11215
|
}
|
|
11121
11216
|
if (!child.name.endsWith(".swift")) continue;
|
|
11122
|
-
const size =
|
|
11217
|
+
const size = import_node_fs17.default.statSync(file).size;
|
|
11123
11218
|
bytes += size;
|
|
11124
11219
|
fileCount++;
|
|
11125
11220
|
if (fileCount > MAX_SWIFT_COMPILE_FILES - 2 || bytes > MAX_SWIFT_COMPILE_SOURCE_BYTES)
|
|
11126
11221
|
throw new Error("Expo Swift sources exceed compile service caps");
|
|
11127
|
-
files[`Sources/${namespace}/${
|
|
11128
|
-
${
|
|
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")}`;
|
|
11129
11224
|
}
|
|
11130
11225
|
};
|
|
11131
11226
|
walk2(ios);
|
|
@@ -11210,7 +11305,7 @@ async function handleExpoSwiftRequest(req, res) {
|
|
|
11210
11305
|
return true;
|
|
11211
11306
|
}
|
|
11212
11307
|
const root = url.searchParams.get("root");
|
|
11213
|
-
if (!root || !
|
|
11308
|
+
if (!root || !import_node_path18.default.isAbsolute(root)) {
|
|
11214
11309
|
res.writeHead(400);
|
|
11215
11310
|
res.end("missing absolute app root");
|
|
11216
11311
|
return true;
|
|
@@ -11227,7 +11322,7 @@ async function handleExpoSwiftRequest(req, res) {
|
|
|
11227
11322
|
modules: [],
|
|
11228
11323
|
failures: []
|
|
11229
11324
|
};
|
|
11230
|
-
const key = (0,
|
|
11325
|
+
const key = (0, import_node_crypto7.createHash)("sha256").update(import_node_fs17.default.realpathSync(root)).digest("hex");
|
|
11231
11326
|
const host2 = req.headers.host;
|
|
11232
11327
|
if (!host2) throw new Error("Expo Swift request has no host");
|
|
11233
11328
|
const base = `http://${host2}`;
|
|
@@ -11241,8 +11336,8 @@ async function handleExpoSwiftRequest(req, res) {
|
|
|
11241
11336
|
continue;
|
|
11242
11337
|
}
|
|
11243
11338
|
try {
|
|
11244
|
-
const packagePath =
|
|
11245
|
-
|
|
11339
|
+
const packagePath = import_node_path18.default.join(
|
|
11340
|
+
import_node_os7.default.tmpdir(),
|
|
11246
11341
|
"peach-expo-swift",
|
|
11247
11342
|
key,
|
|
11248
11343
|
unit.namespace
|
|
@@ -11251,7 +11346,7 @@ async function handleExpoSwiftRequest(req, res) {
|
|
|
11251
11346
|
packagePath,
|
|
11252
11347
|
new Map(
|
|
11253
11348
|
Object.entries(unit.files).map(([name2, source]) => [
|
|
11254
|
-
|
|
11349
|
+
import_node_path18.default.join(packagePath, name2),
|
|
11255
11350
|
source
|
|
11256
11351
|
])
|
|
11257
11352
|
)
|
|
@@ -11302,8 +11397,8 @@ async function handleExpoSwiftRequest(req, res) {
|
|
|
11302
11397
|
import PackageDescription
|
|
11303
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")])
|
|
11304
11399
|
`;
|
|
11305
|
-
const packagePath =
|
|
11306
|
-
|
|
11400
|
+
const packagePath = import_node_path18.default.join(
|
|
11401
|
+
import_node_os7.default.tmpdir(),
|
|
11307
11402
|
"peach-expo-swift",
|
|
11308
11403
|
key,
|
|
11309
11404
|
"linked-app"
|
|
@@ -11312,7 +11407,7 @@ let package = Package(name: "PeachExpo", targets: [${targets.map((name2) => `.ta
|
|
|
11312
11407
|
packagePath,
|
|
11313
11408
|
new Map(
|
|
11314
11409
|
Object.entries(files).map(([name2, source]) => [
|
|
11315
|
-
|
|
11410
|
+
import_node_path18.default.join(packagePath, name2),
|
|
11316
11411
|
source
|
|
11317
11412
|
])
|
|
11318
11413
|
)
|
|
@@ -11485,20 +11580,20 @@ var RNX_RUNTIME_PRODUCT = {
|
|
|
11485
11580
|
var rnxRuntime = createRuntimeDelivery(RNX_RUNTIME_PRODUCT);
|
|
11486
11581
|
|
|
11487
11582
|
// src/host/agent-host.ts
|
|
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);
|
|
11586
|
+
|
|
11587
|
+
// src/agent-sessions.ts
|
|
11588
|
+
var import_node_child_process9 = require("node:child_process");
|
|
11488
11589
|
var import_node_crypto9 = require("node:crypto");
|
|
11489
11590
|
var import_node_fs20 = __toESM(require("node:fs"), 1);
|
|
11490
11591
|
var import_node_path21 = __toESM(require("node:path"), 1);
|
|
11491
|
-
|
|
11492
|
-
// src/agent-sessions.ts
|
|
11493
|
-
var import_node_child_process8 = require("node:child_process");
|
|
11494
|
-
var import_node_crypto8 = require("node:crypto");
|
|
11495
|
-
var import_node_fs19 = __toESM(require("node:fs"), 1);
|
|
11496
|
-
var import_node_path20 = __toESM(require("node:path"), 1);
|
|
11497
11592
|
var import_node_readline = __toESM(require("node:readline"), 1);
|
|
11498
11593
|
|
|
11499
11594
|
// cli/self-invocation.ts
|
|
11500
|
-
var
|
|
11501
|
-
var
|
|
11595
|
+
var import_node_fs18 = require("node:fs");
|
|
11596
|
+
var import_node_path19 = require("node:path");
|
|
11502
11597
|
var import_node_url3 = require("node:url");
|
|
11503
11598
|
init_public_brand();
|
|
11504
11599
|
|
|
@@ -11508,14 +11603,14 @@ var IS_STANDALONE = typeof __SOOTSIM_STANDALONE__ !== "undefined" && __SOOTSIM_S
|
|
|
11508
11603
|
// cli/self-invocation.ts
|
|
11509
11604
|
function sourceEntryPath() {
|
|
11510
11605
|
try {
|
|
11511
|
-
const candidate = (0,
|
|
11512
|
-
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;
|
|
11513
11608
|
} catch {
|
|
11514
11609
|
return null;
|
|
11515
11610
|
}
|
|
11516
11611
|
}
|
|
11517
|
-
function isCliEntry(
|
|
11518
|
-
const name2 = (0,
|
|
11612
|
+
function isCliEntry(path22) {
|
|
11613
|
+
const name2 = (0, import_node_path19.basename)(path22);
|
|
11519
11614
|
return name2 === "bin.ts" || name2 === "bin.js";
|
|
11520
11615
|
}
|
|
11521
11616
|
function rnxSelfInvocation() {
|
|
@@ -11574,9 +11669,9 @@ function encodeAgentPromptEnvelope(input) {
|
|
|
11574
11669
|
}
|
|
11575
11670
|
|
|
11576
11671
|
// src/attached-projects.ts
|
|
11577
|
-
var
|
|
11578
|
-
var
|
|
11579
|
-
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);
|
|
11580
11675
|
init_home_paths();
|
|
11581
11676
|
var overrideDir = null;
|
|
11582
11677
|
function userDataDir() {
|
|
@@ -11589,7 +11684,7 @@ function getUserDataDir() {
|
|
|
11589
11684
|
return userDataDir();
|
|
11590
11685
|
}
|
|
11591
11686
|
function storeFile() {
|
|
11592
|
-
return
|
|
11687
|
+
return import_node_path20.default.join(userDataDir(), "attached-projects.json");
|
|
11593
11688
|
}
|
|
11594
11689
|
function cloneEmpty() {
|
|
11595
11690
|
return {
|
|
@@ -11603,7 +11698,7 @@ function loadStore() {
|
|
|
11603
11698
|
const file = storeFile();
|
|
11604
11699
|
let raw2;
|
|
11605
11700
|
try {
|
|
11606
|
-
raw2 =
|
|
11701
|
+
raw2 = import_node_fs19.default.readFileSync(file, "utf8");
|
|
11607
11702
|
} catch (err) {
|
|
11608
11703
|
if (err.code === "ENOENT") return cloneEmpty();
|
|
11609
11704
|
throw err;
|
|
@@ -11620,7 +11715,7 @@ function loadStore() {
|
|
|
11620
11715
|
} catch (err) {
|
|
11621
11716
|
const quarantine = `${file}.corrupt-${Date.now()}`;
|
|
11622
11717
|
try {
|
|
11623
|
-
|
|
11718
|
+
import_node_fs19.default.renameSync(file, quarantine);
|
|
11624
11719
|
console.warn(
|
|
11625
11720
|
`[sootsim] attached-projects.json was unparseable; quarantined to ${quarantine}. original error: ${err.message}`
|
|
11626
11721
|
);
|
|
@@ -11631,16 +11726,16 @@ function loadStore() {
|
|
|
11631
11726
|
}
|
|
11632
11727
|
function writeStore(store) {
|
|
11633
11728
|
const file = storeFile();
|
|
11634
|
-
|
|
11729
|
+
import_node_fs19.default.mkdirSync(import_node_path20.default.dirname(file), { recursive: true });
|
|
11635
11730
|
const tmp = `${file}.tmp-${process.pid}-${Date.now()}`;
|
|
11636
|
-
const fd =
|
|
11731
|
+
const fd = import_node_fs19.default.openSync(tmp, "w", 384);
|
|
11637
11732
|
try {
|
|
11638
|
-
|
|
11639
|
-
|
|
11733
|
+
import_node_fs19.default.writeFileSync(fd, JSON.stringify(store, null, 2));
|
|
11734
|
+
import_node_fs19.default.fsyncSync(fd);
|
|
11640
11735
|
} finally {
|
|
11641
|
-
|
|
11736
|
+
import_node_fs19.default.closeSync(fd);
|
|
11642
11737
|
}
|
|
11643
|
-
|
|
11738
|
+
import_node_fs19.default.renameSync(tmp, file);
|
|
11644
11739
|
}
|
|
11645
11740
|
function mutateStore(fn) {
|
|
11646
11741
|
const store = loadStore();
|
|
@@ -11649,13 +11744,13 @@ function mutateStore(fn) {
|
|
|
11649
11744
|
return store;
|
|
11650
11745
|
}
|
|
11651
11746
|
function projectIdForCwd(cwd) {
|
|
11652
|
-
return (0,
|
|
11747
|
+
return (0, import_node_crypto8.createHash)("sha256").update(import_node_path20.default.resolve(cwd)).digest("hex").slice(0, 16);
|
|
11653
11748
|
}
|
|
11654
11749
|
function newSessionId() {
|
|
11655
|
-
return `s_${(0,
|
|
11750
|
+
return `s_${(0, import_node_crypto8.randomBytes)(10).toString("hex")}`;
|
|
11656
11751
|
}
|
|
11657
11752
|
function upsertProject(input) {
|
|
11658
|
-
const cwd =
|
|
11753
|
+
const cwd = import_node_path20.default.resolve(input.cwd);
|
|
11659
11754
|
const id = projectIdForCwd(cwd);
|
|
11660
11755
|
let result;
|
|
11661
11756
|
mutateStore((store) => {
|
|
@@ -11681,7 +11776,7 @@ function upsertProject(input) {
|
|
|
11681
11776
|
const now = Date.now();
|
|
11682
11777
|
const created = {
|
|
11683
11778
|
id,
|
|
11684
|
-
name: input.name ??
|
|
11779
|
+
name: input.name ?? import_node_path20.default.basename(cwd),
|
|
11685
11780
|
cwd,
|
|
11686
11781
|
repoRoot: input.repoRoot,
|
|
11687
11782
|
sourceRoots: input.sourceRoots ?? [cwd],
|
|
@@ -11827,8 +11922,8 @@ async function seedFromDemoAppRegistry() {
|
|
|
11827
11922
|
if (apps.length === 0) return;
|
|
11828
11923
|
mutateStore((store) => {
|
|
11829
11924
|
for (const app of apps) {
|
|
11830
|
-
if (!
|
|
11831
|
-
const cwd =
|
|
11925
|
+
if (!import_node_fs19.default.existsSync(app.dir)) continue;
|
|
11926
|
+
const cwd = import_node_path20.default.resolve(app.dir);
|
|
11832
11927
|
const id = projectIdForCwd(cwd);
|
|
11833
11928
|
if (store.attachedProjects.some((p) => p.id === id)) continue;
|
|
11834
11929
|
const now = Date.now();
|
|
@@ -11853,16 +11948,16 @@ async function seedFromDemoAppRegistry() {
|
|
|
11853
11948
|
// src/agent-sessions.ts
|
|
11854
11949
|
init_public_brand();
|
|
11855
11950
|
function sessionDir(sessionId) {
|
|
11856
|
-
return
|
|
11951
|
+
return import_node_path21.default.join(getUserDataDir(), "sessions", sessionId);
|
|
11857
11952
|
}
|
|
11858
11953
|
function promptFifoPath(sessionId) {
|
|
11859
|
-
return
|
|
11954
|
+
return import_node_path21.default.join(sessionDir(sessionId), "prompt.in");
|
|
11860
11955
|
}
|
|
11861
11956
|
function eventsFifoPath(sessionId) {
|
|
11862
|
-
return
|
|
11957
|
+
return import_node_path21.default.join(sessionDir(sessionId), "events.out");
|
|
11863
11958
|
}
|
|
11864
11959
|
function transcriptPath(sessionId) {
|
|
11865
|
-
return
|
|
11960
|
+
return import_node_path21.default.join(getUserDataDir(), "transcripts", `${sessionId}.log`);
|
|
11866
11961
|
}
|
|
11867
11962
|
function pidIsAlive(pid, sessionId) {
|
|
11868
11963
|
if (!pid) return false;
|
|
@@ -11872,7 +11967,7 @@ function pidIsAlive(pid, sessionId) {
|
|
|
11872
11967
|
return false;
|
|
11873
11968
|
}
|
|
11874
11969
|
if (sessionId) {
|
|
11875
|
-
if (!
|
|
11970
|
+
if (!import_node_fs20.default.existsSync(sessionDir(sessionId))) return false;
|
|
11876
11971
|
}
|
|
11877
11972
|
return true;
|
|
11878
11973
|
}
|
|
@@ -11885,11 +11980,11 @@ function resolveSootsimInvocation() {
|
|
|
11885
11980
|
const resourcesPath = process.resourcesPath;
|
|
11886
11981
|
if (resourcesPath) {
|
|
11887
11982
|
const candidates = [
|
|
11888
|
-
|
|
11889
|
-
|
|
11983
|
+
import_node_path21.default.join(resourcesPath, "bin", "sootsim"),
|
|
11984
|
+
import_node_path21.default.join(resourcesPath, "bin", `sootsim-${process.platform}-${process.arch}`)
|
|
11890
11985
|
];
|
|
11891
11986
|
for (const c of candidates) {
|
|
11892
|
-
if (
|
|
11987
|
+
if (import_node_fs20.default.existsSync(c)) return { executable: c, prefixArgs: [] };
|
|
11893
11988
|
}
|
|
11894
11989
|
}
|
|
11895
11990
|
}
|
|
@@ -11908,15 +12003,15 @@ function tryWorkspaceSootsim() {
|
|
|
11908
12003
|
const sootsimDir = resolveSootsimPackageDir();
|
|
11909
12004
|
if (!sootsimDir) return null;
|
|
11910
12005
|
const binaryName = `peach-${process.platform === "win32" ? "windows" : process.platform}-${process.arch}${process.platform === "win32" ? ".exe" : ""}`;
|
|
11911
|
-
const distBinary =
|
|
11912
|
-
if (
|
|
11913
|
-
const distBin =
|
|
11914
|
-
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)) {
|
|
11915
12010
|
try {
|
|
11916
|
-
const src =
|
|
11917
|
-
if (
|
|
11918
|
-
const srcMtime =
|
|
11919
|
-
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;
|
|
11920
12015
|
if (buildMtime < srcMtime) {
|
|
11921
12016
|
console.warn(
|
|
11922
12017
|
`[peach] dist-cli/bin.js is older than agent-wrapper.ts \u2014 rebuild with \`bun run --cwd packages/peachsim build:cli\`.`
|
|
@@ -11935,22 +12030,22 @@ function tryWorkspaceSootsim() {
|
|
|
11935
12030
|
function resolveSootsimPackageDir() {
|
|
11936
12031
|
try {
|
|
11937
12032
|
const resolved = require.resolve(`${rnxPublicBrand.packageName}/package.json`);
|
|
11938
|
-
return
|
|
12033
|
+
return import_node_path21.default.dirname(resolved);
|
|
11939
12034
|
} catch {
|
|
11940
12035
|
}
|
|
11941
12036
|
const here = fileFromImportMeta();
|
|
11942
12037
|
if (!here) return null;
|
|
11943
|
-
let cur =
|
|
12038
|
+
let cur = import_node_path21.default.dirname(here);
|
|
11944
12039
|
for (let i = 0; i < 8; i++) {
|
|
11945
|
-
const pkg =
|
|
12040
|
+
const pkg = import_node_path21.default.join(cur, "package.json");
|
|
11946
12041
|
try {
|
|
11947
|
-
if (
|
|
11948
|
-
const parsed = JSON.parse(
|
|
12042
|
+
if (import_node_fs20.default.existsSync(pkg)) {
|
|
12043
|
+
const parsed = JSON.parse(import_node_fs20.default.readFileSync(pkg, "utf8"));
|
|
11949
12044
|
if (parsed.name === rnxPublicBrand.packageName) return cur;
|
|
11950
12045
|
}
|
|
11951
12046
|
} catch {
|
|
11952
12047
|
}
|
|
11953
|
-
const parent =
|
|
12048
|
+
const parent = import_node_path21.default.dirname(cur);
|
|
11954
12049
|
if (parent === cur) break;
|
|
11955
12050
|
cur = parent;
|
|
11956
12051
|
}
|
|
@@ -11966,28 +12061,28 @@ function fileFromImportMeta() {
|
|
|
11966
12061
|
}
|
|
11967
12062
|
}
|
|
11968
12063
|
async function withStartLock(projectId, provider, fn) {
|
|
11969
|
-
const lockDir =
|
|
11970
|
-
|
|
12064
|
+
const lockDir = import_node_path21.default.join(getUserDataDir(), "locks");
|
|
12065
|
+
import_node_fs20.default.mkdirSync(lockDir, { recursive: true });
|
|
11971
12066
|
try {
|
|
11972
|
-
|
|
12067
|
+
import_node_fs20.default.chmodSync(lockDir, 448);
|
|
11973
12068
|
} catch {
|
|
11974
12069
|
}
|
|
11975
|
-
const lockPath =
|
|
12070
|
+
const lockPath = import_node_path21.default.join(lockDir, `start-${projectId}-${provider}.lock`);
|
|
11976
12071
|
const deadline = Date.now() + 4e3;
|
|
11977
12072
|
let fd = null;
|
|
11978
12073
|
while (fd === null) {
|
|
11979
12074
|
try {
|
|
11980
|
-
fd =
|
|
12075
|
+
fd = import_node_fs20.default.openSync(
|
|
11981
12076
|
lockPath,
|
|
11982
|
-
|
|
12077
|
+
import_node_fs20.constants.O_WRONLY | import_node_fs20.constants.O_CREAT | import_node_fs20.constants.O_EXCL,
|
|
11983
12078
|
384
|
|
11984
12079
|
);
|
|
11985
12080
|
} catch (err) {
|
|
11986
12081
|
if (err.code !== "EEXIST") throw err;
|
|
11987
12082
|
try {
|
|
11988
|
-
const stale = Number(
|
|
12083
|
+
const stale = Number(import_node_fs20.default.readFileSync(lockPath, "utf8").trim());
|
|
11989
12084
|
if (stale && !isProcessAlive(stale)) {
|
|
11990
|
-
|
|
12085
|
+
import_node_fs20.default.unlinkSync(lockPath);
|
|
11991
12086
|
continue;
|
|
11992
12087
|
}
|
|
11993
12088
|
} catch {
|
|
@@ -12001,15 +12096,15 @@ async function withStartLock(projectId, provider, fn) {
|
|
|
12001
12096
|
}
|
|
12002
12097
|
}
|
|
12003
12098
|
try {
|
|
12004
|
-
|
|
12099
|
+
import_node_fs20.default.writeFileSync(fd, String(process.pid));
|
|
12005
12100
|
return await fn();
|
|
12006
12101
|
} finally {
|
|
12007
12102
|
try {
|
|
12008
|
-
|
|
12103
|
+
import_node_fs20.default.closeSync(fd);
|
|
12009
12104
|
} catch {
|
|
12010
12105
|
}
|
|
12011
12106
|
try {
|
|
12012
|
-
|
|
12107
|
+
import_node_fs20.default.unlinkSync(lockPath);
|
|
12013
12108
|
} catch {
|
|
12014
12109
|
}
|
|
12015
12110
|
}
|
|
@@ -12023,28 +12118,28 @@ function isProcessAlive(pid) {
|
|
|
12023
12118
|
}
|
|
12024
12119
|
}
|
|
12025
12120
|
function mkfifoSync(p) {
|
|
12026
|
-
const parent =
|
|
12027
|
-
|
|
12121
|
+
const parent = import_node_path21.default.dirname(p);
|
|
12122
|
+
import_node_fs20.default.mkdirSync(parent, { recursive: true });
|
|
12028
12123
|
try {
|
|
12029
|
-
|
|
12124
|
+
import_node_fs20.default.chmodSync(parent, 448);
|
|
12030
12125
|
} catch {
|
|
12031
12126
|
}
|
|
12032
|
-
if (
|
|
12127
|
+
if (import_node_fs20.default.existsSync(p)) {
|
|
12033
12128
|
try {
|
|
12034
|
-
const stat2 =
|
|
12129
|
+
const stat2 = import_node_fs20.default.statSync(p);
|
|
12035
12130
|
if (stat2.isFIFO()) {
|
|
12036
12131
|
try {
|
|
12037
|
-
|
|
12132
|
+
import_node_fs20.default.chmodSync(p, 384);
|
|
12038
12133
|
} catch {
|
|
12039
12134
|
}
|
|
12040
12135
|
return;
|
|
12041
12136
|
}
|
|
12042
|
-
|
|
12137
|
+
import_node_fs20.default.unlinkSync(p);
|
|
12043
12138
|
} catch {
|
|
12044
|
-
|
|
12139
|
+
import_node_fs20.default.unlinkSync(p);
|
|
12045
12140
|
}
|
|
12046
12141
|
}
|
|
12047
|
-
const result = (0,
|
|
12142
|
+
const result = (0, import_node_child_process9.spawnSync)("mkfifo", ["-m", "600", p]);
|
|
12048
12143
|
if (result.status !== 0) {
|
|
12049
12144
|
throw new Error(
|
|
12050
12145
|
`mkfifo(${p}) failed: ${result.stderr?.toString().trim() || "unknown error"}`
|
|
@@ -12074,7 +12169,7 @@ async function startSession(opts) {
|
|
|
12074
12169
|
`session already running for project=${project.id} provider=${provider} (session ${existingLive.id}, pid ${existingLive.wrapperPid}). end it first with \`peach agent end <sessionId>\`.`
|
|
12075
12170
|
);
|
|
12076
12171
|
}
|
|
12077
|
-
const claudeSessionUuid = provider === "claude" ? (0,
|
|
12172
|
+
const claudeSessionUuid = provider === "claude" ? (0, import_node_crypto9.randomUUID)() : void 0;
|
|
12078
12173
|
const session = upsertSession({
|
|
12079
12174
|
projectId: project.id,
|
|
12080
12175
|
provider,
|
|
@@ -12088,10 +12183,10 @@ async function startSession(opts) {
|
|
|
12088
12183
|
const transcript = transcriptPath(session.id);
|
|
12089
12184
|
mkfifoSync(promptIn);
|
|
12090
12185
|
mkfifoSync(eventsOut);
|
|
12091
|
-
const transcriptDir =
|
|
12092
|
-
|
|
12186
|
+
const transcriptDir = import_node_path21.default.dirname(transcript);
|
|
12187
|
+
import_node_fs20.default.mkdirSync(transcriptDir, { recursive: true });
|
|
12093
12188
|
try {
|
|
12094
|
-
|
|
12189
|
+
import_node_fs20.default.chmodSync(transcriptDir, 448);
|
|
12095
12190
|
} catch {
|
|
12096
12191
|
}
|
|
12097
12192
|
const { executable, prefixArgs } = resolveSootsimInvocation();
|
|
@@ -12119,7 +12214,7 @@ async function startSession(opts) {
|
|
|
12119
12214
|
if (claudeSessionUuid) {
|
|
12120
12215
|
wrapperArgs.push("--claude-session-uuid", claudeSessionUuid);
|
|
12121
12216
|
}
|
|
12122
|
-
const child = (0,
|
|
12217
|
+
const child = (0, import_node_child_process9.spawn)(executable, wrapperArgs, {
|
|
12123
12218
|
detached: true,
|
|
12124
12219
|
stdio: "ignore",
|
|
12125
12220
|
env: {
|
|
@@ -12142,7 +12237,7 @@ async function startSession(opts) {
|
|
|
12142
12237
|
}
|
|
12143
12238
|
}
|
|
12144
12239
|
try {
|
|
12145
|
-
|
|
12240
|
+
import_node_fs20.default.rmSync(sessionDir(session.id), { recursive: true, force: true });
|
|
12146
12241
|
} catch {
|
|
12147
12242
|
}
|
|
12148
12243
|
updateSessionStatus(session.id, { status: "ended" });
|
|
@@ -12170,18 +12265,18 @@ async function sendPrompt(sessionId, prompt) {
|
|
|
12170
12265
|
);
|
|
12171
12266
|
}
|
|
12172
12267
|
const fifo = promptFifoPath(sessionId);
|
|
12173
|
-
if (!
|
|
12268
|
+
if (!import_node_fs20.default.existsSync(fifo)) {
|
|
12174
12269
|
throw new AgentSessionError("NO_FIFO", `prompt FIFO missing: ${fifo}`);
|
|
12175
12270
|
}
|
|
12176
|
-
const fd =
|
|
12271
|
+
const fd = import_node_fs20.default.openSync(fifo, import_node_fs20.constants.O_WRONLY);
|
|
12177
12272
|
try {
|
|
12178
12273
|
const wireText = encodeAgentPromptEnvelope(prompt);
|
|
12179
12274
|
if (!wireText) {
|
|
12180
12275
|
throw new AgentSessionError("EMPTY_PROMPT", "prompt text is empty");
|
|
12181
12276
|
}
|
|
12182
|
-
|
|
12277
|
+
import_node_fs20.default.writeSync(fd, wireText + "\n");
|
|
12183
12278
|
} finally {
|
|
12184
|
-
|
|
12279
|
+
import_node_fs20.default.closeSync(fd);
|
|
12185
12280
|
}
|
|
12186
12281
|
updateSessionStatus(sessionId, {
|
|
12187
12282
|
lastPrompt: prompt.displayText ?? prompt.text,
|
|
@@ -12203,7 +12298,7 @@ async function endSession(sessionId) {
|
|
|
12203
12298
|
const base = getUserDataDir();
|
|
12204
12299
|
if (dir.startsWith(base)) {
|
|
12205
12300
|
try {
|
|
12206
|
-
|
|
12301
|
+
import_node_fs20.default.rmSync(dir, { recursive: true, force: true });
|
|
12207
12302
|
} catch {
|
|
12208
12303
|
}
|
|
12209
12304
|
}
|
|
@@ -12211,11 +12306,11 @@ async function endSession(sessionId) {
|
|
|
12211
12306
|
}
|
|
12212
12307
|
function subscribeEvents(sessionId, onEvent) {
|
|
12213
12308
|
const fifo = eventsFifoPath(sessionId);
|
|
12214
|
-
if (!
|
|
12309
|
+
if (!import_node_fs20.default.existsSync(fifo)) {
|
|
12215
12310
|
throw new AgentSessionError("NO_FIFO", `events FIFO missing: ${fifo}`);
|
|
12216
12311
|
}
|
|
12217
|
-
const fd =
|
|
12218
|
-
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 });
|
|
12219
12314
|
const rl = import_node_readline.default.createInterface({ input: stream, crlfDelay: Infinity });
|
|
12220
12315
|
rl.on("line", (line) => {
|
|
12221
12316
|
const event = parseAgentEventLine(line);
|
|
@@ -12226,7 +12321,7 @@ function subscribeEvents(sessionId, onEvent) {
|
|
|
12226
12321
|
if (closed) return;
|
|
12227
12322
|
closed = true;
|
|
12228
12323
|
try {
|
|
12229
|
-
|
|
12324
|
+
import_node_fs20.default.writeSync(fd, "\n");
|
|
12230
12325
|
} catch {
|
|
12231
12326
|
}
|
|
12232
12327
|
try {
|
|
@@ -12240,7 +12335,7 @@ function subscribeEvents(sessionId, onEvent) {
|
|
|
12240
12335
|
};
|
|
12241
12336
|
}
|
|
12242
12337
|
async function waitForFirstEvent(fifo, predicate, timeoutMs) {
|
|
12243
|
-
const fd =
|
|
12338
|
+
const fd = import_node_fs20.default.openSync(fifo, import_node_fs20.constants.O_RDWR | import_node_fs20.constants.O_NONBLOCK);
|
|
12244
12339
|
const buf = Buffer.alloc(8192);
|
|
12245
12340
|
let leftover = "";
|
|
12246
12341
|
const deadline = Date.now() + timeoutMs;
|
|
@@ -12248,7 +12343,7 @@ async function waitForFirstEvent(fifo, predicate, timeoutMs) {
|
|
|
12248
12343
|
while (Date.now() < deadline) {
|
|
12249
12344
|
let n = 0;
|
|
12250
12345
|
try {
|
|
12251
|
-
n =
|
|
12346
|
+
n = import_node_fs20.default.readSync(fd, buf, 0, buf.length, null);
|
|
12252
12347
|
} catch (err) {
|
|
12253
12348
|
if (err.code !== "EAGAIN") throw err;
|
|
12254
12349
|
n = 0;
|
|
@@ -12268,7 +12363,7 @@ async function waitForFirstEvent(fifo, predicate, timeoutMs) {
|
|
|
12268
12363
|
}
|
|
12269
12364
|
return null;
|
|
12270
12365
|
} finally {
|
|
12271
|
-
|
|
12366
|
+
import_node_fs20.default.closeSync(fd);
|
|
12272
12367
|
}
|
|
12273
12368
|
}
|
|
12274
12369
|
|
|
@@ -12476,7 +12571,7 @@ var AgentHost = class {
|
|
|
12476
12571
|
throw new AgentSessionError("EMPTY_PROMPT", "inspect message cannot be empty");
|
|
12477
12572
|
}
|
|
12478
12573
|
const message = {
|
|
12479
|
-
id: `inspect-${(0,
|
|
12574
|
+
id: `inspect-${(0, import_node_crypto10.randomUUID)()}`,
|
|
12480
12575
|
simId,
|
|
12481
12576
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
12482
12577
|
prompt
|
|
@@ -12522,7 +12617,7 @@ var AgentHost = class {
|
|
|
12522
12617
|
);
|
|
12523
12618
|
const project = upsertProject({
|
|
12524
12619
|
cwd: match.cwd,
|
|
12525
|
-
name: match.projectName ??
|
|
12620
|
+
name: match.projectName ?? import_node_path22.default.basename(match.cwd),
|
|
12526
12621
|
preferredProvider: input.provider ?? existing?.preferredProvider,
|
|
12527
12622
|
sourceRoots: existing?.sourceRoots ?? [match.cwd],
|
|
12528
12623
|
knownBundleUrls,
|
|
@@ -12533,18 +12628,18 @@ var AgentHost = class {
|
|
|
12533
12628
|
}
|
|
12534
12629
|
getTranscript(sessionId) {
|
|
12535
12630
|
const p = transcriptPath(sessionId);
|
|
12536
|
-
if (!
|
|
12631
|
+
if (!import_node_fs21.default.existsSync(p)) {
|
|
12537
12632
|
return { error: "transcript not found", code: "NO_TRANSCRIPT" };
|
|
12538
12633
|
}
|
|
12539
|
-
return
|
|
12634
|
+
return import_node_fs21.default.readFileSync(p, "utf8");
|
|
12540
12635
|
}
|
|
12541
12636
|
getPaths() {
|
|
12542
12637
|
const dir = getUserDataDir();
|
|
12543
12638
|
return {
|
|
12544
12639
|
userDataDir: dir,
|
|
12545
|
-
storeFile:
|
|
12546
|
-
sessionsDir:
|
|
12547
|
-
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")
|
|
12548
12643
|
};
|
|
12549
12644
|
}
|
|
12550
12645
|
// --- subscription management ---
|
|
@@ -13245,7 +13340,7 @@ function handleAppApiRequest(req, res) {
|
|
|
13245
13340
|
}
|
|
13246
13341
|
|
|
13247
13342
|
// src/host/fetch-proxy-transport.ts
|
|
13248
|
-
var
|
|
13343
|
+
var import_node_crypto11 = require("node:crypto");
|
|
13249
13344
|
var import_node_http22 = require("node:http2");
|
|
13250
13345
|
var import_x509 = require("@peculiar/x509");
|
|
13251
13346
|
async function startFetchProxyTransport() {
|
|
@@ -13253,7 +13348,7 @@ async function startFetchProxyTransport() {
|
|
|
13253
13348
|
const keys = await crypto.subtle.generateKey(algorithm, true, ["sign", "verify"]);
|
|
13254
13349
|
const certificate = await import_x509.X509CertificateGenerator.createSelfSigned(
|
|
13255
13350
|
{
|
|
13256
|
-
serialNumber: (0,
|
|
13351
|
+
serialNumber: (0, import_node_crypto11.randomBytes)(16).toString("hex"),
|
|
13257
13352
|
name: "CN=localhost",
|
|
13258
13353
|
notBefore: new Date(Date.now() - 6e4),
|
|
13259
13354
|
notAfter: new Date(Date.now() + 365 * 24 * 60 * 6e4),
|
|
@@ -13266,7 +13361,7 @@ async function startFetchProxyTransport() {
|
|
|
13266
13361
|
crypto
|
|
13267
13362
|
);
|
|
13268
13363
|
const privateKey = Buffer.from(await crypto.subtle.exportKey("pkcs8", keys.privateKey));
|
|
13269
|
-
const spki = (0,
|
|
13364
|
+
const spki = (0, import_node_crypto11.createHash)("sha256").update(Buffer.from(await crypto.subtle.exportKey("spki", keys.publicKey))).digest("base64");
|
|
13270
13365
|
const sessions = /* @__PURE__ */ new Set();
|
|
13271
13366
|
const server = (0, import_node_http22.createSecureServer)(
|
|
13272
13367
|
{
|
|
@@ -13388,8 +13483,8 @@ async function openUrl(url, options = {}) {
|
|
|
13388
13483
|
}
|
|
13389
13484
|
|
|
13390
13485
|
// src/host/plane-host.ts
|
|
13391
|
-
var
|
|
13392
|
-
var
|
|
13486
|
+
var import_node_fs23 = __toESM(require("node:fs"), 1);
|
|
13487
|
+
var import_node_path24 = __toESM(require("node:path"), 1);
|
|
13393
13488
|
|
|
13394
13489
|
// ../peach-box/src/planeProtocol.ts
|
|
13395
13490
|
var PLANE_FLAG_READ_ONLY = 1;
|
|
@@ -13468,9 +13563,9 @@ async function dispatchPlaneCommand(plane, type, msg, mutationOptions) {
|
|
|
13468
13563
|
}
|
|
13469
13564
|
|
|
13470
13565
|
// cli/commands/box/checkout-plane.ts
|
|
13471
|
-
var
|
|
13472
|
-
var
|
|
13473
|
-
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);
|
|
13474
13569
|
var CheckoutRequiresGitError = class extends Error {
|
|
13475
13570
|
};
|
|
13476
13571
|
var BINARY_SNIFF_BYTES = 8192;
|
|
@@ -13481,14 +13576,14 @@ function looksBinary(filePath, size) {
|
|
|
13481
13576
|
if (size === 0) return false;
|
|
13482
13577
|
let fd;
|
|
13483
13578
|
try {
|
|
13484
|
-
fd =
|
|
13579
|
+
fd = import_node_fs22.default.openSync(filePath, "r");
|
|
13485
13580
|
const buffer = Buffer.alloc(Math.min(BINARY_SNIFF_BYTES, size));
|
|
13486
|
-
const read =
|
|
13581
|
+
const read = import_node_fs22.default.readSync(fd, buffer, 0, buffer.length, 0);
|
|
13487
13582
|
return buffer.subarray(0, read).includes(0);
|
|
13488
13583
|
} catch {
|
|
13489
13584
|
return false;
|
|
13490
13585
|
} finally {
|
|
13491
|
-
if (fd !== void 0)
|
|
13586
|
+
if (fd !== void 0) import_node_fs22.default.closeSync(fd);
|
|
13492
13587
|
}
|
|
13493
13588
|
}
|
|
13494
13589
|
var CheckoutFilePlane = class {
|
|
@@ -13501,7 +13596,7 @@ var CheckoutFilePlane = class {
|
|
|
13501
13596
|
listTimeoutMs;
|
|
13502
13597
|
trackedOnly;
|
|
13503
13598
|
constructor(root, options = {}) {
|
|
13504
|
-
this.root =
|
|
13599
|
+
this.root = import_node_path23.default.resolve(root);
|
|
13505
13600
|
this.listTimeoutMs = options.listTimeoutMs ?? LIST_FILES_TIMEOUT_MS;
|
|
13506
13601
|
this.trackedOnly = options.trackedOnly ?? false;
|
|
13507
13602
|
}
|
|
@@ -13510,7 +13605,7 @@ var CheckoutFilePlane = class {
|
|
|
13510
13605
|
}
|
|
13511
13606
|
listFiles() {
|
|
13512
13607
|
const args = this.trackedOnly ? ["ls-files", "-z"] : ["ls-files", "-co", "--exclude-standard", "-z"];
|
|
13513
|
-
const stdout = (0,
|
|
13608
|
+
const stdout = (0, import_node_child_process10.execFileSync)("git", args, {
|
|
13514
13609
|
cwd: this.root,
|
|
13515
13610
|
encoding: "utf8",
|
|
13516
13611
|
maxBuffer: 64 * 1024 * 1024,
|
|
@@ -13563,13 +13658,13 @@ var CheckoutFilePlane = class {
|
|
|
13563
13658
|
if (!relative2) continue;
|
|
13564
13659
|
let stat2;
|
|
13565
13660
|
try {
|
|
13566
|
-
stat2 =
|
|
13661
|
+
stat2 = import_node_fs22.default.statSync(import_node_path23.default.join(this.root, relative2));
|
|
13567
13662
|
} catch {
|
|
13568
13663
|
continue;
|
|
13569
13664
|
}
|
|
13570
13665
|
if (!stat2.isFile()) continue;
|
|
13571
13666
|
const seen = this.sniffed.get(relative2);
|
|
13572
|
-
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);
|
|
13573
13668
|
nextSniffed.set(relative2, { size: stat2.size, mtimeMs: stat2.mtimeMs, binary });
|
|
13574
13669
|
next.set(relative2, {
|
|
13575
13670
|
size: stat2.size,
|
|
@@ -13583,22 +13678,22 @@ var CheckoutFilePlane = class {
|
|
|
13583
13678
|
this.sniffed = nextSniffed;
|
|
13584
13679
|
}
|
|
13585
13680
|
absolute(planePath) {
|
|
13586
|
-
const resolved =
|
|
13587
|
-
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}`)) {
|
|
13588
13683
|
throw new Error(`path escapes the project: ${planePath}`);
|
|
13589
13684
|
}
|
|
13590
13685
|
return resolved;
|
|
13591
13686
|
}
|
|
13592
13687
|
async read(planePath) {
|
|
13593
|
-
return
|
|
13688
|
+
return import_node_fs22.default.promises.readFile(this.absolute(planePath), "utf8");
|
|
13594
13689
|
}
|
|
13595
13690
|
async readBytes(planePath) {
|
|
13596
|
-
return
|
|
13691
|
+
return import_node_fs22.default.promises.readFile(this.absolute(planePath));
|
|
13597
13692
|
}
|
|
13598
13693
|
async write(planePath, content) {
|
|
13599
13694
|
const absolute = this.absolute(planePath);
|
|
13600
|
-
await
|
|
13601
|
-
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);
|
|
13602
13697
|
this.entries.set(planePath, {
|
|
13603
13698
|
size: content.byteLength,
|
|
13604
13699
|
readOnly: false,
|
|
@@ -13607,7 +13702,7 @@ var CheckoutFilePlane = class {
|
|
|
13607
13702
|
});
|
|
13608
13703
|
}
|
|
13609
13704
|
async delete(planePath) {
|
|
13610
|
-
await
|
|
13705
|
+
await import_node_fs22.default.promises.rm(this.absolute(planePath), { force: true });
|
|
13611
13706
|
this.entries.delete(planePath);
|
|
13612
13707
|
}
|
|
13613
13708
|
};
|
|
@@ -13625,12 +13720,12 @@ var PlaneHost = class {
|
|
|
13625
13720
|
/** handle a plane:* message. returns true iff it was one. */
|
|
13626
13721
|
async handleMessage(ws, msg) {
|
|
13627
13722
|
if (typeof msg !== "object" || msg === null) return false;
|
|
13628
|
-
const
|
|
13629
|
-
const type =
|
|
13723
|
+
const record2 = { ...msg };
|
|
13724
|
+
const type = record2.type;
|
|
13630
13725
|
if (typeof type !== "string" || !type.startsWith("plane:")) return false;
|
|
13631
|
-
const id =
|
|
13726
|
+
const id = record2.id;
|
|
13632
13727
|
try {
|
|
13633
|
-
this.respond(ws, id, await this.dispatch(ws, type,
|
|
13728
|
+
this.respond(ws, id, await this.dispatch(ws, type, record2));
|
|
13634
13729
|
} catch (err) {
|
|
13635
13730
|
const code = err instanceof PlaneNotRegisteredError ? "plane-not-registered" : void 0;
|
|
13636
13731
|
this.respondError(ws, id, err instanceof Error ? err.message : String(err), code);
|
|
@@ -13733,14 +13828,14 @@ var PlaneHost = class {
|
|
|
13733
13828
|
// root and an opened one cannot disagree about the same directory.
|
|
13734
13829
|
realRoot(root) {
|
|
13735
13830
|
if (!root) throw new Error("root is required");
|
|
13736
|
-
const resolved =
|
|
13831
|
+
const resolved = import_node_path24.default.resolve(root);
|
|
13737
13832
|
let real;
|
|
13738
13833
|
try {
|
|
13739
|
-
real =
|
|
13834
|
+
real = import_node_fs23.default.realpathSync(resolved);
|
|
13740
13835
|
} catch {
|
|
13741
13836
|
throw new Error(`no such directory: ${resolved}`);
|
|
13742
13837
|
}
|
|
13743
|
-
if (!
|
|
13838
|
+
if (!import_node_fs23.default.statSync(real).isDirectory()) throw new Error(`not a directory: ${real}`);
|
|
13744
13839
|
return real;
|
|
13745
13840
|
}
|
|
13746
13841
|
respond(ws, id, result) {
|
|
@@ -13760,9 +13855,9 @@ var PlaneHost = class {
|
|
|
13760
13855
|
};
|
|
13761
13856
|
|
|
13762
13857
|
// src/host/replacement-module-handler.ts
|
|
13763
|
-
var
|
|
13858
|
+
var import_node_fs24 = require("node:fs");
|
|
13764
13859
|
var import_promises5 = __toESM(require("node:fs/promises"), 1);
|
|
13765
|
-
var
|
|
13860
|
+
var import_node_path25 = __toESM(require("node:path"), 1);
|
|
13766
13861
|
|
|
13767
13862
|
// ../contrast-bundler/src/replacementModule.ts
|
|
13768
13863
|
var import_dist = require("sucrase/dist/index.js");
|
|
@@ -14090,16 +14185,16 @@ function sendJavaScript(req, res, source) {
|
|
|
14090
14185
|
res.end(req.method === "HEAD" ? void 0 : source);
|
|
14091
14186
|
}
|
|
14092
14187
|
function resolveReplacementModuleFile(fromFile, specifier) {
|
|
14093
|
-
const base =
|
|
14188
|
+
const base = import_node_path25.default.resolve(import_node_path25.default.dirname(fromFile), specifier);
|
|
14094
14189
|
const candidates = [
|
|
14095
14190
|
...REPLACEMENT_MODULE_EXTENSIONS.some(
|
|
14096
|
-
(ext) => ext ===
|
|
14191
|
+
(ext) => ext === import_node_path25.default.extname(base).toLowerCase()
|
|
14097
14192
|
) ? [base] : [],
|
|
14098
14193
|
...REPLACEMENT_MODULE_EXTENSIONS.map((ext) => base + ext),
|
|
14099
|
-
...REPLACEMENT_MODULE_EXTENSIONS.map((ext) =>
|
|
14194
|
+
...REPLACEMENT_MODULE_EXTENSIONS.map((ext) => import_node_path25.default.join(base, `index${ext}`))
|
|
14100
14195
|
];
|
|
14101
14196
|
const found = candidates.find(
|
|
14102
|
-
(candidate) => (0,
|
|
14197
|
+
(candidate) => (0, import_node_fs24.statSync)(candidate, { throwIfNoEntry: false })?.isFile()
|
|
14103
14198
|
);
|
|
14104
14199
|
if (!found) {
|
|
14105
14200
|
throw new Error(
|
|
@@ -14154,13 +14249,13 @@ async function handleReplacementModuleRequest(req, res, options = {}) {
|
|
|
14154
14249
|
res.end("missing path param");
|
|
14155
14250
|
return true;
|
|
14156
14251
|
}
|
|
14157
|
-
const extension =
|
|
14252
|
+
const extension = import_node_path25.default.extname(targetPath).toLowerCase();
|
|
14158
14253
|
if (!REPLACEMENT_MODULE_EXTENSIONS.some((allowed) => allowed === extension)) {
|
|
14159
14254
|
res.writeHead(400, { "Content-Type": "text/plain; charset=utf-8" });
|
|
14160
14255
|
res.end(`replacement files must be ${REPLACEMENT_MODULE_EXTENSIONS.join(", ")}`);
|
|
14161
14256
|
return true;
|
|
14162
14257
|
}
|
|
14163
|
-
if (!
|
|
14258
|
+
if (!import_node_path25.default.isAbsolute(targetPath)) {
|
|
14164
14259
|
res.writeHead(400, { "Content-Type": "text/plain; charset=utf-8" });
|
|
14165
14260
|
res.end("replacement file path must be absolute");
|
|
14166
14261
|
return true;
|
|
@@ -14168,10 +14263,10 @@ async function handleReplacementModuleRequest(req, res, options = {}) {
|
|
|
14168
14263
|
const runtimePackages = new Set(url.searchParams.getAll("runtimePackage"));
|
|
14169
14264
|
let resolvedProjectRoot;
|
|
14170
14265
|
if (options.projectRoot) {
|
|
14171
|
-
const lexicalProjectRoot =
|
|
14266
|
+
const lexicalProjectRoot = import_node_path25.default.resolve(options.projectRoot);
|
|
14172
14267
|
resolvedProjectRoot = await import_promises5.default.realpath(options.projectRoot);
|
|
14173
|
-
const lexicalTarget =
|
|
14174
|
-
if (lexicalTarget.startsWith("..") ||
|
|
14268
|
+
const lexicalTarget = import_node_path25.default.relative(lexicalProjectRoot, targetPath);
|
|
14269
|
+
if (lexicalTarget.startsWith("..") || import_node_path25.default.isAbsolute(lexicalTarget)) {
|
|
14175
14270
|
res.writeHead(403, { "Content-Type": "text/plain; charset=utf-8" });
|
|
14176
14271
|
res.end("replacement file must be inside the project root");
|
|
14177
14272
|
return true;
|
|
@@ -14187,8 +14282,8 @@ async function handleReplacementModuleRequest(req, res, options = {}) {
|
|
|
14187
14282
|
return true;
|
|
14188
14283
|
}
|
|
14189
14284
|
if (resolvedProjectRoot) {
|
|
14190
|
-
const relativeTarget =
|
|
14191
|
-
if (relativeTarget.startsWith("..") ||
|
|
14285
|
+
const relativeTarget = import_node_path25.default.relative(resolvedProjectRoot, resolvedTargetPath);
|
|
14286
|
+
if (relativeTarget.startsWith("..") || import_node_path25.default.isAbsolute(relativeTarget)) {
|
|
14192
14287
|
res.writeHead(403, { "Content-Type": "text/plain; charset=utf-8" });
|
|
14193
14288
|
res.end("replacement file must be inside the project root");
|
|
14194
14289
|
return true;
|