@gears-frontx/react 0.1.0 → 0.2.0-alpha.0

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,61 +1,180 @@
1
1
  import * as React from 'react';
2
- import React__default, { RefObject } from 'react';
3
- import { H as HAI3ProviderProps, U as UseTranslationReturn, a as UseScreenTranslationsReturn, b as UseFormattersReturn, c as UseThemeReturn, M as MfeContextValue } from './types-Cp8Zm5s0.js';
4
- export { d as MfeContext, e as UseAppDispatchReturn, f as UseAppSelector, g as UseHAI3Return, u as useMfeContext } from './types-Cp8Zm5s0.js';
5
- import { HAI3App, AppDispatch, RootState, TranslationMap, TranslationLoader, ChildMfeBridge, Extension, ContainerProvider, ScreensetsRegistry, ParentMfeBridge, EventPayloadMap as EventPayloadMap$1, EventBus } from '@gears-frontx/framework';
6
- export { ACCOUNTS_DOMAIN, Action, ActionsChain, ApiPlugin, ApiPluginBase, ApiPluginErrorContext, ApiProtocol, ApiRequestContext, ApiResponseContext, ApiServiceConfig, AppDispatch, BaseApiService, BasePluginHooks, ChangeThemePayload, ChildMfeBridge, ContainerProvider, EventHandler, EventSourceLike, Extension, ExtensionDomain, ExtensionPresentation, ExtensionRegistrationState, FRONTX_ACTION_LOAD_EXT, FRONTX_ACTION_MOUNT_EXT, FRONTX_ACTION_UNMOUNT_EXT, FRONTX_MFE_ENTRY_MF, FRONTX_OVERLAY_DOMAIN, FRONTX_POPUP_DOMAIN, FRONTX_SCREEN_DOMAIN, FRONTX_SCREEN_EXTENSION_TYPE, FRONTX_SHARED_PROPERTY_LANGUAGE, FRONTX_SHARED_PROPERTY_THEME, FRONTX_SIDEBAR_DOMAIN, FooterConfig, FooterState, HAI3App, HAI3AppBuilder, HAI3Config, HAI3Plugin, HAI3Store, HeaderConfig, HeaderState, HeaderUser, I18nConfig, I18nRegistry, I18nRegistryImpl, I18nRegistryType, JSONSchema, JsonCompatible, JsonObject, JsonPrimitive, JsonValue, LAYOUT_SLICE_NAME, Language, LanguageDisplayMode, LanguageMetadata, LayoutDomain, LayoutDomainReducers, LayoutDomainState, LayoutState, LifecycleHook, LifecycleStage, LoadExtPayload, MOCK_PLUGIN, MenuItem, MenuState, MfeBridgeFactory, MfeEntry, MfeEntryLifecycle, MfeEntryMF, MfeHandler, MfeHandlerMF, MfeState, MockEventSource, MockEvents, MockMap, MockState, MockTogglePayload, MountExtPayload, OverlayConfig, OverlayState, ParentMfeBridge, PluginClass, PluginFactory, PluginLifecycle, PluginProvides, PopupConfig, PopupSliceState, PopupState, Preset, Presets, ProtocolClass, ProtocolPluginType, ReducerPayload, RegisterExtensionPayload, RestMockConfig, RestMockPlugin, RestPlugin, RestPluginHooks, RestPluginWithConfig, RestProtocol, RestProtocolConfig, RestRequestContext, RestResponseContext, RestShortCircuitResponse, RootState, RootStateWithLayout, SUPPORTED_LANGUAGES, ScreenExtension, ScreenState, ScreensetsConfig, ScreensetsRegistry, ScreensetsRegistryConfig, ScreensetsRegistryFactory, SetLanguagePayload, SharedProperty, ShortCircuitResponse, ShowPopupPayload, SidebarPosition, SidebarState, SliceObject, SseConnectContext, SseMockConfig, SseMockEvent, SseMockPlugin, SsePlugin, SsePluginHooks, SsePluginWithConfig, SseProtocol, SseProtocolConfig, SseShortCircuitResponse, Subscription, TENANT_SLICE_NAME, Tenant, TenantChangedPayload, TenantClearedPayload, TenantEvents, TenantState, TextDirection, ThemeConfig, ThemeRegistry, TranslationDictionary, TranslationLoader, TranslationMap, TypeSystemPlugin, UnmountExtPayload, UnregisterExtensionPayload, ValidationError, ValidationResult, apiRegistry, changeTenant, clearActiveScreen, clearTenant, clearTenantAction, clearUser, closeAllPopups, closePopup, closeTopPopup, createHAI3, createHAI3App, createI18nRegistry, createShadowRoot, createSlice, createStore, createThemeRegistry, effects, extensionScreenSchema, extractGtsPackage, footerActions, footerSlice, getLanguageMetadata, getStore, gtsPlugin, hasSlice, headerActions, headerSlice, hideOverlay, i18n, i18nRegistry, initMockEffects, initTenantEffects, injectCssVariables, isMockPlugin, isRestShortCircuit, isShortCircuit, isSseShortCircuit, languageSchema, layout, layoutDomainReducers, layoutReducer, loadExtension, menuActions, menuSlice, microfrontends, mock, mockActions, mockSlice, mountExtension, navigateTo, openPopup, overlayActions, overlayDomain, overlaySlice, popupActions, popupDomain, popupSlice, presets, registerExtension, registerSlice, screenActions, screenDomain, screenSlice, screensets, screensetsRegistryFactory, selectExtensionError, selectExtensionState, selectRegisteredExtensions, setActiveScreen, setFooterConfig, setFooterVisible, setHeaderLoading, setMenuCollapsed, setMenuConfig, setMenuItems, setMenuVisible, setMockEnabled, setOverlayVisible, setScreenLoading, setSidebarCollapsed, setSidebarConfig, setSidebarContent, setSidebarPosition, setSidebarTitle, setSidebarVisible, setSidebarWidth, setTenant, setTenantLoading, setTenantLoadingState, setUser, showOverlay, sidebarActions, sidebarDomain, sidebarSlice, tenantActions, tenantReducer, tenantSlice, themeSchema, themes, toggleMenu, toggleMockMode, toggleSidebar, unmountExtension, unregisterExtension } from '@gears-frontx/framework';
2
+ import React__default, { ReactElement } from 'react';
3
+ import { F as FrontXProviderProps, A as ApiQueryResult, a as ApiInfiniteQueryResult, b as ApiMutationResult, C as CanAccessProps, U as UseTranslationReturn, c as UseScreenTranslationsReturn, d as UseFormattersReturn, e as UseThemeReturn, f as ApiSuspenseQueryResult, g as ApiSuspenseInfiniteQueryResult, h as UseCanAccessResult, M as MfeContextValue } from './types-Cjd20AT-.js';
4
+ export { i as MfeContext, j as UseAppDispatchReturn, k as UseAppSelector, l as UseFrontXReturn, u as useMfeContext } from './types-Cjd20AT-.js';
5
+ import { FrontXApp, EndpointDescriptor, MutationDescriptor, AccessRecord, AppDispatch, RootState, TranslationMap, TranslationLoader, StreamStatus, StreamDescriptor, AccessQuery, ChildMfeBridge, Extension, MfeEntryLifecycle, MfeMountContext, MfeRegistry, EventPayloadMap as EventPayloadMap$1, EventBus } from '@gears-frontx/framework';
6
+ export { ACCOUNTS_DOMAIN, AccessDecision, AccessQuery, Action, ActionHandler, ActionPayload, ActionsChain, ApiPlugin, ApiPluginBase, ApiPluginErrorContext, ApiProtocol, ApiRequestContext, ApiResponseContext, ApiServiceConfig, AppDispatch, AuthCallbackInput, AuthCapabilities, AuthCheckResult, AuthContext, AuthLoginInput, AuthPermissions, AuthPluginConfig, AuthProvider, AuthRuntime, AuthSession, AuthState, AuthStateEvent, AuthStateListener, AuthTransition, AuthUnsubscribe, BaseApiService, BasePluginHooks, ChangeThemePayload, ChildMfeBridge, ConcurrentMountStrategy, ContainerHooks, DomainContext, EndpointDescriptor, EndpointOptions, EventHandler, EventSourceLike, ExclusiveMountStrategy, Extension, ExtensionDomain, ExtensionDomainImplementation, ExtensionDomainImplementationFactory, ExtensionMounter, ExtensionPresentation, ExtensionRegistrationState, FRONTX_ACTION_LOAD_EXT, FRONTX_ACTION_MOUNT_EXT, FRONTX_ACTION_UNMOUNT_EXT, FRONTX_MFE_ENTRY_MF, FRONTX_OVERLAY_DOMAIN, FRONTX_POPUP_DOMAIN, FRONTX_SCREEN_DOMAIN, FRONTX_SCREEN_EXTENSION_TYPE, FRONTX_SHARED_PROPERTY_LANGUAGE, FRONTX_SHARED_PROPERTY_THEME, FRONTX_SIDEBAR_DOMAIN, FooterConfig, FooterState, FrontXApp, FrontXAppBuilder, FrontXConfig, FrontXPlugin, FrontXStore, HeaderConfig, HeaderState, HeaderUser, I18nConfig, I18nRegistry, I18nRegistryImpl, I18nRegistryType, JSONSchema, JsonCompatible, JsonObject, JsonPrimitive, JsonValue, LAYOUT_SLICE_NAME, Language, LanguageDisplayMode, LanguageMetadata, LayoutDomain, LayoutDomainReducers, LayoutDomainState, LayoutState, LifecycleHook, LifecycleStage, LoadExtPayload, MOCK_PLUGIN, MenuItem, MenuState, MfManifest, MfManifestAssets, MfManifestBuildInfo, MfManifestMetaData, MfManifestRemoteEntry, MfManifestShared, MfeBridgeFactory, MfeEntry, MfeEntryLifecycle, MfeEntryMF, MfeHandler, MfeHandlerMF, MfeMountContext, MfeRegistry, MfeRegistryConfig, MfeRegistryFactory, MfeState, MockEventSource, MockEvents, MockMap, MockState, MockTogglePayload, MountExtPayload, MountStrategy, MutationDescriptor, OptionalMountStrategy, OverlayConfig, OverlayState, ParameterizedEndpointDescriptor, ParentMfeBridge, PluginClass, PluginFactory, PluginLifecycle, PluginProvides, PopupConfig, PopupSliceState, PopupState, Preset, Presets, ProtocolClass, ProtocolPluginType, ReducerPayload, RegisterExtensionPayload, RestEndpointProtocol, RestMockConfig, RestMockPlugin, RestPlugin, RestPluginHooks, RestPluginWithConfig, RestProtocol, RestProtocolConfig, RestRequestContext, RestResponseContext, RestShortCircuitResponse, RootState, RootStateWithLayout, SUPPORTED_LANGUAGES, ScreenExtension, SetLanguagePayload, SharedProperty, ShortCircuitResponse, ShowPopupPayload, SidebarPosition, SidebarState, SliceObject, SseConnectContext, SseMockConfig, SseMockEvent, SseMockPlugin, SsePlugin, SsePluginHooks, SsePluginWithConfig, SseProtocol, SseProtocolConfig, SseShortCircuitResponse, SseStreamProtocol, StreamDescriptor, StreamStatus, Subscription, TENANT_SLICE_NAME, Tenant, TenantChangedPayload, TenantClearedPayload, TenantEvents, TenantState, TextDirection, ThemeConfig, ThemeRegistry, TranslationDictionary, TranslationLoader, TranslationMap, TypeSystemPlugin, UnmountExtPayload, UnregisterExtensionPayload, apiRegistry, auth, changeTenant, clearTenant, clearTenantAction, clearUser, closeAllPopups, closePopup, closeTopPopup, createFrontX, createFrontXApp, createI18nRegistry, createShadowRoot, createSlice, createStore, createThemeRegistry, effects, extensionScreenSchema, extractGtsPackage, footerActions, footerSlice, frontxApiTransport, getLanguageMetadata, getStore, gtsPlugin, hasSlice, headerActions, headerSlice, hideOverlay, i18n, i18nRegistry, initMockEffects, initTenantEffects, injectCssVariables, isMockPlugin, isRestShortCircuit, isShortCircuit, isSseShortCircuit, languageSchema, layout, layoutDomainReducers, layoutReducer, loadExtension, menuActions, menuSlice, mfeRegistryFactory, microfrontends, mock, mockActions, mockSlice, mountExtension, openPopup, overlayActions, overlayDomain, overlaySlice, popupActions, popupDomain, popupSlice, presets, queryCache, queryCacheShared, registerExtension, registerSlice, screenDomain, selectExtensionError, selectExtensionState, selectMountedExtensions, selectRegisteredExtensions, setFooterConfig, setFooterVisible, setHeaderLoading, setMenuCollapsed, setMenuConfig, setMenuItems, setMenuVisible, setMockEnabled, setOverlayVisible, setSidebarCollapsed, setSidebarConfig, setSidebarContent, setSidebarPosition, setSidebarTitle, setSidebarVisible, setSidebarWidth, setTenant, setTenantLoading, setTenantLoadingState, setUser, showOverlay, sidebarActions, sidebarDomain, sidebarSlice, subscribeQueryCacheRuntimeChanged, tenantActions, tenantReducer, tenantSlice, themeSchema, themes, toggleMenu, toggleMockMode, toggleSidebar, unmountExtension, unregisterExtension } from '@gears-frontx/framework';
7
+ import { M as MutationCallbackContext, Q as QueryCache } from './testing-Dlmfu6tE.js';
8
+ export { a as QueryCacheInvalidateFilters, b as QueryCacheState, i as invalidateQueryCacheForApp } from './testing-Dlmfu6tE.js';
7
9
  import { TypedUseSelectorHook } from 'react-redux';
10
+ import '@tanstack/react-query';
11
+ import '@gears-frontx/framework/testing';
8
12
 
9
13
  /**
10
- * HAI3 Provider - Main provider component for HAI3 applications
14
+ * FrontX Provider - Main provider component for FrontX applications
11
15
  *
12
16
  * React Layer: L3 (Depends on @gears-frontx/framework)
17
+ *
18
+ * Query cache lifecycle is owned by the queryCache() framework plugin (L2).
19
+ * FrontXProvider reads the plugin-owned QueryClient from the app and mounts the
20
+ * internal React provider around the tree when it is available.
13
21
  */
14
22
 
15
23
  /**
16
- * HAI3 Provider Component
24
+ * FrontX Provider Component
17
25
  *
18
- * Provides the HAI3 application context to all child components.
19
- * Creates the HAI3 app instance with the full preset by default.
26
+ * Provides the FrontX application context to all child components.
27
+ * Creates the FrontX app instance with the full preset by default.
20
28
  *
21
29
  * @example
22
30
  * ```tsx
23
31
  * // Default - creates app with full preset
24
- * <HAI3Provider>
32
+ * <FrontXProvider>
25
33
  * <App />
26
- * </HAI3Provider>
34
+ * </FrontXProvider>
27
35
  *
28
36
  * // With configuration
29
- * <HAI3Provider config={{ devMode: true }}>
37
+ * <FrontXProvider config={{ devMode: true }}>
30
38
  * <App />
31
- * </HAI3Provider>
39
+ * </FrontXProvider>
32
40
  *
33
41
  * // With pre-built app
34
- * const app = createHAI3().use(screensets()).use(microfrontends()).build();
35
- * <HAI3Provider app={app}>
42
+ * const app = createFrontX().use(queryCache()).build();
43
+ * <FrontXProvider app={app}>
36
44
  * <App />
37
- * </HAI3Provider>
45
+ * </FrontXProvider>
38
46
  *
39
47
  * // With MFE bridge (for MFE components)
40
- * <HAI3Provider mfeBridge={{ bridge, extensionId, domainId }}>
48
+ * <FrontXProvider mfeBridge={{ bridge, extensionId, domainId }}>
49
+ * <MyMfeApp />
50
+ * </FrontXProvider>
51
+ *
52
+ * // QueryCache is resolved from the app's plugin composition
53
+ * <FrontXProvider app={app}>
41
54
  * <MyMfeApp />
42
- * </HAI3Provider>
55
+ * </FrontXProvider>
43
56
  * ```
44
57
  */
45
- declare const HAI3Provider: React__default.FC<HAI3ProviderProps>;
58
+ declare const FrontXProvider: React__default.FC<FrontXProviderProps>;
59
+
60
+ /**
61
+ * FrontX Context
62
+ * Holds the FrontX app instance for the application.
63
+ */
64
+ declare const FrontXContext: React.Context<FrontXApp | null>;
65
+ /**
66
+ * Use the FrontX context.
67
+ * Throws if used outside of FrontXProvider.
68
+ *
69
+ * @returns The FrontX app instance
70
+ */
71
+ declare function useFrontX(): FrontXApp;
72
+
73
+ /**
74
+ * useApiQuery - Declarative data fetching hook
75
+ *
76
+ * Accepts an EndpointDescriptor from @gears-frontx/api and returns a Gears FrontX-owned
77
+ * ApiQueryResult. AbortSignal for request cancellation is threaded automatically
78
+ * through the shared QueryClient integration.
79
+ *
80
+ * Cache config cascade: component overrides > descriptor defaults > plugin defaults.
81
+ * Omit overrides to rely on the descriptor's staleTime/gcTime, which in turn
82
+ * fall back to the plugin-level query-cache defaults.
83
+ */
84
+
85
+ /** Per-call cache overrides. Cascade: these > descriptor > plugin defaults. */
86
+ interface ApiQueryOverrides {
87
+ /** Override staleTime for this specific call site. */
88
+ staleTime?: number;
89
+ /** Override gcTime for this specific call site. */
90
+ gcTime?: number;
91
+ }
92
+ declare function useApiQuery<TData = unknown, TError = Error>(descriptor: EndpointDescriptor<TData>, overrides?: ApiQueryOverrides): ApiQueryResult<TData, TError>;
93
+
94
+ /**
95
+ * useApiInfiniteQuery - Declarative paginated data fetching hook
96
+ *
97
+ * Accepts an initial EndpointDescriptor plus descriptor resolvers for adjacent
98
+ * pages. Each page remains a standard service descriptor so MFE code does not
99
+ * need raw TanStack query keys or query functions.
100
+ */
101
+
102
+ interface ApiInfiniteQueryPageContext<TPage> {
103
+ page: TPage;
104
+ pages: readonly TPage[];
105
+ descriptor: EndpointDescriptor<TPage>;
106
+ descriptors: readonly EndpointDescriptor<TPage>[];
107
+ }
108
+ interface ApiInfiniteQueryOptions<TPage> extends ApiQueryOverrides {
109
+ /** Descriptor for the first page in the sequence. */
110
+ initialPage: EndpointDescriptor<TPage>;
111
+ /**
112
+ * Resolve the next page descriptor from the current page payload.
113
+ * Return undefined when there is no next page.
114
+ */
115
+ getNextPage: (context: ApiInfiniteQueryPageContext<TPage>) => EndpointDescriptor<TPage> | undefined;
116
+ /**
117
+ * Resolve the previous page descriptor from the current first page payload.
118
+ * Return undefined when backward pagination is not available.
119
+ */
120
+ getPreviousPage?: (context: ApiInfiniteQueryPageContext<TPage>) => EndpointDescriptor<TPage> | undefined;
121
+ /** Optional TanStack maxPages passthrough for bounded page windows. */
122
+ maxPages?: number;
123
+ }
124
+ declare function useApiInfiniteQuery<TPage = unknown, TError = Error>(options: ApiInfiniteQueryOptions<TPage>): ApiInfiniteQueryResult<TPage, TError>;
125
+
126
+ /**
127
+ * useApiMutation - Declarative mutation hook with restricted QueryCache injection
128
+ *
129
+ * Accepts { endpoint: MutationDescriptor, callbacks } and returns a Gears FrontX-owned
130
+ * ApiMutationResult. Supports optimistic updates, rollback, and cache invalidation
131
+ * through the QueryCache interface injected into each callback.
132
+ *
133
+ * Optimistic update pattern:
134
+ * onMutate -> cancel outgoing refetches, snapshot via queryCache.get,
135
+ * apply optimistic data via queryCache.set, return snapshot
136
+ * onError -> restore snapshot via queryCache.set(key, context.snapshot)
137
+ * onSettled -> invalidate to refetch authoritative state
138
+ *
139
+ * TanStack Query is used internally only and is NOT re-exported.
140
+ * MFEs interact with the cache through QueryCache, not the raw QueryClient.
141
+ */
46
142
 
47
143
  /**
48
- * HAI3 Context
49
- * Holds the HAI3 app instance for the application.
144
+ * Options for useApiMutation.
145
+ *
146
+ * Each callback receives { queryCache } as an additional final parameter,
147
+ * providing controlled access to the shared cache without exposing the
148
+ * raw QueryClient. TContext is the return type of onMutate, passed as
149
+ * context to onSuccess, onError, and onSettled.
50
150
  */
51
- declare const HAI3Context: React.Context<HAI3App | null>;
151
+ type UseApiMutationOptions<TData = unknown, TError = Error, TVariables = void, TContext = unknown> = {
152
+ endpoint: MutationDescriptor<TData, TVariables>;
153
+ cancelOnSupersede?: boolean;
154
+ abortOnUnmount?: boolean;
155
+ onMutate?: (variables: TVariables, ctx: MutationCallbackContext) => Promise<TContext> | TContext;
156
+ onSuccess?: (data: TData, variables: TVariables, context: TContext | undefined, ctx: MutationCallbackContext) => unknown;
157
+ onError?: (error: TError, variables: TVariables, context: TContext | undefined, ctx: MutationCallbackContext) => unknown;
158
+ onSettled?: (data: TData | undefined, error: TError | null, variables: TVariables, context: TContext | undefined, ctx: MutationCallbackContext) => unknown;
159
+ };
160
+ declare function useApiMutation<TData = unknown, TError = Error, TVariables = void, TContext = unknown>(options: UseApiMutationOptions<TData, TError, TVariables, TContext>): ApiMutationResult<TData, TError, TVariables>;
161
+
52
162
  /**
53
- * Use the HAI3 context.
54
- * Throws if used outside of HAI3Provider.
163
+ * Declarative RBAC guard component.
164
+ *
165
+ * Pessimistic: renders `denied` (or `loading` if provided) until an explicit
166
+ * 'allow' decision arrives from app.auth.canAccess. Only renders `allowed`
167
+ * after a confirmed allow.
55
168
  *
56
- * @returns The HAI3 app instance
169
+ * Example:
170
+ * <CanAccess
171
+ * query={{ action: AppAction.InvoicesRead, resource: ResourceKind.Invoice }}
172
+ * allowed={<InvoiceList />}
173
+ * denied={<AccessDenied />}
174
+ * loading={<Spinner />}
175
+ * />
57
176
  */
58
- declare function useHAI3(): HAI3App;
177
+ declare function CanAccess<TRecord extends AccessRecord = AccessRecord>({ query, allowed, denied, loading, }: CanAccessProps<TRecord>): ReactElement | null;
59
178
 
60
179
  /**
61
180
  * useAppDispatch Hook - Type-safe dispatch hook
@@ -225,12 +344,108 @@ declare function useFormatters(): UseFormattersReturn;
225
344
  */
226
345
  declare function useTheme(): UseThemeReturn;
227
346
 
347
+ /**
348
+ * useApiSuspenseQuery - Suspense declarative data fetching hook
349
+ *
350
+ * Mirrors useApiQuery but integrates with React Suspense so the initial load is
351
+ * handled by a Suspense boundary.
352
+ */
353
+
354
+ declare function useApiSuspenseQuery<TData = unknown, TError = Error>(descriptor: EndpointDescriptor<TData>, overrides?: ApiQueryOverrides): ApiSuspenseQueryResult<TData, TError>;
355
+
356
+ /**
357
+ * useApiSuspenseInfiniteQuery - Suspense paginated data fetching hook
358
+ *
359
+ * Mirrors useApiInfiniteQuery but integrates with React Suspense so the initial
360
+ * page load is handled by a Suspense boundary while pagination stays
361
+ * descriptor-driven.
362
+ */
363
+
364
+ declare function useApiSuspenseInfiniteQuery<TPage = unknown, TError = Error>(options: ApiInfiniteQueryOptions<TPage>): ApiSuspenseInfiniteQueryResult<TPage, TError>;
365
+
366
+ /**
367
+ * useApiStream - Declarative SSE streaming hook
368
+ *
369
+ * Accepts a StreamDescriptor from @gears-frontx/api and manages the EventSource
370
+ * lifecycle: connects on mount, disconnects on unmount/descriptor change.
371
+ * Returns the latest event, accumulated events, connection status, and
372
+ * a manual disconnect function.
373
+ *
374
+ * @example
375
+ * ```tsx
376
+ * const { data, events, status, error } = useApiStream(
377
+ * service.messageStream,
378
+ * { mode: 'latest' } // default — data holds last event
379
+ * );
380
+ *
381
+ * // Accumulate all events
382
+ * const { events, status } = useApiStream(service.messageStream, { mode: 'accumulate' });
383
+ * ```
384
+ */
385
+
386
+ /** Configuration options for useApiStream. */
387
+ interface ApiStreamOptions {
388
+ /**
389
+ * `'latest'` (default) — `data` holds the most recent event.
390
+ * `'accumulate'` — `events` holds all received events in order.
391
+ */
392
+ mode?: 'latest' | 'accumulate';
393
+ /** When false the connection is deferred (no connect on mount). Default true. */
394
+ enabled?: boolean;
395
+ }
396
+ /** Return type of useApiStream. */
397
+ interface ApiStreamResult<TEvent> {
398
+ /** Latest event payload (always set in both modes). */
399
+ data: TEvent | undefined;
400
+ /** All received events when `mode: 'accumulate'`; empty array in `'latest'` mode. */
401
+ events: TEvent[];
402
+ /** Connection lifecycle status. */
403
+ status: StreamStatus;
404
+ /** Error if the connection failed. */
405
+ error: Error | null;
406
+ /** Manually close the connection. */
407
+ disconnect: () => void;
408
+ }
409
+ declare function useApiStream<TEvent>(descriptor: StreamDescriptor<TEvent>, options?: ApiStreamOptions): ApiStreamResult<TEvent>;
410
+
411
+ /**
412
+ * Exposes the sanctioned imperative cache API for app and MFE code without
413
+ * leaking the raw QueryClient.
414
+ *
415
+ * Preferred usage:
416
+ * - useApiQuery() for declarative reads
417
+ * - useApiMutation() for writes
418
+ * - useQueryCache() for controlled imperative cache inspection and invalidation
419
+ */
420
+ declare function useQueryCache(): QueryCache;
421
+
422
+ /**
423
+ * Declarative RBAC guard hook.
424
+ *
425
+ * Pessimistic: `allow` is false until an explicit 'allow' decision arrives.
426
+ * Aborts the in-flight canAccess call on unmount and on query change.
427
+ *
428
+ * State machine:
429
+ * mount -> Pending (allow=false, isResolving=true)
430
+ * Pending -> 'allow' -> Allowed (allow=true, isResolving=false)
431
+ * Pending -> 'deny' -> Denied (allow=false, isResolving=false)
432
+ * Pending -> error -> Denied (allow=false, isResolving=false)
433
+ * Allowed -> query-change -> Pending (re-pessimize)
434
+ * Denied -> query-change -> Pending (re-pessimize)
435
+ */
436
+ declare function useCanAccess<TRecord extends AccessRecord = AccessRecord>(query: AccessQuery<TRecord>): UseCanAccessResult;
437
+
228
438
  /**
229
439
  * MFE Provider - Provides MFE context to child components
230
440
  *
231
441
  * Wraps MFE components with bridge and metadata.
232
442
  * Used by the MFE mounting system.
233
443
  *
444
+ * MfeProvider does not create or own the shared QueryClient. When the host uses
445
+ * queryCache() and the child app uses queryCacheShared(), overlapping queries
446
+ * (same query key) are deduplicated and cached once across MFE boundaries.
447
+ * Each MFE still uses its own apiRegistry and service instances in queryFn.
448
+ *
234
449
  * React Layer: L3 (Depends on @gears-frontx/framework)
235
450
  */
236
451
 
@@ -364,7 +579,7 @@ declare function useHostAction<TPayload extends Record<string, unknown> = Record
364
579
  /**
365
580
  * Hook for observing extensions registered for a domain.
366
581
  *
367
- * Subscribes to the HAI3 store to detect registration state changes,
582
+ * Subscribes to the FrontX store to detect registration state changes,
368
583
  * and returns the current list of extensions for the specified domain.
369
584
  *
370
585
  * @param domainId - Domain ID to query extensions for
@@ -387,6 +602,51 @@ declare function useHostAction<TPayload extends Record<string, unknown> = Record
387
602
  */
388
603
  declare function useDomainExtensions(domainId: string): Extension[];
389
604
 
605
+ /**
606
+ * useMountedExtensions Hook - Mounted extension observation for any domain
607
+ *
608
+ * Domain-agnostic hook that returns the currently-mounted Extension instances
609
+ * for any registered domain, including multi-mount domains backed by
610
+ * ConcurrentMountStrategy.
611
+ *
612
+ * React Layer: L3
613
+ */
614
+
615
+ /**
616
+ * Hook for observing the currently-mounted extensions in any domain.
617
+ *
618
+ * Subscribes to the FrontX store to detect mount state changes, and returns
619
+ * the array of Extension instances currently mounted in the specified domain.
620
+ *
621
+ * Pairs with getMountedExtensions(domainId) on the registry and resolves each
622
+ * mounted extension ID to its Extension instance. IDs that have been unregistered
623
+ * concurrently (race against unregister) are filtered out.
624
+ *
625
+ * Returns a referentially stable array when the underlying ID list is unchanged.
626
+ *
627
+ * For multi-mount domains (ConcurrentMountStrategy), may return more than one entry.
628
+ * For single-mount domains (ExclusiveMountStrategy), the returned array has at most one entry.
629
+ *
630
+ * @param domainId - Domain ID to query mounted extensions for
631
+ * @returns Array of Extension instances currently mounted in the domain
632
+ *
633
+ * @example
634
+ * ```tsx
635
+ * function MountedWidgets() {
636
+ * const mounted = useMountedExtensions('gts.frontx.mfes.ext.domain.v1~frontx.screensets.layout.sidebar.v1');
637
+ *
638
+ * return (
639
+ * <ul>
640
+ * {mounted.map(ext => (
641
+ * <li key={ext.id}>{ext.id}</li>
642
+ * ))}
643
+ * </ul>
644
+ * );
645
+ * }
646
+ * ```
647
+ */
648
+ declare function useMountedExtensions(domainId: string): Extension[];
649
+
390
650
  /**
391
651
  * useRegisteredPackages Hook - Registered GTS packages subscription
392
652
  *
@@ -398,7 +658,7 @@ declare function useDomainExtensions(domainId: string): Extension[];
398
658
  /**
399
659
  * Hook for observing registered GTS packages.
400
660
  *
401
- * Subscribes to the HAI3 store to detect registration state changes,
661
+ * Subscribes to the FrontX store to detect registration state changes,
402
662
  * and returns the current list of GTS packages extracted from registered
403
663
  * extensions.
404
664
  *
@@ -406,7 +666,7 @@ declare function useDomainExtensions(domainId: string): Extension[];
406
666
  * This hook uses `useSyncExternalStore` with `app.store.subscribe`, which
407
667
  * fires on any Redux dispatch. Since `registerExtension()` dispatches to
408
668
  * the mfe store slice, the subscription WILL trigger when packages change.
409
- * The `getSnapshot` function calls `screensetsRegistry.getRegisteredPackages()`
669
+ * The `getSnapshot` function calls `mfeRegistry.getRegisteredPackages()`
410
670
  * which reads the private `packages` Map. This works because every package
411
671
  * map mutation (in registerExtension/unregisterExtension) is always
412
672
  * accompanied by a store dispatch in the same serializer callback.
@@ -434,74 +694,66 @@ declare function useDomainExtensions(domainId: string): Extension[];
434
694
  declare function useRegisteredPackages(): string[];
435
695
 
436
696
  /**
437
- * useActivePackage Hook - Active GTS package subscription
438
- *
439
- * Subscribes to store changes and returns the GTS package of the currently
440
- * mounted screen extension.
441
- *
442
- * React Layer: L3
443
- */
444
- /**
445
- * Hook for observing the active GTS package (the package of the currently
446
- * mounted screen extension).
447
- *
448
- * Subscribes to the HAI3 store to detect mount state changes, and returns
449
- * the GTS package extracted from the currently mounted screen extension's ID.
450
- *
451
- * Returns `undefined` if no screen extension is currently mounted.
452
- *
453
- * @returns GTS package string of the active screen extension, or undefined
454
- *
455
- * @example
456
- * ```tsx
457
- * function ActivePackageIndicator() {
458
- * const activePackage = useActivePackage();
459
- *
460
- * if (!activePackage) {
461
- * return <div>No active screen</div>;
462
- * }
463
- *
464
- * return <div>Active package: {activePackage}</div>;
465
- * }
466
- * ```
467
- */
468
- declare function useActivePackage(): string | undefined;
469
-
470
- /**
471
- * Ref Container Provider
697
+ * Abstract base class for React-based MFE lifecycle implementations.
472
698
  *
473
- * Concrete ContainerProvider that wraps a React ref.
474
- * Created by React components (like ExtensionDomainSlot) for use
475
- * by framework-level domain registration code.
699
+ * Styling strategy:
700
+ * 1. adoptHostStylesIntoShadowRoot() clones all host <style> and <link> into the
701
+ * shadow root, bringing the full compiled Tailwind CSS (including MFE utilities,
702
+ * since the host's content paths cover src/mfe_packages/**).
703
+ * 2. injectBaseResets() adds box-model resets and :host defaults that aren't part
704
+ * of Tailwind's compiled output but are needed for consistent rendering.
705
+ * 3. Subclasses may override initializeStyles() to inject additional CSS that is
706
+ * not covered by the host stylesheet (e.g., MFE-specific @font-face rules).
476
707
  *
477
- * @packageDocumentation
478
- */
479
-
480
- /**
481
- * Concrete ContainerProvider that wraps a React ref.
708
+ * Theme CSS variables are delivered via CSS inheritance from :root (Shadow DOM)
709
+ * or via MountManager injection (iframe). MFE lifecycles do NOT need to subscribe
710
+ * to theme changes or call applyThemeToShadowRoot.
482
711
  *
483
- * This provider reads the container element from a React ref at mount time.
484
- * It is designed to be created by React components but passed to domain
485
- * registration code (framework-level).
486
- *
487
- * Usage pattern:
488
- * 1. React component creates a ref via `useRef<HTMLDivElement>(null)`
489
- * 2. Framework-level code creates `RefContainerProvider` wrapping the ref
490
- * 3. Framework-level code passes the provider to `registerDomain(domain, provider)`
491
- * 4. When mount_ext is dispatched, the provider returns `ref.current`
712
+ * Concrete subclasses must provide:
713
+ * - `renderContent(bridge)` - screen component rendering
492
714
  */
493
- declare class RefContainerProvider extends ContainerProvider {
494
- private readonly containerRef;
495
- constructor(containerRef: RefObject<HTMLDivElement>);
496
- getContainer(_extensionId: string): Element;
497
- releaseContainer(_extensionId: string): void;
715
+ declare abstract class ThemeAwareReactLifecycle implements MfeEntryLifecycle<ChildMfeBridge> {
716
+ private readonly app;
717
+ private root;
718
+ constructor(app: FrontXApp);
719
+ mount(container: Element | ShadowRoot, bridge: ChildMfeBridge, mountContext?: MfeMountContext): void;
720
+ unmount(_container: Element | ShadowRoot): void;
721
+ /**
722
+ * Copy all inline <style> and <link rel="stylesheet"> from the host document
723
+ * into the shadow root so that Tailwind and component styles apply inside the MFE.
724
+ */
725
+ protected adoptHostStylesIntoShadowRoot(shadowRoot: ShadowRoot): void;
726
+ /**
727
+ * Box-model resets and :host defaults needed inside every shadow root.
728
+ * These aren't part of Tailwind's compiled output but are required for
729
+ * consistent rendering across browsers.
730
+ */
731
+ private injectBaseResets;
732
+ /**
733
+ * Hook for subclasses to inject additional CSS not covered by the adopted host
734
+ * stylesheet (e.g., MFE-specific @font-face rules or custom animations).
735
+ * No-op by default: host styles adopted in adoptHostStylesIntoShadowRoot()
736
+ * already include all Tailwind utilities compiled from MFE source files.
737
+ */
738
+ protected initializeStyles(_container: Element | ShadowRoot): void;
739
+ /**
740
+ * Return the screen-specific React component tree.
741
+ */
742
+ protected abstract renderContent(bridge: ChildMfeBridge): React__default.ReactNode;
498
743
  }
499
744
 
500
745
  /**
501
746
  * Extension Domain Slot Component
502
747
  *
503
- * React component that renders extensions within a domain slot.
504
- * Manages extension lifecycle (mount/unmount) and provides rendering context.
748
+ * Per-domain React component that provides the DOM root for a registered domain.
749
+ * Delegates root attachment to the per-domain ExtensionMounter obtained from the
750
+ * registry. What extensions live inside the root is a domain-policy concern (the
751
+ * active MountStrategy plus the domain implementation's ContainerHooks), not a
752
+ * slot-API concern.
753
+ *
754
+ * The slot is uniform across all cardinalities (Exclusive / Optional / Concurrent).
755
+ * Mount and unmount actions are dispatched by the host application via
756
+ * registry.executeActionsChain — NOT by this component.
505
757
  *
506
758
  * @packageDocumentation
507
759
  */
@@ -511,57 +763,47 @@ declare class RefContainerProvider extends ContainerProvider {
511
763
  */
512
764
  interface ExtensionDomainSlotProps {
513
765
  /**
514
- * The screensets registry instance
766
+ * The screensets registry instance.
515
767
  */
516
- registry: ScreensetsRegistry;
768
+ registry: MfeRegistry;
517
769
  /**
518
- * The domain ID for this slot
770
+ * The domain ID for this slot.
519
771
  */
520
772
  domainId: string;
521
773
  /**
522
- * The extension ID to render in this slot
523
- */
524
- extensionId: string;
525
- /**
526
- * Optional CSS class name for the container
774
+ * Optional CSS class name for the root container div.
527
775
  */
528
776
  className?: string;
529
777
  /**
530
- * Optional callback when extension is mounted
778
+ * Optional callback invoked after mounter.attach(element) returns.
779
+ * Receives the root element that was attached.
531
780
  */
532
- onMounted?: (bridge: ParentMfeBridge) => void;
781
+ onAttached?: (root: Element) => void;
533
782
  /**
534
- * Optional callback when extension is unmounted
783
+ * Optional callback invoked after mounter.detach() returns on cleanup.
535
784
  */
536
- onUnmounted?: () => void;
785
+ onDetached?: () => void;
537
786
  /**
538
- * Optional error callback
539
- */
540
- onError?: (error: Error) => void;
541
- /**
542
- * Optional loading component
787
+ * Optional loading placeholder rendered before the mounter has been attached.
788
+ * Defaults to null (no visual placeholder).
543
789
  */
544
790
  loadingComponent?: React__default.ReactNode;
545
- /**
546
- * Optional error component renderer
547
- */
548
- errorComponent?: (error: Error) => React__default.ReactNode;
549
791
  }
550
792
  /**
551
793
  * Extension Domain Slot Component
552
794
  *
553
- * Renders an extension within a domain slot. Manages the extension lifecycle:
554
- * - Mounts the extension on component mount
555
- * - Unmounts the extension on component unmount
556
- * - Handles loading and error states
795
+ * Renders a single root `<div>` per domain instance. On ref-attach, resolves the
796
+ * per-domain mounter via registry.getMounter(domainId) and calls mounter.attach(element).
797
+ * On cleanup, calls mounter.detach() which mass-unmounts every currently-mounted
798
+ * extension in the domain so no orphan DOM trees or slice/registry desync remain.
557
799
  *
558
800
  * @example
559
801
  * ```tsx
560
802
  * <ExtensionDomainSlot
561
803
  * registry={registry}
562
- * domainId="gts.frontx.mfes.ext.domain.v1~frontx.screensets.layout.sidebar.v1"
563
- * extensionId="gts.frontx.mfes.ext.extension.v1~myapp.sidebar.widget.v1"
564
- * className="sidebar-slot"
804
+ * domainId={FRONTX_SCREEN_DOMAIN}
805
+ * loadingComponent={<Loading />}
806
+ * onAttached={(root) => console.log('Root attached:', root)}
565
807
  * />
566
808
  * ```
567
809
  */
@@ -571,7 +813,7 @@ declare function ExtensionDomainSlot(props: ExtensionDomainSlotProps): React__de
571
813
  * @gears-frontx/react - React Bindings
572
814
  *
573
815
  * This package provides:
574
- * - HAI3Provider context provider
816
+ * - FrontXProvider context provider
575
817
  * - Type-safe hooks for state and actions
576
818
  * - MFE context, hooks, and components
577
819
  *
@@ -587,4 +829,4 @@ interface EventPayloadMap extends EventPayloadMap$1 {
587
829
  */
588
830
  declare const eventBus: EventBus<EventPayloadMap>;
589
831
 
590
- export { type EventPayloadMap, ExtensionDomainSlot, type ExtensionDomainSlotProps, HAI3Context, HAI3Provider, HAI3ProviderProps, MfeContextValue, MfeProvider, type MfeProviderProps, RefContainerProvider, UseFormattersReturn, UseScreenTranslationsReturn, UseThemeReturn, UseTranslationReturn, eventBus, useActivePackage, useAppDispatch, useAppSelector, useDomainExtensions, useFormatters, useHAI3, useHostAction, useMfeBridge, useRegisteredPackages, useScreenTranslations, useSharedProperty, useTheme, useTranslation };
832
+ export { type ApiInfiniteQueryOptions, type ApiInfiniteQueryPageContext, ApiInfiniteQueryResult, ApiMutationResult, type ApiQueryOverrides, ApiQueryResult, type ApiStreamOptions, type ApiStreamResult, ApiSuspenseInfiniteQueryResult, ApiSuspenseQueryResult, CanAccess, CanAccessProps, type EventPayloadMap, ExtensionDomainSlot, type ExtensionDomainSlotProps, FrontXContext, FrontXProvider, FrontXProviderProps, MfeContextValue, MfeProvider, type MfeProviderProps, MutationCallbackContext, QueryCache, ThemeAwareReactLifecycle, type UseApiMutationOptions, UseCanAccessResult, UseFormattersReturn, UseScreenTranslationsReturn, UseThemeReturn, UseTranslationReturn, eventBus, useApiInfiniteQuery, useApiMutation, useApiQuery, useApiStream, useApiSuspenseInfiniteQuery, useApiSuspenseQuery, useAppDispatch, useAppSelector, useCanAccess, useDomainExtensions, useFormatters, useFrontX, useHostAction, useMfeBridge, useMountedExtensions, useQueryCache, useRegisteredPackages, useScreenTranslations, useSharedProperty, useTheme, useTranslation };