@equinor/fusion-framework-react 2.0.17 → 2.0.18
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 +6 -0
- package/dist/esm/app/index.js +0 -5
- package/dist/esm/app/index.js.map +1 -1
- package/dist/esm/app/useCurrentApp.js +3 -0
- package/dist/esm/app/useCurrentApp.js.map +1 -1
- package/dist/esm/hooks/index.js +0 -1
- package/dist/esm/hooks/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/app/index.d.ts +1 -6
- package/dist/types/hooks/index.d.ts +0 -1
- package/package.json +5 -4
- package/src/app/index.ts +1 -6
- package/src/app/useCurrentApp.ts +6 -2
- package/src/hooks/index.ts +0 -1
- package/tsconfig.json +3 -0
- package/dist/esm/app/useAppConfig.js +0 -30
- package/dist/esm/app/useAppConfig.js.map +0 -1
- package/dist/esm/app/useAppEnv.js +0 -9
- package/dist/esm/app/useAppEnv.js.map +0 -1
- package/dist/esm/app/useAppManifest.js +0 -23
- package/dist/esm/app/useAppManifest.js.map +0 -1
- package/dist/esm/app/useAppManifests.js +0 -23
- package/dist/esm/app/useAppManifests.js.map +0 -1
- package/dist/esm/app/useCurrentAppChanged.js +0 -8
- package/dist/esm/app/useCurrentAppChanged.js.map +0 -1
- package/dist/esm/hooks/use-framework.js +0 -6
- package/dist/esm/hooks/use-framework.js.map +0 -1
- package/dist/types/app/useAppConfig.d.ts +0 -10
- package/dist/types/app/useAppEnv.d.ts +0 -6
- package/dist/types/app/useAppManifest.d.ts +0 -7
- package/dist/types/app/useAppManifests.d.ts +0 -7
- package/dist/types/app/useCurrentAppChanged.d.ts +0 -3
- package/dist/types/hooks/use-framework.d.ts +0 -3
- package/src/app/useAppConfig.ts +0 -43
- package/src/app/useAppEnv.ts +0 -11
- package/src/app/useAppManifest.ts +0 -26
- package/src/app/useAppManifests.ts +0 -26
- package/src/app/useCurrentAppChanged.ts +0 -12
- package/src/hooks/use-framework.ts +0 -18
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
export type { AppConfig, AppManifest, AppType } from '@equinor/fusion-framework-module-app';
|
|
2
|
-
export { useAppManifest } from './useAppManifest';
|
|
3
|
-
export { useAppManifests } from './useAppManifests';
|
|
1
|
+
export type { AppConfig, AppManifest, AppType, App } from '@equinor/fusion-framework-module-app';
|
|
4
2
|
export { useCurrentApp } from './useCurrentApp';
|
|
5
|
-
export { useCurrentAppChanged } from './useCurrentAppChanged';
|
|
6
|
-
export { useAppConfig } from './useAppConfig';
|
|
7
|
-
export { useAppEnv } from './useAppEnv';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@equinor/fusion-framework-react",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.18",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/esm/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -43,12 +43,13 @@
|
|
|
43
43
|
"directory": "packages/react"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@equinor/fusion-framework": "^5.0.
|
|
47
|
-
"@equinor/fusion-framework-react-module-context": "^1.0.
|
|
46
|
+
"@equinor/fusion-framework": "^5.0.17",
|
|
47
|
+
"@equinor/fusion-framework-react-module-context": "^1.0.15",
|
|
48
48
|
"@equinor/fusion-framework-react-module-http": "^1.1.7",
|
|
49
49
|
"rxjs": "^7.5.7"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
+
"@equinor/fusion-framework-module-app": "^2.5.0",
|
|
52
53
|
"@types/react": "^17.0.11",
|
|
53
54
|
"@types/react-dom": "^17.0.7",
|
|
54
55
|
"react": "^17.0.2",
|
|
@@ -68,5 +69,5 @@
|
|
|
68
69
|
"optional": true
|
|
69
70
|
}
|
|
70
71
|
},
|
|
71
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "e5668331df89b0ef6ef6175ea1908d4aeb772544"
|
|
72
73
|
}
|
package/src/app/index.ts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
export type { AppConfig, AppManifest, AppType } from '@equinor/fusion-framework-module-app';
|
|
1
|
+
export type { AppConfig, AppManifest, AppType, App } from '@equinor/fusion-framework-module-app';
|
|
2
2
|
|
|
3
|
-
export { useAppManifest } from './useAppManifest';
|
|
4
|
-
export { useAppManifests } from './useAppManifests';
|
|
5
3
|
export { useCurrentApp } from './useCurrentApp';
|
|
6
|
-
export { useCurrentAppChanged } from './useCurrentAppChanged';
|
|
7
|
-
export { useAppConfig } from './useAppConfig';
|
|
8
|
-
export { useAppEnv } from './useAppEnv';
|
package/src/app/useCurrentApp.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { App } from '@equinor/fusion-framework-module-app';
|
|
1
|
+
import { App, AppModule } from '@equinor/fusion-framework-module-app';
|
|
2
2
|
import { useObservableState } from '@equinor/fusion-observable/react';
|
|
3
3
|
import { useCallback } from 'react';
|
|
4
4
|
|
|
@@ -8,12 +8,16 @@ export const useCurrentApp = (): {
|
|
|
8
8
|
currentApp: App | undefined;
|
|
9
9
|
setCurrentApp: (appKey: string) => void;
|
|
10
10
|
} => {
|
|
11
|
-
const provider = useFramework().modules.app;
|
|
11
|
+
const provider = useFramework<[AppModule]>().modules.app;
|
|
12
|
+
if (!provider) {
|
|
13
|
+
throw Error('Current framework does not have AppModule configured');
|
|
14
|
+
}
|
|
12
15
|
const currentApp = useObservableState(provider.current$);
|
|
13
16
|
const setCurrentApp = useCallback(
|
|
14
17
|
(appKey: string) => provider.setCurrentApp(appKey),
|
|
15
18
|
[provider]
|
|
16
19
|
);
|
|
20
|
+
|
|
17
21
|
return {
|
|
18
22
|
currentApp,
|
|
19
23
|
setCurrentApp,
|
package/src/hooks/index.ts
CHANGED
package/tsconfig.json
CHANGED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react';
|
|
2
|
-
import { useFramework } from '../useFramework';
|
|
3
|
-
export const useAppConfig = (args) => {
|
|
4
|
-
const { appKey } = args;
|
|
5
|
-
const provider = useFramework().modules.app;
|
|
6
|
-
const [value, setValue] = useState();
|
|
7
|
-
const [error, setError] = useState();
|
|
8
|
-
const [isLoading, setIsLoading] = useState(false);
|
|
9
|
-
useEffect(() => {
|
|
10
|
-
setValue(undefined);
|
|
11
|
-
}, [setValue, appKey]);
|
|
12
|
-
useEffect(() => {
|
|
13
|
-
if (!appKey) {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
setIsLoading(true);
|
|
17
|
-
const request = provider.getAppConfig(appKey).subscribe({
|
|
18
|
-
next: (value) => setValue(value),
|
|
19
|
-
error: (err) => setError(err),
|
|
20
|
-
complete: () => setIsLoading(false),
|
|
21
|
-
});
|
|
22
|
-
return () => {
|
|
23
|
-
setIsLoading(false);
|
|
24
|
-
request.unsubscribe();
|
|
25
|
-
};
|
|
26
|
-
}, [provider, setValue, setError, setIsLoading, appKey]);
|
|
27
|
-
return { value, error, isLoading };
|
|
28
|
-
};
|
|
29
|
-
export default useAppConfig;
|
|
30
|
-
//# sourceMappingURL=useAppConfig.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useAppConfig.js","sourceRoot":"","sources":["../../../src/app/useAppConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAG5C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAQ/C,MAAM,CAAC,MAAM,YAAY,GAAG,CAAQ,IAEnC,EAA4B,EAAE;IAC3B,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IACxB,MAAM,QAAQ,GAAG,YAAY,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC;IAC5C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,EAAgC,CAAC;IACnE,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,EAAqB,CAAC;IACxD,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAU,KAAK,CAAC,CAAC;IAE3D,SAAS,CAAC,GAAG,EAAE;QACX,QAAQ,CAAC,SAAS,CAAC,CAAC;IACxB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;IAEvB,SAAS,CAAC,GAAG,EAAE;QACX,IAAI,CAAC,MAAM,EAAE;YACT,OAAO;SACV;QACD,YAAY,CAAC,IAAI,CAAC,CAAC;QACnB,MAAM,OAAO,GAAG,QAAQ,CAAC,YAAY,CAAQ,MAAM,CAAC,CAAC,SAAS,CAAC;YAC3D,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC;YAChC,KAAK,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC;YAC7B,QAAQ,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC;SACtC,CAAC,CAAC;QACH,OAAO,GAAG,EAAE;YACR,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,OAAO,CAAC,WAAW,EAAE,CAAC;QAC1B,CAAC,CAAC;IACN,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,CAAC,CAAC,CAAC;IACzD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;AACvC,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { useAppManifest } from './useAppManifest';
|
|
2
|
-
import { useAppConfig } from './useAppConfig';
|
|
3
|
-
export const useAppEnv = (appKey) => {
|
|
4
|
-
const { value: manifest, isLoading: manifestLoading } = useAppManifest(appKey);
|
|
5
|
-
const { value: config, isLoading: configLoading } = useAppConfig({ appKey });
|
|
6
|
-
return { manifest, config, isLoading: manifestLoading || configLoading };
|
|
7
|
-
};
|
|
8
|
-
export default useAppEnv;
|
|
9
|
-
//# sourceMappingURL=useAppEnv.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useAppEnv.js","sourceRoot":"","sources":["../../../src/app/useAppEnv.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,MAAc,EAAE,EAAE;IACxC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,eAAe,EAAE,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;IAC/E,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,GAAG,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;IAE7E,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,eAAe,IAAI,aAAa,EAAE,CAAC;AAC7E,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react';
|
|
2
|
-
import { useFramework } from '../useFramework';
|
|
3
|
-
export const useAppManifest = (appKey) => {
|
|
4
|
-
const provider = useFramework().modules.app;
|
|
5
|
-
const [value, setValue] = useState(undefined);
|
|
6
|
-
const [error, setError] = useState();
|
|
7
|
-
const [isLoading, setIsLoading] = useState(false);
|
|
8
|
-
useEffect(() => {
|
|
9
|
-
setIsLoading(true);
|
|
10
|
-
const request = provider.getAppManifest(appKey).subscribe({
|
|
11
|
-
next: (value) => setValue(value),
|
|
12
|
-
error: (err) => setError(err),
|
|
13
|
-
complete: () => setIsLoading(false),
|
|
14
|
-
});
|
|
15
|
-
return () => {
|
|
16
|
-
setIsLoading(false);
|
|
17
|
-
request.unsubscribe();
|
|
18
|
-
};
|
|
19
|
-
}, [provider, setValue, setError, setIsLoading, appKey]);
|
|
20
|
-
return { value, error, isLoading };
|
|
21
|
-
};
|
|
22
|
-
export default useAppManifest;
|
|
23
|
-
//# sourceMappingURL=useAppManifest.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useAppManifest.js","sourceRoot":"","sources":["../../../src/app/useAppManifest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,MAAc,EAAE,EAAE;IAC7C,MAAM,QAAQ,GAAG,YAAY,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC;IAC5C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAA0B,SAAS,CAAC,CAAC;IACvE,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,EAAqB,CAAC;IACxD,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAU,KAAK,CAAC,CAAC;IAE3D,SAAS,CAAC,GAAG,EAAE;QACX,YAAY,CAAC,IAAI,CAAC,CAAC;QACnB,MAAM,OAAO,GAAG,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC;YACtD,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC;YAChC,KAAK,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC;YAC7B,QAAQ,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC;SACtC,CAAC,CAAC;QACH,OAAO,GAAG,EAAE;YACR,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,OAAO,CAAC,WAAW,EAAE,CAAC;QAC1B,CAAC,CAAC;IACN,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,CAAC,CAAC,CAAC;IACzD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;AACvC,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react';
|
|
2
|
-
import { useFramework } from '../useFramework';
|
|
3
|
-
export const useAppManifests = () => {
|
|
4
|
-
const provider = useFramework().modules.app;
|
|
5
|
-
const [value, setValue] = useState(undefined);
|
|
6
|
-
const [error, setError] = useState();
|
|
7
|
-
const [isLoading, setIsLoading] = useState(false);
|
|
8
|
-
useEffect(() => {
|
|
9
|
-
setIsLoading(true);
|
|
10
|
-
const request = provider.getAllAppManifests().subscribe({
|
|
11
|
-
next: (value) => setValue(value),
|
|
12
|
-
error: (err) => setError(err),
|
|
13
|
-
complete: () => setIsLoading(false),
|
|
14
|
-
});
|
|
15
|
-
return () => {
|
|
16
|
-
setIsLoading(false);
|
|
17
|
-
request.unsubscribe();
|
|
18
|
-
};
|
|
19
|
-
}, [provider, setValue, setError, setIsLoading]);
|
|
20
|
-
return { value, error, isLoading };
|
|
21
|
-
};
|
|
22
|
-
export default useAppManifests;
|
|
23
|
-
//# sourceMappingURL=useAppManifests.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useAppManifests.js","sourceRoot":"","sources":["../../../src/app/useAppManifests.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,EAAE;IAChC,MAAM,QAAQ,GAAG,YAAY,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC;IAC5C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAA4B,SAAS,CAAC,CAAC;IACzE,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,EAAqB,CAAC;IACxD,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAU,KAAK,CAAC,CAAC;IAE3D,SAAS,CAAC,GAAG,EAAE;QACX,YAAY,CAAC,IAAI,CAAC,CAAC;QACnB,MAAM,OAAO,GAAG,QAAQ,CAAC,kBAAkB,EAAE,CAAC,SAAS,CAAC;YACpD,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC;YAChC,KAAK,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC;YAC7B,QAAQ,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC;SACtC,CAAC,CAAC;QACH,OAAO,GAAG,EAAE;YACR,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,OAAO,CAAC,WAAW,EAAE,CAAC;QAC1B,CAAC,CAAC;IACN,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC;IACjD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;AACvC,CAAC,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { useEffect } from 'react';
|
|
2
|
-
import { useFramework } from '../useFramework';
|
|
3
|
-
export const useCurrentAppChanged = (cb) => {
|
|
4
|
-
const { event } = useFramework().modules;
|
|
5
|
-
useEffect(() => event.addEventListener('onCurrentAppChanged', cb), [event, cb]);
|
|
6
|
-
};
|
|
7
|
-
export default useCurrentAppChanged;
|
|
8
|
-
//# sourceMappingURL=useCurrentAppChanged.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useCurrentAppChanged.js","sourceRoot":"","sources":["../../../src/app/useCurrentAppChanged.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAChC,EAAyE,EAC3E,EAAE;IACA,MAAM,EAAE,KAAK,EAAE,GAAG,YAAY,EAAE,CAAC,OAAO,CAAC;IACzC,SAAS,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,gBAAgB,CAAC,qBAAqB,EAAE,EAAE,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC;AACpF,CAAC,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-framework.js","sourceRoot":"","sources":["../../../src/hooks/use-framework.ts"],"names":[],"mappings":"AAGA,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAW5C,MAAM,CAAC,MAAM,YAAY,GAAG,GAA6D,EAAE;IACvF,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,wDAAwD,CAAC,CAAC;IACtF,OAAO,aAAa,EAAE,CAAC;AAC3B,CAAC,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { AppConfig } from '@equinor/fusion-framework-module-app';
|
|
2
|
-
type UseAppConfigState<TType> = {
|
|
3
|
-
value?: AppConfig<TType>;
|
|
4
|
-
error?: Error;
|
|
5
|
-
isLoading: boolean;
|
|
6
|
-
};
|
|
7
|
-
export declare const useAppConfig: <TType>(args: {
|
|
8
|
-
appKey: string | undefined;
|
|
9
|
-
}) => UseAppConfigState<TType>;
|
|
10
|
-
export default useAppConfig;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export declare const useAppEnv: (appKey: string) => {
|
|
2
|
-
manifest: import("@equinor/fusion-framework-module-app").AppManifest | undefined;
|
|
3
|
-
config: import("@equinor/fusion-framework-module-app").AppConfig<unknown> | undefined;
|
|
4
|
-
isLoading: boolean;
|
|
5
|
-
};
|
|
6
|
-
export default useAppEnv;
|
package/src/app/useAppConfig.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react';
|
|
2
|
-
import { AppConfig } from '@equinor/fusion-framework-module-app';
|
|
3
|
-
|
|
4
|
-
import { useFramework } from '../useFramework';
|
|
5
|
-
|
|
6
|
-
type UseAppConfigState<TType> = {
|
|
7
|
-
value?: AppConfig<TType>;
|
|
8
|
-
error?: Error;
|
|
9
|
-
isLoading: boolean;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export const useAppConfig = <TType>(args: {
|
|
13
|
-
appKey: string | undefined;
|
|
14
|
-
}): UseAppConfigState<TType> => {
|
|
15
|
-
const { appKey } = args;
|
|
16
|
-
const provider = useFramework().modules.app;
|
|
17
|
-
const [value, setValue] = useState<AppConfig<TType> | undefined>();
|
|
18
|
-
const [error, setError] = useState<Error | undefined>();
|
|
19
|
-
const [isLoading, setIsLoading] = useState<boolean>(false);
|
|
20
|
-
|
|
21
|
-
useEffect(() => {
|
|
22
|
-
setValue(undefined);
|
|
23
|
-
}, [setValue, appKey]);
|
|
24
|
-
|
|
25
|
-
useEffect(() => {
|
|
26
|
-
if (!appKey) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
setIsLoading(true);
|
|
30
|
-
const request = provider.getAppConfig<TType>(appKey).subscribe({
|
|
31
|
-
next: (value) => setValue(value),
|
|
32
|
-
error: (err) => setError(err),
|
|
33
|
-
complete: () => setIsLoading(false),
|
|
34
|
-
});
|
|
35
|
-
return () => {
|
|
36
|
-
setIsLoading(false);
|
|
37
|
-
request.unsubscribe();
|
|
38
|
-
};
|
|
39
|
-
}, [provider, setValue, setError, setIsLoading, appKey]);
|
|
40
|
-
return { value, error, isLoading };
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export default useAppConfig;
|
package/src/app/useAppEnv.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { useAppManifest } from './useAppManifest';
|
|
2
|
-
import { useAppConfig } from './useAppConfig';
|
|
3
|
-
|
|
4
|
-
export const useAppEnv = (appKey: string) => {
|
|
5
|
-
const { value: manifest, isLoading: manifestLoading } = useAppManifest(appKey);
|
|
6
|
-
const { value: config, isLoading: configLoading } = useAppConfig({ appKey });
|
|
7
|
-
|
|
8
|
-
return { manifest, config, isLoading: manifestLoading || configLoading };
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export default useAppEnv;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react';
|
|
2
|
-
import { AppManifest } from '@equinor/fusion-framework-module-app';
|
|
3
|
-
import { useFramework } from '../useFramework';
|
|
4
|
-
|
|
5
|
-
export const useAppManifest = (appKey: string) => {
|
|
6
|
-
const provider = useFramework().modules.app;
|
|
7
|
-
const [value, setValue] = useState<AppManifest | undefined>(undefined);
|
|
8
|
-
const [error, setError] = useState<Error | undefined>();
|
|
9
|
-
const [isLoading, setIsLoading] = useState<boolean>(false);
|
|
10
|
-
|
|
11
|
-
useEffect(() => {
|
|
12
|
-
setIsLoading(true);
|
|
13
|
-
const request = provider.getAppManifest(appKey).subscribe({
|
|
14
|
-
next: (value) => setValue(value),
|
|
15
|
-
error: (err) => setError(err),
|
|
16
|
-
complete: () => setIsLoading(false),
|
|
17
|
-
});
|
|
18
|
-
return () => {
|
|
19
|
-
setIsLoading(false);
|
|
20
|
-
request.unsubscribe();
|
|
21
|
-
};
|
|
22
|
-
}, [provider, setValue, setError, setIsLoading, appKey]);
|
|
23
|
-
return { value, error, isLoading };
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export default useAppManifest;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { AppManifest } from '@equinor/fusion-framework-module-app';
|
|
2
|
-
import { useEffect, useState } from 'react';
|
|
3
|
-
import { useFramework } from '../useFramework';
|
|
4
|
-
|
|
5
|
-
export const useAppManifests = () => {
|
|
6
|
-
const provider = useFramework().modules.app;
|
|
7
|
-
const [value, setValue] = useState<AppManifest[] | undefined>(undefined);
|
|
8
|
-
const [error, setError] = useState<Error | undefined>();
|
|
9
|
-
const [isLoading, setIsLoading] = useState<boolean>(false);
|
|
10
|
-
|
|
11
|
-
useEffect(() => {
|
|
12
|
-
setIsLoading(true);
|
|
13
|
-
const request = provider.getAllAppManifests().subscribe({
|
|
14
|
-
next: (value) => setValue(value),
|
|
15
|
-
error: (err) => setError(err),
|
|
16
|
-
complete: () => setIsLoading(false),
|
|
17
|
-
});
|
|
18
|
-
return () => {
|
|
19
|
-
setIsLoading(false);
|
|
20
|
-
request.unsubscribe();
|
|
21
|
-
};
|
|
22
|
-
}, [provider, setValue, setError, setIsLoading]);
|
|
23
|
-
return { value, error, isLoading };
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export default useAppManifests;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { FrameworkEventMap } from '@equinor/fusion-framework-module-event';
|
|
2
|
-
import { useEffect } from 'react';
|
|
3
|
-
import { useFramework } from '../useFramework';
|
|
4
|
-
|
|
5
|
-
export const useCurrentAppChanged = (
|
|
6
|
-
cb: (e: FrameworkEventMap['onCurrentAppChanged']) => Promise<void> | void
|
|
7
|
-
) => {
|
|
8
|
-
const { event } = useFramework().modules;
|
|
9
|
-
useEffect(() => event.addEventListener('onCurrentAppChanged', cb), [event, cb]);
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export default useCurrentAppChanged;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { Fusion } from '@equinor/fusion-framework';
|
|
2
|
-
import type { AnyModule } from '@equinor/fusion-framework-module';
|
|
3
|
-
|
|
4
|
-
import _useFramework from '../useFramework';
|
|
5
|
-
|
|
6
|
-
// TODO - remove next major!
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @deprecated
|
|
10
|
-
*
|
|
11
|
-
* ```ts
|
|
12
|
-
* import { useFramework } from '@equinor/fusion-framework';
|
|
13
|
-
* ```
|
|
14
|
-
*/
|
|
15
|
-
export const useFramework = <TModules extends Array<AnyModule> = []>(): Fusion<TModules> => {
|
|
16
|
-
console.warn('@deprecated', 'import { useFramework } from @equinor/fusion-framework');
|
|
17
|
-
return _useFramework();
|
|
18
|
-
};
|