rnxsim 0.0.0 → 0.1.313
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-XZ2KTPCU.js +48 -0
- package/dist-cli/chunks/agent-wrapper-JJYYW2WH.js +17 -0
- package/dist-cli/chunks/app-fonts-IXRNQG6B.js +4 -0
- package/dist-cli/chunks/assert-54T5SK5F.js +49 -0
- package/dist-cli/chunks/auth-FI5UDI45.js +12 -0
- package/dist-cli/chunks/beta-JV6UKADW.js +4 -0
- package/dist-cli/chunks/camera-VL73YIKP.js +22 -0
- package/dist-cli/chunks/chunk-2D2UPBBR.js +4 -0
- package/dist-cli/chunks/chunk-2YR5BGA5.js +5 -0
- package/dist-cli/chunks/chunk-3NV2NCNX.js +4 -0
- package/dist-cli/chunks/chunk-46EUUFJ5.js +4 -0
- package/dist-cli/chunks/chunk-4NPPOV2N.js +5 -0
- package/dist-cli/chunks/chunk-5DHC6KHQ.js +7 -0
- package/dist-cli/chunks/chunk-5TEF3ET3.js +74 -0
- package/dist-cli/chunks/chunk-5TPRP5QT.js +4 -0
- package/dist-cli/chunks/chunk-5YJCOWCH.js +4 -0
- package/dist-cli/chunks/chunk-7GN3LVWB.js +4 -0
- package/dist-cli/chunks/chunk-BBULZ7CG.js +568 -0
- package/dist-cli/chunks/chunk-BTWORNNG.js +71 -0
- package/dist-cli/chunks/chunk-D4FFVGI5.js +5 -0
- package/dist-cli/chunks/chunk-DCEMHR2Y.js +4 -0
- package/dist-cli/chunks/chunk-DZS6WPUI.js +4 -0
- package/dist-cli/chunks/chunk-F5ZRSS3C.js +3 -0
- package/dist-cli/chunks/chunk-FSUYIVJ6.js +9 -0
- package/dist-cli/chunks/chunk-G2WW6L2C.js +23 -0
- package/dist-cli/chunks/chunk-GASE6UBA.js +4 -0
- package/dist-cli/chunks/chunk-GGRX24GF.js +142 -0
- package/dist-cli/chunks/chunk-HI5TFJWN.js +5 -0
- package/dist-cli/chunks/chunk-IJ5CAZZC.js +5 -0
- package/dist-cli/chunks/chunk-IJO63TDP.js +4 -0
- package/dist-cli/chunks/chunk-KTHV3RUS.js +26 -0
- package/dist-cli/chunks/chunk-LF2ZVT7O.js +6 -0
- package/dist-cli/chunks/chunk-MJRLLB4R.js +38 -0
- package/dist-cli/chunks/chunk-NFK7T35W.js +4 -0
- package/dist-cli/chunks/chunk-NMF2ZMZQ.js +15 -0
- package/dist-cli/chunks/chunk-OHAZNXLK.js +4 -0
- package/dist-cli/chunks/chunk-OVFJFXUD.js +101 -0
- package/dist-cli/chunks/chunk-OZSSI4WN.js +28 -0
- package/dist-cli/chunks/chunk-QKDWYITG.js +25 -0
- package/dist-cli/chunks/chunk-RSZWCKNT.js +30 -0
- package/dist-cli/chunks/chunk-RTN5C5RL.js +4 -0
- package/dist-cli/chunks/chunk-TIVZIMMW.js +4 -0
- package/dist-cli/chunks/chunk-TZFFR3SD.js +7 -0
- package/dist-cli/chunks/chunk-UC6U3MML.js +5 -0
- package/dist-cli/chunks/chunk-VFCMSYZK.js +6 -0
- package/dist-cli/chunks/chunk-VNQEB4L7.js +5 -0
- package/dist-cli/chunks/chunk-VZXWHRUZ.js +983 -0
- package/dist-cli/chunks/chunk-W6K4EFPH.js +107 -0
- package/dist-cli/chunks/chunk-WEXDAC74.js +4 -0
- package/dist-cli/chunks/chunk-WF3T4SVI.js +14 -0
- package/dist-cli/chunks/chunk-WINYQ44O.js +4 -0
- package/dist-cli/chunks/chunk-WMIIKMGK.js +10 -0
- package/dist-cli/chunks/chunk-WUSWBCWA.js +507 -0
- package/dist-cli/chunks/chunk-WWZIXIRD.js +4 -0
- package/dist-cli/chunks/chunk-XEVZYVIW.js +766 -0
- package/dist-cli/chunks/chunk-YDGQTMQL.js +4 -0
- package/dist-cli/chunks/chunk-YIFT42WN.js +4 -0
- package/dist-cli/chunks/chunk-ZMJD5GEC.js +125 -0
- package/dist-cli/chunks/cleanup-P27PA6JI.js +25 -0
- package/dist-cli/chunks/cli-version-WWLPBDQ7.js +4 -0
- package/dist-cli/chunks/compat-ZD65FED3.js +20 -0
- package/dist-cli/chunks/config-XMJRNM2A.js +13 -0
- package/dist-cli/chunks/control-KMIQT3QP.js +4 -0
- package/dist-cli/chunks/daemon-G2ME7NLB.js +4 -0
- package/dist-cli/chunks/debug-PT4HOP7N.js +200 -0
- package/dist-cli/chunks/desktop-S3FG72AK.js +31 -0
- package/dist-cli/chunks/detox-B3D4IFCN.js +52 -0
- package/dist-cli/chunks/device-XBNDSB2R.js +18 -0
- package/dist-cli/chunks/diagnose-HMQXJE5N.js +43 -0
- package/dist-cli/chunks/disk-cleanup-BLCZ5BSZ.js +4 -0
- package/dist-cli/chunks/drivers-LDECZGP2.js +4 -0
- package/dist-cli/chunks/film-BJGTBYZB.js +74 -0
- package/dist-cli/chunks/flow-UEQNVTU7.js +4 -0
- package/dist-cli/chunks/help-T5FYSVGB.js +4 -0
- package/dist-cli/chunks/hidden-runtime-alias-ANOYADHM.js +4 -0
- package/dist-cli/chunks/home-paths-GT3LFNOR.js +4 -0
- package/dist-cli/chunks/inspect-ZA6XF5LD.js +4 -0
- package/dist-cli/chunks/install-desktop-TIMUDHPL.js +4 -0
- package/dist-cli/chunks/login-FJ737MWG.js +28 -0
- package/dist-cli/chunks/logout-ZCNMMHMY.js +4 -0
- package/dist-cli/chunks/maestro-SZTNKLDF.js +104 -0
- package/dist-cli/chunks/maestro-generate-DCFAIZ4H.js +36 -0
- package/dist-cli/chunks/mode-GRMQCRXR.js +26 -0
- package/dist-cli/chunks/optional-demo-registry-W36EWFFB.js +4 -0
- package/dist-cli/chunks/perf-QYBAAUZG.js +48 -0
- package/dist-cli/chunks/permissions-3QCQ6VF4.js +13 -0
- package/dist-cli/chunks/record-QPPC2S4E.js +72 -0
- package/dist-cli/chunks/report-issue-7NMFP4HK.js +29 -0
- package/dist-cli/chunks/runtime-XOAXMSTU.js +4 -0
- package/dist-cli/chunks/screenshot-command-67AECJFB.js +159 -0
- package/dist-cli/chunks/screenshot-layers-ASWBYPJL.js +20 -0
- package/dist-cli/chunks/screenshots-capture-PXA3HFQK.js +42 -0
- package/dist-cli/chunks/serve-BI2NBAXG.js +44 -0
- package/dist-cli/chunks/setup-7DWPMRSB.js +32 -0
- package/dist-cli/chunks/skills-S3Y22TUA.js +50 -0
- package/dist-cli/chunks/storage-XUIMJWAJ.js +37 -0
- package/dist-cli/chunks/store-JTHEJLAZ.js +4 -0
- package/dist-cli/chunks/telemetry-ZYJGD2DB.js +4 -0
- package/dist-cli/chunks/timeline-TMPLQPSP.js +24 -0
- package/dist-cli/chunks/upgrade-7HDSIM7K.js +7 -0
- package/dist-cli/chunks/upload-GMSZPWM6.js +4 -0
- package/dist-cli/chunks/version-HOCHZ37L.js +6 -0
- package/dist-cli/chunks/web-DG3WBYD3.js +4 -0
- package/dist-cli/chunks/what-happened-XFVUTZR7.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 +23922 -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,513 @@
|
|
|
1
|
+
/*! rnx v0.1.313 | (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/index.ts
|
|
33
|
+
var src_exports = {};
|
|
34
|
+
__export(src_exports, {
|
|
35
|
+
DEFAULT_SOOTSIM_BRIDGE_PORT: () => DEFAULT_SOOTSIM_BRIDGE_PORT,
|
|
36
|
+
DEFAULT_SOOTSIM_BRIDGE_URL: () => DEFAULT_SOOTSIM_BRIDGE_URL,
|
|
37
|
+
DEFAULT_SOOTSIM_SHELL_URL: () => DEFAULT_SOOTSIM_SHELL_URL,
|
|
38
|
+
jumpToSourceBabelPlugin: () => sootsimJumpToSourceBabelPlugin,
|
|
39
|
+
metroPlugin: () => metro_plugin_default,
|
|
40
|
+
sootsimPlugin: () => sootsimPlugin
|
|
41
|
+
});
|
|
42
|
+
module.exports = __toCommonJS(src_exports);
|
|
43
|
+
|
|
44
|
+
// src/vite-plugin-one.ts
|
|
45
|
+
var import_fs2 = __toESM(require("fs"), 1);
|
|
46
|
+
var import_path2 = __toESM(require("path"), 1);
|
|
47
|
+
|
|
48
|
+
// src/bridge-constants.ts
|
|
49
|
+
var DEFAULT_SOOTSIM_BRIDGE_PORT = 7668;
|
|
50
|
+
var DEFAULT_SOOTSIM_BRIDGE_URL = `http://localhost:${DEFAULT_SOOTSIM_BRIDGE_PORT}/`;
|
|
51
|
+
|
|
52
|
+
// src/home-paths.ts
|
|
53
|
+
var import_node_fs = __toESM(require("node:fs"), 1);
|
|
54
|
+
var import_node_os = require("node:os");
|
|
55
|
+
var import_node_path = __toESM(require("node:path"), 1);
|
|
56
|
+
var SOOTSIM_HOME_ENV = "SOOTSIM_HOME";
|
|
57
|
+
var ACTIVE_RUNTIME_FILE = "active";
|
|
58
|
+
var DAEMON_LOCKFILE = "daemon.json";
|
|
59
|
+
var DAEMON_HEARTBEAT_STALE_MS = 3e4;
|
|
60
|
+
function sootsimHomeDir() {
|
|
61
|
+
const override = process.env[SOOTSIM_HOME_ENV];
|
|
62
|
+
if (override && override.length > 0) return import_node_path.default.resolve(override);
|
|
63
|
+
return import_node_path.default.join((0, import_node_os.homedir)(), ".sootsim");
|
|
64
|
+
}
|
|
65
|
+
function runtimesDir() {
|
|
66
|
+
return import_node_path.default.join(sootsimHomeDir(), "runtimes");
|
|
67
|
+
}
|
|
68
|
+
function runtimeDir(version) {
|
|
69
|
+
return import_node_path.default.join(runtimesDir(), version);
|
|
70
|
+
}
|
|
71
|
+
function activeRuntimeFile() {
|
|
72
|
+
return import_node_path.default.join(runtimesDir(), ACTIVE_RUNTIME_FILE);
|
|
73
|
+
}
|
|
74
|
+
function daemonLockfilePath() {
|
|
75
|
+
return import_node_path.default.join(sootsimHomeDir(), DAEMON_LOCKFILE);
|
|
76
|
+
}
|
|
77
|
+
function readActiveRuntime() {
|
|
78
|
+
try {
|
|
79
|
+
const value = import_node_fs.default.readFileSync(activeRuntimeFile(), "utf8").trim();
|
|
80
|
+
return value.length > 0 ? value : null;
|
|
81
|
+
} catch {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
var DAEMON_LOCKFILE_MAX_BYTES = 16 * 1024;
|
|
86
|
+
function readDaemonLockfile() {
|
|
87
|
+
try {
|
|
88
|
+
const fd = import_node_fs.default.openSync(daemonLockfilePath(), "r");
|
|
89
|
+
try {
|
|
90
|
+
const buf = Buffer.alloc(DAEMON_LOCKFILE_MAX_BYTES);
|
|
91
|
+
const bytesRead = import_node_fs.default.readSync(fd, buf, 0, DAEMON_LOCKFILE_MAX_BYTES, 0);
|
|
92
|
+
const raw = buf.subarray(0, bytesRead).toString("utf8");
|
|
93
|
+
const parsed = JSON.parse(raw);
|
|
94
|
+
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"))) {
|
|
95
|
+
return parsed;
|
|
96
|
+
}
|
|
97
|
+
return null;
|
|
98
|
+
} finally {
|
|
99
|
+
import_node_fs.default.closeSync(fd);
|
|
100
|
+
}
|
|
101
|
+
} catch {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
function isDaemonLockfileFresh(lock, now = Date.now()) {
|
|
106
|
+
if (!lock) return false;
|
|
107
|
+
if (now - lock.heartbeatAt > DAEMON_HEARTBEAT_STALE_MS) return false;
|
|
108
|
+
try {
|
|
109
|
+
process.kill(lock.pid, 0);
|
|
110
|
+
return true;
|
|
111
|
+
} catch {
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// src/runtime-assets.ts
|
|
117
|
+
var import_fs = __toESM(require("fs"), 1);
|
|
118
|
+
var import_path = __toESM(require("path"), 1);
|
|
119
|
+
var import_url = require("url");
|
|
120
|
+
|
|
121
|
+
// ../contrast-runtime-delivery/src/product.ts
|
|
122
|
+
function isValidRuntimeVersion(value) {
|
|
123
|
+
return value.length <= 100 && /^[0-9A-Za-z][0-9A-Za-z._+-]*$/.test(value);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// src/runtime-assets.ts
|
|
127
|
+
var SOOTSIM_RUNTIME_MISSING_MESSAGE = "[rnx] no engine runtime installed \u2014 run `rnxsim setup`, or `rnxsim runtime install`";
|
|
128
|
+
var _monorepoRootCache;
|
|
129
|
+
function findMonorepoRoot() {
|
|
130
|
+
if (_monorepoRootCache !== void 0) return _monorepoRootCache;
|
|
131
|
+
let dir = import_path.default.dirname((0, import_url.fileURLToPath)(__sootsim_import_meta_url));
|
|
132
|
+
for (let i = 0; i < 12 && dir !== import_path.default.dirname(dir); i++) {
|
|
133
|
+
if (import_fs.default.existsSync(import_path.default.join(dir, "packages/sootsim-engine/package.json")) && import_fs.default.existsSync(import_path.default.join(dir, "public/sootsim"))) {
|
|
134
|
+
_monorepoRootCache = dir;
|
|
135
|
+
return dir;
|
|
136
|
+
}
|
|
137
|
+
dir = import_path.default.dirname(dir);
|
|
138
|
+
}
|
|
139
|
+
_monorepoRootCache = null;
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
function resolveDevCheckoutRuntimeRoot() {
|
|
143
|
+
if (process.env.SOOTSIM_HOME && readActiveRuntime()) return null;
|
|
144
|
+
const root = findMonorepoRoot();
|
|
145
|
+
if (!root) return null;
|
|
146
|
+
const devBuild = import_path.default.join(root, "public/sootsim");
|
|
147
|
+
if (import_fs.default.existsSync(import_path.default.join(devBuild, "index.html")) && import_fs.default.existsSync(import_path.default.join(devBuild, "engine/index.html")) && import_fs.default.existsSync(import_path.default.join(devBuild, "engine-tenant/worker.js"))) {
|
|
148
|
+
return devBuild;
|
|
149
|
+
}
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
var MIME_TYPES = {
|
|
153
|
+
".js": "application/javascript",
|
|
154
|
+
".mjs": "application/javascript",
|
|
155
|
+
".css": "text/css",
|
|
156
|
+
".html": "text/html",
|
|
157
|
+
".wasm": "application/wasm",
|
|
158
|
+
".json": "application/json",
|
|
159
|
+
".jpg": "image/jpeg",
|
|
160
|
+
".jpeg": "image/jpeg",
|
|
161
|
+
".png": "image/png",
|
|
162
|
+
".svg": "image/svg+xml",
|
|
163
|
+
".webp": "image/webp",
|
|
164
|
+
".glb": "model/gltf-binary",
|
|
165
|
+
".ttf": "font/ttf",
|
|
166
|
+
".otf": "font/otf",
|
|
167
|
+
".woff": "font/woff",
|
|
168
|
+
".woff2": "font/woff2",
|
|
169
|
+
".mp3": "audio/mpeg",
|
|
170
|
+
".wav": "audio/wav"
|
|
171
|
+
};
|
|
172
|
+
var ROOT_RUNTIME_PATHS = [
|
|
173
|
+
"/assets/",
|
|
174
|
+
"/engine/",
|
|
175
|
+
"/engine-tenant/",
|
|
176
|
+
"/photos/",
|
|
177
|
+
"/three-mode/",
|
|
178
|
+
"/fonts/",
|
|
179
|
+
"/icons/",
|
|
180
|
+
"/sounds/",
|
|
181
|
+
"/spike/",
|
|
182
|
+
"/test-wallpaper.jpg",
|
|
183
|
+
"/preview-sw.js",
|
|
184
|
+
"/sootsim.svg"
|
|
185
|
+
];
|
|
186
|
+
function resolveActiveRuntimeRoot() {
|
|
187
|
+
const devRoot = resolveDevCheckoutRuntimeRoot();
|
|
188
|
+
if (devRoot) return devRoot;
|
|
189
|
+
const active = readActiveRuntime();
|
|
190
|
+
if (!active) return null;
|
|
191
|
+
const dir = runtimeDir(active);
|
|
192
|
+
if (!import_fs.default.existsSync(import_path.default.join(dir, "index.html"))) return null;
|
|
193
|
+
return dir;
|
|
194
|
+
}
|
|
195
|
+
var RUNTIME_VERSION_HOSTNAME_SUFFIX = ".runtime.localhost";
|
|
196
|
+
function isRuntimeVersionHostname(hostname) {
|
|
197
|
+
return hostname.toLowerCase().endsWith(RUNTIME_VERSION_HOSTNAME_SUFFIX);
|
|
198
|
+
}
|
|
199
|
+
function runtimeVersionFromHostname(hostname) {
|
|
200
|
+
if (!isRuntimeVersionHostname(hostname)) return null;
|
|
201
|
+
const labels = hostname.slice(0, -RUNTIME_VERSION_HOSTNAME_SUFFIX.length).split(".");
|
|
202
|
+
if (labels.length === 0 || labels.some((label) => !/^[0-9a-f]{1,60}$/i.test(label))) {
|
|
203
|
+
return null;
|
|
204
|
+
}
|
|
205
|
+
const encoded = labels.join("");
|
|
206
|
+
if (encoded.length % 2 !== 0) return null;
|
|
207
|
+
try {
|
|
208
|
+
const version = Buffer.from(encoded, "hex").toString("utf8");
|
|
209
|
+
return isValidRuntimeVersion(version) ? version : null;
|
|
210
|
+
} catch {
|
|
211
|
+
return null;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
function resolveInstalledRuntimeRoot(version) {
|
|
215
|
+
const dir = runtimeDir(version);
|
|
216
|
+
if (!import_fs.default.existsSync(import_path.default.join(dir, "index.html"))) return null;
|
|
217
|
+
return dir;
|
|
218
|
+
}
|
|
219
|
+
function resolveRuntimeRootForHostname(hostname) {
|
|
220
|
+
if (!isRuntimeVersionHostname(hostname)) return resolveActiveRuntimeRoot();
|
|
221
|
+
const version = runtimeVersionFromHostname(hostname);
|
|
222
|
+
return version ? resolveInstalledRuntimeRoot(version) : null;
|
|
223
|
+
}
|
|
224
|
+
function resolveRuntimeRootForRequestHost(host) {
|
|
225
|
+
if (!host) return resolveActiveRuntimeRoot();
|
|
226
|
+
try {
|
|
227
|
+
return resolveRuntimeRootForHostname(new URL(`http://${host}`).hostname);
|
|
228
|
+
} catch {
|
|
229
|
+
return null;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
function isRootRuntimeAssetPath(pathname) {
|
|
233
|
+
return ROOT_RUNTIME_PATHS.some((p) => pathname === p || pathname.startsWith(p));
|
|
234
|
+
}
|
|
235
|
+
function resolveRuntimeFilePath(runtimeRoot, pathname) {
|
|
236
|
+
if (!pathname.startsWith("/")) return null;
|
|
237
|
+
if (pathname.includes("\0") || pathname.includes("\\")) return null;
|
|
238
|
+
for (const segment of pathname.split("/")) {
|
|
239
|
+
if (segment === "..") return null;
|
|
240
|
+
}
|
|
241
|
+
const fullPath = import_path.default.resolve(runtimeRoot, pathname.replace(/^\/+/, ""));
|
|
242
|
+
const rootWithSep = runtimeRoot.endsWith(import_path.default.sep) ? runtimeRoot : runtimeRoot + import_path.default.sep;
|
|
243
|
+
if (!fullPath.startsWith(rootWithSep) && fullPath !== runtimeRoot) return null;
|
|
244
|
+
if (!import_fs.default.existsSync(fullPath) || !import_fs.default.statSync(fullPath).isFile()) return null;
|
|
245
|
+
return fullPath;
|
|
246
|
+
}
|
|
247
|
+
function serveRuntimeFile(req, res, fullPath) {
|
|
248
|
+
const ext = import_path.default.extname(fullPath);
|
|
249
|
+
const stat = import_fs.default.statSync(fullPath);
|
|
250
|
+
const lastModified = stat.mtime.toUTCString();
|
|
251
|
+
res.setHeader("content-type", MIME_TYPES[ext] || "application/octet-stream");
|
|
252
|
+
res.setHeader("cache-control", "no-cache");
|
|
253
|
+
res.setHeader("last-modified", lastModified);
|
|
254
|
+
if (req?.headers?.["if-modified-since"] === lastModified) {
|
|
255
|
+
res.statusCode = 304;
|
|
256
|
+
res.end();
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
import_fs.default.createReadStream(fullPath).pipe(res);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// src/vite-plugin-one.ts
|
|
263
|
+
function sootsimPlugin(options = {}) {
|
|
264
|
+
if (options.enabled === false) return [];
|
|
265
|
+
const prefix2 = options.prefix || "/__soot";
|
|
266
|
+
return [
|
|
267
|
+
{
|
|
268
|
+
name: "sootsim-one",
|
|
269
|
+
configureServer(server) {
|
|
270
|
+
const bundleUrl = options.bundleUrl || "/node_modules/one/metro-entry.bundle?platform=ios&dev=true&minify=false";
|
|
271
|
+
const buildShellHtml = (runtimeRoot) => {
|
|
272
|
+
const html = import_fs2.default.readFileSync(import_path2.default.join(runtimeRoot, "index.html"), "utf8");
|
|
273
|
+
const lock = readDaemonLockfile();
|
|
274
|
+
const bridgePort = lock && isDaemonLockfileFresh(lock) && lock.bridgePort > 0 ? lock.bridgePort : DEFAULT_SOOTSIM_BRIDGE_PORT;
|
|
275
|
+
const inject = `<script>(function(){var u=new URL(location.href);if(!u.searchParams.has('bundle'))u.searchParams.set('bundle',${JSON.stringify(bundleUrl)});window.__sootsimBridgePort=${bridgePort};history.replaceState(null,'','${prefix2}/'+u.search)})()</script>`;
|
|
276
|
+
return html.replace("</head>", inject + "</head>");
|
|
277
|
+
};
|
|
278
|
+
server.middlewares.use((req, res, next) => {
|
|
279
|
+
const origWriteHead = res.writeHead.bind(res);
|
|
280
|
+
res.writeHead = function(statusCode, ...args) {
|
|
281
|
+
const setCookie = res.getHeader("set-cookie");
|
|
282
|
+
if (setCookie) {
|
|
283
|
+
const value = Array.isArray(setCookie) ? setCookie.join(", ") : String(setCookie);
|
|
284
|
+
res.setHeader("x-sootsim-set-cookie", value);
|
|
285
|
+
res.setHeader("access-control-expose-headers", "x-sootsim-set-cookie");
|
|
286
|
+
}
|
|
287
|
+
return origWriteHead(
|
|
288
|
+
statusCode,
|
|
289
|
+
...args
|
|
290
|
+
);
|
|
291
|
+
};
|
|
292
|
+
next();
|
|
293
|
+
});
|
|
294
|
+
server.middlewares.use((req, res, next) => {
|
|
295
|
+
if ((req.url || "").split("?")[0] !== "/__server-scan") return next();
|
|
296
|
+
const scanPort = server.config.server.port || 8081;
|
|
297
|
+
const absoluteBundleUrl = bundleUrl.startsWith("http") ? bundleUrl : `http://localhost:${scanPort}${bundleUrl}`;
|
|
298
|
+
res.setHeader("content-type", "application/json");
|
|
299
|
+
res.end(
|
|
300
|
+
JSON.stringify([
|
|
301
|
+
{
|
|
302
|
+
port: scanPort,
|
|
303
|
+
framework: "one",
|
|
304
|
+
bundleUrl: absoluteBundleUrl,
|
|
305
|
+
lastSeen: Date.now()
|
|
306
|
+
}
|
|
307
|
+
])
|
|
308
|
+
);
|
|
309
|
+
});
|
|
310
|
+
server.middlewares.use((req, res, next) => {
|
|
311
|
+
const url = req.url || "";
|
|
312
|
+
const pathname = url.split("?")[0];
|
|
313
|
+
const runtimeRoot = resolveRuntimeRootForRequestHost(req.headers.host);
|
|
314
|
+
if (!runtimeRoot) {
|
|
315
|
+
if (pathname === prefix2 || pathname === prefix2 + "/" || pathname.startsWith(prefix2 + "/")) {
|
|
316
|
+
res.statusCode = 500;
|
|
317
|
+
res.end(SOOTSIM_RUNTIME_MISSING_MESSAGE);
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
next();
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
if (isRootRuntimeAssetPath(pathname)) {
|
|
324
|
+
const fullPath = resolveRuntimeFilePath(runtimeRoot, pathname);
|
|
325
|
+
if (fullPath) {
|
|
326
|
+
serveRuntimeFile(req, res, fullPath);
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
if (pathname === prefix2 || pathname === prefix2 + "/") {
|
|
331
|
+
res.setHeader("content-type", "text/html");
|
|
332
|
+
res.end(buildShellHtml(runtimeRoot));
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
if (pathname.startsWith(prefix2 + "/")) {
|
|
336
|
+
const fullPath = resolveRuntimeFilePath(
|
|
337
|
+
runtimeRoot,
|
|
338
|
+
pathname.slice(prefix2.length)
|
|
339
|
+
);
|
|
340
|
+
if (fullPath) {
|
|
341
|
+
serveRuntimeFile(req, res, fullPath);
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
const ext = import_path2.default.extname(pathname);
|
|
345
|
+
if (!ext) {
|
|
346
|
+
res.setHeader("content-type", "text/html");
|
|
347
|
+
res.end(buildShellHtml(runtimeRoot));
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
next();
|
|
352
|
+
});
|
|
353
|
+
const port = server.config.server.port || 8081;
|
|
354
|
+
const sootsimUrl = `http://localhost:${port}${prefix2}/`;
|
|
355
|
+
console.log(`[rnx] serving at ${sootsimUrl}`);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
];
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
// src/metro-plugin.ts
|
|
362
|
+
var import_fs3 = __toESM(require("fs"), 1);
|
|
363
|
+
var import_path3 = __toESM(require("path"), 1);
|
|
364
|
+
var prefix = "/__soot";
|
|
365
|
+
function withSootsim(config, options = {}) {
|
|
366
|
+
if (options.enabled === false) return config;
|
|
367
|
+
const bundleUrl = options.bundleUrl || "/index.bundle?platform=ios&dev=true&hot=true&minify=false";
|
|
368
|
+
const cfgServer = config.server;
|
|
369
|
+
const existingEnhance = cfgServer?.enhanceMiddleware;
|
|
370
|
+
const serverConfig = {
|
|
371
|
+
...cfgServer,
|
|
372
|
+
enhanceMiddleware: (metroMiddleware, metroServer) => {
|
|
373
|
+
let middleware = metroMiddleware;
|
|
374
|
+
if (existingEnhance) {
|
|
375
|
+
middleware = existingEnhance(metroMiddleware, metroServer);
|
|
376
|
+
}
|
|
377
|
+
let connect;
|
|
378
|
+
try {
|
|
379
|
+
connect = require("connect");
|
|
380
|
+
} catch {
|
|
381
|
+
console.warn("[rnx] connect not available");
|
|
382
|
+
return middleware;
|
|
383
|
+
}
|
|
384
|
+
const server = connect();
|
|
385
|
+
server.use((req, res, next) => {
|
|
386
|
+
const url = req.url || "";
|
|
387
|
+
const pathname = url.split("?")[0];
|
|
388
|
+
const runtimeRoot = resolveRuntimeRootForRequestHost(req.headers?.host);
|
|
389
|
+
if (!runtimeRoot) {
|
|
390
|
+
if (pathname === prefix || pathname === prefix + "/") {
|
|
391
|
+
res.statusCode = 500;
|
|
392
|
+
res.end(SOOTSIM_RUNTIME_MISSING_MESSAGE);
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
next();
|
|
396
|
+
return;
|
|
397
|
+
}
|
|
398
|
+
if (isRootRuntimeAssetPath(pathname)) {
|
|
399
|
+
const fullPath = resolveRuntimeFilePath(runtimeRoot, pathname);
|
|
400
|
+
if (fullPath) {
|
|
401
|
+
serveRuntimeFile(req, res, fullPath);
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
if (pathname.startsWith(prefix + "/")) {
|
|
406
|
+
const fullPath = resolveRuntimeFilePath(
|
|
407
|
+
runtimeRoot,
|
|
408
|
+
pathname.slice(prefix.length)
|
|
409
|
+
);
|
|
410
|
+
if (fullPath) {
|
|
411
|
+
serveRuntimeFile(req, res, fullPath);
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
if (pathname === prefix || pathname === prefix + "/" || pathname.startsWith(prefix + "/")) {
|
|
416
|
+
const ext = import_path3.default.extname(pathname);
|
|
417
|
+
if (!ext) {
|
|
418
|
+
const htmlPath = import_path3.default.join(runtimeRoot, "index.html");
|
|
419
|
+
let html = import_fs3.default.readFileSync(htmlPath, "utf8");
|
|
420
|
+
html = html.replace(
|
|
421
|
+
"</head>",
|
|
422
|
+
`<script>history.replaceState(null,'','${prefix}/?bundle=${encodeURIComponent(bundleUrl)}')</script></head>`
|
|
423
|
+
);
|
|
424
|
+
res.setHeader("content-type", "text/html");
|
|
425
|
+
res.end(html);
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
next();
|
|
430
|
+
});
|
|
431
|
+
server.use(middleware);
|
|
432
|
+
console.log(`[rnx] serving at ${prefix}/`);
|
|
433
|
+
return server;
|
|
434
|
+
}
|
|
435
|
+
};
|
|
436
|
+
return { ...config, server: serverConfig };
|
|
437
|
+
}
|
|
438
|
+
var metro_plugin_default = withSootsim;
|
|
439
|
+
|
|
440
|
+
// src/jump-to-source-babel.ts
|
|
441
|
+
function normalizeSourcePath(path5) {
|
|
442
|
+
const queryStart = path5.indexOf("?");
|
|
443
|
+
const clean = queryStart >= 0 ? path5.slice(0, queryStart) : path5;
|
|
444
|
+
return clean.replace(/\\/g, "/");
|
|
445
|
+
}
|
|
446
|
+
function matchesPath(path5, matcher) {
|
|
447
|
+
return typeof matcher === "string" ? path5.includes(matcher) : matcher.test(path5);
|
|
448
|
+
}
|
|
449
|
+
function shouldStampFile(filename, options) {
|
|
450
|
+
const normalized = normalizeSourcePath(filename);
|
|
451
|
+
if (normalized.includes("/node_modules/")) return false;
|
|
452
|
+
if (normalized.includes("/dist/") || normalized.includes("/build/")) return false;
|
|
453
|
+
if (options.exclude?.some((matcher) => matchesPath(normalized, matcher))) return false;
|
|
454
|
+
if (options.include?.length) {
|
|
455
|
+
return options.include.some((matcher) => matchesPath(normalized, matcher));
|
|
456
|
+
}
|
|
457
|
+
return true;
|
|
458
|
+
}
|
|
459
|
+
function getJSXName(node) {
|
|
460
|
+
if (!node) return null;
|
|
461
|
+
if (node.type === "JSXIdentifier" && node.name) return node.name;
|
|
462
|
+
if (node.type === "JSXMemberExpression") {
|
|
463
|
+
const object = getJSXName(node.object);
|
|
464
|
+
const property = getJSXName(node.property);
|
|
465
|
+
return object && property ? `${object}.${property}` : null;
|
|
466
|
+
}
|
|
467
|
+
return null;
|
|
468
|
+
}
|
|
469
|
+
function hasAttribute(node, attrName) {
|
|
470
|
+
return node.attributes?.some((attr) => {
|
|
471
|
+
if (attr.type !== "JSXAttribute") return false;
|
|
472
|
+
return attr.name?.type === "JSXIdentifier" && attr.name.name === attrName;
|
|
473
|
+
}) ?? false;
|
|
474
|
+
}
|
|
475
|
+
function sootsimJumpToSourceBabelPlugin(api, options = {}) {
|
|
476
|
+
const attrName = options.attrName || "srcloc";
|
|
477
|
+
return {
|
|
478
|
+
name: "sootsim-jump-to-source",
|
|
479
|
+
visitor: {
|
|
480
|
+
JSXOpeningElement(path5, state) {
|
|
481
|
+
if (options.enabled === false) return;
|
|
482
|
+
const filename = state.file?.opts?.filename;
|
|
483
|
+
if (!filename || !shouldStampFile(filename, options)) return;
|
|
484
|
+
const node = path5.node;
|
|
485
|
+
const tagName = getJSXName(node.name);
|
|
486
|
+
if (!tagName || tagName === "Fragment" || tagName.endsWith(".Fragment")) return;
|
|
487
|
+
if (hasAttribute(node, attrName)) return;
|
|
488
|
+
const loc = node.loc?.start;
|
|
489
|
+
if (!loc) return;
|
|
490
|
+
const source = `${normalizeSourcePath(filename)}:${loc.line}:${loc.column + 1}`;
|
|
491
|
+
node.attributes ??= [];
|
|
492
|
+
node.attributes.push(
|
|
493
|
+
api.types.jsxAttribute(
|
|
494
|
+
api.types.jsxIdentifier(attrName),
|
|
495
|
+
api.types.stringLiteral(source)
|
|
496
|
+
)
|
|
497
|
+
);
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
// src/cli-constants.ts
|
|
504
|
+
var DEFAULT_SOOTSIM_SHELL_URL = "http://localhost:5173/";
|
|
505
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
506
|
+
0 && (module.exports = {
|
|
507
|
+
DEFAULT_SOOTSIM_BRIDGE_PORT,
|
|
508
|
+
DEFAULT_SOOTSIM_BRIDGE_URL,
|
|
509
|
+
DEFAULT_SOOTSIM_SHELL_URL,
|
|
510
|
+
jumpToSourceBabelPlugin,
|
|
511
|
+
metroPlugin,
|
|
512
|
+
sootsimPlugin
|
|
513
|
+
});
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/*! rnx v0.1.313 | (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/jump-to-source-babel.ts
|
|
23
|
+
var jump_to_source_babel_exports = {};
|
|
24
|
+
__export(jump_to_source_babel_exports, {
|
|
25
|
+
default: () => sootsimJumpToSourceBabelPlugin,
|
|
26
|
+
sootsimJumpToSourceBabelPlugin: () => sootsimJumpToSourceBabelPlugin
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(jump_to_source_babel_exports);
|
|
29
|
+
function normalizeSourcePath(path) {
|
|
30
|
+
const queryStart = path.indexOf("?");
|
|
31
|
+
const clean = queryStart >= 0 ? path.slice(0, queryStart) : path;
|
|
32
|
+
return clean.replace(/\\/g, "/");
|
|
33
|
+
}
|
|
34
|
+
function matchesPath(path, matcher) {
|
|
35
|
+
return typeof matcher === "string" ? path.includes(matcher) : matcher.test(path);
|
|
36
|
+
}
|
|
37
|
+
function shouldStampFile(filename, options) {
|
|
38
|
+
const normalized = normalizeSourcePath(filename);
|
|
39
|
+
if (normalized.includes("/node_modules/")) return false;
|
|
40
|
+
if (normalized.includes("/dist/") || normalized.includes("/build/")) return false;
|
|
41
|
+
if (options.exclude?.some((matcher) => matchesPath(normalized, matcher))) return false;
|
|
42
|
+
if (options.include?.length) {
|
|
43
|
+
return options.include.some((matcher) => matchesPath(normalized, matcher));
|
|
44
|
+
}
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
function getJSXName(node) {
|
|
48
|
+
if (!node) return null;
|
|
49
|
+
if (node.type === "JSXIdentifier" && node.name) return node.name;
|
|
50
|
+
if (node.type === "JSXMemberExpression") {
|
|
51
|
+
const object = getJSXName(node.object);
|
|
52
|
+
const property = getJSXName(node.property);
|
|
53
|
+
return object && property ? `${object}.${property}` : null;
|
|
54
|
+
}
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
function hasAttribute(node, attrName) {
|
|
58
|
+
return node.attributes?.some((attr) => {
|
|
59
|
+
if (attr.type !== "JSXAttribute") return false;
|
|
60
|
+
return attr.name?.type === "JSXIdentifier" && attr.name.name === attrName;
|
|
61
|
+
}) ?? false;
|
|
62
|
+
}
|
|
63
|
+
function sootsimJumpToSourceBabelPlugin(api, options = {}) {
|
|
64
|
+
const attrName = options.attrName || "srcloc";
|
|
65
|
+
return {
|
|
66
|
+
name: "sootsim-jump-to-source",
|
|
67
|
+
visitor: {
|
|
68
|
+
JSXOpeningElement(path, state) {
|
|
69
|
+
if (options.enabled === false) return;
|
|
70
|
+
const filename = state.file?.opts?.filename;
|
|
71
|
+
if (!filename || !shouldStampFile(filename, options)) return;
|
|
72
|
+
const node = path.node;
|
|
73
|
+
const tagName = getJSXName(node.name);
|
|
74
|
+
if (!tagName || tagName === "Fragment" || tagName.endsWith(".Fragment")) return;
|
|
75
|
+
if (hasAttribute(node, attrName)) return;
|
|
76
|
+
const loc = node.loc?.start;
|
|
77
|
+
if (!loc) return;
|
|
78
|
+
const source = `${normalizeSourcePath(filename)}:${loc.line}:${loc.column + 1}`;
|
|
79
|
+
node.attributes ??= [];
|
|
80
|
+
node.attributes.push(
|
|
81
|
+
api.types.jsxAttribute(
|
|
82
|
+
api.types.jsxIdentifier(attrName),
|
|
83
|
+
api.types.stringLiteral(source)
|
|
84
|
+
)
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
91
|
+
0 && (module.exports = {
|
|
92
|
+
sootsimJumpToSourceBabelPlugin
|
|
93
|
+
});
|