peachsim 0.1.709 → 0.1.710
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/commands/control.ts +55 -1
- package/cli/current-sim.ts +15 -1
- package/cli/drivers/playwright-sim-host.ts +14 -1
- package/cli/drivers/playwright.ts +36 -3
- package/cli/main.ts +8 -0
- package/cli/parent-pid.ts +91 -15
- package/cli/ws-bridge.ts +5 -0
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/agent-identity.cjs +1 -1
- package/dist-lib/agent-sessions.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -1
- package/dist-lib/auth/shared-session.cjs +1 -1
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/beta.cjs +1 -1
- package/dist-lib/beta.mjs +1 -1
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/bridge-contract-input.cjs +1 -1
- package/dist-lib/bridge-contract-input.mjs +1 -1
- package/dist-lib/bridge-contract.cjs +1 -1
- package/dist-lib/bridge-contract.mjs +1 -1
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +1 -1
- package/dist-lib/cli-constants.cjs +1 -1
- package/dist-lib/cloud-contract.cjs +1 -1
- package/dist-lib/cloud-contract.mjs +1 -1
- package/dist-lib/cloud-test-args.cjs +1 -1
- package/dist-lib/cloud-test-args.mjs +1 -1
- package/dist-lib/cloud.cjs +1 -1
- package/dist-lib/cloud.mjs +1 -1
- package/dist-lib/config.cjs +1 -1
- package/dist-lib/detox/index.cjs +78 -5
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +172 -30
- package/dist-lib/host/fetch-proxy-handler.cjs +45 -21
- package/dist-lib/host/fetch-proxy-overrides.cjs +2 -2
- package/dist-lib/host/fetch-proxy-overrides.mjs +2 -2
- package/dist-lib/host/replacement-module-handler.cjs +1 -1
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +78 -5
- package/dist-lib/jump-to-source-babel.cjs +1 -1
- package/dist-lib/jump-to-source-native.cjs +1 -1
- package/dist-lib/kotlin-host.cjs +1 -1
- package/dist-lib/menu.cjs +1 -1
- package/dist-lib/menu.mjs +1 -1
- package/dist-lib/metro-fingerprint-registry.cjs +1 -1
- package/dist-lib/metro-fingerprint-registry.mjs +1 -1
- package/dist-lib/metro-production-bundle.cjs +1 -1
- package/dist-lib/metro-production-bundle.mjs +1 -1
- package/dist-lib/metro.cjs +1 -1
- package/dist-lib/native-app-identity.cjs +1 -1
- package/dist-lib/native-app-identity.mjs +1 -1
- package/dist-lib/native-firebase-metadata.cjs +1 -1
- package/dist-lib/native-firebase-metadata.mjs +1 -1
- package/dist-lib/plist.cjs +1 -1
- package/dist-lib/plist.mjs +1 -1
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +1 -1
- package/dist-lib/render-mode.cjs +1 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
- package/dist-lib/sdk.cjs +1 -1
- package/dist-lib/sdk.mjs +1 -1
- package/dist-lib/skills.cjs +331 -51
- package/dist-lib/swift-compile.cjs +8 -2
- package/dist-lib/swift-compile.mjs +8 -2
- package/dist-lib/swift-package.cjs +1 -1
- package/dist-lib/swift-package.mjs +1 -1
- 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 +9 -3
- package/dist-lib/vite.cjs +1 -1
- package/package.json +2 -1
- package/src/host/bridge-host.ts +65 -0
- package/src/host/fetch-proxy-handler.ts +52 -23
- package/src/host/fetch-proxy-overrides.ts +5 -1
- package/src/host/fetch-proxy-transport.ts +82 -0
- package/src/swift-compile.ts +8 -2
- package/src/swift-submit.ts +2 -1
package/dist-lib/skills.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.710 | (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;
|
|
@@ -5071,7 +5071,7 @@ var init_supported_native_packages = __esm({
|
|
|
5071
5071
|
"react-native-ota-hot-update",
|
|
5072
5072
|
// seam
|
|
5073
5073
|
"react-native-pager-view",
|
|
5074
|
-
// visual-proof
|
|
5074
|
+
// visual-proof+seam
|
|
5075
5075
|
"react-native-palette-full",
|
|
5076
5076
|
// seam
|
|
5077
5077
|
"react-native-pdf",
|
|
@@ -6738,9 +6738,9 @@ var init_registry = __esm({
|
|
|
6738
6738
|
{
|
|
6739
6739
|
range: ">=6.0.0",
|
|
6740
6740
|
coverage: 0.85,
|
|
6741
|
-
note: "
|
|
6742
|
-
working: "PagerView (default + named), initialPage, scrollEnabled, orientation (horizontal/vertical), onPageSelected, onPageScroll, onPageScrollStateChanged, setPage/setPageWithoutAnimation
|
|
6743
|
-
missing: "
|
|
6741
|
+
note: "the published PagerView JS runs unchanged, page wrappers and the iOS pageMargin margins included; RNCViewPager stands in for the SwiftUI page TabView with the engine's paging scroll view, which clips its pages to the pager's bounds whatever the pager's own overflow.",
|
|
6742
|
+
working: "PagerView (default + named), initialPage, scrollEnabled and setScrollEnabled, orientation (horizontal/vertical), overdrag, keyboardDismissMode, pageMargin, onPageSelected, onPageScroll, onPageScrollStateChanged, setPage/setPageWithoutAnimation via ref, reanimated useEvent handlers",
|
|
6743
|
+
missing: "layoutDirection rtl (the TabView's right-to-left layout is unmeasured), offscreenPageLimit and overScrollMode (Android only)"
|
|
6744
6744
|
}
|
|
6745
6745
|
]
|
|
6746
6746
|
},
|
|
@@ -22018,8 +22018,14 @@ function writeSwiftProject(layout, input, moduleRoot) {
|
|
|
22018
22018
|
}
|
|
22019
22019
|
] : compileTargets(input);
|
|
22020
22020
|
const files = /* @__PURE__ */ new Map();
|
|
22021
|
+
const modulePlan = (0, import_node_crypto3.createHash)("sha256").update(
|
|
22022
|
+
swiftModuleInputFiles(moduleRoot).join("\n")
|
|
22023
|
+
);
|
|
22024
|
+
if (!distribution) {
|
|
22025
|
+
modulePlan.update((0, import_node_fs7.readFileSync)(import_node_path7.default.join(moduleRoot, "Package.swift")));
|
|
22026
|
+
}
|
|
22021
22027
|
const moduleFiles = `
|
|
22022
|
-
// sootsim-swift files ${
|
|
22028
|
+
// sootsim-swift files ${modulePlan.digest("hex").slice(0, 16)}
|
|
22023
22029
|
`;
|
|
22024
22030
|
if (targets.length === 0) {
|
|
22025
22031
|
for (const [file, contents] of Object.entries(input.files)) {
|
|
@@ -23547,7 +23553,7 @@ var init_swift_submit = __esm({
|
|
|
23547
23553
|
MAX_SWIFT_COMPILE_IMAGES = 128;
|
|
23548
23554
|
MAX_SWIFT_COMPILE_IMAGE_BYTES = 4 * 1024 * 1024;
|
|
23549
23555
|
MAX_SWIFT_COMPILE_IMAGE_TOTAL_BYTES = 16 * 1024 * 1024;
|
|
23550
|
-
SWIFT_HOST_ABI =
|
|
23556
|
+
SWIFT_HOST_ABI = 17;
|
|
23551
23557
|
POLL_INTERVAL_MS = 1500;
|
|
23552
23558
|
}
|
|
23553
23559
|
});
|
|
@@ -26009,7 +26015,7 @@ function buildFetchProxyUpstreamHeaders(requestHeaders, targetUrl) {
|
|
|
26009
26015
|
for (const [rawKey, value] of requestHeaders) {
|
|
26010
26016
|
const key = rawKey.toLowerCase();
|
|
26011
26017
|
if (key === FETCH_PROXY_NATIVE_USER_AGENT_HEADER) nativeUserAgent = value;
|
|
26012
|
-
if (STRIP_FETCH_PROXY_REQUEST_HEADERS.has(key) || key.startsWith("x-forwarded-")) {
|
|
26018
|
+
if (key.startsWith(":") || STRIP_FETCH_PROXY_REQUEST_HEADERS.has(key) || key.startsWith("x-forwarded-")) {
|
|
26013
26019
|
continue;
|
|
26014
26020
|
}
|
|
26015
26021
|
headers[key] = value;
|
|
@@ -26093,10 +26099,30 @@ function loopbackTlsOptions(targetUrl) {
|
|
|
26093
26099
|
if (targetUrl.protocol !== "https:") return {};
|
|
26094
26100
|
return isLoopbackHost(targetUrl.hostname) ? { rejectUnauthorized: false } : {};
|
|
26095
26101
|
}
|
|
26096
|
-
function applyFetchProxyCors(res) {
|
|
26102
|
+
function applyFetchProxyCors(req, res) {
|
|
26097
26103
|
for (const [key, value] of Object.entries(FETCH_PROXY_CORS_HEADERS)) {
|
|
26098
26104
|
res.setHeader(key, value);
|
|
26099
26105
|
}
|
|
26106
|
+
res.setHeader("access-control-allow-origin", req.headers.origin ?? "*");
|
|
26107
|
+
res.setHeader("access-control-allow-credentials", "true");
|
|
26108
|
+
res.setHeader(
|
|
26109
|
+
"access-control-allow-headers",
|
|
26110
|
+
req.headers["access-control-request-headers"] ?? "*"
|
|
26111
|
+
);
|
|
26112
|
+
res.setHeader(
|
|
26113
|
+
"access-control-expose-headers",
|
|
26114
|
+
[
|
|
26115
|
+
...Object.keys(res.getHeaders()).filter(
|
|
26116
|
+
(name2) => !name2.startsWith("access-control-")
|
|
26117
|
+
),
|
|
26118
|
+
"x-sootsim-set-cookie"
|
|
26119
|
+
].join(", ")
|
|
26120
|
+
);
|
|
26121
|
+
const vary = res.getHeader("vary");
|
|
26122
|
+
res.setHeader(
|
|
26123
|
+
"vary",
|
|
26124
|
+
vary ? `${Array.isArray(vary) ? vary.join(", ") : vary}, Origin` : "Origin"
|
|
26125
|
+
);
|
|
26100
26126
|
}
|
|
26101
26127
|
function buildFetchProxyHeaders(reqHeaders, targetUrl) {
|
|
26102
26128
|
return buildFetchProxyUpstreamHeaders(nodeRequestHeaderEntries(reqHeaders), targetUrl);
|
|
@@ -26118,6 +26144,9 @@ function buildAppApiProxyHeaders(reqHeaders, targetUrl) {
|
|
|
26118
26144
|
function isFetchProxyRequestUrl(rawUrl) {
|
|
26119
26145
|
return rawUrl?.startsWith("/__fetch-proxy?") || rawUrl?.startsWith("/__proxy?") || false;
|
|
26120
26146
|
}
|
|
26147
|
+
function isBundleProxyRequestUrl(rawUrl) {
|
|
26148
|
+
return rawUrl?.startsWith("/__bundle-proxy?") ?? false;
|
|
26149
|
+
}
|
|
26121
26150
|
function isAppApiRequestUrl(rawUrl) {
|
|
26122
26151
|
if (!rawUrl) return false;
|
|
26123
26152
|
if (rawUrl.startsWith("/__app-api?")) return true;
|
|
@@ -26126,16 +26155,17 @@ function isAppApiRequestUrl(rawUrl) {
|
|
|
26126
26155
|
}
|
|
26127
26156
|
async function handleFetchProxyRequest(req, res) {
|
|
26128
26157
|
if (req.method === "OPTIONS") {
|
|
26129
|
-
applyFetchProxyCors(res);
|
|
26130
|
-
res.
|
|
26158
|
+
applyFetchProxyCors(req, res);
|
|
26159
|
+
res.statusCode = 204;
|
|
26131
26160
|
res.end();
|
|
26132
26161
|
return;
|
|
26133
26162
|
}
|
|
26134
26163
|
const params = new URLSearchParams((req.url || "").split("?")[1] || "");
|
|
26135
26164
|
const targetUrl = params.get("url");
|
|
26136
26165
|
if (!targetUrl) {
|
|
26137
|
-
applyFetchProxyCors(res);
|
|
26138
|
-
res.
|
|
26166
|
+
applyFetchProxyCors(req, res);
|
|
26167
|
+
res.statusCode = 400;
|
|
26168
|
+
res.setHeader("Content-Type", "text/plain");
|
|
26139
26169
|
res.end("missing url param");
|
|
26140
26170
|
return;
|
|
26141
26171
|
}
|
|
@@ -26143,8 +26173,9 @@ async function handleFetchProxyRequest(req, res) {
|
|
|
26143
26173
|
try {
|
|
26144
26174
|
upstreamUrl = resolveFetchProxyTargetUrl(new URL(targetUrl));
|
|
26145
26175
|
} catch {
|
|
26146
|
-
applyFetchProxyCors(res);
|
|
26147
|
-
res.
|
|
26176
|
+
applyFetchProxyCors(req, res);
|
|
26177
|
+
res.statusCode = 400;
|
|
26178
|
+
res.setHeader("Content-Type", "text/plain");
|
|
26148
26179
|
res.end("invalid url param");
|
|
26149
26180
|
return;
|
|
26150
26181
|
}
|
|
@@ -26208,7 +26239,7 @@ async function handleFetchProxyRequest(req, res) {
|
|
|
26208
26239
|
}
|
|
26209
26240
|
res.setHeader(key, value);
|
|
26210
26241
|
}
|
|
26211
|
-
applyFetchProxyCors(res);
|
|
26242
|
+
applyFetchProxyCors(req, res);
|
|
26212
26243
|
const setCookie = proxyRes.headers["set-cookie"] ?? [];
|
|
26213
26244
|
if (setCookie.length > 0) {
|
|
26214
26245
|
res.setHeader(
|
|
@@ -26245,15 +26276,17 @@ async function handleFetchProxyRequest(req, res) {
|
|
|
26245
26276
|
}
|
|
26246
26277
|
}
|
|
26247
26278
|
}
|
|
26248
|
-
req.
|
|
26279
|
+
if (req instanceof import_node_http2.Http2ServerRequest) req.stream.destroy();
|
|
26280
|
+
else req.socket.destroy();
|
|
26249
26281
|
}
|
|
26250
26282
|
}
|
|
26251
26283
|
async function handleBundleProxyRequest(req, res) {
|
|
26252
26284
|
const params = new URLSearchParams((req.url || "").split("?")[1] || "");
|
|
26253
26285
|
const target = params.get("url");
|
|
26254
26286
|
if (!target) {
|
|
26255
|
-
applyFetchProxyCors(res);
|
|
26256
|
-
res.
|
|
26287
|
+
applyFetchProxyCors(req, res);
|
|
26288
|
+
res.statusCode = 400;
|
|
26289
|
+
res.setHeader("Content-Type", "text/plain");
|
|
26257
26290
|
res.end("bundle-proxy: missing url query param");
|
|
26258
26291
|
return;
|
|
26259
26292
|
}
|
|
@@ -26261,14 +26294,16 @@ async function handleBundleProxyRequest(req, res) {
|
|
|
26261
26294
|
try {
|
|
26262
26295
|
targetUrl = new URL(target);
|
|
26263
26296
|
} catch {
|
|
26264
|
-
applyFetchProxyCors(res);
|
|
26265
|
-
res.
|
|
26297
|
+
applyFetchProxyCors(req, res);
|
|
26298
|
+
res.statusCode = 400;
|
|
26299
|
+
res.setHeader("Content-Type", "text/plain");
|
|
26266
26300
|
res.end("bundle-proxy: invalid url");
|
|
26267
26301
|
return;
|
|
26268
26302
|
}
|
|
26269
26303
|
if (!isLoopbackHost(targetUrl.hostname)) {
|
|
26270
|
-
applyFetchProxyCors(res);
|
|
26271
|
-
res.
|
|
26304
|
+
applyFetchProxyCors(req, res);
|
|
26305
|
+
res.statusCode = 403;
|
|
26306
|
+
res.setHeader("Content-Type", "text/plain");
|
|
26272
26307
|
res.end("bundle-proxy: only loopback targets allowed");
|
|
26273
26308
|
return;
|
|
26274
26309
|
}
|
|
@@ -26341,22 +26376,20 @@ function handleAppApiRequest(req, res) {
|
|
|
26341
26376
|
req.pipe(proxyReq);
|
|
26342
26377
|
return true;
|
|
26343
26378
|
}
|
|
26344
|
-
var import_http2, import_https, import_promises4, fetchProxyHttpAgent, fetchProxyHttpsAgent, FETCH_PROXY_CORS_HEADERS, APP_API_HEADER_REWRITES;
|
|
26379
|
+
var import_http2, import_https, import_node_http2, import_promises4, fetchProxyHttpAgent, fetchProxyHttpsAgent, FETCH_PROXY_CORS_HEADERS, APP_API_HEADER_REWRITES;
|
|
26345
26380
|
var init_fetch_proxy_handler = __esm({
|
|
26346
26381
|
"src/host/fetch-proxy-handler.ts"() {
|
|
26347
26382
|
"use strict";
|
|
26348
26383
|
import_http2 = __toESM(require("http"), 1);
|
|
26349
26384
|
import_https = __toESM(require("https"), 1);
|
|
26385
|
+
import_node_http2 = require("node:http2");
|
|
26350
26386
|
import_promises4 = require("stream/promises");
|
|
26351
26387
|
init_backend_origin();
|
|
26352
26388
|
init_fetch_proxy_overrides();
|
|
26353
26389
|
fetchProxyHttpAgent = new import_http2.default.Agent({ keepAlive: true, maxSockets: 256 });
|
|
26354
26390
|
fetchProxyHttpsAgent = new import_https.default.Agent({ keepAlive: true, maxSockets: 256 });
|
|
26355
26391
|
FETCH_PROXY_CORS_HEADERS = {
|
|
26356
|
-
"access-control-allow-
|
|
26357
|
-
"access-control-allow-methods": "GET,POST,PUT,DELETE,PATCH,OPTIONS",
|
|
26358
|
-
"access-control-allow-headers": "*",
|
|
26359
|
-
"access-control-expose-headers": "*",
|
|
26392
|
+
"access-control-allow-methods": "GET,HEAD,POST,PUT,DELETE,PATCH,OPTIONS",
|
|
26360
26393
|
"access-control-max-age": "3600"
|
|
26361
26394
|
};
|
|
26362
26395
|
APP_API_HEADER_REWRITES = /* @__PURE__ */ new Set([
|
|
@@ -26370,6 +26403,82 @@ var init_fetch_proxy_handler = __esm({
|
|
|
26370
26403
|
}
|
|
26371
26404
|
});
|
|
26372
26405
|
|
|
26406
|
+
// src/host/fetch-proxy-transport.ts
|
|
26407
|
+
async function startFetchProxyTransport() {
|
|
26408
|
+
const algorithm = { name: "ECDSA", namedCurve: "P-256", hash: "SHA-256" };
|
|
26409
|
+
const keys = await crypto.subtle.generateKey(algorithm, true, ["sign", "verify"]);
|
|
26410
|
+
const certificate = await import_x509.X509CertificateGenerator.createSelfSigned(
|
|
26411
|
+
{
|
|
26412
|
+
serialNumber: (0, import_node_crypto10.randomBytes)(16).toString("hex"),
|
|
26413
|
+
name: "CN=localhost",
|
|
26414
|
+
notBefore: new Date(Date.now() - 6e4),
|
|
26415
|
+
notAfter: new Date(Date.now() + 365 * 24 * 60 * 6e4),
|
|
26416
|
+
signingAlgorithm: algorithm,
|
|
26417
|
+
keys,
|
|
26418
|
+
extensions: [
|
|
26419
|
+
new import_x509.SubjectAlternativeNameExtension([{ type: "ip", value: "127.0.0.1" }])
|
|
26420
|
+
]
|
|
26421
|
+
},
|
|
26422
|
+
crypto
|
|
26423
|
+
);
|
|
26424
|
+
const privateKey = Buffer.from(await crypto.subtle.exportKey("pkcs8", keys.privateKey));
|
|
26425
|
+
const spki = (0, import_node_crypto10.createHash)("sha256").update(Buffer.from(await crypto.subtle.exportKey("spki", keys.publicKey))).digest("base64");
|
|
26426
|
+
const sessions = /* @__PURE__ */ new Set();
|
|
26427
|
+
const server = (0, import_node_http22.createSecureServer)(
|
|
26428
|
+
{
|
|
26429
|
+
cert: certificate.toString("pem"),
|
|
26430
|
+
key: `-----BEGIN PRIVATE KEY-----
|
|
26431
|
+
${privateKey.toString("base64").match(/.{1,64}/g)?.join("\n")}
|
|
26432
|
+
-----END PRIVATE KEY-----
|
|
26433
|
+
`,
|
|
26434
|
+
settings: { maxConcurrentStreams: 256 }
|
|
26435
|
+
},
|
|
26436
|
+
(req, res) => {
|
|
26437
|
+
res.setHeader("Cross-Origin-Resource-Policy", "cross-origin");
|
|
26438
|
+
res.setHeader("Timing-Allow-Origin", "*");
|
|
26439
|
+
const handler = isBundleProxyRequestUrl(req.url) ? handleBundleProxyRequest : isFetchProxyRequestUrl(req.url) ? handleFetchProxyRequest : null;
|
|
26440
|
+
if (!handler) {
|
|
26441
|
+
res.writeHead(404);
|
|
26442
|
+
res.end();
|
|
26443
|
+
return;
|
|
26444
|
+
}
|
|
26445
|
+
void handler(req, res).catch(() => res.destroy());
|
|
26446
|
+
}
|
|
26447
|
+
);
|
|
26448
|
+
server.on("session", (session) => {
|
|
26449
|
+
sessions.add(session);
|
|
26450
|
+
session.once("close", () => sessions.delete(session));
|
|
26451
|
+
session.on("error", () => session.destroy());
|
|
26452
|
+
});
|
|
26453
|
+
await new Promise((resolve10, reject) => {
|
|
26454
|
+
server.once("error", reject);
|
|
26455
|
+
server.listen(0, "127.0.0.1", () => {
|
|
26456
|
+
server.off("error", reject);
|
|
26457
|
+
resolve10();
|
|
26458
|
+
});
|
|
26459
|
+
});
|
|
26460
|
+
const address = server.address();
|
|
26461
|
+
if (!address || typeof address === "string")
|
|
26462
|
+
throw new Error("fetch proxy has no address");
|
|
26463
|
+
return {
|
|
26464
|
+
descriptor: { origin: `https://127.0.0.1:${address.port}`, spki },
|
|
26465
|
+
async close() {
|
|
26466
|
+
for (const session of sessions) session.destroy();
|
|
26467
|
+
await new Promise((resolve10) => server.close(() => resolve10()));
|
|
26468
|
+
}
|
|
26469
|
+
};
|
|
26470
|
+
}
|
|
26471
|
+
var import_node_crypto10, import_node_http22, import_x509;
|
|
26472
|
+
var init_fetch_proxy_transport = __esm({
|
|
26473
|
+
"src/host/fetch-proxy-transport.ts"() {
|
|
26474
|
+
"use strict";
|
|
26475
|
+
import_node_crypto10 = require("node:crypto");
|
|
26476
|
+
import_node_http22 = require("node:http2");
|
|
26477
|
+
import_x509 = require("@peculiar/x509");
|
|
26478
|
+
init_fetch_proxy_handler();
|
|
26479
|
+
}
|
|
26480
|
+
});
|
|
26481
|
+
|
|
26373
26482
|
// src/host/open-url.ts
|
|
26374
26483
|
function buildOpenUrlCommand(url, options = {}) {
|
|
26375
26484
|
if (!url) throw new Error("openUrl requires a url");
|
|
@@ -31175,7 +31284,7 @@ function listMetroAssetDest(assetsPath) {
|
|
|
31175
31284
|
return { directory, files, truncated };
|
|
31176
31285
|
}
|
|
31177
31286
|
function metroDescriptorHash(scaleBytes) {
|
|
31178
|
-
const hasher = (0,
|
|
31287
|
+
const hasher = (0, import_node_crypto11.createHash)("md5");
|
|
31179
31288
|
for (const bytes of scaleBytes) hasher.update(bytes);
|
|
31180
31289
|
return hasher.digest("hex");
|
|
31181
31290
|
}
|
|
@@ -31204,7 +31313,7 @@ function distinctByContent(directory, options) {
|
|
|
31204
31313
|
} catch {
|
|
31205
31314
|
continue;
|
|
31206
31315
|
}
|
|
31207
|
-
const digest = (0,
|
|
31316
|
+
const digest = (0, import_node_crypto11.createHash)("md5").update(bytes).digest("hex");
|
|
31208
31317
|
if (!byContent.has(digest)) byContent.set(digest, relative2);
|
|
31209
31318
|
}
|
|
31210
31319
|
return [...byContent.values()];
|
|
@@ -31238,7 +31347,7 @@ function placeMetroDescriptor(listing, descriptor) {
|
|
|
31238
31347
|
continue;
|
|
31239
31348
|
}
|
|
31240
31349
|
const identical = fileHashes ? bytes.every((file, index) => {
|
|
31241
|
-
const digest = (0,
|
|
31350
|
+
const digest = (0, import_node_crypto11.createHash)("md5").update(file).digest("hex");
|
|
31242
31351
|
return descriptor.scales.some(
|
|
31243
31352
|
(scale, declared) => scale === scales[index] && fileHashes[declared] === digest
|
|
31244
31353
|
);
|
|
@@ -31473,7 +31582,7 @@ async function produceArtifact(bundlePath, maxBytes, command, assetPolicy) {
|
|
|
31473
31582
|
}
|
|
31474
31583
|
return {
|
|
31475
31584
|
bytes,
|
|
31476
|
-
sha256: (0,
|
|
31585
|
+
sha256: (0, import_node_crypto11.createHash)("sha256").update(bytes).digest("hex"),
|
|
31477
31586
|
receipt: artifact.receipt,
|
|
31478
31587
|
assetsDirectory: prepared.dest?.directory ?? null,
|
|
31479
31588
|
warnings
|
|
@@ -31618,11 +31727,11 @@ function createCloudBridgeForParsed(parsed) {
|
|
|
31618
31727
|
if (!session) return null;
|
|
31619
31728
|
return session.service === "box" ? new CloudBoxBridge(session) : new CloudBridge(session);
|
|
31620
31729
|
}
|
|
31621
|
-
var
|
|
31730
|
+
var import_node_crypto11, import_node_fs23, import_node_path23, DEFAULT_RNX_CLOUD_ORIGIN, MAX_RNX_CLOUD_BUNDLE_BYTES, REMOTE_COMMAND, MAX_ASSET_DEST_FILES, ACCOUNT_CHOICE_REFUSALS, PROJECT_ONLY_DIRECTORIES, MAX_PLACEMENT_COMBINATIONS, CloudBridge, CloudBoxBridge;
|
|
31622
31731
|
var init_cloud_client = __esm({
|
|
31623
31732
|
"cli/cloud-client.ts"() {
|
|
31624
31733
|
"use strict";
|
|
31625
|
-
|
|
31734
|
+
import_node_crypto11 = require("node:crypto");
|
|
31626
31735
|
import_node_fs23 = require("node:fs");
|
|
31627
31736
|
import_node_path23 = require("node:path");
|
|
31628
31737
|
init_metroAssetArtifact();
|
|
@@ -31664,7 +31773,7 @@ var init_cloud_client = __esm({
|
|
|
31664
31773
|
plane = "cloud";
|
|
31665
31774
|
async send(command, options) {
|
|
31666
31775
|
const body = {
|
|
31667
|
-
id: (0,
|
|
31776
|
+
id: (0, import_node_crypto11.randomUUID)(),
|
|
31668
31777
|
claimId: this.session.claimId,
|
|
31669
31778
|
command: cloudCommand(command)
|
|
31670
31779
|
};
|
|
@@ -31734,7 +31843,7 @@ var init_cloud_client = __esm({
|
|
|
31734
31843
|
}
|
|
31735
31844
|
plane = "cloud";
|
|
31736
31845
|
async send(command, options) {
|
|
31737
|
-
const id = (0,
|
|
31846
|
+
const id = (0, import_node_crypto11.randomUUID)();
|
|
31738
31847
|
const payload = {};
|
|
31739
31848
|
for (const [key, value] of Object.entries(command)) {
|
|
31740
31849
|
if (key !== "id" && key !== "simId") payload[key] = value;
|
|
@@ -31867,6 +31976,16 @@ __export(bridge_host_exports, {
|
|
|
31867
31976
|
SootSimBridgeHost: () => SootSimBridgeHost,
|
|
31868
31977
|
injectSharedConfigIntoHtml: () => injectSharedConfigIntoHtml
|
|
31869
31978
|
});
|
|
31979
|
+
function isProcessGroupAlive(pgid) {
|
|
31980
|
+
if (!Number.isInteger(pgid) || pgid <= 1) return true;
|
|
31981
|
+
try {
|
|
31982
|
+
process.kill(-pgid, 0);
|
|
31983
|
+
return true;
|
|
31984
|
+
} catch (error) {
|
|
31985
|
+
const code = error && typeof error === "object" ? Reflect.get(error, "code") : null;
|
|
31986
|
+
return code !== "ESRCH";
|
|
31987
|
+
}
|
|
31988
|
+
}
|
|
31870
31989
|
function shouldAcquireLease(msg) {
|
|
31871
31990
|
if (!msg || typeof msg.type !== "string") return false;
|
|
31872
31991
|
if (msg.acquireLock === true) return true;
|
|
@@ -31917,6 +32036,7 @@ var init_bridge_host = __esm({
|
|
|
31917
32036
|
init_runtime_delivery();
|
|
31918
32037
|
init_agent_host();
|
|
31919
32038
|
init_fetch_proxy_handler();
|
|
32039
|
+
init_fetch_proxy_transport();
|
|
31920
32040
|
init_open_url();
|
|
31921
32041
|
init_plane_host();
|
|
31922
32042
|
init_replacement_module_handler();
|
|
@@ -31969,6 +32089,7 @@ var init_bridge_host = __esm({
|
|
|
31969
32089
|
openUrlHandler;
|
|
31970
32090
|
httpServer = null;
|
|
31971
32091
|
wss = null;
|
|
32092
|
+
fetchProxyTransport = null;
|
|
31972
32093
|
nextCommandId = 1;
|
|
31973
32094
|
nextSimNumber = 161;
|
|
31974
32095
|
sims = /* @__PURE__ */ new Map();
|
|
@@ -31979,6 +32100,7 @@ var init_bridge_host = __esm({
|
|
|
31979
32100
|
cliLastCommandAt = /* @__PURE__ */ new Map();
|
|
31980
32101
|
cliIdentityKeyBySocket = /* @__PURE__ */ new Map();
|
|
31981
32102
|
cliLabelBySocket = /* @__PURE__ */ new Map();
|
|
32103
|
+
cliOwnerPgidBySocket = /* @__PURE__ */ new Map();
|
|
31982
32104
|
restorableSims = /* @__PURE__ */ new Map();
|
|
31983
32105
|
nextCliFallbackId = 1;
|
|
31984
32106
|
cliIdleTimer = null;
|
|
@@ -32078,6 +32200,12 @@ var init_bridge_host = __esm({
|
|
|
32078
32200
|
`
|
|
32079
32201
|
);
|
|
32080
32202
|
}
|
|
32203
|
+
try {
|
|
32204
|
+
this.fetchProxyTransport = await startFetchProxyTransport();
|
|
32205
|
+
} catch (error) {
|
|
32206
|
+
await this.close();
|
|
32207
|
+
throw error;
|
|
32208
|
+
}
|
|
32081
32209
|
this.afterBind();
|
|
32082
32210
|
return boundPort;
|
|
32083
32211
|
} catch (err) {
|
|
@@ -32372,6 +32500,7 @@ var init_bridge_host = __esm({
|
|
|
32372
32500
|
this.cliLastCommandAt.delete(ws);
|
|
32373
32501
|
this.cliIdentityKeyBySocket.delete(ws);
|
|
32374
32502
|
this.cliLabelBySocket.delete(ws);
|
|
32503
|
+
this.cliOwnerPgidBySocket.delete(ws);
|
|
32375
32504
|
for (const [sentId2, entry] of this.cliBySentId) {
|
|
32376
32505
|
if (entry.ws === ws) this.cliBySentId.delete(sentId2);
|
|
32377
32506
|
}
|
|
@@ -32384,6 +32513,11 @@ var init_bridge_host = __esm({
|
|
|
32384
32513
|
if (typeof msg.cliLabel === "string" && msg.cliLabel.trim()) {
|
|
32385
32514
|
this.cliLabelBySocket.set(ws, msg.cliLabel.trim());
|
|
32386
32515
|
}
|
|
32516
|
+
if (typeof msg.cliOwnerPgid === "number" && Number.isInteger(msg.cliOwnerPgid) && msg.cliOwnerPgid > 1) {
|
|
32517
|
+
this.cliOwnerPgidBySocket.set(ws, msg.cliOwnerPgid);
|
|
32518
|
+
} else {
|
|
32519
|
+
this.cliOwnerPgidBySocket.delete(ws);
|
|
32520
|
+
}
|
|
32387
32521
|
if (ws.readyState === import_ws.WebSocket.OPEN) {
|
|
32388
32522
|
ws.send(
|
|
32389
32523
|
JSON.stringify({
|
|
@@ -32534,6 +32668,7 @@ var init_bridge_host = __esm({
|
|
|
32534
32668
|
this.cliLastCommandAt.delete(ws);
|
|
32535
32669
|
this.cliIdentityKeyBySocket.delete(ws);
|
|
32536
32670
|
this.cliLabelBySocket.delete(ws);
|
|
32671
|
+
this.cliOwnerPgidBySocket.delete(ws);
|
|
32537
32672
|
for (const [sentId, entry] of this.cliBySentId) {
|
|
32538
32673
|
if (entry.ws === ws) this.cliBySentId.delete(sentId);
|
|
32539
32674
|
}
|
|
@@ -32893,6 +33028,14 @@ var init_bridge_host = __esm({
|
|
|
32893
33028
|
* non-upgrade routes that don't match serve index.html (SPA behavior) so
|
|
32894
33029
|
* electron's webContents can navigate freely inside the runtime. */
|
|
32895
33030
|
handleHttpRequest(req, res) {
|
|
33031
|
+
if (req.url === "/__peach/fetch-transport") {
|
|
33032
|
+
res.writeHead(200, {
|
|
33033
|
+
"Content-Type": "application/json",
|
|
33034
|
+
"Cache-Control": "no-store"
|
|
33035
|
+
});
|
|
33036
|
+
res.end(JSON.stringify(this.fetchProxyTransport?.descriptor));
|
|
33037
|
+
return;
|
|
33038
|
+
}
|
|
32896
33039
|
res.setHeader("Cross-Origin-Opener-Policy", "same-origin");
|
|
32897
33040
|
res.setHeader("Cross-Origin-Embedder-Policy", SOOTSIM_CROSS_ORIGIN_EMBEDDER_POLICY);
|
|
32898
33041
|
res.setHeader("Cross-Origin-Resource-Policy", "cross-origin");
|
|
@@ -33455,6 +33598,8 @@ var init_bridge_host = __esm({
|
|
|
33455
33598
|
} catch {
|
|
33456
33599
|
}
|
|
33457
33600
|
}
|
|
33601
|
+
await this.fetchProxyTransport?.close();
|
|
33602
|
+
this.fetchProxyTransport = null;
|
|
33458
33603
|
this.effectivePort = 0;
|
|
33459
33604
|
this.startedAt = 0;
|
|
33460
33605
|
this.agentHost.close();
|
|
@@ -33519,6 +33664,10 @@ var init_bridge_host = __esm({
|
|
|
33519
33664
|
sim.cliLease = void 0;
|
|
33520
33665
|
return null;
|
|
33521
33666
|
}
|
|
33667
|
+
if (lease.kind === "cli" && lease.ownerPgid !== void 0 && !isProcessGroupAlive(lease.ownerPgid)) {
|
|
33668
|
+
sim.cliLease = void 0;
|
|
33669
|
+
return null;
|
|
33670
|
+
}
|
|
33522
33671
|
return lease;
|
|
33523
33672
|
}
|
|
33524
33673
|
tryAcquireLease(ws, sim, opts = {}) {
|
|
@@ -33561,7 +33710,8 @@ var init_bridge_host = __esm({
|
|
|
33561
33710
|
kind: "cli",
|
|
33562
33711
|
cliIdentityKey,
|
|
33563
33712
|
cliLabel,
|
|
33564
|
-
expiresAt: now + _SootSimBridgeHost.CLI_LEASE_TTL_MS
|
|
33713
|
+
expiresAt: now + _SootSimBridgeHost.CLI_LEASE_TTL_MS,
|
|
33714
|
+
ownerPgid: this.cliOwnerPgidBySocket.get(ws)
|
|
33565
33715
|
};
|
|
33566
33716
|
sim.cliLease = lease;
|
|
33567
33717
|
return { granted: true, lease, bootedCount };
|
|
@@ -33891,6 +34041,14 @@ function getProcessComm(pid) {
|
|
|
33891
34041
|
return null;
|
|
33892
34042
|
}
|
|
33893
34043
|
}
|
|
34044
|
+
function getProcessPgid(pid) {
|
|
34045
|
+
if (!cachedPgid) cachedPgid = buildPgid();
|
|
34046
|
+
try {
|
|
34047
|
+
return cachedPgid(pid);
|
|
34048
|
+
} catch {
|
|
34049
|
+
return null;
|
|
34050
|
+
}
|
|
34051
|
+
}
|
|
33894
34052
|
function buildComm() {
|
|
33895
34053
|
if (process.platform === "linux") {
|
|
33896
34054
|
return (pid) => {
|
|
@@ -33924,6 +34082,31 @@ function build() {
|
|
|
33924
34082
|
}
|
|
33925
34083
|
return () => null;
|
|
33926
34084
|
}
|
|
34085
|
+
function buildPgid() {
|
|
34086
|
+
if (process.platform === "linux") {
|
|
34087
|
+
return (pid) => {
|
|
34088
|
+
try {
|
|
34089
|
+
const raw2 = (0, import_fs3.readFileSync)(`/proc/${pid}/stat`, "utf8");
|
|
34090
|
+
const end = raw2.lastIndexOf(")");
|
|
34091
|
+
if (end < 0) return null;
|
|
34092
|
+
const rest = raw2.slice(end + 1).trim().split(/\s+/);
|
|
34093
|
+
const pgid = Number(rest[2]);
|
|
34094
|
+
return Number.isFinite(pgid) && pgid > 0 ? pgid : null;
|
|
34095
|
+
} catch {
|
|
34096
|
+
return null;
|
|
34097
|
+
}
|
|
34098
|
+
};
|
|
34099
|
+
}
|
|
34100
|
+
if (process.platform === "darwin") {
|
|
34101
|
+
const ffi = tryBuildDarwinPgidFfi();
|
|
34102
|
+
if (ffi) return ffi;
|
|
34103
|
+
return (pid) => {
|
|
34104
|
+
const pgid = readProcessTable().get(pid)?.pgid;
|
|
34105
|
+
return pgid !== void 0 && pgid > 0 ? pgid : null;
|
|
34106
|
+
};
|
|
34107
|
+
}
|
|
34108
|
+
return () => null;
|
|
34109
|
+
}
|
|
33927
34110
|
function readProcessTable() {
|
|
33928
34111
|
const now = Date.now();
|
|
33929
34112
|
if (processTable.readAt && now - processTable.readAt < PROCESS_TABLE_TTL_MS) {
|
|
@@ -33931,18 +34114,19 @@ function readProcessTable() {
|
|
|
33931
34114
|
}
|
|
33932
34115
|
const rows = /* @__PURE__ */ new Map();
|
|
33933
34116
|
try {
|
|
33934
|
-
const out = (0, import_child_process4.execFileSync)("ps", ["-eo", "pid=,ppid=,comm="], {
|
|
34117
|
+
const out = (0, import_child_process4.execFileSync)("ps", ["-eo", "pid=,ppid=,pgid=,comm="], {
|
|
33935
34118
|
encoding: "utf8",
|
|
33936
34119
|
timeout: 5e3,
|
|
33937
34120
|
maxBuffer: 8 * 1024 * 1024,
|
|
33938
34121
|
stdio: ["ignore", "pipe", "ignore"]
|
|
33939
34122
|
});
|
|
33940
34123
|
for (const line of out.split("\n")) {
|
|
33941
|
-
const parsed = line.trim().match(/^(\d+)\s+(\d+)\s+(.*)$/);
|
|
34124
|
+
const parsed = line.trim().match(/^(\d+)\s+(\d+)\s+(\d+)\s+(.*)$/);
|
|
33942
34125
|
if (!parsed) continue;
|
|
33943
34126
|
rows.set(Number(parsed[1]), {
|
|
33944
34127
|
ppid: Number(parsed[2]),
|
|
33945
|
-
|
|
34128
|
+
pgid: Number(parsed[3]),
|
|
34129
|
+
comm: (parsed[4].split("/").at(-1) ?? "").slice(0, PBI_COMM_LEN)
|
|
33946
34130
|
});
|
|
33947
34131
|
}
|
|
33948
34132
|
} catch {
|
|
@@ -34014,7 +34198,31 @@ function tryBuildDarwinCommFfi() {
|
|
|
34014
34198
|
return null;
|
|
34015
34199
|
}
|
|
34016
34200
|
}
|
|
34017
|
-
|
|
34201
|
+
function tryBuildDarwinPgidFfi() {
|
|
34202
|
+
if (!process.versions?.bun) return null;
|
|
34203
|
+
try {
|
|
34204
|
+
const r = (0, import_module.createRequire)(__sootsim_import_meta_url);
|
|
34205
|
+
const { dlopen, FFIType } = r("bun:ffi");
|
|
34206
|
+
const lib = dlopen("/usr/lib/libproc.dylib", {
|
|
34207
|
+
proc_pidinfo: {
|
|
34208
|
+
args: [FFIType.i32, FFIType.i32, FFIType.u64, FFIType.ptr, FFIType.i32],
|
|
34209
|
+
returns: FFIType.i32
|
|
34210
|
+
}
|
|
34211
|
+
});
|
|
34212
|
+
const buf = Buffer.alloc(PROC_BSDINFO_SIZE);
|
|
34213
|
+
return (pid) => {
|
|
34214
|
+
const ret = Number(
|
|
34215
|
+
lib.symbols.proc_pidinfo(pid, PROC_PIDTBSDINFO, 0n, buf, PROC_BSDINFO_SIZE)
|
|
34216
|
+
);
|
|
34217
|
+
if (ret <= 0) return null;
|
|
34218
|
+
const pgid = buf.readUInt32LE(PBI_PGID_OFFSET);
|
|
34219
|
+
return pgid > 0 ? pgid : null;
|
|
34220
|
+
};
|
|
34221
|
+
} catch {
|
|
34222
|
+
return null;
|
|
34223
|
+
}
|
|
34224
|
+
}
|
|
34225
|
+
var import_child_process4, import_fs3, import_module, cached3, cachedComm, cachedPgid, PROCESS_TABLE_TTL_MS, processTable, PROC_PIDTBSDINFO, PROC_BSDINFO_SIZE, PBI_PPID_OFFSET, PBI_COMM_OFFSET, PBI_COMM_LEN, PBI_PGID_OFFSET;
|
|
34018
34226
|
var init_parent_pid = __esm({
|
|
34019
34227
|
"cli/parent-pid.ts"() {
|
|
34020
34228
|
"use strict";
|
|
@@ -34023,6 +34231,7 @@ var init_parent_pid = __esm({
|
|
|
34023
34231
|
import_module = require("module");
|
|
34024
34232
|
cached3 = null;
|
|
34025
34233
|
cachedComm = null;
|
|
34234
|
+
cachedPgid = null;
|
|
34026
34235
|
PROCESS_TABLE_TTL_MS = 2e3;
|
|
34027
34236
|
processTable = { readAt: 0, rows: /* @__PURE__ */ new Map() };
|
|
34028
34237
|
PROC_PIDTBSDINFO = 3;
|
|
@@ -34030,13 +34239,14 @@ var init_parent_pid = __esm({
|
|
|
34030
34239
|
PBI_PPID_OFFSET = 16;
|
|
34031
34240
|
PBI_COMM_OFFSET = 48;
|
|
34032
34241
|
PBI_COMM_LEN = 16;
|
|
34242
|
+
PBI_PGID_OFFSET = 100;
|
|
34033
34243
|
}
|
|
34034
34244
|
});
|
|
34035
34245
|
|
|
34036
34246
|
// cli/secure-file.ts
|
|
34037
34247
|
function writeSecureJsonAtomic(filepath, value) {
|
|
34038
34248
|
(0, import_node_fs24.mkdirSync)((0, import_node_path24.dirname)(filepath), { recursive: true });
|
|
34039
|
-
const temporary = `${filepath}.tmp-${process.pid}-${(0,
|
|
34249
|
+
const temporary = `${filepath}.tmp-${process.pid}-${(0, import_node_crypto12.randomUUID)()}`;
|
|
34040
34250
|
let descriptor = null;
|
|
34041
34251
|
try {
|
|
34042
34252
|
descriptor = (0, import_node_fs24.openSync)(temporary, "wx", 384);
|
|
@@ -34053,11 +34263,11 @@ function writeSecureJsonAtomic(filepath, value) {
|
|
|
34053
34263
|
throw error;
|
|
34054
34264
|
}
|
|
34055
34265
|
}
|
|
34056
|
-
var
|
|
34266
|
+
var import_node_crypto12, import_node_fs24, import_node_path24;
|
|
34057
34267
|
var init_secure_file = __esm({
|
|
34058
34268
|
"cli/secure-file.ts"() {
|
|
34059
34269
|
"use strict";
|
|
34060
|
-
|
|
34270
|
+
import_node_crypto12 = require("node:crypto");
|
|
34061
34271
|
import_node_fs24 = require("node:fs");
|
|
34062
34272
|
import_node_path24 = require("node:path");
|
|
34063
34273
|
}
|
|
@@ -34102,6 +34312,12 @@ function getCliIdentityKey() {
|
|
|
34102
34312
|
function getStableOwnerPid() {
|
|
34103
34313
|
return findTopAncestor(process.ppid);
|
|
34104
34314
|
}
|
|
34315
|
+
function getOwnerProcessGroupId() {
|
|
34316
|
+
const owner = getStableOwnerPid();
|
|
34317
|
+
if (!owner || owner <= 1) return null;
|
|
34318
|
+
const pgid = getProcessPgid(owner);
|
|
34319
|
+
return pgid !== null && pgid > 1 ? pgid : null;
|
|
34320
|
+
}
|
|
34105
34321
|
function getCurrentSimPath() {
|
|
34106
34322
|
if (process.env[CURRENT_SIM_PATH_ENV]) {
|
|
34107
34323
|
return (0, import_path3.resolve)(process.env[CURRENT_SIM_PATH_ENV]);
|
|
@@ -34467,7 +34683,11 @@ function createBridge(wsPort, opts = {}) {
|
|
|
34467
34683
|
id: 0,
|
|
34468
34684
|
cliIdentityKey: identity.key,
|
|
34469
34685
|
cliIdentitySource: identity.source,
|
|
34470
|
-
cliLabel: opts.cliLabel
|
|
34686
|
+
cliLabel: opts.cliLabel,
|
|
34687
|
+
// lets the bridge free this cli's leases once its owning
|
|
34688
|
+
// session is entirely gone, instead of blocking others
|
|
34689
|
+
// until the TTL burns out. null when ancestry is unreadable.
|
|
34690
|
+
cliOwnerPgid: getOwnerProcessGroupId()
|
|
34471
34691
|
})
|
|
34472
34692
|
);
|
|
34473
34693
|
} catch {
|
|
@@ -38644,6 +38864,32 @@ async function launch2(opts) {
|
|
|
38644
38864
|
message: `playwright provisioning failed: ${error instanceof Error ? error.message : String(error)}`
|
|
38645
38865
|
};
|
|
38646
38866
|
}
|
|
38867
|
+
const targetUrl = new URL(opts.url);
|
|
38868
|
+
let fetchProxySpki = "";
|
|
38869
|
+
if (opts.bridgePort) {
|
|
38870
|
+
try {
|
|
38871
|
+
const response = await fetch(
|
|
38872
|
+
`http://127.0.0.1:${opts.bridgePort}/__peach/fetch-transport`,
|
|
38873
|
+
{ signal: AbortSignal.timeout(1e4) }
|
|
38874
|
+
);
|
|
38875
|
+
if (!response.ok) throw new Error(`transport discovery returned ${response.status}`);
|
|
38876
|
+
const descriptor = await response.json();
|
|
38877
|
+
if (!descriptor || typeof descriptor !== "object")
|
|
38878
|
+
throw new Error("invalid fetch transport");
|
|
38879
|
+
const origin = Reflect.get(descriptor, "origin");
|
|
38880
|
+
const spki = Reflect.get(descriptor, "spki");
|
|
38881
|
+
if (typeof origin !== "string" || !/^https:\/\/127\.0\.0\.1:\d+$/.test(origin) || typeof spki !== "string" || !/^[A-Za-z0-9+/]{43}=$/.test(spki)) {
|
|
38882
|
+
throw new Error("invalid fetch transport");
|
|
38883
|
+
}
|
|
38884
|
+
targetUrl.searchParams.set("fetchProxyOrigin", origin);
|
|
38885
|
+
fetchProxySpki = spki;
|
|
38886
|
+
} catch (error) {
|
|
38887
|
+
return {
|
|
38888
|
+
launched: false,
|
|
38889
|
+
message: `fetch transport discovery failed: ${String(error)}`
|
|
38890
|
+
};
|
|
38891
|
+
}
|
|
38892
|
+
}
|
|
38647
38893
|
const playwrightEnv = { ...process.env };
|
|
38648
38894
|
const provisioning = await ensurePlaywrightBrowser(
|
|
38649
38895
|
resolved,
|
|
@@ -38671,7 +38917,8 @@ async function launch2(opts) {
|
|
|
38671
38917
|
...playwrightEnv,
|
|
38672
38918
|
SOOTSIM_PW_MODULE: resolved.modulePath,
|
|
38673
38919
|
SOOTSIM_PW_EXECUTABLE: provisioning.executablePath,
|
|
38674
|
-
SOOTSIM_PW_URL:
|
|
38920
|
+
SOOTSIM_PW_URL: targetUrl.href,
|
|
38921
|
+
PEACH_PW_FETCH_PROXY_SPKI: fetchProxySpki,
|
|
38675
38922
|
SOOTSIM_PW_BRIDGE_PORT: opts.bridgePort ? String(opts.bridgePort) : "",
|
|
38676
38923
|
SOOTSIM_PW_HEADLESS: opts.headless ?? true ? "1" : "0",
|
|
38677
38924
|
SOOTSIM_PW_USERDATADIR: resolveUserDataDir(opts),
|
|
@@ -38710,10 +38957,10 @@ ${hint}` : ""}`
|
|
|
38710
38957
|
const ownerNote = ` \u2014 browser closes after ${idleMinutes} min with no peach command, or when pid ${ownerPid}${ownerComm ? ` (${ownerComm})` : ""} exits`;
|
|
38711
38958
|
return {
|
|
38712
38959
|
launched: true,
|
|
38713
|
-
message: `playwright chrome launched \u2192 ${
|
|
38960
|
+
message: `playwright chrome launched \u2192 ${targetUrl.href}${ownerNote}`,
|
|
38714
38961
|
pid: child.pid,
|
|
38715
38962
|
target: resolved.spec,
|
|
38716
|
-
attachUrl:
|
|
38963
|
+
attachUrl: targetUrl.href,
|
|
38717
38964
|
connectAckFile,
|
|
38718
38965
|
diagnosticLogPath: errLog
|
|
38719
38966
|
};
|
|
@@ -40004,7 +40251,7 @@ async function buildShellUrl(target, baseUrl = resolveDefaultShellBaseUrl(), opt
|
|
|
40004
40251
|
`http://localhost:${port.port}/__peach/expo-swift?root=${encodeURIComponent(expoRoot)}`
|
|
40005
40252
|
);
|
|
40006
40253
|
}
|
|
40007
|
-
if (!opts.device && !opts.proof && !opts.posture && !opts.orientation && !opts.osVersion && !opts.env?.length && !opts.dotEnv)
|
|
40254
|
+
if (!opts.device && !opts.proof && !opts.posture && !opts.orientation && !opts.osVersion && !opts.theme && !opts.env?.length && !opts.dotEnv)
|
|
40008
40255
|
return expoStamped.toString();
|
|
40009
40256
|
const url = expoStamped;
|
|
40010
40257
|
if (opts.dotEnv) url.searchParams.set("dotEnv", JSON.stringify(opts.dotEnv));
|
|
@@ -40012,6 +40259,7 @@ async function buildShellUrl(target, baseUrl = resolveDefaultShellBaseUrl(), opt
|
|
|
40012
40259
|
if (opts.posture) url.searchParams.set("posture", opts.posture);
|
|
40013
40260
|
if (opts.orientation) url.searchParams.set("orientation", opts.orientation);
|
|
40014
40261
|
if (opts.osVersion) url.searchParams.set("osVersion", opts.osVersion);
|
|
40262
|
+
if (opts.theme) url.searchParams.set("theme", opts.theme);
|
|
40015
40263
|
if (opts.proof) url.searchParams.set("proof", "1");
|
|
40016
40264
|
for (const entry of opts.env ?? []) url.searchParams.append("env", entry);
|
|
40017
40265
|
return url.toString();
|
|
@@ -40158,6 +40406,16 @@ function signalDriverLaunchConnected(result) {
|
|
|
40158
40406
|
return false;
|
|
40159
40407
|
}
|
|
40160
40408
|
}
|
|
40409
|
+
function readUnservedUrl(result) {
|
|
40410
|
+
if (!result.diagnosticLogPath) return null;
|
|
40411
|
+
try {
|
|
40412
|
+
const detail = import_node_fs33.default.readFileSync(result.diagnosticLogPath, "utf8");
|
|
40413
|
+
const match = detail.match(/\[unserved\] nothing serves (\S+)/);
|
|
40414
|
+
return match ? match[1] : null;
|
|
40415
|
+
} catch {
|
|
40416
|
+
return null;
|
|
40417
|
+
}
|
|
40418
|
+
}
|
|
40161
40419
|
function printDriverDiagnosticLogTail(result) {
|
|
40162
40420
|
if (!result.diagnosticLogPath) return;
|
|
40163
40421
|
try {
|
|
@@ -40429,7 +40687,9 @@ async function runOpenCommand(args, opts = {}) {
|
|
|
40429
40687
|
"--orientation",
|
|
40430
40688
|
"--os-version",
|
|
40431
40689
|
"--viewport",
|
|
40432
|
-
"--env"
|
|
40690
|
+
"--env",
|
|
40691
|
+
"--theme",
|
|
40692
|
+
"-t"
|
|
40433
40693
|
]
|
|
40434
40694
|
});
|
|
40435
40695
|
const requestedProfileId = args.find((_, i) => args[i - 1] === "--profile");
|
|
@@ -40464,6 +40724,18 @@ async function runOpenCommand(args, opts = {}) {
|
|
|
40464
40724
|
);
|
|
40465
40725
|
rnxExit(1);
|
|
40466
40726
|
}
|
|
40727
|
+
const themeFlagIndex = args.findIndex((arg) => arg === "--theme" || arg === "-t");
|
|
40728
|
+
const themeArg = themeFlagIndex === -1 ? void 0 : args[themeFlagIndex + 1];
|
|
40729
|
+
if (themeFlagIndex !== -1 && themeArg === void 0) {
|
|
40730
|
+
console.error(" peach open: --theme expects light, dark, or auto");
|
|
40731
|
+
rnxExit(1);
|
|
40732
|
+
}
|
|
40733
|
+
if (themeArg !== void 0 && themeArg !== "light" && themeArg !== "dark" && themeArg !== "auto") {
|
|
40734
|
+
console.error(
|
|
40735
|
+
` peach open: --theme must be light, dark, or auto, got "${themeArg}"`
|
|
40736
|
+
);
|
|
40737
|
+
rnxExit(1);
|
|
40738
|
+
}
|
|
40467
40739
|
if (isAppDeepLinkTarget(target)) {
|
|
40468
40740
|
if (openInNewSim) {
|
|
40469
40741
|
console.error(
|
|
@@ -40633,6 +40905,7 @@ async function runOpenCommand(args, opts = {}) {
|
|
|
40633
40905
|
posture: postureArg,
|
|
40634
40906
|
orientation: orientationArg,
|
|
40635
40907
|
osVersion: osVersionArg,
|
|
40908
|
+
theme: themeArg,
|
|
40636
40909
|
resolvedBundle,
|
|
40637
40910
|
project,
|
|
40638
40911
|
proof: args.includes("--proof"),
|
|
@@ -40835,7 +41108,14 @@ async function runOpenCommand(args, opts = {}) {
|
|
|
40835
41108
|
);
|
|
40836
41109
|
if (outcome.kind === "host-exit") {
|
|
40837
41110
|
printDriverDiagnosticLogTail(result);
|
|
40838
|
-
|
|
41111
|
+
const unserved = readUnservedUrl(result);
|
|
41112
|
+
if (unserved) {
|
|
41113
|
+
console.error(
|
|
41114
|
+
` nothing serves ${unserved} \u2014 start the shell or daemon that owns it, then try again`
|
|
41115
|
+
);
|
|
41116
|
+
} else {
|
|
41117
|
+
console.error(` ${driver.name} host crashed \u2014 sim is no longer attached`);
|
|
41118
|
+
}
|
|
40839
41119
|
rnxExit(1);
|
|
40840
41120
|
}
|
|
40841
41121
|
if (outcome.kind === "timeout") {
|