@hai3/framework 0.2.0-alpha.4 → 0.4.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +194 -19
- package/commands/hai3-new-action.md +6 -45
- package/dist/index.cjs +498 -521
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +309 -94
- package/dist/index.d.ts +309 -94
- package/dist/index.js +486 -504
- package/dist/index.js.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +30 -117
- package/dist/types.d.ts +30 -117
- package/llms.txt +122 -13
- package/package.json +1 -1
package/llms.txt
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
1
|
# @hai3/framework
|
|
2
2
|
|
|
3
|
-
> Plugin-based application framework for HAI3 SDK. Orchestrates SDK packages into cohesive applications.
|
|
3
|
+
> Plugin-based application framework for HAI3 SDK. Orchestrates SDK packages into cohesive applications with MFE (Microfrontend) support.
|
|
4
4
|
|
|
5
|
-
Part of the HAI3 Framework Layer (L2) - depends on all SDK packages (@hai3/state, @hai3/screensets, @hai3/api, @hai3/i18n)
|
|
5
|
+
Part of the HAI3 Framework Layer (L2) - depends on all SDK packages (@hai3/state, @hai3/screensets, @hai3/api, @hai3/i18n). Owns layout slices.
|
|
6
6
|
|
|
7
7
|
## Core API
|
|
8
8
|
|
|
9
9
|
- [createHAI3](https://hai3.dev/docs/framework/create): App builder with plugin composition
|
|
10
|
-
- [createHAI3App](https://hai3.dev/docs/framework/app): Convenience function (full preset)
|
|
10
|
+
- [createHAI3App](https://hai3.dev/docs/framework/app): Convenience function (full preset with MFE)
|
|
11
11
|
- [presets](https://hai3.dev/docs/framework/presets): Pre-configured plugin combinations (full, minimal, headless)
|
|
12
12
|
|
|
13
13
|
## Available Plugins
|
|
14
14
|
|
|
15
15
|
| Plugin | Provides |
|
|
16
16
|
|--------|----------|
|
|
17
|
-
| `screensets()` |
|
|
17
|
+
| `screensets()` | screensetsRegistry (MFE-enabled), layout domain slices |
|
|
18
18
|
| `themes()` | themeRegistry, changeTheme action |
|
|
19
|
-
| `layout()` | header, footer, menu, sidebar, popup, overlay
|
|
20
|
-
| `
|
|
21
|
-
| `routing()` | routeRegistry, URL sync |
|
|
19
|
+
| `layout()` | header, footer, menu, sidebar, popup, overlay state |
|
|
20
|
+
| `microfrontends()` | MFE actions, selectors, domain constants |
|
|
22
21
|
| `i18n()` | i18nRegistry, setLanguage action |
|
|
23
22
|
| `effects()` | Core effect coordination |
|
|
23
|
+
| `mock()` | mockSlice, toggleMockMode action |
|
|
24
24
|
|
|
25
25
|
## Quick Start
|
|
26
26
|
|
|
27
27
|
```typescript
|
|
28
|
-
import { createHAI3, screensets, themes, layout,
|
|
28
|
+
import { createHAI3, screensets, themes, layout, microfrontends, i18n } from '@hai3/framework';
|
|
29
29
|
|
|
30
30
|
// Compose plugins
|
|
31
31
|
const app = createHAI3()
|
|
32
32
|
.use(screensets())
|
|
33
33
|
.use(themes())
|
|
34
34
|
.use(layout())
|
|
35
|
-
.use(
|
|
35
|
+
.use(microfrontends())
|
|
36
36
|
.use(i18n())
|
|
37
37
|
.build();
|
|
38
38
|
|
|
@@ -40,13 +40,122 @@ const app = createHAI3()
|
|
|
40
40
|
import { createHAI3App } from '@hai3/framework';
|
|
41
41
|
const app = createHAI3App();
|
|
42
42
|
|
|
43
|
-
// Access
|
|
44
|
-
app.
|
|
45
|
-
app.
|
|
43
|
+
// Access MFE-enabled registry
|
|
44
|
+
app.screensetsRegistry.registerDomain(screenDomain);
|
|
45
|
+
app.screensetsRegistry.registerExtension(homeExtension);
|
|
46
|
+
await app.screensetsRegistry.loadExtension({ extensionId: 'home' });
|
|
47
|
+
|
|
48
|
+
// Access MFE actions
|
|
49
|
+
app.actions.loadExtension({ extensionId: 'home' });
|
|
50
|
+
app.actions.mountExtension({ extensionId: 'home', domainId: 'screen', container });
|
|
51
|
+
app.actions.unmountExtension({ extensionId: 'home', domainId: 'screen' });
|
|
52
|
+
|
|
53
|
+
// Access theme and i18n actions
|
|
46
54
|
app.actions.changeTheme({ themeId: 'dark' });
|
|
55
|
+
app.actions.setLanguage({ language: 'es' });
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## MFE Plugin
|
|
59
|
+
|
|
60
|
+
The `microfrontends()` plugin provides:
|
|
61
|
+
|
|
62
|
+
### MFE Actions
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
import {
|
|
66
|
+
loadExtension, // Load extension code
|
|
67
|
+
mountExtension, // Mount extension into domain
|
|
68
|
+
unmountExtension, // Unmount extension from domain
|
|
69
|
+
registerExtension, // Register extension dynamically
|
|
70
|
+
unregisterExtension, // Unregister extension
|
|
71
|
+
} from '@hai3/framework';
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### MFE Selectors
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
import {
|
|
78
|
+
selectExtensionState, // Get extension state
|
|
79
|
+
selectRegisteredExtensions, // Get all registered extensions
|
|
80
|
+
selectExtensionError, // Get extension error
|
|
81
|
+
} from '@hai3/framework';
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Domain Constants
|
|
85
|
+
|
|
86
|
+
```typescript
|
|
87
|
+
import {
|
|
88
|
+
HAI3_SCREEN_DOMAIN, // 'screen'
|
|
89
|
+
HAI3_SIDEBAR_DOMAIN, // 'sidebar'
|
|
90
|
+
HAI3_POPUP_DOMAIN, // 'popup'
|
|
91
|
+
HAI3_OVERLAY_DOMAIN, // 'overlay'
|
|
92
|
+
screenDomain, // ExtensionDomain object
|
|
93
|
+
sidebarDomain, // ExtensionDomain object
|
|
94
|
+
popupDomain, // ExtensionDomain object
|
|
95
|
+
overlayDomain, // ExtensionDomain object
|
|
96
|
+
} from '@hai3/framework';
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Action Constants
|
|
100
|
+
|
|
101
|
+
```typescript
|
|
102
|
+
import {
|
|
103
|
+
HAI3_ACTION_LOAD_EXT, // 'hai3.action.load_ext'
|
|
104
|
+
HAI3_ACTION_MOUNT_EXT, // 'hai3.action.mount_ext'
|
|
105
|
+
HAI3_ACTION_UNMOUNT_EXT, // 'hai3.action.unmount_ext'
|
|
106
|
+
} from '@hai3/framework';
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Shared Property Constants
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
import {
|
|
113
|
+
HAI3_SHARED_PROPERTY_THEME, // 'hai3.shared.theme'
|
|
114
|
+
HAI3_SHARED_PROPERTY_LANGUAGE, // 'hai3.shared.language'
|
|
115
|
+
} from '@hai3/framework';
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Plugin Composition Pattern
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
import { createHAI3, screensets, microfrontends } from '@hai3/framework';
|
|
122
|
+
|
|
123
|
+
// MFE-enabled app
|
|
124
|
+
const app = createHAI3()
|
|
125
|
+
.use(screensets()) // Provides screensetsRegistry (MFE-enabled)
|
|
126
|
+
.use(microfrontends()) // Provides MFE actions and domain management
|
|
127
|
+
.build();
|
|
128
|
+
|
|
129
|
+
// Access MFE features
|
|
130
|
+
app.screensetsRegistry.registerExtension(extension);
|
|
131
|
+
await app.actions.mountExtension({ extensionId, domainId, container });
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## MFE Types
|
|
135
|
+
|
|
136
|
+
```typescript
|
|
137
|
+
import type {
|
|
138
|
+
Extension, // Extension definition
|
|
139
|
+
ScreenExtension, // Screen-specific extension (derived type)
|
|
140
|
+
ExtensionDomain, // Domain definition
|
|
141
|
+
MfeHandler, // Abstract handler for MFE lifecycle
|
|
142
|
+
MfeBridgeFactory, // Abstract factory for bridges
|
|
143
|
+
ParentMfeBridge, // Parent bridge interface
|
|
144
|
+
ChildMfeBridge, // Child bridge interface
|
|
145
|
+
LifecycleStage, // Lifecycle stage definition
|
|
146
|
+
ActionsChain, // Actions chain for lifecycle hooks
|
|
147
|
+
} from '@hai3/framework';
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## Concrete MFE Implementations
|
|
151
|
+
|
|
152
|
+
```typescript
|
|
153
|
+
import { MfeHandlerMF } from '@hai3/framework'; // Module Federation handler
|
|
154
|
+
import { gtsPlugin } from '@hai3/framework'; // GTS type validation plugin
|
|
47
155
|
```
|
|
48
156
|
|
|
49
157
|
## Optional
|
|
50
158
|
|
|
51
159
|
- [Custom Plugins](https://hai3.dev/docs/framework/plugins): Creating custom plugins
|
|
52
|
-
- [
|
|
160
|
+
- [MFE Bridge Communication](https://hai3.dev/docs/framework/mfe-bridge): Parent-child patterns
|
|
161
|
+
- [Migration Guide](https://hai3.dev/docs/framework/migration): Migrating from legacy screensets API
|