peachsim 0.1.730 → 0.1.745
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/bridge-flow-runner.ts +15 -2
- package/cli/commands/control.ts +13 -3
- package/cli/commands/desktop.ts +1 -0
- package/cli/commands/electron.ts +12 -8
- package/cli/commands/flow.ts +1 -3
- package/cli/commands/install-desktop.ts +105 -66
- package/cli/commands/logout.ts +5 -1
- package/cli/commands/no-bridge-hint.ts +2 -2
- package/cli/commands/swift.ts +26 -9
- package/cli/desktop-companion.ts +36 -9
- package/cli/drivers/desktop.ts +65 -0
- package/cli/drivers/electron.ts +4 -66
- package/cli/drivers/index.ts +1 -0
- package/cli/drivers/playwright.ts +3 -3
- package/cli/drivers/registry.ts +7 -2
- package/cli/drivers/types.ts +4 -3
- package/cli/maestro-js.ts +10 -0
- package/cli/outbound-endpoints.ts +2 -2
- 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 +39 -9
- 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 +13 -19
- package/dist-lib/capture-contract.mjs +13 -19
- 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 +20 -2
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/home-paths.cjs +32 -1
- package/dist-lib/host/bridge-host.cjs +1616 -532
- 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 +14 -19
- 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 +2 -1
- package/dist-lib/sdk.mjs +2 -1
- package/dist-lib/skills.cjs +2306 -1067
- package/dist-lib/swift-compile.cjs +317 -60
- package/dist-lib/swift-compile.mjs +313 -61
- package/dist-lib/swift-package.cjs +146 -9
- package/dist-lib/swift-package.mjs +144 -9
- package/dist-lib/swift-submit.cjs +2 -2
- package/dist-lib/swift-submit.mjs +2 -2
- package/dist-lib/swift-toolchain.cjs +1 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +1310 -226
- package/dist-lib/vite.cjs +1 -1
- package/package.json +1 -1
- package/skills/contrast/SKILL.md +1 -1
- package/src/auth/shared-session.ts +45 -9
- package/src/bridge-constants.ts +7 -7
- package/src/capture-contract.ts +18 -33
- package/src/desktop-host-delivery.ts +81 -0
- package/src/home-paths.ts +30 -0
- package/src/host/bridge-host.ts +11 -6
- package/src/native-seam-manifest.ts +0 -11
- package/src/sim-client.ts +1 -0
- package/src/swift-compile.ts +403 -68
- package/src/swift-distribution.lock.json +11 -11
- package/src/swift-host.ts +316 -43
- package/src/swift-package.ts +204 -19
- package/src/swift-remote-packages.ts +255 -0
- package/src/swift-submit.ts +4 -1
- package/src/vite-plugin.ts +19 -8
- package/src/xcode-project.ts +527 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.745 | (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;
|
|
@@ -60,9 +60,9 @@ function resolveContrastBackendOrigin(currentOrigin) {
|
|
|
60
60
|
const origin = currentOrigin?.trim();
|
|
61
61
|
if (!origin) return DEFAULT_CONTRAST_BACKEND_ORIGIN;
|
|
62
62
|
try {
|
|
63
|
-
const
|
|
64
|
-
if (isLoopbackHost(
|
|
65
|
-
return
|
|
63
|
+
const parsed2 = new URL(origin);
|
|
64
|
+
if (isLoopbackHost(parsed2.hostname) || isContrastBackendHost(parsed2.hostname)) {
|
|
65
|
+
return parsed2.origin;
|
|
66
66
|
}
|
|
67
67
|
} catch {
|
|
68
68
|
}
|
|
@@ -431,8 +431,8 @@ function configFilePath() {
|
|
|
431
431
|
function readSharedConfig() {
|
|
432
432
|
try {
|
|
433
433
|
const raw2 = import_node_fs3.default.readFileSync(configFilePath(), "utf8");
|
|
434
|
-
const
|
|
435
|
-
return
|
|
434
|
+
const parsed2 = JSON.parse(raw2);
|
|
435
|
+
return parsed2 && typeof parsed2 === "object" ? parsed2 : {};
|
|
436
436
|
} catch {
|
|
437
437
|
return {};
|
|
438
438
|
}
|
|
@@ -500,9 +500,9 @@ function readDaemonLockfile() {
|
|
|
500
500
|
const buf = Buffer.alloc(DAEMON_LOCKFILE_MAX_BYTES);
|
|
501
501
|
const bytesRead = import_node_fs3.default.readSync(fd, buf, 0, DAEMON_LOCKFILE_MAX_BYTES, 0);
|
|
502
502
|
const raw2 = buf.subarray(0, bytesRead).toString("utf8");
|
|
503
|
-
const
|
|
504
|
-
if (
|
|
505
|
-
return
|
|
503
|
+
const parsed2 = JSON.parse(raw2);
|
|
504
|
+
if (parsed2 && parsed2.schema === 1 && typeof parsed2.pid === "number" && typeof parsed2.bridgePort === "number" && typeof parsed2.runtimePort === "number" && typeof parsed2.startedAt === "number" && typeof parsed2.heartbeatAt === "number" && (parsed2.servedRuntimes === void 0 || Array.isArray(parsed2.servedRuntimes) && parsed2.servedRuntimes.every((version) => typeof version === "string"))) {
|
|
505
|
+
return parsed2;
|
|
506
506
|
}
|
|
507
507
|
return null;
|
|
508
508
|
} finally {
|
|
@@ -514,9 +514,9 @@ function readDaemonLockfile() {
|
|
|
514
514
|
}
|
|
515
515
|
function parseDevBridgeLockfile(raw2) {
|
|
516
516
|
try {
|
|
517
|
-
const
|
|
518
|
-
if (
|
|
519
|
-
return
|
|
517
|
+
const parsed2 = JSON.parse(raw2);
|
|
518
|
+
if (parsed2 && parsed2.schema === 1 && parsed2.source === "vite-dev" && typeof parsed2.pid === "number" && typeof parsed2.bridgePort === "number" && typeof parsed2.runtimePort === "number" && typeof parsed2.cwd === "string" && typeof parsed2.startedAt === "number" && typeof parsed2.heartbeatAt === "number" && (parsed2.shellPort === void 0 || typeof parsed2.shellPort === "number") && (parsed2.servedRuntimes === void 0 || Array.isArray(parsed2.servedRuntimes) && parsed2.servedRuntimes.every((version) => typeof version === "string"))) {
|
|
519
|
+
return parsed2;
|
|
520
520
|
}
|
|
521
521
|
return null;
|
|
522
522
|
} catch {
|
|
@@ -832,8 +832,8 @@ function readSharedDesktopAuthSession() {
|
|
|
832
832
|
const filepath = getSharedDesktopAuthFilePath();
|
|
833
833
|
if (!(0, import_node_fs12.existsSync)(filepath)) return null;
|
|
834
834
|
try {
|
|
835
|
-
const
|
|
836
|
-
const normalized = normalizeSession(
|
|
835
|
+
const parsed2 = JSON.parse((0, import_node_fs12.readFileSync)(filepath, "utf8"));
|
|
836
|
+
const normalized = normalizeSession(parsed2);
|
|
837
837
|
if (!normalized) {
|
|
838
838
|
(0, import_node_fs12.rmSync)(filepath, { force: true });
|
|
839
839
|
return null;
|
|
@@ -2299,10 +2299,10 @@ function readStringArray(text, start, end) {
|
|
|
2299
2299
|
for (; ; ) {
|
|
2300
2300
|
cursor = skipTrivia(text, cursor, end);
|
|
2301
2301
|
if (text[cursor] === "]") return { values, end: cursor + 1 };
|
|
2302
|
-
const
|
|
2303
|
-
if (!
|
|
2304
|
-
values.push(
|
|
2305
|
-
cursor = skipTrivia(text,
|
|
2302
|
+
const parsed2 = readQuoted(text, cursor, end);
|
|
2303
|
+
if (!parsed2) return null;
|
|
2304
|
+
values.push(parsed2.value);
|
|
2305
|
+
cursor = skipTrivia(text, parsed2.end, end);
|
|
2306
2306
|
if (text[cursor] === "]") return { values, end: cursor + 1 };
|
|
2307
2307
|
if (text[cursor] !== ",") return null;
|
|
2308
2308
|
cursor++;
|
|
@@ -2455,10 +2455,10 @@ function scanAssetDescriptorSites(bundle) {
|
|
|
2455
2455
|
continue;
|
|
2456
2456
|
}
|
|
2457
2457
|
if (character === '"' || character === "'") {
|
|
2458
|
-
const
|
|
2459
|
-
const after =
|
|
2458
|
+
const parsed2 = readQuoted(bundle, cursor, bundle.length);
|
|
2459
|
+
const after = parsed2?.end ?? quotedEnd(bundle, cursor, bundle.length);
|
|
2460
2460
|
const colon = skipTrivia(bundle, after, bundle.length);
|
|
2461
|
-
if (
|
|
2461
|
+
if (parsed2?.value === "__packager_asset" && bundle[colon] === ":" && objects.length > 0) {
|
|
2462
2462
|
objects[objects.length - 1].hasAssetKey = true;
|
|
2463
2463
|
}
|
|
2464
2464
|
cursor = after;
|
|
@@ -2689,8 +2689,8 @@ function metroIosAssetDestRelatives(httpServerLocation, filename) {
|
|
|
2689
2689
|
}
|
|
2690
2690
|
const out = [];
|
|
2691
2691
|
for (const dir of dirs) {
|
|
2692
|
-
const
|
|
2693
|
-
if (!out.includes(
|
|
2692
|
+
const path20 = `${dir}/${filename}`;
|
|
2693
|
+
if (!out.includes(path20)) out.push(path20);
|
|
2694
2694
|
}
|
|
2695
2695
|
if (!out.includes(filename)) out.push(filename);
|
|
2696
2696
|
return out;
|
|
@@ -3180,13 +3180,13 @@ async function parseRegistryBytes(args) {
|
|
|
3180
3180
|
if (integrity !== args.expectedIntegrity) {
|
|
3181
3181
|
throw new Error("RNX Metro fingerprint registry integrity mismatch");
|
|
3182
3182
|
}
|
|
3183
|
-
let
|
|
3183
|
+
let parsed2;
|
|
3184
3184
|
try {
|
|
3185
|
-
|
|
3185
|
+
parsed2 = JSON.parse(new TextDecoder().decode(args.bytes));
|
|
3186
3186
|
} catch {
|
|
3187
3187
|
throw new Error("RNX Metro fingerprint registry is not valid JSON");
|
|
3188
3188
|
}
|
|
3189
|
-
const registry = (0, import_metro_fingerprint_registry.parseRNXMetroFingerprintRegistry)(
|
|
3189
|
+
const registry = (0, import_metro_fingerprint_registry.parseRNXMetroFingerprintRegistry)(parsed2);
|
|
3190
3190
|
if (!registry) throw new Error("RNX Metro fingerprint registry is malformed");
|
|
3191
3191
|
if (args.expectedRevision && registry.revision !== args.expectedRevision) {
|
|
3192
3192
|
throw new Error("RNX Metro fingerprint registry revision does not match its pointer");
|
|
@@ -3241,13 +3241,13 @@ async function readPointer(response) {
|
|
|
3241
3241
|
`RNX Metro fingerprint pointer exceeds ${import_metro_fingerprint_registry.RNX_METRO_FINGERPRINT_MAX_POINTER_BYTES} bytes`
|
|
3242
3242
|
);
|
|
3243
3243
|
}
|
|
3244
|
-
let
|
|
3244
|
+
let parsed2;
|
|
3245
3245
|
try {
|
|
3246
|
-
|
|
3246
|
+
parsed2 = JSON.parse(new TextDecoder().decode(bytes));
|
|
3247
3247
|
} catch {
|
|
3248
3248
|
throw new Error("RNX Metro fingerprint pointer is not valid JSON");
|
|
3249
3249
|
}
|
|
3250
|
-
const pointer = (0, import_metro_fingerprint_registry.parseRNXMetroFingerprintPointer)(
|
|
3250
|
+
const pointer = (0, import_metro_fingerprint_registry.parseRNXMetroFingerprintPointer)(parsed2);
|
|
3251
3251
|
if (!pointer) throw new Error("RNX Metro fingerprint pointer is malformed");
|
|
3252
3252
|
return pointer;
|
|
3253
3253
|
}
|
|
@@ -3642,13 +3642,13 @@ function readFactoryStringLiterals(factory) {
|
|
|
3642
3642
|
return literals;
|
|
3643
3643
|
}
|
|
3644
3644
|
function normalizeFingerprintLiteral(literal) {
|
|
3645
|
-
const
|
|
3645
|
+
const path20 = literal.replaceAll("\\\\", "/").replaceAll("\\/", "/");
|
|
3646
3646
|
const nodeModulesMarker = "/node_modules/";
|
|
3647
|
-
const nodeModulesIndex =
|
|
3647
|
+
const nodeModulesIndex = path20.lastIndexOf(nodeModulesMarker);
|
|
3648
3648
|
if (nodeModulesIndex >= 0) {
|
|
3649
|
-
return `node_modules/${
|
|
3649
|
+
return `node_modules/${path20.slice(nodeModulesIndex + nodeModulesMarker.length)}`;
|
|
3650
3650
|
}
|
|
3651
|
-
if ((
|
|
3651
|
+
if ((path20.startsWith("/") || /^[A-Za-z]:\//.test(path20) || path20.startsWith("file:/")) && /\.[cm]?[jt]sx?(?::\d+(?::\d+)?)?$/.test(path20)) {
|
|
3652
3652
|
return null;
|
|
3653
3653
|
}
|
|
3654
3654
|
return literal;
|
|
@@ -3676,16 +3676,16 @@ function canonicalFactoryForDigest(factory, tokens) {
|
|
|
3676
3676
|
return cursor === 0 ? factory : canonical + factory.slice(cursor);
|
|
3677
3677
|
}
|
|
3678
3678
|
function readDependencyIds(source) {
|
|
3679
|
-
let
|
|
3679
|
+
let parsed2;
|
|
3680
3680
|
try {
|
|
3681
|
-
|
|
3681
|
+
parsed2 = JSON.parse(source);
|
|
3682
3682
|
} catch {
|
|
3683
3683
|
throw new Error("Metro fingerprint analysis found a noncanonical dependency array");
|
|
3684
3684
|
}
|
|
3685
|
-
if (!Array.isArray(
|
|
3685
|
+
if (!Array.isArray(parsed2) || !parsed2.every((dependency) => dependency === null || Number.isSafeInteger(dependency))) {
|
|
3686
3686
|
throw new Error("Metro fingerprint analysis found a noncanonical dependency array");
|
|
3687
3687
|
}
|
|
3688
|
-
return
|
|
3688
|
+
return parsed2;
|
|
3689
3689
|
}
|
|
3690
3690
|
function fnv1a64(value) {
|
|
3691
3691
|
let hash = 0xcbf29ce484222325n;
|
|
@@ -3886,10 +3886,10 @@ function templateAssignment(template, embeddings) {
|
|
|
3886
3886
|
if (existingNode !== void 0 && existingNode !== nodeIndex) return null;
|
|
3887
3887
|
nodesByModuleId.set(moduleId, nodeIndex);
|
|
3888
3888
|
const node = template.nodes[nodeIndex];
|
|
3889
|
-
const
|
|
3889
|
+
const path20 = node.landmarkPath ?? `node_modules/${template.packageName}/__rnx_inferred__/${moduleId}.js`;
|
|
3890
3890
|
const existingPath = pathsByModuleId.get(moduleId);
|
|
3891
|
-
if (existingPath !== void 0 && existingPath !==
|
|
3892
|
-
pathsByModuleId.set(moduleId,
|
|
3891
|
+
if (existingPath !== void 0 && existingPath !== path20) return null;
|
|
3892
|
+
pathsByModuleId.set(moduleId, path20);
|
|
3893
3893
|
}
|
|
3894
3894
|
}
|
|
3895
3895
|
return {
|
|
@@ -4051,14 +4051,14 @@ async function inferMetroModuleIdentity(args) {
|
|
|
4051
4051
|
const packageClaims = claimsByPackage.values().next().value;
|
|
4052
4052
|
if (!packageClaims) continue;
|
|
4053
4053
|
const exactClaims = packageClaims.filter((assignment2) => {
|
|
4054
|
-
const
|
|
4055
|
-
return
|
|
4054
|
+
const path20 = assignment2.pathsByModuleId.get(moduleId);
|
|
4055
|
+
return path20 !== void 0 && !path20.includes("/__rnx_inferred__/");
|
|
4056
4056
|
});
|
|
4057
4057
|
const preferredClaims = exactClaims.length > 0 ? exactClaims : packageClaims;
|
|
4058
4058
|
const routes = new Set(
|
|
4059
4059
|
preferredClaims.flatMap((assignment2) => {
|
|
4060
|
-
const
|
|
4061
|
-
return
|
|
4060
|
+
const path20 = assignment2.pathsByModuleId.get(moduleId);
|
|
4061
|
+
return path20 ? [metroFingerprintModuleClaimRoute(assignment2.packageName, path20)] : [];
|
|
4062
4062
|
})
|
|
4063
4063
|
);
|
|
4064
4064
|
if (routes.size !== 1) continue;
|
|
@@ -4198,19 +4198,19 @@ var init_cloud_contract = __esm({
|
|
|
4198
4198
|
|
|
4199
4199
|
// cli/cloud-session.ts
|
|
4200
4200
|
function normalizeCloudOrigin(source) {
|
|
4201
|
-
let
|
|
4201
|
+
let parsed2;
|
|
4202
4202
|
try {
|
|
4203
|
-
|
|
4203
|
+
parsed2 = new URL(source);
|
|
4204
4204
|
} catch {
|
|
4205
4205
|
throw new Error(`invalid remote simulator origin: ${source}`);
|
|
4206
4206
|
}
|
|
4207
|
-
if (
|
|
4207
|
+
if (parsed2.protocol !== "https:" && parsed2.protocol !== "http:" || parsed2.username || parsed2.password || parsed2.pathname !== "/" || parsed2.search || parsed2.hash) {
|
|
4208
4208
|
throw new Error(`remote simulator origin must be an HTTP(S) origin: ${source}`);
|
|
4209
4209
|
}
|
|
4210
|
-
if (
|
|
4210
|
+
if (parsed2.protocol === "http:" && !isLoopbackHost(parsed2.hostname)) {
|
|
4211
4211
|
throw new Error(`remote simulator origin requires HTTPS outside loopback: ${source}`);
|
|
4212
4212
|
}
|
|
4213
|
-
return
|
|
4213
|
+
return parsed2.origin;
|
|
4214
4214
|
}
|
|
4215
4215
|
function createCloudSession(input) {
|
|
4216
4216
|
const boxId = input.boxId?.trim() ?? "";
|
|
@@ -4258,8 +4258,8 @@ function detectFramework(deps) {
|
|
|
4258
4258
|
return "unknown";
|
|
4259
4259
|
}
|
|
4260
4260
|
function detectProject(dir) {
|
|
4261
|
-
const pkgPath = (0,
|
|
4262
|
-
if (!(0,
|
|
4261
|
+
const pkgPath = (0, import_node_path24.join)(dir, "package.json");
|
|
4262
|
+
if (!(0, import_node_fs24.existsSync)(pkgPath)) return null;
|
|
4263
4263
|
const pkg = readProjectManifest(dir);
|
|
4264
4264
|
if (!pkg) return null;
|
|
4265
4265
|
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
@@ -4271,25 +4271,25 @@ function detectProject(dir) {
|
|
|
4271
4271
|
if (framework === "unknown") return null;
|
|
4272
4272
|
return {
|
|
4273
4273
|
dir,
|
|
4274
|
-
name: pkg.name || (0,
|
|
4274
|
+
name: pkg.name || (0, import_node_path24.basename)(dir),
|
|
4275
4275
|
framework,
|
|
4276
4276
|
// a config file is a config file whatever module system it declares. real
|
|
4277
4277
|
// apps write .cjs as often as .js, and missing one reads as "this project
|
|
4278
4278
|
// has no bundler config" and sends the user to create a second one.
|
|
4279
4279
|
hasViteConfig: CONFIG_EXTENSIONS.some(
|
|
4280
|
-
(ext) => (0,
|
|
4280
|
+
(ext) => (0, import_node_fs24.existsSync)((0, import_node_path24.join)(dir, `vite.config.${ext}`))
|
|
4281
4281
|
),
|
|
4282
4282
|
hasMetroConfig: CONFIG_EXTENSIONS.some(
|
|
4283
|
-
(ext) => (0,
|
|
4283
|
+
(ext) => (0, import_node_fs24.existsSync)((0, import_node_path24.join)(dir, `metro.config.${ext}`))
|
|
4284
4284
|
),
|
|
4285
4285
|
devCommand: typeof devCommand === "string" ? devCommand : null
|
|
4286
4286
|
};
|
|
4287
4287
|
}
|
|
4288
|
-
function readProjectMetadata(
|
|
4288
|
+
function readProjectMetadata(path20) {
|
|
4289
4289
|
try {
|
|
4290
|
-
const info = (0,
|
|
4290
|
+
const info = (0, import_node_fs24.lstatSync)(path20);
|
|
4291
4291
|
if (!info.isFile() || info.size > 4 * 1024 * 1024) return null;
|
|
4292
|
-
return (0,
|
|
4292
|
+
return (0, import_node_fs24.readFileSync)(path20, "utf8");
|
|
4293
4293
|
} catch {
|
|
4294
4294
|
return null;
|
|
4295
4295
|
}
|
|
@@ -4298,8 +4298,8 @@ function metadataValue(value, key) {
|
|
|
4298
4298
|
if (!value || typeof value !== "object") return void 0;
|
|
4299
4299
|
return Object.getOwnPropertyDescriptor(value, key)?.value;
|
|
4300
4300
|
}
|
|
4301
|
-
function readProjectJson(
|
|
4302
|
-
const text = readProjectMetadata(
|
|
4301
|
+
function readProjectJson(path20) {
|
|
4302
|
+
const text = readProjectMetadata(path20);
|
|
4303
4303
|
if (text === null) return null;
|
|
4304
4304
|
try {
|
|
4305
4305
|
const value = JSON.parse(text);
|
|
@@ -4309,8 +4309,8 @@ function readProjectJson(path18) {
|
|
|
4309
4309
|
}
|
|
4310
4310
|
}
|
|
4311
4311
|
function readProjectManifest(dir) {
|
|
4312
|
-
const
|
|
4313
|
-
if (!
|
|
4312
|
+
const parsed2 = readProjectJson((0, import_node_path24.join)(dir, "package.json"));
|
|
4313
|
+
if (!parsed2 || typeof parsed2 !== "object") return null;
|
|
4314
4314
|
const record = (value) => {
|
|
4315
4315
|
if (!value || typeof value !== "object") return {};
|
|
4316
4316
|
return Object.fromEntries(
|
|
@@ -4319,19 +4319,19 @@ function readProjectManifest(dir) {
|
|
|
4319
4319
|
)
|
|
4320
4320
|
);
|
|
4321
4321
|
};
|
|
4322
|
-
const name2 = metadataValue(
|
|
4322
|
+
const name2 = metadataValue(parsed2, "name");
|
|
4323
4323
|
return {
|
|
4324
4324
|
...typeof name2 === "string" ? { name: name2 } : {},
|
|
4325
|
-
dependencies: record(metadataValue(
|
|
4326
|
-
devDependencies: record(metadataValue(
|
|
4325
|
+
dependencies: record(metadataValue(parsed2, "dependencies")),
|
|
4326
|
+
devDependencies: record(metadataValue(parsed2, "devDependencies"))
|
|
4327
4327
|
};
|
|
4328
4328
|
}
|
|
4329
|
-
var
|
|
4329
|
+
var import_node_fs24, import_node_path24, import_json5, import_yaml, CONFIG_EXTENSIONS;
|
|
4330
4330
|
var init_detect = __esm({
|
|
4331
4331
|
"cli/commands/detect.ts"() {
|
|
4332
4332
|
"use strict";
|
|
4333
|
-
|
|
4334
|
-
|
|
4333
|
+
import_node_fs24 = require("node:fs");
|
|
4334
|
+
import_node_path24 = require("node:path");
|
|
4335
4335
|
import_json5 = __toESM(require("json5"), 1);
|
|
4336
4336
|
import_yaml = require("yaml");
|
|
4337
4337
|
CONFIG_EXTENSIONS = ["ts", "js", "cjs", "mjs", "mts", "cts"];
|
|
@@ -4340,24 +4340,24 @@ var init_detect = __esm({
|
|
|
4340
4340
|
|
|
4341
4341
|
// cli/cloud-client.ts
|
|
4342
4342
|
function failureSentence(text) {
|
|
4343
|
-
let
|
|
4343
|
+
let parsed2;
|
|
4344
4344
|
try {
|
|
4345
|
-
|
|
4345
|
+
parsed2 = JSON.parse(text);
|
|
4346
4346
|
} catch {
|
|
4347
4347
|
return null;
|
|
4348
4348
|
}
|
|
4349
|
-
if (!isRecord2(
|
|
4350
|
-
if (isRecord2(
|
|
4351
|
-
const code = typeof
|
|
4352
|
-
return `${
|
|
4349
|
+
if (!isRecord2(parsed2)) return null;
|
|
4350
|
+
if (isRecord2(parsed2.error) && typeof parsed2.error.message === "string") {
|
|
4351
|
+
const code = typeof parsed2.error.code === "string" && parsed2.error.code ? ` [${parsed2.error.code}]` : "";
|
|
4352
|
+
return `${parsed2.error.message}${code}`;
|
|
4353
4353
|
}
|
|
4354
|
-
if (typeof
|
|
4355
|
-
if (typeof
|
|
4354
|
+
if (typeof parsed2.message === "string") return parsed2.message;
|
|
4355
|
+
if (typeof parsed2.error === "string") return parsed2.error;
|
|
4356
4356
|
return null;
|
|
4357
4357
|
}
|
|
4358
4358
|
function responseError(status, text) {
|
|
4359
|
-
const
|
|
4360
|
-
const sentence =
|
|
4359
|
+
const parsed2 = text ? failureSentence(text) : null;
|
|
4360
|
+
const sentence = parsed2 && ACCOUNT_CHOICE_REFUSALS.has(parsed2) ? CHOOSE_ACCOUNT_HINT : parsed2;
|
|
4361
4361
|
return new Error(
|
|
4362
4362
|
`remote simulator request failed (${status})${sentence ? `: ${sentence}` : text.trim() ? `: ${text.trim()}` : ""}`
|
|
4363
4363
|
);
|
|
@@ -4368,21 +4368,21 @@ function resolveCloudOrigin(value) {
|
|
|
4368
4368
|
return normalizeCloudOrigin(source);
|
|
4369
4369
|
}
|
|
4370
4370
|
function readImmutableBundleSource(bundlePath) {
|
|
4371
|
-
const filepath = (0,
|
|
4372
|
-
if ((0,
|
|
4371
|
+
const filepath = (0, import_node_path25.resolve)(bundlePath);
|
|
4372
|
+
if ((0, import_node_path25.extname)(filepath) !== ".js") {
|
|
4373
4373
|
throw new Error(`${REMOTE_COMMAND} requires one local Metro .js bundle`);
|
|
4374
4374
|
}
|
|
4375
|
-
const descriptor = (0,
|
|
4375
|
+
const descriptor = (0, import_node_fs25.openSync)(filepath, "r");
|
|
4376
4376
|
try {
|
|
4377
|
-
const before = (0,
|
|
4377
|
+
const before = (0, import_node_fs25.fstatSync)(descriptor, { bigint: true });
|
|
4378
4378
|
if (!before.isFile()) {
|
|
4379
4379
|
throw new Error(`${REMOTE_COMMAND} bundle must be a regular local file`);
|
|
4380
4380
|
}
|
|
4381
4381
|
if (before.size <= 0n) {
|
|
4382
4382
|
throw new Error(`${REMOTE_COMMAND} bundle is empty`);
|
|
4383
4383
|
}
|
|
4384
|
-
const bytes = (0,
|
|
4385
|
-
const after = (0,
|
|
4384
|
+
const bytes = (0, import_node_fs25.readFileSync)(descriptor);
|
|
4385
|
+
const after = (0, import_node_fs25.fstatSync)(descriptor, { bigint: true });
|
|
4386
4386
|
if (before.dev !== after.dev || before.ino !== after.ino || before.size !== after.size || before.mtimeNs !== after.mtimeNs || bytes.length !== Number(before.size)) {
|
|
4387
4387
|
throw new Error(`${REMOTE_COMMAND} bundle changed while it was being read`);
|
|
4388
4388
|
}
|
|
@@ -4397,7 +4397,7 @@ function readImmutableBundleSource(bundlePath) {
|
|
|
4397
4397
|
}
|
|
4398
4398
|
return source;
|
|
4399
4399
|
} finally {
|
|
4400
|
-
(0,
|
|
4400
|
+
(0, import_node_fs25.closeSync)(descriptor);
|
|
4401
4401
|
}
|
|
4402
4402
|
}
|
|
4403
4403
|
async function fetchBundleSource(bundleUrl) {
|
|
@@ -4444,15 +4444,15 @@ async function loadBundleSource(bundleInput) {
|
|
|
4444
4444
|
return readImmutableBundleSource(bundleInput);
|
|
4445
4445
|
}
|
|
4446
4446
|
function listMetroAssetDest(assetsPath) {
|
|
4447
|
-
const directory = (0,
|
|
4448
|
-
if (!(0,
|
|
4449
|
-
const skipNested = (0,
|
|
4447
|
+
const directory = (0, import_node_path25.resolve)(assetsPath);
|
|
4448
|
+
if (!(0, import_node_fs25.existsSync)(directory)) return { directory, files: [], truncated: false };
|
|
4449
|
+
const skipNested = (0, import_node_fs25.existsSync)((0, import_node_path25.join)(directory, "package.json"));
|
|
4450
4450
|
const files = [];
|
|
4451
4451
|
let truncated = false;
|
|
4452
|
-
const
|
|
4452
|
+
const walk2 = (dir, prefix) => {
|
|
4453
4453
|
let entries;
|
|
4454
4454
|
try {
|
|
4455
|
-
entries = (0,
|
|
4455
|
+
entries = (0, import_node_fs25.readdirSync)(dir, { withFileTypes: true });
|
|
4456
4456
|
} catch {
|
|
4457
4457
|
return;
|
|
4458
4458
|
}
|
|
@@ -4464,13 +4464,13 @@ function listMetroAssetDest(assetsPath) {
|
|
|
4464
4464
|
if (entry.isDirectory()) {
|
|
4465
4465
|
if (entry.name === ".git") continue;
|
|
4466
4466
|
if (skipNested && PROJECT_ONLY_DIRECTORIES.has(entry.name)) continue;
|
|
4467
|
-
|
|
4467
|
+
walk2((0, import_node_path25.join)(dir, entry.name), prefix ? `${prefix}/${entry.name}` : entry.name);
|
|
4468
4468
|
} else if (entry.isFile()) {
|
|
4469
4469
|
files.push(prefix ? `${prefix}/${entry.name}` : entry.name);
|
|
4470
4470
|
}
|
|
4471
4471
|
}
|
|
4472
4472
|
};
|
|
4473
|
-
|
|
4473
|
+
walk2(directory, "");
|
|
4474
4474
|
return { directory, files, truncated };
|
|
4475
4475
|
}
|
|
4476
4476
|
function metroDescriptorHash(scaleBytes) {
|
|
@@ -4499,7 +4499,7 @@ function distinctByContent(directory, options) {
|
|
|
4499
4499
|
for (const relative2 of options) {
|
|
4500
4500
|
let bytes;
|
|
4501
4501
|
try {
|
|
4502
|
-
bytes = (0,
|
|
4502
|
+
bytes = (0, import_node_fs25.readFileSync)((0, import_node_path25.join)(directory, relative2));
|
|
4503
4503
|
} catch {
|
|
4504
4504
|
continue;
|
|
4505
4505
|
}
|
|
@@ -4531,7 +4531,7 @@ function placeMetroDescriptor(listing, descriptor) {
|
|
|
4531
4531
|
let bytes;
|
|
4532
4532
|
try {
|
|
4533
4533
|
bytes = combination.map(
|
|
4534
|
-
(relative2) => (0,
|
|
4534
|
+
(relative2) => (0, import_node_fs25.readFileSync)((0, import_node_path25.join)(listing.directory, relative2))
|
|
4535
4535
|
);
|
|
4536
4536
|
} catch {
|
|
4537
4537
|
continue;
|
|
@@ -4557,26 +4557,26 @@ function placeMetroDescriptor(listing, descriptor) {
|
|
|
4557
4557
|
}
|
|
4558
4558
|
function unverifiedFileKey(dest) {
|
|
4559
4559
|
return dest.placements.filter((placement) => !placement.verified).flatMap(
|
|
4560
|
-
(placement) => [...placement.files.values()].map((relative2) => (0,
|
|
4560
|
+
(placement) => [...placement.files.values()].map((relative2) => (0, import_node_path25.join)(dest.directory, relative2))
|
|
4561
4561
|
).sort().join("\n");
|
|
4562
4562
|
}
|
|
4563
4563
|
function searchMetroAssetDest(bundlePath, descriptors) {
|
|
4564
|
-
const bundleDirectory = (0,
|
|
4564
|
+
const bundleDirectory = (0, import_node_path25.dirname)((0, import_node_path25.resolve)(bundlePath));
|
|
4565
4565
|
const candidates = [
|
|
4566
|
-
(0,
|
|
4566
|
+
(0, import_node_path25.join)(bundleDirectory, "assets"),
|
|
4567
4567
|
bundleDirectory,
|
|
4568
|
-
(0,
|
|
4568
|
+
(0, import_node_path25.resolve)(bundleDirectory, "..", "assets")
|
|
4569
4569
|
];
|
|
4570
4570
|
const cwd = process.cwd();
|
|
4571
4571
|
let projectDirectory = null;
|
|
4572
4572
|
for (const start of [bundleDirectory, cwd]) {
|
|
4573
|
-
let directory = (0,
|
|
4573
|
+
let directory = (0, import_node_path25.resolve)(start);
|
|
4574
4574
|
while (true) {
|
|
4575
4575
|
if (detectProject(directory)?.hasMetroConfig) {
|
|
4576
4576
|
projectDirectory = directory;
|
|
4577
4577
|
break;
|
|
4578
4578
|
}
|
|
4579
|
-
const parent = (0,
|
|
4579
|
+
const parent = (0, import_node_path25.dirname)(directory);
|
|
4580
4580
|
if (parent === directory) break;
|
|
4581
4581
|
directory = parent;
|
|
4582
4582
|
}
|
|
@@ -4584,11 +4584,11 @@ function searchMetroAssetDest(bundlePath, descriptors) {
|
|
|
4584
4584
|
}
|
|
4585
4585
|
if (projectDirectory) {
|
|
4586
4586
|
candidates.push(
|
|
4587
|
-
(0,
|
|
4588
|
-
(0,
|
|
4589
|
-
(0,
|
|
4590
|
-
(0,
|
|
4591
|
-
(0,
|
|
4587
|
+
(0, import_node_path25.join)(projectDirectory, "assets"),
|
|
4588
|
+
(0, import_node_path25.join)(projectDirectory, "dist"),
|
|
4589
|
+
(0, import_node_path25.join)(projectDirectory, "dist", "assets"),
|
|
4590
|
+
(0, import_node_path25.join)(projectDirectory, "build"),
|
|
4591
|
+
(0, import_node_path25.join)(projectDirectory, "build", "assets")
|
|
4592
4592
|
);
|
|
4593
4593
|
}
|
|
4594
4594
|
const searched = [];
|
|
@@ -4596,7 +4596,7 @@ function searchMetroAssetDest(bundlePath, descriptors) {
|
|
|
4596
4596
|
const stale = [];
|
|
4597
4597
|
let truncated = false;
|
|
4598
4598
|
for (const candidate of candidates) {
|
|
4599
|
-
const directory = (0,
|
|
4599
|
+
const directory = (0, import_node_path25.resolve)(candidate);
|
|
4600
4600
|
if (searched.includes(directory)) continue;
|
|
4601
4601
|
searched.push(directory);
|
|
4602
4602
|
const listing = listMetroAssetDest(directory);
|
|
@@ -4609,10 +4609,10 @@ function searchMetroAssetDest(bundlePath, descriptors) {
|
|
|
4609
4609
|
stale.push(directory);
|
|
4610
4610
|
continue;
|
|
4611
4611
|
}
|
|
4612
|
-
const
|
|
4613
|
-
if (
|
|
4612
|
+
const verified3 = placements.filter((placement) => placement.verified).length;
|
|
4613
|
+
if (verified3 === 0 && placements.every((placement) => placement.files.size === 0))
|
|
4614
4614
|
continue;
|
|
4615
|
-
holders.push({ dest: { directory, placements }, verified:
|
|
4615
|
+
holders.push({ dest: { directory, placements }, verified: verified3 });
|
|
4616
4616
|
}
|
|
4617
4617
|
if (holders.length === 0) {
|
|
4618
4618
|
if (stale.length > 0) {
|
|
@@ -4702,7 +4702,7 @@ async function embedBundleAssets(bundlePath, command, assetPolicy) {
|
|
|
4702
4702
|
);
|
|
4703
4703
|
}
|
|
4704
4704
|
const relative2 = placement?.files.get(variant.scale);
|
|
4705
|
-
if (relative2 && dest) return (0,
|
|
4705
|
+
if (relative2 && dest) return (0, import_node_fs25.readFileSync)((0, import_node_path25.join)(dest.directory, relative2));
|
|
4706
4706
|
if (placement && placement.files.size > 0) return null;
|
|
4707
4707
|
if (placement && placement.ambiguous.length > 0 && dest) {
|
|
4708
4708
|
throw new Error(
|
|
@@ -4731,7 +4731,7 @@ async function embedBundleAssets(bundlePath, command, assetPolicy) {
|
|
|
4731
4731
|
);
|
|
4732
4732
|
const classic = metroIosAssetDestRelatives(variant.descriptor.httpServerLocation, filename)[0] ?? filename;
|
|
4733
4733
|
throw new Error(
|
|
4734
|
-
`${command} could not read ${(0,
|
|
4734
|
+
`${command} could not read ${(0, import_node_path25.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\`.`
|
|
4735
4735
|
);
|
|
4736
4736
|
});
|
|
4737
4737
|
return {
|
|
@@ -4848,13 +4848,13 @@ async function createCloudBox(options) {
|
|
|
4848
4848
|
}
|
|
4849
4849
|
const responseText = await response.text();
|
|
4850
4850
|
if (!response.ok) throw responseError(response.status, responseText);
|
|
4851
|
-
let
|
|
4851
|
+
let parsed2;
|
|
4852
4852
|
try {
|
|
4853
|
-
|
|
4853
|
+
parsed2 = JSON.parse(responseText);
|
|
4854
4854
|
} catch {
|
|
4855
4855
|
throw new Error("remote simulator create returned unreadable JSON");
|
|
4856
4856
|
}
|
|
4857
|
-
const created = readCreateResponse(
|
|
4857
|
+
const created = readCreateResponse(parsed2, artifact.bytes.length, artifact.sha256);
|
|
4858
4858
|
const session = createCloudSession({
|
|
4859
4859
|
boxId: created.receipt.boxId,
|
|
4860
4860
|
boxToken: created.boxToken,
|
|
@@ -4877,13 +4877,13 @@ async function createCloudBox(options) {
|
|
|
4877
4877
|
warnings: artifact.warnings
|
|
4878
4878
|
};
|
|
4879
4879
|
}
|
|
4880
|
-
var import_node_crypto11,
|
|
4880
|
+
var import_node_crypto11, import_node_fs25, import_node_path25, DEFAULT_RNX_CLOUD_ORIGIN, MAX_RNX_CLOUD_BUNDLE_BYTES, REMOTE_COMMAND, MAX_ASSET_DEST_FILES, ACCOUNT_CHOICE_REFUSALS, PROJECT_ONLY_DIRECTORIES, MAX_PLACEMENT_COMBINATIONS;
|
|
4881
4881
|
var init_cloud_client = __esm({
|
|
4882
4882
|
"cli/cloud-client.ts"() {
|
|
4883
4883
|
"use strict";
|
|
4884
4884
|
import_node_crypto11 = require("node:crypto");
|
|
4885
|
-
|
|
4886
|
-
|
|
4885
|
+
import_node_fs25 = require("node:fs");
|
|
4886
|
+
import_node_path25 = require("node:path");
|
|
4887
4887
|
init_metroAssetArtifact();
|
|
4888
4888
|
init_metroCloudArtifact();
|
|
4889
4889
|
init_metro_fingerprint_registry_client();
|
|
@@ -5169,13 +5169,13 @@ function hasPeachConfig(config) {
|
|
|
5169
5169
|
return typeof config.runtimeVersion === "string" && config.runtimeVersion.length > 0 || hasOwnKeys(config.modules) || hasOwnKeys(config.turboModules) || hasOwnKeys(config.nativeModules) || hasOwnKeys(config.nativeViews) || hasOwnKeys(config.env) || hasOwnKeys(config.network?.remap) || hasOwnKeys(config.settings) || hasOwnKeys(config.initialState);
|
|
5170
5170
|
}
|
|
5171
5171
|
function applyPeachConfigToUrl(url, config) {
|
|
5172
|
-
const
|
|
5172
|
+
const parsed2 = new URL(url);
|
|
5173
5173
|
if (hasPeachConfig(config)) {
|
|
5174
|
-
|
|
5174
|
+
parsed2.searchParams.set(PEACH_CONFIG_QUERY_PARAM, JSON.stringify(config));
|
|
5175
5175
|
} else {
|
|
5176
|
-
|
|
5176
|
+
parsed2.searchParams.delete(PEACH_CONFIG_QUERY_PARAM);
|
|
5177
5177
|
}
|
|
5178
|
-
return
|
|
5178
|
+
return parsed2.toString();
|
|
5179
5179
|
}
|
|
5180
5180
|
|
|
5181
5181
|
// src/native-dev-bundle-url.ts
|
|
@@ -5199,25 +5199,25 @@ function alignLoopbackBundleUrlWithProbe(bundleUrl, probeBaseUrl) {
|
|
|
5199
5199
|
return bundleUrl;
|
|
5200
5200
|
}
|
|
5201
5201
|
}
|
|
5202
|
-
function applyPreviewProdBundle(
|
|
5202
|
+
function applyPreviewProdBundle(parsed2) {
|
|
5203
5203
|
if (!process.env.SOOTSIM_PREVIEW_PROD_BUNDLE) return;
|
|
5204
|
-
|
|
5205
|
-
|
|
5206
|
-
if (
|
|
5204
|
+
parsed2.searchParams.set("dev", "false");
|
|
5205
|
+
parsed2.searchParams.set("minify", "true");
|
|
5206
|
+
if (parsed2.searchParams.has("hot")) parsed2.searchParams.set("hot", "false");
|
|
5207
5207
|
}
|
|
5208
5208
|
function normalizeNativeDevBundleUrl(bundleUrl) {
|
|
5209
5209
|
try {
|
|
5210
5210
|
const isAbsolute2 = isAbsoluteHttpUrl(bundleUrl);
|
|
5211
|
-
const
|
|
5212
|
-
|
|
5213
|
-
if (!isNativeDevBundlePath(
|
|
5214
|
-
|
|
5215
|
-
if (
|
|
5216
|
-
|
|
5217
|
-
}
|
|
5218
|
-
applyPreviewProdBundle(
|
|
5219
|
-
if (isAbsolute2) return
|
|
5220
|
-
return `${
|
|
5211
|
+
const parsed2 = new URL(bundleUrl, "http://sootsim.local");
|
|
5212
|
+
parsed2.pathname = parsed2.pathname.replace(/\.\.bundle$/, ".bundle");
|
|
5213
|
+
if (!isNativeDevBundlePath(parsed2.pathname)) return bundleUrl;
|
|
5214
|
+
parsed2.searchParams.delete("transform.bytecode");
|
|
5215
|
+
if (parsed2.searchParams.get("lazy") === "true") {
|
|
5216
|
+
parsed2.searchParams.set("lazy", "false");
|
|
5217
|
+
}
|
|
5218
|
+
applyPreviewProdBundle(parsed2);
|
|
5219
|
+
if (isAbsolute2) return parsed2.toString();
|
|
5220
|
+
return `${parsed2.pathname}${parsed2.search}${parsed2.hash}`;
|
|
5221
5221
|
} catch {
|
|
5222
5222
|
return bundleUrl;
|
|
5223
5223
|
}
|
|
@@ -5315,9 +5315,9 @@ function safeChildPlistName(value) {
|
|
|
5315
5315
|
name: file.toLowerCase().endsWith(".plist") ? file : `${file}.plist`
|
|
5316
5316
|
};
|
|
5317
5317
|
}
|
|
5318
|
-
async function readableSettingsBundle(
|
|
5318
|
+
async function readableSettingsBundle(path20) {
|
|
5319
5319
|
try {
|
|
5320
|
-
const root = await (0, import_promises.stat)((0, import_node_path.join)(
|
|
5320
|
+
const root = await (0, import_promises.stat)((0, import_node_path.join)(path20, "Root.plist"));
|
|
5321
5321
|
return root.isFile() && root.size <= MAX_PLIST_BYTES;
|
|
5322
5322
|
} catch {
|
|
5323
5323
|
return false;
|
|
@@ -5362,13 +5362,13 @@ async function settingsBundleFingerprint(bundlePath) {
|
|
|
5362
5362
|
return null;
|
|
5363
5363
|
}
|
|
5364
5364
|
}
|
|
5365
|
-
async function parsePlistRecord(
|
|
5365
|
+
async function parsePlistRecord(path20) {
|
|
5366
5366
|
try {
|
|
5367
|
-
const metadata = await (0, import_promises.stat)(
|
|
5367
|
+
const metadata = await (0, import_promises.stat)(path20);
|
|
5368
5368
|
if (!metadata.isFile() || metadata.size > MAX_PLIST_BYTES) return null;
|
|
5369
|
-
const source = await (0, import_promises.readFile)(
|
|
5370
|
-
const
|
|
5371
|
-
return isRecord(
|
|
5369
|
+
const source = await (0, import_promises.readFile)(path20, "utf8");
|
|
5370
|
+
const parsed2 = parsePlistSource(source);
|
|
5371
|
+
return isRecord(parsed2) ? parsed2 : null;
|
|
5372
5372
|
} catch {
|
|
5373
5373
|
return null;
|
|
5374
5374
|
}
|
|
@@ -5628,7 +5628,7 @@ async function tcpPing(port, timeout = TCP_GATE_MS) {
|
|
|
5628
5628
|
return null;
|
|
5629
5629
|
}
|
|
5630
5630
|
}
|
|
5631
|
-
function httpGet(hostname, port,
|
|
5631
|
+
function httpGet(hostname, port, path20, method = "GET", timeout = TIMEOUT_MS, headers = {}) {
|
|
5632
5632
|
return new Promise((resolve5) => {
|
|
5633
5633
|
let settled = false;
|
|
5634
5634
|
let killing = false;
|
|
@@ -5637,7 +5637,7 @@ function httpGet(hostname, port, path18, method = "GET", timeout = TIMEOUT_MS, h
|
|
|
5637
5637
|
settled = true;
|
|
5638
5638
|
resolve5(value);
|
|
5639
5639
|
};
|
|
5640
|
-
const req = import_http.default.request({ hostname, port, path:
|
|
5640
|
+
const req = import_http.default.request({ hostname, port, path: path20, method, headers }, (res) => {
|
|
5641
5641
|
let body = "";
|
|
5642
5642
|
res.on("data", (c) => body += c.toString());
|
|
5643
5643
|
const contentType = (() => {
|
|
@@ -5876,8 +5876,8 @@ function isDirectOneBundleUrl(bundleUrl) {
|
|
|
5876
5876
|
}
|
|
5877
5877
|
function safeParseManifest(body) {
|
|
5878
5878
|
try {
|
|
5879
|
-
const
|
|
5880
|
-
return
|
|
5879
|
+
const parsed2 = JSON.parse(body);
|
|
5880
|
+
return parsed2 && typeof parsed2 === "object" ? parsed2 : null;
|
|
5881
5881
|
} catch {
|
|
5882
5882
|
return null;
|
|
5883
5883
|
}
|
|
@@ -5927,8 +5927,8 @@ function applyManifest(result, manifestRes, buildIconProxyUrl) {
|
|
|
5927
5927
|
if (rawIcon.startsWith("http://") || rawIcon.startsWith("https://")) {
|
|
5928
5928
|
let isLoopback = false;
|
|
5929
5929
|
try {
|
|
5930
|
-
const
|
|
5931
|
-
isLoopback = isLoopbackHost(
|
|
5930
|
+
const parsed2 = new URL(rawIcon);
|
|
5931
|
+
isLoopback = isLoopbackHost(parsed2.hostname);
|
|
5932
5932
|
} catch {
|
|
5933
5933
|
}
|
|
5934
5934
|
if (buildIconProxyUrl) {
|
|
@@ -6001,7 +6001,7 @@ async function fetchManifestEnrichment(result, buildIconProxyUrl) {
|
|
|
6001
6001
|
}
|
|
6002
6002
|
);
|
|
6003
6003
|
if (!manifestRes || manifestRes.statusCode !== 200) return;
|
|
6004
|
-
const
|
|
6004
|
+
const parsed2 = applyManifest(
|
|
6005
6005
|
{
|
|
6006
6006
|
port: result.port,
|
|
6007
6007
|
framework: "one",
|
|
@@ -6011,12 +6011,12 @@ async function fetchManifestEnrichment(result, buildIconProxyUrl) {
|
|
|
6011
6011
|
manifestRes,
|
|
6012
6012
|
buildIconProxyUrl
|
|
6013
6013
|
);
|
|
6014
|
-
if (!
|
|
6014
|
+
if (!parsed2.projectName && !parsed2.iconUrl) return;
|
|
6015
6015
|
enrichmentCache.set(result.port, {
|
|
6016
|
-
projectName:
|
|
6017
|
-
iconUrl:
|
|
6018
|
-
iconPath:
|
|
6019
|
-
bundleId:
|
|
6016
|
+
projectName: parsed2.projectName,
|
|
6017
|
+
iconUrl: parsed2.iconUrl,
|
|
6018
|
+
iconPath: parsed2.iconPath,
|
|
6019
|
+
bundleId: parsed2.bundleId
|
|
6020
6020
|
});
|
|
6021
6021
|
invalidatePortCache(result.port);
|
|
6022
6022
|
}
|
|
@@ -6316,12 +6316,12 @@ function getCliVersion() {
|
|
|
6316
6316
|
}
|
|
6317
6317
|
|
|
6318
6318
|
// src/expo-swift-host.ts
|
|
6319
|
-
var
|
|
6319
|
+
var import_node_child_process7 = require("node:child_process");
|
|
6320
6320
|
var import_node_crypto6 = require("node:crypto");
|
|
6321
|
-
var
|
|
6321
|
+
var import_node_fs16 = __toESM(require("node:fs"), 1);
|
|
6322
6322
|
var import_node_module = require("node:module");
|
|
6323
6323
|
var import_node_os6 = __toESM(require("node:os"), 1);
|
|
6324
|
-
var
|
|
6324
|
+
var import_node_path16 = __toESM(require("node:path"), 1);
|
|
6325
6325
|
var import_node_util3 = require("node:util");
|
|
6326
6326
|
|
|
6327
6327
|
// cli/internal-child.ts
|
|
@@ -6508,14 +6508,24 @@ function swiftImplicitResourcePaths(paths) {
|
|
|
6508
6508
|
) || /(?:^|\/)[^/]+\.lproj\/[^/]+$/.test(file))
|
|
6509
6509
|
).sort();
|
|
6510
6510
|
}
|
|
6511
|
-
|
|
6512
|
-
|
|
6513
|
-
|
|
6514
|
-
|
|
6515
|
-
|
|
6511
|
+
var MANIFEST_DECLARATIONS = [
|
|
6512
|
+
"executableTarget",
|
|
6513
|
+
"testTarget",
|
|
6514
|
+
"binaryTarget",
|
|
6515
|
+
"systemLibrary",
|
|
6516
|
+
"macro",
|
|
6517
|
+
"plugin",
|
|
6518
|
+
"target",
|
|
6519
|
+
"library",
|
|
6520
|
+
"executable",
|
|
6521
|
+
"package"
|
|
6522
|
+
];
|
|
6523
|
+
function manifestCalls(manifest, kinds) {
|
|
6524
|
+
const code = manifest.replace(/\/\*[\s\S]*?\*\//g, "").replace(/(^|[^:"])\/\/[^\n]*/g, "$1");
|
|
6525
|
+
const calls = [];
|
|
6526
|
+
const pattern = new RegExp(`\\.(${MANIFEST_DECLARATIONS.join("|")})\\s*\\(`, "g");
|
|
6516
6527
|
let match;
|
|
6517
6528
|
while ((match = pattern.exec(code)) !== null) {
|
|
6518
|
-
const executable = match[1] === "executableTarget";
|
|
6519
6529
|
let depth = 1;
|
|
6520
6530
|
const start = pattern.lastIndex;
|
|
6521
6531
|
let i = start;
|
|
@@ -6543,18 +6553,141 @@ function swiftManifestTargets(manifest, resourcePaths = []) {
|
|
|
6543
6553
|
}
|
|
6544
6554
|
i++;
|
|
6545
6555
|
}
|
|
6556
|
+
if (kinds.includes(match[1]))
|
|
6557
|
+
calls.push({ kind: match[1], flat, call: code.slice(start, i) });
|
|
6558
|
+
pattern.lastIndex = i;
|
|
6559
|
+
}
|
|
6560
|
+
return calls;
|
|
6561
|
+
}
|
|
6562
|
+
var NAME = /\bname\s*:\s*"([^"]+)"/;
|
|
6563
|
+
function listArgument(call, label) {
|
|
6564
|
+
const start = new RegExp(`\\b${label}\\s*:\\s*\\[`).exec(call);
|
|
6565
|
+
if (!start) return [];
|
|
6566
|
+
const items = [];
|
|
6567
|
+
let depth = 0;
|
|
6568
|
+
let inString = false;
|
|
6569
|
+
let item = "";
|
|
6570
|
+
for (let i = start.index + start[0].length; i < call.length; i++) {
|
|
6571
|
+
const ch = call[i];
|
|
6572
|
+
if (inString) {
|
|
6573
|
+
item += ch;
|
|
6574
|
+
if (ch === '"' && call[i - 1] !== "\\") inString = false;
|
|
6575
|
+
continue;
|
|
6576
|
+
}
|
|
6577
|
+
if (ch === '"') inString = true;
|
|
6578
|
+
else if (ch === "(" || ch === "[") depth++;
|
|
6579
|
+
else if (ch === ")" || ch === "]") {
|
|
6580
|
+
if (depth === 0) break;
|
|
6581
|
+
depth--;
|
|
6582
|
+
} else if (ch === "," && depth === 0) {
|
|
6583
|
+
items.push(item.trim());
|
|
6584
|
+
item = "";
|
|
6585
|
+
continue;
|
|
6586
|
+
}
|
|
6587
|
+
item += ch;
|
|
6588
|
+
}
|
|
6589
|
+
if (item.trim()) items.push(item.trim());
|
|
6590
|
+
return items;
|
|
6591
|
+
}
|
|
6592
|
+
function swiftPackageIdentity(url) {
|
|
6593
|
+
return (url.split("/").pop() ?? url).replace(/\.git$/, "").toLowerCase();
|
|
6594
|
+
}
|
|
6595
|
+
function swiftManifestGraph(manifest) {
|
|
6596
|
+
const graph = {
|
|
6597
|
+
products: /* @__PURE__ */ new Map(),
|
|
6598
|
+
dependencies: /* @__PURE__ */ new Map(),
|
|
6599
|
+
binaryTargets: /* @__PURE__ */ new Set(),
|
|
6600
|
+
systemLibraries: /* @__PURE__ */ new Set(),
|
|
6601
|
+
packageURLs: /* @__PURE__ */ new Map(),
|
|
6602
|
+
packagePaths: []
|
|
6603
|
+
};
|
|
6604
|
+
for (const { kind, flat, call } of manifestCalls(manifest, [
|
|
6605
|
+
"library",
|
|
6606
|
+
"executableTarget",
|
|
6607
|
+
"target",
|
|
6608
|
+
"binaryTarget",
|
|
6609
|
+
"systemLibrary",
|
|
6610
|
+
"package"
|
|
6611
|
+
])) {
|
|
6612
|
+
if (kind === "package") {
|
|
6613
|
+
const local = /\bpath\s*:\s*"([^"]+)"/.exec(flat)?.[1];
|
|
6614
|
+
if (local) graph.packagePaths.push(local);
|
|
6615
|
+
const url = /\burl\s*:\s*"([^"]+)"/.exec(flat)?.[1];
|
|
6616
|
+
if (!url) continue;
|
|
6617
|
+
graph.packageURLs.set(swiftPackageIdentity(url), url);
|
|
6618
|
+
const name3 = NAME.exec(flat)?.[1];
|
|
6619
|
+
if (name3) graph.packageURLs.set(name3.toLowerCase(), url);
|
|
6620
|
+
continue;
|
|
6621
|
+
}
|
|
6622
|
+
const name2 = NAME.exec(flat)?.[1];
|
|
6623
|
+
if (!name2) continue;
|
|
6624
|
+
if (kind === "library") {
|
|
6625
|
+
graph.products.set(
|
|
6626
|
+
name2,
|
|
6627
|
+
listArgument(call, "targets").flatMap(
|
|
6628
|
+
(item) => /^"([^"]+)"$/.exec(item)?.[1] ?? []
|
|
6629
|
+
)
|
|
6630
|
+
);
|
|
6631
|
+
continue;
|
|
6632
|
+
}
|
|
6633
|
+
if (kind === "binaryTarget") graph.binaryTargets.add(name2);
|
|
6634
|
+
if (kind === "systemLibrary") graph.systemLibraries.add(name2);
|
|
6635
|
+
const dependencies = [];
|
|
6636
|
+
for (const item of listArgument(call, "dependencies")) {
|
|
6637
|
+
const platforms = /condition\s*:\s*\.when\(\s*platforms\s*:\s*\[([^\]]*)\]/.exec(
|
|
6638
|
+
item
|
|
6639
|
+
)?.[1];
|
|
6640
|
+
if (platforms !== void 0 && !/\.iOS\b/.test(platforms)) continue;
|
|
6641
|
+
if (/condition\s*:\s*\.when\([^)]*\btraits\s*:/.test(item)) continue;
|
|
6642
|
+
const plain = /^"([^"]+)"$/.exec(item)?.[1];
|
|
6643
|
+
const product = /^\.product(?:Item)?\(\s*name\s*:\s*"([^"]+)"\s*,\s*package\s*:\s*"([^"]+)"/.exec(
|
|
6644
|
+
item
|
|
6645
|
+
);
|
|
6646
|
+
const target = /^\.(?:target|byName)(?:Item)?\(\s*name\s*:\s*"([^"]+)"/.exec(
|
|
6647
|
+
item
|
|
6648
|
+
)?.[1];
|
|
6649
|
+
if (plain) dependencies.push({ kind: "target", name: plain });
|
|
6650
|
+
else if (product)
|
|
6651
|
+
dependencies.push({
|
|
6652
|
+
kind: "product",
|
|
6653
|
+
name: product[1],
|
|
6654
|
+
package: product[2].toLowerCase()
|
|
6655
|
+
});
|
|
6656
|
+
else if (target) dependencies.push({ kind: "target", name: target });
|
|
6657
|
+
}
|
|
6658
|
+
graph.dependencies.set(name2, dependencies);
|
|
6659
|
+
}
|
|
6660
|
+
for (const dependencies of graph.dependencies.values()) {
|
|
6661
|
+
for (const [index, dependency] of dependencies.entries()) {
|
|
6662
|
+
if (dependency.kind === "target" && !graph.dependencies.has(dependency.name))
|
|
6663
|
+
dependencies[index] = {
|
|
6664
|
+
kind: "product",
|
|
6665
|
+
name: dependency.name,
|
|
6666
|
+
package: dependency.name.toLowerCase()
|
|
6667
|
+
};
|
|
6668
|
+
}
|
|
6669
|
+
}
|
|
6670
|
+
return graph;
|
|
6671
|
+
}
|
|
6672
|
+
function swiftManifestTargets(manifest, resourcePaths = []) {
|
|
6673
|
+
const implicitResources = swiftImplicitResourcePaths(resourcePaths);
|
|
6674
|
+
const targets = [];
|
|
6675
|
+
for (const { kind, flat, call } of manifestCalls(manifest, [
|
|
6676
|
+
"executableTarget",
|
|
6677
|
+
"target"
|
|
6678
|
+
])) {
|
|
6679
|
+
const executable = kind === "executableTarget";
|
|
6546
6680
|
const name2 = /\bname\s*:\s*"([^"]+)"/.exec(flat)?.[1];
|
|
6547
6681
|
if (!name2) continue;
|
|
6548
6682
|
const rawPath = /\bpath\s*:\s*"([^"]*)"/.exec(flat)?.[1];
|
|
6549
6683
|
const targetPath = rawPath == null || rawPath === "" ? `Sources/${name2}` : rawPath.replace(/^\.\//, "").replace(/\/+$/, "");
|
|
6550
|
-
const call = code.slice(start, i);
|
|
6551
6684
|
const languageMode = Number(
|
|
6552
6685
|
/\.swiftLanguageMode\(\s*\.v(\d+)\s*\)/.exec(call)?.[1] ?? "5"
|
|
6553
6686
|
);
|
|
6554
6687
|
const mainActorIsolation = /\.defaultIsolation\(\s*MainActor\.self\s*\)/.test(call);
|
|
6555
6688
|
const excluded = [
|
|
6556
6689
|
...(/\bexclude\s*:\s*\[([^\]]*)\]/.exec(flat)?.[1] ?? "").matchAll(/"([^"]+)"/g)
|
|
6557
|
-
].map((
|
|
6690
|
+
].map((match) => match[1].replace(/^\.\//, "").replace(/\/+$/, ""));
|
|
6558
6691
|
const prefix = targetPath === "." ? "" : `${targetPath}/`;
|
|
6559
6692
|
const resources = /\bresources\s*:/.test(flat) || implicitResources.some((file) => {
|
|
6560
6693
|
if (!file.startsWith(prefix)) return false;
|
|
@@ -6609,14 +6742,14 @@ function swiftModuleInputFiles(root) {
|
|
|
6609
6742
|
"scripts/contrast-app-Package.swift",
|
|
6610
6743
|
"toolchain.json"
|
|
6611
6744
|
];
|
|
6612
|
-
const
|
|
6745
|
+
const walk2 = (dir) => {
|
|
6613
6746
|
for (const entry of (0, import_node_fs7.readdirSync)(import_node_path7.default.join(root, dir), { withFileTypes: true })) {
|
|
6614
6747
|
const relative2 = `${dir}/${entry.name}`;
|
|
6615
|
-
if (entry.isDirectory())
|
|
6748
|
+
if (entry.isDirectory()) walk2(relative2);
|
|
6616
6749
|
else if (/\.(swift|c|cpp|h)$/.test(entry.name)) files.push(relative2);
|
|
6617
6750
|
}
|
|
6618
6751
|
};
|
|
6619
|
-
|
|
6752
|
+
walk2("Sources");
|
|
6620
6753
|
return files.sort();
|
|
6621
6754
|
}
|
|
6622
6755
|
async function ensureMacroPlugins(moduleRoot, toolchainBin) {
|
|
@@ -6698,6 +6831,9 @@ var OPTIONAL_FRAMEWORK_DEPENDENCIES = {
|
|
|
6698
6831
|
CryptoKit: [],
|
|
6699
6832
|
CommonCrypto: [],
|
|
6700
6833
|
CoreText: [],
|
|
6834
|
+
Compression: ["PeachCodec"],
|
|
6835
|
+
zlib: ["PeachCodec"],
|
|
6836
|
+
PeachCodec: [],
|
|
6701
6837
|
Security: ["CryptoKit"],
|
|
6702
6838
|
TikTokBusinessSDK: [],
|
|
6703
6839
|
nSure: [],
|
|
@@ -6708,6 +6844,66 @@ var OPTIONAL_FRAMEWORK_DEPENDENCIES = {
|
|
|
6708
6844
|
DatadogTrace: ["DatadogCore"]
|
|
6709
6845
|
};
|
|
6710
6846
|
var OPTIONAL_FRAMEWORKS = new Set(Object.keys(OPTIONAL_FRAMEWORK_DEPENDENCIES));
|
|
6847
|
+
var SWIFT_IMPORT = /^\s*(?:@\w+(?:\([^)]*\))?\s+)*import\s+(?:(?:typealias|struct|class|enum|protocol|let|var|func)\s+)?([A-Za-z_][A-Za-z0-9_]*)/;
|
|
6848
|
+
function swiftImportNames(contents, unconditional = false) {
|
|
6849
|
+
const names = [];
|
|
6850
|
+
let depth = 0;
|
|
6851
|
+
for (const line of contents.split("\n")) {
|
|
6852
|
+
const directive = /^\s*#(if|endif)\b/.exec(line)?.[1];
|
|
6853
|
+
if (directive === "if") depth++;
|
|
6854
|
+
else if (directive === "endif") depth = Math.max(0, depth - 1);
|
|
6855
|
+
if (unconditional && depth > 0) continue;
|
|
6856
|
+
const name2 = SWIFT_IMPORT.exec(line)?.[1];
|
|
6857
|
+
if (name2) names.push(name2);
|
|
6858
|
+
}
|
|
6859
|
+
return names;
|
|
6860
|
+
}
|
|
6861
|
+
function swiftPeachModules(moduleRoot) {
|
|
6862
|
+
const distribution = swiftDistributionAt(moduleRoot);
|
|
6863
|
+
return distribution ? distribution.modules : [
|
|
6864
|
+
...(0, import_node_fs7.readFileSync)(import_node_path7.default.join(moduleRoot, "Package.swift"), "utf8").matchAll(
|
|
6865
|
+
/\.(?:target|systemLibrary)\(\s*name:\s*"([^"]+)"/g
|
|
6866
|
+
)
|
|
6867
|
+
].map((match) => match[1]);
|
|
6868
|
+
}
|
|
6869
|
+
var availableModules = /* @__PURE__ */ new Map();
|
|
6870
|
+
function swiftAvailableModules(moduleRoot, toolchainBin) {
|
|
6871
|
+
const sdk = swiftModuleSdk(moduleRoot).wasmSdkId;
|
|
6872
|
+
const key = `${moduleRoot}\0${sdk}`;
|
|
6873
|
+
const cached3 = availableModules.get(key);
|
|
6874
|
+
if (cached3) return cached3;
|
|
6875
|
+
const modules = new Set(swiftPeachModules(moduleRoot));
|
|
6876
|
+
const configuration = (0, import_node_child_process3.execFileSync)(
|
|
6877
|
+
import_node_path7.default.join(toolchainBin, "swift"),
|
|
6878
|
+
["sdk", "configure", "--show-configuration", sdk, "wasm32-unknown-wasip1"],
|
|
6879
|
+
{ encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }
|
|
6880
|
+
);
|
|
6881
|
+
const resources = /^swiftResourcesPath:\s*(.+)$/m.exec(configuration)?.[1]?.trim();
|
|
6882
|
+
if (!resources) throw new Error(`swift sdk ${sdk} reports no swiftResourcesPath`);
|
|
6883
|
+
for (const entry of (0, import_node_fs7.readdirSync)(import_node_path7.default.join(resources, "wasi"))) {
|
|
6884
|
+
if (entry.endsWith(".swiftmodule"))
|
|
6885
|
+
modules.add(entry.slice(0, -".swiftmodule".length));
|
|
6886
|
+
}
|
|
6887
|
+
for (const entry of (0, import_node_fs7.readdirSync)(resources)) {
|
|
6888
|
+
const map = import_node_path7.default.join(resources, entry, "module.modulemap");
|
|
6889
|
+
if (!(0, import_node_fs7.existsSync)(map)) continue;
|
|
6890
|
+
for (const match of (0, import_node_fs7.readFileSync)(map, "utf8").matchAll(/^module\s+([A-Za-z_]\w*)/gm))
|
|
6891
|
+
modules.add(match[1]);
|
|
6892
|
+
}
|
|
6893
|
+
availableModules.set(key, modules);
|
|
6894
|
+
return modules;
|
|
6895
|
+
}
|
|
6896
|
+
function missingSwiftModules(files, available) {
|
|
6897
|
+
const missing = /* @__PURE__ */ new Map();
|
|
6898
|
+
for (const [file, contents] of Object.entries(files)) {
|
|
6899
|
+
if (!file.endsWith(".swift") || file === "Package.swift") continue;
|
|
6900
|
+
for (const name2 of new Set(swiftImportNames(contents, true))) {
|
|
6901
|
+
if (available.has(name2)) continue;
|
|
6902
|
+
missing.set(name2, [...missing.get(name2) ?? [], file]);
|
|
6903
|
+
}
|
|
6904
|
+
}
|
|
6905
|
+
return new Map([...missing].sort(([left], [right]) => left.localeCompare(right)));
|
|
6906
|
+
}
|
|
6711
6907
|
function swiftTargetDependencies(files, targets) {
|
|
6712
6908
|
const names = /* @__PURE__ */ new Set([...OPTIONAL_FRAMEWORKS, ...targets.map((target) => target.name)]);
|
|
6713
6909
|
const siblings = /* @__PURE__ */ new Map();
|
|
@@ -6720,10 +6916,8 @@ function swiftTargetDependencies(files, targets) {
|
|
|
6720
6916
|
(candidate) => candidate.name !== target.name && candidate.path !== "." && candidate.path.startsWith(prefix) && file.startsWith(`${candidate.path}/`)
|
|
6721
6917
|
))
|
|
6722
6918
|
continue;
|
|
6723
|
-
for (const
|
|
6724
|
-
|
|
6725
|
-
)) {
|
|
6726
|
-
if (names.has(match[1]) && match[1] !== target.name) deps.add(match[1]);
|
|
6919
|
+
for (const name2 of swiftImportNames(contents)) {
|
|
6920
|
+
if (names.has(name2) && name2 !== target.name) deps.add(name2);
|
|
6727
6921
|
}
|
|
6728
6922
|
}
|
|
6729
6923
|
siblings.set(target.name, [...deps].sort());
|
|
@@ -6733,16 +6927,14 @@ function swiftTargetDependencies(files, targets) {
|
|
|
6733
6927
|
var ONE_PRODUCT = '.product(name: "One", package: "sootsim-swift")';
|
|
6734
6928
|
var SPRITEKIT_PRODUCT = '.product(name: "SpriteKit", package: "sootsim-swift")';
|
|
6735
6929
|
var importsSpriteKit = (files) => Object.entries(files).some(
|
|
6736
|
-
([file, contents]) => file.endsWith(".swift") &&
|
|
6737
|
-
contents
|
|
6738
|
-
)
|
|
6930
|
+
([file, contents]) => file.endsWith(".swift") && swiftImportNames(contents).includes("SpriteKit")
|
|
6739
6931
|
);
|
|
6740
|
-
var FOUNDATION_IMPLICIT_FLAGS = ', "-Xfrontend", "-import-module", "-Xfrontend", "PeachObjC", "-Xfrontend", "-import-module", "-Xfrontend", "Dispatch", "-Xfrontend", "-import-module", "-Xfrontend", "FoundationNetworking"';
|
|
6932
|
+
var FOUNDATION_IMPLICIT_FLAGS = ', "-Xfrontend", "-import-module", "-Xfrontend", "PeachObjC", "-Xfrontend", "-import-module", "-Xfrontend", "Dispatch", "-Xfrontend", "-import-module", "-Xfrontend", "FoundationNetworking", "-Xfrontend", "-import-module", "-Xfrontend", "WASILibc", "-Xfrontend", "-import-module", "-Xfrontend", "wasi_pthread"';
|
|
6741
6933
|
var ONE_IMPLICIT_FLAGS = ', "-Xfrontend", "-import-module", "-Xfrontend", "One"';
|
|
6742
|
-
var MULTI_MANIFEST_VERSION =
|
|
6934
|
+
var MULTI_MANIFEST_VERSION = 11;
|
|
6743
6935
|
function swiftArtifactHash(input, release, moduleRoot) {
|
|
6744
6936
|
const hash = (0, import_node_crypto3.createHash)("sha256");
|
|
6745
|
-
hash.update(`swift-compile/
|
|
6937
|
+
hash.update(`swift-compile/v16
|
|
6746
6938
|
${release}
|
|
6747
6939
|
`);
|
|
6748
6940
|
if (input.oneModule) hash.update("one-module\n");
|
|
@@ -6851,15 +7043,15 @@ function emitSwiftPackageManifest(args) {
|
|
|
6851
7043
|
}
|
|
6852
7044
|
function syncSwiftTree(base, files) {
|
|
6853
7045
|
(0, import_node_fs7.mkdirSync)(base, { recursive: true });
|
|
6854
|
-
const
|
|
7046
|
+
const walk2 = (dir) => {
|
|
6855
7047
|
for (const entry of (0, import_node_fs7.readdirSync)(dir, { withFileTypes: true })) {
|
|
6856
7048
|
const full = import_node_path7.default.join(dir, entry.name);
|
|
6857
7049
|
if (dir === base && entry.name === ".build") continue;
|
|
6858
|
-
if (entry.isDirectory())
|
|
7050
|
+
if (entry.isDirectory()) walk2(full);
|
|
6859
7051
|
else if (!files.has(full)) (0, import_node_fs7.rmSync)(full, { force: true });
|
|
6860
7052
|
}
|
|
6861
7053
|
};
|
|
6862
|
-
|
|
7054
|
+
walk2(base);
|
|
6863
7055
|
for (const [full, contents] of files) {
|
|
6864
7056
|
if ((0, import_node_fs7.existsSync)(full) && (0, import_node_fs7.readFileSync)(full, "utf8") === contents) continue;
|
|
6865
7057
|
(0, import_node_fs7.mkdirSync)(import_node_path7.default.dirname(full), { recursive: true });
|
|
@@ -6914,23 +7106,98 @@ function forwardedArguments(parameters) {
|
|
|
6914
7106
|
}
|
|
6915
7107
|
return args.join(", ");
|
|
6916
7108
|
}
|
|
6917
|
-
function
|
|
7109
|
+
function closingBrace(source, tokens, open) {
|
|
7110
|
+
let depth = 0;
|
|
7111
|
+
for (const at of tokens) {
|
|
7112
|
+
if (at < open) continue;
|
|
7113
|
+
if (source[at] === "{") depth++;
|
|
7114
|
+
else if (source[at] === "}" && --depth === 0) return at + 1;
|
|
7115
|
+
}
|
|
7116
|
+
return source.length;
|
|
7117
|
+
}
|
|
7118
|
+
function scanObjCExtensionMembers(source, tokens, records) {
|
|
7119
|
+
const masked = swiftCodeMask(source);
|
|
7120
|
+
const found = /* @__PURE__ */ new Map();
|
|
7121
|
+
const member = /\b(func|var)\s+([A-Za-z_]\w*)/g;
|
|
7122
|
+
for (const record of records) {
|
|
7123
|
+
const close = closingBrace(source, tokens, record.open);
|
|
7124
|
+
const body = masked.slice(record.open, close);
|
|
7125
|
+
member.lastIndex = 0;
|
|
7126
|
+
for (let match = member.exec(body); match; match = member.exec(body)) {
|
|
7127
|
+
const at = record.open + match.index + match[0].indexOf(match[1]);
|
|
7128
|
+
let depth = 0;
|
|
7129
|
+
for (const token of tokens) {
|
|
7130
|
+
if (token <= record.open) continue;
|
|
7131
|
+
if (token >= at) break;
|
|
7132
|
+
if (source[token] === "{") depth++;
|
|
7133
|
+
else if (source[token] === "}") depth--;
|
|
7134
|
+
}
|
|
7135
|
+
if (depth > 0) continue;
|
|
7136
|
+
const head = masked.slice(record.open, at);
|
|
7137
|
+
const bound = Math.max(
|
|
7138
|
+
head.lastIndexOf(";"),
|
|
7139
|
+
head.lastIndexOf("{"),
|
|
7140
|
+
head.lastIndexOf("}")
|
|
7141
|
+
);
|
|
7142
|
+
const prefix = head.slice(bound + 1);
|
|
7143
|
+
if (/(?:^|[^A-Za-z0-9_$])(?:private|fileprivate|static|class)(?:[^A-Za-z0-9_$]|$)/.test(
|
|
7144
|
+
prefix
|
|
7145
|
+
))
|
|
7146
|
+
continue;
|
|
7147
|
+
if (!/@objc\b/.test(prefix) && !/@IBAction\b/.test(prefix) && !record.objcMembers)
|
|
7148
|
+
continue;
|
|
7149
|
+
const members = found.get(record.type) ?? /* @__PURE__ */ new Set();
|
|
7150
|
+
members.add(match[2]);
|
|
7151
|
+
found.set(record.type, members);
|
|
7152
|
+
}
|
|
7153
|
+
}
|
|
7154
|
+
return found;
|
|
7155
|
+
}
|
|
7156
|
+
function objcExtensionMemberIndex(sources) {
|
|
7157
|
+
const index = /* @__PURE__ */ new Map();
|
|
7158
|
+
for (const source of sources) {
|
|
7159
|
+
const { tokens } = swiftCodeScan(source);
|
|
7160
|
+
const masked = swiftCodeMask(source);
|
|
7161
|
+
const records = [];
|
|
7162
|
+
let pending = null;
|
|
7163
|
+
for (const at of tokens) {
|
|
7164
|
+
const rest = source.slice(at, at + 600);
|
|
7165
|
+
if (rest.startsWith("{")) {
|
|
7166
|
+
if (pending) records.push({ ...pending, open: at });
|
|
7167
|
+
pending = null;
|
|
7168
|
+
continue;
|
|
7169
|
+
}
|
|
7170
|
+
if (rest.startsWith("}")) continue;
|
|
7171
|
+
const extended = EXTENSION_DECL.exec(rest);
|
|
7172
|
+
if (extended) {
|
|
7173
|
+
const lines = source.lastIndexOf("\n", source.lastIndexOf("\n", at - 1) - 1) + 1;
|
|
7174
|
+
pending = {
|
|
7175
|
+
type: extended[1].split(".").pop(),
|
|
7176
|
+
objcMembers: /@objcMembers\b/.test(masked.slice(lines, at))
|
|
7177
|
+
};
|
|
7178
|
+
}
|
|
7179
|
+
}
|
|
7180
|
+
for (const [type, members] of scanObjCExtensionMembers(source, tokens, records)) {
|
|
7181
|
+
const into = index.get(type) ?? /* @__PURE__ */ new Set();
|
|
7182
|
+
for (const member of members) into.add(member);
|
|
7183
|
+
index.set(type, into);
|
|
7184
|
+
}
|
|
7185
|
+
}
|
|
7186
|
+
return index;
|
|
7187
|
+
}
|
|
7188
|
+
function liftExtensionOverrides(source, extraObjCExtensions) {
|
|
6918
7189
|
const { tokens } = swiftCodeScan(source);
|
|
7190
|
+
const masked = swiftCodeMask(source);
|
|
6919
7191
|
const stack = [];
|
|
6920
7192
|
let pending = null;
|
|
6921
7193
|
const classes = /* @__PURE__ */ new Map();
|
|
6922
7194
|
let declaredBase = null;
|
|
6923
7195
|
let declaredObjCMembers = false;
|
|
7196
|
+
const extensions = [];
|
|
7197
|
+
let declaredExtObjCMembers = false;
|
|
6924
7198
|
const lifted = [];
|
|
6925
|
-
const
|
|
6926
|
-
|
|
6927
|
-
for (const at of tokens) {
|
|
6928
|
-
if (at < open) continue;
|
|
6929
|
-
if (source[at] === "{") depth++;
|
|
6930
|
-
else if (source[at] === "}" && --depth === 0) return at + 1;
|
|
6931
|
-
}
|
|
6932
|
-
return source.length;
|
|
6933
|
-
};
|
|
7199
|
+
const overrides = [];
|
|
7200
|
+
const closing = (open) => closingBrace(source, tokens, open);
|
|
6934
7201
|
for (const at of tokens) {
|
|
6935
7202
|
const rest = source.slice(at, at + 600);
|
|
6936
7203
|
if (rest.startsWith("{")) {
|
|
@@ -6941,6 +7208,12 @@ function liftExtensionOverrides(source) {
|
|
|
6941
7208
|
base: declaredBase,
|
|
6942
7209
|
objcMembers: declaredObjCMembers
|
|
6943
7210
|
});
|
|
7211
|
+
if (frame.kind === "extension")
|
|
7212
|
+
extensions.push({
|
|
7213
|
+
type: frame.name,
|
|
7214
|
+
open: at,
|
|
7215
|
+
objcMembers: declaredExtObjCMembers
|
|
7216
|
+
});
|
|
6944
7217
|
stack.push(frame);
|
|
6945
7218
|
pending = null;
|
|
6946
7219
|
continue;
|
|
@@ -6960,12 +7233,39 @@ function liftExtensionOverrides(source) {
|
|
|
6960
7233
|
const extended = EXTENSION_DECL.exec(rest);
|
|
6961
7234
|
if (extended) {
|
|
6962
7235
|
pending = { kind: "extension", name: extended[1].split(".").pop() };
|
|
7236
|
+
const lines = source.lastIndexOf("\n", source.lastIndexOf("\n", at - 1) - 1) + 1;
|
|
7237
|
+
declaredExtObjCMembers = /@objcMembers\b/.test(masked.slice(lines, at));
|
|
6963
7238
|
continue;
|
|
6964
7239
|
}
|
|
6965
7240
|
const top = stack.at(-1);
|
|
6966
|
-
if (!rest.startsWith("override") ||
|
|
7241
|
+
if (!rest.startsWith("override") || pending) continue;
|
|
6967
7242
|
const line = source.slice(source.lastIndexOf("\n", at - 1) + 1, at);
|
|
6968
7243
|
const modifiers = (` ${line} `.match(MODIFIERS) ?? []).map((word) => word.trim());
|
|
7244
|
+
if (top?.kind === "class") {
|
|
7245
|
+
let member;
|
|
7246
|
+
let nameAt = 0;
|
|
7247
|
+
const direct = OVERRIDE_FUNC.exec(rest);
|
|
7248
|
+
if (direct) {
|
|
7249
|
+
member = direct[2];
|
|
7250
|
+
nameAt = at + rest.indexOf(
|
|
7251
|
+
member,
|
|
7252
|
+
rest.indexOf("func", "override".length + direct[1].length) + 4
|
|
7253
|
+
);
|
|
7254
|
+
} else {
|
|
7255
|
+
const property2 = OVERRIDE_VAR.exec(rest);
|
|
7256
|
+
if (property2) {
|
|
7257
|
+
const open = at + property2[0].length - 1;
|
|
7258
|
+
if (!/\b(?:set|willSet|didSet)\b/.test(source.slice(open, closing(open)))) {
|
|
7259
|
+
member = property2[2];
|
|
7260
|
+
nameAt = at + rest.indexOf(member, rest.indexOf("var"));
|
|
7261
|
+
}
|
|
7262
|
+
}
|
|
7263
|
+
}
|
|
7264
|
+
if (member !== void 0 && !modifiers.includes("private") && !modifiers.includes("fileprivate"))
|
|
7265
|
+
overrides.push({ type: top.name, member, at, nameAt });
|
|
7266
|
+
continue;
|
|
7267
|
+
}
|
|
7268
|
+
if (top?.kind !== "extension") continue;
|
|
6969
7269
|
const func = OVERRIDE_FUNC.exec(rest);
|
|
6970
7270
|
if (func) {
|
|
6971
7271
|
const name2 = func[2];
|
|
@@ -6983,20 +7283,18 @@ function liftExtensionOverrides(source) {
|
|
|
6983
7283
|
if (args === null) continue;
|
|
6984
7284
|
const call = (clause.includes("->") ? "return " : "") + (/\b(?:throws|rethrows)\b/.test(clause) ? "try " : "") + (/\basync\b/.test(clause) ? "await " : "") + `__peach_ext_${name2}(${args})`;
|
|
6985
7285
|
const signature = `func ${name2}${func[3] ?? ""}${source.slice(open, close + 1)}${clause ? ` ${clause}` : ""}`;
|
|
7286
|
+
const nameAt = at + rest.indexOf(name2, rest.indexOf("func", "override".length + func[1].length) + 4);
|
|
6986
7287
|
lifted.push({
|
|
6987
7288
|
type: top.name,
|
|
6988
7289
|
member: name2,
|
|
6989
|
-
|
|
7290
|
+
at,
|
|
7291
|
+
modifiers,
|
|
7292
|
+
decl: signature,
|
|
7293
|
+
forward: `{ ${call} };`,
|
|
7294
|
+
nameAt,
|
|
6990
7295
|
edits: [
|
|
6991
7296
|
[at, "override".length, " ".repeat("override".length)],
|
|
6992
|
-
[
|
|
6993
|
-
at + rest.indexOf(
|
|
6994
|
-
name2,
|
|
6995
|
-
rest.indexOf("func", "override".length + func[1].length) + 4
|
|
6996
|
-
),
|
|
6997
|
-
0,
|
|
6998
|
-
"__peach_ext_"
|
|
6999
|
-
]
|
|
7297
|
+
[nameAt, 0, "__peach_ext_"]
|
|
7000
7298
|
]
|
|
7001
7299
|
});
|
|
7002
7300
|
continue;
|
|
@@ -7006,42 +7304,79 @@ function liftExtensionOverrides(source) {
|
|
|
7006
7304
|
const open = at + property[0].length - 1;
|
|
7007
7305
|
if (/\b(?:set|willSet|didSet)\b/.test(source.slice(open, closing(open)))) continue;
|
|
7008
7306
|
const name2 = property[2];
|
|
7307
|
+
const nameAt = at + rest.indexOf(name2, rest.indexOf("var"));
|
|
7009
7308
|
lifted.push({
|
|
7010
7309
|
type: top.name,
|
|
7011
7310
|
member: name2,
|
|
7012
|
-
|
|
7311
|
+
at,
|
|
7312
|
+
modifiers,
|
|
7313
|
+
decl: `var ${name2}: ${property[3].trim()}`,
|
|
7314
|
+
forward: `{ __peach_ext_${name2} };`,
|
|
7315
|
+
nameAt,
|
|
7013
7316
|
edits: [
|
|
7014
7317
|
[at, "override".length, " ".repeat("override".length)],
|
|
7015
|
-
[
|
|
7318
|
+
[nameAt, 0, "__peach_ext_"]
|
|
7016
7319
|
]
|
|
7017
7320
|
});
|
|
7018
7321
|
}
|
|
7019
7322
|
}
|
|
7020
|
-
const
|
|
7323
|
+
const extIndex = /* @__PURE__ */ new Map();
|
|
7324
|
+
if (extraObjCExtensions)
|
|
7325
|
+
for (const [type, members] of extraObjCExtensions)
|
|
7326
|
+
extIndex.set(type, new Set(members));
|
|
7327
|
+
for (const [type, members] of scanObjCExtensionMembers(source, tokens, extensions)) {
|
|
7328
|
+
const into = extIndex.get(type) ?? /* @__PURE__ */ new Set();
|
|
7329
|
+
for (const member of members) into.add(member);
|
|
7330
|
+
extIndex.set(type, into);
|
|
7331
|
+
}
|
|
7332
|
+
const overrideKind = (type, member) => {
|
|
7021
7333
|
let base = classes.get(type)?.base ?? null;
|
|
7022
7334
|
while (base !== null) {
|
|
7023
|
-
if (APPLE_CLASS.test(base)) return true;
|
|
7024
7335
|
const declaredClass = classes.get(base);
|
|
7025
|
-
if (
|
|
7026
|
-
|
|
7027
|
-
|
|
7028
|
-
|
|
7029
|
-
|
|
7030
|
-
|
|
7031
|
-
|
|
7032
|
-
|
|
7336
|
+
if (declaredClass) {
|
|
7337
|
+
const body = source.slice(declaredClass.brace, closing(declaredClass.brace));
|
|
7338
|
+
const found = new RegExp(`\\b(?:func|var)\\s+${member}\\b`).exec(body);
|
|
7339
|
+
if (found) {
|
|
7340
|
+
const line = body.slice(body.lastIndexOf("\n", found.index) + 1, found.index);
|
|
7341
|
+
return declaredClass.objcMembers || /@objc\b/.test(line) ? "objc" : "plain";
|
|
7342
|
+
}
|
|
7343
|
+
if (extIndex.get(base)?.has(member)) return "ext";
|
|
7344
|
+
base = declaredClass.base;
|
|
7345
|
+
} else if (extIndex.get(base)?.has(member)) return "ext";
|
|
7346
|
+
else if (APPLE_CLASS.test(base)) return "apple";
|
|
7347
|
+
else return "unknown";
|
|
7033
7348
|
}
|
|
7034
|
-
return
|
|
7349
|
+
return "unknown";
|
|
7035
7350
|
};
|
|
7351
|
+
const rename = (at, nameAt) => [
|
|
7352
|
+
[at, "override".length, " ".repeat("override".length)],
|
|
7353
|
+
[nameAt, 0, "__peach_ovr_"]
|
|
7354
|
+
];
|
|
7036
7355
|
const edits = [];
|
|
7037
7356
|
const stubs = /* @__PURE__ */ new Map();
|
|
7038
7357
|
for (const entry of lifted) {
|
|
7039
7358
|
const brace = classes.get(entry.type)?.brace;
|
|
7040
|
-
if (brace === void 0
|
|
7359
|
+
if (brace === void 0) continue;
|
|
7360
|
+
const kind = overrideKind(entry.type, entry.member);
|
|
7361
|
+
if (kind !== "apple" && kind !== "objc" && kind !== "ext") continue;
|
|
7362
|
+
if (kind === "ext" && (entry.modifiers.includes("private") || entry.modifiers.includes("fileprivate")))
|
|
7363
|
+
continue;
|
|
7364
|
+
if (kind === "ext") {
|
|
7365
|
+
edits.push(...rename(entry.at, entry.nameAt));
|
|
7366
|
+
continue;
|
|
7367
|
+
}
|
|
7041
7368
|
edits.push(...entry.edits);
|
|
7042
|
-
|
|
7369
|
+
const head = [...entry.modifiers, "override"].filter((word) => word !== "").join(" ");
|
|
7370
|
+
stubs.set(brace, [
|
|
7371
|
+
...stubs.get(brace) ?? [],
|
|
7372
|
+
`${head} ${entry.decl} ${entry.forward}`
|
|
7373
|
+
]);
|
|
7374
|
+
}
|
|
7375
|
+
for (const candidate of overrides) {
|
|
7376
|
+
if (overrideKind(candidate.type, candidate.member) !== "ext") continue;
|
|
7377
|
+
edits.push(...rename(candidate.at, candidate.nameAt));
|
|
7043
7378
|
}
|
|
7044
|
-
for (const [brace,
|
|
7379
|
+
for (const [brace, list2] of stubs) edits.push([brace + 1, 0, ` ${list2.join(" ")}`]);
|
|
7045
7380
|
let out = source;
|
|
7046
7381
|
for (const [at, remove, insert] of edits.sort((a, b) => b[0] - a[0]))
|
|
7047
7382
|
out = out.slice(0, at) + insert + out.slice(at + remove);
|
|
@@ -7221,8 +7556,8 @@ function swiftCodeMask(source) {
|
|
|
7221
7556
|
scanCode(0, false);
|
|
7222
7557
|
return chars.join("");
|
|
7223
7558
|
}
|
|
7224
|
-
function swiftSourceAsIOS(original) {
|
|
7225
|
-
const source = liftExtensionOverrides(original);
|
|
7559
|
+
function swiftSourceAsIOS(original, extraObjCExtensions) {
|
|
7560
|
+
const source = liftExtensionOverrides(original, extraObjCExtensions);
|
|
7226
7561
|
const { lineStarts, tokens } = swiftCodeScan(source);
|
|
7227
7562
|
let offset = 0;
|
|
7228
7563
|
const conditioned = source.split("\n").map((line) => {
|
|
@@ -7391,7 +7726,7 @@ function swiftCodeScan(source) {
|
|
|
7391
7726
|
}
|
|
7392
7727
|
return { lineStarts: starts, tokens };
|
|
7393
7728
|
}
|
|
7394
|
-
var compiledSource = (file, contents) => file.endsWith(".swift") ? swiftSourceAsIOS(contents) : contents;
|
|
7729
|
+
var compiledSource = (file, contents, extraObjCExtensions) => file.endsWith(".swift") ? swiftSourceAsIOS(contents, extraObjCExtensions) : contents;
|
|
7395
7730
|
function writeSwiftProject(layout, input, moduleRoot) {
|
|
7396
7731
|
const resourceTargets = swiftManifestTargets(
|
|
7397
7732
|
input.files["Package.swift"] ?? "",
|
|
@@ -7424,10 +7759,16 @@ function writeSwiftProject(layout, input, moduleRoot) {
|
|
|
7424
7759
|
// sootsim-swift files ${modulePlan.digest("hex").slice(0, 16)}
|
|
7425
7760
|
// resource accessors ${resourcePlan}
|
|
7426
7761
|
`;
|
|
7762
|
+
const objcExtensions = objcExtensionMemberIndex(
|
|
7763
|
+
Object.entries(input.files).filter(([file]) => file.endsWith(".swift")).map(([, contents]) => contents)
|
|
7764
|
+
);
|
|
7427
7765
|
if (targets.length === 0) {
|
|
7428
7766
|
for (const [file, contents] of Object.entries(input.files)) {
|
|
7429
7767
|
if (file === "Package.swift") continue;
|
|
7430
|
-
files.set(
|
|
7768
|
+
files.set(
|
|
7769
|
+
import_node_path7.default.join(layout.sources, file),
|
|
7770
|
+
compiledSource(file, contents, objcExtensions)
|
|
7771
|
+
);
|
|
7431
7772
|
}
|
|
7432
7773
|
let manifest = (0, import_node_fs7.readFileSync)(
|
|
7433
7774
|
import_node_path7.default.join(moduleRoot, "scripts/contrast-app-Package.swift"),
|
|
@@ -7473,7 +7814,7 @@ function writeSwiftProject(layout, input, moduleRoot) {
|
|
|
7473
7814
|
const base = layout.multi ? layout.root : layout.sources;
|
|
7474
7815
|
for (const [file, contents] of Object.entries(input.files)) {
|
|
7475
7816
|
if (file === "Package.swift") continue;
|
|
7476
|
-
files.set(import_node_path7.default.join(base, file), compiledSource(file, contents));
|
|
7817
|
+
files.set(import_node_path7.default.join(base, file), compiledSource(file, contents, objcExtensions));
|
|
7477
7818
|
}
|
|
7478
7819
|
files.set(
|
|
7479
7820
|
import_node_path7.default.join(layout.root, "Package.swift"),
|
|
@@ -7668,10 +8009,10 @@ var DEFAULT_LOCAL_RUNTIME_RETENTION_COUNT = 2;
|
|
|
7668
8009
|
function createRuntimeDelivery(product) {
|
|
7669
8010
|
function readConfig() {
|
|
7670
8011
|
try {
|
|
7671
|
-
const
|
|
8012
|
+
const parsed2 = JSON.parse(
|
|
7672
8013
|
import_node_fs9.default.readFileSync(product.configFile(), "utf8")
|
|
7673
8014
|
);
|
|
7674
|
-
return
|
|
8015
|
+
return parsed2 && typeof parsed2 === "object" ? parsed2 : {};
|
|
7675
8016
|
} catch {
|
|
7676
8017
|
return {};
|
|
7677
8018
|
}
|
|
@@ -7683,7 +8024,7 @@ function createRuntimeDelivery(product) {
|
|
|
7683
8024
|
}
|
|
7684
8025
|
function resolveChannel(input) {
|
|
7685
8026
|
const config = readConfig();
|
|
7686
|
-
return input || process.env[product.env.channel] || config.runtimeChannel || "stable";
|
|
8027
|
+
return input || process.env[product.env.channel] || config.runtimeChannel || product.defaultChannel || "stable";
|
|
7687
8028
|
}
|
|
7688
8029
|
function resolvePin() {
|
|
7689
8030
|
if (!product.env.pin) return null;
|
|
@@ -7957,7 +8298,7 @@ function createRuntimeDelivery(product) {
|
|
|
7957
8298
|
async function installVerifiedTarball(tarball) {
|
|
7958
8299
|
const { url, digest, destDir, installedMarker, label } = tarball;
|
|
7959
8300
|
const downloadDir = import_node_fs9.default.mkdtempSync(import_node_path9.default.join(import_node_os3.default.tmpdir(), "runtime-delivery-download-"));
|
|
7960
|
-
const archivePath = import_node_path9.default.join(downloadDir, "archive
|
|
8301
|
+
const archivePath = import_node_path9.default.join(downloadDir, "archive");
|
|
7961
8302
|
import_node_fs9.default.mkdirSync(import_node_path9.default.dirname(destDir), { recursive: true });
|
|
7962
8303
|
const tmpDir = import_node_fs9.default.mkdtempSync(
|
|
7963
8304
|
import_node_path9.default.join(import_node_path9.default.dirname(destDir), `.installing-${import_node_path9.default.basename(destDir)}-`)
|
|
@@ -7970,7 +8311,8 @@ async function installVerifiedTarball(tarball) {
|
|
|
7970
8311
|
`${digest.algorithm} mismatch for ${label}: expected ${digest.value}, actual ${actual}`
|
|
7971
8312
|
);
|
|
7972
8313
|
}
|
|
7973
|
-
await
|
|
8314
|
+
if (new URL(url).pathname.endsWith(".zip")) await extractZip(archivePath, tmpDir);
|
|
8315
|
+
else await extractTarball(archivePath, tmpDir, tarball.stripComponents ?? 0);
|
|
7974
8316
|
if (!import_node_fs9.default.existsSync(import_node_path9.default.join(tmpDir, installedMarker))) {
|
|
7975
8317
|
throw new Error(`extracted tarball for ${label} is missing ${installedMarker}`);
|
|
7976
8318
|
}
|
|
@@ -8032,17 +8374,23 @@ function digestFile(filePath, algorithm, encoding) {
|
|
|
8032
8374
|
stream.on("end", () => resolve5(hash.digest(encoding)));
|
|
8033
8375
|
});
|
|
8034
8376
|
}
|
|
8377
|
+
function extractZip(zipPath, destDir) {
|
|
8378
|
+
return runExtractor("ditto", ["-x", "-k", zipPath, destDir]);
|
|
8379
|
+
}
|
|
8035
8380
|
function extractTarball(tarPath, destDir, stripComponents) {
|
|
8381
|
+
const args = ["-xzf", tarPath, "-C", destDir];
|
|
8382
|
+
if (stripComponents > 0) args.push(`--strip-components=${stripComponents}`);
|
|
8383
|
+
return runExtractor("tar", args);
|
|
8384
|
+
}
|
|
8385
|
+
function runExtractor(command, args) {
|
|
8036
8386
|
return new Promise((resolve5, reject) => {
|
|
8037
|
-
const
|
|
8038
|
-
if (stripComponents > 0) args.push(`--strip-components=${stripComponents}`);
|
|
8039
|
-
const child = (0, import_node_child_process4.spawn)("tar", args, {
|
|
8387
|
+
const child = (0, import_node_child_process4.spawn)(command, args, {
|
|
8040
8388
|
stdio: ["ignore", "inherit", "inherit"]
|
|
8041
8389
|
});
|
|
8042
8390
|
child.on("error", reject);
|
|
8043
8391
|
child.on("exit", (code) => {
|
|
8044
8392
|
if (code === 0) resolve5();
|
|
8045
|
-
else reject(new Error(
|
|
8393
|
+
else reject(new Error(`${command} exited with code ${code}`));
|
|
8046
8394
|
});
|
|
8047
8395
|
});
|
|
8048
8396
|
}
|
|
@@ -8052,24 +8400,24 @@ init_home_paths();
|
|
|
8052
8400
|
|
|
8053
8401
|
// src/swift-distribution.lock.json
|
|
8054
8402
|
var swift_distribution_lock_default = {
|
|
8055
|
-
id: "
|
|
8403
|
+
id: "d27a9b6d2aee64d4",
|
|
8056
8404
|
release: "swift-6.3-RELEASE",
|
|
8057
|
-
wasmSdkId: "swift-6.3-RELEASE_wasm-peach-
|
|
8058
|
-
wasmSdkUrl: "https://r2.sootsim.com/swift-wasm-sdk/swift-6.3-RELEASE_wasm-peach-
|
|
8059
|
-
wasmSdkChecksum: "
|
|
8060
|
-
source: "
|
|
8405
|
+
wasmSdkId: "swift-6.3-RELEASE_wasm-peach-41921598-peach-26be2317",
|
|
8406
|
+
wasmSdkUrl: "https://r2.sootsim.com/swift-wasm-sdk/swift-6.3-RELEASE_wasm-peach-41921598-peach-26be2317.artifactbundle.tar.gz",
|
|
8407
|
+
wasmSdkChecksum: "f34f29d9426f42b04d1c38585d61cf38ecb5357f4287c4843870bec63de6b08c",
|
|
8408
|
+
source: "8f9873608a950d832ec49cf4bbc32fb65689e5f7",
|
|
8061
8409
|
hosts: {
|
|
8062
8410
|
"darwin-arm64": {
|
|
8063
|
-
sha256: "
|
|
8064
|
-
size:
|
|
8411
|
+
sha256: "b7fa68565ae1be6ee7964390b4d07949228894ac4a06fe7f58e4238dd0650197",
|
|
8412
|
+
size: 19319227
|
|
8065
8413
|
},
|
|
8066
8414
|
"linux-x64": {
|
|
8067
|
-
sha256: "
|
|
8068
|
-
size:
|
|
8415
|
+
sha256: "733ebee3a16142c97575532daf49990df57171ede17de6530a9c5906471d96ca",
|
|
8416
|
+
size: 19324099
|
|
8069
8417
|
},
|
|
8070
8418
|
"linux-arm64": {
|
|
8071
|
-
sha256: "
|
|
8072
|
-
size:
|
|
8419
|
+
sha256: "84b258d95a71536392f25d2afb8c40835df771594a2c0e42049ee33781ce78ad",
|
|
8420
|
+
size: 19323438
|
|
8073
8421
|
}
|
|
8074
8422
|
}
|
|
8075
8423
|
};
|
|
@@ -8194,10 +8542,10 @@ function swiftDistributionRoot() {
|
|
|
8194
8542
|
return pending;
|
|
8195
8543
|
}
|
|
8196
8544
|
async function resolveSwiftModule() {
|
|
8197
|
-
const
|
|
8198
|
-
if (import_node_fs11.default.existsSync(import_node_path11.default.join(
|
|
8545
|
+
const checkout2 = import_node_path11.default.resolve(import_meta2.dirname, "../../sootsim-swift");
|
|
8546
|
+
if (import_node_fs11.default.existsSync(import_node_path11.default.join(checkout2, "toolchain.json"))) {
|
|
8199
8547
|
try {
|
|
8200
|
-
return { root:
|
|
8548
|
+
return { root: checkout2, ...swiftModuleToolchain(checkout2) };
|
|
8201
8549
|
} catch {
|
|
8202
8550
|
return null;
|
|
8203
8551
|
}
|
|
@@ -8215,9 +8563,9 @@ function swiftModuleToolchain(root) {
|
|
|
8215
8563
|
|
|
8216
8564
|
// src/swift-host.ts
|
|
8217
8565
|
var import_node_crypto5 = require("node:crypto");
|
|
8218
|
-
var
|
|
8566
|
+
var import_node_fs15 = __toESM(require("node:fs"), 1);
|
|
8219
8567
|
var import_node_os5 = __toESM(require("node:os"), 1);
|
|
8220
|
-
var
|
|
8568
|
+
var import_node_path15 = __toESM(require("node:path"), 1);
|
|
8221
8569
|
|
|
8222
8570
|
// ../sootsim-swift/src/bundleAssets.ts
|
|
8223
8571
|
var import_svgpath = __toESM(require("svgpath"), 1);
|
|
@@ -8251,15 +8599,15 @@ function pickImagesetFile(images) {
|
|
|
8251
8599
|
scale: pick.scale === "2x" ? 2 : pick.scale === "3x" ? 3 : 1
|
|
8252
8600
|
};
|
|
8253
8601
|
}
|
|
8254
|
-
function flatScale(
|
|
8255
|
-
const match = /@([23])x\.[^./]+$/.exec(
|
|
8602
|
+
function flatScale(path20) {
|
|
8603
|
+
const match = /@([23])x\.[^./]+$/.exec(path20);
|
|
8256
8604
|
return match ? Number(match[1]) : 1;
|
|
8257
8605
|
}
|
|
8258
8606
|
function providesNamespace(text) {
|
|
8259
8607
|
if (text === null) return false;
|
|
8260
8608
|
try {
|
|
8261
|
-
const
|
|
8262
|
-
return
|
|
8609
|
+
const parsed2 = JSON.parse(text);
|
|
8610
|
+
return parsed2?.properties?.["provides-namespace"] === true;
|
|
8263
8611
|
} catch {
|
|
8264
8612
|
return false;
|
|
8265
8613
|
}
|
|
@@ -8279,25 +8627,25 @@ function catalogEntryName(contentsPath, kind, readText) {
|
|
|
8279
8627
|
}
|
|
8280
8628
|
return segments.join("/");
|
|
8281
8629
|
}
|
|
8282
|
-
function isFlatResourceImage(
|
|
8283
|
-
return
|
|
8630
|
+
function isFlatResourceImage(path20) {
|
|
8631
|
+
return path20.split("/").includes("Resources") && RASTER_EXTENSIONS.has(extOf(path20));
|
|
8284
8632
|
}
|
|
8285
8633
|
function enumerateBundleImages(paths, readText) {
|
|
8286
8634
|
const table = [];
|
|
8287
8635
|
const seen = /* @__PURE__ */ new Set();
|
|
8288
|
-
const catalogs = paths.filter((
|
|
8636
|
+
const catalogs = paths.filter((path20) => baseOf(path20) === "Contents.json");
|
|
8289
8637
|
for (const contentsPath of catalogs) {
|
|
8290
8638
|
const name2 = catalogEntryName(contentsPath, ".imageset", readText);
|
|
8291
8639
|
if (name2 === null || seen.has(name2)) continue;
|
|
8292
|
-
let
|
|
8640
|
+
let parsed2;
|
|
8293
8641
|
try {
|
|
8294
8642
|
const text = readText(contentsPath);
|
|
8295
8643
|
if (text === null) continue;
|
|
8296
|
-
|
|
8644
|
+
parsed2 = JSON.parse(text);
|
|
8297
8645
|
} catch {
|
|
8298
8646
|
continue;
|
|
8299
8647
|
}
|
|
8300
|
-
const images =
|
|
8648
|
+
const images = parsed2?.images;
|
|
8301
8649
|
if (!Array.isArray(images)) continue;
|
|
8302
8650
|
const dir = contentsPath.split("/").slice(0, -1).join("/");
|
|
8303
8651
|
const pick = pickImagesetFile(images);
|
|
@@ -8306,19 +8654,19 @@ function enumerateBundleImages(paths, readText) {
|
|
|
8306
8654
|
seen.add(name2);
|
|
8307
8655
|
table.push({ name: name2, file: `${dir}/${pick.filename}`, scale: pick.scale });
|
|
8308
8656
|
}
|
|
8309
|
-
for (const
|
|
8310
|
-
if (!isFlatResourceImage(
|
|
8311
|
-
const name2 = baseOf(
|
|
8657
|
+
for (const path20 of paths) {
|
|
8658
|
+
if (!isFlatResourceImage(path20)) continue;
|
|
8659
|
+
const name2 = baseOf(path20).slice(0, -extOf(path20).length);
|
|
8312
8660
|
if (name2 === "" || seen.has(name2)) continue;
|
|
8313
8661
|
seen.add(name2);
|
|
8314
|
-
table.push({ name: name2, file:
|
|
8662
|
+
table.push({ name: name2, file: path20, scale: flatScale(path20) });
|
|
8315
8663
|
}
|
|
8316
8664
|
return table;
|
|
8317
8665
|
}
|
|
8318
8666
|
function colorComponent(value) {
|
|
8319
8667
|
if (typeof value !== "string") return null;
|
|
8320
|
-
const
|
|
8321
|
-
return Number.isFinite(
|
|
8668
|
+
const parsed2 = value.startsWith("0x") ? Number.parseInt(value.slice(2), 16) / 255 : value.includes(".") ? Number.parseFloat(value) : Number.parseInt(value, 10) / 255;
|
|
8669
|
+
return Number.isFinite(parsed2) ? parsed2 : null;
|
|
8322
8670
|
}
|
|
8323
8671
|
function colorsetValue(color) {
|
|
8324
8672
|
if (typeof color !== "object" || color === null) return null;
|
|
@@ -8340,7 +8688,7 @@ function colorsetValue(color) {
|
|
|
8340
8688
|
}
|
|
8341
8689
|
function enumerateBundleColors(paths, readText) {
|
|
8342
8690
|
const table = {};
|
|
8343
|
-
for (const contentsPath of paths.filter((
|
|
8691
|
+
for (const contentsPath of paths.filter((path20) => baseOf(path20) === "Contents.json")) {
|
|
8344
8692
|
const name2 = catalogEntryName(contentsPath, ".colorset", readText);
|
|
8345
8693
|
if (name2 === null || name2 in table) continue;
|
|
8346
8694
|
let colors;
|
|
@@ -8359,12 +8707,12 @@ function enumerateBundleColors(paths, readText) {
|
|
|
8359
8707
|
const idiom = Reflect.get(entry, "idiom");
|
|
8360
8708
|
if (idiom !== "universal" && idiom !== "iphone") continue;
|
|
8361
8709
|
const appearances = Reflect.get(entry, "appearances");
|
|
8362
|
-
const
|
|
8363
|
-
if (
|
|
8364
|
-
const isDark =
|
|
8710
|
+
const list2 = Array.isArray(appearances) ? appearances : [];
|
|
8711
|
+
if (list2.some((item) => Reflect.get(item, "appearance") === "contrast")) continue;
|
|
8712
|
+
const isDark = list2.some(
|
|
8365
8713
|
(item) => Reflect.get(item, "appearance") === "luminosity" && Reflect.get(item, "value") === "dark"
|
|
8366
8714
|
);
|
|
8367
|
-
if (
|
|
8715
|
+
if (list2.length > 0 && !isDark) continue;
|
|
8368
8716
|
const value = colorsetValue(Reflect.get(entry, "color"));
|
|
8369
8717
|
if (value === null) continue;
|
|
8370
8718
|
if (isDark) dark = value;
|
|
@@ -8405,8 +8753,8 @@ function axisExtremes(points) {
|
|
|
8405
8753
|
function pathBounds(d) {
|
|
8406
8754
|
const xs = [];
|
|
8407
8755
|
const ys = [];
|
|
8408
|
-
for (const
|
|
8409
|
-
(0, import_svgpath.default)(
|
|
8756
|
+
for (const path20 of d)
|
|
8757
|
+
(0, import_svgpath.default)(path20).abs().unshort().unarc().iterate((segment, _index, x, y) => {
|
|
8410
8758
|
const [command, ...args] = segment;
|
|
8411
8759
|
if (command === "M" || command === "L") {
|
|
8412
8760
|
xs.push(Number(args[0]));
|
|
@@ -8433,7 +8781,7 @@ function guide(svg, id, axis) {
|
|
|
8433
8781
|
}
|
|
8434
8782
|
function enumerateBundleSymbols(paths, readText) {
|
|
8435
8783
|
const table = {};
|
|
8436
|
-
for (const contentsPath of paths.filter((
|
|
8784
|
+
for (const contentsPath of paths.filter((path20) => baseOf(path20) === "Contents.json")) {
|
|
8437
8785
|
const name2 = catalogEntryName(contentsPath, ".symbolset", readText);
|
|
8438
8786
|
if (name2 === null || name2 in table) continue;
|
|
8439
8787
|
let symbols;
|
|
@@ -8466,8 +8814,8 @@ function enumerateBundleSymbols(paths, readText) {
|
|
|
8466
8814
|
viewBox: "0 0 24 24",
|
|
8467
8815
|
advance,
|
|
8468
8816
|
box: [12 - advance / 2, 12 - tall / 2, advance, tall],
|
|
8469
|
-
layers: d.map((
|
|
8470
|
-
d: (0, import_svgpath.default)(
|
|
8817
|
+
layers: d.map((path20) => ({
|
|
8818
|
+
d: (0, import_svgpath.default)(path20).abs().scale(scale).translate(translateX, translateY).round(3).toString()
|
|
8471
8819
|
}))
|
|
8472
8820
|
};
|
|
8473
8821
|
}
|
|
@@ -8477,7 +8825,7 @@ function enumerateBundleJson(paths) {
|
|
|
8477
8825
|
const found = [];
|
|
8478
8826
|
const seen = /* @__PURE__ */ new Set();
|
|
8479
8827
|
const ordered = [...paths].filter(
|
|
8480
|
-
(
|
|
8828
|
+
(path20) => path20.split("/").includes("Resources") && path20.split("/").every((segment) => segment !== "" && segment !== "..") && (extOf(path20) === ".json" || extOf(path20) === ".xcstrings")
|
|
8481
8829
|
).sort((a, b) => {
|
|
8482
8830
|
const aDepth = a.split("/").length;
|
|
8483
8831
|
const bDepth = b.split("/").length;
|
|
@@ -8496,6 +8844,190 @@ function enumerateBundleJson(paths) {
|
|
|
8496
8844
|
init_auth();
|
|
8497
8845
|
init_backend_origin();
|
|
8498
8846
|
|
|
8847
|
+
// src/swift-remote-packages.ts
|
|
8848
|
+
var import_node_child_process6 = require("node:child_process");
|
|
8849
|
+
var import_node_fs13 = __toESM(require("node:fs"), 1);
|
|
8850
|
+
var import_node_path13 = __toESM(require("node:path"), 1);
|
|
8851
|
+
var REMOTE_CHECKOUTS = import_node_path13.default.join(".build", "peach", "checkouts");
|
|
8852
|
+
var C_FAMILY = /\.(c|cc|cpp|cxx|m|mm|s|S)$/;
|
|
8853
|
+
function readPins(resolved) {
|
|
8854
|
+
const data = JSON.parse(import_node_fs13.default.readFileSync(resolved, "utf8"));
|
|
8855
|
+
const pins = data && typeof data === "object" && "pins" in data && Array.isArray(data.pins) ? data.pins : null;
|
|
8856
|
+
if (!pins)
|
|
8857
|
+
throw new Error(`${resolved} has no pins; resolve packages in a current Xcode`);
|
|
8858
|
+
const out = /* @__PURE__ */ new Map();
|
|
8859
|
+
for (const pin of pins) {
|
|
8860
|
+
const identity = pin?.identity;
|
|
8861
|
+
const location2 = pin?.location;
|
|
8862
|
+
const revision = pin?.state?.revision;
|
|
8863
|
+
if (typeof identity === "string" && typeof location2 === "string" && typeof revision === "string")
|
|
8864
|
+
out.set(identity, { location: location2, revision });
|
|
8865
|
+
}
|
|
8866
|
+
return out;
|
|
8867
|
+
}
|
|
8868
|
+
function walk(dir) {
|
|
8869
|
+
if (!import_node_fs13.default.existsSync(dir)) return [];
|
|
8870
|
+
const out = [];
|
|
8871
|
+
for (const entry of import_node_fs13.default.readdirSync(dir, { withFileTypes: true })) {
|
|
8872
|
+
if (entry.name.startsWith(".")) continue;
|
|
8873
|
+
const full = import_node_path13.default.join(dir, entry.name);
|
|
8874
|
+
if (entry.isDirectory()) out.push(...walk(full));
|
|
8875
|
+
else if (entry.isFile()) out.push(full);
|
|
8876
|
+
}
|
|
8877
|
+
return out.sort();
|
|
8878
|
+
}
|
|
8879
|
+
var verified2 = /* @__PURE__ */ new Set();
|
|
8880
|
+
function checkout(checkouts, identity, pin) {
|
|
8881
|
+
const dir = import_node_path13.default.join(checkouts, identity);
|
|
8882
|
+
const key = `${dir}\0${pin.revision}`;
|
|
8883
|
+
if (verified2.has(key)) return dir;
|
|
8884
|
+
const git = (...args) => (0, import_node_child_process6.execFileSync)("git", ["-C", dir, ...args], {
|
|
8885
|
+
encoding: "utf8",
|
|
8886
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
8887
|
+
}).trim();
|
|
8888
|
+
const current = import_node_fs13.default.existsSync(import_node_path13.default.join(dir, ".git")) ? git("rev-parse", "HEAD") : "";
|
|
8889
|
+
if (current !== pin.revision) {
|
|
8890
|
+
import_node_fs13.default.rmSync(dir, { recursive: true, force: true });
|
|
8891
|
+
import_node_fs13.default.mkdirSync(dir, { recursive: true });
|
|
8892
|
+
try {
|
|
8893
|
+
git("init", "-q");
|
|
8894
|
+
git("fetch", "-q", "--depth", "1", pin.location, pin.revision);
|
|
8895
|
+
git("checkout", "-q", "FETCH_HEAD");
|
|
8896
|
+
} catch (error) {
|
|
8897
|
+
import_node_fs13.default.rmSync(dir, { recursive: true, force: true });
|
|
8898
|
+
const stderr = error instanceof Error && "stderr" in error ? String(error.stderr).trim() : "";
|
|
8899
|
+
throw new Error(
|
|
8900
|
+
`could not fetch ${pin.location} at ${pin.revision}${stderr ? `: ${stderr}` : ""}`
|
|
8901
|
+
);
|
|
8902
|
+
}
|
|
8903
|
+
}
|
|
8904
|
+
verified2.add(key);
|
|
8905
|
+
return dir;
|
|
8906
|
+
}
|
|
8907
|
+
function resolveRemotePackages(projectDir, resolved, products, provided) {
|
|
8908
|
+
const result = { targets: [], unavailable: /* @__PURE__ */ new Map() };
|
|
8909
|
+
const wanted = products.filter((entry) => !provided.has(entry.product));
|
|
8910
|
+
if (wanted.length === 0) return result;
|
|
8911
|
+
if (!resolved) {
|
|
8912
|
+
for (const entry of wanted)
|
|
8913
|
+
result.unavailable.set(entry.product, {
|
|
8914
|
+
repositoryURL: entry.repositoryURL,
|
|
8915
|
+
reason: "no Package.resolved pins it; resolve packages in Xcode once"
|
|
8916
|
+
});
|
|
8917
|
+
return result;
|
|
8918
|
+
}
|
|
8919
|
+
const pins = readPins(resolved);
|
|
8920
|
+
const checkouts = import_node_path13.default.join(projectDir, REMOTE_CHECKOUTS);
|
|
8921
|
+
import_node_fs13.default.mkdirSync(checkouts, { recursive: true });
|
|
8922
|
+
import_node_fs13.default.writeFileSync(import_node_path13.default.join(import_node_path13.default.dirname(checkouts), ".gitignore"), "*\n");
|
|
8923
|
+
const packages = /* @__PURE__ */ new Map();
|
|
8924
|
+
const load2 = (identity) => {
|
|
8925
|
+
const cached3 = packages.get(identity);
|
|
8926
|
+
if (cached3) return cached3;
|
|
8927
|
+
const pin = pins.get(identity);
|
|
8928
|
+
if (!pin) return null;
|
|
8929
|
+
const dir = checkout(checkouts, identity, pin);
|
|
8930
|
+
const manifest = import_node_fs13.default.readFileSync(import_node_path13.default.join(dir, "Package.swift"), "utf8");
|
|
8931
|
+
const loaded = { dir, manifest, graph: swiftManifestGraph(manifest) };
|
|
8932
|
+
packages.set(identity, loaded);
|
|
8933
|
+
return loaded;
|
|
8934
|
+
};
|
|
8935
|
+
const targets = /* @__PURE__ */ new Map();
|
|
8936
|
+
const outcomes = /* @__PURE__ */ new Map();
|
|
8937
|
+
const resolveProduct = (identity, product) => {
|
|
8938
|
+
const key = `${identity}\0${product}`;
|
|
8939
|
+
if (outcomes.has(key)) return outcomes.get(key);
|
|
8940
|
+
outcomes.set(key, null);
|
|
8941
|
+
const pkg = load2(identity);
|
|
8942
|
+
if (!pkg) {
|
|
8943
|
+
outcomes.set(key, `package ${identity} is not pinned in Package.resolved`);
|
|
8944
|
+
return outcomes.get(key);
|
|
8945
|
+
}
|
|
8946
|
+
const roots = pkg.graph.products.get(product);
|
|
8947
|
+
if (!roots) {
|
|
8948
|
+
outcomes.set(key, `package ${identity} has no library ${product}`);
|
|
8949
|
+
return outcomes.get(key);
|
|
8950
|
+
}
|
|
8951
|
+
const declared = new Map(
|
|
8952
|
+
swiftManifestTargets(pkg.manifest).map((target) => [target.name, target])
|
|
8953
|
+
);
|
|
8954
|
+
const reached = [];
|
|
8955
|
+
const seen = /* @__PURE__ */ new Set();
|
|
8956
|
+
const pending = [...roots];
|
|
8957
|
+
let reason = null;
|
|
8958
|
+
while (pending.length > 0 && !reason) {
|
|
8959
|
+
const name2 = pending.pop();
|
|
8960
|
+
if (seen.has(name2) || provided.has(name2)) continue;
|
|
8961
|
+
seen.add(name2);
|
|
8962
|
+
if (pkg.graph.binaryTargets.has(name2)) {
|
|
8963
|
+
reason = `${name2} is a binary framework`;
|
|
8964
|
+
break;
|
|
8965
|
+
}
|
|
8966
|
+
if (pkg.graph.systemLibraries.has(name2)) {
|
|
8967
|
+
reason = `${name2} is a system C library`;
|
|
8968
|
+
break;
|
|
8969
|
+
}
|
|
8970
|
+
const target = declared.get(name2);
|
|
8971
|
+
if (!target) {
|
|
8972
|
+
reason = `${identity} declares no target ${name2}`;
|
|
8973
|
+
break;
|
|
8974
|
+
}
|
|
8975
|
+
const files = walk(import_node_path13.default.join(pkg.dir, target.path));
|
|
8976
|
+
if (files.some((file) => C_FAMILY.test(file))) {
|
|
8977
|
+
reason = `${name2} is a C or Objective-C target`;
|
|
8978
|
+
break;
|
|
8979
|
+
}
|
|
8980
|
+
reached.push(target);
|
|
8981
|
+
for (const dependency of pkg.graph.dependencies.get(name2) ?? []) {
|
|
8982
|
+
if (dependency.kind === "target") pending.push(dependency.name);
|
|
8983
|
+
else if (!provided.has(dependency.name)) {
|
|
8984
|
+
const url = pkg.graph.packageURLs.get(dependency.package);
|
|
8985
|
+
const nested = resolveProduct(
|
|
8986
|
+
url ? swiftPackageIdentity(url) : dependency.package,
|
|
8987
|
+
dependency.name
|
|
8988
|
+
);
|
|
8989
|
+
if (nested) reason = `${dependency.name}: ${nested}`;
|
|
8990
|
+
}
|
|
8991
|
+
}
|
|
8992
|
+
}
|
|
8993
|
+
if (reason) {
|
|
8994
|
+
outcomes.set(key, reason);
|
|
8995
|
+
return reason;
|
|
8996
|
+
}
|
|
8997
|
+
const relative2 = reached.flatMap(
|
|
8998
|
+
(target) => walk(import_node_path13.default.join(pkg.dir, target.path)).map(
|
|
8999
|
+
(file) => import_node_path13.default.relative(pkg.dir, file).split(import_node_path13.default.sep).join(import_node_path13.default.posix.sep)
|
|
9000
|
+
)
|
|
9001
|
+
);
|
|
9002
|
+
const withResources = new Map(
|
|
9003
|
+
swiftManifestTargets(pkg.manifest, relative2).map((target) => [target.name, target])
|
|
9004
|
+
);
|
|
9005
|
+
for (const target of reached) {
|
|
9006
|
+
const dir = import_node_path13.default.join(pkg.dir, target.path);
|
|
9007
|
+
targets.set(target.name, {
|
|
9008
|
+
...withResources.get(target.name) ?? target,
|
|
9009
|
+
executable: false,
|
|
9010
|
+
dir,
|
|
9011
|
+
files: walk(dir)
|
|
9012
|
+
});
|
|
9013
|
+
}
|
|
9014
|
+
return null;
|
|
9015
|
+
};
|
|
9016
|
+
for (const entry of wanted) {
|
|
9017
|
+
const reason = resolveProduct(
|
|
9018
|
+
swiftPackageIdentity(entry.repositoryURL),
|
|
9019
|
+
entry.product
|
|
9020
|
+
);
|
|
9021
|
+
if (reason)
|
|
9022
|
+
result.unavailable.set(entry.product, {
|
|
9023
|
+
repositoryURL: entry.repositoryURL,
|
|
9024
|
+
reason
|
|
9025
|
+
});
|
|
9026
|
+
}
|
|
9027
|
+
result.targets = [...targets.values()];
|
|
9028
|
+
return result;
|
|
9029
|
+
}
|
|
9030
|
+
|
|
8499
9031
|
// src/swift-submit.ts
|
|
8500
9032
|
var SWIFT_COMPILE_PATH = "/api/swift-compile";
|
|
8501
9033
|
var MAX_SWIFT_COMPILE_FILES = 256;
|
|
@@ -8506,7 +9038,7 @@ var MAX_SWIFT_COMPILE_RESOURCE_TOTAL_BYTES = 8 * 1024 * 1024;
|
|
|
8506
9038
|
var MAX_SWIFT_COMPILE_IMAGES = 128;
|
|
8507
9039
|
var MAX_SWIFT_COMPILE_IMAGE_BYTES = 4 * 1024 * 1024;
|
|
8508
9040
|
var MAX_SWIFT_COMPILE_IMAGE_TOTAL_BYTES = 16 * 1024 * 1024;
|
|
8509
|
-
var SWIFT_HOST_ABI =
|
|
9041
|
+
var SWIFT_HOST_ABI = 24;
|
|
8510
9042
|
var POLL_INTERVAL_MS = 1500;
|
|
8511
9043
|
function httpSwiftCompileSubmit(context) {
|
|
8512
9044
|
const { assetReadToken, authorization, endpoint } = context;
|
|
@@ -8622,6 +9154,383 @@ async function compileSwiftProject(submit, work, origin, signal) {
|
|
|
8622
9154
|
}
|
|
8623
9155
|
}
|
|
8624
9156
|
|
|
9157
|
+
// src/xcode-project.ts
|
|
9158
|
+
var import_node_fs14 = __toESM(require("node:fs"), 1);
|
|
9159
|
+
var import_node_path14 = __toESM(require("node:path"), 1);
|
|
9160
|
+
function parseOpenStepPlist(text) {
|
|
9161
|
+
let i = 0;
|
|
9162
|
+
const fail = (message) => {
|
|
9163
|
+
const line = text.slice(0, i).split("\n").length;
|
|
9164
|
+
throw new Error(`project.pbxproj line ${line}: ${message}`);
|
|
9165
|
+
};
|
|
9166
|
+
const skip = () => {
|
|
9167
|
+
for (; ; ) {
|
|
9168
|
+
const ch = text[i];
|
|
9169
|
+
if (ch === " " || ch === " " || ch === "\n" || ch === "\r") i++;
|
|
9170
|
+
else if (ch === "/" && text[i + 1] === "*") {
|
|
9171
|
+
const end = text.indexOf("*/", i + 2);
|
|
9172
|
+
if (end < 0) fail("unterminated comment");
|
|
9173
|
+
i = end + 2;
|
|
9174
|
+
} else if (ch === "/" && text[i + 1] === "/") {
|
|
9175
|
+
const end = text.indexOf("\n", i);
|
|
9176
|
+
i = end < 0 ? text.length : end + 1;
|
|
9177
|
+
} else return;
|
|
9178
|
+
}
|
|
9179
|
+
};
|
|
9180
|
+
const quoted = () => {
|
|
9181
|
+
i++;
|
|
9182
|
+
let out = "";
|
|
9183
|
+
for (; ; ) {
|
|
9184
|
+
const ch = text[i++];
|
|
9185
|
+
if (ch === void 0) fail("unterminated string");
|
|
9186
|
+
if (ch === '"') return out;
|
|
9187
|
+
if (ch !== "\\") {
|
|
9188
|
+
out += ch;
|
|
9189
|
+
continue;
|
|
9190
|
+
}
|
|
9191
|
+
const next = text[i++];
|
|
9192
|
+
if (next === "n") out += "\n";
|
|
9193
|
+
else if (next === "t") out += " ";
|
|
9194
|
+
else if (next === "r") out += "\r";
|
|
9195
|
+
else if (next === "U") {
|
|
9196
|
+
out += String.fromCharCode(parseInt(text.slice(i, i + 4), 16));
|
|
9197
|
+
i += 4;
|
|
9198
|
+
} else out += next;
|
|
9199
|
+
}
|
|
9200
|
+
};
|
|
9201
|
+
const value = () => {
|
|
9202
|
+
skip();
|
|
9203
|
+
const ch = text[i];
|
|
9204
|
+
if (ch === "{") {
|
|
9205
|
+
i++;
|
|
9206
|
+
const dict = {};
|
|
9207
|
+
for (; ; ) {
|
|
9208
|
+
skip();
|
|
9209
|
+
if (text[i] === "}") {
|
|
9210
|
+
i++;
|
|
9211
|
+
return dict;
|
|
9212
|
+
}
|
|
9213
|
+
const key = value();
|
|
9214
|
+
if (typeof key !== "string") fail("dictionary key is not a string");
|
|
9215
|
+
skip();
|
|
9216
|
+
if (text[i++] !== "=") fail("expected =");
|
|
9217
|
+
dict[key] = value();
|
|
9218
|
+
skip();
|
|
9219
|
+
if (text[i++] !== ";") fail("expected ;");
|
|
9220
|
+
}
|
|
9221
|
+
}
|
|
9222
|
+
if (ch === "(") {
|
|
9223
|
+
i++;
|
|
9224
|
+
const list2 = [];
|
|
9225
|
+
for (; ; ) {
|
|
9226
|
+
skip();
|
|
9227
|
+
if (text[i] === ")") {
|
|
9228
|
+
i++;
|
|
9229
|
+
return list2;
|
|
9230
|
+
}
|
|
9231
|
+
list2.push(value());
|
|
9232
|
+
skip();
|
|
9233
|
+
if (text[i] === ",") i++;
|
|
9234
|
+
else if (text[i] !== ")") fail("expected , or )");
|
|
9235
|
+
}
|
|
9236
|
+
}
|
|
9237
|
+
if (ch === '"') return quoted();
|
|
9238
|
+
const start = i;
|
|
9239
|
+
while (i < text.length && /[A-Za-z0-9_$+/:.\-<>]/.test(text[i])) i++;
|
|
9240
|
+
if (i === start) fail(`unexpected ${JSON.stringify(ch ?? "end of file")}`);
|
|
9241
|
+
return text.slice(start, i);
|
|
9242
|
+
};
|
|
9243
|
+
if (text.startsWith("// !$*UTF8*$!")) i = text.indexOf("\n") + 1;
|
|
9244
|
+
const root = value();
|
|
9245
|
+
skip();
|
|
9246
|
+
if (i !== text.length) fail("trailing content");
|
|
9247
|
+
return root;
|
|
9248
|
+
}
|
|
9249
|
+
var isDict = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9250
|
+
var str = (value) => typeof value === "string" ? value : void 0;
|
|
9251
|
+
var list = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
|
|
9252
|
+
var APPLICATION = "com.apple.product-type.application";
|
|
9253
|
+
var NEVER_MEMBER = /(?:^|\/)(?:Info\.plist|[^/]+\.entitlements|[^/]+\.xcconfig|\.DS_Store)$/;
|
|
9254
|
+
var BUNDLE_DIR = /\.(xcassets|bundle|lproj|xcdatamodeld|scnassets|spriteatlas|rcproject|storyboardc|icon)$/;
|
|
9255
|
+
function walkFiles(dir) {
|
|
9256
|
+
if (!import_node_fs14.default.existsSync(dir)) return [];
|
|
9257
|
+
const out = [];
|
|
9258
|
+
for (const entry of import_node_fs14.default.readdirSync(dir, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
|
|
9259
|
+
if (entry.name.startsWith(".")) continue;
|
|
9260
|
+
const full = import_node_path14.default.join(dir, entry.name);
|
|
9261
|
+
if (entry.isDirectory()) out.push(...walkFiles(full));
|
|
9262
|
+
else if (entry.isFile()) out.push(full);
|
|
9263
|
+
}
|
|
9264
|
+
return out;
|
|
9265
|
+
}
|
|
9266
|
+
function readXcconfig(file, seen = /* @__PURE__ */ new Set()) {
|
|
9267
|
+
if (seen.has(file) || !import_node_fs14.default.existsSync(file)) return {};
|
|
9268
|
+
seen.add(file);
|
|
9269
|
+
const settings = {};
|
|
9270
|
+
for (const raw2 of import_node_fs14.default.readFileSync(file, "utf8").split("\n")) {
|
|
9271
|
+
const line = raw2.replace(/\/\/.*$/, "").trim();
|
|
9272
|
+
const include = /^#include\??\s+"([^"]+)"/.exec(line);
|
|
9273
|
+
if (include) {
|
|
9274
|
+
Object.assign(
|
|
9275
|
+
settings,
|
|
9276
|
+
readXcconfig(import_node_path14.default.resolve(import_node_path14.default.dirname(file), include[1]), seen)
|
|
9277
|
+
);
|
|
9278
|
+
continue;
|
|
9279
|
+
}
|
|
9280
|
+
const setting = /^([A-Z_][A-Z0-9_]*)(?:\[[^\]]*\])?\s*=\s*(.*)$/.exec(line);
|
|
9281
|
+
if (setting) settings[setting[1]] = setting[2].trim();
|
|
9282
|
+
}
|
|
9283
|
+
return settings;
|
|
9284
|
+
}
|
|
9285
|
+
function c99Identifier(name2) {
|
|
9286
|
+
const id = name2.replace(/[^A-Za-z0-9_]/g, "_");
|
|
9287
|
+
return /^[0-9]/.test(id) ? `_${id}` : id;
|
|
9288
|
+
}
|
|
9289
|
+
var parsed = /* @__PURE__ */ new Map();
|
|
9290
|
+
function readProject(pbxproj) {
|
|
9291
|
+
const mtimeMs = import_node_fs14.default.statSync(pbxproj).mtimeMs;
|
|
9292
|
+
const cached3 = parsed.get(pbxproj);
|
|
9293
|
+
if (cached3?.mtimeMs === mtimeMs) return cached3.root;
|
|
9294
|
+
const root = parseOpenStepPlist(import_node_fs14.default.readFileSync(pbxproj, "utf8"));
|
|
9295
|
+
if (!isDict(root) || !isDict(root.objects)) {
|
|
9296
|
+
throw new Error(`${pbxproj} has no objects table`);
|
|
9297
|
+
}
|
|
9298
|
+
parsed.set(pbxproj, { mtimeMs, root });
|
|
9299
|
+
return root;
|
|
9300
|
+
}
|
|
9301
|
+
function readXcodeAppTarget(xcodeproj, targetName) {
|
|
9302
|
+
const pbxproj = import_node_path14.default.join(xcodeproj, "project.pbxproj");
|
|
9303
|
+
if (!import_node_fs14.default.existsSync(pbxproj)) throw new Error(`${xcodeproj} has no project.pbxproj`);
|
|
9304
|
+
const root = readProject(pbxproj);
|
|
9305
|
+
const objects = root.objects;
|
|
9306
|
+
const object = (id) => {
|
|
9307
|
+
const found = id === void 0 ? void 0 : objects[id];
|
|
9308
|
+
return isDict(found) ? found : void 0;
|
|
9309
|
+
};
|
|
9310
|
+
const project = object(str(root.rootObject));
|
|
9311
|
+
if (!project || project.isa !== "PBXProject") {
|
|
9312
|
+
throw new Error(`${pbxproj} has no PBXProject root`);
|
|
9313
|
+
}
|
|
9314
|
+
const projectDir = import_node_fs14.default.realpathSync(
|
|
9315
|
+
import_node_path14.default.resolve(import_node_path14.default.dirname(xcodeproj), str(project.projectDirPath) ?? "")
|
|
9316
|
+
);
|
|
9317
|
+
const parent = /* @__PURE__ */ new Map();
|
|
9318
|
+
for (const [id, entry] of Object.entries(objects)) {
|
|
9319
|
+
if (!isDict(entry)) continue;
|
|
9320
|
+
if (entry.isa === "PBXGroup" || entry.isa === "PBXVariantGroup") {
|
|
9321
|
+
for (const child of list(entry.children)) parent.set(child, id);
|
|
9322
|
+
}
|
|
9323
|
+
}
|
|
9324
|
+
const resolvedPaths = /* @__PURE__ */ new Map();
|
|
9325
|
+
const resolvePath = (id) => {
|
|
9326
|
+
if (resolvedPaths.has(id)) return resolvedPaths.get(id);
|
|
9327
|
+
const entry = object(id);
|
|
9328
|
+
let result = null;
|
|
9329
|
+
if (entry) {
|
|
9330
|
+
const own = str(entry.path) ?? "";
|
|
9331
|
+
const tree = str(entry.sourceTree) ?? "<group>";
|
|
9332
|
+
if (tree === "<absolute>") result = own;
|
|
9333
|
+
else if (tree === "SOURCE_ROOT") result = import_node_path14.default.join(projectDir, own);
|
|
9334
|
+
else if (tree === "<group>") {
|
|
9335
|
+
const up = parent.get(id);
|
|
9336
|
+
const base = up ? resolvePath(up) : projectDir;
|
|
9337
|
+
result = base === null ? null : import_node_path14.default.join(base, own);
|
|
9338
|
+
}
|
|
9339
|
+
}
|
|
9340
|
+
resolvedPaths.set(id, result);
|
|
9341
|
+
return result;
|
|
9342
|
+
};
|
|
9343
|
+
const targets = list(project.targets).map((id) => ({ id, target: object(id) })).filter(
|
|
9344
|
+
(entry) => entry.target?.isa === "PBXNativeTarget"
|
|
9345
|
+
);
|
|
9346
|
+
const appTargets = targets.filter((entry) => entry.target.productType === APPLICATION);
|
|
9347
|
+
const appTargetNames = appTargets.map((entry) => str(entry.target.name) ?? entry.id);
|
|
9348
|
+
const chosen = targetName ? appTargets.find((entry) => entry.target.name === targetName) : appTargets.length === 1 ? appTargets[0] : void 0;
|
|
9349
|
+
if (!chosen) {
|
|
9350
|
+
throw new Error(
|
|
9351
|
+
targetName ? `${import_node_path14.default.basename(xcodeproj)} has no application target ${targetName}; it has ${appTargetNames.join(", ") || "none"}` : `${import_node_path14.default.basename(xcodeproj)} has ${appTargetNames.length} application targets (${appTargetNames.join(", ") || "none"}); pass --target`
|
|
9352
|
+
);
|
|
9353
|
+
}
|
|
9354
|
+
const { id: targetId, target } = chosen;
|
|
9355
|
+
const configSettings = (listId) => {
|
|
9356
|
+
const configs = list(object(listId)?.buildConfigurations).map(object);
|
|
9357
|
+
const config = configs.find((entry) => entry?.name === "Debug") ?? configs.find(Boolean);
|
|
9358
|
+
if (!config) return {};
|
|
9359
|
+
const base = str(config.baseConfigurationReference);
|
|
9360
|
+
const fromFile = base ? readXcconfig(resolvePath(base) ?? "") : {};
|
|
9361
|
+
const own = isDict(config.buildSettings) ? config.buildSettings : {};
|
|
9362
|
+
return {
|
|
9363
|
+
...fromFile,
|
|
9364
|
+
...Object.fromEntries(
|
|
9365
|
+
Object.entries(own).flatMap(
|
|
9366
|
+
([key, value]) => typeof value === "string" ? [[key, value]] : []
|
|
9367
|
+
)
|
|
9368
|
+
)
|
|
9369
|
+
};
|
|
9370
|
+
};
|
|
9371
|
+
const settings = {
|
|
9372
|
+
...configSettings(str(project.buildConfigurationList)),
|
|
9373
|
+
...configSettings(str(target.buildConfigurationList))
|
|
9374
|
+
};
|
|
9375
|
+
const name2 = str(target.name) ?? targetId;
|
|
9376
|
+
const productName = (settings.PRODUCT_NAME ?? "$(TARGET_NAME)").replaceAll("$(TARGET_NAME)", name2).replaceAll("${TARGET_NAME}", name2);
|
|
9377
|
+
const moduleName = c99Identifier(
|
|
9378
|
+
settings.PRODUCT_MODULE_NAME && !settings.PRODUCT_MODULE_NAME.includes("$(") ? settings.PRODUCT_MODULE_NAME : productName
|
|
9379
|
+
);
|
|
9380
|
+
const sources = /* @__PURE__ */ new Set();
|
|
9381
|
+
const resources = /* @__PURE__ */ new Set();
|
|
9382
|
+
const addResource = (file) => {
|
|
9383
|
+
if (import_node_fs14.default.existsSync(file) && import_node_fs14.default.statSync(file).isDirectory()) {
|
|
9384
|
+
for (const inner of walkFiles(file)) resources.add(inner);
|
|
9385
|
+
} else if (import_node_fs14.default.existsSync(file)) resources.add(file);
|
|
9386
|
+
};
|
|
9387
|
+
const fileRefPaths = (refId) => {
|
|
9388
|
+
const ref = object(refId);
|
|
9389
|
+
if (!ref) return [];
|
|
9390
|
+
if (ref.isa === "PBXVariantGroup") {
|
|
9391
|
+
return list(ref.children).flatMap((child) => {
|
|
9392
|
+
const resolved2 = resolvePath(child);
|
|
9393
|
+
return resolved2 ? [resolved2] : [];
|
|
9394
|
+
});
|
|
9395
|
+
}
|
|
9396
|
+
const resolved = resolvePath(refId);
|
|
9397
|
+
return resolved ? [resolved] : [];
|
|
9398
|
+
};
|
|
9399
|
+
for (const phaseId of list(target.buildPhases)) {
|
|
9400
|
+
const phase = object(phaseId);
|
|
9401
|
+
if (phase?.isa !== "PBXSourcesBuildPhase" && phase?.isa !== "PBXResourcesBuildPhase")
|
|
9402
|
+
continue;
|
|
9403
|
+
for (const buildFileId of list(phase.files)) {
|
|
9404
|
+
for (const file of fileRefPaths(str(object(buildFileId)?.fileRef) ?? "")) {
|
|
9405
|
+
if (phase.isa === "PBXSourcesBuildPhase" && file.endsWith(".swift")) {
|
|
9406
|
+
if (import_node_fs14.default.existsSync(file)) sources.add(file);
|
|
9407
|
+
} else if (phase.isa === "PBXResourcesBuildPhase") addResource(file);
|
|
9408
|
+
}
|
|
9409
|
+
}
|
|
9410
|
+
}
|
|
9411
|
+
const addSynchronized = (folder, relative2) => {
|
|
9412
|
+
const file = import_node_path14.default.join(folder, relative2);
|
|
9413
|
+
if (NEVER_MEMBER.test(relative2)) return;
|
|
9414
|
+
if (file.endsWith(".swift")) {
|
|
9415
|
+
if (!relative2.split("/").some((segment) => BUNDLE_DIR.test(segment)))
|
|
9416
|
+
sources.add(file);
|
|
9417
|
+
} else if (/\.(h|m|mm|c|cpp|metal)$/.test(file)) {
|
|
9418
|
+
return;
|
|
9419
|
+
} else resources.add(file);
|
|
9420
|
+
};
|
|
9421
|
+
const owned = new Set(list(target.fileSystemSynchronizedGroups));
|
|
9422
|
+
for (const [groupId, group] of Object.entries(objects)) {
|
|
9423
|
+
if (!isDict(group) || group.isa !== "PBXFileSystemSynchronizedRootGroup") continue;
|
|
9424
|
+
const folder = resolvePath(groupId);
|
|
9425
|
+
if (!folder) continue;
|
|
9426
|
+
const exceptions = /* @__PURE__ */ new Set();
|
|
9427
|
+
for (const exceptionId of list(group.exceptions)) {
|
|
9428
|
+
const exception = object(exceptionId);
|
|
9429
|
+
if (exception?.target !== targetId) continue;
|
|
9430
|
+
for (const relative2 of list(exception.membershipExceptions))
|
|
9431
|
+
exceptions.add(relative2);
|
|
9432
|
+
}
|
|
9433
|
+
if (owned.has(groupId)) {
|
|
9434
|
+
for (const file of walkFiles(folder)) {
|
|
9435
|
+
const relative2 = import_node_path14.default.relative(folder, file).split(import_node_path14.default.sep).join("/");
|
|
9436
|
+
if ([...exceptions].some(
|
|
9437
|
+
(exception) => relative2 === exception || relative2.startsWith(`${exception}/`)
|
|
9438
|
+
))
|
|
9439
|
+
continue;
|
|
9440
|
+
addSynchronized(folder, relative2);
|
|
9441
|
+
}
|
|
9442
|
+
} else {
|
|
9443
|
+
for (const relative2 of exceptions) {
|
|
9444
|
+
const file = import_node_path14.default.join(folder, relative2);
|
|
9445
|
+
if (import_node_fs14.default.existsSync(file) && import_node_fs14.default.statSync(file).isDirectory()) {
|
|
9446
|
+
for (const inner of walkFiles(file))
|
|
9447
|
+
addSynchronized(
|
|
9448
|
+
folder,
|
|
9449
|
+
import_node_path14.default.relative(folder, inner).split(import_node_path14.default.sep).join("/")
|
|
9450
|
+
);
|
|
9451
|
+
} else if (import_node_fs14.default.existsSync(file)) addSynchronized(folder, relative2);
|
|
9452
|
+
}
|
|
9453
|
+
}
|
|
9454
|
+
}
|
|
9455
|
+
const localPackageDirs = Object.entries(objects).flatMap(([id, entry]) => {
|
|
9456
|
+
if (!isDict(entry)) return [];
|
|
9457
|
+
const candidate = entry.isa === "XCLocalSwiftPackageReference" ? import_node_path14.default.resolve(projectDir, str(entry.relativePath) ?? "") : entry.isa === "PBXFileReference" && entry.lastKnownFileType === "wrapper" ? resolvePath(id) : null;
|
|
9458
|
+
return candidate && import_node_fs14.default.existsSync(import_node_path14.default.join(candidate, "Package.swift")) ? [candidate] : [];
|
|
9459
|
+
});
|
|
9460
|
+
const graphs = /* @__PURE__ */ new Map();
|
|
9461
|
+
const graphOf = (dir) => {
|
|
9462
|
+
const cached3 = graphs.get(dir);
|
|
9463
|
+
if (cached3) return cached3;
|
|
9464
|
+
const graph = swiftManifestGraph(
|
|
9465
|
+
import_node_fs14.default.readFileSync(import_node_path14.default.join(dir, "Package.swift"), "utf8")
|
|
9466
|
+
);
|
|
9467
|
+
graphs.set(dir, graph);
|
|
9468
|
+
return graph;
|
|
9469
|
+
};
|
|
9470
|
+
const localProducts = /* @__PURE__ */ new Map();
|
|
9471
|
+
for (const dir of localPackageDirs) {
|
|
9472
|
+
for (const product of graphOf(dir).products.keys()) localProducts.set(product, dir);
|
|
9473
|
+
}
|
|
9474
|
+
const localPackages = /* @__PURE__ */ new Set();
|
|
9475
|
+
const remoteProducts = [];
|
|
9476
|
+
const unresolvedProducts = [];
|
|
9477
|
+
for (const dependencyId of list(target.packageProductDependencies)) {
|
|
9478
|
+
const dependency = object(dependencyId);
|
|
9479
|
+
const product = str(dependency?.productName);
|
|
9480
|
+
if (!dependency || !product) continue;
|
|
9481
|
+
const reference = object(str(dependency.package));
|
|
9482
|
+
if (reference?.isa === "XCRemoteSwiftPackageReference") {
|
|
9483
|
+
remoteProducts.push({ product, repositoryURL: str(reference.repositoryURL) ?? "" });
|
|
9484
|
+
} else if (reference?.isa === "XCLocalSwiftPackageReference") {
|
|
9485
|
+
localPackages.add(import_node_path14.default.resolve(projectDir, str(reference.relativePath) ?? ""));
|
|
9486
|
+
} else if (localProducts.has(product)) {
|
|
9487
|
+
localPackages.add(localProducts.get(product));
|
|
9488
|
+
} else unresolvedProducts.push(product);
|
|
9489
|
+
}
|
|
9490
|
+
const pending = [...localPackages];
|
|
9491
|
+
while (pending.length > 0) {
|
|
9492
|
+
const dir = pending.pop();
|
|
9493
|
+
const graph = graphOf(dir);
|
|
9494
|
+
for (const relative2 of graph.packagePaths) {
|
|
9495
|
+
const next = import_node_path14.default.resolve(dir, relative2);
|
|
9496
|
+
if (localPackages.has(next) || !import_node_fs14.default.existsSync(import_node_path14.default.join(next, "Package.swift")))
|
|
9497
|
+
continue;
|
|
9498
|
+
localPackages.add(next);
|
|
9499
|
+
pending.push(next);
|
|
9500
|
+
}
|
|
9501
|
+
for (const dependencies of graph.dependencies.values()) {
|
|
9502
|
+
for (const dependency of dependencies) {
|
|
9503
|
+
if (dependency.kind !== "product") continue;
|
|
9504
|
+
const url = graph.packageURLs.get(dependency.package);
|
|
9505
|
+
if (url && !remoteProducts.some((entry) => entry.product === dependency.name))
|
|
9506
|
+
remoteProducts.push({ product: dependency.name, repositoryURL: url });
|
|
9507
|
+
}
|
|
9508
|
+
}
|
|
9509
|
+
}
|
|
9510
|
+
const packageResolved = [
|
|
9511
|
+
import_node_path14.default.join(xcodeproj, "project.xcworkspace"),
|
|
9512
|
+
...import_node_fs14.default.readdirSync(projectDir).filter((entry) => entry.endsWith(".xcworkspace")).map((entry) => import_node_path14.default.join(projectDir, entry))
|
|
9513
|
+
].map(
|
|
9514
|
+
(workspace) => import_node_path14.default.join(workspace, "xcshareddata", "swiftpm", "Package.resolved")
|
|
9515
|
+
).find((file) => import_node_fs14.default.existsSync(file)) ?? null;
|
|
9516
|
+
const swiftVersion = Number.parseFloat(settings.SWIFT_VERSION ?? "5");
|
|
9517
|
+
return {
|
|
9518
|
+
projectDir,
|
|
9519
|
+
pbxproj,
|
|
9520
|
+
name: name2,
|
|
9521
|
+
moduleName,
|
|
9522
|
+
sources: [...sources].sort(),
|
|
9523
|
+
resources: [...resources].sort(),
|
|
9524
|
+
languageMode: swiftVersion >= 6 ? 6 : 5,
|
|
9525
|
+
mainActorIsolation: settings.SWIFT_DEFAULT_ACTOR_ISOLATION === "MainActor",
|
|
9526
|
+
localPackages: [...localPackages].sort(),
|
|
9527
|
+
remoteProducts,
|
|
9528
|
+
packageResolved,
|
|
9529
|
+
unresolvedProducts,
|
|
9530
|
+
appTargets: appTargetNames
|
|
9531
|
+
};
|
|
9532
|
+
}
|
|
9533
|
+
|
|
8625
9534
|
// src/swift-host.ts
|
|
8626
9535
|
var ARTIFACT_PATH = "/__peach/swift/";
|
|
8627
9536
|
var RESOURCE_PATH = "/__peach/swift-res/";
|
|
@@ -8637,17 +9546,17 @@ var SKIP_SOURCE_DIRS = /* @__PURE__ */ new Set([
|
|
|
8637
9546
|
var NATIVE_DESCRIPTOR = ".one-native-source.json";
|
|
8638
9547
|
var NATIVE_GLUE = ".one-native-source.swift.txt";
|
|
8639
9548
|
function swiftPackageId(packagePath) {
|
|
8640
|
-
return
|
|
9549
|
+
return import_node_path15.default.basename(packagePath).replace(/[^A-Za-z0-9_]/g, "_").replace(/^(\d)/, "_$1");
|
|
8641
9550
|
}
|
|
8642
9551
|
function nativeSourceDescriptor(packagePath) {
|
|
8643
|
-
packagePath =
|
|
8644
|
-
const file =
|
|
8645
|
-
if (!
|
|
9552
|
+
packagePath = import_node_fs15.default.realpathSync(packagePath);
|
|
9553
|
+
const file = import_node_path15.default.join(packagePath, NATIVE_DESCRIPTOR);
|
|
9554
|
+
if (!import_node_fs15.default.existsSync(file)) return null;
|
|
8646
9555
|
const value = JSON.parse(
|
|
8647
9556
|
readPackageFile(packagePath, file, MAX_SWIFT_COMPILE_SOURCE_BYTES).toString("utf8")
|
|
8648
9557
|
);
|
|
8649
9558
|
const invalid = () => new Error(`${file}: invalid One native source descriptor; run one typegen`);
|
|
8650
|
-
if (!value || typeof value !== "object" || Reflect.get(value, "generatedBy") !== "one typegen" || !
|
|
9559
|
+
if (!value || typeof value !== "object" || Reflect.get(value, "generatedBy") !== "one typegen" || !import_node_fs15.default.existsSync(import_node_path15.default.join(packagePath, NATIVE_GLUE))) {
|
|
8651
9560
|
throw invalid();
|
|
8652
9561
|
}
|
|
8653
9562
|
if (!isSwiftNativeModules(value) || value.packageId !== swiftPackageId(packagePath)) {
|
|
@@ -8657,7 +9566,7 @@ function nativeSourceDescriptor(packagePath) {
|
|
|
8657
9566
|
}
|
|
8658
9567
|
var projects = /* @__PURE__ */ new Map();
|
|
8659
9568
|
function projectFor(packagePath, hosted) {
|
|
8660
|
-
packagePath =
|
|
9569
|
+
packagePath = import_node_fs15.default.realpathSync(packagePath);
|
|
8661
9570
|
const existing = projects.get(packagePath);
|
|
8662
9571
|
if (existing) {
|
|
8663
9572
|
if (hosted && !existing.hosted) {
|
|
@@ -8677,52 +9586,130 @@ function projectFor(packagePath, hosted) {
|
|
|
8677
9586
|
projects.set(packagePath, created);
|
|
8678
9587
|
return created;
|
|
8679
9588
|
}
|
|
9589
|
+
var xcodeProjects = /* @__PURE__ */ new Map();
|
|
9590
|
+
function remotePackages(entry, app) {
|
|
9591
|
+
if (!entry.provided) return { targets: [], unavailable: /* @__PURE__ */ new Map() };
|
|
9592
|
+
const key = JSON.stringify([
|
|
9593
|
+
app.remoteProducts,
|
|
9594
|
+
app.packageResolved,
|
|
9595
|
+
app.packageResolved ? import_node_fs15.default.statSync(app.packageResolved).mtimeMs : 0
|
|
9596
|
+
]);
|
|
9597
|
+
if (entry.remote?.key !== key) {
|
|
9598
|
+
entry.remote = {
|
|
9599
|
+
key,
|
|
9600
|
+
packages: resolveRemotePackages(
|
|
9601
|
+
import_node_fs15.default.realpathSync(app.projectDir),
|
|
9602
|
+
app.packageResolved,
|
|
9603
|
+
app.remoteProducts,
|
|
9604
|
+
entry.provided
|
|
9605
|
+
)
|
|
9606
|
+
};
|
|
9607
|
+
}
|
|
9608
|
+
return entry.remote.packages;
|
|
9609
|
+
}
|
|
9610
|
+
var XCODE_APP_DIR = "__app__";
|
|
9611
|
+
var XCODE_PACKAGES_DIR = "__packages__";
|
|
9612
|
+
var CHECKOUTS_PREFIX = `${REMOTE_CHECKOUTS.split(import_node_path15.default.sep).join(import_node_path15.default.posix.sep)}/`;
|
|
9613
|
+
function xcodeInputKey(appSources, file, relative2) {
|
|
9614
|
+
if (appSources.has(file)) return import_node_path15.default.posix.join(XCODE_APP_DIR, relative2);
|
|
9615
|
+
return relative2.startsWith(CHECKOUTS_PREFIX) ? import_node_path15.default.posix.join(XCODE_PACKAGES_DIR, relative2.slice(CHECKOUTS_PREFIX.length)) : relative2;
|
|
9616
|
+
}
|
|
9617
|
+
function xcodeLayout(root) {
|
|
9618
|
+
const registered = xcodeProjects.get(root);
|
|
9619
|
+
if (!registered) return null;
|
|
9620
|
+
const app = readXcodeAppTarget(registered.xcodeproj, registered.target);
|
|
9621
|
+
const files = /* @__PURE__ */ new Set([app.pbxproj, ...app.sources, ...app.resources]);
|
|
9622
|
+
const targets = [];
|
|
9623
|
+
for (const dir of app.localPackages) {
|
|
9624
|
+
const manifest = import_node_path15.default.join(dir, "Package.swift");
|
|
9625
|
+
files.add(manifest);
|
|
9626
|
+
const prefix = import_node_path15.default.relative(root, dir).split(import_node_path15.default.sep).join(import_node_path15.default.posix.sep);
|
|
9627
|
+
const all = packageFiles(dir).map(
|
|
9628
|
+
(file) => import_node_path15.default.relative(dir, file).split(import_node_path15.default.sep).join(import_node_path15.default.posix.sep)
|
|
9629
|
+
);
|
|
9630
|
+
for (const target of swiftManifestTargets(import_node_fs15.default.readFileSync(manifest, "utf8"), all)) {
|
|
9631
|
+
if (target.executable) continue;
|
|
9632
|
+
targets.push({ ...target, path: import_node_path15.default.posix.join(prefix, target.path) });
|
|
9633
|
+
for (const relative2 of all) {
|
|
9634
|
+
if (relative2.startsWith(`${target.path}/`)) files.add(import_node_path15.default.join(dir, relative2));
|
|
9635
|
+
}
|
|
9636
|
+
}
|
|
9637
|
+
}
|
|
9638
|
+
const remote = remotePackages(registered, app);
|
|
9639
|
+
for (const target of remote.targets) {
|
|
9640
|
+
targets.push({
|
|
9641
|
+
...target,
|
|
9642
|
+
path: import_node_path15.default.posix.join(
|
|
9643
|
+
XCODE_PACKAGES_DIR,
|
|
9644
|
+
import_node_path15.default.relative(import_node_path15.default.join(root, REMOTE_CHECKOUTS), target.dir).split(import_node_path15.default.sep).join(import_node_path15.default.posix.sep)
|
|
9645
|
+
)
|
|
9646
|
+
});
|
|
9647
|
+
for (const file of target.files) files.add(file);
|
|
9648
|
+
}
|
|
9649
|
+
return { app, targets, unavailable: remote.unavailable, files: [...files].sort() };
|
|
9650
|
+
}
|
|
9651
|
+
function xcodeManifest(layout) {
|
|
9652
|
+
const settings = (mode, mainActor) => `swiftSettings: [.swiftLanguageMode(.v${mode})${mainActor ? ", .defaultIsolation(MainActor.self)" : ""}]`;
|
|
9653
|
+
return [
|
|
9654
|
+
"// swift-tools-version: 6.2",
|
|
9655
|
+
"import PackageDescription",
|
|
9656
|
+
'let package = Package(name: "app", targets: [',
|
|
9657
|
+
` .executableTarget(name: "${layout.app.moduleName}", path: "${XCODE_APP_DIR}", ${settings(layout.app.languageMode, layout.app.mainActorIsolation)}),`,
|
|
9658
|
+
...layout.targets.map(
|
|
9659
|
+
(target) => ` .target(name: "${target.name}", path: "${target.path}", ${target.resources ? "resources: [], " : ""}${settings(target.languageMode, target.mainActorIsolation)}),`
|
|
9660
|
+
),
|
|
9661
|
+
"])",
|
|
9662
|
+
""
|
|
9663
|
+
].join("\n");
|
|
9664
|
+
}
|
|
8680
9665
|
function packageFiles(root) {
|
|
8681
|
-
const canonicalRoot =
|
|
9666
|
+
const canonicalRoot = import_node_fs15.default.realpathSync(root);
|
|
9667
|
+
const xcode = xcodeLayout(canonicalRoot);
|
|
9668
|
+
if (xcode) return xcode.files;
|
|
8682
9669
|
const found = [];
|
|
8683
|
-
const
|
|
8684
|
-
for (const entry of
|
|
9670
|
+
const walk2 = (dir) => {
|
|
9671
|
+
for (const entry of import_node_fs15.default.readdirSync(dir, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
|
|
8685
9672
|
if (entry.name.startsWith(".") && entry.name !== NATIVE_DESCRIPTOR && entry.name !== NATIVE_GLUE || SKIP_SOURCE_DIRS.has(entry.name))
|
|
8686
9673
|
continue;
|
|
8687
|
-
const full =
|
|
9674
|
+
const full = import_node_path15.default.join(dir, entry.name);
|
|
8688
9675
|
if (entry.isSymbolicLink()) throw new Error(`swift input is a symlink: ${full}`);
|
|
8689
|
-
const real =
|
|
8690
|
-
const relative2 =
|
|
8691
|
-
if (relative2.startsWith(`..${
|
|
9676
|
+
const real = import_node_fs15.default.realpathSync(full);
|
|
9677
|
+
const relative2 = import_node_path15.default.relative(canonicalRoot, real);
|
|
9678
|
+
if (relative2.startsWith(`..${import_node_path15.default.sep}`) || relative2 === ".." || import_node_path15.default.isAbsolute(relative2)) {
|
|
8692
9679
|
throw new Error(`swift input escapes the selected package: ${full}`);
|
|
8693
9680
|
}
|
|
8694
9681
|
if (entry.isDirectory()) {
|
|
8695
|
-
if (
|
|
8696
|
-
|
|
9682
|
+
if (import_node_fs15.default.existsSync(import_node_path15.default.join(full, "Package.swift"))) continue;
|
|
9683
|
+
walk2(full);
|
|
8697
9684
|
} else if (entry.isFile()) {
|
|
8698
9685
|
found.push(full);
|
|
8699
9686
|
if (found.length > 4096) throw new Error("swift package exceeds 4096 input files");
|
|
8700
9687
|
}
|
|
8701
9688
|
}
|
|
8702
9689
|
};
|
|
8703
|
-
|
|
9690
|
+
walk2(canonicalRoot);
|
|
8704
9691
|
return found;
|
|
8705
9692
|
}
|
|
8706
9693
|
function readPackageFile(root, file, maxBytes) {
|
|
8707
|
-
const canonicalRoot =
|
|
8708
|
-
const relative2 =
|
|
8709
|
-
if (relative2 === ".." || relative2.startsWith(`..${
|
|
9694
|
+
const canonicalRoot = import_node_fs15.default.realpathSync(root);
|
|
9695
|
+
const relative2 = import_node_path15.default.relative(canonicalRoot, import_node_fs15.default.realpathSync(file));
|
|
9696
|
+
if (relative2 === ".." || relative2.startsWith(`..${import_node_path15.default.sep}`) || import_node_path15.default.isAbsolute(relative2)) {
|
|
8710
9697
|
throw new Error(`swift input escapes the selected package: ${file}`);
|
|
8711
9698
|
}
|
|
8712
|
-
let ancestor =
|
|
9699
|
+
let ancestor = import_node_path15.default.resolve(file);
|
|
8713
9700
|
while (ancestor !== canonicalRoot) {
|
|
8714
|
-
if (
|
|
9701
|
+
if (import_node_fs15.default.lstatSync(ancestor).isSymbolicLink()) {
|
|
8715
9702
|
throw new Error(`swift input is a symlink: ${ancestor}`);
|
|
8716
9703
|
}
|
|
8717
|
-
const parent =
|
|
9704
|
+
const parent = import_node_path15.default.dirname(ancestor);
|
|
8718
9705
|
if (parent === ancestor)
|
|
8719
9706
|
throw new Error(`swift input escapes the selected package: ${file}`);
|
|
8720
9707
|
ancestor = parent;
|
|
8721
9708
|
}
|
|
8722
|
-
const expected =
|
|
8723
|
-
const fd =
|
|
9709
|
+
const expected = import_node_fs15.default.statSync(file);
|
|
9710
|
+
const fd = import_node_fs15.default.openSync(file, import_node_fs15.default.constants.O_RDONLY | import_node_fs15.default.constants.O_NOFOLLOW);
|
|
8724
9711
|
try {
|
|
8725
|
-
const stat2 =
|
|
9712
|
+
const stat2 = import_node_fs15.default.fstatSync(fd);
|
|
8726
9713
|
if (stat2.dev !== expected.dev || stat2.ino !== expected.ino) {
|
|
8727
9714
|
throw new Error(`swift input changed while opening: ${file}`);
|
|
8728
9715
|
}
|
|
@@ -8732,28 +9719,43 @@ function readPackageFile(root, file, maxBytes) {
|
|
|
8732
9719
|
const bytes = Buffer.alloc(stat2.size + 1);
|
|
8733
9720
|
let offset = 0;
|
|
8734
9721
|
while (offset < bytes.length) {
|
|
8735
|
-
const count =
|
|
9722
|
+
const count = import_node_fs15.default.readSync(fd, bytes, offset, bytes.length - offset, null);
|
|
8736
9723
|
if (count === 0) break;
|
|
8737
9724
|
offset += count;
|
|
8738
9725
|
}
|
|
8739
|
-
if (offset !== stat2.size ||
|
|
9726
|
+
if (offset !== stat2.size || import_node_fs15.default.fstatSync(fd).size !== stat2.size) {
|
|
8740
9727
|
throw new Error(`swift input changed while reading: ${file}`);
|
|
8741
9728
|
}
|
|
8742
9729
|
return bytes.subarray(0, offset);
|
|
8743
9730
|
} finally {
|
|
8744
|
-
|
|
9731
|
+
import_node_fs15.default.closeSync(fd);
|
|
8745
9732
|
}
|
|
8746
9733
|
}
|
|
8747
9734
|
function sourceFiles(root) {
|
|
8748
|
-
|
|
8749
|
-
if (files.length > MAX_SWIFT_COMPILE_FILES || files.reduce((total, file) => total + import_node_fs13.default.statSync(file).size, 0) > MAX_SWIFT_COMPILE_SOURCE_BYTES) {
|
|
8750
|
-
throw new Error("swift sources exceed the compile service caps");
|
|
8751
|
-
}
|
|
8752
|
-
return files;
|
|
9735
|
+
return packageFiles(root).filter((file) => file.endsWith(".swift"));
|
|
8753
9736
|
}
|
|
8754
9737
|
function resourceCandidateFiles(root) {
|
|
8755
|
-
return packageFiles(root).filter(
|
|
9738
|
+
return packageFiles(root).filter(
|
|
9739
|
+
(file) => !file.endsWith(".swift") && import_node_path15.default.basename(file) !== "project.pbxproj"
|
|
9740
|
+
);
|
|
8756
9741
|
}
|
|
9742
|
+
var HOSTED_LIMITS = {
|
|
9743
|
+
resources: MAX_SWIFT_COMPILE_RESOURCES,
|
|
9744
|
+
resourceBytes: MAX_SWIFT_COMPILE_RESOURCE_BYTES,
|
|
9745
|
+
resourceTotalBytes: MAX_SWIFT_COMPILE_RESOURCE_TOTAL_BYTES,
|
|
9746
|
+
images: MAX_SWIFT_COMPILE_IMAGES,
|
|
9747
|
+
imageBytes: MAX_SWIFT_COMPILE_IMAGE_BYTES,
|
|
9748
|
+
imageTotalBytes: MAX_SWIFT_COMPILE_IMAGE_TOTAL_BYTES
|
|
9749
|
+
};
|
|
9750
|
+
var LOCAL_LIMITS = {
|
|
9751
|
+
resources: Infinity,
|
|
9752
|
+
resourceBytes: Infinity,
|
|
9753
|
+
resourceTotalBytes: Infinity,
|
|
9754
|
+
images: Infinity,
|
|
9755
|
+
imageBytes: Infinity,
|
|
9756
|
+
imageTotalBytes: Infinity
|
|
9757
|
+
};
|
|
9758
|
+
var inputLimits = (hosted) => hosted ? HOSTED_LIMITS : LOCAL_LIMITS;
|
|
8757
9759
|
var RESOURCE_CONTENT_TYPES = {
|
|
8758
9760
|
".avif": "image/avif",
|
|
8759
9761
|
".bmp": "image/bmp",
|
|
@@ -8765,20 +9767,19 @@ var RESOURCE_CONTENT_TYPES = {
|
|
|
8765
9767
|
".webp": "image/webp"
|
|
8766
9768
|
};
|
|
8767
9769
|
function buildSwiftResourceTable(project, baseUrl) {
|
|
9770
|
+
const limits = inputLimits(Boolean(project.hosted));
|
|
8768
9771
|
const absolute = resourceCandidateFiles(project.packagePath);
|
|
8769
9772
|
const relative2 = absolute.map(
|
|
8770
|
-
(file) =>
|
|
9773
|
+
(file) => import_node_path15.default.relative(project.packagePath, file).split(import_node_path15.default.sep).join(import_node_path15.default.posix.sep)
|
|
8771
9774
|
);
|
|
8772
9775
|
const byRelative = new Map(absolute.map((file, index) => [relative2[index], file]));
|
|
8773
9776
|
const readContents = (candidate) => {
|
|
8774
9777
|
const file = byRelative.get(candidate);
|
|
8775
9778
|
if (!file || !/(^|\/)Contents\.json$|\.symbolset\/[^/]+\.svg$/.test(candidate))
|
|
8776
9779
|
return null;
|
|
8777
|
-
return readPackageFile(
|
|
8778
|
-
|
|
8779
|
-
|
|
8780
|
-
MAX_SWIFT_COMPILE_RESOURCE_BYTES
|
|
8781
|
-
).toString("utf8");
|
|
9780
|
+
return readPackageFile(project.packagePath, file, limits.resourceBytes).toString(
|
|
9781
|
+
"utf8"
|
|
9782
|
+
);
|
|
8782
9783
|
};
|
|
8783
9784
|
const found = enumerateBundleImages(relative2, readContents);
|
|
8784
9785
|
const colors = enumerateBundleColors(relative2, readContents);
|
|
@@ -8791,20 +9792,16 @@ function buildSwiftResourceTable(project, baseUrl) {
|
|
|
8791
9792
|
for (const { name: name2, file, scale } of found) {
|
|
8792
9793
|
const disk = byRelative.get(file);
|
|
8793
9794
|
if (!disk) continue;
|
|
8794
|
-
if (Object.keys(images).length >=
|
|
9795
|
+
if (Object.keys(images).length >= limits.images || imageBytes + import_node_fs15.default.statSync(disk).size > limits.imageTotalBytes) {
|
|
8795
9796
|
throw new Error("swift image pack exceeds the compile service caps");
|
|
8796
9797
|
}
|
|
8797
|
-
const bytes = readPackageFile(
|
|
8798
|
-
project.packagePath,
|
|
8799
|
-
disk,
|
|
8800
|
-
MAX_SWIFT_COMPILE_IMAGE_BYTES
|
|
8801
|
-
);
|
|
9798
|
+
const bytes = readPackageFile(project.packagePath, disk, limits.imageBytes);
|
|
8802
9799
|
imageBytes += bytes.length;
|
|
8803
9800
|
const hash = (0, import_node_crypto5.createHash)("sha256").update(bytes).digest("hex").slice(0, 16);
|
|
8804
|
-
const ext =
|
|
9801
|
+
const ext = import_node_path15.default.posix.extname(file).toLowerCase();
|
|
8805
9802
|
table[name2] = { uri: `${baseUrl}${RESOURCE_PATH}${hash}${ext}`, scale };
|
|
8806
9803
|
images[name2] = {
|
|
8807
|
-
file:
|
|
9804
|
+
file: import_node_path15.default.posix.basename(file),
|
|
8808
9805
|
data: bytes.toString("base64")
|
|
8809
9806
|
};
|
|
8810
9807
|
watched.push(file);
|
|
@@ -8827,26 +9824,24 @@ function buildSwiftResourceTable(project, baseUrl) {
|
|
|
8827
9824
|
}
|
|
8828
9825
|
return { table, images, colors, symbols, watched };
|
|
8829
9826
|
}
|
|
8830
|
-
|
|
8831
|
-
|
|
8832
|
-
|
|
8833
|
-
function buildSwiftBundleFiles(packagePath) {
|
|
8834
|
-
packagePath = import_node_fs13.default.realpathSync(packagePath);
|
|
9827
|
+
function buildSwiftBundleFiles(packagePath, hosted) {
|
|
9828
|
+
packagePath = import_node_fs15.default.realpathSync(packagePath);
|
|
9829
|
+
const limits = inputLimits(hosted);
|
|
8835
9830
|
const relative2 = resourceCandidateFiles(packagePath).map(
|
|
8836
|
-
(file) =>
|
|
9831
|
+
(file) => import_node_path15.default.relative(packagePath, file).split(import_node_path15.default.sep).join(import_node_path15.default.posix.sep)
|
|
8837
9832
|
);
|
|
8838
9833
|
const files = {};
|
|
8839
9834
|
const watched = [];
|
|
8840
9835
|
let total = 0;
|
|
8841
9836
|
for (const { base, file } of enumerateBundleJson(relative2)) {
|
|
8842
9837
|
watched.push(file);
|
|
8843
|
-
const disk =
|
|
8844
|
-
if (Object.keys(files).length >=
|
|
9838
|
+
const disk = import_node_path15.default.join(packagePath, ...file.split("/"));
|
|
9839
|
+
if (Object.keys(files).length >= limits.resources || total + import_node_fs15.default.statSync(disk).size > limits.resourceTotalBytes) {
|
|
8845
9840
|
throw new Error(
|
|
8846
|
-
`swift bundle pack exceeds ${
|
|
9841
|
+
`swift bundle pack exceeds ${limits.resources} files / ${limits.resourceTotalBytes} bytes`
|
|
8847
9842
|
);
|
|
8848
9843
|
}
|
|
8849
|
-
const bytes = readPackageFile(packagePath, disk,
|
|
9844
|
+
const bytes = readPackageFile(packagePath, disk, limits.resourceBytes);
|
|
8850
9845
|
files[base] = bytes.toString("base64");
|
|
8851
9846
|
total += bytes.length;
|
|
8852
9847
|
}
|
|
@@ -8856,12 +9851,12 @@ function serveSwiftResource(project, key) {
|
|
|
8856
9851
|
return project.resourceFiles.get(key) ?? project.resourcesPrevious.get(key) ?? null;
|
|
8857
9852
|
}
|
|
8858
9853
|
function linkedModuleRoots(packagePath) {
|
|
8859
|
-
packagePath =
|
|
9854
|
+
packagePath = import_node_fs15.default.realpathSync(packagePath);
|
|
8860
9855
|
let manifest;
|
|
8861
9856
|
try {
|
|
8862
9857
|
manifest = readPackageFile(
|
|
8863
9858
|
packagePath,
|
|
8864
|
-
|
|
9859
|
+
import_node_path15.default.join(packagePath, "Package.swift"),
|
|
8865
9860
|
MAX_SWIFT_COMPILE_SOURCE_BYTES
|
|
8866
9861
|
).toString("utf8");
|
|
8867
9862
|
} catch {
|
|
@@ -8870,8 +9865,8 @@ function linkedModuleRoots(packagePath) {
|
|
|
8870
9865
|
const roots = /* @__PURE__ */ new Set();
|
|
8871
9866
|
const dependency = /\.package\(\s*path:\s*"([^"]+)"\s*\)/g;
|
|
8872
9867
|
for (const match of manifest.replace(/^\s*\/\/.*$/gm, "").matchAll(dependency)) {
|
|
8873
|
-
const root =
|
|
8874
|
-
if (
|
|
9868
|
+
const root = import_node_path15.default.resolve(packagePath, match[1]);
|
|
9869
|
+
if (import_node_fs15.default.existsSync(import_node_path15.default.join(root, "Package.swift"))) roots.add(root);
|
|
8875
9870
|
}
|
|
8876
9871
|
return [...roots].sort();
|
|
8877
9872
|
}
|
|
@@ -8880,18 +9875,18 @@ function sourceStamp(packagePath, moduleRootOverride, hosted = false) {
|
|
|
8880
9875
|
hash.update(packagePath);
|
|
8881
9876
|
const projectInputs = new Set(packageFiles(packagePath));
|
|
8882
9877
|
for (const file of [...projectInputs].sort()) {
|
|
8883
|
-
hash.update(
|
|
8884
|
-
const stat2 =
|
|
9878
|
+
hash.update(import_node_path15.default.relative(packagePath, file));
|
|
9879
|
+
const stat2 = import_node_fs15.default.statSync(file);
|
|
8885
9880
|
hash.update(`${stat2.mtimeMs}/${stat2.ctimeMs}/${stat2.size}`);
|
|
8886
9881
|
}
|
|
8887
9882
|
const moduleRoot = hosted ? void 0 : moduleRootOverride ?? linkedModuleRoots(packagePath).find(
|
|
8888
|
-
(root) =>
|
|
9883
|
+
(root) => import_node_fs15.default.existsSync(import_node_path15.default.join(root, "toolchain.json"))
|
|
8889
9884
|
);
|
|
8890
9885
|
if (moduleRoot) {
|
|
8891
9886
|
hash.update(moduleRoot);
|
|
8892
9887
|
for (const relative2 of swiftModuleInputFiles(moduleRoot)) {
|
|
8893
9888
|
hash.update(relative2);
|
|
8894
|
-
hash.update(String(
|
|
9889
|
+
hash.update(String(import_node_fs15.default.statSync(import_node_path15.default.join(moduleRoot, relative2)).mtimeMs));
|
|
8895
9890
|
}
|
|
8896
9891
|
}
|
|
8897
9892
|
return hash.digest("hex").slice(0, 16);
|
|
@@ -8900,22 +9895,19 @@ function icuUrl(origin, artifact) {
|
|
|
8900
9895
|
return "url" in artifact.icu ? artifact.icu.url : `${origin}${ICU_PATH}${artifact.icu.sha256}`;
|
|
8901
9896
|
}
|
|
8902
9897
|
function packageSources(packagePath) {
|
|
8903
|
-
const
|
|
8904
|
-
|
|
8905
|
-
throw new Error("swift source file cap exceeded");
|
|
8906
|
-
let total = 0;
|
|
8907
|
-
for (const file of sources) total += import_node_fs13.default.statSync(file).size;
|
|
8908
|
-
if (total > MAX_SWIFT_COMPILE_SOURCE_BYTES)
|
|
8909
|
-
throw new Error("swift source byte cap exceeded");
|
|
9898
|
+
const xcode = xcodeLayout(packagePath);
|
|
9899
|
+
const appSources = new Set(xcode?.app.sources);
|
|
8910
9900
|
const files = {};
|
|
8911
|
-
for (const file of
|
|
8912
|
-
const relative2 =
|
|
8913
|
-
|
|
9901
|
+
for (const file of sourceFiles(packagePath)) {
|
|
9902
|
+
const relative2 = import_node_path15.default.relative(packagePath, file).split(import_node_path15.default.sep).join(import_node_path15.default.posix.sep);
|
|
9903
|
+
if (xcode && import_node_path15.default.basename(file) === "Package.swift") continue;
|
|
9904
|
+
files[xcode ? xcodeInputKey(appSources, file, relative2) : relative2] = readPackageFile(
|
|
8914
9905
|
packagePath,
|
|
8915
9906
|
file,
|
|
8916
9907
|
MAX_SWIFT_COMPILE_SOURCE_BYTES
|
|
8917
9908
|
).toString("utf8");
|
|
8918
9909
|
}
|
|
9910
|
+
if (xcode) files["Package.swift"] = xcodeManifest(xcode);
|
|
8919
9911
|
return files;
|
|
8920
9912
|
}
|
|
8921
9913
|
function packageSnapshot(project) {
|
|
@@ -8925,16 +9917,16 @@ function packageSnapshot(project) {
|
|
|
8925
9917
|
files,
|
|
8926
9918
|
resourcePaths: swiftImplicitResourcePaths(
|
|
8927
9919
|
resourceCandidateFiles(project.packagePath).map(
|
|
8928
|
-
(file) =>
|
|
9920
|
+
(file) => import_node_path15.default.relative(project.packagePath, file).split(import_node_path15.default.sep).join(import_node_path15.default.posix.sep)
|
|
8929
9921
|
)
|
|
8930
9922
|
),
|
|
8931
9923
|
resources: buildSwiftResourceTable(project, ""),
|
|
8932
|
-
bundleFiles: buildSwiftBundleFiles(project.packagePath),
|
|
9924
|
+
bundleFiles: buildSwiftBundleFiles(project.packagePath, Boolean(project.hosted)),
|
|
8933
9925
|
native,
|
|
8934
9926
|
...native ? {
|
|
8935
9927
|
glue: readPackageFile(
|
|
8936
9928
|
project.packagePath,
|
|
8937
|
-
|
|
9929
|
+
import_node_path15.default.join(project.packagePath, NATIVE_GLUE),
|
|
8938
9930
|
MAX_SWIFT_COMPILE_SOURCE_BYTES
|
|
8939
9931
|
).toString("utf8")
|
|
8940
9932
|
} : {}
|
|
@@ -8970,7 +9962,7 @@ async function compile(packagePath, entry, stamp, moduleRootOverride, hosted, sn
|
|
|
8970
9962
|
package: content
|
|
8971
9963
|
};
|
|
8972
9964
|
const moduleRoot = moduleRootOverride ?? linkedModuleRoots(packagePath).find(
|
|
8973
|
-
(root) =>
|
|
9965
|
+
(root) => import_node_fs15.default.existsSync(import_node_path15.default.join(root, "toolchain.json"))
|
|
8974
9966
|
) ?? await swiftDistributionRoot();
|
|
8975
9967
|
if (!moduleRoot)
|
|
8976
9968
|
return {
|
|
@@ -8979,27 +9971,112 @@ async function compile(packagePath, entry, stamp, moduleRootOverride, hosted, sn
|
|
|
8979
9971
|
package: content
|
|
8980
9972
|
};
|
|
8981
9973
|
const toolchain = swiftModuleToolchain(moduleRoot);
|
|
8982
|
-
const
|
|
9974
|
+
const input = snapshotCompileInput(snapshot, entry);
|
|
9975
|
+
const targets = compileTargets(input).map((target) => target.name);
|
|
9976
|
+
const missing = missingSwiftModules(
|
|
9977
|
+
input.files,
|
|
9978
|
+
/* @__PURE__ */ new Set([
|
|
9979
|
+
...swiftAvailableModules(moduleRoot, toolchain.toolchainBin),
|
|
9980
|
+
// a project without a manifest compiles as the template's one App target
|
|
9981
|
+
...targets.length > 0 ? targets : ["App"]
|
|
9982
|
+
])
|
|
9983
|
+
);
|
|
9984
|
+
if (missing.size > 0) throw new Error(missingModulesMessage(packagePath, missing));
|
|
9985
|
+
const artifact = await compileSwiftProjectUnit(input, {
|
|
8983
9986
|
// the compile rewrites Sources/App in its root before swiftpm builds, and
|
|
8984
9987
|
// its lock orders one process only: two vites on one root (a lane's dev
|
|
8985
9988
|
// server and a capture, or two checkouts) build each other's sources. so
|
|
8986
9989
|
// each app and module checkout gets its own root, which keeps the same
|
|
8987
9990
|
// app's incremental build across restarts.
|
|
8988
|
-
buildRoot: process.env.CONTRAST_SWIFT_BUILD_ROOT ??
|
|
9991
|
+
buildRoot: process.env.CONTRAST_SWIFT_BUILD_ROOT ?? import_node_path15.default.join(
|
|
8989
9992
|
import_node_os5.default.tmpdir(),
|
|
8990
9993
|
"contrast-swift-build",
|
|
8991
|
-
(0, import_node_crypto5.createHash)("sha256").update(`${moduleRoot}\0${
|
|
9994
|
+
(0, import_node_crypto5.createHash)("sha256").update(`${moduleRoot}\0${import_node_path15.default.resolve(packagePath)}`).digest("hex").slice(0, 16)
|
|
8992
9995
|
),
|
|
8993
9996
|
moduleRoot,
|
|
8994
9997
|
...toolchain
|
|
9998
|
+
}).catch((error) => {
|
|
9999
|
+
const report = error instanceof Error ? swiftApiGapReport(error.message) : null;
|
|
10000
|
+
throw report ? new Error(`${error instanceof Error ? error.message : ""}
|
|
10001
|
+
|
|
10002
|
+
${report}`, {
|
|
10003
|
+
cause: error
|
|
10004
|
+
}) : error;
|
|
8995
10005
|
});
|
|
8996
10006
|
return { ...artifact, stamp, package: content };
|
|
8997
10007
|
}
|
|
10008
|
+
var API_GAP_PATTERNS = [
|
|
10009
|
+
[/^cannot find (?:type )?'([^']+)' in scope/, (match) => match[1]],
|
|
10010
|
+
// a typealias reports its aliased type after `aka`, which is the api's owner
|
|
10011
|
+
[
|
|
10012
|
+
/^(?:value of )?type '([^']+)'(?: \(aka '([^']+)'\))? has no member '([^']+)'/,
|
|
10013
|
+
(match) => `${(match[2] ?? match[1]).replace(/^Optional<(.+)>$/, "$1").replace(/\?$/, "")}.${match[3]}`
|
|
10014
|
+
],
|
|
10015
|
+
[
|
|
10016
|
+
/^module '([^']+)' has no member named '([^']+)'/,
|
|
10017
|
+
(match) => `${match[1]}.${match[2]}`
|
|
10018
|
+
],
|
|
10019
|
+
[/^'([^']+)' is unavailable/, (match) => match[1]],
|
|
10020
|
+
[/^no such module '([^']+)'/, (match) => `module ${match[1]}`]
|
|
10021
|
+
];
|
|
10022
|
+
function swiftApiGapReport(output) {
|
|
10023
|
+
const gaps = /* @__PURE__ */ new Map();
|
|
10024
|
+
const other = /* @__PURE__ */ new Map();
|
|
10025
|
+
const seen = /* @__PURE__ */ new Set();
|
|
10026
|
+
for (const line of output.split("\n")) {
|
|
10027
|
+
const diagnostic = /^(\S[^:]*\.swift):(\d+):(\d+): error: (.+)$/.exec(line);
|
|
10028
|
+
if (!diagnostic || seen.has(line)) continue;
|
|
10029
|
+
seen.add(line);
|
|
10030
|
+
const file = diagnostic[1].replace(new RegExp(`^${XCODE_APP_DIR}/`), "").replace(new RegExp(`^${XCODE_PACKAGES_DIR}/`), "");
|
|
10031
|
+
const message = diagnostic[4];
|
|
10032
|
+
const rule = API_GAP_PATTERNS.find(([pattern]) => pattern.test(message));
|
|
10033
|
+
const key = rule ? rule[1](rule[0].exec(message)) : message;
|
|
10034
|
+
const table = rule ? gaps : other;
|
|
10035
|
+
const entry = table.get(key) ?? { errors: 0, files: /* @__PURE__ */ new Set() };
|
|
10036
|
+
entry.errors++;
|
|
10037
|
+
entry.files.add(file);
|
|
10038
|
+
table.set(key, entry);
|
|
10039
|
+
}
|
|
10040
|
+
if (gaps.size === 0) return null;
|
|
10041
|
+
const rows = (table) => {
|
|
10042
|
+
const sorted = [...table].sort(
|
|
10043
|
+
([left, a], [right, b]) => b.errors - a.errors || left.localeCompare(right)
|
|
10044
|
+
);
|
|
10045
|
+
const width = Math.min(48, Math.max(...sorted.map(([key]) => key.length)));
|
|
10046
|
+
return sorted.map(
|
|
10047
|
+
([key, entry]) => ` ${key.padEnd(width)} ${String(entry.errors).padStart(3)} error${entry.errors === 1 ? " " : "s"} ${[...entry.files].sort().join(", ")}`
|
|
10048
|
+
);
|
|
10049
|
+
};
|
|
10050
|
+
const errors = [...gaps.values()].reduce((sum, entry) => sum + entry.errors, 0);
|
|
10051
|
+
return [
|
|
10052
|
+
`Peach lacks ${gaps.size} API${gaps.size === 1 ? "" : "s"} this app uses (${errors} error${errors === 1 ? "" : "s"}):`,
|
|
10053
|
+
...rows(gaps),
|
|
10054
|
+
...other.size > 0 ? ["other errors, often caused by the ones above:", ...rows(other)] : []
|
|
10055
|
+
].join("\n");
|
|
10056
|
+
}
|
|
10057
|
+
function missingModulesMessage(packagePath, missing) {
|
|
10058
|
+
const layout = xcodeLayout(packagePath);
|
|
10059
|
+
const remote = new Map(
|
|
10060
|
+
(layout?.app.remoteProducts ?? []).map((entry) => [
|
|
10061
|
+
entry.product,
|
|
10062
|
+
entry.repositoryURL
|
|
10063
|
+
])
|
|
10064
|
+
);
|
|
10065
|
+
const width = Math.max(...[...missing.keys()].map((name2) => name2.length));
|
|
10066
|
+
return [
|
|
10067
|
+
`Peach does not provide ${missing.size} module${missing.size === 1 ? "" : "s"} this app imports:`,
|
|
10068
|
+
...[...missing].map(([name2, files]) => {
|
|
10069
|
+
const source = remote.get(name2);
|
|
10070
|
+
const reason = layout?.unavailable.get(name2)?.reason;
|
|
10071
|
+
return ` ${name2.padEnd(width)} ${files.length} file${files.length === 1 ? "" : "s"}${source ? `, package ${source}` : ""}${reason ? ` (${reason})` : ""}`;
|
|
10072
|
+
})
|
|
10073
|
+
].join("\n");
|
|
10074
|
+
}
|
|
8998
10075
|
async function compileRemote(packagePath, entry, snapshot, hosted) {
|
|
8999
10076
|
const auth = hosted ? null : resolveCliAuth();
|
|
9000
10077
|
if (!hosted && (!auth || auth.kind === "github")) {
|
|
9001
10078
|
throw new Error(
|
|
9002
|
-
`compiling ${
|
|
10079
|
+
`compiling ${import_node_path15.default.basename(packagePath)} for Peach needs \`peach login\` or PEACH_API_KEY: this peachsim has no local SwiftUI module, so Contrast compiles it`
|
|
9003
10080
|
);
|
|
9004
10081
|
}
|
|
9005
10082
|
const origin = hosted?.origin ?? resolveContrastBackendOrigin(auth?.kind === "session" ? auth.origin : null);
|
|
@@ -9014,6 +10091,13 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
|
|
|
9014
10091
|
signal
|
|
9015
10092
|
});
|
|
9016
10093
|
if (!submit) throw new Error("swift compile: no credential to submit with");
|
|
10094
|
+
const sources = Object.values(snapshot.files);
|
|
10095
|
+
const bytes = sources.reduce((total2, text) => total2 + Buffer.byteLength(text), 0);
|
|
10096
|
+
if (sources.length > MAX_SWIFT_COMPILE_FILES || bytes > MAX_SWIFT_COMPILE_SOURCE_BYTES) {
|
|
10097
|
+
throw new Error(
|
|
10098
|
+
`${import_node_path15.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`
|
|
10099
|
+
);
|
|
10100
|
+
}
|
|
9017
10101
|
const descriptor = snapshot.native;
|
|
9018
10102
|
const address = await compileSwiftProject(
|
|
9019
10103
|
submit,
|
|
@@ -9030,7 +10114,7 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
|
|
|
9030
10114
|
);
|
|
9031
10115
|
if (descriptor && address.native?.hash !== descriptor.hash) {
|
|
9032
10116
|
throw new Error(
|
|
9033
|
-
`${
|
|
10117
|
+
`${import_node_path15.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`
|
|
9034
10118
|
);
|
|
9035
10119
|
}
|
|
9036
10120
|
const response = await fetch(address.url, { signal });
|
|
@@ -9149,13 +10233,13 @@ function serveSwiftPackageAsset(pathname, res) {
|
|
|
9149
10233
|
}
|
|
9150
10234
|
|
|
9151
10235
|
// src/expo-swift-host.ts
|
|
9152
|
-
var run3 = (0, import_node_util3.promisify)(
|
|
10236
|
+
var run3 = (0, import_node_util3.promisify)(import_node_child_process7.execFile);
|
|
9153
10237
|
var scriptEnv = { ...process.env, [RNX_FORKED_SCRIPT_ENV]: "1" };
|
|
9154
10238
|
var EXPO_SWIFT_ROUTE = "/__peach/expo-swift";
|
|
9155
10239
|
var EXPO_SWIFT_ENTRY = "Sources/PeachExpoApp/PeachExpoEntry.swift";
|
|
9156
10240
|
async function collectExpoSwiftSources(appRoot) {
|
|
9157
|
-
appRoot =
|
|
9158
|
-
const appRequire = (0, import_node_module.createRequire)(
|
|
10241
|
+
appRoot = import_node_fs16.default.realpathSync(appRoot);
|
|
10242
|
+
const appRequire = (0, import_node_module.createRequire)(import_node_path16.default.join(appRoot, "package.json"));
|
|
9159
10243
|
let autolinker;
|
|
9160
10244
|
try {
|
|
9161
10245
|
autolinker = appRequire.resolve("expo-modules-autolinking/package.json");
|
|
@@ -9169,7 +10253,7 @@ async function collectExpoSwiftSources(appRoot) {
|
|
|
9169
10253
|
(command) => run3(
|
|
9170
10254
|
process.execPath,
|
|
9171
10255
|
[
|
|
9172
|
-
|
|
10256
|
+
import_node_path16.default.join(import_node_path16.default.dirname(autolinker), "bin/expo-modules-autolinking.js"),
|
|
9173
10257
|
command,
|
|
9174
10258
|
"--platform",
|
|
9175
10259
|
"apple",
|
|
@@ -9200,8 +10284,8 @@ async function collectExpoSwiftSources(appRoot) {
|
|
|
9200
10284
|
const sourceRoot = Reflect.get(entry, "path");
|
|
9201
10285
|
if (typeof sourceRoot !== "string")
|
|
9202
10286
|
throw new Error("Expo autolinking entry has no path");
|
|
9203
|
-
const canonical =
|
|
9204
|
-
if (canonical.split(
|
|
10287
|
+
const canonical = import_node_fs16.default.realpathSync(sourceRoot);
|
|
10288
|
+
if (canonical.split(import_node_path16.default.sep).includes("node_modules")) continue;
|
|
9205
10289
|
const resolution = resolutions.find(
|
|
9206
10290
|
(candidate) => candidate && typeof candidate === "object" && Reflect.get(candidate, "packageName") === Reflect.get(entry, "name")
|
|
9207
10291
|
);
|
|
@@ -9227,29 +10311,29 @@ async function collectExpoSwiftSources(appRoot) {
|
|
|
9227
10311
|
`(${className.includes(".") ? className : `${namespace}.${className}`}.self, ${name2 === null ? "nil" : JSON.stringify(name2)})`
|
|
9228
10312
|
);
|
|
9229
10313
|
}
|
|
9230
|
-
const ios =
|
|
9231
|
-
if (
|
|
10314
|
+
const ios = import_node_path16.default.join(canonical, "ios");
|
|
10315
|
+
if (import_node_fs16.default.lstatSync(ios).isSymbolicLink())
|
|
9232
10316
|
throw new Error(`Expo Swift source directory is a symlink: ${ios}`);
|
|
9233
|
-
const
|
|
9234
|
-
for (const child of
|
|
9235
|
-
const file =
|
|
10317
|
+
const walk2 = (dir) => {
|
|
10318
|
+
for (const child of import_node_fs16.default.readdirSync(dir, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
10319
|
+
const file = import_node_path16.default.join(dir, child.name);
|
|
9236
10320
|
if (child.isSymbolicLink())
|
|
9237
10321
|
throw new Error(`Expo Swift source is a symlink: ${file}`);
|
|
9238
10322
|
if (child.isDirectory()) {
|
|
9239
|
-
if (!child.name.startsWith(".") && child.name !== "build")
|
|
10323
|
+
if (!child.name.startsWith(".") && child.name !== "build") walk2(file);
|
|
9240
10324
|
continue;
|
|
9241
10325
|
}
|
|
9242
10326
|
if (!child.name.endsWith(".swift")) continue;
|
|
9243
|
-
const size =
|
|
10327
|
+
const size = import_node_fs16.default.statSync(file).size;
|
|
9244
10328
|
bytes += size;
|
|
9245
10329
|
fileCount++;
|
|
9246
10330
|
if (fileCount > MAX_SWIFT_COMPILE_FILES - 2 || bytes > MAX_SWIFT_COMPILE_SOURCE_BYTES)
|
|
9247
10331
|
throw new Error("Expo Swift sources exceed compile service caps");
|
|
9248
|
-
files[`Sources/${namespace}/${
|
|
9249
|
-
${
|
|
10332
|
+
files[`Sources/${namespace}/${import_node_path16.default.relative(ios, file).split(import_node_path16.default.sep).join("/")}`] = `#sourceLocation(file: ${JSON.stringify(file)}, line: 1)
|
|
10333
|
+
${import_node_fs16.default.readFileSync(file, "utf8")}`;
|
|
9250
10334
|
}
|
|
9251
10335
|
};
|
|
9252
|
-
|
|
10336
|
+
walk2(ios);
|
|
9253
10337
|
const unit = { namespace, classes, files };
|
|
9254
10338
|
files[EXPO_SWIFT_ENTRY] = expoEntry([unit]);
|
|
9255
10339
|
units.push(unit);
|
|
@@ -9331,7 +10415,7 @@ async function handleExpoSwiftRequest(req, res) {
|
|
|
9331
10415
|
return true;
|
|
9332
10416
|
}
|
|
9333
10417
|
const root = url.searchParams.get("root");
|
|
9334
|
-
if (!root || !
|
|
10418
|
+
if (!root || !import_node_path16.default.isAbsolute(root)) {
|
|
9335
10419
|
res.writeHead(400);
|
|
9336
10420
|
res.end("missing absolute app root");
|
|
9337
10421
|
return true;
|
|
@@ -9348,7 +10432,7 @@ async function handleExpoSwiftRequest(req, res) {
|
|
|
9348
10432
|
modules: [],
|
|
9349
10433
|
failures: []
|
|
9350
10434
|
};
|
|
9351
|
-
const key = (0, import_node_crypto6.createHash)("sha256").update(
|
|
10435
|
+
const key = (0, import_node_crypto6.createHash)("sha256").update(import_node_fs16.default.realpathSync(root)).digest("hex");
|
|
9352
10436
|
const host2 = req.headers.host;
|
|
9353
10437
|
if (!host2) throw new Error("Expo Swift request has no host");
|
|
9354
10438
|
const base = `http://${host2}`;
|
|
@@ -9362,7 +10446,7 @@ async function handleExpoSwiftRequest(req, res) {
|
|
|
9362
10446
|
continue;
|
|
9363
10447
|
}
|
|
9364
10448
|
try {
|
|
9365
|
-
const packagePath =
|
|
10449
|
+
const packagePath = import_node_path16.default.join(
|
|
9366
10450
|
import_node_os6.default.tmpdir(),
|
|
9367
10451
|
"peach-expo-swift",
|
|
9368
10452
|
key,
|
|
@@ -9372,7 +10456,7 @@ async function handleExpoSwiftRequest(req, res) {
|
|
|
9372
10456
|
packagePath,
|
|
9373
10457
|
new Map(
|
|
9374
10458
|
Object.entries(unit.files).map(([name2, source]) => [
|
|
9375
|
-
|
|
10459
|
+
import_node_path16.default.join(packagePath, name2),
|
|
9376
10460
|
source
|
|
9377
10461
|
])
|
|
9378
10462
|
)
|
|
@@ -9423,7 +10507,7 @@ async function handleExpoSwiftRequest(req, res) {
|
|
|
9423
10507
|
import PackageDescription
|
|
9424
10508
|
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")])
|
|
9425
10509
|
`;
|
|
9426
|
-
const packagePath =
|
|
10510
|
+
const packagePath = import_node_path16.default.join(
|
|
9427
10511
|
import_node_os6.default.tmpdir(),
|
|
9428
10512
|
"peach-expo-swift",
|
|
9429
10513
|
key,
|
|
@@ -9433,7 +10517,7 @@ let package = Package(name: "PeachExpo", targets: [${targets.map((name2) => `.ta
|
|
|
9433
10517
|
packagePath,
|
|
9434
10518
|
new Map(
|
|
9435
10519
|
Object.entries(files).map(([name2, source]) => [
|
|
9436
|
-
|
|
10520
|
+
import_node_path16.default.join(packagePath, name2),
|
|
9437
10521
|
source
|
|
9438
10522
|
])
|
|
9439
10523
|
)
|
|
@@ -9607,19 +10691,19 @@ var rnxRuntime = createRuntimeDelivery(RNX_RUNTIME_PRODUCT);
|
|
|
9607
10691
|
|
|
9608
10692
|
// src/host/agent-host.ts
|
|
9609
10693
|
var import_node_crypto9 = require("node:crypto");
|
|
9610
|
-
var
|
|
9611
|
-
var
|
|
10694
|
+
var import_node_fs20 = __toESM(require("node:fs"), 1);
|
|
10695
|
+
var import_node_path20 = __toESM(require("node:path"), 1);
|
|
9612
10696
|
|
|
9613
10697
|
// src/agent-sessions.ts
|
|
9614
|
-
var
|
|
10698
|
+
var import_node_child_process8 = require("node:child_process");
|
|
9615
10699
|
var import_node_crypto8 = require("node:crypto");
|
|
9616
|
-
var
|
|
9617
|
-
var
|
|
10700
|
+
var import_node_fs19 = __toESM(require("node:fs"), 1);
|
|
10701
|
+
var import_node_path19 = __toESM(require("node:path"), 1);
|
|
9618
10702
|
var import_node_readline = __toESM(require("node:readline"), 1);
|
|
9619
10703
|
|
|
9620
10704
|
// cli/self-invocation.ts
|
|
9621
|
-
var
|
|
9622
|
-
var
|
|
10705
|
+
var import_node_fs17 = require("node:fs");
|
|
10706
|
+
var import_node_path17 = require("node:path");
|
|
9623
10707
|
var import_node_url3 = require("node:url");
|
|
9624
10708
|
init_public_brand();
|
|
9625
10709
|
|
|
@@ -9629,14 +10713,14 @@ var IS_STANDALONE = typeof __SOOTSIM_STANDALONE__ !== "undefined" && __SOOTSIM_S
|
|
|
9629
10713
|
// cli/self-invocation.ts
|
|
9630
10714
|
function sourceEntryPath() {
|
|
9631
10715
|
try {
|
|
9632
|
-
const candidate = (0,
|
|
9633
|
-
return (0,
|
|
10716
|
+
const candidate = (0, import_node_path17.join)((0, import_node_path17.dirname)((0, import_node_url3.fileURLToPath)(__sootsim_import_meta_url)), "bin.ts");
|
|
10717
|
+
return (0, import_node_fs17.existsSync)(candidate) ? candidate : null;
|
|
9634
10718
|
} catch {
|
|
9635
10719
|
return null;
|
|
9636
10720
|
}
|
|
9637
10721
|
}
|
|
9638
|
-
function isCliEntry(
|
|
9639
|
-
const name2 = (0,
|
|
10722
|
+
function isCliEntry(path20) {
|
|
10723
|
+
const name2 = (0, import_node_path17.basename)(path20);
|
|
9640
10724
|
return name2 === "bin.ts" || name2 === "bin.js";
|
|
9641
10725
|
}
|
|
9642
10726
|
function rnxSelfInvocation() {
|
|
@@ -9665,8 +10749,8 @@ function parseAgentEventLine(line) {
|
|
|
9665
10749
|
const trimmed = line.trim();
|
|
9666
10750
|
if (!trimmed) return null;
|
|
9667
10751
|
try {
|
|
9668
|
-
const
|
|
9669
|
-
return isAgentEvent(
|
|
10752
|
+
const parsed2 = JSON.parse(trimmed);
|
|
10753
|
+
return isAgentEvent(parsed2) ? parsed2 : null;
|
|
9670
10754
|
} catch {
|
|
9671
10755
|
return null;
|
|
9672
10756
|
}
|
|
@@ -9696,8 +10780,8 @@ function encodeAgentPromptEnvelope(input) {
|
|
|
9696
10780
|
|
|
9697
10781
|
// src/attached-projects.ts
|
|
9698
10782
|
var import_node_crypto7 = require("node:crypto");
|
|
9699
|
-
var
|
|
9700
|
-
var
|
|
10783
|
+
var import_node_fs18 = __toESM(require("node:fs"), 1);
|
|
10784
|
+
var import_node_path18 = __toESM(require("node:path"), 1);
|
|
9701
10785
|
init_home_paths();
|
|
9702
10786
|
var overrideDir = null;
|
|
9703
10787
|
function userDataDir() {
|
|
@@ -9710,7 +10794,7 @@ function getUserDataDir() {
|
|
|
9710
10794
|
return userDataDir();
|
|
9711
10795
|
}
|
|
9712
10796
|
function storeFile() {
|
|
9713
|
-
return
|
|
10797
|
+
return import_node_path18.default.join(userDataDir(), "attached-projects.json");
|
|
9714
10798
|
}
|
|
9715
10799
|
function cloneEmpty() {
|
|
9716
10800
|
return {
|
|
@@ -9724,24 +10808,24 @@ function loadStore() {
|
|
|
9724
10808
|
const file = storeFile();
|
|
9725
10809
|
let raw2;
|
|
9726
10810
|
try {
|
|
9727
|
-
raw2 =
|
|
10811
|
+
raw2 = import_node_fs18.default.readFileSync(file, "utf8");
|
|
9728
10812
|
} catch (err) {
|
|
9729
10813
|
if (err.code === "ENOENT") return cloneEmpty();
|
|
9730
10814
|
throw err;
|
|
9731
10815
|
}
|
|
9732
10816
|
try {
|
|
9733
|
-
const
|
|
9734
|
-
if (!
|
|
10817
|
+
const parsed2 = JSON.parse(raw2);
|
|
10818
|
+
if (!parsed2 || typeof parsed2 !== "object") throw new Error("not an object");
|
|
9735
10819
|
return {
|
|
9736
10820
|
version: 1,
|
|
9737
|
-
attachedProjects: Array.isArray(
|
|
9738
|
-
previewAttachments: Array.isArray(
|
|
9739
|
-
agentSessions: Array.isArray(
|
|
10821
|
+
attachedProjects: Array.isArray(parsed2.attachedProjects) ? parsed2.attachedProjects : [],
|
|
10822
|
+
previewAttachments: Array.isArray(parsed2.previewAttachments) ? parsed2.previewAttachments : [],
|
|
10823
|
+
agentSessions: Array.isArray(parsed2.agentSessions) ? parsed2.agentSessions : []
|
|
9740
10824
|
};
|
|
9741
10825
|
} catch (err) {
|
|
9742
10826
|
const quarantine = `${file}.corrupt-${Date.now()}`;
|
|
9743
10827
|
try {
|
|
9744
|
-
|
|
10828
|
+
import_node_fs18.default.renameSync(file, quarantine);
|
|
9745
10829
|
console.warn(
|
|
9746
10830
|
`[sootsim] attached-projects.json was unparseable; quarantined to ${quarantine}. original error: ${err.message}`
|
|
9747
10831
|
);
|
|
@@ -9752,16 +10836,16 @@ function loadStore() {
|
|
|
9752
10836
|
}
|
|
9753
10837
|
function writeStore(store) {
|
|
9754
10838
|
const file = storeFile();
|
|
9755
|
-
|
|
10839
|
+
import_node_fs18.default.mkdirSync(import_node_path18.default.dirname(file), { recursive: true });
|
|
9756
10840
|
const tmp = `${file}.tmp-${process.pid}-${Date.now()}`;
|
|
9757
|
-
const fd =
|
|
10841
|
+
const fd = import_node_fs18.default.openSync(tmp, "w", 384);
|
|
9758
10842
|
try {
|
|
9759
|
-
|
|
9760
|
-
|
|
10843
|
+
import_node_fs18.default.writeFileSync(fd, JSON.stringify(store, null, 2));
|
|
10844
|
+
import_node_fs18.default.fsyncSync(fd);
|
|
9761
10845
|
} finally {
|
|
9762
|
-
|
|
10846
|
+
import_node_fs18.default.closeSync(fd);
|
|
9763
10847
|
}
|
|
9764
|
-
|
|
10848
|
+
import_node_fs18.default.renameSync(tmp, file);
|
|
9765
10849
|
}
|
|
9766
10850
|
function mutateStore(fn) {
|
|
9767
10851
|
const store = loadStore();
|
|
@@ -9770,13 +10854,13 @@ function mutateStore(fn) {
|
|
|
9770
10854
|
return store;
|
|
9771
10855
|
}
|
|
9772
10856
|
function projectIdForCwd(cwd) {
|
|
9773
|
-
return (0, import_node_crypto7.createHash)("sha256").update(
|
|
10857
|
+
return (0, import_node_crypto7.createHash)("sha256").update(import_node_path18.default.resolve(cwd)).digest("hex").slice(0, 16);
|
|
9774
10858
|
}
|
|
9775
10859
|
function newSessionId() {
|
|
9776
10860
|
return `s_${(0, import_node_crypto7.randomBytes)(10).toString("hex")}`;
|
|
9777
10861
|
}
|
|
9778
10862
|
function upsertProject(input) {
|
|
9779
|
-
const cwd =
|
|
10863
|
+
const cwd = import_node_path18.default.resolve(input.cwd);
|
|
9780
10864
|
const id = projectIdForCwd(cwd);
|
|
9781
10865
|
let result;
|
|
9782
10866
|
mutateStore((store) => {
|
|
@@ -9802,7 +10886,7 @@ function upsertProject(input) {
|
|
|
9802
10886
|
const now = Date.now();
|
|
9803
10887
|
const created = {
|
|
9804
10888
|
id,
|
|
9805
|
-
name: input.name ??
|
|
10889
|
+
name: input.name ?? import_node_path18.default.basename(cwd),
|
|
9806
10890
|
cwd,
|
|
9807
10891
|
repoRoot: input.repoRoot,
|
|
9808
10892
|
sourceRoots: input.sourceRoots ?? [cwd],
|
|
@@ -9948,8 +11032,8 @@ async function seedFromDemoAppRegistry() {
|
|
|
9948
11032
|
if (apps.length === 0) return;
|
|
9949
11033
|
mutateStore((store) => {
|
|
9950
11034
|
for (const app of apps) {
|
|
9951
|
-
if (!
|
|
9952
|
-
const cwd =
|
|
11035
|
+
if (!import_node_fs18.default.existsSync(app.dir)) continue;
|
|
11036
|
+
const cwd = import_node_path18.default.resolve(app.dir);
|
|
9953
11037
|
const id = projectIdForCwd(cwd);
|
|
9954
11038
|
if (store.attachedProjects.some((p) => p.id === id)) continue;
|
|
9955
11039
|
const now = Date.now();
|
|
@@ -9974,16 +11058,16 @@ async function seedFromDemoAppRegistry() {
|
|
|
9974
11058
|
// src/agent-sessions.ts
|
|
9975
11059
|
init_public_brand();
|
|
9976
11060
|
function sessionDir(sessionId) {
|
|
9977
|
-
return
|
|
11061
|
+
return import_node_path19.default.join(getUserDataDir(), "sessions", sessionId);
|
|
9978
11062
|
}
|
|
9979
11063
|
function promptFifoPath(sessionId) {
|
|
9980
|
-
return
|
|
11064
|
+
return import_node_path19.default.join(sessionDir(sessionId), "prompt.in");
|
|
9981
11065
|
}
|
|
9982
11066
|
function eventsFifoPath(sessionId) {
|
|
9983
|
-
return
|
|
11067
|
+
return import_node_path19.default.join(sessionDir(sessionId), "events.out");
|
|
9984
11068
|
}
|
|
9985
11069
|
function transcriptPath(sessionId) {
|
|
9986
|
-
return
|
|
11070
|
+
return import_node_path19.default.join(getUserDataDir(), "transcripts", `${sessionId}.log`);
|
|
9987
11071
|
}
|
|
9988
11072
|
function pidIsAlive(pid, sessionId) {
|
|
9989
11073
|
if (!pid) return false;
|
|
@@ -9993,7 +11077,7 @@ function pidIsAlive(pid, sessionId) {
|
|
|
9993
11077
|
return false;
|
|
9994
11078
|
}
|
|
9995
11079
|
if (sessionId) {
|
|
9996
|
-
if (!
|
|
11080
|
+
if (!import_node_fs19.default.existsSync(sessionDir(sessionId))) return false;
|
|
9997
11081
|
}
|
|
9998
11082
|
return true;
|
|
9999
11083
|
}
|
|
@@ -10006,11 +11090,11 @@ function resolveSootsimInvocation() {
|
|
|
10006
11090
|
const resourcesPath = process.resourcesPath;
|
|
10007
11091
|
if (resourcesPath) {
|
|
10008
11092
|
const candidates = [
|
|
10009
|
-
|
|
10010
|
-
|
|
11093
|
+
import_node_path19.default.join(resourcesPath, "bin", "sootsim"),
|
|
11094
|
+
import_node_path19.default.join(resourcesPath, "bin", `sootsim-${process.platform}-${process.arch}`)
|
|
10011
11095
|
];
|
|
10012
11096
|
for (const c of candidates) {
|
|
10013
|
-
if (
|
|
11097
|
+
if (import_node_fs19.default.existsSync(c)) return { executable: c, prefixArgs: [] };
|
|
10014
11098
|
}
|
|
10015
11099
|
}
|
|
10016
11100
|
}
|
|
@@ -10029,15 +11113,15 @@ function tryWorkspaceSootsim() {
|
|
|
10029
11113
|
const sootsimDir = resolveSootsimPackageDir();
|
|
10030
11114
|
if (!sootsimDir) return null;
|
|
10031
11115
|
const binaryName = `peach-${process.platform === "win32" ? "windows" : process.platform}-${process.arch}${process.platform === "win32" ? ".exe" : ""}`;
|
|
10032
|
-
const distBinary =
|
|
10033
|
-
if (
|
|
10034
|
-
const distBin =
|
|
10035
|
-
if (
|
|
11116
|
+
const distBinary = import_node_path19.default.join(sootsimDir, "dist-bin", binaryName);
|
|
11117
|
+
if (import_node_fs19.default.existsSync(distBinary)) return { executable: distBinary, prefixArgs: [] };
|
|
11118
|
+
const distBin = import_node_path19.default.join(sootsimDir, "dist-cli", "bin.js");
|
|
11119
|
+
if (import_node_fs19.default.existsSync(distBin)) {
|
|
10036
11120
|
try {
|
|
10037
|
-
const src =
|
|
10038
|
-
if (
|
|
10039
|
-
const srcMtime =
|
|
10040
|
-
const buildMtime =
|
|
11121
|
+
const src = import_node_path19.default.join(sootsimDir, "cli", "commands", "agent-wrapper.ts");
|
|
11122
|
+
if (import_node_fs19.default.existsSync(src)) {
|
|
11123
|
+
const srcMtime = import_node_fs19.default.statSync(src).mtimeMs;
|
|
11124
|
+
const buildMtime = import_node_fs19.default.statSync(distBin).mtimeMs;
|
|
10041
11125
|
if (buildMtime < srcMtime) {
|
|
10042
11126
|
console.warn(
|
|
10043
11127
|
`[peach] dist-cli/bin.js is older than agent-wrapper.ts \u2014 rebuild with \`bun run --cwd packages/peachsim build:cli\`.`
|
|
@@ -10056,22 +11140,22 @@ function tryWorkspaceSootsim() {
|
|
|
10056
11140
|
function resolveSootsimPackageDir() {
|
|
10057
11141
|
try {
|
|
10058
11142
|
const resolved = require.resolve(`${rnxPublicBrand.packageName}/package.json`);
|
|
10059
|
-
return
|
|
11143
|
+
return import_node_path19.default.dirname(resolved);
|
|
10060
11144
|
} catch {
|
|
10061
11145
|
}
|
|
10062
11146
|
const here = fileFromImportMeta();
|
|
10063
11147
|
if (!here) return null;
|
|
10064
|
-
let cur =
|
|
11148
|
+
let cur = import_node_path19.default.dirname(here);
|
|
10065
11149
|
for (let i = 0; i < 8; i++) {
|
|
10066
|
-
const pkg =
|
|
11150
|
+
const pkg = import_node_path19.default.join(cur, "package.json");
|
|
10067
11151
|
try {
|
|
10068
|
-
if (
|
|
10069
|
-
const
|
|
10070
|
-
if (
|
|
11152
|
+
if (import_node_fs19.default.existsSync(pkg)) {
|
|
11153
|
+
const parsed2 = JSON.parse(import_node_fs19.default.readFileSync(pkg, "utf8"));
|
|
11154
|
+
if (parsed2.name === rnxPublicBrand.packageName) return cur;
|
|
10071
11155
|
}
|
|
10072
11156
|
} catch {
|
|
10073
11157
|
}
|
|
10074
|
-
const parent =
|
|
11158
|
+
const parent = import_node_path19.default.dirname(cur);
|
|
10075
11159
|
if (parent === cur) break;
|
|
10076
11160
|
cur = parent;
|
|
10077
11161
|
}
|
|
@@ -10087,28 +11171,28 @@ function fileFromImportMeta() {
|
|
|
10087
11171
|
}
|
|
10088
11172
|
}
|
|
10089
11173
|
async function withStartLock(projectId, provider, fn) {
|
|
10090
|
-
const lockDir =
|
|
10091
|
-
|
|
11174
|
+
const lockDir = import_node_path19.default.join(getUserDataDir(), "locks");
|
|
11175
|
+
import_node_fs19.default.mkdirSync(lockDir, { recursive: true });
|
|
10092
11176
|
try {
|
|
10093
|
-
|
|
11177
|
+
import_node_fs19.default.chmodSync(lockDir, 448);
|
|
10094
11178
|
} catch {
|
|
10095
11179
|
}
|
|
10096
|
-
const lockPath =
|
|
11180
|
+
const lockPath = import_node_path19.default.join(lockDir, `start-${projectId}-${provider}.lock`);
|
|
10097
11181
|
const deadline = Date.now() + 4e3;
|
|
10098
11182
|
let fd = null;
|
|
10099
11183
|
while (fd === null) {
|
|
10100
11184
|
try {
|
|
10101
|
-
fd =
|
|
11185
|
+
fd = import_node_fs19.default.openSync(
|
|
10102
11186
|
lockPath,
|
|
10103
|
-
|
|
11187
|
+
import_node_fs19.constants.O_WRONLY | import_node_fs19.constants.O_CREAT | import_node_fs19.constants.O_EXCL,
|
|
10104
11188
|
384
|
|
10105
11189
|
);
|
|
10106
11190
|
} catch (err) {
|
|
10107
11191
|
if (err.code !== "EEXIST") throw err;
|
|
10108
11192
|
try {
|
|
10109
|
-
const stale = Number(
|
|
11193
|
+
const stale = Number(import_node_fs19.default.readFileSync(lockPath, "utf8").trim());
|
|
10110
11194
|
if (stale && !isProcessAlive(stale)) {
|
|
10111
|
-
|
|
11195
|
+
import_node_fs19.default.unlinkSync(lockPath);
|
|
10112
11196
|
continue;
|
|
10113
11197
|
}
|
|
10114
11198
|
} catch {
|
|
@@ -10122,15 +11206,15 @@ async function withStartLock(projectId, provider, fn) {
|
|
|
10122
11206
|
}
|
|
10123
11207
|
}
|
|
10124
11208
|
try {
|
|
10125
|
-
|
|
11209
|
+
import_node_fs19.default.writeFileSync(fd, String(process.pid));
|
|
10126
11210
|
return await fn();
|
|
10127
11211
|
} finally {
|
|
10128
11212
|
try {
|
|
10129
|
-
|
|
11213
|
+
import_node_fs19.default.closeSync(fd);
|
|
10130
11214
|
} catch {
|
|
10131
11215
|
}
|
|
10132
11216
|
try {
|
|
10133
|
-
|
|
11217
|
+
import_node_fs19.default.unlinkSync(lockPath);
|
|
10134
11218
|
} catch {
|
|
10135
11219
|
}
|
|
10136
11220
|
}
|
|
@@ -10144,28 +11228,28 @@ function isProcessAlive(pid) {
|
|
|
10144
11228
|
}
|
|
10145
11229
|
}
|
|
10146
11230
|
function mkfifoSync(p) {
|
|
10147
|
-
const parent =
|
|
10148
|
-
|
|
11231
|
+
const parent = import_node_path19.default.dirname(p);
|
|
11232
|
+
import_node_fs19.default.mkdirSync(parent, { recursive: true });
|
|
10149
11233
|
try {
|
|
10150
|
-
|
|
11234
|
+
import_node_fs19.default.chmodSync(parent, 448);
|
|
10151
11235
|
} catch {
|
|
10152
11236
|
}
|
|
10153
|
-
if (
|
|
11237
|
+
if (import_node_fs19.default.existsSync(p)) {
|
|
10154
11238
|
try {
|
|
10155
|
-
const stat2 =
|
|
11239
|
+
const stat2 = import_node_fs19.default.statSync(p);
|
|
10156
11240
|
if (stat2.isFIFO()) {
|
|
10157
11241
|
try {
|
|
10158
|
-
|
|
11242
|
+
import_node_fs19.default.chmodSync(p, 384);
|
|
10159
11243
|
} catch {
|
|
10160
11244
|
}
|
|
10161
11245
|
return;
|
|
10162
11246
|
}
|
|
10163
|
-
|
|
11247
|
+
import_node_fs19.default.unlinkSync(p);
|
|
10164
11248
|
} catch {
|
|
10165
|
-
|
|
11249
|
+
import_node_fs19.default.unlinkSync(p);
|
|
10166
11250
|
}
|
|
10167
11251
|
}
|
|
10168
|
-
const result = (0,
|
|
11252
|
+
const result = (0, import_node_child_process8.spawnSync)("mkfifo", ["-m", "600", p]);
|
|
10169
11253
|
if (result.status !== 0) {
|
|
10170
11254
|
throw new Error(
|
|
10171
11255
|
`mkfifo(${p}) failed: ${result.stderr?.toString().trim() || "unknown error"}`
|
|
@@ -10209,10 +11293,10 @@ async function startSession(opts) {
|
|
|
10209
11293
|
const transcript = transcriptPath(session.id);
|
|
10210
11294
|
mkfifoSync(promptIn);
|
|
10211
11295
|
mkfifoSync(eventsOut);
|
|
10212
|
-
const transcriptDir =
|
|
10213
|
-
|
|
11296
|
+
const transcriptDir = import_node_path19.default.dirname(transcript);
|
|
11297
|
+
import_node_fs19.default.mkdirSync(transcriptDir, { recursive: true });
|
|
10214
11298
|
try {
|
|
10215
|
-
|
|
11299
|
+
import_node_fs19.default.chmodSync(transcriptDir, 448);
|
|
10216
11300
|
} catch {
|
|
10217
11301
|
}
|
|
10218
11302
|
const { executable, prefixArgs } = resolveSootsimInvocation();
|
|
@@ -10240,7 +11324,7 @@ async function startSession(opts) {
|
|
|
10240
11324
|
if (claudeSessionUuid) {
|
|
10241
11325
|
wrapperArgs.push("--claude-session-uuid", claudeSessionUuid);
|
|
10242
11326
|
}
|
|
10243
|
-
const child = (0,
|
|
11327
|
+
const child = (0, import_node_child_process8.spawn)(executable, wrapperArgs, {
|
|
10244
11328
|
detached: true,
|
|
10245
11329
|
stdio: "ignore",
|
|
10246
11330
|
env: {
|
|
@@ -10263,7 +11347,7 @@ async function startSession(opts) {
|
|
|
10263
11347
|
}
|
|
10264
11348
|
}
|
|
10265
11349
|
try {
|
|
10266
|
-
|
|
11350
|
+
import_node_fs19.default.rmSync(sessionDir(session.id), { recursive: true, force: true });
|
|
10267
11351
|
} catch {
|
|
10268
11352
|
}
|
|
10269
11353
|
updateSessionStatus(session.id, { status: "ended" });
|
|
@@ -10291,18 +11375,18 @@ async function sendPrompt(sessionId, prompt) {
|
|
|
10291
11375
|
);
|
|
10292
11376
|
}
|
|
10293
11377
|
const fifo = promptFifoPath(sessionId);
|
|
10294
|
-
if (!
|
|
11378
|
+
if (!import_node_fs19.default.existsSync(fifo)) {
|
|
10295
11379
|
throw new AgentSessionError("NO_FIFO", `prompt FIFO missing: ${fifo}`);
|
|
10296
11380
|
}
|
|
10297
|
-
const fd =
|
|
11381
|
+
const fd = import_node_fs19.default.openSync(fifo, import_node_fs19.constants.O_WRONLY);
|
|
10298
11382
|
try {
|
|
10299
11383
|
const wireText = encodeAgentPromptEnvelope(prompt);
|
|
10300
11384
|
if (!wireText) {
|
|
10301
11385
|
throw new AgentSessionError("EMPTY_PROMPT", "prompt text is empty");
|
|
10302
11386
|
}
|
|
10303
|
-
|
|
11387
|
+
import_node_fs19.default.writeSync(fd, wireText + "\n");
|
|
10304
11388
|
} finally {
|
|
10305
|
-
|
|
11389
|
+
import_node_fs19.default.closeSync(fd);
|
|
10306
11390
|
}
|
|
10307
11391
|
updateSessionStatus(sessionId, {
|
|
10308
11392
|
lastPrompt: prompt.displayText ?? prompt.text,
|
|
@@ -10324,7 +11408,7 @@ async function endSession(sessionId) {
|
|
|
10324
11408
|
const base = getUserDataDir();
|
|
10325
11409
|
if (dir.startsWith(base)) {
|
|
10326
11410
|
try {
|
|
10327
|
-
|
|
11411
|
+
import_node_fs19.default.rmSync(dir, { recursive: true, force: true });
|
|
10328
11412
|
} catch {
|
|
10329
11413
|
}
|
|
10330
11414
|
}
|
|
@@ -10332,11 +11416,11 @@ async function endSession(sessionId) {
|
|
|
10332
11416
|
}
|
|
10333
11417
|
function subscribeEvents(sessionId, onEvent) {
|
|
10334
11418
|
const fifo = eventsFifoPath(sessionId);
|
|
10335
|
-
if (!
|
|
11419
|
+
if (!import_node_fs19.default.existsSync(fifo)) {
|
|
10336
11420
|
throw new AgentSessionError("NO_FIFO", `events FIFO missing: ${fifo}`);
|
|
10337
11421
|
}
|
|
10338
|
-
const fd =
|
|
10339
|
-
const stream =
|
|
11422
|
+
const fd = import_node_fs19.default.openSync(fifo, import_node_fs19.constants.O_RDWR);
|
|
11423
|
+
const stream = import_node_fs19.default.createReadStream("", { fd, autoClose: true });
|
|
10340
11424
|
const rl = import_node_readline.default.createInterface({ input: stream, crlfDelay: Infinity });
|
|
10341
11425
|
rl.on("line", (line) => {
|
|
10342
11426
|
const event = parseAgentEventLine(line);
|
|
@@ -10347,7 +11431,7 @@ function subscribeEvents(sessionId, onEvent) {
|
|
|
10347
11431
|
if (closed) return;
|
|
10348
11432
|
closed = true;
|
|
10349
11433
|
try {
|
|
10350
|
-
|
|
11434
|
+
import_node_fs19.default.writeSync(fd, "\n");
|
|
10351
11435
|
} catch {
|
|
10352
11436
|
}
|
|
10353
11437
|
try {
|
|
@@ -10361,7 +11445,7 @@ function subscribeEvents(sessionId, onEvent) {
|
|
|
10361
11445
|
};
|
|
10362
11446
|
}
|
|
10363
11447
|
async function waitForFirstEvent(fifo, predicate, timeoutMs) {
|
|
10364
|
-
const fd =
|
|
11448
|
+
const fd = import_node_fs19.default.openSync(fifo, import_node_fs19.constants.O_RDWR | import_node_fs19.constants.O_NONBLOCK);
|
|
10365
11449
|
const buf = Buffer.alloc(8192);
|
|
10366
11450
|
let leftover = "";
|
|
10367
11451
|
const deadline = Date.now() + timeoutMs;
|
|
@@ -10369,7 +11453,7 @@ async function waitForFirstEvent(fifo, predicate, timeoutMs) {
|
|
|
10369
11453
|
while (Date.now() < deadline) {
|
|
10370
11454
|
let n = 0;
|
|
10371
11455
|
try {
|
|
10372
|
-
n =
|
|
11456
|
+
n = import_node_fs19.default.readSync(fd, buf, 0, buf.length, null);
|
|
10373
11457
|
} catch (err) {
|
|
10374
11458
|
if (err.code !== "EAGAIN") throw err;
|
|
10375
11459
|
n = 0;
|
|
@@ -10389,7 +11473,7 @@ async function waitForFirstEvent(fifo, predicate, timeoutMs) {
|
|
|
10389
11473
|
}
|
|
10390
11474
|
return null;
|
|
10391
11475
|
} finally {
|
|
10392
|
-
|
|
11476
|
+
import_node_fs19.default.closeSync(fd);
|
|
10393
11477
|
}
|
|
10394
11478
|
}
|
|
10395
11479
|
|
|
@@ -10643,7 +11727,7 @@ var AgentHost = class {
|
|
|
10643
11727
|
);
|
|
10644
11728
|
const project = upsertProject({
|
|
10645
11729
|
cwd: match.cwd,
|
|
10646
|
-
name: match.projectName ??
|
|
11730
|
+
name: match.projectName ?? import_node_path20.default.basename(match.cwd),
|
|
10647
11731
|
preferredProvider: input.provider ?? existing?.preferredProvider,
|
|
10648
11732
|
sourceRoots: existing?.sourceRoots ?? [match.cwd],
|
|
10649
11733
|
knownBundleUrls,
|
|
@@ -10654,18 +11738,18 @@ var AgentHost = class {
|
|
|
10654
11738
|
}
|
|
10655
11739
|
getTranscript(sessionId) {
|
|
10656
11740
|
const p = transcriptPath(sessionId);
|
|
10657
|
-
if (!
|
|
11741
|
+
if (!import_node_fs20.default.existsSync(p)) {
|
|
10658
11742
|
return { error: "transcript not found", code: "NO_TRANSCRIPT" };
|
|
10659
11743
|
}
|
|
10660
|
-
return
|
|
11744
|
+
return import_node_fs20.default.readFileSync(p, "utf8");
|
|
10661
11745
|
}
|
|
10662
11746
|
getPaths() {
|
|
10663
11747
|
const dir = getUserDataDir();
|
|
10664
11748
|
return {
|
|
10665
11749
|
userDataDir: dir,
|
|
10666
|
-
storeFile:
|
|
10667
|
-
sessionsDir:
|
|
10668
|
-
transcriptsDir:
|
|
11750
|
+
storeFile: import_node_path20.default.join(dir, "attached-projects.json"),
|
|
11751
|
+
sessionsDir: import_node_path20.default.join(dir, "sessions"),
|
|
11752
|
+
transcriptsDir: import_node_path20.default.join(dir, "transcripts")
|
|
10669
11753
|
};
|
|
10670
11754
|
}
|
|
10671
11755
|
// --- subscription management ---
|
|
@@ -11301,9 +12385,9 @@ function handleAppApiRequest(req, res) {
|
|
|
11301
12385
|
let targetPath = "";
|
|
11302
12386
|
let targetOrigin = "";
|
|
11303
12387
|
if (reqUrl.startsWith("/__app-api?")) {
|
|
11304
|
-
const
|
|
11305
|
-
targetPath =
|
|
11306
|
-
targetOrigin =
|
|
12388
|
+
const parsed2 = new URL(reqUrl, "http://sootsim.local");
|
|
12389
|
+
targetPath = parsed2.searchParams.get("path") || "";
|
|
12390
|
+
targetOrigin = parsed2.searchParams.get("origin")?.trim() || "";
|
|
11307
12391
|
} else if (reqUrl.startsWith("/__app-api/")) {
|
|
11308
12392
|
targetPath = reqUrl.slice("/__app-api".length);
|
|
11309
12393
|
} else {
|
|
@@ -11508,8 +12592,8 @@ async function openUrl(url, options = {}) {
|
|
|
11508
12592
|
}
|
|
11509
12593
|
|
|
11510
12594
|
// src/host/plane-host.ts
|
|
11511
|
-
var
|
|
11512
|
-
var
|
|
12595
|
+
var import_node_fs22 = __toESM(require("node:fs"), 1);
|
|
12596
|
+
var import_node_path22 = __toESM(require("node:path"), 1);
|
|
11513
12597
|
|
|
11514
12598
|
// ../peach-box/src/planeProtocol.ts
|
|
11515
12599
|
var PLANE_FLAG_READ_ONLY = 1;
|
|
@@ -11588,9 +12672,9 @@ async function dispatchPlaneCommand(plane, type, msg, mutationOptions) {
|
|
|
11588
12672
|
}
|
|
11589
12673
|
|
|
11590
12674
|
// cli/commands/box/checkout-plane.ts
|
|
11591
|
-
var
|
|
11592
|
-
var
|
|
11593
|
-
var
|
|
12675
|
+
var import_node_child_process9 = require("node:child_process");
|
|
12676
|
+
var import_node_fs21 = __toESM(require("node:fs"), 1);
|
|
12677
|
+
var import_node_path21 = __toESM(require("node:path"), 1);
|
|
11594
12678
|
var CheckoutRequiresGitError = class extends Error {
|
|
11595
12679
|
};
|
|
11596
12680
|
var BINARY_SNIFF_BYTES = 8192;
|
|
@@ -11601,14 +12685,14 @@ function looksBinary(filePath, size) {
|
|
|
11601
12685
|
if (size === 0) return false;
|
|
11602
12686
|
let fd;
|
|
11603
12687
|
try {
|
|
11604
|
-
fd =
|
|
12688
|
+
fd = import_node_fs21.default.openSync(filePath, "r");
|
|
11605
12689
|
const buffer = Buffer.alloc(Math.min(BINARY_SNIFF_BYTES, size));
|
|
11606
|
-
const read =
|
|
12690
|
+
const read = import_node_fs21.default.readSync(fd, buffer, 0, buffer.length, 0);
|
|
11607
12691
|
return buffer.subarray(0, read).includes(0);
|
|
11608
12692
|
} catch {
|
|
11609
12693
|
return false;
|
|
11610
12694
|
} finally {
|
|
11611
|
-
if (fd !== void 0)
|
|
12695
|
+
if (fd !== void 0) import_node_fs21.default.closeSync(fd);
|
|
11612
12696
|
}
|
|
11613
12697
|
}
|
|
11614
12698
|
var CheckoutFilePlane = class {
|
|
@@ -11621,7 +12705,7 @@ var CheckoutFilePlane = class {
|
|
|
11621
12705
|
listTimeoutMs;
|
|
11622
12706
|
trackedOnly;
|
|
11623
12707
|
constructor(root, options = {}) {
|
|
11624
|
-
this.root =
|
|
12708
|
+
this.root = import_node_path21.default.resolve(root);
|
|
11625
12709
|
this.listTimeoutMs = options.listTimeoutMs ?? LIST_FILES_TIMEOUT_MS;
|
|
11626
12710
|
this.trackedOnly = options.trackedOnly ?? false;
|
|
11627
12711
|
}
|
|
@@ -11630,7 +12714,7 @@ var CheckoutFilePlane = class {
|
|
|
11630
12714
|
}
|
|
11631
12715
|
listFiles() {
|
|
11632
12716
|
const args = this.trackedOnly ? ["ls-files", "-z"] : ["ls-files", "-co", "--exclude-standard", "-z"];
|
|
11633
|
-
const stdout = (0,
|
|
12717
|
+
const stdout = (0, import_node_child_process9.execFileSync)("git", args, {
|
|
11634
12718
|
cwd: this.root,
|
|
11635
12719
|
encoding: "utf8",
|
|
11636
12720
|
maxBuffer: 64 * 1024 * 1024,
|
|
@@ -11683,13 +12767,13 @@ var CheckoutFilePlane = class {
|
|
|
11683
12767
|
if (!relative2) continue;
|
|
11684
12768
|
let stat2;
|
|
11685
12769
|
try {
|
|
11686
|
-
stat2 =
|
|
12770
|
+
stat2 = import_node_fs21.default.statSync(import_node_path21.default.join(this.root, relative2));
|
|
11687
12771
|
} catch {
|
|
11688
12772
|
continue;
|
|
11689
12773
|
}
|
|
11690
12774
|
if (!stat2.isFile()) continue;
|
|
11691
12775
|
const seen = this.sniffed.get(relative2);
|
|
11692
|
-
const binary = seen && seen.size === stat2.size && seen.mtimeMs === stat2.mtimeMs ? seen.binary : looksBinary(
|
|
12776
|
+
const binary = seen && seen.size === stat2.size && seen.mtimeMs === stat2.mtimeMs ? seen.binary : looksBinary(import_node_path21.default.join(this.root, relative2), stat2.size);
|
|
11693
12777
|
nextSniffed.set(relative2, { size: stat2.size, mtimeMs: stat2.mtimeMs, binary });
|
|
11694
12778
|
next.set(relative2, {
|
|
11695
12779
|
size: stat2.size,
|
|
@@ -11703,22 +12787,22 @@ var CheckoutFilePlane = class {
|
|
|
11703
12787
|
this.sniffed = nextSniffed;
|
|
11704
12788
|
}
|
|
11705
12789
|
absolute(planePath) {
|
|
11706
|
-
const resolved =
|
|
11707
|
-
if (resolved !== this.root && !resolved.startsWith(`${this.root}${
|
|
12790
|
+
const resolved = import_node_path21.default.resolve(this.root, planePath);
|
|
12791
|
+
if (resolved !== this.root && !resolved.startsWith(`${this.root}${import_node_path21.default.sep}`)) {
|
|
11708
12792
|
throw new Error(`path escapes the project: ${planePath}`);
|
|
11709
12793
|
}
|
|
11710
12794
|
return resolved;
|
|
11711
12795
|
}
|
|
11712
12796
|
async read(planePath) {
|
|
11713
|
-
return
|
|
12797
|
+
return import_node_fs21.default.promises.readFile(this.absolute(planePath), "utf8");
|
|
11714
12798
|
}
|
|
11715
12799
|
async readBytes(planePath) {
|
|
11716
|
-
return
|
|
12800
|
+
return import_node_fs21.default.promises.readFile(this.absolute(planePath));
|
|
11717
12801
|
}
|
|
11718
12802
|
async write(planePath, content) {
|
|
11719
12803
|
const absolute = this.absolute(planePath);
|
|
11720
|
-
await
|
|
11721
|
-
await
|
|
12804
|
+
await import_node_fs21.default.promises.mkdir(import_node_path21.default.dirname(absolute), { recursive: true });
|
|
12805
|
+
await import_node_fs21.default.promises.writeFile(absolute, content);
|
|
11722
12806
|
this.entries.set(planePath, {
|
|
11723
12807
|
size: content.byteLength,
|
|
11724
12808
|
readOnly: false,
|
|
@@ -11727,7 +12811,7 @@ var CheckoutFilePlane = class {
|
|
|
11727
12811
|
});
|
|
11728
12812
|
}
|
|
11729
12813
|
async delete(planePath) {
|
|
11730
|
-
await
|
|
12814
|
+
await import_node_fs21.default.promises.rm(this.absolute(planePath), { force: true });
|
|
11731
12815
|
this.entries.delete(planePath);
|
|
11732
12816
|
}
|
|
11733
12817
|
};
|
|
@@ -11853,14 +12937,14 @@ var PlaneHost = class {
|
|
|
11853
12937
|
// root and an opened one cannot disagree about the same directory.
|
|
11854
12938
|
realRoot(root) {
|
|
11855
12939
|
if (!root) throw new Error("root is required");
|
|
11856
|
-
const resolved =
|
|
12940
|
+
const resolved = import_node_path22.default.resolve(root);
|
|
11857
12941
|
let real;
|
|
11858
12942
|
try {
|
|
11859
|
-
real =
|
|
12943
|
+
real = import_node_fs22.default.realpathSync(resolved);
|
|
11860
12944
|
} catch {
|
|
11861
12945
|
throw new Error(`no such directory: ${resolved}`);
|
|
11862
12946
|
}
|
|
11863
|
-
if (!
|
|
12947
|
+
if (!import_node_fs22.default.statSync(real).isDirectory()) throw new Error(`not a directory: ${real}`);
|
|
11864
12948
|
return real;
|
|
11865
12949
|
}
|
|
11866
12950
|
respond(ws, id, result) {
|
|
@@ -11880,9 +12964,9 @@ var PlaneHost = class {
|
|
|
11880
12964
|
};
|
|
11881
12965
|
|
|
11882
12966
|
// src/host/replacement-module-handler.ts
|
|
11883
|
-
var
|
|
12967
|
+
var import_node_fs23 = require("node:fs");
|
|
11884
12968
|
var import_promises5 = __toESM(require("node:fs/promises"), 1);
|
|
11885
|
-
var
|
|
12969
|
+
var import_node_path23 = __toESM(require("node:path"), 1);
|
|
11886
12970
|
|
|
11887
12971
|
// ../contrast-bundler/src/replacementModule.ts
|
|
11888
12972
|
var import_dist = require("sucrase/dist/index.js");
|
|
@@ -11948,7 +13032,7 @@ function dirname4(p) {
|
|
|
11948
13032
|
if (idx === 0) return "/";
|
|
11949
13033
|
return p.slice(0, idx);
|
|
11950
13034
|
}
|
|
11951
|
-
function
|
|
13035
|
+
function basename4(p, ext) {
|
|
11952
13036
|
const idx = p.lastIndexOf("/");
|
|
11953
13037
|
const base = idx < 0 ? p : p.slice(idx + 1);
|
|
11954
13038
|
if (ext != null && ext.length < base.length && base.endsWith(ext)) {
|
|
@@ -11957,7 +13041,7 @@ function basename3(p, ext) {
|
|
|
11957
13041
|
return base;
|
|
11958
13042
|
}
|
|
11959
13043
|
function extname(p) {
|
|
11960
|
-
const base =
|
|
13044
|
+
const base = basename4(p);
|
|
11961
13045
|
const idx = base.lastIndexOf(".");
|
|
11962
13046
|
if (idx <= 0) return "";
|
|
11963
13047
|
return base.slice(idx);
|
|
@@ -11981,7 +13065,7 @@ var posix = {
|
|
|
11981
13065
|
join: join6,
|
|
11982
13066
|
resolve: resolve3,
|
|
11983
13067
|
dirname: dirname4,
|
|
11984
|
-
basename:
|
|
13068
|
+
basename: basename4,
|
|
11985
13069
|
extname,
|
|
11986
13070
|
relative
|
|
11987
13071
|
};
|
|
@@ -12207,16 +13291,16 @@ function sendJavaScript(req, res, source) {
|
|
|
12207
13291
|
res.end(req.method === "HEAD" ? void 0 : source);
|
|
12208
13292
|
}
|
|
12209
13293
|
function resolveLocalImport(fromFile, specifier) {
|
|
12210
|
-
const base =
|
|
13294
|
+
const base = import_node_path23.default.resolve(import_node_path23.default.dirname(fromFile), specifier);
|
|
12211
13295
|
const candidates = [
|
|
12212
13296
|
...REPLACEMENT_MODULE_EXTENSIONS.some(
|
|
12213
|
-
(ext) => ext ===
|
|
13297
|
+
(ext) => ext === import_node_path23.default.extname(base).toLowerCase()
|
|
12214
13298
|
) ? [base] : [],
|
|
12215
13299
|
...REPLACEMENT_MODULE_EXTENSIONS.map((ext) => base + ext),
|
|
12216
|
-
...REPLACEMENT_MODULE_EXTENSIONS.map((ext) =>
|
|
13300
|
+
...REPLACEMENT_MODULE_EXTENSIONS.map((ext) => import_node_path23.default.join(base, `index${ext}`))
|
|
12217
13301
|
];
|
|
12218
13302
|
const found = candidates.find(
|
|
12219
|
-
(candidate) => (0,
|
|
13303
|
+
(candidate) => (0, import_node_fs23.statSync)(candidate, { throwIfNoEntry: false })?.isFile()
|
|
12220
13304
|
);
|
|
12221
13305
|
if (!found) {
|
|
12222
13306
|
throw new Error(
|
|
@@ -12271,13 +13355,13 @@ async function handleReplacementModuleRequest(req, res, options = {}) {
|
|
|
12271
13355
|
res.end("missing path param");
|
|
12272
13356
|
return true;
|
|
12273
13357
|
}
|
|
12274
|
-
const extension =
|
|
13358
|
+
const extension = import_node_path23.default.extname(targetPath).toLowerCase();
|
|
12275
13359
|
if (!REPLACEMENT_MODULE_EXTENSIONS.some((allowed) => allowed === extension)) {
|
|
12276
13360
|
res.writeHead(400, { "Content-Type": "text/plain; charset=utf-8" });
|
|
12277
13361
|
res.end(`replacement files must be ${REPLACEMENT_MODULE_EXTENSIONS.join(", ")}`);
|
|
12278
13362
|
return true;
|
|
12279
13363
|
}
|
|
12280
|
-
if (!
|
|
13364
|
+
if (!import_node_path23.default.isAbsolute(targetPath)) {
|
|
12281
13365
|
res.writeHead(400, { "Content-Type": "text/plain; charset=utf-8" });
|
|
12282
13366
|
res.end("replacement file path must be absolute");
|
|
12283
13367
|
return true;
|
|
@@ -12285,10 +13369,10 @@ async function handleReplacementModuleRequest(req, res, options = {}) {
|
|
|
12285
13369
|
const runtimePackages = new Set(url.searchParams.getAll("runtimePackage"));
|
|
12286
13370
|
let resolvedProjectRoot;
|
|
12287
13371
|
if (options.projectRoot) {
|
|
12288
|
-
const lexicalProjectRoot =
|
|
13372
|
+
const lexicalProjectRoot = import_node_path23.default.resolve(options.projectRoot);
|
|
12289
13373
|
resolvedProjectRoot = await import_promises5.default.realpath(options.projectRoot);
|
|
12290
|
-
const lexicalTarget =
|
|
12291
|
-
if (lexicalTarget.startsWith("..") ||
|
|
13374
|
+
const lexicalTarget = import_node_path23.default.relative(lexicalProjectRoot, targetPath);
|
|
13375
|
+
if (lexicalTarget.startsWith("..") || import_node_path23.default.isAbsolute(lexicalTarget)) {
|
|
12292
13376
|
res.writeHead(403, { "Content-Type": "text/plain; charset=utf-8" });
|
|
12293
13377
|
res.end("replacement file must be inside the project root");
|
|
12294
13378
|
return true;
|
|
@@ -12304,8 +13388,8 @@ async function handleReplacementModuleRequest(req, res, options = {}) {
|
|
|
12304
13388
|
return true;
|
|
12305
13389
|
}
|
|
12306
13390
|
if (resolvedProjectRoot) {
|
|
12307
|
-
const relativeTarget =
|
|
12308
|
-
if (relativeTarget.startsWith("..") ||
|
|
13391
|
+
const relativeTarget = import_node_path23.default.relative(resolvedProjectRoot, resolvedTargetPath);
|
|
13392
|
+
if (relativeTarget.startsWith("..") || import_node_path23.default.isAbsolute(relativeTarget)) {
|
|
12309
13393
|
res.writeHead(403, { "Content-Type": "text/plain; charset=utf-8" });
|
|
12310
13394
|
res.end("replacement file must be inside the project root");
|
|
12311
13395
|
return true;
|
|
@@ -12430,10 +13514,10 @@ function decodeProxyHeaders(encoded) {
|
|
|
12430
13514
|
if (!encoded) return {};
|
|
12431
13515
|
const base64 = encoded.replace(/-/g, "+").replace(/_/g, "/");
|
|
12432
13516
|
const padded = base64 + "=".repeat((4 - base64.length % 4) % 4);
|
|
12433
|
-
const
|
|
12434
|
-
if (!
|
|
13517
|
+
const parsed2 = JSON.parse(Buffer.from(padded, "base64").toString("utf8"));
|
|
13518
|
+
if (!parsed2 || typeof parsed2 !== "object" || Array.isArray(parsed2)) return {};
|
|
12435
13519
|
const headers = {};
|
|
12436
|
-
for (const [key, value] of Object.entries(
|
|
13520
|
+
for (const [key, value] of Object.entries(parsed2)) {
|
|
12437
13521
|
if (value == null) continue;
|
|
12438
13522
|
if (STRIP_UPSTREAM_HEADERS.has(key.toLowerCase())) continue;
|
|
12439
13523
|
headers[key] = Array.isArray(value) ? value.join(", ") : String(value);
|
|
@@ -13016,7 +14100,7 @@ var SootSimBridgeHost = class _SootSimBridgeHost {
|
|
|
13016
14100
|
this.updateUserActivity(sim);
|
|
13017
14101
|
return;
|
|
13018
14102
|
}
|
|
13019
|
-
if (msg.type === "bridge:capture-active" && sim) {
|
|
14103
|
+
if ((msg.type === "bridge:user-present" || msg.type === "bridge:capture-active") && sim) {
|
|
13020
14104
|
sim.lastActiveAt = Date.now();
|
|
13021
14105
|
return;
|
|
13022
14106
|
}
|
|
@@ -13709,12 +14793,12 @@ var SootSimBridgeHost = class _SootSimBridgeHost {
|
|
|
13709
14793
|
}
|
|
13710
14794
|
chunks.push(buffer);
|
|
13711
14795
|
}
|
|
13712
|
-
const
|
|
13713
|
-
if (!
|
|
14796
|
+
const parsed2 = JSON.parse(Buffer.concat(chunks).toString("utf8"));
|
|
14797
|
+
if (!parsed2 || typeof parsed2 !== "object" || Array.isArray(parsed2)) {
|
|
13714
14798
|
throw new Error("shared config patch must be an object");
|
|
13715
14799
|
}
|
|
13716
14800
|
const patch = Object.fromEntries(
|
|
13717
|
-
Object.entries(
|
|
14801
|
+
Object.entries(parsed2)
|
|
13718
14802
|
);
|
|
13719
14803
|
const next = this.writeAndBroadcastSharedConfig(patch);
|
|
13720
14804
|
res.writeHead(200, { "Content-Type": "application/json" });
|
|
@@ -13753,11 +14837,11 @@ var SootSimBridgeHost = class _SootSimBridgeHost {
|
|
|
13753
14837
|
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
13754
14838
|
}
|
|
13755
14839
|
const text = Buffer.concat(chunks).toString("utf8").trim();
|
|
13756
|
-
const
|
|
13757
|
-
if (!
|
|
14840
|
+
const parsed2 = text ? JSON.parse(text) : {};
|
|
14841
|
+
if (!parsed2 || typeof parsed2 !== "object" || Array.isArray(parsed2)) {
|
|
13758
14842
|
throw new Error("send to box needs a json object body");
|
|
13759
14843
|
}
|
|
13760
|
-
const body = { ...
|
|
14844
|
+
const body = { ...parsed2 };
|
|
13761
14845
|
const { CHOOSE_ACCOUNT_HINT: CHOOSE_ACCOUNT_HINT2, resolveCliAuth: resolveCliAuth2, authHeaderValue: authHeaderValue2 } = await Promise.resolve().then(() => (init_auth(), auth_exports));
|
|
13762
14846
|
const auth = resolveCliAuth2();
|
|
13763
14847
|
if (!auth) {
|