@elliemae/pui-app-sdk 5.40.0-beta.2 → 5.40.0-beta.4

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 (45) hide show
  1. package/demo/{4018.2e1aaff7.iframe.bundle.js → 4018.1c57a40f.iframe.bundle.js} +1 -1
  2. package/demo/4018.1c57a40f.iframe.bundle.js.br +0 -0
  3. package/demo/{4018.2e1aaff7.iframe.bundle.js.gz → 4018.1c57a40f.iframe.bundle.js.gz} +0 -0
  4. package/demo/docs/{4018.2e1aaff7.iframe.bundle.js → 4018.1c57a40f.iframe.bundle.js} +1 -1
  5. package/demo/docs/4018.1c57a40f.iframe.bundle.js.br +0 -0
  6. package/demo/docs/{4018.2e1aaff7.iframe.bundle.js.gz → 4018.1c57a40f.iframe.bundle.js.gz} +0 -0
  7. package/demo/docs/iframe.html +1 -1
  8. package/demo/docs/index.html +1 -1
  9. package/demo/docs/main.68f8e581.iframe.bundle.js +5 -0
  10. package/demo/docs/main.68f8e581.iframe.bundle.js.br +0 -0
  11. package/demo/docs/main.68f8e581.iframe.bundle.js.gz +0 -0
  12. package/demo/docs/{main.81dbbc1cf5969ea75037.manager.bundle.js → main.6e37f80888d31e1b17bb.manager.bundle.js} +1 -1
  13. package/demo/docs/{main.81dbbc1cf5969ea75037.manager.bundle.js.br → main.6e37f80888d31e1b17bb.manager.bundle.js.br} +0 -0
  14. package/demo/docs/{main.81dbbc1cf5969ea75037.manager.bundle.js.gz → main.6e37f80888d31e1b17bb.manager.bundle.js.gz} +0 -0
  15. package/demo/docs/project.json +1 -1
  16. package/demo/iframe.html +1 -1
  17. package/demo/index.html +1 -1
  18. package/demo/main.68f8e581.iframe.bundle.js +5 -0
  19. package/demo/main.68f8e581.iframe.bundle.js.br +0 -0
  20. package/demo/main.68f8e581.iframe.bundle.js.gz +0 -0
  21. package/demo/{main.81dbbc1cf5969ea75037.manager.bundle.js → main.6e37f80888d31e1b17bb.manager.bundle.js} +1 -1
  22. package/demo/{main.81dbbc1cf5969ea75037.manager.bundle.js.br → main.6e37f80888d31e1b17bb.manager.bundle.js.br} +0 -0
  23. package/demo/{main.81dbbc1cf5969ea75037.manager.bundle.js.gz → main.6e37f80888d31e1b17bb.manager.bundle.js.gz} +0 -0
  24. package/demo/project.json +1 -1
  25. package/dist/cjs/utils/micro-frontend/guest.js +5 -2
  26. package/dist/cjs/utils/micro-frontend/host.js +30 -10
  27. package/dist/cjs/utils/micro-frontend/module-so.js +6 -10
  28. package/dist/esm/index.js +3 -1
  29. package/dist/esm/utils/micro-frontend/guest.js +5 -2
  30. package/dist/esm/utils/micro-frontend/host.js +30 -10
  31. package/dist/esm/utils/micro-frontend/module-so.js +6 -10
  32. package/dist/types/lib/index.d.ts +2 -1
  33. package/dist/types/lib/utils/micro-frontend/guest.d.ts +5 -2
  34. package/dist/types/lib/utils/micro-frontend/host.d.ts +20 -3
  35. package/dist/types/lib/utils/micro-frontend/module-so.d.ts +9 -5
  36. package/dist/types/tsconfig.tsbuildinfo +1 -1
  37. package/package.json +1 -1
  38. package/demo/4018.2e1aaff7.iframe.bundle.js.br +0 -0
  39. package/demo/docs/4018.2e1aaff7.iframe.bundle.js.br +0 -0
  40. package/demo/docs/main.b0d74522.iframe.bundle.js +0 -5
  41. package/demo/docs/main.b0d74522.iframe.bundle.js.br +0 -0
  42. package/demo/docs/main.b0d74522.iframe.bundle.js.gz +0 -0
  43. package/demo/main.b0d74522.iframe.bundle.js +0 -5
  44. package/demo/main.b0d74522.iframe.bundle.js.br +0 -0
  45. package/demo/main.b0d74522.iframe.bundle.js.gz +0 -0
@@ -445,9 +445,12 @@ class CMicroAppGuest {
445
445
  if (url) this.props.history.push(url, state);
446
446
  }
447
447
  /**
448
- * add scripting object for child microapp to use
448
+ * Register a scripting object for child micro-apps to use.
449
+ * Adds the object to both the App Bridge and the SSF Host so guests
450
+ * using either transport can discover it. Always prefer this method
451
+ * over calling appBridge.addScriptingObject() directly.
449
452
  * @param so - The scripting object to be added.
450
- * @param params - Optional parameters for adding the scripting object.
453
+ * @param params - Optional parameters (e.g. `{ guestId }` to scope to a specific guest).
451
454
  */
452
455
  addScriptingObject(so, params) {
453
456
  if (this.#appBridge) {
@@ -51,6 +51,7 @@ class CMicroAppHost {
51
51
  scriptingObjects;
52
52
  #ssfHostRef;
53
53
  #appBridge = null;
54
+ #selfInitialize;
54
55
  // eslint-disable-next-line max-statements
55
56
  constructor(params) {
56
57
  this.appId = (0, import_config.getAppConfigValue)("appId");
@@ -58,6 +59,7 @@ class CMicroAppHost {
58
59
  this.logger = params?.logger || import_console_logger.consoleLogger;
59
60
  (0, import_logger.setLogger)(this.logger);
60
61
  this.onRenewSessionTimer = params?.onRenewSessionTimer;
62
+ this.#selfInitialize = params?.selfInitialize ?? false;
61
63
  this.props = {
62
64
  systemVersion: params?.version ?? "latest",
63
65
  history: params?.history ?? import_history2.browserHistory,
@@ -89,15 +91,17 @@ class CMicroAppHost {
89
91
  leading: true
90
92
  }
91
93
  );
92
- (0, import_app_config.loadAppConfig)().then(() => {
93
- (0, import_app_bridge.getAppBridge)().then((appBridge) => {
94
- this.#appBridge = appBridge;
95
- if (this.onInit) this.onInit(this.props);
96
- }).catch((ex) => {
97
- throw ex;
94
+ if (!this.#selfInitialize) {
95
+ (0, import_app_config.loadAppConfig)().then(() => {
96
+ (0, import_app_bridge.getAppBridge)().then((appBridge) => {
97
+ this.#appBridge = appBridge;
98
+ if (this.onInit) this.onInit(this.props);
99
+ }).catch((ex) => {
100
+ throw ex;
101
+ });
102
+ }).catch(() => {
98
103
  });
99
- }).catch(() => {
100
- });
104
+ }
101
105
  (0, import_pui_analytics_so.updateBAEventParameters)({ appId: this.appId });
102
106
  }
103
107
  static getInstance(params) {
@@ -109,6 +113,19 @@ class CMicroAppHost {
109
113
  static isInitialized() {
110
114
  return !!this.instance;
111
115
  }
116
+ /**
117
+ * Host-initiated lifecycle: loads app config, initializes the app bridge,
118
+ * and calls the onInit callback. Call this instead of relying on the
119
+ * automatic constructor chain when `selfInitialize: true`.
120
+ * @returns host options (systemVersion, history, theme)
121
+ */
122
+ async initialize() {
123
+ await (0, import_app_config.loadAppConfig)();
124
+ const appBridge = await (0, import_app_bridge.getAppBridge)();
125
+ this.#appBridge = appBridge;
126
+ if (this.onInit) this.onInit(this.props);
127
+ return this.props;
128
+ }
112
129
  getProps() {
113
130
  return this.props;
114
131
  }
@@ -197,9 +214,12 @@ class CMicroAppHost {
197
214
  return this.scriptingObjects[name];
198
215
  }
199
216
  /**
200
- * add scripting object for child microapp to use
217
+ * Register a scripting object for child micro-apps to use.
218
+ * Adds the object to both the App Bridge and the SSF Host so guests
219
+ * using either transport can discover it. Always prefer this method
220
+ * over calling appBridge.addScriptingObject() directly.
201
221
  * @param so - The scripting object to be added.
202
- * @param params - Optional parameters for adding the scripting object.
222
+ * @param params - Optional parameters (e.g. `{ guestId }` to scope to a specific guest).
203
223
  */
204
224
  addScriptingObject(so, params) {
205
225
  if (this.#appBridge) {
@@ -65,13 +65,9 @@ class GuestModule extends import_ssf_host.ScriptingObject {
65
65
  _setUnloadHandler(handler) {
66
66
  this.#onUnload = handler;
67
67
  }
68
- getParameters() {
69
- return Promise.resolve(this.#params);
70
- }
71
- getCapabilities() {
72
- return Promise.resolve({});
73
- }
74
- log(message, logLevel) {
68
+ getParameters = () => Promise.resolve(this.#params);
69
+ getCapabilities = () => Promise.resolve({});
70
+ log = (message, logLevel) => {
75
71
  const logger = window.emui?.logger;
76
72
  if (!logger) return Promise.resolve();
77
73
  const text = typeof message === "string" ? message : message.message;
@@ -79,11 +75,11 @@ class GuestModule extends import_ssf_host.ScriptingObject {
79
75
  const logFn = logger[method];
80
76
  if (logFn) logFn(text);
81
77
  return Promise.resolve();
82
- }
83
- unload() {
78
+ };
79
+ unload = () => {
84
80
  if (this.#onUnload) return this.#onUnload();
85
81
  return Promise.resolve();
86
- }
82
+ };
87
83
  }
88
84
  const createGuestModule = (guestId, params = {}, overrides = {}) => {
89
85
  const mod = new GuestModule(guestId, params);
package/dist/esm/index.js CHANGED
@@ -64,7 +64,9 @@ import {
64
64
  CMicroAppGuest,
65
65
  CMicroAppGuest as CMicroAppGuest2
66
66
  } from "./utils/micro-frontend/guest.js";
67
- import { CMicroAppHost } from "./utils/micro-frontend/host.js";
67
+ import {
68
+ CMicroAppHost
69
+ } from "./utils/micro-frontend/host.js";
68
70
  import {
69
71
  buildModuleParams,
70
72
  createGuestModule,
@@ -412,9 +412,12 @@ class CMicroAppGuest {
412
412
  if (url) this.props.history.push(url, state);
413
413
  }
414
414
  /**
415
- * add scripting object for child microapp to use
415
+ * Register a scripting object for child micro-apps to use.
416
+ * Adds the object to both the App Bridge and the SSF Host so guests
417
+ * using either transport can discover it. Always prefer this method
418
+ * over calling appBridge.addScriptingObject() directly.
416
419
  * @param so - The scripting object to be added.
417
- * @param params - Optional parameters for adding the scripting object.
420
+ * @param params - Optional parameters (e.g. `{ guestId }` to scope to a specific guest).
418
421
  */
419
422
  addScriptingObject(so, params) {
420
423
  if (this.#appBridge) {
@@ -36,6 +36,7 @@ class CMicroAppHost {
36
36
  scriptingObjects;
37
37
  #ssfHostRef;
38
38
  #appBridge = null;
39
+ #selfInitialize;
39
40
  // eslint-disable-next-line max-statements
40
41
  constructor(params) {
41
42
  this.appId = getAppConfigValue("appId");
@@ -43,6 +44,7 @@ class CMicroAppHost {
43
44
  this.logger = params?.logger || consoleLogger;
44
45
  setLogger(this.logger);
45
46
  this.onRenewSessionTimer = params?.onRenewSessionTimer;
47
+ this.#selfInitialize = params?.selfInitialize ?? false;
46
48
  this.props = {
47
49
  systemVersion: params?.version ?? "latest",
48
50
  history: params?.history ?? browserHistory,
@@ -74,15 +76,17 @@ class CMicroAppHost {
74
76
  leading: true
75
77
  }
76
78
  );
77
- loadAppConfig().then(() => {
78
- getAppBridge().then((appBridge) => {
79
- this.#appBridge = appBridge;
80
- if (this.onInit) this.onInit(this.props);
81
- }).catch((ex) => {
82
- throw ex;
79
+ if (!this.#selfInitialize) {
80
+ loadAppConfig().then(() => {
81
+ getAppBridge().then((appBridge) => {
82
+ this.#appBridge = appBridge;
83
+ if (this.onInit) this.onInit(this.props);
84
+ }).catch((ex) => {
85
+ throw ex;
86
+ });
87
+ }).catch(() => {
83
88
  });
84
- }).catch(() => {
85
- });
89
+ }
86
90
  updateBAEventParameters({ appId: this.appId });
87
91
  }
88
92
  static getInstance(params) {
@@ -94,6 +98,19 @@ class CMicroAppHost {
94
98
  static isInitialized() {
95
99
  return !!this.instance;
96
100
  }
101
+ /**
102
+ * Host-initiated lifecycle: loads app config, initializes the app bridge,
103
+ * and calls the onInit callback. Call this instead of relying on the
104
+ * automatic constructor chain when `selfInitialize: true`.
105
+ * @returns host options (systemVersion, history, theme)
106
+ */
107
+ async initialize() {
108
+ await loadAppConfig();
109
+ const appBridge = await getAppBridge();
110
+ this.#appBridge = appBridge;
111
+ if (this.onInit) this.onInit(this.props);
112
+ return this.props;
113
+ }
97
114
  getProps() {
98
115
  return this.props;
99
116
  }
@@ -182,9 +199,12 @@ class CMicroAppHost {
182
199
  return this.scriptingObjects[name];
183
200
  }
184
201
  /**
185
- * add scripting object for child microapp to use
202
+ * Register a scripting object for child micro-apps to use.
203
+ * Adds the object to both the App Bridge and the SSF Host so guests
204
+ * using either transport can discover it. Always prefer this method
205
+ * over calling appBridge.addScriptingObject() directly.
186
206
  * @param so - The scripting object to be added.
187
- * @param params - Optional parameters for adding the scripting object.
207
+ * @param params - Optional parameters (e.g. `{ guestId }` to scope to a specific guest).
188
208
  */
189
209
  addScriptingObject(so, params) {
190
210
  if (this.#appBridge) {
@@ -40,13 +40,9 @@ class GuestModule extends ScriptingObject {
40
40
  _setUnloadHandler(handler) {
41
41
  this.#onUnload = handler;
42
42
  }
43
- getParameters() {
44
- return Promise.resolve(this.#params);
45
- }
46
- getCapabilities() {
47
- return Promise.resolve({});
48
- }
49
- log(message, logLevel) {
43
+ getParameters = () => Promise.resolve(this.#params);
44
+ getCapabilities = () => Promise.resolve({});
45
+ log = (message, logLevel) => {
50
46
  const logger = window.emui?.logger;
51
47
  if (!logger) return Promise.resolve();
52
48
  const text = typeof message === "string" ? message : message.message;
@@ -54,11 +50,11 @@ class GuestModule extends ScriptingObject {
54
50
  const logFn = logger[method];
55
51
  if (logFn) logFn(text);
56
52
  return Promise.resolve();
57
- }
58
- unload() {
53
+ };
54
+ unload = () => {
59
55
  if (this.#onUnload) return this.#onUnload();
60
56
  return Promise.resolve();
61
- }
57
+ };
62
58
  }
63
59
  const createGuestModule = (guestId, params = {}, overrides = {}) => {
64
60
  const mod = new GuestModule(guestId, params);
@@ -30,7 +30,8 @@ export { subscribeToSessionExpiryWarning, subscribeToSessionExpiry, subscribeToR
30
30
  export { waitMessage as waitMessageAction } from './data/wait-message/actions.js';
31
31
  export { initServiceWorker } from './utils/service-worker.js';
32
32
  export { CMicroAppGuest, CMicroAppGuest as CMicroApp, } from './utils/micro-frontend/guest.js';
33
- export { CMicroAppHost } from './utils/micro-frontend/host.js';
33
+ /** @deprecated Use CMicroApp with selfInitialize: true instead */
34
+ export { CMicroAppHost, type HostOptions, } from './utils/micro-frontend/host.js';
34
35
  export { buildModuleParams, createGuestModule, GuestModule, } from './utils/micro-frontend/module-so.js';
35
36
  export type { HostProvidedParams, ModuleOverrides, } from './utils/micro-frontend/module-so.js';
36
37
  export { enableReactAppForHostIntegration } from './utils/app-host-integration/react.js';
@@ -112,9 +112,12 @@ export declare class CMicroAppGuest<AppObjects extends ScriptingObjects = Partia
112
112
  getRef<T>(): T | null;
113
113
  navigate(url: To, state?: any): void;
114
114
  /**
115
- * add scripting object for child microapp to use
115
+ * Register a scripting object for child micro-apps to use.
116
+ * Adds the object to both the App Bridge and the SSF Host so guests
117
+ * using either transport can discover it. Always prefer this method
118
+ * over calling appBridge.addScriptingObject() directly.
116
119
  * @param so - The scripting object to be added.
117
- * @param params - Optional parameters for adding the scripting object.
120
+ * @param params - Optional parameters (e.g. `{ guestId }` to scope to a specific guest).
118
121
  */
119
122
  addScriptingObject<SO extends AppObjects[keyof AppObjects]>(so: SO, params?: AddScriptingObjectParams): void;
120
123
  /**
@@ -6,7 +6,7 @@ import { BAEvent, ScriptingObjectTypes, Events } from '@elliemae/pui-scripting-o
6
6
  import type { ScriptingObjects, EventListeners, AddScriptingObjectParams, DispatchEventParam, EventOptions } from '@elliemae/microfe-common';
7
7
  import { Analytics } from '@elliemae/pui-analytics-so';
8
8
  import { MicroFrontEndLogger } from '../types.js';
9
- type HostOptions = {
9
+ export type HostOptions = {
10
10
  systemVersion: string;
11
11
  history: History;
12
12
  theme: DefaultTheme;
@@ -22,11 +22,18 @@ type ConstructorParams = {
22
22
  onInit?: OnInitCallback;
23
23
  ssfHostRef?: SSFHost<ScriptingObjectTypes, Events> | null;
24
24
  analytics?: Analytics;
25
+ /**
26
+ * When true the host drives its own lifecycle via {@link CMicroAppHost.initialize}.
27
+ * The constructor skips the automatic loadAppConfig → getAppBridge → onInit chain.
28
+ */
29
+ selfInitialize?: boolean;
25
30
  };
26
31
  /**
27
32
  * Micro-frontend host application class (singleton).
28
33
  * Manages hosting and coordination of multiple micro-frontend guest applications.
29
34
  * Provides shared services like navigation, theming, analytics, and state management.
35
+ * @deprecated Use {@link CMicroAppGuest | CMicroApp} instead. CMicroApp now supports
36
+ * both guest and host use cases via `selfInitialize: true` and `initialize()`.
30
37
  * @template AppObjects - Type of custom scripting objects
31
38
  * @template AppEvents - Type of custom event listeners
32
39
  * @example
@@ -57,6 +64,13 @@ export declare class CMicroAppHost<AppObjects extends ScriptingObjects = Partial
57
64
  private constructor();
58
65
  static getInstance<AppObjects extends ScriptingObjects = Partial<ScriptingObjectTypes>, AppEvents extends EventListeners = Events>(params?: ConstructorParams): CMicroAppHost<AppObjects, AppEvents>;
59
66
  static isInitialized(): boolean;
67
+ /**
68
+ * Host-initiated lifecycle: loads app config, initializes the app bridge,
69
+ * and calls the onInit callback. Call this instead of relying on the
70
+ * automatic constructor chain when `selfInitialize: true`.
71
+ * @returns host options (systemVersion, history, theme)
72
+ */
73
+ initialize(): Promise<HostOptions>;
60
74
  getProps(): HostOptions;
61
75
  getLogger(): MicroFrontEndLogger;
62
76
  getItem(key: string): string | null;
@@ -85,9 +99,12 @@ export declare class CMicroAppHost<AppObjects extends ScriptingObjects = Partial
85
99
  sendBAEvent(data: BAEvent): void;
86
100
  getObject<T>(name: string): Promise<T>;
87
101
  /**
88
- * add scripting object for child microapp to use
102
+ * Register a scripting object for child micro-apps to use.
103
+ * Adds the object to both the App Bridge and the SSF Host so guests
104
+ * using either transport can discover it. Always prefer this method
105
+ * over calling appBridge.addScriptingObject() directly.
89
106
  * @param so - The scripting object to be added.
90
- * @param params - Optional parameters for adding the scripting object.
107
+ * @param params - Optional parameters (e.g. `{ guestId }` to scope to a specific guest).
91
108
  */
92
109
  addScriptingObject<SO extends AppObjects[keyof AppObjects]>(so: SO, params?: AddScriptingObjectParams): void;
93
110
  /**
@@ -43,10 +43,10 @@ export declare class GuestModule extends ScriptingObject implements IModule {
43
43
  * @param handler
44
44
  */
45
45
  _setUnloadHandler(handler: () => Promise<void>): void;
46
- getParameters(): Promise<ModuleParameters>;
47
- getCapabilities(): Promise<Record<string, unknown>>;
48
- log(message: LogMessage | string, logLevel: keyof typeof LogLevels): Promise<void>;
49
- unload(): Promise<void>;
46
+ getParameters: () => Promise<ModuleParameters>;
47
+ getCapabilities: () => Promise<Record<string, unknown>>;
48
+ log: (message: LogMessage | string, logLevel: keyof typeof LogLevels) => Promise<void>;
49
+ unload: () => Promise<void>;
50
50
  }
51
51
  /**
52
52
  * Optional method overrides the host can supply to customise
@@ -74,9 +74,13 @@ export type ModuleOverrides = {
74
74
  * Internally calls {@link buildModuleParams} to merge the app config
75
75
  * values (hostUrl, manifestPath, homeRoute) with host-provided values
76
76
  * (theme, history, initialRoute).
77
+ *
78
+ * Register the returned object via {@link CMicroAppHost.addScriptingObject}
79
+ * or {@link CMicroAppGuest.addScriptingObject} (not directly on the app
80
+ * bridge) so it is added to both the App Bridge and the SSF Host.
77
81
  * @param guestId - App id as defined in app.config.json (e.g. 'loanapp')
78
82
  * @param params - Host-provided values (theme, history, initialRoute, custom keys)
79
83
  * @param overrides - Method overrides / additions (e.g. custom getCapabilities)
80
- * @returns IModule scripting object ready for addScriptingObject()
84
+ * @returns IModule scripting object ready for CMicroAppHost/CMicroApp.addScriptingObject()
81
85
  */
82
86
  export declare const createGuestModule: (guestId: string, params?: HostProvidedParams, overrides?: ModuleOverrides) => IModule;