wu-framework 1.1.15 → 1.1.17

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 (88) hide show
  1. package/README.md +52 -20
  2. package/dist/wu-framework.cjs.js +1 -1
  3. package/dist/wu-framework.cjs.js.map +1 -1
  4. package/dist/wu-framework.dev.js +15511 -15146
  5. package/dist/wu-framework.dev.js.map +1 -1
  6. package/dist/wu-framework.esm.js +1 -1
  7. package/dist/wu-framework.esm.js.map +1 -1
  8. package/dist/wu-framework.umd.js +1 -1
  9. package/dist/wu-framework.umd.js.map +1 -1
  10. package/package.json +166 -161
  11. package/src/adapters/angular/ai.js +30 -30
  12. package/src/adapters/angular/index.d.ts +154 -154
  13. package/src/adapters/angular/index.js +932 -932
  14. package/src/adapters/angular.d.ts +3 -3
  15. package/src/adapters/angular.js +3 -3
  16. package/src/adapters/index.js +168 -168
  17. package/src/adapters/lit/ai.js +20 -20
  18. package/src/adapters/lit/index.d.ts +120 -120
  19. package/src/adapters/lit/index.js +721 -721
  20. package/src/adapters/lit.d.ts +3 -3
  21. package/src/adapters/lit.js +3 -3
  22. package/src/adapters/preact/ai.js +33 -33
  23. package/src/adapters/preact/index.d.ts +108 -108
  24. package/src/adapters/preact/index.js +661 -661
  25. package/src/adapters/preact.d.ts +3 -3
  26. package/src/adapters/preact.js +3 -3
  27. package/src/adapters/react/index.js +48 -54
  28. package/src/adapters/react.d.ts +3 -3
  29. package/src/adapters/react.js +3 -3
  30. package/src/adapters/shared.js +64 -64
  31. package/src/adapters/solid/ai.js +32 -32
  32. package/src/adapters/solid/index.d.ts +101 -101
  33. package/src/adapters/solid/index.js +586 -586
  34. package/src/adapters/solid.d.ts +3 -3
  35. package/src/adapters/solid.js +3 -3
  36. package/src/adapters/svelte/ai.js +31 -31
  37. package/src/adapters/svelte/index.d.ts +166 -166
  38. package/src/adapters/svelte/index.js +798 -798
  39. package/src/adapters/svelte.d.ts +3 -3
  40. package/src/adapters/svelte.js +3 -3
  41. package/src/adapters/vanilla/ai.js +30 -30
  42. package/src/adapters/vanilla/index.d.ts +179 -179
  43. package/src/adapters/vanilla/index.js +785 -785
  44. package/src/adapters/vanilla.d.ts +3 -3
  45. package/src/adapters/vanilla.js +3 -3
  46. package/src/adapters/vue/ai.js +52 -52
  47. package/src/adapters/vue/index.d.ts +299 -299
  48. package/src/adapters/vue/index.js +610 -610
  49. package/src/adapters/vue.d.ts +3 -3
  50. package/src/adapters/vue.js +3 -3
  51. package/src/ai/wu-ai-actions.js +261 -261
  52. package/src/ai/wu-ai-agent.js +546 -546
  53. package/src/ai/wu-ai-browser-primitives.js +354 -354
  54. package/src/ai/wu-ai-browser.js +380 -380
  55. package/src/ai/wu-ai-context.js +332 -332
  56. package/src/ai/wu-ai-conversation.js +613 -613
  57. package/src/ai/wu-ai-orchestrate.js +1021 -1021
  58. package/src/ai/wu-ai-permissions.js +381 -381
  59. package/src/ai/wu-ai-provider.js +700 -700
  60. package/src/ai/wu-ai-schema.js +225 -225
  61. package/src/ai/wu-ai-triggers.js +396 -396
  62. package/src/ai/wu-ai.js +804 -804
  63. package/src/core/wu-app.js +236 -236
  64. package/src/core/wu-cache.js +498 -477
  65. package/src/core/wu-core.js +1412 -1398
  66. package/src/core/wu-error-boundary.js +396 -382
  67. package/src/core/wu-event-bus.js +390 -348
  68. package/src/core/wu-hooks.js +350 -350
  69. package/src/core/wu-html-parser.js +199 -190
  70. package/src/core/wu-iframe-sandbox.js +328 -328
  71. package/src/core/wu-loader.js +385 -273
  72. package/src/core/wu-logger.js +142 -134
  73. package/src/core/wu-manifest.js +532 -509
  74. package/src/core/wu-mcp-bridge.js +432 -432
  75. package/src/core/wu-overrides.js +510 -510
  76. package/src/core/wu-performance.js +228 -228
  77. package/src/core/wu-plugin.js +401 -348
  78. package/src/core/wu-prefetch.js +414 -414
  79. package/src/core/wu-proxy-sandbox.js +477 -476
  80. package/src/core/wu-sandbox.js +779 -779
  81. package/src/core/wu-script-executor.js +161 -113
  82. package/src/core/wu-snapshot-sandbox.js +227 -227
  83. package/src/core/wu-store.js +13 -3
  84. package/src/core/wu-strategies.js +256 -256
  85. package/src/core/wu-style-bridge.js +477 -477
  86. package/src/index.d.ts +317 -0
  87. package/src/index.js +234 -224
  88. package/src/utils/dependency-resolver.js +327 -327
@@ -1,236 +1,236 @@
1
- /**
2
- * 🎯 WU-APP: SIMPLIFIED API WRAPPER
3
- *
4
- * Wrapper simple para uso declarativo de microfrontends
5
- * Mantiene todo el core de wu-framework pero simplifica el uso
6
- */
7
- import { logger } from './wu-logger.js';
8
-
9
-
10
- export class WuApp {
11
- /**
12
- * @param {string} name - Nombre de la app
13
- * @param {Object} config - Configuración de la app
14
- * @param {string} config.url - URL donde está corriendo la app
15
- * @param {string} [config.container] - Selector del contenedor (opcional)
16
- * @param {Object} wu - Instancia de WuCore
17
- */
18
- constructor(name, config, wu) {
19
- this.name = name
20
- this.url = config.url
21
- this.container = config.container
22
- this.keepAlive = config.keepAlive || false
23
- this._wu = wu
24
- this._mounted = false
25
- this._autoInit = config.autoInit !== false // Default true
26
-
27
- // Auto-register app in wu-framework
28
- if (this._autoInit) {
29
- this._registerApp()
30
- }
31
- }
32
-
33
- /**
34
- * Registrar app en wu-framework
35
- * @private
36
- */
37
- _registerApp() {
38
- if (!this._wu.apps.has(this.name)) {
39
- this._wu.apps.set(this.name, {
40
- name: this.name,
41
- url: this.url,
42
- keepAlive: this.keepAlive,
43
- status: 'registered'
44
- })
45
- logger.debug(`📦 App registered: ${this.name} at ${this.url}`)
46
- }
47
- }
48
-
49
- /**
50
- * Montar la app en el contenedor
51
- * @param {string} [container] - Selector del contenedor (opcional, usa config.container si no se pasa)
52
- * @returns {Promise<void>}
53
- */
54
- async mount(container) {
55
- const targetContainer = container || this.container
56
-
57
- if (!targetContainer) {
58
- throw new Error(`Container not specified for app: ${this.name}`)
59
- }
60
-
61
- // Asegurar que wu-framework está inicializado
62
- if (!this._wu.isInitialized) {
63
- await this._wu.init({
64
- apps: [{ name: this.name, url: this.url }]
65
- })
66
- }
67
-
68
- // Montar usando wu-framework core
69
- await this._wu.mount(this.name, targetContainer)
70
- this._mounted = true
71
-
72
- return this
73
- }
74
-
75
- /**
76
- * Desmontar la app.
77
- * If keepAlive is configured, hides instead of destroying.
78
- *
79
- * @param {Object} [options] - { keepAlive, force }
80
- * @returns {Promise<WuApp>}
81
- */
82
- async unmount(options = {}) {
83
- if (!this._mounted && !this._wu.isHidden(this.name)) {
84
- logger.warn(`⚠️ App ${this.name} is not mounted`)
85
- return this
86
- }
87
-
88
- await this._wu.unmount(this.name, options)
89
- this._mounted = !this._wu.isHidden(this.name)
90
-
91
- return this
92
- }
93
-
94
- /**
95
- * Hide the app (keep-alive). Preserves all state for instant re-show.
96
- * @returns {Promise<WuApp>}
97
- */
98
- async hide() {
99
- if (!this._mounted) {
100
- logger.warn(`⚠️ App ${this.name} is not mounted`)
101
- return this
102
- }
103
-
104
- await this._wu.hide(this.name)
105
- this._mounted = false
106
- return this
107
- }
108
-
109
- /**
110
- * Show a hidden (keep-alive) app instantly.
111
- * @returns {Promise<WuApp>}
112
- */
113
- async show() {
114
- if (!this._wu.isHidden(this.name)) {
115
- logger.warn(`⚠️ App ${this.name} is not in keep-alive state`)
116
- return this
117
- }
118
-
119
- await this._wu.show(this.name)
120
- this._mounted = true
121
- return this
122
- }
123
-
124
- /**
125
- * Remontar la app (útil para recargas)
126
- * @param {string} [container] - Selector del contenedor
127
- * @returns {Promise<void>}
128
- */
129
- async remount(container) {
130
- await this.unmount({ force: true })
131
- await this.mount(container)
132
- return this
133
- }
134
-
135
- /**
136
- * Verificar si la app está montada
137
- * @returns {boolean}
138
- */
139
- get isMounted() {
140
- return this._mounted && this._wu.mounted?.has(this.name)
141
- }
142
-
143
- /**
144
- * Check if the app is in keep-alive (hidden) state
145
- * @returns {boolean}
146
- */
147
- get isHidden() {
148
- return this._wu.isHidden(this.name)
149
- }
150
-
151
- /**
152
- * Obtener información de la app
153
- * @returns {Object}
154
- */
155
- get info() {
156
- return {
157
- name: this.name,
158
- url: this.url,
159
- container: this.container,
160
- mounted: this.isMounted,
161
- status: this._wu.apps.get(this.name)?.status || 'unknown'
162
- }
163
- }
164
-
165
- /**
166
- * Recargar la app (limpiar cache y remontar)
167
- * @returns {Promise<void>}
168
- */
169
- async reload() {
170
- logger.debug(`🔄 Reloading app: ${this.name}`)
171
-
172
- await this.unmount()
173
-
174
- // Limpiar caches
175
- if (this._wu.loader?.clearCache) {
176
- this._wu.loader.clearCache(this.name)
177
- }
178
- if (this._wu.manifest?.clearCache) {
179
- this._wu.manifest.clearCache(this.name)
180
- }
181
-
182
- await this.mount()
183
- logger.debug(`✅ App reloaded: ${this.name}`)
184
-
185
- return this
186
- }
187
-
188
- /**
189
- * Verificar el estado de la app
190
- * @returns {Object}
191
- */
192
- async verify() {
193
- const container = document.querySelector(this.container)
194
- const hasShadowDOM = container?.shadowRoot !== null
195
- const hasContent = (container?.shadowRoot?.children?.length || 0) > 0
196
-
197
- return {
198
- name: this.name,
199
- mounted: this.isMounted,
200
- container: {
201
- found: !!container,
202
- selector: this.container,
203
- hasShadowDOM,
204
- hasContent
205
- },
206
- wu: {
207
- registered: this._wu.apps.has(this.name),
208
- mountedInWu: this._wu.mounted?.has(this.name)
209
- }
210
- }
211
- }
212
-
213
- /**
214
- * Shorthand para mount
215
- */
216
- async start(container) {
217
- return await this.mount(container)
218
- }
219
-
220
- /**
221
- * Shorthand para unmount
222
- */
223
- async stop() {
224
- return await this.unmount()
225
- }
226
-
227
- /**
228
- * Destruir la app completamente
229
- */
230
- async destroy() {
231
- await this.unmount({ force: true })
232
- this._wu.apps.delete(this.name)
233
- this._mounted = false
234
- logger.debug(`🗑️ App destroyed: ${this.name}`)
235
- }
236
- }
1
+ /**
2
+ * 🎯 WU-APP: SIMPLIFIED API WRAPPER
3
+ *
4
+ * Wrapper simple para uso declarativo de microfrontends
5
+ * Mantiene todo el core de wu-framework pero simplifica el uso
6
+ */
7
+ import { logger } from './wu-logger.js';
8
+
9
+
10
+ export class WuApp {
11
+ /**
12
+ * @param {string} name - Nombre de la app
13
+ * @param {Object} config - Configuración de la app
14
+ * @param {string} config.url - URL donde está corriendo la app
15
+ * @param {string} [config.container] - Selector del contenedor (opcional)
16
+ * @param {Object} wu - Instancia de WuCore
17
+ */
18
+ constructor(name, config, wu) {
19
+ this.name = name
20
+ this.url = config.url
21
+ this.container = config.container
22
+ this.keepAlive = config.keepAlive || false
23
+ this._wu = wu
24
+ this._mounted = false
25
+ this._autoInit = config.autoInit !== false // Default true
26
+
27
+ // Auto-register app in wu-framework
28
+ if (this._autoInit) {
29
+ this._registerApp()
30
+ }
31
+ }
32
+
33
+ /**
34
+ * Registrar app en wu-framework
35
+ * @private
36
+ */
37
+ _registerApp() {
38
+ if (!this._wu.apps.has(this.name)) {
39
+ this._wu.apps.set(this.name, {
40
+ name: this.name,
41
+ url: this.url,
42
+ keepAlive: this.keepAlive,
43
+ status: 'registered'
44
+ })
45
+ logger.debug(`📦 App registered: ${this.name} at ${this.url}`)
46
+ }
47
+ }
48
+
49
+ /**
50
+ * Montar la app en el contenedor
51
+ * @param {string} [container] - Selector del contenedor (opcional, usa config.container si no se pasa)
52
+ * @returns {Promise<void>}
53
+ */
54
+ async mount(container) {
55
+ const targetContainer = container || this.container
56
+
57
+ if (!targetContainer) {
58
+ throw new Error(`Container not specified for app: ${this.name}`)
59
+ }
60
+
61
+ // Asegurar que wu-framework está inicializado
62
+ if (!this._wu.isInitialized) {
63
+ await this._wu.init({
64
+ apps: [{ name: this.name, url: this.url }]
65
+ })
66
+ }
67
+
68
+ // Montar usando wu-framework core
69
+ await this._wu.mount(this.name, targetContainer)
70
+ this._mounted = true
71
+
72
+ return this
73
+ }
74
+
75
+ /**
76
+ * Desmontar la app.
77
+ * If keepAlive is configured, hides instead of destroying.
78
+ *
79
+ * @param {Object} [options] - { keepAlive, force }
80
+ * @returns {Promise<WuApp>}
81
+ */
82
+ async unmount(options = {}) {
83
+ if (!this._mounted && !this._wu.isHidden(this.name)) {
84
+ logger.warn(`⚠️ App ${this.name} is not mounted`)
85
+ return this
86
+ }
87
+
88
+ await this._wu.unmount(this.name, options)
89
+ this._mounted = !this._wu.isHidden(this.name)
90
+
91
+ return this
92
+ }
93
+
94
+ /**
95
+ * Hide the app (keep-alive). Preserves all state for instant re-show.
96
+ * @returns {Promise<WuApp>}
97
+ */
98
+ async hide() {
99
+ if (!this._mounted) {
100
+ logger.warn(`⚠️ App ${this.name} is not mounted`)
101
+ return this
102
+ }
103
+
104
+ await this._wu.hide(this.name)
105
+ this._mounted = false
106
+ return this
107
+ }
108
+
109
+ /**
110
+ * Show a hidden (keep-alive) app instantly.
111
+ * @returns {Promise<WuApp>}
112
+ */
113
+ async show() {
114
+ if (!this._wu.isHidden(this.name)) {
115
+ logger.warn(`⚠️ App ${this.name} is not in keep-alive state`)
116
+ return this
117
+ }
118
+
119
+ await this._wu.show(this.name)
120
+ this._mounted = true
121
+ return this
122
+ }
123
+
124
+ /**
125
+ * Remontar la app (útil para recargas)
126
+ * @param {string} [container] - Selector del contenedor
127
+ * @returns {Promise<void>}
128
+ */
129
+ async remount(container) {
130
+ await this.unmount({ force: true })
131
+ await this.mount(container)
132
+ return this
133
+ }
134
+
135
+ /**
136
+ * Verificar si la app está montada
137
+ * @returns {boolean}
138
+ */
139
+ get isMounted() {
140
+ return this._mounted && this._wu.mounted?.has(this.name)
141
+ }
142
+
143
+ /**
144
+ * Check if the app is in keep-alive (hidden) state
145
+ * @returns {boolean}
146
+ */
147
+ get isHidden() {
148
+ return this._wu.isHidden(this.name)
149
+ }
150
+
151
+ /**
152
+ * Obtener información de la app
153
+ * @returns {Object}
154
+ */
155
+ get info() {
156
+ return {
157
+ name: this.name,
158
+ url: this.url,
159
+ container: this.container,
160
+ mounted: this.isMounted,
161
+ status: this._wu.apps.get(this.name)?.status || 'unknown'
162
+ }
163
+ }
164
+
165
+ /**
166
+ * Recargar la app (limpiar cache y remontar)
167
+ * @returns {Promise<void>}
168
+ */
169
+ async reload() {
170
+ logger.debug(`🔄 Reloading app: ${this.name}`)
171
+
172
+ await this.unmount()
173
+
174
+ // Limpiar caches
175
+ if (this._wu.loader?.clearCache) {
176
+ this._wu.loader.clearCache(this.name)
177
+ }
178
+ if (this._wu.manifest?.clearCache) {
179
+ this._wu.manifest.clearCache(this.name)
180
+ }
181
+
182
+ await this.mount()
183
+ logger.debug(`✅ App reloaded: ${this.name}`)
184
+
185
+ return this
186
+ }
187
+
188
+ /**
189
+ * Verificar el estado de la app
190
+ * @returns {Object}
191
+ */
192
+ async verify() {
193
+ const container = document.querySelector(this.container)
194
+ const hasShadowDOM = container?.shadowRoot !== null
195
+ const hasContent = (container?.shadowRoot?.children?.length || 0) > 0
196
+
197
+ return {
198
+ name: this.name,
199
+ mounted: this.isMounted,
200
+ container: {
201
+ found: !!container,
202
+ selector: this.container,
203
+ hasShadowDOM,
204
+ hasContent
205
+ },
206
+ wu: {
207
+ registered: this._wu.apps.has(this.name),
208
+ mountedInWu: this._wu.mounted?.has(this.name)
209
+ }
210
+ }
211
+ }
212
+
213
+ /**
214
+ * Shorthand para mount
215
+ */
216
+ async start(container) {
217
+ return await this.mount(container)
218
+ }
219
+
220
+ /**
221
+ * Shorthand para unmount
222
+ */
223
+ async stop() {
224
+ return await this.unmount()
225
+ }
226
+
227
+ /**
228
+ * Destruir la app completamente
229
+ */
230
+ async destroy() {
231
+ await this.unmount({ force: true })
232
+ this._wu.apps.delete(this.name)
233
+ this._mounted = false
234
+ logger.debug(`🗑️ App destroyed: ${this.name}`)
235
+ }
236
+ }