peachsim 0.1.769 → 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/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 +548 -436
- 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 +817 -698
- 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 +381 -269
- package/dist-lib/vite.cjs +1 -1
- package/package.json +1 -1
- package/src/swift-binary-modules.ts +116 -0
- package/src/swift-host.ts +28 -4
- 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 = (() => {
|
|
@@ -6345,11 +6345,11 @@ function getCliVersion() {
|
|
|
6345
6345
|
|
|
6346
6346
|
// src/expo-swift-host.ts
|
|
6347
6347
|
var import_node_child_process8 = require("node:child_process");
|
|
6348
|
-
var
|
|
6349
|
-
var
|
|
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,10 +8604,10 @@ function swiftModuleToolchain(root) {
|
|
|
8604
8604
|
}
|
|
8605
8605
|
|
|
8606
8606
|
// src/swift-host.ts
|
|
8607
|
-
var
|
|
8608
|
-
var
|
|
8609
|
-
var
|
|
8610
|
-
var
|
|
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);
|
|
8611
8611
|
|
|
8612
8612
|
// ../sootsim-swift/src/bundleAssets.ts
|
|
8613
8613
|
var import_svgpath = __toESM(require("svgpath"), 1);
|
|
@@ -8641,8 +8641,8 @@ function pickImagesetFile(images) {
|
|
|
8641
8641
|
scale: pick.scale === "2x" ? 2 : pick.scale === "3x" ? 3 : 1
|
|
8642
8642
|
};
|
|
8643
8643
|
}
|
|
8644
|
-
function flatScale(
|
|
8645
|
-
const match = /@([23])x\.[^./]+$/.exec(
|
|
8644
|
+
function flatScale(path23) {
|
|
8645
|
+
const match = /@([23])x\.[^./]+$/.exec(path23);
|
|
8646
8646
|
return match ? Number(match[1]) : 1;
|
|
8647
8647
|
}
|
|
8648
8648
|
function providesNamespace(text2) {
|
|
@@ -8669,13 +8669,13 @@ function catalogEntryName(contentsPath, kind, readText) {
|
|
|
8669
8669
|
}
|
|
8670
8670
|
return segments.join("/");
|
|
8671
8671
|
}
|
|
8672
|
-
function isFlatResourceImage(
|
|
8673
|
-
return
|
|
8672
|
+
function isFlatResourceImage(path23) {
|
|
8673
|
+
return path23.split("/").includes("Resources") && RASTER_EXTENSIONS.has(extOf(path23));
|
|
8674
8674
|
}
|
|
8675
8675
|
function enumerateBundleImages(paths, readText) {
|
|
8676
8676
|
const table = [];
|
|
8677
8677
|
const seen = /* @__PURE__ */ new Set();
|
|
8678
|
-
const catalogs = paths.filter((
|
|
8678
|
+
const catalogs = paths.filter((path23) => baseOf(path23) === "Contents.json");
|
|
8679
8679
|
for (const contentsPath of catalogs) {
|
|
8680
8680
|
const name2 = catalogEntryName(contentsPath, ".imageset", readText);
|
|
8681
8681
|
if (name2 === null || seen.has(name2)) continue;
|
|
@@ -8696,12 +8696,12 @@ function enumerateBundleImages(paths, readText) {
|
|
|
8696
8696
|
seen.add(name2);
|
|
8697
8697
|
table.push({ name: name2, file: `${dir}/${pick.filename}`, scale: pick.scale });
|
|
8698
8698
|
}
|
|
8699
|
-
for (const
|
|
8700
|
-
if (!isFlatResourceImage(
|
|
8701
|
-
const name2 = baseOf(
|
|
8699
|
+
for (const path23 of paths) {
|
|
8700
|
+
if (!isFlatResourceImage(path23)) continue;
|
|
8701
|
+
const name2 = baseOf(path23).slice(0, -extOf(path23).length);
|
|
8702
8702
|
if (name2 === "" || seen.has(name2)) continue;
|
|
8703
8703
|
seen.add(name2);
|
|
8704
|
-
table.push({ name: name2, file:
|
|
8704
|
+
table.push({ name: name2, file: path23, scale: flatScale(path23) });
|
|
8705
8705
|
}
|
|
8706
8706
|
return table;
|
|
8707
8707
|
}
|
|
@@ -8730,7 +8730,7 @@ function colorsetValue(color) {
|
|
|
8730
8730
|
}
|
|
8731
8731
|
function enumerateBundleColors(paths, readText) {
|
|
8732
8732
|
const table = {};
|
|
8733
|
-
for (const contentsPath of paths.filter((
|
|
8733
|
+
for (const contentsPath of paths.filter((path23) => baseOf(path23) === "Contents.json")) {
|
|
8734
8734
|
const name2 = catalogEntryName(contentsPath, ".colorset", readText);
|
|
8735
8735
|
if (name2 === null || name2 in table) continue;
|
|
8736
8736
|
let colors;
|
|
@@ -8795,8 +8795,8 @@ function axisExtremes(points) {
|
|
|
8795
8795
|
function pathBounds(d) {
|
|
8796
8796
|
const xs = [];
|
|
8797
8797
|
const ys = [];
|
|
8798
|
-
for (const
|
|
8799
|
-
(0, import_svgpath.default)(
|
|
8798
|
+
for (const path23 of d)
|
|
8799
|
+
(0, import_svgpath.default)(path23).abs().unshort().unarc().iterate((segment, _index, x, y) => {
|
|
8800
8800
|
const [command, ...args] = segment;
|
|
8801
8801
|
if (command === "M" || command === "L") {
|
|
8802
8802
|
xs.push(Number(args[0]));
|
|
@@ -8823,7 +8823,7 @@ function guide(svg, id, axis) {
|
|
|
8823
8823
|
}
|
|
8824
8824
|
function enumerateBundleSymbols(paths, readText) {
|
|
8825
8825
|
const table = {};
|
|
8826
|
-
for (const contentsPath of paths.filter((
|
|
8826
|
+
for (const contentsPath of paths.filter((path23) => baseOf(path23) === "Contents.json")) {
|
|
8827
8827
|
const name2 = catalogEntryName(contentsPath, ".symbolset", readText);
|
|
8828
8828
|
if (name2 === null || name2 in table) continue;
|
|
8829
8829
|
let symbols;
|
|
@@ -8856,8 +8856,8 @@ function enumerateBundleSymbols(paths, readText) {
|
|
|
8856
8856
|
viewBox: "0 0 24 24",
|
|
8857
8857
|
advance,
|
|
8858
8858
|
box: [12 - advance / 2, 12 - tall / 2, advance, tall],
|
|
8859
|
-
layers: d.map((
|
|
8860
|
-
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()
|
|
8861
8861
|
}))
|
|
8862
8862
|
};
|
|
8863
8863
|
}
|
|
@@ -8867,7 +8867,7 @@ function enumerateBundleJson(paths) {
|
|
|
8867
8867
|
const found = [];
|
|
8868
8868
|
const seen = /* @__PURE__ */ new Set();
|
|
8869
8869
|
const ordered = [...paths].filter(
|
|
8870
|
-
(
|
|
8870
|
+
(path23) => path23.split("/").includes("Resources") && path23.split("/").every((segment) => segment !== "" && segment !== "..") && (extOf(path23) === ".json" || extOf(path23) === ".xcstrings")
|
|
8871
8871
|
).sort((a, b) => {
|
|
8872
8872
|
const aDepth = a.split("/").length;
|
|
8873
8873
|
const bDepth = b.split("/").length;
|
|
@@ -9177,17 +9177,101 @@ var ios_sdk_frameworks_default = {
|
|
|
9177
9177
|
]
|
|
9178
9178
|
};
|
|
9179
9179
|
|
|
9180
|
+
// src/swift-binary-modules.ts
|
|
9181
|
+
var import_node_crypto5 = require("node:crypto");
|
|
9182
|
+
var import_node_fs13 = __toESM(require("node:fs"), 1);
|
|
9183
|
+
var import_node_os5 = __toESM(require("node:os"), 1);
|
|
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
|
+
|
|
9180
9264
|
// src/swift-packages.ts
|
|
9181
9265
|
var import_node_child_process7 = require("node:child_process");
|
|
9182
|
-
var
|
|
9183
|
-
var
|
|
9266
|
+
var import_node_fs15 = __toESM(require("node:fs"), 1);
|
|
9267
|
+
var import_node_path15 = __toESM(require("node:path"), 1);
|
|
9184
9268
|
|
|
9185
9269
|
// src/swift-package-manifest.ts
|
|
9186
9270
|
var import_node_child_process6 = require("node:child_process");
|
|
9187
|
-
var
|
|
9188
|
-
var
|
|
9189
|
-
var
|
|
9190
|
-
var
|
|
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);
|
|
9191
9275
|
var TARGET_TYPES = [
|
|
9192
9276
|
"regular",
|
|
9193
9277
|
"executable",
|
|
@@ -9202,19 +9286,19 @@ var record = (value) => value && typeof value === "object" && !Array.isArray(val
|
|
|
9202
9286
|
var array = (value) => Array.isArray(value) ? value : [];
|
|
9203
9287
|
var string = (value) => typeof value === "string" ? value : void 0;
|
|
9204
9288
|
function swiftCommand() {
|
|
9205
|
-
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: [] };
|
|
9206
9290
|
}
|
|
9207
|
-
var
|
|
9291
|
+
var cacheDir3 = import_node_path14.default.join(import_node_os6.default.tmpdir(), "peach-swift-manifests");
|
|
9208
9292
|
var evaluated = /* @__PURE__ */ new Map();
|
|
9209
9293
|
function dump(dir) {
|
|
9210
|
-
const manifests =
|
|
9294
|
+
const manifests = import_node_fs14.default.readdirSync(dir).filter((name2) => /^Package(@swift-[\d.]+)?\.swift$/.test(name2)).sort();
|
|
9211
9295
|
const command = swiftCommand();
|
|
9212
|
-
const key = (0,
|
|
9213
|
-
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")
|
|
9214
9298
|
).digest("hex").slice(0, 32);
|
|
9215
|
-
const cached3 =
|
|
9216
|
-
if (
|
|
9217
|
-
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"))) };
|
|
9218
9302
|
let output;
|
|
9219
9303
|
try {
|
|
9220
9304
|
output = (0, import_node_child_process6.execFileSync)(
|
|
@@ -9226,7 +9310,7 @@ function dump(dir) {
|
|
|
9226
9310
|
dir,
|
|
9227
9311
|
// swiftpm's scratch files never land in the app's own package
|
|
9228
9312
|
"--scratch-path",
|
|
9229
|
-
|
|
9313
|
+
import_node_path14.default.join(cacheDir3, `${key}.build`),
|
|
9230
9314
|
"dump-package"
|
|
9231
9315
|
],
|
|
9232
9316
|
{
|
|
@@ -9238,11 +9322,11 @@ function dump(dir) {
|
|
|
9238
9322
|
} catch (error) {
|
|
9239
9323
|
const stderr = error instanceof Error && "stderr" in error ? String(error.stderr).trim() : "";
|
|
9240
9324
|
throw new Error(
|
|
9241
|
-
`swiftpm could not evaluate ${
|
|
9325
|
+
`swiftpm could not evaluate ${import_node_path14.default.join(dir, "Package.swift")}${stderr ? `: ${stderr}` : ""}`
|
|
9242
9326
|
);
|
|
9243
9327
|
}
|
|
9244
|
-
|
|
9245
|
-
|
|
9328
|
+
import_node_fs14.default.mkdirSync(cacheDir3, { recursive: true });
|
|
9329
|
+
import_node_fs14.default.writeFileSync(cached3, output);
|
|
9246
9330
|
return { key, raw: record(JSON.parse(output)) };
|
|
9247
9331
|
}
|
|
9248
9332
|
function defaultTraits(manifest) {
|
|
@@ -9270,7 +9354,7 @@ function linksOnIOS(condition, traits) {
|
|
|
9270
9354
|
return gates.length === 0 || gates.some((name2) => traits.has(string(name2) ?? ""));
|
|
9271
9355
|
}
|
|
9272
9356
|
function swiftPackageManifest(dir) {
|
|
9273
|
-
dir =
|
|
9357
|
+
dir = import_node_fs14.default.realpathSync(dir);
|
|
9274
9358
|
const { key, raw: raw2 } = dump(dir);
|
|
9275
9359
|
const known = evaluated.get(key);
|
|
9276
9360
|
if (known) return known;
|
|
@@ -9318,7 +9402,7 @@ function swiftPackageManifest(dir) {
|
|
|
9318
9402
|
if (!name2 || !isTargetType(kind)) continue;
|
|
9319
9403
|
const declared = string(target.path);
|
|
9320
9404
|
const roots = kind === "test" ? ["Tests"] : ["Sources", "Source", "src", "srcs"];
|
|
9321
|
-
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);
|
|
9322
9406
|
const dependencies = [];
|
|
9323
9407
|
for (const dependency of array(target.dependencies)) {
|
|
9324
9408
|
const { target: local, product, byName } = record(dependency);
|
|
@@ -9360,30 +9444,31 @@ function swiftPackageManifest(dir) {
|
|
|
9360
9444
|
dependencies,
|
|
9361
9445
|
languageMode,
|
|
9362
9446
|
mainActorIsolation,
|
|
9363
|
-
declaresResources: array(target.resources).length > 0
|
|
9447
|
+
declaresResources: array(target.resources).length > 0,
|
|
9448
|
+
url: string(target.url) ?? null
|
|
9364
9449
|
});
|
|
9365
9450
|
}
|
|
9366
9451
|
const manifest = { dir, products, targets, packages };
|
|
9367
9452
|
evaluated.set(key, manifest);
|
|
9368
9453
|
return manifest;
|
|
9369
9454
|
}
|
|
9370
|
-
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}`));
|
|
9371
9456
|
function walk(dir) {
|
|
9372
|
-
if (!
|
|
9373
|
-
if (
|
|
9457
|
+
if (!import_node_fs14.default.existsSync(dir)) return [];
|
|
9458
|
+
if (import_node_fs14.default.statSync(dir).isFile()) return [dir];
|
|
9374
9459
|
const out = [];
|
|
9375
|
-
for (const entry of
|
|
9460
|
+
for (const entry of import_node_fs14.default.readdirSync(dir, { withFileTypes: true })) {
|
|
9376
9461
|
if (entry.name.startsWith(".")) continue;
|
|
9377
|
-
const full =
|
|
9462
|
+
const full = import_node_path14.default.join(dir, entry.name);
|
|
9378
9463
|
if (entry.isDirectory()) out.push(...walk(full));
|
|
9379
9464
|
else if (entry.isFile()) out.push(full);
|
|
9380
9465
|
}
|
|
9381
9466
|
return out;
|
|
9382
9467
|
}
|
|
9383
9468
|
function swiftTargetFiles(manifest, target) {
|
|
9384
|
-
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];
|
|
9385
9470
|
const excluded = [
|
|
9386
|
-
...target.exclude.map((file) =>
|
|
9471
|
+
...target.exclude.map((file) => import_node_path14.default.resolve(target.dir, file)),
|
|
9387
9472
|
...[...manifest.targets.values()].flatMap(
|
|
9388
9473
|
(other) => other !== target && within(other.dir, [target.dir]) && other.dir !== target.dir ? [other.dir] : []
|
|
9389
9474
|
)
|
|
@@ -9392,10 +9477,12 @@ function swiftTargetFiles(manifest, target) {
|
|
|
9392
9477
|
}
|
|
9393
9478
|
|
|
9394
9479
|
// src/swift-packages.ts
|
|
9395
|
-
var REMOTE_CHECKOUTS =
|
|
9480
|
+
var REMOTE_CHECKOUTS = import_node_path15.default.join(".build", "peach", "checkouts");
|
|
9396
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;
|
|
9397
9484
|
function readPins(resolved) {
|
|
9398
|
-
const data = JSON.parse(
|
|
9485
|
+
const data = JSON.parse(import_node_fs15.default.readFileSync(resolved, "utf8"));
|
|
9399
9486
|
const pins = data && typeof data === "object" && "pins" in data && Array.isArray(data.pins) ? data.pins : null;
|
|
9400
9487
|
if (!pins)
|
|
9401
9488
|
throw new Error(`${resolved} has no pins; resolve packages in a current Xcode`);
|
|
@@ -9411,23 +9498,23 @@ function readPins(resolved) {
|
|
|
9411
9498
|
}
|
|
9412
9499
|
var verified2 = /* @__PURE__ */ new Set();
|
|
9413
9500
|
function checkout(checkouts, identity, pin) {
|
|
9414
|
-
const dir =
|
|
9501
|
+
const dir = import_node_path15.default.join(checkouts, identity);
|
|
9415
9502
|
const key = `${dir}\0${pin.revision}`;
|
|
9416
9503
|
if (verified2.has(key)) return dir;
|
|
9417
9504
|
const git = (...args) => (0, import_node_child_process7.execFileSync)("git", ["-C", dir, ...args], {
|
|
9418
9505
|
encoding: "utf8",
|
|
9419
9506
|
stdio: ["ignore", "pipe", "pipe"]
|
|
9420
9507
|
}).trim();
|
|
9421
|
-
const current =
|
|
9508
|
+
const current = import_node_fs15.default.existsSync(import_node_path15.default.join(dir, ".git")) ? git("rev-parse", "HEAD") : "";
|
|
9422
9509
|
if (current !== pin.revision) {
|
|
9423
|
-
|
|
9424
|
-
|
|
9510
|
+
import_node_fs15.default.rmSync(dir, { recursive: true, force: true });
|
|
9511
|
+
import_node_fs15.default.mkdirSync(dir, { recursive: true });
|
|
9425
9512
|
try {
|
|
9426
9513
|
git("init", "-q");
|
|
9427
9514
|
git("fetch", "-q", "--depth", "1", pin.location, pin.revision);
|
|
9428
9515
|
git("checkout", "-q", "FETCH_HEAD");
|
|
9429
9516
|
} catch (error) {
|
|
9430
|
-
|
|
9517
|
+
import_node_fs15.default.rmSync(dir, { recursive: true, force: true });
|
|
9431
9518
|
const stderr = error instanceof Error && "stderr" in error ? String(error.stderr).trim() : "";
|
|
9432
9519
|
throw new Error(
|
|
9433
9520
|
`could not fetch ${pin.location} at ${pin.revision}${stderr ? `: ${stderr}` : ""}`
|
|
@@ -9443,13 +9530,14 @@ function resolveSwiftPackages(options) {
|
|
|
9443
9530
|
const result = {
|
|
9444
9531
|
targets: [],
|
|
9445
9532
|
unavailable: /* @__PURE__ */ new Map(),
|
|
9446
|
-
modules: /* @__PURE__ */ new Map()
|
|
9533
|
+
modules: /* @__PURE__ */ new Map(),
|
|
9534
|
+
binaries: []
|
|
9447
9535
|
};
|
|
9448
9536
|
const pins = resolved ? readPins(resolved) : null;
|
|
9449
|
-
const checkouts =
|
|
9537
|
+
const checkouts = import_node_path15.default.join(rootDir, REMOTE_CHECKOUTS);
|
|
9450
9538
|
const packages = /* @__PURE__ */ new Map();
|
|
9451
9539
|
const load2 = (source) => {
|
|
9452
|
-
const key = source.kind === "local" ?
|
|
9540
|
+
const key = source.kind === "local" ? import_node_path15.default.resolve(source.dir) : source.url;
|
|
9453
9541
|
const cached3 = packages.get(key);
|
|
9454
9542
|
if (cached3 !== void 0) return cached3;
|
|
9455
9543
|
let loaded2;
|
|
@@ -9461,8 +9549,8 @@ function resolveSwiftPackages(options) {
|
|
|
9461
9549
|
if (!pin) {
|
|
9462
9550
|
loaded2 = pins ? `package ${identity} is not pinned in Package.resolved` : "no Package.resolved pins it; resolve packages in Xcode once";
|
|
9463
9551
|
} else {
|
|
9464
|
-
|
|
9465
|
-
|
|
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");
|
|
9466
9554
|
loaded2 = {
|
|
9467
9555
|
source: source.url,
|
|
9468
9556
|
remote: true,
|
|
@@ -9482,8 +9570,8 @@ function resolveSwiftPackages(options) {
|
|
|
9482
9570
|
const outcome = (() => {
|
|
9483
9571
|
if (provided.has(name2)) return null;
|
|
9484
9572
|
const target = pkg.manifest.targets.get(name2);
|
|
9485
|
-
if (!target) return `${
|
|
9486
|
-
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}`;
|
|
9487
9575
|
if (target.type === "system") return `${name2} is a system C library`;
|
|
9488
9576
|
if (target.type !== "regular") return `${name2} is a ${target.type} target`;
|
|
9489
9577
|
const files = swiftTargetFiles(pkg.manifest, target);
|
|
@@ -9494,9 +9582,9 @@ function resolveSwiftPackages(options) {
|
|
|
9494
9582
|
const nested = resolveDependencyProduct(pkg, dependency.package, dependency.name);
|
|
9495
9583
|
return nested && `${dependency.name}: ${nested}`;
|
|
9496
9584
|
});
|
|
9497
|
-
const blocked = reasons
|
|
9585
|
+
const blocked = blocker(reasons);
|
|
9498
9586
|
if (blocked) return blocked;
|
|
9499
|
-
const relative2 = files.map((file) =>
|
|
9587
|
+
const relative2 = files.map((file) => import_node_path15.default.relative(target.dir, file));
|
|
9500
9588
|
targets.set(`${pkg.manifest.dir}\0${name2}`, {
|
|
9501
9589
|
name: name2,
|
|
9502
9590
|
path: "",
|
|
@@ -9518,7 +9606,7 @@ function resolveSwiftPackages(options) {
|
|
|
9518
9606
|
const resolveProduct = (pkg, product) => {
|
|
9519
9607
|
if (provided.has(product)) return null;
|
|
9520
9608
|
const roots = pkg.manifest.products.get(product);
|
|
9521
|
-
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)));
|
|
9522
9610
|
productOutcomes.set(`${pkg.manifest.dir}\0${product}`, { pkg, reason });
|
|
9523
9611
|
return reason;
|
|
9524
9612
|
};
|
|
@@ -9526,7 +9614,7 @@ function resolveSwiftPackages(options) {
|
|
|
9526
9614
|
if (provided.has(product)) return null;
|
|
9527
9615
|
const dependency = pkg.manifest.packages.get(packageName);
|
|
9528
9616
|
if (!dependency)
|
|
9529
|
-
return `${
|
|
9617
|
+
return `${import_node_path15.default.basename(pkg.manifest.dir)} names no package ${packageName}`;
|
|
9530
9618
|
if ("dir" in dependency) {
|
|
9531
9619
|
const loaded3 = load2({ kind: "local", dir: dependency.dir });
|
|
9532
9620
|
return typeof loaded3 === "string" ? loaded3 : resolveProduct(loaded3, product);
|
|
@@ -9553,6 +9641,13 @@ function resolveSwiftPackages(options) {
|
|
|
9553
9641
|
if (target.type === "test" || target.type === "plugin" || target.type === "macro")
|
|
9554
9642
|
continue;
|
|
9555
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
|
+
});
|
|
9556
9651
|
const reason = resolveTarget(pkg, name2);
|
|
9557
9652
|
if (reason && !result.modules.has(name2))
|
|
9558
9653
|
result.modules.set(name2, { source: pkg.source, reason });
|
|
@@ -9572,7 +9667,7 @@ function resolveSwiftPackages(options) {
|
|
|
9572
9667
|
if (dependency.kind === "target") reach(pkg, dependency.name);
|
|
9573
9668
|
else {
|
|
9574
9669
|
const source = pkg.manifest.packages.get(dependency.package);
|
|
9575
|
-
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));
|
|
9576
9671
|
if (nested && typeof nested !== "string")
|
|
9577
9672
|
for (const root of nested.manifest.products.get(dependency.name) ?? [])
|
|
9578
9673
|
reach(nested, root);
|
|
@@ -9580,7 +9675,7 @@ function resolveSwiftPackages(options) {
|
|
|
9580
9675
|
}
|
|
9581
9676
|
};
|
|
9582
9677
|
for (const { product, source } of products) {
|
|
9583
|
-
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);
|
|
9584
9679
|
if (!pkg || typeof pkg === "string") continue;
|
|
9585
9680
|
for (const root of pkg.manifest.products.get(product) ?? []) reach(pkg, root);
|
|
9586
9681
|
}
|
|
@@ -9715,12 +9810,12 @@ async function compileSwiftProject(submit, work, origin, signal) {
|
|
|
9715
9810
|
}
|
|
9716
9811
|
|
|
9717
9812
|
// src/xcode-project.ts
|
|
9718
|
-
var
|
|
9719
|
-
var
|
|
9813
|
+
var import_node_fs16 = __toESM(require("node:fs"), 1);
|
|
9814
|
+
var import_node_path17 = __toESM(require("node:path"), 1);
|
|
9720
9815
|
var import_plist3 = __toESM(require_plist(), 1);
|
|
9721
9816
|
|
|
9722
9817
|
// src/xcode-json-project.ts
|
|
9723
|
-
var
|
|
9818
|
+
var import_node_path16 = __toESM(require("node:path"), 1);
|
|
9724
9819
|
var import_json5 = __toESM(require("json5"), 1);
|
|
9725
9820
|
var isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9726
9821
|
var text = (value) => typeof value === "string" ? value : void 0;
|
|
@@ -9736,7 +9831,7 @@ var PHASE_ISA = {
|
|
|
9736
9831
|
function readXcodeJsonProject(xcodeproj, source) {
|
|
9737
9832
|
const json = import_json5.default.parse(source);
|
|
9738
9833
|
if (!isJsonObject(json)) throw new Error(`${xcodeproj}/project.xcproj is not an object`);
|
|
9739
|
-
const projectDir =
|
|
9834
|
+
const projectDir = import_node_path16.default.dirname(xcodeproj);
|
|
9740
9835
|
const objects = {};
|
|
9741
9836
|
let next = 0;
|
|
9742
9837
|
const add = (entry, id) => {
|
|
@@ -9749,7 +9844,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
9749
9844
|
const base = /^<([A-Z]+)>\/(.*)$/.exec(raw2);
|
|
9750
9845
|
if (base) {
|
|
9751
9846
|
if (base[1] === "PROJECT")
|
|
9752
|
-
return { sourceTree: "<absolute>", path:
|
|
9847
|
+
return { sourceTree: "<absolute>", path: import_node_path16.default.join(projectDir, base[2]) };
|
|
9753
9848
|
if (base[1] === "PRODUCTS")
|
|
9754
9849
|
return { sourceTree: "BUILT_PRODUCTS_DIR", path: base[2] };
|
|
9755
9850
|
return null;
|
|
@@ -9757,7 +9852,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
9757
9852
|
const unescaped = raw2.replaceAll("\\<", "<");
|
|
9758
9853
|
if (unescaped.startsWith("/")) return { sourceTree: "<absolute>", path: unescaped };
|
|
9759
9854
|
if (unescaped.startsWith("~")) return null;
|
|
9760
|
-
return groupDir === null ? null : { sourceTree: "<absolute>", path:
|
|
9855
|
+
return groupDir === null ? null : { sourceTree: "<absolute>", path: import_node_path16.default.join(groupDir, unescaped) };
|
|
9761
9856
|
};
|
|
9762
9857
|
const memberships = [];
|
|
9763
9858
|
const folders = [];
|
|
@@ -9768,7 +9863,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
9768
9863
|
const kind = text(entry.kind) ?? "file-reference";
|
|
9769
9864
|
const raw2 = text(entry.path) ?? "";
|
|
9770
9865
|
const located = raw2 === "" ? null : locate(raw2, parent.dir);
|
|
9771
|
-
const name2 = text(entry.name) ??
|
|
9866
|
+
const name2 = text(entry.name) ?? import_node_path16.default.basename(raw2);
|
|
9772
9867
|
const node = { id: "", name: name2, dir: null, parent, children: [] };
|
|
9773
9868
|
if (kind === "group" || kind === "variant-group" || kind === "version-group") {
|
|
9774
9869
|
node.dir = raw2 === "" ? parent.dir : located?.sourceTree === "<absolute>" ? located.path : null;
|
|
@@ -9883,7 +9978,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
9883
9978
|
if (!isObject(entry)) continue;
|
|
9884
9979
|
const repository = text(entry.repository);
|
|
9885
9980
|
const local = text(entry.path);
|
|
9886
|
-
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$/, "");
|
|
9887
9982
|
const id = text(entry.kind) === "local" && local !== void 0 ? add({ isa: "XCLocalSwiftPackageReference", relativePath: local }) : add({ isa: "XCRemoteSwiftPackageReference", repositoryURL: repository ?? "" });
|
|
9888
9983
|
packageIds.set(name2.toLowerCase(), id);
|
|
9889
9984
|
}
|
|
@@ -10160,28 +10255,28 @@ var CONDITIONS = {
|
|
|
10160
10255
|
variant: "normal"
|
|
10161
10256
|
};
|
|
10162
10257
|
function walkFiles(dir) {
|
|
10163
|
-
if (!
|
|
10258
|
+
if (!import_node_fs16.default.existsSync(dir)) return [];
|
|
10164
10259
|
const out = [];
|
|
10165
|
-
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))) {
|
|
10166
10261
|
if (entry.name.startsWith(".")) continue;
|
|
10167
|
-
const full =
|
|
10262
|
+
const full = import_node_path17.default.join(dir, entry.name);
|
|
10168
10263
|
if (entry.isDirectory()) out.push(...walkFiles(full));
|
|
10169
10264
|
else if (entry.isFile()) out.push(full);
|
|
10170
10265
|
}
|
|
10171
10266
|
return out;
|
|
10172
10267
|
}
|
|
10173
|
-
var isDirectory = (dir) =>
|
|
10268
|
+
var isDirectory = (dir) => import_node_fs16.default.existsSync(dir) && import_node_fs16.default.statSync(dir).isDirectory();
|
|
10174
10269
|
function readXcconfig(file, seen = /* @__PURE__ */ new Set()) {
|
|
10175
|
-
if (seen.has(file) || !
|
|
10270
|
+
if (seen.has(file) || !import_node_fs16.default.existsSync(file)) return {};
|
|
10176
10271
|
seen.add(file);
|
|
10177
10272
|
const settings = {};
|
|
10178
|
-
for (const raw2 of
|
|
10273
|
+
for (const raw2 of import_node_fs16.default.readFileSync(file, "utf8").split("\n")) {
|
|
10179
10274
|
const line = raw2.replace(/\/\/.*$/, "").trim();
|
|
10180
10275
|
const include = /^#include\??\s+"([^"]+)"/.exec(line);
|
|
10181
10276
|
if (include) {
|
|
10182
10277
|
Object.assign(
|
|
10183
10278
|
settings,
|
|
10184
|
-
readXcconfig(
|
|
10279
|
+
readXcconfig(import_node_path17.default.resolve(import_node_path17.default.dirname(file), include[1]), seen)
|
|
10185
10280
|
);
|
|
10186
10281
|
continue;
|
|
10187
10282
|
}
|
|
@@ -10231,22 +10326,22 @@ function decodeXml(text2) {
|
|
|
10231
10326
|
return text2.replaceAll(""", '"').replaceAll("'", "'").replaceAll("<", "<").replaceAll(">", ">").replaceAll("&", "&");
|
|
10232
10327
|
}
|
|
10233
10328
|
function workspaceReferences(workspace) {
|
|
10234
|
-
const data =
|
|
10235
|
-
if (!
|
|
10329
|
+
const data = import_node_path17.default.join(workspace, "contents.xcworkspacedata");
|
|
10330
|
+
if (!import_node_fs16.default.existsSync(data))
|
|
10236
10331
|
throw new Error(`${workspace} has no contents.xcworkspacedata`);
|
|
10237
|
-
const container =
|
|
10332
|
+
const container = import_node_path17.default.dirname(workspace);
|
|
10238
10333
|
const locate = (location2, base) => {
|
|
10239
10334
|
const colon = location2.indexOf(":");
|
|
10240
10335
|
const kind = location2.slice(0, colon);
|
|
10241
10336
|
const rest = location2.slice(colon + 1);
|
|
10242
|
-
if (kind === "group") return
|
|
10243
|
-
if (kind === "container" || kind === "self") return
|
|
10244
|
-
if (kind === "absolute") return
|
|
10245
|
-
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}`);
|
|
10246
10341
|
};
|
|
10247
10342
|
const groups = [container];
|
|
10248
10343
|
const references = [];
|
|
10249
|
-
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)) {
|
|
10250
10345
|
if (closing) {
|
|
10251
10346
|
if (tag === "Group") groups.pop();
|
|
10252
10347
|
continue;
|
|
@@ -10262,8 +10357,8 @@ function workspaceReferences(workspace) {
|
|
|
10262
10357
|
var loaded = /* @__PURE__ */ new Map();
|
|
10263
10358
|
function xcodeProjectFile(xcodeproj) {
|
|
10264
10359
|
for (const name2 of ["project.pbxproj", "project.xcproj"]) {
|
|
10265
|
-
const file =
|
|
10266
|
-
if (
|
|
10360
|
+
const file = import_node_path17.default.join(xcodeproj, name2);
|
|
10361
|
+
if (import_node_fs16.default.existsSync(file)) return file;
|
|
10267
10362
|
}
|
|
10268
10363
|
return null;
|
|
10269
10364
|
}
|
|
@@ -10271,10 +10366,10 @@ function loadProject(xcodeproj) {
|
|
|
10271
10366
|
const projectFile = xcodeProjectFile(xcodeproj);
|
|
10272
10367
|
if (!projectFile)
|
|
10273
10368
|
throw new Error(`${xcodeproj} has no project.pbxproj or project.xcproj`);
|
|
10274
|
-
const mtimeMs =
|
|
10369
|
+
const mtimeMs = import_node_fs16.default.statSync(projectFile).mtimeMs;
|
|
10275
10370
|
const cached3 = loaded.get(projectFile);
|
|
10276
10371
|
if (cached3?.mtimeMs === mtimeMs) return cached3.project;
|
|
10277
|
-
const source =
|
|
10372
|
+
const source = import_node_fs16.default.readFileSync(projectFile, "utf8");
|
|
10278
10373
|
const root = projectFile.endsWith(".xcproj") ? readXcodeJsonProject(xcodeproj, source) : parseOpenStepPlist(source);
|
|
10279
10374
|
if (!isDict(root) || !isDict(root.objects)) {
|
|
10280
10375
|
throw new Error(`${projectFile} has no objects table`);
|
|
@@ -10288,8 +10383,8 @@ function loadProject(xcodeproj) {
|
|
|
10288
10383
|
if (!project || project.isa !== "PBXProject") {
|
|
10289
10384
|
throw new Error(`${projectFile} has no PBXProject root`);
|
|
10290
10385
|
}
|
|
10291
|
-
const projectDir =
|
|
10292
|
-
|
|
10386
|
+
const projectDir = import_node_fs16.default.realpathSync(
|
|
10387
|
+
import_node_path17.default.resolve(import_node_path17.default.dirname(xcodeproj), str(project.projectDirPath) ?? "")
|
|
10293
10388
|
);
|
|
10294
10389
|
const parent = /* @__PURE__ */ new Map();
|
|
10295
10390
|
for (const [id, entry] of Object.entries(objects)) {
|
|
@@ -10307,11 +10402,11 @@ function loadProject(xcodeproj) {
|
|
|
10307
10402
|
const own = str(entry.path) ?? "";
|
|
10308
10403
|
const tree = str(entry.sourceTree) ?? "<group>";
|
|
10309
10404
|
if (tree === "<absolute>") result2 = own;
|
|
10310
|
-
else if (tree === "SOURCE_ROOT") result2 =
|
|
10405
|
+
else if (tree === "SOURCE_ROOT") result2 = import_node_path17.default.join(projectDir, own);
|
|
10311
10406
|
else if (tree === "<group>") {
|
|
10312
10407
|
const up = parent.get(id);
|
|
10313
10408
|
const base = up ? resolvePath(up) : projectDir;
|
|
10314
|
-
result2 = base === null ? null :
|
|
10409
|
+
result2 = base === null ? null : import_node_path17.default.join(base, own);
|
|
10315
10410
|
}
|
|
10316
10411
|
}
|
|
10317
10412
|
resolvedPaths.set(id, result2);
|
|
@@ -10411,7 +10506,7 @@ function targetMembers(ref) {
|
|
|
10411
10506
|
const addResource = (file) => {
|
|
10412
10507
|
if (isDirectory(file)) {
|
|
10413
10508
|
for (const inner of walkFiles(file)) resources.add(inner);
|
|
10414
|
-
} else if (
|
|
10509
|
+
} else if (import_node_fs16.default.existsSync(file)) resources.add(file);
|
|
10415
10510
|
};
|
|
10416
10511
|
const fileRefPaths = (refId) => {
|
|
10417
10512
|
const entry = project.object(refId);
|
|
@@ -10432,7 +10527,7 @@ function targetMembers(ref) {
|
|
|
10432
10527
|
for (const buildFileId of list(phase.files)) {
|
|
10433
10528
|
for (const file of fileRefPaths(str(project.object(buildFileId)?.fileRef) ?? "")) {
|
|
10434
10529
|
if (phase.isa === "PBXSourcesBuildPhase") {
|
|
10435
|
-
if (!
|
|
10530
|
+
if (!import_node_fs16.default.existsSync(file)) continue;
|
|
10436
10531
|
allSources.add(file);
|
|
10437
10532
|
if (file.endsWith(".swift")) sources.add(file);
|
|
10438
10533
|
} else if (phase.isa === "PBXResourcesBuildPhase") addResource(file);
|
|
@@ -10440,7 +10535,7 @@ function targetMembers(ref) {
|
|
|
10440
10535
|
}
|
|
10441
10536
|
}
|
|
10442
10537
|
const addSynchronized = (folder, relative2) => {
|
|
10443
|
-
const file =
|
|
10538
|
+
const file = import_node_path17.default.join(folder, relative2);
|
|
10444
10539
|
if (NEVER_MEMBER.test(relative2)) return;
|
|
10445
10540
|
if (file.endsWith(".swift")) {
|
|
10446
10541
|
if (!relative2.split("/").some((segment) => BUNDLE_DIR.test(segment))) {
|
|
@@ -10465,7 +10560,7 @@ function targetMembers(ref) {
|
|
|
10465
10560
|
}
|
|
10466
10561
|
if (owned.has(groupId)) {
|
|
10467
10562
|
for (const file of walkFiles(folder)) {
|
|
10468
|
-
const relative2 =
|
|
10563
|
+
const relative2 = import_node_path17.default.relative(folder, file).split(import_node_path17.default.sep).join("/");
|
|
10469
10564
|
if ([...exceptions].some(
|
|
10470
10565
|
(exception) => relative2 === exception || relative2.startsWith(`${exception}/`)
|
|
10471
10566
|
))
|
|
@@ -10474,14 +10569,14 @@ function targetMembers(ref) {
|
|
|
10474
10569
|
}
|
|
10475
10570
|
} else {
|
|
10476
10571
|
for (const relative2 of exceptions) {
|
|
10477
|
-
const file =
|
|
10572
|
+
const file = import_node_path17.default.join(folder, relative2);
|
|
10478
10573
|
if (isDirectory(file)) {
|
|
10479
10574
|
for (const inner of walkFiles(file))
|
|
10480
10575
|
addSynchronized(
|
|
10481
10576
|
folder,
|
|
10482
|
-
|
|
10577
|
+
import_node_path17.default.relative(folder, inner).split(import_node_path17.default.sep).join("/")
|
|
10483
10578
|
);
|
|
10484
|
-
} else if (
|
|
10579
|
+
} else if (import_node_fs16.default.existsSync(file)) addSynchronized(folder, relative2);
|
|
10485
10580
|
}
|
|
10486
10581
|
}
|
|
10487
10582
|
}
|
|
@@ -10494,8 +10589,8 @@ function targetMembers(ref) {
|
|
|
10494
10589
|
function commonAncestor(dirs) {
|
|
10495
10590
|
let common = dirs[0];
|
|
10496
10591
|
for (const dir of dirs) {
|
|
10497
|
-
while (common !==
|
|
10498
|
-
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);
|
|
10499
10594
|
}
|
|
10500
10595
|
return common;
|
|
10501
10596
|
}
|
|
@@ -10504,8 +10599,8 @@ function workspaceProjects(xcodeprojOrWorkspace) {
|
|
|
10504
10599
|
const projects2 = [];
|
|
10505
10600
|
const projectAt = /* @__PURE__ */ new Map();
|
|
10506
10601
|
const addProject = (xcodeproj) => {
|
|
10507
|
-
const key =
|
|
10508
|
-
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;
|
|
10509
10604
|
if (!xcodeProjectFile(key)) return;
|
|
10510
10605
|
const project = loadProject(key);
|
|
10511
10606
|
projectAt.set(key, project);
|
|
@@ -10522,7 +10617,7 @@ function workspaceProjects(xcodeprojOrWorkspace) {
|
|
|
10522
10617
|
for (const reference of listed)
|
|
10523
10618
|
if (reference.endsWith(".xcodeproj")) addProject(reference);
|
|
10524
10619
|
if (projects2.length === 0) {
|
|
10525
|
-
throw new Error(`${
|
|
10620
|
+
throw new Error(`${import_node_path17.default.basename(xcodeprojOrWorkspace)} lists no Xcode project`);
|
|
10526
10621
|
}
|
|
10527
10622
|
return { listed, projects: projects2, projectAt };
|
|
10528
10623
|
}
|
|
@@ -10544,7 +10639,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
10544
10639
|
const allTargets = projects2.flatMap(nativeTargets);
|
|
10545
10640
|
const appTargets = allTargets.filter((ref) => ref.target.productType === APPLICATION);
|
|
10546
10641
|
const appTargetNames = appTargets.map((ref) => str(ref.target.name) ?? ref.id);
|
|
10547
|
-
const container =
|
|
10642
|
+
const container = import_node_path17.default.basename(xcodeprojOrWorkspace);
|
|
10548
10643
|
const named = targetName ? appTargets.filter((ref) => ref.target.name === targetName) : appTargets;
|
|
10549
10644
|
if (named.length !== 1) {
|
|
10550
10645
|
throw new Error(
|
|
@@ -10556,14 +10651,14 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
10556
10651
|
for (const ref of allTargets) {
|
|
10557
10652
|
const product = ref.project.object(str(ref.target.productReference));
|
|
10558
10653
|
const file = str(product?.path);
|
|
10559
|
-
if (file && !byProduct.has(
|
|
10560
|
-
byProduct.set(
|
|
10654
|
+
if (file && !byProduct.has(import_node_path17.default.basename(file)))
|
|
10655
|
+
byProduct.set(import_node_path17.default.basename(file), ref);
|
|
10561
10656
|
}
|
|
10562
10657
|
const proxied = (project, proxyId) => {
|
|
10563
10658
|
const proxy = project.object(proxyId);
|
|
10564
10659
|
if (proxy?.isa !== "PBXContainerItemProxy") return void 0;
|
|
10565
10660
|
const portal = str(proxy.containerPortal);
|
|
10566
|
-
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 ?? "") ?? ""));
|
|
10567
10662
|
const remote = str(proxy.remoteGlobalIDString);
|
|
10568
10663
|
if (!owner || !remote) return void 0;
|
|
10569
10664
|
return nativeTargets(owner).find(
|
|
@@ -10584,7 +10679,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
10584
10679
|
if (phase?.isa !== "PBXFrameworksBuildPhase") continue;
|
|
10585
10680
|
for (const buildFileId of list(phase.files)) {
|
|
10586
10681
|
const file = project.object(str(project.object(buildFileId)?.fileRef));
|
|
10587
|
-
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;
|
|
10588
10683
|
if (resolved) found.push(resolved);
|
|
10589
10684
|
}
|
|
10590
10685
|
}
|
|
@@ -10605,7 +10700,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
10605
10700
|
const name2 = str(ref.target.name) ?? ref.id;
|
|
10606
10701
|
const { get: settings2, keys } = targetSettings(ref, {
|
|
10607
10702
|
TARGET_NAME: name2,
|
|
10608
|
-
PROJECT_NAME:
|
|
10703
|
+
PROJECT_NAME: import_node_path17.default.basename(ref.project.xcodeproj, ".xcodeproj"),
|
|
10609
10704
|
SRCROOT: ref.project.projectDir,
|
|
10610
10705
|
SOURCE_ROOT: ref.project.projectDir,
|
|
10611
10706
|
PROJECT_DIR: ref.project.projectDir,
|
|
@@ -10636,8 +10731,8 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
10636
10731
|
}
|
|
10637
10732
|
return value;
|
|
10638
10733
|
};
|
|
10639
|
-
const infoPlistFile = settings("INFOPLIST_FILE") ?
|
|
10640
|
-
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")) : {};
|
|
10641
10736
|
if (!sourceInfo || typeof sourceInfo !== "object" || Array.isArray(sourceInfo) || sourceInfo instanceof Date || Buffer.isBuffer(sourceInfo)) {
|
|
10642
10737
|
throw new Error(`${module2.name} Info.plist must contain a dictionary`);
|
|
10643
10738
|
}
|
|
@@ -10655,12 +10750,12 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
10655
10750
|
};
|
|
10656
10751
|
}
|
|
10657
10752
|
const localPackageDirs = [
|
|
10658
|
-
...listed.filter((reference) =>
|
|
10753
|
+
...listed.filter((reference) => import_node_fs16.default.existsSync(import_node_path17.default.join(reference, "Package.swift"))),
|
|
10659
10754
|
...projects2.flatMap(
|
|
10660
10755
|
(project) => Object.entries(project.objects).flatMap(([id, entry]) => {
|
|
10661
10756
|
if (!isDict(entry)) return [];
|
|
10662
|
-
const candidate = entry.isa === "XCLocalSwiftPackageReference" ?
|
|
10663
|
-
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] : [];
|
|
10664
10759
|
})
|
|
10665
10760
|
)
|
|
10666
10761
|
];
|
|
@@ -10684,7 +10779,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
10684
10779
|
product,
|
|
10685
10780
|
source: reference?.isa === "XCRemoteSwiftPackageReference" ? { kind: "remote", url: str(reference.repositoryURL) ?? "" } : reference?.isa === "XCLocalSwiftPackageReference" ? {
|
|
10686
10781
|
kind: "local",
|
|
10687
|
-
dir:
|
|
10782
|
+
dir: import_node_path17.default.resolve(
|
|
10688
10783
|
project.projectDir,
|
|
10689
10784
|
str(reference.relativePath) ?? ""
|
|
10690
10785
|
)
|
|
@@ -10706,8 +10801,8 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
10706
10801
|
}
|
|
10707
10802
|
}
|
|
10708
10803
|
}
|
|
10709
|
-
const resolvedFile =
|
|
10710
|
-
workspace ??
|
|
10804
|
+
const resolvedFile = import_node_path17.default.join(
|
|
10805
|
+
workspace ?? import_node_path17.default.join(xcodeprojOrWorkspace, "project.xcworkspace"),
|
|
10711
10806
|
"xcshareddata",
|
|
10712
10807
|
"swiftpm",
|
|
10713
10808
|
"Package.resolved"
|
|
@@ -10717,13 +10812,13 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
10717
10812
|
...module2,
|
|
10718
10813
|
rootDir: commonAncestor(
|
|
10719
10814
|
[
|
|
10720
|
-
workspace ?
|
|
10815
|
+
workspace ? import_node_path17.default.dirname(workspace) : app.project.projectDir,
|
|
10721
10816
|
...used.map((project) => project.projectDir),
|
|
10722
10817
|
...localPackageDirs,
|
|
10723
10818
|
...linkedProducts.flatMap(
|
|
10724
|
-
({ source }) => source.kind === "local" &&
|
|
10819
|
+
({ source }) => source.kind === "local" && import_node_fs16.default.existsSync(source.dir) ? [source.dir] : []
|
|
10725
10820
|
)
|
|
10726
|
-
].map((dir) =>
|
|
10821
|
+
].map((dir) => import_node_fs16.default.realpathSync(dir))
|
|
10727
10822
|
),
|
|
10728
10823
|
projectFiles: [...new Set(used.map((project) => project.projectFile))].sort(),
|
|
10729
10824
|
infoPlist: import_plist3.default.build(info),
|
|
@@ -10731,10 +10826,10 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
10731
10826
|
frameworks,
|
|
10732
10827
|
linkedProducts,
|
|
10733
10828
|
localPackageDirs: [
|
|
10734
|
-
...new Set(localPackageDirs.map((dir) =>
|
|
10829
|
+
...new Set(localPackageDirs.map((dir) => import_node_fs16.default.realpathSync(dir)))
|
|
10735
10830
|
].sort(),
|
|
10736
10831
|
binaryFrameworks: [...binaryFrameworks].sort(),
|
|
10737
|
-
packageResolved:
|
|
10832
|
+
packageResolved: import_node_fs16.default.existsSync(resolvedFile) ? resolvedFile : null,
|
|
10738
10833
|
appTargets: appTargetNames
|
|
10739
10834
|
};
|
|
10740
10835
|
}
|
|
@@ -10754,17 +10849,17 @@ var SKIP_SOURCE_DIRS = /* @__PURE__ */ new Set([
|
|
|
10754
10849
|
var NATIVE_DESCRIPTOR = ".one-native-source.json";
|
|
10755
10850
|
var NATIVE_GLUE = ".one-native-source.swift.txt";
|
|
10756
10851
|
function swiftPackageId(packagePath) {
|
|
10757
|
-
return
|
|
10852
|
+
return import_node_path18.default.basename(packagePath).replace(/[^A-Za-z0-9_]/g, "_").replace(/^(\d)/, "_$1");
|
|
10758
10853
|
}
|
|
10759
10854
|
function nativeSourceDescriptor(packagePath) {
|
|
10760
|
-
packagePath =
|
|
10761
|
-
const file =
|
|
10762
|
-
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;
|
|
10763
10858
|
const value = JSON.parse(
|
|
10764
10859
|
readPackageFile(packagePath, file, MAX_SWIFT_COMPILE_SOURCE_BYTES).toString("utf8")
|
|
10765
10860
|
);
|
|
10766
10861
|
const invalid = () => new Error(`${file}: invalid One native source descriptor; run one typegen`);
|
|
10767
|
-
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))) {
|
|
10768
10863
|
throw invalid();
|
|
10769
10864
|
}
|
|
10770
10865
|
if (!isSwiftNativeModules(value) || value.packageId !== swiftPackageId(packagePath)) {
|
|
@@ -10774,7 +10869,7 @@ function nativeSourceDescriptor(packagePath) {
|
|
|
10774
10869
|
}
|
|
10775
10870
|
var projects = /* @__PURE__ */ new Map();
|
|
10776
10871
|
function projectFor(packagePath, hosted) {
|
|
10777
|
-
packagePath =
|
|
10872
|
+
packagePath = import_node_fs17.default.realpathSync(packagePath);
|
|
10778
10873
|
const existing = projects.get(packagePath);
|
|
10779
10874
|
if (existing) {
|
|
10780
10875
|
if (hosted && !existing.hosted) {
|
|
@@ -10796,14 +10891,14 @@ function projectFor(packagePath, hosted) {
|
|
|
10796
10891
|
}
|
|
10797
10892
|
var xcodeProjects = /* @__PURE__ */ new Map();
|
|
10798
10893
|
function swiftPackages(entry, app) {
|
|
10799
|
-
const stamp = (file) => file &&
|
|
10894
|
+
const stamp = (file) => file && import_node_fs17.default.existsSync(file) ? import_node_fs17.default.statSync(file).mtimeMs : 0;
|
|
10800
10895
|
const key = JSON.stringify([
|
|
10801
10896
|
app.linkedProducts,
|
|
10802
10897
|
app.packageResolved,
|
|
10803
10898
|
stamp(app.packageResolved),
|
|
10804
|
-
app.localPackageDirs.map((dir) => stamp(
|
|
10899
|
+
app.localPackageDirs.map((dir) => stamp(import_node_path18.default.join(dir, "Package.swift"))),
|
|
10805
10900
|
app.linkedProducts.map(
|
|
10806
|
-
({ source }) => source.kind === "local" ? stamp(
|
|
10901
|
+
({ source }) => source.kind === "local" ? stamp(import_node_path18.default.join(source.dir, "Package.swift")) : 0
|
|
10807
10902
|
)
|
|
10808
10903
|
]);
|
|
10809
10904
|
if (entry.packages?.key !== key) {
|
|
@@ -10823,11 +10918,11 @@ function swiftPackages(entry, app) {
|
|
|
10823
10918
|
var XCODE_APP_DIR = "__app__";
|
|
10824
10919
|
var XCODE_FRAMEWORKS_DIR = "__frameworks__";
|
|
10825
10920
|
var XCODE_PACKAGES_DIR = "__packages__";
|
|
10826
|
-
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)}/`;
|
|
10827
10922
|
function xcodeInputKey(layout, file, relative2) {
|
|
10828
10923
|
const owner = layout.targetDirs.get(file);
|
|
10829
|
-
if (owner) return
|
|
10830
|
-
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;
|
|
10831
10926
|
}
|
|
10832
10927
|
function xcodeLayout(root) {
|
|
10833
10928
|
const registered = xcodeProjects.get(root);
|
|
@@ -10838,7 +10933,7 @@ function xcodeLayout(root) {
|
|
|
10838
10933
|
const targetDirs = new Map(app.sources.map((file) => [file, XCODE_APP_DIR]));
|
|
10839
10934
|
const targets = [];
|
|
10840
10935
|
for (const framework of app.frameworks) {
|
|
10841
|
-
const dir =
|
|
10936
|
+
const dir = import_node_path18.default.posix.join(XCODE_FRAMEWORKS_DIR, framework.moduleName);
|
|
10842
10937
|
for (const file of framework.sources) {
|
|
10843
10938
|
if (targetDirs.has(file)) continue;
|
|
10844
10939
|
targetDirs.set(file, dir);
|
|
@@ -10856,19 +10951,19 @@ function xcodeLayout(root) {
|
|
|
10856
10951
|
}
|
|
10857
10952
|
const packages = swiftPackages(registered, app);
|
|
10858
10953
|
for (const target of packages.targets) {
|
|
10859
|
-
const relative2 =
|
|
10860
|
-
target.remote ?
|
|
10954
|
+
const relative2 = import_node_path18.default.relative(
|
|
10955
|
+
target.remote ? import_node_path18.default.join(root, REMOTE_CHECKOUTS) : root,
|
|
10861
10956
|
target.dir
|
|
10862
10957
|
);
|
|
10863
|
-
if (relative2 === ".." || relative2.startsWith(`..${
|
|
10958
|
+
if (relative2 === ".." || relative2.startsWith(`..${import_node_path18.default.sep}`) || import_node_path18.default.isAbsolute(relative2))
|
|
10864
10959
|
throw new Error(`swift input escapes the selected package: ${target.dir}`);
|
|
10865
|
-
const posix2 = relative2.split(
|
|
10960
|
+
const posix2 = relative2.split(import_node_path18.default.sep).join(import_node_path18.default.posix.sep);
|
|
10866
10961
|
targets.push({
|
|
10867
10962
|
...target,
|
|
10868
|
-
path: target.remote ?
|
|
10963
|
+
path: target.remote ? import_node_path18.default.posix.join(XCODE_PACKAGES_DIR, posix2) : posix2,
|
|
10869
10964
|
exclude: []
|
|
10870
10965
|
});
|
|
10871
|
-
if (!target.remote) files.add(
|
|
10966
|
+
if (!target.remote) files.add(import_node_path18.default.join(target.packageDir, "Package.swift"));
|
|
10872
10967
|
for (const file of target.files) files.add(file);
|
|
10873
10968
|
}
|
|
10874
10969
|
for (const target of targets) {
|
|
@@ -10897,25 +10992,25 @@ function xcodeManifest(layout) {
|
|
|
10897
10992
|
].join("\n");
|
|
10898
10993
|
}
|
|
10899
10994
|
function packageFiles(root) {
|
|
10900
|
-
const canonicalRoot =
|
|
10995
|
+
const canonicalRoot = import_node_fs17.default.realpathSync(root);
|
|
10901
10996
|
const xcode = xcodeLayout(canonicalRoot);
|
|
10902
10997
|
return xcode ? xcode.files : sourceTreeFiles(canonicalRoot, canonicalRoot);
|
|
10903
10998
|
}
|
|
10904
10999
|
function sourceTreeFiles(dir, canonicalRoot) {
|
|
10905
11000
|
const found = [];
|
|
10906
11001
|
const walk2 = (dir2) => {
|
|
10907
|
-
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))) {
|
|
10908
11003
|
if (entry.name.startsWith(".") && entry.name !== NATIVE_DESCRIPTOR && entry.name !== NATIVE_GLUE || SKIP_SOURCE_DIRS.has(entry.name))
|
|
10909
11004
|
continue;
|
|
10910
|
-
const full =
|
|
11005
|
+
const full = import_node_path18.default.join(dir2, entry.name);
|
|
10911
11006
|
if (entry.isSymbolicLink()) throw new Error(`swift input is a symlink: ${full}`);
|
|
10912
|
-
const real =
|
|
10913
|
-
const relative2 =
|
|
10914
|
-
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)) {
|
|
10915
11010
|
throw new Error(`swift input escapes the selected package: ${full}`);
|
|
10916
11011
|
}
|
|
10917
11012
|
if (entry.isDirectory()) {
|
|
10918
|
-
if (
|
|
11013
|
+
if (import_node_fs17.default.existsSync(import_node_path18.default.join(full, "Package.swift"))) continue;
|
|
10919
11014
|
walk2(full);
|
|
10920
11015
|
} else if (entry.isFile()) {
|
|
10921
11016
|
found.push(full);
|
|
@@ -10923,29 +11018,29 @@ function sourceTreeFiles(dir, canonicalRoot) {
|
|
|
10923
11018
|
}
|
|
10924
11019
|
}
|
|
10925
11020
|
};
|
|
10926
|
-
if (
|
|
11021
|
+
if (import_node_fs17.default.existsSync(dir)) walk2(import_node_fs17.default.realpathSync(dir));
|
|
10927
11022
|
return found;
|
|
10928
11023
|
}
|
|
10929
11024
|
function readPackageFile(root, file, maxBytes) {
|
|
10930
|
-
const canonicalRoot =
|
|
10931
|
-
const relative2 =
|
|
10932
|
-
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)) {
|
|
10933
11028
|
throw new Error(`swift input escapes the selected package: ${file}`);
|
|
10934
11029
|
}
|
|
10935
|
-
let ancestor =
|
|
11030
|
+
let ancestor = import_node_path18.default.resolve(file);
|
|
10936
11031
|
while (ancestor !== canonicalRoot) {
|
|
10937
|
-
if (
|
|
11032
|
+
if (import_node_fs17.default.lstatSync(ancestor).isSymbolicLink()) {
|
|
10938
11033
|
throw new Error(`swift input is a symlink: ${ancestor}`);
|
|
10939
11034
|
}
|
|
10940
|
-
const parent =
|
|
11035
|
+
const parent = import_node_path18.default.dirname(ancestor);
|
|
10941
11036
|
if (parent === ancestor)
|
|
10942
11037
|
throw new Error(`swift input escapes the selected package: ${file}`);
|
|
10943
11038
|
ancestor = parent;
|
|
10944
11039
|
}
|
|
10945
|
-
const expected =
|
|
10946
|
-
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);
|
|
10947
11042
|
try {
|
|
10948
|
-
const stat2 =
|
|
11043
|
+
const stat2 = import_node_fs17.default.fstatSync(fd);
|
|
10949
11044
|
if (stat2.dev !== expected.dev || stat2.ino !== expected.ino) {
|
|
10950
11045
|
throw new Error(`swift input changed while opening: ${file}`);
|
|
10951
11046
|
}
|
|
@@ -10955,16 +11050,16 @@ function readPackageFile(root, file, maxBytes) {
|
|
|
10955
11050
|
const bytes = Buffer.alloc(stat2.size + 1);
|
|
10956
11051
|
let offset = 0;
|
|
10957
11052
|
while (offset < bytes.length) {
|
|
10958
|
-
const count =
|
|
11053
|
+
const count = import_node_fs17.default.readSync(fd, bytes, offset, bytes.length - offset, null);
|
|
10959
11054
|
if (count === 0) break;
|
|
10960
11055
|
offset += count;
|
|
10961
11056
|
}
|
|
10962
|
-
if (offset !== stat2.size ||
|
|
11057
|
+
if (offset !== stat2.size || import_node_fs17.default.fstatSync(fd).size !== stat2.size) {
|
|
10963
11058
|
throw new Error(`swift input changed while reading: ${file}`);
|
|
10964
11059
|
}
|
|
10965
11060
|
return bytes.subarray(0, offset);
|
|
10966
11061
|
} finally {
|
|
10967
|
-
|
|
11062
|
+
import_node_fs17.default.closeSync(fd);
|
|
10968
11063
|
}
|
|
10969
11064
|
}
|
|
10970
11065
|
function sourceFiles(root) {
|
|
@@ -10972,7 +11067,7 @@ function sourceFiles(root) {
|
|
|
10972
11067
|
}
|
|
10973
11068
|
function resourceCandidateFiles(root) {
|
|
10974
11069
|
return packageFiles(root).filter(
|
|
10975
|
-
(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))
|
|
10976
11071
|
);
|
|
10977
11072
|
}
|
|
10978
11073
|
var HOSTED_LIMITS = {
|
|
@@ -11006,7 +11101,7 @@ function buildSwiftResourceTable(project, baseUrl) {
|
|
|
11006
11101
|
const limits = inputLimits(Boolean(project.hosted));
|
|
11007
11102
|
const absolute = resourceCandidateFiles(project.packagePath);
|
|
11008
11103
|
const relative2 = absolute.map(
|
|
11009
|
-
(file) =>
|
|
11104
|
+
(file) => import_node_path18.default.relative(project.packagePath, file).split(import_node_path18.default.sep).join(import_node_path18.default.posix.sep)
|
|
11010
11105
|
);
|
|
11011
11106
|
const byRelative = new Map(absolute.map((file, index) => [relative2[index], file]));
|
|
11012
11107
|
const readContents = (candidate) => {
|
|
@@ -11028,16 +11123,16 @@ function buildSwiftResourceTable(project, baseUrl) {
|
|
|
11028
11123
|
for (const { name: name2, file, scale } of found) {
|
|
11029
11124
|
const disk = byRelative.get(file);
|
|
11030
11125
|
if (!disk) continue;
|
|
11031
|
-
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) {
|
|
11032
11127
|
throw new Error("swift image pack exceeds the compile service caps");
|
|
11033
11128
|
}
|
|
11034
11129
|
const bytes = readPackageFile(project.packagePath, disk, limits.imageBytes);
|
|
11035
11130
|
imageBytes += bytes.length;
|
|
11036
|
-
const hash = (0,
|
|
11037
|
-
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();
|
|
11038
11133
|
table[name2] = { uri: `${baseUrl}${RESOURCE_PATH}${hash}${ext}`, scale };
|
|
11039
11134
|
images[name2] = {
|
|
11040
|
-
file:
|
|
11135
|
+
file: import_node_path18.default.posix.basename(file),
|
|
11041
11136
|
data: bytes.toString("base64")
|
|
11042
11137
|
};
|
|
11043
11138
|
watched.push(file);
|
|
@@ -11061,10 +11156,10 @@ function buildSwiftResourceTable(project, baseUrl) {
|
|
|
11061
11156
|
return { table, images, colors, symbols, watched };
|
|
11062
11157
|
}
|
|
11063
11158
|
function buildSwiftBundleFiles(packagePath, hosted) {
|
|
11064
|
-
packagePath =
|
|
11159
|
+
packagePath = import_node_fs17.default.realpathSync(packagePath);
|
|
11065
11160
|
const limits = inputLimits(hosted);
|
|
11066
11161
|
const relative2 = resourceCandidateFiles(packagePath).map(
|
|
11067
|
-
(file) =>
|
|
11162
|
+
(file) => import_node_path18.default.relative(packagePath, file).split(import_node_path18.default.sep).join(import_node_path18.default.posix.sep)
|
|
11068
11163
|
);
|
|
11069
11164
|
const files = {};
|
|
11070
11165
|
const watched = [];
|
|
@@ -11078,13 +11173,13 @@ function buildSwiftBundleFiles(packagePath, hosted) {
|
|
|
11078
11173
|
total += bytes.length;
|
|
11079
11174
|
if (xcode.app.infoPlistFile)
|
|
11080
11175
|
watched.push(
|
|
11081
|
-
|
|
11176
|
+
import_node_path18.default.relative(packagePath, xcode.app.infoPlistFile).split(import_node_path18.default.sep).join("/")
|
|
11082
11177
|
);
|
|
11083
11178
|
}
|
|
11084
11179
|
for (const { base, file } of enumerateBundleJson(relative2)) {
|
|
11085
11180
|
watched.push(file);
|
|
11086
|
-
const disk =
|
|
11087
|
-
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) {
|
|
11088
11183
|
throw new Error(
|
|
11089
11184
|
`swift bundle pack exceeds ${limits.resources} files / ${limits.resourceTotalBytes} bytes`
|
|
11090
11185
|
);
|
|
@@ -11099,12 +11194,12 @@ function serveSwiftResource(project, key) {
|
|
|
11099
11194
|
return project.resourceFiles.get(key) ?? project.resourcesPrevious.get(key) ?? null;
|
|
11100
11195
|
}
|
|
11101
11196
|
function linkedModuleRoots(packagePath) {
|
|
11102
|
-
packagePath =
|
|
11197
|
+
packagePath = import_node_fs17.default.realpathSync(packagePath);
|
|
11103
11198
|
let manifest;
|
|
11104
11199
|
try {
|
|
11105
11200
|
manifest = readPackageFile(
|
|
11106
11201
|
packagePath,
|
|
11107
|
-
|
|
11202
|
+
import_node_path18.default.join(packagePath, "Package.swift"),
|
|
11108
11203
|
MAX_SWIFT_COMPILE_SOURCE_BYTES
|
|
11109
11204
|
).toString("utf8");
|
|
11110
11205
|
} catch {
|
|
@@ -11113,28 +11208,28 @@ function linkedModuleRoots(packagePath) {
|
|
|
11113
11208
|
const roots = /* @__PURE__ */ new Set();
|
|
11114
11209
|
const dependency = /\.package\(\s*path:\s*"([^"]+)"\s*\)/g;
|
|
11115
11210
|
for (const match of manifest.replace(/^\s*\/\/.*$/gm, "").matchAll(dependency)) {
|
|
11116
|
-
const root =
|
|
11117
|
-
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);
|
|
11118
11213
|
}
|
|
11119
11214
|
return [...roots].sort();
|
|
11120
11215
|
}
|
|
11121
11216
|
function sourceStamp(packagePath, moduleRootOverride, hosted = false) {
|
|
11122
|
-
const hash = (0,
|
|
11217
|
+
const hash = (0, import_node_crypto7.createHash)("sha256");
|
|
11123
11218
|
hash.update(packagePath);
|
|
11124
11219
|
const projectInputs = new Set(packageFiles(packagePath));
|
|
11125
11220
|
for (const file of [...projectInputs].sort()) {
|
|
11126
|
-
hash.update(
|
|
11127
|
-
const stat2 =
|
|
11221
|
+
hash.update(import_node_path18.default.relative(packagePath, file));
|
|
11222
|
+
const stat2 = import_node_fs17.default.statSync(file);
|
|
11128
11223
|
hash.update(`${stat2.mtimeMs}/${stat2.ctimeMs}/${stat2.size}`);
|
|
11129
11224
|
}
|
|
11130
11225
|
const moduleRoot = hosted ? void 0 : moduleRootOverride ?? linkedModuleRoots(packagePath).find(
|
|
11131
|
-
(root) =>
|
|
11226
|
+
(root) => import_node_fs17.default.existsSync(import_node_path18.default.join(root, "toolchain.json"))
|
|
11132
11227
|
);
|
|
11133
11228
|
if (moduleRoot) {
|
|
11134
11229
|
hash.update(moduleRoot);
|
|
11135
11230
|
for (const relative2 of swiftModuleInputFiles(moduleRoot)) {
|
|
11136
11231
|
hash.update(relative2);
|
|
11137
|
-
hash.update(String(
|
|
11232
|
+
hash.update(String(import_node_fs17.default.statSync(import_node_path18.default.join(moduleRoot, relative2)).mtimeMs));
|
|
11138
11233
|
}
|
|
11139
11234
|
}
|
|
11140
11235
|
return hash.digest("hex").slice(0, 16);
|
|
@@ -11146,8 +11241,8 @@ function packageSources(packagePath) {
|
|
|
11146
11241
|
const xcode = xcodeLayout(packagePath);
|
|
11147
11242
|
const files = {};
|
|
11148
11243
|
for (const file of sourceFiles(packagePath)) {
|
|
11149
|
-
const relative2 =
|
|
11150
|
-
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;
|
|
11151
11246
|
files[xcode ? xcodeInputKey(xcode, file, relative2) : relative2] = readPackageFile(
|
|
11152
11247
|
packagePath,
|
|
11153
11248
|
file,
|
|
@@ -11164,7 +11259,7 @@ function packageSnapshot(project) {
|
|
|
11164
11259
|
files,
|
|
11165
11260
|
resourcePaths: swiftImplicitResourcePaths(
|
|
11166
11261
|
resourceCandidateFiles(project.packagePath).map(
|
|
11167
|
-
(file) =>
|
|
11262
|
+
(file) => import_node_path18.default.relative(project.packagePath, file).split(import_node_path18.default.sep).join(import_node_path18.default.posix.sep)
|
|
11168
11263
|
)
|
|
11169
11264
|
),
|
|
11170
11265
|
resources: buildSwiftResourceTable(project, ""),
|
|
@@ -11173,7 +11268,7 @@ function packageSnapshot(project) {
|
|
|
11173
11268
|
...native ? {
|
|
11174
11269
|
glue: readPackageFile(
|
|
11175
11270
|
project.packagePath,
|
|
11176
|
-
|
|
11271
|
+
import_node_path18.default.join(project.packagePath, NATIVE_GLUE),
|
|
11177
11272
|
MAX_SWIFT_COMPILE_SOURCE_BYTES
|
|
11178
11273
|
).toString("utf8")
|
|
11179
11274
|
} : {}
|
|
@@ -11209,7 +11304,7 @@ async function compile(packagePath, entry, stamp, moduleRootOverride, hosted, sn
|
|
|
11209
11304
|
package: content
|
|
11210
11305
|
};
|
|
11211
11306
|
const moduleRoot = moduleRootOverride ?? linkedModuleRoots(packagePath).find(
|
|
11212
|
-
(root) =>
|
|
11307
|
+
(root) => import_node_fs17.default.existsSync(import_node_path18.default.join(root, "toolchain.json"))
|
|
11213
11308
|
) ?? await swiftDistributionRoot();
|
|
11214
11309
|
if (!moduleRoot)
|
|
11215
11310
|
return {
|
|
@@ -11228,17 +11323,17 @@ async function compile(packagePath, entry, stamp, moduleRootOverride, hosted, sn
|
|
|
11228
11323
|
...targets.length > 0 ? targets : ["App"]
|
|
11229
11324
|
])
|
|
11230
11325
|
);
|
|
11231
|
-
if (missing.size > 0) throw new Error(missingModulesMessage(packagePath, missing));
|
|
11326
|
+
if (missing.size > 0) throw new Error(await missingModulesMessage(packagePath, missing));
|
|
11232
11327
|
const artifact = await compileSwiftProjectUnit(input, {
|
|
11233
11328
|
// the compile rewrites Sources/App in its root before swiftpm builds, and
|
|
11234
11329
|
// its lock orders one process only: two vites on one root (a lane's dev
|
|
11235
11330
|
// server and a capture, or two checkouts) build each other's sources. so
|
|
11236
11331
|
// each app and module checkout gets its own root, which keeps the same
|
|
11237
11332
|
// app's incremental build across restarts.
|
|
11238
|
-
buildRoot: process.env.CONTRAST_SWIFT_BUILD_ROOT ??
|
|
11239
|
-
|
|
11333
|
+
buildRoot: process.env.CONTRAST_SWIFT_BUILD_ROOT ?? import_node_path18.default.join(
|
|
11334
|
+
import_node_os7.default.tmpdir(),
|
|
11240
11335
|
"contrast-swift-build",
|
|
11241
|
-
(0,
|
|
11336
|
+
(0, import_node_crypto7.createHash)("sha256").update(`${moduleRoot}\0${import_node_path18.default.resolve(packagePath)}`).digest("hex").slice(0, 16)
|
|
11242
11337
|
),
|
|
11243
11338
|
moduleRoot,
|
|
11244
11339
|
...toolchain
|
|
@@ -11306,7 +11401,7 @@ var UNPROVIDED_PLATFORM_MODULES = {
|
|
|
11306
11401
|
MachO: "Peach compiles for WebAssembly, which has no Mach-O images"
|
|
11307
11402
|
};
|
|
11308
11403
|
var IOS_SDK_FRAMEWORKS = new Set(ios_sdk_frameworks_default.frameworks);
|
|
11309
|
-
function missingModulesMessage(packagePath, missing) {
|
|
11404
|
+
async function missingModulesMessage(packagePath, missing) {
|
|
11310
11405
|
const layout = xcodeLayout(packagePath);
|
|
11311
11406
|
const gaps = new Map([
|
|
11312
11407
|
...(layout?.app.binaryFrameworks ?? []).map(
|
|
@@ -11328,12 +11423,29 @@ function missingModulesMessage(packagePath, missing) {
|
|
|
11328
11423
|
...layout?.packages.modules ?? [],
|
|
11329
11424
|
...layout?.packages.unavailable ?? []
|
|
11330
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
|
+
);
|
|
11331
11443
|
const width = Math.max(...[...missing.keys()].map((name2) => name2.length));
|
|
11332
11444
|
return [
|
|
11333
11445
|
`Peach does not provide ${missing.size} module${missing.size === 1 ? "" : "s"} this app imports:`,
|
|
11334
11446
|
...[...missing].map(([name2, files]) => {
|
|
11335
11447
|
const gap = gaps.get(name2);
|
|
11336
|
-
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})` : ""}`;
|
|
11337
11449
|
})
|
|
11338
11450
|
].join("\n");
|
|
11339
11451
|
}
|
|
@@ -11341,7 +11453,7 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
|
|
|
11341
11453
|
const auth = hosted ? null : resolveCliAuth();
|
|
11342
11454
|
if (!hosted && (!auth || auth.kind === "github")) {
|
|
11343
11455
|
throw new Error(
|
|
11344
|
-
`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`
|
|
11345
11457
|
);
|
|
11346
11458
|
}
|
|
11347
11459
|
const origin = hosted?.origin ?? resolveContrastBackendOrigin(auth?.kind === "session" ? auth.origin : null);
|
|
@@ -11360,7 +11472,7 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
|
|
|
11360
11472
|
const bytes = sources.reduce((total2, text2) => total2 + Buffer.byteLength(text2), 0);
|
|
11361
11473
|
if (sources.length > MAX_SWIFT_COMPILE_FILES || bytes > MAX_SWIFT_COMPILE_SOURCE_BYTES) {
|
|
11362
11474
|
throw new Error(
|
|
11363
|
-
`${
|
|
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`
|
|
11364
11476
|
);
|
|
11365
11477
|
}
|
|
11366
11478
|
const descriptor = snapshot.native;
|
|
@@ -11379,7 +11491,7 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
|
|
|
11379
11491
|
);
|
|
11380
11492
|
if (descriptor && address.native?.hash !== descriptor.hash) {
|
|
11381
11493
|
throw new Error(
|
|
11382
|
-
`${
|
|
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`
|
|
11383
11495
|
);
|
|
11384
11496
|
}
|
|
11385
11497
|
const response = await fetch(address.url, { signal });
|
|
@@ -11503,8 +11615,8 @@ var scriptEnv = { ...process.env, [RNX_FORKED_SCRIPT_ENV]: "1" };
|
|
|
11503
11615
|
var EXPO_SWIFT_ROUTE = "/__peach/expo-swift";
|
|
11504
11616
|
var EXPO_SWIFT_ENTRY = "Sources/PeachExpoApp/PeachExpoEntry.swift";
|
|
11505
11617
|
async function collectExpoSwiftSources(appRoot) {
|
|
11506
|
-
appRoot =
|
|
11507
|
-
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"));
|
|
11508
11620
|
let autolinker;
|
|
11509
11621
|
try {
|
|
11510
11622
|
autolinker = appRequire.resolve("expo-modules-autolinking/package.json");
|
|
@@ -11518,7 +11630,7 @@ async function collectExpoSwiftSources(appRoot) {
|
|
|
11518
11630
|
(command) => run3(
|
|
11519
11631
|
process.execPath,
|
|
11520
11632
|
[
|
|
11521
|
-
|
|
11633
|
+
import_node_path19.default.join(import_node_path19.default.dirname(autolinker), "bin/expo-modules-autolinking.js"),
|
|
11522
11634
|
command,
|
|
11523
11635
|
"--platform",
|
|
11524
11636
|
"apple",
|
|
@@ -11549,8 +11661,8 @@ async function collectExpoSwiftSources(appRoot) {
|
|
|
11549
11661
|
const sourceRoot = Reflect.get(entry, "path");
|
|
11550
11662
|
if (typeof sourceRoot !== "string")
|
|
11551
11663
|
throw new Error("Expo autolinking entry has no path");
|
|
11552
|
-
const canonical =
|
|
11553
|
-
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;
|
|
11554
11666
|
const resolution = resolutions.find(
|
|
11555
11667
|
(candidate) => candidate && typeof candidate === "object" && Reflect.get(candidate, "packageName") === Reflect.get(entry, "name")
|
|
11556
11668
|
);
|
|
@@ -11576,12 +11688,12 @@ async function collectExpoSwiftSources(appRoot) {
|
|
|
11576
11688
|
`(${className.includes(".") ? className : `${namespace}.${className}`}.self, ${name2 === null ? "nil" : JSON.stringify(name2)})`
|
|
11577
11689
|
);
|
|
11578
11690
|
}
|
|
11579
|
-
const ios =
|
|
11580
|
-
if (
|
|
11691
|
+
const ios = import_node_path19.default.join(canonical, "ios");
|
|
11692
|
+
if (import_node_fs18.default.lstatSync(ios).isSymbolicLink())
|
|
11581
11693
|
throw new Error(`Expo Swift source directory is a symlink: ${ios}`);
|
|
11582
11694
|
const walk2 = (dir) => {
|
|
11583
|
-
for (const child of
|
|
11584
|
-
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);
|
|
11585
11697
|
if (child.isSymbolicLink())
|
|
11586
11698
|
throw new Error(`Expo Swift source is a symlink: ${file}`);
|
|
11587
11699
|
if (child.isDirectory()) {
|
|
@@ -11589,13 +11701,13 @@ async function collectExpoSwiftSources(appRoot) {
|
|
|
11589
11701
|
continue;
|
|
11590
11702
|
}
|
|
11591
11703
|
if (!child.name.endsWith(".swift")) continue;
|
|
11592
|
-
const size =
|
|
11704
|
+
const size = import_node_fs18.default.statSync(file).size;
|
|
11593
11705
|
bytes += size;
|
|
11594
11706
|
fileCount++;
|
|
11595
11707
|
if (fileCount > MAX_SWIFT_COMPILE_FILES - 2 || bytes > MAX_SWIFT_COMPILE_SOURCE_BYTES)
|
|
11596
11708
|
throw new Error("Expo Swift sources exceed compile service caps");
|
|
11597
|
-
files[`Sources/${namespace}/${
|
|
11598
|
-
${
|
|
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")}`;
|
|
11599
11711
|
}
|
|
11600
11712
|
};
|
|
11601
11713
|
walk2(ios);
|
|
@@ -11680,7 +11792,7 @@ async function handleExpoSwiftRequest(req, res) {
|
|
|
11680
11792
|
return true;
|
|
11681
11793
|
}
|
|
11682
11794
|
const root = url.searchParams.get("root");
|
|
11683
|
-
if (!root || !
|
|
11795
|
+
if (!root || !import_node_path19.default.isAbsolute(root)) {
|
|
11684
11796
|
res.writeHead(400);
|
|
11685
11797
|
res.end("missing absolute app root");
|
|
11686
11798
|
return true;
|
|
@@ -11697,7 +11809,7 @@ async function handleExpoSwiftRequest(req, res) {
|
|
|
11697
11809
|
modules: [],
|
|
11698
11810
|
failures: []
|
|
11699
11811
|
};
|
|
11700
|
-
const key = (0,
|
|
11812
|
+
const key = (0, import_node_crypto8.createHash)("sha256").update(import_node_fs18.default.realpathSync(root)).digest("hex");
|
|
11701
11813
|
const host2 = req.headers.host;
|
|
11702
11814
|
if (!host2) throw new Error("Expo Swift request has no host");
|
|
11703
11815
|
const base = `http://${host2}`;
|
|
@@ -11711,8 +11823,8 @@ async function handleExpoSwiftRequest(req, res) {
|
|
|
11711
11823
|
continue;
|
|
11712
11824
|
}
|
|
11713
11825
|
try {
|
|
11714
|
-
const packagePath =
|
|
11715
|
-
|
|
11826
|
+
const packagePath = import_node_path19.default.join(
|
|
11827
|
+
import_node_os8.default.tmpdir(),
|
|
11716
11828
|
"peach-expo-swift",
|
|
11717
11829
|
key,
|
|
11718
11830
|
unit.namespace
|
|
@@ -11721,7 +11833,7 @@ async function handleExpoSwiftRequest(req, res) {
|
|
|
11721
11833
|
packagePath,
|
|
11722
11834
|
new Map(
|
|
11723
11835
|
Object.entries(unit.files).map(([name2, source]) => [
|
|
11724
|
-
|
|
11836
|
+
import_node_path19.default.join(packagePath, name2),
|
|
11725
11837
|
source
|
|
11726
11838
|
])
|
|
11727
11839
|
)
|
|
@@ -11772,8 +11884,8 @@ async function handleExpoSwiftRequest(req, res) {
|
|
|
11772
11884
|
import PackageDescription
|
|
11773
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")])
|
|
11774
11886
|
`;
|
|
11775
|
-
const packagePath =
|
|
11776
|
-
|
|
11887
|
+
const packagePath = import_node_path19.default.join(
|
|
11888
|
+
import_node_os8.default.tmpdir(),
|
|
11777
11889
|
"peach-expo-swift",
|
|
11778
11890
|
key,
|
|
11779
11891
|
"linked-app"
|
|
@@ -11782,7 +11894,7 @@ let package = Package(name: "PeachExpo", targets: [${targets.map((name2) => `.ta
|
|
|
11782
11894
|
packagePath,
|
|
11783
11895
|
new Map(
|
|
11784
11896
|
Object.entries(files).map(([name2, source]) => [
|
|
11785
|
-
|
|
11897
|
+
import_node_path19.default.join(packagePath, name2),
|
|
11786
11898
|
source
|
|
11787
11899
|
])
|
|
11788
11900
|
)
|
|
@@ -11892,10 +12004,10 @@ function resolveRuntimeRootForHostname(hostname) {
|
|
|
11892
12004
|
}
|
|
11893
12005
|
function sendFileWithRanges(req, res, filePath, total, headers) {
|
|
11894
12006
|
const head = (req?.method || "GET").toUpperCase() === "HEAD";
|
|
11895
|
-
const
|
|
11896
|
-
const invalid =
|
|
11897
|
-
if (
|
|
11898
|
-
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;
|
|
11899
12011
|
const start = startRaw ? Number(startRaw) : Math.max(0, total - Number(endRaw));
|
|
11900
12012
|
const end = startRaw && endRaw ? Math.min(Number(endRaw), total - 1) : total - 1;
|
|
11901
12013
|
if (start > end || start >= total) {
|
|
@@ -11955,20 +12067,20 @@ var RNX_RUNTIME_PRODUCT = {
|
|
|
11955
12067
|
var rnxRuntime = createRuntimeDelivery(RNX_RUNTIME_PRODUCT);
|
|
11956
12068
|
|
|
11957
12069
|
// src/host/agent-host.ts
|
|
11958
|
-
var
|
|
11959
|
-
var
|
|
11960
|
-
var
|
|
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);
|
|
11961
12073
|
|
|
11962
12074
|
// src/agent-sessions.ts
|
|
11963
12075
|
var import_node_child_process9 = require("node:child_process");
|
|
11964
|
-
var
|
|
11965
|
-
var
|
|
11966
|
-
var
|
|
12076
|
+
var import_node_crypto10 = require("node:crypto");
|
|
12077
|
+
var import_node_fs21 = __toESM(require("node:fs"), 1);
|
|
12078
|
+
var import_node_path22 = __toESM(require("node:path"), 1);
|
|
11967
12079
|
var import_node_readline = __toESM(require("node:readline"), 1);
|
|
11968
12080
|
|
|
11969
12081
|
// cli/self-invocation.ts
|
|
11970
|
-
var
|
|
11971
|
-
var
|
|
12082
|
+
var import_node_fs19 = require("node:fs");
|
|
12083
|
+
var import_node_path20 = require("node:path");
|
|
11972
12084
|
var import_node_url3 = require("node:url");
|
|
11973
12085
|
init_public_brand();
|
|
11974
12086
|
|
|
@@ -11978,14 +12090,14 @@ var IS_STANDALONE = typeof __SOOTSIM_STANDALONE__ !== "undefined" && __SOOTSIM_S
|
|
|
11978
12090
|
// cli/self-invocation.ts
|
|
11979
12091
|
function sourceEntryPath() {
|
|
11980
12092
|
try {
|
|
11981
|
-
const candidate = (0,
|
|
11982
|
-
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;
|
|
11983
12095
|
} catch {
|
|
11984
12096
|
return null;
|
|
11985
12097
|
}
|
|
11986
12098
|
}
|
|
11987
|
-
function isCliEntry(
|
|
11988
|
-
const name2 = (0,
|
|
12099
|
+
function isCliEntry(path23) {
|
|
12100
|
+
const name2 = (0, import_node_path20.basename)(path23);
|
|
11989
12101
|
return name2 === "bin.ts" || name2 === "bin.js";
|
|
11990
12102
|
}
|
|
11991
12103
|
function rnxSelfInvocation() {
|
|
@@ -12044,9 +12156,9 @@ function encodeAgentPromptEnvelope(input) {
|
|
|
12044
12156
|
}
|
|
12045
12157
|
|
|
12046
12158
|
// src/attached-projects.ts
|
|
12047
|
-
var
|
|
12048
|
-
var
|
|
12049
|
-
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);
|
|
12050
12162
|
init_home_paths();
|
|
12051
12163
|
var overrideDir = null;
|
|
12052
12164
|
function userDataDir() {
|
|
@@ -12059,7 +12171,7 @@ function getUserDataDir() {
|
|
|
12059
12171
|
return userDataDir();
|
|
12060
12172
|
}
|
|
12061
12173
|
function storeFile() {
|
|
12062
|
-
return
|
|
12174
|
+
return import_node_path21.default.join(userDataDir(), "attached-projects.json");
|
|
12063
12175
|
}
|
|
12064
12176
|
function cloneEmpty() {
|
|
12065
12177
|
return {
|
|
@@ -12073,7 +12185,7 @@ function loadStore() {
|
|
|
12073
12185
|
const file = storeFile();
|
|
12074
12186
|
let raw2;
|
|
12075
12187
|
try {
|
|
12076
|
-
raw2 =
|
|
12188
|
+
raw2 = import_node_fs20.default.readFileSync(file, "utf8");
|
|
12077
12189
|
} catch (err) {
|
|
12078
12190
|
if (err.code === "ENOENT") return cloneEmpty();
|
|
12079
12191
|
throw err;
|
|
@@ -12090,7 +12202,7 @@ function loadStore() {
|
|
|
12090
12202
|
} catch (err) {
|
|
12091
12203
|
const quarantine = `${file}.corrupt-${Date.now()}`;
|
|
12092
12204
|
try {
|
|
12093
|
-
|
|
12205
|
+
import_node_fs20.default.renameSync(file, quarantine);
|
|
12094
12206
|
console.warn(
|
|
12095
12207
|
`[sootsim] attached-projects.json was unparseable; quarantined to ${quarantine}. original error: ${err.message}`
|
|
12096
12208
|
);
|
|
@@ -12101,16 +12213,16 @@ function loadStore() {
|
|
|
12101
12213
|
}
|
|
12102
12214
|
function writeStore(store) {
|
|
12103
12215
|
const file = storeFile();
|
|
12104
|
-
|
|
12216
|
+
import_node_fs20.default.mkdirSync(import_node_path21.default.dirname(file), { recursive: true });
|
|
12105
12217
|
const tmp = `${file}.tmp-${process.pid}-${Date.now()}`;
|
|
12106
|
-
const fd =
|
|
12218
|
+
const fd = import_node_fs20.default.openSync(tmp, "w", 384);
|
|
12107
12219
|
try {
|
|
12108
|
-
|
|
12109
|
-
|
|
12220
|
+
import_node_fs20.default.writeFileSync(fd, JSON.stringify(store, null, 2));
|
|
12221
|
+
import_node_fs20.default.fsyncSync(fd);
|
|
12110
12222
|
} finally {
|
|
12111
|
-
|
|
12223
|
+
import_node_fs20.default.closeSync(fd);
|
|
12112
12224
|
}
|
|
12113
|
-
|
|
12225
|
+
import_node_fs20.default.renameSync(tmp, file);
|
|
12114
12226
|
}
|
|
12115
12227
|
function mutateStore(fn) {
|
|
12116
12228
|
const store = loadStore();
|
|
@@ -12119,13 +12231,13 @@ function mutateStore(fn) {
|
|
|
12119
12231
|
return store;
|
|
12120
12232
|
}
|
|
12121
12233
|
function projectIdForCwd(cwd) {
|
|
12122
|
-
return (0,
|
|
12234
|
+
return (0, import_node_crypto9.createHash)("sha256").update(import_node_path21.default.resolve(cwd)).digest("hex").slice(0, 16);
|
|
12123
12235
|
}
|
|
12124
12236
|
function newSessionId() {
|
|
12125
|
-
return `s_${(0,
|
|
12237
|
+
return `s_${(0, import_node_crypto9.randomBytes)(10).toString("hex")}`;
|
|
12126
12238
|
}
|
|
12127
12239
|
function upsertProject(input) {
|
|
12128
|
-
const cwd =
|
|
12240
|
+
const cwd = import_node_path21.default.resolve(input.cwd);
|
|
12129
12241
|
const id = projectIdForCwd(cwd);
|
|
12130
12242
|
let result;
|
|
12131
12243
|
mutateStore((store) => {
|
|
@@ -12151,7 +12263,7 @@ function upsertProject(input) {
|
|
|
12151
12263
|
const now = Date.now();
|
|
12152
12264
|
const created = {
|
|
12153
12265
|
id,
|
|
12154
|
-
name: input.name ??
|
|
12266
|
+
name: input.name ?? import_node_path21.default.basename(cwd),
|
|
12155
12267
|
cwd,
|
|
12156
12268
|
repoRoot: input.repoRoot,
|
|
12157
12269
|
sourceRoots: input.sourceRoots ?? [cwd],
|
|
@@ -12297,8 +12409,8 @@ async function seedFromDemoAppRegistry() {
|
|
|
12297
12409
|
if (apps.length === 0) return;
|
|
12298
12410
|
mutateStore((store) => {
|
|
12299
12411
|
for (const app of apps) {
|
|
12300
|
-
if (!
|
|
12301
|
-
const cwd =
|
|
12412
|
+
if (!import_node_fs20.default.existsSync(app.dir)) continue;
|
|
12413
|
+
const cwd = import_node_path21.default.resolve(app.dir);
|
|
12302
12414
|
const id = projectIdForCwd(cwd);
|
|
12303
12415
|
if (store.attachedProjects.some((p) => p.id === id)) continue;
|
|
12304
12416
|
const now = Date.now();
|
|
@@ -12323,16 +12435,16 @@ async function seedFromDemoAppRegistry() {
|
|
|
12323
12435
|
// src/agent-sessions.ts
|
|
12324
12436
|
init_public_brand();
|
|
12325
12437
|
function sessionDir(sessionId) {
|
|
12326
|
-
return
|
|
12438
|
+
return import_node_path22.default.join(getUserDataDir(), "sessions", sessionId);
|
|
12327
12439
|
}
|
|
12328
12440
|
function promptFifoPath(sessionId) {
|
|
12329
|
-
return
|
|
12441
|
+
return import_node_path22.default.join(sessionDir(sessionId), "prompt.in");
|
|
12330
12442
|
}
|
|
12331
12443
|
function eventsFifoPath(sessionId) {
|
|
12332
|
-
return
|
|
12444
|
+
return import_node_path22.default.join(sessionDir(sessionId), "events.out");
|
|
12333
12445
|
}
|
|
12334
12446
|
function transcriptPath(sessionId) {
|
|
12335
|
-
return
|
|
12447
|
+
return import_node_path22.default.join(getUserDataDir(), "transcripts", `${sessionId}.log`);
|
|
12336
12448
|
}
|
|
12337
12449
|
function pidIsAlive(pid, sessionId) {
|
|
12338
12450
|
if (!pid) return false;
|
|
@@ -12342,7 +12454,7 @@ function pidIsAlive(pid, sessionId) {
|
|
|
12342
12454
|
return false;
|
|
12343
12455
|
}
|
|
12344
12456
|
if (sessionId) {
|
|
12345
|
-
if (!
|
|
12457
|
+
if (!import_node_fs21.default.existsSync(sessionDir(sessionId))) return false;
|
|
12346
12458
|
}
|
|
12347
12459
|
return true;
|
|
12348
12460
|
}
|
|
@@ -12355,11 +12467,11 @@ function resolveSootsimInvocation() {
|
|
|
12355
12467
|
const resourcesPath = process.resourcesPath;
|
|
12356
12468
|
if (resourcesPath) {
|
|
12357
12469
|
const candidates = [
|
|
12358
|
-
|
|
12359
|
-
|
|
12470
|
+
import_node_path22.default.join(resourcesPath, "bin", "sootsim"),
|
|
12471
|
+
import_node_path22.default.join(resourcesPath, "bin", `sootsim-${process.platform}-${process.arch}`)
|
|
12360
12472
|
];
|
|
12361
12473
|
for (const c of candidates) {
|
|
12362
|
-
if (
|
|
12474
|
+
if (import_node_fs21.default.existsSync(c)) return { executable: c, prefixArgs: [] };
|
|
12363
12475
|
}
|
|
12364
12476
|
}
|
|
12365
12477
|
}
|
|
@@ -12378,15 +12490,15 @@ function tryWorkspaceSootsim() {
|
|
|
12378
12490
|
const sootsimDir = resolveSootsimPackageDir();
|
|
12379
12491
|
if (!sootsimDir) return null;
|
|
12380
12492
|
const binaryName = `peach-${process.platform === "win32" ? "windows" : process.platform}-${process.arch}${process.platform === "win32" ? ".exe" : ""}`;
|
|
12381
|
-
const distBinary =
|
|
12382
|
-
if (
|
|
12383
|
-
const distBin =
|
|
12384
|
-
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)) {
|
|
12385
12497
|
try {
|
|
12386
|
-
const src =
|
|
12387
|
-
if (
|
|
12388
|
-
const srcMtime =
|
|
12389
|
-
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;
|
|
12390
12502
|
if (buildMtime < srcMtime) {
|
|
12391
12503
|
console.warn(
|
|
12392
12504
|
`[peach] dist-cli/bin.js is older than agent-wrapper.ts \u2014 rebuild with \`bun run --cwd packages/peachsim build:cli\`.`
|
|
@@ -12405,22 +12517,22 @@ function tryWorkspaceSootsim() {
|
|
|
12405
12517
|
function resolveSootsimPackageDir() {
|
|
12406
12518
|
try {
|
|
12407
12519
|
const resolved = require.resolve(`${rnxPublicBrand.packageName}/package.json`);
|
|
12408
|
-
return
|
|
12520
|
+
return import_node_path22.default.dirname(resolved);
|
|
12409
12521
|
} catch {
|
|
12410
12522
|
}
|
|
12411
12523
|
const here = fileFromImportMeta();
|
|
12412
12524
|
if (!here) return null;
|
|
12413
|
-
let cur =
|
|
12525
|
+
let cur = import_node_path22.default.dirname(here);
|
|
12414
12526
|
for (let i = 0; i < 8; i++) {
|
|
12415
|
-
const pkg =
|
|
12527
|
+
const pkg = import_node_path22.default.join(cur, "package.json");
|
|
12416
12528
|
try {
|
|
12417
|
-
if (
|
|
12418
|
-
const parsed = JSON.parse(
|
|
12529
|
+
if (import_node_fs21.default.existsSync(pkg)) {
|
|
12530
|
+
const parsed = JSON.parse(import_node_fs21.default.readFileSync(pkg, "utf8"));
|
|
12419
12531
|
if (parsed.name === rnxPublicBrand.packageName) return cur;
|
|
12420
12532
|
}
|
|
12421
12533
|
} catch {
|
|
12422
12534
|
}
|
|
12423
|
-
const parent =
|
|
12535
|
+
const parent = import_node_path22.default.dirname(cur);
|
|
12424
12536
|
if (parent === cur) break;
|
|
12425
12537
|
cur = parent;
|
|
12426
12538
|
}
|
|
@@ -12436,28 +12548,28 @@ function fileFromImportMeta() {
|
|
|
12436
12548
|
}
|
|
12437
12549
|
}
|
|
12438
12550
|
async function withStartLock(projectId, provider, fn) {
|
|
12439
|
-
const lockDir =
|
|
12440
|
-
|
|
12551
|
+
const lockDir = import_node_path22.default.join(getUserDataDir(), "locks");
|
|
12552
|
+
import_node_fs21.default.mkdirSync(lockDir, { recursive: true });
|
|
12441
12553
|
try {
|
|
12442
|
-
|
|
12554
|
+
import_node_fs21.default.chmodSync(lockDir, 448);
|
|
12443
12555
|
} catch {
|
|
12444
12556
|
}
|
|
12445
|
-
const lockPath =
|
|
12557
|
+
const lockPath = import_node_path22.default.join(lockDir, `start-${projectId}-${provider}.lock`);
|
|
12446
12558
|
const deadline = Date.now() + 4e3;
|
|
12447
12559
|
let fd = null;
|
|
12448
12560
|
while (fd === null) {
|
|
12449
12561
|
try {
|
|
12450
|
-
fd =
|
|
12562
|
+
fd = import_node_fs21.default.openSync(
|
|
12451
12563
|
lockPath,
|
|
12452
|
-
|
|
12564
|
+
import_node_fs21.constants.O_WRONLY | import_node_fs21.constants.O_CREAT | import_node_fs21.constants.O_EXCL,
|
|
12453
12565
|
384
|
|
12454
12566
|
);
|
|
12455
12567
|
} catch (err) {
|
|
12456
12568
|
if (err.code !== "EEXIST") throw err;
|
|
12457
12569
|
try {
|
|
12458
|
-
const stale = Number(
|
|
12570
|
+
const stale = Number(import_node_fs21.default.readFileSync(lockPath, "utf8").trim());
|
|
12459
12571
|
if (stale && !isProcessAlive(stale)) {
|
|
12460
|
-
|
|
12572
|
+
import_node_fs21.default.unlinkSync(lockPath);
|
|
12461
12573
|
continue;
|
|
12462
12574
|
}
|
|
12463
12575
|
} catch {
|
|
@@ -12471,15 +12583,15 @@ async function withStartLock(projectId, provider, fn) {
|
|
|
12471
12583
|
}
|
|
12472
12584
|
}
|
|
12473
12585
|
try {
|
|
12474
|
-
|
|
12586
|
+
import_node_fs21.default.writeFileSync(fd, String(process.pid));
|
|
12475
12587
|
return await fn();
|
|
12476
12588
|
} finally {
|
|
12477
12589
|
try {
|
|
12478
|
-
|
|
12590
|
+
import_node_fs21.default.closeSync(fd);
|
|
12479
12591
|
} catch {
|
|
12480
12592
|
}
|
|
12481
12593
|
try {
|
|
12482
|
-
|
|
12594
|
+
import_node_fs21.default.unlinkSync(lockPath);
|
|
12483
12595
|
} catch {
|
|
12484
12596
|
}
|
|
12485
12597
|
}
|
|
@@ -12493,25 +12605,25 @@ function isProcessAlive(pid) {
|
|
|
12493
12605
|
}
|
|
12494
12606
|
}
|
|
12495
12607
|
function mkfifoSync(p) {
|
|
12496
|
-
const parent =
|
|
12497
|
-
|
|
12608
|
+
const parent = import_node_path22.default.dirname(p);
|
|
12609
|
+
import_node_fs21.default.mkdirSync(parent, { recursive: true });
|
|
12498
12610
|
try {
|
|
12499
|
-
|
|
12611
|
+
import_node_fs21.default.chmodSync(parent, 448);
|
|
12500
12612
|
} catch {
|
|
12501
12613
|
}
|
|
12502
|
-
if (
|
|
12614
|
+
if (import_node_fs21.default.existsSync(p)) {
|
|
12503
12615
|
try {
|
|
12504
|
-
const stat2 =
|
|
12616
|
+
const stat2 = import_node_fs21.default.statSync(p);
|
|
12505
12617
|
if (stat2.isFIFO()) {
|
|
12506
12618
|
try {
|
|
12507
|
-
|
|
12619
|
+
import_node_fs21.default.chmodSync(p, 384);
|
|
12508
12620
|
} catch {
|
|
12509
12621
|
}
|
|
12510
12622
|
return;
|
|
12511
12623
|
}
|
|
12512
|
-
|
|
12624
|
+
import_node_fs21.default.unlinkSync(p);
|
|
12513
12625
|
} catch {
|
|
12514
|
-
|
|
12626
|
+
import_node_fs21.default.unlinkSync(p);
|
|
12515
12627
|
}
|
|
12516
12628
|
}
|
|
12517
12629
|
const result = (0, import_node_child_process9.spawnSync)("mkfifo", ["-m", "600", p]);
|
|
@@ -12544,7 +12656,7 @@ async function startSession(opts) {
|
|
|
12544
12656
|
`session already running for project=${project.id} provider=${provider} (session ${existingLive.id}, pid ${existingLive.wrapperPid}). end it first with \`peach agent end <sessionId>\`.`
|
|
12545
12657
|
);
|
|
12546
12658
|
}
|
|
12547
|
-
const claudeSessionUuid = provider === "claude" ? (0,
|
|
12659
|
+
const claudeSessionUuid = provider === "claude" ? (0, import_node_crypto10.randomUUID)() : void 0;
|
|
12548
12660
|
const session = upsertSession({
|
|
12549
12661
|
projectId: project.id,
|
|
12550
12662
|
provider,
|
|
@@ -12558,10 +12670,10 @@ async function startSession(opts) {
|
|
|
12558
12670
|
const transcript = transcriptPath(session.id);
|
|
12559
12671
|
mkfifoSync(promptIn);
|
|
12560
12672
|
mkfifoSync(eventsOut);
|
|
12561
|
-
const transcriptDir =
|
|
12562
|
-
|
|
12673
|
+
const transcriptDir = import_node_path22.default.dirname(transcript);
|
|
12674
|
+
import_node_fs21.default.mkdirSync(transcriptDir, { recursive: true });
|
|
12563
12675
|
try {
|
|
12564
|
-
|
|
12676
|
+
import_node_fs21.default.chmodSync(transcriptDir, 448);
|
|
12565
12677
|
} catch {
|
|
12566
12678
|
}
|
|
12567
12679
|
const { executable, prefixArgs } = resolveSootsimInvocation();
|
|
@@ -12612,7 +12724,7 @@ async function startSession(opts) {
|
|
|
12612
12724
|
}
|
|
12613
12725
|
}
|
|
12614
12726
|
try {
|
|
12615
|
-
|
|
12727
|
+
import_node_fs21.default.rmSync(sessionDir(session.id), { recursive: true, force: true });
|
|
12616
12728
|
} catch {
|
|
12617
12729
|
}
|
|
12618
12730
|
updateSessionStatus(session.id, { status: "ended" });
|
|
@@ -12640,18 +12752,18 @@ async function sendPrompt(sessionId, prompt) {
|
|
|
12640
12752
|
);
|
|
12641
12753
|
}
|
|
12642
12754
|
const fifo = promptFifoPath(sessionId);
|
|
12643
|
-
if (!
|
|
12755
|
+
if (!import_node_fs21.default.existsSync(fifo)) {
|
|
12644
12756
|
throw new AgentSessionError("NO_FIFO", `prompt FIFO missing: ${fifo}`);
|
|
12645
12757
|
}
|
|
12646
|
-
const fd =
|
|
12758
|
+
const fd = import_node_fs21.default.openSync(fifo, import_node_fs21.constants.O_WRONLY);
|
|
12647
12759
|
try {
|
|
12648
12760
|
const wireText = encodeAgentPromptEnvelope(prompt);
|
|
12649
12761
|
if (!wireText) {
|
|
12650
12762
|
throw new AgentSessionError("EMPTY_PROMPT", "prompt text is empty");
|
|
12651
12763
|
}
|
|
12652
|
-
|
|
12764
|
+
import_node_fs21.default.writeSync(fd, wireText + "\n");
|
|
12653
12765
|
} finally {
|
|
12654
|
-
|
|
12766
|
+
import_node_fs21.default.closeSync(fd);
|
|
12655
12767
|
}
|
|
12656
12768
|
updateSessionStatus(sessionId, {
|
|
12657
12769
|
lastPrompt: prompt.displayText ?? prompt.text,
|
|
@@ -12673,7 +12785,7 @@ async function endSession(sessionId) {
|
|
|
12673
12785
|
const base = getUserDataDir();
|
|
12674
12786
|
if (dir.startsWith(base)) {
|
|
12675
12787
|
try {
|
|
12676
|
-
|
|
12788
|
+
import_node_fs21.default.rmSync(dir, { recursive: true, force: true });
|
|
12677
12789
|
} catch {
|
|
12678
12790
|
}
|
|
12679
12791
|
}
|
|
@@ -12681,11 +12793,11 @@ async function endSession(sessionId) {
|
|
|
12681
12793
|
}
|
|
12682
12794
|
function subscribeEvents(sessionId, onEvent) {
|
|
12683
12795
|
const fifo = eventsFifoPath(sessionId);
|
|
12684
|
-
if (!
|
|
12796
|
+
if (!import_node_fs21.default.existsSync(fifo)) {
|
|
12685
12797
|
throw new AgentSessionError("NO_FIFO", `events FIFO missing: ${fifo}`);
|
|
12686
12798
|
}
|
|
12687
|
-
const fd =
|
|
12688
|
-
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 });
|
|
12689
12801
|
const rl = import_node_readline.default.createInterface({ input: stream, crlfDelay: Infinity });
|
|
12690
12802
|
rl.on("line", (line) => {
|
|
12691
12803
|
const event = parseAgentEventLine(line);
|
|
@@ -12696,7 +12808,7 @@ function subscribeEvents(sessionId, onEvent) {
|
|
|
12696
12808
|
if (closed) return;
|
|
12697
12809
|
closed = true;
|
|
12698
12810
|
try {
|
|
12699
|
-
|
|
12811
|
+
import_node_fs21.default.writeSync(fd, "\n");
|
|
12700
12812
|
} catch {
|
|
12701
12813
|
}
|
|
12702
12814
|
try {
|
|
@@ -12710,7 +12822,7 @@ function subscribeEvents(sessionId, onEvent) {
|
|
|
12710
12822
|
};
|
|
12711
12823
|
}
|
|
12712
12824
|
async function waitForFirstEvent(fifo, predicate, timeoutMs) {
|
|
12713
|
-
const fd =
|
|
12825
|
+
const fd = import_node_fs21.default.openSync(fifo, import_node_fs21.constants.O_RDWR | import_node_fs21.constants.O_NONBLOCK);
|
|
12714
12826
|
const buf = Buffer.alloc(8192);
|
|
12715
12827
|
let leftover = "";
|
|
12716
12828
|
const deadline = Date.now() + timeoutMs;
|
|
@@ -12718,7 +12830,7 @@ async function waitForFirstEvent(fifo, predicate, timeoutMs) {
|
|
|
12718
12830
|
while (Date.now() < deadline) {
|
|
12719
12831
|
let n = 0;
|
|
12720
12832
|
try {
|
|
12721
|
-
n =
|
|
12833
|
+
n = import_node_fs21.default.readSync(fd, buf, 0, buf.length, null);
|
|
12722
12834
|
} catch (err) {
|
|
12723
12835
|
if (err.code !== "EAGAIN") throw err;
|
|
12724
12836
|
n = 0;
|
|
@@ -12738,7 +12850,7 @@ async function waitForFirstEvent(fifo, predicate, timeoutMs) {
|
|
|
12738
12850
|
}
|
|
12739
12851
|
return null;
|
|
12740
12852
|
} finally {
|
|
12741
|
-
|
|
12853
|
+
import_node_fs21.default.closeSync(fd);
|
|
12742
12854
|
}
|
|
12743
12855
|
}
|
|
12744
12856
|
|
|
@@ -12946,7 +13058,7 @@ var AgentHost = class {
|
|
|
12946
13058
|
throw new AgentSessionError("EMPTY_PROMPT", "inspect message cannot be empty");
|
|
12947
13059
|
}
|
|
12948
13060
|
const message = {
|
|
12949
|
-
id: `inspect-${(0,
|
|
13061
|
+
id: `inspect-${(0, import_node_crypto11.randomUUID)()}`,
|
|
12950
13062
|
simId,
|
|
12951
13063
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
12952
13064
|
prompt
|
|
@@ -12992,7 +13104,7 @@ var AgentHost = class {
|
|
|
12992
13104
|
);
|
|
12993
13105
|
const project = upsertProject({
|
|
12994
13106
|
cwd: match.cwd,
|
|
12995
|
-
name: match.projectName ??
|
|
13107
|
+
name: match.projectName ?? import_node_path23.default.basename(match.cwd),
|
|
12996
13108
|
preferredProvider: input.provider ?? existing?.preferredProvider,
|
|
12997
13109
|
sourceRoots: existing?.sourceRoots ?? [match.cwd],
|
|
12998
13110
|
knownBundleUrls,
|
|
@@ -13003,18 +13115,18 @@ var AgentHost = class {
|
|
|
13003
13115
|
}
|
|
13004
13116
|
getTranscript(sessionId) {
|
|
13005
13117
|
const p = transcriptPath(sessionId);
|
|
13006
|
-
if (!
|
|
13118
|
+
if (!import_node_fs22.default.existsSync(p)) {
|
|
13007
13119
|
return { error: "transcript not found", code: "NO_TRANSCRIPT" };
|
|
13008
13120
|
}
|
|
13009
|
-
return
|
|
13121
|
+
return import_node_fs22.default.readFileSync(p, "utf8");
|
|
13010
13122
|
}
|
|
13011
13123
|
getPaths() {
|
|
13012
13124
|
const dir = getUserDataDir();
|
|
13013
13125
|
return {
|
|
13014
13126
|
userDataDir: dir,
|
|
13015
|
-
storeFile:
|
|
13016
|
-
sessionsDir:
|
|
13017
|
-
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")
|
|
13018
13130
|
};
|
|
13019
13131
|
}
|
|
13020
13132
|
// --- subscription management ---
|
|
@@ -13715,7 +13827,7 @@ function handleAppApiRequest(req, res) {
|
|
|
13715
13827
|
}
|
|
13716
13828
|
|
|
13717
13829
|
// src/host/fetch-proxy-transport.ts
|
|
13718
|
-
var
|
|
13830
|
+
var import_node_crypto12 = require("node:crypto");
|
|
13719
13831
|
var import_node_http22 = require("node:http2");
|
|
13720
13832
|
var import_x509 = require("@peculiar/x509");
|
|
13721
13833
|
async function startFetchProxyTransport() {
|
|
@@ -13723,7 +13835,7 @@ async function startFetchProxyTransport() {
|
|
|
13723
13835
|
const keys = await crypto.subtle.generateKey(algorithm, true, ["sign", "verify"]);
|
|
13724
13836
|
const certificate = await import_x509.X509CertificateGenerator.createSelfSigned(
|
|
13725
13837
|
{
|
|
13726
|
-
serialNumber: (0,
|
|
13838
|
+
serialNumber: (0, import_node_crypto12.randomBytes)(16).toString("hex"),
|
|
13727
13839
|
name: "CN=localhost",
|
|
13728
13840
|
notBefore: new Date(Date.now() - 6e4),
|
|
13729
13841
|
notAfter: new Date(Date.now() + 365 * 24 * 60 * 6e4),
|
|
@@ -13736,7 +13848,7 @@ async function startFetchProxyTransport() {
|
|
|
13736
13848
|
crypto
|
|
13737
13849
|
);
|
|
13738
13850
|
const privateKey = Buffer.from(await crypto.subtle.exportKey("pkcs8", keys.privateKey));
|
|
13739
|
-
const spki = (0,
|
|
13851
|
+
const spki = (0, import_node_crypto12.createHash)("sha256").update(Buffer.from(await crypto.subtle.exportKey("spki", keys.publicKey))).digest("base64");
|
|
13740
13852
|
const sessions = /* @__PURE__ */ new Set();
|
|
13741
13853
|
const server = (0, import_node_http22.createSecureServer)(
|
|
13742
13854
|
{
|
|
@@ -13858,8 +13970,8 @@ async function openUrl(url, options = {}) {
|
|
|
13858
13970
|
}
|
|
13859
13971
|
|
|
13860
13972
|
// src/host/plane-host.ts
|
|
13861
|
-
var
|
|
13862
|
-
var
|
|
13973
|
+
var import_node_fs24 = __toESM(require("node:fs"), 1);
|
|
13974
|
+
var import_node_path25 = __toESM(require("node:path"), 1);
|
|
13863
13975
|
|
|
13864
13976
|
// ../peach-box/src/planeProtocol.ts
|
|
13865
13977
|
var PLANE_FLAG_READ_ONLY = 1;
|
|
@@ -13939,8 +14051,8 @@ async function dispatchPlaneCommand(plane, type, msg, mutationOptions) {
|
|
|
13939
14051
|
|
|
13940
14052
|
// cli/commands/box/checkout-plane.ts
|
|
13941
14053
|
var import_node_child_process10 = require("node:child_process");
|
|
13942
|
-
var
|
|
13943
|
-
var
|
|
14054
|
+
var import_node_fs23 = __toESM(require("node:fs"), 1);
|
|
14055
|
+
var import_node_path24 = __toESM(require("node:path"), 1);
|
|
13944
14056
|
var CheckoutRequiresGitError = class extends Error {
|
|
13945
14057
|
};
|
|
13946
14058
|
var BINARY_SNIFF_BYTES = 8192;
|
|
@@ -13951,14 +14063,14 @@ function looksBinary(filePath, size) {
|
|
|
13951
14063
|
if (size === 0) return false;
|
|
13952
14064
|
let fd;
|
|
13953
14065
|
try {
|
|
13954
|
-
fd =
|
|
14066
|
+
fd = import_node_fs23.default.openSync(filePath, "r");
|
|
13955
14067
|
const buffer = Buffer.alloc(Math.min(BINARY_SNIFF_BYTES, size));
|
|
13956
|
-
const read =
|
|
14068
|
+
const read = import_node_fs23.default.readSync(fd, buffer, 0, buffer.length, 0);
|
|
13957
14069
|
return buffer.subarray(0, read).includes(0);
|
|
13958
14070
|
} catch {
|
|
13959
14071
|
return false;
|
|
13960
14072
|
} finally {
|
|
13961
|
-
if (fd !== void 0)
|
|
14073
|
+
if (fd !== void 0) import_node_fs23.default.closeSync(fd);
|
|
13962
14074
|
}
|
|
13963
14075
|
}
|
|
13964
14076
|
var CheckoutFilePlane = class {
|
|
@@ -13971,7 +14083,7 @@ var CheckoutFilePlane = class {
|
|
|
13971
14083
|
listTimeoutMs;
|
|
13972
14084
|
trackedOnly;
|
|
13973
14085
|
constructor(root, options = {}) {
|
|
13974
|
-
this.root =
|
|
14086
|
+
this.root = import_node_path24.default.resolve(root);
|
|
13975
14087
|
this.listTimeoutMs = options.listTimeoutMs ?? LIST_FILES_TIMEOUT_MS;
|
|
13976
14088
|
this.trackedOnly = options.trackedOnly ?? false;
|
|
13977
14089
|
}
|
|
@@ -14033,13 +14145,13 @@ var CheckoutFilePlane = class {
|
|
|
14033
14145
|
if (!relative2) continue;
|
|
14034
14146
|
let stat2;
|
|
14035
14147
|
try {
|
|
14036
|
-
stat2 =
|
|
14148
|
+
stat2 = import_node_fs23.default.statSync(import_node_path24.default.join(this.root, relative2));
|
|
14037
14149
|
} catch {
|
|
14038
14150
|
continue;
|
|
14039
14151
|
}
|
|
14040
14152
|
if (!stat2.isFile()) continue;
|
|
14041
14153
|
const seen = this.sniffed.get(relative2);
|
|
14042
|
-
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);
|
|
14043
14155
|
nextSniffed.set(relative2, { size: stat2.size, mtimeMs: stat2.mtimeMs, binary });
|
|
14044
14156
|
next.set(relative2, {
|
|
14045
14157
|
size: stat2.size,
|
|
@@ -14053,22 +14165,22 @@ var CheckoutFilePlane = class {
|
|
|
14053
14165
|
this.sniffed = nextSniffed;
|
|
14054
14166
|
}
|
|
14055
14167
|
absolute(planePath) {
|
|
14056
|
-
const resolved =
|
|
14057
|
-
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}`)) {
|
|
14058
14170
|
throw new Error(`path escapes the project: ${planePath}`);
|
|
14059
14171
|
}
|
|
14060
14172
|
return resolved;
|
|
14061
14173
|
}
|
|
14062
14174
|
async read(planePath) {
|
|
14063
|
-
return
|
|
14175
|
+
return import_node_fs23.default.promises.readFile(this.absolute(planePath), "utf8");
|
|
14064
14176
|
}
|
|
14065
14177
|
async readBytes(planePath) {
|
|
14066
|
-
return
|
|
14178
|
+
return import_node_fs23.default.promises.readFile(this.absolute(planePath));
|
|
14067
14179
|
}
|
|
14068
14180
|
async write(planePath, content) {
|
|
14069
14181
|
const absolute = this.absolute(planePath);
|
|
14070
|
-
await
|
|
14071
|
-
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);
|
|
14072
14184
|
this.entries.set(planePath, {
|
|
14073
14185
|
size: content.byteLength,
|
|
14074
14186
|
readOnly: false,
|
|
@@ -14077,7 +14189,7 @@ var CheckoutFilePlane = class {
|
|
|
14077
14189
|
});
|
|
14078
14190
|
}
|
|
14079
14191
|
async delete(planePath) {
|
|
14080
|
-
await
|
|
14192
|
+
await import_node_fs23.default.promises.rm(this.absolute(planePath), { force: true });
|
|
14081
14193
|
this.entries.delete(planePath);
|
|
14082
14194
|
}
|
|
14083
14195
|
};
|
|
@@ -14203,14 +14315,14 @@ var PlaneHost = class {
|
|
|
14203
14315
|
// root and an opened one cannot disagree about the same directory.
|
|
14204
14316
|
realRoot(root) {
|
|
14205
14317
|
if (!root) throw new Error("root is required");
|
|
14206
|
-
const resolved =
|
|
14318
|
+
const resolved = import_node_path25.default.resolve(root);
|
|
14207
14319
|
let real;
|
|
14208
14320
|
try {
|
|
14209
|
-
real =
|
|
14321
|
+
real = import_node_fs24.default.realpathSync(resolved);
|
|
14210
14322
|
} catch {
|
|
14211
14323
|
throw new Error(`no such directory: ${resolved}`);
|
|
14212
14324
|
}
|
|
14213
|
-
if (!
|
|
14325
|
+
if (!import_node_fs24.default.statSync(real).isDirectory()) throw new Error(`not a directory: ${real}`);
|
|
14214
14326
|
return real;
|
|
14215
14327
|
}
|
|
14216
14328
|
respond(ws, id, result) {
|
|
@@ -14230,9 +14342,9 @@ var PlaneHost = class {
|
|
|
14230
14342
|
};
|
|
14231
14343
|
|
|
14232
14344
|
// src/host/replacement-module-handler.ts
|
|
14233
|
-
var
|
|
14345
|
+
var import_node_fs25 = require("node:fs");
|
|
14234
14346
|
var import_promises5 = __toESM(require("node:fs/promises"), 1);
|
|
14235
|
-
var
|
|
14347
|
+
var import_node_path26 = __toESM(require("node:path"), 1);
|
|
14236
14348
|
|
|
14237
14349
|
// ../contrast-bundler/src/replacementModule.ts
|
|
14238
14350
|
var import_dist = require("sucrase/dist/index.js");
|
|
@@ -14560,16 +14672,16 @@ function sendJavaScript(req, res, source) {
|
|
|
14560
14672
|
res.end(req.method === "HEAD" ? void 0 : source);
|
|
14561
14673
|
}
|
|
14562
14674
|
function resolveReplacementModuleFile(fromFile, specifier) {
|
|
14563
|
-
const base =
|
|
14675
|
+
const base = import_node_path26.default.resolve(import_node_path26.default.dirname(fromFile), specifier);
|
|
14564
14676
|
const candidates = [
|
|
14565
14677
|
...REPLACEMENT_MODULE_EXTENSIONS.some(
|
|
14566
|
-
(ext) => ext ===
|
|
14678
|
+
(ext) => ext === import_node_path26.default.extname(base).toLowerCase()
|
|
14567
14679
|
) ? [base] : [],
|
|
14568
14680
|
...REPLACEMENT_MODULE_EXTENSIONS.map((ext) => base + ext),
|
|
14569
|
-
...REPLACEMENT_MODULE_EXTENSIONS.map((ext) =>
|
|
14681
|
+
...REPLACEMENT_MODULE_EXTENSIONS.map((ext) => import_node_path26.default.join(base, `index${ext}`))
|
|
14570
14682
|
];
|
|
14571
14683
|
const found = candidates.find(
|
|
14572
|
-
(candidate) => (0,
|
|
14684
|
+
(candidate) => (0, import_node_fs25.statSync)(candidate, { throwIfNoEntry: false })?.isFile()
|
|
14573
14685
|
);
|
|
14574
14686
|
if (!found) {
|
|
14575
14687
|
throw new Error(
|
|
@@ -14624,13 +14736,13 @@ async function handleReplacementModuleRequest(req, res, options = {}) {
|
|
|
14624
14736
|
res.end("missing path param");
|
|
14625
14737
|
return true;
|
|
14626
14738
|
}
|
|
14627
|
-
const extension =
|
|
14739
|
+
const extension = import_node_path26.default.extname(targetPath).toLowerCase();
|
|
14628
14740
|
if (!REPLACEMENT_MODULE_EXTENSIONS.some((allowed) => allowed === extension)) {
|
|
14629
14741
|
res.writeHead(400, { "Content-Type": "text/plain; charset=utf-8" });
|
|
14630
14742
|
res.end(`replacement files must be ${REPLACEMENT_MODULE_EXTENSIONS.join(", ")}`);
|
|
14631
14743
|
return true;
|
|
14632
14744
|
}
|
|
14633
|
-
if (!
|
|
14745
|
+
if (!import_node_path26.default.isAbsolute(targetPath)) {
|
|
14634
14746
|
res.writeHead(400, { "Content-Type": "text/plain; charset=utf-8" });
|
|
14635
14747
|
res.end("replacement file path must be absolute");
|
|
14636
14748
|
return true;
|
|
@@ -14638,10 +14750,10 @@ async function handleReplacementModuleRequest(req, res, options = {}) {
|
|
|
14638
14750
|
const runtimePackages = new Set(url.searchParams.getAll("runtimePackage"));
|
|
14639
14751
|
let resolvedProjectRoot;
|
|
14640
14752
|
if (options.projectRoot) {
|
|
14641
|
-
const lexicalProjectRoot =
|
|
14753
|
+
const lexicalProjectRoot = import_node_path26.default.resolve(options.projectRoot);
|
|
14642
14754
|
resolvedProjectRoot = await import_promises5.default.realpath(options.projectRoot);
|
|
14643
|
-
const lexicalTarget =
|
|
14644
|
-
if (lexicalTarget.startsWith("..") ||
|
|
14755
|
+
const lexicalTarget = import_node_path26.default.relative(lexicalProjectRoot, targetPath);
|
|
14756
|
+
if (lexicalTarget.startsWith("..") || import_node_path26.default.isAbsolute(lexicalTarget)) {
|
|
14645
14757
|
res.writeHead(403, { "Content-Type": "text/plain; charset=utf-8" });
|
|
14646
14758
|
res.end("replacement file must be inside the project root");
|
|
14647
14759
|
return true;
|
|
@@ -14657,8 +14769,8 @@ async function handleReplacementModuleRequest(req, res, options = {}) {
|
|
|
14657
14769
|
return true;
|
|
14658
14770
|
}
|
|
14659
14771
|
if (resolvedProjectRoot) {
|
|
14660
|
-
const relativeTarget =
|
|
14661
|
-
if (relativeTarget.startsWith("..") ||
|
|
14772
|
+
const relativeTarget = import_node_path26.default.relative(resolvedProjectRoot, resolvedTargetPath);
|
|
14773
|
+
if (relativeTarget.startsWith("..") || import_node_path26.default.isAbsolute(relativeTarget)) {
|
|
14662
14774
|
res.writeHead(403, { "Content-Type": "text/plain; charset=utf-8" });
|
|
14663
14775
|
res.end("replacement file must be inside the project root");
|
|
14664
14776
|
return true;
|