@equinor/fusion-framework-react-app 1.0.2 → 1.0.3
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 +9 -0
- package/dist/esm/create-component.js +1 -1
- package/dist/esm/create-component.js.map +1 -1
- package/dist/esm/create-legacy-app.js +1 -1
- package/dist/esm/create-legacy-app.js.map +1 -1
- package/dist/esm/render-component.js +3 -12
- package/dist/esm/render-component.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/create-component.d.ts +1 -1
- package/dist/types/render-component.d.ts +1 -1
- package/dist/types/useAppModule.d.ts +1 -1
- package/dist/types/useAppModules.d.ts +1 -1
- package/package.json +8 -8
- package/src/create-component.tsx +4 -5
- package/src/create-legacy-app.tsx +1 -1
- package/src/render-component.tsx +17 -22
- package/dist/esm/create-app.js +0 -24
- package/dist/esm/create-app.js.map +0 -1
- package/dist/types/create-app.d.ts +0 -15
- package/yarn-error.log +0 -13173
|
@@ -7,7 +7,7 @@ export declare type ComponentRenderArgs<TFusion extends Fusion = Fusion, TManife
|
|
|
7
7
|
fusion: TFusion;
|
|
8
8
|
env: TManifest;
|
|
9
9
|
};
|
|
10
|
-
export declare type ComponentRenderer<TFusion extends Fusion = Fusion, TManifest extends AppManifest = AppManifest> = (
|
|
10
|
+
export declare type ComponentRenderer<TFusion extends Fusion = Fusion, TManifest extends AppManifest = AppManifest> = (fusion: TFusion, env: TManifest) => React.LazyExoticComponent<React.ComponentType>;
|
|
11
11
|
export declare const createComponent: <TModules extends AnyModule[], TRef extends Fusion<[]> = Fusion<[]>, TManifest extends AppManifest = AppManifest>(Component: React.ComponentType, configure?: AppModuleInitiator<TModules, TRef, TManifest> | undefined) => ComponentRenderer<TRef, TManifest>;
|
|
12
12
|
declare module '@equinor/fusion-framework-module-event' {
|
|
13
13
|
interface FrameworkEventMap {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ComponentRenderArgs, ComponentRenderer } from 'create-component';
|
|
1
|
+
import type { ComponentRenderArgs, ComponentRenderer } from './create-component';
|
|
2
2
|
export declare type RenderTeardown = VoidFunction;
|
|
3
3
|
export declare const renderComponent: (renderer: ComponentRenderer) => (el: HTMLElement, args: ComponentRenderArgs) => RenderTeardown;
|
|
4
4
|
export default renderComponent;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { AppModulesInstance } from '@equinor/fusion-framework-app';
|
|
2
|
-
export declare const useAppModule: <TKey extends "dispose" | "
|
|
2
|
+
export declare const useAppModule: <TKey extends "event" | "dispose" | "http" | "auth" | "appConfig">(module: TKey) => AppModulesInstance<unknown>[TKey];
|
|
3
3
|
export default useAppModule;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@equinor/fusion-framework-react-app",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/esm/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -39,12 +39,12 @@
|
|
|
39
39
|
"directory": "packages/react"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@equinor/fusion-framework-app": "^1.0.
|
|
43
|
-
"@equinor/fusion-framework-module": "^1.1.
|
|
44
|
-
"@equinor/fusion-framework-module-event": "^1.0.
|
|
45
|
-
"@equinor/fusion-framework-module-msal": "^1.0.
|
|
46
|
-
"@equinor/fusion-framework-react": "^1.0.
|
|
47
|
-
"@equinor/fusion-framework-react-module-app-config": "^1.0.
|
|
42
|
+
"@equinor/fusion-framework-app": "^1.0.3",
|
|
43
|
+
"@equinor/fusion-framework-module": "^1.1.1",
|
|
44
|
+
"@equinor/fusion-framework-module-event": "^1.0.3",
|
|
45
|
+
"@equinor/fusion-framework-module-msal": "^1.0.3",
|
|
46
|
+
"@equinor/fusion-framework-react": "^1.0.3",
|
|
47
|
+
"@equinor/fusion-framework-react-module-app-config": "^1.0.3"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@types/react": "^17.0.11",
|
|
@@ -66,5 +66,5 @@
|
|
|
66
66
|
"optional": true
|
|
67
67
|
}
|
|
68
68
|
},
|
|
69
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "ed86940ac2091df63390cebd4c34d54ad02ed3fc"
|
|
70
70
|
}
|
package/src/create-component.tsx
CHANGED
|
@@ -20,12 +20,11 @@ export type ComponentRenderArgs<
|
|
|
20
20
|
TFusion extends Fusion = Fusion,
|
|
21
21
|
TManifest extends AppManifest = AppManifest
|
|
22
22
|
> = { fusion: TFusion; env: TManifest };
|
|
23
|
+
|
|
23
24
|
export type ComponentRenderer<
|
|
24
25
|
TFusion extends Fusion = Fusion,
|
|
25
26
|
TManifest extends AppManifest = AppManifest
|
|
26
|
-
> = (
|
|
27
|
-
args: ComponentRenderArgs<TFusion, TManifest>
|
|
28
|
-
) => React.LazyExoticComponent<React.ComponentType>;
|
|
27
|
+
> = (fusion: TFusion, env: TManifest) => React.LazyExoticComponent<React.ComponentType>;
|
|
29
28
|
|
|
30
29
|
/**
|
|
31
30
|
* Creates an lazy loading Component which configures modules
|
|
@@ -85,9 +84,9 @@ export const createComponent =
|
|
|
85
84
|
Component: React.ComponentType,
|
|
86
85
|
configure?: AppModuleInitiator<TModules, TRef, TManifest>
|
|
87
86
|
): ComponentRenderer<TRef, TManifest> =>
|
|
88
|
-
(
|
|
87
|
+
(fusion, env) =>
|
|
89
88
|
lazy(async () => {
|
|
90
|
-
const init = initAppModules(configure);
|
|
89
|
+
const init = initAppModules<TModules, TRef, TManifest>(configure);
|
|
91
90
|
const modules = (await init({
|
|
92
91
|
fusion,
|
|
93
92
|
manifest: env,
|
|
@@ -15,7 +15,7 @@ export const createLegacyApp = <TModules extends Array<AnyModule>>(
|
|
|
15
15
|
const fusion = useFramework();
|
|
16
16
|
const RenderComponent = useMemo(() => {
|
|
17
17
|
const creator = createComponent(Component, configure);
|
|
18
|
-
return creator(
|
|
18
|
+
return creator(fusion, { name: 'legacy' });
|
|
19
19
|
}, []);
|
|
20
20
|
return (
|
|
21
21
|
<Suspense fallback={<p>loading app</p>}>
|
package/src/render-component.tsx
CHANGED
|
@@ -1,23 +1,18 @@
|
|
|
1
1
|
import { Suspense, StrictMode } from 'react';
|
|
2
2
|
import type { FunctionComponent } from 'react';
|
|
3
|
-
import type { ComponentRenderArgs, ComponentRenderer } from 'create-component';
|
|
3
|
+
import type { ComponentRenderArgs, ComponentRenderer } from './create-component';
|
|
4
4
|
import ReactDOM from 'react-dom';
|
|
5
5
|
|
|
6
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
7
|
-
// @ts-ignore
|
|
8
|
-
import { createRoot } from 'react-dom/client';
|
|
9
|
-
|
|
10
6
|
export type RenderTeardown = VoidFunction;
|
|
11
7
|
|
|
12
8
|
export const renderComponent = (renderer: ComponentRenderer) => {
|
|
13
9
|
return (el: HTMLElement, args: ComponentRenderArgs): RenderTeardown => {
|
|
14
|
-
const Component = renderer(args);
|
|
15
|
-
|
|
16
|
-
return renderFn(el, Component);
|
|
10
|
+
const Component = renderer(args.fusion, args.env);
|
|
11
|
+
return render(el, Component);
|
|
17
12
|
};
|
|
18
13
|
};
|
|
19
14
|
|
|
20
|
-
const
|
|
15
|
+
const render = (el: Element, Component: FunctionComponent): RenderTeardown => {
|
|
21
16
|
ReactDOM.render(
|
|
22
17
|
<StrictMode>
|
|
23
18
|
<Suspense fallback={<p>loading app</p>}>
|
|
@@ -31,18 +26,18 @@ const renderLegacy = (el: Element, Component: FunctionComponent): RenderTeardown
|
|
|
31
26
|
};
|
|
32
27
|
};
|
|
33
28
|
|
|
34
|
-
const render = (el: Element, Component: FunctionComponent): RenderTeardown => {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
};
|
|
29
|
+
// const render = (el: Element, Component: FunctionComponent): RenderTeardown => {
|
|
30
|
+
// const root = createRoot(el);
|
|
31
|
+
// root.render(
|
|
32
|
+
// <StrictMode>
|
|
33
|
+
// <Suspense fallback={<p>loading app</p>}>
|
|
34
|
+
// <Component />
|
|
35
|
+
// </Suspense>
|
|
36
|
+
// </StrictMode>
|
|
37
|
+
// );
|
|
38
|
+
// return () => {
|
|
39
|
+
// root.unmount();
|
|
40
|
+
// };
|
|
41
|
+
// };
|
|
47
42
|
|
|
48
43
|
export default renderComponent;
|
package/dist/esm/create-app.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { lazy } from 'react';
|
|
3
|
-
import { FrameworkProvider } from '@equinor/fusion-framework-react';
|
|
4
|
-
import { initializeAppModules } from '@equinor/fusion-framework-app';
|
|
5
|
-
import { ModuleProvider as AppModuleProvider } from '@equinor/fusion-framework-react-module';
|
|
6
|
-
export const createApp = (Component, configure, modules) => (fusion, env) => lazy(async () => {
|
|
7
|
-
modules ??= [];
|
|
8
|
-
const configurator = async (config) => {
|
|
9
|
-
if (configure) {
|
|
10
|
-
await Promise.resolve(configure(config, fusion, env));
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
const appInitiator = initializeAppModules(configurator, modules ?? []);
|
|
14
|
-
const appModules = await appInitiator(fusion, env);
|
|
15
|
-
appModules.event.dispatchEvent('onReactAppLoaded', {
|
|
16
|
-
detail: { modules, fusion },
|
|
17
|
-
source: Component,
|
|
18
|
-
});
|
|
19
|
-
return {
|
|
20
|
-
default: () => (_jsx(FrameworkProvider, { value: fusion, children: _jsx(AppModuleProvider, { value: appModules, children: _jsx(Component, {}) }) })),
|
|
21
|
-
};
|
|
22
|
-
});
|
|
23
|
-
export default createApp;
|
|
24
|
-
//# sourceMappingURL=create-app.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-app.js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|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import type { Fusion } from '@equinor/fusion-framework-react';
|
|
3
|
-
import type { AppManifest, AppConfigurator, AppModules } from '@equinor/fusion-framework-app';
|
|
4
|
-
import type { AnyModule, ModulesInstanceType } from '@equinor/fusion-framework-module';
|
|
5
|
-
import type { FrameworkEvent, FrameworkEventInit } from '@equinor/fusion-framework-module-event';
|
|
6
|
-
export declare const createApp: <TModules extends AnyModule[]>(Component: React.ComponentType, configure?: AppConfigurator<TModules> | undefined, modules?: TModules | undefined) => (fusion: Fusion, env: AppManifest) => React.LazyExoticComponent<React.ComponentType>;
|
|
7
|
-
declare module '@equinor/fusion-framework-module-event' {
|
|
8
|
-
interface FrameworkEventMap {
|
|
9
|
-
onReactAppLoaded: FrameworkEvent<FrameworkEventInit<{
|
|
10
|
-
modules: ModulesInstanceType<AppModules>;
|
|
11
|
-
fusion: Fusion;
|
|
12
|
-
}, React.ComponentType>>;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
export default createApp;
|