@equinor/fusion-framework-react-app 9.0.8 → 10.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/CHANGELOG.md +85 -14
  2. package/README.md +176 -99
  3. package/dist/esm/ag-grid/useTheme.js +7 -0
  4. package/dist/esm/ag-grid/useTheme.js.map +1 -1
  5. package/dist/esm/analytics/index.js +8 -0
  6. package/dist/esm/analytics/index.js.map +1 -1
  7. package/dist/esm/analytics/useTrackFeature.js +17 -1
  8. package/dist/esm/analytics/useTrackFeature.js.map +1 -1
  9. package/dist/esm/apploader/Apploader.js +1 -1
  10. package/dist/esm/apploader/Apploader.js.map +1 -1
  11. package/dist/esm/apploader/index.js +8 -0
  12. package/dist/esm/apploader/index.js.map +1 -1
  13. package/dist/esm/bookmark/index.js +8 -0
  14. package/dist/esm/bookmark/index.js.map +1 -1
  15. package/dist/esm/context/index.js +8 -0
  16. package/dist/esm/context/index.js.map +1 -1
  17. package/dist/esm/context/useContextProvider.js +6 -0
  18. package/dist/esm/context/useContextProvider.js.map +1 -1
  19. package/dist/esm/context/useCurrentContext.js +14 -0
  20. package/dist/esm/context/useCurrentContext.js.map +1 -1
  21. package/dist/esm/create-legacy-app.js +13 -0
  22. package/dist/esm/create-legacy-app.js.map +1 -1
  23. package/dist/esm/feature-flag/index.js.map +1 -1
  24. package/dist/esm/feature-flag/useFeature.js +20 -4
  25. package/dist/esm/feature-flag/useFeature.js.map +1 -1
  26. package/dist/esm/framework/index.js +8 -1
  27. package/dist/esm/framework/index.js.map +1 -1
  28. package/dist/esm/framework/useFrameworkCurrentContext.js +9 -0
  29. package/dist/esm/framework/useFrameworkCurrentContext.js.map +1 -1
  30. package/dist/esm/help-center/useHelpCenter.js +12 -1
  31. package/dist/esm/help-center/useHelpCenter.js.map +1 -1
  32. package/dist/esm/http/index.js +9 -0
  33. package/dist/esm/http/index.js.map +1 -1
  34. package/dist/esm/http/selectors.js +10 -0
  35. package/dist/esm/http/selectors.js.map +1 -0
  36. package/dist/esm/index.js +16 -2
  37. package/dist/esm/index.js.map +1 -1
  38. package/dist/esm/make-component.js +1 -1
  39. package/dist/esm/make-component.js.map +1 -1
  40. package/dist/esm/msal/index.js +13 -0
  41. package/dist/esm/msal/index.js.map +1 -1
  42. package/dist/esm/msal/useAccessToken.js +15 -3
  43. package/dist/esm/msal/useAccessToken.js.map +1 -1
  44. package/dist/esm/msal/useCurrentAccount.js +12 -2
  45. package/dist/esm/msal/useCurrentAccount.js.map +1 -1
  46. package/dist/esm/msal/useToken.js +19 -3
  47. package/dist/esm/msal/useToken.js.map +1 -1
  48. package/dist/esm/navigation/index.js +8 -0
  49. package/dist/esm/navigation/index.js.map +1 -1
  50. package/dist/esm/navigation/useNavigationModule.js +6 -1
  51. package/dist/esm/navigation/useNavigationModule.js.map +1 -1
  52. package/dist/esm/navigation/useRouter.js +23 -4
  53. package/dist/esm/navigation/useRouter.js.map +1 -1
  54. package/dist/esm/render-app.js +22 -1
  55. package/dist/esm/render-app.js.map +1 -1
  56. package/dist/esm/render-component.js +30 -23
  57. package/dist/esm/render-component.js.map +1 -1
  58. package/dist/esm/settings/index.js +8 -0
  59. package/dist/esm/settings/index.js.map +1 -1
  60. package/dist/esm/useAppModule.js +13 -5
  61. package/dist/esm/useAppModule.js.map +1 -1
  62. package/dist/esm/useAppModules.js +9 -3
  63. package/dist/esm/useAppModules.js.map +1 -1
  64. package/dist/esm/version.js +1 -1
  65. package/dist/esm/version.js.map +1 -1
  66. package/dist/tsconfig.tsbuildinfo +1 -1
  67. package/dist/types/ag-grid/useTheme.d.ts +7 -0
  68. package/dist/types/analytics/index.d.ts +8 -0
  69. package/dist/types/analytics/useTrackFeature.d.ts +17 -1
  70. package/dist/types/apploader/Apploader.d.ts +3 -2
  71. package/dist/types/apploader/index.d.ts +8 -0
  72. package/dist/types/bookmark/index.d.ts +8 -0
  73. package/dist/types/context/index.d.ts +8 -0
  74. package/dist/types/context/useContextProvider.d.ts +6 -0
  75. package/dist/types/context/useCurrentContext.d.ts +14 -0
  76. package/dist/types/create-legacy-app.d.ts +13 -0
  77. package/dist/types/feature-flag/index.d.ts +8 -0
  78. package/dist/types/feature-flag/useFeature.d.ts +20 -4
  79. package/dist/types/framework/index.d.ts +8 -0
  80. package/dist/types/framework/useFrameworkCurrentContext.d.ts +9 -0
  81. package/dist/types/help-center/useHelpCenter.d.ts +12 -1
  82. package/dist/types/http/index.d.ts +9 -0
  83. package/dist/types/http/selectors.d.ts +9 -0
  84. package/dist/types/index.d.ts +18 -1
  85. package/dist/types/make-component.d.ts +15 -0
  86. package/dist/types/msal/index.d.ts +13 -0
  87. package/dist/types/msal/useAccessToken.d.ts +15 -3
  88. package/dist/types/msal/useCurrentAccount.d.ts +12 -2
  89. package/dist/types/msal/useToken.d.ts +19 -3
  90. package/dist/types/navigation/index.d.ts +8 -0
  91. package/dist/types/navigation/useNavigationModule.d.ts +6 -1
  92. package/dist/types/navigation/useRouter.d.ts +23 -4
  93. package/dist/types/render-app.d.ts +22 -1
  94. package/dist/types/render-component.d.ts +16 -1
  95. package/dist/types/settings/index.d.ts +8 -0
  96. package/dist/types/useAppModule.d.ts +13 -5
  97. package/dist/types/useAppModules.d.ts +9 -3
  98. package/dist/types/version.d.ts +1 -1
  99. package/package.json +35 -27
  100. package/src/__tests__/render-app.test.tsx +113 -0
  101. package/src/ag-grid/useTheme.ts +7 -0
  102. package/src/analytics/index.ts +8 -0
  103. package/src/analytics/useTrackFeature.ts +17 -1
  104. package/src/apploader/Apploader.tsx +3 -3
  105. package/src/apploader/index.ts +8 -0
  106. package/src/bookmark/index.ts +8 -0
  107. package/src/context/index.ts +8 -0
  108. package/src/context/useContextProvider.ts +6 -0
  109. package/src/context/useCurrentContext.ts +14 -0
  110. package/src/create-legacy-app.tsx +13 -0
  111. package/src/feature-flag/index.ts +8 -0
  112. package/src/feature-flag/useFeature.ts +20 -4
  113. package/src/framework/index.ts +8 -1
  114. package/src/framework/useFrameworkCurrentContext.ts +9 -0
  115. package/src/help-center/useHelpCenter.ts +12 -1
  116. package/src/http/index.ts +9 -0
  117. package/src/http/selectors.ts +9 -0
  118. package/src/index.ts +20 -2
  119. package/src/make-component.tsx +16 -1
  120. package/src/msal/index.ts +13 -0
  121. package/src/msal/useAccessToken.ts +15 -3
  122. package/src/msal/useCurrentAccount.ts +12 -2
  123. package/src/msal/useToken.ts +19 -3
  124. package/src/navigation/index.ts +8 -0
  125. package/src/navigation/useNavigationModule.ts +6 -1
  126. package/src/navigation/useRouter.ts +23 -4
  127. package/src/render-app.ts +22 -1
  128. package/src/render-component.tsx +36 -27
  129. package/src/settings/index.ts +8 -0
  130. package/src/useAppModule.ts +13 -5
  131. package/src/useAppModules.ts +11 -5
  132. package/src/version.ts +1 -1
  133. package/tsconfig.json +1 -1
  134. package/vitest.config.ts +15 -0
@@ -1,2 +1,9 @@
1
1
  import type { Theme } from '@equinor/fusion-framework-module-ag-grid/themes';
2
+ /**
3
+ * React hook that returns the current AG Grid theme from the application-scoped
4
+ * AG Grid module.
5
+ *
6
+ * @returns The active {@link Theme} object.
7
+ * @throws If the AG Grid module is not registered in the application.
8
+ */
2
9
  export declare const useTheme: () => Theme;
@@ -1 +1,9 @@
1
+ /**
2
+ * Analytics sub-path entry-point.
3
+ *
4
+ * Provides the {@link useTrackFeature} hook for tracking application-level
5
+ * analytics events through the Fusion analytics module.
6
+ *
7
+ * @packageDocumentation
8
+ */
1
9
  export { useTrackFeature } from './useTrackFeature';
@@ -1,5 +1,21 @@
1
1
  import type { AnyValueMap } from '@equinor/fusion-framework-module-analytics';
2
2
  /**
3
- * Hook for using analytics module configured in the framework.
3
+ * React hook that returns a callback for tracking application feature usage
4
+ * via the Fusion analytics module.
5
+ *
6
+ * The tracked event includes the current app key and context (if available)
7
+ * as attributes, enabling downstream analytics dashboards to group events
8
+ * by application and context.
9
+ *
10
+ * @returns A `trackFeature` callback: `(name: string, data?: AnyValueMap) => void`.
11
+ *
12
+ * @example
13
+ * ```tsx
14
+ * const trackFeature = useTrackFeature();
15
+ *
16
+ * const handleClick = useCallback(() => {
17
+ * trackFeature('button-click', { section: 'header' });
18
+ * }, [trackFeature]);
19
+ * ```
4
20
  */
5
21
  export declare const useTrackFeature: () => (name: string, data?: AnyValueMap) => void;
@@ -1,3 +1,4 @@
1
+ import { type ReactElement } from 'react';
1
2
  export type ApploaderProps = {
2
3
  appKey: string;
3
4
  };
@@ -9,10 +10,10 @@ export type ApploaderProps = {
9
10
  *
10
11
  * @param { ApploaderProps } props - The props for the component.
11
12
  * @param { string } props.appKey - The key of the Fusion app to load and mount.
12
- * @returns { JSX.Element } The rendered component, which displays loading, error, or the embedded app.
13
+ * @returns { ReactElement } The rendered component, which displays loading, error, or the embedded app.
13
14
  *
14
15
  * @example
15
16
  * <Apploader appKey="my-app" />
16
17
  */
17
- export declare const Apploader: ({ appKey }: ApploaderProps) => JSX.Element;
18
+ export declare const Apploader: ({ appKey }: ApploaderProps) => ReactElement;
18
19
  export default Apploader;
@@ -1,2 +1,10 @@
1
+ /**
2
+ * Apploader sub-path entry-point.
3
+ *
4
+ * Provides the {@link Apploader} component and {@link useApploader} hook
5
+ * for embedding Fusion child applications inside a parent Fusion application.
6
+ *
7
+ * @packageDocumentation
8
+ */
1
9
  export { Apploader, type ApploaderProps } from './Apploader';
2
10
  export { useApploader } from './useApploader';
@@ -1,3 +1,11 @@
1
+ /**
2
+ * Bookmark sub-path entry-point.
3
+ *
4
+ * Provides helpers to enable and consume the Fusion bookmark module,
5
+ * allowing users to save and restore application state snapshots.
6
+ *
7
+ * @packageDocumentation
8
+ */
1
9
  export { enableBookmark } from '@equinor/fusion-framework-app/enable-bookmark';
2
10
  export { useCurrentBookmark } from './useCurrentBookmark';
3
11
  export { useBookmark } from './useBookmark';
@@ -1,3 +1,11 @@
1
+ /**
2
+ * Context sub-path entry-point.
3
+ *
4
+ * Provides hooks for reading and interacting with the Fusion context
5
+ * (project, facility, etc.) at both the application and framework level.
6
+ *
7
+ * @packageDocumentation
8
+ */
1
9
  export * from '@equinor/fusion-framework-react-module-context';
2
10
  export { useContextProvider } from './useContextProvider';
3
11
  export { useCurrentContext } from './useCurrentContext';
@@ -1,2 +1,8 @@
1
+ /**
2
+ * React hook that resolves the application-scoped context module provider.
3
+ *
4
+ * @returns The context module provider instance.
5
+ * @throws If the context module is not registered in the application scope.
6
+ */
1
7
  export declare const useContextProvider: () => import("@equinor/fusion-framework-module-context").IContextProvider;
2
8
  export default useContextProvider;
@@ -1,3 +1,17 @@
1
+ /**
2
+ * React hook that returns the currently selected Fusion context from the
3
+ * **application-scoped** context module.
4
+ *
5
+ * @returns The current context object, or `undefined` if no context is selected.
6
+ *
7
+ * @example
8
+ * ```tsx
9
+ * const context = useCurrentContext();
10
+ * if (context) {
11
+ * console.log('Selected:', context.title);
12
+ * }
13
+ * ```
14
+ */
1
15
  export declare const useCurrentContext: () => {
2
16
  currentContext: import("@equinor/fusion-framework-module-context").ContextItem | null | undefined;
3
17
  setCurrentContext: (entry?: import("@equinor/fusion-framework-module-context").ContextItem | string | null) => void | Promise<import("@equinor/fusion-framework-module-context").ContextItem<Record<string, unknown>> | null>;
@@ -1,4 +1,17 @@
1
1
  import { type ElementType } from 'react';
2
2
  import type { AnyModule } from '@equinor/fusion-framework-module';
3
3
  import type { AppModuleInitiator } from '@equinor/fusion-framework-app';
4
+ /**
5
+ * Creates a legacy wrapper component that bootstraps a Fusion React app within
6
+ * the older Fusion CLI hosting model.
7
+ *
8
+ * @deprecated Prefer {@link renderApp} for new applications. This helper exists
9
+ * only for backward-compatibility with apps that must run inside the legacy
10
+ * Fusion CLI.
11
+ *
12
+ * @template TModules - Array of additional module types to initialise.
13
+ * @param Component - The root React element to render.
14
+ * @param configure - Optional callback to configure application modules.
15
+ * @returns A React function component that initialises modules and renders the app.
16
+ */
4
17
  export declare const createLegacyApp: <TModules extends Array<AnyModule>>(Component: ElementType, configure?: AppModuleInitiator<TModules>) => () => import("react/jsx-runtime").JSX.Element;
@@ -1,3 +1,11 @@
1
+ /**
2
+ * Feature-flag sub-path entry-point.
3
+ *
4
+ * Provides the {@link enableFeatureFlag} configurator helper and the
5
+ * {@link useFeature} hook for reading and toggling feature flags at runtime.
6
+ *
7
+ * @packageDocumentation
8
+ */
1
9
  export { IFeatureFlag, IFeatureFlagProvider, FeatureFlagModule, } from '@equinor/fusion-framework-module-feature-flag';
2
10
  export { enableFeatureFlag } from './enable-feature-flag';
3
11
  export { useFeature } from './useFeature';
@@ -1,9 +1,25 @@
1
1
  import type { IFeatureFlag } from '@equinor/fusion-framework-module-feature-flag';
2
2
  /**
3
- * Custom hook for accessing and manipulating feature flags.
4
- * @template T - The type of the feature flag value.
5
- * @param key - The key of the feature flag.
6
- * @returns An object containing the feature flag, toggle function, and error (if any).
3
+ * React hook for reading and toggling a single feature flag.
4
+ *
5
+ * Merges feature flags from both the framework and the application scope,
6
+ * so framework-level flags are visible alongside app-specific ones.
7
+ *
8
+ * @template T - The type of the feature flag's value payload.
9
+ * @param key - The unique key identifying the feature flag.
10
+ * @returns An object with:
11
+ * - `feature` – the resolved {@link IFeatureFlag}, or `undefined` if not found.
12
+ * - `toggleFeature` – callback to toggle the flag; pass `true`/`false` to
13
+ * set explicitly, or omit to invert the current state.
14
+ * - `error` – any error from the feature-flag observable.
15
+ *
16
+ * @example
17
+ * ```tsx
18
+ * const { feature, toggleFeature } = useFeature('dark-mode');
19
+ * return (
20
+ * <Switch checked={feature?.enabled} onChange={() => toggleFeature()} />
21
+ * );
22
+ * ```
7
23
  */
8
24
  export declare const useFeature: <T = unknown>(key: string) => {
9
25
  feature?: IFeatureFlag<T>;
@@ -1,2 +1,10 @@
1
+ /**
2
+ * Framework sub-path entry-point.
3
+ *
4
+ * Re-exports framework-level hooks (as opposed to application-scoped ones)
5
+ * for accessing the Fusion instance, current user, and HTTP clients.
6
+ *
7
+ * @packageDocumentation
8
+ */
1
9
  export { useFramework } from '@equinor/fusion-framework-react';
2
10
  export { useCurrentUser, useHttpClient as useFrameworkHttpClient, } from '@equinor/fusion-framework-react/hooks';
@@ -1,3 +1,12 @@
1
+ /**
2
+ * React hook that returns the currently selected context from the
3
+ * **framework-level** context module (as opposed to the application-scoped one).
4
+ *
5
+ * Use this when you need the portal/host context rather than the app's own
6
+ * context provider.
7
+ *
8
+ * @returns The current framework context, or `undefined` if none is selected.
9
+ */
1
10
  export declare const useFrameworkCurrentContext: () => {
2
11
  currentContext: import("@equinor/fusion-framework-module-context").ContextItem | null | undefined;
3
12
  setCurrentContext: (entry?: import("@equinor/fusion-framework-module-context").ContextItem | string | null) => void | Promise<import("@equinor/fusion-framework-module-context").ContextItem<Record<string, unknown>> | null>;
@@ -46,7 +46,18 @@ export interface HelpCenter {
46
46
  openReleaseNotes(): void;
47
47
  }
48
48
  /**
49
- * Hook for accessing help center.
49
+ * React hook that returns an API for opening the portal help-center sidesheet.
50
+ *
51
+ * Each method dispatches a framework event that the portal shell listens for
52
+ * and opens the corresponding help page.
53
+ *
54
+ * @returns A {@link HelpCenter} object with methods to open specific help pages.
55
+ *
56
+ * @example
57
+ * ```tsx
58
+ * const helpCenter = useHelpCenter();
59
+ * <Button onClick={() => helpCenter.openFaqs()}>FAQs</Button>
60
+ * ```
50
61
  */
51
62
  export declare const useHelpCenter: () => HelpCenter;
52
63
  export default useHelpCenter;
@@ -1 +1,10 @@
1
+ /**
2
+ * HTTP sub-path entry-point.
3
+ *
4
+ * Re-exports hooks from `@equinor/fusion-framework-react-module-http`,
5
+ * including {@link useHttpClient} for making authenticated HTTP requests
6
+ * from within a Fusion application.
7
+ *
8
+ * @packageDocumentation
9
+ */
1
10
  export * from '@equinor/fusion-framework-react-module-http';
@@ -0,0 +1,9 @@
1
+ /**
2
+ * HTTP selector utilities.
3
+ *
4
+ * Re-exports response-selector helpers (e.g. JSON, blob, text selectors)
5
+ * from `@equinor/fusion-framework-module-http/selectors`.
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ export * from '@equinor/fusion-framework-module-http/selectors';
@@ -1,12 +1,29 @@
1
+ /**
2
+ * @packageDocumentation
3
+ *
4
+ * React bindings for building Fusion Framework applications.
5
+ *
6
+ * Provides the main entry-point helpers (`renderApp`, `createComponent`, `makeComponent`)
7
+ * plus React hooks for accessing framework modules (HTTP, auth, context, navigation, etc.)
8
+ * from within a Fusion app.
9
+ *
10
+ * @remarks
11
+ * This is the primary package application developers depend on when building
12
+ * React-based Fusion apps. It re-exports core types from `@equinor/fusion-framework-app`
13
+ * and adds React-specific rendering, hooks, and sub-path entry-points for optional
14
+ * modules such as MSAL, feature flags, bookmarks, analytics, and settings.
15
+ */
1
16
  export type { AppConfig, AppEnv, AppModuleInitiator, AppModules, AppModulesInstance, AppRenderFn, IAppConfigurator, } from '@equinor/fusion-framework-app';
17
+ export type { Fusion } from '@equinor/fusion-framework-react';
2
18
  export { AppManifest } from '@equinor/fusion-framework-module-app';
3
19
  export { useAppModule } from './useAppModule';
4
20
  export { useAppModules } from './useAppModules';
5
21
  export { useAppEnvironmentVariables } from './useAppEnvironmentVariables';
6
22
  export { makeComponent, ComponentRenderArgs } from './make-component';
7
23
  export { createLegacyApp } from './create-legacy-app';
8
- export { renderApp } from './render-app';
9
24
  export { createComponent } from './create-component';
25
+ export { renderApp } from './render-app';
10
26
  export { renderComponent } from './render-component';
11
27
  export type { ComponentRenderer } from './create-component';
28
+ export type { RenderTeardown } from './render-component';
12
29
  export { default } from './render-app';
@@ -4,10 +4,25 @@ import { type AppEnv } from '@equinor/fusion-framework-app';
4
4
  import type { AppModuleInitiator, AppModulesInstance } from '@equinor/fusion-framework-app';
5
5
  import type { AnyModule } from '@equinor/fusion-framework-module';
6
6
  import type { FrameworkEvent, FrameworkEventInit } from '@equinor/fusion-framework-module-event';
7
+ /**
8
+ * Arguments supplied when rendering a Fusion app component.
9
+ *
10
+ * @template TFusion - The Fusion framework instance type.
11
+ * @template TEnv - The application environment type.
12
+ */
7
13
  export type ComponentRenderArgs<TFusion extends Fusion = Fusion, TEnv = AppEnv> = {
14
+ /** The Fusion framework instance. */
8
15
  fusion: TFusion;
16
+ /** The application environment (manifest, config, basename, etc.). */
9
17
  env: TEnv;
10
18
  };
19
+ /**
20
+ * Factory function that receives a Fusion instance and environment and returns a
21
+ * lazy React component ready to be rendered.
22
+ *
23
+ * @template TFusion - The Fusion framework instance type.
24
+ * @template TEnv - The application environment type.
25
+ */
11
26
  export type ComponentRenderer<TFusion extends Fusion = Fusion, TEnv = AppEnv> = (fusion: TFusion, env: TEnv) => React.LazyExoticComponent<React.ComponentType>;
12
27
  /**
13
28
  * Creates a lazy loading React Component that initializes and configures modules,
@@ -1,3 +1,16 @@
1
+ /**
2
+ * MSAL authentication sub-path entry-point.
3
+ *
4
+ * Provides React hooks for accessing MSAL-based authentication state
5
+ * (current account, access tokens) from within a Fusion application.
6
+ *
7
+ * @remarks
8
+ * Requires `@equinor/fusion-framework-module-msal` to be installed and
9
+ * configured by the host/portal. Applications should **not** configure the
10
+ * MSAL module themselves.
11
+ *
12
+ * @packageDocumentation
13
+ */
1
14
  export { useCurrentAccount } from './useCurrentAccount';
2
15
  export { useAccessToken } from './useAccessToken';
3
16
  export { useToken } from './useToken';
@@ -1,8 +1,20 @@
1
1
  /**
2
- * Custom hook that retrieves an access token for the specified authentication request.
2
+ * React hook that acquires an OAuth 2.0 access token string via MSAL.
3
3
  *
4
- * @param req - The authentication request.
5
- * @returns An object containing the access token, pending state, and error.
4
+ * This is a convenience wrapper around {@link useToken} that extracts the
5
+ * `accessToken` property from the full `AuthenticationResult`.
6
+ *
7
+ * @param req - The token request containing the `scopes` to acquire.
8
+ * @param req.scopes - Array of scope strings (e.g. `['User.Read']`).
9
+ * @returns An object with:
10
+ * - `token` – the access token string, or `undefined` while pending.
11
+ * - `pending` – `true` while the token is being acquired.
12
+ * - `error` – any error encountered during acquisition.
13
+ *
14
+ * @example
15
+ * ```tsx
16
+ * const { token, pending, error } = useAccessToken({ scopes: ['api://my-api/.default'] });
17
+ * ```
6
18
  */
7
19
  export declare const useAccessToken: (req: {
8
20
  scopes: string[];
@@ -1,6 +1,16 @@
1
1
  import type { AccountInfo } from '@equinor/fusion-framework-module-msal';
2
2
  /**
3
- * Retrieves the current account information from the MSAL provider.
4
- * @returns The current account information or undefined if no account is available.
3
+ * React hook that returns the currently signed-in user's MSAL account info.
4
+ *
5
+ * @returns The {@link AccountInfo} for the active account, or `undefined` if
6
+ * no user is signed in.
7
+ *
8
+ * @example
9
+ * ```tsx
10
+ * const account = useCurrentAccount();
11
+ * if (account) {
12
+ * console.log('Signed in as', account.name);
13
+ * }
14
+ * ```
5
15
  */
6
16
  export declare const useCurrentAccount: () => AccountInfo | undefined;
@@ -1,8 +1,24 @@
1
1
  import type { AuthenticationResult } from '@equinor/fusion-framework-module-msal';
2
2
  /**
3
- * Custom hook for acquiring an authentication token using MSAL.
4
- * @param req - The authentication request.
5
- * @returns An object containing the acquired token, pending state, and error.
3
+ * React hook that acquires a full MSAL {@link AuthenticationResult} for the
4
+ * requested scopes.
5
+ *
6
+ * The hook attempts silent acquisition first and falls back to an interactive
7
+ * prompt when required by the MSAL provider.
8
+ *
9
+ * @param req - The token request containing the `scopes` to acquire.
10
+ * @param req.scopes - Array of scope strings (e.g. `['User.Read']`).
11
+ * @returns An object with:
12
+ * - `token` – the full {@link AuthenticationResult}, or `undefined` while pending.
13
+ * - `pending` – `true` while the token is being acquired.
14
+ * - `error` – any error encountered during acquisition.
15
+ *
16
+ * @example
17
+ * ```tsx
18
+ * const { token, pending } = useToken({ scopes: ['User.Read'] });
19
+ * if (pending) return <Spinner />;
20
+ * console.log('ID token:', token?.idToken);
21
+ * ```
6
22
  */
7
23
  export declare const useToken: (req: {
8
24
  scopes: string[];
@@ -1,2 +1,10 @@
1
+ /**
2
+ * Navigation sub-path entry-point.
3
+ *
4
+ * Provides hooks for accessing the Fusion navigation module and creating
5
+ * client-side routers compatible with `react-router`.
6
+ *
7
+ * @packageDocumentation
8
+ */
1
9
  export { useNavigationModule } from './useNavigationModule';
2
10
  export { useRouter } from './useRouter';
@@ -1,3 +1,8 @@
1
1
  import type { INavigationProvider } from '@equinor/fusion-framework-module-navigation';
2
- /** hook for getting the navigation provider (if enabled!) */
2
+ /**
3
+ * React hook that resolves the application-scoped navigation module provider.
4
+ *
5
+ * @returns The navigation provider instance.
6
+ * @throws If the navigation module has not been enabled for the application.
7
+ */
3
8
  export declare const useNavigationModule: () => INavigationProvider;
@@ -1,8 +1,27 @@
1
1
  import type { INavigationProvider } from '@equinor/fusion-framework-module-navigation';
2
2
  /**
3
- * create a router for react routing
4
- * @see {@link [docs](https://equinor.github.io/fusion-framework/modules/navigation/)}
5
- * @see {@link [react-router](https://reactrouter.com/en/main/routers/create-browser-router)}
6
- * @param routes router objects __(must be static | memorized)__
3
+ * React hook that creates a router instance for client-side navigation.
4
+ *
5
+ * The `routes` argument **must** be static or memoised to avoid re-creating
6
+ * the router on every render.
7
+ *
8
+ * @param routes - An array of route objects compatible with
9
+ * `INavigationProvider.createRouter`.
10
+ * @returns A router instance to pass to `<RouterProvider>`.
11
+ *
12
+ * @see {@link https://equinor.github.io/fusion-framework/modules/navigation/ | Fusion navigation docs}
13
+ * @see {@link https://reactrouter.com/en/main/routers/create-browser-router | react-router docs}
14
+ *
15
+ * @example
16
+ * ```tsx
17
+ * import { useRouter } from '@equinor/fusion-framework-react-app/navigation';
18
+ * import { RouterProvider } from 'react-router-dom';
19
+ *
20
+ * const routes = [{ path: '/', element: <Home /> }];
21
+ * const App = () => {
22
+ * const router = useRouter(routes);
23
+ * return <RouterProvider router={router} />;
24
+ * };
25
+ * ```
7
26
  */
8
27
  export declare const useRouter: (routes: Parameters<INavigationProvider["createRouter"]>[0]) => ReturnType<INavigationProvider["createRouter"]>;
@@ -1,6 +1,27 @@
1
1
  import { createComponent } from './create-component';
2
2
  import { type RenderTeardown } from './render-component';
3
3
  import type { ComponentRenderArgs } from './create-component';
4
- /** @deprecated */
4
+ /**
5
+ * Creates a render function for a Fusion React application.
6
+ *
7
+ * Wraps {@link createComponent} and {@link renderComponent} into a single factory:
8
+ * call the returned function with an `HTMLElement` and `ComponentRenderArgs` to
9
+ * mount the app using React 18's `createRoot` API.
10
+ *
11
+ * @param componentArgs - Arguments forwarded to {@link createComponent} (the React
12
+ * component to render and an optional module-configuration callback).
13
+ * @returns A mount function that accepts a DOM element and render args, and returns
14
+ * a {@link RenderTeardown} callback to unmount the application.
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * import { renderApp } from '@equinor/fusion-framework-react-app';
19
+ * import { App } from './App';
20
+ * import { configure } from './config';
21
+ *
22
+ * export const render = renderApp(App, configure);
23
+ * export default render;
24
+ * ```
25
+ */
5
26
  export declare const renderApp: (...componentArgs: Parameters<typeof createComponent>) => (el: HTMLElement, args: ComponentRenderArgs) => RenderTeardown;
6
27
  export default renderApp;
@@ -1,5 +1,20 @@
1
1
  import type { ComponentRenderArgs, ComponentRenderer } from './create-component';
2
+ /**
3
+ * Callback returned after mounting an application; invoke it to unmount and clean
4
+ * up the React root.
5
+ */
2
6
  export type RenderTeardown = VoidFunction;
3
- /** @deprecated */
7
+ /**
8
+ * Creates a mount function from a {@link ComponentRenderer}.
9
+ *
10
+ * The returned function accepts a target `HTMLElement` and
11
+ * {@link ComponentRenderArgs}, resolves the lazy component via the renderer,
12
+ * and mounts it with React 18's `createRoot`.
13
+ *
14
+ * @param renderer - A {@link ComponentRenderer} that produces a lazy component
15
+ * from Fusion and environment arguments.
16
+ * @returns A function `(el, args) => RenderTeardown` that mounts the app and
17
+ * returns a teardown callback.
18
+ */
4
19
  export declare const renderComponent: (renderer: ComponentRenderer) => (el: HTMLElement, args: ComponentRenderArgs) => RenderTeardown;
5
20
  export default renderComponent;
@@ -1,3 +1,11 @@
1
+ /**
2
+ * Settings sub-path entry-point.
3
+ *
4
+ * Provides hooks for reading and updating per-application user settings
5
+ * that are persisted by the Fusion platform.
6
+ *
7
+ * @packageDocumentation
8
+ */
1
9
  export { useAppSetting } from './useAppSetting';
2
10
  export { useAppSettings } from './useAppSettings';
3
11
  export type { AppSettings } from '@equinor/fusion-framework-module-app';
@@ -1,12 +1,20 @@
1
1
  import type { AppModules, AppModulesInstance } from '@equinor/fusion-framework-app';
2
2
  import type { AnyModule, ModuleKey, ModuleType, ModuleTypes } from '@equinor/fusion-framework-module';
3
3
  /**
4
- * Retrieves the specified app module from the app scope.
4
+ * React hook that retrieves a single module instance from the application scope.
5
5
  *
6
- * @template TType - The type of the app module.
7
- * @template TKey - The key of the app module.
8
- * @param module - The key of the app module to retrieve.
9
- * @returns The app module instance if found, otherwise throws an error.
6
+ * @template TType - The concrete module type (e.g. `ContextModule`). Pass
7
+ * `unknown` to infer the type from the key.
8
+ * @template TKey - The string key used to look up the module.
9
+ * @param module - The key identifying the module to retrieve.
10
+ * @returns The resolved module instance.
11
+ * @throws If the requested module is not registered in the application scope.
12
+ *
13
+ * @example
14
+ * ```tsx
15
+ * const auth = useAppModule('auth');
16
+ * auth.acquireAccessToken().then(console.log);
17
+ * ```
10
18
  */
11
19
  export declare function useAppModule<TType extends AnyModule | unknown = unknown, TKey extends string = ModuleKey<ModuleTypes<AppModules<[TType]>>>>(module: TKey): TType extends AnyModule ? ModuleType<TType> : AppModulesInstance[Extract<keyof AppModulesInstance, TKey>];
12
20
  export default useAppModule;
@@ -1,10 +1,16 @@
1
1
  import type { AppModulesInstance } from '@equinor/fusion-framework-app';
2
2
  import type { AnyModule } from '@equinor/fusion-framework-module';
3
3
  /**
4
- * Custom hook that returns an instance of the app modules.
4
+ * React hook that returns the full set of initialised application-scoped modules.
5
5
  *
6
- * @template T - The type of the app modules.
7
- * @returns An instance of the app modules.
6
+ * @template T - Optional array of additional module types beyond the defaults.
7
+ * @returns The {@link AppModulesInstance} containing all registered modules.
8
+ *
9
+ * @example
10
+ * ```tsx
11
+ * const modules = useAppModules();
12
+ * console.log(Object.keys(modules));
13
+ * ```
8
14
  */
9
15
  export declare const useAppModules: <T extends Array<AnyModule> | unknown = unknown>() => AppModulesInstance<T>;
10
16
  export default useAppModules;
@@ -1 +1 @@
1
- export declare const version = "9.0.8";
1
+ export declare const version = "10.0.0";