@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.
- package/CHANGELOG.md +457 -433
- package/dist/esm/ag-grid/useTheme.js.map +1 -1
- package/dist/esm/bookmark/useBookmark.js.map +1 -1
- package/dist/esm/bookmark/useCurrentBookmark.js.map +1 -1
- package/dist/esm/create-component.js.map +1 -1
- package/dist/esm/create-legacy-app.js +1 -0
- package/dist/esm/create-legacy-app.js.map +1 -1
- package/dist/esm/feature-flag/enable-feature-flag.js.map +1 -1
- package/dist/esm/feature-flag/useFeature.js.map +1 -1
- package/dist/esm/framework/index.js.map +1 -1
- package/dist/esm/make-component.js.map +1 -1
- package/dist/esm/msal/useAccessToken.js.map +1 -1
- package/dist/esm/msal/useCurrentAccount.js.map +1 -1
- package/dist/esm/msal/useToken.js.map +1 -1
- package/dist/esm/navigation/useRouter.js.map +1 -1
- package/dist/esm/render-app.js.map +1 -1
- package/dist/esm/render-component.js.map +1 -1
- package/dist/esm/settings/useAppSetting.js +1 -2
- package/dist/esm/settings/useAppSetting.js.map +1 -1
- package/dist/esm/settings/useAppSettings.js +1 -2
- package/dist/esm/settings/useAppSettings.js.map +1 -1
- package/dist/esm/settings/useAppSettingsStatus.js.map +1 -1
- package/dist/esm/useAppEnvironmentVariables.js.map +1 -1
- package/dist/esm/useAppModule.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/ag-grid/useTheme.d.ts +1 -1
- package/dist/types/bookmark/useCurrentBookmark.d.ts +1 -1
- package/dist/types/create-component.d.ts +2 -2
- package/dist/types/create-legacy-app.d.ts +2 -1
- package/dist/types/feature-flag/enable-feature-flag.d.ts +5 -17
- package/dist/types/feature-flag/useFeature.d.ts +1 -1
- package/dist/types/make-component.d.ts +2 -2
- package/dist/types/msal/useCurrentAccount.d.ts +1 -1
- package/dist/types/msal/useToken.d.ts +1 -1
- package/dist/types/navigation/useNavigationModule.d.ts +1 -1
- package/dist/types/navigation/useRouter.d.ts +1 -1
- package/dist/types/render-app.d.ts +2 -1
- package/dist/types/settings/useAppSettings.d.ts +1 -1
- package/dist/types/useAppEnvironmentVariables.d.ts +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +18 -18
- package/src/ag-grid/useTheme.ts +7 -7
- package/src/bookmark/index.ts +5 -5
- package/src/bookmark/useBookmark.ts +2 -2
- package/src/bookmark/useCurrentBookmark.ts +17 -17
- package/src/context/useContextProvider.ts +1 -1
- package/src/create-component.tsx +40 -39
- package/src/create-legacy-app.tsx +25 -24
- package/src/feature-flag/enable-feature-flag.ts +42 -43
- package/src/feature-flag/index.ts +3 -3
- package/src/feature-flag/useFeature.ts +40 -40
- package/src/framework/index.ts +2 -2
- package/src/index.ts +7 -7
- package/src/make-component.tsx +34 -33
- package/src/msal/useAccessToken.ts +3 -3
- package/src/msal/useCurrentAccount.ts +3 -3
- package/src/msal/useToken.ts +16 -16
- package/src/navigation/useNavigationModule.ts +1 -1
- package/src/navigation/useRouter.ts +4 -4
- package/src/render-app.ts +5 -5
- package/src/render-component.tsx +16 -16
- package/src/settings/useAppSetting.ts +49 -50
- package/src/settings/useAppSettings.ts +38 -39
- package/src/settings/useAppSettingsStatus.ts +19 -19
- package/src/useAppEnvironmentVariables.ts +20 -20
- package/src/useAppModule.ts +15 -15
- package/src/useAppModules.ts +1 -1
- package/src/version.ts +1 -1
- package/src/widget/index.ts +4 -4
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
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:
|
|
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 {
|
|
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
|
|
10
|
-
|
|
11
|
-
|
|
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
|
|
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 {
|
|
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 {
|
|
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 {
|
|
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 {
|
|
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 {
|
|
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.
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "6.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.
|
|
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.
|
|
93
|
-
"@equinor/fusion-framework-module": "^
|
|
94
|
-
"@equinor/fusion-framework-module-navigation": "^4.0.
|
|
95
|
-
"@equinor/fusion-framework-module
|
|
96
|
-
"@equinor/fusion-framework-react": "^7.4.
|
|
97
|
-
"@equinor/fusion-framework-
|
|
98
|
-
"@equinor/fusion-framework-react-module-http": "^8.0.
|
|
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.
|
|
107
|
-
"@equinor/fusion-framework-module-ag-grid": "^33.
|
|
108
|
-
"@equinor/fusion-framework-module-
|
|
109
|
-
"@equinor/fusion-framework-module-
|
|
110
|
-
"@equinor/fusion-framework-module-
|
|
111
|
-
"@equinor/fusion-framework-react-module-
|
|
112
|
-
"@equinor/fusion-framework-react-module-
|
|
113
|
-
"@equinor/fusion-framework-react-widget": "^1.1.
|
|
114
|
-
"@equinor/fusion-observable": "^8.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.
|
|
121
|
+
"@equinor/fusion-framework-module-msal": "^4.0.1"
|
|
122
122
|
},
|
|
123
123
|
"peerDependenciesMeta": {
|
|
124
124
|
"@equinor/fusion-framework-react-module-ag-grid": {
|
package/src/ag-grid/useTheme.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { useAppModule } from '../useAppModule';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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
|
-
|
|
6
|
+
const agGrid = useAppModule<AgGridModule>('agGrid');
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
if (!agGrid) {
|
|
9
|
+
throw new Error('agGrid module is not available');
|
|
10
|
+
}
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
return agGrid.theme as Theme;
|
|
13
13
|
};
|
package/src/bookmark/index.ts
CHANGED
|
@@ -4,9 +4,9 @@ export { useCurrentBookmark } from './useCurrentBookmark';
|
|
|
4
4
|
export { useBookmark } from './useBookmark';
|
|
5
5
|
|
|
6
6
|
export type {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
Bookmark,
|
|
8
|
+
Bookmarks,
|
|
9
|
+
BookmarkData,
|
|
10
|
+
BookmarkPayloadGenerator,
|
|
11
|
+
BookmarkProvider,
|
|
12
12
|
} from '@equinor/fusion-framework-react-module-bookmark';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
23
|
+
payloadGenerator?: BookmarkPayloadGenerator<TData>,
|
|
24
24
|
) => {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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 {
|
|
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');
|
package/src/create-component.tsx
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import 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
|
-
|
|
17
|
-
|
|
17
|
+
fusion: TFusion;
|
|
18
|
+
env: TEnv;
|
|
18
19
|
};
|
|
19
20
|
|
|
20
21
|
export type ComponentRenderer<TFusion extends Fusion = Fusion, TEnv = AppEnv> = (
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
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
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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
|
-
|
|
108
|
-
|
|
109
|
-
|
|
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
|
-
|
|
13
|
-
|
|
12
|
+
Component: ElementType,
|
|
13
|
+
configure?: AppModuleInitiator<TModules>,
|
|
14
14
|
) => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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 {
|
|
1
|
+
import type { AppConfigurator, IAppConfigurator } from '@equinor/fusion-framework-app';
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
enableFeatureFlagging,
|
|
5
|
+
type FeatureFlagBuilderCallback,
|
|
6
|
+
type IFeatureFlag,
|
|
7
7
|
} from '@equinor/fusion-framework-module-feature-flag';
|
|
8
8
|
|
|
9
9
|
import {
|
|
10
|
-
|
|
11
|
-
|
|
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
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
|
37
|
-
|
|
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
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
configurator: IAppConfigurator,
|
|
46
|
+
flags_cb:
|
|
47
|
+
| Array<IFeatureFlag<unknown> & { allowUrl?: boolean | undefined }>
|
|
48
|
+
| FeatureFlagBuilderCallback,
|
|
50
49
|
): void {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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
|
}
|