peachsim 0.1.527
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +640 -0
- package/cli/app-config.ts +82 -0
- package/cli/app-fonts.ts +388 -0
- package/cli/app-project.ts +59 -0
- package/cli/app-splash.ts +171 -0
- package/cli/app-state-reset.ts +26 -0
- package/cli/auth.ts +184 -0
- package/cli/bin.ts +59 -0
- package/cli/bridge-diagnostics.ts +226 -0
- package/cli/bridge-flow-runner.ts +2806 -0
- package/cli/browser-backend.ts +44 -0
- package/cli/browser-evals.ts +96 -0
- package/cli/cli-update.ts +261 -0
- package/cli/cloud-client.ts +1530 -0
- package/cli/cloud-dispatch.ts +206 -0
- package/cli/cloud-session.ts +227 -0
- package/cli/command-contract.ts +221 -0
- package/cli/command-registry.ts +304 -0
- package/cli/commands/agent-wrapper.ts +1048 -0
- package/cli/commands/agent.ts +439 -0
- package/cli/commands/app-fonts.ts +99 -0
- package/cli/commands/assert.ts +542 -0
- package/cli/commands/auth.ts +71 -0
- package/cli/commands/box/bundle-plane.ts +71 -0
- package/cli/commands/box/checkout-plane.ts +256 -0
- package/cli/commands/box/plane-share.ts +208 -0
- package/cli/commands/box/rnx-command.ts +60 -0
- package/cli/commands/box/search-command.ts +157 -0
- package/cli/commands/box.ts +925 -0
- package/cli/commands/camera.ts +266 -0
- package/cli/commands/cleanup.ts +169 -0
- package/cli/commands/compat.ts +176 -0
- package/cli/commands/config.ts +34 -0
- package/cli/commands/control.ts +2154 -0
- package/cli/commands/cpu-profile.ts +941 -0
- package/cli/commands/daemon-mac-app.ts +165 -0
- package/cli/commands/daemon.ts +800 -0
- package/cli/commands/debug.ts +751 -0
- package/cli/commands/desktop.ts +39 -0
- package/cli/commands/detect.ts +201 -0
- package/cli/commands/detox.ts +481 -0
- package/cli/commands/device.ts +134 -0
- package/cli/commands/diagnose.ts +589 -0
- package/cli/commands/do-chain.ts +408 -0
- package/cli/commands/electron.ts +94 -0
- package/cli/commands/film.ts +379 -0
- package/cli/commands/flow.ts +1240 -0
- package/cli/commands/inspect/actions.ts +516 -0
- package/cli/commands/inspect/core.ts +2086 -0
- package/cli/commands/inspect/count.ts +17 -0
- package/cli/commands/inspect/describe.ts +119 -0
- package/cli/commands/inspect/env.ts +25 -0
- package/cli/commands/inspect/find.ts +169 -0
- package/cli/commands/inspect/get-layout.ts +53 -0
- package/cli/commands/inspect/keyboard.ts +54 -0
- package/cli/commands/inspect/list.ts +175 -0
- package/cli/commands/inspect/memory.ts +215 -0
- package/cli/commands/inspect/redaction.ts +39 -0
- package/cli/commands/inspect/resolve-target.ts +77 -0
- package/cli/commands/inspect/screens.ts +78 -0
- package/cli/commands/inspect/settle.ts +32 -0
- package/cli/commands/inspect/settling.ts +197 -0
- package/cli/commands/inspect/shared.ts +259 -0
- package/cli/commands/inspect/sleep.ts +15 -0
- package/cli/commands/inspect/tree.ts +23 -0
- package/cli/commands/inspect/url.ts +17 -0
- package/cli/commands/inspect/wait-event.ts +211 -0
- package/cli/commands/inspect/wait-idle.ts +25 -0
- package/cli/commands/inspect/wait-ready.ts +87 -0
- package/cli/commands/inspect/wait-selector.ts +59 -0
- package/cli/commands/inspect/wait.ts +32 -0
- package/cli/commands/inspect.ts +4738 -0
- package/cli/commands/install-cli.ts +275 -0
- package/cli/commands/install-desktop.ts +385 -0
- package/cli/commands/login.ts +357 -0
- package/cli/commands/logout.ts +24 -0
- package/cli/commands/maestro-generate.ts +375 -0
- package/cli/commands/maestro.ts +536 -0
- package/cli/commands/mode.ts +58 -0
- package/cli/commands/no-bridge-hint.ts +80 -0
- package/cli/commands/perf.ts +67 -0
- package/cli/commands/permissions.ts +203 -0
- package/cli/commands/platform.ts +410 -0
- package/cli/commands/preview.ts +103 -0
- package/cli/commands/profile.ts +106 -0
- package/cli/commands/react.ts +353 -0
- package/cli/commands/record.ts +1435 -0
- package/cli/commands/report-issue.ts +305 -0
- package/cli/commands/reset.ts +89 -0
- package/cli/commands/runtime.ts +348 -0
- package/cli/commands/screenshot-command.ts +106 -0
- package/cli/commands/screenshot-layers.ts +144 -0
- package/cli/commands/screenshot-mode.ts +38 -0
- package/cli/commands/screenshot.ts +492 -0
- package/cli/commands/screenshots-capture.ts +608 -0
- package/cli/commands/screenshots.ts +127 -0
- package/cli/commands/serve.ts +139 -0
- package/cli/commands/setup.ts +416 -0
- package/cli/commands/shell-boolean-mode.ts +82 -0
- package/cli/commands/skills.ts +468 -0
- package/cli/commands/slides.ts +357 -0
- package/cli/commands/state.ts +94 -0
- package/cli/commands/storage.ts +58 -0
- package/cli/commands/telemetry.ts +55 -0
- package/cli/commands/test.ts +535 -0
- package/cli/commands/three-mode.ts +771 -0
- package/cli/commands/timeline.ts +121 -0
- package/cli/commands/upgrade.ts +167 -0
- package/cli/commands/upload.ts +1203 -0
- package/cli/commands/version.ts +63 -0
- package/cli/commands/welcome.ts +17 -0
- package/cli/commands/what-happened.ts +328 -0
- package/cli/current-sim.ts +217 -0
- package/cli/desktop-companion.ts +315 -0
- package/cli/drivers/electron.ts +70 -0
- package/cli/drivers/index.ts +20 -0
- package/cli/drivers/playwright-provisioning.ts +184 -0
- package/cli/drivers/playwright-sim-host.ts +537 -0
- package/cli/drivers/playwright.ts +209 -0
- package/cli/drivers/registry.ts +65 -0
- package/cli/drivers/types.ts +102 -0
- package/cli/flow-export.ts +55 -0
- package/cli/flow-file.ts +142 -0
- package/cli/flow-live-status.ts +126 -0
- package/cli/flow-session.ts +140 -0
- package/cli/help-core.ts +143 -0
- package/cli/help.ts +44 -0
- package/cli/hidden-runtime-alias.ts +19 -0
- package/cli/hints.ts +214 -0
- package/cli/inspect-notice-state.ts +114 -0
- package/cli/internal-child.ts +176 -0
- package/cli/maestro-js.ts +323 -0
- package/cli/main.ts +704 -0
- package/cli/open-url.ts +8 -0
- package/cli/outbound-endpoints.ts +830 -0
- package/cli/parent-pid.ts +204 -0
- package/cli/parse-args.ts +189 -0
- package/cli/privacy.ts +53 -0
- package/cli/prompt.ts +56 -0
- package/cli/recording-access.ts +108 -0
- package/cli/registry.ts +2 -0
- package/cli/resolve-assets.ts +63 -0
- package/cli/rnx-in-process.ts +98 -0
- package/cli/run-registry.ts +226 -0
- package/cli/run-rnx-core.ts +148 -0
- package/cli/run-rnx.ts +137 -0
- package/cli/runtime-notes.ts +66 -0
- package/cli/runtime-summary.ts +25 -0
- package/cli/secure-file.ts +31 -0
- package/cli/self-invocation.ts +58 -0
- package/cli/send-to-box.ts +109 -0
- package/cli/setup-repository.ts +191 -0
- package/cli/shell-init.ts +98 -0
- package/cli/standalone.ts +4 -0
- package/cli/telemetry.ts +84 -0
- package/cli/ui.ts +68 -0
- package/cli/ws-bridge.ts +1020 -0
- package/detox/attempt-events.cjs +23 -0
- package/detox/colors.ts +54 -0
- package/detox/config-loader.ts +135 -0
- package/detox/element-types.ts +48 -0
- package/detox/expectations.ts +534 -0
- package/detox/gestures.ts +501 -0
- package/detox/index.ts +2694 -0
- package/detox/jest-preset.cjs +29 -0
- package/detox/jest-setup-after-env.cjs +22 -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-lifecycle.ts +290 -0
- package/detox/navigation.ts +43 -0
- package/detox/proof-frame.cjs +114 -0
- package/detox/record-block-execution.cjs +78 -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-lib/agent-daemon-client.cjs +502 -0
- package/dist-lib/agent-events.cjs +48 -0
- package/dist-lib/agent-identity.cjs +53 -0
- package/dist-lib/agent-sessions.cjs +759 -0
- package/dist-lib/attached-projects.cjs +526 -0
- package/dist-lib/auth/shared-session.cjs +208 -0
- package/dist-lib/backend-origin.cjs +88 -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/bridge-contract-input.cjs +451 -0
- package/dist-lib/bridge-contract-input.mjs +414 -0
- package/dist-lib/bridge-contract.cjs +130 -0
- package/dist-lib/bridge-contract.mjs +94 -0
- package/dist-lib/capture-contract.cjs +220 -0
- package/dist-lib/capture-contract.mjs +190 -0
- package/dist-lib/cli-constants.cjs +32 -0
- package/dist-lib/cloud-contract.cjs +194 -0
- package/dist-lib/cloud-contract.mjs +145 -0
- package/dist-lib/cloud.cjs +670 -0
- package/dist-lib/cloud.mjs +639 -0
- package/dist-lib/config.cjs +96 -0
- package/dist-lib/detox/index.cjs +3789 -0
- package/dist-lib/detox/jest-preset.cjs +29 -0
- package/dist-lib/dev-bundle-resolution.cjs +290 -0
- package/dist-lib/home-paths.cjs +638 -0
- package/dist-lib/host/bridge-host.cjs +10903 -0
- package/dist-lib/host/fetch-proxy-handler.cjs +421 -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/replacement-module-handler.cjs +469 -0
- package/dist-lib/host/websocket-proxy.cjs +298 -0
- package/dist-lib/index.cjs +4268 -0
- package/dist-lib/jump-to-source-babel.cjs +93 -0
- package/dist-lib/jump-to-source-native.cjs +112 -0
- package/dist-lib/menu.cjs +646 -0
- package/dist-lib/menu.mjs +604 -0
- package/dist-lib/metro-fingerprint-registry.cjs +186 -0
- package/dist-lib/metro-fingerprint-registry.mjs +156 -0
- package/dist-lib/metro-production-bundle.cjs +329 -0
- package/dist-lib/metro-production-bundle.mjs +295 -0
- package/dist-lib/metro.cjs +904 -0
- package/dist-lib/profiles.cjs +246 -0
- package/dist-lib/public-brand.cjs +39 -0
- package/dist-lib/react-native-host-modules.cjs +51 -0
- package/dist-lib/react-native-host-modules.mjs +25 -0
- package/dist-lib/render-mode.cjs +54 -0
- package/dist-lib/scripts/dev-server-scanner.cjs +1232 -0
- package/dist-lib/sdk.cjs +2433 -0
- package/dist-lib/sdk.mjs +2336 -0
- package/dist-lib/skills.cjs +39132 -0
- package/dist-lib/swift-submit.cjs +92 -0
- package/dist-lib/swift-submit.mjs +65 -0
- package/dist-lib/swift.cjs +1646 -0
- package/dist-lib/vite.cjs +1591 -0
- package/package.json +290 -0
- package/scripts/dev-server-scanner.ts +1291 -0
- package/scripts/optional-demo-registry.ts +113 -0
- package/skills/contrast/SKILL.md +165 -0
- package/skills/rnx-debug/SKILL.md +433 -0
- package/skills/rnx-perf/SKILL.md +399 -0
- package/skills/rnx-setup/SKILL.md +172 -0
- package/skills/rnx-test/SKILL.md +321 -0
- package/skills/rnx-visual/SKILL.md +126 -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 +580 -0
- package/src/app-url.ts +39 -0
- package/src/attached-projects.ts +539 -0
- package/src/auth/shared-session.ts +235 -0
- package/src/backend-origin.ts +70 -0
- package/src/beta.ts +19 -0
- package/src/bridge-constants.ts +175 -0
- package/src/bridge-contract-input.ts +502 -0
- package/src/bridge-contract.ts +558 -0
- package/src/browser-cache.ts +16 -0
- package/src/capture-contract.ts +587 -0
- package/src/cli-constants.ts +1 -0
- package/src/cli-version.ts +40 -0
- package/src/cloud-contract.ts +274 -0
- package/src/cloud.ts +762 -0
- package/src/codex-client.ts +234 -0
- package/src/config.ts +132 -0
- package/src/connect.ts +101 -0
- package/src/dev-bundle-resolution.ts +346 -0
- package/src/dev-server-open.ts +198 -0
- package/src/disk-cleanup.ts +540 -0
- package/src/flow-timeout-scale.ts +15 -0
- package/src/home-paths.ts +806 -0
- package/src/host/agent-host.ts +666 -0
- package/src/host/bridge-host.ts +2788 -0
- package/src/host/fetch-proxy-handler.ts +449 -0
- package/src/host/fetch-proxy-overrides.ts +51 -0
- package/src/host/open-url.ts +89 -0
- package/src/host/plane-host.ts +203 -0
- package/src/host/replacement-module-handler.ts +158 -0
- package/src/host/websocket-proxy.ts +315 -0
- package/src/index.ts +71 -0
- package/src/jump-to-source-babel.ts +135 -0
- package/src/jump-to-source-native.ts +102 -0
- package/src/menu.ts +777 -0
- package/src/metro-fingerprint-registry.ts +302 -0
- package/src/metro-plugin.ts +341 -0
- package/src/metro-production-bundle.ts +471 -0
- package/src/native-dev-bundle-url.ts +118 -0
- package/src/native-seam-manifest.ts +341 -0
- package/src/playwright-host-log.ts +16 -0
- package/src/plist.ts +27 -0
- package/src/poll-until.ts +123 -0
- package/src/profiles.ts +179 -0
- package/src/public-brand.ts +9 -0
- package/src/react-native-host-modules.ts +26 -0
- package/src/render-mode.ts +27 -0
- package/src/rolldown-plugin-swift.ts +240 -0
- package/src/runtime-assets.ts +233 -0
- package/src/runtime-delivery.ts +54 -0
- package/src/screenshots/compose.ts +422 -0
- package/src/screenshots/frame-compose.ts +514 -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 +15 -0
- package/src/settings-bundle.ts +418 -0
- package/src/shell-bridge-identity.ts +15 -0
- package/src/sim-client.ts +697 -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/swift-submit.ts +185 -0
- package/src/swift.ts +7 -0
- package/src/team-machine-prompt.ts +73 -0
- package/src/vite-plugin-one.ts +264 -0
- package/src/vite-plugin-swift.ts +620 -0
- package/src/vite-plugin.ts +1946 -0
- package/src/worklets-babel.ts +250 -0
|
@@ -0,0 +1,408 @@
|
|
|
1
|
+
import { BridgeInputError } from '../../src/bridge-contract-input'
|
|
2
|
+
import type { SimPerformStep } from '../../src/sim-client'
|
|
3
|
+
|
|
4
|
+
interface TargetedDoubleTapAction {
|
|
5
|
+
type: 'targetedDoubleTap'
|
|
6
|
+
id: string
|
|
7
|
+
gapMs: number
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface TargetedLongPressAction {
|
|
11
|
+
type: 'targetedLongPress'
|
|
12
|
+
id: string
|
|
13
|
+
durationMs: number
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type DoChainAction =
|
|
17
|
+
| SimPerformStep
|
|
18
|
+
| TargetedDoubleTapAction
|
|
19
|
+
| TargetedLongPressAction
|
|
20
|
+
|
|
21
|
+
const DO_CHAIN_ACTIONS = new Set([
|
|
22
|
+
'tap',
|
|
23
|
+
'tap-id',
|
|
24
|
+
'tap-text',
|
|
25
|
+
'double-tap',
|
|
26
|
+
'long-press',
|
|
27
|
+
'type',
|
|
28
|
+
'type-into',
|
|
29
|
+
'key',
|
|
30
|
+
'key-sequence',
|
|
31
|
+
'dismiss',
|
|
32
|
+
'scroll',
|
|
33
|
+
'drag',
|
|
34
|
+
'swipe',
|
|
35
|
+
'pinch',
|
|
36
|
+
'touch',
|
|
37
|
+
'sleep',
|
|
38
|
+
])
|
|
39
|
+
|
|
40
|
+
export function hasDoChain(args: string[]): boolean {
|
|
41
|
+
return args.includes('--then')
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function invalidAction(index: number, usage: string): never {
|
|
45
|
+
throw new BridgeInputError(
|
|
46
|
+
`do chain action ${index + 1} has invalid arguments; usage: rnx do ${usage}`,
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function finiteNumber(value: string | undefined, index: number, usage: string): number {
|
|
51
|
+
const parsed = Number(value)
|
|
52
|
+
if (value === undefined || !Number.isFinite(parsed)) invalidAction(index, usage)
|
|
53
|
+
return parsed
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function parseDoChainActions(args: string[]): DoChainAction[] {
|
|
57
|
+
const segments: string[][] = [[]]
|
|
58
|
+
for (const argument of args) {
|
|
59
|
+
if (argument !== '--then') {
|
|
60
|
+
segments[segments.length - 1].push(argument)
|
|
61
|
+
continue
|
|
62
|
+
}
|
|
63
|
+
if (segments[segments.length - 1].length === 0) {
|
|
64
|
+
throw new BridgeInputError('do chain contains an empty action')
|
|
65
|
+
}
|
|
66
|
+
segments.push([])
|
|
67
|
+
}
|
|
68
|
+
if (segments[segments.length - 1].length === 0) {
|
|
69
|
+
throw new BridgeInputError('do chain cannot end with --then')
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return segments.flatMap((segment, index): DoChainAction[] => {
|
|
73
|
+
const [action, ...values] = segment
|
|
74
|
+
if (!action) throw new BridgeInputError('do chain contains an empty action')
|
|
75
|
+
if (!DO_CHAIN_ACTIONS.has(action)) {
|
|
76
|
+
throw new BridgeInputError(
|
|
77
|
+
`do chain action ${index + 1} cannot batch ${JSON.stringify(action)}; run it as a separate rnx do command`,
|
|
78
|
+
)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
switch (action) {
|
|
82
|
+
case 'tap': {
|
|
83
|
+
if (values.length === 1 && !Number.isFinite(Number(values[0]))) {
|
|
84
|
+
return [{ type: 'tapId', id: values[0] }]
|
|
85
|
+
}
|
|
86
|
+
if (values.length !== 2) invalidAction(index, 'tap <testid> | <x> <y>')
|
|
87
|
+
return [
|
|
88
|
+
{
|
|
89
|
+
type: 'tap',
|
|
90
|
+
x: finiteNumber(values[0], index, 'tap <testid> | <x> <y>'),
|
|
91
|
+
y: finiteNumber(values[1], index, 'tap <testid> | <x> <y>'),
|
|
92
|
+
},
|
|
93
|
+
]
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
case 'tap-id':
|
|
97
|
+
if (values.length !== 1) invalidAction(index, 'tap-id <id>')
|
|
98
|
+
return [{ type: 'tapId', id: values[0] }]
|
|
99
|
+
|
|
100
|
+
case 'tap-text': {
|
|
101
|
+
const text = values.join(' ')
|
|
102
|
+
if (!text) invalidAction(index, 'tap-text <text>')
|
|
103
|
+
return [{ type: 'tapText', text }]
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
case 'double-tap': {
|
|
107
|
+
const usage = 'double-tap <testid> [gapMs] | <x> <y> [gapMs]'
|
|
108
|
+
if (values.length > 0 && !Number.isFinite(Number(values[0]))) {
|
|
109
|
+
if (values.length > 2) invalidAction(index, usage)
|
|
110
|
+
return [
|
|
111
|
+
{
|
|
112
|
+
type: 'targetedDoubleTap',
|
|
113
|
+
id: values[0],
|
|
114
|
+
gapMs:
|
|
115
|
+
values.length === 2
|
|
116
|
+
? Math.max(0, Math.round(finiteNumber(values[1], index, usage)))
|
|
117
|
+
: 80,
|
|
118
|
+
},
|
|
119
|
+
]
|
|
120
|
+
}
|
|
121
|
+
if (values.length < 2 || values.length > 3) invalidAction(index, usage)
|
|
122
|
+
return [
|
|
123
|
+
{
|
|
124
|
+
type: 'doubleTap',
|
|
125
|
+
x: finiteNumber(values[0], index, usage),
|
|
126
|
+
y: finiteNumber(values[1], index, usage),
|
|
127
|
+
gapMs:
|
|
128
|
+
values.length === 3
|
|
129
|
+
? Math.max(0, Math.round(finiteNumber(values[2], index, usage)))
|
|
130
|
+
: 80,
|
|
131
|
+
},
|
|
132
|
+
]
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
case 'long-press': {
|
|
136
|
+
const usage = 'long-press <testid> [durationMs] | <x> <y> [durationMs]'
|
|
137
|
+
if (values.length > 0 && !Number.isFinite(Number(values[0]))) {
|
|
138
|
+
if (values.length > 2) invalidAction(index, usage)
|
|
139
|
+
return [
|
|
140
|
+
{
|
|
141
|
+
type: 'targetedLongPress',
|
|
142
|
+
id: values[0],
|
|
143
|
+
durationMs:
|
|
144
|
+
values.length === 2
|
|
145
|
+
? Math.max(0, Math.round(finiteNumber(values[1], index, usage)))
|
|
146
|
+
: 600,
|
|
147
|
+
},
|
|
148
|
+
]
|
|
149
|
+
}
|
|
150
|
+
if (values.length < 2 || values.length > 3) invalidAction(index, usage)
|
|
151
|
+
return [
|
|
152
|
+
{
|
|
153
|
+
type: 'longPress',
|
|
154
|
+
x: finiteNumber(values[0], index, usage),
|
|
155
|
+
y: finiteNumber(values[1], index, usage),
|
|
156
|
+
durationMs:
|
|
157
|
+
values.length === 3
|
|
158
|
+
? Math.max(0, Math.round(finiteNumber(values[2], index, usage)))
|
|
159
|
+
: 600,
|
|
160
|
+
},
|
|
161
|
+
]
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
case 'type': {
|
|
165
|
+
const text = values.join(' ')
|
|
166
|
+
if (!text) invalidAction(index, 'type <text>')
|
|
167
|
+
return [{ type: 'type', text }]
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
case 'type-into': {
|
|
171
|
+
const text = values.slice(1).join(' ')
|
|
172
|
+
if (!values[0] || !text) invalidAction(index, 'type-into <id> <text>')
|
|
173
|
+
return [
|
|
174
|
+
{ type: 'tapId', id: values[0] },
|
|
175
|
+
{ type: 'type', text },
|
|
176
|
+
]
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
case 'key':
|
|
180
|
+
if (values.length !== 1) invalidAction(index, 'key <name>')
|
|
181
|
+
return [{ type: 'key', key: values[0] }]
|
|
182
|
+
|
|
183
|
+
case 'key-sequence':
|
|
184
|
+
if (values.length === 0) invalidAction(index, 'key-sequence <key> [<key> ...]')
|
|
185
|
+
return values.map((key) => ({ type: 'key', key }))
|
|
186
|
+
|
|
187
|
+
case 'dismiss':
|
|
188
|
+
if (values.length !== 0) invalidAction(index, 'dismiss')
|
|
189
|
+
return [{ type: 'dismissKeyboard' }]
|
|
190
|
+
|
|
191
|
+
case 'scroll': {
|
|
192
|
+
const usage = 'scroll <id> <x> <y>'
|
|
193
|
+
if (values.length !== 3) invalidAction(index, usage)
|
|
194
|
+
return [
|
|
195
|
+
{
|
|
196
|
+
type: 'scroll',
|
|
197
|
+
id: values[0],
|
|
198
|
+
x: finiteNumber(values[1], index, usage),
|
|
199
|
+
y: finiteNumber(values[2], index, usage),
|
|
200
|
+
animated: false,
|
|
201
|
+
},
|
|
202
|
+
]
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
case 'drag':
|
|
206
|
+
case 'swipe': {
|
|
207
|
+
const usage = `${action} <x1> <y1> <x2> <y2> [steps] [stepMs]`
|
|
208
|
+
if (values.length < 4 || values.length > 6) invalidAction(index, usage)
|
|
209
|
+
const defaultSteps = action === 'swipe' ? 10 : 12
|
|
210
|
+
const defaultStepMs = action === 'swipe' ? 8 : 16
|
|
211
|
+
return [
|
|
212
|
+
{
|
|
213
|
+
type: 'drag',
|
|
214
|
+
fromX: finiteNumber(values[0], index, usage),
|
|
215
|
+
fromY: finiteNumber(values[1], index, usage),
|
|
216
|
+
toX: finiteNumber(values[2], index, usage),
|
|
217
|
+
toY: finiteNumber(values[3], index, usage),
|
|
218
|
+
steps:
|
|
219
|
+
values.length >= 5
|
|
220
|
+
? Math.max(1, Math.round(finiteNumber(values[4], index, usage)))
|
|
221
|
+
: defaultSteps,
|
|
222
|
+
stepMs:
|
|
223
|
+
values.length === 6
|
|
224
|
+
? Math.max(0, Math.round(finiteNumber(values[5], index, usage)))
|
|
225
|
+
: defaultStepMs,
|
|
226
|
+
},
|
|
227
|
+
]
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
case 'pinch': {
|
|
231
|
+
const usage = "pinch <x1> <y1> <x2> <y2> <x1'> <y1'> <x2'> <y2'> [steps] [stepMs]"
|
|
232
|
+
if (values.length < 8 || values.length > 10) invalidAction(index, usage)
|
|
233
|
+
return [
|
|
234
|
+
{
|
|
235
|
+
type: 'pinch',
|
|
236
|
+
fromX1: finiteNumber(values[0], index, usage),
|
|
237
|
+
fromY1: finiteNumber(values[1], index, usage),
|
|
238
|
+
fromX2: finiteNumber(values[2], index, usage),
|
|
239
|
+
fromY2: finiteNumber(values[3], index, usage),
|
|
240
|
+
toX1: finiteNumber(values[4], index, usage),
|
|
241
|
+
toY1: finiteNumber(values[5], index, usage),
|
|
242
|
+
toX2: finiteNumber(values[6], index, usage),
|
|
243
|
+
toY2: finiteNumber(values[7], index, usage),
|
|
244
|
+
steps:
|
|
245
|
+
values.length >= 9
|
|
246
|
+
? Math.max(1, Math.round(finiteNumber(values[8], index, usage)))
|
|
247
|
+
: 12,
|
|
248
|
+
stepMs:
|
|
249
|
+
values.length === 10
|
|
250
|
+
? Math.max(0, Math.round(finiteNumber(values[9], index, usage)))
|
|
251
|
+
: 16,
|
|
252
|
+
},
|
|
253
|
+
]
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
case 'touch': {
|
|
257
|
+
const usage = 'touch <down|move|up|cancel> <x> <y> [pointerId]'
|
|
258
|
+
if (values.length < 3 || values.length > 4) invalidAction(index, usage)
|
|
259
|
+
const phase = values[0]
|
|
260
|
+
if (
|
|
261
|
+
phase !== 'down' &&
|
|
262
|
+
phase !== 'move' &&
|
|
263
|
+
phase !== 'up' &&
|
|
264
|
+
phase !== 'cancel'
|
|
265
|
+
) {
|
|
266
|
+
invalidAction(index, usage)
|
|
267
|
+
}
|
|
268
|
+
const pointerId =
|
|
269
|
+
values.length === 4
|
|
270
|
+
? Math.max(1, Math.round(finiteNumber(values[3], index, usage)))
|
|
271
|
+
: 999
|
|
272
|
+
if (phase === 'cancel') return [{ type: 'touchCancel', pointerId }]
|
|
273
|
+
return [
|
|
274
|
+
{
|
|
275
|
+
type:
|
|
276
|
+
phase === 'down' ? 'touchDown' : phase === 'move' ? 'touchMove' : 'touchUp',
|
|
277
|
+
x: finiteNumber(values[1], index, usage),
|
|
278
|
+
y: finiteNumber(values[2], index, usage),
|
|
279
|
+
pointerId,
|
|
280
|
+
},
|
|
281
|
+
]
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
case 'sleep': {
|
|
285
|
+
const usage = 'sleep [seconds]'
|
|
286
|
+
if (values.length > 1) invalidAction(index, usage)
|
|
287
|
+
const seconds = values.length === 1 ? finiteNumber(values[0], index, usage) : 0.5
|
|
288
|
+
if (seconds < 0) invalidAction(index, usage)
|
|
289
|
+
return [{ type: 'wait', ms: Math.round(seconds * 1000) }]
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
default:
|
|
293
|
+
throw new BridgeInputError(
|
|
294
|
+
`do chain action ${index + 1} cannot batch ${JSON.stringify(action)}`,
|
|
295
|
+
)
|
|
296
|
+
}
|
|
297
|
+
})
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
export async function runDoChain(
|
|
301
|
+
args: string[],
|
|
302
|
+
opts: { port?: number } = {},
|
|
303
|
+
): Promise<number> {
|
|
304
|
+
const [connectModule, simClientModule, bridgeModule, envModule, targetModule] =
|
|
305
|
+
await Promise.all([
|
|
306
|
+
import('../../src/connect'),
|
|
307
|
+
import('../../src/sim-client'),
|
|
308
|
+
import('../ws-bridge'),
|
|
309
|
+
import('./inspect/env'),
|
|
310
|
+
import('./inspect/resolve-target'),
|
|
311
|
+
])
|
|
312
|
+
const { connect } = connectModule
|
|
313
|
+
const { SimPerformError } = simClientModule
|
|
314
|
+
const { checkSimHealth, parseBridgeCliArgs } = bridgeModule
|
|
315
|
+
const { isAgentEnv } = envModule
|
|
316
|
+
const { resolveTargetCoords } = targetModule
|
|
317
|
+
const wantsJson = args.includes('--json')
|
|
318
|
+
const skipSettle = args.includes('--no-wait') || process.env.RNX_NO_AUTO_WAIT === '1'
|
|
319
|
+
const parsed = parseBridgeCliArgs(args, {
|
|
320
|
+
port: opts.port,
|
|
321
|
+
commandTimeoutMs: 30_000,
|
|
322
|
+
stripBooleanFlags: ['--json', '--no-wait'],
|
|
323
|
+
})
|
|
324
|
+
if (!Number.isFinite(parsed.commandTimeoutMs) || parsed.commandTimeoutMs <= 0) {
|
|
325
|
+
console.error(' do chain: --timeout must be a positive number')
|
|
326
|
+
return 1
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
let actions: DoChainAction[]
|
|
330
|
+
try {
|
|
331
|
+
actions = parseDoChainActions(parsed.positional)
|
|
332
|
+
} catch (error) {
|
|
333
|
+
console.error(` do chain: ${error instanceof Error ? error.message : error}`)
|
|
334
|
+
return 1
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
let sim: Awaited<ReturnType<typeof connect>> | null = null
|
|
338
|
+
try {
|
|
339
|
+
sim = await connect({
|
|
340
|
+
port: parsed.wsPort,
|
|
341
|
+
sim: parsed.simIdSource === 'flag' ? parsed.simId : undefined,
|
|
342
|
+
timeoutMs: parsed.commandTimeoutMs,
|
|
343
|
+
})
|
|
344
|
+
await checkSimHealth(sim)
|
|
345
|
+
|
|
346
|
+
const steps: SimPerformStep[] = []
|
|
347
|
+
for (const action of actions) {
|
|
348
|
+
if (action.type !== 'targetedDoubleTap' && action.type !== 'targetedLongPress') {
|
|
349
|
+
steps.push(action)
|
|
350
|
+
continue
|
|
351
|
+
}
|
|
352
|
+
const target = await resolveTargetCoords(sim, { mode: 'testid', value: action.id })
|
|
353
|
+
if (!target) {
|
|
354
|
+
throw new BridgeInputError(
|
|
355
|
+
`do chain could not find testID ${JSON.stringify(action.id)}`,
|
|
356
|
+
)
|
|
357
|
+
}
|
|
358
|
+
steps.push(
|
|
359
|
+
action.type === 'targetedDoubleTap'
|
|
360
|
+
? {
|
|
361
|
+
type: 'doubleTap',
|
|
362
|
+
x: target.x,
|
|
363
|
+
y: target.y,
|
|
364
|
+
gapMs: action.gapMs,
|
|
365
|
+
}
|
|
366
|
+
: {
|
|
367
|
+
type: 'longPress',
|
|
368
|
+
x: target.x,
|
|
369
|
+
y: target.y,
|
|
370
|
+
durationMs: action.durationMs,
|
|
371
|
+
},
|
|
372
|
+
)
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
const result = await sim.perform(steps, { timeoutMs: parsed.commandTimeoutMs })
|
|
376
|
+
if (!skipSettle) {
|
|
377
|
+
try {
|
|
378
|
+
const budgetMs = isAgentEnv() ? 400 : 200
|
|
379
|
+
const settled = await sim.settle({ maxMs: budgetMs })
|
|
380
|
+
if (!settled.settled) {
|
|
381
|
+
process.stderr.write(
|
|
382
|
+
` ⚠ auto-wait timed out after ${settled.elapsed ?? budgetMs}ms. next command may see mid-animation state. use \`rnx do settle\` for a longer wait.\n`,
|
|
383
|
+
)
|
|
384
|
+
}
|
|
385
|
+
} catch {}
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
if (wantsJson) {
|
|
389
|
+
console.log(JSON.stringify(result))
|
|
390
|
+
} else {
|
|
391
|
+
console.log(
|
|
392
|
+
` completed ${result.completed} batched ${result.completed === 1 ? 'step' : 'steps'} in ${result.durationMs}ms`,
|
|
393
|
+
)
|
|
394
|
+
}
|
|
395
|
+
return 0
|
|
396
|
+
} catch (error) {
|
|
397
|
+
if (error instanceof SimPerformError && wantsJson) {
|
|
398
|
+
console.log(JSON.stringify(error.result))
|
|
399
|
+
} else {
|
|
400
|
+
console.error(
|
|
401
|
+
` do chain failed: ${error instanceof Error ? error.message : error}`,
|
|
402
|
+
)
|
|
403
|
+
}
|
|
404
|
+
return 1
|
|
405
|
+
} finally {
|
|
406
|
+
sim?.close()
|
|
407
|
+
}
|
|
408
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// rnx desktop — launch the installed desktop companion via the
|
|
2
|
+
// electron driver. the driver wraps findDesktopCompanion +
|
|
3
|
+
// launchDesktopCompanion, so this command is a thin CLI surface that
|
|
4
|
+
// parses options, prompts for install, and delegates everything else.
|
|
5
|
+
|
|
6
|
+
import { ensureProfile } from '../../src/profiles'
|
|
7
|
+
import { findDesktopCompanion } from '../desktop-companion'
|
|
8
|
+
import { electronDriver } from '../drivers'
|
|
9
|
+
import { confirm } from '../prompt'
|
|
10
|
+
import { rnxExit } from '../run-rnx'
|
|
11
|
+
import { buildShellUrl } from './control'
|
|
12
|
+
import { printMissingCompanionHint } from './no-bridge-hint'
|
|
13
|
+
|
|
14
|
+
interface ElectronOptions {
|
|
15
|
+
port?: number
|
|
16
|
+
device?: string
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function parseInlinePort(args: string[]): number | undefined {
|
|
20
|
+
const portIdx = args.indexOf('--port')
|
|
21
|
+
if (portIdx < 0) return undefined
|
|
22
|
+
const raw = args[portIdx + 1]
|
|
23
|
+
const port = raw ? Number(raw) : Number.NaN
|
|
24
|
+
if (!Number.isInteger(port) || port <= 0) {
|
|
25
|
+
console.error(` invalid --port value: ${raw || '(missing)'}`)
|
|
26
|
+
rnxExit(1)
|
|
27
|
+
}
|
|
28
|
+
return port
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export async function resolveElectronLaunchUrl(
|
|
32
|
+
args: string[],
|
|
33
|
+
opts: ElectronOptions,
|
|
34
|
+
): Promise<string | undefined> {
|
|
35
|
+
const targetPort = parseInlinePort(args) ?? opts.port
|
|
36
|
+
return targetPort ? buildShellUrl(String(targetPort)) : undefined
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export async function runElectron(args: string[], opts: ElectronOptions) {
|
|
40
|
+
if (args.includes('--help') || args.includes('-h')) {
|
|
41
|
+
console.log(`
|
|
42
|
+
rnx desktop — launch the desktop companion
|
|
43
|
+
|
|
44
|
+
usage:
|
|
45
|
+
rnx desktop [options]
|
|
46
|
+
|
|
47
|
+
options:
|
|
48
|
+
--port <number> connect to running dev server on this port
|
|
49
|
+
--profile <id> launch with an isolated persistent storage profile
|
|
50
|
+
--ephemeral launch with a temporary isolated storage profile
|
|
51
|
+
|
|
52
|
+
examples:
|
|
53
|
+
rnx desktop
|
|
54
|
+
rnx desktop --port 5173
|
|
55
|
+
rnx desktop --profile qa
|
|
56
|
+
`)
|
|
57
|
+
rnxExit(0)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const profileArg = args.find((_, i) => args[i - 1] === '--profile')
|
|
61
|
+
const ephemeralProfile = args.includes('--ephemeral')
|
|
62
|
+
if (profileArg && ephemeralProfile) {
|
|
63
|
+
console.error(' rnx desktop: --profile cannot be combined with --ephemeral')
|
|
64
|
+
rnxExit(1)
|
|
65
|
+
}
|
|
66
|
+
const profileId = profileArg ? ensureProfile(profileArg).id : undefined
|
|
67
|
+
let install = findDesktopCompanion()
|
|
68
|
+
if (!install) {
|
|
69
|
+
printMissingCompanionHint()
|
|
70
|
+
const canPrompt =
|
|
71
|
+
process.stdin.isTTY && process.env.CI !== '1' && process.env.RNX_NO_PROMPT !== '1'
|
|
72
|
+
if (canPrompt && (await confirm('run rnx desktop install now?', true))) {
|
|
73
|
+
console.log()
|
|
74
|
+
const { runInstallDesktop } = await import('./install-desktop')
|
|
75
|
+
await runInstallDesktop(['--yes'])
|
|
76
|
+
install = findDesktopCompanion()
|
|
77
|
+
}
|
|
78
|
+
if (!install) rnxExit(1)
|
|
79
|
+
}
|
|
80
|
+
console.log(` launching ${install.path}`)
|
|
81
|
+
|
|
82
|
+
const url = await resolveElectronLaunchUrl(args, opts)
|
|
83
|
+
const result = await electronDriver.launch({
|
|
84
|
+
url,
|
|
85
|
+
device: opts.device,
|
|
86
|
+
profileId,
|
|
87
|
+
ephemeralProfile,
|
|
88
|
+
})
|
|
89
|
+
if (!result.launched) {
|
|
90
|
+
console.error(` ${result.message}`)
|
|
91
|
+
rnxExit(1)
|
|
92
|
+
}
|
|
93
|
+
console.log(` ${result.message}`)
|
|
94
|
+
}
|