@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,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formatting utilities
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Format file size in human-readable form
|
|
6
|
+
*/
|
|
7
|
+
export function formatFileSize(bytes) {
|
|
8
|
+
if (bytes === 0)
|
|
9
|
+
return '0 B';
|
|
10
|
+
const units = ['B', 'KB', 'MB', 'GB', 'TB'];
|
|
11
|
+
const k = 1024;
|
|
12
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
13
|
+
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(1))} ${units[i]}`;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Format a date relative to now
|
|
17
|
+
*/
|
|
18
|
+
export function formatRelativeTime(date) {
|
|
19
|
+
const now = new Date();
|
|
20
|
+
const diffMs = now.getTime() - date.getTime();
|
|
21
|
+
const diffSecs = Math.floor(diffMs / 1000);
|
|
22
|
+
const diffMins = Math.floor(diffSecs / 60);
|
|
23
|
+
const diffHours = Math.floor(diffMins / 60);
|
|
24
|
+
const diffDays = Math.floor(diffHours / 24);
|
|
25
|
+
if (diffSecs < 60) {
|
|
26
|
+
return 'just now';
|
|
27
|
+
}
|
|
28
|
+
else if (diffMins < 60) {
|
|
29
|
+
return `${diffMins}m ago`;
|
|
30
|
+
}
|
|
31
|
+
else if (diffHours < 24) {
|
|
32
|
+
return `${diffHours}h ago`;
|
|
33
|
+
}
|
|
34
|
+
else if (diffDays < 7) {
|
|
35
|
+
return `${diffDays}d ago`;
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
return date.toLocaleDateString();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Format a date for display
|
|
43
|
+
*/
|
|
44
|
+
export function formatDate(date) {
|
|
45
|
+
return date.toLocaleDateString(undefined, {
|
|
46
|
+
year: 'numeric',
|
|
47
|
+
month: 'short',
|
|
48
|
+
day: 'numeric'
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Format a date and time for display
|
|
53
|
+
*/
|
|
54
|
+
export function formatDateTime(date) {
|
|
55
|
+
return date.toLocaleString(undefined, {
|
|
56
|
+
year: 'numeric',
|
|
57
|
+
month: 'short',
|
|
58
|
+
day: 'numeric',
|
|
59
|
+
hour: '2-digit',
|
|
60
|
+
minute: '2-digit'
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Format duration in milliseconds to human readable
|
|
65
|
+
*/
|
|
66
|
+
export function formatDuration(ms) {
|
|
67
|
+
if (ms < 1000) {
|
|
68
|
+
return `${ms}ms`;
|
|
69
|
+
}
|
|
70
|
+
else if (ms < 60000) {
|
|
71
|
+
return `${(ms / 1000).toFixed(1)}s`;
|
|
72
|
+
}
|
|
73
|
+
else if (ms < 3600000) {
|
|
74
|
+
return `${Math.floor(ms / 60000)}m ${Math.floor((ms % 60000) / 1000)}s`;
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
return `${Math.floor(ms / 3600000)}h ${Math.floor((ms % 3600000) / 60000)}m`;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Format line and column position
|
|
82
|
+
*/
|
|
83
|
+
export function formatPosition(line, column) {
|
|
84
|
+
return `Ln ${line}, Col ${column}`;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Format a path for display (truncate middle if too long)
|
|
88
|
+
*/
|
|
89
|
+
export function formatPath(path, maxLength = 50) {
|
|
90
|
+
if (path.length <= maxLength) {
|
|
91
|
+
return path;
|
|
92
|
+
}
|
|
93
|
+
const parts = path.split('/');
|
|
94
|
+
if (parts.length <= 2) {
|
|
95
|
+
return path.slice(0, maxLength - 3) + '...';
|
|
96
|
+
}
|
|
97
|
+
const first = parts[0];
|
|
98
|
+
const last = parts[parts.length - 1];
|
|
99
|
+
const middle = '...';
|
|
100
|
+
if (first.length + last.length + middle.length >= maxLength) {
|
|
101
|
+
return '...' + last.slice(-(maxLength - 3));
|
|
102
|
+
}
|
|
103
|
+
return `${first}/${middle}/${last}`;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Format number with thousands separators
|
|
107
|
+
*/
|
|
108
|
+
export function formatNumber(num) {
|
|
109
|
+
return num.toLocaleString();
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Format percentage
|
|
113
|
+
*/
|
|
114
|
+
export function formatPercent(value, decimals = 0) {
|
|
115
|
+
return `${(value * 100).toFixed(decimals)}%`;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Pluralize a word based on count
|
|
119
|
+
*/
|
|
120
|
+
export function pluralize(count, singular, plural) {
|
|
121
|
+
if (count === 1) {
|
|
122
|
+
return `${count} ${singular}`;
|
|
123
|
+
}
|
|
124
|
+
return `${count} ${plural ?? singular + 's'}`;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Truncate text with ellipsis
|
|
128
|
+
*/
|
|
129
|
+
export function truncate(text, maxLength) {
|
|
130
|
+
if (text.length <= maxLength) {
|
|
131
|
+
return text;
|
|
132
|
+
}
|
|
133
|
+
return text.slice(0, maxLength - 1) + '…';
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Convert camelCase to Title Case
|
|
137
|
+
*/
|
|
138
|
+
export function camelToTitle(text) {
|
|
139
|
+
return text
|
|
140
|
+
.replace(/([A-Z])/g, ' $1')
|
|
141
|
+
.replace(/^./, (str) => str.toUpperCase())
|
|
142
|
+
.trim();
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Convert snake_case to Title Case
|
|
146
|
+
*/
|
|
147
|
+
export function snakeToTitle(text) {
|
|
148
|
+
return text
|
|
149
|
+
.split('_')
|
|
150
|
+
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
|
|
151
|
+
.join(' ');
|
|
152
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keyboard shortcut utilities
|
|
3
|
+
*/
|
|
4
|
+
export interface Keybinding {
|
|
5
|
+
keys: string[];
|
|
6
|
+
command: string;
|
|
7
|
+
when?: string;
|
|
8
|
+
label?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Check if running on macOS
|
|
12
|
+
*/
|
|
13
|
+
export declare function isMac(): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Get the modifier key name for the current platform
|
|
16
|
+
*/
|
|
17
|
+
export declare function getModKey(): string;
|
|
18
|
+
/**
|
|
19
|
+
* Format a key combination for display
|
|
20
|
+
*/
|
|
21
|
+
export declare function formatKeybinding(keys: string[]): string;
|
|
22
|
+
/**
|
|
23
|
+
* Check if a keyboard event matches a key combination
|
|
24
|
+
*/
|
|
25
|
+
export declare function matchesKeybinding(event: KeyboardEvent, keys: string[]): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Create a keyboard event handler for a set of keybindings
|
|
28
|
+
*/
|
|
29
|
+
export declare function createKeybindingHandler(bindings: Keybinding[], executeCommand: (command: string) => void): (event: KeyboardEvent) => void;
|
|
30
|
+
/**
|
|
31
|
+
* Default IDE keybindings
|
|
32
|
+
*/
|
|
33
|
+
export declare const defaultKeybindings: Keybinding[];
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keyboard shortcut utilities
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Check if running on macOS
|
|
6
|
+
*/
|
|
7
|
+
export function isMac() {
|
|
8
|
+
if (typeof navigator === 'undefined')
|
|
9
|
+
return false;
|
|
10
|
+
return navigator.platform.toUpperCase().indexOf('MAC') >= 0;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Get the modifier key name for the current platform
|
|
14
|
+
*/
|
|
15
|
+
export function getModKey() {
|
|
16
|
+
return isMac() ? 'Cmd' : 'Ctrl';
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Format a key combination for display
|
|
20
|
+
*/
|
|
21
|
+
export function formatKeybinding(keys) {
|
|
22
|
+
return keys
|
|
23
|
+
.map((key) => {
|
|
24
|
+
switch (key.toLowerCase()) {
|
|
25
|
+
case 'mod':
|
|
26
|
+
return isMac() ? '⌘' : 'Ctrl';
|
|
27
|
+
case 'ctrl':
|
|
28
|
+
return isMac() ? '⌃' : 'Ctrl';
|
|
29
|
+
case 'alt':
|
|
30
|
+
return isMac() ? '⌥' : 'Alt';
|
|
31
|
+
case 'shift':
|
|
32
|
+
return isMac() ? '⇧' : 'Shift';
|
|
33
|
+
case 'meta':
|
|
34
|
+
case 'cmd':
|
|
35
|
+
return '⌘';
|
|
36
|
+
case 'enter':
|
|
37
|
+
return '↵';
|
|
38
|
+
case 'escape':
|
|
39
|
+
case 'esc':
|
|
40
|
+
return 'Esc';
|
|
41
|
+
case 'backspace':
|
|
42
|
+
return '⌫';
|
|
43
|
+
case 'delete':
|
|
44
|
+
return '⌦';
|
|
45
|
+
case 'tab':
|
|
46
|
+
return '⇥';
|
|
47
|
+
case 'space':
|
|
48
|
+
return 'Space';
|
|
49
|
+
case 'up':
|
|
50
|
+
return '↑';
|
|
51
|
+
case 'down':
|
|
52
|
+
return '↓';
|
|
53
|
+
case 'left':
|
|
54
|
+
return '←';
|
|
55
|
+
case 'right':
|
|
56
|
+
return '→';
|
|
57
|
+
default:
|
|
58
|
+
return key.toUpperCase();
|
|
59
|
+
}
|
|
60
|
+
})
|
|
61
|
+
.join(isMac() ? '' : '+');
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Check if a keyboard event matches a key combination
|
|
65
|
+
*/
|
|
66
|
+
export function matchesKeybinding(event, keys) {
|
|
67
|
+
const normalizedKeys = keys.map((k) => k.toLowerCase());
|
|
68
|
+
// Check modifiers
|
|
69
|
+
const needsMod = normalizedKeys.includes('mod');
|
|
70
|
+
const needsCtrl = normalizedKeys.includes('ctrl');
|
|
71
|
+
const needsAlt = normalizedKeys.includes('alt');
|
|
72
|
+
const needsShift = normalizedKeys.includes('shift');
|
|
73
|
+
const needsMeta = normalizedKeys.includes('meta') || normalizedKeys.includes('cmd');
|
|
74
|
+
// On Mac, 'mod' maps to Meta (Cmd), on others to Ctrl
|
|
75
|
+
const modKey = isMac() ? event.metaKey : event.ctrlKey;
|
|
76
|
+
if (needsMod && !modKey)
|
|
77
|
+
return false;
|
|
78
|
+
if (needsCtrl && !event.ctrlKey)
|
|
79
|
+
return false;
|
|
80
|
+
if (needsAlt && !event.altKey)
|
|
81
|
+
return false;
|
|
82
|
+
if (needsShift && !event.shiftKey)
|
|
83
|
+
return false;
|
|
84
|
+
if (needsMeta && !event.metaKey)
|
|
85
|
+
return false;
|
|
86
|
+
// Check if extra modifiers are pressed
|
|
87
|
+
const modifiersInBinding = ['mod', 'ctrl', 'alt', 'shift', 'meta', 'cmd'];
|
|
88
|
+
const hasExtraCtrl = event.ctrlKey && !needsCtrl && !(needsMod && !isMac());
|
|
89
|
+
const hasExtraAlt = event.altKey && !needsAlt;
|
|
90
|
+
const hasExtraShift = event.shiftKey && !needsShift;
|
|
91
|
+
const hasExtraMeta = event.metaKey && !needsMeta && !(needsMod && isMac());
|
|
92
|
+
if (hasExtraCtrl || hasExtraAlt || hasExtraShift || hasExtraMeta) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
// Get the main key (non-modifier)
|
|
96
|
+
const mainKey = normalizedKeys.find((k) => !modifiersInBinding.includes(k));
|
|
97
|
+
if (!mainKey)
|
|
98
|
+
return false;
|
|
99
|
+
// Normalize event key
|
|
100
|
+
let eventKey = event.key.toLowerCase();
|
|
101
|
+
// Handle special keys
|
|
102
|
+
if (eventKey === ' ')
|
|
103
|
+
eventKey = 'space';
|
|
104
|
+
if (eventKey === 'arrowup')
|
|
105
|
+
eventKey = 'up';
|
|
106
|
+
if (eventKey === 'arrowdown')
|
|
107
|
+
eventKey = 'down';
|
|
108
|
+
if (eventKey === 'arrowleft')
|
|
109
|
+
eventKey = 'left';
|
|
110
|
+
if (eventKey === 'arrowright')
|
|
111
|
+
eventKey = 'right';
|
|
112
|
+
return eventKey === mainKey;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Create a keyboard event handler for a set of keybindings
|
|
116
|
+
*/
|
|
117
|
+
export function createKeybindingHandler(bindings, executeCommand) {
|
|
118
|
+
return (event) => {
|
|
119
|
+
for (const binding of bindings) {
|
|
120
|
+
if (matchesKeybinding(event, binding.keys)) {
|
|
121
|
+
event.preventDefault();
|
|
122
|
+
event.stopPropagation();
|
|
123
|
+
executeCommand(binding.command);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Default IDE keybindings
|
|
131
|
+
*/
|
|
132
|
+
export const defaultKeybindings = [
|
|
133
|
+
// File operations
|
|
134
|
+
{ keys: ['mod', 's'], command: 'file.save', label: 'Save' },
|
|
135
|
+
{ keys: ['mod', 'shift', 's'], command: 'file.saveAll', label: 'Save All' },
|
|
136
|
+
{ keys: ['mod', 'w'], command: 'file.close', label: 'Close Tab' },
|
|
137
|
+
{ keys: ['mod', 'shift', 'w'], command: 'file.closeAll', label: 'Close All Tabs' },
|
|
138
|
+
{ keys: ['mod', 'n'], command: 'file.new', label: 'New File' },
|
|
139
|
+
{ keys: ['mod', 'o'], command: 'file.open', label: 'Open File' },
|
|
140
|
+
// Navigation
|
|
141
|
+
{ keys: ['mod', 'p'], command: 'quickOpen', label: 'Quick Open' },
|
|
142
|
+
{ keys: ['mod', 'shift', 'p'], command: 'commandPalette', label: 'Command Palette' },
|
|
143
|
+
{ keys: ['mod', 'g'], command: 'goToLine', label: 'Go to Line' },
|
|
144
|
+
{ keys: ['ctrl', 'tab'], command: 'tab.next', label: 'Next Tab' },
|
|
145
|
+
{ keys: ['ctrl', 'shift', 'tab'], command: 'tab.prev', label: 'Previous Tab' },
|
|
146
|
+
// Search
|
|
147
|
+
{ keys: ['mod', 'f'], command: 'search.find', label: 'Find' },
|
|
148
|
+
{ keys: ['mod', 'h'], command: 'search.replace', label: 'Find and Replace' },
|
|
149
|
+
{ keys: ['mod', 'shift', 'f'], command: 'search.global', label: 'Search in Files' },
|
|
150
|
+
// View
|
|
151
|
+
{ keys: ['mod', 'b'], command: 'view.sidebar', label: 'Toggle Sidebar' },
|
|
152
|
+
{ keys: ['mod', 'j'], command: 'view.panel', label: 'Toggle Panel' },
|
|
153
|
+
{ keys: ['mod', '`'], command: 'view.terminal', label: 'Toggle Terminal' },
|
|
154
|
+
{ keys: ['mod', 'shift', 'e'], command: 'view.explorer', label: 'Focus Explorer' },
|
|
155
|
+
{ keys: ['mod', '\\'], command: 'view.splitEditor', label: 'Split Editor' },
|
|
156
|
+
{ keys: ['mod', 'k', 'z'], command: 'view.zenMode', label: 'Toggle Zen Mode' },
|
|
157
|
+
// Editor
|
|
158
|
+
{ keys: ['mod', '/'], command: 'editor.toggleComment', label: 'Toggle Comment' },
|
|
159
|
+
{ keys: ['mod', 'd'], command: 'editor.addSelection', label: 'Add Selection' },
|
|
160
|
+
{ keys: ['mod', 'shift', 'k'], command: 'editor.deleteLine', label: 'Delete Line' },
|
|
161
|
+
{ keys: ['alt', 'up'], command: 'editor.moveLineUp', label: 'Move Line Up' },
|
|
162
|
+
{ keys: ['alt', 'down'], command: 'editor.moveLineDown', label: 'Move Line Down' },
|
|
163
|
+
{ keys: ['mod', '['], command: 'editor.outdent', label: 'Outdent Line' },
|
|
164
|
+
{ keys: ['mod', ']'], command: 'editor.indent', label: 'Indent Line' },
|
|
165
|
+
{ keys: ['mod', 'z'], command: 'editor.undo', label: 'Undo' },
|
|
166
|
+
{ keys: ['mod', 'shift', 'z'], command: 'editor.redo', label: 'Redo' },
|
|
167
|
+
// AI
|
|
168
|
+
{ keys: ['mod', 'i'], command: 'ai.toggle', label: 'Toggle AI Panel' },
|
|
169
|
+
{ keys: ['mod', 'shift', 'i'], command: 'ai.explain', label: 'Explain Selection' },
|
|
170
|
+
{ keys: ['mod', 'k'], command: 'ai.inline', label: 'Inline AI Edit' }
|
|
171
|
+
];
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Language detection and utilities
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Detect language from filename
|
|
6
|
+
*/
|
|
7
|
+
export declare function detectLanguage(filename: string): string;
|
|
8
|
+
/**
|
|
9
|
+
* Get file extension (lowercase, without dot)
|
|
10
|
+
*/
|
|
11
|
+
export declare function getExtension(filename: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* Get MIME type for a language
|
|
14
|
+
*/
|
|
15
|
+
export declare function getLanguageMimeType(language: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* Check if a language is supported for syntax highlighting
|
|
18
|
+
*/
|
|
19
|
+
export declare function isLanguageSupported(language: string): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Get display name for a language
|
|
22
|
+
*/
|
|
23
|
+
export declare function getLanguageDisplayName(language: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* Get icon name for a language (for use with icon components)
|
|
26
|
+
*/
|
|
27
|
+
export declare function getLanguageIcon(language: string): string;
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Language detection and utilities
|
|
3
|
+
*/
|
|
4
|
+
const extensionToLanguage = {
|
|
5
|
+
// JavaScript / TypeScript
|
|
6
|
+
js: 'javascript',
|
|
7
|
+
mjs: 'javascript',
|
|
8
|
+
cjs: 'javascript',
|
|
9
|
+
jsx: 'javascript',
|
|
10
|
+
ts: 'typescript',
|
|
11
|
+
tsx: 'typescript',
|
|
12
|
+
mts: 'typescript',
|
|
13
|
+
cts: 'typescript',
|
|
14
|
+
// Web
|
|
15
|
+
html: 'html',
|
|
16
|
+
htm: 'html',
|
|
17
|
+
css: 'css',
|
|
18
|
+
scss: 'css',
|
|
19
|
+
sass: 'css',
|
|
20
|
+
less: 'css',
|
|
21
|
+
// Data formats
|
|
22
|
+
json: 'json',
|
|
23
|
+
jsonc: 'json',
|
|
24
|
+
yaml: 'yaml',
|
|
25
|
+
yml: 'yaml',
|
|
26
|
+
toml: 'toml',
|
|
27
|
+
xml: 'xml',
|
|
28
|
+
svg: 'xml',
|
|
29
|
+
// Markdown
|
|
30
|
+
md: 'markdown',
|
|
31
|
+
mdx: 'markdown',
|
|
32
|
+
markdown: 'markdown',
|
|
33
|
+
// Programming languages
|
|
34
|
+
py: 'python',
|
|
35
|
+
pyw: 'python',
|
|
36
|
+
go: 'go',
|
|
37
|
+
rs: 'rust',
|
|
38
|
+
java: 'java',
|
|
39
|
+
kt: 'kotlin',
|
|
40
|
+
kts: 'kotlin',
|
|
41
|
+
scala: 'scala',
|
|
42
|
+
c: 'cpp',
|
|
43
|
+
cpp: 'cpp',
|
|
44
|
+
cc: 'cpp',
|
|
45
|
+
cxx: 'cpp',
|
|
46
|
+
h: 'cpp',
|
|
47
|
+
hpp: 'cpp',
|
|
48
|
+
hxx: 'cpp',
|
|
49
|
+
cs: 'csharp',
|
|
50
|
+
rb: 'ruby',
|
|
51
|
+
php: 'php',
|
|
52
|
+
swift: 'swift',
|
|
53
|
+
// Shell
|
|
54
|
+
sh: 'shell',
|
|
55
|
+
bash: 'shell',
|
|
56
|
+
zsh: 'shell',
|
|
57
|
+
fish: 'shell',
|
|
58
|
+
ps1: 'powershell',
|
|
59
|
+
psm1: 'powershell',
|
|
60
|
+
// Database
|
|
61
|
+
sql: 'sql',
|
|
62
|
+
psql: 'sql',
|
|
63
|
+
mysql: 'sql',
|
|
64
|
+
// Config
|
|
65
|
+
dockerfile: 'dockerfile',
|
|
66
|
+
makefile: 'makefile',
|
|
67
|
+
cmake: 'cmake',
|
|
68
|
+
// Svelte
|
|
69
|
+
svelte: 'svelte',
|
|
70
|
+
// Vue
|
|
71
|
+
vue: 'vue'
|
|
72
|
+
};
|
|
73
|
+
const filenameToLanguage = {
|
|
74
|
+
dockerfile: 'dockerfile',
|
|
75
|
+
makefile: 'makefile',
|
|
76
|
+
cmakelists: 'cmake',
|
|
77
|
+
gemfile: 'ruby',
|
|
78
|
+
rakefile: 'ruby',
|
|
79
|
+
vagrantfile: 'ruby',
|
|
80
|
+
jenkinsfile: 'groovy',
|
|
81
|
+
'.gitignore': 'gitignore',
|
|
82
|
+
'.gitattributes': 'gitattributes',
|
|
83
|
+
'.editorconfig': 'editorconfig',
|
|
84
|
+
'.env': 'dotenv',
|
|
85
|
+
'.env.local': 'dotenv',
|
|
86
|
+
'.env.development': 'dotenv',
|
|
87
|
+
'.env.production': 'dotenv'
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Detect language from filename
|
|
91
|
+
*/
|
|
92
|
+
export function detectLanguage(filename) {
|
|
93
|
+
const lowerFilename = filename.toLowerCase();
|
|
94
|
+
// Check exact filename matches first
|
|
95
|
+
if (filenameToLanguage[lowerFilename]) {
|
|
96
|
+
return filenameToLanguage[lowerFilename];
|
|
97
|
+
}
|
|
98
|
+
// Check for files without extension but known names
|
|
99
|
+
const baseName = lowerFilename.split('/').pop() ?? lowerFilename;
|
|
100
|
+
if (filenameToLanguage[baseName]) {
|
|
101
|
+
return filenameToLanguage[baseName];
|
|
102
|
+
}
|
|
103
|
+
// Get extension
|
|
104
|
+
const ext = getExtension(filename);
|
|
105
|
+
if (ext && extensionToLanguage[ext]) {
|
|
106
|
+
return extensionToLanguage[ext];
|
|
107
|
+
}
|
|
108
|
+
return 'plaintext';
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Get file extension (lowercase, without dot)
|
|
112
|
+
*/
|
|
113
|
+
export function getExtension(filename) {
|
|
114
|
+
const lastDot = filename.lastIndexOf('.');
|
|
115
|
+
if (lastDot === -1 || lastDot === filename.length - 1) {
|
|
116
|
+
return '';
|
|
117
|
+
}
|
|
118
|
+
return filename.slice(lastDot + 1).toLowerCase();
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Get MIME type for a language
|
|
122
|
+
*/
|
|
123
|
+
export function getLanguageMimeType(language) {
|
|
124
|
+
const mimeTypes = {
|
|
125
|
+
javascript: 'text/javascript',
|
|
126
|
+
typescript: 'text/typescript',
|
|
127
|
+
html: 'text/html',
|
|
128
|
+
css: 'text/css',
|
|
129
|
+
json: 'application/json',
|
|
130
|
+
xml: 'application/xml',
|
|
131
|
+
markdown: 'text/markdown',
|
|
132
|
+
python: 'text/x-python',
|
|
133
|
+
go: 'text/x-go',
|
|
134
|
+
rust: 'text/x-rust',
|
|
135
|
+
java: 'text/x-java',
|
|
136
|
+
cpp: 'text/x-c++src',
|
|
137
|
+
sql: 'text/x-sql',
|
|
138
|
+
yaml: 'text/x-yaml',
|
|
139
|
+
plaintext: 'text/plain'
|
|
140
|
+
};
|
|
141
|
+
return mimeTypes[language] ?? 'text/plain';
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Check if a language is supported for syntax highlighting
|
|
145
|
+
*/
|
|
146
|
+
export function isLanguageSupported(language) {
|
|
147
|
+
const supported = [
|
|
148
|
+
'javascript',
|
|
149
|
+
'typescript',
|
|
150
|
+
'html',
|
|
151
|
+
'css',
|
|
152
|
+
'json',
|
|
153
|
+
'markdown',
|
|
154
|
+
'python',
|
|
155
|
+
'go',
|
|
156
|
+
'rust',
|
|
157
|
+
'java',
|
|
158
|
+
'cpp',
|
|
159
|
+
'sql',
|
|
160
|
+
'xml',
|
|
161
|
+
'yaml',
|
|
162
|
+
'php'
|
|
163
|
+
];
|
|
164
|
+
return supported.includes(language);
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Get display name for a language
|
|
168
|
+
*/
|
|
169
|
+
export function getLanguageDisplayName(language) {
|
|
170
|
+
const displayNames = {
|
|
171
|
+
javascript: 'JavaScript',
|
|
172
|
+
typescript: 'TypeScript',
|
|
173
|
+
html: 'HTML',
|
|
174
|
+
css: 'CSS',
|
|
175
|
+
json: 'JSON',
|
|
176
|
+
xml: 'XML',
|
|
177
|
+
yaml: 'YAML',
|
|
178
|
+
markdown: 'Markdown',
|
|
179
|
+
python: 'Python',
|
|
180
|
+
go: 'Go',
|
|
181
|
+
rust: 'Rust',
|
|
182
|
+
java: 'Java',
|
|
183
|
+
kotlin: 'Kotlin',
|
|
184
|
+
scala: 'Scala',
|
|
185
|
+
cpp: 'C++',
|
|
186
|
+
csharp: 'C#',
|
|
187
|
+
ruby: 'Ruby',
|
|
188
|
+
php: 'PHP',
|
|
189
|
+
swift: 'Swift',
|
|
190
|
+
sql: 'SQL',
|
|
191
|
+
shell: 'Shell',
|
|
192
|
+
powershell: 'PowerShell',
|
|
193
|
+
dockerfile: 'Dockerfile',
|
|
194
|
+
makefile: 'Makefile',
|
|
195
|
+
svelte: 'Svelte',
|
|
196
|
+
vue: 'Vue',
|
|
197
|
+
plaintext: 'Plain Text'
|
|
198
|
+
};
|
|
199
|
+
return displayNames[language] ?? language.charAt(0).toUpperCase() + language.slice(1);
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Get icon name for a language (for use with icon components)
|
|
203
|
+
*/
|
|
204
|
+
export function getLanguageIcon(language) {
|
|
205
|
+
// Returns icon identifiers that can be mapped to actual icons
|
|
206
|
+
const iconMap = {
|
|
207
|
+
javascript: 'file-js',
|
|
208
|
+
typescript: 'file-ts',
|
|
209
|
+
html: 'file-html',
|
|
210
|
+
css: 'file-css',
|
|
211
|
+
json: 'file-json',
|
|
212
|
+
markdown: 'file-md',
|
|
213
|
+
python: 'file-python',
|
|
214
|
+
go: 'file-go',
|
|
215
|
+
rust: 'file-rust',
|
|
216
|
+
java: 'file-java',
|
|
217
|
+
cpp: 'file-cpp',
|
|
218
|
+
svelte: 'file-svelte',
|
|
219
|
+
vue: 'file-vue'
|
|
220
|
+
};
|
|
221
|
+
return iconMap[language] ?? 'file';
|
|
222
|
+
}
|