@nocturnium/svelte-ide 1.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +251 -0
- package/dist/components/agents/AgentActivityPanel.svelte +565 -0
- package/dist/components/agents/AgentActivityPanel.svelte.d.ts +24 -0
- package/dist/components/agents/AgentAvatar.svelte +417 -0
- package/dist/components/agents/AgentAvatar.svelte.d.ts +23 -0
- package/dist/components/agents/AgentCursor.svelte +224 -0
- package/dist/components/agents/AgentCursor.svelte.d.ts +35 -0
- package/dist/components/agents/AgentPresenceBar.svelte +261 -0
- package/dist/components/agents/AgentPresenceBar.svelte.d.ts +20 -0
- package/dist/components/agents/index.d.ts +4 -0
- package/dist/components/agents/index.js +5 -0
- package/dist/components/ai/AIConversationList.svelte +524 -0
- package/dist/components/ai/AIConversationList.svelte.d.ts +17 -0
- package/dist/components/ai/AIEditPreview.svelte +132 -0
- package/dist/components/ai/AIEditPreview.svelte.d.ts +8 -0
- package/dist/components/ai/AIInlineEdit.svelte +155 -0
- package/dist/components/ai/AIInlineEdit.svelte.d.ts +10 -0
- package/dist/components/ai/AIMessage.svelte +239 -0
- package/dist/components/ai/AIMessage.svelte.d.ts +13 -0
- package/dist/components/ai/AIMessageActions.svelte +176 -0
- package/dist/components/ai/AIMessageActions.svelte.d.ts +12 -0
- package/dist/components/ai/AIMessageContent.svelte +355 -0
- package/dist/components/ai/AIMessageContent.svelte.d.ts +7 -0
- package/dist/components/ai/AIPanel.svelte +561 -0
- package/dist/components/ai/AIPanel.svelte.d.ts +7 -0
- package/dist/components/ai/AISuggestionWidget.svelte +132 -0
- package/dist/components/ai/AISuggestionWidget.svelte.d.ts +10 -0
- package/dist/components/ai/AIToolCallDisplay.svelte +317 -0
- package/dist/components/ai/AIToolCallDisplay.svelte.d.ts +12 -0
- package/dist/components/ai/index.d.ts +9 -0
- package/dist/components/ai/index.js +10 -0
- package/dist/components/core/Avatar.svelte +110 -0
- package/dist/components/core/Avatar.svelte.d.ts +12 -0
- package/dist/components/core/Badge.svelte +98 -0
- package/dist/components/core/Badge.svelte.d.ts +11 -0
- package/dist/components/core/Button.svelte +175 -0
- package/dist/components/core/Button.svelte.d.ts +18 -0
- package/dist/components/core/ConnectionStatus.svelte +294 -0
- package/dist/components/core/ConnectionStatus.svelte.d.ts +20 -0
- package/dist/components/core/ContextMenu.svelte +176 -0
- package/dist/components/core/ContextMenu.svelte.d.ts +19 -0
- package/dist/components/core/ErrorBoundary.svelte +277 -0
- package/dist/components/core/ErrorBoundary.svelte.d.ts +23 -0
- package/dist/components/core/Icon.svelte +107 -0
- package/dist/components/core/Icon.svelte.d.ts +8 -0
- package/dist/components/core/Input.svelte +138 -0
- package/dist/components/core/Input.svelte.d.ts +20 -0
- package/dist/components/core/Kbd.svelte +34 -0
- package/dist/components/core/Kbd.svelte.d.ts +7 -0
- package/dist/components/core/ResizeHandle.svelte +200 -0
- package/dist/components/core/ResizeHandle.svelte.d.ts +23 -0
- package/dist/components/core/Spinner.svelte +35 -0
- package/dist/components/core/Spinner.svelte.d.ts +7 -0
- package/dist/components/core/Textarea.svelte +112 -0
- package/dist/components/core/Textarea.svelte.d.ts +18 -0
- package/dist/components/core/Tooltip.svelte +103 -0
- package/dist/components/core/Tooltip.svelte.d.ts +11 -0
- package/dist/components/core/index.d.ts +13 -0
- package/dist/components/core/index.js +14 -0
- package/dist/components/editor/AIFocusLayer.svelte +430 -0
- package/dist/components/editor/AIFocusLayer.svelte.d.ts +32 -0
- package/dist/components/editor/Breadcrumbs.svelte +435 -0
- package/dist/components/editor/Breadcrumbs.svelte.d.ts +33 -0
- package/dist/components/editor/BreakpointLayer.svelte +642 -0
- package/dist/components/editor/BreakpointLayer.svelte.d.ts +20 -0
- package/dist/components/editor/CognitiveLoadMeter.svelte +324 -0
- package/dist/components/editor/CognitiveLoadMeter.svelte.d.ts +18 -0
- package/dist/components/editor/CollaborativeEditor.svelte +218 -0
- package/dist/components/editor/CollaborativeEditor.svelte.d.ts +32 -0
- package/dist/components/editor/CommandPalette.svelte +434 -0
- package/dist/components/editor/CommandPalette.svelte.d.ts +11 -0
- package/dist/components/editor/ComplexityLayer.svelte +293 -0
- package/dist/components/editor/ComplexityLayer.svelte.d.ts +23 -0
- package/dist/components/editor/ConflictZoneLayer.svelte +441 -0
- package/dist/components/editor/ConflictZoneLayer.svelte.d.ts +25 -0
- package/dist/components/editor/ContextLens.svelte +262 -0
- package/dist/components/editor/ContextLens.svelte.d.ts +27 -0
- package/dist/components/editor/CustomEditor.svelte +1242 -0
- package/dist/components/editor/CustomEditor.svelte.d.ts +37 -0
- package/dist/components/editor/DebugConsole.svelte +646 -0
- package/dist/components/editor/DebugConsole.svelte.d.ts +41 -0
- package/dist/components/editor/EchoCursorLayer.svelte +363 -0
- package/dist/components/editor/EchoCursorLayer.svelte.d.ts +24 -0
- package/dist/components/editor/Editor.svelte +61 -0
- package/dist/components/editor/Editor.svelte.d.ts +22 -0
- package/dist/components/editor/EditorGutter.svelte +119 -0
- package/dist/components/editor/EditorGutter.svelte.d.ts +19 -0
- package/dist/components/editor/EditorLines.svelte +182 -0
- package/dist/components/editor/EditorLines.svelte.d.ts +43 -0
- package/dist/components/editor/EditorPane.svelte +134 -0
- package/dist/components/editor/EditorPane.svelte.d.ts +9 -0
- package/dist/components/editor/EditorSelections.svelte +186 -0
- package/dist/components/editor/EditorSelections.svelte.d.ts +25 -0
- package/dist/components/editor/EditorTabs.svelte +170 -0
- package/dist/components/editor/EditorTabs.svelte.d.ts +12 -0
- package/dist/components/editor/FileExplorer.svelte +811 -0
- package/dist/components/editor/FileExplorer.svelte.d.ts +67 -0
- package/dist/components/editor/FileIcon.svelte +110 -0
- package/dist/components/editor/FileIcon.svelte.d.ts +10 -0
- package/dist/components/editor/FindReplace.svelte +448 -0
- package/dist/components/editor/FindReplace.svelte.d.ts +40 -0
- package/dist/components/editor/GhostBracketLayer.svelte +391 -0
- package/dist/components/editor/GhostBracketLayer.svelte.d.ts +24 -0
- package/dist/components/editor/GitBlameLayer.svelte +436 -0
- package/dist/components/editor/GitBlameLayer.svelte.d.ts +18 -0
- package/dist/components/editor/InlineDiagnosticsLayer.svelte +540 -0
- package/dist/components/editor/InlineDiagnosticsLayer.svelte.d.ts +35 -0
- package/dist/components/editor/InlineDiffLayer.svelte +337 -0
- package/dist/components/editor/InlineDiffLayer.svelte.d.ts +31 -0
- package/dist/components/editor/MinimalEditor.svelte +75 -0
- package/dist/components/editor/MinimalEditor.svelte.d.ts +6 -0
- package/dist/components/editor/MinimalEditor2.svelte +84 -0
- package/dist/components/editor/MinimalEditor2.svelte.d.ts +6 -0
- package/dist/components/editor/Minimap.svelte +327 -0
- package/dist/components/editor/Minimap.svelte.d.ts +34 -0
- package/dist/components/editor/PluginPreviewSandbox.svelte +793 -0
- package/dist/components/editor/PluginPreviewSandbox.svelte.d.ts +49 -0
- package/dist/components/editor/ProblemsPanel.svelte +628 -0
- package/dist/components/editor/ProblemsPanel.svelte.d.ts +25 -0
- package/dist/components/editor/QuickActionsMenu.svelte +403 -0
- package/dist/components/editor/QuickActionsMenu.svelte.d.ts +18 -0
- package/dist/components/editor/SnippetPalette.svelte +530 -0
- package/dist/components/editor/SnippetPalette.svelte.d.ts +16 -0
- package/dist/components/editor/StructureMap.svelte +431 -0
- package/dist/components/editor/StructureMap.svelte.d.ts +37 -0
- package/dist/components/editor/SymbolOutline.svelte +722 -0
- package/dist/components/editor/SymbolOutline.svelte.d.ts +44 -0
- package/dist/components/editor/TimelineScrubber.svelte +470 -0
- package/dist/components/editor/TimelineScrubber.svelte.d.ts +40 -0
- package/dist/components/editor/TokenRenderer.svelte +69 -0
- package/dist/components/editor/TokenRenderer.svelte.d.ts +15 -0
- package/dist/components/editor/constants.d.ts +32 -0
- package/dist/components/editor/constants.js +36 -0
- package/dist/components/editor/core/ai-awareness.d.ts +176 -0
- package/dist/components/editor/core/ai-awareness.js +210 -0
- package/dist/components/editor/core/bracket-healer.d.ts +189 -0
- package/dist/components/editor/core/bracket-healer.js +406 -0
- package/dist/components/editor/core/breakpoints.d.ts +203 -0
- package/dist/components/editor/core/breakpoints.js +414 -0
- package/dist/components/editor/core/commands.d.ts +108 -0
- package/dist/components/editor/core/commands.js +246 -0
- package/dist/components/editor/core/complexity-analyzer.d.ts +123 -0
- package/dist/components/editor/core/complexity-analyzer.js +376 -0
- package/dist/components/editor/core/conflict-predictor.d.ts +135 -0
- package/dist/components/editor/core/conflict-predictor.js +316 -0
- package/dist/components/editor/core/crdt-binding.d.ts +118 -0
- package/dist/components/editor/core/crdt-binding.js +286 -0
- package/dist/components/editor/core/diagnostics.d.ts +210 -0
- package/dist/components/editor/core/diagnostics.js +335 -0
- package/dist/components/editor/core/echo-cursor.d.ts +201 -0
- package/dist/components/editor/core/echo-cursor.js +267 -0
- package/dist/components/editor/core/folding.d.ts +124 -0
- package/dist/components/editor/core/folding.js +672 -0
- package/dist/components/editor/core/ghost-pair.d.ts +122 -0
- package/dist/components/editor/core/ghost-pair.js +221 -0
- package/dist/components/editor/core/git-blame.d.ts +170 -0
- package/dist/components/editor/core/git-blame.js +324 -0
- package/dist/components/editor/core/index.d.ts +26 -0
- package/dist/components/editor/core/index.js +24 -0
- package/dist/components/editor/core/keybindings.d.ts +79 -0
- package/dist/components/editor/core/keybindings.js +357 -0
- package/dist/components/editor/core/multi-cursor.d.ts +196 -0
- package/dist/components/editor/core/multi-cursor.js +521 -0
- package/dist/components/editor/core/navigation.d.ts +107 -0
- package/dist/components/editor/core/navigation.js +408 -0
- package/dist/components/editor/core/quick-actions.d.ts +189 -0
- package/dist/components/editor/core/quick-actions.js +427 -0
- package/dist/components/editor/core/search.d.ts +88 -0
- package/dist/components/editor/core/search.js +192 -0
- package/dist/components/editor/core/semantic-analyzer.d.ts +77 -0
- package/dist/components/editor/core/semantic-analyzer.js +424 -0
- package/dist/components/editor/core/snippet-manager.d.ts +202 -0
- package/dist/components/editor/core/snippet-manager.js +565 -0
- package/dist/components/editor/core/state.d.ts +367 -0
- package/dist/components/editor/core/state.js +900 -0
- package/dist/components/editor/core/timeline.d.ts +204 -0
- package/dist/components/editor/core/timeline.js +349 -0
- package/dist/components/editor/editor-find.d.ts +56 -0
- package/dist/components/editor/editor-find.js +148 -0
- package/dist/components/editor/editor-input.d.ts +77 -0
- package/dist/components/editor/editor-input.js +445 -0
- package/dist/components/editor/editor-multicursor.d.ts +21 -0
- package/dist/components/editor/editor-multicursor.js +196 -0
- package/dist/components/editor/editor-scroll.d.ts +14 -0
- package/dist/components/editor/editor-scroll.js +34 -0
- package/dist/components/editor/index.d.ts +15 -0
- package/dist/components/editor/index.js +21 -0
- package/dist/components/editor/languages.d.ts +62 -0
- package/dist/components/editor/languages.js +285 -0
- package/dist/components/editor/theme.d.ts +88 -0
- package/dist/components/editor/theme.js +139 -0
- package/dist/components/editor/tokenizer/base.d.ts +40 -0
- package/dist/components/editor/tokenizer/base.js +203 -0
- package/dist/components/editor/tokenizer/index.d.ts +56 -0
- package/dist/components/editor/tokenizer/index.js +215 -0
- package/dist/components/editor/tokenizer/languages/css.d.ts +17 -0
- package/dist/components/editor/tokenizer/languages/css.js +194 -0
- package/dist/components/editor/tokenizer/languages/go.d.ts +17 -0
- package/dist/components/editor/tokenizer/languages/go.js +220 -0
- package/dist/components/editor/tokenizer/languages/html.d.ts +24 -0
- package/dist/components/editor/tokenizer/languages/html.js +145 -0
- package/dist/components/editor/tokenizer/languages/javascript.d.ts +56 -0
- package/dist/components/editor/tokenizer/languages/javascript.js +452 -0
- package/dist/components/editor/tokenizer/languages/json.d.ts +12 -0
- package/dist/components/editor/tokenizer/languages/json.js +91 -0
- package/dist/components/editor/tokenizer/languages/markdown.d.ts +16 -0
- package/dist/components/editor/tokenizer/languages/markdown.js +156 -0
- package/dist/components/editor/tokenizer/languages/python.d.ts +20 -0
- package/dist/components/editor/tokenizer/languages/python.js +227 -0
- package/dist/components/editor/tokenizer/languages/svelte.d.ts +40 -0
- package/dist/components/editor/tokenizer/languages/svelte.js +326 -0
- package/dist/components/editor/tokenizer/types.d.ts +86 -0
- package/dist/components/editor/tokenizer/types.js +4 -0
- package/dist/components/layout/IDELayout.svelte +274 -0
- package/dist/components/layout/IDELayout.svelte.d.ts +29 -0
- package/dist/components/layout/StatusBar.svelte +511 -0
- package/dist/components/layout/StatusBar.svelte.d.ts +47 -0
- package/dist/components/layout/index.d.ts +2 -0
- package/dist/components/layout/index.js +3 -0
- package/dist/components/lsp/AutocompleteWidget.svelte +364 -0
- package/dist/components/lsp/AutocompleteWidget.svelte.d.ts +33 -0
- package/dist/components/lsp/DiagnosticMarker.svelte +166 -0
- package/dist/components/lsp/DiagnosticMarker.svelte.d.ts +19 -0
- package/dist/components/lsp/DiagnosticsPanel.svelte +388 -0
- package/dist/components/lsp/DiagnosticsPanel.svelte.d.ts +21 -0
- package/dist/components/lsp/HoverTooltip.svelte +274 -0
- package/dist/components/lsp/HoverTooltip.svelte.d.ts +24 -0
- package/dist/components/lsp/LSPEditor.svelte +486 -0
- package/dist/components/lsp/LSPEditor.svelte.d.ts +39 -0
- package/dist/components/lsp/SignatureHelpWidget.svelte +216 -0
- package/dist/components/lsp/SignatureHelpWidget.svelte.d.ts +22 -0
- package/dist/components/lsp/index.d.ts +6 -0
- package/dist/components/lsp/index.js +7 -0
- package/dist/components/plugins/PluginCard.svelte +153 -0
- package/dist/components/plugins/PluginCard.svelte.d.ts +19 -0
- package/dist/components/plugins/PluginPanel.svelte +280 -0
- package/dist/components/plugins/PluginPanel.svelte.d.ts +8 -0
- package/dist/components/plugins/PluginProposalForm.svelte +250 -0
- package/dist/components/plugins/PluginProposalForm.svelte.d.ts +6 -0
- package/dist/components/plugins/PluginStatusBadge.svelte +14 -0
- package/dist/components/plugins/PluginStatusBadge.svelte.d.ts +8 -0
- package/dist/components/plugins/index.d.ts +4 -0
- package/dist/components/plugins/index.js +5 -0
- package/dist/components/vfs/LockConflictDialog.svelte +705 -0
- package/dist/components/vfs/LockConflictDialog.svelte.d.ts +21 -0
- package/dist/components/vfs/LockIndicator.svelte +194 -0
- package/dist/components/vfs/LockIndicator.svelte.d.ts +29 -0
- package/dist/components/vfs/LockOverlay.svelte +344 -0
- package/dist/components/vfs/LockOverlay.svelte.d.ts +17 -0
- package/dist/components/vfs/VersionConflictDialog.svelte +549 -0
- package/dist/components/vfs/VersionConflictDialog.svelte.d.ts +24 -0
- package/dist/components/vfs/index.d.ts +4 -0
- package/dist/components/vfs/index.js +5 -0
- package/dist/crdt/awareness.d.ts +42 -0
- package/dist/crdt/awareness.js +109 -0
- package/dist/crdt/document.d.ts +101 -0
- package/dist/crdt/document.js +187 -0
- package/dist/crdt/index.d.ts +9 -0
- package/dist/crdt/index.js +8 -0
- package/dist/crdt/provider.d.ts +85 -0
- package/dist/crdt/provider.js +150 -0
- package/dist/crdt/types.d.ts +61 -0
- package/dist/crdt/types.js +4 -0
- package/dist/crdt/undo.d.ts +34 -0
- package/dist/crdt/undo.js +70 -0
- package/dist/index.d.ts +277 -0
- package/dist/index.js +280 -0
- package/dist/plugins/index.d.ts +103 -0
- package/dist/plugins/index.js +153 -0
- package/dist/services/error-handling.d.ts +95 -0
- package/dist/services/error-handling.js +413 -0
- package/dist/services/ide-integration.d.ts +83 -0
- package/dist/services/ide-integration.js +367 -0
- package/dist/services/lsp-client.d.ts +69 -0
- package/dist/services/lsp-client.js +667 -0
- package/dist/services/mock-ai.d.ts +37 -0
- package/dist/services/mock-ai.js +318 -0
- package/dist/services/optimistic.d.ts +141 -0
- package/dist/services/optimistic.js +367 -0
- package/dist/services/vfs-client.d.ts +81 -0
- package/dist/services/vfs-client.js +348 -0
- package/dist/stores/agents.svelte.d.ts +85 -0
- package/dist/stores/agents.svelte.js +459 -0
- package/dist/stores/ai-persistence.svelte.d.ts +76 -0
- package/dist/stores/ai-persistence.svelte.js +334 -0
- package/dist/stores/ai.svelte.d.ts +140 -0
- package/dist/stores/ai.svelte.js +383 -0
- package/dist/stores/collaboration.svelte.d.ts +164 -0
- package/dist/stores/collaboration.svelte.js +334 -0
- package/dist/stores/editor.svelte.d.ts +131 -0
- package/dist/stores/editor.svelte.js +250 -0
- package/dist/stores/index.d.ts +10 -0
- package/dist/stores/index.js +29 -0
- package/dist/stores/layout.svelte.d.ts +171 -0
- package/dist/stores/layout.svelte.js +351 -0
- package/dist/stores/plugin.svelte.d.ts +121 -0
- package/dist/stores/plugin.svelte.js +410 -0
- package/dist/stores/vfs.svelte.d.ts +123 -0
- package/dist/stores/vfs.svelte.js +680 -0
- package/dist/styles/theme.css +623 -0
- package/dist/types/agents.d.ts +127 -0
- package/dist/types/agents.js +5 -0
- package/dist/types/ai.d.ts +137 -0
- package/dist/types/ai.js +4 -0
- package/dist/types/crdt.d.ts +222 -0
- package/dist/types/crdt.js +5 -0
- package/dist/types/editor.d.ts +52 -0
- package/dist/types/editor.js +18 -0
- package/dist/types/events.d.ts +133 -0
- package/dist/types/events.js +4 -0
- package/dist/types/filesystem.d.ts +77 -0
- package/dist/types/filesystem.js +4 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/index.js +12 -0
- package/dist/types/lsp.d.ts +691 -0
- package/dist/types/lsp.js +108 -0
- package/dist/types/plugin.d.ts +239 -0
- package/dist/types/plugin.js +5 -0
- package/dist/types/vfs.d.ts +191 -0
- package/dist/types/vfs.js +18 -0
- package/dist/utils/format.d.ts +55 -0
- package/dist/utils/format.js +152 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.js +4 -0
- package/dist/utils/keybindings.d.ts +33 -0
- package/dist/utils/keybindings.js +171 -0
- package/dist/utils/language.d.ts +27 -0
- package/dist/utils/language.js +222 -0
- package/package.json +178 -0
|
@@ -0,0 +1,434 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* Command Palette
|
|
4
|
+
*
|
|
5
|
+
* A searchable command palette (Ctrl+Shift+P) for quick access to editor commands.
|
|
6
|
+
* Inspired by VS Code's command palette.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { getCommandRegistry, type Command } from './core/commands';
|
|
10
|
+
import { onMount } from 'svelte';
|
|
11
|
+
|
|
12
|
+
interface Props {
|
|
13
|
+
/** Whether the palette is open */
|
|
14
|
+
open?: boolean;
|
|
15
|
+
/** Callback when palette closes */
|
|
16
|
+
onClose?: () => void;
|
|
17
|
+
/** Placeholder text */
|
|
18
|
+
placeholder?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
let { open = $bindable(false), onClose, placeholder = 'Type a command...' }: Props = $props();
|
|
22
|
+
|
|
23
|
+
const registry = getCommandRegistry();
|
|
24
|
+
|
|
25
|
+
let query = $state('');
|
|
26
|
+
let selectedIndex = $state(0);
|
|
27
|
+
let inputElement: HTMLInputElement | null = $state(null);
|
|
28
|
+
|
|
29
|
+
// Get filtered commands
|
|
30
|
+
let commands = $derived.by(() => {
|
|
31
|
+
const all = registry.getAll();
|
|
32
|
+
if (!query.trim()) {
|
|
33
|
+
// Group by category when no search
|
|
34
|
+
return all.sort((a, b) => {
|
|
35
|
+
if (a.category !== b.category) {
|
|
36
|
+
return a.category.localeCompare(b.category);
|
|
37
|
+
}
|
|
38
|
+
return a.label.localeCompare(b.label);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return registry.search(query);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// Group commands by category
|
|
45
|
+
let groupedCommands = $derived.by(() => {
|
|
46
|
+
const groups = new Map<string, Command[]>();
|
|
47
|
+
for (const cmd of commands) {
|
|
48
|
+
const existing = groups.get(cmd.category) || [];
|
|
49
|
+
existing.push(cmd);
|
|
50
|
+
groups.set(cmd.category, existing);
|
|
51
|
+
}
|
|
52
|
+
return groups;
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// Flat list for keyboard navigation
|
|
56
|
+
let flatCommands = $derived(commands);
|
|
57
|
+
|
|
58
|
+
// Reset selection when query changes
|
|
59
|
+
$effect(() => {
|
|
60
|
+
query;
|
|
61
|
+
selectedIndex = 0;
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
// Focus input when opened
|
|
65
|
+
$effect(() => {
|
|
66
|
+
if (open && inputElement) {
|
|
67
|
+
query = '';
|
|
68
|
+
selectedIndex = 0;
|
|
69
|
+
// Small delay to ensure DOM is ready
|
|
70
|
+
setTimeout(() => inputElement?.focus(), 10);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
function handleKeyDown(e: KeyboardEvent) {
|
|
75
|
+
switch (e.key) {
|
|
76
|
+
case 'ArrowDown':
|
|
77
|
+
e.preventDefault();
|
|
78
|
+
selectedIndex = Math.min(selectedIndex + 1, flatCommands.length - 1);
|
|
79
|
+
scrollToSelected();
|
|
80
|
+
break;
|
|
81
|
+
case 'ArrowUp':
|
|
82
|
+
e.preventDefault();
|
|
83
|
+
selectedIndex = Math.max(selectedIndex - 1, 0);
|
|
84
|
+
scrollToSelected();
|
|
85
|
+
break;
|
|
86
|
+
case 'Enter':
|
|
87
|
+
e.preventDefault();
|
|
88
|
+
executeSelected();
|
|
89
|
+
break;
|
|
90
|
+
case 'Escape':
|
|
91
|
+
e.preventDefault();
|
|
92
|
+
close();
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function scrollToSelected() {
|
|
98
|
+
const selected = document.querySelector('.command-palette__item--selected');
|
|
99
|
+
selected?.scrollIntoView({ block: 'nearest' });
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function executeSelected() {
|
|
103
|
+
const command = flatCommands[selectedIndex];
|
|
104
|
+
if (command) {
|
|
105
|
+
executeCommand(command);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function executeCommand(command: Command) {
|
|
110
|
+
close();
|
|
111
|
+
// Execute after close to avoid UI glitches
|
|
112
|
+
setTimeout(() => {
|
|
113
|
+
command.execute();
|
|
114
|
+
}, 50);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function close() {
|
|
118
|
+
open = false;
|
|
119
|
+
onClose?.();
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function handleBackdropClick(e: MouseEvent) {
|
|
123
|
+
if (e.target === e.currentTarget) {
|
|
124
|
+
close();
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function highlightMatch(text: string, search: string): string {
|
|
129
|
+
if (!search.trim()) return escapeHtml(text);
|
|
130
|
+
|
|
131
|
+
const regex = new RegExp(`(${escapeRegex(search)})`, 'gi');
|
|
132
|
+
return escapeHtml(text).replace(regex, '<mark>$1</mark>');
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function escapeHtml(text: string): string {
|
|
136
|
+
return text
|
|
137
|
+
.replace(/&/g, '&')
|
|
138
|
+
.replace(/</g, '<')
|
|
139
|
+
.replace(/>/g, '>');
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function escapeRegex(text: string): string {
|
|
143
|
+
return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function getCategoryLabel(categoryId: string): string {
|
|
147
|
+
const categories = registry.getCategories();
|
|
148
|
+
const cat = categories.find((c) => c.id === categoryId);
|
|
149
|
+
return cat?.label || categoryId;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function getCategoryIcon(categoryId: string): string {
|
|
153
|
+
const categories = registry.getCategories();
|
|
154
|
+
const cat = categories.find((c) => c.id === categoryId);
|
|
155
|
+
return cat?.icon || '';
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Global index tracker for flat list
|
|
159
|
+
function getFlatIndex(category: string, indexInCategory: number): number {
|
|
160
|
+
let idx = 0;
|
|
161
|
+
for (const [cat, cmds] of groupedCommands) {
|
|
162
|
+
if (cat === category) {
|
|
163
|
+
return idx + indexInCategory;
|
|
164
|
+
}
|
|
165
|
+
idx += cmds.length;
|
|
166
|
+
}
|
|
167
|
+
return idx;
|
|
168
|
+
}
|
|
169
|
+
</script>
|
|
170
|
+
|
|
171
|
+
{#if open}
|
|
172
|
+
<!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
|
|
173
|
+
<div
|
|
174
|
+
class="command-palette__backdrop"
|
|
175
|
+
onclick={handleBackdropClick}
|
|
176
|
+
onkeydown={handleKeyDown}
|
|
177
|
+
role="dialog"
|
|
178
|
+
tabindex={-1}
|
|
179
|
+
aria-modal="true"
|
|
180
|
+
aria-label="Command palette"
|
|
181
|
+
>
|
|
182
|
+
<div class="command-palette">
|
|
183
|
+
<div class="command-palette__header">
|
|
184
|
+
<span class="command-palette__icon">⌘</span>
|
|
185
|
+
<input
|
|
186
|
+
bind:this={inputElement}
|
|
187
|
+
bind:value={query}
|
|
188
|
+
type="text"
|
|
189
|
+
class="command-palette__input"
|
|
190
|
+
{placeholder}
|
|
191
|
+
autocomplete="off"
|
|
192
|
+
spellcheck="false"
|
|
193
|
+
/>
|
|
194
|
+
<button class="command-palette__close" onclick={close} aria-label="Close">
|
|
195
|
+
✕
|
|
196
|
+
</button>
|
|
197
|
+
</div>
|
|
198
|
+
|
|
199
|
+
<div class="command-palette__content">
|
|
200
|
+
{#if flatCommands.length === 0}
|
|
201
|
+
<div class="command-palette__empty">No commands found</div>
|
|
202
|
+
{:else}
|
|
203
|
+
{#each [...groupedCommands] as [category, categoryCommands], categoryIdx}
|
|
204
|
+
<div class="command-palette__group">
|
|
205
|
+
<div class="command-palette__group-header">
|
|
206
|
+
<span class="command-palette__group-icon">{getCategoryIcon(category)}</span>
|
|
207
|
+
<span class="command-palette__group-label">{getCategoryLabel(category)}</span>
|
|
208
|
+
</div>
|
|
209
|
+
{#each categoryCommands as command, cmdIdx}
|
|
210
|
+
{@const flatIdx = getFlatIndex(category, cmdIdx)}
|
|
211
|
+
<button
|
|
212
|
+
class="command-palette__item"
|
|
213
|
+
class:command-palette__item--selected={flatIdx === selectedIndex}
|
|
214
|
+
onclick={() => executeCommand(command)}
|
|
215
|
+
onmouseenter={() => (selectedIndex = flatIdx)}
|
|
216
|
+
>
|
|
217
|
+
<span class="command-palette__item-icon">{command.icon || ''}</span>
|
|
218
|
+
<span class="command-palette__item-label">
|
|
219
|
+
{@html highlightMatch(command.label, query)}
|
|
220
|
+
</span>
|
|
221
|
+
{#if command.shortcut}
|
|
222
|
+
<span class="command-palette__item-shortcut">{command.shortcut}</span>
|
|
223
|
+
{/if}
|
|
224
|
+
</button>
|
|
225
|
+
{/each}
|
|
226
|
+
</div>
|
|
227
|
+
{/each}
|
|
228
|
+
{/if}
|
|
229
|
+
</div>
|
|
230
|
+
|
|
231
|
+
<div class="command-palette__footer">
|
|
232
|
+
<span class="command-palette__hint">
|
|
233
|
+
<kbd>↑</kbd><kbd>↓</kbd> Navigate
|
|
234
|
+
</span>
|
|
235
|
+
<span class="command-palette__hint">
|
|
236
|
+
<kbd>↵</kbd> Execute
|
|
237
|
+
</span>
|
|
238
|
+
<span class="command-palette__hint">
|
|
239
|
+
<kbd>Esc</kbd> Close
|
|
240
|
+
</span>
|
|
241
|
+
</div>
|
|
242
|
+
</div>
|
|
243
|
+
</div>
|
|
244
|
+
{/if}
|
|
245
|
+
|
|
246
|
+
<style>
|
|
247
|
+
.command-palette__backdrop {
|
|
248
|
+
position: fixed;
|
|
249
|
+
inset: 0;
|
|
250
|
+
z-index: 9999;
|
|
251
|
+
background: rgba(0, 0, 0, 0.5);
|
|
252
|
+
display: flex;
|
|
253
|
+
justify-content: center;
|
|
254
|
+
padding-top: 10vh;
|
|
255
|
+
backdrop-filter: blur(2px);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
.command-palette {
|
|
259
|
+
width: 100%;
|
|
260
|
+
max-width: 600px;
|
|
261
|
+
max-height: 70vh;
|
|
262
|
+
background: var(--color-surface, #1e1e2e);
|
|
263
|
+
border: 1px solid var(--color-border, #333);
|
|
264
|
+
border-radius: 12px;
|
|
265
|
+
box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
|
|
266
|
+
display: flex;
|
|
267
|
+
flex-direction: column;
|
|
268
|
+
overflow: hidden;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
.command-palette__header {
|
|
272
|
+
display: flex;
|
|
273
|
+
align-items: center;
|
|
274
|
+
gap: 12px;
|
|
275
|
+
padding: 12px 16px;
|
|
276
|
+
border-bottom: 1px solid var(--color-border, #333);
|
|
277
|
+
background: var(--color-surface-secondary, #252535);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
.command-palette__icon {
|
|
281
|
+
font-size: 18px;
|
|
282
|
+
color: var(--color-text-muted, #888);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
.command-palette__input {
|
|
286
|
+
flex: 1;
|
|
287
|
+
background: transparent;
|
|
288
|
+
border: none;
|
|
289
|
+
outline: none;
|
|
290
|
+
font-size: 16px;
|
|
291
|
+
color: var(--color-text, #e8e8f0);
|
|
292
|
+
font-family: inherit;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
.command-palette__input::placeholder {
|
|
296
|
+
color: var(--color-text-muted, #666);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
.command-palette__close {
|
|
300
|
+
background: none;
|
|
301
|
+
border: none;
|
|
302
|
+
color: var(--color-text-muted, #888);
|
|
303
|
+
cursor: pointer;
|
|
304
|
+
font-size: 16px;
|
|
305
|
+
padding: 4px 8px;
|
|
306
|
+
border-radius: 4px;
|
|
307
|
+
transition: background 0.15s ease;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
.command-palette__close:hover {
|
|
311
|
+
background: rgba(255, 255, 255, 0.1);
|
|
312
|
+
color: var(--color-text, #e8e8f0);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
.command-palette__content {
|
|
316
|
+
flex: 1;
|
|
317
|
+
overflow-y: auto;
|
|
318
|
+
padding: 8px 0;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
.command-palette__empty {
|
|
322
|
+
padding: 24px;
|
|
323
|
+
text-align: center;
|
|
324
|
+
color: var(--color-text-muted, #888);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
.command-palette__group {
|
|
328
|
+
margin-bottom: 8px;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
.command-palette__group-header {
|
|
332
|
+
display: flex;
|
|
333
|
+
align-items: center;
|
|
334
|
+
gap: 8px;
|
|
335
|
+
padding: 6px 16px;
|
|
336
|
+
font-size: 11px;
|
|
337
|
+
font-weight: 600;
|
|
338
|
+
text-transform: uppercase;
|
|
339
|
+
letter-spacing: 0.05em;
|
|
340
|
+
color: var(--color-text-muted, #888);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
.command-palette__group-icon {
|
|
344
|
+
opacity: 0.7;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
.command-palette__item {
|
|
348
|
+
display: flex;
|
|
349
|
+
align-items: center;
|
|
350
|
+
gap: 12px;
|
|
351
|
+
width: 100%;
|
|
352
|
+
padding: 8px 16px;
|
|
353
|
+
background: transparent;
|
|
354
|
+
border: none;
|
|
355
|
+
text-align: left;
|
|
356
|
+
color: var(--color-text, #e8e8f0);
|
|
357
|
+
cursor: pointer;
|
|
358
|
+
font-size: 14px;
|
|
359
|
+
transition: background 0.1s ease;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
.command-palette__item:hover,
|
|
363
|
+
.command-palette__item--selected {
|
|
364
|
+
background: rgba(255, 255, 255, 0.08);
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
.command-palette__item--selected {
|
|
368
|
+
background: var(--color-primary, #4a9eff) !important;
|
|
369
|
+
color: #fff;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
.command-palette__item-icon {
|
|
373
|
+
width: 20px;
|
|
374
|
+
text-align: center;
|
|
375
|
+
opacity: 0.7;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
.command-palette__item-label {
|
|
379
|
+
flex: 1;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
.command-palette__item-label :global(mark) {
|
|
383
|
+
background: rgba(255, 200, 0, 0.3);
|
|
384
|
+
color: inherit;
|
|
385
|
+
border-radius: 2px;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
.command-palette__item--selected .command-palette__item-label :global(mark) {
|
|
389
|
+
background: rgba(255, 255, 255, 0.3);
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
.command-palette__item-shortcut {
|
|
393
|
+
font-size: 11px;
|
|
394
|
+
padding: 2px 6px;
|
|
395
|
+
background: rgba(255, 255, 255, 0.1);
|
|
396
|
+
border-radius: 4px;
|
|
397
|
+
color: var(--color-text-muted, #888);
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
.command-palette__item--selected .command-palette__item-shortcut {
|
|
401
|
+
background: rgba(255, 255, 255, 0.2);
|
|
402
|
+
color: rgba(255, 255, 255, 0.9);
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
.command-palette__footer {
|
|
406
|
+
display: flex;
|
|
407
|
+
justify-content: center;
|
|
408
|
+
gap: 24px;
|
|
409
|
+
padding: 10px 16px;
|
|
410
|
+
border-top: 1px solid var(--color-border, #333);
|
|
411
|
+
background: var(--color-surface-secondary, #252535);
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
.command-palette__hint {
|
|
415
|
+
display: flex;
|
|
416
|
+
align-items: center;
|
|
417
|
+
gap: 6px;
|
|
418
|
+
font-size: 11px;
|
|
419
|
+
color: var(--color-text-muted, #888);
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
.command-palette__hint kbd {
|
|
423
|
+
display: inline-flex;
|
|
424
|
+
align-items: center;
|
|
425
|
+
justify-content: center;
|
|
426
|
+
min-width: 20px;
|
|
427
|
+
height: 20px;
|
|
428
|
+
padding: 0 6px;
|
|
429
|
+
background: rgba(255, 255, 255, 0.1);
|
|
430
|
+
border-radius: 4px;
|
|
431
|
+
font-family: inherit;
|
|
432
|
+
font-size: 10px;
|
|
433
|
+
}
|
|
434
|
+
</style>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface Props {
|
|
2
|
+
/** Whether the palette is open */
|
|
3
|
+
open?: boolean;
|
|
4
|
+
/** Callback when palette closes */
|
|
5
|
+
onClose?: () => void;
|
|
6
|
+
/** Placeholder text */
|
|
7
|
+
placeholder?: string;
|
|
8
|
+
}
|
|
9
|
+
declare const CommandPalette: import("svelte").Component<Props, {}, "open">;
|
|
10
|
+
type CommandPalette = ReturnType<typeof CommandPalette>;
|
|
11
|
+
export default CommandPalette;
|