rnxsim 0.1.433 → 0.1.435
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/commands/inspect.ts +8 -1
- 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,6 +1,9 @@
|
|
|
1
1
|
import fs from 'node:fs/promises'
|
|
2
2
|
import path from 'node:path'
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
compileReplacementModule,
|
|
5
|
+
REPLACEMENT_MODULE_EXTENSIONS,
|
|
6
|
+
} from '../../../contrast-bundler/src/replacementModule.ts'
|
|
4
7
|
import { isLoopbackHost } from '../backend-origin.ts'
|
|
5
8
|
import type { IncomingMessage, ServerResponse } from 'node:http'
|
|
6
9
|
|
|
@@ -12,22 +15,6 @@ export interface ReplacementModuleHandlerOptions {
|
|
|
12
15
|
requestToken?: string
|
|
13
16
|
}
|
|
14
17
|
|
|
15
|
-
function getReplacementLoader(filePath: string): 'js' | 'jsx' | 'ts' | 'tsx' | null {
|
|
16
|
-
const ext = path.extname(filePath).toLowerCase()
|
|
17
|
-
switch (ext) {
|
|
18
|
-
case '.js':
|
|
19
|
-
return 'js'
|
|
20
|
-
case '.jsx':
|
|
21
|
-
return 'jsx'
|
|
22
|
-
case '.ts':
|
|
23
|
-
return 'ts'
|
|
24
|
-
case '.tsx':
|
|
25
|
-
return 'tsx'
|
|
26
|
-
default:
|
|
27
|
-
return null
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
18
|
function sendJavaScript(req: IncomingMessage, res: ServerResponse, source: string): void {
|
|
32
19
|
const origin = req.headers.origin
|
|
33
20
|
let allowedOrigin: string | undefined
|
|
@@ -102,10 +89,10 @@ export async function handleReplacementModuleRequest(
|
|
|
102
89
|
return true
|
|
103
90
|
}
|
|
104
91
|
|
|
105
|
-
const
|
|
106
|
-
if (!
|
|
92
|
+
const extension = path.extname(targetPath).toLowerCase()
|
|
93
|
+
if (!REPLACEMENT_MODULE_EXTENSIONS.some((allowed) => allowed === extension)) {
|
|
107
94
|
res.writeHead(400, { 'Content-Type': 'text/plain; charset=utf-8' })
|
|
108
|
-
res.end(
|
|
95
|
+
res.end(`replacement files must be ${REPLACEMENT_MODULE_EXTENSIONS.join(', ')}`)
|
|
109
96
|
return true
|
|
110
97
|
}
|
|
111
98
|
|
|
@@ -149,86 +136,23 @@ export async function handleReplacementModuleRequest(
|
|
|
149
136
|
}
|
|
150
137
|
|
|
151
138
|
try {
|
|
152
|
-
const
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
format: 'esm',
|
|
157
|
-
platform: 'browser',
|
|
158
|
-
target: 'es2022',
|
|
159
|
-
jsx: 'transform',
|
|
160
|
-
jsxFactory: 'React.createElement',
|
|
161
|
-
jsxFragment: 'React.Fragment',
|
|
162
|
-
tsconfigRaw: { compilerOptions: { jsx: 'react' } },
|
|
163
|
-
sourcemap: 'inline',
|
|
164
|
-
logLevel: 'silent',
|
|
165
|
-
plugins: [
|
|
166
|
-
{
|
|
167
|
-
name: 'sootsim-replacement-runtime',
|
|
168
|
-
setup(runtimeBuild) {
|
|
169
|
-
runtimeBuild.onResolve(
|
|
170
|
-
{
|
|
171
|
-
filter:
|
|
172
|
-
/^(react|react-native|react\/jsx-runtime|react\/jsx-dev-runtime)$/,
|
|
173
|
-
},
|
|
174
|
-
(args) => ({ path: args.path, namespace: 'sootsim-replacement-runtime' }),
|
|
175
|
-
)
|
|
176
|
-
runtimeBuild.onResolve({ filter: /.*/ }, (args) =>
|
|
177
|
-
runtimePackages.has(args.path)
|
|
178
|
-
? { path: args.path, namespace: 'sootsim-replacement-runtime' }
|
|
179
|
-
: undefined,
|
|
180
|
-
)
|
|
181
|
-
runtimeBuild.onLoad(
|
|
182
|
-
{ filter: /.*/, namespace: 'sootsim-replacement-runtime' },
|
|
183
|
-
(args) => {
|
|
184
|
-
if (args.path === 'react-native') {
|
|
185
|
-
return {
|
|
186
|
-
contents: `const bridge = globalThis.__sootsim_components__
|
|
187
|
-
if (!bridge) throw new Error('[rnx] replacement React Native bridge is not ready')
|
|
188
|
-
module.exports = bridge`,
|
|
189
|
-
loader: 'js',
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
if (args.path === 'react') {
|
|
193
|
-
return {
|
|
194
|
-
contents: `const bridge = globalThis.__sootsim_react_bridge
|
|
195
|
-
if (!bridge) throw new Error('[rnx] replacement React bridge is not ready')
|
|
196
|
-
module.exports = bridge`,
|
|
197
|
-
loader: 'js',
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
if (
|
|
201
|
-
args.path !== 'react/jsx-runtime' &&
|
|
202
|
-
args.path !== 'react/jsx-dev-runtime'
|
|
203
|
-
) {
|
|
204
|
-
return {
|
|
205
|
-
contents: `const packages = globalThis.__sootsim_config_package_modules
|
|
206
|
-
const bridge = packages?.[${JSON.stringify(args.path)}]
|
|
207
|
-
if (!bridge) throw new Error(${JSON.stringify(`[rnx] replacement package bridge ${args.path} is not ready`)})
|
|
208
|
-
module.exports = bridge`,
|
|
209
|
-
loader: 'js',
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
return {
|
|
213
|
-
contents: `const React = globalThis.__sootsim_react_bridge
|
|
214
|
-
if (!React) throw new Error('[rnx] replacement React bridge is not ready')
|
|
215
|
-
exports.Fragment = React.Fragment
|
|
216
|
-
exports.jsx = (type, props, key) => React.createElement(type, key === undefined ? props : { ...props, key })
|
|
217
|
-
exports.jsxs = exports.jsx
|
|
218
|
-
exports.jsxDEV = exports.jsx`,
|
|
219
|
-
loader: 'js',
|
|
220
|
-
}
|
|
221
|
-
},
|
|
222
|
-
)
|
|
223
|
-
},
|
|
224
|
-
},
|
|
225
|
-
],
|
|
139
|
+
const compiled = compileReplacementModule({
|
|
140
|
+
filePath: resolvedTargetPath,
|
|
141
|
+
source: await fs.readFile(resolvedTargetPath, 'utf8'),
|
|
142
|
+
runtimePackages,
|
|
226
143
|
})
|
|
227
|
-
|
|
144
|
+
// inline the map: the file is the app author's own source, and the
|
|
145
|
+
// simulator page is the only thing that ever loads it.
|
|
146
|
+
const map = Buffer.from(JSON.stringify(compiled.sourceMap), 'utf8').toString('base64')
|
|
147
|
+
sendJavaScript(
|
|
148
|
+
req,
|
|
149
|
+
res,
|
|
150
|
+
`${compiled.code}\n//# sourceMappingURL=data:application/json;base64,${map}\n`,
|
|
151
|
+
)
|
|
228
152
|
} catch (error) {
|
|
229
153
|
const message = error instanceof Error ? error.message : String(error)
|
|
230
154
|
res.writeHead(500, { 'Content-Type': 'text/plain; charset=utf-8' })
|
|
231
|
-
res.end(`replacement
|
|
155
|
+
res.end(`replacement compile failed: ${message}`)
|
|
232
156
|
}
|
|
233
157
|
return true
|
|
234
158
|
}
|
package/src/menu.ts
CHANGED
|
@@ -68,6 +68,8 @@ export interface SootSimMenuState {
|
|
|
68
68
|
inspectMode: boolean
|
|
69
69
|
devtoolsOpen: boolean
|
|
70
70
|
alwaysShowLiveWebViews: boolean
|
|
71
|
+
// whether "send to box" hands the box the signed-in session it captured
|
|
72
|
+
sendToBoxCarryAuth: boolean
|
|
71
73
|
stayOnTop: boolean
|
|
72
74
|
scaleMode: SootSimScaleMode
|
|
73
75
|
}
|
|
@@ -353,6 +355,12 @@ function debugMenu(state: SootSimMenuState): SootSimMenuDef {
|
|
|
353
355
|
checked: state.alwaysShowLiveWebViews,
|
|
354
356
|
action: 'toggle-live-webviews',
|
|
355
357
|
},
|
|
358
|
+
{
|
|
359
|
+
label: 'Send to Box Carries Sign-In',
|
|
360
|
+
type: 'checkbox',
|
|
361
|
+
checked: state.sendToBoxCarryAuth,
|
|
362
|
+
action: 'toggle-send-to-box-auth',
|
|
363
|
+
},
|
|
356
364
|
{ type: 'separator' },
|
|
357
365
|
{
|
|
358
366
|
label: 'Clear Cache and Reload',
|