@decido/shell-vscode-core 1.0.0 → 4.0.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.
Files changed (207) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/README.md +31 -0
  3. package/package.json +2 -2
  4. package/dist/appState.d.ts +0 -23
  5. package/dist/appState.d.ts.map +0 -1
  6. package/dist/appState.js +0 -138
  7. package/dist/core/AIService.d.ts +0 -33
  8. package/dist/core/AIService.d.ts.map +0 -1
  9. package/dist/core/AIService.js +0 -73
  10. package/dist/core/ApiService.d.ts +0 -34
  11. package/dist/core/ApiService.d.ts.map +0 -1
  12. package/dist/core/ApiService.js +0 -32
  13. package/dist/core/AuthService.d.ts +0 -31
  14. package/dist/core/AuthService.d.ts.map +0 -1
  15. package/dist/core/AuthService.js +0 -56
  16. package/dist/core/BaseService.d.ts +0 -29
  17. package/dist/core/BaseService.d.ts.map +0 -1
  18. package/dist/core/BaseService.js +0 -33
  19. package/dist/core/CalendarService.d.ts +0 -15
  20. package/dist/core/CalendarService.d.ts.map +0 -1
  21. package/dist/core/CalendarService.js +0 -32
  22. package/dist/core/CommandService.d.ts +0 -25
  23. package/dist/core/CommandService.d.ts.map +0 -1
  24. package/dist/core/CommandService.js +0 -52
  25. package/dist/core/DebugPanelService.d.ts +0 -12
  26. package/dist/core/DebugPanelService.d.ts.map +0 -1
  27. package/dist/core/DebugPanelService.js +0 -29
  28. package/dist/core/DebugService.d.ts +0 -57
  29. package/dist/core/DebugService.d.ts.map +0 -1
  30. package/dist/core/DebugService.js +0 -134
  31. package/dist/core/EventBus.d.ts +0 -32
  32. package/dist/core/EventBus.d.ts.map +0 -1
  33. package/dist/core/EventBus.js +0 -51
  34. package/dist/core/EventHandler.d.ts +0 -3
  35. package/dist/core/EventHandler.d.ts.map +0 -1
  36. package/dist/core/EventHandler.js +0 -82
  37. package/dist/core/GamificationService.d.ts +0 -19
  38. package/dist/core/GamificationService.d.ts.map +0 -1
  39. package/dist/core/GamificationService.js +0 -102
  40. package/dist/core/HookService.d.ts +0 -34
  41. package/dist/core/HookService.d.ts.map +0 -1
  42. package/dist/core/HookService.js +0 -64
  43. package/dist/core/LayoutService.d.ts +0 -61
  44. package/dist/core/LayoutService.d.ts.map +0 -1
  45. package/dist/core/LayoutService.js +0 -223
  46. package/dist/core/ModalService.d.ts +0 -21
  47. package/dist/core/ModalService.d.ts.map +0 -1
  48. package/dist/core/ModalService.js +0 -71
  49. package/dist/core/NotificationService.d.ts +0 -7
  50. package/dist/core/NotificationService.d.ts.map +0 -1
  51. package/dist/core/NotificationService.js +0 -42
  52. package/dist/core/RouterService.d.ts +0 -13
  53. package/dist/core/RouterService.d.ts.map +0 -1
  54. package/dist/core/RouterService.js +0 -54
  55. package/dist/core/ServiceContainer.d.ts +0 -18
  56. package/dist/core/ServiceContainer.d.ts.map +0 -1
  57. package/dist/core/ServiceContainer.js +0 -27
  58. package/dist/core/ShortcutService.d.ts +0 -17
  59. package/dist/core/ShortcutService.d.ts.map +0 -1
  60. package/dist/core/ShortcutService.js +0 -37
  61. package/dist/core/StorageService.d.ts +0 -36
  62. package/dist/core/StorageService.d.ts.map +0 -1
  63. package/dist/core/StorageService.js +0 -101
  64. package/dist/core/ThemeService.d.ts +0 -12
  65. package/dist/core/ThemeService.d.ts.map +0 -1
  66. package/dist/core/ThemeService.js +0 -60
  67. package/dist/core/WebSocketService.d.ts +0 -16
  68. package/dist/core/WebSocketService.d.ts.map +0 -1
  69. package/dist/core/WebSocketService.js +0 -22
  70. package/dist/core/api.d.ts +0 -70
  71. package/dist/core/api.d.ts.map +0 -1
  72. package/dist/core/api.js +0 -1
  73. package/dist/core/app/ModuleManager copy.d.ts +0 -23
  74. package/dist/core/app/ModuleManager copy.js +0 -52
  75. package/dist/core/app/ModuleManager.d.ts +0 -60
  76. package/dist/core/app/ModuleManager.d.ts.map +0 -1
  77. package/dist/core/app/ModuleManager.js +0 -217
  78. package/dist/core/app/apiFactory.d.ts +0 -4
  79. package/dist/core/app/apiFactory.d.ts.map +0 -1
  80. package/dist/core/app/apiFactory.js +0 -120
  81. package/dist/core/app/commandManager.d.ts +0 -3
  82. package/dist/core/app/commandManager.d.ts.map +0 -1
  83. package/dist/core/app/commandManager.js +0 -195
  84. package/dist/core/app/moduleLoader.d.ts +0 -11
  85. package/dist/core/app/moduleLoader.d.ts.map +0 -1
  86. package/dist/core/app/moduleLoader.js +0 -30
  87. package/dist/core/app/routeManager.d.ts +0 -2
  88. package/dist/core/app/routeManager.d.ts.map +0 -1
  89. package/dist/core/app/routeManager.js +0 -7
  90. package/dist/core/index.d.ts +0 -16
  91. package/dist/core/index.d.ts.map +0 -1
  92. package/dist/core/index.js +0 -15
  93. package/dist/core/layout/dragDropManager.d.ts +0 -8
  94. package/dist/core/layout/dragDropManager.d.ts.map +0 -1
  95. package/dist/core/layout/dragDropManager.js +0 -8
  96. package/dist/core/layout/paneManager.d.ts +0 -7
  97. package/dist/core/layout/paneManager.d.ts.map +0 -1
  98. package/dist/core/layout/paneManager.js +0 -7
  99. package/dist/core/layout/renderer.d.ts +0 -8
  100. package/dist/core/layout/renderer.d.ts.map +0 -1
  101. package/dist/core/layout/renderer.js +0 -8
  102. package/dist/core/layout/resizeManager.d.ts +0 -5
  103. package/dist/core/layout/resizeManager.d.ts.map +0 -1
  104. package/dist/core/layout/resizeManager.js +0 -5
  105. package/dist/core/signals.d.ts +0 -20
  106. package/dist/core/signals.d.ts.map +0 -1
  107. package/dist/core/signals.js +0 -66
  108. package/dist/core/uiState.d.ts +0 -9
  109. package/dist/core/uiState.d.ts.map +0 -1
  110. package/dist/core/uiState.js +0 -11
  111. package/dist/index.d.ts +0 -17
  112. package/dist/index.d.ts.map +0 -1
  113. package/dist/index.js +0 -15
  114. package/dist/lib/local-db.d.ts +0 -43
  115. package/dist/lib/local-db.d.ts.map +0 -1
  116. package/dist/lib/local-db.js +0 -23
  117. package/dist/lib/sync-service.d.ts +0 -7
  118. package/dist/lib/sync-service.d.ts.map +0 -1
  119. package/dist/lib/sync-service.js +0 -41
  120. package/dist/platform/ILayoutService.d.ts +0 -63
  121. package/dist/platform/ILayoutService.d.ts.map +0 -1
  122. package/dist/platform/ILayoutService.js +0 -1
  123. package/dist/platform/IRenderer.d.ts +0 -16
  124. package/dist/platform/IRenderer.d.ts.map +0 -1
  125. package/dist/platform/IRenderer.js +0 -1
  126. package/dist/platform/ServiceRegistry.d.ts +0 -43
  127. package/dist/platform/ServiceRegistry.d.ts.map +0 -1
  128. package/dist/platform/ServiceRegistry.js +0 -2
  129. package/dist/platform/extensionPoints.d.ts +0 -70
  130. package/dist/platform/extensionPoints.d.ts.map +0 -1
  131. package/dist/platform/extensionPoints.js +0 -22
  132. package/dist/platform/index.d.ts +0 -5
  133. package/dist/platform/index.d.ts.map +0 -1
  134. package/dist/platform/index.js +0 -4
  135. package/dist/stores/editorStore.d.ts +0 -5
  136. package/dist/stores/editorStore.d.ts.map +0 -1
  137. package/dist/stores/editorStore.js +0 -4
  138. package/dist/stores/gamificationStore.d.ts +0 -3
  139. package/dist/stores/gamificationStore.d.ts.map +0 -1
  140. package/dist/stores/gamificationStore.js +0 -2
  141. package/dist/stores/historyStore.d.ts +0 -12
  142. package/dist/stores/historyStore.d.ts.map +0 -1
  143. package/dist/stores/historyStore.js +0 -6
  144. package/dist/stores/workspaceStore.d.ts +0 -13
  145. package/dist/stores/workspaceStore.d.ts.map +0 -1
  146. package/dist/stores/workspaceStore.js +0 -6
  147. package/dist/types/app.d.ts +0 -31
  148. package/dist/types/app.d.ts.map +0 -1
  149. package/dist/types/app.js +0 -1
  150. package/dist/types/debug.d.ts +0 -68
  151. package/dist/types/debug.d.ts.map +0 -1
  152. package/dist/types/debug.js +0 -1
  153. package/dist/types/entities.d.ts +0 -42
  154. package/dist/types/entities.js +0 -2
  155. package/dist/types/index.d.ts +0 -3
  156. package/dist/types/index.d.ts.map +0 -1
  157. package/dist/types/index.js +0 -3
  158. package/dist/types/modules.d.ts +0 -66
  159. package/dist/types/modules.js +0 -2
  160. package/dist/types/platform.d.ts +0 -95
  161. package/dist/types/platform.d.ts.map +0 -1
  162. package/dist/types/platform.js +0 -2
  163. package/dist/ui/Palette.d.ts +0 -38
  164. package/dist/ui/Palette.d.ts.map +0 -1
  165. package/dist/ui/Palette.js +0 -144
  166. package/dist/ui/debug-panel/dragAndResize.d.ts +0 -6
  167. package/dist/ui/debug-panel/dragAndResize.d.ts.map +0 -1
  168. package/dist/ui/debug-panel/dragAndResize.js +0 -140
  169. package/dist/ui/debug-panel/eventBinder.d.ts +0 -5
  170. package/dist/ui/debug-panel/eventBinder.d.ts.map +0 -1
  171. package/dist/ui/debug-panel/eventBinder.js +0 -120
  172. package/dist/ui/debug-panel/layoutManager.d.ts +0 -16
  173. package/dist/ui/debug-panel/layoutManager.d.ts.map +0 -1
  174. package/dist/ui/debug-panel/layoutManager.js +0 -73
  175. package/dist/ui/debug-panel/main.d.ts +0 -12
  176. package/dist/ui/debug-panel/main.d.ts.map +0 -1
  177. package/dist/ui/debug-panel/main.js +0 -42
  178. package/dist/ui/debug-panel/panelManager.d.ts +0 -17
  179. package/dist/ui/debug-panel/panelManager.d.ts.map +0 -1
  180. package/dist/ui/debug-panel/panelManager.js +0 -123
  181. package/dist/ui/debug-panel/renderer.d.ts +0 -4
  182. package/dist/ui/debug-panel/renderer.d.ts.map +0 -1
  183. package/dist/ui/debug-panel/renderer.js +0 -181
  184. package/dist/ui/debug-panel/services.d.ts +0 -4
  185. package/dist/ui/debug-panel/services.d.ts.map +0 -1
  186. package/dist/ui/debug-panel/services.js +0 -134
  187. package/dist/ui/debug-panel/settings.d.ts +0 -5
  188. package/dist/ui/debug-panel/settings.d.ts.map +0 -1
  189. package/dist/ui/debug-panel/settings.js +0 -35
  190. package/dist/ui/debug-panel/state.d.ts +0 -128
  191. package/dist/ui/debug-panel/state.d.ts.map +0 -1
  192. package/dist/ui/debug-panel/state.js +0 -42
  193. package/dist/ui/debug-panel/stateEditor.d.ts +0 -9
  194. package/dist/ui/debug-panel/stateEditor.d.ts.map +0 -1
  195. package/dist/ui/debug-panel/stateEditor.js +0 -158
  196. package/dist/ui/debug-panel/types.d.ts +0 -68
  197. package/dist/ui/debug-panel/types.d.ts.map +0 -1
  198. package/dist/ui/debug-panel/types.js +0 -1
  199. package/dist/ui/debug-panel/ui.d.ts +0 -10
  200. package/dist/ui/debug-panel/ui.d.ts.map +0 -1
  201. package/dist/ui/debug-panel/ui.js +0 -199
  202. package/dist/ui/debug-panel/utils.d.ts +0 -16
  203. package/dist/ui/debug-panel/utils.d.ts.map +0 -1
  204. package/dist/ui/debug-panel/utils.js +0 -104
  205. package/dist/utils.d.ts +0 -22
  206. package/dist/utils.d.ts.map +0 -1
  207. package/dist/utils.js +0 -58
@@ -1,217 +0,0 @@
1
- // src/core/app/ModuleManager.ts (REFACTORIZADO COMPLETO)
2
- import React, { useEffect } from 'react';
3
- /**
4
- * Gestiona el ciclo de vida completo de los módulos:
5
- * 1. Lee los manifiestos y registra las contribuciones estáticas (Fase de Registro).
6
- * 2. Activa los módulos bajo demanda (lazy loading) cuando se requiere su código (Fase de Activación).
7
- */
8
- export class ModuleManager {
9
- api;
10
- container;
11
- modules = new Map();
12
- activatedModules = new Set();
13
- // Un mapa para saber qué módulo provee qué servicio.
14
- serviceProviderMap = new Map();
15
- // private coreModuleImporter: ModuleImporterFn | null = null;
16
- constructor(api, container) {
17
- this.api = api;
18
- this.container = container;
19
- }
20
- /**
21
- * FASE 1: Procesa los manifiestos de todos los módulos disponibles.
22
- * @param moduleDefs Un array de objetos con el id del módulo y su manifiesto.
23
- */
24
- // public async processManifests(moduleDefs: { id: string, manifest: any, path: string }[]) {
25
- // for (const def of moduleDefs) {
26
- // this.modules.set(def.id, { ...def });
27
- // console.log(`[Manifest] Procesando contribuciones para '${def.id}'`);
28
- // this.registerStaticContributions(def.manifest);
29
- // }
30
- // }
31
- async registerModules(moduleDefs) {
32
- for (const def of moduleDefs) {
33
- if (this.modules.has(def.id)) {
34
- console.warn(`[ModuleManager] El módulo '${def.id}' ya está registrado. Omitiendo duplicado.`);
35
- continue;
36
- }
37
- this.modules.set(def.id, def);
38
- console.log(`[Manifest] Registrando contribuciones para '${def.id}'`);
39
- this.registerStaticContributions(def.manifest);
40
- }
41
- }
42
- /**
43
- * NUEVO MÉTODO: Este es el "puerto de carga". La aplicación llamará a este método
44
- * para darle al ModuleManager la capacidad de cargar módulos del núcleo.
45
- */
46
- // public setCoreModuleImporter(importer: ModuleImporterFn) {
47
- // this.coreModuleImporter = importer;
48
- // }
49
- /**
50
- * Lee la sección `contributes` y registra "placeholders" para la UI.
51
- * Estos placeholders activarán el módulo cuando se interactúe con ellos.
52
- */
53
- registerStaticContributions(manifest) {
54
- const moduleId = manifest.name; // Usamos el 'name' del package.json como ID
55
- if (!moduleId || !manifest.contributes)
56
- return;
57
- const contributions = manifest.contributes;
58
- // Registrar declaraciones de servicios
59
- manifest.provides?.forEach((serviceKey) => {
60
- this.serviceProviderMap.set(serviceKey, moduleId);
61
- });
62
- // Registrar comandos (con un execute que activa el módulo)
63
- contributions.commands?.forEach((cmd) => {
64
- this.api.commands.register({
65
- ...cmd,
66
- execute: (api, args) => this.activateAndExecute(moduleId, cmd.id, args),
67
- });
68
- });
69
- // Registrar vistas (con lógica híbrida: render o component)
70
- contributions.sidebarViews?.forEach((view) => {
71
- // Si el shell soporta registro directo de componentes (nueva arquitectura React)
72
- if (this.api.layout.registerSidebarView) {
73
- // Creamos un Lazy Component React
74
- const LazyLoader = this.createLazyModuleView(moduleId, view.title);
75
- this.api.layout.registerSidebarView({
76
- ...view,
77
- // Si el view ya traía component (definido estáticamente?), lo usamos, si no, Lazy
78
- // Normalmente JSON no trae component.
79
- component: LazyLoader
80
- });
81
- }
82
- // Fallback para shells legacy (Lit-html)
83
- else if (view.render) {
84
- this.api.layout.registerSidebarView({
85
- ...view,
86
- render: (container) => {
87
- container.innerHTML = `<div class="p-4 text-center text-muted-foreground">Cargando ${view.title}...</div>`;
88
- this.activateModule(moduleId).then(() => {
89
- this.api.layout.renderSidebar();
90
- });
91
- }
92
- });
93
- }
94
- });
95
- // Registrar iconos activity bar
96
- contributions.activityBar?.forEach((item) => {
97
- this.api.layout.registerActivityBarItem({
98
- ...item
99
- });
100
- });
101
- // Registrar Vistas del Panel Inferior
102
- contributions.panelViews?.forEach((view) => {
103
- if (this.api.layout.registerPanelView && this.createLazyModuleView) {
104
- const LazyLoader = this.createLazyModuleView(moduleId, view.title);
105
- this.api.layout.registerPanelView({
106
- ...view,
107
- component: LazyLoader
108
- });
109
- }
110
- else if (view.render) {
111
- this.api.layout.registerPanelView({
112
- ...view,
113
- render: (container) => {
114
- container.innerHTML = `<div class="p-4 text-center text-muted-foreground">Cargando ${view.title}...</div>`;
115
- this.activateModule(moduleId).then(() => {
116
- this.api.layout.renderPanel();
117
- });
118
- }
119
- });
120
- }
121
- });
122
- // Registrar Items de la Barra Superior
123
- contributions.topBarItems?.forEach((item) => {
124
- this.api.layout.registerTopBarItem(item);
125
- });
126
- // Registrar Items de la Barra de Estado
127
- contributions.statusBarItems?.forEach((item) => {
128
- this.api.layout.registerStatusBarItem(item);
129
- });
130
- }
131
- /**
132
- * FASE 2: Activa un módulo (carga su código y ejecuta `activate`).
133
- * @param moduleId El ID del módulo a activar (ej: 'decido.projects').
134
- */
135
- async activateModule(moduleId) {
136
- if (this.activatedModules.has(moduleId)) {
137
- return;
138
- }
139
- const moduleDef = this.modules.get(moduleId);
140
- if (!moduleDef) {
141
- throw new Error(`Intento de activar un módulo no registrado: ${moduleId}`);
142
- }
143
- // Verificamos si tenemos un cargador inyectado.
144
- // if (!this.coreModuleImporter) {
145
- // throw new Error("No se ha configurado un importador de módulos del núcleo. Llama a 'setCoreModuleImporter' al iniciar la aplicación.");
146
- // }
147
- console.log(`🚀 Activando módulo del núcleo '${moduleId}'...`);
148
- try {
149
- // 1. Usamos la función inyectada para obtener el módulo.
150
- const module = await moduleDef.importer();
151
- if (module.activate && typeof module.activate === 'function') {
152
- await module.activate(this.api);
153
- this.activatedModules.add(moduleId);
154
- console.log(`✅ Módulo '${moduleId}' activado con éxito.`);
155
- }
156
- else {
157
- throw new Error(`El módulo no tiene una función de exportación 'activate' válida.`);
158
- }
159
- }
160
- catch (error) {
161
- console.error(`❌ Fallo al activar el módulo '${moduleId}':`, error);
162
- this.api.notifications.show('error', `Fallo al activar: ${moduleId}`, error.message);
163
- }
164
- }
165
- async loadExternalModules(moduleDefs) {
166
- for (const def of moduleDefs) {
167
- if (this.activatedModules.has(def.id)) {
168
- continue;
169
- }
170
- console.log(`🔌 Cargando módulo externo '${def.id}' desde '${def.path}'`);
171
- try {
172
- // Construimos la ruta completa al punto de entrada del módulo
173
- const moduleUrl = `${window.location.origin}${def.path}/index.js`;
174
- // Usamos import() dinámico para cargar el código
175
- const module = await import(/* @vite-ignore */ moduleUrl);
176
- if (module.activate && typeof module.activate === 'function') {
177
- await module.activate(this.api);
178
- this.activatedModules.add(def.id);
179
- console.log(`✅ Módulo externo '${def.id}' activado.`);
180
- }
181
- else {
182
- throw new Error(`El módulo externo no exporta una función 'activate'.`);
183
- }
184
- }
185
- catch (error) {
186
- console.error(`❌ Fallo al cargar el módulo externo '${def.id}':`, error);
187
- this.api.notifications.show('error', `Fallo de Módulo Externo`, error.message);
188
- }
189
- }
190
- }
191
- /**
192
- * Devuelve el ID del módulo que provee un servicio específico.
193
- */
194
- getModuleIdForService(serviceKey) {
195
- return this.serviceProviderMap.get(serviceKey);
196
- }
197
- /**
198
- * Una función de ayuda que asegura la activación de un módulo antes de ejecutar un comando.
199
- */
200
- async activateAndExecute(moduleId, commandId, args) {
201
- await this.activateModule(moduleId);
202
- // El comando real ya habrá sido sobreescrito por el módulo durante su activación.
203
- // Lo ejecutamos.
204
- this.api.commands.execute(commandId, args);
205
- }
206
- /**
207
- * Crea un componente React que activa el módulo al montarse.
208
- */
209
- createLazyModuleView(moduleId, title) {
210
- return () => {
211
- useEffect(() => {
212
- this.activateModule(moduleId).catch(err => console.error("Lazy Load failed", err));
213
- }, []);
214
- return React.createElement('div', { className: "flex items-center justify-center h-full text-muted-foreground" }, `Cargando módulo: ${title}...`);
215
- };
216
- }
217
- }
@@ -1,4 +0,0 @@
1
- import { IPlatformAPI } from '../api.js';
2
- import { ServiceContainer } from '../ServiceContainer.js';
3
- export declare function createPlatformAPI(container: ServiceContainer): IPlatformAPI;
4
- //# sourceMappingURL=apiFactory.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"apiFactory.d.ts","sourceRoot":"","sources":["../../../src/core/app/apiFactory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAezC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAM1D,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,gBAAgB,GAAG,YAAY,CA2G3E"}
@@ -1,120 +0,0 @@
1
- import { EventBus } from '../EventBus.js';
2
- import { CommandService } from '../CommandService.js';
3
- import { NotificationService } from '../NotificationService.js';
4
- import { ModalService } from '../ModalService.js';
5
- import { GamificationService } from '../GamificationService.js';
6
- import { CalendarService } from '../CalendarService.js';
7
- import { ShortcutService } from '../ShortcutService.js';
8
- import { apiService } from '../ApiService.js';
9
- import * as appState from '../../appState.js';
10
- import { ThemeService } from '../ThemeService.js';
11
- import { authService } from '../AuthService.js';
12
- import { routerService } from '../RouterService.js';
13
- import { SyncService } from '../../lib/sync-service.js';
14
- import { StorageService } from '../StorageService.js';
15
- import { HookService } from '../HookService.js';
16
- import { ModuleManager } from './ModuleManager.js';
17
- import { WebSocketService } from '../WebSocketService.js'; // Importa el nuevo servicio
18
- export function createPlatformAPI(container) {
19
- const eventBus = new EventBus();
20
- authService.init(apiService);
21
- apiService.init(authService);
22
- // Registramos los servicios DEL NÚCLEO en el contenedor
23
- container.register('events', new EventBus());
24
- container.register('notifications', new NotificationService());
25
- container.register('modals', new ModalService());
26
- container.register('commands', new CommandService());
27
- container.register('shortcuts', new ShortcutService());
28
- container.register('gamification', new GamificationService());
29
- container.register('calendar', new CalendarService());
30
- container.register('storage', new StorageService());
31
- container.register('sync', new SyncService());
32
- container.register('hooks', new HookService());
33
- container.register('theme', new ThemeService());
34
- container.register('websocket', new WebSocketService());
35
- const getModuleManager = () => container.get('moduleManager');
36
- const api = {
37
- debug: undefined,
38
- events: container.get('events'),
39
- state: appState,
40
- commands: container.get('commands'),
41
- modals: container.get('modals'),
42
- notifications: container.get('notifications'),
43
- shortcuts: container.get('shortcuts'),
44
- gamification: container.get('gamification'),
45
- calendar: container.get('calendar'),
46
- theme: container.get('theme'),
47
- storage: container.get('storage'),
48
- sync: container.get('sync'),
49
- moduleManager: null, // TODO: revisar por que se asignaba como null
50
- auth: authService,
51
- router: routerService,
52
- hooks: container.get('hooks'),
53
- websocket: container.get('websocket'),
54
- modules: {
55
- getModules: () => apiService.fetch('/marketplace/modules'),
56
- getInstalledModules: () => apiService.fetch('/marketplace/user/modules'),
57
- installModule: (moduleId) => apiService.fetch(`/marketplace/install/${moduleId}`, { method: 'POST' }),
58
- uploadModule: (formData) => apiService.uploadModule(formData),
59
- getProfile: apiService.getProfile.bind(apiService),
60
- updateProfile: apiService.updateProfile.bind(apiService),
61
- rateModule: (id, rating, review) => apiService.fetch(`/marketplace/rate/${id}`, { method: 'POST', body: JSON.stringify({ rating, review }) }),
62
- getModuleById: (moduleId) => apiService.fetch(`/marketplace/module/${moduleId}`),
63
- getCategories: () => apiService.fetch('/marketplace/categories'),
64
- },
65
- ai: {
66
- generateTheme: (prompt) => apiService.fetch('/ai/generate-theme', { method: 'POST', body: JSON.stringify({ prompt }) }),
67
- // generateContent: (prompt, history, mcpServerId) => apiService.fetch('/ai/chat', { method: 'POST', body: { prompt, history, mcpServerId } }),
68
- },
69
- // mcp: {
70
- // getServers: () => apiService.fetch('/mcp/servers'),
71
- // installServer: (server) => apiService.fetch('/mcp/servers', { method: 'POST', body: server }),
72
- // updateServer: (id, data) => apiService.fetch(`/mcp/servers/${id}`, { method: 'PUT', body: data }),
73
- // uninstallServer: (id) => apiService.fetch(`/mcp/servers/${id}`, { method: 'DELETE' }),
74
- // },
75
- // chat: {
76
- // getConversations: () => apiService.fetch('/chat/conversations'),
77
- // getConversation: (id) => apiService.fetch(`/chat/conversations/${id}`),
78
- // createConversation: (data) => apiService.fetch('/chat/conversations', { method: 'POST', body: data }),
79
- // updateConversation: (id, data) => apiService.fetch(`/chat/conversations/${id}`, { method: 'PUT', body: data }),
80
- // deleteConversation: (id) => apiService.fetch(`/chat/conversations/${id}`, { method: 'DELETE' }),
81
- // },
82
- timetravel: {
83
- revertToDate: (date) => apiService.fetch('/timetravel/revert', { method: 'POST', body: JSON.stringify({ date }) }),
84
- getSnapshotDates: () => apiService.fetch('/timetravel/snapshots/dates'),
85
- getPreviousActivityDate: (date) => apiService.fetch(`/timetravel/previous-activity-date?currentDate=${date}`),
86
- getNextActivityDate: (date) => apiService.fetch(`/timetravel/next-activity-date?currentDate=${date}`),
87
- },
88
- container: container, // Exponemos el contenedor directamente
89
- services: {
90
- // El método register es una fachada para el contenedor
91
- register: (key, instance) => container.register(key, instance),
92
- // El método get también usa el contenedor
93
- get: async (key) => {
94
- try {
95
- // Intenta obtener el servicio directamente. Si ya está registrado, esto funciona.
96
- return container.get(key);
97
- }
98
- catch (e) {
99
- // Si el servicio no está, es porque su módulo no ha sido activado.
100
- console.log(`[API] Servicio '${key}' no encontrado. Buscando proveedor...`);
101
- const moduleManager = getModuleManager();
102
- const moduleId = moduleManager.getModuleIdForService(key);
103
- if (moduleId) {
104
- // Encontramos el módulo que lo provee. Lo activamos.
105
- await moduleManager.activateModule(moduleId);
106
- // Después de la activación, el servicio DEBE estar en el contenedor.
107
- // Lo volvemos a pedir. Esta vez no debería fallar.
108
- return container.get(key);
109
- }
110
- else {
111
- throw new Error(`[API] No se encontró ningún módulo que provea el servicio '${key}'.`);
112
- }
113
- }
114
- }
115
- },
116
- };
117
- container.register('moduleManager', new ModuleManager(api, container));
118
- api.websocket?.init(api);
119
- return api;
120
- }
@@ -1,3 +0,0 @@
1
- import { IPlatformAPI } from '../api';
2
- export declare function registerCoreCommands(this: any, platformAPI: IPlatformAPI): void;
3
- //# sourceMappingURL=commandManager.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"commandManager.d.ts","sourceRoot":"","sources":["../../../src/core/app/commandManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAKtC,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,GAAG,EAAE,WAAW,EAAE,YAAY,QAmNxE"}
@@ -1,195 +0,0 @@
1
- import { Palette } from '../../ui/Palette';
2
- import { html } from '../../utils.js';
3
- export function registerCoreCommands(platformAPI) {
4
- const palette = new Palette(platformAPI);
5
- platformAPI.commands.register({ id: 'palette.toggle', title: 'Abrir Paleta de Comandos', execute: () => palette.toggle() });
6
- platformAPI.shortcuts.register({ id: 'togglePalette', keys: 'Control+K', commandId: 'palette.toggle', description: 'Abrir/Cerrar Paleta de Comandos' });
7
- platformAPI.layout.registerTopBarItem({
8
- id: 'right.toggle-left-sidebar',
9
- icon: 'fas fa-arrow-right-from-bracket',
10
- title: 'Panel Izquierdo',
11
- commandId: 'layout.toggleSidebar',
12
- order: 1
13
- });
14
- platformAPI.layout.registerTopBarItem({
15
- id: 'right.toggle-right-sidebar',
16
- icon: 'fas fa-arrow-left',
17
- title: 'Panel Derecho',
18
- commandId: 'layout.toggleSidebarRight',
19
- order: 2
20
- });
21
- platformAPI.layout.registerTopBarItem({
22
- id: 'right.toggle-bottom-panel',
23
- icon: 'fas fa-panel-bottom',
24
- title: 'Panel Inferior',
25
- commandId: 'layout.togglePanel',
26
- order: 3
27
- });
28
- platformAPI.commands.register({
29
- id: 'app.showInfo',
30
- title: 'Mostrar Información de la App',
31
- category: 'Ayuda',
32
- execute: () => {
33
- platformAPI.modals.show({
34
- title: 'Acerca de Decido',
35
- content: html `<div class="text-center"><h2 class="text-2xl font-bold">Decido</h2><p class="text-lg">Tu sistema operativo para la vida.</p><p class="mt-4">Versión 0.3.1 - Estable</p></div>`,
36
- });
37
- }
38
- });
39
- platformAPI.commands.register({
40
- id: 'auth.showLoginModal',
41
- title: 'Iniciar Sesión',
42
- category: 'Usuario',
43
- execute: () => {
44
- const modalContent = document.createElement('div');
45
- modalContent.innerHTML = html `
46
- <form id="login-form" class="space-y-4">
47
- <div><label for="email" class="journal-label">Email</label><input type="email" name="email" class="form-input-premium" required value="test@test.com"></div>
48
- <div><label for="password" class="journal-label">Contraseña</label><input type="password" name="password" class="form-input-premium" required value="password"></div>
49
- <div class="pt-4 text-right"><button type="submit" class="btn-premium">Entrar</button></div>
50
- </form>
51
- `;
52
- const modal = platformAPI.modals.show({
53
- title: 'Iniciar Sesión',
54
- content: modalContent,
55
- actions: []
56
- });
57
- modalContent.querySelector('#login-form')?.addEventListener('submit', async (e) => {
58
- e.preventDefault();
59
- const form = e.target;
60
- const email = form.elements.namedItem('email').value;
61
- const password = form.elements.namedItem('password').value;
62
- try {
63
- await platformAPI.auth.login(email, password);
64
- modal.close();
65
- }
66
- catch (error) {
67
- const errorMessage = error instanceof Error ? error.message : "Error desconocido";
68
- platformAPI.notifications.show('error', 'Error de Login', errorMessage);
69
- }
70
- });
71
- }
72
- });
73
- platformAPI.commands.register({
74
- id: 'auth.showRegisterModal',
75
- title: 'Registrarse',
76
- category: 'Usuario',
77
- execute: () => {
78
- const modalContent = document.createElement('div');
79
- modalContent.innerHTML = html `
80
- <form id="register-form" class="space-y-4">
81
- <div><label for="username" class="journal-label">Nombre</label><input type="text" name="username" class="form-input-premium" required></div>
82
- <div><label for="email" class="journal-label">Email</label><input type="email" name="email" class="form-input-premium" required></div>
83
- <div><label for="password" class="journal-label">Contraseña</label><input type="password" name="password" class="form-input-premium" required></div>
84
- <div class="pt-4 text-right"><button type="submit" class="btn-premium">Registrarse</button></div>
85
- </form>
86
- <div class="text-center mt-4">
87
- <a href="#" class="text-sm text-accent hover:underline" data-command="auth.showLoginModal">¿Ya tienes cuenta? Inicia sesión</a>
88
- </div>
89
- `;
90
- const modal = platformAPI.modals.show({
91
- title: 'Crear Cuenta',
92
- content: modalContent,
93
- actions: []
94
- });
95
- modalContent.querySelector('#register-form')?.addEventListener('submit', async (e) => {
96
- e.preventDefault();
97
- const form = e.target;
98
- const username = form.elements.namedItem('username').value;
99
- const email = form.elements.namedItem('email').value;
100
- const password = form.elements.namedItem('password').value;
101
- try {
102
- await platformAPI.auth.register(username, email, password);
103
- modal.close();
104
- platformAPI.notifications.show('success', 'Registro Exitoso', 'Ahora puedes iniciar sesión.');
105
- platformAPI.commands.execute('auth.showLoginModal');
106
- }
107
- catch (error) {
108
- const errorMessage = error instanceof Error ? error.message : "Error desconocido";
109
- platformAPI.notifications.show('error', 'Error de Registro', errorMessage);
110
- }
111
- });
112
- }
113
- });
114
- platformAPI.commands.register({
115
- id: 'workbench.splitPane',
116
- title: 'Dividir Editor',
117
- category: 'Layout',
118
- execute: (api) => {
119
- const currentPanes = api.state.editorPanes();
120
- const newPaneId = `pane-${Date.now()}`;
121
- const newPane = {
122
- id: newPaneId,
123
- tabs: [],
124
- activeTabId: null
125
- };
126
- api.state.setEditorPanes([...currentPanes, newPane]);
127
- api.state.setActivePaneId(newPaneId);
128
- }
129
- });
130
- platformAPI.commands.register({
131
- id: 'workbench.openTab',
132
- title: 'Abrir Vista en Editor',
133
- category: 'Layout',
134
- execute: (api, tabData) => {
135
- const { state, layout } = api;
136
- let panes = state.editorPanes();
137
- let activePaneId = state.activePaneId();
138
- if (panes.length === 0) {
139
- const newPane = {
140
- id: `pane-${Date.now()}`,
141
- tabs: [],
142
- activeTabId: null,
143
- };
144
- panes = [newPane];
145
- activePaneId = newPane.id;
146
- state.setActivePaneId(activePaneId);
147
- }
148
- const targetPane = panes.find(p => p.id === activePaneId);
149
- const tabExists = targetPane.tabs.some(t => t.id === tabData.id);
150
- if (!tabExists) {
151
- targetPane.tabs.push(tabData);
152
- }
153
- targetPane.activeTabId = tabData.id;
154
- state.setEditorPanes([...panes]);
155
- }
156
- });
157
- platformAPI.commands.register({
158
- id: 'workbench.focusTab',
159
- title: 'Enfocar Vista',
160
- execute: (api, { paneId, tabId }) => {
161
- const { state } = api;
162
- const panes = state.editorPanes();
163
- const targetPane = panes.find(p => p.id === paneId);
164
- if (targetPane) {
165
- targetPane.activeTabId = tabId;
166
- state.setActivePaneId(paneId);
167
- state.setEditorPanes([...panes]);
168
- }
169
- }
170
- });
171
- platformAPI.commands.register({
172
- id: 'workbench.closeTab',
173
- title: 'Cerrar Vista',
174
- execute: (api, { paneId, tabId }) => {
175
- const { state } = api;
176
- let panes = state.editorPanes();
177
- const targetPane = panes.find(p => p.id === paneId);
178
- if (!targetPane)
179
- return;
180
- const remainingTabs = targetPane.tabs.filter(t => t.id !== tabId);
181
- if (remainingTabs.length === 0 && panes.length > 1) {
182
- panes = panes.filter(p => p.id !== paneId);
183
- const newActivePaneId = panes[panes.length - 1]?.id || null;
184
- state.setActivePaneId(newActivePaneId);
185
- }
186
- else {
187
- targetPane.tabs = remainingTabs;
188
- if (targetPane.activeTabId === tabId) {
189
- targetPane.activeTabId = remainingTabs[remainingTabs.length - 1]?.id || null;
190
- }
191
- }
192
- state.setEditorPanes([...panes]);
193
- }
194
- });
195
- }
@@ -1,11 +0,0 @@
1
- import { RegisteredModule } from "./ModuleManager";
2
- /**
3
- * Procesa los objetos generados por `import.meta.glob` de Vite para crear una lista
4
- * de definiciones de módulos (`RegisteredModule`) que el ModuleManager puede registrar.
5
- * * @param imports El objeto de importaciones dinámicas de Vite (ej: `import.meta.glob('.\\/**\\/*.ts')`).
6
- * @param manifests El objeto de manifiestos cargados de forma síncrona (ej: `import.meta.glob('.\\/**\\/package.json', { eager: true })`).
7
- * @param enabledModules Un Set opcional con los nombres de los módulos que se deben cargar. Si no se proporciona, todos los módulos descubiertos serán procesados.
8
- * @returns Un array de `RegisteredModule` listo para ser usado por el ModuleManager.
9
- */
10
- export declare function processModuleDefinitions(imports: Record<string, () => Promise<unknown>>, manifests: Record<string, any>, enabledModules?: Set<string>): RegisteredModule[];
11
- //# sourceMappingURL=moduleLoader.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"moduleLoader.d.ts","sourceRoot":"","sources":["../../../src/core/app/moduleLoader.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CACpC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC,EAC/C,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC9B,cAAc,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,GAC7B,gBAAgB,EAAE,CAsBpB"}
@@ -1,30 +0,0 @@
1
- // File: packages/core/src/core/app/module-loader.ts
2
- /**
3
- * Procesa los objetos generados por `import.meta.glob` de Vite para crear una lista
4
- * de definiciones de módulos (`RegisteredModule`) que el ModuleManager puede registrar.
5
- * * @param imports El objeto de importaciones dinámicas de Vite (ej: `import.meta.glob('.\\/**\\/*.ts')`).
6
- * @param manifests El objeto de manifiestos cargados de forma síncrona (ej: `import.meta.glob('.\\/**\\/package.json', { eager: true })`).
7
- * @param enabledModules Un Set opcional con los nombres de los módulos que se deben cargar. Si no se proporciona, todos los módulos descubiertos serán procesados.
8
- * @returns Un array de `RegisteredModule` listo para ser usado por el ModuleManager.
9
- */
10
- export function processModuleDefinitions(imports, manifests, enabledModules // El Set de módulos habilitados ahora es opcional
11
- ) {
12
- const definitions = [];
13
- for (const path in imports) {
14
- const manifestPath = path.replace('index.ts', 'package.json');
15
- const manifest = manifests[manifestPath];
16
- if (!manifest || !manifest.name) {
17
- continue;
18
- }
19
- // Si se proporcionó una lista de módulos habilitados, filtramos por ella.
20
- // Si no, cargamos todos los que encontramos.
21
- if (!enabledModules || enabledModules.has(manifest.name)) {
22
- definitions.push({
23
- id: manifest.name,
24
- manifest: manifest,
25
- importer: imports[path]
26
- });
27
- }
28
- }
29
- return definitions;
30
- }
@@ -1,2 +0,0 @@
1
- export declare function defineCoreRoutes(): void;
2
- //# sourceMappingURL=routeManager.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"routeManager.d.ts","sourceRoot":"","sources":["../../../src/core/app/routeManager.ts"],"names":[],"mappings":"AAGA,wBAAgB,gBAAgB,SAI/B"}
@@ -1,7 +0,0 @@
1
- // src/core/app/routeManager.ts
2
- import { routerService } from '../RouterService';
3
- export function defineCoreRoutes() {
4
- routerService.registerRoute({ path: '/', componentTag: 'dashboard-view', auth: 'protected', title: 'Dashboard' });
5
- routerService.registerRoute({ path: '/login', componentTag: 'login-view', auth: 'guestOnly', title: 'Iniciar Sesión', isFullscreen: true });
6
- routerService.registerRoute({ path: '/forbidden', componentTag: 'forbidden-view', auth: 'public' });
7
- }
@@ -1,16 +0,0 @@
1
- export * from './api.js';
2
- export * from './ApiService.js';
3
- export * from './AuthService.js';
4
- export * from './BaseService.js';
5
- export * from './CalendarService.js';
6
- export * from './CommandService.js';
7
- export * from './GamificationService.js';
8
- export * from './HookService.js';
9
- export * from './ModalService.js';
10
- export * from './NotificationService.js';
11
- export * from './RouterService.js';
12
- export * from './ShortcutService.js';
13
- export * from './StorageService.js';
14
- export * from './ThemeService.js';
15
- export * from './EventHandler.js';
16
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAChC,cAAc,kBAAkB,CAAA;AAChC,cAAc,sBAAsB,CAAA;AACpC,cAAc,qBAAqB,CAAA;AACnC,cAAc,0BAA0B,CAAA;AACxC,cAAc,kBAAkB,CAAA;AAChC,cAAc,mBAAmB,CAAA;AACjC,cAAc,0BAA0B,CAAA;AACxC,cAAc,oBAAoB,CAAA;AAClC,cAAc,sBAAsB,CAAA;AACpC,cAAc,qBAAqB,CAAA;AACnC,cAAc,mBAAmB,CAAA;AACjC,cAAc,mBAAmB,CAAA"}
@@ -1,15 +0,0 @@
1
- export * from './api.js';
2
- export * from './ApiService.js';
3
- export * from './AuthService.js';
4
- export * from './BaseService.js';
5
- export * from './CalendarService.js';
6
- export * from './CommandService.js';
7
- export * from './GamificationService.js';
8
- export * from './HookService.js';
9
- export * from './ModalService.js';
10
- export * from './NotificationService.js';
11
- export * from './RouterService.js';
12
- export * from './ShortcutService.js';
13
- export * from './StorageService.js';
14
- export * from './ThemeService.js';
15
- export * from './EventHandler.js';