/** * @erpsquad/common/runtime: the single shared runtime entry. * * ⚠️ This module is the ONE place the React Contexts that back the library's * cross-cutting state (Auth, Language, Page, Permission) are reached from. * * Why this exists * --------------- * A React Context's identity is the object returned by `createContext()`, and * that object is tied to the physical module copy it lives in. Under Module * Federation, `shared` is keyed by the *import-specifier string*, not the * physical file. When the library is consumed through deep imports, the same * context module is reachable through many specifiers (`@erpsquad/common`, * `/contexts`, `/contexts/AuthContext`, `/hooks`, `/hooks/useAuth`, ...), each a * separate share key. Federation then bundles a copy per app, producing * multiple `createContext` identities, so `useAuth()`/`usePermissions()` read a * context the Host's provider never wrote to (the classic `null` in HRMS). * * The fix: every internal consumer (components, views, ERPUIProvider) imports * these symbols from THIS specifier, and the build keeps `@erpsquad/common/runtime` * external so each chunk keeps a bare `import ... from '@erpsquad/common/runtime'`. * Host and HRMS then share ONLY this one specifier as `singleton: true`, giving * a single context identity across the whole page. Components no longer need to * be added to federation `shared` at all. * * NOTE: this file is the ONLY module that imports the underlying context/hook * files by relative path. That is deliberate: those relative imports are what * bundle the real context code into this one shared runtime graph. Everywhere * else must import these symbols from `@erpsquad/common/runtime`. */ export { AuthContext, AuthProvider, useAuth, } from '../contexts/AuthContext'; export type { AuthContextType, User, DefaultProviderProps, LoginFormValues, resetFormValues, resetPasswordValues, changePasswordValues, changeUserPasswordValues, } from '../contexts/AuthContext'; export { default as LanguageContext, LanguageProvider, useLanguageContext, } from '../contexts/languageContext'; export type { LanguageContextType } from '../contexts/languageContext'; export { PageContext, PageProvider, usePageContext, initialFilter, defaultPageState, } from '../contexts/page-context'; export type { PageState, ViewType, SavedViewType, GeneratedColumnsState, } from '../contexts/page-context'; export { PermissionContext, PermissionsContext, PermissionsProvider, PermissionProvider, usePermissionContext, } from '../contexts/permission-context'; export type { PermissionContextType, PermissionsContextType, Permission, } from '../contexts/permission-context'; export { onApiConfigReady, initializeApiConfig, getApiConfig, getApiConfigSafe, isApiConfigInitialized, resetApiConfig, } from '../utils/api-config'; export type { ApiConfig } from '../utils/api-config'; export { usePermissions } from '../hooks/use-permissions'; export { usePages } from '../hooks/use-pages'; export * from '../hooks/useLangauge'; export * from '../hooks/useLanguageFallback';