peachsim 0.1.768 → 0.1.770
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/commands/daemon.ts +2 -1
- package/cli/outbound-endpoints.ts +14 -0
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/agent-identity.cjs +1 -1
- package/dist-lib/agent-sessions.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -1
- package/dist-lib/auth/shared-session.cjs +1 -1
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/beta.cjs +1 -1
- package/dist-lib/beta.mjs +1 -1
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/bridge-contract-input.cjs +1 -1
- package/dist-lib/bridge-contract-input.mjs +1 -1
- package/dist-lib/bridge-contract.cjs +1 -1
- package/dist-lib/bridge-contract.mjs +1 -1
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +1 -1
- package/dist-lib/cli-constants.cjs +1 -1
- package/dist-lib/cloud-contract.cjs +1 -1
- package/dist-lib/cloud-contract.mjs +1 -1
- package/dist-lib/cloud-test-args.cjs +1 -1
- package/dist-lib/cloud-test-args.mjs +1 -1
- package/dist-lib/cloud.cjs +1 -1
- package/dist-lib/cloud.mjs +1 -1
- package/dist-lib/config.cjs +1 -1
- package/dist-lib/detox/index.cjs +1 -1
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +847 -458
- package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
- package/dist-lib/host/replacement-module-handler.cjs +1 -1
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +1 -1
- package/dist-lib/jump-to-source-babel.cjs +1 -1
- package/dist-lib/jump-to-source-native.cjs +1 -1
- package/dist-lib/kotlin-host.cjs +1 -1
- package/dist-lib/menu.cjs +1 -1
- package/dist-lib/menu.mjs +1 -1
- package/dist-lib/metro-fingerprint-registry.cjs +1 -1
- package/dist-lib/metro-fingerprint-registry.mjs +1 -1
- package/dist-lib/metro-production-bundle.cjs +1 -1
- package/dist-lib/metro-production-bundle.mjs +1 -1
- package/dist-lib/metro.cjs +1 -1
- package/dist-lib/native-app-identity.cjs +1 -1
- package/dist-lib/native-app-identity.mjs +1 -1
- package/dist-lib/native-firebase-metadata.cjs +1 -1
- package/dist-lib/native-firebase-metadata.mjs +1 -1
- package/dist-lib/plist.cjs +1 -1
- package/dist-lib/plist.mjs +1 -1
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +1 -1
- package/dist-lib/render-mode.cjs +1 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
- package/dist-lib/sdk.cjs +1 -1
- package/dist-lib/sdk.mjs +1 -1
- package/dist-lib/skills.cjs +1134 -732
- package/dist-lib/swift-compile.cjs +1 -1
- package/dist-lib/swift-compile.mjs +1 -1
- package/dist-lib/swift-package.cjs +1 -1
- package/dist-lib/swift-package.mjs +1 -1
- package/dist-lib/swift-submit.cjs +1 -1
- package/dist-lib/swift-submit.mjs +1 -1
- package/dist-lib/swift-toolchain.cjs +1 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +674 -285
- package/dist-lib/vite.cjs +1 -1
- package/package.json +1 -1
- package/src/ios-sdk-frameworks.json +289 -0
- package/src/swift-binary-modules.ts +116 -0
- package/src/swift-host.ts +34 -22
- package/src/swift-package-manifest.ts +3 -0
- package/src/swift-packages.ts +32 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.770 | (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;
|
|
@@ -2696,8 +2696,8 @@ function metroIosAssetDestRelatives(httpServerLocation, filename) {
|
|
|
2696
2696
|
}
|
|
2697
2697
|
const out = [];
|
|
2698
2698
|
for (const dir of dirs) {
|
|
2699
|
-
const
|
|
2700
|
-
if (!out.includes(
|
|
2699
|
+
const path23 = `${dir}/${filename}`;
|
|
2700
|
+
if (!out.includes(path23)) out.push(path23);
|
|
2701
2701
|
}
|
|
2702
2702
|
if (!out.includes(filename)) out.push(filename);
|
|
2703
2703
|
return out;
|
|
@@ -3651,13 +3651,13 @@ function readFactoryStringLiterals(factory) {
|
|
|
3651
3651
|
return literals;
|
|
3652
3652
|
}
|
|
3653
3653
|
function normalizeFingerprintLiteral(literal) {
|
|
3654
|
-
const
|
|
3654
|
+
const path23 = literal.replaceAll("\\\\", "/").replaceAll("\\/", "/");
|
|
3655
3655
|
const nodeModulesMarker = "/node_modules/";
|
|
3656
|
-
const nodeModulesIndex =
|
|
3656
|
+
const nodeModulesIndex = path23.lastIndexOf(nodeModulesMarker);
|
|
3657
3657
|
if (nodeModulesIndex >= 0) {
|
|
3658
|
-
return `node_modules/${
|
|
3658
|
+
return `node_modules/${path23.slice(nodeModulesIndex + nodeModulesMarker.length)}`;
|
|
3659
3659
|
}
|
|
3660
|
-
if ((
|
|
3660
|
+
if ((path23.startsWith("/") || /^[A-Za-z]:\//.test(path23) || path23.startsWith("file:/")) && /\.[cm]?[jt]sx?(?::\d+(?::\d+)?)?$/.test(path23)) {
|
|
3661
3661
|
return null;
|
|
3662
3662
|
}
|
|
3663
3663
|
return literal;
|
|
@@ -3895,10 +3895,10 @@ function templateAssignment(template, embeddings) {
|
|
|
3895
3895
|
if (existingNode !== void 0 && existingNode !== nodeIndex) return null;
|
|
3896
3896
|
nodesByModuleId.set(moduleId, nodeIndex);
|
|
3897
3897
|
const node = template.nodes[nodeIndex];
|
|
3898
|
-
const
|
|
3898
|
+
const path23 = node.landmarkPath ?? `node_modules/${template.packageName}/__rnx_inferred__/${moduleId}.js`;
|
|
3899
3899
|
const existingPath = pathsByModuleId.get(moduleId);
|
|
3900
|
-
if (existingPath !== void 0 && existingPath !==
|
|
3901
|
-
pathsByModuleId.set(moduleId,
|
|
3900
|
+
if (existingPath !== void 0 && existingPath !== path23) return null;
|
|
3901
|
+
pathsByModuleId.set(moduleId, path23);
|
|
3902
3902
|
}
|
|
3903
3903
|
}
|
|
3904
3904
|
return {
|
|
@@ -4060,14 +4060,14 @@ async function inferMetroModuleIdentity(args) {
|
|
|
4060
4060
|
const packageClaims = claimsByPackage.values().next().value;
|
|
4061
4061
|
if (!packageClaims) continue;
|
|
4062
4062
|
const exactClaims = packageClaims.filter((assignment2) => {
|
|
4063
|
-
const
|
|
4064
|
-
return
|
|
4063
|
+
const path23 = assignment2.pathsByModuleId.get(moduleId);
|
|
4064
|
+
return path23 !== void 0 && !path23.includes("/__rnx_inferred__/");
|
|
4065
4065
|
});
|
|
4066
4066
|
const preferredClaims = exactClaims.length > 0 ? exactClaims : packageClaims;
|
|
4067
4067
|
const routes = new Set(
|
|
4068
4068
|
preferredClaims.flatMap((assignment2) => {
|
|
4069
|
-
const
|
|
4070
|
-
return
|
|
4069
|
+
const path23 = assignment2.pathsByModuleId.get(moduleId);
|
|
4070
|
+
return path23 ? [metroFingerprintModuleClaimRoute(assignment2.packageName, path23)] : [];
|
|
4071
4071
|
})
|
|
4072
4072
|
);
|
|
4073
4073
|
if (routes.size !== 1) continue;
|
|
@@ -4267,8 +4267,8 @@ function detectFramework(deps) {
|
|
|
4267
4267
|
return "unknown";
|
|
4268
4268
|
}
|
|
4269
4269
|
function detectProject(dir) {
|
|
4270
|
-
const pkgPath = (0,
|
|
4271
|
-
if (!(0,
|
|
4270
|
+
const pkgPath = (0, import_node_path27.join)(dir, "package.json");
|
|
4271
|
+
if (!(0, import_node_fs26.existsSync)(pkgPath)) return null;
|
|
4272
4272
|
const pkg = readProjectManifest(dir);
|
|
4273
4273
|
if (!pkg) return null;
|
|
4274
4274
|
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
@@ -4280,25 +4280,25 @@ function detectProject(dir) {
|
|
|
4280
4280
|
if (framework === "unknown") return null;
|
|
4281
4281
|
return {
|
|
4282
4282
|
dir,
|
|
4283
|
-
name: pkg.name || (0,
|
|
4283
|
+
name: pkg.name || (0, import_node_path27.basename)(dir),
|
|
4284
4284
|
framework,
|
|
4285
4285
|
// a config file is a config file whatever module system it declares. real
|
|
4286
4286
|
// apps write .cjs as often as .js, and missing one reads as "this project
|
|
4287
4287
|
// has no bundler config" and sends the user to create a second one.
|
|
4288
4288
|
hasViteConfig: CONFIG_EXTENSIONS.some(
|
|
4289
|
-
(ext) => (0,
|
|
4289
|
+
(ext) => (0, import_node_fs26.existsSync)((0, import_node_path27.join)(dir, `vite.config.${ext}`))
|
|
4290
4290
|
),
|
|
4291
4291
|
hasMetroConfig: CONFIG_EXTENSIONS.some(
|
|
4292
|
-
(ext) => (0,
|
|
4292
|
+
(ext) => (0, import_node_fs26.existsSync)((0, import_node_path27.join)(dir, `metro.config.${ext}`))
|
|
4293
4293
|
),
|
|
4294
4294
|
devCommand: typeof devCommand === "string" ? devCommand : null
|
|
4295
4295
|
};
|
|
4296
4296
|
}
|
|
4297
|
-
function readProjectMetadata(
|
|
4297
|
+
function readProjectMetadata(path23) {
|
|
4298
4298
|
try {
|
|
4299
|
-
const info = (0,
|
|
4299
|
+
const info = (0, import_node_fs26.lstatSync)(path23);
|
|
4300
4300
|
if (!info.isFile() || info.size > 4 * 1024 * 1024) return null;
|
|
4301
|
-
return (0,
|
|
4301
|
+
return (0, import_node_fs26.readFileSync)(path23, "utf8");
|
|
4302
4302
|
} catch {
|
|
4303
4303
|
return null;
|
|
4304
4304
|
}
|
|
@@ -4307,8 +4307,8 @@ function metadataValue(value, key) {
|
|
|
4307
4307
|
if (!value || typeof value !== "object") return void 0;
|
|
4308
4308
|
return Object.getOwnPropertyDescriptor(value, key)?.value;
|
|
4309
4309
|
}
|
|
4310
|
-
function readProjectJson(
|
|
4311
|
-
const text2 = readProjectMetadata(
|
|
4310
|
+
function readProjectJson(path23) {
|
|
4311
|
+
const text2 = readProjectMetadata(path23);
|
|
4312
4312
|
if (text2 === null) return null;
|
|
4313
4313
|
try {
|
|
4314
4314
|
const value = JSON.parse(text2);
|
|
@@ -4318,7 +4318,7 @@ function readProjectJson(path22) {
|
|
|
4318
4318
|
}
|
|
4319
4319
|
}
|
|
4320
4320
|
function readProjectManifest(dir) {
|
|
4321
|
-
const parsed = readProjectJson((0,
|
|
4321
|
+
const parsed = readProjectJson((0, import_node_path27.join)(dir, "package.json"));
|
|
4322
4322
|
if (!parsed || typeof parsed !== "object") return null;
|
|
4323
4323
|
const record2 = (value) => {
|
|
4324
4324
|
if (!value || typeof value !== "object") return {};
|
|
@@ -4335,12 +4335,12 @@ function readProjectManifest(dir) {
|
|
|
4335
4335
|
devDependencies: record2(metadataValue(parsed, "devDependencies"))
|
|
4336
4336
|
};
|
|
4337
4337
|
}
|
|
4338
|
-
var
|
|
4338
|
+
var import_node_fs26, import_node_path27, import_json52, import_yaml, CONFIG_EXTENSIONS;
|
|
4339
4339
|
var init_detect = __esm({
|
|
4340
4340
|
"cli/commands/detect.ts"() {
|
|
4341
4341
|
"use strict";
|
|
4342
|
-
|
|
4343
|
-
|
|
4342
|
+
import_node_fs26 = require("node:fs");
|
|
4343
|
+
import_node_path27 = require("node:path");
|
|
4344
4344
|
import_json52 = __toESM(require("json5"), 1);
|
|
4345
4345
|
import_yaml = require("yaml");
|
|
4346
4346
|
CONFIG_EXTENSIONS = ["ts", "js", "cjs", "mjs", "mts", "cts"];
|
|
@@ -4377,21 +4377,21 @@ function resolveCloudOrigin(value) {
|
|
|
4377
4377
|
return normalizeCloudOrigin(source);
|
|
4378
4378
|
}
|
|
4379
4379
|
function readImmutableBundleSource(bundlePath) {
|
|
4380
|
-
const filepath = (0,
|
|
4381
|
-
if ((0,
|
|
4380
|
+
const filepath = (0, import_node_path28.resolve)(bundlePath);
|
|
4381
|
+
if ((0, import_node_path28.extname)(filepath) !== ".js") {
|
|
4382
4382
|
throw new Error(`${REMOTE_COMMAND} requires one local Metro .js bundle`);
|
|
4383
4383
|
}
|
|
4384
|
-
const descriptor = (0,
|
|
4384
|
+
const descriptor = (0, import_node_fs27.openSync)(filepath, "r");
|
|
4385
4385
|
try {
|
|
4386
|
-
const before = (0,
|
|
4386
|
+
const before = (0, import_node_fs27.fstatSync)(descriptor, { bigint: true });
|
|
4387
4387
|
if (!before.isFile()) {
|
|
4388
4388
|
throw new Error(`${REMOTE_COMMAND} bundle must be a regular local file`);
|
|
4389
4389
|
}
|
|
4390
4390
|
if (before.size <= 0n) {
|
|
4391
4391
|
throw new Error(`${REMOTE_COMMAND} bundle is empty`);
|
|
4392
4392
|
}
|
|
4393
|
-
const bytes = (0,
|
|
4394
|
-
const after = (0,
|
|
4393
|
+
const bytes = (0, import_node_fs27.readFileSync)(descriptor);
|
|
4394
|
+
const after = (0, import_node_fs27.fstatSync)(descriptor, { bigint: true });
|
|
4395
4395
|
if (before.dev !== after.dev || before.ino !== after.ino || before.size !== after.size || before.mtimeNs !== after.mtimeNs || bytes.length !== Number(before.size)) {
|
|
4396
4396
|
throw new Error(`${REMOTE_COMMAND} bundle changed while it was being read`);
|
|
4397
4397
|
}
|
|
@@ -4406,7 +4406,7 @@ function readImmutableBundleSource(bundlePath) {
|
|
|
4406
4406
|
}
|
|
4407
4407
|
return source;
|
|
4408
4408
|
} finally {
|
|
4409
|
-
(0,
|
|
4409
|
+
(0, import_node_fs27.closeSync)(descriptor);
|
|
4410
4410
|
}
|
|
4411
4411
|
}
|
|
4412
4412
|
async function fetchBundleSource(bundleUrl) {
|
|
@@ -4453,15 +4453,15 @@ async function loadBundleSource(bundleInput) {
|
|
|
4453
4453
|
return readImmutableBundleSource(bundleInput);
|
|
4454
4454
|
}
|
|
4455
4455
|
function listMetroAssetDest(assetsPath) {
|
|
4456
|
-
const directory = (0,
|
|
4457
|
-
if (!(0,
|
|
4458
|
-
const skipNested = (0,
|
|
4456
|
+
const directory = (0, import_node_path28.resolve)(assetsPath);
|
|
4457
|
+
if (!(0, import_node_fs27.existsSync)(directory)) return { directory, files: [], truncated: false };
|
|
4458
|
+
const skipNested = (0, import_node_fs27.existsSync)((0, import_node_path28.join)(directory, "package.json"));
|
|
4459
4459
|
const files = [];
|
|
4460
4460
|
let truncated = false;
|
|
4461
4461
|
const walk2 = (dir, prefix) => {
|
|
4462
4462
|
let entries;
|
|
4463
4463
|
try {
|
|
4464
|
-
entries = (0,
|
|
4464
|
+
entries = (0, import_node_fs27.readdirSync)(dir, { withFileTypes: true });
|
|
4465
4465
|
} catch {
|
|
4466
4466
|
return;
|
|
4467
4467
|
}
|
|
@@ -4473,7 +4473,7 @@ function listMetroAssetDest(assetsPath) {
|
|
|
4473
4473
|
if (entry.isDirectory()) {
|
|
4474
4474
|
if (entry.name === ".git") continue;
|
|
4475
4475
|
if (skipNested && PROJECT_ONLY_DIRECTORIES.has(entry.name)) continue;
|
|
4476
|
-
walk2((0,
|
|
4476
|
+
walk2((0, import_node_path28.join)(dir, entry.name), prefix ? `${prefix}/${entry.name}` : entry.name);
|
|
4477
4477
|
} else if (entry.isFile()) {
|
|
4478
4478
|
files.push(prefix ? `${prefix}/${entry.name}` : entry.name);
|
|
4479
4479
|
}
|
|
@@ -4483,7 +4483,7 @@ function listMetroAssetDest(assetsPath) {
|
|
|
4483
4483
|
return { directory, files, truncated };
|
|
4484
4484
|
}
|
|
4485
4485
|
function metroDescriptorHash(scaleBytes) {
|
|
4486
|
-
const hasher = (0,
|
|
4486
|
+
const hasher = (0, import_node_crypto13.createHash)("md5");
|
|
4487
4487
|
for (const bytes of scaleBytes) hasher.update(bytes);
|
|
4488
4488
|
return hasher.digest("hex");
|
|
4489
4489
|
}
|
|
@@ -4508,11 +4508,11 @@ function distinctByContent(directory, options) {
|
|
|
4508
4508
|
for (const relative2 of options) {
|
|
4509
4509
|
let bytes;
|
|
4510
4510
|
try {
|
|
4511
|
-
bytes = (0,
|
|
4511
|
+
bytes = (0, import_node_fs27.readFileSync)((0, import_node_path28.join)(directory, relative2));
|
|
4512
4512
|
} catch {
|
|
4513
4513
|
continue;
|
|
4514
4514
|
}
|
|
4515
|
-
const digest = (0,
|
|
4515
|
+
const digest = (0, import_node_crypto13.createHash)("md5").update(bytes).digest("hex");
|
|
4516
4516
|
if (!byContent.has(digest)) byContent.set(digest, relative2);
|
|
4517
4517
|
}
|
|
4518
4518
|
return [...byContent.values()];
|
|
@@ -4540,13 +4540,13 @@ function placeMetroDescriptor(listing, descriptor) {
|
|
|
4540
4540
|
let bytes;
|
|
4541
4541
|
try {
|
|
4542
4542
|
bytes = combination.map(
|
|
4543
|
-
(relative2) => (0,
|
|
4543
|
+
(relative2) => (0, import_node_fs27.readFileSync)((0, import_node_path28.join)(listing.directory, relative2))
|
|
4544
4544
|
);
|
|
4545
4545
|
} catch {
|
|
4546
4546
|
continue;
|
|
4547
4547
|
}
|
|
4548
4548
|
const identical = fileHashes ? bytes.every((file, index) => {
|
|
4549
|
-
const digest = (0,
|
|
4549
|
+
const digest = (0, import_node_crypto13.createHash)("md5").update(file).digest("hex");
|
|
4550
4550
|
return descriptor.scales.some(
|
|
4551
4551
|
(scale, declared) => scale === scales[index] && fileHashes[declared] === digest
|
|
4552
4552
|
);
|
|
@@ -4568,10 +4568,10 @@ function unverifiedContentKey(dest, fileDigests) {
|
|
|
4568
4568
|
return JSON.stringify(
|
|
4569
4569
|
dest.placements.map(
|
|
4570
4570
|
(placement) => placement.verified ? null : [...placement.files].map(([scale, relative2]) => {
|
|
4571
|
-
const file = (0,
|
|
4571
|
+
const file = (0, import_node_path28.join)(dest.directory, relative2);
|
|
4572
4572
|
let digest = fileDigests.get(file);
|
|
4573
4573
|
if (digest === void 0) {
|
|
4574
|
-
digest = (0,
|
|
4574
|
+
digest = (0, import_node_crypto13.createHash)("sha256").update((0, import_node_fs27.readFileSync)(file)).digest("hex");
|
|
4575
4575
|
fileDigests.set(file, digest);
|
|
4576
4576
|
}
|
|
4577
4577
|
return [scale, digest];
|
|
@@ -4580,22 +4580,22 @@ function unverifiedContentKey(dest, fileDigests) {
|
|
|
4580
4580
|
);
|
|
4581
4581
|
}
|
|
4582
4582
|
function searchMetroAssetDest(bundlePath, descriptors) {
|
|
4583
|
-
const bundleDirectory = (0,
|
|
4583
|
+
const bundleDirectory = (0, import_node_path28.dirname)((0, import_node_path28.resolve)(bundlePath));
|
|
4584
4584
|
const candidates = [
|
|
4585
|
-
(0,
|
|
4585
|
+
(0, import_node_path28.join)(bundleDirectory, "assets"),
|
|
4586
4586
|
bundleDirectory,
|
|
4587
|
-
(0,
|
|
4587
|
+
(0, import_node_path28.resolve)(bundleDirectory, "..", "assets")
|
|
4588
4588
|
];
|
|
4589
4589
|
const cwd = process.cwd();
|
|
4590
4590
|
let projectDirectory = null;
|
|
4591
4591
|
for (const start of [bundleDirectory, cwd]) {
|
|
4592
|
-
let directory = (0,
|
|
4592
|
+
let directory = (0, import_node_path28.resolve)(start);
|
|
4593
4593
|
while (true) {
|
|
4594
4594
|
if (detectProject(directory)?.hasMetroConfig) {
|
|
4595
4595
|
projectDirectory = directory;
|
|
4596
4596
|
break;
|
|
4597
4597
|
}
|
|
4598
|
-
const parent = (0,
|
|
4598
|
+
const parent = (0, import_node_path28.dirname)(directory);
|
|
4599
4599
|
if (parent === directory) break;
|
|
4600
4600
|
directory = parent;
|
|
4601
4601
|
}
|
|
@@ -4603,11 +4603,11 @@ function searchMetroAssetDest(bundlePath, descriptors) {
|
|
|
4603
4603
|
}
|
|
4604
4604
|
if (projectDirectory) {
|
|
4605
4605
|
candidates.push(
|
|
4606
|
-
(0,
|
|
4607
|
-
(0,
|
|
4608
|
-
(0,
|
|
4609
|
-
(0,
|
|
4610
|
-
(0,
|
|
4606
|
+
(0, import_node_path28.join)(projectDirectory, "assets"),
|
|
4607
|
+
(0, import_node_path28.join)(projectDirectory, "dist"),
|
|
4608
|
+
(0, import_node_path28.join)(projectDirectory, "dist", "assets"),
|
|
4609
|
+
(0, import_node_path28.join)(projectDirectory, "build"),
|
|
4610
|
+
(0, import_node_path28.join)(projectDirectory, "build", "assets")
|
|
4611
4611
|
);
|
|
4612
4612
|
}
|
|
4613
4613
|
const searched = [];
|
|
@@ -4615,7 +4615,7 @@ function searchMetroAssetDest(bundlePath, descriptors) {
|
|
|
4615
4615
|
const stale = [];
|
|
4616
4616
|
let truncated = false;
|
|
4617
4617
|
for (const candidate of candidates) {
|
|
4618
|
-
const directory = (0,
|
|
4618
|
+
const directory = (0, import_node_path28.resolve)(candidate);
|
|
4619
4619
|
if (searched.includes(directory)) continue;
|
|
4620
4620
|
searched.push(directory);
|
|
4621
4621
|
const listing = listMetroAssetDest(directory);
|
|
@@ -4724,7 +4724,7 @@ async function embedBundleAssets(bundlePath, command, assetPolicy) {
|
|
|
4724
4724
|
);
|
|
4725
4725
|
}
|
|
4726
4726
|
const relative2 = placement?.files.get(variant.scale);
|
|
4727
|
-
if (relative2 && dest) return (0,
|
|
4727
|
+
if (relative2 && dest) return (0, import_node_fs27.readFileSync)((0, import_node_path28.join)(dest.directory, relative2));
|
|
4728
4728
|
if (placement && placement.files.size > 0) return null;
|
|
4729
4729
|
if (placement && placement.ambiguous.length > 0 && dest) {
|
|
4730
4730
|
throw new Error(
|
|
@@ -4753,7 +4753,7 @@ async function embedBundleAssets(bundlePath, command, assetPolicy) {
|
|
|
4753
4753
|
);
|
|
4754
4754
|
const classic = metroIosAssetDestRelatives(variant.descriptor.httpServerLocation, filename)[0] ?? filename;
|
|
4755
4755
|
throw new Error(
|
|
4756
|
-
`${command} could not read ${(0,
|
|
4756
|
+
`${command} could not read ${(0, import_node_path28.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\`.`
|
|
4757
4757
|
);
|
|
4758
4758
|
});
|
|
4759
4759
|
return {
|
|
@@ -4794,7 +4794,7 @@ async function produceArtifact(bundlePath, maxBytes, command, assetPolicy) {
|
|
|
4794
4794
|
}
|
|
4795
4795
|
return {
|
|
4796
4796
|
bytes,
|
|
4797
|
-
sha256: (0,
|
|
4797
|
+
sha256: (0, import_node_crypto13.createHash)("sha256").update(bytes).digest("hex"),
|
|
4798
4798
|
receipt: artifact.receipt,
|
|
4799
4799
|
assetsDirectory: prepared.dest?.directory ?? null,
|
|
4800
4800
|
warnings
|
|
@@ -4899,13 +4899,13 @@ async function createCloudBox(options) {
|
|
|
4899
4899
|
warnings: artifact.warnings
|
|
4900
4900
|
};
|
|
4901
4901
|
}
|
|
4902
|
-
var
|
|
4902
|
+
var import_node_crypto13, import_node_fs27, import_node_path28, DEFAULT_RNX_CLOUD_ORIGIN, MAX_RNX_CLOUD_BUNDLE_BYTES, REMOTE_COMMAND, MAX_ASSET_DEST_FILES, ACCOUNT_CHOICE_REFUSALS, PROJECT_ONLY_DIRECTORIES, MAX_PLACEMENT_COMBINATIONS;
|
|
4903
4903
|
var init_cloud_client = __esm({
|
|
4904
4904
|
"cli/cloud-client.ts"() {
|
|
4905
4905
|
"use strict";
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
|
|
4906
|
+
import_node_crypto13 = require("node:crypto");
|
|
4907
|
+
import_node_fs27 = require("node:fs");
|
|
4908
|
+
import_node_path28 = require("node:path");
|
|
4909
4909
|
init_metroAssetArtifact();
|
|
4910
4910
|
init_metroCloudArtifact();
|
|
4911
4911
|
init_metro_fingerprint_registry_client();
|
|
@@ -5343,9 +5343,9 @@ function safeChildPlistName(value) {
|
|
|
5343
5343
|
name: file.toLowerCase().endsWith(".plist") ? file : `${file}.plist`
|
|
5344
5344
|
};
|
|
5345
5345
|
}
|
|
5346
|
-
async function readableSettingsBundle(
|
|
5346
|
+
async function readableSettingsBundle(path23) {
|
|
5347
5347
|
try {
|
|
5348
|
-
const root = await (0, import_promises.stat)((0, import_node_path.join)(
|
|
5348
|
+
const root = await (0, import_promises.stat)((0, import_node_path.join)(path23, "Root.plist"));
|
|
5349
5349
|
return root.isFile() && root.size <= MAX_PLIST_BYTES;
|
|
5350
5350
|
} catch {
|
|
5351
5351
|
return false;
|
|
@@ -5390,11 +5390,11 @@ async function settingsBundleFingerprint(bundlePath) {
|
|
|
5390
5390
|
return null;
|
|
5391
5391
|
}
|
|
5392
5392
|
}
|
|
5393
|
-
async function parsePlistRecord(
|
|
5393
|
+
async function parsePlistRecord(path23) {
|
|
5394
5394
|
try {
|
|
5395
|
-
const metadata = await (0, import_promises.stat)(
|
|
5395
|
+
const metadata = await (0, import_promises.stat)(path23);
|
|
5396
5396
|
if (!metadata.isFile() || metadata.size > MAX_PLIST_BYTES) return null;
|
|
5397
|
-
const source = await (0, import_promises.readFile)(
|
|
5397
|
+
const source = await (0, import_promises.readFile)(path23, "utf8");
|
|
5398
5398
|
const parsed = parsePlistSource(source);
|
|
5399
5399
|
return isRecord2(parsed) ? parsed : null;
|
|
5400
5400
|
} catch {
|
|
@@ -5656,7 +5656,7 @@ async function tcpPing(port, timeout = TCP_GATE_MS) {
|
|
|
5656
5656
|
return null;
|
|
5657
5657
|
}
|
|
5658
5658
|
}
|
|
5659
|
-
function httpGet(hostname, port,
|
|
5659
|
+
function httpGet(hostname, port, path23, method = "GET", timeout = TIMEOUT_MS, headers = {}) {
|
|
5660
5660
|
return new Promise((resolve5) => {
|
|
5661
5661
|
let settled = false;
|
|
5662
5662
|
let killing = false;
|
|
@@ -5665,7 +5665,7 @@ function httpGet(hostname, port, path22, method = "GET", timeout = TIMEOUT_MS, h
|
|
|
5665
5665
|
settled = true;
|
|
5666
5666
|
resolve5(value);
|
|
5667
5667
|
};
|
|
5668
|
-
const req = import_http.default.request({ hostname, port, path:
|
|
5668
|
+
const req = import_http.default.request({ hostname, port, path: path23, method, headers }, (res) => {
|
|
5669
5669
|
let body = "";
|
|
5670
5670
|
res.on("data", (c) => body += c.toString());
|
|
5671
5671
|
const contentType = (() => {
|
|
@@ -6344,12 +6344,12 @@ function getCliVersion() {
|
|
|
6344
6344
|
}
|
|
6345
6345
|
|
|
6346
6346
|
// src/expo-swift-host.ts
|
|
6347
|
-
var
|
|
6348
|
-
var
|
|
6349
|
-
var
|
|
6347
|
+
var import_node_child_process8 = require("node:child_process");
|
|
6348
|
+
var import_node_crypto8 = require("node:crypto");
|
|
6349
|
+
var import_node_fs18 = __toESM(require("node:fs"), 1);
|
|
6350
6350
|
var import_node_module = require("node:module");
|
|
6351
|
-
var
|
|
6352
|
-
var
|
|
6351
|
+
var import_node_os8 = __toESM(require("node:os"), 1);
|
|
6352
|
+
var import_node_path19 = __toESM(require("node:path"), 1);
|
|
6353
6353
|
var import_node_util3 = require("node:util");
|
|
6354
6354
|
|
|
6355
6355
|
// cli/internal-child.ts
|
|
@@ -7270,14 +7270,14 @@ function liftExtensionOverrides(source, extraObjCExtensions) {
|
|
|
7270
7270
|
const args = forwardedArguments(source.slice(open + 1, close));
|
|
7271
7271
|
if (args === null) continue;
|
|
7272
7272
|
const call = (clause.includes("->") ? "return " : "") + (/\b(?:throws|rethrows)\b/.test(clause) ? "try " : "") + (/\basync\b/.test(clause) ? "await " : "") + `__peach_ext_${name2}(${args})`;
|
|
7273
|
-
const
|
|
7273
|
+
const signature2 = `func ${name2}${func[3] ?? ""}${source.slice(open, close + 1)}${clause ? ` ${clause}` : ""}`;
|
|
7274
7274
|
const nameAt = at + rest.indexOf(name2, rest.indexOf("func", "override".length + func[1].length) + 4);
|
|
7275
7275
|
lifted.push({
|
|
7276
7276
|
type: top.name,
|
|
7277
7277
|
member: name2,
|
|
7278
7278
|
at,
|
|
7279
7279
|
modifiers,
|
|
7280
|
-
decl:
|
|
7280
|
+
decl: signature2,
|
|
7281
7281
|
forward: `{ ${call} };`,
|
|
7282
7282
|
nameAt,
|
|
7283
7283
|
edits: [
|
|
@@ -8604,11 +8604,10 @@ function swiftModuleToolchain(root) {
|
|
|
8604
8604
|
}
|
|
8605
8605
|
|
|
8606
8606
|
// src/swift-host.ts
|
|
8607
|
-
var
|
|
8608
|
-
var
|
|
8609
|
-
var
|
|
8610
|
-
var
|
|
8611
|
-
var import_node_path17 = __toESM(require("node:path"), 1);
|
|
8607
|
+
var import_node_crypto7 = require("node:crypto");
|
|
8608
|
+
var import_node_fs17 = __toESM(require("node:fs"), 1);
|
|
8609
|
+
var import_node_os7 = __toESM(require("node:os"), 1);
|
|
8610
|
+
var import_node_path18 = __toESM(require("node:path"), 1);
|
|
8612
8611
|
|
|
8613
8612
|
// ../sootsim-swift/src/bundleAssets.ts
|
|
8614
8613
|
var import_svgpath = __toESM(require("svgpath"), 1);
|
|
@@ -8642,8 +8641,8 @@ function pickImagesetFile(images) {
|
|
|
8642
8641
|
scale: pick.scale === "2x" ? 2 : pick.scale === "3x" ? 3 : 1
|
|
8643
8642
|
};
|
|
8644
8643
|
}
|
|
8645
|
-
function flatScale(
|
|
8646
|
-
const match = /@([23])x\.[^./]+$/.exec(
|
|
8644
|
+
function flatScale(path23) {
|
|
8645
|
+
const match = /@([23])x\.[^./]+$/.exec(path23);
|
|
8647
8646
|
return match ? Number(match[1]) : 1;
|
|
8648
8647
|
}
|
|
8649
8648
|
function providesNamespace(text2) {
|
|
@@ -8670,13 +8669,13 @@ function catalogEntryName(contentsPath, kind, readText) {
|
|
|
8670
8669
|
}
|
|
8671
8670
|
return segments.join("/");
|
|
8672
8671
|
}
|
|
8673
|
-
function isFlatResourceImage(
|
|
8674
|
-
return
|
|
8672
|
+
function isFlatResourceImage(path23) {
|
|
8673
|
+
return path23.split("/").includes("Resources") && RASTER_EXTENSIONS.has(extOf(path23));
|
|
8675
8674
|
}
|
|
8676
8675
|
function enumerateBundleImages(paths, readText) {
|
|
8677
8676
|
const table = [];
|
|
8678
8677
|
const seen = /* @__PURE__ */ new Set();
|
|
8679
|
-
const catalogs = paths.filter((
|
|
8678
|
+
const catalogs = paths.filter((path23) => baseOf(path23) === "Contents.json");
|
|
8680
8679
|
for (const contentsPath of catalogs) {
|
|
8681
8680
|
const name2 = catalogEntryName(contentsPath, ".imageset", readText);
|
|
8682
8681
|
if (name2 === null || seen.has(name2)) continue;
|
|
@@ -8697,12 +8696,12 @@ function enumerateBundleImages(paths, readText) {
|
|
|
8697
8696
|
seen.add(name2);
|
|
8698
8697
|
table.push({ name: name2, file: `${dir}/${pick.filename}`, scale: pick.scale });
|
|
8699
8698
|
}
|
|
8700
|
-
for (const
|
|
8701
|
-
if (!isFlatResourceImage(
|
|
8702
|
-
const name2 = baseOf(
|
|
8699
|
+
for (const path23 of paths) {
|
|
8700
|
+
if (!isFlatResourceImage(path23)) continue;
|
|
8701
|
+
const name2 = baseOf(path23).slice(0, -extOf(path23).length);
|
|
8703
8702
|
if (name2 === "" || seen.has(name2)) continue;
|
|
8704
8703
|
seen.add(name2);
|
|
8705
|
-
table.push({ name: name2, file:
|
|
8704
|
+
table.push({ name: name2, file: path23, scale: flatScale(path23) });
|
|
8706
8705
|
}
|
|
8707
8706
|
return table;
|
|
8708
8707
|
}
|
|
@@ -8731,7 +8730,7 @@ function colorsetValue(color) {
|
|
|
8731
8730
|
}
|
|
8732
8731
|
function enumerateBundleColors(paths, readText) {
|
|
8733
8732
|
const table = {};
|
|
8734
|
-
for (const contentsPath of paths.filter((
|
|
8733
|
+
for (const contentsPath of paths.filter((path23) => baseOf(path23) === "Contents.json")) {
|
|
8735
8734
|
const name2 = catalogEntryName(contentsPath, ".colorset", readText);
|
|
8736
8735
|
if (name2 === null || name2 in table) continue;
|
|
8737
8736
|
let colors;
|
|
@@ -8796,8 +8795,8 @@ function axisExtremes(points) {
|
|
|
8796
8795
|
function pathBounds(d) {
|
|
8797
8796
|
const xs = [];
|
|
8798
8797
|
const ys = [];
|
|
8799
|
-
for (const
|
|
8800
|
-
(0, import_svgpath.default)(
|
|
8798
|
+
for (const path23 of d)
|
|
8799
|
+
(0, import_svgpath.default)(path23).abs().unshort().unarc().iterate((segment, _index, x, y) => {
|
|
8801
8800
|
const [command, ...args] = segment;
|
|
8802
8801
|
if (command === "M" || command === "L") {
|
|
8803
8802
|
xs.push(Number(args[0]));
|
|
@@ -8824,7 +8823,7 @@ function guide(svg, id, axis) {
|
|
|
8824
8823
|
}
|
|
8825
8824
|
function enumerateBundleSymbols(paths, readText) {
|
|
8826
8825
|
const table = {};
|
|
8827
|
-
for (const contentsPath of paths.filter((
|
|
8826
|
+
for (const contentsPath of paths.filter((path23) => baseOf(path23) === "Contents.json")) {
|
|
8828
8827
|
const name2 = catalogEntryName(contentsPath, ".symbolset", readText);
|
|
8829
8828
|
if (name2 === null || name2 in table) continue;
|
|
8830
8829
|
let symbols;
|
|
@@ -8857,8 +8856,8 @@ function enumerateBundleSymbols(paths, readText) {
|
|
|
8857
8856
|
viewBox: "0 0 24 24",
|
|
8858
8857
|
advance,
|
|
8859
8858
|
box: [12 - advance / 2, 12 - tall / 2, advance, tall],
|
|
8860
|
-
layers: d.map((
|
|
8861
|
-
d: (0, import_svgpath.default)(
|
|
8859
|
+
layers: d.map((path23) => ({
|
|
8860
|
+
d: (0, import_svgpath.default)(path23).abs().scale(scale).translate(translateX, translateY).round(3).toString()
|
|
8862
8861
|
}))
|
|
8863
8862
|
};
|
|
8864
8863
|
}
|
|
@@ -8868,7 +8867,7 @@ function enumerateBundleJson(paths) {
|
|
|
8868
8867
|
const found = [];
|
|
8869
8868
|
const seen = /* @__PURE__ */ new Set();
|
|
8870
8869
|
const ordered = [...paths].filter(
|
|
8871
|
-
(
|
|
8870
|
+
(path23) => path23.split("/").includes("Resources") && path23.split("/").every((segment) => segment !== "" && segment !== "..") && (extOf(path23) === ".json" || extOf(path23) === ".xcstrings")
|
|
8872
8871
|
).sort((a, b) => {
|
|
8873
8872
|
const aDepth = a.split("/").length;
|
|
8874
8873
|
const bDepth = b.split("/").length;
|
|
@@ -8887,17 +8886,392 @@ function enumerateBundleJson(paths) {
|
|
|
8887
8886
|
init_auth();
|
|
8888
8887
|
init_backend_origin();
|
|
8889
8888
|
|
|
8890
|
-
// src/
|
|
8891
|
-
var
|
|
8892
|
-
|
|
8893
|
-
|
|
8889
|
+
// src/ios-sdk-frameworks.json
|
|
8890
|
+
var ios_sdk_frameworks_default = {
|
|
8891
|
+
sdk: "iphonesimulator27.1",
|
|
8892
|
+
frameworks: [
|
|
8893
|
+
"ARKit",
|
|
8894
|
+
"AVFAudio",
|
|
8895
|
+
"AVFoundation",
|
|
8896
|
+
"AVKit",
|
|
8897
|
+
"AVRouting",
|
|
8898
|
+
"Accelerate",
|
|
8899
|
+
"Accessibility",
|
|
8900
|
+
"AccessoryLiveActivities",
|
|
8901
|
+
"AccessoryNotifications",
|
|
8902
|
+
"AccessorySetupKit",
|
|
8903
|
+
"AccessoryTransportExtension",
|
|
8904
|
+
"Accounts",
|
|
8905
|
+
"ActivityKit",
|
|
8906
|
+
"AdAttributionKit",
|
|
8907
|
+
"AdServices",
|
|
8908
|
+
"AdSupport",
|
|
8909
|
+
"AddressBook",
|
|
8910
|
+
"AddressBookUI",
|
|
8911
|
+
"AlarmKit",
|
|
8912
|
+
"AppClip",
|
|
8913
|
+
"AppIntents",
|
|
8914
|
+
"AppIntentsTypeSupport",
|
|
8915
|
+
"AppMigrationKit",
|
|
8916
|
+
"AppTrackingTransparency",
|
|
8917
|
+
"AssetsLibrary",
|
|
8918
|
+
"AudioToolbox",
|
|
8919
|
+
"AudioUnit",
|
|
8920
|
+
"AuthenticationServices",
|
|
8921
|
+
"AutomatedDeviceEnrollment",
|
|
8922
|
+
"AutomaticAssessmentConfiguration",
|
|
8923
|
+
"BackgroundAssets",
|
|
8924
|
+
"BackgroundTasks",
|
|
8925
|
+
"BrowserEngineCore",
|
|
8926
|
+
"BrowserEngineKit",
|
|
8927
|
+
"BrowserKit",
|
|
8928
|
+
"BusinessChat",
|
|
8929
|
+
"CFNetwork",
|
|
8930
|
+
"CallKit",
|
|
8931
|
+
"CarKey",
|
|
8932
|
+
"CarPlay",
|
|
8933
|
+
"Charts",
|
|
8934
|
+
"ClassKit",
|
|
8935
|
+
"ClassKitUI",
|
|
8936
|
+
"ClockKit",
|
|
8937
|
+
"CloudKit",
|
|
8938
|
+
"ColorSync",
|
|
8939
|
+
"Combine",
|
|
8940
|
+
"ComputeGraph",
|
|
8941
|
+
"ContactProvider",
|
|
8942
|
+
"Contacts",
|
|
8943
|
+
"ContactsUI",
|
|
8944
|
+
"CoreAudio",
|
|
8945
|
+
"CoreAudioKit",
|
|
8946
|
+
"CoreAudioTypes",
|
|
8947
|
+
"CoreBluetooth",
|
|
8948
|
+
"CoreData",
|
|
8949
|
+
"CoreFoundation",
|
|
8950
|
+
"CoreGraphics",
|
|
8951
|
+
"CoreHaptics",
|
|
8952
|
+
"CoreImage",
|
|
8953
|
+
"CoreLocation",
|
|
8954
|
+
"CoreLocationUI",
|
|
8955
|
+
"CoreMIDI",
|
|
8956
|
+
"CoreML",
|
|
8957
|
+
"CoreMedia",
|
|
8958
|
+
"CoreMotion",
|
|
8959
|
+
"CoreNFC",
|
|
8960
|
+
"CoreServices",
|
|
8961
|
+
"CoreSpotlight",
|
|
8962
|
+
"CoreTelephony",
|
|
8963
|
+
"CoreText",
|
|
8964
|
+
"CoreTransferable",
|
|
8965
|
+
"CoreVideo",
|
|
8966
|
+
"CreateMLComponents",
|
|
8967
|
+
"CryptoKit",
|
|
8968
|
+
"CryptoTokenKit",
|
|
8969
|
+
"DataDetection",
|
|
8970
|
+
"DeclaredAgeRange",
|
|
8971
|
+
"DeveloperToolsSupport",
|
|
8972
|
+
"DeviceActivity",
|
|
8973
|
+
"DeviceCheck",
|
|
8974
|
+
"DeviceDiscoveryExtension",
|
|
8975
|
+
"DeviceDiscoveryUI",
|
|
8976
|
+
"EnergyKit",
|
|
8977
|
+
"EventKit",
|
|
8978
|
+
"EventKitUI",
|
|
8979
|
+
"ExposureNotification",
|
|
8980
|
+
"ExtensionFoundation",
|
|
8981
|
+
"ExtensionKit",
|
|
8982
|
+
"ExternalAccessory",
|
|
8983
|
+
"FamilyControls",
|
|
8984
|
+
"FileProvider",
|
|
8985
|
+
"FileProviderUI",
|
|
8986
|
+
"FinanceKit",
|
|
8987
|
+
"FinanceKitUI",
|
|
8988
|
+
"Foundation",
|
|
8989
|
+
"FoundationModels",
|
|
8990
|
+
"GLKit",
|
|
8991
|
+
"GSS",
|
|
8992
|
+
"GameController",
|
|
8993
|
+
"GameKit",
|
|
8994
|
+
"GameSave",
|
|
8995
|
+
"GameplayKit",
|
|
8996
|
+
"GeoToolbox",
|
|
8997
|
+
"GroupActivities",
|
|
8998
|
+
"HealthKit",
|
|
8999
|
+
"HealthKitUI",
|
|
9000
|
+
"HomeKit",
|
|
9001
|
+
"IOKit",
|
|
9002
|
+
"IOSurface",
|
|
9003
|
+
"IdentityDocumentServices",
|
|
9004
|
+
"IdentityDocumentServicesUI",
|
|
9005
|
+
"IdentityLookup",
|
|
9006
|
+
"IdentityLookupUI",
|
|
9007
|
+
"ImageCaptureCore",
|
|
9008
|
+
"ImageIO",
|
|
9009
|
+
"ImagePlayground",
|
|
9010
|
+
"ImmersiveMediaSupport",
|
|
9011
|
+
"Intents",
|
|
9012
|
+
"IntentsUI",
|
|
9013
|
+
"JavaScriptCore",
|
|
9014
|
+
"LinkPresentation",
|
|
9015
|
+
"LinkSecurity",
|
|
9016
|
+
"LiveCommunicationKit",
|
|
9017
|
+
"LocalAuthentication",
|
|
9018
|
+
"LocalAuthenticationEmbeddedUI",
|
|
9019
|
+
"LockedCameraCapture",
|
|
9020
|
+
"ManagedApp",
|
|
9021
|
+
"ManagedAppDistribution",
|
|
9022
|
+
"ManagedSettings",
|
|
9023
|
+
"ManagedSettingsUI",
|
|
9024
|
+
"MapKit",
|
|
9025
|
+
"MarketplaceKit",
|
|
9026
|
+
"Matter",
|
|
9027
|
+
"MatterSupport",
|
|
9028
|
+
"MediaAccessibility",
|
|
9029
|
+
"MediaIntelligence",
|
|
9030
|
+
"MediaIntents",
|
|
9031
|
+
"MediaPlayer",
|
|
9032
|
+
"MediaToolbox",
|
|
9033
|
+
"MessageUI",
|
|
9034
|
+
"Messages",
|
|
9035
|
+
"Metal",
|
|
9036
|
+
"MetalKit",
|
|
9037
|
+
"MetalPerformancePrimitives",
|
|
9038
|
+
"MetalPerformanceShaders",
|
|
9039
|
+
"MetalPerformanceShadersGraph",
|
|
9040
|
+
"MetricKit",
|
|
9041
|
+
"MobileCoreServices",
|
|
9042
|
+
"ModelIO",
|
|
9043
|
+
"MultipeerConnectivity",
|
|
9044
|
+
"MusicKit",
|
|
9045
|
+
"MusicUnderstanding",
|
|
9046
|
+
"NaturalLanguage",
|
|
9047
|
+
"NearbyInteraction",
|
|
9048
|
+
"Network",
|
|
9049
|
+
"NetworkExtension",
|
|
9050
|
+
"NotificationCenter",
|
|
9051
|
+
"NowPlaying",
|
|
9052
|
+
"OSLog",
|
|
9053
|
+
"OpenAL",
|
|
9054
|
+
"OpenGLES",
|
|
9055
|
+
"PDFKit",
|
|
9056
|
+
"PHASE",
|
|
9057
|
+
"PaperKit",
|
|
9058
|
+
"PassKit",
|
|
9059
|
+
"PencilKit",
|
|
9060
|
+
"PermissionKit",
|
|
9061
|
+
"Photos",
|
|
9062
|
+
"PhotosUI",
|
|
9063
|
+
"ProximityReader",
|
|
9064
|
+
"PushKit",
|
|
9065
|
+
"PushToTalk",
|
|
9066
|
+
"QuartzCore",
|
|
9067
|
+
"QuickLook",
|
|
9068
|
+
"QuickLookThumbnailing",
|
|
9069
|
+
"RealityFoundation",
|
|
9070
|
+
"RealityKit",
|
|
9071
|
+
"RelevanceKit",
|
|
9072
|
+
"ReplayKit",
|
|
9073
|
+
"RoomPlan",
|
|
9074
|
+
"SafariServices",
|
|
9075
|
+
"SafetyKit",
|
|
9076
|
+
"SceneKit",
|
|
9077
|
+
"ScreenTime",
|
|
9078
|
+
"SecureElementCredential",
|
|
9079
|
+
"Security",
|
|
9080
|
+
"SecurityUI",
|
|
9081
|
+
"SensitiveContentAnalysis",
|
|
9082
|
+
"SensorKit",
|
|
9083
|
+
"ServicesAccountLinking",
|
|
9084
|
+
"SharedWithYou",
|
|
9085
|
+
"SharedWithYouCore",
|
|
9086
|
+
"ShazamKit",
|
|
9087
|
+
"Social",
|
|
9088
|
+
"SoundAnalysis",
|
|
9089
|
+
"Speech",
|
|
9090
|
+
"SpriteKit",
|
|
9091
|
+
"StateReporting",
|
|
9092
|
+
"StoreKit",
|
|
9093
|
+
"SuggestedActions",
|
|
9094
|
+
"SwiftData",
|
|
9095
|
+
"SwiftUI",
|
|
9096
|
+
"SwiftUICore",
|
|
9097
|
+
"Symbols",
|
|
9098
|
+
"SystemConfiguration",
|
|
9099
|
+
"SystemExtensions",
|
|
9100
|
+
"TabularData",
|
|
9101
|
+
"TelephonyMessagingKit",
|
|
9102
|
+
"TipKit",
|
|
9103
|
+
"TouchController",
|
|
9104
|
+
"Translation",
|
|
9105
|
+
"TranslationUIProvider",
|
|
9106
|
+
"TrustInsights",
|
|
9107
|
+
"Twitter",
|
|
9108
|
+
"UIKit",
|
|
9109
|
+
"USDKit",
|
|
9110
|
+
"UniformTypeIdentifiers",
|
|
9111
|
+
"UserNotifications",
|
|
9112
|
+
"UserNotificationsUI",
|
|
9113
|
+
"VideoSubscriberAccount",
|
|
9114
|
+
"VideoToolbox",
|
|
9115
|
+
"Vision",
|
|
9116
|
+
"VisionKit",
|
|
9117
|
+
"WatchConnectivity",
|
|
9118
|
+
"WeatherKit",
|
|
9119
|
+
"WebKit",
|
|
9120
|
+
"WiFiAware",
|
|
9121
|
+
"WidgetKit",
|
|
9122
|
+
"WorkoutKit",
|
|
9123
|
+
"_AVKit_SwiftUI",
|
|
9124
|
+
"_AdAttributionKit_StoreKit",
|
|
9125
|
+
"_AppIntents_HealthKit",
|
|
9126
|
+
"_AppIntents_SwiftUI",
|
|
9127
|
+
"_AppIntents_UIKit",
|
|
9128
|
+
"_AuthenticationServices_SwiftUI",
|
|
9129
|
+
"_Contacts_AppIntents",
|
|
9130
|
+
"_CoreData_CloudKit",
|
|
9131
|
+
"_CoreLocationUI_SwiftUI",
|
|
9132
|
+
"_CoreNFC_UIKit",
|
|
9133
|
+
"_CoreSpotlight_FoundationModels",
|
|
9134
|
+
"_DataDetection_SwiftUI",
|
|
9135
|
+
"_DeviceActivity_SwiftUI",
|
|
9136
|
+
"_DeviceDiscoveryUI_SwiftUI",
|
|
9137
|
+
"_FinanceKit_AppIntents",
|
|
9138
|
+
"_FoundationModels_SwiftUI",
|
|
9139
|
+
"_FoundationModels_UIKit",
|
|
9140
|
+
"_GameController_SwiftUI",
|
|
9141
|
+
"_GeoToolbox_AppIntents",
|
|
9142
|
+
"_GroupActivities_UIKit",
|
|
9143
|
+
"_HomeKit_SwiftUI",
|
|
9144
|
+
"_Intents_TipKit",
|
|
9145
|
+
"_LinkPresentation_AppIntents",
|
|
9146
|
+
"_LocationEssentials",
|
|
9147
|
+
"_MapKit_SwiftUI",
|
|
9148
|
+
"_MarketplaceKit_UIKit",
|
|
9149
|
+
"_MediaIntents_AppIntents",
|
|
9150
|
+
"_MediaPlayer_AppIntents",
|
|
9151
|
+
"_MusicKit_SwiftUI",
|
|
9152
|
+
"_NowPlaying_AppIntents",
|
|
9153
|
+
"_PassKit_SwiftUI",
|
|
9154
|
+
"_PermissionKit_SwiftUI",
|
|
9155
|
+
"_PermissionKit_UIKit",
|
|
9156
|
+
"_PhotosUI_SwiftUI",
|
|
9157
|
+
"_PhotosUI_WidgetKit",
|
|
9158
|
+
"_Photos_AppIntents",
|
|
9159
|
+
"_QuickLook_SwiftUI",
|
|
9160
|
+
"_RealityKit_ComputeGraph",
|
|
9161
|
+
"_RealityKit_SwiftUI",
|
|
9162
|
+
"_RelevanceKit_MapKit",
|
|
9163
|
+
"_SceneKit_SwiftUI",
|
|
9164
|
+
"_SecureElementCredential_SwiftUI",
|
|
9165
|
+
"_SecureElementCredential_UIKit",
|
|
9166
|
+
"_SharedWithYou_AppIntents",
|
|
9167
|
+
"_SpriteKit_SwiftUI",
|
|
9168
|
+
"_StoreKit_SwiftUI",
|
|
9169
|
+
"_SwiftData_CoreData",
|
|
9170
|
+
"_SwiftData_SwiftUI",
|
|
9171
|
+
"_Translation_SwiftUI",
|
|
9172
|
+
"_USDKit_RealityKit",
|
|
9173
|
+
"_UserNotifications_AppIntents",
|
|
9174
|
+
"_WebKit_SwiftUI",
|
|
9175
|
+
"_WorkoutKit_SwiftUI",
|
|
9176
|
+
"iAd"
|
|
9177
|
+
]
|
|
9178
|
+
};
|
|
8894
9179
|
|
|
8895
|
-
// src/swift-
|
|
8896
|
-
var import_node_child_process6 = require("node:child_process");
|
|
9180
|
+
// src/swift-binary-modules.ts
|
|
8897
9181
|
var import_node_crypto5 = require("node:crypto");
|
|
8898
9182
|
var import_node_fs13 = __toESM(require("node:fs"), 1);
|
|
8899
9183
|
var import_node_os5 = __toESM(require("node:os"), 1);
|
|
8900
9184
|
var import_node_path13 = __toESM(require("node:path"), 1);
|
|
9185
|
+
var cacheDir2 = import_node_path13.default.join(import_node_os5.default.tmpdir(), "peach-swift-binary-modules");
|
|
9186
|
+
function frameworkModules(paths) {
|
|
9187
|
+
const modules = /* @__PURE__ */ new Set();
|
|
9188
|
+
for (const file of paths) {
|
|
9189
|
+
const segment = file.split("/").find((part) => part.endsWith(".framework"));
|
|
9190
|
+
if (segment) modules.add(segment.slice(0, -".framework".length));
|
|
9191
|
+
}
|
|
9192
|
+
return [...modules].sort();
|
|
9193
|
+
}
|
|
9194
|
+
async function range(url, spec) {
|
|
9195
|
+
const response = await fetch(url, {
|
|
9196
|
+
headers: { range: `bytes=${spec}` },
|
|
9197
|
+
signal: AbortSignal.timeout(2e4)
|
|
9198
|
+
});
|
|
9199
|
+
const match = /^bytes (\d+)-\d+\/(\d+)$/.exec(
|
|
9200
|
+
response.headers.get("content-range") ?? ""
|
|
9201
|
+
);
|
|
9202
|
+
if (response.status !== 206 || !match)
|
|
9203
|
+
throw new Error(`${url} answered ${response.status} to a range request`);
|
|
9204
|
+
return {
|
|
9205
|
+
bytes: Buffer.from(await response.arrayBuffer()),
|
|
9206
|
+
start: Number(match[1]),
|
|
9207
|
+
total: Number(match[2])
|
|
9208
|
+
};
|
|
9209
|
+
}
|
|
9210
|
+
var signature = (bytes, value) => {
|
|
9211
|
+
const needle = Buffer.alloc(4);
|
|
9212
|
+
needle.writeUInt32LE(value);
|
|
9213
|
+
return bytes.lastIndexOf(needle);
|
|
9214
|
+
};
|
|
9215
|
+
async function zipEntries(url) {
|
|
9216
|
+
const { total } = await range(url, "0-0");
|
|
9217
|
+
const tail = await range(url, `${Math.max(0, total - 65558)}-${total - 1}`);
|
|
9218
|
+
const end = signature(tail.bytes, 101010256);
|
|
9219
|
+
if (end < 0) throw new Error(`${url} has no zip end record`);
|
|
9220
|
+
let size = tail.bytes.readUInt32LE(end + 12);
|
|
9221
|
+
let offset = tail.bytes.readUInt32LE(end + 16);
|
|
9222
|
+
if (offset === 4294967295 || size === 4294967295) {
|
|
9223
|
+
const locator = end - 20;
|
|
9224
|
+
if (locator < 0 || tail.bytes.readUInt32LE(locator) !== 117853008)
|
|
9225
|
+
throw new Error(`${url} has no zip64 locator`);
|
|
9226
|
+
const recordAt = Number(tail.bytes.readBigUInt64LE(locator + 8));
|
|
9227
|
+
const record2 = recordAt >= tail.start ? tail.bytes.subarray(recordAt - tail.start) : (await range(url, `${recordAt}-${recordAt + 55}`)).bytes;
|
|
9228
|
+
size = Number(record2.readBigUInt64LE(40));
|
|
9229
|
+
offset = Number(record2.readBigUInt64LE(48));
|
|
9230
|
+
}
|
|
9231
|
+
const directory = offset >= tail.start ? tail.bytes.subarray(offset - tail.start, offset - tail.start + size) : (await range(url, `${offset}-${offset + size - 1}`)).bytes;
|
|
9232
|
+
const names = [];
|
|
9233
|
+
for (let at = 0; at + 46 <= directory.length; ) {
|
|
9234
|
+
if (directory.readUInt32LE(at) !== 33639248) break;
|
|
9235
|
+
const nameLength = directory.readUInt16LE(at + 28);
|
|
9236
|
+
names.push(directory.toString("utf8", at + 46, at + 46 + nameLength));
|
|
9237
|
+
at += 46 + nameLength + directory.readUInt16LE(at + 30) + directory.readUInt16LE(at + 32);
|
|
9238
|
+
}
|
|
9239
|
+
return names;
|
|
9240
|
+
}
|
|
9241
|
+
function localEntries(dir) {
|
|
9242
|
+
if (!import_node_fs13.default.existsSync(dir)) return [];
|
|
9243
|
+
return import_node_fs13.default.readdirSync(dir, { withFileTypes: true }).filter((slice) => slice.isDirectory()).flatMap(
|
|
9244
|
+
(slice) => import_node_fs13.default.readdirSync(import_node_path13.default.join(dir, slice.name)).map((entry) => `${slice.name}/${entry}`)
|
|
9245
|
+
);
|
|
9246
|
+
}
|
|
9247
|
+
async function swiftBinaryModules(binary) {
|
|
9248
|
+
if (!binary.url) return frameworkModules(localEntries(binary.dir));
|
|
9249
|
+
const cached3 = import_node_path13.default.join(
|
|
9250
|
+
cacheDir2,
|
|
9251
|
+
`${(0, import_node_crypto5.createHash)("sha256").update(binary.url).digest("hex").slice(0, 32)}.json`
|
|
9252
|
+
);
|
|
9253
|
+
if (import_node_fs13.default.existsSync(cached3)) {
|
|
9254
|
+
const value = JSON.parse(import_node_fs13.default.readFileSync(cached3, "utf8"));
|
|
9255
|
+
if (Array.isArray(value) && value.every((name2) => typeof name2 === "string"))
|
|
9256
|
+
return value;
|
|
9257
|
+
}
|
|
9258
|
+
const modules = frameworkModules(await zipEntries(binary.url));
|
|
9259
|
+
import_node_fs13.default.mkdirSync(cacheDir2, { recursive: true });
|
|
9260
|
+
import_node_fs13.default.writeFileSync(cached3, JSON.stringify(modules));
|
|
9261
|
+
return modules;
|
|
9262
|
+
}
|
|
9263
|
+
|
|
9264
|
+
// src/swift-packages.ts
|
|
9265
|
+
var import_node_child_process7 = require("node:child_process");
|
|
9266
|
+
var import_node_fs15 = __toESM(require("node:fs"), 1);
|
|
9267
|
+
var import_node_path15 = __toESM(require("node:path"), 1);
|
|
9268
|
+
|
|
9269
|
+
// src/swift-package-manifest.ts
|
|
9270
|
+
var import_node_child_process6 = require("node:child_process");
|
|
9271
|
+
var import_node_crypto6 = require("node:crypto");
|
|
9272
|
+
var import_node_fs14 = __toESM(require("node:fs"), 1);
|
|
9273
|
+
var import_node_os6 = __toESM(require("node:os"), 1);
|
|
9274
|
+
var import_node_path14 = __toESM(require("node:path"), 1);
|
|
8901
9275
|
var TARGET_TYPES = [
|
|
8902
9276
|
"regular",
|
|
8903
9277
|
"executable",
|
|
@@ -8912,19 +9286,19 @@ var record = (value) => value && typeof value === "object" && !Array.isArray(val
|
|
|
8912
9286
|
var array = (value) => Array.isArray(value) ? value : [];
|
|
8913
9287
|
var string = (value) => typeof value === "string" ? value : void 0;
|
|
8914
9288
|
function swiftCommand() {
|
|
8915
|
-
return process.platform === "darwin" ? { file: "xcrun", args: ["swift"] } : { file:
|
|
9289
|
+
return process.platform === "darwin" ? { file: "xcrun", args: ["swift"] } : { file: import_node_path14.default.join(swiftToolchainBin(swift_distribution_lock_default.release), "swift"), args: [] };
|
|
8916
9290
|
}
|
|
8917
|
-
var
|
|
9291
|
+
var cacheDir3 = import_node_path14.default.join(import_node_os6.default.tmpdir(), "peach-swift-manifests");
|
|
8918
9292
|
var evaluated = /* @__PURE__ */ new Map();
|
|
8919
9293
|
function dump(dir) {
|
|
8920
|
-
const manifests =
|
|
9294
|
+
const manifests = import_node_fs14.default.readdirSync(dir).filter((name2) => /^Package(@swift-[\d.]+)?\.swift$/.test(name2)).sort();
|
|
8921
9295
|
const command = swiftCommand();
|
|
8922
|
-
const key = (0,
|
|
8923
|
-
manifests.map((name2) => `${name2}\0${
|
|
9296
|
+
const key = (0, import_node_crypto6.createHash)("sha256").update(JSON.stringify([command, import_node_path14.default.resolve(dir)])).update(
|
|
9297
|
+
manifests.map((name2) => `${name2}\0${import_node_fs14.default.readFileSync(import_node_path14.default.join(dir, name2), "utf8")}`).join("\0")
|
|
8924
9298
|
).digest("hex").slice(0, 32);
|
|
8925
|
-
const cached3 =
|
|
8926
|
-
if (
|
|
8927
|
-
return { key, raw: record(JSON.parse(
|
|
9299
|
+
const cached3 = import_node_path14.default.join(cacheDir3, `${key}.json`);
|
|
9300
|
+
if (import_node_fs14.default.existsSync(cached3))
|
|
9301
|
+
return { key, raw: record(JSON.parse(import_node_fs14.default.readFileSync(cached3, "utf8"))) };
|
|
8928
9302
|
let output;
|
|
8929
9303
|
try {
|
|
8930
9304
|
output = (0, import_node_child_process6.execFileSync)(
|
|
@@ -8936,7 +9310,7 @@ function dump(dir) {
|
|
|
8936
9310
|
dir,
|
|
8937
9311
|
// swiftpm's scratch files never land in the app's own package
|
|
8938
9312
|
"--scratch-path",
|
|
8939
|
-
|
|
9313
|
+
import_node_path14.default.join(cacheDir3, `${key}.build`),
|
|
8940
9314
|
"dump-package"
|
|
8941
9315
|
],
|
|
8942
9316
|
{
|
|
@@ -8948,11 +9322,11 @@ function dump(dir) {
|
|
|
8948
9322
|
} catch (error) {
|
|
8949
9323
|
const stderr = error instanceof Error && "stderr" in error ? String(error.stderr).trim() : "";
|
|
8950
9324
|
throw new Error(
|
|
8951
|
-
`swiftpm could not evaluate ${
|
|
9325
|
+
`swiftpm could not evaluate ${import_node_path14.default.join(dir, "Package.swift")}${stderr ? `: ${stderr}` : ""}`
|
|
8952
9326
|
);
|
|
8953
9327
|
}
|
|
8954
|
-
|
|
8955
|
-
|
|
9328
|
+
import_node_fs14.default.mkdirSync(cacheDir3, { recursive: true });
|
|
9329
|
+
import_node_fs14.default.writeFileSync(cached3, output);
|
|
8956
9330
|
return { key, raw: record(JSON.parse(output)) };
|
|
8957
9331
|
}
|
|
8958
9332
|
function defaultTraits(manifest) {
|
|
@@ -8980,7 +9354,7 @@ function linksOnIOS(condition, traits) {
|
|
|
8980
9354
|
return gates.length === 0 || gates.some((name2) => traits.has(string(name2) ?? ""));
|
|
8981
9355
|
}
|
|
8982
9356
|
function swiftPackageManifest(dir) {
|
|
8983
|
-
dir =
|
|
9357
|
+
dir = import_node_fs14.default.realpathSync(dir);
|
|
8984
9358
|
const { key, raw: raw2 } = dump(dir);
|
|
8985
9359
|
const known = evaluated.get(key);
|
|
8986
9360
|
if (known) return known;
|
|
@@ -9028,7 +9402,7 @@ function swiftPackageManifest(dir) {
|
|
|
9028
9402
|
if (!name2 || !isTargetType(kind)) continue;
|
|
9029
9403
|
const declared = string(target.path);
|
|
9030
9404
|
const roots = kind === "test" ? ["Tests"] : ["Sources", "Source", "src", "srcs"];
|
|
9031
|
-
const targetDir = declared ?
|
|
9405
|
+
const targetDir = declared ? import_node_path14.default.resolve(dir, declared) : roots.map((root) => import_node_path14.default.join(dir, root, name2)).find((candidate) => import_node_fs14.default.existsSync(candidate)) ?? import_node_path14.default.join(dir, roots[0], name2);
|
|
9032
9406
|
const dependencies = [];
|
|
9033
9407
|
for (const dependency of array(target.dependencies)) {
|
|
9034
9408
|
const { target: local, product, byName } = record(dependency);
|
|
@@ -9070,30 +9444,31 @@ function swiftPackageManifest(dir) {
|
|
|
9070
9444
|
dependencies,
|
|
9071
9445
|
languageMode,
|
|
9072
9446
|
mainActorIsolation,
|
|
9073
|
-
declaresResources: array(target.resources).length > 0
|
|
9447
|
+
declaresResources: array(target.resources).length > 0,
|
|
9448
|
+
url: string(target.url) ?? null
|
|
9074
9449
|
});
|
|
9075
9450
|
}
|
|
9076
9451
|
const manifest = { dir, products, targets, packages };
|
|
9077
9452
|
evaluated.set(key, manifest);
|
|
9078
9453
|
return manifest;
|
|
9079
9454
|
}
|
|
9080
|
-
var within = (file, roots) => roots.some((root) => file === root || file.startsWith(`${root}${
|
|
9455
|
+
var within = (file, roots) => roots.some((root) => file === root || file.startsWith(`${root}${import_node_path14.default.sep}`));
|
|
9081
9456
|
function walk(dir) {
|
|
9082
|
-
if (!
|
|
9083
|
-
if (
|
|
9457
|
+
if (!import_node_fs14.default.existsSync(dir)) return [];
|
|
9458
|
+
if (import_node_fs14.default.statSync(dir).isFile()) return [dir];
|
|
9084
9459
|
const out = [];
|
|
9085
|
-
for (const entry of
|
|
9460
|
+
for (const entry of import_node_fs14.default.readdirSync(dir, { withFileTypes: true })) {
|
|
9086
9461
|
if (entry.name.startsWith(".")) continue;
|
|
9087
|
-
const full =
|
|
9462
|
+
const full = import_node_path14.default.join(dir, entry.name);
|
|
9088
9463
|
if (entry.isDirectory()) out.push(...walk(full));
|
|
9089
9464
|
else if (entry.isFile()) out.push(full);
|
|
9090
9465
|
}
|
|
9091
9466
|
return out;
|
|
9092
9467
|
}
|
|
9093
9468
|
function swiftTargetFiles(manifest, target) {
|
|
9094
|
-
const included = target.sources ? target.sources.map((source) =>
|
|
9469
|
+
const included = target.sources ? target.sources.map((source) => import_node_path14.default.resolve(target.dir, source)) : [target.dir];
|
|
9095
9470
|
const excluded = [
|
|
9096
|
-
...target.exclude.map((file) =>
|
|
9471
|
+
...target.exclude.map((file) => import_node_path14.default.resolve(target.dir, file)),
|
|
9097
9472
|
...[...manifest.targets.values()].flatMap(
|
|
9098
9473
|
(other) => other !== target && within(other.dir, [target.dir]) && other.dir !== target.dir ? [other.dir] : []
|
|
9099
9474
|
)
|
|
@@ -9102,10 +9477,12 @@ function swiftTargetFiles(manifest, target) {
|
|
|
9102
9477
|
}
|
|
9103
9478
|
|
|
9104
9479
|
// src/swift-packages.ts
|
|
9105
|
-
var REMOTE_CHECKOUTS =
|
|
9480
|
+
var REMOTE_CHECKOUTS = import_node_path15.default.join(".build", "peach", "checkouts");
|
|
9106
9481
|
var C_FAMILY = /\.(c|cc|cpp|cxx|m|mm|s|S)$/;
|
|
9482
|
+
var BINARY = "is a binary framework";
|
|
9483
|
+
var blocker = (reasons) => reasons.find((reason) => reason?.includes(BINARY)) ?? reasons.find((reason) => reason !== null) ?? null;
|
|
9107
9484
|
function readPins(resolved) {
|
|
9108
|
-
const data = JSON.parse(
|
|
9485
|
+
const data = JSON.parse(import_node_fs15.default.readFileSync(resolved, "utf8"));
|
|
9109
9486
|
const pins = data && typeof data === "object" && "pins" in data && Array.isArray(data.pins) ? data.pins : null;
|
|
9110
9487
|
if (!pins)
|
|
9111
9488
|
throw new Error(`${resolved} has no pins; resolve packages in a current Xcode`);
|
|
@@ -9121,23 +9498,23 @@ function readPins(resolved) {
|
|
|
9121
9498
|
}
|
|
9122
9499
|
var verified2 = /* @__PURE__ */ new Set();
|
|
9123
9500
|
function checkout(checkouts, identity, pin) {
|
|
9124
|
-
const dir =
|
|
9501
|
+
const dir = import_node_path15.default.join(checkouts, identity);
|
|
9125
9502
|
const key = `${dir}\0${pin.revision}`;
|
|
9126
9503
|
if (verified2.has(key)) return dir;
|
|
9127
9504
|
const git = (...args) => (0, import_node_child_process7.execFileSync)("git", ["-C", dir, ...args], {
|
|
9128
9505
|
encoding: "utf8",
|
|
9129
9506
|
stdio: ["ignore", "pipe", "pipe"]
|
|
9130
9507
|
}).trim();
|
|
9131
|
-
const current =
|
|
9508
|
+
const current = import_node_fs15.default.existsSync(import_node_path15.default.join(dir, ".git")) ? git("rev-parse", "HEAD") : "";
|
|
9132
9509
|
if (current !== pin.revision) {
|
|
9133
|
-
|
|
9134
|
-
|
|
9510
|
+
import_node_fs15.default.rmSync(dir, { recursive: true, force: true });
|
|
9511
|
+
import_node_fs15.default.mkdirSync(dir, { recursive: true });
|
|
9135
9512
|
try {
|
|
9136
9513
|
git("init", "-q");
|
|
9137
9514
|
git("fetch", "-q", "--depth", "1", pin.location, pin.revision);
|
|
9138
9515
|
git("checkout", "-q", "FETCH_HEAD");
|
|
9139
9516
|
} catch (error) {
|
|
9140
|
-
|
|
9517
|
+
import_node_fs15.default.rmSync(dir, { recursive: true, force: true });
|
|
9141
9518
|
const stderr = error instanceof Error && "stderr" in error ? String(error.stderr).trim() : "";
|
|
9142
9519
|
throw new Error(
|
|
9143
9520
|
`could not fetch ${pin.location} at ${pin.revision}${stderr ? `: ${stderr}` : ""}`
|
|
@@ -9153,13 +9530,14 @@ function resolveSwiftPackages(options) {
|
|
|
9153
9530
|
const result = {
|
|
9154
9531
|
targets: [],
|
|
9155
9532
|
unavailable: /* @__PURE__ */ new Map(),
|
|
9156
|
-
modules: /* @__PURE__ */ new Map()
|
|
9533
|
+
modules: /* @__PURE__ */ new Map(),
|
|
9534
|
+
binaries: []
|
|
9157
9535
|
};
|
|
9158
9536
|
const pins = resolved ? readPins(resolved) : null;
|
|
9159
|
-
const checkouts =
|
|
9537
|
+
const checkouts = import_node_path15.default.join(rootDir, REMOTE_CHECKOUTS);
|
|
9160
9538
|
const packages = /* @__PURE__ */ new Map();
|
|
9161
9539
|
const load2 = (source) => {
|
|
9162
|
-
const key = source.kind === "local" ?
|
|
9540
|
+
const key = source.kind === "local" ? import_node_path15.default.resolve(source.dir) : source.url;
|
|
9163
9541
|
const cached3 = packages.get(key);
|
|
9164
9542
|
if (cached3 !== void 0) return cached3;
|
|
9165
9543
|
let loaded2;
|
|
@@ -9171,8 +9549,8 @@ function resolveSwiftPackages(options) {
|
|
|
9171
9549
|
if (!pin) {
|
|
9172
9550
|
loaded2 = pins ? `package ${identity} is not pinned in Package.resolved` : "no Package.resolved pins it; resolve packages in Xcode once";
|
|
9173
9551
|
} else {
|
|
9174
|
-
|
|
9175
|
-
|
|
9552
|
+
import_node_fs15.default.mkdirSync(checkouts, { recursive: true });
|
|
9553
|
+
import_node_fs15.default.writeFileSync(import_node_path15.default.join(import_node_path15.default.dirname(checkouts), ".gitignore"), "*\n");
|
|
9176
9554
|
loaded2 = {
|
|
9177
9555
|
source: source.url,
|
|
9178
9556
|
remote: true,
|
|
@@ -9192,8 +9570,8 @@ function resolveSwiftPackages(options) {
|
|
|
9192
9570
|
const outcome = (() => {
|
|
9193
9571
|
if (provided.has(name2)) return null;
|
|
9194
9572
|
const target = pkg.manifest.targets.get(name2);
|
|
9195
|
-
if (!target) return `${
|
|
9196
|
-
if (target.type === "binary") return `${name2}
|
|
9573
|
+
if (!target) return `${import_node_path15.default.basename(pkg.manifest.dir)} declares no target ${name2}`;
|
|
9574
|
+
if (target.type === "binary") return `${name2} ${BINARY}`;
|
|
9197
9575
|
if (target.type === "system") return `${name2} is a system C library`;
|
|
9198
9576
|
if (target.type !== "regular") return `${name2} is a ${target.type} target`;
|
|
9199
9577
|
const files = swiftTargetFiles(pkg.manifest, target);
|
|
@@ -9204,9 +9582,9 @@ function resolveSwiftPackages(options) {
|
|
|
9204
9582
|
const nested = resolveDependencyProduct(pkg, dependency.package, dependency.name);
|
|
9205
9583
|
return nested && `${dependency.name}: ${nested}`;
|
|
9206
9584
|
});
|
|
9207
|
-
const blocked = reasons
|
|
9585
|
+
const blocked = blocker(reasons);
|
|
9208
9586
|
if (blocked) return blocked;
|
|
9209
|
-
const relative2 = files.map((file) =>
|
|
9587
|
+
const relative2 = files.map((file) => import_node_path15.default.relative(target.dir, file));
|
|
9210
9588
|
targets.set(`${pkg.manifest.dir}\0${name2}`, {
|
|
9211
9589
|
name: name2,
|
|
9212
9590
|
path: "",
|
|
@@ -9228,7 +9606,7 @@ function resolveSwiftPackages(options) {
|
|
|
9228
9606
|
const resolveProduct = (pkg, product) => {
|
|
9229
9607
|
if (provided.has(product)) return null;
|
|
9230
9608
|
const roots = pkg.manifest.products.get(product);
|
|
9231
|
-
const reason = !roots ? `${
|
|
9609
|
+
const reason = !roots ? `${import_node_path15.default.basename(pkg.manifest.dir)} has no library ${product}` : blocker(roots.map((name2) => resolveTarget(pkg, name2)));
|
|
9232
9610
|
productOutcomes.set(`${pkg.manifest.dir}\0${product}`, { pkg, reason });
|
|
9233
9611
|
return reason;
|
|
9234
9612
|
};
|
|
@@ -9236,7 +9614,7 @@ function resolveSwiftPackages(options) {
|
|
|
9236
9614
|
if (provided.has(product)) return null;
|
|
9237
9615
|
const dependency = pkg.manifest.packages.get(packageName);
|
|
9238
9616
|
if (!dependency)
|
|
9239
|
-
return `${
|
|
9617
|
+
return `${import_node_path15.default.basename(pkg.manifest.dir)} names no package ${packageName}`;
|
|
9240
9618
|
if ("dir" in dependency) {
|
|
9241
9619
|
const loaded3 = load2({ kind: "local", dir: dependency.dir });
|
|
9242
9620
|
return typeof loaded3 === "string" ? loaded3 : resolveProduct(loaded3, product);
|
|
@@ -9263,6 +9641,13 @@ function resolveSwiftPackages(options) {
|
|
|
9263
9641
|
if (target.type === "test" || target.type === "plugin" || target.type === "macro")
|
|
9264
9642
|
continue;
|
|
9265
9643
|
if (target.type === "executable") continue;
|
|
9644
|
+
if (target.type === "binary")
|
|
9645
|
+
result.binaries.push({
|
|
9646
|
+
target: name2,
|
|
9647
|
+
source: pkg.source,
|
|
9648
|
+
url: target.url,
|
|
9649
|
+
dir: target.dir
|
|
9650
|
+
});
|
|
9266
9651
|
const reason = resolveTarget(pkg, name2);
|
|
9267
9652
|
if (reason && !result.modules.has(name2))
|
|
9268
9653
|
result.modules.set(name2, { source: pkg.source, reason });
|
|
@@ -9282,7 +9667,7 @@ function resolveSwiftPackages(options) {
|
|
|
9282
9667
|
if (dependency.kind === "target") reach(pkg, dependency.name);
|
|
9283
9668
|
else {
|
|
9284
9669
|
const source = pkg.manifest.packages.get(dependency.package);
|
|
9285
|
-
const nested = source && ("dir" in source ? packages.get(
|
|
9670
|
+
const nested = source && ("dir" in source ? packages.get(import_node_path15.default.resolve(source.dir)) : packages.get(source.url));
|
|
9286
9671
|
if (nested && typeof nested !== "string")
|
|
9287
9672
|
for (const root of nested.manifest.products.get(dependency.name) ?? [])
|
|
9288
9673
|
reach(nested, root);
|
|
@@ -9290,7 +9675,7 @@ function resolveSwiftPackages(options) {
|
|
|
9290
9675
|
}
|
|
9291
9676
|
};
|
|
9292
9677
|
for (const { product, source } of products) {
|
|
9293
|
-
const pkg = source.kind === "unnamed" ? unnamed().find((candidate) => candidate.manifest.products.has(product)) : packages.get(source.kind === "local" ?
|
|
9678
|
+
const pkg = source.kind === "unnamed" ? unnamed().find((candidate) => candidate.manifest.products.has(product)) : packages.get(source.kind === "local" ? import_node_path15.default.resolve(source.dir) : source.url);
|
|
9294
9679
|
if (!pkg || typeof pkg === "string") continue;
|
|
9295
9680
|
for (const root of pkg.manifest.products.get(product) ?? []) reach(pkg, root);
|
|
9296
9681
|
}
|
|
@@ -9425,12 +9810,12 @@ async function compileSwiftProject(submit, work, origin, signal) {
|
|
|
9425
9810
|
}
|
|
9426
9811
|
|
|
9427
9812
|
// src/xcode-project.ts
|
|
9428
|
-
var
|
|
9429
|
-
var
|
|
9813
|
+
var import_node_fs16 = __toESM(require("node:fs"), 1);
|
|
9814
|
+
var import_node_path17 = __toESM(require("node:path"), 1);
|
|
9430
9815
|
var import_plist3 = __toESM(require_plist(), 1);
|
|
9431
9816
|
|
|
9432
9817
|
// src/xcode-json-project.ts
|
|
9433
|
-
var
|
|
9818
|
+
var import_node_path16 = __toESM(require("node:path"), 1);
|
|
9434
9819
|
var import_json5 = __toESM(require("json5"), 1);
|
|
9435
9820
|
var isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9436
9821
|
var text = (value) => typeof value === "string" ? value : void 0;
|
|
@@ -9446,7 +9831,7 @@ var PHASE_ISA = {
|
|
|
9446
9831
|
function readXcodeJsonProject(xcodeproj, source) {
|
|
9447
9832
|
const json = import_json5.default.parse(source);
|
|
9448
9833
|
if (!isJsonObject(json)) throw new Error(`${xcodeproj}/project.xcproj is not an object`);
|
|
9449
|
-
const projectDir =
|
|
9834
|
+
const projectDir = import_node_path16.default.dirname(xcodeproj);
|
|
9450
9835
|
const objects = {};
|
|
9451
9836
|
let next = 0;
|
|
9452
9837
|
const add = (entry, id) => {
|
|
@@ -9459,7 +9844,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
9459
9844
|
const base = /^<([A-Z]+)>\/(.*)$/.exec(raw2);
|
|
9460
9845
|
if (base) {
|
|
9461
9846
|
if (base[1] === "PROJECT")
|
|
9462
|
-
return { sourceTree: "<absolute>", path:
|
|
9847
|
+
return { sourceTree: "<absolute>", path: import_node_path16.default.join(projectDir, base[2]) };
|
|
9463
9848
|
if (base[1] === "PRODUCTS")
|
|
9464
9849
|
return { sourceTree: "BUILT_PRODUCTS_DIR", path: base[2] };
|
|
9465
9850
|
return null;
|
|
@@ -9467,7 +9852,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
9467
9852
|
const unescaped = raw2.replaceAll("\\<", "<");
|
|
9468
9853
|
if (unescaped.startsWith("/")) return { sourceTree: "<absolute>", path: unescaped };
|
|
9469
9854
|
if (unescaped.startsWith("~")) return null;
|
|
9470
|
-
return groupDir === null ? null : { sourceTree: "<absolute>", path:
|
|
9855
|
+
return groupDir === null ? null : { sourceTree: "<absolute>", path: import_node_path16.default.join(groupDir, unescaped) };
|
|
9471
9856
|
};
|
|
9472
9857
|
const memberships = [];
|
|
9473
9858
|
const folders = [];
|
|
@@ -9478,7 +9863,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
9478
9863
|
const kind = text(entry.kind) ?? "file-reference";
|
|
9479
9864
|
const raw2 = text(entry.path) ?? "";
|
|
9480
9865
|
const located = raw2 === "" ? null : locate(raw2, parent.dir);
|
|
9481
|
-
const name2 = text(entry.name) ??
|
|
9866
|
+
const name2 = text(entry.name) ?? import_node_path16.default.basename(raw2);
|
|
9482
9867
|
const node = { id: "", name: name2, dir: null, parent, children: [] };
|
|
9483
9868
|
if (kind === "group" || kind === "variant-group" || kind === "version-group") {
|
|
9484
9869
|
node.dir = raw2 === "" ? parent.dir : located?.sourceTree === "<absolute>" ? located.path : null;
|
|
@@ -9593,7 +9978,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
9593
9978
|
if (!isObject(entry)) continue;
|
|
9594
9979
|
const repository = text(entry.repository);
|
|
9595
9980
|
const local = text(entry.path);
|
|
9596
|
-
const name2 = local !== void 0 ?
|
|
9981
|
+
const name2 = local !== void 0 ? import_node_path16.default.basename(import_node_path16.default.resolve(import_node_path16.default.dirname(xcodeproj), local)) : import_node_path16.default.basename(repository ?? "").replace(/\.git$/, "");
|
|
9597
9982
|
const id = text(entry.kind) === "local" && local !== void 0 ? add({ isa: "XCLocalSwiftPackageReference", relativePath: local }) : add({ isa: "XCRemoteSwiftPackageReference", repositoryURL: repository ?? "" });
|
|
9598
9983
|
packageIds.set(name2.toLowerCase(), id);
|
|
9599
9984
|
}
|
|
@@ -9870,28 +10255,28 @@ var CONDITIONS = {
|
|
|
9870
10255
|
variant: "normal"
|
|
9871
10256
|
};
|
|
9872
10257
|
function walkFiles(dir) {
|
|
9873
|
-
if (!
|
|
10258
|
+
if (!import_node_fs16.default.existsSync(dir)) return [];
|
|
9874
10259
|
const out = [];
|
|
9875
|
-
for (const entry of
|
|
10260
|
+
for (const entry of import_node_fs16.default.readdirSync(dir, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
|
|
9876
10261
|
if (entry.name.startsWith(".")) continue;
|
|
9877
|
-
const full =
|
|
10262
|
+
const full = import_node_path17.default.join(dir, entry.name);
|
|
9878
10263
|
if (entry.isDirectory()) out.push(...walkFiles(full));
|
|
9879
10264
|
else if (entry.isFile()) out.push(full);
|
|
9880
10265
|
}
|
|
9881
10266
|
return out;
|
|
9882
10267
|
}
|
|
9883
|
-
var isDirectory = (dir) =>
|
|
10268
|
+
var isDirectory = (dir) => import_node_fs16.default.existsSync(dir) && import_node_fs16.default.statSync(dir).isDirectory();
|
|
9884
10269
|
function readXcconfig(file, seen = /* @__PURE__ */ new Set()) {
|
|
9885
|
-
if (seen.has(file) || !
|
|
10270
|
+
if (seen.has(file) || !import_node_fs16.default.existsSync(file)) return {};
|
|
9886
10271
|
seen.add(file);
|
|
9887
10272
|
const settings = {};
|
|
9888
|
-
for (const raw2 of
|
|
10273
|
+
for (const raw2 of import_node_fs16.default.readFileSync(file, "utf8").split("\n")) {
|
|
9889
10274
|
const line = raw2.replace(/\/\/.*$/, "").trim();
|
|
9890
10275
|
const include = /^#include\??\s+"([^"]+)"/.exec(line);
|
|
9891
10276
|
if (include) {
|
|
9892
10277
|
Object.assign(
|
|
9893
10278
|
settings,
|
|
9894
|
-
readXcconfig(
|
|
10279
|
+
readXcconfig(import_node_path17.default.resolve(import_node_path17.default.dirname(file), include[1]), seen)
|
|
9895
10280
|
);
|
|
9896
10281
|
continue;
|
|
9897
10282
|
}
|
|
@@ -9941,22 +10326,22 @@ function decodeXml(text2) {
|
|
|
9941
10326
|
return text2.replaceAll(""", '"').replaceAll("'", "'").replaceAll("<", "<").replaceAll(">", ">").replaceAll("&", "&");
|
|
9942
10327
|
}
|
|
9943
10328
|
function workspaceReferences(workspace) {
|
|
9944
|
-
const data =
|
|
9945
|
-
if (!
|
|
10329
|
+
const data = import_node_path17.default.join(workspace, "contents.xcworkspacedata");
|
|
10330
|
+
if (!import_node_fs16.default.existsSync(data))
|
|
9946
10331
|
throw new Error(`${workspace} has no contents.xcworkspacedata`);
|
|
9947
|
-
const container =
|
|
10332
|
+
const container = import_node_path17.default.dirname(workspace);
|
|
9948
10333
|
const locate = (location2, base) => {
|
|
9949
10334
|
const colon = location2.indexOf(":");
|
|
9950
10335
|
const kind = location2.slice(0, colon);
|
|
9951
10336
|
const rest = location2.slice(colon + 1);
|
|
9952
|
-
if (kind === "group") return
|
|
9953
|
-
if (kind === "container" || kind === "self") return
|
|
9954
|
-
if (kind === "absolute") return
|
|
9955
|
-
throw new Error(`${
|
|
10337
|
+
if (kind === "group") return import_node_path17.default.resolve(base, rest);
|
|
10338
|
+
if (kind === "container" || kind === "self") return import_node_path17.default.resolve(container, rest);
|
|
10339
|
+
if (kind === "absolute") return import_node_path17.default.resolve(rest);
|
|
10340
|
+
throw new Error(`${import_node_path17.default.basename(workspace)} has an unsupported location ${location2}`);
|
|
9956
10341
|
};
|
|
9957
10342
|
const groups = [container];
|
|
9958
10343
|
const references = [];
|
|
9959
|
-
for (const [, closing, tag, attributes, selfClosing] of
|
|
10344
|
+
for (const [, closing, tag, attributes, selfClosing] of import_node_fs16.default.readFileSync(data, "utf8").matchAll(/<(\/?)(Group|FileRef)\b([^>]*?)(\/?)>/g)) {
|
|
9960
10345
|
if (closing) {
|
|
9961
10346
|
if (tag === "Group") groups.pop();
|
|
9962
10347
|
continue;
|
|
@@ -9972,8 +10357,8 @@ function workspaceReferences(workspace) {
|
|
|
9972
10357
|
var loaded = /* @__PURE__ */ new Map();
|
|
9973
10358
|
function xcodeProjectFile(xcodeproj) {
|
|
9974
10359
|
for (const name2 of ["project.pbxproj", "project.xcproj"]) {
|
|
9975
|
-
const file =
|
|
9976
|
-
if (
|
|
10360
|
+
const file = import_node_path17.default.join(xcodeproj, name2);
|
|
10361
|
+
if (import_node_fs16.default.existsSync(file)) return file;
|
|
9977
10362
|
}
|
|
9978
10363
|
return null;
|
|
9979
10364
|
}
|
|
@@ -9981,10 +10366,10 @@ function loadProject(xcodeproj) {
|
|
|
9981
10366
|
const projectFile = xcodeProjectFile(xcodeproj);
|
|
9982
10367
|
if (!projectFile)
|
|
9983
10368
|
throw new Error(`${xcodeproj} has no project.pbxproj or project.xcproj`);
|
|
9984
|
-
const mtimeMs =
|
|
10369
|
+
const mtimeMs = import_node_fs16.default.statSync(projectFile).mtimeMs;
|
|
9985
10370
|
const cached3 = loaded.get(projectFile);
|
|
9986
10371
|
if (cached3?.mtimeMs === mtimeMs) return cached3.project;
|
|
9987
|
-
const source =
|
|
10372
|
+
const source = import_node_fs16.default.readFileSync(projectFile, "utf8");
|
|
9988
10373
|
const root = projectFile.endsWith(".xcproj") ? readXcodeJsonProject(xcodeproj, source) : parseOpenStepPlist(source);
|
|
9989
10374
|
if (!isDict(root) || !isDict(root.objects)) {
|
|
9990
10375
|
throw new Error(`${projectFile} has no objects table`);
|
|
@@ -9998,8 +10383,8 @@ function loadProject(xcodeproj) {
|
|
|
9998
10383
|
if (!project || project.isa !== "PBXProject") {
|
|
9999
10384
|
throw new Error(`${projectFile} has no PBXProject root`);
|
|
10000
10385
|
}
|
|
10001
|
-
const projectDir =
|
|
10002
|
-
|
|
10386
|
+
const projectDir = import_node_fs16.default.realpathSync(
|
|
10387
|
+
import_node_path17.default.resolve(import_node_path17.default.dirname(xcodeproj), str(project.projectDirPath) ?? "")
|
|
10003
10388
|
);
|
|
10004
10389
|
const parent = /* @__PURE__ */ new Map();
|
|
10005
10390
|
for (const [id, entry] of Object.entries(objects)) {
|
|
@@ -10017,11 +10402,11 @@ function loadProject(xcodeproj) {
|
|
|
10017
10402
|
const own = str(entry.path) ?? "";
|
|
10018
10403
|
const tree = str(entry.sourceTree) ?? "<group>";
|
|
10019
10404
|
if (tree === "<absolute>") result2 = own;
|
|
10020
|
-
else if (tree === "SOURCE_ROOT") result2 =
|
|
10405
|
+
else if (tree === "SOURCE_ROOT") result2 = import_node_path17.default.join(projectDir, own);
|
|
10021
10406
|
else if (tree === "<group>") {
|
|
10022
10407
|
const up = parent.get(id);
|
|
10023
10408
|
const base = up ? resolvePath(up) : projectDir;
|
|
10024
|
-
result2 = base === null ? null :
|
|
10409
|
+
result2 = base === null ? null : import_node_path17.default.join(base, own);
|
|
10025
10410
|
}
|
|
10026
10411
|
}
|
|
10027
10412
|
resolvedPaths.set(id, result2);
|
|
@@ -10121,7 +10506,7 @@ function targetMembers(ref) {
|
|
|
10121
10506
|
const addResource = (file) => {
|
|
10122
10507
|
if (isDirectory(file)) {
|
|
10123
10508
|
for (const inner of walkFiles(file)) resources.add(inner);
|
|
10124
|
-
} else if (
|
|
10509
|
+
} else if (import_node_fs16.default.existsSync(file)) resources.add(file);
|
|
10125
10510
|
};
|
|
10126
10511
|
const fileRefPaths = (refId) => {
|
|
10127
10512
|
const entry = project.object(refId);
|
|
@@ -10142,7 +10527,7 @@ function targetMembers(ref) {
|
|
|
10142
10527
|
for (const buildFileId of list(phase.files)) {
|
|
10143
10528
|
for (const file of fileRefPaths(str(project.object(buildFileId)?.fileRef) ?? "")) {
|
|
10144
10529
|
if (phase.isa === "PBXSourcesBuildPhase") {
|
|
10145
|
-
if (!
|
|
10530
|
+
if (!import_node_fs16.default.existsSync(file)) continue;
|
|
10146
10531
|
allSources.add(file);
|
|
10147
10532
|
if (file.endsWith(".swift")) sources.add(file);
|
|
10148
10533
|
} else if (phase.isa === "PBXResourcesBuildPhase") addResource(file);
|
|
@@ -10150,7 +10535,7 @@ function targetMembers(ref) {
|
|
|
10150
10535
|
}
|
|
10151
10536
|
}
|
|
10152
10537
|
const addSynchronized = (folder, relative2) => {
|
|
10153
|
-
const file =
|
|
10538
|
+
const file = import_node_path17.default.join(folder, relative2);
|
|
10154
10539
|
if (NEVER_MEMBER.test(relative2)) return;
|
|
10155
10540
|
if (file.endsWith(".swift")) {
|
|
10156
10541
|
if (!relative2.split("/").some((segment) => BUNDLE_DIR.test(segment))) {
|
|
@@ -10175,7 +10560,7 @@ function targetMembers(ref) {
|
|
|
10175
10560
|
}
|
|
10176
10561
|
if (owned.has(groupId)) {
|
|
10177
10562
|
for (const file of walkFiles(folder)) {
|
|
10178
|
-
const relative2 =
|
|
10563
|
+
const relative2 = import_node_path17.default.relative(folder, file).split(import_node_path17.default.sep).join("/");
|
|
10179
10564
|
if ([...exceptions].some(
|
|
10180
10565
|
(exception) => relative2 === exception || relative2.startsWith(`${exception}/`)
|
|
10181
10566
|
))
|
|
@@ -10184,14 +10569,14 @@ function targetMembers(ref) {
|
|
|
10184
10569
|
}
|
|
10185
10570
|
} else {
|
|
10186
10571
|
for (const relative2 of exceptions) {
|
|
10187
|
-
const file =
|
|
10572
|
+
const file = import_node_path17.default.join(folder, relative2);
|
|
10188
10573
|
if (isDirectory(file)) {
|
|
10189
10574
|
for (const inner of walkFiles(file))
|
|
10190
10575
|
addSynchronized(
|
|
10191
10576
|
folder,
|
|
10192
|
-
|
|
10577
|
+
import_node_path17.default.relative(folder, inner).split(import_node_path17.default.sep).join("/")
|
|
10193
10578
|
);
|
|
10194
|
-
} else if (
|
|
10579
|
+
} else if (import_node_fs16.default.existsSync(file)) addSynchronized(folder, relative2);
|
|
10195
10580
|
}
|
|
10196
10581
|
}
|
|
10197
10582
|
}
|
|
@@ -10204,8 +10589,8 @@ function targetMembers(ref) {
|
|
|
10204
10589
|
function commonAncestor(dirs) {
|
|
10205
10590
|
let common = dirs[0];
|
|
10206
10591
|
for (const dir of dirs) {
|
|
10207
|
-
while (common !==
|
|
10208
|
-
common =
|
|
10592
|
+
while (common !== import_node_path17.default.dirname(common) && import_node_path17.default.relative(common, dir).startsWith(".."))
|
|
10593
|
+
common = import_node_path17.default.dirname(common);
|
|
10209
10594
|
}
|
|
10210
10595
|
return common;
|
|
10211
10596
|
}
|
|
@@ -10214,8 +10599,8 @@ function workspaceProjects(xcodeprojOrWorkspace) {
|
|
|
10214
10599
|
const projects2 = [];
|
|
10215
10600
|
const projectAt = /* @__PURE__ */ new Map();
|
|
10216
10601
|
const addProject = (xcodeproj) => {
|
|
10217
|
-
const key =
|
|
10218
|
-
if (projectAt.has(key) || key.split(
|
|
10602
|
+
const key = import_node_path17.default.resolve(xcodeproj);
|
|
10603
|
+
if (projectAt.has(key) || key.split(import_node_path17.default.sep).includes("Pods")) return;
|
|
10219
10604
|
if (!xcodeProjectFile(key)) return;
|
|
10220
10605
|
const project = loadProject(key);
|
|
10221
10606
|
projectAt.set(key, project);
|
|
@@ -10232,7 +10617,7 @@ function workspaceProjects(xcodeprojOrWorkspace) {
|
|
|
10232
10617
|
for (const reference of listed)
|
|
10233
10618
|
if (reference.endsWith(".xcodeproj")) addProject(reference);
|
|
10234
10619
|
if (projects2.length === 0) {
|
|
10235
|
-
throw new Error(`${
|
|
10620
|
+
throw new Error(`${import_node_path17.default.basename(xcodeprojOrWorkspace)} lists no Xcode project`);
|
|
10236
10621
|
}
|
|
10237
10622
|
return { listed, projects: projects2, projectAt };
|
|
10238
10623
|
}
|
|
@@ -10254,7 +10639,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
10254
10639
|
const allTargets = projects2.flatMap(nativeTargets);
|
|
10255
10640
|
const appTargets = allTargets.filter((ref) => ref.target.productType === APPLICATION);
|
|
10256
10641
|
const appTargetNames = appTargets.map((ref) => str(ref.target.name) ?? ref.id);
|
|
10257
|
-
const container =
|
|
10642
|
+
const container = import_node_path17.default.basename(xcodeprojOrWorkspace);
|
|
10258
10643
|
const named = targetName ? appTargets.filter((ref) => ref.target.name === targetName) : appTargets;
|
|
10259
10644
|
if (named.length !== 1) {
|
|
10260
10645
|
throw new Error(
|
|
@@ -10266,14 +10651,14 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
10266
10651
|
for (const ref of allTargets) {
|
|
10267
10652
|
const product = ref.project.object(str(ref.target.productReference));
|
|
10268
10653
|
const file = str(product?.path);
|
|
10269
|
-
if (file && !byProduct.has(
|
|
10270
|
-
byProduct.set(
|
|
10654
|
+
if (file && !byProduct.has(import_node_path17.default.basename(file)))
|
|
10655
|
+
byProduct.set(import_node_path17.default.basename(file), ref);
|
|
10271
10656
|
}
|
|
10272
10657
|
const proxied = (project, proxyId) => {
|
|
10273
10658
|
const proxy = project.object(proxyId);
|
|
10274
10659
|
if (proxy?.isa !== "PBXContainerItemProxy") return void 0;
|
|
10275
10660
|
const portal = str(proxy.containerPortal);
|
|
10276
|
-
const owner = project.object(portal)?.isa === "PBXProject" ? project : projectAt.get(
|
|
10661
|
+
const owner = project.object(portal)?.isa === "PBXProject" ? project : projectAt.get(import_node_path17.default.resolve(project.resolvePath(portal ?? "") ?? ""));
|
|
10277
10662
|
const remote = str(proxy.remoteGlobalIDString);
|
|
10278
10663
|
if (!owner || !remote) return void 0;
|
|
10279
10664
|
return nativeTargets(owner).find(
|
|
@@ -10294,7 +10679,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
10294
10679
|
if (phase?.isa !== "PBXFrameworksBuildPhase") continue;
|
|
10295
10680
|
for (const buildFileId of list(phase.files)) {
|
|
10296
10681
|
const file = project.object(str(project.object(buildFileId)?.fileRef));
|
|
10297
|
-
const resolved = file?.isa === "PBXReferenceProxy" ? proxied(project, str(file.remoteRef)) : file && str(file.sourceTree) === "BUILT_PRODUCTS_DIR" ? byProduct.get(
|
|
10682
|
+
const resolved = file?.isa === "PBXReferenceProxy" ? proxied(project, str(file.remoteRef)) : file && str(file.sourceTree) === "BUILT_PRODUCTS_DIR" ? byProduct.get(import_node_path17.default.basename(str(file.path) ?? "")) : void 0;
|
|
10298
10683
|
if (resolved) found.push(resolved);
|
|
10299
10684
|
}
|
|
10300
10685
|
}
|
|
@@ -10315,7 +10700,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
10315
10700
|
const name2 = str(ref.target.name) ?? ref.id;
|
|
10316
10701
|
const { get: settings2, keys } = targetSettings(ref, {
|
|
10317
10702
|
TARGET_NAME: name2,
|
|
10318
|
-
PROJECT_NAME:
|
|
10703
|
+
PROJECT_NAME: import_node_path17.default.basename(ref.project.xcodeproj, ".xcodeproj"),
|
|
10319
10704
|
SRCROOT: ref.project.projectDir,
|
|
10320
10705
|
SOURCE_ROOT: ref.project.projectDir,
|
|
10321
10706
|
PROJECT_DIR: ref.project.projectDir,
|
|
@@ -10346,8 +10731,8 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
10346
10731
|
}
|
|
10347
10732
|
return value;
|
|
10348
10733
|
};
|
|
10349
|
-
const infoPlistFile = settings("INFOPLIST_FILE") ?
|
|
10350
|
-
const sourceInfo = infoPlistFile ? import_plist3.default.parse(
|
|
10734
|
+
const infoPlistFile = settings("INFOPLIST_FILE") ? import_node_path17.default.resolve(app.project.projectDir, settings("INFOPLIST_FILE")) : null;
|
|
10735
|
+
const sourceInfo = infoPlistFile ? import_plist3.default.parse(import_node_fs16.default.readFileSync(infoPlistFile, "utf8")) : {};
|
|
10351
10736
|
if (!sourceInfo || typeof sourceInfo !== "object" || Array.isArray(sourceInfo) || sourceInfo instanceof Date || Buffer.isBuffer(sourceInfo)) {
|
|
10352
10737
|
throw new Error(`${module2.name} Info.plist must contain a dictionary`);
|
|
10353
10738
|
}
|
|
@@ -10365,12 +10750,12 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
10365
10750
|
};
|
|
10366
10751
|
}
|
|
10367
10752
|
const localPackageDirs = [
|
|
10368
|
-
...listed.filter((reference) =>
|
|
10753
|
+
...listed.filter((reference) => import_node_fs16.default.existsSync(import_node_path17.default.join(reference, "Package.swift"))),
|
|
10369
10754
|
...projects2.flatMap(
|
|
10370
10755
|
(project) => Object.entries(project.objects).flatMap(([id, entry]) => {
|
|
10371
10756
|
if (!isDict(entry)) return [];
|
|
10372
|
-
const candidate = entry.isa === "XCLocalSwiftPackageReference" ?
|
|
10373
|
-
return candidate &&
|
|
10757
|
+
const candidate = entry.isa === "XCLocalSwiftPackageReference" ? import_node_path17.default.resolve(project.projectDir, str(entry.relativePath) ?? "") : entry.isa === "PBXFileReference" ? project.resolvePath(id) : null;
|
|
10758
|
+
return candidate && import_node_fs16.default.existsSync(import_node_path17.default.join(candidate, "Package.swift")) ? [candidate] : [];
|
|
10374
10759
|
})
|
|
10375
10760
|
)
|
|
10376
10761
|
];
|
|
@@ -10394,7 +10779,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
10394
10779
|
product,
|
|
10395
10780
|
source: reference?.isa === "XCRemoteSwiftPackageReference" ? { kind: "remote", url: str(reference.repositoryURL) ?? "" } : reference?.isa === "XCLocalSwiftPackageReference" ? {
|
|
10396
10781
|
kind: "local",
|
|
10397
|
-
dir:
|
|
10782
|
+
dir: import_node_path17.default.resolve(
|
|
10398
10783
|
project.projectDir,
|
|
10399
10784
|
str(reference.relativePath) ?? ""
|
|
10400
10785
|
)
|
|
@@ -10416,8 +10801,8 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
10416
10801
|
}
|
|
10417
10802
|
}
|
|
10418
10803
|
}
|
|
10419
|
-
const resolvedFile =
|
|
10420
|
-
workspace ??
|
|
10804
|
+
const resolvedFile = import_node_path17.default.join(
|
|
10805
|
+
workspace ?? import_node_path17.default.join(xcodeprojOrWorkspace, "project.xcworkspace"),
|
|
10421
10806
|
"xcshareddata",
|
|
10422
10807
|
"swiftpm",
|
|
10423
10808
|
"Package.resolved"
|
|
@@ -10427,13 +10812,13 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
10427
10812
|
...module2,
|
|
10428
10813
|
rootDir: commonAncestor(
|
|
10429
10814
|
[
|
|
10430
|
-
workspace ?
|
|
10815
|
+
workspace ? import_node_path17.default.dirname(workspace) : app.project.projectDir,
|
|
10431
10816
|
...used.map((project) => project.projectDir),
|
|
10432
10817
|
...localPackageDirs,
|
|
10433
10818
|
...linkedProducts.flatMap(
|
|
10434
|
-
({ source }) => source.kind === "local" &&
|
|
10819
|
+
({ source }) => source.kind === "local" && import_node_fs16.default.existsSync(source.dir) ? [source.dir] : []
|
|
10435
10820
|
)
|
|
10436
|
-
].map((dir) =>
|
|
10821
|
+
].map((dir) => import_node_fs16.default.realpathSync(dir))
|
|
10437
10822
|
),
|
|
10438
10823
|
projectFiles: [...new Set(used.map((project) => project.projectFile))].sort(),
|
|
10439
10824
|
infoPlist: import_plist3.default.build(info),
|
|
@@ -10441,10 +10826,10 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
10441
10826
|
frameworks,
|
|
10442
10827
|
linkedProducts,
|
|
10443
10828
|
localPackageDirs: [
|
|
10444
|
-
...new Set(localPackageDirs.map((dir) =>
|
|
10829
|
+
...new Set(localPackageDirs.map((dir) => import_node_fs16.default.realpathSync(dir)))
|
|
10445
10830
|
].sort(),
|
|
10446
10831
|
binaryFrameworks: [...binaryFrameworks].sort(),
|
|
10447
|
-
packageResolved:
|
|
10832
|
+
packageResolved: import_node_fs16.default.existsSync(resolvedFile) ? resolvedFile : null,
|
|
10448
10833
|
appTargets: appTargetNames
|
|
10449
10834
|
};
|
|
10450
10835
|
}
|
|
@@ -10464,17 +10849,17 @@ var SKIP_SOURCE_DIRS = /* @__PURE__ */ new Set([
|
|
|
10464
10849
|
var NATIVE_DESCRIPTOR = ".one-native-source.json";
|
|
10465
10850
|
var NATIVE_GLUE = ".one-native-source.swift.txt";
|
|
10466
10851
|
function swiftPackageId(packagePath) {
|
|
10467
|
-
return
|
|
10852
|
+
return import_node_path18.default.basename(packagePath).replace(/[^A-Za-z0-9_]/g, "_").replace(/^(\d)/, "_$1");
|
|
10468
10853
|
}
|
|
10469
10854
|
function nativeSourceDescriptor(packagePath) {
|
|
10470
|
-
packagePath =
|
|
10471
|
-
const file =
|
|
10472
|
-
if (!
|
|
10855
|
+
packagePath = import_node_fs17.default.realpathSync(packagePath);
|
|
10856
|
+
const file = import_node_path18.default.join(packagePath, NATIVE_DESCRIPTOR);
|
|
10857
|
+
if (!import_node_fs17.default.existsSync(file)) return null;
|
|
10473
10858
|
const value = JSON.parse(
|
|
10474
10859
|
readPackageFile(packagePath, file, MAX_SWIFT_COMPILE_SOURCE_BYTES).toString("utf8")
|
|
10475
10860
|
);
|
|
10476
10861
|
const invalid = () => new Error(`${file}: invalid One native source descriptor; run one typegen`);
|
|
10477
|
-
if (!value || typeof value !== "object" || Reflect.get(value, "generatedBy") !== "one typegen" || !
|
|
10862
|
+
if (!value || typeof value !== "object" || Reflect.get(value, "generatedBy") !== "one typegen" || !import_node_fs17.default.existsSync(import_node_path18.default.join(packagePath, NATIVE_GLUE))) {
|
|
10478
10863
|
throw invalid();
|
|
10479
10864
|
}
|
|
10480
10865
|
if (!isSwiftNativeModules(value) || value.packageId !== swiftPackageId(packagePath)) {
|
|
@@ -10484,7 +10869,7 @@ function nativeSourceDescriptor(packagePath) {
|
|
|
10484
10869
|
}
|
|
10485
10870
|
var projects = /* @__PURE__ */ new Map();
|
|
10486
10871
|
function projectFor(packagePath, hosted) {
|
|
10487
|
-
packagePath =
|
|
10872
|
+
packagePath = import_node_fs17.default.realpathSync(packagePath);
|
|
10488
10873
|
const existing = projects.get(packagePath);
|
|
10489
10874
|
if (existing) {
|
|
10490
10875
|
if (hosted && !existing.hosted) {
|
|
@@ -10506,14 +10891,14 @@ function projectFor(packagePath, hosted) {
|
|
|
10506
10891
|
}
|
|
10507
10892
|
var xcodeProjects = /* @__PURE__ */ new Map();
|
|
10508
10893
|
function swiftPackages(entry, app) {
|
|
10509
|
-
const stamp = (file) => file &&
|
|
10894
|
+
const stamp = (file) => file && import_node_fs17.default.existsSync(file) ? import_node_fs17.default.statSync(file).mtimeMs : 0;
|
|
10510
10895
|
const key = JSON.stringify([
|
|
10511
10896
|
app.linkedProducts,
|
|
10512
10897
|
app.packageResolved,
|
|
10513
10898
|
stamp(app.packageResolved),
|
|
10514
|
-
app.localPackageDirs.map((dir) => stamp(
|
|
10899
|
+
app.localPackageDirs.map((dir) => stamp(import_node_path18.default.join(dir, "Package.swift"))),
|
|
10515
10900
|
app.linkedProducts.map(
|
|
10516
|
-
({ source }) => source.kind === "local" ? stamp(
|
|
10901
|
+
({ source }) => source.kind === "local" ? stamp(import_node_path18.default.join(source.dir, "Package.swift")) : 0
|
|
10517
10902
|
)
|
|
10518
10903
|
]);
|
|
10519
10904
|
if (entry.packages?.key !== key) {
|
|
@@ -10533,11 +10918,11 @@ function swiftPackages(entry, app) {
|
|
|
10533
10918
|
var XCODE_APP_DIR = "__app__";
|
|
10534
10919
|
var XCODE_FRAMEWORKS_DIR = "__frameworks__";
|
|
10535
10920
|
var XCODE_PACKAGES_DIR = "__packages__";
|
|
10536
|
-
var CHECKOUTS_PREFIX = `${REMOTE_CHECKOUTS.split(
|
|
10921
|
+
var CHECKOUTS_PREFIX = `${REMOTE_CHECKOUTS.split(import_node_path18.default.sep).join(import_node_path18.default.posix.sep)}/`;
|
|
10537
10922
|
function xcodeInputKey(layout, file, relative2) {
|
|
10538
10923
|
const owner = layout.targetDirs.get(file);
|
|
10539
|
-
if (owner) return
|
|
10540
|
-
return relative2.startsWith(CHECKOUTS_PREFIX) ?
|
|
10924
|
+
if (owner) return import_node_path18.default.posix.join(owner, relative2);
|
|
10925
|
+
return relative2.startsWith(CHECKOUTS_PREFIX) ? import_node_path18.default.posix.join(XCODE_PACKAGES_DIR, relative2.slice(CHECKOUTS_PREFIX.length)) : relative2;
|
|
10541
10926
|
}
|
|
10542
10927
|
function xcodeLayout(root) {
|
|
10543
10928
|
const registered = xcodeProjects.get(root);
|
|
@@ -10548,7 +10933,7 @@ function xcodeLayout(root) {
|
|
|
10548
10933
|
const targetDirs = new Map(app.sources.map((file) => [file, XCODE_APP_DIR]));
|
|
10549
10934
|
const targets = [];
|
|
10550
10935
|
for (const framework of app.frameworks) {
|
|
10551
|
-
const dir =
|
|
10936
|
+
const dir = import_node_path18.default.posix.join(XCODE_FRAMEWORKS_DIR, framework.moduleName);
|
|
10552
10937
|
for (const file of framework.sources) {
|
|
10553
10938
|
if (targetDirs.has(file)) continue;
|
|
10554
10939
|
targetDirs.set(file, dir);
|
|
@@ -10566,19 +10951,19 @@ function xcodeLayout(root) {
|
|
|
10566
10951
|
}
|
|
10567
10952
|
const packages = swiftPackages(registered, app);
|
|
10568
10953
|
for (const target of packages.targets) {
|
|
10569
|
-
const relative2 =
|
|
10570
|
-
target.remote ?
|
|
10954
|
+
const relative2 = import_node_path18.default.relative(
|
|
10955
|
+
target.remote ? import_node_path18.default.join(root, REMOTE_CHECKOUTS) : root,
|
|
10571
10956
|
target.dir
|
|
10572
10957
|
);
|
|
10573
|
-
if (relative2 === ".." || relative2.startsWith(`..${
|
|
10958
|
+
if (relative2 === ".." || relative2.startsWith(`..${import_node_path18.default.sep}`) || import_node_path18.default.isAbsolute(relative2))
|
|
10574
10959
|
throw new Error(`swift input escapes the selected package: ${target.dir}`);
|
|
10575
|
-
const posix2 = relative2.split(
|
|
10960
|
+
const posix2 = relative2.split(import_node_path18.default.sep).join(import_node_path18.default.posix.sep);
|
|
10576
10961
|
targets.push({
|
|
10577
10962
|
...target,
|
|
10578
|
-
path: target.remote ?
|
|
10963
|
+
path: target.remote ? import_node_path18.default.posix.join(XCODE_PACKAGES_DIR, posix2) : posix2,
|
|
10579
10964
|
exclude: []
|
|
10580
10965
|
});
|
|
10581
|
-
if (!target.remote) files.add(
|
|
10966
|
+
if (!target.remote) files.add(import_node_path18.default.join(target.packageDir, "Package.swift"));
|
|
10582
10967
|
for (const file of target.files) files.add(file);
|
|
10583
10968
|
}
|
|
10584
10969
|
for (const target of targets) {
|
|
@@ -10607,25 +10992,25 @@ function xcodeManifest(layout) {
|
|
|
10607
10992
|
].join("\n");
|
|
10608
10993
|
}
|
|
10609
10994
|
function packageFiles(root) {
|
|
10610
|
-
const canonicalRoot =
|
|
10995
|
+
const canonicalRoot = import_node_fs17.default.realpathSync(root);
|
|
10611
10996
|
const xcode = xcodeLayout(canonicalRoot);
|
|
10612
10997
|
return xcode ? xcode.files : sourceTreeFiles(canonicalRoot, canonicalRoot);
|
|
10613
10998
|
}
|
|
10614
10999
|
function sourceTreeFiles(dir, canonicalRoot) {
|
|
10615
11000
|
const found = [];
|
|
10616
11001
|
const walk2 = (dir2) => {
|
|
10617
|
-
for (const entry of
|
|
11002
|
+
for (const entry of import_node_fs17.default.readdirSync(dir2, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
|
|
10618
11003
|
if (entry.name.startsWith(".") && entry.name !== NATIVE_DESCRIPTOR && entry.name !== NATIVE_GLUE || SKIP_SOURCE_DIRS.has(entry.name))
|
|
10619
11004
|
continue;
|
|
10620
|
-
const full =
|
|
11005
|
+
const full = import_node_path18.default.join(dir2, entry.name);
|
|
10621
11006
|
if (entry.isSymbolicLink()) throw new Error(`swift input is a symlink: ${full}`);
|
|
10622
|
-
const real =
|
|
10623
|
-
const relative2 =
|
|
10624
|
-
if (relative2.startsWith(`..${
|
|
11007
|
+
const real = import_node_fs17.default.realpathSync(full);
|
|
11008
|
+
const relative2 = import_node_path18.default.relative(canonicalRoot, real);
|
|
11009
|
+
if (relative2.startsWith(`..${import_node_path18.default.sep}`) || relative2 === ".." || import_node_path18.default.isAbsolute(relative2)) {
|
|
10625
11010
|
throw new Error(`swift input escapes the selected package: ${full}`);
|
|
10626
11011
|
}
|
|
10627
11012
|
if (entry.isDirectory()) {
|
|
10628
|
-
if (
|
|
11013
|
+
if (import_node_fs17.default.existsSync(import_node_path18.default.join(full, "Package.swift"))) continue;
|
|
10629
11014
|
walk2(full);
|
|
10630
11015
|
} else if (entry.isFile()) {
|
|
10631
11016
|
found.push(full);
|
|
@@ -10633,29 +11018,29 @@ function sourceTreeFiles(dir, canonicalRoot) {
|
|
|
10633
11018
|
}
|
|
10634
11019
|
}
|
|
10635
11020
|
};
|
|
10636
|
-
if (
|
|
11021
|
+
if (import_node_fs17.default.existsSync(dir)) walk2(import_node_fs17.default.realpathSync(dir));
|
|
10637
11022
|
return found;
|
|
10638
11023
|
}
|
|
10639
11024
|
function readPackageFile(root, file, maxBytes) {
|
|
10640
|
-
const canonicalRoot =
|
|
10641
|
-
const relative2 =
|
|
10642
|
-
if (relative2 === ".." || relative2.startsWith(`..${
|
|
11025
|
+
const canonicalRoot = import_node_fs17.default.realpathSync(root);
|
|
11026
|
+
const relative2 = import_node_path18.default.relative(canonicalRoot, import_node_fs17.default.realpathSync(file));
|
|
11027
|
+
if (relative2 === ".." || relative2.startsWith(`..${import_node_path18.default.sep}`) || import_node_path18.default.isAbsolute(relative2)) {
|
|
10643
11028
|
throw new Error(`swift input escapes the selected package: ${file}`);
|
|
10644
11029
|
}
|
|
10645
|
-
let ancestor =
|
|
11030
|
+
let ancestor = import_node_path18.default.resolve(file);
|
|
10646
11031
|
while (ancestor !== canonicalRoot) {
|
|
10647
|
-
if (
|
|
11032
|
+
if (import_node_fs17.default.lstatSync(ancestor).isSymbolicLink()) {
|
|
10648
11033
|
throw new Error(`swift input is a symlink: ${ancestor}`);
|
|
10649
11034
|
}
|
|
10650
|
-
const parent =
|
|
11035
|
+
const parent = import_node_path18.default.dirname(ancestor);
|
|
10651
11036
|
if (parent === ancestor)
|
|
10652
11037
|
throw new Error(`swift input escapes the selected package: ${file}`);
|
|
10653
11038
|
ancestor = parent;
|
|
10654
11039
|
}
|
|
10655
|
-
const expected =
|
|
10656
|
-
const fd =
|
|
11040
|
+
const expected = import_node_fs17.default.statSync(file);
|
|
11041
|
+
const fd = import_node_fs17.default.openSync(file, import_node_fs17.default.constants.O_RDONLY | import_node_fs17.default.constants.O_NOFOLLOW);
|
|
10657
11042
|
try {
|
|
10658
|
-
const stat2 =
|
|
11043
|
+
const stat2 = import_node_fs17.default.fstatSync(fd);
|
|
10659
11044
|
if (stat2.dev !== expected.dev || stat2.ino !== expected.ino) {
|
|
10660
11045
|
throw new Error(`swift input changed while opening: ${file}`);
|
|
10661
11046
|
}
|
|
@@ -10665,16 +11050,16 @@ function readPackageFile(root, file, maxBytes) {
|
|
|
10665
11050
|
const bytes = Buffer.alloc(stat2.size + 1);
|
|
10666
11051
|
let offset = 0;
|
|
10667
11052
|
while (offset < bytes.length) {
|
|
10668
|
-
const count =
|
|
11053
|
+
const count = import_node_fs17.default.readSync(fd, bytes, offset, bytes.length - offset, null);
|
|
10669
11054
|
if (count === 0) break;
|
|
10670
11055
|
offset += count;
|
|
10671
11056
|
}
|
|
10672
|
-
if (offset !== stat2.size ||
|
|
11057
|
+
if (offset !== stat2.size || import_node_fs17.default.fstatSync(fd).size !== stat2.size) {
|
|
10673
11058
|
throw new Error(`swift input changed while reading: ${file}`);
|
|
10674
11059
|
}
|
|
10675
11060
|
return bytes.subarray(0, offset);
|
|
10676
11061
|
} finally {
|
|
10677
|
-
|
|
11062
|
+
import_node_fs17.default.closeSync(fd);
|
|
10678
11063
|
}
|
|
10679
11064
|
}
|
|
10680
11065
|
function sourceFiles(root) {
|
|
@@ -10682,7 +11067,7 @@ function sourceFiles(root) {
|
|
|
10682
11067
|
}
|
|
10683
11068
|
function resourceCandidateFiles(root) {
|
|
10684
11069
|
return packageFiles(root).filter(
|
|
10685
|
-
(file) => !file.endsWith(".swift") && !["project.pbxproj", "project.xcproj"].includes(
|
|
11070
|
+
(file) => !file.endsWith(".swift") && !["project.pbxproj", "project.xcproj"].includes(import_node_path18.default.basename(file))
|
|
10686
11071
|
);
|
|
10687
11072
|
}
|
|
10688
11073
|
var HOSTED_LIMITS = {
|
|
@@ -10716,7 +11101,7 @@ function buildSwiftResourceTable(project, baseUrl) {
|
|
|
10716
11101
|
const limits = inputLimits(Boolean(project.hosted));
|
|
10717
11102
|
const absolute = resourceCandidateFiles(project.packagePath);
|
|
10718
11103
|
const relative2 = absolute.map(
|
|
10719
|
-
(file) =>
|
|
11104
|
+
(file) => import_node_path18.default.relative(project.packagePath, file).split(import_node_path18.default.sep).join(import_node_path18.default.posix.sep)
|
|
10720
11105
|
);
|
|
10721
11106
|
const byRelative = new Map(absolute.map((file, index) => [relative2[index], file]));
|
|
10722
11107
|
const readContents = (candidate) => {
|
|
@@ -10738,16 +11123,16 @@ function buildSwiftResourceTable(project, baseUrl) {
|
|
|
10738
11123
|
for (const { name: name2, file, scale } of found) {
|
|
10739
11124
|
const disk = byRelative.get(file);
|
|
10740
11125
|
if (!disk) continue;
|
|
10741
|
-
if (Object.keys(images).length >= limits.images || imageBytes +
|
|
11126
|
+
if (Object.keys(images).length >= limits.images || imageBytes + import_node_fs17.default.statSync(disk).size > limits.imageTotalBytes) {
|
|
10742
11127
|
throw new Error("swift image pack exceeds the compile service caps");
|
|
10743
11128
|
}
|
|
10744
11129
|
const bytes = readPackageFile(project.packagePath, disk, limits.imageBytes);
|
|
10745
11130
|
imageBytes += bytes.length;
|
|
10746
|
-
const hash = (0,
|
|
10747
|
-
const ext =
|
|
11131
|
+
const hash = (0, import_node_crypto7.createHash)("sha256").update(bytes).digest("hex").slice(0, 16);
|
|
11132
|
+
const ext = import_node_path18.default.posix.extname(file).toLowerCase();
|
|
10748
11133
|
table[name2] = { uri: `${baseUrl}${RESOURCE_PATH}${hash}${ext}`, scale };
|
|
10749
11134
|
images[name2] = {
|
|
10750
|
-
file:
|
|
11135
|
+
file: import_node_path18.default.posix.basename(file),
|
|
10751
11136
|
data: bytes.toString("base64")
|
|
10752
11137
|
};
|
|
10753
11138
|
watched.push(file);
|
|
@@ -10771,10 +11156,10 @@ function buildSwiftResourceTable(project, baseUrl) {
|
|
|
10771
11156
|
return { table, images, colors, symbols, watched };
|
|
10772
11157
|
}
|
|
10773
11158
|
function buildSwiftBundleFiles(packagePath, hosted) {
|
|
10774
|
-
packagePath =
|
|
11159
|
+
packagePath = import_node_fs17.default.realpathSync(packagePath);
|
|
10775
11160
|
const limits = inputLimits(hosted);
|
|
10776
11161
|
const relative2 = resourceCandidateFiles(packagePath).map(
|
|
10777
|
-
(file) =>
|
|
11162
|
+
(file) => import_node_path18.default.relative(packagePath, file).split(import_node_path18.default.sep).join(import_node_path18.default.posix.sep)
|
|
10778
11163
|
);
|
|
10779
11164
|
const files = {};
|
|
10780
11165
|
const watched = [];
|
|
@@ -10788,13 +11173,13 @@ function buildSwiftBundleFiles(packagePath, hosted) {
|
|
|
10788
11173
|
total += bytes.length;
|
|
10789
11174
|
if (xcode.app.infoPlistFile)
|
|
10790
11175
|
watched.push(
|
|
10791
|
-
|
|
11176
|
+
import_node_path18.default.relative(packagePath, xcode.app.infoPlistFile).split(import_node_path18.default.sep).join("/")
|
|
10792
11177
|
);
|
|
10793
11178
|
}
|
|
10794
11179
|
for (const { base, file } of enumerateBundleJson(relative2)) {
|
|
10795
11180
|
watched.push(file);
|
|
10796
|
-
const disk =
|
|
10797
|
-
if (Object.keys(files).length >= limits.resources || total +
|
|
11181
|
+
const disk = import_node_path18.default.join(packagePath, ...file.split("/"));
|
|
11182
|
+
if (Object.keys(files).length >= limits.resources || total + import_node_fs17.default.statSync(disk).size > limits.resourceTotalBytes) {
|
|
10798
11183
|
throw new Error(
|
|
10799
11184
|
`swift bundle pack exceeds ${limits.resources} files / ${limits.resourceTotalBytes} bytes`
|
|
10800
11185
|
);
|
|
@@ -10809,12 +11194,12 @@ function serveSwiftResource(project, key) {
|
|
|
10809
11194
|
return project.resourceFiles.get(key) ?? project.resourcesPrevious.get(key) ?? null;
|
|
10810
11195
|
}
|
|
10811
11196
|
function linkedModuleRoots(packagePath) {
|
|
10812
|
-
packagePath =
|
|
11197
|
+
packagePath = import_node_fs17.default.realpathSync(packagePath);
|
|
10813
11198
|
let manifest;
|
|
10814
11199
|
try {
|
|
10815
11200
|
manifest = readPackageFile(
|
|
10816
11201
|
packagePath,
|
|
10817
|
-
|
|
11202
|
+
import_node_path18.default.join(packagePath, "Package.swift"),
|
|
10818
11203
|
MAX_SWIFT_COMPILE_SOURCE_BYTES
|
|
10819
11204
|
).toString("utf8");
|
|
10820
11205
|
} catch {
|
|
@@ -10823,28 +11208,28 @@ function linkedModuleRoots(packagePath) {
|
|
|
10823
11208
|
const roots = /* @__PURE__ */ new Set();
|
|
10824
11209
|
const dependency = /\.package\(\s*path:\s*"([^"]+)"\s*\)/g;
|
|
10825
11210
|
for (const match of manifest.replace(/^\s*\/\/.*$/gm, "").matchAll(dependency)) {
|
|
10826
|
-
const root =
|
|
10827
|
-
if (
|
|
11211
|
+
const root = import_node_path18.default.resolve(packagePath, match[1]);
|
|
11212
|
+
if (import_node_fs17.default.existsSync(import_node_path18.default.join(root, "Package.swift"))) roots.add(root);
|
|
10828
11213
|
}
|
|
10829
11214
|
return [...roots].sort();
|
|
10830
11215
|
}
|
|
10831
11216
|
function sourceStamp(packagePath, moduleRootOverride, hosted = false) {
|
|
10832
|
-
const hash = (0,
|
|
11217
|
+
const hash = (0, import_node_crypto7.createHash)("sha256");
|
|
10833
11218
|
hash.update(packagePath);
|
|
10834
11219
|
const projectInputs = new Set(packageFiles(packagePath));
|
|
10835
11220
|
for (const file of [...projectInputs].sort()) {
|
|
10836
|
-
hash.update(
|
|
10837
|
-
const stat2 =
|
|
11221
|
+
hash.update(import_node_path18.default.relative(packagePath, file));
|
|
11222
|
+
const stat2 = import_node_fs17.default.statSync(file);
|
|
10838
11223
|
hash.update(`${stat2.mtimeMs}/${stat2.ctimeMs}/${stat2.size}`);
|
|
10839
11224
|
}
|
|
10840
11225
|
const moduleRoot = hosted ? void 0 : moduleRootOverride ?? linkedModuleRoots(packagePath).find(
|
|
10841
|
-
(root) =>
|
|
11226
|
+
(root) => import_node_fs17.default.existsSync(import_node_path18.default.join(root, "toolchain.json"))
|
|
10842
11227
|
);
|
|
10843
11228
|
if (moduleRoot) {
|
|
10844
11229
|
hash.update(moduleRoot);
|
|
10845
11230
|
for (const relative2 of swiftModuleInputFiles(moduleRoot)) {
|
|
10846
11231
|
hash.update(relative2);
|
|
10847
|
-
hash.update(String(
|
|
11232
|
+
hash.update(String(import_node_fs17.default.statSync(import_node_path18.default.join(moduleRoot, relative2)).mtimeMs));
|
|
10848
11233
|
}
|
|
10849
11234
|
}
|
|
10850
11235
|
return hash.digest("hex").slice(0, 16);
|
|
@@ -10856,8 +11241,8 @@ function packageSources(packagePath) {
|
|
|
10856
11241
|
const xcode = xcodeLayout(packagePath);
|
|
10857
11242
|
const files = {};
|
|
10858
11243
|
for (const file of sourceFiles(packagePath)) {
|
|
10859
|
-
const relative2 =
|
|
10860
|
-
if (xcode &&
|
|
11244
|
+
const relative2 = import_node_path18.default.relative(packagePath, file).split(import_node_path18.default.sep).join(import_node_path18.default.posix.sep);
|
|
11245
|
+
if (xcode && import_node_path18.default.basename(file) === "Package.swift") continue;
|
|
10861
11246
|
files[xcode ? xcodeInputKey(xcode, file, relative2) : relative2] = readPackageFile(
|
|
10862
11247
|
packagePath,
|
|
10863
11248
|
file,
|
|
@@ -10874,7 +11259,7 @@ function packageSnapshot(project) {
|
|
|
10874
11259
|
files,
|
|
10875
11260
|
resourcePaths: swiftImplicitResourcePaths(
|
|
10876
11261
|
resourceCandidateFiles(project.packagePath).map(
|
|
10877
|
-
(file) =>
|
|
11262
|
+
(file) => import_node_path18.default.relative(project.packagePath, file).split(import_node_path18.default.sep).join(import_node_path18.default.posix.sep)
|
|
10878
11263
|
)
|
|
10879
11264
|
),
|
|
10880
11265
|
resources: buildSwiftResourceTable(project, ""),
|
|
@@ -10883,7 +11268,7 @@ function packageSnapshot(project) {
|
|
|
10883
11268
|
...native ? {
|
|
10884
11269
|
glue: readPackageFile(
|
|
10885
11270
|
project.packagePath,
|
|
10886
|
-
|
|
11271
|
+
import_node_path18.default.join(project.packagePath, NATIVE_GLUE),
|
|
10887
11272
|
MAX_SWIFT_COMPILE_SOURCE_BYTES
|
|
10888
11273
|
).toString("utf8")
|
|
10889
11274
|
} : {}
|
|
@@ -10919,7 +11304,7 @@ async function compile(packagePath, entry, stamp, moduleRootOverride, hosted, sn
|
|
|
10919
11304
|
package: content
|
|
10920
11305
|
};
|
|
10921
11306
|
const moduleRoot = moduleRootOverride ?? linkedModuleRoots(packagePath).find(
|
|
10922
|
-
(root) =>
|
|
11307
|
+
(root) => import_node_fs17.default.existsSync(import_node_path18.default.join(root, "toolchain.json"))
|
|
10923
11308
|
) ?? await swiftDistributionRoot();
|
|
10924
11309
|
if (!moduleRoot)
|
|
10925
11310
|
return {
|
|
@@ -10938,17 +11323,17 @@ async function compile(packagePath, entry, stamp, moduleRootOverride, hosted, sn
|
|
|
10938
11323
|
...targets.length > 0 ? targets : ["App"]
|
|
10939
11324
|
])
|
|
10940
11325
|
);
|
|
10941
|
-
if (missing.size > 0) throw new Error(missingModulesMessage(packagePath, missing));
|
|
11326
|
+
if (missing.size > 0) throw new Error(await missingModulesMessage(packagePath, missing));
|
|
10942
11327
|
const artifact = await compileSwiftProjectUnit(input, {
|
|
10943
11328
|
// the compile rewrites Sources/App in its root before swiftpm builds, and
|
|
10944
11329
|
// its lock orders one process only: two vites on one root (a lane's dev
|
|
10945
11330
|
// server and a capture, or two checkouts) build each other's sources. so
|
|
10946
11331
|
// each app and module checkout gets its own root, which keeps the same
|
|
10947
11332
|
// app's incremental build across restarts.
|
|
10948
|
-
buildRoot: process.env.CONTRAST_SWIFT_BUILD_ROOT ??
|
|
10949
|
-
|
|
11333
|
+
buildRoot: process.env.CONTRAST_SWIFT_BUILD_ROOT ?? import_node_path18.default.join(
|
|
11334
|
+
import_node_os7.default.tmpdir(),
|
|
10950
11335
|
"contrast-swift-build",
|
|
10951
|
-
(0,
|
|
11336
|
+
(0, import_node_crypto7.createHash)("sha256").update(`${moduleRoot}\0${import_node_path18.default.resolve(packagePath)}`).digest("hex").slice(0, 16)
|
|
10952
11337
|
),
|
|
10953
11338
|
moduleRoot,
|
|
10954
11339
|
...toolchain
|
|
@@ -11015,21 +11400,8 @@ var UNPROVIDED_PLATFORM_MODULES = {
|
|
|
11015
11400
|
Darwin: "Peach compiles for WebAssembly, which has no Darwin; C library names come through Foundation",
|
|
11016
11401
|
MachO: "Peach compiles for WebAssembly, which has no Mach-O images"
|
|
11017
11402
|
};
|
|
11018
|
-
var
|
|
11019
|
-
function
|
|
11020
|
-
if (iosSdkFrameworks) return iosSdkFrameworks;
|
|
11021
|
-
iosSdkFrameworks = /* @__PURE__ */ new Set();
|
|
11022
|
-
if (process.platform !== "darwin") return iosSdkFrameworks;
|
|
11023
|
-
const sdk = (0, import_node_child_process8.execFileSync)("xcrun", ["--sdk", "iphonesimulator", "--show-sdk-path"], {
|
|
11024
|
-
encoding: "utf8",
|
|
11025
|
-
stdio: ["ignore", "pipe", "ignore"]
|
|
11026
|
-
}).trim();
|
|
11027
|
-
for (const entry of import_node_fs16.default.readdirSync(import_node_path17.default.join(sdk, "System/Library/Frameworks")))
|
|
11028
|
-
if (entry.endsWith(".framework"))
|
|
11029
|
-
iosSdkFrameworks.add(entry.slice(0, -".framework".length));
|
|
11030
|
-
return iosSdkFrameworks;
|
|
11031
|
-
}
|
|
11032
|
-
function missingModulesMessage(packagePath, missing) {
|
|
11403
|
+
var IOS_SDK_FRAMEWORKS = new Set(ios_sdk_frameworks_default.frameworks);
|
|
11404
|
+
async function missingModulesMessage(packagePath, missing) {
|
|
11033
11405
|
const layout = xcodeLayout(packagePath);
|
|
11034
11406
|
const gaps = new Map([
|
|
11035
11407
|
...(layout?.app.binaryFrameworks ?? []).map(
|
|
@@ -11041,7 +11413,7 @@ function missingModulesMessage(packagePath, missing) {
|
|
|
11041
11413
|
name2,
|
|
11042
11414
|
{ source: "the iOS SDK", reason: UNPROVIDED_PLATFORM_MODULES[name2] }
|
|
11043
11415
|
]
|
|
11044
|
-
] :
|
|
11416
|
+
] : IOS_SDK_FRAMEWORKS.has(name2) ? [
|
|
11045
11417
|
[
|
|
11046
11418
|
name2,
|
|
11047
11419
|
{ source: "the iOS SDK", reason: "a framework Peach does not provide" }
|
|
@@ -11051,12 +11423,29 @@ function missingModulesMessage(packagePath, missing) {
|
|
|
11051
11423
|
...layout?.packages.modules ?? [],
|
|
11052
11424
|
...layout?.packages.unavailable ?? []
|
|
11053
11425
|
]);
|
|
11426
|
+
const packaged = new Set(
|
|
11427
|
+
[...missing.keys()].filter(
|
|
11428
|
+
(name2) => !UNPROVIDED_PLATFORM_MODULES[name2] && !IOS_SDK_FRAMEWORKS.has(name2)
|
|
11429
|
+
)
|
|
11430
|
+
);
|
|
11431
|
+
if (packaged.size > 0)
|
|
11432
|
+
await Promise.all(
|
|
11433
|
+
(layout?.packages.binaries ?? []).map(async (binary) => {
|
|
11434
|
+
const modules = await swiftBinaryModules(binary).catch(() => []);
|
|
11435
|
+
for (const name2 of modules)
|
|
11436
|
+
if (packaged.has(name2))
|
|
11437
|
+
gaps.set(name2, {
|
|
11438
|
+
source: binary.source,
|
|
11439
|
+
reason: `${binary.target} is a binary framework`
|
|
11440
|
+
});
|
|
11441
|
+
})
|
|
11442
|
+
);
|
|
11054
11443
|
const width = Math.max(...[...missing.keys()].map((name2) => name2.length));
|
|
11055
11444
|
return [
|
|
11056
11445
|
`Peach does not provide ${missing.size} module${missing.size === 1 ? "" : "s"} this app imports:`,
|
|
11057
11446
|
...[...missing].map(([name2, files]) => {
|
|
11058
11447
|
const gap = gaps.get(name2);
|
|
11059
|
-
return ` ${name2.padEnd(width)} ${files.length} file${files.length === 1 ? "" : "s"}${gap ? `, ${gap.source.includes("://") ? `package ${gap.source}` : gap.source.startsWith("/") ? `package ${
|
|
11448
|
+
return ` ${name2.padEnd(width)} ${files.length} file${files.length === 1 ? "" : "s"}${gap ? `, ${gap.source.includes("://") ? `package ${gap.source}` : gap.source.startsWith("/") ? `package ${import_node_path18.default.relative(packagePath, gap.source) || "."}` : gap.source} (${gap.reason})` : ""}`;
|
|
11060
11449
|
})
|
|
11061
11450
|
].join("\n");
|
|
11062
11451
|
}
|
|
@@ -11064,7 +11453,7 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
|
|
|
11064
11453
|
const auth = hosted ? null : resolveCliAuth();
|
|
11065
11454
|
if (!hosted && (!auth || auth.kind === "github")) {
|
|
11066
11455
|
throw new Error(
|
|
11067
|
-
`compiling ${
|
|
11456
|
+
`compiling ${import_node_path18.default.basename(packagePath)} for Peach needs \`peach login\` or PEACH_API_KEY: this peachsim has no local SwiftUI module, so Contrast compiles it`
|
|
11068
11457
|
);
|
|
11069
11458
|
}
|
|
11070
11459
|
const origin = hosted?.origin ?? resolveContrastBackendOrigin(auth?.kind === "session" ? auth.origin : null);
|
|
@@ -11083,7 +11472,7 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
|
|
|
11083
11472
|
const bytes = sources.reduce((total2, text2) => total2 + Buffer.byteLength(text2), 0);
|
|
11084
11473
|
if (sources.length > MAX_SWIFT_COMPILE_FILES || bytes > MAX_SWIFT_COMPILE_SOURCE_BYTES) {
|
|
11085
11474
|
throw new Error(
|
|
11086
|
-
`${
|
|
11475
|
+
`${import_node_path18.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`
|
|
11087
11476
|
);
|
|
11088
11477
|
}
|
|
11089
11478
|
const descriptor = snapshot.native;
|
|
@@ -11102,7 +11491,7 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
|
|
|
11102
11491
|
);
|
|
11103
11492
|
if (descriptor && address.native?.hash !== descriptor.hash) {
|
|
11104
11493
|
throw new Error(
|
|
11105
|
-
`${
|
|
11494
|
+
`${import_node_path18.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`
|
|
11106
11495
|
);
|
|
11107
11496
|
}
|
|
11108
11497
|
const response = await fetch(address.url, { signal });
|
|
@@ -11221,13 +11610,13 @@ function serveSwiftPackageAsset(pathname, res) {
|
|
|
11221
11610
|
}
|
|
11222
11611
|
|
|
11223
11612
|
// src/expo-swift-host.ts
|
|
11224
|
-
var run3 = (0, import_node_util3.promisify)(
|
|
11613
|
+
var run3 = (0, import_node_util3.promisify)(import_node_child_process8.execFile);
|
|
11225
11614
|
var scriptEnv = { ...process.env, [RNX_FORKED_SCRIPT_ENV]: "1" };
|
|
11226
11615
|
var EXPO_SWIFT_ROUTE = "/__peach/expo-swift";
|
|
11227
11616
|
var EXPO_SWIFT_ENTRY = "Sources/PeachExpoApp/PeachExpoEntry.swift";
|
|
11228
11617
|
async function collectExpoSwiftSources(appRoot) {
|
|
11229
|
-
appRoot =
|
|
11230
|
-
const appRequire = (0, import_node_module.createRequire)(
|
|
11618
|
+
appRoot = import_node_fs18.default.realpathSync(appRoot);
|
|
11619
|
+
const appRequire = (0, import_node_module.createRequire)(import_node_path19.default.join(appRoot, "package.json"));
|
|
11231
11620
|
let autolinker;
|
|
11232
11621
|
try {
|
|
11233
11622
|
autolinker = appRequire.resolve("expo-modules-autolinking/package.json");
|
|
@@ -11241,7 +11630,7 @@ async function collectExpoSwiftSources(appRoot) {
|
|
|
11241
11630
|
(command) => run3(
|
|
11242
11631
|
process.execPath,
|
|
11243
11632
|
[
|
|
11244
|
-
|
|
11633
|
+
import_node_path19.default.join(import_node_path19.default.dirname(autolinker), "bin/expo-modules-autolinking.js"),
|
|
11245
11634
|
command,
|
|
11246
11635
|
"--platform",
|
|
11247
11636
|
"apple",
|
|
@@ -11272,8 +11661,8 @@ async function collectExpoSwiftSources(appRoot) {
|
|
|
11272
11661
|
const sourceRoot = Reflect.get(entry, "path");
|
|
11273
11662
|
if (typeof sourceRoot !== "string")
|
|
11274
11663
|
throw new Error("Expo autolinking entry has no path");
|
|
11275
|
-
const canonical =
|
|
11276
|
-
if (canonical.split(
|
|
11664
|
+
const canonical = import_node_fs18.default.realpathSync(sourceRoot);
|
|
11665
|
+
if (canonical.split(import_node_path19.default.sep).includes("node_modules")) continue;
|
|
11277
11666
|
const resolution = resolutions.find(
|
|
11278
11667
|
(candidate) => candidate && typeof candidate === "object" && Reflect.get(candidate, "packageName") === Reflect.get(entry, "name")
|
|
11279
11668
|
);
|
|
@@ -11299,12 +11688,12 @@ async function collectExpoSwiftSources(appRoot) {
|
|
|
11299
11688
|
`(${className.includes(".") ? className : `${namespace}.${className}`}.self, ${name2 === null ? "nil" : JSON.stringify(name2)})`
|
|
11300
11689
|
);
|
|
11301
11690
|
}
|
|
11302
|
-
const ios =
|
|
11303
|
-
if (
|
|
11691
|
+
const ios = import_node_path19.default.join(canonical, "ios");
|
|
11692
|
+
if (import_node_fs18.default.lstatSync(ios).isSymbolicLink())
|
|
11304
11693
|
throw new Error(`Expo Swift source directory is a symlink: ${ios}`);
|
|
11305
11694
|
const walk2 = (dir) => {
|
|
11306
|
-
for (const child of
|
|
11307
|
-
const file =
|
|
11695
|
+
for (const child of import_node_fs18.default.readdirSync(dir, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
11696
|
+
const file = import_node_path19.default.join(dir, child.name);
|
|
11308
11697
|
if (child.isSymbolicLink())
|
|
11309
11698
|
throw new Error(`Expo Swift source is a symlink: ${file}`);
|
|
11310
11699
|
if (child.isDirectory()) {
|
|
@@ -11312,13 +11701,13 @@ async function collectExpoSwiftSources(appRoot) {
|
|
|
11312
11701
|
continue;
|
|
11313
11702
|
}
|
|
11314
11703
|
if (!child.name.endsWith(".swift")) continue;
|
|
11315
|
-
const size =
|
|
11704
|
+
const size = import_node_fs18.default.statSync(file).size;
|
|
11316
11705
|
bytes += size;
|
|
11317
11706
|
fileCount++;
|
|
11318
11707
|
if (fileCount > MAX_SWIFT_COMPILE_FILES - 2 || bytes > MAX_SWIFT_COMPILE_SOURCE_BYTES)
|
|
11319
11708
|
throw new Error("Expo Swift sources exceed compile service caps");
|
|
11320
|
-
files[`Sources/${namespace}/${
|
|
11321
|
-
${
|
|
11709
|
+
files[`Sources/${namespace}/${import_node_path19.default.relative(ios, file).split(import_node_path19.default.sep).join("/")}`] = `#sourceLocation(file: ${JSON.stringify(file)}, line: 1)
|
|
11710
|
+
${import_node_fs18.default.readFileSync(file, "utf8")}`;
|
|
11322
11711
|
}
|
|
11323
11712
|
};
|
|
11324
11713
|
walk2(ios);
|
|
@@ -11403,7 +11792,7 @@ async function handleExpoSwiftRequest(req, res) {
|
|
|
11403
11792
|
return true;
|
|
11404
11793
|
}
|
|
11405
11794
|
const root = url.searchParams.get("root");
|
|
11406
|
-
if (!root || !
|
|
11795
|
+
if (!root || !import_node_path19.default.isAbsolute(root)) {
|
|
11407
11796
|
res.writeHead(400);
|
|
11408
11797
|
res.end("missing absolute app root");
|
|
11409
11798
|
return true;
|
|
@@ -11420,7 +11809,7 @@ async function handleExpoSwiftRequest(req, res) {
|
|
|
11420
11809
|
modules: [],
|
|
11421
11810
|
failures: []
|
|
11422
11811
|
};
|
|
11423
|
-
const key = (0,
|
|
11812
|
+
const key = (0, import_node_crypto8.createHash)("sha256").update(import_node_fs18.default.realpathSync(root)).digest("hex");
|
|
11424
11813
|
const host2 = req.headers.host;
|
|
11425
11814
|
if (!host2) throw new Error("Expo Swift request has no host");
|
|
11426
11815
|
const base = `http://${host2}`;
|
|
@@ -11434,8 +11823,8 @@ async function handleExpoSwiftRequest(req, res) {
|
|
|
11434
11823
|
continue;
|
|
11435
11824
|
}
|
|
11436
11825
|
try {
|
|
11437
|
-
const packagePath =
|
|
11438
|
-
|
|
11826
|
+
const packagePath = import_node_path19.default.join(
|
|
11827
|
+
import_node_os8.default.tmpdir(),
|
|
11439
11828
|
"peach-expo-swift",
|
|
11440
11829
|
key,
|
|
11441
11830
|
unit.namespace
|
|
@@ -11444,7 +11833,7 @@ async function handleExpoSwiftRequest(req, res) {
|
|
|
11444
11833
|
packagePath,
|
|
11445
11834
|
new Map(
|
|
11446
11835
|
Object.entries(unit.files).map(([name2, source]) => [
|
|
11447
|
-
|
|
11836
|
+
import_node_path19.default.join(packagePath, name2),
|
|
11448
11837
|
source
|
|
11449
11838
|
])
|
|
11450
11839
|
)
|
|
@@ -11495,8 +11884,8 @@ async function handleExpoSwiftRequest(req, res) {
|
|
|
11495
11884
|
import PackageDescription
|
|
11496
11885
|
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")])
|
|
11497
11886
|
`;
|
|
11498
|
-
const packagePath =
|
|
11499
|
-
|
|
11887
|
+
const packagePath = import_node_path19.default.join(
|
|
11888
|
+
import_node_os8.default.tmpdir(),
|
|
11500
11889
|
"peach-expo-swift",
|
|
11501
11890
|
key,
|
|
11502
11891
|
"linked-app"
|
|
@@ -11505,7 +11894,7 @@ let package = Package(name: "PeachExpo", targets: [${targets.map((name2) => `.ta
|
|
|
11505
11894
|
packagePath,
|
|
11506
11895
|
new Map(
|
|
11507
11896
|
Object.entries(files).map(([name2, source]) => [
|
|
11508
|
-
|
|
11897
|
+
import_node_path19.default.join(packagePath, name2),
|
|
11509
11898
|
source
|
|
11510
11899
|
])
|
|
11511
11900
|
)
|
|
@@ -11615,10 +12004,10 @@ function resolveRuntimeRootForHostname(hostname) {
|
|
|
11615
12004
|
}
|
|
11616
12005
|
function sendFileWithRanges(req, res, filePath, total, headers) {
|
|
11617
12006
|
const head = (req?.method || "GET").toUpperCase() === "HEAD";
|
|
11618
|
-
const
|
|
11619
|
-
const invalid =
|
|
11620
|
-
if (
|
|
11621
|
-
const [, startRaw, endRaw] =
|
|
12007
|
+
const range2 = /^bytes=(\d*)-(\d*)$/.exec(req?.headers?.range || "");
|
|
12008
|
+
const invalid = range2 && range2[1] && range2[2] && Number(range2[2]) < Number(range2[1]);
|
|
12009
|
+
if (range2 && (range2[1] || range2[2]) && !invalid) {
|
|
12010
|
+
const [, startRaw, endRaw] = range2;
|
|
11622
12011
|
const start = startRaw ? Number(startRaw) : Math.max(0, total - Number(endRaw));
|
|
11623
12012
|
const end = startRaw && endRaw ? Math.min(Number(endRaw), total - 1) : total - 1;
|
|
11624
12013
|
if (start > end || start >= total) {
|
|
@@ -11678,20 +12067,20 @@ var RNX_RUNTIME_PRODUCT = {
|
|
|
11678
12067
|
var rnxRuntime = createRuntimeDelivery(RNX_RUNTIME_PRODUCT);
|
|
11679
12068
|
|
|
11680
12069
|
// src/host/agent-host.ts
|
|
12070
|
+
var import_node_crypto11 = require("node:crypto");
|
|
12071
|
+
var import_node_fs22 = __toESM(require("node:fs"), 1);
|
|
12072
|
+
var import_node_path23 = __toESM(require("node:path"), 1);
|
|
12073
|
+
|
|
12074
|
+
// src/agent-sessions.ts
|
|
12075
|
+
var import_node_child_process9 = require("node:child_process");
|
|
11681
12076
|
var import_node_crypto10 = require("node:crypto");
|
|
11682
12077
|
var import_node_fs21 = __toESM(require("node:fs"), 1);
|
|
11683
12078
|
var import_node_path22 = __toESM(require("node:path"), 1);
|
|
11684
|
-
|
|
11685
|
-
// src/agent-sessions.ts
|
|
11686
|
-
var import_node_child_process10 = require("node:child_process");
|
|
11687
|
-
var import_node_crypto9 = require("node:crypto");
|
|
11688
|
-
var import_node_fs20 = __toESM(require("node:fs"), 1);
|
|
11689
|
-
var import_node_path21 = __toESM(require("node:path"), 1);
|
|
11690
12079
|
var import_node_readline = __toESM(require("node:readline"), 1);
|
|
11691
12080
|
|
|
11692
12081
|
// cli/self-invocation.ts
|
|
11693
|
-
var
|
|
11694
|
-
var
|
|
12082
|
+
var import_node_fs19 = require("node:fs");
|
|
12083
|
+
var import_node_path20 = require("node:path");
|
|
11695
12084
|
var import_node_url3 = require("node:url");
|
|
11696
12085
|
init_public_brand();
|
|
11697
12086
|
|
|
@@ -11701,14 +12090,14 @@ var IS_STANDALONE = typeof __SOOTSIM_STANDALONE__ !== "undefined" && __SOOTSIM_S
|
|
|
11701
12090
|
// cli/self-invocation.ts
|
|
11702
12091
|
function sourceEntryPath() {
|
|
11703
12092
|
try {
|
|
11704
|
-
const candidate = (0,
|
|
11705
|
-
return (0,
|
|
12093
|
+
const candidate = (0, import_node_path20.join)((0, import_node_path20.dirname)((0, import_node_url3.fileURLToPath)(__sootsim_import_meta_url)), "bin.ts");
|
|
12094
|
+
return (0, import_node_fs19.existsSync)(candidate) ? candidate : null;
|
|
11706
12095
|
} catch {
|
|
11707
12096
|
return null;
|
|
11708
12097
|
}
|
|
11709
12098
|
}
|
|
11710
|
-
function isCliEntry(
|
|
11711
|
-
const name2 = (0,
|
|
12099
|
+
function isCliEntry(path23) {
|
|
12100
|
+
const name2 = (0, import_node_path20.basename)(path23);
|
|
11712
12101
|
return name2 === "bin.ts" || name2 === "bin.js";
|
|
11713
12102
|
}
|
|
11714
12103
|
function rnxSelfInvocation() {
|
|
@@ -11767,9 +12156,9 @@ function encodeAgentPromptEnvelope(input) {
|
|
|
11767
12156
|
}
|
|
11768
12157
|
|
|
11769
12158
|
// src/attached-projects.ts
|
|
11770
|
-
var
|
|
11771
|
-
var
|
|
11772
|
-
var
|
|
12159
|
+
var import_node_crypto9 = require("node:crypto");
|
|
12160
|
+
var import_node_fs20 = __toESM(require("node:fs"), 1);
|
|
12161
|
+
var import_node_path21 = __toESM(require("node:path"), 1);
|
|
11773
12162
|
init_home_paths();
|
|
11774
12163
|
var overrideDir = null;
|
|
11775
12164
|
function userDataDir() {
|
|
@@ -11782,7 +12171,7 @@ function getUserDataDir() {
|
|
|
11782
12171
|
return userDataDir();
|
|
11783
12172
|
}
|
|
11784
12173
|
function storeFile() {
|
|
11785
|
-
return
|
|
12174
|
+
return import_node_path21.default.join(userDataDir(), "attached-projects.json");
|
|
11786
12175
|
}
|
|
11787
12176
|
function cloneEmpty() {
|
|
11788
12177
|
return {
|
|
@@ -11796,7 +12185,7 @@ function loadStore() {
|
|
|
11796
12185
|
const file = storeFile();
|
|
11797
12186
|
let raw2;
|
|
11798
12187
|
try {
|
|
11799
|
-
raw2 =
|
|
12188
|
+
raw2 = import_node_fs20.default.readFileSync(file, "utf8");
|
|
11800
12189
|
} catch (err) {
|
|
11801
12190
|
if (err.code === "ENOENT") return cloneEmpty();
|
|
11802
12191
|
throw err;
|
|
@@ -11813,7 +12202,7 @@ function loadStore() {
|
|
|
11813
12202
|
} catch (err) {
|
|
11814
12203
|
const quarantine = `${file}.corrupt-${Date.now()}`;
|
|
11815
12204
|
try {
|
|
11816
|
-
|
|
12205
|
+
import_node_fs20.default.renameSync(file, quarantine);
|
|
11817
12206
|
console.warn(
|
|
11818
12207
|
`[sootsim] attached-projects.json was unparseable; quarantined to ${quarantine}. original error: ${err.message}`
|
|
11819
12208
|
);
|
|
@@ -11824,16 +12213,16 @@ function loadStore() {
|
|
|
11824
12213
|
}
|
|
11825
12214
|
function writeStore(store) {
|
|
11826
12215
|
const file = storeFile();
|
|
11827
|
-
|
|
12216
|
+
import_node_fs20.default.mkdirSync(import_node_path21.default.dirname(file), { recursive: true });
|
|
11828
12217
|
const tmp = `${file}.tmp-${process.pid}-${Date.now()}`;
|
|
11829
|
-
const fd =
|
|
12218
|
+
const fd = import_node_fs20.default.openSync(tmp, "w", 384);
|
|
11830
12219
|
try {
|
|
11831
|
-
|
|
11832
|
-
|
|
12220
|
+
import_node_fs20.default.writeFileSync(fd, JSON.stringify(store, null, 2));
|
|
12221
|
+
import_node_fs20.default.fsyncSync(fd);
|
|
11833
12222
|
} finally {
|
|
11834
|
-
|
|
12223
|
+
import_node_fs20.default.closeSync(fd);
|
|
11835
12224
|
}
|
|
11836
|
-
|
|
12225
|
+
import_node_fs20.default.renameSync(tmp, file);
|
|
11837
12226
|
}
|
|
11838
12227
|
function mutateStore(fn) {
|
|
11839
12228
|
const store = loadStore();
|
|
@@ -11842,13 +12231,13 @@ function mutateStore(fn) {
|
|
|
11842
12231
|
return store;
|
|
11843
12232
|
}
|
|
11844
12233
|
function projectIdForCwd(cwd) {
|
|
11845
|
-
return (0,
|
|
12234
|
+
return (0, import_node_crypto9.createHash)("sha256").update(import_node_path21.default.resolve(cwd)).digest("hex").slice(0, 16);
|
|
11846
12235
|
}
|
|
11847
12236
|
function newSessionId() {
|
|
11848
|
-
return `s_${(0,
|
|
12237
|
+
return `s_${(0, import_node_crypto9.randomBytes)(10).toString("hex")}`;
|
|
11849
12238
|
}
|
|
11850
12239
|
function upsertProject(input) {
|
|
11851
|
-
const cwd =
|
|
12240
|
+
const cwd = import_node_path21.default.resolve(input.cwd);
|
|
11852
12241
|
const id = projectIdForCwd(cwd);
|
|
11853
12242
|
let result;
|
|
11854
12243
|
mutateStore((store) => {
|
|
@@ -11874,7 +12263,7 @@ function upsertProject(input) {
|
|
|
11874
12263
|
const now = Date.now();
|
|
11875
12264
|
const created = {
|
|
11876
12265
|
id,
|
|
11877
|
-
name: input.name ??
|
|
12266
|
+
name: input.name ?? import_node_path21.default.basename(cwd),
|
|
11878
12267
|
cwd,
|
|
11879
12268
|
repoRoot: input.repoRoot,
|
|
11880
12269
|
sourceRoots: input.sourceRoots ?? [cwd],
|
|
@@ -12020,8 +12409,8 @@ async function seedFromDemoAppRegistry() {
|
|
|
12020
12409
|
if (apps.length === 0) return;
|
|
12021
12410
|
mutateStore((store) => {
|
|
12022
12411
|
for (const app of apps) {
|
|
12023
|
-
if (!
|
|
12024
|
-
const cwd =
|
|
12412
|
+
if (!import_node_fs20.default.existsSync(app.dir)) continue;
|
|
12413
|
+
const cwd = import_node_path21.default.resolve(app.dir);
|
|
12025
12414
|
const id = projectIdForCwd(cwd);
|
|
12026
12415
|
if (store.attachedProjects.some((p) => p.id === id)) continue;
|
|
12027
12416
|
const now = Date.now();
|
|
@@ -12046,16 +12435,16 @@ async function seedFromDemoAppRegistry() {
|
|
|
12046
12435
|
// src/agent-sessions.ts
|
|
12047
12436
|
init_public_brand();
|
|
12048
12437
|
function sessionDir(sessionId) {
|
|
12049
|
-
return
|
|
12438
|
+
return import_node_path22.default.join(getUserDataDir(), "sessions", sessionId);
|
|
12050
12439
|
}
|
|
12051
12440
|
function promptFifoPath(sessionId) {
|
|
12052
|
-
return
|
|
12441
|
+
return import_node_path22.default.join(sessionDir(sessionId), "prompt.in");
|
|
12053
12442
|
}
|
|
12054
12443
|
function eventsFifoPath(sessionId) {
|
|
12055
|
-
return
|
|
12444
|
+
return import_node_path22.default.join(sessionDir(sessionId), "events.out");
|
|
12056
12445
|
}
|
|
12057
12446
|
function transcriptPath(sessionId) {
|
|
12058
|
-
return
|
|
12447
|
+
return import_node_path22.default.join(getUserDataDir(), "transcripts", `${sessionId}.log`);
|
|
12059
12448
|
}
|
|
12060
12449
|
function pidIsAlive(pid, sessionId) {
|
|
12061
12450
|
if (!pid) return false;
|
|
@@ -12065,7 +12454,7 @@ function pidIsAlive(pid, sessionId) {
|
|
|
12065
12454
|
return false;
|
|
12066
12455
|
}
|
|
12067
12456
|
if (sessionId) {
|
|
12068
|
-
if (!
|
|
12457
|
+
if (!import_node_fs21.default.existsSync(sessionDir(sessionId))) return false;
|
|
12069
12458
|
}
|
|
12070
12459
|
return true;
|
|
12071
12460
|
}
|
|
@@ -12078,11 +12467,11 @@ function resolveSootsimInvocation() {
|
|
|
12078
12467
|
const resourcesPath = process.resourcesPath;
|
|
12079
12468
|
if (resourcesPath) {
|
|
12080
12469
|
const candidates = [
|
|
12081
|
-
|
|
12082
|
-
|
|
12470
|
+
import_node_path22.default.join(resourcesPath, "bin", "sootsim"),
|
|
12471
|
+
import_node_path22.default.join(resourcesPath, "bin", `sootsim-${process.platform}-${process.arch}`)
|
|
12083
12472
|
];
|
|
12084
12473
|
for (const c of candidates) {
|
|
12085
|
-
if (
|
|
12474
|
+
if (import_node_fs21.default.existsSync(c)) return { executable: c, prefixArgs: [] };
|
|
12086
12475
|
}
|
|
12087
12476
|
}
|
|
12088
12477
|
}
|
|
@@ -12101,15 +12490,15 @@ function tryWorkspaceSootsim() {
|
|
|
12101
12490
|
const sootsimDir = resolveSootsimPackageDir();
|
|
12102
12491
|
if (!sootsimDir) return null;
|
|
12103
12492
|
const binaryName = `peach-${process.platform === "win32" ? "windows" : process.platform}-${process.arch}${process.platform === "win32" ? ".exe" : ""}`;
|
|
12104
|
-
const distBinary =
|
|
12105
|
-
if (
|
|
12106
|
-
const distBin =
|
|
12107
|
-
if (
|
|
12493
|
+
const distBinary = import_node_path22.default.join(sootsimDir, "dist-bin", binaryName);
|
|
12494
|
+
if (import_node_fs21.default.existsSync(distBinary)) return { executable: distBinary, prefixArgs: [] };
|
|
12495
|
+
const distBin = import_node_path22.default.join(sootsimDir, "dist-cli", "bin.js");
|
|
12496
|
+
if (import_node_fs21.default.existsSync(distBin)) {
|
|
12108
12497
|
try {
|
|
12109
|
-
const src =
|
|
12110
|
-
if (
|
|
12111
|
-
const srcMtime =
|
|
12112
|
-
const buildMtime =
|
|
12498
|
+
const src = import_node_path22.default.join(sootsimDir, "cli", "commands", "agent-wrapper.ts");
|
|
12499
|
+
if (import_node_fs21.default.existsSync(src)) {
|
|
12500
|
+
const srcMtime = import_node_fs21.default.statSync(src).mtimeMs;
|
|
12501
|
+
const buildMtime = import_node_fs21.default.statSync(distBin).mtimeMs;
|
|
12113
12502
|
if (buildMtime < srcMtime) {
|
|
12114
12503
|
console.warn(
|
|
12115
12504
|
`[peach] dist-cli/bin.js is older than agent-wrapper.ts \u2014 rebuild with \`bun run --cwd packages/peachsim build:cli\`.`
|
|
@@ -12128,22 +12517,22 @@ function tryWorkspaceSootsim() {
|
|
|
12128
12517
|
function resolveSootsimPackageDir() {
|
|
12129
12518
|
try {
|
|
12130
12519
|
const resolved = require.resolve(`${rnxPublicBrand.packageName}/package.json`);
|
|
12131
|
-
return
|
|
12520
|
+
return import_node_path22.default.dirname(resolved);
|
|
12132
12521
|
} catch {
|
|
12133
12522
|
}
|
|
12134
12523
|
const here = fileFromImportMeta();
|
|
12135
12524
|
if (!here) return null;
|
|
12136
|
-
let cur =
|
|
12525
|
+
let cur = import_node_path22.default.dirname(here);
|
|
12137
12526
|
for (let i = 0; i < 8; i++) {
|
|
12138
|
-
const pkg =
|
|
12527
|
+
const pkg = import_node_path22.default.join(cur, "package.json");
|
|
12139
12528
|
try {
|
|
12140
|
-
if (
|
|
12141
|
-
const parsed = JSON.parse(
|
|
12529
|
+
if (import_node_fs21.default.existsSync(pkg)) {
|
|
12530
|
+
const parsed = JSON.parse(import_node_fs21.default.readFileSync(pkg, "utf8"));
|
|
12142
12531
|
if (parsed.name === rnxPublicBrand.packageName) return cur;
|
|
12143
12532
|
}
|
|
12144
12533
|
} catch {
|
|
12145
12534
|
}
|
|
12146
|
-
const parent =
|
|
12535
|
+
const parent = import_node_path22.default.dirname(cur);
|
|
12147
12536
|
if (parent === cur) break;
|
|
12148
12537
|
cur = parent;
|
|
12149
12538
|
}
|
|
@@ -12159,28 +12548,28 @@ function fileFromImportMeta() {
|
|
|
12159
12548
|
}
|
|
12160
12549
|
}
|
|
12161
12550
|
async function withStartLock(projectId, provider, fn) {
|
|
12162
|
-
const lockDir =
|
|
12163
|
-
|
|
12551
|
+
const lockDir = import_node_path22.default.join(getUserDataDir(), "locks");
|
|
12552
|
+
import_node_fs21.default.mkdirSync(lockDir, { recursive: true });
|
|
12164
12553
|
try {
|
|
12165
|
-
|
|
12554
|
+
import_node_fs21.default.chmodSync(lockDir, 448);
|
|
12166
12555
|
} catch {
|
|
12167
12556
|
}
|
|
12168
|
-
const lockPath =
|
|
12557
|
+
const lockPath = import_node_path22.default.join(lockDir, `start-${projectId}-${provider}.lock`);
|
|
12169
12558
|
const deadline = Date.now() + 4e3;
|
|
12170
12559
|
let fd = null;
|
|
12171
12560
|
while (fd === null) {
|
|
12172
12561
|
try {
|
|
12173
|
-
fd =
|
|
12562
|
+
fd = import_node_fs21.default.openSync(
|
|
12174
12563
|
lockPath,
|
|
12175
|
-
|
|
12564
|
+
import_node_fs21.constants.O_WRONLY | import_node_fs21.constants.O_CREAT | import_node_fs21.constants.O_EXCL,
|
|
12176
12565
|
384
|
|
12177
12566
|
);
|
|
12178
12567
|
} catch (err) {
|
|
12179
12568
|
if (err.code !== "EEXIST") throw err;
|
|
12180
12569
|
try {
|
|
12181
|
-
const stale = Number(
|
|
12570
|
+
const stale = Number(import_node_fs21.default.readFileSync(lockPath, "utf8").trim());
|
|
12182
12571
|
if (stale && !isProcessAlive(stale)) {
|
|
12183
|
-
|
|
12572
|
+
import_node_fs21.default.unlinkSync(lockPath);
|
|
12184
12573
|
continue;
|
|
12185
12574
|
}
|
|
12186
12575
|
} catch {
|
|
@@ -12194,15 +12583,15 @@ async function withStartLock(projectId, provider, fn) {
|
|
|
12194
12583
|
}
|
|
12195
12584
|
}
|
|
12196
12585
|
try {
|
|
12197
|
-
|
|
12586
|
+
import_node_fs21.default.writeFileSync(fd, String(process.pid));
|
|
12198
12587
|
return await fn();
|
|
12199
12588
|
} finally {
|
|
12200
12589
|
try {
|
|
12201
|
-
|
|
12590
|
+
import_node_fs21.default.closeSync(fd);
|
|
12202
12591
|
} catch {
|
|
12203
12592
|
}
|
|
12204
12593
|
try {
|
|
12205
|
-
|
|
12594
|
+
import_node_fs21.default.unlinkSync(lockPath);
|
|
12206
12595
|
} catch {
|
|
12207
12596
|
}
|
|
12208
12597
|
}
|
|
@@ -12216,28 +12605,28 @@ function isProcessAlive(pid) {
|
|
|
12216
12605
|
}
|
|
12217
12606
|
}
|
|
12218
12607
|
function mkfifoSync(p) {
|
|
12219
|
-
const parent =
|
|
12220
|
-
|
|
12608
|
+
const parent = import_node_path22.default.dirname(p);
|
|
12609
|
+
import_node_fs21.default.mkdirSync(parent, { recursive: true });
|
|
12221
12610
|
try {
|
|
12222
|
-
|
|
12611
|
+
import_node_fs21.default.chmodSync(parent, 448);
|
|
12223
12612
|
} catch {
|
|
12224
12613
|
}
|
|
12225
|
-
if (
|
|
12614
|
+
if (import_node_fs21.default.existsSync(p)) {
|
|
12226
12615
|
try {
|
|
12227
|
-
const stat2 =
|
|
12616
|
+
const stat2 = import_node_fs21.default.statSync(p);
|
|
12228
12617
|
if (stat2.isFIFO()) {
|
|
12229
12618
|
try {
|
|
12230
|
-
|
|
12619
|
+
import_node_fs21.default.chmodSync(p, 384);
|
|
12231
12620
|
} catch {
|
|
12232
12621
|
}
|
|
12233
12622
|
return;
|
|
12234
12623
|
}
|
|
12235
|
-
|
|
12624
|
+
import_node_fs21.default.unlinkSync(p);
|
|
12236
12625
|
} catch {
|
|
12237
|
-
|
|
12626
|
+
import_node_fs21.default.unlinkSync(p);
|
|
12238
12627
|
}
|
|
12239
12628
|
}
|
|
12240
|
-
const result = (0,
|
|
12629
|
+
const result = (0, import_node_child_process9.spawnSync)("mkfifo", ["-m", "600", p]);
|
|
12241
12630
|
if (result.status !== 0) {
|
|
12242
12631
|
throw new Error(
|
|
12243
12632
|
`mkfifo(${p}) failed: ${result.stderr?.toString().trim() || "unknown error"}`
|
|
@@ -12267,7 +12656,7 @@ async function startSession(opts) {
|
|
|
12267
12656
|
`session already running for project=${project.id} provider=${provider} (session ${existingLive.id}, pid ${existingLive.wrapperPid}). end it first with \`peach agent end <sessionId>\`.`
|
|
12268
12657
|
);
|
|
12269
12658
|
}
|
|
12270
|
-
const claudeSessionUuid = provider === "claude" ? (0,
|
|
12659
|
+
const claudeSessionUuid = provider === "claude" ? (0, import_node_crypto10.randomUUID)() : void 0;
|
|
12271
12660
|
const session = upsertSession({
|
|
12272
12661
|
projectId: project.id,
|
|
12273
12662
|
provider,
|
|
@@ -12281,10 +12670,10 @@ async function startSession(opts) {
|
|
|
12281
12670
|
const transcript = transcriptPath(session.id);
|
|
12282
12671
|
mkfifoSync(promptIn);
|
|
12283
12672
|
mkfifoSync(eventsOut);
|
|
12284
|
-
const transcriptDir =
|
|
12285
|
-
|
|
12673
|
+
const transcriptDir = import_node_path22.default.dirname(transcript);
|
|
12674
|
+
import_node_fs21.default.mkdirSync(transcriptDir, { recursive: true });
|
|
12286
12675
|
try {
|
|
12287
|
-
|
|
12676
|
+
import_node_fs21.default.chmodSync(transcriptDir, 448);
|
|
12288
12677
|
} catch {
|
|
12289
12678
|
}
|
|
12290
12679
|
const { executable, prefixArgs } = resolveSootsimInvocation();
|
|
@@ -12312,7 +12701,7 @@ async function startSession(opts) {
|
|
|
12312
12701
|
if (claudeSessionUuid) {
|
|
12313
12702
|
wrapperArgs.push("--claude-session-uuid", claudeSessionUuid);
|
|
12314
12703
|
}
|
|
12315
|
-
const child = (0,
|
|
12704
|
+
const child = (0, import_node_child_process9.spawn)(executable, wrapperArgs, {
|
|
12316
12705
|
detached: true,
|
|
12317
12706
|
stdio: "ignore",
|
|
12318
12707
|
env: {
|
|
@@ -12335,7 +12724,7 @@ async function startSession(opts) {
|
|
|
12335
12724
|
}
|
|
12336
12725
|
}
|
|
12337
12726
|
try {
|
|
12338
|
-
|
|
12727
|
+
import_node_fs21.default.rmSync(sessionDir(session.id), { recursive: true, force: true });
|
|
12339
12728
|
} catch {
|
|
12340
12729
|
}
|
|
12341
12730
|
updateSessionStatus(session.id, { status: "ended" });
|
|
@@ -12363,18 +12752,18 @@ async function sendPrompt(sessionId, prompt) {
|
|
|
12363
12752
|
);
|
|
12364
12753
|
}
|
|
12365
12754
|
const fifo = promptFifoPath(sessionId);
|
|
12366
|
-
if (!
|
|
12755
|
+
if (!import_node_fs21.default.existsSync(fifo)) {
|
|
12367
12756
|
throw new AgentSessionError("NO_FIFO", `prompt FIFO missing: ${fifo}`);
|
|
12368
12757
|
}
|
|
12369
|
-
const fd =
|
|
12758
|
+
const fd = import_node_fs21.default.openSync(fifo, import_node_fs21.constants.O_WRONLY);
|
|
12370
12759
|
try {
|
|
12371
12760
|
const wireText = encodeAgentPromptEnvelope(prompt);
|
|
12372
12761
|
if (!wireText) {
|
|
12373
12762
|
throw new AgentSessionError("EMPTY_PROMPT", "prompt text is empty");
|
|
12374
12763
|
}
|
|
12375
|
-
|
|
12764
|
+
import_node_fs21.default.writeSync(fd, wireText + "\n");
|
|
12376
12765
|
} finally {
|
|
12377
|
-
|
|
12766
|
+
import_node_fs21.default.closeSync(fd);
|
|
12378
12767
|
}
|
|
12379
12768
|
updateSessionStatus(sessionId, {
|
|
12380
12769
|
lastPrompt: prompt.displayText ?? prompt.text,
|
|
@@ -12396,7 +12785,7 @@ async function endSession(sessionId) {
|
|
|
12396
12785
|
const base = getUserDataDir();
|
|
12397
12786
|
if (dir.startsWith(base)) {
|
|
12398
12787
|
try {
|
|
12399
|
-
|
|
12788
|
+
import_node_fs21.default.rmSync(dir, { recursive: true, force: true });
|
|
12400
12789
|
} catch {
|
|
12401
12790
|
}
|
|
12402
12791
|
}
|
|
@@ -12404,11 +12793,11 @@ async function endSession(sessionId) {
|
|
|
12404
12793
|
}
|
|
12405
12794
|
function subscribeEvents(sessionId, onEvent) {
|
|
12406
12795
|
const fifo = eventsFifoPath(sessionId);
|
|
12407
|
-
if (!
|
|
12796
|
+
if (!import_node_fs21.default.existsSync(fifo)) {
|
|
12408
12797
|
throw new AgentSessionError("NO_FIFO", `events FIFO missing: ${fifo}`);
|
|
12409
12798
|
}
|
|
12410
|
-
const fd =
|
|
12411
|
-
const stream =
|
|
12799
|
+
const fd = import_node_fs21.default.openSync(fifo, import_node_fs21.constants.O_RDWR);
|
|
12800
|
+
const stream = import_node_fs21.default.createReadStream("", { fd, autoClose: true });
|
|
12412
12801
|
const rl = import_node_readline.default.createInterface({ input: stream, crlfDelay: Infinity });
|
|
12413
12802
|
rl.on("line", (line) => {
|
|
12414
12803
|
const event = parseAgentEventLine(line);
|
|
@@ -12419,7 +12808,7 @@ function subscribeEvents(sessionId, onEvent) {
|
|
|
12419
12808
|
if (closed) return;
|
|
12420
12809
|
closed = true;
|
|
12421
12810
|
try {
|
|
12422
|
-
|
|
12811
|
+
import_node_fs21.default.writeSync(fd, "\n");
|
|
12423
12812
|
} catch {
|
|
12424
12813
|
}
|
|
12425
12814
|
try {
|
|
@@ -12433,7 +12822,7 @@ function subscribeEvents(sessionId, onEvent) {
|
|
|
12433
12822
|
};
|
|
12434
12823
|
}
|
|
12435
12824
|
async function waitForFirstEvent(fifo, predicate, timeoutMs) {
|
|
12436
|
-
const fd =
|
|
12825
|
+
const fd = import_node_fs21.default.openSync(fifo, import_node_fs21.constants.O_RDWR | import_node_fs21.constants.O_NONBLOCK);
|
|
12437
12826
|
const buf = Buffer.alloc(8192);
|
|
12438
12827
|
let leftover = "";
|
|
12439
12828
|
const deadline = Date.now() + timeoutMs;
|
|
@@ -12441,7 +12830,7 @@ async function waitForFirstEvent(fifo, predicate, timeoutMs) {
|
|
|
12441
12830
|
while (Date.now() < deadline) {
|
|
12442
12831
|
let n = 0;
|
|
12443
12832
|
try {
|
|
12444
|
-
n =
|
|
12833
|
+
n = import_node_fs21.default.readSync(fd, buf, 0, buf.length, null);
|
|
12445
12834
|
} catch (err) {
|
|
12446
12835
|
if (err.code !== "EAGAIN") throw err;
|
|
12447
12836
|
n = 0;
|
|
@@ -12461,7 +12850,7 @@ async function waitForFirstEvent(fifo, predicate, timeoutMs) {
|
|
|
12461
12850
|
}
|
|
12462
12851
|
return null;
|
|
12463
12852
|
} finally {
|
|
12464
|
-
|
|
12853
|
+
import_node_fs21.default.closeSync(fd);
|
|
12465
12854
|
}
|
|
12466
12855
|
}
|
|
12467
12856
|
|
|
@@ -12669,7 +13058,7 @@ var AgentHost = class {
|
|
|
12669
13058
|
throw new AgentSessionError("EMPTY_PROMPT", "inspect message cannot be empty");
|
|
12670
13059
|
}
|
|
12671
13060
|
const message = {
|
|
12672
|
-
id: `inspect-${(0,
|
|
13061
|
+
id: `inspect-${(0, import_node_crypto11.randomUUID)()}`,
|
|
12673
13062
|
simId,
|
|
12674
13063
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
12675
13064
|
prompt
|
|
@@ -12715,7 +13104,7 @@ var AgentHost = class {
|
|
|
12715
13104
|
);
|
|
12716
13105
|
const project = upsertProject({
|
|
12717
13106
|
cwd: match.cwd,
|
|
12718
|
-
name: match.projectName ??
|
|
13107
|
+
name: match.projectName ?? import_node_path23.default.basename(match.cwd),
|
|
12719
13108
|
preferredProvider: input.provider ?? existing?.preferredProvider,
|
|
12720
13109
|
sourceRoots: existing?.sourceRoots ?? [match.cwd],
|
|
12721
13110
|
knownBundleUrls,
|
|
@@ -12726,18 +13115,18 @@ var AgentHost = class {
|
|
|
12726
13115
|
}
|
|
12727
13116
|
getTranscript(sessionId) {
|
|
12728
13117
|
const p = transcriptPath(sessionId);
|
|
12729
|
-
if (!
|
|
13118
|
+
if (!import_node_fs22.default.existsSync(p)) {
|
|
12730
13119
|
return { error: "transcript not found", code: "NO_TRANSCRIPT" };
|
|
12731
13120
|
}
|
|
12732
|
-
return
|
|
13121
|
+
return import_node_fs22.default.readFileSync(p, "utf8");
|
|
12733
13122
|
}
|
|
12734
13123
|
getPaths() {
|
|
12735
13124
|
const dir = getUserDataDir();
|
|
12736
13125
|
return {
|
|
12737
13126
|
userDataDir: dir,
|
|
12738
|
-
storeFile:
|
|
12739
|
-
sessionsDir:
|
|
12740
|
-
transcriptsDir:
|
|
13127
|
+
storeFile: import_node_path23.default.join(dir, "attached-projects.json"),
|
|
13128
|
+
sessionsDir: import_node_path23.default.join(dir, "sessions"),
|
|
13129
|
+
transcriptsDir: import_node_path23.default.join(dir, "transcripts")
|
|
12741
13130
|
};
|
|
12742
13131
|
}
|
|
12743
13132
|
// --- subscription management ---
|
|
@@ -13438,7 +13827,7 @@ function handleAppApiRequest(req, res) {
|
|
|
13438
13827
|
}
|
|
13439
13828
|
|
|
13440
13829
|
// src/host/fetch-proxy-transport.ts
|
|
13441
|
-
var
|
|
13830
|
+
var import_node_crypto12 = require("node:crypto");
|
|
13442
13831
|
var import_node_http22 = require("node:http2");
|
|
13443
13832
|
var import_x509 = require("@peculiar/x509");
|
|
13444
13833
|
async function startFetchProxyTransport() {
|
|
@@ -13446,7 +13835,7 @@ async function startFetchProxyTransport() {
|
|
|
13446
13835
|
const keys = await crypto.subtle.generateKey(algorithm, true, ["sign", "verify"]);
|
|
13447
13836
|
const certificate = await import_x509.X509CertificateGenerator.createSelfSigned(
|
|
13448
13837
|
{
|
|
13449
|
-
serialNumber: (0,
|
|
13838
|
+
serialNumber: (0, import_node_crypto12.randomBytes)(16).toString("hex"),
|
|
13450
13839
|
name: "CN=localhost",
|
|
13451
13840
|
notBefore: new Date(Date.now() - 6e4),
|
|
13452
13841
|
notAfter: new Date(Date.now() + 365 * 24 * 60 * 6e4),
|
|
@@ -13459,7 +13848,7 @@ async function startFetchProxyTransport() {
|
|
|
13459
13848
|
crypto
|
|
13460
13849
|
);
|
|
13461
13850
|
const privateKey = Buffer.from(await crypto.subtle.exportKey("pkcs8", keys.privateKey));
|
|
13462
|
-
const spki = (0,
|
|
13851
|
+
const spki = (0, import_node_crypto12.createHash)("sha256").update(Buffer.from(await crypto.subtle.exportKey("spki", keys.publicKey))).digest("base64");
|
|
13463
13852
|
const sessions = /* @__PURE__ */ new Set();
|
|
13464
13853
|
const server = (0, import_node_http22.createSecureServer)(
|
|
13465
13854
|
{
|
|
@@ -13581,8 +13970,8 @@ async function openUrl(url, options = {}) {
|
|
|
13581
13970
|
}
|
|
13582
13971
|
|
|
13583
13972
|
// src/host/plane-host.ts
|
|
13584
|
-
var
|
|
13585
|
-
var
|
|
13973
|
+
var import_node_fs24 = __toESM(require("node:fs"), 1);
|
|
13974
|
+
var import_node_path25 = __toESM(require("node:path"), 1);
|
|
13586
13975
|
|
|
13587
13976
|
// ../peach-box/src/planeProtocol.ts
|
|
13588
13977
|
var PLANE_FLAG_READ_ONLY = 1;
|
|
@@ -13661,9 +14050,9 @@ async function dispatchPlaneCommand(plane, type, msg, mutationOptions) {
|
|
|
13661
14050
|
}
|
|
13662
14051
|
|
|
13663
14052
|
// cli/commands/box/checkout-plane.ts
|
|
13664
|
-
var
|
|
13665
|
-
var
|
|
13666
|
-
var
|
|
14053
|
+
var import_node_child_process10 = require("node:child_process");
|
|
14054
|
+
var import_node_fs23 = __toESM(require("node:fs"), 1);
|
|
14055
|
+
var import_node_path24 = __toESM(require("node:path"), 1);
|
|
13667
14056
|
var CheckoutRequiresGitError = class extends Error {
|
|
13668
14057
|
};
|
|
13669
14058
|
var BINARY_SNIFF_BYTES = 8192;
|
|
@@ -13674,14 +14063,14 @@ function looksBinary(filePath, size) {
|
|
|
13674
14063
|
if (size === 0) return false;
|
|
13675
14064
|
let fd;
|
|
13676
14065
|
try {
|
|
13677
|
-
fd =
|
|
14066
|
+
fd = import_node_fs23.default.openSync(filePath, "r");
|
|
13678
14067
|
const buffer = Buffer.alloc(Math.min(BINARY_SNIFF_BYTES, size));
|
|
13679
|
-
const read =
|
|
14068
|
+
const read = import_node_fs23.default.readSync(fd, buffer, 0, buffer.length, 0);
|
|
13680
14069
|
return buffer.subarray(0, read).includes(0);
|
|
13681
14070
|
} catch {
|
|
13682
14071
|
return false;
|
|
13683
14072
|
} finally {
|
|
13684
|
-
if (fd !== void 0)
|
|
14073
|
+
if (fd !== void 0) import_node_fs23.default.closeSync(fd);
|
|
13685
14074
|
}
|
|
13686
14075
|
}
|
|
13687
14076
|
var CheckoutFilePlane = class {
|
|
@@ -13694,7 +14083,7 @@ var CheckoutFilePlane = class {
|
|
|
13694
14083
|
listTimeoutMs;
|
|
13695
14084
|
trackedOnly;
|
|
13696
14085
|
constructor(root, options = {}) {
|
|
13697
|
-
this.root =
|
|
14086
|
+
this.root = import_node_path24.default.resolve(root);
|
|
13698
14087
|
this.listTimeoutMs = options.listTimeoutMs ?? LIST_FILES_TIMEOUT_MS;
|
|
13699
14088
|
this.trackedOnly = options.trackedOnly ?? false;
|
|
13700
14089
|
}
|
|
@@ -13703,7 +14092,7 @@ var CheckoutFilePlane = class {
|
|
|
13703
14092
|
}
|
|
13704
14093
|
listFiles() {
|
|
13705
14094
|
const args = this.trackedOnly ? ["ls-files", "-z"] : ["ls-files", "-co", "--exclude-standard", "-z"];
|
|
13706
|
-
const stdout = (0,
|
|
14095
|
+
const stdout = (0, import_node_child_process10.execFileSync)("git", args, {
|
|
13707
14096
|
cwd: this.root,
|
|
13708
14097
|
encoding: "utf8",
|
|
13709
14098
|
maxBuffer: 64 * 1024 * 1024,
|
|
@@ -13756,13 +14145,13 @@ var CheckoutFilePlane = class {
|
|
|
13756
14145
|
if (!relative2) continue;
|
|
13757
14146
|
let stat2;
|
|
13758
14147
|
try {
|
|
13759
|
-
stat2 =
|
|
14148
|
+
stat2 = import_node_fs23.default.statSync(import_node_path24.default.join(this.root, relative2));
|
|
13760
14149
|
} catch {
|
|
13761
14150
|
continue;
|
|
13762
14151
|
}
|
|
13763
14152
|
if (!stat2.isFile()) continue;
|
|
13764
14153
|
const seen = this.sniffed.get(relative2);
|
|
13765
|
-
const binary = seen && seen.size === stat2.size && seen.mtimeMs === stat2.mtimeMs ? seen.binary : looksBinary(
|
|
14154
|
+
const binary = seen && seen.size === stat2.size && seen.mtimeMs === stat2.mtimeMs ? seen.binary : looksBinary(import_node_path24.default.join(this.root, relative2), stat2.size);
|
|
13766
14155
|
nextSniffed.set(relative2, { size: stat2.size, mtimeMs: stat2.mtimeMs, binary });
|
|
13767
14156
|
next.set(relative2, {
|
|
13768
14157
|
size: stat2.size,
|
|
@@ -13776,22 +14165,22 @@ var CheckoutFilePlane = class {
|
|
|
13776
14165
|
this.sniffed = nextSniffed;
|
|
13777
14166
|
}
|
|
13778
14167
|
absolute(planePath) {
|
|
13779
|
-
const resolved =
|
|
13780
|
-
if (resolved !== this.root && !resolved.startsWith(`${this.root}${
|
|
14168
|
+
const resolved = import_node_path24.default.resolve(this.root, planePath);
|
|
14169
|
+
if (resolved !== this.root && !resolved.startsWith(`${this.root}${import_node_path24.default.sep}`)) {
|
|
13781
14170
|
throw new Error(`path escapes the project: ${planePath}`);
|
|
13782
14171
|
}
|
|
13783
14172
|
return resolved;
|
|
13784
14173
|
}
|
|
13785
14174
|
async read(planePath) {
|
|
13786
|
-
return
|
|
14175
|
+
return import_node_fs23.default.promises.readFile(this.absolute(planePath), "utf8");
|
|
13787
14176
|
}
|
|
13788
14177
|
async readBytes(planePath) {
|
|
13789
|
-
return
|
|
14178
|
+
return import_node_fs23.default.promises.readFile(this.absolute(planePath));
|
|
13790
14179
|
}
|
|
13791
14180
|
async write(planePath, content) {
|
|
13792
14181
|
const absolute = this.absolute(planePath);
|
|
13793
|
-
await
|
|
13794
|
-
await
|
|
14182
|
+
await import_node_fs23.default.promises.mkdir(import_node_path24.default.dirname(absolute), { recursive: true });
|
|
14183
|
+
await import_node_fs23.default.promises.writeFile(absolute, content);
|
|
13795
14184
|
this.entries.set(planePath, {
|
|
13796
14185
|
size: content.byteLength,
|
|
13797
14186
|
readOnly: false,
|
|
@@ -13800,7 +14189,7 @@ var CheckoutFilePlane = class {
|
|
|
13800
14189
|
});
|
|
13801
14190
|
}
|
|
13802
14191
|
async delete(planePath) {
|
|
13803
|
-
await
|
|
14192
|
+
await import_node_fs23.default.promises.rm(this.absolute(planePath), { force: true });
|
|
13804
14193
|
this.entries.delete(planePath);
|
|
13805
14194
|
}
|
|
13806
14195
|
};
|
|
@@ -13926,14 +14315,14 @@ var PlaneHost = class {
|
|
|
13926
14315
|
// root and an opened one cannot disagree about the same directory.
|
|
13927
14316
|
realRoot(root) {
|
|
13928
14317
|
if (!root) throw new Error("root is required");
|
|
13929
|
-
const resolved =
|
|
14318
|
+
const resolved = import_node_path25.default.resolve(root);
|
|
13930
14319
|
let real;
|
|
13931
14320
|
try {
|
|
13932
|
-
real =
|
|
14321
|
+
real = import_node_fs24.default.realpathSync(resolved);
|
|
13933
14322
|
} catch {
|
|
13934
14323
|
throw new Error(`no such directory: ${resolved}`);
|
|
13935
14324
|
}
|
|
13936
|
-
if (!
|
|
14325
|
+
if (!import_node_fs24.default.statSync(real).isDirectory()) throw new Error(`not a directory: ${real}`);
|
|
13937
14326
|
return real;
|
|
13938
14327
|
}
|
|
13939
14328
|
respond(ws, id, result) {
|
|
@@ -13953,9 +14342,9 @@ var PlaneHost = class {
|
|
|
13953
14342
|
};
|
|
13954
14343
|
|
|
13955
14344
|
// src/host/replacement-module-handler.ts
|
|
13956
|
-
var
|
|
14345
|
+
var import_node_fs25 = require("node:fs");
|
|
13957
14346
|
var import_promises5 = __toESM(require("node:fs/promises"), 1);
|
|
13958
|
-
var
|
|
14347
|
+
var import_node_path26 = __toESM(require("node:path"), 1);
|
|
13959
14348
|
|
|
13960
14349
|
// ../contrast-bundler/src/replacementModule.ts
|
|
13961
14350
|
var import_dist = require("sucrase/dist/index.js");
|
|
@@ -14283,16 +14672,16 @@ function sendJavaScript(req, res, source) {
|
|
|
14283
14672
|
res.end(req.method === "HEAD" ? void 0 : source);
|
|
14284
14673
|
}
|
|
14285
14674
|
function resolveReplacementModuleFile(fromFile, specifier) {
|
|
14286
|
-
const base =
|
|
14675
|
+
const base = import_node_path26.default.resolve(import_node_path26.default.dirname(fromFile), specifier);
|
|
14287
14676
|
const candidates = [
|
|
14288
14677
|
...REPLACEMENT_MODULE_EXTENSIONS.some(
|
|
14289
|
-
(ext) => ext ===
|
|
14678
|
+
(ext) => ext === import_node_path26.default.extname(base).toLowerCase()
|
|
14290
14679
|
) ? [base] : [],
|
|
14291
14680
|
...REPLACEMENT_MODULE_EXTENSIONS.map((ext) => base + ext),
|
|
14292
|
-
...REPLACEMENT_MODULE_EXTENSIONS.map((ext) =>
|
|
14681
|
+
...REPLACEMENT_MODULE_EXTENSIONS.map((ext) => import_node_path26.default.join(base, `index${ext}`))
|
|
14293
14682
|
];
|
|
14294
14683
|
const found = candidates.find(
|
|
14295
|
-
(candidate) => (0,
|
|
14684
|
+
(candidate) => (0, import_node_fs25.statSync)(candidate, { throwIfNoEntry: false })?.isFile()
|
|
14296
14685
|
);
|
|
14297
14686
|
if (!found) {
|
|
14298
14687
|
throw new Error(
|
|
@@ -14347,13 +14736,13 @@ async function handleReplacementModuleRequest(req, res, options = {}) {
|
|
|
14347
14736
|
res.end("missing path param");
|
|
14348
14737
|
return true;
|
|
14349
14738
|
}
|
|
14350
|
-
const extension =
|
|
14739
|
+
const extension = import_node_path26.default.extname(targetPath).toLowerCase();
|
|
14351
14740
|
if (!REPLACEMENT_MODULE_EXTENSIONS.some((allowed) => allowed === extension)) {
|
|
14352
14741
|
res.writeHead(400, { "Content-Type": "text/plain; charset=utf-8" });
|
|
14353
14742
|
res.end(`replacement files must be ${REPLACEMENT_MODULE_EXTENSIONS.join(", ")}`);
|
|
14354
14743
|
return true;
|
|
14355
14744
|
}
|
|
14356
|
-
if (!
|
|
14745
|
+
if (!import_node_path26.default.isAbsolute(targetPath)) {
|
|
14357
14746
|
res.writeHead(400, { "Content-Type": "text/plain; charset=utf-8" });
|
|
14358
14747
|
res.end("replacement file path must be absolute");
|
|
14359
14748
|
return true;
|
|
@@ -14361,10 +14750,10 @@ async function handleReplacementModuleRequest(req, res, options = {}) {
|
|
|
14361
14750
|
const runtimePackages = new Set(url.searchParams.getAll("runtimePackage"));
|
|
14362
14751
|
let resolvedProjectRoot;
|
|
14363
14752
|
if (options.projectRoot) {
|
|
14364
|
-
const lexicalProjectRoot =
|
|
14753
|
+
const lexicalProjectRoot = import_node_path26.default.resolve(options.projectRoot);
|
|
14365
14754
|
resolvedProjectRoot = await import_promises5.default.realpath(options.projectRoot);
|
|
14366
|
-
const lexicalTarget =
|
|
14367
|
-
if (lexicalTarget.startsWith("..") ||
|
|
14755
|
+
const lexicalTarget = import_node_path26.default.relative(lexicalProjectRoot, targetPath);
|
|
14756
|
+
if (lexicalTarget.startsWith("..") || import_node_path26.default.isAbsolute(lexicalTarget)) {
|
|
14368
14757
|
res.writeHead(403, { "Content-Type": "text/plain; charset=utf-8" });
|
|
14369
14758
|
res.end("replacement file must be inside the project root");
|
|
14370
14759
|
return true;
|
|
@@ -14380,8 +14769,8 @@ async function handleReplacementModuleRequest(req, res, options = {}) {
|
|
|
14380
14769
|
return true;
|
|
14381
14770
|
}
|
|
14382
14771
|
if (resolvedProjectRoot) {
|
|
14383
|
-
const relativeTarget =
|
|
14384
|
-
if (relativeTarget.startsWith("..") ||
|
|
14772
|
+
const relativeTarget = import_node_path26.default.relative(resolvedProjectRoot, resolvedTargetPath);
|
|
14773
|
+
if (relativeTarget.startsWith("..") || import_node_path26.default.isAbsolute(relativeTarget)) {
|
|
14385
14774
|
res.writeHead(403, { "Content-Type": "text/plain; charset=utf-8" });
|
|
14386
14775
|
res.end("replacement file must be inside the project root");
|
|
14387
14776
|
return true;
|