@equinor/fusion-framework-react-app 6.0.0 → 6.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/CHANGELOG.md +457 -433
  2. package/dist/esm/ag-grid/useTheme.js.map +1 -1
  3. package/dist/esm/bookmark/useBookmark.js.map +1 -1
  4. package/dist/esm/bookmark/useCurrentBookmark.js.map +1 -1
  5. package/dist/esm/create-component.js.map +1 -1
  6. package/dist/esm/create-legacy-app.js +1 -0
  7. package/dist/esm/create-legacy-app.js.map +1 -1
  8. package/dist/esm/feature-flag/enable-feature-flag.js.map +1 -1
  9. package/dist/esm/feature-flag/useFeature.js.map +1 -1
  10. package/dist/esm/framework/index.js.map +1 -1
  11. package/dist/esm/make-component.js.map +1 -1
  12. package/dist/esm/msal/useAccessToken.js.map +1 -1
  13. package/dist/esm/msal/useCurrentAccount.js.map +1 -1
  14. package/dist/esm/msal/useToken.js.map +1 -1
  15. package/dist/esm/navigation/useRouter.js.map +1 -1
  16. package/dist/esm/render-app.js.map +1 -1
  17. package/dist/esm/render-component.js.map +1 -1
  18. package/dist/esm/settings/useAppSetting.js +1 -2
  19. package/dist/esm/settings/useAppSetting.js.map +1 -1
  20. package/dist/esm/settings/useAppSettings.js +1 -2
  21. package/dist/esm/settings/useAppSettings.js.map +1 -1
  22. package/dist/esm/settings/useAppSettingsStatus.js.map +1 -1
  23. package/dist/esm/useAppEnvironmentVariables.js.map +1 -1
  24. package/dist/esm/useAppModule.js.map +1 -1
  25. package/dist/esm/version.js +1 -1
  26. package/dist/tsconfig.tsbuildinfo +1 -1
  27. package/dist/types/ag-grid/useTheme.d.ts +1 -1
  28. package/dist/types/bookmark/useCurrentBookmark.d.ts +1 -1
  29. package/dist/types/create-component.d.ts +2 -2
  30. package/dist/types/create-legacy-app.d.ts +2 -1
  31. package/dist/types/feature-flag/enable-feature-flag.d.ts +5 -17
  32. package/dist/types/feature-flag/useFeature.d.ts +1 -1
  33. package/dist/types/make-component.d.ts +2 -2
  34. package/dist/types/msal/useCurrentAccount.d.ts +1 -1
  35. package/dist/types/msal/useToken.d.ts +1 -1
  36. package/dist/types/navigation/useNavigationModule.d.ts +1 -1
  37. package/dist/types/navigation/useRouter.d.ts +1 -1
  38. package/dist/types/render-app.d.ts +2 -1
  39. package/dist/types/settings/useAppSettings.d.ts +1 -1
  40. package/dist/types/useAppEnvironmentVariables.d.ts +1 -1
  41. package/dist/types/version.d.ts +1 -1
  42. package/package.json +18 -18
  43. package/src/ag-grid/useTheme.ts +7 -7
  44. package/src/bookmark/index.ts +5 -5
  45. package/src/bookmark/useBookmark.ts +2 -2
  46. package/src/bookmark/useCurrentBookmark.ts +17 -17
  47. package/src/context/useContextProvider.ts +1 -1
  48. package/src/create-component.tsx +40 -39
  49. package/src/create-legacy-app.tsx +25 -24
  50. package/src/feature-flag/enable-feature-flag.ts +42 -43
  51. package/src/feature-flag/index.ts +3 -3
  52. package/src/feature-flag/useFeature.ts +40 -40
  53. package/src/framework/index.ts +2 -2
  54. package/src/index.ts +7 -7
  55. package/src/make-component.tsx +34 -33
  56. package/src/msal/useAccessToken.ts +3 -3
  57. package/src/msal/useCurrentAccount.ts +3 -3
  58. package/src/msal/useToken.ts +16 -16
  59. package/src/navigation/useNavigationModule.ts +1 -1
  60. package/src/navigation/useRouter.ts +4 -4
  61. package/src/render-app.ts +5 -5
  62. package/src/render-component.tsx +16 -16
  63. package/src/settings/useAppSetting.ts +49 -50
  64. package/src/settings/useAppSettings.ts +38 -39
  65. package/src/settings/useAppSettingsStatus.ts +19 -19
  66. package/src/useAppEnvironmentVariables.ts +20 -20
  67. package/src/useAppModule.ts +15 -15
  68. package/src/useAppModules.ts +1 -1
  69. package/src/version.ts +1 -1
  70. package/src/widget/index.ts +4 -4
@@ -1,2 +1,2 @@
1
- import { type Theme } from '@equinor/fusion-framework-module-ag-grid/themes';
1
+ import type { Theme } from '@equinor/fusion-framework-module-ag-grid/themes';
2
2
  export declare const useTheme: () => Theme;
@@ -1,4 +1,4 @@
1
- import { BookmarkData, BookmarkPayloadGenerator } from '@equinor/fusion-framework-react-module-bookmark';
1
+ import { type BookmarkData, type BookmarkPayloadGenerator } from '@equinor/fusion-framework-react-module-bookmark';
2
2
  /**
3
3
  * By providing a CreateBookMarkFn bookmarks is enabled for the current application.
4
4
  *
@@ -1,6 +1,6 @@
1
- import React from 'react';
1
+ import type React from 'react';
2
2
  import type { Fusion } from '@equinor/fusion-framework-react';
3
- import { AppEnv } from '@equinor/fusion-framework-app';
3
+ 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';
@@ -1,3 +1,4 @@
1
+ import { type ElementType } from 'react';
1
2
  import type { AnyModule } from '@equinor/fusion-framework-module';
2
3
  import type { AppModuleInitiator } from '@equinor/fusion-framework-app';
3
- export declare const createLegacyApp: <TModules extends Array<AnyModule>>(Component: React.ElementType, configure?: AppModuleInitiator<TModules>) => () => JSX.Element;
4
+ export declare const createLegacyApp: <TModules extends Array<AnyModule>>(Component: ElementType, configure?: AppModuleInitiator<TModules>) => () => import("react/jsx-runtime").JSX.Element;
@@ -1,4 +1,4 @@
1
- import { type IAppConfigurator } from '@equinor/fusion-framework-app';
1
+ import type { IAppConfigurator } from '@equinor/fusion-framework-app';
2
2
  import { type FeatureFlagBuilderCallback, type IFeatureFlag } from '@equinor/fusion-framework-module-feature-flag';
3
3
  /**
4
4
  * Enables the specified feature flags.
@@ -6,11 +6,9 @@ import { type FeatureFlagBuilderCallback, type IFeatureFlag } from '@equinor/fus
6
6
  * @param configurator - The AppConfigurator instance.
7
7
  * @param flags - An array of feature flags to enable.
8
8
  */
9
- export interface enableFeatureFlag {
10
- (configurator: IAppConfigurator, flags: Array<IFeatureFlag<unknown> & {
11
- allowUrl?: boolean | undefined;
12
- }>): void;
13
- }
9
+ export declare function enableFeatureFlag(configurator: IAppConfigurator, flags: Array<IFeatureFlag<unknown> & {
10
+ allowUrl?: boolean | undefined;
11
+ }>): void;
14
12
  /**
15
13
  * Enables a feature flag by invoking the provided configurator and callback.
16
14
  *
@@ -20,14 +18,4 @@ export interface enableFeatureFlag {
20
18
  * @remarks
21
19
  * Advance use __ONLY__
22
20
  */
23
- export interface enableFeatureFlag {
24
- (configurator: IAppConfigurator, cb: FeatureFlagBuilderCallback): void;
25
- }
26
- /**
27
- * Enables feature flagging based on the provided configurator and flags callback.
28
- * @param configurator The AppConfigurator instance.
29
- * @param flags_cb Optional flags callback that can be an array of feature flags or a callback function.
30
- */
31
- export declare function enableFeatureFlag(configurator: IAppConfigurator, flags_cb: Array<IFeatureFlag<unknown> & {
32
- allowUrl?: boolean | undefined;
33
- }> | FeatureFlagBuilderCallback): void;
21
+ export declare function enableFeatureFlag(configurator: IAppConfigurator, cb: FeatureFlagBuilderCallback): void;
@@ -1,4 +1,4 @@
1
- import { type IFeatureFlag } from '@equinor/fusion-framework-module-feature-flag';
1
+ import type { IFeatureFlag } from '@equinor/fusion-framework-module-feature-flag';
2
2
  /**
3
3
  * Custom hook for accessing and manipulating feature flags.
4
4
  * @template T - The type of the feature flag value.
@@ -1,6 +1,6 @@
1
- import React from 'react';
1
+ import type React from 'react';
2
2
  import type { Fusion } from '@equinor/fusion-framework-react';
3
- import { AppEnv } from '@equinor/fusion-framework-app';
3
+ 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';
@@ -1,4 +1,4 @@
1
- import { AccountInfo } from '@equinor/fusion-framework-module-msal';
1
+ import type { AccountInfo } from '@equinor/fusion-framework-module-msal';
2
2
  /**
3
3
  * Retrieves the current account information from the MSAL provider.
4
4
  * @returns The current account information or undefined if no account is available.
@@ -1,4 +1,4 @@
1
- import { type AuthenticationResult } from '@equinor/fusion-framework-module-msal';
1
+ import type { AuthenticationResult } from '@equinor/fusion-framework-module-msal';
2
2
  /**
3
3
  * Custom hook for acquiring an authentication token using MSAL.
4
4
  * @param req - The authentication request.
@@ -1,3 +1,3 @@
1
- import { INavigationProvider } from '@equinor/fusion-framework-module-navigation';
1
+ import type { INavigationProvider } from '@equinor/fusion-framework-module-navigation';
2
2
  /** hook for getting the navigation provider (if enabled!) */
3
3
  export declare const useNavigationModule: () => INavigationProvider;
@@ -1,4 +1,4 @@
1
- import { type INavigationProvider } from '@equinor/fusion-framework-module-navigation';
1
+ import type { INavigationProvider } from '@equinor/fusion-framework-module-navigation';
2
2
  /**
3
3
  * create a router for react routing
4
4
  * @see {@link [docs](https://equinor.github.io/fusion-framework/modules/navigation/)}
@@ -1,4 +1,5 @@
1
- import { RenderTeardown } from './render-component';
1
+ import { createComponent } from './create-component';
2
+ import { type RenderTeardown } from './render-component';
2
3
  import type { ComponentRenderArgs } from './create-component';
3
4
  /** @deprecated */
4
5
  export declare const renderApp: (Component: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements>, configure?: import("@equinor/fusion-framework-app").AppModuleInitiator<import("@equinor/fusion-framework-module").AnyModule[], import("@equinor/fusion-framework-react").Fusion<unknown>, import("@equinor/fusion-framework-app").AppEnv> | undefined) => (el: HTMLElement, args: ComponentRenderArgs) => RenderTeardown;
@@ -1,4 +1,4 @@
1
- import { type AppSettings } from '@equinor/fusion-framework-module-app';
1
+ import type { AppSettings } from '@equinor/fusion-framework-module-app';
2
2
  import { type AppSettingsStatusHooks } from './useAppSettingsStatus';
3
3
  type UpdateSettingsFunction<T, O = T> = (currentSettings: T | undefined) => O;
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { ConfigEnvironment } from '@equinor/fusion-framework-module-app';
1
+ import type { ConfigEnvironment } from '@equinor/fusion-framework-module-app';
2
2
  import { type ObservableStateReturnType } from '@equinor/fusion-observable/react';
3
3
  /**
4
4
  * A React hook that provides access to the application's environment variables.
@@ -1 +1 @@
1
- export declare const version = "6.0.0";
1
+ export declare const version = "6.0.2";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/fusion-framework-react-app",
3
- "version": "6.0.0",
3
+ "version": "6.0.2",
4
4
  "description": "",
5
5
  "main": "./dist/esm/index.js",
6
6
  "types": "./dist/types/index.d.ts",
@@ -89,13 +89,13 @@
89
89
  "directory": "packages/react"
90
90
  },
91
91
  "dependencies": {
92
- "@equinor/fusion-framework-app": "^9.3.0",
93
- "@equinor/fusion-framework-module": "^4.3.5",
94
- "@equinor/fusion-framework-module-navigation": "^4.0.7",
95
- "@equinor/fusion-framework-module-app": "^6.1.4",
96
- "@equinor/fusion-framework-react": "^7.4.0",
97
- "@equinor/fusion-framework-react-module": "^3.1.6",
98
- "@equinor/fusion-framework-react-module-http": "^8.0.1"
92
+ "@equinor/fusion-framework-app": "^9.3.2",
93
+ "@equinor/fusion-framework-module-app": "^6.1.5",
94
+ "@equinor/fusion-framework-module-navigation": "^4.0.8",
95
+ "@equinor/fusion-framework-react-module": "^3.1.7",
96
+ "@equinor/fusion-framework-react": "^7.4.2",
97
+ "@equinor/fusion-framework-module": "^4.3.6",
98
+ "@equinor/fusion-framework-react-module-http": "^8.0.2"
99
99
  },
100
100
  "devDependencies": {
101
101
  "@types/react": "^18.2.50",
@@ -103,22 +103,22 @@
103
103
  "react": "^18.2.0",
104
104
  "react-dom": "^18.2.0",
105
105
  "rxjs": "^7.8.1",
106
- "typescript": "^5.5.4",
107
- "@equinor/fusion-framework-module-ag-grid": "^33.0.2",
108
- "@equinor/fusion-framework-module-event": "^4.3.0",
109
- "@equinor/fusion-framework-module-msal": "^4.0.0",
110
- "@equinor/fusion-framework-module-feature-flag": "^1.1.12",
111
- "@equinor/fusion-framework-react-module-context": "^6.2.17",
112
- "@equinor/fusion-framework-react-module-bookmark": "^3.0.0",
113
- "@equinor/fusion-framework-react-widget": "^1.1.27",
114
- "@equinor/fusion-observable": "^8.4.4"
106
+ "typescript": "^5.7.3",
107
+ "@equinor/fusion-framework-module-ag-grid": "^33.1.1",
108
+ "@equinor/fusion-framework-module-feature-flag": "^1.1.13",
109
+ "@equinor/fusion-framework-module-event": "^4.3.1",
110
+ "@equinor/fusion-framework-module-msal": "^4.0.1",
111
+ "@equinor/fusion-framework-react-module-bookmark": "^3.0.2",
112
+ "@equinor/fusion-framework-react-module-context": "^6.2.19",
113
+ "@equinor/fusion-framework-react-widget": "^1.1.29",
114
+ "@equinor/fusion-observable": "^8.4.5"
115
115
  },
116
116
  "peerDependencies": {
117
117
  "@types/react": "^17.0.0 || ^18.0.0",
118
118
  "react": "^17.0.0 || ^18.0.0",
119
119
  "react-dom": "^17.0.0 || ^18.0.0",
120
120
  "rxjs": "^7.8.1",
121
- "@equinor/fusion-framework-module-msal": "^4.0.0"
121
+ "@equinor/fusion-framework-module-msal": "^4.0.1"
122
122
  },
123
123
  "peerDependenciesMeta": {
124
124
  "@equinor/fusion-framework-react-module-ag-grid": {
@@ -1,13 +1,13 @@
1
1
  import { useAppModule } from '../useAppModule';
2
- import { type AgGridModule } from '@equinor/fusion-framework-module-ag-grid';
3
- import { type Theme } from '@equinor/fusion-framework-module-ag-grid/themes';
2
+ import type { AgGridModule } from '@equinor/fusion-framework-module-ag-grid';
3
+ import type { Theme } from '@equinor/fusion-framework-module-ag-grid/themes';
4
4
 
5
5
  export const useTheme = (): Theme => {
6
- const agGrid = useAppModule<AgGridModule>('agGrid');
6
+ const agGrid = useAppModule<AgGridModule>('agGrid');
7
7
 
8
- if (!agGrid) {
9
- throw new Error('agGrid module is not available');
10
- }
8
+ if (!agGrid) {
9
+ throw new Error('agGrid module is not available');
10
+ }
11
11
 
12
- return agGrid.theme as Theme;
12
+ return agGrid.theme as Theme;
13
13
  };
@@ -4,9 +4,9 @@ export { useCurrentBookmark } from './useCurrentBookmark';
4
4
  export { useBookmark } from './useBookmark';
5
5
 
6
6
  export type {
7
- Bookmark,
8
- Bookmarks,
9
- BookmarkData,
10
- BookmarkPayloadGenerator,
11
- BookmarkProvider,
7
+ Bookmark,
8
+ Bookmarks,
9
+ BookmarkData,
10
+ BookmarkPayloadGenerator,
11
+ BookmarkProvider,
12
12
  } from '@equinor/fusion-framework-react-module-bookmark';
@@ -1,6 +1,6 @@
1
1
  import {
2
- useBookmark as _useBookmark,
3
- type useBookmarkResult,
2
+ useBookmark as _useBookmark,
3
+ type useBookmarkResult,
4
4
  } from '@equinor/fusion-framework-react-module-bookmark';
5
5
 
6
6
  /**
@@ -1,9 +1,9 @@
1
1
  import {
2
- BookmarkData,
3
- BookmarkPayloadGenerator,
4
- useCurrentBookmark as _useCurrentBookmark,
2
+ type BookmarkData,
3
+ type BookmarkPayloadGenerator,
4
+ useCurrentBookmark as _useCurrentBookmark,
5
5
  } from '@equinor/fusion-framework-react-module-bookmark';
6
- import { BookmarkModule } from '../../../../modules/bookmark/src';
6
+ import type { BookmarkModule } from '../../../../modules/bookmark/src';
7
7
  import { useFrameworkModule } from '@equinor/fusion-framework-react';
8
8
  import useAppModules from '../useAppModules';
9
9
 
@@ -20,20 +20,20 @@ import useAppModules from '../useAppModules';
20
20
  * @return {*} {CurrentBookmark<TData>}
21
21
  */
22
22
  export const useCurrentBookmark = <TData extends BookmarkData>(
23
- payloadGenerator?: BookmarkPayloadGenerator<TData>,
23
+ payloadGenerator?: BookmarkPayloadGenerator<TData>,
24
24
  ) => {
25
- const appBookmarkProvider = useAppModules<[BookmarkModule]>().bookmark;
26
- const frameworkBookmarkProvider = useFrameworkModule<BookmarkModule>('bookmark');
27
- if (!appBookmarkProvider) {
28
- console.warn(
29
- '@deprecation',
30
- 'application has not enabled bookmarks, this will not work in the future',
31
- );
32
- }
33
- return _useCurrentBookmark<TData>({
34
- provider: appBookmarkProvider ?? frameworkBookmarkProvider,
35
- payloadGenerator,
36
- });
25
+ const appBookmarkProvider = useAppModules<[BookmarkModule]>().bookmark;
26
+ const frameworkBookmarkProvider = useFrameworkModule<BookmarkModule>('bookmark');
27
+ if (!appBookmarkProvider) {
28
+ console.warn(
29
+ '@deprecation',
30
+ 'application has not enabled bookmarks, this will not work in the future',
31
+ );
32
+ }
33
+ return _useCurrentBookmark<TData>({
34
+ provider: appBookmarkProvider ?? frameworkBookmarkProvider,
35
+ payloadGenerator,
36
+ });
37
37
  };
38
38
 
39
39
  export default useCurrentBookmark;
@@ -1,4 +1,4 @@
1
- import { type ContextModule } from '@equinor/fusion-framework-react-module-context';
1
+ import type { ContextModule } from '@equinor/fusion-framework-react-module-context';
2
2
  import { useAppModule } from '../useAppModule';
3
3
 
4
4
  export const useContextProvider = () => useAppModule<ContextModule>('context');
@@ -1,9 +1,10 @@
1
- import React, { lazy } from 'react';
1
+ import type React from 'react';
2
+ import { lazy } from 'react';
2
3
 
3
4
  import { FrameworkProvider } from '@equinor/fusion-framework-react';
4
5
  import type { Fusion } from '@equinor/fusion-framework-react';
5
6
 
6
- import { AppEnv, configureModules } from '@equinor/fusion-framework-app';
7
+ import { type AppEnv, configureModules } from '@equinor/fusion-framework-app';
7
8
  import type { AppModuleInitiator, AppModulesInstance } from '@equinor/fusion-framework-app';
8
9
 
9
10
  import type { AnyModule } from '@equinor/fusion-framework-module';
@@ -13,13 +14,13 @@ import type { FrameworkEvent, FrameworkEventInit } from '@equinor/fusion-framewo
13
14
  import { ModuleProvider as AppModuleProvider } from '@equinor/fusion-framework-react-module';
14
15
 
15
16
  export type ComponentRenderArgs<TFusion extends Fusion = Fusion, TEnv = AppEnv> = {
16
- fusion: TFusion;
17
- env: TEnv;
17
+ fusion: TFusion;
18
+ env: TEnv;
18
19
  };
19
20
 
20
21
  export type ComponentRenderer<TFusion extends Fusion = Fusion, TEnv = AppEnv> = (
21
- fusion: TFusion,
22
- env: TEnv,
22
+ fusion: TFusion,
23
+ env: TEnv,
23
24
  ) => React.LazyExoticComponent<React.ComponentType>;
24
25
 
25
26
  /**
@@ -73,42 +74,42 @@ export type ComponentRenderer<TFusion extends Fusion = Fusion, TEnv = AppEnv> =
73
74
  * @param modules - required modules for application
74
75
  */
75
76
  export const createComponent =
76
- <TModules extends Array<AnyModule>, TRef extends Fusion = Fusion, TEnv extends AppEnv = AppEnv>(
77
- Component: React.ElementType,
78
- configure?: AppModuleInitiator<TModules, TRef, TEnv>,
79
- ): ComponentRenderer<TRef, TEnv> =>
80
- (fusion, env) =>
81
- lazy(async () => {
82
- const init = configureModules<TModules, TRef, TEnv>(configure);
83
- const modules = (await init({
84
- fusion,
85
- env,
86
- })) as unknown as AppModulesInstance;
77
+ <TModules extends Array<AnyModule>, TRef extends Fusion = Fusion, TEnv extends AppEnv = AppEnv>(
78
+ Component: React.ElementType,
79
+ configure?: AppModuleInitiator<TModules, TRef, TEnv>,
80
+ ): ComponentRenderer<TRef, TEnv> =>
81
+ (fusion, env) =>
82
+ lazy(async () => {
83
+ const init = configureModules<TModules, TRef, TEnv>(configure);
84
+ const modules = (await init({
85
+ fusion,
86
+ env,
87
+ })) as unknown as AppModulesInstance;
87
88
 
88
- modules.event.dispatchEvent('onReactAppLoaded', {
89
- detail: { modules, fusion },
90
- source: Component,
91
- });
92
- return {
93
- default: () => (
94
- <FrameworkProvider value={fusion}>
95
- <AppModuleProvider value={modules}>
96
- {/* TODO */}
97
- {/* eslint-disable-next-line @typescript-eslint/ban-ts-comment*/}
98
- {/* @ts-ignore */}
99
- <Component />
100
- </AppModuleProvider>
101
- </FrameworkProvider>
102
- ),
103
- };
104
- });
89
+ modules.event.dispatchEvent('onReactAppLoaded', {
90
+ detail: { modules, fusion },
91
+ source: Component,
92
+ });
93
+ return {
94
+ default: () => (
95
+ <FrameworkProvider value={fusion}>
96
+ <AppModuleProvider value={modules}>
97
+ {/* TODO */}
98
+ {/* eslint-disable-next-line @typescript-eslint/ban-ts-comment*/}
99
+ {/* @ts-ignore */}
100
+ <Component />
101
+ </AppModuleProvider>
102
+ </FrameworkProvider>
103
+ ),
104
+ };
105
+ });
105
106
 
106
107
  declare module '@equinor/fusion-framework-module-event' {
107
- interface FrameworkEventMap {
108
- onReactAppLoaded: FrameworkEvent<
109
- FrameworkEventInit<{ modules: AppModulesInstance; fusion: Fusion }, React.ComponentType>
110
- >;
111
- }
108
+ interface FrameworkEventMap {
109
+ onReactAppLoaded: FrameworkEvent<
110
+ FrameworkEventInit<{ modules: AppModulesInstance; fusion: Fusion }, React.ComponentType>
111
+ >;
112
+ }
112
113
  }
113
114
 
114
115
  export default createComponent;
@@ -1,4 +1,4 @@
1
- import { Suspense, useMemo } from 'react';
1
+ import { Suspense, useMemo, type ElementType } from 'react';
2
2
 
3
3
  import { useFramework } from '@equinor/fusion-framework-react';
4
4
 
@@ -6,30 +6,31 @@ import type { AnyModule } from '@equinor/fusion-framework-module';
6
6
  import type { AppEnv, AppModuleInitiator } from '@equinor/fusion-framework-app';
7
7
 
8
8
  import { createComponent } from './create-component';
9
- import { AppModule } from '@equinor/fusion-framework-module-app';
9
+ import type { AppModule } from '@equinor/fusion-framework-module-app';
10
10
 
11
11
  export const createLegacyApp = <TModules extends Array<AnyModule>>(
12
- Component: React.ElementType,
13
- configure?: AppModuleInitiator<TModules>,
12
+ Component: ElementType,
13
+ configure?: AppModuleInitiator<TModules>,
14
14
  ) => {
15
- const LegacyComponent = (): JSX.Element => {
16
- const fusion = useFramework<[AppModule]>();
17
- const RenderComponent = useMemo(() => {
18
- const creator = createComponent(Component, configure);
19
- // @eikeland
20
- // TODO - recheck when legacy fusion-cli is updated!
21
- const appProvider = fusion.modules.app;
22
- if (appProvider?.current) {
23
- const { config, manifest } = appProvider.current;
24
- return creator(fusion, { config, manifest } as unknown as AppEnv);
25
- }
26
- return creator(fusion, {} as unknown as AppEnv);
27
- }, [fusion]);
28
- return (
29
- <Suspense fallback={<p>loading app</p>}>
30
- <RenderComponent />
31
- </Suspense>
32
- );
33
- };
34
- return LegacyComponent;
15
+ const LegacyComponent = () => {
16
+ const fusion = useFramework<[AppModule]>();
17
+ // biome-ignore lint/correctness/useExhaustiveDependencies: this will soon be removed
18
+ const RenderComponent = useMemo(() => {
19
+ const creator = createComponent(Component, configure);
20
+ // @eikeland
21
+ // TODO - recheck when legacy fusion-cli is updated!
22
+ const appProvider = fusion.modules.app;
23
+ if (appProvider?.current) {
24
+ const { config, manifest } = appProvider.current;
25
+ return creator(fusion, { config, manifest } as unknown as AppEnv);
26
+ }
27
+ return creator(fusion, {} as unknown as AppEnv);
28
+ }, [fusion]);
29
+ return (
30
+ <Suspense fallback={<p>loading app</p>}>
31
+ <RenderComponent />
32
+ </Suspense>
33
+ );
34
+ };
35
+ return LegacyComponent;
35
36
  };
@@ -1,14 +1,14 @@
1
- import { type AppConfigurator, type IAppConfigurator } from '@equinor/fusion-framework-app';
1
+ import type { AppConfigurator, IAppConfigurator } from '@equinor/fusion-framework-app';
2
2
 
3
3
  import {
4
- enableFeatureFlagging,
5
- type FeatureFlagBuilderCallback,
6
- type IFeatureFlag,
4
+ enableFeatureFlagging,
5
+ type FeatureFlagBuilderCallback,
6
+ type IFeatureFlag,
7
7
  } from '@equinor/fusion-framework-module-feature-flag';
8
8
 
9
9
  import {
10
- createLocalStoragePlugin,
11
- createUrlPlugin,
10
+ createLocalStoragePlugin,
11
+ createUrlPlugin,
12
12
  } from '@equinor/fusion-framework-module-feature-flag/plugins';
13
13
 
14
14
  /**
@@ -17,12 +17,10 @@ import {
17
17
  * @param configurator - The AppConfigurator instance.
18
18
  * @param flags - An array of feature flags to enable.
19
19
  */
20
- export interface enableFeatureFlag {
21
- (
22
- configurator: IAppConfigurator,
23
- flags: Array<IFeatureFlag<unknown> & { allowUrl?: boolean | undefined }>,
24
- ): void;
25
- }
20
+ export function enableFeatureFlag(
21
+ configurator: IAppConfigurator,
22
+ flags: Array<IFeatureFlag<unknown> & { allowUrl?: boolean | undefined }>,
23
+ ): void;
26
24
 
27
25
  /**
28
26
  * Enables a feature flag by invoking the provided configurator and callback.
@@ -33,9 +31,10 @@ export interface enableFeatureFlag {
33
31
  * @remarks
34
32
  * Advance use __ONLY__
35
33
  */
36
- export interface enableFeatureFlag {
37
- (configurator: IAppConfigurator, cb: FeatureFlagBuilderCallback): void;
38
- }
34
+ export function enableFeatureFlag(
35
+ configurator: IAppConfigurator,
36
+ cb: FeatureFlagBuilderCallback,
37
+ ): void;
39
38
 
40
39
  /**
41
40
  * Enables feature flagging based on the provided configurator and flags callback.
@@ -43,35 +42,35 @@ export interface enableFeatureFlag {
43
42
  * @param flags_cb Optional flags callback that can be an array of feature flags or a callback function.
44
43
  */
45
44
  export function enableFeatureFlag(
46
- configurator: IAppConfigurator,
47
- flags_cb:
48
- | Array<IFeatureFlag<unknown> & { allowUrl?: boolean | undefined }>
49
- | FeatureFlagBuilderCallback,
45
+ configurator: IAppConfigurator,
46
+ flags_cb:
47
+ | Array<IFeatureFlag<unknown> & { allowUrl?: boolean | undefined }>
48
+ | FeatureFlagBuilderCallback,
50
49
  ): void {
51
- switch (typeof flags_cb) {
52
- case 'function': {
53
- enableFeatureFlagging(configurator, flags_cb);
54
- break;
55
- }
56
- case 'object': {
57
- const urlFlags: IFeatureFlag[] = [];
58
- const localFlags = (flags_cb ?? []).map((flag) => {
59
- const { allowUrl, ...localFlag } = flag;
60
- if (allowUrl) {
61
- urlFlags.push(flag);
62
- }
63
- return localFlag;
64
- });
65
- enableFeatureFlagging(configurator, async (builder) => {
66
- // TODO: should unnamed application be allowed to use feature flags?
67
- builder.addPlugin(
68
- createLocalStoragePlugin(localFlags, {
69
- name: (configurator as AppConfigurator).env?.manifest.appKey ?? undefined,
70
- }),
71
- );
72
- builder.addPlugin(createUrlPlugin(urlFlags));
73
- });
74
- break;
50
+ switch (typeof flags_cb) {
51
+ case 'function': {
52
+ enableFeatureFlagging(configurator, flags_cb);
53
+ break;
54
+ }
55
+ case 'object': {
56
+ const urlFlags: IFeatureFlag[] = [];
57
+ const localFlags = (flags_cb ?? []).map((flag) => {
58
+ const { allowUrl, ...localFlag } = flag;
59
+ if (allowUrl) {
60
+ urlFlags.push(flag);
75
61
  }
62
+ return localFlag;
63
+ });
64
+ enableFeatureFlagging(configurator, async (builder) => {
65
+ // TODO: should unnamed application be allowed to use feature flags?
66
+ builder.addPlugin(
67
+ createLocalStoragePlugin(localFlags, {
68
+ name: (configurator as AppConfigurator).env?.manifest.appKey ?? undefined,
69
+ }),
70
+ );
71
+ builder.addPlugin(createUrlPlugin(urlFlags));
72
+ });
73
+ break;
76
74
  }
75
+ }
77
76
  }
@@ -1,7 +1,7 @@
1
1
  export {
2
- IFeatureFlag,
3
- IFeatureFlagProvider,
4
- FeatureFlagModule,
2
+ IFeatureFlag,
3
+ IFeatureFlagProvider,
4
+ FeatureFlagModule,
5
5
  } from '@equinor/fusion-framework-module-feature-flag';
6
6
 
7
7
  export { enableFeatureFlag } from './enable-feature-flag';