wu-framework 1.2.1 → 2.1.1

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 (164) hide show
  1. package/LICENSE +39 -39
  2. package/README.md +570 -489
  3. package/dist/adapters/alpine/index.js +2 -0
  4. package/dist/adapters/alpine/index.js.map +1 -0
  5. package/{src → dist}/adapters/angular/index.d.ts +154 -154
  6. package/dist/adapters/angular/index.js +2 -0
  7. package/dist/adapters/angular/index.js.map +1 -0
  8. package/{src → dist}/adapters/angular.d.ts +3 -3
  9. package/dist/adapters/htmx/index.js +2 -0
  10. package/dist/adapters/htmx/index.js.map +1 -0
  11. package/dist/adapters/index.js +2 -0
  12. package/dist/adapters/index.js.map +1 -0
  13. package/{src → dist}/adapters/lit/index.d.ts +120 -120
  14. package/dist/adapters/lit/index.js +44 -0
  15. package/dist/adapters/lit/index.js.map +1 -0
  16. package/{src → dist}/adapters/lit.d.ts +3 -3
  17. package/{src → dist}/adapters/preact/index.d.ts +108 -108
  18. package/dist/adapters/preact/index.js +2 -0
  19. package/dist/adapters/preact/index.js.map +1 -0
  20. package/{src → dist}/adapters/preact.d.ts +3 -3
  21. package/dist/adapters/qwik/index.js +2 -0
  22. package/dist/adapters/qwik/index.js.map +1 -0
  23. package/{src → dist}/adapters/react/index.d.ts +246 -246
  24. package/dist/adapters/react/index.js +2 -0
  25. package/dist/adapters/react/index.js.map +1 -0
  26. package/{src → dist}/adapters/react.d.ts +3 -3
  27. package/dist/adapters/shared.js +2 -0
  28. package/dist/adapters/shared.js.map +1 -0
  29. package/{src → dist}/adapters/solid/index.d.ts +101 -101
  30. package/dist/adapters/solid/index.js +2 -0
  31. package/dist/adapters/solid/index.js.map +1 -0
  32. package/{src → dist}/adapters/solid.d.ts +3 -3
  33. package/dist/adapters/stencil/index.js +2 -0
  34. package/dist/adapters/stencil/index.js.map +1 -0
  35. package/dist/adapters/stimulus/index.js +2 -0
  36. package/dist/adapters/stimulus/index.js.map +1 -0
  37. package/{src → dist}/adapters/svelte/index.d.ts +166 -166
  38. package/dist/adapters/svelte/index.js +2 -0
  39. package/dist/adapters/svelte/index.js.map +1 -0
  40. package/{src → dist}/adapters/svelte.d.ts +3 -3
  41. package/{src → dist}/adapters/vanilla/index.d.ts +179 -179
  42. package/dist/adapters/vanilla/index.js +2 -0
  43. package/dist/adapters/vanilla/index.js.map +1 -0
  44. package/{src → dist}/adapters/vanilla.d.ts +3 -3
  45. package/{src → dist}/adapters/vue/index.d.ts +299 -299
  46. package/dist/adapters/vue/index.js +2 -0
  47. package/dist/adapters/vue/index.js.map +1 -0
  48. package/{src → dist}/adapters/vue.d.ts +3 -3
  49. package/dist/ai/wu-ai.js +2 -0
  50. package/dist/ai/wu-ai.js.map +1 -0
  51. package/dist/core/wu-html-parser.js +2 -0
  52. package/dist/core/wu-html-parser.js.map +1 -0
  53. package/dist/core/wu-iframe-sandbox.js +2 -0
  54. package/dist/core/wu-iframe-sandbox.js.map +1 -0
  55. package/dist/core/wu-loader.js +2 -0
  56. package/dist/core/wu-loader.js.map +1 -0
  57. package/dist/core/wu-mcp-bridge.js +2 -0
  58. package/dist/core/wu-mcp-bridge.js.map +1 -0
  59. package/dist/core/wu-script-executor.js +2 -0
  60. package/dist/core/wu-script-executor.js.map +1 -0
  61. package/{src → dist}/index.d.ts +445 -317
  62. package/dist/wu-ai-browser-primitives-BDKXJlwc.js +2 -0
  63. package/dist/wu-ai-browser-primitives-BDKXJlwc.js.map +1 -0
  64. package/dist/wu-framework.cjs.js +2 -2
  65. package/dist/wu-framework.cjs.js.map +1 -1
  66. package/dist/wu-framework.dev.js +8681 -15683
  67. package/dist/wu-framework.dev.js.map +1 -1
  68. package/dist/wu-framework.esm.js +2 -2
  69. package/dist/wu-framework.esm.js.map +1 -1
  70. package/dist/wu-framework.umd.js +2 -2
  71. package/dist/wu-framework.umd.js.map +1 -1
  72. package/dist/wu-logger-fJfUHBGA.js +2 -0
  73. package/dist/wu-logger-fJfUHBGA.js.map +1 -0
  74. package/integrations/astro/README.md +127 -127
  75. package/integrations/astro/WuApp.astro +63 -63
  76. package/integrations/astro/WuShell.astro +39 -39
  77. package/integrations/astro/index.js +68 -68
  78. package/integrations/astro/package.json +38 -38
  79. package/integrations/astro/types.d.ts +53 -53
  80. package/package.json +218 -209
  81. package/src/adapters/alpine/index.js +0 -231
  82. package/src/adapters/alpine.js +0 -3
  83. package/src/adapters/angular/ai.js +0 -30
  84. package/src/adapters/angular/index.js +0 -932
  85. package/src/adapters/angular.js +0 -3
  86. package/src/adapters/htmx/index.js +0 -242
  87. package/src/adapters/htmx.js +0 -3
  88. package/src/adapters/index.js +0 -225
  89. package/src/adapters/lit/ai.js +0 -20
  90. package/src/adapters/lit/index.js +0 -721
  91. package/src/adapters/lit.js +0 -3
  92. package/src/adapters/preact/ai.js +0 -33
  93. package/src/adapters/preact/index.js +0 -661
  94. package/src/adapters/preact.js +0 -3
  95. package/src/adapters/qwik/index.js +0 -108
  96. package/src/adapters/qwik.js +0 -3
  97. package/src/adapters/react/ai.js +0 -135
  98. package/src/adapters/react/index.js +0 -695
  99. package/src/adapters/react.js +0 -3
  100. package/src/adapters/shared.js +0 -64
  101. package/src/adapters/solid/ai.js +0 -32
  102. package/src/adapters/solid/index.js +0 -586
  103. package/src/adapters/solid.js +0 -3
  104. package/src/adapters/stencil/index.js +0 -228
  105. package/src/adapters/stencil.js +0 -3
  106. package/src/adapters/stimulus/index.js +0 -255
  107. package/src/adapters/stimulus.js +0 -3
  108. package/src/adapters/svelte/ai.js +0 -31
  109. package/src/adapters/svelte/index.js +0 -798
  110. package/src/adapters/svelte.js +0 -3
  111. package/src/adapters/vanilla/ai.js +0 -30
  112. package/src/adapters/vanilla/index.js +0 -785
  113. package/src/adapters/vanilla.js +0 -3
  114. package/src/adapters/vue/ai.js +0 -52
  115. package/src/adapters/vue/index.js +0 -618
  116. package/src/adapters/vue.js +0 -3
  117. package/src/ai/wu-ai-actions.js +0 -261
  118. package/src/ai/wu-ai-agent.js +0 -546
  119. package/src/ai/wu-ai-browser-primitives.js +0 -354
  120. package/src/ai/wu-ai-browser.js +0 -380
  121. package/src/ai/wu-ai-context.js +0 -332
  122. package/src/ai/wu-ai-conversation.js +0 -613
  123. package/src/ai/wu-ai-orchestrate.js +0 -1021
  124. package/src/ai/wu-ai-permissions.js +0 -381
  125. package/src/ai/wu-ai-provider.js +0 -700
  126. package/src/ai/wu-ai-schema.js +0 -225
  127. package/src/ai/wu-ai-triggers.js +0 -396
  128. package/src/ai/wu-ai.js +0 -804
  129. package/src/core/wu-app.js +0 -236
  130. package/src/core/wu-cache.js +0 -498
  131. package/src/core/wu-core.js +0 -1412
  132. package/src/core/wu-error-boundary.js +0 -396
  133. package/src/core/wu-event-bus.js +0 -390
  134. package/src/core/wu-hooks.js +0 -350
  135. package/src/core/wu-html-parser.js +0 -199
  136. package/src/core/wu-iframe-sandbox.js +0 -328
  137. package/src/core/wu-loader.js +0 -450
  138. package/src/core/wu-logger.js +0 -143
  139. package/src/core/wu-manifest.js +0 -533
  140. package/src/core/wu-mcp-bridge.js +0 -432
  141. package/src/core/wu-overrides.js +0 -510
  142. package/src/core/wu-performance.js +0 -228
  143. package/src/core/wu-plugin.js +0 -401
  144. package/src/core/wu-prefetch.js +0 -414
  145. package/src/core/wu-proxy-sandbox.js +0 -477
  146. package/src/core/wu-sandbox.js +0 -779
  147. package/src/core/wu-script-executor.js +0 -161
  148. package/src/core/wu-sentinel-client.js +0 -311
  149. package/src/core/wu-snapshot-sandbox.js +0 -227
  150. package/src/core/wu-store.js +0 -307
  151. package/src/core/wu-strategies.js +0 -256
  152. package/src/core/wu-style-bridge.js +0 -477
  153. package/src/index.js +0 -234
  154. package/src/utils/dependency-resolver.js +0 -328
  155. /package/{src → dist}/adapters/alpine/index.d.ts +0 -0
  156. /package/{src → dist}/adapters/alpine.d.ts +0 -0
  157. /package/{src → dist}/adapters/htmx/index.d.ts +0 -0
  158. /package/{src → dist}/adapters/htmx.d.ts +0 -0
  159. /package/{src → dist}/adapters/qwik/index.d.ts +0 -0
  160. /package/{src → dist}/adapters/qwik.d.ts +0 -0
  161. /package/{src → dist}/adapters/stencil/index.d.ts +0 -0
  162. /package/{src → dist}/adapters/stencil.d.ts +0 -0
  163. /package/{src → dist}/adapters/stimulus/index.d.ts +0 -0
  164. /package/{src → dist}/adapters/stimulus.d.ts +0 -0
package/README.md CHANGED
@@ -1,489 +1,570 @@
1
- <p align="center">
2
- <img src="https://raw.githubusercontent.com/LuisPadre25/wu-framework/main/wu-logo.png" width="80" alt="Wu Framework" />
3
- </p>
4
-
5
- <h1 align="center">Wu Framework</h1>
6
-
7
- <p align="center">
8
- <strong>Universal microfrontends with built-in AI. Zero dependencies.</strong>
9
- </p>
10
-
11
- <p align="center">
12
- <a href="https://www.npmjs.com/package/wu-framework"><img src="https://img.shields.io/npm/v/wu-framework.svg?color=6366f1&label=npm" alt="npm version" /></a>
13
- <a href="https://github.com/LuisPadre25/wu-framework/actions"><img src="https://img.shields.io/github/actions/workflow/status/LuisPadre25/wu-framework/ci.yml?label=tests&color=14b8a6" alt="tests" /></a>
14
- <img src="https://img.shields.io/badge/tests-650%20passed-14b8a6" alt="650 tests" />
15
- <img src="https://img.shields.io/badge/dependencies-0-6366f1" alt="zero deps" />
16
- <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="MIT License" /></a>
17
- </p>
18
-
19
- <p align="center">
20
- <a href="https://www.wu-framework.com">Documentation</a> &middot;
21
- <a href="https://www.wu-framework.com/docs/quick-start">Quick Start</a> &middot;
22
- <a href="https://www.wu-framework.com/docs/ai/overview">AI Integration</a> &middot;
23
- <a href="#wucommerce--real-world-example">Live Example</a>
24
- </p>
25
-
26
- ---
27
-
28
- Run **React, Vue, Angular, Svelte, Solid, Preact, Lit, Qwik, Alpine.js, Stencil, HTMX, Stimulus, and Vanilla JS** micro-apps side by side in the same page. Each app lives in its own Shadow DOM with full CSS isolation. Apps communicate through a shared event bus and store — no tight coupling, no iframes.
29
-
30
- Add AI to any app with one line. Connect your own LLM (OpenAI, Anthropic, Ollama) and your app gains context-aware tool calling, autonomous agents, and cross-app orchestration. **WebMCP ready** for Chrome 146+.
31
-
32
- ```bash
33
- npm install wu-framework
34
- ```
35
-
36
- ## 30-Second Demo
37
-
38
- ```js
39
- import { wu } from 'wu-framework';
40
- import { wuReact } from 'wu-framework/adapters/react';
41
- import { wuVue } from 'wu-framework/adapters/vue';
42
-
43
- // Register micro-apps from different frameworks
44
- wuReact.register('cart', CartApp);
45
- wuVue.register('catalog', CatalogApp);
46
-
47
- // Mount them each gets its own Shadow DOM
48
- await wu.mount('cart', '#cart-container');
49
- await wu.mount('catalog', '#catalog-container');
50
-
51
- // They talk to each other via events
52
- wu.emit('cart:item-added', { productId: 'SKU-42' });
53
- wu.on('catalog:product-selected', (e) => console.log(e.data));
54
-
55
- // Add AI with one line — BYOL (Bring Your Own LLM)
56
- wu.ai.provider('openai', { endpoint: '/api/ai/chat', model: 'gpt-4o' });
57
- wu.ai.action('addToCart', {
58
- description: 'Add a product to the shopping cart',
59
- parameters: { productId: { type: 'string', required: true } },
60
- handler: async (params) => wu.emit('cart:item-added', params),
61
- });
62
-
63
- // Now the AI can control your app
64
- await wu.ai.send('Add product SKU-42 to the cart');
65
- ```
66
-
67
- ## Why Wu?
68
-
69
- | | **Wu Framework** | **single-spa** | **Module Federation** | **iframes** |
70
- |---|:---:|:---:|:---:|:---:|
71
- | Framework adapters | **13** | 4 | 1* | Any |
72
- | Shadow DOM isolation | Yes | No | No | Yes (heavy) |
73
- | Shared event bus | Built-in | Manual | Manual | postMessage |
74
- | Shared store | Built-in | Manual | Manual | No |
75
- | Standalone mode | Automatic | No | No | N/A |
76
- | AI integration | Built-in | No | No | No |
77
- | WebMCP (Chrome 146+) | Built-in | No | No | No |
78
- | MCP Server (dev tools) | Built-in | No | No | No |
79
- | Dependencies | **0** | 0 | Webpack 5 | N/A |
80
- | Bundle size (min) | ~174 KB | ~10 KB | Varies | N/A |
81
-
82
- *Module Federation is Webpack-coupled; Wu is bundler-agnostic.
83
-
84
- ---
85
-
86
- ## Features
87
-
88
- ### Core
89
-
90
- - **13 Framework Adapters** React, Vue, Angular, Svelte, Solid, Preact, Lit, Qwik, Alpine.js, Stencil, HTMX, Stimulus, Vanilla
91
- - **Shadow DOM Isolation** CSS and DOM fully sandboxed per app
92
- - **3 Sandbox Strategies** Shadow DOM, Proxy, iframe choose per app
93
- - **3 CSS Isolation Modes** `shared`, `isolated`, `fully-isolated` per app
94
- - **Event Bus** — Namespaced pub/sub with wildcards, replay, and middleware
95
- - **Shared Store** — Cross-app reactive state with dot-path notation and persistence
96
- - **Plugin System** — Extend Wu with lifecycle hooks
97
- - **Performance Monitor** — Mount time, memory, FPS tracking per app
98
- - **Error Boundaries** — Catch and recover from micro-app failures
99
- - **Keep-Alive** — Preserve app state when hiding/showing
100
- - **Prefetch** — Speculation Rules API with automatic fallback chain
101
- - **Cookie Overrides** — QA redirects individual apps to different URLs per-browser
102
- - **Standalone Mode** — Every micro-app works without a shell, zero lock-in
103
-
104
- ### AI (BYOLBring Your Own LLM)
105
-
106
- - **4 Paradigms** — App→LLM, LLM→App, Autonomous Agent, Cross-App Orchestration
107
- - **Tool Calling** — Register actions the AI executes autonomously
108
- - **Streaming** — Async generator for real-time responses
109
- - **Multi-turn** — Namespaced conversations with history
110
- - **Reactive Triggers** — Events automatically invoke the AI
111
- - **Auto Context** — Store state, apps, events injected into the system prompt
112
- - **10 Browser Actions** — Screenshot, click, type, navigate, read console/network
113
- - **WebMCP** — `wu.ai.expose()` registers tools via `navigator.modelContext` (Chrome 146+)
114
- - **MCP Server** — Connect Claude Code, Cursor, or any MCP client to your live app
115
- - **4-Layer Security** — Permissions, rate limiting, circuit breaker, loop protection
116
- - **Workflows** — Reusable parameterized AI recipes
117
-
118
- ---
119
-
120
- ## Quick Start
121
-
122
- ### 1. Register your micro-app
123
-
124
- ```jsx
125
- // React
126
- import { wuReact } from 'wu-framework/adapters/react';
127
- wuReact.register('orders', App);
128
-
129
- // Vue
130
- import { wuVue } from 'wu-framework/adapters/vue';
131
- wuVue.register('products', App);
132
-
133
- // Angular (standalone)
134
- import { wuAngular } from 'wu-framework/adapters/angular';
135
- wuAngular.registerStandalone('settings', AppComponent, { createApplication, createComponent });
136
-
137
- // Svelte 5
138
- import { wuSvelte } from 'wu-framework/adapters/svelte';
139
- wuSvelte.registerSvelte5('dashboard', App);
140
-
141
- // Qwik
142
- import { wuQwik } from 'wu-framework/adapters/qwik';
143
- wuQwik.register('widget', QwikApp);
144
-
145
- // Alpine.js
146
- import { wuAlpine } from 'wu-framework/adapters/alpine';
147
- wuAlpine.register('search', initFn);
148
-
149
- // Stencil (Web Components)
150
- import { wuStencil } from 'wu-framework/adapters/stencil';
151
- wuStencil.register('badge', 'my-badge');
152
-
153
- // HTMX
154
- import { wuHtmx } from 'wu-framework/adapters/htmx';
155
- wuHtmx.register('feed', { template: '<div hx-get="/api/feed">...</div>' });
156
-
157
- // Stimulus
158
- import { wuStimulus } from 'wu-framework/adapters/stimulus';
159
- wuStimulus.register('form', { controllers: { hello: HelloController }, template: '...' });
160
-
161
- // Same pattern for Solid, Preact, Lit, Vanilla
162
- ```
163
-
164
- ### 2. Mount from the shell
165
-
166
- ```js
167
- import { wu } from 'wu-framework';
168
-
169
- await wu.init({
170
- apps: [
171
- { name: 'header', url: 'http://localhost:3001' },
172
- { name: 'sidebar', url: 'http://localhost:3002' },
173
- { name: 'content', url: 'http://localhost:3003' },
174
- ]
175
- });
176
-
177
- await wu.mount('header', '#header-container');
178
- await wu.mount('sidebar', '#sidebar-container');
179
- await wu.mount('content', '#content-container');
180
- ```
181
-
182
- ### 3. Cross-app communication
183
-
184
- ```js
185
- import { emit, on, getState, setState } from 'wu-framework';
186
-
187
- // Events
188
- emit('user:login', { userId: 123 });
189
- on('user:*', (event) => console.log(event.data));
190
-
191
- // Shared store
192
- setState('user.name', 'John');
193
- getState('user.name'); // 'John'
194
- ```
195
-
196
- ### 4. Add AI (optional)
197
-
198
- ```js
199
- wu.ai.provider('ollama', {
200
- endpoint: 'http://localhost:11434/api/chat',
201
- model: 'llama3',
202
- });
203
-
204
- const response = await wu.ai.send('What apps are mounted?');
205
- ```
206
-
207
- ---
208
-
209
- ## WuCommerce Real-World Example
210
-
211
- Wu ships with **WuCommerce**, a Shopify-like merchant dashboard where every section is a real micro-app built with a different framework.
212
-
213
- | Micro-app | Framework | What it does |
214
- |-----------|-----------|-------------|
215
- | **Topbar** | Preact | Store name, nav tabs, search, notifications, theme toggle |
216
- | **Dashboard** | Svelte 5 | KPI cards, sparklines, recent orders, revenue chart |
217
- | **Orders** | React | Order table with filters, search, status badges |
218
- | **Products** | Vue 3 | Product catalog grid, stock badges, category filter |
219
- | **Customers** | Solid.js | Customer list, segment badges, click-to-filter-orders |
220
- | **Analytics** | Lit | Revenue bar chart, traffic donut, top products |
221
- | **Chat** | Vanilla JS | Floating chat widget with conversations and messages |
222
- | **Settings** | Angular 21 | Store config form, shipping zones, payment methods |
223
-
224
- All 8 apps communicate through Wu's event bus and shared store. Click a customer → orders filter. Toggle theme → all 8 apps update. Change store name in settings → topbar updates.
225
-
226
- ---
227
-
228
- ## 3 Sandbox Strategies
229
-
230
- | Mode | How it works | Tree shaking | Source maps | HMR | JS isolation |
231
- |------|-------------|:---:|:---:|:---:|:---:|
232
- | `module` (default) | `import()` + Proxy side-effect tracking | Yes | Yes | Yes | Side effects only |
233
- | `strict` | Hidden iframe + real `import()` | Yes | Yes | Yes | **Full** (separate window) |
234
- | `eval` | Fetch HTML → parse → `with(proxy){}` | No | No | No | **Full** (proxy traps) |
235
-
236
- ```js
237
- await wu.init({
238
- apps: [
239
- { name: 'header', url: '...', sandbox: 'module' },
240
- { name: 'analytics', url: '...', sandbox: 'strict' },
241
- { name: 'legacy', url: '...', sandbox: 'eval' },
242
- ]
243
- });
244
- ```
245
-
246
- **Auto-cleaned on unmount:** timers, intervals, rAF, event listeners, localStorage keys, DOM mutations.
247
-
248
- ---
249
-
250
- ## 3 CSS Isolation Modes
251
-
252
- | Mode | What happens | When to use |
253
- |------|-------------|-------------|
254
- | `shared` | Host styles injected into Shadow DOM | Apps sharing a design system (Tailwind) |
255
- | `isolated` | Pure Shadow DOM no external styles | Fully independent apps |
256
- | `fully-isolated` | Only the app's own styles | Apps that need their CSS but not global CSS |
257
-
258
- ```json
259
- { "name": "my-app", "entry": "index.js", "styleMode": "isolated" }
260
- ```
261
-
262
- ---
263
-
264
- ## AI Paradigms
265
-
266
- ### 1. App → LLM → App
267
-
268
- ```js
269
- const response = await wu.ai.send('What items are in the cart?');
270
- ```
271
-
272
- ### 2. LLM → App → LLM (WebMCP)
273
-
274
- ```js
275
- wu.ai.expose(); // Registers all tools via navigator.modelContext (Chrome 146+)
276
- ```
277
-
278
- ### 3. Autonomous Agent
279
-
280
- ```js
281
- for await (const step of wu.ai.agent('Find the top customer and show their profile')) {
282
- console.log(`Step ${step.step}: ${step.content}`);
283
- }
284
- ```
285
-
286
- ### 4. Cross-App Orchestration
287
-
288
- ```js
289
- const result = await wu.ai.intent('Find customer Emma and refund order #4821');
290
- console.log(result.appsInvolved); // ['customers', 'orders']
291
- ```
292
-
293
- ---
294
-
295
- ## Plugins & Hooks
296
-
297
- ```js
298
- import { usePlugin, createPlugin, useHook } from 'wu-framework';
299
-
300
- usePlugin(createPlugin({
301
- name: 'analytics',
302
- install: (api) => api.on('app:mounted', (e) => track(e)),
303
- afterMount: async (ctx) => log('mounted in', ctx.mountTime, 'ms')
304
- }));
305
-
306
- useHook('beforeMount', async (context, next) => {
307
- console.log('Mounting:', context.appName);
308
- await next();
309
- });
310
- ```
311
-
312
- Phases: `beforeInit` `afterInit` `beforeLoad``afterLoad` → `beforeMount` → `afterMount` → `beforeUnmount` → `afterUnmount`
313
-
314
- ---
315
-
316
- ## Prefetch (Speculation Rules API)
317
-
318
- ```js
319
- wu.prefetch(['sidebar', 'analytics']);
320
- wu.prefetch(['sidebar'], { trigger: 'hover', action: 'prerender' });
321
- wu.prefetchAll();
322
- ```
323
-
324
- Fallback chain: Speculation Rules API (Chrome 121+) → `<link rel="modulepreload">` → `<link rel="prefetch">`
325
-
326
- ---
327
-
328
- ## Cookie Overrides for QA
329
-
330
- ```js
331
- wu.override('sidebar', 'http://localhost:5174');
332
- wu.getOverrides(); // { sidebar: 'http://localhost:5174' }
333
- wu.removeOverride('sidebar');
334
- ```
335
-
336
- QA sets a cookie → only **their browser** sees the override. Everyone else sees production. 3-layer security: environment gate, domain allowlist, visual indicator.
337
-
338
- ---
339
-
340
- ## Project Stats
341
-
342
- | Metric | Value |
343
- |---|---|
344
- | Source files | 79 |
345
- | Lines of code | 23,442 |
346
- | Test cases | **650** |
347
- | Framework adapters | 13 |
348
- | AI modules | 12 |
349
- | Core modules | 23 |
350
- | Runtime dependencies | **0** |
351
- | Bundle (ESM, minified) | ~174 KB |
352
-
353
- ---
354
-
355
- ## Build
356
-
357
- ```bash
358
- npm run build # ESM + CJS + UMD + Dev
359
- npm run test # 650 tests (Vitest)
360
- npm run test:coverage # Coverage report
361
- ```
362
-
363
- | Output | Format | Use |
364
- |--------|--------|-----|
365
- | `wu-framework.esm.js` | ES Module | Bundler imports |
366
- | `wu-framework.cjs.js` | CommonJS | Node.js require |
367
- | `wu-framework.umd.js` | UMD | CDN / script tag |
368
- | `www.wu-framework.com.js` | ES Module | Development |
369
-
370
- ---
371
-
372
- ## Architecture
373
-
374
- ```
375
- ┌───────────────────────────────────────────────────────────────────────┐
376
- │ SHELL (any framework) │
377
- ├──────────┬──────────┬──────────┬──────────┬──────────┬───────────────┤
378
- │ Shadow Shadow │ Shadow │ Shadow │ Shadow │ Shadow ... │
379
- │ ┌──────┐ │ ┌──────┐ │ ┌──────┐ │ ┌──────┐ │ ┌──────┐ │ ┌──────┐ │
380
- │ │Topbar│ │ │Dashbd│ │ │Orders│ │ │Produc│ │ │Custo.│ │ │Analyt│ │
381
- │ │Preact│ │ │Svelte│ │ │React │ │ │Vue 3 │ │ │Solid │ │ │ Lit │ │
382
- └──────┘ └──────┘ └──────┘ └──────┘ └──────┘ └──────┘ │
383
- ├──────────┴──────────┴──────────┴──────────┴──────────┴───────────────┤
384
- │ WU FRAMEWORK CORE │
385
- │ Sandbox (module/strict/eval) · EventBus (wildcards, replay) │
386
- │ Store (dot-paths, batch) · StyleBridge (shared/isolated/fully-iso) │
387
- │ Loader · Hooks · Plugins · Cache · Prefetch · Overrides │
388
- ├──────────────────────────────────────────────────────────────────────┤
389
- │ WU AI (BYOL) │
390
- │ Provider · Actions · Agent · Orchestrate · Triggers · Context │
391
- │ Browser Actions · WebMCP · MCP Server · Workflows · Security │
392
- └──────────────────────────────────────────────────────────────────────┘
393
- ```
394
-
395
- ---
396
-
397
- ## Documentation
398
-
399
- Full documentation at **[www.wu-framework.com](https://www.wu-framework.com)**
400
-
401
- - [Quick Start](https://www.wu-framework.com/docs/quick-start) — Get running in 5 minutes
402
- - [Getting Started](https://www.wu-framework.com/docs/getting-started) — Deeper tutorial with cross-app communication
403
- - [API Reference](https://www.wu-framework.com/docs/core/api) — Full API docs
404
- - [Event Bus](https://www.wu-framework.com/docs/core/event-bus) — Inter-app communication
405
- - [Shared Store](https://www.wu-framework.com/docs/core/store) Cross-app reactive state
406
- - [Sandbox](https://www.wu-framework.com/docs/core/sandbox) JS isolation strategies
407
- - [AI Overview](https://www.wu-framework.com/docs/ai/overview) 4 AI paradigms
408
- - [AI Actions](https://www.wu-framework.com/docs/ai/actions) — Register tools for the LLM
409
- - [Browser Actions](https://www.wu-framework.com/docs/ai/browser-actions) — 10 built-in browser tools
410
- - [MCP Server](https://www.wu-framework.com/docs/ai/mcp-server) Connect AI agents to live apps
411
- - [CSS Isolation](https://www.wu-framework.com/docs/guides/css-isolation) — Shadow DOM style modes
412
- - [Deployment](https://www.wu-framework.com/docs/guides/deployment) Production deployment guide
413
-
414
- ---
415
-
416
- ## Browser Support
417
-
418
- Chrome 80+, Firefox 78+, Safari 14+, Edge 80+. Shadow DOM v1 required.
419
-
420
- ---
421
-
422
- <div align="center">
423
-
424
- ### What if Wu Framework could think without thinking?
425
-
426
- </div>
427
-
428
- ```
429
- User: "add to cart"
430
-
431
- Before After
432
- ────── ─────
433
- wu.ai.send() LLM wu.ai.send() → ???
434
- ~2,000 ms ~0.73 ms
435
- $0.003 per call $0.000
436
- ```
437
-
438
- Something is coming. It learned from every LLM call you ever made. It doesn't need the cloud anymore.
439
-
440
- **99.79% accuracy. 0.73 milliseconds. 800 KB. Zero GPU. Zero internet.**
441
-
442
- 274x faster than neural networks. And it dreams.
443
-
444
- <div align="center">
445
-
446
- **COMING SOON**
447
-
448
- </div>
449
-
450
- ---
451
-
452
- ## Wu CLI
453
-
454
- The official CLI for wu-framework. One binary, one port, all your micro-apps.
455
-
456
- ```bash
457
- npm install -g @wu-framework/cli
458
-
459
- wu create my-project # Interactive scaffolding (13 frameworks)
460
- cd my-project
461
- wu dev # Native Zig dev server on one port
462
- wu build # Production build (parallel Vite)
463
- wu serve # Serve production build
464
- ```
465
-
466
- Features:
467
- - Native SIMD HTTP server written in Zig (16 bytes/cycle parsing)
468
- - Three-tier compilation: Native Zig JSX (0-2ms) -> Compiler Daemon (10-50ms) -> Node fallback
469
- - Two-level cache with 73-138x speedup on warm restart
470
- - Theme-aware production shell with dark/light toggle
471
- - 13 framework app templates with CSS variable theming
472
-
473
- See [@wu-framework/cli](https://github.com/LuisPadre25/wu-cli) for full documentation.
474
-
475
- ---
476
-
477
- ## Contributing
478
-
479
- Contributions welcome. Please open an issue first to discuss what you'd like to change.
480
-
481
- ## License
482
-
483
- [MIT](./LICENSE) -- Free for personal and commercial use.
484
-
485
- See [LICENSE-COMMERCIAL.md](./LICENSE-COMMERCIAL.md) for optional enterprise support and consulting.
486
-
487
- ---
488
-
489
- *2026 Wu Framework*
1
+ <p align="center">
2
+ <img src="https://raw.githubusercontent.com/LuisPadre25/wu-framework/main/wu-logo.png" width="80" alt="Wu Framework" />
3
+ </p>
4
+
5
+ <h1 align="center">Wu Framework</h1>
6
+
7
+ <p align="center">
8
+ <strong>Universal microfrontends with built-in AI. Zero dependencies.</strong>
9
+ </p>
10
+
11
+ <p align="center">
12
+ <a href="https://www.npmjs.com/package/wu-framework"><img src="https://img.shields.io/npm/v/wu-framework.svg?color=6366f1&label=npm" alt="npm version" /></a>
13
+ <a href="https://github.com/LuisPadre25/wu-framework/actions"><img src="https://img.shields.io/github/actions/workflow/status/LuisPadre25/wu-framework/ci.yml?label=tests&color=14b8a6" alt="tests" /></a>
14
+ <img src="https://img.shields.io/badge/tests-702%20passed-14b8a6" alt="702 tests" />
15
+ <img src="https://img.shields.io/badge/dependencies-0-6366f1" alt="zero deps" />
16
+ <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="MIT License" /></a>
17
+ </p>
18
+
19
+ <p align="center">
20
+ <a href="https://www.wu-framework.com">Documentation</a> &middot;
21
+ <a href="https://www.wu-framework.com/docs/quick-start">Quick Start</a> &middot;
22
+ <a href="https://www.wu-framework.com/docs/ai/overview">AI Integration</a> &middot;
23
+ <a href="#wucommerce--real-world-example">Live Example</a>
24
+ </p>
25
+
26
+ ---
27
+
28
+ Run **React, Vue, Angular, Svelte, Solid, Preact, Lit, Qwik, Alpine.js, Stencil, HTMX, Stimulus, and Vanilla JS** micro-apps side by side in the same page. Each app lives in its own Shadow DOM with full CSS isolation. Apps communicate through a shared event bus and store — no tight coupling, no iframes.
29
+
30
+ Add AI to any app with one line. Connect your own LLM (OpenAI, Anthropic, Ollama) and your app gains context-aware tool calling, autonomous agents, and cross-app orchestration. **WebMCP ready** for Chrome 146+.
31
+
32
+ ```bash
33
+ npm install wu-framework
34
+ ```
35
+
36
+ > **v2.1**: honest sandbox modes + reference-counted mount/unmount for robust
37
+ > StrictMode + Suspense flows. New: `wu.getSandboxInfo(name)`, `strictFallback`
38
+ > option, `wu.tagStyleAsApp(el, name)`, styleMode aliases `none` / `own-only`.
39
+ > All additive zero breaking changes from v2.0. See [CHANGELOG.md](./CHANGELOG.md#210---2026-05-17---honest-sandboxes--strictmode-robustness).
40
+ >
41
+ > 📚 **Full docs**: [`docs/`](./docs/README.md) — API reference, concepts deep dives, AI guide, 12 recipes.
42
+ >
43
+ > **v2.0**: bundle reduced from 194 → 105 KB (−46%) via lazy chunks for AI and
44
+ > sandbox modes. Breaking changes documented in [CHANGELOG.md](./CHANGELOG.md#200---2026-05-17---lazy-by-default-bundle-split-signed-trust).
45
+ > The runtime API (`wu.mount`, `wu.ai.*`, `wuReact.register`, etc.) is preserved
46
+ > — most apps need no code changes. AI users may want to add `await wu.aiReady()`
47
+ > for explicit warm-up if they need the chunk loaded before first call.
48
+
49
+ ## 30-Second Demo
50
+
51
+ ```js
52
+ import { wu } from 'wu-framework';
53
+ import { wuReact } from 'wu-framework/adapters/react';
54
+ import { wuVue } from 'wu-framework/adapters/vue';
55
+
56
+ // Register micro-apps from different frameworks
57
+ wuReact.register('cart', CartApp);
58
+ wuVue.register('catalog', CatalogApp);
59
+
60
+ // Mount them each gets its own Shadow DOM
61
+ await wu.mount('cart', '#cart-container');
62
+ await wu.mount('catalog', '#catalog-container');
63
+
64
+ // They talk to each other via events
65
+ wu.emit('cart:item-added', { productId: 'SKU-42' });
66
+ wu.on('catalog:product-selected', (e) => console.log(e.data));
67
+
68
+ // Add AI with one line — BYOL (Bring Your Own LLM)
69
+ wu.ai.provider('openai', { endpoint: '/api/ai/chat', model: 'gpt-4o' });
70
+ wu.ai.action('addToCart', {
71
+ description: 'Add a product to the shopping cart',
72
+ parameters: { productId: { type: 'string', required: true } },
73
+ handler: async (params) => wu.emit('cart:item-added', params),
74
+ });
75
+
76
+ // Now the AI can control your app
77
+ await wu.ai.send('Add product SKU-42 to the cart');
78
+ ```
79
+
80
+ ## Why Wu?
81
+
82
+ | | **Wu Framework** | **single-spa** | **Module Federation** | **iframes** |
83
+ |---|:---:|:---:|:---:|:---:|
84
+ | Framework adapters | **13** | 4 | 1* | Any |
85
+ | Shadow DOM isolation | Yes | No | No | Yes (heavy) |
86
+ | Shared event bus | Built-in | Manual | Manual | postMessage |
87
+ | Shared store | Built-in | Manual | Manual | No |
88
+ | Standalone mode | Automatic | No | No | N/A |
89
+ | AI integration | Built-in | No | No | No |
90
+ | WebMCP (Chrome 146+) | Built-in | No | No | No |
91
+ | MCP Server (dev tools) | Built-in | No | No | No |
92
+ | Dependencies | **0** | 0 | Webpack 5 | N/A |
93
+ | Bundle size (min, ESM) | **~109 KB** core + lazy chunks | ~10 KB | Varies | N/A |
94
+
95
+ *Module Federation is Webpack-coupled; Wu is bundler-agnostic.
96
+
97
+ ---
98
+
99
+ ## Features
100
+
101
+ ### Core
102
+
103
+ - **13 Framework Adapters** — React, Vue, Angular, Svelte, Solid, Preact, Lit, Qwik, Alpine.js, Stencil, HTMX, Stimulus, Vanilla
104
+ - **Shadow DOM Isolation** CSS and DOM fully sandboxed per app
105
+ - **3 Sandbox Strategies** — Shadow DOM, Proxy, iframe — choose per app
106
+ - **3 CSS Isolation Modes** — `shared`, `isolated`, `fully-isolated` per app
107
+ - **Event Bus** — Namespaced pub/sub with wildcards, replay, and middleware
108
+ - **Shared Store** — Cross-app reactive state with dot-path notation and persistence
109
+ - **Plugin System** — Extend Wu with lifecycle hooks
110
+ - **Performance Monitor** — Mount time, memory, FPS tracking per app
111
+ - **Error Boundaries** — Catch and recover from micro-app failures
112
+ - **Keep-Alive** — Preserve app state when hiding/showing
113
+ - **Prefetch** — Speculation Rules API with automatic fallback chain
114
+ - **Cookie Overrides** — QA redirects individual apps to different URLs per-browser
115
+ - **Standalone Mode** — Every micro-app works without a shell, zero lock-in
116
+
117
+ ### AI (BYOL — Bring Your Own LLM)
118
+
119
+ - **4 Paradigms** — App→LLM, LLM→App, Autonomous Agent, Cross-App Orchestration
120
+ - **Tool Calling** — Register actions the AI executes autonomously
121
+ - **Streaming** — Async generator for real-time responses
122
+ - **Multi-turn** Namespaced conversations with history
123
+ - **Reactive Triggers** — Events automatically invoke the AI
124
+ - **Auto Context** — Store state, apps, events injected into the system prompt
125
+ - **10 Browser Actions** — Screenshot, click, type, navigate, read console/network
126
+ - **WebMCP** `wu.ai.expose()` registers tools via `navigator.modelContext` (Chrome 146+)
127
+ - **MCP Server** — Connect Claude Code, Cursor, or any MCP client to your live app
128
+ - **4-Layer Security** — Permissions, rate limiting, circuit breaker, loop protection
129
+ - **Workflows** — Reusable parameterized AI recipes
130
+
131
+ ---
132
+
133
+ ## Quick Start
134
+
135
+ ### 1. Register your micro-app
136
+
137
+ ```jsx
138
+ // React
139
+ import { wuReact } from 'wu-framework/adapters/react';
140
+ wuReact.register('orders', App);
141
+
142
+ // Vue
143
+ import { wuVue } from 'wu-framework/adapters/vue';
144
+ wuVue.register('products', App);
145
+
146
+ // Angular (standalone)
147
+ import { wuAngular } from 'wu-framework/adapters/angular';
148
+ wuAngular.registerStandalone('settings', AppComponent, { createApplication, createComponent });
149
+
150
+ // Svelte 5
151
+ import { wuSvelte } from 'wu-framework/adapters/svelte';
152
+ wuSvelte.registerSvelte5('dashboard', App);
153
+
154
+ // Qwik
155
+ import { wuQwik } from 'wu-framework/adapters/qwik';
156
+ wuQwik.register('widget', QwikApp);
157
+
158
+ // Alpine.js
159
+ import { wuAlpine } from 'wu-framework/adapters/alpine';
160
+ wuAlpine.register('search', initFn);
161
+
162
+ // Stencil (Web Components)
163
+ import { wuStencil } from 'wu-framework/adapters/stencil';
164
+ wuStencil.register('badge', 'my-badge');
165
+
166
+ // HTMX
167
+ import { wuHtmx } from 'wu-framework/adapters/htmx';
168
+ wuHtmx.register('feed', { template: '<div hx-get="/api/feed">...</div>' });
169
+
170
+ // Stimulus
171
+ import { wuStimulus } from 'wu-framework/adapters/stimulus';
172
+ wuStimulus.register('form', { controllers: { hello: HelloController }, template: '...' });
173
+
174
+ // Same pattern for Solid, Preact, Lit, Vanilla
175
+ ```
176
+
177
+ ### 2. Mount from the shell
178
+
179
+ ```js
180
+ import { wu } from 'wu-framework';
181
+
182
+ await wu.init({
183
+ apps: [
184
+ { name: 'header', url: 'http://localhost:3001' },
185
+ { name: 'sidebar', url: 'http://localhost:3002' },
186
+ { name: 'content', url: 'http://localhost:3003' },
187
+ ]
188
+ });
189
+
190
+ await wu.mount('header', '#header-container');
191
+ await wu.mount('sidebar', '#sidebar-container');
192
+ await wu.mount('content', '#content-container');
193
+ ```
194
+
195
+ ### 3. Cross-app communication
196
+
197
+ ```js
198
+ import { emit, on, getState, setState } from 'wu-framework';
199
+
200
+ // Events
201
+ emit('user:login', { userId: 123 });
202
+ on('user:*', (event) => console.log(event.data));
203
+
204
+ // Shared store
205
+ setState('user.name', 'John');
206
+ getState('user.name'); // 'John'
207
+ ```
208
+
209
+ ### 4. Add AI (optional, lazy-loaded)
210
+
211
+ The AI subsystem (~71 KB) is loaded on demand the first call to `wu.ai.*`
212
+ triggers a dynamic import. Sync config calls (`provider`, `action`, …) queue
213
+ and return the proxy for chaining. Async calls (`send`, `stream`, `agent`)
214
+ await the chunk transparently.
215
+
216
+ ```js
217
+ wu.ai.provider('ollama', {
218
+ endpoint: 'http://localhost:11434/api/chat',
219
+ model: 'llama3',
220
+ });
221
+
222
+ // First call triggers the chunk load
223
+ const response = await wu.ai.send('What apps are mounted?');
224
+
225
+ // Or warm up explicitly (useful before showing an AI button in UI)
226
+ await wu.aiReady();
227
+ ```
228
+
229
+ ---
230
+
231
+ ## WuCommerce — Real-World Example
232
+
233
+ Wu ships with **WuCommerce**, a Shopify-like merchant dashboard where every section is a real micro-app built with a different framework.
234
+
235
+ | Micro-app | Framework | What it does |
236
+ |-----------|-----------|-------------|
237
+ | **Topbar** | Preact | Store name, nav tabs, search, notifications, theme toggle |
238
+ | **Dashboard** | Svelte 5 | KPI cards, sparklines, recent orders, revenue chart |
239
+ | **Orders** | React | Order table with filters, search, status badges |
240
+ | **Products** | Vue 3 | Product catalog grid, stock badges, category filter |
241
+ | **Customers** | Solid.js | Customer list, segment badges, click-to-filter-orders |
242
+ | **Analytics** | Lit | Revenue bar chart, traffic donut, top products |
243
+ | **Chat** | Vanilla JS | Floating chat widget with conversations and messages |
244
+ | **Settings** | Angular 21 | Store config form, shipping zones, payment methods |
245
+
246
+ All 8 apps communicate through Wu's event bus and shared store. Click a customer → orders filter. Toggle theme → all 8 apps update. Change store name in settings → topbar updates.
247
+
248
+ ---
249
+
250
+ ## 3 Sandbox Strategies
251
+
252
+ | Mode | How it works | Tree shaking | Source maps | HMR | JS isolation |
253
+ |------|-------------|:---:|:---:|:---:|:---:|
254
+ | `module` (default) | `import()` + Proxy side-effect tracking | Yes | Yes | Yes | **None** (cleanup tracker only) |
255
+ | `strict` | Hidden iframe + real `import()` | Yes | Yes | Yes | **Iframe-level** (separate window) |
256
+ | `eval` | Fetch HTML parse `with(proxy){}` | No | No | No | **Proxy-trap-level** |
257
+
258
+ `module` is honest naming since v2.1: the proxy *tracks* side effects so they
259
+ can be undone on unmount, but **does not prevent** global pollution while the
260
+ app is running. Choose `strict` for real JS isolation.
261
+
262
+ ```js
263
+ await wu.init({
264
+ sandbox: 'strict', // global default
265
+ strictFallback: false, // CORS = Error, not silent eval (v2.1)
266
+ apps: [
267
+ { name: 'header', url: '...', sandbox: 'module' },
268
+ { name: 'analytics', url: '...', sandbox: 'strict' },
269
+ { name: 'legacy', url: '...', sandbox: 'eval' },
270
+ ]
271
+ });
272
+
273
+ // Verify what isolation level actually got applied (v2.1)
274
+ const info = wu.getSandboxInfo('analytics');
275
+ // { requestedMode: 'strict', actualMode: 'strict', isolationLevel: 'iframe', mounted: true }
276
+ ```
277
+
278
+ **Auto-cleaned on unmount:** timers, intervals, rAF, event listeners, localStorage keys, DOM mutations.
279
+ **Mount/unmount is reference-counted** (v2.1) so multi-cycle StrictMode +
280
+ Suspense flows don't tear down apps that are still needed.
281
+
282
+ ---
283
+
284
+ ## 3 CSS Isolation Modes
285
+
286
+ | Mode | Alias (v2.1) | What happens | When to use |
287
+ |------|------|-------------|-------------|
288
+ | `shared` | — | Host styles injected into Shadow DOM | Apps sharing a design system (Tailwind) |
289
+ | `isolated` | `none` | Pure Shadow DOM no external styles | Fully independent apps |
290
+ | `fully-isolated` | `own-only` | Only the app's own styles | Apps that need their CSS but not global CSS |
291
+
292
+ ```json
293
+ { "name": "my-app", "entry": "index.js", "styleMode": "own-only" }
294
+ ```
295
+
296
+ **For non-Vite bundlers** (webpack, esbuild, plain HTML), tag your styles
297
+ explicitly so `own-only` mode picks them up:
298
+
299
+ ```js
300
+ import { wu } from 'wu-framework';
301
+
302
+ const style = document.createElement('style');
303
+ style.textContent = `/* your styles */`;
304
+ wu.tagStyleAsApp(style, 'cart');
305
+ document.head.appendChild(style);
306
+ ```
307
+
308
+ ---
309
+
310
+ ## AI Paradigms
311
+
312
+ ### 1. AppLLMApp
313
+
314
+ ```js
315
+ const response = await wu.ai.send('What items are in the cart?');
316
+ ```
317
+
318
+ ### 2. LLM → App → LLM (WebMCP)
319
+
320
+ ```js
321
+ wu.ai.expose(); // Registers all tools via navigator.modelContext (Chrome 146+)
322
+ ```
323
+
324
+ ### 3. Autonomous Agent
325
+
326
+ ```js
327
+ for await (const step of wu.ai.agent('Find the top customer and show their profile')) {
328
+ console.log(`Step ${step.step}: ${step.content}`);
329
+ }
330
+ ```
331
+
332
+ ### 4. Cross-App Orchestration
333
+
334
+ ```js
335
+ const result = await wu.ai.intent('Find customer Emma and refund order #4821');
336
+ console.log(result.appsInvolved); // ['customers', 'orders']
337
+ ```
338
+
339
+ ---
340
+
341
+ ## Plugins & Hooks
342
+
343
+ ```js
344
+ import { usePlugin, createPlugin, useHook } from 'wu-framework';
345
+
346
+ usePlugin(createPlugin({
347
+ name: 'analytics',
348
+ install: (api) => api.on('app:mounted', (e) => track(e)),
349
+ afterMount: async (ctx) => log('mounted in', ctx.mountTime, 'ms')
350
+ }));
351
+
352
+ useHook('beforeMount', async (context, next) => {
353
+ console.log('Mounting:', context.appName);
354
+ await next();
355
+ });
356
+ ```
357
+
358
+ Phases: `beforeInit` `afterInit` `beforeLoad` `afterLoad` `beforeMount` → `afterMount` → `beforeUnmount` → `afterUnmount`
359
+
360
+ ---
361
+
362
+ ## Prefetch (Speculation Rules API)
363
+
364
+ ```js
365
+ wu.prefetch(['sidebar', 'analytics']);
366
+ wu.prefetch(['sidebar'], { trigger: 'hover', action: 'prerender' });
367
+ wu.prefetchAll();
368
+ ```
369
+
370
+ Fallback chain: Speculation Rules API (Chrome 121+) → `<link rel="modulepreload">` → `<link rel="prefetch">`
371
+
372
+ ---
373
+
374
+ ## Cookie Overrides for QA
375
+
376
+ ```js
377
+ wu.override('sidebar', 'http://localhost:5174');
378
+ wu.getOverrides(); // { sidebar: 'http://localhost:5174' }
379
+ wu.removeOverride('sidebar');
380
+ ```
381
+
382
+ QA sets a cookie only **their browser** sees the override. Everyone else sees production. 3-layer security: environment gate, domain allowlist, visual indicator.
383
+
384
+ ---
385
+
386
+ ## Project Stats
387
+
388
+ | Metric | Value |
389
+ |---|---|
390
+ | Source files | 73 (`src/**/*.js`) |
391
+ | Lines of code | ~24.8k |
392
+ | Test cases | **702** (24 test files, Vitest) |
393
+ | Framework adapters | 13 |
394
+ | AI modules | 12 |
395
+ | Core modules | 23 |
396
+ | Runtime dependencies | **0** |
397
+ | Bundle (ESM, minified) | **~109 KB** core (AI + sandbox modes lazy-loaded) |
398
+ | Lazy chunks | AI ~71 KB · iframe-sandbox ~4 KB · html-parser ~2 KB · script-executor ~2 KB |
399
+
400
+ ---
401
+
402
+ ## Build
403
+
404
+ ```bash
405
+ npm run build # ESM + CJS + UMD + Dev
406
+ npm run test # 702 tests (Vitest)
407
+ npm run test:coverage # Coverage report
408
+ ```
409
+
410
+ | Output | Format | Use |
411
+ |--------|--------|-----|
412
+ | `wu-framework.esm.js` | ES Module | Bundler imports |
413
+ | `wu-framework.cjs.js` | CommonJS | Node.js require |
414
+ | `wu-framework.umd.js` | UMD | CDN / script tag |
415
+ | `www.wu-framework.com.js` | ES Module | Development |
416
+
417
+ ---
418
+
419
+ ## Architecture
420
+
421
+ ```
422
+ ┌───────────────────────────────────────────────────────────────────────┐
423
+ │ SHELL (any framework) │
424
+ ├──────────┬──────────┬──────────┬──────────┬──────────┬───────────────┤
425
+ │ Shadow │ Shadow │ Shadow │ Shadow │ Shadow │ Shadow ... │
426
+ │ ┌──────┐ │ ┌──────┐ │ ┌──────┐ │ ┌──────┐ │ ┌──────┐ │ ┌──────┐ │
427
+ │ │Topbar│ │ │Dashbd│ │ │Orders│ │ │Produc│ │ │Custo.│ │ │Analyt│ │
428
+ │ │Preact│ │ │Svelte│ │ │React │ │ │Vue 3 │ │ │Solid │ │ │ Lit │ │
429
+ └──────┘ └──────┘ │ └──────┘ │ └──────┘ │ └──────┘ │ └──────┘ │
430
+ ├──────────┴──────────┴──────────┴──────────┴──────────┴───────────────┤
431
+ │ WU FRAMEWORK CORE
432
+ │ Sandbox (module/strict/eval) · EventBus (wildcards, replay) │
433
+ │ Store (dot-paths, batch) · StyleBridge (shared/isolated/fully-iso)
434
+ │ Loader · Hooks · Plugins · Cache · Prefetch · Overrides │
435
+ ├──────────────────────────────────────────────────────────────────────┤
436
+ │ WU AI (BYOL) │
437
+ │ Provider · Actions · Agent · Orchestrate · Triggers · Context │
438
+ │ Browser Actions · WebMCP · MCP Server · Workflows · Security │
439
+ └──────────────────────────────────────────────────────────────────────┘
440
+ ```
441
+
442
+ ---
443
+
444
+ ## Documentation
445
+
446
+ Full documentation at **[www.wu-framework.com](https://www.wu-framework.com)**
447
+
448
+ - [Quick Start](https://www.wu-framework.com/docs/quick-start) — Get running in 5 minutes
449
+ - [Getting Started](https://www.wu-framework.com/docs/getting-started) — Deeper tutorial with cross-app communication, includes the production-only gotchas (`wu.json` missing → MIME error, inline `entry` ignored, silent `strict→eval` fallback)
450
+ - [API Reference](https://www.wu-framework.com/docs/core/api) — Full API docs, including the [Manifest (`wu.json`) schema](./docs/api-reference.md#manifest-wujson) with entry-resolution rules
451
+ - [Event Bus](https://www.wu-framework.com/docs/core/event-bus) — Inter-app communication
452
+ - [Shared Store](https://www.wu-framework.com/docs/core/store) — Cross-app reactive state
453
+ - [Sandbox](https://www.wu-framework.com/docs/core/sandbox) — JS isolation strategies
454
+ - [AI Overview](https://www.wu-framework.com/docs/ai/overview) 4 AI paradigms
455
+ - [AI Actions](https://www.wu-framework.com/docs/ai/actions) — Register tools for the LLM
456
+ - [Browser Actions](https://www.wu-framework.com/docs/ai/browser-actions) — 10 built-in browser tools
457
+ - [MCP Server](https://www.wu-framework.com/docs/ai/mcp-server) — Connect AI agents to live apps
458
+ - [CSS Isolation](https://www.wu-framework.com/docs/guides/css-isolation) — Shadow DOM style modes
459
+ - [Deployment](https://www.wu-framework.com/docs/guides/deployment) Production deployment guide
460
+
461
+ ---
462
+
463
+ ## Browser Support
464
+
465
+ Chrome 80+, Firefox 78+, Safari 14+, Edge 80+. Shadow DOM v1 required.
466
+
467
+ ---
468
+
469
+ <div align="center">
470
+
471
+ ### What if Wu Framework could think without thinking?
472
+
473
+ </div>
474
+
475
+ ```
476
+ User: "add to cart"
477
+
478
+ Before After
479
+ ────── ─────
480
+ wu.ai.send() → LLM wu.ai.send() → ???
481
+ ~2,000 ms ~0.73 ms
482
+ $0.003 per call $0.000
483
+ ```
484
+
485
+ Something is coming. It learned from every LLM call you ever made. It doesn't need the cloud anymore.
486
+
487
+ **99.79% accuracy. 0.73 milliseconds. 800 KB. Zero GPU. Zero internet.**
488
+
489
+ 274x faster than neural networks. And it dreams.
490
+
491
+ <div align="center">
492
+
493
+ **COMING SOON**
494
+
495
+ </div>
496
+
497
+ ---
498
+
499
+ ## Wu CLI
500
+
501
+ The official CLI for wu-framework. One binary, one port, all your micro-apps.
502
+
503
+ ```bash
504
+ npm install -g @wu-framework/cli
505
+
506
+ wu create my-project # Guided interactive scaffolding (13 frameworks)
507
+ cd my-project
508
+ wu dev # Native Zig dev server on one port (Windows UTF-8 ready)
509
+ wu build # Production build (parallel Vite + React/Vue/Svelte shells)
510
+ wu serve # Serve production build
511
+ ```
512
+
513
+ Features:
514
+ - Native SIMD HTTP server written in Zig 0.16.0
515
+ - **Guided Dialogue**: Step-by-step project creation with intelligent naming.
516
+ - **Multi-Framework Shells**: Generate shells in React (with `WuSlot`), Vue, or Svelte.
517
+ - Three-tier compilation: Native Zig JSX (0-2ms) -> Compiler Daemon (10-50ms) -> Node fallback
518
+ - Two-level cache with 73-138x speedup on warm restart
519
+ - Theme-aware production shell with dark/light toggle
520
+ - 13 framework app templates with CSS variable theming
521
+
522
+ See [@wu-framework/cli](https://github.com/LuisPadre25/wu-cli) for full documentation.
523
+
524
+ ---
525
+
526
+ ## v2.0 Migration
527
+
528
+ Most code keeps working — `wu.mount`, `wu.ai.*`, `wuReact.register`, and
529
+ `wu.emit/on/store` are unchanged. The transparent `wu.ai` proxy means existing
530
+ `wu.ai.provider().action().send(...)` chains keep their sync semantics.
531
+
532
+ What did change (full list in [CHANGELOG.md](./CHANGELOG.md)):
533
+
534
+ ```js
535
+ // AI helper classes moved to a subpath (lazy chunk).
536
+ - import { WuAI, WuAIAgent } from 'wu-framework';
537
+ + import { WuAI, WuAIAgent } from 'wu-framework/ai';
538
+
539
+ // Sandbox internals moved to subpaths (also lazy).
540
+ - import { WuIframeSandbox } from 'wu-framework';
541
+ + import { WuIframeSandbox } from 'wu-framework/sandbox/iframe';
542
+
543
+ // Eager `adapters` object replaced by async loader.
544
+ - import { adapters } from 'wu-framework/adapters';
545
+ - adapters.react.register('cart', App);
546
+ + import { loadAdapter } from 'wu-framework/adapters';
547
+ + const wuReact = await loadAdapter('react');
548
+ + wuReact.register('cart', App);
549
+
550
+ // (or just import the specific subpath — same as before)
551
+ import { wuReact } from 'wu-framework/adapters/react';
552
+ ```
553
+
554
+ Security changes worth knowing:
555
+ - `WuStore.set('__proto__.x', v)` now throws (was silently polluting `Object.prototype`).
556
+ - `wu.eventBus.emit(name, data, { appName: 'wu-ai' })` from user code is rejected in `strictMode` unless you hold the internal token. Use a registered app name + `registerApp()` token instead.
557
+
558
+ ## Contributing
559
+
560
+ Contributions welcome. Please open an issue first to discuss what you'd like to change.
561
+
562
+ ## License
563
+
564
+ [MIT](./LICENSE) -- Free for personal and commercial use.
565
+
566
+ See [LICENSE-COMMERCIAL.md](./LICENSE-COMMERCIAL.md) for optional enterprise support and consulting.
567
+
568
+ ---
569
+
570
+ *2026 Wu Framework*