@equinor/fusion-framework-react-app 9.0.0-next.0 → 9.0.1
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 +55 -29
- package/dist/esm/analytics/index.js +2 -0
- package/dist/esm/analytics/index.js.map +1 -0
- package/dist/esm/analytics/useTrackFeature.js +48 -0
- package/dist/esm/analytics/useTrackFeature.js.map +1 -0
- package/dist/esm/apploader/Apploader.js +1 -1
- package/dist/esm/apploader/Apploader.js.map +1 -1
- package/dist/esm/index.js +2 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/make-component.js +1 -1
- package/dist/esm/make-component.js.map +1 -1
- package/dist/esm/render-app.js +1 -7
- package/dist/esm/render-app.js.map +1 -1
- package/dist/esm/render-component.js +23 -22
- package/dist/esm/render-component.js.map +1 -1
- package/dist/esm/useAppModules.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/analytics/index.d.ts +1 -0
- package/dist/types/analytics/useTrackFeature.d.ts +5 -0
- package/dist/types/apploader/Apploader.d.ts +2 -3
- package/dist/types/index.d.ts +1 -3
- package/dist/types/render-app.d.ts +1 -7
- package/dist/types/render-component.d.ts +1 -7
- package/dist/types/version.d.ts +1 -1
- package/package.json +32 -34
- package/src/analytics/README.md +41 -0
- package/src/analytics/index.ts +1 -0
- package/src/analytics/useTrackFeature.ts +56 -0
- package/src/apploader/Apploader.tsx +3 -3
- package/src/index.ts +2 -4
- package/src/make-component.tsx +1 -1
- package/src/render-app.ts +1 -7
- package/src/render-component.tsx +27 -24
- package/src/useAppModules.ts +2 -2
- package/src/version.ts +1 -1
- package/tsconfig.json +4 -1
- package/dist/esm/http/selectors.js +0 -2
- package/dist/esm/http/selectors.js.map +0 -1
- package/dist/types/http/selectors.d.ts +0 -1
- package/src/__tests__/render-app.test.tsx +0 -113
- package/src/http/selectors.ts +0 -1
- package/vitest.config.ts +0 -20
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useTrackFeature } from './useTrackFeature';
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { type ReactElement } from 'react';
|
|
2
1
|
export type ApploaderProps = {
|
|
3
2
|
appKey: string;
|
|
4
3
|
};
|
|
@@ -10,10 +9,10 @@ export type ApploaderProps = {
|
|
|
10
9
|
*
|
|
11
10
|
* @param { ApploaderProps } props - The props for the component.
|
|
12
11
|
* @param { string } props.appKey - The key of the Fusion app to load and mount.
|
|
13
|
-
* @returns {
|
|
12
|
+
* @returns { JSX.Element } The rendered component, which displays loading, error, or the embedded app.
|
|
14
13
|
*
|
|
15
14
|
* @example
|
|
16
15
|
* <Apploader appKey="my-app" />
|
|
17
16
|
*/
|
|
18
|
-
export declare const Apploader: ({ appKey }: ApploaderProps) =>
|
|
17
|
+
export declare const Apploader: ({ appKey }: ApploaderProps) => JSX.Element;
|
|
19
18
|
export default Apploader;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
export type { AppConfig, AppEnv, AppModuleInitiator, AppModules, AppModulesInstance, AppRenderFn, IAppConfigurator, } from '@equinor/fusion-framework-app';
|
|
2
|
-
export type { Fusion } from '@equinor/fusion-framework-react';
|
|
3
2
|
export { AppManifest } from '@equinor/fusion-framework-module-app';
|
|
4
3
|
export { useAppModule } from './useAppModule';
|
|
5
4
|
export { useAppModules } from './useAppModules';
|
|
6
5
|
export { useAppEnvironmentVariables } from './useAppEnvironmentVariables';
|
|
7
6
|
export { makeComponent, ComponentRenderArgs } from './make-component';
|
|
8
7
|
export { createLegacyApp } from './create-legacy-app';
|
|
9
|
-
export { createComponent } from './create-component';
|
|
10
8
|
export { renderApp } from './render-app';
|
|
9
|
+
export { createComponent } from './create-component';
|
|
11
10
|
export { renderComponent } from './render-component';
|
|
12
11
|
export type { ComponentRenderer } from './create-component';
|
|
13
|
-
export type { RenderTeardown } from './render-component';
|
|
14
12
|
export { default } from './render-app';
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import { createComponent } from './create-component';
|
|
2
2
|
import { type RenderTeardown } from './render-component';
|
|
3
3
|
import type { ComponentRenderArgs } from './create-component';
|
|
4
|
-
/**
|
|
5
|
-
* Creates a render function for an app component.
|
|
6
|
-
* Uses React 18's createRoot API via renderComponent.
|
|
7
|
-
*
|
|
8
|
-
* @param componentArgs - Arguments to pass to createComponent
|
|
9
|
-
* @returns A function that renders the app into a DOM element
|
|
10
|
-
*/
|
|
4
|
+
/** @deprecated */
|
|
11
5
|
export declare const renderApp: (...componentArgs: Parameters<typeof createComponent>) => (el: HTMLElement, args: ComponentRenderArgs) => RenderTeardown;
|
|
12
6
|
export default renderApp;
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import type { ComponentRenderArgs, ComponentRenderer } from './create-component';
|
|
2
2
|
export type RenderTeardown = VoidFunction;
|
|
3
|
-
/**
|
|
4
|
-
* Creates a render function for a component renderer.
|
|
5
|
-
* Uses React 18's createRoot API instead of the deprecated ReactDOM.render.
|
|
6
|
-
*
|
|
7
|
-
* @param renderer - A function that creates a component from fusion and env
|
|
8
|
-
* @returns A function that renders the component into a DOM element
|
|
9
|
-
*/
|
|
3
|
+
/** @deprecated */
|
|
10
4
|
export declare const renderComponent: (renderer: ComponentRenderer) => (el: HTMLElement, args: ComponentRenderArgs) => RenderTeardown;
|
|
11
5
|
export default renderComponent;
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "9.0.
|
|
1
|
+
export declare const version = "9.0.1";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@equinor/fusion-framework-react-app",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/esm/index.js",
|
|
6
6
|
"types": "./dist/types/index.d.ts",
|
|
@@ -9,6 +9,10 @@
|
|
|
9
9
|
"types": "./dist/types/index.d.ts",
|
|
10
10
|
"import": "./dist/esm/index.js"
|
|
11
11
|
},
|
|
12
|
+
"./analytics": {
|
|
13
|
+
"types": "./dist/types/analytics/index.d.ts",
|
|
14
|
+
"import": "./dist/esm/analytics/index.js"
|
|
15
|
+
},
|
|
12
16
|
"./apploader": {
|
|
13
17
|
"types": "./dist/types/apploader/index.d.ts",
|
|
14
18
|
"import": "./dist/esm/apploader/index.js"
|
|
@@ -37,10 +41,6 @@
|
|
|
37
41
|
"types": "./dist/types/http/index.d.ts",
|
|
38
42
|
"import": "./dist/esm/http/index.js"
|
|
39
43
|
},
|
|
40
|
-
"./http/selectors": {
|
|
41
|
-
"types": "./dist/types/http/selectors.d.ts",
|
|
42
|
-
"import": "./dist/esm/http/selectors.js"
|
|
43
|
-
},
|
|
44
44
|
"./msal": {
|
|
45
45
|
"types": "./dist/types/msal/index.d.ts",
|
|
46
46
|
"import": "./dist/esm/msal/index.js"
|
|
@@ -63,6 +63,9 @@
|
|
|
63
63
|
".": [
|
|
64
64
|
"dist/types/index.d.ts"
|
|
65
65
|
],
|
|
66
|
+
"analytics": [
|
|
67
|
+
"dist/types/analytics/index.d.ts"
|
|
68
|
+
],
|
|
66
69
|
"apploader": [
|
|
67
70
|
"dist/types/apploader/index.d.ts"
|
|
68
71
|
],
|
|
@@ -110,40 +113,36 @@
|
|
|
110
113
|
"directory": "packages/react"
|
|
111
114
|
},
|
|
112
115
|
"dependencies": {
|
|
113
|
-
"@equinor/fusion-framework-app": "
|
|
114
|
-
"@equinor/fusion-framework-module": "
|
|
115
|
-
"@equinor/fusion-framework-module-
|
|
116
|
-
"@equinor/fusion-framework-
|
|
117
|
-
"@equinor/fusion-framework-
|
|
118
|
-
"@equinor/fusion-framework-module
|
|
119
|
-
"@equinor/fusion-framework-react-module": "
|
|
120
|
-
"@equinor/fusion-framework-react-module-http": "^11.0.0-next.0"
|
|
116
|
+
"@equinor/fusion-framework-app": "10.4.2",
|
|
117
|
+
"@equinor/fusion-framework-module": "5.0.5",
|
|
118
|
+
"@equinor/fusion-framework-module-navigation": "6.0.0",
|
|
119
|
+
"@equinor/fusion-framework-react": "7.4.19",
|
|
120
|
+
"@equinor/fusion-framework-module-app": "7.4.0",
|
|
121
|
+
"@equinor/fusion-framework-react-module": "3.1.13",
|
|
122
|
+
"@equinor/fusion-framework-react-module-http": "10.0.0"
|
|
121
123
|
},
|
|
122
124
|
"devDependencies": {
|
|
123
|
-
"@
|
|
124
|
-
"@types/react": "^
|
|
125
|
-
"
|
|
126
|
-
"
|
|
127
|
-
"react": "^19.2.1",
|
|
128
|
-
"react-dom": "^19.2.1",
|
|
125
|
+
"@types/react": "^18.2.50",
|
|
126
|
+
"@types/react-dom": "^18.2.7",
|
|
127
|
+
"react": "^18.2.0",
|
|
128
|
+
"react-dom": "^18.2.0",
|
|
129
129
|
"rxjs": "^7.8.1",
|
|
130
130
|
"typescript": "^5.8.2",
|
|
131
|
-
"
|
|
132
|
-
"
|
|
133
|
-
"@equinor/fusion-framework-module-event": "
|
|
134
|
-
"@equinor/fusion-framework-module-feature-flag": "
|
|
135
|
-
"@equinor/fusion-framework-module-msal": "
|
|
136
|
-
"@equinor/fusion-framework-module-
|
|
137
|
-
"@equinor/fusion-framework-react-module-
|
|
138
|
-
"@equinor/fusion-observable": "
|
|
139
|
-
"@equinor/fusion-framework-react-module-context": "^7.0.0-next.0"
|
|
131
|
+
"@equinor/fusion-framework-module-ag-grid": "34.4.0",
|
|
132
|
+
"@equinor/fusion-framework-module-analytics": "0.2.3",
|
|
133
|
+
"@equinor/fusion-framework-module-event": "5.0.0",
|
|
134
|
+
"@equinor/fusion-framework-module-feature-flag": "1.1.27",
|
|
135
|
+
"@equinor/fusion-framework-module-msal": "7.0.0",
|
|
136
|
+
"@equinor/fusion-framework-react-module-bookmark": "5.0.1",
|
|
137
|
+
"@equinor/fusion-framework-react-module-context": "6.2.33",
|
|
138
|
+
"@equinor/fusion-observable": "8.5.7"
|
|
140
139
|
},
|
|
141
140
|
"peerDependencies": {
|
|
142
|
-
"@types/react": "^
|
|
143
|
-
"react": "^
|
|
144
|
-
"react-dom": "^
|
|
141
|
+
"@types/react": "^17.0.0 || ^18.0.0",
|
|
142
|
+
"react": "^17.0.0 || ^18.0.0",
|
|
143
|
+
"react-dom": "^17.0.0 || ^18.0.0",
|
|
145
144
|
"rxjs": "^7.8.1",
|
|
146
|
-
"@equinor/fusion-framework-module-msal": "^7.0.0
|
|
145
|
+
"@equinor/fusion-framework-module-msal": "^7.0.0"
|
|
147
146
|
},
|
|
148
147
|
"peerDependenciesMeta": {
|
|
149
148
|
"@equinor/fusion-framework-react-module-ag-grid": {
|
|
@@ -175,7 +174,6 @@
|
|
|
175
174
|
}
|
|
176
175
|
},
|
|
177
176
|
"scripts": {
|
|
178
|
-
"build": "tsc -b"
|
|
179
|
-
"test": "vitest --run"
|
|
177
|
+
"build": "tsc -b"
|
|
180
178
|
}
|
|
181
179
|
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
## Analytics
|
|
2
|
+
|
|
3
|
+
The Fusion Framework Analytics Module provides an unified way to track analytics.
|
|
4
|
+
|
|
5
|
+
This is a hook to manually send features to track.
|
|
6
|
+
|
|
7
|
+
This hook can be used by app teams wanting to track a specific feature they use.
|
|
8
|
+
|
|
9
|
+
### useTrackFeature
|
|
10
|
+
|
|
11
|
+
A hook to send feature used.
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
const trackFeature = useTrackFeature();
|
|
15
|
+
|
|
16
|
+
trackFeature('foo');
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
const SomeComponent = () => {
|
|
21
|
+
const trackFeature = useTrackFeature();
|
|
22
|
+
|
|
23
|
+
// Tracks when button is clicked.
|
|
24
|
+
const handleOnClick = useCallback(() => {
|
|
25
|
+
trackFeature('button-clicked');
|
|
26
|
+
}, [trackFeature]);
|
|
27
|
+
|
|
28
|
+
// Triggers when the component is loaded.
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
trackFeature('SomeComponent loaded');
|
|
31
|
+
|
|
32
|
+
// Send additional data
|
|
33
|
+
trackFeature('some feature happened', {
|
|
34
|
+
extra: 'data',
|
|
35
|
+
foo: 'bar',
|
|
36
|
+
});
|
|
37
|
+
}, [trackFeature]);
|
|
38
|
+
|
|
39
|
+
return <button onClick={handleOnClick}>Click me</button>;
|
|
40
|
+
};
|
|
41
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useTrackFeature } from './useTrackFeature';
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { useFrameworkModule } from '@equinor/fusion-framework-react';
|
|
2
|
+
import type { AppModule } from '@equinor/fusion-framework-module-app';
|
|
3
|
+
import type { AnalyticsModule, AnyValueMap } from '@equinor/fusion-framework-module-analytics';
|
|
4
|
+
import { useCallback } from 'react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Hook for using analytics module configured in the framework.
|
|
8
|
+
*/
|
|
9
|
+
export const useTrackFeature = () => {
|
|
10
|
+
const analyticsProvider = useFrameworkModule<AnalyticsModule>('analytics');
|
|
11
|
+
const appProvider = useFrameworkModule<AppModule>('app');
|
|
12
|
+
const contextProvider = useFrameworkModule('context');
|
|
13
|
+
const telemetryProvider = useFrameworkModule('telemetry');
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Tracks a analytics event.
|
|
17
|
+
*
|
|
18
|
+
* Can be used both in useCallback or useEffects - see README.md for examples.
|
|
19
|
+
*
|
|
20
|
+
* @param name - The feature to track
|
|
21
|
+
* @param data - Optional map of additional key-value pairs to include with the analytics event
|
|
22
|
+
*/
|
|
23
|
+
const trackFeature = useCallback(
|
|
24
|
+
(name: string, data?: AnyValueMap) => {
|
|
25
|
+
if (!analyticsProvider) {
|
|
26
|
+
telemetryProvider?.trackException({
|
|
27
|
+
name: 'AnalyticsProviderNotFound',
|
|
28
|
+
exception: new Error(`Analytics provider not found`),
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
analyticsProvider?.trackAnalytic({
|
|
33
|
+
name: 'app-feature',
|
|
34
|
+
value: {
|
|
35
|
+
feature: name,
|
|
36
|
+
data,
|
|
37
|
+
},
|
|
38
|
+
attributes: {
|
|
39
|
+
appKey: appProvider?.current?.appKey,
|
|
40
|
+
context: contextProvider?.currentContext
|
|
41
|
+
? {
|
|
42
|
+
id: contextProvider.currentContext.id,
|
|
43
|
+
externalId: contextProvider.currentContext.externalId,
|
|
44
|
+
title: contextProvider.currentContext.title,
|
|
45
|
+
type: contextProvider.currentContext.type.id,
|
|
46
|
+
source: contextProvider.currentContext.source,
|
|
47
|
+
}
|
|
48
|
+
: undefined,
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
},
|
|
52
|
+
[analyticsProvider, appProvider, contextProvider, telemetryProvider],
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
return trackFeature;
|
|
56
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useEffect, useRef
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
2
|
import { useApploader } from './useApploader';
|
|
3
3
|
|
|
4
4
|
export type ApploaderProps = {
|
|
@@ -13,12 +13,12 @@ export type ApploaderProps = {
|
|
|
13
13
|
*
|
|
14
14
|
* @param { ApploaderProps } props - The props for the component.
|
|
15
15
|
* @param { string } props.appKey - The key of the Fusion app to load and mount.
|
|
16
|
-
* @returns {
|
|
16
|
+
* @returns { JSX.Element } The rendered component, which displays loading, error, or the embedded app.
|
|
17
17
|
*
|
|
18
18
|
* @example
|
|
19
19
|
* <Apploader appKey="my-app" />
|
|
20
20
|
*/
|
|
21
|
-
export const Apploader = ({ appKey }: ApploaderProps):
|
|
21
|
+
export const Apploader = ({ appKey }: ApploaderProps): JSX.Element => {
|
|
22
22
|
const refWrapp = useRef<HTMLDivElement | null>(null);
|
|
23
23
|
const { loading, error, appRef } = useApploader({ appKey });
|
|
24
24
|
|
package/src/index.ts
CHANGED
|
@@ -8,8 +8,6 @@ export type {
|
|
|
8
8
|
IAppConfigurator,
|
|
9
9
|
} from '@equinor/fusion-framework-app';
|
|
10
10
|
|
|
11
|
-
export type { Fusion } from '@equinor/fusion-framework-react';
|
|
12
|
-
|
|
13
11
|
export { AppManifest } from '@equinor/fusion-framework-module-app';
|
|
14
12
|
|
|
15
13
|
export { useAppModule } from './useAppModule';
|
|
@@ -20,11 +18,11 @@ export { makeComponent, ComponentRenderArgs } from './make-component';
|
|
|
20
18
|
|
|
21
19
|
export { createLegacyApp } from './create-legacy-app';
|
|
22
20
|
|
|
23
|
-
|
|
21
|
+
// TODO deprecate
|
|
24
22
|
export { renderApp } from './render-app';
|
|
23
|
+
export { createComponent } from './create-component';
|
|
25
24
|
export { renderComponent } from './render-component';
|
|
26
25
|
|
|
27
26
|
export type { ComponentRenderer } from './create-component';
|
|
28
|
-
export type { RenderTeardown } from './render-component';
|
|
29
27
|
|
|
30
28
|
export { default } from './render-app';
|
package/src/make-component.tsx
CHANGED
|
@@ -55,7 +55,7 @@ export const makeComponent = <
|
|
|
55
55
|
): React.LazyExoticComponent<React.ComponentType> =>
|
|
56
56
|
lazy(async () => {
|
|
57
57
|
const init = configureModules<TModules, TRef, TEnv>(configure);
|
|
58
|
-
const modules = await init(args);
|
|
58
|
+
const modules = (await init(args)) as unknown as AppModulesInstance;
|
|
59
59
|
|
|
60
60
|
const { fusion } = args;
|
|
61
61
|
|
package/src/render-app.ts
CHANGED
|
@@ -3,13 +3,7 @@ import { renderComponent, type RenderTeardown } from './render-component';
|
|
|
3
3
|
|
|
4
4
|
import type { ComponentRenderArgs } from './create-component';
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
* Creates a render function for an app component.
|
|
8
|
-
* Uses React 18's createRoot API via renderComponent.
|
|
9
|
-
*
|
|
10
|
-
* @param componentArgs - Arguments to pass to createComponent
|
|
11
|
-
* @returns A function that renders the app into a DOM element
|
|
12
|
-
*/
|
|
6
|
+
/** @deprecated */
|
|
13
7
|
export const renderApp = (...componentArgs: Parameters<typeof createComponent>) => {
|
|
14
8
|
const renderer = renderComponent(createComponent(...componentArgs));
|
|
15
9
|
return (el: HTMLElement, args: ComponentRenderArgs): RenderTeardown => {
|
package/src/render-component.tsx
CHANGED
|
@@ -1,43 +1,46 @@
|
|
|
1
1
|
import { Suspense, StrictMode } from 'react';
|
|
2
2
|
import type { FunctionComponent } from 'react';
|
|
3
|
-
import { createRoot, type Root } from 'react-dom/client';
|
|
4
3
|
import type { ComponentRenderArgs, ComponentRenderer } from './create-component';
|
|
4
|
+
import ReactDOM from 'react-dom';
|
|
5
5
|
|
|
6
6
|
export type RenderTeardown = VoidFunction;
|
|
7
7
|
|
|
8
|
-
/**
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
/** @deprecated */
|
|
9
|
+
export const renderComponent = (renderer: ComponentRenderer) => {
|
|
10
|
+
return (el: HTMLElement, args: ComponentRenderArgs): RenderTeardown => {
|
|
11
|
+
const Component = renderer(args.fusion, args.env);
|
|
12
|
+
return render(el, Component);
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
|
|
15
16
|
const render = (el: Element, Component: FunctionComponent): RenderTeardown => {
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
// eslint-disable-next-line react/no-deprecated
|
|
18
|
+
ReactDOM.render(
|
|
18
19
|
<StrictMode>
|
|
19
20
|
<Suspense fallback={<p>loading app</p>}>
|
|
20
21
|
<Component />
|
|
21
22
|
</Suspense>
|
|
22
23
|
</StrictMode>,
|
|
24
|
+
el,
|
|
23
25
|
);
|
|
24
26
|
return () => {
|
|
25
|
-
|
|
27
|
+
// eslint-disable-next-line react/no-deprecated
|
|
28
|
+
ReactDOM.unmountComponentAtNode(el);
|
|
26
29
|
};
|
|
27
30
|
};
|
|
28
31
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
};
|
|
32
|
+
// const render = (el: Element, Component: FunctionComponent): RenderTeardown => {
|
|
33
|
+
// const root = createRoot(el);
|
|
34
|
+
// root.render(
|
|
35
|
+
// <StrictMode>
|
|
36
|
+
// <Suspense fallback={<p>loading app</p>}>
|
|
37
|
+
// <Component />
|
|
38
|
+
// </Suspense>
|
|
39
|
+
// </StrictMode>
|
|
40
|
+
// );
|
|
41
|
+
// return () => {
|
|
42
|
+
// root.unmount();
|
|
43
|
+
// };
|
|
44
|
+
// };
|
|
42
45
|
|
|
43
46
|
export default renderComponent;
|
package/src/useAppModules.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AppModulesInstance } from '@equinor/fusion-framework-app';
|
|
2
2
|
import type { AnyModule } from '@equinor/fusion-framework-module';
|
|
3
3
|
import { useModules } from '@equinor/fusion-framework-react-module';
|
|
4
4
|
|
|
@@ -10,6 +10,6 @@ import { useModules } from '@equinor/fusion-framework-react-module';
|
|
|
10
10
|
*/
|
|
11
11
|
export const useAppModules = <
|
|
12
12
|
T extends Array<AnyModule> | unknown = unknown,
|
|
13
|
-
>(): AppModulesInstance<T> => useModules<
|
|
13
|
+
>(): AppModulesInstance<T> => useModules<AppModulesInstance<T>>();
|
|
14
14
|
|
|
15
15
|
export default useAppModules;
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by genversion.
|
|
2
|
-
export const version = '9.0.
|
|
2
|
+
export const version = '9.0.1';
|
package/tsconfig.json
CHANGED
|
@@ -15,6 +15,9 @@
|
|
|
15
15
|
{
|
|
16
16
|
"path": "../framework"
|
|
17
17
|
},
|
|
18
|
+
{
|
|
19
|
+
"path": "../../modules/analytics"
|
|
20
|
+
},
|
|
18
21
|
{
|
|
19
22
|
"path": "../../modules/ag-grid"
|
|
20
23
|
},
|
|
@@ -35,5 +38,5 @@
|
|
|
35
38
|
}
|
|
36
39
|
],
|
|
37
40
|
"include": ["src/**/*"],
|
|
38
|
-
"exclude": ["node_modules", "lib"
|
|
41
|
+
"exclude": ["node_modules", "lib"]
|
|
39
42
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"selectors.js","sourceRoot":"","sources":["../../../src/http/selectors.ts"],"names":[],"mappings":"AAAA,cAAc,iDAAiD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '@equinor/fusion-framework-module-http/selectors';
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
-
import type { ComponentRenderArgs } from '../create-component';
|
|
3
|
-
import type { Fusion } from '@equinor/fusion-framework-react';
|
|
4
|
-
import type { AppEnv } from '@equinor/fusion-framework-app';
|
|
5
|
-
|
|
6
|
-
// Mock dependencies before importing
|
|
7
|
-
vi.mock('../create-component', () => ({
|
|
8
|
-
createComponent: vi.fn(),
|
|
9
|
-
}));
|
|
10
|
-
|
|
11
|
-
vi.mock('../render-component', () => ({
|
|
12
|
-
renderComponent: vi.fn(),
|
|
13
|
-
}));
|
|
14
|
-
|
|
15
|
-
import { renderApp } from '../render-app';
|
|
16
|
-
import { createComponent } from '../create-component';
|
|
17
|
-
import { renderComponent } from '../render-component';
|
|
18
|
-
|
|
19
|
-
describe('renderApp', () => {
|
|
20
|
-
let mockFusion: Fusion;
|
|
21
|
-
let mockEnv: AppEnv;
|
|
22
|
-
let mockElement: HTMLElement;
|
|
23
|
-
let mockTeardown: () => void;
|
|
24
|
-
let mockComponentRenderer: ReturnType<typeof createComponent>;
|
|
25
|
-
let mockRenderFunction: ReturnType<typeof renderComponent>;
|
|
26
|
-
|
|
27
|
-
beforeEach(() => {
|
|
28
|
-
// Setup mock data
|
|
29
|
-
mockFusion = {} as Fusion;
|
|
30
|
-
mockEnv = {} as AppEnv;
|
|
31
|
-
mockElement = document.createElement('div');
|
|
32
|
-
mockTeardown = vi.fn();
|
|
33
|
-
|
|
34
|
-
// Create a mock component renderer
|
|
35
|
-
// createComponent returns a ComponentRenderer function: (fusion, env) => React.LazyExoticComponent
|
|
36
|
-
mockComponentRenderer = vi.fn() as unknown as ReturnType<typeof createComponent>;
|
|
37
|
-
|
|
38
|
-
// Create a mock render function
|
|
39
|
-
mockRenderFunction = vi.fn(() => mockTeardown) as unknown as ReturnType<typeof renderComponent>;
|
|
40
|
-
|
|
41
|
-
// Mock renderComponent to return our mock render function
|
|
42
|
-
vi.mocked(renderComponent).mockReturnValue(mockRenderFunction);
|
|
43
|
-
|
|
44
|
-
// Mock createComponent to return our mock component renderer
|
|
45
|
-
vi.mocked(createComponent).mockReturnValue(mockComponentRenderer);
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it('should create a render function that calls createComponent with provided arguments', () => {
|
|
49
|
-
const TestComponent = () => <div>Test</div>;
|
|
50
|
-
const mockConfigure = vi.fn();
|
|
51
|
-
|
|
52
|
-
renderApp(TestComponent, mockConfigure);
|
|
53
|
-
|
|
54
|
-
expect(createComponent).toHaveBeenCalledWith(TestComponent, mockConfigure);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it('should create a render function that uses renderComponent with the component renderer', () => {
|
|
58
|
-
const TestComponent = () => <div>Test</div>;
|
|
59
|
-
const appRender = renderApp(TestComponent);
|
|
60
|
-
|
|
61
|
-
// Call the render function
|
|
62
|
-
const teardown = appRender(mockElement, { fusion: mockFusion, env: mockEnv });
|
|
63
|
-
|
|
64
|
-
expect(renderComponent).toHaveBeenCalledWith(mockComponentRenderer);
|
|
65
|
-
expect(mockRenderFunction).toHaveBeenCalledWith(mockElement, {
|
|
66
|
-
fusion: mockFusion,
|
|
67
|
-
env: mockEnv,
|
|
68
|
-
});
|
|
69
|
-
expect(teardown).toBe(mockTeardown);
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it('should return a teardown function that unmounts the component', () => {
|
|
73
|
-
const TestComponent = () => <div>Test</div>;
|
|
74
|
-
const appRender = renderApp(TestComponent);
|
|
75
|
-
|
|
76
|
-
const teardown = appRender(mockElement, { fusion: mockFusion, env: mockEnv });
|
|
77
|
-
|
|
78
|
-
expect(typeof teardown).toBe('function');
|
|
79
|
-
teardown();
|
|
80
|
-
expect(mockTeardown).toHaveBeenCalled();
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
it('should work without a configure callback', () => {
|
|
84
|
-
vi.clearAllMocks();
|
|
85
|
-
const TestComponent = () => <div>Test</div>;
|
|
86
|
-
const appRender = renderApp(TestComponent);
|
|
87
|
-
|
|
88
|
-
// When no configure callback is provided, it may be called with just the component
|
|
89
|
-
// or with undefined as the second parameter
|
|
90
|
-
expect(createComponent).toHaveBeenCalled();
|
|
91
|
-
const calls = vi.mocked(createComponent).mock.calls;
|
|
92
|
-
expect(calls[calls.length - 1][0]).toBe(TestComponent);
|
|
93
|
-
expect(calls[calls.length - 1][1]).toBeUndefined();
|
|
94
|
-
|
|
95
|
-
const teardown = appRender(mockElement, { fusion: mockFusion, env: mockEnv });
|
|
96
|
-
|
|
97
|
-
expect(teardown).toBe(mockTeardown);
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
it('should pass component renderer args correctly to renderComponent', () => {
|
|
101
|
-
const TestComponent = () => <div>Test</div>;
|
|
102
|
-
const appRender = renderApp(TestComponent);
|
|
103
|
-
|
|
104
|
-
const args: ComponentRenderArgs = {
|
|
105
|
-
fusion: mockFusion,
|
|
106
|
-
env: mockEnv,
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
appRender(mockElement, args);
|
|
110
|
-
|
|
111
|
-
expect(mockRenderFunction).toHaveBeenCalledWith(mockElement, args);
|
|
112
|
-
});
|
|
113
|
-
});
|
package/src/http/selectors.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '@equinor/fusion-framework-module-http/selectors';
|
package/vitest.config.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { defineProject } from 'vitest/config';
|
|
2
|
-
import tsconfigPaths from 'vite-tsconfig-paths';
|
|
3
|
-
import { fileURLToPath } from 'node:url';
|
|
4
|
-
import { resolve } from 'node:path';
|
|
5
|
-
|
|
6
|
-
import { name, version } from './package.json';
|
|
7
|
-
|
|
8
|
-
export default defineProject({
|
|
9
|
-
plugins: [
|
|
10
|
-
tsconfigPaths({
|
|
11
|
-
root: resolve(fileURLToPath(new URL('../../..', import.meta.url))),
|
|
12
|
-
projects: [resolve(fileURLToPath(new URL('.', import.meta.url)), 'tsconfig.json')],
|
|
13
|
-
}),
|
|
14
|
-
],
|
|
15
|
-
test: {
|
|
16
|
-
include: ['src/__tests__/**'],
|
|
17
|
-
name: `${name}@${version}`,
|
|
18
|
-
environment: 'happy-dom',
|
|
19
|
-
},
|
|
20
|
-
});
|