@equinor/fusion-framework-react 7.1.0 → 7.1.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 +68 -0
- package/dist/esm/app/useAppProvider.js +4 -0
- package/dist/esm/app/useAppProvider.js.map +1 -1
- package/dist/esm/app/useApps.js +5 -0
- package/dist/esm/app/useApps.js.map +1 -1
- package/dist/esm/app/useCurrentApp.js +8 -0
- package/dist/esm/app/useCurrentApp.js.map +1 -1
- package/dist/esm/app/useCurrentAppModule.js +11 -1
- package/dist/esm/app/useCurrentAppModule.js.map +1 -1
- package/dist/esm/app/useCurrentAppModules.js +8 -0
- package/dist/esm/app/useCurrentAppModules.js.map +1 -1
- package/dist/esm/context.js +19 -0
- package/dist/esm/context.js.map +1 -1
- package/dist/esm/create-framework-provider.js +19 -0
- package/dist/esm/create-framework-provider.js.map +1 -1
- package/dist/esm/feature-flag/useCurrentAppFeatures.js +4 -0
- package/dist/esm/feature-flag/useCurrentAppFeatures.js.map +1 -1
- package/dist/esm/feature-flag/useFeature.js +8 -0
- package/dist/esm/feature-flag/useFeature.js.map +1 -1
- package/dist/esm/feature-flag/useFeatures.js +20 -0
- package/dist/esm/feature-flag/useFeatures.js.map +1 -1
- package/dist/esm/feature-flag/useFrameworkFeature.js +8 -0
- package/dist/esm/feature-flag/useFrameworkFeature.js.map +1 -1
- package/dist/esm/feature-flag/useFrameworkFeatures.js +6 -0
- package/dist/esm/feature-flag/useFrameworkFeatures.js.map +1 -1
- package/dist/esm/hooks/use-http-client.js +1 -0
- package/dist/esm/hooks/use-http-client.js.map +1 -1
- package/dist/esm/index.js +4 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/signalr/index.js +22 -0
- package/dist/esm/signalr/index.js.map +1 -1
- package/dist/esm/useFramework.js +9 -0
- package/dist/esm/useFramework.js.map +1 -1
- package/dist/esm/useFrameworkModule.js +12 -0
- package/dist/esm/useFrameworkModule.js.map +1 -1
- package/dist/esm/version.js +2 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/app/useAppProvider.d.ts +5 -1
- package/dist/types/app/useApps.d.ts +5 -0
- package/dist/types/app/useCurrentApp.d.ts +9 -1
- package/dist/types/app/useCurrentAppModule.d.ts +12 -2
- package/dist/types/app/useCurrentAppModules.d.ts +10 -2
- package/dist/types/context/useCurrentContext.d.ts +1 -1
- package/dist/types/context.d.ts +18 -1
- package/dist/types/create-framework-provider.d.ts +20 -1
- package/dist/types/feature-flag/useCurrentAppFeatures.d.ts +4 -0
- package/dist/types/feature-flag/useFeature.d.ts +11 -0
- package/dist/types/feature-flag/useFeatures.d.ts +12 -0
- package/dist/types/feature-flag/useFrameworkFeature.d.ts +8 -0
- package/dist/types/feature-flag/useFrameworkFeatures.d.ts +6 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/signalr/index.d.ts +22 -0
- package/dist/types/useFramework.d.ts +10 -1
- package/dist/types/useFrameworkModule.d.ts +10 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +13 -13
- package/src/version.ts +1 -1
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { FusionModulesInstance } from '@equinor/fusion-framework';
|
|
2
2
|
import { AppModule } from '@equinor/fusion-framework-module-app';
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* React Hook - get appProvider interface
|
|
5
|
+
* @returns framework AppModule
|
|
6
|
+
*/
|
|
7
|
+
export declare const useAppProvider: () => FusionModulesInstance<[AppModule]>["app"];
|
|
4
8
|
export default useAppProvider;
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { AppManifest } from '@equinor/fusion-framework-module-app';
|
|
2
|
+
/**
|
|
3
|
+
* React Hook - Get apps from framework
|
|
4
|
+
* @param args Object with boolean member includeHidden
|
|
5
|
+
* @returns Object {apps, isLoading} where apps is Array of AppManifest, isLoading is a boolean on observable complete
|
|
6
|
+
*/
|
|
2
7
|
export declare const useApps: (args?: {
|
|
3
8
|
includeHidden: boolean;
|
|
4
9
|
}) => {
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { type AnyModule } from '@equinor/fusion-framework-module';
|
|
2
2
|
import { type CurrentApp } from '@equinor/fusion-framework-module-app';
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Observers the stream of current app and return the latest application
|
|
5
|
+
*
|
|
6
|
+
* __Warning:__ type hint templates are only hints, this does not check if the modules are actually enabled!
|
|
7
|
+
*
|
|
8
|
+
* @template TModule type hint modules which the application has configured
|
|
9
|
+
* @template TEnv type hint what kind of environment config the application has
|
|
10
|
+
*/
|
|
11
|
+
export declare const useCurrentApp: <TModules extends Array<AnyModule> = [], TEnv = unknown>() => {
|
|
4
12
|
currentApp?: CurrentApp<TModules, TEnv> | null;
|
|
5
13
|
setCurrentApp: (appKey: string) => void;
|
|
6
14
|
clearCurrentApp: () => void;
|
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
import { AppModules, AppModulesInstance } from '@equinor/fusion-framework-module-app';
|
|
2
2
|
import { ModuleKey, type AnyModule, ModuleTypes, ModuleType } from '@equinor/fusion-framework-module';
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Retrieves the current app module based on the provided module key.
|
|
5
|
+
* @template TType - The type of the module.
|
|
6
|
+
* @template TKey - The type of the module key.
|
|
7
|
+
* @param {TKey} moduleKey - The key of the module to retrieve.
|
|
8
|
+
* @returns {AnyModule | null | undefined} - The current app module or null if not found.
|
|
9
|
+
* @remarks
|
|
10
|
+
* - when module is null, there are no current selected application
|
|
11
|
+
* - when undefined is, the application has not enabled the requested module
|
|
12
|
+
*/
|
|
13
|
+
export declare const useCurrentAppModule: <TType extends AnyModule | unknown = unknown, TKey extends string = ModuleKey<ModuleTypes<AppModules<[TType]>>>>(moduleKey: TKey) => {
|
|
14
|
+
module?: (TType extends AnyModule ? ModuleType<TType> : AppModulesInstance[Extract<keyof AppModulesInstance, TKey>]) | null;
|
|
5
15
|
error?: unknown;
|
|
6
16
|
complete: boolean;
|
|
7
17
|
};
|
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import { AppModulesInstance } from '@equinor/fusion-framework-module-app';
|
|
2
2
|
import { type AnyModule } from '@equinor/fusion-framework-module';
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Observers the stream of current app initialized modules
|
|
5
|
+
*
|
|
6
|
+
* __Warning:__ type hint templates are only hints, this does not check if the modules are actually enabled!
|
|
7
|
+
*
|
|
8
|
+
* @template TModule type hint modules which the application has configured
|
|
9
|
+
* @returns the observable instance of initialized modules of the application
|
|
10
|
+
*/
|
|
11
|
+
export declare const useCurrentAppModules: <TModules extends Array<AnyModule> = []>() => {
|
|
12
|
+
modules?: AppModulesInstance<TModules> | null;
|
|
5
13
|
error?: unknown;
|
|
6
14
|
complete: boolean;
|
|
7
15
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const useCurrentContext: () => {
|
|
2
2
|
currentContext: import("@equinor/fusion-framework-react-module-context").ContextItem | null | undefined;
|
|
3
|
-
setCurrentContext: (entry?:
|
|
3
|
+
setCurrentContext: (entry?: import("@equinor/fusion-framework-react-module-context").ContextItem | string | null) => void | Promise<import("@equinor/fusion-framework-react-module-context").ContextItem<Record<string, unknown>> | null>;
|
|
4
4
|
};
|
|
5
5
|
export default useCurrentContext;
|
package/dist/types/context.d.ts
CHANGED
|
@@ -1,4 +1,21 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import type { Fusion } from '@equinor/fusion-framework';
|
|
3
2
|
export declare const context: import("react").Context<Fusion<any> | null>;
|
|
3
|
+
/**
|
|
4
|
+
* Component for providing framework.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Should be created by {@link createFrameworkProvider}
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* import {FrameworkProvider} from '@equinor/fusion-framework-react';
|
|
12
|
+
* export const Component = (args: React.PropsWithChildren<{framework: Fusion}>) => {
|
|
13
|
+
* return (
|
|
14
|
+
* <FrameworkProvider value={args.framework}>
|
|
15
|
+
* {args.children}
|
|
16
|
+
* </FrameworkProvider>
|
|
17
|
+
* );
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
4
21
|
export declare const FrameworkProvider: import("react").Provider<Fusion<any> | null>;
|
|
@@ -1,4 +1,23 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { FusionConfigurator } from '@equinor/fusion-framework';
|
|
3
3
|
import type { AnyModule } from '@equinor/fusion-framework-module';
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Create a framework provider for react.
|
|
6
|
+
*
|
|
7
|
+
* This function is for providers of framework, like a portal.
|
|
8
|
+
*
|
|
9
|
+
* @param configurator - callback for configuring modules
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* const config: FusionConfigurator = (config) => {}
|
|
13
|
+
* const Portal = () => {
|
|
14
|
+
* const Framework = createFrameworkProvider(config);
|
|
15
|
+
* return (
|
|
16
|
+
* <Suspense fallback={<span>loading...</span>}>
|
|
17
|
+
* <Framework>{children}</Framework>
|
|
18
|
+
* </Suspense>
|
|
19
|
+
* );
|
|
20
|
+
* };
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare const createFrameworkProvider: <TModules extends Array<AnyModule> = []>(cb: (configurator: FusionConfigurator<TModules>) => void | Promise<void>) => React.LazyExoticComponent<React.FunctionComponent<React.PropsWithChildren<unknown>>>;
|
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
import { type UseFeaturesResult } from './useFeatures';
|
|
2
|
+
/**
|
|
3
|
+
* Custom hook that returns the current app features and provides a function to toggle a feature.
|
|
4
|
+
* @returns An object containing the current app features, a function to toggle a feature, and any error that occurred.
|
|
5
|
+
*/
|
|
2
6
|
export declare const useCurrentAppFeatures: () => UseFeaturesResult;
|
|
@@ -2,7 +2,18 @@ import { type IFeatureFlag, type IFeatureFlagProvider } from '@equinor/fusion-fr
|
|
|
2
2
|
export interface UseFeatureResult<T> {
|
|
3
3
|
feature?: IFeatureFlag<T>;
|
|
4
4
|
error?: unknown;
|
|
5
|
+
/**
|
|
6
|
+
* @param enable - Optional provide new enabled state of the feature flag. _Defaults to inversion of current feature flag state_
|
|
7
|
+
*/
|
|
5
8
|
toggleFeature: (enable?: boolean) => void;
|
|
6
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* Custom hook that retrieves a feature flag from a feature flag provider.
|
|
12
|
+
*
|
|
13
|
+
* @template T - The type of the feature flag value.
|
|
14
|
+
* @param {IFeatureFlagProvider} provider - The feature flag provider.
|
|
15
|
+
* @param {string} key - The key of the feature flag.
|
|
16
|
+
* @returns {UseFeatureResult<T>} - An object containing the feature flag value, a function to toggle the feature flag, and any error that occurred.
|
|
17
|
+
*/
|
|
7
18
|
export declare const useFeature: <T = unknown>(provider: IFeatureFlagProvider, key: string) => UseFeatureResult<T>;
|
|
8
19
|
export default useFeature;
|
|
@@ -3,7 +3,19 @@ import { type FeatureSelectorFn } from '@equinor/fusion-framework-module-feature
|
|
|
3
3
|
export interface UseFeaturesResult {
|
|
4
4
|
features: IFeatureFlag[];
|
|
5
5
|
error: unknown;
|
|
6
|
+
/**
|
|
7
|
+
* @param key - The key of the feature flag.
|
|
8
|
+
* @param enable - Optional provide new enabled state of the feature flag. _Defaults to inversion of current feature flag state_
|
|
9
|
+
*/
|
|
6
10
|
toggleFeature: (key: string, enable?: boolean) => void;
|
|
7
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Custom hook that provides access to the feature flags and their values.
|
|
14
|
+
*
|
|
15
|
+
* @param provider - The feature flag provider.
|
|
16
|
+
* @param selector - Optional function to filter the feature flags.
|
|
17
|
+
* @returns An object containing the features, any error that occurred while retrieving them, and a function to set the enabled state of a feature flag.
|
|
18
|
+
* @throws Error if the feature flag provider is missing.
|
|
19
|
+
*/
|
|
8
20
|
export declare const useFeatures: (provider?: IFeatureFlagProvider | null, selector?: FeatureSelectorFn) => UseFeaturesResult;
|
|
9
21
|
export default useFeatures;
|
|
@@ -1,3 +1,11 @@
|
|
|
1
1
|
import { useFeature } from './useFeature';
|
|
2
|
+
/**
|
|
3
|
+
* Custom hook that allows accessing a framework feature based on a given feature flag key.
|
|
4
|
+
*
|
|
5
|
+
* @template T - The type of the feature.
|
|
6
|
+
* @param {string} key - The feature flag key.
|
|
7
|
+
* @returns {ReturnType<typeof useFeature<T>>} - The result of the feature hook.
|
|
8
|
+
* @throws {Error} - If feature flagging is not enabled in the framework.
|
|
9
|
+
*/
|
|
2
10
|
export declare const useFrameworkFeature: <T>(key: string) => ReturnType<typeof useFeature<T>>;
|
|
3
11
|
export default useFrameworkFeature;
|
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import { useFeatures } from './useFeatures';
|
|
2
|
+
/**
|
|
3
|
+
* Custom hook that provides access to framework-specific feature flags.
|
|
4
|
+
* It returns the result of the `useFeatures` hook from the `featureFlag` module.
|
|
5
|
+
* @returns The result of the `useFeatures` hook.
|
|
6
|
+
* @throws Error if feature flagging is not enabled in the framework.
|
|
7
|
+
*/
|
|
2
8
|
export declare const useFrameworkFeatures: () => ReturnType<typeof useFeatures>;
|
|
3
9
|
export default useFrameworkFeatures;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,2 +1,24 @@
|
|
|
1
1
|
import { useProviderTopic } from '@equinor/fusion-framework-react-module-signalr';
|
|
2
|
+
/**
|
|
3
|
+
* hook for subscribing to a topic of a SignalR hub
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
```ts
|
|
7
|
+
// config.ts
|
|
8
|
+
import {enableSignalR} from '@equinor/fusion-framework-react-module-signalr';
|
|
9
|
+
(configurator) => enableSignalR(configurator, 'notifications');
|
|
10
|
+
|
|
11
|
+
// myHook.ts
|
|
12
|
+
const myHook = () => {
|
|
13
|
+
const topic = useSignalR('notifications', 'foo');
|
|
14
|
+
return useObservableState(topic).next;
|
|
15
|
+
}
|
|
16
|
+
```
|
|
17
|
+
*
|
|
18
|
+
* @see {@link [module signalr](https://equinor.github.io/fusion-framework/modules/signalr)}
|
|
19
|
+
*
|
|
20
|
+
* @param hubId identifier of connection hub (must be configured)
|
|
21
|
+
* @param topicId identifier of topic to connect to
|
|
22
|
+
* @returns Topic
|
|
23
|
+
*/
|
|
2
24
|
export declare const useSignalR: <T>(hubId: string, topicId: string) => ReturnType<typeof useProviderTopic<T>>;
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import type { Fusion } from '@equinor/fusion-framework';
|
|
2
2
|
import type { AnyModule } from '@equinor/fusion-framework-module';
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* const useSometing = () => {
|
|
7
|
+
* const fusion = useFramework();
|
|
8
|
+
* return fusion.something;
|
|
9
|
+
* }
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export declare const useFramework: <TModules extends Array<AnyModule> = []>() => Fusion<TModules>;
|
|
4
13
|
export default useFramework;
|
|
@@ -1,3 +1,12 @@
|
|
|
1
1
|
import type { FusionModules, FusionModulesInstance } from '@equinor/fusion-framework';
|
|
2
2
|
import { AnyModule, ModuleKey, ModuleType, ModuleTypes } from '@equinor/fusion-framework-module';
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Retrieves a module from the framework instance based on its name.
|
|
5
|
+
*
|
|
6
|
+
* @template TType - The type of the module to retrieve.
|
|
7
|
+
* @template TKey - The type of the module name.
|
|
8
|
+
* @param name - The name of the module to retrieve.
|
|
9
|
+
* @returns The requested module from the framework instance.
|
|
10
|
+
* @throws Error if the requested module is not included in the framework instance.
|
|
11
|
+
*/
|
|
12
|
+
export declare const useFrameworkModule: <TType extends AnyModule | unknown = unknown, TKey extends string = ModuleKey<ModuleTypes<FusionModules<[TType]>>>>(name: TKey) => TType extends AnyModule ? ModuleType<TType> | undefined : FusionModulesInstance[Extract<keyof FusionModulesInstance, TKey>] | undefined;
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "7.1.
|
|
1
|
+
export declare const version = "7.1.2";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@equinor/fusion-framework-react",
|
|
3
|
-
"version": "7.1.
|
|
3
|
+
"version": "7.1.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/esm/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -69,29 +69,29 @@
|
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
71
|
"rxjs": "^7.8.1",
|
|
72
|
-
"@equinor/fusion-framework": "^7.2.
|
|
73
|
-
"@equinor/fusion-framework-
|
|
74
|
-
"@equinor/fusion-framework-module": "^
|
|
75
|
-
"@equinor/fusion-observable": "^8.3.
|
|
76
|
-
"@equinor/fusion-framework-react-module-http": "^6.0.
|
|
72
|
+
"@equinor/fusion-framework": "^7.2.2",
|
|
73
|
+
"@equinor/fusion-framework-module": "^4.3.2",
|
|
74
|
+
"@equinor/fusion-framework-react-module": "^3.1.3",
|
|
75
|
+
"@equinor/fusion-observable": "^8.3.3",
|
|
76
|
+
"@equinor/fusion-framework-react-module-http": "^6.0.1"
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
79
|
"@types/react": "^18.2.50",
|
|
80
80
|
"@types/react-dom": "^18.2.7",
|
|
81
81
|
"react": "^18.2.0",
|
|
82
82
|
"react-dom": "^18.2.0",
|
|
83
|
-
"typescript": "^5.
|
|
84
|
-
"@equinor/fusion-framework-module-
|
|
85
|
-
"@equinor/fusion-framework-module-
|
|
86
|
-
"@equinor/fusion-framework-
|
|
87
|
-
"@equinor/fusion-framework-module-
|
|
83
|
+
"typescript": "^5.5.3",
|
|
84
|
+
"@equinor/fusion-framework-module-app": "^5.3.8",
|
|
85
|
+
"@equinor/fusion-framework-module-feature-flag": "^1.1.5",
|
|
86
|
+
"@equinor/fusion-framework-module-event": "^4.2.0",
|
|
87
|
+
"@equinor/fusion-framework-react-module-context": "^6.2.9"
|
|
88
88
|
},
|
|
89
89
|
"peerDependencies": {
|
|
90
90
|
"@types/react": "^17.0.0 || ^18.0.0",
|
|
91
91
|
"react": "^17.0.0 || ^18.0.0",
|
|
92
92
|
"react-dom": "^17.0.0 || ^18.0.0",
|
|
93
|
-
"@equinor/fusion-framework-module-feature-flag": "^1.1.
|
|
94
|
-
"@equinor/fusion-framework-react-module-signalr": "^3.0.
|
|
93
|
+
"@equinor/fusion-framework-module-feature-flag": "^1.1.5",
|
|
94
|
+
"@equinor/fusion-framework-react-module-signalr": "^3.0.11"
|
|
95
95
|
},
|
|
96
96
|
"peerDependenciesMeta": {
|
|
97
97
|
"@equinor/fusion-framework-module-event": {
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by genversion.
|
|
2
|
-
export const version = '7.1.
|
|
2
|
+
export const version = '7.1.2';
|