@equinor/fusion-framework-module-app 6.1.8 → 6.1.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,24 +1,3 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
11
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
12
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
13
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
14
- };
15
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
16
- if (kind === "m") throw new TypeError("Private method is not writable");
17
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
18
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
19
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
20
- };
21
- var _App_instances, _App_state, _App_registerEvents;
22
1
  import { Observable } from '@equinor/fusion-observable';
23
2
  import { combineLatest, of, Subscription, firstValueFrom, lastValueFrom, } from 'rxjs';
24
3
  import { defaultIfEmpty, filter, last, map, switchMap } from 'rxjs/operators';
@@ -34,42 +13,43 @@ const fallbackSettings = {};
34
13
  // TODO make streams distinct until changed from state
35
14
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
36
15
  export class App {
16
+ #state;
37
17
  //#region === streams ===
38
18
  get manifest$() {
39
- return __classPrivateFieldGet(this, _App_state, "f").select((state) => state.manifest).pipe(filterEmpty());
19
+ return this.#state.select((state) => state.manifest).pipe(filterEmpty());
40
20
  }
41
21
  get config$() {
42
- return __classPrivateFieldGet(this, _App_state, "f")
22
+ return this.#state
43
23
  .select((state) => state.config, isEqual)
44
24
  .pipe(filterEmpty());
45
25
  }
46
26
  get modules$() {
47
- return __classPrivateFieldGet(this, _App_state, "f").select((state) => state.modules).pipe(filterEmpty());
27
+ return this.#state.select((state) => state.modules).pipe(filterEmpty());
48
28
  }
49
29
  get instance$() {
50
- return __classPrivateFieldGet(this, _App_state, "f")
30
+ return this.#state
51
31
  .select((state) => state.instance)
52
32
  .pipe(filterEmpty());
53
33
  }
54
34
  get settings$() {
55
35
  return new Observable((subscriber) => {
56
- __classPrivateFieldGet(this, _App_state, "f").next(actions.fetchSettings(this.appKey));
57
- subscriber.add(__classPrivateFieldGet(this, _App_state, "f")
36
+ this.#state.next(actions.fetchSettings(this.appKey));
37
+ subscriber.add(this.#state
58
38
  .select((state) => state.settings, isEqual)
59
39
  .pipe(filterEmpty(), defaultIfEmpty(fallbackSettings))
60
40
  .subscribe(subscriber));
61
41
  });
62
42
  }
63
43
  get status$() {
64
- return __classPrivateFieldGet(this, _App_state, "f").select((state) => state.status);
44
+ return this.#state.select((state) => state.status);
65
45
  }
66
46
  //#endregion
67
47
  get state() {
68
48
  // todo deep-freeze
69
- return Object.freeze(__classPrivateFieldGet(this, _App_state, "f").value);
49
+ return Object.freeze(this.#state.value);
70
50
  }
71
51
  get appKey() {
72
- return __classPrivateFieldGet(this, _App_state, "f").value.appKey;
52
+ return this.#state.value.appKey;
73
53
  }
74
54
  get manifest() {
75
55
  return this.state.manifest;
@@ -84,16 +64,14 @@ export class App {
84
64
  return firstValueFrom(this.config$);
85
65
  }
86
66
  get instance() {
87
- return __classPrivateFieldGet(this, _App_state, "f").value.instance;
67
+ return this.#state.value.instance;
88
68
  }
89
69
  constructor(value, args) {
90
- _App_instances.add(this);
91
- _App_state.set(this, void 0);
92
- __classPrivateFieldSet(this, _App_state, createState(value, args.provider), "f");
70
+ this.#state = createState(value, args.provider);
93
71
  const { appKey } = value;
94
72
  const { event } = args;
95
73
  // register events if event module is provided
96
- event && __classPrivateFieldGet(this, _App_instances, "m", _App_registerEvents).call(this, event);
74
+ event && this.#registerEvents(event);
97
75
  // create a tear down handler for the application
98
76
  const subscriptions = new Subscription();
99
77
  if (event) {
@@ -106,23 +84,174 @@ export class App {
106
84
  // validate that the event is for the current app
107
85
  if (e.detail.appKey === appKey) {
108
86
  // set the instance of the app modules
109
- __classPrivateFieldGet(this, _App_state, "f").next(actions.setInstance(e.detail.modules));
87
+ this.#state.next(actions.setInstance(e.detail.modules));
110
88
  }
111
89
  }));
112
90
  }
113
91
  this.dispose = () => {
114
- subscriptions === null || subscriptions === void 0 ? void 0 : subscriptions.unsubscribe();
115
- if (__classPrivateFieldGet(this, _App_state, "f").value.instance) {
92
+ subscriptions?.unsubscribe();
93
+ if (this.#state.value.instance) {
116
94
  // tear down modules of application
117
- __classPrivateFieldGet(this, _App_state, "f").value.instance.dispose();
95
+ this.#state.value.instance.dispose();
118
96
  }
119
- __classPrivateFieldGet(this, _App_state, "f").complete();
97
+ this.#state.complete();
120
98
  };
121
99
  }
100
+ /**
101
+ * Registers event listeners for various actions in the app.
102
+ * @param event - The event module used for dispatching events.
103
+ */
104
+ #registerEvents(event) {
105
+ const { appKey } = this;
106
+ // monitor when application manifest is loading
107
+ this.#state.addEffect(actions.fetchManifest.type, () => {
108
+ // dispatch event to notify listeners that the application manifest is being loaded
109
+ event.dispatchEvent('onAppManifestLoad', {
110
+ detail: { appKey },
111
+ source: this,
112
+ });
113
+ });
114
+ // monitor when application manifest is loaded
115
+ this.#state.addEffect(actions.fetchManifest.success.type, (action) => {
116
+ // dispatch event to notify listeners that the application manifest has been loaded
117
+ event.dispatchEvent('onAppManifestLoaded', {
118
+ detail: { appKey, manifest: action.payload },
119
+ source: this,
120
+ });
121
+ });
122
+ // monitor when application manifest fails to load
123
+ this.#state.addEffect(actions.fetchManifest.failure.type, (action) => {
124
+ // dispatch event to notify listeners that the application manifest failed to load
125
+ event.dispatchEvent('onAppManifestFailure', {
126
+ detail: { appKey, error: action.payload },
127
+ source: this,
128
+ });
129
+ });
130
+ // monitor when application configuration is loading
131
+ this.#state.addEffect(actions.fetchConfig.type, () => {
132
+ // dispatch event to notify listeners that the application configuration is being loaded
133
+ event.dispatchEvent('onAppConfigLoad', {
134
+ detail: { appKey },
135
+ source: this,
136
+ });
137
+ });
138
+ // monitor when application configuration is loaded
139
+ this.#state.addEffect(actions.fetchConfig.success.type, (action) => {
140
+ // dispatch event to notify listeners that the application configuration has been loaded
141
+ event.dispatchEvent('onAppConfigLoaded', {
142
+ detail: { appKey, config: action.payload },
143
+ source: this,
144
+ });
145
+ });
146
+ // monitor when application configuration fails to load
147
+ this.#state.addEffect(actions.fetchConfig.failure.type, (action) => {
148
+ // dispatch event to notify listeners that the application configuration failed to load
149
+ event.dispatchEvent('onAppConfigFailure', {
150
+ detail: { appKey, error: action.payload },
151
+ source: this,
152
+ });
153
+ });
154
+ // monitor when application settings is loading
155
+ this.#state.addEffect(actions.fetchSettings.type, () => {
156
+ // dispatch event to notify listeners that the application settings is being loaded
157
+ event.dispatchEvent('onAppSettingsLoad', {
158
+ detail: { appKey },
159
+ source: this,
160
+ });
161
+ });
162
+ // monitor when application settings is loaded
163
+ this.#state.addEffect(actions.fetchSettings.success.type, (action) => {
164
+ // dispatch event to notify listeners that the application settings has been loaded
165
+ event.dispatchEvent('onAppSettingsLoaded', {
166
+ detail: { appKey, settings: action.payload },
167
+ source: this,
168
+ });
169
+ });
170
+ // monitor when application settings fails to load
171
+ this.#state.addEffect(actions.fetchSettings.failure.type, (action) => {
172
+ // dispatch event to notify listeners that the application settings failed to load
173
+ event.dispatchEvent('onAppSettingsFailure', {
174
+ detail: { appKey, error: action.payload },
175
+ source: this,
176
+ });
177
+ });
178
+ // monitor when application settings is updated
179
+ this.#state.addEffect(actions.updateSettings.type, (action) => {
180
+ // dispatch event to notify listeners that the application settings has been loaded
181
+ event.dispatchEvent('onAppSettingsUpdate', {
182
+ detail: { appKey, settings: action.payload.settings },
183
+ source: this,
184
+ });
185
+ });
186
+ // monitor when application settings is updated
187
+ this.#state.addEffect(actions.updateSettings.success.type, (action) => {
188
+ // dispatch event to notify listeners that the application settings has been loaded
189
+ event.dispatchEvent('onAppSettingsUpdated', {
190
+ detail: { appKey, settings: action.payload.settings },
191
+ source: this,
192
+ });
193
+ });
194
+ // monitor when application settings fails to updated
195
+ this.#state.addEffect(actions.updateSettings.failure.type, (action) => {
196
+ // dispatch event to notify listeners that the application settings has been loaded
197
+ event.dispatchEvent('onAppSettingsUpdateFailure', {
198
+ detail: { appKey, settings: action.payload },
199
+ source: this,
200
+ });
201
+ });
202
+ // monitor when application script is loading
203
+ this.#state.addEffect(actions.importApp.type, () => {
204
+ // dispatch event to notify listeners that the application script is being loaded
205
+ event.dispatchEvent('onAppScriptLoad', {
206
+ detail: { appKey },
207
+ source: this,
208
+ });
209
+ });
210
+ // monitor when application script is loaded
211
+ this.#state.addEffect(actions.importApp.success.type, (action) => {
212
+ // dispatch event to notify listeners that the application script has been loaded
213
+ event.dispatchEvent('onAppScriptLoaded', {
214
+ detail: { appKey, script: action.payload },
215
+ source: this,
216
+ });
217
+ });
218
+ // monitor when application script fails to load
219
+ this.#state.addEffect(actions.importApp.failure.type, (action) => {
220
+ // dispatch event to notify listeners that the application script failed to load
221
+ event.dispatchEvent('onAppScriptFailure', {
222
+ detail: { appKey, error: action.payload },
223
+ source: this,
224
+ });
225
+ });
226
+ // monitor when application is initializing
227
+ this.#state.addEffect(actions.initialize.type, () => {
228
+ // dispatch event to notify listeners that the application is initializing
229
+ event.dispatchEvent('onAppInitialize', {
230
+ detail: { appKey },
231
+ source: this,
232
+ });
233
+ });
234
+ // monitor when application has been initialized
235
+ this.#state.addEffect(actions.initialize.success.type, () => {
236
+ // dispatch event to notify listeners that the application has been initialized
237
+ event.dispatchEvent('onAppInitialized', {
238
+ detail: { appKey },
239
+ source: this,
240
+ });
241
+ });
242
+ // monitor when application fails to initialize
243
+ this.#state.addEffect(actions.initialize.failure.type, ({ payload }) => {
244
+ // dispatch event to notify listeners that the application failed to initialize
245
+ event.dispatchEvent('onAppInitializeFailure', {
246
+ detail: { appKey, error: payload },
247
+ source: this,
248
+ });
249
+ });
250
+ }
122
251
  initialize() {
123
252
  return new Observable((subscriber) => {
124
253
  // dispatch initialize action to indicate that the application is initializing
125
- __classPrivateFieldGet(this, _App_state, "f").next(actions.initialize());
254
+ this.#state.next(actions.initialize());
126
255
  subscriber.add(
127
256
  // request latest manifest, application script, and configuration
128
257
  combineLatest([this.getManifest(), this.getAppModule(), this.getConfig()]).subscribe({
@@ -135,11 +264,11 @@ export class App {
135
264
  }),
136
265
  error: (err) => {
137
266
  // emit error and complete the stream
138
- subscriber.error(err), __classPrivateFieldGet(this, _App_state, "f").next(actions.initialize.failure(err));
267
+ subscriber.error(err), this.#state.next(actions.initialize.failure(err));
139
268
  },
140
269
  complete: () => {
141
270
  // dispatch initialize success action to indicate that the application has been initialized
142
- __classPrivateFieldGet(this, _App_state, "f").next(actions.initialize.success());
271
+ this.#state.next(actions.initialize.success());
143
272
  subscriber.complete();
144
273
  },
145
274
  }));
@@ -149,33 +278,30 @@ export class App {
149
278
  // TODO - shit fix
150
279
  (this.manifest ? of(this.manifest) : this.getManifest()).subscribe({
151
280
  next: (manifest) => {
152
- __classPrivateFieldGet(this, _App_state, "f").next(actions.fetchConfig(manifest));
281
+ this.#state.next(actions.fetchConfig(manifest));
153
282
  },
154
283
  });
155
284
  }
156
285
  loadManifest(update) {
157
- __classPrivateFieldGet(this, _App_state, "f").next(actions.fetchManifest(this.appKey, update));
286
+ this.#state.next(actions.fetchManifest(this.appKey, update));
158
287
  }
159
288
  updateManifest(manifest, replace) {
160
- __classPrivateFieldGet(this, _App_state, "f").next(actions.setManifest(manifest, !replace));
161
- }
162
- loadAppModule() {
163
- return __awaiter(this, arguments, void 0, function* (allow_cache = true) {
164
- var _a;
165
- const manifest = yield this.getManifestAsync(allow_cache);
166
- if ((_a = manifest.build) === null || _a === void 0 ? void 0 : _a.entryPoint) {
167
- __classPrivateFieldGet(this, _App_state, "f").next(actions.importApp(manifest.build.entryPoint));
168
- }
169
- else {
170
- console.warn(`The ${manifest.appKey} is missing entryPoint, please upload a build for the app before continuing`);
171
- }
172
- });
289
+ this.#state.next(actions.setManifest(manifest, !replace));
290
+ }
291
+ async loadAppModule(allow_cache = true) {
292
+ const manifest = await this.getManifestAsync(allow_cache);
293
+ if (manifest.build?.entryPoint) {
294
+ this.#state.next(actions.importApp(manifest.build.entryPoint));
295
+ }
296
+ else {
297
+ console.warn(`The ${manifest.appKey} is missing entryPoint, please upload a build for the app before continuing`);
298
+ }
173
299
  }
174
300
  getConfig(force_refresh = false) {
175
301
  return new Observable((subscriber) => {
176
- if (__classPrivateFieldGet(this, _App_state, "f").value.config) {
302
+ if (this.#state.value.config) {
177
303
  // emit current config to the subscriber
178
- subscriber.next(__classPrivateFieldGet(this, _App_state, "f").value.config);
304
+ subscriber.next(this.#state.value.config);
179
305
  if (!force_refresh) {
180
306
  // since we have the config and no force refresh, complete the stream
181
307
  return subscriber.complete();
@@ -184,13 +310,13 @@ export class App {
184
310
  // when stream closes, dispose of subscription to change of state config
185
311
  subscriber.add(
186
312
  // monitor changes to state changes of config and emit to subscriber
187
- __classPrivateFieldGet(this, _App_state, "f").addEffect('set_config', ({ payload }) => {
313
+ this.#state.addEffect('set_config', ({ payload }) => {
188
314
  subscriber.next(payload);
189
315
  }));
190
316
  // when stream closes, dispose of subscription to fetch config
191
317
  subscriber.add(
192
318
  // monitor success of fetching config and emit to subscriber
193
- __classPrivateFieldGet(this, _App_state, "f").addEffect('fetch_config::success', ({ payload }) => {
319
+ this.#state.addEffect('fetch_config::success', ({ payload }) => {
194
320
  // application config loaded, emit to subscriber and complete the stream
195
321
  subscriber.next(payload);
196
322
  subscriber.complete();
@@ -198,7 +324,7 @@ export class App {
198
324
  // when stream closes, dispose of subscription to fetch config
199
325
  subscriber.add(
200
326
  // monitor failure of fetching config and emit error to subscriber
201
- __classPrivateFieldGet(this, _App_state, "f").addEffect('fetch_config::failure', ({ payload }) => {
327
+ this.#state.addEffect('fetch_config::failure', ({ payload }) => {
202
328
  // application config failed to load, emit error and complete the stream
203
329
  subscriber.error(Error('failed to load application config', {
204
330
  cause: payload,
@@ -214,9 +340,9 @@ export class App {
214
340
  }
215
341
  getSettings(force_refresh = false) {
216
342
  return new Observable((subscriber) => {
217
- if (__classPrivateFieldGet(this, _App_state, "f").value.settings) {
343
+ if (this.#state.value.settings) {
218
344
  // emit current settings to the subscriber
219
- subscriber.next(__classPrivateFieldGet(this, _App_state, "f").value.settings);
345
+ subscriber.next(this.#state.value.settings);
220
346
  if (!force_refresh) {
221
347
  // since we have the settings and no force refresh, complete the stream
222
348
  return subscriber.complete();
@@ -225,13 +351,13 @@ export class App {
225
351
  // when stream closes, dispose of subscription to change of state settings
226
352
  subscriber.add(
227
353
  // monitor changes to state changes of settings and emit to subscriber
228
- __classPrivateFieldGet(this, _App_state, "f").addEffect('set_settings', ({ payload }) => {
354
+ this.#state.addEffect('set_settings', ({ payload }) => {
229
355
  subscriber.next(payload);
230
356
  }));
231
357
  // when stream closes, dispose of subscription to fetch settings
232
358
  subscriber.add(
233
359
  // monitor success of fetching settings and emit to subscriber
234
- __classPrivateFieldGet(this, _App_state, "f").addEffect('fetch_settings::success', ({ payload }) => {
360
+ this.#state.addEffect('fetch_settings::success', ({ payload }) => {
235
361
  // application settings loaded, emit to subscriber and complete the stream
236
362
  subscriber.next(payload);
237
363
  subscriber.complete();
@@ -239,13 +365,13 @@ export class App {
239
365
  // when stream closes, dispose of subscription to fetch settings
240
366
  subscriber.add(
241
367
  // monitor failure of fetching settings and emit error to subscriber
242
- __classPrivateFieldGet(this, _App_state, "f").addEffect('fetch_settings::failure', ({ payload }) => {
368
+ this.#state.addEffect('fetch_settings::failure', ({ payload }) => {
243
369
  // application settings failed to load, emit error and complete the stream
244
370
  subscriber.error(Error('failed to load application settings', {
245
371
  cause: payload,
246
372
  }));
247
373
  }));
248
- __classPrivateFieldGet(this, _App_state, "f").next(actions.fetchSettings(this.appKey));
374
+ this.#state.next(actions.fetchSettings(this.appKey));
249
375
  });
250
376
  }
251
377
  getSettingsAsync(allow_cache = true) {
@@ -257,9 +383,9 @@ export class App {
257
383
  return new Observable((subscriber) => {
258
384
  subscriber.add(
259
385
  // monitor failure of updating settings and emit error to subscriber
260
- __classPrivateFieldGet(this, _App_state, "f").addEffect('update_settings::failure', ({ payload }) => {
386
+ this.#state.addEffect('update_settings::failure', ({ payload }) => {
261
387
  // request to reset settings to source state
262
- __classPrivateFieldGet(this, _App_state, "f").next(actions.fetchSettings(this.appKey));
388
+ this.#state.next(actions.fetchSettings(this.appKey));
263
389
  // application settings failed to save, emit error and complete the stream
264
390
  subscriber.error(Error('failed to update application settings', {
265
391
  cause: payload,
@@ -267,28 +393,28 @@ export class App {
267
393
  }));
268
394
  subscriber.add(
269
395
  // monitor success of updating settings and emit to subscriber
270
- __classPrivateFieldGet(this, _App_state, "f").addEffect('update_settings::success', ({ payload }) => {
396
+ this.#state.addEffect('update_settings::success', ({ payload }) => {
271
397
  subscriber.next(payload);
272
398
  subscriber.complete();
273
399
  }));
274
400
  // optimistic update of settings
275
- __classPrivateFieldGet(this, _App_state, "f").next(actions.setSettings(settings));
401
+ this.#state.next(actions.setSettings(settings));
276
402
  // request to update settings
277
- __classPrivateFieldGet(this, _App_state, "f").next(actions.updateSettings(this.appKey, settings));
403
+ this.#state.next(actions.updateSettings(this.appKey, settings));
278
404
  });
279
405
  }
280
406
  updateSettingsAsync(settings) {
281
407
  return lastValueFrom(this.updateSettings(settings));
282
408
  }
283
409
  updateSetting(property, value) {
284
- const currentSettings$ = __classPrivateFieldGet(this, _App_state, "f").value.settings === undefined
410
+ const currentSettings$ = this.#state.value.settings === undefined
285
411
  ? // if settings are not loaded, fetch settings
286
412
  this.getSettings().pipe(last())
287
413
  : // if settings are loaded, use current settings
288
- of(__classPrivateFieldGet(this, _App_state, "f").value.settings);
414
+ of(this.#state.value.settings);
289
415
  return currentSettings$.pipe(
290
416
  // merge current settings with new value
291
- map((settings) => (Object.assign(Object.assign({}, settings), { [property]: value }))),
417
+ map((settings) => ({ ...settings, [property]: value })),
292
418
  // update settings
293
419
  switchMap((settings) => this.updateSettings(settings)),
294
420
  // return the updated property
@@ -299,9 +425,9 @@ export class App {
299
425
  }
300
426
  getManifest(force_refresh = false) {
301
427
  return new Observable((subscriber) => {
302
- if (__classPrivateFieldGet(this, _App_state, "f").value.manifest) {
428
+ if (this.#state.value.manifest) {
303
429
  // emit current manifest to the subscriber
304
- subscriber.next(__classPrivateFieldGet(this, _App_state, "f").value.manifest);
430
+ subscriber.next(this.#state.value.manifest);
305
431
  if (!force_refresh) {
306
432
  // since we have the manifest and no force refresh, complete the stream
307
433
  return subscriber.complete();
@@ -310,20 +436,20 @@ export class App {
310
436
  // when stream closes, dispose of subscription to change of state manifest
311
437
  subscriber.add(
312
438
  // monitor changes to state changes of manifest and emit to subscriber
313
- __classPrivateFieldGet(this, _App_state, "f").addEffect('set_manifest', ({ payload }) => {
439
+ this.#state.addEffect('set_manifest', ({ payload }) => {
314
440
  subscriber.next(payload);
315
441
  }));
316
442
  // when stream closes, dispose of subscription to fetch manifest
317
443
  subscriber.add(
318
444
  // monitor success of fetching manifest and emit to subscriber
319
- __classPrivateFieldGet(this, _App_state, "f").addEffect('fetch_manifest::success', ({ payload }) => {
445
+ this.#state.addEffect('fetch_manifest::success', ({ payload }) => {
320
446
  subscriber.next(payload);
321
447
  // application manifest loaded, complete the stream
322
448
  subscriber.complete();
323
449
  }));
324
450
  subscriber.add(
325
451
  // monitor failure of fetching manifest and emit error to subscriber
326
- __classPrivateFieldGet(this, _App_state, "f").addEffect('fetch_manifest::failure', ({ payload }) => {
452
+ this.#state.addEffect('fetch_manifest::failure', ({ payload }) => {
327
453
  // application manifest failed to load, emit error and complete the stream
328
454
  subscriber.error(Error('failed to load application manifest', {
329
455
  cause: payload,
@@ -340,9 +466,9 @@ export class App {
340
466
  }
341
467
  getAppModule(force_refresh = false) {
342
468
  return new Observable((subscriber) => {
343
- if (__classPrivateFieldGet(this, _App_state, "f").value.modules) {
469
+ if (this.#state.value.modules) {
344
470
  // emit current value to the subscriber
345
- subscriber.next(__classPrivateFieldGet(this, _App_state, "f").value.modules);
471
+ subscriber.next(this.#state.value.modules);
346
472
  if (!force_refresh) {
347
473
  // complete if no force refresh
348
474
  return subscriber.complete();
@@ -351,13 +477,13 @@ export class App {
351
477
  // when stream closes, dispose of subscription to change of state modules
352
478
  subscriber.add(
353
479
  // monitor changes to state changes of modules and emit to subscriber
354
- __classPrivateFieldGet(this, _App_state, "f").addEffect('set_module', ({ payload }) => {
480
+ this.#state.addEffect('set_module', ({ payload }) => {
355
481
  subscriber.next(payload);
356
482
  }));
357
483
  // when stream closes, dispose of subscription script load success
358
484
  subscriber.add(
359
485
  // monitor success of loading application script and emit to subscriber
360
- __classPrivateFieldGet(this, _App_state, "f").addEffect('import_app::success', ({ payload }) => {
486
+ this.#state.addEffect('import_app::success', ({ payload }) => {
361
487
  subscriber.next(payload);
362
488
  // application module loaded, complete the stream
363
489
  subscriber.complete();
@@ -365,7 +491,7 @@ export class App {
365
491
  // when stream closes, dispose of subscription to script load failure
366
492
  subscriber.add(
367
493
  // monitor failure of loading application script and emit error to subscriber
368
- __classPrivateFieldGet(this, _App_state, "f").addEffect('import_app::failure', ({ payload }) => {
494
+ this.#state.addEffect('import_app::failure', ({ payload }) => {
369
495
  // application module failed to load, emit error and complete the stream
370
496
  subscriber.error(Error('failed to load application modules from script', {
371
497
  cause: payload,
@@ -375,12 +501,11 @@ export class App {
375
501
  subscriber.add(
376
502
  // fetch application latest manifest and request loading of the application script
377
503
  this.getManifest().subscribe((manifest) => {
378
- var _a, _b;
379
- if ((_a = manifest.build) === null || _a === void 0 ? void 0 : _a.entryPoint) {
504
+ if (manifest.build?.entryPoint) {
380
505
  // TODO - this should come from backend
381
- const assetPath = (_b = manifest.build.assetPath) !== null && _b !== void 0 ? _b : [manifest.appKey, manifest.build.version].join('@');
506
+ const assetPath = manifest.build.assetPath ?? [manifest.appKey, manifest.build.version].join('@');
382
507
  // dispatch import_app action to load the application script
383
- __classPrivateFieldGet(this, _App_state, "f").next(actions.importApp([assetPath, manifest.build.entryPoint].join('/')));
508
+ this.#state.next(actions.importApp([assetPath, manifest.build.entryPoint].join('/')));
384
509
  }
385
510
  else {
386
511
  console.error(`The ${manifest.appKey} app is missing a entry in the manifest, upload a build for your app before continuing`);
@@ -393,153 +518,7 @@ export class App {
393
518
  const operator = allow_cache ? firstValueFrom : lastValueFrom;
394
519
  return operator(this.getAppModule(!allow_cache));
395
520
  }
521
+ dispose;
396
522
  }
397
- _App_state = new WeakMap(), _App_instances = new WeakSet(), _App_registerEvents = function _App_registerEvents(event) {
398
- const { appKey } = this;
399
- // monitor when application manifest is loading
400
- __classPrivateFieldGet(this, _App_state, "f").addEffect(actions.fetchManifest.type, () => {
401
- // dispatch event to notify listeners that the application manifest is being loaded
402
- event.dispatchEvent('onAppManifestLoad', {
403
- detail: { appKey },
404
- source: this,
405
- });
406
- });
407
- // monitor when application manifest is loaded
408
- __classPrivateFieldGet(this, _App_state, "f").addEffect(actions.fetchManifest.success.type, (action) => {
409
- // dispatch event to notify listeners that the application manifest has been loaded
410
- event.dispatchEvent('onAppManifestLoaded', {
411
- detail: { appKey, manifest: action.payload },
412
- source: this,
413
- });
414
- });
415
- // monitor when application manifest fails to load
416
- __classPrivateFieldGet(this, _App_state, "f").addEffect(actions.fetchManifest.failure.type, (action) => {
417
- // dispatch event to notify listeners that the application manifest failed to load
418
- event.dispatchEvent('onAppManifestFailure', {
419
- detail: { appKey, error: action.payload },
420
- source: this,
421
- });
422
- });
423
- // monitor when application configuration is loading
424
- __classPrivateFieldGet(this, _App_state, "f").addEffect(actions.fetchConfig.type, () => {
425
- // dispatch event to notify listeners that the application configuration is being loaded
426
- event.dispatchEvent('onAppConfigLoad', {
427
- detail: { appKey },
428
- source: this,
429
- });
430
- });
431
- // monitor when application configuration is loaded
432
- __classPrivateFieldGet(this, _App_state, "f").addEffect(actions.fetchConfig.success.type, (action) => {
433
- // dispatch event to notify listeners that the application configuration has been loaded
434
- event.dispatchEvent('onAppConfigLoaded', {
435
- detail: { appKey, config: action.payload },
436
- source: this,
437
- });
438
- });
439
- // monitor when application configuration fails to load
440
- __classPrivateFieldGet(this, _App_state, "f").addEffect(actions.fetchConfig.failure.type, (action) => {
441
- // dispatch event to notify listeners that the application configuration failed to load
442
- event.dispatchEvent('onAppConfigFailure', {
443
- detail: { appKey, error: action.payload },
444
- source: this,
445
- });
446
- });
447
- // monitor when application settings is loading
448
- __classPrivateFieldGet(this, _App_state, "f").addEffect(actions.fetchSettings.type, () => {
449
- // dispatch event to notify listeners that the application settings is being loaded
450
- event.dispatchEvent('onAppSettingsLoad', {
451
- detail: { appKey },
452
- source: this,
453
- });
454
- });
455
- // monitor when application settings is loaded
456
- __classPrivateFieldGet(this, _App_state, "f").addEffect(actions.fetchSettings.success.type, (action) => {
457
- // dispatch event to notify listeners that the application settings has been loaded
458
- event.dispatchEvent('onAppSettingsLoaded', {
459
- detail: { appKey, settings: action.payload },
460
- source: this,
461
- });
462
- });
463
- // monitor when application settings fails to load
464
- __classPrivateFieldGet(this, _App_state, "f").addEffect(actions.fetchSettings.failure.type, (action) => {
465
- // dispatch event to notify listeners that the application settings failed to load
466
- event.dispatchEvent('onAppSettingsFailure', {
467
- detail: { appKey, error: action.payload },
468
- source: this,
469
- });
470
- });
471
- // monitor when application settings is updated
472
- __classPrivateFieldGet(this, _App_state, "f").addEffect(actions.updateSettings.type, (action) => {
473
- // dispatch event to notify listeners that the application settings has been loaded
474
- event.dispatchEvent('onAppSettingsUpdate', {
475
- detail: { appKey, settings: action.payload.settings },
476
- source: this,
477
- });
478
- });
479
- // monitor when application settings is updated
480
- __classPrivateFieldGet(this, _App_state, "f").addEffect(actions.updateSettings.success.type, (action) => {
481
- // dispatch event to notify listeners that the application settings has been loaded
482
- event.dispatchEvent('onAppSettingsUpdated', {
483
- detail: { appKey, settings: action.payload.settings },
484
- source: this,
485
- });
486
- });
487
- // monitor when application settings fails to updated
488
- __classPrivateFieldGet(this, _App_state, "f").addEffect(actions.updateSettings.failure.type, (action) => {
489
- // dispatch event to notify listeners that the application settings has been loaded
490
- event.dispatchEvent('onAppSettingsUpdateFailure', {
491
- detail: { appKey, settings: action.payload },
492
- source: this,
493
- });
494
- });
495
- // monitor when application script is loading
496
- __classPrivateFieldGet(this, _App_state, "f").addEffect(actions.importApp.type, () => {
497
- // dispatch event to notify listeners that the application script is being loaded
498
- event.dispatchEvent('onAppScriptLoad', {
499
- detail: { appKey },
500
- source: this,
501
- });
502
- });
503
- // monitor when application script is loaded
504
- __classPrivateFieldGet(this, _App_state, "f").addEffect(actions.importApp.success.type, (action) => {
505
- // dispatch event to notify listeners that the application script has been loaded
506
- event.dispatchEvent('onAppScriptLoaded', {
507
- detail: { appKey, script: action.payload },
508
- source: this,
509
- });
510
- });
511
- // monitor when application script fails to load
512
- __classPrivateFieldGet(this, _App_state, "f").addEffect(actions.importApp.failure.type, (action) => {
513
- // dispatch event to notify listeners that the application script failed to load
514
- event.dispatchEvent('onAppScriptFailure', {
515
- detail: { appKey, error: action.payload },
516
- source: this,
517
- });
518
- });
519
- // monitor when application is initializing
520
- __classPrivateFieldGet(this, _App_state, "f").addEffect(actions.initialize.type, () => {
521
- // dispatch event to notify listeners that the application is initializing
522
- event.dispatchEvent('onAppInitialize', {
523
- detail: { appKey },
524
- source: this,
525
- });
526
- });
527
- // monitor when application has been initialized
528
- __classPrivateFieldGet(this, _App_state, "f").addEffect(actions.initialize.success.type, () => {
529
- // dispatch event to notify listeners that the application has been initialized
530
- event.dispatchEvent('onAppInitialized', {
531
- detail: { appKey },
532
- source: this,
533
- });
534
- });
535
- // monitor when application fails to initialize
536
- __classPrivateFieldGet(this, _App_state, "f").addEffect(actions.initialize.failure.type, ({ payload }) => {
537
- // dispatch event to notify listeners that the application failed to initialize
538
- event.dispatchEvent('onAppInitializeFailure', {
539
- detail: { appKey, error: payload },
540
- source: this,
541
- });
542
- });
543
- };
544
523
  export default App;
545
524
  //# sourceMappingURL=App.js.map