@hai3/framework 0.2.0-alpha.1 → 0.2.0-alpha.3

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/dist/index.d.ts CHANGED
@@ -1,15 +1,15 @@
1
- import { HAI3Config, HAI3AppBuilder, HAI3App, ScreensetsConfig, HAI3Plugin, ChangeThemePayload, ShowPopupPayload, NavigateToScreenPayload, NavigateToScreensetPayload, NavigationConfig, SetLanguagePayload, Presets, ThemeRegistry, RouteRegistry } from './types.js';
2
- export { HAI3Store, LegacyTheme, PluginFactory, PluginLifecycle, PluginProvides, Preset, ThemeApplyFn, ThemeConfig } from './types.js';
1
+ import { HAI3Config, HAI3AppBuilder, ThemesConfig, HAI3Plugin, Presets, HAI3App, ScreensetsConfig, ChangeThemePayload, ShowPopupPayload, NavigateToScreenPayload, NavigateToScreensetPayload, NavigationConfig, SetLanguagePayload, ThemeRegistry, RouteRegistry } from './types.js';
2
+ export { CompiledRoute, HAI3Store, PluginFactory, PluginLifecycle, PluginProvides, Preset, RouteMatchResult, RouteParams, RouterMode, ThemeApplyFn, ThemeConfig, UikitTheme } from './types.js';
3
3
  import { ScreensetRegistry } from '@hai3/screensets';
4
4
  export { LayoutDomain, MenuItemConfig, MenuScreenItem, ScreenConfig, ScreenId, ScreenLoader, ScreensetCategory, ScreensetDefinition as ScreensetConfig, ScreensetDefinition, ScreensetId, ScreensetRegistry, ScreensetRegistry as ScreensetRegistryContract, createScreensetRegistry, screensetRegistry } from '@hai3/screensets';
5
5
  import * as _hai3_state from '@hai3/state';
6
- import { AppDispatch } from '@hai3/state';
7
6
  export { AppDispatch, EffectInitializer, EventHandler, EventPayloadMap, ReducerPayload, RootState, SliceObject, Subscription, createSlice, createStore, eventBus, getStore, hasSlice, registerSlice } from '@hai3/state';
8
7
  import * as redux from 'redux';
9
8
  import * as _reduxjs_toolkit from '@reduxjs/toolkit';
10
9
  import { Reducer } from '@reduxjs/toolkit';
11
- export { ApiProtocol, ApiService, ApiServiceConfig, ApiServicesMap, BaseApiService, JsonCompatible, JsonObject, JsonPrimitive, JsonValue, MockMap, MockPlugin, RestProtocol, RestProtocolConfig, SseProtocol, SseProtocolConfig, apiRegistry } from '@hai3/api';
10
+ export { ApiPlugin, ApiPluginBase, ApiPluginErrorContext, ApiProtocol, ApiRequestContext, ApiResponseContext, ApiServiceConfig, BaseApiService, BasePluginHooks, EventSourceLike, JsonCompatible, JsonObject, JsonPrimitive, JsonValue, MOCK_PLUGIN, MockEventSource, MockMap, PluginClass, ProtocolClass, ProtocolPluginType, RestMockConfig, RestMockPlugin, RestPlugin, RestPluginHooks, RestPluginWithConfig, RestProtocol, RestProtocolConfig, RestRequestContext, RestResponseContext, RestShortCircuitResponse, ShortCircuitResponse, SseConnectContext, SseMockConfig, SseMockEvent, SseMockPlugin, SsePlugin, SsePluginHooks, SsePluginWithConfig, SseProtocol, SseProtocolConfig, SseShortCircuitResponse, apiRegistry, isMockPlugin, isRestShortCircuit, isShortCircuit, isSseShortCircuit } from '@hai3/api';
12
11
  export { I18nConfig, I18nRegistryImpl as I18nRegistry, I18nRegistryImpl, I18nRegistry as I18nRegistryType, Language, LanguageDisplayMode, LanguageMetadata, SUPPORTED_LANGUAGES, TextDirection, TranslationDictionary, TranslationLoader, TranslationMap, createI18nRegistry, getLanguageMetadata, i18nRegistry } from '@hai3/i18n';
12
+ import 'path-to-regexp';
13
13
 
14
14
  /**
15
15
  * createHAI3 - App Builder Factory
@@ -36,6 +36,68 @@ export { I18nConfig, I18nRegistryImpl as I18nRegistry, I18nRegistryImpl, I18nReg
36
36
  */
37
37
  declare function createHAI3(config?: HAI3Config): HAI3AppBuilder;
38
38
 
39
+ /**
40
+ * Presets - Pre-configured plugin combinations
41
+ *
42
+ * Framework Layer: L2
43
+ */
44
+
45
+ /**
46
+ * Full preset configuration.
47
+ */
48
+ interface FullPresetConfig {
49
+ /** Configuration for themes plugin */
50
+ themes?: ThemesConfig;
51
+ }
52
+ /**
53
+ * Full preset - All plugins for the complete HAI3 experience.
54
+ * This is the default for `hai3 create` projects.
55
+ *
56
+ * Includes:
57
+ * - screensets (screenset registry, screen slice)
58
+ * - themes (theme registry, changeTheme action)
59
+ * - layout (all layout domain slices and effects)
60
+ * - navigation (navigateToScreen, navigateToScreenset actions)
61
+ * - routing (route registry auto-synced from screensets)
62
+ * - i18n (i18n registry, setLanguage action)
63
+ * - effects (effect coordination)
64
+ * - mock (mock mode control for API services)
65
+ *
66
+ * @param config - Optional preset configuration
67
+ *
68
+ * @example
69
+ * ```typescript
70
+ * import { applyTheme } from '@hai3/uikit';
71
+ *
72
+ * const app = createHAI3()
73
+ * .use(full({ themes: { applyFn: applyTheme } }))
74
+ * .build();
75
+ * ```
76
+ */
77
+ declare function full(config?: FullPresetConfig): HAI3Plugin[];
78
+ /**
79
+ * Minimal preset - Screensets + themes only.
80
+ * For users who want basic HAI3 patterns without full layout management.
81
+ *
82
+ * Includes:
83
+ * - screensets (screenset registry, screen slice)
84
+ * - themes (theme registry, changeTheme action)
85
+ */
86
+ declare function minimal(): HAI3Plugin[];
87
+ /**
88
+ * Headless preset - Screensets only.
89
+ * For external platform integration where you only need screenset orchestration.
90
+ * The external platform provides its own menu, header, navigation, etc.
91
+ *
92
+ * Includes:
93
+ * - screensets (screenset registry, screen slice)
94
+ */
95
+ declare function headless(): HAI3Plugin[];
96
+ /**
97
+ * Presets collection
98
+ */
99
+ declare const presets: Presets;
100
+
39
101
  /**
40
102
  * createHAI3App - Convenience function for full HAI3 application
41
103
  *
@@ -44,6 +106,12 @@ declare function createHAI3(config?: HAI3Config): HAI3AppBuilder;
44
106
  * Framework Layer: L2
45
107
  */
46
108
 
109
+ /**
110
+ * Combined configuration for createHAI3App.
111
+ * Includes both HAI3 core config and full preset config.
112
+ */
113
+ interface HAI3AppConfig extends HAI3Config, FullPresetConfig {
114
+ }
47
115
  /**
48
116
  * Create a fully configured HAI3 application.
49
117
  *
@@ -58,11 +126,15 @@ declare function createHAI3(config?: HAI3Config): HAI3AppBuilder;
58
126
  * // Default - uses full() preset
59
127
  * const app = createHAI3App();
60
128
  *
129
+ * // With theme apply function
130
+ * import { applyTheme } from '@hai3/uikit';
131
+ * const app = createHAI3App({ themes: { applyFn: applyTheme } });
132
+ *
61
133
  * // With configuration
62
134
  * const app = createHAI3App({ devMode: true });
63
135
  * ```
64
136
  */
65
- declare function createHAI3App(config?: HAI3Config): HAI3App;
137
+ declare function createHAI3App(config?: HAI3AppConfig): HAI3App;
66
138
 
67
139
  /**
68
140
  * Screensets Plugin - Provides screenset registry and screen slice
@@ -106,19 +178,22 @@ declare module '@hai3/state' {
106
178
  /**
107
179
  * Themes plugin factory.
108
180
  *
181
+ * @param config - Optional themes configuration
109
182
  * @returns Themes plugin
110
183
  *
111
184
  * @example
112
185
  * ```typescript
186
+ * import { applyTheme } from '@hai3/uikit';
187
+ *
113
188
  * const app = createHAI3()
114
189
  * .use(screensets())
115
- * .use(themes())
190
+ * .use(themes({ applyFn: applyTheme }))
116
191
  * .build();
117
192
  *
118
193
  * app.actions.changeTheme({ themeId: 'dark' });
119
194
  * ```
120
195
  */
121
- declare function themes(): HAI3Plugin;
196
+ declare function themes(config?: ThemesConfig): HAI3Plugin;
122
197
 
123
198
  /**
124
199
  * Layout Plugin - Provides all layout domain slices and effects
@@ -267,47 +342,47 @@ declare function i18n(): HAI3Plugin;
267
342
  declare function effects(): HAI3Plugin;
268
343
 
269
344
  /**
270
- * Presets - Pre-configured plugin combinations
345
+ * Mock Plugin - Centralized mock mode control
271
346
  *
272
347
  * Framework Layer: L2
348
+ *
349
+ * Automatically registers mockSlice and initializes mock effects.
350
+ * Apps don't need to manually call registerSlice(mockSlice) or initMockEffects().
273
351
  */
274
352
 
275
353
  /**
276
- * Full preset - All plugins for the complete HAI3 experience.
277
- * This is the default for `hai3 create` projects.
278
- *
279
- * Includes:
280
- * - screensets (screenset registry, screen slice)
281
- * - themes (theme registry, changeTheme action)
282
- * - layout (all layout domain slices and effects)
283
- * - navigation (navigateToScreen, navigateToScreenset actions)
284
- * - routing (route registry auto-synced from screensets)
285
- * - i18n (i18n registry, setLanguage action)
286
- * - effects (effect coordination)
354
+ * Mock plugin configuration
287
355
  */
288
- declare function full(): HAI3Plugin[];
356
+ interface MockPluginConfig {
357
+ /**
358
+ * Enable mock mode by default.
359
+ * When true, mock plugins are activated immediately on app init.
360
+ * @default true (enabled in dev mode by default)
361
+ */
362
+ enabledByDefault?: boolean;
363
+ }
289
364
  /**
290
- * Minimal preset - Screensets + themes only.
291
- * For users who want basic HAI3 patterns without full layout management.
365
+ * Mock plugin factory.
292
366
  *
293
- * Includes:
294
- * - screensets (screenset registry, screen slice)
295
- * - themes (theme registry, changeTheme action)
296
- */
297
- declare function minimal(): HAI3Plugin[];
298
- /**
299
- * Headless preset - Screensets only.
300
- * For external platform integration where you only need screenset orchestration.
301
- * The external platform provides its own menu, header, navigation, etc.
367
+ * Provides centralized mock mode control for API services.
368
+ * Automatically registers the mock slice and initializes mock effects.
369
+ * In dev mode, mock mode is enabled by default.
302
370
  *
303
- * Includes:
304
- * - screensets (screenset registry, screen slice)
305
- */
306
- declare function headless(): HAI3Plugin[];
307
- /**
308
- * Presets collection
371
+ * @param config - Optional plugin configuration
372
+ * @returns Mock plugin
373
+ *
374
+ * @example
375
+ * ```typescript
376
+ * const app = createHAI3()
377
+ * .use(effects())
378
+ * .use(mock()) // Automatic mock mode support (enabled in dev)
379
+ * .build();
380
+ *
381
+ * // Toggle mock mode via actions
382
+ * app.actions.toggleMockMode(true);
383
+ * ```
309
384
  */
310
- declare const presets: Presets;
385
+ declare function mock(config?: MockPluginConfig): HAI3Plugin;
311
386
 
312
387
  /**
313
388
  * Theme Registry - Manages theme registration and application
@@ -317,8 +392,10 @@ declare const presets: Presets;
317
392
 
318
393
  /**
319
394
  * Create a new theme registry instance.
395
+ *
396
+ * @param config - Optional configuration for the theme registry
320
397
  */
321
- declare function createThemeRegistry(): ThemeRegistry;
398
+ declare function createThemeRegistry(config?: ThemesConfig): ThemeRegistry;
322
399
 
323
400
  /**
324
401
  * Route Registry - Manages routes auto-synced from screensets
@@ -567,6 +644,15 @@ declare const tenantActions: {
567
644
 
568
645
  declare const _default: redux.Reducer<TenantState>;
569
646
 
647
+ interface MockState {
648
+ enabled: boolean;
649
+ }
650
+ declare const setMockEnabled: _reduxjs_toolkit.ActionCreatorWithPayload<boolean, "mock/setMockEnabled">;
651
+ declare const mockSlice: _hai3_state.SliceObject<MockState>;
652
+ declare const mockActions: {
653
+ setMockEnabled: _reduxjs_toolkit.ActionCreatorWithPayload<boolean, "mock/setMockEnabled">;
654
+ };
655
+
570
656
  declare const LAYOUT_SLICE_NAME: "layout";
571
657
  declare const TENANT_SLICE_NAME: "app/tenant";
572
658
  /** Explicit type for layout domain reducers to avoid incorrect dts generation */
@@ -649,49 +735,52 @@ declare function clearTenantAction(): void;
649
735
  declare function setTenantLoadingState(loading: boolean): void;
650
736
 
651
737
  /**
652
- * Backward Compatibility Exports
653
- *
654
- * These exports provide backward compatibility with @hai3/uicore API.
655
- * They are singletons that mirror the old API.
738
+ * Mock Effects
656
739
  *
657
- * NOTE: These are exported for migration convenience but may be deprecated
658
- * in future major versions. Prefer using the plugin architecture.
740
+ * Listens for mock mode toggle events and manages mock plugin lifecycle.
741
+ * Event-driven architecture: UI emits events, effects handle plugin activation/deactivation.
659
742
  */
660
-
661
- declare const ACCOUNTS_DOMAIN: "accounts";
662
-
743
+ /** Mock event names */
744
+ declare const MockEvents: {
745
+ readonly Toggle: "mock/toggle";
746
+ };
747
+ /** Payload for mock toggle event */
748
+ interface MockTogglePayload {
749
+ enabled: boolean;
750
+ }
751
+ declare module '@hai3/state' {
752
+ interface EventPayloadMap {
753
+ 'mock/toggle': MockTogglePayload;
754
+ }
755
+ }
663
756
  /**
664
- * Global theme registry singleton
665
- *
666
- * @deprecated Prefer using app.themeRegistry from createHAI3App()
757
+ * Initialize mock mode effects
758
+ * Call this once during app bootstrap to start listening for mock toggle events.
667
759
  */
668
- declare const themeRegistry: ThemeRegistry;
760
+ declare function initMockEffects(): () => void;
669
761
  /**
670
- * Global route registry singleton
762
+ * Toggle mock mode on/off.
763
+ * Emits event that mockEffects handles.
671
764
  *
672
- * @deprecated Prefer using app.routeRegistry from createHAI3App()
765
+ * @example
766
+ * ```typescript
767
+ * import { toggleMockMode } from '@hai3/framework';
768
+ * toggleMockMode(true); // Enable mock mode
769
+ * toggleMockMode(false); // Disable mock mode
770
+ * ```
673
771
  */
674
- declare const routeRegistry: RouteRegistry;
772
+ declare function toggleMockMode(enabled: boolean): void;
773
+
675
774
  /**
676
- * Navigate to a screen by ID.
677
- * Simply updates the active screen in the store.
678
- *
679
- * NOTE: This is a simplified backward-compatible function.
680
- * For full navigation including screenset switching, use:
681
- * - useNavigation().navigateToScreen(screensetId, screenId) hook
682
- * - or app.actions.navigateToScreen({ screensetId, screenId })
775
+ * Backward Compatibility Exports
683
776
  *
684
- * @param screenId Screen ID to navigate to
685
- * @deprecated Use useNavigation() hook or app.actions.navigateToScreen()
686
- */
687
- declare const navigateToScreen: (screenId: string) => void;
688
- /**
689
- * Fetch current user from API
690
- * Returns a thunk action that fetches user data.
777
+ * These exports provide backward compatibility with @hai3/uicore API.
778
+ * They are singletons that mirror the old API.
691
779
  *
692
- * @deprecated Prefer using api services directly in actions
780
+ * NOTE: These are exported for migration convenience but may be deprecated
781
+ * in future major versions. Prefer using the plugin architecture.
693
782
  */
694
- declare const fetchCurrentUser: () => (_dispatch: AppDispatch) => void;
783
+ declare const ACCOUNTS_DOMAIN: "accounts";
695
784
 
696
785
  /**
697
786
  * Migration Helpers - Utilities for migrating from @hai3/uicore
@@ -828,16 +917,5 @@ declare function hasLegacyUicoreState(state: unknown): state is LegacyRootState;
828
917
  * Check if a state object has the new layout structure
829
918
  */
830
919
  declare function hasNewLayoutState(state: unknown): state is RootStateWithLayout;
831
- /**
832
- * Legacy selectors placeholder
833
- *
834
- * @deprecated Named selectors are removed. Use useAppSelector hook from @hai3/react
835
- * with inline state access: `useAppSelector((state) => state.layout.menu)`
836
- *
837
- * Migration guide:
838
- * - Before: `const menu = useSelector(selectMenu);`
839
- * - After: `const menu = useAppSelector((state: RootState) => state.layout.menu);`
840
- */
841
- declare const legacySelectors: {};
842
920
 
843
- export { ACCOUNTS_DOMAIN, ChangeThemePayload, type FooterConfig, type FooterState, HAI3App, HAI3AppBuilder, HAI3Config, HAI3Plugin, type HeaderConfig, type HeaderState, type HeaderUser, LAYOUT_SLICE_NAME, type LayoutDomainReducers, type LayoutDomainState, type LayoutState, type LegacyRootState, type LegacyUicoreState, type MenuItem, type MenuState, NavigateToScreenPayload, NavigateToScreensetPayload, type OverlayConfig, type OverlayState, type PopupConfig, type PopupSliceState, type PopupState, Presets, type RootStateWithLayout, RouteRegistry, STATE_PATH_MAPPING, type ScreenState, ScreensetsConfig, type Selector, SetLanguagePayload, ShowPopupPayload, type SidebarPosition, type SidebarState, TENANT_SLICE_NAME, type Tenant, type TenantChangedPayload, type TenantClearedPayload, TenantEvents, type TenantState, ThemeRegistry, changeTenant, clearActiveScreen, clearTenant, clearTenantAction, clearUser, closeAllPopups, closePopup, closeTopPopup, createHAI3, createHAI3App, createLegacySelector, createRouteRegistry, createThemeRegistry, effects, fetchCurrentUser, footerActions, footerSlice, full, getLayoutDomainState, hasLegacyUicoreState, hasNewLayoutState, headerActions, headerSlice, headless, hideOverlay, i18n, initTenantEffects, isDeprecationWarningsEnabled, layout, layoutDomainReducers, layoutReducer, legacySelectors, menuActions, menuSlice, minimal, navigateTo, navigateToScreen, navigation, openPopup, overlayActions, overlaySlice, popupActions, popupSlice, presets, routeRegistry, routing, screenActions, screenSlice, screensets, setActiveScreen, setDeprecationWarnings, setFooterConfig, setFooterVisible, setLoading as setHeaderLoading, setMenuCollapsed, setMenuConfig, setMenuItems, setMenuVisible, setOverlayVisible, setScreenLoading, setSidebarCollapsed, setSidebarConfig, setSidebarContent, setSidebarPosition, setSidebarTitle, setSidebarVisible, setSidebarWidth, setTenant, setTenantLoading, setTenantLoadingState, setUser, showOverlay, sidebarActions, sidebarSlice, tenantActions, _default as tenantReducer, tenantSlice, themeRegistry, themes, toggleMenu, toggleSidebar };
921
+ export { ACCOUNTS_DOMAIN, ChangeThemePayload, type FooterConfig, type FooterState, type FullPresetConfig, HAI3App, HAI3AppBuilder, type HAI3AppConfig, HAI3Config, HAI3Plugin, type HeaderConfig, type HeaderState, type HeaderUser, LAYOUT_SLICE_NAME, type LayoutDomainReducers, type LayoutDomainState, type LayoutState, type LegacyRootState, type LegacyUicoreState, type MenuItem, type MenuState, MockEvents, type MockPluginConfig, type MockState, type MockTogglePayload, NavigateToScreenPayload, NavigateToScreensetPayload, type OverlayConfig, type OverlayState, type PopupConfig, type PopupSliceState, type PopupState, Presets, type RootStateWithLayout, RouteRegistry, STATE_PATH_MAPPING, type ScreenState, ScreensetsConfig, type Selector, SetLanguagePayload, ShowPopupPayload, type SidebarPosition, type SidebarState, TENANT_SLICE_NAME, type Tenant, type TenantChangedPayload, type TenantClearedPayload, TenantEvents, type TenantState, ThemeRegistry, ThemesConfig, changeTenant, clearActiveScreen, clearTenant, clearTenantAction, clearUser, closeAllPopups, closePopup, closeTopPopup, createHAI3, createHAI3App, createLegacySelector, createRouteRegistry, createThemeRegistry, effects, footerActions, footerSlice, full, getLayoutDomainState, hasLegacyUicoreState, hasNewLayoutState, headerActions, headerSlice, headless, hideOverlay, i18n, initMockEffects, initTenantEffects, isDeprecationWarningsEnabled, layout, layoutDomainReducers, layoutReducer, menuActions, menuSlice, minimal, mock, mockActions, mockSlice, navigateTo, navigation, openPopup, overlayActions, overlaySlice, popupActions, popupSlice, presets, routing, screenActions, screenSlice, screensets, setActiveScreen, setDeprecationWarnings, setFooterConfig, setFooterVisible, setLoading as setHeaderLoading, setMenuCollapsed, setMenuConfig, setMenuItems, setMenuVisible, setMockEnabled, setOverlayVisible, setScreenLoading, setSidebarCollapsed, setSidebarConfig, setSidebarContent, setSidebarPosition, setSidebarTitle, setSidebarVisible, setSidebarWidth, setTenant, setTenantLoading, setTenantLoadingState, setUser, showOverlay, sidebarActions, sidebarSlice, tenantActions, _default as tenantReducer, tenantSlice, themes, toggleMenu, toggleMockMode, toggleSidebar };