@hai3/framework 0.2.0-alpha.1 → 0.2.0-alpha.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/CLAUDE.md +31 -2
- package/commands/hai3-quick-ref.md +1 -3
- package/dist/index.cjs +300 -190
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +160 -83
- package/dist/index.d.ts +160 -83
- package/dist/index.js +289 -175
- package/dist/index.js.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +31 -15
- package/dist/types.d.ts +31 -15
- package/package.json +4 -1
package/dist/index.cjs
CHANGED
|
@@ -21,18 +21,29 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var src_exports = {};
|
|
22
22
|
__export(src_exports, {
|
|
23
23
|
ACCOUNTS_DOMAIN: () => ACCOUNTS_DOMAIN,
|
|
24
|
+
ApiPlugin: () => import_api3.ApiPlugin,
|
|
25
|
+
ApiPluginBase: () => import_api3.ApiPluginBase,
|
|
26
|
+
ApiProtocol: () => import_api3.ApiProtocol,
|
|
24
27
|
BaseApiService: () => import_api3.BaseApiService,
|
|
25
28
|
I18nRegistry: () => import_i18n6.I18nRegistryImpl,
|
|
26
29
|
I18nRegistryImpl: () => import_i18n5.I18nRegistryImpl,
|
|
27
30
|
LAYOUT_SLICE_NAME: () => LAYOUT_SLICE_NAME,
|
|
28
31
|
Language: () => import_i18n5.Language,
|
|
29
32
|
LanguageDisplayMode: () => import_i18n5.LanguageDisplayMode,
|
|
30
|
-
LayoutDomain: () =>
|
|
31
|
-
|
|
33
|
+
LayoutDomain: () => import_screensets6.LayoutDomain,
|
|
34
|
+
MOCK_PLUGIN: () => import_api3.MOCK_PLUGIN,
|
|
35
|
+
MockEventSource: () => import_api3.MockEventSource,
|
|
36
|
+
MockEvents: () => MockEvents,
|
|
37
|
+
RestMockPlugin: () => import_api3.RestMockPlugin,
|
|
38
|
+
RestPlugin: () => import_api3.RestPlugin,
|
|
39
|
+
RestPluginWithConfig: () => import_api3.RestPluginWithConfig,
|
|
32
40
|
RestProtocol: () => import_api3.RestProtocol,
|
|
33
41
|
STATE_PATH_MAPPING: () => STATE_PATH_MAPPING,
|
|
34
42
|
SUPPORTED_LANGUAGES: () => import_i18n5.SUPPORTED_LANGUAGES,
|
|
35
|
-
ScreensetCategory: () =>
|
|
43
|
+
ScreensetCategory: () => import_screensets6.ScreensetCategory,
|
|
44
|
+
SseMockPlugin: () => import_api3.SseMockPlugin,
|
|
45
|
+
SsePlugin: () => import_api3.SsePlugin,
|
|
46
|
+
SsePluginWithConfig: () => import_api3.SsePluginWithConfig,
|
|
36
47
|
SseProtocol: () => import_api3.SseProtocol,
|
|
37
48
|
TENANT_SLICE_NAME: () => TENANT_SLICE_NAME,
|
|
38
49
|
TenantEvents: () => TenantEvents,
|
|
@@ -51,39 +62,44 @@ __export(src_exports, {
|
|
|
51
62
|
createI18nRegistry: () => import_i18n5.createI18nRegistry,
|
|
52
63
|
createLegacySelector: () => createLegacySelector,
|
|
53
64
|
createRouteRegistry: () => createRouteRegistry,
|
|
54
|
-
createScreensetRegistry: () =>
|
|
55
|
-
createSlice: () =>
|
|
56
|
-
createStore: () =>
|
|
65
|
+
createScreensetRegistry: () => import_screensets4.createScreensetRegistry,
|
|
66
|
+
createSlice: () => import_state17.createSlice,
|
|
67
|
+
createStore: () => import_state17.createStore,
|
|
57
68
|
createThemeRegistry: () => createThemeRegistry,
|
|
58
69
|
effects: () => effects,
|
|
59
|
-
eventBus: () =>
|
|
60
|
-
fetchCurrentUser: () => fetchCurrentUser,
|
|
70
|
+
eventBus: () => import_state17.eventBus,
|
|
61
71
|
footerActions: () => footerActions,
|
|
62
72
|
footerSlice: () => footerSlice,
|
|
63
73
|
full: () => full,
|
|
64
74
|
getLanguageMetadata: () => import_i18n5.getLanguageMetadata,
|
|
65
75
|
getLayoutDomainState: () => getLayoutDomainState,
|
|
66
|
-
getStore: () =>
|
|
76
|
+
getStore: () => import_state17.getStore,
|
|
67
77
|
hasLegacyUicoreState: () => hasLegacyUicoreState,
|
|
68
78
|
hasNewLayoutState: () => hasNewLayoutState,
|
|
69
|
-
hasSlice: () =>
|
|
79
|
+
hasSlice: () => import_state17.hasSlice,
|
|
70
80
|
headerActions: () => headerActions,
|
|
71
81
|
headerSlice: () => headerSlice,
|
|
72
82
|
headless: () => headless,
|
|
73
83
|
hideOverlay: () => hideOverlay,
|
|
74
84
|
i18n: () => i18n,
|
|
75
85
|
i18nRegistry: () => import_i18n5.i18nRegistry,
|
|
86
|
+
initMockEffects: () => initMockEffects,
|
|
76
87
|
initTenantEffects: () => initTenantEffects,
|
|
77
88
|
isDeprecationWarningsEnabled: () => isDeprecationWarningsEnabled,
|
|
89
|
+
isMockPlugin: () => import_api3.isMockPlugin,
|
|
90
|
+
isRestShortCircuit: () => import_api3.isRestShortCircuit,
|
|
91
|
+
isShortCircuit: () => import_api3.isShortCircuit,
|
|
92
|
+
isSseShortCircuit: () => import_api3.isSseShortCircuit,
|
|
78
93
|
layout: () => layout,
|
|
79
94
|
layoutDomainReducers: () => layoutDomainReducers,
|
|
80
95
|
layoutReducer: () => layoutReducer,
|
|
81
|
-
legacySelectors: () => legacySelectors,
|
|
82
96
|
menuActions: () => menuActions,
|
|
83
97
|
menuSlice: () => menuSlice,
|
|
84
98
|
minimal: () => minimal,
|
|
99
|
+
mock: () => mock,
|
|
100
|
+
mockActions: () => mockActions,
|
|
101
|
+
mockSlice: () => mockSlice,
|
|
85
102
|
navigateTo: () => navigateTo,
|
|
86
|
-
navigateToScreen: () => navigateToScreen,
|
|
87
103
|
navigation: () => navigation,
|
|
88
104
|
openPopup: () => openPopup,
|
|
89
105
|
overlayActions: () => overlayActions,
|
|
@@ -91,12 +107,11 @@ __export(src_exports, {
|
|
|
91
107
|
popupActions: () => popupActions,
|
|
92
108
|
popupSlice: () => popupSlice,
|
|
93
109
|
presets: () => presets,
|
|
94
|
-
registerSlice: () =>
|
|
95
|
-
routeRegistry: () => routeRegistry,
|
|
110
|
+
registerSlice: () => import_state17.registerSlice,
|
|
96
111
|
routing: () => routing,
|
|
97
112
|
screenActions: () => screenActions,
|
|
98
113
|
screenSlice: () => screenSlice,
|
|
99
|
-
screensetRegistry: () =>
|
|
114
|
+
screensetRegistry: () => import_screensets5.screensetRegistry,
|
|
100
115
|
screensets: () => screensets,
|
|
101
116
|
setActiveScreen: () => setActiveScreen,
|
|
102
117
|
setDeprecationWarnings: () => setDeprecationWarnings,
|
|
@@ -107,6 +122,7 @@ __export(src_exports, {
|
|
|
107
122
|
setMenuConfig: () => setMenuConfig,
|
|
108
123
|
setMenuItems: () => setMenuItems,
|
|
109
124
|
setMenuVisible: () => setMenuVisible,
|
|
125
|
+
setMockEnabled: () => setMockEnabled,
|
|
110
126
|
setOverlayVisible: () => setOverlayVisible,
|
|
111
127
|
setScreenLoading: () => setScreenLoading,
|
|
112
128
|
setSidebarCollapsed: () => setSidebarCollapsed,
|
|
@@ -126,9 +142,9 @@ __export(src_exports, {
|
|
|
126
142
|
tenantActions: () => tenantActions,
|
|
127
143
|
tenantReducer: () => tenantSlice_default,
|
|
128
144
|
tenantSlice: () => tenantSlice,
|
|
129
|
-
themeRegistry: () => themeRegistry,
|
|
130
145
|
themes: () => themes,
|
|
131
146
|
toggleMenu: () => toggleMenu,
|
|
147
|
+
toggleMockMode: () => toggleMockMode,
|
|
132
148
|
toggleSidebar: () => toggleSidebar
|
|
133
149
|
});
|
|
134
150
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -294,8 +310,8 @@ Add the missing plugin: .use(${depName}())`
|
|
|
294
310
|
*/
|
|
295
311
|
createStoreWithSlices(slices) {
|
|
296
312
|
const store = (0, import_state.getStore)();
|
|
297
|
-
slices.forEach((
|
|
298
|
-
(0, import_state.registerSlice)(
|
|
313
|
+
slices.forEach((slice10) => {
|
|
314
|
+
(0, import_state.registerSlice)(slice10);
|
|
299
315
|
});
|
|
300
316
|
return store;
|
|
301
317
|
}
|
|
@@ -579,6 +595,25 @@ var tenantSlice = slice8;
|
|
|
579
595
|
var tenantActions = { setTenant, setTenantLoading, clearTenant };
|
|
580
596
|
var tenantSlice_default = slice8.reducer;
|
|
581
597
|
|
|
598
|
+
// src/slices/mockSlice.ts
|
|
599
|
+
var import_state10 = require("@hai3/state");
|
|
600
|
+
var SLICE_KEY9 = "mock";
|
|
601
|
+
var initialState9 = {
|
|
602
|
+
enabled: false
|
|
603
|
+
};
|
|
604
|
+
var { slice: slice9, setMockEnabled } = (0, import_state10.createSlice)({
|
|
605
|
+
name: SLICE_KEY9,
|
|
606
|
+
initialState: initialState9,
|
|
607
|
+
reducers: {
|
|
608
|
+
setMockEnabled: (state, action) => {
|
|
609
|
+
state.enabled = action.payload;
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
});
|
|
613
|
+
var mockSlice = slice9;
|
|
614
|
+
var mockActions = { setMockEnabled };
|
|
615
|
+
var mockSlice_default = slice9.reducer;
|
|
616
|
+
|
|
582
617
|
// src/slices/index.ts
|
|
583
618
|
var LAYOUT_SLICE_NAME = "layout";
|
|
584
619
|
var TENANT_SLICE_NAME = "app/tenant";
|
|
@@ -624,39 +659,34 @@ function screensets(config) {
|
|
|
624
659
|
// src/plugins/themes.ts
|
|
625
660
|
var import_state11 = require("@hai3/state");
|
|
626
661
|
|
|
627
|
-
// src/compat.ts
|
|
628
|
-
var import_state10 = require("@hai3/state");
|
|
629
|
-
var import_api2 = require("@hai3/api");
|
|
630
|
-
var import_screensets2 = require("@hai3/screensets");
|
|
631
|
-
|
|
632
662
|
// src/registries/themeRegistry.ts
|
|
633
|
-
function createThemeRegistry() {
|
|
663
|
+
function createThemeRegistry(config) {
|
|
634
664
|
const themes2 = /* @__PURE__ */ new Map();
|
|
635
|
-
const
|
|
665
|
+
const uikitThemes = /* @__PURE__ */ new Map();
|
|
636
666
|
let currentThemeId = null;
|
|
637
|
-
|
|
667
|
+
const customApplyFn = config?.applyFn ?? null;
|
|
638
668
|
const subscribers = /* @__PURE__ */ new Set();
|
|
639
669
|
let version = 0;
|
|
640
670
|
function notifySubscribers() {
|
|
641
671
|
version++;
|
|
642
672
|
subscribers.forEach((callback) => callback());
|
|
643
673
|
}
|
|
644
|
-
function applyCSSVariables(
|
|
674
|
+
function applyCSSVariables(config2) {
|
|
645
675
|
if (typeof document === "undefined") return;
|
|
646
676
|
const root = document.documentElement;
|
|
647
|
-
Object.entries(
|
|
677
|
+
Object.entries(config2.variables).forEach(([key, value]) => {
|
|
648
678
|
root.style.setProperty(key, value);
|
|
649
679
|
});
|
|
650
680
|
}
|
|
651
681
|
return {
|
|
652
682
|
/**
|
|
653
683
|
* Register a theme.
|
|
654
|
-
* Supports both
|
|
684
|
+
* Supports both config-based API and UIKit theme API.
|
|
655
685
|
*/
|
|
656
|
-
register(configOrId,
|
|
686
|
+
register(configOrId, uikitTheme) {
|
|
657
687
|
if (typeof configOrId === "string") {
|
|
658
688
|
const id = configOrId;
|
|
659
|
-
if (!
|
|
689
|
+
if (!uikitTheme) {
|
|
660
690
|
console.warn(`register() called with ID "${id}" but no theme object. Skipping.`);
|
|
661
691
|
return;
|
|
662
692
|
}
|
|
@@ -664,39 +694,33 @@ function createThemeRegistry() {
|
|
|
664
694
|
console.warn(`Theme "${id}" is already registered. Skipping.`);
|
|
665
695
|
return;
|
|
666
696
|
}
|
|
667
|
-
|
|
697
|
+
uikitThemes.set(id, uikitTheme);
|
|
668
698
|
let themeName = id;
|
|
669
|
-
if (
|
|
670
|
-
const nameValue =
|
|
699
|
+
if (uikitTheme && typeof uikitTheme === "object" && "name" in uikitTheme) {
|
|
700
|
+
const nameValue = uikitTheme.name;
|
|
671
701
|
if (typeof nameValue === "string") {
|
|
672
702
|
themeName = nameValue;
|
|
673
703
|
}
|
|
674
704
|
}
|
|
675
|
-
const
|
|
705
|
+
const config3 = {
|
|
676
706
|
id,
|
|
677
707
|
name: themeName,
|
|
678
708
|
variables: {}
|
|
679
|
-
//
|
|
709
|
+
// UIKit themes use custom apply function
|
|
680
710
|
};
|
|
681
|
-
themes2.set(id,
|
|
711
|
+
themes2.set(id, config3);
|
|
682
712
|
return;
|
|
683
713
|
}
|
|
684
|
-
const
|
|
685
|
-
if (themes2.has(
|
|
686
|
-
console.warn(`Theme "${
|
|
714
|
+
const config2 = configOrId;
|
|
715
|
+
if (themes2.has(config2.id)) {
|
|
716
|
+
console.warn(`Theme "${config2.id}" is already registered. Skipping.`);
|
|
687
717
|
return;
|
|
688
718
|
}
|
|
689
|
-
themes2.set(
|
|
690
|
-
if (
|
|
691
|
-
this.apply(
|
|
719
|
+
themes2.set(config2.id, config2);
|
|
720
|
+
if (config2.default && currentThemeId === null) {
|
|
721
|
+
this.apply(config2.id);
|
|
692
722
|
}
|
|
693
723
|
},
|
|
694
|
-
/**
|
|
695
|
-
* Set the apply function (legacy API).
|
|
696
|
-
*/
|
|
697
|
-
setApplyFunction(applyFn) {
|
|
698
|
-
customApplyFn = applyFn;
|
|
699
|
-
},
|
|
700
724
|
/**
|
|
701
725
|
* Get theme by ID.
|
|
702
726
|
*/
|
|
@@ -713,16 +737,17 @@ function createThemeRegistry() {
|
|
|
713
737
|
* Apply a theme.
|
|
714
738
|
*/
|
|
715
739
|
apply(id) {
|
|
716
|
-
const
|
|
717
|
-
if (!
|
|
740
|
+
const config2 = themes2.get(id);
|
|
741
|
+
if (!config2) {
|
|
718
742
|
console.warn(`Theme "${id}" not found. Cannot apply.`);
|
|
719
743
|
return;
|
|
720
744
|
}
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
745
|
+
if (config2.variables && Object.keys(config2.variables).length > 0) {
|
|
746
|
+
applyCSSVariables(config2);
|
|
747
|
+
}
|
|
748
|
+
const uikitTheme = uikitThemes.get(id);
|
|
749
|
+
if (uikitTheme && customApplyFn) {
|
|
750
|
+
customApplyFn(uikitTheme, id);
|
|
726
751
|
}
|
|
727
752
|
currentThemeId = id;
|
|
728
753
|
notifySubscribers();
|
|
@@ -753,117 +778,18 @@ function createThemeRegistry() {
|
|
|
753
778
|
};
|
|
754
779
|
}
|
|
755
780
|
|
|
756
|
-
// src/registries/routeRegistry.ts
|
|
757
|
-
function createRouteRegistry(screensetRegistry3) {
|
|
758
|
-
let routes = null;
|
|
759
|
-
function buildRoutes() {
|
|
760
|
-
if (routes !== null) {
|
|
761
|
-
return routes;
|
|
762
|
-
}
|
|
763
|
-
routes = [];
|
|
764
|
-
const screensets2 = screensetRegistry3.getAll();
|
|
765
|
-
screensets2.forEach((screenset) => {
|
|
766
|
-
screenset.menu.forEach((menuScreenItem) => {
|
|
767
|
-
const screenId = menuScreenItem.menuItem.screenId ?? menuScreenItem.menuItem.id;
|
|
768
|
-
if (screenId && menuScreenItem.screen) {
|
|
769
|
-
routes.push({
|
|
770
|
-
screensetId: screenset.id,
|
|
771
|
-
screenId,
|
|
772
|
-
loader: menuScreenItem.screen
|
|
773
|
-
});
|
|
774
|
-
}
|
|
775
|
-
});
|
|
776
|
-
});
|
|
777
|
-
return routes;
|
|
778
|
-
}
|
|
779
|
-
return {
|
|
780
|
-
/**
|
|
781
|
-
* Check if a screen exists by screenId only (globally unique).
|
|
782
|
-
*/
|
|
783
|
-
hasScreenById(screenId) {
|
|
784
|
-
const allRoutes = buildRoutes();
|
|
785
|
-
return allRoutes.some((route) => route.screenId === screenId);
|
|
786
|
-
},
|
|
787
|
-
/**
|
|
788
|
-
* Check if a screen exists (legacy, requires both IDs).
|
|
789
|
-
*/
|
|
790
|
-
hasScreen(screensetId, screenId) {
|
|
791
|
-
const allRoutes = buildRoutes();
|
|
792
|
-
return allRoutes.some(
|
|
793
|
-
(route) => route.screensetId === screensetId && route.screenId === screenId
|
|
794
|
-
);
|
|
795
|
-
},
|
|
796
|
-
/**
|
|
797
|
-
* Get screenset ID for a given screen ID (reverse lookup).
|
|
798
|
-
* Screen IDs are globally unique across all screensets.
|
|
799
|
-
*/
|
|
800
|
-
getScreensetForScreen(screenId) {
|
|
801
|
-
const allRoutes = buildRoutes();
|
|
802
|
-
const route = allRoutes.find((r) => r.screenId === screenId);
|
|
803
|
-
return route?.screensetId;
|
|
804
|
-
},
|
|
805
|
-
/**
|
|
806
|
-
* Get screen loader by screenId only.
|
|
807
|
-
*/
|
|
808
|
-
getScreenById(screenId) {
|
|
809
|
-
const allRoutes = buildRoutes();
|
|
810
|
-
const route = allRoutes.find((r) => r.screenId === screenId);
|
|
811
|
-
return route?.loader;
|
|
812
|
-
},
|
|
813
|
-
/**
|
|
814
|
-
* Get screen loader (legacy, requires both IDs).
|
|
815
|
-
*/
|
|
816
|
-
getScreen(screensetId, screenId) {
|
|
817
|
-
const allRoutes = buildRoutes();
|
|
818
|
-
const route = allRoutes.find(
|
|
819
|
-
(r) => r.screensetId === screensetId && r.screenId === screenId
|
|
820
|
-
);
|
|
821
|
-
return route?.loader;
|
|
822
|
-
},
|
|
823
|
-
/**
|
|
824
|
-
* Get all routes.
|
|
825
|
-
*/
|
|
826
|
-
getAll() {
|
|
827
|
-
const allRoutes = buildRoutes();
|
|
828
|
-
return allRoutes.map(({ screensetId, screenId }) => ({
|
|
829
|
-
screensetId,
|
|
830
|
-
screenId
|
|
831
|
-
}));
|
|
832
|
-
}
|
|
833
|
-
};
|
|
834
|
-
}
|
|
835
|
-
|
|
836
|
-
// src/compat.ts
|
|
837
|
-
var import_screensets3 = require("@hai3/screensets");
|
|
838
|
-
var screenActions3 = screenActions;
|
|
839
|
-
var ACCOUNTS_DOMAIN = "accounts";
|
|
840
|
-
var themeRegistry = createThemeRegistry();
|
|
841
|
-
var routeRegistry = createRouteRegistry(import_screensets2.screensetRegistry);
|
|
842
|
-
var navigateToScreen = (screenId) => {
|
|
843
|
-
(0, import_state10.getStore)().dispatch(screenActions3.setActiveScreen(screenId));
|
|
844
|
-
};
|
|
845
|
-
var fetchCurrentUser = () => (_dispatch) => {
|
|
846
|
-
try {
|
|
847
|
-
const accountsService = import_api2.apiRegistry.getService(ACCOUNTS_DOMAIN);
|
|
848
|
-
const service = accountsService;
|
|
849
|
-
service.getCurrentUser?.();
|
|
850
|
-
} catch {
|
|
851
|
-
console.warn("fetchCurrentUser: accounts service not registered");
|
|
852
|
-
}
|
|
853
|
-
};
|
|
854
|
-
|
|
855
781
|
// src/plugins/themes.ts
|
|
856
782
|
function changeTheme(payload) {
|
|
857
783
|
import_state11.eventBus.emit("theme/changed", payload);
|
|
858
784
|
}
|
|
859
|
-
function themes() {
|
|
860
|
-
const
|
|
785
|
+
function themes(config) {
|
|
786
|
+
const themeRegistry = createThemeRegistry(config);
|
|
861
787
|
return {
|
|
862
788
|
name: "themes",
|
|
863
789
|
dependencies: [],
|
|
864
790
|
provides: {
|
|
865
791
|
registries: {
|
|
866
|
-
themeRegistry
|
|
792
|
+
themeRegistry
|
|
867
793
|
},
|
|
868
794
|
actions: {
|
|
869
795
|
changeTheme
|
|
@@ -871,11 +797,11 @@ function themes() {
|
|
|
871
797
|
},
|
|
872
798
|
onInit(_app) {
|
|
873
799
|
import_state11.eventBus.on("theme/changed", (payload) => {
|
|
874
|
-
|
|
800
|
+
themeRegistry.apply(payload.themeId);
|
|
875
801
|
});
|
|
876
|
-
const themes2 =
|
|
802
|
+
const themes2 = themeRegistry.getAll();
|
|
877
803
|
if (themes2.length > 0) {
|
|
878
|
-
|
|
804
|
+
themeRegistry.apply(themes2[0].id);
|
|
879
805
|
}
|
|
880
806
|
}
|
|
881
807
|
};
|
|
@@ -1010,9 +936,9 @@ function resolveBase(pluginConfig, appConfig) {
|
|
|
1010
936
|
}
|
|
1011
937
|
|
|
1012
938
|
// src/plugins/navigation.ts
|
|
1013
|
-
var
|
|
939
|
+
var screenActions3 = screenActions;
|
|
1014
940
|
var menuActions3 = menuActions;
|
|
1015
|
-
function
|
|
941
|
+
function navigateToScreen(payload) {
|
|
1016
942
|
import_state13.eventBus.emit("navigation/screen/navigated", payload);
|
|
1017
943
|
}
|
|
1018
944
|
function navigateToScreenset(payload) {
|
|
@@ -1024,7 +950,7 @@ function navigation(config) {
|
|
|
1024
950
|
dependencies: ["screensets"],
|
|
1025
951
|
provides: {
|
|
1026
952
|
actions: {
|
|
1027
|
-
navigateToScreen
|
|
953
|
+
navigateToScreen,
|
|
1028
954
|
navigateToScreenset
|
|
1029
955
|
}
|
|
1030
956
|
},
|
|
@@ -1074,7 +1000,7 @@ function navigation(config) {
|
|
|
1074
1000
|
return;
|
|
1075
1001
|
}
|
|
1076
1002
|
activateScreenset(screensetId);
|
|
1077
|
-
dispatch(
|
|
1003
|
+
dispatch(screenActions3.navigateTo(screenId));
|
|
1078
1004
|
};
|
|
1079
1005
|
import_state13.eventBus.on("navigation/screen/navigated", (payload) => {
|
|
1080
1006
|
if (!app.routeRegistry?.hasScreen(payload.screensetId, payload.screenId)) {
|
|
@@ -1084,7 +1010,7 @@ function navigation(config) {
|
|
|
1084
1010
|
return;
|
|
1085
1011
|
}
|
|
1086
1012
|
activateScreenset(payload.screensetId);
|
|
1087
|
-
dispatch(
|
|
1013
|
+
dispatch(screenActions3.navigateTo(payload.screenId));
|
|
1088
1014
|
if (typeof window !== "undefined") {
|
|
1089
1015
|
const url = prependBase(`/${payload.screenId}`, base);
|
|
1090
1016
|
if (window.location.pathname !== url) {
|
|
@@ -1098,7 +1024,7 @@ function navigation(config) {
|
|
|
1098
1024
|
console.warn(`Screenset "${payload.screensetId}" not found.`);
|
|
1099
1025
|
return;
|
|
1100
1026
|
}
|
|
1101
|
-
|
|
1027
|
+
navigateToScreen({
|
|
1102
1028
|
screensetId: payload.screensetId,
|
|
1103
1029
|
screenId: screenset.defaultScreen
|
|
1104
1030
|
});
|
|
@@ -1146,6 +1072,86 @@ function navigation(config) {
|
|
|
1146
1072
|
};
|
|
1147
1073
|
}
|
|
1148
1074
|
|
|
1075
|
+
// src/registries/routeRegistry.ts
|
|
1076
|
+
function createRouteRegistry(screensetRegistry3) {
|
|
1077
|
+
let routes = null;
|
|
1078
|
+
function buildRoutes() {
|
|
1079
|
+
if (routes !== null) {
|
|
1080
|
+
return routes;
|
|
1081
|
+
}
|
|
1082
|
+
routes = [];
|
|
1083
|
+
const screensets2 = screensetRegistry3.getAll();
|
|
1084
|
+
screensets2.forEach((screenset) => {
|
|
1085
|
+
screenset.menu.forEach((menuScreenItem) => {
|
|
1086
|
+
const screenId = menuScreenItem.menuItem.screenId ?? menuScreenItem.menuItem.id;
|
|
1087
|
+
if (screenId && menuScreenItem.screen) {
|
|
1088
|
+
routes.push({
|
|
1089
|
+
screensetId: screenset.id,
|
|
1090
|
+
screenId,
|
|
1091
|
+
loader: menuScreenItem.screen
|
|
1092
|
+
});
|
|
1093
|
+
}
|
|
1094
|
+
});
|
|
1095
|
+
});
|
|
1096
|
+
return routes;
|
|
1097
|
+
}
|
|
1098
|
+
return {
|
|
1099
|
+
/**
|
|
1100
|
+
* Check if a screen exists by screenId only (globally unique).
|
|
1101
|
+
*/
|
|
1102
|
+
hasScreenById(screenId) {
|
|
1103
|
+
const allRoutes = buildRoutes();
|
|
1104
|
+
return allRoutes.some((route) => route.screenId === screenId);
|
|
1105
|
+
},
|
|
1106
|
+
/**
|
|
1107
|
+
* Check if a screen exists by both screensetId and screenId (explicit lookup when screenset context is known).
|
|
1108
|
+
*/
|
|
1109
|
+
hasScreen(screensetId, screenId) {
|
|
1110
|
+
const allRoutes = buildRoutes();
|
|
1111
|
+
return allRoutes.some(
|
|
1112
|
+
(route) => route.screensetId === screensetId && route.screenId === screenId
|
|
1113
|
+
);
|
|
1114
|
+
},
|
|
1115
|
+
/**
|
|
1116
|
+
* Get screenset ID for a given screen ID (reverse lookup).
|
|
1117
|
+
* Screen IDs are globally unique across all screensets.
|
|
1118
|
+
*/
|
|
1119
|
+
getScreensetForScreen(screenId) {
|
|
1120
|
+
const allRoutes = buildRoutes();
|
|
1121
|
+
const route = allRoutes.find((r) => r.screenId === screenId);
|
|
1122
|
+
return route?.screensetId;
|
|
1123
|
+
},
|
|
1124
|
+
/**
|
|
1125
|
+
* Get screen loader by screenId only.
|
|
1126
|
+
*/
|
|
1127
|
+
getScreenById(screenId) {
|
|
1128
|
+
const allRoutes = buildRoutes();
|
|
1129
|
+
const route = allRoutes.find((r) => r.screenId === screenId);
|
|
1130
|
+
return route?.loader;
|
|
1131
|
+
},
|
|
1132
|
+
/**
|
|
1133
|
+
* Get screen loader by both screensetId and screenId (explicit lookup when screenset context is known).
|
|
1134
|
+
*/
|
|
1135
|
+
getScreen(screensetId, screenId) {
|
|
1136
|
+
const allRoutes = buildRoutes();
|
|
1137
|
+
const route = allRoutes.find(
|
|
1138
|
+
(r) => r.screensetId === screensetId && r.screenId === screenId
|
|
1139
|
+
);
|
|
1140
|
+
return route?.loader;
|
|
1141
|
+
},
|
|
1142
|
+
/**
|
|
1143
|
+
* Get all routes.
|
|
1144
|
+
*/
|
|
1145
|
+
getAll() {
|
|
1146
|
+
const allRoutes = buildRoutes();
|
|
1147
|
+
return allRoutes.map(({ screensetId, screenId }) => ({
|
|
1148
|
+
screensetId,
|
|
1149
|
+
screenId
|
|
1150
|
+
}));
|
|
1151
|
+
}
|
|
1152
|
+
};
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1149
1155
|
// src/plugins/routing.ts
|
|
1150
1156
|
function routing() {
|
|
1151
1157
|
return {
|
|
@@ -1154,8 +1160,8 @@ function routing() {
|
|
|
1154
1160
|
onRegister(_app) {
|
|
1155
1161
|
},
|
|
1156
1162
|
onInit(app) {
|
|
1157
|
-
const
|
|
1158
|
-
app.routeRegistry =
|
|
1163
|
+
const routeRegistry = createRouteRegistry(app.screensetRegistry);
|
|
1164
|
+
app.routeRegistry = routeRegistry;
|
|
1159
1165
|
}
|
|
1160
1166
|
};
|
|
1161
1167
|
}
|
|
@@ -1203,16 +1209,101 @@ function effects() {
|
|
|
1203
1209
|
};
|
|
1204
1210
|
}
|
|
1205
1211
|
|
|
1212
|
+
// src/effects/mockEffects.ts
|
|
1213
|
+
var import_state15 = require("@hai3/state");
|
|
1214
|
+
var import_api2 = require("@hai3/api");
|
|
1215
|
+
function hasPluginManagement(protocol) {
|
|
1216
|
+
return "plugins" in protocol && typeof protocol.plugins === "object";
|
|
1217
|
+
}
|
|
1218
|
+
var MockEvents = {
|
|
1219
|
+
Toggle: "mock/toggle"
|
|
1220
|
+
};
|
|
1221
|
+
function syncMockPlugins(enabled) {
|
|
1222
|
+
for (const service of import_api2.apiRegistry.getAll()) {
|
|
1223
|
+
const registeredPlugins = service.getPlugins();
|
|
1224
|
+
for (const [protocol, plugins] of registeredPlugins) {
|
|
1225
|
+
if (!hasPluginManagement(protocol)) continue;
|
|
1226
|
+
for (const plugin of plugins) {
|
|
1227
|
+
if ((0, import_api2.isMockPlugin)(plugin)) {
|
|
1228
|
+
if (enabled) {
|
|
1229
|
+
const existingPlugins = protocol.plugins.getAll();
|
|
1230
|
+
if (!existingPlugins.includes(plugin)) {
|
|
1231
|
+
protocol.plugins.add(plugin);
|
|
1232
|
+
}
|
|
1233
|
+
} else {
|
|
1234
|
+
protocol.plugins.remove(plugin);
|
|
1235
|
+
}
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
}
|
|
1241
|
+
function initMockEffects() {
|
|
1242
|
+
const store = (0, import_state15.getStore)();
|
|
1243
|
+
const unsubscribe = import_state15.eventBus.on(MockEvents.Toggle, (payload) => {
|
|
1244
|
+
store.dispatch(setMockEnabled(payload.enabled));
|
|
1245
|
+
syncMockPlugins(payload.enabled);
|
|
1246
|
+
});
|
|
1247
|
+
const currentState = store.getState();
|
|
1248
|
+
if ("mock" in currentState && currentState.mock && typeof currentState.mock === "object" && "enabled" in currentState.mock) {
|
|
1249
|
+
syncMockPlugins(currentState.mock.enabled);
|
|
1250
|
+
}
|
|
1251
|
+
return () => {
|
|
1252
|
+
unsubscribe.unsubscribe();
|
|
1253
|
+
};
|
|
1254
|
+
}
|
|
1255
|
+
function toggleMockMode(enabled) {
|
|
1256
|
+
import_state15.eventBus.emit(MockEvents.Toggle, { enabled });
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1259
|
+
// src/plugins/mock.ts
|
|
1260
|
+
var cleanup = null;
|
|
1261
|
+
function isDevEnvironment() {
|
|
1262
|
+
if (typeof window === "undefined") return false;
|
|
1263
|
+
const { hostname } = window.location;
|
|
1264
|
+
return hostname === "localhost" || hostname === "127.0.0.1" || hostname.endsWith(".local");
|
|
1265
|
+
}
|
|
1266
|
+
function mock(config) {
|
|
1267
|
+
return {
|
|
1268
|
+
name: "mock",
|
|
1269
|
+
dependencies: ["effects"],
|
|
1270
|
+
provides: {
|
|
1271
|
+
slices: [mockSlice],
|
|
1272
|
+
actions: {
|
|
1273
|
+
toggleMockMode
|
|
1274
|
+
}
|
|
1275
|
+
},
|
|
1276
|
+
onInit() {
|
|
1277
|
+
cleanup = initMockEffects();
|
|
1278
|
+
const isDev = isDevEnvironment();
|
|
1279
|
+
const enabledByDefault = config?.enabledByDefault ?? isDev;
|
|
1280
|
+
if (enabledByDefault) {
|
|
1281
|
+
toggleMockMode(true);
|
|
1282
|
+
if (isDev) {
|
|
1283
|
+
console.log("[HAI3] Mock mode enabled by default (dev environment detected)");
|
|
1284
|
+
}
|
|
1285
|
+
}
|
|
1286
|
+
},
|
|
1287
|
+
onDestroy() {
|
|
1288
|
+
if (cleanup) {
|
|
1289
|
+
cleanup();
|
|
1290
|
+
cleanup = null;
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1293
|
+
};
|
|
1294
|
+
}
|
|
1295
|
+
|
|
1206
1296
|
// src/presets/index.ts
|
|
1207
|
-
function full() {
|
|
1297
|
+
function full(config) {
|
|
1208
1298
|
return [
|
|
1209
1299
|
effects(),
|
|
1210
1300
|
screensets({ autoDiscover: true }),
|
|
1211
|
-
themes(),
|
|
1301
|
+
themes(config?.themes),
|
|
1212
1302
|
layout(),
|
|
1213
1303
|
routing(),
|
|
1214
1304
|
navigation(),
|
|
1215
|
-
i18n()
|
|
1305
|
+
i18n(),
|
|
1306
|
+
mock()
|
|
1216
1307
|
];
|
|
1217
1308
|
}
|
|
1218
1309
|
function minimal() {
|
|
@@ -1234,28 +1325,28 @@ var presets = {
|
|
|
1234
1325
|
|
|
1235
1326
|
// src/createHAI3App.ts
|
|
1236
1327
|
function createHAI3App(config) {
|
|
1237
|
-
return createHAI3(config).useAll(full()).build();
|
|
1328
|
+
return createHAI3(config).useAll(full({ themes: config?.themes })).build();
|
|
1238
1329
|
}
|
|
1239
1330
|
|
|
1240
1331
|
// src/registries/index.ts
|
|
1241
|
-
var
|
|
1332
|
+
var import_screensets4 = require("@hai3/screensets");
|
|
1242
1333
|
|
|
1243
1334
|
// src/index.ts
|
|
1244
|
-
var
|
|
1245
|
-
var
|
|
1335
|
+
var import_state17 = require("@hai3/state");
|
|
1336
|
+
var import_screensets6 = require("@hai3/screensets");
|
|
1246
1337
|
|
|
1247
1338
|
// src/effects/tenantEffects.ts
|
|
1248
|
-
var
|
|
1339
|
+
var import_state16 = require("@hai3/state");
|
|
1249
1340
|
var TenantEvents = {
|
|
1250
1341
|
Changed: "app/tenant/changed",
|
|
1251
1342
|
Cleared: "app/tenant/cleared"
|
|
1252
1343
|
};
|
|
1253
1344
|
function initTenantEffects() {
|
|
1254
|
-
const store = (0,
|
|
1255
|
-
const subChanged =
|
|
1345
|
+
const store = (0, import_state16.getStore)();
|
|
1346
|
+
const subChanged = import_state16.eventBus.on(TenantEvents.Changed, (payload) => {
|
|
1256
1347
|
store.dispatch(setTenant(payload.tenant));
|
|
1257
1348
|
});
|
|
1258
|
-
const subCleared =
|
|
1349
|
+
const subCleared = import_state16.eventBus.on(TenantEvents.Cleared, () => {
|
|
1259
1350
|
store.dispatch(clearTenant());
|
|
1260
1351
|
});
|
|
1261
1352
|
return () => {
|
|
@@ -1264,13 +1355,13 @@ function initTenantEffects() {
|
|
|
1264
1355
|
};
|
|
1265
1356
|
}
|
|
1266
1357
|
function changeTenant(tenant) {
|
|
1267
|
-
|
|
1358
|
+
import_state16.eventBus.emit(TenantEvents.Changed, { tenant });
|
|
1268
1359
|
}
|
|
1269
1360
|
function clearTenantAction() {
|
|
1270
|
-
|
|
1361
|
+
import_state16.eventBus.emit(TenantEvents.Cleared, {});
|
|
1271
1362
|
}
|
|
1272
1363
|
function setTenantLoadingState(loading) {
|
|
1273
|
-
(0,
|
|
1364
|
+
(0, import_state16.getStore)().dispatch(setTenantLoading(loading));
|
|
1274
1365
|
}
|
|
1275
1366
|
|
|
1276
1367
|
// src/index.ts
|
|
@@ -1278,6 +1369,10 @@ var import_api3 = require("@hai3/api");
|
|
|
1278
1369
|
var import_i18n5 = require("@hai3/i18n");
|
|
1279
1370
|
var import_i18n6 = require("@hai3/i18n");
|
|
1280
1371
|
|
|
1372
|
+
// src/compat.ts
|
|
1373
|
+
var import_screensets5 = require("@hai3/screensets");
|
|
1374
|
+
var ACCOUNTS_DOMAIN = "accounts";
|
|
1375
|
+
|
|
1281
1376
|
// src/migration.ts
|
|
1282
1377
|
var STATE_PATH_MAPPING = {
|
|
1283
1378
|
// App state (moved to app slice)
|
|
@@ -1331,10 +1426,12 @@ function hasLegacyUicoreState(state) {
|
|
|
1331
1426
|
function hasNewLayoutState(state) {
|
|
1332
1427
|
return typeof state === "object" && state !== null && "layout" in state && typeof state.layout === "object";
|
|
1333
1428
|
}
|
|
1334
|
-
var legacySelectors = {};
|
|
1335
1429
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1336
1430
|
0 && (module.exports = {
|
|
1337
1431
|
ACCOUNTS_DOMAIN,
|
|
1432
|
+
ApiPlugin,
|
|
1433
|
+
ApiPluginBase,
|
|
1434
|
+
ApiProtocol,
|
|
1338
1435
|
BaseApiService,
|
|
1339
1436
|
I18nRegistry,
|
|
1340
1437
|
I18nRegistryImpl,
|
|
@@ -1342,11 +1439,19 @@ var legacySelectors = {};
|
|
|
1342
1439
|
Language,
|
|
1343
1440
|
LanguageDisplayMode,
|
|
1344
1441
|
LayoutDomain,
|
|
1345
|
-
|
|
1442
|
+
MOCK_PLUGIN,
|
|
1443
|
+
MockEventSource,
|
|
1444
|
+
MockEvents,
|
|
1445
|
+
RestMockPlugin,
|
|
1446
|
+
RestPlugin,
|
|
1447
|
+
RestPluginWithConfig,
|
|
1346
1448
|
RestProtocol,
|
|
1347
1449
|
STATE_PATH_MAPPING,
|
|
1348
1450
|
SUPPORTED_LANGUAGES,
|
|
1349
1451
|
ScreensetCategory,
|
|
1452
|
+
SseMockPlugin,
|
|
1453
|
+
SsePlugin,
|
|
1454
|
+
SsePluginWithConfig,
|
|
1350
1455
|
SseProtocol,
|
|
1351
1456
|
TENANT_SLICE_NAME,
|
|
1352
1457
|
TenantEvents,
|
|
@@ -1371,7 +1476,6 @@ var legacySelectors = {};
|
|
|
1371
1476
|
createThemeRegistry,
|
|
1372
1477
|
effects,
|
|
1373
1478
|
eventBus,
|
|
1374
|
-
fetchCurrentUser,
|
|
1375
1479
|
footerActions,
|
|
1376
1480
|
footerSlice,
|
|
1377
1481
|
full,
|
|
@@ -1387,17 +1491,23 @@ var legacySelectors = {};
|
|
|
1387
1491
|
hideOverlay,
|
|
1388
1492
|
i18n,
|
|
1389
1493
|
i18nRegistry,
|
|
1494
|
+
initMockEffects,
|
|
1390
1495
|
initTenantEffects,
|
|
1391
1496
|
isDeprecationWarningsEnabled,
|
|
1497
|
+
isMockPlugin,
|
|
1498
|
+
isRestShortCircuit,
|
|
1499
|
+
isShortCircuit,
|
|
1500
|
+
isSseShortCircuit,
|
|
1392
1501
|
layout,
|
|
1393
1502
|
layoutDomainReducers,
|
|
1394
1503
|
layoutReducer,
|
|
1395
|
-
legacySelectors,
|
|
1396
1504
|
menuActions,
|
|
1397
1505
|
menuSlice,
|
|
1398
1506
|
minimal,
|
|
1507
|
+
mock,
|
|
1508
|
+
mockActions,
|
|
1509
|
+
mockSlice,
|
|
1399
1510
|
navigateTo,
|
|
1400
|
-
navigateToScreen,
|
|
1401
1511
|
navigation,
|
|
1402
1512
|
openPopup,
|
|
1403
1513
|
overlayActions,
|
|
@@ -1406,7 +1516,6 @@ var legacySelectors = {};
|
|
|
1406
1516
|
popupSlice,
|
|
1407
1517
|
presets,
|
|
1408
1518
|
registerSlice,
|
|
1409
|
-
routeRegistry,
|
|
1410
1519
|
routing,
|
|
1411
1520
|
screenActions,
|
|
1412
1521
|
screenSlice,
|
|
@@ -1421,6 +1530,7 @@ var legacySelectors = {};
|
|
|
1421
1530
|
setMenuConfig,
|
|
1422
1531
|
setMenuItems,
|
|
1423
1532
|
setMenuVisible,
|
|
1533
|
+
setMockEnabled,
|
|
1424
1534
|
setOverlayVisible,
|
|
1425
1535
|
setScreenLoading,
|
|
1426
1536
|
setSidebarCollapsed,
|
|
@@ -1440,9 +1550,9 @@ var legacySelectors = {};
|
|
|
1440
1550
|
tenantActions,
|
|
1441
1551
|
tenantReducer,
|
|
1442
1552
|
tenantSlice,
|
|
1443
|
-
themeRegistry,
|
|
1444
1553
|
themes,
|
|
1445
1554
|
toggleMenu,
|
|
1555
|
+
toggleMockMode,
|
|
1446
1556
|
toggleSidebar
|
|
1447
1557
|
});
|
|
1448
1558
|
//# sourceMappingURL=index.cjs.map
|