peachsim 0.1.769 → 0.1.771
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/main.ts +5 -1
- package/cli/outbound-endpoints.ts +14 -0
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/agent-identity.cjs +1 -1
- package/dist-lib/agent-sessions.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -1
- package/dist-lib/auth/shared-session.cjs +1 -1
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/beta.cjs +1 -1
- package/dist-lib/beta.mjs +1 -1
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/bridge-contract-input.cjs +1 -1
- package/dist-lib/bridge-contract-input.mjs +1 -1
- package/dist-lib/bridge-contract.cjs +1 -1
- package/dist-lib/bridge-contract.mjs +1 -1
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +1 -1
- package/dist-lib/cli-constants.cjs +1 -1
- package/dist-lib/cloud-contract.cjs +1 -1
- package/dist-lib/cloud-contract.mjs +1 -1
- package/dist-lib/cloud-test-args.cjs +1 -1
- package/dist-lib/cloud-test-args.mjs +1 -1
- package/dist-lib/cloud.cjs +1 -1
- package/dist-lib/cloud.mjs +1 -1
- package/dist-lib/config.cjs +1 -1
- package/dist-lib/detox/index.cjs +1 -1
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +563 -439
- 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 +832 -701
- package/dist-lib/swift-compile.cjs +18 -4
- package/dist-lib/swift-compile.mjs +17 -4
- 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 +396 -272
- package/dist-lib/vite.cjs +1 -1
- package/package.json +1 -1
- package/src/swift-binary-modules.ts +116 -0
- package/src/swift-compile.ts +28 -3
- 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.771 | (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
|
|
@@ -6922,7 +6922,7 @@ var ONE_IMPLICIT_FLAGS = ', "-Xfrontend", "-import-module", "-Xfrontend", "One"'
|
|
|
6922
6922
|
var MULTI_MANIFEST_VERSION = 11;
|
|
6923
6923
|
function swiftArtifactHash(input, release, moduleRoot) {
|
|
6924
6924
|
const hash = (0, import_node_crypto3.createHash)("sha256");
|
|
6925
|
-
hash.update(`swift-compile/
|
|
6925
|
+
hash.update(`swift-compile/v18
|
|
6926
6926
|
${release}
|
|
6927
6927
|
`);
|
|
6928
6928
|
if (input.oneModule) hash.update("one-module\n");
|
|
@@ -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: [
|
|
@@ -7453,6 +7453,18 @@ function lowerAVAssetURLCluster(source) {
|
|
|
7453
7453
|
out = out.slice(0, at) + insert + out.slice(at + remove);
|
|
7454
7454
|
return out;
|
|
7455
7455
|
}
|
|
7456
|
+
function lowerNSValueTimeBox(source) {
|
|
7457
|
+
const masked = swiftCodeMask(source);
|
|
7458
|
+
const pattern = /\bNSValue\s*\(\s*time\s*:/g;
|
|
7459
|
+
const edits = [];
|
|
7460
|
+
let hit;
|
|
7461
|
+
while ((hit = pattern.exec(masked)) !== null)
|
|
7462
|
+
edits.push([hit.index, "NSValue".length, "NSValue.boxedTime"]);
|
|
7463
|
+
let out = source;
|
|
7464
|
+
for (const [at, remove, insert] of edits.sort((a, b) => b[0] - a[0]))
|
|
7465
|
+
out = out.slice(0, at) + insert + out.slice(at + remove);
|
|
7466
|
+
return out;
|
|
7467
|
+
}
|
|
7456
7468
|
function swiftCodeMask(source) {
|
|
7457
7469
|
const chars = source.split("");
|
|
7458
7470
|
const blank = (from, to) => {
|
|
@@ -7656,8 +7668,8 @@ function swiftSourceAsIOS(original, extraObjCExtensions) {
|
|
|
7656
7668
|
out += conditioned.slice(copied, at) + replacement;
|
|
7657
7669
|
copied = at + match[0].length;
|
|
7658
7670
|
}
|
|
7659
|
-
return
|
|
7660
|
-
lowerAnyObjectDoubleValue(out + conditioned.slice(copied))
|
|
7671
|
+
return lowerNSValueTimeBox(
|
|
7672
|
+
lowerAVAssetURLCluster(lowerAnyObjectDoubleValue(out + conditioned.slice(copied)))
|
|
7661
7673
|
);
|
|
7662
7674
|
}
|
|
7663
7675
|
function swiftCodeScan(source) {
|
|
@@ -8604,10 +8616,10 @@ function swiftModuleToolchain(root) {
|
|
|
8604
8616
|
}
|
|
8605
8617
|
|
|
8606
8618
|
// src/swift-host.ts
|
|
8607
|
-
var
|
|
8608
|
-
var
|
|
8609
|
-
var
|
|
8610
|
-
var
|
|
8619
|
+
var import_node_crypto7 = require("node:crypto");
|
|
8620
|
+
var import_node_fs17 = __toESM(require("node:fs"), 1);
|
|
8621
|
+
var import_node_os7 = __toESM(require("node:os"), 1);
|
|
8622
|
+
var import_node_path18 = __toESM(require("node:path"), 1);
|
|
8611
8623
|
|
|
8612
8624
|
// ../sootsim-swift/src/bundleAssets.ts
|
|
8613
8625
|
var import_svgpath = __toESM(require("svgpath"), 1);
|
|
@@ -8641,8 +8653,8 @@ function pickImagesetFile(images) {
|
|
|
8641
8653
|
scale: pick.scale === "2x" ? 2 : pick.scale === "3x" ? 3 : 1
|
|
8642
8654
|
};
|
|
8643
8655
|
}
|
|
8644
|
-
function flatScale(
|
|
8645
|
-
const match = /@([23])x\.[^./]+$/.exec(
|
|
8656
|
+
function flatScale(path23) {
|
|
8657
|
+
const match = /@([23])x\.[^./]+$/.exec(path23);
|
|
8646
8658
|
return match ? Number(match[1]) : 1;
|
|
8647
8659
|
}
|
|
8648
8660
|
function providesNamespace(text2) {
|
|
@@ -8669,13 +8681,13 @@ function catalogEntryName(contentsPath, kind, readText) {
|
|
|
8669
8681
|
}
|
|
8670
8682
|
return segments.join("/");
|
|
8671
8683
|
}
|
|
8672
|
-
function isFlatResourceImage(
|
|
8673
|
-
return
|
|
8684
|
+
function isFlatResourceImage(path23) {
|
|
8685
|
+
return path23.split("/").includes("Resources") && RASTER_EXTENSIONS.has(extOf(path23));
|
|
8674
8686
|
}
|
|
8675
8687
|
function enumerateBundleImages(paths, readText) {
|
|
8676
8688
|
const table = [];
|
|
8677
8689
|
const seen = /* @__PURE__ */ new Set();
|
|
8678
|
-
const catalogs = paths.filter((
|
|
8690
|
+
const catalogs = paths.filter((path23) => baseOf(path23) === "Contents.json");
|
|
8679
8691
|
for (const contentsPath of catalogs) {
|
|
8680
8692
|
const name2 = catalogEntryName(contentsPath, ".imageset", readText);
|
|
8681
8693
|
if (name2 === null || seen.has(name2)) continue;
|
|
@@ -8696,12 +8708,12 @@ function enumerateBundleImages(paths, readText) {
|
|
|
8696
8708
|
seen.add(name2);
|
|
8697
8709
|
table.push({ name: name2, file: `${dir}/${pick.filename}`, scale: pick.scale });
|
|
8698
8710
|
}
|
|
8699
|
-
for (const
|
|
8700
|
-
if (!isFlatResourceImage(
|
|
8701
|
-
const name2 = baseOf(
|
|
8711
|
+
for (const path23 of paths) {
|
|
8712
|
+
if (!isFlatResourceImage(path23)) continue;
|
|
8713
|
+
const name2 = baseOf(path23).slice(0, -extOf(path23).length);
|
|
8702
8714
|
if (name2 === "" || seen.has(name2)) continue;
|
|
8703
8715
|
seen.add(name2);
|
|
8704
|
-
table.push({ name: name2, file:
|
|
8716
|
+
table.push({ name: name2, file: path23, scale: flatScale(path23) });
|
|
8705
8717
|
}
|
|
8706
8718
|
return table;
|
|
8707
8719
|
}
|
|
@@ -8730,7 +8742,7 @@ function colorsetValue(color) {
|
|
|
8730
8742
|
}
|
|
8731
8743
|
function enumerateBundleColors(paths, readText) {
|
|
8732
8744
|
const table = {};
|
|
8733
|
-
for (const contentsPath of paths.filter((
|
|
8745
|
+
for (const contentsPath of paths.filter((path23) => baseOf(path23) === "Contents.json")) {
|
|
8734
8746
|
const name2 = catalogEntryName(contentsPath, ".colorset", readText);
|
|
8735
8747
|
if (name2 === null || name2 in table) continue;
|
|
8736
8748
|
let colors;
|
|
@@ -8795,8 +8807,8 @@ function axisExtremes(points) {
|
|
|
8795
8807
|
function pathBounds(d) {
|
|
8796
8808
|
const xs = [];
|
|
8797
8809
|
const ys = [];
|
|
8798
|
-
for (const
|
|
8799
|
-
(0, import_svgpath.default)(
|
|
8810
|
+
for (const path23 of d)
|
|
8811
|
+
(0, import_svgpath.default)(path23).abs().unshort().unarc().iterate((segment, _index, x, y) => {
|
|
8800
8812
|
const [command, ...args] = segment;
|
|
8801
8813
|
if (command === "M" || command === "L") {
|
|
8802
8814
|
xs.push(Number(args[0]));
|
|
@@ -8823,7 +8835,7 @@ function guide(svg, id, axis) {
|
|
|
8823
8835
|
}
|
|
8824
8836
|
function enumerateBundleSymbols(paths, readText) {
|
|
8825
8837
|
const table = {};
|
|
8826
|
-
for (const contentsPath of paths.filter((
|
|
8838
|
+
for (const contentsPath of paths.filter((path23) => baseOf(path23) === "Contents.json")) {
|
|
8827
8839
|
const name2 = catalogEntryName(contentsPath, ".symbolset", readText);
|
|
8828
8840
|
if (name2 === null || name2 in table) continue;
|
|
8829
8841
|
let symbols;
|
|
@@ -8856,8 +8868,8 @@ function enumerateBundleSymbols(paths, readText) {
|
|
|
8856
8868
|
viewBox: "0 0 24 24",
|
|
8857
8869
|
advance,
|
|
8858
8870
|
box: [12 - advance / 2, 12 - tall / 2, advance, tall],
|
|
8859
|
-
layers: d.map((
|
|
8860
|
-
d: (0, import_svgpath.default)(
|
|
8871
|
+
layers: d.map((path23) => ({
|
|
8872
|
+
d: (0, import_svgpath.default)(path23).abs().scale(scale).translate(translateX, translateY).round(3).toString()
|
|
8861
8873
|
}))
|
|
8862
8874
|
};
|
|
8863
8875
|
}
|
|
@@ -8867,7 +8879,7 @@ function enumerateBundleJson(paths) {
|
|
|
8867
8879
|
const found = [];
|
|
8868
8880
|
const seen = /* @__PURE__ */ new Set();
|
|
8869
8881
|
const ordered = [...paths].filter(
|
|
8870
|
-
(
|
|
8882
|
+
(path23) => path23.split("/").includes("Resources") && path23.split("/").every((segment) => segment !== "" && segment !== "..") && (extOf(path23) === ".json" || extOf(path23) === ".xcstrings")
|
|
8871
8883
|
).sort((a, b) => {
|
|
8872
8884
|
const aDepth = a.split("/").length;
|
|
8873
8885
|
const bDepth = b.split("/").length;
|
|
@@ -9177,17 +9189,101 @@ var ios_sdk_frameworks_default = {
|
|
|
9177
9189
|
]
|
|
9178
9190
|
};
|
|
9179
9191
|
|
|
9192
|
+
// src/swift-binary-modules.ts
|
|
9193
|
+
var import_node_crypto5 = require("node:crypto");
|
|
9194
|
+
var import_node_fs13 = __toESM(require("node:fs"), 1);
|
|
9195
|
+
var import_node_os5 = __toESM(require("node:os"), 1);
|
|
9196
|
+
var import_node_path13 = __toESM(require("node:path"), 1);
|
|
9197
|
+
var cacheDir2 = import_node_path13.default.join(import_node_os5.default.tmpdir(), "peach-swift-binary-modules");
|
|
9198
|
+
function frameworkModules(paths) {
|
|
9199
|
+
const modules = /* @__PURE__ */ new Set();
|
|
9200
|
+
for (const file of paths) {
|
|
9201
|
+
const segment = file.split("/").find((part) => part.endsWith(".framework"));
|
|
9202
|
+
if (segment) modules.add(segment.slice(0, -".framework".length));
|
|
9203
|
+
}
|
|
9204
|
+
return [...modules].sort();
|
|
9205
|
+
}
|
|
9206
|
+
async function range(url, spec) {
|
|
9207
|
+
const response = await fetch(url, {
|
|
9208
|
+
headers: { range: `bytes=${spec}` },
|
|
9209
|
+
signal: AbortSignal.timeout(2e4)
|
|
9210
|
+
});
|
|
9211
|
+
const match = /^bytes (\d+)-\d+\/(\d+)$/.exec(
|
|
9212
|
+
response.headers.get("content-range") ?? ""
|
|
9213
|
+
);
|
|
9214
|
+
if (response.status !== 206 || !match)
|
|
9215
|
+
throw new Error(`${url} answered ${response.status} to a range request`);
|
|
9216
|
+
return {
|
|
9217
|
+
bytes: Buffer.from(await response.arrayBuffer()),
|
|
9218
|
+
start: Number(match[1]),
|
|
9219
|
+
total: Number(match[2])
|
|
9220
|
+
};
|
|
9221
|
+
}
|
|
9222
|
+
var signature = (bytes, value) => {
|
|
9223
|
+
const needle = Buffer.alloc(4);
|
|
9224
|
+
needle.writeUInt32LE(value);
|
|
9225
|
+
return bytes.lastIndexOf(needle);
|
|
9226
|
+
};
|
|
9227
|
+
async function zipEntries(url) {
|
|
9228
|
+
const { total } = await range(url, "0-0");
|
|
9229
|
+
const tail = await range(url, `${Math.max(0, total - 65558)}-${total - 1}`);
|
|
9230
|
+
const end = signature(tail.bytes, 101010256);
|
|
9231
|
+
if (end < 0) throw new Error(`${url} has no zip end record`);
|
|
9232
|
+
let size = tail.bytes.readUInt32LE(end + 12);
|
|
9233
|
+
let offset = tail.bytes.readUInt32LE(end + 16);
|
|
9234
|
+
if (offset === 4294967295 || size === 4294967295) {
|
|
9235
|
+
const locator = end - 20;
|
|
9236
|
+
if (locator < 0 || tail.bytes.readUInt32LE(locator) !== 117853008)
|
|
9237
|
+
throw new Error(`${url} has no zip64 locator`);
|
|
9238
|
+
const recordAt = Number(tail.bytes.readBigUInt64LE(locator + 8));
|
|
9239
|
+
const record2 = recordAt >= tail.start ? tail.bytes.subarray(recordAt - tail.start) : (await range(url, `${recordAt}-${recordAt + 55}`)).bytes;
|
|
9240
|
+
size = Number(record2.readBigUInt64LE(40));
|
|
9241
|
+
offset = Number(record2.readBigUInt64LE(48));
|
|
9242
|
+
}
|
|
9243
|
+
const directory = offset >= tail.start ? tail.bytes.subarray(offset - tail.start, offset - tail.start + size) : (await range(url, `${offset}-${offset + size - 1}`)).bytes;
|
|
9244
|
+
const names = [];
|
|
9245
|
+
for (let at = 0; at + 46 <= directory.length; ) {
|
|
9246
|
+
if (directory.readUInt32LE(at) !== 33639248) break;
|
|
9247
|
+
const nameLength = directory.readUInt16LE(at + 28);
|
|
9248
|
+
names.push(directory.toString("utf8", at + 46, at + 46 + nameLength));
|
|
9249
|
+
at += 46 + nameLength + directory.readUInt16LE(at + 30) + directory.readUInt16LE(at + 32);
|
|
9250
|
+
}
|
|
9251
|
+
return names;
|
|
9252
|
+
}
|
|
9253
|
+
function localEntries(dir) {
|
|
9254
|
+
if (!import_node_fs13.default.existsSync(dir)) return [];
|
|
9255
|
+
return import_node_fs13.default.readdirSync(dir, { withFileTypes: true }).filter((slice) => slice.isDirectory()).flatMap(
|
|
9256
|
+
(slice) => import_node_fs13.default.readdirSync(import_node_path13.default.join(dir, slice.name)).map((entry) => `${slice.name}/${entry}`)
|
|
9257
|
+
);
|
|
9258
|
+
}
|
|
9259
|
+
async function swiftBinaryModules(binary) {
|
|
9260
|
+
if (!binary.url) return frameworkModules(localEntries(binary.dir));
|
|
9261
|
+
const cached3 = import_node_path13.default.join(
|
|
9262
|
+
cacheDir2,
|
|
9263
|
+
`${(0, import_node_crypto5.createHash)("sha256").update(binary.url).digest("hex").slice(0, 32)}.json`
|
|
9264
|
+
);
|
|
9265
|
+
if (import_node_fs13.default.existsSync(cached3)) {
|
|
9266
|
+
const value = JSON.parse(import_node_fs13.default.readFileSync(cached3, "utf8"));
|
|
9267
|
+
if (Array.isArray(value) && value.every((name2) => typeof name2 === "string"))
|
|
9268
|
+
return value;
|
|
9269
|
+
}
|
|
9270
|
+
const modules = frameworkModules(await zipEntries(binary.url));
|
|
9271
|
+
import_node_fs13.default.mkdirSync(cacheDir2, { recursive: true });
|
|
9272
|
+
import_node_fs13.default.writeFileSync(cached3, JSON.stringify(modules));
|
|
9273
|
+
return modules;
|
|
9274
|
+
}
|
|
9275
|
+
|
|
9180
9276
|
// src/swift-packages.ts
|
|
9181
9277
|
var import_node_child_process7 = require("node:child_process");
|
|
9182
|
-
var
|
|
9183
|
-
var
|
|
9278
|
+
var import_node_fs15 = __toESM(require("node:fs"), 1);
|
|
9279
|
+
var import_node_path15 = __toESM(require("node:path"), 1);
|
|
9184
9280
|
|
|
9185
9281
|
// src/swift-package-manifest.ts
|
|
9186
9282
|
var import_node_child_process6 = require("node:child_process");
|
|
9187
|
-
var
|
|
9188
|
-
var
|
|
9189
|
-
var
|
|
9190
|
-
var
|
|
9283
|
+
var import_node_crypto6 = require("node:crypto");
|
|
9284
|
+
var import_node_fs14 = __toESM(require("node:fs"), 1);
|
|
9285
|
+
var import_node_os6 = __toESM(require("node:os"), 1);
|
|
9286
|
+
var import_node_path14 = __toESM(require("node:path"), 1);
|
|
9191
9287
|
var TARGET_TYPES = [
|
|
9192
9288
|
"regular",
|
|
9193
9289
|
"executable",
|
|
@@ -9202,19 +9298,19 @@ var record = (value) => value && typeof value === "object" && !Array.isArray(val
|
|
|
9202
9298
|
var array = (value) => Array.isArray(value) ? value : [];
|
|
9203
9299
|
var string = (value) => typeof value === "string" ? value : void 0;
|
|
9204
9300
|
function swiftCommand() {
|
|
9205
|
-
return process.platform === "darwin" ? { file: "xcrun", args: ["swift"] } : { file:
|
|
9301
|
+
return process.platform === "darwin" ? { file: "xcrun", args: ["swift"] } : { file: import_node_path14.default.join(swiftToolchainBin(swift_distribution_lock_default.release), "swift"), args: [] };
|
|
9206
9302
|
}
|
|
9207
|
-
var
|
|
9303
|
+
var cacheDir3 = import_node_path14.default.join(import_node_os6.default.tmpdir(), "peach-swift-manifests");
|
|
9208
9304
|
var evaluated = /* @__PURE__ */ new Map();
|
|
9209
9305
|
function dump(dir) {
|
|
9210
|
-
const manifests =
|
|
9306
|
+
const manifests = import_node_fs14.default.readdirSync(dir).filter((name2) => /^Package(@swift-[\d.]+)?\.swift$/.test(name2)).sort();
|
|
9211
9307
|
const command = swiftCommand();
|
|
9212
|
-
const key = (0,
|
|
9213
|
-
manifests.map((name2) => `${name2}\0${
|
|
9308
|
+
const key = (0, import_node_crypto6.createHash)("sha256").update(JSON.stringify([command, import_node_path14.default.resolve(dir)])).update(
|
|
9309
|
+
manifests.map((name2) => `${name2}\0${import_node_fs14.default.readFileSync(import_node_path14.default.join(dir, name2), "utf8")}`).join("\0")
|
|
9214
9310
|
).digest("hex").slice(0, 32);
|
|
9215
|
-
const cached3 =
|
|
9216
|
-
if (
|
|
9217
|
-
return { key, raw: record(JSON.parse(
|
|
9311
|
+
const cached3 = import_node_path14.default.join(cacheDir3, `${key}.json`);
|
|
9312
|
+
if (import_node_fs14.default.existsSync(cached3))
|
|
9313
|
+
return { key, raw: record(JSON.parse(import_node_fs14.default.readFileSync(cached3, "utf8"))) };
|
|
9218
9314
|
let output;
|
|
9219
9315
|
try {
|
|
9220
9316
|
output = (0, import_node_child_process6.execFileSync)(
|
|
@@ -9226,7 +9322,7 @@ function dump(dir) {
|
|
|
9226
9322
|
dir,
|
|
9227
9323
|
// swiftpm's scratch files never land in the app's own package
|
|
9228
9324
|
"--scratch-path",
|
|
9229
|
-
|
|
9325
|
+
import_node_path14.default.join(cacheDir3, `${key}.build`),
|
|
9230
9326
|
"dump-package"
|
|
9231
9327
|
],
|
|
9232
9328
|
{
|
|
@@ -9238,11 +9334,11 @@ function dump(dir) {
|
|
|
9238
9334
|
} catch (error) {
|
|
9239
9335
|
const stderr = error instanceof Error && "stderr" in error ? String(error.stderr).trim() : "";
|
|
9240
9336
|
throw new Error(
|
|
9241
|
-
`swiftpm could not evaluate ${
|
|
9337
|
+
`swiftpm could not evaluate ${import_node_path14.default.join(dir, "Package.swift")}${stderr ? `: ${stderr}` : ""}`
|
|
9242
9338
|
);
|
|
9243
9339
|
}
|
|
9244
|
-
|
|
9245
|
-
|
|
9340
|
+
import_node_fs14.default.mkdirSync(cacheDir3, { recursive: true });
|
|
9341
|
+
import_node_fs14.default.writeFileSync(cached3, output);
|
|
9246
9342
|
return { key, raw: record(JSON.parse(output)) };
|
|
9247
9343
|
}
|
|
9248
9344
|
function defaultTraits(manifest) {
|
|
@@ -9270,7 +9366,7 @@ function linksOnIOS(condition, traits) {
|
|
|
9270
9366
|
return gates.length === 0 || gates.some((name2) => traits.has(string(name2) ?? ""));
|
|
9271
9367
|
}
|
|
9272
9368
|
function swiftPackageManifest(dir) {
|
|
9273
|
-
dir =
|
|
9369
|
+
dir = import_node_fs14.default.realpathSync(dir);
|
|
9274
9370
|
const { key, raw: raw2 } = dump(dir);
|
|
9275
9371
|
const known = evaluated.get(key);
|
|
9276
9372
|
if (known) return known;
|
|
@@ -9318,7 +9414,7 @@ function swiftPackageManifest(dir) {
|
|
|
9318
9414
|
if (!name2 || !isTargetType(kind)) continue;
|
|
9319
9415
|
const declared = string(target.path);
|
|
9320
9416
|
const roots = kind === "test" ? ["Tests"] : ["Sources", "Source", "src", "srcs"];
|
|
9321
|
-
const targetDir = declared ?
|
|
9417
|
+
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
9418
|
const dependencies = [];
|
|
9323
9419
|
for (const dependency of array(target.dependencies)) {
|
|
9324
9420
|
const { target: local, product, byName } = record(dependency);
|
|
@@ -9360,30 +9456,31 @@ function swiftPackageManifest(dir) {
|
|
|
9360
9456
|
dependencies,
|
|
9361
9457
|
languageMode,
|
|
9362
9458
|
mainActorIsolation,
|
|
9363
|
-
declaresResources: array(target.resources).length > 0
|
|
9459
|
+
declaresResources: array(target.resources).length > 0,
|
|
9460
|
+
url: string(target.url) ?? null
|
|
9364
9461
|
});
|
|
9365
9462
|
}
|
|
9366
9463
|
const manifest = { dir, products, targets, packages };
|
|
9367
9464
|
evaluated.set(key, manifest);
|
|
9368
9465
|
return manifest;
|
|
9369
9466
|
}
|
|
9370
|
-
var within = (file, roots) => roots.some((root) => file === root || file.startsWith(`${root}${
|
|
9467
|
+
var within = (file, roots) => roots.some((root) => file === root || file.startsWith(`${root}${import_node_path14.default.sep}`));
|
|
9371
9468
|
function walk(dir) {
|
|
9372
|
-
if (!
|
|
9373
|
-
if (
|
|
9469
|
+
if (!import_node_fs14.default.existsSync(dir)) return [];
|
|
9470
|
+
if (import_node_fs14.default.statSync(dir).isFile()) return [dir];
|
|
9374
9471
|
const out = [];
|
|
9375
|
-
for (const entry of
|
|
9472
|
+
for (const entry of import_node_fs14.default.readdirSync(dir, { withFileTypes: true })) {
|
|
9376
9473
|
if (entry.name.startsWith(".")) continue;
|
|
9377
|
-
const full =
|
|
9474
|
+
const full = import_node_path14.default.join(dir, entry.name);
|
|
9378
9475
|
if (entry.isDirectory()) out.push(...walk(full));
|
|
9379
9476
|
else if (entry.isFile()) out.push(full);
|
|
9380
9477
|
}
|
|
9381
9478
|
return out;
|
|
9382
9479
|
}
|
|
9383
9480
|
function swiftTargetFiles(manifest, target) {
|
|
9384
|
-
const included = target.sources ? target.sources.map((source) =>
|
|
9481
|
+
const included = target.sources ? target.sources.map((source) => import_node_path14.default.resolve(target.dir, source)) : [target.dir];
|
|
9385
9482
|
const excluded = [
|
|
9386
|
-
...target.exclude.map((file) =>
|
|
9483
|
+
...target.exclude.map((file) => import_node_path14.default.resolve(target.dir, file)),
|
|
9387
9484
|
...[...manifest.targets.values()].flatMap(
|
|
9388
9485
|
(other) => other !== target && within(other.dir, [target.dir]) && other.dir !== target.dir ? [other.dir] : []
|
|
9389
9486
|
)
|
|
@@ -9392,10 +9489,12 @@ function swiftTargetFiles(manifest, target) {
|
|
|
9392
9489
|
}
|
|
9393
9490
|
|
|
9394
9491
|
// src/swift-packages.ts
|
|
9395
|
-
var REMOTE_CHECKOUTS =
|
|
9492
|
+
var REMOTE_CHECKOUTS = import_node_path15.default.join(".build", "peach", "checkouts");
|
|
9396
9493
|
var C_FAMILY = /\.(c|cc|cpp|cxx|m|mm|s|S)$/;
|
|
9494
|
+
var BINARY = "is a binary framework";
|
|
9495
|
+
var blocker = (reasons) => reasons.find((reason) => reason?.includes(BINARY)) ?? reasons.find((reason) => reason !== null) ?? null;
|
|
9397
9496
|
function readPins(resolved) {
|
|
9398
|
-
const data = JSON.parse(
|
|
9497
|
+
const data = JSON.parse(import_node_fs15.default.readFileSync(resolved, "utf8"));
|
|
9399
9498
|
const pins = data && typeof data === "object" && "pins" in data && Array.isArray(data.pins) ? data.pins : null;
|
|
9400
9499
|
if (!pins)
|
|
9401
9500
|
throw new Error(`${resolved} has no pins; resolve packages in a current Xcode`);
|
|
@@ -9411,23 +9510,23 @@ function readPins(resolved) {
|
|
|
9411
9510
|
}
|
|
9412
9511
|
var verified2 = /* @__PURE__ */ new Set();
|
|
9413
9512
|
function checkout(checkouts, identity, pin) {
|
|
9414
|
-
const dir =
|
|
9513
|
+
const dir = import_node_path15.default.join(checkouts, identity);
|
|
9415
9514
|
const key = `${dir}\0${pin.revision}`;
|
|
9416
9515
|
if (verified2.has(key)) return dir;
|
|
9417
9516
|
const git = (...args) => (0, import_node_child_process7.execFileSync)("git", ["-C", dir, ...args], {
|
|
9418
9517
|
encoding: "utf8",
|
|
9419
9518
|
stdio: ["ignore", "pipe", "pipe"]
|
|
9420
9519
|
}).trim();
|
|
9421
|
-
const current =
|
|
9520
|
+
const current = import_node_fs15.default.existsSync(import_node_path15.default.join(dir, ".git")) ? git("rev-parse", "HEAD") : "";
|
|
9422
9521
|
if (current !== pin.revision) {
|
|
9423
|
-
|
|
9424
|
-
|
|
9522
|
+
import_node_fs15.default.rmSync(dir, { recursive: true, force: true });
|
|
9523
|
+
import_node_fs15.default.mkdirSync(dir, { recursive: true });
|
|
9425
9524
|
try {
|
|
9426
9525
|
git("init", "-q");
|
|
9427
9526
|
git("fetch", "-q", "--depth", "1", pin.location, pin.revision);
|
|
9428
9527
|
git("checkout", "-q", "FETCH_HEAD");
|
|
9429
9528
|
} catch (error) {
|
|
9430
|
-
|
|
9529
|
+
import_node_fs15.default.rmSync(dir, { recursive: true, force: true });
|
|
9431
9530
|
const stderr = error instanceof Error && "stderr" in error ? String(error.stderr).trim() : "";
|
|
9432
9531
|
throw new Error(
|
|
9433
9532
|
`could not fetch ${pin.location} at ${pin.revision}${stderr ? `: ${stderr}` : ""}`
|
|
@@ -9443,13 +9542,14 @@ function resolveSwiftPackages(options) {
|
|
|
9443
9542
|
const result = {
|
|
9444
9543
|
targets: [],
|
|
9445
9544
|
unavailable: /* @__PURE__ */ new Map(),
|
|
9446
|
-
modules: /* @__PURE__ */ new Map()
|
|
9545
|
+
modules: /* @__PURE__ */ new Map(),
|
|
9546
|
+
binaries: []
|
|
9447
9547
|
};
|
|
9448
9548
|
const pins = resolved ? readPins(resolved) : null;
|
|
9449
|
-
const checkouts =
|
|
9549
|
+
const checkouts = import_node_path15.default.join(rootDir, REMOTE_CHECKOUTS);
|
|
9450
9550
|
const packages = /* @__PURE__ */ new Map();
|
|
9451
9551
|
const load2 = (source) => {
|
|
9452
|
-
const key = source.kind === "local" ?
|
|
9552
|
+
const key = source.kind === "local" ? import_node_path15.default.resolve(source.dir) : source.url;
|
|
9453
9553
|
const cached3 = packages.get(key);
|
|
9454
9554
|
if (cached3 !== void 0) return cached3;
|
|
9455
9555
|
let loaded2;
|
|
@@ -9461,8 +9561,8 @@ function resolveSwiftPackages(options) {
|
|
|
9461
9561
|
if (!pin) {
|
|
9462
9562
|
loaded2 = pins ? `package ${identity} is not pinned in Package.resolved` : "no Package.resolved pins it; resolve packages in Xcode once";
|
|
9463
9563
|
} else {
|
|
9464
|
-
|
|
9465
|
-
|
|
9564
|
+
import_node_fs15.default.mkdirSync(checkouts, { recursive: true });
|
|
9565
|
+
import_node_fs15.default.writeFileSync(import_node_path15.default.join(import_node_path15.default.dirname(checkouts), ".gitignore"), "*\n");
|
|
9466
9566
|
loaded2 = {
|
|
9467
9567
|
source: source.url,
|
|
9468
9568
|
remote: true,
|
|
@@ -9482,8 +9582,8 @@ function resolveSwiftPackages(options) {
|
|
|
9482
9582
|
const outcome = (() => {
|
|
9483
9583
|
if (provided.has(name2)) return null;
|
|
9484
9584
|
const target = pkg.manifest.targets.get(name2);
|
|
9485
|
-
if (!target) return `${
|
|
9486
|
-
if (target.type === "binary") return `${name2}
|
|
9585
|
+
if (!target) return `${import_node_path15.default.basename(pkg.manifest.dir)} declares no target ${name2}`;
|
|
9586
|
+
if (target.type === "binary") return `${name2} ${BINARY}`;
|
|
9487
9587
|
if (target.type === "system") return `${name2} is a system C library`;
|
|
9488
9588
|
if (target.type !== "regular") return `${name2} is a ${target.type} target`;
|
|
9489
9589
|
const files = swiftTargetFiles(pkg.manifest, target);
|
|
@@ -9494,9 +9594,9 @@ function resolveSwiftPackages(options) {
|
|
|
9494
9594
|
const nested = resolveDependencyProduct(pkg, dependency.package, dependency.name);
|
|
9495
9595
|
return nested && `${dependency.name}: ${nested}`;
|
|
9496
9596
|
});
|
|
9497
|
-
const blocked = reasons
|
|
9597
|
+
const blocked = blocker(reasons);
|
|
9498
9598
|
if (blocked) return blocked;
|
|
9499
|
-
const relative2 = files.map((file) =>
|
|
9599
|
+
const relative2 = files.map((file) => import_node_path15.default.relative(target.dir, file));
|
|
9500
9600
|
targets.set(`${pkg.manifest.dir}\0${name2}`, {
|
|
9501
9601
|
name: name2,
|
|
9502
9602
|
path: "",
|
|
@@ -9518,7 +9618,7 @@ function resolveSwiftPackages(options) {
|
|
|
9518
9618
|
const resolveProduct = (pkg, product) => {
|
|
9519
9619
|
if (provided.has(product)) return null;
|
|
9520
9620
|
const roots = pkg.manifest.products.get(product);
|
|
9521
|
-
const reason = !roots ? `${
|
|
9621
|
+
const reason = !roots ? `${import_node_path15.default.basename(pkg.manifest.dir)} has no library ${product}` : blocker(roots.map((name2) => resolveTarget(pkg, name2)));
|
|
9522
9622
|
productOutcomes.set(`${pkg.manifest.dir}\0${product}`, { pkg, reason });
|
|
9523
9623
|
return reason;
|
|
9524
9624
|
};
|
|
@@ -9526,7 +9626,7 @@ function resolveSwiftPackages(options) {
|
|
|
9526
9626
|
if (provided.has(product)) return null;
|
|
9527
9627
|
const dependency = pkg.manifest.packages.get(packageName);
|
|
9528
9628
|
if (!dependency)
|
|
9529
|
-
return `${
|
|
9629
|
+
return `${import_node_path15.default.basename(pkg.manifest.dir)} names no package ${packageName}`;
|
|
9530
9630
|
if ("dir" in dependency) {
|
|
9531
9631
|
const loaded3 = load2({ kind: "local", dir: dependency.dir });
|
|
9532
9632
|
return typeof loaded3 === "string" ? loaded3 : resolveProduct(loaded3, product);
|
|
@@ -9553,6 +9653,13 @@ function resolveSwiftPackages(options) {
|
|
|
9553
9653
|
if (target.type === "test" || target.type === "plugin" || target.type === "macro")
|
|
9554
9654
|
continue;
|
|
9555
9655
|
if (target.type === "executable") continue;
|
|
9656
|
+
if (target.type === "binary")
|
|
9657
|
+
result.binaries.push({
|
|
9658
|
+
target: name2,
|
|
9659
|
+
source: pkg.source,
|
|
9660
|
+
url: target.url,
|
|
9661
|
+
dir: target.dir
|
|
9662
|
+
});
|
|
9556
9663
|
const reason = resolveTarget(pkg, name2);
|
|
9557
9664
|
if (reason && !result.modules.has(name2))
|
|
9558
9665
|
result.modules.set(name2, { source: pkg.source, reason });
|
|
@@ -9572,7 +9679,7 @@ function resolveSwiftPackages(options) {
|
|
|
9572
9679
|
if (dependency.kind === "target") reach(pkg, dependency.name);
|
|
9573
9680
|
else {
|
|
9574
9681
|
const source = pkg.manifest.packages.get(dependency.package);
|
|
9575
|
-
const nested = source && ("dir" in source ? packages.get(
|
|
9682
|
+
const nested = source && ("dir" in source ? packages.get(import_node_path15.default.resolve(source.dir)) : packages.get(source.url));
|
|
9576
9683
|
if (nested && typeof nested !== "string")
|
|
9577
9684
|
for (const root of nested.manifest.products.get(dependency.name) ?? [])
|
|
9578
9685
|
reach(nested, root);
|
|
@@ -9580,7 +9687,7 @@ function resolveSwiftPackages(options) {
|
|
|
9580
9687
|
}
|
|
9581
9688
|
};
|
|
9582
9689
|
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" ?
|
|
9690
|
+
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
9691
|
if (!pkg || typeof pkg === "string") continue;
|
|
9585
9692
|
for (const root of pkg.manifest.products.get(product) ?? []) reach(pkg, root);
|
|
9586
9693
|
}
|
|
@@ -9715,12 +9822,12 @@ async function compileSwiftProject(submit, work, origin, signal) {
|
|
|
9715
9822
|
}
|
|
9716
9823
|
|
|
9717
9824
|
// src/xcode-project.ts
|
|
9718
|
-
var
|
|
9719
|
-
var
|
|
9825
|
+
var import_node_fs16 = __toESM(require("node:fs"), 1);
|
|
9826
|
+
var import_node_path17 = __toESM(require("node:path"), 1);
|
|
9720
9827
|
var import_plist3 = __toESM(require_plist(), 1);
|
|
9721
9828
|
|
|
9722
9829
|
// src/xcode-json-project.ts
|
|
9723
|
-
var
|
|
9830
|
+
var import_node_path16 = __toESM(require("node:path"), 1);
|
|
9724
9831
|
var import_json5 = __toESM(require("json5"), 1);
|
|
9725
9832
|
var isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9726
9833
|
var text = (value) => typeof value === "string" ? value : void 0;
|
|
@@ -9736,7 +9843,7 @@ var PHASE_ISA = {
|
|
|
9736
9843
|
function readXcodeJsonProject(xcodeproj, source) {
|
|
9737
9844
|
const json = import_json5.default.parse(source);
|
|
9738
9845
|
if (!isJsonObject(json)) throw new Error(`${xcodeproj}/project.xcproj is not an object`);
|
|
9739
|
-
const projectDir =
|
|
9846
|
+
const projectDir = import_node_path16.default.dirname(xcodeproj);
|
|
9740
9847
|
const objects = {};
|
|
9741
9848
|
let next = 0;
|
|
9742
9849
|
const add = (entry, id) => {
|
|
@@ -9749,7 +9856,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
9749
9856
|
const base = /^<([A-Z]+)>\/(.*)$/.exec(raw2);
|
|
9750
9857
|
if (base) {
|
|
9751
9858
|
if (base[1] === "PROJECT")
|
|
9752
|
-
return { sourceTree: "<absolute>", path:
|
|
9859
|
+
return { sourceTree: "<absolute>", path: import_node_path16.default.join(projectDir, base[2]) };
|
|
9753
9860
|
if (base[1] === "PRODUCTS")
|
|
9754
9861
|
return { sourceTree: "BUILT_PRODUCTS_DIR", path: base[2] };
|
|
9755
9862
|
return null;
|
|
@@ -9757,7 +9864,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
9757
9864
|
const unescaped = raw2.replaceAll("\\<", "<");
|
|
9758
9865
|
if (unescaped.startsWith("/")) return { sourceTree: "<absolute>", path: unescaped };
|
|
9759
9866
|
if (unescaped.startsWith("~")) return null;
|
|
9760
|
-
return groupDir === null ? null : { sourceTree: "<absolute>", path:
|
|
9867
|
+
return groupDir === null ? null : { sourceTree: "<absolute>", path: import_node_path16.default.join(groupDir, unescaped) };
|
|
9761
9868
|
};
|
|
9762
9869
|
const memberships = [];
|
|
9763
9870
|
const folders = [];
|
|
@@ -9768,7 +9875,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
9768
9875
|
const kind = text(entry.kind) ?? "file-reference";
|
|
9769
9876
|
const raw2 = text(entry.path) ?? "";
|
|
9770
9877
|
const located = raw2 === "" ? null : locate(raw2, parent.dir);
|
|
9771
|
-
const name2 = text(entry.name) ??
|
|
9878
|
+
const name2 = text(entry.name) ?? import_node_path16.default.basename(raw2);
|
|
9772
9879
|
const node = { id: "", name: name2, dir: null, parent, children: [] };
|
|
9773
9880
|
if (kind === "group" || kind === "variant-group" || kind === "version-group") {
|
|
9774
9881
|
node.dir = raw2 === "" ? parent.dir : located?.sourceTree === "<absolute>" ? located.path : null;
|
|
@@ -9883,7 +9990,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
9883
9990
|
if (!isObject(entry)) continue;
|
|
9884
9991
|
const repository = text(entry.repository);
|
|
9885
9992
|
const local = text(entry.path);
|
|
9886
|
-
const name2 = local !== void 0 ?
|
|
9993
|
+
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
9994
|
const id = text(entry.kind) === "local" && local !== void 0 ? add({ isa: "XCLocalSwiftPackageReference", relativePath: local }) : add({ isa: "XCRemoteSwiftPackageReference", repositoryURL: repository ?? "" });
|
|
9888
9995
|
packageIds.set(name2.toLowerCase(), id);
|
|
9889
9996
|
}
|
|
@@ -10160,28 +10267,28 @@ var CONDITIONS = {
|
|
|
10160
10267
|
variant: "normal"
|
|
10161
10268
|
};
|
|
10162
10269
|
function walkFiles(dir) {
|
|
10163
|
-
if (!
|
|
10270
|
+
if (!import_node_fs16.default.existsSync(dir)) return [];
|
|
10164
10271
|
const out = [];
|
|
10165
|
-
for (const entry of
|
|
10272
|
+
for (const entry of import_node_fs16.default.readdirSync(dir, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
|
|
10166
10273
|
if (entry.name.startsWith(".")) continue;
|
|
10167
|
-
const full =
|
|
10274
|
+
const full = import_node_path17.default.join(dir, entry.name);
|
|
10168
10275
|
if (entry.isDirectory()) out.push(...walkFiles(full));
|
|
10169
10276
|
else if (entry.isFile()) out.push(full);
|
|
10170
10277
|
}
|
|
10171
10278
|
return out;
|
|
10172
10279
|
}
|
|
10173
|
-
var isDirectory = (dir) =>
|
|
10280
|
+
var isDirectory = (dir) => import_node_fs16.default.existsSync(dir) && import_node_fs16.default.statSync(dir).isDirectory();
|
|
10174
10281
|
function readXcconfig(file, seen = /* @__PURE__ */ new Set()) {
|
|
10175
|
-
if (seen.has(file) || !
|
|
10282
|
+
if (seen.has(file) || !import_node_fs16.default.existsSync(file)) return {};
|
|
10176
10283
|
seen.add(file);
|
|
10177
10284
|
const settings = {};
|
|
10178
|
-
for (const raw2 of
|
|
10285
|
+
for (const raw2 of import_node_fs16.default.readFileSync(file, "utf8").split("\n")) {
|
|
10179
10286
|
const line = raw2.replace(/\/\/.*$/, "").trim();
|
|
10180
10287
|
const include = /^#include\??\s+"([^"]+)"/.exec(line);
|
|
10181
10288
|
if (include) {
|
|
10182
10289
|
Object.assign(
|
|
10183
10290
|
settings,
|
|
10184
|
-
readXcconfig(
|
|
10291
|
+
readXcconfig(import_node_path17.default.resolve(import_node_path17.default.dirname(file), include[1]), seen)
|
|
10185
10292
|
);
|
|
10186
10293
|
continue;
|
|
10187
10294
|
}
|
|
@@ -10231,22 +10338,22 @@ function decodeXml(text2) {
|
|
|
10231
10338
|
return text2.replaceAll(""", '"').replaceAll("'", "'").replaceAll("<", "<").replaceAll(">", ">").replaceAll("&", "&");
|
|
10232
10339
|
}
|
|
10233
10340
|
function workspaceReferences(workspace) {
|
|
10234
|
-
const data =
|
|
10235
|
-
if (!
|
|
10341
|
+
const data = import_node_path17.default.join(workspace, "contents.xcworkspacedata");
|
|
10342
|
+
if (!import_node_fs16.default.existsSync(data))
|
|
10236
10343
|
throw new Error(`${workspace} has no contents.xcworkspacedata`);
|
|
10237
|
-
const container =
|
|
10344
|
+
const container = import_node_path17.default.dirname(workspace);
|
|
10238
10345
|
const locate = (location2, base) => {
|
|
10239
10346
|
const colon = location2.indexOf(":");
|
|
10240
10347
|
const kind = location2.slice(0, colon);
|
|
10241
10348
|
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(`${
|
|
10349
|
+
if (kind === "group") return import_node_path17.default.resolve(base, rest);
|
|
10350
|
+
if (kind === "container" || kind === "self") return import_node_path17.default.resolve(container, rest);
|
|
10351
|
+
if (kind === "absolute") return import_node_path17.default.resolve(rest);
|
|
10352
|
+
throw new Error(`${import_node_path17.default.basename(workspace)} has an unsupported location ${location2}`);
|
|
10246
10353
|
};
|
|
10247
10354
|
const groups = [container];
|
|
10248
10355
|
const references = [];
|
|
10249
|
-
for (const [, closing, tag, attributes, selfClosing] of
|
|
10356
|
+
for (const [, closing, tag, attributes, selfClosing] of import_node_fs16.default.readFileSync(data, "utf8").matchAll(/<(\/?)(Group|FileRef)\b([^>]*?)(\/?)>/g)) {
|
|
10250
10357
|
if (closing) {
|
|
10251
10358
|
if (tag === "Group") groups.pop();
|
|
10252
10359
|
continue;
|
|
@@ -10262,8 +10369,8 @@ function workspaceReferences(workspace) {
|
|
|
10262
10369
|
var loaded = /* @__PURE__ */ new Map();
|
|
10263
10370
|
function xcodeProjectFile(xcodeproj) {
|
|
10264
10371
|
for (const name2 of ["project.pbxproj", "project.xcproj"]) {
|
|
10265
|
-
const file =
|
|
10266
|
-
if (
|
|
10372
|
+
const file = import_node_path17.default.join(xcodeproj, name2);
|
|
10373
|
+
if (import_node_fs16.default.existsSync(file)) return file;
|
|
10267
10374
|
}
|
|
10268
10375
|
return null;
|
|
10269
10376
|
}
|
|
@@ -10271,10 +10378,10 @@ function loadProject(xcodeproj) {
|
|
|
10271
10378
|
const projectFile = xcodeProjectFile(xcodeproj);
|
|
10272
10379
|
if (!projectFile)
|
|
10273
10380
|
throw new Error(`${xcodeproj} has no project.pbxproj or project.xcproj`);
|
|
10274
|
-
const mtimeMs =
|
|
10381
|
+
const mtimeMs = import_node_fs16.default.statSync(projectFile).mtimeMs;
|
|
10275
10382
|
const cached3 = loaded.get(projectFile);
|
|
10276
10383
|
if (cached3?.mtimeMs === mtimeMs) return cached3.project;
|
|
10277
|
-
const source =
|
|
10384
|
+
const source = import_node_fs16.default.readFileSync(projectFile, "utf8");
|
|
10278
10385
|
const root = projectFile.endsWith(".xcproj") ? readXcodeJsonProject(xcodeproj, source) : parseOpenStepPlist(source);
|
|
10279
10386
|
if (!isDict(root) || !isDict(root.objects)) {
|
|
10280
10387
|
throw new Error(`${projectFile} has no objects table`);
|
|
@@ -10288,8 +10395,8 @@ function loadProject(xcodeproj) {
|
|
|
10288
10395
|
if (!project || project.isa !== "PBXProject") {
|
|
10289
10396
|
throw new Error(`${projectFile} has no PBXProject root`);
|
|
10290
10397
|
}
|
|
10291
|
-
const projectDir =
|
|
10292
|
-
|
|
10398
|
+
const projectDir = import_node_fs16.default.realpathSync(
|
|
10399
|
+
import_node_path17.default.resolve(import_node_path17.default.dirname(xcodeproj), str(project.projectDirPath) ?? "")
|
|
10293
10400
|
);
|
|
10294
10401
|
const parent = /* @__PURE__ */ new Map();
|
|
10295
10402
|
for (const [id, entry] of Object.entries(objects)) {
|
|
@@ -10307,11 +10414,11 @@ function loadProject(xcodeproj) {
|
|
|
10307
10414
|
const own = str(entry.path) ?? "";
|
|
10308
10415
|
const tree = str(entry.sourceTree) ?? "<group>";
|
|
10309
10416
|
if (tree === "<absolute>") result2 = own;
|
|
10310
|
-
else if (tree === "SOURCE_ROOT") result2 =
|
|
10417
|
+
else if (tree === "SOURCE_ROOT") result2 = import_node_path17.default.join(projectDir, own);
|
|
10311
10418
|
else if (tree === "<group>") {
|
|
10312
10419
|
const up = parent.get(id);
|
|
10313
10420
|
const base = up ? resolvePath(up) : projectDir;
|
|
10314
|
-
result2 = base === null ? null :
|
|
10421
|
+
result2 = base === null ? null : import_node_path17.default.join(base, own);
|
|
10315
10422
|
}
|
|
10316
10423
|
}
|
|
10317
10424
|
resolvedPaths.set(id, result2);
|
|
@@ -10411,7 +10518,7 @@ function targetMembers(ref) {
|
|
|
10411
10518
|
const addResource = (file) => {
|
|
10412
10519
|
if (isDirectory(file)) {
|
|
10413
10520
|
for (const inner of walkFiles(file)) resources.add(inner);
|
|
10414
|
-
} else if (
|
|
10521
|
+
} else if (import_node_fs16.default.existsSync(file)) resources.add(file);
|
|
10415
10522
|
};
|
|
10416
10523
|
const fileRefPaths = (refId) => {
|
|
10417
10524
|
const entry = project.object(refId);
|
|
@@ -10432,7 +10539,7 @@ function targetMembers(ref) {
|
|
|
10432
10539
|
for (const buildFileId of list(phase.files)) {
|
|
10433
10540
|
for (const file of fileRefPaths(str(project.object(buildFileId)?.fileRef) ?? "")) {
|
|
10434
10541
|
if (phase.isa === "PBXSourcesBuildPhase") {
|
|
10435
|
-
if (!
|
|
10542
|
+
if (!import_node_fs16.default.existsSync(file)) continue;
|
|
10436
10543
|
allSources.add(file);
|
|
10437
10544
|
if (file.endsWith(".swift")) sources.add(file);
|
|
10438
10545
|
} else if (phase.isa === "PBXResourcesBuildPhase") addResource(file);
|
|
@@ -10440,7 +10547,7 @@ function targetMembers(ref) {
|
|
|
10440
10547
|
}
|
|
10441
10548
|
}
|
|
10442
10549
|
const addSynchronized = (folder, relative2) => {
|
|
10443
|
-
const file =
|
|
10550
|
+
const file = import_node_path17.default.join(folder, relative2);
|
|
10444
10551
|
if (NEVER_MEMBER.test(relative2)) return;
|
|
10445
10552
|
if (file.endsWith(".swift")) {
|
|
10446
10553
|
if (!relative2.split("/").some((segment) => BUNDLE_DIR.test(segment))) {
|
|
@@ -10465,7 +10572,7 @@ function targetMembers(ref) {
|
|
|
10465
10572
|
}
|
|
10466
10573
|
if (owned.has(groupId)) {
|
|
10467
10574
|
for (const file of walkFiles(folder)) {
|
|
10468
|
-
const relative2 =
|
|
10575
|
+
const relative2 = import_node_path17.default.relative(folder, file).split(import_node_path17.default.sep).join("/");
|
|
10469
10576
|
if ([...exceptions].some(
|
|
10470
10577
|
(exception) => relative2 === exception || relative2.startsWith(`${exception}/`)
|
|
10471
10578
|
))
|
|
@@ -10474,14 +10581,14 @@ function targetMembers(ref) {
|
|
|
10474
10581
|
}
|
|
10475
10582
|
} else {
|
|
10476
10583
|
for (const relative2 of exceptions) {
|
|
10477
|
-
const file =
|
|
10584
|
+
const file = import_node_path17.default.join(folder, relative2);
|
|
10478
10585
|
if (isDirectory(file)) {
|
|
10479
10586
|
for (const inner of walkFiles(file))
|
|
10480
10587
|
addSynchronized(
|
|
10481
10588
|
folder,
|
|
10482
|
-
|
|
10589
|
+
import_node_path17.default.relative(folder, inner).split(import_node_path17.default.sep).join("/")
|
|
10483
10590
|
);
|
|
10484
|
-
} else if (
|
|
10591
|
+
} else if (import_node_fs16.default.existsSync(file)) addSynchronized(folder, relative2);
|
|
10485
10592
|
}
|
|
10486
10593
|
}
|
|
10487
10594
|
}
|
|
@@ -10494,8 +10601,8 @@ function targetMembers(ref) {
|
|
|
10494
10601
|
function commonAncestor(dirs) {
|
|
10495
10602
|
let common = dirs[0];
|
|
10496
10603
|
for (const dir of dirs) {
|
|
10497
|
-
while (common !==
|
|
10498
|
-
common =
|
|
10604
|
+
while (common !== import_node_path17.default.dirname(common) && import_node_path17.default.relative(common, dir).startsWith(".."))
|
|
10605
|
+
common = import_node_path17.default.dirname(common);
|
|
10499
10606
|
}
|
|
10500
10607
|
return common;
|
|
10501
10608
|
}
|
|
@@ -10504,8 +10611,8 @@ function workspaceProjects(xcodeprojOrWorkspace) {
|
|
|
10504
10611
|
const projects2 = [];
|
|
10505
10612
|
const projectAt = /* @__PURE__ */ new Map();
|
|
10506
10613
|
const addProject = (xcodeproj) => {
|
|
10507
|
-
const key =
|
|
10508
|
-
if (projectAt.has(key) || key.split(
|
|
10614
|
+
const key = import_node_path17.default.resolve(xcodeproj);
|
|
10615
|
+
if (projectAt.has(key) || key.split(import_node_path17.default.sep).includes("Pods")) return;
|
|
10509
10616
|
if (!xcodeProjectFile(key)) return;
|
|
10510
10617
|
const project = loadProject(key);
|
|
10511
10618
|
projectAt.set(key, project);
|
|
@@ -10522,7 +10629,7 @@ function workspaceProjects(xcodeprojOrWorkspace) {
|
|
|
10522
10629
|
for (const reference of listed)
|
|
10523
10630
|
if (reference.endsWith(".xcodeproj")) addProject(reference);
|
|
10524
10631
|
if (projects2.length === 0) {
|
|
10525
|
-
throw new Error(`${
|
|
10632
|
+
throw new Error(`${import_node_path17.default.basename(xcodeprojOrWorkspace)} lists no Xcode project`);
|
|
10526
10633
|
}
|
|
10527
10634
|
return { listed, projects: projects2, projectAt };
|
|
10528
10635
|
}
|
|
@@ -10544,7 +10651,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
10544
10651
|
const allTargets = projects2.flatMap(nativeTargets);
|
|
10545
10652
|
const appTargets = allTargets.filter((ref) => ref.target.productType === APPLICATION);
|
|
10546
10653
|
const appTargetNames = appTargets.map((ref) => str(ref.target.name) ?? ref.id);
|
|
10547
|
-
const container =
|
|
10654
|
+
const container = import_node_path17.default.basename(xcodeprojOrWorkspace);
|
|
10548
10655
|
const named = targetName ? appTargets.filter((ref) => ref.target.name === targetName) : appTargets;
|
|
10549
10656
|
if (named.length !== 1) {
|
|
10550
10657
|
throw new Error(
|
|
@@ -10556,14 +10663,14 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
10556
10663
|
for (const ref of allTargets) {
|
|
10557
10664
|
const product = ref.project.object(str(ref.target.productReference));
|
|
10558
10665
|
const file = str(product?.path);
|
|
10559
|
-
if (file && !byProduct.has(
|
|
10560
|
-
byProduct.set(
|
|
10666
|
+
if (file && !byProduct.has(import_node_path17.default.basename(file)))
|
|
10667
|
+
byProduct.set(import_node_path17.default.basename(file), ref);
|
|
10561
10668
|
}
|
|
10562
10669
|
const proxied = (project, proxyId) => {
|
|
10563
10670
|
const proxy = project.object(proxyId);
|
|
10564
10671
|
if (proxy?.isa !== "PBXContainerItemProxy") return void 0;
|
|
10565
10672
|
const portal = str(proxy.containerPortal);
|
|
10566
|
-
const owner = project.object(portal)?.isa === "PBXProject" ? project : projectAt.get(
|
|
10673
|
+
const owner = project.object(portal)?.isa === "PBXProject" ? project : projectAt.get(import_node_path17.default.resolve(project.resolvePath(portal ?? "") ?? ""));
|
|
10567
10674
|
const remote = str(proxy.remoteGlobalIDString);
|
|
10568
10675
|
if (!owner || !remote) return void 0;
|
|
10569
10676
|
return nativeTargets(owner).find(
|
|
@@ -10584,7 +10691,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
10584
10691
|
if (phase?.isa !== "PBXFrameworksBuildPhase") continue;
|
|
10585
10692
|
for (const buildFileId of list(phase.files)) {
|
|
10586
10693
|
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(
|
|
10694
|
+
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
10695
|
if (resolved) found.push(resolved);
|
|
10589
10696
|
}
|
|
10590
10697
|
}
|
|
@@ -10605,7 +10712,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
10605
10712
|
const name2 = str(ref.target.name) ?? ref.id;
|
|
10606
10713
|
const { get: settings2, keys } = targetSettings(ref, {
|
|
10607
10714
|
TARGET_NAME: name2,
|
|
10608
|
-
PROJECT_NAME:
|
|
10715
|
+
PROJECT_NAME: import_node_path17.default.basename(ref.project.xcodeproj, ".xcodeproj"),
|
|
10609
10716
|
SRCROOT: ref.project.projectDir,
|
|
10610
10717
|
SOURCE_ROOT: ref.project.projectDir,
|
|
10611
10718
|
PROJECT_DIR: ref.project.projectDir,
|
|
@@ -10636,8 +10743,8 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
10636
10743
|
}
|
|
10637
10744
|
return value;
|
|
10638
10745
|
};
|
|
10639
|
-
const infoPlistFile = settings("INFOPLIST_FILE") ?
|
|
10640
|
-
const sourceInfo = infoPlistFile ? import_plist3.default.parse(
|
|
10746
|
+
const infoPlistFile = settings("INFOPLIST_FILE") ? import_node_path17.default.resolve(app.project.projectDir, settings("INFOPLIST_FILE")) : null;
|
|
10747
|
+
const sourceInfo = infoPlistFile ? import_plist3.default.parse(import_node_fs16.default.readFileSync(infoPlistFile, "utf8")) : {};
|
|
10641
10748
|
if (!sourceInfo || typeof sourceInfo !== "object" || Array.isArray(sourceInfo) || sourceInfo instanceof Date || Buffer.isBuffer(sourceInfo)) {
|
|
10642
10749
|
throw new Error(`${module2.name} Info.plist must contain a dictionary`);
|
|
10643
10750
|
}
|
|
@@ -10655,12 +10762,12 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
10655
10762
|
};
|
|
10656
10763
|
}
|
|
10657
10764
|
const localPackageDirs = [
|
|
10658
|
-
...listed.filter((reference) =>
|
|
10765
|
+
...listed.filter((reference) => import_node_fs16.default.existsSync(import_node_path17.default.join(reference, "Package.swift"))),
|
|
10659
10766
|
...projects2.flatMap(
|
|
10660
10767
|
(project) => Object.entries(project.objects).flatMap(([id, entry]) => {
|
|
10661
10768
|
if (!isDict(entry)) return [];
|
|
10662
|
-
const candidate = entry.isa === "XCLocalSwiftPackageReference" ?
|
|
10663
|
-
return candidate &&
|
|
10769
|
+
const candidate = entry.isa === "XCLocalSwiftPackageReference" ? import_node_path17.default.resolve(project.projectDir, str(entry.relativePath) ?? "") : entry.isa === "PBXFileReference" ? project.resolvePath(id) : null;
|
|
10770
|
+
return candidate && import_node_fs16.default.existsSync(import_node_path17.default.join(candidate, "Package.swift")) ? [candidate] : [];
|
|
10664
10771
|
})
|
|
10665
10772
|
)
|
|
10666
10773
|
];
|
|
@@ -10684,7 +10791,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
10684
10791
|
product,
|
|
10685
10792
|
source: reference?.isa === "XCRemoteSwiftPackageReference" ? { kind: "remote", url: str(reference.repositoryURL) ?? "" } : reference?.isa === "XCLocalSwiftPackageReference" ? {
|
|
10686
10793
|
kind: "local",
|
|
10687
|
-
dir:
|
|
10794
|
+
dir: import_node_path17.default.resolve(
|
|
10688
10795
|
project.projectDir,
|
|
10689
10796
|
str(reference.relativePath) ?? ""
|
|
10690
10797
|
)
|
|
@@ -10706,8 +10813,8 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
10706
10813
|
}
|
|
10707
10814
|
}
|
|
10708
10815
|
}
|
|
10709
|
-
const resolvedFile =
|
|
10710
|
-
workspace ??
|
|
10816
|
+
const resolvedFile = import_node_path17.default.join(
|
|
10817
|
+
workspace ?? import_node_path17.default.join(xcodeprojOrWorkspace, "project.xcworkspace"),
|
|
10711
10818
|
"xcshareddata",
|
|
10712
10819
|
"swiftpm",
|
|
10713
10820
|
"Package.resolved"
|
|
@@ -10717,13 +10824,13 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
10717
10824
|
...module2,
|
|
10718
10825
|
rootDir: commonAncestor(
|
|
10719
10826
|
[
|
|
10720
|
-
workspace ?
|
|
10827
|
+
workspace ? import_node_path17.default.dirname(workspace) : app.project.projectDir,
|
|
10721
10828
|
...used.map((project) => project.projectDir),
|
|
10722
10829
|
...localPackageDirs,
|
|
10723
10830
|
...linkedProducts.flatMap(
|
|
10724
|
-
({ source }) => source.kind === "local" &&
|
|
10831
|
+
({ source }) => source.kind === "local" && import_node_fs16.default.existsSync(source.dir) ? [source.dir] : []
|
|
10725
10832
|
)
|
|
10726
|
-
].map((dir) =>
|
|
10833
|
+
].map((dir) => import_node_fs16.default.realpathSync(dir))
|
|
10727
10834
|
),
|
|
10728
10835
|
projectFiles: [...new Set(used.map((project) => project.projectFile))].sort(),
|
|
10729
10836
|
infoPlist: import_plist3.default.build(info),
|
|
@@ -10731,10 +10838,10 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
10731
10838
|
frameworks,
|
|
10732
10839
|
linkedProducts,
|
|
10733
10840
|
localPackageDirs: [
|
|
10734
|
-
...new Set(localPackageDirs.map((dir) =>
|
|
10841
|
+
...new Set(localPackageDirs.map((dir) => import_node_fs16.default.realpathSync(dir)))
|
|
10735
10842
|
].sort(),
|
|
10736
10843
|
binaryFrameworks: [...binaryFrameworks].sort(),
|
|
10737
|
-
packageResolved:
|
|
10844
|
+
packageResolved: import_node_fs16.default.existsSync(resolvedFile) ? resolvedFile : null,
|
|
10738
10845
|
appTargets: appTargetNames
|
|
10739
10846
|
};
|
|
10740
10847
|
}
|
|
@@ -10754,17 +10861,17 @@ var SKIP_SOURCE_DIRS = /* @__PURE__ */ new Set([
|
|
|
10754
10861
|
var NATIVE_DESCRIPTOR = ".one-native-source.json";
|
|
10755
10862
|
var NATIVE_GLUE = ".one-native-source.swift.txt";
|
|
10756
10863
|
function swiftPackageId(packagePath) {
|
|
10757
|
-
return
|
|
10864
|
+
return import_node_path18.default.basename(packagePath).replace(/[^A-Za-z0-9_]/g, "_").replace(/^(\d)/, "_$1");
|
|
10758
10865
|
}
|
|
10759
10866
|
function nativeSourceDescriptor(packagePath) {
|
|
10760
|
-
packagePath =
|
|
10761
|
-
const file =
|
|
10762
|
-
if (!
|
|
10867
|
+
packagePath = import_node_fs17.default.realpathSync(packagePath);
|
|
10868
|
+
const file = import_node_path18.default.join(packagePath, NATIVE_DESCRIPTOR);
|
|
10869
|
+
if (!import_node_fs17.default.existsSync(file)) return null;
|
|
10763
10870
|
const value = JSON.parse(
|
|
10764
10871
|
readPackageFile(packagePath, file, MAX_SWIFT_COMPILE_SOURCE_BYTES).toString("utf8")
|
|
10765
10872
|
);
|
|
10766
10873
|
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" || !
|
|
10874
|
+
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
10875
|
throw invalid();
|
|
10769
10876
|
}
|
|
10770
10877
|
if (!isSwiftNativeModules(value) || value.packageId !== swiftPackageId(packagePath)) {
|
|
@@ -10774,7 +10881,7 @@ function nativeSourceDescriptor(packagePath) {
|
|
|
10774
10881
|
}
|
|
10775
10882
|
var projects = /* @__PURE__ */ new Map();
|
|
10776
10883
|
function projectFor(packagePath, hosted) {
|
|
10777
|
-
packagePath =
|
|
10884
|
+
packagePath = import_node_fs17.default.realpathSync(packagePath);
|
|
10778
10885
|
const existing = projects.get(packagePath);
|
|
10779
10886
|
if (existing) {
|
|
10780
10887
|
if (hosted && !existing.hosted) {
|
|
@@ -10796,14 +10903,14 @@ function projectFor(packagePath, hosted) {
|
|
|
10796
10903
|
}
|
|
10797
10904
|
var xcodeProjects = /* @__PURE__ */ new Map();
|
|
10798
10905
|
function swiftPackages(entry, app) {
|
|
10799
|
-
const stamp = (file) => file &&
|
|
10906
|
+
const stamp = (file) => file && import_node_fs17.default.existsSync(file) ? import_node_fs17.default.statSync(file).mtimeMs : 0;
|
|
10800
10907
|
const key = JSON.stringify([
|
|
10801
10908
|
app.linkedProducts,
|
|
10802
10909
|
app.packageResolved,
|
|
10803
10910
|
stamp(app.packageResolved),
|
|
10804
|
-
app.localPackageDirs.map((dir) => stamp(
|
|
10911
|
+
app.localPackageDirs.map((dir) => stamp(import_node_path18.default.join(dir, "Package.swift"))),
|
|
10805
10912
|
app.linkedProducts.map(
|
|
10806
|
-
({ source }) => source.kind === "local" ? stamp(
|
|
10913
|
+
({ source }) => source.kind === "local" ? stamp(import_node_path18.default.join(source.dir, "Package.swift")) : 0
|
|
10807
10914
|
)
|
|
10808
10915
|
]);
|
|
10809
10916
|
if (entry.packages?.key !== key) {
|
|
@@ -10823,11 +10930,11 @@ function swiftPackages(entry, app) {
|
|
|
10823
10930
|
var XCODE_APP_DIR = "__app__";
|
|
10824
10931
|
var XCODE_FRAMEWORKS_DIR = "__frameworks__";
|
|
10825
10932
|
var XCODE_PACKAGES_DIR = "__packages__";
|
|
10826
|
-
var CHECKOUTS_PREFIX = `${REMOTE_CHECKOUTS.split(
|
|
10933
|
+
var CHECKOUTS_PREFIX = `${REMOTE_CHECKOUTS.split(import_node_path18.default.sep).join(import_node_path18.default.posix.sep)}/`;
|
|
10827
10934
|
function xcodeInputKey(layout, file, relative2) {
|
|
10828
10935
|
const owner = layout.targetDirs.get(file);
|
|
10829
|
-
if (owner) return
|
|
10830
|
-
return relative2.startsWith(CHECKOUTS_PREFIX) ?
|
|
10936
|
+
if (owner) return import_node_path18.default.posix.join(owner, relative2);
|
|
10937
|
+
return relative2.startsWith(CHECKOUTS_PREFIX) ? import_node_path18.default.posix.join(XCODE_PACKAGES_DIR, relative2.slice(CHECKOUTS_PREFIX.length)) : relative2;
|
|
10831
10938
|
}
|
|
10832
10939
|
function xcodeLayout(root) {
|
|
10833
10940
|
const registered = xcodeProjects.get(root);
|
|
@@ -10838,7 +10945,7 @@ function xcodeLayout(root) {
|
|
|
10838
10945
|
const targetDirs = new Map(app.sources.map((file) => [file, XCODE_APP_DIR]));
|
|
10839
10946
|
const targets = [];
|
|
10840
10947
|
for (const framework of app.frameworks) {
|
|
10841
|
-
const dir =
|
|
10948
|
+
const dir = import_node_path18.default.posix.join(XCODE_FRAMEWORKS_DIR, framework.moduleName);
|
|
10842
10949
|
for (const file of framework.sources) {
|
|
10843
10950
|
if (targetDirs.has(file)) continue;
|
|
10844
10951
|
targetDirs.set(file, dir);
|
|
@@ -10856,19 +10963,19 @@ function xcodeLayout(root) {
|
|
|
10856
10963
|
}
|
|
10857
10964
|
const packages = swiftPackages(registered, app);
|
|
10858
10965
|
for (const target of packages.targets) {
|
|
10859
|
-
const relative2 =
|
|
10860
|
-
target.remote ?
|
|
10966
|
+
const relative2 = import_node_path18.default.relative(
|
|
10967
|
+
target.remote ? import_node_path18.default.join(root, REMOTE_CHECKOUTS) : root,
|
|
10861
10968
|
target.dir
|
|
10862
10969
|
);
|
|
10863
|
-
if (relative2 === ".." || relative2.startsWith(`..${
|
|
10970
|
+
if (relative2 === ".." || relative2.startsWith(`..${import_node_path18.default.sep}`) || import_node_path18.default.isAbsolute(relative2))
|
|
10864
10971
|
throw new Error(`swift input escapes the selected package: ${target.dir}`);
|
|
10865
|
-
const posix2 = relative2.split(
|
|
10972
|
+
const posix2 = relative2.split(import_node_path18.default.sep).join(import_node_path18.default.posix.sep);
|
|
10866
10973
|
targets.push({
|
|
10867
10974
|
...target,
|
|
10868
|
-
path: target.remote ?
|
|
10975
|
+
path: target.remote ? import_node_path18.default.posix.join(XCODE_PACKAGES_DIR, posix2) : posix2,
|
|
10869
10976
|
exclude: []
|
|
10870
10977
|
});
|
|
10871
|
-
if (!target.remote) files.add(
|
|
10978
|
+
if (!target.remote) files.add(import_node_path18.default.join(target.packageDir, "Package.swift"));
|
|
10872
10979
|
for (const file of target.files) files.add(file);
|
|
10873
10980
|
}
|
|
10874
10981
|
for (const target of targets) {
|
|
@@ -10897,25 +11004,25 @@ function xcodeManifest(layout) {
|
|
|
10897
11004
|
].join("\n");
|
|
10898
11005
|
}
|
|
10899
11006
|
function packageFiles(root) {
|
|
10900
|
-
const canonicalRoot =
|
|
11007
|
+
const canonicalRoot = import_node_fs17.default.realpathSync(root);
|
|
10901
11008
|
const xcode = xcodeLayout(canonicalRoot);
|
|
10902
11009
|
return xcode ? xcode.files : sourceTreeFiles(canonicalRoot, canonicalRoot);
|
|
10903
11010
|
}
|
|
10904
11011
|
function sourceTreeFiles(dir, canonicalRoot) {
|
|
10905
11012
|
const found = [];
|
|
10906
11013
|
const walk2 = (dir2) => {
|
|
10907
|
-
for (const entry of
|
|
11014
|
+
for (const entry of import_node_fs17.default.readdirSync(dir2, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
|
|
10908
11015
|
if (entry.name.startsWith(".") && entry.name !== NATIVE_DESCRIPTOR && entry.name !== NATIVE_GLUE || SKIP_SOURCE_DIRS.has(entry.name))
|
|
10909
11016
|
continue;
|
|
10910
|
-
const full =
|
|
11017
|
+
const full = import_node_path18.default.join(dir2, entry.name);
|
|
10911
11018
|
if (entry.isSymbolicLink()) throw new Error(`swift input is a symlink: ${full}`);
|
|
10912
|
-
const real =
|
|
10913
|
-
const relative2 =
|
|
10914
|
-
if (relative2.startsWith(`..${
|
|
11019
|
+
const real = import_node_fs17.default.realpathSync(full);
|
|
11020
|
+
const relative2 = import_node_path18.default.relative(canonicalRoot, real);
|
|
11021
|
+
if (relative2.startsWith(`..${import_node_path18.default.sep}`) || relative2 === ".." || import_node_path18.default.isAbsolute(relative2)) {
|
|
10915
11022
|
throw new Error(`swift input escapes the selected package: ${full}`);
|
|
10916
11023
|
}
|
|
10917
11024
|
if (entry.isDirectory()) {
|
|
10918
|
-
if (
|
|
11025
|
+
if (import_node_fs17.default.existsSync(import_node_path18.default.join(full, "Package.swift"))) continue;
|
|
10919
11026
|
walk2(full);
|
|
10920
11027
|
} else if (entry.isFile()) {
|
|
10921
11028
|
found.push(full);
|
|
@@ -10923,29 +11030,29 @@ function sourceTreeFiles(dir, canonicalRoot) {
|
|
|
10923
11030
|
}
|
|
10924
11031
|
}
|
|
10925
11032
|
};
|
|
10926
|
-
if (
|
|
11033
|
+
if (import_node_fs17.default.existsSync(dir)) walk2(import_node_fs17.default.realpathSync(dir));
|
|
10927
11034
|
return found;
|
|
10928
11035
|
}
|
|
10929
11036
|
function readPackageFile(root, file, maxBytes) {
|
|
10930
|
-
const canonicalRoot =
|
|
10931
|
-
const relative2 =
|
|
10932
|
-
if (relative2 === ".." || relative2.startsWith(`..${
|
|
11037
|
+
const canonicalRoot = import_node_fs17.default.realpathSync(root);
|
|
11038
|
+
const relative2 = import_node_path18.default.relative(canonicalRoot, import_node_fs17.default.realpathSync(file));
|
|
11039
|
+
if (relative2 === ".." || relative2.startsWith(`..${import_node_path18.default.sep}`) || import_node_path18.default.isAbsolute(relative2)) {
|
|
10933
11040
|
throw new Error(`swift input escapes the selected package: ${file}`);
|
|
10934
11041
|
}
|
|
10935
|
-
let ancestor =
|
|
11042
|
+
let ancestor = import_node_path18.default.resolve(file);
|
|
10936
11043
|
while (ancestor !== canonicalRoot) {
|
|
10937
|
-
if (
|
|
11044
|
+
if (import_node_fs17.default.lstatSync(ancestor).isSymbolicLink()) {
|
|
10938
11045
|
throw new Error(`swift input is a symlink: ${ancestor}`);
|
|
10939
11046
|
}
|
|
10940
|
-
const parent =
|
|
11047
|
+
const parent = import_node_path18.default.dirname(ancestor);
|
|
10941
11048
|
if (parent === ancestor)
|
|
10942
11049
|
throw new Error(`swift input escapes the selected package: ${file}`);
|
|
10943
11050
|
ancestor = parent;
|
|
10944
11051
|
}
|
|
10945
|
-
const expected =
|
|
10946
|
-
const fd =
|
|
11052
|
+
const expected = import_node_fs17.default.statSync(file);
|
|
11053
|
+
const fd = import_node_fs17.default.openSync(file, import_node_fs17.default.constants.O_RDONLY | import_node_fs17.default.constants.O_NOFOLLOW);
|
|
10947
11054
|
try {
|
|
10948
|
-
const stat2 =
|
|
11055
|
+
const stat2 = import_node_fs17.default.fstatSync(fd);
|
|
10949
11056
|
if (stat2.dev !== expected.dev || stat2.ino !== expected.ino) {
|
|
10950
11057
|
throw new Error(`swift input changed while opening: ${file}`);
|
|
10951
11058
|
}
|
|
@@ -10955,16 +11062,16 @@ function readPackageFile(root, file, maxBytes) {
|
|
|
10955
11062
|
const bytes = Buffer.alloc(stat2.size + 1);
|
|
10956
11063
|
let offset = 0;
|
|
10957
11064
|
while (offset < bytes.length) {
|
|
10958
|
-
const count =
|
|
11065
|
+
const count = import_node_fs17.default.readSync(fd, bytes, offset, bytes.length - offset, null);
|
|
10959
11066
|
if (count === 0) break;
|
|
10960
11067
|
offset += count;
|
|
10961
11068
|
}
|
|
10962
|
-
if (offset !== stat2.size ||
|
|
11069
|
+
if (offset !== stat2.size || import_node_fs17.default.fstatSync(fd).size !== stat2.size) {
|
|
10963
11070
|
throw new Error(`swift input changed while reading: ${file}`);
|
|
10964
11071
|
}
|
|
10965
11072
|
return bytes.subarray(0, offset);
|
|
10966
11073
|
} finally {
|
|
10967
|
-
|
|
11074
|
+
import_node_fs17.default.closeSync(fd);
|
|
10968
11075
|
}
|
|
10969
11076
|
}
|
|
10970
11077
|
function sourceFiles(root) {
|
|
@@ -10972,7 +11079,7 @@ function sourceFiles(root) {
|
|
|
10972
11079
|
}
|
|
10973
11080
|
function resourceCandidateFiles(root) {
|
|
10974
11081
|
return packageFiles(root).filter(
|
|
10975
|
-
(file) => !file.endsWith(".swift") && !["project.pbxproj", "project.xcproj"].includes(
|
|
11082
|
+
(file) => !file.endsWith(".swift") && !["project.pbxproj", "project.xcproj"].includes(import_node_path18.default.basename(file))
|
|
10976
11083
|
);
|
|
10977
11084
|
}
|
|
10978
11085
|
var HOSTED_LIMITS = {
|
|
@@ -11006,7 +11113,7 @@ function buildSwiftResourceTable(project, baseUrl) {
|
|
|
11006
11113
|
const limits = inputLimits(Boolean(project.hosted));
|
|
11007
11114
|
const absolute = resourceCandidateFiles(project.packagePath);
|
|
11008
11115
|
const relative2 = absolute.map(
|
|
11009
|
-
(file) =>
|
|
11116
|
+
(file) => import_node_path18.default.relative(project.packagePath, file).split(import_node_path18.default.sep).join(import_node_path18.default.posix.sep)
|
|
11010
11117
|
);
|
|
11011
11118
|
const byRelative = new Map(absolute.map((file, index) => [relative2[index], file]));
|
|
11012
11119
|
const readContents = (candidate) => {
|
|
@@ -11028,16 +11135,16 @@ function buildSwiftResourceTable(project, baseUrl) {
|
|
|
11028
11135
|
for (const { name: name2, file, scale } of found) {
|
|
11029
11136
|
const disk = byRelative.get(file);
|
|
11030
11137
|
if (!disk) continue;
|
|
11031
|
-
if (Object.keys(images).length >= limits.images || imageBytes +
|
|
11138
|
+
if (Object.keys(images).length >= limits.images || imageBytes + import_node_fs17.default.statSync(disk).size > limits.imageTotalBytes) {
|
|
11032
11139
|
throw new Error("swift image pack exceeds the compile service caps");
|
|
11033
11140
|
}
|
|
11034
11141
|
const bytes = readPackageFile(project.packagePath, disk, limits.imageBytes);
|
|
11035
11142
|
imageBytes += bytes.length;
|
|
11036
|
-
const hash = (0,
|
|
11037
|
-
const ext =
|
|
11143
|
+
const hash = (0, import_node_crypto7.createHash)("sha256").update(bytes).digest("hex").slice(0, 16);
|
|
11144
|
+
const ext = import_node_path18.default.posix.extname(file).toLowerCase();
|
|
11038
11145
|
table[name2] = { uri: `${baseUrl}${RESOURCE_PATH}${hash}${ext}`, scale };
|
|
11039
11146
|
images[name2] = {
|
|
11040
|
-
file:
|
|
11147
|
+
file: import_node_path18.default.posix.basename(file),
|
|
11041
11148
|
data: bytes.toString("base64")
|
|
11042
11149
|
};
|
|
11043
11150
|
watched.push(file);
|
|
@@ -11061,10 +11168,10 @@ function buildSwiftResourceTable(project, baseUrl) {
|
|
|
11061
11168
|
return { table, images, colors, symbols, watched };
|
|
11062
11169
|
}
|
|
11063
11170
|
function buildSwiftBundleFiles(packagePath, hosted) {
|
|
11064
|
-
packagePath =
|
|
11171
|
+
packagePath = import_node_fs17.default.realpathSync(packagePath);
|
|
11065
11172
|
const limits = inputLimits(hosted);
|
|
11066
11173
|
const relative2 = resourceCandidateFiles(packagePath).map(
|
|
11067
|
-
(file) =>
|
|
11174
|
+
(file) => import_node_path18.default.relative(packagePath, file).split(import_node_path18.default.sep).join(import_node_path18.default.posix.sep)
|
|
11068
11175
|
);
|
|
11069
11176
|
const files = {};
|
|
11070
11177
|
const watched = [];
|
|
@@ -11078,13 +11185,13 @@ function buildSwiftBundleFiles(packagePath, hosted) {
|
|
|
11078
11185
|
total += bytes.length;
|
|
11079
11186
|
if (xcode.app.infoPlistFile)
|
|
11080
11187
|
watched.push(
|
|
11081
|
-
|
|
11188
|
+
import_node_path18.default.relative(packagePath, xcode.app.infoPlistFile).split(import_node_path18.default.sep).join("/")
|
|
11082
11189
|
);
|
|
11083
11190
|
}
|
|
11084
11191
|
for (const { base, file } of enumerateBundleJson(relative2)) {
|
|
11085
11192
|
watched.push(file);
|
|
11086
|
-
const disk =
|
|
11087
|
-
if (Object.keys(files).length >= limits.resources || total +
|
|
11193
|
+
const disk = import_node_path18.default.join(packagePath, ...file.split("/"));
|
|
11194
|
+
if (Object.keys(files).length >= limits.resources || total + import_node_fs17.default.statSync(disk).size > limits.resourceTotalBytes) {
|
|
11088
11195
|
throw new Error(
|
|
11089
11196
|
`swift bundle pack exceeds ${limits.resources} files / ${limits.resourceTotalBytes} bytes`
|
|
11090
11197
|
);
|
|
@@ -11099,12 +11206,12 @@ function serveSwiftResource(project, key) {
|
|
|
11099
11206
|
return project.resourceFiles.get(key) ?? project.resourcesPrevious.get(key) ?? null;
|
|
11100
11207
|
}
|
|
11101
11208
|
function linkedModuleRoots(packagePath) {
|
|
11102
|
-
packagePath =
|
|
11209
|
+
packagePath = import_node_fs17.default.realpathSync(packagePath);
|
|
11103
11210
|
let manifest;
|
|
11104
11211
|
try {
|
|
11105
11212
|
manifest = readPackageFile(
|
|
11106
11213
|
packagePath,
|
|
11107
|
-
|
|
11214
|
+
import_node_path18.default.join(packagePath, "Package.swift"),
|
|
11108
11215
|
MAX_SWIFT_COMPILE_SOURCE_BYTES
|
|
11109
11216
|
).toString("utf8");
|
|
11110
11217
|
} catch {
|
|
@@ -11113,28 +11220,28 @@ function linkedModuleRoots(packagePath) {
|
|
|
11113
11220
|
const roots = /* @__PURE__ */ new Set();
|
|
11114
11221
|
const dependency = /\.package\(\s*path:\s*"([^"]+)"\s*\)/g;
|
|
11115
11222
|
for (const match of manifest.replace(/^\s*\/\/.*$/gm, "").matchAll(dependency)) {
|
|
11116
|
-
const root =
|
|
11117
|
-
if (
|
|
11223
|
+
const root = import_node_path18.default.resolve(packagePath, match[1]);
|
|
11224
|
+
if (import_node_fs17.default.existsSync(import_node_path18.default.join(root, "Package.swift"))) roots.add(root);
|
|
11118
11225
|
}
|
|
11119
11226
|
return [...roots].sort();
|
|
11120
11227
|
}
|
|
11121
11228
|
function sourceStamp(packagePath, moduleRootOverride, hosted = false) {
|
|
11122
|
-
const hash = (0,
|
|
11229
|
+
const hash = (0, import_node_crypto7.createHash)("sha256");
|
|
11123
11230
|
hash.update(packagePath);
|
|
11124
11231
|
const projectInputs = new Set(packageFiles(packagePath));
|
|
11125
11232
|
for (const file of [...projectInputs].sort()) {
|
|
11126
|
-
hash.update(
|
|
11127
|
-
const stat2 =
|
|
11233
|
+
hash.update(import_node_path18.default.relative(packagePath, file));
|
|
11234
|
+
const stat2 = import_node_fs17.default.statSync(file);
|
|
11128
11235
|
hash.update(`${stat2.mtimeMs}/${stat2.ctimeMs}/${stat2.size}`);
|
|
11129
11236
|
}
|
|
11130
11237
|
const moduleRoot = hosted ? void 0 : moduleRootOverride ?? linkedModuleRoots(packagePath).find(
|
|
11131
|
-
(root) =>
|
|
11238
|
+
(root) => import_node_fs17.default.existsSync(import_node_path18.default.join(root, "toolchain.json"))
|
|
11132
11239
|
);
|
|
11133
11240
|
if (moduleRoot) {
|
|
11134
11241
|
hash.update(moduleRoot);
|
|
11135
11242
|
for (const relative2 of swiftModuleInputFiles(moduleRoot)) {
|
|
11136
11243
|
hash.update(relative2);
|
|
11137
|
-
hash.update(String(
|
|
11244
|
+
hash.update(String(import_node_fs17.default.statSync(import_node_path18.default.join(moduleRoot, relative2)).mtimeMs));
|
|
11138
11245
|
}
|
|
11139
11246
|
}
|
|
11140
11247
|
return hash.digest("hex").slice(0, 16);
|
|
@@ -11146,8 +11253,8 @@ function packageSources(packagePath) {
|
|
|
11146
11253
|
const xcode = xcodeLayout(packagePath);
|
|
11147
11254
|
const files = {};
|
|
11148
11255
|
for (const file of sourceFiles(packagePath)) {
|
|
11149
|
-
const relative2 =
|
|
11150
|
-
if (xcode &&
|
|
11256
|
+
const relative2 = import_node_path18.default.relative(packagePath, file).split(import_node_path18.default.sep).join(import_node_path18.default.posix.sep);
|
|
11257
|
+
if (xcode && import_node_path18.default.basename(file) === "Package.swift") continue;
|
|
11151
11258
|
files[xcode ? xcodeInputKey(xcode, file, relative2) : relative2] = readPackageFile(
|
|
11152
11259
|
packagePath,
|
|
11153
11260
|
file,
|
|
@@ -11164,7 +11271,7 @@ function packageSnapshot(project) {
|
|
|
11164
11271
|
files,
|
|
11165
11272
|
resourcePaths: swiftImplicitResourcePaths(
|
|
11166
11273
|
resourceCandidateFiles(project.packagePath).map(
|
|
11167
|
-
(file) =>
|
|
11274
|
+
(file) => import_node_path18.default.relative(project.packagePath, file).split(import_node_path18.default.sep).join(import_node_path18.default.posix.sep)
|
|
11168
11275
|
)
|
|
11169
11276
|
),
|
|
11170
11277
|
resources: buildSwiftResourceTable(project, ""),
|
|
@@ -11173,7 +11280,7 @@ function packageSnapshot(project) {
|
|
|
11173
11280
|
...native ? {
|
|
11174
11281
|
glue: readPackageFile(
|
|
11175
11282
|
project.packagePath,
|
|
11176
|
-
|
|
11283
|
+
import_node_path18.default.join(project.packagePath, NATIVE_GLUE),
|
|
11177
11284
|
MAX_SWIFT_COMPILE_SOURCE_BYTES
|
|
11178
11285
|
).toString("utf8")
|
|
11179
11286
|
} : {}
|
|
@@ -11209,7 +11316,7 @@ async function compile(packagePath, entry, stamp, moduleRootOverride, hosted, sn
|
|
|
11209
11316
|
package: content
|
|
11210
11317
|
};
|
|
11211
11318
|
const moduleRoot = moduleRootOverride ?? linkedModuleRoots(packagePath).find(
|
|
11212
|
-
(root) =>
|
|
11319
|
+
(root) => import_node_fs17.default.existsSync(import_node_path18.default.join(root, "toolchain.json"))
|
|
11213
11320
|
) ?? await swiftDistributionRoot();
|
|
11214
11321
|
if (!moduleRoot)
|
|
11215
11322
|
return {
|
|
@@ -11228,17 +11335,17 @@ async function compile(packagePath, entry, stamp, moduleRootOverride, hosted, sn
|
|
|
11228
11335
|
...targets.length > 0 ? targets : ["App"]
|
|
11229
11336
|
])
|
|
11230
11337
|
);
|
|
11231
|
-
if (missing.size > 0) throw new Error(missingModulesMessage(packagePath, missing));
|
|
11338
|
+
if (missing.size > 0) throw new Error(await missingModulesMessage(packagePath, missing));
|
|
11232
11339
|
const artifact = await compileSwiftProjectUnit(input, {
|
|
11233
11340
|
// the compile rewrites Sources/App in its root before swiftpm builds, and
|
|
11234
11341
|
// its lock orders one process only: two vites on one root (a lane's dev
|
|
11235
11342
|
// server and a capture, or two checkouts) build each other's sources. so
|
|
11236
11343
|
// each app and module checkout gets its own root, which keeps the same
|
|
11237
11344
|
// app's incremental build across restarts.
|
|
11238
|
-
buildRoot: process.env.CONTRAST_SWIFT_BUILD_ROOT ??
|
|
11239
|
-
|
|
11345
|
+
buildRoot: process.env.CONTRAST_SWIFT_BUILD_ROOT ?? import_node_path18.default.join(
|
|
11346
|
+
import_node_os7.default.tmpdir(),
|
|
11240
11347
|
"contrast-swift-build",
|
|
11241
|
-
(0,
|
|
11348
|
+
(0, import_node_crypto7.createHash)("sha256").update(`${moduleRoot}\0${import_node_path18.default.resolve(packagePath)}`).digest("hex").slice(0, 16)
|
|
11242
11349
|
),
|
|
11243
11350
|
moduleRoot,
|
|
11244
11351
|
...toolchain
|
|
@@ -11306,7 +11413,7 @@ var UNPROVIDED_PLATFORM_MODULES = {
|
|
|
11306
11413
|
MachO: "Peach compiles for WebAssembly, which has no Mach-O images"
|
|
11307
11414
|
};
|
|
11308
11415
|
var IOS_SDK_FRAMEWORKS = new Set(ios_sdk_frameworks_default.frameworks);
|
|
11309
|
-
function missingModulesMessage(packagePath, missing) {
|
|
11416
|
+
async function missingModulesMessage(packagePath, missing) {
|
|
11310
11417
|
const layout = xcodeLayout(packagePath);
|
|
11311
11418
|
const gaps = new Map([
|
|
11312
11419
|
...(layout?.app.binaryFrameworks ?? []).map(
|
|
@@ -11328,12 +11435,29 @@ function missingModulesMessage(packagePath, missing) {
|
|
|
11328
11435
|
...layout?.packages.modules ?? [],
|
|
11329
11436
|
...layout?.packages.unavailable ?? []
|
|
11330
11437
|
]);
|
|
11438
|
+
const packaged = new Set(
|
|
11439
|
+
[...missing.keys()].filter(
|
|
11440
|
+
(name2) => !UNPROVIDED_PLATFORM_MODULES[name2] && !IOS_SDK_FRAMEWORKS.has(name2)
|
|
11441
|
+
)
|
|
11442
|
+
);
|
|
11443
|
+
if (packaged.size > 0)
|
|
11444
|
+
await Promise.all(
|
|
11445
|
+
(layout?.packages.binaries ?? []).map(async (binary) => {
|
|
11446
|
+
const modules = await swiftBinaryModules(binary).catch(() => []);
|
|
11447
|
+
for (const name2 of modules)
|
|
11448
|
+
if (packaged.has(name2))
|
|
11449
|
+
gaps.set(name2, {
|
|
11450
|
+
source: binary.source,
|
|
11451
|
+
reason: `${binary.target} is a binary framework`
|
|
11452
|
+
});
|
|
11453
|
+
})
|
|
11454
|
+
);
|
|
11331
11455
|
const width = Math.max(...[...missing.keys()].map((name2) => name2.length));
|
|
11332
11456
|
return [
|
|
11333
11457
|
`Peach does not provide ${missing.size} module${missing.size === 1 ? "" : "s"} this app imports:`,
|
|
11334
11458
|
...[...missing].map(([name2, files]) => {
|
|
11335
11459
|
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 ${
|
|
11460
|
+
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
11461
|
})
|
|
11338
11462
|
].join("\n");
|
|
11339
11463
|
}
|
|
@@ -11341,7 +11465,7 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
|
|
|
11341
11465
|
const auth = hosted ? null : resolveCliAuth();
|
|
11342
11466
|
if (!hosted && (!auth || auth.kind === "github")) {
|
|
11343
11467
|
throw new Error(
|
|
11344
|
-
`compiling ${
|
|
11468
|
+
`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
11469
|
);
|
|
11346
11470
|
}
|
|
11347
11471
|
const origin = hosted?.origin ?? resolveContrastBackendOrigin(auth?.kind === "session" ? auth.origin : null);
|
|
@@ -11360,7 +11484,7 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
|
|
|
11360
11484
|
const bytes = sources.reduce((total2, text2) => total2 + Buffer.byteLength(text2), 0);
|
|
11361
11485
|
if (sources.length > MAX_SWIFT_COMPILE_FILES || bytes > MAX_SWIFT_COMPILE_SOURCE_BYTES) {
|
|
11362
11486
|
throw new Error(
|
|
11363
|
-
`${
|
|
11487
|
+
`${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
11488
|
);
|
|
11365
11489
|
}
|
|
11366
11490
|
const descriptor = snapshot.native;
|
|
@@ -11379,7 +11503,7 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
|
|
|
11379
11503
|
);
|
|
11380
11504
|
if (descriptor && address.native?.hash !== descriptor.hash) {
|
|
11381
11505
|
throw new Error(
|
|
11382
|
-
`${
|
|
11506
|
+
`${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
11507
|
);
|
|
11384
11508
|
}
|
|
11385
11509
|
const response = await fetch(address.url, { signal });
|
|
@@ -11503,8 +11627,8 @@ var scriptEnv = { ...process.env, [RNX_FORKED_SCRIPT_ENV]: "1" };
|
|
|
11503
11627
|
var EXPO_SWIFT_ROUTE = "/__peach/expo-swift";
|
|
11504
11628
|
var EXPO_SWIFT_ENTRY = "Sources/PeachExpoApp/PeachExpoEntry.swift";
|
|
11505
11629
|
async function collectExpoSwiftSources(appRoot) {
|
|
11506
|
-
appRoot =
|
|
11507
|
-
const appRequire = (0, import_node_module.createRequire)(
|
|
11630
|
+
appRoot = import_node_fs18.default.realpathSync(appRoot);
|
|
11631
|
+
const appRequire = (0, import_node_module.createRequire)(import_node_path19.default.join(appRoot, "package.json"));
|
|
11508
11632
|
let autolinker;
|
|
11509
11633
|
try {
|
|
11510
11634
|
autolinker = appRequire.resolve("expo-modules-autolinking/package.json");
|
|
@@ -11518,7 +11642,7 @@ async function collectExpoSwiftSources(appRoot) {
|
|
|
11518
11642
|
(command) => run3(
|
|
11519
11643
|
process.execPath,
|
|
11520
11644
|
[
|
|
11521
|
-
|
|
11645
|
+
import_node_path19.default.join(import_node_path19.default.dirname(autolinker), "bin/expo-modules-autolinking.js"),
|
|
11522
11646
|
command,
|
|
11523
11647
|
"--platform",
|
|
11524
11648
|
"apple",
|
|
@@ -11549,8 +11673,8 @@ async function collectExpoSwiftSources(appRoot) {
|
|
|
11549
11673
|
const sourceRoot = Reflect.get(entry, "path");
|
|
11550
11674
|
if (typeof sourceRoot !== "string")
|
|
11551
11675
|
throw new Error("Expo autolinking entry has no path");
|
|
11552
|
-
const canonical =
|
|
11553
|
-
if (canonical.split(
|
|
11676
|
+
const canonical = import_node_fs18.default.realpathSync(sourceRoot);
|
|
11677
|
+
if (canonical.split(import_node_path19.default.sep).includes("node_modules")) continue;
|
|
11554
11678
|
const resolution = resolutions.find(
|
|
11555
11679
|
(candidate) => candidate && typeof candidate === "object" && Reflect.get(candidate, "packageName") === Reflect.get(entry, "name")
|
|
11556
11680
|
);
|
|
@@ -11576,12 +11700,12 @@ async function collectExpoSwiftSources(appRoot) {
|
|
|
11576
11700
|
`(${className.includes(".") ? className : `${namespace}.${className}`}.self, ${name2 === null ? "nil" : JSON.stringify(name2)})`
|
|
11577
11701
|
);
|
|
11578
11702
|
}
|
|
11579
|
-
const ios =
|
|
11580
|
-
if (
|
|
11703
|
+
const ios = import_node_path19.default.join(canonical, "ios");
|
|
11704
|
+
if (import_node_fs18.default.lstatSync(ios).isSymbolicLink())
|
|
11581
11705
|
throw new Error(`Expo Swift source directory is a symlink: ${ios}`);
|
|
11582
11706
|
const walk2 = (dir) => {
|
|
11583
|
-
for (const child of
|
|
11584
|
-
const file =
|
|
11707
|
+
for (const child of import_node_fs18.default.readdirSync(dir, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
11708
|
+
const file = import_node_path19.default.join(dir, child.name);
|
|
11585
11709
|
if (child.isSymbolicLink())
|
|
11586
11710
|
throw new Error(`Expo Swift source is a symlink: ${file}`);
|
|
11587
11711
|
if (child.isDirectory()) {
|
|
@@ -11589,13 +11713,13 @@ async function collectExpoSwiftSources(appRoot) {
|
|
|
11589
11713
|
continue;
|
|
11590
11714
|
}
|
|
11591
11715
|
if (!child.name.endsWith(".swift")) continue;
|
|
11592
|
-
const size =
|
|
11716
|
+
const size = import_node_fs18.default.statSync(file).size;
|
|
11593
11717
|
bytes += size;
|
|
11594
11718
|
fileCount++;
|
|
11595
11719
|
if (fileCount > MAX_SWIFT_COMPILE_FILES - 2 || bytes > MAX_SWIFT_COMPILE_SOURCE_BYTES)
|
|
11596
11720
|
throw new Error("Expo Swift sources exceed compile service caps");
|
|
11597
|
-
files[`Sources/${namespace}/${
|
|
11598
|
-
${
|
|
11721
|
+
files[`Sources/${namespace}/${import_node_path19.default.relative(ios, file).split(import_node_path19.default.sep).join("/")}`] = `#sourceLocation(file: ${JSON.stringify(file)}, line: 1)
|
|
11722
|
+
${import_node_fs18.default.readFileSync(file, "utf8")}`;
|
|
11599
11723
|
}
|
|
11600
11724
|
};
|
|
11601
11725
|
walk2(ios);
|
|
@@ -11680,7 +11804,7 @@ async function handleExpoSwiftRequest(req, res) {
|
|
|
11680
11804
|
return true;
|
|
11681
11805
|
}
|
|
11682
11806
|
const root = url.searchParams.get("root");
|
|
11683
|
-
if (!root || !
|
|
11807
|
+
if (!root || !import_node_path19.default.isAbsolute(root)) {
|
|
11684
11808
|
res.writeHead(400);
|
|
11685
11809
|
res.end("missing absolute app root");
|
|
11686
11810
|
return true;
|
|
@@ -11697,7 +11821,7 @@ async function handleExpoSwiftRequest(req, res) {
|
|
|
11697
11821
|
modules: [],
|
|
11698
11822
|
failures: []
|
|
11699
11823
|
};
|
|
11700
|
-
const key = (0,
|
|
11824
|
+
const key = (0, import_node_crypto8.createHash)("sha256").update(import_node_fs18.default.realpathSync(root)).digest("hex");
|
|
11701
11825
|
const host2 = req.headers.host;
|
|
11702
11826
|
if (!host2) throw new Error("Expo Swift request has no host");
|
|
11703
11827
|
const base = `http://${host2}`;
|
|
@@ -11711,8 +11835,8 @@ async function handleExpoSwiftRequest(req, res) {
|
|
|
11711
11835
|
continue;
|
|
11712
11836
|
}
|
|
11713
11837
|
try {
|
|
11714
|
-
const packagePath =
|
|
11715
|
-
|
|
11838
|
+
const packagePath = import_node_path19.default.join(
|
|
11839
|
+
import_node_os8.default.tmpdir(),
|
|
11716
11840
|
"peach-expo-swift",
|
|
11717
11841
|
key,
|
|
11718
11842
|
unit.namespace
|
|
@@ -11721,7 +11845,7 @@ async function handleExpoSwiftRequest(req, res) {
|
|
|
11721
11845
|
packagePath,
|
|
11722
11846
|
new Map(
|
|
11723
11847
|
Object.entries(unit.files).map(([name2, source]) => [
|
|
11724
|
-
|
|
11848
|
+
import_node_path19.default.join(packagePath, name2),
|
|
11725
11849
|
source
|
|
11726
11850
|
])
|
|
11727
11851
|
)
|
|
@@ -11772,8 +11896,8 @@ async function handleExpoSwiftRequest(req, res) {
|
|
|
11772
11896
|
import PackageDescription
|
|
11773
11897
|
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
11898
|
`;
|
|
11775
|
-
const packagePath =
|
|
11776
|
-
|
|
11899
|
+
const packagePath = import_node_path19.default.join(
|
|
11900
|
+
import_node_os8.default.tmpdir(),
|
|
11777
11901
|
"peach-expo-swift",
|
|
11778
11902
|
key,
|
|
11779
11903
|
"linked-app"
|
|
@@ -11782,7 +11906,7 @@ let package = Package(name: "PeachExpo", targets: [${targets.map((name2) => `.ta
|
|
|
11782
11906
|
packagePath,
|
|
11783
11907
|
new Map(
|
|
11784
11908
|
Object.entries(files).map(([name2, source]) => [
|
|
11785
|
-
|
|
11909
|
+
import_node_path19.default.join(packagePath, name2),
|
|
11786
11910
|
source
|
|
11787
11911
|
])
|
|
11788
11912
|
)
|
|
@@ -11892,10 +12016,10 @@ function resolveRuntimeRootForHostname(hostname) {
|
|
|
11892
12016
|
}
|
|
11893
12017
|
function sendFileWithRanges(req, res, filePath, total, headers) {
|
|
11894
12018
|
const head = (req?.method || "GET").toUpperCase() === "HEAD";
|
|
11895
|
-
const
|
|
11896
|
-
const invalid =
|
|
11897
|
-
if (
|
|
11898
|
-
const [, startRaw, endRaw] =
|
|
12019
|
+
const range2 = /^bytes=(\d*)-(\d*)$/.exec(req?.headers?.range || "");
|
|
12020
|
+
const invalid = range2 && range2[1] && range2[2] && Number(range2[2]) < Number(range2[1]);
|
|
12021
|
+
if (range2 && (range2[1] || range2[2]) && !invalid) {
|
|
12022
|
+
const [, startRaw, endRaw] = range2;
|
|
11899
12023
|
const start = startRaw ? Number(startRaw) : Math.max(0, total - Number(endRaw));
|
|
11900
12024
|
const end = startRaw && endRaw ? Math.min(Number(endRaw), total - 1) : total - 1;
|
|
11901
12025
|
if (start > end || start >= total) {
|
|
@@ -11955,20 +12079,20 @@ var RNX_RUNTIME_PRODUCT = {
|
|
|
11955
12079
|
var rnxRuntime = createRuntimeDelivery(RNX_RUNTIME_PRODUCT);
|
|
11956
12080
|
|
|
11957
12081
|
// src/host/agent-host.ts
|
|
11958
|
-
var
|
|
11959
|
-
var
|
|
11960
|
-
var
|
|
12082
|
+
var import_node_crypto11 = require("node:crypto");
|
|
12083
|
+
var import_node_fs22 = __toESM(require("node:fs"), 1);
|
|
12084
|
+
var import_node_path23 = __toESM(require("node:path"), 1);
|
|
11961
12085
|
|
|
11962
12086
|
// src/agent-sessions.ts
|
|
11963
12087
|
var import_node_child_process9 = require("node:child_process");
|
|
11964
|
-
var
|
|
11965
|
-
var
|
|
11966
|
-
var
|
|
12088
|
+
var import_node_crypto10 = require("node:crypto");
|
|
12089
|
+
var import_node_fs21 = __toESM(require("node:fs"), 1);
|
|
12090
|
+
var import_node_path22 = __toESM(require("node:path"), 1);
|
|
11967
12091
|
var import_node_readline = __toESM(require("node:readline"), 1);
|
|
11968
12092
|
|
|
11969
12093
|
// cli/self-invocation.ts
|
|
11970
|
-
var
|
|
11971
|
-
var
|
|
12094
|
+
var import_node_fs19 = require("node:fs");
|
|
12095
|
+
var import_node_path20 = require("node:path");
|
|
11972
12096
|
var import_node_url3 = require("node:url");
|
|
11973
12097
|
init_public_brand();
|
|
11974
12098
|
|
|
@@ -11978,14 +12102,14 @@ var IS_STANDALONE = typeof __SOOTSIM_STANDALONE__ !== "undefined" && __SOOTSIM_S
|
|
|
11978
12102
|
// cli/self-invocation.ts
|
|
11979
12103
|
function sourceEntryPath() {
|
|
11980
12104
|
try {
|
|
11981
|
-
const candidate = (0,
|
|
11982
|
-
return (0,
|
|
12105
|
+
const candidate = (0, import_node_path20.join)((0, import_node_path20.dirname)((0, import_node_url3.fileURLToPath)(__sootsim_import_meta_url)), "bin.ts");
|
|
12106
|
+
return (0, import_node_fs19.existsSync)(candidate) ? candidate : null;
|
|
11983
12107
|
} catch {
|
|
11984
12108
|
return null;
|
|
11985
12109
|
}
|
|
11986
12110
|
}
|
|
11987
|
-
function isCliEntry(
|
|
11988
|
-
const name2 = (0,
|
|
12111
|
+
function isCliEntry(path23) {
|
|
12112
|
+
const name2 = (0, import_node_path20.basename)(path23);
|
|
11989
12113
|
return name2 === "bin.ts" || name2 === "bin.js";
|
|
11990
12114
|
}
|
|
11991
12115
|
function rnxSelfInvocation() {
|
|
@@ -12044,9 +12168,9 @@ function encodeAgentPromptEnvelope(input) {
|
|
|
12044
12168
|
}
|
|
12045
12169
|
|
|
12046
12170
|
// src/attached-projects.ts
|
|
12047
|
-
var
|
|
12048
|
-
var
|
|
12049
|
-
var
|
|
12171
|
+
var import_node_crypto9 = require("node:crypto");
|
|
12172
|
+
var import_node_fs20 = __toESM(require("node:fs"), 1);
|
|
12173
|
+
var import_node_path21 = __toESM(require("node:path"), 1);
|
|
12050
12174
|
init_home_paths();
|
|
12051
12175
|
var overrideDir = null;
|
|
12052
12176
|
function userDataDir() {
|
|
@@ -12059,7 +12183,7 @@ function getUserDataDir() {
|
|
|
12059
12183
|
return userDataDir();
|
|
12060
12184
|
}
|
|
12061
12185
|
function storeFile() {
|
|
12062
|
-
return
|
|
12186
|
+
return import_node_path21.default.join(userDataDir(), "attached-projects.json");
|
|
12063
12187
|
}
|
|
12064
12188
|
function cloneEmpty() {
|
|
12065
12189
|
return {
|
|
@@ -12073,7 +12197,7 @@ function loadStore() {
|
|
|
12073
12197
|
const file = storeFile();
|
|
12074
12198
|
let raw2;
|
|
12075
12199
|
try {
|
|
12076
|
-
raw2 =
|
|
12200
|
+
raw2 = import_node_fs20.default.readFileSync(file, "utf8");
|
|
12077
12201
|
} catch (err) {
|
|
12078
12202
|
if (err.code === "ENOENT") return cloneEmpty();
|
|
12079
12203
|
throw err;
|
|
@@ -12090,7 +12214,7 @@ function loadStore() {
|
|
|
12090
12214
|
} catch (err) {
|
|
12091
12215
|
const quarantine = `${file}.corrupt-${Date.now()}`;
|
|
12092
12216
|
try {
|
|
12093
|
-
|
|
12217
|
+
import_node_fs20.default.renameSync(file, quarantine);
|
|
12094
12218
|
console.warn(
|
|
12095
12219
|
`[sootsim] attached-projects.json was unparseable; quarantined to ${quarantine}. original error: ${err.message}`
|
|
12096
12220
|
);
|
|
@@ -12101,16 +12225,16 @@ function loadStore() {
|
|
|
12101
12225
|
}
|
|
12102
12226
|
function writeStore(store) {
|
|
12103
12227
|
const file = storeFile();
|
|
12104
|
-
|
|
12228
|
+
import_node_fs20.default.mkdirSync(import_node_path21.default.dirname(file), { recursive: true });
|
|
12105
12229
|
const tmp = `${file}.tmp-${process.pid}-${Date.now()}`;
|
|
12106
|
-
const fd =
|
|
12230
|
+
const fd = import_node_fs20.default.openSync(tmp, "w", 384);
|
|
12107
12231
|
try {
|
|
12108
|
-
|
|
12109
|
-
|
|
12232
|
+
import_node_fs20.default.writeFileSync(fd, JSON.stringify(store, null, 2));
|
|
12233
|
+
import_node_fs20.default.fsyncSync(fd);
|
|
12110
12234
|
} finally {
|
|
12111
|
-
|
|
12235
|
+
import_node_fs20.default.closeSync(fd);
|
|
12112
12236
|
}
|
|
12113
|
-
|
|
12237
|
+
import_node_fs20.default.renameSync(tmp, file);
|
|
12114
12238
|
}
|
|
12115
12239
|
function mutateStore(fn) {
|
|
12116
12240
|
const store = loadStore();
|
|
@@ -12119,13 +12243,13 @@ function mutateStore(fn) {
|
|
|
12119
12243
|
return store;
|
|
12120
12244
|
}
|
|
12121
12245
|
function projectIdForCwd(cwd) {
|
|
12122
|
-
return (0,
|
|
12246
|
+
return (0, import_node_crypto9.createHash)("sha256").update(import_node_path21.default.resolve(cwd)).digest("hex").slice(0, 16);
|
|
12123
12247
|
}
|
|
12124
12248
|
function newSessionId() {
|
|
12125
|
-
return `s_${(0,
|
|
12249
|
+
return `s_${(0, import_node_crypto9.randomBytes)(10).toString("hex")}`;
|
|
12126
12250
|
}
|
|
12127
12251
|
function upsertProject(input) {
|
|
12128
|
-
const cwd =
|
|
12252
|
+
const cwd = import_node_path21.default.resolve(input.cwd);
|
|
12129
12253
|
const id = projectIdForCwd(cwd);
|
|
12130
12254
|
let result;
|
|
12131
12255
|
mutateStore((store) => {
|
|
@@ -12151,7 +12275,7 @@ function upsertProject(input) {
|
|
|
12151
12275
|
const now = Date.now();
|
|
12152
12276
|
const created = {
|
|
12153
12277
|
id,
|
|
12154
|
-
name: input.name ??
|
|
12278
|
+
name: input.name ?? import_node_path21.default.basename(cwd),
|
|
12155
12279
|
cwd,
|
|
12156
12280
|
repoRoot: input.repoRoot,
|
|
12157
12281
|
sourceRoots: input.sourceRoots ?? [cwd],
|
|
@@ -12297,8 +12421,8 @@ async function seedFromDemoAppRegistry() {
|
|
|
12297
12421
|
if (apps.length === 0) return;
|
|
12298
12422
|
mutateStore((store) => {
|
|
12299
12423
|
for (const app of apps) {
|
|
12300
|
-
if (!
|
|
12301
|
-
const cwd =
|
|
12424
|
+
if (!import_node_fs20.default.existsSync(app.dir)) continue;
|
|
12425
|
+
const cwd = import_node_path21.default.resolve(app.dir);
|
|
12302
12426
|
const id = projectIdForCwd(cwd);
|
|
12303
12427
|
if (store.attachedProjects.some((p) => p.id === id)) continue;
|
|
12304
12428
|
const now = Date.now();
|
|
@@ -12323,16 +12447,16 @@ async function seedFromDemoAppRegistry() {
|
|
|
12323
12447
|
// src/agent-sessions.ts
|
|
12324
12448
|
init_public_brand();
|
|
12325
12449
|
function sessionDir(sessionId) {
|
|
12326
|
-
return
|
|
12450
|
+
return import_node_path22.default.join(getUserDataDir(), "sessions", sessionId);
|
|
12327
12451
|
}
|
|
12328
12452
|
function promptFifoPath(sessionId) {
|
|
12329
|
-
return
|
|
12453
|
+
return import_node_path22.default.join(sessionDir(sessionId), "prompt.in");
|
|
12330
12454
|
}
|
|
12331
12455
|
function eventsFifoPath(sessionId) {
|
|
12332
|
-
return
|
|
12456
|
+
return import_node_path22.default.join(sessionDir(sessionId), "events.out");
|
|
12333
12457
|
}
|
|
12334
12458
|
function transcriptPath(sessionId) {
|
|
12335
|
-
return
|
|
12459
|
+
return import_node_path22.default.join(getUserDataDir(), "transcripts", `${sessionId}.log`);
|
|
12336
12460
|
}
|
|
12337
12461
|
function pidIsAlive(pid, sessionId) {
|
|
12338
12462
|
if (!pid) return false;
|
|
@@ -12342,7 +12466,7 @@ function pidIsAlive(pid, sessionId) {
|
|
|
12342
12466
|
return false;
|
|
12343
12467
|
}
|
|
12344
12468
|
if (sessionId) {
|
|
12345
|
-
if (!
|
|
12469
|
+
if (!import_node_fs21.default.existsSync(sessionDir(sessionId))) return false;
|
|
12346
12470
|
}
|
|
12347
12471
|
return true;
|
|
12348
12472
|
}
|
|
@@ -12355,11 +12479,11 @@ function resolveSootsimInvocation() {
|
|
|
12355
12479
|
const resourcesPath = process.resourcesPath;
|
|
12356
12480
|
if (resourcesPath) {
|
|
12357
12481
|
const candidates = [
|
|
12358
|
-
|
|
12359
|
-
|
|
12482
|
+
import_node_path22.default.join(resourcesPath, "bin", "sootsim"),
|
|
12483
|
+
import_node_path22.default.join(resourcesPath, "bin", `sootsim-${process.platform}-${process.arch}`)
|
|
12360
12484
|
];
|
|
12361
12485
|
for (const c of candidates) {
|
|
12362
|
-
if (
|
|
12486
|
+
if (import_node_fs21.default.existsSync(c)) return { executable: c, prefixArgs: [] };
|
|
12363
12487
|
}
|
|
12364
12488
|
}
|
|
12365
12489
|
}
|
|
@@ -12378,15 +12502,15 @@ function tryWorkspaceSootsim() {
|
|
|
12378
12502
|
const sootsimDir = resolveSootsimPackageDir();
|
|
12379
12503
|
if (!sootsimDir) return null;
|
|
12380
12504
|
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 (
|
|
12505
|
+
const distBinary = import_node_path22.default.join(sootsimDir, "dist-bin", binaryName);
|
|
12506
|
+
if (import_node_fs21.default.existsSync(distBinary)) return { executable: distBinary, prefixArgs: [] };
|
|
12507
|
+
const distBin = import_node_path22.default.join(sootsimDir, "dist-cli", "bin.js");
|
|
12508
|
+
if (import_node_fs21.default.existsSync(distBin)) {
|
|
12385
12509
|
try {
|
|
12386
|
-
const src =
|
|
12387
|
-
if (
|
|
12388
|
-
const srcMtime =
|
|
12389
|
-
const buildMtime =
|
|
12510
|
+
const src = import_node_path22.default.join(sootsimDir, "cli", "commands", "agent-wrapper.ts");
|
|
12511
|
+
if (import_node_fs21.default.existsSync(src)) {
|
|
12512
|
+
const srcMtime = import_node_fs21.default.statSync(src).mtimeMs;
|
|
12513
|
+
const buildMtime = import_node_fs21.default.statSync(distBin).mtimeMs;
|
|
12390
12514
|
if (buildMtime < srcMtime) {
|
|
12391
12515
|
console.warn(
|
|
12392
12516
|
`[peach] dist-cli/bin.js is older than agent-wrapper.ts \u2014 rebuild with \`bun run --cwd packages/peachsim build:cli\`.`
|
|
@@ -12405,22 +12529,22 @@ function tryWorkspaceSootsim() {
|
|
|
12405
12529
|
function resolveSootsimPackageDir() {
|
|
12406
12530
|
try {
|
|
12407
12531
|
const resolved = require.resolve(`${rnxPublicBrand.packageName}/package.json`);
|
|
12408
|
-
return
|
|
12532
|
+
return import_node_path22.default.dirname(resolved);
|
|
12409
12533
|
} catch {
|
|
12410
12534
|
}
|
|
12411
12535
|
const here = fileFromImportMeta();
|
|
12412
12536
|
if (!here) return null;
|
|
12413
|
-
let cur =
|
|
12537
|
+
let cur = import_node_path22.default.dirname(here);
|
|
12414
12538
|
for (let i = 0; i < 8; i++) {
|
|
12415
|
-
const pkg =
|
|
12539
|
+
const pkg = import_node_path22.default.join(cur, "package.json");
|
|
12416
12540
|
try {
|
|
12417
|
-
if (
|
|
12418
|
-
const parsed = JSON.parse(
|
|
12541
|
+
if (import_node_fs21.default.existsSync(pkg)) {
|
|
12542
|
+
const parsed = JSON.parse(import_node_fs21.default.readFileSync(pkg, "utf8"));
|
|
12419
12543
|
if (parsed.name === rnxPublicBrand.packageName) return cur;
|
|
12420
12544
|
}
|
|
12421
12545
|
} catch {
|
|
12422
12546
|
}
|
|
12423
|
-
const parent =
|
|
12547
|
+
const parent = import_node_path22.default.dirname(cur);
|
|
12424
12548
|
if (parent === cur) break;
|
|
12425
12549
|
cur = parent;
|
|
12426
12550
|
}
|
|
@@ -12436,28 +12560,28 @@ function fileFromImportMeta() {
|
|
|
12436
12560
|
}
|
|
12437
12561
|
}
|
|
12438
12562
|
async function withStartLock(projectId, provider, fn) {
|
|
12439
|
-
const lockDir =
|
|
12440
|
-
|
|
12563
|
+
const lockDir = import_node_path22.default.join(getUserDataDir(), "locks");
|
|
12564
|
+
import_node_fs21.default.mkdirSync(lockDir, { recursive: true });
|
|
12441
12565
|
try {
|
|
12442
|
-
|
|
12566
|
+
import_node_fs21.default.chmodSync(lockDir, 448);
|
|
12443
12567
|
} catch {
|
|
12444
12568
|
}
|
|
12445
|
-
const lockPath =
|
|
12569
|
+
const lockPath = import_node_path22.default.join(lockDir, `start-${projectId}-${provider}.lock`);
|
|
12446
12570
|
const deadline = Date.now() + 4e3;
|
|
12447
12571
|
let fd = null;
|
|
12448
12572
|
while (fd === null) {
|
|
12449
12573
|
try {
|
|
12450
|
-
fd =
|
|
12574
|
+
fd = import_node_fs21.default.openSync(
|
|
12451
12575
|
lockPath,
|
|
12452
|
-
|
|
12576
|
+
import_node_fs21.constants.O_WRONLY | import_node_fs21.constants.O_CREAT | import_node_fs21.constants.O_EXCL,
|
|
12453
12577
|
384
|
|
12454
12578
|
);
|
|
12455
12579
|
} catch (err) {
|
|
12456
12580
|
if (err.code !== "EEXIST") throw err;
|
|
12457
12581
|
try {
|
|
12458
|
-
const stale = Number(
|
|
12582
|
+
const stale = Number(import_node_fs21.default.readFileSync(lockPath, "utf8").trim());
|
|
12459
12583
|
if (stale && !isProcessAlive(stale)) {
|
|
12460
|
-
|
|
12584
|
+
import_node_fs21.default.unlinkSync(lockPath);
|
|
12461
12585
|
continue;
|
|
12462
12586
|
}
|
|
12463
12587
|
} catch {
|
|
@@ -12471,15 +12595,15 @@ async function withStartLock(projectId, provider, fn) {
|
|
|
12471
12595
|
}
|
|
12472
12596
|
}
|
|
12473
12597
|
try {
|
|
12474
|
-
|
|
12598
|
+
import_node_fs21.default.writeFileSync(fd, String(process.pid));
|
|
12475
12599
|
return await fn();
|
|
12476
12600
|
} finally {
|
|
12477
12601
|
try {
|
|
12478
|
-
|
|
12602
|
+
import_node_fs21.default.closeSync(fd);
|
|
12479
12603
|
} catch {
|
|
12480
12604
|
}
|
|
12481
12605
|
try {
|
|
12482
|
-
|
|
12606
|
+
import_node_fs21.default.unlinkSync(lockPath);
|
|
12483
12607
|
} catch {
|
|
12484
12608
|
}
|
|
12485
12609
|
}
|
|
@@ -12493,25 +12617,25 @@ function isProcessAlive(pid) {
|
|
|
12493
12617
|
}
|
|
12494
12618
|
}
|
|
12495
12619
|
function mkfifoSync(p) {
|
|
12496
|
-
const parent =
|
|
12497
|
-
|
|
12620
|
+
const parent = import_node_path22.default.dirname(p);
|
|
12621
|
+
import_node_fs21.default.mkdirSync(parent, { recursive: true });
|
|
12498
12622
|
try {
|
|
12499
|
-
|
|
12623
|
+
import_node_fs21.default.chmodSync(parent, 448);
|
|
12500
12624
|
} catch {
|
|
12501
12625
|
}
|
|
12502
|
-
if (
|
|
12626
|
+
if (import_node_fs21.default.existsSync(p)) {
|
|
12503
12627
|
try {
|
|
12504
|
-
const stat2 =
|
|
12628
|
+
const stat2 = import_node_fs21.default.statSync(p);
|
|
12505
12629
|
if (stat2.isFIFO()) {
|
|
12506
12630
|
try {
|
|
12507
|
-
|
|
12631
|
+
import_node_fs21.default.chmodSync(p, 384);
|
|
12508
12632
|
} catch {
|
|
12509
12633
|
}
|
|
12510
12634
|
return;
|
|
12511
12635
|
}
|
|
12512
|
-
|
|
12636
|
+
import_node_fs21.default.unlinkSync(p);
|
|
12513
12637
|
} catch {
|
|
12514
|
-
|
|
12638
|
+
import_node_fs21.default.unlinkSync(p);
|
|
12515
12639
|
}
|
|
12516
12640
|
}
|
|
12517
12641
|
const result = (0, import_node_child_process9.spawnSync)("mkfifo", ["-m", "600", p]);
|
|
@@ -12544,7 +12668,7 @@ async function startSession(opts) {
|
|
|
12544
12668
|
`session already running for project=${project.id} provider=${provider} (session ${existingLive.id}, pid ${existingLive.wrapperPid}). end it first with \`peach agent end <sessionId>\`.`
|
|
12545
12669
|
);
|
|
12546
12670
|
}
|
|
12547
|
-
const claudeSessionUuid = provider === "claude" ? (0,
|
|
12671
|
+
const claudeSessionUuid = provider === "claude" ? (0, import_node_crypto10.randomUUID)() : void 0;
|
|
12548
12672
|
const session = upsertSession({
|
|
12549
12673
|
projectId: project.id,
|
|
12550
12674
|
provider,
|
|
@@ -12558,10 +12682,10 @@ async function startSession(opts) {
|
|
|
12558
12682
|
const transcript = transcriptPath(session.id);
|
|
12559
12683
|
mkfifoSync(promptIn);
|
|
12560
12684
|
mkfifoSync(eventsOut);
|
|
12561
|
-
const transcriptDir =
|
|
12562
|
-
|
|
12685
|
+
const transcriptDir = import_node_path22.default.dirname(transcript);
|
|
12686
|
+
import_node_fs21.default.mkdirSync(transcriptDir, { recursive: true });
|
|
12563
12687
|
try {
|
|
12564
|
-
|
|
12688
|
+
import_node_fs21.default.chmodSync(transcriptDir, 448);
|
|
12565
12689
|
} catch {
|
|
12566
12690
|
}
|
|
12567
12691
|
const { executable, prefixArgs } = resolveSootsimInvocation();
|
|
@@ -12612,7 +12736,7 @@ async function startSession(opts) {
|
|
|
12612
12736
|
}
|
|
12613
12737
|
}
|
|
12614
12738
|
try {
|
|
12615
|
-
|
|
12739
|
+
import_node_fs21.default.rmSync(sessionDir(session.id), { recursive: true, force: true });
|
|
12616
12740
|
} catch {
|
|
12617
12741
|
}
|
|
12618
12742
|
updateSessionStatus(session.id, { status: "ended" });
|
|
@@ -12640,18 +12764,18 @@ async function sendPrompt(sessionId, prompt) {
|
|
|
12640
12764
|
);
|
|
12641
12765
|
}
|
|
12642
12766
|
const fifo = promptFifoPath(sessionId);
|
|
12643
|
-
if (!
|
|
12767
|
+
if (!import_node_fs21.default.existsSync(fifo)) {
|
|
12644
12768
|
throw new AgentSessionError("NO_FIFO", `prompt FIFO missing: ${fifo}`);
|
|
12645
12769
|
}
|
|
12646
|
-
const fd =
|
|
12770
|
+
const fd = import_node_fs21.default.openSync(fifo, import_node_fs21.constants.O_WRONLY);
|
|
12647
12771
|
try {
|
|
12648
12772
|
const wireText = encodeAgentPromptEnvelope(prompt);
|
|
12649
12773
|
if (!wireText) {
|
|
12650
12774
|
throw new AgentSessionError("EMPTY_PROMPT", "prompt text is empty");
|
|
12651
12775
|
}
|
|
12652
|
-
|
|
12776
|
+
import_node_fs21.default.writeSync(fd, wireText + "\n");
|
|
12653
12777
|
} finally {
|
|
12654
|
-
|
|
12778
|
+
import_node_fs21.default.closeSync(fd);
|
|
12655
12779
|
}
|
|
12656
12780
|
updateSessionStatus(sessionId, {
|
|
12657
12781
|
lastPrompt: prompt.displayText ?? prompt.text,
|
|
@@ -12673,7 +12797,7 @@ async function endSession(sessionId) {
|
|
|
12673
12797
|
const base = getUserDataDir();
|
|
12674
12798
|
if (dir.startsWith(base)) {
|
|
12675
12799
|
try {
|
|
12676
|
-
|
|
12800
|
+
import_node_fs21.default.rmSync(dir, { recursive: true, force: true });
|
|
12677
12801
|
} catch {
|
|
12678
12802
|
}
|
|
12679
12803
|
}
|
|
@@ -12681,11 +12805,11 @@ async function endSession(sessionId) {
|
|
|
12681
12805
|
}
|
|
12682
12806
|
function subscribeEvents(sessionId, onEvent) {
|
|
12683
12807
|
const fifo = eventsFifoPath(sessionId);
|
|
12684
|
-
if (!
|
|
12808
|
+
if (!import_node_fs21.default.existsSync(fifo)) {
|
|
12685
12809
|
throw new AgentSessionError("NO_FIFO", `events FIFO missing: ${fifo}`);
|
|
12686
12810
|
}
|
|
12687
|
-
const fd =
|
|
12688
|
-
const stream =
|
|
12811
|
+
const fd = import_node_fs21.default.openSync(fifo, import_node_fs21.constants.O_RDWR);
|
|
12812
|
+
const stream = import_node_fs21.default.createReadStream("", { fd, autoClose: true });
|
|
12689
12813
|
const rl = import_node_readline.default.createInterface({ input: stream, crlfDelay: Infinity });
|
|
12690
12814
|
rl.on("line", (line) => {
|
|
12691
12815
|
const event = parseAgentEventLine(line);
|
|
@@ -12696,7 +12820,7 @@ function subscribeEvents(sessionId, onEvent) {
|
|
|
12696
12820
|
if (closed) return;
|
|
12697
12821
|
closed = true;
|
|
12698
12822
|
try {
|
|
12699
|
-
|
|
12823
|
+
import_node_fs21.default.writeSync(fd, "\n");
|
|
12700
12824
|
} catch {
|
|
12701
12825
|
}
|
|
12702
12826
|
try {
|
|
@@ -12710,7 +12834,7 @@ function subscribeEvents(sessionId, onEvent) {
|
|
|
12710
12834
|
};
|
|
12711
12835
|
}
|
|
12712
12836
|
async function waitForFirstEvent(fifo, predicate, timeoutMs) {
|
|
12713
|
-
const fd =
|
|
12837
|
+
const fd = import_node_fs21.default.openSync(fifo, import_node_fs21.constants.O_RDWR | import_node_fs21.constants.O_NONBLOCK);
|
|
12714
12838
|
const buf = Buffer.alloc(8192);
|
|
12715
12839
|
let leftover = "";
|
|
12716
12840
|
const deadline = Date.now() + timeoutMs;
|
|
@@ -12718,7 +12842,7 @@ async function waitForFirstEvent(fifo, predicate, timeoutMs) {
|
|
|
12718
12842
|
while (Date.now() < deadline) {
|
|
12719
12843
|
let n = 0;
|
|
12720
12844
|
try {
|
|
12721
|
-
n =
|
|
12845
|
+
n = import_node_fs21.default.readSync(fd, buf, 0, buf.length, null);
|
|
12722
12846
|
} catch (err) {
|
|
12723
12847
|
if (err.code !== "EAGAIN") throw err;
|
|
12724
12848
|
n = 0;
|
|
@@ -12738,7 +12862,7 @@ async function waitForFirstEvent(fifo, predicate, timeoutMs) {
|
|
|
12738
12862
|
}
|
|
12739
12863
|
return null;
|
|
12740
12864
|
} finally {
|
|
12741
|
-
|
|
12865
|
+
import_node_fs21.default.closeSync(fd);
|
|
12742
12866
|
}
|
|
12743
12867
|
}
|
|
12744
12868
|
|
|
@@ -12946,7 +13070,7 @@ var AgentHost = class {
|
|
|
12946
13070
|
throw new AgentSessionError("EMPTY_PROMPT", "inspect message cannot be empty");
|
|
12947
13071
|
}
|
|
12948
13072
|
const message = {
|
|
12949
|
-
id: `inspect-${(0,
|
|
13073
|
+
id: `inspect-${(0, import_node_crypto11.randomUUID)()}`,
|
|
12950
13074
|
simId,
|
|
12951
13075
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
12952
13076
|
prompt
|
|
@@ -12992,7 +13116,7 @@ var AgentHost = class {
|
|
|
12992
13116
|
);
|
|
12993
13117
|
const project = upsertProject({
|
|
12994
13118
|
cwd: match.cwd,
|
|
12995
|
-
name: match.projectName ??
|
|
13119
|
+
name: match.projectName ?? import_node_path23.default.basename(match.cwd),
|
|
12996
13120
|
preferredProvider: input.provider ?? existing?.preferredProvider,
|
|
12997
13121
|
sourceRoots: existing?.sourceRoots ?? [match.cwd],
|
|
12998
13122
|
knownBundleUrls,
|
|
@@ -13003,18 +13127,18 @@ var AgentHost = class {
|
|
|
13003
13127
|
}
|
|
13004
13128
|
getTranscript(sessionId) {
|
|
13005
13129
|
const p = transcriptPath(sessionId);
|
|
13006
|
-
if (!
|
|
13130
|
+
if (!import_node_fs22.default.existsSync(p)) {
|
|
13007
13131
|
return { error: "transcript not found", code: "NO_TRANSCRIPT" };
|
|
13008
13132
|
}
|
|
13009
|
-
return
|
|
13133
|
+
return import_node_fs22.default.readFileSync(p, "utf8");
|
|
13010
13134
|
}
|
|
13011
13135
|
getPaths() {
|
|
13012
13136
|
const dir = getUserDataDir();
|
|
13013
13137
|
return {
|
|
13014
13138
|
userDataDir: dir,
|
|
13015
|
-
storeFile:
|
|
13016
|
-
sessionsDir:
|
|
13017
|
-
transcriptsDir:
|
|
13139
|
+
storeFile: import_node_path23.default.join(dir, "attached-projects.json"),
|
|
13140
|
+
sessionsDir: import_node_path23.default.join(dir, "sessions"),
|
|
13141
|
+
transcriptsDir: import_node_path23.default.join(dir, "transcripts")
|
|
13018
13142
|
};
|
|
13019
13143
|
}
|
|
13020
13144
|
// --- subscription management ---
|
|
@@ -13715,7 +13839,7 @@ function handleAppApiRequest(req, res) {
|
|
|
13715
13839
|
}
|
|
13716
13840
|
|
|
13717
13841
|
// src/host/fetch-proxy-transport.ts
|
|
13718
|
-
var
|
|
13842
|
+
var import_node_crypto12 = require("node:crypto");
|
|
13719
13843
|
var import_node_http22 = require("node:http2");
|
|
13720
13844
|
var import_x509 = require("@peculiar/x509");
|
|
13721
13845
|
async function startFetchProxyTransport() {
|
|
@@ -13723,7 +13847,7 @@ async function startFetchProxyTransport() {
|
|
|
13723
13847
|
const keys = await crypto.subtle.generateKey(algorithm, true, ["sign", "verify"]);
|
|
13724
13848
|
const certificate = await import_x509.X509CertificateGenerator.createSelfSigned(
|
|
13725
13849
|
{
|
|
13726
|
-
serialNumber: (0,
|
|
13850
|
+
serialNumber: (0, import_node_crypto12.randomBytes)(16).toString("hex"),
|
|
13727
13851
|
name: "CN=localhost",
|
|
13728
13852
|
notBefore: new Date(Date.now() - 6e4),
|
|
13729
13853
|
notAfter: new Date(Date.now() + 365 * 24 * 60 * 6e4),
|
|
@@ -13736,7 +13860,7 @@ async function startFetchProxyTransport() {
|
|
|
13736
13860
|
crypto
|
|
13737
13861
|
);
|
|
13738
13862
|
const privateKey = Buffer.from(await crypto.subtle.exportKey("pkcs8", keys.privateKey));
|
|
13739
|
-
const spki = (0,
|
|
13863
|
+
const spki = (0, import_node_crypto12.createHash)("sha256").update(Buffer.from(await crypto.subtle.exportKey("spki", keys.publicKey))).digest("base64");
|
|
13740
13864
|
const sessions = /* @__PURE__ */ new Set();
|
|
13741
13865
|
const server = (0, import_node_http22.createSecureServer)(
|
|
13742
13866
|
{
|
|
@@ -13858,8 +13982,8 @@ async function openUrl(url, options = {}) {
|
|
|
13858
13982
|
}
|
|
13859
13983
|
|
|
13860
13984
|
// src/host/plane-host.ts
|
|
13861
|
-
var
|
|
13862
|
-
var
|
|
13985
|
+
var import_node_fs24 = __toESM(require("node:fs"), 1);
|
|
13986
|
+
var import_node_path25 = __toESM(require("node:path"), 1);
|
|
13863
13987
|
|
|
13864
13988
|
// ../peach-box/src/planeProtocol.ts
|
|
13865
13989
|
var PLANE_FLAG_READ_ONLY = 1;
|
|
@@ -13939,8 +14063,8 @@ async function dispatchPlaneCommand(plane, type, msg, mutationOptions) {
|
|
|
13939
14063
|
|
|
13940
14064
|
// cli/commands/box/checkout-plane.ts
|
|
13941
14065
|
var import_node_child_process10 = require("node:child_process");
|
|
13942
|
-
var
|
|
13943
|
-
var
|
|
14066
|
+
var import_node_fs23 = __toESM(require("node:fs"), 1);
|
|
14067
|
+
var import_node_path24 = __toESM(require("node:path"), 1);
|
|
13944
14068
|
var CheckoutRequiresGitError = class extends Error {
|
|
13945
14069
|
};
|
|
13946
14070
|
var BINARY_SNIFF_BYTES = 8192;
|
|
@@ -13951,14 +14075,14 @@ function looksBinary(filePath, size) {
|
|
|
13951
14075
|
if (size === 0) return false;
|
|
13952
14076
|
let fd;
|
|
13953
14077
|
try {
|
|
13954
|
-
fd =
|
|
14078
|
+
fd = import_node_fs23.default.openSync(filePath, "r");
|
|
13955
14079
|
const buffer = Buffer.alloc(Math.min(BINARY_SNIFF_BYTES, size));
|
|
13956
|
-
const read =
|
|
14080
|
+
const read = import_node_fs23.default.readSync(fd, buffer, 0, buffer.length, 0);
|
|
13957
14081
|
return buffer.subarray(0, read).includes(0);
|
|
13958
14082
|
} catch {
|
|
13959
14083
|
return false;
|
|
13960
14084
|
} finally {
|
|
13961
|
-
if (fd !== void 0)
|
|
14085
|
+
if (fd !== void 0) import_node_fs23.default.closeSync(fd);
|
|
13962
14086
|
}
|
|
13963
14087
|
}
|
|
13964
14088
|
var CheckoutFilePlane = class {
|
|
@@ -13971,7 +14095,7 @@ var CheckoutFilePlane = class {
|
|
|
13971
14095
|
listTimeoutMs;
|
|
13972
14096
|
trackedOnly;
|
|
13973
14097
|
constructor(root, options = {}) {
|
|
13974
|
-
this.root =
|
|
14098
|
+
this.root = import_node_path24.default.resolve(root);
|
|
13975
14099
|
this.listTimeoutMs = options.listTimeoutMs ?? LIST_FILES_TIMEOUT_MS;
|
|
13976
14100
|
this.trackedOnly = options.trackedOnly ?? false;
|
|
13977
14101
|
}
|
|
@@ -14033,13 +14157,13 @@ var CheckoutFilePlane = class {
|
|
|
14033
14157
|
if (!relative2) continue;
|
|
14034
14158
|
let stat2;
|
|
14035
14159
|
try {
|
|
14036
|
-
stat2 =
|
|
14160
|
+
stat2 = import_node_fs23.default.statSync(import_node_path24.default.join(this.root, relative2));
|
|
14037
14161
|
} catch {
|
|
14038
14162
|
continue;
|
|
14039
14163
|
}
|
|
14040
14164
|
if (!stat2.isFile()) continue;
|
|
14041
14165
|
const seen = this.sniffed.get(relative2);
|
|
14042
|
-
const binary = seen && seen.size === stat2.size && seen.mtimeMs === stat2.mtimeMs ? seen.binary : looksBinary(
|
|
14166
|
+
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
14167
|
nextSniffed.set(relative2, { size: stat2.size, mtimeMs: stat2.mtimeMs, binary });
|
|
14044
14168
|
next.set(relative2, {
|
|
14045
14169
|
size: stat2.size,
|
|
@@ -14053,22 +14177,22 @@ var CheckoutFilePlane = class {
|
|
|
14053
14177
|
this.sniffed = nextSniffed;
|
|
14054
14178
|
}
|
|
14055
14179
|
absolute(planePath) {
|
|
14056
|
-
const resolved =
|
|
14057
|
-
if (resolved !== this.root && !resolved.startsWith(`${this.root}${
|
|
14180
|
+
const resolved = import_node_path24.default.resolve(this.root, planePath);
|
|
14181
|
+
if (resolved !== this.root && !resolved.startsWith(`${this.root}${import_node_path24.default.sep}`)) {
|
|
14058
14182
|
throw new Error(`path escapes the project: ${planePath}`);
|
|
14059
14183
|
}
|
|
14060
14184
|
return resolved;
|
|
14061
14185
|
}
|
|
14062
14186
|
async read(planePath) {
|
|
14063
|
-
return
|
|
14187
|
+
return import_node_fs23.default.promises.readFile(this.absolute(planePath), "utf8");
|
|
14064
14188
|
}
|
|
14065
14189
|
async readBytes(planePath) {
|
|
14066
|
-
return
|
|
14190
|
+
return import_node_fs23.default.promises.readFile(this.absolute(planePath));
|
|
14067
14191
|
}
|
|
14068
14192
|
async write(planePath, content) {
|
|
14069
14193
|
const absolute = this.absolute(planePath);
|
|
14070
|
-
await
|
|
14071
|
-
await
|
|
14194
|
+
await import_node_fs23.default.promises.mkdir(import_node_path24.default.dirname(absolute), { recursive: true });
|
|
14195
|
+
await import_node_fs23.default.promises.writeFile(absolute, content);
|
|
14072
14196
|
this.entries.set(planePath, {
|
|
14073
14197
|
size: content.byteLength,
|
|
14074
14198
|
readOnly: false,
|
|
@@ -14077,7 +14201,7 @@ var CheckoutFilePlane = class {
|
|
|
14077
14201
|
});
|
|
14078
14202
|
}
|
|
14079
14203
|
async delete(planePath) {
|
|
14080
|
-
await
|
|
14204
|
+
await import_node_fs23.default.promises.rm(this.absolute(planePath), { force: true });
|
|
14081
14205
|
this.entries.delete(planePath);
|
|
14082
14206
|
}
|
|
14083
14207
|
};
|
|
@@ -14203,14 +14327,14 @@ var PlaneHost = class {
|
|
|
14203
14327
|
// root and an opened one cannot disagree about the same directory.
|
|
14204
14328
|
realRoot(root) {
|
|
14205
14329
|
if (!root) throw new Error("root is required");
|
|
14206
|
-
const resolved =
|
|
14330
|
+
const resolved = import_node_path25.default.resolve(root);
|
|
14207
14331
|
let real;
|
|
14208
14332
|
try {
|
|
14209
|
-
real =
|
|
14333
|
+
real = import_node_fs24.default.realpathSync(resolved);
|
|
14210
14334
|
} catch {
|
|
14211
14335
|
throw new Error(`no such directory: ${resolved}`);
|
|
14212
14336
|
}
|
|
14213
|
-
if (!
|
|
14337
|
+
if (!import_node_fs24.default.statSync(real).isDirectory()) throw new Error(`not a directory: ${real}`);
|
|
14214
14338
|
return real;
|
|
14215
14339
|
}
|
|
14216
14340
|
respond(ws, id, result) {
|
|
@@ -14230,9 +14354,9 @@ var PlaneHost = class {
|
|
|
14230
14354
|
};
|
|
14231
14355
|
|
|
14232
14356
|
// src/host/replacement-module-handler.ts
|
|
14233
|
-
var
|
|
14357
|
+
var import_node_fs25 = require("node:fs");
|
|
14234
14358
|
var import_promises5 = __toESM(require("node:fs/promises"), 1);
|
|
14235
|
-
var
|
|
14359
|
+
var import_node_path26 = __toESM(require("node:path"), 1);
|
|
14236
14360
|
|
|
14237
14361
|
// ../contrast-bundler/src/replacementModule.ts
|
|
14238
14362
|
var import_dist = require("sucrase/dist/index.js");
|
|
@@ -14560,16 +14684,16 @@ function sendJavaScript(req, res, source) {
|
|
|
14560
14684
|
res.end(req.method === "HEAD" ? void 0 : source);
|
|
14561
14685
|
}
|
|
14562
14686
|
function resolveReplacementModuleFile(fromFile, specifier) {
|
|
14563
|
-
const base =
|
|
14687
|
+
const base = import_node_path26.default.resolve(import_node_path26.default.dirname(fromFile), specifier);
|
|
14564
14688
|
const candidates = [
|
|
14565
14689
|
...REPLACEMENT_MODULE_EXTENSIONS.some(
|
|
14566
|
-
(ext) => ext ===
|
|
14690
|
+
(ext) => ext === import_node_path26.default.extname(base).toLowerCase()
|
|
14567
14691
|
) ? [base] : [],
|
|
14568
14692
|
...REPLACEMENT_MODULE_EXTENSIONS.map((ext) => base + ext),
|
|
14569
|
-
...REPLACEMENT_MODULE_EXTENSIONS.map((ext) =>
|
|
14693
|
+
...REPLACEMENT_MODULE_EXTENSIONS.map((ext) => import_node_path26.default.join(base, `index${ext}`))
|
|
14570
14694
|
];
|
|
14571
14695
|
const found = candidates.find(
|
|
14572
|
-
(candidate) => (0,
|
|
14696
|
+
(candidate) => (0, import_node_fs25.statSync)(candidate, { throwIfNoEntry: false })?.isFile()
|
|
14573
14697
|
);
|
|
14574
14698
|
if (!found) {
|
|
14575
14699
|
throw new Error(
|
|
@@ -14624,13 +14748,13 @@ async function handleReplacementModuleRequest(req, res, options = {}) {
|
|
|
14624
14748
|
res.end("missing path param");
|
|
14625
14749
|
return true;
|
|
14626
14750
|
}
|
|
14627
|
-
const extension =
|
|
14751
|
+
const extension = import_node_path26.default.extname(targetPath).toLowerCase();
|
|
14628
14752
|
if (!REPLACEMENT_MODULE_EXTENSIONS.some((allowed) => allowed === extension)) {
|
|
14629
14753
|
res.writeHead(400, { "Content-Type": "text/plain; charset=utf-8" });
|
|
14630
14754
|
res.end(`replacement files must be ${REPLACEMENT_MODULE_EXTENSIONS.join(", ")}`);
|
|
14631
14755
|
return true;
|
|
14632
14756
|
}
|
|
14633
|
-
if (!
|
|
14757
|
+
if (!import_node_path26.default.isAbsolute(targetPath)) {
|
|
14634
14758
|
res.writeHead(400, { "Content-Type": "text/plain; charset=utf-8" });
|
|
14635
14759
|
res.end("replacement file path must be absolute");
|
|
14636
14760
|
return true;
|
|
@@ -14638,10 +14762,10 @@ async function handleReplacementModuleRequest(req, res, options = {}) {
|
|
|
14638
14762
|
const runtimePackages = new Set(url.searchParams.getAll("runtimePackage"));
|
|
14639
14763
|
let resolvedProjectRoot;
|
|
14640
14764
|
if (options.projectRoot) {
|
|
14641
|
-
const lexicalProjectRoot =
|
|
14765
|
+
const lexicalProjectRoot = import_node_path26.default.resolve(options.projectRoot);
|
|
14642
14766
|
resolvedProjectRoot = await import_promises5.default.realpath(options.projectRoot);
|
|
14643
|
-
const lexicalTarget =
|
|
14644
|
-
if (lexicalTarget.startsWith("..") ||
|
|
14767
|
+
const lexicalTarget = import_node_path26.default.relative(lexicalProjectRoot, targetPath);
|
|
14768
|
+
if (lexicalTarget.startsWith("..") || import_node_path26.default.isAbsolute(lexicalTarget)) {
|
|
14645
14769
|
res.writeHead(403, { "Content-Type": "text/plain; charset=utf-8" });
|
|
14646
14770
|
res.end("replacement file must be inside the project root");
|
|
14647
14771
|
return true;
|
|
@@ -14657,8 +14781,8 @@ async function handleReplacementModuleRequest(req, res, options = {}) {
|
|
|
14657
14781
|
return true;
|
|
14658
14782
|
}
|
|
14659
14783
|
if (resolvedProjectRoot) {
|
|
14660
|
-
const relativeTarget =
|
|
14661
|
-
if (relativeTarget.startsWith("..") ||
|
|
14784
|
+
const relativeTarget = import_node_path26.default.relative(resolvedProjectRoot, resolvedTargetPath);
|
|
14785
|
+
if (relativeTarget.startsWith("..") || import_node_path26.default.isAbsolute(relativeTarget)) {
|
|
14662
14786
|
res.writeHead(403, { "Content-Type": "text/plain; charset=utf-8" });
|
|
14663
14787
|
res.end("replacement file must be inside the project root");
|
|
14664
14788
|
return true;
|