@pi-chamber/web 1.0.5-rc.4 → 1.0.6-rc.1
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-CiAfS52a.js → DiagramView-DUxXEKjQ.js} +1 -1
- package/dist/assets/DiffView-DEd3rdnu.js +18 -0
- package/dist/assets/FileSaveConflictDialog-C6o4fYIn.js +3 -0
- package/dist/assets/{FilesView-DAEtByHZ.js → FilesView-Ccl4CxjR.js} +3 -3
- package/dist/assets/{GitHubDetailScaffold-CtFeWl_3.js → GitHubDetailScaffold-DlgVm5uD.js} +3 -3
- package/dist/assets/{GitHubLinkPicker-BEB6WkNO.js → GitHubLinkPicker-BgDZR-3K.js} +1 -1
- package/dist/assets/{GitHubListPrimitives-BilsEUSt.js → GitHubListPrimitives-BTeI3B3C.js} +1 -1
- package/dist/assets/{GitView-C19-aC7A.js → GitView-BkrH0HFQ.js} +4 -4
- package/dist/assets/{IssuesSurface-zvICpciG.js → IssuesSurface-CD1m8BHP.js} +3 -3
- package/dist/assets/{JsonTreeView-D99tzKTq.js → JsonTreeView-RLgBKik9.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-CRfobHRu.js → MarkdownRendererImpl-BkfhE9NN.js} +2 -2
- package/dist/assets/{PatchDiff-Fbf3Mt_o.js → PatchDiff-BLNLrGYa.js} +1 -1
- package/dist/assets/{PierreDiffViewer-C2nEOax_.js → PierreDiffViewer-iLnLAFeL.js} +3 -3
- package/dist/assets/PullRequestsSurface-_kgJMFTh.js +2 -0
- package/dist/assets/{SessionSwitcherContent-DByH7H41.js → SessionSwitcherContent-BCOUKRch.js} +1 -1
- package/dist/assets/SessionSwitcherDropdown-CA64t2xd.js +2 -0
- package/dist/assets/SessionUnreadDot-BZy2DM6H.js +1 -0
- package/dist/assets/SettingsView-TwUy1kXV.js +6 -0
- package/dist/assets/{SettingsWindow-B1_mMQyb.js → SettingsWindow-BXE4JP-T.js} +1 -1
- package/dist/assets/{StickyHorizontalScrollbar-BMITjK4e.js → StickyHorizontalScrollbar-p7EbL2-E.js} +2 -2
- package/dist/assets/{ToolOutputDialog-BO3d88qF.js → ToolOutputDialog-tiXT-Xts.js} +4 -4
- package/dist/assets/{ToolPartDiffPreview-BgbLfmmd.js → ToolPartDiffPreview-CylbiIKd.js} +1 -1
- package/dist/assets/{VirtualizedFileDiff-D7kxYBDG.js → VirtualizedFileDiff-Cccy1L8L.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-8pZIB8G2.js → computeVirtualFileMetrics-ydVGT2RY.js} +2 -2
- package/dist/assets/{contextFileOpenGuard-BNtzRA7B.js → contextFileOpenGuard--7BLkncT.js} +1 -1
- package/dist/assets/{document-attachments-BslE4Ns7.js → document-attachments-CZl9rK1z.js} +5 -5
- package/dist/assets/{gitStatusPredicates-B7adeDSu.js → gitStatusPredicates-BzR54iPh.js} +1 -1
- package/dist/assets/{githubLink-DVRaj2ms.js → githubLink-WO5BkC0U.js} +5 -5
- package/dist/assets/{index-D4n3TVp2.js → index-C2ISrmRR.js} +10 -10
- package/dist/assets/index-DgwThEwf.css +1 -0
- package/dist/assets/index-nOAE6UDy.js +1 -0
- package/dist/assets/{lua-BgMRiT3U.js → lua-VAEuO923.js} +1 -1
- package/dist/assets/main-B4UP1bOp.js +2 -0
- package/dist/assets/main-DxYfmK5D.js +137 -0
- package/dist/assets/{markdown-shiki.worker-DnvH1S1x.js → markdown-shiki.worker-BVA5NZBT.js} +5 -5
- package/dist/assets/markdownCore-DIn2dwA6.js +2 -0
- package/dist/assets/miniChat-CMGH4R_p.js +2 -0
- package/dist/assets/mobile-BJz0lBjK.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-D6vrJGbH.js +9 -0
- package/dist/assets/{registerCustomTheme-DmolaWWZ.js → registerCustomTheme-C-h6lsYW.js} +1 -1
- package/dist/assets/{renderDiffWithHighlighter-BamhejwM.js → renderDiffWithHighlighter-JwKOWdBN.js} +1 -1
- package/dist/assets/renderElectronMiniChatApp-DYdkuv5N.js +2 -0
- package/dist/assets/{renderFileWithHighlighter-CFlqKZg7.js → renderFileWithHighlighter-RJTrDxFH.js} +1 -1
- package/dist/assets/renderMobileApp-x1P9U65-.js +11 -0
- package/dist/assets/ruby-BK5aLJev.js +1 -0
- package/dist/assets/runtimeEndpointReset-OqTh3bbO.js +62 -0
- package/dist/assets/runtimeSurface-CJN1oo_1.js +1 -0
- package/dist/assets/themeResolver-DrfmQi8i.js +1 -0
- package/dist/assets/useAppFontEffects-CHnpTOtc.js +215 -0
- package/dist/assets/useFilesViewSearch-DeVixiGZ.js +7 -0
- package/dist/assets/{useGitHubRemoteSearch-BoCzq4zs.js → useGitHubRemoteSearch-GjQca1iD.js} +1 -1
- package/dist/assets/{useSwitcherItems-C8IKoSTL.js → useSwitcherItems-DYtnl0T2.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-DTteDmIQ.js → web-components-CIPJC1JE.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-CEAAlJ4b.js +0 -18
- package/dist/assets/FileSaveConflictDialog-yvhJRLj7.js +0 -3
- package/dist/assets/PullRequestsSurface-DMWgrwmP.js +0 -2
- package/dist/assets/SessionSwitcherDropdown-D-kE5IJ_.js +0 -2
- package/dist/assets/SessionUnreadDot-DNbvtMOd.js +0 -1
- package/dist/assets/SettingsView-BhXkRsZT.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-B7HgGIB0.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-BWWBkkNK.js +0 -136
- package/dist/assets/main-C-nlfc4f.js +0 -2
- package/dist/assets/make-CHLpvVh8.js +0 -1
- package/dist/assets/markdown-Cvjx9yec.js +0 -1
- package/dist/assets/markdownCore-B6YzRefV.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-b8DbqBHL.js +0 -2
- package/dist/assets/mipsasm-CKIfxQSi.js +0 -1
- package/dist/assets/mobile-BDDUPrDt.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-gLalTsQo.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-CiWui-Wg.js +0 -2
- package/dist/assets/renderMobileApp-C27Xb0G7.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-O-OHpVl7.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-B6Bro-YP.js +0 -212
- package/dist/assets/useFilesViewSearch-jAAdikwo.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,241 @@
|
|
|
1
|
+
const CURSOR_PROBE_INTERVAL_MS = 80;
|
|
2
|
+
// Chrome answers a wheel event only after the page has handled it, which on
|
|
3
|
+
// a busy page takes longer than a trackpad waits between events. Wheel
|
|
4
|
+
// movement that arrives meanwhile is added up and sent as one event, so
|
|
5
|
+
// scrolling never falls behind the person's hand.
|
|
6
|
+
const MAX_WHEEL_DELTA = 10_000;
|
|
7
|
+
const MODIFIER_BITS = { alt: 1, ctrl: 2, meta: 4, shift: 8 };
|
|
8
|
+
const BUTTON_BITS = { left: 1, right: 2, middle: 4 };
|
|
9
|
+
|
|
10
|
+
const modifierMask = (modifiers) => {
|
|
11
|
+
if (!modifiers || typeof modifiers !== 'object') return 0;
|
|
12
|
+
let mask = 0;
|
|
13
|
+
for (const [name, bit] of Object.entries(MODIFIER_BITS)) {
|
|
14
|
+
if (modifiers[name] === true) mask |= bit;
|
|
15
|
+
}
|
|
16
|
+
return mask;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const clampWheel = (value) => Math.max(-MAX_WHEEL_DELTA, Math.min(MAX_WHEEL_DELTA, value));
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Editing commands for keyboard shortcuts. Headless Chrome on Linux does not
|
|
23
|
+
* map Cmd shortcuts (a Mac client) or copy/cut to editing commands, so they
|
|
24
|
+
* are sent explicitly. Ctrl+Z and Ctrl+A already work there; adding commands
|
|
25
|
+
* for them too would apply undo twice.
|
|
26
|
+
*/
|
|
27
|
+
export const editingCommandsForKey = ({ key, modifiers }) => {
|
|
28
|
+
if (typeof key !== 'string' || key.length !== 1) return [];
|
|
29
|
+
const lower = key.toLowerCase();
|
|
30
|
+
const meta = modifiers?.meta === true;
|
|
31
|
+
const ctrl = modifiers?.ctrl === true;
|
|
32
|
+
if (!meta && !ctrl) return [];
|
|
33
|
+
if (lower === 'c') return ['copy'];
|
|
34
|
+
if (lower === 'x') return ['cut'];
|
|
35
|
+
if (!meta) return [];
|
|
36
|
+
if (lower === 'a') return ['selectAll'];
|
|
37
|
+
if (lower === 'z') return [modifiers?.shift === true ? 'redo' : 'undo'];
|
|
38
|
+
return [];
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Mouse, wheel, and keyboard input for one page. Mouse moves and wheel
|
|
43
|
+
* movement never wait for Chrome: while one is on its way, newer moves
|
|
44
|
+
* replace it and newer wheel movement is added up. Any other input first
|
|
45
|
+
* waits for them.
|
|
46
|
+
*
|
|
47
|
+
* Each viewer's pressed buttons and keys are remembered, so a viewer that
|
|
48
|
+
* disconnects mid-drag or mid-shortcut does not leave them held down.
|
|
49
|
+
*/
|
|
50
|
+
export const createTabInput = ({ onInput, onScroll = () => {}, cursorAt, onCursor, takeCopy, onCopied }) => {
|
|
51
|
+
let send = null;
|
|
52
|
+
let closed = false;
|
|
53
|
+
let pendingMove = null;
|
|
54
|
+
let moveInFlight = false;
|
|
55
|
+
const pendingWheels = [];
|
|
56
|
+
let wheelDispatch = null;
|
|
57
|
+
let lastCursorProbe = 0;
|
|
58
|
+
let cursorTimer = null;
|
|
59
|
+
|
|
60
|
+
const dispatch = (method, params) => (send ? send(method, params).catch(() => {}) : Promise.resolve());
|
|
61
|
+
|
|
62
|
+
const probeCursor = (x, y) => {
|
|
63
|
+
const wait = CURSOR_PROBE_INTERVAL_MS - (Date.now() - lastCursorProbe);
|
|
64
|
+
clearTimeout(cursorTimer);
|
|
65
|
+
if (wait > 0) {
|
|
66
|
+
cursorTimer = setTimeout(() => probeCursor(x, y), wait);
|
|
67
|
+
cursorTimer.unref?.();
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
lastCursorProbe = Date.now();
|
|
71
|
+
void cursorAt(x, y).then((cursor) => {
|
|
72
|
+
if (!closed && typeof cursor === 'string') onCursor(cursor);
|
|
73
|
+
}, () => {});
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const dispatchMove = async () => {
|
|
77
|
+
if (moveInFlight || !pendingMove) return;
|
|
78
|
+
const move = pendingMove;
|
|
79
|
+
pendingMove = null;
|
|
80
|
+
moveInFlight = true;
|
|
81
|
+
// A failed move is superseded by the next one.
|
|
82
|
+
await dispatch('Input.dispatchMouseEvent', move);
|
|
83
|
+
moveInFlight = false;
|
|
84
|
+
if (pendingMove) void dispatchMove();
|
|
85
|
+
else probeCursor(move.x, move.y);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const flushMove = async () => {
|
|
89
|
+
if (!pendingMove) return;
|
|
90
|
+
const move = pendingMove;
|
|
91
|
+
pendingMove = null;
|
|
92
|
+
await dispatch('Input.dispatchMouseEvent', move);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const deliverWheel = async () => {
|
|
96
|
+
while (pendingWheels.length > 0) await dispatch('Input.dispatchMouseEvent', pendingWheels.shift());
|
|
97
|
+
wheelDispatch = null;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const queueWheel = (event) => {
|
|
101
|
+
const last = pendingWheels.at(-1);
|
|
102
|
+
// Different modifiers (a pinch is ctrl+wheel) start a new event.
|
|
103
|
+
if (last && last.modifiers === event.modifiers) {
|
|
104
|
+
pendingWheels[pendingWheels.length - 1] = {
|
|
105
|
+
...event,
|
|
106
|
+
deltaX: clampWheel(last.deltaX + event.deltaX),
|
|
107
|
+
deltaY: clampWheel(last.deltaY + event.deltaY),
|
|
108
|
+
};
|
|
109
|
+
} else {
|
|
110
|
+
pendingWheels.push(event);
|
|
111
|
+
}
|
|
112
|
+
wheelDispatch ??= deliverWheel();
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
/** Waits until all wheel movement so far has reached the page. */
|
|
116
|
+
const flushWheel = async () => {
|
|
117
|
+
while (wheelDispatch) await wheelDispatch;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
const pressedOf = (viewer) => {
|
|
121
|
+
viewer.pressed ??= { buttons: new Map(), keys: new Map() };
|
|
122
|
+
return viewer.pressed;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
const handleMouse = async (message, viewer = {}) => {
|
|
126
|
+
onInput();
|
|
127
|
+
const x = Number(message.x);
|
|
128
|
+
const y = Number(message.y);
|
|
129
|
+
if (!Number.isFinite(x) || !Number.isFinite(y)) return;
|
|
130
|
+
const modifiers = modifierMask(message.modifiers);
|
|
131
|
+
const button = ['left', 'middle', 'right'].includes(message.button) ? message.button : 'none';
|
|
132
|
+
const buttons = Number.isInteger(message.buttons) ? message.buttons : 0;
|
|
133
|
+
if (message.action === 'move') {
|
|
134
|
+
pendingMove = { type: 'mouseMoved', x, y, modifiers, button, buttons };
|
|
135
|
+
void dispatchMove();
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
await flushMove();
|
|
139
|
+
if (message.action === 'wheel') {
|
|
140
|
+
onScroll();
|
|
141
|
+
queueWheel({ type: 'mouseWheel', x, y, deltaX: clampWheel(Number(message.deltaX) || 0), deltaY: clampWheel(Number(message.deltaY) || 0), modifiers });
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
await flushWheel();
|
|
145
|
+
if (message.action !== 'down' && message.action !== 'up') return;
|
|
146
|
+
const down = message.action === 'down';
|
|
147
|
+
if (button !== 'none') {
|
|
148
|
+
if (down) pressedOf(viewer).buttons.set(button, { x, y });
|
|
149
|
+
else pressedOf(viewer).buttons.delete(button);
|
|
150
|
+
}
|
|
151
|
+
await dispatch('Input.dispatchMouseEvent', {
|
|
152
|
+
type: down ? 'mousePressed' : 'mouseReleased',
|
|
153
|
+
x,
|
|
154
|
+
y,
|
|
155
|
+
modifiers,
|
|
156
|
+
button,
|
|
157
|
+
buttons: buttons || (down ? BUTTON_BITS[button] || 0 : 0),
|
|
158
|
+
clickCount: Math.max(1, Math.min(3, Number(message.clickCount) || 1)),
|
|
159
|
+
});
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
const handleKey = async (message, viewer = {}) => {
|
|
163
|
+
onInput();
|
|
164
|
+
if (message.action !== 'down' && message.action !== 'up') return;
|
|
165
|
+
const key = typeof message.key === 'string' ? message.key.slice(0, 32) : '';
|
|
166
|
+
if (!key) return;
|
|
167
|
+
const down = message.action === 'down';
|
|
168
|
+
const modifiers = modifierMask(message.modifiers);
|
|
169
|
+
const code = typeof message.code === 'string' ? message.code.slice(0, 32) : '';
|
|
170
|
+
const keyCode = Number.isInteger(message.keyCode) ? message.keyCode : 0;
|
|
171
|
+
const shortcut = message.modifiers?.ctrl === true || message.modifiers?.meta === true || message.modifiers?.alt === true;
|
|
172
|
+
let text = '';
|
|
173
|
+
if (down && !shortcut) {
|
|
174
|
+
if (key === 'Enter') text = '\r';
|
|
175
|
+
else if (key.length === 1) text = key;
|
|
176
|
+
}
|
|
177
|
+
const params = {
|
|
178
|
+
type: !down ? 'keyUp' : text ? 'keyDown' : 'rawKeyDown',
|
|
179
|
+
key,
|
|
180
|
+
code,
|
|
181
|
+
windowsVirtualKeyCode: keyCode,
|
|
182
|
+
nativeVirtualKeyCode: keyCode,
|
|
183
|
+
modifiers,
|
|
184
|
+
autoRepeat: message.repeat === true,
|
|
185
|
+
location: Number.isInteger(message.location) ? message.location : 0,
|
|
186
|
+
};
|
|
187
|
+
if (text) {
|
|
188
|
+
params.text = text;
|
|
189
|
+
params.unmodifiedText = text;
|
|
190
|
+
}
|
|
191
|
+
const commands = down ? editingCommandsForKey({ key, modifiers: message.modifiers }) : [];
|
|
192
|
+
if (commands.length > 0) params.commands = commands;
|
|
193
|
+
if (down) pressedOf(viewer).keys.set(code || key, { key, code, keyCode });
|
|
194
|
+
else pressedOf(viewer).keys.delete(code || key);
|
|
195
|
+
await flushMove();
|
|
196
|
+
const copies = commands.includes('copy') || commands.includes('cut');
|
|
197
|
+
// Drop anything recorded earlier, so only this key's copy is reported.
|
|
198
|
+
if (copies) await takeCopy().catch(() => '');
|
|
199
|
+
await dispatch('Input.dispatchKeyEvent', params);
|
|
200
|
+
if (!copies) return;
|
|
201
|
+
const copied = await takeCopy().catch(() => '');
|
|
202
|
+
if (typeof copied === 'string' && copied) onCopied(copied);
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
return {
|
|
206
|
+
bind(nextSend) {
|
|
207
|
+
send = nextSend;
|
|
208
|
+
pendingMove = null;
|
|
209
|
+
pendingWheels.length = 0;
|
|
210
|
+
},
|
|
211
|
+
|
|
212
|
+
handleMouse,
|
|
213
|
+
handleKey,
|
|
214
|
+
|
|
215
|
+
async insertText(text) {
|
|
216
|
+
onInput();
|
|
217
|
+
if (typeof text !== 'string' || !text) return;
|
|
218
|
+
await flushMove();
|
|
219
|
+
await dispatch('Input.insertText', { text: text.slice(0, 1_000_000) });
|
|
220
|
+
},
|
|
221
|
+
|
|
222
|
+
/** Lets go of everything a disconnecting viewer still holds down. */
|
|
223
|
+
async releaseViewer(viewer) {
|
|
224
|
+
const pressed = viewer.pressed;
|
|
225
|
+
if (!pressed) return;
|
|
226
|
+
viewer.pressed = null;
|
|
227
|
+
for (const { key, code, keyCode } of pressed.keys.values()) {
|
|
228
|
+
await dispatch('Input.dispatchKeyEvent', { type: 'keyUp', key, code, windowsVirtualKeyCode: keyCode, nativeVirtualKeyCode: keyCode });
|
|
229
|
+
}
|
|
230
|
+
for (const [button, { x, y }] of pressed.buttons) {
|
|
231
|
+
await dispatch('Input.dispatchMouseEvent', { type: 'mouseReleased', x, y, button, buttons: 0, clickCount: 1 });
|
|
232
|
+
}
|
|
233
|
+
},
|
|
234
|
+
|
|
235
|
+
close() {
|
|
236
|
+
closed = true;
|
|
237
|
+
clearTimeout(cursorTimer);
|
|
238
|
+
send = null;
|
|
239
|
+
},
|
|
240
|
+
};
|
|
241
|
+
};
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { MAX_CHOOSER_BYTES } from './uploads.js';
|
|
2
|
+
|
|
3
|
+
const MAX_DIALOG_MESSAGE = 4_000;
|
|
4
|
+
const MAX_PROMPT_TEXT = 10_000;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A page's JavaScript dialogs and file choosers. Every viewer sees them and
|
|
8
|
+
* any viewer may answer. With nobody watching, a dialog is answered at once
|
|
9
|
+
* (leaving a page is allowed, anything else declined) so the page never
|
|
10
|
+
* stalls on it.
|
|
11
|
+
*/
|
|
12
|
+
export const createTabPrompts = ({ broadcast, hasViewers, log = () => {} }) => {
|
|
13
|
+
let dialog = null;
|
|
14
|
+
let chooser = null;
|
|
15
|
+
let chooserSeq = 0;
|
|
16
|
+
|
|
17
|
+
const dialogMessage = () => ({ type: 'dialog', ...dialog.info });
|
|
18
|
+
const chooserMessage = () => ({ type: 'file-chooser', id: chooser.id, multiple: chooser.multiple });
|
|
19
|
+
|
|
20
|
+
const answer = async (handle, { accept, text }) => {
|
|
21
|
+
try {
|
|
22
|
+
if (accept) await handle.accept(typeof text === 'string' ? text.slice(0, MAX_PROMPT_TEXT) : undefined);
|
|
23
|
+
else await handle.dismiss();
|
|
24
|
+
} catch (error) {
|
|
25
|
+
// The page closed or navigated first.
|
|
26
|
+
log(`[server-browser] dialog: ${error?.message || error}`);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const closeChooser = () => {
|
|
31
|
+
if (!chooser) return;
|
|
32
|
+
const { id } = chooser;
|
|
33
|
+
chooser = null;
|
|
34
|
+
broadcast({ type: 'file-chooser-closed', id });
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
return {
|
|
38
|
+
bindPage(page) {
|
|
39
|
+
page.on('dialog', (handle) => {
|
|
40
|
+
const kind = handle.type();
|
|
41
|
+
if (!hasViewers()) {
|
|
42
|
+
void answer(handle, { accept: kind === 'beforeunload' });
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
dialog = {
|
|
46
|
+
handle,
|
|
47
|
+
info: {
|
|
48
|
+
kind,
|
|
49
|
+
message: String(handle.message() || '').slice(0, MAX_DIALOG_MESSAGE),
|
|
50
|
+
defaultPrompt: kind === 'prompt' ? handle.defaultValue() || '' : '',
|
|
51
|
+
url: page.url(),
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
broadcast(dialogMessage());
|
|
55
|
+
});
|
|
56
|
+
page.on('filechooser', (handle) => {
|
|
57
|
+
chooserSeq += 1;
|
|
58
|
+
chooser = { id: chooserSeq, multiple: handle.isMultiple(), handle };
|
|
59
|
+
broadcast(chooserMessage());
|
|
60
|
+
});
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* The last viewer left: answer a waiting dialog as if nobody had been
|
|
65
|
+
* watching, so the page does not stall on it.
|
|
66
|
+
*/
|
|
67
|
+
async viewersLeft() {
|
|
68
|
+
if (!dialog || hasViewers()) return;
|
|
69
|
+
const { handle, info } = dialog;
|
|
70
|
+
dialog = null;
|
|
71
|
+
broadcast({ type: 'dialog-closed' });
|
|
72
|
+
await answer(handle, { accept: info.kind === 'beforeunload' });
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
/** What a newly attached viewer must see. */
|
|
76
|
+
replay(viewer) {
|
|
77
|
+
if (dialog) viewer.sendJson(dialogMessage());
|
|
78
|
+
if (chooser) viewer.sendJson(chooserMessage());
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
async respondDialog({ accept, text }) {
|
|
82
|
+
if (!dialog) return;
|
|
83
|
+
const { handle, info } = dialog;
|
|
84
|
+
dialog = null;
|
|
85
|
+
broadcast({ type: 'dialog-closed' });
|
|
86
|
+
await answer(handle, { accept: accept === true, text: info.kind === 'prompt' ? text : undefined });
|
|
87
|
+
},
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Gives the page the files (`{ name, mimeType, buffer }`) for chooser
|
|
91
|
+
* `id`; none cancels it. Files the page cannot take send an
|
|
92
|
+
* `upload-failed` notice.
|
|
93
|
+
*/
|
|
94
|
+
async respondFileChooser({ id, files }) {
|
|
95
|
+
if (!chooser || chooser.id !== id) return;
|
|
96
|
+
const { handle, multiple } = chooser;
|
|
97
|
+
closeChooser();
|
|
98
|
+
if (!Array.isArray(files) || files.length === 0) return;
|
|
99
|
+
const picked = multiple ? files : files.slice(0, 1);
|
|
100
|
+
const failed = (message) => broadcast({ type: 'notice', kind: 'upload-failed', message });
|
|
101
|
+
if (picked.reduce((total, file) => total + file.buffer.byteLength, 0) > MAX_CHOOSER_BYTES) {
|
|
102
|
+
failed('Files for one upload must be under 50 MB together');
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
await handle.setFiles(picked).catch((error) => {
|
|
106
|
+
log(`[server-browser] file chooser: ${error?.message || error}`);
|
|
107
|
+
failed('The page did not take the files');
|
|
108
|
+
});
|
|
109
|
+
},
|
|
110
|
+
|
|
111
|
+
/** A new document: a file chooser belongs to the page that asked. */
|
|
112
|
+
documentChanged() {
|
|
113
|
+
closeChooser();
|
|
114
|
+
},
|
|
115
|
+
|
|
116
|
+
/** The page is gone (closed, crashed, or replaced). */
|
|
117
|
+
reset() {
|
|
118
|
+
if (dialog) {
|
|
119
|
+
dialog = null;
|
|
120
|
+
broadcast({ type: 'dialog-closed' });
|
|
121
|
+
}
|
|
122
|
+
closeChooser();
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
};
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
// Chrome sends a new screencast frame only after the previous one is acked.
|
|
2
|
+
// Acking no sooner than these caps the stream near 60 frames per second
|
|
3
|
+
// while someone is using the page and 30 otherwise, so a page that animates
|
|
4
|
+
// on its own does not keep the server busy at the full rate.
|
|
5
|
+
const ACTIVE_ACK_INTERVAL_MS = 16;
|
|
6
|
+
const IDLE_ACK_INTERVAL_MS = 33;
|
|
7
|
+
const ACTIVE_AFTER_INPUT_MS = 1_000;
|
|
8
|
+
// Frames a viewer may have unacknowledged before it only keeps the latest.
|
|
9
|
+
const VIEWER_MAX_INFLIGHT_FRAMES = 2;
|
|
10
|
+
const SCREENCAST_QUALITY = 70;
|
|
11
|
+
// While the page scrolls, frames are half the size and coarser, so each
|
|
12
|
+
// costs Chrome and the network about a quarter as much and the stream keeps
|
|
13
|
+
// up. Scrolling counts once a few frames follow a wheel event closely; a
|
|
14
|
+
// single wheel step stays sharp. A pause in scrolling restarts the stream at
|
|
15
|
+
// full size, and Chrome sends a sharp frame of the still page at once.
|
|
16
|
+
const SCROLL_SCALE = 0.5;
|
|
17
|
+
const SCROLL_QUALITY = 50;
|
|
18
|
+
const SCROLL_FRAMES = 4;
|
|
19
|
+
const SCROLL_WINDOW_MS = 300;
|
|
20
|
+
const SCROLL_SETTLE_MS = 200;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Encodes a frame for viewers: a 4-byte big-endian header length, the JSON
|
|
24
|
+
* header, then the JPEG bytes.
|
|
25
|
+
*/
|
|
26
|
+
const encodeFrame = (header, jpeg) => {
|
|
27
|
+
const headerBytes = Buffer.from(JSON.stringify(header), 'utf8');
|
|
28
|
+
const prefix = Buffer.alloc(4);
|
|
29
|
+
prefix.writeUInt32BE(headerBytes.length, 0);
|
|
30
|
+
return Buffer.concat([prefix, headerBytes, jpeg]);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The screencast of one page, shared by its viewers. Chrome encodes each
|
|
35
|
+
* frame once; every viewer gets frames at the pace it acknowledges them, and
|
|
36
|
+
* a viewer that falls behind gets only the newest.
|
|
37
|
+
*
|
|
38
|
+
* `send` is the page's CDP session; `bind` replaces it when the page does.
|
|
39
|
+
* Viewers are `{ sendFrame(buffer) }`.
|
|
40
|
+
*/
|
|
41
|
+
export const createTabStream = ({ viewport }) => {
|
|
42
|
+
let send = null;
|
|
43
|
+
const viewers = new Set();
|
|
44
|
+
let screencasting = false;
|
|
45
|
+
// Starting fails while the page swaps renderer processes; it is retried
|
|
46
|
+
// when the next navigation commits.
|
|
47
|
+
let startFailed = false;
|
|
48
|
+
let frameSeq = 0;
|
|
49
|
+
let lastChromeAck = 0;
|
|
50
|
+
let lastInputAt = 0;
|
|
51
|
+
let ackTimer = null;
|
|
52
|
+
let scrolledAt = 0;
|
|
53
|
+
let scrolling = false;
|
|
54
|
+
let recentFrames = [];
|
|
55
|
+
let settleTimer = null;
|
|
56
|
+
// Restarts run one at a time: Chrome refuses a start while one runs.
|
|
57
|
+
let restarts = Promise.resolve();
|
|
58
|
+
// The newest frame, for a viewer that joins and for inspect. Chrome's
|
|
59
|
+
// screenshots are not used: while it takes one, it changes the page's
|
|
60
|
+
// emulated scale, and input in that moment lands at the wrong place.
|
|
61
|
+
let latest = null;
|
|
62
|
+
|
|
63
|
+
const deliver = (viewer, frame) => {
|
|
64
|
+
if (viewer.inflight >= VIEWER_MAX_INFLIGHT_FRAMES) {
|
|
65
|
+
viewer.pendingFrame = frame;
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
viewer.inflight += 1;
|
|
69
|
+
viewer.sendFrame(frame);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const ackChrome = (frameSessionId) => {
|
|
73
|
+
const current = send;
|
|
74
|
+
const interval = Date.now() - lastInputAt < ACTIVE_AFTER_INPUT_MS ? ACTIVE_ACK_INTERVAL_MS : IDLE_ACK_INTERVAL_MS;
|
|
75
|
+
const wait = Math.max(0, interval - (Date.now() - lastChromeAck));
|
|
76
|
+
clearTimeout(ackTimer);
|
|
77
|
+
ackTimer = setTimeout(() => {
|
|
78
|
+
ackTimer = null;
|
|
79
|
+
lastChromeAck = Date.now();
|
|
80
|
+
void current?.('Page.screencastFrameAck', { sessionId: frameSessionId }).catch(() => {});
|
|
81
|
+
}, wait);
|
|
82
|
+
ackTimer.unref?.();
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const start = async () => {
|
|
86
|
+
if (!send || viewers.size === 0) return;
|
|
87
|
+
const { width, height, dpr } = viewport();
|
|
88
|
+
screencasting = true;
|
|
89
|
+
// Chrome draws at 2x; the stream is scaled to the viewer's pixel ratio.
|
|
90
|
+
const scale = scrolling ? SCROLL_SCALE : 1;
|
|
91
|
+
startFailed = await send('Page.startScreencast', {
|
|
92
|
+
format: 'jpeg',
|
|
93
|
+
quality: scrolling ? SCROLL_QUALITY : SCREENCAST_QUALITY,
|
|
94
|
+
maxWidth: Math.max(1, Math.round(width * dpr * scale)),
|
|
95
|
+
maxHeight: Math.max(1, Math.round(height * dpr * scale)),
|
|
96
|
+
everyNthFrame: 1,
|
|
97
|
+
}).then(() => false, () => true);
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
/** Restarts a running screencast with the current settings. */
|
|
101
|
+
const restartScreencast = () => {
|
|
102
|
+
restarts = restarts.then(async () => {
|
|
103
|
+
if (!screencasting || !send) return;
|
|
104
|
+
await send('Page.stopScreencast').catch(() => {});
|
|
105
|
+
if (screencasting) await start();
|
|
106
|
+
});
|
|
107
|
+
return restarts;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const setScrolling = (next) => {
|
|
111
|
+
if (scrolling === next) return;
|
|
112
|
+
scrolling = next;
|
|
113
|
+
recentFrames = [];
|
|
114
|
+
void restartScreencast();
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const resetScrolling = () => {
|
|
118
|
+
clearTimeout(settleTimer);
|
|
119
|
+
settleTimer = null;
|
|
120
|
+
scrolling = false;
|
|
121
|
+
recentFrames = [];
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const settleLater = (wait) => {
|
|
125
|
+
clearTimeout(settleTimer);
|
|
126
|
+
settleTimer = setTimeout(() => {
|
|
127
|
+
settleTimer = null;
|
|
128
|
+
if (!scrolling) return;
|
|
129
|
+
const quiet = Date.now() - scrolledAt;
|
|
130
|
+
if (quiet >= SCROLL_SETTLE_MS) setScrolling(false);
|
|
131
|
+
else settleLater(SCROLL_SETTLE_MS - quiet);
|
|
132
|
+
}, wait);
|
|
133
|
+
settleTimer.unref?.();
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
const noteFrameForScrolling = () => {
|
|
137
|
+
const now = Date.now();
|
|
138
|
+
recentFrames.push(now);
|
|
139
|
+
while (recentFrames[0] < now - SCROLL_WINDOW_MS) recentFrames.shift();
|
|
140
|
+
if (!scrolling && recentFrames.length >= SCROLL_FRAMES && now - scrolledAt < SCROLL_WINDOW_MS) setScrolling(true);
|
|
141
|
+
else if (scrolling && now - scrolledAt > SCROLL_SETTLE_MS) setScrolling(false);
|
|
142
|
+
if (scrolling) settleLater(SCROLL_SETTLE_MS);
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
const stop = async () => {
|
|
146
|
+
if (!screencasting) return;
|
|
147
|
+
screencasting = false;
|
|
148
|
+
latest = null;
|
|
149
|
+
clearTimeout(ackTimer);
|
|
150
|
+
ackTimer = null;
|
|
151
|
+
resetScrolling();
|
|
152
|
+
await send?.('Page.stopScreencast').catch(() => {});
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
const header = (metadata = {}) => ({
|
|
156
|
+
seq: ++frameSeq,
|
|
157
|
+
width: metadata.deviceWidth,
|
|
158
|
+
height: metadata.deviceHeight,
|
|
159
|
+
offsetTop: metadata.offsetTop || 0,
|
|
160
|
+
pageScaleFactor: metadata.pageScaleFactor || 1,
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
return {
|
|
164
|
+
/** Uses a (new) page session; the screencast restarts on it. */
|
|
165
|
+
async bind(nextSend) {
|
|
166
|
+
clearTimeout(ackTimer);
|
|
167
|
+
ackTimer = null;
|
|
168
|
+
resetScrolling();
|
|
169
|
+
send = nextSend;
|
|
170
|
+
screencasting = false;
|
|
171
|
+
latest = null;
|
|
172
|
+
await start();
|
|
173
|
+
},
|
|
174
|
+
|
|
175
|
+
onFrame(params) {
|
|
176
|
+
ackChrome(params.sessionId);
|
|
177
|
+
if (viewers.size === 0) return;
|
|
178
|
+
noteFrameForScrolling();
|
|
179
|
+
const jpeg = Buffer.from(params.data, 'base64');
|
|
180
|
+
const frameHeader = header(params.metadata);
|
|
181
|
+
const frame = encodeFrame(frameHeader, jpeg);
|
|
182
|
+
latest = { frame, jpeg, width: frameHeader.width, height: frameHeader.height };
|
|
183
|
+
for (const viewer of viewers) deliver(viewer, frame);
|
|
184
|
+
},
|
|
185
|
+
|
|
186
|
+
noteInput() {
|
|
187
|
+
lastInputAt = Date.now();
|
|
188
|
+
},
|
|
189
|
+
|
|
190
|
+
/** A wheel or touch scroll reached the page. */
|
|
191
|
+
noteScroll() {
|
|
192
|
+
lastInputAt = Date.now();
|
|
193
|
+
scrolledAt = lastInputAt;
|
|
194
|
+
},
|
|
195
|
+
|
|
196
|
+
async addViewer(viewer) {
|
|
197
|
+
viewer.inflight = 0;
|
|
198
|
+
viewer.pendingFrame = null;
|
|
199
|
+
viewers.add(viewer);
|
|
200
|
+
if (viewers.size === 1) {
|
|
201
|
+
await start();
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
// An idle page does not draw again for a new viewer, so a late viewer
|
|
205
|
+
// starts from the newest frame.
|
|
206
|
+
if (latest) deliver(viewer, latest.frame);
|
|
207
|
+
},
|
|
208
|
+
|
|
209
|
+
/** The newest frame's JPEG and its CSS size, or null before the first. */
|
|
210
|
+
still() {
|
|
211
|
+
return latest ? { jpeg: latest.jpeg, width: latest.width, height: latest.height } : null;
|
|
212
|
+
},
|
|
213
|
+
|
|
214
|
+
removeViewer(viewer) {
|
|
215
|
+
viewers.delete(viewer);
|
|
216
|
+
if (viewers.size === 0) void stop();
|
|
217
|
+
},
|
|
218
|
+
|
|
219
|
+
ack(viewer) {
|
|
220
|
+
viewer.inflight = Math.max(0, viewer.inflight - 1);
|
|
221
|
+
if (viewer.pendingFrame && viewer.inflight < VIEWER_MAX_INFLIGHT_FRAMES) {
|
|
222
|
+
const frame = viewer.pendingFrame;
|
|
223
|
+
viewer.pendingFrame = null;
|
|
224
|
+
viewer.inflight += 1;
|
|
225
|
+
viewer.sendFrame(frame);
|
|
226
|
+
}
|
|
227
|
+
},
|
|
228
|
+
|
|
229
|
+
/** Retries a screencast that failed to start. */
|
|
230
|
+
async retry() {
|
|
231
|
+
if (screencasting && startFailed) await start();
|
|
232
|
+
},
|
|
233
|
+
|
|
234
|
+
/** The viewport changed: the stream restarts at the new size. */
|
|
235
|
+
async restart() {
|
|
236
|
+
restarts = restarts.then(async () => {
|
|
237
|
+
if (!screencasting) return;
|
|
238
|
+
await stop();
|
|
239
|
+
await start();
|
|
240
|
+
});
|
|
241
|
+
await restarts;
|
|
242
|
+
},
|
|
243
|
+
|
|
244
|
+
close() {
|
|
245
|
+
clearTimeout(ackTimer);
|
|
246
|
+
ackTimer = null;
|
|
247
|
+
resetScrolling();
|
|
248
|
+
viewers.clear();
|
|
249
|
+
send = null;
|
|
250
|
+
},
|
|
251
|
+
};
|
|
252
|
+
};
|