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

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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/HAI3Provider.tsx","../src/HAI3Context.tsx","../src/mfe/MfeContext.tsx","../src/mfe/MfeProvider.tsx","../src/hooks/useAppDispatch.ts","../src/hooks/useAppSelector.ts","../src/hooks/useTranslation.ts","../src/hooks/useScreenTranslations.ts","../src/hooks/useFormatters.ts","../src/hooks/useTheme.ts","../src/mfe/hooks/useMfeBridge.ts","../src/mfe/hooks/useSharedProperty.ts","../src/mfe/hooks/useHostAction.ts","../src/mfe/hooks/useDomainExtensions.ts","../src/mfe/hooks/useRegisteredPackages.ts","../src/mfe/hooks/useActivePackage.ts","../src/mfe/components/RefContainerProvider.ts","../src/mfe/components/ExtensionDomainSlot.tsx"],"sourcesContent":["/**\n * @gears-frontx/react - React Bindings\n *\n * This package provides:\n * - HAI3Provider context provider\n * - Type-safe hooks for state and actions\n * - MFE context, hooks, and components\n *\n * Layer: L3 (Depends on @gears-frontx/framework)\n */\n\n// ============================================================================\n// Provider\n// ============================================================================\n\nexport { HAI3Provider } from './HAI3Provider';\nexport { HAI3Context, useHAI3 } from './HAI3Context';\n\n// ============================================================================\n// Hooks\n// ============================================================================\n\nexport {\n useAppDispatch,\n useAppSelector,\n useTranslation,\n useScreenTranslations,\n useFormatters,\n useTheme,\n} from './hooks';\n\n// ============================================================================\n// MFE Context and Hooks\n// ============================================================================\n\nexport {\n MfeContext,\n useMfeContext,\n MfeProvider,\n useMfeBridge,\n useSharedProperty,\n useHostAction,\n useDomainExtensions,\n useRegisteredPackages,\n useActivePackage,\n RefContainerProvider,\n ExtensionDomainSlot,\n} from './mfe';\n\nexport type {\n MfeContextValue,\n MfeProviderProps,\n ExtensionDomainSlotProps,\n} from './mfe';\n\n// ============================================================================\n// Type Exports\n// ============================================================================\n\nexport type {\n HAI3ProviderProps,\n UseHAI3Return,\n UseAppSelector,\n UseAppDispatchReturn,\n UseTranslationReturn,\n UseScreenTranslationsReturn,\n UseFormattersReturn,\n UseThemeReturn,\n} from './types';\n\n// ============================================================================\n// Re-exports from @gears-frontx/framework for convenience\n// ============================================================================\n\n// These re-exports allow users to import everything from @gears-frontx/react\n// without needing to import from @gears-frontx/framework directly\n\nexport {\n // Core\n createHAI3,\n createHAI3App,\n presets,\n\n // Backward compatibility constants\n ACCOUNTS_DOMAIN,\n\n // I18nRegistry class (capital I for backward compat)\n I18nRegistry,\n\n // Plugins\n screensets,\n themes,\n layout,\n i18n,\n effects,\n\n // Registries\n createThemeRegistry,\n\n // Flux (Event bus + Store)\n // NOTE: eventBus is re-exported separately below with augmented EventPayloadMap type\n\n // Store\n createStore,\n getStore,\n registerSlice,\n hasSlice,\n createSlice,\n\n // Layout domain exports\n LayoutDomain,\n layoutReducer,\n layoutDomainReducers,\n LAYOUT_SLICE_NAME,\n headerSlice,\n footerSlice,\n menuSlice,\n sidebarSlice,\n screenSlice,\n popupSlice,\n overlaySlice,\n headerActions,\n footerActions,\n menuActions,\n sidebarActions,\n screenActions,\n popupActions,\n overlayActions,\n // Individual reducer functions - header\n setUser,\n setHeaderLoading,\n clearUser,\n // Individual reducer functions - footer\n setFooterVisible,\n setFooterConfig,\n toggleMenu,\n setMenuCollapsed,\n setMenuItems,\n setMenuVisible,\n setMenuConfig,\n toggleSidebar,\n setSidebarCollapsed,\n setSidebarPosition,\n setSidebarTitle,\n setSidebarContent,\n setSidebarVisible,\n setSidebarWidth,\n setSidebarConfig,\n setActiveScreen,\n setScreenLoading,\n navigateTo,\n clearActiveScreen,\n openPopup,\n closePopup,\n closeTopPopup,\n closeAllPopups,\n showOverlay,\n hideOverlay,\n setOverlayVisible,\n\n // Tenant (app-level, not layout)\n TENANT_SLICE_NAME,\n tenantSlice,\n tenantActions,\n tenantReducer,\n setTenant,\n setTenantLoading,\n clearTenant,\n // Tenant effects and events\n initTenantEffects,\n changeTenant,\n clearTenantAction,\n setTenantLoadingState,\n TenantEvents,\n\n // Mock (app-level, not layout)\n mockSlice,\n mockActions,\n setMockEnabled,\n // Mock effects and events\n initMockEffects,\n toggleMockMode,\n MockEvents,\n\n // API\n apiRegistry,\n BaseApiService,\n RestProtocol,\n SseProtocol,\n // Protocol-specific mock plugins (replaces generic MockPlugin)\n RestMockPlugin,\n SseMockPlugin,\n MockEventSource,\n // Plugin base classes\n ApiPluginBase,\n ApiPlugin,\n ApiProtocol,\n RestPlugin,\n RestPluginWithConfig,\n SsePlugin,\n SsePluginWithConfig,\n // Type guards\n isShortCircuit,\n isRestShortCircuit,\n isSseShortCircuit,\n // Mock plugin identification\n MOCK_PLUGIN,\n isMockPlugin,\n\n // I18n\n i18nRegistry,\n I18nRegistryImpl,\n createI18nRegistry,\n SUPPORTED_LANGUAGES,\n getLanguageMetadata,\n} from '@gears-frontx/framework';\n\n// Re-export i18n types from @gears-frontx/framework (correct layer access)\nexport { Language, TextDirection, LanguageDisplayMode } from '@gears-frontx/framework';\n\n// Re-export types from @gears-frontx/framework\nexport type {\n // Config\n HAI3Config,\n HAI3Plugin,\n HAI3AppBuilder,\n HAI3App,\n PluginFactory,\n PluginProvides,\n PluginLifecycle,\n ThemeRegistry,\n ThemeConfig,\n Preset,\n Presets,\n ScreensetsConfig,\n ShowPopupPayload,\n ChangeThemePayload,\n SetLanguagePayload,\n\n // Flux (Events + Store)\n EventHandler,\n Subscription,\n\n // Store\n RootState,\n AppDispatch,\n SliceObject,\n HAI3Store,\n ReducerPayload,\n\n // Layout\n LayoutDomainState,\n HeaderUser,\n HeaderConfig,\n HeaderState,\n FooterConfig,\n FooterState,\n MenuItem,\n MenuState,\n SidebarPosition,\n SidebarState,\n ScreenState,\n PopupConfig,\n PopupState,\n PopupSliceState,\n OverlayConfig,\n OverlayState,\n LayoutState,\n RootStateWithLayout,\n LayoutDomainReducers,\n\n // Tenant types\n Tenant,\n TenantState,\n TenantChangedPayload,\n TenantClearedPayload,\n\n // Mock types\n MockState,\n MockTogglePayload,\n\n // API\n MockMap,\n ApiServiceConfig,\n JsonValue,\n JsonObject,\n JsonPrimitive,\n JsonCompatible,\n SseProtocolConfig,\n RestProtocolConfig,\n // Plugin context types (class-based plugin system)\n ApiRequestContext,\n ApiResponseContext,\n ShortCircuitResponse,\n PluginClass,\n ProtocolClass,\n ProtocolPluginType,\n BasePluginHooks,\n // Protocol-specific types\n RestPluginHooks,\n SsePluginHooks,\n RestRequestContext,\n RestResponseContext,\n ApiPluginErrorContext,\n SseConnectContext,\n EventSourceLike,\n RestShortCircuitResponse,\n SseShortCircuitResponse,\n RestMockConfig,\n SseMockConfig,\n SseMockEvent,\n\n // I18n\n I18nConfig,\n TranslationLoader,\n TranslationMap,\n TranslationDictionary,\n LanguageMetadata,\n I18nRegistryType,\n} from '@gears-frontx/framework';\n\n// ============================================================================\n// MFE Re-exports from @gears-frontx/framework (Layering Compliance)\n// ============================================================================\n\n// MFE Plugin factories\nexport {\n microfrontends,\n mock,\n} from '@gears-frontx/framework';\n\n// MFE Action functions\nexport {\n loadExtension,\n mountExtension,\n unmountExtension,\n registerExtension,\n unregisterExtension,\n} from '@gears-frontx/framework';\n\n// MFE Selectors\nexport {\n selectExtensionState,\n selectRegisteredExtensions,\n selectExtensionError,\n} from '@gears-frontx/framework';\n\n// MFE Domain constants\nexport {\n FRONTX_POPUP_DOMAIN,\n FRONTX_SIDEBAR_DOMAIN,\n FRONTX_SCREEN_DOMAIN,\n FRONTX_OVERLAY_DOMAIN,\n // Base ExtensionDomain constants\n screenDomain,\n sidebarDomain,\n popupDomain,\n overlayDomain,\n} from '@gears-frontx/framework';\n\n// MFE Type constants\nexport {\n FRONTX_SCREEN_EXTENSION_TYPE,\n FRONTX_MFE_ENTRY_MF,\n} from '@gears-frontx/framework';\n\n// MFE Action constants\nexport {\n FRONTX_ACTION_LOAD_EXT,\n FRONTX_ACTION_MOUNT_EXT,\n FRONTX_ACTION_UNMOUNT_EXT,\n} from '@gears-frontx/framework';\n\n// MFE Shared Property constants\nexport {\n FRONTX_SHARED_PROPERTY_THEME,\n FRONTX_SHARED_PROPERTY_LANGUAGE,\n} from '@gears-frontx/framework';\n\n// MFE Types\nexport type {\n ChildMfeBridge,\n ParentMfeBridge,\n Extension,\n ScreenExtension,\n ExtensionPresentation,\n ExtensionDomain,\n ActionsChain,\n Action,\n SharedProperty,\n LifecycleStage,\n LifecycleHook,\n MfeEntryLifecycle,\n MfeEntry,\n MfeEntryMF,\n JSONSchema,\n ValidationError,\n ValidationResult,\n LoadExtPayload,\n MountExtPayload,\n UnmountExtPayload,\n ScreensetsRegistryConfig,\n TypeSystemPlugin,\n} from '@gears-frontx/framework';\n\n// MFE Abstract classes\nexport {\n MfeHandler,\n MfeBridgeFactory,\n ScreensetsRegistry,\n ScreensetsRegistryFactory,\n screensetsRegistryFactory,\n ContainerProvider,\n} from '@gears-frontx/framework';\n\n// MFE Concrete implementations\nexport { MfeHandlerMF, gtsPlugin } from '@gears-frontx/framework';\n\n// GTS Derived Schemas (application-layer registration)\nexport { themeSchema, languageSchema, extensionScreenSchema } from '@gears-frontx/framework';\n\n// MFE Utilities\nexport {\n createShadowRoot,\n injectCssVariables,\n extractGtsPackage,\n} from '@gears-frontx/framework';\n\n// MFE Plugin types\nexport type {\n MfeState,\n ExtensionRegistrationState,\n RegisterExtensionPayload,\n UnregisterExtensionPayload,\n} from '@gears-frontx/framework';\n\n// ============================================================================\n// Module Augmentation Support - EventPayloadMap Re-declaration\n// ============================================================================\n\n/**\n * Re-declare EventPayloadMap to enable module augmentation on @gears-frontx/react\n *\n * This creates a new declaration site in @gears-frontx/react that TypeScript can augment.\n * App-layer code can now use `declare module '@gears-frontx/react'` instead of importing\n * from L1 packages directly, maintaining proper layer architecture.\n *\n * ARCHITECTURE: This pattern allows L3+ code to augment event types without\n * violating layer boundaries by importing from L1 (@gears-frontx/state).\n *\n * IMPORTANT: We must also re-export eventBus with the augmented type to ensure\n * type safety. The eventBus instance uses this augmented EventPayloadMap.\n *\n * @example\n * ```typescript\n * // In app-layer code (e.g., src/app/events/bootstrapEvents.ts)\n * import '@gears-frontx/react';\n *\n * declare module '@gears-frontx/react' {\n * interface EventPayloadMap {\n * 'app/user/fetch': void;\n * 'app/user/loaded': { user: ApiUser };\n * }\n * }\n * ```\n */\nimport type { EventPayloadMap as FrameworkEventPayloadMap, EventBus } from '@gears-frontx/framework';\nimport { eventBus as frameworkEventBus } from '@gears-frontx/framework';\n\n// @cpt-dod:cpt-hai3-dod-react-bindings-event-payload-map:p2\n// @cpt-begin:cpt-hai3-dod-react-bindings-event-payload-map:p2:inst-event-payload-map\nexport interface EventPayloadMap extends FrameworkEventPayloadMap { }\n\n/**\n * Re-export eventBus with augmented EventPayloadMap type.\n * This ensures that code importing eventBus from @gears-frontx/react gets\n * type-safe access to both framework events and app-layer augmented events.\n */\nexport const eventBus: EventBus<EventPayloadMap> = frameworkEventBus as EventBus<EventPayloadMap>;\n// @cpt-end:cpt-hai3-dod-react-bindings-event-payload-map:p2:inst-event-payload-map\n","/**\n * HAI3 Provider - Main provider component for HAI3 applications\n *\n * React Layer: L3 (Depends on @gears-frontx/framework)\n */\n// @cpt-flow:cpt-hai3-flow-react-bindings-bootstrap-provider:p1\n// @cpt-algo:cpt-hai3-algo-react-bindings-resolve-app:p1\n// @cpt-algo:cpt-hai3-algo-react-bindings-build-provider-tree:p1\n// @cpt-dod:cpt-hai3-dod-react-bindings-provider:p1\n\nimport React, { useMemo, useEffect } from 'react';\nimport { Provider as ReduxProvider } from 'react-redux';\nimport { createHAI3App } from '@gears-frontx/framework';\nimport type { HAI3App } from '@gears-frontx/framework';\nimport { HAI3Context } from './HAI3Context';\nimport { MfeProvider } from './mfe/MfeProvider';\nimport type { HAI3ProviderProps } from './types';\n\n/**\n * HAI3 Provider Component\n *\n * Provides the HAI3 application context to all child components.\n * Creates the HAI3 app instance with the full preset by default.\n *\n * @example\n * ```tsx\n * // Default - creates app with full preset\n * <HAI3Provider>\n * <App />\n * </HAI3Provider>\n *\n * // With configuration\n * <HAI3Provider config={{ devMode: true }}>\n * <App />\n * </HAI3Provider>\n *\n * // With pre-built app\n * const app = createHAI3().use(screensets()).use(microfrontends()).build();\n * <HAI3Provider app={app}>\n * <App />\n * </HAI3Provider>\n *\n * // With MFE bridge (for MFE components)\n * <HAI3Provider mfeBridge={{ bridge, extensionId, domainId }}>\n * <MyMfeApp />\n * </HAI3Provider>\n * ```\n */\n// @cpt-begin:cpt-hai3-flow-react-bindings-bootstrap-provider:p1:inst-render-provider\n// @cpt-begin:cpt-hai3-dod-react-bindings-provider:p1:inst-render-provider\nexport const HAI3Provider: React.FC<HAI3ProviderProps> = ({\n children,\n config,\n app: providedApp,\n mfeBridge,\n}) => {\n // @cpt-begin:cpt-hai3-flow-react-bindings-bootstrap-provider:p1:inst-resolve-app\n // @cpt-begin:cpt-hai3-algo-react-bindings-resolve-app:p1:inst-use-provided-app\n // @cpt-begin:cpt-hai3-algo-react-bindings-resolve-app:p1:inst-create-app\n // @cpt-begin:cpt-hai3-algo-react-bindings-resolve-app:p1:inst-memoize-app\n // @cpt-begin:cpt-hai3-algo-react-bindings-build-provider-tree:p1:inst-resolve-app-tree\n // Create or use provided app instance\n const app = useMemo<HAI3App>(() => {\n if (providedApp) {\n return providedApp;\n }\n\n return createHAI3App(config);\n }, [providedApp, config]);\n // @cpt-end:cpt-hai3-algo-react-bindings-resolve-app:p1:inst-use-provided-app\n // @cpt-end:cpt-hai3-algo-react-bindings-resolve-app:p1:inst-create-app\n // @cpt-end:cpt-hai3-algo-react-bindings-resolve-app:p1:inst-memoize-app\n // @cpt-end:cpt-hai3-algo-react-bindings-build-provider-tree:p1:inst-resolve-app-tree\n // @cpt-end:cpt-hai3-flow-react-bindings-bootstrap-provider:p1:inst-resolve-app\n\n // @cpt-begin:cpt-hai3-flow-react-bindings-bootstrap-provider:p1:inst-destroy-app\n // Cleanup on unmount\n useEffect(() => {\n return () => {\n // Only destroy if we created the app (not provided)\n if (!providedApp) {\n app.destroy();\n }\n };\n }, [app, providedApp]);\n // @cpt-end:cpt-hai3-flow-react-bindings-bootstrap-provider:p1:inst-destroy-app\n\n // @cpt-begin:cpt-hai3-algo-react-bindings-build-provider-tree:p1:inst-wrap-hai3-context\n // @cpt-begin:cpt-hai3-algo-react-bindings-build-provider-tree:p1:inst-wrap-redux\n // @cpt-begin:cpt-hai3-algo-react-bindings-build-provider-tree:p1:inst-render-children-tree\n // @cpt-begin:cpt-hai3-flow-react-bindings-bootstrap-provider:p1:inst-set-hai3-context\n // @cpt-begin:cpt-hai3-flow-react-bindings-bootstrap-provider:p1:inst-set-redux-provider\n // @cpt-begin:cpt-hai3-flow-react-bindings-bootstrap-provider:p1:inst-render-children\n // Render content\n const content = (\n <HAI3Context.Provider value={app}>\n <ReduxProvider store={app.store as Parameters<typeof ReduxProvider>[0]['store']}>\n {children}\n </ReduxProvider>\n </HAI3Context.Provider>\n );\n // @cpt-end:cpt-hai3-algo-react-bindings-build-provider-tree:p1:inst-wrap-hai3-context\n // @cpt-end:cpt-hai3-algo-react-bindings-build-provider-tree:p1:inst-wrap-redux\n // @cpt-end:cpt-hai3-algo-react-bindings-build-provider-tree:p1:inst-render-children-tree\n // @cpt-end:cpt-hai3-flow-react-bindings-bootstrap-provider:p1:inst-set-hai3-context\n // @cpt-end:cpt-hai3-flow-react-bindings-bootstrap-provider:p1:inst-set-redux-provider\n // @cpt-end:cpt-hai3-flow-react-bindings-bootstrap-provider:p1:inst-render-children\n\n // @cpt-begin:cpt-hai3-algo-react-bindings-build-provider-tree:p1:inst-wrap-mfe-conditional\n // @cpt-begin:cpt-hai3-flow-react-bindings-bootstrap-provider:p2:inst-wrap-mfe-provider\n // Wrap with MfeProvider if bridge is provided\n if (mfeBridge) {\n return (\n <MfeProvider value={mfeBridge}>\n {content}\n </MfeProvider>\n );\n }\n // @cpt-end:cpt-hai3-algo-react-bindings-build-provider-tree:p1:inst-wrap-mfe-conditional\n // @cpt-end:cpt-hai3-flow-react-bindings-bootstrap-provider:p2:inst-wrap-mfe-provider\n\n return content;\n};\n// @cpt-end:cpt-hai3-flow-react-bindings-bootstrap-provider:p1:inst-render-provider\n// @cpt-end:cpt-hai3-dod-react-bindings-provider:p1:inst-render-provider\n","/**\n * HAI3 Context - React context for HAI3 application\n *\n * React Layer: L3 (Depends on @gears-frontx/framework)\n */\n// @cpt-flow:cpt-hai3-flow-react-bindings-use-hai3:p2\n// @cpt-algo:cpt-hai3-algo-react-bindings-mfe-context-guard:p1\n\nimport { createContext, useContext } from 'react';\nimport type { HAI3App } from '@gears-frontx/framework';\n\n// ============================================================================\n// Context Definition\n// ============================================================================\n\n/**\n * HAI3 Context\n * Holds the HAI3 app instance for the application.\n */\nexport const HAI3Context = createContext<HAI3App | null>(null);\n\n/**\n * Use the HAI3 context.\n * Throws if used outside of HAI3Provider.\n *\n * @returns The HAI3 app instance\n */\n// @cpt-begin:cpt-hai3-flow-react-bindings-use-hai3:p2:inst-call-use-hai3\n// @cpt-begin:cpt-hai3-algo-react-bindings-mfe-context-guard:p1:inst-throw-no-hai3-context\nexport function useHAI3(): HAI3App {\n const context = useContext(HAI3Context);\n\n // @cpt-begin:cpt-hai3-flow-react-bindings-use-hai3:p2:inst-guard-hai3-context\n if (!context) {\n throw new Error(\n 'useHAI3 must be used within a HAI3Provider. ' +\n 'Wrap your application with <HAI3Provider> to access HAI3 features.'\n );\n }\n // @cpt-end:cpt-hai3-flow-react-bindings-use-hai3:p2:inst-guard-hai3-context\n\n // @cpt-begin:cpt-hai3-flow-react-bindings-use-hai3:p2:inst-return-hai3-app\n return context;\n // @cpt-end:cpt-hai3-flow-react-bindings-use-hai3:p2:inst-return-hai3-app\n}\n// @cpt-end:cpt-hai3-flow-react-bindings-use-hai3:p2:inst-call-use-hai3\n// @cpt-end:cpt-hai3-algo-react-bindings-mfe-context-guard:p1:inst-throw-no-hai3-context\n","/**\n * MFE Context - React context for MFE state\n *\n * Provides MFE bridge and metadata to child components.\n * Used by MFE components to access their runtime context.\n *\n * React Layer: L3 (Depends on @gears-frontx/framework)\n */\n// @cpt-flow:cpt-hai3-flow-react-bindings-mfe-provider:p1\n// @cpt-algo:cpt-hai3-algo-react-bindings-mfe-context-guard:p1\n// @cpt-dod:cpt-hai3-dod-react-bindings-mfe-hooks:p1\n\nimport { createContext, useContext } from 'react';\nimport type { ChildMfeBridge } from '@gears-frontx/framework';\n\n// ============================================================================\n// Context Value Types\n// ============================================================================\n\n/**\n * MFE Context Value\n * Contains bridge and metadata about the MFE instance.\n */\nexport interface MfeContextValue {\n /** Child bridge for communication with host */\n bridge: ChildMfeBridge;\n /** Extension ID */\n extensionId: string;\n /** Domain ID where MFE is mounted */\n domainId: string;\n}\n\n// ============================================================================\n// Context Definition\n// ============================================================================\n\n/**\n * MFE Context\n * Holds the MFE bridge and metadata for child components.\n */\nexport const MfeContext = createContext<MfeContextValue | null>(null);\n\n/**\n * Use the MFE context.\n * Throws if used outside of MFE context.\n *\n * @returns The MFE context value\n */\n// @cpt-begin:cpt-hai3-flow-react-bindings-mfe-provider:p1:inst-use-mfe-context\n// @cpt-begin:cpt-hai3-algo-react-bindings-mfe-context-guard:p1:inst-throw-no-mfe-context\n// @cpt-begin:cpt-hai3-dod-react-bindings-mfe-hooks:p1:inst-use-mfe-context\nexport function useMfeContext(): MfeContextValue {\n const context = useContext(MfeContext);\n\n if (!context) {\n throw new Error(\n 'useMfeContext must be used within a MfeProvider. ' +\n 'This hook can only be used inside MFE components.'\n );\n }\n\n return context;\n}\n// @cpt-end:cpt-hai3-flow-react-bindings-mfe-provider:p1:inst-use-mfe-context\n// @cpt-end:cpt-hai3-algo-react-bindings-mfe-context-guard:p1:inst-throw-no-mfe-context\n// @cpt-end:cpt-hai3-dod-react-bindings-mfe-hooks:p1:inst-use-mfe-context\n","/**\n * MFE Provider - Provides MFE context to child components\n *\n * Wraps MFE components with bridge and metadata.\n * Used by the MFE mounting system.\n *\n * React Layer: L3 (Depends on @gears-frontx/framework)\n */\n// @cpt-flow:cpt-hai3-flow-react-bindings-mfe-provider:p1\n// @cpt-dod:cpt-hai3-dod-react-bindings-mfe-hooks:p1\n\nimport React from 'react';\nimport { MfeContext, type MfeContextValue } from './MfeContext';\n\n// ============================================================================\n// Provider Props\n// ============================================================================\n\n/**\n * MFE Provider Props\n */\nexport interface MfeProviderProps {\n /** MFE context value */\n value: MfeContextValue;\n /** Child components */\n children: React.ReactNode;\n}\n\n// ============================================================================\n// Provider Component\n// ============================================================================\n\n/**\n * MFE Provider Component\n *\n * Provides MFE bridge and metadata to child components.\n * Used by the MFE mounting system to wrap MFE components.\n *\n * @example\n * ```tsx\n * <MfeProvider value={{ bridge, extensionId, domainId }}>\n * <MyMfeComponent />\n * </MfeProvider>\n * ```\n */\n// @cpt-begin:cpt-hai3-flow-react-bindings-mfe-provider:p1:inst-render-mfe-provider\n// @cpt-begin:cpt-hai3-flow-react-bindings-mfe-provider:p1:inst-set-mfe-context\n// @cpt-begin:cpt-hai3-dod-react-bindings-mfe-hooks:p1:inst-render-mfe-provider\nexport const MfeProvider: React.FC<MfeProviderProps> = ({ value, children }) => {\n return (\n <MfeContext.Provider value={value}>\n {children}\n </MfeContext.Provider>\n );\n};\n// @cpt-end:cpt-hai3-flow-react-bindings-mfe-provider:p1:inst-render-mfe-provider\n// @cpt-end:cpt-hai3-flow-react-bindings-mfe-provider:p1:inst-set-mfe-context\n// @cpt-end:cpt-hai3-dod-react-bindings-mfe-hooks:p1:inst-render-mfe-provider\n","/**\n * useAppDispatch Hook - Type-safe dispatch hook\n *\n * React Layer: L3\n */\n// @cpt-flow:cpt-hai3-flow-react-bindings-use-dispatch:p1\n// @cpt-dod:cpt-hai3-dod-react-bindings-redux-hooks:p1\n\nimport { useDispatch } from 'react-redux';\nimport type { AppDispatch } from '@gears-frontx/framework';\n\n/**\n * Type-safe dispatch hook.\n *\n * @returns The typed dispatch function\n *\n * @example\n * ```tsx\n * const dispatch = useAppDispatch();\n * dispatch(someAction());\n * ```\n */\n// @cpt-begin:cpt-hai3-flow-react-bindings-use-dispatch:p1:inst-call-dispatch\n// @cpt-begin:cpt-hai3-flow-react-bindings-use-dispatch:p1:inst-delegate-dispatch\n// @cpt-begin:cpt-hai3-flow-react-bindings-use-dispatch:p1:inst-use-dispatch\n// @cpt-begin:cpt-hai3-dod-react-bindings-redux-hooks:p1:inst-use-dispatch\nexport function useAppDispatch(): AppDispatch {\n // Use untyped useDispatch and cast the result\n // This avoids type constraint issues with react-redux's generic\n return useDispatch() as AppDispatch;\n}\n// @cpt-end:cpt-hai3-flow-react-bindings-use-dispatch:p1:inst-call-dispatch\n// @cpt-end:cpt-hai3-flow-react-bindings-use-dispatch:p1:inst-delegate-dispatch\n// @cpt-end:cpt-hai3-flow-react-bindings-use-dispatch:p1:inst-use-dispatch\n// @cpt-end:cpt-hai3-dod-react-bindings-redux-hooks:p1:inst-use-dispatch\n","/**\n * useAppSelector Hook - Type-safe selector hook\n *\n * React Layer: L3\n */\n// @cpt-flow:cpt-hai3-flow-react-bindings-use-selector:p1\n// @cpt-dod:cpt-hai3-dod-react-bindings-redux-hooks:p1\n\nimport { useSelector, type TypedUseSelectorHook } from 'react-redux';\nimport type { RootState } from '@gears-frontx/framework';\n\n/**\n * Type-safe selector hook.\n *\n * @example\n * ```tsx\n * const activeScreen = useAppSelector(selectActiveScreen);\n * const menuCollapsed = useAppSelector(selectMenuCollapsed);\n * ```\n */\n// @cpt-begin:cpt-hai3-flow-react-bindings-use-selector:p1:inst-call-selector\n// @cpt-begin:cpt-hai3-flow-react-bindings-use-selector:p1:inst-delegate-selector\n// @cpt-begin:cpt-hai3-flow-react-bindings-use-selector:p1:inst-return-state\n// @cpt-begin:cpt-hai3-flow-react-bindings-use-selector:p1:inst-rerender-on-change\n// @cpt-begin:cpt-hai3-dod-react-bindings-redux-hooks:p1:inst-use-selector\nexport const useAppSelector: TypedUseSelectorHook<RootState> = useSelector;\n// @cpt-end:cpt-hai3-flow-react-bindings-use-selector:p1:inst-call-selector\n// @cpt-end:cpt-hai3-flow-react-bindings-use-selector:p1:inst-delegate-selector\n// @cpt-end:cpt-hai3-flow-react-bindings-use-selector:p1:inst-return-state\n// @cpt-end:cpt-hai3-flow-react-bindings-use-selector:p1:inst-rerender-on-change\n// @cpt-end:cpt-hai3-dod-react-bindings-redux-hooks:p1:inst-use-selector\n","/**\n * useTranslation Hook - Translation utilities\n *\n * React Layer: L3\n */\n// @cpt-flow:cpt-hai3-flow-react-bindings-use-translation:p1\n// @cpt-dod:cpt-hai3-dod-react-bindings-translation-hook:p1\n\nimport { useMemo, useCallback, useSyncExternalStore } from 'react';\nimport type { Language } from '@gears-frontx/framework';\nimport { useHAI3 } from '../HAI3Context';\nimport type { UseTranslationReturn } from '../types';\n\n/**\n * Hook for accessing translation utilities.\n *\n * @returns Translation utilities\n *\n * @example\n * ```tsx\n * const { t, language, setLanguage, isRTL } = useTranslation();\n *\n * return (\n * <div dir={isRTL ? 'rtl' : 'ltr'}>\n * <h1>{t('common:app.title')}</h1>\n * <p>{t('common:app.welcome', { name: 'John' })}</p>\n * </div>\n * );\n * ```\n */\n// @cpt-begin:cpt-hai3-flow-react-bindings-use-translation:p1:inst-call-translation\n// @cpt-begin:cpt-hai3-dod-react-bindings-translation-hook:p1:inst-call-translation\nexport function useTranslation(): UseTranslationReturn {\n // @cpt-begin:cpt-hai3-flow-react-bindings-use-translation:p1:inst-read-i18n-registry\n const app = useHAI3();\n const { i18nRegistry } = app;\n // @cpt-end:cpt-hai3-flow-react-bindings-use-translation:p1:inst-read-i18n-registry\n\n // @cpt-begin:cpt-hai3-flow-react-bindings-use-translation:p1:inst-subscribe-i18n\n // @cpt-begin:cpt-hai3-flow-react-bindings-use-translation:p1:inst-rerender-on-lang-change\n // Subscribe to translation changes using useSyncExternalStore\n // Uses version counter to trigger re-renders when translations change\n const version = useSyncExternalStore(\n useCallback(\n (callback: () => void) => {\n // Subscribe to translation changes (new translations registered)\n return i18nRegistry.subscribe(callback);\n },\n [i18nRegistry]\n ),\n () => i18nRegistry.getVersion(),\n () => i18nRegistry.getVersion()\n );\n // @cpt-end:cpt-hai3-flow-react-bindings-use-translation:p1:inst-subscribe-i18n\n // @cpt-end:cpt-hai3-flow-react-bindings-use-translation:p1:inst-rerender-on-lang-change\n\n // Get current language (memoized to avoid unnecessary recalculations)\n // version is used to trigger recalculation when translations change\n const language = useMemo(() => {\n void version; // Trigger recalculation when version changes\n return i18nRegistry.getLanguage();\n }, [i18nRegistry, version]);\n\n // Translation function\n const t = useCallback(\n (key: string, params?: Record<string, string | number | boolean>) => {\n return i18nRegistry.t(key, params);\n },\n [i18nRegistry]\n );\n\n // @cpt-begin:cpt-hai3-flow-react-bindings-use-translation:p1:inst-set-language\n // Set language via framework action (emits event bus for MFE propagation)\n const setLanguage = useCallback(\n (lang: Language) => {\n if (app.actions.setLanguage) {\n app.actions.setLanguage({ language: lang });\n }\n },\n [app.actions]\n );\n // @cpt-end:cpt-hai3-flow-react-bindings-use-translation:p1:inst-set-language\n\n // Check RTL - recomputes when language changes\n const isRTL = useMemo(() => {\n // Reference language to trigger recalculation on language change\n void language;\n return i18nRegistry.isRTL();\n }, [i18nRegistry, language]);\n\n // @cpt-begin:cpt-hai3-flow-react-bindings-use-translation:p1:inst-return-translation-api\n return {\n t,\n language,\n setLanguage,\n isRTL,\n };\n // @cpt-end:cpt-hai3-flow-react-bindings-use-translation:p1:inst-return-translation-api\n}\n// @cpt-end:cpt-hai3-flow-react-bindings-use-translation:p1:inst-call-translation\n// @cpt-end:cpt-hai3-dod-react-bindings-translation-hook:p1:inst-call-translation\n","/**\n * useScreenTranslations Hook - Screen-level translation loading\n *\n * React Layer: L3\n */\n// @cpt-flow:cpt-hai3-flow-react-bindings-use-screen-translations:p1\n// @cpt-algo:cpt-hai3-algo-react-bindings-load-screen-translations:p1\n// @cpt-state:cpt-hai3-state-react-bindings-screen-translation:p1\n// @cpt-dod:cpt-hai3-dod-react-bindings-screen-translation-hook:p1\n\nimport { useState, useEffect, useMemo, useCallback, useSyncExternalStore } from 'react';\nimport type { TranslationMap, TranslationLoader } from '@gears-frontx/framework';\nimport { useHAI3 } from '../HAI3Context';\nimport type { UseScreenTranslationsReturn } from '../types';\n\n// Re-export TranslationMap for consumers who need it\nexport type { TranslationMap };\n\n/**\n * Check if the input is a TranslationLoader function (from I18nRegistry.createLoader)\n * vs a TranslationMap object\n */\nfunction isTranslationLoader(\n input: TranslationMap | TranslationLoader\n): input is TranslationLoader {\n return typeof input === 'function';\n}\n\n/**\n * Hook for loading screen-level translations.\n * Use this in screen components to lazy-load translations.\n * Automatically reloads translations when language changes.\n *\n * @param screensetId - The screenset ID\n * @param screenId - The screen ID\n * @param translations - Either a TranslationMap object or a TranslationLoader function\n * (from I18nRegistry.createLoader)\n * @returns Loading state\n *\n * @example\n * ```tsx\n * // Option 1: Using I18nRegistry.createLoader (recommended)\n * const translations = I18nRegistry.createLoader({\n * en: () => import('./i18n/en.json'),\n * es: () => import('./i18n/es.json'),\n * });\n *\n * // Option 2: Using raw TranslationMap\n * const translations = {\n * en: () => import('./i18n/en.json'),\n * es: () => import('./i18n/es.json'),\n * };\n *\n * export const HomeScreen: React.FC = () => {\n * const { isLoaded, error } = useScreenTranslations(\n * 'demo',\n * 'home',\n * translations\n * );\n *\n * if (!isLoaded) return <LoadingSpinner />;\n * if (error) return <ErrorMessage error={error} />;\n *\n * return <div>...</div>;\n * };\n * ```\n */\n// @cpt-begin:cpt-hai3-flow-react-bindings-use-screen-translations:p1:inst-call-screen-translations\n// @cpt-begin:cpt-hai3-dod-react-bindings-screen-translation-hook:p1:inst-call-screen-translations\nexport function useScreenTranslations(\n screensetId: string,\n screenId: string,\n translations: TranslationMap | TranslationLoader\n): UseScreenTranslationsReturn {\n const app = useHAI3();\n const { i18nRegistry } = app;\n\n // Track loading state per language to handle language changes\n // @cpt-begin:cpt-hai3-state-react-bindings-screen-translation:p1:inst-begin-load\n // @cpt-begin:cpt-hai3-state-react-bindings-screen-translation:p1:inst-load-success\n // @cpt-begin:cpt-hai3-state-react-bindings-screen-translation:p1:inst-load-error\n // @cpt-begin:cpt-hai3-state-react-bindings-screen-translation:p1:inst-reload-on-lang-change\n // @cpt-begin:cpt-hai3-state-react-bindings-screen-translation:p2:inst-retry-on-lang-change\n const [loadedLanguage, setLoadedLanguage] = useState<string | null>(null);\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n // @cpt-end:cpt-hai3-state-react-bindings-screen-translation:p1:inst-begin-load\n // @cpt-end:cpt-hai3-state-react-bindings-screen-translation:p1:inst-load-success\n // @cpt-end:cpt-hai3-state-react-bindings-screen-translation:p1:inst-load-error\n // @cpt-end:cpt-hai3-state-react-bindings-screen-translation:p1:inst-reload-on-lang-change\n // @cpt-end:cpt-hai3-state-react-bindings-screen-translation:p2:inst-retry-on-lang-change\n\n // @cpt-begin:cpt-hai3-flow-react-bindings-use-screen-translations:p1:inst-subscribe-lang-change\n // Subscribe to translation changes using useSyncExternalStore\n // This ensures we reload when language changes\n const version = useSyncExternalStore(\n useCallback(\n (callback: () => void) => i18nRegistry.subscribe(callback),\n [i18nRegistry]\n ),\n () => i18nRegistry.getVersion(),\n () => i18nRegistry.getVersion()\n );\n // @cpt-end:cpt-hai3-flow-react-bindings-use-screen-translations:p1:inst-subscribe-lang-change\n\n // @cpt-begin:cpt-hai3-algo-react-bindings-load-screen-translations:p1:inst-get-current-lang\n // Get current language (changes when version changes)\n // version is used to trigger recalculation when translations change\n const currentLanguage = useMemo(() => {\n void version; // Trigger recalculation when version changes\n return i18nRegistry.getLanguage();\n }, [i18nRegistry, version]);\n // @cpt-end:cpt-hai3-algo-react-bindings-load-screen-translations:p1:inst-get-current-lang\n\n // @cpt-begin:cpt-hai3-algo-react-bindings-load-screen-translations:p1:inst-resolve-loader\n // Create a TranslationLoader function from the translation map or use directly if already a loader\n const loader: TranslationLoader = useMemo(() => {\n if (isTranslationLoader(translations)) {\n // Already a loader function (from I18nRegistry.createLoader)\n return translations;\n }\n\n // Convert TranslationMap to TranslationLoader\n return async (language: string) => {\n const importFn = translations[language as keyof typeof translations];\n if (!importFn) {\n // Return empty dictionary if language not in map\n return {};\n }\n const module = await importFn();\n return module.default;\n };\n }, [translations]);\n // @cpt-end:cpt-hai3-algo-react-bindings-load-screen-translations:p1:inst-resolve-loader\n\n // @cpt-begin:cpt-hai3-flow-react-bindings-use-screen-translations:p1:inst-run-load-screen-translations\n useEffect(() => {\n // @cpt-begin:cpt-hai3-algo-react-bindings-load-screen-translations:p1:inst-skip-if-loaded\n // Skip if no language or already loaded for this language\n if (!currentLanguage || currentLanguage === loadedLanguage) {\n return;\n }\n // @cpt-end:cpt-hai3-algo-react-bindings-load-screen-translations:p1:inst-skip-if-loaded\n\n let cancelled = false;\n setIsLoading(true);\n\n const loadTranslations = async () => {\n try {\n const namespace = `screen.${screensetId}.${screenId}`;\n\n // @cpt-begin:cpt-hai3-algo-react-bindings-load-screen-translations:p1:inst-register-loader\n // Register the loader for future language changes\n i18nRegistry.registerLoader(namespace, loader);\n // @cpt-end:cpt-hai3-algo-react-bindings-load-screen-translations:p1:inst-register-loader\n\n // @cpt-begin:cpt-hai3-algo-react-bindings-load-screen-translations:p1:inst-call-loader\n // Actually load the translations for current language\n const loadedTranslations = await loader(currentLanguage);\n // @cpt-end:cpt-hai3-algo-react-bindings-load-screen-translations:p1:inst-call-loader\n\n // @cpt-begin:cpt-hai3-algo-react-bindings-load-screen-translations:p1:inst-register-translations\n i18nRegistry.register(namespace, currentLanguage, loadedTranslations);\n // @cpt-end:cpt-hai3-algo-react-bindings-load-screen-translations:p1:inst-register-translations\n\n // @cpt-begin:cpt-hai3-algo-react-bindings-load-screen-translations:p1:inst-cancel-on-unmount\n if (!cancelled) {\n setLoadedLanguage(currentLanguage);\n setIsLoading(false);\n setError(null);\n }\n // @cpt-end:cpt-hai3-algo-react-bindings-load-screen-translations:p1:inst-cancel-on-unmount\n } catch (err) {\n // @cpt-begin:cpt-hai3-algo-react-bindings-load-screen-translations:p1:inst-handle-load-error\n if (!cancelled) {\n setError(err instanceof Error ? err : new Error(String(err)));\n setIsLoading(false);\n }\n // @cpt-end:cpt-hai3-algo-react-bindings-load-screen-translations:p1:inst-handle-load-error\n }\n };\n\n loadTranslations();\n\n // @cpt-begin:cpt-hai3-algo-react-bindings-load-screen-translations:p1:inst-cancel-stale-load\n return () => {\n cancelled = true;\n };\n // @cpt-end:cpt-hai3-algo-react-bindings-load-screen-translations:p1:inst-cancel-stale-load\n }, [screensetId, screenId, loader, i18nRegistry, currentLanguage, loadedLanguage]);\n // @cpt-end:cpt-hai3-flow-react-bindings-use-screen-translations:p1:inst-run-load-screen-translations\n\n // @cpt-begin:cpt-hai3-flow-react-bindings-use-screen-translations:p1:inst-return-loading-state\n // Derive isLoaded from whether we've loaded translations for the current language\n const isLoaded = currentLanguage !== null && currentLanguage === loadedLanguage && !isLoading;\n\n // @cpt-begin:cpt-hai3-flow-react-bindings-use-screen-translations:p1:inst-gate-render\n // isLoaded is the gate value: consumers must check this before rendering translation-dependent UI\n return { isLoaded, error };\n // @cpt-end:cpt-hai3-flow-react-bindings-use-screen-translations:p1:inst-gate-render\n // @cpt-end:cpt-hai3-flow-react-bindings-use-screen-translations:p1:inst-return-loading-state\n}\n// @cpt-end:cpt-hai3-flow-react-bindings-use-screen-translations:p1:inst-call-screen-translations\n// @cpt-end:cpt-hai3-dod-react-bindings-screen-translation-hook:p1:inst-call-screen-translations\n","/**\n * useFormatters Hook - Locale-aware formatters\n *\n * Returns formatters that use i18nRegistry.getLanguage() internally.\n * Calls useTranslation() so the component re-renders when language changes.\n *\n * React Layer: L3\n */\n// @cpt-flow:cpt-hai3-flow-react-bindings-use-formatters:p1\n// @cpt-dod:cpt-hai3-dod-react-bindings-formatters-hook:p1\n\nimport { useMemo } from 'react';\nimport {\n formatDate as formatDateFn,\n formatTime as formatTimeFn,\n formatDateTime as formatDateTimeFn,\n formatRelative as formatRelativeFn,\n formatNumber as formatNumberFn,\n formatPercent as formatPercentFn,\n formatCompact as formatCompactFn,\n formatCurrency as formatCurrencyFn,\n compareStrings as compareStringsFn,\n createCollator as createCollatorFn,\n} from '@gears-frontx/framework';\nimport type { UseFormattersReturn } from '../types';\nimport { useTranslation } from './useTranslation';\n\n/**\n * Hook for accessing locale-aware formatters (date, number, currency, sort).\n *\n * Formatters use the current app language from i18nRegistry.getLanguage().\n * Re-renders when language changes via useTranslation() subscription.\n *\n * @returns Object with formatDate, formatTime, formatDateTime, formatRelative,\n * formatNumber, formatPercent, formatCompact, formatCurrency, compareStrings, createCollator\n *\n * @example\n * ```tsx\n * const { formatDate, formatCurrency } = useFormatters();\n * return (\n * <span>{formatDate(new Date(), 'short')}</span>\n * <span>{formatCurrency(99.99, 'USD')}</span>\n * );\n * ```\n */\n// @cpt-begin:cpt-hai3-flow-react-bindings-use-formatters:p1:inst-call-formatters\n// @cpt-begin:cpt-hai3-dod-react-bindings-formatters-hook:p1:inst-call-formatters\nexport function useFormatters(): UseFormattersReturn {\n // @cpt-begin:cpt-hai3-flow-react-bindings-use-formatters:p1:inst-subscribe-via-translation\n // useTranslation() subscribes to language changes so this component re-renders\n // when language changes; formatters read i18nRegistry.getLanguage() at call time\n const { language } = useTranslation();\n // @cpt-end:cpt-hai3-flow-react-bindings-use-formatters:p1:inst-subscribe-via-translation\n\n // @cpt-begin:cpt-hai3-flow-react-bindings-use-formatters:p1:inst-return-formatters\n // @cpt-begin:cpt-hai3-flow-react-bindings-use-formatters:p1:inst-formatters-read-locale\n // @cpt-begin:cpt-hai3-flow-react-bindings-use-formatters:p1:inst-recompute-on-lang\n return useMemo<UseFormattersReturn>(\n () => {\n void language; // re-run when language changes so formatters see new locale\n return {\n formatDate: formatDateFn,\n formatTime: formatTimeFn,\n formatDateTime: formatDateTimeFn,\n formatRelative: formatRelativeFn,\n formatNumber: formatNumberFn,\n formatPercent: formatPercentFn,\n formatCompact: formatCompactFn,\n formatCurrency: formatCurrencyFn,\n compareStrings: compareStringsFn,\n createCollator: createCollatorFn,\n };\n },\n [language]\n );\n // @cpt-end:cpt-hai3-flow-react-bindings-use-formatters:p1:inst-return-formatters\n // @cpt-end:cpt-hai3-flow-react-bindings-use-formatters:p1:inst-formatters-read-locale\n // @cpt-end:cpt-hai3-flow-react-bindings-use-formatters:p1:inst-recompute-on-lang\n}\n// @cpt-end:cpt-hai3-flow-react-bindings-use-formatters:p1:inst-call-formatters\n// @cpt-end:cpt-hai3-dod-react-bindings-formatters-hook:p1:inst-call-formatters\n","/**\n * useTheme Hook - Theme utilities\n *\n * React Layer: L3\n */\n// @cpt-flow:cpt-hai3-flow-react-bindings-use-theme:p1\n// @cpt-dod:cpt-hai3-dod-react-bindings-theme-hook:p1\n\nimport { useCallback, useMemo, useSyncExternalStore } from 'react';\nimport { useHAI3 } from '../HAI3Context';\nimport type { UseThemeReturn } from '../types';\n\n/**\n * Hook for theme utilities.\n *\n * @returns Theme utilities\n *\n * @example\n * ```tsx\n * const { currentTheme, themes, setTheme } = useTheme();\n *\n * return (\n * <select\n * value={currentTheme}\n * onChange={(e) => setTheme(e.target.value)}\n * >\n * {themes.map((theme) => (\n * <option key={theme.id} value={theme.id}>\n * {theme.name}\n * </option>\n * ))}\n * </select>\n * );\n * ```\n */\n// @cpt-begin:cpt-hai3-flow-react-bindings-use-theme:p1:inst-call-theme\n// @cpt-begin:cpt-hai3-dod-react-bindings-theme-hook:p1:inst-call-theme\nexport function useTheme(): UseThemeReturn {\n // @cpt-begin:cpt-hai3-flow-react-bindings-use-theme:p1:inst-read-theme-registry\n const app = useHAI3();\n const { themeRegistry } = app;\n // @cpt-end:cpt-hai3-flow-react-bindings-use-theme:p1:inst-read-theme-registry\n\n // @cpt-begin:cpt-hai3-flow-react-bindings-use-theme:p1:inst-subscribe-theme\n // @cpt-begin:cpt-hai3-flow-react-bindings-use-theme:p1:inst-rerender-on-theme-change\n // Subscribe to theme changes using useSyncExternalStore\n // Uses version counter to trigger re-renders when theme changes\n const version = useSyncExternalStore(\n useCallback(\n (callback: () => void) => {\n return themeRegistry.subscribe(callback);\n },\n [themeRegistry]\n ),\n () => themeRegistry.getVersion(),\n () => themeRegistry.getVersion()\n );\n // @cpt-end:cpt-hai3-flow-react-bindings-use-theme:p1:inst-subscribe-theme\n // @cpt-end:cpt-hai3-flow-react-bindings-use-theme:p1:inst-rerender-on-theme-change\n\n // Get current theme (memoized, recalculates on version change)\n const currentTheme = useMemo(() => {\n // Reference version to trigger recalculation on theme change\n void version;\n const theme = themeRegistry.getCurrent();\n return theme?.id;\n }, [themeRegistry, version]);\n\n // Get all themes\n const themes = useMemo(() => {\n return themeRegistry.getAll().map((theme) => ({\n id: theme.id,\n name: theme.name,\n }));\n }, [themeRegistry]);\n\n // @cpt-begin:cpt-hai3-flow-react-bindings-use-theme:p1:inst-dispatch-change-theme\n // Set theme\n const setTheme = useCallback(\n (themeId: string) => {\n if (app.actions.changeTheme) {\n app.actions.changeTheme({ themeId });\n }\n },\n [app.actions]\n );\n // @cpt-end:cpt-hai3-flow-react-bindings-use-theme:p1:inst-dispatch-change-theme\n\n // @cpt-begin:cpt-hai3-flow-react-bindings-use-theme:p1:inst-return-theme-api\n return {\n currentTheme,\n themes,\n setTheme,\n };\n // @cpt-end:cpt-hai3-flow-react-bindings-use-theme:p1:inst-return-theme-api\n}\n// @cpt-end:cpt-hai3-flow-react-bindings-use-theme:p1:inst-call-theme\n// @cpt-end:cpt-hai3-dod-react-bindings-theme-hook:p1:inst-call-theme\n","/**\n * useMfeBridge Hook - MFE bridge access\n *\n * Returns the ChildMfeBridge from context for communication with host.\n *\n * React Layer: L3\n */\n// @cpt-flow:cpt-hai3-flow-react-bindings-mfe-provider:p1\n// @cpt-algo:cpt-hai3-algo-react-bindings-mfe-context-guard:p1\n// @cpt-dod:cpt-hai3-dod-react-bindings-mfe-hooks:p1\n\nimport { useMfeContext } from '../MfeContext';\nimport type { ChildMfeBridge } from '@gears-frontx/framework';\n\n// ============================================================================\n// Hook Implementation\n// ============================================================================\n\n/**\n * Hook for accessing the MFE bridge.\n *\n * Returns the ChildMfeBridge instance for communication with the host.\n * Must be used within a MfeProvider (i.e., inside an MFE component).\n *\n * @returns Child MFE bridge\n *\n * @example\n * ```tsx\n * function MyMfeComponent() {\n * const bridge = useMfeBridge();\n *\n * // Bridge methods:\n * // bridge.executeActionsChain(chain);\n * // bridge.subscribeToProperty(propertyTypeId, callback);\n *\n * return <div>Domain: {bridge.domainId}</div>;\n * }\n * ```\n */\n// @cpt-begin:cpt-hai3-flow-react-bindings-mfe-provider:p1:inst-use-bridge\n// @cpt-begin:cpt-hai3-algo-react-bindings-mfe-context-guard:p1:inst-throw-no-mfe-context\n// @cpt-begin:cpt-hai3-dod-react-bindings-mfe-hooks:p1:inst-use-bridge\nexport function useMfeBridge(): ChildMfeBridge {\n const { bridge } = useMfeContext();\n return bridge;\n}\n// @cpt-end:cpt-hai3-flow-react-bindings-mfe-provider:p1:inst-use-bridge\n// @cpt-end:cpt-hai3-algo-react-bindings-mfe-context-guard:p1:inst-throw-no-mfe-context\n// @cpt-end:cpt-hai3-dod-react-bindings-mfe-hooks:p1:inst-use-bridge\n","/**\n * useSharedProperty Hook - Shared property subscription\n *\n * Subscribes to shared property updates from the host.\n *\n * React Layer: L3\n */\n// @cpt-flow:cpt-hai3-flow-react-bindings-use-shared-property:p1\n// @cpt-algo:cpt-hai3-algo-react-bindings-mfe-context-guard:p1\n// @cpt-dod:cpt-hai3-dod-react-bindings-mfe-hooks:p1\n\nimport { useSyncExternalStore, useCallback } from 'react';\nimport { useMfeContext } from '../MfeContext';\n\n// ============================================================================\n// Hook Implementation\n// ============================================================================\n\n/**\n * Hook for subscribing to a shared property.\n *\n * Subscribes to property updates from the host and returns the current value.\n * Must be used within a MfeProvider (i.e., inside an MFE component).\n *\n * NOTE: This hook provides the interface and uses useSyncExternalStore with a stub subscription.\n * Full bridge subscription should be implemented when bridge methods are available.\n *\n * @param _propertyTypeId - Type ID of the shared property to subscribe to (currently unused)\n * @returns Current property value\n *\n * @example\n * ```tsx\n * function MyMfeComponent() {\n * const userData = useSharedProperty('gts.frontx.mfes.comm.shared_property.v1~myapp.user_data.v1');\n *\n * return <div>User: {userData?.name}</div>;\n * }\n * ```\n */\n// @cpt-begin:cpt-hai3-flow-react-bindings-use-shared-property:p1:inst-call-shared-property\n// @cpt-begin:cpt-hai3-dod-react-bindings-mfe-hooks:p1:inst-call-shared-property\nexport function useSharedProperty<T = unknown>(propertyTypeId: string): T | undefined {\n // @cpt-begin:cpt-hai3-flow-react-bindings-use-shared-property:p1:inst-read-bridge\n // @cpt-begin:cpt-hai3-algo-react-bindings-mfe-context-guard:p1:inst-throw-no-mfe-context\n // Enforce MfeProvider context requirement\n const { bridge } = useMfeContext(); // Throws if not in MfeProvider\n // @cpt-end:cpt-hai3-flow-react-bindings-use-shared-property:p1:inst-read-bridge\n // @cpt-end:cpt-hai3-algo-react-bindings-mfe-context-guard:p1:inst-throw-no-mfe-context\n\n // @cpt-begin:cpt-hai3-flow-react-bindings-use-shared-property:p1:inst-subscribe-property\n // @cpt-begin:cpt-hai3-flow-react-bindings-use-shared-property:p1:inst-rerender-on-property-change\n // Subscribe to property updates via bridge\n const subscribe = useCallback((callback: () => void) => {\n return bridge.subscribeToProperty(propertyTypeId, () => {\n // When property changes, trigger React re-render\n callback();\n });\n }, [bridge, propertyTypeId]);\n // @cpt-end:cpt-hai3-flow-react-bindings-use-shared-property:p1:inst-subscribe-property\n // @cpt-end:cpt-hai3-flow-react-bindings-use-shared-property:p1:inst-rerender-on-property-change\n\n // @cpt-begin:cpt-hai3-flow-react-bindings-use-shared-property:p1:inst-return-property-value\n const getSnapshot = useCallback(() => {\n const property = bridge.getProperty(propertyTypeId);\n // Type narrowing: caller specifies expected type T (standard React hook pattern)\n // Similar to useState<T>, useContext<T> - type safety is caller's responsibility\n return property?.value as T | undefined;\n }, [bridge, propertyTypeId]);\n\n const value = useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n\n return value;\n // @cpt-end:cpt-hai3-flow-react-bindings-use-shared-property:p1:inst-return-property-value\n}\n// @cpt-end:cpt-hai3-flow-react-bindings-use-shared-property:p1:inst-call-shared-property\n// @cpt-end:cpt-hai3-dod-react-bindings-mfe-hooks:p1:inst-call-shared-property\n","/**\n * useHostAction Hook - Host action requests\n *\n * Returns a callback to request host actions via the bridge.\n *\n * React Layer: L3\n */\n// @cpt-flow:cpt-hai3-flow-react-bindings-use-host-action:p1\n// @cpt-algo:cpt-hai3-algo-react-bindings-mfe-context-guard:p1\n// @cpt-dod:cpt-hai3-dod-react-bindings-mfe-hooks:p1\n\nimport { useCallback } from 'react';\nimport { useMfeContext } from '../MfeContext';\n\n// ============================================================================\n// Hook Implementation\n// ============================================================================\n\n/**\n * Hook for requesting host actions.\n *\n * Returns a callback function that sends an actions chain to the host.\n * Must be used within a MfeProvider (i.e., inside an MFE component).\n *\n * NOTE: This hook provides the interface. Bridge executeActionsChain() delegates to the registry.\n *\n * @param actionTypeId - Type ID of the action to request\n * @returns Callback function to request the action with payload\n *\n * @example\n * ```tsx\n * function MyMfeComponent() {\n * const requestNavigation = useHostAction('gts.frontx.mfes.comm.action.v1~myapp.navigate.v1');\n *\n * const handleClick = () => {\n * requestNavigation({ path: '/dashboard' });\n * };\n *\n * return <button onClick={handleClick}>Navigate</button>;\n * }\n * ```\n */\n// @cpt-begin:cpt-hai3-flow-react-bindings-use-host-action:p1:inst-call-host-action\n// @cpt-begin:cpt-hai3-dod-react-bindings-mfe-hooks:p1:inst-call-host-action\nexport function useHostAction<TPayload extends Record<string, unknown> = Record<string, unknown>>(\n actionTypeId: string\n): (payload?: TPayload) => void {\n // @cpt-begin:cpt-hai3-flow-react-bindings-use-host-action:p1:inst-read-bridge-for-action\n // @cpt-begin:cpt-hai3-algo-react-bindings-mfe-context-guard:p1:inst-throw-no-mfe-context\n // Enforce MfeProvider context requirement\n const { bridge } = useMfeContext(); // Throws if not in MfeProvider\n // @cpt-end:cpt-hai3-flow-react-bindings-use-host-action:p1:inst-read-bridge-for-action\n // @cpt-end:cpt-hai3-algo-react-bindings-mfe-context-guard:p1:inst-throw-no-mfe-context\n\n // @cpt-begin:cpt-hai3-flow-react-bindings-use-host-action:p1:inst-return-action-callback\n return useCallback((payload?: TPayload) => {\n // Construct an ActionsChain with the action\n // With the constraint, TPayload extends Record<string, unknown>,\n // so this is a safe widening from specific to general\n const chain = {\n action: {\n type: actionTypeId,\n target: bridge.domainId,\n payload: payload as Record<string, unknown> | undefined,\n },\n };\n\n // @cpt-begin:cpt-hai3-flow-react-bindings-use-host-action:p1:inst-log-action-error\n // Send the chain to the host\n bridge.executeActionsChain(chain).catch((error: Error) => {\n console.error(\n `[useHostAction] Failed to send action '${actionTypeId}':`,\n error\n );\n });\n // @cpt-end:cpt-hai3-flow-react-bindings-use-host-action:p1:inst-log-action-error\n }, [actionTypeId, bridge]);\n // @cpt-end:cpt-hai3-flow-react-bindings-use-host-action:p1:inst-return-action-callback\n}\n// @cpt-end:cpt-hai3-flow-react-bindings-use-host-action:p1:inst-call-host-action\n// @cpt-end:cpt-hai3-dod-react-bindings-mfe-hooks:p1:inst-call-host-action\n","/**\n * useDomainExtensions Hook - Domain extension list subscription\n *\n * Subscribes to store changes to detect when extensions are registered or unregistered,\n * and returns the current list of extensions for a domain.\n *\n * React Layer: L3\n */\n// @cpt-flow:cpt-hai3-flow-react-bindings-use-domain-extensions:p1\n// @cpt-algo:cpt-hai3-algo-react-bindings-mfe-context-guard:p1\n// @cpt-algo:cpt-hai3-algo-react-bindings-stable-snapshots:p1\n// @cpt-dod:cpt-hai3-dod-react-bindings-observation-hooks:p1\n\nimport { useSyncExternalStore, useCallback, useRef } from 'react';\nimport { useHAI3 } from '../../HAI3Context';\nimport type { Extension } from '@gears-frontx/framework';\n\n// ============================================================================\n// Hook Implementation\n// ============================================================================\n\n/**\n * Hook for observing extensions registered for a domain.\n *\n * Subscribes to the HAI3 store to detect registration state changes,\n * and returns the current list of extensions for the specified domain.\n *\n * @param domainId - Domain ID to query extensions for\n * @returns Array of extensions currently registered for the domain\n *\n * @example\n * ```tsx\n * function SidebarExtensions() {\n * const extensions = useDomainExtensions('gts.frontx.mfes.ext.domain.v1~frontx.screensets.layout.sidebar.v1');\n *\n * return (\n * <div>\n * {extensions.map(ext => (\n * <div key={ext.id}>{ext.id}</div>\n * ))}\n * </div>\n * );\n * }\n * ```\n */\n// @cpt-begin:cpt-hai3-flow-react-bindings-use-domain-extensions:p1:inst-call-domain-extensions\n// @cpt-begin:cpt-hai3-dod-react-bindings-observation-hooks:p1:inst-call-domain-extensions\nexport function useDomainExtensions(domainId: string): Extension[] {\n const app = useHAI3();\n const registry = app.screensetsRegistry;\n\n // @cpt-begin:cpt-hai3-flow-react-bindings-use-domain-extensions:p1:inst-guard-registry\n // @cpt-begin:cpt-hai3-algo-react-bindings-mfe-context-guard:p1:inst-throw-no-registry\n if (!registry) {\n throw new Error(\n 'useDomainExtensions requires the microfrontends plugin. ' +\n 'Add microfrontends() to your HAI3 app configuration.'\n );\n }\n // @cpt-end:cpt-hai3-flow-react-bindings-use-domain-extensions:p1:inst-guard-registry\n // @cpt-end:cpt-hai3-algo-react-bindings-mfe-context-guard:p1:inst-throw-no-registry\n\n // @cpt-begin:cpt-hai3-flow-react-bindings-use-domain-extensions:p1:inst-subscribe-store\n // Subscribe to store changes.\n // Any dispatch (including registration state updates) triggers a snapshot check.\n // The snapshot comparison ensures only actual extension list changes cause re-renders.\n const subscribe = useCallback(\n (onStoreChange: () => void) => {\n return app.store.subscribe(onStoreChange);\n },\n [app.store]\n );\n // @cpt-end:cpt-hai3-flow-react-bindings-use-domain-extensions:p1:inst-subscribe-store\n\n // @cpt-begin:cpt-hai3-algo-react-bindings-stable-snapshots:p1:inst-cache-ref\n // Cache the snapshot to maintain referential stability for useSyncExternalStore.\n // Only update when the extension IDs actually change.\n const cacheRef = useRef<{ ids: string; extensions: Extension[] }>({ ids: '', extensions: [] });\n // @cpt-end:cpt-hai3-algo-react-bindings-stable-snapshots:p1:inst-cache-ref\n\n // @cpt-begin:cpt-hai3-flow-react-bindings-use-domain-extensions:p1:inst-diff-extensions\n // @cpt-begin:cpt-hai3-flow-react-bindings-use-domain-extensions:p1:inst-stable-reference\n const getSnapshot = useCallback(() => {\n const extensions = registry.getExtensionsForDomain(domainId);\n // @cpt-begin:cpt-hai3-algo-react-bindings-stable-snapshots:p1:inst-compute-cache-key\n const ids = extensions.map(e => e.id).join(',');\n // @cpt-end:cpt-hai3-algo-react-bindings-stable-snapshots:p1:inst-compute-cache-key\n // @cpt-begin:cpt-hai3-algo-react-bindings-stable-snapshots:p1:inst-return-cached\n // @cpt-begin:cpt-hai3-algo-react-bindings-stable-snapshots:p1:inst-update-cache\n if (ids !== cacheRef.current.ids) {\n cacheRef.current = { ids, extensions };\n }\n return cacheRef.current.extensions;\n // @cpt-end:cpt-hai3-algo-react-bindings-stable-snapshots:p1:inst-return-cached\n // @cpt-end:cpt-hai3-algo-react-bindings-stable-snapshots:p1:inst-update-cache\n }, [registry, domainId]);\n // @cpt-end:cpt-hai3-flow-react-bindings-use-domain-extensions:p1:inst-diff-extensions\n // @cpt-end:cpt-hai3-flow-react-bindings-use-domain-extensions:p1:inst-stable-reference\n\n return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n}\n// @cpt-end:cpt-hai3-flow-react-bindings-use-domain-extensions:p1:inst-call-domain-extensions\n// @cpt-end:cpt-hai3-dod-react-bindings-observation-hooks:p1:inst-call-domain-extensions\n","/**\n * useRegisteredPackages Hook - Registered GTS packages subscription\n *\n * Subscribes to store changes to detect when extensions are registered or unregistered,\n * and returns the current list of registered GTS packages.\n *\n * React Layer: L3\n */\n// @cpt-flow:cpt-hai3-flow-react-bindings-use-registered-packages:p1\n// @cpt-algo:cpt-hai3-algo-react-bindings-mfe-context-guard:p1\n// @cpt-algo:cpt-hai3-algo-react-bindings-stable-snapshots:p1\n// @cpt-dod:cpt-hai3-dod-react-bindings-observation-hooks:p1\n\nimport { useSyncExternalStore, useCallback, useRef } from 'react';\nimport { useHAI3 } from '../../HAI3Context';\n\n// ============================================================================\n// Hook Implementation\n// ============================================================================\n\n/**\n * Hook for observing registered GTS packages.\n *\n * Subscribes to the HAI3 store to detect registration state changes,\n * and returns the current list of GTS packages extracted from registered\n * extensions.\n *\n * ARCHITECTURAL NOTE ON STORE SUBSCRIPTION COUPLING:\n * This hook uses `useSyncExternalStore` with `app.store.subscribe`, which\n * fires on any Redux dispatch. Since `registerExtension()` dispatches to\n * the mfe store slice, the subscription WILL trigger when packages change.\n * The `getSnapshot` function calls `screensetsRegistry.getRegisteredPackages()`\n * which reads the private `packages` Map. This works because every package\n * map mutation (in registerExtension/unregisterExtension) is always\n * accompanied by a store dispatch in the same serializer callback.\n *\n * IMPORTANT: If a future change mutates the packages map WITHOUT a store\n * dispatch, this hook would fail to re-render. Keep this coupling documented.\n *\n * @returns Array of GTS package strings currently registered\n *\n * @example\n * ```tsx\n * function PackageList() {\n * const packages = useRegisteredPackages();\n *\n * return (\n * <div>\n * {packages.map(pkg => (\n * <div key={pkg}>{pkg}</div>\n * ))}\n * </div>\n * );\n * }\n * ```\n */\n// @cpt-begin:cpt-hai3-flow-react-bindings-use-registered-packages:p1:inst-call-registered-packages\n// @cpt-begin:cpt-hai3-dod-react-bindings-observation-hooks:p1:inst-call-registered-packages\nexport function useRegisteredPackages(): string[] {\n const app = useHAI3();\n const registry = app.screensetsRegistry;\n\n // @cpt-begin:cpt-hai3-flow-react-bindings-use-registered-packages:p1:inst-guard-registry-packages\n // @cpt-begin:cpt-hai3-algo-react-bindings-mfe-context-guard:p1:inst-throw-no-registry\n if (!registry) {\n throw new Error(\n 'useRegisteredPackages requires the microfrontends plugin. ' +\n 'Add microfrontends() to your HAI3 app configuration.'\n );\n }\n // @cpt-end:cpt-hai3-flow-react-bindings-use-registered-packages:p1:inst-guard-registry-packages\n // @cpt-end:cpt-hai3-algo-react-bindings-mfe-context-guard:p1:inst-throw-no-registry\n\n // @cpt-begin:cpt-hai3-flow-react-bindings-use-registered-packages:p1:inst-subscribe-store-packages\n // Subscribe to store changes.\n // Any dispatch (including registration state updates) triggers a snapshot check.\n // The snapshot comparison ensures only actual package list changes cause re-renders.\n const subscribe = useCallback(\n (onStoreChange: () => void) => {\n return app.store.subscribe(onStoreChange);\n },\n [app.store]\n );\n // @cpt-end:cpt-hai3-flow-react-bindings-use-registered-packages:p1:inst-subscribe-store-packages\n\n // @cpt-begin:cpt-hai3-algo-react-bindings-stable-snapshots:p1:inst-cache-ref\n // Cache the snapshot to maintain referential stability for useSyncExternalStore.\n // Only update when the package list actually changes.\n const cacheRef = useRef<{ packages: string; list: string[] }>({ packages: '', list: [] });\n // @cpt-end:cpt-hai3-algo-react-bindings-stable-snapshots:p1:inst-cache-ref\n\n // @cpt-begin:cpt-hai3-flow-react-bindings-use-registered-packages:p1:inst-diff-packages\n const getSnapshot = useCallback(() => {\n const list = registry.getRegisteredPackages();\n // @cpt-begin:cpt-hai3-algo-react-bindings-stable-snapshots:p1:inst-compute-cache-key\n const packages = list.join(',');\n // @cpt-end:cpt-hai3-algo-react-bindings-stable-snapshots:p1:inst-compute-cache-key\n // @cpt-begin:cpt-hai3-algo-react-bindings-stable-snapshots:p1:inst-return-cached\n // @cpt-begin:cpt-hai3-algo-react-bindings-stable-snapshots:p1:inst-update-cache\n if (packages !== cacheRef.current.packages) {\n cacheRef.current = { packages, list };\n }\n return cacheRef.current.list;\n // @cpt-end:cpt-hai3-algo-react-bindings-stable-snapshots:p1:inst-return-cached\n // @cpt-end:cpt-hai3-algo-react-bindings-stable-snapshots:p1:inst-update-cache\n }, [registry]);\n // @cpt-end:cpt-hai3-flow-react-bindings-use-registered-packages:p1:inst-diff-packages\n\n return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n}\n// @cpt-end:cpt-hai3-flow-react-bindings-use-registered-packages:p1:inst-call-registered-packages\n// @cpt-end:cpt-hai3-dod-react-bindings-observation-hooks:p1:inst-call-registered-packages\n","/**\n * useActivePackage Hook - Active GTS package subscription\n *\n * Subscribes to store changes and returns the GTS package of the currently\n * mounted screen extension.\n *\n * React Layer: L3\n */\n// @cpt-flow:cpt-hai3-flow-react-bindings-use-active-package:p1\n// @cpt-algo:cpt-hai3-algo-react-bindings-mfe-context-guard:p1\n// @cpt-algo:cpt-hai3-algo-react-bindings-stable-snapshots:p1\n// @cpt-dod:cpt-hai3-dod-react-bindings-observation-hooks:p1\n\nimport { useSyncExternalStore, useCallback, useRef } from 'react';\nimport { useHAI3 } from '../../HAI3Context';\nimport { extractGtsPackage, FRONTX_SCREEN_DOMAIN } from '@gears-frontx/framework';\n\n// ============================================================================\n// Hook Implementation\n// ============================================================================\n\n/**\n * Hook for observing the active GTS package (the package of the currently\n * mounted screen extension).\n *\n * Subscribes to the HAI3 store to detect mount state changes, and returns\n * the GTS package extracted from the currently mounted screen extension's ID.\n *\n * Returns `undefined` if no screen extension is currently mounted.\n *\n * @returns GTS package string of the active screen extension, or undefined\n *\n * @example\n * ```tsx\n * function ActivePackageIndicator() {\n * const activePackage = useActivePackage();\n *\n * if (!activePackage) {\n * return <div>No active screen</div>;\n * }\n *\n * return <div>Active package: {activePackage}</div>;\n * }\n * ```\n */\n// @cpt-begin:cpt-hai3-flow-react-bindings-use-active-package:p1:inst-call-active-package\n// @cpt-begin:cpt-hai3-dod-react-bindings-observation-hooks:p1:inst-call-active-package\nexport function useActivePackage(): string | undefined {\n const app = useHAI3();\n const registry = app.screensetsRegistry;\n\n // @cpt-begin:cpt-hai3-flow-react-bindings-use-active-package:p1:inst-guard-registry-active\n // @cpt-begin:cpt-hai3-algo-react-bindings-mfe-context-guard:p1:inst-throw-no-registry\n if (!registry) {\n throw new Error(\n 'useActivePackage requires the microfrontends plugin. ' +\n 'Add microfrontends() to your HAI3 app configuration.'\n );\n }\n // @cpt-end:cpt-hai3-flow-react-bindings-use-active-package:p1:inst-guard-registry-active\n // @cpt-end:cpt-hai3-algo-react-bindings-mfe-context-guard:p1:inst-throw-no-registry\n\n // @cpt-begin:cpt-hai3-flow-react-bindings-use-active-package:p1:inst-subscribe-store-active\n // Subscribe to store changes.\n // Any dispatch (including mount state updates) triggers a snapshot check.\n // The snapshot comparison ensures only actual active package changes cause re-renders.\n const subscribe = useCallback(\n (onStoreChange: () => void) => {\n return app.store.subscribe(onStoreChange);\n },\n [app.store]\n );\n // @cpt-end:cpt-hai3-flow-react-bindings-use-active-package:p1:inst-subscribe-store-active\n\n // @cpt-begin:cpt-hai3-algo-react-bindings-stable-snapshots:p1:inst-cache-ref\n // Cache the snapshot to maintain referential stability for useSyncExternalStore.\n // Only update when the active package actually changes.\n const cacheRef = useRef<{ activePackage: string | undefined }>({ activePackage: undefined });\n // @cpt-end:cpt-hai3-algo-react-bindings-stable-snapshots:p1:inst-cache-ref\n\n const getSnapshot = useCallback(() => {\n // @cpt-begin:cpt-hai3-flow-react-bindings-use-active-package:p1:inst-get-mounted-extension\n const mountedExtensionId = registry.getMountedExtension(FRONTX_SCREEN_DOMAIN);\n // @cpt-end:cpt-hai3-flow-react-bindings-use-active-package:p1:inst-get-mounted-extension\n\n // @cpt-begin:cpt-hai3-flow-react-bindings-use-active-package:p1:inst-return-undefined-active\n // Guard: if no extension is mounted, return undefined immediately\n if (!mountedExtensionId) {\n const result = undefined;\n // @cpt-begin:cpt-hai3-algo-react-bindings-stable-snapshots:p1:inst-return-cached\n if (result !== cacheRef.current.activePackage) {\n cacheRef.current = { activePackage: result };\n }\n return cacheRef.current.activePackage;\n // @cpt-end:cpt-hai3-algo-react-bindings-stable-snapshots:p1:inst-return-cached\n }\n // @cpt-end:cpt-hai3-flow-react-bindings-use-active-package:p1:inst-return-undefined-active\n\n // @cpt-begin:cpt-hai3-flow-react-bindings-use-active-package:p1:inst-extract-package\n // @cpt-begin:cpt-hai3-algo-react-bindings-stable-snapshots:p1:inst-compute-cache-key\n // Extract GTS package from the mounted extension ID\n const activePackage = extractGtsPackage(mountedExtensionId);\n // @cpt-end:cpt-hai3-algo-react-bindings-stable-snapshots:p1:inst-compute-cache-key\n\n // @cpt-begin:cpt-hai3-algo-react-bindings-stable-snapshots:p1:inst-update-cache\n if (activePackage !== cacheRef.current.activePackage) {\n cacheRef.current = { activePackage };\n }\n // @cpt-end:cpt-hai3-algo-react-bindings-stable-snapshots:p1:inst-update-cache\n\n return cacheRef.current.activePackage;\n // @cpt-end:cpt-hai3-flow-react-bindings-use-active-package:p1:inst-extract-package\n }, [registry]);\n\n return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n}\n// @cpt-end:cpt-hai3-flow-react-bindings-use-active-package:p1:inst-call-active-package\n// @cpt-end:cpt-hai3-dod-react-bindings-observation-hooks:p1:inst-call-active-package\n","/**\n * Ref Container Provider\n *\n * Concrete ContainerProvider that wraps a React ref.\n * Created by React components (like ExtensionDomainSlot) for use\n * by framework-level domain registration code.\n *\n * @packageDocumentation\n */\n// @cpt-dod:cpt-hai3-dod-react-bindings-ref-container-provider:p1\n\nimport type { RefObject } from 'react';\nimport { ContainerProvider } from '@gears-frontx/framework';\n\n/**\n * Concrete ContainerProvider that wraps a React ref.\n *\n * This provider reads the container element from a React ref at mount time.\n * It is designed to be created by React components but passed to domain\n * registration code (framework-level).\n *\n * Usage pattern:\n * 1. React component creates a ref via `useRef<HTMLDivElement>(null)`\n * 2. Framework-level code creates `RefContainerProvider` wrapping the ref\n * 3. Framework-level code passes the provider to `registerDomain(domain, provider)`\n * 4. When mount_ext is dispatched, the provider returns `ref.current`\n */\n// @cpt-begin:cpt-hai3-dod-react-bindings-ref-container-provider:p1:inst-1\nexport class RefContainerProvider extends ContainerProvider {\n constructor(private readonly containerRef: RefObject<HTMLDivElement>) {\n super();\n }\n\n getContainer(_extensionId: string): Element {\n if (!this.containerRef.current) {\n throw new Error('Container ref is not attached -- component may not be mounted yet');\n }\n return this.containerRef.current;\n }\n\n releaseContainer(_extensionId: string): void {\n // No-op for React ref -- the ref lifecycle is managed by React.\n // Container cleanup happens when the component unmounts.\n }\n}\n// @cpt-end:cpt-hai3-dod-react-bindings-ref-container-provider:p1:inst-1\n","/**\n * Extension Domain Slot Component\n *\n * React component that renders extensions within a domain slot.\n * Manages extension lifecycle (mount/unmount) and provides rendering context.\n *\n * @packageDocumentation\n */\n// @cpt-flow:cpt-hai3-flow-react-bindings-extension-domain-slot:p1\n// @cpt-state:cpt-hai3-state-react-bindings-extension-slot:p1\n// @cpt-dod:cpt-hai3-dod-react-bindings-extension-slot:p1\n\nimport React, { useEffect, useRef, useState } from 'react';\nimport type { ScreensetsRegistry, ParentMfeBridge } from '@gears-frontx/framework';\nimport {\n FRONTX_ACTION_MOUNT_EXT,\n FRONTX_ACTION_UNMOUNT_EXT,\n} from '@gears-frontx/framework';\n\n/**\n * Props for ExtensionDomainSlot component\n */\nexport interface ExtensionDomainSlotProps {\n /**\n * The screensets registry instance\n */\n registry: ScreensetsRegistry;\n\n /**\n * The domain ID for this slot\n */\n domainId: string;\n\n /**\n * The extension ID to render in this slot\n */\n extensionId: string;\n\n /**\n * Optional CSS class name for the container\n */\n className?: string;\n\n /**\n * Optional callback when extension is mounted\n */\n onMounted?: (bridge: ParentMfeBridge) => void;\n\n /**\n * Optional callback when extension is unmounted\n */\n onUnmounted?: () => void;\n\n /**\n * Optional error callback\n */\n onError?: (error: Error) => void;\n\n /**\n * Optional loading component\n */\n loadingComponent?: React.ReactNode;\n\n /**\n * Optional error component renderer\n */\n errorComponent?: (error: Error) => React.ReactNode;\n}\n\n/**\n * Extension Domain Slot Component\n *\n * Renders an extension within a domain slot. Manages the extension lifecycle:\n * - Mounts the extension on component mount\n * - Unmounts the extension on component unmount\n * - Handles loading and error states\n *\n * @example\n * ```tsx\n * <ExtensionDomainSlot\n * registry={registry}\n * domainId=\"gts.frontx.mfes.ext.domain.v1~frontx.screensets.layout.sidebar.v1\"\n * extensionId=\"gts.frontx.mfes.ext.extension.v1~myapp.sidebar.widget.v1\"\n * className=\"sidebar-slot\"\n * />\n * ```\n */\n// @cpt-begin:cpt-hai3-flow-react-bindings-extension-domain-slot:p1:inst-render-slot\n// @cpt-begin:cpt-hai3-dod-react-bindings-extension-slot:p1:inst-render-slot\nexport function ExtensionDomainSlot(props: ExtensionDomainSlotProps): React.ReactElement {\n const {\n registry,\n domainId,\n extensionId,\n className,\n onMounted,\n onUnmounted,\n onError,\n loadingComponent,\n errorComponent,\n } = props;\n\n const containerRef = useRef<HTMLDivElement>(null);\n // @cpt-begin:cpt-hai3-state-react-bindings-extension-slot:p1:inst-start-mount\n const [isLoading, setIsLoading] = useState(true);\n // @cpt-end:cpt-hai3-state-react-bindings-extension-slot:p1:inst-start-mount\n const [error, setError] = useState<Error | null>(null);\n const [bridge, setBridge] = useState<ParentMfeBridge | null>(null);\n\n useEffect(() => {\n let mounted = true;\n let currentBridge: ParentMfeBridge | null = null;\n\n async function mountExtension() {\n if (!containerRef.current) {\n return;\n }\n\n try {\n // @cpt-begin:cpt-hai3-state-react-bindings-extension-slot:p2:inst-retry-mount\n // Resetting error/loading here also handles the ERROR→MOUNTING transition when\n // extensionId or domainId props change (effect re-runs due to dependency array)\n setIsLoading(true);\n setError(null);\n // @cpt-end:cpt-hai3-state-react-bindings-extension-slot:p2:inst-retry-mount\n\n // @cpt-begin:cpt-hai3-flow-react-bindings-extension-domain-slot:p1:inst-dispatch-mount\n // Mount the extension via actions chain (auto-loads if not already loaded)\n // Container is provided by the domain's ContainerProvider (registered at domain registration time)\n await registry.executeActionsChain({\n action: {\n type: FRONTX_ACTION_MOUNT_EXT,\n target: domainId,\n payload: {\n extensionId,\n },\n },\n });\n // @cpt-end:cpt-hai3-flow-react-bindings-extension-domain-slot:p1:inst-dispatch-mount\n\n // @cpt-begin:cpt-hai3-flow-react-bindings-extension-domain-slot:p2:inst-race-cleanup\n // @cpt-begin:cpt-hai3-state-react-bindings-extension-slot:p1:inst-race-unmount\n if (!mounted) {\n // Component was unmounted while mounting - clean up\n await registry.executeActionsChain({\n action: {\n type: FRONTX_ACTION_UNMOUNT_EXT,\n target: domainId,\n payload: {\n extensionId,\n },\n },\n });\n return;\n }\n // @cpt-end:cpt-hai3-flow-react-bindings-extension-domain-slot:p2:inst-race-cleanup\n // @cpt-end:cpt-hai3-state-react-bindings-extension-slot:p1:inst-race-unmount\n\n // @cpt-begin:cpt-hai3-flow-react-bindings-extension-domain-slot:p1:inst-get-bridge\n // @cpt-begin:cpt-hai3-state-react-bindings-extension-slot:p1:inst-mount-success\n // Query the bridge after mount completes\n const newBridge = registry.getParentBridge(extensionId);\n if (!newBridge) {\n throw new Error(`Failed to obtain bridge for extension ${extensionId} after mount`);\n }\n\n currentBridge = newBridge;\n setBridge(newBridge);\n setIsLoading(false);\n // @cpt-end:cpt-hai3-flow-react-bindings-extension-domain-slot:p1:inst-get-bridge\n // @cpt-end:cpt-hai3-state-react-bindings-extension-slot:p1:inst-mount-success\n\n // @cpt-begin:cpt-hai3-flow-react-bindings-extension-domain-slot:p1:inst-notify-mounted\n // Notify parent\n if (onMounted) {\n onMounted(newBridge);\n }\n // @cpt-end:cpt-hai3-flow-react-bindings-extension-domain-slot:p1:inst-notify-mounted\n } catch (err) {\n // @cpt-begin:cpt-hai3-flow-react-bindings-extension-domain-slot:p1:inst-handle-mount-error\n // @cpt-begin:cpt-hai3-state-react-bindings-extension-slot:p1:inst-mount-error\n if (!mounted) {\n return;\n }\n\n const errorObj = err instanceof Error ? err : new Error(String(err));\n setError(errorObj);\n setIsLoading(false);\n\n if (onError) {\n onError(errorObj);\n }\n // @cpt-end:cpt-hai3-flow-react-bindings-extension-domain-slot:p1:inst-handle-mount-error\n // @cpt-end:cpt-hai3-state-react-bindings-extension-slot:p1:inst-mount-error\n }\n }\n\n // Start mounting\n void mountExtension();\n\n // @cpt-begin:cpt-hai3-flow-react-bindings-extension-domain-slot:p1:inst-cleanup-unmount\n // @cpt-begin:cpt-hai3-state-react-bindings-extension-slot:p1:inst-start-unmount\n // Cleanup on unmount\n return () => {\n mounted = false;\n\n if (currentBridge) {\n // Unmount extension asynchronously via actions chain\n void registry.executeActionsChain({\n action: {\n type: FRONTX_ACTION_UNMOUNT_EXT,\n target: domainId,\n payload: {\n extensionId,\n },\n },\n }).then(() => {\n if (onUnmounted) {\n onUnmounted();\n }\n });\n }\n };\n // @cpt-end:cpt-hai3-flow-react-bindings-extension-domain-slot:p1:inst-cleanup-unmount\n // @cpt-end:cpt-hai3-state-react-bindings-extension-slot:p1:inst-start-unmount\n }, [registry, domainId, extensionId, onMounted, onUnmounted, onError]);\n\n // @cpt-begin:cpt-hai3-flow-react-bindings-extension-domain-slot:p1:inst-show-loading\n // Render loading state\n if (isLoading) {\n return (\n <div className={className} data-domain-id={domainId} data-extension-id={extensionId}>\n {loadingComponent ?? <div>Loading extension...</div>}\n </div>\n );\n }\n // @cpt-end:cpt-hai3-flow-react-bindings-extension-domain-slot:p1:inst-show-loading\n\n // Render error state\n if (error) {\n return (\n <div className={className} data-domain-id={domainId} data-extension-id={extensionId}>\n {errorComponent ? errorComponent(error) : (\n <div>\n <strong>Error loading extension:</strong>\n <pre>{error.message}</pre>\n </div>\n )}\n </div>\n );\n }\n\n // Render the container for the mounted extension\n return (\n <div\n ref={containerRef}\n className={className}\n data-domain-id={domainId}\n data-extension-id={extensionId}\n data-bridge-active={bridge !== null}\n />\n );\n}\n// @cpt-end:cpt-hai3-flow-react-bindings-extension-domain-slot:p1:inst-render-slot\n// @cpt-end:cpt-hai3-dod-react-bindings-extension-slot:p1:inst-render-slot\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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;AAAA,YACF;AAAA,UACF;AAAA,QACF,CAAC,EAAE,KAAK,MAAM;AACZ,cAAI,aAAa;AACf,wBAAY;AAAA,UACd;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EAGF,GAAG,CAAC,UAAU,UAAU,aAAa,WAAW,aAAa,OAAO,CAAC;AAIrE,MAAI,WAAW;AACb,WACE,6CAAC,SAAI,WAAsB,kBAAgB,UAAU,qBAAmB,aACrE,8BAAoB,6CAAC,SAAI,kCAAoB,GAChD;AAAA,EAEJ;AAIA,MAAI,OAAO;AACT,WACE,6CAAC,SAAI,WAAsB,kBAAgB,UAAU,qBAAmB,aACrE,2BAAiB,eAAe,KAAK,IACpC,8CAAC,SACC;AAAA,mDAAC,YAAO,sCAAwB;AAAA,MAChC,6CAAC,SAAK,gBAAM,SAAQ;AAAA,OACtB,GAEJ;AAAA,EAEJ;AAGA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,KAAK;AAAA,MACL;AAAA,MACA,kBAAgB;AAAA,MAChB,qBAAmB;AAAA,MACnB,sBAAoB,WAAW;AAAA;AAAA,EACjC;AAEJ;;;AlBzLA,IAAAC,oBA0IO;AAGP,IAAAA,oBAA6D;AA4G7D,IAAAA,oBAGO;AAGP,IAAAA,oBAMO;AAGP,IAAAA,qBAIO;AAGP,IAAAA,qBAUO;AAGP,IAAAA,qBAGO;AAGP,IAAAA,qBAIO;AAGP,IAAAA,qBAGO;AA6BP,IAAAA,qBAOO;AAGP,IAAAA,qBAAwC;AAGxC,IAAAA,qBAAmE;AAGnE,IAAAA,qBAIO;AAyCP,IAAAA,qBAA8C;AAWvC,IAAM,WAAsC,mBAAAC;","names":["import_react","import_react","import_jsx_runtime","ReduxProvider","import_react_redux","import_react_redux","import_react","i18nRegistry","import_react","i18nRegistry","module","import_react","import_framework","formatDateFn","formatTimeFn","formatDateTimeFn","formatRelativeFn","formatNumberFn","formatPercentFn","formatCompactFn","formatCurrencyFn","compareStringsFn","createCollatorFn","import_react","themes","import_react","import_react","import_react","import_react","import_react","import_framework","import_framework","import_react","import_framework","import_jsx_runtime","mountExtension","import_framework","frameworkEventBus"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/FrontXProvider.tsx","../src/FrontXContext.tsx","../src/mfe/MfeContext.tsx","../src/mfe/MfeProvider.tsx","../src/queryClient.tsx","../src/hooks/QueryCache.ts","../src/hooks/useLatest.ts","../src/hooks/useCanAccess.ts","../src/components/CanAccess.tsx","../src/hooks/useAppDispatch.ts","../src/hooks/useAppSelector.ts","../src/hooks/useTranslation.ts","../src/hooks/useScreenTranslations.ts","../src/hooks/useFormatters.ts","../src/hooks/useTheme.ts","../src/hooks/useApiQuery.ts","../src/hooks/useApiSuspenseQuery.ts","../src/hooks/useApiInfiniteQuery.ts","../src/hooks/useApiSuspenseInfiniteQuery.ts","../src/hooks/useApiMutation.ts","../src/hooks/useApiStream.ts","../src/hooks/useQueryCache.ts","../src/mfe/hooks/useMfeBridge.ts","../src/mfe/hooks/useSharedProperty.ts","../src/mfe/hooks/useHostAction.ts","../src/mfe/hooks/useMfeRegistry.ts","../src/mfe/hooks/useDomainExtensions.ts","../src/mfe/hooks/useRegisteredPackages.ts","../src/mfe/ThemeAwareReactLifecycle.tsx","../src/mfe/domainTeardownCollector.ts","../src/mfe/components/ExtensionDomainSlot.tsx"],"sourcesContent":["/**\n * @gears-frontx/react - React Bindings\n *\n * This package provides:\n * - FrontXProvider context provider\n * - Type-safe hooks for state and actions\n * - MFE context, hooks, and components\n *\n * Layer: L3 (Depends on @gears-frontx/framework)\n */\n\n// ============================================================================\n// Provider\n// ============================================================================\n\nexport { FrontXProvider } from './FrontXProvider';\nexport { FrontXContext, useFrontX } from './FrontXContext';\nexport { invalidateQueryCacheForApp } from './queryClient';\nexport { CanAccess } from './components/CanAccess';\nexport type { CanAccessProps } from './types';\n\n// ============================================================================\n// Hooks\n// ============================================================================\n\nexport {\n useAppDispatch,\n useAppSelector,\n useTranslation,\n useScreenTranslations,\n useFormatters,\n useTheme,\n useApiQuery,\n useApiSuspenseQuery,\n useApiInfiniteQuery,\n useApiSuspenseInfiniteQuery,\n useApiMutation,\n useApiStream,\n useQueryCache,\n} from './hooks';\nexport { useCanAccess } from './hooks/useCanAccess';\n\nexport type { ApiQueryOverrides, ApiSuspenseQueryOverrides } from './hooks/useApiQuery';\nexport type {\n ApiInfiniteQueryOptions,\n ApiSuspenseInfiniteQueryOptions,\n ApiInfiniteQueryPageContext,\n} from './hooks/useApiInfiniteQuery';\nexport type { UseApiMutationOptions } from './hooks/useApiMutation';\nexport type { ApiStreamOptions, ApiStreamResult } from './hooks/useApiStream';\nexport type {\n QueryCache,\n QueryCacheInvalidateFilters,\n QueryCacheState,\n MutationCallbackContext,\n} from './hooks/QueryCache';\n\n// ============================================================================\n// MFE Context and Hooks\n// ============================================================================\n\nexport {\n MfeContext,\n useMfeContext,\n MfeProvider,\n useMfeBridge,\n ThemeAwareReactLifecycle,\n useSharedProperty,\n useHostAction,\n useMfeRegistry,\n useDomainExtensions,\n useRegisteredPackages,\n ExtensionDomainSlot,\n} from './mfe';\n\nexport type {\n MfeContextValue,\n MfeProviderProps,\n ExtensionDomainSlotProps,\n UseSharedPropertyOptions,\n} from './mfe';\n\n// ============================================================================\n// Type Exports\n// ============================================================================\n\nexport type {\n FrontXProviderProps,\n UseFrontXReturn,\n UseAppSelector,\n UseAppDispatchReturn,\n UseTranslationReturn,\n UseScreenTranslationsReturn,\n UseFormattersReturn,\n UseThemeReturn,\n ApiQueryResult,\n ApiSuspenseQueryResult,\n ApiInfiniteQueryResult,\n ApiSuspenseInfiniteQueryResult,\n ApiMutationResult,\n UseCanAccessResult,\n} from './types';\n\n// ============================================================================\n// Re-exports from @gears-frontx/framework for convenience\n// ============================================================================\n\n// These re-exports allow users to import everything from @gears-frontx/react\n// without needing to import from @gears-frontx/framework directly\n\nexport {\n // Core\n createFrontX,\n presets,\n\n // Backward compatibility constants\n ACCOUNTS_DOMAIN,\n\n // I18nRegistry class (capital I for backward compat)\n I18nRegistry,\n\n // Plugins\n themes,\n layout,\n i18n,\n effects,\n queryCache,\n queryCacheShared,\n subscribeQueryCacheRuntimeChanged,\n\n // Registries\n createThemeRegistry,\n\n // Flux (Event bus + Store)\n // NOTE: eventBus is re-exported separately below with augmented EventPayloadMap type\n\n // Store\n createStore,\n getStore,\n registerSlice,\n hasSlice,\n createSlice,\n\n // Layout domain exports\n layoutReducer,\n layoutDomainReducers,\n LAYOUT_SLICE_NAME,\n headerSlice,\n footerSlice,\n menuSlice,\n sidebarSlice,\n popupSlice,\n overlaySlice,\n headerActions,\n footerActions,\n menuActions,\n sidebarActions,\n popupActions,\n overlayActions,\n // Individual reducer functions - header\n setUser,\n setHeaderLoading,\n clearUser,\n // Individual reducer functions - footer\n setFooterVisible,\n setFooterConfig,\n toggleMenu,\n setMenuCollapsed,\n setMenuItems,\n setMenuVisible,\n setMenuConfig,\n toggleSidebar,\n setSidebarCollapsed,\n setSidebarPosition,\n setSidebarTitle,\n setSidebarContent,\n setSidebarVisible,\n setSidebarWidth,\n setSidebarConfig,\n openPopup,\n closePopup,\n closeTopPopup,\n closeAllPopups,\n showOverlay,\n hideOverlay,\n setOverlayVisible,\n\n // Tenant (app-level, not layout)\n TENANT_SLICE_NAME,\n tenantSlice,\n tenantActions,\n tenantReducer,\n setTenant,\n setTenantLoading,\n clearTenant,\n // Tenant effects and events\n initTenantEffects,\n changeTenant,\n clearTenantAction,\n setTenantLoadingState,\n TenantEvents,\n\n // Mock (app-level, not layout)\n mockSlice,\n mockActions,\n setMockEnabled,\n // Mock effects and events\n initMockEffects,\n toggleMockMode,\n MockEvents,\n\n // Auth\n auth,\n AuthEvents,\n frontxApiTransport,\n\n // API\n apiRegistry,\n BaseApiService,\n RestProtocol,\n RestEndpointProtocol,\n SseProtocol,\n SseStreamProtocol,\n // Plugin base classes\n ApiPluginBase,\n ApiPlugin,\n ApiProtocol,\n RestPlugin,\n RestPluginWithConfig,\n SsePlugin,\n SsePluginWithConfig,\n // Type guards\n isShortCircuit,\n isRestShortCircuit,\n isSseShortCircuit,\n // Mock plugin identification\n MOCK_PLUGIN,\n isMockPlugin,\n\n // I18n\n i18nRegistry,\n I18nRegistryImpl,\n createI18nRegistry,\n SUPPORTED_LANGUAGES,\n getLanguageMetadata,\n} from '@gears-frontx/framework';\n\n// Re-export i18n types from @gears-frontx/framework (correct layer access)\nexport { Language, TextDirection, LanguageDisplayMode } from '@gears-frontx/framework';\n\n// Re-export types from @gears-frontx/framework\nexport type {\n // Config\n FrontXConfig,\n FrontXPlugin,\n FrontXAppBuilder,\n FrontXApp,\n // Endpoint descriptors — L3 components import from @gears-frontx/react\n EndpointOptions,\n EndpointDescriptor,\n ParameterizedEndpointDescriptor,\n MutationDescriptor,\n // Stream descriptors\n StreamDescriptor,\n StreamStatus,\n PluginFactory,\n PluginProvides,\n PluginLifecycle,\n ThemeRegistry,\n ThemeConfig,\n Preset,\n Presets,\n ShowPopupPayload,\n ChangeThemePayload,\n SetLanguagePayload,\n AuthPluginConfig,\n AuthRuntime,\n AuthLoggedInPayload,\n AuthLoggedOutPayload,\n\n // Auth contract types\n AuthProvider,\n AuthSession,\n AuthContext,\n AuthCheckResult,\n AuthLoginInput,\n AuthCallbackInput,\n AuthTransition,\n AuthPermissions,\n AccessQuery,\n AccessDecision,\n AuthCapabilities,\n AuthState,\n AuthStateEvent,\n AuthStateListener,\n AuthUnsubscribe,\n\n // Flux (Events + Store)\n EventHandler,\n Subscription,\n\n // Store\n RootState,\n AppDispatch,\n SliceObject,\n FrontXStore,\n ReducerPayload,\n\n // Layout\n LayoutDomainState,\n HeaderUser,\n HeaderConfig,\n HeaderState,\n FooterConfig,\n FooterState,\n MenuItem,\n MenuState,\n SidebarPosition,\n SidebarState,\n PopupConfig,\n PopupState,\n PopupSliceState,\n OverlayConfig,\n OverlayState,\n LayoutState,\n RootStateWithLayout,\n LayoutDomainReducers,\n\n // Tenant types\n Tenant,\n TenantState,\n TenantChangedPayload,\n TenantClearedPayload,\n\n // Mock types\n MockState,\n MockTogglePayload,\n\n // API\n MockMap,\n ApiServiceConfig,\n JsonValue,\n JsonObject,\n JsonPrimitive,\n JsonCompatible,\n SseProtocolConfig,\n RestProtocolConfig,\n // Plugin context types (class-based plugin system)\n ApiRequestContext,\n ApiResponseContext,\n ShortCircuitResponse,\n PluginClass,\n ProtocolClass,\n ProtocolPluginType,\n BasePluginHooks,\n // Protocol-specific types\n RestPluginHooks,\n SsePluginHooks,\n RestRequestContext,\n RestResponseContext,\n ApiPluginErrorContext,\n SseConnectContext,\n EventSourceLike,\n RestShortCircuitResponse,\n SseShortCircuitResponse,\n\n // I18n\n I18nConfig,\n TranslationLoader,\n TranslationMap,\n TranslationDictionary,\n LanguageMetadata,\n I18nRegistryType,\n} from '@gears-frontx/framework';\n\n// ============================================================================\n// MFE Re-exports from @gears-frontx/framework (Layering Compliance)\n// ============================================================================\n\n// MFE Plugin factories\nexport {\n microfrontends,\n mock,\n} from '@gears-frontx/framework';\n\n// MFE Action functions\nexport {\n loadExtension,\n mountExtension,\n unmountExtension,\n registerExtension,\n unregisterExtension,\n} from '@gears-frontx/framework';\n\n// MFE Selectors\nexport {\n selectExtensionState,\n selectRegisteredExtensions,\n selectExtensionError,\n} from '@gears-frontx/framework';\n\n// MFE Domain constants\nexport {\n FRONTX_POPUP_DOMAIN,\n FRONTX_SIDEBAR_DOMAIN,\n FRONTX_SCREEN_DOMAIN,\n FRONTX_OVERLAY_DOMAIN,\n // Base ExtensionDomain constants\n screenDomain,\n sidebarDomain,\n popupDomain,\n overlayDomain,\n} from '@gears-frontx/framework';\n\n// MFE Type constants\nexport {\n FRONTX_SCREEN_EXTENSION_TYPE,\n FRONTX_MFE_ENTRY_MF,\n} from '@gears-frontx/framework';\n\n// MFE Action constants\nexport {\n FRONTX_ACTION_LOAD_EXT,\n FRONTX_ACTION_MOUNT_EXT,\n FRONTX_ACTION_UNMOUNT_EXT,\n} from '@gears-frontx/framework';\n\n// MFE Shared Property constants\nexport {\n FRONTX_SHARED_PROPERTY_THEME,\n FRONTX_SHARED_PROPERTY_LANGUAGE,\n} from '@gears-frontx/framework';\n\n// MFE Types\nexport type {\n MfeMountContext,\n Extension,\n ScreenExtension,\n ExtensionPresentation,\n ExtensionDomain,\n ActionsChain,\n Action,\n SharedProperty,\n LifecycleStage,\n LifecycleHook,\n MfeEntryLifecycle,\n MfeEntry,\n MfeEntryMF,\n JSONSchema,\n LoadExtPayload,\n MountExtPayload,\n UnmountExtPayload,\n MfeRegistryConfig,\n TypeSystemPlugin,\n // MF2 manifest types\n MfManifest,\n MfManifestMetaData,\n MfManifestRemoteEntry,\n MfManifestBuildInfo,\n MfManifestShared,\n MfManifestAssets,\n} from '@gears-frontx/framework';\n\n// MFE Abstract classes\nexport {\n ChildMfeBridge,\n ParentMfeBridge,\n MfeHandler,\n MfeBridgeFactory,\n MfeRegistry,\n MfeRegistryFactory,\n mfeRegistryFactory,\n ActionHandler,\n ExtensionDomainImplementation,\n ExtensionDomainImplementationFactory,\n ExtensionMounter,\n MountStrategy,\n ConcurrentMountStrategy,\n OptionalMountStrategy,\n ExclusiveMountStrategy,\n} from '@gears-frontx/framework';\n\nexport type {\n ContainerHooks,\n DomainContext,\n ActionPayload,\n} from '@gears-frontx/framework';\n\n// MFE Concrete implementations\nexport { MfeHandlerMF, gtsPlugin } from '@gears-frontx/framework';\n\n// GTS derived schemas (themeSchema, languageSchema, extensionScreenSchema) and the\n// protocol-specific mock plugins (RestMockPlugin, SseMockPlugin, MockEventSource)\n// are application-layer symbols owned by @gears-frontx/frontx-template-shell and\n// are no longer re-exported here — import them from the template package (#601).\n\n// MFE Utilities\nexport {\n createShadowRoot,\n injectCssVariables,\n extractGtsPackage,\n} from '@gears-frontx/framework';\n\n// MFE Plugin types\nexport type {\n MfeState,\n ExtensionRegistrationState,\n RegisterExtensionPayload,\n UnregisterExtensionPayload,\n} from '@gears-frontx/framework';\n\n// ============================================================================\n// Module Augmentation Support - EventPayloadMap Re-declaration\n// ============================================================================\n\n/**\n * Re-declare EventPayloadMap to enable module augmentation on @gears-frontx/react\n *\n * This creates a new declaration site in @gears-frontx/react that TypeScript can augment.\n * App-layer code can now use `declare module '@gears-frontx/react'` instead of importing\n * from L1 packages directly, maintaining proper layer architecture.\n *\n * ARCHITECTURE: This pattern allows L3+ code to augment event types without\n * violating layer boundaries by importing from L1 (@gears-frontx/state).\n *\n * IMPORTANT: We must also re-export eventBus with the augmented type to ensure\n * type safety. The eventBus instance uses this augmented EventPayloadMap.\n *\n * @example\n * ```typescript\n * // In app-layer code (e.g., src/app/events/bootstrapEvents.ts)\n * import '@gears-frontx/react';\n *\n * declare module '@gears-frontx/react' {\n * interface EventPayloadMap {\n * 'app/user/fetch': void;\n * 'app/user/loaded': { user: ApiUser };\n * }\n * }\n * ```\n */\nimport type { EventPayloadMap as FrameworkEventPayloadMap, EventBus } from '@gears-frontx/framework';\nimport { eventBus as frameworkEventBus } from '@gears-frontx/framework';\n\nexport interface EventPayloadMap extends FrameworkEventPayloadMap { }\n\n/**\n * Re-export eventBus with augmented EventPayloadMap type.\n * This ensures that code importing eventBus from @gears-frontx/react gets\n * type-safe access to both framework events and app-layer augmented events.\n */\nexport const eventBus: EventBus<EventPayloadMap> = frameworkEventBus as EventBus<EventPayloadMap>;\n","/**\n * FrontX Provider - Main provider component for FrontX applications\n *\n * React Layer: L3 (Depends on @gears-frontx/framework)\n *\n * Query cache lifecycle is owned by the queryCache() framework plugin (L2).\n * FrontXProvider reads the plugin-owned QueryClient from the app and mounts the\n * internal React provider around the tree when it is available.\n */\n// @cpt-flow:cpt-frontx-flow-react-bindings-bootstrap-provider:p1\n// @cpt-algo:cpt-frontx-algo-react-bindings-resolve-app:p1\n// @cpt-algo:cpt-frontx-algo-react-bindings-build-provider-tree:p1\n// @cpt-dod:cpt-frontx-dod-react-bindings-provider:p1\n// @cpt-dod:cpt-frontx-dod-request-lifecycle-query-provider:p2\n// @cpt-flow:cpt-frontx-flow-request-lifecycle-query-client-lifecycle:p2\n// @cpt-FEATURE:implement-endpoint-descriptors:p3\n\nimport React, { useEffect } from 'react';\nimport { Provider as ReduxProvider } from 'react-redux';\nimport type { Store } from '@reduxjs/toolkit';\nimport { FrontXContext } from './FrontXContext';\nimport { MfeProvider } from './mfe/MfeProvider';\nimport {\n hasFrontXQueryClientActivator,\n FrontXQueryClientProvider,\n useBootstrappedFrontXQueryClient,\n} from './queryClient';\nimport type { FrontXProviderProps } from './types';\n\n/**\n * FrontX Provider Component\n *\n * Provides the FrontX application context to all child components. The app\n * is built once per runtime by the caller (`createFrontX(...).build()`); the\n * provider never creates or destroys one.\n *\n * @example\n * ```tsx\n * const app = createFrontX().use(queryCache()).build();\n * <FrontXProvider app={app}>\n * <App />\n * </FrontXProvider>\n *\n * // With MFE bridge (for MFE components)\n * <FrontXProvider app={app} mfeBridge={{ bridge, extensionId, domainId }}>\n * <MyMfeApp />\n * </FrontXProvider>\n *\n * // QueryCache is resolved from the app's plugin composition\n * <FrontXProvider app={app}>\n * <MyMfeApp />\n * </FrontXProvider>\n * ```\n */\n// @cpt-begin:cpt-frontx-flow-react-bindings-bootstrap-provider:p1:inst-render-provider\n// @cpt-begin:cpt-frontx-dod-react-bindings-provider:p1:inst-render-provider\n// @cpt-begin:cpt-frontx-dod-request-lifecycle-query-provider:p2:inst-render-provider\nexport const FrontXProvider: React.FC<FrontXProviderProps> = ({\n children,\n app,\n mfeBridge,\n}) => {\n const queryClient = useBootstrappedFrontXQueryClient(app);\n const deferQuerySubtree =\n hasFrontXQueryClientActivator(app) && queryClient === undefined;\n\n useEffect(() => {\n if (\n queryClient ||\n hasFrontXQueryClientActivator(app) ||\n process.env.NODE_ENV === 'production' ||\n process.env.NODE_ENV === 'test' ||\n process.env.VITEST === 'true'\n ) {\n return;\n }\n\n console.warn(\n '[FrontXProvider] No query cache available. Add queryCache() or queryCacheShared() to your plugin composition. ' +\n 'useApiQuery/useApiMutation will fail without it.'\n );\n }, [app, queryClient]);\n\n // @cpt-begin:cpt-frontx-algo-react-bindings-build-provider-tree:p1:inst-wrap-frontx-context\n // @cpt-begin:cpt-frontx-algo-react-bindings-build-provider-tree:p1:inst-wrap-redux\n // @cpt-begin:cpt-frontx-flow-react-bindings-bootstrap-provider:p1:inst-set-frontx-context\n // @cpt-begin:cpt-frontx-flow-react-bindings-bootstrap-provider:p1:inst-set-redux-provider\n // @cpt-begin:cpt-frontx-flow-react-bindings-bootstrap-provider:p1:inst-render-query-provider\n // @cpt-begin:cpt-frontx-flow-react-bindings-bootstrap-provider:p1:inst-render-children\n // @cpt-begin:cpt-frontx-flow-request-lifecycle-query-client-lifecycle:p2:inst-render-query-provider\n // Provider order (outer to inner):\n // FrontXContext -> ReduxProvider -> QueryClientProvider -> children\n // queryCache()/queryCacheShared() own the shared QueryClient lifecycle.\n const content = (\n <FrontXContext.Provider value={app}>\n <ReduxProvider store={app.store as Store}>\n {/* app.store is FrontX-owned but Redux-compatible. Cast keeps react-redux happy. */}\n <FrontXQueryClientProvider queryClient={queryClient}>\n {deferQuerySubtree ? null : children}\n </FrontXQueryClientProvider>\n </ReduxProvider>\n </FrontXContext.Provider>\n );\n // @cpt-end:cpt-frontx-flow-request-lifecycle-query-client-lifecycle:p2:inst-render-query-provider\n // @cpt-end:cpt-frontx-flow-react-bindings-bootstrap-provider:p1:inst-render-children\n // @cpt-end:cpt-frontx-flow-react-bindings-bootstrap-provider:p1:inst-render-query-provider\n // @cpt-end:cpt-frontx-flow-react-bindings-bootstrap-provider:p1:inst-set-redux-provider\n // @cpt-end:cpt-frontx-flow-react-bindings-bootstrap-provider:p1:inst-set-frontx-context\n // @cpt-end:cpt-frontx-algo-react-bindings-build-provider-tree:p1:inst-wrap-redux\n // @cpt-end:cpt-frontx-algo-react-bindings-build-provider-tree:p1:inst-wrap-frontx-context\n\n // @cpt-begin:cpt-frontx-algo-react-bindings-build-provider-tree:p1:inst-wrap-mfe-conditional\n // @cpt-begin:cpt-frontx-flow-react-bindings-bootstrap-provider:p2:inst-wrap-mfe-provider\n // Wrap with MfeProvider if bridge is provided\n if (mfeBridge) {\n return (\n <MfeProvider value={mfeBridge}>\n {content}\n </MfeProvider>\n );\n }\n // @cpt-end:cpt-frontx-algo-react-bindings-build-provider-tree:p1:inst-wrap-mfe-conditional\n // @cpt-end:cpt-frontx-flow-react-bindings-bootstrap-provider:p2:inst-wrap-mfe-provider\n\n return content;\n};\n// @cpt-end:cpt-frontx-flow-react-bindings-bootstrap-provider:p1:inst-render-provider\n// @cpt-end:cpt-frontx-dod-react-bindings-provider:p1:inst-render-provider\n// @cpt-end:cpt-frontx-dod-request-lifecycle-query-provider:p2:inst-render-provider\n","/**\n * FrontX Context - React context for FrontX application\n *\n * React Layer: L3 (Depends on @gears-frontx/framework)\n */\n// @cpt-flow:cpt-frontx-flow-react-bindings-use-frontx:p2\n\nimport { createContext, useContext } from 'react';\nimport type { FrontXApp } from '@gears-frontx/framework';\n\n// ============================================================================\n// Context Definition\n// ============================================================================\n\n/**\n * FrontX Context\n * Holds the FrontX app instance for the application.\n */\nexport const FrontXContext = createContext<FrontXApp | null>(null);\n\n/**\n * Use the FrontX context.\n * Throws if used outside of FrontXProvider.\n *\n * @returns The FrontX app instance\n */\n// @cpt-begin:cpt-frontx-flow-react-bindings-use-frontx:p2:inst-call-use-frontx\nexport function useFrontX(): FrontXApp {\n const context = useContext(FrontXContext);\n\n // @cpt-begin:cpt-frontx-flow-react-bindings-use-frontx:p2:inst-guard-frontx-context\n if (!context) {\n throw new Error(\n 'useFrontX must be used within a FrontXProvider. ' +\n 'Wrap your application with <FrontXProvider> to access Gears FrontX features.'\n );\n }\n // @cpt-end:cpt-frontx-flow-react-bindings-use-frontx:p2:inst-guard-frontx-context\n\n // @cpt-begin:cpt-frontx-flow-react-bindings-use-frontx:p2:inst-return-frontx-app\n return context;\n // @cpt-end:cpt-frontx-flow-react-bindings-use-frontx:p2:inst-return-frontx-app\n}\n// @cpt-end:cpt-frontx-flow-react-bindings-use-frontx:p2:inst-call-use-frontx\n","/**\n * MFE Context - React context for MFE state\n *\n * Provides MFE bridge and metadata to child components.\n * Used by MFE components to access their runtime context.\n *\n * React Layer: L3 (Depends on @gears-frontx/framework)\n */\n// @cpt-flow:cpt-frontx-flow-react-bindings-mfe-provider:p1\n// @cpt-algo:cpt-frontx-algo-react-bindings-mfe-context-guard:p1\n// @cpt-dod:cpt-frontx-dod-react-bindings-mfe-hooks:p1\n\nimport { createContext, useContext } from 'react';\nimport type { ChildMfeBridge } from '@gears-frontx/framework';\n\n// ============================================================================\n// Context Value Types\n// ============================================================================\n\n/**\n * MFE Context Value\n * Contains bridge and metadata about the MFE instance.\n */\nexport interface MfeContextValue {\n /** Child bridge for communication with host */\n bridge: ChildMfeBridge;\n /** Extension ID */\n extensionId: string;\n /** Domain ID where MFE is mounted */\n domainId: string;\n}\n\n// ============================================================================\n// Context Definition\n// ============================================================================\n\n/**\n * MFE Context\n * Holds the MFE bridge and metadata for child components.\n */\nexport const MfeContext = createContext<MfeContextValue | null>(null);\n\n/**\n * Use the MFE context.\n * Throws if used outside of MFE context.\n *\n * @returns The MFE context value\n */\n// @cpt-begin:cpt-frontx-flow-react-bindings-mfe-provider:p1:inst-use-mfe-context\n// @cpt-begin:cpt-frontx-algo-react-bindings-mfe-context-guard:p1:inst-throw-no-mfe-context\n// @cpt-begin:cpt-frontx-dod-react-bindings-mfe-hooks:p1:inst-use-mfe-context\nexport function useMfeContext(): MfeContextValue {\n const context = useContext(MfeContext);\n\n if (!context) {\n throw new Error(\n 'useMfeContext must be used within a MfeProvider. ' +\n 'This hook can only be used inside MFE components.'\n );\n }\n\n return context;\n}\n// @cpt-end:cpt-frontx-flow-react-bindings-mfe-provider:p1:inst-use-mfe-context\n// @cpt-end:cpt-frontx-algo-react-bindings-mfe-context-guard:p1:inst-throw-no-mfe-context\n// @cpt-end:cpt-frontx-dod-react-bindings-mfe-hooks:p1:inst-use-mfe-context\n","/**\n * MFE Provider - Provides MFE context to child components\n *\n * Wraps MFE components with bridge and metadata.\n * Used by the MFE mounting system.\n *\n * MfeProvider does not create or own the shared QueryClient. When the host uses\n * queryCache() and the child app uses queryCacheShared(), overlapping queries\n * (same query key) are deduplicated and cached once across MFE boundaries.\n * Each MFE still uses its own apiRegistry and service instances in queryFn.\n *\n * React Layer: L3 (Depends on @gears-frontx/framework)\n */\n// @cpt-flow:cpt-frontx-flow-react-bindings-mfe-provider:p1\n// @cpt-dod:cpt-frontx-dod-react-bindings-mfe-hooks:p1\n// @cpt-flow:cpt-frontx-flow-request-lifecycle-query-client-lifecycle:p2\n\nimport React from 'react';\nimport { MfeContext, type MfeContextValue } from './MfeContext';\n\n// ============================================================================\n// Provider Props\n// ============================================================================\n\n/**\n * MFE Provider Props\n */\nexport interface MfeProviderProps {\n /** MFE context value */\n value: MfeContextValue;\n /** Child components */\n children: React.ReactNode;\n}\n\n// ============================================================================\n// Provider Component\n// ============================================================================\n\n/**\n * MFE Provider Component\n *\n * Provides MFE bridge and metadata to child components.\n * Used by the MFE mounting system to wrap MFE components.\n *\n * @example\n * ```tsx\n * <MfeProvider value={{ bridge, extensionId, domainId }}>\n * <MyMfeComponent />\n * </MfeProvider>\n * ```\n */\n// @cpt-begin:cpt-frontx-flow-react-bindings-mfe-provider:p1:inst-render-mfe-provider\n// @cpt-begin:cpt-frontx-flow-react-bindings-mfe-provider:p1:inst-set-mfe-context\n// @cpt-begin:cpt-frontx-dod-react-bindings-mfe-hooks:p1:inst-render-mfe-provider\n// @cpt-begin:cpt-frontx-flow-request-lifecycle-query-client-lifecycle:p2:inst-mfe-query-client\nexport const MfeProvider: React.FC<MfeProviderProps> = ({ value, children }) => {\n // MfeProvider only supplies the bridge context. Shared cache depends on\n // plugin-owned QueryClient reuse across each MFE root's FrontXProvider.\n return (\n <MfeContext.Provider value={value}>\n {children}\n </MfeContext.Provider>\n );\n};\n// @cpt-end:cpt-frontx-flow-react-bindings-mfe-provider:p1:inst-render-mfe-provider\n// @cpt-end:cpt-frontx-flow-react-bindings-mfe-provider:p1:inst-set-mfe-context\n// @cpt-end:cpt-frontx-dod-react-bindings-mfe-hooks:p1:inst-render-mfe-provider\n// @cpt-end:cpt-frontx-flow-request-lifecycle-query-client-lifecycle:p2:inst-mfe-query-client\n","import React, {\n createContext,\n useContext,\n useEffect,\n useLayoutEffect,\n useMemo,\n useState,\n} from 'react';\nimport {\n QueryClientContext,\n QueryClientProvider,\n type QueryClient,\n useInfiniteQuery,\n useMutation,\n useQuery,\n useSuspenseInfiniteQuery,\n useSuspenseQuery,\n type MutationFunctionContext,\n} from '@tanstack/react-query';\nimport {\n readQueryCacheScopeGeneration,\n recordQueryCacheScopeWriteDropped,\n subscribeQueryCacheRuntimeChanged,\n type EndpointDescriptor,\n type FrontXApp,\n} from '@gears-frontx/framework';\nimport type { ApiQueryOverrides, ApiSuspenseQueryOverrides } from './hooks/useApiQuery';\nimport type {\n ApiInfiniteQueryOptions,\n ApiInfiniteQueryPageContext,\n ApiSuspenseInfiniteQueryOptions,\n} from './hooks/useApiInfiniteQuery';\nimport type { UseApiMutationOptions } from './hooks/useApiMutation';\nimport {\n createQueryCache,\n type MutationCallbackContext,\n type QueryCache,\n type QueryCacheKey,\n} from './hooks/QueryCache';\nimport { useLatest } from './hooks/useLatest';\n\nconst APP_QUERY_CLIENT_SYMBOL = Symbol.for('frontx:query-cache:app-client');\nconst APP_QUERY_CLIENT_RESOLVER_SYMBOL = Symbol.for('frontx:query-cache:app-client-resolver');\nconst APP_QUERY_CLIENT_ACTIVATOR_SYMBOL = Symbol.for('frontx:query-cache:app-client-activator');\n\ntype QueryClientApp = FrontXApp & {\n [APP_QUERY_CLIENT_SYMBOL]?: QueryClient;\n [APP_QUERY_CLIENT_RESOLVER_SYMBOL]?: () => QueryClient | undefined;\n [APP_QUERY_CLIENT_ACTIVATOR_SYMBOL]?: () => QueryClient | undefined;\n};\n\nconst FrontXQueryClientContext = createContext<QueryClient | undefined>(undefined);\n\ntype RuntimeAwareEndpointDescriptor<TData> = EndpointDescriptor<TData> & {\n fetch(options?: { signal?: AbortSignal; staleTime?: number }): Promise<TData>;\n};\n\ntype AppResolvedQueryClient = {\n app: FrontXApp;\n queryClient: QueryClient;\n};\n\nconst useCommitEffect = typeof globalThis.window === 'undefined' ? useEffect : useLayoutEffect;\n\nexport function resolveFrontXQueryClient(app: FrontXApp): QueryClient | undefined {\n const clientApp = app as QueryClientApp;\n return clientApp[APP_QUERY_CLIENT_SYMBOL] ?? clientApp[APP_QUERY_CLIENT_RESOLVER_SYMBOL]?.();\n}\n\nexport function hasFrontXQueryClientActivator(app: FrontXApp): boolean {\n return typeof (app as QueryClientApp)[APP_QUERY_CLIENT_ACTIVATOR_SYMBOL] === 'function';\n}\n\nexport function activateFrontXQueryClient(app: FrontXApp): QueryClient | undefined {\n const clientApp = app as QueryClientApp;\n return clientApp[APP_QUERY_CLIENT_SYMBOL] ?? clientApp[APP_QUERY_CLIENT_ACTIVATOR_SYMBOL]?.();\n}\n\n/**\n * Imperatively invalidates cache entries for `target` on the QueryClient bound to `app`.\n * Use from non-React code (e.g. MFE actions); in components prefer `useQueryCache().invalidate`.\n */\nexport async function invalidateQueryCacheForApp(\n app: FrontXApp,\n target: EndpointDescriptor<unknown> | QueryCacheKey\n): Promise<void> {\n const queryClient = resolveFrontXQueryClient(app) ?? activateFrontXQueryClient(app);\n if (!queryClient) {\n throw new Error(\n '[invalidateQueryCacheForApp] No QueryClient on app. Ensure queryCache() or queryCacheShared() is in the plugin chain.'\n );\n }\n await createQueryCache(queryClient).invalidate(target);\n}\n\n/** Resolves the app-bound QueryClient without triggering plugin activation during render. */\nexport function bootstrapFrontXQueryClient(app: FrontXApp): QueryClient | undefined {\n return resolveFrontXQueryClient(app);\n}\n\nexport function useBootstrappedFrontXQueryClient(app: FrontXApp): QueryClient | undefined {\n const fromApp = useMemo(() => bootstrapFrontXQueryClient(app), [app]);\n const [eventResolvedClient, setEventResolvedClient] = useState<AppResolvedQueryClient | undefined>(\n undefined\n );\n const queryClient =\n fromApp ?? (eventResolvedClient?.app === app ? eventResolvedClient.queryClient : undefined);\n\n useCommitEffect(() => {\n if (fromApp || !hasFrontXQueryClientActivator(app)) {\n return;\n }\n\n const tryResolveQueryClient = () => {\n const nextQueryClient = resolveFrontXQueryClient(app) ?? activateFrontXQueryClient(app);\n if (nextQueryClient) {\n setEventResolvedClient((current) => {\n if (current?.app === app && current.queryClient === nextQueryClient) {\n return current;\n }\n\n return {\n app,\n queryClient: nextQueryClient,\n };\n });\n }\n };\n\n // Only activate after commit so abandoned renders cannot leak retainers/listeners.\n tryResolveQueryClient();\n\n const subscription = subscribeQueryCacheRuntimeChanged(() => {\n tryResolveQueryClient();\n });\n\n return () => {\n subscription.unsubscribe();\n };\n }, [app, fromApp]);\n\n return queryClient;\n}\n\nexport function FrontXQueryClientProvider({\n queryClient,\n children,\n}: Readonly<{\n queryClient: QueryClient | undefined;\n children: React.ReactNode;\n}>) {\n if (!queryClient) {\n return (\n <FrontXQueryClientContext.Provider value={undefined}>\n <QueryClientContext.Provider value={undefined}>{children}</QueryClientContext.Provider>\n </FrontXQueryClientContext.Provider>\n );\n }\n\n return (\n <FrontXQueryClientContext.Provider value={queryClient}>\n <QueryClientProvider client={queryClient}>{children}</QueryClientProvider>\n </FrontXQueryClientContext.Provider>\n );\n}\n\nexport function useOptionalFrontXQueryClient(): QueryClient | undefined {\n return useContext(FrontXQueryClientContext);\n}\n\nexport function useRequiredFrontXQueryClient(): QueryClient {\n const queryClient = useOptionalFrontXQueryClient();\n if (!queryClient) {\n throw new Error(\n '[FrontXProvider] No query cache available. Add queryCache() or queryCacheShared() to your plugin composition.'\n );\n }\n\n return queryClient;\n}\n\nfunction buildPageContext<TPage>(\n page: TPage,\n pages: readonly TPage[],\n descriptor: EndpointDescriptor<TPage>,\n descriptors: readonly EndpointDescriptor<TPage>[]\n): ApiInfiniteQueryPageContext<TPage> {\n return {\n page,\n pages,\n descriptor,\n descriptors,\n };\n}\n\nfunction normalizeFetchStaleTime(staleTime: unknown): number | undefined {\n if (staleTime === 'static') {\n return Number.POSITIVE_INFINITY;\n }\n\n // A function staleTime is resolved per query by TanStack; 0 keeps the fetch\n // cache from serving a response older than the query would accept.\n if (typeof staleTime === 'function') {\n return 0;\n }\n\n return typeof staleTime === 'number' ? staleTime : undefined;\n}\n\n/**\n * The staleTime the shared fetch cache uses, resolved the way TanStack\n * resolves it for the query: call site, then descriptor, then the\n * QueryClient defaults for the query key (global defaults with every\n * matching setQueryDefaults prefix spread over them).\n */\nfunction resolveFetchStaleTime<TData>(\n queryClient: QueryClient,\n queryKey: readonly unknown[],\n descriptor: EndpointDescriptor<TData>,\n overrideStaleTime?: number\n): number | undefined {\n const clientDefaults = {\n ...queryClient.getDefaultOptions().queries,\n ...queryClient.getQueryDefaults(queryKey),\n };\n return normalizeFetchStaleTime(\n overrideStaleTime ?? descriptor.staleTime ?? clientDefaults.staleTime\n );\n}\n\n/**\n * staleTime/gcTime for a query, with only the keys that are set. An explicit\n * `undefined` would override the QueryClient defaults (TanStack spreads the\n * query options over them), so a screen that remounts would refetch instead of\n * painting from cache.\n */\nfunction cacheTimeOptions(\n staleTime: number | undefined,\n gcTime: number | undefined\n): { staleTime?: number; gcTime?: number } {\n return {\n ...(staleTime === undefined ? {} : { staleTime }),\n ...(gcTime === undefined ? {} : { gcTime }),\n };\n}\n\nfunction fetchDescriptor<TData>(\n descriptor: EndpointDescriptor<TData>,\n options?: { signal?: AbortSignal; staleTime?: number }\n): Promise<TData> {\n return (descriptor as RuntimeAwareEndpointDescriptor<TData>).fetch(options);\n}\n\nexport function useFrontXQuery<TData = unknown, TError = Error>(\n descriptor: EndpointDescriptor<TData>,\n overrides?: ApiQueryOverrides\n) {\n const queryClient = useRequiredFrontXQueryClient();\n const staleTime = resolveFetchStaleTime(\n queryClient,\n descriptor.key,\n descriptor,\n overrides?.staleTime\n );\n const result = useQuery<TData, TError>({\n queryKey: descriptor.key as unknown[],\n queryFn: ({ signal }) => fetchDescriptor(descriptor, { signal, staleTime }),\n ...cacheTimeOptions(\n overrides?.staleTime ?? descriptor.staleTime,\n overrides?.gcTime ?? descriptor.gcTime\n ),\n ...(overrides?.enabled === undefined ? {} : { enabled: overrides.enabled }),\n });\n\n return {\n data: result.data,\n error: result.error,\n isLoading: result.isLoading,\n isFetching: result.isFetching,\n isError: result.isError,\n refetch: result.refetch,\n };\n}\n\nexport function useFrontXSuspenseQuery<TData = unknown, TError = Error>(\n descriptor: EndpointDescriptor<TData>,\n overrides?: ApiSuspenseQueryOverrides\n) {\n const queryClient = useRequiredFrontXQueryClient();\n const staleTime = resolveFetchStaleTime(\n queryClient,\n descriptor.key,\n descriptor,\n overrides?.staleTime\n );\n const result = useSuspenseQuery<TData, TError>({\n queryKey: descriptor.key as unknown[],\n queryFn: ({ signal }) => fetchDescriptor(descriptor, { signal, staleTime }),\n ...cacheTimeOptions(\n overrides?.staleTime ?? descriptor.staleTime,\n overrides?.gcTime ?? descriptor.gcTime\n ),\n });\n\n return {\n data: result.data,\n error: result.error,\n isFetching: result.isFetching,\n refetch: async () => {\n await result.refetch();\n },\n };\n}\n\nexport function useFrontXInfiniteQuery<TPage = unknown, TError = Error>(\n options: ApiInfiniteQueryOptions<TPage>\n) {\n const queryClient = useRequiredFrontXQueryClient();\n const result = useInfiniteQuery<\n TPage,\n TError,\n readonly TPage[],\n readonly unknown[],\n EndpointDescriptor<TPage>\n >({\n queryKey: options.initialPage.key,\n initialPageParam: options.initialPage,\n queryFn: ({ pageParam, signal }) =>\n fetchDescriptor(pageParam, {\n signal,\n staleTime: resolveFetchStaleTime(\n queryClient,\n options.initialPage.key,\n pageParam,\n options.staleTime\n ),\n }),\n getNextPageParam: (\n lastPage,\n allPages,\n lastPageDescriptor,\n allPageDescriptors\n ) =>\n options.getNextPage(\n buildPageContext(\n lastPage,\n allPages,\n lastPageDescriptor,\n allPageDescriptors\n )\n ),\n getPreviousPageParam: options.getPreviousPage\n ? (firstPage, allPages, firstPageDescriptor, allPageDescriptors) =>\n options.getPreviousPage?.(\n buildPageContext(\n firstPage,\n allPages,\n firstPageDescriptor,\n allPageDescriptors\n )\n )\n : undefined,\n select: (data) => data.pages,\n ...cacheTimeOptions(\n options.staleTime ?? options.initialPage.staleTime,\n options.gcTime ?? options.initialPage.gcTime\n ),\n maxPages: options.maxPages,\n ...(options.enabled === undefined ? {} : { enabled: options.enabled }),\n });\n\n return {\n data: result.data,\n error: result.error,\n isLoading: result.isLoading,\n isFetching: result.isFetching,\n isError: result.isError,\n hasNextPage: result.hasNextPage ?? false,\n hasPreviousPage: result.hasPreviousPage ?? false,\n isFetchingNextPage: result.isFetchingNextPage,\n isFetchingPreviousPage: result.isFetchingPreviousPage,\n fetchNextPage: async () => {\n await result.fetchNextPage();\n },\n fetchPreviousPage: async () => {\n await result.fetchPreviousPage();\n },\n refetch: async () => {\n await result.refetch();\n },\n };\n}\n\nexport function useFrontXSuspenseInfiniteQuery<TPage = unknown, TError = Error>(\n options: ApiSuspenseInfiniteQueryOptions<TPage>\n) {\n const queryClient = useRequiredFrontXQueryClient();\n const result = useSuspenseInfiniteQuery<\n TPage,\n TError,\n readonly TPage[],\n readonly unknown[],\n EndpointDescriptor<TPage>\n >({\n queryKey: options.initialPage.key,\n initialPageParam: options.initialPage,\n queryFn: ({ pageParam, signal }) =>\n fetchDescriptor(pageParam, {\n signal,\n staleTime: resolveFetchStaleTime(\n queryClient,\n options.initialPage.key,\n pageParam,\n options.staleTime\n ),\n }),\n getNextPageParam: (\n lastPage,\n allPages,\n lastPageDescriptor,\n allPageDescriptors\n ) =>\n options.getNextPage(\n buildPageContext(\n lastPage,\n allPages,\n lastPageDescriptor,\n allPageDescriptors\n )\n ),\n getPreviousPageParam: options.getPreviousPage\n ? (firstPage, allPages, firstPageDescriptor, allPageDescriptors) =>\n options.getPreviousPage?.(\n buildPageContext(\n firstPage,\n allPages,\n firstPageDescriptor,\n allPageDescriptors\n )\n )\n : undefined,\n select: (data) => data.pages,\n ...cacheTimeOptions(\n options.staleTime ?? options.initialPage.staleTime,\n options.gcTime ?? options.initialPage.gcTime\n ),\n maxPages: options.maxPages,\n });\n\n return {\n data: result.data,\n error: result.error,\n isFetching: result.isFetching,\n hasNextPage: result.hasNextPage ?? false,\n hasPreviousPage: result.hasPreviousPage ?? false,\n isFetchingNextPage: result.isFetchingNextPage,\n isFetchingPreviousPage: result.isFetchingPreviousPage,\n fetchNextPage: async () => {\n await result.fetchNextPage();\n },\n fetchPreviousPage: async () => {\n await result.fetchPreviousPage();\n },\n refetch: async () => {\n await result.refetch();\n },\n };\n}\n\n/** The cache scope a mutation started under: its QueryClient and that client's scope generation. */\ntype MutationScope = {\n queryClient: QueryClient;\n generation: number;\n};\n\n/**\n * The scope each mutation run started under, keyed by the context object\n * TanStack builds once per run and passes as the last argument to onMutate,\n * onSuccess, onError and onSettled. Recorded before the caller's onMutate\n * runs, so the callbacks find it even when that onMutate throws and TanStack\n * keeps no onMutate result.\n */\nconst mutationScopes = new WeakMap<MutationFunctionContext, MutationScope>();\n\n/**\n * A queryCache whose writes do nothing once the cache scope (mock mode,\n * tenant, session) has changed since the mutation started, so a response or a\n * snapshot from the old scope never lands in the new scope's cache. Reads\n * still go through.\n */\nfunction scopeBoundQueryCache(queryCache: QueryCache, scope: MutationScope): QueryCache {\n const scopeChanged = () => readQueryCacheScopeGeneration(scope.queryClient) !== scope.generation;\n // A dropped write that would change the cache is recorded, so a session check that keeps the\n // session knows it has something to refresh. A dropped cancel changes nothing.\n const dropped = (): boolean => {\n if (!scopeChanged()) return false;\n recordQueryCacheScopeWriteDropped(scope.queryClient, scope.generation);\n return true;\n };\n return {\n get: queryCache.get,\n getState: queryCache.getState,\n set: (key, dataOrUpdater) => {\n if (!dropped()) queryCache.set(key, dataOrUpdater);\n },\n cancel: (key) => (scopeChanged() ? Promise.resolve() : queryCache.cancel(key)),\n invalidate: (key) => (dropped() ? Promise.resolve() : queryCache.invalidate(key)),\n invalidateMany: (filters) => (dropped() ? Promise.resolve() : queryCache.invalidateMany(filters)),\n remove: (key) => {\n if (!dropped()) queryCache.remove(key);\n },\n };\n}\n\n// The cache is built from the recorded QueryClient, not the latest render's,\n// so the scope check and the writes always target the same client even when\n// the provider swaps its QueryClient mid-flight. No scope only for a run that\n// skipped onMutate (TanStack resuming a restored paused mutation).\nfunction scopeBoundCallbackCtx(\n callbackCtx: MutationCallbackContext,\n scope: MutationScope | undefined\n): MutationCallbackContext {\n return scope\n ? { queryCache: scopeBoundQueryCache(createQueryCache(scope.queryClient), scope) }\n : callbackCtx;\n}\n\nexport function useFrontXMutation<\n TData = unknown,\n TError = Error,\n TVariables = void,\n TContext = unknown,\n>(\n options: UseApiMutationOptions<TData, TError, TVariables, TContext>,\n callbackCtx: MutationCallbackContext\n) {\n const queryClient = useRequiredFrontXQueryClient();\n\n const latestRef = useLatest({ options, callbackCtx, queryClient });\n const fetchAbortControllersRef = React.useRef<Set<AbortController>>(new Set());\n\n // Effect event: reads abortOnUnmount from the most recent render, not\n // whatever option value was current when the unmount effect was set up.\n const abortFetchesOnUnmount = React.useEffectEvent(() => {\n if (options.abortOnUnmount) {\n for (const controller of fetchAbortControllersRef.current) {\n controller.abort();\n }\n fetchAbortControllersRef.current.clear();\n }\n });\n\n React.useEffect(() => {\n return () => {\n abortFetchesOnUnmount();\n };\n }, []);\n\n const mutationFn = React.useCallback((variables: TVariables, context: MutationFunctionContext) => {\n const cancelOnSupersede = latestRef.current.options.cancelOnSupersede;\n if (cancelOnSupersede) {\n for (const controller of fetchAbortControllersRef.current) {\n controller.abort();\n }\n fetchAbortControllersRef.current.clear();\n }\n\n const controller = new AbortController();\n fetchAbortControllersRef.current.add(controller);\n\n const librarySignal = (context as MutationFunctionContext & { signal?: AbortSignal }).signal;\n if (cancelOnSupersede && librarySignal) {\n if (librarySignal.aborted) {\n controller.abort();\n } else {\n librarySignal.addEventListener('abort', () => controller.abort(), { once: true });\n }\n }\n\n return latestRef.current.options.endpoint\n .fetch(variables, { signal: controller.signal })\n .finally(() => {\n fetchAbortControllersRef.current.delete(controller);\n });\n // latestRef's identity never changes (useLatest returns a stable ref\n // object) — listing it satisfies exhaustive-deps without recreating this\n // callback on every render.\n }, [latestRef]);\n\n // onMutate always runs: it records the scope the mutation starts under,\n // and every callback gets a queryCache bound to that scope.\n const onMutate = React.useCallback(async (\n variables: TVariables,\n mutationFnContext: MutationFunctionContext\n ): Promise<TContext | undefined> => {\n const current = latestRef.current;\n const scope: MutationScope = {\n queryClient: current.queryClient,\n generation: readQueryCacheScopeGeneration(current.queryClient),\n };\n mutationScopes.set(mutationFnContext, scope);\n return current.options.onMutate?.(\n variables,\n scopeBoundCallbackCtx(current.callbackCtx, scope)\n );\n // latestRef's identity never changes - see mutationFn above.\n }, [latestRef]);\n\n const onSuccess = React.useCallback((\n data: TData,\n variables: TVariables,\n context: TContext | undefined,\n mutationFnContext: MutationFunctionContext\n ) => {\n const current = latestRef.current;\n return current.options.onSuccess?.(\n data,\n variables,\n context,\n scopeBoundCallbackCtx(current.callbackCtx, mutationScopes.get(mutationFnContext))\n );\n // latestRef's identity never changes - see mutationFn above.\n }, [latestRef]);\n\n const onError = React.useCallback((\n error: TError,\n variables: TVariables,\n context: TContext | undefined,\n mutationFnContext: MutationFunctionContext\n ) => {\n const current = latestRef.current;\n return current.options.onError?.(\n error,\n variables,\n context,\n scopeBoundCallbackCtx(current.callbackCtx, mutationScopes.get(mutationFnContext))\n );\n // latestRef's identity never changes - see mutationFn above.\n }, [latestRef]);\n\n const onSettled = React.useCallback((\n data: TData | undefined,\n error: TError | null,\n variables: TVariables,\n context: TContext | undefined,\n mutationFnContext: MutationFunctionContext\n ) => {\n const current = latestRef.current;\n return current.options.onSettled?.(\n data,\n error,\n variables,\n context,\n scopeBoundCallbackCtx(current.callbackCtx, mutationScopes.get(mutationFnContext))\n );\n // latestRef's identity never changes - see mutationFn above.\n }, [latestRef]);\n\n const mutation = useMutation<TData, TError, TVariables, TContext | undefined>({\n mutationFn,\n onMutate,\n onSuccess: options.onSuccess ? onSuccess : undefined,\n onError: options.onError ? onError : undefined,\n onSettled: options.onSettled ? onSettled : undefined,\n });\n\n return {\n mutate: mutation.mutate as (variables: TVariables) => void,\n mutateAsync: mutation.mutateAsync as (variables: TVariables) => Promise<TData>,\n isPending: mutation.isPending,\n error: mutation.error,\n data: mutation.data,\n reset: mutation.reset,\n };\n}\n","/**\n * QueryCache — restricted interface for interacting with the shared QueryClient.\n *\n * MFEs and screen-set components access the cache only through this sanctioned\n * public interface. It is injected as { queryCache } into useApiMutation\n * callbacks and also returned by useQueryCache() for controlled imperative\n * cache access.\n */\n// @cpt-dod:cpt-frontx-dod-request-lifecycle-use-api-mutation:p2\n// @cpt-flow:cpt-frontx-flow-request-lifecycle-use-api-mutation:p2:inst-create-query-cache\n// @cpt-FEATURE:implement-endpoint-descriptors:p3\n\nimport type { EndpointDescriptor } from '@gears-frontx/framework';\nimport { eventBus } from '@gears-frontx/framework';\nimport { type QueryClient, type QueryState } from '@tanstack/react-query';\n\nexport type QueryCacheKey = readonly unknown[];\nexport type QueryCacheRefetchMode = 'active' | 'inactive' | 'all' | 'none';\nexport type QueryCacheInvalidateTarget =\n | EndpointDescriptor<unknown>\n | QueryCacheKey\n | null\n | undefined;\n\nexport interface QueryCacheState<TData = unknown, TError = Error> {\n data: TData | undefined;\n dataUpdatedAt: number;\n error: TError | null;\n errorUpdatedAt: number;\n fetchFailureCount: number;\n fetchFailureReason: TError | null;\n fetchStatus: 'fetching' | 'paused' | 'idle';\n isInvalidated: boolean;\n status: 'pending' | 'error' | 'success';\n}\n\nexport type QueryCacheInvalidateFilters = {\n queryKey?: QueryCacheInvalidateTarget;\n exact?: boolean;\n refetchType?: QueryCacheRefetchMode;\n};\n\ntype QueryCacheUpdater<T> = T | ((old: T | undefined) => T | undefined);\n\ntype CacheInvalidateEvent = {\n queryKey: QueryCacheKey;\n exact?: boolean;\n refetchType?: QueryCacheRefetchMode;\n source?: string;\n};\n\ntype CacheSetEvent = {\n queryKey: QueryCacheKey;\n dataOrUpdater: QueryCacheUpdater<unknown>;\n source?: string;\n};\n\ntype CacheRemoveEvent = {\n queryKey: QueryCacheKey;\n source?: string;\n};\n\nconst QUERY_CLIENT_BROADCAST_TARGET = Symbol.for('frontx:query-cache:broadcast-target');\nconst QUERY_CLIENT_BROADCAST_COUNTER = Symbol.for('frontx:query-cache:broadcast-counter');\n\ntype QueryClientWithMetadata = QueryClient & {\n [QUERY_CLIENT_BROADCAST_TARGET]?: string;\n};\n\ntype QueryClientCounterHost = typeof globalThis & {\n [QUERY_CLIENT_BROADCAST_COUNTER]?: number;\n};\n\nfunction emitCacheEvent(event: string, payload: unknown): void {\n (eventBus.emit as (eventType: string, payload: unknown) => void)(event, payload);\n}\n\nfunction ensureBroadcastSource(queryClient: QueryClient): string {\n const clientWithMetadata = queryClient as QueryClientWithMetadata;\n const existingSource = clientWithMetadata[QUERY_CLIENT_BROADCAST_TARGET];\n if (typeof existingSource === 'string' && existingSource.length > 0) {\n return existingSource;\n }\n\n const host = globalThis as QueryClientCounterHost;\n const nextCounter = (host[QUERY_CLIENT_BROADCAST_COUNTER] ?? 0) + 1;\n host[QUERY_CLIENT_BROADCAST_COUNTER] = nextCounter;\n\n const source = `query-cache-${nextCounter}`;\n clientWithMetadata[QUERY_CLIENT_BROADCAST_TARGET] = source;\n return source;\n}\n\n// @cpt-begin:implement-endpoint-descriptors:p3:inst-resolve-key\nexport function resolveKey(target: EndpointDescriptor<unknown> | QueryCacheKey): readonly unknown[] {\n if (\n target !== null &&\n typeof target === 'object' &&\n !Array.isArray(target) &&\n 'key' in target &&\n 'fetch' in target &&\n Array.isArray(target.key) &&\n typeof target.fetch === 'function'\n ) {\n return target.key;\n }\n\n return target as readonly unknown[];\n}\n// @cpt-end:implement-endpoint-descriptors:p3:inst-resolve-key\n\n// @cpt-begin:cpt-frontx-dod-request-lifecycle-use-api-mutation:p2:inst-query-cache-interface\nexport interface QueryCache {\n get<T>(queryKey: EndpointDescriptor<unknown> | QueryCacheKey): T | undefined;\n getState<TData = unknown, TError = Error>(\n queryKey: EndpointDescriptor<unknown> | QueryCacheKey\n ): QueryCacheState<TData, TError> | undefined;\n set<T>(\n queryKey: EndpointDescriptor<unknown> | QueryCacheKey,\n dataOrUpdater: T | ((old: T | undefined) => T | undefined)\n ): void;\n cancel(queryKey: EndpointDescriptor<unknown> | QueryCacheKey): Promise<void>;\n invalidate(queryKey: EndpointDescriptor<unknown> | QueryCacheKey): Promise<void>;\n invalidateMany(filters?: QueryCacheInvalidateFilters | null): Promise<void>;\n remove(queryKey: EndpointDescriptor<unknown> | QueryCacheKey): void;\n}\n// @cpt-end:cpt-frontx-dod-request-lifecycle-use-api-mutation:p2:inst-query-cache-interface\n\n// @cpt-begin:cpt-frontx-dod-request-lifecycle-use-api-mutation:p2:inst-mutation-callback-context\nexport interface MutationCallbackContext {\n queryCache: QueryCache;\n}\n// @cpt-end:cpt-frontx-dod-request-lifecycle-use-api-mutation:p2:inst-mutation-callback-context\n\nfunction toQueryUpdater<T>(\n dataOrUpdater: QueryCacheUpdater<T>\n): (old: T | undefined) => T | undefined {\n if (typeof dataOrUpdater === 'function') {\n return dataOrUpdater as (old: T | undefined) => T | undefined;\n }\n\n return () => dataOrUpdater;\n}\n\nfunction mapQueryState<TData, TError = Error>(\n state: QueryState<TData, TError>\n): QueryCacheState<TData, TError> {\n return {\n data: state.data,\n dataUpdatedAt: state.dataUpdatedAt,\n error: state.error,\n errorUpdatedAt: state.errorUpdatedAt,\n fetchFailureCount: state.fetchFailureCount,\n fetchFailureReason: state.fetchFailureReason,\n fetchStatus: state.fetchStatus,\n isInvalidated: state.isInvalidated,\n status: state.status,\n };\n}\n\n// @cpt-begin:implement-endpoint-descriptors:p3:inst-create-query-cache\nexport function createQueryCache(queryClient: QueryClient): QueryCache {\n return {\n get: <T,>(key: EndpointDescriptor<unknown> | QueryCacheKey): T | undefined => {\n return queryClient.getQueryData<T>(resolveKey(key));\n },\n getState: <TData = unknown, TError = Error>(key: EndpointDescriptor<unknown> | QueryCacheKey) => {\n const state = queryClient.getQueryState<TData, TError>(resolveKey(key));\n return state ? mapQueryState(state) : undefined;\n },\n set: <T,>(key: EndpointDescriptor<unknown> | QueryCacheKey, dataOrUpdater: QueryCacheUpdater<T>): void => {\n const resolvedKey = resolveKey(key);\n queryClient.setQueryData<T>(resolvedKey, toQueryUpdater(dataOrUpdater));\n emitCacheEvent('cache/set', {\n queryKey: resolvedKey,\n dataOrUpdater: dataOrUpdater as QueryCacheUpdater<unknown>,\n source: ensureBroadcastSource(queryClient),\n } satisfies CacheSetEvent);\n },\n cancel: (key: EndpointDescriptor<unknown> | QueryCacheKey): Promise<void> => {\n return queryClient.cancelQueries({ queryKey: resolveKey(key) });\n },\n invalidate: (key: EndpointDescriptor<unknown> | QueryCacheKey): Promise<void> => {\n const resolvedKey = resolveKey(key);\n const result = queryClient.invalidateQueries({ queryKey: resolvedKey });\n emitCacheEvent('cache/invalidate', {\n queryKey: resolvedKey,\n source: ensureBroadcastSource(queryClient),\n } satisfies CacheInvalidateEvent);\n return result;\n },\n invalidateMany: (filters): Promise<void> => {\n if (filters?.queryKey == null) {\n return Promise.resolve();\n }\n\n const resolvedKey = resolveKey(filters.queryKey);\n if (!Array.isArray(resolvedKey) || resolvedKey.length === 0) {\n return Promise.resolve();\n }\n\n const payload = {\n ...filters,\n queryKey: resolvedKey,\n };\n const result = queryClient.invalidateQueries(payload);\n emitCacheEvent('cache/invalidate', {\n ...payload,\n source: ensureBroadcastSource(queryClient),\n } satisfies CacheInvalidateEvent);\n return result;\n },\n remove: (key: EndpointDescriptor<unknown> | QueryCacheKey): void => {\n const resolvedKey = resolveKey(key);\n queryClient.removeQueries({ queryKey: resolvedKey });\n emitCacheEvent('cache/remove', {\n queryKey: resolvedKey,\n source: ensureBroadcastSource(queryClient),\n } satisfies CacheRemoveEvent);\n },\n };\n}\n// @cpt-end:implement-endpoint-descriptors:p3:inst-create-query-cache\n","/**\n * useLatest - keeps a ref pinned to the most recently rendered value\n *\n * A handful of hooks/components in this package need to read the current\n * value of a prop or option from inside a callback or effect-cleanup closure\n * that must NOT re-run every time that value changes (e.g. a stable\n * useCallback with `[]` deps, or a mount/unmount effect keyed on identity\n * rather than on every option). Stashing the value in a ref sidesteps the\n * closure staleness without pulling the value into the dependency array.\n *\n * The write happens inside a deps-less effect (runs after every commit)\n * rather than during render, because refs must not be mutated while\n * rendering: render can be invoked more than once per commit (React\n * StrictMode's double-invoke, and future concurrent-rendering paths that\n * may discard a render), so a render-time write can leave the ref out of\n * sync with what was actually committed to the DOM. A deps-less effect\n * runs exactly once per real commit, so the ref always reflects the value\n * that was last rendered.\n */\n\nimport { useEffect, useRef, type RefObject } from 'react';\n\n/**\n * Returns a ref that always holds the most recently rendered `value`.\n *\n * The ref identity is stable across renders (same object returned every\n * time), so it is safe to add to a `useCallback`/`useEffect` dependency\n * array without causing the callback/effect to be recreated.\n */\nexport function useLatest<T>(value: T): RefObject<T> {\n const ref = useRef(value);\n\n // Deps-less: must run after every render so `ref.current` never lags\n // behind the value that was just committed. See module doc for why this\n // write cannot happen during render itself.\n useEffect(() => {\n ref.current = value;\n });\n\n return ref;\n}\n","import { useEffect, useState } from 'react';\nimport type {\n AccessQuery,\n AccessRecord,\n AuthRuntime,\n FrontXApp,\n} from '@gears-frontx/framework';\nimport { useFrontX } from '../FrontXContext';\nimport type { UseCanAccessResult } from '../types';\n\n/**\n * Stable string key for an AccessQuery.\n * Record keys are sorted so { b:1, a:2 } and { a:2, b:1 } yield the same key.\n * Values include an explicit type prefix to avoid collisions:\n * 1 !== \"1\", null !== \"null\", true !== \"true\".\n */\nfunction serializeRecordValue(value: AccessRecord[string]): string {\n if (value === null) return 'n:';\n if (typeof value === 'string') return `s:${value}`;\n if (typeof value === 'number') {\n // Preserve -0 distinction for completeness.\n return `d:${Object.is(value, -0) ? '-0' : String(value)}`;\n }\n return value ? 'b:1' : 'b:0';\n}\n\nfunction accessQueryKey(query: AccessQuery): string {\n const { action, resource, record } = query;\n // JSON-encode the tuple so delimiter characters in any component\n // (action / resource / record keys / string values) cannot collide.\n // Using Object.entries avoids dynamic bracket access on `record` (static\n // analyzers flag `record[k]` as a potential object-injection sink).\n const normalizedRecord = record\n ? Object.entries(record)\n .sort(([a], [b]) => a.localeCompare(b))\n .map(([k, v]) => [k, serializeRecordValue(v)] as const)\n : null;\n return JSON.stringify([action, resource, normalizedRecord]);\n}\n\ntype FrontXAuthAppContract = FrontXApp & {\n auth?: AuthRuntime;\n};\n\nfunction getAuthRuntime(app: FrontXApp): AuthRuntime | null {\n return (app as FrontXAuthAppContract).auth ?? null;\n}\n\n// Module-level constant so the no-auth-runtime denial keeps a stable identity\n// across renders — consumers can put the hook result in dependency lists\n// without re-firing every render.\nconst DENIED_NO_AUTH: UseCanAccessResult = { allow: false, isResolving: false };\n\n/**\n * Declarative RBAC guard hook.\n *\n * Pessimistic: `allow` is false until an explicit 'allow' decision arrives.\n * Aborts the in-flight canAccess call on unmount and on query change.\n *\n * State machine:\n * mount -> Pending (allow=false, isResolving=true)\n * Pending -> 'allow' -> Allowed (allow=true, isResolving=false)\n * Pending -> 'deny' -> Denied (allow=false, isResolving=false)\n * Pending -> error -> Denied (allow=false, isResolving=false)\n * Allowed -> query-change -> Pending (re-pessimize)\n * Denied -> query-change -> Pending (re-pessimize)\n */\nexport function useCanAccess<TRecord extends AccessRecord = AccessRecord>(\n query: AccessQuery<TRecord>,\n): UseCanAccessResult {\n const app = useFrontX();\n\n // Resolved once per `app` change; read here (not just inside the effect) so both the\n // \"no auth runtime\" case and the \"pending\" reset below can be derived/adjusted at\n // render time instead of requiring a synchronous setState from the effect.\n const auth = getAuthRuntime(app);\n\n const stableKey = accessQueryKey(query as AccessQuery);\n\n // Derived state: store the query value whose key matches `stableKey`. We\n // refresh it during render whenever `stableKey` changes (React derived-state\n // pattern) so the effect can depend on the stored value directly — its\n // referential identity tracks the access intent, not the parent render cycle.\n const [stableQuery, setStableQuery] = useState<AccessQuery>(() => query as AccessQuery);\n // Tracks the (auth, stableKey) combination the effect below was last run for —\n // exactly its dependency list — so every input that would restart the access check\n // also re-pessimizes `result` here, during render, instead of via a setState call\n // inside the effect.\n //\n // `app` is not part of it. The decision is the auth runtime's, and a host that\n // rebuilds its app object around the same runtime has changed nothing the check\n // reads; tracking it would re-pessimize an answered guard back to Pending and\n // ask the same question again.\n const [runState, setRunState] = useState({ auth, stableKey });\n const [result, setResult] = useState<UseCanAccessResult>({ allow: false, isResolving: true });\n\n if (runState.auth !== auth || runState.stableKey !== stableKey) {\n setRunState({ auth, stableKey });\n setStableQuery(query as AccessQuery);\n // Re-pessimize at render time: every (auth, stableKey) combination\n // the effect below runs for enters Pending here, before the async\n // decision starts.\n setResult({ allow: false, isResolving: true });\n }\n\n useEffect(() => {\n if (!auth) {\n // No auth runtime on the app: the returned result is derived below\n // (`auth ? result : DENIED_NO_AUTH`), so there is nothing to synchronize here.\n return;\n }\n\n // `result` is re-pessimized during render above for every\n // (auth, stableKey) combination this effect runs for — no setState needed\n // here before starting the async decision.\n let alive = true;\n const controller = new AbortController();\n\n void auth\n .canAccess(stableQuery, { signal: controller.signal })\n .then((decision) => {\n if (alive) {\n setResult({ allow: decision === 'allow', isResolving: false });\n }\n })\n .catch(() => {\n if (alive) {\n setResult({ allow: false, isResolving: false });\n }\n });\n\n return () => {\n alive = false;\n controller.abort();\n };\n }, [auth, stableQuery]);\n\n return auth ? result : DENIED_NO_AUTH;\n}\n","// @cpt-FEATURE:cpt-frontx-feature-auth-plugin:p1\n// @cpt-flow:cpt-frontx-flow-auth-plugin-rbac-guard:p1\nimport type { ReactElement } from 'react';\nimport type { AccessRecord } from '@gears-frontx/framework';\nimport { useCanAccess } from '../hooks/useCanAccess';\nimport type { CanAccessProps } from '../types';\n\n/**\n * Declarative RBAC guard component.\n *\n * Pessimistic: renders `denied` (or `loading` if provided) until an explicit\n * 'allow' decision arrives from app.auth.canAccess. Only renders `allowed`\n * after a confirmed allow.\n *\n * Example:\n * <CanAccess\n * query={{ action: AppAction.InvoicesRead, resource: ResourceKind.Invoice }}\n * allowed={<InvoiceList />}\n * denied={<AccessDenied />}\n * loading={<Spinner />}\n * />\n */\nexport function CanAccess<TRecord extends AccessRecord = AccessRecord>({\n query,\n allowed,\n denied = null,\n loading,\n}: CanAccessProps<TRecord>): ReactElement | null {\n // @cpt-begin:cpt-frontx-flow-auth-plugin-rbac-guard:p1:inst-component-render\n const { allow, isResolving } = useCanAccess(query);\n\n if (isResolving) {\n return (loading !== undefined ? loading : denied) as ReactElement | null;\n }\n\n return (allow ? allowed : denied) as ReactElement | null;\n // @cpt-end:cpt-frontx-flow-auth-plugin-rbac-guard:p1:inst-component-render\n}\n","/**\n * useAppDispatch Hook - Type-safe dispatch hook\n *\n * React Layer: L3\n */\n// @cpt-flow:cpt-frontx-flow-react-bindings-use-dispatch:p1\n// @cpt-dod:cpt-frontx-dod-react-bindings-redux-hooks:p1\n\nimport { useDispatch } from 'react-redux';\nimport type { AppDispatch } from '@gears-frontx/framework';\n\n/**\n * Type-safe dispatch hook.\n *\n * @returns The typed dispatch function\n *\n * @example\n * ```tsx\n * const dispatch = useAppDispatch();\n * dispatch(someAction());\n * ```\n */\n// @cpt-begin:cpt-frontx-flow-react-bindings-use-dispatch:p1:inst-call-dispatch\n// @cpt-begin:cpt-frontx-flow-react-bindings-use-dispatch:p1:inst-delegate-dispatch\n// @cpt-begin:cpt-frontx-flow-react-bindings-use-dispatch:p1:inst-use-dispatch\n// @cpt-begin:cpt-frontx-dod-react-bindings-redux-hooks:p1:inst-use-dispatch\nexport function useAppDispatch(): AppDispatch {\n // Use untyped useDispatch and cast the result\n // This avoids type constraint issues with react-redux's generic\n return useDispatch() as AppDispatch;\n}\n// @cpt-end:cpt-frontx-flow-react-bindings-use-dispatch:p1:inst-call-dispatch\n// @cpt-end:cpt-frontx-flow-react-bindings-use-dispatch:p1:inst-delegate-dispatch\n// @cpt-end:cpt-frontx-flow-react-bindings-use-dispatch:p1:inst-use-dispatch\n// @cpt-end:cpt-frontx-dod-react-bindings-redux-hooks:p1:inst-use-dispatch\n","/**\n * useAppSelector Hook - Type-safe selector hook\n *\n * React Layer: L3\n */\n// @cpt-flow:cpt-frontx-flow-react-bindings-use-selector:p1\n// @cpt-dod:cpt-frontx-dod-react-bindings-redux-hooks:p1\n\nimport { useSelector, type TypedUseSelectorHook } from 'react-redux';\nimport type { RootState } from '@gears-frontx/framework';\n\n/**\n * Type-safe selector hook.\n *\n * @example\n * ```tsx\n * const activeScreen = useAppSelector(selectActiveScreen);\n * const menuCollapsed = useAppSelector(selectMenuCollapsed);\n * ```\n */\n// @cpt-begin:cpt-frontx-flow-react-bindings-use-selector:p1:inst-call-selector\n// @cpt-begin:cpt-frontx-flow-react-bindings-use-selector:p1:inst-delegate-selector\n// @cpt-begin:cpt-frontx-flow-react-bindings-use-selector:p1:inst-return-state\n// @cpt-begin:cpt-frontx-flow-react-bindings-use-selector:p1:inst-rerender-on-change\n// @cpt-begin:cpt-frontx-dod-react-bindings-redux-hooks:p1:inst-use-selector\nexport const useAppSelector: TypedUseSelectorHook<RootState> = useSelector;\n// @cpt-end:cpt-frontx-flow-react-bindings-use-selector:p1:inst-call-selector\n// @cpt-end:cpt-frontx-flow-react-bindings-use-selector:p1:inst-delegate-selector\n// @cpt-end:cpt-frontx-flow-react-bindings-use-selector:p1:inst-return-state\n// @cpt-end:cpt-frontx-flow-react-bindings-use-selector:p1:inst-rerender-on-change\n// @cpt-end:cpt-frontx-dod-react-bindings-redux-hooks:p1:inst-use-selector\n","/**\n * useTranslation Hook - Translation utilities\n *\n * React Layer: L3\n */\n// @cpt-flow:cpt-frontx-flow-react-bindings-use-translation:p1\n// @cpt-dod:cpt-frontx-dod-react-bindings-translation-hook:p1\n\nimport { useMemo, useCallback, useSyncExternalStore } from 'react';\nimport type { Language } from '@gears-frontx/framework';\nimport { useFrontX } from '../FrontXContext';\nimport type { UseTranslationReturn } from '../types';\n\n/**\n * Hook for accessing translation utilities.\n *\n * @returns Translation utilities\n *\n * @example\n * ```tsx\n * const { t, language, setLanguage, isRTL } = useTranslation();\n *\n * return (\n * <div dir={isRTL ? 'rtl' : 'ltr'}>\n * <h1>{t('common:app.title')}</h1>\n * <p>{t('common:app.welcome', { name: 'John' })}</p>\n * </div>\n * );\n * ```\n */\n// @cpt-begin:cpt-frontx-flow-react-bindings-use-translation:p1:inst-call-translation\n// @cpt-begin:cpt-frontx-dod-react-bindings-translation-hook:p1:inst-call-translation\nexport function useTranslation(): UseTranslationReturn {\n // @cpt-begin:cpt-frontx-flow-react-bindings-use-translation:p1:inst-read-i18n-registry\n const app = useFrontX();\n const { i18nRegistry } = app;\n // @cpt-end:cpt-frontx-flow-react-bindings-use-translation:p1:inst-read-i18n-registry\n\n // @cpt-begin:cpt-frontx-flow-react-bindings-use-translation:p1:inst-subscribe-i18n\n // @cpt-begin:cpt-frontx-flow-react-bindings-use-translation:p1:inst-rerender-on-lang-change\n // Subscribe to translation changes using useSyncExternalStore\n // Uses version counter to trigger re-renders when translations change\n const version = useSyncExternalStore(\n useCallback(\n (callback: () => void) => {\n // Subscribe to translation changes (new translations registered)\n return i18nRegistry.subscribe(callback);\n },\n [i18nRegistry]\n ),\n () => i18nRegistry.getVersion(),\n () => i18nRegistry.getVersion()\n );\n // @cpt-end:cpt-frontx-flow-react-bindings-use-translation:p1:inst-subscribe-i18n\n // @cpt-end:cpt-frontx-flow-react-bindings-use-translation:p1:inst-rerender-on-lang-change\n\n // Get current language (memoized to avoid unnecessary recalculations)\n // version is used to trigger recalculation when translations change\n const language = useMemo(() => {\n void version; // Trigger recalculation when version changes\n return i18nRegistry.getLanguage();\n }, [i18nRegistry, version]);\n\n // Translation function\n const t = useCallback(\n (key: string, params?: Record<string, string | number | boolean>) => {\n return i18nRegistry.t(key, params);\n },\n [i18nRegistry]\n );\n\n // @cpt-begin:cpt-frontx-flow-react-bindings-use-translation:p1:inst-set-language\n // Set language via framework action (emits event bus for MFE propagation)\n const setLanguage = useCallback(\n (lang: Language) => {\n if (app.actions.setLanguage) {\n app.actions.setLanguage({ language: lang });\n }\n },\n [app.actions]\n );\n // @cpt-end:cpt-frontx-flow-react-bindings-use-translation:p1:inst-set-language\n\n // Check RTL - recomputes when language changes\n const isRTL = useMemo(() => {\n // Reference language to trigger recalculation on language change\n void language;\n return i18nRegistry.isRTL();\n }, [i18nRegistry, language]);\n\n // @cpt-begin:cpt-frontx-flow-react-bindings-use-translation:p1:inst-return-translation-api\n return {\n t,\n language,\n setLanguage,\n isRTL,\n };\n // @cpt-end:cpt-frontx-flow-react-bindings-use-translation:p1:inst-return-translation-api\n}\n// @cpt-end:cpt-frontx-flow-react-bindings-use-translation:p1:inst-call-translation\n// @cpt-end:cpt-frontx-dod-react-bindings-translation-hook:p1:inst-call-translation\n","/**\n * useScreenTranslations Hook - Screen-level translation loading\n *\n * React Layer: L3\n */\n// @cpt-flow:cpt-frontx-flow-react-bindings-use-screen-translations:p1\n// @cpt-algo:cpt-frontx-algo-react-bindings-load-screen-translations:p1\n// @cpt-state:cpt-frontx-state-react-bindings-screen-translation:p1\n// @cpt-dod:cpt-frontx-dod-react-bindings-screen-translation-hook:p1\n\nimport { useState, useEffect, useMemo, useCallback, useSyncExternalStore } from 'react';\nimport type { TranslationMap, TranslationLoader } from '@gears-frontx/framework';\nimport { useFrontX } from '../FrontXContext';\nimport type { UseScreenTranslationsReturn } from '../types';\n\n// Re-export TranslationMap for consumers who need it\nexport type { TranslationMap };\n\n/**\n * Check if the input is a TranslationLoader function (from I18nRegistry.createLoader)\n * vs a TranslationMap object\n */\nfunction isTranslationLoader(\n input: TranslationMap | TranslationLoader\n): input is TranslationLoader {\n return typeof input === 'function';\n}\n\n/**\n * Hook for loading screen-level translations.\n * Use this in screen components to lazy-load translations.\n * Automatically reloads translations when language changes.\n *\n * @param screensetId - The screenset ID\n * @param screenId - The screen ID\n * @param translations - Either a TranslationMap object or a TranslationLoader function\n * (from I18nRegistry.createLoader)\n * @returns Loading state\n *\n * @example\n * ```tsx\n * // Option 1: Using I18nRegistry.createLoader (recommended)\n * const translations = I18nRegistry.createLoader({\n * en: () => import('./i18n/en.json'),\n * es: () => import('./i18n/es.json'),\n * });\n *\n * // Option 2: Using raw TranslationMap\n * const translations = {\n * en: () => import('./i18n/en.json'),\n * es: () => import('./i18n/es.json'),\n * };\n *\n * export const HomeScreen: React.FC = () => {\n * const { isLoaded, error } = useScreenTranslations(\n * 'demo',\n * 'home',\n * translations\n * );\n *\n * if (!isLoaded) return <LoadingSpinner />;\n * if (error) return <ErrorMessage error={error} />;\n *\n * return <div>...</div>;\n * };\n * ```\n */\n// @cpt-begin:cpt-frontx-flow-react-bindings-use-screen-translations:p1:inst-call-screen-translations\n// @cpt-begin:cpt-frontx-dod-react-bindings-screen-translation-hook:p1:inst-call-screen-translations\nexport function useScreenTranslations(\n screensetId: string,\n screenId: string,\n translations: TranslationMap | TranslationLoader\n): UseScreenTranslationsReturn {\n const app = useFrontX();\n const { i18nRegistry } = app;\n\n // Track loading state per language to handle language changes. No\n // inst-begin-load marker here: nothing in this state pair signals \"load\n // began\" — loading-in-progress is derived as\n // (currentLanguage !== loadedLanguage), see the comment on `isLoaded`.\n // @cpt-begin:cpt-frontx-state-react-bindings-screen-translation:p1:inst-load-success\n // @cpt-begin:cpt-frontx-state-react-bindings-screen-translation:p1:inst-load-error\n // @cpt-begin:cpt-frontx-state-react-bindings-screen-translation:p1:inst-reload-on-lang-change\n // @cpt-begin:cpt-frontx-state-react-bindings-screen-translation:p2:inst-retry-on-lang-change\n const [loadedLanguage, setLoadedLanguage] = useState<string | null>(null);\n const [error, setError] = useState<Error | null>(null);\n // @cpt-end:cpt-frontx-state-react-bindings-screen-translation:p1:inst-load-success\n // @cpt-end:cpt-frontx-state-react-bindings-screen-translation:p1:inst-load-error\n // @cpt-end:cpt-frontx-state-react-bindings-screen-translation:p1:inst-reload-on-lang-change\n // @cpt-end:cpt-frontx-state-react-bindings-screen-translation:p2:inst-retry-on-lang-change\n\n // @cpt-begin:cpt-frontx-flow-react-bindings-use-screen-translations:p1:inst-subscribe-lang-change\n // Subscribe to translation changes using useSyncExternalStore\n // This ensures we reload when language changes\n const version = useSyncExternalStore(\n useCallback(\n (callback: () => void) => i18nRegistry.subscribe(callback),\n [i18nRegistry]\n ),\n () => i18nRegistry.getVersion(),\n () => i18nRegistry.getVersion()\n );\n // @cpt-end:cpt-frontx-flow-react-bindings-use-screen-translations:p1:inst-subscribe-lang-change\n\n // @cpt-begin:cpt-frontx-algo-react-bindings-load-screen-translations:p1:inst-get-current-lang\n // Get current language (changes when version changes)\n // version is used to trigger recalculation when translations change\n const currentLanguage = useMemo(() => {\n void version; // Trigger recalculation when version changes\n return i18nRegistry.getLanguage();\n }, [i18nRegistry, version]);\n // @cpt-end:cpt-frontx-algo-react-bindings-load-screen-translations:p1:inst-get-current-lang\n\n // @cpt-begin:cpt-frontx-algo-react-bindings-load-screen-translations:p1:inst-resolve-loader\n // Create a TranslationLoader function from the translation map or use directly if already a loader\n const loader: TranslationLoader = useMemo(() => {\n if (isTranslationLoader(translations)) {\n // Already a loader function (from I18nRegistry.createLoader)\n return translations;\n }\n\n // Convert TranslationMap to TranslationLoader\n return async (language: string) => {\n const importFn = translations[language as keyof typeof translations];\n if (!importFn) {\n // Return empty dictionary if language not in map\n return {};\n }\n const module = await importFn();\n return module.default;\n };\n }, [translations]);\n // @cpt-end:cpt-frontx-algo-react-bindings-load-screen-translations:p1:inst-resolve-loader\n\n // @cpt-begin:cpt-frontx-flow-react-bindings-use-screen-translations:p1:inst-run-load-screen-translations\n useEffect(() => {\n // @cpt-begin:cpt-frontx-algo-react-bindings-load-screen-translations:p1:inst-skip-if-loaded\n // Skip if no language or already loaded for this language\n if (!currentLanguage || currentLanguage === loadedLanguage) {\n return;\n }\n // @cpt-end:cpt-frontx-algo-react-bindings-load-screen-translations:p1:inst-skip-if-loaded\n\n let cancelled = false;\n\n const loadTranslations = async () => {\n try {\n const namespace = `screen.${screensetId}.${screenId}`;\n\n // @cpt-begin:cpt-frontx-algo-react-bindings-load-screen-translations:p1:inst-register-loader\n // Register the loader for future language changes\n i18nRegistry.registerLoader(namespace, loader);\n // @cpt-end:cpt-frontx-algo-react-bindings-load-screen-translations:p1:inst-register-loader\n\n // @cpt-begin:cpt-frontx-algo-react-bindings-load-screen-translations:p1:inst-call-loader\n // Actually load the translations for current language\n const loadedTranslations = await loader(currentLanguage);\n // @cpt-end:cpt-frontx-algo-react-bindings-load-screen-translations:p1:inst-call-loader\n\n // @cpt-begin:cpt-frontx-algo-react-bindings-load-screen-translations:p1:inst-register-translations\n i18nRegistry.register(namespace, currentLanguage, loadedTranslations);\n // @cpt-end:cpt-frontx-algo-react-bindings-load-screen-translations:p1:inst-register-translations\n\n // @cpt-begin:cpt-frontx-algo-react-bindings-load-screen-translations:p1:inst-cancel-on-unmount\n if (!cancelled) {\n setLoadedLanguage(currentLanguage);\n setError(null);\n }\n // @cpt-end:cpt-frontx-algo-react-bindings-load-screen-translations:p1:inst-cancel-on-unmount\n } catch (err) {\n // @cpt-begin:cpt-frontx-algo-react-bindings-load-screen-translations:p1:inst-handle-load-error\n if (!cancelled) {\n setError(err instanceof Error ? err : new Error(String(err)));\n }\n // @cpt-end:cpt-frontx-algo-react-bindings-load-screen-translations:p1:inst-handle-load-error\n }\n };\n\n loadTranslations();\n\n // @cpt-begin:cpt-frontx-algo-react-bindings-load-screen-translations:p1:inst-cancel-stale-load\n return () => {\n cancelled = true;\n };\n // @cpt-end:cpt-frontx-algo-react-bindings-load-screen-translations:p1:inst-cancel-stale-load\n }, [screensetId, screenId, loader, i18nRegistry, currentLanguage, loadedLanguage]);\n // @cpt-end:cpt-frontx-flow-react-bindings-use-screen-translations:p1:inst-run-load-screen-translations\n\n // @cpt-begin:cpt-frontx-flow-react-bindings-use-screen-translations:p1:inst-return-loading-state\n // Derived, not a stored flag: on error, loadedLanguage is never advanced to\n // currentLanguage, so the mismatch alone already gates isLoaded false.\n const isLoaded = currentLanguage !== null && currentLanguage === loadedLanguage;\n\n // @cpt-begin:cpt-frontx-flow-react-bindings-use-screen-translations:p1:inst-gate-render\n // isLoaded is the gate value: consumers must check this before rendering translation-dependent UI\n return { isLoaded, error };\n // @cpt-end:cpt-frontx-flow-react-bindings-use-screen-translations:p1:inst-gate-render\n // @cpt-end:cpt-frontx-flow-react-bindings-use-screen-translations:p1:inst-return-loading-state\n}\n// @cpt-end:cpt-frontx-flow-react-bindings-use-screen-translations:p1:inst-call-screen-translations\n// @cpt-end:cpt-frontx-dod-react-bindings-screen-translation-hook:p1:inst-call-screen-translations\n","/**\n * useFormatters Hook - Locale-aware formatters\n *\n * Returns formatters that use i18nRegistry.getLanguage() internally.\n * Calls useTranslation() so the component re-renders when language changes.\n *\n * React Layer: L3\n */\n// @cpt-flow:cpt-frontx-flow-react-bindings-use-formatters:p1\n// @cpt-dod:cpt-frontx-dod-react-bindings-formatters-hook:p1\n\nimport { useMemo } from 'react';\nimport {\n formatDate as formatDateFn,\n formatTime as formatTimeFn,\n formatDateTime as formatDateTimeFn,\n formatRelative as formatRelativeFn,\n formatNumber as formatNumberFn,\n formatPercent as formatPercentFn,\n formatCompact as formatCompactFn,\n formatCurrency as formatCurrencyFn,\n compareStrings as compareStringsFn,\n createCollator as createCollatorFn,\n} from '@gears-frontx/framework';\nimport type { UseFormattersReturn } from '../types';\nimport { useTranslation } from './useTranslation';\n\n/**\n * Hook for accessing locale-aware formatters (date, number, currency, sort).\n *\n * Formatters use the current app language from i18nRegistry.getLanguage().\n * Re-renders when language changes via useTranslation() subscription.\n *\n * @returns Object with formatDate, formatTime, formatDateTime, formatRelative,\n * formatNumber, formatPercent, formatCompact, formatCurrency, compareStrings, createCollator\n *\n * @example\n * ```tsx\n * const { formatDate, formatCurrency } = useFormatters();\n * return (\n * <span>{formatDate(new Date(), 'short')}</span>\n * <span>{formatCurrency(99.99, 'USD')}</span>\n * );\n * ```\n */\n// @cpt-begin:cpt-frontx-flow-react-bindings-use-formatters:p1:inst-call-formatters\n// @cpt-begin:cpt-frontx-dod-react-bindings-formatters-hook:p1:inst-call-formatters\nexport function useFormatters(): UseFormattersReturn {\n // @cpt-begin:cpt-frontx-flow-react-bindings-use-formatters:p1:inst-subscribe-via-translation\n // useTranslation() subscribes to language changes so this component re-renders\n // when language changes; formatters read i18nRegistry.getLanguage() at call time\n const { language } = useTranslation();\n // @cpt-end:cpt-frontx-flow-react-bindings-use-formatters:p1:inst-subscribe-via-translation\n\n // @cpt-begin:cpt-frontx-flow-react-bindings-use-formatters:p1:inst-return-formatters\n // @cpt-begin:cpt-frontx-flow-react-bindings-use-formatters:p1:inst-formatters-read-locale\n // @cpt-begin:cpt-frontx-flow-react-bindings-use-formatters:p1:inst-recompute-on-lang\n return useMemo<UseFormattersReturn>(\n () => {\n void language; // re-run when language changes so formatters see new locale\n return {\n formatDate: formatDateFn,\n formatTime: formatTimeFn,\n formatDateTime: formatDateTimeFn,\n formatRelative: formatRelativeFn,\n formatNumber: formatNumberFn,\n formatPercent: formatPercentFn,\n formatCompact: formatCompactFn,\n formatCurrency: formatCurrencyFn,\n compareStrings: compareStringsFn,\n createCollator: createCollatorFn,\n };\n },\n [language]\n );\n // @cpt-end:cpt-frontx-flow-react-bindings-use-formatters:p1:inst-return-formatters\n // @cpt-end:cpt-frontx-flow-react-bindings-use-formatters:p1:inst-formatters-read-locale\n // @cpt-end:cpt-frontx-flow-react-bindings-use-formatters:p1:inst-recompute-on-lang\n}\n// @cpt-end:cpt-frontx-flow-react-bindings-use-formatters:p1:inst-call-formatters\n// @cpt-end:cpt-frontx-dod-react-bindings-formatters-hook:p1:inst-call-formatters\n","/**\n * useTheme Hook - Theme utilities\n *\n * React Layer: L3\n */\n// @cpt-flow:cpt-frontx-flow-react-bindings-use-theme:p1\n// @cpt-dod:cpt-frontx-dod-react-bindings-theme-hook:p1\n\nimport { useCallback, useMemo, useSyncExternalStore } from 'react';\nimport { useFrontX } from '../FrontXContext';\nimport type { UseThemeReturn } from '../types';\n\n/**\n * Hook for theme utilities.\n *\n * @returns Theme utilities\n *\n * @example\n * ```tsx\n * const { currentTheme, themes, setTheme } = useTheme();\n *\n * return (\n * <select\n * value={currentTheme}\n * onChange={(e) => setTheme(e.target.value)}\n * >\n * {themes.map((theme) => (\n * <option key={theme.id} value={theme.id}>\n * {theme.name}\n * </option>\n * ))}\n * </select>\n * );\n * ```\n */\n// @cpt-begin:cpt-frontx-flow-react-bindings-use-theme:p1:inst-call-theme\n// @cpt-begin:cpt-frontx-dod-react-bindings-theme-hook:p1:inst-call-theme\nexport function useTheme(): UseThemeReturn {\n // @cpt-begin:cpt-frontx-flow-react-bindings-use-theme:p1:inst-read-theme-registry\n const app = useFrontX();\n const { themeRegistry } = app;\n // @cpt-end:cpt-frontx-flow-react-bindings-use-theme:p1:inst-read-theme-registry\n\n // @cpt-begin:cpt-frontx-flow-react-bindings-use-theme:p1:inst-subscribe-theme\n // @cpt-begin:cpt-frontx-flow-react-bindings-use-theme:p1:inst-rerender-on-theme-change\n // Subscribe to theme changes using useSyncExternalStore\n // Uses version counter to trigger re-renders when theme changes\n const version = useSyncExternalStore(\n useCallback(\n (callback: () => void) => {\n return themeRegistry.subscribe(callback);\n },\n [themeRegistry]\n ),\n () => themeRegistry.getVersion(),\n () => themeRegistry.getVersion()\n );\n // @cpt-end:cpt-frontx-flow-react-bindings-use-theme:p1:inst-subscribe-theme\n // @cpt-end:cpt-frontx-flow-react-bindings-use-theme:p1:inst-rerender-on-theme-change\n\n // Get current theme (memoized, recalculates on version change)\n const currentTheme = useMemo(() => {\n // Reference version to trigger recalculation on theme change\n void version;\n const theme = themeRegistry.getCurrent();\n return theme?.id;\n }, [themeRegistry, version]);\n\n // Get all themes\n const themes = useMemo(() => {\n return themeRegistry.getAll().map((theme) => ({\n id: theme.id,\n name: theme.name,\n }));\n }, [themeRegistry]);\n\n // @cpt-begin:cpt-frontx-flow-react-bindings-use-theme:p1:inst-dispatch-change-theme\n // Set theme\n const setTheme = useCallback(\n (themeId: string) => {\n if (app.actions.changeTheme) {\n app.actions.changeTheme({ themeId });\n }\n },\n [app.actions]\n );\n // @cpt-end:cpt-frontx-flow-react-bindings-use-theme:p1:inst-dispatch-change-theme\n\n // @cpt-begin:cpt-frontx-flow-react-bindings-use-theme:p1:inst-return-theme-api\n return {\n currentTheme,\n themes,\n setTheme,\n };\n // @cpt-end:cpt-frontx-flow-react-bindings-use-theme:p1:inst-return-theme-api\n}\n// @cpt-end:cpt-frontx-flow-react-bindings-use-theme:p1:inst-call-theme\n// @cpt-end:cpt-frontx-dod-react-bindings-theme-hook:p1:inst-call-theme\n","/**\n * useApiQuery - Declarative data fetching hook\n *\n * Accepts an EndpointDescriptor from @gears-frontx/api and returns a Gears FrontX-owned\n * ApiQueryResult. AbortSignal for request cancellation is threaded automatically\n * through the shared QueryClient integration.\n *\n * Cache config cascade: component overrides > descriptor defaults > plugin defaults.\n * Omit overrides to rely on the descriptor's staleTime/gcTime, which in turn\n * fall back to the plugin-level query-cache defaults, so a screen that remounts\n * within staleTime paints from cache without refetching.\n *\n * Pass `enabled: false` to hold a query whose input is not known yet.\n */\n\nimport type { EndpointDescriptor } from '@gears-frontx/framework';\nimport type { ApiQueryResult } from '../types';\nimport { useFrontXQuery } from '../queryClient';\n\n/**\n * Per-call cache overrides shared by every read hook.\n * Cascade: these > descriptor > plugin defaults.\n */\nexport interface ApiQueryCacheOverrides {\n /** Override staleTime for this specific call site. */\n staleTime?: number;\n /** Override gcTime for this specific call site. */\n gcTime?: number;\n}\n\n/** Per-call overrides for useApiSuspenseQuery. */\nexport interface ApiSuspenseQueryOverrides extends ApiQueryCacheOverrides {\n /** A suspense query always runs; use useApiQuery to hold one back. */\n enabled?: never;\n}\n\n/** Per-call overrides for useApiQuery. */\nexport interface ApiQueryOverrides extends ApiQueryCacheOverrides {\n /**\n * `false` keeps the query idle: it is not fetched automatically and\n * `isLoading` stays false until it turns `true`. An explicit `refetch`\n * still fetches. Defaults to `true`.\n */\n enabled?: boolean;\n}\n\nexport function useApiQuery<TData = unknown, TError = Error>(\n descriptor: EndpointDescriptor<TData>,\n overrides?: ApiQueryOverrides\n): ApiQueryResult<TData, TError> {\n return useFrontXQuery(descriptor, overrides);\n}\n","/**\n * useApiSuspenseQuery - Suspense declarative data fetching hook\n *\n * Mirrors useApiQuery but integrates with React Suspense so the initial load is\n * handled by a Suspense boundary. A suspense query always runs, so there is no\n * `enabled` override.\n */\n\nimport type { EndpointDescriptor } from '@gears-frontx/framework';\nimport type { ApiSuspenseQueryResult } from '../types';\nimport type { ApiSuspenseQueryOverrides } from './useApiQuery';\nimport { useFrontXSuspenseQuery } from '../queryClient';\n\nexport function useApiSuspenseQuery<TData = unknown, TError = Error>(\n descriptor: EndpointDescriptor<TData>,\n overrides?: ApiSuspenseQueryOverrides\n): ApiSuspenseQueryResult<TData, TError> {\n return useFrontXSuspenseQuery<TData, TError>(descriptor, overrides);\n}\n","/**\n * useApiInfiniteQuery - Declarative paginated data fetching hook\n *\n * Accepts an initial EndpointDescriptor plus descriptor resolvers for adjacent\n * pages. Each page remains a standard service descriptor so MFE code does not\n * need raw TanStack query keys or query functions.\n */\n\nimport type { EndpointDescriptor } from '@gears-frontx/framework';\nimport type { ApiInfiniteQueryResult } from '../types';\nimport type { ApiQueryCacheOverrides } from './useApiQuery';\nimport { useFrontXInfiniteQuery } from '../queryClient';\n\nexport interface ApiInfiniteQueryPageContext<TPage> {\n page: TPage;\n pages: readonly TPage[];\n descriptor: EndpointDescriptor<TPage>;\n descriptors: readonly EndpointDescriptor<TPage>[];\n}\n\n/** Options shared by useApiInfiniteQuery and useApiSuspenseInfiniteQuery. */\nexport interface ApiInfiniteQueryBaseOptions<TPage> extends ApiQueryCacheOverrides {\n /** Descriptor for the first page in the sequence. */\n initialPage: EndpointDescriptor<TPage>;\n /**\n * Resolve the next page descriptor from the current page payload.\n * Return undefined when there is no next page.\n */\n getNextPage: (\n context: ApiInfiniteQueryPageContext<TPage>\n ) => EndpointDescriptor<TPage> | undefined;\n /**\n * Resolve the previous page descriptor from the current first page payload.\n * Return undefined when backward pagination is not available.\n */\n getPreviousPage?: (\n context: ApiInfiniteQueryPageContext<TPage>\n ) => EndpointDescriptor<TPage> | undefined;\n /** Optional TanStack maxPages passthrough for bounded page windows. */\n maxPages?: number;\n}\n\n/** Options for useApiSuspenseInfiniteQuery. */\nexport interface ApiSuspenseInfiniteQueryOptions<TPage> extends ApiInfiniteQueryBaseOptions<TPage> {\n /** A suspense query always runs; use useApiInfiniteQuery to hold one back. */\n enabled?: never;\n}\n\nexport interface ApiInfiniteQueryOptions<TPage> extends ApiInfiniteQueryBaseOptions<TPage> {\n /**\n * `false` keeps the query idle: no page is fetched until it turns `true`.\n * Defaults to `true`.\n */\n enabled?: boolean;\n}\n\nexport function useApiInfiniteQuery<TPage = unknown, TError = Error>(\n options: ApiInfiniteQueryOptions<TPage>\n): ApiInfiniteQueryResult<TPage, TError> {\n return useFrontXInfiniteQuery<TPage, TError>(options);\n}\n","/**\n * useApiSuspenseInfiniteQuery - Suspense paginated data fetching hook\n *\n * Mirrors useApiInfiniteQuery but integrates with React Suspense so the initial\n * page load is handled by a Suspense boundary while pagination stays\n * descriptor-driven.\n */\n\nimport type { ApiSuspenseInfiniteQueryResult } from '../types';\nimport type { ApiSuspenseInfiniteQueryOptions } from './useApiInfiniteQuery';\nimport { useFrontXSuspenseInfiniteQuery } from '../queryClient';\n\nexport function useApiSuspenseInfiniteQuery<TPage = unknown, TError = Error>(\n options: ApiSuspenseInfiniteQueryOptions<TPage>\n): ApiSuspenseInfiniteQueryResult<TPage, TError> {\n return useFrontXSuspenseInfiniteQuery<TPage, TError>(options);\n}\n","/**\n * useApiMutation - Declarative mutation hook with restricted QueryCache injection\n *\n * Accepts { endpoint: MutationDescriptor, callbacks } and returns a Gears FrontX-owned\n * ApiMutationResult. Supports optimistic updates, rollback, and cache invalidation\n * through the QueryCache interface injected into each callback.\n *\n * Optimistic update pattern:\n * onMutate -> cancel outgoing refetches, snapshot via queryCache.get,\n * apply optimistic data via queryCache.set, return snapshot\n * onError -> restore snapshot via queryCache.set(key, context.snapshot)\n * onSettled -> invalidate to refetch authoritative state\n *\n * TanStack Query is used internally only and is NOT re-exported.\n * MFEs interact with the cache through QueryCache, not the raw QueryClient.\n */\n// @cpt-dod:cpt-frontx-dod-request-lifecycle-use-api-mutation:p2\n// @cpt-flow:cpt-frontx-flow-request-lifecycle-use-api-mutation:p2\n// @cpt-algo:cpt-frontx-algo-request-lifecycle-optimistic-update:p2\n// @cpt-algo:cpt-frontx-algo-request-lifecycle-query-invalidation:p2\n// @cpt-state:cpt-frontx-state-request-lifecycle-mutation:p2\n// @cpt-FEATURE:implement-endpoint-descriptors:p3\n\nimport type { MutationDescriptor } from '@gears-frontx/framework';\nimport type { MutationCallbackContext } from './QueryCache';\nimport type { ApiMutationResult } from '../types';\nimport { useFrontXMutation, useRequiredFrontXQueryClient } from '../queryClient';\nimport { createQueryCache } from './QueryCache';\nimport { useMemo } from 'react';\n\nexport type { QueryCache, MutationCallbackContext } from './QueryCache';\n\n// @cpt-begin:cpt-frontx-dod-request-lifecycle-use-api-mutation:p2:inst-type-alias\n/**\n * Options for useApiMutation.\n *\n * Each callback receives { queryCache } as an additional final parameter,\n * providing controlled access to the shared cache without exposing the\n * raw QueryClient. TContext is the return type of onMutate, passed as\n * context to onSuccess, onError, and onSettled.\n */\nexport type UseApiMutationOptions<\n TData = unknown,\n TError = Error,\n TVariables = void,\n TContext = unknown,\n> = {\n endpoint: MutationDescriptor<TData, TVariables>;\n cancelOnSupersede?: boolean;\n abortOnUnmount?: boolean;\n onMutate?: (variables: TVariables, ctx: MutationCallbackContext) => Promise<TContext> | TContext;\n onSuccess?: (data: TData, variables: TVariables, context: TContext | undefined, ctx: MutationCallbackContext) => unknown;\n onError?: (error: TError, variables: TVariables, context: TContext | undefined, ctx: MutationCallbackContext) => unknown;\n onSettled?: (data: TData | undefined, error: TError | null, variables: TVariables, context: TContext | undefined, ctx: MutationCallbackContext) => unknown;\n};\n// @cpt-end:cpt-frontx-dod-request-lifecycle-use-api-mutation:p2:inst-type-alias\n\n// @cpt-begin:cpt-frontx-flow-request-lifecycle-use-api-mutation:p2:inst-delegate-use-mutation\nexport function useApiMutation<\n TData = unknown,\n TError = Error,\n TVariables = void,\n TContext = unknown,\n>(\n options: UseApiMutationOptions<TData, TError, TVariables, TContext>\n): ApiMutationResult<TData, TError, TVariables> {\n const queryClient = useRequiredFrontXQueryClient();\n const queryCache = useMemo(() => createQueryCache(queryClient), [queryClient]);\n const callbackCtx: MutationCallbackContext = useMemo(() => ({ queryCache }), [queryCache]);\n return useFrontXMutation<TData, TError, TVariables, TContext>(options, callbackCtx);\n}\n// @cpt-end:cpt-frontx-flow-request-lifecycle-use-api-mutation:p2:inst-delegate-use-mutation\n","/**\n * useApiStream - Declarative SSE streaming hook\n *\n * Accepts a StreamDescriptor from @gears-frontx/api and returns the latest\n * event, accumulated events, connection status, and a manual disconnect\n * function.\n *\n * @example\n * ```tsx\n * const { data, events, status, error } = useApiStream(\n * service.messageStream,\n * { mode: 'latest' } // default — data holds last event\n * );\n *\n * // Accumulate all events\n * const { events, status } = useApiStream(service.messageStream, { mode: 'accumulate' });\n * ```\n */\n\nimport { useEffect, useMemo, useRef, useState, useCallback } from 'react';\nimport type { StreamDescriptor, StreamStatus } from '@gears-frontx/framework';\nimport { useLatest } from './useLatest';\n\n/** Configuration options for useApiStream. */\nexport interface ApiStreamOptions {\n /**\n * `'latest'` (default) — `data` holds the most recent event.\n * `'accumulate'` — `events` holds all received events in order.\n */\n mode?: 'latest' | 'accumulate';\n /** When false the connection is deferred (no connect on mount). Default true. */\n enabled?: boolean;\n}\n\n/** Return type of useApiStream. */\nexport interface ApiStreamResult<TEvent> {\n /** Latest event payload, set in both modes — `undefined` until the first event and after each connect attempt resets it. */\n data: TEvent | undefined;\n /** All received events when `mode: 'accumulate'`; empty array in `'latest'` mode. */\n events: TEvent[];\n /** Connection lifecycle status. */\n status: StreamStatus;\n /** Last connect error — set when a connect attempt rejects, cleared when the next attempt starts. */\n error: Error | null;\n /** Manually close the connection. */\n disconnect: () => void;\n}\n\n/**\n * Manages the status lifecycle for a single SSE stream connection.\n *\n * **Status values**\n * - `'idle'` — no connection is being attempted. This is the status whenever\n * `enabled` is `false`, including on mount: a hook that mounts disabled\n * never reports anything but `'idle'` until `enabled` flips to `true`. A\n * hook that mounts enabled skips `'idle'` entirely — the status is set\n * during render, so its very first render already reports `'connecting'`.\n * Consumers must not assume `'idle'` means \"never\n * connected\" — a stream that is disabled after having connected returns to\n * `'idle'` too, and `data`/`events` from the earlier connection are not\n * cleared by that transition alone (they are cleared by mode/key changes,\n * see below).\n * - `'connecting'` — a connection attempt is committed to but has not settled.\n * It is published during the render that turns the stream on, which is\n * before `descriptor.connect()` runs: the call is made from an effect after\n * that render commits. So `'connecting'` means \"this stream is being\n * opened\", not \"the connect promise is pending\" — for one render the two\n * differ, and a consumer that reads the status as proof a request is already\n * in flight is reading it too strongly.\n * - `'connected'` — set both when `connect()` resolves (unless a disconnect\n * was requested while it was pending) and, independently, whenever the\n * `onEvent` callback delivers a new event. Because every event re-asserts\n * `'connected'`, this status also serves as \"still receiving events.\"\n * - `'disconnected'` — reached via any of: the descriptor's `onComplete`\n * callback firing (the stream ended normally), `connect()` rejecting while\n * a disconnect was requested concurrently, or the manual `disconnect()`\n * function being called. `disconnect()` has no `enabled` guard, but calling\n * it while the stream is disabled is not observable: the stored status moves\n * to `'disconnected'` while the published one stays `'idle'`, and flipping\n * `enabled` back to `true` sets `'connecting'` during that render, so the\n * stored `'disconnected'` is overwritten before it is ever returned.\n * - `'error'` — `connect()` rejected and no disconnect was requested while it\n * was pending. `error` holds the rejection, coerced to an `Error` if it\n * wasn't one already.\n *\n * **Transitions**\n * - Mounting enabled, `enabled` becoming `true`, or `descriptor.key` / `mode`\n * changing while `enabled` is `true`: `data`, `events`, and `error` are reset\n * and status is set to `'connecting'` synchronously during render (not from\n * an effect); `connect()` is then called from an effect that runs after that\n * render commits.\n * - `descriptor.key` or `mode` changing while `enabled` is `false`: `data`,\n * `events`, and `error` are reset all the same, since that reset is not gated\n * on `enabled`, but the status write is - so no `'connecting'` is written and\n * the published status stays `'idle'`; `connect()` is not called. The skipped\n * `'connecting'` is not owed later either: the change counts as handled when\n * it happens, so what publishes `'connecting'` is the subsequent flip of\n * `enabled` to `true`, once, for whichever key and mode are in force by then.\n * - `enabled` becomes `false` (or starts `false`): the published status is\n * `'idle'` for as long as `enabled` stays `false` — it is derived from\n * `enabled` rather than written, so nothing a prior connection stored can\n * surface through it — and `connect()` is never called; no other field is\n * reset by this transition alone.\n * - Unmount, `descriptor.key` change, `mode` change, or `enabled` flipping to\n * `false` while connected or connecting: the previous connection is torn\n * down via `descriptor.disconnect()` once its `connect()` promise settles\n * (or immediately skipped if it rejected). All four share the same cleanup\n * path: the effect's cleanup runs on every dependency change and on unmount.\n * - Calling `disconnect()`: if a connection id is already resolved, it is\n * disconnected immediately and status becomes `'disconnected'`. If\n * `connect()` is still pending, the request is recorded and honored when\n * the promise settles — the newly resolved connection is torn down instead\n * of being adopted, and status is `'disconnected'`. One caveat:\n * `disconnect()` does not cancel the event callback, so a buffered or\n * in-flight event landing after the call re-asserts `'connected'` — and in\n * the pending-connect case the settle handler tears the connection down\n * without touching status, so that stray `'connected'` persists.\n * - Stream completion while `connect()` is still pending: the current\n * implementation lets `onComplete` set `'disconnected'`, then the settle\n * handler adopts the connection id and re-asserts `'connected'` anyway.\n * This is known current behavior, not a durable guarantee: a pending\n * upstream derived-status rewrite is expected to remove this transition.\n *\n * `enabled` (default `true`) is the only way to defer connecting past mount;\n * flipping it back to `true` re-runs the same connect sequence as a fresh\n * mount would.\n */\nexport function useApiStream<TEvent>(\n descriptor: StreamDescriptor<TEvent>,\n options?: ApiStreamOptions,\n): ApiStreamResult<TEvent> {\n const mode = options?.mode ?? 'latest';\n const enabled = options?.enabled ?? true;\n\n const [data, setData] = useState<TEvent | undefined>(undefined);\n const [events, setEvents] = useState<TEvent[]>([]);\n // Lazy initializer mirrors what the \"connecting\" render-adjustment below would set on\n // a later (descriptorKey, mode, enabled) change — the adjustment's before/after\n // comparison can't itself detect \"this is the very first render\", since its own\n // `prevConnectKey` state is seeded from the same initial connectKey.\n const [status, setStatus] = useState<StreamStatus>(() => (enabled ? 'connecting' : 'idle'));\n const [error, setError] = useState<Error | null>(null);\n\n // Tracks the in-flight connect() promise so cleanup can await it.\n const connectPromiseRef = useRef<Promise<string> | null>(null);\n // Tracks the resolved connectionId for the manual disconnect() callback.\n const connectionIdRef = useRef<string | null>(null);\n /** When true, connect's promise resolution must tear down the new id instead of adopting it. */\n const disconnectRequestedRef = useRef(false);\n // Latest descriptor for connect/disconnect without tying effect or callbacks to object identity.\n const descriptorRef = useLatest(descriptor);\n\n // Stable identity derived from descriptor key — used as effect dependency.\n // JSON.stringify avoids join('/') collisions when a segment contains '/'.\n const descriptorKey = useMemo(() => JSON.stringify(descriptor.key), [descriptor.key]);\n\n // Resets stream state when the descriptor or mode changes, using the \"adjusting state\n // during render\" pattern (react.dev) instead of an effect: this clears stale data\n // before paint in the same render pass rather than committing once with old data and\n // scheduling a second render from an effect.\n const resetKey = `${descriptorKey}:${mode}`;\n const [prevResetKey, setPrevResetKey] = useState(resetKey);\n if (resetKey !== prevResetKey) {\n setPrevResetKey(resetKey);\n setData(undefined);\n setEvents([]);\n setError(null);\n }\n\n // Same pattern, scoped to when the connect effect below is about to (re)start a\n // connection: also flips `status` to 'connecting' up front, exactly once per\n // (descriptorKey, mode, enabled) combination — matching the effect's dependency list\n // — instead of the effect setting it synchronously on every run.\n const connectKey = `${resetKey}:${enabled}`;\n const [prevConnectKey, setPrevConnectKey] = useState(connectKey);\n if (connectKey !== prevConnectKey) {\n setPrevConnectKey(connectKey);\n if (enabled) {\n setData(undefined);\n setEvents([]);\n setStatus('connecting');\n setError(null);\n }\n }\n\n const disconnect = useCallback(() => {\n disconnectRequestedRef.current = true;\n if (connectionIdRef.current) {\n descriptorRef.current.disconnect(connectionIdRef.current);\n connectionIdRef.current = null;\n disconnectRequestedRef.current = false;\n }\n setStatus('disconnected');\n // descriptorRef's identity never changes (useLatest returns a stable ref\n // object) — listing it here satisfies exhaustive-deps without altering\n // when this callback is recreated.\n }, [descriptorRef]);\n\n useEffect(() => {\n // Disabled: no connection attempt. `status` is displayed as 'idle' via the\n // derived value below instead of writing it here — the stored `status` from a\n // prior connection is left untouched so a later re-enable has nothing stale to\n // clean up, and no synchronous setState is needed in this effect.\n if (!enabled) {\n return;\n }\n\n let cancelled = false;\n\n disconnectRequestedRef.current = false;\n\n const d = descriptorRef.current;\n // data/events/status/error were already reset to the 'connecting' state above,\n // during render, for this exact (descriptorKey, mode, enabled) combination.\n\n const connectPromise = d.connect(\n (event) => {\n if (cancelled) return;\n setData(event);\n setStatus('connected');\n if (mode === 'accumulate') {\n setEvents((prev) => [...prev, event]);\n }\n },\n () => {\n if (cancelled) return;\n setStatus('disconnected');\n connectionIdRef.current = null;\n },\n );\n\n connectPromiseRef.current = connectPromise;\n\n connectPromise\n .then((id) => {\n if (cancelled) return;\n if (disconnectRequestedRef.current) {\n d.disconnect(id);\n disconnectRequestedRef.current = false;\n return;\n }\n connectionIdRef.current = id;\n setStatus('connected');\n })\n .catch((err) => {\n if (cancelled) return;\n if (disconnectRequestedRef.current) {\n disconnectRequestedRef.current = false;\n setStatus('disconnected');\n return;\n }\n setError(err instanceof Error ? err : new Error(String(err)));\n setStatus('error');\n });\n\n return () => {\n cancelled = true;\n connectPromise.then(\n (id) => d.disconnect(id),\n () => { /* connect failed — nothing to disconnect */ },\n );\n connectPromiseRef.current = null;\n connectionIdRef.current = null;\n };\n // descriptorRef's identity never changes (useLatest returns a stable ref\n // object) — listing it here satisfies exhaustive-deps without causing\n // this effect to re-run on every render.\n }, [descriptorKey, enabled, mode, descriptorRef]);\n\n // Derived: while disabled the connection is deliberately not attempted, so the\n // publicly visible status is always 'idle' regardless of what a prior connection\n // left in `status` state.\n return { data, events, status: enabled ? status : 'idle', error, disconnect };\n}\n","import { useMemo } from 'react';\nimport { createQueryCache } from './QueryCache';\nimport { useOptionalFrontXQueryClient } from '../queryClient';\n\n/**\n * Exposes the sanctioned imperative cache API for app and MFE code without\n * leaking the raw QueryClient.\n *\n * Preferred usage:\n * - useApiQuery() for declarative reads\n * - useApiMutation() for writes\n * - useQueryCache() for controlled imperative cache inspection and invalidation\n *\n * The returned handle is not bound to the cache scope (mock mode, tenant,\n * session): it writes to whatever scope is current. A write after an await or\n * inside a mutation callback must use the `queryCache` that callback receives,\n * which drops writes once the scope changed since the mutation started.\n */\nexport function useQueryCache() {\n const queryClient = useOptionalFrontXQueryClient();\n\n if (!queryClient) {\n throw new Error(\n '[FrontXProvider] No query cache available. Add queryCache() or queryCacheShared() to your plugin composition.'\n );\n }\n\n return useMemo(() => createQueryCache(queryClient), [queryClient]);\n}\n","/**\n * useMfeBridge Hook - MFE bridge access\n *\n * Returns the ChildMfeBridge from context for communication with host.\n *\n * React Layer: L3\n */\n// @cpt-flow:cpt-frontx-flow-react-bindings-mfe-provider:p1\n// @cpt-algo:cpt-frontx-algo-react-bindings-mfe-context-guard:p1\n// @cpt-dod:cpt-frontx-dod-react-bindings-mfe-hooks:p1\n\nimport { useMfeContext } from '../MfeContext';\nimport type { ChildMfeBridge } from '@gears-frontx/framework';\n\n// ============================================================================\n// Hook Implementation\n// ============================================================================\n\n/**\n * Hook for accessing the MFE bridge.\n *\n * Returns the ChildMfeBridge instance for communication with the host.\n * Must be used within a MfeProvider (i.e., inside an MFE component).\n *\n * @returns Child MFE bridge\n *\n * @example\n * ```tsx\n * function MyMfeComponent() {\n * const bridge = useMfeBridge();\n *\n * // Bridge methods:\n * // bridge.executeActionsChain(chain);\n * // bridge.subscribeToProperty(propertyTypeId, callback);\n *\n * return <div>Domain: {bridge.extDomainId}</div>;\n * }\n * ```\n */\n// @cpt-begin:cpt-frontx-flow-react-bindings-mfe-provider:p1:inst-use-bridge\n// @cpt-begin:cpt-frontx-algo-react-bindings-mfe-context-guard:p1:inst-throw-no-mfe-context\n// @cpt-begin:cpt-frontx-dod-react-bindings-mfe-hooks:p1:inst-use-bridge\nexport function useMfeBridge(): ChildMfeBridge {\n const { bridge } = useMfeContext();\n return bridge;\n}\n// @cpt-end:cpt-frontx-flow-react-bindings-mfe-provider:p1:inst-use-bridge\n// @cpt-end:cpt-frontx-algo-react-bindings-mfe-context-guard:p1:inst-throw-no-mfe-context\n// @cpt-end:cpt-frontx-dod-react-bindings-mfe-hooks:p1:inst-use-bridge\n","/**\n * useSharedProperty Hook - Shared property subscription\n *\n * Subscribes to shared property updates from the host, either through the\n * ambient MfeProvider context or through an explicitly supplied bridge.\n *\n * React Layer: L3\n */\n\nimport { useCallback, useContext, useSyncExternalStore } from 'react';\nimport type { ChildMfeBridge } from '@gears-frontx/framework';\nimport { MfeContext } from '../MfeContext';\n\n// ============================================================================\n// Option Types\n// ============================================================================\n\n/**\n * Options for {@link useSharedProperty}.\n */\nexport interface UseSharedPropertyOptions<T> {\n /**\n * Bridge to read the property from, bypassing `MfeContext`.\n *\n * Pass this when the calling component never mounts `MfeProvider` (for\n * example, a component that receives its bridge directly as a prop or from\n * a non-React entry point). When omitted, the hook falls back to the\n * bridge from `MfeContext` and throws if no `MfeProvider` is mounted,\n * matching the zero-argument form.\n *\n * `bridge` and `propertyTypeId` identify the subscription: changing either\n * one unsubscribes from the old source and subscribes to the new one, and\n * the returned value reflects the new source on the same render.\n */\n bridge?: ChildMfeBridge;\n\n /**\n * Value returned while the host has not published the property yet\n * (`bridge.getProperty()` returns `undefined`).\n *\n * Only the `undefined` sentinel is substituted: a published `null` is a\n * real value and is returned as-is. The host validates every published\n * value against the property's schema before it reaches any MFE\n * (`TypeSystemPlugin.register()` throws on a schema mismatch and the\n * update is never stored or delivered), so no consumer-side filtering is\n * needed -- `T` is simply the caller's declaration of that schema.\n *\n * `fallback` may be passed inline on every render; it does not affect the\n * host subscription.\n */\n fallback?: T;\n}\n\n// ============================================================================\n// Hook Implementation\n// ============================================================================\n\n/**\n * Subscribe to a shared property from the host.\n *\n * Two forms:\n *\n * 1. **Context form** -- `useSharedProperty(propertyTypeId)`. Reads the\n * bridge from `MfeContext` and throws if no `MfeProvider` is mounted.\n * 2. **Options form** -- `useSharedProperty(propertyTypeId, options)`. Pass\n * `options.bridge` for components that never mount `MfeProvider`, and/or\n * `options.fallback` for a value to show until the host publishes one.\n * `options.bridge` may be omitted, in which case the hook still falls\n * back to `MfeContext`.\n *\n * Both forms read through `useSyncExternalStore`: the bridge is the store,\n * `bridge.getProperty()` is the snapshot, so the first render already shows\n * the host's current value, a publish between render and commit is picked\n * up when React re-reads the snapshot after subscribing, and the value is\n * tearing-protected under concurrent rendering.\n *\n * @param propertyTypeId - GTS type ID of the shared property to subscribe to\n * @param options - Optional bridge override and fallback\n * @returns The current property value; `T` when `options.fallback` is set,\n * otherwise `T | undefined`\n *\n * @example Context form (inside MfeProvider)\n * ```tsx\n * function ThemedComponent() {\n * const theme = useSharedProperty<{ primaryColor: string }>(THEME_PROPERTY_ID);\n * return <div style={{ color: theme?.primaryColor }} />;\n * }\n * ```\n *\n * @example Explicit bridge with fallback (no MfeProvider)\n * ```tsx\n * function StandaloneComponent({ bridge }: { bridge: ChildMfeBridge }) {\n * const label = useSharedProperty<string>(LABEL_PROPERTY_ID, {\n * bridge,\n * fallback: 'Untitled',\n * });\n * return <span>{label}</span>;\n * }\n * ```\n */\nexport function useSharedProperty<T = unknown>(propertyTypeId: string): T | undefined;\nexport function useSharedProperty<T>(\n propertyTypeId: string,\n options: UseSharedPropertyOptions<T> & { fallback: T }\n): T;\nexport function useSharedProperty<T = unknown>(\n propertyTypeId: string,\n options?: UseSharedPropertyOptions<T>\n): T | undefined;\nexport function useSharedProperty<T = unknown>(\n propertyTypeId: string,\n options?: UseSharedPropertyOptions<T>\n): T | undefined {\n // useContext is called unconditionally (Rules of Hooks) regardless of whether\n // an explicit bridge was supplied; only the *result* is used conditionally below.\n const contextValue = useContext(MfeContext);\n const bridge = options?.bridge ?? contextValue?.bridge;\n const fallback = options?.fallback;\n\n if (!bridge) {\n throw new Error(\n 'useSharedProperty must be used within a MfeProvider, or given an explicit ' +\n '`bridge` option, for components that never mount MfeProvider.'\n );\n }\n\n const subscribe = useCallback(\n (onStoreChange: () => void) =>\n bridge.subscribeToProperty(propertyTypeId, () => {\n onStoreChange();\n }),\n [bridge, propertyTypeId]\n );\n\n const getSnapshot = useCallback(() => {\n const raw = bridge.getProperty(propertyTypeId)?.value;\n // `undefined` is the only \"not published\" sentinel; `null` is a real value.\n // The caller specifies the expected `T` (as with `useState<T>`/\n // `useContext<T>`); the host has already validated the value against the\n // property's schema, so the assertion states the schema, not a hope.\n return raw === undefined ? fallback : (raw as T);\n }, [bridge, propertyTypeId, fallback]);\n\n return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n}\n","/**\n * useHostAction Hook - Host action requests\n *\n * Returns a callback to request host actions via the bridge.\n *\n * React Layer: L3\n */\n// @cpt-flow:cpt-frontx-flow-react-bindings-use-host-action:p1\n// @cpt-algo:cpt-frontx-algo-react-bindings-mfe-context-guard:p1\n// @cpt-dod:cpt-frontx-dod-react-bindings-mfe-hooks:p1\n\nimport { useCallback } from 'react';\nimport { useMfeContext } from '../MfeContext';\n\n// ============================================================================\n// Hook Implementation\n// ============================================================================\n\n/**\n * Hook for requesting host actions.\n *\n * Returns a callback function that sends an actions chain to the host.\n * Must be used within a MfeProvider (i.e., inside an MFE component).\n *\n * NOTE: This hook provides the interface. Bridge executeActionsChain() delegates to the registry.\n *\n * @param actionTypeId - Type ID of the action to request\n * @returns Callback function to request the action with payload\n *\n * @example\n * ```tsx\n * function MyMfeComponent() {\n * const requestNavigation = useHostAction('gts.frontx.mfes.comm.action.v1~myapp.navigate.v1');\n *\n * const handleClick = () => {\n * requestNavigation({ path: '/dashboard' });\n * };\n *\n * return <button onClick={handleClick}>Navigate</button>;\n * }\n * ```\n */\n// @cpt-begin:cpt-frontx-flow-react-bindings-use-host-action:p1:inst-call-host-action\n// @cpt-begin:cpt-frontx-dod-react-bindings-mfe-hooks:p1:inst-call-host-action\nexport function useHostAction<TPayload extends Record<string, unknown> = Record<string, unknown>>(\n actionTypeId: string\n): (payload?: TPayload) => void {\n // @cpt-begin:cpt-frontx-flow-react-bindings-use-host-action:p1:inst-read-bridge-for-action\n // @cpt-begin:cpt-frontx-algo-react-bindings-mfe-context-guard:p1:inst-throw-no-mfe-context\n // Enforce MfeProvider context requirement\n const { bridge } = useMfeContext(); // Throws if not in MfeProvider\n // @cpt-end:cpt-frontx-flow-react-bindings-use-host-action:p1:inst-read-bridge-for-action\n // @cpt-end:cpt-frontx-algo-react-bindings-mfe-context-guard:p1:inst-throw-no-mfe-context\n\n // @cpt-begin:cpt-frontx-flow-react-bindings-use-host-action:p1:inst-return-action-callback\n return useCallback((payload?: TPayload) => {\n // Construct an ActionsChain with the action\n // With the constraint, TPayload extends Record<string, unknown>,\n // so this is a safe widening from specific to general\n const chain = {\n action: {\n type: actionTypeId,\n target: bridge.extDomainId,\n payload: payload as Record<string, unknown> | undefined,\n },\n };\n\n // @cpt-begin:cpt-frontx-flow-react-bindings-use-host-action:p1:inst-log-action-error\n // Fire-and-forget: `executeActionsChain` returns void.\n bridge.executeActionsChain(chain);\n // @cpt-end:cpt-frontx-flow-react-bindings-use-host-action:p1:inst-log-action-error\n }, [actionTypeId, bridge]);\n // @cpt-end:cpt-frontx-flow-react-bindings-use-host-action:p1:inst-return-action-callback\n}\n// @cpt-end:cpt-frontx-flow-react-bindings-use-host-action:p1:inst-call-host-action\n// @cpt-end:cpt-frontx-dod-react-bindings-mfe-hooks:p1:inst-call-host-action\n","/**\n * useMfeRegistry Hook - Shared MfeRegistry access guard\n *\n * Resolves the MFE-enabled registry off the FrontX app instance and throws a\n * descriptive error when the `microfrontends()` plugin was not installed.\n * Extracted so every registry-consuming hook shares one guard implementation\n * instead of hand-rolling the same `if (!app.mfeRegistry)` check.\n *\n * React Layer: L3\n */\n\nimport { useFrontX } from '../../FrontXContext';\nimport type { FrontXApp, MfeRegistry } from '@gears-frontx/framework';\n\n// ============================================================================\n// Internal Guard\n// ============================================================================\n\n/**\n * Internal, non-hook form of the guard. Lets the registry-consuming hooks name\n * themselves in the thrown message, so a developer learns which hook failed\n * even though the guard itself is shared. Not part of the package's public\n * surface — app code uses {@link useMfeRegistry}.\n *\n * @param app - The FrontX app instance to resolve the registry from\n * @param callerName - Name of the calling hook, used in the error message\n * @returns The MFE-enabled registry\n */\nexport function resolveMfeRegistry(app: FrontXApp, callerName: string): MfeRegistry {\n const registry = app.mfeRegistry;\n\n if (!registry) {\n throw new Error(\n `${callerName} requires the microfrontends plugin. ` +\n 'Add microfrontends() to your Gears FrontX app configuration.'\n );\n }\n\n return registry;\n}\n\n// ============================================================================\n// Hook Implementation\n// ============================================================================\n\n/**\n * Hook for accessing the MFE-enabled registry off the current FrontX app.\n *\n * Throws if the app was built without the `microfrontends()` plugin.\n *\n * @returns The MFE-enabled registry\n *\n * @example\n * ```ts\n * const registry = useMfeRegistry();\n * ```\n */\nexport function useMfeRegistry(): MfeRegistry {\n const app = useFrontX();\n\n return resolveMfeRegistry(app, 'useMfeRegistry');\n}\n","/**\n * useDomainExtensions Hook - Domain extension list subscription\n *\n * Subscribes to store changes to detect when extensions are registered or unregistered,\n * and returns the current list of extensions for a domain.\n *\n * React Layer: L3\n */\n\nimport { useSyncExternalStore, useCallback, useRef } from 'react';\nimport { useFrontX } from '../../FrontXContext';\nimport { resolveMfeRegistry } from './useMfeRegistry';\nimport type { Extension } from '@gears-frontx/framework';\n\n// ============================================================================\n// Hook Implementation\n// ============================================================================\n\n/**\n * Hook for observing extensions registered for a domain.\n *\n * Subscribes to the FrontX store to detect registration state changes,\n * and returns the current list of extensions for the specified domain.\n *\n * @param domainId - Domain ID to query extensions for\n * @returns Array of extensions currently registered for the domain\n *\n * @example\n * ```tsx\n * function SidebarExtensions() {\n * const extensions = useDomainExtensions('gts.frontx.mfes.ext.domain.v1~frontx.screensets.layout.sidebar.v1');\n *\n * return (\n * <div>\n * {extensions.map(ext => (\n * <div key={ext.id}>{ext.id}</div>\n * ))}\n * </div>\n * );\n * }\n * ```\n */\nexport function useDomainExtensions(domainId: string): Array<Omit<Extension, 'route'>> {\n const app = useFrontX();\n const registry = resolveMfeRegistry(app, 'useDomainExtensions');\n\n // Subscribe to store changes.\n // Any dispatch (including registration state updates) triggers a snapshot check.\n // The snapshot comparison ensures only actual extension list changes cause re-renders.\n const subscribe = useCallback(\n (onStoreChange: () => void) => {\n return app.store.subscribe(onStoreChange);\n },\n [app.store]\n );\n\n // Cache the snapshot to maintain referential stability for useSyncExternalStore.\n // Only update when the extension IDs actually change.\n const cacheRef = useRef<{ ids: string; extensions: Array<Omit<Extension, 'route'>> }>({ ids: '', extensions: [] });\n\n const getSnapshot = useCallback(() => {\n const extensions = registry.getExtensionsForDomain(domainId);\n const ids = extensions.map(e => e.id).join(',');\n if (ids !== cacheRef.current.ids) {\n cacheRef.current = { ids, extensions };\n }\n return cacheRef.current.extensions;\n }, [registry, domainId]);\n\n return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n}\n","/**\n * useRegisteredPackages Hook - Registered GTS packages subscription\n *\n * Subscribes to store changes to detect when extensions are registered or unregistered,\n * and returns the current list of registered GTS packages.\n *\n * React Layer: L3\n */\n\nimport { useSyncExternalStore, useCallback, useRef } from 'react';\nimport { useFrontX } from '../../FrontXContext';\nimport { resolveMfeRegistry } from './useMfeRegistry';\n\n// ============================================================================\n// Hook Implementation\n// ============================================================================\n\n/**\n * Hook for observing registered GTS packages.\n *\n * Subscribes to the FrontX store to detect registration state changes,\n * and returns the current list of GTS packages extracted from registered\n * extensions.\n *\n * ARCHITECTURAL NOTE ON STORE SUBSCRIPTION COUPLING:\n * This hook uses `useSyncExternalStore` with `app.store.subscribe`, which\n * fires on any Redux dispatch. Since `registerExtension()` dispatches to\n * the mfe store slice, the subscription WILL trigger when packages change.\n * The `getSnapshot` function calls `mfeRegistry.getRegisteredPackages()`\n * which reads the private `packages` Map. This works because every package\n * map mutation (in registerExtension/unregisterExtension) is always\n * accompanied by a store dispatch in the same serializer callback.\n *\n * IMPORTANT: If a future change mutates the packages map WITHOUT a store\n * dispatch, this hook would fail to re-render. Keep this coupling documented.\n *\n * @returns Array of GTS package strings currently registered\n *\n * @example\n * ```tsx\n * function PackageList() {\n * const packages = useRegisteredPackages();\n *\n * return (\n * <div>\n * {packages.map(pkg => (\n * <div key={pkg}>{pkg}</div>\n * ))}\n * </div>\n * );\n * }\n * ```\n */\nexport function useRegisteredPackages(): string[] {\n const app = useFrontX();\n const registry = resolveMfeRegistry(app, 'useRegisteredPackages');\n\n // Subscribe to store changes.\n // Any dispatch (including registration state updates) triggers a snapshot check.\n // The snapshot comparison ensures only actual package list changes cause re-renders.\n const subscribe = useCallback(\n (onStoreChange: () => void) => {\n return app.store.subscribe(onStoreChange);\n },\n [app.store]\n );\n\n // Cache the snapshot to maintain referential stability for useSyncExternalStore.\n // Only update when the package list actually changes.\n const cacheRef = useRef<{ packages: string; list: string[] }>({ packages: '', list: [] });\n\n const getSnapshot = useCallback(() => {\n const list = registry.getRegisteredPackages();\n const packages = list.join(',');\n if (packages !== cacheRef.current.packages) {\n cacheRef.current = { packages, list };\n }\n return cacheRef.current.list;\n }, [registry]);\n\n return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n}\n","import React from 'react';\nimport { createRoot, type Root } from 'react-dom/client';\nimport type {\n FrontXApp,\n MfeEntryLifecycle,\n ChildMfeBridge,\n MfeMountContext,\n} from '@gears-frontx/framework';\nimport { FrontXProvider } from '../FrontXProvider';\nimport { hasFrontXQueryClientActivator, resolveFrontXQueryClient } from '../queryClient';\nimport { collectDomainTeardowns } from './domainTeardownCollector';\n\n/**\n * Marks every node `adoptHostStylesIntoShadowRoot` puts into a shadow root, so\n * a later mount can find its own previous block and replace it.\n *\n * A marker attribute rather than the single `id` that\n * `injectStylesheet`/`injectCssVariables` key on in `@gears-frontx/mfes`'\n * shadow utilities, because the adopted block is many nodes whose order\n * relative to each other is load-bearing: one id can only name one of them.\n */\nconst ADOPTED_HOST_STYLE_ATTR = 'data-frontx-adopted-host-style';\n\n/** Identity of the base-resets node, so a remount reuses it instead of adding a second. */\nconst BASE_RESETS_STYLE_ID = '__frontx-base-resets__';\n\n/**\n * Ids of the style nodes `@gears-frontx/mfes` puts in a shadow root itself -\n * the isolation block from `createShadowRoot` and the theme variables from\n * `injectCssVariables`. Together with the adopted block they are the\n * shell-owned head of the shadow root, and the base resets belong at its end:\n * after them, ahead of the MFE's own CSS.\n *\n * Mirrored here rather than imported because those utilities keep the ids as\n * local constants. The values are what the shell puts in the shadow root, so\n * they change only when the shell changes them - and the remount test pins\n * this list against the ids those utilities actually emit.\n */\nconst SHELL_OWNED_SHADOW_STYLE_IDS = ['__frontx-shadow-isolation__', '__frontx-css-variables__'];\n\n/**\n * The CSS for the copy of a host `<style>`: its text when it holds anything\n * but whitespace, otherwise the rules of its stylesheet.\n *\n * CSS-in-JS libraries such as emotion and styled-components write every rule\n * into an empty element through `sheet.insertRule` in production. Those rules\n * never appear in `textContent`, so a copy of the text would be an empty\n * `<style>`; for an element without text the copy is built from `cssRules`.\n * Whitespace counts as no text: it holds no rules, so every rule in the sheet\n * of such an element was inserted, and the text would carry none of them.\n *\n * An element with text is copied as written rather than through `cssRules`,\n * because serialising a rule can lose declarations: for a shorthand set with\n * `var()` and followed by one of its longhands (`margin: var(--space-2);\n * margin-left: 0`, as in a ui-kit rule), the other longhands serialise as\n * empty and drop out of the copy. The text also keeps the copy's hash equal to\n * the host's, so a CSP that allows the host `<style>` by its hash allows the\n * copy. A copy built from rules matches no hash; under a CSP only its nonce or\n * `'unsafe-inline'` admits it. The cost is that a rule inserted into an element\n * that also has text is not copied.\n */\nfunction cssToCopy(style: HTMLStyleElement): string {\n const text = style.textContent ?? '';\n const sheet = style.sheet;\n if (text.trim() || !sheet) return text;\n return Array.from(sheet.cssRules, (rule) => rule.cssText).join('\\n');\n}\n\ninterface ProviderMountOptions {\n mfeBridge?: {\n bridge: ChildMfeBridge;\n extensionId: string;\n domainId: string;\n };\n}\n\nfunction resolveProviderMountOptions(\n app: FrontXApp,\n bridge: ChildMfeBridge,\n mountContext?: MfeMountContext\n): ProviderMountOptions {\n const extensionId = mountContext?.extensionId;\n const domainId = mountContext?.domainId;\n const isMountedMfe = typeof extensionId === 'string' && typeof domainId === 'string';\n\n if (\n isMountedMfe &&\n !resolveFrontXQueryClient(app) &&\n !hasFrontXQueryClientActivator(app)\n ) {\n throw new Error(\n '[FrontXProvider] Mounted MFEs require queryCacheShared() in the child app and queryCache() in the host app before loading the MFE app.'\n );\n }\n\n return {\n mfeBridge:\n isMountedMfe\n ? { bridge, extensionId, domainId }\n : undefined,\n };\n}\n\ninterface MountRuntimeAwareProviderProps {\n readonly app: FrontXApp;\n readonly mfeBridge?: Readonly<{\n readonly bridge: ChildMfeBridge;\n readonly extensionId: string;\n readonly domainId: string;\n }>;\n readonly children: React.ReactNode;\n}\n\nfunction MountRuntimeAwareProvider({\n app,\n mfeBridge,\n children,\n}: Readonly<MountRuntimeAwareProviderProps>): React.JSX.Element {\n return (\n <FrontXProvider app={app} mfeBridge={mfeBridge}>\n {children}\n </FrontXProvider>\n );\n}\n\n/**\n * Abstract base class for React-based MFE lifecycle implementations.\n *\n * Styling strategy:\n * 1. adoptHostStylesIntoShadowRoot() clones all host <style> and <link> into the\n * front of the shadow root, bringing the full compiled Tailwind CSS (including\n * MFE utilities, since the host's content paths cover src-app/mfe_packages/**) and\n * the ui-kit component CSS (the host entry side-effect-imports\n * @gears-frontx/ui-kit so that CSS exists in the host document; the kit's\n * CSS-module class names are stable per kit version, so they match the\n * classes MFE bundles reference only while host and MFE install the same\n * kit version - the template-pin-drift policy check is what guarantees\n * that; a drifted MFE renders its kit components unstyled with no error).\n * Front, not back, so the MFE's own stylesheets\n * outrank them - see the method. Design tokens must therefore be full CSS\n * colors - both Tailwind utilities (var(--x)) and ui-kit component CSS\n * consume them directly.\n * 2. injectBaseResets() adds box-model resets and :host defaults that aren't part\n * of Tailwind's compiled output but are needed for consistent rendering, and\n * positions them at the end of the shell-owned head - after the adopted block\n * and the isolation style, ahead of the MFE's own CSS.\n * 3. Subclasses may override initializeStyles() to inject additional CSS that is\n * not covered by the host stylesheet (e.g., MFE-specific @font-face rules).\n *\n * Every mount therefore leaves the same sequence - adopted host block, shadow\n * isolation, base resets, then the MFE's stylesheets - so the shell's CSS is\n * context and the MFE wins every specificity tie against all three shell blocks.\n * Steps 1 and 2 both position what they own rather than appending beside it,\n * because a remounted container arrives with its shadow root intact and the MFE's\n * own stylesheet removed and re-appended around the remount - see each method.\n *\n * Theme CSS variables are delivered via CSS inheritance from :root (Shadow DOM)\n * or via MountManager injection (iframe). MFE lifecycles do NOT need to subscribe\n * to theme changes or call applyThemeToShadowRoot.\n *\n * Concrete subclasses must provide:\n * - `renderContent(bridge)` - screen component rendering\n */\nexport abstract class ThemeAwareReactLifecycle implements MfeEntryLifecycle<ChildMfeBridge> {\n private root: Root | null = null;\n\n constructor(private readonly app: FrontXApp) { }\n\n mount(container: Element | ShadowRoot, bridge: ChildMfeBridge, mountContext?: MfeMountContext): void {\n // Must stay the first statement: this read builds the runtime's registry\n // inside the mount window so the host links it.\n void this.app.mfeRegistry;\n\n if (container instanceof ShadowRoot) {\n this.adoptHostStylesIntoShadowRoot(container);\n }\n\n this.injectBaseResets(container);\n this.initializeStyles(container);\n\n const providerMountOptions = resolveProviderMountOptions(this.app, bridge, mountContext);\n this.root = createRoot(container);\n this.root.render(\n <MountRuntimeAwareProvider\n app={this.app}\n mfeBridge={providerMountOptions.mfeBridge}\n >\n {this.renderContent(bridge)}\n </MountRuntimeAwareProvider>\n );\n }\n\n /**\n * `Root.unmount()` itself is synchronous, but a nested `ExtensionDomainSlot`\n * mounted anywhere in this root's own tree cannot make ITS cleanup\n * synchronous too — its mounter's own `detach()` awaits per-extension\n * unmounts. Collecting whatever that cleanup fire-and-forgets (through\n * `domainTeardownCollector`, scoped to this one `Root.unmount()` call) and\n * awaiting it here is what makes this method's own returned promise settle\n * only once every nested domain this root owns has actually finished\n * tearing down — never before. A root with no routed nested domain\n * collects nothing, and this resolves exactly as before (a microtask after\n * the synchronous unmount, same observable timing `void | Promise<void>`\n * already allows).\n */\n async unmount(_container: Element | ShadowRoot): Promise<void> {\n if (!this.root) return;\n const root = this.root;\n this.root = null;\n const pendingTeardowns = collectDomainTeardowns(() => root.unmount());\n // Waits for EVERY nested teardown to settle before reporting the first\n // failure: `Promise.all` would reject as soon as one fails and let the\n // caller proceed (e.g. destroy the app) while the others still run.\n const settled = await Promise.allSettled(pendingTeardowns);\n const failed = settled.find((result): result is PromiseRejectedResult => result.status === 'rejected');\n if (failed) throw failed.reason;\n }\n\n /**\n * Copy all inline <style> and <link rel=\"stylesheet\"> from the host document\n * into the shadow root so that Tailwind and component styles apply inside the MFE.\n *\n * The clones are inserted ahead of everything already in the shadow root, never\n * appended, because adopted host styles are context rather than authority: where\n * they and the MFE's own CSS declare the same property at equal specificity, the\n * MFE has to win. Appending inverted that. `MfeHandlerMF` injects the MFE's\n * compiled stylesheet into the shadow root before it calls mount, so an appended\n * clone of the shell's Tailwind preflight - whose\n * `button, [type='button'], [type='reset'], [type='submit']` rule sets\n * `background-color: transparent` at specificity (0,1,0) - tied with\n * `@gears-frontx/ui-kit`'s single-class button rule and won on document order,\n * leaving every kit Button transparent until it was hovered.\n *\n * Inserting at the front rather than pushing MFE styles to the back is what makes\n * the invariant hold for stylesheets that appear after mount too - a lazily\n * imported component's CSS module, or whatever initializeStyles() adds - since\n * those land behind the adopted block by construction.\n *\n * A cascade layer around the adopted CSS was the alternative and is rejected:\n * layered rules lose to unlayered ones at *any* specificity, so a host utility\n * class would stop overriding an MFE element selector. Document order keeps\n * specificity in charge and only settles the ties.\n *\n * The block replaces its predecessor instead of stacking on it, the same\n * upsert shape `injectStylesheet` and `injectCssVariables` use in\n * `@gears-frontx/mfes`' shadow utilities, widened from one id-keyed node to a\n * marked block. Replacement is required rather than tidy: `createShadowRoot`\n * hands back an existing `element.shadowRoot` instead of attaching a new one,\n * so remounting the same container runs this method again on a shadow root\n * that already holds a full adopted block, and appending would grow it once\n * per mount with no bound. It does not save re-resolving the cloned `<link>`s -\n * every mount clones them afresh and the browser resolves each clone; what\n * replacement buys is that the count stays at one block instead of one per\n * mount.\n *\n * The block is rebuilt from the host head rather than left in place, because\n * the head is not fixed: a lazily imported chunk adds stylesheets to it after\n * the first mount, and the second mount has to pick those up.\n *\n * A `<style>` is copied into a new element that holds the host's CSS - see\n * `cssToCopy` - and takes three things from the host element: `media`,\n * without which a print-only host style applies on screen inside the MFE;\n * `type`, which keeps the copy of a non-CSS element as inert as the original;\n * and the nonce, without which a nonce-based CSP blocks the copy. The nonce is read from the `nonce` property, because\n * browsers blank the attribute in a document served with a CSP header.\n * Nothing else is carried over, because libraries look for their own\n * attributes inside the shadow root: styled-components, rendering into it,\n * puts its tag right after the last `style[data-styled]` there, so a copy of\n * the host's tag would pull the MFE's rules ahead of the base resets and the\n * MFE's own CSS. A `<link>` is a deep clone and is loaded from its `href`\n * again.\n *\n * The fresh block goes in before the previous one comes out. Removing first\n * leaves the shadow root with no host CSS at all, and everything between that\n * removal and the insertion is synchronous work in this same task - so the gap\n * never reaches a paint, but any code that reads computed styles from the tree\n * in between sees an unstyled one. Inserting first costs one moment with two\n * blocks present, which changes nothing: the old block is a clone of the same\n * host head and loses every tie to the new one on document order anyway.\n */\n protected adoptHostStylesIntoShadowRoot(shadowRoot: ShadowRoot): void {\n // Collected before the insertion, so the marked nodes this removes are only\n // the ones already there: the fresh clones below carry the same marker and\n // a selector query after the insertion would match them too.\n const supersededStyles = Array.from(shadowRoot.querySelectorAll(`[${ADOPTED_HOST_STYLE_ATTR}]`));\n\n const adoptedStyles = document.createDocumentFragment();\n\n // One query covering both kinds, because querySelectorAll returns document\n // order: querying <style> and <link> separately would concatenate the two\n // groups instead, so a host declaring <link A> before <style B> would get\n // them adopted as B then A. That reordering decides which rule wins every\n // specificity tie between them, which is the tie this whole method exists\n // to settle - so the adopted block has to preserve the host's own order,\n // not just sit ahead of the MFE's CSS.\n const hostStyleNodes = document.head.querySelectorAll('style, link[rel=\"stylesheet\"]');\n hostStyleNodes.forEach((el) => {\n if (el instanceof HTMLStyleElement) {\n const copy = document.createElement('style');\n if (el.media) copy.media = el.media;\n if (el.type) copy.type = el.type;\n if (el.nonce) copy.nonce = el.nonce;\n copy.textContent = cssToCopy(el);\n copy.setAttribute(ADOPTED_HOST_STYLE_ATTR, '');\n adoptedStyles.appendChild(copy);\n return;\n }\n const linkClone = el.cloneNode(true) as Element;\n linkClone.setAttribute(ADOPTED_HOST_STYLE_ATTR, '');\n adoptedStyles.appendChild(linkClone);\n });\n\n // Staged in a fragment so the adopted pieces keep their host-document order\n // relative to each other while moving as one block to the front.\n shadowRoot.insertBefore(adoptedStyles, shadowRoot.firstChild);\n supersededStyles.forEach((el) => el.remove());\n }\n\n /**\n * Box-model resets and :host defaults needed inside every shadow root.\n * These aren't part of Tailwind's compiled output but are required for\n * consistent rendering across browsers.\n *\n * Reuses the node a previous mount left behind, exactly as `injectStylesheet`\n * does in `@gears-frontx/mfes`' shadow utilities: a remount runs against a\n * shadow root that `createShadowRoot` handed back intact, and appending a\n * second copy would add one node per mount forever.\n *\n * Reuse alone is not enough, which is why the node is also positioned on every\n * mount rather than left where the previous one sat. These resets are context\n * like the adopted block is - `border-color: currentColor` on `*` is a 0-0-0\n * declaration that beats an MFE preflight's own 0-0-0 reset purely on document\n * order - so they have to stay ahead of the MFE's CSS, and where they land is\n * not stable on its own. `MfeHandlerMF.wrapLifecycleWithStylesheets` removes the\n * MFE's stylesheet on unmount and appends a fresh one before the next mount, so\n * a node merely left in place ends up ahead of that stylesheet on a remount and\n * behind it on the first mount: two different cascades for one component.\n * Anchoring it to the end of the shell-owned head gives every mount the same\n * order - adopted block, isolation, resets, MFE - which is also the order the\n * adoption method's invariant is written against.\n *\n * With no shell-owned node to anchor to, the resets go to the front. That is the\n * plain-`Element` container: no adopted block, no isolation style, and the MFE\n * stylesheet already appended by the handler, so the front is again the only\n * position that leaves the MFE winning ties.\n *\n * Looked up by attribute-selector form rather than `getElementById`, which\n * `ShadowRoot` has but `Element` does not, and this hook takes either.\n */\n private injectBaseResets(container: Element | ShadowRoot): void {\n const existing = container.querySelector<HTMLStyleElement>(\n `style[id=\"${BASE_RESETS_STYLE_ID}\"]`\n );\n const style = existing ?? document.createElement('style');\n style.id = BASE_RESETS_STYLE_ID;\n style.textContent = `\n *, *::before, *::after {\n box-sizing: border-box;\n border-width: 0;\n border-style: solid;\n border-color: currentColor;\n }\n * { margin: 0; padding: 0; }\n :host {\n font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;\n line-height: 1.5;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n color: var(--foreground);\n background-color: var(--background);\n }\n `;\n // Runs whether the node is new or reused: `insertBefore` moves a node that\n // is already in the tree, and is a no-op when it already sits there.\n const shellOwnedHead = container.querySelectorAll(\n [\n `[${ADOPTED_HOST_STYLE_ATTR}]`,\n ...SHELL_OWNED_SHADOW_STYLE_IDS.map((id) => `[id=\"${id}\"]`),\n ].join(', ')\n );\n const lastShellOwnedNode = shellOwnedHead[shellOwnedHead.length - 1];\n container.insertBefore(\n style,\n lastShellOwnedNode ? lastShellOwnedNode.nextSibling : container.firstChild\n );\n }\n\n /**\n * Hook for subclasses to inject additional CSS not covered by the adopted host\n * stylesheet (e.g., MFE-specific @font-face rules or custom animations).\n * No-op by default: host styles adopted in adoptHostStylesIntoShadowRoot()\n * already include all Tailwind utilities compiled from MFE source files.\n */\n protected initializeStyles(_container: Element | ShadowRoot): void {\n // No-op by default.\n }\n\n /**\n * Return the screen-specific React component tree.\n */\n protected abstract renderContent(bridge: ChildMfeBridge): React.ReactNode;\n}\n","/**\n * Collects nested domain-teardown promises synchronously raised while\n * `ThemeAwareReactLifecycle.unmount()` runs `Root.unmount()`.\n *\n * `Root.unmount()` is synchronous, but it runs every unmounting effect's own\n * cleanup synchronously as part of that same call — including\n * `ExtensionDomainSlot`'s own cleanup, which fire-and-forgets its mounter's\n * `detach()` (async: it awaits per-extension unmounts) because React\n * cleanup itself cannot be async. Left alone, the surrounding lifecycle's\n * own `unmount()` would then resolve while nested occupants are still\n * mid-teardown.\n *\n * This module closes that gap without a new public prop on\n * `ExtensionDomainSlot` and without `ThemeAwareReactLifecycle` reaching into\n * React internals: `ThemeAwareReactLifecycle.unmount()` opens a collector\n * before calling `Root.unmount()`, `ExtensionDomainSlot`'s cleanup (any\n * depth beneath that root — `Root.unmount()` unmounts the whole subtree in\n * one synchronous pass) registers its own detach promise into whichever\n * collector is currently open, and `unmount()` awaits everything collected\n * before it resolves. Module-scoped rather than per-call state because the\n * two call sites live in different files of this SAME package (no\n * cross-package externalization boundary to defend against, unlike the\n * router's own realm-global rendezvous) and only one `Root.unmount()` call\n * is ever in flight at a time (JS is single-threaded; nothing re-enters this\n * module between a collector opening and closing).\n *\n * @packageDocumentation\n */\n\nlet activeCollector: Promise<void>[] | undefined;\n\n/**\n * Runs `fn` with a fresh collector active, and returns whatever\n * `fn` registered through {@link registerDomainTeardown} while it ran.\n * Nested calls (an unmount triggered from within another unmount, e.g. a\n * remount's own cleanup) restore the outer collector afterward rather than\n * losing it.\n */\nexport function collectDomainTeardowns(fn: () => void): Promise<void>[] {\n const previousCollector = activeCollector;\n const collector: Promise<void>[] = [];\n activeCollector = collector;\n try {\n fn();\n } finally {\n activeCollector = previousCollector;\n }\n return collector;\n}\n\n/**\n * Registers a nested domain's own teardown promise with whichever collector\n * is currently open. A no-op outside `collectDomainTeardowns` (e.g. a\n * registry with no `ThemeAwareReactLifecycle` owning this React root, such\n * as a bare `createRoot(...).unmount()` in a test) — the promise still runs\n * to completion on its own; nothing here awaits it, so it is still the\n * caller's `void`.\n */\nexport function registerDomainTeardown(promise: Promise<void>): void {\n activeCollector?.push(promise);\n}\n","/**\n * Extension Domain Slot Component\n *\n * Per-domain React component that provides the DOM root for a registered domain.\n * Delegates root attachment to the per-domain ExtensionMounter obtained from the\n * registry. What extensions live inside the root is a domain-policy concern (the\n * active MountStrategy plus the domain implementation's ContainerHooks), not a\n * slot-API concern.\n *\n * The slot is uniform across all cardinalities (Exclusive / Optional / Concurrent).\n * Mount and unmount actions are dispatched by the host application via\n * registry.executeActionsChain — NOT by this component.\n *\n * @packageDocumentation\n */\n// @cpt-flow:cpt-frontx-flow-react-bindings-extension-domain-slot:p1\n// @cpt-state:cpt-frontx-state-react-bindings-extension-slot:p1\n// @cpt-dod:cpt-frontx-dod-react-bindings-extension-slot:p1\n\nimport React, { useEffect, useEffectEvent, useRef, useState } from 'react';\nimport type { MfeRegistry } from '@gears-frontx/framework';\nimport { registerDomainTeardown } from '../domainTeardownCollector';\n\n/**\n * Props for ExtensionDomainSlot component\n */\nexport interface ExtensionDomainSlotProps {\n /**\n * The MFE registry instance.\n */\n registry: MfeRegistry;\n\n /**\n * The domain ID for this slot.\n */\n domainId: string;\n\n /**\n * Optional CSS class name for the root container div.\n */\n className?: string;\n\n /**\n * Optional callback invoked after mounter.attach(element) returns.\n * Receives the root element that was attached.\n */\n onAttached?: (root: Element) => void;\n\n /**\n * Optional callback invoked after mounter.detach() returns on cleanup.\n */\n onDetached?: () => void;\n\n /**\n * Optional loading placeholder rendered before the mounter has been attached.\n * Defaults to null (no visual placeholder).\n */\n loadingComponent?: React.ReactNode;\n}\n\n/**\n * Extension Domain Slot Component\n *\n * Renders a single root `<div>` per domain instance. On ref-attach, resolves the\n * per-domain mounter via registry.getMounter(domainId) and calls mounter.attach(element).\n * On cleanup, calls mounter.detach() which mass-unmounts every currently-mounted\n * extension in the domain so no orphan DOM trees or slice/registry desync remain.\n *\n * @example\n * ```tsx\n * <ExtensionDomainSlot\n * registry={registry}\n * domainId={FRONTX_SCREEN_DOMAIN}\n * loadingComponent={<Loading />}\n * onAttached={(root) => console.log('Root attached:', root)}\n * />\n * ```\n */\n// @cpt-begin:cpt-frontx-flow-react-bindings-extension-domain-slot:p1:inst-render-slot\n// @cpt-begin:cpt-frontx-dod-react-bindings-extension-slot:p1:inst-render-slot\nexport function ExtensionDomainSlot(props: ExtensionDomainSlotProps): React.ReactElement {\n const {\n registry,\n domainId,\n className,\n onAttached,\n onDetached,\n loadingComponent = null,\n } = props;\n\n const rootRef = useRef<HTMLDivElement | null>(null);\n\n // Effect events so effect deps stay minimal — inline parent handlers do not\n // re-run the attach/detach effect on every parent render, yet each call\n // sees the latest committed onAttached/onDetached prop.\n const emitAttached = useEffectEvent((root: Element) => {\n onAttached?.(root);\n });\n const emitDetached = useEffectEvent(() => {\n onDetached?.();\n });\n\n // @cpt-begin:cpt-frontx-state-react-bindings-extension-slot:p1:inst-slot-attached\n // Tracks whether the mounter has been attached to the DOM root.\n // The loading placeholder is shown until attached becomes true.\n const [attached, setAttached] = useState(false);\n // @cpt-end:cpt-frontx-state-react-bindings-extension-slot:p1:inst-slot-attached\n\n useEffect(() => {\n const root = rootRef.current;\n if (!root) {\n return;\n }\n\n // @cpt-begin:cpt-frontx-flow-react-bindings-extension-domain-slot:p1:inst-attach-root\n // Resolve the per-domain mounter and attach the DOM root.\n // The mounter owns all per-extension container placement under this root.\n const mounter = registry.getMounter(domainId);\n mounter.attach(root);\n // @cpt-end:cpt-frontx-flow-react-bindings-extension-domain-slot:p1:inst-attach-root\n\n // @cpt-begin:cpt-frontx-state-react-bindings-extension-slot:p1:inst-slot-attached\n setAttached(true);\n // @cpt-end:cpt-frontx-state-react-bindings-extension-slot:p1:inst-slot-attached\n\n emitAttached(root);\n\n // @cpt-begin:cpt-frontx-flow-react-bindings-extension-domain-slot:p1:inst-detach-root\n return () => {\n // Mass-unmount every extension currently mounted in the domain.\n // detach() is async (awaits per-extension unmounts) but React cleanup is\n // synchronous, so this call site cannot itself await it. Registering\n // the promise with whichever `ThemeAwareReactLifecycle.unmount()` is\n // currently unmounting this root (or any ancestor root, for a nested\n // domain slot) is what lets that lifecycle's own unmount resolve only\n // once this domain's own teardown has actually finished, instead of\n // the moment `Root.unmount()` returns synchronously — see\n // `domainTeardownCollector`'s own doc comment.\n const detachPromise = mounter.detach();\n registerDomainTeardown(detachPromise);\n\n // @cpt-begin:cpt-frontx-state-react-bindings-extension-slot:p1:inst-slot-detached\n setAttached(false);\n // @cpt-end:cpt-frontx-state-react-bindings-extension-slot:p1:inst-slot-detached\n\n // emitDetached is an effect event: it always calls the onDetached prop\n // from the latest committed render, not whatever prop was current when\n // this effect instance was originally set up.\n emitDetached();\n };\n // @cpt-end:cpt-frontx-flow-react-bindings-extension-domain-slot:p1:inst-detach-root\n // @cpt-begin:cpt-frontx-state-react-bindings-extension-slot:p2:inst-slot-stable-rerender\n // ATTACHED → ATTACHED (no-op) when parent supplies the same domainId and\n // registry on re-render: useEffect dep equality short-circuits the attach/detach pair.\n // emitAttached/emitDetached are effect events — non-reactive by contract,\n // so they are excluded from deps and the effect does not re-run when the\n // parent passes new inline handlers.\n }, [registry, domainId]);\n // @cpt-end:cpt-frontx-state-react-bindings-extension-slot:p2:inst-slot-stable-rerender\n\n // @cpt-begin:cpt-frontx-flow-react-bindings-extension-domain-slot:p1:inst-show-loading\n // Render the loading placeholder until the mounter has been attached.\n // Once attached, render the root div with null children — multi-mount children\n // are placed imperatively under this root by the per-domain mounter.\n return (\n <div\n ref={rootRef}\n className={className}\n data-domain-id={domainId}\n >\n {!attached ? loadingComponent : null}\n </div>\n );\n // @cpt-end:cpt-frontx-flow-react-bindings-extension-domain-slot:p1:inst-show-loading\n}\n// @cpt-end:cpt-frontx-flow-react-bindings-extension-domain-slot:p1:inst-render-slot\n// @cpt-end:cpt-frontx-dod-react-bindings-extension-slot:p1:inst-render-slot\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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OAAqD;AACvF,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,mBAAmB;AAAA,EACrB,IAAI;AAEJ,QAAM,cAAU,uBAA8B,IAAI;AAKlD,QAAM,mBAAe,+BAAe,CAAC,SAAkB;AACrD,iBAAa,IAAI;AAAA,EACnB,CAAC;AACD,QAAM,mBAAe,+BAAe,MAAM;AACxC,iBAAa;AAAA,EACf,CAAC;AAKD,QAAM,CAAC,UAAU,WAAW,QAAI,yBAAS,KAAK;AAG9C,gCAAU,MAAM;AACd,UAAM,OAAO,QAAQ;AACrB,QAAI,CAAC,MAAM;AACT;AAAA,IACF;AAKA,UAAM,UAAU,SAAS,WAAW,QAAQ;AAC5C,YAAQ,OAAO,IAAI;AAInB,gBAAY,IAAI;AAGhB,iBAAa,IAAI;AAGjB,WAAO,MAAM;AAUX,YAAM,gBAAgB,QAAQ,OAAO;AACrC,6BAAuB,aAAa;AAGpC,kBAAY,KAAK;AAMjB,mBAAa;AAAA,IACf;AAAA,EAQF,GAAG,CAAC,UAAU,QAAQ,CAAC;AAOvB,SACE;AAAA,IAAC;AAAA;AAAA,MACC,KAAK;AAAA,MACL;AAAA,MACA,kBAAgB;AAAA,MAEf,WAAC,WAAW,mBAAmB;AAAA;AAAA,EAClC;AAGJ;;;A/BhEA,IAAAC,oBAuIO;AAGP,IAAAA,oBAA6D;AAoI7D,IAAAA,oBAGO;AAGP,IAAAA,oBAMO;AAGP,IAAAA,oBAIO;AAGP,IAAAA,oBAUO;AAGP,IAAAA,qBAGO;AAGP,IAAAA,qBAIO;AAGP,IAAAA,qBAGO;AAiCP,IAAAA,qBAgBO;AASP,IAAAA,qBAAwC;AAQxC,IAAAA,qBAIO;AAyCP,IAAAA,qBAA8C;AASvC,IAAMC,YAAsC,mBAAAC;","names":["eventBus","import_react","import_react","import_react","import_framework","import_react","import_jsx_runtime","queryCache","React","controller","import_jsx_runtime","ReduxProvider","import_react","auth","import_react_redux","import_react_redux","import_react","i18nRegistry","import_react","i18nRegistry","module","import_react","import_framework","formatDateFn","formatTimeFn","formatDateTimeFn","formatRelativeFn","formatNumberFn","formatPercentFn","formatCompactFn","formatCurrencyFn","compareStringsFn","createCollatorFn","import_react","themes","import_react","queryCache","import_react","import_react","import_react","import_react","import_react","import_react","import_jsx_runtime","import_react","import_jsx_runtime","import_framework","eventBus","frameworkEventBus"]}