rnxsim 0.1.375 → 0.1.377
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/README.md +28 -25
- package/cli/app-config.ts +9 -12
- package/cli/app-fonts.ts +3 -3
- package/cli/app-project.ts +8 -8
- package/cli/auth.ts +7 -9
- package/cli/bin.ts +16 -31
- package/cli/bridge-flow-runner.ts +3 -3
- package/cli/browser-backend.ts +44 -0
- package/cli/command-contract.ts +221 -0
- package/cli/command-registry.ts +291 -0
- package/cli/commands/agent-wrapper.ts +2 -2
- package/cli/commands/app-fonts.ts +2 -2
- package/cli/commands/assert.ts +3 -3
- package/cli/commands/auth.ts +1 -1
- package/cli/commands/box/cloud-box.ts +1 -1
- package/cli/commands/box/plane-share.ts +2 -2
- package/cli/commands/box.ts +4 -6
- package/cli/commands/compat.ts +1 -1
- package/cli/commands/config.ts +2 -2
- package/cli/commands/control.ts +42 -28
- package/cli/commands/cpu-profile.ts +7 -7
- package/cli/commands/daemon-mac-app.ts +7 -7
- package/cli/commands/daemon.ts +10 -10
- package/cli/commands/debug.ts +11 -11
- package/cli/commands/detox.ts +13 -13
- package/cli/commands/diagnose.ts +6 -6
- package/cli/commands/do-chain.ts +1 -2
- package/cli/commands/electron.ts +1 -3
- package/cli/commands/film.ts +3 -3
- package/cli/commands/flow.ts +43 -43
- package/cli/commands/inspect/count.ts +1 -1
- package/cli/commands/inspect/describe.ts +1 -1
- package/cli/commands/inspect/env.ts +2 -2
- package/cli/commands/inspect/get-layout.ts +1 -1
- package/cli/commands/inspect/keyboard.ts +1 -1
- package/cli/commands/inspect/list.ts +1 -1
- package/cli/commands/inspect/memory.ts +1 -1
- package/cli/commands/inspect/resolve-target.ts +1 -1
- package/cli/commands/inspect/screens.ts +1 -1
- package/cli/commands/inspect/tree.ts +1 -1
- package/cli/commands/inspect/url.ts +1 -1
- package/cli/commands/inspect/wait-event.ts +5 -5
- package/cli/commands/inspect.ts +34 -34
- package/cli/commands/install-desktop.ts +3 -3
- package/cli/commands/login.ts +6 -6
- package/cli/commands/maestro-generate.ts +5 -5
- package/cli/commands/maestro.ts +5 -5
- package/cli/commands/profile.ts +1 -1
- package/cli/commands/record.ts +9 -9
- package/cli/commands/runtime.ts +18 -18
- package/cli/commands/screenshot-command.ts +1 -1
- package/cli/commands/screenshot-layers.ts +5 -5
- package/cli/commands/screenshot-mode.ts +1 -1
- package/cli/commands/screenshot.ts +8 -8
- package/cli/commands/screenshots-capture.ts +5 -5
- package/cli/commands/serve.ts +3 -3
- package/cli/commands/setup.ts +20 -12
- package/cli/commands/skills.ts +5 -5
- package/cli/commands/slides.ts +1 -1
- package/cli/commands/telemetry.ts +1 -1
- package/cli/commands/three-mode.ts +1 -1
- package/cli/commands/timeline.ts +8 -8
- package/cli/commands/upgrade.ts +116 -131
- package/cli/commands/upload.ts +12 -12
- package/cli/commands/version.ts +7 -7
- package/cli/commands/what-happened.ts +9 -9
- package/cli/current-sim.ts +3 -3
- package/cli/desktop-companion.ts +1 -1
- package/cli/drivers/playwright.ts +9 -9
- package/cli/drivers/registry.ts +1 -1
- package/cli/drivers/types.ts +1 -1
- package/cli/flow-file.ts +2 -2
- package/cli/flow-session.ts +1 -1
- package/cli/help-core.ts +136 -0
- package/cli/help.ts +17 -53
- package/cli/hints.ts +5 -5
- package/cli/inspect-notice-state.ts +1 -1
- package/cli/maestro-js.ts +1 -1
- package/cli/outbound-endpoints.ts +23 -5
- package/cli/parse-args.ts +19 -66
- package/cli/recording-access.ts +1 -1
- package/cli/registry.ts +1 -0
- package/cli/run-registry.ts +1 -1
- package/cli/run-rnx-core.ts +148 -0
- package/cli/run-rnx.ts +6 -9
- package/cli/runtime-notes.ts +3 -3
- package/cli/standalone.ts +4 -0
- package/cli/ws-bridge.ts +8 -8
- package/detox/config-loader.ts +2 -2
- package/detox/index.ts +8 -8
- package/detox/jest-preset.cjs +1 -1
- package/detox/navigation.ts +2 -2
- package/dist-lib/agent-daemon-client.cjs +5 -5
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/agent-identity.cjs +2 -2
- package/dist-lib/agent-sessions.cjs +10 -10
- package/dist-lib/attached-projects.cjs +6 -6
- package/dist-lib/auth/shared-session.cjs +6 -6
- 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/cli-constants.cjs +1 -1
- package/dist-lib/config.cjs +25 -25
- package/dist-lib/detox/index.cjs +9 -9
- package/dist-lib/detox/jest-preset.cjs +1 -1
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/home-paths.cjs +29 -29
- package/dist-lib/host/bridge-host.cjs +274 -181
- 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 +1 -1
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +14 -14
- package/dist-lib/jump-to-source-babel.cjs +1 -1
- package/dist-lib/menu.cjs +1 -1
- package/dist-lib/menu.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 +8 -8
- package/dist-lib/profiles.cjs +12 -12
- 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 +25 -11
- package/dist-lib/sdk.cjs +1 -1
- package/dist-lib/sdk.mjs +1 -1
- package/dist-lib/skills.cjs +470 -322
- package/dist-lib/vite.cjs +9 -9
- package/package.json +4 -11
- package/scripts/dev-server-scanner.ts +25 -7
- package/scripts/optional-demo-registry.ts +1 -1
- package/skills/contrast/SKILL.md +3 -3
- package/skills/rnx-debug/SKILL.md +1 -1
- package/skills/rnx-test/SKILL.md +2 -2
- package/src/agent-identity.ts +1 -1
- package/src/agent-sessions.ts +7 -5
- package/src/cli-version.ts +12 -4
- package/src/config.ts +26 -28
- package/src/disk-cleanup.ts +11 -11
- package/src/home-paths.ts +28 -28
- package/src/host/bridge-host.ts +16 -16
- package/src/metro-plugin.ts +2 -2
- package/src/profiles.ts +2 -2
- package/src/runtime-assets.ts +7 -7
- package/src/runtime-delivery.ts +13 -13
- package/src/screenshots/orchestrate.ts +1 -1
- package/src/screenshots/schema.ts +2 -2
- package/src/skills/builtin/a11y-review.ts +2 -2
- package/src/skills/builtin/compat-check.ts +2 -2
- package/src/skills/builtin/maestro-test.ts +2 -2
- package/src/skills/builtin/perf-profile.ts +2 -2
- package/src/skills/builtin/screenshot-all.ts +2 -2
- package/src/skills/builtin/visual-diff.ts +2 -2
- package/src/skills/registry.ts +8 -8
- package/src/skills/types.ts +1 -1
- package/src/vite-plugin-one.ts +3 -3
- package/src/vite-plugin.ts +15 -2
- package/dist-cli/bin.js +0 -15
- package/dist-cli/chunks/agent-JJN7U6FR.js +0 -48
- package/dist-cli/chunks/agent-wrapper-AVVUJ3WF.js +0 -17
- package/dist-cli/chunks/app-fonts-QJ22CNAZ.js +0 -4
- package/dist-cli/chunks/assert-PZZKIY3K.js +0 -49
- package/dist-cli/chunks/auth-5AVDJO33.js +0 -12
- package/dist-cli/chunks/beta-PFRGP266.js +0 -4
- package/dist-cli/chunks/box-ILC2O7ZO.js +0 -1730
- package/dist-cli/chunks/camera-J3V62PP7.js +0 -33
- package/dist-cli/chunks/chunk-25KRGDZT.js +0 -4
- package/dist-cli/chunks/chunk-2BRBFLWA.js +0 -38
- package/dist-cli/chunks/chunk-2GXNAZHB.js +0 -74
- package/dist-cli/chunks/chunk-2IUMRRYV.js +0 -7
- package/dist-cli/chunks/chunk-4ALPWIMP.js +0 -10
- package/dist-cli/chunks/chunk-4CEZZKRY.js +0 -4
- package/dist-cli/chunks/chunk-4EUKOIAV.js +0 -4
- package/dist-cli/chunks/chunk-4IKE4YUS.js +0 -32
- package/dist-cli/chunks/chunk-4ZXR2M3D.js +0 -4
- package/dist-cli/chunks/chunk-5CGJFU27.js +0 -7
- package/dist-cli/chunks/chunk-5HHWECGT.js +0 -4
- package/dist-cli/chunks/chunk-5PZVYF42.js +0 -312
- package/dist-cli/chunks/chunk-7NCPUZ52.js +0 -27
- package/dist-cli/chunks/chunk-7OSIJCBR.js +0 -107
- package/dist-cli/chunks/chunk-AQ5TMOAI.js +0 -4
- package/dist-cli/chunks/chunk-BQCEI37V.js +0 -5
- package/dist-cli/chunks/chunk-C6B5FOP3.js +0 -4
- package/dist-cli/chunks/chunk-CCMZSHJB.js +0 -71
- package/dist-cli/chunks/chunk-CX7VCKAT.js +0 -14
- package/dist-cli/chunks/chunk-DQUPSAHE.js +0 -4
- package/dist-cli/chunks/chunk-DSD2UBZI.js +0 -4
- package/dist-cli/chunks/chunk-EWPAI4MO.js +0 -7
- package/dist-cli/chunks/chunk-EZXV6U2N.js +0 -497
- package/dist-cli/chunks/chunk-F5F7FIPM.js +0 -6
- package/dist-cli/chunks/chunk-FUTYK55H.js +0 -30
- package/dist-cli/chunks/chunk-FW6AN7I2.js +0 -3
- package/dist-cli/chunks/chunk-FZDRA7Z4.js +0 -4
- package/dist-cli/chunks/chunk-GDLE4NIV.js +0 -4
- package/dist-cli/chunks/chunk-GEX7RVHY.js +0 -5
- package/dist-cli/chunks/chunk-H4MYYOYJ.js +0 -5
- package/dist-cli/chunks/chunk-HEV7BAPE.js +0 -11
- package/dist-cli/chunks/chunk-HNDWYCND.js +0 -506
- package/dist-cli/chunks/chunk-HNPHODBD.js +0 -4
- package/dist-cli/chunks/chunk-HWDVC6YA.js +0 -11
- package/dist-cli/chunks/chunk-JOHJZUGG.js +0 -4
- package/dist-cli/chunks/chunk-JWUDT4QK.js +0 -5
- package/dist-cli/chunks/chunk-K7QQWKGE.js +0 -4
- package/dist-cli/chunks/chunk-LAOKTKT4.js +0 -4
- package/dist-cli/chunks/chunk-LD7I266X.js +0 -24
- package/dist-cli/chunks/chunk-LMHBU5LZ.js +0 -4
- package/dist-cli/chunks/chunk-LSOGXSDV.js +0 -535
- package/dist-cli/chunks/chunk-MP2GPO4T.js +0 -4
- package/dist-cli/chunks/chunk-MXJ2UWRV.js +0 -4
- package/dist-cli/chunks/chunk-OJNKRIZF.js +0 -15
- package/dist-cli/chunks/chunk-PBOWUNXO.js +0 -4
- package/dist-cli/chunks/chunk-PNRJFHX4.js +0 -4
- package/dist-cli/chunks/chunk-QJQOK34O.js +0 -28
- package/dist-cli/chunks/chunk-RLCQLMFF.js +0 -142
- package/dist-cli/chunks/chunk-S65CK3RI.js +0 -9
- package/dist-cli/chunks/chunk-SWBUNMQS.js +0 -4
- package/dist-cli/chunks/chunk-SXBFGGAM.js +0 -4
- package/dist-cli/chunks/chunk-T4ISWS5H.js +0 -4
- package/dist-cli/chunks/chunk-TPPVAA7Z.js +0 -5
- package/dist-cli/chunks/chunk-USM3P74H.js +0 -4
- package/dist-cli/chunks/chunk-V4EJJHF5.js +0 -4
- package/dist-cli/chunks/chunk-V7RGRZOL.js +0 -423
- package/dist-cli/chunks/chunk-XUBV77WH.js +0 -130
- package/dist-cli/chunks/chunk-XYSDYGKC.js +0 -4
- package/dist-cli/chunks/chunk-YNHRSDVG.js +0 -5
- package/dist-cli/chunks/chunk-YX52RJKO.js +0 -4
- package/dist-cli/chunks/chunk-Z5O5H4O7.js +0 -99
- package/dist-cli/chunks/chunk-Z6LOIW46.js +0 -7
- package/dist-cli/chunks/chunk-ZXFVBYJY.js +0 -5
- package/dist-cli/chunks/cleanup-KPUW4SFK.js +0 -25
- package/dist-cli/chunks/cli-version-APGT6GAT.js +0 -4
- package/dist-cli/chunks/compat-XXRFD2TW.js +0 -23
- package/dist-cli/chunks/config-DDMFDQ7F.js +0 -13
- package/dist-cli/chunks/connect-IPG47YXM.js +0 -4
- package/dist-cli/chunks/control-O22Z3UJ5.js +0 -4
- package/dist-cli/chunks/daemon-PADUIMJV.js +0 -4
- package/dist-cli/chunks/debug-MYIP46TM.js +0 -200
- package/dist-cli/chunks/desktop-ENFFBQAA.js +0 -31
- package/dist-cli/chunks/detox-J5WVK6OH.js +0 -52
- package/dist-cli/chunks/device-RAVQVL75.js +0 -18
- package/dist-cli/chunks/diagnose-PJMPXKJY.js +0 -43
- package/dist-cli/chunks/disk-cleanup-YLAY445J.js +0 -4
- package/dist-cli/chunks/do-chain-UBE7GIOU.js +0 -5
- package/dist-cli/chunks/drivers-ZFNX3T5Z.js +0 -4
- package/dist-cli/chunks/env-Y5XJSNRD.js +0 -4
- package/dist-cli/chunks/film-W3V6VURB.js +0 -74
- package/dist-cli/chunks/flow-VMLI7BYM.js +0 -4
- package/dist-cli/chunks/help-PKZCWHJJ.js +0 -4
- package/dist-cli/chunks/hidden-runtime-alias-S5DJ7EDF.js +0 -4
- package/dist-cli/chunks/home-paths-5O4IZPYV.js +0 -4
- package/dist-cli/chunks/inspect-LT4MXK37.js +0 -4
- package/dist-cli/chunks/install-desktop-EXCFMXFS.js +0 -4
- package/dist-cli/chunks/login-V6TZ54ZH.js +0 -26
- package/dist-cli/chunks/logout-SPMLFWYA.js +0 -4
- package/dist-cli/chunks/maestro-5ISTBAZE.js +0 -108
- package/dist-cli/chunks/maestro-generate-WUI64NHR.js +0 -36
- package/dist-cli/chunks/mode-QPNBYXUF.js +0 -26
- package/dist-cli/chunks/optional-demo-registry-CBSYF4CG.js +0 -4
- package/dist-cli/chunks/perf-T6N5PVYV.js +0 -48
- package/dist-cli/chunks/permissions-YZ7RRSZJ.js +0 -13
- package/dist-cli/chunks/platform-XDQAA72X.js +0 -6
- package/dist-cli/chunks/privacy-54FIGXLT.js +0 -4
- package/dist-cli/chunks/record-QGYXRUKP.js +0 -72
- package/dist-cli/chunks/report-issue-VUUTGX7V.js +0 -29
- package/dist-cli/chunks/reset-CGO52KBW.js +0 -4
- package/dist-cli/chunks/resolve-target-NNQCALDM.js +0 -4
- package/dist-cli/chunks/runtime-4EP6YJVL.js +0 -4
- package/dist-cli/chunks/screenshot-command-NZCMSJ4P.js +0 -159
- package/dist-cli/chunks/screenshot-layers-VMTQ6XIU.js +0 -20
- package/dist-cli/chunks/screenshots-capture-K3MWIDBK.js +0 -42
- package/dist-cli/chunks/serve-QJRIB2BV.js +0 -56
- package/dist-cli/chunks/setup-6XXEJQVF.js +0 -4
- package/dist-cli/chunks/sim-client-5YUVL45C.js +0 -4
- package/dist-cli/chunks/skills-T3CS7CXK.js +0 -50
- package/dist-cli/chunks/state-AJC3VK3G.js +0 -14
- package/dist-cli/chunks/storage-KVGZKC3Y.js +0 -37
- package/dist-cli/chunks/store-AWUMOQUH.js +0 -4
- package/dist-cli/chunks/telemetry-W5ZDGWK6.js +0 -4
- package/dist-cli/chunks/timeline-DXDCAZUA.js +0 -24
- package/dist-cli/chunks/upgrade-SRPTJACU.js +0 -7
- package/dist-cli/chunks/upload-ZDV4BFED.js +0 -4
- package/dist-cli/chunks/version-SOLPSBMG.js +0 -6
- package/dist-cli/chunks/web-RT75LD7A.js +0 -4
- package/dist-cli/chunks/welcome-IJ55EC7U.js +0 -5
- package/dist-cli/chunks/what-happened-CEIWJIWK.js +0 -25
- package/dist-cli/chunks/ws-bridge-YK5R3HOI.js +0 -4
- package/scripts/postinstall.cjs +0 -3
- package/scripts/preuninstall.cjs +0 -118
|
@@ -1,506 +0,0 @@
|
|
|
1
|
-
/*! rnx v0.1.375 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
-
import { createRequire as __sootsimCreateRequire } from 'node:module'
|
|
3
|
-
var require = __sootsimCreateRequire(import.meta.url)
|
|
4
|
-
import{a as y,c as P}from"./chunk-YNHRSDVG.js";import{a as f,b as S}from"./chunk-Z6LOIW46.js";import{b}from"./chunk-GEX7RVHY.js";import{a as v}from"./chunk-K7QQWKGE.js";function M(){let e=f();return e?{available:!0,reason:null,detail:`${e.kind} @ ${e.path}`}:{available:!1,reason:"rnx desktop app not installed (run `rnx desktop install`)"}}async function A(e){let o=f();if(!o)return{launched:!1,message:"rnx desktop app not installed"};try{let r=await S(e.url,o,{device:e.device,profileId:e.profileId,ephemeralProfile:e.ephemeralProfile,ownerPid:e.ownerPid});return r.launched?{launched:!0,message:e.url?`electron launched via ${r.via} \u2192 ${e.url}`:`electron launched via ${r.via}`,target:r.target,attachUrl:e.url}:{launched:!1,message:"desktop companion failed to start"}}catch(r){return{launched:!1,message:`electron launch failed: ${r instanceof Error?r.message:String(r)}`}}}var k={id:"electron",name:"electron",description:"rnx desktop companion app (native window, menu bar)",kind:"native",availability:M,launch:A};import{spawn as B}from"child_process";import{closeSync as F,mkdtempSync as G,openSync as U,readFileSync as q}from"fs";import{tmpdir as T}from"os";import{join as I}from"path";import{spawnSync as O}from"node:child_process";import{existsSync as _,readFileSync as R}from"node:fs";import{createRequire as L}from"node:module";import{dirname as W,join as N}from"node:path";var $=`
|
|
5
|
-
const { existsSync } = require('node:fs');
|
|
6
|
-
const modulePath = process.env.SOOTSIM_PW_MODULE;
|
|
7
|
-
try {
|
|
8
|
-
const playwright = require(modulePath);
|
|
9
|
-
const browser = playwright && playwright.chromium;
|
|
10
|
-
if (!browser || typeof browser.executablePath !== 'function') {
|
|
11
|
-
throw new Error('resolved package does not expose browser "chromium"');
|
|
12
|
-
}
|
|
13
|
-
const executablePath = browser.executablePath();
|
|
14
|
-
process.stdout.write(JSON.stringify({ executablePath, exists: existsSync(executablePath) }));
|
|
15
|
-
} catch (error) {
|
|
16
|
-
process.stderr.write(String((error && error.stack) || error));
|
|
17
|
-
process.exit(1);
|
|
18
|
-
}
|
|
19
|
-
`;function w(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function g(){let e=[`${process.cwd()}/`];process.argv[1]&&e.push(process.argv[1]);for(let o of e)try{let r=L(o);for(let t of["playwright","playwright-chromium","playwright-core"])try{let n=r.resolve(t),i=r.resolve(`${t}/package.json`),a=JSON.parse(R(i,"utf8"));if(!w(a)||typeof a.version!="string")continue;let l=a.bin,s=null;if(typeof l=="string")s=l;else if(w(l)){let d=l.playwright??l["playwright-core"],p=Object.values(l).find(c=>typeof c=="string");s=typeof d=="string"?d:typeof p=="string"?p:null}if(!s)continue;let u=N(W(i),s);if(!_(u))continue;return{spec:t,modulePath:n,cliPath:u,version:a.version}}catch{}}catch{}return null}function x(e,o){let r=O(process.execPath,["-e",$],{env:{...o,SOOTSIM_PW_MODULE:e.modulePath},encoding:"utf8",timeout:3e4});if(r.status!==0){let t=(r.stderr||r.error?.message||"browser probe failed").trim();return{ok:!1,message:`could not inspect ${e.spec}@${e.version} chromium: ${t}`}}try{let t=JSON.parse(r.stdout);if(!w(t)||typeof t.executablePath!="string"||typeof t.exists!="boolean")throw new Error("probe returned an invalid result");return{ok:!0,executablePath:t.executablePath,exists:t.exists&&_(t.executablePath)}}catch(t){return{ok:!1,message:`could not inspect ${e.spec}@${e.version} chromium: ${t instanceof Error?t.message:String(t)}`}}}function D(e,o=process.env){let r=x(e,o);if(!r.ok)return r;if(r.exists)return{ok:!0,executablePath:r.executablePath,installed:!1};let t=O(process.execPath,[e.cliPath,"install","chromium"],{env:o,encoding:"utf8",timeout:10*6e4});if(t.status!==0){let i=(t.stderr||t.stdout||t.error?.message||"browser install failed").trim(),a=i.length<=4e3?i:i.slice(-4e3);return{ok:!1,message:`${e.spec}@${e.version} requires chromium at ${r.executablePath}, but its browser install failed${a?`:
|
|
20
|
-
${a}`:""}`}}let n=x(e,o);return n.ok?n.exists?{ok:!0,executablePath:n.executablePath,installed:!0}:{ok:!1,message:`${e.spec}@${e.version} browser install completed, but its required chromium executable is still missing at ${n.executablePath}`}:n}var j=`
|
|
21
|
-
const modulePath = process.env.SOOTSIM_PW_MODULE;
|
|
22
|
-
const url = process.env.SOOTSIM_PW_URL;
|
|
23
|
-
// the WS bridge port the sim page must register with, injected below as
|
|
24
|
-
// window.__sootsimBridgePort so the page skips its shell-port heuristic (which
|
|
25
|
-
// assumes the default offset and breaks when the dev bridge drifted).
|
|
26
|
-
const bridgePort = process.env.SOOTSIM_PW_BRIDGE_PORT || '';
|
|
27
|
-
const headless = process.env.SOOTSIM_PW_HEADLESS === '1';
|
|
28
|
-
const callerUserDataDir = process.env.SOOTSIM_PW_USERDATADIR || '';
|
|
29
|
-
// pid of the session that launched us (its topmost non-init ancestor). when
|
|
30
|
-
// that process exits we tear Chrome down \u2014 see startOwnerWatch below. it is a
|
|
31
|
-
// required lifetime bound: an invalid value aborts before Chrome launches.
|
|
32
|
-
// SOOTSIM_PW_OWNER_POLL_MS is a test-only override of the 5s poll interval;
|
|
33
|
-
// production never sets it.
|
|
34
|
-
const ownerPid = Number(process.env.SOOTSIM_PW_OWNER_PID || 0);
|
|
35
|
-
const ownerPollMs = Number(process.env.SOOTSIM_PW_OWNER_POLL_MS || 5000);
|
|
36
|
-
// optional CDP port \u2014 exposes Chrome's remote-debugging endpoint so a
|
|
37
|
-
// bridge-driven sim can also be cpu-profiled (sootsim perf cpu --cdp-port).
|
|
38
|
-
// playwright keeps its own pipe connection; the port is an additional endpoint.
|
|
39
|
-
const cdpPort = process.env.SOOTSIM_PW_CDP_PORT || '';
|
|
40
|
-
// extra chromium launch args, space-separated. a linux GPU runner injects
|
|
41
|
-
// '--use-angle=vulkan --enable-features=Vulkan' here so chrome binds the
|
|
42
|
-
// real GPU instead of silently falling back to swiftshader software
|
|
43
|
-
// rendering (which pegs cores and produces ~1fps canvas capture).
|
|
44
|
-
const extraChromeArgs = (process.env.SOOTSIM_PW_CHROME_ARGS || '')
|
|
45
|
-
.split(' ')
|
|
46
|
-
.filter(Boolean);
|
|
47
|
-
// Local CanvasKit work must never fall back to Playwright's software
|
|
48
|
-
// renderer. CI may use the bundled browser for non-interactive coverage, but
|
|
49
|
-
// local test drives fail closed unless the hardware-backed test browser is
|
|
50
|
-
// proven after launch.
|
|
51
|
-
const hardwareGpuRequired = process.env.CI !== '1' && process.env.CI !== 'true';
|
|
52
|
-
const softwareRendererPattern = /swiftshader|software(?: rasterizer)?|llvmpipe|lavapipe|softpipe/i;
|
|
53
|
-
// page viewport as '<w>x<h>'. the caller sizes it from the device profile;
|
|
54
|
-
// the fallback is phone-shaped because the page hosts a phone sim \u2014 the
|
|
55
|
-
// playwright default (1280x720 desktop) letterboxes the device frame.
|
|
56
|
-
const viewportSpec = /^(\\d+)x(\\d+)$/.exec(process.env.SOOTSIM_PW_VIEWPORT || '');
|
|
57
|
-
const viewport = viewportSpec
|
|
58
|
-
? { width: Number(viewportSpec[1]), height: Number(viewportSpec[2]) }
|
|
59
|
-
: { width: 600, height: 900 };
|
|
60
|
-
// device pixels per css pixel. playwright's default is 1, which makes the
|
|
61
|
-
// engine allocate its canvas backing store at HALF the resolution a normal
|
|
62
|
-
// retina-mac chrome would (dpr 2) \u2014 the sim looks visibly soft. default to 2
|
|
63
|
-
// so a driver-launched sim matches what the user sees in their own browser.
|
|
64
|
-
const deviceScaleFactor = Number(process.env.SOOTSIM_PW_DSF || 2);
|
|
65
|
-
const closeTimeoutMs = Number(process.env.SOOTSIM_PW_CLOSE_TIMEOUT_MS || 2500);
|
|
66
|
-
const connectAckFile = process.env.SOOTSIM_PW_CONNECTED_ACK_FILE || '';
|
|
67
|
-
const disposableBrowserCacheDirs = new Set(${JSON.stringify(v)});
|
|
68
|
-
const { existsSync, mkdtempSync, readdirSync, rmSync, unlinkSync } = require('fs');
|
|
69
|
-
const { execSync } = require('child_process');
|
|
70
|
-
const { tmpdir } = require('os');
|
|
71
|
-
const { join } = require('path');
|
|
72
|
-
// chrome tree reaper \u2014 playwright's browser.close() and even SIGKILLing the
|
|
73
|
-
// root chrome process do NOT reliably take down the helper tree (gpu, renderer,
|
|
74
|
-
// network/storage utilities). they reparent to launchd/init and survive, each
|
|
75
|
-
// one busy enough to peg CPU at 100%+. close() only reaches the root.
|
|
76
|
-
//
|
|
77
|
-
// the prior approach was \`pgrep -f ms-playwright/[c]hromium\`. it never matched
|
|
78
|
-
// system Chrome, so the reaper was a no-op in the common case and every
|
|
79
|
-
// aborted/closed \`sootsim open\` leaked a renderer + gpu helper burning 100%+
|
|
80
|
-
// CPU until manually killed (multiple incidents 2026-06).
|
|
81
|
-
//
|
|
82
|
-
// fix: identify our chrome tree by its UNIQUE user-data-dir. every helper a
|
|
83
|
-
// chrome root spawns inherits \`--user-data-dir=<dir>\` in its cmdline, so
|
|
84
|
-
// \`pgrep -f <profileDir>\` finds exactly the tree we launched and nothing else
|
|
85
|
-
// \u2014 Chrome for Testing and bundled playwright chromium alike. as a side benefit we
|
|
86
|
-
// no longer need the launch / launchPersistentContext fork: we ALWAYS use a
|
|
87
|
-
// profile dir (mkdtemp'd if the caller didn't pass one, then removed at exit).
|
|
88
|
-
const reapEnabled = process.platform !== 'win32';
|
|
89
|
-
let profileDir = callerUserDataDir;
|
|
90
|
-
let ephemeralProfile = false;
|
|
91
|
-
if (!profileDir) {
|
|
92
|
-
profileDir = mkdtempSync(join(tmpdir(), 'sootsim-playwright-host-'));
|
|
93
|
-
ephemeralProfile = true;
|
|
94
|
-
}
|
|
95
|
-
// browser HTTP caches are acceleration data, not profile identity. give each
|
|
96
|
-
// host a bounded temporary cache so persistent named profiles retain cookies
|
|
97
|
-
// and storage without multiplying a private cache for every profile.
|
|
98
|
-
const diskCacheDir = mkdtempSync(join(tmpdir(), 'sootsim-playwright-cache-'));
|
|
99
|
-
const chromePidsByProfile = () => {
|
|
100
|
-
if (!reapEnabled) return [];
|
|
101
|
-
try {
|
|
102
|
-
return execSync('pgrep -f ' + profileDir + ' || true', { stdio: ['ignore', 'pipe', 'ignore'] })
|
|
103
|
-
.toString().split('\\n').filter(Boolean).map((p) => Number(p))
|
|
104
|
-
.filter((p) => p && p !== process.pid);
|
|
105
|
-
} catch { return []; }
|
|
106
|
-
};
|
|
107
|
-
const chromeCommandsByProfile = () => {
|
|
108
|
-
if (!reapEnabled) return [];
|
|
109
|
-
const pids = chromePidsByProfile();
|
|
110
|
-
if (pids.length === 0) return [];
|
|
111
|
-
try {
|
|
112
|
-
return execSync('ps -p ' + pids.join(',') + ' -o command=', {
|
|
113
|
-
stdio: ['ignore', 'pipe', 'ignore'],
|
|
114
|
-
}).toString().split('\\n').filter(Boolean);
|
|
115
|
-
} catch { return []; }
|
|
116
|
-
};
|
|
117
|
-
const assertNoUnsafeSwiftShaderFlag = () => {
|
|
118
|
-
if (!hardwareGpuRequired) return;
|
|
119
|
-
const unsafe = chromeCommandsByProfile().find((command) =>
|
|
120
|
-
command.includes('--enable-unsafe-swiftshader') ||
|
|
121
|
-
/--use-angle=(?:swiftshader|swiftshader-webgl)(?:\\s|$)/i.test(command)
|
|
122
|
-
);
|
|
123
|
-
if (unsafe) {
|
|
124
|
-
throw new Error(
|
|
125
|
-
'[playwright-driver] refused software-rendering Chrome: launched process contains a SwiftShader flag'
|
|
126
|
-
);
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
const killTree = (pid) => {
|
|
130
|
-
let kids = [];
|
|
131
|
-
try {
|
|
132
|
-
kids = execSync('pgrep -P ' + pid + ' || true', { stdio: ['ignore', 'pipe', 'ignore'] })
|
|
133
|
-
.toString().split('\\n').filter(Boolean);
|
|
134
|
-
} catch {}
|
|
135
|
-
for (const k of kids) killTree(Number(k));
|
|
136
|
-
try { process.kill(pid, 'SIGKILL'); } catch {}
|
|
137
|
-
};
|
|
138
|
-
const reapChrome = () => { for (const pid of chromePidsByProfile()) killTree(pid); };
|
|
139
|
-
const removeDisposableCaches = (root) => {
|
|
140
|
-
let children = [];
|
|
141
|
-
try { children = readdirSync(root, { withFileTypes: true }); } catch { return; }
|
|
142
|
-
for (const child of children) {
|
|
143
|
-
if (!child.isDirectory() || child.isSymbolicLink()) continue;
|
|
144
|
-
const childPath = join(root, child.name);
|
|
145
|
-
if (disposableBrowserCacheDirs.has(child.name)) {
|
|
146
|
-
try { rmSync(childPath, { recursive: true, force: true }); } catch {}
|
|
147
|
-
continue;
|
|
148
|
-
}
|
|
149
|
-
removeDisposableCaches(childPath);
|
|
150
|
-
}
|
|
151
|
-
};
|
|
152
|
-
const cleanupProfile = () => {
|
|
153
|
-
try { rmSync(diskCacheDir, { recursive: true, force: true }); } catch {}
|
|
154
|
-
if (ephemeralProfile) {
|
|
155
|
-
try { rmSync(profileDir, { recursive: true, force: true }); } catch {}
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
removeDisposableCaches(profileDir);
|
|
159
|
-
};
|
|
160
|
-
(async () => {
|
|
161
|
-
const pw = require(modulePath);
|
|
162
|
-
let context;
|
|
163
|
-
let keepAlive = null;
|
|
164
|
-
let connectTimer = null;
|
|
165
|
-
let connectAckPoll = null;
|
|
166
|
-
let ownerWatch = null;
|
|
167
|
-
let connected = false;
|
|
168
|
-
let shuttingDown = false;
|
|
169
|
-
const clearConnectTimer = () => {
|
|
170
|
-
if (connectTimer) {
|
|
171
|
-
clearTimeout(connectTimer);
|
|
172
|
-
connectTimer = null;
|
|
173
|
-
}
|
|
174
|
-
if (connectAckPoll) {
|
|
175
|
-
clearInterval(connectAckPoll);
|
|
176
|
-
connectAckPoll = null;
|
|
177
|
-
}
|
|
178
|
-
};
|
|
179
|
-
const markConnected = () => {
|
|
180
|
-
connected = true;
|
|
181
|
-
clearConnectTimer();
|
|
182
|
-
};
|
|
183
|
-
const ackFileExists = () => {
|
|
184
|
-
if (!connectAckFile) return false;
|
|
185
|
-
try { return existsSync(connectAckFile); } catch { return false; }
|
|
186
|
-
};
|
|
187
|
-
const bounded = async (label, work, timeoutMs) => {
|
|
188
|
-
let timer = null;
|
|
189
|
-
try {
|
|
190
|
-
const timeout = new Promise((resolve) => {
|
|
191
|
-
timer = setTimeout(() => resolve({ timedOut: true }), timeoutMs);
|
|
192
|
-
});
|
|
193
|
-
if (typeof timer.unref === 'function') timer.unref();
|
|
194
|
-
const result = await Promise.race([
|
|
195
|
-
Promise.resolve().then(work).then(
|
|
196
|
-
() => ({ timedOut: false }),
|
|
197
|
-
(error) => ({ timedOut: false, error }),
|
|
198
|
-
),
|
|
199
|
-
timeout,
|
|
200
|
-
]);
|
|
201
|
-
if (result && result.timedOut) {
|
|
202
|
-
process.stderr.write('[shutdown-timeout] ' + label + ' exceeded ' + timeoutMs + 'ms\\n');
|
|
203
|
-
return false;
|
|
204
|
-
}
|
|
205
|
-
if (result && result.error) {
|
|
206
|
-
process.stderr.write('[shutdown-error] ' + label + ': ' + String((result.error && result.error.message) || result.error) + '\\n');
|
|
207
|
-
return false;
|
|
208
|
-
}
|
|
209
|
-
return true;
|
|
210
|
-
} finally {
|
|
211
|
-
if (timer) clearTimeout(timer);
|
|
212
|
-
}
|
|
213
|
-
};
|
|
214
|
-
const browserProcess = () => {
|
|
215
|
-
if (context && typeof context.browser === 'function') {
|
|
216
|
-
try {
|
|
217
|
-
const b = context.browser();
|
|
218
|
-
if (b && typeof b.process === 'function') return b.process();
|
|
219
|
-
} catch {}
|
|
220
|
-
}
|
|
221
|
-
return null;
|
|
222
|
-
};
|
|
223
|
-
const processIsAlive = (proc) => {
|
|
224
|
-
if (!proc || !proc.pid) return false;
|
|
225
|
-
try {
|
|
226
|
-
process.kill(proc.pid, 0);
|
|
227
|
-
return true;
|
|
228
|
-
} catch (err) {
|
|
229
|
-
return err && err.code === 'EPERM';
|
|
230
|
-
}
|
|
231
|
-
};
|
|
232
|
-
const terminateBrowserProcess = async () => {
|
|
233
|
-
const proc = browserProcess();
|
|
234
|
-
if (!proc || !proc.pid || !processIsAlive(proc)) return;
|
|
235
|
-
try { proc.kill('SIGTERM'); } catch {}
|
|
236
|
-
await bounded('browser process exit after SIGTERM', async () => {
|
|
237
|
-
while (processIsAlive(proc)) {
|
|
238
|
-
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
239
|
-
}
|
|
240
|
-
}, 600);
|
|
241
|
-
if (!processIsAlive(proc)) return;
|
|
242
|
-
try { proc.kill('SIGKILL'); } catch {}
|
|
243
|
-
};
|
|
244
|
-
const shutdown = async (code = 0) => {
|
|
245
|
-
if (shuttingDown) return;
|
|
246
|
-
shuttingDown = true;
|
|
247
|
-
clearConnectTimer();
|
|
248
|
-
if (keepAlive) clearInterval(keepAlive);
|
|
249
|
-
if (ownerWatch) clearInterval(ownerWatch);
|
|
250
|
-
const timeoutMs = Number.isFinite(closeTimeoutMs) && closeTimeoutMs > 0 ? closeTimeoutMs : 2500;
|
|
251
|
-
if (context) await bounded('context.close', () => context.close(), timeoutMs);
|
|
252
|
-
await terminateBrowserProcess();
|
|
253
|
-
// close() + root-SIGKILL above handle the graceful case; the helper tree
|
|
254
|
-
// (gpu/renderer/utilities) reparents and survives every one of those, so
|
|
255
|
-
// we always sweep by our unique profile dir as the load-bearing teardown.
|
|
256
|
-
reapChrome();
|
|
257
|
-
cleanupProfile();
|
|
258
|
-
if (connectAckFile) {
|
|
259
|
-
try { unlinkSync(connectAckFile); } catch {}
|
|
260
|
-
}
|
|
261
|
-
process.exit(code);
|
|
262
|
-
};
|
|
263
|
-
process.once('SIGTERM', () => { void shutdown(0); });
|
|
264
|
-
process.once('SIGINT', () => { void shutdown(0); });
|
|
265
|
-
// the launch-failure path at the bottom of this script exits without going
|
|
266
|
-
// through shutdown(); the exit hook (sync sweep) still reaps the tree.
|
|
267
|
-
process.on('exit', () => { reapChrome(); cleanupProfile(); });
|
|
268
|
-
// owner-liveness watchdog \u2014 the load-bearing fix for leaked Chrome hosts.
|
|
269
|
-
// we are spawned detached + unref'd so \`sootsim open\` returns immediately,
|
|
270
|
-
// which means nothing in the OS process tree ties Chrome's lifetime to the
|
|
271
|
-
// session that asked for it. once the sim connects, the connect-timeout
|
|
272
|
-
// safety net is cleared, so absent an explicit \`sootsim close\` (or the
|
|
273
|
-
// daemon's idle reaper closing the sim socket) the host would hold Chrome
|
|
274
|
-
// open forever after its owner exits. poll the owning session's pid and tear
|
|
275
|
-
// down when it's gone. ESRCH (kill throws) = owner exited; EPERM = alive but
|
|
276
|
-
// not signalable by us, which still counts as alive.
|
|
277
|
-
const startOwnerWatch = () => {
|
|
278
|
-
if (!Number.isInteger(ownerPid) || ownerPid <= 1) {
|
|
279
|
-
throw new Error('[playwright-driver] missing valid owning process; refusing unsupervised browser host');
|
|
280
|
-
}
|
|
281
|
-
const intervalMs = Number.isFinite(ownerPollMs) && ownerPollMs > 0 ? ownerPollMs : 5000;
|
|
282
|
-
ownerWatch = setInterval(() => {
|
|
283
|
-
try {
|
|
284
|
-
process.kill(ownerPid, 0);
|
|
285
|
-
} catch (err) {
|
|
286
|
-
if (err && err.code === 'EPERM') return;
|
|
287
|
-
process.stderr.write('[owner-gone] owning process ' + ownerPid + ' exited; closing playwright host\\n');
|
|
288
|
-
void shutdown(0);
|
|
289
|
-
}
|
|
290
|
-
}, intervalMs);
|
|
291
|
-
if (typeof ownerWatch.unref === 'function') ownerWatch.unref();
|
|
292
|
-
};
|
|
293
|
-
startOwnerWatch();
|
|
294
|
-
// Local rendering uses Playwright's full Chrome for Testing app. On macOS its
|
|
295
|
-
// com.google.chrome.for.testing identity cannot intercept open/quit events for
|
|
296
|
-
// the user's com.google.Chrome browser. CI may use chromium_headless_shell;
|
|
297
|
-
// local rendering fails closed because that shell has no GPU and silently
|
|
298
|
-
// chooses SwiftShader. NOTE: this is NOT enough to make \`sootsim perf cpu\`
|
|
299
|
-
// work \u2014 that profiles the tenant *worker*, and the JS Self-Profiler API
|
|
300
|
-
// cannot be constructed in a dedicated worker (see
|
|
301
|
-
// worker-handlers/cpu-profile.ts). cpu-profile needs a CDP-based profiler
|
|
302
|
-
// instead.
|
|
303
|
-
if (
|
|
304
|
-
hardwareGpuRequired &&
|
|
305
|
-
extraChromeArgs.some((arg) =>
|
|
306
|
-
arg === '--enable-unsafe-swiftshader' ||
|
|
307
|
-
/^--use-angle=(?:swiftshader|swiftshader-webgl)$/i.test(arg)
|
|
308
|
-
)
|
|
309
|
-
) {
|
|
310
|
-
throw new Error('[playwright-driver] refused SwiftShader launch arguments');
|
|
311
|
-
}
|
|
312
|
-
// one browser path per environment: the full, separately identified test app
|
|
313
|
-
// locally; chromium_headless_shell on CI. never launch a branded user browser.
|
|
314
|
-
const channelsToTry = hardwareGpuRequired ? ['chromium'] : [null];
|
|
315
|
-
const launchWith = async (channel) => {
|
|
316
|
-
const opts = channel
|
|
317
|
-
? { headless, channel, viewport, deviceScaleFactor }
|
|
318
|
-
: { headless, viewport, deviceScaleFactor };
|
|
319
|
-
// playwright injects --force-color-profile=srgb by default, which reads
|
|
320
|
-
// visibly washed-out next to a normal chrome window on a wide-gamut mac
|
|
321
|
-
// display. strip it so driver-launched sims color-match the user's own
|
|
322
|
-
// browser (real incident 2026-07-09: "low res and whitewashed" sim).
|
|
323
|
-
opts.ignoreDefaultArgs = ['--force-color-profile=srgb'];
|
|
324
|
-
// headless chromium backgrounds/occludes the renderer and throttles rAF +
|
|
325
|
-
// timers to ~1fps, which silently starves combined/video frame capture
|
|
326
|
-
// (was 47 frames over 63s -> frozen-looking mp4). keep the render loop at
|
|
327
|
-
// full rate so the recorder captures real motion. document.hidden stays
|
|
328
|
-
// false in headless, so assertTabVisibleForCapture never caught this \u2014 it
|
|
329
|
-
// has to be fixed at the launch flags.
|
|
330
|
-
opts.args = [
|
|
331
|
-
// the compositor renders through skia graphite on webgpu, so a launch
|
|
332
|
-
// without navigator.gpu boots to a fatal instead of a sim.
|
|
333
|
-
'--enable-unsafe-webgpu',
|
|
334
|
-
'--disk-cache-dir=' + diskCacheDir,
|
|
335
|
-
'--disk-cache-size=67108864',
|
|
336
|
-
'--disable-background-timer-throttling',
|
|
337
|
-
'--disable-backgrounding-occluded-windows',
|
|
338
|
-
'--disable-renderer-backgrounding',
|
|
339
|
-
];
|
|
340
|
-
if (channel) {
|
|
341
|
-
// the full test browser can bind the real platform GPU \u2014 force the native
|
|
342
|
-
// ANGLE backend and strip playwright's --enable-unsafe-swiftshader
|
|
343
|
-
// default arg. without both, headless chrome silently falls back to
|
|
344
|
-
// swiftshader software rendering for the CanvasKit/WebGL canvas and
|
|
345
|
-
// pegs every core. SOOTSIM_PW_CHROME_ARGS is appended later, so an
|
|
346
|
-
// env-injected --use-angle=... still overrides (last flag wins).
|
|
347
|
-
const angle = process.platform === 'darwin' ? 'metal'
|
|
348
|
-
: process.platform === 'linux' ? 'vulkan' : 'default';
|
|
349
|
-
opts.args.unshift(
|
|
350
|
-
'--use-angle=' + angle,
|
|
351
|
-
'--enable-gpu',
|
|
352
|
-
'--enable-gpu-rasterization',
|
|
353
|
-
'--enable-zero-copy',
|
|
354
|
-
'--ignore-gpu-blocklist',
|
|
355
|
-
);
|
|
356
|
-
opts.ignoreDefaultArgs.push('--enable-unsafe-swiftshader');
|
|
357
|
-
} else {
|
|
358
|
-
// playwright's bundled software chromium exposes no navigator.gpu until
|
|
359
|
-
// Vulkan is named explicitly, and webgpu is the only backend there is.
|
|
360
|
-
opts.args.push('--enable-features=Vulkan');
|
|
361
|
-
}
|
|
362
|
-
if (cdpPort) opts.args.push('--remote-debugging-port=' + cdpPort);
|
|
363
|
-
if (extraChromeArgs.length) opts.args.push(...extraChromeArgs);
|
|
364
|
-
// headed: size the OS window to the (phone-shaped) viewport too, plus
|
|
365
|
-
// room for chrome's own toolbar, so the window isn't desktop-shaped
|
|
366
|
-
// around a letterboxed page.
|
|
367
|
-
if (!headless) opts.args.push('--window-size=' + viewport.width + ',' + (viewport.height + 88));
|
|
368
|
-
// ALWAYS persistent: every chrome process inherits --user-data-dir=<dir>
|
|
369
|
-
// in its cmdline, which is how reapChrome() finds the whole tree (root +
|
|
370
|
-
// helpers) on shutdown. without a unique dir there is no way to attribute
|
|
371
|
-
// an orphaned helper back to us, which is the leak we just fixed.
|
|
372
|
-
return await pw.chromium.launchPersistentContext(profileDir, opts);
|
|
373
|
-
};
|
|
374
|
-
let launchErr = null;
|
|
375
|
-
let launchedChannel = null;
|
|
376
|
-
for (const channel of channelsToTry) {
|
|
377
|
-
try {
|
|
378
|
-
context = await launchWith(channel);
|
|
379
|
-
launchedChannel = channel || 'chromium';
|
|
380
|
-
launchErr = null;
|
|
381
|
-
break;
|
|
382
|
-
} catch (err) {
|
|
383
|
-
launchErr = err;
|
|
384
|
-
const msg = err && err.message ? String(err.message) : '';
|
|
385
|
-
const isMissingChannel =
|
|
386
|
-
/not found at/i.test(msg) ||
|
|
387
|
-
/not installed/i.test(msg) ||
|
|
388
|
-
/Chromium distribution/i.test(msg);
|
|
389
|
-
if (!isMissingChannel) throw err; // unexpected failure: bubble up
|
|
390
|
-
if (channel) {
|
|
391
|
-
const next = hardwareGpuRequired
|
|
392
|
-
? '; bundled Chromium is disabled for local GPU work\\n'
|
|
393
|
-
: ', falling back to bundled chromium\\n';
|
|
394
|
-
process.stderr.write('[playwright-driver] channel "' + channel + '" not available' + next);
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
if (launchErr) throw launchErr;
|
|
399
|
-
if (launchedChannel) {
|
|
400
|
-
process.stderr.write('[playwright-driver] launched ' + launchedChannel + '\\n');
|
|
401
|
-
}
|
|
402
|
-
// grant camera up front so the sim's Camera app reaches the host webcam
|
|
403
|
-
// through getUserMedia, mirroring a real iOS simulator where the camera just
|
|
404
|
-
// works. without this the unhandled chrome permission prompt auto-denies and
|
|
405
|
-
// CameraApp renders its "Camera Access Required" placeholder.
|
|
406
|
-
await context.grantPermissions(['camera']);
|
|
407
|
-
const hostMeta = {
|
|
408
|
-
sootsimHostDriver: 'playwright',
|
|
409
|
-
sootsimHostPid: process.pid,
|
|
410
|
-
sootsimHostOwnerPid: ownerPid,
|
|
411
|
-
sootsimHostStartedAt: Date.now(),
|
|
412
|
-
};
|
|
413
|
-
// inject the resolved bridge port (numeric literal) BEFORE the page runs, so
|
|
414
|
-
// the shell/engine talk to the daemon this driver owns. addInitScript runs
|
|
415
|
-
// ahead of every page script, and the vite dev plugin only fills the value in
|
|
416
|
-
// when it is still unset, so this one wins. plain assignment, NOT
|
|
417
|
-
// defineProperty: other injectors also assign to it, and a non-writable
|
|
418
|
-
// property would throw at that assignment and crash boot.
|
|
419
|
-
const bridgePortInject = bridgePort
|
|
420
|
-
? 'window.__sootsimBridgePort = ' + Number(bridgePort) + ';'
|
|
421
|
-
: '';
|
|
422
|
-
await context.addInitScript({
|
|
423
|
-
content: 'Object.defineProperty(window, "__sootsimHostMeta", { value: ' + JSON.stringify(hostMeta) + ', configurable: true });' + bridgePortInject,
|
|
424
|
-
});
|
|
425
|
-
await context.exposeBinding('__sootsimHostClose', async () => {
|
|
426
|
-
await shutdown(0);
|
|
427
|
-
});
|
|
428
|
-
const connectTimeoutMs = Number(process.env.SOOTSIM_PW_CONNECT_TIMEOUT_MS || 120000);
|
|
429
|
-
if (connectAckFile) {
|
|
430
|
-
connectAckPoll = setInterval(() => {
|
|
431
|
-
if (ackFileExists()) markConnected();
|
|
432
|
-
}, 500);
|
|
433
|
-
if (typeof connectAckPoll.unref === 'function') connectAckPoll.unref();
|
|
434
|
-
}
|
|
435
|
-
connectTimer = setTimeout(() => {
|
|
436
|
-
if (ackFileExists()) {
|
|
437
|
-
markConnected();
|
|
438
|
-
return;
|
|
439
|
-
}
|
|
440
|
-
if (connected) return;
|
|
441
|
-
process.stderr.write('[connect-timeout] sim did not register with the bridge within ' + connectTimeoutMs + 'ms; closing playwright host\\n');
|
|
442
|
-
void shutdown(2);
|
|
443
|
-
}, Number.isFinite(connectTimeoutMs) && connectTimeoutMs > 0 ? connectTimeoutMs : 120000);
|
|
444
|
-
if (typeof connectTimer.unref === 'function') connectTimer.unref();
|
|
445
|
-
const page = await context.newPage();
|
|
446
|
-
if (hardwareGpuRequired) {
|
|
447
|
-
assertNoUnsafeSwiftShaderFlag();
|
|
448
|
-
const gpu = await page.evaluate(() => {
|
|
449
|
-
const canvas = document.createElement('canvas');
|
|
450
|
-
const gl =
|
|
451
|
-
canvas.getContext('webgl2', { powerPreference: 'high-performance' }) ||
|
|
452
|
-
canvas.getContext('webgl', { powerPreference: 'high-performance' });
|
|
453
|
-
if (!gl) return { renderer: null, vendor: null };
|
|
454
|
-
const info = gl.getExtension('WEBGL_debug_renderer_info');
|
|
455
|
-
return {
|
|
456
|
-
renderer: info ? String(gl.getParameter(info.UNMASKED_RENDERER_WEBGL)) : null,
|
|
457
|
-
vendor: info ? String(gl.getParameter(info.UNMASKED_VENDOR_WEBGL)) : null,
|
|
458
|
-
};
|
|
459
|
-
});
|
|
460
|
-
if (!gpu.renderer) {
|
|
461
|
-
throw new Error(
|
|
462
|
-
'[playwright-driver] could not prove a hardware WebGL renderer; refusing local render-heavy launch'
|
|
463
|
-
);
|
|
464
|
-
}
|
|
465
|
-
if (softwareRendererPattern.test(gpu.renderer)) {
|
|
466
|
-
throw new Error('[playwright-driver] refused software WebGL renderer: ' + gpu.renderer);
|
|
467
|
-
}
|
|
468
|
-
assertNoUnsafeSwiftShaderFlag();
|
|
469
|
-
process.stderr.write(
|
|
470
|
-
'[playwright-driver] hardware WebGL renderer: ' + gpu.renderer +
|
|
471
|
-
(gpu.vendor ? ' (' + gpu.vendor + ')' : '') + '\\n'
|
|
472
|
-
);
|
|
473
|
-
}
|
|
474
|
-
// surface page-side failures (engine boot crash, failed WS registration)
|
|
475
|
-
// to stderr so a sim that never connects produces a real diagnostic
|
|
476
|
-
// instead of a silent "timed out waiting for opened sim to connect".
|
|
477
|
-
page.on('pageerror', (e) => {
|
|
478
|
-
process.stderr.write('[pageerror] ' + ((e && e.stack) || e) + '\\n');
|
|
479
|
-
});
|
|
480
|
-
page.on('console', (m) => {
|
|
481
|
-
if (m.type() === 'error') {
|
|
482
|
-
process.stderr.write('[console.error] ' + m.text() + '\\n');
|
|
483
|
-
}
|
|
484
|
-
});
|
|
485
|
-
page.on('crash', () => process.stderr.write('[page] renderer crashed\\n'));
|
|
486
|
-
try {
|
|
487
|
-
await page.goto(url, { waitUntil: 'domcontentloaded', timeout: 60000 });
|
|
488
|
-
} catch (err) {
|
|
489
|
-
process.stderr.write('[goto] ' + String((err && err.message) || err) + '\\n');
|
|
490
|
-
}
|
|
491
|
-
keepAlive = setInterval(() => {}, 1 << 30);
|
|
492
|
-
// browser disconnect (e.g. user killed chrome from outside) \u2192 tear down.
|
|
493
|
-
// we are persistent-only now, so .browser() is the only handle to it.
|
|
494
|
-
try {
|
|
495
|
-
const b = context.browser && context.browser();
|
|
496
|
-
if (b && typeof b.on === 'function') b.on('disconnected', () => { void shutdown(0); });
|
|
497
|
-
} catch {}
|
|
498
|
-
context.on('close', () => { void shutdown(0); });
|
|
499
|
-
page.on('close', () => { void shutdown(0); });
|
|
500
|
-
})().catch((err) => {
|
|
501
|
-
process.stderr.write(String((err && err.stack) || err) + '\\n');
|
|
502
|
-
process.exit(1);
|
|
503
|
-
});
|
|
504
|
-
`;function H(){let e=g();return e?{available:!0,reason:null,detail:`resolved via ${e.spec}@${e.version}`}:{available:!1,reason:"playwright not installed in the current workspace"}}function K(e,o){return process.platform!=="linux"||e.headless||process.env.DISPLAY||process.env.WAYLAND_DISPLAY||!/missing x server|cannot open display|x server|x11/i.test(o)?null:" hint: linux without DISPLAY/WAYLAND_DISPLAY \u2014 rerun without --headed (or add --headless) to run playwright headless."}function Y(e){return e.profileId?y(P(e.profileId).id):e.ephemeralProfile?G(I(T(),"sootsim-playwright-profile-")):""}async function J(e){let o=g();if(!o)return{launched:!1,message:"playwright not installed \u2014 run `bun add -D playwright` first"};if(!e.url)return{launched:!1,message:"playwright driver requires a target url"};let r=e.ownerPid;if(r===void 0||!Number.isInteger(r)||r<=1)return{launched:!1,message:"playwright driver requires a valid owning session process"};let t={...process.env},n=D(o,t);if(!n.ok)return{launched:!1,message:`playwright browser provisioning failed: ${n.message}`};let i=I(T(),`sootsim-playwright-host-${Date.now().toString(36)}-${process.pid}.log`),a=`${i}.connected`,l=U(i,"a");try{let s=B(process.execPath,["-e",j],{detached:!0,stdio:["ignore","ignore",l],env:{...t,SOOTSIM_PW_MODULE:o.modulePath,SOOTSIM_PW_URL:e.url,SOOTSIM_PW_BRIDGE_PORT:e.bridgePort?String(e.bridgePort):"",SOOTSIM_PW_HEADLESS:e.headless??!0?"1":"0",SOOTSIM_PW_USERDATADIR:Y(e),SOOTSIM_PW_CDP_PORT:e.cdpPort?String(e.cdpPort):"",...e.viewport?{SOOTSIM_PW_VIEWPORT:`${e.viewport.width}x${e.viewport.height}`}:{},SOOTSIM_PW_CONNECTED_ACK_FILE:a,SOOTSIM_PW_CONNECT_TIMEOUT_MS:String(e.connectTimeoutMs??12e4),SOOTSIM_PW_OWNER_PID:String(r)}});s.unref();let u=await new Promise(c=>{let m=setTimeout(()=>c(null),4e3);s.once("exit",C=>{clearTimeout(m),c(C??0)})});if(u!==null){let c=q(i,"utf8").trim(),m=K(e,c);return{launched:!1,message:`playwright host exited early (code ${u}) \u2014 host log ${i}${c?`:
|
|
505
|
-
${c}`:""}${m?`
|
|
506
|
-
${m}`:""}`}}let d=b(r),p=` \u2014 browser closes when pid ${r}${d?` (${d})`:""} exits`;return{launched:!0,message:`playwright chrome launched \u2192 ${e.url}${p}`,pid:s.pid,target:o.spec,attachUrl:e.url,connectAckFile:a,diagnosticLogPath:i}}catch(s){return{launched:!1,message:`playwright launch failed: ${s instanceof Error?s.message:String(s)}`}}finally{F(l)}}var E={id:"playwright",name:"playwright",description:"programmatic chromium via the playwright package \u2014 headless default",kind:"automation",availability:H,launch:J};var h=[k,E];function pe(){return h}function me(e){return h.find(o=>o.id===e)??null}function fe(e,o){if(e)return h.find(t=>t.id===e)??null;for(let r of o){let t=h.find(n=>n.id===r);if(t&&t.availability().available)return t}return null}function we(){return h.map(e=>{let o=e.availability();return{id:e.id,name:e.name,kind:e.kind,description:e.description,available:o.available,reason:o.reason,detail:o.detail??null}})}export{k as a,E as b,h as c,pe as d,me as e,fe as f,we as g};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/*! rnx v0.1.375 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
-
import { createRequire as __sootsimCreateRequire } from 'node:module'
|
|
3
|
-
var require = __sootsimCreateRequire(import.meta.url)
|
|
4
|
-
import{n}from"./chunk-7NCPUZ52.js";import{M as t,j as r}from"./chunk-HWDVC6YA.js";function l(){let e=t(),i=r()?n():null;return i?.source==="dev-bridge"?{primary:`engine dev source (:${i.bridgePort})`,installedRuntime:e?`installed runtime v${e}`:null,isDevBridge:!0}:{primary:e?`runtime v${e}`:"runtime not installed",installedRuntime:null,isDevBridge:!1}}export{l as a};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/*! rnx v0.1.375 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
-
import { createRequire as __sootsimCreateRequire } from 'node:module'
|
|
3
|
-
var require = __sootsimCreateRequire(import.meta.url)
|
|
4
|
-
import{randomUUID as x}from"node:crypto";import n from"node:fs";import{homedir as I}from"node:os";import i from"node:path";var $="SOOTSIM_HOME",B="active",M="daemon.json",T="dev-bridges",J="config.json",L=3e4;function s(){let e=process.env[$];return e&&e.length>0?i.resolve(e):i.join(I(),".sootsim")}function U(){if(process.env.SOOTSIM_FORCE_DAEMON_INSTALL==="1")return!1;let e=process.env.SOOTSIM_DEV;if(e==="1"||e==="true")return!0;if(e==="0"||e==="false")return!1;let t=process.argv[1];if(!t)return!1;try{return n.realpathSync(t).includes(`${i.sep}packages${i.sep}sootsim${i.sep}`)}catch{return!1}}function V(){return process.env.SOOTSIM_FORCE_DAEMON_INSTALL==="1"?!1:process.env.IS_TAMAGUI_DEV==="1"}function ce(){return U()||V()}function v(){return i.join(s(),"runtimes")}function H(e){return i.join(v(),e)}function w(){return i.join(v(),B)}function A(){return i.join(s(),"electron")}function se(){return i.join(A(),"userData")}function ae(e){return i.join(A(),e)}function G(){return i.join(s(),"profiles")}function ue(){return i.join(s(),"camera-fixtures")}function K(){return i.join(s(),"daemon-app")}function X(){return i.join(K(),"SootSim Daemon.app")}function fe(){return i.join(X(),"Contents","MacOS","sootsim-daemon")}function q(){return i.join(s(),"cache")}function m(){return i.join(s(),M)}function y(){return i.join(s(),T)}function O(e){if(!Number.isInteger(e)||e<=0)throw new Error(`invalid development bridge port: ${e}`);return i.join(y(),`${e}.json`)}function b(){return i.join(s(),J)}function p(){try{let e=n.readFileSync(b(),"utf8"),t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return{}}}function P(e){h();let t=p(),r={...t,...e};e.settings&&typeof e.settings=="object"&&(r.settings={...t.settings&&typeof t.settings=="object"?t.settings:{},...e.settings});let c=`${b()}.tmp`;return n.writeFileSync(c,`${JSON.stringify(r,null,2)}
|
|
5
|
-
`,"utf8"),n.renameSync(c,b()),r}var E=1;function le(){return p().onboardingVersion===E}function de(){let e=p().simulatorDriver;return e==="electron"||e==="playwright"?e:null}function me(e){P({onboardingVersion:E,simulatorDriver:e})}function pe(){let e=p().settings,t=e?.productAnalytics,r=e?.crashReports;return{productAnalytics:typeof t=="boolean"?t:!1,crashReports:typeof r=="boolean"?r:!1,configured:typeof t=="boolean"&&typeof r=="boolean"}}function ye(e){P({settings:{productAnalytics:e.productAnalytics,crashReports:e.crashReports}})}function ge(){let e=p().anonymousId;if(typeof e=="string"&&e.trim())return e;let t=`anon-cli-${x()}`;return P({anonymousId:t}),t}function g(){return i.join(s(),"runtime-upgraded.json")}function Se(e){h();let t=`${g()}.tmp`;n.writeFileSync(t,`${JSON.stringify(e)}
|
|
6
|
-
`,"utf8"),n.renameSync(t,g())}function ve(){try{let e=n.readFileSync(g(),"utf8");n.unlinkSync(g());let t=JSON.parse(e);return typeof t?.to!="string"||!t.to?null:{from:typeof t.from=="string"?t.from:null,to:t.to,at:typeof t.at=="number"?t.at:0}}catch{return null}}function h(){n.mkdirSync(s(),{recursive:!0}),n.mkdirSync(v(),{recursive:!0}),n.mkdirSync(A(),{recursive:!0}),n.mkdirSync(G(),{recursive:!0}),n.mkdirSync(q(),{recursive:!0})}function z(){try{let e=n.readFileSync(w(),"utf8").trim();return e.length>0?e:null}catch{return null}}function he(e){n.mkdirSync(v(),{recursive:!0}),n.writeFileSync(w(),`${e}
|
|
7
|
-
`,"utf8")}function De(){let e=z();if(!e)return null;let t=H(e);try{if(n.statSync(t).isDirectory())return t}catch{}return null}var S=16*1024,W=3e4;function d(){try{let e=n.openSync(m(),"r");try{let t=Buffer.alloc(S),r=n.readSync(e,t,0,S,0),c=t.subarray(0,r).toString("utf8"),o=JSON.parse(c);return o&&o.schema===1&&typeof o.pid=="number"&&typeof o.bridgePort=="number"&&typeof o.runtimePort=="number"&&typeof o.startedAt=="number"&&typeof o.heartbeatAt=="number"&&(o.servedRuntimes===void 0||Array.isArray(o.servedRuntimes)&&o.servedRuntimes.every(a=>typeof a=="string"))?o:null}finally{n.closeSync(e)}}catch{return null}}function N(e){try{let t=JSON.parse(e);return t&&t.schema===1&&t.source==="vite-dev"&&typeof t.pid=="number"&&typeof t.bridgePort=="number"&&typeof t.runtimePort=="number"&&typeof t.cwd=="string"&&typeof t.startedAt=="number"&&typeof t.heartbeatAt=="number"&&(t.shellPort===void 0||typeof t.shellPort=="number")&&(t.servedRuntimes===void 0||Array.isArray(t.servedRuntimes)&&t.servedRuntimes.every(r=>typeof r=="string"))?t:null}catch{return null}}function Y(){let e;try{e=n.readdirSync(y(),{withFileTypes:!0})}catch{return[]}let t=[];for(let r of e)if(!(!r.isFile()||!/^\d+\.json$/.test(r.name)))try{let c=i.join(y(),r.name),o=n.openSync(c,"r");try{let a=Buffer.alloc(S),u=n.readSync(o,a,0,S,0),D=N(a.subarray(0,u).toString("utf8"));D&&r.name===`${D.bridgePort}.json`&&t.push(D)}finally{n.closeSync(o)}}catch{}return t.sort((r,c)=>r.bridgePort-c.bridgePort)}function k(e,t=Date.now()){if(!e||t-e.heartbeatAt>L)return!1;try{return process.kill(e.pid,0),!0}catch{return!1}}function Q(e,t=Date.now()){if(!e||t-e.heartbeatAt>L)return!1;try{return process.kill(e.pid,0),!0}catch{return!1}}function be(){let e=new Set,t=d();if(k(t)){t.activeRuntime&&e.add(t.activeRuntime);for(let r of t.servedRuntimes??[])e.add(r)}for(let r of Y())if(Q(r))for(let c of r.servedRuntimes??[])e.add(c);return[...e].sort()}function Z(e){h();let t=m(),r=d();if(!r){if(_(e))return;throw new Error("another rnx daemon claimed the lockfile before this write")}if(!f(r,e))throw new Error("refusing to overwrite another rnx daemon lockfile");let c=`${t}.${e.pid}.${x()}.tmp`;n.writeFileSync(c,`${JSON.stringify(e,null,2)}
|
|
8
|
-
`,"utf8");try{let o=d();if(!o||!f(o,e))throw new Error("rnx daemon lock ownership changed during heartbeat");n.renameSync(c,t)}finally{try{n.unlinkSync(c)}catch{}}}function ke(e){n.mkdirSync(y(),{recursive:!0});let t=O(e.bridgePort),r=`${t}.${e.pid}.tmp`;n.writeFileSync(r,`${JSON.stringify(e,null,2)}
|
|
9
|
-
`,"utf8"),n.renameSync(r,t)}function f(e,t){return e.pid===t.pid&&e.startedAt===t.startedAt}function C(e){return e instanceof Error&&"code"in e&&Reflect.get(e,"code")==="EEXIST"}function _(e){let t=m(),r=`${t}.${e.pid}.${x()}.claim`;n.writeFileSync(r,`${JSON.stringify(e,null,2)}
|
|
10
|
-
`,"utf8");try{return n.linkSync(r,t),!0}catch(c){if(C(c))return!1;throw c}finally{try{n.unlinkSync(r)}catch{}}}function l(){return`${m()}.claim`}function j(e){try{let t=JSON.parse(e);if(t!==null&&typeof t=="object"&&typeof Reflect.get(t,"pid")=="number"&&typeof Reflect.get(t,"startedAt")=="number"&&typeof Reflect.get(t,"createdAt")=="number")return{pid:Reflect.get(t,"pid"),startedAt:Reflect.get(t,"startedAt"),createdAt:Reflect.get(t,"createdAt")}}catch{}return null}function F(){try{return j(n.readFileSync(l(),"utf8"))}catch{return null}}function R(e,t=Date.now()){if(t-e.createdAt>W)return!1;try{return process.kill(e.pid,0),!0}catch{return!1}}function ee(e){let t={pid:e.pid,startedAt:e.startedAt,createdAt:Date.now()},r=`${JSON.stringify(t)}
|
|
11
|
-
`;for(let c=0;c<8;c++){try{return n.writeFileSync(l(),r,{encoding:"utf8",flag:"wx"}),!0}catch(u){if(!C(u))throw u}let o=F();if(o&&f(o,t))return!0;if(o&&R(o))return!1;let a;try{a=n.readFileSync(l(),"utf8");let u=j(a);if(u&&R(u))return!1;if(n.readFileSync(l(),"utf8")!==a)continue;n.unlinkSync(l())}catch{}}return!1}function te(e){try{let t=F();if(!t||!f(t,e))return;n.unlinkSync(l())}catch{}}function xe(e){if(h(),!ee(e))return!1;try{let t=d();if(t&&f(t,e))return Z(e),!0;if(t&&k(t))return!1;if(t){let r=d();if(!r||!f(r,t)||k(r))return!1;try{n.unlinkSync(m())}catch{return!1}}return _(e)}finally{te(e)}}function Ae(e){try{let t=d();if(!t||!f(t,e))return;n.unlinkSync(m())}catch{}}function Pe(e){try{let t=O(e.bridgePort),r=N(n.readFileSync(t,"utf8"));if(r?.pid!==e.pid||r.startedAt!==e.startedAt)return;n.unlinkSync(t)}catch{}}export{$ as a,B as b,M as c,T as d,J as e,L as f,s as g,U as h,V as i,ce as j,v as k,H as l,w as m,A as n,se as o,ae as p,G as q,ue as r,K as s,X as t,fe as u,q as v,m as w,y as x,O as y,b as z,p as A,P as B,le as C,de as D,me as E,pe as F,ye as G,ge as H,g as I,Se as J,ve as K,h as L,z as M,he as N,De as O,d as P,Y as Q,k as R,Q as S,be as T,Z as U,ke as V,xe as W,Ae as X,Pe as Y};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/*! rnx v0.1.375 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
-
import { createRequire as __sootsimCreateRequire } from 'node:module'
|
|
3
|
-
var require = __sootsimCreateRequire(import.meta.url)
|
|
4
|
-
import{a as r}from"./chunk-XUBV77WH.js";var i=[{title:"Overview",route:"/docs/rnx/cli"},...r.slice().sort((o,t)=>o.order-t.order).map(o=>({title:o.navTitle,route:`/docs/rnx/cli/${o.slug}`}))];
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/*! rnx v0.1.375 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
-
import { createRequire as __sootsimCreateRequire } from 'node:module'
|
|
3
|
-
var require = __sootsimCreateRequire(import.meta.url)
|
|
4
|
-
import{o as d}from"./chunk-HWDVC6YA.js";import{chmodSync as S,existsSync as f,mkdirSync as A,readFileSync as k,rmSync as o,writeFileSync as y}from"node:fs";import{dirname as c,join as D,resolve as m}from"node:path";var s=1,p="SOOTSIM_SHARED_AUTH_FILE",u="https://contrast.dev";function w(){let t=process.env[p];return t?.trim()?c(m(t)):d()}function a(){let t=process.env[p];return t?.trim()?m(t):D(w(),"desktop-auth.json")}function g(t){if(!t||typeof t!="object")return null;let e=t;return typeof e.id!="string"||!e.id.trim()?null:{id:e.id.trim(),name:typeof e.name=="string"?e.name:void 0,email:typeof e.email=="string"?e.email:void 0,image:typeof e.image=="string"?e.image:void 0,githubUsername:typeof e.githubUsername=="string"?e.githubUsername:void 0,isAdmin:e.isAdmin===!0,teams:Array.isArray(e.teams)?e.teams.map(r=>{if(!r||typeof r!="object")return null;let n=r;return typeof n.id!="string"||typeof n.name!="string"?null:{id:n.id,name:n.name,role:n.role==="owner"?"owner":"member",githubOrg:typeof n.githubOrg=="string"?n.githubOrg:null}}).filter(r=>!!r):void 0}}function v(t){if(!t||typeof t!="object")return null;let e=t;if(e.version!==s||typeof e.token!="string"||!e.token.trim())return null;let r=typeof e.origin=="string"&&e.origin.trim()?e.origin.trim():u,n=e.source==="cli"||e.source==="electron"||e.source==="browser"||e.source==="unknown"?e.source:"unknown",i=typeof e.updatedAt=="string"&&e.updatedAt?e.updatedAt:new Date().toISOString(),h=typeof e.validatedAt=="string"&&e.validatedAt?e.validatedAt:void 0;return{version:s,token:e.token.trim(),user:g(e.user),origin:r,source:n,updatedAt:i,validatedAt:h}}function b(){let t=a();if(!f(t))return null;try{let e=JSON.parse(k(t,"utf8")),r=v(e);return r||(o(t,{force:!0}),null)}catch{return o(t,{force:!0}),null}}function O(t){let e=a();A(c(e),{recursive:!0});let r={version:s,token:t.token.trim(),user:t.user?g(t.user):null,origin:t.origin?.trim()||u,source:t.source,updatedAt:t.updatedAt||new Date().toISOString(),validatedAt:t.validatedAt};y(e,JSON.stringify(r,null,2)+`
|
|
5
|
-
`);try{S(e,384)}catch{}return r}function l(){o(a(),{force:!0})}async function E(t){let e=b();if(!e?.token)return null;let r=t||e.origin||u;try{let n=await fetch(`${r.replace(/\/$/,"")}/api/auth/me`,{headers:{authorization:`Bearer ${e.token}`}});if(n.status===401)return l(),null;if(!n.ok)return e;let i=await n.json();return i.user?.id?O({token:e.token,user:i.user,origin:r,source:e.source,validatedAt:new Date().toISOString()}):(l(),null)}catch{return e}}export{b as a,O as b,l as c,E as d};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/*! rnx v0.1.375 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
-
import { createRequire as __sootsimCreateRequire } from 'node:module'
|
|
3
|
-
var require = __sootsimCreateRequire(import.meta.url)
|
|
4
|
-
var a=["Cache","Code Cache","DawnCache","DawnGraphiteCache","DawnWebGPUCache","GPUCache","GrShaderCache","ShaderCache"],r=new Set(a);function s(e){return r.has(e)}export{a,s as b};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/*! rnx v0.1.375 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
-
import { createRequire as __sootsimCreateRequire } from 'node:module'
|
|
3
|
-
var require = __sootsimCreateRequire(import.meta.url)
|
|
4
|
-
import{a as F,b as h,e as f,f as W,g as B}from"./chunk-V7RGRZOL.js";import{b as l}from"./chunk-YX52RJKO.js";import{b as P}from"./chunk-C6B5FOP3.js";import{E as y,G as D,d as T,e as u,h as v,k as I,l as R,o as O,p as $,r as M,s as A,x as N,z as _}from"./chunk-5PZVYF42.js";var o=class extends Error{constructor(e){super(e),this.name=new.target.name}},m=class extends o{},w=class extends o{status;constructor(e){super(`sim not ready: ${O(e)}`),this.status=e}},d=class extends o{outcome;constructor(e,t=null){super(e),this.outcome=t}},b=class extends o{},g=class extends o{result;constructor(e){let t=e.steps.find(n=>!n.ok),s=t?`${t.index} (${t.type})`:String(e.completed),r=t?.error??e.error;super(`perform failed at step ${s}${r?`: ${r}`:""}`),this.result=e}},x=class extends o{result;constructor(e){super(`reset (${e.strategy}) failed${e.error?`: ${e.error}`:""}`),this.result=e}};function U(i){return new Promise(e=>setTimeout(e,i))}function C(i){if(typeof i!="string"||!i.startsWith("data:image/png;base64,"))throw new o(`screenshot bridge returned a non-png payload: ${JSON.stringify(typeof i=="string"?i.slice(0,80):i)}`);let e=i.slice(22),t=atob(e),s=new Uint8Array(t.length);for(let r=0;r<t.length;r++)s[r]=t.charCodeAt(r);return{dataUrl:i,bytes:s}}var J=["bundle","demo","app","open","port","inspectOpen","appFonts","appSplash"];function K(i,e){let t=new URL(i);for(let a of J)t.searchParams.delete(a);let s=t.pathname.replace(/\/+$/,"")||"/",r=s==="/__soot"||s.startsWith("/__soot/")?"/__soot":"",n=String(e).trim();return/^\d+$/.test(n)?t.pathname=`${r}/rn/${n}`:(t.pathname=`${r}/rn`,t.searchParams.set("open",n)),t.toString()}function j(i){return typeof i=="object"&&"text"in i&&typeof i.text=="string"&&!("layout"in i)&&!("absolutePosition"in i)}var k=class{simId;bridge;closed=!1;constructor(e,t,s={}){this.bridge=e,this.simId=t}send(e,t){if(this.closed)return Promise.reject(new m("sim client is closed"));let s=e.simId===void 0?{...e,simId:this.simId}:e;return this.bridge.send(s,t)}listSims(){return this.bridge.listSims()}focusSim(e=this.simId){return this.bridge.focusSim(e)}closeSim(e=this.simId){return this.bridge.closeSim(e)}claim(e=this.simId,t){return this.bridge.claim(e,t)}close(){this.closed||(this.closed=!0,this.bridge.close())}async open(e,t={}){let r=(await this.listSims()).find(c=>c.id===this.simId);if(!r)throw new m(`sim ${this.simId} is no longer connected`);let n=r.url??r.origin;if(!n)throw new m(`sim ${this.simId} reported no URL to derive the shell from`);let a=K(n,e),p=new URL(a);await this.send({type:"evaluate",code:`window.location.href = ${JSON.stringify(a)}`});let L=Date.now()+(t.timeoutMs??3e4);for(;Date.now()<L;){await U(250);try{let{url:c}=await u(this),S=new URL(c);if(S.pathname===p.pathname&&S.searchParams.get("open")===p.searchParams.get("open"))return}catch{}}throw new m(`timed out waiting for sim ${this.simId} to load ${a}`)}openUrl(e){return P(this,e)}async waitReady(e={}){let t=await $(this,e.timeoutMs??2e4,{onProgress:e.onProgress});if(!t.ready)throw new w(t);return t}settle(e={}){return F({bridge:this,maxMs:e.maxMs??3e3,strict:e.strict})}async find(e){return(await this.findAll(e))[0]??null}async findAll(e){let t={testId:e.testId??null,role:e.role??null,type:e.type??null,text:e.text??null,pressable:e.pressable},s=await R(this,t);if(!s)throw new o("find() needs at least one of testId, text, role, type, or pressable");let{result:r}=s;return Array.isArray(r)?r:r?[r]:[]}async tree(e=5){let{tree:t}=await T(this,e);return Array.isArray(t)?t:[]}resolve(e){return this.send({type:"resolve",selector:e})}describe(e={}){return v(this,{describe:!0,verbose:e.verbose??!1,filter:e.filter??"",compact:!e.verbose,hideXy:!1,fullText:!0})}accessibilityTree(){return I(this)}async logs(e={}){return _(await N(this),e)}errors(e=20){return M(this,e)}warnings(e=20){return A(this,e)}keyboard(){return y(this)}shellState(e=0){return D(this,e)}async url(){let{url:e}=await u(this);return e}async screenshot(e={}){let t=await this.send({type:"screenshot",...e.layers?{layers:e.layers}:{},...e.crop?{crop:e.crop}:{}});return C(t)}async tap(e){if(typeof e=="string")return this.throwUnlessTapped(await B(this,e),e);if("testId"in e&&typeof e.testId=="string")return this.throwUnlessTapped(await f(this,e.testId),e.testId);if(j(e)){let{text:r,...n}=e;return this.throwUnlessTapped(await W(this,r,n),r)}if("testID"in e&&typeof e.testID=="string")return this.throwUnlessTapped(await f(this,e.testID),e.testID);let t=this.coordsForTapTarget(e),s=await this.send({type:"tap",x:t.x,y:t.y});if(!h(s))throw new d(`tap at ${t.x},${t.y} missed: ${JSON.stringify(s)}`)}async longPress(e,t={}){let s=await this.resolveCoords(e);if(!(await this.send({type:"longPress",x:s.x,y:s.y,durationMs:t.durationMs??600},{timeoutMs:(t.durationMs??600)+15e3}))?.ok)throw new d(`longPress at ${s.x},${s.y} missed`)}async type(e){await this.requireVisibleKeyboard("type"),await this.send({type:"keyboard",action:"type",text:e})}async press(e){await this.requireVisibleKeyboard("press"),await this.send({type:"keyboard",action:"press",text:e})}async dismissKeyboard(){await this.send({type:"keyboard",action:"dismiss"})}async perform(e,t){let s=[];for(let a of e){if(a.type!=="tapText"){s.push(a);continue}let p=await l(this,{mode:"text",value:a.text});if(!p)throw new d(`perform tapText: no node with text ${JSON.stringify(a.text)}`);s.push({type:"tap",x:p.x,y:p.y,target:{testID:p.testID??void 0,text:p.text??void 0,type:p.type??void 0}})}let r=t?.timeoutMs??3e4,n=await this.send({type:"perform",steps:s,...t?{performOptions:t}:{}},{timeoutMs:r+5e3});if(!n?.ok)throw new g(n);return n}state(e){return this.send({type:"state",...e?{stateOptions:e}:{}})}async reset(e){let t=await this.send({type:"reset",...e?{resetOptions:e}:{}},{timeoutMs:6e4});if(!t?.ok)throw new x(t);return t}throwUnlessTapped(e,t){if(!e.failure&&h(e.result))return;let s=e.failure==="not-found"?"no matching node":e.failure==="missed"?e.result?.reason??"press missed":e.payload?.ambiguous?`ambiguous: ${e.payload.total} matches`:e.result?.reason??e.payload?.error??"tap failed";throw new d(`tap ${JSON.stringify(t)} failed: ${s}`,e)}coordsForTapTarget(e){if(typeof e=="object"&&"x"in e&&"y"in e&&typeof e.x=="number"&&typeof e.y=="number")return{x:e.x,y:e.y};if(typeof e=="object"&&"absolutePosition"in e&&e.absolutePosition&&e.layout)return{x:e.absolutePosition.x+(e.layout.width??0)/2,y:e.absolutePosition.y+(e.layout.height??0)/2};throw new o("tap target needs coordinates, a testId, text, or a node from find()")}async resolveCoords(e){if(typeof e=="string"){let t=await l(this,{mode:"testid",value:e})??await l(this,{mode:"text",value:e});if(!t)throw new d(`no node matching ${JSON.stringify(e)}`);return t}if("testId"in e&&typeof e.testId=="string"){let t=await l(this,{mode:"testid",value:e.testId});if(!t)throw new d(`no node with testID ${JSON.stringify(e.testId)}`);return t}if("text"in e&&typeof e.text=="string"&&!("layout"in e)){let t=await l(this,{mode:"text",value:e.text});if(!t)throw new d(`no node with text ${JSON.stringify(e.text)}`);return t}return this.coordsForTapTarget(e)}async requireVisibleKeyboard(e){let t=Date.now()+1500;for(;;){let s=await y(this);if(!("error"in s)&&s.visible)return;if(Date.now()>=t)throw new b(`${e} requires the iOS keyboard to be visible \u2014 focus an input first (tap a TextInput)`);await U(150)}}};export{o as a,m as b,w as c,d,b as e,g as f,x as g,K as h,k as i};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/*! rnx v0.1.375 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
-
import { createRequire as __sootsimCreateRequire } from 'node:module'
|
|
3
|
-
var require = __sootsimCreateRequire(import.meta.url)
|
|
4
|
-
import{a as b}from"./chunk-Z6LOIW46.js";import{c as h}from"./chunk-T4ISWS5H.js";import{a as P,b as k,c as x,d as v,e as y,h as O,i as A}from"./chunk-S65CK3RI.js";import{spawn as I,spawnSync as p}from"child_process";import{chmodSync as L,copyFileSync as C,createWriteStream as R,existsSync as g,mkdirSync as S,rmSync as u,statSync as B,unlinkSync as F}from"fs";import{tmpdir as N}from"os";import{dirname as W,join as f,resolve as M}from"path";var D="https://contrast.dev/api/electron-release";function Y(){let n=process.arch;if(process.platform==="darwin"){let t=n==="arm64"?"mac-arm64":"mac-x64",r=`sootsim-latest-${t}.dmg`;return{platform:t,filename:r,url:`${D}/${r}`,install:z}}if(process.platform==="linux"){let t=n==="arm64"?"linux-arm64":"linux-x64",r=`sootsim-latest-${t}.AppImage`;return{platform:t,filename:r,url:`${D}/${r}`,install:H}}if(process.platform==="win32"){let t="sootsim-latest-win-x64.exe";return{platform:"win-x64",filename:t,url:`${D}/${t}`,install:K}}return null}async function _({url:n,dest:t,onProgress:r}){let s=await fetch(n,{redirect:"follow"});if(!s.ok)throw new Error(`${s.status} ${s.statusText} (${n})`);let o=s.headers.get("content-length"),a=o?Number(o):null;if(!s.body)throw new Error(`empty response body (${n})`);S(W(t),{recursive:!0});let l=R(t),d=s.body.getReader(),c=0;try{for(;;){let{done:e,value:i}=await d.read();if(e)break;l.write(Buffer.from(i)),c+=i.byteLength,r?.(c,a)}}finally{await new Promise((e,i)=>{l.end(m=>m?i(m):e())})}}function q(n,t){let r=(n/1048576).toFixed(1);if(!t)return` ${r} MB`;let s=Math.min(100,Math.round(n/t*100)),o=(t/(1024*1024)).toFixed(1),a=24,l=Math.round(s/100*a);return` ${P("\u2588".repeat(l))+x("\u2591".repeat(a-l))} ${s}% ${r} / ${o} MB`}async function z(n){let t=p("hdiutil",["attach","-nobrowse","-readonly",n],{encoding:"utf8"});if(t.status!==0)throw new Error(`hdiutil attach failed: ${t.stderr||t.stdout}`.trim());let r=t.stdout.trim().split(`
|
|
5
|
-
`),o=r[r.length-1].split(" ").pop()?.trim();if(!o||!g(o))throw new Error(`could not determine dmg mount point (output: ${t.stdout})`);let a=f(o,"rnx.app");if(!g(a))throw p("hdiutil",["detach","-force",o]),new Error(`rnx.app not found inside ${o}`);let l="/Applications",d=M(process.env.HOME||"","Applications"),c=l;try{let w=f(l,`.sootsim-write-probe-${process.pid}`);p("touch",[w]),g(w)?u(w,{force:!0}):c=d}catch{c=d}c===d&&S(c,{recursive:!0});let e=f(c,"rnx.app"),i=f(c,`.rnx-incoming-${process.pid}.app`);u(i,{recursive:!0,force:!0});let m=p("cp",["-R",a,i]);if(m.status!==0)throw p("hdiutil",["detach","-force",o]),u(i,{recursive:!0,force:!0}),new Error(`copy to ${c} failed: ${m.stderr?.toString()||""}`.trim());let T=p("hdiutil",["detach","-force",o]),$=f(c,`.rnx-previous-${process.pid}.app`);if(g(e)){let w=p("mv",[e,$]);if(w.status!==0)throw u(i,{recursive:!0,force:!0}),new Error(`could not replace ${e}: ${w.stderr?.toString()||""}`.trim())}let E=p("mv",[i,e]);if(E.status!==0)throw g($)&&p("mv",[$,e]),u(i,{recursive:!0,force:!0}),new Error(`could not move into ${e}: ${E.stderr?.toString()||""}`.trim());return u($,{recursive:!0,force:!0}),T.status!==0&&console.warn(` warning: failed to unmount ${o} (${T.stderr?.toString().trim()||"unknown error"})`),p("xattr",["-dr","com.apple.quarantine",e]),e}async function H(n){let t=M(process.env.HOME||"","Applications");S(t,{recursive:!0});let r=f(t,"rnx.AppImage");return g(r)&&u(r,{force:!0}),C(n,r),F(n),L(r,493),r}async function K(n){await new Promise((r,s)=>{let o=I("cmd",["/c","start",'""',"/wait",n],{stdio:"inherit"});o.once("error",s),o.once("exit",a=>{a===0?r():s(new Error(`installer exited with code ${a}`))})});let t=b();if(!t)throw new Error("the installer finished but the rnx application was not registered");return t.path}async function tt(n){(n.includes("--help")||n.includes("-h"))&&(console.log(`
|
|
6
|
-
rnx desktop install
|
|
7
|
-
|
|
8
|
-
Download and install the optional rnx Desktop app.
|
|
9
|
-
The CLI works without it. Choose Desktop when you want a dedicated native window.
|
|
10
|
-
|
|
11
|
-
usage:
|
|
12
|
-
rnx desktop install [options]
|
|
13
|
-
|
|
14
|
-
options:
|
|
15
|
-
-y, --yes skip confirmation and install immediately
|
|
16
|
-
--force reinstall even if the companion is already present
|
|
17
|
-
|
|
18
|
-
examples:
|
|
19
|
-
rnx desktop install
|
|
20
|
-
rnx desktop install --yes
|
|
21
|
-
`),h(0));let t=n.includes("--yes")||n.includes("-y")||process.env.SOOTSIM_NO_PROMPT==="1"||process.env.CI==="1"||!process.stdin.isTTY,r=n.includes("--force"),s=b();if(s&&!r){console.log(` ${v("\u2713")} Desktop app is already installed at ${s.path}`),console.log(` ${x("Pass --force to reinstall.")}`);return}let o=Y();if(o||(console.error(` ${y("\xD7")} No desktop build is available for ${process.platform}/${process.arch}.`),console.error(" Supported: darwin-arm64, darwin-x64, linux-x64, linux-arm64, win32-x64"),h(1)),console.log(` ${k("Desktop app")}`),console.log(` Platform ${o.platform}`),console.log(` Download ${o.url}`),console.log(),!t){if(!await A("Download and install now?",!0)){console.log(` ${x("Cancelled.")}`);return}console.log()}let a=f(N(),`sootsim-install-${Date.now()}`),l=f(a,o.filename),d=0;process.stdout.write(` Downloading ${o.filename}...
|
|
22
|
-
`);try{await _({url:o.url,dest:l,onProgress:(e,i)=>{let m=Date.now();m-d<100&&e<(i??1/0)||(d=m,process.stdout.isTTY&&process.stdout.write(`\r\x1B[2K${q(e,i)}`))}})}catch(e){u(a,{recursive:!0,force:!0});let i=e instanceof Error?e.message:String(e);console.error(`
|
|
23
|
-
${y("\xD7")} Download failed: ${i}`),console.error(` The ${o.platform} desktop build may not be published yet, or your`),console.error(" network blocked the request. Check your connection and try again later."),console.error(" The CLI and daemon work without the desktop app. Run `rnx --help`."),h(1)}process.stdout.isTTY&&process.stdout.write(`
|
|
24
|
-
`);let c=B(l).size;console.log(` ${v("\u2713")} Downloaded ${(c/(1024*1024)).toFixed(1)} MB`),console.log();try{let e=await O("Installing the desktop app",()=>o.install(l));console.log(` Installed at ${e}`),u(a,{recursive:!0,force:!0})}catch(e){console.error(` ${y("\xD7")} Install failed: ${e instanceof Error?e.message:String(e)}`),process.platform==="darwin"?(p("open",[l]),console.error(` Opened ${o.filename} \u2014 drag rnx to Applications to finish.`)):console.error(` Keeping the download at ${l} for manual installation.`),h(1)}console.log(),console.log(` ${k("Ready")}`),console.log(" rnx desktop Launch the desktop app"),console.log(" rnx open <target> Open a demo or bundle in it")}export{tt as a};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/*! rnx v0.1.375 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
-
import { createRequire as __sootsimCreateRequire } from 'node:module'
|
|
3
|
-
var require = __sootsimCreateRequire(import.meta.url)
|
|
4
|
-
var e=["SOOTSIM_AGENT","TM_SESSION","CLAUDECODE","CLAUDE_CODE_ENTRYPOINT","CLAUDE_CODE_SESSION_ID","CODEX_THREAD_ID","CURSOR_TRACE_ID","AIDER_MODEL"];function n(){if(process.env.SOOTSIM_AGENT==="0")return!1;for(let _ of e){let E=process.env[_];if(E&&E.trim()&&E!=="0")return!0}return!1}export{n as a};
|