@elliemae/pui-app-bridge 2.0.0-next.26 → 2.0.0-next.27

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.
Files changed (31) hide show
  1. package/dist/cjs/config/app.js +25 -0
  2. package/dist/cjs/index.js +2 -2
  3. package/dist/cjs/{microAppFactory.js → microfeFactory.js} +88 -40
  4. package/dist/cjs/{microAppHost.js → microfeHost.js} +101 -39
  5. package/dist/esm/config/app.js +25 -0
  6. package/dist/esm/index.js +1 -1
  7. package/dist/esm/{microAppFactory.js → microfeFactory.js} +85 -37
  8. package/dist/esm/{microAppHost.js → microfeHost.js} +98 -36
  9. package/dist/public/frame.html +1 -1
  10. package/dist/public/index.html +1 -1
  11. package/dist/public/js/{emuiAppBridge.20469d6f81dbac45a9e5.js → emuiAppBridge.943ed7f133ada8a33815.js} +2 -2
  12. package/dist/public/js/emuiAppBridge.943ed7f133ada8a33815.js.br +0 -0
  13. package/dist/public/js/{emuiAppBridge.20469d6f81dbac45a9e5.js.gz → emuiAppBridge.943ed7f133ada8a33815.js.gz} +0 -0
  14. package/dist/public/js/emuiAppBridge.943ed7f133ada8a33815.js.map +1 -0
  15. package/dist/types/config/app.d.ts +94 -0
  16. package/dist/types/index.d.ts +4 -3
  17. package/dist/types/microfeFactory.d.ts +87 -0
  18. package/dist/types/microfeHost.d.ts +111 -0
  19. package/dist/types/typings/common.d.ts +26 -0
  20. package/dist/types/typings/guest.d.ts +78 -33
  21. package/dist/types/typings/host.d.ts +72 -46
  22. package/dist/types/window.d.ts +4 -4
  23. package/dist/umd/index.js +1 -1
  24. package/dist/umd/index.js.br +0 -0
  25. package/dist/umd/index.js.gz +0 -0
  26. package/dist/umd/index.js.map +1 -1
  27. package/package.json +1 -1
  28. package/dist/public/js/emuiAppBridge.20469d6f81dbac45a9e5.js.br +0 -0
  29. package/dist/public/js/emuiAppBridge.20469d6f81dbac45a9e5.js.map +0 -1
  30. package/dist/types/microAppFactory.d.ts +0 -22
  31. package/dist/types/microAppHost.d.ts +0 -38
@@ -66,9 +66,34 @@ class CAppConfig {
66
66
  delete data.env;
67
67
  __privateSet(this, _gAppConfig, (0, import_merge.default)(data, activeEnvConfig));
68
68
  });
69
+ /**
70
+ * Get value for the given app config key
71
+ *
72
+ * @param key key to get value for
73
+ * @param defaultValue default value to return if key is not found
74
+ * @returns value for the given key
75
+ */
69
76
  this.get = (key = "", defaultValue = null) => (0, import_clone.default)((0, import_get.default)(__privateGet(this, _gAppConfig), key, defaultValue));
77
+ /**
78
+ * Set value for the given app config key
79
+ *
80
+ * @param key key to set value for
81
+ * @param value value to set
82
+ * @returns app config instance
83
+ */
70
84
  this.set = (key, value) => (0, import_set.default)(__privateGet(this, _gAppConfig), key, value);
85
+ /**
86
+ * Check if the given key exists in app config
87
+ *
88
+ * @param key key to check
89
+ * @returns true if key exists
90
+ */
71
91
  this.has = (key = "") => (0, import_has.default)(__privateGet(this, _gAppConfig), key);
92
+ /**
93
+ * load application configuration from the given asset path
94
+ *
95
+ * @param assetPath url path to load app config from
96
+ */
72
97
  this.load = async (assetPath = "latest/") => {
73
98
  const response = await fetch(
74
99
  `${assetPath.replace(/\/?$/, "/")}app.config.json`
package/dist/cjs/index.js CHANGED
@@ -18,10 +18,10 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var lib_exports = {};
20
20
  __export(lib_exports, {
21
- CMicroAppFactory: () => import_microAppFactory.CMicroAppFactory,
21
+ CMicroAppFactory: () => import_microfeFactory.CMicroAppFactory,
22
22
  Event: () => import_em_ssf_common.Event,
23
23
  ScriptingObject: () => import_em_ssf_common.ScriptingObject
24
24
  });
25
25
  module.exports = __toCommonJS(lib_exports);
26
26
  var import_em_ssf_common = require("@elliemae/em-ssf-common");
27
- var import_microAppFactory = require("./microAppFactory.js");
27
+ var import_microfeFactory = require("./microfeFactory.js");
@@ -34,22 +34,27 @@ var __privateSet = (obj, member, value, setter) => {
34
34
  setter ? setter.call(obj, value) : member.set(obj, value);
35
35
  return value;
36
36
  };
37
- var microAppFactory_exports = {};
38
- __export(microAppFactory_exports, {
37
+ var microfeFactory_exports = {};
38
+ __export(microfeFactory_exports, {
39
39
  CMicroAppFactory: () => CMicroAppFactory
40
40
  });
41
- module.exports = __toCommonJS(microAppFactory_exports);
41
+ module.exports = __toCommonJS(microfeFactory_exports);
42
42
  var import_frame = require("./frame.js");
43
43
  var import_window = require("./window.js");
44
44
  var import_app = require("./config/app.js");
45
45
  var import_microFE = require("./config/microFE.js");
46
46
  var import_loaders = require("./loaders/index.js");
47
- var import_microAppHost = require("./microAppHost.js");
47
+ var import_microfeHost = require("./microfeHost.js");
48
48
  var _logger, _scriptLoader, _styleLoader, _appConfig, _microFEConfig, _host, _activeGuests, _activeApps, _removeAssetsFromDOM, _addAppToActiveAppList, _waitAndInitApplication, _initApplication, _loadApp, _unloadApp, _mountApp, _unmountApp;
49
49
  const APP_CONTAINER_ID_PREFIX = "pui-app-container-";
50
50
  const cssType = /\.css$/;
51
51
  const isCss = (fileName) => cssType.test(fileName);
52
52
  class CMicroAppFactory {
53
+ /**
54
+ * Create a new instance of the MicroAppFactory
55
+ *
56
+ * @param {MicroAppFactoryParams} params - parameter for the constructor
57
+ */
53
58
  constructor(params) {
54
59
  __privateAdd(this, _logger, void 0);
55
60
  __privateAdd(this, _scriptLoader, void 0);
@@ -193,8 +198,52 @@ class CMicroAppFactory {
193
198
  containerId: `${APP_CONTAINER_ID_PREFIX}${id}`
194
199
  });
195
200
  });
196
- this.getGuests = () => Array.from(__privateGet(this, _activeGuests).values());
201
+ /**
202
+ * Close all active guest micro frontend applications
203
+ */
204
+ this.closeAllApps = async () => {
205
+ await Promise.all(Object.keys(__privateGet(this, _activeApps)).map(this.closeApp));
206
+ };
207
+ /**
208
+ * Close guest micro frontend application
209
+ *
210
+ * @param id unique id of guest application
211
+ */
212
+ this.closeApp = async (id) => {
213
+ if (!id)
214
+ throw new Error("id is required");
215
+ const appConfig = __privateGet(this, _microFEConfig).getConfigById(id);
216
+ if (!appConfig) {
217
+ throw new Error(`Application with id ${id} is not found`);
218
+ }
219
+ const { name, hostUrl } = appConfig;
220
+ try {
221
+ await __privateGet(this, _unmountApp).call(this, { id, name });
222
+ } finally {
223
+ const frameEle = import_frame.Frame.get(id);
224
+ if (!frameEle?.contentDocument) {
225
+ throw new Error(`Iframe for application with id ${id} is not found`);
226
+ }
227
+ __privateGet(this, _unloadApp).call(this, { id, hostUrl, documentEle: frameEle.contentDocument });
228
+ import_frame.Frame.remove(id);
229
+ }
230
+ };
231
+ /**
232
+ * Get guest by id
233
+ *
234
+ * @param guestId unique id of guest
235
+ * @returns guest instance
236
+ */
197
237
  this.getGuest = (guestId) => __privateGet(this, _activeGuests).get(guestId);
238
+ /**
239
+ * Get list of active guests
240
+ *
241
+ * @returns list of active guests
242
+ */
243
+ this.getGuests = () => Array.from(__privateGet(this, _activeGuests).values());
244
+ /**
245
+ * Initialize factory
246
+ */
198
247
  this.init = async () => {
199
248
  await __privateGet(this, _appConfig).load();
200
249
  __privateGet(this, _microFEConfig).init({
@@ -202,8 +251,28 @@ class CMicroAppFactory {
202
251
  appConfig: __privateGet(this, _appConfig)
203
252
  });
204
253
  };
205
- this.openApp = async (options) => {
206
- const { id, frameOptions, history, theme } = options;
254
+ /**
255
+ * Mount guest micro frontend application into DOM
256
+ *
257
+ * @param id unique id of guest micro frontend application
258
+ * @throws Error if application with given id is not found in configuration
259
+ */
260
+ this.mountApp = async (id) => {
261
+ if (!id)
262
+ throw new Error("id is required");
263
+ const appConfig = __privateGet(this, _microFEConfig).getConfigById(id);
264
+ if (!appConfig) {
265
+ throw new Error(`Application with id ${id} is not found`);
266
+ }
267
+ await __privateGet(this, _mountApp).call(this, appConfig);
268
+ };
269
+ /**
270
+ * Open guest micro frontend application
271
+ *
272
+ * @param {OpenAppParams} params - options to open guest application
273
+ */
274
+ this.openApp = async (params) => {
275
+ const { id, frameOptions, history, theme } = params;
207
276
  const appConfig = __privateGet(this, _microFEConfig).getConfigById(id);
208
277
  if (!appConfig) {
209
278
  throw new Error(`Application with id ${id} is not found`);
@@ -234,34 +303,12 @@ class CMicroAppFactory {
234
303
  throw err;
235
304
  }
236
305
  };
237
- this.closeApp = async (id) => {
238
- if (!id)
239
- throw new Error("id is required");
240
- const appConfig = __privateGet(this, _microFEConfig).getConfigById(id);
241
- if (!appConfig) {
242
- throw new Error(`Application with id ${id} is not found`);
243
- }
244
- const { name, hostUrl } = appConfig;
245
- try {
246
- await __privateGet(this, _unmountApp).call(this, { id, name });
247
- } finally {
248
- const frameEle = import_frame.Frame.get(id);
249
- if (!frameEle?.contentDocument) {
250
- throw new Error(`Iframe for application with id ${id} is not found`);
251
- }
252
- __privateGet(this, _unloadApp).call(this, { id, hostUrl, documentEle: frameEle.contentDocument });
253
- import_frame.Frame.remove(id);
254
- }
255
- };
256
- this.mountApp = async (id) => {
257
- if (!id)
258
- throw new Error("id is required");
259
- const appConfig = __privateGet(this, _microFEConfig).getConfigById(id);
260
- if (!appConfig) {
261
- throw new Error(`Application with id ${id} is not found`);
262
- }
263
- await __privateGet(this, _mountApp).call(this, appConfig);
264
- };
306
+ /**
307
+ * Unmount guest micro frontend application from DOM
308
+ *
309
+ * @param id unique id of guest micro frontend application
310
+ * @throws Error if application with given id is not found in configuration
311
+ */
265
312
  this.unmountApp = async (id) => {
266
313
  if (!id)
267
314
  throw new Error("id is required");
@@ -271,18 +318,19 @@ class CMicroAppFactory {
271
318
  }
272
319
  await __privateGet(this, _unmountApp).call(this, appConfig);
273
320
  };
274
- this.closeAllApps = async () => {
275
- await Promise.all(Object.keys(__privateGet(this, _activeApps)).map(this.closeApp));
276
- };
277
321
  const { logger } = params;
278
322
  if (!logger)
279
323
  throw new Error("logger is required");
280
324
  __privateSet(this, _logger, params.logger);
281
325
  __privateSet(this, _scriptLoader, new import_loaders.ScriptLoader(logger));
282
326
  __privateSet(this, _styleLoader, new import_loaders.StyleLoader(logger));
283
- __privateSet(this, _host, new import_microAppHost.CMicroAppHost(params));
327
+ __privateSet(this, _host, new import_microfeHost.CMicroFEHost(params));
284
328
  }
285
- // public api
329
+ /**
330
+ * Get instance of host
331
+ *
332
+ * @returns instance of host
333
+ */
286
334
  get host() {
287
335
  return __privateGet(this, _host);
288
336
  }
@@ -34,38 +34,40 @@ var __privateSet = (obj, member, value, setter) => {
34
34
  setter ? setter.call(obj, value) : member.set(obj, value);
35
35
  return value;
36
36
  };
37
- var microAppHost_exports = {};
38
- __export(microAppHost_exports, {
39
- CMicroAppHost: () => CMicroAppHost
37
+ var microfeHost_exports = {};
38
+ __export(microfeHost_exports, {
39
+ CMicroFEHost: () => CMicroFEHost
40
40
  });
41
- module.exports = __toCommonJS(microAppHost_exports);
41
+ module.exports = __toCommonJS(microfeHost_exports);
42
42
  var import_pubsub_js = require("pubsub-js");
43
43
  var import_em_ssf_common = require("@elliemae/em-ssf-common");
44
44
  var import_frame = require("./frame.js");
45
45
  var import_constant = require("./constant.js");
46
46
  var _logger, _version, _eventManager, _scriptingObjects;
47
- class CMicroAppHost {
47
+ class CMicroFEHost {
48
+ /**
49
+ * Create new instance of the host frontend application
50
+ *
51
+ * @param {CMicroFEHostParams} params - constructor parameters
52
+ */
48
53
  constructor(params) {
49
54
  __privateAdd(this, _logger, void 0);
50
55
  __privateAdd(this, _version, void 0);
51
56
  __privateAdd(this, _eventManager, void 0);
52
57
  __privateAdd(this, _scriptingObjects, /* @__PURE__ */ new Map());
53
- this.setAppWindowSize = (appSize) => {
54
- const { appId, size } = appSize;
55
- const frameEle = document.getElementById(
56
- `${import_frame.FRAME_CONTAINER_ID_PREFIX}${appId}`
57
- );
58
- if (frameEle) {
59
- frameEle.style.height = `${size.height}px`;
60
- }
61
- };
62
- // Scripting Object methods
63
- this.getObject = (objectId) => {
64
- const id = objectId.toLowerCase();
65
- const data = __privateGet(this, _scriptingObjects).get(id);
66
- return Promise.resolve(data || null);
67
- };
68
- this.registerScriptingObject = (so) => {
58
+ /**
59
+ * add listener to the scripting object event
60
+ *
61
+ * @param {AddEventListenerParams<EventId, EventType>} params - parameters to add event listener
62
+ * @returns subscription id
63
+ */
64
+ this.addEventListener = (params) => __privateGet(this, _eventManager).subscribe(params);
65
+ /**
66
+ * registers scripting object to the host
67
+ *
68
+ * @param so scripting object to publish
69
+ */
70
+ this.addScriptingObject = (so) => {
69
71
  if (!so?.id || !so?._toJSON) {
70
72
  throw new Error("Object is not derived from ScriptingObject");
71
73
  }
@@ -78,31 +80,86 @@ class CMicroAppHost {
78
80
  throw new Error(`Scripting Object ${so.id} already exists`);
79
81
  __privateGet(this, _scriptingObjects).set(objectId, so);
80
82
  };
81
- this.unregisterScriptingObject = (objectId) => {
83
+ /**
84
+ * dispatch event to guest microfrontend application
85
+ *
86
+ * @param {DispatchEventParams<EventId, Params>} params - event parameters
87
+ */
88
+ this.dispatchEvent = async (params) => __privateGet(this, _eventManager).dispatchEvent(params);
89
+ /**
90
+ * Get reference to the scripting object (or proxy) by name
91
+ *
92
+ * @param name unique name of the scripting object
93
+ * @param objectId
94
+ * @returns scripting object reference
95
+ */
96
+ this.getObject = (objectId) => {
97
+ const id = objectId.toLowerCase();
98
+ const data = __privateGet(this, _scriptingObjects).get(id);
99
+ return Promise.resolve(data || null);
100
+ };
101
+ /**
102
+ * removes listener from the scripting object event
103
+ *
104
+ * @param {RemoveEventListenerParams<EventId>} params - parameters to remove event listener
105
+ */
106
+ this.removeEventListener = (params) => {
107
+ __privateGet(this, _eventManager).unsubscribe(params);
108
+ };
109
+ /**
110
+ * remove all listeners
111
+ */
112
+ this.removeAllEventListeners = () => {
113
+ __privateGet(this, _eventManager).unsubscribeAll();
114
+ };
115
+ /**
116
+ * removes scripting object from the host
117
+ *
118
+ * @param objectId unique id of the scripting object
119
+ */
120
+ this.removeScriptingObject = (objectId) => {
82
121
  __privateGet(this, _scriptingObjects).delete(
83
122
  objectId.toLowerCase()
84
123
  );
85
124
  };
86
- this.dispatchEvent = async ({
87
- event: { id, name, requiresFeedback, scriptingObject },
88
- eventParams
89
- }) => __privateGet(this, _eventManager).dispatchEvent({
90
- event: { id, name, requiresFeedback, scriptingObject },
91
- eventParams
92
- });
93
- this.addEventListener = ({
94
- eventId,
95
- listener
96
- }) => __privateGet(this, _eventManager).subscribe({ eventId, listener });
97
- this.removeEventListener = ({
98
- eventId,
99
- subscriptionId
100
- }) => __privateGet(this, _eventManager).unsubscribe({ eventId, subscriptionId });
101
- this.removeAllEventListeners = () => __privateGet(this, _eventManager).unsubscribeAll();
102
- // deprecated methods
125
+ /**
126
+ * set the size of the guest application iframe window
127
+ *
128
+ * @param {AppWindowSize} appSize window size of the application
129
+ */
130
+ this.setAppWindowSize = (appSize) => {
131
+ const { appId, size } = appSize;
132
+ const frameEle = document.getElementById(
133
+ `${import_frame.FRAME_CONTAINER_ID_PREFIX}${appId}`
134
+ );
135
+ if (frameEle) {
136
+ frameEle.style.height = `${size.height}px`;
137
+ }
138
+ };
139
+ // deprecated legacy eventing methods (to be removed)
140
+ /**
141
+ * emit event to all subscribers (deprecated)
142
+ *
143
+ * @param eventId unique id of the event. The format is <scripting object name>.<event name>
144
+ * @param data data to be sent to the subscribers of the event
145
+ * @returns true if event is published successfully
146
+ */
103
147
  this.publish = (eventId, data) => (0, import_pubsub_js.publish)(eventId, data);
148
+ /**
149
+ * subscribe to an scripting object event (deprecated)
150
+ *
151
+ * @param eventId unique id of the event. The format is <scripting object name>.<event name>
152
+ * @param listener callback function to be called when the event is fired
153
+ * @returns token to be used to unsubscribe
154
+ */
104
155
  // eslint-disable-next-line @typescript-eslint/ban-types
105
156
  this.subscribe = (eventId, listener) => (0, import_pubsub_js.subscribe)(eventId, listener);
157
+ /**
158
+ * unsubscribe from an scripting object event (deprecated)
159
+ *
160
+ * @param token unique token returned by subscribe
161
+ * @param eventId unique id of the event. The format is <scripting object name>.<event name>
162
+ */
106
163
  this.unsubscribe = (token) => {
107
164
  (0, import_pubsub_js.unsubscribe)(token);
108
165
  };
@@ -110,6 +167,11 @@ class CMicroAppHost {
110
167
  __privateSet(this, _version, params?.version || import_constant.LATEST_VERSION);
111
168
  __privateSet(this, _eventManager, new import_em_ssf_common.EventManager());
112
169
  }
170
+ /**
171
+ * application release version
172
+ *
173
+ * @returns release version
174
+ */
113
175
  get version() {
114
176
  return __privateGet(this, _version);
115
177
  }
@@ -33,9 +33,34 @@ class CAppConfig {
33
33
  delete data.env;
34
34
  __privateSet(this, _gAppConfig, lodashMerge(data, activeEnvConfig));
35
35
  });
36
+ /**
37
+ * Get value for the given app config key
38
+ *
39
+ * @param key key to get value for
40
+ * @param defaultValue default value to return if key is not found
41
+ * @returns value for the given key
42
+ */
36
43
  this.get = (key = "", defaultValue = null) => lodashClone(lodashGet(__privateGet(this, _gAppConfig), key, defaultValue));
44
+ /**
45
+ * Set value for the given app config key
46
+ *
47
+ * @param key key to set value for
48
+ * @param value value to set
49
+ * @returns app config instance
50
+ */
37
51
  this.set = (key, value) => lodashSet(__privateGet(this, _gAppConfig), key, value);
52
+ /**
53
+ * Check if the given key exists in app config
54
+ *
55
+ * @param key key to check
56
+ * @returns true if key exists
57
+ */
38
58
  this.has = (key = "") => lodashHas(__privateGet(this, _gAppConfig), key);
59
+ /**
60
+ * load application configuration from the given asset path
61
+ *
62
+ * @param assetPath url path to load app config from
63
+ */
39
64
  this.load = async (assetPath = "latest/") => {
40
65
  const response = await fetch(
41
66
  `${assetPath.replace(/\/?$/, "/")}app.config.json`
package/dist/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Event, ScriptingObject } from "@elliemae/em-ssf-common";
2
- import { CMicroAppFactory } from "./microAppFactory.js";
2
+ import { CMicroAppFactory } from "./microfeFactory.js";
3
3
  export {
4
4
  CMicroAppFactory,
5
5
  Event,
@@ -22,11 +22,16 @@ import { getCurrentBreakpoint, getViewportSize } from "./window.js";
22
22
  import { CAppConfig } from "./config/app.js";
23
23
  import { CMicroFEConfig } from "./config/microFE.js";
24
24
  import { StyleLoader, ScriptLoader, ManifestLoader } from "./loaders/index.js";
25
- import { CMicroAppHost } from "./microAppHost.js";
25
+ import { CMicroFEHost } from "./microfeHost.js";
26
26
  const APP_CONTAINER_ID_PREFIX = "pui-app-container-";
27
27
  const cssType = /\.css$/;
28
28
  const isCss = (fileName) => cssType.test(fileName);
29
29
  class CMicroAppFactory {
30
+ /**
31
+ * Create a new instance of the MicroAppFactory
32
+ *
33
+ * @param {MicroAppFactoryParams} params - parameter for the constructor
34
+ */
30
35
  constructor(params) {
31
36
  __privateAdd(this, _logger, void 0);
32
37
  __privateAdd(this, _scriptLoader, void 0);
@@ -170,8 +175,52 @@ class CMicroAppFactory {
170
175
  containerId: `${APP_CONTAINER_ID_PREFIX}${id}`
171
176
  });
172
177
  });
173
- this.getGuests = () => Array.from(__privateGet(this, _activeGuests).values());
178
+ /**
179
+ * Close all active guest micro frontend applications
180
+ */
181
+ this.closeAllApps = async () => {
182
+ await Promise.all(Object.keys(__privateGet(this, _activeApps)).map(this.closeApp));
183
+ };
184
+ /**
185
+ * Close guest micro frontend application
186
+ *
187
+ * @param id unique id of guest application
188
+ */
189
+ this.closeApp = async (id) => {
190
+ if (!id)
191
+ throw new Error("id is required");
192
+ const appConfig = __privateGet(this, _microFEConfig).getConfigById(id);
193
+ if (!appConfig) {
194
+ throw new Error(`Application with id ${id} is not found`);
195
+ }
196
+ const { name, hostUrl } = appConfig;
197
+ try {
198
+ await __privateGet(this, _unmountApp).call(this, { id, name });
199
+ } finally {
200
+ const frameEle = Frame.get(id);
201
+ if (!frameEle?.contentDocument) {
202
+ throw new Error(`Iframe for application with id ${id} is not found`);
203
+ }
204
+ __privateGet(this, _unloadApp).call(this, { id, hostUrl, documentEle: frameEle.contentDocument });
205
+ Frame.remove(id);
206
+ }
207
+ };
208
+ /**
209
+ * Get guest by id
210
+ *
211
+ * @param guestId unique id of guest
212
+ * @returns guest instance
213
+ */
174
214
  this.getGuest = (guestId) => __privateGet(this, _activeGuests).get(guestId);
215
+ /**
216
+ * Get list of active guests
217
+ *
218
+ * @returns list of active guests
219
+ */
220
+ this.getGuests = () => Array.from(__privateGet(this, _activeGuests).values());
221
+ /**
222
+ * Initialize factory
223
+ */
175
224
  this.init = async () => {
176
225
  await __privateGet(this, _appConfig).load();
177
226
  __privateGet(this, _microFEConfig).init({
@@ -179,8 +228,28 @@ class CMicroAppFactory {
179
228
  appConfig: __privateGet(this, _appConfig)
180
229
  });
181
230
  };
182
- this.openApp = async (options) => {
183
- const { id, frameOptions, history, theme } = options;
231
+ /**
232
+ * Mount guest micro frontend application into DOM
233
+ *
234
+ * @param id unique id of guest micro frontend application
235
+ * @throws Error if application with given id is not found in configuration
236
+ */
237
+ this.mountApp = async (id) => {
238
+ if (!id)
239
+ throw new Error("id is required");
240
+ const appConfig = __privateGet(this, _microFEConfig).getConfigById(id);
241
+ if (!appConfig) {
242
+ throw new Error(`Application with id ${id} is not found`);
243
+ }
244
+ await __privateGet(this, _mountApp).call(this, appConfig);
245
+ };
246
+ /**
247
+ * Open guest micro frontend application
248
+ *
249
+ * @param {OpenAppParams} params - options to open guest application
250
+ */
251
+ this.openApp = async (params) => {
252
+ const { id, frameOptions, history, theme } = params;
184
253
  const appConfig = __privateGet(this, _microFEConfig).getConfigById(id);
185
254
  if (!appConfig) {
186
255
  throw new Error(`Application with id ${id} is not found`);
@@ -211,34 +280,12 @@ class CMicroAppFactory {
211
280
  throw err;
212
281
  }
213
282
  };
214
- this.closeApp = async (id) => {
215
- if (!id)
216
- throw new Error("id is required");
217
- const appConfig = __privateGet(this, _microFEConfig).getConfigById(id);
218
- if (!appConfig) {
219
- throw new Error(`Application with id ${id} is not found`);
220
- }
221
- const { name, hostUrl } = appConfig;
222
- try {
223
- await __privateGet(this, _unmountApp).call(this, { id, name });
224
- } finally {
225
- const frameEle = Frame.get(id);
226
- if (!frameEle?.contentDocument) {
227
- throw new Error(`Iframe for application with id ${id} is not found`);
228
- }
229
- __privateGet(this, _unloadApp).call(this, { id, hostUrl, documentEle: frameEle.contentDocument });
230
- Frame.remove(id);
231
- }
232
- };
233
- this.mountApp = async (id) => {
234
- if (!id)
235
- throw new Error("id is required");
236
- const appConfig = __privateGet(this, _microFEConfig).getConfigById(id);
237
- if (!appConfig) {
238
- throw new Error(`Application with id ${id} is not found`);
239
- }
240
- await __privateGet(this, _mountApp).call(this, appConfig);
241
- };
283
+ /**
284
+ * Unmount guest micro frontend application from DOM
285
+ *
286
+ * @param id unique id of guest micro frontend application
287
+ * @throws Error if application with given id is not found in configuration
288
+ */
242
289
  this.unmountApp = async (id) => {
243
290
  if (!id)
244
291
  throw new Error("id is required");
@@ -248,18 +295,19 @@ class CMicroAppFactory {
248
295
  }
249
296
  await __privateGet(this, _unmountApp).call(this, appConfig);
250
297
  };
251
- this.closeAllApps = async () => {
252
- await Promise.all(Object.keys(__privateGet(this, _activeApps)).map(this.closeApp));
253
- };
254
298
  const { logger } = params;
255
299
  if (!logger)
256
300
  throw new Error("logger is required");
257
301
  __privateSet(this, _logger, params.logger);
258
302
  __privateSet(this, _scriptLoader, new ScriptLoader(logger));
259
303
  __privateSet(this, _styleLoader, new StyleLoader(logger));
260
- __privateSet(this, _host, new CMicroAppHost(params));
304
+ __privateSet(this, _host, new CMicroFEHost(params));
261
305
  }
262
- // public api
306
+ /**
307
+ * Get instance of host
308
+ *
309
+ * @returns instance of host
310
+ */
263
311
  get host() {
264
312
  return __privateGet(this, _host);
265
313
  }