@decido/shell-vscode-core 1.0.0
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/.turbo/turbo-build.log +13 -0
- package/dist/appState.d.ts +23 -0
- package/dist/appState.d.ts.map +1 -0
- package/dist/appState.js +138 -0
- package/dist/core/AIService.d.ts +33 -0
- package/dist/core/AIService.d.ts.map +1 -0
- package/dist/core/AIService.js +73 -0
- package/dist/core/ApiService.d.ts +34 -0
- package/dist/core/ApiService.d.ts.map +1 -0
- package/dist/core/ApiService.js +32 -0
- package/dist/core/AuthService.d.ts +31 -0
- package/dist/core/AuthService.d.ts.map +1 -0
- package/dist/core/AuthService.js +56 -0
- package/dist/core/BaseService.d.ts +29 -0
- package/dist/core/BaseService.d.ts.map +1 -0
- package/dist/core/BaseService.js +33 -0
- package/dist/core/CalendarService.d.ts +15 -0
- package/dist/core/CalendarService.d.ts.map +1 -0
- package/dist/core/CalendarService.js +32 -0
- package/dist/core/CommandService.d.ts +25 -0
- package/dist/core/CommandService.d.ts.map +1 -0
- package/dist/core/CommandService.js +52 -0
- package/dist/core/DebugPanelService.d.ts +12 -0
- package/dist/core/DebugPanelService.d.ts.map +1 -0
- package/dist/core/DebugPanelService.js +29 -0
- package/dist/core/DebugService.d.ts +57 -0
- package/dist/core/DebugService.d.ts.map +1 -0
- package/dist/core/DebugService.js +134 -0
- package/dist/core/EventBus.d.ts +32 -0
- package/dist/core/EventBus.d.ts.map +1 -0
- package/dist/core/EventBus.js +51 -0
- package/dist/core/EventHandler.d.ts +3 -0
- package/dist/core/EventHandler.d.ts.map +1 -0
- package/dist/core/EventHandler.js +82 -0
- package/dist/core/GamificationService.d.ts +19 -0
- package/dist/core/GamificationService.d.ts.map +1 -0
- package/dist/core/GamificationService.js +102 -0
- package/dist/core/HookService.d.ts +34 -0
- package/dist/core/HookService.d.ts.map +1 -0
- package/dist/core/HookService.js +64 -0
- package/dist/core/LayoutService.d.ts +61 -0
- package/dist/core/LayoutService.d.ts.map +1 -0
- package/dist/core/LayoutService.js +223 -0
- package/dist/core/ModalService.d.ts +21 -0
- package/dist/core/ModalService.d.ts.map +1 -0
- package/dist/core/ModalService.js +71 -0
- package/dist/core/NotificationService.d.ts +7 -0
- package/dist/core/NotificationService.d.ts.map +1 -0
- package/dist/core/NotificationService.js +42 -0
- package/dist/core/RouterService.d.ts +13 -0
- package/dist/core/RouterService.d.ts.map +1 -0
- package/dist/core/RouterService.js +54 -0
- package/dist/core/ServiceContainer.d.ts +18 -0
- package/dist/core/ServiceContainer.d.ts.map +1 -0
- package/dist/core/ServiceContainer.js +27 -0
- package/dist/core/ShortcutService.d.ts +17 -0
- package/dist/core/ShortcutService.d.ts.map +1 -0
- package/dist/core/ShortcutService.js +37 -0
- package/dist/core/StorageService.d.ts +36 -0
- package/dist/core/StorageService.d.ts.map +1 -0
- package/dist/core/StorageService.js +101 -0
- package/dist/core/ThemeService.d.ts +12 -0
- package/dist/core/ThemeService.d.ts.map +1 -0
- package/dist/core/ThemeService.js +60 -0
- package/dist/core/WebSocketService.d.ts +16 -0
- package/dist/core/WebSocketService.d.ts.map +1 -0
- package/dist/core/WebSocketService.js +22 -0
- package/dist/core/api.d.ts +70 -0
- package/dist/core/api.d.ts.map +1 -0
- package/dist/core/api.js +1 -0
- package/dist/core/app/ModuleManager copy.d.ts +23 -0
- package/dist/core/app/ModuleManager copy.js +52 -0
- package/dist/core/app/ModuleManager.d.ts +60 -0
- package/dist/core/app/ModuleManager.d.ts.map +1 -0
- package/dist/core/app/ModuleManager.js +217 -0
- package/dist/core/app/apiFactory.d.ts +4 -0
- package/dist/core/app/apiFactory.d.ts.map +1 -0
- package/dist/core/app/apiFactory.js +120 -0
- package/dist/core/app/commandManager.d.ts +3 -0
- package/dist/core/app/commandManager.d.ts.map +1 -0
- package/dist/core/app/commandManager.js +195 -0
- package/dist/core/app/moduleLoader.d.ts +11 -0
- package/dist/core/app/moduleLoader.d.ts.map +1 -0
- package/dist/core/app/moduleLoader.js +30 -0
- package/dist/core/app/routeManager.d.ts +2 -0
- package/dist/core/app/routeManager.d.ts.map +1 -0
- package/dist/core/app/routeManager.js +7 -0
- package/dist/core/index.d.ts +16 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +15 -0
- package/dist/core/layout/dragDropManager.d.ts +8 -0
- package/dist/core/layout/dragDropManager.d.ts.map +1 -0
- package/dist/core/layout/dragDropManager.js +8 -0
- package/dist/core/layout/paneManager.d.ts +7 -0
- package/dist/core/layout/paneManager.d.ts.map +1 -0
- package/dist/core/layout/paneManager.js +7 -0
- package/dist/core/layout/renderer.d.ts +8 -0
- package/dist/core/layout/renderer.d.ts.map +1 -0
- package/dist/core/layout/renderer.js +8 -0
- package/dist/core/layout/resizeManager.d.ts +5 -0
- package/dist/core/layout/resizeManager.d.ts.map +1 -0
- package/dist/core/layout/resizeManager.js +5 -0
- package/dist/core/signals.d.ts +20 -0
- package/dist/core/signals.d.ts.map +1 -0
- package/dist/core/signals.js +66 -0
- package/dist/core/uiState.d.ts +9 -0
- package/dist/core/uiState.d.ts.map +1 -0
- package/dist/core/uiState.js +11 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/lib/local-db.d.ts +43 -0
- package/dist/lib/local-db.d.ts.map +1 -0
- package/dist/lib/local-db.js +23 -0
- package/dist/lib/sync-service.d.ts +7 -0
- package/dist/lib/sync-service.d.ts.map +1 -0
- package/dist/lib/sync-service.js +41 -0
- package/dist/platform/ILayoutService.d.ts +63 -0
- package/dist/platform/ILayoutService.d.ts.map +1 -0
- package/dist/platform/ILayoutService.js +1 -0
- package/dist/platform/IRenderer.d.ts +16 -0
- package/dist/platform/IRenderer.d.ts.map +1 -0
- package/dist/platform/IRenderer.js +1 -0
- package/dist/platform/ServiceRegistry.d.ts +43 -0
- package/dist/platform/ServiceRegistry.d.ts.map +1 -0
- package/dist/platform/ServiceRegistry.js +2 -0
- package/dist/platform/extensionPoints.d.ts +70 -0
- package/dist/platform/extensionPoints.d.ts.map +1 -0
- package/dist/platform/extensionPoints.js +22 -0
- package/dist/platform/index.d.ts +5 -0
- package/dist/platform/index.d.ts.map +1 -0
- package/dist/platform/index.js +4 -0
- package/dist/stores/editorStore.d.ts +5 -0
- package/dist/stores/editorStore.d.ts.map +1 -0
- package/dist/stores/editorStore.js +4 -0
- package/dist/stores/gamificationStore.d.ts +3 -0
- package/dist/stores/gamificationStore.d.ts.map +1 -0
- package/dist/stores/gamificationStore.js +2 -0
- package/dist/stores/historyStore.d.ts +12 -0
- package/dist/stores/historyStore.d.ts.map +1 -0
- package/dist/stores/historyStore.js +6 -0
- package/dist/stores/workspaceStore.d.ts +13 -0
- package/dist/stores/workspaceStore.d.ts.map +1 -0
- package/dist/stores/workspaceStore.js +6 -0
- package/dist/types/app.d.ts +31 -0
- package/dist/types/app.d.ts.map +1 -0
- package/dist/types/app.js +1 -0
- package/dist/types/debug.d.ts +68 -0
- package/dist/types/debug.d.ts.map +1 -0
- package/dist/types/debug.js +1 -0
- package/dist/types/entities.d.ts +42 -0
- package/dist/types/entities.js +2 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/modules.d.ts +66 -0
- package/dist/types/modules.js +2 -0
- package/dist/types/platform.d.ts +95 -0
- package/dist/types/platform.d.ts.map +1 -0
- package/dist/types/platform.js +2 -0
- package/dist/ui/Palette.d.ts +38 -0
- package/dist/ui/Palette.d.ts.map +1 -0
- package/dist/ui/Palette.js +144 -0
- package/dist/ui/debug-panel/dragAndResize.d.ts +6 -0
- package/dist/ui/debug-panel/dragAndResize.d.ts.map +1 -0
- package/dist/ui/debug-panel/dragAndResize.js +140 -0
- package/dist/ui/debug-panel/eventBinder.d.ts +5 -0
- package/dist/ui/debug-panel/eventBinder.d.ts.map +1 -0
- package/dist/ui/debug-panel/eventBinder.js +120 -0
- package/dist/ui/debug-panel/layoutManager.d.ts +16 -0
- package/dist/ui/debug-panel/layoutManager.d.ts.map +1 -0
- package/dist/ui/debug-panel/layoutManager.js +73 -0
- package/dist/ui/debug-panel/main.d.ts +12 -0
- package/dist/ui/debug-panel/main.d.ts.map +1 -0
- package/dist/ui/debug-panel/main.js +42 -0
- package/dist/ui/debug-panel/panelManager.d.ts +17 -0
- package/dist/ui/debug-panel/panelManager.d.ts.map +1 -0
- package/dist/ui/debug-panel/panelManager.js +123 -0
- package/dist/ui/debug-panel/renderer.d.ts +4 -0
- package/dist/ui/debug-panel/renderer.d.ts.map +1 -0
- package/dist/ui/debug-panel/renderer.js +181 -0
- package/dist/ui/debug-panel/services.d.ts +4 -0
- package/dist/ui/debug-panel/services.d.ts.map +1 -0
- package/dist/ui/debug-panel/services.js +134 -0
- package/dist/ui/debug-panel/settings.d.ts +5 -0
- package/dist/ui/debug-panel/settings.d.ts.map +1 -0
- package/dist/ui/debug-panel/settings.js +35 -0
- package/dist/ui/debug-panel/state.d.ts +128 -0
- package/dist/ui/debug-panel/state.d.ts.map +1 -0
- package/dist/ui/debug-panel/state.js +42 -0
- package/dist/ui/debug-panel/stateEditor.d.ts +9 -0
- package/dist/ui/debug-panel/stateEditor.d.ts.map +1 -0
- package/dist/ui/debug-panel/stateEditor.js +158 -0
- package/dist/ui/debug-panel/types.d.ts +68 -0
- package/dist/ui/debug-panel/types.d.ts.map +1 -0
- package/dist/ui/debug-panel/types.js +1 -0
- package/dist/ui/debug-panel/ui.d.ts +10 -0
- package/dist/ui/debug-panel/ui.d.ts.map +1 -0
- package/dist/ui/debug-panel/ui.js +199 -0
- package/dist/ui/debug-panel/utils.d.ts +16 -0
- package/dist/ui/debug-panel/utils.d.ts.map +1 -0
- package/dist/ui/debug-panel/utils.js +104 -0
- package/dist/utils.d.ts +22 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +58 -0
- package/package.json +37 -0
- package/src/appState.ts +167 -0
- package/src/core/AIService.ts +109 -0
- package/src/core/ApiService.ts +40 -0
- package/src/core/AuthService.ts +85 -0
- package/src/core/BaseService.ts +47 -0
- package/src/core/CalendarService.ts +44 -0
- package/src/core/CommandService.ts +69 -0
- package/src/core/DebugPanelService.ts +38 -0
- package/src/core/DebugService.ts +181 -0
- package/src/core/EventBus.ts +60 -0
- package/src/core/EventHandler.ts +97 -0
- package/src/core/GamificationService.ts +120 -0
- package/src/core/HookService.ts +86 -0
- package/src/core/ModalService.ts +97 -0
- package/src/core/NotificationService.ts +53 -0
- package/src/core/RouterService.ts +68 -0
- package/src/core/ServiceContainer.ts +31 -0
- package/src/core/ShortcutService.ts +49 -0
- package/src/core/StorageService.ts +123 -0
- package/src/core/ThemeService.ts +71 -0
- package/src/core/WebSocketService.ts +32 -0
- package/src/core/api.ts +78 -0
- package/src/core/app/ModuleManager.ts +273 -0
- package/src/core/app/apiFactory.ts +130 -0
- package/src/core/app/commandManager.ts +218 -0
- package/src/core/app/moduleLoader.ts +39 -0
- package/src/core/app/routeManager.ts +8 -0
- package/src/core/index.ts +15 -0
- package/src/core/signals.ts +84 -0
- package/src/core/uiState.ts +13 -0
- package/src/index.ts +18 -0
- package/src/lib/local-db.ts +65 -0
- package/src/lib/sync-service.ts +44 -0
- package/src/platform/ILayoutService.ts +77 -0
- package/src/platform/IRenderer.ts +16 -0
- package/src/platform/ServiceRegistry.ts +53 -0
- package/src/platform/extensionPoints.ts +202 -0
- package/src/platform/index.ts +4 -0
- package/src/stores/editorStore.ts +6 -0
- package/src/stores/gamificationStore.ts +4 -0
- package/src/stores/historyStore.ts +14 -0
- package/src/stores/workspaceStore.ts +8 -0
- package/src/types/app.ts +36 -0
- package/src/types/debug.ts +69 -0
- package/src/types/index.ts +3 -0
- package/src/types/platform.ts +112 -0
- package/src/ui/Palette.ts +161 -0
- package/src/utils.ts +63 -0
- package/tsconfig.json +23 -0
package/src/types/app.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// src/types/app.ts
|
|
2
|
+
import { IPlatformAPI } from "../core/api";
|
|
3
|
+
|
|
4
|
+
export type RouteAccess = 'public' | 'guestOnly' | 'protected';
|
|
5
|
+
|
|
6
|
+
export interface RouteDefinition {
|
|
7
|
+
path: string;
|
|
8
|
+
componentTag: string;
|
|
9
|
+
auth: RouteAccess;
|
|
10
|
+
roles?: string[];
|
|
11
|
+
title?: string;
|
|
12
|
+
isFullscreen?: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface RegisteredComponent {
|
|
16
|
+
name: string;
|
|
17
|
+
icon: string;
|
|
18
|
+
slot: 'sidebar-nav';
|
|
19
|
+
order?: number;
|
|
20
|
+
render: (container: HTMLElement, appContext: AppContext) => void;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type AppContext = IPlatformAPI;
|
|
24
|
+
export type ViewId = 'dashboard' | 'kanban' | 'goal-architect' | 'projects' | 'calendar' | 'journal' | 'resilience' | 'settings' | 'progress' | 'blueprint' | 'marketplace' | 'upload-module' | 'user-profile' | 'help' | 'about' | 'notifications';
|
|
25
|
+
|
|
26
|
+
declare const HTML_RESULT = 1;
|
|
27
|
+
declare const SVG_RESULT = 2;
|
|
28
|
+
declare const MATHML_RESULT = 3;
|
|
29
|
+
type ResultType = typeof HTML_RESULT | typeof SVG_RESULT | typeof MATHML_RESULT;
|
|
30
|
+
|
|
31
|
+
export type UncompiledTemplateResult<T extends ResultType = ResultType> = {
|
|
32
|
+
['_$litType$']: T;
|
|
33
|
+
strings: TemplateStringsArray;
|
|
34
|
+
values: unknown[];
|
|
35
|
+
};
|
|
36
|
+
export type TemplateResult<T extends ResultType = ResultType> = UncompiledTemplateResult<T>;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// Types
|
|
2
|
+
export type LogLevel = 'log' | 'info' | 'warn' | 'error';
|
|
3
|
+
export type DockPosition = 'left' | 'bottom' | 'right' | 'floating';
|
|
4
|
+
export type TabId = 'state' | 'history' | 'events' | 'console' | 'network' | 'performance';
|
|
5
|
+
export type PanelLayout = 'single' | 'split-horizontal' | 'split-vertical' | 'grid';
|
|
6
|
+
|
|
7
|
+
export interface ConsoleLog {
|
|
8
|
+
id: string;
|
|
9
|
+
type: LogLevel;
|
|
10
|
+
timestamp: Date;
|
|
11
|
+
message: any[];
|
|
12
|
+
stack?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface NetworkLog {
|
|
16
|
+
id: string;
|
|
17
|
+
url: string;
|
|
18
|
+
method: string;
|
|
19
|
+
status: number;
|
|
20
|
+
timestamp: Date;
|
|
21
|
+
duration: number;
|
|
22
|
+
size?: number;
|
|
23
|
+
error?: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface PerformanceLog {
|
|
27
|
+
id: string;
|
|
28
|
+
name: string;
|
|
29
|
+
duration: number;
|
|
30
|
+
timestamp: Date;
|
|
31
|
+
type: 'navigation' | 'resource' | 'measure' | 'mark';
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface EventLog {
|
|
35
|
+
id: string;
|
|
36
|
+
name: string;
|
|
37
|
+
data: any;
|
|
38
|
+
timestamp: Date;
|
|
39
|
+
direction: 'emitted' | 'received';
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface PanelInstance {
|
|
43
|
+
id: string;
|
|
44
|
+
activeTab: TabId;
|
|
45
|
+
position: { x: number; y: number };
|
|
46
|
+
size: { width: number; height: number };
|
|
47
|
+
isMinimized: boolean;
|
|
48
|
+
zIndex: number;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface DebugSettings {
|
|
52
|
+
maxLogs: number;
|
|
53
|
+
autoScroll: boolean;
|
|
54
|
+
showTimestamps: boolean;
|
|
55
|
+
position: DockPosition;
|
|
56
|
+
isMinimized: boolean;
|
|
57
|
+
layout: PanelLayout;
|
|
58
|
+
panels: PanelInstance[];
|
|
59
|
+
enableStateEditing: boolean;
|
|
60
|
+
autoSaveState: boolean;
|
|
61
|
+
theme: 'dark' | 'light';
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface StateEditContext {
|
|
65
|
+
path: string[];
|
|
66
|
+
originalValue: any;
|
|
67
|
+
isEditing: boolean;
|
|
68
|
+
element?: HTMLElement;
|
|
69
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// --- Tipos de la UI del Workbench ---
|
|
2
|
+
|
|
3
|
+
import { IPlatformAPI } from "../core/api";
|
|
4
|
+
import { TemplateResult } from "./app";
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
export interface Pane {
|
|
8
|
+
id: string;
|
|
9
|
+
tabs: Tab[];
|
|
10
|
+
activeTabId: string | null;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface Tab {
|
|
14
|
+
id: string;
|
|
15
|
+
title: string;
|
|
16
|
+
componentTag: string;
|
|
17
|
+
icon?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// --- Tipos de Puntos de Contribución de la UI ---
|
|
21
|
+
|
|
22
|
+
export interface ActivityBarItem {
|
|
23
|
+
id: string;
|
|
24
|
+
icon: string;
|
|
25
|
+
title: string;
|
|
26
|
+
viewId: string; // ID de la vista que se mostrará en el sidebar
|
|
27
|
+
order?: number;
|
|
28
|
+
command?: string; // Comando opcional a ejecutar en lugar del default
|
|
29
|
+
commandArg?: any;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface SidebarView {
|
|
33
|
+
id: string;
|
|
34
|
+
title: string;
|
|
35
|
+
render?: (container: HTMLElement, api: IPlatformAPI) => void;
|
|
36
|
+
component?: React.ComponentType<any>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface SidebarRightView {
|
|
40
|
+
id: string;
|
|
41
|
+
title: string;
|
|
42
|
+
render?: (container: HTMLElement, api: IPlatformAPI) => void;
|
|
43
|
+
component?: React.ComponentType<any>;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface MainView { // Opcional, si quieres registrar vistas principales
|
|
47
|
+
id: string;
|
|
48
|
+
render?: (container: HTMLElement, api: IPlatformAPI) => void;
|
|
49
|
+
componentTag: string;
|
|
50
|
+
component?: React.ComponentType<any>;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface PanelView {
|
|
54
|
+
id: string;
|
|
55
|
+
title: string;
|
|
56
|
+
render?: (container: HTMLElement, api: IPlatformAPI) => void;
|
|
57
|
+
component?: React.ComponentType<any>;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface StatusBarItem {
|
|
61
|
+
id: string;
|
|
62
|
+
render: (container: HTMLElement, api: IPlatformAPI) => void;
|
|
63
|
+
alignment: 'left' | 'right';
|
|
64
|
+
order?: number;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface TopBarItem {
|
|
68
|
+
id: string;
|
|
69
|
+
order?: number;
|
|
70
|
+
// Para botones simples
|
|
71
|
+
icon?: string;
|
|
72
|
+
title?: string;
|
|
73
|
+
commandId?: string;
|
|
74
|
+
commandArg?: any;
|
|
75
|
+
// Para componentes complejos
|
|
76
|
+
render?: (api: IPlatformAPI) => TemplateResult;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export interface CalendarEvent {
|
|
80
|
+
id: number;
|
|
81
|
+
title: string;
|
|
82
|
+
start: string; // Formato ISO: "2025-07-25T10:00:00"
|
|
83
|
+
end: string; // Formato ISO: "2025-07-25T11:30:00"
|
|
84
|
+
allDay: boolean;
|
|
85
|
+
color: string; // Color del evento, puede heredar de un proyecto
|
|
86
|
+
source?: {
|
|
87
|
+
type: 'project' | 'task' | 'manual';
|
|
88
|
+
id?: number;
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export interface GamificationAchievement {
|
|
93
|
+
id: string;
|
|
94
|
+
title: string;
|
|
95
|
+
description: string;
|
|
96
|
+
icon: string;
|
|
97
|
+
conditionType: 'tasks_completed' | 'goals_created' | 'journal_streak' | 'level';
|
|
98
|
+
conditionValue: number;
|
|
99
|
+
reward_xp: number;
|
|
100
|
+
isCustom?: boolean;
|
|
101
|
+
isSuggested?: boolean;
|
|
102
|
+
unlocked?: boolean;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export interface GamificationState {
|
|
106
|
+
xp: number;
|
|
107
|
+
level: number;
|
|
108
|
+
streak: number;
|
|
109
|
+
lastJournalDate: string | null;
|
|
110
|
+
unlockedAchievements: string[];
|
|
111
|
+
achievements: GamificationAchievement[];
|
|
112
|
+
}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
// /src/ui/Palette.ts (VERSIÓN COMPLETA Y FUNCIONAL)
|
|
2
|
+
|
|
3
|
+
import { IPlatformAPI } from '../core/api.js';
|
|
4
|
+
import { Command } from '../core/CommandService.js';
|
|
5
|
+
import { html } from '../utils.js';
|
|
6
|
+
|
|
7
|
+
export class Palette {
|
|
8
|
+
private api: IPlatformAPI;
|
|
9
|
+
private dom: { [key: string]: HTMLElement | null } = {};
|
|
10
|
+
private allCommands: Command[] = [];
|
|
11
|
+
private filteredCommands: Command[] = [];
|
|
12
|
+
private selectedIndex = 0;
|
|
13
|
+
|
|
14
|
+
constructor(api: IPlatformAPI) {
|
|
15
|
+
this.api = api;
|
|
16
|
+
this.init();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Alterna la visibilidad de la paleta.
|
|
21
|
+
*/
|
|
22
|
+
public toggle() {
|
|
23
|
+
const isHidden = this.dom.modal?.classList.contains('hidden');
|
|
24
|
+
if (isHidden) this.show();
|
|
25
|
+
else this.hide();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Muestra la paleta, carga los comandos y enfoca el input.
|
|
30
|
+
*/
|
|
31
|
+
private show() {
|
|
32
|
+
this.allCommands = this.api.commands.getAll();
|
|
33
|
+
this.filteredCommands = this.allCommands;
|
|
34
|
+
this.selectedIndex = 0;
|
|
35
|
+
this.renderResults();
|
|
36
|
+
this.dom.modal?.classList.remove('hidden');
|
|
37
|
+
(this.dom.input as HTMLInputElement)?.focus();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Oculta la paleta y resetea el input.
|
|
42
|
+
*/
|
|
43
|
+
private hide() {
|
|
44
|
+
const input = this.dom.input as HTMLInputElement;
|
|
45
|
+
if (input) input.value = '';
|
|
46
|
+
this.dom.modal?.classList.add('hidden');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Crea el HTML de la paleta y lo añade al DOM.
|
|
51
|
+
*/
|
|
52
|
+
private init() {
|
|
53
|
+
const paletteEl = document.createElement('div');
|
|
54
|
+
paletteEl.id = 'command-palette-modal';
|
|
55
|
+
paletteEl.className = 'fixed inset-0 bg-darker/80 backdrop-blur-sm flex items-start justify-center hidden pt-24';
|
|
56
|
+
paletteEl.style.zIndex = '10000';
|
|
57
|
+
paletteEl.style.position = 'fixed';
|
|
58
|
+
paletteEl.innerHTML = html`
|
|
59
|
+
<div class="glass-premium p-4 rounded-2xl w-full max-w-2xl animate-scale-in flex flex-col max-h-[70vh]">
|
|
60
|
+
<input id="palette-search-input" type="text" class="form-input-premium text-lg mb-2" placeholder="Escribe un comando...">
|
|
61
|
+
<div id="palette-results-list" class="overflow-y-auto"></div>
|
|
62
|
+
</div>
|
|
63
|
+
`;
|
|
64
|
+
document.body.appendChild(paletteEl);
|
|
65
|
+
|
|
66
|
+
this.dom.modal = paletteEl;
|
|
67
|
+
this.dom.input = paletteEl.querySelector('#palette-search-input');
|
|
68
|
+
this.dom.results = paletteEl.querySelector('#palette-results-list');
|
|
69
|
+
|
|
70
|
+
this.attachEventListeners();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Adjunta todos los listeners necesarios para la interactividad de la paleta.
|
|
75
|
+
*/
|
|
76
|
+
private attachEventListeners() {
|
|
77
|
+
// Cerrar al hacer clic fuera del modal
|
|
78
|
+
this.dom.modal?.addEventListener('click', (e) => {
|
|
79
|
+
if (e.target === this.dom.modal) this.hide();
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
// Filtrar resultados mientras el usuario escribe
|
|
83
|
+
this.dom.input?.addEventListener('input', () => {
|
|
84
|
+
const searchTerm = (this.dom.input as HTMLInputElement).value.toLowerCase();
|
|
85
|
+
this.filteredCommands = this.allCommands.filter(cmd =>
|
|
86
|
+
cmd.title.toLowerCase().includes(searchTerm) ||
|
|
87
|
+
cmd.category?.toLowerCase().includes(searchTerm)
|
|
88
|
+
);
|
|
89
|
+
this.selectedIndex = 0;
|
|
90
|
+
this.renderResults();
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
// Navegación por teclado y ejecución
|
|
94
|
+
this.dom.input?.addEventListener('keydown', (e: KeyboardEvent) => {
|
|
95
|
+
switch (e.key) {
|
|
96
|
+
case 'ArrowDown':
|
|
97
|
+
e.preventDefault();
|
|
98
|
+
this.selectedIndex = Math.min(this.selectedIndex + 1, this.filteredCommands.length - 1);
|
|
99
|
+
this.renderResults();
|
|
100
|
+
break;
|
|
101
|
+
case 'ArrowUp':
|
|
102
|
+
e.preventDefault();
|
|
103
|
+
this.selectedIndex = Math.max(this.selectedIndex - 1, 0);
|
|
104
|
+
this.renderResults();
|
|
105
|
+
break;
|
|
106
|
+
case 'Enter':
|
|
107
|
+
e.preventDefault();
|
|
108
|
+
this.executeSelected();
|
|
109
|
+
break;
|
|
110
|
+
case 'Escape':
|
|
111
|
+
this.hide();
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
// Ejecución por clic
|
|
117
|
+
this.dom.results?.addEventListener('click', (e: MouseEvent) => {
|
|
118
|
+
const item = (e.target as HTMLElement).closest('.command-palette-item') as HTMLElement;
|
|
119
|
+
if (item?.dataset.commandId) {
|
|
120
|
+
this.api.commands.execute(item.dataset.commandId);
|
|
121
|
+
this.hide();
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Dibuja la lista de comandos filtrados en el DOM.
|
|
128
|
+
*/
|
|
129
|
+
private renderResults() {
|
|
130
|
+
if (!this.dom.results) return;
|
|
131
|
+
|
|
132
|
+
if (this.filteredCommands.length === 0) {
|
|
133
|
+
this.dom.results.innerHTML = `<div class="p-4 text-center text-muted-foreground">No se encontraron comandos.</div>`;
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
this.dom.results.innerHTML = this.filteredCommands.map((cmd, index) => html`
|
|
138
|
+
<div class="command-palette-item ${index === this.selectedIndex ? 'selected' : ''}" data-command-id="${cmd.id}">
|
|
139
|
+
<div class="flex items-center gap-3">
|
|
140
|
+
<i class="${cmd.icon || 'fas fa-cogs'}"></i>
|
|
141
|
+
<span>${cmd.title}</span>
|
|
142
|
+
</div>
|
|
143
|
+
${cmd.category ? `<span class="category">${cmd.category}</span>` : ''}
|
|
144
|
+
</div>
|
|
145
|
+
`).join('');
|
|
146
|
+
|
|
147
|
+
// Asegurarse de que el elemento seleccionado esté visible
|
|
148
|
+
this.dom.results.querySelector('.selected')?.scrollIntoView({ block: 'nearest' });
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Ejecuta el comando actualmente seleccionado en la lista.
|
|
153
|
+
*/
|
|
154
|
+
private executeSelected() {
|
|
155
|
+
const command = this.filteredCommands[this.selectedIndex];
|
|
156
|
+
if (command) {
|
|
157
|
+
this.api.commands.execute(command.id);
|
|
158
|
+
this.hide();
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
package/src/utils.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// js/utils.js
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Formatea una cadena de fecha (ej: "2025-06-20") a un formato legible.
|
|
5
|
+
* @param {string} dateString - La fecha en formato YYYY-MM-DD.
|
|
6
|
+
* @returns {string} La fecha formateada (ej: "20 jun. 2025").
|
|
7
|
+
*/
|
|
8
|
+
export function formatDate(dateString?: string): string {
|
|
9
|
+
if (!dateString) return 'Sin fecha';
|
|
10
|
+
const date = new Date(dateString);
|
|
11
|
+
const userTimezoneOffset = date.getTimezoneOffset() * 60000;
|
|
12
|
+
return new Date(date.getTime() + userTimezoneOffset).toLocaleDateString('es-ES', {
|
|
13
|
+
year: 'numeric',
|
|
14
|
+
month: 'short',
|
|
15
|
+
day: 'numeric'
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Función ficticia (dummy) para activar el resaltado de sintaxis de HTML
|
|
21
|
+
* en las plantillas de texto de VS Code. Simplemente reconstruye y devuelve
|
|
22
|
+
* la cadena de texto original.
|
|
23
|
+
* @param {TemplateStringsArray} strings
|
|
24
|
+
* @param {...any} values
|
|
25
|
+
* @returns {string}
|
|
26
|
+
*/
|
|
27
|
+
export function html(strings: any, ...values: any[]) {
|
|
28
|
+
// String.raw es una forma segura y nativa de reconstruir la plantilla
|
|
29
|
+
return String.raw({ raw: strings }, ...values);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Hace que un elemento del DOM sea arrastrable usando un manejador.
|
|
34
|
+
* @param {HTMLElement} _element - El elemento a mover.
|
|
35
|
+
* @param {HTMLElement} _handle - El elemento que activa el arrastre.
|
|
36
|
+
*/
|
|
37
|
+
export function makeDraggable(_element: any, _handle: any) {
|
|
38
|
+
// let pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0;
|
|
39
|
+
// handle.onmousedown = dragMouseDown;
|
|
40
|
+
|
|
41
|
+
// function dragMouseDown(e) {
|
|
42
|
+
// e.preventDefault();
|
|
43
|
+
// pos3 = e.clientX;
|
|
44
|
+
// pos4 = e.clientY;
|
|
45
|
+
// document.onmouseup = closeDragElement;
|
|
46
|
+
// document.onmousemove = elementDrag;
|
|
47
|
+
// }
|
|
48
|
+
|
|
49
|
+
// function elementDrag(e) {
|
|
50
|
+
// e.preventDefault();
|
|
51
|
+
// pos1 = pos3 - e.clientX;
|
|
52
|
+
// pos2 = pos4 - e.clientY;
|
|
53
|
+
// pos3 = e.clientX;
|
|
54
|
+
// pos4 = e.clientY;
|
|
55
|
+
// element.style.top = (element.offsetTop - pos2) + "px";
|
|
56
|
+
// element.style.left = (element.offsetLeft - pos1) + "px";
|
|
57
|
+
// }
|
|
58
|
+
|
|
59
|
+
// function closeDragElement() {
|
|
60
|
+
// document.onmouseup = null;
|
|
61
|
+
// document.onmousemove = null;
|
|
62
|
+
// }
|
|
63
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ESNext",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"outDir": "dist",
|
|
6
|
+
"rootDir": "src",
|
|
7
|
+
"strict": true,
|
|
8
|
+
"esModuleInterop": true,
|
|
9
|
+
"skipLibCheck": true,
|
|
10
|
+
"forceConsistentCasingInFileNames": true,
|
|
11
|
+
"declaration": true,
|
|
12
|
+
"declarationMap": true,
|
|
13
|
+
"moduleResolution": "node",
|
|
14
|
+
"jsx": "react-jsx"
|
|
15
|
+
},
|
|
16
|
+
"include": [
|
|
17
|
+
"src/**/*.ts"
|
|
18
|
+
],
|
|
19
|
+
"exclude": [
|
|
20
|
+
"node_modules",
|
|
21
|
+
"dist"
|
|
22
|
+
]
|
|
23
|
+
}
|