@elliemae/pui-app-sdk 5.40.0-beta.8 → 5.40.0

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 (53) hide show
  1. package/demo/{9693.f2e51ea9.iframe.bundle.js → 2.2f2cb9fa.iframe.bundle.js} +522 -522
  2. package/demo/2.2f2cb9fa.iframe.bundle.js.br +0 -0
  3. package/demo/2.2f2cb9fa.iframe.bundle.js.gz +0 -0
  4. package/demo/docs/{9693.f2e51ea9.iframe.bundle.js → 2.2f2cb9fa.iframe.bundle.js} +522 -522
  5. package/demo/docs/2.2f2cb9fa.iframe.bundle.js.br +0 -0
  6. package/demo/docs/2.2f2cb9fa.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.4f1869df889cba0eb042.manager.bundle.js +1 -0
  10. package/demo/docs/main.4f1869df889cba0eb042.manager.bundle.js.br +0 -0
  11. package/demo/docs/main.4f1869df889cba0eb042.manager.bundle.js.gz +0 -0
  12. package/demo/docs/main.d2529e6d.iframe.bundle.js +5 -0
  13. package/demo/docs/main.d2529e6d.iframe.bundle.js.br +0 -0
  14. package/demo/docs/main.d2529e6d.iframe.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.4f1869df889cba0eb042.manager.bundle.js +1 -0
  19. package/demo/main.4f1869df889cba0eb042.manager.bundle.js.br +0 -0
  20. package/demo/main.4f1869df889cba0eb042.manager.bundle.js.gz +0 -0
  21. package/demo/main.d2529e6d.iframe.bundle.js +5 -0
  22. package/demo/main.d2529e6d.iframe.bundle.js.br +0 -0
  23. package/demo/main.d2529e6d.iframe.bundle.js.gz +0 -0
  24. package/demo/project.json +1 -1
  25. package/dist/cjs/utils/micro-frontend/guest.js +23 -7
  26. package/dist/cjs/utils/micro-frontend/host.js +6 -0
  27. package/dist/cjs/utils/micro-frontend/module-so.js +2 -0
  28. package/dist/cjs/utils/micro-frontend/tests/__snapshots__/guest.test.ts.snap +1 -0
  29. package/dist/cjs/view/app-router.js +7 -0
  30. package/dist/esm/utils/micro-frontend/guest.js +23 -7
  31. package/dist/esm/utils/micro-frontend/host.js +6 -0
  32. package/dist/esm/utils/micro-frontend/module-so.js +2 -0
  33. package/dist/esm/utils/micro-frontend/tests/__snapshots__/guest.test.ts.snap +1 -0
  34. package/dist/esm/view/app-router.js +7 -0
  35. package/dist/types/lib/utils/micro-frontend/guest.d.ts +6 -1
  36. package/dist/types/tsconfig.tsbuildinfo +1 -1
  37. package/package.json +6 -6
  38. package/demo/9693.f2e51ea9.iframe.bundle.js.br +0 -0
  39. package/demo/9693.f2e51ea9.iframe.bundle.js.gz +0 -0
  40. package/demo/docs/9693.f2e51ea9.iframe.bundle.js.br +0 -0
  41. package/demo/docs/9693.f2e51ea9.iframe.bundle.js.gz +0 -0
  42. package/demo/docs/main.1985b2d8e3c713f34e4d.manager.bundle.js +0 -1
  43. package/demo/docs/main.1985b2d8e3c713f34e4d.manager.bundle.js.br +0 -0
  44. package/demo/docs/main.1985b2d8e3c713f34e4d.manager.bundle.js.gz +0 -0
  45. package/demo/docs/main.f3783eb6.iframe.bundle.js +0 -5
  46. package/demo/docs/main.f3783eb6.iframe.bundle.js.br +0 -0
  47. package/demo/docs/main.f3783eb6.iframe.bundle.js.gz +0 -0
  48. package/demo/main.1985b2d8e3c713f34e4d.manager.bundle.js +0 -1
  49. package/demo/main.1985b2d8e3c713f34e4d.manager.bundle.js.br +0 -0
  50. package/demo/main.1985b2d8e3c713f34e4d.manager.bundle.js.gz +0 -0
  51. package/demo/main.f3783eb6.iframe.bundle.js +0 -5
  52. package/demo/main.f3783eb6.iframe.bundle.js.br +0 -0
  53. package/demo/main.f3783eb6.iframe.bundle.js.gz +0 -0
@@ -46,6 +46,7 @@ var import_web_storage = require("../web-storage.js");
46
46
  var import_app_bridge = require("./app-bridge.js");
47
47
  var import_helpers = require("../helpers.js");
48
48
  var import_ssf_host2 = require("./ssf-host.js");
49
+ const DEFAULT_CONTAINER_ID = "app-container";
49
50
  const isCrossDomain = () => {
50
51
  try {
51
52
  window.parent.document;
@@ -68,7 +69,6 @@ class CMicroAppGuest {
68
69
  logger;
69
70
  appId;
70
71
  props;
71
- containerId;
72
72
  /**
73
73
  * communication method used between microapps
74
74
  */
@@ -98,7 +98,6 @@ class CMicroAppGuest {
98
98
  onGetRef;
99
99
  // eslint-disable-next-line max-statements
100
100
  constructor(params) {
101
- this.containerId = "app-container";
102
101
  window.emui.uuid = window.emui.uuid || (0, import_uuid.v4)();
103
102
  this.appId = window.emui?.appId || (0, import_config.getAppConfigValue)("appId");
104
103
  this.#uuid = window.emui.uuid;
@@ -109,7 +108,8 @@ class CMicroAppGuest {
109
108
  prevState: null,
110
109
  history: params?.history || import_history2.browserHistory,
111
110
  theme: (0, import_pui_theme.getDefaultTheme)(),
112
- manifestPath: "./latest"
111
+ manifestPath: "./latest",
112
+ containerId: DEFAULT_CONTAINER_ID
113
113
  };
114
114
  this.logger = params?.logger || import_console_logger.consoleLogger;
115
115
  (0, import_logger.setLogger)(this.logger);
@@ -133,6 +133,11 @@ class CMicroAppGuest {
133
133
  static getInstance(params) {
134
134
  if (!this.instance) {
135
135
  this.instance = new CMicroAppGuest(params);
136
+ if (!params?.selfInitialize) {
137
+ (params?.logger || import_console_logger.consoleLogger).warn(
138
+ "CMicroApp.getInstance() called without selfInitialize: true \u2014 this legacy mode is deprecated. Pass { selfInitialize: true } and use initialize() instead."
139
+ );
140
+ }
136
141
  }
137
142
  return this.instance;
138
143
  }
@@ -249,7 +254,7 @@ class CMicroAppGuest {
249
254
  }
250
255
  delete window.emui.app;
251
256
  }
252
- this.unmount({ containerId: this.containerId }).catch(() => {
257
+ this.unmount({ containerId: this.props.containerId }).catch(() => {
253
258
  });
254
259
  }
255
260
  getSessionStorageItem(key) {
@@ -338,6 +343,9 @@ class CMicroAppGuest {
338
343
  if (params.hostUrl) this.props.hostUrl = params.hostUrl;
339
344
  if (params.manifestPath)
340
345
  this.props.manifestPath = params.manifestPath;
346
+ if (params.containerId) {
347
+ this.props.containerId = params.containerId;
348
+ }
341
349
  this.#applyHistoryFromParams(params);
342
350
  }
343
351
  #applyHistoryFromParams(params) {
@@ -371,8 +379,13 @@ class CMicroAppGuest {
371
379
  * one, a warning is logged and the guest proceeds with its own config.
372
380
  * @returns module parameters provided by the host, or a minimal object with moduleId
373
381
  */
374
- // eslint-disable-next-line max-statements
382
+ // eslint-disable-next-line max-statements, complexity
375
383
  async initialize() {
384
+ if (window.emui?._ASSET_PATH) {
385
+ __webpack_public_path__ = new URL("../", window.emui._ASSET_PATH).href;
386
+ } else {
387
+ __webpack_public_path__ = __webpack_public_path__.replace(/\/?$/, "/");
388
+ }
376
389
  const isStandalone = window.top === window.self && !window.opener;
377
390
  if (isStandalone) {
378
391
  await (0, import_app_config.loadAppConfig)();
@@ -408,6 +421,9 @@ class CMicroAppGuest {
408
421
  `Failed to retrieve module parameters for "${this.appId}". Proceeding without host-provided parameters.`
409
422
  );
410
423
  }
424
+ const instanceId = this.getSessionStorageItem("instanceId") || "";
425
+ const userId = this.getSessionStorageItem("userId") || "";
426
+ (0, import_pui_analytics_so.updateBAEventParameters)({ appId: this.appId, instanceId, userId });
411
427
  if (this.onInit) this.onInit(this.props);
412
428
  return params;
413
429
  }
@@ -436,8 +452,8 @@ class CMicroAppGuest {
436
452
  });
437
453
  });
438
454
  }
439
- mount(options = { containerId: "app-container" }) {
440
- this.containerId = options?.containerId;
455
+ mount(options = { containerId: DEFAULT_CONTAINER_ID }) {
456
+ this.props.containerId = options?.containerId;
441
457
  return Promise.resolve().then(() => {
442
458
  if (this.#pendingInitialRoute) {
443
459
  this.props.history.push(this.#pendingInitialRoute);
@@ -107,6 +107,11 @@ class CMicroAppHost {
107
107
  static getInstance(params) {
108
108
  if (!this.instance) {
109
109
  this.instance = new CMicroAppHost(params);
110
+ if (!params?.selfInitialize) {
111
+ (params?.logger || import_console_logger.consoleLogger).warn(
112
+ "CMicroAppHost.getInstance() called without selfInitialize: true \u2014 this legacy mode is deprecated. Pass { selfInitialize: true } and use initialize() instead."
113
+ );
114
+ }
110
115
  }
111
116
  return this.instance;
112
117
  }
@@ -120,6 +125,7 @@ class CMicroAppHost {
120
125
  * @returns host options (systemVersion, history, theme)
121
126
  */
122
127
  async initialize() {
128
+ __webpack_public_path__ = __webpack_public_path__.replace(/\/?$/, "/");
123
129
  await (0, import_app_config.loadAppConfig)();
124
130
  const appBridge = await (0, import_app_bridge.getAppBridge)();
125
131
  this.#appBridge = appBridge;
@@ -25,6 +25,7 @@ __export(module_so_exports, {
25
25
  module.exports = __toCommonJS(module_so_exports);
26
26
  var import_ssf_host = require("@elliemae/ssf-host");
27
27
  var import_index = require("./index.js");
28
+ var import_const = require("../../view/micro-app/const.js");
28
29
  const LOG_LEVEL_METHOD = {
29
30
  DEBUG: "debug",
30
31
  INFO: "info",
@@ -40,6 +41,7 @@ const buildModuleParams = (guestId, params = {}) => {
40
41
  hostUrl: config.hostUrl,
41
42
  manifestPath: config.manifestPath,
42
43
  homeRoute: config.homeRoute,
44
+ containerId: `${import_const.APP_CONTAINER_ID_PREFIX}${guestId}`,
43
45
  ...params
44
46
  };
45
47
  };
@@ -2,6 +2,7 @@
2
2
 
3
3
  exports[`CMicroAppGuest - Standalone calls onInit 1`] = `
4
4
  {
5
+ "containerId": "app-container",
5
6
  "history": {
6
7
  "action": "POP",
7
8
  "back": [Function],
@@ -29,6 +29,13 @@ const AppRouter = ({ history, basename, ...props }) => {
29
29
  action: history.action,
30
30
  location: history.location
31
31
  });
32
+ (0, import_react.useLayoutEffect)(() => {
33
+ if (basename && state.location.pathname && !state.location.pathname.startsWith(basename)) {
34
+ console.warn(
35
+ `[AppRouter] basename "${basename}" does not match location.pathname "${state.location.pathname}". React Router will render nothing. Verify that "homeRoute" in app.config.json matches the guest's route.`
36
+ );
37
+ }
38
+ }, [basename, state.location.pathname]);
32
39
  (0, import_react.useLayoutEffect)(() => {
33
40
  const unlisten = history.listen((...args) => {
34
41
  if (args.length === 2) {
@@ -13,6 +13,7 @@ import { removeStorageEvents } from "../web-storage.js";
13
13
  import { getAppBridge } from "./app-bridge.js";
14
14
  import { abortPromise } from "../helpers.js";
15
15
  import { getSSFHost, setSSFHost } from "./ssf-host.js";
16
+ const DEFAULT_CONTAINER_ID = "app-container";
16
17
  const isCrossDomain = () => {
17
18
  try {
18
19
  window.parent.document;
@@ -35,7 +36,6 @@ class CMicroAppGuest {
35
36
  logger;
36
37
  appId;
37
38
  props;
38
- containerId;
39
39
  /**
40
40
  * communication method used between microapps
41
41
  */
@@ -65,7 +65,6 @@ class CMicroAppGuest {
65
65
  onGetRef;
66
66
  // eslint-disable-next-line max-statements
67
67
  constructor(params) {
68
- this.containerId = "app-container";
69
68
  window.emui.uuid = window.emui.uuid || uuidv4();
70
69
  this.appId = window.emui?.appId || getAppConfigValue("appId");
71
70
  this.#uuid = window.emui.uuid;
@@ -76,7 +75,8 @@ class CMicroAppGuest {
76
75
  prevState: null,
77
76
  history: params?.history || browserHistory,
78
77
  theme: getDefaultTheme(),
79
- manifestPath: "./latest"
78
+ manifestPath: "./latest",
79
+ containerId: DEFAULT_CONTAINER_ID
80
80
  };
81
81
  this.logger = params?.logger || consoleLogger;
82
82
  setLogger(this.logger);
@@ -100,6 +100,11 @@ class CMicroAppGuest {
100
100
  static getInstance(params) {
101
101
  if (!this.instance) {
102
102
  this.instance = new CMicroAppGuest(params);
103
+ if (!params?.selfInitialize) {
104
+ (params?.logger || consoleLogger).warn(
105
+ "CMicroApp.getInstance() called without selfInitialize: true \u2014 this legacy mode is deprecated. Pass { selfInitialize: true } and use initialize() instead."
106
+ );
107
+ }
103
108
  }
104
109
  return this.instance;
105
110
  }
@@ -216,7 +221,7 @@ class CMicroAppGuest {
216
221
  }
217
222
  delete window.emui.app;
218
223
  }
219
- this.unmount({ containerId: this.containerId }).catch(() => {
224
+ this.unmount({ containerId: this.props.containerId }).catch(() => {
220
225
  });
221
226
  }
222
227
  getSessionStorageItem(key) {
@@ -305,6 +310,9 @@ class CMicroAppGuest {
305
310
  if (params.hostUrl) this.props.hostUrl = params.hostUrl;
306
311
  if (params.manifestPath)
307
312
  this.props.manifestPath = params.manifestPath;
313
+ if (params.containerId) {
314
+ this.props.containerId = params.containerId;
315
+ }
308
316
  this.#applyHistoryFromParams(params);
309
317
  }
310
318
  #applyHistoryFromParams(params) {
@@ -338,8 +346,13 @@ class CMicroAppGuest {
338
346
  * one, a warning is logged and the guest proceeds with its own config.
339
347
  * @returns module parameters provided by the host, or a minimal object with moduleId
340
348
  */
341
- // eslint-disable-next-line max-statements
349
+ // eslint-disable-next-line max-statements, complexity
342
350
  async initialize() {
351
+ if (window.emui?._ASSET_PATH) {
352
+ __webpack_public_path__ = new URL("../", window.emui._ASSET_PATH).href;
353
+ } else {
354
+ __webpack_public_path__ = __webpack_public_path__.replace(/\/?$/, "/");
355
+ }
343
356
  const isStandalone = window.top === window.self && !window.opener;
344
357
  if (isStandalone) {
345
358
  await loadAppConfig();
@@ -375,6 +388,9 @@ class CMicroAppGuest {
375
388
  `Failed to retrieve module parameters for "${this.appId}". Proceeding without host-provided parameters.`
376
389
  );
377
390
  }
391
+ const instanceId = this.getSessionStorageItem("instanceId") || "";
392
+ const userId = this.getSessionStorageItem("userId") || "";
393
+ updateBAEventParameters({ appId: this.appId, instanceId, userId });
378
394
  if (this.onInit) this.onInit(this.props);
379
395
  return params;
380
396
  }
@@ -403,8 +419,8 @@ class CMicroAppGuest {
403
419
  });
404
420
  });
405
421
  }
406
- mount(options = { containerId: "app-container" }) {
407
- this.containerId = options?.containerId;
422
+ mount(options = { containerId: DEFAULT_CONTAINER_ID }) {
423
+ this.props.containerId = options?.containerId;
408
424
  return Promise.resolve().then(() => {
409
425
  if (this.#pendingInitialRoute) {
410
426
  this.props.history.push(this.#pendingInitialRoute);
@@ -92,6 +92,11 @@ class CMicroAppHost {
92
92
  static getInstance(params) {
93
93
  if (!this.instance) {
94
94
  this.instance = new CMicroAppHost(params);
95
+ if (!params?.selfInitialize) {
96
+ (params?.logger || consoleLogger).warn(
97
+ "CMicroAppHost.getInstance() called without selfInitialize: true \u2014 this legacy mode is deprecated. Pass { selfInitialize: true } and use initialize() instead."
98
+ );
99
+ }
95
100
  }
96
101
  return this.instance;
97
102
  }
@@ -105,6 +110,7 @@ class CMicroAppHost {
105
110
  * @returns host options (systemVersion, history, theme)
106
111
  */
107
112
  async initialize() {
113
+ __webpack_public_path__ = __webpack_public_path__.replace(/\/?$/, "/");
108
114
  await loadAppConfig();
109
115
  const appBridge = await getAppBridge();
110
116
  this.#appBridge = appBridge;
@@ -1,5 +1,6 @@
1
1
  import { ScriptingObject, Event } from "@elliemae/ssf-host";
2
2
  import { getMicroFrontEndAppConfig } from "./index.js";
3
+ import { APP_CONTAINER_ID_PREFIX } from "../../view/micro-app/const.js";
3
4
  const LOG_LEVEL_METHOD = {
4
5
  DEBUG: "debug",
5
6
  INFO: "info",
@@ -15,6 +16,7 @@ const buildModuleParams = (guestId, params = {}) => {
15
16
  hostUrl: config.hostUrl,
16
17
  manifestPath: config.manifestPath,
17
18
  homeRoute: config.homeRoute,
19
+ containerId: `${APP_CONTAINER_ID_PREFIX}${guestId}`,
18
20
  ...params
19
21
  };
20
22
  };
@@ -2,6 +2,7 @@
2
2
 
3
3
  exports[`CMicroAppGuest - Standalone calls onInit 1`] = `
4
4
  {
5
+ "containerId": "app-container",
5
6
  "history": {
6
7
  "action": "POP",
7
8
  "back": [Function],
@@ -6,6 +6,13 @@ const AppRouter = ({ history, basename, ...props }) => {
6
6
  action: history.action,
7
7
  location: history.location
8
8
  });
9
+ useLayoutEffect(() => {
10
+ if (basename && state.location.pathname && !state.location.pathname.startsWith(basename)) {
11
+ console.warn(
12
+ `[AppRouter] basename "${basename}" does not match location.pathname "${state.location.pathname}". React Router will render nothing. Verify that "homeRoute" in app.config.json matches the guest's route.`
13
+ );
14
+ }
15
+ }, [basename, state.location.pathname]);
9
16
  useLayoutEffect(() => {
10
17
  const unlisten = history.listen((...args) => {
11
18
  if (args.length === 2) {
@@ -11,6 +11,12 @@ export interface GuestProps<AppObjects extends ScriptingObjects = Partial<Script
11
11
  prevState: JSONValue | null;
12
12
  history: History;
13
13
  theme: DefaultTheme;
14
+ /**
15
+ * DOM element ID where the guest app should render. Defaults to
16
+ * {@link DEFAULT_CONTAINER_ID} and can be overridden by the host via module
17
+ * parameters or the {@link MountOptions} passed to `mount()`.
18
+ */
19
+ containerId: string;
14
20
  }
15
21
  export type OnInitCallback = (options: GuestProps) => void;
16
22
  export type OnMountCallback = (options: MountOptions) => void;
@@ -65,7 +71,6 @@ export declare class CMicroAppGuest<AppObjects extends ScriptingObjects = Partia
65
71
  private readonly logger;
66
72
  private readonly appId;
67
73
  private props;
68
- private containerId;
69
74
  private readonly onInit?;
70
75
  private readonly onMount?;
71
76
  private readonly onUnmount?;