@elliemae/pui-app-sdk 5.40.0-beta.1 → 5.40.0-beta.11
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.
- package/demo/{2706.3ac48b3e.iframe.bundle.js → 2706.13c3ce47.iframe.bundle.js} +1 -1
- package/demo/2706.13c3ce47.iframe.bundle.js.br +0 -0
- package/demo/2706.13c3ce47.iframe.bundle.js.gz +0 -0
- package/demo/{4545.f7205e3b.iframe.bundle.js → 4545.2a18ef60.iframe.bundle.js} +1 -1
- package/demo/4545.2a18ef60.iframe.bundle.js.br +0 -0
- package/demo/4545.2a18ef60.iframe.bundle.js.gz +0 -0
- package/demo/{786.6c70980fba796c81e61a.manager.bundle.js → 786.dfe92a10916c85ed77b9.manager.bundle.js} +67 -67
- package/demo/786.dfe92a10916c85ed77b9.manager.bundle.js.br +0 -0
- package/demo/786.dfe92a10916c85ed77b9.manager.bundle.js.gz +0 -0
- package/demo/{docs/4018.e3bb4bb2.iframe.bundle.js → 9693.7a0c5fc2.iframe.bundle.js} +10 -10
- package/demo/9693.7a0c5fc2.iframe.bundle.js.br +0 -0
- package/demo/9693.7a0c5fc2.iframe.bundle.js.gz +0 -0
- package/demo/docs/{2706.3ac48b3e.iframe.bundle.js → 2706.13c3ce47.iframe.bundle.js} +1 -1
- package/demo/docs/2706.13c3ce47.iframe.bundle.js.br +0 -0
- package/demo/docs/2706.13c3ce47.iframe.bundle.js.gz +0 -0
- package/demo/docs/{4545.f7205e3b.iframe.bundle.js → 4545.2a18ef60.iframe.bundle.js} +1 -1
- package/demo/docs/4545.2a18ef60.iframe.bundle.js.br +0 -0
- package/demo/docs/4545.2a18ef60.iframe.bundle.js.gz +0 -0
- package/demo/docs/{786.6c70980fba796c81e61a.manager.bundle.js → 786.dfe92a10916c85ed77b9.manager.bundle.js} +67 -67
- package/demo/docs/786.dfe92a10916c85ed77b9.manager.bundle.js.br +0 -0
- package/demo/docs/786.dfe92a10916c85ed77b9.manager.bundle.js.gz +0 -0
- package/demo/{4018.e3bb4bb2.iframe.bundle.js → docs/9693.7a0c5fc2.iframe.bundle.js} +10 -10
- package/demo/docs/9693.7a0c5fc2.iframe.bundle.js.br +0 -0
- package/demo/docs/9693.7a0c5fc2.iframe.bundle.js.gz +0 -0
- package/demo/docs/iframe.html +1 -1
- package/demo/docs/index.html +1 -1
- package/demo/docs/main.04bcc8d6.iframe.bundle.js +5 -0
- package/demo/docs/main.04bcc8d6.iframe.bundle.js.br +0 -0
- package/demo/docs/main.04bcc8d6.iframe.bundle.js.gz +0 -0
- package/demo/docs/{main.b2bf60fb5c3e8e222a28.manager.bundle.js → main.a91ed185747422e77b95.manager.bundle.js} +1 -1
- package/demo/docs/{main.b2bf60fb5c3e8e222a28.manager.bundle.js.br → main.a91ed185747422e77b95.manager.bundle.js.br} +0 -0
- package/demo/docs/main.a91ed185747422e77b95.manager.bundle.js.gz +0 -0
- package/demo/docs/project.json +1 -1
- package/demo/docs/{runtime~main.962b8cd7.iframe.bundle.js → runtime~main.8f74ac51.iframe.bundle.js} +1 -1
- package/demo/docs/runtime~main.8f74ac51.iframe.bundle.js.br +0 -0
- package/demo/docs/{runtime~main.962b8cd7.iframe.bundle.js.gz → runtime~main.8f74ac51.iframe.bundle.js.gz} +0 -0
- package/demo/iframe.html +1 -1
- package/demo/index.html +1 -1
- package/demo/main.04bcc8d6.iframe.bundle.js +5 -0
- package/demo/main.04bcc8d6.iframe.bundle.js.br +0 -0
- package/demo/main.04bcc8d6.iframe.bundle.js.gz +0 -0
- package/demo/{main.b2bf60fb5c3e8e222a28.manager.bundle.js → main.a91ed185747422e77b95.manager.bundle.js} +1 -1
- package/demo/{main.b2bf60fb5c3e8e222a28.manager.bundle.js.br → main.a91ed185747422e77b95.manager.bundle.js.br} +0 -0
- package/demo/main.a91ed185747422e77b95.manager.bundle.js.gz +0 -0
- package/demo/project.json +1 -1
- package/demo/{runtime~main.962b8cd7.iframe.bundle.js → runtime~main.8f74ac51.iframe.bundle.js} +1 -1
- package/demo/runtime~main.8f74ac51.iframe.bundle.js.br +0 -0
- package/demo/{runtime~main.962b8cd7.iframe.bundle.js.gz → runtime~main.8f74ac51.iframe.bundle.js.gz} +0 -0
- package/dist/cjs/utils/micro-frontend/guest.js +62 -18
- package/dist/cjs/utils/micro-frontend/host.js +36 -10
- package/dist/cjs/utils/micro-frontend/module-so.js +10 -12
- package/dist/cjs/utils/micro-frontend/tests/__snapshots__/guest.test.ts.snap +1 -0
- package/dist/cjs/view/guest-microapp.js +2 -0
- package/dist/cjs/view/tests/app.config.json +11 -0
- package/dist/cjs/view/tests/constants.js +2 -0
- package/dist/esm/index.js +3 -1
- package/dist/esm/utils/micro-frontend/guest.js +62 -18
- package/dist/esm/utils/micro-frontend/host.js +36 -10
- package/dist/esm/utils/micro-frontend/module-so.js +10 -12
- package/dist/esm/utils/micro-frontend/tests/__snapshots__/guest.test.ts.snap +1 -0
- package/dist/esm/view/guest-microapp.js +2 -0
- package/dist/esm/view/tests/app.config.json +11 -0
- package/dist/esm/view/tests/constants.js +2 -0
- package/dist/types/lib/index.d.ts +2 -1
- package/dist/types/lib/utils/micro-frontend/guest.d.ts +17 -6
- package/dist/types/lib/utils/micro-frontend/host.d.ts +20 -3
- package/dist/types/lib/utils/micro-frontend/module-so.d.ts +10 -6
- package/dist/types/lib/utils/micro-frontend/types.d.ts +6 -0
- package/dist/types/lib/utils/window.d.ts +1 -0
- package/dist/types/lib/view/tests/constants.d.ts +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/demo/2706.3ac48b3e.iframe.bundle.js.br +0 -0
- package/demo/2706.3ac48b3e.iframe.bundle.js.gz +0 -0
- package/demo/4018.e3bb4bb2.iframe.bundle.js.br +0 -0
- package/demo/4018.e3bb4bb2.iframe.bundle.js.gz +0 -0
- package/demo/4545.f7205e3b.iframe.bundle.js.br +0 -0
- package/demo/4545.f7205e3b.iframe.bundle.js.gz +0 -0
- package/demo/786.6c70980fba796c81e61a.manager.bundle.js.br +0 -0
- package/demo/786.6c70980fba796c81e61a.manager.bundle.js.gz +0 -0
- package/demo/docs/2706.3ac48b3e.iframe.bundle.js.br +0 -0
- package/demo/docs/2706.3ac48b3e.iframe.bundle.js.gz +0 -0
- package/demo/docs/4018.e3bb4bb2.iframe.bundle.js.br +0 -0
- package/demo/docs/4018.e3bb4bb2.iframe.bundle.js.gz +0 -0
- package/demo/docs/4545.f7205e3b.iframe.bundle.js.br +0 -0
- package/demo/docs/4545.f7205e3b.iframe.bundle.js.gz +0 -0
- package/demo/docs/786.6c70980fba796c81e61a.manager.bundle.js.br +0 -0
- package/demo/docs/786.6c70980fba796c81e61a.manager.bundle.js.gz +0 -0
- package/demo/docs/main.b2bf60fb5c3e8e222a28.manager.bundle.js.gz +0 -0
- package/demo/docs/main.d3eba28f.iframe.bundle.js +0 -5
- package/demo/docs/main.d3eba28f.iframe.bundle.js.br +0 -0
- package/demo/docs/main.d3eba28f.iframe.bundle.js.gz +0 -0
- package/demo/docs/runtime~main.962b8cd7.iframe.bundle.js.br +0 -0
- package/demo/main.b2bf60fb5c3e8e222a28.manager.bundle.js.gz +0 -0
- package/demo/main.d3eba28f.iframe.bundle.js +0 -5
- package/demo/main.d3eba28f.iframe.bundle.js.br +0 -0
- package/demo/main.d3eba28f.iframe.bundle.js.gz +0 -0
- package/demo/runtime~main.962b8cd7.iframe.bundle.js.br +0 -0
|
@@ -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 {
|
|
67
|
+
import {
|
|
68
|
+
CMicroAppHost
|
|
69
|
+
} from "./utils/micro-frontend/host.js";
|
|
68
70
|
import {
|
|
69
71
|
buildModuleParams,
|
|
70
72
|
createGuestModule,
|
|
@@ -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) {
|
|
@@ -292,12 +297,22 @@ class CMicroAppGuest {
|
|
|
292
297
|
}
|
|
293
298
|
return null;
|
|
294
299
|
}
|
|
300
|
+
#exposeGetHost() {
|
|
301
|
+
window.emui = window.emui || {};
|
|
302
|
+
window.emui.getHost = () => this.props.host ?? null;
|
|
303
|
+
}
|
|
304
|
+
async #initAppBridge() {
|
|
305
|
+
this.#appBridge = await getAppBridge();
|
|
306
|
+
}
|
|
295
307
|
#applyModuleParams(params) {
|
|
296
308
|
if (params.homeRoute) this.props.homeRoute = params.homeRoute;
|
|
297
309
|
if (params.theme) this.props.theme = params.theme;
|
|
298
310
|
if (params.hostUrl) this.props.hostUrl = params.hostUrl;
|
|
299
311
|
if (params.manifestPath)
|
|
300
312
|
this.props.manifestPath = params.manifestPath;
|
|
313
|
+
if (params.containerId) {
|
|
314
|
+
this.props.containerId = params.containerId;
|
|
315
|
+
}
|
|
301
316
|
this.#applyHistoryFromParams(params);
|
|
302
317
|
}
|
|
303
318
|
#applyHistoryFromParams(params) {
|
|
@@ -322,35 +337,60 @@ class CMicroAppGuest {
|
|
|
322
337
|
if (route) this.props.history.push(route);
|
|
323
338
|
}
|
|
324
339
|
/**
|
|
325
|
-
* Guest-initiated lifecycle: discovers the host
|
|
326
|
-
*
|
|
340
|
+
* Guest-initiated lifecycle: discovers the host and applies module
|
|
341
|
+
* parameters if available. After this resolves the guest is ready to render.
|
|
327
342
|
* Requires selfInitialize: true in the constructor so the bridge
|
|
328
343
|
* skips calling init() / mount() on this guest.
|
|
329
|
-
*
|
|
344
|
+
*
|
|
345
|
+
* The module scripting object is optional — if the host did not register
|
|
346
|
+
* one, a warning is logged and the guest proceeds with its own config.
|
|
347
|
+
* @returns module parameters provided by the host, or a minimal object with moduleId
|
|
330
348
|
*/
|
|
349
|
+
// eslint-disable-next-line max-statements, complexity
|
|
331
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
|
+
}
|
|
332
356
|
const isStandalone = window.top === window.self && !window.opener;
|
|
333
357
|
if (isStandalone) {
|
|
334
358
|
await loadAppConfig();
|
|
359
|
+
await this.#initAppBridge();
|
|
335
360
|
this.logger.info("Running in standalone mode \u2014 skipping host discovery");
|
|
336
361
|
if (this.onInit) this.onInit(this.props);
|
|
337
362
|
return { moduleId: this.appId };
|
|
338
363
|
}
|
|
339
|
-
const [host] = await Promise.all([
|
|
364
|
+
const [host] = await Promise.all([
|
|
365
|
+
this.#discoverHost(),
|
|
366
|
+
loadAppConfig().then(() => this.#initAppBridge())
|
|
367
|
+
]);
|
|
340
368
|
if (!host) {
|
|
341
369
|
throw new Error(
|
|
342
370
|
"Unable to discover host. Ensure the host uses an updated pui-app-sdk and pui-microfe, or use the host-initiated model (onInit/onMount)."
|
|
343
371
|
);
|
|
344
372
|
}
|
|
345
373
|
this.props.host = host;
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
374
|
+
this.#exposeGetHost();
|
|
375
|
+
let params = { moduleId: this.appId };
|
|
376
|
+
try {
|
|
377
|
+
const module = await host.getObject("module");
|
|
378
|
+
if (module) {
|
|
379
|
+
params = await module.getParameters();
|
|
380
|
+
this.#applyModuleParams(params);
|
|
381
|
+
} else {
|
|
382
|
+
this.logger.warn(
|
|
383
|
+
`Host did not register a module scripting object for "${this.appId}". Proceeding without host-provided parameters (history, theme, initialRoute).`
|
|
384
|
+
);
|
|
385
|
+
}
|
|
386
|
+
} catch (ex) {
|
|
387
|
+
this.logger.warn(
|
|
388
|
+
`Failed to retrieve module parameters for "${this.appId}". Proceeding without host-provided parameters.`
|
|
350
389
|
);
|
|
351
390
|
}
|
|
352
|
-
const
|
|
353
|
-
this
|
|
391
|
+
const instanceId = this.getSessionStorageItem("instanceId") || "";
|
|
392
|
+
const userId = this.getSessionStorageItem("userId") || "";
|
|
393
|
+
updateBAEventParameters({ appId: this.appId, instanceId, userId });
|
|
354
394
|
if (this.onInit) this.onInit(this.props);
|
|
355
395
|
return params;
|
|
356
396
|
}
|
|
@@ -363,6 +403,7 @@ class CMicroAppGuest {
|
|
|
363
403
|
this.props.host = host;
|
|
364
404
|
} else this.logger.warn("unable to connect to host microapp");
|
|
365
405
|
}
|
|
406
|
+
this.#exposeGetHost();
|
|
366
407
|
__webpack_public_path__ = __webpack_public_path__.replace(/\/?$/, "/");
|
|
367
408
|
return loadAppConfig().then(() => {
|
|
368
409
|
const instanceId = this.getSessionStorageItem("instanceId") || "";
|
|
@@ -378,8 +419,8 @@ class CMicroAppGuest {
|
|
|
378
419
|
});
|
|
379
420
|
});
|
|
380
421
|
}
|
|
381
|
-
mount(options = { containerId:
|
|
382
|
-
this.containerId = options?.containerId;
|
|
422
|
+
mount(options = { containerId: DEFAULT_CONTAINER_ID }) {
|
|
423
|
+
this.props.containerId = options?.containerId;
|
|
383
424
|
return Promise.resolve().then(() => {
|
|
384
425
|
if (this.#pendingInitialRoute) {
|
|
385
426
|
this.props.history.push(this.#pendingInitialRoute);
|
|
@@ -401,9 +442,12 @@ class CMicroAppGuest {
|
|
|
401
442
|
if (url) this.props.history.push(url, state);
|
|
402
443
|
}
|
|
403
444
|
/**
|
|
404
|
-
*
|
|
445
|
+
* Register a scripting object for child micro-apps to use.
|
|
446
|
+
* Adds the object to both the App Bridge and the SSF Host so guests
|
|
447
|
+
* using either transport can discover it. Always prefer this method
|
|
448
|
+
* over calling appBridge.addScriptingObject() directly.
|
|
405
449
|
* @param so - The scripting object to be added.
|
|
406
|
-
* @param params - Optional parameters
|
|
450
|
+
* @param params - Optional parameters (e.g. `{ guestId }` to scope to a specific guest).
|
|
407
451
|
*/
|
|
408
452
|
addScriptingObject(so, params) {
|
|
409
453
|
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,26 +76,47 @@ class CMicroAppHost {
|
|
|
74
76
|
leading: true
|
|
75
77
|
}
|
|
76
78
|
);
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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
|
-
}
|
|
85
|
-
});
|
|
89
|
+
}
|
|
86
90
|
updateBAEventParameters({ appId: this.appId });
|
|
87
91
|
}
|
|
88
92
|
static getInstance(params) {
|
|
89
93
|
if (!this.instance) {
|
|
90
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
|
+
}
|
|
91
100
|
}
|
|
92
101
|
return this.instance;
|
|
93
102
|
}
|
|
94
103
|
static isInitialized() {
|
|
95
104
|
return !!this.instance;
|
|
96
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* Host-initiated lifecycle: loads app config, initializes the app bridge,
|
|
108
|
+
* and calls the onInit callback. Call this instead of relying on the
|
|
109
|
+
* automatic constructor chain when `selfInitialize: true`.
|
|
110
|
+
* @returns host options (systemVersion, history, theme)
|
|
111
|
+
*/
|
|
112
|
+
async initialize() {
|
|
113
|
+
__webpack_public_path__ = __webpack_public_path__.replace(/\/?$/, "/");
|
|
114
|
+
await loadAppConfig();
|
|
115
|
+
const appBridge = await getAppBridge();
|
|
116
|
+
this.#appBridge = appBridge;
|
|
117
|
+
if (this.onInit) this.onInit(this.props);
|
|
118
|
+
return this.props;
|
|
119
|
+
}
|
|
97
120
|
getProps() {
|
|
98
121
|
return this.props;
|
|
99
122
|
}
|
|
@@ -182,9 +205,12 @@ class CMicroAppHost {
|
|
|
182
205
|
return this.scriptingObjects[name];
|
|
183
206
|
}
|
|
184
207
|
/**
|
|
185
|
-
*
|
|
208
|
+
* Register a scripting object for child micro-apps to use.
|
|
209
|
+
* Adds the object to both the App Bridge and the SSF Host so guests
|
|
210
|
+
* using either transport can discover it. Always prefer this method
|
|
211
|
+
* over calling appBridge.addScriptingObject() directly.
|
|
186
212
|
* @param so - The scripting object to be added.
|
|
187
|
-
* @param params - Optional parameters
|
|
213
|
+
* @param params - Optional parameters (e.g. `{ guestId }` to scope to a specific guest).
|
|
188
214
|
*/
|
|
189
215
|
addScriptingObject(so, params) {
|
|
190
216
|
if (this.#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
|
};
|
|
@@ -37,16 +39,12 @@ class GuestModule extends ScriptingObject {
|
|
|
37
39
|
* @param handler
|
|
38
40
|
*/
|
|
39
41
|
// eslint-disable-next-line no-underscore-dangle
|
|
40
|
-
_setUnloadHandler(handler) {
|
|
42
|
+
_setUnloadHandler = (handler) => {
|
|
41
43
|
this.#onUnload = handler;
|
|
42
|
-
}
|
|
43
|
-
getParameters()
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
getCapabilities() {
|
|
47
|
-
return Promise.resolve({});
|
|
48
|
-
}
|
|
49
|
-
log(message, logLevel) {
|
|
44
|
+
};
|
|
45
|
+
getParameters = () => Promise.resolve(this.#params);
|
|
46
|
+
getCapabilities = () => Promise.resolve({});
|
|
47
|
+
log = (message, logLevel) => {
|
|
50
48
|
const logger = window.emui?.logger;
|
|
51
49
|
if (!logger) return Promise.resolve();
|
|
52
50
|
const text = typeof message === "string" ? message : message.message;
|
|
@@ -54,11 +52,11 @@ class GuestModule extends ScriptingObject {
|
|
|
54
52
|
const logFn = logger[method];
|
|
55
53
|
if (logFn) logFn(text);
|
|
56
54
|
return Promise.resolve();
|
|
57
|
-
}
|
|
58
|
-
unload() {
|
|
55
|
+
};
|
|
56
|
+
unload = () => {
|
|
59
57
|
if (this.#onUnload) return this.#onUnload();
|
|
60
58
|
return Promise.resolve();
|
|
61
|
-
}
|
|
59
|
+
};
|
|
62
60
|
}
|
|
63
61
|
const createGuestModule = (guestId, params = {}, overrides = {}) => {
|
|
64
62
|
const mod = new GuestModule(guestId, params);
|
|
@@ -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
|
-
|
|
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';
|
|
@@ -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?;
|
|
@@ -96,11 +101,14 @@ export declare class CMicroAppGuest<AppObjects extends ScriptingObjects = Partia
|
|
|
96
101
|
private findHost;
|
|
97
102
|
get uuid(): string;
|
|
98
103
|
/**
|
|
99
|
-
* Guest-initiated lifecycle: discovers the host
|
|
100
|
-
*
|
|
104
|
+
* Guest-initiated lifecycle: discovers the host and applies module
|
|
105
|
+
* parameters if available. After this resolves the guest is ready to render.
|
|
101
106
|
* Requires selfInitialize: true in the constructor so the bridge
|
|
102
107
|
* skips calling init() / mount() on this guest.
|
|
103
|
-
*
|
|
108
|
+
*
|
|
109
|
+
* The module scripting object is optional — if the host did not register
|
|
110
|
+
* one, a warning is logged and the guest proceeds with its own config.
|
|
111
|
+
* @returns module parameters provided by the host, or a minimal object with moduleId
|
|
104
112
|
*/
|
|
105
113
|
initialize(): Promise<ModuleParameters>;
|
|
106
114
|
init(options: InitOptions<AppObjects, AppEvents>): Promise<void>;
|
|
@@ -109,9 +117,12 @@ export declare class CMicroAppGuest<AppObjects extends ScriptingObjects = Partia
|
|
|
109
117
|
getRef<T>(): T | null;
|
|
110
118
|
navigate(url: To, state?: any): void;
|
|
111
119
|
/**
|
|
112
|
-
*
|
|
120
|
+
* Register a scripting object for child micro-apps to use.
|
|
121
|
+
* Adds the object to both the App Bridge and the SSF Host so guests
|
|
122
|
+
* using either transport can discover it. Always prefer this method
|
|
123
|
+
* over calling appBridge.addScriptingObject() directly.
|
|
113
124
|
* @param so - The scripting object to be added.
|
|
114
|
-
* @param params - Optional parameters
|
|
125
|
+
* @param params - Optional parameters (e.g. `{ guestId }` to scope to a specific guest).
|
|
115
126
|
*/
|
|
116
127
|
addScriptingObject<SO extends AppObjects[keyof AppObjects]>(so: SO, params?: AddScriptingObjectParams): void;
|
|
117
128
|
/**
|
|
@@ -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
|
-
*
|
|
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
|
|
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
|
/**
|
|
@@ -42,11 +42,11 @@ export declare class GuestModule extends ScriptingObject implements IModule {
|
|
|
42
42
|
* The App Bridge auto-binds this in openApp().
|
|
43
43
|
* @param handler
|
|
44
44
|
*/
|
|
45
|
-
_setUnloadHandler(handler: () => Promise<void>)
|
|
46
|
-
getParameters()
|
|
47
|
-
getCapabilities()
|
|
48
|
-
log(message: LogMessage | string, logLevel: keyof typeof LogLevels)
|
|
49
|
-
unload()
|
|
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>;
|
|
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;
|
|
@@ -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
|
*/
|
|
@@ -15,6 +15,7 @@ export type EMUI<AppObjects extends ScriptingObjects = Partial<ScriptingObjectTy
|
|
|
15
15
|
version: string;
|
|
16
16
|
MicroAppHost?: IMicroFEHost<AppObjects, AppEvents> | IMicroAppHost | SSFGuest<AppObjects, AppEvents>;
|
|
17
17
|
__host?: IMicroFEHost<AppObjects, AppEvents>;
|
|
18
|
+
getHost?: () => IMicroFEHost<AppObjects, AppEvents> | SSFGuest<AppObjects, AppEvents> | IMicroAppHost | null;
|
|
18
19
|
logger?: Logger;
|
|
19
20
|
logRocket?: typeof LogRocket;
|
|
20
21
|
logRocketConfig?: {
|
|
@@ -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";
|