wu-framework 1.1.11 β 1.1.13
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/dist/wu-framework.cjs.js +1 -1
- package/dist/wu-framework.cjs.js.map +1 -1
- package/dist/wu-framework.dev.js +246 -236
- package/dist/wu-framework.dev.js.map +1 -1
- package/dist/wu-framework.esm.js +1 -1
- package/dist/wu-framework.esm.js.map +1 -1
- package/dist/wu-framework.umd.js +1 -1
- package/dist/wu-framework.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/adapters/react/index.js +41 -26
- package/src/adapters/vue/index.js +18 -16
- package/src/core/wu-app.js +9 -7
- package/src/core/wu-cache.js +16 -14
- package/src/core/wu-error-boundary.js +17 -15
- package/src/core/wu-event-bus.js +4 -2
- package/src/core/wu-hooks.js +10 -8
- package/src/core/wu-loader.js +20 -18
- package/src/core/wu-manifest.js +10 -8
- package/src/core/wu-mcp-bridge.js +6 -5
- package/src/core/wu-performance.js +7 -5
- package/src/core/wu-plugin.js +8 -6
- package/src/core/wu-strategies.js +14 -12
- package/src/utils/dependency-resolver.js +13 -11
package/src/core/wu-loader.js
CHANGED
|
@@ -3,12 +3,14 @@
|
|
|
3
3
|
* Carga aplicaciones y componentes sin depender del framework
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
import { logger } from './wu-logger.js';
|
|
7
|
+
|
|
6
8
|
export class WuLoader {
|
|
7
9
|
constructor() {
|
|
8
10
|
this.cache = new Map();
|
|
9
11
|
this.loadingPromises = new Map();
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
logger.debug('[WuLoader] π¦ Dynamic loader initialized');
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
/**
|
|
@@ -21,18 +23,18 @@ export class WuLoader {
|
|
|
21
23
|
const entryFile = manifest?.entry || 'index.js';
|
|
22
24
|
const fullUrl = `${appUrl}/${entryFile}`;
|
|
23
25
|
|
|
24
|
-
|
|
26
|
+
logger.debug(`[WuLoader] π₯ Loading app from: ${fullUrl}`);
|
|
25
27
|
|
|
26
28
|
try {
|
|
27
29
|
// Verificar cache
|
|
28
30
|
if (this.cache.has(fullUrl)) {
|
|
29
|
-
|
|
31
|
+
logger.debug(`[WuLoader] β‘ Cache hit for: ${fullUrl}`);
|
|
30
32
|
return this.cache.get(fullUrl);
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
// Verificar si ya estΓ‘ cargando
|
|
34
36
|
if (this.loadingPromises.has(fullUrl)) {
|
|
35
|
-
|
|
37
|
+
logger.debug(`[WuLoader] β³ Loading in progress for: ${fullUrl}`);
|
|
36
38
|
return await this.loadingPromises.get(fullUrl);
|
|
37
39
|
}
|
|
38
40
|
|
|
@@ -46,7 +48,7 @@ export class WuLoader {
|
|
|
46
48
|
this.loadingPromises.delete(fullUrl);
|
|
47
49
|
this.cache.set(fullUrl, code);
|
|
48
50
|
|
|
49
|
-
|
|
51
|
+
logger.debug(`[WuLoader] β
App loaded successfully: ${fullUrl}`);
|
|
50
52
|
return code;
|
|
51
53
|
|
|
52
54
|
} catch (error) {
|
|
@@ -74,7 +76,7 @@ export class WuLoader {
|
|
|
74
76
|
|
|
75
77
|
const fullUrl = `${appUrl}/${normalizedPath}`;
|
|
76
78
|
|
|
77
|
-
|
|
79
|
+
logger.debug(`[WuLoader] π§© Loading component from: ${fullUrl}`);
|
|
78
80
|
|
|
79
81
|
try {
|
|
80
82
|
// Cargar cΓ³digo del componente
|
|
@@ -91,13 +93,13 @@ export class WuLoader {
|
|
|
91
93
|
// Ejecutar y obtener el componente
|
|
92
94
|
const fakeModule = { exports: {} };
|
|
93
95
|
const fakeRequire = (name) => {
|
|
94
|
-
|
|
96
|
+
logger.warn(`[WuLoader] Component ${componentPath} requires ${name} - not supported yet`);
|
|
95
97
|
return {};
|
|
96
98
|
};
|
|
97
99
|
|
|
98
100
|
const component = componentFunction(fakeRequire, fakeModule, fakeModule.exports);
|
|
99
101
|
|
|
100
|
-
|
|
102
|
+
logger.debug(`[WuLoader] β
Component loaded: ${componentPath}`);
|
|
101
103
|
return component;
|
|
102
104
|
|
|
103
105
|
} catch (error) {
|
|
@@ -168,19 +170,19 @@ export class WuLoader {
|
|
|
168
170
|
* @param {Array} appConfigs - Configuraciones de aplicaciones
|
|
169
171
|
*/
|
|
170
172
|
async preload(appConfigs) {
|
|
171
|
-
|
|
173
|
+
logger.debug(`[WuLoader] π Preloading ${appConfigs.length} apps...`);
|
|
172
174
|
|
|
173
175
|
const preloadPromises = appConfigs.map(async (config) => {
|
|
174
176
|
try {
|
|
175
177
|
await this.loadApp(config.url, config.manifest);
|
|
176
|
-
|
|
178
|
+
logger.debug(`[WuLoader] β
Preloaded: ${config.name}`);
|
|
177
179
|
} catch (error) {
|
|
178
|
-
|
|
180
|
+
logger.warn(`[WuLoader] β οΈ Failed to preload ${config.name}:`, error.message);
|
|
179
181
|
}
|
|
180
182
|
});
|
|
181
183
|
|
|
182
184
|
await Promise.allSettled(preloadPromises);
|
|
183
|
-
|
|
185
|
+
logger.debug(`[WuLoader] π Preload completed`);
|
|
184
186
|
}
|
|
185
187
|
|
|
186
188
|
/**
|
|
@@ -209,13 +211,13 @@ export class WuLoader {
|
|
|
209
211
|
const [appName, componentName] = importPath.split('.');
|
|
210
212
|
|
|
211
213
|
if (!appName || !componentName) {
|
|
212
|
-
|
|
214
|
+
logger.warn(`[WuLoader] Invalid import format: ${importPath}`);
|
|
213
215
|
continue;
|
|
214
216
|
}
|
|
215
217
|
|
|
216
218
|
const app = availableApps.get(appName);
|
|
217
219
|
if (!app) {
|
|
218
|
-
|
|
220
|
+
logger.warn(`[WuLoader] Import app not found: ${appName}`);
|
|
219
221
|
continue;
|
|
220
222
|
}
|
|
221
223
|
|
|
@@ -223,14 +225,14 @@ export class WuLoader {
|
|
|
223
225
|
const exportPath = manifest?.wu?.exports?.[componentName];
|
|
224
226
|
|
|
225
227
|
if (!exportPath) {
|
|
226
|
-
|
|
228
|
+
logger.warn(`[WuLoader] Export not found: ${importPath}`);
|
|
227
229
|
continue;
|
|
228
230
|
}
|
|
229
231
|
|
|
230
232
|
try {
|
|
231
233
|
const component = await this.loadComponent(app.url, exportPath);
|
|
232
234
|
resolved.set(importPath, component);
|
|
233
|
-
|
|
235
|
+
logger.debug(`[WuLoader] β
Resolved dependency: ${importPath}`);
|
|
234
236
|
} catch (error) {
|
|
235
237
|
console.error(`[WuLoader] β Failed to resolve: ${importPath}`, error);
|
|
236
238
|
}
|
|
@@ -249,12 +251,12 @@ export class WuLoader {
|
|
|
249
251
|
for (const [url] of this.cache) {
|
|
250
252
|
if (regex.test(url)) {
|
|
251
253
|
this.cache.delete(url);
|
|
252
|
-
|
|
254
|
+
logger.debug(`[WuLoader] ποΈ Cleared cache for: ${url}`);
|
|
253
255
|
}
|
|
254
256
|
}
|
|
255
257
|
} else {
|
|
256
258
|
this.cache.clear();
|
|
257
|
-
|
|
259
|
+
logger.debug(`[WuLoader] ποΈ Cache cleared completely`);
|
|
258
260
|
}
|
|
259
261
|
}
|
|
260
262
|
|
package/src/core/wu-manifest.js
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
* ValidaciΓ³n estricta de wu.json para seguridad
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
import { logger } from './wu-logger.js';
|
|
7
|
+
|
|
6
8
|
export class WuManifest {
|
|
7
9
|
constructor() {
|
|
8
10
|
this.cache = new Map();
|
|
@@ -62,12 +64,12 @@ export class WuManifest {
|
|
|
62
64
|
async load(appUrl) {
|
|
63
65
|
const manifestUrl = `${appUrl}/wu.json`;
|
|
64
66
|
|
|
65
|
-
|
|
67
|
+
logger.debug(`[WuManifest] π₯ Loading manifest: ${manifestUrl}`);
|
|
66
68
|
|
|
67
69
|
try {
|
|
68
70
|
// Verificar cache
|
|
69
71
|
if (this.cache.has(manifestUrl)) {
|
|
70
|
-
|
|
72
|
+
logger.debug(`[WuManifest] β‘ Cache hit: ${manifestUrl}`);
|
|
71
73
|
return this.cache.get(manifestUrl);
|
|
72
74
|
}
|
|
73
75
|
|
|
@@ -82,7 +84,7 @@ export class WuManifest {
|
|
|
82
84
|
if (!response.ok) {
|
|
83
85
|
// Si no hay manifest, crear uno bΓ‘sico
|
|
84
86
|
if (response.status === 404) {
|
|
85
|
-
|
|
87
|
+
logger.debug(`[WuManifest] π No manifest found, creating default for: ${appUrl}`);
|
|
86
88
|
return this.createDefaultManifest(appUrl);
|
|
87
89
|
}
|
|
88
90
|
|
|
@@ -110,7 +112,7 @@ export class WuManifest {
|
|
|
110
112
|
// Cachear resultado
|
|
111
113
|
this.cache.set(manifestUrl, validatedManifest);
|
|
112
114
|
|
|
113
|
-
|
|
115
|
+
logger.debug(`[WuManifest] β
Manifest loaded: ${manifest.name}`);
|
|
114
116
|
return validatedManifest;
|
|
115
117
|
|
|
116
118
|
} catch (error) {
|
|
@@ -145,7 +147,7 @@ export class WuManifest {
|
|
|
145
147
|
}
|
|
146
148
|
};
|
|
147
149
|
|
|
148
|
-
|
|
150
|
+
logger.debug(`[WuManifest] π§ Created default manifest for: ${appName}`);
|
|
149
151
|
return defaultManifest;
|
|
150
152
|
}
|
|
151
153
|
|
|
@@ -344,7 +346,7 @@ export class WuManifest {
|
|
|
344
346
|
// Validar imports
|
|
345
347
|
normalized.wu.imports = normalized.wu.imports.filter(imp => {
|
|
346
348
|
if (typeof imp !== 'string' || !imp.includes('.')) {
|
|
347
|
-
|
|
349
|
+
logger.warn(`[WuManifest] Invalid import format: ${imp}`);
|
|
348
350
|
return false;
|
|
349
351
|
}
|
|
350
352
|
return true;
|
|
@@ -486,12 +488,12 @@ export class WuManifest {
|
|
|
486
488
|
for (const [url] of this.cache) {
|
|
487
489
|
if (regex.test(url)) {
|
|
488
490
|
this.cache.delete(url);
|
|
489
|
-
|
|
491
|
+
logger.debug(`[WuManifest] ποΈ Cleared cache for: ${url}`);
|
|
490
492
|
}
|
|
491
493
|
}
|
|
492
494
|
} else {
|
|
493
495
|
this.cache.clear();
|
|
494
|
-
|
|
496
|
+
logger.debug(`[WuManifest] ποΈ Manifest cache cleared completely`);
|
|
495
497
|
}
|
|
496
498
|
}
|
|
497
499
|
|
|
@@ -30,6 +30,7 @@ import {
|
|
|
30
30
|
getFilteredNetwork,
|
|
31
31
|
getFilteredConsole,
|
|
32
32
|
} from '../ai/wu-ai-browser-primitives.js';
|
|
33
|
+
import { logger } from './wu-logger.js';
|
|
33
34
|
|
|
34
35
|
/**
|
|
35
36
|
* Create the MCP bridge for a Wu instance.
|
|
@@ -280,7 +281,7 @@ export function createMcpBridge(wu) {
|
|
|
280
281
|
|
|
281
282
|
function connect(url = 'ws://localhost:19100', options = {}) {
|
|
282
283
|
if (ws && ws.readyState <= 1) {
|
|
283
|
-
|
|
284
|
+
logger.warn('[wu-mcp-bridge] Already connected or connecting');
|
|
284
285
|
return;
|
|
285
286
|
}
|
|
286
287
|
|
|
@@ -291,7 +292,7 @@ export function createMcpBridge(wu) {
|
|
|
291
292
|
ws = new WebSocket(url);
|
|
292
293
|
|
|
293
294
|
ws.onopen = () => {
|
|
294
|
-
|
|
295
|
+
logger.debug('[wu-mcp-bridge] Connected to wu-mcp-server');
|
|
295
296
|
reconnectAttempts = 0;
|
|
296
297
|
|
|
297
298
|
// Send auth handshake if token provided
|
|
@@ -314,7 +315,7 @@ export function createMcpBridge(wu) {
|
|
|
314
315
|
console.error('[wu-mcp-bridge] Authentication failed:', msg.reason || 'Invalid token');
|
|
315
316
|
disconnect();
|
|
316
317
|
} else {
|
|
317
|
-
|
|
318
|
+
logger.debug('[wu-mcp-bridge] Authenticated successfully');
|
|
318
319
|
}
|
|
319
320
|
return;
|
|
320
321
|
}
|
|
@@ -330,7 +331,7 @@ export function createMcpBridge(wu) {
|
|
|
330
331
|
const { id, command, params } = msg;
|
|
331
332
|
|
|
332
333
|
if (!id || !command) {
|
|
333
|
-
|
|
334
|
+
logger.warn('[wu-mcp-bridge] Invalid message:', msg);
|
|
334
335
|
return;
|
|
335
336
|
}
|
|
336
337
|
|
|
@@ -352,7 +353,7 @@ export function createMcpBridge(wu) {
|
|
|
352
353
|
};
|
|
353
354
|
|
|
354
355
|
ws.onclose = () => {
|
|
355
|
-
|
|
356
|
+
logger.debug('[wu-mcp-bridge] Disconnected');
|
|
356
357
|
ws = null;
|
|
357
358
|
authenticated = false;
|
|
358
359
|
_scheduleReconnect(url, options);
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
* - EstadΓsticas por app
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
+
import { logger } from './wu-logger.js';
|
|
11
|
+
|
|
10
12
|
export class WuPerformance {
|
|
11
13
|
constructor() {
|
|
12
14
|
this.metrics = new Map(); // appName -> metrics
|
|
@@ -24,7 +26,7 @@ export class WuPerformance {
|
|
|
24
26
|
load: 5000 // ms
|
|
25
27
|
};
|
|
26
28
|
|
|
27
|
-
|
|
29
|
+
logger.debug('[WuPerformance] β‘ Framework performance monitoring initialized');
|
|
28
30
|
}
|
|
29
31
|
|
|
30
32
|
/**
|
|
@@ -36,7 +38,7 @@ export class WuPerformance {
|
|
|
36
38
|
const markName = `${appName}:${name}:start`;
|
|
37
39
|
this.marks.set(markName, performance.now());
|
|
38
40
|
|
|
39
|
-
|
|
41
|
+
logger.debug(`[WuPerformance] π Measure started: ${markName}`);
|
|
40
42
|
}
|
|
41
43
|
|
|
42
44
|
/**
|
|
@@ -68,10 +70,10 @@ export class WuPerformance {
|
|
|
68
70
|
|
|
69
71
|
// Verificar threshold
|
|
70
72
|
if (this.checkThreshold(name, duration)) {
|
|
71
|
-
|
|
73
|
+
logger.warn(`[WuPerformance] β οΈ Threshold exceeded for ${name}: ${duration.toFixed(2)}ms`);
|
|
72
74
|
}
|
|
73
75
|
|
|
74
|
-
|
|
76
|
+
logger.debug(`[WuPerformance] βΉοΈ Measure ended: ${markName} (${duration.toFixed(2)}ms)`);
|
|
75
77
|
return duration;
|
|
76
78
|
}
|
|
77
79
|
|
|
@@ -203,7 +205,7 @@ export class WuPerformance {
|
|
|
203
205
|
this.measurements = [];
|
|
204
206
|
}
|
|
205
207
|
|
|
206
|
-
|
|
208
|
+
logger.debug(`[WuPerformance] π§Ή Metrics cleared${appName ? ` for ${appName}` : ''}`);
|
|
207
209
|
}
|
|
208
210
|
|
|
209
211
|
/**
|
package/src/core/wu-plugin.js
CHANGED
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
* - Permission system
|
|
8
8
|
* - Timeout protection
|
|
9
9
|
*/
|
|
10
|
+
import { logger } from './wu-logger.js';
|
|
11
|
+
|
|
10
12
|
|
|
11
13
|
export class WuPluginSystem {
|
|
12
14
|
constructor(core) {
|
|
@@ -101,7 +103,7 @@ export class WuPluginSystem {
|
|
|
101
103
|
// π¨ Acceso completo solo con permiso 'unsafe'
|
|
102
104
|
if (permissions.includes('unsafe')) {
|
|
103
105
|
api._unsafeCore = this._core;
|
|
104
|
-
|
|
106
|
+
logger.warn('[WuPlugin] β οΈ Plugin has unsafe access to core!');
|
|
105
107
|
}
|
|
106
108
|
|
|
107
109
|
// Congelar API para evitar modificaciones
|
|
@@ -166,7 +168,7 @@ export class WuPluginSystem {
|
|
|
166
168
|
|
|
167
169
|
// Verificar si ya estΓ‘ instalado
|
|
168
170
|
if (this.plugins.has(plugin.name)) {
|
|
169
|
-
|
|
171
|
+
logger.warn(`[WuPlugin] Plugin "${plugin.name}" already installed`);
|
|
170
172
|
return;
|
|
171
173
|
}
|
|
172
174
|
|
|
@@ -204,7 +206,7 @@ export class WuPluginSystem {
|
|
|
204
206
|
installedAt: Date.now()
|
|
205
207
|
});
|
|
206
208
|
|
|
207
|
-
|
|
209
|
+
logger.debug(`[WuPlugin] β
Plugin "${plugin.name}" installed (permissions: ${permissions.join(', ')})`);
|
|
208
210
|
}
|
|
209
211
|
|
|
210
212
|
/**
|
|
@@ -237,7 +239,7 @@ export class WuPluginSystem {
|
|
|
237
239
|
*/
|
|
238
240
|
registerHook(hookName, callback) {
|
|
239
241
|
if (!this.hooks.has(hookName)) {
|
|
240
|
-
|
|
242
|
+
logger.warn(`[WuPlugin] Unknown hook: ${hookName}`);
|
|
241
243
|
return;
|
|
242
244
|
}
|
|
243
245
|
this.hooks.get(hookName).push(callback);
|
|
@@ -269,7 +271,7 @@ export class WuPluginSystem {
|
|
|
269
271
|
uninstall(pluginName) {
|
|
270
272
|
const pluginData = this.plugins.get(pluginName);
|
|
271
273
|
if (!pluginData) {
|
|
272
|
-
|
|
274
|
+
logger.warn(`[WuPlugin] Plugin "${pluginName}" not found`);
|
|
273
275
|
return;
|
|
274
276
|
}
|
|
275
277
|
|
|
@@ -284,7 +286,7 @@ export class WuPluginSystem {
|
|
|
284
286
|
}
|
|
285
287
|
|
|
286
288
|
this.plugins.delete(pluginName);
|
|
287
|
-
|
|
289
|
+
logger.debug(`[WuPlugin] β
Plugin "${pluginName}" uninstalled`);
|
|
288
290
|
}
|
|
289
291
|
|
|
290
292
|
/**
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
* - Idle: Carga cuando el navegador estΓ‘ idle
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
+
import { logger } from './wu-logger.js';
|
|
12
|
+
|
|
11
13
|
export class WuLoadingStrategy {
|
|
12
14
|
constructor(core) {
|
|
13
15
|
this.core = core;
|
|
@@ -18,7 +20,7 @@ export class WuLoadingStrategy {
|
|
|
18
20
|
this.registerDefaultStrategies();
|
|
19
21
|
this.setupIdleCallback();
|
|
20
22
|
|
|
21
|
-
|
|
23
|
+
logger.debug('[WuStrategies] π― Loading strategies initialized');
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
/**
|
|
@@ -29,7 +31,7 @@ export class WuLoadingStrategy {
|
|
|
29
31
|
this.register('lazy', {
|
|
30
32
|
shouldPreload: false,
|
|
31
33
|
load: async (appName, config) => {
|
|
32
|
-
|
|
34
|
+
logger.debug(`[Strategy:Lazy] Loading ${appName} on demand (no preload)`);
|
|
33
35
|
// No hace nada, la app se carga cuando se monta
|
|
34
36
|
return;
|
|
35
37
|
}
|
|
@@ -40,14 +42,14 @@ export class WuLoadingStrategy {
|
|
|
40
42
|
shouldPreload: true,
|
|
41
43
|
priority: 'high',
|
|
42
44
|
load: async (appName, config) => {
|
|
43
|
-
|
|
45
|
+
logger.debug(`[Strategy:Eager] Preloading ${appName} immediately`);
|
|
44
46
|
|
|
45
47
|
// Cargar el mΓ³dulo de la app
|
|
46
48
|
const app = this.core.apps.get(appName);
|
|
47
49
|
if (app) {
|
|
48
50
|
const moduleUrl = await this.core.resolveModulePath(app);
|
|
49
51
|
await import(/* @vite-ignore */ moduleUrl);
|
|
50
|
-
|
|
52
|
+
logger.debug(`[Strategy:Eager] β
${appName} preloaded`);
|
|
51
53
|
}
|
|
52
54
|
}
|
|
53
55
|
});
|
|
@@ -57,7 +59,7 @@ export class WuLoadingStrategy {
|
|
|
57
59
|
shouldPreload: true,
|
|
58
60
|
priority: 'medium',
|
|
59
61
|
load: async (appName, config) => {
|
|
60
|
-
|
|
62
|
+
logger.debug(`[Strategy:Preload] Using resource hints for ${appName}`);
|
|
61
63
|
|
|
62
64
|
// Crear <link rel="prefetch">
|
|
63
65
|
const app = this.core.apps.get(appName);
|
|
@@ -70,7 +72,7 @@ export class WuLoadingStrategy {
|
|
|
70
72
|
link.as = 'script';
|
|
71
73
|
document.head.appendChild(link);
|
|
72
74
|
|
|
73
|
-
|
|
75
|
+
logger.debug(`[Strategy:Preload] β
Resource hint added for ${appName}`);
|
|
74
76
|
}
|
|
75
77
|
}
|
|
76
78
|
});
|
|
@@ -92,7 +94,7 @@ export class WuLoadingStrategy {
|
|
|
92
94
|
this.register('idle', {
|
|
93
95
|
shouldPreload: false,
|
|
94
96
|
load: async (appName, config) => {
|
|
95
|
-
|
|
97
|
+
logger.debug(`[Strategy:Idle] Queueing ${appName} for idle loading`);
|
|
96
98
|
|
|
97
99
|
return new Promise((resolve) => {
|
|
98
100
|
this.loadingQueue.push({
|
|
@@ -127,7 +129,7 @@ export class WuLoadingStrategy {
|
|
|
127
129
|
load: strategy.load
|
|
128
130
|
});
|
|
129
131
|
|
|
130
|
-
|
|
132
|
+
logger.debug(`[WuStrategies] Strategy "${name}" registered`);
|
|
131
133
|
}
|
|
132
134
|
|
|
133
135
|
/**
|
|
@@ -141,7 +143,7 @@ export class WuLoadingStrategy {
|
|
|
141
143
|
const strategy = this.strategies.get(strategyName);
|
|
142
144
|
|
|
143
145
|
if (!strategy) {
|
|
144
|
-
|
|
146
|
+
logger.warn(`[WuStrategies] Strategy "${strategyName}" not found, using lazy`);
|
|
145
147
|
return await this.strategies.get('lazy').load(appName, config);
|
|
146
148
|
}
|
|
147
149
|
|
|
@@ -166,7 +168,7 @@ export class WuLoadingStrategy {
|
|
|
166
168
|
return priorityOrder[aPriority] - priorityOrder[bPriority];
|
|
167
169
|
});
|
|
168
170
|
|
|
169
|
-
|
|
171
|
+
logger.debug(`[WuStrategies] Preloading ${toPreload.length} apps`);
|
|
170
172
|
|
|
171
173
|
// Precargar en orden
|
|
172
174
|
for (const app of toPreload) {
|
|
@@ -219,7 +221,7 @@ export class WuLoadingStrategy {
|
|
|
219
221
|
if (app) {
|
|
220
222
|
const moduleUrl = await this.core.resolveModulePath(app);
|
|
221
223
|
await import(/* @vite-ignore */ moduleUrl);
|
|
222
|
-
|
|
224
|
+
logger.debug(`[Strategy:Idle] β
${item.appName} loaded during idle time`);
|
|
223
225
|
item.resolve(true);
|
|
224
226
|
} else {
|
|
225
227
|
item.resolve(null);
|
|
@@ -249,6 +251,6 @@ export class WuLoadingStrategy {
|
|
|
249
251
|
*/
|
|
250
252
|
cleanup() {
|
|
251
253
|
this.loadingQueue = [];
|
|
252
|
-
|
|
254
|
+
logger.debug('[WuStrategies] π§Ή Strategies cleaned up');
|
|
253
255
|
}
|
|
254
256
|
}
|
|
@@ -3,12 +3,14 @@
|
|
|
3
3
|
* Maneja imports/exports entre micro-apps
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
import { logger } from '../core/wu-logger.js';
|
|
7
|
+
|
|
6
8
|
export class WuDependencyResolver {
|
|
7
9
|
constructor() {
|
|
8
10
|
this.resolvedComponents = new Map();
|
|
9
11
|
this.pendingResolutions = new Map();
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
logger.debug('[WuDependencyResolver] π Dependency resolver initialized');
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
/**
|
|
@@ -18,7 +20,7 @@ export class WuDependencyResolver {
|
|
|
18
20
|
* @returns {Map} Componentes resueltos
|
|
19
21
|
*/
|
|
20
22
|
async resolveAll(imports, availableApps) {
|
|
21
|
-
|
|
23
|
+
logger.debug(`[WuDependencyResolver] π Resolving ${imports.length} dependencies...`);
|
|
22
24
|
|
|
23
25
|
const resolved = new Map();
|
|
24
26
|
const errors = [];
|
|
@@ -27,18 +29,18 @@ export class WuDependencyResolver {
|
|
|
27
29
|
try {
|
|
28
30
|
const component = await this.resolve(importPath, availableApps);
|
|
29
31
|
resolved.set(importPath, component);
|
|
30
|
-
|
|
32
|
+
logger.debug(`[WuDependencyResolver] β
Resolved: ${importPath}`);
|
|
31
33
|
} catch (error) {
|
|
32
34
|
errors.push({ import: importPath, error: error.message });
|
|
33
|
-
|
|
35
|
+
logger.warn(`[WuDependencyResolver] β Failed to resolve: ${importPath}`, error);
|
|
34
36
|
}
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
if (errors.length > 0) {
|
|
38
|
-
|
|
40
|
+
logger.warn(`[WuDependencyResolver] β οΈ ${errors.length} dependencies failed to resolve:`, errors);
|
|
39
41
|
}
|
|
40
42
|
|
|
41
|
-
|
|
43
|
+
logger.debug(`[WuDependencyResolver] π Resolved ${resolved.size}/${imports.length} dependencies`);
|
|
42
44
|
return resolved;
|
|
43
45
|
}
|
|
44
46
|
|
|
@@ -51,13 +53,13 @@ export class WuDependencyResolver {
|
|
|
51
53
|
async resolve(importPath, availableApps) {
|
|
52
54
|
// Verificar cache
|
|
53
55
|
if (this.resolvedComponents.has(importPath)) {
|
|
54
|
-
|
|
56
|
+
logger.debug(`[WuDependencyResolver] β‘ Cache hit: ${importPath}`);
|
|
55
57
|
return this.resolvedComponents.get(importPath);
|
|
56
58
|
}
|
|
57
59
|
|
|
58
60
|
// Verificar si ya estΓ‘ resolviendo
|
|
59
61
|
if (this.pendingResolutions.has(importPath)) {
|
|
60
|
-
|
|
62
|
+
logger.debug(`[WuDependencyResolver] β³ Waiting for pending resolution: ${importPath}`);
|
|
61
63
|
return await this.pendingResolutions.get(importPath);
|
|
62
64
|
}
|
|
63
65
|
|
|
@@ -269,7 +271,7 @@ export class WuDependencyResolver {
|
|
|
269
271
|
*/
|
|
270
272
|
createComponentWrapper(component, importPath) {
|
|
271
273
|
return function WuSharedComponent(props) {
|
|
272
|
-
|
|
274
|
+
logger.debug(`[WuDependencyResolver] π§© Rendering shared component: ${importPath}`);
|
|
273
275
|
|
|
274
276
|
try {
|
|
275
277
|
return component(props);
|
|
@@ -304,12 +306,12 @@ export class WuDependencyResolver {
|
|
|
304
306
|
for (const [importPath] of this.resolvedComponents) {
|
|
305
307
|
if (regex.test(importPath)) {
|
|
306
308
|
this.resolvedComponents.delete(importPath);
|
|
307
|
-
|
|
309
|
+
logger.debug(`[WuDependencyResolver] ποΈ Cleared cache for: ${importPath}`);
|
|
308
310
|
}
|
|
309
311
|
}
|
|
310
312
|
} else {
|
|
311
313
|
this.resolvedComponents.clear();
|
|
312
|
-
|
|
314
|
+
logger.debug(`[WuDependencyResolver] ποΈ Dependency cache cleared completely`);
|
|
313
315
|
}
|
|
314
316
|
}
|
|
315
317
|
|