rnxsim 0.1.433 → 0.1.434
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/cloud-client.ts +55 -13
- package/cli/commands/box.ts +89 -14
- package/cli/outbound-endpoints.ts +5 -0
- package/cli/send-to-box.ts +112 -0
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/agent-identity.cjs +1 -1
- package/dist-lib/agent-sessions.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -1
- package/dist-lib/auth/shared-session.cjs +1 -1
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/beta.cjs +1 -1
- package/dist-lib/beta.mjs +1 -1
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/bridge-contract-input.cjs +1 -1
- package/dist-lib/bridge-contract-input.mjs +1 -1
- package/dist-lib/bridge-contract.cjs +1 -1
- package/dist-lib/bridge-contract.mjs +1 -1
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +1 -1
- package/dist-lib/cli-constants.cjs +1 -1
- package/dist-lib/cloud-contract.cjs +1 -1
- package/dist-lib/cloud-contract.mjs +1 -1
- package/dist-lib/cloud.cjs +1 -1
- package/dist-lib/cloud.mjs +1 -1
- package/dist-lib/config.cjs +1 -1
- package/dist-lib/detox/index.cjs +1 -1
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +5324 -1371
- package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
- package/dist-lib/host/replacement-module-handler.cjs +298 -91
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +313 -104
- package/dist-lib/jump-to-source-babel.cjs +1 -1
- package/dist-lib/menu.cjs +7 -1
- package/dist-lib/menu.mjs +7 -1
- package/dist-lib/metro-fingerprint-registry.cjs +1 -1
- package/dist-lib/metro-fingerprint-registry.mjs +1 -1
- package/dist-lib/metro-production-bundle.cjs +1 -1
- package/dist-lib/metro-production-bundle.mjs +1 -1
- package/dist-lib/metro.cjs +302 -95
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +1 -1
- package/dist-lib/render-mode.cjs +1 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
- package/dist-lib/sdk.cjs +1 -1
- package/dist-lib/sdk.mjs +1 -1
- package/dist-lib/skills.cjs +5006 -1441
- package/dist-lib/vite.cjs +298 -91
- package/package.json +2 -2
- package/src/bridge-contract.ts +6 -0
- package/src/host/bridge-host.ts +79 -0
- package/src/host/replacement-module-handler.ts +20 -96
- package/src/menu.ts +8 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.434 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.434 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.434 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
|
|
3
3
|
// src/host/fetch-proxy-overrides.ts
|
|
4
4
|
var FETCH_PROXY_BROWSER_USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.434 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
|
@@ -39,7 +39,287 @@ __export(replacement_module_handler_exports, {
|
|
|
39
39
|
module.exports = __toCommonJS(replacement_module_handler_exports);
|
|
40
40
|
var import_promises = __toESM(require("node:fs/promises"), 1);
|
|
41
41
|
var import_node_path = __toESM(require("node:path"), 1);
|
|
42
|
-
|
|
42
|
+
|
|
43
|
+
// ../contrast-bundler/src/replacementModule.ts
|
|
44
|
+
var import_dist = require("sucrase/dist/index.js");
|
|
45
|
+
var import_parser = require("sucrase/dist/parser/index.js");
|
|
46
|
+
var import_types = require("sucrase/dist/parser/tokenizer/types.js");
|
|
47
|
+
|
|
48
|
+
// ../contrast-bundler/src/posixPath.ts
|
|
49
|
+
var sep = "/";
|
|
50
|
+
var delimiter = ":";
|
|
51
|
+
function isAbsolute(p) {
|
|
52
|
+
return p.charCodeAt(0) === 47;
|
|
53
|
+
}
|
|
54
|
+
function normalizeSegments(parts, allowAboveRoot) {
|
|
55
|
+
const out = [];
|
|
56
|
+
for (const part of parts) {
|
|
57
|
+
if (part === "" || part === ".") continue;
|
|
58
|
+
if (part === "..") {
|
|
59
|
+
if (out.length > 0 && out[out.length - 1] !== "..") out.pop();
|
|
60
|
+
else if (allowAboveRoot) out.push("..");
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
out.push(part);
|
|
64
|
+
}
|
|
65
|
+
return out;
|
|
66
|
+
}
|
|
67
|
+
function normalize(p) {
|
|
68
|
+
if (p.length === 0) return ".";
|
|
69
|
+
const absolute = isAbsolute(p);
|
|
70
|
+
const trailingSlash = p.charCodeAt(p.length - 1) === 47;
|
|
71
|
+
const segments = normalizeSegments(p.split("/"), !absolute);
|
|
72
|
+
let joined = segments.join("/");
|
|
73
|
+
if (joined.length === 0) {
|
|
74
|
+
if (absolute) return "/";
|
|
75
|
+
return trailingSlash ? "./" : ".";
|
|
76
|
+
}
|
|
77
|
+
if (trailingSlash) joined += "/";
|
|
78
|
+
return absolute ? "/" + joined : joined;
|
|
79
|
+
}
|
|
80
|
+
function join(...parts) {
|
|
81
|
+
const present = parts.filter((part) => part.length > 0);
|
|
82
|
+
if (present.length === 0) return ".";
|
|
83
|
+
return normalize(present.join("/"));
|
|
84
|
+
}
|
|
85
|
+
function resolve(...parts) {
|
|
86
|
+
let resolved = "";
|
|
87
|
+
let absolute = false;
|
|
88
|
+
for (let i = parts.length - 1; i >= 0 && !absolute; i--) {
|
|
89
|
+
const part = parts[i];
|
|
90
|
+
if (part.length === 0) continue;
|
|
91
|
+
resolved = resolved.length > 0 ? `${part}/${resolved}` : part;
|
|
92
|
+
absolute = isAbsolute(part);
|
|
93
|
+
}
|
|
94
|
+
if (!absolute)
|
|
95
|
+
throw new Error(
|
|
96
|
+
`posixPath.resolve needs an absolute segment, got: ${parts.join(", ")}`
|
|
97
|
+
);
|
|
98
|
+
const normalized = normalizeSegments(resolved.split("/"), false).join("/");
|
|
99
|
+
return normalized.length > 0 ? "/" + normalized : "/";
|
|
100
|
+
}
|
|
101
|
+
function dirname(p) {
|
|
102
|
+
const idx = p.lastIndexOf("/");
|
|
103
|
+
if (idx < 0) return ".";
|
|
104
|
+
if (idx === 0) return "/";
|
|
105
|
+
return p.slice(0, idx);
|
|
106
|
+
}
|
|
107
|
+
function basename(p, ext) {
|
|
108
|
+
const idx = p.lastIndexOf("/");
|
|
109
|
+
const base = idx < 0 ? p : p.slice(idx + 1);
|
|
110
|
+
if (ext != null && ext.length < base.length && base.endsWith(ext)) {
|
|
111
|
+
return base.slice(0, base.length - ext.length);
|
|
112
|
+
}
|
|
113
|
+
return base;
|
|
114
|
+
}
|
|
115
|
+
function extname(p) {
|
|
116
|
+
const base = basename(p);
|
|
117
|
+
const idx = base.lastIndexOf(".");
|
|
118
|
+
if (idx <= 0) return "";
|
|
119
|
+
return base.slice(idx);
|
|
120
|
+
}
|
|
121
|
+
function relative(from, to) {
|
|
122
|
+
if (from === to) return "";
|
|
123
|
+
const fromParts = normalizeSegments(from.split("/"), false);
|
|
124
|
+
const toParts = normalizeSegments(to.split("/"), false);
|
|
125
|
+
let shared = 0;
|
|
126
|
+
while (shared < fromParts.length && shared < toParts.length && fromParts[shared] === toParts[shared]) {
|
|
127
|
+
shared++;
|
|
128
|
+
}
|
|
129
|
+
const up = new Array(fromParts.length - shared).fill("..");
|
|
130
|
+
return [...up, ...toParts.slice(shared)].join("/");
|
|
131
|
+
}
|
|
132
|
+
var posix = {
|
|
133
|
+
sep,
|
|
134
|
+
delimiter,
|
|
135
|
+
isAbsolute,
|
|
136
|
+
normalize,
|
|
137
|
+
join,
|
|
138
|
+
resolve,
|
|
139
|
+
dirname,
|
|
140
|
+
basename,
|
|
141
|
+
extname,
|
|
142
|
+
relative
|
|
143
|
+
};
|
|
144
|
+
var posixPath_default = { ...posix, posix };
|
|
145
|
+
|
|
146
|
+
// ../contrast-bundler/src/replacementModule.ts
|
|
147
|
+
var REPLACEMENT_MODULE_EXTENSIONS = [".js", ".jsx", ".ts", ".tsx"];
|
|
148
|
+
var IMPORT_KEYWORD = import_types.TokenType["_import"];
|
|
149
|
+
var EXPORT_KEYWORD = import_types.TokenType["_export"];
|
|
150
|
+
var REACT_BRIDGE = "globalThis.__sootsim_react_bridge";
|
|
151
|
+
var REACT_NATIVE_BRIDGE = "globalThis.__sootsim_components__";
|
|
152
|
+
var PACKAGE_BRIDGES = "globalThis.__sootsim_config_package_modules";
|
|
153
|
+
var JSX_RUNTIME_SPECIFIERS = /* @__PURE__ */ new Set(["react/jsx-runtime", "react/jsx-dev-runtime"]);
|
|
154
|
+
function transformsFor(filePath) {
|
|
155
|
+
switch (extname(filePath).toLowerCase()) {
|
|
156
|
+
case ".ts":
|
|
157
|
+
return ["typescript"];
|
|
158
|
+
case ".tsx":
|
|
159
|
+
return ["typescript", "jsx"];
|
|
160
|
+
case ".js":
|
|
161
|
+
case ".jsx":
|
|
162
|
+
return ["jsx"];
|
|
163
|
+
default:
|
|
164
|
+
throw new Error(
|
|
165
|
+
`replacement files must be ${REPLACEMENT_MODULE_EXTENSIONS.join(", ")}`
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
function unsupportedSpecifier(specifier) {
|
|
170
|
+
return new Error(
|
|
171
|
+
`replacement modules may only import react, react-native, and the packages rnx stubs for this app; '${specifier}' is none of those. vendor the code into the replacement file, or add the package to rnx.config so the simulator bridges it.`
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
function bridgeDeclaration(name, specifier) {
|
|
175
|
+
const notReady = (what) => JSON.stringify(`[rnx] replacement ${what} bridge is not ready`);
|
|
176
|
+
if (specifier === "react") {
|
|
177
|
+
return `const ${name} = ${REACT_BRIDGE}; if (!${name}) throw new Error(${notReady("React")});`;
|
|
178
|
+
}
|
|
179
|
+
if (specifier === "react-native") {
|
|
180
|
+
return `const ${name} = ${REACT_NATIVE_BRIDGE}; if (!${name}) throw new Error(${notReady("React Native")});`;
|
|
181
|
+
}
|
|
182
|
+
if (JSX_RUNTIME_SPECIFIERS.has(specifier)) {
|
|
183
|
+
return `const ${name} = (() => { const react = ${REACT_BRIDGE}; if (!react) throw new Error(${notReady("React")}); const jsx = (type, props, key) => react.createElement(type, key === undefined ? props : { ...props, key }); return { Fragment: react.Fragment, jsx, jsxs: jsx, jsxDEV: jsx }; })();`;
|
|
184
|
+
}
|
|
185
|
+
return `const ${name} = (${PACKAGE_BRIDGES} || {})[${JSON.stringify(specifier)}]; if (!${name}) throw new Error(${JSON.stringify(`[rnx] replacement package bridge ${specifier} is not ready`)});`;
|
|
186
|
+
}
|
|
187
|
+
var DEFAULT_INTEROP = "__rnxReplacementDefault";
|
|
188
|
+
var DEFAULT_INTEROP_DECLARATION = `const ${DEFAULT_INTEROP} = (bridge) => (bridge && bridge.__esModule ? bridge.default : bridge);`;
|
|
189
|
+
function compileReplacementModule(input) {
|
|
190
|
+
const transformed = (0, import_dist.transform)(input.source, {
|
|
191
|
+
transforms: transformsFor(input.filePath),
|
|
192
|
+
filePath: input.filePath,
|
|
193
|
+
// classic runtime, matching what the app's own Metro build does for a file
|
|
194
|
+
// that has no automatic-runtime pragma: the file imports React itself.
|
|
195
|
+
jsxRuntime: "classic",
|
|
196
|
+
jsxPragma: "React.createElement",
|
|
197
|
+
jsxFragmentPragma: "React.Fragment",
|
|
198
|
+
production: true,
|
|
199
|
+
sourceMapOptions: { compiledFilename: input.filePath }
|
|
200
|
+
});
|
|
201
|
+
const code = transformed.code;
|
|
202
|
+
const sourceMap = transformed.sourceMap;
|
|
203
|
+
if (!sourceMap) throw new Error("sucrase compiled the replacement with no source map");
|
|
204
|
+
const { tokens } = (0, import_parser.parse)(code, false, false, false);
|
|
205
|
+
const read = (token) => code.slice(token.start, token.end);
|
|
206
|
+
const readSpecifier = (token) => {
|
|
207
|
+
if (token.type !== import_types.TokenType.string) {
|
|
208
|
+
throw new Error("replacement module import has no string specifier");
|
|
209
|
+
}
|
|
210
|
+
return code.slice(token.start + 1, token.end - 1);
|
|
211
|
+
};
|
|
212
|
+
const bridgeNames = /* @__PURE__ */ new Map();
|
|
213
|
+
const declarations = [];
|
|
214
|
+
let needsDefaultInterop = false;
|
|
215
|
+
const bridgeFor = (specifier) => {
|
|
216
|
+
const existing = bridgeNames.get(specifier);
|
|
217
|
+
if (existing) return existing;
|
|
218
|
+
const name = `__rnxReplacementBridge${bridgeNames.size}`;
|
|
219
|
+
bridgeNames.set(specifier, name);
|
|
220
|
+
declarations.push(bridgeDeclaration(name, specifier));
|
|
221
|
+
return name;
|
|
222
|
+
};
|
|
223
|
+
const edits = [];
|
|
224
|
+
for (let index = 0; index < tokens.length; index++) {
|
|
225
|
+
const token = tokens[index];
|
|
226
|
+
if (token.type === EXPORT_KEYWORD) {
|
|
227
|
+
const after2 = tokens[index + 1];
|
|
228
|
+
let fromAt = -1;
|
|
229
|
+
if (after2?.type === import_types.TokenType.star) {
|
|
230
|
+
fromAt = read(tokens[index + 2]) === "from" ? index + 2 : index + 4;
|
|
231
|
+
} else if (after2?.type === import_types.TokenType.braceL) {
|
|
232
|
+
let depth = 1;
|
|
233
|
+
let cursor2 = index + 2;
|
|
234
|
+
while (cursor2 < tokens.length && depth > 0) {
|
|
235
|
+
if (tokens[cursor2].type === import_types.TokenType.braceL) depth++;
|
|
236
|
+
else if (tokens[cursor2].type === import_types.TokenType.braceR) depth--;
|
|
237
|
+
cursor2++;
|
|
238
|
+
}
|
|
239
|
+
fromAt = cursor2;
|
|
240
|
+
}
|
|
241
|
+
if (fromAt > 0 && tokens[fromAt] && read(tokens[fromAt]) === "from" && tokens[fromAt + 1]?.type === import_types.TokenType.string) {
|
|
242
|
+
const specifier2 = readSpecifier(tokens[fromAt + 1]);
|
|
243
|
+
throw new Error(
|
|
244
|
+
`a replacement module cannot re-export from another module, and this one re-exports from '${specifier2}'. import what you need and export the binding.`
|
|
245
|
+
);
|
|
246
|
+
}
|
|
247
|
+
continue;
|
|
248
|
+
}
|
|
249
|
+
if (token.type !== IMPORT_KEYWORD) continue;
|
|
250
|
+
const after = tokens[index + 1];
|
|
251
|
+
if (!after || after.type === import_types.TokenType.parenL || after.type === import_types.TokenType.dot) continue;
|
|
252
|
+
const bindings = [];
|
|
253
|
+
let cursor = index + 1;
|
|
254
|
+
if (after.type !== import_types.TokenType.string) {
|
|
255
|
+
while (cursor < tokens.length) {
|
|
256
|
+
const clause = tokens[cursor];
|
|
257
|
+
if (clause.type === import_types.TokenType.name && read(clause) === "from") break;
|
|
258
|
+
if (clause.type === import_types.TokenType.comma) {
|
|
259
|
+
cursor++;
|
|
260
|
+
continue;
|
|
261
|
+
}
|
|
262
|
+
if (clause.type === import_types.TokenType.star) {
|
|
263
|
+
bindings.push({ local: read(tokens[cursor + 2]), imported: null });
|
|
264
|
+
cursor += 3;
|
|
265
|
+
continue;
|
|
266
|
+
}
|
|
267
|
+
if (clause.type === import_types.TokenType.braceL) {
|
|
268
|
+
cursor++;
|
|
269
|
+
while (cursor < tokens.length && tokens[cursor].type !== import_types.TokenType.braceR) {
|
|
270
|
+
if (tokens[cursor].type === import_types.TokenType.comma) {
|
|
271
|
+
cursor++;
|
|
272
|
+
continue;
|
|
273
|
+
}
|
|
274
|
+
const nameToken = tokens[cursor];
|
|
275
|
+
const imported = nameToken.type === import_types.TokenType.string ? readSpecifier(nameToken) : read(nameToken);
|
|
276
|
+
let local = imported;
|
|
277
|
+
if (tokens[cursor + 1] && read(tokens[cursor + 1]) === "as") {
|
|
278
|
+
local = read(tokens[cursor + 2]);
|
|
279
|
+
cursor += 2;
|
|
280
|
+
}
|
|
281
|
+
bindings.push({ local, imported });
|
|
282
|
+
cursor++;
|
|
283
|
+
}
|
|
284
|
+
cursor++;
|
|
285
|
+
continue;
|
|
286
|
+
}
|
|
287
|
+
bindings.push({ local: read(clause), imported: "default" });
|
|
288
|
+
cursor++;
|
|
289
|
+
}
|
|
290
|
+
cursor++;
|
|
291
|
+
}
|
|
292
|
+
const specifierToken = tokens[cursor];
|
|
293
|
+
if (!specifierToken) throw new Error("replacement module import is unterminated");
|
|
294
|
+
const specifier = readSpecifier(specifierToken);
|
|
295
|
+
if (specifier !== "react" && specifier !== "react-native" && !JSX_RUNTIME_SPECIFIERS.has(specifier) && !input.runtimePackages.has(specifier)) {
|
|
296
|
+
throw unsupportedSpecifier(specifier);
|
|
297
|
+
}
|
|
298
|
+
const bridge = bindings.length > 0 ? bridgeFor(specifier) : null;
|
|
299
|
+
const replacement = bindings.map((binding) => {
|
|
300
|
+
if (binding.imported === null) return `const ${binding.local} = ${bridge};`;
|
|
301
|
+
if (binding.imported === "default") {
|
|
302
|
+
needsDefaultInterop = true;
|
|
303
|
+
return `const ${binding.local} = ${DEFAULT_INTEROP}(${bridge});`;
|
|
304
|
+
}
|
|
305
|
+
return `const ${binding.local} = ${bridge}[${JSON.stringify(binding.imported)}];`;
|
|
306
|
+
}).join(" ");
|
|
307
|
+
const start = token.start;
|
|
308
|
+
const end = specifierToken.end;
|
|
309
|
+
const newlines = code.slice(start, end).split("\n").length - 1;
|
|
310
|
+
edits.push({ start, end, text: replacement + "\n".repeat(newlines) });
|
|
311
|
+
}
|
|
312
|
+
let out = code;
|
|
313
|
+
for (const edit of edits.reverse()) {
|
|
314
|
+
out = out.slice(0, edit.start) + edit.text + out.slice(edit.end);
|
|
315
|
+
}
|
|
316
|
+
if (needsDefaultInterop) declarations.unshift(DEFAULT_INTEROP_DECLARATION);
|
|
317
|
+
const preamble = declarations.join(" ");
|
|
318
|
+
return {
|
|
319
|
+
code: preamble ? `${preamble} ${out}` : out,
|
|
320
|
+
sourceMap: { ...sourceMap, sourcesContent: [input.source] }
|
|
321
|
+
};
|
|
322
|
+
}
|
|
43
323
|
|
|
44
324
|
// src/backend-origin.ts
|
|
45
325
|
function normalizeHostname(hostname) {
|
|
@@ -52,21 +332,6 @@ function isLoopbackHost(hostname) {
|
|
|
52
332
|
|
|
53
333
|
// src/host/replacement-module-handler.ts
|
|
54
334
|
var REPLACEMENT_MODULE_ROUTE = "/__sootsim-replacement-module";
|
|
55
|
-
function getReplacementLoader(filePath) {
|
|
56
|
-
const ext = import_node_path.default.extname(filePath).toLowerCase();
|
|
57
|
-
switch (ext) {
|
|
58
|
-
case ".js":
|
|
59
|
-
return "js";
|
|
60
|
-
case ".jsx":
|
|
61
|
-
return "jsx";
|
|
62
|
-
case ".ts":
|
|
63
|
-
return "ts";
|
|
64
|
-
case ".tsx":
|
|
65
|
-
return "tsx";
|
|
66
|
-
default:
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
335
|
function sendJavaScript(req, res, source) {
|
|
71
336
|
const origin = req.headers.origin;
|
|
72
337
|
let allowedOrigin;
|
|
@@ -129,10 +394,10 @@ async function handleReplacementModuleRequest(req, res, options = {}) {
|
|
|
129
394
|
res.end("missing path param");
|
|
130
395
|
return true;
|
|
131
396
|
}
|
|
132
|
-
const
|
|
133
|
-
if (!
|
|
397
|
+
const extension = import_node_path.default.extname(targetPath).toLowerCase();
|
|
398
|
+
if (!REPLACEMENT_MODULE_EXTENSIONS.some((allowed) => allowed === extension)) {
|
|
134
399
|
res.writeHead(400, { "Content-Type": "text/plain; charset=utf-8" });
|
|
135
|
-
res.end(
|
|
400
|
+
res.end(`replacement files must be ${REPLACEMENT_MODULE_EXTENSIONS.join(", ")}`);
|
|
136
401
|
return true;
|
|
137
402
|
}
|
|
138
403
|
if (!import_node_path.default.isAbsolute(targetPath)) {
|
|
@@ -170,81 +435,23 @@ async function handleReplacementModuleRequest(req, res, options = {}) {
|
|
|
170
435
|
}
|
|
171
436
|
}
|
|
172
437
|
try {
|
|
173
|
-
const
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
format: "esm",
|
|
178
|
-
platform: "browser",
|
|
179
|
-
target: "es2022",
|
|
180
|
-
jsx: "transform",
|
|
181
|
-
jsxFactory: "React.createElement",
|
|
182
|
-
jsxFragment: "React.Fragment",
|
|
183
|
-
tsconfigRaw: { compilerOptions: { jsx: "react" } },
|
|
184
|
-
sourcemap: "inline",
|
|
185
|
-
logLevel: "silent",
|
|
186
|
-
plugins: [
|
|
187
|
-
{
|
|
188
|
-
name: "sootsim-replacement-runtime",
|
|
189
|
-
setup(runtimeBuild) {
|
|
190
|
-
runtimeBuild.onResolve(
|
|
191
|
-
{
|
|
192
|
-
filter: /^(react|react-native|react\/jsx-runtime|react\/jsx-dev-runtime)$/
|
|
193
|
-
},
|
|
194
|
-
(args) => ({ path: args.path, namespace: "sootsim-replacement-runtime" })
|
|
195
|
-
);
|
|
196
|
-
runtimeBuild.onResolve(
|
|
197
|
-
{ filter: /.*/ },
|
|
198
|
-
(args) => runtimePackages.has(args.path) ? { path: args.path, namespace: "sootsim-replacement-runtime" } : void 0
|
|
199
|
-
);
|
|
200
|
-
runtimeBuild.onLoad(
|
|
201
|
-
{ filter: /.*/, namespace: "sootsim-replacement-runtime" },
|
|
202
|
-
(args) => {
|
|
203
|
-
if (args.path === "react-native") {
|
|
204
|
-
return {
|
|
205
|
-
contents: `const bridge = globalThis.__sootsim_components__
|
|
206
|
-
if (!bridge) throw new Error('[rnx] replacement React Native bridge is not ready')
|
|
207
|
-
module.exports = bridge`,
|
|
208
|
-
loader: "js"
|
|
209
|
-
};
|
|
210
|
-
}
|
|
211
|
-
if (args.path === "react") {
|
|
212
|
-
return {
|
|
213
|
-
contents: `const bridge = globalThis.__sootsim_react_bridge
|
|
214
|
-
if (!bridge) throw new Error('[rnx] replacement React bridge is not ready')
|
|
215
|
-
module.exports = bridge`,
|
|
216
|
-
loader: "js"
|
|
217
|
-
};
|
|
218
|
-
}
|
|
219
|
-
if (args.path !== "react/jsx-runtime" && args.path !== "react/jsx-dev-runtime") {
|
|
220
|
-
return {
|
|
221
|
-
contents: `const packages = globalThis.__sootsim_config_package_modules
|
|
222
|
-
const bridge = packages?.[${JSON.stringify(args.path)}]
|
|
223
|
-
if (!bridge) throw new Error(${JSON.stringify(`[rnx] replacement package bridge ${args.path} is not ready`)})
|
|
224
|
-
module.exports = bridge`,
|
|
225
|
-
loader: "js"
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
|
-
return {
|
|
229
|
-
contents: `const React = globalThis.__sootsim_react_bridge
|
|
230
|
-
if (!React) throw new Error('[rnx] replacement React bridge is not ready')
|
|
231
|
-
exports.Fragment = React.Fragment
|
|
232
|
-
exports.jsx = (type, props, key) => React.createElement(type, key === undefined ? props : { ...props, key })
|
|
233
|
-
exports.jsxs = exports.jsx
|
|
234
|
-
exports.jsxDEV = exports.jsx`,
|
|
235
|
-
loader: "js"
|
|
236
|
-
};
|
|
237
|
-
}
|
|
238
|
-
);
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
]
|
|
438
|
+
const compiled = compileReplacementModule({
|
|
439
|
+
filePath: resolvedTargetPath,
|
|
440
|
+
source: await import_promises.default.readFile(resolvedTargetPath, "utf8"),
|
|
441
|
+
runtimePackages
|
|
242
442
|
});
|
|
243
|
-
|
|
443
|
+
const map = Buffer.from(JSON.stringify(compiled.sourceMap), "utf8").toString("base64");
|
|
444
|
+
sendJavaScript(
|
|
445
|
+
req,
|
|
446
|
+
res,
|
|
447
|
+
`${compiled.code}
|
|
448
|
+
//# sourceMappingURL=data:application/json;base64,${map}
|
|
449
|
+
`
|
|
450
|
+
);
|
|
244
451
|
} catch (error) {
|
|
245
452
|
const message = error instanceof Error ? error.message : String(error);
|
|
246
453
|
res.writeHead(500, { "Content-Type": "text/plain; charset=utf-8" });
|
|
247
|
-
res.end(`replacement
|
|
454
|
+
res.end(`replacement compile failed: ${message}`);
|
|
248
455
|
}
|
|
249
456
|
return true;
|
|
250
457
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.434 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __defProp = Object.defineProperty;
|