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,51 @@
|
|
|
1
|
+
// jest preset for running existing detox suites against sootsim.
|
|
2
|
+
//
|
|
3
|
+
// users drop `preset: 'sootsim/detox/jest-preset'` into their jest config
|
|
4
|
+
// (or `sootsim-detox.config.cjs`) and their `import { by, device, element,
|
|
5
|
+
// expect, waitFor } from 'detox'` calls resolve to the sootsim driver.
|
|
6
|
+
|
|
7
|
+
const path = require('path')
|
|
8
|
+
|
|
9
|
+
// resolve the published driver entry so the mapping works from any cwd.
|
|
10
|
+
// `require.resolve('sootsim/detox')` honours the subpath export in the
|
|
11
|
+
// sootsim package.json.
|
|
12
|
+
const DRIVER_ENTRY = require.resolve('rnxsim/detox')
|
|
13
|
+
const PACKAGE_ROOT = path.dirname(require.resolve('rnxsim/package.json'))
|
|
14
|
+
|
|
15
|
+
/** @type {import('@jest/types').Config.InitialOptions} */
|
|
16
|
+
module.exports = {
|
|
17
|
+
testTimeout: 180000,
|
|
18
|
+
maxWorkers: 1,
|
|
19
|
+
watchman: false,
|
|
20
|
+
forceExit: true,
|
|
21
|
+
verbose: true,
|
|
22
|
+
testEnvironment: 'node',
|
|
23
|
+
setupFilesAfterEnv: [path.join(PACKAGE_ROOT, 'detox', 'jest-setup-after-env.cjs')],
|
|
24
|
+
transform: {
|
|
25
|
+
'^.+\\.tsx?$': [
|
|
26
|
+
'ts-jest',
|
|
27
|
+
{
|
|
28
|
+
isolatedModules: true,
|
|
29
|
+
tsconfig: {
|
|
30
|
+
module: 'commonjs',
|
|
31
|
+
target: 'es2020',
|
|
32
|
+
esModuleInterop: true,
|
|
33
|
+
jsx: 'react-jsx',
|
|
34
|
+
strict: false,
|
|
35
|
+
skipLibCheck: true,
|
|
36
|
+
moduleResolution: 'node',
|
|
37
|
+
allowJs: true,
|
|
38
|
+
resolveJsonModule: true,
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
moduleNameMapper: {
|
|
44
|
+
'^detox$': DRIVER_ENTRY,
|
|
45
|
+
// shared utils some external detox suites import relatively.
|
|
46
|
+
'^\\.\\./utils/navigation$': path.join(PACKAGE_ROOT, 'detox', 'navigation.ts'),
|
|
47
|
+
'^\\.\\./utils/colors$': path.join(PACKAGE_ROOT, 'detox', 'colors.ts'),
|
|
48
|
+
'^\\./(utils/navigation)$': path.join(PACKAGE_ROOT, 'detox', 'navigation.ts'),
|
|
49
|
+
'^\\./(utils/colors)$': path.join(PACKAGE_ROOT, 'detox', 'colors.ts'),
|
|
50
|
+
},
|
|
51
|
+
}
|
|
@@ -0,0 +1,223 @@
|
|
|
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 __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// src/dev-bundle-resolution.ts
|
|
23
|
+
var dev_bundle_resolution_exports = {};
|
|
24
|
+
__export(dev_bundle_resolution_exports, {
|
|
25
|
+
DEFAULT_TEST_DRIVE_PORT: () => DEFAULT_TEST_DRIVE_PORT,
|
|
26
|
+
inferManifestFramework: () => inferManifestFramework,
|
|
27
|
+
probePortBundle: () => probePortBundle,
|
|
28
|
+
resolveConnectionInput: () => resolveConnectionInput
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(dev_bundle_resolution_exports);
|
|
31
|
+
|
|
32
|
+
// src/backend-origin.ts
|
|
33
|
+
function normalizeHostname(hostname) {
|
|
34
|
+
return hostname.replace(/^\[|\]$/g, "").toLowerCase();
|
|
35
|
+
}
|
|
36
|
+
function isLoopbackHost(hostname) {
|
|
37
|
+
const normalized = normalizeHostname(hostname);
|
|
38
|
+
return normalized === "localhost" || normalized.endsWith(".localhost") || normalized === "0.0.0.0" || normalized === "::1" || /^127(?:\.\d{1,3}){3}$/.test(normalized);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// src/native-dev-bundle-url.ts
|
|
42
|
+
var METRO_BUNDLE_PATH = "/index.bundle?platform=ios&dev=true&hot=true&minify=false";
|
|
43
|
+
function isAbsoluteHttpUrl(url) {
|
|
44
|
+
return /^https?:\/\//i.test(url);
|
|
45
|
+
}
|
|
46
|
+
function isNativeDevBundlePath(pathname) {
|
|
47
|
+
return pathname.endsWith(".bundle");
|
|
48
|
+
}
|
|
49
|
+
function applyPreviewProdBundle(parsed) {
|
|
50
|
+
if (!process.env.SOOTSIM_PREVIEW_PROD_BUNDLE) return;
|
|
51
|
+
parsed.searchParams.set("dev", "false");
|
|
52
|
+
parsed.searchParams.set("minify", "true");
|
|
53
|
+
if (parsed.searchParams.has("hot")) parsed.searchParams.set("hot", "false");
|
|
54
|
+
}
|
|
55
|
+
function normalizeNativeDevBundleUrl(bundleUrl) {
|
|
56
|
+
try {
|
|
57
|
+
const isAbsolute = isAbsoluteHttpUrl(bundleUrl);
|
|
58
|
+
const parsed = new URL(bundleUrl, "http://sootsim.local");
|
|
59
|
+
parsed.pathname = parsed.pathname.replace(/\.\.bundle$/, ".bundle");
|
|
60
|
+
if (!isNativeDevBundlePath(parsed.pathname)) return bundleUrl;
|
|
61
|
+
parsed.searchParams.delete("transform.bytecode");
|
|
62
|
+
if (parsed.searchParams.get("lazy") === "true") {
|
|
63
|
+
parsed.searchParams.set("lazy", "false");
|
|
64
|
+
}
|
|
65
|
+
applyPreviewProdBundle(parsed);
|
|
66
|
+
if (isAbsolute) return parsed.toString();
|
|
67
|
+
return `${parsed.pathname}${parsed.search}${parsed.hash}`;
|
|
68
|
+
} catch {
|
|
69
|
+
return bundleUrl;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// src/dev-bundle-resolution.ts
|
|
74
|
+
var DEFAULT_TEST_DRIVE_PORT = 8081;
|
|
75
|
+
function buildUnresolvedTargetError(targetLabel) {
|
|
76
|
+
return new Error(
|
|
77
|
+
`could not resolve a native bundle for ${targetLabel}. pass an explicit bundle URL or open Connect and choose the app there.`
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
function inferManifestFramework(launchUrl, sdkVersion) {
|
|
81
|
+
if (launchUrl?.includes("/one/metro-entry.bundle")) return "one";
|
|
82
|
+
if (typeof sdkVersion === "string" && sdkVersion) return "expo";
|
|
83
|
+
return "unknown";
|
|
84
|
+
}
|
|
85
|
+
function buildBaseUrl(protocol, host, port) {
|
|
86
|
+
return `${protocol}//${host}:${port}`;
|
|
87
|
+
}
|
|
88
|
+
function shouldProxyLoopbackProbe(targetUrl) {
|
|
89
|
+
if (typeof window === "undefined") return false;
|
|
90
|
+
try {
|
|
91
|
+
const parsed = new URL(targetUrl);
|
|
92
|
+
return isLoopbackHost(parsed.hostname) && isLoopbackHost(window.location.hostname) && parsed.origin !== window.location.origin;
|
|
93
|
+
} catch {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
async function fetchDevProbe(targetUrl, init) {
|
|
98
|
+
const requestInit = {
|
|
99
|
+
...init,
|
|
100
|
+
cache: init?.cache ?? "no-store"
|
|
101
|
+
};
|
|
102
|
+
if (!shouldProxyLoopbackProbe(targetUrl)) {
|
|
103
|
+
return fetch(targetUrl, requestInit);
|
|
104
|
+
}
|
|
105
|
+
return fetch(`/__fetch-proxy?url=${encodeURIComponent(targetUrl)}`, requestInit);
|
|
106
|
+
}
|
|
107
|
+
function getDefaultPortForProtocol(protocol) {
|
|
108
|
+
return protocol === "https:" ? 443 : 80;
|
|
109
|
+
}
|
|
110
|
+
function isBaseServerUrl(url) {
|
|
111
|
+
const path = url.pathname || "/";
|
|
112
|
+
return (path === "/" || path === "") && !url.search && !url.hash;
|
|
113
|
+
}
|
|
114
|
+
async function resolvePortViaServerScan(port) {
|
|
115
|
+
try {
|
|
116
|
+
const res = await fetch("/__server-scan", { cache: "no-store" });
|
|
117
|
+
if (!res.ok) return null;
|
|
118
|
+
if (!(res.headers.get("content-type") || "").toLowerCase().includes("json"))
|
|
119
|
+
return null;
|
|
120
|
+
const servers = await res.json();
|
|
121
|
+
if (!Array.isArray(servers)) return null;
|
|
122
|
+
const match = servers.find(
|
|
123
|
+
(s) => !!s && typeof s === "object" && s.port === port && typeof s.bundleUrl === "string"
|
|
124
|
+
);
|
|
125
|
+
if (!match) return null;
|
|
126
|
+
return {
|
|
127
|
+
// normalize exactly like the manifest-probe branch below — the scan
|
|
128
|
+
// returns metro's raw launchAsset url (lazy=true for code-split one/vxrn
|
|
129
|
+
// apps), but sootsim loads ONE self-contained bundle into the tenant
|
|
130
|
+
// worker, so a deferred React.lazy chunk throws "Requiring unknown module
|
|
131
|
+
// <id>". normalizeNativeDevBundleUrl forces lazy=false + strips bytecode.
|
|
132
|
+
bundleUrl: normalizeNativeDevBundleUrl(match.bundleUrl),
|
|
133
|
+
port,
|
|
134
|
+
framework: typeof match.framework === "string" ? match.framework : "unknown",
|
|
135
|
+
projectName: typeof match.projectName === "string" ? match.projectName : void 0
|
|
136
|
+
};
|
|
137
|
+
} catch {
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
async function probeBaseUrlBundle(baseUrl, port) {
|
|
142
|
+
const normalizedBaseUrl = baseUrl.replace(/\/+$/, "");
|
|
143
|
+
try {
|
|
144
|
+
if (isLoopbackHost(new URL(normalizedBaseUrl).hostname)) {
|
|
145
|
+
const viaScan = await resolvePortViaServerScan(port);
|
|
146
|
+
if (viaScan) return viaScan;
|
|
147
|
+
}
|
|
148
|
+
} catch {
|
|
149
|
+
}
|
|
150
|
+
try {
|
|
151
|
+
const manifestRes = await fetchDevProbe(`${normalizedBaseUrl}/`, {
|
|
152
|
+
headers: { "expo-platform": "ios" }
|
|
153
|
+
});
|
|
154
|
+
if (manifestRes.ok) {
|
|
155
|
+
const manifest = await manifestRes.json();
|
|
156
|
+
const client = manifest?.extra?.expoClient || manifest?.extra || {};
|
|
157
|
+
const launchUrl = typeof manifest?.launchAsset?.url === "string" ? manifest.launchAsset.url : void 0;
|
|
158
|
+
if (launchUrl || client.name) {
|
|
159
|
+
return {
|
|
160
|
+
bundleUrl: normalizeNativeDevBundleUrl(
|
|
161
|
+
launchUrl || `${normalizedBaseUrl}${METRO_BUNDLE_PATH}`
|
|
162
|
+
),
|
|
163
|
+
port,
|
|
164
|
+
framework: inferManifestFramework(launchUrl, client.sdkVersion),
|
|
165
|
+
projectName: client.name
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
} catch {
|
|
170
|
+
}
|
|
171
|
+
try {
|
|
172
|
+
const statusRes = await fetchDevProbe(`${normalizedBaseUrl}/status`);
|
|
173
|
+
if (statusRes.ok) {
|
|
174
|
+
const text = await statusRes.text();
|
|
175
|
+
if (text.includes("packager-status:running")) {
|
|
176
|
+
return {
|
|
177
|
+
bundleUrl: `${normalizedBaseUrl}${METRO_BUNDLE_PATH}`,
|
|
178
|
+
port,
|
|
179
|
+
framework: "metro"
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
} catch {
|
|
184
|
+
}
|
|
185
|
+
return null;
|
|
186
|
+
}
|
|
187
|
+
async function probePortBundle(port) {
|
|
188
|
+
return probeBaseUrlBundle(buildBaseUrl("http:", "localhost", port), port);
|
|
189
|
+
}
|
|
190
|
+
async function resolveConnectionInput(input) {
|
|
191
|
+
const trimmed = input.trim();
|
|
192
|
+
if (/^\d+$/.test(trimmed)) {
|
|
193
|
+
const port2 = parseInt(trimmed, 10);
|
|
194
|
+
const resolved = await probePortBundle(port2);
|
|
195
|
+
if (resolved) return resolved;
|
|
196
|
+
throw buildUnresolvedTargetError(`localhost:${port2}`);
|
|
197
|
+
}
|
|
198
|
+
const bundleUrl = trimmed.startsWith("http") ? trimmed : `http://${trimmed}`;
|
|
199
|
+
let parsed;
|
|
200
|
+
try {
|
|
201
|
+
parsed = new URL(bundleUrl);
|
|
202
|
+
} catch {
|
|
203
|
+
throw new Error(
|
|
204
|
+
`could not parse "${input}". pass a dev-server port, a dev-server base URL, or a full bundle URL.`
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
const protocol = parsed.protocol || "http:";
|
|
208
|
+
const port = parsed.port ? parseInt(parsed.port, 10) : getDefaultPortForProtocol(protocol);
|
|
209
|
+
const baseUrl = buildBaseUrl(protocol, parsed.hostname, port);
|
|
210
|
+
if (isBaseServerUrl(parsed)) {
|
|
211
|
+
const resolved = await probeBaseUrlBundle(baseUrl, port);
|
|
212
|
+
if (resolved) return resolved;
|
|
213
|
+
throw buildUnresolvedTargetError(baseUrl);
|
|
214
|
+
}
|
|
215
|
+
return { bundleUrl: parsed.toString(), port, framework: "unknown" };
|
|
216
|
+
}
|
|
217
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
218
|
+
0 && (module.exports = {
|
|
219
|
+
DEFAULT_TEST_DRIVE_PORT,
|
|
220
|
+
inferManifestFramework,
|
|
221
|
+
probePortBundle,
|
|
222
|
+
resolveConnectionInput
|
|
223
|
+
});
|
|
@@ -0,0 +1,421 @@
|
|
|
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
|
+
// src/home-paths.ts
|
|
33
|
+
var home_paths_exports = {};
|
|
34
|
+
__export(home_paths_exports, {
|
|
35
|
+
ACTIVE_RUNTIME_FILE: () => ACTIVE_RUNTIME_FILE,
|
|
36
|
+
CONFIG_FILE: () => CONFIG_FILE,
|
|
37
|
+
DAEMON_HEARTBEAT_STALE_MS: () => DAEMON_HEARTBEAT_STALE_MS,
|
|
38
|
+
DAEMON_LOCKFILE: () => DAEMON_LOCKFILE,
|
|
39
|
+
DEV_BRIDGE_LOCKFILE: () => DEV_BRIDGE_LOCKFILE,
|
|
40
|
+
SOOTSIM_HOME_ENV: () => SOOTSIM_HOME_ENV,
|
|
41
|
+
activeRuntimeDir: () => activeRuntimeDir,
|
|
42
|
+
activeRuntimeFile: () => activeRuntimeFile,
|
|
43
|
+
cacheDir: () => cacheDir,
|
|
44
|
+
claimDaemonLockfile: () => claimDaemonLockfile,
|
|
45
|
+
configFilePath: () => configFilePath,
|
|
46
|
+
consumeRuntimeUpgradeNotice: () => consumeRuntimeUpgradeNotice,
|
|
47
|
+
daemonAppBundlePath: () => daemonAppBundlePath,
|
|
48
|
+
daemonAppDir: () => daemonAppDir,
|
|
49
|
+
daemonAppLauncherPath: () => daemonAppLauncherPath,
|
|
50
|
+
daemonLockfilePath: () => daemonLockfilePath,
|
|
51
|
+
devBridgeLockfilePath: () => devBridgeLockfilePath,
|
|
52
|
+
electronDir: () => electronDir,
|
|
53
|
+
electronUserDataDir: () => electronUserDataDir,
|
|
54
|
+
electronVersionDir: () => electronVersionDir,
|
|
55
|
+
ensureSootsimHome: () => ensureSootsimHome,
|
|
56
|
+
isDaemonLockfileFresh: () => isDaemonLockfileFresh,
|
|
57
|
+
isDevBridgeLockfileFresh: () => isDevBridgeLockfileFresh,
|
|
58
|
+
isDevWorkstation: () => isDevWorkstation,
|
|
59
|
+
isSootsimDevCheckout: () => isSootsimDevCheckout,
|
|
60
|
+
profilesDir: () => profilesDir,
|
|
61
|
+
readActiveRuntime: () => readActiveRuntime,
|
|
62
|
+
readDaemonLockfile: () => readDaemonLockfile,
|
|
63
|
+
readDevBridgeLockfile: () => readDevBridgeLockfile,
|
|
64
|
+
readLiveRuntimeVersions: () => readLiveRuntimeVersions,
|
|
65
|
+
readOrCreateAnonymousId: () => readOrCreateAnonymousId,
|
|
66
|
+
readPrivacyPreferences: () => readPrivacyPreferences,
|
|
67
|
+
readSharedConfig: () => readSharedConfig,
|
|
68
|
+
removeDaemonLockfile: () => removeDaemonLockfile,
|
|
69
|
+
removeDevBridgeLockfile: () => removeDevBridgeLockfile,
|
|
70
|
+
runtimeDir: () => runtimeDir,
|
|
71
|
+
runtimeUpgradeNoticePath: () => runtimeUpgradeNoticePath,
|
|
72
|
+
runtimesDir: () => runtimesDir,
|
|
73
|
+
shouldSkipPersistentDaemon: () => shouldSkipPersistentDaemon,
|
|
74
|
+
sootsimHomeDir: () => sootsimHomeDir,
|
|
75
|
+
writeActiveRuntime: () => writeActiveRuntime,
|
|
76
|
+
writeDaemonLockfile: () => writeDaemonLockfile,
|
|
77
|
+
writeDevBridgeLockfile: () => writeDevBridgeLockfile,
|
|
78
|
+
writePrivacyPreferences: () => writePrivacyPreferences,
|
|
79
|
+
writeRuntimeUpgradeNotice: () => writeRuntimeUpgradeNotice,
|
|
80
|
+
writeSharedConfig: () => writeSharedConfig
|
|
81
|
+
});
|
|
82
|
+
module.exports = __toCommonJS(home_paths_exports);
|
|
83
|
+
var import_node_crypto = require("node:crypto");
|
|
84
|
+
var import_node_fs = __toESM(require("node:fs"), 1);
|
|
85
|
+
var import_node_os = require("node:os");
|
|
86
|
+
var import_node_path = __toESM(require("node:path"), 1);
|
|
87
|
+
var SOOTSIM_HOME_ENV = "SOOTSIM_HOME";
|
|
88
|
+
var ACTIVE_RUNTIME_FILE = "active";
|
|
89
|
+
var DAEMON_LOCKFILE = "daemon.json";
|
|
90
|
+
var DEV_BRIDGE_LOCKFILE = "dev-bridge.json";
|
|
91
|
+
var CONFIG_FILE = "config.json";
|
|
92
|
+
var DAEMON_HEARTBEAT_STALE_MS = 3e4;
|
|
93
|
+
function sootsimHomeDir() {
|
|
94
|
+
const override = process.env[SOOTSIM_HOME_ENV];
|
|
95
|
+
if (override && override.length > 0) return import_node_path.default.resolve(override);
|
|
96
|
+
return import_node_path.default.join((0, import_node_os.homedir)(), ".sootsim");
|
|
97
|
+
}
|
|
98
|
+
function isSootsimDevCheckout() {
|
|
99
|
+
if (process.env.SOOTSIM_FORCE_DAEMON_INSTALL === "1") return false;
|
|
100
|
+
const env = process.env.SOOTSIM_DEV;
|
|
101
|
+
if (env === "1" || env === "true") return true;
|
|
102
|
+
if (env === "0" || env === "false") return false;
|
|
103
|
+
const argv1 = process.argv[1];
|
|
104
|
+
if (!argv1) return false;
|
|
105
|
+
try {
|
|
106
|
+
const real = import_node_fs.default.realpathSync(argv1);
|
|
107
|
+
return real.includes(`${import_node_path.default.sep}packages${import_node_path.default.sep}sootsim${import_node_path.default.sep}`);
|
|
108
|
+
} catch {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function isDevWorkstation() {
|
|
113
|
+
if (process.env.SOOTSIM_FORCE_DAEMON_INSTALL === "1") return false;
|
|
114
|
+
return process.env.IS_TAMAGUI_DEV === "1";
|
|
115
|
+
}
|
|
116
|
+
function shouldSkipPersistentDaemon() {
|
|
117
|
+
return isSootsimDevCheckout() || isDevWorkstation();
|
|
118
|
+
}
|
|
119
|
+
function runtimesDir() {
|
|
120
|
+
return import_node_path.default.join(sootsimHomeDir(), "runtimes");
|
|
121
|
+
}
|
|
122
|
+
function runtimeDir(version) {
|
|
123
|
+
return import_node_path.default.join(runtimesDir(), version);
|
|
124
|
+
}
|
|
125
|
+
function activeRuntimeFile() {
|
|
126
|
+
return import_node_path.default.join(runtimesDir(), ACTIVE_RUNTIME_FILE);
|
|
127
|
+
}
|
|
128
|
+
function electronDir() {
|
|
129
|
+
return import_node_path.default.join(sootsimHomeDir(), "electron");
|
|
130
|
+
}
|
|
131
|
+
function electronUserDataDir() {
|
|
132
|
+
return import_node_path.default.join(electronDir(), "userData");
|
|
133
|
+
}
|
|
134
|
+
function electronVersionDir(version) {
|
|
135
|
+
return import_node_path.default.join(electronDir(), version);
|
|
136
|
+
}
|
|
137
|
+
function profilesDir() {
|
|
138
|
+
return import_node_path.default.join(sootsimHomeDir(), "profiles");
|
|
139
|
+
}
|
|
140
|
+
function daemonAppDir() {
|
|
141
|
+
return import_node_path.default.join(sootsimHomeDir(), "daemon-app");
|
|
142
|
+
}
|
|
143
|
+
function daemonAppBundlePath() {
|
|
144
|
+
return import_node_path.default.join(daemonAppDir(), "SootSim Daemon.app");
|
|
145
|
+
}
|
|
146
|
+
function daemonAppLauncherPath() {
|
|
147
|
+
return import_node_path.default.join(daemonAppBundlePath(), "Contents", "MacOS", "sootsim-daemon");
|
|
148
|
+
}
|
|
149
|
+
function cacheDir() {
|
|
150
|
+
return import_node_path.default.join(sootsimHomeDir(), "cache");
|
|
151
|
+
}
|
|
152
|
+
function daemonLockfilePath() {
|
|
153
|
+
return import_node_path.default.join(sootsimHomeDir(), DAEMON_LOCKFILE);
|
|
154
|
+
}
|
|
155
|
+
function devBridgeLockfilePath() {
|
|
156
|
+
return import_node_path.default.join(sootsimHomeDir(), DEV_BRIDGE_LOCKFILE);
|
|
157
|
+
}
|
|
158
|
+
function configFilePath() {
|
|
159
|
+
return import_node_path.default.join(sootsimHomeDir(), CONFIG_FILE);
|
|
160
|
+
}
|
|
161
|
+
function readSharedConfig() {
|
|
162
|
+
try {
|
|
163
|
+
const raw = import_node_fs.default.readFileSync(configFilePath(), "utf8");
|
|
164
|
+
const parsed = JSON.parse(raw);
|
|
165
|
+
return parsed && typeof parsed === "object" ? parsed : {};
|
|
166
|
+
} catch {
|
|
167
|
+
return {};
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
function writeSharedConfig(patch) {
|
|
171
|
+
ensureSootsimHome();
|
|
172
|
+
const current = readSharedConfig();
|
|
173
|
+
const next = { ...current, ...patch };
|
|
174
|
+
if (patch.settings && typeof patch.settings === "object") {
|
|
175
|
+
next.settings = {
|
|
176
|
+
...current.settings && typeof current.settings === "object" ? current.settings : {},
|
|
177
|
+
...patch.settings
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
const tmp = `${configFilePath()}.tmp`;
|
|
181
|
+
import_node_fs.default.writeFileSync(tmp, `${JSON.stringify(next, null, 2)}
|
|
182
|
+
`, "utf8");
|
|
183
|
+
import_node_fs.default.renameSync(tmp, configFilePath());
|
|
184
|
+
return next;
|
|
185
|
+
}
|
|
186
|
+
function readPrivacyPreferences() {
|
|
187
|
+
const settings = readSharedConfig().settings;
|
|
188
|
+
const productAnalytics = settings?.productAnalytics;
|
|
189
|
+
const crashReports = settings?.crashReports;
|
|
190
|
+
return {
|
|
191
|
+
productAnalytics: typeof productAnalytics === "boolean" ? productAnalytics : true,
|
|
192
|
+
crashReports: typeof crashReports === "boolean" ? crashReports : true,
|
|
193
|
+
configured: typeof productAnalytics === "boolean" && typeof crashReports === "boolean"
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
function writePrivacyPreferences(preferences) {
|
|
197
|
+
writeSharedConfig({
|
|
198
|
+
settings: {
|
|
199
|
+
productAnalytics: preferences.productAnalytics,
|
|
200
|
+
crashReports: preferences.crashReports
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
function readOrCreateAnonymousId() {
|
|
205
|
+
const existing = readSharedConfig().anonymousId;
|
|
206
|
+
if (typeof existing === "string" && existing.trim()) return existing;
|
|
207
|
+
const created = `anon-cli-${(0, import_node_crypto.randomUUID)()}`;
|
|
208
|
+
writeSharedConfig({ anonymousId: created });
|
|
209
|
+
return created;
|
|
210
|
+
}
|
|
211
|
+
function runtimeUpgradeNoticePath() {
|
|
212
|
+
return import_node_path.default.join(sootsimHomeDir(), "runtime-upgraded.json");
|
|
213
|
+
}
|
|
214
|
+
function writeRuntimeUpgradeNotice(notice) {
|
|
215
|
+
ensureSootsimHome();
|
|
216
|
+
const tmp = `${runtimeUpgradeNoticePath()}.tmp`;
|
|
217
|
+
import_node_fs.default.writeFileSync(tmp, `${JSON.stringify(notice)}
|
|
218
|
+
`, "utf8");
|
|
219
|
+
import_node_fs.default.renameSync(tmp, runtimeUpgradeNoticePath());
|
|
220
|
+
}
|
|
221
|
+
function consumeRuntimeUpgradeNotice() {
|
|
222
|
+
try {
|
|
223
|
+
const raw = import_node_fs.default.readFileSync(runtimeUpgradeNoticePath(), "utf8");
|
|
224
|
+
import_node_fs.default.unlinkSync(runtimeUpgradeNoticePath());
|
|
225
|
+
const parsed = JSON.parse(raw);
|
|
226
|
+
if (typeof parsed?.to !== "string" || !parsed.to) return null;
|
|
227
|
+
return {
|
|
228
|
+
from: typeof parsed.from === "string" ? parsed.from : null,
|
|
229
|
+
to: parsed.to,
|
|
230
|
+
at: typeof parsed.at === "number" ? parsed.at : 0
|
|
231
|
+
};
|
|
232
|
+
} catch {
|
|
233
|
+
return null;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
function ensureSootsimHome() {
|
|
237
|
+
import_node_fs.default.mkdirSync(sootsimHomeDir(), { recursive: true });
|
|
238
|
+
import_node_fs.default.mkdirSync(runtimesDir(), { recursive: true });
|
|
239
|
+
import_node_fs.default.mkdirSync(electronDir(), { recursive: true });
|
|
240
|
+
import_node_fs.default.mkdirSync(profilesDir(), { recursive: true });
|
|
241
|
+
import_node_fs.default.mkdirSync(cacheDir(), { recursive: true });
|
|
242
|
+
}
|
|
243
|
+
function readActiveRuntime() {
|
|
244
|
+
try {
|
|
245
|
+
const value = import_node_fs.default.readFileSync(activeRuntimeFile(), "utf8").trim();
|
|
246
|
+
return value.length > 0 ? value : null;
|
|
247
|
+
} catch {
|
|
248
|
+
return null;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
function writeActiveRuntime(version) {
|
|
252
|
+
import_node_fs.default.mkdirSync(runtimesDir(), { recursive: true });
|
|
253
|
+
import_node_fs.default.writeFileSync(activeRuntimeFile(), `${version}
|
|
254
|
+
`, "utf8");
|
|
255
|
+
}
|
|
256
|
+
function activeRuntimeDir() {
|
|
257
|
+
const version = readActiveRuntime();
|
|
258
|
+
if (!version) return null;
|
|
259
|
+
const dir = runtimeDir(version);
|
|
260
|
+
try {
|
|
261
|
+
if (import_node_fs.default.statSync(dir).isDirectory()) return dir;
|
|
262
|
+
} catch {
|
|
263
|
+
}
|
|
264
|
+
return null;
|
|
265
|
+
}
|
|
266
|
+
var DAEMON_LOCKFILE_MAX_BYTES = 16 * 1024;
|
|
267
|
+
function readDaemonLockfile() {
|
|
268
|
+
try {
|
|
269
|
+
const fd = import_node_fs.default.openSync(daemonLockfilePath(), "r");
|
|
270
|
+
try {
|
|
271
|
+
const buf = Buffer.alloc(DAEMON_LOCKFILE_MAX_BYTES);
|
|
272
|
+
const bytesRead = import_node_fs.default.readSync(fd, buf, 0, DAEMON_LOCKFILE_MAX_BYTES, 0);
|
|
273
|
+
const raw = buf.subarray(0, bytesRead).toString("utf8");
|
|
274
|
+
const parsed = JSON.parse(raw);
|
|
275
|
+
if (parsed && parsed.schema === 1 && typeof parsed.pid === "number" && typeof parsed.bridgePort === "number" && typeof parsed.runtimePort === "number" && typeof parsed.startedAt === "number" && typeof parsed.heartbeatAt === "number" && (parsed.servedRuntimes === void 0 || Array.isArray(parsed.servedRuntimes) && parsed.servedRuntimes.every((version) => typeof version === "string"))) {
|
|
276
|
+
return parsed;
|
|
277
|
+
}
|
|
278
|
+
return null;
|
|
279
|
+
} finally {
|
|
280
|
+
import_node_fs.default.closeSync(fd);
|
|
281
|
+
}
|
|
282
|
+
} catch {
|
|
283
|
+
return null;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
function readDevBridgeLockfile() {
|
|
287
|
+
try {
|
|
288
|
+
const fd = import_node_fs.default.openSync(devBridgeLockfilePath(), "r");
|
|
289
|
+
try {
|
|
290
|
+
const buf = Buffer.alloc(DAEMON_LOCKFILE_MAX_BYTES);
|
|
291
|
+
const bytesRead = import_node_fs.default.readSync(fd, buf, 0, DAEMON_LOCKFILE_MAX_BYTES, 0);
|
|
292
|
+
const raw = buf.subarray(0, bytesRead).toString("utf8");
|
|
293
|
+
const parsed = JSON.parse(raw);
|
|
294
|
+
if (parsed && parsed.schema === 1 && parsed.source === "vite-dev" && typeof parsed.pid === "number" && typeof parsed.bridgePort === "number" && typeof parsed.runtimePort === "number" && typeof parsed.cwd === "string" && typeof parsed.startedAt === "number" && typeof parsed.heartbeatAt === "number" && (parsed.shellPort === void 0 || typeof parsed.shellPort === "number") && (parsed.servedRuntimes === void 0 || Array.isArray(parsed.servedRuntimes) && parsed.servedRuntimes.every((version) => typeof version === "string"))) {
|
|
295
|
+
return parsed;
|
|
296
|
+
}
|
|
297
|
+
return null;
|
|
298
|
+
} finally {
|
|
299
|
+
import_node_fs.default.closeSync(fd);
|
|
300
|
+
}
|
|
301
|
+
} catch {
|
|
302
|
+
return null;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
function isDaemonLockfileFresh(lock, now = Date.now()) {
|
|
306
|
+
if (!lock) return false;
|
|
307
|
+
if (now - lock.heartbeatAt > DAEMON_HEARTBEAT_STALE_MS) return false;
|
|
308
|
+
try {
|
|
309
|
+
process.kill(lock.pid, 0);
|
|
310
|
+
return true;
|
|
311
|
+
} catch {
|
|
312
|
+
return false;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
function isDevBridgeLockfileFresh(lock, now = Date.now()) {
|
|
316
|
+
if (!lock) return false;
|
|
317
|
+
if (now - lock.heartbeatAt > DAEMON_HEARTBEAT_STALE_MS) return false;
|
|
318
|
+
try {
|
|
319
|
+
process.kill(lock.pid, 0);
|
|
320
|
+
return true;
|
|
321
|
+
} catch {
|
|
322
|
+
return false;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
function readLiveRuntimeVersions() {
|
|
326
|
+
const versions = /* @__PURE__ */ new Set();
|
|
327
|
+
const daemon = readDaemonLockfile();
|
|
328
|
+
if (isDaemonLockfileFresh(daemon)) {
|
|
329
|
+
if (daemon.activeRuntime) versions.add(daemon.activeRuntime);
|
|
330
|
+
for (const version of daemon.servedRuntimes ?? []) versions.add(version);
|
|
331
|
+
}
|
|
332
|
+
const devBridge = readDevBridgeLockfile();
|
|
333
|
+
if (isDevBridgeLockfileFresh(devBridge)) {
|
|
334
|
+
for (const version of devBridge.servedRuntimes ?? []) versions.add(version);
|
|
335
|
+
}
|
|
336
|
+
return [...versions].sort();
|
|
337
|
+
}
|
|
338
|
+
function writeDaemonLockfile(data) {
|
|
339
|
+
ensureSootsimHome();
|
|
340
|
+
const tmp = `${daemonLockfilePath()}.tmp`;
|
|
341
|
+
import_node_fs.default.writeFileSync(tmp, `${JSON.stringify(data, null, 2)}
|
|
342
|
+
`, "utf8");
|
|
343
|
+
import_node_fs.default.renameSync(tmp, daemonLockfilePath());
|
|
344
|
+
}
|
|
345
|
+
function writeDevBridgeLockfile(data) {
|
|
346
|
+
ensureSootsimHome();
|
|
347
|
+
const tmp = `${devBridgeLockfilePath()}.tmp`;
|
|
348
|
+
import_node_fs.default.writeFileSync(tmp, `${JSON.stringify(data, null, 2)}
|
|
349
|
+
`, "utf8");
|
|
350
|
+
import_node_fs.default.renameSync(tmp, devBridgeLockfilePath());
|
|
351
|
+
}
|
|
352
|
+
function claimDaemonLockfile(data) {
|
|
353
|
+
ensureSootsimHome();
|
|
354
|
+
const existing = readDaemonLockfile();
|
|
355
|
+
if (existing && isDaemonLockfileFresh(existing) && existing.pid !== data.pid) {
|
|
356
|
+
return false;
|
|
357
|
+
}
|
|
358
|
+
writeDaemonLockfile(data);
|
|
359
|
+
return true;
|
|
360
|
+
}
|
|
361
|
+
function removeDaemonLockfile() {
|
|
362
|
+
try {
|
|
363
|
+
import_node_fs.default.unlinkSync(daemonLockfilePath());
|
|
364
|
+
} catch {
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
function removeDevBridgeLockfile() {
|
|
368
|
+
try {
|
|
369
|
+
import_node_fs.default.unlinkSync(devBridgeLockfilePath());
|
|
370
|
+
} catch {
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
374
|
+
0 && (module.exports = {
|
|
375
|
+
ACTIVE_RUNTIME_FILE,
|
|
376
|
+
CONFIG_FILE,
|
|
377
|
+
DAEMON_HEARTBEAT_STALE_MS,
|
|
378
|
+
DAEMON_LOCKFILE,
|
|
379
|
+
DEV_BRIDGE_LOCKFILE,
|
|
380
|
+
SOOTSIM_HOME_ENV,
|
|
381
|
+
activeRuntimeDir,
|
|
382
|
+
activeRuntimeFile,
|
|
383
|
+
cacheDir,
|
|
384
|
+
claimDaemonLockfile,
|
|
385
|
+
configFilePath,
|
|
386
|
+
consumeRuntimeUpgradeNotice,
|
|
387
|
+
daemonAppBundlePath,
|
|
388
|
+
daemonAppDir,
|
|
389
|
+
daemonAppLauncherPath,
|
|
390
|
+
daemonLockfilePath,
|
|
391
|
+
devBridgeLockfilePath,
|
|
392
|
+
electronDir,
|
|
393
|
+
electronUserDataDir,
|
|
394
|
+
electronVersionDir,
|
|
395
|
+
ensureSootsimHome,
|
|
396
|
+
isDaemonLockfileFresh,
|
|
397
|
+
isDevBridgeLockfileFresh,
|
|
398
|
+
isDevWorkstation,
|
|
399
|
+
isSootsimDevCheckout,
|
|
400
|
+
profilesDir,
|
|
401
|
+
readActiveRuntime,
|
|
402
|
+
readDaemonLockfile,
|
|
403
|
+
readDevBridgeLockfile,
|
|
404
|
+
readLiveRuntimeVersions,
|
|
405
|
+
readOrCreateAnonymousId,
|
|
406
|
+
readPrivacyPreferences,
|
|
407
|
+
readSharedConfig,
|
|
408
|
+
removeDaemonLockfile,
|
|
409
|
+
removeDevBridgeLockfile,
|
|
410
|
+
runtimeDir,
|
|
411
|
+
runtimeUpgradeNoticePath,
|
|
412
|
+
runtimesDir,
|
|
413
|
+
shouldSkipPersistentDaemon,
|
|
414
|
+
sootsimHomeDir,
|
|
415
|
+
writeActiveRuntime,
|
|
416
|
+
writeDaemonLockfile,
|
|
417
|
+
writeDevBridgeLockfile,
|
|
418
|
+
writePrivacyPreferences,
|
|
419
|
+
writeRuntimeUpgradeNotice,
|
|
420
|
+
writeSharedConfig
|
|
421
|
+
});
|