@pi-chamber/web 1.0.5 → 1.0.6-rc.2
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/dist/assets/{DiagramView-CrKjR8CR.js → DiagramView-BdDt1SI7.js} +1 -1
- package/dist/assets/DiffView-Dk3VIX9E.js +18 -0
- package/dist/assets/FileSaveConflictDialog-DpyPjMH1.js +3 -0
- package/dist/assets/{FilesView-BRR3N7UA.js → FilesView-CumrwioK.js} +3 -3
- package/dist/assets/{GitHubDetailScaffold-C1UHuETI.js → GitHubDetailScaffold-CW2ZqU0Y.js} +3 -3
- package/dist/assets/{GitHubLinkPicker-B0O3Vapu.js → GitHubLinkPicker-BjJNQ7Ap.js} +1 -1
- package/dist/assets/{GitHubListPrimitives-DvQDU--z.js → GitHubListPrimitives-BcB-cCTs.js} +1 -1
- package/dist/assets/{GitView-wAscrRhO.js → GitView-BoCaX5AO.js} +4 -4
- package/dist/assets/{IssuesSurface-mh50UUQ8.js → IssuesSurface-CDZENHrE.js} +3 -3
- package/dist/assets/{JsonTreeView-BfErTllU.js → JsonTreeView-DpCgOUXg.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-SXAK4uOu.js → MarkdownRendererImpl-BkT5TUWF.js} +2 -2
- package/dist/assets/{PatchDiff-CHr79sJ6.js → PatchDiff-Dcr3EQgA.js} +1 -1
- package/dist/assets/{PierreDiffViewer-CGpKcLro.js → PierreDiffViewer-o_Edh6ny.js} +3 -3
- package/dist/assets/PullRequestsSurface-eSXl6sef.js +2 -0
- package/dist/assets/{SessionSwitcherContent-DEAw6v12.js → SessionSwitcherContent-Dm30bfpn.js} +1 -1
- package/dist/assets/SessionSwitcherDropdown-CFj9VWSa.js +2 -0
- package/dist/assets/SessionUnreadDot-CHlK2awX.js +1 -0
- package/dist/assets/SettingsView-CcHRUyev.js +6 -0
- package/dist/assets/{SettingsWindow-BiY5FmhZ.js → SettingsWindow-BMzUErrM.js} +1 -1
- package/dist/assets/{StickyHorizontalScrollbar-BMITjK4e.js → StickyHorizontalScrollbar-p7EbL2-E.js} +2 -2
- package/dist/assets/{ToolOutputDialog-B3RRLhR3.js → ToolOutputDialog-QC8IoeBH.js} +4 -4
- package/dist/assets/{ToolPartDiffPreview-D9m_vrht.js → ToolPartDiffPreview-BigGwtul.js} +1 -1
- package/dist/assets/{VirtualizedFileDiff-B8lhZGLu.js → VirtualizedFileDiff-DvLCd7Qq.js} +4 -4
- package/dist/assets/{Virtualizer-DP6HbEeC.js → Virtualizer-DNJrJKVb.js} +1 -1
- package/dist/assets/{appThemeRegistry-gegrE2dq.js → appThemeRegistry-Ca8eGRB9.js} +1 -1
- package/dist/assets/{collapsible-9MJx4VhA.js → collapsible-0yfy07W2.js} +1 -1
- package/dist/assets/{computeVirtualFileMetrics-Bjhk2CQS.js → computeVirtualFileMetrics-aX6tjjqv.js} +2 -2
- package/dist/assets/{contextFileOpenGuard-CsF5Boky.js → contextFileOpenGuard-CZKJuHxf.js} +1 -1
- package/dist/assets/{document-attachments-BslE4Ns7.js → document-attachments-CZl9rK1z.js} +5 -5
- package/dist/assets/{gitStatusPredicates-B3Zxud6E.js → gitStatusPredicates-3i8CcYWJ.js} +1 -1
- package/dist/assets/{githubLink-CbGYxsIq.js → githubLink-BvevcNay.js} +5 -5
- package/dist/assets/index-BMdbHCFt.js +1 -0
- package/dist/assets/{index-D4n3TVp2.js → index-C2ISrmRR.js} +10 -10
- package/dist/assets/index-DgwThEwf.css +1 -0
- package/dist/assets/{lua-BgMRiT3U.js → lua-VAEuO923.js} +1 -1
- package/dist/assets/main-BM-b2y8p.js +2 -0
- package/dist/assets/main-BXZ561E3.js +137 -0
- package/dist/assets/{markdown-shiki.worker-DnvH1S1x.js → markdown-shiki.worker-BVA5NZBT.js} +5 -5
- package/dist/assets/markdownCore-DbS8DkKw.js +2 -0
- package/dist/assets/miniChat-DO3DW6kJ.js +2 -0
- package/dist/assets/mobile-BgWLkut6.js +2 -0
- package/dist/assets/{nativeFileSave-BJsGPh58.js → nativeFileSave-Bhafll_7.js} +1 -1
- package/dist/assets/nsis-LY0VT_u5.js +1 -0
- package/dist/assets/permissionStore-zIpxq9Pq.js +1 -0
- package/dist/assets/pi-session-focus-preference-ChYVctYk.js +9 -0
- package/dist/assets/{registerCustomTheme-DmolaWWZ.js → registerCustomTheme-C-h6lsYW.js} +1 -1
- package/dist/assets/{renderDiffWithHighlighter-BhMEWmHn.js → renderDiffWithHighlighter-xlvSvnTf.js} +1 -1
- package/dist/assets/renderElectronMiniChatApp-CgVqxKDm.js +2 -0
- package/dist/assets/{renderFileWithHighlighter-DUGluXlw.js → renderFileWithHighlighter-CCoYfC-t.js} +1 -1
- package/dist/assets/renderMobileApp-CoY1tsk5.js +11 -0
- package/dist/assets/ruby-BK5aLJev.js +1 -0
- package/dist/assets/runtimeEndpointReset-fozcAShH.js +62 -0
- package/dist/assets/runtimeSurface-CJN1oo_1.js +1 -0
- package/dist/assets/themeResolver-DrfmQi8i.js +1 -0
- package/dist/assets/useAppFontEffects-D_gtiA95.js +215 -0
- package/dist/assets/useFilesViewSearch-BUxcZj60.js +7 -0
- package/dist/assets/{useGitHubRemoteSearch-DYoLQ4ro.js → useGitHubRemoteSearch-CevR5iLf.js} +1 -1
- package/dist/assets/{useSwitcherItems-BS6E199F.js → useSwitcherItems-kaRkXggX.js} +1 -1
- package/dist/assets/vendor-aparajita-capacitor-secure-storage-BLsm9T1Y.js +1 -0
- package/dist/assets/vendor-base-ui-C7vVMZTg.js +1 -0
- package/dist/assets/{vendor-beautiful-mermaid-DApbjBp2.js → vendor-beautiful-mermaid-b48gT2g0.js} +1 -1
- package/dist/assets/vendor-boot-CoTxysn6.js +65 -0
- package/dist/assets/{vendor-capacitor-app-BaupizkW.js → vendor-capacitor-app-NX6DULfp.js} +1 -1
- package/dist/assets/{vendor-capacitor-keyboard-9BVxykO7.js → vendor-capacitor-keyboard-DJD81I9f.js} +1 -1
- package/dist/assets/{vendor-capacitor-status-bar-BsrUwiaA.js → vendor-capacitor-status-bar-DV24OoQV.js} +1 -1
- package/dist/assets/vendor-codemirror-autocomplete-qsuH4Dh-.js +1 -0
- package/dist/assets/vendor-codemirror-lang-angular-ZHWyBf7j.js +1 -0
- package/dist/assets/vendor-codemirror-lang-cpp-pCTOmv-k.js +1 -0
- package/dist/assets/vendor-codemirror-lang-css-2bFuyM70.js +1 -0
- package/dist/assets/{vendor-codemirror-lang-go-Crwca_X7.js → vendor-codemirror-lang-go-DrG_c7D7.js} +2 -2
- package/dist/assets/vendor-codemirror-lang-html-BV8lrR8v.js +1 -0
- package/dist/assets/vendor-codemirror-lang-java-DrsvH6T2.js +1 -0
- package/dist/assets/vendor-codemirror-lang-javascript-Dkzl3s07.js +13 -0
- package/dist/assets/vendor-codemirror-lang-jinja-8Nn3bnoP.js +1 -0
- package/dist/assets/vendor-codemirror-lang-json-CsdmtHhi.js +1 -0
- package/dist/assets/vendor-codemirror-lang-less-DJuZ4cZe.js +1 -0
- package/dist/assets/vendor-codemirror-lang-liquid-D2RO-Pzr.js +1 -0
- package/dist/assets/vendor-codemirror-lang-markdown-C0Zu3b3n.js +1 -0
- package/dist/assets/vendor-codemirror-lang-php-CuDtt2Zj.js +1 -0
- package/dist/assets/vendor-codemirror-lang-python-Cv2exx_M.js +3 -0
- package/dist/assets/vendor-codemirror-lang-rust-C4TxJ6Rg.js +1 -0
- package/dist/assets/vendor-codemirror-lang-sass-BmtPz8kf.js +1 -0
- package/dist/assets/{vendor-codemirror-lang-sql-B0f-qCZo.js → vendor-codemirror-lang-sql-BF1ZaXqJ.js} +2 -2
- package/dist/assets/vendor-codemirror-lang-vue-DZgXrP2k.js +1 -0
- package/dist/assets/vendor-codemirror-lang-wast-DsnaGtL_.js +1 -0
- package/dist/assets/vendor-codemirror-lang-xml-D8DzzFat.js +1 -0
- package/dist/assets/vendor-codemirror-lang-yaml-D5hBv7m6.js +1 -0
- package/dist/assets/{vendor-codemirror-language-data-CqU7kHmg.js → vendor-codemirror-language-data-vn2RyN9T.js} +2 -2
- package/dist/assets/vendor-codemirror-search-BVCYIV0D.js +2 -0
- package/dist/assets/vendor-dompurify-BGCr_sdL.js +3 -0
- package/dist/assets/vendor-elkjs-D1S1RCAO.js +24 -0
- package/dist/assets/vendor-fuse.js-t_7AcMTv.js +1 -0
- package/dist/assets/{vendor-hast-util-to-html-BKBhbTDb.js → vendor-hast-util-to-html-O3stl53j.js} +1 -1
- package/dist/assets/{vendor-heic2any-pq-UTQQR.js → vendor-heic2any-sztndhZI.js} +1 -1
- package/dist/assets/vendor-lezer-cpp-vqXSn3lv.js +1 -0
- package/dist/assets/vendor-lezer-css-JnEzSyZR.js +1 -0
- package/dist/assets/{vendor-lezer-go-CHIhCNY6.js → vendor-lezer-go-dD2gQMIL.js} +1 -1
- package/dist/assets/{vendor-lezer-html-B3h0MOrG.js → vendor-lezer-html-Cr3U-1pu.js} +1 -1
- package/dist/assets/vendor-lezer-java-CRM0IMCo.js +1 -0
- package/dist/assets/vendor-lezer-javascript-B3s21DIS.js +1 -0
- package/dist/assets/{vendor-lezer-json-BP_UAzLL.js → vendor-lezer-json-DPFM6EBV.js} +1 -1
- package/dist/assets/vendor-lezer-lr-Bllrq8hY.js +1 -0
- package/dist/assets/vendor-lezer-markdown-6-3PLvXG.js +6 -0
- package/dist/assets/vendor-lezer-php-DOyzfHRl.js +1 -0
- package/dist/assets/{vendor-lezer-python-EJ4Im4y2.js → vendor-lezer-python-CdHdN5qt.js} +1 -1
- package/dist/assets/vendor-lezer-rust-CqnW8EMH.js +1 -0
- package/dist/assets/{vendor-lezer-sass-CMi6zfXI.js → vendor-lezer-sass-BbcF4y6A.js} +1 -1
- package/dist/assets/{vendor-lezer-xml-0MHMeZDp.js → vendor-lezer-xml-C31AyWoo.js} +1 -1
- package/dist/assets/{vendor-lezer-yaml-BE2EFjpA.js → vendor-lezer-yaml-Cv908yC2.js} +1 -1
- package/dist/assets/{vendor-lru_map-DOPmc7GU.js → vendor-lru_map-BbiDqlyL.js} +1 -1
- package/dist/assets/vendor-marked-Be78pDn1.js +59 -0
- package/dist/assets/{vendor-oniguruma-parser-C0D4_9rT.js → vendor-oniguruma-parser-BrbMHgHx.js} +1 -1
- package/dist/assets/vendor-oniguruma-to-es-DgwFOwdE.js +94 -0
- package/dist/assets/{vendor-pierre-theming-Dgp7B_O4.js → vendor-pierre-theming-BO6EPniU.js} +1 -1
- package/dist/assets/vendor-property-information-C40bX6nM.js +1 -0
- package/dist/assets/{vendor-qrcode-Dv4uniC1.js → vendor-qrcode-gzL9QFkg.js} +5 -5
- package/dist/assets/vendor-react-Bz1tRBxM.js +1 -0
- package/dist/assets/{vendor-react-drawio-Duu5LgQA.js → vendor-react-drawio-IYnLUY5N.js} +1 -1
- package/dist/assets/vendor-remend-DcBOpbSu.js +24 -0
- package/dist/assets/vendor-replit-codemirror-vim-Cwhyn_5f.js +6 -0
- package/dist/assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js +34 -0
- package/dist/assets/vendor-shiki-BEwTOAFg.js +1 -0
- package/dist/assets/{vendor-shikijs-core-CGM_jqPK.js → vendor-shikijs-core-Ck_OPM_T.js} +1 -1
- package/dist/assets/{vendor-shikijs-engine-javascript-Cme4830A.js → vendor-shikijs-engine-javascript-DL394yyj.js} +1 -1
- package/dist/assets/vendor-shikijs-vscode-textmate-DPFxvYtK.js +3 -0
- package/dist/assets/vendor-tailwind-merge-BKkUfl9q.js +1 -0
- package/dist/assets/vendor-workbox-window-BBnX5xw4.js +2 -0
- package/dist/assets/vendor-zumer-snapdom-SJzqoCHV.js +8 -0
- package/dist/assets/vendor-zustand-CXhN0IMY.js +6 -0
- package/dist/assets/{web-components-DzQ9ybbb.js → web-components-6ORYp3Iv.js} +1 -1
- package/dist/assets/worker-CKCfxIfO.js +153 -0
- package/dist/assets/workerFactory-DlGfNFqf.js +1 -0
- package/dist/assets/zig-BB16gwVL.js +1 -0
- package/dist/index.html +8 -8
- package/dist/mini-chat.html +7 -7
- package/dist/mobile.html +7 -7
- package/package.json +54 -53
- package/server/index.js +18 -1
- package/server/lib/client-auth/live-revocation.test.js +4 -0
- package/server/lib/fs/DOCUMENTATION.md +10 -0
- package/server/lib/fs/project-icon.js +243 -0
- package/server/lib/fs/project-icon.test.js +114 -0
- package/server/lib/fs/routes.js +35 -0
- package/server/lib/fs/routes.test.js +74 -0
- package/server/lib/git/DOCUMENTATION.md +2 -1
- package/server/lib/git/routes.js +11 -3
- package/server/lib/git/routes.test.js +80 -0
- package/server/lib/git/service.js +38 -3
- package/server/lib/git/service.test.js +93 -0
- package/server/lib/open-url/DOCUMENTATION.md +35 -0
- package/server/lib/open-url/browser-env.js +199 -0
- package/server/lib/open-url/browser-env.test.js +147 -0
- package/server/lib/open-url/browser-handler.mjs +154 -0
- package/server/lib/open-url/browser-handler.test.js +69 -0
- package/server/lib/open-url/intake.js +187 -0
- package/server/lib/open-url/intake.test.js +75 -0
- package/server/lib/pi/extension-protocol.js +149 -0
- package/server/lib/pi/extension-protocol.test.js +20 -1
- package/server/lib/pi/routes.js +195 -1
- package/server/lib/pi/routes.test.js +129 -0
- package/server/lib/pi/session-daemon/DOCUMENTATION.md +38 -10
- package/server/lib/pi/session-daemon/builtin-extensions.js +14 -4
- package/server/lib/pi/session-daemon/daemon-process.js +13 -0
- package/server/lib/pi/session-daemon/extension-bridge-draft.test.js +6 -1
- package/server/lib/pi/session-daemon/extension-bridge.js +40 -6
- package/server/lib/pi/session-daemon/extension-custom-host.js +1259 -0
- package/server/lib/pi/session-daemon/extension-custom-host.test.js +759 -0
- package/server/lib/pi/session-daemon/extension-keybindings.js +21 -0
- package/server/lib/pi/session-daemon/extension-keybindings.test.js +37 -0
- package/server/lib/pi/session-daemon/extension-message-render.js +7 -4
- package/server/lib/pi/session-daemon/extension-message-render.test.js +14 -2
- package/server/lib/pi/session-daemon/extension-tool-render.js +7 -0
- package/server/lib/pi/session-daemon/extension-tool-render.test.js +26 -0
- package/server/lib/pi/session-daemon/open-request.js +60 -0
- package/server/lib/pi/session-daemon/open-request.test.js +54 -0
- package/server/lib/pi/session-daemon/prompt-preflight.test.js +134 -0
- package/server/lib/pi/session-daemon/sdk-upgrade.test.js +21 -4
- package/server/lib/pi/session-daemon/session-daemon-bash.e2e.test.js +225 -0
- package/server/lib/pi/session-daemon/session-daemon-directory-catalog.e2e.test.js +156 -0
- package/server/lib/pi/session-daemon/session-daemon-directory-catalog.test.js +381 -0
- package/server/lib/pi/session-daemon/session-daemon-engines.test.js +11 -2
- package/server/lib/pi/session-daemon/session-daemon-extensions.test.js +30 -4
- package/server/lib/pi/session-daemon/session-daemon-list-live.test.js +20 -0
- package/server/lib/pi/session-daemon/session-daemon-mcp.e2e.test.js +16 -4
- package/server/lib/pi/session-daemon/session-daemon-turn.e2e.test.js +7 -2
- package/server/lib/pi/session-daemon/session-daemon.js +448 -49
- package/server/lib/pi/session-daemon/session-daemon.test.js +91 -4
- package/server/lib/pi/session-daemon/session-engine-router.js +9 -3
- package/server/lib/pi/session-daemon/session-engine-router.test.js +12 -2
- package/server/lib/pi/session-daemon/session-engines.js +7 -2
- package/server/lib/pi/session-daemon/session-jsonl.js +170 -75
- package/server/lib/pi/session-daemon/session-jsonl.test.js +106 -2
- package/server/lib/pi/session-daemon/supervisor.js +4 -0
- package/server/lib/pi/session-daemon/user-bash.js +326 -0
- package/server/lib/pi/session-daemon/user-bash.test.js +371 -0
- package/server/lib/preview/proxy-runtime.js +140 -45
- package/server/lib/preview/proxy-runtime.test.js +174 -3
- package/server/lib/preview/proxy-runtime.websocket.test.js +89 -0
- package/server/lib/relay/tunnel-host.js +1 -0
- package/server/lib/security/request-security.js +37 -0
- package/server/lib/security/request-security.test.js +54 -0
- package/server/lib/security/server-network-host.js +107 -0
- package/server/lib/security/server-network-host.test.js +70 -0
- package/server/lib/server-browser/DOCUMENTATION.md +243 -0
- package/server/lib/server-browser/browser-tab.js +524 -0
- package/server/lib/server-browser/chrome-executable.js +138 -0
- package/server/lib/server-browser/chrome-launch.js +138 -0
- package/server/lib/server-browser/dev-servers.js +288 -0
- package/server/lib/server-browser/dev-servers.test.js +152 -0
- package/server/lib/server-browser/downloads.js +75 -0
- package/server/lib/server-browser/frame-policy.js +183 -0
- package/server/lib/server-browser/frame-policy.test.js +98 -0
- package/server/lib/server-browser/network-guard.js +235 -0
- package/server/lib/server-browser/page-scripts.js +209 -0
- package/server/lib/server-browser/runtime.integration.test.js +474 -0
- package/server/lib/server-browser/runtime.js +300 -0
- package/server/lib/server-browser/runtime.test.js +50 -0
- package/server/lib/server-browser/server-browser.js +431 -0
- package/server/lib/server-browser/server-browser.test.js +975 -0
- package/server/lib/server-browser/tab-input.js +241 -0
- package/server/lib/server-browser/tab-prompts.js +125 -0
- package/server/lib/server-browser/tab-stream.js +252 -0
- package/server/lib/server-browser/uploads.js +98 -0
- package/server/lib/stt/runtime.js +4 -1
- package/server/lib/stt/runtime.test.js +43 -0
- package/server/lib/terminal/runtime.js +4 -1
- package/server/lib/terminal/runtime.test.js +41 -0
- package/server/lib/ui-auth/DOCUMENTATION.md +29 -1
- package/server/lib/ui-auth/ui-auth.js +1 -0
- package/server/lib/ui-auth/ui-auth.test.js +9 -1
- package/server/lib/workspace/host.js +20 -3
- package/dist/assets/DiffView-CSonR3pr.js +0 -18
- package/dist/assets/FileSaveConflictDialog-Cun0LIbj.js +0 -3
- package/dist/assets/PullRequestsSurface-CfaOpeZn.js +0 -2
- package/dist/assets/SessionSwitcherDropdown-BSutduo7.js +0 -2
- package/dist/assets/SessionUnreadDot-Dav_rix1.js +0 -1
- package/dist/assets/SettingsView-CQJkOPJh.js +0 -6
- package/dist/assets/abap-BdImnpbu.js +0 -1
- package/dist/assets/actionscript-3-CoDkCxhg.js +0 -1
- package/dist/assets/ada-bCR0ucgS.js +0 -1
- package/dist/assets/angular-html-CU67Zn6k.js +0 -1
- package/dist/assets/angular-ts-BwZT4LLn.js +0 -1
- package/dist/assets/apache-Pmp26Uib.js +0 -1
- package/dist/assets/apex-D8_7TLub.js +0 -1
- package/dist/assets/apl-dKokRX4l.js +0 -1
- package/dist/assets/applescript-Co6uUVPk.js +0 -1
- package/dist/assets/ara-BRHolxvo.js +0 -1
- package/dist/assets/asciidoc-Ve4PFQV2.js +0 -1
- package/dist/assets/asm-D_Q5rh1f.js +0 -1
- package/dist/assets/astro-CbQHKStN.js +0 -1
- package/dist/assets/awk-DMzUqQB5.js +0 -1
- package/dist/assets/ballerina-BFfxhgS-.js +0 -1
- package/dist/assets/bat-BkioyH1T.js +0 -1
- package/dist/assets/beancount-k_qm7-4y.js +0 -1
- package/dist/assets/berry-uYugtg8r.js +0 -1
- package/dist/assets/bibtex-CHM0blh-.js +0 -1
- package/dist/assets/bicep-Bmn6On1c.js +0 -1
- package/dist/assets/bird2-DPOp833l.js +0 -1
- package/dist/assets/blade-D4QpJJKB.js +0 -1
- package/dist/assets/bsl-BO_Y6i37.js +0 -1
- package/dist/assets/c-BIGW1oBm.js +0 -1
- package/dist/assets/c3-eo99z4R2.js +0 -1
- package/dist/assets/cadence-Bv_4Rxtq.js +0 -1
- package/dist/assets/cairo-KRGpt6FW.js +0 -1
- package/dist/assets/clarity-D53aC0YG.js +0 -1
- package/dist/assets/clojure-P80f7IUj.js +0 -1
- package/dist/assets/cmake-D1j8_8rp.js +0 -1
- package/dist/assets/cobol-nwyudZeR.js +0 -1
- package/dist/assets/codeowners-Bp6g37R7.js +0 -1
- package/dist/assets/codeql-DsOJ9woJ.js +0 -1
- package/dist/assets/coffee-Ch7k5sss.js +0 -1
- package/dist/assets/common-lisp-Cg-RD9OK.js +0 -1
- package/dist/assets/coq-DkFqJrB1.js +0 -1
- package/dist/assets/cpp-CofmeUqb.js +0 -1
- package/dist/assets/crystal-tKQVLTB8.js +0 -1
- package/dist/assets/csharp-COcwbKMJ.js +0 -1
- package/dist/assets/css-DPfMkruS.js +0 -1
- package/dist/assets/csv-fuZLfV_i.js +0 -1
- package/dist/assets/cue-D82EKSYY.js +0 -1
- package/dist/assets/cypher-COkxafJQ.js +0 -1
- package/dist/assets/d-85-TOEBH.js +0 -1
- package/dist/assets/dart-CF10PKvl.js +0 -1
- package/dist/assets/dax-CEL-wOlO.js +0 -1
- package/dist/assets/desktop-BmXAJ9_W.js +0 -1
- package/dist/assets/diff-D97Zzqfu.js +0 -1
- package/dist/assets/docker-BcOcwvcX.js +0 -1
- package/dist/assets/dotenv-Da5cRb03.js +0 -1
- package/dist/assets/dream-maker-BtqSS_iP.js +0 -1
- package/dist/assets/edge-BkV0erSs.js +0 -1
- package/dist/assets/elixir-CDX3lj18.js +0 -1
- package/dist/assets/elm-DbKCFpqz.js +0 -1
- package/dist/assets/emacs-lisp-C9XAeP06.js +0 -1
- package/dist/assets/erb-B12qg9BL.js +0 -1
- package/dist/assets/erlang-DsQrWhSR.js +0 -1
- package/dist/assets/fennel-BYunw83y.js +0 -1
- package/dist/assets/fish-BvzEVeQv.js +0 -1
- package/dist/assets/fluent-C4IJs8-o.js +0 -1
- package/dist/assets/fortran-fixed-form-CkoXwp7k.js +0 -1
- package/dist/assets/fortran-free-form-BxgE0vQu.js +0 -1
- package/dist/assets/fsharp-CXgrBDvD.js +0 -1
- package/dist/assets/gdresource-BOOCDP_w.js +0 -1
- package/dist/assets/gdscript-C5YyOfLZ.js +0 -1
- package/dist/assets/gdshader-DkwncUOv.js +0 -1
- package/dist/assets/genie-D0YGMca9.js +0 -1
- package/dist/assets/gherkin-DyxjwDmM.js +0 -1
- package/dist/assets/git-commit-F4YmCXRG.js +0 -1
- package/dist/assets/git-rebase-r7XF79zn.js +0 -1
- package/dist/assets/gleam-BspZqrRM.js +0 -1
- package/dist/assets/glimmer-js-Rg0-pVw9.js +0 -1
- package/dist/assets/glimmer-ts-U6CK756n.js +0 -1
- package/dist/assets/glsl-DplSGwfg.js +0 -1
- package/dist/assets/gn-n2N0HUVH.js +0 -1
- package/dist/assets/gnuplot-DdkO51Og.js +0 -1
- package/dist/assets/go-CxLEBnE3.js +0 -1
- package/dist/assets/graphql-ChdNCCLP.js +0 -1
- package/dist/assets/groovy-gcz8RCvz.js +0 -1
- package/dist/assets/hack-CaT9iCJl.js +0 -1
- package/dist/assets/haml-B8DHNrY2.js +0 -1
- package/dist/assets/handlebars-BL8al0AC.js +0 -1
- package/dist/assets/haskell-Df6bDoY_.js +0 -1
- package/dist/assets/haxe-CzTSHFRz.js +0 -1
- package/dist/assets/hcl-BWvSN4gD.js +0 -1
- package/dist/assets/hjson-D5-asLiD.js +0 -1
- package/dist/assets/hlsl-D3lLCCz7.js +0 -1
- package/dist/assets/html-GMplVEZG.js +0 -1
- package/dist/assets/html-derivative-BFtXZ54Q.js +0 -1
- package/dist/assets/http-jrhK8wxY.js +0 -1
- package/dist/assets/hurl-irOxFIW8.js +0 -1
- package/dist/assets/hxml-Bvhsp5Yf.js +0 -1
- package/dist/assets/hy-DFXneXwc.js +0 -1
- package/dist/assets/imba-DGztddWO.js +0 -1
- package/dist/assets/index-B0h6_x5N.js +0 -1
- package/dist/assets/index-BwoW_-vk.css +0 -1
- package/dist/assets/ini-BEwlwnbL.js +0 -1
- package/dist/assets/java-CylS5w8V.js +0 -1
- package/dist/assets/javascript-wDzz0qaB.js +0 -1
- package/dist/assets/jinja-4LBKfQ-Z.js +0 -1
- package/dist/assets/jison-wvAkD_A8.js +0 -1
- package/dist/assets/json-Cp-IABpG.js +0 -1
- package/dist/assets/json5-C9tS-k6U.js +0 -1
- package/dist/assets/jsonc-Des-eS-w.js +0 -1
- package/dist/assets/jsonl-DcaNXYhu.js +0 -1
- package/dist/assets/jsonnet-DFQXde-d.js +0 -1
- package/dist/assets/jssm-C2t-YnRu.js +0 -1
- package/dist/assets/jsx-g9-lgVsj.js +0 -1
- package/dist/assets/julia-CxzCAyBv.js +0 -1
- package/dist/assets/just-Cw27pwNe.js +0 -1
- package/dist/assets/kdl-DV7GczEv.js +0 -1
- package/dist/assets/kotlin-BdnUsdx6.js +0 -1
- package/dist/assets/kusto-DZf3V79B.js +0 -1
- package/dist/assets/latex-CWtU0Tv5.js +0 -1
- package/dist/assets/lean-BZvkOJ9d.js +0 -1
- package/dist/assets/less-B1dDrJ26.js +0 -1
- package/dist/assets/liquid-DYVedYrR.js +0 -1
- package/dist/assets/llvm-DjAJT7YJ.js +0 -1
- package/dist/assets/log-2UxHyX5q.js +0 -1
- package/dist/assets/logo-BtOb2qkB.js +0 -1
- package/dist/assets/lua-BaeVxFsk.js +0 -1
- package/dist/assets/luau-C-HG3fhB.js +0 -1
- package/dist/assets/main-C6i4ph9N.js +0 -2
- package/dist/assets/main-r5elIPBi.js +0 -136
- package/dist/assets/make-CHLpvVh8.js +0 -1
- package/dist/assets/markdown-Cvjx9yec.js +0 -1
- package/dist/assets/markdownCore-C2YQ3Z0q.js +0 -2
- package/dist/assets/marko-CnJfTvn9.js +0 -1
- package/dist/assets/matlab-D7o27uSR.js +0 -1
- package/dist/assets/mdc-BMNejdWA.js +0 -1
- package/dist/assets/mdx-Cmh6b_Ma.js +0 -1
- package/dist/assets/mermaid-mWjccvbQ.js +0 -1
- package/dist/assets/miniChat-d_GCHoIf.js +0 -2
- package/dist/assets/mipsasm-CKIfxQSi.js +0 -1
- package/dist/assets/mobile-BJ3tgyKd.js +0 -2
- package/dist/assets/mojo-rZm6bMo-.js +0 -1
- package/dist/assets/moonbit-_H4v1dQx.js +0 -1
- package/dist/assets/move-IF9eRakj.js +0 -1
- package/dist/assets/narrat-DRg8JJMk.js +0 -1
- package/dist/assets/nextflow-Zz6hmt5N.js +0 -1
- package/dist/assets/nextflow-groovy-BeH2EWoN.js +0 -1
- package/dist/assets/nginx-BpAMiNFr.js +0 -1
- package/dist/assets/nim-CVrawwO9.js +0 -1
- package/dist/assets/nix-CwoSXNpI.js +0 -1
- package/dist/assets/nsis-LdVXkNf5.js +0 -1
- package/dist/assets/nushell-Cz2AlsmD.js +0 -1
- package/dist/assets/objective-c-DXmwc3jG.js +0 -1
- package/dist/assets/objective-cpp-CLxacb5B.js +0 -1
- package/dist/assets/ocaml-C0hk2d4L.js +0 -1
- package/dist/assets/odin-BBf5iR-q.js +0 -1
- package/dist/assets/openscad-C4EeE6gA.js +0 -1
- package/dist/assets/pascal-D93ZcfNL.js +0 -1
- package/dist/assets/perl-C0TMdlhV.js +0 -1
- package/dist/assets/permissionStore-B9Hkrqny.js +0 -1
- package/dist/assets/php-Dhbhpdrm.js +0 -1
- package/dist/assets/pi-session-focus-preference-BFnGFuvP.js +0 -9
- package/dist/assets/pkl-u5AG7uiY.js +0 -1
- package/dist/assets/plsql-ChMvpjG-.js +0 -1
- package/dist/assets/po-BTJTHyun.js +0 -1
- package/dist/assets/polar-C0HS_06l.js +0 -1
- package/dist/assets/postcss-CXtECtnM.js +0 -1
- package/dist/assets/powerquery-CEu0bR-o.js +0 -1
- package/dist/assets/powershell-Dpen1YoG.js +0 -1
- package/dist/assets/prisma-Dd19v3D-.js +0 -1
- package/dist/assets/prolog-CbFg5uaA.js +0 -1
- package/dist/assets/proto-C7zT0LnQ.js +0 -1
- package/dist/assets/pug-CGlum2m_.js +0 -1
- package/dist/assets/puppet-BMWR74SV.js +0 -1
- package/dist/assets/purescript-CklMAg4u.js +0 -1
- package/dist/assets/python-B6aJPvgy.js +0 -1
- package/dist/assets/qml-3beO22l8.js +0 -1
- package/dist/assets/qmldir-C8lEn-DE.js +0 -1
- package/dist/assets/qss-IeuSbFQv.js +0 -1
- package/dist/assets/r-Dspwwk_N.js +0 -1
- package/dist/assets/racket-BqYA7rlc.js +0 -1
- package/dist/assets/raku-DXvB9xmW.js +0 -1
- package/dist/assets/razor-Uh8Bk_45.js +0 -1
- package/dist/assets/reg-C-SQnVFl.js +0 -1
- package/dist/assets/regexp-CDVJQ6XC.js +0 -1
- package/dist/assets/rel-C3B-1QV4.js +0 -1
- package/dist/assets/renderElectronMiniChatApp-Bap5OwgB.js +0 -2
- package/dist/assets/renderMobileApp-DJbslvby.js +0 -11
- package/dist/assets/riscv-BM1_JUlF.js +0 -1
- package/dist/assets/ron-D8l8udqQ.js +0 -1
- package/dist/assets/rosmsg-BJDFO7_C.js +0 -1
- package/dist/assets/rst-BrH8l1NY.js +0 -1
- package/dist/assets/ruby-B2Rjki9n.js +0 -1
- package/dist/assets/ruby-Dw2BHqvy.js +0 -1
- package/dist/assets/runtimeEndpointReset-D22U_Vjs.js +0 -62
- package/dist/assets/runtimeSurface-k1Eit61v.js +0 -1
- package/dist/assets/rust-B1yitclQ.js +0 -1
- package/dist/assets/sas-cz2c8ADy.js +0 -1
- package/dist/assets/sass-Cj5Yp3dK.js +0 -1
- package/dist/assets/scala-C151Ov-r.js +0 -1
- package/dist/assets/scheme-C98Dy4si.js +0 -1
- package/dist/assets/scss-OYdSNvt2.js +0 -1
- package/dist/assets/sdbl-DVxCFoDh.js +0 -1
- package/dist/assets/shaderlab-Dg9Lc6iA.js +0 -1
- package/dist/assets/shellscript-Yzrsuije.js +0 -1
- package/dist/assets/shellsession-BADoaaVG.js +0 -1
- package/dist/assets/smalltalk-BERRCDM3.js +0 -1
- package/dist/assets/solidity-rGO070M0.js +0 -1
- package/dist/assets/soy-Brmx7dQM.js +0 -1
- package/dist/assets/sparql-rVzFXLq3.js +0 -1
- package/dist/assets/splunk-BtCnVYZw.js +0 -1
- package/dist/assets/sql-BLtJtn59.js +0 -1
- package/dist/assets/ssh-config-_ykCGR6B.js +0 -1
- package/dist/assets/stata-BH5u7GGu.js +0 -1
- package/dist/assets/stylus-BEDo0Tqx.js +0 -1
- package/dist/assets/surrealql-Bq5Q-fJD.js +0 -1
- package/dist/assets/svelte-C_ipcX3V.js +0 -1
- package/dist/assets/swift-D82vCrfD.js +0 -1
- package/dist/assets/system-verilog-CnnmHF94.js +0 -1
- package/dist/assets/systemd-4A_iFExJ.js +0 -1
- package/dist/assets/talonscript-CkByrt1z.js +0 -1
- package/dist/assets/tasl-QIJgUcNo.js +0 -1
- package/dist/assets/tcl-dwOrl1Do.js +0 -1
- package/dist/assets/templ-P3uqSqPl.js +0 -1
- package/dist/assets/terraform-BETggiCN.js +0 -1
- package/dist/assets/tex-idrVyKtj.js +0 -1
- package/dist/assets/themeResolver-yJ9XpNMI.js +0 -1
- package/dist/assets/toml-vGWfd6FD.js +0 -1
- package/dist/assets/ts-tags-zn1MmPIZ.js +0 -1
- package/dist/assets/tsv-B_m7g4N7.js +0 -1
- package/dist/assets/tsx-COt5Ahok.js +0 -1
- package/dist/assets/turtle-BsS91CYL.js +0 -1
- package/dist/assets/twig-DNn4PbVi.js +0 -1
- package/dist/assets/typescript-BPQ3VLAy.js +0 -1
- package/dist/assets/typespec-BGHnOYBU.js +0 -1
- package/dist/assets/typst-DHCkPAjA.js +0 -1
- package/dist/assets/useAppFontEffects-CqHhRKmN.js +0 -212
- package/dist/assets/useFilesViewSearch-CqoYEK0U.js +0 -7
- package/dist/assets/v-BcVCzyr7.js +0 -1
- package/dist/assets/vala-CsfeWuGM.js +0 -1
- package/dist/assets/vb-D17OF-Vu.js +0 -1
- package/dist/assets/vendor-aparajita-capacitor-secure-storage-BDrMx_CE.js +0 -1
- package/dist/assets/vendor-base-ui-CKRUCG-f.js +0 -1
- package/dist/assets/vendor-boot-EC6IyLt1.js +0 -69
- package/dist/assets/vendor-codemirror-autocomplete-CGpAsPWp.js +0 -1
- package/dist/assets/vendor-codemirror-lang-angular-CDJoHJSY.js +0 -1
- package/dist/assets/vendor-codemirror-lang-cpp-BmHofQls.js +0 -1
- package/dist/assets/vendor-codemirror-lang-css-RM2HqXZ0.js +0 -1
- package/dist/assets/vendor-codemirror-lang-html-CHSHUpwq.js +0 -1
- package/dist/assets/vendor-codemirror-lang-java-lhQXgWu0.js +0 -1
- package/dist/assets/vendor-codemirror-lang-javascript-Dw4kFO4e.js +0 -13
- package/dist/assets/vendor-codemirror-lang-jinja-_pAC3UTN.js +0 -1
- package/dist/assets/vendor-codemirror-lang-json-B-b1vAv-.js +0 -1
- package/dist/assets/vendor-codemirror-lang-less-xIgOi1ze.js +0 -1
- package/dist/assets/vendor-codemirror-lang-liquid-CP49m5dB.js +0 -1
- package/dist/assets/vendor-codemirror-lang-markdown-BTht2ATe.js +0 -1
- package/dist/assets/vendor-codemirror-lang-php-BguZDhaO.js +0 -1
- package/dist/assets/vendor-codemirror-lang-python-CH6_em9L.js +0 -3
- package/dist/assets/vendor-codemirror-lang-rust-EG_DtGyi.js +0 -1
- package/dist/assets/vendor-codemirror-lang-sass-BknY5Qpo.js +0 -1
- package/dist/assets/vendor-codemirror-lang-vue-CyGn9snv.js +0 -1
- package/dist/assets/vendor-codemirror-lang-wast-CsFfSyyB.js +0 -1
- package/dist/assets/vendor-codemirror-lang-xml-Cdan_Jp1.js +0 -1
- package/dist/assets/vendor-codemirror-lang-yaml-COI5hck8.js +0 -1
- package/dist/assets/vendor-codemirror-search-DUfSCF9S.js +0 -2
- package/dist/assets/vendor-dompurify-r8glNMJW.js +0 -2
- package/dist/assets/vendor-elkjs-D27273Ms.js +0 -24
- package/dist/assets/vendor-fuse.js-Dw8P0qyA.js +0 -1
- package/dist/assets/vendor-lezer-cpp-DMZOJzBa.js +0 -1
- package/dist/assets/vendor-lezer-css-DUkkbMp7.js +0 -1
- package/dist/assets/vendor-lezer-java-tMazV_6X.js +0 -1
- package/dist/assets/vendor-lezer-javascript-ctwLWf4v.js +0 -1
- package/dist/assets/vendor-lezer-lr-B8TQctNw.js +0 -1
- package/dist/assets/vendor-lezer-markdown-aGLZf_3h.js +0 -6
- package/dist/assets/vendor-lezer-php-D5zCNzlt.js +0 -1
- package/dist/assets/vendor-lezer-rust-DO5c7OtA.js +0 -1
- package/dist/assets/vendor-marked-CX41MkDF.js +0 -59
- package/dist/assets/vendor-oniguruma-to-es-DLBnFDCE.js +0 -94
- package/dist/assets/vendor-property-information-rJCbAzvX.js +0 -1
- package/dist/assets/vendor-react-DASdDPIk.js +0 -1
- package/dist/assets/vendor-remend-BWYYytN3.js +0 -22
- package/dist/assets/vendor-replit-codemirror-vim-AnOuN8yJ.js +0 -39
- package/dist/assets/vendor-shiki-Bbf2GEcE.js +0 -2
- package/dist/assets/vendor-shikijs-vscode-textmate-BgLrS_2D.js +0 -3
- package/dist/assets/vendor-tailwind-merge-CPcsbTWB.js +0 -1
- package/dist/assets/vendor-workbox-window-BIl4cyR9.js +0 -2
- package/dist/assets/vendor-zumer-snapdom-Btyu_Xi2.js +0 -8
- package/dist/assets/vendor-zustand-CUi8eEds.js +0 -6
- package/dist/assets/verilog-BQ8w6xss.js +0 -1
- package/dist/assets/vhdl-CeAyd5Ju.js +0 -1
- package/dist/assets/viml-CJc9bBzg.js +0 -1
- package/dist/assets/vue-DN_0RTcg.js +0 -1
- package/dist/assets/vue-html-AaS7Mt5G.js +0 -1
- package/dist/assets/vue-vine-CQOfvN7w.js +0 -1
- package/dist/assets/vyper-CDx5xZoG.js +0 -1
- package/dist/assets/wasm-MzD3tlZU.js +0 -1
- package/dist/assets/wenyan-BV7otONQ.js +0 -1
- package/dist/assets/wgsl-Dx-B1_4e.js +0 -1
- package/dist/assets/wikitext-BhOHFoWU.js +0 -1
- package/dist/assets/wit-5i3qLPDT.js +0 -1
- package/dist/assets/wolfram-lXgVvXCa.js +0 -1
- package/dist/assets/worker-BBk7yuNN.js +0 -153
- package/dist/assets/workerFactory-tw7cIdmV.js +0 -1
- package/dist/assets/xml-sdJ4AIDG.js +0 -1
- package/dist/assets/xsl-CtQFsRM5.js +0 -1
- package/dist/assets/yaml-Buea-lGh.js +0 -1
- package/dist/assets/zenscript-DVFEvuxE.js +0 -1
- package/dist/assets/zig-VOosw3JB.js +0 -1
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { execFile } from 'node:child_process';
|
|
2
|
+
|
|
3
|
+
import { chromium } from 'playwright-core';
|
|
4
|
+
|
|
5
|
+
// Chrome's first start on a fresh machine has taken 13 to 30 seconds.
|
|
6
|
+
const LAUNCH_TIMEOUT_MS = 30_000;
|
|
7
|
+
const VERSION_TIMEOUT_MS = 10_000;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Flags added to Playwright's own. Pages keep running while nobody watches
|
|
11
|
+
* them (Playwright already turns off background throttling), because a viewer
|
|
12
|
+
* can attach at any time and expects a live page. Screencasts ignore the
|
|
13
|
+
* emulated device scale, so Chrome draws at 2x and each viewer's stream is
|
|
14
|
+
* scaled down to its own pixel ratio.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* The device scale factor Chrome draws at. Its screencast ignores an emulated
|
|
18
|
+
* scale, so Chrome starts at this one and pages are emulated at it too: while
|
|
19
|
+
* the two differ (when Chrome takes a screenshot, or while a page swaps
|
|
20
|
+
* renderers), input lands at scaled coordinates. Viewers with a lower pixel
|
|
21
|
+
* ratio get a scaled-down stream.
|
|
22
|
+
*/
|
|
23
|
+
export const CHROME_SCALE_FACTOR = 2;
|
|
24
|
+
|
|
25
|
+
const chromeArgs = (extraArgs = []) => [
|
|
26
|
+
'--disable-gpu',
|
|
27
|
+
`--force-device-scale-factor=${CHROME_SCALE_FACTOR}`,
|
|
28
|
+
'--hide-crash-restore-bubble',
|
|
29
|
+
// Without this, `navigator.webdriver` is true and sign-in pages refuse.
|
|
30
|
+
'--disable-blink-features=AutomationControlled',
|
|
31
|
+
...extraArgs,
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
// Playwright defaults the server browser must not have: the automation
|
|
35
|
+
// banner and flag, popups without a click, and hidden scrollbars (people
|
|
36
|
+
// scroll with them).
|
|
37
|
+
const IGNORED_DEFAULT_ARGS = ['--enable-automation', '--disable-popup-blocking', '--hide-scrollbars'];
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Turns a failed launch into something the setup message can explain.
|
|
41
|
+
* `text` is Chrome's stderr, or Playwright's launch error, which quotes it.
|
|
42
|
+
* @returns {{ kind: 'missing-library' | 'sandbox-root' | 'sandbox-namespaces' | 'unknown', library?: string, detail: string }}
|
|
43
|
+
*/
|
|
44
|
+
export const classifyLaunchFailure = (text, { isRoot = false } = {}) => {
|
|
45
|
+
// The command line Playwright quotes names flags such as `--no-sandbox`.
|
|
46
|
+
const raw = String(text || '').split('\n').filter((line) => !line.includes('<launching>')).join('\n');
|
|
47
|
+
// Playwright prefixes each stderr line with `[pid=N][err]`.
|
|
48
|
+
const stderr = [...raw.matchAll(/\[pid=\d+\]\[err\] ?(.*)/g)].map((match) => match[1]);
|
|
49
|
+
const lines = stderr.length > 0 ? [...new Set(stderr)] : raw.trim().split('\n');
|
|
50
|
+
const detail = lines.slice(-6).join('\n').slice(-1200);
|
|
51
|
+
const library = /error while loading shared libraries: ([^:\s]+)/.exec(raw);
|
|
52
|
+
if (library) return { kind: 'missing-library', library: library[1], detail };
|
|
53
|
+
const sandbox = /sandbox/i.test(raw);
|
|
54
|
+
if (/Running as root without --no-sandbox/i.test(raw) || (isRoot && sandbox)) return { kind: 'sandbox-root', detail };
|
|
55
|
+
if (/No usable sandbox|user namespaces|setuid sandbox|sandboxing failed/i.test(raw)) return { kind: 'sandbox-namespaces', detail };
|
|
56
|
+
return { kind: 'unknown', detail };
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export class ChromeLaunchError extends Error {
|
|
60
|
+
constructor(failure) {
|
|
61
|
+
super(failure.detail || 'Chrome did not start');
|
|
62
|
+
this.name = 'ChromeLaunchError';
|
|
63
|
+
this.failure = failure;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const UA_PLATFORMS = {
|
|
68
|
+
darwin: 'Macintosh; Intel Mac OS X 10_15_7',
|
|
69
|
+
win32: 'Windows NT 10.0; Win64; x64',
|
|
70
|
+
linux: 'X11; Linux x86_64',
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* The user agent pages see: a regular Chrome of the running version, without
|
|
75
|
+
* the `HeadlessChrome` marker many sites refuse. Like Chrome itself, it
|
|
76
|
+
* reports only the major version. `null` when the version is unknown.
|
|
77
|
+
*/
|
|
78
|
+
export const pageUserAgent = (version, platform = process.platform) => {
|
|
79
|
+
const major = /(\d+)\.\d+\.\d+\.\d+/.exec(String(version || ''))?.[1];
|
|
80
|
+
if (!major) return null;
|
|
81
|
+
return `Mozilla/5.0 (${UA_PLATFORMS[platform] || UA_PLATFORMS.linux}) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${major}.0.0.0 Safari/537.36`;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* The executable's version from `--version`, or `null`. Not asked on
|
|
86
|
+
* Windows: Chrome there prints nothing and may open a browser window, which
|
|
87
|
+
* would hold up the launch until the probe times out. The launch then
|
|
88
|
+
* learns the version from the running browser.
|
|
89
|
+
*/
|
|
90
|
+
export const chromeVersion = (executable, { env = process.env, platform = process.platform } = {}) => new Promise((resolve) => {
|
|
91
|
+
if (platform === 'win32') {
|
|
92
|
+
resolve(null);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
execFile(executable, ['--version'], { env, timeout: VERSION_TIMEOUT_MS, windowsHide: true }, (error, stdout) => {
|
|
96
|
+
resolve(error ? null : (/\d+\.\d+\.\d+\.\d+/.exec(String(stdout))?.[0] ?? null));
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Starts Chrome on a persistent profile and returns its Playwright context.
|
|
102
|
+
* Rejects with a `ChromeLaunchError` when Chrome exits or does not answer.
|
|
103
|
+
*/
|
|
104
|
+
export const launchChrome = async ({
|
|
105
|
+
executable,
|
|
106
|
+
userDataDir,
|
|
107
|
+
noSandbox = false,
|
|
108
|
+
extraArgs = [],
|
|
109
|
+
isRoot = false,
|
|
110
|
+
env = process.env,
|
|
111
|
+
userAgent = null,
|
|
112
|
+
launchTimeoutMs = LAUNCH_TIMEOUT_MS,
|
|
113
|
+
}) => {
|
|
114
|
+
try {
|
|
115
|
+
return await chromium.launchPersistentContext(userDataDir, {
|
|
116
|
+
executablePath: executable,
|
|
117
|
+
headless: true,
|
|
118
|
+
chromiumSandbox: !noSandbox,
|
|
119
|
+
// The viewer sets the page size; Playwright must not.
|
|
120
|
+
viewport: null,
|
|
121
|
+
...(userAgent ? { userAgent } : {}),
|
|
122
|
+
acceptDownloads: true,
|
|
123
|
+
args: chromeArgs(extraArgs),
|
|
124
|
+
ignoreDefaultArgs: IGNORED_DEFAULT_ARGS,
|
|
125
|
+
env,
|
|
126
|
+
timeout: launchTimeoutMs,
|
|
127
|
+
// PiChamber stops Chrome on its own shutdown.
|
|
128
|
+
handleSIGINT: false,
|
|
129
|
+
handleSIGTERM: false,
|
|
130
|
+
handleSIGHUP: false,
|
|
131
|
+
});
|
|
132
|
+
} catch (error) {
|
|
133
|
+
if (error?.name === 'TimeoutError') {
|
|
134
|
+
throw new ChromeLaunchError({ kind: 'unknown', detail: `Chrome did not answer within ${Math.round(launchTimeoutMs / 1000)}s.` });
|
|
135
|
+
}
|
|
136
|
+
throw new ChromeLaunchError(classifyLaunchFailure(error?.message || String(error), { isRoot }));
|
|
137
|
+
}
|
|
138
|
+
};
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
import { execFile as execFileCallback } from 'node:child_process';
|
|
2
|
+
import fs from 'node:fs/promises';
|
|
3
|
+
import http from 'node:http';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
|
|
6
|
+
const MAX_CANDIDATES = 48;
|
|
7
|
+
const PROBE_CONCURRENCY = 8;
|
|
8
|
+
const PROBE_TIMEOUT_MS = 800;
|
|
9
|
+
const PROBE_MAX_BYTES = 64 * 1024;
|
|
10
|
+
const CACHE_MS = 3_000;
|
|
11
|
+
const MIN_PORT = 1024;
|
|
12
|
+
|
|
13
|
+
const LISTEN_STATE = '0A';
|
|
14
|
+
const V4_ANY = '00000000';
|
|
15
|
+
const V6_ANY = '0'.repeat(32);
|
|
16
|
+
const V6_LOOPBACK = '00000000000000000000000001000000';
|
|
17
|
+
const V4_MAPPED_PREFIX = '0000000000000000FFFF0000';
|
|
18
|
+
|
|
19
|
+
const reachableFromLoopback = (hexAddress) => {
|
|
20
|
+
const address = hexAddress.toUpperCase();
|
|
21
|
+
if (address.length === 8) return address === V4_ANY || address.endsWith('7F') ? '127.0.0.1' : null;
|
|
22
|
+
if (address === V6_ANY || address === V6_LOOPBACK) return '::1';
|
|
23
|
+
if (address.startsWith(V4_MAPPED_PREFIX)) {
|
|
24
|
+
const v4 = address.slice(V4_MAPPED_PREFIX.length);
|
|
25
|
+
return v4 === V4_ANY || v4.endsWith('7F') ? '127.0.0.1' : null;
|
|
26
|
+
}
|
|
27
|
+
return null;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Listening sockets from a Linux `/proc/net/tcp` or `tcp6` table that a
|
|
32
|
+
* loopback request can reach.
|
|
33
|
+
*/
|
|
34
|
+
export const parseProcNetTcp = (text) => {
|
|
35
|
+
const sockets = [];
|
|
36
|
+
for (const line of String(text).split('\n').slice(1)) {
|
|
37
|
+
const fields = line.trim().split(/\s+/);
|
|
38
|
+
if (fields.length < 10 || fields[3] !== LISTEN_STATE) continue;
|
|
39
|
+
const [hexAddress, hexPort] = fields[1].split(':');
|
|
40
|
+
const host = reachableFromLoopback(hexAddress || '');
|
|
41
|
+
const port = Number.parseInt(hexPort || '', 16);
|
|
42
|
+
if (!host || !Number.isInteger(port) || port <= 0) continue;
|
|
43
|
+
sockets.push({ host, port, inode: fields[9] });
|
|
44
|
+
}
|
|
45
|
+
return sockets;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/** Listening sockets and their processes from `lsof -nP -iTCP -sTCP:LISTEN -Fpcn`. */
|
|
49
|
+
export const parseLsofListen = (text) => {
|
|
50
|
+
const sockets = [];
|
|
51
|
+
let pid = null;
|
|
52
|
+
let command = null;
|
|
53
|
+
for (const line of String(text).split('\n')) {
|
|
54
|
+
const tag = line[0];
|
|
55
|
+
const value = line.slice(1);
|
|
56
|
+
if (tag === 'p') {
|
|
57
|
+
pid = Number.parseInt(value, 10);
|
|
58
|
+
command = null;
|
|
59
|
+
} else if (tag === 'c') {
|
|
60
|
+
command = value;
|
|
61
|
+
} else if (tag === 'n') {
|
|
62
|
+
const match = /^(.*):(\d+)$/.exec(value);
|
|
63
|
+
if (!match) continue;
|
|
64
|
+
const address = match[1];
|
|
65
|
+
const port = Number.parseInt(match[2], 10);
|
|
66
|
+
let host = null;
|
|
67
|
+
if (address === '*' || address === '127.0.0.1' || address.startsWith('127.')) host = '127.0.0.1';
|
|
68
|
+
else if (address === '[::1]' || address === '[::]') host = '::1';
|
|
69
|
+
if (host) sockets.push({ host, port, pid, command });
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return sockets;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
/** Parses `lsof -a -d cwd -p <pids> -Fpn` into a pid → cwd map. */
|
|
76
|
+
export const parseLsofCwd = (text) => {
|
|
77
|
+
const cwds = new Map();
|
|
78
|
+
let pid = null;
|
|
79
|
+
for (const line of String(text).split('\n')) {
|
|
80
|
+
if (line[0] === 'p') pid = Number.parseInt(line.slice(1), 10);
|
|
81
|
+
else if (line[0] === 'n' && pid !== null) cwds.set(pid, line.slice(1));
|
|
82
|
+
}
|
|
83
|
+
return cwds;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
/** The `<title>` of an HTML document, trimmed and collapsed. */
|
|
87
|
+
const extractTitle = (html) => {
|
|
88
|
+
const match = /<title[^>]*>([\s\S]*?)<\/title>/i.exec(String(html));
|
|
89
|
+
if (!match) return null;
|
|
90
|
+
const title = match[1]
|
|
91
|
+
.replace(/&/g, '&')
|
|
92
|
+
.replace(/</g, '<')
|
|
93
|
+
.replace(/>/g, '>')
|
|
94
|
+
.replace(/"/g, '"')
|
|
95
|
+
.replace(/'/g, "'")
|
|
96
|
+
.replace(/\s+/g, ' ')
|
|
97
|
+
.trim();
|
|
98
|
+
return title ? title.slice(0, 120) : null;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const isWithinDirectory = (child, directory) => {
|
|
102
|
+
if (!child || !directory) return false;
|
|
103
|
+
const relative = path.relative(path.resolve(directory), path.resolve(child));
|
|
104
|
+
return relative === '' || (!relative.startsWith('..') && !path.isAbsolute(relative));
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
/** Sends `GET /` and resolves with the page title, or `undefined` when the port does not speak HTTP. */
|
|
108
|
+
const probeHttp = ({ host, port }) => new Promise((resolve) => {
|
|
109
|
+
let settled = false;
|
|
110
|
+
const finish = (value) => {
|
|
111
|
+
if (settled) return;
|
|
112
|
+
settled = true;
|
|
113
|
+
resolve(value);
|
|
114
|
+
};
|
|
115
|
+
const request = http.request({
|
|
116
|
+
host,
|
|
117
|
+
port,
|
|
118
|
+
path: '/',
|
|
119
|
+
method: 'GET',
|
|
120
|
+
headers: { accept: 'text/html,*/*;q=0.8', 'user-agent': 'PiChamber dev server discovery' },
|
|
121
|
+
timeout: PROBE_TIMEOUT_MS,
|
|
122
|
+
}, (response) => {
|
|
123
|
+
const isHtml = /text\/html/i.test(String(response.headers['content-type'] || ''));
|
|
124
|
+
if (!isHtml) {
|
|
125
|
+
response.destroy();
|
|
126
|
+
finish(null);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
let body = '';
|
|
130
|
+
response.setEncoding('utf8');
|
|
131
|
+
response.on('data', (chunk) => {
|
|
132
|
+
body += chunk;
|
|
133
|
+
if (body.length >= PROBE_MAX_BYTES || /<\/title>/i.test(body)) {
|
|
134
|
+
response.destroy();
|
|
135
|
+
finish(extractTitle(body));
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
response.on('end', () => finish(extractTitle(body)));
|
|
139
|
+
response.on('error', () => finish(extractTitle(body)));
|
|
140
|
+
});
|
|
141
|
+
request.on('timeout', () => { request.destroy(); finish(undefined); });
|
|
142
|
+
request.on('error', () => finish(undefined));
|
|
143
|
+
request.end();
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
const mapLimit = async (items, limit, worker) => {
|
|
147
|
+
const results = new Array(items.length);
|
|
148
|
+
let next = 0;
|
|
149
|
+
const run = async () => {
|
|
150
|
+
while (next < items.length) {
|
|
151
|
+
const index = next++;
|
|
152
|
+
results[index] = await worker(items[index]);
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
await Promise.all(Array.from({ length: Math.min(limit, items.length) }, run));
|
|
156
|
+
return results;
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
const execFileText = (file, args) => new Promise((resolve) => {
|
|
160
|
+
execFileCallback(file, args, { timeout: 2_000, maxBuffer: 1024 * 1024 }, (error, stdout) => {
|
|
161
|
+
// lsof exits 1 when nothing matched; its output is still usable.
|
|
162
|
+
resolve(error && !stdout ? '' : String(stdout || ''));
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
const linuxListeners = async ({ readFile, readdir, readlink }) => {
|
|
167
|
+
const tables = await Promise.all(['/proc/net/tcp', '/proc/net/tcp6'].map((file) => readFile(file, 'utf8').catch(() => '')));
|
|
168
|
+
const sockets = tables.flatMap(parseProcNetTcp);
|
|
169
|
+
if (sockets.length === 0) return [];
|
|
170
|
+
|
|
171
|
+
// Match socket inodes to the processes this user can see.
|
|
172
|
+
const wanted = new Set(sockets.map((socket) => socket.inode));
|
|
173
|
+
const owners = new Map();
|
|
174
|
+
const pids = (await readdir('/proc').catch(() => [])).filter((name) => /^\d+$/.test(name));
|
|
175
|
+
await mapLimit(pids, 16, async (pid) => {
|
|
176
|
+
const fds = await readdir(`/proc/${pid}/fd`).catch(() => []);
|
|
177
|
+
for (const fd of fds) {
|
|
178
|
+
const target = await readlink(`/proc/${pid}/fd/${fd}`).catch(() => '');
|
|
179
|
+
const inode = /^socket:\[(\d+)\]$/.exec(target)?.[1];
|
|
180
|
+
if (inode && wanted.has(inode) && !owners.has(inode)) owners.set(inode, Number(pid));
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
const processInfo = new Map();
|
|
185
|
+
const infoFor = async (pid) => {
|
|
186
|
+
if (!processInfo.has(pid)) {
|
|
187
|
+
// The executable's name: runtimes such as Node rename their main
|
|
188
|
+
// thread, so `comm` often reads "MainThread".
|
|
189
|
+
processInfo.set(pid, Promise.all([
|
|
190
|
+
readlink(`/proc/${pid}/exe`).then((exe) => path.basename(exe.replace(/ \(deleted\)$/, ''))).catch(() => null),
|
|
191
|
+
readFile(`/proc/${pid}/comm`, 'utf8').then((text) => text.trim()).catch(() => null),
|
|
192
|
+
readlink(`/proc/${pid}/cwd`).catch(() => null),
|
|
193
|
+
]).then(([exe, comm, cwd]) => ({ command: exe || comm, cwd })));
|
|
194
|
+
}
|
|
195
|
+
return processInfo.get(pid);
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
return Promise.all(sockets.map(async (socket) => {
|
|
199
|
+
const pid = owners.get(socket.inode) ?? null;
|
|
200
|
+
const info = pid === null ? { command: null, cwd: null } : await infoFor(pid);
|
|
201
|
+
return { host: socket.host, port: socket.port, pid, command: info.command, cwd: info.cwd };
|
|
202
|
+
}));
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
const macListeners = async ({ execFile }) => {
|
|
206
|
+
const sockets = parseLsofListen(await execFile('lsof', ['-nP', '-iTCP', '-sTCP:LISTEN', '-Fpcn']));
|
|
207
|
+
const pids = [...new Set(sockets.map((socket) => socket.pid).filter(Number.isInteger))];
|
|
208
|
+
const cwds = pids.length > 0
|
|
209
|
+
? parseLsofCwd(await execFile('lsof', ['-a', '-d', 'cwd', '-p', pids.join(','), '-Fpn']))
|
|
210
|
+
: new Map();
|
|
211
|
+
return sockets.map((socket) => ({ ...socket, cwd: cwds.get(socket.pid) ?? null }));
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Finds web servers listening on this machine's loopback interface, such as
|
|
216
|
+
* dev servers an agent started. Reports the port, page title, process name,
|
|
217
|
+
* and whether the process runs inside the project; never command lines or
|
|
218
|
+
* paths.
|
|
219
|
+
*/
|
|
220
|
+
export const createDevServerFinder = ({
|
|
221
|
+
platform = process.platform,
|
|
222
|
+
readFile = fs.readFile,
|
|
223
|
+
readdir = fs.readdir,
|
|
224
|
+
readlink = fs.readlink,
|
|
225
|
+
execFile = execFileText,
|
|
226
|
+
probe = probeHttp,
|
|
227
|
+
ownPid = process.pid,
|
|
228
|
+
now = Date.now,
|
|
229
|
+
} = {}) => {
|
|
230
|
+
let cache = null;
|
|
231
|
+
|
|
232
|
+
const listListeners = async () => {
|
|
233
|
+
if (platform === 'linux') return linuxListeners({ readFile, readdir, readlink });
|
|
234
|
+
if (platform === 'darwin') return macListeners({ execFile });
|
|
235
|
+
return null;
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
const scan = async () => {
|
|
239
|
+
const listeners = await listListeners();
|
|
240
|
+
if (!listeners) return { supported: false, listeners: [] };
|
|
241
|
+
// One entry per port; an IPv4 listener answers the loopback probe most reliably.
|
|
242
|
+
const byPort = new Map();
|
|
243
|
+
for (const listener of listeners) {
|
|
244
|
+
if (listener.port < MIN_PORT || listener.pid === ownPid) continue;
|
|
245
|
+
const existing = byPort.get(listener.port);
|
|
246
|
+
if (!existing || (existing.host !== '127.0.0.1' && listener.host === '127.0.0.1') || (!existing.pid && listener.pid)) {
|
|
247
|
+
byPort.set(listener.port, { ...listener, pid: listener.pid ?? existing?.pid ?? null, command: listener.command ?? existing?.command ?? null, cwd: listener.cwd ?? existing?.cwd ?? null });
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
// Ports a visible process owns first; others are usually system services.
|
|
251
|
+
const candidates = [...byPort.values()]
|
|
252
|
+
.sort((a, b) => Number(Boolean(b.pid)) - Number(Boolean(a.pid)) || a.port - b.port)
|
|
253
|
+
.slice(0, MAX_CANDIDATES);
|
|
254
|
+
const titles = await mapLimit(candidates, PROBE_CONCURRENCY, (candidate) => probe(candidate));
|
|
255
|
+
return {
|
|
256
|
+
supported: true,
|
|
257
|
+
listeners: candidates
|
|
258
|
+
.map((candidate, index) => ({ ...candidate, title: titles[index] }))
|
|
259
|
+
.filter((candidate) => candidate.title !== undefined),
|
|
260
|
+
};
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
const listeners = () => {
|
|
264
|
+
if (cache && now() - cache.at < CACHE_MS) return cache.promise;
|
|
265
|
+
const promise = scan().catch(() => ({ supported: true, listeners: [] }));
|
|
266
|
+
cache = { at: now(), promise };
|
|
267
|
+
return promise;
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
return {
|
|
271
|
+
/** Web servers for a project, its own first. `excludePorts` hides PiChamber's own ports. */
|
|
272
|
+
async find({ directory = null, excludePorts = [] } = {}) {
|
|
273
|
+
const { supported, listeners: found } = await listeners();
|
|
274
|
+
const excluded = new Set(excludePorts);
|
|
275
|
+
const servers = found
|
|
276
|
+
.filter((listener) => !excluded.has(listener.port))
|
|
277
|
+
.map((listener) => ({
|
|
278
|
+
url: `http://localhost:${listener.port}/`,
|
|
279
|
+
port: listener.port,
|
|
280
|
+
title: listener.title || null,
|
|
281
|
+
process: listener.command || null,
|
|
282
|
+
inProject: isWithinDirectory(listener.cwd, directory),
|
|
283
|
+
}))
|
|
284
|
+
.sort((a, b) => Number(b.inProject) - Number(a.inProject) || a.port - b.port);
|
|
285
|
+
return { supported, servers };
|
|
286
|
+
},
|
|
287
|
+
};
|
|
288
|
+
};
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import http from 'node:http';
|
|
2
|
+
|
|
3
|
+
import { afterEach, describe, expect, it } from 'vitest';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
createDevServerFinder,
|
|
7
|
+
parseLsofCwd,
|
|
8
|
+
parseLsofListen,
|
|
9
|
+
parseProcNetTcp,
|
|
10
|
+
} from './dev-servers.js';
|
|
11
|
+
|
|
12
|
+
const HEADER = ' sl local_address rem_address st tx_queue rx_queue tr tm->when retrnsmt uid timeout inode';
|
|
13
|
+
const row = (local, state, inode) => ` 0: ${local} 00000000:0000 ${state} 00000000:00000000 00:00000000 00000000 1000 0 ${inode} 1 0 100 0 0 10 0`;
|
|
14
|
+
|
|
15
|
+
describe('parseProcNetTcp', () => {
|
|
16
|
+
it('keeps listening sockets a loopback request can reach', () => {
|
|
17
|
+
const v4 = [
|
|
18
|
+
HEADER,
|
|
19
|
+
row('0100007F:1435', '0A', '11'), // 127.0.0.1:5173
|
|
20
|
+
row('00000000:0BB8', '0A', '12'), // 0.0.0.0:3000
|
|
21
|
+
row('0100A8C0:1F90', '0A', '13'), // 192.168.0.1:8080, not loopback
|
|
22
|
+
row('0100007F:1F91', '01', '14'), // established, not listening
|
|
23
|
+
].join('\n');
|
|
24
|
+
expect(parseProcNetTcp(v4)).toEqual([
|
|
25
|
+
{ host: '127.0.0.1', port: 5173, inode: '11' },
|
|
26
|
+
{ host: '127.0.0.1', port: 3000, inode: '12' },
|
|
27
|
+
]);
|
|
28
|
+
|
|
29
|
+
const v6 = [
|
|
30
|
+
HEADER,
|
|
31
|
+
row('00000000000000000000000001000000:2328', '0A', '21'), // [::1]:9000
|
|
32
|
+
row('0000000000000000FFFF00000100007F:2329', '0A', '22'), // ::ffff:127.0.0.1:9001
|
|
33
|
+
row('B80D0120000000000000000001000000:232A', '0A', '23'), // 2001:db8::1, not loopback
|
|
34
|
+
].join('\n');
|
|
35
|
+
expect(parseProcNetTcp(v6)).toEqual([
|
|
36
|
+
{ host: '::1', port: 9000, inode: '21' },
|
|
37
|
+
{ host: '127.0.0.1', port: 9001, inode: '22' },
|
|
38
|
+
]);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
describe('lsof parsing', () => {
|
|
43
|
+
it('reads listening sockets and working directories', () => {
|
|
44
|
+
const listen = ['p101', 'cnode', 'n*:5173', 'n[::1]:5173', 'p202', 'cpostgres', 'n10.0.0.2:5432', ''].join('\n');
|
|
45
|
+
expect(parseLsofListen(listen)).toEqual([
|
|
46
|
+
{ host: '127.0.0.1', port: 5173, pid: 101, command: 'node' },
|
|
47
|
+
{ host: '::1', port: 5173, pid: 101, command: 'node' },
|
|
48
|
+
]);
|
|
49
|
+
expect(parseLsofCwd(['p101', 'fcwd', 'n/Users/me/app', ''].join('\n'))).toEqual(new Map([[101, '/Users/me/app']]));
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
describe('createDevServerFinder', () => {
|
|
54
|
+
const linuxFs = (files, links, dirs) => ({
|
|
55
|
+
platform: 'linux',
|
|
56
|
+
readFile: async (file) => {
|
|
57
|
+
if (file in files) return files[file];
|
|
58
|
+
throw new Error('ENOENT');
|
|
59
|
+
},
|
|
60
|
+
readlink: async (file) => {
|
|
61
|
+
if (file in links) return links[file];
|
|
62
|
+
throw new Error('ENOENT');
|
|
63
|
+
},
|
|
64
|
+
readdir: async (dir) => {
|
|
65
|
+
if (dir in dirs) return dirs[dir];
|
|
66
|
+
throw new Error('ENOENT');
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('lists web servers with their project first and skips PiChamber and non-HTTP ports', async () => {
|
|
71
|
+
const tcp = [
|
|
72
|
+
HEADER,
|
|
73
|
+
row('0100007F:1435', '0A', '11'), // 5173, owned by pid 50 in the project
|
|
74
|
+
row('00000000:0BB8', '0A', '12'), // 3000, owned by pid 60 elsewhere
|
|
75
|
+
row('00000000:18EB', '0A', '13'), // 6379, not HTTP
|
|
76
|
+
row('00000000:0016', '0A', '14'), // 22, below 1024
|
|
77
|
+
row('00000000:2710', '0A', '15'), // 10000, PiChamber's own port
|
|
78
|
+
].join('\n');
|
|
79
|
+
const probes = [];
|
|
80
|
+
const finder = createDevServerFinder({
|
|
81
|
+
...linuxFs(
|
|
82
|
+
{ '/proc/net/tcp': tcp, '/proc/50/comm': 'MainThread\n', '/proc/60/comm': 'python3\n' },
|
|
83
|
+
{
|
|
84
|
+
'/proc/50/fd/3': 'socket:[11]',
|
|
85
|
+
'/proc/60/fd/4': 'socket:[12]',
|
|
86
|
+
'/proc/50/exe': '/usr/bin/node',
|
|
87
|
+
'/proc/50/cwd': '/repo/app/web',
|
|
88
|
+
'/proc/60/cwd': '/tmp',
|
|
89
|
+
},
|
|
90
|
+
{ '/proc': ['50', '60', 'self'], '/proc/50/fd': ['3'], '/proc/60/fd': ['4'] },
|
|
91
|
+
),
|
|
92
|
+
probe: async ({ port }) => {
|
|
93
|
+
probes.push(port);
|
|
94
|
+
return { 5173: 'Vite App', 3000: null, 6379: undefined, 10000: 'PiChamber' }[port];
|
|
95
|
+
},
|
|
96
|
+
ownPid: 1,
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
const result = await finder.find({ directory: '/repo/app', excludePorts: [10000] });
|
|
100
|
+
expect(result).toEqual({
|
|
101
|
+
supported: true,
|
|
102
|
+
servers: [
|
|
103
|
+
{ url: 'http://localhost:5173/', port: 5173, title: 'Vite App', process: 'node', inProject: true },
|
|
104
|
+
{ url: 'http://localhost:3000/', port: 3000, title: null, process: 'python3', inProject: false },
|
|
105
|
+
],
|
|
106
|
+
});
|
|
107
|
+
expect(probes).not.toContain(22);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it('reuses a recent scan', async () => {
|
|
111
|
+
let scans = 0;
|
|
112
|
+
let time = 0;
|
|
113
|
+
const finder = createDevServerFinder({
|
|
114
|
+
...linuxFs({ '/proc/net/tcp': [HEADER, row('0100007F:1435', '0A', '11')].join('\n') }, {}, { '/proc': [] }),
|
|
115
|
+
probe: async () => { scans += 1; return 'App'; },
|
|
116
|
+
now: () => time,
|
|
117
|
+
});
|
|
118
|
+
await finder.find();
|
|
119
|
+
await finder.find();
|
|
120
|
+
expect(scans).toBe(1);
|
|
121
|
+
time = 10_000;
|
|
122
|
+
await finder.find();
|
|
123
|
+
expect(scans).toBe(2);
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
describe('dev server probe', () => {
|
|
128
|
+
let server = null;
|
|
129
|
+
afterEach(async () => {
|
|
130
|
+
await new Promise((resolve) => (server ? server.close(resolve) : resolve()));
|
|
131
|
+
server = null;
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it('reads the title from a real loopback server', async () => {
|
|
135
|
+
server = http.createServer((_req, res) => {
|
|
136
|
+
res.setHeader('content-type', 'text/html');
|
|
137
|
+
res.end('<!doctype html><title>Fixture</title><p>hi</p>');
|
|
138
|
+
});
|
|
139
|
+
await new Promise((resolve) => server.listen(0, '127.0.0.1', resolve));
|
|
140
|
+
const { port } = server.address();
|
|
141
|
+
const finder = createDevServerFinder({
|
|
142
|
+
platform: 'linux',
|
|
143
|
+
readFile: async (file) => (file === '/proc/net/tcp'
|
|
144
|
+
? [HEADER, row(`0100007F:${port.toString(16).toUpperCase().padStart(4, '0')}`, '0A', '1')].join('\n')
|
|
145
|
+
: ''),
|
|
146
|
+
readdir: async () => [],
|
|
147
|
+
readlink: async () => { throw new Error('ENOENT'); },
|
|
148
|
+
});
|
|
149
|
+
const { servers } = await finder.find();
|
|
150
|
+
expect(servers).toEqual([{ url: `http://localhost:${port}/`, port, title: 'Fixture', process: null, inProject: false }]);
|
|
151
|
+
});
|
|
152
|
+
});
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import crypto from 'node:crypto';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
|
|
5
|
+
const MAX_DOWNLOADS = 50;
|
|
6
|
+
|
|
7
|
+
export const safeFileName = (value) => {
|
|
8
|
+
const base = path.basename(String(value || '')).replace(/[\u0000-\u001f<>:"/\\|?*]/g, '_').trim();
|
|
9
|
+
return (base || 'file').slice(0, 200);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Files pages downloaded, saved under `dir` (owner-only) and offered to the
|
|
14
|
+
* tab's viewers. The newest 50 are kept. Downloads are indexed in memory
|
|
15
|
+
* only, so files from an earlier run are never served; `dir` is emptied on
|
|
16
|
+
* start.
|
|
17
|
+
*/
|
|
18
|
+
export const createDownloadStore = ({ dir, log = () => {} }) => {
|
|
19
|
+
const downloads = new Map();
|
|
20
|
+
try { fs.rmSync(dir, { recursive: true, force: true }); } catch { /* unreadable; left alone */ }
|
|
21
|
+
|
|
22
|
+
const message = (entry) => ({
|
|
23
|
+
type: 'download',
|
|
24
|
+
id: entry.id,
|
|
25
|
+
filename: entry.filename,
|
|
26
|
+
state: entry.state,
|
|
27
|
+
receivedBytes: entry.bytes,
|
|
28
|
+
totalBytes: entry.bytes,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const evict = () => {
|
|
32
|
+
while (downloads.size > MAX_DOWNLOADS) {
|
|
33
|
+
const [oldest] = downloads.values();
|
|
34
|
+
downloads.delete(oldest.id);
|
|
35
|
+
void fs.promises.rm(oldest.path, { force: true }).catch(() => {});
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
return {
|
|
40
|
+
/** Saves a Playwright download for `tab`, telling its viewers when it starts and ends. */
|
|
41
|
+
async add(tab, download) {
|
|
42
|
+
const id = crypto.randomUUID();
|
|
43
|
+
const entry = { id, filename: safeFileName(download.suggestedFilename()), path: path.join(dir, id), state: 'inProgress', bytes: 0 };
|
|
44
|
+
downloads.set(id, entry);
|
|
45
|
+
evict();
|
|
46
|
+
tab.broadcast(message(entry));
|
|
47
|
+
try {
|
|
48
|
+
const failure = await download.failure();
|
|
49
|
+
if (failure) throw new Error(failure);
|
|
50
|
+
await fs.promises.mkdir(dir, { recursive: true, mode: 0o700 });
|
|
51
|
+
await download.saveAs(entry.path);
|
|
52
|
+
// saveAs copies with the process umask; a download stays owner-only.
|
|
53
|
+
await fs.promises.chmod(entry.path, 0o600);
|
|
54
|
+
entry.bytes = (await fs.promises.stat(entry.path)).size;
|
|
55
|
+
entry.state = 'completed';
|
|
56
|
+
// Evicted while it downloaded: nothing can ask for it.
|
|
57
|
+
if (downloads.get(id) !== entry) await fs.promises.rm(entry.path, { force: true });
|
|
58
|
+
} catch (error) {
|
|
59
|
+
entry.state = 'canceled';
|
|
60
|
+
log(`[server-browser] download failed: ${error?.message || error}`);
|
|
61
|
+
await fs.promises.rm(entry.path, { force: true }).catch(() => {});
|
|
62
|
+
} finally {
|
|
63
|
+
// saveAs copied it; Playwright's own copy is not needed.
|
|
64
|
+
await download.delete().catch(() => {});
|
|
65
|
+
}
|
|
66
|
+
tab.broadcast(message(entry));
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
get(id) {
|
|
70
|
+
const entry = downloads.get(id);
|
|
71
|
+
if (!entry || entry.state !== 'completed') return null;
|
|
72
|
+
return { path: entry.path, filename: entry.filename };
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
};
|