wu-framework 1.1.15 → 1.1.16
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 +408 -408
- package/dist/wu-framework.cjs.js.map +1 -1
- package/dist/wu-framework.dev.js +15151 -15151
- package/dist/wu-framework.dev.js.map +1 -1
- package/dist/wu-framework.esm.js.map +1 -1
- package/dist/wu-framework.umd.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 +161 -161
- package/src/adapters/angular/ai.js +30 -30
- package/src/adapters/angular/index.d.ts +154 -154
- package/src/adapters/angular/index.js +932 -932
- package/src/adapters/angular.d.ts +3 -3
- package/src/adapters/angular.js +3 -3
- package/src/adapters/index.js +168 -168
- package/src/adapters/lit/ai.js +20 -20
- package/src/adapters/lit/index.d.ts +120 -120
- package/src/adapters/lit/index.js +721 -721
- package/src/adapters/lit.d.ts +3 -3
- package/src/adapters/lit.js +3 -3
- package/src/adapters/preact/ai.js +33 -33
- package/src/adapters/preact/index.d.ts +108 -108
- package/src/adapters/preact/index.js +661 -661
- package/src/adapters/preact.d.ts +3 -3
- package/src/adapters/preact.js +3 -3
- package/src/adapters/react/index.js +48 -54
- package/src/adapters/react.d.ts +3 -3
- package/src/adapters/react.js +3 -3
- package/src/adapters/shared.js +64 -64
- package/src/adapters/solid/ai.js +32 -32
- package/src/adapters/solid/index.d.ts +101 -101
- package/src/adapters/solid/index.js +586 -586
- package/src/adapters/solid.d.ts +3 -3
- package/src/adapters/solid.js +3 -3
- package/src/adapters/svelte/ai.js +31 -31
- package/src/adapters/svelte/index.d.ts +166 -166
- package/src/adapters/svelte/index.js +798 -798
- package/src/adapters/svelte.d.ts +3 -3
- package/src/adapters/svelte.js +3 -3
- package/src/adapters/vanilla/ai.js +30 -30
- package/src/adapters/vanilla/index.d.ts +179 -179
- package/src/adapters/vanilla/index.js +785 -785
- package/src/adapters/vanilla.d.ts +3 -3
- package/src/adapters/vanilla.js +3 -3
- package/src/adapters/vue/ai.js +52 -52
- package/src/adapters/vue/index.d.ts +299 -299
- package/src/adapters/vue/index.js +610 -610
- package/src/adapters/vue.d.ts +3 -3
- package/src/adapters/vue.js +3 -3
- package/src/ai/wu-ai-actions.js +261 -261
- package/src/ai/wu-ai-agent.js +546 -546
- package/src/ai/wu-ai-browser-primitives.js +354 -354
- package/src/ai/wu-ai-browser.js +380 -380
- package/src/ai/wu-ai-context.js +332 -332
- package/src/ai/wu-ai-conversation.js +613 -613
- package/src/ai/wu-ai-orchestrate.js +1021 -1021
- package/src/ai/wu-ai-permissions.js +381 -381
- package/src/ai/wu-ai-provider.js +700 -700
- package/src/ai/wu-ai-schema.js +225 -225
- package/src/ai/wu-ai-triggers.js +396 -396
- package/src/ai/wu-ai.js +804 -804
- package/src/core/wu-app.js +236 -236
- package/src/core/wu-cache.js +477 -477
- package/src/core/wu-core.js +1398 -1398
- package/src/core/wu-error-boundary.js +382 -382
- package/src/core/wu-event-bus.js +348 -348
- package/src/core/wu-hooks.js +350 -350
- package/src/core/wu-html-parser.js +190 -190
- package/src/core/wu-iframe-sandbox.js +328 -328
- package/src/core/wu-loader.js +272 -272
- package/src/core/wu-logger.js +134 -134
- package/src/core/wu-manifest.js +509 -509
- package/src/core/wu-mcp-bridge.js +432 -432
- package/src/core/wu-overrides.js +510 -510
- package/src/core/wu-performance.js +228 -228
- package/src/core/wu-plugin.js +348 -348
- package/src/core/wu-prefetch.js +414 -414
- package/src/core/wu-proxy-sandbox.js +476 -476
- package/src/core/wu-sandbox.js +779 -779
- package/src/core/wu-script-executor.js +113 -113
- package/src/core/wu-snapshot-sandbox.js +227 -227
- package/src/core/wu-strategies.js +256 -256
- package/src/core/wu-style-bridge.js +477 -477
- package/src/index.js +224 -224
- package/src/utils/dependency-resolver.js +327 -327
|
@@ -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
|
+
}
|
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@wu-framework/astro",
|
|
3
|
-
"version": "1.0.0",
|
|
4
|
-
"description": "Astro integration for wu-framework microfrontends",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "index.js",
|
|
7
|
-
"exports": {
|
|
8
|
-
".": "./index.js",
|
|
9
|
-
"./WuApp.astro": "./WuApp.astro",
|
|
10
|
-
"./WuShell.astro": "./WuShell.astro"
|
|
11
|
-
},
|
|
12
|
-
"files": [
|
|
13
|
-
"index.js",
|
|
14
|
-
"WuApp.astro",
|
|
15
|
-
"WuShell.astro",
|
|
16
|
-
"types.d.ts",
|
|
17
|
-
"README.md"
|
|
18
|
-
],
|
|
19
|
-
"keywords": [
|
|
20
|
-
"astro",
|
|
21
|
-
"astro-integration",
|
|
22
|
-
"wu-framework",
|
|
23
|
-
"microfrontends",
|
|
24
|
-
"micro-frontends"
|
|
25
|
-
],
|
|
26
|
-
"author": "Wu Framework Team",
|
|
27
|
-
"license": "MIT",
|
|
28
|
-
"peerDependencies": {
|
|
29
|
-
"astro": ">=4.0.0",
|
|
30
|
-
"wu-framework": ">=1.1.0"
|
|
31
|
-
},
|
|
32
|
-
"repository": {
|
|
33
|
-
"type": "git",
|
|
34
|
-
"url": "https://github.com/wu-framework/wu-framework.git",
|
|
35
|
-
"directory": "integrations/astro"
|
|
36
|
-
},
|
|
37
|
-
"homepage": "https://wu-framework.dev/docs/integrations/astro"
|
|
38
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@wu-framework/astro",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Astro integration for wu-framework microfrontends",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "index.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./index.js",
|
|
9
|
+
"./WuApp.astro": "./WuApp.astro",
|
|
10
|
+
"./WuShell.astro": "./WuShell.astro"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"index.js",
|
|
14
|
+
"WuApp.astro",
|
|
15
|
+
"WuShell.astro",
|
|
16
|
+
"types.d.ts",
|
|
17
|
+
"README.md"
|
|
18
|
+
],
|
|
19
|
+
"keywords": [
|
|
20
|
+
"astro",
|
|
21
|
+
"astro-integration",
|
|
22
|
+
"wu-framework",
|
|
23
|
+
"microfrontends",
|
|
24
|
+
"micro-frontends"
|
|
25
|
+
],
|
|
26
|
+
"author": "Wu Framework Team",
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"astro": ">=4.0.0",
|
|
30
|
+
"wu-framework": ">=1.1.0"
|
|
31
|
+
},
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "https://github.com/wu-framework/wu-framework.git",
|
|
35
|
+
"directory": "integrations/astro"
|
|
36
|
+
},
|
|
37
|
+
"homepage": "https://wu-framework.dev/docs/integrations/astro"
|
|
38
|
+
}
|