wu-framework 1.1.14 → 1.1.16

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 (90) hide show
  1. package/LICENSE +39 -39
  2. package/README.md +408 -408
  3. package/dist/wu-framework.cjs.js.map +1 -1
  4. package/dist/wu-framework.dev.js +15151 -15151
  5. package/dist/wu-framework.dev.js.map +1 -1
  6. package/dist/wu-framework.esm.js.map +1 -1
  7. package/dist/wu-framework.umd.js.map +1 -1
  8. package/integrations/astro/README.md +127 -127
  9. package/integrations/astro/WuApp.astro +63 -63
  10. package/integrations/astro/WuShell.astro +39 -39
  11. package/integrations/astro/index.js +68 -68
  12. package/integrations/astro/package.json +38 -38
  13. package/integrations/astro/types.d.ts +53 -53
  14. package/package.json +161 -161
  15. package/src/adapters/angular/ai.js +30 -30
  16. package/src/adapters/angular/index.d.ts +154 -154
  17. package/src/adapters/angular/index.js +932 -932
  18. package/src/adapters/angular.d.ts +3 -3
  19. package/src/adapters/angular.js +3 -3
  20. package/src/adapters/index.js +168 -168
  21. package/src/adapters/lit/ai.js +20 -20
  22. package/src/adapters/lit/index.d.ts +120 -120
  23. package/src/adapters/lit/index.js +721 -721
  24. package/src/adapters/lit.d.ts +3 -3
  25. package/src/adapters/lit.js +3 -3
  26. package/src/adapters/preact/ai.js +33 -33
  27. package/src/adapters/preact/index.d.ts +108 -108
  28. package/src/adapters/preact/index.js +661 -661
  29. package/src/adapters/preact.d.ts +3 -3
  30. package/src/adapters/preact.js +3 -3
  31. package/src/adapters/react/index.js +48 -54
  32. package/src/adapters/react.d.ts +3 -3
  33. package/src/adapters/react.js +3 -3
  34. package/src/adapters/shared.js +64 -64
  35. package/src/adapters/solid/ai.js +32 -32
  36. package/src/adapters/solid/index.d.ts +101 -101
  37. package/src/adapters/solid/index.js +586 -586
  38. package/src/adapters/solid.d.ts +3 -3
  39. package/src/adapters/solid.js +3 -3
  40. package/src/adapters/svelte/ai.js +31 -31
  41. package/src/adapters/svelte/index.d.ts +166 -166
  42. package/src/adapters/svelte/index.js +798 -798
  43. package/src/adapters/svelte.d.ts +3 -3
  44. package/src/adapters/svelte.js +3 -3
  45. package/src/adapters/vanilla/ai.js +30 -30
  46. package/src/adapters/vanilla/index.d.ts +179 -179
  47. package/src/adapters/vanilla/index.js +785 -785
  48. package/src/adapters/vanilla.d.ts +3 -3
  49. package/src/adapters/vanilla.js +3 -3
  50. package/src/adapters/vue/ai.js +52 -52
  51. package/src/adapters/vue/index.d.ts +299 -299
  52. package/src/adapters/vue/index.js +610 -610
  53. package/src/adapters/vue.d.ts +3 -3
  54. package/src/adapters/vue.js +3 -3
  55. package/src/ai/wu-ai-actions.js +261 -261
  56. package/src/ai/wu-ai-agent.js +546 -546
  57. package/src/ai/wu-ai-browser-primitives.js +354 -354
  58. package/src/ai/wu-ai-browser.js +380 -380
  59. package/src/ai/wu-ai-context.js +332 -332
  60. package/src/ai/wu-ai-conversation.js +613 -613
  61. package/src/ai/wu-ai-orchestrate.js +1021 -1021
  62. package/src/ai/wu-ai-permissions.js +381 -381
  63. package/src/ai/wu-ai-provider.js +700 -700
  64. package/src/ai/wu-ai-schema.js +225 -225
  65. package/src/ai/wu-ai-triggers.js +396 -396
  66. package/src/ai/wu-ai.js +804 -804
  67. package/src/core/wu-app.js +236 -236
  68. package/src/core/wu-cache.js +477 -477
  69. package/src/core/wu-core.js +1398 -1398
  70. package/src/core/wu-error-boundary.js +382 -382
  71. package/src/core/wu-event-bus.js +348 -348
  72. package/src/core/wu-hooks.js +350 -350
  73. package/src/core/wu-html-parser.js +190 -190
  74. package/src/core/wu-iframe-sandbox.js +328 -328
  75. package/src/core/wu-loader.js +272 -272
  76. package/src/core/wu-logger.js +134 -134
  77. package/src/core/wu-manifest.js +509 -509
  78. package/src/core/wu-mcp-bridge.js +432 -432
  79. package/src/core/wu-overrides.js +510 -510
  80. package/src/core/wu-performance.js +228 -228
  81. package/src/core/wu-plugin.js +348 -348
  82. package/src/core/wu-prefetch.js +414 -414
  83. package/src/core/wu-proxy-sandbox.js +476 -476
  84. package/src/core/wu-sandbox.js +779 -779
  85. package/src/core/wu-script-executor.js +113 -113
  86. package/src/core/wu-snapshot-sandbox.js +227 -227
  87. package/src/core/wu-strategies.js +256 -256
  88. package/src/core/wu-style-bridge.js +477 -477
  89. package/src/index.js +224 -224
  90. package/src/utils/dependency-resolver.js +327 -327
@@ -1,228 +1,228 @@
1
- /**
2
- * ⚡ WU-PERFORMANCE: MICROFRONTEND LIFECYCLE MONITORING
3
- *
4
- * Monitoreo de performance específico para operaciones del framework:
5
- * - Tiempos de mount/unmount
6
- * - Tiempos de carga de módulos
7
- * - Estadísticas por app
8
- */
9
-
10
- import { logger } from './wu-logger.js';
11
-
12
- export class WuPerformance {
13
- constructor() {
14
- this.metrics = new Map(); // appName -> metrics
15
- this.measurements = [];
16
- this.marks = new Map();
17
-
18
- this.config = {
19
- enabled: true,
20
- maxMeasurements: 1000
21
- };
22
-
23
- this.thresholds = {
24
- mount: 3000, // ms
25
- unmount: 1000, // ms
26
- load: 5000 // ms
27
- };
28
-
29
- logger.debug('[WuPerformance] ⚡ Framework performance monitoring initialized');
30
- }
31
-
32
- /**
33
- * 📊 START MEASURE: Iniciar medición
34
- * @param {string} name - Nombre de la medición
35
- * @param {string} appName - Nombre de la app (opcional)
36
- */
37
- startMeasure(name, appName = 'global') {
38
- const markName = `${appName}:${name}:start`;
39
- this.marks.set(markName, performance.now());
40
-
41
- logger.debug(`[WuPerformance] 📊 Measure started: ${markName}`);
42
- }
43
-
44
- /**
45
- * ⏹️ END MEASURE: Finalizar medición
46
- * @param {string} name - Nombre de la medición
47
- * @param {string} appName - Nombre de la app (opcional)
48
- * @returns {number} Duración en ms
49
- */
50
- endMeasure(name, appName = 'global') {
51
- const markName = `${appName}:${name}:start`;
52
- const startTime = this.marks.get(markName);
53
-
54
- if (!startTime) {
55
- // Puede ocurrir en React StrictMode (doble mount) — no es un error
56
- return 0;
57
- }
58
-
59
- const duration = performance.now() - startTime;
60
- this.marks.delete(markName);
61
-
62
- // Registrar medición
63
- this.recordMeasurement({
64
- name,
65
- appName,
66
- duration,
67
- timestamp: Date.now(),
68
- type: 'duration'
69
- });
70
-
71
- // Verificar threshold
72
- if (this.checkThreshold(name, duration)) {
73
- logger.warn(`[WuPerformance] ⚠️ Threshold exceeded for ${name}: ${duration.toFixed(2)}ms`);
74
- }
75
-
76
- logger.debug(`[WuPerformance] ⏹️ Measure ended: ${markName} (${duration.toFixed(2)}ms)`);
77
- return duration;
78
- }
79
-
80
- /**
81
- * 📝 RECORD MEASUREMENT: Registrar medición
82
- * @param {Object} measurement - Medición
83
- */
84
- recordMeasurement(measurement) {
85
- this.measurements.push(measurement);
86
-
87
- // Mantener tamaño máximo
88
- if (this.measurements.length > this.config.maxMeasurements) {
89
- this.measurements.shift();
90
- }
91
-
92
- // Actualizar métricas de la app
93
- if (!this.metrics.has(measurement.appName)) {
94
- this.metrics.set(measurement.appName, {
95
- appName: measurement.appName,
96
- measurements: [],
97
- stats: {}
98
- });
99
- }
100
-
101
- const appMetrics = this.metrics.get(measurement.appName);
102
- appMetrics.measurements.push(measurement);
103
-
104
- // Calcular estadísticas
105
- this.calculateStats(measurement.appName);
106
- }
107
-
108
- /**
109
- * 📊 CALCULATE STATS: Calcular estadísticas
110
- * @param {string} appName - Nombre de la app
111
- */
112
- calculateStats(appName) {
113
- const appMetrics = this.metrics.get(appName);
114
- if (!appMetrics) return;
115
-
116
- const measurements = appMetrics.measurements;
117
- if (measurements.length === 0) return;
118
-
119
- // Agrupar por tipo de medición
120
- const byType = {};
121
- measurements.forEach(m => {
122
- if (!byType[m.name]) byType[m.name] = [];
123
- byType[m.name].push(m.duration);
124
- });
125
-
126
- // Calcular estadísticas para cada tipo
127
- appMetrics.stats = {};
128
- Object.entries(byType).forEach(([name, durations]) => {
129
- appMetrics.stats[name] = {
130
- count: durations.length,
131
- avg: durations.reduce((a, b) => a + b, 0) / durations.length,
132
- min: Math.min(...durations),
133
- max: Math.max(...durations),
134
- last: durations[durations.length - 1]
135
- };
136
- });
137
- }
138
-
139
- /**
140
- * 🎯 CHECK THRESHOLD: Verificar si se excedió threshold
141
- * @param {string} name - Nombre de la medición
142
- * @param {number} value - Valor
143
- * @returns {boolean}
144
- */
145
- checkThreshold(name, value) {
146
- const threshold = this.thresholds[name];
147
- return threshold && value > threshold;
148
- }
149
-
150
- /**
151
- * 📊 GENERATE REPORT: Generar reporte de performance del framework
152
- * @returns {Object}
153
- */
154
- generateReport() {
155
- const report = {
156
- timestamp: Date.now(),
157
- totalMeasurements: this.measurements.length,
158
- apps: {}
159
- };
160
-
161
- // Agregar métricas por app
162
- for (const [appName, metrics] of this.metrics) {
163
- report.apps[appName] = {
164
- measurementCount: metrics.measurements.length,
165
- stats: metrics.stats
166
- };
167
- }
168
-
169
- return report;
170
- }
171
-
172
- /**
173
- * 📋 GET METRICS: Obtener métricas de una app
174
- * @param {string} appName - Nombre de la app
175
- * @returns {Object}
176
- */
177
- getMetrics(appName) {
178
- return this.metrics.get(appName) || null;
179
- }
180
-
181
- /**
182
- * 📊 GET ALL METRICS: Obtener todas las métricas
183
- * @returns {Object}
184
- */
185
- getAllMetrics() {
186
- const allMetrics = {};
187
-
188
- for (const [appName, metrics] of this.metrics) {
189
- allMetrics[appName] = metrics;
190
- }
191
-
192
- return allMetrics;
193
- }
194
-
195
- /**
196
- * 🧹 CLEAR METRICS: Limpiar métricas
197
- * @param {string} appName - Nombre de la app (opcional)
198
- */
199
- clearMetrics(appName) {
200
- if (appName) {
201
- this.metrics.delete(appName);
202
- this.measurements = this.measurements.filter(m => m.appName !== appName);
203
- } else {
204
- this.metrics.clear();
205
- this.measurements = [];
206
- }
207
-
208
- logger.debug(`[WuPerformance] 🧹 Metrics cleared${appName ? ` for ${appName}` : ''}`);
209
- }
210
-
211
- /**
212
- * ⚙️ CONFIGURE: Configurar performance monitor
213
- * @param {Object} config - Nueva configuración
214
- */
215
- configure(config) {
216
- this.config = {
217
- ...this.config,
218
- ...config
219
- };
220
-
221
- if (config.thresholds) {
222
- this.thresholds = {
223
- ...this.thresholds,
224
- ...config.thresholds
225
- };
226
- }
227
- }
228
- }
1
+ /**
2
+ * ⚡ WU-PERFORMANCE: MICROFRONTEND LIFECYCLE MONITORING
3
+ *
4
+ * Monitoreo de performance específico para operaciones del framework:
5
+ * - Tiempos de mount/unmount
6
+ * - Tiempos de carga de módulos
7
+ * - Estadísticas por app
8
+ */
9
+
10
+ import { logger } from './wu-logger.js';
11
+
12
+ export class WuPerformance {
13
+ constructor() {
14
+ this.metrics = new Map(); // appName -> metrics
15
+ this.measurements = [];
16
+ this.marks = new Map();
17
+
18
+ this.config = {
19
+ enabled: true,
20
+ maxMeasurements: 1000
21
+ };
22
+
23
+ this.thresholds = {
24
+ mount: 3000, // ms
25
+ unmount: 1000, // ms
26
+ load: 5000 // ms
27
+ };
28
+
29
+ logger.debug('[WuPerformance] ⚡ Framework performance monitoring initialized');
30
+ }
31
+
32
+ /**
33
+ * 📊 START MEASURE: Iniciar medición
34
+ * @param {string} name - Nombre de la medición
35
+ * @param {string} appName - Nombre de la app (opcional)
36
+ */
37
+ startMeasure(name, appName = 'global') {
38
+ const markName = `${appName}:${name}:start`;
39
+ this.marks.set(markName, performance.now());
40
+
41
+ logger.debug(`[WuPerformance] 📊 Measure started: ${markName}`);
42
+ }
43
+
44
+ /**
45
+ * ⏹️ END MEASURE: Finalizar medición
46
+ * @param {string} name - Nombre de la medición
47
+ * @param {string} appName - Nombre de la app (opcional)
48
+ * @returns {number} Duración en ms
49
+ */
50
+ endMeasure(name, appName = 'global') {
51
+ const markName = `${appName}:${name}:start`;
52
+ const startTime = this.marks.get(markName);
53
+
54
+ if (!startTime) {
55
+ // Puede ocurrir en React StrictMode (doble mount) — no es un error
56
+ return 0;
57
+ }
58
+
59
+ const duration = performance.now() - startTime;
60
+ this.marks.delete(markName);
61
+
62
+ // Registrar medición
63
+ this.recordMeasurement({
64
+ name,
65
+ appName,
66
+ duration,
67
+ timestamp: Date.now(),
68
+ type: 'duration'
69
+ });
70
+
71
+ // Verificar threshold
72
+ if (this.checkThreshold(name, duration)) {
73
+ logger.warn(`[WuPerformance] ⚠️ Threshold exceeded for ${name}: ${duration.toFixed(2)}ms`);
74
+ }
75
+
76
+ logger.debug(`[WuPerformance] ⏹️ Measure ended: ${markName} (${duration.toFixed(2)}ms)`);
77
+ return duration;
78
+ }
79
+
80
+ /**
81
+ * 📝 RECORD MEASUREMENT: Registrar medición
82
+ * @param {Object} measurement - Medición
83
+ */
84
+ recordMeasurement(measurement) {
85
+ this.measurements.push(measurement);
86
+
87
+ // Mantener tamaño máximo
88
+ if (this.measurements.length > this.config.maxMeasurements) {
89
+ this.measurements.shift();
90
+ }
91
+
92
+ // Actualizar métricas de la app
93
+ if (!this.metrics.has(measurement.appName)) {
94
+ this.metrics.set(measurement.appName, {
95
+ appName: measurement.appName,
96
+ measurements: [],
97
+ stats: {}
98
+ });
99
+ }
100
+
101
+ const appMetrics = this.metrics.get(measurement.appName);
102
+ appMetrics.measurements.push(measurement);
103
+
104
+ // Calcular estadísticas
105
+ this.calculateStats(measurement.appName);
106
+ }
107
+
108
+ /**
109
+ * 📊 CALCULATE STATS: Calcular estadísticas
110
+ * @param {string} appName - Nombre de la app
111
+ */
112
+ calculateStats(appName) {
113
+ const appMetrics = this.metrics.get(appName);
114
+ if (!appMetrics) return;
115
+
116
+ const measurements = appMetrics.measurements;
117
+ if (measurements.length === 0) return;
118
+
119
+ // Agrupar por tipo de medición
120
+ const byType = {};
121
+ measurements.forEach(m => {
122
+ if (!byType[m.name]) byType[m.name] = [];
123
+ byType[m.name].push(m.duration);
124
+ });
125
+
126
+ // Calcular estadísticas para cada tipo
127
+ appMetrics.stats = {};
128
+ Object.entries(byType).forEach(([name, durations]) => {
129
+ appMetrics.stats[name] = {
130
+ count: durations.length,
131
+ avg: durations.reduce((a, b) => a + b, 0) / durations.length,
132
+ min: Math.min(...durations),
133
+ max: Math.max(...durations),
134
+ last: durations[durations.length - 1]
135
+ };
136
+ });
137
+ }
138
+
139
+ /**
140
+ * 🎯 CHECK THRESHOLD: Verificar si se excedió threshold
141
+ * @param {string} name - Nombre de la medición
142
+ * @param {number} value - Valor
143
+ * @returns {boolean}
144
+ */
145
+ checkThreshold(name, value) {
146
+ const threshold = this.thresholds[name];
147
+ return threshold && value > threshold;
148
+ }
149
+
150
+ /**
151
+ * 📊 GENERATE REPORT: Generar reporte de performance del framework
152
+ * @returns {Object}
153
+ */
154
+ generateReport() {
155
+ const report = {
156
+ timestamp: Date.now(),
157
+ totalMeasurements: this.measurements.length,
158
+ apps: {}
159
+ };
160
+
161
+ // Agregar métricas por app
162
+ for (const [appName, metrics] of this.metrics) {
163
+ report.apps[appName] = {
164
+ measurementCount: metrics.measurements.length,
165
+ stats: metrics.stats
166
+ };
167
+ }
168
+
169
+ return report;
170
+ }
171
+
172
+ /**
173
+ * 📋 GET METRICS: Obtener métricas de una app
174
+ * @param {string} appName - Nombre de la app
175
+ * @returns {Object}
176
+ */
177
+ getMetrics(appName) {
178
+ return this.metrics.get(appName) || null;
179
+ }
180
+
181
+ /**
182
+ * 📊 GET ALL METRICS: Obtener todas las métricas
183
+ * @returns {Object}
184
+ */
185
+ getAllMetrics() {
186
+ const allMetrics = {};
187
+
188
+ for (const [appName, metrics] of this.metrics) {
189
+ allMetrics[appName] = metrics;
190
+ }
191
+
192
+ return allMetrics;
193
+ }
194
+
195
+ /**
196
+ * 🧹 CLEAR METRICS: Limpiar métricas
197
+ * @param {string} appName - Nombre de la app (opcional)
198
+ */
199
+ clearMetrics(appName) {
200
+ if (appName) {
201
+ this.metrics.delete(appName);
202
+ this.measurements = this.measurements.filter(m => m.appName !== appName);
203
+ } else {
204
+ this.metrics.clear();
205
+ this.measurements = [];
206
+ }
207
+
208
+ logger.debug(`[WuPerformance] 🧹 Metrics cleared${appName ? ` for ${appName}` : ''}`);
209
+ }
210
+
211
+ /**
212
+ * ⚙️ CONFIGURE: Configurar performance monitor
213
+ * @param {Object} config - Nueva configuración
214
+ */
215
+ configure(config) {
216
+ this.config = {
217
+ ...this.config,
218
+ ...config
219
+ };
220
+
221
+ if (config.thresholds) {
222
+ this.thresholds = {
223
+ ...this.thresholds,
224
+ ...config.thresholds
225
+ };
226
+ }
227
+ }
228
+ }