@hai3/framework 0.4.0-alpha.0 → 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/commands/hai3-new-action.md +6 -45
- package/dist/index.cjs +36 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +16 -28
- package/dist/index.d.ts +16 -28
- package/dist/index.js +37 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -5,8 +5,7 @@
|
|
|
5
5
|
1) Read .ai/targets/EVENTS.md before starting.
|
|
6
6
|
2) Summarize 3-6 key rules.
|
|
7
7
|
3) Gather requirements from user.
|
|
8
|
-
4)
|
|
9
|
-
5) After approval, apply implementation.
|
|
8
|
+
4) Implement.
|
|
10
9
|
|
|
11
10
|
## GATHER REQUIREMENTS
|
|
12
11
|
Ask user for:
|
|
@@ -14,44 +13,9 @@ Ask user for:
|
|
|
14
13
|
- Which screenset and domain (e.g., "chat/threads", "demo/navigation").
|
|
15
14
|
- Event payload data.
|
|
16
15
|
|
|
17
|
-
## STEP 1:
|
|
18
|
-
Create `openspec/changes/add-{screenset}-{action}/` with:
|
|
16
|
+
## STEP 1: Implementation
|
|
19
17
|
|
|
20
|
-
###
|
|
21
|
-
```markdown
|
|
22
|
-
# Proposal: Add {ActionName} Action
|
|
23
|
-
|
|
24
|
-
## Summary
|
|
25
|
-
Add new action "{actionName}" to {screenset}/{domain} domain.
|
|
26
|
-
|
|
27
|
-
## Details
|
|
28
|
-
- Screenset: {screenset}
|
|
29
|
-
- Domain: {domain}
|
|
30
|
-
- Action: {actionName}
|
|
31
|
-
- Event: {eventName}
|
|
32
|
-
- Payload: {payloadFields}
|
|
33
|
-
|
|
34
|
-
## Implementation
|
|
35
|
-
Follow HAI3 event-driven flux pattern: Action -> Event -> Effect -> Slice.
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
### tasks.md
|
|
39
|
-
```markdown
|
|
40
|
-
# Tasks: Add {ActionName} Action
|
|
41
|
-
|
|
42
|
-
- [ ] Define event in events/{domain}Events.ts
|
|
43
|
-
- [ ] Create action in actions/{domain}Actions.ts
|
|
44
|
-
- [ ] Create effect in effects/{domain}Effects.ts
|
|
45
|
-
- [ ] Validate: `npm run arch:check`
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
## STEP 2: Wait for Approval
|
|
49
|
-
Tell user: "I've created an OpenSpec proposal at `openspec/changes/add-{screenset}-{action}/`. Please review and run `/openspec:apply add-{screenset}-{action}` to implement."
|
|
50
|
-
|
|
51
|
-
## STEP 3: Apply Implementation (after approval)
|
|
52
|
-
When user runs `/openspec:apply`, execute:
|
|
53
|
-
|
|
54
|
-
### 3.1 Define Event
|
|
18
|
+
### 1.1 Define Event
|
|
55
19
|
In src/screensets/{screenset}/events/{domain}Events.ts:
|
|
56
20
|
```typescript
|
|
57
21
|
import { SCREENSET_ID } from '../ids';
|
|
@@ -73,7 +37,7 @@ declare module '@hai3/state' {
|
|
|
73
37
|
}
|
|
74
38
|
```
|
|
75
39
|
|
|
76
|
-
###
|
|
40
|
+
### 1.2 Create Action
|
|
77
41
|
In src/screensets/{screenset}/actions/{domain}Actions.ts:
|
|
78
42
|
```typescript
|
|
79
43
|
import { eventBus } from '@hai3/state';
|
|
@@ -88,7 +52,7 @@ export const {actionName} = (params: ParamsType) => {
|
|
|
88
52
|
};
|
|
89
53
|
```
|
|
90
54
|
|
|
91
|
-
###
|
|
55
|
+
### 1.3 Create Effect
|
|
92
56
|
In src/screensets/{screenset}/effects/{domain}Effects.ts:
|
|
93
57
|
```typescript
|
|
94
58
|
import { eventBus, getStore } from '@hai3/state';
|
|
@@ -102,14 +66,11 @@ export function init{Domain}Effects(): void {
|
|
|
102
66
|
}
|
|
103
67
|
```
|
|
104
68
|
|
|
105
|
-
###
|
|
69
|
+
### 1.4 Validate
|
|
106
70
|
```bash
|
|
107
71
|
npm run arch:check
|
|
108
72
|
```
|
|
109
73
|
|
|
110
|
-
### 3.5 Mark Tasks Complete
|
|
111
|
-
Update tasks.md to mark all completed tasks.
|
|
112
|
-
|
|
113
74
|
## RULES
|
|
114
75
|
- Actions use imperative names (selectScreen, changeTheme).
|
|
115
76
|
- Events use past-tense names (screenSelected, themeChanged).
|
package/dist/index.cjs
CHANGED
|
@@ -29,6 +29,7 @@ __export(src_exports, {
|
|
|
29
29
|
HAI3_ACTION_LOAD_EXT: () => import_screensets9.HAI3_ACTION_LOAD_EXT,
|
|
30
30
|
HAI3_ACTION_MOUNT_EXT: () => import_screensets9.HAI3_ACTION_MOUNT_EXT,
|
|
31
31
|
HAI3_ACTION_UNMOUNT_EXT: () => import_screensets9.HAI3_ACTION_UNMOUNT_EXT,
|
|
32
|
+
HAI3_MFE_ENTRY_MF: () => import_screensets8.HAI3_MFE_ENTRY_MF,
|
|
32
33
|
HAI3_OVERLAY_DOMAIN: () => HAI3_OVERLAY_DOMAIN,
|
|
33
34
|
HAI3_POPUP_DOMAIN: () => HAI3_POPUP_DOMAIN,
|
|
34
35
|
HAI3_SCREEN_DOMAIN: () => HAI3_SCREEN_DOMAIN,
|
|
@@ -99,7 +100,7 @@ __export(src_exports, {
|
|
|
99
100
|
getLanguageMetadata: () => import_i18n4.getLanguageMetadata,
|
|
100
101
|
getLayoutDomainState: () => getLayoutDomainState,
|
|
101
102
|
getStore: () => import_state21.getStore,
|
|
102
|
-
gtsPlugin: () =>
|
|
103
|
+
gtsPlugin: () => import_gts.gtsPlugin,
|
|
103
104
|
hasLegacyUicoreState: () => hasLegacyUicoreState,
|
|
104
105
|
hasNewLayoutState: () => hasNewLayoutState,
|
|
105
106
|
hasSlice: () => import_state21.hasSlice,
|
|
@@ -211,6 +212,8 @@ var HAI3AppBuilderImpl = class {
|
|
|
211
212
|
* Add a plugin to the application.
|
|
212
213
|
* Also accepts an array of plugins (for preset support).
|
|
213
214
|
*/
|
|
215
|
+
// @cpt-begin:cpt-hai3-flow-framework-composition-app-bootstrap:p1:inst-1
|
|
216
|
+
// @cpt-begin:cpt-hai3-state-framework-composition-builder:p1:inst-1
|
|
214
217
|
use(plugin) {
|
|
215
218
|
if (Array.isArray(plugin)) {
|
|
216
219
|
plugin.forEach((p) => this.use(p));
|
|
@@ -228,6 +231,8 @@ var HAI3AppBuilderImpl = class {
|
|
|
228
231
|
this.plugins.push(resolved);
|
|
229
232
|
return this;
|
|
230
233
|
}
|
|
234
|
+
// @cpt-end:cpt-hai3-flow-framework-composition-app-bootstrap:p1:inst-1
|
|
235
|
+
// @cpt-end:cpt-hai3-state-framework-composition-builder:p1:inst-1
|
|
231
236
|
/**
|
|
232
237
|
* Add multiple plugins at once.
|
|
233
238
|
*/
|
|
@@ -238,6 +243,8 @@ var HAI3AppBuilderImpl = class {
|
|
|
238
243
|
/**
|
|
239
244
|
* Build the application.
|
|
240
245
|
*/
|
|
246
|
+
// @cpt-begin:cpt-hai3-flow-framework-composition-app-bootstrap:p1:inst-2
|
|
247
|
+
// @cpt-begin:cpt-hai3-state-framework-composition-builder:p1:inst-2
|
|
241
248
|
build() {
|
|
242
249
|
const orderedPlugins = this.resolveDependencies();
|
|
243
250
|
orderedPlugins.forEach((plugin) => {
|
|
@@ -267,9 +274,13 @@ var HAI3AppBuilderImpl = class {
|
|
|
267
274
|
});
|
|
268
275
|
return app;
|
|
269
276
|
}
|
|
277
|
+
// @cpt-end:cpt-hai3-flow-framework-composition-app-bootstrap:p1:inst-2
|
|
278
|
+
// @cpt-end:cpt-hai3-state-framework-composition-builder:p1:inst-2
|
|
270
279
|
/**
|
|
271
280
|
* Resolve plugin dependencies using topological sort.
|
|
272
281
|
*/
|
|
282
|
+
// @cpt-begin:cpt-hai3-algo-framework-composition-dep-resolution:p1:inst-1
|
|
283
|
+
// @cpt-begin:cpt-hai3-flow-framework-composition-plugin-dependency:p1:inst-2
|
|
273
284
|
resolveDependencies() {
|
|
274
285
|
const resolved = [];
|
|
275
286
|
const visited = /* @__PURE__ */ new Set();
|
|
@@ -308,9 +319,12 @@ Add the missing plugin: .use(${depName}())`
|
|
|
308
319
|
this.plugins.forEach(visit);
|
|
309
320
|
return resolved;
|
|
310
321
|
}
|
|
322
|
+
// @cpt-end:cpt-hai3-algo-framework-composition-dep-resolution:p1:inst-1
|
|
323
|
+
// @cpt-end:cpt-hai3-flow-framework-composition-plugin-dependency:p1:inst-2
|
|
311
324
|
/**
|
|
312
325
|
* Aggregate all provides from plugins.
|
|
313
326
|
*/
|
|
327
|
+
// @cpt-begin:cpt-hai3-algo-framework-composition-provides-aggregation:p1:inst-1
|
|
314
328
|
aggregateProvides(plugins) {
|
|
315
329
|
const registries = {};
|
|
316
330
|
const slices = [];
|
|
@@ -333,6 +347,7 @@ Add the missing plugin: .use(${depName}())`
|
|
|
333
347
|
});
|
|
334
348
|
return { registries, slices, effects: effects2, actions: actions2 };
|
|
335
349
|
}
|
|
350
|
+
// @cpt-end:cpt-hai3-algo-framework-composition-provides-aggregation:p1:inst-1
|
|
336
351
|
/**
|
|
337
352
|
* Create store with all aggregated slices.
|
|
338
353
|
*
|
|
@@ -355,6 +370,7 @@ Add the missing plugin: .use(${depName}())`
|
|
|
355
370
|
/**
|
|
356
371
|
* Destroy the app and cleanup resources.
|
|
357
372
|
*/
|
|
373
|
+
// @cpt-begin:cpt-hai3-flow-framework-composition-teardown:p2:inst-1
|
|
358
374
|
destroyApp(plugins, app) {
|
|
359
375
|
[...plugins].reverse().forEach((plugin) => {
|
|
360
376
|
if (plugin.onDestroy) {
|
|
@@ -362,6 +378,7 @@ Add the missing plugin: .use(${depName}())`
|
|
|
362
378
|
}
|
|
363
379
|
});
|
|
364
380
|
}
|
|
381
|
+
// @cpt-end:cpt-hai3-flow-framework-composition-teardown:p2:inst-1
|
|
365
382
|
};
|
|
366
383
|
function createHAI3(config) {
|
|
367
384
|
return new HAI3AppBuilderImpl(config);
|
|
@@ -820,6 +837,8 @@ function themes(config) {
|
|
|
820
837
|
changeTheme
|
|
821
838
|
}
|
|
822
839
|
},
|
|
840
|
+
// @cpt-begin:cpt-hai3-flow-framework-composition-theme-propagation:p1:inst-2
|
|
841
|
+
// @cpt-begin:cpt-hai3-dod-framework-composition-propagation:p1:inst-1
|
|
823
842
|
onInit(app) {
|
|
824
843
|
import_state11.eventBus.on("theme/changed", (payload) => {
|
|
825
844
|
themeRegistry.apply(payload.themeId);
|
|
@@ -834,6 +853,8 @@ function themes(config) {
|
|
|
834
853
|
themeRegistry.apply(themes2[0].id);
|
|
835
854
|
}
|
|
836
855
|
}
|
|
856
|
+
// @cpt-end:cpt-hai3-flow-framework-composition-theme-propagation:p1:inst-2
|
|
857
|
+
// @cpt-end:cpt-hai3-dod-framework-composition-propagation:p1:inst-1
|
|
837
858
|
};
|
|
838
859
|
}
|
|
839
860
|
|
|
@@ -935,6 +956,8 @@ function i18n() {
|
|
|
935
956
|
setLanguage
|
|
936
957
|
}
|
|
937
958
|
},
|
|
959
|
+
// @cpt-begin:cpt-hai3-flow-framework-composition-i18n-propagation:p1:inst-2
|
|
960
|
+
// @cpt-begin:cpt-hai3-dod-framework-composition-propagation:p1:inst-2
|
|
938
961
|
onInit(app) {
|
|
939
962
|
import_state13.eventBus.on("i18n/language/changed", async (payload) => {
|
|
940
963
|
await i18nRegistry2.setLanguage(payload.language);
|
|
@@ -948,6 +971,8 @@ function i18n() {
|
|
|
948
971
|
console.warn("[HAI3] Failed to load initial translations:", err);
|
|
949
972
|
});
|
|
950
973
|
}
|
|
974
|
+
// @cpt-end:cpt-hai3-flow-framework-composition-i18n-propagation:p1:inst-2
|
|
975
|
+
// @cpt-end:cpt-hai3-dod-framework-composition-propagation:p1:inst-2
|
|
951
976
|
};
|
|
952
977
|
}
|
|
953
978
|
|
|
@@ -1044,7 +1069,6 @@ function mock(config) {
|
|
|
1044
1069
|
|
|
1045
1070
|
// src/plugins/microfrontends/index.ts
|
|
1046
1071
|
var import_screensets5 = require("@hai3/screensets");
|
|
1047
|
-
var import_gts = require("@hai3/screensets/plugins/gts");
|
|
1048
1072
|
var import_state18 = require("@hai3/state");
|
|
1049
1073
|
|
|
1050
1074
|
// src/plugins/microfrontends/slice.ts
|
|
@@ -1261,9 +1285,9 @@ var overlayDomain = {
|
|
|
1261
1285
|
};
|
|
1262
1286
|
|
|
1263
1287
|
// src/plugins/microfrontends/index.ts
|
|
1264
|
-
function microfrontends(config
|
|
1288
|
+
function microfrontends(config) {
|
|
1265
1289
|
const screensetsRegistry2 = import_screensets5.screensetsRegistryFactory.build({
|
|
1266
|
-
typeSystem:
|
|
1290
|
+
typeSystem: config.typeSystem,
|
|
1267
1291
|
mfeHandlers: config.mfeHandlers
|
|
1268
1292
|
});
|
|
1269
1293
|
const originalExecuteActionsChain = screensetsRegistry2.executeActionsChain.bind(screensetsRegistry2);
|
|
@@ -1324,15 +1348,18 @@ function microfrontends(config = {}) {
|
|
|
1324
1348
|
|
|
1325
1349
|
// src/presets/index.ts
|
|
1326
1350
|
function full(config) {
|
|
1327
|
-
|
|
1351
|
+
const plugins = [
|
|
1328
1352
|
effects(),
|
|
1329
1353
|
screensets({ autoDiscover: true }),
|
|
1330
1354
|
themes(config?.themes),
|
|
1331
1355
|
layout(),
|
|
1332
1356
|
i18n(),
|
|
1333
|
-
mock()
|
|
1334
|
-
microfrontends(config?.microfrontends)
|
|
1357
|
+
mock()
|
|
1335
1358
|
];
|
|
1359
|
+
if (config?.microfrontends) {
|
|
1360
|
+
plugins.push(microfrontends(config.microfrontends));
|
|
1361
|
+
}
|
|
1362
|
+
return plugins;
|
|
1336
1363
|
}
|
|
1337
1364
|
function minimal() {
|
|
1338
1365
|
return [
|
|
@@ -1365,7 +1392,7 @@ var import_screensets9 = require("@hai3/screensets");
|
|
|
1365
1392
|
var import_screensets10 = require("@hai3/screensets");
|
|
1366
1393
|
var import_screensets11 = require("@hai3/screensets");
|
|
1367
1394
|
var import_handler = require("@hai3/screensets/mfe/handler");
|
|
1368
|
-
var
|
|
1395
|
+
var import_gts = require("@hai3/screensets/plugins/gts");
|
|
1369
1396
|
var import_screensets12 = require("@hai3/screensets");
|
|
1370
1397
|
var import_state21 = require("@hai3/state");
|
|
1371
1398
|
var import_screensets13 = require("@hai3/screensets");
|
|
@@ -1475,6 +1502,7 @@ function hasNewLayoutState(state) {
|
|
|
1475
1502
|
HAI3_ACTION_LOAD_EXT,
|
|
1476
1503
|
HAI3_ACTION_MOUNT_EXT,
|
|
1477
1504
|
HAI3_ACTION_UNMOUNT_EXT,
|
|
1505
|
+
HAI3_MFE_ENTRY_MF,
|
|
1478
1506
|
HAI3_OVERLAY_DOMAIN,
|
|
1479
1507
|
HAI3_POPUP_DOMAIN,
|
|
1480
1508
|
HAI3_SCREEN_DOMAIN,
|