@elliemae/pui-app-sdk 5.40.0-beta.1 → 5.40.0-beta.3

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 (52) hide show
  1. package/demo/{4018.e3bb4bb2.iframe.bundle.js → 4018.e60ce619.iframe.bundle.js} +1 -1
  2. package/demo/4018.e60ce619.iframe.bundle.js.br +0 -0
  3. package/demo/{4018.e3bb4bb2.iframe.bundle.js.gz → 4018.e60ce619.iframe.bundle.js.gz} +0 -0
  4. package/demo/docs/{4018.e3bb4bb2.iframe.bundle.js → 4018.e60ce619.iframe.bundle.js} +1 -1
  5. package/demo/docs/4018.e60ce619.iframe.bundle.js.br +0 -0
  6. package/demo/docs/{4018.e3bb4bb2.iframe.bundle.js.gz → 4018.e60ce619.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.821d8de7.iframe.bundle.js +5 -0
  10. package/demo/docs/main.821d8de7.iframe.bundle.js.br +0 -0
  11. package/demo/docs/main.821d8de7.iframe.bundle.js.gz +0 -0
  12. package/demo/docs/{main.b2bf60fb5c3e8e222a28.manager.bundle.js → main.b378ddd694929651bda3.manager.bundle.js} +1 -1
  13. package/demo/docs/{main.b2bf60fb5c3e8e222a28.manager.bundle.js.br → main.b378ddd694929651bda3.manager.bundle.js.br} +0 -0
  14. package/demo/docs/main.b378ddd694929651bda3.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.821d8de7.iframe.bundle.js +5 -0
  19. package/demo/main.821d8de7.iframe.bundle.js.br +0 -0
  20. package/demo/main.821d8de7.iframe.bundle.js.gz +0 -0
  21. package/demo/{main.b2bf60fb5c3e8e222a28.manager.bundle.js → main.b378ddd694929651bda3.manager.bundle.js} +1 -1
  22. package/demo/{main.b2bf60fb5c3e8e222a28.manager.bundle.js.br → main.b378ddd694929651bda3.manager.bundle.js.br} +0 -0
  23. package/demo/main.b378ddd694929651bda3.manager.bundle.js.gz +0 -0
  24. package/demo/project.json +1 -1
  25. package/dist/cjs/utils/micro-frontend/guest.js +20 -9
  26. package/dist/cjs/utils/micro-frontend/host.js +25 -8
  27. package/dist/cjs/view/guest-microapp.js +2 -0
  28. package/dist/cjs/view/tests/app.config.json +11 -0
  29. package/dist/cjs/view/tests/constants.js +2 -0
  30. package/dist/esm/index.js +3 -1
  31. package/dist/esm/utils/micro-frontend/guest.js +20 -9
  32. package/dist/esm/utils/micro-frontend/host.js +25 -8
  33. package/dist/esm/view/guest-microapp.js +2 -0
  34. package/dist/esm/view/tests/app.config.json +11 -0
  35. package/dist/esm/view/tests/constants.js +2 -0
  36. package/dist/types/lib/index.d.ts +2 -1
  37. package/dist/types/lib/utils/micro-frontend/guest.d.ts +6 -3
  38. package/dist/types/lib/utils/micro-frontend/host.d.ts +15 -1
  39. package/dist/types/lib/utils/micro-frontend/types.d.ts +6 -0
  40. package/dist/types/lib/view/tests/constants.d.ts +1 -0
  41. package/dist/types/tsconfig.tsbuildinfo +1 -1
  42. package/package.json +1 -1
  43. package/demo/4018.e3bb4bb2.iframe.bundle.js.br +0 -0
  44. package/demo/docs/4018.e3bb4bb2.iframe.bundle.js.br +0 -0
  45. package/demo/docs/main.b2bf60fb5c3e8e222a28.manager.bundle.js.gz +0 -0
  46. package/demo/docs/main.d3eba28f.iframe.bundle.js +0 -5
  47. package/demo/docs/main.d3eba28f.iframe.bundle.js.br +0 -0
  48. package/demo/docs/main.d3eba28f.iframe.bundle.js.gz +0 -0
  49. package/demo/main.b2bf60fb5c3e8e222a28.manager.bundle.js.gz +0 -0
  50. package/demo/main.d3eba28f.iframe.bundle.js +0 -5
  51. package/demo/main.d3eba28f.iframe.bundle.js.br +0 -0
  52. package/demo/main.d3eba28f.iframe.bundle.js.gz +0 -0
@@ -355,11 +355,14 @@ class CMicroAppGuest {
355
355
  if (route) this.props.history.push(route);
356
356
  }
357
357
  /**
358
- * Guest-initiated lifecycle: discovers the host, pulls module parameters,
359
- * and applies them. After this resolves the guest is ready to render.
358
+ * Guest-initiated lifecycle: discovers the host and applies module
359
+ * parameters if available. After this resolves the guest is ready to render.
360
360
  * Requires selfInitialize: true in the constructor so the bridge
361
361
  * skips calling init() / mount() on this guest.
362
- * @returns module parameters provided by the host
362
+ *
363
+ * The module scripting object is optional — if the host did not register
364
+ * one, a warning is logged and the guest proceeds with its own config.
365
+ * @returns module parameters provided by the host, or a minimal object with moduleId
363
366
  */
364
367
  async initialize() {
365
368
  const isStandalone = window.top === window.self && !window.opener;
@@ -376,14 +379,22 @@ class CMicroAppGuest {
376
379
  );
377
380
  }
378
381
  this.props.host = host;
379
- const module2 = await host.getObject("module");
380
- if (!module2) {
381
- throw new Error(
382
- `Host did not register a module scripting object for guest "${this.appId}". Ensure the host registers a module SO before rendering GuestMicroApp.`
382
+ let params = { moduleId: this.appId };
383
+ try {
384
+ const module2 = await host.getObject("module");
385
+ if (module2) {
386
+ params = await module2.getParameters();
387
+ this.#applyModuleParams(params);
388
+ } else {
389
+ this.logger.warn(
390
+ `Host did not register a module scripting object for "${this.appId}". Proceeding without host-provided parameters (history, theme, initialRoute).`
391
+ );
392
+ }
393
+ } catch (ex) {
394
+ this.logger.warn(
395
+ `Failed to retrieve module parameters for "${this.appId}". Proceeding without host-provided parameters.`
383
396
  );
384
397
  }
385
- const params = await module2.getParameters();
386
- this.#applyModuleParams(params);
387
398
  if (this.onInit) this.onInit(this.props);
388
399
  return params;
389
400
  }
@@ -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
  }
@@ -88,6 +88,7 @@ const useAppRenderer = (props) => {
88
88
  hostUrl,
89
89
  title,
90
90
  name,
91
+ selfInitialize: configSelfInitialize,
91
92
  ssfAppOptions: configSsfAppOptions = {}
92
93
  } = getConfig();
93
94
  const mergedSsfAppOptions = {
@@ -135,6 +136,7 @@ const useAppRenderer = (props) => {
135
136
  if (isMounted) {
136
137
  instanceId = await appBridge.openApp({
137
138
  id,
139
+ selfInitialize: configSelfInitialize,
138
140
  frameOptions: {
139
141
  containerId,
140
142
  queryParams: (0, import_pui_logrocket.buildLogRocketQueryParams)()
@@ -25,6 +25,17 @@
25
25
  "style": "border: 2px solid red;"
26
26
  }
27
27
  },
28
+ "loanapp-selfinit": {
29
+ "name": "Loan Self Init",
30
+ "hostUrl": "./loan",
31
+ "selfInitialize": true,
32
+ "development": {
33
+ "files": ["index.js"]
34
+ },
35
+ "production": {
36
+ "files": ["index.js"]
37
+ }
38
+ },
28
39
  "taskapp": {
29
40
  "name": "Task",
30
41
  "hostUrl": "./task",
@@ -26,6 +26,7 @@ __export(constants_exports, {
26
26
  LATEST_VERSION: () => LATEST_VERSION,
27
27
  LOAN_APP_ID: () => LOAN_APP_ID,
28
28
  LOAN_SAVED_EVENT: () => LOAN_SAVED_EVENT,
29
+ LOAN_SELF_INIT_APP_ID: () => LOAN_SELF_INIT_APP_ID,
29
30
  PRE_COMMIT_EVENT: () => PRE_COMMIT_EVENT,
30
31
  RELEASE_VERSION: () => RELEASE_VERSION,
31
32
  SSF_APP_ID: () => SSF_APP_ID,
@@ -35,6 +36,7 @@ module.exports = __toCommonJS(constants_exports);
35
36
  const LATEST_VERSION = "latest";
36
37
  const RELEASE_VERSION = "23.1.0";
37
38
  const LOAN_APP_ID = "loanapp";
39
+ const LOAN_SELF_INIT_APP_ID = "loanapp-selfinit";
38
40
  const SSF_APP_ID = "ssfapp";
39
41
  const TASK_APP_ID = "taskapp";
40
42
  const FLIGHTS_APP_ID = "flights";
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,
@@ -322,11 +322,14 @@ class CMicroAppGuest {
322
322
  if (route) this.props.history.push(route);
323
323
  }
324
324
  /**
325
- * Guest-initiated lifecycle: discovers the host, pulls module parameters,
326
- * and applies them. After this resolves the guest is ready to render.
325
+ * Guest-initiated lifecycle: discovers the host and applies module
326
+ * parameters if available. After this resolves the guest is ready to render.
327
327
  * Requires selfInitialize: true in the constructor so the bridge
328
328
  * skips calling init() / mount() on this guest.
329
- * @returns module parameters provided by the host
329
+ *
330
+ * The module scripting object is optional — if the host did not register
331
+ * one, a warning is logged and the guest proceeds with its own config.
332
+ * @returns module parameters provided by the host, or a minimal object with moduleId
330
333
  */
331
334
  async initialize() {
332
335
  const isStandalone = window.top === window.self && !window.opener;
@@ -343,14 +346,22 @@ class CMicroAppGuest {
343
346
  );
344
347
  }
345
348
  this.props.host = host;
346
- const module = await host.getObject("module");
347
- if (!module) {
348
- throw new Error(
349
- `Host did not register a module scripting object for guest "${this.appId}". Ensure the host registers a module SO before rendering GuestMicroApp.`
349
+ let params = { moduleId: this.appId };
350
+ try {
351
+ const module = await host.getObject("module");
352
+ if (module) {
353
+ params = await module.getParameters();
354
+ this.#applyModuleParams(params);
355
+ } else {
356
+ this.logger.warn(
357
+ `Host did not register a module scripting object for "${this.appId}". Proceeding without host-provided parameters (history, theme, initialRoute).`
358
+ );
359
+ }
360
+ } catch (ex) {
361
+ this.logger.warn(
362
+ `Failed to retrieve module parameters for "${this.appId}". Proceeding without host-provided parameters.`
350
363
  );
351
364
  }
352
- const params = await module.getParameters();
353
- this.#applyModuleParams(params);
354
365
  if (this.onInit) this.onInit(this.props);
355
366
  return params;
356
367
  }
@@ -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
  }
@@ -60,6 +60,7 @@ const useAppRenderer = (props) => {
60
60
  hostUrl,
61
61
  title,
62
62
  name,
63
+ selfInitialize: configSelfInitialize,
63
64
  ssfAppOptions: configSsfAppOptions = {}
64
65
  } = getConfig();
65
66
  const mergedSsfAppOptions = {
@@ -107,6 +108,7 @@ const useAppRenderer = (props) => {
107
108
  if (isMounted) {
108
109
  instanceId = await appBridge.openApp({
109
110
  id,
111
+ selfInitialize: configSelfInitialize,
110
112
  frameOptions: {
111
113
  containerId,
112
114
  queryParams: buildLogRocketQueryParams()
@@ -25,6 +25,17 @@
25
25
  "style": "border: 2px solid red;"
26
26
  }
27
27
  },
28
+ "loanapp-selfinit": {
29
+ "name": "Loan Self Init",
30
+ "hostUrl": "./loan",
31
+ "selfInitialize": true,
32
+ "development": {
33
+ "files": ["index.js"]
34
+ },
35
+ "production": {
36
+ "files": ["index.js"]
37
+ }
38
+ },
28
39
  "taskapp": {
29
40
  "name": "Task",
30
41
  "hostUrl": "./task",
@@ -1,6 +1,7 @@
1
1
  const LATEST_VERSION = "latest";
2
2
  const RELEASE_VERSION = "23.1.0";
3
3
  const LOAN_APP_ID = "loanapp";
4
+ const LOAN_SELF_INIT_APP_ID = "loanapp-selfinit";
4
5
  const SSF_APP_ID = "ssfapp";
5
6
  const TASK_APP_ID = "taskapp";
6
7
  const FLIGHTS_APP_ID = "flights";
@@ -19,6 +20,7 @@ export {
19
20
  LATEST_VERSION,
20
21
  LOAN_APP_ID,
21
22
  LOAN_SAVED_EVENT,
23
+ LOAN_SELF_INIT_APP_ID,
22
24
  PRE_COMMIT_EVENT,
23
25
  RELEASE_VERSION,
24
26
  SSF_APP_ID,
@@ -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';
@@ -96,11 +96,14 @@ export declare class CMicroAppGuest<AppObjects extends ScriptingObjects = Partia
96
96
  private findHost;
97
97
  get uuid(): string;
98
98
  /**
99
- * Guest-initiated lifecycle: discovers the host, pulls module parameters,
100
- * and applies them. After this resolves the guest is ready to render.
99
+ * Guest-initiated lifecycle: discovers the host and applies module
100
+ * parameters if available. After this resolves the guest is ready to render.
101
101
  * Requires selfInitialize: true in the constructor so the bridge
102
102
  * skips calling init() / mount() on this guest.
103
- * @returns module parameters provided by the host
103
+ *
104
+ * The module scripting object is optional — if the host did not register
105
+ * one, a warning is logged and the guest proceeds with its own config.
106
+ * @returns module parameters provided by the host, or a minimal object with moduleId
104
107
  */
105
108
  initialize(): Promise<ModuleParameters>;
106
109
  init(options: InitOptions<AppObjects, AppEvents>): Promise<void>;
@@ -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;
@@ -127,6 +127,12 @@ export type MicroAppConfig = {
127
127
  * options for ssf based micro-frontend applications.
128
128
  */
129
129
  ssfAppOptions?: SSFAppOptions<Record<string, string | number | boolean>>;
130
+ /**
131
+ * When true the guest drives its own lifecycle via `initialize()` and
132
+ * the bridge skips calling `init()` / `mount()` on the guest.
133
+ * Set this in the `microFrontendApps` section of `app.config.json`.
134
+ */
135
+ selfInitialize?: boolean;
130
136
  /**
131
137
  * The Document object associated with the micro-frontend application.
132
138
  */
@@ -1,6 +1,7 @@
1
1
  export declare const LATEST_VERSION = "latest";
2
2
  export declare const RELEASE_VERSION = "23.1.0";
3
3
  export declare const LOAN_APP_ID = "loanapp";
4
+ export declare const LOAN_SELF_INIT_APP_ID = "loanapp-selfinit";
4
5
  export declare const SSF_APP_ID = "ssfapp";
5
6
  export declare const TASK_APP_ID = "taskapp";
6
7
  export declare const FLIGHTS_APP_ID = "flights";