khal-os 1.260324.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +23 -0
- package/.genie/mailbox/cli-sent.jsonl +3 -0
- package/.genie/mailbox/ds1-wave2-engineer-1.json +15 -0
- package/.genie/mailbox/ds1-wave2-engineer-2.json +15 -0
- package/.genie/mailbox/ds1-wave2-engineer-3.json +15 -0
- package/.genie/state/os-observability.json +39 -0
- package/.genie/state/tmux-control-mode-terminal.json +28 -0
- package/.genie/wishes/genieos-one-theme/WISH.md +417 -0
- package/.genie/wishes/workos-prod-rbac/WISH.md +345 -0
- package/.github/workflows/ci.yml +39 -0
- package/.github/workflows/release.yml +78 -0
- package/.github/workflows/version.yml +122 -0
- package/.husky/pre-commit +1 -0
- package/.pnpm-approve-builds.json +1 -0
- package/CLAUDE.md +117 -0
- package/LICENSE +21 -0
- package/README.md +38 -0
- package/biome.json +124 -0
- package/bun.lock +1249 -0
- package/docs/workos-setup.md +116 -0
- package/ecosystem.config.cjs +26 -0
- package/instrumentation.ts +8 -0
- package/knip.json +35 -0
- package/nats.conf +7 -0
- package/next.config.ts +25 -0
- package/package.json +78 -0
- package/packages/dev3000-app/components.ts +12 -0
- package/packages/dev3000-app/manifest.ts +19 -0
- package/packages/dev3000-app/package.json +23 -0
- package/packages/dev3000-app/views/dev3000/Dev3000App.tsx +758 -0
- package/packages/dev3000-app/views/dev3000/ErrorsPanel.tsx +160 -0
- package/packages/dev3000-app/views/dev3000/dev3000-context.tsx +21 -0
- package/packages/dev3000-app/views/dev3000/index.ts +4 -0
- package/packages/dev3000-app/views/dev3000/schema.ts +55 -0
- package/packages/dev3000-app/views/dev3000/service/index.ts +358 -0
- package/packages/dev3000-app/views/dev3000/service/runtime +1 -0
- package/packages/dev3000-app/views/dev3000/subjects.ts +9 -0
- package/packages/dev3000-app/views/dev3000/types.ts +77 -0
- package/packages/files-app/components.ts +12 -0
- package/packages/files-app/manifest.ts +19 -0
- package/packages/files-app/package.json +23 -0
- package/packages/files-app/views/files/ContextMenu.tsx +151 -0
- package/packages/files-app/views/files/DeleteConfirmDialog.tsx +39 -0
- package/packages/files-app/views/files/FileItem.tsx +128 -0
- package/packages/files-app/views/files/FilesApp.tsx +509 -0
- package/packages/files-app/views/files/FilesListView.tsx +201 -0
- package/packages/files-app/views/files/FilesToolbar.tsx +117 -0
- package/packages/files-app/views/files/GridView.tsx +90 -0
- package/packages/files-app/views/files/InlineInput.tsx +131 -0
- package/packages/files-app/views/files/UploadOverlay.tsx +61 -0
- package/packages/files-app/views/files/schema.ts +49 -0
- package/packages/files-app/views/files/service/index.ts +184 -0
- package/packages/files-app/views/files/service/runtime +1 -0
- package/packages/files-app/views/files/use-files.ts +201 -0
- package/packages/files-app/views/files/use-upload.ts +105 -0
- package/packages/genie-app/components.ts +12 -0
- package/packages/genie-app/lib/subjects.ts +87 -0
- package/packages/genie-app/manifest.ts +19 -0
- package/packages/genie-app/package.json +29 -0
- package/packages/genie-app/views/genie/service/agent-lifecycle.ts +136 -0
- package/packages/genie-app/views/genie/service/cli.ts +114 -0
- package/packages/genie-app/views/genie/service/comms.ts +141 -0
- package/packages/genie-app/views/genie/service/directory.ts +167 -0
- package/packages/genie-app/views/genie/service/index.ts +219 -0
- package/packages/genie-app/views/genie/service/system.ts +123 -0
- package/packages/genie-app/views/genie/service/teams.ts +191 -0
- package/packages/genie-app/views/genie/service/terminal-proxy.ts +184 -0
- package/packages/genie-app/views/genie/service/tmux-control.ts +318 -0
- package/packages/genie-app/views/genie/service/wishes.ts +270 -0
- package/packages/genie-app/views/genie/ui/GenieApp.tsx +5 -0
- package/packages/genie-app/views/genie/ui/PaneCard.tsx +307 -0
- package/packages/genie-app/views/genie/ui/Sidebar.tsx +212 -0
- package/packages/genie-app/views/genie/ui/TabBar.tsx +70 -0
- package/packages/genie-app/views/genie/ui/WorkspaceCanvas.tsx +343 -0
- package/packages/genie-app/views/genie/ui/XTermPane.tsx +306 -0
- package/packages/genie-app/views/genie/ui/hooks/useNatsAction.ts +54 -0
- package/packages/genie-app/views/genie/ui/hooks/useNatsRequest.ts +68 -0
- package/packages/genie-app/views/genie/ui/panels/AgentsPanel.tsx +399 -0
- package/packages/genie-app/views/genie/ui/panels/ChatPanel.tsx +351 -0
- package/packages/genie-app/views/genie/ui/panels/SystemPanel.tsx +195 -0
- package/packages/genie-app/views/genie/ui/panels/TeamsPanel.tsx +560 -0
- package/packages/genie-app/views/genie/ui/panels/WishesPanel.tsx +424 -0
- package/packages/nats-viewer-app/components.ts +12 -0
- package/packages/nats-viewer-app/manifest.ts +18 -0
- package/packages/nats-viewer-app/package.json +14 -0
- package/packages/nats-viewer-app/views/nats-viewer/ActiveSubs.tsx +34 -0
- package/packages/nats-viewer-app/views/nats-viewer/MessageLog.tsx +247 -0
- package/packages/nats-viewer-app/views/nats-viewer/NatsViewer.tsx +209 -0
- package/packages/nats-viewer-app/views/nats-viewer/PublishPanel.tsx +111 -0
- package/packages/nats-viewer-app/views/nats-viewer/RequestPanel.tsx +165 -0
- package/packages/nats-viewer-app/views/nats-viewer/Sidebar.tsx +59 -0
- package/packages/nats-viewer-app/views/nats-viewer/SubjectCatalog.tsx +63 -0
- package/packages/nats-viewer-app/views/nats-viewer/SubscribeInput.tsx +59 -0
- package/packages/nats-viewer-app/views/nats-viewer/index.ts +5 -0
- package/packages/nats-viewer-app/views/nats-viewer/nats-viewer-context.tsx +31 -0
- package/packages/nats-viewer-app/views/nats-viewer/types.ts +7 -0
- package/packages/nats-viewer-app/views/nats-viewer/use-message-buffer.ts +55 -0
- package/packages/os-cli/package.json +18 -0
- package/packages/os-cli/src/commands/events.ts +176 -0
- package/packages/os-cli/src/commands/logs.ts +96 -0
- package/packages/os-cli/src/commands/status.ts +53 -0
- package/packages/os-cli/src/commands/traces.ts +115 -0
- package/packages/os-cli/src/index.ts +15 -0
- package/packages/os-cli/src/lib/formatter.ts +123 -0
- package/packages/os-cli/src/lib/nats.ts +16 -0
- package/packages/os-cli/src/lib/trace-tree.ts +144 -0
- package/packages/os-cli/tsconfig.json +12 -0
- package/packages/os-sdk/package.json +27 -0
- package/packages/os-sdk/src/api/handler.ts +67 -0
- package/packages/os-sdk/src/config.ts +68 -0
- package/packages/os-sdk/src/db/factory.test.ts +42 -0
- package/packages/os-sdk/src/db/factory.ts +72 -0
- package/packages/os-sdk/src/db/migrate.ts +140 -0
- package/packages/os-sdk/src/db/provision.ts +44 -0
- package/packages/os-sdk/src/index.ts +36 -0
- package/packages/os-sdk/src/service/console-intercept.ts +60 -0
- package/packages/os-sdk/src/service/logger.ts +88 -0
- package/packages/os-sdk/src/service/o11y-streams.ts +88 -0
- package/packages/os-sdk/src/service/runtime.ts +259 -0
- package/packages/os-sdk/src/service/trace.ts +71 -0
- package/packages/os-sdk/tsconfig.json +16 -0
- package/packages/os-ui/package.json +13 -0
- package/packages/os-ui/src/index.ts +29 -0
- package/packages/os-ui/src/server.ts +4 -0
- package/packages/os-ui/tsconfig.json +19 -0
- package/packages/settings-app/components.ts +12 -0
- package/packages/settings-app/manifest.ts +18 -0
- package/packages/settings-app/package.json +14 -0
- package/packages/settings-app/views/settings/Settings.tsx +492 -0
- package/packages/terminal-app/components.ts +12 -0
- package/packages/terminal-app/manifest.ts +20 -0
- package/packages/terminal-app/package.json +23 -0
- package/packages/terminal-app/views/terminal/schema.ts +82 -0
- package/packages/terminal-app/views/terminal/service/index.ts +133 -0
- package/packages/terminal-app/views/terminal/service/runtime +1 -0
- package/packages/terminal-app/views/terminal/service/session.ts +290 -0
- package/packages/terminal-app/views/terminal/service/shell-hooks/bashrc-hook.sh +21 -0
- package/packages/terminal-app/views/terminal/types.ts +26 -0
- package/packages/terminal-app/views/terminal/ui/MultiTerminalApp.tsx +615 -0
- package/packages/terminal-app/views/terminal/ui/SplitDragHandle.tsx +91 -0
- package/packages/terminal-app/views/terminal/ui/SplitPaneRenderer.tsx +112 -0
- package/packages/terminal-app/views/terminal/ui/TerminalPane.tsx +478 -0
- package/packages/terminal-app/views/terminal/ui/TerminalTabBar.tsx +131 -0
- package/pnpm-workspace.yaml +9 -0
- package/postcss.config.mjs +7 -0
- package/public/file.svg +1 -0
- package/public/globe.svg +1 -0
- package/public/icons/code-server.svg +6 -0
- package/public/icons/default.svg +5 -0
- package/public/icons/dusk/1password.svg +1 -0
- package/public/icons/dusk/activity_monitor.svg +1 -0
- package/public/icons/dusk/app_store.svg +1 -0
- package/public/icons/dusk/atom.svg +1 -0
- package/public/icons/dusk/brave.svg +1 -0
- package/public/icons/dusk/calculator.svg +1 -0
- package/public/icons/dusk/calendar.svg +1 -0
- package/public/icons/dusk/chrome.svg +1 -0
- package/public/icons/dusk/chrome2.svg +1 -0
- package/public/icons/dusk/dashboard.svg +13 -0
- package/public/icons/dusk/discord.svg +1 -0
- package/public/icons/dusk/dropbox.svg +1 -0
- package/public/icons/dusk/electron.svg +1 -0
- package/public/icons/dusk/figma.svg +1 -0
- package/public/icons/dusk/finder.svg +1 -0
- package/public/icons/dusk/finder2.svg +1 -0
- package/public/icons/dusk/finder3.svg +1 -0
- package/public/icons/dusk/firefox.svg +1 -0
- package/public/icons/dusk/framer.svg +1 -0
- package/public/icons/dusk/gimp.svg +1 -0
- package/public/icons/dusk/github_desktop.svg +1 -0
- package/public/icons/dusk/hyper.svg +1 -0
- package/public/icons/dusk/hyper3.svg +1 -0
- package/public/icons/dusk/intellij.svg +1 -0
- package/public/icons/dusk/iterm2.svg +1 -0
- package/public/icons/dusk/itunes.svg +1 -0
- package/public/icons/dusk/mail.svg +1 -0
- package/public/icons/dusk/messenger.svg +1 -0
- package/public/icons/dusk/mongodb.svg +1 -0
- package/public/icons/dusk/notes.svg +1 -0
- package/public/icons/dusk/notion.svg +1 -0
- package/public/icons/dusk/obs.svg +1 -0
- package/public/icons/dusk/pages.svg +1 -0
- package/public/icons/dusk/photos.svg +1 -0
- package/public/icons/dusk/postman.svg +1 -0
- package/public/icons/dusk/preview.svg +1 -0
- package/public/icons/dusk/reminders.svg +1 -0
- package/public/icons/dusk/safari.svg +1 -0
- package/public/icons/dusk/sequel_pro.svg +1 -0
- package/public/icons/dusk/sketch.svg +1 -0
- package/public/icons/dusk/skype.svg +1 -0
- package/public/icons/dusk/slack.svg +1 -0
- package/public/icons/dusk/slack2.svg +1 -0
- package/public/icons/dusk/spotify.svg +1 -0
- package/public/icons/dusk/steam.svg +1 -0
- package/public/icons/dusk/system_preferences.svg +1 -0
- package/public/icons/dusk/tableplus.svg +1 -0
- package/public/icons/dusk/teams.svg +1 -0
- package/public/icons/dusk/telegram.svg +1 -0
- package/public/icons/dusk/terminal.svg +1 -0
- package/public/icons/dusk/todoist.svg +1 -0
- package/public/icons/dusk/trash.svg +1 -0
- package/public/icons/dusk/trello.svg +1 -0
- package/public/icons/dusk/vivaldi.svg +1 -0
- package/public/icons/dusk/vlc.svg +1 -0
- package/public/icons/dusk/vscode.svg +1 -0
- package/public/icons/dusk/whatsapp.svg +1 -0
- package/public/icons/dusk/xeyes.svg +1 -0
- package/public/icons/dusk/zoom.svg +1 -0
- package/public/icons/files.svg +5 -0
- package/public/icons/pwa/icon-192.png +0 -0
- package/public/icons/pwa/icon-512.png +0 -0
- package/public/icons/settings.svg +14 -0
- package/public/icons/terminal.svg +5 -0
- package/public/icons/text-editor.svg +7 -0
- package/public/manifest.json +38 -0
- package/public/next.svg +1 -0
- package/public/sw.js +41 -0
- package/public/vercel.svg +1 -0
- package/public/wallpapers/default.svg +10 -0
- package/public/window.svg +1 -0
- package/scripts/generate-pwa-icons.mjs +33 -0
- package/scripts/install-nats.sh +37 -0
- package/sentry.client.config.ts +21 -0
- package/sentry.edge.config.ts +12 -0
- package/sentry.server.config.ts +12 -0
- package/src/app/api/files/download/route.ts +81 -0
- package/src/app/api/files/download-zip/route.ts +102 -0
- package/src/app/api/files/upload/route.ts +58 -0
- package/src/app/api/webhooks/workos/route.ts +98 -0
- package/src/app/auth/callback/route.ts +16 -0
- package/src/app/auth/logout/route.ts +15 -0
- package/src/app/desktop/desktop-shell.tsx +110 -0
- package/src/app/desktop/layout.tsx +8 -0
- package/src/app/desktop/page.tsx +24 -0
- package/src/app/favicon.ico +0 -0
- package/src/app/globals.css +7 -0
- package/src/app/layout.tsx +64 -0
- package/src/app/offline/page.tsx +83 -0
- package/src/app/page.tsx +5 -0
- package/src/app/standalone/[appId]/page.tsx +28 -0
- package/src/app/standalone/layout.tsx +10 -0
- package/src/components/app-icon.tsx +55 -0
- package/src/components/apps/_echo/schema.ts +14 -0
- package/src/components/apps/_echo/service/index.ts +42 -0
- package/src/components/apps/app-manifest.ts +97 -0
- package/src/components/apps/app-registry.ts +55 -0
- package/src/components/apps/dev3000/Dev3000App.tsx +224 -0
- package/src/components/apps/dev3000/ErrorsPanel.tsx +160 -0
- package/src/components/apps/dev3000/Sidebar.tsx +41 -0
- package/src/components/apps/dev3000/TimelineLog.tsx +173 -0
- package/src/components/apps/dev3000/dev3000-context.tsx +29 -0
- package/src/components/apps/dev3000/index.ts +4 -0
- package/src/components/apps/dev3000/schema.ts +48 -0
- package/src/components/apps/dev3000/service/index.ts +520 -0
- package/src/components/apps/dev3000/service/runtime +1 -0
- package/src/components/apps/dev3000/types.ts +15 -0
- package/src/components/apps/dev3000/use-message-buffer.ts +46 -0
- package/src/components/apps/files/ContextMenu.tsx +151 -0
- package/src/components/apps/files/DeleteConfirmDialog.tsx +78 -0
- package/src/components/apps/files/FileItem.tsx +128 -0
- package/src/components/apps/files/FilesApp.tsx +509 -0
- package/src/components/apps/files/FilesListView.tsx +201 -0
- package/src/components/apps/files/FilesToolbar.tsx +117 -0
- package/src/components/apps/files/GridView.tsx +90 -0
- package/src/components/apps/files/InlineInput.tsx +131 -0
- package/src/components/apps/files/UploadOverlay.tsx +61 -0
- package/src/components/apps/files/schema.ts +49 -0
- package/src/components/apps/files/service/index.ts +227 -0
- package/src/components/apps/files/service/runtime +1 -0
- package/src/components/apps/files/use-files.ts +201 -0
- package/src/components/apps/files/use-upload.ts +105 -0
- package/src/components/apps/nats-viewer/ActiveSubs.tsx +34 -0
- package/src/components/apps/nats-viewer/MessageLog.tsx +247 -0
- package/src/components/apps/nats-viewer/NatsViewer.tsx +209 -0
- package/src/components/apps/nats-viewer/PublishPanel.tsx +113 -0
- package/src/components/apps/nats-viewer/RequestPanel.tsx +167 -0
- package/src/components/apps/nats-viewer/Sidebar.tsx +62 -0
- package/src/components/apps/nats-viewer/SubjectCatalog.tsx +64 -0
- package/src/components/apps/nats-viewer/SubscribeInput.tsx +59 -0
- package/src/components/apps/nats-viewer/index.ts +5 -0
- package/src/components/apps/nats-viewer/nats-viewer-context.tsx +31 -0
- package/src/components/apps/nats-viewer/types.ts +7 -0
- package/src/components/apps/nats-viewer/use-message-buffer.ts +55 -0
- package/src/components/apps/settings/Settings.tsx +492 -0
- package/src/components/apps/terminal/schema.ts +82 -0
- package/src/components/apps/terminal/service/index.ts +189 -0
- package/src/components/apps/terminal/service/runtime +1 -0
- package/src/components/apps/terminal/service/session.ts +296 -0
- package/src/components/apps/terminal/service/shell-hooks/bashrc-hook.sh +21 -0
- package/src/components/apps/terminal/types.ts +26 -0
- package/src/components/apps/terminal/ui/MultiTerminalApp.tsx +617 -0
- package/src/components/apps/terminal/ui/SplitDragHandle.tsx +91 -0
- package/src/components/apps/terminal/ui/SplitPaneRenderer.tsx +112 -0
- package/src/components/apps/terminal/ui/TerminalPane.tsx +476 -0
- package/src/components/apps/terminal/ui/TerminalTabBar.tsx +131 -0
- package/src/components/desktop/AnimatedBackground.tsx +69 -0
- package/src/components/desktop/Desktop.tsx +79 -0
- package/src/components/desktop/DesktopBackground.tsx +16 -0
- package/src/components/desktop/DesktopIcon.tsx +49 -0
- package/src/components/desktop/ShortcutViewer.tsx +136 -0
- package/src/components/desktop/WindowRenderer.tsx +34 -0
- package/src/components/desktop/WindowSwitcher.tsx +42 -0
- package/src/components/notifications/NotificationCenter.tsx +153 -0
- package/src/components/notifications/NotificationToasts.tsx +66 -0
- package/src/components/notifications/OrphanSessionToast.tsx +293 -0
- package/src/components/os-primitives/collapsible-sidebar.tsx +226 -0
- package/src/components/os-primitives/dialog.tsx +76 -0
- package/src/components/os-primitives/empty-state.tsx +43 -0
- package/src/components/os-primitives/index.ts +21 -0
- package/src/components/os-primitives/list-view.tsx +155 -0
- package/src/components/os-primitives/property-panel.tsx +108 -0
- package/src/components/os-primitives/section-header.tsx +19 -0
- package/src/components/os-primitives/sidebar-nav.tsx +110 -0
- package/src/components/os-primitives/split-pane.tsx +146 -0
- package/src/components/os-primitives/status-badge.tsx +10 -0
- package/src/components/os-primitives/status-bar.tsx +100 -0
- package/src/components/os-primitives/toolbar.tsx +152 -0
- package/src/components/taskbar/AppLauncher.tsx +114 -0
- package/src/components/taskbar/RunningApps.tsx +71 -0
- package/src/components/taskbar/SystemTray.tsx +134 -0
- package/src/components/taskbar/Taskbar.tsx +45 -0
- package/src/components/taskbar/UserMenu.tsx +138 -0
- package/src/components/taskbar/WorkspaceSwitcher.tsx +9 -0
- package/src/components/ui/ContextMenu.tsx +130 -0
- package/src/components/ui/badge.tsx +39 -0
- package/src/components/ui/button.tsx +102 -0
- package/src/components/ui/command.tsx +165 -0
- package/src/components/ui/dropdown-menu.tsx +233 -0
- package/src/components/ui/input.tsx +48 -0
- package/src/components/ui/note.tsx +55 -0
- package/src/components/ui/separator.tsx +25 -0
- package/src/components/ui/spinner.tsx +42 -0
- package/src/components/ui/switch.tsx +36 -0
- package/src/components/ui/theme-provider.tsx +24 -0
- package/src/components/ui/theme-switcher.tsx +51 -0
- package/src/components/ui/tooltip.tsx +62 -0
- package/src/components/window/MobileWindowStack.tsx +218 -0
- package/src/components/window/SnapPreview.tsx +37 -0
- package/src/components/window/StandaloneFrame.tsx +170 -0
- package/src/components/window/Window.tsx +423 -0
- package/src/components/window/WindowContent.tsx +14 -0
- package/src/components/window/WindowControlsOverlay.tsx +89 -0
- package/src/components/window/WindowFrame.tsx +124 -0
- package/src/lib/auth/index.ts +27 -0
- package/src/lib/auth/roles.ts +50 -0
- package/src/lib/auth/types.ts +32 -0
- package/src/lib/auth/use-auth.ts +53 -0
- package/src/lib/auth/webhook-handler.ts +87 -0
- package/src/lib/auth/workos.ts +67 -0
- package/src/lib/constants.ts +1 -0
- package/src/lib/desktop/dedup.ts +57 -0
- package/src/lib/desktop/schema.ts +55 -0
- package/src/lib/files/filename-validation.ts +41 -0
- package/src/lib/files/safe-path.ts +49 -0
- package/src/lib/hooks/use-desktop-nats.ts +438 -0
- package/src/lib/hooks/use-is-mobile.ts +23 -0
- package/src/lib/hooks/use-launch-app.ts +79 -0
- package/src/lib/hooks/use-nats-notifications.ts +84 -0
- package/src/lib/hooks/use-nats.ts +60 -0
- package/src/lib/hooks/use-visual-viewport.ts +72 -0
- package/src/lib/icons/resolve-window-icon.ts +10 -0
- package/src/lib/keyboard/defaults.ts +146 -0
- package/src/lib/keyboard/types.ts +52 -0
- package/src/lib/keyboard/use-global-keybinds.ts +231 -0
- package/src/lib/nats-client.ts +255 -0
- package/src/lib/nats.ts +35 -0
- package/src/lib/notifications/schema.ts +12 -0
- package/src/lib/service-loader.ts +171 -0
- package/src/lib/subjects.ts +64 -0
- package/src/lib/utils.ts +6 -0
- package/src/lib/ws-bridge.ts +288 -0
- package/src/lib/ws-protocol.ts +53 -0
- package/src/lib/ws-server.ts +167 -0
- package/src/middleware.ts +57 -0
- package/src/stores/desktop-store.ts +112 -0
- package/src/stores/keybind-store.ts +66 -0
- package/src/stores/notification-store.ts +271 -0
- package/src/stores/theme-store.ts +25 -0
- package/src/stores/window-store.ts +294 -0
- package/src/theme/animations.css +68 -0
- package/src/theme/base.css +123 -0
- package/src/theme/controls.css +35 -0
- package/src/theme/design-tokens.css +276 -0
- package/src/theme/index.css +23 -0
- package/src/theme/menus.css +45 -0
- package/src/theme/status.css +41 -0
- package/src/theme/surfaces.css +94 -0
- package/src/theme/tailwind-map.css +138 -0
- package/src/theme/taskbar.css +25 -0
- package/src/theme/terminal.css +55 -0
- package/src/theme/typography.css +26 -0
- package/src/theme/utilities.css +156 -0
- package/src/theme/window.css +103 -0
- package/src/types/desktop-entry.ts +12 -0
- package/src/types/use-descendants.d.ts +13 -0
- package/src/types/window.ts +28 -0
- package/src/types.d.ts +9 -0
- package/tauri/Cargo.lock +5464 -0
- package/tauri/Cargo.toml +19 -0
- package/tauri/build.rs +3 -0
- package/tauri/capabilities/default.json +36 -0
- package/tauri/icons/128x128.png +0 -0
- package/tauri/icons/128x128@2x.png +0 -0
- package/tauri/icons/32x32.png +0 -0
- package/tauri/icons/icon.png +0 -0
- package/tauri/src/main.rs +396 -0
- package/tauri/tauri.conf.json +23 -0
- package/tsconfig.json +43 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { useSyncExternalStore } from 'react';
|
|
2
|
+
|
|
3
|
+
interface ViewportSize {
|
|
4
|
+
height: number;
|
|
5
|
+
width: number;
|
|
6
|
+
offsetTop: number;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
let cached: ViewportSize = {
|
|
10
|
+
height: typeof window !== 'undefined' ? window.innerHeight : 800,
|
|
11
|
+
width: typeof window !== 'undefined' ? window.innerWidth : 1280,
|
|
12
|
+
offsetTop: 0,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const listeners = new Set<() => void>();
|
|
16
|
+
|
|
17
|
+
function update() {
|
|
18
|
+
const vv = typeof window !== 'undefined' ? window.visualViewport : null;
|
|
19
|
+
const next: ViewportSize = vv
|
|
20
|
+
? { height: vv.height, width: vv.width, offsetTop: vv.offsetTop }
|
|
21
|
+
: {
|
|
22
|
+
height: typeof window !== 'undefined' ? window.innerHeight : 800,
|
|
23
|
+
width: typeof window !== 'undefined' ? window.innerWidth : 1280,
|
|
24
|
+
offsetTop: 0,
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
if (next.height !== cached.height || next.width !== cached.width || next.offsetTop !== cached.offsetTop) {
|
|
28
|
+
cached = next;
|
|
29
|
+
for (const cb of listeners) cb();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
let listening = false;
|
|
34
|
+
|
|
35
|
+
function subscribe(cb: () => void) {
|
|
36
|
+
listeners.add(cb);
|
|
37
|
+
|
|
38
|
+
if (!listening && typeof window !== 'undefined') {
|
|
39
|
+
listening = true;
|
|
40
|
+
const vv = window.visualViewport;
|
|
41
|
+
if (vv) {
|
|
42
|
+
vv.addEventListener('resize', update);
|
|
43
|
+
vv.addEventListener('scroll', update);
|
|
44
|
+
}
|
|
45
|
+
window.addEventListener('resize', update);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return () => {
|
|
49
|
+
listeners.delete(cb);
|
|
50
|
+
if (listeners.size === 0 && typeof window !== 'undefined') {
|
|
51
|
+
listening = false;
|
|
52
|
+
const vv = window.visualViewport;
|
|
53
|
+
if (vv) {
|
|
54
|
+
vv.removeEventListener('resize', update);
|
|
55
|
+
vv.removeEventListener('scroll', update);
|
|
56
|
+
}
|
|
57
|
+
window.removeEventListener('resize', update);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function getSnapshot() {
|
|
63
|
+
return cached;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function getServerSnapshot(): ViewportSize {
|
|
67
|
+
return { height: 800, width: 1280, offsetTop: 0 };
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function useVisualViewport(): ViewportSize {
|
|
71
|
+
return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
|
|
72
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { useDesktopStore } from '@/stores/desktop-store';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* React hook version — subscribes to the desktop store.
|
|
5
|
+
*/
|
|
6
|
+
export function useResolvedIcon(appId: string): string | null {
|
|
7
|
+
const apps = useDesktopStore((s) => s.apps);
|
|
8
|
+
const entry = apps.find((a) => a.id === appId || a.component === appId);
|
|
9
|
+
return entry?.icon ?? null;
|
|
10
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import type { ShortcutDefinition } from './types';
|
|
2
|
+
|
|
3
|
+
export const DEFAULT_SHORTCUTS: ShortcutDefinition[] = [
|
|
4
|
+
// ── Window Management ──────────────────────────────────────────────
|
|
5
|
+
{
|
|
6
|
+
id: 'window.cycle-next',
|
|
7
|
+
label: 'Switch Window',
|
|
8
|
+
description: 'Cycle to next window (Alt-Tab)',
|
|
9
|
+
category: 'window',
|
|
10
|
+
defaultBinding: { key: 'Tab', modifiers: ['alt'] },
|
|
11
|
+
repeat: true,
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
id: 'window.cycle-prev',
|
|
15
|
+
label: 'Switch Window (Reverse)',
|
|
16
|
+
description: 'Cycle to previous window',
|
|
17
|
+
category: 'window',
|
|
18
|
+
defaultBinding: { key: 'Tab', modifiers: ['alt', 'shift'] },
|
|
19
|
+
repeat: true,
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
id: 'window.close',
|
|
23
|
+
label: 'Close Window',
|
|
24
|
+
description: 'Close the focused window',
|
|
25
|
+
category: 'window',
|
|
26
|
+
defaultBinding: { key: 'w', modifiers: ['alt'] },
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
id: 'window.minimize',
|
|
30
|
+
label: 'Minimize Window',
|
|
31
|
+
description: 'Minimize the focused window',
|
|
32
|
+
category: 'window',
|
|
33
|
+
defaultBinding: { key: 'h', modifiers: ['meta'] },
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
id: 'window.maximize',
|
|
37
|
+
label: 'Maximize / Restore Window',
|
|
38
|
+
description: 'Toggle maximize on the focused window',
|
|
39
|
+
category: 'window',
|
|
40
|
+
defaultBinding: { key: 'ArrowUp', modifiers: ['meta'] },
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
id: 'window.snap-left',
|
|
44
|
+
label: 'Tile Window Left',
|
|
45
|
+
description: 'Snap the focused window to the left half',
|
|
46
|
+
category: 'window',
|
|
47
|
+
defaultBinding: { key: 'ArrowLeft', modifiers: ['meta'] },
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
id: 'window.snap-right',
|
|
51
|
+
label: 'Tile Window Right',
|
|
52
|
+
description: 'Snap the focused window to the right half',
|
|
53
|
+
category: 'window',
|
|
54
|
+
defaultBinding: { key: 'ArrowRight', modifiers: ['meta'] },
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
// ── Launcher ───────────────────────────────────────────────────────
|
|
58
|
+
{
|
|
59
|
+
id: 'launcher.open',
|
|
60
|
+
label: 'App Launcher',
|
|
61
|
+
description: 'Open the application launcher',
|
|
62
|
+
category: 'launcher',
|
|
63
|
+
defaultBinding: { key: 'k', modifiers: ['meta'] },
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
id: 'launcher.terminal',
|
|
67
|
+
label: 'Open Terminal',
|
|
68
|
+
description: 'Open a new terminal window',
|
|
69
|
+
category: 'launcher',
|
|
70
|
+
defaultBinding: { key: 't', modifiers: ['ctrl', 'alt'] },
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
id: 'launcher.settings',
|
|
74
|
+
label: 'Open Settings',
|
|
75
|
+
description: 'Open the settings panel',
|
|
76
|
+
category: 'launcher',
|
|
77
|
+
defaultBinding: { key: ',', modifiers: ['meta'] },
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
// ── System ─────────────────────────────────────────────────────────
|
|
81
|
+
{
|
|
82
|
+
id: 'system.notification-center',
|
|
83
|
+
label: 'Notification Center',
|
|
84
|
+
description: 'Toggle the notification center',
|
|
85
|
+
category: 'system',
|
|
86
|
+
defaultBinding: { key: 'n', modifiers: ['meta'] },
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
id: 'system.shortcut-viewer',
|
|
90
|
+
label: 'Shortcut Viewer',
|
|
91
|
+
description: 'Open the keyboard shortcut reference',
|
|
92
|
+
category: 'system',
|
|
93
|
+
defaultBinding: { key: '/', modifiers: ['meta'] },
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
id: 'window.close-meta',
|
|
97
|
+
label: 'Close Window/Tab',
|
|
98
|
+
description: 'Close window or terminal tab (context-aware)',
|
|
99
|
+
category: 'window',
|
|
100
|
+
defaultBinding: { key: 'w', modifiers: ['meta'] },
|
|
101
|
+
},
|
|
102
|
+
|
|
103
|
+
// ── Terminal ───────────────────────────────────────────────────────
|
|
104
|
+
{
|
|
105
|
+
id: 'terminal.new-tab',
|
|
106
|
+
label: 'New Terminal Tab',
|
|
107
|
+
description: 'Create a new tab in the terminal',
|
|
108
|
+
category: 'terminal',
|
|
109
|
+
defaultBinding: { key: 't', modifiers: ['meta'] },
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
id: 'terminal.close-tab',
|
|
113
|
+
label: 'Close Terminal Tab/Pane',
|
|
114
|
+
description: 'Close the active terminal tab or pane',
|
|
115
|
+
category: 'terminal',
|
|
116
|
+
defaultBinding: { key: 'w', modifiers: ['meta'] },
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
id: 'terminal.next-tab',
|
|
120
|
+
label: 'Next Terminal Tab',
|
|
121
|
+
description: 'Switch to the next terminal tab',
|
|
122
|
+
category: 'terminal',
|
|
123
|
+
defaultBinding: { key: 'Tab', modifiers: ['ctrl'] },
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
id: 'terminal.prev-tab',
|
|
127
|
+
label: 'Previous Terminal Tab',
|
|
128
|
+
description: 'Switch to the previous terminal tab',
|
|
129
|
+
category: 'terminal',
|
|
130
|
+
defaultBinding: { key: 'Tab', modifiers: ['ctrl', 'shift'] },
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
id: 'terminal.split-vertical',
|
|
134
|
+
label: 'Split Terminal Vertically',
|
|
135
|
+
description: 'Split the active pane into two side-by-side panes',
|
|
136
|
+
category: 'terminal',
|
|
137
|
+
defaultBinding: { key: 'd', modifiers: ['meta'] },
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
id: 'terminal.split-horizontal',
|
|
141
|
+
label: 'Split Terminal Horizontally',
|
|
142
|
+
description: 'Split the active pane into two top/bottom panes',
|
|
143
|
+
category: 'terminal',
|
|
144
|
+
defaultBinding: { key: 'd', modifiers: ['meta', 'shift'] },
|
|
145
|
+
},
|
|
146
|
+
];
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export type ModifierKey = 'meta' | 'ctrl' | 'alt' | 'shift';
|
|
2
|
+
|
|
3
|
+
export interface KeyCombo {
|
|
4
|
+
key: string;
|
|
5
|
+
modifiers: ModifierKey[];
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export type ShortcutCategory = 'window' | 'workspace' | 'launcher' | 'terminal' | 'system';
|
|
9
|
+
|
|
10
|
+
export interface ShortcutDefinition {
|
|
11
|
+
id: string;
|
|
12
|
+
label: string;
|
|
13
|
+
description: string;
|
|
14
|
+
category: ShortcutCategory;
|
|
15
|
+
defaultBinding: KeyCombo;
|
|
16
|
+
/** Whether the shortcut fires on keyup instead of keydown */
|
|
17
|
+
onKeyUp?: boolean;
|
|
18
|
+
/** Whether the shortcut repeats when held */
|
|
19
|
+
repeat?: boolean;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function comboToSymbols(combo: KeyCombo): string {
|
|
23
|
+
const isMac = typeof navigator !== 'undefined' && /Mac|iPhone|iPad/.test(navigator.userAgent);
|
|
24
|
+
const parts: string[] = [];
|
|
25
|
+
if (combo.modifiers.includes('ctrl')) parts.push(isMac ? '\u2303' : 'Ctrl');
|
|
26
|
+
if (combo.modifiers.includes('alt')) parts.push(isMac ? '\u2325' : 'Alt');
|
|
27
|
+
if (combo.modifiers.includes('shift')) parts.push(isMac ? '\u21E7' : 'Shift');
|
|
28
|
+
if (combo.modifiers.includes('meta')) parts.push(isMac ? '\u2318' : 'Super');
|
|
29
|
+
parts.push(formatKeyName(combo.key));
|
|
30
|
+
return parts.join(isMac ? '' : ' + ');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function formatKeyName(key: string): string {
|
|
34
|
+
if (key === 'Tab') return 'Tab';
|
|
35
|
+
if (key === 'Escape') return 'Esc';
|
|
36
|
+
if (key === 'ArrowLeft') return '\u2190';
|
|
37
|
+
if (key === 'ArrowRight') return '\u2192';
|
|
38
|
+
if (key === 'ArrowUp') return '\u2191';
|
|
39
|
+
if (key === 'ArrowDown') return '\u2193';
|
|
40
|
+
if (key === ' ') return 'Space';
|
|
41
|
+
if (key.length === 1) return key.toUpperCase();
|
|
42
|
+
return key;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function matchesCombo(e: KeyboardEvent, combo: KeyCombo): boolean {
|
|
46
|
+
if (e.key.toLowerCase() !== combo.key.toLowerCase() && e.key !== combo.key) return false;
|
|
47
|
+
const wantMeta = combo.modifiers.includes('meta');
|
|
48
|
+
const wantCtrl = combo.modifiers.includes('ctrl');
|
|
49
|
+
const wantAlt = combo.modifiers.includes('alt');
|
|
50
|
+
const wantShift = combo.modifiers.includes('shift');
|
|
51
|
+
return e.metaKey === wantMeta && e.ctrlKey === wantCtrl && e.altKey === wantAlt && e.shiftKey === wantShift;
|
|
52
|
+
}
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
4
|
+
import { useKhalAuth } from '@/lib/auth/use-auth';
|
|
5
|
+
import { hasAppPermission } from '@/lib/hooks/use-launch-app';
|
|
6
|
+
import { useKeybindStore } from '@/stores/keybind-store';
|
|
7
|
+
import { useNotificationStore } from '@/stores/notification-store';
|
|
8
|
+
import { useWindowStore } from '@/stores/window-store';
|
|
9
|
+
import type { WindowState } from '@/types/window';
|
|
10
|
+
import { matchesCombo } from './types';
|
|
11
|
+
|
|
12
|
+
interface WindowSwitcherState {
|
|
13
|
+
visible: boolean;
|
|
14
|
+
windows: WindowState[];
|
|
15
|
+
selectedIndex: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function useGlobalKeybinds() {
|
|
19
|
+
const [switcher, setSwitcher] = useState<WindowSwitcherState>({
|
|
20
|
+
visible: false,
|
|
21
|
+
windows: [],
|
|
22
|
+
selectedIndex: 0,
|
|
23
|
+
});
|
|
24
|
+
const switcherRef = useRef(switcher);
|
|
25
|
+
switcherRef.current = switcher;
|
|
26
|
+
|
|
27
|
+
const [launcherToggle, setLauncherToggle] = useState(0);
|
|
28
|
+
const [shortcutViewerVisible, setShortcutViewerVisible] = useState(false);
|
|
29
|
+
|
|
30
|
+
// Track permissions via ref so handleAction stays stable (no dep change)
|
|
31
|
+
const auth = useKhalAuth();
|
|
32
|
+
const permissionsRef = useRef<string[]>(auth?.permissions ?? []);
|
|
33
|
+
permissionsRef.current = auth?.permissions ?? [];
|
|
34
|
+
|
|
35
|
+
const handleAction = useCallback((id: string) => {
|
|
36
|
+
const windowStore = useWindowStore.getState();
|
|
37
|
+
|
|
38
|
+
switch (id) {
|
|
39
|
+
case 'window.cycle-next':
|
|
40
|
+
case 'window.cycle-prev': {
|
|
41
|
+
const windows = windowStore.getWindows();
|
|
42
|
+
if (windows.length === 0) return;
|
|
43
|
+
const sorted = [...windows].sort((a, b) => b.zIndex - a.zIndex);
|
|
44
|
+
const current = switcherRef.current;
|
|
45
|
+
|
|
46
|
+
if (!current.visible) {
|
|
47
|
+
const startIndex = id === 'window.cycle-next' ? 1 : sorted.length - 1;
|
|
48
|
+
setSwitcher({
|
|
49
|
+
visible: true,
|
|
50
|
+
windows: sorted,
|
|
51
|
+
selectedIndex: Math.min(startIndex, sorted.length - 1),
|
|
52
|
+
});
|
|
53
|
+
} else {
|
|
54
|
+
const dir = id === 'window.cycle-next' ? 1 : -1;
|
|
55
|
+
const next = (current.selectedIndex + dir + current.windows.length) % current.windows.length;
|
|
56
|
+
setSwitcher((prev) => ({ ...prev, selectedIndex: next }));
|
|
57
|
+
}
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
case 'window.close': {
|
|
62
|
+
const top = windowStore.getTopmostWindow();
|
|
63
|
+
if (top) windowStore.closeWindow(top.id);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
case 'window.close-meta': {
|
|
67
|
+
const top = windowStore.getTopmostWindow();
|
|
68
|
+
// If focused window is terminal, skip (let terminal handle Cmd+W internally as close-tab)
|
|
69
|
+
if (top && top.appId !== 'terminal') {
|
|
70
|
+
windowStore.closeWindow(top.id);
|
|
71
|
+
}
|
|
72
|
+
// If it is terminal, do nothing - terminal's internal handler will take over
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
case 'window.minimize': {
|
|
76
|
+
const top = windowStore.getTopmostWindow();
|
|
77
|
+
if (top) windowStore.minimizeWindow(top.id);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
case 'window.maximize': {
|
|
81
|
+
const top = windowStore.getTopmostWindow();
|
|
82
|
+
if (top) {
|
|
83
|
+
if (top.maximized) windowStore.restoreWindow(top.id);
|
|
84
|
+
else windowStore.maximizeWindow(top.id);
|
|
85
|
+
}
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
case 'window.snap-left': {
|
|
89
|
+
const top = windowStore.getTopmostWindow();
|
|
90
|
+
if (top) {
|
|
91
|
+
if (top.snapped === 'left') windowStore.unsnapWindow(top.id);
|
|
92
|
+
else windowStore.snapWindow(top.id, 'left');
|
|
93
|
+
}
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
case 'window.snap-right': {
|
|
97
|
+
const top = windowStore.getTopmostWindow();
|
|
98
|
+
if (top) {
|
|
99
|
+
if (top.snapped === 'right') windowStore.unsnapWindow(top.id);
|
|
100
|
+
else windowStore.snapWindow(top.id, 'right');
|
|
101
|
+
}
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
default: {
|
|
106
|
+
if (id === 'launcher.open') {
|
|
107
|
+
setLauncherToggle((n) => n + 1);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
if (id === 'launcher.terminal') {
|
|
111
|
+
if (!hasAppPermission('terminal', permissionsRef.current)) {
|
|
112
|
+
useNotificationStore.getState().addNotification({
|
|
113
|
+
id: Date.now(),
|
|
114
|
+
replacesId: 0,
|
|
115
|
+
summary: 'Permission Denied',
|
|
116
|
+
body: 'You do not have permission to open Terminal.',
|
|
117
|
+
icon: null,
|
|
118
|
+
actions: [],
|
|
119
|
+
expires: 4000,
|
|
120
|
+
urgency: 'normal',
|
|
121
|
+
});
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
windowStore.openWindow({ title: 'Terminal', appId: 'terminal', width: 720, height: 480 });
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
if (id === 'launcher.settings') {
|
|
128
|
+
if (!hasAppPermission('settings', permissionsRef.current)) {
|
|
129
|
+
useNotificationStore.getState().addNotification({
|
|
130
|
+
id: Date.now(),
|
|
131
|
+
replacesId: 0,
|
|
132
|
+
summary: 'Permission Denied',
|
|
133
|
+
body: 'You do not have permission to open Settings.',
|
|
134
|
+
icon: null,
|
|
135
|
+
actions: [],
|
|
136
|
+
expires: 4000,
|
|
137
|
+
urgency: 'normal',
|
|
138
|
+
});
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
windowStore.openWindow({ title: 'Settings', appId: 'settings', width: 700, height: 500 });
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
if (id === 'system.notification-center') {
|
|
145
|
+
useNotificationStore.getState().toggleCenter();
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
if (id === 'system.shortcut-viewer') {
|
|
149
|
+
setShortcutViewerVisible((v) => !v);
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}, []);
|
|
155
|
+
|
|
156
|
+
const commitSwitcher = useCallback(() => {
|
|
157
|
+
const current = switcherRef.current;
|
|
158
|
+
if (!current.visible) return;
|
|
159
|
+
const selected = current.windows[current.selectedIndex];
|
|
160
|
+
if (selected) {
|
|
161
|
+
useWindowStore.getState().focusWindow(selected.id);
|
|
162
|
+
}
|
|
163
|
+
setSwitcher({ visible: false, windows: [], selectedIndex: 0 });
|
|
164
|
+
}, []);
|
|
165
|
+
|
|
166
|
+
useEffect(() => {
|
|
167
|
+
const store = useKeybindStore.getState();
|
|
168
|
+
const { definitions } = store;
|
|
169
|
+
|
|
170
|
+
const handleKeyDown = (e: KeyboardEvent) => {
|
|
171
|
+
if (
|
|
172
|
+
e.target instanceof HTMLInputElement ||
|
|
173
|
+
e.target instanceof HTMLTextAreaElement ||
|
|
174
|
+
(e.target instanceof HTMLElement && e.target.isContentEditable)
|
|
175
|
+
) {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const state = useKeybindStore.getState();
|
|
180
|
+
if (state.suspended) return;
|
|
181
|
+
const { getBinding } = state;
|
|
182
|
+
for (const def of definitions) {
|
|
183
|
+
if (def.onKeyUp) continue;
|
|
184
|
+
const binding = getBinding(def.id);
|
|
185
|
+
if (!binding) continue;
|
|
186
|
+
if (!def.repeat && e.repeat) continue;
|
|
187
|
+
if (matchesCombo(e, binding)) {
|
|
188
|
+
e.preventDefault();
|
|
189
|
+
e.stopPropagation();
|
|
190
|
+
handleAction(def.id);
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
const handleKeyUp = (e: KeyboardEvent) => {
|
|
197
|
+
if (e.key === 'Alt' && switcherRef.current.visible) {
|
|
198
|
+
commitSwitcher();
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
const upState = useKeybindStore.getState();
|
|
203
|
+
if (upState.suspended) return;
|
|
204
|
+
const { getBinding } = upState;
|
|
205
|
+
for (const def of definitions) {
|
|
206
|
+
if (!def.onKeyUp) continue;
|
|
207
|
+
const binding = getBinding(def.id);
|
|
208
|
+
if (!binding) continue;
|
|
209
|
+
if (matchesCombo(e, binding)) {
|
|
210
|
+
e.preventDefault();
|
|
211
|
+
handleAction(def.id);
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
window.addEventListener('keydown', handleKeyDown, { capture: true });
|
|
218
|
+
window.addEventListener('keyup', handleKeyUp, { capture: true });
|
|
219
|
+
return () => {
|
|
220
|
+
window.removeEventListener('keydown', handleKeyDown, { capture: true });
|
|
221
|
+
window.removeEventListener('keyup', handleKeyUp, { capture: true });
|
|
222
|
+
};
|
|
223
|
+
}, [handleAction, commitSwitcher]);
|
|
224
|
+
|
|
225
|
+
return {
|
|
226
|
+
switcher,
|
|
227
|
+
launcherToggle,
|
|
228
|
+
shortcutViewerVisible,
|
|
229
|
+
setShortcutViewerVisible,
|
|
230
|
+
};
|
|
231
|
+
}
|