@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,388 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* DiagnosticsPanel - LSP diagnostics list display
|
|
4
|
+
*
|
|
5
|
+
* Shows errors, warnings, info, and hints from the language server
|
|
6
|
+
* in a filterable, navigable panel.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { Diagnostic, DiagnosticSeverity } from '../../types/lsp';
|
|
10
|
+
|
|
11
|
+
interface DiagnosticWithFile extends Diagnostic {
|
|
12
|
+
uri: string;
|
|
13
|
+
fileName: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface Props {
|
|
17
|
+
/** Diagnostics grouped by file URI */
|
|
18
|
+
diagnostics: Map<string, Diagnostic[]>;
|
|
19
|
+
/** Filter by severity (null = show all) */
|
|
20
|
+
severityFilter?: DiagnosticSeverity | null;
|
|
21
|
+
/** Called when a diagnostic is clicked */
|
|
22
|
+
onNavigate: (uri: string, line: number, column: number) => void;
|
|
23
|
+
/** Called when filter changes */
|
|
24
|
+
onFilterChange?: (severity: DiagnosticSeverity | null) => void;
|
|
25
|
+
class?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
let {
|
|
29
|
+
diagnostics,
|
|
30
|
+
severityFilter = null,
|
|
31
|
+
onNavigate,
|
|
32
|
+
onFilterChange,
|
|
33
|
+
class: className = ''
|
|
34
|
+
}: Props = $props();
|
|
35
|
+
|
|
36
|
+
// Flatten diagnostics with file info
|
|
37
|
+
let allDiagnostics = $derived(() => {
|
|
38
|
+
const result: DiagnosticWithFile[] = [];
|
|
39
|
+
diagnostics.forEach((diags, uri) => {
|
|
40
|
+
const fileName = uri.split('/').pop() || uri;
|
|
41
|
+
for (const diag of diags) {
|
|
42
|
+
if (severityFilter === null || diag.severity === severityFilter) {
|
|
43
|
+
result.push({ ...diag, uri, fileName });
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
// Sort by severity (errors first), then by file, then by line
|
|
48
|
+
return result.sort((a, b) => {
|
|
49
|
+
if (a.severity !== b.severity) {
|
|
50
|
+
return (a.severity ?? 4) - (b.severity ?? 4);
|
|
51
|
+
}
|
|
52
|
+
if (a.uri !== b.uri) {
|
|
53
|
+
return a.uri.localeCompare(b.uri);
|
|
54
|
+
}
|
|
55
|
+
return a.range.start.line - b.range.start.line;
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
// Count by severity
|
|
60
|
+
let counts = $derived(() => {
|
|
61
|
+
const result = { errors: 0, warnings: 0, info: 0, hints: 0 };
|
|
62
|
+
diagnostics.forEach((diags) => {
|
|
63
|
+
for (const diag of diags) {
|
|
64
|
+
switch (diag.severity) {
|
|
65
|
+
case 1: result.errors++; break;
|
|
66
|
+
case 2: result.warnings++; break;
|
|
67
|
+
case 3: result.info++; break;
|
|
68
|
+
case 4: result.hints++; break;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
return result;
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
function getSeverityIcon(severity?: DiagnosticSeverity): string {
|
|
76
|
+
switch (severity) {
|
|
77
|
+
case 1: return 'error';
|
|
78
|
+
case 2: return 'warning';
|
|
79
|
+
case 3: return 'info';
|
|
80
|
+
case 4: return 'hint';
|
|
81
|
+
default: return 'info';
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function getSeverityLabel(severity?: DiagnosticSeverity): string {
|
|
86
|
+
switch (severity) {
|
|
87
|
+
case 1: return 'Error';
|
|
88
|
+
case 2: return 'Warning';
|
|
89
|
+
case 3: return 'Info';
|
|
90
|
+
case 4: return 'Hint';
|
|
91
|
+
default: return 'Unknown';
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function handleDiagnosticClick(diag: DiagnosticWithFile) {
|
|
96
|
+
onNavigate(diag.uri, diag.range.start.line, diag.range.start.character);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function setFilter(severity: DiagnosticSeverity | null) {
|
|
100
|
+
onFilterChange?.(severity);
|
|
101
|
+
}
|
|
102
|
+
</script>
|
|
103
|
+
|
|
104
|
+
<div class="diagnostics-panel {className}">
|
|
105
|
+
<div class="diagnostics-panel__header">
|
|
106
|
+
<h3 class="diagnostics-panel__title">Problems</h3>
|
|
107
|
+
<div class="diagnostics-panel__filters">
|
|
108
|
+
<button
|
|
109
|
+
class="diagnostics-panel__filter"
|
|
110
|
+
class:diagnostics-panel__filter--active={severityFilter === null}
|
|
111
|
+
onclick={() => setFilter(null)}
|
|
112
|
+
title="Show all"
|
|
113
|
+
>
|
|
114
|
+
All ({allDiagnostics().length})
|
|
115
|
+
</button>
|
|
116
|
+
<button
|
|
117
|
+
class="diagnostics-panel__filter diagnostics-panel__filter--error"
|
|
118
|
+
class:diagnostics-panel__filter--active={severityFilter === 1}
|
|
119
|
+
onclick={() => setFilter(1)}
|
|
120
|
+
title="Show errors"
|
|
121
|
+
disabled={counts().errors === 0}
|
|
122
|
+
>
|
|
123
|
+
<span class="diagnostics-panel__icon diagnostics-panel__icon--error">
|
|
124
|
+
{@html errorIcon}
|
|
125
|
+
</span>
|
|
126
|
+
{counts().errors}
|
|
127
|
+
</button>
|
|
128
|
+
<button
|
|
129
|
+
class="diagnostics-panel__filter diagnostics-panel__filter--warning"
|
|
130
|
+
class:diagnostics-panel__filter--active={severityFilter === 2}
|
|
131
|
+
onclick={() => setFilter(2)}
|
|
132
|
+
title="Show warnings"
|
|
133
|
+
disabled={counts().warnings === 0}
|
|
134
|
+
>
|
|
135
|
+
<span class="diagnostics-panel__icon diagnostics-panel__icon--warning">
|
|
136
|
+
{@html warningIcon}
|
|
137
|
+
</span>
|
|
138
|
+
{counts().warnings}
|
|
139
|
+
</button>
|
|
140
|
+
<button
|
|
141
|
+
class="diagnostics-panel__filter diagnostics-panel__filter--info"
|
|
142
|
+
class:diagnostics-panel__filter--active={severityFilter === 3}
|
|
143
|
+
onclick={() => setFilter(3)}
|
|
144
|
+
title="Show info"
|
|
145
|
+
disabled={counts().info === 0}
|
|
146
|
+
>
|
|
147
|
+
<span class="diagnostics-panel__icon diagnostics-panel__icon--info">
|
|
148
|
+
{@html infoIcon}
|
|
149
|
+
</span>
|
|
150
|
+
{counts().info}
|
|
151
|
+
</button>
|
|
152
|
+
</div>
|
|
153
|
+
</div>
|
|
154
|
+
|
|
155
|
+
<div class="diagnostics-panel__list" role="list">
|
|
156
|
+
{#if allDiagnostics().length === 0}
|
|
157
|
+
<div class="diagnostics-panel__empty">
|
|
158
|
+
<span class="diagnostics-panel__empty-icon">{@html checkIcon}</span>
|
|
159
|
+
<span>No problems detected</span>
|
|
160
|
+
</div>
|
|
161
|
+
{:else}
|
|
162
|
+
{#each allDiagnostics() as diag, i}
|
|
163
|
+
<button
|
|
164
|
+
class="diagnostics-panel__item diagnostics-panel__item--{getSeverityIcon(diag.severity)}"
|
|
165
|
+
role="listitem"
|
|
166
|
+
onclick={() => handleDiagnosticClick(diag)}
|
|
167
|
+
>
|
|
168
|
+
<span class="diagnostics-panel__item-icon">
|
|
169
|
+
{@html getSeveritySVG(diag.severity)}
|
|
170
|
+
</span>
|
|
171
|
+
<div class="diagnostics-panel__item-content">
|
|
172
|
+
<span class="diagnostics-panel__item-message">{diag.message}</span>
|
|
173
|
+
<span class="diagnostics-panel__item-location">
|
|
174
|
+
{diag.fileName}:{diag.range.start.line + 1}:{diag.range.start.character + 1}
|
|
175
|
+
{#if diag.source}
|
|
176
|
+
<span class="diagnostics-panel__item-source">[{diag.source}]</span>
|
|
177
|
+
{/if}
|
|
178
|
+
{#if diag.code}
|
|
179
|
+
<span class="diagnostics-panel__item-code">({diag.code})</span>
|
|
180
|
+
{/if}
|
|
181
|
+
</span>
|
|
182
|
+
</div>
|
|
183
|
+
</button>
|
|
184
|
+
{/each}
|
|
185
|
+
{/if}
|
|
186
|
+
</div>
|
|
187
|
+
</div>
|
|
188
|
+
|
|
189
|
+
<script context="module" lang="ts">
|
|
190
|
+
const errorIcon = `<svg viewBox="0 0 16 16" width="14" height="14"><circle cx="8" cy="8" r="7" fill="currentColor"/><path d="M5.5 5.5l5 5M10.5 5.5l-5 5" stroke="var(--ide-bg-primary)" stroke-width="1.5"/></svg>`;
|
|
191
|
+
const warningIcon = `<svg viewBox="0 0 16 16" width="14" height="14"><path d="M8 1L1 15h14L8 1z" fill="currentColor"/><path d="M8 6v4M8 12v1" stroke="var(--ide-bg-primary)" stroke-width="1.5" stroke-linecap="round"/></svg>`;
|
|
192
|
+
const infoIcon = `<svg viewBox="0 0 16 16" width="14" height="14"><circle cx="8" cy="8" r="7" fill="currentColor"/><path d="M8 5v1M8 8v4" stroke="var(--ide-bg-primary)" stroke-width="1.5" stroke-linecap="round"/></svg>`;
|
|
193
|
+
const checkIcon = `<svg viewBox="0 0 16 16" width="24" height="24"><circle cx="8" cy="8" r="7" fill="var(--ide-success)" opacity="0.2"/><path d="M5 8l2 2 4-4" stroke="var(--ide-success)" stroke-width="1.5" fill="none" stroke-linecap="round" stroke-linejoin="round"/></svg>`;
|
|
194
|
+
|
|
195
|
+
function getSeveritySVG(severity?: number): string {
|
|
196
|
+
switch (severity) {
|
|
197
|
+
case 1: return errorIcon;
|
|
198
|
+
case 2: return warningIcon;
|
|
199
|
+
case 3: return infoIcon;
|
|
200
|
+
case 4: return `<svg viewBox="0 0 16 16" width="14" height="14"><circle cx="8" cy="8" r="7" fill="currentColor"/><path d="M8 4v5M8 11v1" stroke="var(--ide-bg-primary)" stroke-width="1.5" stroke-linecap="round"/></svg>`;
|
|
201
|
+
default: return infoIcon;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
</script>
|
|
205
|
+
|
|
206
|
+
<style>
|
|
207
|
+
.diagnostics-panel {
|
|
208
|
+
display: flex;
|
|
209
|
+
flex-direction: column;
|
|
210
|
+
height: 100%;
|
|
211
|
+
background: var(--ide-bg-secondary);
|
|
212
|
+
border-top: 1px solid var(--ide-border);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
.diagnostics-panel__header {
|
|
216
|
+
display: flex;
|
|
217
|
+
align-items: center;
|
|
218
|
+
justify-content: space-between;
|
|
219
|
+
padding: var(--ide-spacing-xs) var(--ide-spacing-sm);
|
|
220
|
+
border-bottom: 1px solid var(--ide-border);
|
|
221
|
+
background: var(--ide-bg-tertiary);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
.diagnostics-panel__title {
|
|
225
|
+
margin: 0;
|
|
226
|
+
font-size: var(--ide-font-size-sm);
|
|
227
|
+
font-weight: 500;
|
|
228
|
+
color: var(--ide-text-secondary);
|
|
229
|
+
text-transform: uppercase;
|
|
230
|
+
letter-spacing: 0.05em;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
.diagnostics-panel__filters {
|
|
234
|
+
display: flex;
|
|
235
|
+
gap: var(--ide-spacing-xs);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
.diagnostics-panel__filter {
|
|
239
|
+
display: flex;
|
|
240
|
+
align-items: center;
|
|
241
|
+
gap: 4px;
|
|
242
|
+
padding: 2px 8px;
|
|
243
|
+
border: none;
|
|
244
|
+
border-radius: var(--ide-radius-sm);
|
|
245
|
+
background: transparent;
|
|
246
|
+
color: var(--ide-text-secondary);
|
|
247
|
+
font: inherit;
|
|
248
|
+
font-size: var(--ide-font-size-xs);
|
|
249
|
+
cursor: pointer;
|
|
250
|
+
transition: all var(--ide-transition-fast);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
.diagnostics-panel__filter:hover:not(:disabled) {
|
|
254
|
+
background: var(--ide-bg-hover);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
.diagnostics-panel__filter:disabled {
|
|
258
|
+
opacity: 0.4;
|
|
259
|
+
cursor: not-allowed;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
.diagnostics-panel__filter--active {
|
|
263
|
+
background: var(--ide-bg-active);
|
|
264
|
+
color: var(--ide-text-primary);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
.diagnostics-panel__icon {
|
|
268
|
+
display: flex;
|
|
269
|
+
align-items: center;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
.diagnostics-panel__icon--error {
|
|
273
|
+
color: var(--ide-error);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
.diagnostics-panel__icon--warning {
|
|
277
|
+
color: var(--ide-warning);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
.diagnostics-panel__icon--info {
|
|
281
|
+
color: var(--ide-info);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
.diagnostics-panel__list {
|
|
285
|
+
flex: 1;
|
|
286
|
+
overflow-y: auto;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
.diagnostics-panel__empty {
|
|
290
|
+
display: flex;
|
|
291
|
+
flex-direction: column;
|
|
292
|
+
align-items: center;
|
|
293
|
+
justify-content: center;
|
|
294
|
+
gap: var(--ide-spacing-sm);
|
|
295
|
+
height: 100%;
|
|
296
|
+
color: var(--ide-text-muted);
|
|
297
|
+
font-size: var(--ide-font-size-sm);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
.diagnostics-panel__item {
|
|
301
|
+
display: flex;
|
|
302
|
+
align-items: flex-start;
|
|
303
|
+
gap: var(--ide-spacing-sm);
|
|
304
|
+
width: 100%;
|
|
305
|
+
padding: var(--ide-spacing-xs) var(--ide-spacing-sm);
|
|
306
|
+
border: none;
|
|
307
|
+
border-bottom: 1px solid var(--ide-border-light);
|
|
308
|
+
background: transparent;
|
|
309
|
+
color: var(--ide-text-primary);
|
|
310
|
+
font: inherit;
|
|
311
|
+
font-size: var(--ide-font-size-sm);
|
|
312
|
+
text-align: left;
|
|
313
|
+
cursor: pointer;
|
|
314
|
+
transition: background var(--ide-transition-fast);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
.diagnostics-panel__item:hover {
|
|
318
|
+
background: var(--ide-bg-hover);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
.diagnostics-panel__item:last-child {
|
|
322
|
+
border-bottom: none;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
.diagnostics-panel__item-icon {
|
|
326
|
+
flex-shrink: 0;
|
|
327
|
+
display: flex;
|
|
328
|
+
align-items: center;
|
|
329
|
+
margin-top: 2px;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
.diagnostics-panel__item--error .diagnostics-panel__item-icon {
|
|
333
|
+
color: var(--ide-error);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
.diagnostics-panel__item--warning .diagnostics-panel__item-icon {
|
|
337
|
+
color: var(--ide-warning);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
.diagnostics-panel__item--info .diagnostics-panel__item-icon {
|
|
341
|
+
color: var(--ide-info);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
.diagnostics-panel__item--hint .diagnostics-panel__item-icon {
|
|
345
|
+
color: var(--ide-text-muted);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
.diagnostics-panel__item-content {
|
|
349
|
+
flex: 1;
|
|
350
|
+
min-width: 0;
|
|
351
|
+
display: flex;
|
|
352
|
+
flex-direction: column;
|
|
353
|
+
gap: 2px;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
.diagnostics-panel__item-message {
|
|
357
|
+
color: var(--ide-text-primary);
|
|
358
|
+
word-break: break-word;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
.diagnostics-panel__item-location {
|
|
362
|
+
font-size: var(--ide-font-size-xs);
|
|
363
|
+
font-family: var(--ide-font-mono);
|
|
364
|
+
color: var(--ide-text-muted);
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
.diagnostics-panel__item-source {
|
|
368
|
+
color: var(--ide-text-secondary);
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
.diagnostics-panel__item-code {
|
|
372
|
+
color: var(--ide-text-muted);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
/* Scrollbar styling */
|
|
376
|
+
.diagnostics-panel__list::-webkit-scrollbar {
|
|
377
|
+
width: 8px;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
.diagnostics-panel__list::-webkit-scrollbar-track {
|
|
381
|
+
background: transparent;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
.diagnostics-panel__list::-webkit-scrollbar-thumb {
|
|
385
|
+
background: var(--ide-scrollbar-thumb);
|
|
386
|
+
border-radius: 4px;
|
|
387
|
+
}
|
|
388
|
+
</style>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DiagnosticsPanel - LSP diagnostics list display
|
|
3
|
+
*
|
|
4
|
+
* Shows errors, warnings, info, and hints from the language server
|
|
5
|
+
* in a filterable, navigable panel.
|
|
6
|
+
*/
|
|
7
|
+
import type { Diagnostic, DiagnosticSeverity } from '../../types/lsp';
|
|
8
|
+
interface Props {
|
|
9
|
+
/** Diagnostics grouped by file URI */
|
|
10
|
+
diagnostics: Map<string, Diagnostic[]>;
|
|
11
|
+
/** Filter by severity (null = show all) */
|
|
12
|
+
severityFilter?: DiagnosticSeverity | null;
|
|
13
|
+
/** Called when a diagnostic is clicked */
|
|
14
|
+
onNavigate: (uri: string, line: number, column: number) => void;
|
|
15
|
+
/** Called when filter changes */
|
|
16
|
+
onFilterChange?: (severity: DiagnosticSeverity | null) => void;
|
|
17
|
+
class?: string;
|
|
18
|
+
}
|
|
19
|
+
declare const DiagnosticsPanel: import("svelte").Component<Props, {}, "">;
|
|
20
|
+
type DiagnosticsPanel = ReturnType<typeof DiagnosticsPanel>;
|
|
21
|
+
export default DiagnosticsPanel;
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* HoverTooltip - LSP hover information display
|
|
4
|
+
*
|
|
5
|
+
* Shows type information, documentation, and other hover content
|
|
6
|
+
* from the language server when hovering over code symbols.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { Hover, MarkupContent } from '../../types/lsp';
|
|
10
|
+
|
|
11
|
+
interface Props {
|
|
12
|
+
/** Hover content from LSP */
|
|
13
|
+
hover: Hover;
|
|
14
|
+
/** Position to render the tooltip */
|
|
15
|
+
position: { x: number; y: number };
|
|
16
|
+
/** Maximum width before wrapping */
|
|
17
|
+
maxWidth?: number;
|
|
18
|
+
/** Called when tooltip should close */
|
|
19
|
+
onDismiss: () => void;
|
|
20
|
+
class?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
let {
|
|
24
|
+
hover,
|
|
25
|
+
position,
|
|
26
|
+
maxWidth = 500,
|
|
27
|
+
onDismiss,
|
|
28
|
+
class: className = ''
|
|
29
|
+
}: Props = $props();
|
|
30
|
+
|
|
31
|
+
let tooltipRef: HTMLElement;
|
|
32
|
+
|
|
33
|
+
// Adjust position to stay within viewport
|
|
34
|
+
let adjustedPosition = $derived(() => {
|
|
35
|
+
if (!tooltipRef) return position;
|
|
36
|
+
|
|
37
|
+
const rect = tooltipRef.getBoundingClientRect();
|
|
38
|
+
const viewportWidth = window.innerWidth;
|
|
39
|
+
const viewportHeight = window.innerHeight;
|
|
40
|
+
|
|
41
|
+
let x = position.x;
|
|
42
|
+
let y = position.y;
|
|
43
|
+
|
|
44
|
+
// Adjust horizontal position
|
|
45
|
+
if (x + rect.width > viewportWidth - 16) {
|
|
46
|
+
x = viewportWidth - rect.width - 16;
|
|
47
|
+
}
|
|
48
|
+
if (x < 16) x = 16;
|
|
49
|
+
|
|
50
|
+
// Adjust vertical position - show above if not enough space below
|
|
51
|
+
if (y + rect.height > viewportHeight - 16) {
|
|
52
|
+
y = position.y - rect.height - 24; // 24px to account for cursor height
|
|
53
|
+
}
|
|
54
|
+
if (y < 16) y = 16;
|
|
55
|
+
|
|
56
|
+
return { x, y };
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
function handleKeyDown(e: KeyboardEvent) {
|
|
60
|
+
if (e.key === 'Escape') {
|
|
61
|
+
e.preventDefault();
|
|
62
|
+
onDismiss();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** A code-block string with an explicit language (LSP MarkedString form). */
|
|
67
|
+
type MarkedString = { language: string; value: string };
|
|
68
|
+
/** The shape a single hover content entry can take. */
|
|
69
|
+
type HoverContent = string | MarkupContent | MarkedString;
|
|
70
|
+
|
|
71
|
+
function getHoverContent(): HoverContent | HoverContent[] {
|
|
72
|
+
return hover.contents;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function renderContent(content: HoverContent): { type: 'text' | 'markdown'; value: string } {
|
|
76
|
+
if (typeof content === 'string') {
|
|
77
|
+
return { type: 'text', value: content };
|
|
78
|
+
}
|
|
79
|
+
if ('kind' in content) {
|
|
80
|
+
return { type: content.kind === 'markdown' ? 'markdown' : 'text', value: content.value };
|
|
81
|
+
}
|
|
82
|
+
// MarkedString with language
|
|
83
|
+
if ('language' in content) {
|
|
84
|
+
return { type: 'markdown', value: `\`\`\`${content.language}\n${content.value}\n\`\`\`` };
|
|
85
|
+
}
|
|
86
|
+
return { type: 'text', value: String(content) };
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function getContentsArray(): HoverContent[] {
|
|
90
|
+
const contents = getHoverContent();
|
|
91
|
+
if (Array.isArray(contents)) {
|
|
92
|
+
return contents;
|
|
93
|
+
}
|
|
94
|
+
return [contents];
|
|
95
|
+
}
|
|
96
|
+
</script>
|
|
97
|
+
|
|
98
|
+
<svelte:window onkeydown={handleKeyDown} />
|
|
99
|
+
|
|
100
|
+
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
101
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
102
|
+
<div
|
|
103
|
+
class="hover-tooltip {className}"
|
|
104
|
+
style="left: {adjustedPosition().x}px; top: {adjustedPosition().y}px; max-width: {maxWidth}px;"
|
|
105
|
+
bind:this={tooltipRef}
|
|
106
|
+
role="tooltip"
|
|
107
|
+
onclick={(e) => e.stopPropagation()}
|
|
108
|
+
>
|
|
109
|
+
<div class="hover-tooltip__content">
|
|
110
|
+
{#each getContentsArray() as content, i}
|
|
111
|
+
{@const rendered = renderContent(content)}
|
|
112
|
+
{#if i > 0}
|
|
113
|
+
<hr class="hover-tooltip__divider" />
|
|
114
|
+
{/if}
|
|
115
|
+
{#if rendered.type === 'markdown'}
|
|
116
|
+
<div class="hover-tooltip__markdown">
|
|
117
|
+
{@html renderMarkdown(rendered.value)}
|
|
118
|
+
</div>
|
|
119
|
+
{:else}
|
|
120
|
+
<pre class="hover-tooltip__text">{rendered.value}</pre>
|
|
121
|
+
{/if}
|
|
122
|
+
{/each}
|
|
123
|
+
</div>
|
|
124
|
+
</div>
|
|
125
|
+
|
|
126
|
+
<script context="module" lang="ts">
|
|
127
|
+
// Simple markdown renderer for hover content
|
|
128
|
+
// Handles code blocks, inline code, bold, italic, and links
|
|
129
|
+
function renderMarkdown(text: string): string {
|
|
130
|
+
let html = escapeHtml(text);
|
|
131
|
+
|
|
132
|
+
// Code blocks with language
|
|
133
|
+
html = html.replace(
|
|
134
|
+
/```(\w+)?\n([\s\S]*?)```/g,
|
|
135
|
+
(_, lang, code) => `<pre class="hover-tooltip__code-block" data-lang="${lang || ''}">${code.trim()}</pre>`
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
// Inline code
|
|
139
|
+
html = html.replace(/`([^`]+)`/g, '<code class="hover-tooltip__inline-code">$1</code>');
|
|
140
|
+
|
|
141
|
+
// Bold
|
|
142
|
+
html = html.replace(/\*\*([^*]+)\*\*/g, '<strong>$1</strong>');
|
|
143
|
+
|
|
144
|
+
// Italic
|
|
145
|
+
html = html.replace(/\*([^*]+)\*/g, '<em>$1</em>');
|
|
146
|
+
|
|
147
|
+
// Links (href is validated; unsafe schemes degrade to plain text)
|
|
148
|
+
html = html.replace(/\[([^\]]+)\]\(([^)]+)\)/g, (_match, label: string, href: string) => {
|
|
149
|
+
const url = safeUrl(href);
|
|
150
|
+
return url ? `<a href="${url}" target="_blank" rel="noopener">${label}</a>` : label;
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
// Line breaks
|
|
154
|
+
html = html.replace(/\n/g, '<br>');
|
|
155
|
+
|
|
156
|
+
return html;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function escapeHtml(text: string): string {
|
|
160
|
+
const map: Record<string, string> = {
|
|
161
|
+
'&': '&',
|
|
162
|
+
'<': '<',
|
|
163
|
+
'>': '>',
|
|
164
|
+
'"': '"',
|
|
165
|
+
"'": '''
|
|
166
|
+
};
|
|
167
|
+
return text.replace(/[&<>"']/g, (char) => map[char]);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// Whitelist link schemes. Relative/anchor URLs and http(s)/mailto are allowed;
|
|
171
|
+
// anything else (e.g. javascript:, data:, vbscript:) is rejected.
|
|
172
|
+
function safeUrl(url: string): string | null {
|
|
173
|
+
const trimmed = url.trim();
|
|
174
|
+
if (/^(\/|#|\.\/|\.\.\/)/.test(trimmed)) return trimmed;
|
|
175
|
+
if (/^(https?:|mailto:)/i.test(trimmed)) return trimmed;
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
</script>
|
|
179
|
+
|
|
180
|
+
<style>
|
|
181
|
+
.hover-tooltip {
|
|
182
|
+
position: fixed;
|
|
183
|
+
z-index: 1001;
|
|
184
|
+
background: var(--ide-bg-secondary);
|
|
185
|
+
border: 1px solid var(--ide-border);
|
|
186
|
+
border-radius: var(--ide-radius-md);
|
|
187
|
+
box-shadow: var(--ide-shadow-lg);
|
|
188
|
+
overflow: hidden;
|
|
189
|
+
font-size: var(--ide-font-size-sm);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
.hover-tooltip__content {
|
|
193
|
+
padding: var(--ide-spacing-sm) var(--ide-spacing-md);
|
|
194
|
+
max-height: 400px;
|
|
195
|
+
overflow-y: auto;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
.hover-tooltip__divider {
|
|
199
|
+
border: none;
|
|
200
|
+
border-top: 1px solid var(--ide-border);
|
|
201
|
+
margin: var(--ide-spacing-sm) 0;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
.hover-tooltip__text {
|
|
205
|
+
margin: 0;
|
|
206
|
+
font-family: var(--ide-font-mono);
|
|
207
|
+
white-space: pre-wrap;
|
|
208
|
+
word-break: break-word;
|
|
209
|
+
color: var(--ide-text-primary);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
.hover-tooltip__markdown {
|
|
213
|
+
color: var(--ide-text-primary);
|
|
214
|
+
line-height: 1.5;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
.hover-tooltip__markdown :global(pre) {
|
|
218
|
+
margin: var(--ide-spacing-xs) 0;
|
|
219
|
+
padding: var(--ide-spacing-sm);
|
|
220
|
+
background: var(--ide-bg-tertiary);
|
|
221
|
+
border-radius: var(--ide-radius-sm);
|
|
222
|
+
overflow-x: auto;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
.hover-tooltip__markdown :global(code) {
|
|
226
|
+
font-family: var(--ide-font-mono);
|
|
227
|
+
font-size: var(--ide-font-size-xs);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
.hover-tooltip__markdown :global(.hover-tooltip__code-block) {
|
|
231
|
+
font-family: var(--ide-font-mono);
|
|
232
|
+
font-size: var(--ide-font-size-xs);
|
|
233
|
+
color: var(--ide-syntax-string);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
.hover-tooltip__markdown :global(.hover-tooltip__inline-code) {
|
|
237
|
+
padding: 0.125em 0.25em;
|
|
238
|
+
background: var(--ide-bg-tertiary);
|
|
239
|
+
border-radius: var(--ide-radius-xs);
|
|
240
|
+
font-size: 0.9em;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
.hover-tooltip__markdown :global(strong) {
|
|
244
|
+
font-weight: 600;
|
|
245
|
+
color: var(--ide-text-primary);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
.hover-tooltip__markdown :global(em) {
|
|
249
|
+
font-style: italic;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
.hover-tooltip__markdown :global(a) {
|
|
253
|
+
color: var(--ide-interactive);
|
|
254
|
+
text-decoration: none;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
.hover-tooltip__markdown :global(a:hover) {
|
|
258
|
+
text-decoration: underline;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/* Scrollbar styling */
|
|
262
|
+
.hover-tooltip__content::-webkit-scrollbar {
|
|
263
|
+
width: 8px;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
.hover-tooltip__content::-webkit-scrollbar-track {
|
|
267
|
+
background: transparent;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
.hover-tooltip__content::-webkit-scrollbar-thumb {
|
|
271
|
+
background: var(--ide-scrollbar-thumb);
|
|
272
|
+
border-radius: 4px;
|
|
273
|
+
}
|
|
274
|
+
</style>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HoverTooltip - LSP hover information display
|
|
3
|
+
*
|
|
4
|
+
* Shows type information, documentation, and other hover content
|
|
5
|
+
* from the language server when hovering over code symbols.
|
|
6
|
+
*/
|
|
7
|
+
import type { Hover } from '../../types/lsp';
|
|
8
|
+
interface Props {
|
|
9
|
+
/** Hover content from LSP */
|
|
10
|
+
hover: Hover;
|
|
11
|
+
/** Position to render the tooltip */
|
|
12
|
+
position: {
|
|
13
|
+
x: number;
|
|
14
|
+
y: number;
|
|
15
|
+
};
|
|
16
|
+
/** Maximum width before wrapping */
|
|
17
|
+
maxWidth?: number;
|
|
18
|
+
/** Called when tooltip should close */
|
|
19
|
+
onDismiss: () => void;
|
|
20
|
+
class?: string;
|
|
21
|
+
}
|
|
22
|
+
declare const HoverTooltip: import("svelte").Component<Props, {}, "">;
|
|
23
|
+
type HoverTooltip = ReturnType<typeof HoverTooltip>;
|
|
24
|
+
export default HoverTooltip;
|