@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,98 @@
|
|
|
1
|
+
import crypto from 'node:crypto';
|
|
2
|
+
|
|
3
|
+
import { safeFileName } from './downloads.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Files one file chooser answer can give a page, together. Playwright passes
|
|
7
|
+
* in-memory files to the page and refuses 50 MB or more in one call.
|
|
8
|
+
*/
|
|
9
|
+
export const MAX_CHOOSER_BYTES = 50 * 1024 * 1024 - 1;
|
|
10
|
+
// Uploads wait here only between their upload and the chooser answer.
|
|
11
|
+
const UPLOAD_HOLD_MS = 10 * 60 * 1000;
|
|
12
|
+
// Memory all waiting uploads may take together.
|
|
13
|
+
const MAX_HELD_BYTES = 4 * MAX_CHOOSER_BYTES;
|
|
14
|
+
|
|
15
|
+
const tooLarge = (message) => Object.assign(new Error(message), { code: 'TOO_LARGE' });
|
|
16
|
+
|
|
17
|
+
const MIME_TYPE = /^[\w.+-]+\/[\w.+-]+$/;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Files the person picked for a page's file chooser, held in memory until
|
|
21
|
+
* the chooser answer takes them. The page then holds them itself, as files
|
|
22
|
+
* picked in a desktop browser; nothing is written to the server's disk.
|
|
23
|
+
*/
|
|
24
|
+
export const createUploadStore = () => {
|
|
25
|
+
const uploads = new Map();
|
|
26
|
+
// Bytes of finished uploads, and of uploads still arriving: both are in
|
|
27
|
+
// memory, so both count against MAX_HELD_BYTES.
|
|
28
|
+
let heldBytes = 0;
|
|
29
|
+
let arrivingBytes = 0;
|
|
30
|
+
|
|
31
|
+
const drop = (id) => {
|
|
32
|
+
const upload = uploads.get(id);
|
|
33
|
+
if (!upload) return null;
|
|
34
|
+
uploads.delete(id);
|
|
35
|
+
clearTimeout(upload.timer);
|
|
36
|
+
heldBytes -= upload.buffer.byteLength;
|
|
37
|
+
return upload;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
return {
|
|
41
|
+
/** Reads one file from `stream`; returns its id. */
|
|
42
|
+
async save({ name, mimeType, lastModified, stream }) {
|
|
43
|
+
const chunks = [];
|
|
44
|
+
let received = 0;
|
|
45
|
+
// Released as soon as this upload fails: closing its stream takes a
|
|
46
|
+
// turn, and other uploads keep arriving meanwhile.
|
|
47
|
+
const release = () => {
|
|
48
|
+
arrivingBytes -= received;
|
|
49
|
+
received = 0;
|
|
50
|
+
};
|
|
51
|
+
try {
|
|
52
|
+
for await (const data of stream) {
|
|
53
|
+
const chunk = Buffer.isBuffer(data) ? data : Buffer.from(data);
|
|
54
|
+
if (received + chunk.length > MAX_CHOOSER_BYTES) {
|
|
55
|
+
release();
|
|
56
|
+
throw tooLarge('Files for one upload must be under 50 MB together');
|
|
57
|
+
}
|
|
58
|
+
if (heldBytes + arrivingBytes + chunk.length > MAX_HELD_BYTES) {
|
|
59
|
+
release();
|
|
60
|
+
throw tooLarge('Too many uploads are waiting for a page');
|
|
61
|
+
}
|
|
62
|
+
received += chunk.length;
|
|
63
|
+
arrivingBytes += chunk.length;
|
|
64
|
+
chunks.push(chunk);
|
|
65
|
+
}
|
|
66
|
+
} finally {
|
|
67
|
+
release();
|
|
68
|
+
}
|
|
69
|
+
const buffer = Buffer.concat(chunks);
|
|
70
|
+
if (heldBytes + arrivingBytes + buffer.byteLength > MAX_HELD_BYTES) throw tooLarge('Too many uploads are waiting for a page');
|
|
71
|
+
const id = crypto.randomUUID();
|
|
72
|
+
const timer = setTimeout(() => drop(id), UPLOAD_HOLD_MS);
|
|
73
|
+
timer.unref?.();
|
|
74
|
+
heldBytes += buffer.byteLength;
|
|
75
|
+
uploads.set(id, {
|
|
76
|
+
name: safeFileName(name),
|
|
77
|
+
mimeType: typeof mimeType === 'string' && MIME_TYPE.test(mimeType) ? mimeType : undefined,
|
|
78
|
+
lastModifiedMs: Number.isFinite(lastModified) && lastModified > 0 ? lastModified : undefined,
|
|
79
|
+
buffer,
|
|
80
|
+
timer,
|
|
81
|
+
});
|
|
82
|
+
return { id };
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Takes the uploads `ids` names, for a chooser answer; each can be taken
|
|
87
|
+
* once. Unknown and expired ids are left out.
|
|
88
|
+
*/
|
|
89
|
+
take: (ids) => (Array.isArray(ids) ? ids : [])
|
|
90
|
+
.map((id) => drop(id))
|
|
91
|
+
.filter(Boolean)
|
|
92
|
+
.map(({ name, mimeType, lastModifiedMs, buffer }) => ({ name, mimeType, lastModifiedMs, buffer })),
|
|
93
|
+
|
|
94
|
+
clear() {
|
|
95
|
+
for (const id of [...uploads.keys()]) drop(id);
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
};
|
|
@@ -6,7 +6,7 @@ import { SttStreamManager } from './stream-manager.js';
|
|
|
6
6
|
|
|
7
7
|
const HEARTBEAT_MS = 30_000;
|
|
8
8
|
|
|
9
|
-
export function createSttRuntime({ app, server, express, uiAuthController, isRequestOriginAllowed, rejectWebSocketUpgrade, modelsDir, configFile, liveRevocation = null }) {
|
|
9
|
+
export function createSttRuntime({ app, server, express, uiAuthController, isRequestOriginAllowed, isCrossSiteRequest, rejectWebSocketUpgrade, modelsDir, configFile, liveRevocation = null }) {
|
|
10
10
|
const service = createSttService({ modelsDir, configFile });
|
|
11
11
|
const manager = new SttStreamManager({ createTranscriber: (providerConfigId) => service.createTranscriber(providerConfigId) });
|
|
12
12
|
|
|
@@ -122,6 +122,9 @@ export function createSttRuntime({ app, server, express, uiAuthController, isReq
|
|
|
122
122
|
principal = await uiAuthController.ensureSessionToken(req, null);
|
|
123
123
|
if (!principal) { rejectWebSocketUpgrade(socket, 401, 'UI authentication required'); return; }
|
|
124
124
|
if (!await isRequestOriginAllowed(req)) { rejectWebSocketUpgrade(socket, 403, 'Invalid origin'); return; }
|
|
125
|
+
} else if (await isCrossSiteRequest(req)) {
|
|
126
|
+
// Without UI auth, another site's page must not open this socket.
|
|
127
|
+
rejectWebSocketUpgrade(socket, 403, 'Invalid origin'); return;
|
|
125
128
|
}
|
|
126
129
|
if (!wsServer) { rejectWebSocketUpgrade(socket, 503, 'STT WebSocket unavailable'); return; }
|
|
127
130
|
// Deterministic verify-registration barrier, as in the terminal
|
|
@@ -2,6 +2,7 @@ import { EventEmitter } from 'node:events';
|
|
|
2
2
|
import { describe, expect, test } from 'bun:test';
|
|
3
3
|
import { WebSocketServer } from 'ws';
|
|
4
4
|
|
|
5
|
+
import { createRequestSecurityRuntime } from '../security/request-security.js';
|
|
5
6
|
import { createSttRuntime } from './runtime.js';
|
|
6
7
|
|
|
7
8
|
describe('STT runtime upgrade', () => {
|
|
@@ -29,6 +30,7 @@ describe('STT runtime upgrade', () => {
|
|
|
29
30
|
ensureSessionToken: async () => 'client:thrower',
|
|
30
31
|
},
|
|
31
32
|
isRequestOriginAllowed: async () => true,
|
|
33
|
+
isCrossSiteRequest: async () => false,
|
|
32
34
|
rejectWebSocketUpgrade: () => {},
|
|
33
35
|
modelsDir: '/tmp/stt-test-models',
|
|
34
36
|
configFile: '/tmp/stt-test-config.json',
|
|
@@ -50,4 +52,45 @@ describe('STT runtime upgrade', () => {
|
|
|
50
52
|
await runtime.shutdown();
|
|
51
53
|
}
|
|
52
54
|
});
|
|
55
|
+
|
|
56
|
+
test('refuses a WebSocket from another site while UI auth is off', async () => {
|
|
57
|
+
const originalHandleUpgrade = WebSocketServer.prototype.handleUpgrade;
|
|
58
|
+
const upgradedOrigins = [];
|
|
59
|
+
WebSocketServer.prototype.handleUpgrade = function (req) {
|
|
60
|
+
upgradedOrigins.push(req.headers.origin ?? null);
|
|
61
|
+
return undefined;
|
|
62
|
+
};
|
|
63
|
+
const security = createRequestSecurityRuntime({ readSettingsFromDiskMigrated: async () => ({}) });
|
|
64
|
+
const rejections = [];
|
|
65
|
+
const server = new EventEmitter();
|
|
66
|
+
const runtime = createSttRuntime({
|
|
67
|
+
app: { get() {}, put() {}, post() {}, delete() {} },
|
|
68
|
+
server,
|
|
69
|
+
express: { json: () => (_req, _res, next) => next?.() },
|
|
70
|
+
uiAuthController: null,
|
|
71
|
+
isRequestOriginAllowed: security.isRequestOriginAllowed,
|
|
72
|
+
isCrossSiteRequest: security.isCrossSiteRequest,
|
|
73
|
+
rejectWebSocketUpgrade: (_socket, status) => rejections.push(status),
|
|
74
|
+
modelsDir: '/tmp/stt-test-models',
|
|
75
|
+
configFile: '/tmp/stt-test-config.json',
|
|
76
|
+
});
|
|
77
|
+
const upgrade = async (origin) => {
|
|
78
|
+
const socket = new EventEmitter();
|
|
79
|
+
socket.destroyed = false;
|
|
80
|
+
socket.destroy = function () { this.destroyed = true; };
|
|
81
|
+
server.emit('upgrade', { url: '/api/stt/ws', headers: { host: '127.0.0.1:3001', origin } }, socket, Buffer.alloc(0));
|
|
82
|
+
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
83
|
+
};
|
|
84
|
+
try {
|
|
85
|
+
await upgrade('https://evil.example.com');
|
|
86
|
+
expect(rejections).toEqual([403]);
|
|
87
|
+
expect(upgradedOrigins).toEqual([]);
|
|
88
|
+
await upgrade('http://127.0.0.1:3001');
|
|
89
|
+
expect(rejections).toEqual([403]);
|
|
90
|
+
expect(upgradedOrigins).toEqual(['http://127.0.0.1:3001']);
|
|
91
|
+
} finally {
|
|
92
|
+
WebSocketServer.prototype.handleUpgrade = originalHandleUpgrade;
|
|
93
|
+
await runtime.shutdown();
|
|
94
|
+
}
|
|
95
|
+
});
|
|
53
96
|
});
|
|
@@ -28,7 +28,7 @@ const trimHistory = (history) => {
|
|
|
28
28
|
|
|
29
29
|
export function createTerminalRuntime({
|
|
30
30
|
app, server, fs, path, uiAuthController, buildAugmentedPath, searchPathFor, isExecutable,
|
|
31
|
-
isRequestOriginAllowed, rejectWebSocketUpgrade, TERMINAL_INPUT_WS_HEARTBEAT_INTERVAL_MS,
|
|
31
|
+
isRequestOriginAllowed, isCrossSiteRequest, rejectWebSocketUpgrade, TERMINAL_INPUT_WS_HEARTBEAT_INTERVAL_MS,
|
|
32
32
|
// Live-revocation owner for this transport: upgrades are tracked under the
|
|
33
33
|
// authenticated principal so a later revocation or global invalidation
|
|
34
34
|
// closes the socket. Lifetime is not tied to the 60-second URL token TTL
|
|
@@ -320,6 +320,9 @@ export function createTerminalRuntime({
|
|
|
320
320
|
principal = await uiAuthController.ensureSessionToken(req, null);
|
|
321
321
|
if (!principal) { rejectWebSocketUpgrade(socket, 401, 'UI authentication required'); return; }
|
|
322
322
|
if (!await isRequestOriginAllowed(req)) { rejectWebSocketUpgrade(socket, 403, 'Invalid origin'); return; }
|
|
323
|
+
} else if (await isCrossSiteRequest(req)) {
|
|
324
|
+
// Without UI auth, another site's page must not open this socket.
|
|
325
|
+
rejectWebSocketUpgrade(socket, 403, 'Invalid origin'); return;
|
|
323
326
|
}
|
|
324
327
|
if (!wsServer) { rejectWebSocketUpgrade(socket, 500, 'Terminal WebSocket unavailable'); return; }
|
|
325
328
|
// Deterministic verify-registration barrier: generation was captured
|
|
@@ -6,6 +6,7 @@ import { describe, expect, it } from 'vitest';
|
|
|
6
6
|
import express from 'express';
|
|
7
7
|
import { WebSocket } from 'ws';
|
|
8
8
|
|
|
9
|
+
import { createRequestSecurityRuntime } from '../security/request-security.js';
|
|
9
10
|
import { createTerminalRuntime } from './runtime.js';
|
|
10
11
|
import { createTerminalWsControlFrame, readTerminalWsControlFrame } from './terminal-ws-protocol.js';
|
|
11
12
|
|
|
@@ -42,6 +43,7 @@ function createRuntime(server, overrides = {}) {
|
|
|
42
43
|
searchPathFor: () => null,
|
|
43
44
|
isExecutable: () => false,
|
|
44
45
|
isRequestOriginAllowed: async () => true,
|
|
46
|
+
isCrossSiteRequest: async () => false,
|
|
45
47
|
rejectWebSocketUpgrade() {},
|
|
46
48
|
TERMINAL_INPUT_WS_HEARTBEAT_INTERVAL_MS: 30_000,
|
|
47
49
|
TERMINAL_INPUT_WS_REBIND_WINDOW_MS: 1_000,
|
|
@@ -599,4 +601,43 @@ describe('terminal runtime', () => {
|
|
|
599
601
|
await runtime.shutdown();
|
|
600
602
|
}
|
|
601
603
|
});
|
|
604
|
+
|
|
605
|
+
it('refuses a WebSocket from another site while UI auth is off', async () => {
|
|
606
|
+
const { WebSocketServer } = await import('ws');
|
|
607
|
+
const originalHandleUpgrade = WebSocketServer.prototype.handleUpgrade;
|
|
608
|
+
const upgradedOrigins = [];
|
|
609
|
+
WebSocketServer.prototype.handleUpgrade = function (req) {
|
|
610
|
+
upgradedOrigins.push(req.headers.origin ?? null);
|
|
611
|
+
return undefined;
|
|
612
|
+
};
|
|
613
|
+
const security = createRequestSecurityRuntime({ readSettingsFromDiskMigrated: async () => ({}) });
|
|
614
|
+
const rejections = [];
|
|
615
|
+
const server = new EventEmitter();
|
|
616
|
+
const runtime = createRuntime(server, {
|
|
617
|
+
uiAuthController: null,
|
|
618
|
+
isRequestOriginAllowed: security.isRequestOriginAllowed,
|
|
619
|
+
isCrossSiteRequest: security.isCrossSiteRequest,
|
|
620
|
+
rejectWebSocketUpgrade: (_socket, status) => rejections.push(status),
|
|
621
|
+
});
|
|
622
|
+
const upgrade = async (origin) => {
|
|
623
|
+
const socket = new EventEmitter();
|
|
624
|
+
socket.destroyed = false;
|
|
625
|
+
socket.destroy = function () { this.destroyed = true; };
|
|
626
|
+
const headers = { host: '127.0.0.1:3001', ...(origin ? { origin } : {}) };
|
|
627
|
+
server.emit('upgrade', { url: '/api/terminal/ws', headers }, socket, Buffer.alloc(0));
|
|
628
|
+
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
629
|
+
};
|
|
630
|
+
try {
|
|
631
|
+
await upgrade('https://evil.example.com');
|
|
632
|
+
expect(rejections).toEqual([403]);
|
|
633
|
+
expect(upgradedOrigins).toEqual([]);
|
|
634
|
+
await upgrade('http://127.0.0.1:3001');
|
|
635
|
+
await upgrade(null);
|
|
636
|
+
expect(rejections).toEqual([403]);
|
|
637
|
+
expect(upgradedOrigins).toEqual(['http://127.0.0.1:3001', null]);
|
|
638
|
+
} finally {
|
|
639
|
+
WebSocketServer.prototype.handleUpgrade = originalHandleUpgrade;
|
|
640
|
+
await runtime.shutdown();
|
|
641
|
+
}
|
|
642
|
+
});
|
|
602
643
|
});
|
|
@@ -7,7 +7,7 @@ Trusted-device access has one durable credential model: a remote client bearer t
|
|
|
7
7
|
|
|
8
8
|
Pairing v2 is implemented by `packages/web/server/lib/client-auth/pairing.js`. It stores short-lived one-time pairing sessions with hashed secrets, exposes create/cancel/redeem routes under `/api/client-auth/pairing/*`, and redeems a valid pairing secret into the same remote client token used by password/passkey trusted-device flows.
|
|
9
9
|
|
|
10
|
-
Browser WebSocket clients mint a 60-second `oc_url_token` through the authenticated `/auth/url-token` route because the WebSocket constructor cannot attach an Authorization header. The token is encrypted with a key derived from the server's persisted JWT secret, so an ordinary server restart does not invalidate a token that the browser may still use. Global sign-out rotates that secret and invalidates outstanding tokens. The token is accepted only for the explicit WebSocket allowlist, currently `/api/terminal/ws
|
|
10
|
+
Browser WebSocket clients mint a 60-second `oc_url_token` through the authenticated `/auth/url-token` route because the WebSocket constructor cannot attach an Authorization header. The token is encrypted with a key derived from the server's persisted JWT secret, so an ordinary server restart does not invalidate a token that the browser may still use. Global sign-out rotates that secret and invalidates outstanding tokens. The token is accepted only for the explicit WebSocket allowlist, currently `/api/terminal/ws`, `/api/stt/ws`, and `/api/server-browser/ws`; ordinary API routes and unknown upgrade paths reject it. The token resolves to the UI session or remote-client identity that minted it.
|
|
11
11
|
|
|
12
12
|
The 60-second URL token TTL gates **establishment only**. Every establishment (WebSocket upgrade, SSE event-stream request) re-validates the embedded principal — client principals against the credential store, UI session principals against the current signing secret — so a token minted before a revocation or global sign-out is denied at open time (the mint/open race). An established connection's lifetime is governed by live revocation tracking, never by token expiry; see `../client-auth/DOCUMENTATION.md` for the latency guarantee (immediate in-process closure, bounded poll after the next successful read on healthy storage) and resource bounds (50 per principal / 1000 global / 2000 revoked IDs).
|
|
13
13
|
|
|
@@ -15,6 +15,34 @@ Verify-registration barrier: `requireAuth` captures the coordinator generation (
|
|
|
15
15
|
|
|
16
16
|
Signing-secret topology: the JWT secret is read once at startup (env override or persisted file) and cached in memory; `rotateJwtSecret` rewrites the file and rereads into memory synchronously, so new cookies and URL tokens bind to the new generation. Rotation is single-server only — the pairing CLI never rotates the secret and multi-server sharing is unsupported. While `PICHAMBER_JWT_SECRET` is set, `/auth/reset` returns 400 without side effects; global sign-out is unavailable.
|
|
17
17
|
|
|
18
|
+
## Cross-site requests
|
|
19
|
+
|
|
20
|
+
A page on another site must not drive PiChamber through the person's browser.
|
|
21
|
+
WebSockets skip CORS, so without this rule any site the person visits (or a
|
|
22
|
+
public page in the server browser) could open the terminal on a server
|
|
23
|
+
without UI auth. `security/request-security.js` owns the rule:
|
|
24
|
+
|
|
25
|
+
- `isCrossSiteRequest(req)` is true when the request names an `Origin` that is
|
|
26
|
+
not PiChamber's own (`Host`, `X-Forwarded-Host`), a packaged client's, or a
|
|
27
|
+
loopback page's (the origins CORS allows), and the browser does not mark it
|
|
28
|
+
`Sec-Fetch-Site: same-origin`. A request with no `Origin` is not a page's,
|
|
29
|
+
so it passes.
|
|
30
|
+
- `rejectCrossSiteRequests`, registered right after CORS in `server/index.js`,
|
|
31
|
+
answers 403 `Invalid origin` to such POST, PUT, PATCH, and DELETE requests
|
|
32
|
+
in every auth mode. Reads pass (CORS keeps their responses from other
|
|
33
|
+
sites), and so does preview proxy traffic under `/api/preview/proxy/`,
|
|
34
|
+
which carries no PiChamber credentials and belongs to the dev server.
|
|
35
|
+
- Without UI auth, the terminal, dictation, server browser, and preview proxy
|
|
36
|
+
WebSocket upgrades refuse cross-site requests with 403. With UI auth they
|
|
37
|
+
keep the stricter rule: an `Origin` is required and must pass
|
|
38
|
+
`isRequestOriginAllowed`.
|
|
39
|
+
|
|
40
|
+
Browsers send `Sec-Fetch-Site` only to secure origins (HTTPS or localhost), so
|
|
41
|
+
a proxy that rewrites `Host` on plain HTTP must set `X-Forwarded-Host`; the
|
|
42
|
+
Vite development proxy does, on requests and WebSocket upgrades. A proxy must
|
|
43
|
+
never rewrite `Origin` to the server's own: every page would then pass. DNS rebinding (another name resolving to the
|
|
44
|
+
server, so `Origin` and `Host` agree) is not caught.
|
|
45
|
+
|
|
18
46
|
## Entrypoints and structure
|
|
19
47
|
- `packages/web/server/lib/ui-auth/ui-auth.js`: UI auth controller runtime, cookie/session issuance, rate limiting, auth route handlers, and the auth-owning boundary where authenticated SSE event streams are registered for live revocation.
|
|
20
48
|
- `packages/web/server/lib/ui-auth/ui-passkeys.js`: passkey store and WebAuthn registration/authentication verification helpers.
|
|
@@ -359,6 +359,7 @@ const isEventStreamRequest = (req) => {
|
|
|
359
359
|
const URL_AUTH_WEBSOCKET_PATHS = new Set([
|
|
360
360
|
'/api/terminal/ws',
|
|
361
361
|
'/api/stt/ws',
|
|
362
|
+
'/api/server-browser/ws',
|
|
362
363
|
]);
|
|
363
364
|
|
|
364
365
|
const isUrlAuthWebSocketPath = (pathname) => URL_AUTH_WEBSOCKET_PATHS.has(pathname);
|
|
@@ -201,6 +201,14 @@ describe('ui auth client credential seam', () => {
|
|
|
201
201
|
};
|
|
202
202
|
expect(await auth.ensureSessionToken(sttWsReq, createResponse())).toBe('client:device-1');
|
|
203
203
|
|
|
204
|
+
const serverBrowserWsReq = {
|
|
205
|
+
method: 'GET',
|
|
206
|
+
path: '/api/server-browser/ws',
|
|
207
|
+
url: `/api/server-browser/ws?tab=t&oc_url_token=${encodeURIComponent(urlToken)}`,
|
|
208
|
+
headers: { connection: 'Upgrade', upgrade: 'websocket' },
|
|
209
|
+
};
|
|
210
|
+
expect(await auth.ensureSessionToken(serverBrowserWsReq, createResponse())).toBe('client:device-1');
|
|
211
|
+
|
|
204
212
|
const arbitraryWsReq = {
|
|
205
213
|
method: 'GET',
|
|
206
214
|
path: '/api/not-allowed/ws',
|
|
@@ -365,7 +373,7 @@ describe('ui auth live revocation', () => {
|
|
|
365
373
|
|
|
366
374
|
// Revoke, then try to open with the token minted moments earlier.
|
|
367
375
|
await remoteClientAuthRuntime.revokeClient(created.client.id);
|
|
368
|
-
for (const path of ['/api/terminal/ws', '/api/stt/ws']) {
|
|
376
|
+
for (const path of ['/api/terminal/ws', '/api/stt/ws', '/api/server-browser/ws']) {
|
|
369
377
|
const openReq = {
|
|
370
378
|
method: 'GET',
|
|
371
379
|
path,
|
|
@@ -8,6 +8,7 @@ import { registerFsRoutes } from '../fs/routes.js';
|
|
|
8
8
|
import { registerGitRoutes } from '../git/routes.js';
|
|
9
9
|
import { registerGitHubRoutes } from '../github/index.js';
|
|
10
10
|
import { createPreviewProxyRuntime } from '../preview/proxy-runtime.js';
|
|
11
|
+
import { createServerBrowserRuntime } from '../server-browser/runtime.js';
|
|
11
12
|
import { createRequestSecurityRuntime } from '../security/request-security.js';
|
|
12
13
|
import { mergePathValues } from '../server/path-utils.js';
|
|
13
14
|
import { createTerminalRuntime } from '../terminal/runtime.js';
|
|
@@ -54,8 +55,10 @@ const resolveProjectDirectory = async (req) => {
|
|
|
54
55
|
}
|
|
55
56
|
};
|
|
56
57
|
|
|
57
|
-
export const registerWorkspaceIntegrations = ({
|
|
58
|
-
|
|
58
|
+
export const registerWorkspaceIntegrations = ({
|
|
59
|
+
app, server, express, uiAuthController, dataDir, liveRevocation = null,
|
|
60
|
+
security = createRequestSecurityRuntime({ readSettingsFromDiskMigrated: async () => ({}) }),
|
|
61
|
+
}) => {
|
|
59
62
|
registerGitRoutes(app);
|
|
60
63
|
registerGitHubRoutes(app);
|
|
61
64
|
registerFsRoutes(app, {
|
|
@@ -82,6 +85,7 @@ export const registerWorkspaceIntegrations = ({ app, server, express, uiAuthCont
|
|
|
82
85
|
searchPathFor,
|
|
83
86
|
isExecutable,
|
|
84
87
|
isRequestOriginAllowed: security.isRequestOriginAllowed,
|
|
88
|
+
isCrossSiteRequest: security.isCrossSiteRequest,
|
|
85
89
|
rejectWebSocketUpgrade: security.rejectWebSocketUpgrade,
|
|
86
90
|
});
|
|
87
91
|
const sttRuntime = createSttRuntime({
|
|
@@ -91,6 +95,7 @@ export const registerWorkspaceIntegrations = ({ app, server, express, uiAuthCont
|
|
|
91
95
|
uiAuthController,
|
|
92
96
|
liveRevocation,
|
|
93
97
|
isRequestOriginAllowed: security.isRequestOriginAllowed,
|
|
98
|
+
isCrossSiteRequest: security.isCrossSiteRequest,
|
|
94
99
|
rejectWebSocketUpgrade: security.rejectWebSocketUpgrade,
|
|
95
100
|
modelsDir: path.join(dataDir, 'speech-models'),
|
|
96
101
|
configFile: path.join(dataDir, 'stt', 'config.json'),
|
|
@@ -105,11 +110,23 @@ export const registerWorkspaceIntegrations = ({ app, server, express, uiAuthCont
|
|
|
105
110
|
express,
|
|
106
111
|
uiAuthController,
|
|
107
112
|
isRequestOriginAllowed: security.isRequestOriginAllowed,
|
|
113
|
+
isCrossSiteRequest: security.isCrossSiteRequest,
|
|
114
|
+
rejectWebSocketUpgrade: security.rejectWebSocketUpgrade,
|
|
115
|
+
});
|
|
116
|
+
const serverBrowserRuntime = createServerBrowserRuntime({
|
|
117
|
+
app,
|
|
118
|
+
server,
|
|
119
|
+
express,
|
|
120
|
+
dataDir,
|
|
121
|
+
uiAuthController,
|
|
122
|
+
liveRevocation,
|
|
123
|
+
isRequestOriginAllowed: security.isRequestOriginAllowed,
|
|
124
|
+
isCrossSiteRequest: security.isCrossSiteRequest,
|
|
108
125
|
rejectWebSocketUpgrade: security.rejectWebSocketUpgrade,
|
|
109
126
|
});
|
|
110
127
|
return {
|
|
111
128
|
shutdown: async () => {
|
|
112
|
-
await Promise.allSettled([terminalRuntime.shutdown(), sttRuntime.shutdown()]);
|
|
129
|
+
await Promise.allSettled([terminalRuntime.shutdown(), sttRuntime.shutdown(), serverBrowserRuntime.shutdown()]);
|
|
113
130
|
},
|
|
114
131
|
};
|
|
115
132
|
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import{k as t,aL as St}from"./vendor-boot-EC6IyLt1.js";import{R as r}from"./vendor-react-DASdDPIk.js";import{e as re,f as Y,a as et,p as Oe}from"./index-D4n3TVp2.js";import{e6 as Nt,dQ as Ct,e4 as Lt,at as tt,ah as nt,cx as Dt,cy as ke,B as Se,I as z,z as st,aN as ce,t as it,dY as rt,ai as kt,al as Rt,an as Et,ap as Ge,cr as At,e7 as Tt,e8 as Mt,y as It,ae as Pt,aI as $t,ar as Wt,cS as _t,h as Bt,aD as zt,aW as Ot,aj as Gt,ak as Ht,am as Ut}from"./useAppFontEffects-CqHhRKmN.js";import{d as ot,i as He,a as Ue,b as Vt,C as Kt}from"./gitStatusPredicates-B3Zxud6E.js";import{p as qt}from"./VirtualizedFileDiff-B8lhZGLu.js";import{P as Xt}from"./PierreDiffViewer-CGpKcLro.js";import{v as Yt,g as Qt}from"./contextFileOpenGuard-CsF5Boky.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-zustand-CUi8eEds.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./runtimeSurface-k1Eit61v.js";import"./nativeFileSave-BJsGPh58.js";import"./web-components-DzQ9ybbb.js";import"./computeVirtualFileMetrics-Bjhk2CQS.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./themeResolver-yJ9XpNMI.js";import"./vendor-pierre-theming-Dgp7B_O4.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./renderDiffWithHighlighter-BhMEWmHn.js";import"./vendor-diff-C3JhlQdm.js";import"./StickyHorizontalScrollbar-BMITjK4e.js";import"./runtimeEndpointReset-D22U_Vjs.js";import"./SessionUnreadDot-Dav_rix1.js";/* empty css */import"./permissionStore-B9Hkrqny.js";import"./appThemeRegistry-gegrE2dq.js";import"./registerCustomTheme-DmolaWWZ.js";function Jt(n,s=10){const e=[];let i;for(const l of n.split(`
|
|
2
|
-
`)){const p=l.match(Nt);if(p!=null){i!=null&&(i.hunkLines.length>0&&(Ee(i,s,"trailing"),Ie(i,e)),i=void 0);const d=parseInt(p[3]),b=parseInt(p[1]),g=parseInt(p[4]??"1"),c=parseInt(p[2]??"1");isNaN(d)||isNaN(b)||isNaN(g)||isNaN(c)?e.push(l):i={additionStart:d,deletionStart:b,additionCount:0,deletionCount:0,hunkLines:[],contextLines:[]};continue}if(i==null){e.push(l);continue}if(l.startsWith(" "))i.contextLines.push(l);else if(l!==""){if(i.hunkLines.length>0&&i.contextLines.length>s*2){const d=i.contextLines.length-s*2,b=i.contextLines.slice(-s);Ee(i,s,"trailing");const{additionCount:g,deletionCount:c}=i;Ie(i,e),i={additionStart:i.additionStart+g+d,deletionStart:i.deletionStart+c+d,deletionCount:0,additionCount:0,contextLines:b,hunkLines:[]}}Ee(i,s,i.hunkLines.length===0?"leading":"before-change"),i.hunkLines.push(l),l.startsWith("+")?i.additionCount+=1:l.startsWith("-")&&(i.deletionCount+=1)}}i!=null&&i.hunkLines.length>0&&(Ee(i,s,"trailing"),Ie(i,e));const a=e.join(`
|
|
3
|
-
`);return n.endsWith(`
|
|
4
|
-
`)?`${a}
|
|
5
|
-
`:a}function Ee(n,s,e){if(e==="leading"&&n.contextLines.length>s){const i=n.contextLines.length-s;n.contextLines.splice(0,i),n.additionStart+=i,n.deletionStart+=i}return e==="trailing"&&n.contextLines.length>s&&(n.contextLines.length=s),n.contextLines.length>0&&(n.hunkLines.push(...n.contextLines),n.additionCount+=n.contextLines.length,n.deletionCount+=n.contextLines.length,n.contextLines.length=0),n}function Ie(n,s){s.push(`@@ -${Ve(n.deletionStart,n.deletionCount)} +${Ve(n.additionStart,n.additionCount)} @@`),s.push(...n.hunkLines)}function Ve(n,s){return s===1?`${n}`:`${n},${s}`}const Zt=64,en=3,he=new Map,tn=(n,s,e=en)=>{const i=`${n}\0${e}\0${s}`,a=he.get(i);if(a)return he.delete(i),he.set(i,a),a;const l=sn(s),p=l?Ct(Jt(s,e),{oldFile:{name:n,contents:l.before},newFile:{name:n,contents:l.after}})??qe(n):Lt(nn(n,s))[0]?.files[0]??qe(n);for(he.set(i,p);he.size>Zt;){const d=he.keys().next().value;if(!d)break;he.delete(d)}return p},nn=(n,s)=>!s.trim()||s.startsWith("diff --git ")||/^--- [^\n]*\r?\n\+\+\+ /m.test(s)?s:`Index: ${n}
|
|
6
|
-
===================================================================
|
|
7
|
-
--- ${n}
|
|
8
|
-
+++ ${n}
|
|
9
|
-
${s}`,sn=n=>{if(!n.startsWith("diff --git ")&&!/^--- [^\n]*\t?\r?\n\+\+\+ [^\n]*\t?(?:\r?\n|$)/m.test(n))return;const s=[...n.matchAll(/^@@\s+-(\d+)(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s+@@[^\n]*(?:\r?\n|$)/gm)];if(s.length!==1)return;const e=s[0],i=Number.parseInt(e[1]??"",10),a=Number.parseInt(e[2]??"",10);if(i>1||a>1||!Number.isFinite(i)||!Number.isFinite(a))return;const l=(e.index??0)+e[0].length,p=n.slice(l),d=[],b=[];let g;for(const c of p.split(/\r?\n/)){if(c.startsWith("diff --git ")||c.startsWith("@@ "))break;if(c.startsWith("\\")){if(g==="-"||g===" "){const h=d.at(-1);h&&(h.newline=!1)}if(g==="+"||g===" "){const h=b.at(-1);h&&(h.newline=!1)}continue}if(c.startsWith("-")){d.push({text:c.slice(1),newline:!0}),g="-";continue}if(c.startsWith("+")){b.push({text:c.slice(1),newline:!0}),g="+";continue}c.startsWith(" ")&&(d.push({text:c.slice(1),newline:!0}),b.push({text:c.slice(1),newline:!0}),g=" ")}return{before:Ke(d),after:Ke(b)}},Ke=n=>n.map(s=>s.text+(s.newline?`
|
|
10
|
-
`:"")).join(""),qe=n=>qt({name:n,contents:""},{name:n,contents:""}),rn=n=>/^Binary files .+ differ$/m.test(n)||/^GIT binary patch$/m.test(n),$e=(n,s,e)=>rn(s)?{original:"",modified:"",isBinary:!0,patch:s,contextMode:e}:{original:"",modified:"",patch:s,fileDiff:tn(n,s),contextMode:e},at=(n,s,e)=>{const i=n??0,a=s??0;return!i&&!a?null:t.jsxs("span",{className:re("typography-meta flex items-center gap-1 text-xs whitespace-nowrap","flex-shrink-0",e?.className),children:[i?t.jsxs("span",{style:{color:"var(--status-success)"},children:["+",i]}):null,a?t.jsxs("span",{style:{color:"var(--status-error)"},children:["-",a]}):null]})},on=r.memo(function({changedFiles:s,selectedFile:e,onSelectFile:i}){return s.length===0?null:t.jsx(tt,{outerClassName:"flex-1 min-h-0",className:"px-1 py-2",children:t.jsx("ul",{className:"flex flex-col gap-1",children:s.map(a=>{const l=ot(a),p=e===a.path;return t.jsx("li",{children:t.jsxs("button",{type:"button",onClick:()=>i(a.path),className:re("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors",p?"bg-interactive-selection text-interactive-selection-foreground":"text-muted-foreground hover:bg-interactive-hover hover:text-foreground"),children:[t.jsx(nt,{filePath:a.path,className:"h-3.5 w-3.5 flex-shrink-0"}),t.jsx("span",{className:"typography-micro font-semibold w-4 text-center uppercase",style:{color:l.color},title:l.description,"aria-label":l.description,children:l.code}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},title:a.path,children:a.path}),at(a.insertions,a.deletions)]})},a.path)})})})}),an=r.memo(function(){return t.jsx("div",{className:"rounded-lg border border-border/60 bg-background px-3 py-2",children:t.jsx("div",{className:"typography-meta text-muted-foreground",children:"Content of this file cannot be viewed."})})}),ln=r.memo(function({filePath:s,diff:e,renderSideBySide:i}){const a=e.original.length>0,l=e.modified.length>0,p=i?"flex flex-row gap-6 items-start justify-center":"flex flex-col gap-4 items-center",d=i?"flex flex-col items-center gap-2 flex-1 min-w-0":"flex flex-col items-center gap-2";return t.jsx("div",{className:"w-full overflow-auto p-4",style:{contain:"layout"},children:t.jsxs("div",{className:p,children:[a&&t.jsxs("div",{className:d,children:[t.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:"Original"}),t.jsx("img",{src:e.original,alt:`Original: ${s}`,className:i?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]}),l&&t.jsxs("div",{className:d,children:[t.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:a?"Modified":"New"}),t.jsx("img",{src:e.modified,alt:`Modified: ${s}`,className:i?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]})]})})}),cn=r.memo(function({filePath:s,diff:e,renderSideBySide:i,wrapLines:a}){const l=r.useMemo(()=>Dt(s)||"text",[s]);return e.isBinary?t.jsx(an,{}):ke(s)?t.jsx(ln,{filePath:s,diff:e,renderSideBySide:i}):t.jsx("div",{className:"w-full",style:{contain:"layout"},children:t.jsx(Xt,{original:e.original,modified:e.modified,fileDiff:e.fileDiff,language:l,fileName:s,renderSideBySide:i,wrapLines:a,layout:"inline"})})}),Pe=({label:n,icon:s,loading:e,disabled:i,tone:a,onClick:l})=>t.jsx(Se,{variant:"ghost",size:"sm",className:re("h-6 w-6 rounded-none bg-transparent p-0 text-muted-foreground opacity-70 hover:bg-transparent hover:text-foreground hover:opacity-100",a==="failure"&&"text-[var(--status-error)] hover:text-[var(--status-error)]",a==="success"&&"text-[var(--status-success)] hover:text-[var(--status-success)]"),disabled:i,title:n,"aria-label":n,onClick:p=>{p.stopPropagation(),l()},children:e?t.jsx(z,{name:"loader-4",className:"size-3.5 animate-spin"}):t.jsx(z,{name:s,className:s==="add"?"size-4":"size-3.5"})}),un=r.memo(function({filePath:s,staged:e,busyAction:i,disabled:a,onAction:l}){return t.jsx("div",{className:"flex items-center gap-0.5 rounded-full border border-[var(--interactive-border)]/45 bg-[var(--surface-background)]/95 px-1 py-0.5 shadow-sm backdrop-blur-md",children:e?t.jsx(Pe,{label:`Unstage ${s}`,icon:"arrow-go-back",loading:i==="unstage",disabled:a,onClick:()=>l("unstage")}):t.jsxs(t.Fragment,{children:[t.jsx(Pe,{label:`Revert changes in ${s}`,icon:"arrow-go-back",loading:i==="discard",disabled:a,tone:"failure",onClick:()=>l("discard")}),t.jsx(Pe,{label:`Stage ${s}`,icon:"add",loading:i==="stage",disabled:a,tone:"success",onClick:()=>l("stage")})]})})}),lt=3,dn=1e6,fn=15e3,Xe=500,pn=r.memo(function({directory:s,file:e,layout:i,wrapLines:a,isSelected:l,isExpanded:p,isMounted:d,onSelect:b,onExpandedChange:g,registerSectionRef:c,showOpenInEditorAction:h=!1,isOpeningInEditor:w=!1,onOpenInEditor:D,staged:x=!1,showFileActions:S=!0,loadFullFiles:m=!1,initialDiffData:f=null}){const{git:P}=st(),$=ce(r.useCallback(u=>u.directories.get(s)?.diffCache.get(e.path)??null,[s,e.path])),M=ce(u=>u.setDiff),N=ce(u=>u.fetchStatus),O=Y(u=>u.setDiffFileLayout),v=Y(u=>u.setDiffWrapLines),[y,L]=r.useState(0),[k,R]=r.useState(null),[W,C]=r.useState(!1),[_,V]=r.useState(null),[Z,me]=r.useState(!1),[ue,E]=r.useState(null),[I,ee]=r.useState(null),te=r.useRef(null),Q=r.useRef(null),oe=r.useMemo(()=>ot(e),[e]),X=i==="side-by-side",K=m?"full":"patch",ae=`${e.index}:${e.working_dir}:${e.insertions}:${e.deletions}`,J=r.useMemo(()=>f||(x?I:ue||($?{original:$.original,modified:$.modified,isBinary:$.isBinary,contextMode:"full"}:null)),[$,f,ue,x,I]),ge=J?.contextMode===K,de=r.useCallback(u=>{Q.current=u,c(e.path,u)},[e.path,c]),xe=r.useCallback(u=>{g(e.path,u)},[e.path,g]),be=r.useCallback(()=>{b(e.path)},[e.path,b]);r.useEffect(()=>{x?ee(null):E(null),R(null),te.current=null},[ae,x]),r.useEffect(()=>{if(!p||!d)return;if(!s||f||J&&ge){te.current=null,C(!1);return}const u=`${s}::${e.path}::${x?"staged":"unstaged"}::${ae}::${K}::${y}`;if(te.current===u)return;te.current=u,R(null),C(!0);let T=!1;const ne=et(),ye=m?dn:lt,fe=ke(e.path)?P.getGitFileDiff(s,{path:e.path,staged:x}):P.getGitDiff(s,{path:e.path,staged:x,contextLines:ye}),se=fn,Ce=new Promise((q,B)=>{setTimeout(()=>B(new Error(`Timed out after ${se}ms`)),se)});return Promise.race([fe,Ce]).then(q=>{if(!T){if("diff"in q){const B=$e(e.path,q.diff,K);x?ee(B):E(B)}else{const B={original:q.original??"",modified:q.modified??"",isBinary:q.isBinary,contextMode:"full"};x?ee(B):M(s,e.path,B,ne)}C(!1)}}).catch(q=>{if(T)return;const B=q instanceof Error?q.message:String(q);R(B),C(!1)}),()=>{T=!0,te.current===u&&(te.current=null)}},[K,J,ge,y,s,e.path,ae,P,f,p,d,m,M,x]);const le=r.useCallback(()=>{xe(!p),be()},[xe,be,p]),Ne=r.useCallback(async u=>{if(!(!s||_!==null)){V(u);try{u==="stage"?await P.stageGitFile(s,e.path):u==="unstage"?await P.unstageGitFile(s,e.path):await P.revertGitFile(s,e.path,{scope:"working"}),L(T=>T+1),await N(s,P)}catch(T){const ne=u==="unstage"?"Failed to unstage changes":u==="stage"?"Failed to stage changes":"Failed to revert changes";it.error(T instanceof Error?T.message:ne)}finally{V(T=>T===u?null:T)}}},[s,N,e.path,_,P]);return t.jsxs("div",{ref:de,className:re("scroll-mt-9 border-b border-[var(--interactive-border)]/40 last:border-b-0"),children:[t.jsx("div",{className:re("z-30 border-b border-[var(--interactive-border)]/35 bg-[var(--surface-elevated)]/90 backdrop-blur-md supports-[backdrop-filter]:bg-[var(--surface-elevated)]/80","sticky top-0"),children:t.jsxs("div",{role:"button",tabIndex:0,onClick:le,onKeyDown:u=>{u.target===u.currentTarget&&(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),le())},className:re("cursor-pointer","group/header relative grid min-h-9 w-full min-w-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-2 overflow-hidden px-3 py-2","bg-transparent","text-muted-foreground hover:text-foreground",l?"bg-[var(--interactive-selection)]/35":null),children:[t.jsx("div",{className:"absolute inset-0 pointer-events-none group-hover/header:bg-[var(--interactive-hover)]/50"}),t.jsxs("div",{className:"relative flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("span",{className:"flex size-5 items-center justify-center opacity-70 group-hover/header:opacity-100",children:p?t.jsx(z,{name:"arrow-down-s",className:"size-4"}):t.jsx(z,{name:"arrow-right-s",className:"size-4"})}),t.jsx("span",{className:"typography-micro font-semibold leading-none w-4 text-center uppercase",style:{color:oe.color},title:oe.description,"aria-label":oe.description,children:oe.code}),t.jsx("span",{className:"min-w-0 flex-1 overflow-hidden typography-ui-label",title:e.path,children:t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(nt,{filePath:e.path,className:"h-3.5 w-3.5 flex-shrink-0 align-middle"}),(()=>{const u=e.path.lastIndexOf("/");if(u===-1)return t.jsx("span",{className:"block min-w-0 truncate typography-ui-label text-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:e.path});const T=e.path.slice(0,u),ne=e.path.slice(u+1);return t.jsxs("span",{className:"flex min-w-0 items-baseline overflow-hidden",children:[t.jsx("span",{className:"min-w-0 truncate typography-ui-label text-muted-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:T}),t.jsxs("span",{className:"flex-shrink-0 typography-ui-label",children:[t.jsx("span",{className:"text-muted-foreground",children:"/"}),t.jsx("span",{className:"text-foreground",children:ne})]})]})})()]})})]}),t.jsxs("div",{className:"relative flex shrink-0 items-center justify-self-end gap-2",children:[at(e.insertions,e.deletions),h&&D?t.jsx(Se,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0 opacity-70 hover:opacity-100",title:"Open this file in editor at change",onClick:u=>{u.stopPropagation(),D(e.path,J)},disabled:w,children:w?t.jsx(z,{name:"loader-4",className:"size-3.5 animate-spin"}):t.jsx(z,{name:"edit",className:"size-3.5"})}):null,t.jsx(rt,{mode:X?"side-by-side":"unified",onModeChange:u=>{const T=u==="side-by-side"?"side-by-side":"inline";O(e.path,T)},className:"opacity-70"}),t.jsxs(kt,{children:[t.jsx(Rt,{asChild:!0,children:t.jsx(Se,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0 opacity-70 hover:opacity-100",title:"File view options","aria-label":"File view options",onClick:u=>{u.stopPropagation()},onPointerDown:u=>{u.stopPropagation()},children:t.jsx(z,{name:"more-2-fill",className:"size-3.5"})})}),t.jsxs(Et,{align:"end",onClick:u=>{u.stopPropagation()},onPointerDown:u=>{u.stopPropagation()},children:[t.jsxs(Ge,{onSelect:()=>{v(!a)},children:[t.jsx(z,{name:"text-wrap",className:"size-4"}),t.jsx("span",{className:"flex-1",children:"Wrap lines"}),a?t.jsx(z,{name:"check",className:"size-4"}):null]}),t.jsxs(Ge,{onSelect:()=>{O(e.path,X?"inline":"side-by-side")},children:[t.jsx(z,{name:X?"align-justify":"layout-column",className:"size-4"}),X?"Switch to unified view":"Switch to side-by-side view"]})]})]})]})]})}),p&&t.jsxs("div",{className:"relative overflow-clip bg-background",children:[!d&&!k?t.jsx("div",{className:"h-40 border border-border/40 bg-background/40"}):null,k?t.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:"Failed to load diff"}),t.jsx("div",{className:"typography-meta text-muted-foreground max-w-[32rem] text-center",children:k}),t.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>L(u=>u+1),children:"Retry"})]}):null,d&&W&&!J&&!k?t.jsxs("div",{className:"flex items-center justify-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[t.jsx(z,{name:"loader-4",className:"size-4 animate-spin"}),"Loading diff..."]}):null,d&&J&&!Z&&e.insertions+e.deletions>Xe?t.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:`Large diff (${e.insertions+e.deletions} changed lines)`}),t.jsx("div",{className:"typography-meta text-muted-foreground",children:"Rendering may be slow. You can still view the diff by clicking below."}),t.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>me(!0),children:"Render anyway"})]}):null,d&&J&&(Z||e.insertions+e.deletions<=Xe)?t.jsxs(t.Fragment,{children:[t.jsx(cn,{filePath:e.path,diff:J,renderSideBySide:X,wrapLines:a}),S?t.jsx("div",{className:"pointer-events-none absolute bottom-3 right-3 z-20",children:t.jsx("div",{className:"pointer-events-auto",children:t.jsx(un,{filePath:e.path,staged:x,busyAction:_,disabled:_!==null,onAction:Ne})})}):null]}):null]})]})}),hn=1100,Ye=300,mn=n=>n<=6?n:n<=12?6:n<=25?4:2,gn=(n,s)=>At(n,s),Qe=(n,s)=>{const e=n.split(`
|
|
11
|
-
`),i=s.split(`
|
|
12
|
-
`),a=Math.min(e.length,i.length);for(let l=0;l<a;l+=1)if(e[l]!==i[l])return l+1;return i.length>e.length?e.length+1:e.length>i.length?Math.max(1,i.length):1},xn=n=>Array.isArray(n)?n.filter(s=>!s||typeof s!="object"?!1:typeof s.file=="string"):[],bn=n=>n.split(/^diff --git /m).slice(1).flatMap(e=>{const[i=""]=e.split(`
|
|
13
|
-
`,1),a=i.lastIndexOf(" b/");if(a<=2)return[];const l=i.slice(2,a),p=i.slice(a+3).trim(),d=`diff --git ${e}`,b=d.includes(`
|
|
14
|
-
new file mode `)?"added":d.includes(`
|
|
15
|
-
deleted file mode `)?"deleted":d.includes(`
|
|
16
|
-
rename from `)?"renamed":"modified";let g=0,c=0;for(const h of d.split(`
|
|
17
|
-
`))h.startsWith("+")&&!h.startsWith("+++")&&(g+=1),h.startsWith("-")&&!h.startsWith("---")&&(c+=1);return[{file:b==="deleted"?l:p,status:b,additions:g,deletions:c,patch:d}]}),yn=n=>n==="added"?"A":n==="deleted"?"D":"M";function wn({activeDiffScope:n,effectiveDirectory:s,branchBase:e,branchHead:i,git:a,sessionMessageRecords:l}){const[p,d]=r.useState([]),[b,g]=r.useState(null),[c,h]=r.useState(!1),w=r.useMemo(()=>{const S=Tt(l,{showTextJustificationActivity:!1,mergeHiddenUserTurns:!0});for(let m=S.turns.length-1;m>=0;m-=1){const f=S.turns[m];if(!f)continue;const P=f.activityParts.map(N=>N.part).filter(N=>N.type==="tool"),$=Mt(P);if($.length>0)return $.map(N=>({file:N.path,status:"modified",additions:N.additions,deletions:N.deletions,patch:N.patch}));const M=xn(f.userMessage.info?.summary?.diffs);if(M.length>0)return M}return[]},[l]);r.useEffect(()=>{if(n!=="branch"||!s||!e||!i||!a.getGitRangeDiff){d([]),g(null),h(!1);return}let S=!1;return h(!0),g(null),a.getGitRangeDiff(s,{base:e,head:i,contextLines:lt}).then(m=>{S||(d(bn(m.diff??"")),h(!1))}).catch(m=>{S||(d([]),h(!1),g(m instanceof Error?m.message:String(m)))}),()=>{S=!0}},[n,e,i,s,a]);const D=r.useMemo(()=>{const S=new Map;for(const m of w)if(m.file){if(typeof m.patch=="string"){S.set(m.file,$e(m.file,m.patch,"patch"));continue}typeof m.before!="string"&&typeof m.after!="string"||S.set(m.file,{original:m.before??"",modified:m.after??"",contextMode:"full"})}return S},[w]),x=r.useMemo(()=>{const S=new Map;for(const m of p)!m.file||typeof m.patch!="string"||S.set(m.file,$e(m.file,m.patch,"patch"));return S},[p]);return{branchDiffs:p,branchDiffError:b,branchDiffLoading:c,lastTurnDiffs:w,lastTurnDiffData:D,branchDiffData:x}}const Je=(n,s)=>{if(s.length===0)return null;let e=null,i=null;for(const l of s)l.top<=n?(!e||l.top>e.top)&&(e=l):(!i||l.top<i.top)&&(i=l);const a=e??i;return a?{path:a.path,topOffset:a.top-n}:null},Fn=(n,s,e,i)=>Math.min(Math.max(0,i),Math.max(0,n+e-s));function vn({pinSelectedFileHeaderToTopOnNavigate:n,scrollRequestNonce:s,changedFiles:e,expandedFiles:i,setMountedStackedFiles:a,fileDiffRefreshNonce:l}){const p=r.useRef(null),d=r.useRef(new Map),[b,g]=r.useState(null),c=r.useRef(null),h=r.useRef(null),w=r.useRef(!1),D=r.useRef(null),x=r.useRef(i),S=r.useRef(null);r.useLayoutEffect(()=>{x.current=i},[i]);const m=r.useRef(null),f=r.useCallback(()=>{const v=p.current;if(!v)return null;const y=v.getBoundingClientRect().top,L=[];for(const[k,R]of d.current)R&&L.push({path:k,top:R.getBoundingClientRect().top});return Je(y,L)},[]),P=r.useCallback(()=>{c.current=null,w.current=!1,g(null),h.current!==null&&(window.cancelAnimationFrame(h.current),h.current=null)},[]),$=r.useCallback(()=>{D.current=null;const v=p.current;if(!v)return;const y=v.getBoundingClientRect(),L=y.top-Ye,k=y.bottom+Ye,R={},W=[];for(const[C,_]of d.current){if(!_)continue;const V=_.getBoundingClientRect();W.push({path:C,top:V.top}),x.current.has(C)&&(V.bottom<L||V.top>k||(R[C]=!0))}S.current=Je(y.top,W),a(C=>{let _=!1;const V=new Set(C);for(const Z of Object.keys(R))V.has(Z)||(V.add(Z),_=!0);return _?V:C})},[a]),M=r.useCallback(()=>{typeof window>"u"||D.current===null&&(D.current=window.requestAnimationFrame($))},[$]);r.useEffect(()=>{const v=p.current;if(v)return M(),v.addEventListener("scroll",M,{passive:!0}),window.addEventListener("resize",M),()=>{v.removeEventListener("scroll",M),window.removeEventListener("resize",M),D.current!==null&&(window.cancelAnimationFrame(D.current),D.current=null)}},[e,i,M]),r.useLayoutEffect(()=>{const v=m.current;if(!v)return;m.current=null;const y=p.current,L=d.current.get(v.path);if(!y||!L)return;const k=y.getBoundingClientRect().top,R=L.getBoundingClientRect().top-k;y.scrollTop=Fn(y.scrollTop,v.topOffset,R,y.scrollHeight-y.clientHeight),S.current=v},[l]);const N=r.useCallback((v,y)=>{const L=d.current;y?L.set(v,y):L.delete(v),M()},[M]),O=r.useCallback(v=>{const y=d.current.get(v),L=p.current;if(!y||!L)return!1;const k=y.getBoundingClientRect().top-L.getBoundingClientRect().top;return L.scrollTo({top:L.scrollTop+k,behavior:"auto"}),!0},[]);return r.useEffect(()=>{if(!c.current)return;let y=0;const L=20;let k=!1;const R=(C=!0)=>{k||(k=!0,c.current=null,w.current=!1,C&&g(null),h.current!==null&&(window.cancelAnimationFrame(h.current),h.current=null))},W=()=>{if(k){h.current=null;return}const C=c.current;if(!C){R(),h.current=null;return}if(!O(C)){y+=1,y<L?h.current=window.requestAnimationFrame(W):(R(),h.current=null);return}if(n&&w.current){g(C),R(!1);return}R()};return h.current=window.requestAnimationFrame(W),()=>{k=!0,h.current!==null&&(window.cancelAnimationFrame(h.current),h.current=null)}},[n,s,O]),{diffScrollRef:p,fileSectionRefs:d,pinnedStackedTarget:b,pendingScrollTargetRef:c,shouldPinAfterAlignRef:w,pendingScrollAnchorRestoreRef:m,lastScrollAnchorRef:S,captureScrollAnchor:f,cancelPendingScrollAlignment:P,queueVisibleStackedFilesSync:M,registerSectionRef:N,scrollToFile:O}}const Ze=n=>{if(!n)return null;const s=n.split(`
|
|
18
|
-
`);let e=null;for(const i of s){const a=i.match(/^@@\s*-\d+(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s*@@/);if(a){const l=Number.parseInt(a[1]??"",10);e=Number.isFinite(l)&&l>=1?l:null;continue}if(e!==null){if(i.startsWith(" ")){e+=1;continue}if(i.startsWith("+"))return e;if(i.startsWith("-"))return Math.max(1,e)}}return null};function jn({effectiveDirectory:n,activeDiffStaged:s,git:e,files:i,setDiff:a,openContextFileAtLine:l}){const[p,d]=r.useState(null),b=r.useCallback(async(g,c)=>{if(!n||!g)return;d(g);const h=et();try{let w=null;if(c?.patch&&!c.isBinary&&!ke(g)?w=Ze(c.patch):c&&c.contextMode==="full"&&!c.isBinary&&!ke(g)&&(w=Qe(c.original,c.modified)),w===null)try{const f=await e.getGitDiff(n,{path:g,staged:s,contextLines:3});w=Ze(f.diff)}catch{w=null}let D=c;if(w===null||!D){const f=await e.getGitFileDiff(n,{path:g,staged:s});D={original:f.original??"",modified:f.modified??"",isBinary:f.isBinary},s||a(n,g,D,h??void 0)}const x=w??(D.isBinary||ke(g)?1:Qe(D.original,D.modified)),S=gn(n,g),m=await Yt(i,S,{directory:n});if(!m.ok){it.error(Qt(m.reason));return}l(n,S,x,1)}finally{d(w=>w===g?null:w)}},[s,n,i,e,l,a]);return{openingEditorFilePath:p,openFileInEditorAtChange:b}}function Sn(n){const{hideStackedFileSidebar:s=!1,stackedDefaultCollapsedAll:e=!1,pinSelectedFileHeaderToTopOnNavigate:i=!1,diffScope:a="all",branchBase:l=null,branchHead:p=null,targetFilePath:d=null}=n,{git:b,files:g}=st(),c=It(),{screenWidth:h,isMobile:w}=Pt(),D=$t(c??null),x=Wt(c??null),S=_t(c??null),m=ce(o=>o.setActiveDirectory),f=ce(o=>o.ensureStatus),P=ce(o=>o.fetchStatus),$=ce(o=>o.clearDiffCache),M=ce(o=>o.setDiff),[N,O]=r.useState(null),[v,y]=r.useState(!1),[L,k]=r.useState(()=>new Set),[R,W]=r.useState(()=>new Set),[C,_]=r.useState(!1),[V,Z]=r.useState(0),[me,ue]=r.useState(()=>new Map),[E,I]=r.useState(a);r.useEffect(()=>{I(a)},[a]);const ee=Y(o=>o.pendingDiffFile),te=Y(o=>o.pendingDiffStaged),Q=Y(o=>o.pendingDiffScope),oe=Y(o=>o.setPendingDiffFile),X=Y(o=>o.diffLayoutPreference),K=Y(o=>o.diffFileLayout),ae=Y(o=>o.setDiffFileLayout),J=Y(o=>o.diffWrapLinesOverride),ge=Y(o=>o.wrapLinesByDefault),de=Y(o=>o.setDiffWrapLines),xe=Y(o=>o.openContextFileAtLine),be=Bt(o=>o.currentSessionId),le=zt(be??""),Ne=J??ge,u=E==="staged"?!0:E==="working"?!1:null,T=u??v,ne=w||h<=768,ye=!s&&!ne&&h>=1024,fe=r.useRef(null),{branchDiffs:se,branchDiffError:Ce,branchDiffLoading:q,lastTurnDiffs:B,lastTurnDiffData:ie,branchDiffData:G}=wn({activeDiffScope:E,effectiveDirectory:c,branchBase:l,branchHead:p,git:b,sessionMessageRecords:le}),H=r.useMemo(()=>{if(E==="turn"||E==="branch")return(E==="branch"?se:B).map(A=>({path:A.file??"",index:"",working_dir:yn(A.status),insertions:A.additions??0,deletions:A.deletions??0,isNew:A.status==="added"})).filter(A=>A.path).sort((A,U)=>A.path.localeCompare(U.path));if(!x?.files)return[];const o=x.diffStats??{},j=E==="staged"?He:E==="working"?Ue:()=>!0;return x.files.filter(j).map(F=>({...F,insertions:o[F.path]?.insertions??0,deletions:o[F.path]?.deletions??0,isNew:Vt(F)})).sort((F,A)=>F.path.localeCompare(A.path))},[E,se,B,x]),Ae=r.useMemo(()=>x?.files?x.files.filter(Ue).length:0,[x]),ct=r.useMemo(()=>x?.files?x.files.filter(He).length:0,[x]),ut=B.length,dt=x?.files?.length??0,ft=se.length,{diffScrollRef:pt,pinnedStackedTarget:ht,pendingScrollTargetRef:we,shouldPinAfterAlignRef:Fe,pendingScrollAnchorRestoreRef:We,lastScrollAnchorRef:_e,captureScrollAnchor:Be,cancelPendingScrollAlignment:ve,queueVisibleStackedFilesSync:Re,registerSectionRef:mt,scrollToFile:ze}=vn({pinSelectedFileHeaderToTopOnNavigate:i,scrollRequestNonce:V,changedFiles:H,expandedFiles:L,setMountedStackedFiles:W,fileDiffRefreshNonce:me}),je=r.useCallback(o=>{k(j=>{if(j.has(o))return j;const F=new Set(j);return F.add(o),F})},[]),Te=r.useMemo(()=>H.map(o=>o.path).join("\0"),[H]);r.useEffect(()=>{const o=Te?Te.split("\0"):[],j=new Set(o),F=`${c??""}:${E}:${e?"collapsed":"default"}`,A=fe.current!==F;fe.current=F,k(U=>{if(A){const pe=e?0:mn(o.length);return new Set(o.slice(0,pe))}let Le=!1;const De=new Set;for(const pe of U){if(!j.has(pe)){Le=!0;continue}De.add(pe)}return Le?De:U}),W(U=>{if(A)return new Set;let Le=!1;const De=new Set;for(const pe of U){if(!j.has(pe)){Le=!0;continue}De.add(pe)}return Le?De:U})},[E,Te,c,W,e]);const Me=r.useCallback(o=>{const j=K[o.path];if(j)return j;if(X==="inline")return"inline";if(X==="side-by-side")return"side-by-side";const F=h<hn;return o.isNew||F?"inline":"side-by-side"},[K,X,h]),gt=r.useMemo(()=>H.length===0?null:H.every(o=>Me(o)==="side-by-side")?"side-by-side":"inline",[H,Me]);r.useEffect(()=>{c&&(m(c),f(c,b))},[c,m,f,b]),r.useEffect(()=>{if(c)return Ot.onGitRefreshHint(o=>{Oe(o.directory)===Oe(c)&&(o.paths?.length&&(We.current=Be()??_e.current,$(c,o.paths),ue(j=>{const F=new Map(j);for(const A of o.paths??[])F.set(A,(F.get(A)??0)+1);return F})),P(c,b,{silent:!0}))})},[Be,$,c,P,b,_e,We]),r.useEffect(()=>{E!=="all"&&!Q||ee&&(Q&&I(Q),O(ee),y(Q==="staged"||!Q&&te),oe(null),Fe.current=!0,we.current=ee,je(ee),Z(o=>o+1))},[E,je,ee,Q,te,we,oe,Fe]),r.useEffect(()=>{if(E==="all")return;const o=d?.trim();o&&(O(o),y(E==="staged"),Fe.current=!0,we.current=o,je(o),Z(j=>j+1))},[E,je,we,Fe,d]),r.useEffect(()=>{if(!N)return;H.some(j=>j.path===N)||(O(null),y(!1))},[H,N]);const xt=r.useCallback((o,j)=>{ve(),k(F=>{const A=F.has(o);if(j===A)return F;const U=new Set(F);return j?U.add(o):U.delete(o),U}),W(F=>{const A=F.has(o);if(j===A)return F;const U=new Set(F);return j?U.add(o):U.delete(o),U}),Re()},[ve,Re,W]),bt=r.useCallback(()=>{ve(),k(o=>o.size>0?new Set:new Set(H.map(j=>j.path))),W(new Set),Re()},[ve,H,Re,W]),yt=r.useCallback(o=>{},[]),wt=r.useCallback(o=>{ve(),O(o),y(!1),Fe.current=!0,we.current=o,je(o),Z(j=>j+1),ze(o)},[ve,je,we,ze,Fe]),Ft=r.useCallback(o=>{const j=o==="side-by-side"?"side-by-side":"inline";H.forEach(F=>{ae(F.path,j)})},[H,ae]),{openingEditorFilePath:vt,openFileInEditorAtChange:jt}=jn({effectiveDirectory:c,activeDiffStaged:T,git:b,files:g,setDiff:M,openContextFileAtLine:xe});return{git:b,files:g,effectiveDirectory:c,screenWidth:h,isMobile:w,isGitRepo:D,status:x,isLoadingStatus:S,activeDiffScope:E,setActiveDiffScope:I,branchDiffs:se,branchDiffError:Ce,branchDiffLoading:q,diffWrapLines:Ne,setDiffWrapLines:de,forcedStaged:u,displayFileStaged:v,displayFile:N,pinnedStackedTarget:ht,expandedFiles:L,mountedStackedFiles:R,loadFullFiles:C,setLoadFullFiles:_,fileDiffRefreshNonce:me,showFileSidebar:ye,diffScrollRef:pt,lastTurnDiffData:ie,branchDiffData:G,changedFiles:H,workingFileCount:Ae,stagedFileCount:ct,turnFileCount:ut,allFileCount:dt,branchFileCount:ft,currentLayoutForAllFiles:gt,openingEditorFilePath:vt,registerSectionRef:mt,handleStackedEntryExpandedChange:xt,handleExpandOrCollapseAll:bt,handleSelectFile:yt,handleSelectFileAndScroll:wt,handleHeaderLayoutChange:Ft,openFileInEditorAtChange:jt,getLayoutForFile:Me}}const vs=({hideStackedFileSidebar:n=!1,stackedDefaultCollapsedAll:s=!1,pinSelectedFileHeaderToTopOnNavigate:e=!1,showOpenInEditorAction:i=!1,diffScope:a="all",onDiffScopeChange:l,branchBase:p=null,branchHead:d=null,targetFilePath:b=null,flushContent:g=!1,hideToolbar:c=!1,onHeaderControlsStateChange:h,toolbarSlot:w=null})=>{const{effectiveDirectory:D,isGitRepo:x,status:S,isLoadingStatus:m,activeDiffScope:f,setActiveDiffScope:P,branchDiffError:$,branchDiffLoading:M,diffWrapLines:N,setDiffWrapLines:O,forcedStaged:v,displayFileStaged:y,displayFile:L,pinnedStackedTarget:k,expandedFiles:R,mountedStackedFiles:W,loadFullFiles:C,setLoadFullFiles:_,fileDiffRefreshNonce:V,showFileSidebar:Z,diffScrollRef:me,lastTurnDiffData:ue,branchDiffData:E,changedFiles:I,workingFileCount:ee,stagedFileCount:te,turnFileCount:Q,allFileCount:oe,branchFileCount:X,currentLayoutForAllFiles:K,openingEditorFilePath:ae,registerSectionRef:J,handleStackedEntryExpandedChange:ge,handleExpandOrCollapseAll:de,handleSelectFile:xe,handleSelectFileAndScroll:be,handleHeaderLayoutChange:le,openFileInEditorAtChange:Ne,getLayoutForFile:u}=Sn({hideStackedFileSidebar:n,stackedDefaultCollapsedAll:s,pinSelectedFileHeaderToTopOnNavigate:e,diffScope:a,branchBase:p,branchHead:d,targetFilePath:b});r.useEffect(()=>{c&&l?.(f)},[f,c,l]);const T=r.useCallback(()=>{_(ie=>!ie)},[_]),ne=r.useCallback(()=>{O(!N)},[N,O]),ye=r.useCallback(()=>{le(K==="side-by-side"?"unified":"side-by-side")},[K,le]),fe=R.size,se=r.useMemo(()=>({turnCount:Q,branchCount:X,expandedCount:fe,totalCount:I.length,loadFullFiles:C,wrapLines:N,layoutMode:K,onExpandOrCollapseAll:de,onToggleLoadFullFiles:T,onToggleWrapLines:ne,onToggleLayout:ye}),[Q,X,fe,I.length,C,N,K,de,T,ne,ye]);r.useEffect(()=>{c&&h?.(se)},[c,se,h]);const Ce=()=>{if(!D)return null;const ie=G=>v!==null?v:y&&G===L;return t.jsxs("div",{className:re("flex min-w-0 flex-1 min-h-0 h-full",g?"gap-0":"gap-3 px-3 pb-3 pt-2"),children:[Z&&t.jsxs("section",{className:"hidden lg:flex w-72 flex-col rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:[t.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border/40",children:[t.jsx("span",{className:"typography-ui-header font-semibold text-foreground",children:"Files"}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:I.length})]}),t.jsx(on,{changedFiles:I,selectedFile:null,onSelectFile:be})]}),t.jsx("div",{className:"relative flex-1 min-w-0 min-h-0 h-full",children:t.jsxs(tt,{ref:me,outerClassName:"min-h-0 h-full",className:"[overflow-anchor:none]",disableHorizontal:!0,observeMutations:!1,preventOverscroll:!0,"data-diff-virtual-root":!0,children:[t.jsx("div",{className:"flex flex-col [overflow-anchor:none]","data-diff-virtual-content":!0,children:I.map(G=>t.jsx(pn,{directory:D,file:G,layout:u(G),wrapLines:N,isSelected:!1,isExpanded:R.has(G.path),isMounted:W.has(G.path)||G.path===k,onSelect:xe,onExpandedChange:ge,registerSectionRef:J,showOpenInEditorAction:i&&f!=="turn"&&f!=="branch",isOpeningInEditor:ae===G.path,onOpenInEditor:(H,Ae)=>{Ne(H,Ae)},staged:ie(G.path),showFileActions:f!=="turn"&&f!=="branch",loadFullFiles:C,initialDiffData:f==="turn"?ue.get(G.path)??null:f==="branch"?E.get(G.path)??null:null},`${G.path}:${V.get(G.path)??0}`))}),t.jsx("div",{"aria-hidden":"true",className:"h-16 shrink-0"})]})})]})},q=()=>D?f!=="turn"&&m&&!S?t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[t.jsx(z,{name:"loader-4",className:"size-4 animate-spin"}),"Loading repository status..."]}):f!=="turn"&&f!=="branch"&&x===!1?t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:"Not a git repository. Use the Git tab to initialize or change directories."}):f==="branch"&&M?t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[t.jsx(z,{name:"loader-4",className:"size-4 animate-spin"}),"Loading branch changes..."]}):f==="branch"&&$?t.jsx("div",{className:"flex flex-1 items-center justify-center px-4 text-center text-sm text-muted-foreground",children:`Failed to load branch changes: ${$}`}):I.length===0?t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:f==="turn"?"No last turn changes to display":"Working tree clean, no changes to display"}):Ce():t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:"Select a session directory to view diffs"}),B=t.jsxs("div",{className:w?"flex min-w-0 flex-1 items-center gap-1.5":"@container/diff-toolbar flex min-w-0 items-center gap-2 px-3 py-2 bg-background",children:[(x!==!1||f==="turn")&&(f==="all"||f==="working"||f==="staged"||f==="turn"||f==="branch")?t.jsx(Kt,{scope:f,isGitRepo:x,branchAvailable:!!(p&&d),allCount:oe,workingCount:ee,stagedCount:te,turnCount:Q,branchCount:X,onScopeChange:ie=>{P(ie),l?.(ie)}}):t.jsx("div",{className:"flex items-center gap-1 rounded-md px-2 py-1 text-muted-foreground shrink-0",children:t.jsx("span",{className:"typography-ui-label font-medium text-foreground",children:m&&!S?"Loading changes...":I.length===1?`${I.length} file changed`:`${I.length} files changed`})}),I.length>0&&t.jsxs(Se,{variant:"ghost",size:"sm",onClick:de,className:re("diff-toolbar__expand-button h-7 flex-shrink-0 gap-1 px-1.5 text-muted-foreground hover:text-foreground","ml-auto"),title:R.size>0?"Collapse all":"Expand all",children:[t.jsx(z,{name:"expand-up-down",className:"size-4"}),t.jsx("span",{className:"diff-toolbar__expand-label typography-ui-label",children:R.size>0?"Collapse all":"Expand all"})]}),I.length>0&&f!=="turn"&&f!=="branch"&&t.jsxs(Gt,{children:[t.jsx(Ht,{asChild:!0,children:t.jsx(Se,{variant:"ghost",size:"sm",onClick:()=>_(ie=>!ie),"aria-pressed":C,"aria-label":C?"Unload full files":"Load full files",className:re("h-7 w-7 flex-shrink-0 p-0 text-muted-foreground hover:text-foreground",C&&"bg-interactive-selection text-interactive-selection-foreground"),children:t.jsx(z,{name:"file-download",className:"size-4"})})}),t.jsx(Ut,{children:t.jsx("p",{children:C?"Unload full files":"Load full files"})})]}),I.length>0&&t.jsx(Se,{variant:"ghost",size:"sm",onClick:()=>O(!N),className:re("h-5 w-5 p-0 transition-opacity",N?"text-foreground opacity-100":"text-muted-foreground opacity-60 hover:opacity-100"),title:N?"Disable line wrap":"Enable line wrap",children:t.jsx(z,{name:"text-wrap",className:"size-4"})}),K&&t.jsx(rt,{mode:K==="side-by-side"?"side-by-side":"unified",onModeChange:le})]});return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background",children:[w?St.createPortal(B,w):c?null:B,q()]})};export{vs as DiffView};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{k as r}from"./vendor-boot-EC6IyLt1.js";import{R as a}from"./vendor-react-DASdDPIk.js";import{D as j}from"./vendor-react-drawio-Duu5LgQA.js";import{e as C}from"./index-D4n3TVp2.js";import{au as E,av as S,aw as N,ax as B,ay as F,az as H,B as p}from"./useAppFontEffects-CqHhRKmN.js";const A='<mxfile><diagram id="new" name="Page-1"><mxGraphModel dx="0" dy="0" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0"><root><mxCell id="0"/><mxCell id="1" parent="0"/></root></mxGraphModel></diagram></mxfile>';function w(){if(typeof document>"u")return!1;const t=document.documentElement.getAttribute("data-theme");return t==="dark"||!t&&window.matchMedia("(prefers-color-scheme: dark)").matches}const T=a.forwardRef(function({xml:e,readOnly:s,className:d,onChange:u},m){const l=a.useRef(e),c=a.useRef(null),i=a.useRef(!1),[o,y]=a.useState(w),f=a.useRef(e),h=a.useRef(e);h.current!==e&&(h.current=e,f.current=e,l.current=e);const v=a.useRef(o);v.current!==o&&(v.current=o,f.current=l.current);const g=a.useRef(null);a.useEffect(()=>{const n=()=>y(w());n();const x=new MutationObserver(n);return x.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>x.disconnect()},[]),a.useEffect(()=>{const n=setTimeout(()=>{g.current?.querySelector(".diagrams-iframe")?.focus()},600);return()=>clearTimeout(n)},[]),a.useImperativeHandle(m,()=>({getXml:()=>l.current}));const R=a.useCallback(()=>{!e&&!i.current&&(i.current=!0,setTimeout(()=>{c.current?.template({})},500))},[e]),D=a.useCallback(n=>{l.current=n.xml,u?.(n.xml)},[u]);return r.jsx("div",{ref:g,className:C("h-full w-full",d),children:r.jsx(j,{ref:c,xml:f.current||A,autosave:!0,urlParameters:{ui:s?"simple":o?"dark":"kennedy",spin:!0,libraries:!s,chrome:s,nav:s,layers:s,noSaveBtn:!0,noExitBtn:!0,saveAndExit:!1},onLoad:R,onAutoSave:D},o?"dark":"light")})}),X=(t,e)=>!t||t.runtimeKey!==e.runtimeKey||t.root!==e.root||t.path!==e.path||t.generation!==e.generation,b=t=>{if(typeof t=="string")return t;if(t===null)return null},G=(t,e)=>{if(e===!0)return t!==void 0?{expectedRevision:b(t),overwrite:!0}:{overwrite:!0};if(t!==void 0)return{expectedRevision:b(t)}},W=(t,e)=>!!(t&&e&&t.runtimeKey===e.runtimeKey&&t.root===e.root&&t.path===e.path&&t.generation===e.generation),k=(t,e=4e3)=>t.length>e?`${t.slice(0,e)}
|
|
2
|
-
|
|
3
|
-
… truncated …`:t,Y=({open:t,conflict:e,isResolving:s,showCompare:d,onToggleCompare:u,onReload:m,onOverwrite:l,onClose:c})=>{if(!e)return null;const i=!e.exists;return r.jsx(E,{open:t,onOpenChange:o=>{o||c()},children:r.jsxs(S,{showCloseButton:!1,className:"max-w-lg",children:[r.jsxs(N,{children:[r.jsx(B,{children:i?"File deleted on disk":"File changed on disk"}),r.jsx(F,{children:i?`“${e.displayPath}” was deleted since you opened it. Your edits are preserved. Reload to discard them, or overwrite to recreate the file.`:`“${e.displayPath}” changed since you opened it. Your edits are preserved. Reload to discard them and load the current version, or overwrite to keep your edits.`})]}),d&&!i?r.jsxs("div",{className:"grid max-h-64 grid-cols-1 gap-2 overflow-auto py-2",children:[r.jsxs("div",{children:[r.jsx("div",{className:"typography-meta text-muted-foreground",children:"Current version on disk"}),r.jsx("pre",{className:"mt-1 max-h-28 overflow-auto rounded-md bg-[var(--surface-subtle)] p-2 text-xs whitespace-pre-wrap break-words",children:k(e.currentContent??"")})]}),r.jsxs("div",{children:[r.jsx("div",{className:"typography-meta text-muted-foreground",children:"Your edits"}),r.jsx("pre",{className:"mt-1 max-h-28 overflow-auto rounded-md bg-[var(--surface-subtle)] p-2 text-xs whitespace-pre-wrap break-words",children:k(e.dirtyContent)})]})]}):null,r.jsxs(H,{className:"flex flex-wrap gap-2",children:[i?null:r.jsx(p,{variant:"outline",onClick:u,disabled:s,"aria-label":d?"Hide version comparison":"Compare versions",title:d?"Hide version comparison":"Compare versions",children:d?"Hide compare":"Compare"}),r.jsx(p,{variant:"outline",onClick:m,disabled:s,"aria-label":i?"Discard edits and close":"Reload current version",title:i?"Discard edits and close":"Reload current version",children:i?"Discard edits":"Reload"}),r.jsx(p,{variant:"destructive",onClick:l,disabled:s,"aria-label":i?"Recreate file with my edits":"Overwrite with my edits",title:i?"Recreate file with my edits":"Overwrite with my edits",children:s?"Working…":"Overwrite"})]})]})})};export{T as D,Y as F,G as b,W as i,X as s};
|