@equinor/fusion-framework-react-app 0.4.2 → 0.5.0

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.
@@ -1 +1,2 @@
1
- export { AppConfig, useAppConfig, UseAppConfigResult, useAppConfig$, UseAppConfigStreamResult, } from '@equinor/fusion-framework-react-module-app-config';
1
+ export { useAppConfig, useAppConfig$ } from '@equinor/fusion-framework-react-module-app-config';
2
+ export type { AppConfig, UseAppConfigResult, UseAppConfigStreamResult, } from '@equinor/fusion-framework-react-module-app-config';
@@ -1,8 +1,15 @@
1
- import type { Fusion, AppManifest } from '@equinor/fusion-framework';
2
- import { AnyModule, ModulesConfigType } from '@equinor/fusion-framework-module';
3
- import { AppModules } from './modules';
4
- export interface AppConfigurator<TModules extends Array<AnyModule> = []> {
5
- (config: ModulesConfigType<AppModules> & ModulesConfigType<TModules>, fusion: Fusion, env: AppManifest): void | Promise<void>;
6
- }
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';
7
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
+ }
8
15
  export default createApp;
@@ -1,2 +1,6 @@
1
- export { AppConfigurator, createApp, default } from './create-app';
2
- export { AppModules, AppModulesInstance, appModules, useAppModule, useAppModules } from './modules';
1
+ export { appModules } from '@equinor/fusion-framework-app';
2
+ export type { AppConfigurator, AppModules, AppModulesInstance, AppManifest, } from '@equinor/fusion-framework-app';
3
+ export { useAppModule } from './useAppModule';
4
+ export { useAppModules } from './useAppModules';
5
+ export { createApp } from './create-app';
6
+ export { default } from './create-app';
@@ -0,0 +1,3 @@
1
+ import type { AppModulesInstance } from '@equinor/fusion-framework-app';
2
+ export declare const useAppModule: <TKey extends string | number>(module: TKey) => AppModulesInstance<[]>[TKey];
3
+ export default useAppModule;
@@ -0,0 +1,3 @@
1
+ import type { AppModulesInstance } from '@equinor/fusion-framework-app';
2
+ export declare const useAppModules: () => AppModulesInstance<[]>;
3
+ export default useAppModules;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/fusion-framework-react-app",
3
- "version": "0.4.2",
3
+ "version": "0.5.0",
4
4
  "description": "",
5
5
  "main": "dist/esm/index.js",
6
6
  "exports": {
@@ -39,13 +39,15 @@
39
39
  "directory": "packages/react"
40
40
  },
41
41
  "dependencies": {
42
- "@equinor/fusion-framework": "^2.0.1",
43
- "@equinor/fusion-framework-module": "^0.4.1",
44
- "@equinor/fusion-framework-module-http": "^0.6.1",
45
- "@equinor/fusion-framework-module-msal": "^0.3.1",
46
- "@equinor/fusion-framework-react": "^0.2.15",
47
- "@equinor/fusion-framework-react-module-app-config": "^0.1.2",
48
- "@equinor/fusion-observable": "^0.1.3"
42
+ "@equinor/fusion-framework": "^2.1.0",
43
+ "@equinor/fusion-framework-app": "^0.1.1",
44
+ "@equinor/fusion-framework-module": "^0.4.2",
45
+ "@equinor/fusion-framework-module-event": "^0.1.1",
46
+ "@equinor/fusion-framework-module-http": "^0.6.2",
47
+ "@equinor/fusion-framework-module-msal": "^0.3.2",
48
+ "@equinor/fusion-framework-react": "^0.2.17",
49
+ "@equinor/fusion-framework-react-module-app-config": "^0.1.3",
50
+ "@equinor/fusion-observable": "^0.3.0"
49
51
  },
50
52
  "devDependencies": {
51
53
  "@types/react": "^17.0.11",
@@ -67,5 +69,5 @@
67
69
  "optional": true
68
70
  }
69
71
  },
70
- "gitHead": "293ea245afed24ebcbbf04cb4be66210d7705af9"
72
+ "gitHead": "4a8883c57421b9353676a9972179321c59b48ed7"
71
73
  }
@@ -1,7 +1,7 @@
1
- export {
1
+ export { useAppConfig, useAppConfig$ } from '@equinor/fusion-framework-react-module-app-config';
2
+
3
+ export type {
2
4
  AppConfig,
3
- useAppConfig,
4
5
  UseAppConfigResult,
5
- useAppConfig$,
6
6
  UseAppConfigStreamResult,
7
7
  } from '@equinor/fusion-framework-react-module-app-config';
@@ -1,36 +1,16 @@
1
- /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
2
1
  import { lazy } from 'react';
3
2
 
4
- import type { Fusion, AppManifest } from '@equinor/fusion-framework';
5
- import FrameworkProvider from '@equinor/fusion-framework-react';
3
+ import { FrameworkProvider } from '@equinor/fusion-framework-react';
4
+ import type { Fusion } from '@equinor/fusion-framework-react';
6
5
 
7
- import { AnyModule, ModulesConfigType } from '@equinor/fusion-framework-module';
6
+ import { initializeAppModules } from '@equinor/fusion-framework-app';
7
+ import type { AppManifest, AppConfigurator, AppModules } from '@equinor/fusion-framework-app';
8
8
 
9
- import { appModules, AppModules } from './modules';
9
+ import type { AnyModule, ModulesInstanceType } from '@equinor/fusion-framework-module';
10
10
 
11
- import { createModuleProvider } from '@equinor/fusion-framework-react-module';
11
+ import type { FrameworkEvent, FrameworkEventInit } from '@equinor/fusion-framework-module-event';
12
12
 
13
- /**
14
- * Interface for type hinting configuration callbacks
15
- * @example
16
- * ```ts
17
- * const configCallback: AppConfigurator = (configurator) => {
18
- * configurator.http.configureClient(
19
- * 'bar', {
20
- * baseUri: 'https://somewhere-test.com',
21
- * defaultScopes: ['foo/.default']
22
- * }
23
- * );
24
- * };
25
- * ```
26
- */
27
- export interface AppConfigurator<TModules extends Array<AnyModule> = []> {
28
- (
29
- config: ModulesConfigType<AppModules> & ModulesConfigType<TModules>,
30
- fusion: Fusion,
31
- env: AppManifest
32
- ): void | Promise<void>;
33
- }
13
+ import { ModuleProvider as AppModuleProvider } from '@equinor/fusion-framework-react-module';
34
14
 
35
15
  /**
36
16
  * Creates an lazy loading Component which configures modules
@@ -96,18 +76,18 @@ export const createApp =
96
76
  await Promise.resolve(configure(config, fusion, env));
97
77
  }
98
78
  };
99
- const AppModuleProvider = await createModuleProvider(
100
- configurator,
101
- // TODO type hint concat of modules
102
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
103
- // @ts-ignore
104
- appModules.concat(modules),
105
- fusion.modules
106
- );
79
+
80
+ const appInitiator = initializeAppModules(configurator, modules ?? []);
81
+
82
+ const appModules = await appInitiator(fusion, env);
83
+ appModules.event.dispatchEvent('onReactAppLoaded', {
84
+ detail: { modules, fusion },
85
+ source: Component,
86
+ });
107
87
  return {
108
88
  default: () => (
109
89
  <FrameworkProvider value={fusion}>
110
- <AppModuleProvider>
90
+ <AppModuleProvider value={appModules}>
111
91
  <Component />
112
92
  </AppModuleProvider>
113
93
  </FrameworkProvider>
@@ -115,4 +95,15 @@ export const createApp =
115
95
  };
116
96
  });
117
97
 
98
+ declare module '@equinor/fusion-framework-module-event' {
99
+ interface FrameworkEventMap {
100
+ onReactAppLoaded: FrameworkEvent<
101
+ FrameworkEventInit<
102
+ { modules: ModulesInstanceType<AppModules>; fusion: Fusion },
103
+ React.ComponentType
104
+ >
105
+ >;
106
+ }
107
+ }
108
+
118
109
  export default createApp;
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable @typescript-eslint/ban-types */
2
2
  import { HttpClientMsal, IHttpClient } from '@equinor/fusion-framework-module-http';
3
3
  import { useMemo } from 'react';
4
- import { useAppModule } from '../modules';
4
+ import { useAppModule } from '../useAppModule';
5
5
 
6
6
  /**
7
7
  * Use a configured client from application modules
package/src/index.ts CHANGED
@@ -3,5 +3,18 @@
3
3
  * @module
4
4
  */
5
5
 
6
- export { AppConfigurator, createApp, default } from './create-app';
7
- export { AppModules, AppModulesInstance, appModules, useAppModule, useAppModules } from './modules';
6
+ export { appModules } from '@equinor/fusion-framework-app';
7
+
8
+ export type {
9
+ AppConfigurator,
10
+ AppModules,
11
+ AppModulesInstance,
12
+ AppManifest,
13
+ } from '@equinor/fusion-framework-app';
14
+
15
+ export { useAppModule } from './useAppModule';
16
+ export { useAppModules } from './useAppModules';
17
+
18
+ export { createApp } from './create-app';
19
+
20
+ export { default } from './create-app';
@@ -0,0 +1,8 @@
1
+ import type { AppModulesInstance } from '@equinor/fusion-framework-app';
2
+ import { useAppModules } from './useAppModules';
3
+
4
+ export const useAppModule = <TKey extends keyof AppModulesInstance>(
5
+ module: TKey
6
+ ): AppModulesInstance[TKey] => useAppModules()[module];
7
+
8
+ export default useAppModule;
@@ -0,0 +1,6 @@
1
+ import type { AppModulesInstance } from '@equinor/fusion-framework-app';
2
+ import { useModules } from '@equinor/fusion-framework-react-module';
3
+
4
+ export const useAppModules = useModules<AppModulesInstance>;
5
+
6
+ export default useAppModules;
package/tsconfig.json CHANGED
@@ -14,6 +14,9 @@
14
14
  {
15
15
  "path": "../framework"
16
16
  },
17
+ {
18
+ "path": "../app"
19
+ },
17
20
  {
18
21
  "path": "../framework-react"
19
22
  },
@@ -26,6 +29,9 @@
26
29
  {
27
30
  "path": "../module-msal"
28
31
  },
32
+ {
33
+ "path": "../module-event"
34
+ },
29
35
  {
30
36
  "path": "../react-module"
31
37
  },
@@ -1,8 +0,0 @@
1
- import http from '@equinor/fusion-framework-module-http';
2
- import msal from '@equinor/fusion-framework-module-msal';
3
- import appConfig from '@equinor/fusion-framework-react-module-app-config';
4
- import { useModules } from '@equinor/fusion-framework-react-module';
5
- export const appModules = [http, msal, appConfig];
6
- export const useAppModules = (useModules);
7
- export const useAppModule = (module) => useAppModules()[module];
8
- //# sourceMappingURL=modules.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"modules.js","sourceRoot":"","sources":["../../src/modules.tsx"],"names":[],"mappings":"AAEA,OAAO,IAAoB,MAAM,uCAAuC,CAAC;AACzE,OAAO,IAAoB,MAAM,uCAAuC,CAAC;AACzE,OAAO,SAA8B,MAAM,mDAAmD,CAAC;AAE/F,OAAO,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AAKpE,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;AAElD,MAAM,CAAC,MAAM,aAAa,GAAG,CAAA,UAA8B,CAAA,CAAC;AAC5D,MAAM,CAAC,MAAM,YAAY,GAAG,CACxB,MAAY,EACY,EAAE,CAAC,aAAa,EAAE,CAAC,MAAM,CAAC,CAAC"}
package/dist/esm/types.js DELETED
@@ -1,2 +0,0 @@
1
- "use strict";
2
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
@@ -1,17 +0,0 @@
1
- import { ModulesInstanceType } from '@equinor/fusion-framework-module';
2
- import { HttpModule } from '@equinor/fusion-framework-module-http';
3
- import { MsalModule } from '@equinor/fusion-framework-module-msal';
4
- import { AppConfigModule } from '@equinor/fusion-framework-react-module-app-config';
5
- export declare type AppModules = [HttpModule, MsalModule, AppConfigModule];
6
- export declare type AppModulesInstance = ModulesInstanceType<AppModules>;
7
- export declare const appModules: (HttpModule | MsalModule | AppConfigModule)[];
8
- export declare const useAppModules: () => {
9
- http: import("@equinor/fusion-framework-module-http").IHttpClientProvider<import("@equinor/fusion-framework-module-http").IHttpClient<import("@equinor/fusion-framework-module-http").FetchRequest, Response>>;
10
- auth: import("@equinor/fusion-framework-module-msal").IAuthProvider;
11
- appConfig: import("@equinor/fusion-framework-react-module-app-config").IAppConfigProvider<unknown>;
12
- };
13
- export declare const useAppModule: <TKey extends "http" | "auth" | "appConfig">(module: TKey) => {
14
- http: import("@equinor/fusion-framework-module-http").IHttpClientProvider<import("@equinor/fusion-framework-module-http").IHttpClient<import("@equinor/fusion-framework-module-http").FetchRequest, Response>>;
15
- auth: import("@equinor/fusion-framework-module-msal").IAuthProvider;
16
- appConfig: import("@equinor/fusion-framework-react-module-app-config").IAppConfigProvider<unknown>;
17
- }[TKey];
File without changes
package/src/modules.tsx DELETED
@@ -1,17 +0,0 @@
1
- import { ModulesInstanceType } from '@equinor/fusion-framework-module';
2
-
3
- import http, { HttpModule } from '@equinor/fusion-framework-module-http';
4
- import msal, { MsalModule } from '@equinor/fusion-framework-module-msal';
5
- import appConfig, { AppConfigModule } from '@equinor/fusion-framework-react-module-app-config';
6
-
7
- import { useModules } from '@equinor/fusion-framework-react-module';
8
-
9
- export type AppModules = [HttpModule, MsalModule, AppConfigModule];
10
- export type AppModulesInstance = ModulesInstanceType<AppModules>;
11
-
12
- export const appModules = [http, msal, appConfig];
13
-
14
- export const useAppModules = useModules<AppModulesInstance>;
15
- export const useAppModule = <TKey extends keyof AppModulesInstance>(
16
- module: TKey
17
- ): AppModulesInstance[TKey] => useAppModules()[module];
package/src/types.ts DELETED
File without changes