peachsim 0.1.527

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.
Files changed (324) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +640 -0
  3. package/cli/app-config.ts +82 -0
  4. package/cli/app-fonts.ts +388 -0
  5. package/cli/app-project.ts +59 -0
  6. package/cli/app-splash.ts +171 -0
  7. package/cli/app-state-reset.ts +26 -0
  8. package/cli/auth.ts +184 -0
  9. package/cli/bin.ts +59 -0
  10. package/cli/bridge-diagnostics.ts +226 -0
  11. package/cli/bridge-flow-runner.ts +2806 -0
  12. package/cli/browser-backend.ts +44 -0
  13. package/cli/browser-evals.ts +96 -0
  14. package/cli/cli-update.ts +261 -0
  15. package/cli/cloud-client.ts +1530 -0
  16. package/cli/cloud-dispatch.ts +206 -0
  17. package/cli/cloud-session.ts +227 -0
  18. package/cli/command-contract.ts +221 -0
  19. package/cli/command-registry.ts +304 -0
  20. package/cli/commands/agent-wrapper.ts +1048 -0
  21. package/cli/commands/agent.ts +439 -0
  22. package/cli/commands/app-fonts.ts +99 -0
  23. package/cli/commands/assert.ts +542 -0
  24. package/cli/commands/auth.ts +71 -0
  25. package/cli/commands/box/bundle-plane.ts +71 -0
  26. package/cli/commands/box/checkout-plane.ts +256 -0
  27. package/cli/commands/box/plane-share.ts +208 -0
  28. package/cli/commands/box/rnx-command.ts +60 -0
  29. package/cli/commands/box/search-command.ts +157 -0
  30. package/cli/commands/box.ts +925 -0
  31. package/cli/commands/camera.ts +266 -0
  32. package/cli/commands/cleanup.ts +169 -0
  33. package/cli/commands/compat.ts +176 -0
  34. package/cli/commands/config.ts +34 -0
  35. package/cli/commands/control.ts +2154 -0
  36. package/cli/commands/cpu-profile.ts +941 -0
  37. package/cli/commands/daemon-mac-app.ts +165 -0
  38. package/cli/commands/daemon.ts +800 -0
  39. package/cli/commands/debug.ts +751 -0
  40. package/cli/commands/desktop.ts +39 -0
  41. package/cli/commands/detect.ts +201 -0
  42. package/cli/commands/detox.ts +481 -0
  43. package/cli/commands/device.ts +134 -0
  44. package/cli/commands/diagnose.ts +589 -0
  45. package/cli/commands/do-chain.ts +408 -0
  46. package/cli/commands/electron.ts +94 -0
  47. package/cli/commands/film.ts +379 -0
  48. package/cli/commands/flow.ts +1240 -0
  49. package/cli/commands/inspect/actions.ts +516 -0
  50. package/cli/commands/inspect/core.ts +2086 -0
  51. package/cli/commands/inspect/count.ts +17 -0
  52. package/cli/commands/inspect/describe.ts +119 -0
  53. package/cli/commands/inspect/env.ts +25 -0
  54. package/cli/commands/inspect/find.ts +169 -0
  55. package/cli/commands/inspect/get-layout.ts +53 -0
  56. package/cli/commands/inspect/keyboard.ts +54 -0
  57. package/cli/commands/inspect/list.ts +175 -0
  58. package/cli/commands/inspect/memory.ts +215 -0
  59. package/cli/commands/inspect/redaction.ts +39 -0
  60. package/cli/commands/inspect/resolve-target.ts +77 -0
  61. package/cli/commands/inspect/screens.ts +78 -0
  62. package/cli/commands/inspect/settle.ts +32 -0
  63. package/cli/commands/inspect/settling.ts +197 -0
  64. package/cli/commands/inspect/shared.ts +259 -0
  65. package/cli/commands/inspect/sleep.ts +15 -0
  66. package/cli/commands/inspect/tree.ts +23 -0
  67. package/cli/commands/inspect/url.ts +17 -0
  68. package/cli/commands/inspect/wait-event.ts +211 -0
  69. package/cli/commands/inspect/wait-idle.ts +25 -0
  70. package/cli/commands/inspect/wait-ready.ts +87 -0
  71. package/cli/commands/inspect/wait-selector.ts +59 -0
  72. package/cli/commands/inspect/wait.ts +32 -0
  73. package/cli/commands/inspect.ts +4738 -0
  74. package/cli/commands/install-cli.ts +275 -0
  75. package/cli/commands/install-desktop.ts +385 -0
  76. package/cli/commands/login.ts +357 -0
  77. package/cli/commands/logout.ts +24 -0
  78. package/cli/commands/maestro-generate.ts +375 -0
  79. package/cli/commands/maestro.ts +536 -0
  80. package/cli/commands/mode.ts +58 -0
  81. package/cli/commands/no-bridge-hint.ts +80 -0
  82. package/cli/commands/perf.ts +67 -0
  83. package/cli/commands/permissions.ts +203 -0
  84. package/cli/commands/platform.ts +410 -0
  85. package/cli/commands/preview.ts +103 -0
  86. package/cli/commands/profile.ts +106 -0
  87. package/cli/commands/react.ts +353 -0
  88. package/cli/commands/record.ts +1435 -0
  89. package/cli/commands/report-issue.ts +305 -0
  90. package/cli/commands/reset.ts +89 -0
  91. package/cli/commands/runtime.ts +348 -0
  92. package/cli/commands/screenshot-command.ts +106 -0
  93. package/cli/commands/screenshot-layers.ts +144 -0
  94. package/cli/commands/screenshot-mode.ts +38 -0
  95. package/cli/commands/screenshot.ts +492 -0
  96. package/cli/commands/screenshots-capture.ts +608 -0
  97. package/cli/commands/screenshots.ts +127 -0
  98. package/cli/commands/serve.ts +139 -0
  99. package/cli/commands/setup.ts +416 -0
  100. package/cli/commands/shell-boolean-mode.ts +82 -0
  101. package/cli/commands/skills.ts +468 -0
  102. package/cli/commands/slides.ts +357 -0
  103. package/cli/commands/state.ts +94 -0
  104. package/cli/commands/storage.ts +58 -0
  105. package/cli/commands/telemetry.ts +55 -0
  106. package/cli/commands/test.ts +535 -0
  107. package/cli/commands/three-mode.ts +771 -0
  108. package/cli/commands/timeline.ts +121 -0
  109. package/cli/commands/upgrade.ts +167 -0
  110. package/cli/commands/upload.ts +1203 -0
  111. package/cli/commands/version.ts +63 -0
  112. package/cli/commands/welcome.ts +17 -0
  113. package/cli/commands/what-happened.ts +328 -0
  114. package/cli/current-sim.ts +217 -0
  115. package/cli/desktop-companion.ts +315 -0
  116. package/cli/drivers/electron.ts +70 -0
  117. package/cli/drivers/index.ts +20 -0
  118. package/cli/drivers/playwright-provisioning.ts +184 -0
  119. package/cli/drivers/playwright-sim-host.ts +537 -0
  120. package/cli/drivers/playwright.ts +209 -0
  121. package/cli/drivers/registry.ts +65 -0
  122. package/cli/drivers/types.ts +102 -0
  123. package/cli/flow-export.ts +55 -0
  124. package/cli/flow-file.ts +142 -0
  125. package/cli/flow-live-status.ts +126 -0
  126. package/cli/flow-session.ts +140 -0
  127. package/cli/help-core.ts +143 -0
  128. package/cli/help.ts +44 -0
  129. package/cli/hidden-runtime-alias.ts +19 -0
  130. package/cli/hints.ts +214 -0
  131. package/cli/inspect-notice-state.ts +114 -0
  132. package/cli/internal-child.ts +176 -0
  133. package/cli/maestro-js.ts +323 -0
  134. package/cli/main.ts +704 -0
  135. package/cli/open-url.ts +8 -0
  136. package/cli/outbound-endpoints.ts +830 -0
  137. package/cli/parent-pid.ts +204 -0
  138. package/cli/parse-args.ts +189 -0
  139. package/cli/privacy.ts +53 -0
  140. package/cli/prompt.ts +56 -0
  141. package/cli/recording-access.ts +108 -0
  142. package/cli/registry.ts +2 -0
  143. package/cli/resolve-assets.ts +63 -0
  144. package/cli/rnx-in-process.ts +98 -0
  145. package/cli/run-registry.ts +226 -0
  146. package/cli/run-rnx-core.ts +148 -0
  147. package/cli/run-rnx.ts +137 -0
  148. package/cli/runtime-notes.ts +66 -0
  149. package/cli/runtime-summary.ts +25 -0
  150. package/cli/secure-file.ts +31 -0
  151. package/cli/self-invocation.ts +58 -0
  152. package/cli/send-to-box.ts +109 -0
  153. package/cli/setup-repository.ts +191 -0
  154. package/cli/shell-init.ts +98 -0
  155. package/cli/standalone.ts +4 -0
  156. package/cli/telemetry.ts +84 -0
  157. package/cli/ui.ts +68 -0
  158. package/cli/ws-bridge.ts +1020 -0
  159. package/detox/attempt-events.cjs +23 -0
  160. package/detox/colors.ts +54 -0
  161. package/detox/config-loader.ts +135 -0
  162. package/detox/element-types.ts +48 -0
  163. package/detox/expectations.ts +534 -0
  164. package/detox/gestures.ts +501 -0
  165. package/detox/index.ts +2694 -0
  166. package/detox/jest-preset.cjs +29 -0
  167. package/detox/jest-setup-after-env.cjs +22 -0
  168. package/detox/matchers.ts +30 -0
  169. package/detox/motion-change.cjs +109 -0
  170. package/detox/motion-change.d.cts +35 -0
  171. package/detox/navigation-lifecycle.ts +290 -0
  172. package/detox/navigation.ts +43 -0
  173. package/detox/proof-frame.cjs +114 -0
  174. package/detox/record-block-execution.cjs +78 -0
  175. package/detox/screenshots/animated-color-test-rest-norngh.png +0 -0
  176. package/detox/screenshots/color-test-after-drag-norngh.png +0 -0
  177. package/detox/screenshots/color-test-rest-norngh.png +0 -0
  178. package/detox/screenshots/theme-blue-toggle.png +0 -0
  179. package/detox/screenshots/theme-blue.png +0 -0
  180. package/detox/screenshots/theme-red-toggle.png +0 -0
  181. package/detox/screenshots/theme-red.png +0 -0
  182. package/dist-lib/agent-daemon-client.cjs +502 -0
  183. package/dist-lib/agent-events.cjs +48 -0
  184. package/dist-lib/agent-identity.cjs +53 -0
  185. package/dist-lib/agent-sessions.cjs +759 -0
  186. package/dist-lib/attached-projects.cjs +526 -0
  187. package/dist-lib/auth/shared-session.cjs +208 -0
  188. package/dist-lib/backend-origin.cjs +88 -0
  189. package/dist-lib/beta.cjs +41 -0
  190. package/dist-lib/beta.mjs +13 -0
  191. package/dist-lib/bridge-constants.cjs +161 -0
  192. package/dist-lib/bridge-contract-input.cjs +451 -0
  193. package/dist-lib/bridge-contract-input.mjs +414 -0
  194. package/dist-lib/bridge-contract.cjs +130 -0
  195. package/dist-lib/bridge-contract.mjs +94 -0
  196. package/dist-lib/capture-contract.cjs +220 -0
  197. package/dist-lib/capture-contract.mjs +190 -0
  198. package/dist-lib/cli-constants.cjs +32 -0
  199. package/dist-lib/cloud-contract.cjs +194 -0
  200. package/dist-lib/cloud-contract.mjs +145 -0
  201. package/dist-lib/cloud.cjs +670 -0
  202. package/dist-lib/cloud.mjs +639 -0
  203. package/dist-lib/config.cjs +96 -0
  204. package/dist-lib/detox/index.cjs +3789 -0
  205. package/dist-lib/detox/jest-preset.cjs +29 -0
  206. package/dist-lib/dev-bundle-resolution.cjs +290 -0
  207. package/dist-lib/home-paths.cjs +638 -0
  208. package/dist-lib/host/bridge-host.cjs +10903 -0
  209. package/dist-lib/host/fetch-proxy-handler.cjs +421 -0
  210. package/dist-lib/host/fetch-proxy-overrides.cjs +63 -0
  211. package/dist-lib/host/fetch-proxy-overrides.mjs +37 -0
  212. package/dist-lib/host/replacement-module-handler.cjs +469 -0
  213. package/dist-lib/host/websocket-proxy.cjs +298 -0
  214. package/dist-lib/index.cjs +4268 -0
  215. package/dist-lib/jump-to-source-babel.cjs +93 -0
  216. package/dist-lib/jump-to-source-native.cjs +112 -0
  217. package/dist-lib/menu.cjs +646 -0
  218. package/dist-lib/menu.mjs +604 -0
  219. package/dist-lib/metro-fingerprint-registry.cjs +186 -0
  220. package/dist-lib/metro-fingerprint-registry.mjs +156 -0
  221. package/dist-lib/metro-production-bundle.cjs +329 -0
  222. package/dist-lib/metro-production-bundle.mjs +295 -0
  223. package/dist-lib/metro.cjs +904 -0
  224. package/dist-lib/profiles.cjs +246 -0
  225. package/dist-lib/public-brand.cjs +39 -0
  226. package/dist-lib/react-native-host-modules.cjs +51 -0
  227. package/dist-lib/react-native-host-modules.mjs +25 -0
  228. package/dist-lib/render-mode.cjs +54 -0
  229. package/dist-lib/scripts/dev-server-scanner.cjs +1232 -0
  230. package/dist-lib/sdk.cjs +2433 -0
  231. package/dist-lib/sdk.mjs +2336 -0
  232. package/dist-lib/skills.cjs +39132 -0
  233. package/dist-lib/swift-submit.cjs +92 -0
  234. package/dist-lib/swift-submit.mjs +65 -0
  235. package/dist-lib/swift.cjs +1646 -0
  236. package/dist-lib/vite.cjs +1591 -0
  237. package/package.json +290 -0
  238. package/scripts/dev-server-scanner.ts +1291 -0
  239. package/scripts/optional-demo-registry.ts +113 -0
  240. package/skills/contrast/SKILL.md +165 -0
  241. package/skills/rnx-debug/SKILL.md +433 -0
  242. package/skills/rnx-perf/SKILL.md +399 -0
  243. package/skills/rnx-setup/SKILL.md +172 -0
  244. package/skills/rnx-test/SKILL.md +321 -0
  245. package/skills/rnx-visual/SKILL.md +126 -0
  246. package/src/agent-daemon-client.ts +410 -0
  247. package/src/agent-events.ts +71 -0
  248. package/src/agent-identity.ts +23 -0
  249. package/src/agent-prompt.ts +71 -0
  250. package/src/agent-sessions.ts +580 -0
  251. package/src/app-url.ts +39 -0
  252. package/src/attached-projects.ts +539 -0
  253. package/src/auth/shared-session.ts +235 -0
  254. package/src/backend-origin.ts +70 -0
  255. package/src/beta.ts +19 -0
  256. package/src/bridge-constants.ts +175 -0
  257. package/src/bridge-contract-input.ts +502 -0
  258. package/src/bridge-contract.ts +558 -0
  259. package/src/browser-cache.ts +16 -0
  260. package/src/capture-contract.ts +587 -0
  261. package/src/cli-constants.ts +1 -0
  262. package/src/cli-version.ts +40 -0
  263. package/src/cloud-contract.ts +274 -0
  264. package/src/cloud.ts +762 -0
  265. package/src/codex-client.ts +234 -0
  266. package/src/config.ts +132 -0
  267. package/src/connect.ts +101 -0
  268. package/src/dev-bundle-resolution.ts +346 -0
  269. package/src/dev-server-open.ts +198 -0
  270. package/src/disk-cleanup.ts +540 -0
  271. package/src/flow-timeout-scale.ts +15 -0
  272. package/src/home-paths.ts +806 -0
  273. package/src/host/agent-host.ts +666 -0
  274. package/src/host/bridge-host.ts +2788 -0
  275. package/src/host/fetch-proxy-handler.ts +449 -0
  276. package/src/host/fetch-proxy-overrides.ts +51 -0
  277. package/src/host/open-url.ts +89 -0
  278. package/src/host/plane-host.ts +203 -0
  279. package/src/host/replacement-module-handler.ts +158 -0
  280. package/src/host/websocket-proxy.ts +315 -0
  281. package/src/index.ts +71 -0
  282. package/src/jump-to-source-babel.ts +135 -0
  283. package/src/jump-to-source-native.ts +102 -0
  284. package/src/menu.ts +777 -0
  285. package/src/metro-fingerprint-registry.ts +302 -0
  286. package/src/metro-plugin.ts +341 -0
  287. package/src/metro-production-bundle.ts +471 -0
  288. package/src/native-dev-bundle-url.ts +118 -0
  289. package/src/native-seam-manifest.ts +341 -0
  290. package/src/playwright-host-log.ts +16 -0
  291. package/src/plist.ts +27 -0
  292. package/src/poll-until.ts +123 -0
  293. package/src/profiles.ts +179 -0
  294. package/src/public-brand.ts +9 -0
  295. package/src/react-native-host-modules.ts +26 -0
  296. package/src/render-mode.ts +27 -0
  297. package/src/rolldown-plugin-swift.ts +240 -0
  298. package/src/runtime-assets.ts +233 -0
  299. package/src/runtime-delivery.ts +54 -0
  300. package/src/screenshots/compose.ts +422 -0
  301. package/src/screenshots/frame-compose.ts +514 -0
  302. package/src/screenshots/orchestrate.ts +256 -0
  303. package/src/screenshots/org-deck.ts +91 -0
  304. package/src/screenshots/registry.ts +58 -0
  305. package/src/screenshots/schema.ts +364 -0
  306. package/src/sdk.ts +15 -0
  307. package/src/settings-bundle.ts +418 -0
  308. package/src/shell-bridge-identity.ts +15 -0
  309. package/src/sim-client.ts +697 -0
  310. package/src/skills/builtin/a11y-review.ts +132 -0
  311. package/src/skills/builtin/compat-check.ts +71 -0
  312. package/src/skills/builtin/maestro-test.ts +121 -0
  313. package/src/skills/builtin/perf-profile.ts +90 -0
  314. package/src/skills/builtin/screenshot-all.ts +52 -0
  315. package/src/skills/builtin/visual-diff.ts +100 -0
  316. package/src/skills/registry.ts +107 -0
  317. package/src/skills/types.ts +41 -0
  318. package/src/swift-submit.ts +185 -0
  319. package/src/swift.ts +7 -0
  320. package/src/team-machine-prompt.ts +73 -0
  321. package/src/vite-plugin-one.ts +264 -0
  322. package/src/vite-plugin-swift.ts +620 -0
  323. package/src/vite-plugin.ts +1946 -0
  324. package/src/worklets-babel.ts +250 -0
@@ -0,0 +1,1232 @@
1
+ /*! rnx v0.1.527 | (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
+ DevServerScanUnavailableError: () => DevServerScanUnavailableError,
36
+ __applyManifestForTests: () => __applyManifestForTests,
37
+ __attachAppSettingsBundleForTests: () => __attachAppSettingsBundleForTests,
38
+ __isSootSimSelfServerForTests: () => __isSootSimSelfServerForTests,
39
+ __resetScannerCache: () => __resetScannerCache,
40
+ __shouldReuseScannerCacheEntry: () => __shouldReuseScannerCacheEntry,
41
+ discoverListeningPorts: () => discoverListeningPorts,
42
+ discoverListeningProcesses: () => discoverListeningProcesses,
43
+ pidFromNetstat: () => pidFromNetstat,
44
+ probePort: () => probePort,
45
+ resolveListeningPid: () => resolveListeningPid,
46
+ resolveProcessCwd: () => resolveProcessCwd,
47
+ scanDevServers: () => scanDevServers,
48
+ scanListeningProcesses: () => scanListeningProcesses
49
+ });
50
+ module.exports = __toCommonJS(dev_server_scanner_exports);
51
+ var import_child_process = require("child_process");
52
+ var import_promises2 = require("fs/promises");
53
+ var import_http = __toESM(require("http"), 1);
54
+ var import_net = __toESM(require("net"), 1);
55
+ var import_node_fs2 = require("node:fs");
56
+ var import_node_path3 = require("node:path");
57
+
58
+ // src/backend-origin.ts
59
+ var LOOPBACK_PROBE_HOSTNAMES = ["127.0.0.1", "::1"];
60
+ function normalizeHostname(hostname) {
61
+ return hostname.replace(/^\[|\]$/g, "").toLowerCase();
62
+ }
63
+ function buildLoopbackProbeBaseUrl(protocol, hostname, port) {
64
+ const normalizedHostname = normalizeHostname(hostname);
65
+ const urlHost = normalizedHostname.includes(":") ? `[${normalizedHostname}]` : normalizedHostname;
66
+ return `${protocol}//${urlHost}:${port}`;
67
+ }
68
+ function isLoopbackHost(hostname) {
69
+ const normalized = normalizeHostname(hostname);
70
+ return normalized === "localhost" || normalized.endsWith(".localhost") || normalized === "0.0.0.0" || normalized === "::1" || /^127(?:\.\d{1,3}){3}$/.test(normalized);
71
+ }
72
+
73
+ // src/config.ts
74
+ var RNX_CONFIG_QUERY_PARAM = "rnxConfig";
75
+ function hasOwnKeys(value) {
76
+ return !!value && Object.keys(value).length > 0;
77
+ }
78
+ function hasRNXConfig(config) {
79
+ if (!config) return false;
80
+ 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);
81
+ }
82
+ function applyRNXConfigToUrl(url, config) {
83
+ const parsed = new URL(url);
84
+ if (hasRNXConfig(config)) {
85
+ parsed.searchParams.set(RNX_CONFIG_QUERY_PARAM, JSON.stringify(config));
86
+ } else {
87
+ parsed.searchParams.delete(RNX_CONFIG_QUERY_PARAM);
88
+ }
89
+ return parsed.toString();
90
+ }
91
+
92
+ // src/native-dev-bundle-url.ts
93
+ function isAbsoluteHttpUrl(url) {
94
+ return /^https?:\/\//i.test(url);
95
+ }
96
+ function isNativeDevBundlePath(pathname) {
97
+ return pathname.endsWith(".bundle");
98
+ }
99
+ function alignLoopbackBundleUrlWithProbe(bundleUrl, probeBaseUrl) {
100
+ try {
101
+ const bundle = new URL(bundleUrl);
102
+ const probe = new URL(probeBaseUrl);
103
+ if (!isLoopbackHost(bundle.hostname) || !isLoopbackHost(probe.hostname)) {
104
+ return bundleUrl;
105
+ }
106
+ bundle.hostname = probe.hostname;
107
+ return bundle.toString();
108
+ } catch {
109
+ return bundleUrl;
110
+ }
111
+ }
112
+ function applyPreviewProdBundle(parsed) {
113
+ if (!process.env.SOOTSIM_PREVIEW_PROD_BUNDLE) return;
114
+ parsed.searchParams.set("dev", "false");
115
+ parsed.searchParams.set("minify", "true");
116
+ if (parsed.searchParams.has("hot")) parsed.searchParams.set("hot", "false");
117
+ }
118
+ function normalizeNativeDevBundleUrl(bundleUrl) {
119
+ try {
120
+ const isAbsolute = isAbsoluteHttpUrl(bundleUrl);
121
+ const parsed = new URL(bundleUrl, "http://sootsim.local");
122
+ parsed.pathname = parsed.pathname.replace(/\.\.bundle$/, ".bundle");
123
+ if (!isNativeDevBundlePath(parsed.pathname)) return bundleUrl;
124
+ parsed.searchParams.delete("transform.bytecode");
125
+ if (parsed.searchParams.get("lazy") === "true") {
126
+ parsed.searchParams.set("lazy", "false");
127
+ }
128
+ applyPreviewProdBundle(parsed);
129
+ if (isAbsolute) return parsed.toString();
130
+ return `${parsed.pathname}${parsed.search}${parsed.hash}`;
131
+ } catch {
132
+ return bundleUrl;
133
+ }
134
+ }
135
+
136
+ // src/settings-bundle.ts
137
+ var import_promises = require("node:fs/promises");
138
+ var import_node_path = require("node:path");
139
+
140
+ // src/plist.ts
141
+ var import_plist = __toESM(require("@expo/plist"), 1);
142
+ function isRecord(value) {
143
+ return typeof value === "object" && value !== null && !Array.isArray(value);
144
+ }
145
+ function resolvePlistParser(value) {
146
+ if (!isRecord(value)) return null;
147
+ const direct = value.parse;
148
+ if (typeof direct === "function") {
149
+ return (source) => Reflect.apply(direct, value, [source]);
150
+ }
151
+ const nested = value.default;
152
+ if (!isRecord(nested)) return null;
153
+ const nestedParse = nested.parse;
154
+ return typeof nestedParse === "function" ? (source) => Reflect.apply(nestedParse, nested, [source]) : null;
155
+ }
156
+ var parsePlist = resolvePlistParser(import_plist.default);
157
+ function parsePlistSource(source) {
158
+ return parsePlist?.(source) ?? null;
159
+ }
160
+
161
+ // src/settings-bundle.ts
162
+ var MAX_PLIST_BYTES = 1048576;
163
+ var MAX_CHILD_DEPTH = 8;
164
+ var MAX_PLIST_FILES = 32;
165
+ var MAX_SPECIFIERS = 512;
166
+ var settingsBundleCache = /* @__PURE__ */ new Map();
167
+ function isRecord2(value) {
168
+ return typeof value === "object" && value !== null && !Array.isArray(value);
169
+ }
170
+ function optionalString(value) {
171
+ return typeof value === "string" ? value : void 0;
172
+ }
173
+ function requiredString(value) {
174
+ if (typeof value !== "string") return null;
175
+ const normalized = value.trim();
176
+ return normalized ? normalized : null;
177
+ }
178
+ function finiteNumber(value) {
179
+ return typeof value === "number" && Number.isFinite(value) ? value : null;
180
+ }
181
+ function preferenceValue(value) {
182
+ if (typeof value === "string" || typeof value === "boolean") return value;
183
+ return finiteNumber(value);
184
+ }
185
+ function keyboardType(value) {
186
+ if (typeof value !== "string") return void 0;
187
+ switch (value.replaceAll(/[-_\s]/g, "").toLowerCase()) {
188
+ case "alphabet":
189
+ return "alphabet";
190
+ case "numbersandpunctuation":
191
+ return "numbers-and-punctuation";
192
+ case "numberpad":
193
+ return "number-pad";
194
+ case "url":
195
+ return "url";
196
+ case "emailaddress":
197
+ return "email-address";
198
+ case "namephonepad":
199
+ return "name-phone-pad";
200
+ case "asciicapable":
201
+ return "ascii-capable";
202
+ default:
203
+ return void 0;
204
+ }
205
+ }
206
+ function autocapitalization(value) {
207
+ if (typeof value !== "string") return void 0;
208
+ switch (value.replaceAll(/[-_\s]/g, "").toLowerCase()) {
209
+ case "none":
210
+ return "none";
211
+ case "sentences":
212
+ return "sentences";
213
+ case "words":
214
+ return "words";
215
+ case "allcharacters":
216
+ return "all-characters";
217
+ default:
218
+ return void 0;
219
+ }
220
+ }
221
+ function autocorrection(value) {
222
+ if (typeof value === "boolean") return value;
223
+ if (typeof value !== "string") return void 0;
224
+ switch (value.trim().toLowerCase()) {
225
+ case "yes":
226
+ return true;
227
+ case "no":
228
+ return false;
229
+ default:
230
+ return void 0;
231
+ }
232
+ }
233
+ function safeChildPlistName(value) {
234
+ const file = requiredString(value);
235
+ if (!file || file.includes("/") || file.includes("\\") || file.includes("..")) {
236
+ return null;
237
+ }
238
+ return {
239
+ file,
240
+ name: file.toLowerCase().endsWith(".plist") ? file : `${file}.plist`
241
+ };
242
+ }
243
+ async function readableSettingsBundle(path) {
244
+ try {
245
+ const root = await (0, import_promises.stat)((0, import_node_path.join)(path, "Root.plist"));
246
+ return root.isFile() && root.size <= MAX_PLIST_BYTES;
247
+ } catch {
248
+ return false;
249
+ }
250
+ }
251
+ async function findSettingsBundle(projectRoot) {
252
+ const directCandidates = [
253
+ (0, import_node_path.join)(projectRoot, "Settings.bundle"),
254
+ (0, import_node_path.join)(projectRoot, "ios", "Settings.bundle")
255
+ ];
256
+ for (const candidate of directCandidates) {
257
+ if (await readableSettingsBundle(candidate)) return candidate;
258
+ }
259
+ try {
260
+ const iosRoot = (0, import_node_path.join)(projectRoot, "ios");
261
+ const children = await (0, import_promises.readdir)(iosRoot, { withFileTypes: true });
262
+ const candidates = children.filter(
263
+ (entry) => entry.isDirectory() && entry.name !== "Pods" && entry.name !== "build" && !entry.name.startsWith(".")
264
+ ).map((entry) => (0, import_node_path.join)(iosRoot, entry.name, "Settings.bundle")).sort();
265
+ for (const candidate of candidates) {
266
+ if (await readableSettingsBundle(candidate)) return candidate;
267
+ }
268
+ } catch {
269
+ }
270
+ return null;
271
+ }
272
+ async function settingsBundleFingerprint(bundlePath) {
273
+ try {
274
+ const entries = await (0, import_promises.readdir)(bundlePath, { withFileTypes: true });
275
+ const names = entries.filter((entry) => entry.isFile() && entry.name.toLowerCase().endsWith(".plist")).map((entry) => entry.name).sort().slice(0, MAX_PLIST_FILES + 1);
276
+ if (names.length === 0 || names.length > MAX_PLIST_FILES) return null;
277
+ const parts = await Promise.all(
278
+ names.map(async (name) => {
279
+ const metadata = await (0, import_promises.stat)((0, import_node_path.join)(bundlePath, name));
280
+ if (!metadata.isFile() || metadata.size > MAX_PLIST_BYTES) return null;
281
+ return `${name}:${metadata.size}:${metadata.mtimeMs}:${metadata.ctimeMs}`;
282
+ })
283
+ );
284
+ if (parts.some((part) => part === null)) return null;
285
+ return parts.join("|");
286
+ } catch {
287
+ return null;
288
+ }
289
+ }
290
+ async function parsePlistRecord(path) {
291
+ try {
292
+ const metadata = await (0, import_promises.stat)(path);
293
+ if (!metadata.isFile() || metadata.size > MAX_PLIST_BYTES) return null;
294
+ const source = await (0, import_promises.readFile)(path, "utf8");
295
+ const parsed = parsePlistSource(source);
296
+ return isRecord2(parsed) ? parsed : null;
297
+ } catch {
298
+ return null;
299
+ }
300
+ }
301
+ function normalizeMultiValue(raw, key, title) {
302
+ if (!Array.isArray(raw.Values) || !Array.isArray(raw.Titles)) return null;
303
+ const values = [];
304
+ const titles = [];
305
+ let optionType;
306
+ const pairCount = Math.min(raw.Values.length, raw.Titles.length);
307
+ for (let index = 0; index < pairCount; index++) {
308
+ const value = preferenceValue(raw.Values[index]);
309
+ const optionTitle = optionalString(raw.Titles[index]);
310
+ if (value === null || optionTitle === void 0) continue;
311
+ const valueType = typeof value === "string" ? "string" : typeof value === "number" ? "number" : "boolean";
312
+ if (optionType !== void 0 && valueType !== optionType) continue;
313
+ optionType = valueType;
314
+ values.push(value);
315
+ titles.push(optionTitle);
316
+ }
317
+ const firstValue = values[0];
318
+ if (firstValue === void 0) return null;
319
+ const declaredDefault = preferenceValue(raw.DefaultValue);
320
+ const defaultValue = declaredDefault !== null && values.includes(declaredDefault) ? declaredDefault : firstValue;
321
+ return {
322
+ type: "multi-value",
323
+ key,
324
+ title,
325
+ defaultValue,
326
+ currentValue: defaultValue,
327
+ values,
328
+ titles
329
+ };
330
+ }
331
+ async function normalizeSpecifier(raw, context) {
332
+ if (!isRecord2(raw)) return null;
333
+ if (context.budget.specifiers >= MAX_SPECIFIERS) return null;
334
+ const type = requiredString(raw.Type);
335
+ if (!type) return null;
336
+ context.budget.specifiers += 1;
337
+ if (type === "PSGroupSpecifier") {
338
+ const title2 = optionalString(raw.Title);
339
+ const footer = optionalString(raw.FooterText);
340
+ return {
341
+ type: "group",
342
+ ...title2 !== void 0 ? { title: title2 } : null,
343
+ ...footer !== void 0 ? { footer } : null
344
+ };
345
+ }
346
+ const key = requiredString(raw.Key);
347
+ if (type === "PSSliderSpecifier") {
348
+ if (!key) return null;
349
+ const minimumValue = finiteNumber(raw.MinimumValue);
350
+ const maximumValue = finiteNumber(raw.MaximumValue);
351
+ if (minimumValue === null || maximumValue === null || maximumValue <= minimumValue) {
352
+ return null;
353
+ }
354
+ const declaredDefault = finiteNumber(raw.DefaultValue);
355
+ const defaultValue = Math.min(
356
+ maximumValue,
357
+ Math.max(minimumValue, declaredDefault ?? minimumValue)
358
+ );
359
+ const title2 = optionalString(raw.Title);
360
+ const minimumValueImage = optionalString(raw.MinimumValueImage);
361
+ const maximumValueImage = optionalString(raw.MaximumValueImage);
362
+ return {
363
+ type: "slider",
364
+ key,
365
+ defaultValue,
366
+ currentValue: defaultValue,
367
+ minimumValue,
368
+ maximumValue,
369
+ ...title2 !== void 0 ? { title: title2 } : null,
370
+ ...minimumValueImage !== void 0 ? { minimumValueImage } : null,
371
+ ...maximumValueImage !== void 0 ? { maximumValueImage } : null
372
+ };
373
+ }
374
+ if (type === "PSChildPaneSpecifier") {
375
+ const title2 = requiredString(raw.Title);
376
+ const child = safeChildPlistName(raw.File);
377
+ if (!title2 || !child || context.depth >= MAX_CHILD_DEPTH) return null;
378
+ const childSpecifiers = await parseSpecifierFile(child.name, {
379
+ ...context,
380
+ depth: context.depth + 1
381
+ });
382
+ if (!childSpecifiers || childSpecifiers.length === 0) return null;
383
+ return {
384
+ type: "child-pane",
385
+ title: title2,
386
+ file: child.file,
387
+ specifiers: childSpecifiers
388
+ };
389
+ }
390
+ if (!key) return null;
391
+ const title = requiredString(raw.Title) ?? key;
392
+ if (type === "PSToggleSwitchSpecifier") {
393
+ const defaultValue = typeof raw.DefaultValue === "boolean" ? raw.DefaultValue : false;
394
+ return {
395
+ type: "toggle",
396
+ key,
397
+ title,
398
+ defaultValue,
399
+ currentValue: defaultValue
400
+ };
401
+ }
402
+ if (type === "PSTextFieldSpecifier") {
403
+ const defaultValue = optionalString(raw.DefaultValue) ?? "";
404
+ const placeholder = optionalString(raw.Placeholder);
405
+ const resolvedKeyboardType = keyboardType(raw.KeyboardType);
406
+ const resolvedAutocapitalization = autocapitalization(raw.AutocapitalizationType);
407
+ const resolvedAutocorrection = autocorrection(raw.AutocorrectionType);
408
+ return {
409
+ type: "text",
410
+ key,
411
+ title,
412
+ defaultValue,
413
+ currentValue: defaultValue,
414
+ ...placeholder !== void 0 ? { placeholder } : null,
415
+ ...typeof raw.IsSecure === "boolean" ? { secure: raw.IsSecure } : null,
416
+ ...resolvedKeyboardType ? { keyboardType: resolvedKeyboardType } : null,
417
+ ...resolvedAutocapitalization ? { autocapitalization: resolvedAutocapitalization } : null,
418
+ ...resolvedAutocorrection !== void 0 ? { autocorrection: resolvedAutocorrection } : null
419
+ };
420
+ }
421
+ if (type === "PSMultiValueSpecifier" || type === "PSRadioGroupSpecifier") {
422
+ return normalizeMultiValue(raw, key, title);
423
+ }
424
+ if (type === "PSTitleValueSpecifier") {
425
+ const defaultValue = preferenceValue(raw.DefaultValue) ?? "";
426
+ return {
427
+ type: "title-value",
428
+ key,
429
+ title,
430
+ defaultValue,
431
+ currentValue: defaultValue
432
+ };
433
+ }
434
+ return null;
435
+ }
436
+ async function parseSpecifierFile(fileName, context) {
437
+ const cached2 = context.fileCache.get(fileName);
438
+ if (cached2 !== void 0) return cached2;
439
+ if (context.stack.has(fileName) || context.budget.files >= MAX_PLIST_FILES) {
440
+ return null;
441
+ }
442
+ context.budget.files += 1;
443
+ const root = await parsePlistRecord((0, import_node_path.join)(context.bundlePath, fileName));
444
+ if (!root || !Array.isArray(root.PreferenceSpecifiers)) {
445
+ context.fileCache.set(fileName, null);
446
+ return null;
447
+ }
448
+ const stack = new Set(context.stack);
449
+ stack.add(fileName);
450
+ const specifiers = [];
451
+ for (const raw of root.PreferenceSpecifiers) {
452
+ if (context.budget.specifiers >= MAX_SPECIFIERS) break;
453
+ const specifier = await normalizeSpecifier(raw, { ...context, stack });
454
+ if (specifier) specifiers.push(specifier);
455
+ }
456
+ context.fileCache.set(fileName, specifiers);
457
+ return specifiers;
458
+ }
459
+ async function readAppSettingsBundle(projectRoot) {
460
+ const bundlePath = await findSettingsBundle(projectRoot);
461
+ if (!bundlePath) return null;
462
+ const fingerprint = await settingsBundleFingerprint(bundlePath);
463
+ if (!fingerprint) return null;
464
+ const cached2 = settingsBundleCache.get(bundlePath);
465
+ if (cached2?.fingerprint === fingerprint) return cached2.specifiers;
466
+ const specifiers = await parseSpecifierFile("Root.plist", {
467
+ bundlePath,
468
+ depth: 0,
469
+ budget: { files: 0, specifiers: 0 },
470
+ stack: /* @__PURE__ */ new Set(),
471
+ fileCache: /* @__PURE__ */ new Map()
472
+ });
473
+ const normalized = specifiers && specifiers.length > 0 ? specifiers : null;
474
+ settingsBundleCache.set(bundlePath, { fingerprint, specifiers: normalized });
475
+ return normalized;
476
+ }
477
+ function __resetAppSettingsBundleCacheForTests() {
478
+ settingsBundleCache.clear();
479
+ }
480
+
481
+ // scripts/optional-demo-registry.ts
482
+ var import_node_fs = require("node:fs");
483
+ var import_node_path2 = require("node:path");
484
+ var import_node_url = require("node:url");
485
+ var REGISTRY_REPO_PATH = "packages/sootsim/scripts/demo-app-registry.ts";
486
+ var MAX_ANCESTOR_STEPS = 8;
487
+ function findInternalDemoRegistry(startDir) {
488
+ let dir = startDir;
489
+ for (let step = 0; step < MAX_ANCESTOR_STEPS; step++) {
490
+ if ((0, import_node_path2.basename)(dir) === "node_modules") return null;
491
+ const candidate = (0, import_node_path2.join)(dir, REGISTRY_REPO_PATH);
492
+ if ((0, import_node_fs.existsSync)(candidate)) return candidate;
493
+ const parent = (0, import_node_path2.dirname)(dir);
494
+ if (parent === dir) return null;
495
+ dir = parent;
496
+ }
497
+ return null;
498
+ }
499
+ var cached = null;
500
+ async function loadOptionalDemoApps() {
501
+ if (cached) return cached;
502
+ const registryPath = findInternalDemoRegistry((0, import_node_path2.dirname)((0, import_node_url.fileURLToPath)(__sootsim_import_meta_url)));
503
+ if (!registryPath) {
504
+ cached = [];
505
+ return cached;
506
+ }
507
+ try {
508
+ const mod = await import(
509
+ /* @vite-ignore */
510
+ (0, import_node_url.pathToFileURL)(registryPath).href
511
+ );
512
+ cached = Array.isArray(mod.APPS) ? mod.APPS : [];
513
+ } catch {
514
+ cached = [];
515
+ }
516
+ return cached;
517
+ }
518
+ function optionalDemoAppsSync() {
519
+ return cached ?? [];
520
+ }
521
+
522
+ // scripts/dev-server-scanner.ts
523
+ var EXEC_EXIT_GRACE_MS = 2e3;
524
+ async function execGuarded(command, timeout, extra = {}) {
525
+ let child;
526
+ const ran = new Promise((resolve2, reject) => {
527
+ child = (0, import_child_process.exec)(command, { encoding: "utf8", timeout, ...extra }, (err, stdout) => {
528
+ if (err) reject(err);
529
+ else resolve2({ stdout });
530
+ });
531
+ });
532
+ let deadlineTimer;
533
+ const deadline = new Promise((_resolve, reject) => {
534
+ deadlineTimer = setTimeout(() => {
535
+ child?.kill("SIGKILL");
536
+ const err = new Error(`\`${command}\` did not exit within ${timeout}ms`);
537
+ Object.assign(err, { killed: true });
538
+ reject(err);
539
+ }, timeout + EXEC_EXIT_GRACE_MS);
540
+ });
541
+ try {
542
+ return await Promise.race([ran, deadline]);
543
+ } finally {
544
+ clearTimeout(deadlineTimer);
545
+ }
546
+ }
547
+ var TIMEOUT_MS = 250;
548
+ var MANIFEST_TIMEOUT_MS = 1500;
549
+ var TCP_GATE_MS = 120;
550
+ var BODY_TIMEOUT_MS = 3e4;
551
+ async function tcpPing(port, timeout = TCP_GATE_MS) {
552
+ try {
553
+ return await Promise.any(
554
+ LOOPBACK_PROBE_HOSTNAMES.map(
555
+ (hostname) => new Promise((resolve2, reject) => {
556
+ const sock = new import_net.default.Socket();
557
+ let settled = false;
558
+ const done = (reachable) => {
559
+ if (settled) return;
560
+ settled = true;
561
+ sock.destroy();
562
+ if (reachable) resolve2(hostname);
563
+ else reject(new Error(`unreachable loopback host ${hostname}`));
564
+ };
565
+ sock.setTimeout(timeout);
566
+ sock.once("connect", () => done(true));
567
+ sock.once("timeout", () => done(false));
568
+ sock.once("error", () => done(false));
569
+ sock.connect(port, hostname);
570
+ })
571
+ )
572
+ );
573
+ } catch {
574
+ return null;
575
+ }
576
+ }
577
+ function httpGet(hostname, port, path, method = "GET", timeout = TIMEOUT_MS, headers = {}) {
578
+ return new Promise((resolve2) => {
579
+ let settled = false;
580
+ const settle = (value) => {
581
+ if (settled) return;
582
+ settled = true;
583
+ resolve2(value);
584
+ };
585
+ const req = import_http.default.request({ hostname, port, path, method, headers }, (res) => {
586
+ let body = "";
587
+ res.on("data", (c) => body += c.toString());
588
+ const contentType = (() => {
589
+ const raw = res.headers["content-type"];
590
+ if (typeof raw === "string") return raw;
591
+ if (Array.isArray(raw)) return raw[0];
592
+ return void 0;
593
+ })();
594
+ res.on(
595
+ "end",
596
+ () => settle({
597
+ statusCode: res.statusCode || 0,
598
+ body,
599
+ contentType,
600
+ hostname
601
+ })
602
+ );
603
+ });
604
+ req.on("error", () => settle(null));
605
+ req.end();
606
+ const giveUp = setTimeout(() => {
607
+ settle(null);
608
+ req.socket?.unref();
609
+ }, timeout);
610
+ const abandon = setTimeout(() => req.destroy(), BODY_TIMEOUT_MS);
611
+ req.on("close", () => {
612
+ clearTimeout(giveUp);
613
+ clearTimeout(abandon);
614
+ setImmediate(() => settle(null));
615
+ });
616
+ });
617
+ }
618
+ var FALLBACK_PORTS = [
619
+ 8081,
620
+ 8082,
621
+ 8083,
622
+ 8084,
623
+ 8085,
624
+ 8086,
625
+ 3e3,
626
+ 3001,
627
+ 19e3
628
+ ].map((port) => ({ port, pid: 0 }));
629
+ var SELF_PORT_RANGE_START = 5170;
630
+ var SELF_PORT_RANGE_END = 5200;
631
+ function isOwnShellPort(port) {
632
+ const offset = Number(process.env.PORT_OFFSET) || 0;
633
+ if (port >= SELF_PORT_RANGE_START && port <= SELF_PORT_RANGE_END) return true;
634
+ return offset > 0 && port >= SELF_PORT_RANGE_START + offset && port <= SELF_PORT_RANGE_END + offset;
635
+ }
636
+ function acceptPort(port, excluded) {
637
+ if (port <= 0 || port >= 2e4) return false;
638
+ if (excluded.has(port)) return false;
639
+ if (isOwnShellPort(port)) return false;
640
+ return true;
641
+ }
642
+ var DevServerScanUnavailableError = class extends Error {
643
+ constructor() {
644
+ super("could not enumerate listening processes (lsof/ss unavailable or timed out)");
645
+ this.name = "DevServerScanUnavailableError";
646
+ }
647
+ };
648
+ var LISTING_TIMEOUT_MS = 1e4;
649
+ function wasKilledByTimeout(err) {
650
+ return !!(err && typeof err === "object" && err.killed);
651
+ }
652
+ async function discoverListeningProcesses(excludePorts = []) {
653
+ const scan = await scanListeningProcesses(excludePorts);
654
+ return scan.state === "looked" ? scan.processes : [];
655
+ }
656
+ async function scanListeningProcesses(excludePorts = []) {
657
+ const excluded = new Set(excludePorts);
658
+ let timedOut = false;
659
+ try {
660
+ const { stdout } = await execGuarded(
661
+ `lsof -iTCP -sTCP:LISTEN -P -n 2>/dev/null | grep -E '^(node|bun)'`,
662
+ LISTING_TIMEOUT_MS
663
+ );
664
+ const seen = /* @__PURE__ */ new Map();
665
+ for (const line of stdout.trim() ? stdout.trim().split("\n") : []) {
666
+ const parts = line.trim().split(/\s+/);
667
+ if (parts.length < 9) continue;
668
+ const pid = Number(parts[1]);
669
+ const addr = parts[8];
670
+ const m = addr.match(/:(\d+)$/);
671
+ if (!m) continue;
672
+ const port = Number(m[1]);
673
+ if (!acceptPort(port, excluded)) continue;
674
+ if (!seen.has(port)) seen.set(port, pid);
675
+ }
676
+ return {
677
+ state: "looked",
678
+ processes: [...seen.entries()].map(([port, pid]) => ({ port, pid }))
679
+ };
680
+ } catch (err) {
681
+ if (wasKilledByTimeout(err)) timedOut = true;
682
+ }
683
+ try {
684
+ const { stdout } = await execGuarded(
685
+ `ss -tlnp 2>/dev/null | grep -E '"(node|bun)"'`,
686
+ LISTING_TIMEOUT_MS
687
+ );
688
+ const seen = /* @__PURE__ */ new Map();
689
+ for (const line of stdout.trim() ? stdout.trim().split("\n") : []) {
690
+ const portMatch = line.match(/:(\d+)\s/);
691
+ const pidMatch = line.match(/pid=(\d+)/);
692
+ if (!portMatch) continue;
693
+ const port = Number(portMatch[1]);
694
+ const pid = pidMatch ? Number(pidMatch[1]) : 0;
695
+ if (!acceptPort(port, excluded)) continue;
696
+ if (!seen.has(port)) seen.set(port, pid);
697
+ }
698
+ return {
699
+ state: "looked",
700
+ processes: [...seen.entries()].map(([port, pid]) => ({ port, pid }))
701
+ };
702
+ } catch (err) {
703
+ if (wasKilledByTimeout(err)) timedOut = true;
704
+ }
705
+ if (timedOut) return { state: "could-not-look" };
706
+ return {
707
+ state: "looked",
708
+ processes: FALLBACK_PORTS.filter((p) => acceptPort(p.port, excluded))
709
+ };
710
+ }
711
+ async function discoverListeningPorts(excludePorts = []) {
712
+ const processes = await discoverListeningProcesses(excludePorts);
713
+ return processes.map((p) => p.port);
714
+ }
715
+ function pidFromNetstat(stdout, port) {
716
+ for (const line of stdout.split("\n")) {
717
+ if (!line.includes("LISTEN")) continue;
718
+ const parts = line.trim().split(/\s+/);
719
+ if (!parts[3]?.endsWith(`.${port}`)) continue;
720
+ for (const token of parts) {
721
+ const owner = token.match(/^\S+:(\d+)$/);
722
+ if (owner) {
723
+ const pid = Number(owner[1]);
724
+ if (pid > 0) return pid;
725
+ }
726
+ }
727
+ }
728
+ return null;
729
+ }
730
+ async function resolveListeningPid(port) {
731
+ if (!Number.isInteger(port) || port <= 0) return null;
732
+ try {
733
+ const { stdout } = await execGuarded("netstat -anv -p tcp 2>/dev/null", 8e3, {
734
+ maxBuffer: 16 * 1024 * 1024
735
+ });
736
+ const pid = pidFromNetstat(stdout, port);
737
+ if (pid !== null) return pid;
738
+ } catch {
739
+ }
740
+ try {
741
+ const { stdout } = await execGuarded(`ss -tlnp 2>/dev/null`, 8e3, {
742
+ maxBuffer: 16 * 1024 * 1024
743
+ });
744
+ for (const line of stdout.split("\n")) {
745
+ if (!new RegExp(`:${port}\\s`).test(line)) continue;
746
+ const pid = Number(line.match(/pid=(\d+)/)?.[1]);
747
+ if (pid > 0) return pid;
748
+ }
749
+ } catch {
750
+ }
751
+ return null;
752
+ }
753
+ var cwdByPid = /* @__PURE__ */ new Map();
754
+ async function resolveProcessCwd(pid) {
755
+ if (pid <= 0) return null;
756
+ const cached2 = cwdByPid.get(pid);
757
+ if (cached2) return cached2;
758
+ try {
759
+ const cwd = await (0, import_promises2.readlink)(`/proc/${pid}/cwd`);
760
+ if (cwd) {
761
+ cwdByPid.set(pid, cwd);
762
+ return cwd;
763
+ }
764
+ } catch {
765
+ }
766
+ try {
767
+ const { stdout } = await execGuarded(
768
+ `lsof -b -w -p ${pid} -a -d cwd -Fn 2>/dev/null`,
769
+ 8e3
770
+ );
771
+ for (const line of stdout.split("\n")) {
772
+ if (line.startsWith("n") && line.length > 1) {
773
+ const cwd = line.slice(1).trim();
774
+ if (cwd) {
775
+ cwdByPid.set(pid, cwd);
776
+ return cwd;
777
+ }
778
+ }
779
+ }
780
+ } catch {
781
+ }
782
+ return null;
783
+ }
784
+ function makeResult(hostname, port, framework, owner) {
785
+ return {
786
+ port,
787
+ framework,
788
+ bundleUrl: withRuntimeConfig(
789
+ port,
790
+ `${buildLoopbackProbeBaseUrl("http:", hostname, port)}/index.bundle?platform=ios&dev=true&hot=true&minify=false`,
791
+ owner.cwd
792
+ ),
793
+ hmrUrl: `${buildLoopbackProbeBaseUrl("ws:", hostname, port)}/hot`,
794
+ lastSeen: Date.now(),
795
+ ...owner
796
+ };
797
+ }
798
+ function withRuntimeConfig(port, bundleUrl, projectCwd) {
799
+ let physicalProjectCwd;
800
+ if (projectCwd) {
801
+ try {
802
+ physicalProjectCwd = (0, import_node_fs2.realpathSync)((0, import_node_path3.resolve)(projectCwd));
803
+ } catch {
804
+ }
805
+ }
806
+ const knownApps = physicalProjectCwd ? optionalDemoAppsSync().filter((app) => {
807
+ try {
808
+ return (0, import_node_fs2.realpathSync)((0, import_node_path3.resolve)(app.dir)) === physicalProjectCwd;
809
+ } catch {
810
+ return false;
811
+ }
812
+ }) : [];
813
+ const exactKnownApps = knownApps.filter((app) => app.preferredPort === port);
814
+ const knownApp = exactKnownApps.length === 1 ? exactKnownApps[0] : exactKnownApps.length === 0 && knownApps.length === 1 ? knownApps[0] : void 0;
815
+ const configured = knownApp?.runtimeConfig ? applyRNXConfigToUrl(bundleUrl, knownApp.runtimeConfig) : bundleUrl;
816
+ return normalizeNativeDevBundleUrl(configured);
817
+ }
818
+ function isDirectOneBundleUrl(bundleUrl) {
819
+ return bundleUrl.includes("/node_modules/one/metro-entry.bundle");
820
+ }
821
+ function safeParseManifest(body) {
822
+ try {
823
+ const parsed = JSON.parse(body);
824
+ return parsed && typeof parsed === "object" ? parsed : null;
825
+ } catch {
826
+ return null;
827
+ }
828
+ }
829
+ var localIconPathCache = /* @__PURE__ */ new Map();
830
+ var localIconProbeInFlight = /* @__PURE__ */ new Set();
831
+ function metroAssetPath(rawIcon) {
832
+ return `/assets/${rawIcon.replace(/^\.?\//, "")}`;
833
+ }
834
+ function staticAssetPath(rawIcon) {
835
+ return `/${rawIcon.replace(/^\.?\//, "")}`;
836
+ }
837
+ async function resolveLocalIconPath(hostname, port, rawIcon) {
838
+ const candidates = [metroAssetPath(rawIcon), staticAssetPath(rawIcon)];
839
+ for (const candidate of candidates) {
840
+ const res = await httpGet(hostname, port, candidate, "HEAD", ENRICH_TIMEOUT_MS);
841
+ if (res?.statusCode === 200) {
842
+ localIconPathCache.set(port, candidate);
843
+ portCache.delete(port);
844
+ return;
845
+ }
846
+ }
847
+ }
848
+ function applyManifest(result, manifestRes, buildIconProxyUrl) {
849
+ if (!manifestRes) return result;
850
+ try {
851
+ const manifest = JSON.parse(manifestRes.body);
852
+ const client = manifest?.extra?.expoClient || manifest?.extra || {};
853
+ if (client.name) result.projectName = client.name;
854
+ if (typeof client.primaryColor === "string") result.primaryColor = client.primaryColor;
855
+ if (client.ios?.bundleIdentifier) result.bundleId = client.ios.bundleIdentifier;
856
+ if (result.framework === "metro" && client.sdkVersion) result.framework = "expo";
857
+ const rawLaunchUrl = manifest?.launchAsset?.url;
858
+ const launchUrl = typeof rawLaunchUrl === "string" ? alignLoopbackBundleUrlWithProbe(
859
+ rawLaunchUrl,
860
+ buildLoopbackProbeBaseUrl("http:", manifestRes.hostname, result.port)
861
+ ) : rawLaunchUrl;
862
+ if (launchUrl && !result.patched && !isDirectOneBundleUrl(result.bundleUrl)) {
863
+ result.bundleUrl = withRuntimeConfig(result.port, launchUrl, result.cwd);
864
+ }
865
+ const localIcon = client.icon || client.ios?.icon;
866
+ const remoteIcon = client.iconUrl || client.ios?.iconUrl;
867
+ const rawIcon = localIcon || remoteIcon;
868
+ if (rawIcon) {
869
+ result.iconPath = rawIcon;
870
+ let resolvedIconUrl;
871
+ if (rawIcon.startsWith("http://") || rawIcon.startsWith("https://")) {
872
+ let isLoopback = false;
873
+ try {
874
+ const parsed = new URL(rawIcon);
875
+ isLoopback = isLoopbackHost(parsed.hostname);
876
+ } catch {
877
+ }
878
+ if (buildIconProxyUrl) {
879
+ if (isLoopback) {
880
+ resolvedIconUrl = buildIconProxyUrl(rawIcon);
881
+ }
882
+ } else {
883
+ resolvedIconUrl = rawIcon;
884
+ }
885
+ } else {
886
+ const base = buildLoopbackProbeBaseUrl("http:", manifestRes.hostname, result.port);
887
+ const assetPath = localIconPathCache.get(result.port) ?? metroAssetPath(rawIcon);
888
+ const localUrl = `${base}${assetPath}`;
889
+ resolvedIconUrl = buildIconProxyUrl ? buildIconProxyUrl(localUrl) : localUrl;
890
+ }
891
+ if (resolvedIconUrl) {
892
+ result.iconUrl = resolvedIconUrl;
893
+ }
894
+ }
895
+ } catch {
896
+ }
897
+ return result;
898
+ }
899
+ function __applyManifestForTests(result, manifestBody, buildIconProxyUrl) {
900
+ return applyManifest(
901
+ result,
902
+ {
903
+ statusCode: 200,
904
+ body: manifestBody,
905
+ hostname: new URL(result.bundleUrl).hostname
906
+ },
907
+ buildIconProxyUrl
908
+ );
909
+ }
910
+ var ENRICH_TIMEOUT_MS = 2e4;
911
+ var enrichmentCache = /* @__PURE__ */ new Map();
912
+ var enrichmentInFlight = /* @__PURE__ */ new Set();
913
+ function ensureLocalIconPathResolved(result) {
914
+ const rawIcon = result.iconPath;
915
+ if (!rawIcon) return;
916
+ if (rawIcon.startsWith("http://") || rawIcon.startsWith("https://")) return;
917
+ if (localIconPathCache.has(result.port)) return;
918
+ if (localIconProbeInFlight.has(result.port)) return;
919
+ localIconProbeInFlight.add(result.port);
920
+ const hostname = normalizeHostname(new URL(result.bundleUrl).hostname);
921
+ void resolveLocalIconPath(hostname, result.port, rawIcon).finally(
922
+ () => localIconProbeInFlight.delete(result.port)
923
+ );
924
+ }
925
+ function enrichWithManifest(result, buildIconProxyUrl) {
926
+ ensureLocalIconPathResolved(result);
927
+ if (result.projectName) return result;
928
+ const cached2 = enrichmentCache.get(result.port);
929
+ if (cached2) {
930
+ if (cached2.projectName) result.projectName = cached2.projectName;
931
+ if (cached2.iconUrl && !result.iconUrl) {
932
+ result.iconUrl = cached2.iconUrl;
933
+ result.iconPath = cached2.iconPath;
934
+ }
935
+ if (cached2.bundleId && !result.bundleId) result.bundleId = cached2.bundleId;
936
+ return result;
937
+ }
938
+ if (!enrichmentInFlight.has(result.port)) {
939
+ enrichmentInFlight.add(result.port);
940
+ void fetchManifestEnrichment(result, buildIconProxyUrl).finally(
941
+ () => enrichmentInFlight.delete(result.port)
942
+ );
943
+ }
944
+ return result;
945
+ }
946
+ async function fetchManifestEnrichment(result, buildIconProxyUrl) {
947
+ const hostname = normalizeHostname(new URL(result.bundleUrl).hostname);
948
+ const manifestRes = await httpGet(
949
+ hostname,
950
+ result.port,
951
+ "/",
952
+ "GET",
953
+ ENRICH_TIMEOUT_MS,
954
+ {
955
+ "expo-platform": "ios"
956
+ }
957
+ );
958
+ if (!manifestRes || manifestRes.statusCode !== 200) return;
959
+ const parsed = applyManifest(
960
+ {
961
+ port: result.port,
962
+ framework: "one",
963
+ bundleUrl: `${buildLoopbackProbeBaseUrl("http:", hostname, result.port)}/index.bundle`,
964
+ lastSeen: 0
965
+ },
966
+ manifestRes,
967
+ buildIconProxyUrl
968
+ );
969
+ if (!parsed.projectName && !parsed.iconUrl) return;
970
+ enrichmentCache.set(result.port, {
971
+ projectName: parsed.projectName,
972
+ iconUrl: parsed.iconUrl,
973
+ iconPath: parsed.iconPath,
974
+ bundleId: parsed.bundleId
975
+ });
976
+ portCache.delete(result.port);
977
+ }
978
+ var knownNonPatched = /* @__PURE__ */ new Set();
979
+ var knownNonExpo = /* @__PURE__ */ new Set();
980
+ var knownOne = /* @__PURE__ */ new Set();
981
+ async function probePort(port, buildIconProxyUrl, listeningProcess) {
982
+ await loadOptionalDemoApps();
983
+ const probeHostname = await tcpPing(port);
984
+ if (!probeHostname) return null;
985
+ const suppliedPid = listeningProcess?.pid;
986
+ const ownerPid = suppliedPid && suppliedPid > 0 ? suppliedPid : await resolveListeningPid(port);
987
+ const ownerCwd = ownerPid ? await resolveProcessCwd(ownerPid) : null;
988
+ const owner = {
989
+ ...ownerPid ? { pid: ownerPid } : {},
990
+ ...ownerCwd ? { cwd: ownerCwd } : {}
991
+ };
992
+ const onePath = `/node_modules/one/metro-entry.bundle?platform=ios&dev=true`;
993
+ const [sootsimRes, statusRes, manifestRes, expoRes] = await Promise.all([
994
+ knownNonPatched.has(port) ? Promise.resolve(null) : httpGet(probeHostname, port, "/__soot/"),
995
+ httpGet(probeHostname, port, "/status"),
996
+ knownOne.has(port) ? Promise.resolve(null) : httpGet(probeHostname, port, "/", "GET", MANIFEST_TIMEOUT_MS, {
997
+ "expo-platform": "ios"
998
+ }),
999
+ knownNonExpo.has(port) ? Promise.resolve(null) : httpGet(probeHostname, port, "/_expo/status")
1000
+ ]);
1001
+ if (expoRes && expoRes.statusCode === 200) {
1002
+ knownNonExpo.delete(port);
1003
+ } else if (!knownNonExpo.has(port)) {
1004
+ knownNonExpo.add(port);
1005
+ }
1006
+ const manifestParsed = manifestRes ? safeParseManifest(manifestRes.body) : null;
1007
+ const manifestLaunchUrl = typeof manifestParsed?.launchAsset?.url === "string" ? manifestParsed.launchAsset.url : null;
1008
+ const manifestClient = manifestParsed?.extra?.expoClient || manifestParsed?.extra || {};
1009
+ const manifestState = !manifestRes ? "no-answer" : manifestParsed && (manifestLaunchUrl || typeof manifestClient.name === "string") ? "resolved" : "no-manifest";
1010
+ if (manifestState === "resolved") {
1011
+ knownNonPatched.add(port);
1012
+ const launchUrl = manifestLaunchUrl || `${buildLoopbackProbeBaseUrl("http:", probeHostname, port)}/index.bundle?platform=ios&dev=true&hot=true&minify=false`;
1013
+ const framework = launchUrl.includes(
1014
+ "/one/metro-entry.bundle"
1015
+ ) ? "one" : "expo";
1016
+ return applyManifest(
1017
+ {
1018
+ port,
1019
+ framework,
1020
+ bundleUrl: withRuntimeConfig(port, launchUrl, owner.cwd),
1021
+ hmrUrl: `${buildLoopbackProbeBaseUrl("ws:", probeHostname, port)}/hot`,
1022
+ lastSeen: Date.now(),
1023
+ ...owner
1024
+ },
1025
+ manifestRes,
1026
+ buildIconProxyUrl
1027
+ );
1028
+ }
1029
+ if (statusRes && statusRes.body.includes("packager-status:running")) {
1030
+ knownNonPatched.add(port);
1031
+ const result = makeResult(
1032
+ probeHostname,
1033
+ port,
1034
+ expoRes && expoRes.statusCode === 200 ? "expo" : "metro",
1035
+ owner
1036
+ );
1037
+ if (manifestState === "no-answer") result.bundleUrlProvisional = true;
1038
+ return enrichWithManifest(
1039
+ applyManifest(result, manifestRes, buildIconProxyUrl),
1040
+ buildIconProxyUrl
1041
+ );
1042
+ }
1043
+ if (sootsimRes && sootsimRes.statusCode === 200 && sootsimRes.body.includes("sootsim-patched")) {
1044
+ knownNonPatched.delete(port);
1045
+ return enrichWithManifest(
1046
+ applyManifest(
1047
+ {
1048
+ port,
1049
+ framework: "one",
1050
+ bundleUrl: withRuntimeConfig(
1051
+ port,
1052
+ `${buildLoopbackProbeBaseUrl("http:", probeHostname, port)}/__soot/bundle.js`,
1053
+ owner.cwd
1054
+ ),
1055
+ hmrUrl: `${buildLoopbackProbeBaseUrl("ws:", probeHostname, port)}/hot`,
1056
+ lastSeen: Date.now(),
1057
+ patched: true,
1058
+ ...owner
1059
+ },
1060
+ manifestRes,
1061
+ buildIconProxyUrl
1062
+ ),
1063
+ buildIconProxyUrl
1064
+ );
1065
+ }
1066
+ const looksLikeMetroPackager = statusRes && statusRes.statusCode === 200 || expoRes && expoRes.statusCode === 200 || manifestRes && manifestRes.statusCode === 200 && manifestParsed != null;
1067
+ if (looksLikeMetroPackager) {
1068
+ return null;
1069
+ }
1070
+ const oneRes = await httpGet(probeHostname, port, onePath, "HEAD");
1071
+ if (oneRes && oneRes.statusCode > 0 && oneRes.statusCode < 400 && /application\/javascript/i.test(oneRes.contentType || "")) {
1072
+ knownNonPatched.add(port);
1073
+ knownOne.add(port);
1074
+ return enrichWithManifest(
1075
+ applyManifest(
1076
+ {
1077
+ port,
1078
+ framework: "one",
1079
+ bundleUrl: withRuntimeConfig(
1080
+ port,
1081
+ `${buildLoopbackProbeBaseUrl("http:", probeHostname, port)}${onePath}&minify=false`,
1082
+ owner.cwd
1083
+ ),
1084
+ hmrUrl: `${buildLoopbackProbeBaseUrl("ws:", probeHostname, port)}/hot`,
1085
+ lastSeen: Date.now(),
1086
+ ...owner
1087
+ },
1088
+ manifestRes,
1089
+ buildIconProxyUrl
1090
+ ),
1091
+ buildIconProxyUrl
1092
+ );
1093
+ }
1094
+ knownNonPatched.add(port);
1095
+ return null;
1096
+ }
1097
+ function isSootSimSelfServer(server) {
1098
+ const bundleId = server.bundleId?.trim().toLowerCase();
1099
+ if (bundleId?.startsWith("dev.sootsim.")) return true;
1100
+ return false;
1101
+ }
1102
+ var __isSootSimSelfServerForTests = isSootSimSelfServer;
1103
+ var portCache = /* @__PURE__ */ new Map();
1104
+ var NEGATIVE_CACHE_TTL_MS = 3e4;
1105
+ var WEAK_RESULT_CACHE_TTL_MS = 1500;
1106
+ function isWeakCachedResult(result) {
1107
+ if (!result) return true;
1108
+ if (result.framework === "metro" || result.framework === "unknown") return true;
1109
+ return false;
1110
+ }
1111
+ function hasCurrentRuntimeConfig(result) {
1112
+ if (!result) return true;
1113
+ return withRuntimeConfig(result.port, result.bundleUrl, result.cwd) === result.bundleUrl;
1114
+ }
1115
+ function __shouldReuseScannerCacheEntry(entry, pid, now = Date.now()) {
1116
+ if (pid === 0) return false;
1117
+ if (entry.pid !== pid) return false;
1118
+ if (!hasCurrentRuntimeConfig(entry.result)) return false;
1119
+ const ageMs = now - entry.cachedAt;
1120
+ if (entry.result === null && ageMs >= NEGATIVE_CACHE_TTL_MS) return false;
1121
+ if (isWeakCachedResult(entry.result) && ageMs >= WEAK_RESULT_CACHE_TTL_MS) return false;
1122
+ return true;
1123
+ }
1124
+ function __resetScannerCache() {
1125
+ portCache.clear();
1126
+ knownNonPatched.clear();
1127
+ knownNonExpo.clear();
1128
+ knownOne.clear();
1129
+ enrichmentCache.clear();
1130
+ enrichmentInFlight.clear();
1131
+ __resetAppSettingsBundleCacheForTests();
1132
+ }
1133
+ async function attachAppSettingsBundle(result, projectRoot) {
1134
+ const settingsBundle = await readAppSettingsBundle(projectRoot);
1135
+ if (settingsBundle) {
1136
+ result.settingsBundle = settingsBundle;
1137
+ result.settingsStorageScopeUrl = result.bundleUrl;
1138
+ } else {
1139
+ delete result.settingsBundle;
1140
+ delete result.settingsStorageScopeUrl;
1141
+ }
1142
+ }
1143
+ var __attachAppSettingsBundleForTests = attachAppSettingsBundle;
1144
+ async function scanDevServers(opts = {}) {
1145
+ await loadOptionalDemoApps();
1146
+ const scan = await scanListeningProcesses(opts.excludePorts);
1147
+ if (scan.state === "could-not-look") throw new DevServerScanUnavailableError();
1148
+ const processes = scan.processes;
1149
+ const currentPorts = new Set(processes.map((p) => p.port));
1150
+ for (const p of [...portCache.keys()]) {
1151
+ if (!currentPorts.has(p)) portCache.delete(p);
1152
+ }
1153
+ for (const p of [...knownNonPatched]) {
1154
+ if (!currentPorts.has(p)) knownNonPatched.delete(p);
1155
+ }
1156
+ for (const p of [...knownNonExpo]) {
1157
+ if (!currentPorts.has(p)) knownNonExpo.delete(p);
1158
+ }
1159
+ for (const p of [...knownOne]) {
1160
+ if (!currentPorts.has(p)) knownOne.delete(p);
1161
+ }
1162
+ for (const p of [...enrichmentCache.keys()]) {
1163
+ if (!currentPorts.has(p)) enrichmentCache.delete(p);
1164
+ }
1165
+ for (const p of [...localIconPathCache.keys()]) {
1166
+ if (!currentPorts.has(p)) localIconPathCache.delete(p);
1167
+ }
1168
+ const results = [];
1169
+ const toProbe = [];
1170
+ for (const { port, pid } of processes) {
1171
+ const cached2 = portCache.get(port);
1172
+ if (cached2 && __shouldReuseScannerCacheEntry(cached2, pid)) {
1173
+ if (cached2.result) results.push(cached2.result);
1174
+ continue;
1175
+ }
1176
+ if (cached2 && cached2.pid !== pid) {
1177
+ knownNonPatched.delete(port);
1178
+ knownNonExpo.delete(port);
1179
+ knownOne.delete(port);
1180
+ enrichmentCache.delete(port);
1181
+ localIconPathCache.delete(port);
1182
+ }
1183
+ toProbe.push({ port, pid });
1184
+ }
1185
+ if (toProbe.length > 0) {
1186
+ const probed = await Promise.all(
1187
+ toProbe.map((p) => probePort(p.port, opts.buildIconProxyUrl, p))
1188
+ );
1189
+ probed.forEach((result, i) => {
1190
+ const { port, pid } = toProbe[i];
1191
+ if (pid !== 0) portCache.set(port, { pid, result, cachedAt: Date.now() });
1192
+ if (result) results.push(result);
1193
+ });
1194
+ }
1195
+ const pidByPort = /* @__PURE__ */ new Map();
1196
+ for (const { port, pid } of processes) {
1197
+ if (pid > 0) pidByPort.set(port, pid);
1198
+ }
1199
+ await Promise.all(
1200
+ results.map(async (result) => {
1201
+ const pid = pidByPort.get(result.port);
1202
+ if (!pid) return;
1203
+ result.pid = pid;
1204
+ const cwd = await resolveProcessCwd(pid);
1205
+ if (!cwd) return;
1206
+ result.cwd = cwd;
1207
+ await attachAppSettingsBundle(result, cwd);
1208
+ })
1209
+ );
1210
+ const livePids = new Set(pidByPort.values());
1211
+ for (const pid of [...cwdByPid.keys()]) {
1212
+ if (!livePids.has(pid)) cwdByPid.delete(pid);
1213
+ }
1214
+ return results.filter((r) => !isSootSimSelfServer(r));
1215
+ }
1216
+ // Annotate the CommonJS export names for ESM import in node:
1217
+ 0 && (module.exports = {
1218
+ DevServerScanUnavailableError,
1219
+ __applyManifestForTests,
1220
+ __attachAppSettingsBundleForTests,
1221
+ __isSootSimSelfServerForTests,
1222
+ __resetScannerCache,
1223
+ __shouldReuseScannerCacheEntry,
1224
+ discoverListeningPorts,
1225
+ discoverListeningProcesses,
1226
+ pidFromNetstat,
1227
+ probePort,
1228
+ resolveListeningPid,
1229
+ resolveProcessCwd,
1230
+ scanDevServers,
1231
+ scanListeningProcesses
1232
+ });