rnxsim 0.0.0 → 0.1.312
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/LICENSE +21 -0
- package/README.md +512 -0
- package/detox/colors.ts +54 -0
- package/detox/config-loader.ts +135 -0
- package/detox/element-types.ts +39 -0
- package/detox/expectations.ts +537 -0
- package/detox/gestures.ts +480 -0
- package/detox/index.ts +2118 -0
- package/detox/jest-preset.cjs +51 -0
- package/detox/jest-setup-after-env.cjs +18 -0
- package/detox/matchers.ts +30 -0
- package/detox/motion-change.cjs +109 -0
- package/detox/motion-change.d.cts +35 -0
- package/detox/navigation.ts +43 -0
- package/detox/screenshots/animated-color-test-rest-norngh.png +0 -0
- package/detox/screenshots/color-test-after-drag-norngh.png +0 -0
- package/detox/screenshots/color-test-rest-norngh.png +0 -0
- package/detox/screenshots/theme-blue-toggle.png +0 -0
- package/detox/screenshots/theme-blue.png +0 -0
- package/detox/screenshots/theme-red-toggle.png +0 -0
- package/detox/screenshots/theme-red.png +0 -0
- package/dist-cli/bin.js +15 -0
- package/dist-cli/chunks/agent-NXVDDCFG.js +48 -0
- package/dist-cli/chunks/agent-wrapper-DXJCFKL3.js +17 -0
- package/dist-cli/chunks/app-fonts-W5AJZQJF.js +4 -0
- package/dist-cli/chunks/assert-3LOJEUDT.js +49 -0
- package/dist-cli/chunks/auth-MFTYYPNX.js +12 -0
- package/dist-cli/chunks/beta-GT3NN67B.js +4 -0
- package/dist-cli/chunks/camera-6EAK7CUL.js +22 -0
- package/dist-cli/chunks/chunk-274UD5FD.js +4 -0
- package/dist-cli/chunks/chunk-2SA2VTGP.js +5 -0
- package/dist-cli/chunks/chunk-33FKQH54.js +5 -0
- package/dist-cli/chunks/chunk-37I5AIS7.js +3 -0
- package/dist-cli/chunks/chunk-3D57IBPC.js +4 -0
- package/dist-cli/chunks/chunk-4BXCZHAU.js +4 -0
- package/dist-cli/chunks/chunk-5OX7ANRA.js +5 -0
- package/dist-cli/chunks/chunk-66NF2KNG.js +9 -0
- package/dist-cli/chunks/chunk-6UKJB2VC.js +125 -0
- package/dist-cli/chunks/chunk-7INBNA3U.js +26 -0
- package/dist-cli/chunks/chunk-7VWOSTD5.js +5 -0
- package/dist-cli/chunks/chunk-AY47WKS5.js +23 -0
- package/dist-cli/chunks/chunk-B7KMNHX7.js +4 -0
- package/dist-cli/chunks/chunk-BKNOLP3J.js +4 -0
- package/dist-cli/chunks/chunk-BRIZOR4K.js +28 -0
- package/dist-cli/chunks/chunk-DM6KUAOZ.js +4 -0
- package/dist-cli/chunks/chunk-EUAVBTKU.js +4 -0
- package/dist-cli/chunks/chunk-FTC4M26Q.js +4 -0
- package/dist-cli/chunks/chunk-FWYYCUAZ.js +4 -0
- package/dist-cli/chunks/chunk-G74YIEVS.js +7 -0
- package/dist-cli/chunks/chunk-GZDHEONW.js +507 -0
- package/dist-cli/chunks/chunk-HG7ORJMT.js +5 -0
- package/dist-cli/chunks/chunk-HMDOLCKG.js +15 -0
- package/dist-cli/chunks/chunk-JG6S4RSH.js +4 -0
- package/dist-cli/chunks/chunk-KR5BGMBZ.js +4 -0
- package/dist-cli/chunks/chunk-KZW5WBGU.js +983 -0
- package/dist-cli/chunks/chunk-L24Z3CRS.js +30 -0
- package/dist-cli/chunks/chunk-LDQ7HVCW.js +4 -0
- package/dist-cli/chunks/chunk-MENV7VLD.js +4 -0
- package/dist-cli/chunks/chunk-MNGQ42QE.js +568 -0
- package/dist-cli/chunks/chunk-N6A3SXMR.js +4 -0
- package/dist-cli/chunks/chunk-NLEMQ4PY.js +6 -0
- package/dist-cli/chunks/chunk-NPVGMH2N.js +101 -0
- package/dist-cli/chunks/chunk-OR3XTXEB.js +107 -0
- package/dist-cli/chunks/chunk-PEPUGJVI.js +4 -0
- package/dist-cli/chunks/chunk-Q3RGLERJ.js +142 -0
- package/dist-cli/chunks/chunk-SI3BUTQR.js +4 -0
- package/dist-cli/chunks/chunk-T4FT6CM7.js +4 -0
- package/dist-cli/chunks/chunk-TBMVBI26.js +7 -0
- package/dist-cli/chunks/chunk-TCWQJILS.js +5 -0
- package/dist-cli/chunks/chunk-TGQNQ6XT.js +766 -0
- package/dist-cli/chunks/chunk-TYE3WBSR.js +5 -0
- package/dist-cli/chunks/chunk-U4PN6JOT.js +6 -0
- package/dist-cli/chunks/chunk-VUFRB347.js +4 -0
- package/dist-cli/chunks/chunk-VZBLFMYC.js +10 -0
- package/dist-cli/chunks/chunk-WBT32R6N.js +25 -0
- package/dist-cli/chunks/chunk-XRGEEPJ5.js +38 -0
- package/dist-cli/chunks/chunk-Y2FSZSO7.js +71 -0
- package/dist-cli/chunks/chunk-YRV7HR3P.js +74 -0
- package/dist-cli/chunks/chunk-YZRFF4YA.js +14 -0
- package/dist-cli/chunks/chunk-ZMZTHU7V.js +4 -0
- package/dist-cli/chunks/cleanup-H3GWQB63.js +25 -0
- package/dist-cli/chunks/cli-version-3QPAJ3LC.js +4 -0
- package/dist-cli/chunks/compat-5WG2XJV7.js +20 -0
- package/dist-cli/chunks/config-ANMBVVLL.js +13 -0
- package/dist-cli/chunks/control-NSGNQFJG.js +4 -0
- package/dist-cli/chunks/daemon-JHF4BJ3U.js +4 -0
- package/dist-cli/chunks/debug-CHV2O2KF.js +200 -0
- package/dist-cli/chunks/desktop-FIPIK4CH.js +31 -0
- package/dist-cli/chunks/detox-CVUJP7K6.js +52 -0
- package/dist-cli/chunks/device-6WCUM4W6.js +18 -0
- package/dist-cli/chunks/diagnose-I6EMWEII.js +43 -0
- package/dist-cli/chunks/disk-cleanup-P27CYFTN.js +4 -0
- package/dist-cli/chunks/drivers-HQ6AKZT6.js +4 -0
- package/dist-cli/chunks/film-UOQFFYNF.js +74 -0
- package/dist-cli/chunks/flow-N27MRRNL.js +4 -0
- package/dist-cli/chunks/help-SF6FEGEE.js +4 -0
- package/dist-cli/chunks/hidden-runtime-alias-NJYFSJKZ.js +4 -0
- package/dist-cli/chunks/home-paths-XOV44JEF.js +4 -0
- package/dist-cli/chunks/inspect-CWFRFQTY.js +4 -0
- package/dist-cli/chunks/install-desktop-KLQDNXZQ.js +4 -0
- package/dist-cli/chunks/login-BPFQENCX.js +28 -0
- package/dist-cli/chunks/logout-5A45ZGY7.js +4 -0
- package/dist-cli/chunks/maestro-E4CSDMLM.js +104 -0
- package/dist-cli/chunks/maestro-generate-CKMOJQX2.js +36 -0
- package/dist-cli/chunks/mode-SZYNMIQF.js +26 -0
- package/dist-cli/chunks/optional-demo-registry-FRH4SFVG.js +4 -0
- package/dist-cli/chunks/perf-VXU2XJAX.js +48 -0
- package/dist-cli/chunks/permissions-IRIAOVND.js +13 -0
- package/dist-cli/chunks/record-RY7FPLLH.js +72 -0
- package/dist-cli/chunks/report-issue-KNWXOE53.js +29 -0
- package/dist-cli/chunks/runtime-AR3GJTGK.js +4 -0
- package/dist-cli/chunks/screenshot-command-QLALR6GY.js +159 -0
- package/dist-cli/chunks/screenshot-layers-OQFMFVRL.js +20 -0
- package/dist-cli/chunks/screenshots-capture-6TSRJFGB.js +42 -0
- package/dist-cli/chunks/serve-F54J2NQO.js +44 -0
- package/dist-cli/chunks/setup-7V6UKX4U.js +32 -0
- package/dist-cli/chunks/skills-QQBOSETH.js +50 -0
- package/dist-cli/chunks/storage-TAPMKK5O.js +37 -0
- package/dist-cli/chunks/store-7NX3S43H.js +4 -0
- package/dist-cli/chunks/telemetry-E7BUK6RA.js +4 -0
- package/dist-cli/chunks/timeline-IAM564NA.js +24 -0
- package/dist-cli/chunks/upgrade-CD55QXIX.js +7 -0
- package/dist-cli/chunks/upload-GZ6LIMYM.js +4 -0
- package/dist-cli/chunks/version-3DYJ5AS3.js +6 -0
- package/dist-cli/chunks/web-6NW6YLPI.js +4 -0
- package/dist-cli/chunks/what-happened-CZZDOOVG.js +25 -0
- package/dist-lib/agent-daemon-client.cjs +468 -0
- package/dist-lib/agent-events.cjs +48 -0
- package/dist-lib/agent-identity.cjs +53 -0
- package/dist-lib/agent-sessions.cjs +725 -0
- package/dist-lib/attached-projects.cjs +526 -0
- package/dist-lib/auth/shared-session.cjs +195 -0
- package/dist-lib/backend-origin.cjs +70 -0
- package/dist-lib/beta.cjs +41 -0
- package/dist-lib/beta.mjs +13 -0
- package/dist-lib/bridge-constants.cjs +161 -0
- package/dist-lib/cli-constants.cjs +32 -0
- package/dist-lib/config.cjs +96 -0
- package/dist-lib/detox/index.cjs +2863 -0
- package/dist-lib/detox/jest-preset.cjs +51 -0
- package/dist-lib/dev-bundle-resolution.cjs +223 -0
- package/dist-lib/home-paths.cjs +421 -0
- package/dist-lib/host/bridge-host.cjs +5600 -0
- package/dist-lib/host/fetch-proxy-handler.cjs +373 -0
- package/dist-lib/host/fetch-proxy-overrides.cjs +63 -0
- package/dist-lib/host/fetch-proxy-overrides.mjs +37 -0
- package/dist-lib/host/websocket-proxy.cjs +214 -0
- package/dist-lib/index.cjs +513 -0
- package/dist-lib/jump-to-source-babel.cjs +93 -0
- package/dist-lib/menu.cjs +620 -0
- package/dist-lib/menu.mjs +581 -0
- package/dist-lib/metro.cjs +297 -0
- package/dist-lib/profiles.cjs +246 -0
- package/dist-lib/public-brand.cjs +39 -0
- package/dist-lib/render-mode.cjs +54 -0
- package/dist-lib/scripts/dev-server-scanner.cjs +1034 -0
- package/dist-lib/sdk.cjs +2333 -0
- package/dist-lib/sdk.mjs +2240 -0
- package/dist-lib/skills.cjs +23911 -0
- package/dist-lib/vite.cjs +358 -0
- package/package.json +189 -18
- package/scripts/dev-server-scanner.ts +941 -0
- package/scripts/optional-demo-registry.ts +113 -0
- package/scripts/postinstall.cjs +3 -0
- package/scripts/preuninstall.cjs +118 -0
- package/skills/contrast/SKILL.md +171 -0
- package/skills/rnx-debug/SKILL.md +425 -0
- package/skills/rnx-perf/SKILL.md +295 -0
- package/skills/rnx-setup/SKILL.md +160 -0
- package/skills/rnx-test/SKILL.md +292 -0
- package/skills/rnx-visual/SKILL.md +122 -0
- package/src/agent-daemon-client.ts +410 -0
- package/src/agent-events.ts +71 -0
- package/src/agent-identity.ts +23 -0
- package/src/agent-prompt.ts +71 -0
- package/src/agent-sessions.ts +573 -0
- package/src/attached-projects.ts +539 -0
- package/src/auth/shared-session.ts +204 -0
- package/src/backend-origin.ts +49 -0
- package/src/beta.ts +19 -0
- package/src/bridge-constants.ts +171 -0
- package/src/browser-cache.ts +16 -0
- package/src/cli-constants.ts +1 -0
- package/src/cli-version.ts +32 -0
- package/src/codex-client.ts +215 -0
- package/src/config.ts +134 -0
- package/src/dev-bundle-resolution.ts +236 -0
- package/src/disk-cleanup.ts +466 -0
- package/src/home-paths.ts +552 -0
- package/src/host/agent-host.ts +666 -0
- package/src/host/bridge-host.ts +2626 -0
- package/src/host/fetch-proxy-handler.ts +397 -0
- package/src/host/fetch-proxy-overrides.ts +51 -0
- package/src/host/open-url.ts +89 -0
- package/src/host/websocket-proxy.ts +210 -0
- package/src/index.ts +12 -705
- package/src/jump-to-source-babel.ts +135 -0
- package/src/menu.ts +734 -0
- package/src/metro-plugin.ts +139 -0
- package/src/native-dev-bundle-url.ts +96 -0
- package/src/native-seam-manifest.ts +341 -0
- package/src/plist.ts +27 -0
- package/src/poll-until.ts +92 -0
- package/src/profiles.ts +179 -0
- package/src/public-brand.ts +9 -0
- package/src/render-mode.ts +27 -0
- package/src/runtime-assets.ts +228 -0
- package/src/runtime-delivery.ts +54 -0
- package/src/screenshots/compose.ts +422 -0
- package/src/screenshots/frame-compose.ts +454 -0
- package/src/screenshots/orchestrate.ts +256 -0
- package/src/screenshots/org-deck.ts +91 -0
- package/src/screenshots/registry.ts +58 -0
- package/src/screenshots/schema.ts +364 -0
- package/src/sdk.ts +7 -0
- package/src/settings-bundle.ts +418 -0
- package/src/skills/builtin/a11y-review.ts +132 -0
- package/src/skills/builtin/compat-check.ts +71 -0
- package/src/skills/builtin/maestro-test.ts +121 -0
- package/src/skills/builtin/perf-profile.ts +90 -0
- package/src/skills/builtin/screenshot-all.ts +52 -0
- package/src/skills/builtin/visual-diff.ts +100 -0
- package/src/skills/registry.ts +107 -0
- package/src/skills/types.ts +41 -0
- package/src/team-machine-prompt.ts +73 -0
- package/src/vite-plugin-one.ts +190 -0
- package/src/vite-plugin.ts +1750 -0
- package/src/worklets-babel.ts +134 -0
|
@@ -0,0 +1,1034 @@
|
|
|
1
|
+
/*! rnx v0.1.312 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
|
+
"use strict";
|
|
4
|
+
var __create = Object.create;
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __export = (target, all) => {
|
|
11
|
+
for (var name in all)
|
|
12
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
13
|
+
};
|
|
14
|
+
var __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from))
|
|
17
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
18
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
28
|
+
mod
|
|
29
|
+
));
|
|
30
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
31
|
+
|
|
32
|
+
// scripts/dev-server-scanner.ts
|
|
33
|
+
var dev_server_scanner_exports = {};
|
|
34
|
+
__export(dev_server_scanner_exports, {
|
|
35
|
+
__applyManifestForTests: () => __applyManifestForTests,
|
|
36
|
+
__attachAppSettingsBundleForTests: () => __attachAppSettingsBundleForTests,
|
|
37
|
+
__isSootSimSelfServerForTests: () => __isSootSimSelfServerForTests,
|
|
38
|
+
__resetScannerCache: () => __resetScannerCache,
|
|
39
|
+
__shouldReuseScannerCacheEntry: () => __shouldReuseScannerCacheEntry,
|
|
40
|
+
discoverListeningPorts: () => discoverListeningPorts,
|
|
41
|
+
discoverListeningProcesses: () => discoverListeningProcesses,
|
|
42
|
+
pidFromNetstat: () => pidFromNetstat,
|
|
43
|
+
probePort: () => probePort,
|
|
44
|
+
resolveListeningPid: () => resolveListeningPid,
|
|
45
|
+
resolveProcessCwd: () => resolveProcessCwd,
|
|
46
|
+
scanDevServers: () => scanDevServers
|
|
47
|
+
});
|
|
48
|
+
module.exports = __toCommonJS(dev_server_scanner_exports);
|
|
49
|
+
var import_child_process = require("child_process");
|
|
50
|
+
var import_promises2 = require("fs/promises");
|
|
51
|
+
var import_http = __toESM(require("http"), 1);
|
|
52
|
+
var import_net = __toESM(require("net"), 1);
|
|
53
|
+
var import_node_path3 = require("node:path");
|
|
54
|
+
var import_util = require("util");
|
|
55
|
+
|
|
56
|
+
// src/config.ts
|
|
57
|
+
var SOOTSIM_CONFIG_QUERY_PARAM = "sootsimConfig";
|
|
58
|
+
function hasOwnKeys(value) {
|
|
59
|
+
return !!value && Object.keys(value).length > 0;
|
|
60
|
+
}
|
|
61
|
+
function hasSootSimConfig(config) {
|
|
62
|
+
if (!config) return false;
|
|
63
|
+
return typeof config.runtimeVersion === "string" && config.runtimeVersion.length > 0 || hasOwnKeys(config.modules) || hasOwnKeys(config.turboModules) || hasOwnKeys(config.nativeModules) || hasOwnKeys(config.env) || hasOwnKeys(config.network?.remap) || hasOwnKeys(config.settings) || hasOwnKeys(config.initialState);
|
|
64
|
+
}
|
|
65
|
+
function applySootSimConfigToUrl(url, config) {
|
|
66
|
+
const parsed = new URL(url);
|
|
67
|
+
if (hasSootSimConfig(config)) {
|
|
68
|
+
parsed.searchParams.set(SOOTSIM_CONFIG_QUERY_PARAM, JSON.stringify(config));
|
|
69
|
+
} else {
|
|
70
|
+
parsed.searchParams.delete(SOOTSIM_CONFIG_QUERY_PARAM);
|
|
71
|
+
}
|
|
72
|
+
return parsed.toString();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// src/native-dev-bundle-url.ts
|
|
76
|
+
function isAbsoluteHttpUrl(url) {
|
|
77
|
+
return /^https?:\/\//i.test(url);
|
|
78
|
+
}
|
|
79
|
+
function isNativeDevBundlePath(pathname) {
|
|
80
|
+
return pathname.endsWith(".bundle");
|
|
81
|
+
}
|
|
82
|
+
function applyPreviewProdBundle(parsed) {
|
|
83
|
+
if (!process.env.SOOTSIM_PREVIEW_PROD_BUNDLE) return;
|
|
84
|
+
parsed.searchParams.set("dev", "false");
|
|
85
|
+
parsed.searchParams.set("minify", "true");
|
|
86
|
+
if (parsed.searchParams.has("hot")) parsed.searchParams.set("hot", "false");
|
|
87
|
+
}
|
|
88
|
+
function normalizeNativeDevBundleUrl(bundleUrl) {
|
|
89
|
+
try {
|
|
90
|
+
const isAbsolute = isAbsoluteHttpUrl(bundleUrl);
|
|
91
|
+
const parsed = new URL(bundleUrl, "http://sootsim.local");
|
|
92
|
+
parsed.pathname = parsed.pathname.replace(/\.\.bundle$/, ".bundle");
|
|
93
|
+
if (!isNativeDevBundlePath(parsed.pathname)) return bundleUrl;
|
|
94
|
+
parsed.searchParams.delete("transform.bytecode");
|
|
95
|
+
if (parsed.searchParams.get("lazy") === "true") {
|
|
96
|
+
parsed.searchParams.set("lazy", "false");
|
|
97
|
+
}
|
|
98
|
+
applyPreviewProdBundle(parsed);
|
|
99
|
+
if (isAbsolute) return parsed.toString();
|
|
100
|
+
return `${parsed.pathname}${parsed.search}${parsed.hash}`;
|
|
101
|
+
} catch {
|
|
102
|
+
return bundleUrl;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// src/settings-bundle.ts
|
|
107
|
+
var import_promises = require("node:fs/promises");
|
|
108
|
+
var import_node_path = require("node:path");
|
|
109
|
+
|
|
110
|
+
// src/plist.ts
|
|
111
|
+
var import_plist = __toESM(require("@expo/plist"), 1);
|
|
112
|
+
function isRecord(value) {
|
|
113
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
114
|
+
}
|
|
115
|
+
function resolvePlistParser(value) {
|
|
116
|
+
if (!isRecord(value)) return null;
|
|
117
|
+
const direct = value.parse;
|
|
118
|
+
if (typeof direct === "function") {
|
|
119
|
+
return (source) => Reflect.apply(direct, value, [source]);
|
|
120
|
+
}
|
|
121
|
+
const nested = value.default;
|
|
122
|
+
if (!isRecord(nested)) return null;
|
|
123
|
+
const nestedParse = nested.parse;
|
|
124
|
+
return typeof nestedParse === "function" ? (source) => Reflect.apply(nestedParse, nested, [source]) : null;
|
|
125
|
+
}
|
|
126
|
+
var parsePlist = resolvePlistParser(import_plist.default);
|
|
127
|
+
function parsePlistSource(source) {
|
|
128
|
+
return parsePlist?.(source) ?? null;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// src/settings-bundle.ts
|
|
132
|
+
var MAX_PLIST_BYTES = 1048576;
|
|
133
|
+
var MAX_CHILD_DEPTH = 8;
|
|
134
|
+
var MAX_PLIST_FILES = 32;
|
|
135
|
+
var MAX_SPECIFIERS = 512;
|
|
136
|
+
var settingsBundleCache = /* @__PURE__ */ new Map();
|
|
137
|
+
function isRecord2(value) {
|
|
138
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
139
|
+
}
|
|
140
|
+
function optionalString(value) {
|
|
141
|
+
return typeof value === "string" ? value : void 0;
|
|
142
|
+
}
|
|
143
|
+
function requiredString(value) {
|
|
144
|
+
if (typeof value !== "string") return null;
|
|
145
|
+
const normalized = value.trim();
|
|
146
|
+
return normalized ? normalized : null;
|
|
147
|
+
}
|
|
148
|
+
function finiteNumber(value) {
|
|
149
|
+
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
150
|
+
}
|
|
151
|
+
function preferenceValue(value) {
|
|
152
|
+
if (typeof value === "string" || typeof value === "boolean") return value;
|
|
153
|
+
return finiteNumber(value);
|
|
154
|
+
}
|
|
155
|
+
function keyboardType(value) {
|
|
156
|
+
if (typeof value !== "string") return void 0;
|
|
157
|
+
switch (value.replaceAll(/[-_\s]/g, "").toLowerCase()) {
|
|
158
|
+
case "alphabet":
|
|
159
|
+
return "alphabet";
|
|
160
|
+
case "numbersandpunctuation":
|
|
161
|
+
return "numbers-and-punctuation";
|
|
162
|
+
case "numberpad":
|
|
163
|
+
return "number-pad";
|
|
164
|
+
case "url":
|
|
165
|
+
return "url";
|
|
166
|
+
case "emailaddress":
|
|
167
|
+
return "email-address";
|
|
168
|
+
case "namephonepad":
|
|
169
|
+
return "name-phone-pad";
|
|
170
|
+
case "asciicapable":
|
|
171
|
+
return "ascii-capable";
|
|
172
|
+
default:
|
|
173
|
+
return void 0;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
function autocapitalization(value) {
|
|
177
|
+
if (typeof value !== "string") return void 0;
|
|
178
|
+
switch (value.replaceAll(/[-_\s]/g, "").toLowerCase()) {
|
|
179
|
+
case "none":
|
|
180
|
+
return "none";
|
|
181
|
+
case "sentences":
|
|
182
|
+
return "sentences";
|
|
183
|
+
case "words":
|
|
184
|
+
return "words";
|
|
185
|
+
case "allcharacters":
|
|
186
|
+
return "all-characters";
|
|
187
|
+
default:
|
|
188
|
+
return void 0;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
function autocorrection(value) {
|
|
192
|
+
if (typeof value === "boolean") return value;
|
|
193
|
+
if (typeof value !== "string") return void 0;
|
|
194
|
+
switch (value.trim().toLowerCase()) {
|
|
195
|
+
case "yes":
|
|
196
|
+
return true;
|
|
197
|
+
case "no":
|
|
198
|
+
return false;
|
|
199
|
+
default:
|
|
200
|
+
return void 0;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
function safeChildPlistName(value) {
|
|
204
|
+
const file = requiredString(value);
|
|
205
|
+
if (!file || file.includes("/") || file.includes("\\") || file.includes("..")) {
|
|
206
|
+
return null;
|
|
207
|
+
}
|
|
208
|
+
return {
|
|
209
|
+
file,
|
|
210
|
+
name: file.toLowerCase().endsWith(".plist") ? file : `${file}.plist`
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
async function readableSettingsBundle(path) {
|
|
214
|
+
try {
|
|
215
|
+
const root = await (0, import_promises.stat)((0, import_node_path.join)(path, "Root.plist"));
|
|
216
|
+
return root.isFile() && root.size <= MAX_PLIST_BYTES;
|
|
217
|
+
} catch {
|
|
218
|
+
return false;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
async function findSettingsBundle(projectRoot) {
|
|
222
|
+
const directCandidates = [
|
|
223
|
+
(0, import_node_path.join)(projectRoot, "Settings.bundle"),
|
|
224
|
+
(0, import_node_path.join)(projectRoot, "ios", "Settings.bundle")
|
|
225
|
+
];
|
|
226
|
+
for (const candidate of directCandidates) {
|
|
227
|
+
if (await readableSettingsBundle(candidate)) return candidate;
|
|
228
|
+
}
|
|
229
|
+
try {
|
|
230
|
+
const iosRoot = (0, import_node_path.join)(projectRoot, "ios");
|
|
231
|
+
const children = await (0, import_promises.readdir)(iosRoot, { withFileTypes: true });
|
|
232
|
+
const candidates = children.filter(
|
|
233
|
+
(entry) => entry.isDirectory() && entry.name !== "Pods" && entry.name !== "build" && !entry.name.startsWith(".")
|
|
234
|
+
).map((entry) => (0, import_node_path.join)(iosRoot, entry.name, "Settings.bundle")).sort();
|
|
235
|
+
for (const candidate of candidates) {
|
|
236
|
+
if (await readableSettingsBundle(candidate)) return candidate;
|
|
237
|
+
}
|
|
238
|
+
} catch {
|
|
239
|
+
}
|
|
240
|
+
return null;
|
|
241
|
+
}
|
|
242
|
+
async function settingsBundleFingerprint(bundlePath) {
|
|
243
|
+
try {
|
|
244
|
+
const entries = await (0, import_promises.readdir)(bundlePath, { withFileTypes: true });
|
|
245
|
+
const names = entries.filter((entry) => entry.isFile() && entry.name.toLowerCase().endsWith(".plist")).map((entry) => entry.name).sort().slice(0, MAX_PLIST_FILES + 1);
|
|
246
|
+
if (names.length === 0 || names.length > MAX_PLIST_FILES) return null;
|
|
247
|
+
const parts = await Promise.all(
|
|
248
|
+
names.map(async (name) => {
|
|
249
|
+
const metadata = await (0, import_promises.stat)((0, import_node_path.join)(bundlePath, name));
|
|
250
|
+
if (!metadata.isFile() || metadata.size > MAX_PLIST_BYTES) return null;
|
|
251
|
+
return `${name}:${metadata.size}:${metadata.mtimeMs}:${metadata.ctimeMs}`;
|
|
252
|
+
})
|
|
253
|
+
);
|
|
254
|
+
if (parts.some((part) => part === null)) return null;
|
|
255
|
+
return parts.join("|");
|
|
256
|
+
} catch {
|
|
257
|
+
return null;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
async function parsePlistRecord(path) {
|
|
261
|
+
try {
|
|
262
|
+
const metadata = await (0, import_promises.stat)(path);
|
|
263
|
+
if (!metadata.isFile() || metadata.size > MAX_PLIST_BYTES) return null;
|
|
264
|
+
const source = await (0, import_promises.readFile)(path, "utf8");
|
|
265
|
+
const parsed = parsePlistSource(source);
|
|
266
|
+
return isRecord2(parsed) ? parsed : null;
|
|
267
|
+
} catch {
|
|
268
|
+
return null;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
function normalizeMultiValue(raw, key, title) {
|
|
272
|
+
if (!Array.isArray(raw.Values) || !Array.isArray(raw.Titles)) return null;
|
|
273
|
+
const values = [];
|
|
274
|
+
const titles = [];
|
|
275
|
+
let optionType;
|
|
276
|
+
const pairCount = Math.min(raw.Values.length, raw.Titles.length);
|
|
277
|
+
for (let index = 0; index < pairCount; index++) {
|
|
278
|
+
const value = preferenceValue(raw.Values[index]);
|
|
279
|
+
const optionTitle = optionalString(raw.Titles[index]);
|
|
280
|
+
if (value === null || optionTitle === void 0) continue;
|
|
281
|
+
const valueType = typeof value === "string" ? "string" : typeof value === "number" ? "number" : "boolean";
|
|
282
|
+
if (optionType !== void 0 && valueType !== optionType) continue;
|
|
283
|
+
optionType = valueType;
|
|
284
|
+
values.push(value);
|
|
285
|
+
titles.push(optionTitle);
|
|
286
|
+
}
|
|
287
|
+
const firstValue = values[0];
|
|
288
|
+
if (firstValue === void 0) return null;
|
|
289
|
+
const declaredDefault = preferenceValue(raw.DefaultValue);
|
|
290
|
+
const defaultValue = declaredDefault !== null && values.includes(declaredDefault) ? declaredDefault : firstValue;
|
|
291
|
+
return {
|
|
292
|
+
type: "multi-value",
|
|
293
|
+
key,
|
|
294
|
+
title,
|
|
295
|
+
defaultValue,
|
|
296
|
+
currentValue: defaultValue,
|
|
297
|
+
values,
|
|
298
|
+
titles
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
async function normalizeSpecifier(raw, context) {
|
|
302
|
+
if (!isRecord2(raw)) return null;
|
|
303
|
+
if (context.budget.specifiers >= MAX_SPECIFIERS) return null;
|
|
304
|
+
const type = requiredString(raw.Type);
|
|
305
|
+
if (!type) return null;
|
|
306
|
+
context.budget.specifiers += 1;
|
|
307
|
+
if (type === "PSGroupSpecifier") {
|
|
308
|
+
const title2 = optionalString(raw.Title);
|
|
309
|
+
const footer = optionalString(raw.FooterText);
|
|
310
|
+
return {
|
|
311
|
+
type: "group",
|
|
312
|
+
...title2 !== void 0 ? { title: title2 } : null,
|
|
313
|
+
...footer !== void 0 ? { footer } : null
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
const key = requiredString(raw.Key);
|
|
317
|
+
if (type === "PSSliderSpecifier") {
|
|
318
|
+
if (!key) return null;
|
|
319
|
+
const minimumValue = finiteNumber(raw.MinimumValue);
|
|
320
|
+
const maximumValue = finiteNumber(raw.MaximumValue);
|
|
321
|
+
if (minimumValue === null || maximumValue === null || maximumValue <= minimumValue) {
|
|
322
|
+
return null;
|
|
323
|
+
}
|
|
324
|
+
const declaredDefault = finiteNumber(raw.DefaultValue);
|
|
325
|
+
const defaultValue = Math.min(
|
|
326
|
+
maximumValue,
|
|
327
|
+
Math.max(minimumValue, declaredDefault ?? minimumValue)
|
|
328
|
+
);
|
|
329
|
+
const title2 = optionalString(raw.Title);
|
|
330
|
+
const minimumValueImage = optionalString(raw.MinimumValueImage);
|
|
331
|
+
const maximumValueImage = optionalString(raw.MaximumValueImage);
|
|
332
|
+
return {
|
|
333
|
+
type: "slider",
|
|
334
|
+
key,
|
|
335
|
+
defaultValue,
|
|
336
|
+
currentValue: defaultValue,
|
|
337
|
+
minimumValue,
|
|
338
|
+
maximumValue,
|
|
339
|
+
...title2 !== void 0 ? { title: title2 } : null,
|
|
340
|
+
...minimumValueImage !== void 0 ? { minimumValueImage } : null,
|
|
341
|
+
...maximumValueImage !== void 0 ? { maximumValueImage } : null
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
if (type === "PSChildPaneSpecifier") {
|
|
345
|
+
const title2 = requiredString(raw.Title);
|
|
346
|
+
const child = safeChildPlistName(raw.File);
|
|
347
|
+
if (!title2 || !child || context.depth >= MAX_CHILD_DEPTH) return null;
|
|
348
|
+
const childSpecifiers = await parseSpecifierFile(child.name, {
|
|
349
|
+
...context,
|
|
350
|
+
depth: context.depth + 1
|
|
351
|
+
});
|
|
352
|
+
if (!childSpecifiers || childSpecifiers.length === 0) return null;
|
|
353
|
+
return {
|
|
354
|
+
type: "child-pane",
|
|
355
|
+
title: title2,
|
|
356
|
+
file: child.file,
|
|
357
|
+
specifiers: childSpecifiers
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
if (!key) return null;
|
|
361
|
+
const title = requiredString(raw.Title) ?? key;
|
|
362
|
+
if (type === "PSToggleSwitchSpecifier") {
|
|
363
|
+
const defaultValue = typeof raw.DefaultValue === "boolean" ? raw.DefaultValue : false;
|
|
364
|
+
return {
|
|
365
|
+
type: "toggle",
|
|
366
|
+
key,
|
|
367
|
+
title,
|
|
368
|
+
defaultValue,
|
|
369
|
+
currentValue: defaultValue
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
if (type === "PSTextFieldSpecifier") {
|
|
373
|
+
const defaultValue = optionalString(raw.DefaultValue) ?? "";
|
|
374
|
+
const placeholder = optionalString(raw.Placeholder);
|
|
375
|
+
const resolvedKeyboardType = keyboardType(raw.KeyboardType);
|
|
376
|
+
const resolvedAutocapitalization = autocapitalization(raw.AutocapitalizationType);
|
|
377
|
+
const resolvedAutocorrection = autocorrection(raw.AutocorrectionType);
|
|
378
|
+
return {
|
|
379
|
+
type: "text",
|
|
380
|
+
key,
|
|
381
|
+
title,
|
|
382
|
+
defaultValue,
|
|
383
|
+
currentValue: defaultValue,
|
|
384
|
+
...placeholder !== void 0 ? { placeholder } : null,
|
|
385
|
+
...typeof raw.IsSecure === "boolean" ? { secure: raw.IsSecure } : null,
|
|
386
|
+
...resolvedKeyboardType ? { keyboardType: resolvedKeyboardType } : null,
|
|
387
|
+
...resolvedAutocapitalization ? { autocapitalization: resolvedAutocapitalization } : null,
|
|
388
|
+
...resolvedAutocorrection !== void 0 ? { autocorrection: resolvedAutocorrection } : null
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
if (type === "PSMultiValueSpecifier" || type === "PSRadioGroupSpecifier") {
|
|
392
|
+
return normalizeMultiValue(raw, key, title);
|
|
393
|
+
}
|
|
394
|
+
if (type === "PSTitleValueSpecifier") {
|
|
395
|
+
const defaultValue = preferenceValue(raw.DefaultValue) ?? "";
|
|
396
|
+
return {
|
|
397
|
+
type: "title-value",
|
|
398
|
+
key,
|
|
399
|
+
title,
|
|
400
|
+
defaultValue,
|
|
401
|
+
currentValue: defaultValue
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
return null;
|
|
405
|
+
}
|
|
406
|
+
async function parseSpecifierFile(fileName, context) {
|
|
407
|
+
const cached2 = context.fileCache.get(fileName);
|
|
408
|
+
if (cached2 !== void 0) return cached2;
|
|
409
|
+
if (context.stack.has(fileName) || context.budget.files >= MAX_PLIST_FILES) {
|
|
410
|
+
return null;
|
|
411
|
+
}
|
|
412
|
+
context.budget.files += 1;
|
|
413
|
+
const root = await parsePlistRecord((0, import_node_path.join)(context.bundlePath, fileName));
|
|
414
|
+
if (!root || !Array.isArray(root.PreferenceSpecifiers)) {
|
|
415
|
+
context.fileCache.set(fileName, null);
|
|
416
|
+
return null;
|
|
417
|
+
}
|
|
418
|
+
const stack = new Set(context.stack);
|
|
419
|
+
stack.add(fileName);
|
|
420
|
+
const specifiers = [];
|
|
421
|
+
for (const raw of root.PreferenceSpecifiers) {
|
|
422
|
+
if (context.budget.specifiers >= MAX_SPECIFIERS) break;
|
|
423
|
+
const specifier = await normalizeSpecifier(raw, { ...context, stack });
|
|
424
|
+
if (specifier) specifiers.push(specifier);
|
|
425
|
+
}
|
|
426
|
+
context.fileCache.set(fileName, specifiers);
|
|
427
|
+
return specifiers;
|
|
428
|
+
}
|
|
429
|
+
async function readAppSettingsBundle(projectRoot) {
|
|
430
|
+
const bundlePath = await findSettingsBundle(projectRoot);
|
|
431
|
+
if (!bundlePath) return null;
|
|
432
|
+
const fingerprint = await settingsBundleFingerprint(bundlePath);
|
|
433
|
+
if (!fingerprint) return null;
|
|
434
|
+
const cached2 = settingsBundleCache.get(bundlePath);
|
|
435
|
+
if (cached2?.fingerprint === fingerprint) return cached2.specifiers;
|
|
436
|
+
const specifiers = await parseSpecifierFile("Root.plist", {
|
|
437
|
+
bundlePath,
|
|
438
|
+
depth: 0,
|
|
439
|
+
budget: { files: 0, specifiers: 0 },
|
|
440
|
+
stack: /* @__PURE__ */ new Set(),
|
|
441
|
+
fileCache: /* @__PURE__ */ new Map()
|
|
442
|
+
});
|
|
443
|
+
const normalized = specifiers && specifiers.length > 0 ? specifiers : null;
|
|
444
|
+
settingsBundleCache.set(bundlePath, { fingerprint, specifiers: normalized });
|
|
445
|
+
return normalized;
|
|
446
|
+
}
|
|
447
|
+
function __resetAppSettingsBundleCacheForTests() {
|
|
448
|
+
settingsBundleCache.clear();
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
// scripts/optional-demo-registry.ts
|
|
452
|
+
var import_node_fs = require("node:fs");
|
|
453
|
+
var import_node_path2 = require("node:path");
|
|
454
|
+
var import_node_url = require("node:url");
|
|
455
|
+
var REGISTRY_REPO_PATH = "packages/sootsim/scripts/demo-app-registry.ts";
|
|
456
|
+
var MAX_ANCESTOR_STEPS = 8;
|
|
457
|
+
function findInternalDemoRegistry(startDir) {
|
|
458
|
+
let dir = startDir;
|
|
459
|
+
for (let step = 0; step < MAX_ANCESTOR_STEPS; step++) {
|
|
460
|
+
if ((0, import_node_path2.basename)(dir) === "node_modules") return null;
|
|
461
|
+
const candidate = (0, import_node_path2.join)(dir, REGISTRY_REPO_PATH);
|
|
462
|
+
if ((0, import_node_fs.existsSync)(candidate)) return candidate;
|
|
463
|
+
const parent = (0, import_node_path2.dirname)(dir);
|
|
464
|
+
if (parent === dir) return null;
|
|
465
|
+
dir = parent;
|
|
466
|
+
}
|
|
467
|
+
return null;
|
|
468
|
+
}
|
|
469
|
+
var cached = null;
|
|
470
|
+
async function loadOptionalDemoApps() {
|
|
471
|
+
if (cached) return cached;
|
|
472
|
+
const registryPath = findInternalDemoRegistry((0, import_node_path2.dirname)((0, import_node_url.fileURLToPath)(__sootsim_import_meta_url)));
|
|
473
|
+
if (!registryPath) {
|
|
474
|
+
cached = [];
|
|
475
|
+
return cached;
|
|
476
|
+
}
|
|
477
|
+
try {
|
|
478
|
+
const mod = await import(
|
|
479
|
+
/* @vite-ignore */
|
|
480
|
+
(0, import_node_url.pathToFileURL)(registryPath).href
|
|
481
|
+
);
|
|
482
|
+
cached = Array.isArray(mod.APPS) ? mod.APPS : [];
|
|
483
|
+
} catch {
|
|
484
|
+
cached = [];
|
|
485
|
+
}
|
|
486
|
+
return cached;
|
|
487
|
+
}
|
|
488
|
+
function optionalDemoAppsSync() {
|
|
489
|
+
return cached ?? [];
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
// scripts/dev-server-scanner.ts
|
|
493
|
+
var execP = (0, import_util.promisify)(import_child_process.exec);
|
|
494
|
+
var TIMEOUT_MS = 250;
|
|
495
|
+
var MANIFEST_TIMEOUT_MS = 1500;
|
|
496
|
+
var TCP_GATE_MS = 120;
|
|
497
|
+
function tcpPing(port, timeout = TCP_GATE_MS) {
|
|
498
|
+
return new Promise((resolve2) => {
|
|
499
|
+
const sock = new import_net.default.Socket();
|
|
500
|
+
let settled = false;
|
|
501
|
+
const done = (ok) => {
|
|
502
|
+
if (settled) return;
|
|
503
|
+
settled = true;
|
|
504
|
+
sock.destroy();
|
|
505
|
+
resolve2(ok);
|
|
506
|
+
};
|
|
507
|
+
sock.setTimeout(timeout);
|
|
508
|
+
sock.once("connect", () => done(true));
|
|
509
|
+
sock.once("timeout", () => done(false));
|
|
510
|
+
sock.once("error", () => done(false));
|
|
511
|
+
sock.connect(port, "localhost");
|
|
512
|
+
});
|
|
513
|
+
}
|
|
514
|
+
function httpGet(port, path, method = "GET", timeout = TIMEOUT_MS, headers = {}) {
|
|
515
|
+
return new Promise((resolve2) => {
|
|
516
|
+
const req = import_http.default.request(
|
|
517
|
+
{ hostname: "localhost", port, path, method, timeout, headers },
|
|
518
|
+
(res) => {
|
|
519
|
+
let body = "";
|
|
520
|
+
res.on("data", (c) => body += c.toString());
|
|
521
|
+
const contentType = (() => {
|
|
522
|
+
const raw = res.headers["content-type"];
|
|
523
|
+
if (typeof raw === "string") return raw;
|
|
524
|
+
if (Array.isArray(raw)) return raw[0];
|
|
525
|
+
return void 0;
|
|
526
|
+
})();
|
|
527
|
+
res.on(
|
|
528
|
+
"end",
|
|
529
|
+
() => resolve2({ statusCode: res.statusCode || 0, body, contentType })
|
|
530
|
+
);
|
|
531
|
+
}
|
|
532
|
+
);
|
|
533
|
+
req.on("error", () => resolve2(null));
|
|
534
|
+
req.setTimeout(timeout, () => {
|
|
535
|
+
req.destroy();
|
|
536
|
+
resolve2(null);
|
|
537
|
+
});
|
|
538
|
+
req.end();
|
|
539
|
+
});
|
|
540
|
+
}
|
|
541
|
+
var FALLBACK_PORTS = [
|
|
542
|
+
8081,
|
|
543
|
+
8082,
|
|
544
|
+
8083,
|
|
545
|
+
8084,
|
|
546
|
+
8085,
|
|
547
|
+
8086,
|
|
548
|
+
3e3,
|
|
549
|
+
3001,
|
|
550
|
+
19e3
|
|
551
|
+
].map((port) => ({ port, pid: 0 }));
|
|
552
|
+
function acceptPort(port, excluded) {
|
|
553
|
+
if (port <= 0 || port >= 2e4) return false;
|
|
554
|
+
if (excluded.has(port)) return false;
|
|
555
|
+
if (port >= 5170 && port <= 5200) return false;
|
|
556
|
+
return true;
|
|
557
|
+
}
|
|
558
|
+
async function discoverListeningProcesses(excludePorts = []) {
|
|
559
|
+
const excluded = new Set(excludePorts);
|
|
560
|
+
try {
|
|
561
|
+
const { stdout } = await execP(
|
|
562
|
+
`lsof -iTCP -sTCP:LISTEN -P -n 2>/dev/null | grep -E '^(node|bun)'`,
|
|
563
|
+
{ encoding: "utf8", timeout: 2e3 }
|
|
564
|
+
);
|
|
565
|
+
if (stdout.trim()) {
|
|
566
|
+
const seen = /* @__PURE__ */ new Map();
|
|
567
|
+
for (const line of stdout.trim().split("\n")) {
|
|
568
|
+
const parts = line.trim().split(/\s+/);
|
|
569
|
+
if (parts.length < 9) continue;
|
|
570
|
+
const pid = Number(parts[1]);
|
|
571
|
+
const addr = parts[8];
|
|
572
|
+
const m = addr.match(/:(\d+)$/);
|
|
573
|
+
if (!m) continue;
|
|
574
|
+
const port = Number(m[1]);
|
|
575
|
+
if (!acceptPort(port, excluded)) continue;
|
|
576
|
+
if (!seen.has(port)) seen.set(port, pid);
|
|
577
|
+
}
|
|
578
|
+
if (seen.size > 0) {
|
|
579
|
+
return [...seen.entries()].map(([port, pid]) => ({ port, pid }));
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
} catch {
|
|
583
|
+
}
|
|
584
|
+
try {
|
|
585
|
+
const { stdout } = await execP(`ss -tlnp 2>/dev/null | grep -E '"(node|bun)"'`, {
|
|
586
|
+
encoding: "utf8",
|
|
587
|
+
timeout: 2e3
|
|
588
|
+
});
|
|
589
|
+
if (stdout.trim()) {
|
|
590
|
+
const seen = /* @__PURE__ */ new Map();
|
|
591
|
+
for (const line of stdout.trim().split("\n")) {
|
|
592
|
+
const portMatch = line.match(/:(\d+)\s/);
|
|
593
|
+
const pidMatch = line.match(/pid=(\d+)/);
|
|
594
|
+
if (!portMatch) continue;
|
|
595
|
+
const port = Number(portMatch[1]);
|
|
596
|
+
const pid = pidMatch ? Number(pidMatch[1]) : 0;
|
|
597
|
+
if (!acceptPort(port, excluded)) continue;
|
|
598
|
+
if (!seen.has(port)) seen.set(port, pid);
|
|
599
|
+
}
|
|
600
|
+
if (seen.size > 0) {
|
|
601
|
+
return [...seen.entries()].map(([port, pid]) => ({ port, pid }));
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
} catch {
|
|
605
|
+
}
|
|
606
|
+
return FALLBACK_PORTS.filter((p) => acceptPort(p.port, excluded));
|
|
607
|
+
}
|
|
608
|
+
async function discoverListeningPorts(excludePorts = []) {
|
|
609
|
+
const processes = await discoverListeningProcesses(excludePorts);
|
|
610
|
+
return processes.map((p) => p.port);
|
|
611
|
+
}
|
|
612
|
+
function pidFromNetstat(stdout, port) {
|
|
613
|
+
for (const line of stdout.split("\n")) {
|
|
614
|
+
if (!line.includes("LISTEN")) continue;
|
|
615
|
+
const parts = line.trim().split(/\s+/);
|
|
616
|
+
if (!parts[3]?.endsWith(`.${port}`)) continue;
|
|
617
|
+
for (const token of parts) {
|
|
618
|
+
const owner = token.match(/^\S+:(\d+)$/);
|
|
619
|
+
if (owner) {
|
|
620
|
+
const pid = Number(owner[1]);
|
|
621
|
+
if (pid > 0) return pid;
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
return null;
|
|
626
|
+
}
|
|
627
|
+
async function resolveListeningPid(port) {
|
|
628
|
+
if (!Number.isInteger(port) || port <= 0) return null;
|
|
629
|
+
try {
|
|
630
|
+
const { stdout } = await execP("netstat -anv -p tcp 2>/dev/null", {
|
|
631
|
+
encoding: "utf8",
|
|
632
|
+
timeout: 8e3,
|
|
633
|
+
maxBuffer: 16 * 1024 * 1024
|
|
634
|
+
});
|
|
635
|
+
const pid = pidFromNetstat(stdout, port);
|
|
636
|
+
if (pid !== null) return pid;
|
|
637
|
+
} catch {
|
|
638
|
+
}
|
|
639
|
+
try {
|
|
640
|
+
const { stdout } = await execP(`ss -tlnp 2>/dev/null`, {
|
|
641
|
+
encoding: "utf8",
|
|
642
|
+
timeout: 8e3,
|
|
643
|
+
maxBuffer: 16 * 1024 * 1024
|
|
644
|
+
});
|
|
645
|
+
for (const line of stdout.split("\n")) {
|
|
646
|
+
if (!new RegExp(`:${port}\\s`).test(line)) continue;
|
|
647
|
+
const pid = Number(line.match(/pid=(\d+)/)?.[1]);
|
|
648
|
+
if (pid > 0) return pid;
|
|
649
|
+
}
|
|
650
|
+
} catch {
|
|
651
|
+
}
|
|
652
|
+
return null;
|
|
653
|
+
}
|
|
654
|
+
var cwdByPid = /* @__PURE__ */ new Map();
|
|
655
|
+
async function resolveProcessCwd(pid) {
|
|
656
|
+
if (pid <= 0) return null;
|
|
657
|
+
const cached2 = cwdByPid.get(pid);
|
|
658
|
+
if (cached2) return cached2;
|
|
659
|
+
try {
|
|
660
|
+
const cwd = await (0, import_promises2.readlink)(`/proc/${pid}/cwd`);
|
|
661
|
+
if (cwd) {
|
|
662
|
+
cwdByPid.set(pid, cwd);
|
|
663
|
+
return cwd;
|
|
664
|
+
}
|
|
665
|
+
} catch {
|
|
666
|
+
}
|
|
667
|
+
try {
|
|
668
|
+
const { stdout } = await execP(`lsof -b -w -p ${pid} -a -d cwd -Fn 2>/dev/null`, {
|
|
669
|
+
encoding: "utf8",
|
|
670
|
+
timeout: 8e3
|
|
671
|
+
});
|
|
672
|
+
for (const line of stdout.split("\n")) {
|
|
673
|
+
if (line.startsWith("n") && line.length > 1) {
|
|
674
|
+
const cwd = line.slice(1).trim();
|
|
675
|
+
if (cwd) {
|
|
676
|
+
cwdByPid.set(pid, cwd);
|
|
677
|
+
return cwd;
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
} catch {
|
|
682
|
+
}
|
|
683
|
+
return null;
|
|
684
|
+
}
|
|
685
|
+
function makeResult(port, framework, owner) {
|
|
686
|
+
return {
|
|
687
|
+
port,
|
|
688
|
+
framework,
|
|
689
|
+
bundleUrl: withRuntimeConfig(
|
|
690
|
+
port,
|
|
691
|
+
`http://localhost:${port}/index.bundle?platform=ios&dev=true&hot=true&minify=false`,
|
|
692
|
+
owner.cwd
|
|
693
|
+
),
|
|
694
|
+
hmrUrl: `ws://localhost:${port}/hot`,
|
|
695
|
+
lastSeen: Date.now(),
|
|
696
|
+
...owner
|
|
697
|
+
};
|
|
698
|
+
}
|
|
699
|
+
function withRuntimeConfig(port, bundleUrl, projectCwd) {
|
|
700
|
+
const knownApp = projectCwd ? optionalDemoAppsSync().find(
|
|
701
|
+
(app) => app.preferredPort === port && (0, import_node_path3.resolve)(app.dir) === (0, import_node_path3.resolve)(projectCwd)
|
|
702
|
+
) : void 0;
|
|
703
|
+
const configured = knownApp?.runtimeConfig ? applySootSimConfigToUrl(bundleUrl, knownApp.runtimeConfig) : bundleUrl;
|
|
704
|
+
return normalizeNativeDevBundleUrl(configured);
|
|
705
|
+
}
|
|
706
|
+
function isDirectOneBundleUrl(bundleUrl) {
|
|
707
|
+
return bundleUrl.includes("/node_modules/one/metro-entry.bundle");
|
|
708
|
+
}
|
|
709
|
+
function safeParseManifest(body) {
|
|
710
|
+
try {
|
|
711
|
+
const parsed = JSON.parse(body);
|
|
712
|
+
return parsed && typeof parsed === "object" ? parsed : null;
|
|
713
|
+
} catch {
|
|
714
|
+
return null;
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
function applyManifest(result, manifestRes, buildIconProxyUrl) {
|
|
718
|
+
if (!manifestRes) return result;
|
|
719
|
+
try {
|
|
720
|
+
const manifest = JSON.parse(manifestRes.body);
|
|
721
|
+
const client = manifest?.extra?.expoClient || manifest?.extra || {};
|
|
722
|
+
if (client.name) result.projectName = client.name;
|
|
723
|
+
if (client.ios?.bundleIdentifier) result.bundleId = client.ios.bundleIdentifier;
|
|
724
|
+
if (result.framework === "metro" && client.sdkVersion) result.framework = "expo";
|
|
725
|
+
const launchUrl = manifest?.launchAsset?.url;
|
|
726
|
+
if (launchUrl && !result.patched && !isDirectOneBundleUrl(result.bundleUrl)) {
|
|
727
|
+
result.bundleUrl = withRuntimeConfig(result.port, launchUrl, result.cwd);
|
|
728
|
+
}
|
|
729
|
+
const rawIconUrl = client.iconUrl || client.ios?.iconUrl || client.icon || client.ios?.icon;
|
|
730
|
+
if (rawIconUrl) {
|
|
731
|
+
result.iconPath = rawIconUrl;
|
|
732
|
+
if (buildIconProxyUrl) {
|
|
733
|
+
if (rawIconUrl.startsWith("http")) {
|
|
734
|
+
result.iconUrl = buildIconProxyUrl(rawIconUrl);
|
|
735
|
+
} else {
|
|
736
|
+
const cleanPath = rawIconUrl.replace(/^\.\//, "");
|
|
737
|
+
result.iconUrl = buildIconProxyUrl(
|
|
738
|
+
`http://localhost:${result.port}/assets/${cleanPath}`
|
|
739
|
+
);
|
|
740
|
+
}
|
|
741
|
+
} else {
|
|
742
|
+
result.iconUrl = rawIconUrl.startsWith("http") ? rawIconUrl : `http://localhost:${result.port}/assets/${rawIconUrl.replace(/^\.\//, "")}`;
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
} catch {
|
|
746
|
+
}
|
|
747
|
+
return result;
|
|
748
|
+
}
|
|
749
|
+
function __applyManifestForTests(result, manifestBody) {
|
|
750
|
+
return applyManifest(result, { statusCode: 200, body: manifestBody });
|
|
751
|
+
}
|
|
752
|
+
var ENRICH_TIMEOUT_MS = 2e4;
|
|
753
|
+
var enrichmentCache = /* @__PURE__ */ new Map();
|
|
754
|
+
var enrichmentInFlight = /* @__PURE__ */ new Set();
|
|
755
|
+
function enrichWithManifest(result, buildIconProxyUrl) {
|
|
756
|
+
if (result.projectName) return result;
|
|
757
|
+
const cached2 = enrichmentCache.get(result.port);
|
|
758
|
+
if (cached2) {
|
|
759
|
+
if (cached2.projectName) result.projectName = cached2.projectName;
|
|
760
|
+
if (cached2.iconUrl && !result.iconUrl) {
|
|
761
|
+
result.iconUrl = cached2.iconUrl;
|
|
762
|
+
result.iconPath = cached2.iconPath;
|
|
763
|
+
}
|
|
764
|
+
if (cached2.bundleId && !result.bundleId) result.bundleId = cached2.bundleId;
|
|
765
|
+
return result;
|
|
766
|
+
}
|
|
767
|
+
if (!enrichmentInFlight.has(result.port)) {
|
|
768
|
+
enrichmentInFlight.add(result.port);
|
|
769
|
+
const port = result.port;
|
|
770
|
+
void fetchManifestEnrichment(port, buildIconProxyUrl).finally(
|
|
771
|
+
() => enrichmentInFlight.delete(port)
|
|
772
|
+
);
|
|
773
|
+
}
|
|
774
|
+
return result;
|
|
775
|
+
}
|
|
776
|
+
async function fetchManifestEnrichment(port, buildIconProxyUrl) {
|
|
777
|
+
const manifestRes = await httpGet(port, "/", "GET", ENRICH_TIMEOUT_MS, {
|
|
778
|
+
"expo-platform": "ios"
|
|
779
|
+
});
|
|
780
|
+
if (!manifestRes || manifestRes.statusCode !== 200) return;
|
|
781
|
+
const parsed = applyManifest(
|
|
782
|
+
{ port, framework: "one", bundleUrl: "", lastSeen: 0 },
|
|
783
|
+
manifestRes,
|
|
784
|
+
buildIconProxyUrl
|
|
785
|
+
);
|
|
786
|
+
if (!parsed.projectName && !parsed.iconUrl) return;
|
|
787
|
+
enrichmentCache.set(port, {
|
|
788
|
+
projectName: parsed.projectName,
|
|
789
|
+
iconUrl: parsed.iconUrl,
|
|
790
|
+
iconPath: parsed.iconPath,
|
|
791
|
+
bundleId: parsed.bundleId
|
|
792
|
+
});
|
|
793
|
+
portCache.delete(port);
|
|
794
|
+
}
|
|
795
|
+
var knownNonPatched = /* @__PURE__ */ new Set();
|
|
796
|
+
var knownNonExpo = /* @__PURE__ */ new Set();
|
|
797
|
+
var knownOne = /* @__PURE__ */ new Set();
|
|
798
|
+
async function probePort(port, buildIconProxyUrl, listeningProcess) {
|
|
799
|
+
await loadOptionalDemoApps();
|
|
800
|
+
if (!await tcpPing(port)) return null;
|
|
801
|
+
const suppliedPid = listeningProcess?.pid;
|
|
802
|
+
const ownerPid = suppliedPid && suppliedPid > 0 ? suppliedPid : await resolveListeningPid(port);
|
|
803
|
+
const ownerCwd = ownerPid ? await resolveProcessCwd(ownerPid) : null;
|
|
804
|
+
const owner = {
|
|
805
|
+
...ownerPid ? { pid: ownerPid } : {},
|
|
806
|
+
...ownerCwd ? { cwd: ownerCwd } : {}
|
|
807
|
+
};
|
|
808
|
+
const onePath = `/node_modules/one/metro-entry.bundle?platform=ios&dev=true`;
|
|
809
|
+
const [sootsimRes, statusRes, manifestRes, expoRes] = await Promise.all([
|
|
810
|
+
knownNonPatched.has(port) ? Promise.resolve(null) : httpGet(port, "/__soot/"),
|
|
811
|
+
httpGet(port, "/status"),
|
|
812
|
+
knownOne.has(port) ? Promise.resolve(null) : httpGet(port, "/", "GET", MANIFEST_TIMEOUT_MS, { "expo-platform": "ios" }),
|
|
813
|
+
knownNonExpo.has(port) ? Promise.resolve(null) : httpGet(port, "/_expo/status")
|
|
814
|
+
]);
|
|
815
|
+
if (expoRes && expoRes.statusCode === 200) {
|
|
816
|
+
knownNonExpo.delete(port);
|
|
817
|
+
} else if (!knownNonExpo.has(port)) {
|
|
818
|
+
knownNonExpo.add(port);
|
|
819
|
+
}
|
|
820
|
+
const manifestParsed = manifestRes ? safeParseManifest(manifestRes.body) : null;
|
|
821
|
+
const manifestLaunchUrl = typeof manifestParsed?.launchAsset?.url === "string" ? manifestParsed.launchAsset.url : null;
|
|
822
|
+
const manifestClient = manifestParsed?.extra?.expoClient || manifestParsed?.extra || {};
|
|
823
|
+
if (manifestParsed && (manifestLaunchUrl || typeof manifestClient.name === "string")) {
|
|
824
|
+
knownNonPatched.add(port);
|
|
825
|
+
const launchUrl = manifestLaunchUrl || `http://localhost:${port}/index.bundle?platform=ios&dev=true&hot=true&minify=false`;
|
|
826
|
+
const framework = launchUrl.includes(
|
|
827
|
+
"/one/metro-entry.bundle"
|
|
828
|
+
) ? "one" : "expo";
|
|
829
|
+
return applyManifest(
|
|
830
|
+
{
|
|
831
|
+
port,
|
|
832
|
+
framework,
|
|
833
|
+
bundleUrl: withRuntimeConfig(port, launchUrl, owner.cwd),
|
|
834
|
+
hmrUrl: `ws://localhost:${port}/hot`,
|
|
835
|
+
lastSeen: Date.now(),
|
|
836
|
+
...owner
|
|
837
|
+
},
|
|
838
|
+
manifestRes,
|
|
839
|
+
buildIconProxyUrl
|
|
840
|
+
);
|
|
841
|
+
}
|
|
842
|
+
if (statusRes && statusRes.body.includes("packager-status:running")) {
|
|
843
|
+
knownNonPatched.add(port);
|
|
844
|
+
return enrichWithManifest(
|
|
845
|
+
applyManifest(
|
|
846
|
+
makeResult(port, expoRes && expoRes.statusCode === 200 ? "expo" : "metro", owner),
|
|
847
|
+
manifestRes,
|
|
848
|
+
buildIconProxyUrl
|
|
849
|
+
),
|
|
850
|
+
buildIconProxyUrl
|
|
851
|
+
);
|
|
852
|
+
}
|
|
853
|
+
if (sootsimRes && sootsimRes.statusCode === 200 && sootsimRes.body.includes("sootsim-patched")) {
|
|
854
|
+
knownNonPatched.delete(port);
|
|
855
|
+
return enrichWithManifest(
|
|
856
|
+
applyManifest(
|
|
857
|
+
{
|
|
858
|
+
port,
|
|
859
|
+
framework: "one",
|
|
860
|
+
bundleUrl: withRuntimeConfig(
|
|
861
|
+
port,
|
|
862
|
+
`http://localhost:${port}/__soot/bundle.js`,
|
|
863
|
+
owner.cwd
|
|
864
|
+
),
|
|
865
|
+
hmrUrl: `ws://localhost:${port}/hot`,
|
|
866
|
+
lastSeen: Date.now(),
|
|
867
|
+
patched: true,
|
|
868
|
+
...owner
|
|
869
|
+
},
|
|
870
|
+
manifestRes,
|
|
871
|
+
buildIconProxyUrl
|
|
872
|
+
),
|
|
873
|
+
buildIconProxyUrl
|
|
874
|
+
);
|
|
875
|
+
}
|
|
876
|
+
const looksLikeMetroPackager = statusRes && statusRes.statusCode === 200 || expoRes && expoRes.statusCode === 200 || manifestRes && manifestRes.statusCode === 200 && manifestParsed != null;
|
|
877
|
+
if (looksLikeMetroPackager) {
|
|
878
|
+
return null;
|
|
879
|
+
}
|
|
880
|
+
const oneRes = await httpGet(port, onePath, "HEAD");
|
|
881
|
+
if (oneRes && oneRes.statusCode > 0 && oneRes.statusCode < 400 && /application\/javascript/i.test(oneRes.contentType || "")) {
|
|
882
|
+
knownNonPatched.add(port);
|
|
883
|
+
knownOne.add(port);
|
|
884
|
+
return enrichWithManifest(
|
|
885
|
+
applyManifest(
|
|
886
|
+
{
|
|
887
|
+
port,
|
|
888
|
+
framework: "one",
|
|
889
|
+
bundleUrl: withRuntimeConfig(
|
|
890
|
+
port,
|
|
891
|
+
`http://localhost:${port}${onePath}&minify=false`,
|
|
892
|
+
owner.cwd
|
|
893
|
+
),
|
|
894
|
+
hmrUrl: `ws://localhost:${port}/hot`,
|
|
895
|
+
lastSeen: Date.now(),
|
|
896
|
+
...owner
|
|
897
|
+
},
|
|
898
|
+
manifestRes,
|
|
899
|
+
buildIconProxyUrl
|
|
900
|
+
),
|
|
901
|
+
buildIconProxyUrl
|
|
902
|
+
);
|
|
903
|
+
}
|
|
904
|
+
knownNonPatched.add(port);
|
|
905
|
+
return null;
|
|
906
|
+
}
|
|
907
|
+
function isSootSimSelfServer(server) {
|
|
908
|
+
const bundleId = server.bundleId?.trim().toLowerCase();
|
|
909
|
+
if (bundleId?.startsWith("dev.sootsim.")) return true;
|
|
910
|
+
return false;
|
|
911
|
+
}
|
|
912
|
+
var __isSootSimSelfServerForTests = isSootSimSelfServer;
|
|
913
|
+
var portCache = /* @__PURE__ */ new Map();
|
|
914
|
+
var NEGATIVE_CACHE_TTL_MS = 3e4;
|
|
915
|
+
var WEAK_RESULT_CACHE_TTL_MS = 1500;
|
|
916
|
+
function isWeakCachedResult(result) {
|
|
917
|
+
if (!result) return true;
|
|
918
|
+
if (result.framework === "metro" || result.framework === "unknown") return true;
|
|
919
|
+
return false;
|
|
920
|
+
}
|
|
921
|
+
function hasCurrentRuntimeConfig(result) {
|
|
922
|
+
if (!result) return true;
|
|
923
|
+
return withRuntimeConfig(result.port, result.bundleUrl, result.cwd) === result.bundleUrl;
|
|
924
|
+
}
|
|
925
|
+
function __shouldReuseScannerCacheEntry(entry, pid, now = Date.now()) {
|
|
926
|
+
if (pid === 0) return false;
|
|
927
|
+
if (entry.pid !== pid) return false;
|
|
928
|
+
if (!hasCurrentRuntimeConfig(entry.result)) return false;
|
|
929
|
+
const ageMs = now - entry.cachedAt;
|
|
930
|
+
if (entry.result === null && ageMs >= NEGATIVE_CACHE_TTL_MS) return false;
|
|
931
|
+
if (isWeakCachedResult(entry.result) && ageMs >= WEAK_RESULT_CACHE_TTL_MS) return false;
|
|
932
|
+
return true;
|
|
933
|
+
}
|
|
934
|
+
function __resetScannerCache() {
|
|
935
|
+
portCache.clear();
|
|
936
|
+
knownNonPatched.clear();
|
|
937
|
+
knownNonExpo.clear();
|
|
938
|
+
knownOne.clear();
|
|
939
|
+
enrichmentCache.clear();
|
|
940
|
+
enrichmentInFlight.clear();
|
|
941
|
+
__resetAppSettingsBundleCacheForTests();
|
|
942
|
+
}
|
|
943
|
+
async function attachAppSettingsBundle(result, projectRoot) {
|
|
944
|
+
const settingsBundle = await readAppSettingsBundle(projectRoot);
|
|
945
|
+
if (settingsBundle) {
|
|
946
|
+
result.settingsBundle = settingsBundle;
|
|
947
|
+
result.settingsStorageScopeUrl = result.bundleUrl;
|
|
948
|
+
} else {
|
|
949
|
+
delete result.settingsBundle;
|
|
950
|
+
delete result.settingsStorageScopeUrl;
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
var __attachAppSettingsBundleForTests = attachAppSettingsBundle;
|
|
954
|
+
async function scanDevServers(opts = {}) {
|
|
955
|
+
await loadOptionalDemoApps();
|
|
956
|
+
const processes = await discoverListeningProcesses(opts.excludePorts);
|
|
957
|
+
const currentPorts = new Set(processes.map((p) => p.port));
|
|
958
|
+
for (const p of [...portCache.keys()]) {
|
|
959
|
+
if (!currentPorts.has(p)) portCache.delete(p);
|
|
960
|
+
}
|
|
961
|
+
for (const p of [...knownNonPatched]) {
|
|
962
|
+
if (!currentPorts.has(p)) knownNonPatched.delete(p);
|
|
963
|
+
}
|
|
964
|
+
for (const p of [...knownNonExpo]) {
|
|
965
|
+
if (!currentPorts.has(p)) knownNonExpo.delete(p);
|
|
966
|
+
}
|
|
967
|
+
for (const p of [...knownOne]) {
|
|
968
|
+
if (!currentPorts.has(p)) knownOne.delete(p);
|
|
969
|
+
}
|
|
970
|
+
for (const p of [...enrichmentCache.keys()]) {
|
|
971
|
+
if (!currentPorts.has(p)) enrichmentCache.delete(p);
|
|
972
|
+
}
|
|
973
|
+
const results = [];
|
|
974
|
+
const toProbe = [];
|
|
975
|
+
for (const { port, pid } of processes) {
|
|
976
|
+
const cached2 = portCache.get(port);
|
|
977
|
+
if (cached2 && __shouldReuseScannerCacheEntry(cached2, pid)) {
|
|
978
|
+
if (cached2.result) results.push(cached2.result);
|
|
979
|
+
continue;
|
|
980
|
+
}
|
|
981
|
+
if (cached2 && cached2.pid !== pid) {
|
|
982
|
+
knownNonPatched.delete(port);
|
|
983
|
+
knownNonExpo.delete(port);
|
|
984
|
+
knownOne.delete(port);
|
|
985
|
+
enrichmentCache.delete(port);
|
|
986
|
+
}
|
|
987
|
+
toProbe.push({ port, pid });
|
|
988
|
+
}
|
|
989
|
+
if (toProbe.length > 0) {
|
|
990
|
+
const probed = await Promise.all(
|
|
991
|
+
toProbe.map((p) => probePort(p.port, opts.buildIconProxyUrl, p))
|
|
992
|
+
);
|
|
993
|
+
probed.forEach((result, i) => {
|
|
994
|
+
const { port, pid } = toProbe[i];
|
|
995
|
+
if (pid !== 0) portCache.set(port, { pid, result, cachedAt: Date.now() });
|
|
996
|
+
if (result) results.push(result);
|
|
997
|
+
});
|
|
998
|
+
}
|
|
999
|
+
const pidByPort = /* @__PURE__ */ new Map();
|
|
1000
|
+
for (const { port, pid } of processes) {
|
|
1001
|
+
if (pid > 0) pidByPort.set(port, pid);
|
|
1002
|
+
}
|
|
1003
|
+
await Promise.all(
|
|
1004
|
+
results.map(async (result) => {
|
|
1005
|
+
const pid = pidByPort.get(result.port);
|
|
1006
|
+
if (!pid) return;
|
|
1007
|
+
result.pid = pid;
|
|
1008
|
+
const cwd = await resolveProcessCwd(pid);
|
|
1009
|
+
if (!cwd) return;
|
|
1010
|
+
result.cwd = cwd;
|
|
1011
|
+
await attachAppSettingsBundle(result, cwd);
|
|
1012
|
+
})
|
|
1013
|
+
);
|
|
1014
|
+
const livePids = new Set(pidByPort.values());
|
|
1015
|
+
for (const pid of [...cwdByPid.keys()]) {
|
|
1016
|
+
if (!livePids.has(pid)) cwdByPid.delete(pid);
|
|
1017
|
+
}
|
|
1018
|
+
return results.filter((r) => !isSootSimSelfServer(r));
|
|
1019
|
+
}
|
|
1020
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
1021
|
+
0 && (module.exports = {
|
|
1022
|
+
__applyManifestForTests,
|
|
1023
|
+
__attachAppSettingsBundleForTests,
|
|
1024
|
+
__isSootSimSelfServerForTests,
|
|
1025
|
+
__resetScannerCache,
|
|
1026
|
+
__shouldReuseScannerCacheEntry,
|
|
1027
|
+
discoverListeningPorts,
|
|
1028
|
+
discoverListeningProcesses,
|
|
1029
|
+
pidFromNetstat,
|
|
1030
|
+
probePort,
|
|
1031
|
+
resolveListeningPid,
|
|
1032
|
+
resolveProcessCwd,
|
|
1033
|
+
scanDevServers
|
|
1034
|
+
});
|