wu-framework 1.1.7 → 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.
Files changed (95) hide show
  1. package/LICENSE +19 -1
  2. package/README.md +257 -1122
  3. package/dist/wu-framework.cjs.js +3 -1
  4. package/dist/wu-framework.cjs.js.map +1 -0
  5. package/dist/wu-framework.dev.js +9867 -3183
  6. package/dist/wu-framework.dev.js.map +1 -1
  7. package/dist/wu-framework.esm.js +3 -0
  8. package/dist/wu-framework.esm.js.map +1 -0
  9. package/dist/wu-framework.umd.js +3 -1
  10. package/dist/wu-framework.umd.js.map +1 -0
  11. package/integrations/astro/README.md +127 -0
  12. package/integrations/astro/WuApp.astro +63 -0
  13. package/integrations/astro/WuShell.astro +39 -0
  14. package/integrations/astro/index.js +68 -0
  15. package/integrations/astro/package.json +38 -0
  16. package/integrations/astro/types.d.ts +53 -0
  17. package/package.json +96 -72
  18. package/src/adapters/angular/ai.js +30 -0
  19. package/src/adapters/angular/index.d.ts +154 -0
  20. package/src/adapters/angular/index.js +932 -0
  21. package/src/adapters/angular.d.ts +3 -154
  22. package/src/adapters/angular.js +3 -813
  23. package/src/adapters/index.js +35 -24
  24. package/src/adapters/lit/ai.js +20 -0
  25. package/src/adapters/lit/index.d.ts +120 -0
  26. package/src/adapters/lit/index.js +721 -0
  27. package/src/adapters/lit.d.ts +3 -120
  28. package/src/adapters/lit.js +3 -726
  29. package/src/adapters/preact/ai.js +33 -0
  30. package/src/adapters/preact/index.d.ts +108 -0
  31. package/src/adapters/preact/index.js +661 -0
  32. package/src/adapters/preact.d.ts +3 -108
  33. package/src/adapters/preact.js +3 -665
  34. package/src/adapters/react/ai.js +135 -0
  35. package/src/adapters/react/index.d.ts +246 -0
  36. package/src/adapters/react/index.js +694 -0
  37. package/src/adapters/react.d.ts +3 -212
  38. package/src/adapters/react.js +3 -513
  39. package/src/adapters/shared.js +64 -0
  40. package/src/adapters/solid/ai.js +32 -0
  41. package/src/adapters/solid/index.d.ts +101 -0
  42. package/src/adapters/solid/index.js +586 -0
  43. package/src/adapters/solid.d.ts +3 -101
  44. package/src/adapters/solid.js +3 -591
  45. package/src/adapters/svelte/ai.js +31 -0
  46. package/src/adapters/svelte/index.d.ts +166 -0
  47. package/src/adapters/svelte/index.js +798 -0
  48. package/src/adapters/svelte.d.ts +3 -166
  49. package/src/adapters/svelte.js +3 -803
  50. package/src/adapters/vanilla/ai.js +30 -0
  51. package/src/adapters/vanilla/index.d.ts +179 -0
  52. package/src/adapters/vanilla/index.js +785 -0
  53. package/src/adapters/vanilla.d.ts +3 -179
  54. package/src/adapters/vanilla.js +3 -791
  55. package/src/adapters/vue/ai.js +52 -0
  56. package/src/adapters/vue/index.d.ts +299 -0
  57. package/src/adapters/vue/index.js +608 -0
  58. package/src/adapters/vue.d.ts +3 -299
  59. package/src/adapters/vue.js +3 -611
  60. package/src/ai/wu-ai-actions.js +261 -0
  61. package/src/ai/wu-ai-agent.js +546 -0
  62. package/src/ai/wu-ai-browser-primitives.js +354 -0
  63. package/src/ai/wu-ai-browser.js +380 -0
  64. package/src/ai/wu-ai-context.js +332 -0
  65. package/src/ai/wu-ai-conversation.js +613 -0
  66. package/src/ai/wu-ai-orchestrate.js +1021 -0
  67. package/src/ai/wu-ai-permissions.js +381 -0
  68. package/src/ai/wu-ai-provider.js +700 -0
  69. package/src/ai/wu-ai-schema.js +225 -0
  70. package/src/ai/wu-ai-triggers.js +396 -0
  71. package/src/ai/wu-ai.js +804 -0
  72. package/src/core/wu-app.js +50 -8
  73. package/src/core/wu-cache.js +2 -3
  74. package/src/core/wu-core.js +648 -681
  75. package/src/core/wu-html-parser.js +121 -211
  76. package/src/core/wu-iframe-sandbox.js +328 -0
  77. package/src/core/wu-mcp-bridge.js +431 -0
  78. package/src/core/wu-overrides.js +510 -0
  79. package/src/core/wu-plugin.js +4 -1
  80. package/src/core/wu-prefetch.js +414 -0
  81. package/src/core/wu-proxy-sandbox.js +398 -75
  82. package/src/core/wu-sandbox.js +86 -268
  83. package/src/core/wu-script-executor.js +79 -182
  84. package/src/core/wu-snapshot-sandbox.js +149 -106
  85. package/src/core/wu-strategies.js +13 -0
  86. package/src/core/wu-style-bridge.js +23 -23
  87. package/src/index.js +162 -665
  88. package/dist/wu-framework.hex.js +0 -23
  89. package/dist/wu-framework.min.js +0 -1
  90. package/dist/wu-framework.obf.js +0 -1
  91. package/scripts/build-protected.js +0 -366
  92. package/scripts/build.js +0 -212
  93. package/scripts/rollup-plugin-hex.js +0 -143
  94. package/src/core/wu-registry.js +0 -60
  95. package/src/core/wu-sandbox-pool.js +0 -390
@@ -17,6 +17,7 @@ export class WuApp {
17
17
  this.name = name
18
18
  this.url = config.url
19
19
  this.container = config.container
20
+ this.keepAlive = config.keepAlive || false
20
21
  this._wu = wu
21
22
  this._mounted = false
22
23
  this._autoInit = config.autoInit !== false // Default true
@@ -33,10 +34,10 @@ export class WuApp {
33
34
  */
34
35
  _registerApp() {
35
36
  if (!this._wu.apps.has(this.name)) {
36
- // Usar el método interno de wu-framework para registrar
37
37
  this._wu.apps.set(this.name, {
38
38
  name: this.name,
39
39
  url: this.url,
40
+ keepAlive: this.keepAlive,
40
41
  status: 'registered'
41
42
  })
42
43
  console.log(`📦 App registered: ${this.name} at ${this.url}`)
@@ -56,7 +57,7 @@ export class WuApp {
56
57
  }
57
58
 
58
59
  // Asegurar que wu-framework está inicializado
59
- if (!this._wu.initialized) {
60
+ if (!this._wu.isInitialized) {
60
61
  await this._wu.init({
61
62
  apps: [{ name: this.name, url: this.url }]
62
63
  })
@@ -70,18 +71,51 @@ export class WuApp {
70
71
  }
71
72
 
72
73
  /**
73
- * Desmontar la app
74
- * @returns {Promise<void>}
74
+ * Desmontar la app.
75
+ * If keepAlive is configured, hides instead of destroying.
76
+ *
77
+ * @param {Object} [options] - { keepAlive, force }
78
+ * @returns {Promise<WuApp>}
75
79
  */
76
- async unmount() {
80
+ async unmount(options = {}) {
81
+ if (!this._mounted && !this._wu.isHidden(this.name)) {
82
+ console.warn(`⚠️ App ${this.name} is not mounted`)
83
+ return this
84
+ }
85
+
86
+ await this._wu.unmount(this.name, options)
87
+ this._mounted = !this._wu.isHidden(this.name)
88
+
89
+ return this
90
+ }
91
+
92
+ /**
93
+ * Hide the app (keep-alive). Preserves all state for instant re-show.
94
+ * @returns {Promise<WuApp>}
95
+ */
96
+ async hide() {
77
97
  if (!this._mounted) {
78
98
  console.warn(`⚠️ App ${this.name} is not mounted`)
79
99
  return this
80
100
  }
81
101
 
82
- await this._wu.unmount(this.name)
102
+ await this._wu.hide(this.name)
83
103
  this._mounted = false
104
+ return this
105
+ }
84
106
 
107
+ /**
108
+ * Show a hidden (keep-alive) app instantly.
109
+ * @returns {Promise<WuApp>}
110
+ */
111
+ async show() {
112
+ if (!this._wu.isHidden(this.name)) {
113
+ console.warn(`⚠️ App ${this.name} is not in keep-alive state`)
114
+ return this
115
+ }
116
+
117
+ await this._wu.show(this.name)
118
+ this._mounted = true
85
119
  return this
86
120
  }
87
121
 
@@ -91,7 +125,7 @@ export class WuApp {
91
125
  * @returns {Promise<void>}
92
126
  */
93
127
  async remount(container) {
94
- await this.unmount()
128
+ await this.unmount({ force: true })
95
129
  await this.mount(container)
96
130
  return this
97
131
  }
@@ -104,6 +138,14 @@ export class WuApp {
104
138
  return this._mounted && this._wu.mounted?.has(this.name)
105
139
  }
106
140
 
141
+ /**
142
+ * Check if the app is in keep-alive (hidden) state
143
+ * @returns {boolean}
144
+ */
145
+ get isHidden() {
146
+ return this._wu.isHidden(this.name)
147
+ }
148
+
107
149
  /**
108
150
  * Obtener información de la app
109
151
  * @returns {Object}
@@ -184,7 +226,7 @@ export class WuApp {
184
226
  * Destruir la app completamente
185
227
  */
186
228
  async destroy() {
187
- await this.unmount()
229
+ await this.unmount({ force: true })
188
230
  this._wu.apps.delete(this.name)
189
231
  this._mounted = false
190
232
  console.log(`🗑️ App destroyed: ${this.name}`)
@@ -16,8 +16,7 @@ export class WuCache {
16
16
  maxItems: options.maxItems || 100,
17
17
  defaultTTL: options.defaultTTL || 3600000, // 1 hour
18
18
  persistent: options.persistent !== false,
19
- storage: options.storage || 'memory',
20
- compression: options.compression || false
19
+ storage: options.storage || 'memory'
21
20
  };
22
21
 
23
22
  // 🔐 Rate limiting configuration
@@ -346,8 +345,8 @@ export class WuCache {
346
345
  * @param {Object} entry - Entrada
347
346
  */
348
347
  saveToStorage(key, entry) {
348
+ const storage = this.getStorage();
349
349
  try {
350
- const storage = this.getStorage();
351
350
  storage.setItem(`wu_cache_${key}`, JSON.stringify(entry));
352
351
  } catch (error) {
353
352
  // Storage lleno, limpiar entradas antiguas