@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/dist/index.d.cts CHANGED
@@ -1,14 +1,13 @@
1
- import { HAI3Config, HAI3AppBuilder, HAI3App, ScreensetsConfig, HAI3Plugin, ChangeThemePayload, ShowPopupPayload, NavigateToScreenPayload, NavigateToScreensetPayload, NavigationConfig, SetLanguagePayload, Presets, ThemeRegistry, RouteRegistry } from './types.cjs';
2
- export { HAI3Store, LegacyTheme, PluginFactory, PluginLifecycle, PluginProvides, Preset, ThemeApplyFn, ThemeConfig } from './types.cjs';
1
+ import { HAI3Config, HAI3AppBuilder, ThemesConfig, Presets, HAI3Plugin, HAI3App, ScreensetsConfig, ChangeThemePayload, ShowPopupPayload, NavigateToScreenPayload, NavigateToScreensetPayload, NavigationConfig, SetLanguagePayload, ThemeRegistry, RouteRegistry } from './types.cjs';
2
+ export { HAI3Store, PluginFactory, PluginLifecycle, PluginProvides, Preset, ThemeApplyFn, ThemeConfig, UikitTheme } from './types.cjs';
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';
13
12
 
14
13
  /**
@@ -36,6 +35,68 @@ export { I18nConfig, I18nRegistryImpl as I18nRegistry, I18nRegistryImpl, I18nReg
36
35
  */
37
36
  declare function createHAI3(config?: HAI3Config): HAI3AppBuilder;
38
37
 
38
+ /**
39
+ * Presets - Pre-configured plugin combinations
40
+ *
41
+ * Framework Layer: L2
42
+ */
43
+
44
+ /**
45
+ * Full preset configuration.
46
+ */
47
+ interface FullPresetConfig {
48
+ /** Configuration for themes plugin */
49
+ themes?: ThemesConfig;
50
+ }
51
+ /**
52
+ * Full preset - All plugins for the complete HAI3 experience.
53
+ * This is the default for `hai3 create` projects.
54
+ *
55
+ * Includes:
56
+ * - screensets (screenset registry, screen slice)
57
+ * - themes (theme registry, changeTheme action)
58
+ * - layout (all layout domain slices and effects)
59
+ * - navigation (navigateToScreen, navigateToScreenset actions)
60
+ * - routing (route registry auto-synced from screensets)
61
+ * - i18n (i18n registry, setLanguage action)
62
+ * - effects (effect coordination)
63
+ * - mock (mock mode control for API services)
64
+ *
65
+ * @param config - Optional preset configuration
66
+ *
67
+ * @example
68
+ * ```typescript
69
+ * import { applyTheme } from '@hai3/uikit';
70
+ *
71
+ * const app = createHAI3()
72
+ * .use(full({ themes: { applyFn: applyTheme } }))
73
+ * .build();
74
+ * ```
75
+ */
76
+ declare function full(config?: FullPresetConfig): HAI3Plugin[];
77
+ /**
78
+ * Minimal preset - Screensets + themes only.
79
+ * For users who want basic HAI3 patterns without full layout management.
80
+ *
81
+ * Includes:
82
+ * - screensets (screenset registry, screen slice)
83
+ * - themes (theme registry, changeTheme action)
84
+ */
85
+ declare function minimal(): HAI3Plugin[];
86
+ /**
87
+ * Headless preset - Screensets only.
88
+ * For external platform integration where you only need screenset orchestration.
89
+ * The external platform provides its own menu, header, navigation, etc.
90
+ *
91
+ * Includes:
92
+ * - screensets (screenset registry, screen slice)
93
+ */
94
+ declare function headless(): HAI3Plugin[];
95
+ /**
96
+ * Presets collection
97
+ */
98
+ declare const presets: Presets;
99
+
39
100
  /**
40
101
  * createHAI3App - Convenience function for full HAI3 application
41
102
  *
@@ -44,6 +105,12 @@ declare function createHAI3(config?: HAI3Config): HAI3AppBuilder;
44
105
  * Framework Layer: L2
45
106
  */
46
107
 
108
+ /**
109
+ * Combined configuration for createHAI3App.
110
+ * Includes both HAI3 core config and full preset config.
111
+ */
112
+ interface HAI3AppConfig extends HAI3Config, FullPresetConfig {
113
+ }
47
114
  /**
48
115
  * Create a fully configured HAI3 application.
49
116
  *
@@ -58,11 +125,15 @@ declare function createHAI3(config?: HAI3Config): HAI3AppBuilder;
58
125
  * // Default - uses full() preset
59
126
  * const app = createHAI3App();
60
127
  *
128
+ * // With theme apply function
129
+ * import { applyTheme } from '@hai3/uikit';
130
+ * const app = createHAI3App({ themes: { applyFn: applyTheme } });
131
+ *
61
132
  * // With configuration
62
133
  * const app = createHAI3App({ devMode: true });
63
134
  * ```
64
135
  */
65
- declare function createHAI3App(config?: HAI3Config): HAI3App;
136
+ declare function createHAI3App(config?: HAI3AppConfig): HAI3App;
66
137
 
67
138
  /**
68
139
  * Screensets Plugin - Provides screenset registry and screen slice
@@ -106,19 +177,22 @@ declare module '@hai3/state' {
106
177
  /**
107
178
  * Themes plugin factory.
108
179
  *
180
+ * @param config - Optional themes configuration
109
181
  * @returns Themes plugin
110
182
  *
111
183
  * @example
112
184
  * ```typescript
185
+ * import { applyTheme } from '@hai3/uikit';
186
+ *
113
187
  * const app = createHAI3()
114
188
  * .use(screensets())
115
- * .use(themes())
189
+ * .use(themes({ applyFn: applyTheme }))
116
190
  * .build();
117
191
  *
118
192
  * app.actions.changeTheme({ themeId: 'dark' });
119
193
  * ```
120
194
  */
121
- declare function themes(): HAI3Plugin;
195
+ declare function themes(config?: ThemesConfig): HAI3Plugin;
122
196
 
123
197
  /**
124
198
  * Layout Plugin - Provides all layout domain slices and effects
@@ -267,47 +341,47 @@ declare function i18n(): HAI3Plugin;
267
341
  declare function effects(): HAI3Plugin;
268
342
 
269
343
  /**
270
- * Presets - Pre-configured plugin combinations
344
+ * Mock Plugin - Centralized mock mode control
271
345
  *
272
346
  * Framework Layer: L2
347
+ *
348
+ * Automatically registers mockSlice and initializes mock effects.
349
+ * Apps don't need to manually call registerSlice(mockSlice) or initMockEffects().
273
350
  */
274
351
 
275
352
  /**
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)
353
+ * Mock plugin configuration
287
354
  */
288
- declare function full(): HAI3Plugin[];
355
+ interface MockPluginConfig {
356
+ /**
357
+ * Enable mock mode by default.
358
+ * When true, mock plugins are activated immediately on app init.
359
+ * @default true (enabled in dev mode by default)
360
+ */
361
+ enabledByDefault?: boolean;
362
+ }
289
363
  /**
290
- * Minimal preset - Screensets + themes only.
291
- * For users who want basic HAI3 patterns without full layout management.
364
+ * Mock plugin factory.
292
365
  *
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.
366
+ * Provides centralized mock mode control for API services.
367
+ * Automatically registers the mock slice and initializes mock effects.
368
+ * In dev mode, mock mode is enabled by default.
302
369
  *
303
- * Includes:
304
- * - screensets (screenset registry, screen slice)
305
- */
306
- declare function headless(): HAI3Plugin[];
307
- /**
308
- * Presets collection
370
+ * @param config - Optional plugin configuration
371
+ * @returns Mock plugin
372
+ *
373
+ * @example
374
+ * ```typescript
375
+ * const app = createHAI3()
376
+ * .use(effects())
377
+ * .use(mock()) // Automatic mock mode support (enabled in dev)
378
+ * .build();
379
+ *
380
+ * // Toggle mock mode via actions
381
+ * app.actions.toggleMockMode(true);
382
+ * ```
309
383
  */
310
- declare const presets: Presets;
384
+ declare function mock(config?: MockPluginConfig): HAI3Plugin;
311
385
 
312
386
  /**
313
387
  * Theme Registry - Manages theme registration and application
@@ -317,8 +391,10 @@ declare const presets: Presets;
317
391
 
318
392
  /**
319
393
  * Create a new theme registry instance.
394
+ *
395
+ * @param config - Optional configuration for the theme registry
320
396
  */
321
- declare function createThemeRegistry(): ThemeRegistry;
397
+ declare function createThemeRegistry(config?: ThemesConfig): ThemeRegistry;
322
398
 
323
399
  /**
324
400
  * Route Registry - Manages routes auto-synced from screensets
@@ -567,6 +643,15 @@ declare const tenantActions: {
567
643
 
568
644
  declare const _default: redux.Reducer<TenantState>;
569
645
 
646
+ interface MockState {
647
+ enabled: boolean;
648
+ }
649
+ declare const setMockEnabled: _reduxjs_toolkit.ActionCreatorWithPayload<boolean, "mock/setMockEnabled">;
650
+ declare const mockSlice: _hai3_state.SliceObject<MockState>;
651
+ declare const mockActions: {
652
+ setMockEnabled: _reduxjs_toolkit.ActionCreatorWithPayload<boolean, "mock/setMockEnabled">;
653
+ };
654
+
570
655
  declare const LAYOUT_SLICE_NAME: "layout";
571
656
  declare const TENANT_SLICE_NAME: "app/tenant";
572
657
  /** Explicit type for layout domain reducers to avoid incorrect dts generation */
@@ -649,49 +734,52 @@ declare function clearTenantAction(): void;
649
734
  declare function setTenantLoadingState(loading: boolean): void;
650
735
 
651
736
  /**
652
- * Backward Compatibility Exports
653
- *
654
- * These exports provide backward compatibility with @hai3/uicore API.
655
- * They are singletons that mirror the old API.
737
+ * Mock Effects
656
738
  *
657
- * NOTE: These are exported for migration convenience but may be deprecated
658
- * in future major versions. Prefer using the plugin architecture.
739
+ * Listens for mock mode toggle events and manages mock plugin lifecycle.
740
+ * Event-driven architecture: UI emits events, effects handle plugin activation/deactivation.
659
741
  */
660
-
661
- declare const ACCOUNTS_DOMAIN: "accounts";
662
-
742
+ /** Mock event names */
743
+ declare const MockEvents: {
744
+ readonly Toggle: "mock/toggle";
745
+ };
746
+ /** Payload for mock toggle event */
747
+ interface MockTogglePayload {
748
+ enabled: boolean;
749
+ }
750
+ declare module '@hai3/state' {
751
+ interface EventPayloadMap {
752
+ 'mock/toggle': MockTogglePayload;
753
+ }
754
+ }
663
755
  /**
664
- * Global theme registry singleton
665
- *
666
- * @deprecated Prefer using app.themeRegistry from createHAI3App()
756
+ * Initialize mock mode effects
757
+ * Call this once during app bootstrap to start listening for mock toggle events.
667
758
  */
668
- declare const themeRegistry: ThemeRegistry;
759
+ declare function initMockEffects(): () => void;
669
760
  /**
670
- * Global route registry singleton
761
+ * Toggle mock mode on/off.
762
+ * Emits event that mockEffects handles.
671
763
  *
672
- * @deprecated Prefer using app.routeRegistry from createHAI3App()
764
+ * @example
765
+ * ```typescript
766
+ * import { toggleMockMode } from '@hai3/framework';
767
+ * toggleMockMode(true); // Enable mock mode
768
+ * toggleMockMode(false); // Disable mock mode
769
+ * ```
673
770
  */
674
- declare const routeRegistry: RouteRegistry;
771
+ declare function toggleMockMode(enabled: boolean): void;
772
+
675
773
  /**
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 })
774
+ * Backward Compatibility Exports
683
775
  *
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.
776
+ * These exports provide backward compatibility with @hai3/uicore API.
777
+ * They are singletons that mirror the old API.
691
778
  *
692
- * @deprecated Prefer using api services directly in actions
779
+ * NOTE: These are exported for migration convenience but may be deprecated
780
+ * in future major versions. Prefer using the plugin architecture.
693
781
  */
694
- declare const fetchCurrentUser: () => (_dispatch: AppDispatch) => void;
782
+ declare const ACCOUNTS_DOMAIN: "accounts";
695
783
 
696
784
  /**
697
785
  * Migration Helpers - Utilities for migrating from @hai3/uicore
@@ -828,16 +916,5 @@ declare function hasLegacyUicoreState(state: unknown): state is LegacyRootState;
828
916
  * Check if a state object has the new layout structure
829
917
  */
830
918
  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
919
 
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 };
920
+ 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 };