@elliemae/pui-app-sdk 5.40.0-beta.2 → 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 (41) hide show
  1. package/demo/{4018.2e1aaff7.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.2e1aaff7.iframe.bundle.js.gz → 4018.e60ce619.iframe.bundle.js.gz} +0 -0
  4. package/demo/docs/{4018.2e1aaff7.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.2e1aaff7.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.81dbbc1cf5969ea75037.manager.bundle.js → main.b378ddd694929651bda3.manager.bundle.js} +1 -1
  13. package/demo/docs/{main.81dbbc1cf5969ea75037.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.81dbbc1cf5969ea75037.manager.bundle.js → main.b378ddd694929651bda3.manager.bundle.js} +1 -1
  22. package/demo/{main.81dbbc1cf5969ea75037.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/host.js +25 -8
  26. package/dist/esm/index.js +3 -1
  27. package/dist/esm/utils/micro-frontend/host.js +25 -8
  28. package/dist/types/lib/index.d.ts +2 -1
  29. package/dist/types/lib/utils/micro-frontend/host.d.ts +15 -1
  30. package/dist/types/tsconfig.tsbuildinfo +1 -1
  31. package/package.json +1 -1
  32. package/demo/4018.2e1aaff7.iframe.bundle.js.br +0 -0
  33. package/demo/docs/4018.2e1aaff7.iframe.bundle.js.br +0 -0
  34. package/demo/docs/main.81dbbc1cf5969ea75037.manager.bundle.js.gz +0 -0
  35. package/demo/docs/main.b0d74522.iframe.bundle.js +0 -5
  36. package/demo/docs/main.b0d74522.iframe.bundle.js.br +0 -0
  37. package/demo/docs/main.b0d74522.iframe.bundle.js.gz +0 -0
  38. package/demo/main.81dbbc1cf5969ea75037.manager.bundle.js.gz +0 -0
  39. package/demo/main.b0d74522.iframe.bundle.js +0 -5
  40. package/demo/main.b0d74522.iframe.bundle.js.br +0 -0
  41. package/demo/main.b0d74522.iframe.bundle.js.gz +0 -0
@@ -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
  }
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,
@@ -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
  }
@@ -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';
@@ -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;