@gears-frontx/react 0.1.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.cts 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.cjs';
4
- export { d as MfeContext, e as UseAppDispatchReturn, f as UseAppSelector, g as UseHAI3Return, u as useMfeContext } from './types-Cp8Zm5s0.cjs';
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-.cjs';
4
+ export { i as MfeContext, j as UseAppDispatchReturn, k as UseAppSelector, l as UseFrontXReturn, u as useMfeContext } from './types-Cjd20AT-.cjs';
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.cjs';
8
+ export { a as QueryCacheInvalidateFilters, b as QueryCacheState, i as invalidateQueryCacheForApp } from './testing-Dlmfu6tE.cjs';
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.
55
164
  *
56
- * @returns The HAI3 app instance
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.
168
+ *
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,165 @@ 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 returns the latest
370
+ * event, accumulated events, connection status, and a manual disconnect
371
+ * function.
372
+ *
373
+ * @example
374
+ * ```tsx
375
+ * const { data, events, status, error } = useApiStream(
376
+ * service.messageStream,
377
+ * { mode: 'latest' } // default — data holds last event
378
+ * );
379
+ *
380
+ * // Accumulate all events
381
+ * const { events, status } = useApiStream(service.messageStream, { mode: 'accumulate' });
382
+ * ```
383
+ */
384
+
385
+ /** Configuration options for useApiStream. */
386
+ interface ApiStreamOptions {
387
+ /**
388
+ * `'latest'` (default) — `data` holds the most recent event.
389
+ * `'accumulate'` — `events` holds all received events in order.
390
+ */
391
+ mode?: 'latest' | 'accumulate';
392
+ /** When false the connection is deferred (no connect on mount). Default true. */
393
+ enabled?: boolean;
394
+ }
395
+ /** Return type of useApiStream. */
396
+ interface ApiStreamResult<TEvent> {
397
+ /** Latest event payload, set in both modes — `undefined` until the first event and after each connect attempt resets it. */
398
+ data: TEvent | undefined;
399
+ /** All received events when `mode: 'accumulate'`; empty array in `'latest'` mode. */
400
+ events: TEvent[];
401
+ /** Connection lifecycle status. */
402
+ status: StreamStatus;
403
+ /** Last connect error — set when a connect attempt rejects, cleared when the next attempt starts. */
404
+ error: Error | null;
405
+ /** Manually close the connection. */
406
+ disconnect: () => void;
407
+ }
408
+ /**
409
+ * Manages the status lifecycle for a single SSE stream connection.
410
+ *
411
+ * **Status values**
412
+ * - `'idle'` — no connection is being attempted. This is the initial status
413
+ * before the first connect effect runs, and it is ordinarily the status
414
+ * while `enabled` is `false`. Consumers must not assume `'idle'` means "never
415
+ * connected" — a stream that is disabled after having connected returns to
416
+ * `'idle'` too, and `data`/`events` from the earlier connection are not
417
+ * cleared by that transition alone (they are cleared by mode/key changes,
418
+ * see below).
419
+ * - `'connecting'` — `descriptor.connect()` has been called and its promise
420
+ * has not yet settled.
421
+ * - `'connected'` — set both when `connect()` resolves (unless a disconnect
422
+ * was requested while it was pending) and, independently, whenever the
423
+ * `onEvent` callback delivers a new event. Because every event re-asserts
424
+ * `'connected'`, this status also serves as "still receiving events."
425
+ * - `'disconnected'` — reached via any of: the descriptor's `onComplete`
426
+ * callback firing (the stream ended normally), `connect()` rejecting while
427
+ * a disconnect was requested concurrently, or the manual `disconnect()`
428
+ * function being called. `disconnect()` has no `enabled` guard: called
429
+ * while the stream is disabled it still sets `'disconnected'`, which
430
+ * persists until the next connect-effect run.
431
+ * - `'error'` — `connect()` rejected and no disconnect was requested while it
432
+ * was pending. `error` holds the rejection, coerced to an `Error` if it
433
+ * wasn't one already.
434
+ *
435
+ * **Transitions**
436
+ * - Mount / `enabled` becomes `true` / `descriptor.key` or `mode` changes:
437
+ * `data`, `events`, and `error` are reset, then status goes to
438
+ * `'connecting'` and `connect()` is called.
439
+ * - `enabled` becomes `false` (or starts `false`): status is forced to
440
+ * `'idle'` and `connect()` is never called; no other field is reset by
441
+ * this transition alone.
442
+ * - Unmount, `descriptor.key` change, `mode` change, or `enabled` flipping to
443
+ * `false` while connected or connecting: the previous connection is torn
444
+ * down via `descriptor.disconnect()` once its `connect()` promise settles
445
+ * (or immediately skipped if it rejected). All four share the same cleanup
446
+ * path: the effect's cleanup runs on every dependency change and on unmount.
447
+ * - Calling `disconnect()`: if a connection id is already resolved, it is
448
+ * disconnected immediately and status becomes `'disconnected'`. If
449
+ * `connect()` is still pending, the request is recorded and honored when
450
+ * the promise settles — the newly resolved connection is torn down instead
451
+ * of being adopted, and status is `'disconnected'`. One caveat:
452
+ * `disconnect()` does not cancel the event callback, so a buffered or
453
+ * in-flight event landing after the call re-asserts `'connected'` — and in
454
+ * the pending-connect case the settle handler tears the connection down
455
+ * without touching status, so that stray `'connected'` persists.
456
+ * - Stream completion while `connect()` is still pending: the current
457
+ * implementation lets `onComplete` set `'disconnected'`, then the settle
458
+ * handler adopts the connection id and re-asserts `'connected'` anyway.
459
+ * This is known current behavior, not a durable guarantee: a pending
460
+ * upstream derived-status rewrite is expected to remove this transition.
461
+ *
462
+ * `enabled` (default `true`) is the only way to defer connecting past mount;
463
+ * flipping it back to `true` re-runs the same connect sequence as a fresh
464
+ * mount would.
465
+ */
466
+ declare function useApiStream<TEvent>(descriptor: StreamDescriptor<TEvent>, options?: ApiStreamOptions): ApiStreamResult<TEvent>;
467
+
468
+ /**
469
+ * Exposes the sanctioned imperative cache API for app and MFE code without
470
+ * leaking the raw QueryClient.
471
+ *
472
+ * Preferred usage:
473
+ * - useApiQuery() for declarative reads
474
+ * - useApiMutation() for writes
475
+ * - useQueryCache() for controlled imperative cache inspection and invalidation
476
+ */
477
+ declare function useQueryCache(): QueryCache;
478
+
479
+ /**
480
+ * Declarative RBAC guard hook.
481
+ *
482
+ * Pessimistic: `allow` is false until an explicit 'allow' decision arrives.
483
+ * Aborts the in-flight canAccess call on unmount and on query change.
484
+ *
485
+ * State machine:
486
+ * mount -> Pending (allow=false, isResolving=true)
487
+ * Pending -> 'allow' -> Allowed (allow=true, isResolving=false)
488
+ * Pending -> 'deny' -> Denied (allow=false, isResolving=false)
489
+ * Pending -> error -> Denied (allow=false, isResolving=false)
490
+ * Allowed -> query-change -> Pending (re-pessimize)
491
+ * Denied -> query-change -> Pending (re-pessimize)
492
+ */
493
+ declare function useCanAccess<TRecord extends AccessRecord = AccessRecord>(query: AccessQuery<TRecord>): UseCanAccessResult;
494
+
228
495
  /**
229
496
  * MFE Provider - Provides MFE context to child components
230
497
  *
231
498
  * Wraps MFE components with bridge and metadata.
232
499
  * Used by the MFE mounting system.
233
500
  *
501
+ * MfeProvider does not create or own the shared QueryClient. When the host uses
502
+ * queryCache() and the child app uses queryCacheShared(), overlapping queries
503
+ * (same query key) are deduplicated and cached once across MFE boundaries.
504
+ * Each MFE still uses its own apiRegistry and service instances in queryFn.
505
+ *
234
506
  * React Layer: L3 (Depends on @gears-frontx/framework)
235
507
  */
236
508
 
@@ -283,7 +555,7 @@ declare const MfeProvider: React__default.FC<MfeProviderProps>;
283
555
  * // bridge.executeActionsChain(chain);
284
556
  * // bridge.subscribeToProperty(propertyTypeId, callback);
285
557
  *
286
- * return <div>Domain: {bridge.domainId}</div>;
558
+ * return <div>Domain: {bridge.extDomainId}</div>;
287
559
  * }
288
560
  * ```
289
561
  */
@@ -364,7 +636,7 @@ declare function useHostAction<TPayload extends Record<string, unknown> = Record
364
636
  /**
365
637
  * Hook for observing extensions registered for a domain.
366
638
  *
367
- * Subscribes to the HAI3 store to detect registration state changes,
639
+ * Subscribes to the FrontX store to detect registration state changes,
368
640
  * and returns the current list of extensions for the specified domain.
369
641
  *
370
642
  * @param domainId - Domain ID to query extensions for
@@ -387,6 +659,51 @@ declare function useHostAction<TPayload extends Record<string, unknown> = Record
387
659
  */
388
660
  declare function useDomainExtensions(domainId: string): Extension[];
389
661
 
662
+ /**
663
+ * useMountedExtensions Hook - Mounted extension observation for any domain
664
+ *
665
+ * Domain-agnostic hook that returns the currently-mounted Extension instances
666
+ * for any registered domain, including multi-mount domains backed by
667
+ * ConcurrentMountStrategy.
668
+ *
669
+ * React Layer: L3
670
+ */
671
+
672
+ /**
673
+ * Hook for observing the currently-mounted extensions in any domain.
674
+ *
675
+ * Subscribes to the FrontX store to detect mount state changes, and returns
676
+ * the array of Extension instances currently mounted in the specified domain.
677
+ *
678
+ * Pairs with getMountedExtensions(domainId) on the registry and resolves each
679
+ * mounted extension ID to its Extension instance. IDs that have been unregistered
680
+ * concurrently (race against unregister) are filtered out.
681
+ *
682
+ * Returns a referentially stable array when the underlying ID list is unchanged.
683
+ *
684
+ * For multi-mount domains (ConcurrentMountStrategy), may return more than one entry.
685
+ * For single-mount domains (ExclusiveMountStrategy), the returned array has at most one entry.
686
+ *
687
+ * @param domainId - Domain ID to query mounted extensions for
688
+ * @returns Array of Extension instances currently mounted in the domain
689
+ *
690
+ * @example
691
+ * ```tsx
692
+ * function MountedWidgets() {
693
+ * const mounted = useMountedExtensions('gts.frontx.mfes.ext.domain.v1~frontx.screensets.layout.sidebar.v1');
694
+ *
695
+ * return (
696
+ * <ul>
697
+ * {mounted.map(ext => (
698
+ * <li key={ext.id}>{ext.id}</li>
699
+ * ))}
700
+ * </ul>
701
+ * );
702
+ * }
703
+ * ```
704
+ */
705
+ declare function useMountedExtensions(domainId: string): Extension[];
706
+
390
707
  /**
391
708
  * useRegisteredPackages Hook - Registered GTS packages subscription
392
709
  *
@@ -398,7 +715,7 @@ declare function useDomainExtensions(domainId: string): Extension[];
398
715
  /**
399
716
  * Hook for observing registered GTS packages.
400
717
  *
401
- * Subscribes to the HAI3 store to detect registration state changes,
718
+ * Subscribes to the FrontX store to detect registration state changes,
402
719
  * and returns the current list of GTS packages extracted from registered
403
720
  * extensions.
404
721
  *
@@ -406,7 +723,7 @@ declare function useDomainExtensions(domainId: string): Extension[];
406
723
  * This hook uses `useSyncExternalStore` with `app.store.subscribe`, which
407
724
  * fires on any Redux dispatch. Since `registerExtension()` dispatches to
408
725
  * the mfe store slice, the subscription WILL trigger when packages change.
409
- * The `getSnapshot` function calls `screensetsRegistry.getRegisteredPackages()`
726
+ * The `getSnapshot` function calls `mfeRegistry.getRegisteredPackages()`
410
727
  * which reads the private `packages` Map. This works because every package
411
728
  * map mutation (in registerExtension/unregisterExtension) is always
412
729
  * accompanied by a store dispatch in the same serializer callback.
@@ -434,74 +751,66 @@ declare function useDomainExtensions(domainId: string): Extension[];
434
751
  declare function useRegisteredPackages(): string[];
435
752
 
436
753
  /**
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
472
- *
473
- * Concrete ContainerProvider that wraps a React ref.
474
- * Created by React components (like ExtensionDomainSlot) for use
475
- * by framework-level domain registration code.
754
+ * Abstract base class for React-based MFE lifecycle implementations.
476
755
  *
477
- * @packageDocumentation
478
- */
479
-
480
- /**
481
- * Concrete ContainerProvider that wraps a React ref.
756
+ * Styling strategy:
757
+ * 1. adoptHostStylesIntoShadowRoot() clones all host <style> and <link> into the
758
+ * shadow root, bringing the full compiled Tailwind CSS (including MFE utilities,
759
+ * since the host's content paths cover src/mfe_packages/**).
760
+ * 2. injectBaseResets() adds box-model resets and :host defaults that aren't part
761
+ * of Tailwind's compiled output but are needed for consistent rendering.
762
+ * 3. Subclasses may override initializeStyles() to inject additional CSS that is
763
+ * not covered by the host stylesheet (e.g., MFE-specific @font-face rules).
482
764
  *
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).
765
+ * Theme CSS variables are delivered via CSS inheritance from :root (Shadow DOM)
766
+ * or via MountManager injection (iframe). MFE lifecycles do NOT need to subscribe
767
+ * to theme changes or call applyThemeToShadowRoot.
486
768
  *
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`
769
+ * Concrete subclasses must provide:
770
+ * - `renderContent(bridge)` - screen component rendering
492
771
  */
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;
772
+ declare abstract class ThemeAwareReactLifecycle implements MfeEntryLifecycle<ChildMfeBridge> {
773
+ private readonly app;
774
+ private root;
775
+ constructor(app: FrontXApp);
776
+ mount(container: Element | ShadowRoot, bridge: ChildMfeBridge, mountContext?: MfeMountContext): void;
777
+ unmount(_container: Element | ShadowRoot): void;
778
+ /**
779
+ * Copy all inline <style> and <link rel="stylesheet"> from the host document
780
+ * into the shadow root so that Tailwind and component styles apply inside the MFE.
781
+ */
782
+ protected adoptHostStylesIntoShadowRoot(shadowRoot: ShadowRoot): void;
783
+ /**
784
+ * Box-model resets and :host defaults needed inside every shadow root.
785
+ * These aren't part of Tailwind's compiled output but are required for
786
+ * consistent rendering across browsers.
787
+ */
788
+ private injectBaseResets;
789
+ /**
790
+ * Hook for subclasses to inject additional CSS not covered by the adopted host
791
+ * stylesheet (e.g., MFE-specific @font-face rules or custom animations).
792
+ * No-op by default: host styles adopted in adoptHostStylesIntoShadowRoot()
793
+ * already include all Tailwind utilities compiled from MFE source files.
794
+ */
795
+ protected initializeStyles(_container: Element | ShadowRoot): void;
796
+ /**
797
+ * Return the screen-specific React component tree.
798
+ */
799
+ protected abstract renderContent(bridge: ChildMfeBridge): React__default.ReactNode;
498
800
  }
499
801
 
500
802
  /**
501
803
  * Extension Domain Slot Component
502
804
  *
503
- * React component that renders extensions within a domain slot.
504
- * Manages extension lifecycle (mount/unmount) and provides rendering context.
805
+ * Per-domain React component that provides the DOM root for a registered domain.
806
+ * Delegates root attachment to the per-domain ExtensionMounter obtained from the
807
+ * registry. What extensions live inside the root is a domain-policy concern (the
808
+ * active MountStrategy plus the domain implementation's ContainerHooks), not a
809
+ * slot-API concern.
810
+ *
811
+ * The slot is uniform across all cardinalities (Exclusive / Optional / Concurrent).
812
+ * Mount and unmount actions are dispatched by the host application via
813
+ * registry.executeActionsChain — NOT by this component.
505
814
  *
506
815
  * @packageDocumentation
507
816
  */
@@ -511,57 +820,47 @@ declare class RefContainerProvider extends ContainerProvider {
511
820
  */
512
821
  interface ExtensionDomainSlotProps {
513
822
  /**
514
- * The screensets registry instance
823
+ * The screensets registry instance.
515
824
  */
516
- registry: ScreensetsRegistry;
825
+ registry: MfeRegistry;
517
826
  /**
518
- * The domain ID for this slot
827
+ * The domain ID for this slot.
519
828
  */
520
829
  domainId: string;
521
830
  /**
522
- * The extension ID to render in this slot
523
- */
524
- extensionId: string;
525
- /**
526
- * Optional CSS class name for the container
831
+ * Optional CSS class name for the root container div.
527
832
  */
528
833
  className?: string;
529
834
  /**
530
- * Optional callback when extension is mounted
835
+ * Optional callback invoked after mounter.attach(element) returns.
836
+ * Receives the root element that was attached.
531
837
  */
532
- onMounted?: (bridge: ParentMfeBridge) => void;
838
+ onAttached?: (root: Element) => void;
533
839
  /**
534
- * Optional callback when extension is unmounted
840
+ * Optional callback invoked after mounter.detach() returns on cleanup.
535
841
  */
536
- onUnmounted?: () => void;
842
+ onDetached?: () => void;
537
843
  /**
538
- * Optional error callback
539
- */
540
- onError?: (error: Error) => void;
541
- /**
542
- * Optional loading component
844
+ * Optional loading placeholder rendered before the mounter has been attached.
845
+ * Defaults to null (no visual placeholder).
543
846
  */
544
847
  loadingComponent?: React__default.ReactNode;
545
- /**
546
- * Optional error component renderer
547
- */
548
- errorComponent?: (error: Error) => React__default.ReactNode;
549
848
  }
550
849
  /**
551
850
  * Extension Domain Slot Component
552
851
  *
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
852
+ * Renders a single root `<div>` per domain instance. On ref-attach, resolves the
853
+ * per-domain mounter via registry.getMounter(domainId) and calls mounter.attach(element).
854
+ * On cleanup, calls mounter.detach() which mass-unmounts every currently-mounted
855
+ * extension in the domain so no orphan DOM trees or slice/registry desync remain.
557
856
  *
558
857
  * @example
559
858
  * ```tsx
560
859
  * <ExtensionDomainSlot
561
860
  * 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"
861
+ * domainId={FRONTX_SCREEN_DOMAIN}
862
+ * loadingComponent={<Loading />}
863
+ * onAttached={(root) => console.log('Root attached:', root)}
565
864
  * />
566
865
  * ```
567
866
  */
@@ -571,7 +870,7 @@ declare function ExtensionDomainSlot(props: ExtensionDomainSlotProps): React__de
571
870
  * @gears-frontx/react - React Bindings
572
871
  *
573
872
  * This package provides:
574
- * - HAI3Provider context provider
873
+ * - FrontXProvider context provider
575
874
  * - Type-safe hooks for state and actions
576
875
  * - MFE context, hooks, and components
577
876
  *
@@ -587,4 +886,4 @@ interface EventPayloadMap extends EventPayloadMap$1 {
587
886
  */
588
887
  declare const eventBus: EventBus<EventPayloadMap>;
589
888
 
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 };
889
+ 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 };