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.
- package/LICENSE +39 -39
- package/README.md +570 -570
- package/dist/adapters/angular/index.d.ts +154 -154
- package/dist/adapters/angular/index.js.map +1 -1
- package/dist/adapters/angular.d.ts +3 -3
- package/dist/adapters/index.js.map +1 -1
- package/dist/adapters/lit/index.d.ts +120 -120
- package/dist/adapters/lit/index.js.map +1 -1
- package/dist/adapters/lit.d.ts +3 -3
- package/dist/adapters/preact/index.d.ts +108 -108
- package/dist/adapters/preact/index.js.map +1 -1
- package/dist/adapters/preact.d.ts +3 -3
- package/dist/adapters/qwik/index.js +1 -1
- package/dist/adapters/qwik/index.js.map +1 -1
- package/dist/adapters/react/index.d.ts +246 -246
- package/dist/adapters/react/index.js.map +1 -1
- package/dist/adapters/react.d.ts +3 -3
- package/dist/adapters/shared.js.map +1 -1
- package/dist/adapters/solid/index.d.ts +101 -101
- package/dist/adapters/solid/index.js.map +1 -1
- package/dist/adapters/solid.d.ts +3 -3
- package/dist/adapters/svelte/index.d.ts +166 -166
- package/dist/adapters/svelte/index.js.map +1 -1
- package/dist/adapters/svelte.d.ts +3 -3
- package/dist/adapters/vanilla/index.d.ts +179 -179
- package/dist/adapters/vanilla/index.js.map +1 -1
- package/dist/adapters/vanilla.d.ts +3 -3
- package/dist/adapters/vue/index.d.ts +299 -299
- package/dist/adapters/vue/index.js.map +1 -1
- package/dist/adapters/vue.d.ts +3 -3
- package/dist/ai/wu-ai.js.map +1 -1
- package/dist/core/wu-html-parser.js +2 -0
- package/dist/core/wu-html-parser.js.map +1 -0
- package/dist/core/wu-iframe-sandbox.js +2 -0
- package/dist/core/wu-iframe-sandbox.js.map +1 -0
- package/dist/core/wu-loader.js +2 -0
- package/dist/core/wu-loader.js.map +1 -0
- package/dist/core/wu-mcp-bridge.js.map +1 -1
- package/dist/core/wu-script-executor.js +2 -0
- package/dist/core/wu-script-executor.js.map +1 -0
- package/dist/wu-ai-browser-primitives-BDKXJlwc.js.map +1 -1
- package/dist/wu-framework.cjs.js +2 -2
- package/dist/wu-framework.cjs.js.map +1 -1
- package/dist/wu-framework.dev.js +8697 -9142
- package/dist/wu-framework.dev.js.map +1 -1
- package/dist/wu-framework.esm.js +2 -2
- package/dist/wu-framework.esm.js.map +1 -1
- package/dist/wu-framework.umd.js +2 -2
- package/dist/wu-framework.umd.js.map +1 -1
- package/dist/wu-logger-fJfUHBGA.js.map +1 -1
- package/integrations/astro/README.md +127 -127
- package/integrations/astro/WuApp.astro +63 -63
- package/integrations/astro/WuShell.astro +39 -39
- package/integrations/astro/index.js +68 -68
- package/integrations/astro/package.json +38 -38
- package/integrations/astro/types.d.ts +53 -53
- package/package.json +218 -218
- package/dist/wu-html-parser.js +0 -2
- package/dist/wu-html-parser.js.map +0 -1
- package/dist/wu-iframe-sandbox.js +0 -2
- package/dist/wu-iframe-sandbox.js.map +0 -1
- package/dist/wu-script-executor.js +0 -2
- package/dist/wu-script-executor.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wu-logger-fJfUHBGA.js","sources":["../src/core/wu-logger.js"],"sourcesContent":["/**\
|
|
1
|
+
{"version":3,"file":"wu-logger-fJfUHBGA.js","sources":["../src/core/wu-logger.js"],"sourcesContent":["/**\n * 📝 WU-LOGGER: Sistema de logging inteligente para entornos\n * Controla los logs automáticamente según el entorno\n */\n\nexport class WuLogger {\n constructor() {\n // Detectar entorno automáticamente\n this.isDevelopment = this.detectEnvironment();\n // En desarrollo: warn (menos ruido), en producción: error\n this.logLevel = this.isDevelopment ? 'warn' : 'error';\n\n this.levels = {\n debug: 0,\n info: 1,\n warn: 2,\n error: 3,\n silent: 4\n };\n }\n\n /**\n * Detectar si estamos en desarrollo\n */\n detectEnvironment() {\n // 1. Explicit flag takes priority\n if (typeof window !== 'undefined' && window.WU_DEBUG === true) return true;\n if (typeof window !== 'undefined' && window.WU_DEBUG === false) return false;\n\n // 2. NODE_ENV check (works in bundlers and Node)\n if (typeof process !== 'undefined' && process.env?.NODE_ENV === 'production') return false;\n if (typeof process !== 'undefined' && process.env?.NODE_ENV === 'development') return true;\n\n // 3. Browser heuristics (only if window exists)\n if (typeof window !== 'undefined' && window.location) {\n const hostname = window.location.hostname;\n if (hostname === 'localhost' || hostname === '127.0.0.1' || hostname === '[::1]') return true;\n\n // URL param override\n try {\n if (new URLSearchParams(window.location.search).has('wu-debug')) return true;\n } catch {}\n }\n\n // 4. Default: assume production\n return false;\n }\n\n /**\n * Configurar nivel de logging\n */\n setLevel(level) {\n this.logLevel = level;\n return this;\n }\n\n /**\n * Habilitar/deshabilitar development mode\n */\n setDevelopment(isDev) {\n this.isDevelopment = isDev;\n this.logLevel = isDev ? 'debug' : 'error';\n return this;\n }\n\n /**\n * Verificar si debemos mostrar el log\n */\n shouldLog(level) {\n return this.levels[level] >= this.levels[this.logLevel];\n }\n\n /**\n * Logging methods\n */\n debug(...args) {\n if (this.shouldLog('debug')) {\n console.log(...args);\n }\n }\n\n info(...args) {\n if (this.shouldLog('info')) {\n console.info(...args);\n }\n }\n\n warn(...args) {\n if (this.shouldLog('warn')) {\n console.warn(...args);\n }\n }\n\n error(...args) {\n if (this.shouldLog('error')) {\n console.error(...args);\n }\n }\n\n /**\n * Logging con contexto Wu\n */\n wu(level, ...args) {\n if (this.shouldLog(level)) {\n const method = level === 'debug' ? 'log' : level;\n console[method]('[Wu]', ...args);\n }\n }\n\n /**\n * Helper methods específicos para Wu\n */\n wuDebug(...args) { this.wu('debug', ...args); }\n wuInfo(...args) { this.wu('info', ...args); }\n wuWarn(...args) { this.wu('warn', ...args); }\n wuError(...args) { this.wu('error', ...args); }\n}\n\n// Singleton instance\nexport const logger = new WuLogger();\n\n// Helper para compatibilidad con logs existentes\nexport const wuLog = {\n debug: (...args) => logger.wuDebug(...args),\n info: (...args) => logger.wuInfo(...args),\n warn: (...args) => logger.wuWarn(...args),\n error: (...args) => logger.wuError(...args)\n};\n\n/**\n * 🔇 Silenciar todos los logs de Wu Framework\n * Útil en producción para eliminar todo el ruido\n */\nexport function silenceAllLogs() {\n logger.setLevel('silent');\n}\n\n/**\n * 🔊 Restaurar logs (nivel debug)\n */\nexport function enableAllLogs() {\n logger.setLevel('debug');\n}"],"names":["logger","constructor","this","isDevelopment","detectEnvironment","logLevel","levels","debug","info","warn","error","silent","window","WU_DEBUG","process","env","NODE_ENV","location","hostname","URLSearchParams","search","has","setLevel","level","setDevelopment","isDev","shouldLog","args","console","log","wu","wuDebug","wuInfo","wuWarn","wuError"],"mappings":"AAuHY,MAACA,EAAS,IAlHf,MACL,WAAAC,GAEEC,KAAKC,cAAgBD,KAAKE,oBAE1BF,KAAKG,SAAWH,KAAKC,cAAgB,OAAS,QAE9CD,KAAKI,OAAS,CACZC,MAAO,EACPC,KAAM,EACNC,KAAM,EACNC,MAAO,EACPC,OAAQ,EAEZ,CAKA,iBAAAP,GAEE,GAAsB,oBAAXQ,SAA8C,IAApBA,OAAOC,SAAmB,OAAO,EACtE,GAAsB,oBAAXD,SAA8C,IAApBA,OAAOC,SAAoB,OAAO,EAGvE,GAAuB,oBAAZC,SAAqD,eAA1BA,QAAQC,KAAKC,SAA2B,OAAO,EACrF,GAAuB,oBAAZF,SAAqD,gBAA1BA,QAAQC,KAAKC,SAA4B,OAAO,EAGtF,GAAsB,oBAAXJ,QAA0BA,OAAOK,SAAU,CACpD,MAAMC,EAAWN,OAAOK,SAASC,SACjC,GAAiB,cAAbA,GAAyC,cAAbA,GAAyC,UAAbA,EAAsB,OAAO,EAGzF,IACE,GAAI,IAAIC,gBAAgBP,OAAOK,SAASG,QAAQC,IAAI,YAAa,OAAO,CAC1E,CAAE,MAAO,CACX,CAGA,OAAO,CACT,CAKA,QAAAC,CAASC,GAEP,OADArB,KAAKG,SAAWkB,EACTrB,IACT,CAKA,cAAAsB,CAAeC,GAGb,OAFAvB,KAAKC,cAAgBsB,EACrBvB,KAAKG,SAAWoB,EAAQ,QAAU,QAC3BvB,IACT,CAKA,SAAAwB,CAAUH,GACR,OAAOrB,KAAKI,OAAOiB,IAAUrB,KAAKI,OAAOJ,KAAKG,SAChD,CAKA,KAAAE,IAASoB,GACHzB,KAAKwB,UAAU,UACjBE,QAAQC,OAAOF,EAEnB,CAEA,IAAAnB,IAAQmB,GACFzB,KAAKwB,UAAU,SACjBE,QAAQpB,QAAQmB,EAEpB,CAEA,IAAAlB,IAAQkB,GACFzB,KAAKwB,UAAU,SACjBE,QAAQnB,QAAQkB,EAEpB,CAEA,KAAAjB,IAASiB,GACHzB,KAAKwB,UAAU,UACjBE,QAAQlB,SAASiB,EAErB,CAKA,EAAAG,CAAGP,KAAUI,GACX,GAAIzB,KAAKwB,UAAUH,GAAQ,CAEzBK,QADyB,UAAVL,EAAoB,MAAQA,GAC3B,UAAWI,EAC7B,CACF,CAKA,OAAAI,IAAWJ,GAAQzB,KAAK4B,GAAG,WAAYH,EAAO,CAC9C,MAAAK,IAAUL,GAAQzB,KAAK4B,GAAG,UAAWH,EAAO,CAC5C,MAAAM,IAAUN,GAAQzB,KAAK4B,GAAG,UAAWH,EAAO,CAC5C,OAAAO,IAAWP,GAAQzB,KAAK4B,GAAG,WAAYH,EAAO"}
|
|
@@ -1,127 +1,127 @@
|
|
|
1
|
-
# @wu-framework/astro
|
|
2
|
-
|
|
3
|
-
Astro integration for **wu-framework** microfrontends. Mount wu micro-apps inside any Astro site with zero runtime overhead at build time.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm install @wu-framework/astro wu-framework
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Quick Start
|
|
12
|
-
|
|
13
|
-
### 1. Add the integration
|
|
14
|
-
|
|
15
|
-
```js
|
|
16
|
-
// astro.config.mjs
|
|
17
|
-
import { defineConfig } from 'astro/config';
|
|
18
|
-
import wu from '@wu-framework/astro';
|
|
19
|
-
|
|
20
|
-
export default defineConfig({
|
|
21
|
-
integrations: [
|
|
22
|
-
wu({
|
|
23
|
-
apps: [
|
|
24
|
-
{ name: 'header', url: '/apps/header', strategy: 'eager' },
|
|
25
|
-
{ name: 'dashboard', url: '/apps/dashboard' }
|
|
26
|
-
]
|
|
27
|
-
})
|
|
28
|
-
]
|
|
29
|
-
});
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
The integration injects the wu-framework runtime and auto-calls `wu.init()` with your apps config.
|
|
33
|
-
|
|
34
|
-
### 2. Mount micro-apps in pages
|
|
35
|
-
|
|
36
|
-
```astro
|
|
37
|
-
---
|
|
38
|
-
import WuApp from '@wu-framework/astro/WuApp.astro';
|
|
39
|
-
---
|
|
40
|
-
|
|
41
|
-
<WuApp name="header" />
|
|
42
|
-
<WuApp name="dashboard" lazy />
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
The `lazy` prop defers mounting until the element scrolls into view (uses `IntersectionObserver` with a 200px root margin).
|
|
46
|
-
|
|
47
|
-
## Components
|
|
48
|
-
|
|
49
|
-
### `WuApp`
|
|
50
|
-
|
|
51
|
-
Renders a mount point and calls `wu.mount()` on the client.
|
|
52
|
-
|
|
53
|
-
| Prop | Type | Default | Description |
|
|
54
|
-
| ------- | --------- | ------- | ---------------------------------------- |
|
|
55
|
-
| `name` | `string` | — | Name of the registered micro-app |
|
|
56
|
-
| `lazy` | `boolean` | `false` | Defer mount until visible |
|
|
57
|
-
| `class` | `string` | — | CSS class(es) for the container |
|
|
58
|
-
| `style` | `string` | — | Inline styles for the container |
|
|
59
|
-
|
|
60
|
-
### `WuShell`
|
|
61
|
-
|
|
62
|
-
Layout wrapper that calls `wu.init()` on the client. Useful when you want page-level control instead of the global integration.
|
|
63
|
-
|
|
64
|
-
```astro
|
|
65
|
-
---
|
|
66
|
-
import WuShell from '@wu-framework/astro/WuShell.astro';
|
|
67
|
-
---
|
|
68
|
-
|
|
69
|
-
<WuShell apps={[{ name: 'header', url: '/apps/header' }]}>
|
|
70
|
-
<main>Page content here</main>
|
|
71
|
-
</WuShell>
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
| Prop | Type | Default | Description |
|
|
75
|
-
| --------- | -------------- | ------- | --------------------------- |
|
|
76
|
-
| `apps` | `WuAppConfig[]`| — | Micro-app definitions |
|
|
77
|
-
| `sandbox` | `string` | — | Sandbox mode |
|
|
78
|
-
| `debug` | `boolean` | `false` | Enable debug logging |
|
|
79
|
-
|
|
80
|
-
## Integration Options
|
|
81
|
-
|
|
82
|
-
| Option | Type | Default | Description |
|
|
83
|
-
| --------- | --------------- | ------- | ----------------------------------------------- |
|
|
84
|
-
| `apps` | `WuAppConfig[]` | `[]` | Auto-register apps via `wu.init()` |
|
|
85
|
-
| `sandbox` | `string` | — | Global sandbox mode (`module`/`strict`/`eval`) |
|
|
86
|
-
| `cdn` | `string` | — | CDN URL for wu-framework UMD bundle |
|
|
87
|
-
| `debug` | `boolean` | `false` | Enable debug logging |
|
|
88
|
-
|
|
89
|
-
## Usage Patterns
|
|
90
|
-
|
|
91
|
-
### Integration only (auto-init)
|
|
92
|
-
|
|
93
|
-
Use the integration in `astro.config.mjs` to auto-init, then mount with `WuApp`:
|
|
94
|
-
|
|
95
|
-
```astro
|
|
96
|
-
---
|
|
97
|
-
import WuApp from '@wu-framework/astro/WuApp.astro';
|
|
98
|
-
---
|
|
99
|
-
<WuApp name="header" />
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
### Shell layout (page-level init)
|
|
103
|
-
|
|
104
|
-
Skip the integration's `apps` option and use `WuShell` for per-page control:
|
|
105
|
-
|
|
106
|
-
```astro
|
|
107
|
-
---
|
|
108
|
-
import WuShell from '@wu-framework/astro/WuShell.astro';
|
|
109
|
-
import WuApp from '@wu-framework/astro/WuApp.astro';
|
|
110
|
-
---
|
|
111
|
-
<WuShell apps={[{ name: 'nav', url: '/apps/nav' }]}>
|
|
112
|
-
<WuApp name="nav" />
|
|
113
|
-
<slot />
|
|
114
|
-
</WuShell>
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
### CDN mode
|
|
118
|
-
|
|
119
|
-
Load wu-framework from a CDN instead of bundling it:
|
|
120
|
-
|
|
121
|
-
```js
|
|
122
|
-
wu({ cdn: 'https://cdn.example.com/wu-framework@1.1.8/dist/wu-framework.umd.js' })
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
## License
|
|
126
|
-
|
|
127
|
-
MIT
|
|
1
|
+
# @wu-framework/astro
|
|
2
|
+
|
|
3
|
+
Astro integration for **wu-framework** microfrontends. Mount wu micro-apps inside any Astro site with zero runtime overhead at build time.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @wu-framework/astro wu-framework
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
### 1. Add the integration
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
// astro.config.mjs
|
|
17
|
+
import { defineConfig } from 'astro/config';
|
|
18
|
+
import wu from '@wu-framework/astro';
|
|
19
|
+
|
|
20
|
+
export default defineConfig({
|
|
21
|
+
integrations: [
|
|
22
|
+
wu({
|
|
23
|
+
apps: [
|
|
24
|
+
{ name: 'header', url: '/apps/header', strategy: 'eager' },
|
|
25
|
+
{ name: 'dashboard', url: '/apps/dashboard' }
|
|
26
|
+
]
|
|
27
|
+
})
|
|
28
|
+
]
|
|
29
|
+
});
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
The integration injects the wu-framework runtime and auto-calls `wu.init()` with your apps config.
|
|
33
|
+
|
|
34
|
+
### 2. Mount micro-apps in pages
|
|
35
|
+
|
|
36
|
+
```astro
|
|
37
|
+
---
|
|
38
|
+
import WuApp from '@wu-framework/astro/WuApp.astro';
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
<WuApp name="header" />
|
|
42
|
+
<WuApp name="dashboard" lazy />
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
The `lazy` prop defers mounting until the element scrolls into view (uses `IntersectionObserver` with a 200px root margin).
|
|
46
|
+
|
|
47
|
+
## Components
|
|
48
|
+
|
|
49
|
+
### `WuApp`
|
|
50
|
+
|
|
51
|
+
Renders a mount point and calls `wu.mount()` on the client.
|
|
52
|
+
|
|
53
|
+
| Prop | Type | Default | Description |
|
|
54
|
+
| ------- | --------- | ------- | ---------------------------------------- |
|
|
55
|
+
| `name` | `string` | — | Name of the registered micro-app |
|
|
56
|
+
| `lazy` | `boolean` | `false` | Defer mount until visible |
|
|
57
|
+
| `class` | `string` | — | CSS class(es) for the container |
|
|
58
|
+
| `style` | `string` | — | Inline styles for the container |
|
|
59
|
+
|
|
60
|
+
### `WuShell`
|
|
61
|
+
|
|
62
|
+
Layout wrapper that calls `wu.init()` on the client. Useful when you want page-level control instead of the global integration.
|
|
63
|
+
|
|
64
|
+
```astro
|
|
65
|
+
---
|
|
66
|
+
import WuShell from '@wu-framework/astro/WuShell.astro';
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
<WuShell apps={[{ name: 'header', url: '/apps/header' }]}>
|
|
70
|
+
<main>Page content here</main>
|
|
71
|
+
</WuShell>
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
| Prop | Type | Default | Description |
|
|
75
|
+
| --------- | -------------- | ------- | --------------------------- |
|
|
76
|
+
| `apps` | `WuAppConfig[]`| — | Micro-app definitions |
|
|
77
|
+
| `sandbox` | `string` | — | Sandbox mode |
|
|
78
|
+
| `debug` | `boolean` | `false` | Enable debug logging |
|
|
79
|
+
|
|
80
|
+
## Integration Options
|
|
81
|
+
|
|
82
|
+
| Option | Type | Default | Description |
|
|
83
|
+
| --------- | --------------- | ------- | ----------------------------------------------- |
|
|
84
|
+
| `apps` | `WuAppConfig[]` | `[]` | Auto-register apps via `wu.init()` |
|
|
85
|
+
| `sandbox` | `string` | — | Global sandbox mode (`module`/`strict`/`eval`) |
|
|
86
|
+
| `cdn` | `string` | — | CDN URL for wu-framework UMD bundle |
|
|
87
|
+
| `debug` | `boolean` | `false` | Enable debug logging |
|
|
88
|
+
|
|
89
|
+
## Usage Patterns
|
|
90
|
+
|
|
91
|
+
### Integration only (auto-init)
|
|
92
|
+
|
|
93
|
+
Use the integration in `astro.config.mjs` to auto-init, then mount with `WuApp`:
|
|
94
|
+
|
|
95
|
+
```astro
|
|
96
|
+
---
|
|
97
|
+
import WuApp from '@wu-framework/astro/WuApp.astro';
|
|
98
|
+
---
|
|
99
|
+
<WuApp name="header" />
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Shell layout (page-level init)
|
|
103
|
+
|
|
104
|
+
Skip the integration's `apps` option and use `WuShell` for per-page control:
|
|
105
|
+
|
|
106
|
+
```astro
|
|
107
|
+
---
|
|
108
|
+
import WuShell from '@wu-framework/astro/WuShell.astro';
|
|
109
|
+
import WuApp from '@wu-framework/astro/WuApp.astro';
|
|
110
|
+
---
|
|
111
|
+
<WuShell apps={[{ name: 'nav', url: '/apps/nav' }]}>
|
|
112
|
+
<WuApp name="nav" />
|
|
113
|
+
<slot />
|
|
114
|
+
</WuShell>
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### CDN mode
|
|
118
|
+
|
|
119
|
+
Load wu-framework from a CDN instead of bundling it:
|
|
120
|
+
|
|
121
|
+
```js
|
|
122
|
+
wu({ cdn: 'https://cdn.example.com/wu-framework@1.1.8/dist/wu-framework.umd.js' })
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## License
|
|
126
|
+
|
|
127
|
+
MIT
|
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
---
|
|
2
|
-
/**
|
|
3
|
-
* WuApp — Mount point for a wu micro-app.
|
|
4
|
-
*
|
|
5
|
-
* Renders a <div> and runs wu.mount() on the client to hydrate
|
|
6
|
-
* the named micro-app into it. When `lazy` is true the mount
|
|
7
|
-
* is deferred until the element scrolls into view.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ---
|
|
11
|
-
* import WuApp from '@wu-framework/astro/WuApp.astro';
|
|
12
|
-
* ---
|
|
13
|
-
* <WuApp name="header" />
|
|
14
|
-
* <WuApp name="dashboard" lazy />
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
interface Props {
|
|
18
|
-
/** Name of the registered wu micro-app */
|
|
19
|
-
name: string;
|
|
20
|
-
/** Defer mounting until the element is visible */
|
|
21
|
-
lazy?: boolean;
|
|
22
|
-
/** CSS class(es) for the container div */
|
|
23
|
-
class?: string;
|
|
24
|
-
/** Inline styles for the container div */
|
|
25
|
-
style?: string;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const { name, lazy = false } = Astro.props;
|
|
29
|
-
const id = `wu-app-${name}`;
|
|
30
|
-
---
|
|
31
|
-
|
|
32
|
-
<div
|
|
33
|
-
id={id}
|
|
34
|
-
class={Astro.props.class}
|
|
35
|
-
style={Astro.props.style}
|
|
36
|
-
data-wu-app={name}
|
|
37
|
-
data-wu-lazy={lazy}
|
|
38
|
-
></div>
|
|
39
|
-
|
|
40
|
-
<script define:vars={{ id, name, lazy }}>
|
|
41
|
-
async function mountApp() {
|
|
42
|
-
const { wu } = await import('wu-framework');
|
|
43
|
-
await wu.mount(name, `#${id}`);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (lazy) {
|
|
47
|
-
const el = document.getElementById(id);
|
|
48
|
-
if (el) {
|
|
49
|
-
const observer = new IntersectionObserver(
|
|
50
|
-
(entries) => {
|
|
51
|
-
if (entries[0].isIntersecting) {
|
|
52
|
-
observer.disconnect();
|
|
53
|
-
mountApp();
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
{ rootMargin: '200px' }
|
|
57
|
-
);
|
|
58
|
-
observer.observe(el);
|
|
59
|
-
}
|
|
60
|
-
} else {
|
|
61
|
-
mountApp();
|
|
62
|
-
}
|
|
63
|
-
</script>
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* WuApp — Mount point for a wu micro-app.
|
|
4
|
+
*
|
|
5
|
+
* Renders a <div> and runs wu.mount() on the client to hydrate
|
|
6
|
+
* the named micro-app into it. When `lazy` is true the mount
|
|
7
|
+
* is deferred until the element scrolls into view.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ---
|
|
11
|
+
* import WuApp from '@wu-framework/astro/WuApp.astro';
|
|
12
|
+
* ---
|
|
13
|
+
* <WuApp name="header" />
|
|
14
|
+
* <WuApp name="dashboard" lazy />
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
interface Props {
|
|
18
|
+
/** Name of the registered wu micro-app */
|
|
19
|
+
name: string;
|
|
20
|
+
/** Defer mounting until the element is visible */
|
|
21
|
+
lazy?: boolean;
|
|
22
|
+
/** CSS class(es) for the container div */
|
|
23
|
+
class?: string;
|
|
24
|
+
/** Inline styles for the container div */
|
|
25
|
+
style?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const { name, lazy = false } = Astro.props;
|
|
29
|
+
const id = `wu-app-${name}`;
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
<div
|
|
33
|
+
id={id}
|
|
34
|
+
class={Astro.props.class}
|
|
35
|
+
style={Astro.props.style}
|
|
36
|
+
data-wu-app={name}
|
|
37
|
+
data-wu-lazy={lazy}
|
|
38
|
+
></div>
|
|
39
|
+
|
|
40
|
+
<script define:vars={{ id, name, lazy }}>
|
|
41
|
+
async function mountApp() {
|
|
42
|
+
const { wu } = await import('wu-framework');
|
|
43
|
+
await wu.mount(name, `#${id}`);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (lazy) {
|
|
47
|
+
const el = document.getElementById(id);
|
|
48
|
+
if (el) {
|
|
49
|
+
const observer = new IntersectionObserver(
|
|
50
|
+
(entries) => {
|
|
51
|
+
if (entries[0].isIntersecting) {
|
|
52
|
+
observer.disconnect();
|
|
53
|
+
mountApp();
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
{ rootMargin: '200px' }
|
|
57
|
+
);
|
|
58
|
+
observer.observe(el);
|
|
59
|
+
}
|
|
60
|
+
} else {
|
|
61
|
+
mountApp();
|
|
62
|
+
}
|
|
63
|
+
</script>
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
---
|
|
2
|
-
/**
|
|
3
|
-
* WuShell — Layout wrapper that initializes wu-framework on the client.
|
|
4
|
-
*
|
|
5
|
-
* Wraps page content in a <slot /> and runs wu.init() with the
|
|
6
|
-
* provided app configuration once the page loads.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ---
|
|
10
|
-
* import WuShell from '@wu-framework/astro/WuShell.astro';
|
|
11
|
-
* ---
|
|
12
|
-
* <WuShell apps={[{ name: 'header', url: '/apps/header' }]}>
|
|
13
|
-
* <main>My page content</main>
|
|
14
|
-
* </WuShell>
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
interface Props {
|
|
18
|
-
/** Array of micro-app definitions to register with wu.init() */
|
|
19
|
-
apps: Array<{
|
|
20
|
-
name: string;
|
|
21
|
-
url: string;
|
|
22
|
-
strategy?: 'eager' | 'lazy' | 'manual';
|
|
23
|
-
}>;
|
|
24
|
-
/** Sandbox isolation mode */
|
|
25
|
-
sandbox?: 'module' | 'strict' | 'eval';
|
|
26
|
-
/** Enable debug logging */
|
|
27
|
-
debug?: boolean;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const { apps, sandbox, debug = false } = Astro.props;
|
|
31
|
-
---
|
|
32
|
-
|
|
33
|
-
<slot />
|
|
34
|
-
|
|
35
|
-
<script define:vars={{ apps, sandbox, debug }}>
|
|
36
|
-
import('wu-framework').then(({ wu }) => {
|
|
37
|
-
wu.init({ apps, sandbox, debug });
|
|
38
|
-
});
|
|
39
|
-
</script>
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* WuShell — Layout wrapper that initializes wu-framework on the client.
|
|
4
|
+
*
|
|
5
|
+
* Wraps page content in a <slot /> and runs wu.init() with the
|
|
6
|
+
* provided app configuration once the page loads.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ---
|
|
10
|
+
* import WuShell from '@wu-framework/astro/WuShell.astro';
|
|
11
|
+
* ---
|
|
12
|
+
* <WuShell apps={[{ name: 'header', url: '/apps/header' }]}>
|
|
13
|
+
* <main>My page content</main>
|
|
14
|
+
* </WuShell>
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
interface Props {
|
|
18
|
+
/** Array of micro-app definitions to register with wu.init() */
|
|
19
|
+
apps: Array<{
|
|
20
|
+
name: string;
|
|
21
|
+
url: string;
|
|
22
|
+
strategy?: 'eager' | 'lazy' | 'manual';
|
|
23
|
+
}>;
|
|
24
|
+
/** Sandbox isolation mode */
|
|
25
|
+
sandbox?: 'module' | 'strict' | 'eval';
|
|
26
|
+
/** Enable debug logging */
|
|
27
|
+
debug?: boolean;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const { apps, sandbox, debug = false } = Astro.props;
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
<slot />
|
|
34
|
+
|
|
35
|
+
<script define:vars={{ apps, sandbox, debug }}>
|
|
36
|
+
import('wu-framework').then(({ wu }) => {
|
|
37
|
+
wu.init({ apps, sandbox, debug });
|
|
38
|
+
});
|
|
39
|
+
</script>
|
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @wu-framework/astro — Astro integration for wu-framework microfrontends.
|
|
3
|
-
*
|
|
4
|
-
* Injects the wu-framework runtime into Astro pages and optionally
|
|
5
|
-
* auto-initializes registered micro-apps via wu.init().
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* // astro.config.mjs
|
|
9
|
-
* import wu from '@wu-framework/astro';
|
|
10
|
-
*
|
|
11
|
-
* export default defineConfig({
|
|
12
|
-
* integrations: [
|
|
13
|
-
* wu({
|
|
14
|
-
* apps: [
|
|
15
|
-
* { name: 'header', url: '/apps/header', strategy: 'eager' },
|
|
16
|
-
* { name: 'dashboard', url: '/apps/dashboard' }
|
|
17
|
-
* ]
|
|
18
|
-
* })
|
|
19
|
-
* ]
|
|
20
|
-
* });
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* @param {import('./types').WuIntegrationOptions} options
|
|
25
|
-
* @returns {import('astro').AstroIntegration}
|
|
26
|
-
*/
|
|
27
|
-
export default function wuIntegration(options = {}) {
|
|
28
|
-
const {
|
|
29
|
-
apps = [],
|
|
30
|
-
sandbox,
|
|
31
|
-
cdn,
|
|
32
|
-
debug = false,
|
|
33
|
-
} = options;
|
|
34
|
-
|
|
35
|
-
return {
|
|
36
|
-
name: '@wu-framework/astro',
|
|
37
|
-
hooks: {
|
|
38
|
-
'astro:config:setup': ({ injectScript, updateConfig }) => {
|
|
39
|
-
// 1. Inject wu-framework runtime
|
|
40
|
-
if (cdn) {
|
|
41
|
-
// Use external CDN script (client-only)
|
|
42
|
-
injectScript(
|
|
43
|
-
'head-inline',
|
|
44
|
-
`(function(){var s=document.createElement('script');s.src='${cdn}';s.defer=true;document.head.appendChild(s);})()`
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// 2. Auto-init if apps are provided (client-only via 'page')
|
|
49
|
-
if (apps.length > 0) {
|
|
50
|
-
const initConfig = JSON.stringify({ apps, sandbox, debug });
|
|
51
|
-
injectScript(
|
|
52
|
-
'page',
|
|
53
|
-
`import('wu-framework').then(function(m){m.wu.init(${initConfig});});`
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// 3. Ensure Vite resolves wu-framework correctly
|
|
58
|
-
updateConfig({
|
|
59
|
-
vite: {
|
|
60
|
-
optimizeDeps: {
|
|
61
|
-
include: ['wu-framework'],
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
});
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
};
|
|
68
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @wu-framework/astro — Astro integration for wu-framework microfrontends.
|
|
3
|
+
*
|
|
4
|
+
* Injects the wu-framework runtime into Astro pages and optionally
|
|
5
|
+
* auto-initializes registered micro-apps via wu.init().
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* // astro.config.mjs
|
|
9
|
+
* import wu from '@wu-framework/astro';
|
|
10
|
+
*
|
|
11
|
+
* export default defineConfig({
|
|
12
|
+
* integrations: [
|
|
13
|
+
* wu({
|
|
14
|
+
* apps: [
|
|
15
|
+
* { name: 'header', url: '/apps/header', strategy: 'eager' },
|
|
16
|
+
* { name: 'dashboard', url: '/apps/dashboard' }
|
|
17
|
+
* ]
|
|
18
|
+
* })
|
|
19
|
+
* ]
|
|
20
|
+
* });
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @param {import('./types').WuIntegrationOptions} options
|
|
25
|
+
* @returns {import('astro').AstroIntegration}
|
|
26
|
+
*/
|
|
27
|
+
export default function wuIntegration(options = {}) {
|
|
28
|
+
const {
|
|
29
|
+
apps = [],
|
|
30
|
+
sandbox,
|
|
31
|
+
cdn,
|
|
32
|
+
debug = false,
|
|
33
|
+
} = options;
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
name: '@wu-framework/astro',
|
|
37
|
+
hooks: {
|
|
38
|
+
'astro:config:setup': ({ injectScript, updateConfig }) => {
|
|
39
|
+
// 1. Inject wu-framework runtime
|
|
40
|
+
if (cdn) {
|
|
41
|
+
// Use external CDN script (client-only)
|
|
42
|
+
injectScript(
|
|
43
|
+
'head-inline',
|
|
44
|
+
`(function(){var s=document.createElement('script');s.src='${cdn}';s.defer=true;document.head.appendChild(s);})()`
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// 2. Auto-init if apps are provided (client-only via 'page')
|
|
49
|
+
if (apps.length > 0) {
|
|
50
|
+
const initConfig = JSON.stringify({ apps, sandbox, debug });
|
|
51
|
+
injectScript(
|
|
52
|
+
'page',
|
|
53
|
+
`import('wu-framework').then(function(m){m.wu.init(${initConfig});});`
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// 3. Ensure Vite resolves wu-framework correctly
|
|
58
|
+
updateConfig({
|
|
59
|
+
vite: {
|
|
60
|
+
optimizeDeps: {
|
|
61
|
+
include: ['wu-framework'],
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
}
|