wu-framework 1.1.8 β 1.1.9
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 +19 -1
- package/README.md +227 -626
- package/dist/wu-framework.cjs.js +1 -1
- package/dist/wu-framework.cjs.js.map +1 -1
- package/dist/wu-framework.dev.js +2988 -1076
- 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 +10 -4
- package/src/adapters/react/index.js +51 -46
- package/src/ai/wu-ai-agent.js +546 -0
- package/src/ai/wu-ai-browser-primitives.js +354 -0
- package/src/ai/wu-ai-browser.js +29 -312
- package/src/ai/wu-ai-conversation.js +143 -84
- package/src/ai/wu-ai-orchestrate.js +1021 -0
- package/src/ai/wu-ai-provider.js +105 -10
- package/src/ai/wu-ai.js +338 -8
- package/src/core/wu-cache.js +1 -2
- package/src/core/wu-core.js +3 -4
- package/src/core/wu-mcp-bridge.js +198 -414
- package/src/core/wu-plugin.js +4 -1
- package/src/core/wu-style-bridge.js +23 -21
- package/src/index.js +25 -2
package/src/core/wu-plugin.js
CHANGED
|
@@ -334,10 +334,13 @@ export const createPlugin = (config) => {
|
|
|
334
334
|
permissions: config.permissions || ['events'],
|
|
335
335
|
install: config.install,
|
|
336
336
|
uninstall: config.uninstall,
|
|
337
|
+
beforeInit: config.beforeInit,
|
|
338
|
+
afterInit: config.afterInit,
|
|
337
339
|
beforeMount: config.beforeMount,
|
|
338
340
|
afterMount: config.afterMount,
|
|
339
341
|
beforeUnmount: config.beforeUnmount,
|
|
340
342
|
afterUnmount: config.afterUnmount,
|
|
341
|
-
onError: config.onError
|
|
343
|
+
onError: config.onError,
|
|
344
|
+
onDestroy: config.onDestroy
|
|
342
345
|
};
|
|
343
346
|
};
|
|
@@ -28,6 +28,8 @@
|
|
|
28
28
|
* - Riesgo de colisiones: NINGUNO
|
|
29
29
|
*/
|
|
30
30
|
|
|
31
|
+
import { logger } from './wu-logger.js';
|
|
32
|
+
|
|
31
33
|
export class WuStyleBridge {
|
|
32
34
|
constructor() {
|
|
33
35
|
this.styleObserver = null;
|
|
@@ -56,7 +58,7 @@ export class WuStyleBridge {
|
|
|
56
58
|
cacheEnabled: true
|
|
57
59
|
};
|
|
58
60
|
|
|
59
|
-
|
|
61
|
+
logger.debug('[WuStyleBridge] π¨ Style sharing system initialized');
|
|
60
62
|
}
|
|
61
63
|
|
|
62
64
|
/**
|
|
@@ -66,7 +68,7 @@ export class WuStyleBridge {
|
|
|
66
68
|
*/
|
|
67
69
|
registerFullyIsolatedApp(appName, appUrl) {
|
|
68
70
|
this.fullyIsolatedApps.set(appName, appUrl);
|
|
69
|
-
|
|
71
|
+
logger.debug(`[WuStyleBridge] π‘οΈ Registered fully-isolated app: ${appName} (${appUrl})`);
|
|
70
72
|
}
|
|
71
73
|
|
|
72
74
|
/**
|
|
@@ -164,7 +166,7 @@ export class WuStyleBridge {
|
|
|
164
166
|
|
|
165
167
|
// Filtrar estilos de apps con fully-isolated (despuΓ©s de obtener viteId para mejor detecciΓ³n)
|
|
166
168
|
if (this.isStyleFromFullyIsolatedApp(style) || (viteId && this.isStyleFromFullyIsolatedApp(viteId))) {
|
|
167
|
-
|
|
169
|
+
logger.debug(`[WuStyleBridge] π‘οΈ Filtered out style from fully-isolated app: ${viteId || 'unknown'}`);
|
|
168
170
|
return;
|
|
169
171
|
}
|
|
170
172
|
|
|
@@ -192,7 +194,7 @@ export class WuStyleBridge {
|
|
|
192
194
|
});
|
|
193
195
|
}
|
|
194
196
|
|
|
195
|
-
|
|
197
|
+
logger.debug(`[WuStyleBridge] π Detected ${styles.length} shareable styles`);
|
|
196
198
|
return styles;
|
|
197
199
|
}
|
|
198
200
|
|
|
@@ -248,26 +250,26 @@ export class WuStyleBridge {
|
|
|
248
250
|
*/
|
|
249
251
|
async injectStylesIntoShadow(shadowRoot, appName, styleMode) {
|
|
250
252
|
if (!shadowRoot) {
|
|
251
|
-
|
|
253
|
+
logger.warn('[WuStyleBridge] β οΈ No shadow root provided');
|
|
252
254
|
return 0;
|
|
253
255
|
}
|
|
254
256
|
|
|
255
257
|
// π‘οΈ MODO FULLY-ISOLATED: No inyectar ningΓΊn estilo compartido
|
|
256
258
|
// Los estilos propios se manejan en wu-sandbox.js con injectOwnStylesToShadow
|
|
257
259
|
if (styleMode === 'fully-isolated') {
|
|
258
|
-
|
|
260
|
+
logger.debug(`[WuStyleBridge] π‘οΈ Style mode "fully-isolated" for ${appName}, skipping shared style injection`);
|
|
259
261
|
return 0;
|
|
260
262
|
}
|
|
261
263
|
|
|
262
264
|
// π MODO ISOLATED: No inyectar estilos externos - usar encapsulamiento nativo de Shadow DOM
|
|
263
265
|
// La app debe manejar sus propios estilos (CSS-in-JS, scoped styles, imports directos)
|
|
264
266
|
if (styleMode === 'isolated') {
|
|
265
|
-
|
|
267
|
+
logger.debug(`[WuStyleBridge] π Style mode "isolated" for ${appName}, using native Shadow DOM encapsulation (no external styles)`);
|
|
266
268
|
return 0;
|
|
267
269
|
}
|
|
268
270
|
|
|
269
271
|
// π MODO SHARED (default): Inyectar todos los estilos compartidos del documento
|
|
270
|
-
|
|
272
|
+
logger.debug(`[WuStyleBridge] π Style mode "shared" for ${appName}, injecting all shared styles...`);
|
|
271
273
|
|
|
272
274
|
// Detectar estilos del documento
|
|
273
275
|
const styles = this.detectDocumentStyles();
|
|
@@ -293,11 +295,11 @@ export class WuStyleBridge {
|
|
|
293
295
|
break;
|
|
294
296
|
}
|
|
295
297
|
} catch (error) {
|
|
296
|
-
|
|
298
|
+
logger.warn(`[WuStyleBridge] β οΈ Failed to inject style:`, error);
|
|
297
299
|
}
|
|
298
300
|
}
|
|
299
301
|
|
|
300
|
-
|
|
302
|
+
logger.debug(`[WuStyleBridge] β
Injected ${injectedCount} shared styles into ${appName}`);
|
|
301
303
|
return injectedCount;
|
|
302
304
|
}
|
|
303
305
|
|
|
@@ -310,7 +312,7 @@ export class WuStyleBridge {
|
|
|
310
312
|
// Verificar si ya existe
|
|
311
313
|
const existing = shadowRoot.querySelector(`link[href="${style.href}"]`);
|
|
312
314
|
if (existing) {
|
|
313
|
-
|
|
315
|
+
logger.debug(`[WuStyleBridge] βοΈ Style already exists: ${style.library || style.href}`);
|
|
314
316
|
return;
|
|
315
317
|
}
|
|
316
318
|
|
|
@@ -324,7 +326,7 @@ export class WuStyleBridge {
|
|
|
324
326
|
// Insertar al principio del shadow root (antes de otros estilos)
|
|
325
327
|
shadowRoot.insertBefore(link, shadowRoot.firstChild);
|
|
326
328
|
|
|
327
|
-
|
|
329
|
+
logger.debug(`[WuStyleBridge] π Injected link: ${style.library || style.href}`);
|
|
328
330
|
}
|
|
329
331
|
|
|
330
332
|
/**
|
|
@@ -338,7 +340,7 @@ export class WuStyleBridge {
|
|
|
338
340
|
if (viteId) {
|
|
339
341
|
const existing = shadowRoot.querySelector(`style[data-wu-vite-id="${viteId}"]`);
|
|
340
342
|
if (existing) {
|
|
341
|
-
|
|
343
|
+
logger.debug(`[WuStyleBridge] βοΈ Inline style already exists: ${viteId}`);
|
|
342
344
|
return;
|
|
343
345
|
}
|
|
344
346
|
}
|
|
@@ -355,7 +357,7 @@ export class WuStyleBridge {
|
|
|
355
357
|
// Insertar al principio del shadow root
|
|
356
358
|
shadowRoot.insertBefore(styleTag, shadowRoot.firstChild);
|
|
357
359
|
|
|
358
|
-
|
|
360
|
+
logger.debug(`[WuStyleBridge] π Injected inline style: ${style.library || viteId}`);
|
|
359
361
|
}
|
|
360
362
|
|
|
361
363
|
/**
|
|
@@ -372,7 +374,7 @@ export class WuStyleBridge {
|
|
|
372
374
|
|
|
373
375
|
// Verificar si ya existe
|
|
374
376
|
if (shadowRoot.adoptedStyleSheets.includes(style.sheet)) {
|
|
375
|
-
|
|
377
|
+
logger.debug(`[WuStyleBridge] βοΈ Adopted stylesheet already exists`);
|
|
376
378
|
return;
|
|
377
379
|
}
|
|
378
380
|
|
|
@@ -381,9 +383,9 @@ export class WuStyleBridge {
|
|
|
381
383
|
style.sheet
|
|
382
384
|
];
|
|
383
385
|
|
|
384
|
-
|
|
386
|
+
logger.debug(`[WuStyleBridge] π Injected adopted stylesheet`);
|
|
385
387
|
} catch (error) {
|
|
386
|
-
|
|
388
|
+
logger.warn(`[WuStyleBridge] β οΈ Failed to inject adopted stylesheet:`, error);
|
|
387
389
|
}
|
|
388
390
|
}
|
|
389
391
|
|
|
@@ -417,7 +419,7 @@ export class WuStyleBridge {
|
|
|
417
419
|
}
|
|
418
420
|
|
|
419
421
|
if (hasStyleChanges && callback) {
|
|
420
|
-
|
|
422
|
+
logger.debug('[WuStyleBridge] π Style changes detected');
|
|
421
423
|
callback();
|
|
422
424
|
}
|
|
423
425
|
});
|
|
@@ -428,7 +430,7 @@ export class WuStyleBridge {
|
|
|
428
430
|
subtree: true
|
|
429
431
|
});
|
|
430
432
|
|
|
431
|
-
|
|
433
|
+
logger.debug('[WuStyleBridge] π Observing style changes');
|
|
432
434
|
}
|
|
433
435
|
|
|
434
436
|
/**
|
|
@@ -441,7 +443,7 @@ export class WuStyleBridge {
|
|
|
441
443
|
...config
|
|
442
444
|
};
|
|
443
445
|
|
|
444
|
-
|
|
446
|
+
logger.debug('[WuStyleBridge] βοΈ Configuration updated:', this.config);
|
|
445
447
|
}
|
|
446
448
|
|
|
447
449
|
/**
|
|
@@ -453,7 +455,7 @@ export class WuStyleBridge {
|
|
|
453
455
|
this.styleObserver = null;
|
|
454
456
|
}
|
|
455
457
|
|
|
456
|
-
|
|
458
|
+
logger.debug('[WuStyleBridge] π§Ή StyleBridge cleaned up');
|
|
457
459
|
}
|
|
458
460
|
|
|
459
461
|
/**
|
package/src/index.js
CHANGED
|
@@ -90,12 +90,12 @@ if (typeof window !== 'undefined') {
|
|
|
90
90
|
if (!wu.mcp) {
|
|
91
91
|
let _mcpBridge = null;
|
|
92
92
|
wu.mcp = {
|
|
93
|
-
async connect(url = 'ws://localhost:19100') {
|
|
93
|
+
async connect(url = 'ws://localhost:19100', options = {}) {
|
|
94
94
|
if (!_mcpBridge) {
|
|
95
95
|
const { createMcpBridge } = await import('./core/wu-mcp-bridge.js');
|
|
96
96
|
_mcpBridge = createMcpBridge(wu);
|
|
97
97
|
}
|
|
98
|
-
_mcpBridge.connect(url);
|
|
98
|
+
_mcpBridge.connect(url, options);
|
|
99
99
|
},
|
|
100
100
|
disconnect() {
|
|
101
101
|
_mcpBridge?.disconnect();
|
|
@@ -193,9 +193,32 @@ export { WuAIContext } from './ai/wu-ai-context.js';
|
|
|
193
193
|
export { WuAIActions } from './ai/wu-ai-actions.js';
|
|
194
194
|
export { WuAIConversation } from './ai/wu-ai-conversation.js';
|
|
195
195
|
export { WuAITriggers } from './ai/wu-ai-triggers.js';
|
|
196
|
+
export { WuAIAgent } from './ai/wu-ai-agent.js';
|
|
197
|
+
export { WuAIOrchestrate } from './ai/wu-ai-orchestrate.js';
|
|
198
|
+
export {
|
|
199
|
+
sanitizeForPrompt,
|
|
200
|
+
redactSensitive,
|
|
201
|
+
interpolate,
|
|
202
|
+
buildToolSchemas,
|
|
203
|
+
normalizeParameters,
|
|
204
|
+
validateParams,
|
|
205
|
+
estimateTokens,
|
|
206
|
+
truncateToTokenBudget,
|
|
207
|
+
} from './ai/wu-ai-schema.js';
|
|
196
208
|
|
|
197
209
|
// --- MCP Bridge (browser-side connection to wu-mcp-server) ---
|
|
198
210
|
export { createMcpBridge } from './core/wu-mcp-bridge.js';
|
|
199
211
|
|
|
200
212
|
// --- AI Browser Actions (autonomous agent control) ---
|
|
201
213
|
export { registerBrowserActions } from './ai/wu-ai-browser.js';
|
|
214
|
+
|
|
215
|
+
// --- AI Browser Primitives (shared browser automation functions) ---
|
|
216
|
+
export {
|
|
217
|
+
ensureInterceptors,
|
|
218
|
+
captureScreenshot,
|
|
219
|
+
buildA11yTree,
|
|
220
|
+
clickElement,
|
|
221
|
+
typeIntoElement,
|
|
222
|
+
getFilteredNetwork,
|
|
223
|
+
getFilteredConsole,
|
|
224
|
+
} from './ai/wu-ai-browser-primitives.js';
|