@hienlh/ppm 0.23.8 → 0.23.10
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/CHANGELOG.md +16 -0
- package/CLAUDE.md +4 -0
- package/assets/skills/ppm/SKILL.md +1 -1
- package/assets/skills/ppm/references/cli-reference.md +4 -4
- package/assets/skills/ppm/references/http-api.md +1 -1
- package/dist/web/assets/accounts-settings-section-BOBJbG7i.js +1 -0
- package/dist/web/assets/accounts-settings-section-BOBJbG7i.js.br +0 -0
- package/dist/web/assets/accounts-settings-section-BOBJbG7i.js.gz +0 -0
- package/dist/web/assets/agent-session-sheet-CjD4hBZV.js +2 -0
- package/dist/web/assets/agent-session-sheet-CjD4hBZV.js.br +0 -0
- package/dist/web/assets/agent-session-sheet-CjD4hBZV.js.gz +0 -0
- package/dist/web/assets/agent-session-sheet-store-BcQbnaV2.js +1 -0
- package/dist/web/assets/agent-session-window-content-Drm1HsSn.js +1 -0
- package/dist/web/assets/agent-session-window-content-Drm1HsSn.js.br +0 -0
- package/dist/web/assets/agent-session-window-content-Drm1HsSn.js.gz +0 -0
- package/dist/web/assets/{ai-resource-editor-DfVRMUHS.js → ai-resource-editor-M1Eax2Hc.js} +1 -1
- package/dist/web/assets/ai-resource-editor-M1Eax2Hc.js.br +0 -0
- package/dist/web/assets/ai-resource-editor-M1Eax2Hc.js.gz +0 -0
- package/dist/web/assets/ai-settings-section-B73t9SXm.js +1 -0
- package/dist/web/assets/{ai-settings-section-Ezhw4Fef.js → ai-settings-section-H173dm1k.js} +1 -1
- package/dist/web/assets/ai-settings-section-H173dm1k.js.br +0 -0
- package/dist/web/assets/ai-settings-section-H173dm1k.js.gz +0 -0
- package/dist/web/assets/{api-settings-tYKJ5Fqk.js → api-settings-BA_n8cPt.js} +1 -1
- package/dist/web/assets/{appearance-settings-section-CPOAp0fY.js → appearance-settings-section-Dqu20pt8.js} +1 -1
- package/dist/web/assets/appearance-settings-section-Dqu20pt8.js.br +0 -0
- package/dist/web/assets/appearance-settings-section-Dqu20pt8.js.gz +0 -0
- package/dist/web/assets/{apps-panel-Cz7_o-M4.js → apps-panel-mkrzY7K0.js} +1 -1
- package/dist/web/assets/apps-panel-mkrzY7K0.js.br +0 -0
- package/dist/web/assets/apps-panel-mkrzY7K0.js.gz +0 -0
- package/dist/web/assets/branch-review-tab-Dw3bNixU.js +1 -0
- package/dist/web/assets/branch-review-tab-Dw3bNixU.js.br +0 -0
- package/dist/web/assets/branch-review-tab-Dw3bNixU.js.gz +0 -0
- package/dist/web/assets/chat-tab-BAbcVFzD.js +15 -0
- package/dist/web/assets/chat-tab-BAbcVFzD.js.br +0 -0
- package/dist/web/assets/chat-tab-BAbcVFzD.js.gz +0 -0
- package/dist/web/assets/chat-tab-BaXGaBEC.js +1 -0
- package/dist/web/assets/chat-tab-BaXGaBEC.js.br +4 -0
- package/dist/web/assets/chat-tab-BaXGaBEC.js.gz +0 -0
- package/dist/web/assets/code-editor-CXLANXnI.js +7 -0
- package/dist/web/assets/code-editor-CXLANXnI.js.br +0 -0
- package/dist/web/assets/code-editor-CXLANXnI.js.gz +0 -0
- package/dist/web/assets/{codex-reset-credit-button-D2hal4bG.js → codex-reset-credit-button-CB8Dfhki.js} +1 -1
- package/dist/web/assets/codex-reset-credit-button-CB8Dfhki.js.br +0 -0
- package/dist/web/assets/codex-reset-credit-button-CB8Dfhki.js.gz +0 -0
- package/dist/web/assets/{conflict-editor-Cj_gUncw.js → conflict-editor-CKsxIw3v.js} +2 -2
- package/dist/web/assets/conflict-editor-CKsxIw3v.js.br +0 -0
- package/dist/web/assets/conflict-editor-CKsxIw3v.js.gz +0 -0
- package/dist/web/assets/{csv-preview-Be3ODNj0.js → csv-preview-U0v_r_-7.js} +1 -1
- package/dist/web/assets/csv-preview-U0v_r_-7.js.br +0 -0
- package/dist/web/assets/csv-preview-U0v_r_-7.js.gz +0 -0
- package/dist/web/assets/{database-viewer-B1b--4y8.js → database-viewer-xQyUcBoL.js} +1 -1
- package/dist/web/assets/database-viewer-xQyUcBoL.js.br +0 -0
- package/dist/web/assets/database-viewer-xQyUcBoL.js.gz +0 -0
- package/dist/web/assets/{design-tab-8wi0IHss.js → design-tab-aaAt2_QE.js} +4 -4
- package/dist/web/assets/design-tab-aaAt2_QE.js.br +0 -0
- package/dist/web/assets/design-tab-aaAt2_QE.js.gz +0 -0
- package/dist/web/assets/{designs-sidebar-panel-D5-1Q8zQ.js → designs-sidebar-panel-CTzO4Thu.js} +1 -1
- package/dist/web/assets/designs-sidebar-panel-CTzO4Thu.js.br +0 -0
- package/dist/web/assets/designs-sidebar-panel-CTzO4Thu.js.gz +0 -0
- package/dist/web/assets/{diff-viewer-Dcxk6UTG.js → diff-viewer-CSE2-OE7.js} +1 -1
- package/dist/web/assets/diff-viewer-CSE2-OE7.js.br +0 -0
- package/dist/web/assets/diff-viewer-CSE2-OE7.js.gz +0 -0
- package/dist/web/assets/{edit-diff-preview-DxDAtYhi.js → edit-diff-preview-gH6pRk4S.js} +1 -1
- package/dist/web/assets/edit-diff-preview-gH6pRk4S.js.br +0 -0
- package/dist/web/assets/{edit-diff-preview-DxDAtYhi.js.gz → edit-diff-preview-gH6pRk4S.js.gz} +0 -0
- package/dist/web/assets/{editor-language-service-BVJQnTSV.js → editor-language-service-CYl04pUy.js} +1 -1
- package/dist/web/assets/editor-language-service-CYl04pUy.js.br +0 -0
- package/dist/web/assets/editor-language-service-CYl04pUy.js.gz +0 -0
- package/dist/web/assets/explorer-body-BBOcvwmV.js +2 -0
- package/dist/web/assets/explorer-body-BBOcvwmV.js.br +0 -0
- package/dist/web/assets/explorer-body-BBOcvwmV.js.gz +0 -0
- package/dist/web/assets/{explorer-window-content-DH5AD3Ng.js → explorer-window-content-juCGcrkc.js} +1 -1
- package/dist/web/assets/explorer-window-content-juCGcrkc.js.br +0 -0
- package/dist/web/assets/explorer-window-content-juCGcrkc.js.gz +0 -0
- package/dist/web/assets/{extension-manager-section-BJr6ccWw.js → extension-manager-section-poMRmwvg.js} +1 -1
- package/dist/web/assets/extension-manager-section-poMRmwvg.js.br +0 -0
- package/dist/web/assets/extension-manager-section-poMRmwvg.js.gz +0 -0
- package/dist/web/assets/{extension-webview-CYNXHd8D.js → extension-webview-0QfzTI6s.js} +1 -1
- package/dist/web/assets/extension-webview-0QfzTI6s.js.br +0 -0
- package/dist/web/assets/extension-webview-0QfzTI6s.js.gz +0 -0
- package/dist/web/assets/{files-settings-section-JX7o4lex.js → files-settings-section-DJptxRgH.js} +1 -1
- package/dist/web/assets/files-settings-section-DJptxRgH.js.br +0 -0
- package/dist/web/assets/files-settings-section-DJptxRgH.js.gz +0 -0
- package/dist/web/assets/{general-settings-section-kF94Mz5q.js → general-settings-section-BFNbdDNv.js} +1 -1
- package/dist/web/assets/general-settings-section-BFNbdDNv.js.br +0 -0
- package/dist/web/assets/general-settings-section-BFNbdDNv.js.gz +0 -0
- package/dist/web/assets/{git-log-panel-Crlp9ofM.js → git-log-panel-SMMIbjSe.js} +1 -1
- package/dist/web/assets/git-log-panel-SMMIbjSe.js.br +0 -0
- package/dist/web/assets/git-log-panel-SMMIbjSe.js.gz +0 -0
- package/dist/web/assets/{glide-data-grid-O6MO5dKU.js → glide-data-grid-DZVmgu0T.js} +3 -3
- package/dist/web/assets/glide-data-grid-DZVmgu0T.js.br +0 -0
- package/dist/web/assets/glide-data-grid-DZVmgu0T.js.gz +0 -0
- package/dist/web/assets/group-chat-tab-d_aaYuK_.js +1 -0
- package/dist/web/assets/group-chat-tab-d_aaYuK_.js.br +0 -0
- package/dist/web/assets/group-chat-tab-d_aaYuK_.js.gz +0 -0
- package/dist/web/assets/{index-DQCw6d-2.js → index-CIscPw4g.js} +6 -6
- package/dist/web/assets/index-CIscPw4g.js.br +0 -0
- package/dist/web/assets/index-CIscPw4g.js.gz +0 -0
- package/dist/web/assets/{jira-watcher-section-DwM7gqHT.js → jira-watcher-section-CsbhnLLn.js} +1 -1
- package/dist/web/assets/keybindings-store-BPs0pM0r.js +1 -0
- package/dist/web/assets/{keyboard-shortcuts-section-CewWGwiF.js → keyboard-shortcuts-section-CXqc2OtM.js} +1 -1
- package/dist/web/assets/keyboard-shortcuts-section-CXqc2OtM.js.br +0 -0
- package/dist/web/assets/keyboard-shortcuts-section-CXqc2OtM.js.gz +0 -0
- package/dist/web/assets/{language-servers-section-nricdxke.js → language-servers-section-B4FsBVvZ.js} +2 -2
- package/dist/web/assets/language-servers-section-B4FsBVvZ.js.br +0 -0
- package/dist/web/assets/language-servers-section-B4FsBVvZ.js.gz +0 -0
- package/dist/web/assets/{lsp-client-DRMEWb-z.js → lsp-client-MQ4mjDfT.js} +1 -1
- package/dist/web/assets/lsp-client-MQ4mjDfT.js.br +0 -0
- package/dist/web/assets/lsp-client-MQ4mjDfT.js.gz +0 -0
- package/dist/web/assets/markdown-renderer-BvCZZlue.js +1 -0
- package/dist/web/assets/{markdown-renderer-Dab9Us6u.js → markdown-renderer-CjPb5pns.js} +3 -3
- package/dist/web/assets/markdown-renderer-CjPb5pns.js.br +0 -0
- package/dist/web/assets/markdown-renderer-CjPb5pns.js.gz +0 -0
- package/dist/web/assets/{mobile-explorer-sheet-DtgdpvJ9.js → mobile-explorer-sheet-0aGhVQtI.js} +1 -1
- package/dist/web/assets/mobile-explorer-sheet-0aGhVQtI.js.br +0 -0
- package/dist/web/assets/mobile-explorer-sheet-0aGhVQtI.js.gz +0 -0
- package/dist/web/assets/{new-design-dialog-Dd5KDB_p.js → new-design-dialog-2oT2oc_F.js} +1 -1
- package/dist/web/assets/new-design-dialog-2oT2oc_F.js.br +0 -0
- package/dist/web/assets/new-design-dialog-2oT2oc_F.js.gz +0 -0
- package/dist/web/assets/notification-store-Dd25PMPQ.js +1 -0
- package/dist/web/assets/{panel-store-DrSH3Nhp.js → panel-store-1X6yM3XZ.js} +1 -1
- package/dist/web/assets/panel-store-1X6yM3XZ.js.br +0 -0
- package/dist/web/assets/panel-store-1X6yM3XZ.js.gz +0 -0
- package/dist/web/assets/performance-panel-Ub96qrEH.js +3 -0
- package/dist/web/assets/performance-panel-Ub96qrEH.js.br +0 -0
- package/dist/web/assets/performance-panel-Ub96qrEH.js.gz +0 -0
- package/dist/web/assets/{ppmbot-settings-section-D67u6gPi.js → ppmbot-settings-section-CPMGP66g.js} +1 -1
- package/dist/web/assets/ppmbot-settings-section-CPMGP66g.js.br +0 -0
- package/dist/web/assets/ppmbot-settings-section-CPMGP66g.js.gz +0 -0
- package/dist/web/assets/{problems-panel-DKgIw4uZ.js → problems-panel-CWwzZIP3.js} +1 -1
- package/dist/web/assets/problems-panel-CWwzZIP3.js.br +0 -0
- package/dist/web/assets/problems-panel-CWwzZIP3.js.gz +0 -0
- package/dist/web/assets/process-table-BwPws3zS.js +1 -0
- package/dist/web/assets/process-table-BwPws3zS.js.br +0 -0
- package/dist/web/assets/process-table-BwPws3zS.js.gz +0 -0
- package/dist/web/assets/{proxy-settings-section-CFiYcTBA.js → proxy-settings-section-nS8VbxI_.js} +1 -1
- package/dist/web/assets/proxy-settings-section-nS8VbxI_.js.br +0 -0
- package/dist/web/assets/proxy-settings-section-nS8VbxI_.js.gz +0 -0
- package/dist/web/assets/{query-audit-section-BybgiPsc.js → query-audit-section-Dv5Pxn-w.js} +1 -1
- package/dist/web/assets/query-audit-section-Dv5Pxn-w.js.br +0 -0
- package/dist/web/assets/query-audit-section-Dv5Pxn-w.js.gz +0 -0
- package/dist/web/assets/{remote-desktop-clipboard-notice-Bs3fZSRw.js → remote-desktop-clipboard-notice-DEbdu0hC.js} +1 -1
- package/dist/web/assets/remote-desktop-clipboard-notice-DEbdu0hC.js.br +0 -0
- package/dist/web/assets/remote-desktop-clipboard-notice-DEbdu0hC.js.gz +0 -0
- package/dist/web/assets/remote-desktop-mobile-sheet-BJm-akVY.js +2 -0
- package/dist/web/assets/remote-desktop-mobile-sheet-BJm-akVY.js.br +0 -0
- package/dist/web/assets/remote-desktop-mobile-sheet-BJm-akVY.js.gz +0 -0
- package/dist/web/assets/{remote-desktop-mobile-view-DgGOfPVY.js → remote-desktop-mobile-view-DPdGFD6C.js} +1 -1
- package/dist/web/assets/remote-desktop-mobile-view-DPdGFD6C.js.br +0 -0
- package/dist/web/assets/remote-desktop-mobile-view-DPdGFD6C.js.gz +0 -0
- package/dist/web/assets/{remote-desktop-readiness-gate-DOWryrQx.js → remote-desktop-readiness-gate-DV7YgSpP.js} +1 -1
- package/dist/web/assets/remote-desktop-readiness-gate-DV7YgSpP.js.br +0 -0
- package/dist/web/assets/remote-desktop-readiness-gate-DV7YgSpP.js.gz +0 -0
- package/dist/web/assets/remote-desktop-window-content-BktcWMjD.js +1 -0
- package/dist/web/assets/remote-desktop-window-content-BktcWMjD.js.br +0 -0
- package/dist/web/assets/remote-desktop-window-content-BktcWMjD.js.gz +0 -0
- package/dist/web/assets/{run-in-terminal-Cdn9PaAl.js → run-in-terminal-B_PCeBqG.js} +1 -1
- package/dist/web/assets/{schedules-settings-section-DGhG-b5O.js → schedules-settings-section-B3HYKSVh.js} +1 -1
- package/dist/web/assets/schedules-settings-section-B3HYKSVh.js.br +0 -0
- package/dist/web/assets/schedules-settings-section-B3HYKSVh.js.gz +0 -0
- package/dist/web/assets/{send-to-chat-B09VjsB5.js → send-to-chat-Bjg6c8Ld.js} +1 -1
- package/dist/web/assets/send-to-chat-Bjg6c8Ld.js.br +0 -0
- package/dist/web/assets/send-to-chat-Bjg6c8Ld.js.gz +0 -0
- package/dist/web/assets/{services-panel-0klE3O4g.js → services-panel-D6k6AVS4.js} +1 -1
- package/dist/web/assets/services-panel-D6k6AVS4.js.br +0 -0
- package/dist/web/assets/services-panel-D6k6AVS4.js.gz +0 -0
- package/dist/web/assets/{settings-body-CfqpqFfq.js → settings-body-Cu0mNA5x.js} +2 -2
- package/dist/web/assets/settings-body-Cu0mNA5x.js.br +0 -0
- package/dist/web/assets/settings-body-Cu0mNA5x.js.gz +0 -0
- package/dist/web/assets/{settings-store-3jIBB8gx.js → settings-store-DIV25PM_.js} +2 -2
- package/dist/web/assets/settings-store-DIV25PM_.js.br +0 -0
- package/dist/web/assets/settings-store-DIV25PM_.js.gz +0 -0
- package/dist/web/assets/{settings-tab-CHweH5Nh.js → settings-tab-C-A6RNQ3.js} +1 -1
- package/dist/web/assets/{settings-window-content-C6Od3qV7.js → settings-window-content-48e5FJAq.js} +1 -1
- package/dist/web/assets/{sql-query-editor-ALQ5_X0j.js → sql-query-editor-CgGWYu9K.js} +1 -1
- package/dist/web/assets/sql-query-editor-CgGWYu9K.js.br +0 -0
- package/dist/web/assets/sql-query-editor-CgGWYu9K.js.gz +0 -0
- package/dist/web/assets/{sqlite-viewer-DKTty_jR.js → sqlite-viewer-Co1Oi3dv.js} +1 -1
- package/dist/web/assets/sqlite-viewer-Co1Oi3dv.js.br +0 -0
- package/dist/web/assets/sqlite-viewer-Co1Oi3dv.js.gz +0 -0
- package/dist/web/assets/{system-monitor-body-D6J6lq7-.js → system-monitor-body-DxPKVa-W.js} +2 -2
- package/dist/web/assets/system-monitor-body-DxPKVa-W.js.br +0 -0
- package/dist/web/assets/system-monitor-body-DxPKVa-W.js.gz +0 -0
- package/dist/web/assets/system-monitor-tab-4miOZuQQ.js +1 -0
- package/dist/web/assets/{system-monitor-window-content-D1t30f32.js → system-monitor-window-content-B-A7DdML.js} +1 -1
- package/dist/web/assets/{tab-host-window-content-DTcx2D0O.js → tab-host-window-content-CChcpg1v.js} +1 -1
- package/dist/web/assets/tab-host-window-content-CChcpg1v.js.br +0 -0
- package/dist/web/assets/tab-host-window-content-CChcpg1v.js.gz +0 -0
- package/dist/web/assets/{tab-store-CUPgQIQz.js → tab-store-D33icgdA.js} +1 -1
- package/dist/web/assets/{terminal-tab-DgTfQKBI.js → terminal-tab-BDqlyBLK.js} +2 -2
- package/dist/web/assets/terminal-tab-BDqlyBLK.js.br +0 -0
- package/dist/web/assets/terminal-tab-BDqlyBLK.js.gz +0 -0
- package/dist/web/assets/tool-cards-iJ8tyrLq.js +9 -0
- package/dist/web/assets/tool-cards-iJ8tyrLq.js.br +0 -0
- package/dist/web/assets/tool-cards-iJ8tyrLq.js.gz +0 -0
- package/dist/web/assets/{use-inline-blame-Dv111BKY.js → use-inline-blame-D9js570a.js} +4 -4
- package/dist/web/assets/use-inline-blame-D9js570a.js.br +0 -0
- package/dist/web/assets/use-inline-blame-D9js570a.js.gz +0 -0
- package/dist/web/assets/{use-lsp-CZTFJIXX.js → use-lsp-BYtylZId.js} +1 -1
- package/dist/web/assets/use-lsp-BYtylZId.js.br +0 -0
- package/dist/web/assets/use-lsp-BYtylZId.js.gz +0 -0
- package/dist/web/assets/{use-monaco-theme-DL2dIG5L.js → use-monaco-theme-DJ8y_7IZ.js} +1 -1
- package/dist/web/assets/{use-process-kill-D7D9QvJG.js → use-process-kill-BS84S-kD.js} +1 -1
- package/dist/web/assets/use-process-kill-BS84S-kD.js.br +0 -0
- package/dist/web/assets/use-process-kill-BS84S-kD.js.gz +0 -0
- package/dist/web/assets/{use-websocket-ziY-Gz_B.js → use-websocket-Mqj27umG.js} +1 -1
- package/dist/web/assets/{video-preview-DzwY3q9W.js → video-preview-BuzUAIma.js} +1 -1
- package/dist/web/assets/video-preview-BuzUAIma.js.br +0 -0
- package/dist/web/assets/video-preview-BuzUAIma.js.gz +0 -0
- package/dist/web/assets/{voice-settings-section-B7zMHsuz.js → voice-settings-section-DnwQjBbw.js} +1 -1
- package/dist/web/assets/voice-settings-section-DnwQjBbw.js.br +0 -0
- package/dist/web/assets/voice-settings-section-DnwQjBbw.js.gz +0 -0
- package/dist/web/assets/{window-pip-registry-dxrBFfkP.js → window-pip-registry-Bl--fK8-.js} +1 -1
- package/dist/web/assets/window-store-vo1N70nK.js +1 -0
- package/dist/web/assets/window-store-vo1N70nK.js.br +0 -0
- package/dist/web/assets/window-store-vo1N70nK.js.gz +0 -0
- package/dist/web/index.html +6 -6
- package/dist/web/index.html.br +0 -0
- package/dist/web/index.html.gz +0 -0
- package/dist/web/sw.js +1 -1
- package/dist/web/sw.js.br +0 -0
- package/dist/web/sw.js.gz +0 -0
- package/docs/architecture/ai-chat-and-providers.md +66 -0
- package/docs/architecture/workspace-and-ui.md +15 -3
- package/docs/design-guidelines.md +6 -1
- package/package.json +1 -1
- package/src/providers/codex-app-server/codex-history.ts +4 -4
- package/src/providers/codex-app-server/codex-provider.ts +1 -1
- package/src/providers/codex-app-server/codex-rollout-tail-parser.ts +203 -0
- package/src/providers/codex-app-server/codex-subagent-thread.ts +7 -1
- package/src/server/index.ts +7 -2
- package/src/server/routes/chat.ts +12 -4
- package/src/server/ws/global.ts +19 -3
- package/src/services/agent-transcript/agent-transcript-activity.ts +72 -0
- package/src/services/agent-transcript/agent-transcript-codex-activity.ts +161 -0
- package/src/services/agent-transcript/agent-transcript-codex-tail-cache.ts +85 -0
- package/src/services/agent-transcript/agent-transcript-envelope.ts +86 -0
- package/src/services/agent-transcript/agent-transcript-error-map.ts +33 -0
- package/src/services/agent-transcript/agent-transcript-file-tail-feed.ts +180 -0
- package/src/services/agent-transcript/agent-transcript-file-tail-state.ts +100 -0
- package/src/services/agent-transcript/agent-transcript-fs-io.ts +79 -0
- package/src/services/agent-transcript/agent-transcript-hub-clock.ts +37 -0
- package/src/services/agent-transcript/agent-transcript-hub-registry.ts +153 -0
- package/src/services/agent-transcript/agent-transcript-hub.ts +103 -0
- package/src/services/agent-transcript/agent-transcript-index-cache.ts +85 -0
- package/src/services/agent-transcript/agent-transcript-session-hub-activity.ts +103 -0
- package/src/services/agent-transcript/agent-transcript-session-hub-read.ts +194 -0
- package/src/services/agent-transcript/agent-transcript-session-hub-types.ts +81 -0
- package/src/services/agent-transcript/agent-transcript-session-hub.ts +196 -0
- package/src/services/agent-transcript/agent-transcript-sources.ts +199 -0
- package/src/services/agent-transcript/agent-transcript-ws-like.ts +19 -0
- package/src/services/agent-transcript/claude-projects-root.ts +21 -0
- package/src/services/agent-transcript/session-ownership.ts +152 -0
- package/src/services/nested-subagent-spy.ts +3 -3
- package/src/services/subagent-transcript-merger.ts +21 -7
- package/src/shared/agent-transcript-protocol.ts +158 -0
- package/src/types/chat.ts +27 -3
- package/src/web/app.tsx +5 -5
- package/src/web/components/chat/agent-card-summary.tsx +73 -0
- package/src/web/components/chat/agent-session-context.ts +34 -0
- package/src/web/components/chat/agent-session-fallback-store.ts +60 -0
- package/src/web/components/chat/agent-session-sheet-store.ts +23 -0
- package/src/web/components/chat/{team-member-sheet.tsx → agent-session-sheet.tsx} +12 -12
- package/src/web/components/chat/agent-session-window-content.tsx +133 -0
- package/src/web/components/chat/chat-history-bar.tsx +1 -0
- package/src/web/components/chat/chat-tab.tsx +21 -4
- package/src/web/components/chat/codex-usage-panel.tsx +26 -8
- package/src/web/components/chat/running-agents-bar.tsx +93 -0
- package/src/web/components/chat/team-activity-panel.tsx +19 -5
- package/src/web/components/chat/tool-cards.tsx +73 -4
- package/src/web/components/chat/use-open-agent-session.ts +83 -0
- package/src/web/components/floating-window/window-content-registry.ts +4 -5
- package/src/web/components/floating-window/window-geometry.ts +18 -0
- package/src/web/components/floating-window/window-persistence.ts +5 -4
- package/src/web/components/floating-window/window-store-types.ts +1 -1
- package/src/web/components/settings/resolve-open-settings-action.ts +1 -1
- package/src/web/components/system/resolve-open-system-monitor-action.ts +1 -1
- package/src/web/hooks/use-agent-activity.ts +65 -0
- package/src/web/hooks/use-agent-session-stream.ts +134 -0
- package/src/web/hooks/use-chat.ts +12 -18
- package/src/web/hooks/use-global-events.ts +35 -2
- package/src/web/lib/agent-session-stream-merge.ts +48 -0
- package/src/web/lib/agent-step-summary.ts +331 -0
- package/src/web/lib/global-ws-channel.ts +41 -0
- package/src/web/lib/running-agent-rows.ts +115 -0
- package/dist/web/assets/accounts-settings-section-BNcPvEq1.js +0 -1
- package/dist/web/assets/accounts-settings-section-BNcPvEq1.js.br +0 -0
- package/dist/web/assets/accounts-settings-section-BNcPvEq1.js.gz +0 -0
- package/dist/web/assets/ai-resource-editor-DfVRMUHS.js.br +0 -0
- package/dist/web/assets/ai-resource-editor-DfVRMUHS.js.gz +0 -0
- package/dist/web/assets/ai-settings-section-B_0-P8jx.js +0 -1
- package/dist/web/assets/ai-settings-section-Ezhw4Fef.js.br +0 -0
- package/dist/web/assets/ai-settings-section-Ezhw4Fef.js.gz +0 -0
- package/dist/web/assets/appearance-settings-section-CPOAp0fY.js.br +0 -0
- package/dist/web/assets/appearance-settings-section-CPOAp0fY.js.gz +0 -0
- package/dist/web/assets/apps-panel-Cz7_o-M4.js.br +0 -0
- package/dist/web/assets/apps-panel-Cz7_o-M4.js.gz +0 -0
- package/dist/web/assets/branch-review-tab-BPx3kHrM.js +0 -1
- package/dist/web/assets/branch-review-tab-BPx3kHrM.js.br +0 -0
- package/dist/web/assets/branch-review-tab-BPx3kHrM.js.gz +0 -0
- package/dist/web/assets/chat-tab-BadDM_j8.js +0 -1
- package/dist/web/assets/chat-tab-BadDM_j8.js.br +0 -0
- package/dist/web/assets/chat-tab-BadDM_j8.js.gz +0 -0
- package/dist/web/assets/chat-tab-IqAY4c7p.js +0 -15
- package/dist/web/assets/chat-tab-IqAY4c7p.js.br +0 -0
- package/dist/web/assets/chat-tab-IqAY4c7p.js.gz +0 -0
- package/dist/web/assets/code-editor-Dmitw9QS.js +0 -7
- package/dist/web/assets/code-editor-Dmitw9QS.js.br +0 -0
- package/dist/web/assets/code-editor-Dmitw9QS.js.gz +0 -0
- package/dist/web/assets/codex-reset-credit-button-D2hal4bG.js.br +0 -0
- package/dist/web/assets/codex-reset-credit-button-D2hal4bG.js.gz +0 -0
- package/dist/web/assets/conflict-editor-Cj_gUncw.js.br +0 -0
- package/dist/web/assets/conflict-editor-Cj_gUncw.js.gz +0 -0
- package/dist/web/assets/csv-preview-Be3ODNj0.js.br +0 -0
- package/dist/web/assets/csv-preview-Be3ODNj0.js.gz +0 -0
- package/dist/web/assets/database-viewer-B1b--4y8.js.br +0 -0
- package/dist/web/assets/database-viewer-B1b--4y8.js.gz +0 -0
- package/dist/web/assets/design-tab-8wi0IHss.js.br +0 -0
- package/dist/web/assets/design-tab-8wi0IHss.js.gz +0 -0
- package/dist/web/assets/designs-sidebar-panel-D5-1Q8zQ.js.br +0 -0
- package/dist/web/assets/designs-sidebar-panel-D5-1Q8zQ.js.gz +0 -0
- package/dist/web/assets/diff-viewer-Dcxk6UTG.js.br +0 -0
- package/dist/web/assets/diff-viewer-Dcxk6UTG.js.gz +0 -0
- package/dist/web/assets/edit-diff-preview-DxDAtYhi.js.br +0 -0
- package/dist/web/assets/editor-language-service-BVJQnTSV.js.br +0 -0
- package/dist/web/assets/editor-language-service-BVJQnTSV.js.gz +0 -0
- package/dist/web/assets/explorer-body-CTkrlrI3.js +0 -2
- package/dist/web/assets/explorer-body-CTkrlrI3.js.br +0 -0
- package/dist/web/assets/explorer-body-CTkrlrI3.js.gz +0 -0
- package/dist/web/assets/explorer-window-content-DH5AD3Ng.js.br +0 -0
- package/dist/web/assets/explorer-window-content-DH5AD3Ng.js.gz +0 -0
- package/dist/web/assets/extension-manager-section-BJr6ccWw.js.br +0 -0
- package/dist/web/assets/extension-manager-section-BJr6ccWw.js.gz +0 -0
- package/dist/web/assets/extension-webview-CYNXHd8D.js.br +0 -0
- package/dist/web/assets/extension-webview-CYNXHd8D.js.gz +0 -0
- package/dist/web/assets/files-settings-section-JX7o4lex.js.br +0 -0
- package/dist/web/assets/files-settings-section-JX7o4lex.js.gz +0 -0
- package/dist/web/assets/general-settings-section-kF94Mz5q.js.br +0 -0
- package/dist/web/assets/general-settings-section-kF94Mz5q.js.gz +0 -0
- package/dist/web/assets/git-log-panel-Crlp9ofM.js.br +0 -0
- package/dist/web/assets/git-log-panel-Crlp9ofM.js.gz +0 -0
- package/dist/web/assets/glide-data-grid-O6MO5dKU.js.br +0 -0
- package/dist/web/assets/glide-data-grid-O6MO5dKU.js.gz +0 -0
- package/dist/web/assets/group-chat-tab-DGLSGf37.js +0 -1
- package/dist/web/assets/group-chat-tab-DGLSGf37.js.br +0 -0
- package/dist/web/assets/group-chat-tab-DGLSGf37.js.gz +0 -0
- package/dist/web/assets/index-DQCw6d-2.js.br +0 -0
- package/dist/web/assets/index-DQCw6d-2.js.gz +0 -0
- package/dist/web/assets/keybindings-store-CJtEHFIQ.js +0 -1
- package/dist/web/assets/keyboard-shortcuts-section-CewWGwiF.js.br +0 -0
- package/dist/web/assets/keyboard-shortcuts-section-CewWGwiF.js.gz +0 -0
- package/dist/web/assets/language-servers-section-nricdxke.js.br +0 -0
- package/dist/web/assets/language-servers-section-nricdxke.js.gz +0 -0
- package/dist/web/assets/lsp-client-DRMEWb-z.js.br +0 -0
- package/dist/web/assets/lsp-client-DRMEWb-z.js.gz +0 -0
- package/dist/web/assets/markdown-renderer-D5-xliE9.js +0 -1
- package/dist/web/assets/markdown-renderer-Dab9Us6u.js.br +0 -0
- package/dist/web/assets/markdown-renderer-Dab9Us6u.js.gz +0 -0
- package/dist/web/assets/mobile-explorer-sheet-DtgdpvJ9.js.br +0 -0
- package/dist/web/assets/mobile-explorer-sheet-DtgdpvJ9.js.gz +0 -0
- package/dist/web/assets/new-design-dialog-Dd5KDB_p.js.br +0 -0
- package/dist/web/assets/new-design-dialog-Dd5KDB_p.js.gz +0 -0
- package/dist/web/assets/notification-store-D2vTyp_Q.js +0 -1
- package/dist/web/assets/panel-store-DrSH3Nhp.js.br +0 -0
- package/dist/web/assets/panel-store-DrSH3Nhp.js.gz +0 -0
- package/dist/web/assets/performance-panel-LMGefOQ2.js +0 -3
- package/dist/web/assets/performance-panel-LMGefOQ2.js.br +0 -0
- package/dist/web/assets/performance-panel-LMGefOQ2.js.gz +0 -0
- package/dist/web/assets/ppmbot-settings-section-D67u6gPi.js.br +0 -0
- package/dist/web/assets/ppmbot-settings-section-D67u6gPi.js.gz +0 -0
- package/dist/web/assets/problems-panel-DKgIw4uZ.js.br +0 -0
- package/dist/web/assets/problems-panel-DKgIw4uZ.js.gz +0 -0
- package/dist/web/assets/process-table-BIAgC_jG.js +0 -1
- package/dist/web/assets/process-table-BIAgC_jG.js.br +0 -0
- package/dist/web/assets/process-table-BIAgC_jG.js.gz +0 -0
- package/dist/web/assets/proxy-settings-section-CFiYcTBA.js.br +0 -0
- package/dist/web/assets/proxy-settings-section-CFiYcTBA.js.gz +0 -0
- package/dist/web/assets/query-audit-section-BybgiPsc.js.br +0 -0
- package/dist/web/assets/query-audit-section-BybgiPsc.js.gz +0 -0
- package/dist/web/assets/remote-desktop-clipboard-notice-Bs3fZSRw.js.br +0 -0
- package/dist/web/assets/remote-desktop-clipboard-notice-Bs3fZSRw.js.gz +0 -0
- package/dist/web/assets/remote-desktop-mobile-sheet-DgxTdWMh.js +0 -2
- package/dist/web/assets/remote-desktop-mobile-sheet-DgxTdWMh.js.br +0 -0
- package/dist/web/assets/remote-desktop-mobile-sheet-DgxTdWMh.js.gz +0 -0
- package/dist/web/assets/remote-desktop-mobile-view-DgGOfPVY.js.br +0 -0
- package/dist/web/assets/remote-desktop-mobile-view-DgGOfPVY.js.gz +0 -0
- package/dist/web/assets/remote-desktop-readiness-gate-DOWryrQx.js.br +0 -0
- package/dist/web/assets/remote-desktop-readiness-gate-DOWryrQx.js.gz +0 -0
- package/dist/web/assets/remote-desktop-window-content-7t0wQsHx.js +0 -1
- package/dist/web/assets/remote-desktop-window-content-7t0wQsHx.js.br +0 -0
- package/dist/web/assets/remote-desktop-window-content-7t0wQsHx.js.gz +0 -0
- package/dist/web/assets/schedules-settings-section-DGhG-b5O.js.br +0 -0
- package/dist/web/assets/schedules-settings-section-DGhG-b5O.js.gz +0 -0
- package/dist/web/assets/send-to-chat-B09VjsB5.js.br +0 -0
- package/dist/web/assets/send-to-chat-B09VjsB5.js.gz +0 -0
- package/dist/web/assets/services-panel-0klE3O4g.js.br +0 -0
- package/dist/web/assets/services-panel-0klE3O4g.js.gz +0 -0
- package/dist/web/assets/settings-body-CfqpqFfq.js.br +0 -0
- package/dist/web/assets/settings-body-CfqpqFfq.js.gz +0 -0
- package/dist/web/assets/settings-store-3jIBB8gx.js.br +0 -0
- package/dist/web/assets/settings-store-3jIBB8gx.js.gz +0 -0
- package/dist/web/assets/sql-query-editor-ALQ5_X0j.js.br +0 -0
- package/dist/web/assets/sql-query-editor-ALQ5_X0j.js.gz +0 -0
- package/dist/web/assets/sqlite-viewer-DKTty_jR.js.br +0 -0
- package/dist/web/assets/sqlite-viewer-DKTty_jR.js.gz +0 -0
- package/dist/web/assets/system-monitor-body-D6J6lq7-.js.br +0 -0
- package/dist/web/assets/system-monitor-body-D6J6lq7-.js.gz +0 -0
- package/dist/web/assets/system-monitor-tab-Di18zNNS.js +0 -1
- package/dist/web/assets/tab-host-window-content-DTcx2D0O.js.br +0 -0
- package/dist/web/assets/tab-host-window-content-DTcx2D0O.js.gz +0 -0
- package/dist/web/assets/team-member-sheet-CFSbPG6n.js +0 -2
- package/dist/web/assets/team-member-sheet-CFSbPG6n.js.br +0 -0
- package/dist/web/assets/team-member-sheet-CFSbPG6n.js.gz +0 -0
- package/dist/web/assets/team-member-window-content-VeI6DGeM.js +0 -1
- package/dist/web/assets/team-member-window-content-VeI6DGeM.js.br +0 -0
- package/dist/web/assets/team-member-window-content-VeI6DGeM.js.gz +0 -0
- package/dist/web/assets/terminal-tab-DgTfQKBI.js.br +0 -0
- package/dist/web/assets/terminal-tab-DgTfQKBI.js.gz +0 -0
- package/dist/web/assets/tool-cards-_fpYI1hB.js +0 -9
- package/dist/web/assets/tool-cards-_fpYI1hB.js.br +0 -0
- package/dist/web/assets/tool-cards-_fpYI1hB.js.gz +0 -0
- package/dist/web/assets/use-inline-blame-Dv111BKY.js.br +0 -0
- package/dist/web/assets/use-inline-blame-Dv111BKY.js.gz +0 -0
- package/dist/web/assets/use-lsp-CZTFJIXX.js.br +0 -0
- package/dist/web/assets/use-lsp-CZTFJIXX.js.gz +0 -0
- package/dist/web/assets/use-open-team-member-ElN3KmCI.js +0 -1
- package/dist/web/assets/use-process-kill-D7D9QvJG.js.br +0 -0
- package/dist/web/assets/use-process-kill-D7D9QvJG.js.gz +0 -0
- package/dist/web/assets/video-preview-DzwY3q9W.js.br +0 -0
- package/dist/web/assets/video-preview-DzwY3q9W.js.gz +0 -0
- package/dist/web/assets/voice-settings-section-B7zMHsuz.js.br +0 -0
- package/dist/web/assets/voice-settings-section-B7zMHsuz.js.gz +0 -0
- package/dist/web/assets/window-store-B4cbZ5rr.js +0 -1
- package/dist/web/assets/window-store-B4cbZ5rr.js.br +0 -0
- package/dist/web/assets/window-store-B4cbZ5rr.js.gz +0 -0
- package/src/web/components/chat/team-member-window-content.tsx +0 -66
- package/src/web/components/chat/team-working-bar.tsx +0 -62
- package/src/web/components/chat/use-open-team-member.ts +0 -41
- package/src/web/hooks/use-member-transcript-tail.ts +0 -95
- /package/dist/web/assets/{api-settings-BeINN5Dy.js → api-settings-BWgfXl7o.js} +0 -0
- /package/dist/web/assets/{api-settings-BeINN5Dy.js.br → api-settings-BWgfXl7o.js.br} +0 -0
- /package/dist/web/assets/{api-settings-BeINN5Dy.js.gz → api-settings-BWgfXl7o.js.gz} +0 -0
- /package/dist/web/assets/{libesm-CxeQSM3t.js → libesm-DAF5_F99.js} +0 -0
- /package/dist/web/assets/{libesm-CxeQSM3t.js.br → libesm-DAF5_F99.js.br} +0 -0
- /package/dist/web/assets/{libesm-CxeQSM3t.js.gz → libesm-DAF5_F99.js.gz} +0 -0
- /package/dist/web/assets/{onboarding-entry-DD3QSDiz.js → onboarding-entry-Bh-WE3vq.js} +0 -0
- /package/dist/web/assets/{onboarding-entry-DD3QSDiz.js.br → onboarding-entry-Bh-WE3vq.js.br} +0 -0
- /package/dist/web/assets/{onboarding-entry-DD3QSDiz.js.gz → onboarding-entry-Bh-WE3vq.js.gz} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import{C as t,S as n}from"./vendor-markdown-QKPNiWEd.js";import{Ar as r,G as i,Jr as a,W as o}from"./icons-CO_II6D-.js";import{r as s}from"./api-client-F5Zi1sR0.js";import{E as c,t as l}from"./settings-store-3jIBB8gx.js";import{n as u}from"./utils-btZ8C8-R.js";import{t as d}from"./ws-auth-J3hw0Mhc.js";import{Z as f}from"./index-DQCw6d-2.js";import{r as p}from"./run-in-terminal-Cdn9PaAl.js";function m(e,t,n=`8081`){let r=d(`/ws/remote-desktop`),i=e.protocol===`https:`?`wss:`:`ws:`;return t&&e.protocol!==`https:`?`ws://${e.hostname}:${n}${r}`:`${i}//${e.host}${r}`}var h=30;function g(e,t=h){return Math.round(e*1e6/t)}var _=e(t(),1);function v(e,t){return t||e}function y(e){let[t,n]=(0,_.useState)(`idle`),[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)({width:0,height:0}),s=(0,_.useRef)(null),c=(0,_.useRef)(null),l=(0,_.useRef)(!1),u=(0,_.useRef)(0),d=(0,_.useRef)(0),f=(0,_.useRef)(null),p=(0,_.useRef)(!1),m=(0,_.useCallback)(e=>{n(`error`),i(e)},[]),h=(0,_.useCallback)(async t=>{if(f.current=t,typeof VideoDecoder>`u`){n(`unsupported`),i(`This browser has no WebCodecs VideoDecoder — try Chrome, Edge, or Safari 16.4+.`);return}let r={codec:t,optimizeForLatency:!0};try{if(!(await VideoDecoder.isConfigSupported(r)).supported){n(`unsupported`),i(`This browser's decoder does not support ${t}.`);return}}catch(e){m(e.message);return}s.current?.close(),l.current=!1,d.current=0;let a=new VideoDecoder({output:t=>{u.current+=1;let n=e.current;n&&((n.width!==t.displayWidth||n.height!==t.displayHeight)&&(n.width=t.displayWidth,n.height=t.displayHeight,o({width:t.displayWidth,height:t.displayHeight})),c.current||=n.getContext(`2d`),c.current?.drawImage(t,0,0,n.width,n.height)),t.close()},error:e=>y(e.message)});try{a.configure(r)}catch(e){m(e.message);return}s.current=a,p.current=!0,n(`ready`),i(null)},[e,m]),y=(0,_.useCallback)(e=>{if(!p.current)return;let t=f.current;if(!t){m(e);return}try{s.current?.close()}catch{}s.current=null,h(t)},[h,m]);return{status:t,errorMessage:r,configure:h,decodeAccessUnit:(0,_.useCallback)((e,t)=>{let n=s.current;if(!(!n||n.state!==`configured`)&&v(l.current,t)){t&&(l.current=!0);try{n.decode(new EncodedVideoChunk({type:t?`key`:`delta`,timestamp:g(d.current++),data:e}))}catch(e){y(e.message)}}},[y]),reset:(0,_.useCallback)(()=>{p.current=!1;try{s.current?.close()}catch{}s.current=null,l.current=!1,u.current=0,d.current=0,n(`idle`),i(null)},[]),getFrameCount:(0,_.useCallback)(()=>u.current,[]),frameSize:a}}function b(e){return e.code===`KeyV`&&(e.ctrlKey||e.metaKey)}function x(e){return(e.code===`KeyC`||e.code===`KeyX`)&&(e.ctrlKey||e.metaKey)}function S(e){let t=document.createElement(`textarea`);t.value=e,t.style.cssText=`position:fixed;top:0;left:-9999px;opacity:0`,t.setAttribute(`aria-hidden`,`true`),document.body.appendChild(t);let n=document.activeElement,r=!1;try{t.focus({preventScroll:!0}),t.setSelectionRange(0,e.length),t.select(),r=document.execCommand(`copy`)}catch{r=!1}t.remove();try{n?.focus({preventScroll:!0})}catch{}return r}async function C(e){try{return navigator.clipboard?.writeText?(await navigator.clipboard.writeText(e),!0):!1}catch{return!1}}var w=120,T=400;function ee(){let e=(0,_.useRef)(null),t=(0,_.useRef)(null),n=(0,_.useRef)(null),r=(0,_.useRef)(0),i=(0,_.useRef)(0),[a,o]=(0,_.useState)(`idle`),s=(0,_.useCallback)(()=>{try{t.current?.close()}catch{}t.current=null,n.current=null;let a=e.current;e.current=null,a&&a.close().catch(()=>{}),r.current=0,i.current=0,o(e=>e===`unsupported`?e:`idle`)},[]),c=(0,_.useCallback)(t=>{let i=e.current;if(!i){t.close();return}let a=t.numberOfFrames,o=t.numberOfChannels,s=i.createBuffer(o,a,t.sampleRate);for(let e=0;e<o;e++){let n=new Float32Array(a);t.copyTo(n,{planeIndex:e,format:`f32-planar`}),s.copyToChannel(n,e)}t.close();let c=i.currentTime,l=(r.current-c)*1e3;(l<0||l>T)&&(r.current=c+w/1e3);let u=i.createBufferSource();u.buffer=s,u.connect(i.destination),n.current&&u.connect(n.current),u.start(r.current),r.current+=s.duration},[]),l=(0,_.useCallback)(async(a,l)=>{if(typeof AudioDecoder>`u`||typeof AudioContext>`u`){o(`unsupported`);return}s();let u=new AudioContext({sampleRate:l,latencyHint:`interactive`});e.current=u,u.state===`suspended`&&await u.resume().catch(()=>{}),n.current=u.createMediaStreamDestination();let d=new AudioDecoder({output:c,error:()=>{try{t.current?.reset()}catch{}}});try{d.configure({codec:`opus`,sampleRate:l,numberOfChannels:a})}catch{o(`unsupported`);return}t.current=d,r.current=0,i.current=0,o(`playing`)},[c,s]),u=(0,_.useCallback)(e=>{let n=t.current;if(!n||n.state!==`configured`)return;let r=i.current;i.current+=2e4;try{n.decode(new EncodedAudioChunk({type:`key`,timestamp:r,data:e}))}catch{}},[]),d=(0,_.useCallback)(()=>n.current?n.current.stream.getAudioTracks():[],[]);return(0,_.useEffect)(()=>()=>s(),[s]),{status:a,configure:l,decodePacket:u,reset:s,getTracks:d}}var E=5e3,D=2;function O(e,{displayId:t}={}){let n=(0,_.useRef)(null),r=(0,_.useRef)(0),[i,a]=(0,_.useState)(`connecting`),[o,u]=(0,_.useState)(null),[d,f]=(0,_.useState)(0),[p,h]=(0,_.useState)(()=>({preset:c(l.getState().remoteDesktopQuality)??`balanced`,held:1})),g=(0,_.useRef)(c(l.getState().remoteDesktopQuality)),[v,b]=(0,_.useState)(null),x=(0,_.useRef)(null),S=l(e=>e.remoteDesktopShowCursor),w=l(e=>e.remoteDesktopClipboardSync),T=(0,_.useRef)(S),O=(0,_.useRef)(w);(0,_.useEffect)(()=>{T.current=S},[S]),(0,_.useEffect)(()=>{O.current=w},[w]);let k=(0,_.useRef)(l.getState().remoteDesktopCodec),[A,j]=(0,_.useState)(k.current),M=y(e),N=ee(),[P,F]=(0,_.useState)(!1),[I,L]=(0,_.useState)(!1),[R,z]=(0,_.useState)(null),[B,V]=(0,_.useState)(null),[H,U]=(0,_.useState)(null),[W,G]=(0,_.useState)(null),K=(0,_.useCallback)(e=>{let t=n.current;t?.readyState===WebSocket.OPEN&&t.send(JSON.stringify(e))},[]),q=(0,_.useCallback)(e=>{let t=c(e.preset);t&&h({preset:t,held:typeof e.held==`number`&&e.held>0&&e.held<1?e.held:1})},[]),J=(0,_.useCallback)(e=>{if(e!==`custom`)return{type:`quality`,preset:e};let t=l.getState();return{type:`quality`,preset:`custom`,percent:t.remoteDesktopCustomQualityPercent,fps:t.remoteDesktopCustomFps}},[]),Y=(0,_.useCallback)(e=>{g.current=e,l.getState().setRemoteDesktopQuality(e),K(J(e))},[J,K]),X=(0,_.useCallback)((e,t)=>{let n=l.getState();n.setRemoteDesktopCustomQuality(e,t),n.setRemoteDesktopQuality(`custom`),g.current=`custom`,K(J(`custom`))},[J,K]),Z=(0,_.useCallback)(e=>{z(null),K({type:`privacy`,enabled:e})},[K]),Q=(0,_.useCallback)(e=>{F(e),e||N.reset(),K({type:`audio`,enabled:e})},[N,K]),$=(0,_.useCallback)(e=>{k.current=e,l.getState().setRemoteDesktopCodec(e),j(e),e&&K({type:`codec`,encoder:e})},[K]),te=(0,_.useCallback)(e=>{G(null),K({type:`resolution`,modeId:e})},[K]),ne=(0,_.useCallback)(e=>{T.current=e,l.getState().setRemoteDesktopShowCursor(e),K({type:`cursor`,show:e})},[K]),re=(0,_.useCallback)((e,t,n=!1)=>{K({type:`clipboard`,text:e,paste:t,shift:n})},[K]),ie=(0,_.useCallback)(()=>{x.current&&clearTimeout(x.current),x.current=setTimeout(()=>{x.current=null,K({type:`clipboardRead`})},350)},[K]),ae=(0,_.useCallback)(()=>b(null),[]);(0,_.useEffect)(()=>()=>{x.current&&clearTimeout(x.current)},[]),(0,_.useEffect)(()=>{let e=!1,i=null;a(`connecting`),u(null),L(!1),z(null),r.current=0,M.reset(),(async()=>{let o;try{o=(await s.post(`/api/remote-desktop/session`)).nonce}catch(t){e||(a(`error`),u(t.message));return}if(e)return;let c=m(window.location,!1,void 0),l=new WebSocket(c);l.binaryType=`arraybuffer`,n.current=l,l.onopen=()=>{l.send(JSON.stringify({type:`auth`,nonce:o,...t?{displayId:t}:{},cursor:T.current,...k.current?{codec:k.current}:{}})),g.current&&l.send(JSON.stringify(J(g.current))),i=setInterval(()=>K({type:`ping`}),E)},l.onmessage=t=>{if(typeof t.data==`string`){let n;try{n=JSON.parse(t.data)}catch{return}if(n.type===`config`&&typeof n.codec==`string`)q(n),j(typeof n.encoder==`string`?n.encoder:null),M.configure(n.codec).then(()=>{e||a(`streaming`)});else if(n.type===`quality`)q(n);else if(n.type===`codec`)j(typeof n.encoder==`string`?n.encoder:null);else if(n.type===`resolution`)V(typeof n.modeId==`string`?n.modeId:null),U(typeof n.original==`string`?n.original:null),G(null);else if(n.type===`resolutionError`)G(typeof n.message==`string`?n.message:`The host refused the mode.`);else if(n.type===`privacy`)L(n.enabled===!0),z(typeof n.reason==`string`?n.reason:null);else if(n.type===`audio`){let e=n.enabled===!0;if(F(e),!e){N.reset();return}let t=typeof n.channels==`number`?n.channels:2,r=typeof n.sampleRate==`number`?n.sampleRate:48e3;N.configure(t,r)}else if(n.type===`clipboard`&&typeof n.text==`string`){if(!O.current)return;let t=n.text;C(t).then(n=>{!n&&!e&&b(t)})}else n.type===`error`&&(a(`error`),u(typeof n.message==`string`?n.message:`Server error`));return}let n=new Uint8Array(t.data);if(!(n.length<1)){if(r.current+=n.length,n[0]===D){N.decodePacket(n.subarray(1));return}M.decodeAccessUnit(n.subarray(1),n[0]===1)}},l.onerror=()=>{e||(a(`error`),u(`WebSocket error`))},l.onclose=()=>{e||a(e=>e===`error`?e:`closed`)}})();let o=()=>{if(document.hidden||e)return;let t=n.current;t&&t.readyState===WebSocket.OPEN?t.send(JSON.stringify({type:`ping`})):f(e=>e+1)};return document.addEventListener(`visibilitychange`,o),()=>{e=!0,document.removeEventListener(`visibilitychange`,o),i&&clearInterval(i);try{n.current?.close()}catch{}n.current=null;try{M.reset()}catch{}try{N.reset()}catch{}}},[d,t]);let oe=(0,_.useCallback)(()=>f(e=>e+1),[]),se=(0,_.useCallback)(()=>r.current,[]);return{connState:i,errorMessage:o,decoderStatus:M.status,decoderErrorMessage:M.errorMessage,sendMessage:K,reconnect:oe,getTotalBytes:se,getFrameCount:M.getFrameCount,frameSize:M.frameSize,quality:p,setQuality:Y,setCustomQuality:X,showCursor:S,setShowCursor:ne,codec:A,setCodec:$,audioOn:P,setAudioOn:Q,getAudioTracks:N.getTracks,privacyOn:I,privacyError:R,setPrivacyOn:Z,hostModeId:B,hostOriginalModeId:H,resolutionError:W,setHostMode:te,pendingHostClipboard:v,clearHostClipboard:ae,sendClipboard:re,requestHostClipboard:ie}}function k(e){return Math.min(Math.max(e,0),1)}function A(e,t,n){let r=n.width>0?(e-n.left)/n.width:0,i=n.height>0?(t-n.top)/n.height:0;return{xFrac:k(r),yFrac:k(i)}}function j(e,t,n,r){let i=r.scale||1,a=n.left+n.width/2,o=n.top+n.height/2;return A(a+(e-a-r.panX)/i,o+(t-o-r.panY)/i,n)}function M(e,t,n){if(t<=0||n<=0||e.width<=0||e.height<=0)return e;let r=e.width/e.height,i=t/n;if(i>r){let t=e.width/i;return{left:e.left,top:e.top+(e.height-t)/2,width:e.width,height:t}}let a=e.height*i;return{left:e.left+(e.width-a)/2,top:e.top,width:a,height:e.height}}function N(e){let t=new Map;for(let n of e){if(n.width<=0||n.height<=0)continue;let e=`${n.width}x${n.height}`,r=t.get(e);(!r||P(n,r))&&t.set(e,n)}return[...t.values()].sort((e,t)=>t.width*t.height-e.width*e.height||t.refresh-e.refresh).map(e=>({id:e.id,width:e.width,height:e.height,refresh:e.refresh,current:e.current,preferred:e.preferred}))}function P(e,t){return e.current===t.current?e.preferred===t.preferred?e.refresh>t.refresh:e.preferred:e.current}function F(e,t,n){if(!t||t.width<=0||t.height<=0)return null;let r=e.filter(e=>e.width===t.width&&e.height===t.height);if(r.length===0)return null;let i=e.find(e=>e.id===n)??e.find(e=>e.current)??null;return i&&i.width===t.width&&i.height===t.height?null:r.reduce((e,t)=>P(t,e)?t:e)}function I(){if(typeof window>`u`||!window.screen)return null;let e=Math.round(window.screen.width),t=Math.round(window.screen.height);return e>0&&t>0?{width:e,height:t}:null}function L(e){let t=`${e.width} × ${e.height}`;return e.refresh>0?`${t} · ${e.refresh} Hz`:t}var R=[`video/mp4;codecs=avc1.42E01E,mp4a.40.2`,`video/mp4`,`video/webm;codecs=vp9,opus`,`video/webm;codecs=vp8,opus`,`video/webm`];function z(e=e=>typeof MediaRecorder<`u`&&MediaRecorder.isTypeSupported(e)){return typeof MediaRecorder>`u`?null:R.find(e)??null}function B(e){return e.startsWith(`video/mp4`)?`mp4`:`webm`}function V(e,t=new Date){let n=e=>String(e).padStart(2,`0`);return`ppm-remote-${`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}_${n(t.getHours())}-${n(t.getMinutes())}-${n(t.getSeconds())}`}.${e}`}function H(e,t){let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,r.rel=`noopener`,document.body.appendChild(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),1e4)}async function U(e){if(!e||e.width===0||e.height===0)return!1;let t=await new Promise(t=>e.toBlob(t,`image/png`));return t?(H(t,V(`png`)),!0):!1}function W(e,t){let n=(0,_.useRef)(null),r=(0,_.useRef)([]),[i,a]=(0,_.useState)(!1),[o,s]=(0,_.useState)(0),c=(0,_.useRef)(null);c.current===null&&(c.current=z());let l=(0,_.useCallback)(()=>{n.current?.stop()},[]),u=(0,_.useCallback)(()=>{let i=e.current,o=c.current;if(!i||!o||n.current)return;let l=i.captureStream();for(let e of t?.()??[])l.addTrack(e);let u;try{u=new MediaRecorder(l,{mimeType:o})}catch{return}r.current=[],u.ondataavailable=e=>{e.data.size>0&&r.current.push(e.data)},u.onstop=()=>{let e=new Blob(r.current,{type:o});r.current=[],n.current=null,a(!1),s(0),e.size>0&&H(e,V(B(o)))},u.start(1e3),n.current=u,a(!0),s(0)},[e,t]),d=(0,_.useCallback)(()=>{n.current?l():u()},[u,l]);return(0,_.useEffect)(()=>{if(!i)return;let e=Date.now(),t=setInterval(()=>{let t=Date.now()-e;s(Math.floor(t/1e3)),t>=72e5&&l()},1e3);return()=>clearInterval(t)},[i,l]),(0,_.useEffect)(()=>()=>{n.current?.stop()},[]),{recording:i,elapsedSec:o,supported:c.current!==null,toggle:d}}var G={fps:0,kbps:0};function K(e,t){let n=t.atMs-e.atMs;if(n<=0)return G;let r=n/1e3,i=Math.max(0,t.frameCount-e.frameCount),a=Math.max(0,t.totalBytes-e.totalBytes);return{fps:i/r,kbps:a/1024/r}}var q=n(),J=500;function Y({canvasRef:e,getFrameCount:t,getTotalBytes:n,positionClassName:r=`left-1 top-1`}){let i=l(e=>e.remoteDesktopStatsVisible),[a,o]=(0,_.useState)({fps:0,kbps:0,width:0,height:0}),s=(0,_.useRef)({frameCount:0,totalBytes:0,atMs:0});return(0,_.useEffect)(()=>{if(!i)return;s.current={frameCount:t(),totalBytes:n(),atMs:performance.now()};let r=setInterval(()=>{let r={frameCount:t(),totalBytes:n(),atMs:performance.now()},{fps:i,kbps:a}=K(s.current,r);s.current=r;let c=e.current;o({fps:i,kbps:a,width:c?.width??0,height:c?.height??0})},J);return()=>clearInterval(r)},[i,e,t,n]),i?(0,q.jsxs)(`div`,{className:`pointer-events-none absolute z-40 rounded bg-black/60 px-1.5 py-0.5 font-mono text-[10px] text-white/80 ${r}`,"data-testid":`remote-desktop-stats-overlay`,children:[Math.round(a.fps),` fps · `,Math.round(a.kbps),` KB/s · `,a.width,`×`,a.height]}):null}function X(){let{caps:e}=f(!1),t=e?.displays??[],[n,r]=(0,_.useState)(void 0),i=t.find(e=>e.id===n)??t.find(e=>e.primary)??t[0];return{displays:t,displayId:n,current:i,select:r,next:(0,_.useCallback)(()=>{t.length<2||r(t[(t.findIndex(e=>e.id===i?.id)+1)%t.length]?.id)},[t,i])}}function Z({pendingText:e,onDismiss:t,missingToolAction:n,onDismissMissingTool:a,positionClassName:s=`absolute bottom-2 left-1/2 max-w-[92%] -translate-x-1/2`}){let[c,l]=(0,_.useState)(!1);return e===null?n==null?null:(0,q.jsxs)(Q,{onDismiss:a??(()=>{}),testId:`remote-desktop-clipboard-missing-tool`,positionClassName:s,children:[(0,q.jsx)(o,{className:`size-4 shrink-0 text-amber-300`}),(0,q.jsx)(`span`,{className:`min-w-0 flex-1`,children:`The host has no clipboard tool installed.`}),n.kind===`terminal`&&(0,q.jsxs)(`button`,{type:`button`,onClick:()=>p(n.command),title:n.command,className:`inline-flex min-h-8 shrink-0 items-center gap-1.5 rounded bg-white/15 px-2.5 text-xs hover:bg-white/25`,children:[(0,q.jsx)(r,{className:`size-3.5`}),` `,n.label]})]}):(0,q.jsxs)(Q,{onDismiss:t,testId:`remote-desktop-clipboard-pending`,positionClassName:s,children:[(0,q.jsx)(i,{className:`size-4 shrink-0 text-emerald-400`}),(0,q.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[c?`Could not copy — select the text manually:`:`Copied on the host:`,(0,q.jsx)(`span`,{className:`ml-1 text-white/60`,children:$(e)})]}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>{S(e)?t():l(!0)},className:`min-h-8 shrink-0 rounded bg-white/15 px-2.5 text-xs hover:bg-white/25`,"data-testid":`remote-desktop-clipboard-copy`,children:`Copy here`})]})}function Q({children:e,onDismiss:t,testId:n,positionClassName:r}){return(0,q.jsxs)(`div`,{className:u(`z-50 flex items-center gap-2 rounded-lg border border-white/10 bg-black/85 px-3 py-2 text-xs text-white shadow-lg`,r),"data-testid":n,children:[e,(0,q.jsx)(`button`,{type:`button`,onClick:t,"aria-label":`Dismiss`,className:`flex size-8 shrink-0 items-center justify-center rounded text-white/60 hover:bg-white/10 hover:text-white`,children:(0,q.jsx)(a,{className:`size-3.5`})})]})}function $(e){let t=e.replace(/\s+/g,` `).trim();return t.length>60?`${t.slice(0,60)}…`:t}export{U as a,N as c,j as d,M as f,b as h,W as i,L as l,x as m,X as n,F as o,O as p,Y as r,I as s,Z as t,A as u};
|
|
1
|
+
import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import{C as t,S as n}from"./vendor-markdown-QKPNiWEd.js";import{Ar as r,G as i,Jr as a,W as o}from"./icons-CO_II6D-.js";import{r as s}from"./api-client-F5Zi1sR0.js";import{E as c,t as l}from"./settings-store-DIV25PM_.js";import{n as u}from"./utils-btZ8C8-R.js";import{t as d}from"./ws-auth-J3hw0Mhc.js";import{$ as f}from"./index-CIscPw4g.js";import{r as p}from"./run-in-terminal-B_PCeBqG.js";function m(e,t,n=`8081`){let r=d(`/ws/remote-desktop`),i=e.protocol===`https:`?`wss:`:`ws:`;return t&&e.protocol!==`https:`?`ws://${e.hostname}:${n}${r}`:`${i}//${e.host}${r}`}var h=30;function g(e,t=h){return Math.round(e*1e6/t)}var _=e(t(),1);function v(e,t){return t||e}function y(e){let[t,n]=(0,_.useState)(`idle`),[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)({width:0,height:0}),s=(0,_.useRef)(null),c=(0,_.useRef)(null),l=(0,_.useRef)(!1),u=(0,_.useRef)(0),d=(0,_.useRef)(0),f=(0,_.useRef)(null),p=(0,_.useRef)(!1),m=(0,_.useCallback)(e=>{n(`error`),i(e)},[]),h=(0,_.useCallback)(async t=>{if(f.current=t,typeof VideoDecoder>`u`){n(`unsupported`),i(`This browser has no WebCodecs VideoDecoder — try Chrome, Edge, or Safari 16.4+.`);return}let r={codec:t,optimizeForLatency:!0};try{if(!(await VideoDecoder.isConfigSupported(r)).supported){n(`unsupported`),i(`This browser's decoder does not support ${t}.`);return}}catch(e){m(e.message);return}s.current?.close(),l.current=!1,d.current=0;let a=new VideoDecoder({output:t=>{u.current+=1;let n=e.current;n&&((n.width!==t.displayWidth||n.height!==t.displayHeight)&&(n.width=t.displayWidth,n.height=t.displayHeight,o({width:t.displayWidth,height:t.displayHeight})),c.current||=n.getContext(`2d`),c.current?.drawImage(t,0,0,n.width,n.height)),t.close()},error:e=>y(e.message)});try{a.configure(r)}catch(e){m(e.message);return}s.current=a,p.current=!0,n(`ready`),i(null)},[e,m]),y=(0,_.useCallback)(e=>{if(!p.current)return;let t=f.current;if(!t){m(e);return}try{s.current?.close()}catch{}s.current=null,h(t)},[h,m]);return{status:t,errorMessage:r,configure:h,decodeAccessUnit:(0,_.useCallback)((e,t)=>{let n=s.current;if(!(!n||n.state!==`configured`)&&v(l.current,t)){t&&(l.current=!0);try{n.decode(new EncodedVideoChunk({type:t?`key`:`delta`,timestamp:g(d.current++),data:e}))}catch(e){y(e.message)}}},[y]),reset:(0,_.useCallback)(()=>{p.current=!1;try{s.current?.close()}catch{}s.current=null,l.current=!1,u.current=0,d.current=0,n(`idle`),i(null)},[]),getFrameCount:(0,_.useCallback)(()=>u.current,[]),frameSize:a}}function b(e){return e.code===`KeyV`&&(e.ctrlKey||e.metaKey)}function x(e){return(e.code===`KeyC`||e.code===`KeyX`)&&(e.ctrlKey||e.metaKey)}function S(e){let t=document.createElement(`textarea`);t.value=e,t.style.cssText=`position:fixed;top:0;left:-9999px;opacity:0`,t.setAttribute(`aria-hidden`,`true`),document.body.appendChild(t);let n=document.activeElement,r=!1;try{t.focus({preventScroll:!0}),t.setSelectionRange(0,e.length),t.select(),r=document.execCommand(`copy`)}catch{r=!1}t.remove();try{n?.focus({preventScroll:!0})}catch{}return r}async function C(e){try{return navigator.clipboard?.writeText?(await navigator.clipboard.writeText(e),!0):!1}catch{return!1}}var w=120,T=400;function ee(){let e=(0,_.useRef)(null),t=(0,_.useRef)(null),n=(0,_.useRef)(null),r=(0,_.useRef)(0),i=(0,_.useRef)(0),[a,o]=(0,_.useState)(`idle`),s=(0,_.useCallback)(()=>{try{t.current?.close()}catch{}t.current=null,n.current=null;let a=e.current;e.current=null,a&&a.close().catch(()=>{}),r.current=0,i.current=0,o(e=>e===`unsupported`?e:`idle`)},[]),c=(0,_.useCallback)(t=>{let i=e.current;if(!i){t.close();return}let a=t.numberOfFrames,o=t.numberOfChannels,s=i.createBuffer(o,a,t.sampleRate);for(let e=0;e<o;e++){let n=new Float32Array(a);t.copyTo(n,{planeIndex:e,format:`f32-planar`}),s.copyToChannel(n,e)}t.close();let c=i.currentTime,l=(r.current-c)*1e3;(l<0||l>T)&&(r.current=c+w/1e3);let u=i.createBufferSource();u.buffer=s,u.connect(i.destination),n.current&&u.connect(n.current),u.start(r.current),r.current+=s.duration},[]),l=(0,_.useCallback)(async(a,l)=>{if(typeof AudioDecoder>`u`||typeof AudioContext>`u`){o(`unsupported`);return}s();let u=new AudioContext({sampleRate:l,latencyHint:`interactive`});e.current=u,u.state===`suspended`&&await u.resume().catch(()=>{}),n.current=u.createMediaStreamDestination();let d=new AudioDecoder({output:c,error:()=>{try{t.current?.reset()}catch{}}});try{d.configure({codec:`opus`,sampleRate:l,numberOfChannels:a})}catch{o(`unsupported`);return}t.current=d,r.current=0,i.current=0,o(`playing`)},[c,s]),u=(0,_.useCallback)(e=>{let n=t.current;if(!n||n.state!==`configured`)return;let r=i.current;i.current+=2e4;try{n.decode(new EncodedAudioChunk({type:`key`,timestamp:r,data:e}))}catch{}},[]),d=(0,_.useCallback)(()=>n.current?n.current.stream.getAudioTracks():[],[]);return(0,_.useEffect)(()=>()=>s(),[s]),{status:a,configure:l,decodePacket:u,reset:s,getTracks:d}}var E=5e3,D=2;function O(e,{displayId:t}={}){let n=(0,_.useRef)(null),r=(0,_.useRef)(0),[i,a]=(0,_.useState)(`connecting`),[o,u]=(0,_.useState)(null),[d,f]=(0,_.useState)(0),[p,h]=(0,_.useState)(()=>({preset:c(l.getState().remoteDesktopQuality)??`balanced`,held:1})),g=(0,_.useRef)(c(l.getState().remoteDesktopQuality)),[v,b]=(0,_.useState)(null),x=(0,_.useRef)(null),S=l(e=>e.remoteDesktopShowCursor),w=l(e=>e.remoteDesktopClipboardSync),T=(0,_.useRef)(S),O=(0,_.useRef)(w);(0,_.useEffect)(()=>{T.current=S},[S]),(0,_.useEffect)(()=>{O.current=w},[w]);let k=(0,_.useRef)(l.getState().remoteDesktopCodec),[A,j]=(0,_.useState)(k.current),M=y(e),N=ee(),[P,F]=(0,_.useState)(!1),[I,L]=(0,_.useState)(!1),[R,z]=(0,_.useState)(null),[B,V]=(0,_.useState)(null),[H,U]=(0,_.useState)(null),[W,G]=(0,_.useState)(null),K=(0,_.useCallback)(e=>{let t=n.current;t?.readyState===WebSocket.OPEN&&t.send(JSON.stringify(e))},[]),q=(0,_.useCallback)(e=>{let t=c(e.preset);t&&h({preset:t,held:typeof e.held==`number`&&e.held>0&&e.held<1?e.held:1})},[]),J=(0,_.useCallback)(e=>{if(e!==`custom`)return{type:`quality`,preset:e};let t=l.getState();return{type:`quality`,preset:`custom`,percent:t.remoteDesktopCustomQualityPercent,fps:t.remoteDesktopCustomFps}},[]),Y=(0,_.useCallback)(e=>{g.current=e,l.getState().setRemoteDesktopQuality(e),K(J(e))},[J,K]),X=(0,_.useCallback)((e,t)=>{let n=l.getState();n.setRemoteDesktopCustomQuality(e,t),n.setRemoteDesktopQuality(`custom`),g.current=`custom`,K(J(`custom`))},[J,K]),Z=(0,_.useCallback)(e=>{z(null),K({type:`privacy`,enabled:e})},[K]),Q=(0,_.useCallback)(e=>{F(e),e||N.reset(),K({type:`audio`,enabled:e})},[N,K]),$=(0,_.useCallback)(e=>{k.current=e,l.getState().setRemoteDesktopCodec(e),j(e),e&&K({type:`codec`,encoder:e})},[K]),te=(0,_.useCallback)(e=>{G(null),K({type:`resolution`,modeId:e})},[K]),ne=(0,_.useCallback)(e=>{T.current=e,l.getState().setRemoteDesktopShowCursor(e),K({type:`cursor`,show:e})},[K]),re=(0,_.useCallback)((e,t,n=!1)=>{K({type:`clipboard`,text:e,paste:t,shift:n})},[K]),ie=(0,_.useCallback)(()=>{x.current&&clearTimeout(x.current),x.current=setTimeout(()=>{x.current=null,K({type:`clipboardRead`})},350)},[K]),ae=(0,_.useCallback)(()=>b(null),[]);(0,_.useEffect)(()=>()=>{x.current&&clearTimeout(x.current)},[]),(0,_.useEffect)(()=>{let e=!1,i=null;a(`connecting`),u(null),L(!1),z(null),r.current=0,M.reset(),(async()=>{let o;try{o=(await s.post(`/api/remote-desktop/session`)).nonce}catch(t){e||(a(`error`),u(t.message));return}if(e)return;let c=m(window.location,!1,void 0),l=new WebSocket(c);l.binaryType=`arraybuffer`,n.current=l,l.onopen=()=>{l.send(JSON.stringify({type:`auth`,nonce:o,...t?{displayId:t}:{},cursor:T.current,...k.current?{codec:k.current}:{}})),g.current&&l.send(JSON.stringify(J(g.current))),i=setInterval(()=>K({type:`ping`}),E)},l.onmessage=t=>{if(typeof t.data==`string`){let n;try{n=JSON.parse(t.data)}catch{return}if(n.type===`config`&&typeof n.codec==`string`)q(n),j(typeof n.encoder==`string`?n.encoder:null),M.configure(n.codec).then(()=>{e||a(`streaming`)});else if(n.type===`quality`)q(n);else if(n.type===`codec`)j(typeof n.encoder==`string`?n.encoder:null);else if(n.type===`resolution`)V(typeof n.modeId==`string`?n.modeId:null),U(typeof n.original==`string`?n.original:null),G(null);else if(n.type===`resolutionError`)G(typeof n.message==`string`?n.message:`The host refused the mode.`);else if(n.type===`privacy`)L(n.enabled===!0),z(typeof n.reason==`string`?n.reason:null);else if(n.type===`audio`){let e=n.enabled===!0;if(F(e),!e){N.reset();return}let t=typeof n.channels==`number`?n.channels:2,r=typeof n.sampleRate==`number`?n.sampleRate:48e3;N.configure(t,r)}else if(n.type===`clipboard`&&typeof n.text==`string`){if(!O.current)return;let t=n.text;C(t).then(n=>{!n&&!e&&b(t)})}else n.type===`error`&&(a(`error`),u(typeof n.message==`string`?n.message:`Server error`));return}let n=new Uint8Array(t.data);if(!(n.length<1)){if(r.current+=n.length,n[0]===D){N.decodePacket(n.subarray(1));return}M.decodeAccessUnit(n.subarray(1),n[0]===1)}},l.onerror=()=>{e||(a(`error`),u(`WebSocket error`))},l.onclose=()=>{e||a(e=>e===`error`?e:`closed`)}})();let o=()=>{if(document.hidden||e)return;let t=n.current;t&&t.readyState===WebSocket.OPEN?t.send(JSON.stringify({type:`ping`})):f(e=>e+1)};return document.addEventListener(`visibilitychange`,o),()=>{e=!0,document.removeEventListener(`visibilitychange`,o),i&&clearInterval(i);try{n.current?.close()}catch{}n.current=null;try{M.reset()}catch{}try{N.reset()}catch{}}},[d,t]);let oe=(0,_.useCallback)(()=>f(e=>e+1),[]),se=(0,_.useCallback)(()=>r.current,[]);return{connState:i,errorMessage:o,decoderStatus:M.status,decoderErrorMessage:M.errorMessage,sendMessage:K,reconnect:oe,getTotalBytes:se,getFrameCount:M.getFrameCount,frameSize:M.frameSize,quality:p,setQuality:Y,setCustomQuality:X,showCursor:S,setShowCursor:ne,codec:A,setCodec:$,audioOn:P,setAudioOn:Q,getAudioTracks:N.getTracks,privacyOn:I,privacyError:R,setPrivacyOn:Z,hostModeId:B,hostOriginalModeId:H,resolutionError:W,setHostMode:te,pendingHostClipboard:v,clearHostClipboard:ae,sendClipboard:re,requestHostClipboard:ie}}function k(e){return Math.min(Math.max(e,0),1)}function A(e,t,n){let r=n.width>0?(e-n.left)/n.width:0,i=n.height>0?(t-n.top)/n.height:0;return{xFrac:k(r),yFrac:k(i)}}function j(e,t,n,r){let i=r.scale||1,a=n.left+n.width/2,o=n.top+n.height/2;return A(a+(e-a-r.panX)/i,o+(t-o-r.panY)/i,n)}function M(e,t,n){if(t<=0||n<=0||e.width<=0||e.height<=0)return e;let r=e.width/e.height,i=t/n;if(i>r){let t=e.width/i;return{left:e.left,top:e.top+(e.height-t)/2,width:e.width,height:t}}let a=e.height*i;return{left:e.left+(e.width-a)/2,top:e.top,width:a,height:e.height}}function N(e){let t=new Map;for(let n of e){if(n.width<=0||n.height<=0)continue;let e=`${n.width}x${n.height}`,r=t.get(e);(!r||P(n,r))&&t.set(e,n)}return[...t.values()].sort((e,t)=>t.width*t.height-e.width*e.height||t.refresh-e.refresh).map(e=>({id:e.id,width:e.width,height:e.height,refresh:e.refresh,current:e.current,preferred:e.preferred}))}function P(e,t){return e.current===t.current?e.preferred===t.preferred?e.refresh>t.refresh:e.preferred:e.current}function F(e,t,n){if(!t||t.width<=0||t.height<=0)return null;let r=e.filter(e=>e.width===t.width&&e.height===t.height);if(r.length===0)return null;let i=e.find(e=>e.id===n)??e.find(e=>e.current)??null;return i&&i.width===t.width&&i.height===t.height?null:r.reduce((e,t)=>P(t,e)?t:e)}function I(){if(typeof window>`u`||!window.screen)return null;let e=Math.round(window.screen.width),t=Math.round(window.screen.height);return e>0&&t>0?{width:e,height:t}:null}function L(e){let t=`${e.width} × ${e.height}`;return e.refresh>0?`${t} · ${e.refresh} Hz`:t}var R=[`video/mp4;codecs=avc1.42E01E,mp4a.40.2`,`video/mp4`,`video/webm;codecs=vp9,opus`,`video/webm;codecs=vp8,opus`,`video/webm`];function z(e=e=>typeof MediaRecorder<`u`&&MediaRecorder.isTypeSupported(e)){return typeof MediaRecorder>`u`?null:R.find(e)??null}function B(e){return e.startsWith(`video/mp4`)?`mp4`:`webm`}function V(e,t=new Date){let n=e=>String(e).padStart(2,`0`);return`ppm-remote-${`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}_${n(t.getHours())}-${n(t.getMinutes())}-${n(t.getSeconds())}`}.${e}`}function H(e,t){let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,r.rel=`noopener`,document.body.appendChild(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),1e4)}async function U(e){if(!e||e.width===0||e.height===0)return!1;let t=await new Promise(t=>e.toBlob(t,`image/png`));return t?(H(t,V(`png`)),!0):!1}function W(e,t){let n=(0,_.useRef)(null),r=(0,_.useRef)([]),[i,a]=(0,_.useState)(!1),[o,s]=(0,_.useState)(0),c=(0,_.useRef)(null);c.current===null&&(c.current=z());let l=(0,_.useCallback)(()=>{n.current?.stop()},[]),u=(0,_.useCallback)(()=>{let i=e.current,o=c.current;if(!i||!o||n.current)return;let l=i.captureStream();for(let e of t?.()??[])l.addTrack(e);let u;try{u=new MediaRecorder(l,{mimeType:o})}catch{return}r.current=[],u.ondataavailable=e=>{e.data.size>0&&r.current.push(e.data)},u.onstop=()=>{let e=new Blob(r.current,{type:o});r.current=[],n.current=null,a(!1),s(0),e.size>0&&H(e,V(B(o)))},u.start(1e3),n.current=u,a(!0),s(0)},[e,t]),d=(0,_.useCallback)(()=>{n.current?l():u()},[u,l]);return(0,_.useEffect)(()=>{if(!i)return;let e=Date.now(),t=setInterval(()=>{let t=Date.now()-e;s(Math.floor(t/1e3)),t>=72e5&&l()},1e3);return()=>clearInterval(t)},[i,l]),(0,_.useEffect)(()=>()=>{n.current?.stop()},[]),{recording:i,elapsedSec:o,supported:c.current!==null,toggle:d}}var G={fps:0,kbps:0};function K(e,t){let n=t.atMs-e.atMs;if(n<=0)return G;let r=n/1e3,i=Math.max(0,t.frameCount-e.frameCount),a=Math.max(0,t.totalBytes-e.totalBytes);return{fps:i/r,kbps:a/1024/r}}var q=n(),J=500;function Y({canvasRef:e,getFrameCount:t,getTotalBytes:n,positionClassName:r=`left-1 top-1`}){let i=l(e=>e.remoteDesktopStatsVisible),[a,o]=(0,_.useState)({fps:0,kbps:0,width:0,height:0}),s=(0,_.useRef)({frameCount:0,totalBytes:0,atMs:0});return(0,_.useEffect)(()=>{if(!i)return;s.current={frameCount:t(),totalBytes:n(),atMs:performance.now()};let r=setInterval(()=>{let r={frameCount:t(),totalBytes:n(),atMs:performance.now()},{fps:i,kbps:a}=K(s.current,r);s.current=r;let c=e.current;o({fps:i,kbps:a,width:c?.width??0,height:c?.height??0})},J);return()=>clearInterval(r)},[i,e,t,n]),i?(0,q.jsxs)(`div`,{className:`pointer-events-none absolute z-40 rounded bg-black/60 px-1.5 py-0.5 font-mono text-[10px] text-white/80 ${r}`,"data-testid":`remote-desktop-stats-overlay`,children:[Math.round(a.fps),` fps · `,Math.round(a.kbps),` KB/s · `,a.width,`×`,a.height]}):null}function X(){let{caps:e}=f(!1),t=e?.displays??[],[n,r]=(0,_.useState)(void 0),i=t.find(e=>e.id===n)??t.find(e=>e.primary)??t[0];return{displays:t,displayId:n,current:i,select:r,next:(0,_.useCallback)(()=>{t.length<2||r(t[(t.findIndex(e=>e.id===i?.id)+1)%t.length]?.id)},[t,i])}}function Z({pendingText:e,onDismiss:t,missingToolAction:n,onDismissMissingTool:a,positionClassName:s=`absolute bottom-2 left-1/2 max-w-[92%] -translate-x-1/2`}){let[c,l]=(0,_.useState)(!1);return e===null?n==null?null:(0,q.jsxs)(Q,{onDismiss:a??(()=>{}),testId:`remote-desktop-clipboard-missing-tool`,positionClassName:s,children:[(0,q.jsx)(o,{className:`size-4 shrink-0 text-amber-300`}),(0,q.jsx)(`span`,{className:`min-w-0 flex-1`,children:`The host has no clipboard tool installed.`}),n.kind===`terminal`&&(0,q.jsxs)(`button`,{type:`button`,onClick:()=>p(n.command),title:n.command,className:`inline-flex min-h-8 shrink-0 items-center gap-1.5 rounded bg-white/15 px-2.5 text-xs hover:bg-white/25`,children:[(0,q.jsx)(r,{className:`size-3.5`}),` `,n.label]})]}):(0,q.jsxs)(Q,{onDismiss:t,testId:`remote-desktop-clipboard-pending`,positionClassName:s,children:[(0,q.jsx)(i,{className:`size-4 shrink-0 text-emerald-400`}),(0,q.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[c?`Could not copy — select the text manually:`:`Copied on the host:`,(0,q.jsx)(`span`,{className:`ml-1 text-white/60`,children:$(e)})]}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>{S(e)?t():l(!0)},className:`min-h-8 shrink-0 rounded bg-white/15 px-2.5 text-xs hover:bg-white/25`,"data-testid":`remote-desktop-clipboard-copy`,children:`Copy here`})]})}function Q({children:e,onDismiss:t,testId:n,positionClassName:r}){return(0,q.jsxs)(`div`,{className:u(`z-50 flex items-center gap-2 rounded-lg border border-white/10 bg-black/85 px-3 py-2 text-xs text-white shadow-lg`,r),"data-testid":n,children:[e,(0,q.jsx)(`button`,{type:`button`,onClick:t,"aria-label":`Dismiss`,className:`flex size-8 shrink-0 items-center justify-center rounded text-white/60 hover:bg-white/10 hover:text-white`,children:(0,q.jsx)(a,{className:`size-3.5`})})]})}function $(e){let t=e.replace(/\s+/g,` `).trim();return t.length>60?`${t.slice(0,60)}…`:t}export{U as a,N as c,j as d,M as f,b as h,W as i,L as l,x as m,X as n,F as o,O as p,Y as r,I as s,Z as t,A as u};
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/remote-desktop-mobile-view-DPdGFD6C.js","assets/rolldown-runtime-C5c2KzVm.js","assets/index-CIscPw4g.js","assets/preload-helper-BEFjQwLd.js","assets/vendor-ui-P9Ym7hCv.js","assets/vendor-markdown-QKPNiWEd.js","assets/button-CsmGH5xa.js","assets/utils-btZ8C8-R.js","assets/createLucideIcon-DBXq3G0e.js","assets/api-client-F5Zi1sR0.js","assets/react-CzUPVyyG.js","assets/panel-store-1X6yM3XZ.js","assets/window-store-vo1N70nK.js","assets/project-store-CCimwgGF.js","assets/settings-store-DIV25PM_.js","assets/file-store-DCU7_YyB.js","assets/window-pip-registry-Bl--fK8-.js","assets/onboarding-quick-orientation-WLKI95GY.js","assets/dialog-z8PLkL8n.js","assets/portal-container-context-NFSuymMu.js","assets/icons-CO_II6D-.js","assets/use-is-mobile-CkO33jqU.js","assets/format-file-meta-B0ZpqzSM.js","assets/fs-api-vF_bQoeL.js","assets/context-menu-CH1mvCwA.js","assets/input-CP31LZnN.js","assets/mobile-bottom-sheet-CLic9ovp.js","assets/use-visual-viewport-C307OVeV.js","assets/scroll-area-Dp-P38kg.js","assets/chat-preparation-cache-DoS7sdal.js","assets/file-icons-Ed_yLyef.js","assets/format-date-Fd9tpNaw.js","assets/git-repo-store-CdoOpvmf.js","assets/ws-auth-J3hw0Mhc.js","assets/tab-store-D33icgdA.js","assets/apply-theme-aVoqSG0I.js","assets/resolve-theme-B87m6l4i.js","assets/index-BmsPSBtF.css","assets/remote-desktop-clipboard-notice-DEbdu0hC.js","assets/run-in-terminal-B_PCeBqG.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import{C as t,S as n}from"./vendor-markdown-QKPNiWEd.js";import{_t as r}from"./vendor-ui-P9Ym7hCv.js";import"./icons-CO_II6D-.js";import"./api-client-F5Zi1sR0.js";import"./settings-store-DIV25PM_.js";import{t as i}from"./preload-helper-BEFjQwLd.js";import{n as a}from"./portal-container-context-NFSuymMu.js";import"./panel-store-1X6yM3XZ.js";import"./window-store-vo1N70nK.js";import"./project-store-CCimwgGF.js";import{et as o}from"./index-CIscPw4g.js";import"./run-in-terminal-B_PCeBqG.js";import{n as s,t as c}from"./remote-desktop-readiness-gate-DV7YgSpP.js";var l=e(t(),1),u=e(r(),1),d=n(),f=(0,l.lazy)(()=>i(()=>import(`./remote-desktop-mobile-view-DPdGFD6C.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39])));function p(){let e=o(e=>e.isOpen),t=o(e=>e.close),n=a();return e?(0,u.createPortal)((0,d.jsx)(`div`,{className:`fixed inset-0 z-[45] bg-black`,"data-testid":`remote-desktop-mobile-sheet`,children:(0,d.jsx)(s,{onCancel:t,children:(0,d.jsx)(c,{onCancel:t,children:(0,d.jsx)(l.Suspense,{fallback:(0,d.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-text-2`,children:`Loading…`}),children:(0,d.jsx)(f,{onClose:t})})})})}),n??document.getElementById(`root`)??document.body):null}export{p as RemoteDesktopMobileSheet};
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import{C as t,S as n}from"./vendor-markdown-QKPNiWEd.js";import"./vendor-ui-P9Ym7hCv.js";import{En as r,Gr as i,Gt as a,Jr as o,Mn as s,Nt as c,On as l,Qt as u,Ur as d,W as f,or as p,pr as m,ti as h,ut as g,xr as _,z as v,zt as y}from"./icons-CO_II6D-.js";import"./api-client-F5Zi1sR0.js";import{D as b,T as x,t as S}from"./settings-store-3jIBB8gx.js";import{n as C}from"./utils-btZ8C8-R.js";import"./panel-store-DrSH3Nhp.js";import"./window-store-B4cbZ5rr.js";import"./project-store-CCimwgGF.js";import{t as w}from"./use-visual-viewport-C307OVeV.js";import"./ws-auth-J3hw0Mhc.js";import{Z as ee}from"./index-DQCw6d-2.js";import"./run-in-terminal-Cdn9PaAl.js";import{a as T,c as te,d as E,f as D,i as ne,n as re,o as O,p as k,r as A,s as ie,t as j}from"./remote-desktop-clipboard-notice-Bs3fZSRw.js";var M=e(t(),1);function ae(e,t,n=10,r=300){let i=Math.hypot(t.x-e.x,t.y-e.y),a=t.t-e.t;return i<=n&&a<=r}function oe(e,t,n=15){return Math.abs(t-e)>n?`pinch`:`scroll`}function N(e,t){return Math.hypot(t.x-e.x,t.y-e.y)}function P(e,t){return{x:(e.x+t.x)/2,y:(e.y+t.y)/2}}function F(e,t,n){return Math.min(Math.max(e,t),n)}function I(e,t,n){return[{type:`pointer`,xFrac:e,yFrac:t,button:n,down:!0},{type:`pointer`,xFrac:e,yFrac:t,button:n,down:!1}]}function se(e,t,n){return{start:{x:e,y:t,t:performance.now()},last:{x:e,y:t},moved:!1,rect:n}}function ce(e,t,n,r,i,a){let o=Math.hypot(t-e.start.x,n-e.start.y);if(r===`touch`){if(!e.moved&&o>10){e.moved=!0;let r=E(e.start.x,e.start.y,e.rect,i);return e.last={x:t,y:n},{message:{type:`pointer`,xFrac:r.xFrac,yFrac:r.yFrac,button:`left`,down:!0}}}if(e.last={x:t,y:n},!e.moved)return{};let r=E(t,n,e.rect,i);return{message:{type:`pointer`,xFrac:r.xFrac,yFrac:r.yFrac,button:null,down:null}}}let s=(t-e.last.x)/i.scale,c=(n-e.last.y)/i.scale;return o>10&&(e.moved=!0),e.last={x:t,y:n},{cursor:{xFrac:F(a.xFrac+s/e.rect.width,0,1),yFrac:F(a.yFrac+c/e.rect.height,0,1)},sendCursorMove:!0}}function L(e,t,n,r,i,a){let o={x:t,y:n,t:performance.now()},s=ae(e.start,o,10,300);if(r===`touch`){let r=E(t,n,e.rect,i);return!e.moved&&s?I(r.xFrac,r.yFrac,`left`):e.moved?[{type:`pointer`,xFrac:r.xFrac,yFrac:r.yFrac,button:`left`,down:!1}]:[]}return!e.moved&&s?I(a.xFrac,a.yFrac,`left`):[]}function R(e,t,n){let r=P(e,t);return{startDistance:N(e,t),startMid:r,lastMid:r,startScale:n,startTime:performance.now(),gesture:null}}function le(e,t,n,r){let i=N(t,n),a=P(t,n);if(e.gesture===null){let t=Math.abs(i-e.startDistance),n=N(e.startMid,a);if(t>15)e.gesture=oe(e.startDistance,i,15);else if(n>15)e.gesture=`scroll`;else return e.lastMid=a,{}}let o;if(e.gesture===`pinch`)o={transform:{scale:F(e.startScale*(i/e.startDistance),1,4),panX:r.panX,panY:r.panY}};else if(r.scale>1.01){let t=a.x-e.lastMid.x,n=a.y-e.lastMid.y;o={transform:{scale:r.scale,panX:r.panX+t,panY:r.panY+n}}}else o={wheelDeltaPx:a.y-e.lastMid.y};return e.lastMid=a,o}function z(e,t,n){if(e.gesture===null&&performance.now()-e.startTime<=300){let r=E(e.lastMid.x,e.lastMid.y,t,n);return I(r.xFrac,r.yFrac,`right`)}return[]}var B={scale:1,panX:0,panY:0},ue=40,de=120;function fe({containerRef:e,canvasRef:t,mode:n,sendMessage:r,enabled:i}){let[a,o]=(0,M.useState)(B),[s,c]=(0,M.useState)({xFrac:.5,yFrac:.5}),l=(0,M.useRef)(a),u=(0,M.useRef)(s),d=(0,M.useRef)(n);d.current=n;let f=(0,M.useRef)({transform:null,cursor:null,sendCursorMove:!1,wheelPx:0}),p=(0,M.useRef)(0),m=(0,M.useCallback)(()=>{p.current=0;let e=f.current;e.transform&&=(l.current=e.transform,o(e.transform),null),e.cursor&&(u.current=e.cursor,c(e.cursor),e.sendCursorMove&&r({type:`pointer`,xFrac:e.cursor.xFrac,yFrac:e.cursor.yFrac,button:null,down:null}),e.cursor=null,e.sendCursorMove=!1),e.wheelPx!==0&&(r({type:`wheel`,dy:-(e.wheelPx/ue)*de}),e.wheelPx=0)},[r]),h=(0,M.useCallback)(()=>{p.current||=requestAnimationFrame(m)},[m]),g=(0,M.useCallback)(()=>{l.current=B,o(B)},[]);return(0,M.useEffect)(()=>{let n=e.current;if(!n||!i)return;let a=null,o=null,s=e=>e.forEach(r),c=()=>{let e=n.getBoundingClientRect(),r=t.current;return!r||!r.width||!r.height?e:D(e,r.width,r.height)},m=e=>{e.preventDefault(),e.stopPropagation();let t=c();if(e.touches.length===1){o=null;let n=e.touches[0];a=se(n.clientX,n.clientY,t)}else if(e.touches.length===2){a=null;let[t,n]=[e.touches[0],e.touches[1]];o=R({x:t.clientX,y:t.clientY},{x:n.clientX,y:n.clientY},l.current.scale)}else a=null,o=null},g=e=>{if(e.preventDefault(),e.stopPropagation(),a&&e.touches.length===1){let t=e.touches[0],n=ce(a,t.clientX,t.clientY,d.current,l.current,u.current);n.message&&r(n.message),n.cursor&&(u.current=n.cursor,f.current.cursor=n.cursor,f.current.sendCursorMove=!!n.sendCursorMove,h());return}if(o&&e.touches.length===2){let[t,n]=[e.touches[0],e.touches[1]],r=le(o,{x:t.clientX,y:t.clientY},{x:n.clientX,y:n.clientY},l.current);r.transform&&(l.current=r.transform,f.current.transform=r.transform,h()),r.wheelDeltaPx&&(f.current.wheelPx+=r.wheelDeltaPx,h())}},_=e=>{e.preventDefault(),e.stopPropagation();let t=e.changedTouches[0];if(a){let e=t?t.clientX:a.last.x,n=t?t.clientY:a.last.y;s(L(a,e,n,d.current,l.current,u.current)),a=null}o&&=(s(z(o,c(),l.current)),null)},v=e=>{e.stopPropagation(),a?.moved&&d.current===`touch`&&s(L(a,a.last.x,a.last.y,`touch`,l.current,u.current)),a=null,o=null};return n.addEventListener(`touchstart`,m,{passive:!1}),n.addEventListener(`touchmove`,g,{passive:!1}),n.addEventListener(`touchend`,_,{passive:!1}),n.addEventListener(`touchcancel`,v,{passive:!1}),()=>{p.current&&cancelAnimationFrame(p.current),n.removeEventListener(`touchstart`,m),n.removeEventListener(`touchmove`,g),n.removeEventListener(`touchend`,_),n.removeEventListener(`touchcancel`,v)}},[e,t,i,r,h]),{transform:a,virtualCursor:n===`mouse`?s:null,resetZoom:g}}function V(e,t,n){let r=e=>{n({type:`key`,code:e,down:!0}),n({type:`key`,code:e,down:!1})};switch(e){case`insertText`:return t&&n({type:`text`,text:t}),!0;case`insertLineBreak`:case`insertParagraph`:return r(`Enter`),!0;case`deleteContentBackward`:return r(`Backspace`),!0;case`deleteContentForward`:return r(`Delete`),!0;default:return!1}}function pe(e,t,n){let r=(0,M.useRef)(null);return(0,M.useEffect)(()=>{let i=r.current;if(!i||!t)return;let a=()=>e({type:`releaseAll`}),o=e=>e.code!==``&&e.key!==`Unidentified`,s=t=>{o(t)&&(t.preventDefault(),e({type:`key`,code:t.code,down:!0}))},c=t=>{o(t)&&(t.preventDefault(),e({type:`key`,code:t.code,down:!1}))},l=t=>{V(t.inputType,t.data,e)&&t.preventDefault()},u=t=>{t.data&&e({type:`text`,text:t.data}),i.value=``},d=e=>{let t=e.clipboardData?.getData(`text/plain`);!t||!n||(e.preventDefault(),n(t))},f=()=>a(),p=()=>{document.hidden&&a()};return i.addEventListener(`keydown`,s),i.addEventListener(`keyup`,c),i.addEventListener(`beforeinput`,l),i.addEventListener(`compositionend`,u),i.addEventListener(`paste`,d),i.addEventListener(`blur`,f),document.addEventListener(`visibilitychange`,p),()=>{i.removeEventListener(`keydown`,s),i.removeEventListener(`keyup`,c),i.removeEventListener(`beforeinput`,l),i.removeEventListener(`compositionend`,u),i.removeEventListener(`paste`,d),i.removeEventListener(`blur`,f),document.removeEventListener(`visibilitychange`,p),a()}},[t,e,n]),{inputRef:r,show:(0,M.useCallback)(()=>r.current?.focus(),[])}}var H=n();function U({onClick:e,label:t,active:n,children:r}){return(0,H.jsxs)(`button`,{type:`button`,onClick:e,"aria-label":t,className:C(`flex min-h-11 min-w-11 flex-1 flex-col items-center justify-center gap-0.5 rounded-lg py-1.5 text-[10px]`,`text-white/80 active:bg-white/10 transition-colors`,n&&`bg-white/15 text-white`),children:[r,(0,H.jsx)(`span`,{children:t})]})}function me({displayLabel:e,onNextDisplay:t,qualityLabel:n,onNextQuality:a,mode:c,onToggleMode:l,onOpenKeyboard:d,onResetZoom:f,settingsOpen:p,onToggleSettings:g,onClose:_}){return(0,H.jsxs)(`div`,{className:`flex shrink-0 items-stretch gap-1 border-t border-white/10 bg-black/90 px-2 pb-[max(0.375rem,env(safe-area-inset-bottom))] pt-1.5`,"data-testid":`remote-desktop-mobile-toolbar`,children:[(0,H.jsx)(U,{onClick:l,label:c===`mouse`?`Mouse`:`Touch`,active:!0,children:c===`mouse`?(0,H.jsx)(s,{className:`size-5`}):(0,H.jsx)(y,{className:`size-5`})}),(0,H.jsx)(U,{onClick:d,label:`Keyboard`,children:(0,H.jsx)(u,{className:`size-5`})}),(0,H.jsx)(U,{onClick:f,label:`Reset zoom`,children:(0,H.jsx)(h,{className:`size-5`})}),e!==null&&(0,H.jsx)(U,{onClick:t,label:e.length>10?`${e.slice(0,9)}…`:e,children:(0,H.jsx)(r,{className:`size-5`})}),(0,H.jsx)(U,{onClick:a,label:n,children:(0,H.jsx)(i,{className:`size-5`})}),(0,H.jsx)(U,{onClick:g,label:`More`,active:p,children:(0,H.jsx)(m,{className:`size-5`})}),(0,H.jsx)(U,{onClick:_,label:`Close`,children:(0,H.jsx)(o,{className:`size-5`})})]})}function W(e){return(e.includes(`ControlLeft`)||e.includes(`MetaLeft`))&&(e.includes(`KeyC`)||e.includes(`KeyX`))}var G=[{label:`Ctrl`,code:`ControlLeft`},{label:`Alt`,code:`AltLeft`},{label:`Shift`,code:`ShiftLeft`},{label:`Win`,code:`MetaLeft`}],K=[{label:`Esc`,code:`Escape`},{label:`Tab`,code:`Tab`},{label:`←`,code:`ArrowLeft`},{label:`↑`,code:`ArrowUp`},{label:`↓`,code:`ArrowDown`},{label:`→`,code:`ArrowRight`}],q=[{label:`Ctrl+C`,codes:[`ControlLeft`,`KeyC`]},{label:`Ctrl+V`,codes:[`ControlLeft`,`KeyV`]},{label:`Ctrl+Z`,codes:[`ControlLeft`,`KeyZ`]},{label:`Ctrl+A`,codes:[`ControlLeft`,`KeyA`]},{label:`Alt+Tab`,codes:[`AltLeft`,`Tab`]},{label:`Ctrl+Alt+Del`,codes:[`ControlLeft`,`AltLeft`,`Delete`]}];function J({onClick:e,active:t,className:n,children:r}){return(0,H.jsx)(`button`,{type:`button`,onClick:e,className:C(`min-h-11 min-w-11 shrink-0 whitespace-nowrap rounded-md px-2.5 text-xs font-medium text-white/80`,`active:bg-white/15 transition-colors`,t&&`bg-primary text-primary-foreground`,n),children:r})}function he({sendMessage:e,onCopyCombo:t}){let[n,r]=(0,M.useState)(new Set),i=(0,M.useRef)(n);i.current=n,(0,M.useEffect)(()=>()=>{i.current.forEach(t=>e({type:`key`,code:t,down:!1}))},[e]);let a=(0,M.useCallback)(t=>{r(n=>{let r=n.has(t);e({type:`key`,code:t,down:!r});let i=new Set(n);return r?i.delete(t):i.add(t),i})},[e]),o=(0,M.useCallback)(t=>{e({type:`key`,code:t,down:!0}),e({type:`key`,code:t,down:!1})},[e]),s=(0,M.useCallback)(n=>{n.forEach(t=>e({type:`key`,code:t,down:!0})),[...n].reverse().forEach(t=>e({type:`key`,code:t,down:!1})),W(n)&&t?.()},[e,t]);return(0,H.jsxs)(`div`,{className:`flex shrink-0 gap-1 overflow-x-auto border-t border-white/10 bg-black/90 px-2 py-1.5`,"data-testid":`remote-desktop-mobile-key-bar`,children:[G.map(e=>(0,H.jsx)(J,{onClick:()=>a(e.code),active:n.has(e.code),children:e.label},e.code)),(0,H.jsx)(`div`,{className:`mx-0.5 w-px shrink-0 bg-white/10`}),K.map(e=>(0,H.jsx)(J,{onClick:()=>o(e.code),children:e.label},e.code)),(0,H.jsx)(`div`,{className:`mx-0.5 w-px shrink-0 bg-white/10`}),q.map(e=>(0,H.jsx)(J,{onClick:()=>s(e.codes),children:e.label},e.label))]})}function Y({icon:e,label:t,hint:n,checked:r,onToggle:i,testId:a,disabled:o}){return(0,H.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":r,disabled:o,onClick:i,"data-testid":a,className:`flex min-h-11 w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-white/80 active:bg-white/10 disabled:opacity-50`,children:[(0,H.jsx)(`span`,{className:`shrink-0 opacity-80`,children:e}),(0,H.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`span`,{className:`block truncate text-xs`,children:t}),n&&(0,H.jsx)(`span`,{className:`block truncate text-[10px] text-white/45`,children:n})]}),(0,H.jsx)(`span`,{className:C(`relative h-5 w-9 shrink-0 rounded-full transition-colors`,r?`bg-primary`:`bg-white/20`),children:(0,H.jsx)(`span`,{className:C(`absolute top-0.5 size-4 rounded-full bg-white transition-all`,r?`left-[1.125rem]`:`left-0.5`)})})]})}function ge({statsVisible:e,onToggleStats:t,showCursor:n,onSetShowCursor:r,clipboardEnabled:i,onSetClipboardEnabled:o,audioOn:l,audioReason:u,onSetAudioOn:p,privacyOn:m,privacyReason:h,onSetPrivacyOn:y,hostModes:b,hostModeId:x,hostOriginalModeId:S,onSetHostMode:w,canResizeHost:ee,resolutionError:T,recording:E,recordingSupported:D,onToggleRecording:ne,onScreenshot:re}){let k=(0,M.useMemo)(()=>te(b),[b]),A=(0,M.useMemo)(()=>ie(),[]),j=(0,M.useMemo)(()=>O(b,A,x),[b,A,x]);return(0,H.jsxs)(`div`,{className:`mx-2 mb-1 space-y-0.5 rounded-xl border border-white/10 bg-black/90 p-1`,"data-testid":`remote-desktop-mobile-settings`,children:[(0,H.jsx)(Y,{icon:(0,H.jsx)(c,{className:`size-4`}),label:`Quality monitor`,checked:e,onToggle:t,testId:`remote-desktop-mobile-stats-toggle`}),(0,H.jsx)(Y,{icon:(0,H.jsx)(s,{className:`size-4`}),label:`Show remote cursor`,hint:`Restarts the stream`,checked:n,onToggle:()=>r(!n),testId:`remote-desktop-mobile-cursor-toggle`}),(0,H.jsx)(Y,{icon:(0,H.jsx)(f,{className:`size-4`}),label:`Sync clipboard`,hint:`Off: Ctrl+V pastes the host's own clipboard`,checked:i,onToggle:()=>o(!i),testId:`remote-desktop-mobile-clipboard-toggle`}),(0,H.jsx)(Y,{icon:(0,H.jsx)(d,{className:`size-4`}),label:`Play host audio`,hint:u??void 0,checked:l,disabled:u!==null,onToggle:()=>p(!l),testId:`remote-desktop-mobile-audio-toggle`}),(0,H.jsx)(Y,{icon:(0,H.jsx)(g,{className:`size-4`}),label:`Privacy mode`,hint:h??`Blocks the host's own keyboard and mouse`,checked:m,disabled:h!==null&&!m,onToggle:()=>y(!m),testId:`remote-desktop-mobile-privacy-toggle`}),ee&&k.length>1&&(0,H.jsxs)(`div`,{className:`px-3 pt-1`,children:[(0,H.jsx)(`div`,{className:`pb-1.5 text-[10px] uppercase tracking-wide text-white/40`,children:`Resolution`}),(0,H.jsxs)(`div`,{className:`flex max-h-28 flex-wrap gap-1.5 overflow-y-auto`,children:[S&&S!==x&&(0,H.jsx)(`button`,{type:`button`,onClick:()=>w(S),"data-testid":`remote-desktop-mobile-resolution-original`,className:`min-h-9 rounded-md bg-white/10 px-2.5 py-1 text-[11px] text-white/70 active:bg-white/20`,children:`Original`}),j&&(0,H.jsx)(`button`,{type:`button`,onClick:()=>w(j.id),"data-testid":`remote-desktop-mobile-resolution-fit-local`,className:`min-h-9 rounded-md bg-white/10 px-2.5 py-1 text-[11px] text-white/70 active:bg-white/20`,children:`Fit local`}),k.map(e=>{let t=(x??k.find(e=>e.current)?.id)===e.id;return(0,H.jsxs)(`button`,{type:`button`,onClick:()=>w(e.id),"data-testid":`remote-desktop-mobile-resolution-${e.width}x${e.height}`,className:C(`min-h-9 rounded-md px-2.5 py-1 text-[11px] tabular-nums`,t?`bg-white/25 text-white`:`bg-white/10 text-white/70 active:bg-white/20`),children:[e.width,`×`,e.height]},e.id)})]}),T&&(0,H.jsx)(`div`,{className:`pt-1.5 text-[10px] leading-tight text-red-400`,children:T})]}),(0,H.jsxs)(`button`,{type:`button`,onClick:re,"data-testid":`remote-desktop-mobile-screenshot`,className:`flex min-h-11 w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-xs text-white/80 active:bg-white/10`,children:[(0,H.jsx)(a,{className:`size-4 opacity-80`}),` Save screenshot`]}),D&&(0,H.jsx)(`button`,{type:`button`,onClick:ne,"data-testid":`remote-desktop-mobile-record`,className:`flex min-h-11 w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-xs text-white/80 active:bg-white/10`,children:E?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(_,{className:`size-4 text-red-500`}),` Stop recording`]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(v,{className:`size-4 opacity-80`}),` Start recording`]})})]})}function X({onClose:e}){let t=(0,M.useRef)(null),n=(0,M.useRef)(null),[r,i]=(0,M.useState)(`mouse`),[a,o]=(0,M.useState)(!1),[s,c]=(0,M.useState)(!1),u=re(),{connState:d,errorMessage:f,decoderStatus:m,decoderErrorMessage:h,sendMessage:g,reconnect:_,getTotalBytes:v,getFrameCount:y,quality:C,setQuality:te,showCursor:E,setShowCursor:O,audioOn:ie,setAudioOn:ae,getAudioTracks:oe,privacyOn:N,privacyError:P,setPrivacyOn:F,hostModeId:I,hostOriginalModeId:se,resolutionError:ce,setHostMode:L,pendingHostClipboard:R,clearHostClipboard:le,sendClipboard:z,requestHostClipboard:B}=k(n,{displayId:u.displayId}),ue=S(e=>e.remoteDesktopStatsVisible),de=S(e=>e.toggleRemoteDesktopStatsVisible),V=S(e=>e.remoteDesktopClipboardSync),U=S(e=>e.setRemoteDesktopClipboardSync),W=S(e=>e.remoteDesktopQuality),G=d===`streaming`,{transform:K,virtualCursor:q,resetZoom:J}=fe({containerRef:t,canvasRef:n,mode:r,sendMessage:g,enabled:G}),[Y,X]=(0,M.useState)(!1),_e=(0,M.useCallback)(e=>{X(!0),z(e,!0)},[z]),{caps:Z}=ee(!1),Q=ne(n,oe),{inputRef:ve,show:ye}=pe(g,G,V?_e:void 0),$=w(!0)?.keyboardInset??0,be=(0,M.useCallback)(()=>i(e=>e===`mouse`?`touch`:`mouse`),[]),xe=(0,M.useCallback)(()=>{ye(),o(!0)},[ye]),Se=m===`unsupported`?h:d===`error`?f:d===`closed`?`Disconnected`:d===`connecting`?`Connecting…`:null,Ce={transform:`translate(${K.panX}px, ${K.panY}px) scale(${K.scale})`},we=`${(q?.xFrac??.5)*100}%`,Te=`${(q?.yFrac??.5)*100}%`;if(q&&t.current&&n.current?.width&&n.current.height){let e=t.current.getBoundingClientRect(),r=D({left:0,top:0,width:e.width,height:e.height},n.current.width,n.current.height);we=`${r.left+q.xFrac*r.width}px`,Te=`${r.top+q.yFrac*r.height}px`}return(0,H.jsxs)(`div`,{className:`relative h-full w-full bg-black`,"data-testid":`remote-desktop-mobile-view`,"data-conn-state":d,children:[(0,H.jsxs)(`div`,{ref:t,className:`absolute inset-x-0 top-0 flex items-center justify-center overflow-hidden`,style:{touchAction:`none`,bottom:$},"data-testid":`remote-desktop-mobile-stage-container`,children:[(0,H.jsxs)(`div`,{className:`relative flex h-full w-full items-center justify-center`,style:Ce,children:[(0,H.jsx)(`canvas`,{ref:n,"data-testid":`remote-desktop-canvas`,className:`block h-full w-full min-h-0 min-w-0 object-contain outline-none`}),r===`mouse`&&q&&G&&(0,H.jsx)(`div`,{className:`pointer-events-none absolute rounded-full border-2 border-white bg-primary shadow-[0_0_0_1px_rgba(0,0,0,0.6)]`,style:{left:we,top:Te,width:14,height:14,transform:`translate(-50%, -50%) scale(${1/K.scale})`},"data-testid":`remote-desktop-virtual-cursor`})]}),Se&&(0,H.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-3 bg-black/70 text-sm text-white`,children:[(0,H.jsx)(l,{className:`size-6 opacity-70`}),(0,H.jsx)(`span`,{className:`max-w-sm px-4 text-center`,children:Se}),(d===`error`||d===`closed`)&&m!==`unsupported`&&(0,H.jsxs)(`button`,{onClick:_,className:`flex items-center gap-1.5 rounded-md bg-white/10 px-3 py-1.5 hover:bg-white/20`,children:[(0,H.jsx)(p,{className:`size-3.5`}),` Reconnect`]})]}),(0,H.jsx)(`input`,{ref:ve,type:`text`,autoComplete:`off`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,className:`absolute size-px opacity-0`,"aria-hidden":`true`,tabIndex:-1,onBlur:()=>o(!1),"data-testid":`remote-desktop-virtual-keyboard-input`})]}),(0,H.jsxs)(`div`,{className:`absolute inset-x-0 bottom-0`,style:$>0?{transform:`translateY(-${$}px)`}:void 0,"data-testid":`remote-desktop-mobile-bottom-bar`,children:[(0,H.jsx)(j,{pendingText:R,onDismiss:le,missingToolAction:Y&&Z&&!Z.clipboard.available?Z.clipboard.action:null,onDismissMissingTool:()=>X(!1),positionClassName:`mx-2 mb-1 max-w-[calc(100%-1rem)]`}),s&&(0,H.jsx)(ge,{statsVisible:ue,onToggleStats:de,showCursor:E,onSetShowCursor:O,clipboardEnabled:V,onSetClipboardEnabled:U,audioOn:ie,audioReason:Z&&!Z.audio.available?Z.audio.reason:null,onSetAudioOn:ae,privacyOn:N,privacyReason:P??(Z&&!Z.privacy.available?Z.privacy.reason:null),hostModes:Z?.resolutions?.modes??[],hostModeId:I,hostOriginalModeId:se,onSetHostMode:L,canResizeHost:Z?.inputReady??!1,resolutionError:ce,onSetPrivacyOn:F,recording:Q.recording,recordingSupported:Q.supported,onToggleRecording:Q.toggle,onScreenshot:()=>void T(n.current)}),a&&(0,H.jsx)(he,{sendMessage:g,onCopyCombo:V?B:void 0}),(0,H.jsx)(me,{displayLabel:u.displays.length>1?u.current?.label??null:null,onNextDisplay:u.next,qualityLabel:b(W),onNextQuality:()=>te(x(W)),mode:r,onToggleMode:be,onOpenKeyboard:xe,onResetZoom:J,settingsOpen:s,onToggleSettings:()=>c(e=>!e),onClose:e})]}),(0,H.jsx)(A,{canvasRef:n,getFrameCount:y,getTotalBytes:v,positionClassName:`left-1 top-[calc(env(safe-area-inset-top,0px)+2.75rem)]`})]})}export{X as default};
|
|
1
|
+
import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import{C as t,S as n}from"./vendor-markdown-QKPNiWEd.js";import"./vendor-ui-P9Ym7hCv.js";import{En as r,Gr as i,Gt as a,Jr as o,Mn as s,Nt as c,On as l,Qt as u,Ur as d,W as f,or as p,pr as m,ti as h,ut as g,xr as _,z as v,zt as y}from"./icons-CO_II6D-.js";import"./api-client-F5Zi1sR0.js";import{D as b,T as x,t as S}from"./settings-store-DIV25PM_.js";import{n as C}from"./utils-btZ8C8-R.js";import"./panel-store-1X6yM3XZ.js";import"./window-store-vo1N70nK.js";import"./project-store-CCimwgGF.js";import{t as w}from"./use-visual-viewport-C307OVeV.js";import"./ws-auth-J3hw0Mhc.js";import{$ as ee}from"./index-CIscPw4g.js";import"./run-in-terminal-B_PCeBqG.js";import{a as T,c as te,d as E,f as D,i as ne,n as re,o as O,p as k,r as A,s as ie,t as j}from"./remote-desktop-clipboard-notice-DEbdu0hC.js";var M=e(t(),1);function ae(e,t,n=10,r=300){let i=Math.hypot(t.x-e.x,t.y-e.y),a=t.t-e.t;return i<=n&&a<=r}function oe(e,t,n=15){return Math.abs(t-e)>n?`pinch`:`scroll`}function N(e,t){return Math.hypot(t.x-e.x,t.y-e.y)}function P(e,t){return{x:(e.x+t.x)/2,y:(e.y+t.y)/2}}function F(e,t,n){return Math.min(Math.max(e,t),n)}function I(e,t,n){return[{type:`pointer`,xFrac:e,yFrac:t,button:n,down:!0},{type:`pointer`,xFrac:e,yFrac:t,button:n,down:!1}]}function se(e,t,n){return{start:{x:e,y:t,t:performance.now()},last:{x:e,y:t},moved:!1,rect:n}}function ce(e,t,n,r,i,a){let o=Math.hypot(t-e.start.x,n-e.start.y);if(r===`touch`){if(!e.moved&&o>10){e.moved=!0;let r=E(e.start.x,e.start.y,e.rect,i);return e.last={x:t,y:n},{message:{type:`pointer`,xFrac:r.xFrac,yFrac:r.yFrac,button:`left`,down:!0}}}if(e.last={x:t,y:n},!e.moved)return{};let r=E(t,n,e.rect,i);return{message:{type:`pointer`,xFrac:r.xFrac,yFrac:r.yFrac,button:null,down:null}}}let s=(t-e.last.x)/i.scale,c=(n-e.last.y)/i.scale;return o>10&&(e.moved=!0),e.last={x:t,y:n},{cursor:{xFrac:F(a.xFrac+s/e.rect.width,0,1),yFrac:F(a.yFrac+c/e.rect.height,0,1)},sendCursorMove:!0}}function L(e,t,n,r,i,a){let o={x:t,y:n,t:performance.now()},s=ae(e.start,o,10,300);if(r===`touch`){let r=E(t,n,e.rect,i);return!e.moved&&s?I(r.xFrac,r.yFrac,`left`):e.moved?[{type:`pointer`,xFrac:r.xFrac,yFrac:r.yFrac,button:`left`,down:!1}]:[]}return!e.moved&&s?I(a.xFrac,a.yFrac,`left`):[]}function R(e,t,n){let r=P(e,t);return{startDistance:N(e,t),startMid:r,lastMid:r,startScale:n,startTime:performance.now(),gesture:null}}function le(e,t,n,r){let i=N(t,n),a=P(t,n);if(e.gesture===null){let t=Math.abs(i-e.startDistance),n=N(e.startMid,a);if(t>15)e.gesture=oe(e.startDistance,i,15);else if(n>15)e.gesture=`scroll`;else return e.lastMid=a,{}}let o;if(e.gesture===`pinch`)o={transform:{scale:F(e.startScale*(i/e.startDistance),1,4),panX:r.panX,panY:r.panY}};else if(r.scale>1.01){let t=a.x-e.lastMid.x,n=a.y-e.lastMid.y;o={transform:{scale:r.scale,panX:r.panX+t,panY:r.panY+n}}}else o={wheelDeltaPx:a.y-e.lastMid.y};return e.lastMid=a,o}function z(e,t,n){if(e.gesture===null&&performance.now()-e.startTime<=300){let r=E(e.lastMid.x,e.lastMid.y,t,n);return I(r.xFrac,r.yFrac,`right`)}return[]}var B={scale:1,panX:0,panY:0},ue=40,de=120;function fe({containerRef:e,canvasRef:t,mode:n,sendMessage:r,enabled:i}){let[a,o]=(0,M.useState)(B),[s,c]=(0,M.useState)({xFrac:.5,yFrac:.5}),l=(0,M.useRef)(a),u=(0,M.useRef)(s),d=(0,M.useRef)(n);d.current=n;let f=(0,M.useRef)({transform:null,cursor:null,sendCursorMove:!1,wheelPx:0}),p=(0,M.useRef)(0),m=(0,M.useCallback)(()=>{p.current=0;let e=f.current;e.transform&&=(l.current=e.transform,o(e.transform),null),e.cursor&&(u.current=e.cursor,c(e.cursor),e.sendCursorMove&&r({type:`pointer`,xFrac:e.cursor.xFrac,yFrac:e.cursor.yFrac,button:null,down:null}),e.cursor=null,e.sendCursorMove=!1),e.wheelPx!==0&&(r({type:`wheel`,dy:-(e.wheelPx/ue)*de}),e.wheelPx=0)},[r]),h=(0,M.useCallback)(()=>{p.current||=requestAnimationFrame(m)},[m]),g=(0,M.useCallback)(()=>{l.current=B,o(B)},[]);return(0,M.useEffect)(()=>{let n=e.current;if(!n||!i)return;let a=null,o=null,s=e=>e.forEach(r),c=()=>{let e=n.getBoundingClientRect(),r=t.current;return!r||!r.width||!r.height?e:D(e,r.width,r.height)},m=e=>{e.preventDefault(),e.stopPropagation();let t=c();if(e.touches.length===1){o=null;let n=e.touches[0];a=se(n.clientX,n.clientY,t)}else if(e.touches.length===2){a=null;let[t,n]=[e.touches[0],e.touches[1]];o=R({x:t.clientX,y:t.clientY},{x:n.clientX,y:n.clientY},l.current.scale)}else a=null,o=null},g=e=>{if(e.preventDefault(),e.stopPropagation(),a&&e.touches.length===1){let t=e.touches[0],n=ce(a,t.clientX,t.clientY,d.current,l.current,u.current);n.message&&r(n.message),n.cursor&&(u.current=n.cursor,f.current.cursor=n.cursor,f.current.sendCursorMove=!!n.sendCursorMove,h());return}if(o&&e.touches.length===2){let[t,n]=[e.touches[0],e.touches[1]],r=le(o,{x:t.clientX,y:t.clientY},{x:n.clientX,y:n.clientY},l.current);r.transform&&(l.current=r.transform,f.current.transform=r.transform,h()),r.wheelDeltaPx&&(f.current.wheelPx+=r.wheelDeltaPx,h())}},_=e=>{e.preventDefault(),e.stopPropagation();let t=e.changedTouches[0];if(a){let e=t?t.clientX:a.last.x,n=t?t.clientY:a.last.y;s(L(a,e,n,d.current,l.current,u.current)),a=null}o&&=(s(z(o,c(),l.current)),null)},v=e=>{e.stopPropagation(),a?.moved&&d.current===`touch`&&s(L(a,a.last.x,a.last.y,`touch`,l.current,u.current)),a=null,o=null};return n.addEventListener(`touchstart`,m,{passive:!1}),n.addEventListener(`touchmove`,g,{passive:!1}),n.addEventListener(`touchend`,_,{passive:!1}),n.addEventListener(`touchcancel`,v,{passive:!1}),()=>{p.current&&cancelAnimationFrame(p.current),n.removeEventListener(`touchstart`,m),n.removeEventListener(`touchmove`,g),n.removeEventListener(`touchend`,_),n.removeEventListener(`touchcancel`,v)}},[e,t,i,r,h]),{transform:a,virtualCursor:n===`mouse`?s:null,resetZoom:g}}function V(e,t,n){let r=e=>{n({type:`key`,code:e,down:!0}),n({type:`key`,code:e,down:!1})};switch(e){case`insertText`:return t&&n({type:`text`,text:t}),!0;case`insertLineBreak`:case`insertParagraph`:return r(`Enter`),!0;case`deleteContentBackward`:return r(`Backspace`),!0;case`deleteContentForward`:return r(`Delete`),!0;default:return!1}}function pe(e,t,n){let r=(0,M.useRef)(null);return(0,M.useEffect)(()=>{let i=r.current;if(!i||!t)return;let a=()=>e({type:`releaseAll`}),o=e=>e.code!==``&&e.key!==`Unidentified`,s=t=>{o(t)&&(t.preventDefault(),e({type:`key`,code:t.code,down:!0}))},c=t=>{o(t)&&(t.preventDefault(),e({type:`key`,code:t.code,down:!1}))},l=t=>{V(t.inputType,t.data,e)&&t.preventDefault()},u=t=>{t.data&&e({type:`text`,text:t.data}),i.value=``},d=e=>{let t=e.clipboardData?.getData(`text/plain`);!t||!n||(e.preventDefault(),n(t))},f=()=>a(),p=()=>{document.hidden&&a()};return i.addEventListener(`keydown`,s),i.addEventListener(`keyup`,c),i.addEventListener(`beforeinput`,l),i.addEventListener(`compositionend`,u),i.addEventListener(`paste`,d),i.addEventListener(`blur`,f),document.addEventListener(`visibilitychange`,p),()=>{i.removeEventListener(`keydown`,s),i.removeEventListener(`keyup`,c),i.removeEventListener(`beforeinput`,l),i.removeEventListener(`compositionend`,u),i.removeEventListener(`paste`,d),i.removeEventListener(`blur`,f),document.removeEventListener(`visibilitychange`,p),a()}},[t,e,n]),{inputRef:r,show:(0,M.useCallback)(()=>r.current?.focus(),[])}}var H=n();function U({onClick:e,label:t,active:n,children:r}){return(0,H.jsxs)(`button`,{type:`button`,onClick:e,"aria-label":t,className:C(`flex min-h-11 min-w-11 flex-1 flex-col items-center justify-center gap-0.5 rounded-lg py-1.5 text-[10px]`,`text-white/80 active:bg-white/10 transition-colors`,n&&`bg-white/15 text-white`),children:[r,(0,H.jsx)(`span`,{children:t})]})}function me({displayLabel:e,onNextDisplay:t,qualityLabel:n,onNextQuality:a,mode:c,onToggleMode:l,onOpenKeyboard:d,onResetZoom:f,settingsOpen:p,onToggleSettings:g,onClose:_}){return(0,H.jsxs)(`div`,{className:`flex shrink-0 items-stretch gap-1 border-t border-white/10 bg-black/90 px-2 pb-[max(0.375rem,env(safe-area-inset-bottom))] pt-1.5`,"data-testid":`remote-desktop-mobile-toolbar`,children:[(0,H.jsx)(U,{onClick:l,label:c===`mouse`?`Mouse`:`Touch`,active:!0,children:c===`mouse`?(0,H.jsx)(s,{className:`size-5`}):(0,H.jsx)(y,{className:`size-5`})}),(0,H.jsx)(U,{onClick:d,label:`Keyboard`,children:(0,H.jsx)(u,{className:`size-5`})}),(0,H.jsx)(U,{onClick:f,label:`Reset zoom`,children:(0,H.jsx)(h,{className:`size-5`})}),e!==null&&(0,H.jsx)(U,{onClick:t,label:e.length>10?`${e.slice(0,9)}…`:e,children:(0,H.jsx)(r,{className:`size-5`})}),(0,H.jsx)(U,{onClick:a,label:n,children:(0,H.jsx)(i,{className:`size-5`})}),(0,H.jsx)(U,{onClick:g,label:`More`,active:p,children:(0,H.jsx)(m,{className:`size-5`})}),(0,H.jsx)(U,{onClick:_,label:`Close`,children:(0,H.jsx)(o,{className:`size-5`})})]})}function W(e){return(e.includes(`ControlLeft`)||e.includes(`MetaLeft`))&&(e.includes(`KeyC`)||e.includes(`KeyX`))}var G=[{label:`Ctrl`,code:`ControlLeft`},{label:`Alt`,code:`AltLeft`},{label:`Shift`,code:`ShiftLeft`},{label:`Win`,code:`MetaLeft`}],K=[{label:`Esc`,code:`Escape`},{label:`Tab`,code:`Tab`},{label:`←`,code:`ArrowLeft`},{label:`↑`,code:`ArrowUp`},{label:`↓`,code:`ArrowDown`},{label:`→`,code:`ArrowRight`}],q=[{label:`Ctrl+C`,codes:[`ControlLeft`,`KeyC`]},{label:`Ctrl+V`,codes:[`ControlLeft`,`KeyV`]},{label:`Ctrl+Z`,codes:[`ControlLeft`,`KeyZ`]},{label:`Ctrl+A`,codes:[`ControlLeft`,`KeyA`]},{label:`Alt+Tab`,codes:[`AltLeft`,`Tab`]},{label:`Ctrl+Alt+Del`,codes:[`ControlLeft`,`AltLeft`,`Delete`]}];function J({onClick:e,active:t,className:n,children:r}){return(0,H.jsx)(`button`,{type:`button`,onClick:e,className:C(`min-h-11 min-w-11 shrink-0 whitespace-nowrap rounded-md px-2.5 text-xs font-medium text-white/80`,`active:bg-white/15 transition-colors`,t&&`bg-primary text-primary-foreground`,n),children:r})}function he({sendMessage:e,onCopyCombo:t}){let[n,r]=(0,M.useState)(new Set),i=(0,M.useRef)(n);i.current=n,(0,M.useEffect)(()=>()=>{i.current.forEach(t=>e({type:`key`,code:t,down:!1}))},[e]);let a=(0,M.useCallback)(t=>{r(n=>{let r=n.has(t);e({type:`key`,code:t,down:!r});let i=new Set(n);return r?i.delete(t):i.add(t),i})},[e]),o=(0,M.useCallback)(t=>{e({type:`key`,code:t,down:!0}),e({type:`key`,code:t,down:!1})},[e]),s=(0,M.useCallback)(n=>{n.forEach(t=>e({type:`key`,code:t,down:!0})),[...n].reverse().forEach(t=>e({type:`key`,code:t,down:!1})),W(n)&&t?.()},[e,t]);return(0,H.jsxs)(`div`,{className:`flex shrink-0 gap-1 overflow-x-auto border-t border-white/10 bg-black/90 px-2 py-1.5`,"data-testid":`remote-desktop-mobile-key-bar`,children:[G.map(e=>(0,H.jsx)(J,{onClick:()=>a(e.code),active:n.has(e.code),children:e.label},e.code)),(0,H.jsx)(`div`,{className:`mx-0.5 w-px shrink-0 bg-white/10`}),K.map(e=>(0,H.jsx)(J,{onClick:()=>o(e.code),children:e.label},e.code)),(0,H.jsx)(`div`,{className:`mx-0.5 w-px shrink-0 bg-white/10`}),q.map(e=>(0,H.jsx)(J,{onClick:()=>s(e.codes),children:e.label},e.label))]})}function Y({icon:e,label:t,hint:n,checked:r,onToggle:i,testId:a,disabled:o}){return(0,H.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":r,disabled:o,onClick:i,"data-testid":a,className:`flex min-h-11 w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-white/80 active:bg-white/10 disabled:opacity-50`,children:[(0,H.jsx)(`span`,{className:`shrink-0 opacity-80`,children:e}),(0,H.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`span`,{className:`block truncate text-xs`,children:t}),n&&(0,H.jsx)(`span`,{className:`block truncate text-[10px] text-white/45`,children:n})]}),(0,H.jsx)(`span`,{className:C(`relative h-5 w-9 shrink-0 rounded-full transition-colors`,r?`bg-primary`:`bg-white/20`),children:(0,H.jsx)(`span`,{className:C(`absolute top-0.5 size-4 rounded-full bg-white transition-all`,r?`left-[1.125rem]`:`left-0.5`)})})]})}function ge({statsVisible:e,onToggleStats:t,showCursor:n,onSetShowCursor:r,clipboardEnabled:i,onSetClipboardEnabled:o,audioOn:l,audioReason:u,onSetAudioOn:p,privacyOn:m,privacyReason:h,onSetPrivacyOn:y,hostModes:b,hostModeId:x,hostOriginalModeId:S,onSetHostMode:w,canResizeHost:ee,resolutionError:T,recording:E,recordingSupported:D,onToggleRecording:ne,onScreenshot:re}){let k=(0,M.useMemo)(()=>te(b),[b]),A=(0,M.useMemo)(()=>ie(),[]),j=(0,M.useMemo)(()=>O(b,A,x),[b,A,x]);return(0,H.jsxs)(`div`,{className:`mx-2 mb-1 space-y-0.5 rounded-xl border border-white/10 bg-black/90 p-1`,"data-testid":`remote-desktop-mobile-settings`,children:[(0,H.jsx)(Y,{icon:(0,H.jsx)(c,{className:`size-4`}),label:`Quality monitor`,checked:e,onToggle:t,testId:`remote-desktop-mobile-stats-toggle`}),(0,H.jsx)(Y,{icon:(0,H.jsx)(s,{className:`size-4`}),label:`Show remote cursor`,hint:`Restarts the stream`,checked:n,onToggle:()=>r(!n),testId:`remote-desktop-mobile-cursor-toggle`}),(0,H.jsx)(Y,{icon:(0,H.jsx)(f,{className:`size-4`}),label:`Sync clipboard`,hint:`Off: Ctrl+V pastes the host's own clipboard`,checked:i,onToggle:()=>o(!i),testId:`remote-desktop-mobile-clipboard-toggle`}),(0,H.jsx)(Y,{icon:(0,H.jsx)(d,{className:`size-4`}),label:`Play host audio`,hint:u??void 0,checked:l,disabled:u!==null,onToggle:()=>p(!l),testId:`remote-desktop-mobile-audio-toggle`}),(0,H.jsx)(Y,{icon:(0,H.jsx)(g,{className:`size-4`}),label:`Privacy mode`,hint:h??`Blocks the host's own keyboard and mouse`,checked:m,disabled:h!==null&&!m,onToggle:()=>y(!m),testId:`remote-desktop-mobile-privacy-toggle`}),ee&&k.length>1&&(0,H.jsxs)(`div`,{className:`px-3 pt-1`,children:[(0,H.jsx)(`div`,{className:`pb-1.5 text-[10px] uppercase tracking-wide text-white/40`,children:`Resolution`}),(0,H.jsxs)(`div`,{className:`flex max-h-28 flex-wrap gap-1.5 overflow-y-auto`,children:[S&&S!==x&&(0,H.jsx)(`button`,{type:`button`,onClick:()=>w(S),"data-testid":`remote-desktop-mobile-resolution-original`,className:`min-h-9 rounded-md bg-white/10 px-2.5 py-1 text-[11px] text-white/70 active:bg-white/20`,children:`Original`}),j&&(0,H.jsx)(`button`,{type:`button`,onClick:()=>w(j.id),"data-testid":`remote-desktop-mobile-resolution-fit-local`,className:`min-h-9 rounded-md bg-white/10 px-2.5 py-1 text-[11px] text-white/70 active:bg-white/20`,children:`Fit local`}),k.map(e=>{let t=(x??k.find(e=>e.current)?.id)===e.id;return(0,H.jsxs)(`button`,{type:`button`,onClick:()=>w(e.id),"data-testid":`remote-desktop-mobile-resolution-${e.width}x${e.height}`,className:C(`min-h-9 rounded-md px-2.5 py-1 text-[11px] tabular-nums`,t?`bg-white/25 text-white`:`bg-white/10 text-white/70 active:bg-white/20`),children:[e.width,`×`,e.height]},e.id)})]}),T&&(0,H.jsx)(`div`,{className:`pt-1.5 text-[10px] leading-tight text-red-400`,children:T})]}),(0,H.jsxs)(`button`,{type:`button`,onClick:re,"data-testid":`remote-desktop-mobile-screenshot`,className:`flex min-h-11 w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-xs text-white/80 active:bg-white/10`,children:[(0,H.jsx)(a,{className:`size-4 opacity-80`}),` Save screenshot`]}),D&&(0,H.jsx)(`button`,{type:`button`,onClick:ne,"data-testid":`remote-desktop-mobile-record`,className:`flex min-h-11 w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-xs text-white/80 active:bg-white/10`,children:E?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(_,{className:`size-4 text-red-500`}),` Stop recording`]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(v,{className:`size-4 opacity-80`}),` Start recording`]})})]})}function X({onClose:e}){let t=(0,M.useRef)(null),n=(0,M.useRef)(null),[r,i]=(0,M.useState)(`mouse`),[a,o]=(0,M.useState)(!1),[s,c]=(0,M.useState)(!1),u=re(),{connState:d,errorMessage:f,decoderStatus:m,decoderErrorMessage:h,sendMessage:g,reconnect:_,getTotalBytes:v,getFrameCount:y,quality:C,setQuality:te,showCursor:E,setShowCursor:O,audioOn:ie,setAudioOn:ae,getAudioTracks:oe,privacyOn:N,privacyError:P,setPrivacyOn:F,hostModeId:I,hostOriginalModeId:se,resolutionError:ce,setHostMode:L,pendingHostClipboard:R,clearHostClipboard:le,sendClipboard:z,requestHostClipboard:B}=k(n,{displayId:u.displayId}),ue=S(e=>e.remoteDesktopStatsVisible),de=S(e=>e.toggleRemoteDesktopStatsVisible),V=S(e=>e.remoteDesktopClipboardSync),U=S(e=>e.setRemoteDesktopClipboardSync),W=S(e=>e.remoteDesktopQuality),G=d===`streaming`,{transform:K,virtualCursor:q,resetZoom:J}=fe({containerRef:t,canvasRef:n,mode:r,sendMessage:g,enabled:G}),[Y,X]=(0,M.useState)(!1),_e=(0,M.useCallback)(e=>{X(!0),z(e,!0)},[z]),{caps:Z}=ee(!1),Q=ne(n,oe),{inputRef:ve,show:ye}=pe(g,G,V?_e:void 0),$=w(!0)?.keyboardInset??0,be=(0,M.useCallback)(()=>i(e=>e===`mouse`?`touch`:`mouse`),[]),xe=(0,M.useCallback)(()=>{ye(),o(!0)},[ye]),Se=m===`unsupported`?h:d===`error`?f:d===`closed`?`Disconnected`:d===`connecting`?`Connecting…`:null,Ce={transform:`translate(${K.panX}px, ${K.panY}px) scale(${K.scale})`},we=`${(q?.xFrac??.5)*100}%`,Te=`${(q?.yFrac??.5)*100}%`;if(q&&t.current&&n.current?.width&&n.current.height){let e=t.current.getBoundingClientRect(),r=D({left:0,top:0,width:e.width,height:e.height},n.current.width,n.current.height);we=`${r.left+q.xFrac*r.width}px`,Te=`${r.top+q.yFrac*r.height}px`}return(0,H.jsxs)(`div`,{className:`relative h-full w-full bg-black`,"data-testid":`remote-desktop-mobile-view`,"data-conn-state":d,children:[(0,H.jsxs)(`div`,{ref:t,className:`absolute inset-x-0 top-0 flex items-center justify-center overflow-hidden`,style:{touchAction:`none`,bottom:$},"data-testid":`remote-desktop-mobile-stage-container`,children:[(0,H.jsxs)(`div`,{className:`relative flex h-full w-full items-center justify-center`,style:Ce,children:[(0,H.jsx)(`canvas`,{ref:n,"data-testid":`remote-desktop-canvas`,className:`block h-full w-full min-h-0 min-w-0 object-contain outline-none`}),r===`mouse`&&q&&G&&(0,H.jsx)(`div`,{className:`pointer-events-none absolute rounded-full border-2 border-white bg-primary shadow-[0_0_0_1px_rgba(0,0,0,0.6)]`,style:{left:we,top:Te,width:14,height:14,transform:`translate(-50%, -50%) scale(${1/K.scale})`},"data-testid":`remote-desktop-virtual-cursor`})]}),Se&&(0,H.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-3 bg-black/70 text-sm text-white`,children:[(0,H.jsx)(l,{className:`size-6 opacity-70`}),(0,H.jsx)(`span`,{className:`max-w-sm px-4 text-center`,children:Se}),(d===`error`||d===`closed`)&&m!==`unsupported`&&(0,H.jsxs)(`button`,{onClick:_,className:`flex items-center gap-1.5 rounded-md bg-white/10 px-3 py-1.5 hover:bg-white/20`,children:[(0,H.jsx)(p,{className:`size-3.5`}),` Reconnect`]})]}),(0,H.jsx)(`input`,{ref:ve,type:`text`,autoComplete:`off`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,className:`absolute size-px opacity-0`,"aria-hidden":`true`,tabIndex:-1,onBlur:()=>o(!1),"data-testid":`remote-desktop-virtual-keyboard-input`})]}),(0,H.jsxs)(`div`,{className:`absolute inset-x-0 bottom-0`,style:$>0?{transform:`translateY(-${$}px)`}:void 0,"data-testid":`remote-desktop-mobile-bottom-bar`,children:[(0,H.jsx)(j,{pendingText:R,onDismiss:le,missingToolAction:Y&&Z&&!Z.clipboard.available?Z.clipboard.action:null,onDismissMissingTool:()=>X(!1),positionClassName:`mx-2 mb-1 max-w-[calc(100%-1rem)]`}),s&&(0,H.jsx)(ge,{statsVisible:ue,onToggleStats:de,showCursor:E,onSetShowCursor:O,clipboardEnabled:V,onSetClipboardEnabled:U,audioOn:ie,audioReason:Z&&!Z.audio.available?Z.audio.reason:null,onSetAudioOn:ae,privacyOn:N,privacyReason:P??(Z&&!Z.privacy.available?Z.privacy.reason:null),hostModes:Z?.resolutions?.modes??[],hostModeId:I,hostOriginalModeId:se,onSetHostMode:L,canResizeHost:Z?.inputReady??!1,resolutionError:ce,onSetPrivacyOn:F,recording:Q.recording,recordingSupported:Q.supported,onToggleRecording:Q.toggle,onScreenshot:()=>void T(n.current)}),a&&(0,H.jsx)(he,{sendMessage:g,onCopyCombo:V?B:void 0}),(0,H.jsx)(me,{displayLabel:u.displays.length>1?u.current?.label??null:null,onNextDisplay:u.next,qualityLabel:b(W),onNextQuality:()=>te(x(W)),mode:r,onToggleMode:be,onOpenKeyboard:xe,onResetZoom:J,settingsOpen:s,onToggleSettings:()=>c(e=>!e),onClose:e})]}),(0,H.jsx)(A,{canvasRef:n,getFrameCount:y,getTotalBytes:v,positionClassName:`left-1 top-[calc(env(safe-area-inset-top,0px)+2.75rem)]`})]})}export{X as default};
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import{C as t,S as n}from"./vendor-markdown-QKPNiWEd.js";import{Ar as r,Dn as i,E as a,ct as o,hr as s,un as c,z as l}from"./icons-CO_II6D-.js";import{t as u}from"./settings-store-
|
|
1
|
+
import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import{C as t,S as n}from"./vendor-markdown-QKPNiWEd.js";import{Ar as r,Dn as i,E as a,ct as o,hr as s,un as c,z as l}from"./icons-CO_II6D-.js";import{t as u}from"./settings-store-DIV25PM_.js";import{$ as d}from"./index-CIscPw4g.js";import{r as f}from"./run-in-terminal-B_PCeBqG.js";var p=e(t(),1),m=n();function h({onCancel:e,children:t}){let n=u(e=>e.remoteDesktopWarningDismissed),r=u(e=>e.setRemoteDesktopWarningDismissed),[a,o]=(0,p.useState)(!1),[c,l]=(0,p.useState)(!1);if(n||a)return(0,m.jsx)(m.Fragment,{children:t});let d=()=>{c&&r(!0),o(!0)};return(0,m.jsx)(`div`,{className:`flex h-full w-full items-center justify-center overflow-y-auto bg-black p-4 text-white`,"data-testid":`remote-desktop-warning-gate`,children:(0,m.jsxs)(`div`,{className:`flex w-full max-w-sm flex-col gap-4 rounded-xl border border-white/10 bg-white/5 p-5`,children:[(0,m.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,m.jsx)(i,{className:`size-5 shrink-0 text-primary`}),(0,m.jsx)(`h2`,{className:`text-base font-semibold`,children:`Remote Desktop`}),(0,m.jsx)(`span`,{className:`ml-auto rounded-full bg-amber-500/20 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-amber-300`,children:`Beta`})]}),(0,m.jsxs)(`ul`,{className:`flex flex-col gap-2 text-sm text-white/80`,children:[(0,m.jsxs)(`li`,{className:`flex gap-2`,children:[(0,m.jsx)(s,{className:`mt-0.5 size-4 shrink-0 text-amber-300`}),(0,m.jsxs)(`span`,{children:[`This streams the host's `,(0,m.jsx)(`strong`,{children:`whole screen`}),` and lets you `,(0,m.jsx)(`strong`,{children:`move its mouse and type`}),` as if you were sitting at it. Anything you do here happens on the real desktop.`]})]}),(0,m.jsxs)(`li`,{className:`flex gap-2`,children:[(0,m.jsx)(s,{className:`mt-0.5 size-4 shrink-0 text-amber-300`}),(0,m.jsx)(`span`,{children:`Anyone signed in to this PPM can do the same. Avoid opening it over a public share link you don't fully trust; a private network (Tailscale, LAN) is safer.`})]}),(0,m.jsxs)(`li`,{className:`flex gap-2`,children:[(0,m.jsx)(s,{className:`mt-0.5 size-4 shrink-0 text-amber-300`}),(0,m.jsx)(`span`,{children:`Still beta: the host must be unlocked with an active session, UAC prompts stay hidden, and a person at the host will fight you for the cursor.`})]})]}),(0,m.jsxs)(`label`,{className:`flex min-h-11 cursor-pointer items-center gap-2 text-sm text-white/70`,children:[(0,m.jsx)(`input`,{type:`checkbox`,checked:c,onChange:e=>l(e.target.checked),className:`size-4 accent-primary`,"data-testid":`remote-desktop-warning-dont-show`}),`Don't show this again`]}),(0,m.jsxs)(`div`,{className:`flex gap-2`,children:[(0,m.jsx)(`button`,{type:`button`,onClick:e,className:`min-h-11 flex-1 rounded-md bg-white/10 px-3 text-sm hover:bg-white/20`,"data-testid":`remote-desktop-warning-cancel`,children:`Cancel`}),(0,m.jsx)(`button`,{type:`button`,onClick:d,className:`min-h-11 flex-1 rounded-md bg-primary px-3 text-sm font-medium text-primary-foreground hover:bg-primary/90`,"data-testid":`remote-desktop-warning-continue`,children:`Continue`})]})]})})}function g({onCancel:e,children:t}){let[n,r]=(0,p.useState)(!1),{caps:a,failed:o,runHostAction:s}=d(!n);if(n||a?.videoReady&&a.inputReady)return(0,m.jsx)(m.Fragment,{children:t});let l=a?.requirements.filter(e=>!e.ok)??[],u=!!a?.videoReady&&!a.inputReady,h=t=>{f(t),e()};return(0,m.jsx)(`div`,{className:`flex h-full w-full items-center justify-center overflow-y-auto bg-black p-4 text-white`,"data-testid":`remote-desktop-readiness-gate`,children:(0,m.jsxs)(`div`,{className:`flex w-full max-w-sm flex-col gap-4 rounded-xl border border-white/10 bg-white/5 p-5`,children:[(0,m.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,m.jsx)(i,{className:`size-5 shrink-0 text-primary`}),(0,m.jsx)(`h2`,{className:`text-base font-semibold`,children:`This host needs a few things`})]}),!a&&!o&&(0,m.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-white/70`,children:[(0,m.jsx)(c,{className:`size-4 animate-spin`}),` Checking the host…`]}),o&&(0,m.jsx)(`p`,{className:`text-sm text-red-300`,children:`Could not reach the host's remote-desktop service.`}),(0,m.jsx)(`ul`,{className:`flex flex-col gap-3`,children:a?.requirements.map(e=>(0,m.jsx)(_,{req:e,onHostAction:s,onTerminal:h},e.id))}),l.length>0&&(0,m.jsx)(`p`,{className:`text-xs text-white/50`,children:`Re-checking every few seconds — this updates by itself once fixed.`}),(0,m.jsxs)(`div`,{className:`flex gap-2`,children:[(0,m.jsx)(`button`,{type:`button`,onClick:e,className:`min-h-11 flex-1 rounded-md bg-white/10 px-3 text-sm hover:bg-white/20`,children:`Cancel`}),(0,m.jsx)(`button`,{type:`button`,disabled:!a?.videoReady,onClick:()=>r(!0),className:`min-h-11 flex-1 rounded-md bg-primary px-3 text-sm font-medium text-primary-foreground hover:bg-primary/90 disabled:cursor-not-allowed disabled:opacity-40`,"data-testid":`remote-desktop-readiness-continue`,children:u?`Continue (view only)`:`Continue`})]})]})})}function _({req:e,...t}){return(0,m.jsxs)(`li`,{className:`flex gap-2`,"data-testid":`remote-desktop-requirement-${e.id}`,"data-ok":e.ok,children:[e.ok?(0,m.jsx)(a,{className:`mt-0.5 size-4 shrink-0 text-emerald-400`}):(0,m.jsx)(l,{className:`mt-0.5 size-4 shrink-0 text-amber-300`}),(0,m.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,m.jsxs)(`div`,{className:`text-sm font-medium`,children:[e.title,!e.ok&&(0,m.jsx)(`span`,{className:`ml-2 text-xs font-normal text-white/50`,children:e.gates===`video`?`required`:`for mouse & keyboard`})]}),!e.ok&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`p`,{className:`text-sm text-white/70`,children:e.detail}),(0,m.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.actions.map(n=>(0,m.jsx)(v,{action:n,reqId:e.id,...t},n.label))})]})]})]})}function v({action:e,reqId:t,onHostAction:n,onTerminal:i}){let a=`inline-flex min-h-11 items-center gap-1.5 rounded-md bg-white/10 px-3 text-sm hover:bg-white/20`;return e.kind===`terminal`?(0,m.jsxs)(`button`,{type:`button`,className:a,onClick:()=>i(e.command),title:e.command,children:[(0,m.jsx)(r,{className:`size-4`}),` `,e.label]}):e.kind===`link`?(0,m.jsxs)(`a`,{className:a,href:e.url,target:`_blank`,rel:`noreferrer`,children:[(0,m.jsx)(o,{className:`size-4`}),` `,e.label]}):(0,m.jsx)(`button`,{type:`button`,className:a,onClick:()=>void n(t,e.action),children:e.label})}export{h as n,g as t};
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import{C as t,S as n}from"./vendor-markdown-QKPNiWEd.js";import"./vendor-ui-P9Ym7hCv.js";import{En as r,Gt as i,Nt as a,On as o,Tn as s,Zn as c,or as l,pr as u,ut as d,xr as f,z as p}from"./icons-CO_II6D-.js";import"./api-client-F5Zi1sR0.js";import{C as m,a as h,c as g,d as _,f as v,i as y,l as b,m as x,n as S,o as C,p as w,r as ee,s as T,t as E,u as D,w as te}from"./settings-store-DIV25PM_.js";import{n as ne}from"./utils-btZ8C8-R.js";import"./portal-container-context-NFSuymMu.js";import"./panel-store-1X6yM3XZ.js";import{t as re}from"./window-store-vo1N70nK.js";import"./project-store-CCimwgGF.js";import{t as ie}from"./button-CsmGH5xa.js";import{a as ae,i as O,n as k,o as A,r as j,t as M}from"./dialog-z8PLkL8n.js";import"./ws-auth-J3hw0Mhc.js";import{$ as oe,An as N,Cn as P,Dn as F,En as I,On as L,Sn as R,Tn as z,bn as B,kn as V,wn as H,xn as se,yn as U}from"./index-CIscPw4g.js";import"./run-in-terminal-B_PCeBqG.js";import{n as W,t as G}from"./remote-desktop-readiness-gate-DV7YgSpP.js";import{a as K,c as ce,h as q,i as le,l as ue,m as J,n as de,o as Y,p as fe,r as pe,s as me,t as he,u as X}from"./remote-desktop-clipboard-notice-DEbdu0hC.js";var Z=e(t(),1);function ge(e,t,n,r){let i=(0,Z.useCallback)((n,r,i,a)=>{let o=e.current;if(!o)return;let{xFrac:s,yFrac:c}=X(n,r,o.getBoundingClientRect());t({type:`pointer`,xFrac:s,yFrac:c,button:i,down:a})},[e,t]);(0,Z.useEffect)(()=>{let a=e.current;if(!a||!n)return;let o=e=>e===0?`left`:e===2?`right`:null,s=()=>t({type:`releaseAll`}),c=null,l=0,u=()=>{l=0,c&&=(i(c.x,c.y,null,null),null)},d=()=>{l&&=(cancelAnimationFrame(l),0),c&&=(i(c.x,c.y,null,null),null)},f=e=>{e.preventDefault(),a.setPointerCapture(e.pointerId),a.focus(),d(),i(e.clientX,e.clientY,o(e.button),!0)},p=e=>{c={x:e.clientX,y:e.clientY},l||=requestAnimationFrame(u)},m=e=>{d(),i(e.clientX,e.clientY,o(e.button),!1)},h=e=>e.preventDefault(),g=!1,_=e=>{if(r&&q(e)){g=e.shiftKey;return}e.preventDefault(),t({type:`key`,code:e.code,down:!0}),r&&J(e)&&r.onCopyCombo()},v=e=>{r&&q(e)||(e.preventDefault(),t({type:`key`,code:e.code,down:!1}))},y=e=>{e.preventDefault();let t=e.clipboardData?.getData(`text/plain`);t&&r?.onPasteText(t,g),g=!1},b=()=>{document.hidden&&s()};return a.tabIndex=0,a.addEventListener(`pointerdown`,f),a.addEventListener(`pointermove`,p),a.addEventListener(`pointerup`,m),a.addEventListener(`contextmenu`,h),a.addEventListener(`keydown`,_),a.addEventListener(`keyup`,v),a.addEventListener(`paste`,y),a.addEventListener(`blur`,s),document.addEventListener(`visibilitychange`,b),()=>{l&&cancelAnimationFrame(l),a.removeEventListener(`pointerdown`,f),a.removeEventListener(`pointermove`,p),a.removeEventListener(`pointerup`,m),a.removeEventListener(`contextmenu`,h),a.removeEventListener(`keydown`,_),a.removeEventListener(`keyup`,v),a.removeEventListener(`blur`,s),document.removeEventListener(`visibilitychange`,b)}},[e,n,i,t,r])}var Q={h264_nvenc:`NVIDIA NVENC`,h264_qsv:`Intel QuickSync`,h264_vaapi:`VAAPI (GPU)`,h264_amf:`AMD AMF`,h264_videotoolbox:`Apple VideoToolbox`,libx264:`Software (x264)`};function _e(e){return Object.hasOwn(Q,e)?Q[e]:e}var $=n(),ve=`flex size-7 shrink-0 items-center justify-center rounded bg-black/40 text-white/70 outline-none hover:bg-black/60 hover:text-white data-[state=open]:bg-black/70 data-[state=open]:text-white`;function ye({displays:e,currentDisplayId:t,onSelectDisplay:n,quality:o,qualityChoice:s,onSetQuality:c,onOpenCustomQuality:l,codecs:h,codec:g,onSetCodec:_,hostModes:v,hostModeId:b,hostOriginalModeId:x,onSetHostMode:S,canResizeHost:C,resolutionError:w,viewStyle:T,customScale:E,onSetViewStyle:D,onSetCustomScale:re,showCursor:ie,onSetShowCursor:ae,audioOn:O,audioReason:k,onSetAudioOn:A,privacyOn:j,privacyReason:M,privacyCanBlank:oe,onSetPrivacyOn:W,recording:G,recordingElapsedSec:K,recordingSupported:q,onToggleRecording:le,onScreenshot:J,clipboardEnabled:de,onSetClipboardEnabled:fe,statsVisible:pe,onToggleStats:he}){let X=(0,Z.useMemo)(()=>ce(v),[v]),ge=(0,Z.useMemo)(()=>me(),[]),Q=(0,Z.useMemo)(()=>Y(v,ge,b),[v,ge,b]),ye=!!(x&&x!==b),Se=t??e.find(e=>e.primary)?.id??e[0]?.id??``;return(0,$.jsxs)(`div`,{className:`absolute right-1 top-1 z-40 flex items-center gap-1`,"data-testid":`remote-desktop-toolbar`,children:[e.length>1&&(0,$.jsxs)(U,{children:[(0,$.jsx)(N,{className:ve,"aria-label":`Display`,title:`Display`,children:(0,$.jsx)(r,{className:`size-3.5`})}),(0,$.jsxs)(se,{align:`end`,className:`w-64`,children:[(0,$.jsx)(P,{children:`Display`}),(0,$.jsx)(H,{value:Se,onValueChange:n,children:e.map(e=>(0,$.jsxs)(z,{value:e.id,"data-testid":`remote-desktop-display-${e.id}`,children:[e.label,e.primary?` (main)`:``,` · `,e.width,`×`,e.height]},e.id))})]})]}),(0,$.jsxs)(U,{children:[(0,$.jsx)(N,{className:ve,"aria-label":`Display settings`,title:`Display settings`,"data-testid":`remote-desktop-settings-trigger`,children:(0,$.jsx)(u,{className:`size-3.5`})}),(0,$.jsxs)(se,{align:`end`,className:`w-64`,children:[(0,$.jsx)(P,{children:`Scale`}),(0,$.jsx)(H,{value:T,onValueChange:e=>D(e),children:y.map(e=>(0,$.jsx)(z,{value:e,"data-testid":`remote-desktop-view-style-${e}`,children:ee[e]},e))}),T===`custom`&&(0,$.jsx)(xe,{scale:E,onSet:re}),(0,$.jsx)(I,{}),(0,$.jsxs)(F,{children:[(0,$.jsxs)(V,{"data-testid":`remote-desktop-quality-submenu`,children:[`Image quality`,o.held<1&&(0,$.jsxs)(`span`,{className:`ml-1.5 text-[10px] opacity-60`,"data-testid":`remote-desktop-quality-held`,children:[Math.round(o.held*100),`% — link limited`]})]}),(0,$.jsx)(L,{className:`w-56`,children:(0,$.jsxs)(H,{value:s,onValueChange:e=>e===`custom`?l():c(e),children:[te.map(e=>(0,$.jsx)(z,{value:e,"data-testid":`remote-desktop-quality-${e}`,children:m[e].label},e)),(0,$.jsx)(z,{value:`custom`,"data-testid":`remote-desktop-quality-custom`,children:`Custom…`})]})})]}),h.length>1&&(0,$.jsxs)(F,{children:[(0,$.jsx)(V,{"data-testid":`remote-desktop-codec-submenu`,children:`Codec`}),(0,$.jsx)(L,{className:`w-56`,children:(0,$.jsxs)(H,{value:g??`auto`,onValueChange:e=>_(e===`auto`?null:e),children:[(0,$.jsxs)(z,{value:`auto`,children:[`Auto · `,_e(h[0])]}),h.map(e=>(0,$.jsx)(z,{value:e,"data-testid":`remote-desktop-codec-${e}`,children:_e(e)},e))]})})]}),C&&X.length>1&&(0,$.jsxs)(F,{children:[(0,$.jsx)(V,{"data-testid":`remote-desktop-resolution-submenu`,children:`Resolution`}),(0,$.jsxs)(L,{className:`max-h-80 w-56 overflow-y-auto`,children:[ye&&x&&(0,$.jsx)(R,{onSelect:()=>S(x),"data-testid":`remote-desktop-resolution-original`,children:`Original`}),Q&&(0,$.jsxs)(R,{onSelect:()=>S(Q.id),"data-testid":`remote-desktop-resolution-fit-local`,children:[`Fit local `,Q.width,`×`,Q.height]}),(ye||Q)&&(0,$.jsx)(I,{}),(0,$.jsx)(H,{value:b??X.find(e=>e.current)?.id??``,onValueChange:S,children:X.map(e=>(0,$.jsxs)(z,{value:e.id,"data-testid":`remote-desktop-resolution-${e.width}x${e.height}`,children:[ue(e),e.preferred&&(0,$.jsx)(`span`,{className:`ml-1.5 text-[10px] opacity-60`,children:`native`})]},e.id))}),w&&(0,$.jsx)(`div`,{className:`px-2 py-1.5 text-[10px] leading-tight text-destructive`,children:w})]})]}),(0,$.jsx)(I,{}),(0,$.jsx)(B,{checked:ie,onCheckedChange:ae,"data-testid":`remote-desktop-show-cursor`,children:`Show remote cursor`}),(0,$.jsx)(B,{checked:de,onCheckedChange:fe,"data-testid":`remote-desktop-clipboard-toggle`,children:`Sync clipboard`}),(0,$.jsx)(B,{checked:O,disabled:k!==null,onCheckedChange:A,"data-testid":`remote-desktop-audio-toggle`,children:(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,$.jsx)(`span`,{children:`Play host audio`}),k&&(0,$.jsx)(`span`,{className:`text-[10px] leading-tight text-muted-foreground`,children:k})]})}),(0,$.jsx)(I,{}),(0,$.jsx)(B,{checked:j,disabled:M!==null&&!j,onCheckedChange:W,"data-testid":`remote-desktop-privacy-toggle`,children:(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,$.jsx)(`span`,{children:`Privacy mode`}),(0,$.jsx)(`span`,{className:`text-[10px] leading-tight text-muted-foreground`,children:M??(oe?`Blocks the host's keyboard and mouse, and blanks its screen`:`Blocks the host's keyboard and mouse (its screen stays on)`)})]})}),(0,$.jsx)(I,{}),(0,$.jsxs)(R,{onSelect:J,"data-testid":`remote-desktop-screenshot`,children:[(0,$.jsx)(i,{className:`size-3.5`}),` Save screenshot`]}),q&&(0,$.jsx)(R,{onSelect:le,"data-testid":`remote-desktop-record`,children:G?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(f,{className:`size-3.5 text-red-500`}),` Stop recording · `,be(K)]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(p,{className:`size-3.5`}),` Start recording`]})})]})]}),j&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>W(!1),title:`Privacy mode is on — click to release the host`,"aria-label":`Turn privacy mode off`,className:`flex h-7 shrink-0 items-center gap-1 rounded bg-amber-500/85 px-1.5 text-[10px] font-medium text-black hover:bg-amber-400`,"data-testid":`remote-desktop-privacy-indicator`,children:[(0,$.jsx)(d,{className:`size-3`}),` Host locked`]}),G&&(0,$.jsxs)(`button`,{type:`button`,onClick:le,title:`Stop recording`,"aria-label":`Stop recording`,className:`flex h-7 shrink-0 items-center gap-1 rounded bg-red-600/80 px-1.5 text-[10px] font-medium tabular-nums text-white hover:bg-red-600`,"data-testid":`remote-desktop-recording-indicator`,children:[(0,$.jsx)(`span`,{className:`size-1.5 animate-pulse rounded-full bg-white`}),be(K)]}),(0,$.jsx)(`button`,{type:`button`,onClick:he,"aria-label":`Toggle stats overlay`,"aria-pressed":pe,title:`Quality monitor`,className:ne(ve,pe&&`bg-primary/70 text-primary-foreground hover:bg-primary/80`),children:(0,$.jsx)(a,{className:`size-3.5`})})]})}function be(e){let t=Math.floor(e/3600),n=Math.floor(e%3600/60),r=String(e%60).padStart(2,`0`);return t>0?`${t}:${String(n).padStart(2,`0`)}:${r}`:`${n}:${r}`}function xe({scale:e,onSet:t}){let[n,r]=(0,Z.useState)(null),i=(0,Z.useRef)(null),a=T(Math.round(C(e)*100)),o=n??a,l=g(o);(0,Z.useEffect)(()=>()=>{i.current&&clearTimeout(i.current)},[]);let u=e=>{r(e),i.current&&clearTimeout(i.current),i.current=setTimeout(()=>{r(null),t(e/100)},300)},d=e=>t=>{t.preventDefault(),u(T(o+e*1))},f=`flex size-6 shrink-0 items-center justify-center rounded hover:bg-accent disabled:opacity-40`;return(0,$.jsx)(`div`,{className:`px-2 py-1.5`,"data-testid":`remote-desktop-zoom-row`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`button`,{type:`button`,className:f,onClick:d(-1),disabled:o<=5,"aria-label":`Decrease`,children:(0,$.jsx)(s,{className:`size-3.5`})}),(0,$.jsxs)(`span`,{className:`relative flex-1 py-2.5`,children:[(0,$.jsx)(`input`,{type:`range`,min:0,max:1,step:1/(S-5),value:l,"aria-label":`Scale`,"aria-valuetext":`${o}%`,"data-testid":`remote-desktop-zoom-slider`,onKeyDown:e=>e.stopPropagation(),onChange:e=>u(b(D(Number(e.target.value)))),className:`h-1 w-full cursor-pointer appearance-none rounded bg-accent accent-primary`}),(0,$.jsxs)(`span`,{className:`pointer-events-none absolute top-0 -translate-x-1/2 rounded bg-primary px-1.5 text-[10px] leading-4 tabular-nums text-primary-foreground`,style:{left:`${l*100}%`},"data-testid":`remote-desktop-zoom-value`,children:[o,`%`]})]}),(0,$.jsx)(`button`,{type:`button`,className:f,onClick:d(1),disabled:o>=S,"aria-label":`Increase`,children:(0,$.jsx)(c,{className:`size-3.5`})})]})})}var Se=400;function Ce({open:e,onOpenChange:t,percent:n,fps:r,more:i,onSetMore:a,onCommit:o,frameSize:s}){let[c,l]=(0,Z.useState)(n),[u,d]=(0,Z.useState)(r),f=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{e&&(l(n),d(r))},[e,n,r]),(0,Z.useEffect)(()=>()=>{f.current&&clearTimeout(f.current)},[]);let p=i?_:100,m=(e,t)=>{f.current&&clearTimeout(f.current),f.current=setTimeout(()=>o(e,t),Se)},h=e=>{let t=w(e,i);l(t),m(t,u)},g=e=>{let t=v(e);d(t),m(c,t)},y=e=>{a(e);let t=w(c,e);t!==c&&(l(t),m(t,u))},b=x(c,s.width,s.height);return(0,$.jsx)(M,{open:e,onOpenChange:t,children:(0,$.jsxs)(k,{className:`sm:max-w-md`,"data-testid":`remote-desktop-custom-quality-dialog`,children:[(0,$.jsxs)(ae,{children:[(0,$.jsx)(A,{children:`Custom image quality`}),(0,$.jsx)(j,{children:s.width>0?`${c}% of the base rate for ${s.width}×${s.height} — about ${(b/1e3).toFixed(1)} Mbit/s`:`Waiting for the first frame`})]}),(0,$.jsxs)(`div`,{className:`space-y-4 py-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`input`,{type:`range`,min:10,max:p,step:1,value:Math.min(c,p),onChange:e=>h(Number(e.target.value)),"aria-label":`Bitrate`,"data-testid":`remote-desktop-custom-bitrate`,className:`h-1 min-w-0 flex-1 cursor-pointer appearance-none rounded bg-accent accent-primary`}),(0,$.jsxs)(`span`,{className:`w-14 text-right text-xs tabular-nums`,children:[c,`%`]}),(0,$.jsx)(`span`,{className:`w-14 text-xs text-muted-foreground`,children:`Bitrate`}),(0,$.jsxs)(`label`,{className:`flex shrink-0 items-center gap-1.5 text-xs`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:i,onChange:e=>y(e.target.checked),"data-testid":`remote-desktop-custom-more`,className:`size-3.5 accent-primary`}),`More`]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`input`,{type:`range`,min:5,max:120,step:1,value:u,onChange:e=>g(Number(e.target.value)),"aria-label":`FPS`,"data-testid":`remote-desktop-custom-fps`,className:`h-1 min-w-0 flex-1 cursor-pointer appearance-none rounded bg-accent accent-primary`}),(0,$.jsx)(`span`,{className:`w-14 text-right text-xs tabular-nums`,children:u}),(0,$.jsx)(`span`,{className:`w-14 text-xs text-muted-foreground`,children:`FPS`}),(0,$.jsx)(`span`,{className:`w-[4.25rem] shrink-0`,"aria-hidden":!0})]})]}),(0,$.jsx)(O,{children:(0,$.jsx)(ie,{onClick:()=>t(!1),children:`Close`})})]})})}function we({id:e}){let t=re(e=>e.close),n=(0,Z.useCallback)(()=>t(e),[t,e]);return(0,$.jsx)(W,{onCancel:n,children:(0,$.jsx)(G,{onCancel:n,children:(0,$.jsx)(Te,{})})})}function Te(){let e=(0,Z.useRef)(null),t=de(),{connState:n,errorMessage:r,decoderStatus:i,decoderErrorMessage:a,sendMessage:s,reconnect:c,getFrameCount:u,getTotalBytes:d,frameSize:f,quality:p,setQuality:m,setCustomQuality:g,showCursor:_,setShowCursor:v,codec:y,setCodec:b,audioOn:x,setAudioOn:S,getAudioTracks:C,privacyOn:w,privacyError:ee,setPrivacyOn:T,hostModeId:D,hostOriginalModeId:te,resolutionError:re,setHostMode:ie,pendingHostClipboard:ae,clearHostClipboard:O,sendClipboard:k,requestHostClipboard:A}=fe(e,{displayId:t.displayId}),j=E(e=>e.remoteDesktopStatsVisible),M=E(e=>e.toggleRemoteDesktopStatsVisible),N=E(e=>e.remoteDesktopViewStyle),P=E(e=>e.remoteDesktopCustomScale),F=E(e=>e.setRemoteDesktopViewStyle),I=E(e=>e.setRemoteDesktopCustomScale),L=E(e=>e.remoteDesktopClipboardSync),R=E(e=>e.remoteDesktopQuality),z=E(e=>e.remoteDesktopCustomQualityPercent),B=E(e=>e.remoteDesktopCustomFps),V=E(e=>e.remoteDesktopCustomQualityMore),H=E(e=>e.setRemoteDesktopCustomQualityMore),[se,U]=(0,Z.useState)(!1),W=E(e=>e.setRemoteDesktopClipboardSync),{caps:G}=oe(!1),[ce,q]=(0,Z.useState)(!1),ue=(0,Z.useMemo)(()=>L?{onPasteText:(e,t)=>{q(!0),k(e,!0,t)},onCopyCombo:A}:void 0,[L,k,A]);ge(e,s,n===`streaming`,ue);let J=le(e,C),Y=h(N,P,f),me=i===`unsupported`?a:n===`error`?r:n===`closed`?`Disconnected`:n===`connecting`?`Connecting…`:null;return(0,$.jsxs)(`div`,{className:`relative flex h-full w-full items-center justify-center bg-black`,"data-testid":`remote-desktop-window`,"data-conn-state":n,children:[(0,$.jsx)(`div`,{className:ne(`flex h-full w-full`,Y?`overflow-auto`:`overflow-hidden`),children:(0,$.jsx)(`canvas`,{ref:e,"data-testid":`remote-desktop-canvas`,"data-view-style":N,className:ne(`m-auto outline-none`,!Y&&`max-h-full max-w-full`),style:Y?{width:Y.width,height:Y.height}:void 0})}),(0,$.jsx)(pe,{canvasRef:e,getFrameCount:u,getTotalBytes:d}),(0,$.jsx)(ye,{displays:t.displays,currentDisplayId:t.current?.id,onSelectDisplay:t.select,quality:p,qualityChoice:R,onSetQuality:m,onOpenCustomQuality:()=>U(!0),codecs:G?.encoders??[],codec:y,onSetCodec:b,hostModes:G?.resolutions?.modes??[],hostModeId:D,hostOriginalModeId:te,onSetHostMode:ie,canResizeHost:G?.inputReady??!1,resolutionError:re,viewStyle:N,customScale:P,onSetViewStyle:F,onSetCustomScale:I,showCursor:_,onSetShowCursor:v,audioOn:x,audioReason:G&&!G.audio.available?G.audio.reason:null,onSetAudioOn:S,privacyOn:w,privacyReason:ee??(G&&!G.privacy.available?G.privacy.reason:null),privacyCanBlank:G?.privacy?.canBlank??!1,onSetPrivacyOn:T,recording:J.recording,recordingElapsedSec:J.elapsedSec,recordingSupported:J.supported,onToggleRecording:J.toggle,onScreenshot:()=>void K(e.current),clipboardEnabled:L,onSetClipboardEnabled:W,statsVisible:j,onToggleStats:M}),(0,$.jsx)(he,{pendingText:ae,onDismiss:O,missingToolAction:ce&&G&&!G.clipboard.available?G.clipboard.action:null,onDismissMissingTool:()=>q(!1)}),(0,$.jsx)(Ce,{open:se,onOpenChange:U,percent:z,fps:B,more:V,onSetMore:H,onCommit:g,frameSize:f}),me&&(0,$.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-3 bg-black/70 text-sm text-white`,children:[(0,$.jsx)(o,{className:`size-6 opacity-70`}),(0,$.jsx)(`span`,{className:`max-w-sm text-center px-4`,children:me}),(n===`error`||n===`closed`)&&i!==`unsupported`&&(0,$.jsxs)(`button`,{onClick:c,className:`flex items-center gap-1.5 rounded-md bg-white/10 px-3 py-1.5 hover:bg-white/20`,children:[(0,$.jsx)(l,{className:`size-3.5`}),` Reconnect`]})]})]})}export{we as default};
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./panel-store-
|
|
1
|
+
import{t as e}from"./panel-store-1X6yM3XZ.js";var t=`ppm:run-in-terminal`,n=`ppm:run-in-terminal:ack`;function r(e){return e.replace(/^[ \t]*\$[ \t]+/gm,``).replace(/\s+$/,``)}function i(i,a){let o=r(i);if(!o)return;let s=!1,c=()=>{s=!0};window.addEventListener(n,c),window.dispatchEvent(new CustomEvent(t,{detail:{command:o,projectName:a}})),window.removeEventListener(n,c),!s&&e.getState().openInDock({type:`terminal`,title:`Terminal`,projectId:a??null,closable:!0,metadata:{...a?{projectName:a}:{},pendingCommand:o}})}export{t as n,i as r,n as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import{C as t,S as n}from"./vendor-markdown-QKPNiWEd.js";import"./vendor-ui-P9Ym7hCv.js";import{Mr as r,O as i,Qn as a,S as o,Wn as s,Yn as c,Zn as l,j as u}from"./icons-CO_II6D-.js";import{O as d,r as f}from"./api-client-F5Zi1sR0.js";import{n as p}from"./utils-btZ8C8-R.js";import"./portal-container-context-NFSuymMu.js";import"./context-menu-CH1mvCwA.js";import{n as m}from"./use-is-mobile-CkO33jqU.js";import{t as h}from"./button-CsmGH5xa.js";import{a as ee,n as g,o as _,t as v}from"./dialog-z8PLkL8n.js";import{t as te}from"./mobile-bottom-sheet-CLic9ovp.js";import"./use-visual-viewport-C307OVeV.js";import{t as y}from"./input-CP31LZnN.js";import{t as b}from"./scroll-area-Dp-P38kg.js";import{Ct as x,St as S,an as C,bt as w,mn as T,on as E,sn as D,un as O,vt as k,xt as A,yt as j}from"./index-DQCw6d-2.js";var M=e(t(),1),N=1e4;function P(){let[e,t]=(0,M.useState)([]),[n,r]=(0,M.useState)(!0),i=(0,M.useCallback)(async()=>{try{t(await f.get(`/api/schedules`))}catch{}finally{r(!1)}},[]);return(0,M.useEffect)(()=>{i();let e=setInterval(()=>{document.visibilityState===`visible`&&i()},N);return()=>clearInterval(e)},[i]),{schedules:e,loading:n,refetch:i}}function F(e){let[t,n]=(0,M.useState)([]),[r,i]=(0,M.useState)(!1),a=(0,M.useCallback)(async()=>{if(e!=null){i(!0);try{n(await f.get(`/api/schedules/${e}/runs?limit=20`))}catch{n([])}finally{i(!1)}}},[e]);return(0,M.useEffect)(()=>{a()},[a]),{runs:t,loading:r,refetch:a}}var I=n(),ne={done:`bg-success/10 text-success`,error:`bg-error/10 text-error`,running:`bg-warning/10 text-warning`,skipped:`bg-muted text-muted-foreground`};function re({scheduleId:e}){let{runs:t,loading:n}=F(e);return n&&t.length===0?(0,I.jsx)(`p`,{className:`text-[11px] text-muted-foreground py-1`,children:`Loading runs…`}):t.length===0?(0,I.jsx)(`p`,{className:`text-[11px] text-muted-foreground py-1`,children:`No runs yet.`}):(0,I.jsx)(`div`,{className:`space-y-1`,children:t.map(e=>(0,I.jsx)(ie,{run:e},e.id))})}function L(e){return new Date(e.includes(`T`)?e:e.replace(` `,`T`)+`Z`)}function ie({run:e}){let[t,n]=(0,M.useState)(!1),r=!!(e.output_truncated||e.error),i=e.ended_at?`${Math.round((L(e.ended_at).getTime()-L(e.started_at).getTime())/1e3)}s`:`…`;return(0,I.jsxs)(`div`,{className:`rounded border border-border text-[11px]`,children:[(0,I.jsxs)(`button`,{type:`button`,onClick:()=>r&&n(!t),className:p(`w-full flex items-center gap-2 px-2 py-2 min-h-11 text-left`,r&&`cursor-pointer hover:bg-accent/30`),children:[(0,I.jsx)(`span`,{className:p(`rounded px-1.5 py-0.5 font-medium shrink-0`,ne[e.status]),children:e.status}),(0,I.jsxs)(`span`,{className:`text-muted-foreground truncate flex-1`,children:[L(e.started_at).toLocaleString(),` · `,i,e.cost_usd!=null&&` · $${e.cost_usd.toFixed(4)}`,e.context_window_pct!=null&&` · ctx ${e.context_window_pct}%`]})]}),t&&(0,I.jsxs)(`div`,{className:`px-2 pb-2 space-y-1`,children:[e.error&&(0,I.jsx)(`p`,{className:`text-error break-all`,children:e.error}),e.output_truncated&&(0,I.jsx)(`pre`,{className:`overflow-auto max-h-96 whitespace-pre-wrap break-all text-muted-foreground font-mono text-[10px]`,children:e.output_truncated})]})]})}function ae({schedule:e,onEdit:t,onChanged:n}){let[o,l]=(0,M.useState)(!1),[m,h]=(0,M.useState)(0);return(0,I.jsxs)(`div`,{className:`rounded-lg border border-border`,children:[(0,I.jsxs)(C,{children:[(0,I.jsx)(T,{asChild:!0,children:(0,I.jsxs)(`button`,{type:`button`,onClick:()=>l(!o),className:`w-full flex items-center gap-2 px-2.5 py-2.5 min-h-11 text-left cursor-pointer hover:bg-accent/30`,children:[o?(0,I.jsx)(i,{className:`size-3.5 shrink-0 text-muted-foreground`}):(0,I.jsx)(u,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,I.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,I.jsx)(`p`,{className:`text-xs font-medium truncate`,children:e.name}),(0,I.jsxs)(`p`,{className:`text-[11px] text-muted-foreground truncate`,children:[(0,I.jsx)(`span`,{className:`font-mono`,children:e.cron_expr}),` · `,e.next_fire_at&&e.enabled?`next ${new Date(e.next_fire_at).toLocaleString()}`:`—`]})]}),(0,I.jsx)(`span`,{className:p(`rounded px-1.5 py-0.5 text-[10px] font-medium shrink-0`,e.enabled?`bg-success/10 text-success`:`bg-muted text-muted-foreground`),children:e.enabled?`Enabled`:`Disabled`})]})}),(0,I.jsxs)(E,{children:[(0,I.jsxs)(D,{onClick:async()=>{try{let t=await f.post(`/api/schedules/${e.id}/run-now`);d.success(`Run #${t.runId} started${t.wasRunning?` (previous run still active)`:``}`),l(!0),h(e=>e+1)}catch(e){d.error(e instanceof Error?e.message:`Run failed`)}},children:[(0,I.jsx)(c,{className:`size-3.5`}),` Run now`]}),(0,I.jsxs)(D,{onClick:async()=>{try{await f.patch(`/api/schedules/${e.id}`,{enabled:!e.enabled}),n()}catch(e){d.error(e instanceof Error?e.message:`Update failed`)}},children:[(0,I.jsx)(a,{className:`size-3.5`}),` `,e.enabled?`Disable`:`Enable`]}),(0,I.jsxs)(D,{onClick:t,children:[(0,I.jsx)(s,{className:`size-3.5`}),` Edit`]}),(0,I.jsx)(O,{}),(0,I.jsxs)(D,{variant:`destructive`,onClick:async()=>{try{await f.del(`/api/schedules/${e.id}`),d.success(`Schedule deleted`),n()}catch(e){d.error(e instanceof Error?e.message:`Delete failed`)}},children:[(0,I.jsx)(r,{className:`size-3.5`}),` Delete`]})]})]}),o&&(0,I.jsxs)(`div`,{className:`px-2.5 pb-2.5 space-y-1.5`,children:[(0,I.jsx)(`p`,{className:`text-[11px] text-muted-foreground break-all line-clamp-3`,children:e.prompt}),(0,I.jsx)(re,{scheduleId:e.id},m)]})]})}function R(e,t,n,r,i,a,o,s){return R.fromTZ(R.tp(e,t,n,r,i,a,o),s)}R.fromTZISO=(e,t,n)=>R.fromTZ(B(e,t),n),R.fromTZ=function(e,t){let n=new Date(Date.UTC(e.y,e.m-1,e.d,e.h,e.i,e.s)),r=z(e.tz,n),i=new Date(n.getTime()-r),a=z(e.tz,i);if(a-r===0)return i;{let r=new Date(n.getTime()-a),o=z(e.tz,r);if(o-a===0||!t&&o-a>0)return r;if(t)throw Error(`Invalid date passed to fromTZ()`);return i}},R.toTZ=function(e,t){let n=e.toLocaleString(`en-US`,{timeZone:t}).replace(/[\u202f]/,` `),r=new Date(n);return{y:r.getFullYear(),m:r.getMonth()+1,d:r.getDate(),h:r.getHours(),i:r.getMinutes(),s:r.getSeconds(),tz:t}},R.tp=(e,t,n,r,i,a,o)=>({y:e,m:t,d:n,h:r,i,s:a,tz:o});function z(e,t=new Date){let n=t.toLocaleString(`en-US`,{timeZone:e,timeZoneName:`shortOffset`}).split(` `).slice(-1)[0],r=t.toLocaleString(`en-US`).replace(/[\u202f]/,` `);return Date.parse(`${r} GMT`)-Date.parse(`${r} ${n}`)}function B(e,t){let n=new Date(Date.parse(e));if(isNaN(n))throw Error(`minitz: Invalid ISO8601 passed to parser.`);let r=e.substring(9);return e.includes(`Z`)||r.includes(`-`)||r.includes(`+`)?R.tp(n.getUTCFullYear(),n.getUTCMonth()+1,n.getUTCDate(),n.getUTCHours(),n.getUTCMinutes(),n.getUTCSeconds(),`Etc/UTC`):R.tp(n.getFullYear(),n.getMonth()+1,n.getDate(),n.getHours(),n.getMinutes(),n.getSeconds(),t)}R.minitz=R;var V=32,H=31|V,U=[1,2,4,8,16],W=class{pattern;timezone;second;minute;hour;day;month;dayOfWeek;lastDayOfMonth;starDOM;starDOW;constructor(e,t){this.pattern=e,this.timezone=t,this.second=Array(60).fill(0),this.minute=Array(60).fill(0),this.hour=Array(24).fill(0),this.day=Array(31).fill(0),this.month=Array(12).fill(0),this.dayOfWeek=Array(7).fill(0),this.lastDayOfMonth=!1,this.starDOM=!1,this.starDOW=!1,this.parse()}parse(){if(!(typeof this.pattern==`string`||this.pattern instanceof String))throw TypeError(`CronPattern: Pattern has to be of type string.`);this.pattern.indexOf(`@`)>=0&&(this.pattern=this.handleNicknames(this.pattern).trim());let e=this.pattern.replace(/\s+/g,` `).split(` `);if(e.length<5||e.length>6)throw TypeError(`CronPattern: invalid configuration format ('`+this.pattern+`'), exactly five or six space separated parts are required.`);if(e.length===5&&e.unshift(`0`),e[3].indexOf(`L`)>=0&&(e[3]=e[3].replace(`L`,``),this.lastDayOfMonth=!0),e[3]==`*`&&(this.starDOM=!0),e[4].length>=3&&(e[4]=this.replaceAlphaMonths(e[4])),e[5].length>=3&&(e[5]=this.replaceAlphaDays(e[5])),e[5]==`*`&&(this.starDOW=!0),this.pattern.indexOf(`?`)>=0){let t=new q(new Date,this.timezone).getDate(!0);e[0]=e[0].replace(`?`,t.getSeconds().toString()),e[1]=e[1].replace(`?`,t.getMinutes().toString()),e[2]=e[2].replace(`?`,t.getHours().toString()),this.starDOM||(e[3]=e[3].replace(`?`,t.getDate().toString())),e[4]=e[4].replace(`?`,(t.getMonth()+1).toString()),this.starDOW||(e[5]=e[5].replace(`?`,t.getDay().toString()))}this.throwAtIllegalCharacters(e),this.partToArray(`second`,e[0],0,1),this.partToArray(`minute`,e[1],0,1),this.partToArray(`hour`,e[2],0,1),this.partToArray(`day`,e[3],-1,1),this.partToArray(`month`,e[4],-1,1),this.partToArray(`dayOfWeek`,e[5],0,H),this.dayOfWeek[7]&&(this.dayOfWeek[0]=this.dayOfWeek[7])}partToArray(e,t,n,r){let i=this[e],a=e===`day`&&this.lastDayOfMonth;if(t===``&&!a)throw TypeError(`CronPattern: configuration entry `+e+` (`+t+`) is empty, check for trailing spaces.`);if(t===`*`)return i.fill(r);let o=t.split(`,`);if(o.length>1)for(let t=0;t<o.length;t++)this.partToArray(e,o[t],n,r);else t.indexOf(`-`)!==-1&&t.indexOf(`/`)!==-1?this.handleRangeWithStepping(t,e,n,r):t.indexOf(`-`)===-1?t.indexOf(`/`)===-1?t!==``&&this.handleNumber(t,e,n,r):this.handleStepping(t,e,n,r):this.handleRange(t,e,n,r)}throwAtIllegalCharacters(e){for(let t=0;t<e.length;t++)if((t===5?/[^/*0-9,\-#L]+/:/[^/*0-9,-]+/).test(e[t]))throw TypeError(`CronPattern: configuration entry `+t+` (`+e[t]+`) contains illegal characters.`)}handleNumber(e,t,n,r){let i=this.extractNth(e,t),a=parseInt(i[0],10)+n;if(isNaN(a))throw TypeError(`CronPattern: `+t+` is not a number: '`+e+`'`);this.setPart(t,a,i[1]||r)}setPart(e,t,n){if(!Object.prototype.hasOwnProperty.call(this,e))throw TypeError(`CronPattern: Invalid part specified: `+e);if(e===`dayOfWeek`){if(t===7&&(t=0),t<0||t>6)throw RangeError(`CronPattern: Invalid value for dayOfWeek: `+t);this.setNthWeekdayOfMonth(t,n);return}if(e===`second`||e===`minute`){if(t<0||t>=60)throw RangeError(`CronPattern: Invalid value for `+e+`: `+t)}else if(e===`hour`){if(t<0||t>=24)throw RangeError(`CronPattern: Invalid value for `+e+`: `+t)}else if(e===`day`){if(t<0||t>=31)throw RangeError(`CronPattern: Invalid value for `+e+`: `+t)}else if(e===`month`&&(t<0||t>=12))throw RangeError(`CronPattern: Invalid value for `+e+`: `+t);this[e][t]=n}handleRangeWithStepping(e,t,n,r){let i=this.extractNth(e,t),a=i[0].match(/^(\d+)-(\d+)\/(\d+)$/);if(a===null)throw TypeError(`CronPattern: Syntax error, illegal range with stepping: '`+e+`'`);let[,o,s,c]=a,l=parseInt(o,10)+n,u=parseInt(s,10)+n,d=parseInt(c,10);if(isNaN(l))throw TypeError(`CronPattern: Syntax error, illegal lower range (NaN)`);if(isNaN(u))throw TypeError(`CronPattern: Syntax error, illegal upper range (NaN)`);if(isNaN(d))throw TypeError(`CronPattern: Syntax error, illegal stepping: (NaN)`);if(d===0)throw TypeError(`CronPattern: Syntax error, illegal stepping: 0`);if(d>this[t].length)throw TypeError(`CronPattern: Syntax error, steps cannot be greater than maximum value of part (`+this[t].length+`)`);if(l>u)throw TypeError(`CronPattern: From value is larger than to value: '`+e+`'`);for(let e=l;e<=u;e+=d)this.setPart(t,e,i[1]||r)}extractNth(e,t){let n=e,r;if(n.includes(`#`)){if(t!==`dayOfWeek`)throw Error(`CronPattern: nth (#) only allowed in day-of-week field`);r=n.split(`#`)[1],n=n.split(`#`)[0]}return[n,r]}handleRange(e,t,n,r){let i=this.extractNth(e,t),a=i[0].split(`-`);if(a.length!==2)throw TypeError(`CronPattern: Syntax error, illegal range: '`+e+`'`);let o=parseInt(a[0],10)+n,s=parseInt(a[1],10)+n;if(isNaN(o))throw TypeError(`CronPattern: Syntax error, illegal lower range (NaN)`);if(isNaN(s))throw TypeError(`CronPattern: Syntax error, illegal upper range (NaN)`);if(o>s)throw TypeError(`CronPattern: From value is larger than to value: '`+e+`'`);for(let e=o;e<=s;e++)this.setPart(t,e,i[1]||r)}handleStepping(e,t,n,r){let i=this.extractNth(e,t),a=i[0].split(`/`);if(a.length!==2)throw TypeError(`CronPattern: Syntax error, illegal stepping: '`+e+`'`);a[0]===``&&(a[0]=`*`);let o=0;a[0]!==`*`&&(o=parseInt(a[0],10)+n);let s=parseInt(a[1],10);if(isNaN(s))throw TypeError(`CronPattern: Syntax error, illegal stepping: (NaN)`);if(s===0)throw TypeError(`CronPattern: Syntax error, illegal stepping: 0`);if(s>this[t].length)throw TypeError(`CronPattern: Syntax error, max steps for part is (`+this[t].length+`)`);for(let e=o;e<this[t].length;e+=s)this.setPart(t,e,i[1]||r)}replaceAlphaDays(e){return e.replace(/-sun/gi,`-7`).replace(/sun/gi,`0`).replace(/mon/gi,`1`).replace(/tue/gi,`2`).replace(/wed/gi,`3`).replace(/thu/gi,`4`).replace(/fri/gi,`5`).replace(/sat/gi,`6`)}replaceAlphaMonths(e){return e.replace(/jan/gi,`1`).replace(/feb/gi,`2`).replace(/mar/gi,`3`).replace(/apr/gi,`4`).replace(/may/gi,`5`).replace(/jun/gi,`6`).replace(/jul/gi,`7`).replace(/aug/gi,`8`).replace(/sep/gi,`9`).replace(/oct/gi,`10`).replace(/nov/gi,`11`).replace(/dec/gi,`12`)}handleNicknames(e){let t=e.trim().toLowerCase();return t===`@yearly`||t===`@annually`?`0 0 1 1 *`:t===`@monthly`?`0 0 1 * *`:t===`@weekly`?`0 0 * * 0`:t===`@daily`?`0 0 * * *`:t===`@hourly`?`0 * * * *`:e}setNthWeekdayOfMonth(e,t){if(typeof t!=`number`&&t===`L`)this.dayOfWeek[e]=this.dayOfWeek[e]|V;else if(t===H)this.dayOfWeek[e]=H;else if(t<6&&t>0)this.dayOfWeek[e]=this.dayOfWeek[e]|U[t-1];else throw TypeError(`CronPattern: nth weekday out of range, should be 1-5 or L. Value: ${t}, Type: ${typeof t}`)}},G=[31,28,31,30,31,30,31,31,30,31,30,31],K=[[`month`,`year`,0],[`day`,`month`,-1],[`hour`,`day`,0],[`minute`,`hour`,0],[`second`,`minute`,0]],q=class e{tz;ms;second;minute;hour;day;month;year;constructor(t,n){if(this.tz=n,t&&t instanceof Date)if(!isNaN(t))this.fromDate(t);else throw TypeError(`CronDate: Invalid date passed to CronDate constructor`);else if(t===void 0)this.fromDate(new Date);else if(t&&typeof t==`string`)this.fromString(t);else if(t instanceof e)this.fromCronDate(t);else throw TypeError(`CronDate: Invalid type (`+typeof t+`) passed to CronDate constructor`)}isNthWeekdayOfMonth(e,t,n,r){let i=new Date(Date.UTC(e,t,n)).getUTCDay(),a=0;for(let r=1;r<=n;r++)new Date(Date.UTC(e,t,r)).getUTCDay()===i&&a++;if(r&H&&U[a-1]&r)return!0;if(r&V){let r=new Date(Date.UTC(e,t+1,0)).getUTCDate();for(let a=n+1;a<=r;a++)if(new Date(Date.UTC(e,t,a)).getUTCDay()===i)return!1;return!0}return!1}fromDate(e){if(this.tz!==void 0)if(typeof this.tz==`number`)this.ms=e.getUTCMilliseconds(),this.second=e.getUTCSeconds(),this.minute=e.getUTCMinutes()+this.tz,this.hour=e.getUTCHours(),this.day=e.getUTCDate(),this.month=e.getUTCMonth(),this.year=e.getUTCFullYear(),this.apply();else{let t=R.toTZ(e,this.tz);this.ms=e.getMilliseconds(),this.second=t.s,this.minute=t.i,this.hour=t.h,this.day=t.d,this.month=t.m-1,this.year=t.y}else this.ms=e.getMilliseconds(),this.second=e.getSeconds(),this.minute=e.getMinutes(),this.hour=e.getHours(),this.day=e.getDate(),this.month=e.getMonth(),this.year=e.getFullYear()}fromCronDate(e){this.tz=e.tz,this.year=e.year,this.month=e.month,this.day=e.day,this.hour=e.hour,this.minute=e.minute,this.second=e.second,this.ms=e.ms}apply(){if(this.month>11||this.day>G[this.month]||this.hour>59||this.minute>59||this.second>59||this.hour<0||this.minute<0||this.second<0){let e=new Date(Date.UTC(this.year,this.month,this.day,this.hour,this.minute,this.second,this.ms));return this.ms=e.getUTCMilliseconds(),this.second=e.getUTCSeconds(),this.minute=e.getUTCMinutes(),this.hour=e.getUTCHours(),this.day=e.getUTCDate(),this.month=e.getUTCMonth(),this.year=e.getUTCFullYear(),!0}else return!1}fromString(e){if(typeof this.tz==`number`){let t=R.fromTZISO(e);this.ms=t.getUTCMilliseconds(),this.second=t.getUTCSeconds(),this.minute=t.getUTCMinutes(),this.hour=t.getUTCHours(),this.day=t.getUTCDate(),this.month=t.getUTCMonth(),this.year=t.getUTCFullYear(),this.apply()}else return this.fromDate(R.fromTZISO(e,this.tz))}findNext(e,t,n,r){let i=this[t],a;n.lastDayOfMonth&&(a=this.month===1?new Date(Date.UTC(this.year,this.month+1,0,0,0,0,0)).getUTCDate():G[this.month]);let o=!n.starDOW&&t==`day`?new Date(Date.UTC(this.year,this.month,1,0,0,0,0)).getUTCDay():void 0;for(let s=this[t]+r;s<n[t].length;s++){let c=n[t][s];if(t===`day`&&n.lastDayOfMonth&&s-r==a&&(c=1),t===`day`&&!n.starDOW){let t=n.dayOfWeek[(o+(s-r-1))%7];if(t&&t&H)t=this.isNthWeekdayOfMonth(this.year,this.month,s-r,t)?1:0;else if(t)throw Error(`CronDate: Invalid value for dayOfWeek encountered. ${t}`);e.legacyMode&&!n.starDOM?c||=t:c&&=t}if(c)return this[t]=s-r,i===this[t]?1:2}return 3}recurse(e,t,n){let r=this.findNext(t,K[n][0],e,K[n][2]);if(r>1){let i=n+1;for(;i<K.length;)this[K[i][0]]=-K[i][2],i++;if(r===3)return this[K[n][1]]++,this[K[n][0]]=-K[n][2],this.apply(),this.recurse(e,t,0);if(this.apply())return this.recurse(e,t,n-1)}return n+=1,n>=K.length?this:this.year>=3e3?null:this.recurse(e,t,n)}increment(e,t,n){return this.second+=t.interval!==void 0&&t.interval>1&&n?t.interval:1,this.ms=0,this.apply(),this.recurse(e,t,0)}getDate(e){return e||this.tz===void 0?new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.ms):typeof this.tz==`number`?new Date(Date.UTC(this.year,this.month,this.day,this.hour,this.minute-this.tz,this.second,this.ms)):R.fromTZ(R.tp(this.year,this.month+1,this.day,this.hour,this.minute,this.second,this.tz),!1)}getTime(){return this.getDate(!1).getTime()}};function oe(e){if(e===void 0&&(e={}),delete e.name,e.legacyMode=e.legacyMode===void 0?!0:e.legacyMode,e.paused=e.paused===void 0?!1:e.paused,e.maxRuns=e.maxRuns===void 0?1/0:e.maxRuns,e.catch=e.catch===void 0?!1:e.catch,e.interval=e.interval===void 0?0:parseInt(e.interval.toString(),10),e.utcOffset=e.utcOffset===void 0?void 0:parseInt(e.utcOffset.toString(),10),e.unref=e.unref===void 0?!1:e.unref,e.startAt&&=new q(e.startAt,e.timezone),e.stopAt&&=new q(e.stopAt,e.timezone),e.interval!==null){if(isNaN(e.interval))throw Error(`CronOptions: Supplied value for interval is not a number`);if(e.interval<0)throw Error(`CronOptions: Supplied value for interval can not be negative`)}if(e.utcOffset!==void 0){if(isNaN(e.utcOffset))throw Error(`CronOptions: Invalid value passed for utcOffset, should be number representing minutes offset from UTC.`);if(e.utcOffset<-870||e.utcOffset>870)throw Error(`CronOptions: utcOffset out of bounds.`);if(e.utcOffset!==void 0&&e.timezone)throw Error(`CronOptions: Combining 'utcOffset' with 'timezone' is not allowed.`)}if(e.unref!==!0&&e.unref!==!1)throw Error(`CronOptions: Unref should be either true, false or undefined(false).`);return e}function J(e){return Object.prototype.toString.call(e)===`[object Function]`||typeof e==`function`||e instanceof Function}function se(e){return J(e)}function ce(e){typeof Deno<`u`&&typeof Deno.unrefTimer<`u`?Deno.unrefTimer(e):e&&typeof e.unref<`u`&&e.unref()}var Y=30*1e3,X=[],Z=class{name;options;_states;fn;constructor(e,t,n){let r,i;if(J(t))i=t;else if(typeof t==`object`)r=t;else if(t!==void 0)throw Error(`Cron: Invalid argument passed for optionsIn. Should be one of function, or object (options).`);if(J(n))i=n;else if(typeof n==`object`)r=n;else if(n!==void 0)throw Error(`Cron: Invalid argument passed for funcIn. Should be one of function, or object (options).`);if(this.name=r?.name,this.options=oe(r),this._states={kill:!1,blocking:!1,previousRun:void 0,currentRun:void 0,once:void 0,currentTimeout:void 0,maxRuns:r?r.maxRuns:void 0,paused:r?r.paused:!1,pattern:new W(`* * * * *`)},e&&(e instanceof Date||typeof e==`string`&&e.indexOf(`:`)>0)?this._states.once=new q(e,this.options.timezone||this.options.utcOffset):this._states.pattern=new W(e,this.options.timezone),this.name){if(X.find(e=>e.name===this.name))throw Error(`Cron: Tried to initialize new named job '`+this.name+`', but name already taken.`);X.push(this)}return i!==void 0&&se(i)&&(this.fn=i,this.schedule()),this}nextRun(e){let t=this._next(e);return t?t.getDate(!1):null}nextRuns(e,t){this._states.maxRuns!==void 0&&e>this._states.maxRuns&&(e=this._states.maxRuns);let n=[],r=t||this._states.currentRun||void 0;for(;e--&&(r=this.nextRun(r));)n.push(r);return n}getPattern(){return this._states.pattern?this._states.pattern.pattern:void 0}isRunning(){let e=this.nextRun(this._states.currentRun),t=!this._states.paused,n=this.fn!==void 0,r=!this._states.kill;return t&&n&&r&&e!==null}isStopped(){return this._states.kill}isBusy(){return this._states.blocking}currentRun(){return this._states.currentRun?this._states.currentRun.getDate():null}previousRun(){return this._states.previousRun?this._states.previousRun.getDate():null}msToNext(e){let t=this._next(e);return t?e instanceof q||e instanceof Date?t.getTime()-e.getTime():t.getTime()-new q(e).getTime():null}stop(){this._states.kill=!0,this._states.currentTimeout&&clearTimeout(this._states.currentTimeout);let e=X.indexOf(this);e>=0&&X.splice(e,1)}pause(){return this._states.paused=!0,!this._states.kill}resume(){return this._states.paused=!1,!this._states.kill}schedule(e){if(e&&this.fn)throw Error(`Cron: It is not allowed to schedule two functions using the same Croner instance.`);e&&(this.fn=e);let t=this.msToNext(),n=this.nextRun(this._states.currentRun);return t==null||isNaN(t)||n===null?this:(t>Y&&(t=Y),this._states.currentTimeout=setTimeout(()=>this._checkTrigger(n),t),this._states.currentTimeout&&this.options.unref&&ce(this._states.currentTimeout),this)}async _trigger(e){if(this._states.blocking=!0,this._states.currentRun=new q(void 0,this.options.timezone||this.options.utcOffset),this.options.catch)try{this.fn!==void 0&&await this.fn(this,this.options.context)}catch(e){J(this.options.catch)&&this.options.catch(e,this)}else this.fn!==void 0&&await this.fn(this,this.options.context);this._states.previousRun=new q(e,this.options.timezone||this.options.utcOffset),this._states.blocking=!1}async trigger(){await this._trigger()}runsLeft(){return this._states.maxRuns}_checkTrigger(e){let t=new Date,n=!this._states.paused&&t.getTime()>=e.getTime(),r=this._states.blocking&&this.options.protect;n&&!r?(this._states.maxRuns!==void 0&&this._states.maxRuns--,this._trigger()):n&&r&&J(this.options.protect)&&setTimeout(()=>this.options.protect(this),0),this.schedule()}_next(e){let t=!!(e||this._states.currentRun),n=!1;!e&&this.options.startAt&&this.options.interval&&([e,t]=this._calculatePreviousRun(e,t),n=!e),e=new q(e,this.options.timezone||this.options.utcOffset),this.options.startAt&&e&&e.getTime()<this.options.startAt.getTime()&&(e=this.options.startAt);let r=this._states.once||new q(e,this.options.timezone||this.options.utcOffset);return!n&&r!==this._states.once&&(r=r.increment(this._states.pattern,this.options,t)),this._states.once&&this._states.once.getTime()<=e.getTime()||r===null||this._states.maxRuns!==void 0&&this._states.maxRuns<=0||this._states.kill||this.options.stopAt&&r.getTime()>=this.options.stopAt.getTime()?null:r}_calculatePreviousRun(e,t){let n=new q(void 0,this.options.timezone||this.options.utcOffset),r=e;if(this.options.startAt.getTime()<=n.getTime()){r=this.options.startAt;let e=r.getTime()+this.options.interval*1e3;for(;e<=n.getTime();)r=new q(r,this.options.timezone||this.options.utcOffset).increment(this._states.pattern,this.options,!0),e=r.getTime()+this.options.interval*1e3;t=!0}return r===null&&(r=void 0),[r,t]}},le=[`bypassPermissions`,`acceptEdits`,`default`,`plan`];function ue({open:e,schedule:t,onClose:n,onSaved:r}){let i=m(),[a,o]=(0,M.useState)(()=>$(t)),[s,c]=(0,M.useState)([]),[l,u]=(0,M.useState)(!1),[d,p]=(0,M.useState)(null);(0,M.useEffect)(()=>{e&&(o($(t)),p(null),f.get(`/api/projects`).then(c).catch(()=>c([])))},[e,t]);let C=(0,M.useMemo)(()=>{try{return new Z(a.cron_expr).nextRuns(3).map(e=>e.toLocaleString())}catch{return null}},[a.cron_expr]),T=(e,t)=>o(n=>({...n,[e]:t})),E=(0,I.jsxs)(`div`,{className:`space-y-3 px-1`,children:[(0,I.jsx)(Q,{label:`Name`,children:(0,I.jsx)(y,{value:a.name,onChange:e=>T(`name`,e.target.value),placeholder:`Morning PR review`,className:`h-11 md:h-9 text-xs`})}),(0,I.jsxs)(Q,{label:`Cron expression (local timezone)`,children:[(0,I.jsx)(y,{value:a.cron_expr,onChange:e=>T(`cron_expr`,e.target.value),placeholder:`0 7 * * *`,className:`h-11 md:h-9 text-xs font-mono`}),(0,I.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:C?`Next: ${C.join(` · `)}`:`—`})]}),(0,I.jsx)(Q,{label:`Project`,children:(0,I.jsxs)(k,{value:a.project_path,onValueChange:e=>T(`project_path`,e),children:[(0,I.jsx)(A,{className:`w-full min-h-11 md:min-h-9 text-xs`,children:(0,I.jsx)(S,{placeholder:`Select project`})}),(0,I.jsx)(j,{children:s.map(e=>(0,I.jsx)(w,{value:e.path,children:e.name},e.path))})]})}),(0,I.jsx)(Q,{label:`Prompt (do not embed secrets)`,children:(0,I.jsx)(`textarea`,{value:a.prompt,onChange:e=>T(`prompt`,e.target.value),placeholder:`Check open PRs and summarize. If nothing to do, finish immediately.`,rows:4,className:`w-full rounded-md border border-input bg-transparent px-3 py-2 text-xs outline-none focus-visible:ring-2 focus-visible:ring-ring/50 resize-y`})}),(0,I.jsxs)(Q,{label:`Permission mode`,children:[(0,I.jsxs)(k,{value:a.permission_mode,onValueChange:e=>T(`permission_mode`,e),children:[(0,I.jsx)(A,{className:`w-full min-h-11 md:min-h-9 text-xs`,children:(0,I.jsx)(S,{})}),(0,I.jsx)(j,{children:le.map(e=>(0,I.jsx)(w,{value:e,children:e},e))})]}),a.permission_mode===`bypassPermissions`&&(0,I.jsx)(`p`,{className:`text-[11px] text-warning`,children:`⚠ Unattended writes — agent can modify code and run commands`})]}),(0,I.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,I.jsx)(Q,{label:`Max turns (optional)`,children:(0,I.jsx)(y,{type:`number`,min:1,value:a.max_turns,onChange:e=>T(`max_turns`,e.target.value),placeholder:`∞`,className:`h-11 md:h-9 text-xs`})}),(0,I.jsx)(Q,{label:`Timeout (ms)`,children:(0,I.jsx)(y,{type:`number`,min:1e4,value:a.timeout_ms,onChange:e=>T(`timeout_ms`,e.target.value),className:`h-11 md:h-9 text-xs`})})]}),(0,I.jsxs)(`div`,{className:`flex items-center justify-between min-h-11`,children:[(0,I.jsx)(`span`,{className:`text-xs font-medium`,children:`Enabled`}),(0,I.jsx)(x,{checked:a.enabled,onCheckedChange:e=>T(`enabled`,e)})]}),d&&(0,I.jsx)(`p`,{className:`text-[11px] text-error`,children:d}),(0,I.jsx)(h,{onClick:async()=>{if(!a.name.trim()||!a.project_path||!a.prompt.trim()){p(`Name, project, and prompt are required`);return}if(!C){p(`Invalid cron expression`);return}u(!0),p(null);try{let e={name:a.name.trim(),cron_expr:a.cron_expr,project_path:a.project_path,prompt:a.prompt,permission_mode:a.permission_mode,max_turns:a.max_turns===``?null:Number(a.max_turns),timeout_ms:Number(a.timeout_ms)||18e5,enabled:a.enabled};t?await f.patch(`/api/schedules/${t.id}`,e):await f.post(`/api/schedules`,e),r(),n()}catch(e){p(e instanceof Error?e.message:String(e))}finally{u(!1)}},disabled:l,className:`w-full min-h-11 cursor-pointer`,children:l?`Saving…`:t?`Save changes`:`Create schedule`})]}),D=t?`Edit: ${t.name}`:`New schedule`;return i?(0,I.jsxs)(te,{open:e,onClose:n,className:`max-h-[85vh] flex flex-col`,children:[(0,I.jsx)(`p`,{className:`text-sm font-semibold text-center pb-2`,children:D}),(0,I.jsx)(b,{className:`flex-1 min-h-0 px-3 pb-3`,children:E})]}):(0,I.jsx)(v,{open:e,onOpenChange:e=>!e&&n(),children:(0,I.jsxs)(g,{className:`max-w-md max-h-[85vh] overflow-y-auto`,children:[(0,I.jsx)(ee,{children:(0,I.jsx)(_,{className:`text-sm`,children:D})}),E]})})}function Q({label:e,children:t}){return(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:e}),t]})}function $(e){return{name:e?.name??``,cron_expr:e?.cron_expr??`0 7 * * *`,project_path:e?.project_path??``,prompt:e?.prompt??``,permission_mode:e?.permission_mode??`bypassPermissions`,max_turns:e?.max_turns==null?``:String(e.max_turns),timeout_ms:String(e?.timeout_ms??18e5),enabled:e?!!e.enabled:!0}}function de(){let{schedules:e,loading:t,refetch:n}=P(),[r,i]=(0,M.useState)(!1),[a,s]=(0,M.useState)(null),c=()=>{s(null),i(!0)},u=e=>{s(e),i(!0)};return(0,I.jsxs)(`div`,{className:`space-y-3`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`Periodically wake Claude to work on a project unattended.`}),(0,I.jsxs)(h,{size:`sm`,onClick:c,className:`min-h-11 md:min-h-8 text-xs gap-1 cursor-pointer shrink-0`,children:[(0,I.jsx)(l,{className:`size-3.5`}),` Add`]})]}),t&&e.length===0?(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground py-4 text-center`,children:`Loading…`}):e.length===0?(0,I.jsxs)(`div`,{className:`flex flex-col items-center gap-2 py-8 text-center`,children:[(0,I.jsx)(o,{className:`size-8 text-muted-foreground/50`}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No schedules yet. Add one to run Claude periodically.`}),(0,I.jsxs)(h,{size:`sm`,onClick:c,className:`min-h-11 text-xs gap-1 cursor-pointer`,children:[(0,I.jsx)(l,{className:`size-3.5`}),` Add schedule`]})]}):(0,I.jsx)(`div`,{className:`space-y-2`,children:e.map(e=>(0,I.jsx)(ae,{schedule:e,onEdit:()=>u(e),onChanged:n},e.id))}),(0,I.jsx)(ue,{open:r,schedule:a,onClose:()=>i(!1),onSaved:n})]})}export{de as SchedulesSettingsSection};
|
|
1
|
+
import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import{C as t,S as n}from"./vendor-markdown-QKPNiWEd.js";import"./vendor-ui-P9Ym7hCv.js";import{Mr as r,O as i,Qn as a,S as o,Wn as s,Yn as c,Zn as l,j as u}from"./icons-CO_II6D-.js";import{O as d,r as f}from"./api-client-F5Zi1sR0.js";import{n as p}from"./utils-btZ8C8-R.js";import"./portal-container-context-NFSuymMu.js";import"./context-menu-CH1mvCwA.js";import{n as m}from"./use-is-mobile-CkO33jqU.js";import{t as h}from"./button-CsmGH5xa.js";import{a as ee,n as g,o as _,t as v}from"./dialog-z8PLkL8n.js";import{t as te}from"./mobile-bottom-sheet-CLic9ovp.js";import"./use-visual-viewport-C307OVeV.js";import{t as y}from"./input-CP31LZnN.js";import{t as b}from"./scroll-area-Dp-P38kg.js";import{Ct as x,St as S,Tt as C,bt as w,cn as T,fn as E,gn as D,ln as O,sn as k,wt as A,xt as j}from"./index-CIscPw4g.js";var M=e(t(),1),N=1e4;function P(){let[e,t]=(0,M.useState)([]),[n,r]=(0,M.useState)(!0),i=(0,M.useCallback)(async()=>{try{t(await f.get(`/api/schedules`))}catch{}finally{r(!1)}},[]);return(0,M.useEffect)(()=>{i();let e=setInterval(()=>{document.visibilityState===`visible`&&i()},N);return()=>clearInterval(e)},[i]),{schedules:e,loading:n,refetch:i}}function F(e){let[t,n]=(0,M.useState)([]),[r,i]=(0,M.useState)(!1),a=(0,M.useCallback)(async()=>{if(e!=null){i(!0);try{n(await f.get(`/api/schedules/${e}/runs?limit=20`))}catch{n([])}finally{i(!1)}}},[e]);return(0,M.useEffect)(()=>{a()},[a]),{runs:t,loading:r,refetch:a}}var I=n(),ne={done:`bg-success/10 text-success`,error:`bg-error/10 text-error`,running:`bg-warning/10 text-warning`,skipped:`bg-muted text-muted-foreground`};function re({scheduleId:e}){let{runs:t,loading:n}=F(e);return n&&t.length===0?(0,I.jsx)(`p`,{className:`text-[11px] text-muted-foreground py-1`,children:`Loading runs…`}):t.length===0?(0,I.jsx)(`p`,{className:`text-[11px] text-muted-foreground py-1`,children:`No runs yet.`}):(0,I.jsx)(`div`,{className:`space-y-1`,children:t.map(e=>(0,I.jsx)(ie,{run:e},e.id))})}function L(e){return new Date(e.includes(`T`)?e:e.replace(` `,`T`)+`Z`)}function ie({run:e}){let[t,n]=(0,M.useState)(!1),r=!!(e.output_truncated||e.error),i=e.ended_at?`${Math.round((L(e.ended_at).getTime()-L(e.started_at).getTime())/1e3)}s`:`…`;return(0,I.jsxs)(`div`,{className:`rounded border border-border text-[11px]`,children:[(0,I.jsxs)(`button`,{type:`button`,onClick:()=>r&&n(!t),className:p(`w-full flex items-center gap-2 px-2 py-2 min-h-11 text-left`,r&&`cursor-pointer hover:bg-accent/30`),children:[(0,I.jsx)(`span`,{className:p(`rounded px-1.5 py-0.5 font-medium shrink-0`,ne[e.status]),children:e.status}),(0,I.jsxs)(`span`,{className:`text-muted-foreground truncate flex-1`,children:[L(e.started_at).toLocaleString(),` · `,i,e.cost_usd!=null&&` · $${e.cost_usd.toFixed(4)}`,e.context_window_pct!=null&&` · ctx ${e.context_window_pct}%`]})]}),t&&(0,I.jsxs)(`div`,{className:`px-2 pb-2 space-y-1`,children:[e.error&&(0,I.jsx)(`p`,{className:`text-error break-all`,children:e.error}),e.output_truncated&&(0,I.jsx)(`pre`,{className:`overflow-auto max-h-96 whitespace-pre-wrap break-all text-muted-foreground font-mono text-[10px]`,children:e.output_truncated})]})]})}function ae({schedule:e,onEdit:t,onChanged:n}){let[o,l]=(0,M.useState)(!1),[m,h]=(0,M.useState)(0);return(0,I.jsxs)(`div`,{className:`rounded-lg border border-border`,children:[(0,I.jsxs)(k,{children:[(0,I.jsx)(D,{asChild:!0,children:(0,I.jsxs)(`button`,{type:`button`,onClick:()=>l(!o),className:`w-full flex items-center gap-2 px-2.5 py-2.5 min-h-11 text-left cursor-pointer hover:bg-accent/30`,children:[o?(0,I.jsx)(i,{className:`size-3.5 shrink-0 text-muted-foreground`}):(0,I.jsx)(u,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,I.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,I.jsx)(`p`,{className:`text-xs font-medium truncate`,children:e.name}),(0,I.jsxs)(`p`,{className:`text-[11px] text-muted-foreground truncate`,children:[(0,I.jsx)(`span`,{className:`font-mono`,children:e.cron_expr}),` · `,e.next_fire_at&&e.enabled?`next ${new Date(e.next_fire_at).toLocaleString()}`:`—`]})]}),(0,I.jsx)(`span`,{className:p(`rounded px-1.5 py-0.5 text-[10px] font-medium shrink-0`,e.enabled?`bg-success/10 text-success`:`bg-muted text-muted-foreground`),children:e.enabled?`Enabled`:`Disabled`})]})}),(0,I.jsxs)(T,{children:[(0,I.jsxs)(O,{onClick:async()=>{try{let t=await f.post(`/api/schedules/${e.id}/run-now`);d.success(`Run #${t.runId} started${t.wasRunning?` (previous run still active)`:``}`),l(!0),h(e=>e+1)}catch(e){d.error(e instanceof Error?e.message:`Run failed`)}},children:[(0,I.jsx)(c,{className:`size-3.5`}),` Run now`]}),(0,I.jsxs)(O,{onClick:async()=>{try{await f.patch(`/api/schedules/${e.id}`,{enabled:!e.enabled}),n()}catch(e){d.error(e instanceof Error?e.message:`Update failed`)}},children:[(0,I.jsx)(a,{className:`size-3.5`}),` `,e.enabled?`Disable`:`Enable`]}),(0,I.jsxs)(O,{onClick:t,children:[(0,I.jsx)(s,{className:`size-3.5`}),` Edit`]}),(0,I.jsx)(E,{}),(0,I.jsxs)(O,{variant:`destructive`,onClick:async()=>{try{await f.del(`/api/schedules/${e.id}`),d.success(`Schedule deleted`),n()}catch(e){d.error(e instanceof Error?e.message:`Delete failed`)}},children:[(0,I.jsx)(r,{className:`size-3.5`}),` Delete`]})]})]}),o&&(0,I.jsxs)(`div`,{className:`px-2.5 pb-2.5 space-y-1.5`,children:[(0,I.jsx)(`p`,{className:`text-[11px] text-muted-foreground break-all line-clamp-3`,children:e.prompt}),(0,I.jsx)(re,{scheduleId:e.id},m)]})]})}function R(e,t,n,r,i,a,o,s){return R.fromTZ(R.tp(e,t,n,r,i,a,o),s)}R.fromTZISO=(e,t,n)=>R.fromTZ(B(e,t),n),R.fromTZ=function(e,t){let n=new Date(Date.UTC(e.y,e.m-1,e.d,e.h,e.i,e.s)),r=z(e.tz,n),i=new Date(n.getTime()-r),a=z(e.tz,i);if(a-r===0)return i;{let r=new Date(n.getTime()-a),o=z(e.tz,r);if(o-a===0||!t&&o-a>0)return r;if(t)throw Error(`Invalid date passed to fromTZ()`);return i}},R.toTZ=function(e,t){let n=e.toLocaleString(`en-US`,{timeZone:t}).replace(/[\u202f]/,` `),r=new Date(n);return{y:r.getFullYear(),m:r.getMonth()+1,d:r.getDate(),h:r.getHours(),i:r.getMinutes(),s:r.getSeconds(),tz:t}},R.tp=(e,t,n,r,i,a,o)=>({y:e,m:t,d:n,h:r,i,s:a,tz:o});function z(e,t=new Date){let n=t.toLocaleString(`en-US`,{timeZone:e,timeZoneName:`shortOffset`}).split(` `).slice(-1)[0],r=t.toLocaleString(`en-US`).replace(/[\u202f]/,` `);return Date.parse(`${r} GMT`)-Date.parse(`${r} ${n}`)}function B(e,t){let n=new Date(Date.parse(e));if(isNaN(n))throw Error(`minitz: Invalid ISO8601 passed to parser.`);let r=e.substring(9);return e.includes(`Z`)||r.includes(`-`)||r.includes(`+`)?R.tp(n.getUTCFullYear(),n.getUTCMonth()+1,n.getUTCDate(),n.getUTCHours(),n.getUTCMinutes(),n.getUTCSeconds(),`Etc/UTC`):R.tp(n.getFullYear(),n.getMonth()+1,n.getDate(),n.getHours(),n.getMinutes(),n.getSeconds(),t)}R.minitz=R;var V=32,H=31|V,U=[1,2,4,8,16],W=class{pattern;timezone;second;minute;hour;day;month;dayOfWeek;lastDayOfMonth;starDOM;starDOW;constructor(e,t){this.pattern=e,this.timezone=t,this.second=Array(60).fill(0),this.minute=Array(60).fill(0),this.hour=Array(24).fill(0),this.day=Array(31).fill(0),this.month=Array(12).fill(0),this.dayOfWeek=Array(7).fill(0),this.lastDayOfMonth=!1,this.starDOM=!1,this.starDOW=!1,this.parse()}parse(){if(!(typeof this.pattern==`string`||this.pattern instanceof String))throw TypeError(`CronPattern: Pattern has to be of type string.`);this.pattern.indexOf(`@`)>=0&&(this.pattern=this.handleNicknames(this.pattern).trim());let e=this.pattern.replace(/\s+/g,` `).split(` `);if(e.length<5||e.length>6)throw TypeError(`CronPattern: invalid configuration format ('`+this.pattern+`'), exactly five or six space separated parts are required.`);if(e.length===5&&e.unshift(`0`),e[3].indexOf(`L`)>=0&&(e[3]=e[3].replace(`L`,``),this.lastDayOfMonth=!0),e[3]==`*`&&(this.starDOM=!0),e[4].length>=3&&(e[4]=this.replaceAlphaMonths(e[4])),e[5].length>=3&&(e[5]=this.replaceAlphaDays(e[5])),e[5]==`*`&&(this.starDOW=!0),this.pattern.indexOf(`?`)>=0){let t=new q(new Date,this.timezone).getDate(!0);e[0]=e[0].replace(`?`,t.getSeconds().toString()),e[1]=e[1].replace(`?`,t.getMinutes().toString()),e[2]=e[2].replace(`?`,t.getHours().toString()),this.starDOM||(e[3]=e[3].replace(`?`,t.getDate().toString())),e[4]=e[4].replace(`?`,(t.getMonth()+1).toString()),this.starDOW||(e[5]=e[5].replace(`?`,t.getDay().toString()))}this.throwAtIllegalCharacters(e),this.partToArray(`second`,e[0],0,1),this.partToArray(`minute`,e[1],0,1),this.partToArray(`hour`,e[2],0,1),this.partToArray(`day`,e[3],-1,1),this.partToArray(`month`,e[4],-1,1),this.partToArray(`dayOfWeek`,e[5],0,H),this.dayOfWeek[7]&&(this.dayOfWeek[0]=this.dayOfWeek[7])}partToArray(e,t,n,r){let i=this[e],a=e===`day`&&this.lastDayOfMonth;if(t===``&&!a)throw TypeError(`CronPattern: configuration entry `+e+` (`+t+`) is empty, check for trailing spaces.`);if(t===`*`)return i.fill(r);let o=t.split(`,`);if(o.length>1)for(let t=0;t<o.length;t++)this.partToArray(e,o[t],n,r);else t.indexOf(`-`)!==-1&&t.indexOf(`/`)!==-1?this.handleRangeWithStepping(t,e,n,r):t.indexOf(`-`)===-1?t.indexOf(`/`)===-1?t!==``&&this.handleNumber(t,e,n,r):this.handleStepping(t,e,n,r):this.handleRange(t,e,n,r)}throwAtIllegalCharacters(e){for(let t=0;t<e.length;t++)if((t===5?/[^/*0-9,\-#L]+/:/[^/*0-9,-]+/).test(e[t]))throw TypeError(`CronPattern: configuration entry `+t+` (`+e[t]+`) contains illegal characters.`)}handleNumber(e,t,n,r){let i=this.extractNth(e,t),a=parseInt(i[0],10)+n;if(isNaN(a))throw TypeError(`CronPattern: `+t+` is not a number: '`+e+`'`);this.setPart(t,a,i[1]||r)}setPart(e,t,n){if(!Object.prototype.hasOwnProperty.call(this,e))throw TypeError(`CronPattern: Invalid part specified: `+e);if(e===`dayOfWeek`){if(t===7&&(t=0),t<0||t>6)throw RangeError(`CronPattern: Invalid value for dayOfWeek: `+t);this.setNthWeekdayOfMonth(t,n);return}if(e===`second`||e===`minute`){if(t<0||t>=60)throw RangeError(`CronPattern: Invalid value for `+e+`: `+t)}else if(e===`hour`){if(t<0||t>=24)throw RangeError(`CronPattern: Invalid value for `+e+`: `+t)}else if(e===`day`){if(t<0||t>=31)throw RangeError(`CronPattern: Invalid value for `+e+`: `+t)}else if(e===`month`&&(t<0||t>=12))throw RangeError(`CronPattern: Invalid value for `+e+`: `+t);this[e][t]=n}handleRangeWithStepping(e,t,n,r){let i=this.extractNth(e,t),a=i[0].match(/^(\d+)-(\d+)\/(\d+)$/);if(a===null)throw TypeError(`CronPattern: Syntax error, illegal range with stepping: '`+e+`'`);let[,o,s,c]=a,l=parseInt(o,10)+n,u=parseInt(s,10)+n,d=parseInt(c,10);if(isNaN(l))throw TypeError(`CronPattern: Syntax error, illegal lower range (NaN)`);if(isNaN(u))throw TypeError(`CronPattern: Syntax error, illegal upper range (NaN)`);if(isNaN(d))throw TypeError(`CronPattern: Syntax error, illegal stepping: (NaN)`);if(d===0)throw TypeError(`CronPattern: Syntax error, illegal stepping: 0`);if(d>this[t].length)throw TypeError(`CronPattern: Syntax error, steps cannot be greater than maximum value of part (`+this[t].length+`)`);if(l>u)throw TypeError(`CronPattern: From value is larger than to value: '`+e+`'`);for(let e=l;e<=u;e+=d)this.setPart(t,e,i[1]||r)}extractNth(e,t){let n=e,r;if(n.includes(`#`)){if(t!==`dayOfWeek`)throw Error(`CronPattern: nth (#) only allowed in day-of-week field`);r=n.split(`#`)[1],n=n.split(`#`)[0]}return[n,r]}handleRange(e,t,n,r){let i=this.extractNth(e,t),a=i[0].split(`-`);if(a.length!==2)throw TypeError(`CronPattern: Syntax error, illegal range: '`+e+`'`);let o=parseInt(a[0],10)+n,s=parseInt(a[1],10)+n;if(isNaN(o))throw TypeError(`CronPattern: Syntax error, illegal lower range (NaN)`);if(isNaN(s))throw TypeError(`CronPattern: Syntax error, illegal upper range (NaN)`);if(o>s)throw TypeError(`CronPattern: From value is larger than to value: '`+e+`'`);for(let e=o;e<=s;e++)this.setPart(t,e,i[1]||r)}handleStepping(e,t,n,r){let i=this.extractNth(e,t),a=i[0].split(`/`);if(a.length!==2)throw TypeError(`CronPattern: Syntax error, illegal stepping: '`+e+`'`);a[0]===``&&(a[0]=`*`);let o=0;a[0]!==`*`&&(o=parseInt(a[0],10)+n);let s=parseInt(a[1],10);if(isNaN(s))throw TypeError(`CronPattern: Syntax error, illegal stepping: (NaN)`);if(s===0)throw TypeError(`CronPattern: Syntax error, illegal stepping: 0`);if(s>this[t].length)throw TypeError(`CronPattern: Syntax error, max steps for part is (`+this[t].length+`)`);for(let e=o;e<this[t].length;e+=s)this.setPart(t,e,i[1]||r)}replaceAlphaDays(e){return e.replace(/-sun/gi,`-7`).replace(/sun/gi,`0`).replace(/mon/gi,`1`).replace(/tue/gi,`2`).replace(/wed/gi,`3`).replace(/thu/gi,`4`).replace(/fri/gi,`5`).replace(/sat/gi,`6`)}replaceAlphaMonths(e){return e.replace(/jan/gi,`1`).replace(/feb/gi,`2`).replace(/mar/gi,`3`).replace(/apr/gi,`4`).replace(/may/gi,`5`).replace(/jun/gi,`6`).replace(/jul/gi,`7`).replace(/aug/gi,`8`).replace(/sep/gi,`9`).replace(/oct/gi,`10`).replace(/nov/gi,`11`).replace(/dec/gi,`12`)}handleNicknames(e){let t=e.trim().toLowerCase();return t===`@yearly`||t===`@annually`?`0 0 1 1 *`:t===`@monthly`?`0 0 1 * *`:t===`@weekly`?`0 0 * * 0`:t===`@daily`?`0 0 * * *`:t===`@hourly`?`0 * * * *`:e}setNthWeekdayOfMonth(e,t){if(typeof t!=`number`&&t===`L`)this.dayOfWeek[e]=this.dayOfWeek[e]|V;else if(t===H)this.dayOfWeek[e]=H;else if(t<6&&t>0)this.dayOfWeek[e]=this.dayOfWeek[e]|U[t-1];else throw TypeError(`CronPattern: nth weekday out of range, should be 1-5 or L. Value: ${t}, Type: ${typeof t}`)}},G=[31,28,31,30,31,30,31,31,30,31,30,31],K=[[`month`,`year`,0],[`day`,`month`,-1],[`hour`,`day`,0],[`minute`,`hour`,0],[`second`,`minute`,0]],q=class e{tz;ms;second;minute;hour;day;month;year;constructor(t,n){if(this.tz=n,t&&t instanceof Date)if(!isNaN(t))this.fromDate(t);else throw TypeError(`CronDate: Invalid date passed to CronDate constructor`);else if(t===void 0)this.fromDate(new Date);else if(t&&typeof t==`string`)this.fromString(t);else if(t instanceof e)this.fromCronDate(t);else throw TypeError(`CronDate: Invalid type (`+typeof t+`) passed to CronDate constructor`)}isNthWeekdayOfMonth(e,t,n,r){let i=new Date(Date.UTC(e,t,n)).getUTCDay(),a=0;for(let r=1;r<=n;r++)new Date(Date.UTC(e,t,r)).getUTCDay()===i&&a++;if(r&H&&U[a-1]&r)return!0;if(r&V){let r=new Date(Date.UTC(e,t+1,0)).getUTCDate();for(let a=n+1;a<=r;a++)if(new Date(Date.UTC(e,t,a)).getUTCDay()===i)return!1;return!0}return!1}fromDate(e){if(this.tz!==void 0)if(typeof this.tz==`number`)this.ms=e.getUTCMilliseconds(),this.second=e.getUTCSeconds(),this.minute=e.getUTCMinutes()+this.tz,this.hour=e.getUTCHours(),this.day=e.getUTCDate(),this.month=e.getUTCMonth(),this.year=e.getUTCFullYear(),this.apply();else{let t=R.toTZ(e,this.tz);this.ms=e.getMilliseconds(),this.second=t.s,this.minute=t.i,this.hour=t.h,this.day=t.d,this.month=t.m-1,this.year=t.y}else this.ms=e.getMilliseconds(),this.second=e.getSeconds(),this.minute=e.getMinutes(),this.hour=e.getHours(),this.day=e.getDate(),this.month=e.getMonth(),this.year=e.getFullYear()}fromCronDate(e){this.tz=e.tz,this.year=e.year,this.month=e.month,this.day=e.day,this.hour=e.hour,this.minute=e.minute,this.second=e.second,this.ms=e.ms}apply(){if(this.month>11||this.day>G[this.month]||this.hour>59||this.minute>59||this.second>59||this.hour<0||this.minute<0||this.second<0){let e=new Date(Date.UTC(this.year,this.month,this.day,this.hour,this.minute,this.second,this.ms));return this.ms=e.getUTCMilliseconds(),this.second=e.getUTCSeconds(),this.minute=e.getUTCMinutes(),this.hour=e.getUTCHours(),this.day=e.getUTCDate(),this.month=e.getUTCMonth(),this.year=e.getUTCFullYear(),!0}else return!1}fromString(e){if(typeof this.tz==`number`){let t=R.fromTZISO(e);this.ms=t.getUTCMilliseconds(),this.second=t.getUTCSeconds(),this.minute=t.getUTCMinutes(),this.hour=t.getUTCHours(),this.day=t.getUTCDate(),this.month=t.getUTCMonth(),this.year=t.getUTCFullYear(),this.apply()}else return this.fromDate(R.fromTZISO(e,this.tz))}findNext(e,t,n,r){let i=this[t],a;n.lastDayOfMonth&&(a=this.month===1?new Date(Date.UTC(this.year,this.month+1,0,0,0,0,0)).getUTCDate():G[this.month]);let o=!n.starDOW&&t==`day`?new Date(Date.UTC(this.year,this.month,1,0,0,0,0)).getUTCDay():void 0;for(let s=this[t]+r;s<n[t].length;s++){let c=n[t][s];if(t===`day`&&n.lastDayOfMonth&&s-r==a&&(c=1),t===`day`&&!n.starDOW){let t=n.dayOfWeek[(o+(s-r-1))%7];if(t&&t&H)t=this.isNthWeekdayOfMonth(this.year,this.month,s-r,t)?1:0;else if(t)throw Error(`CronDate: Invalid value for dayOfWeek encountered. ${t}`);e.legacyMode&&!n.starDOM?c||=t:c&&=t}if(c)return this[t]=s-r,i===this[t]?1:2}return 3}recurse(e,t,n){let r=this.findNext(t,K[n][0],e,K[n][2]);if(r>1){let i=n+1;for(;i<K.length;)this[K[i][0]]=-K[i][2],i++;if(r===3)return this[K[n][1]]++,this[K[n][0]]=-K[n][2],this.apply(),this.recurse(e,t,0);if(this.apply())return this.recurse(e,t,n-1)}return n+=1,n>=K.length?this:this.year>=3e3?null:this.recurse(e,t,n)}increment(e,t,n){return this.second+=t.interval!==void 0&&t.interval>1&&n?t.interval:1,this.ms=0,this.apply(),this.recurse(e,t,0)}getDate(e){return e||this.tz===void 0?new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.ms):typeof this.tz==`number`?new Date(Date.UTC(this.year,this.month,this.day,this.hour,this.minute-this.tz,this.second,this.ms)):R.fromTZ(R.tp(this.year,this.month+1,this.day,this.hour,this.minute,this.second,this.tz),!1)}getTime(){return this.getDate(!1).getTime()}};function oe(e){if(e===void 0&&(e={}),delete e.name,e.legacyMode=e.legacyMode===void 0?!0:e.legacyMode,e.paused=e.paused===void 0?!1:e.paused,e.maxRuns=e.maxRuns===void 0?1/0:e.maxRuns,e.catch=e.catch===void 0?!1:e.catch,e.interval=e.interval===void 0?0:parseInt(e.interval.toString(),10),e.utcOffset=e.utcOffset===void 0?void 0:parseInt(e.utcOffset.toString(),10),e.unref=e.unref===void 0?!1:e.unref,e.startAt&&=new q(e.startAt,e.timezone),e.stopAt&&=new q(e.stopAt,e.timezone),e.interval!==null){if(isNaN(e.interval))throw Error(`CronOptions: Supplied value for interval is not a number`);if(e.interval<0)throw Error(`CronOptions: Supplied value for interval can not be negative`)}if(e.utcOffset!==void 0){if(isNaN(e.utcOffset))throw Error(`CronOptions: Invalid value passed for utcOffset, should be number representing minutes offset from UTC.`);if(e.utcOffset<-870||e.utcOffset>870)throw Error(`CronOptions: utcOffset out of bounds.`);if(e.utcOffset!==void 0&&e.timezone)throw Error(`CronOptions: Combining 'utcOffset' with 'timezone' is not allowed.`)}if(e.unref!==!0&&e.unref!==!1)throw Error(`CronOptions: Unref should be either true, false or undefined(false).`);return e}function J(e){return Object.prototype.toString.call(e)===`[object Function]`||typeof e==`function`||e instanceof Function}function se(e){return J(e)}function ce(e){typeof Deno<`u`&&typeof Deno.unrefTimer<`u`?Deno.unrefTimer(e):e&&typeof e.unref<`u`&&e.unref()}var Y=30*1e3,X=[],Z=class{name;options;_states;fn;constructor(e,t,n){let r,i;if(J(t))i=t;else if(typeof t==`object`)r=t;else if(t!==void 0)throw Error(`Cron: Invalid argument passed for optionsIn. Should be one of function, or object (options).`);if(J(n))i=n;else if(typeof n==`object`)r=n;else if(n!==void 0)throw Error(`Cron: Invalid argument passed for funcIn. Should be one of function, or object (options).`);if(this.name=r?.name,this.options=oe(r),this._states={kill:!1,blocking:!1,previousRun:void 0,currentRun:void 0,once:void 0,currentTimeout:void 0,maxRuns:r?r.maxRuns:void 0,paused:r?r.paused:!1,pattern:new W(`* * * * *`)},e&&(e instanceof Date||typeof e==`string`&&e.indexOf(`:`)>0)?this._states.once=new q(e,this.options.timezone||this.options.utcOffset):this._states.pattern=new W(e,this.options.timezone),this.name){if(X.find(e=>e.name===this.name))throw Error(`Cron: Tried to initialize new named job '`+this.name+`', but name already taken.`);X.push(this)}return i!==void 0&&se(i)&&(this.fn=i,this.schedule()),this}nextRun(e){let t=this._next(e);return t?t.getDate(!1):null}nextRuns(e,t){this._states.maxRuns!==void 0&&e>this._states.maxRuns&&(e=this._states.maxRuns);let n=[],r=t||this._states.currentRun||void 0;for(;e--&&(r=this.nextRun(r));)n.push(r);return n}getPattern(){return this._states.pattern?this._states.pattern.pattern:void 0}isRunning(){let e=this.nextRun(this._states.currentRun),t=!this._states.paused,n=this.fn!==void 0,r=!this._states.kill;return t&&n&&r&&e!==null}isStopped(){return this._states.kill}isBusy(){return this._states.blocking}currentRun(){return this._states.currentRun?this._states.currentRun.getDate():null}previousRun(){return this._states.previousRun?this._states.previousRun.getDate():null}msToNext(e){let t=this._next(e);return t?e instanceof q||e instanceof Date?t.getTime()-e.getTime():t.getTime()-new q(e).getTime():null}stop(){this._states.kill=!0,this._states.currentTimeout&&clearTimeout(this._states.currentTimeout);let e=X.indexOf(this);e>=0&&X.splice(e,1)}pause(){return this._states.paused=!0,!this._states.kill}resume(){return this._states.paused=!1,!this._states.kill}schedule(e){if(e&&this.fn)throw Error(`Cron: It is not allowed to schedule two functions using the same Croner instance.`);e&&(this.fn=e);let t=this.msToNext(),n=this.nextRun(this._states.currentRun);return t==null||isNaN(t)||n===null?this:(t>Y&&(t=Y),this._states.currentTimeout=setTimeout(()=>this._checkTrigger(n),t),this._states.currentTimeout&&this.options.unref&&ce(this._states.currentTimeout),this)}async _trigger(e){if(this._states.blocking=!0,this._states.currentRun=new q(void 0,this.options.timezone||this.options.utcOffset),this.options.catch)try{this.fn!==void 0&&await this.fn(this,this.options.context)}catch(e){J(this.options.catch)&&this.options.catch(e,this)}else this.fn!==void 0&&await this.fn(this,this.options.context);this._states.previousRun=new q(e,this.options.timezone||this.options.utcOffset),this._states.blocking=!1}async trigger(){await this._trigger()}runsLeft(){return this._states.maxRuns}_checkTrigger(e){let t=new Date,n=!this._states.paused&&t.getTime()>=e.getTime(),r=this._states.blocking&&this.options.protect;n&&!r?(this._states.maxRuns!==void 0&&this._states.maxRuns--,this._trigger()):n&&r&&J(this.options.protect)&&setTimeout(()=>this.options.protect(this),0),this.schedule()}_next(e){let t=!!(e||this._states.currentRun),n=!1;!e&&this.options.startAt&&this.options.interval&&([e,t]=this._calculatePreviousRun(e,t),n=!e),e=new q(e,this.options.timezone||this.options.utcOffset),this.options.startAt&&e&&e.getTime()<this.options.startAt.getTime()&&(e=this.options.startAt);let r=this._states.once||new q(e,this.options.timezone||this.options.utcOffset);return!n&&r!==this._states.once&&(r=r.increment(this._states.pattern,this.options,t)),this._states.once&&this._states.once.getTime()<=e.getTime()||r===null||this._states.maxRuns!==void 0&&this._states.maxRuns<=0||this._states.kill||this.options.stopAt&&r.getTime()>=this.options.stopAt.getTime()?null:r}_calculatePreviousRun(e,t){let n=new q(void 0,this.options.timezone||this.options.utcOffset),r=e;if(this.options.startAt.getTime()<=n.getTime()){r=this.options.startAt;let e=r.getTime()+this.options.interval*1e3;for(;e<=n.getTime();)r=new q(r,this.options.timezone||this.options.utcOffset).increment(this._states.pattern,this.options,!0),e=r.getTime()+this.options.interval*1e3;t=!0}return r===null&&(r=void 0),[r,t]}},le=[`bypassPermissions`,`acceptEdits`,`default`,`plan`];function ue({open:e,schedule:t,onClose:n,onSaved:r}){let i=m(),[a,o]=(0,M.useState)(()=>$(t)),[s,c]=(0,M.useState)([]),[l,u]=(0,M.useState)(!1),[d,p]=(0,M.useState)(null);(0,M.useEffect)(()=>{e&&(o($(t)),p(null),f.get(`/api/projects`).then(c).catch(()=>c([])))},[e,t]);let T=(0,M.useMemo)(()=>{try{return new Z(a.cron_expr).nextRuns(3).map(e=>e.toLocaleString())}catch{return null}},[a.cron_expr]),E=(e,t)=>o(n=>({...n,[e]:t})),D=(0,I.jsxs)(`div`,{className:`space-y-3 px-1`,children:[(0,I.jsx)(Q,{label:`Name`,children:(0,I.jsx)(y,{value:a.name,onChange:e=>E(`name`,e.target.value),placeholder:`Morning PR review`,className:`h-11 md:h-9 text-xs`})}),(0,I.jsxs)(Q,{label:`Cron expression (local timezone)`,children:[(0,I.jsx)(y,{value:a.cron_expr,onChange:e=>E(`cron_expr`,e.target.value),placeholder:`0 7 * * *`,className:`h-11 md:h-9 text-xs font-mono`}),(0,I.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:T?`Next: ${T.join(` · `)}`:`—`})]}),(0,I.jsx)(Q,{label:`Project`,children:(0,I.jsxs)(w,{value:a.project_path,onValueChange:e=>E(`project_path`,e),children:[(0,I.jsx)(x,{className:`w-full min-h-11 md:min-h-9 text-xs`,children:(0,I.jsx)(A,{placeholder:`Select project`})}),(0,I.jsx)(j,{children:s.map(e=>(0,I.jsx)(S,{value:e.path,children:e.name},e.path))})]})}),(0,I.jsx)(Q,{label:`Prompt (do not embed secrets)`,children:(0,I.jsx)(`textarea`,{value:a.prompt,onChange:e=>E(`prompt`,e.target.value),placeholder:`Check open PRs and summarize. If nothing to do, finish immediately.`,rows:4,className:`w-full rounded-md border border-input bg-transparent px-3 py-2 text-xs outline-none focus-visible:ring-2 focus-visible:ring-ring/50 resize-y`})}),(0,I.jsxs)(Q,{label:`Permission mode`,children:[(0,I.jsxs)(w,{value:a.permission_mode,onValueChange:e=>E(`permission_mode`,e),children:[(0,I.jsx)(x,{className:`w-full min-h-11 md:min-h-9 text-xs`,children:(0,I.jsx)(A,{})}),(0,I.jsx)(j,{children:le.map(e=>(0,I.jsx)(S,{value:e,children:e},e))})]}),a.permission_mode===`bypassPermissions`&&(0,I.jsx)(`p`,{className:`text-[11px] text-warning`,children:`⚠ Unattended writes — agent can modify code and run commands`})]}),(0,I.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,I.jsx)(Q,{label:`Max turns (optional)`,children:(0,I.jsx)(y,{type:`number`,min:1,value:a.max_turns,onChange:e=>E(`max_turns`,e.target.value),placeholder:`∞`,className:`h-11 md:h-9 text-xs`})}),(0,I.jsx)(Q,{label:`Timeout (ms)`,children:(0,I.jsx)(y,{type:`number`,min:1e4,value:a.timeout_ms,onChange:e=>E(`timeout_ms`,e.target.value),className:`h-11 md:h-9 text-xs`})})]}),(0,I.jsxs)(`div`,{className:`flex items-center justify-between min-h-11`,children:[(0,I.jsx)(`span`,{className:`text-xs font-medium`,children:`Enabled`}),(0,I.jsx)(C,{checked:a.enabled,onCheckedChange:e=>E(`enabled`,e)})]}),d&&(0,I.jsx)(`p`,{className:`text-[11px] text-error`,children:d}),(0,I.jsx)(h,{onClick:async()=>{if(!a.name.trim()||!a.project_path||!a.prompt.trim()){p(`Name, project, and prompt are required`);return}if(!T){p(`Invalid cron expression`);return}u(!0),p(null);try{let e={name:a.name.trim(),cron_expr:a.cron_expr,project_path:a.project_path,prompt:a.prompt,permission_mode:a.permission_mode,max_turns:a.max_turns===``?null:Number(a.max_turns),timeout_ms:Number(a.timeout_ms)||18e5,enabled:a.enabled};t?await f.patch(`/api/schedules/${t.id}`,e):await f.post(`/api/schedules`,e),r(),n()}catch(e){p(e instanceof Error?e.message:String(e))}finally{u(!1)}},disabled:l,className:`w-full min-h-11 cursor-pointer`,children:l?`Saving…`:t?`Save changes`:`Create schedule`})]}),O=t?`Edit: ${t.name}`:`New schedule`;return i?(0,I.jsxs)(te,{open:e,onClose:n,className:`max-h-[85vh] flex flex-col`,children:[(0,I.jsx)(`p`,{className:`text-sm font-semibold text-center pb-2`,children:O}),(0,I.jsx)(b,{className:`flex-1 min-h-0 px-3 pb-3`,children:D})]}):(0,I.jsx)(v,{open:e,onOpenChange:e=>!e&&n(),children:(0,I.jsxs)(g,{className:`max-w-md max-h-[85vh] overflow-y-auto`,children:[(0,I.jsx)(ee,{children:(0,I.jsx)(_,{className:`text-sm`,children:O})}),D]})})}function Q({label:e,children:t}){return(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:e}),t]})}function $(e){return{name:e?.name??``,cron_expr:e?.cron_expr??`0 7 * * *`,project_path:e?.project_path??``,prompt:e?.prompt??``,permission_mode:e?.permission_mode??`bypassPermissions`,max_turns:e?.max_turns==null?``:String(e.max_turns),timeout_ms:String(e?.timeout_ms??18e5),enabled:e?!!e.enabled:!0}}function de(){let{schedules:e,loading:t,refetch:n}=P(),[r,i]=(0,M.useState)(!1),[a,s]=(0,M.useState)(null),c=()=>{s(null),i(!0)},u=e=>{s(e),i(!0)};return(0,I.jsxs)(`div`,{className:`space-y-3`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`Periodically wake Claude to work on a project unattended.`}),(0,I.jsxs)(h,{size:`sm`,onClick:c,className:`min-h-11 md:min-h-8 text-xs gap-1 cursor-pointer shrink-0`,children:[(0,I.jsx)(l,{className:`size-3.5`}),` Add`]})]}),t&&e.length===0?(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground py-4 text-center`,children:`Loading…`}):e.length===0?(0,I.jsxs)(`div`,{className:`flex flex-col items-center gap-2 py-8 text-center`,children:[(0,I.jsx)(o,{className:`size-8 text-muted-foreground/50`}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No schedules yet. Add one to run Claude periodically.`}),(0,I.jsxs)(h,{size:`sm`,onClick:c,className:`min-h-11 text-xs gap-1 cursor-pointer`,children:[(0,I.jsx)(l,{className:`size-3.5`}),` Add schedule`]})]}):(0,I.jsx)(`div`,{className:`space-y-2`,children:e.map(e=>(0,I.jsx)(ae,{schedule:e,onEdit:()=>u(e),onChanged:n},e.id))}),(0,I.jsx)(ue,{open:r,schedule:a,onClose:()=>i(!1),onSaved:n})]})}export{de as SchedulesSettingsSection};
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./panel-store-
|
|
1
|
+
import{t as e}from"./panel-store-1X6yM3XZ.js";var t=`ppm:send-to-chat`,n=`ppm:send-to-chat:ack`;function r(e){return typeof e.metadata?.lastActiveAt==`number`?e.metadata.lastActiveAt:-1}function i(t){let{panels:n,focusedPanelId:i}=e.getState(),a=Object.values(n).flatMap(e=>e.tabs.filter(e=>e.type===`chat`).map(t=>({tab:t,selected:e.activeTabId===t.id,focusedPanel:e.id===i})));if(a.length===0)return null;let o=t?a.filter(e=>e.tab.projectId===t||e.tab.metadata?.projectName===t):[],s=o.length>0?o:a,c=e=>[e.selected?e.focusedPanel?2:1:0,r(e.tab)];return s.reduce((e,t)=>{let[n,r]=[c(e),c(t)];for(let i=0;i<n.length;i++)if(n[i]!==r[i])return n[i]>r[i]?e:t;return e}).tab.id}function a(r){let{text:a,label:o,projectName:s}=r;if(!a.trim())return;let c=r.newTab?null:i(s),l=e.getState();if(c){l.setActiveTab(c);let e=!1,r=()=>{e=!0};if(window.addEventListener(n,r),window.dispatchEvent(new CustomEvent(t,{detail:{text:a,label:o,projectName:s,targetTabId:c}})),window.removeEventListener(n,r),e)return;let i=Object.values(l.panels).flatMap(e=>e.tabs).find(e=>e.id===c);l.updateTab(c,{metadata:{...i?.metadata,pendingMessage:a}});return}l.openTab({type:`chat`,title:`Chat`,projectId:null,metadata:{...s?{projectName:s}:{},pendingMessage:a},closable:!0})}export{t as n,a as r,n as t};
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import{C as t,S as n}from"./vendor-markdown-QKPNiWEd.js";import"./vendor-ui-P9Ym7hCv.js";import{ur as r}from"./icons-CO_II6D-.js";import{O as i,a,r as o}from"./api-client-F5Zi1sR0.js";import{n as s}from"./utils-btZ8C8-R.js";import"./portal-container-context-NFSuymMu.js";import"./context-menu-CH1mvCwA.js";import{n as c}from"./use-is-mobile-CkO33jqU.js";import{t as l}from"./button-CsmGH5xa.js";import{a as u,n as d,o as f,t as p}from"./dialog-z8PLkL8n.js";import{t as m}from"./mobile-bottom-sheet-CLic9ovp.js";import"./use-visual-viewport-C307OVeV.js";import{an as h,mn as g,on as _,sn as v,un as y}from"./index-DQCw6d-2.js";import{r as b}from"./format-bytes-DZ8bW_uF.js";import{r as x}from"./process-row-format-Dbs_tAZ2.js";import{r as ee,t as S}from"./sortable-header-IH47XuRI.js";var C=e(t(),1),w=[`start`,`stop`,`restart`,`enable`,`disable`],T=3e3;async function te(e,t,n){let r=a(),i={"Content-Type":`application/json`,"X-PPM-Request":`1`};r&&(i.Authorization=`Bearer ${r}`);let o=await fetch(`/api/system/services/${e}/${encodeURIComponent(t)}/${n}`,{method:`POST`,headers:i,body:`{}`}),s;try{s=await o.json()}catch{throw Error(o.ok?`Empty response from server`:`Server error (HTTP ${o.status})`)}if(s.ok===!1)throw Error(s.error??`HTTP ${o.status}`);return s.data}function E(e,t){return o.get(`/api/system/services/${e}/${encodeURIComponent(t)}`)}function ne(e){let[t,n]=(0,C.useState)(null),[r,i]=(0,C.useState)(null),a=(0,C.useRef)(!1),s=(0,C.useRef)(!0),c=(0,C.useCallback)(async()=>{if(!a.current){a.current=!0;try{let e=await o.get(`/api/system/services`);if(!s.current)return;n(e),i(null)}catch(e){s.current&&i(e instanceof Error?e.message:`Could not list services`)}finally{a.current=!1}}},[]);return(0,C.useEffect)(()=>(s.current=!0,()=>{s.current=!1}),[]),(0,C.useEffect)(()=>{if(!e)return;c();let t=setInterval(()=>void c(),T);return()=>clearInterval(t)},[e,c]),{snapshot:t,error:r,loading:t===null&&r===null,refresh:c}}var D=[`all`,`running`,`failed`,`enabled`];function O(e,t){switch(t){case`running`:return e.running;case`failed`:return e.failed;case`enabled`:return e.enabled;default:return!0}}function k(e,t){let n=t.trim().toLowerCase();return n?e.unit.toLowerCase().includes(n)||e.description.toLowerCase().includes(n):!0}function A(e,t){let n=e=>e.failed?0:e.running?1:2,r=n(e)-n(t);return r===0?e.unit.localeCompare(t.unit):r}function j(e,t,n,r){return e.filter(e=>e.scope===t&&O(e,n)&&k(e,r)).sort(A)}function M(e,t){let n=t?e.filter(e=>e.scope===t):e;return{total:n.length,running:n.filter(e=>e.running).length,failed:n.filter(e=>e.failed).length}}function N(e){return e.failed?`failed`:e.running?`running`:e.activeState===`activating`||e.activeState===`deactivating`||e.activeState===`reloading`?`busy`:`idle`}function P(e){let t=`${e.activeState} (${e.subState})`;return e.unitFileState?`${t} · ${e.unitFileState}`:t}var F=[{key:`name`,label:`Name`,width:null,from:`base`,align:`left`},{key:`pid`,label:`PID`,width:56,from:`@3xl`,align:`right`},{key:`cpu`,label:`CPU`,width:56,from:`@2xl`,align:`right`},{key:`ram`,label:`Memory`,width:72,from:`@2xl`,align:`right`},{key:`swap`,label:`Swap`,width:72,from:`@3xl`,align:`right`},{key:`disk`,label:`Drive`,width:112,from:`@4xl`,align:`right`},{key:`gpu`,label:`GPU`,width:56,from:`@4xl`,align:`right`},{key:`gpuMem`,label:`GPU Memory`,width:80,from:`@4xl`,align:`right`}],I=[`base`,`@2xl`,`@3xl`,`@4xl`],L={base:``,"@2xl":`hidden @2xl:block`,"@3xl":`hidden @3xl:block`,"@4xl":`hidden @4xl:block`};function R(e){return L[e.from]}function re(e){let t=I.indexOf(e);return F.filter(e=>I.indexOf(e.from)<=t)}function z(e){return re(e).map(e=>e.width===null?`minmax(0,1fr)`:`${e.width}px`).join(` `)}var B=[`grid gap-2 grid-cols-[var(--svc-cols-base)]`,`@2xl:grid-cols-[var(--svc-cols-2xl)]`,`@3xl:grid-cols-[var(--svc-cols-3xl)]`,`@4xl:grid-cols-[var(--svc-cols-4xl)]`].join(` `);function V(){return{"--svc-cols-base":z(`base`),"--svc-cols-2xl":z(`@2xl`),"--svc-cols-3xl":z(`@3xl`),"--svc-cols-4xl":z(`@4xl`)}}var H=n(),U={failed:`bg-error`,running:`bg-success`,busy:`bg-warning animate-pulse`,idle:`bg-text-subtle/40`},W={start:`Start`,stop:`Stop`,restart:`Restart`,enable:`Enable at boot`,disable:`Disable at boot`},G=[`stop`,`disable`],K=Object.fromEntries(F.map(e=>[e.key,R(e)])),q=e=>e===void 0?`—`:b(e),J=(e,t)=>e===void 0?`—`:`${e.toFixed(t)}%`;function Y({column:e,children:t}){return(0,H.jsx)(`span`,{className:s(`text-right text-[11px] tabular-nums text-text-subtle truncate`,K[e]),children:t})}function ie({service:e,resources:t,onOpen:n,onAction:r}){let i=N(e),a=w.filter(t=>e.refused?.[t]===void 0),o=w.map(t=>e.refused?.[t]).find(Boolean);return(0,H.jsxs)(h,{children:[(0,H.jsx)(g,{asChild:!0,children:(0,H.jsx)(`div`,{className:`select-none`,children:(0,H.jsxs)(`button`,{type:`button`,onClick:()=>n(e),"data-testid":`sysmon-service-row`,"data-unit":e.unit,"data-tone":i,"data-cpu":t?.cpu,"data-ram-mb":t?.ramMB,className:s(`w-full min-h-11 px-3 py-2 items-center text-left hover:bg-surface-hover transition-colors`,B),children:[(0,H.jsxs)(`span`,{className:`flex items-center gap-2 min-w-0`,children:[(0,H.jsx)(`span`,{className:s(`size-2 rounded-full shrink-0`,U[i]),"aria-hidden":!0}),(0,H.jsxs)(`span`,{className:`flex-1 min-w-0`,children:[(0,H.jsxs)(`span`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,H.jsx)(`span`,{className:`text-sm truncate`,children:e.unit}),e.enabled&&(0,H.jsx)(`span`,{className:`shrink-0 text-[10px] px-1 py-px rounded bg-surface-hover text-text-subtle`,children:`enabled`})]}),(0,H.jsx)(`span`,{className:`block text-[11px] text-text-subtle truncate`,children:e.description||P(e)})]})]}),(0,H.jsx)(Y,{column:`pid`,children:e.mainPid??`—`}),(0,H.jsx)(Y,{column:`cpu`,children:J(t?.cpu,1)}),(0,H.jsx)(Y,{column:`ram`,children:q(t?.ramMB)}),(0,H.jsx)(Y,{column:`swap`,children:q(t?.swapMB)}),(0,H.jsx)(Y,{column:`disk`,children:x(t?.diskReadBps,t?.diskWriteBps)}),(0,H.jsx)(Y,{column:`gpu`,children:J(t?.gpuPct,0)}),(0,H.jsx)(Y,{column:`gpuMem`,children:q(t?.gpuMemMB)})]})})}),(0,H.jsxs)(_,{children:[a.map(t=>(0,H.jsx)(v,{variant:G.includes(t)?`destructive`:void 0,onSelect:()=>r(e,t),children:W[t]},t)),a.length>0&&(0,H.jsx)(y,{}),(0,H.jsx)(v,{onSelect:()=>n(e),children:`Details and log`}),o&&(0,H.jsx)(`p`,{className:`px-2 py-1.5 text-[11px] text-text-subtle max-w-64`,children:o})]})]})}function ae({sortKey:e,sortDir:t,onSort:n}){return(0,H.jsx)(`div`,{role:`row`,"data-testid":`sysmon-services-header`,className:s(`sticky top-0 z-10 px-3 bg-background border-b border-border text-[11px] text-text-subtle`,B),children:F.map(r=>(0,H.jsx)(S,{label:r.label,field:r.key,activeKey:e,activeDir:t,onClick:n,align:r.align,testId:`sysmon-services-sort-${r.key}`,className:s(`px-0`,R(r))},r.key))})}function oe(e,t){if(!(e===void 0&&t===void 0))return(e??0)+(t??0)}function X(e,t){let n=e.resources;switch(t){case`pid`:return e.service.mainPid??void 0;case`cpu`:return n?.cpu;case`ram`:return n?.ramMB;case`swap`:return n?.swapMB;case`disk`:return oe(n?.diskReadBps,n?.diskWriteBps);case`gpu`:return n?.gpuPct;case`gpuMem`:return n?.gpuMemMB}}function se(e,t,n){return t===null?[...e].sort((e,t)=>A(e.service,t.service)):t===`name`?[...e].sort((e,t)=>{let r=e.service.unit.localeCompare(t.service.unit);return n===`asc`?r:-r}):[...e].sort((e,r)=>{let i=X(e,t),a=X(r,t);return i===void 0&&a===void 0?e.service.unit.localeCompare(r.service.unit):i===void 0?1:a===void 0?-1:i===a?e.service.unit.localeCompare(r.service.unit):n===`asc`?i-a:a-i})}function Z(e,t){return t===void 0?e:(e??0)+t}function ce(e){let t=new Map;for(let n of e){if(!n.unitKey)continue;let e=t.get(n.unitKey)??{count:0,cpu:0,ramMB:0};e.count+=1,e.cpu+=n.cpu,e.ramMB+=n.ramMB,e.swapMB=Z(e.swapMB,n.swapMB),e.diskReadBps=Z(e.diskReadBps,n.diskReadBps),e.diskWriteBps=Z(e.diskWriteBps,n.diskWriteBps),e.gpuPct=Z(e.gpuPct,n.gpuPct),e.gpuMemMB=Z(e.gpuMemMB,n.gpuMemMB),t.set(n.unitKey,e)}for(let e of t.values())e.cpu=Math.round(e.cpu*10)/10,e.ramMB=Math.round(e.ramMB*10)/10,e.gpuPct!==void 0&&(e.gpuPct=Math.min(100,Math.round(e.gpuPct*10)/10));return t}function le(e){return`${e.scope}:${e.unit}`}var ue=Object.freeze({count:0,cpu:0,ramMB:0,swapMB:0,diskReadBps:0,diskWriteBps:0,gpuPct:0,gpuMemMB:0}),de=[`.service`,`.scope`];function Q(e,t){return t?t.get(le(e))||(e.subState===`running`&&de.some(t=>e.unit.endsWith(t))?void 0:ue):void 0}function fe({target:e,onClose:t}){let n=c(),[r,i]=(0,C.useState)(null),[a,o]=(0,C.useState)(null);if((0,C.useEffect)(()=>{if(!e){i(null),o(null);return}let t=!0;return i(null),o(null),E(e.scope,e.unit).then(e=>{t&&i(e)}).catch(e=>{t&&o(e instanceof Error?e.message:`Could not read the unit`)}),()=>{t=!1}},[e]),!e)return null;let s=(0,H.jsxs)(`div`,{className:`space-y-3`,"data-testid":`sysmon-service-details`,"data-unit":e.unit,children:[(0,H.jsx)(`p`,{className:`text-xs text-text-subtle`,children:r?.description||e.description||P(e)}),(0,H.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-4 gap-y-2 text-xs`,children:[(0,H.jsx)($,{label:`State`,value:P(r??e)}),(0,H.jsx)($,{label:`Main PID`,value:(r??e).mainPid??`—`}),(0,H.jsx)($,{label:`User`,value:r?.user??`—`}),(0,H.jsx)($,{label:`Group`,value:r?.group??`—`}),(0,H.jsx)($,{label:`Scope`,value:e.scope}),(0,H.jsx)($,{label:`Unit file`,value:r?.fragmentPath??`—`})]}),(0,H.jsxs)(`div`,{className:`space-y-1`,children:[(0,H.jsx)(`h4`,{className:`text-xs font-medium text-text-secondary`,children:`Log (this boot)`}),(0,H.jsxs)(`div`,{className:`rounded-md border border-border bg-surface-hover/40 max-h-64 overflow-y-auto p-2`,children:[a&&(0,H.jsx)(`p`,{className:`text-xs text-error`,children:a}),!a&&r===null&&(0,H.jsx)(`p`,{className:`text-xs text-text-subtle`,children:`Reading the journal…`}),r?.logs.length===0&&(0,H.jsx)(`p`,{className:`text-xs text-text-subtle`,children:`No entries this boot.`}),r?.logs.map((e,t)=>(0,H.jsxs)(`p`,{className:`text-[11px] font-mono whitespace-pre-wrap break-words`,children:[(0,H.jsxs)(`span`,{className:`text-text-subtle`,children:[new Date(e.ts).toLocaleTimeString(),` `]}),e.message]},`${e.ts}-${t}`))]})]})]});return n?(0,H.jsx)(m,{open:!0,onClose:t,children:(0,H.jsxs)(`div`,{className:`px-4 pb-4 space-y-3`,children:[(0,H.jsx)(`h2`,{className:`text-base font-semibold break-all`,children:e.unit}),s]})}):(0,H.jsx)(p,{open:!0,onOpenChange:e=>!e&&t(),children:(0,H.jsxs)(d,{className:`sm:max-w-2xl`,children:[(0,H.jsx)(u,{children:(0,H.jsx)(f,{className:`break-all`,children:e.unit})}),s]})})}function $({label:e,value:t}){return(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`dt`,{className:`text-text-subtle`,children:e}),(0,H.jsx)(`dd`,{className:`truncate`,title:String(t),children:t})]})}var pe=[`stop`,`restart`,`disable`];function me(e){return pe.includes(e)}var he={stop:{title:`Stop service`,body:e=>`Stop ${e}? Anything depending on it stops too.`,cta:`Stop`},restart:{title:`Restart service`,body:e=>`Restart ${e}? It will be briefly unavailable.`,cta:`Restart`},disable:{title:`Disable at boot`,body:e=>`${e} will no longer start at boot. It keeps running now.`,cta:`Disable`}};function ge({pending:e,onConfirm:t,onCancel:n}){let r=c();if(!e)return null;let i=he[e.action];if(!i)return null;let a=(0,H.jsxs)(`div`,{className:`space-y-4`,"data-testid":`sysmon-service-confirm`,"data-action":e.action,children:[(0,H.jsx)(`p`,{className:`text-sm break-words`,children:i.body(e.service.unit)}),(0,H.jsxs)(`p`,{className:`text-xs text-text-subtle`,children:[e.service.scope===`system`?`System service`:`User service`,e.service.mainPid!==null&&` · pid ${e.service.mainPid}`]}),(0,H.jsxs)(`div`,{className:`flex flex-col-reverse md:flex-row gap-2 md:justify-end pt-2`,children:[(0,H.jsx)(l,{variant:`outline`,onClick:n,className:`min-h-11`,children:`Cancel`}),(0,H.jsx)(l,{variant:`destructive`,autoFocus:!1,onClick:()=>t(e),"data-testid":`sysmon-service-confirm-ok`,className:`min-h-11`,children:i.cta})]})]});return r?(0,H.jsx)(m,{open:!0,onClose:n,children:(0,H.jsxs)(`div`,{className:`px-4 pb-4`,children:[(0,H.jsx)(`h2`,{className:`text-base font-semibold mb-3`,children:i.title}),a]})}):(0,H.jsx)(p,{open:!0,onOpenChange:e=>!e&&n(),children:(0,H.jsxs)(d,{children:[(0,H.jsx)(u,{children:(0,H.jsx)(f,{children:i.title})}),a]})})}var _e=[`system`,`user`],ve={system:`System`,user:`User`},ye={all:`All`,running:`Running`,failed:`Failed`,enabled:`Enabled`};function be({active:e,metrics:t}){let{snapshot:n,error:a,loading:o,refresh:c}=ne(e),[l,u]=(0,C.useState)(`system`),[d,f]=(0,C.useState)(`all`),[p,m]=(0,C.useState)(``),[h,g]=(0,C.useState)(null),[_,v]=(0,C.useState)(`desc`),[y,b]=(0,C.useState)(null),[x,S]=(0,C.useState)(null),w=n?.services??[],T=(0,C.useMemo)(()=>j(w,l,d,p),[w,l,d,p]),E=(0,C.useMemo)(()=>M(w,l),[w,l]),O=(0,C.useMemo)(()=>t?.processes.length?ce(t.processes):null,[t]),k=(0,C.useMemo)(()=>se(T.map(e=>({service:e,resources:Q(e,O)})),h,_),[T,O,h,_]),A=(0,C.useCallback)(e=>{let[t,n]=ee(h,_,e);g(t),v(n)},[h,_]),N=(0,C.useCallback)(async({service:e,action:t})=>{S(null);try{await te(e.scope,e.unit,t),i.success(`${e.unit}: ${t} done`),await c()}catch(n){i.error(n instanceof Error?n.message:`Could not ${t} ${e.unit}`)}},[c]),P=(0,C.useCallback)((e,t)=>{me(t)?S({service:e,action:t}):N({service:e,action:t})},[N]);return n&&!n.supported?(0,H.jsxs)(`div`,{className:`p-4 text-sm text-text-subtle`,"data-testid":`sysmon-services`,children:[`This host has no service manager PPM can read.`,n.warnings.map((e,t)=>(0,H.jsx)(`p`,{className:`mt-1 text-xs`,children:e},t))]}):(0,H.jsxs)(`div`,{className:`h-full flex flex-col min-h-0 @container`,style:V(),"data-testid":`sysmon-services`,"data-row-count":k.length,"data-sort-key":h??`default`,"data-sort-dir":_,children:[(0,H.jsxs)(`div`,{className:`shrink-0 border-b border-border`,children:[(0,H.jsx)(`div`,{className:`flex items-center`,role:`tablist`,children:_e.map(e=>(0,H.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":l===e,onClick:()=>u(e),"data-testid":`sysmon-services-scope-${e}`,className:s(`flex-1 md:flex-none min-h-11 px-4 text-sm font-medium transition-colors`,l===e?`text-text-primary border-b-2 border-primary -mb-px`:`text-text-subtle hover:text-text-secondary`),children:ve[e]},e))}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 p-2`,children:[(0,H.jsxs)(`div`,{className:`relative flex-1 min-w-[140px]`,children:[(0,H.jsx)(r,{className:`absolute left-2 top-1/2 -translate-y-1/2 size-3.5 text-text-subtle`}),(0,H.jsx)(`input`,{type:`text`,value:p,onChange:e=>m(e.target.value),placeholder:`Search services`,"aria-label":`Search services`,"data-testid":`sysmon-service-search`,className:`w-full min-h-11 md:min-h-8 pl-7 pr-2 text-sm rounded-md border border-border bg-transparent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`})]}),D.map(e=>(0,H.jsx)(`button`,{type:`button`,onClick:()=>f(e),"aria-pressed":d===e,"data-testid":`sysmon-service-filter-${e}`,className:s(`min-h-11 md:min-h-8 px-3 text-xs rounded-md border transition-colors`,d===e?`border-primary bg-primary/10 text-primary`:`border-border hover:bg-surface-hover`),children:ye[e]},e))]}),(0,H.jsxs)(`p`,{className:`px-3 pb-2 text-[11px] text-text-subtle`,children:[E.total,` units · `,E.running,` running`,E.failed>0&&(0,H.jsxs)(`span`,{className:`text-error`,children:[` · `,E.failed,` failed`]})]})]}),n&&n.warnings.length>0&&(0,H.jsx)(`div`,{className:`px-3 py-1.5 text-[11px] text-warning bg-warning/10 border-b border-border shrink-0`,children:n.warnings.map((e,t)=>(0,H.jsx)(`div`,{children:e},t))}),(0,H.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-y-auto`,children:[(0,H.jsx)(ae,{sortKey:h,sortDir:_,onSort:A}),(0,H.jsxs)(`div`,{className:`divide-y divide-border`,children:[o&&(0,H.jsx)(`p`,{className:`p-4 text-sm text-text-subtle`,children:`Listing units…`}),a&&(0,H.jsx)(`p`,{className:`p-4 text-sm text-error`,children:a}),!o&&!a&&k.length===0&&(0,H.jsx)(`p`,{className:`p-4 text-sm text-text-subtle`,children:`No units match.`}),k.map(({service:e,resources:t})=>(0,H.jsx)(ie,{service:e,resources:t,onOpen:b,onAction:P},`${e.scope}:${e.unit}`))]})]}),(0,H.jsx)(fe,{target:y,onClose:()=>b(null)}),(0,H.jsx)(ge,{pending:x,onConfirm:e=>void N(e),onCancel:()=>S(null)})]})}export{be as ServicesPanel};
|
|
1
|
+
import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import{C as t,S as n}from"./vendor-markdown-QKPNiWEd.js";import"./vendor-ui-P9Ym7hCv.js";import{ur as r}from"./icons-CO_II6D-.js";import{O as i,a,r as o}from"./api-client-F5Zi1sR0.js";import{n as s}from"./utils-btZ8C8-R.js";import"./portal-container-context-NFSuymMu.js";import"./context-menu-CH1mvCwA.js";import{n as c}from"./use-is-mobile-CkO33jqU.js";import{t as l}from"./button-CsmGH5xa.js";import{a as u,n as d,o as f,t as p}from"./dialog-z8PLkL8n.js";import{t as m}from"./mobile-bottom-sheet-CLic9ovp.js";import"./use-visual-viewport-C307OVeV.js";import{cn as h,fn as g,gn as _,ln as v,sn as y}from"./index-CIscPw4g.js";import{r as b}from"./format-bytes-DZ8bW_uF.js";import{r as x}from"./process-row-format-Dbs_tAZ2.js";import{r as ee,t as S}from"./sortable-header-IH47XuRI.js";var C=e(t(),1),w=[`start`,`stop`,`restart`,`enable`,`disable`],T=3e3;async function te(e,t,n){let r=a(),i={"Content-Type":`application/json`,"X-PPM-Request":`1`};r&&(i.Authorization=`Bearer ${r}`);let o=await fetch(`/api/system/services/${e}/${encodeURIComponent(t)}/${n}`,{method:`POST`,headers:i,body:`{}`}),s;try{s=await o.json()}catch{throw Error(o.ok?`Empty response from server`:`Server error (HTTP ${o.status})`)}if(s.ok===!1)throw Error(s.error??`HTTP ${o.status}`);return s.data}function E(e,t){return o.get(`/api/system/services/${e}/${encodeURIComponent(t)}`)}function ne(e){let[t,n]=(0,C.useState)(null),[r,i]=(0,C.useState)(null),a=(0,C.useRef)(!1),s=(0,C.useRef)(!0),c=(0,C.useCallback)(async()=>{if(!a.current){a.current=!0;try{let e=await o.get(`/api/system/services`);if(!s.current)return;n(e),i(null)}catch(e){s.current&&i(e instanceof Error?e.message:`Could not list services`)}finally{a.current=!1}}},[]);return(0,C.useEffect)(()=>(s.current=!0,()=>{s.current=!1}),[]),(0,C.useEffect)(()=>{if(!e)return;c();let t=setInterval(()=>void c(),T);return()=>clearInterval(t)},[e,c]),{snapshot:t,error:r,loading:t===null&&r===null,refresh:c}}var D=[`all`,`running`,`failed`,`enabled`];function O(e,t){switch(t){case`running`:return e.running;case`failed`:return e.failed;case`enabled`:return e.enabled;default:return!0}}function k(e,t){let n=t.trim().toLowerCase();return n?e.unit.toLowerCase().includes(n)||e.description.toLowerCase().includes(n):!0}function A(e,t){let n=e=>e.failed?0:e.running?1:2,r=n(e)-n(t);return r===0?e.unit.localeCompare(t.unit):r}function j(e,t,n,r){return e.filter(e=>e.scope===t&&O(e,n)&&k(e,r)).sort(A)}function M(e,t){let n=t?e.filter(e=>e.scope===t):e;return{total:n.length,running:n.filter(e=>e.running).length,failed:n.filter(e=>e.failed).length}}function N(e){return e.failed?`failed`:e.running?`running`:e.activeState===`activating`||e.activeState===`deactivating`||e.activeState===`reloading`?`busy`:`idle`}function P(e){let t=`${e.activeState} (${e.subState})`;return e.unitFileState?`${t} · ${e.unitFileState}`:t}var F=[{key:`name`,label:`Name`,width:null,from:`base`,align:`left`},{key:`pid`,label:`PID`,width:56,from:`@3xl`,align:`right`},{key:`cpu`,label:`CPU`,width:56,from:`@2xl`,align:`right`},{key:`ram`,label:`Memory`,width:72,from:`@2xl`,align:`right`},{key:`swap`,label:`Swap`,width:72,from:`@3xl`,align:`right`},{key:`disk`,label:`Drive`,width:112,from:`@4xl`,align:`right`},{key:`gpu`,label:`GPU`,width:56,from:`@4xl`,align:`right`},{key:`gpuMem`,label:`GPU Memory`,width:80,from:`@4xl`,align:`right`}],I=[`base`,`@2xl`,`@3xl`,`@4xl`],L={base:``,"@2xl":`hidden @2xl:block`,"@3xl":`hidden @3xl:block`,"@4xl":`hidden @4xl:block`};function R(e){return L[e.from]}function re(e){let t=I.indexOf(e);return F.filter(e=>I.indexOf(e.from)<=t)}function z(e){return re(e).map(e=>e.width===null?`minmax(0,1fr)`:`${e.width}px`).join(` `)}var B=[`grid gap-2 grid-cols-[var(--svc-cols-base)]`,`@2xl:grid-cols-[var(--svc-cols-2xl)]`,`@3xl:grid-cols-[var(--svc-cols-3xl)]`,`@4xl:grid-cols-[var(--svc-cols-4xl)]`].join(` `);function V(){return{"--svc-cols-base":z(`base`),"--svc-cols-2xl":z(`@2xl`),"--svc-cols-3xl":z(`@3xl`),"--svc-cols-4xl":z(`@4xl`)}}var H=n(),U={failed:`bg-error`,running:`bg-success`,busy:`bg-warning animate-pulse`,idle:`bg-text-subtle/40`},W={start:`Start`,stop:`Stop`,restart:`Restart`,enable:`Enable at boot`,disable:`Disable at boot`},G=[`stop`,`disable`],K=Object.fromEntries(F.map(e=>[e.key,R(e)])),q=e=>e===void 0?`—`:b(e),J=(e,t)=>e===void 0?`—`:`${e.toFixed(t)}%`;function Y({column:e,children:t}){return(0,H.jsx)(`span`,{className:s(`text-right text-[11px] tabular-nums text-text-subtle truncate`,K[e]),children:t})}function ie({service:e,resources:t,onOpen:n,onAction:r}){let i=N(e),a=w.filter(t=>e.refused?.[t]===void 0),o=w.map(t=>e.refused?.[t]).find(Boolean);return(0,H.jsxs)(y,{children:[(0,H.jsx)(_,{asChild:!0,children:(0,H.jsx)(`div`,{className:`select-none`,children:(0,H.jsxs)(`button`,{type:`button`,onClick:()=>n(e),"data-testid":`sysmon-service-row`,"data-unit":e.unit,"data-tone":i,"data-cpu":t?.cpu,"data-ram-mb":t?.ramMB,className:s(`w-full min-h-11 px-3 py-2 items-center text-left hover:bg-surface-hover transition-colors`,B),children:[(0,H.jsxs)(`span`,{className:`flex items-center gap-2 min-w-0`,children:[(0,H.jsx)(`span`,{className:s(`size-2 rounded-full shrink-0`,U[i]),"aria-hidden":!0}),(0,H.jsxs)(`span`,{className:`flex-1 min-w-0`,children:[(0,H.jsxs)(`span`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,H.jsx)(`span`,{className:`text-sm truncate`,children:e.unit}),e.enabled&&(0,H.jsx)(`span`,{className:`shrink-0 text-[10px] px-1 py-px rounded bg-surface-hover text-text-subtle`,children:`enabled`})]}),(0,H.jsx)(`span`,{className:`block text-[11px] text-text-subtle truncate`,children:e.description||P(e)})]})]}),(0,H.jsx)(Y,{column:`pid`,children:e.mainPid??`—`}),(0,H.jsx)(Y,{column:`cpu`,children:J(t?.cpu,1)}),(0,H.jsx)(Y,{column:`ram`,children:q(t?.ramMB)}),(0,H.jsx)(Y,{column:`swap`,children:q(t?.swapMB)}),(0,H.jsx)(Y,{column:`disk`,children:x(t?.diskReadBps,t?.diskWriteBps)}),(0,H.jsx)(Y,{column:`gpu`,children:J(t?.gpuPct,0)}),(0,H.jsx)(Y,{column:`gpuMem`,children:q(t?.gpuMemMB)})]})})}),(0,H.jsxs)(h,{children:[a.map(t=>(0,H.jsx)(v,{variant:G.includes(t)?`destructive`:void 0,onSelect:()=>r(e,t),children:W[t]},t)),a.length>0&&(0,H.jsx)(g,{}),(0,H.jsx)(v,{onSelect:()=>n(e),children:`Details and log`}),o&&(0,H.jsx)(`p`,{className:`px-2 py-1.5 text-[11px] text-text-subtle max-w-64`,children:o})]})]})}function ae({sortKey:e,sortDir:t,onSort:n}){return(0,H.jsx)(`div`,{role:`row`,"data-testid":`sysmon-services-header`,className:s(`sticky top-0 z-10 px-3 bg-background border-b border-border text-[11px] text-text-subtle`,B),children:F.map(r=>(0,H.jsx)(S,{label:r.label,field:r.key,activeKey:e,activeDir:t,onClick:n,align:r.align,testId:`sysmon-services-sort-${r.key}`,className:s(`px-0`,R(r))},r.key))})}function oe(e,t){if(!(e===void 0&&t===void 0))return(e??0)+(t??0)}function X(e,t){let n=e.resources;switch(t){case`pid`:return e.service.mainPid??void 0;case`cpu`:return n?.cpu;case`ram`:return n?.ramMB;case`swap`:return n?.swapMB;case`disk`:return oe(n?.diskReadBps,n?.diskWriteBps);case`gpu`:return n?.gpuPct;case`gpuMem`:return n?.gpuMemMB}}function se(e,t,n){return t===null?[...e].sort((e,t)=>A(e.service,t.service)):t===`name`?[...e].sort((e,t)=>{let r=e.service.unit.localeCompare(t.service.unit);return n===`asc`?r:-r}):[...e].sort((e,r)=>{let i=X(e,t),a=X(r,t);return i===void 0&&a===void 0?e.service.unit.localeCompare(r.service.unit):i===void 0?1:a===void 0?-1:i===a?e.service.unit.localeCompare(r.service.unit):n===`asc`?i-a:a-i})}function Z(e,t){return t===void 0?e:(e??0)+t}function ce(e){let t=new Map;for(let n of e){if(!n.unitKey)continue;let e=t.get(n.unitKey)??{count:0,cpu:0,ramMB:0};e.count+=1,e.cpu+=n.cpu,e.ramMB+=n.ramMB,e.swapMB=Z(e.swapMB,n.swapMB),e.diskReadBps=Z(e.diskReadBps,n.diskReadBps),e.diskWriteBps=Z(e.diskWriteBps,n.diskWriteBps),e.gpuPct=Z(e.gpuPct,n.gpuPct),e.gpuMemMB=Z(e.gpuMemMB,n.gpuMemMB),t.set(n.unitKey,e)}for(let e of t.values())e.cpu=Math.round(e.cpu*10)/10,e.ramMB=Math.round(e.ramMB*10)/10,e.gpuPct!==void 0&&(e.gpuPct=Math.min(100,Math.round(e.gpuPct*10)/10));return t}function le(e){return`${e.scope}:${e.unit}`}var ue=Object.freeze({count:0,cpu:0,ramMB:0,swapMB:0,diskReadBps:0,diskWriteBps:0,gpuPct:0,gpuMemMB:0}),de=[`.service`,`.scope`];function Q(e,t){return t?t.get(le(e))||(e.subState===`running`&&de.some(t=>e.unit.endsWith(t))?void 0:ue):void 0}function fe({target:e,onClose:t}){let n=c(),[r,i]=(0,C.useState)(null),[a,o]=(0,C.useState)(null);if((0,C.useEffect)(()=>{if(!e){i(null),o(null);return}let t=!0;return i(null),o(null),E(e.scope,e.unit).then(e=>{t&&i(e)}).catch(e=>{t&&o(e instanceof Error?e.message:`Could not read the unit`)}),()=>{t=!1}},[e]),!e)return null;let s=(0,H.jsxs)(`div`,{className:`space-y-3`,"data-testid":`sysmon-service-details`,"data-unit":e.unit,children:[(0,H.jsx)(`p`,{className:`text-xs text-text-subtle`,children:r?.description||e.description||P(e)}),(0,H.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-4 gap-y-2 text-xs`,children:[(0,H.jsx)($,{label:`State`,value:P(r??e)}),(0,H.jsx)($,{label:`Main PID`,value:(r??e).mainPid??`—`}),(0,H.jsx)($,{label:`User`,value:r?.user??`—`}),(0,H.jsx)($,{label:`Group`,value:r?.group??`—`}),(0,H.jsx)($,{label:`Scope`,value:e.scope}),(0,H.jsx)($,{label:`Unit file`,value:r?.fragmentPath??`—`})]}),(0,H.jsxs)(`div`,{className:`space-y-1`,children:[(0,H.jsx)(`h4`,{className:`text-xs font-medium text-text-secondary`,children:`Log (this boot)`}),(0,H.jsxs)(`div`,{className:`rounded-md border border-border bg-surface-hover/40 max-h-64 overflow-y-auto p-2`,children:[a&&(0,H.jsx)(`p`,{className:`text-xs text-error`,children:a}),!a&&r===null&&(0,H.jsx)(`p`,{className:`text-xs text-text-subtle`,children:`Reading the journal…`}),r?.logs.length===0&&(0,H.jsx)(`p`,{className:`text-xs text-text-subtle`,children:`No entries this boot.`}),r?.logs.map((e,t)=>(0,H.jsxs)(`p`,{className:`text-[11px] font-mono whitespace-pre-wrap break-words`,children:[(0,H.jsxs)(`span`,{className:`text-text-subtle`,children:[new Date(e.ts).toLocaleTimeString(),` `]}),e.message]},`${e.ts}-${t}`))]})]})]});return n?(0,H.jsx)(m,{open:!0,onClose:t,children:(0,H.jsxs)(`div`,{className:`px-4 pb-4 space-y-3`,children:[(0,H.jsx)(`h2`,{className:`text-base font-semibold break-all`,children:e.unit}),s]})}):(0,H.jsx)(p,{open:!0,onOpenChange:e=>!e&&t(),children:(0,H.jsxs)(d,{className:`sm:max-w-2xl`,children:[(0,H.jsx)(u,{children:(0,H.jsx)(f,{className:`break-all`,children:e.unit})}),s]})})}function $({label:e,value:t}){return(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`dt`,{className:`text-text-subtle`,children:e}),(0,H.jsx)(`dd`,{className:`truncate`,title:String(t),children:t})]})}var pe=[`stop`,`restart`,`disable`];function me(e){return pe.includes(e)}var he={stop:{title:`Stop service`,body:e=>`Stop ${e}? Anything depending on it stops too.`,cta:`Stop`},restart:{title:`Restart service`,body:e=>`Restart ${e}? It will be briefly unavailable.`,cta:`Restart`},disable:{title:`Disable at boot`,body:e=>`${e} will no longer start at boot. It keeps running now.`,cta:`Disable`}};function ge({pending:e,onConfirm:t,onCancel:n}){let r=c();if(!e)return null;let i=he[e.action];if(!i)return null;let a=(0,H.jsxs)(`div`,{className:`space-y-4`,"data-testid":`sysmon-service-confirm`,"data-action":e.action,children:[(0,H.jsx)(`p`,{className:`text-sm break-words`,children:i.body(e.service.unit)}),(0,H.jsxs)(`p`,{className:`text-xs text-text-subtle`,children:[e.service.scope===`system`?`System service`:`User service`,e.service.mainPid!==null&&` · pid ${e.service.mainPid}`]}),(0,H.jsxs)(`div`,{className:`flex flex-col-reverse md:flex-row gap-2 md:justify-end pt-2`,children:[(0,H.jsx)(l,{variant:`outline`,onClick:n,className:`min-h-11`,children:`Cancel`}),(0,H.jsx)(l,{variant:`destructive`,autoFocus:!1,onClick:()=>t(e),"data-testid":`sysmon-service-confirm-ok`,className:`min-h-11`,children:i.cta})]})]});return r?(0,H.jsx)(m,{open:!0,onClose:n,children:(0,H.jsxs)(`div`,{className:`px-4 pb-4`,children:[(0,H.jsx)(`h2`,{className:`text-base font-semibold mb-3`,children:i.title}),a]})}):(0,H.jsx)(p,{open:!0,onOpenChange:e=>!e&&n(),children:(0,H.jsxs)(d,{children:[(0,H.jsx)(u,{children:(0,H.jsx)(f,{children:i.title})}),a]})})}var _e=[`system`,`user`],ve={system:`System`,user:`User`},ye={all:`All`,running:`Running`,failed:`Failed`,enabled:`Enabled`};function be({active:e,metrics:t}){let{snapshot:n,error:a,loading:o,refresh:c}=ne(e),[l,u]=(0,C.useState)(`system`),[d,f]=(0,C.useState)(`all`),[p,m]=(0,C.useState)(``),[h,g]=(0,C.useState)(null),[_,v]=(0,C.useState)(`desc`),[y,b]=(0,C.useState)(null),[x,S]=(0,C.useState)(null),w=n?.services??[],T=(0,C.useMemo)(()=>j(w,l,d,p),[w,l,d,p]),E=(0,C.useMemo)(()=>M(w,l),[w,l]),O=(0,C.useMemo)(()=>t?.processes.length?ce(t.processes):null,[t]),k=(0,C.useMemo)(()=>se(T.map(e=>({service:e,resources:Q(e,O)})),h,_),[T,O,h,_]),A=(0,C.useCallback)(e=>{let[t,n]=ee(h,_,e);g(t),v(n)},[h,_]),N=(0,C.useCallback)(async({service:e,action:t})=>{S(null);try{await te(e.scope,e.unit,t),i.success(`${e.unit}: ${t} done`),await c()}catch(n){i.error(n instanceof Error?n.message:`Could not ${t} ${e.unit}`)}},[c]),P=(0,C.useCallback)((e,t)=>{me(t)?S({service:e,action:t}):N({service:e,action:t})},[N]);return n&&!n.supported?(0,H.jsxs)(`div`,{className:`p-4 text-sm text-text-subtle`,"data-testid":`sysmon-services`,children:[`This host has no service manager PPM can read.`,n.warnings.map((e,t)=>(0,H.jsx)(`p`,{className:`mt-1 text-xs`,children:e},t))]}):(0,H.jsxs)(`div`,{className:`h-full flex flex-col min-h-0 @container`,style:V(),"data-testid":`sysmon-services`,"data-row-count":k.length,"data-sort-key":h??`default`,"data-sort-dir":_,children:[(0,H.jsxs)(`div`,{className:`shrink-0 border-b border-border`,children:[(0,H.jsx)(`div`,{className:`flex items-center`,role:`tablist`,children:_e.map(e=>(0,H.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":l===e,onClick:()=>u(e),"data-testid":`sysmon-services-scope-${e}`,className:s(`flex-1 md:flex-none min-h-11 px-4 text-sm font-medium transition-colors`,l===e?`text-text-primary border-b-2 border-primary -mb-px`:`text-text-subtle hover:text-text-secondary`),children:ve[e]},e))}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 p-2`,children:[(0,H.jsxs)(`div`,{className:`relative flex-1 min-w-[140px]`,children:[(0,H.jsx)(r,{className:`absolute left-2 top-1/2 -translate-y-1/2 size-3.5 text-text-subtle`}),(0,H.jsx)(`input`,{type:`text`,value:p,onChange:e=>m(e.target.value),placeholder:`Search services`,"aria-label":`Search services`,"data-testid":`sysmon-service-search`,className:`w-full min-h-11 md:min-h-8 pl-7 pr-2 text-sm rounded-md border border-border bg-transparent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`})]}),D.map(e=>(0,H.jsx)(`button`,{type:`button`,onClick:()=>f(e),"aria-pressed":d===e,"data-testid":`sysmon-service-filter-${e}`,className:s(`min-h-11 md:min-h-8 px-3 text-xs rounded-md border transition-colors`,d===e?`border-primary bg-primary/10 text-primary`:`border-border hover:bg-surface-hover`),children:ye[e]},e))]}),(0,H.jsxs)(`p`,{className:`px-3 pb-2 text-[11px] text-text-subtle`,children:[E.total,` units · `,E.running,` running`,E.failed>0&&(0,H.jsxs)(`span`,{className:`text-error`,children:[` · `,E.failed,` failed`]})]})]}),n&&n.warnings.length>0&&(0,H.jsx)(`div`,{className:`px-3 py-1.5 text-[11px] text-warning bg-warning/10 border-b border-border shrink-0`,children:n.warnings.map((e,t)=>(0,H.jsx)(`div`,{children:e},t))}),(0,H.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-y-auto`,children:[(0,H.jsx)(ae,{sortKey:h,sortDir:_,onSort:A}),(0,H.jsxs)(`div`,{className:`divide-y divide-border`,children:[o&&(0,H.jsx)(`p`,{className:`p-4 text-sm text-text-subtle`,children:`Listing units…`}),a&&(0,H.jsx)(`p`,{className:`p-4 text-sm text-error`,children:a}),!o&&!a&&k.length===0&&(0,H.jsx)(`p`,{className:`p-4 text-sm text-text-subtle`,children:`No units match.`}),k.map(({service:e,resources:t})=>(0,H.jsx)(ie,{service:e,resources:t,onOpen:b,onAction:P},`${e.scope}:${e.unit}`))]})]}),(0,H.jsx)(fe,{target:y,onClose:()=>b(null)}),(0,H.jsx)(ge,{pending:x,onConfirm:e=>void N(e),onCancel:()=>S(null)})]})}export{be as ServicesPanel};
|
|
Binary file
|
|
Binary file
|