wu-framework 2.1.0 → 2.1.2

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 (63) hide show
  1. package/LICENSE +39 -39
  2. package/README.md +570 -570
  3. package/dist/adapters/angular/index.d.ts +154 -154
  4. package/dist/adapters/angular/index.js.map +1 -1
  5. package/dist/adapters/angular.d.ts +3 -3
  6. package/dist/adapters/index.js.map +1 -1
  7. package/dist/adapters/lit/index.d.ts +120 -120
  8. package/dist/adapters/lit/index.js.map +1 -1
  9. package/dist/adapters/lit.d.ts +3 -3
  10. package/dist/adapters/preact/index.d.ts +108 -108
  11. package/dist/adapters/preact/index.js.map +1 -1
  12. package/dist/adapters/preact.d.ts +3 -3
  13. package/dist/adapters/qwik/index.js +1 -1
  14. package/dist/adapters/qwik/index.js.map +1 -1
  15. package/dist/adapters/react/index.d.ts +246 -246
  16. package/dist/adapters/react/index.js.map +1 -1
  17. package/dist/adapters/react.d.ts +3 -3
  18. package/dist/adapters/shared.js.map +1 -1
  19. package/dist/adapters/solid/index.d.ts +101 -101
  20. package/dist/adapters/solid/index.js.map +1 -1
  21. package/dist/adapters/solid.d.ts +3 -3
  22. package/dist/adapters/svelte/index.d.ts +166 -166
  23. package/dist/adapters/svelte/index.js.map +1 -1
  24. package/dist/adapters/svelte.d.ts +3 -3
  25. package/dist/adapters/vanilla/index.d.ts +179 -179
  26. package/dist/adapters/vanilla/index.js.map +1 -1
  27. package/dist/adapters/vanilla.d.ts +3 -3
  28. package/dist/adapters/vue/index.d.ts +299 -299
  29. package/dist/adapters/vue/index.js.map +1 -1
  30. package/dist/adapters/vue.d.ts +3 -3
  31. package/dist/ai/wu-ai.js.map +1 -1
  32. package/dist/core/wu-html-parser.js +2 -0
  33. package/dist/core/wu-html-parser.js.map +1 -0
  34. package/dist/core/wu-iframe-sandbox.js +2 -0
  35. package/dist/core/wu-iframe-sandbox.js.map +1 -0
  36. package/dist/core/wu-loader.js +2 -0
  37. package/dist/core/wu-loader.js.map +1 -0
  38. package/dist/core/wu-mcp-bridge.js.map +1 -1
  39. package/dist/core/wu-script-executor.js +2 -0
  40. package/dist/core/wu-script-executor.js.map +1 -0
  41. package/dist/wu-ai-browser-primitives-BDKXJlwc.js.map +1 -1
  42. package/dist/wu-framework.cjs.js +2 -2
  43. package/dist/wu-framework.cjs.js.map +1 -1
  44. package/dist/wu-framework.dev.js +8697 -9142
  45. package/dist/wu-framework.dev.js.map +1 -1
  46. package/dist/wu-framework.esm.js +2 -2
  47. package/dist/wu-framework.esm.js.map +1 -1
  48. package/dist/wu-framework.umd.js +2 -2
  49. package/dist/wu-framework.umd.js.map +1 -1
  50. package/dist/wu-logger-fJfUHBGA.js.map +1 -1
  51. package/integrations/astro/README.md +127 -127
  52. package/integrations/astro/WuApp.astro +63 -63
  53. package/integrations/astro/WuShell.astro +39 -39
  54. package/integrations/astro/index.js +68 -68
  55. package/integrations/astro/package.json +38 -38
  56. package/integrations/astro/types.d.ts +53 -53
  57. package/package.json +218 -218
  58. package/dist/wu-html-parser.js +0 -2
  59. package/dist/wu-html-parser.js.map +0 -1
  60. package/dist/wu-iframe-sandbox.js +0 -2
  61. package/dist/wu-iframe-sandbox.js.map +0 -1
  62. package/dist/wu-script-executor.js +0 -2
  63. package/dist/wu-script-executor.js.map +0 -1
package/README.md CHANGED
@@ -1,570 +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-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. App → LLM → App
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 | 79 |
391
- | Lines of code | 23,442 |
392
- | Test cases | **650** |
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
450
- - [API Reference](https://www.wu-framework.com/docs/core/api) — Full API docs
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*
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. App → LLM → App
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*