@equinor/fusion-framework-module-app 5.2.7 → 5.2.9

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,28 +1,36 @@
1
1
  import type { FrameworkEvent, FrameworkEventInit } from '@equinor/fusion-framework-module-event';
2
2
  import type { App } from './App';
3
- import type { AppConfig, AppManifest, AppModulesInstance } from '../types';
3
+ import type { AppConfig, AppManifest, AppModulesInstance, AppScriptModule } from '../types';
4
4
  export type AppEventEventInit<TDetail extends Record<string, unknown> | unknown = unknown> = FrameworkEventInit<TDetail & {
5
5
  appKey: string;
6
6
  }, App>;
7
+ export type AppEvent<TDetail extends Record<string, unknown> | unknown = unknown> = FrameworkEvent<AppEventEventInit<TDetail>>;
8
+ export type AppEventFailure = FrameworkEvent<AppEventEventInit<{
9
+ error: AppConfig;
10
+ }>>;
7
11
  declare module '@equinor/fusion-framework-module-event' {
8
12
  interface FrameworkEventMap {
9
- onAppModulesLoaded: FrameworkEvent<AppEventEventInit<{
13
+ onAppModulesLoaded: AppEvent<{
10
14
  modules: AppModulesInstance;
11
- }>>;
12
- onAppManifestLoaded: FrameworkEvent<AppEventEventInit<{
15
+ }>;
16
+ onAppManifestLoad: AppEvent;
17
+ onAppManifestLoaded: AppEvent<{
13
18
  manifest: AppManifest;
14
- }>>;
15
- onAppConfigLoaded: FrameworkEvent<AppEventEventInit<{
19
+ }>;
20
+ onAppManifestFailure: AppEventFailure;
21
+ onAppConfigLoad: AppEvent;
22
+ onAppConfigLoaded: AppEvent<{
16
23
  config: AppConfig;
17
- }>>;
18
- onAppScriptLoaded: FrameworkEvent<AppEventEventInit<{
19
- manifest: AppManifest;
20
- }>>;
21
- onAppInitialize: FrameworkEvent<AppEventEventInit>;
22
- onAppInitialized: FrameworkEvent<AppEventEventInit>;
23
- onAppInitializeFailed: FrameworkEvent<AppEventEventInit<{
24
- error: unknown;
25
- }>>;
24
+ }>;
25
+ onAppConfigFailure: AppEventFailure;
26
+ onAppScriptLoad: AppEvent;
27
+ onAppScriptLoaded: AppEvent<{
28
+ script: AppScriptModule;
29
+ }>;
30
+ onAppScriptFailure: AppEventFailure;
31
+ onAppInitialize: AppEvent;
32
+ onAppInitialized: AppEvent;
33
+ onAppInitializeFailure: AppEventFailure;
26
34
  onAppDispose: FrameworkEvent<AppEventEventInit>;
27
35
  }
28
36
  }
@@ -1 +1 @@
1
- export declare const version = "5.2.7";
1
+ export declare const version = "5.2.9";
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@equinor/fusion-framework-module-app",
3
- "version": "5.2.7",
3
+ "version": "5.2.9",
4
4
  "description": "",
5
5
  "main": "dist/esm/index.js",
6
6
  "exports": {
7
7
  ".": "./dist/esm/index.js",
8
8
  "./errors.js": "./dist/esm/errors.js",
9
- "./app": "./dist/esm/app/index.js"
9
+ "./app": "./dist/esm/app/index.js",
10
+ "./app/*.js": "./dist/esm/app/*.js"
10
11
  },
11
12
  "types": "dist/types/index.d.ts",
12
13
  "typesVersions": {
@@ -16,6 +17,9 @@
16
17
  ],
17
18
  "app": [
18
19
  "dist/types/app/index.d.ts"
20
+ ],
21
+ "app/*.js": [
22
+ "dist/types/app/*.d.ts"
19
23
  ]
20
24
  }
21
25
  },
@@ -34,15 +38,15 @@
34
38
  "immer": "^9.0.16",
35
39
  "rxjs": "^7.8.1",
36
40
  "@equinor/fusion-observable": "^8.1.2",
37
- "@equinor/fusion-query": "^4.0.2"
41
+ "@equinor/fusion-query": "^4.0.3"
38
42
  },
39
43
  "devDependencies": {
40
44
  "typescript": "^5.1.3",
45
+ "@equinor/fusion-framework-module-msal": "^3.0.7",
41
46
  "@equinor/fusion-framework-module": "^4.2.5",
47
+ "@equinor/fusion-framework-module-service-discovery": "^7.0.13",
42
48
  "@equinor/fusion-framework-module-event": "^4.0.6",
43
- "@equinor/fusion-framework-module-http": "^5.1.1",
44
- "@equinor/fusion-framework-module-msal": "^3.0.7",
45
- "@equinor/fusion-framework-module-service-discovery": "^7.0.12"
49
+ "@equinor/fusion-framework-module-http": "^5.1.1"
46
50
  },
47
51
  "scripts": {
48
52
  "build": "tsc -b"
package/src/app/App.ts CHANGED
@@ -170,23 +170,59 @@ export class App<TEnv = any, TModules extends Array<AnyModule> | unknown = unkno
170
170
  #registerEvents(event: ModuleType<EventModule>): void {
171
171
  const { appKey } = this;
172
172
 
173
+ this.#state.addEffect(actions.fetchManifest.type, (action) => {
174
+ event.dispatchEvent('onAppManifestLoad', {
175
+ detail: { appKey, manifest: action.payload },
176
+ source: this,
177
+ });
178
+ });
173
179
  this.#state.addEffect(actions.fetchManifest.success.type, (action) => {
174
180
  event.dispatchEvent('onAppManifestLoaded', {
175
181
  detail: { appKey, manifest: action.payload },
176
182
  source: this,
177
183
  });
178
184
  });
185
+ this.#state.addEffect(actions.fetchManifest.failure.type, (action) => {
186
+ event.dispatchEvent('onAppManifestFailure', {
187
+ detail: { appKey, manifest: action.payload },
188
+ source: this,
189
+ });
190
+ });
179
191
 
192
+ this.#state.addEffect(actions.fetchConfig.type, (action) => {
193
+ event.dispatchEvent('onAppConfigLoad', {
194
+ detail: { appKey, manifest: action.payload },
195
+ source: this,
196
+ });
197
+ });
180
198
  this.#state.addEffect(actions.fetchConfig.success.type, (action) => {
181
199
  event.dispatchEvent('onAppConfigLoaded', {
182
200
  detail: { appKey, manifest: action.payload },
183
201
  source: this,
184
202
  });
185
203
  });
204
+ this.#state.addEffect(actions.fetchConfig.failure.type, (action) => {
205
+ event.dispatchEvent('onAppConfigFailure', {
206
+ detail: { appKey, manifest: action.payload },
207
+ source: this,
208
+ });
209
+ });
186
210
 
211
+ this.#state.addEffect(actions.importApp.type, (action) => {
212
+ event.dispatchEvent('onAppScriptLoad', {
213
+ detail: { appKey, manifest: action.payload },
214
+ source: this,
215
+ });
216
+ });
187
217
  this.#state.addEffect(actions.importApp.success.type, (action) => {
188
218
  event.dispatchEvent('onAppScriptLoaded', {
189
- detail: { appKey, manifest: action.payload },
219
+ detail: { appKey, script: action.payload },
220
+ source: this,
221
+ });
222
+ });
223
+ this.#state.addEffect(actions.importApp.failure.type, (action) => {
224
+ event.dispatchEvent('onAppScriptFailure', {
225
+ detail: { appKey, error: action.payload },
190
226
  source: this,
191
227
  });
192
228
  });
@@ -206,7 +242,7 @@ export class App<TEnv = any, TModules extends Array<AnyModule> | unknown = unkno
206
242
  });
207
243
 
208
244
  this.#state.addEffect(actions.initialize.failure.type, ({ payload }) => {
209
- event.dispatchEvent('onAppInitializeFailed', {
245
+ event.dispatchEvent('onAppInitializeFailure', {
210
246
  detail: { appKey, error: payload },
211
247
  source: this,
212
248
  });
package/src/app/events.ts CHANGED
@@ -2,7 +2,7 @@ import type { FrameworkEvent, FrameworkEventInit } from '@equinor/fusion-framewo
2
2
 
3
3
  import type { App } from './App';
4
4
 
5
- import type { AppConfig, AppManifest, AppModulesInstance } from '../types';
5
+ import type { AppConfig, AppManifest, AppModulesInstance, AppScriptModule } from '../types';
6
6
 
7
7
  /** base event type for applications */
8
8
  export type AppEventEventInit<TDetail extends Record<string, unknown> | unknown = unknown> =
@@ -13,53 +13,57 @@ export type AppEventEventInit<TDetail extends Record<string, unknown> | unknown
13
13
  App
14
14
  >;
15
15
 
16
+ export type AppEvent<TDetail extends Record<string, unknown> | unknown = unknown> = FrameworkEvent<
17
+ AppEventEventInit<TDetail>
18
+ >;
19
+
20
+ export type AppEventFailure = FrameworkEvent<
21
+ AppEventEventInit<{
22
+ error: AppConfig;
23
+ }>
24
+ >;
25
+
16
26
  declare module '@equinor/fusion-framework-module-event' {
17
27
  interface FrameworkEventMap {
18
28
  /** fired when the application has initiated its modules */
19
- onAppModulesLoaded: FrameworkEvent<
20
- AppEventEventInit<{
21
- /** initiated modules for application */
22
- modules: AppModulesInstance;
23
- }>
24
- >;
29
+ onAppModulesLoaded: AppEvent<{
30
+ /** initiated modules for application */
31
+ modules: AppModulesInstance;
32
+ }>;
25
33
 
34
+ onAppManifestLoad: AppEvent;
26
35
  /** fired when the application has loaded corresponding manifest */
27
- onAppManifestLoaded: FrameworkEvent<
28
- AppEventEventInit<{
29
- manifest: AppManifest;
30
- }>
31
- >;
36
+ onAppManifestLoaded: AppEvent<{
37
+ manifest: AppManifest;
38
+ }>;
39
+ onAppManifestFailure: AppEventFailure;
32
40
 
41
+ onAppConfigLoad: AppEvent;
33
42
  /** fired when the application has loaded corresponding config */
34
- onAppConfigLoaded: FrameworkEvent<
35
- AppEventEventInit<{
36
- config: AppConfig;
37
- }>
38
- >;
43
+ onAppConfigLoaded: AppEvent<{
44
+ config: AppConfig;
45
+ }>;
46
+ onAppConfigFailure: AppEventFailure;
39
47
 
40
48
  /** fired when the application has loaded corresponding javascript module */
41
- onAppScriptLoaded: FrameworkEvent<
42
- AppEventEventInit<{
43
- manifest: AppManifest;
44
- }>
45
- >;
49
+ onAppScriptLoad: AppEvent;
50
+ onAppScriptLoaded: AppEvent<{
51
+ script: AppScriptModule;
52
+ }>;
53
+ onAppScriptFailure: AppEventFailure;
46
54
 
47
55
  /** fired before application loads manifest, config and script */
48
- onAppInitialize: FrameworkEvent<AppEventEventInit>;
56
+ onAppInitialize: AppEvent;
49
57
 
50
58
  /**
51
59
  * fired after application has loaded manifest, config and script
52
60
  *
53
61
  * __note:__ not fired until all loaders has settled (last emit)
54
62
  */
55
- onAppInitialized: FrameworkEvent<AppEventEventInit>;
63
+ onAppInitialized: AppEvent;
56
64
 
57
65
  /** fired when application fails to load either manifest, config and script */
58
- onAppInitializeFailed: FrameworkEvent<
59
- AppEventEventInit<{
60
- error: unknown;
61
- }>
62
- >;
66
+ onAppInitializeFailure: AppEventFailure;
63
67
 
64
68
  /** fired when the application is disposed (unmounts) */
65
69
  onAppDispose: FrameworkEvent<AppEventEventInit>;
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  // Generated by genversion.
2
- export const version = '5.2.7';
2
+ export const version = '5.2.9';