@hai3/framework 0.2.0-alpha.0 → 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.ts CHANGED
@@ -1,14 +1,13 @@
1
- import { HAI3Config, HAI3AppBuilder, HAI3App, ScreensetsConfig, HAI3Plugin, ChangeThemePayload, ShowPopupPayload, NavigateToScreenPayload, NavigateToScreensetPayload, 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, Presets, HAI3Plugin, HAI3App, ScreensetsConfig, ChangeThemePayload, ShowPopupPayload, NavigateToScreenPayload, NavigateToScreensetPayload, NavigationConfig, SetLanguagePayload, ThemeRegistry, RouteRegistry } from './types.js';
2
+ export { HAI3Store, PluginFactory, PluginLifecycle, PluginProvides, Preset, 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';
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
@@ -176,19 +250,20 @@ declare module '@hai3/state' {
176
250
  /**
177
251
  * Navigation plugin factory.
178
252
  *
253
+ * @param config - Optional navigation configuration
179
254
  * @returns Navigation plugin
180
255
  *
181
256
  * @example
182
257
  * ```typescript
183
258
  * const app = createHAI3()
184
259
  * .use(screensets())
185
- * .use(navigation())
260
+ * .use(navigation({ base: '/app' }))
186
261
  * .build();
187
262
  *
188
263
  * app.actions.navigateToScreen({ screensetId: 'demo', screenId: 'home' });
189
264
  * ```
190
265
  */
191
- declare function navigation(): HAI3Plugin;
266
+ declare function navigation(config?: NavigationConfig): HAI3Plugin;
192
267
 
193
268
  /**
194
269
  * Routing Plugin - Provides route registry auto-synced from screensets
@@ -266,47 +341,47 @@ declare function i18n(): HAI3Plugin;
266
341
  declare function effects(): HAI3Plugin;
267
342
 
268
343
  /**
269
- * Presets - Pre-configured plugin combinations
344
+ * Mock Plugin - Centralized mock mode control
270
345
  *
271
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().
272
350
  */
273
351
 
274
352
  /**
275
- * Full preset - All plugins for the complete HAI3 experience.
276
- * This is the default for `hai3 create` projects.
277
- *
278
- * Includes:
279
- * - screensets (screenset registry, screen slice)
280
- * - themes (theme registry, changeTheme action)
281
- * - layout (all layout domain slices and effects)
282
- * - navigation (navigateToScreen, navigateToScreenset actions)
283
- * - routing (route registry auto-synced from screensets)
284
- * - i18n (i18n registry, setLanguage action)
285
- * - effects (effect coordination)
353
+ * Mock plugin configuration
286
354
  */
287
- 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
+ }
288
363
  /**
289
- * Minimal preset - Screensets + themes only.
290
- * For users who want basic HAI3 patterns without full layout management.
364
+ * Mock plugin factory.
291
365
  *
292
- * Includes:
293
- * - screensets (screenset registry, screen slice)
294
- * - themes (theme registry, changeTheme action)
295
- */
296
- declare function minimal(): HAI3Plugin[];
297
- /**
298
- * Headless preset - Screensets only.
299
- * For external platform integration where you only need screenset orchestration.
300
- * 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.
301
369
  *
302
- * Includes:
303
- * - screensets (screenset registry, screen slice)
304
- */
305
- declare function headless(): HAI3Plugin[];
306
- /**
307
- * 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
+ * ```
308
383
  */
309
- declare const presets: Presets;
384
+ declare function mock(config?: MockPluginConfig): HAI3Plugin;
310
385
 
311
386
  /**
312
387
  * Theme Registry - Manages theme registration and application
@@ -316,8 +391,10 @@ declare const presets: Presets;
316
391
 
317
392
  /**
318
393
  * Create a new theme registry instance.
394
+ *
395
+ * @param config - Optional configuration for the theme registry
319
396
  */
320
- declare function createThemeRegistry(): ThemeRegistry;
397
+ declare function createThemeRegistry(config?: ThemesConfig): ThemeRegistry;
321
398
 
322
399
  /**
323
400
  * Route Registry - Manages routes auto-synced from screensets
@@ -566,6 +643,15 @@ declare const tenantActions: {
566
643
 
567
644
  declare const _default: redux.Reducer<TenantState>;
568
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
+
569
655
  declare const LAYOUT_SLICE_NAME: "layout";
570
656
  declare const TENANT_SLICE_NAME: "app/tenant";
571
657
  /** Explicit type for layout domain reducers to avoid incorrect dts generation */
@@ -648,49 +734,52 @@ declare function clearTenantAction(): void;
648
734
  declare function setTenantLoadingState(loading: boolean): void;
649
735
 
650
736
  /**
651
- * Backward Compatibility Exports
652
- *
653
- * These exports provide backward compatibility with @hai3/uicore API.
654
- * They are singletons that mirror the old API.
737
+ * Mock Effects
655
738
  *
656
- * NOTE: These are exported for migration convenience but may be deprecated
657
- * 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.
658
741
  */
659
-
660
- declare const ACCOUNTS_DOMAIN: "accounts";
661
-
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
+ }
662
755
  /**
663
- * Global theme registry singleton
664
- *
665
- * @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.
666
758
  */
667
- declare const themeRegistry: ThemeRegistry;
759
+ declare function initMockEffects(): () => void;
668
760
  /**
669
- * Global route registry singleton
761
+ * Toggle mock mode on/off.
762
+ * Emits event that mockEffects handles.
670
763
  *
671
- * @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
+ * ```
672
770
  */
673
- declare const routeRegistry: RouteRegistry;
771
+ declare function toggleMockMode(enabled: boolean): void;
772
+
674
773
  /**
675
- * Navigate to a screen by ID.
676
- * Simply updates the active screen in the store.
677
- *
678
- * NOTE: This is a simplified backward-compatible function.
679
- * For full navigation including screenset switching, use:
680
- * - useNavigation().navigateToScreen(screensetId, screenId) hook
681
- * - or app.actions.navigateToScreen({ screensetId, screenId })
774
+ * Backward Compatibility Exports
682
775
  *
683
- * @param screenId Screen ID to navigate to
684
- * @deprecated Use useNavigation() hook or app.actions.navigateToScreen()
685
- */
686
- declare const navigateToScreen: (screenId: string) => void;
687
- /**
688
- * Fetch current user from API
689
- * 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.
690
778
  *
691
- * @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.
692
781
  */
693
- declare const fetchCurrentUser: () => (_dispatch: AppDispatch) => void;
782
+ declare const ACCOUNTS_DOMAIN: "accounts";
694
783
 
695
784
  /**
696
785
  * Migration Helpers - Utilities for migrating from @hai3/uicore
@@ -827,16 +916,5 @@ declare function hasLegacyUicoreState(state: unknown): state is LegacyRootState;
827
916
  * Check if a state object has the new layout structure
828
917
  */
829
918
  declare function hasNewLayoutState(state: unknown): state is RootStateWithLayout;
830
- /**
831
- * Legacy selectors placeholder
832
- *
833
- * @deprecated Named selectors are removed. Use useAppSelector hook from @hai3/react
834
- * with inline state access: `useAppSelector((state) => state.layout.menu)`
835
- *
836
- * Migration guide:
837
- * - Before: `const menu = useSelector(selectMenu);`
838
- * - After: `const menu = useAppSelector((state: RootState) => state.layout.menu);`
839
- */
840
- declare const legacySelectors: {};
841
919
 
842
- 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 };