@elliemae/pui-app-sdk 5.43.0 → 5.44.1
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/build/docs/404.html +1 -1
- package/build/docs/api/classes/Analytics/index.html +1 -1
- package/build/docs/api/classes/CMicroAppGuest/index.html +1 -1
- package/build/docs/api/classes/CMicroAppHost/index.html +1 -1
- package/build/docs/api/classes/ErrorBoundary/index.html +1 -1
- package/build/docs/api/classes/GuestModule/index.html +1 -1
- package/build/docs/api/functions/AppRoot/index.html +1 -1
- package/build/docs/api/functions/Autocomplete/index.html +1 -1
- package/build/docs/api/functions/CheckBox/index.html +1 -1
- package/build/docs/api/functions/ComboBox/index.html +1 -1
- package/build/docs/api/functions/ComboBoxV3/index.html +1 -1
- package/build/docs/api/functions/ConnectForm/index.html +1 -1
- package/build/docs/api/functions/DateInput/index.html +1 -1
- package/build/docs/api/functions/DatePicker/index.html +1 -1
- package/build/docs/api/functions/DateRangePicker/index.html +1 -1
- package/build/docs/api/functions/DateTimePicker/index.html +1 -1
- package/build/docs/api/functions/Form/index.html +1 -1
- package/build/docs/api/functions/FormItemLayout/index.html +1 -1
- package/build/docs/api/functions/FormLayoutBlockItem/index.html +1 -1
- package/build/docs/api/functions/FormSubmitButton/index.html +1 -1
- package/build/docs/api/functions/InputMask/index.html +1 -1
- package/build/docs/api/functions/InputText/index.html +1 -1
- package/build/docs/api/functions/LargeTextBox/index.html +1 -1
- package/build/docs/api/functions/MaskedInputText/index.html +1 -1
- package/build/docs/api/functions/Page/index.html +1 -1
- package/build/docs/api/functions/Radio/index.html +1 -1
- package/build/docs/api/functions/RadioGroup/index.html +1 -1
- package/build/docs/api/functions/RegisterService/index.html +1 -1
- package/build/docs/api/functions/RenderWithStateAddOns/index.html +1 -1
- package/build/docs/api/functions/RequireAuth/index.html +1 -1
- package/build/docs/api/functions/SessionTimeout/index.html +1 -1
- package/build/docs/api/functions/TextBox/index.html +1 -1
- package/build/docs/api/functions/Toggle/index.html +1 -1
- package/build/docs/api/functions/authSaga/index.html +1 -1
- package/build/docs/api/functions/authorize/index.html +1 -1
- package/build/docs/api/functions/buildModuleParams/index.html +1 -1
- package/build/docs/api/functions/cleanup/index.html +1 -1
- package/build/docs/api/functions/configureStore/index.html +1 -1
- package/build/docs/api/functions/createGuestModule/index.html +1 -1
- package/build/docs/api/functions/createManager/index.html +1 -1
- package/build/docs/api/functions/enableReactAppForHostIntegration/index.html +1 -1
- package/build/docs/api/functions/fetchHostAppData/index.html +1 -1
- package/build/docs/api/functions/fetchUserSettings/index.html +1 -1
- package/build/docs/api/functions/getApiActionCreator/index.html +1 -1
- package/build/docs/api/functions/getAppConfig/index.html +1 -1
- package/build/docs/api/functions/getAppConfigValue/index.html +1 -1
- package/build/docs/api/functions/getAuthHTTPClient/index.html +1 -1
- package/build/docs/api/functions/getAuthorizationHeader/index.html +1 -1
- package/build/docs/api/functions/getHTTPClient/index.html +1 -1
- package/build/docs/api/functions/getHostAppDataByKey/index.html +1 -1
- package/build/docs/api/functions/getLogger/index.html +1 -1
- package/build/docs/api/functions/getMicroFrontEndAppConfig/index.html +1 -1
- package/build/docs/api/functions/getNavigationLinks/index.html +1 -1
- package/build/docs/api/functions/getRedirectUrl/index.html +1 -1
- package/build/docs/api/functions/getSelectField/index.html +1 -1
- package/build/docs/api/functions/getStore/index.html +1 -1
- package/build/docs/api/functions/initServiceWorker/index.html +1 -1
- package/build/docs/api/functions/isCIBuild/index.html +1 -1
- package/build/docs/api/functions/isProd/index.html +1 -1
- package/build/docs/api/functions/isUserAuthorized/index.html +1 -1
- package/build/docs/api/functions/listenStorageEvents/index.html +1 -1
- package/build/docs/api/functions/loadAppConfig/index.html +1 -1
- package/build/docs/api/functions/loadable/index.html +1 -1
- package/build/docs/api/functions/login/index.html +1 -1
- package/build/docs/api/functions/notifyGuestUnloadComplete/index.html +1 -1
- package/build/docs/api/functions/onAuthorizationFailure/index.html +1 -1
- package/build/docs/api/functions/onGuestUnloadStart/index.html +1 -1
- package/build/docs/api/functions/redactPii/index.html +1 -1
- package/build/docs/api/functions/removeDoubleSlash/index.html +1 -1
- package/build/docs/api/functions/removeStorageEvents/index.html +1 -1
- package/build/docs/api/functions/render/index.html +1 -1
- package/build/docs/api/functions/renderHook/index.html +1 -1
- package/build/docs/api/functions/renderWithHostData/index.html +1 -1
- package/build/docs/api/functions/renderWithRedux/index.html +1 -1
- package/build/docs/api/functions/renderWithRouter/index.html +1 -1
- package/build/docs/api/functions/renderWithRouterRedux/index.html +1 -1
- package/build/docs/api/functions/sdkBaseQuery/index.html +1 -1
- package/build/docs/api/functions/sendBAEvent/index.html +1 -1
- package/build/docs/api/functions/sendMessageToHost/index.html +1 -1
- package/build/docs/api/functions/setAppConfig/index.html +1 -1
- package/build/docs/api/functions/setAppConfigValue/index.html +1 -1
- package/build/docs/api/functions/setHostAppData/index.html +1 -1
- package/build/docs/api/functions/setLoginParams/index.html +1 -1
- package/build/docs/api/functions/subscribeToResetSession/index.html +1 -1
- package/build/docs/api/functions/subscribeToSessionExpiry/index.html +1 -1
- package/build/docs/api/functions/subscribeToSessionExpiryWarning/index.html +1 -1
- package/build/docs/api/functions/trackActivity/index.html +1 -1
- package/build/docs/api/functions/useAppDispatch/index.html +1 -1
- package/build/docs/api/functions/useAppMiddleware/index.html +1 -1
- package/build/docs/api/functions/useInjectQuery/index.html +1 -1
- package/build/docs/api/functions/useInjectReducer/index.html +1 -1
- package/build/docs/api/functions/useInjectSaga/index.html +1 -1
- package/build/docs/api/functions/useInjectSideEffect/index.html +1 -1
- package/build/docs/api/functions/useMediaQueryList/index.html +1 -1
- package/build/docs/api/functions/useStateSelector/index.html +1 -1
- package/build/docs/api/functions/useStateSelectorShallow/index.html +1 -1
- package/build/docs/api/functions/waitFor/index.html +1 -1
- package/build/docs/api/functions/waitForElementToBeRemoved/index.html +1 -1
- package/build/docs/api/functions/withAppDecorator/index.html +1 -1
- package/build/docs/api/index.html +1 -1
- package/build/docs/api/interfaces/AppConfig/index.html +1 -1
- package/build/docs/api/interfaces/GuestProps/index.html +1 -1
- package/build/docs/api/interfaces/UseStateSelectorOptions/index.html +1 -1
- package/build/docs/api/type-aliases/AppDispatch/index.html +1 -1
- package/build/docs/api/type-aliases/AppStore/index.html +1 -1
- package/build/docs/api/type-aliases/Await/index.html +1 -1
- package/build/docs/api/type-aliases/EMUI/index.html +1 -1
- package/build/docs/api/type-aliases/HostOptions/index.html +1 -1
- package/build/docs/api/type-aliases/HostProvidedParams/index.html +1 -1
- package/build/docs/api/type-aliases/ModuleOverrides/index.html +1 -1
- package/build/docs/api/type-aliases/OnHostInitCallback/index.html +1 -1
- package/build/docs/api/type-aliases/OnInitCallback/index.html +1 -1
- package/build/docs/api/type-aliases/OnMountCallback/index.html +1 -1
- package/build/docs/api/type-aliases/OnUnMountCallback/index.html +1 -1
- package/build/docs/api/type-aliases/RootState/index.html +1 -1
- package/build/docs/api/type-aliases/SelectStateFieldFunction/index.html +1 -1
- package/build/docs/api/variables/ErrorToast/index.html +1 -1
- package/build/docs/api/variables/FormPropsContext/index.html +1 -1
- package/build/docs/api/variables/GuestMicroApp/index.html +1 -1
- package/build/docs/api/variables/MASK_PIPES/index.html +1 -1
- package/build/docs/api/variables/MASK_TYPES/index.html +1 -1
- package/build/docs/api/variables/MicroApp/index.html +1 -1
- package/build/docs/api/variables/MicroIFrameApp/index.html +1 -1
- package/build/docs/api/variables/NavigationPrompt/index.html +1 -1
- package/build/docs/api/variables/NavigationPromptActions/index.html +1 -1
- package/build/docs/api/variables/Themes/index.html +1 -1
- package/build/docs/api/variables/VisuallyHidden/index.html +1 -1
- package/build/docs/api/variables/WaitMessage/index.html +1 -1
- package/build/docs/api/variables/act/index.html +1 -1
- package/build/docs/api/variables/ariaLive/index.html +1 -1
- package/build/docs/api/variables/auth/index.html +1 -1
- package/build/docs/api/variables/authReducer/index.html +1 -1
- package/build/docs/api/variables/clearSideEffects/index.html +1 -1
- package/build/docs/api/variables/createSideEffect/index.html +1 -1
- package/build/docs/api/variables/decorators/index.html +1 -1
- package/build/docs/api/variables/endSession/index.html +1 -1
- package/build/docs/api/variables/error/index.html +1 -1
- package/build/docs/api/variables/errorMiddleware/index.html +1 -1
- package/build/docs/api/variables/fireEvent/index.html +1 -1
- package/build/docs/api/variables/globalConstants/index.html +1 -1
- package/build/docs/api/variables/history/index.html +1 -1
- package/build/docs/api/variables/httpClientProps/index.html +1 -1
- package/build/docs/api/variables/logout/index.html +1 -1
- package/build/docs/api/variables/memoryHistory/index.html +1 -1
- package/build/docs/api/variables/removeSideEffect/index.html +1 -1
- package/build/docs/api/variables/resetUserIdleTime/index.html +1 -1
- package/build/docs/api/variables/screen/index.html +1 -1
- package/build/docs/api/variables/startSideEffect/index.html +1 -1
- package/build/docs/api/variables/updateBAEventParameters/index.html +1 -1
- package/build/docs/api/variables/useAppSelector/index.html +1 -1
- package/build/docs/api/variables/waitMessageAction/index.html +1 -1
- package/build/docs/api/variables/within/index.html +1 -1
- package/build/docs/assets/js/{main.4e072315.js → main.1bc3906d.js} +2 -2
- package/build/docs/index.html +1 -1
- package/build/docs/usage-guide/index.html +1 -1
- package/demo/{docs/1896.c36b36a3.iframe.bundle.js → 1896.f079560a.iframe.bundle.js} +1 -1
- package/demo/1896.f079560a.iframe.bundle.js.br +0 -0
- package/demo/{docs/1896.c36b36a3.iframe.bundle.js.gz → 1896.f079560a.iframe.bundle.js.gz} +0 -0
- package/demo/{1896.c36b36a3.iframe.bundle.js → docs/1896.f079560a.iframe.bundle.js} +1 -1
- package/demo/docs/1896.f079560a.iframe.bundle.js.br +0 -0
- package/demo/{1896.c36b36a3.iframe.bundle.js.gz → docs/1896.f079560a.iframe.bundle.js.gz} +0 -0
- package/demo/docs/iframe.html +1 -1
- package/demo/docs/index.html +1 -1
- package/demo/docs/main.b01a6dc6.iframe.bundle.js +5 -0
- package/demo/docs/main.b01a6dc6.iframe.bundle.js.br +0 -0
- package/demo/docs/main.b01a6dc6.iframe.bundle.js.gz +0 -0
- package/demo/docs/{main.45c6548c9a377d9f942a.manager.bundle.js → main.e50da2045dbe0d31db54.manager.bundle.js} +1 -1
- package/demo/docs/main.e50da2045dbe0d31db54.manager.bundle.js.br +0 -0
- package/demo/docs/main.e50da2045dbe0d31db54.manager.bundle.js.gz +0 -0
- package/demo/docs/project.json +1 -1
- package/demo/iframe.html +1 -1
- package/demo/index.html +1 -1
- package/demo/main.b01a6dc6.iframe.bundle.js +5 -0
- package/demo/main.b01a6dc6.iframe.bundle.js.br +0 -0
- package/demo/main.b01a6dc6.iframe.bundle.js.gz +0 -0
- package/demo/{main.45c6548c9a377d9f942a.manager.bundle.js → main.e50da2045dbe0d31db54.manager.bundle.js} +1 -1
- package/demo/main.e50da2045dbe0d31db54.manager.bundle.js.br +0 -0
- package/demo/main.e50da2045dbe0d31db54.manager.bundle.js.gz +0 -0
- package/demo/project.json +1 -1
- package/dist/cjs/utils/micro-frontend/guest.js +86 -56
- package/dist/cjs/utils/micro-frontend/tests/__snapshots__/guest.test.ts.snap +1 -12
- package/dist/esm/utils/micro-frontend/guest.js +86 -56
- package/dist/esm/utils/micro-frontend/tests/__snapshots__/guest.test.ts.snap +1 -12
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/demo/1896.c36b36a3.iframe.bundle.js.br +0 -0
- package/demo/docs/1896.c36b36a3.iframe.bundle.js.br +0 -0
- package/demo/docs/main.45c6548c9a377d9f942a.manager.bundle.js.br +0 -0
- package/demo/docs/main.45c6548c9a377d9f942a.manager.bundle.js.gz +0 -0
- package/demo/docs/main.639b7a1f.iframe.bundle.js +0 -5
- package/demo/docs/main.639b7a1f.iframe.bundle.js.br +0 -0
- package/demo/docs/main.639b7a1f.iframe.bundle.js.gz +0 -0
- package/demo/main.45c6548c9a377d9f942a.manager.bundle.js.br +0 -0
- package/demo/main.45c6548c9a377d9f942a.manager.bundle.js.gz +0 -0
- package/demo/main.639b7a1f.iframe.bundle.js +0 -5
- package/demo/main.639b7a1f.iframe.bundle.js.br +0 -0
- package/demo/main.639b7a1f.iframe.bundle.js.gz +0 -0
- /package/build/docs/assets/js/{main.4e072315.js.LICENSE.txt → main.1bc3906d.js.LICENSE.txt} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
(globalThis.webpackChunk_elliemae_pui_app_sdk=globalThis.webpackChunk_elliemae_pui_app_sdk||[]).push([[792],{11792(i,t,o){"use strict";var p=o(59443),m=o(96778),v=Object.defineProperty,l=Object.getOwnPropertySymbols,s=Object.prototype.hasOwnProperty,_=Object.prototype.propertyIsEnumerable,f=(e,a,r)=>a in e?v(e,a,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[a]=r,b=(e,a)=>{for(var r in a||(a={}))s.call(a,r)&&f(e,r,a[r]);if(l)for(var r of l(a))_.call(a,r)&&f(e,r,a[r]);return e},d=(e,a)=>{var r={};for(var n in e)s.call(e,n)&&a.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&l)for(var n of l(e))a.indexOf(n)<0&&_.call(e,n)&&(r[n]=e[n]);return r};const h=e=>{var a=e,{base:r="light",brandTitle:n="Platform UI Components"}=a,u=d(a,["base","brandTitle"]);return(0,m.vt)(b({base:r,brandTitle:`${n} v5.
|
|
1
|
+
(globalThis.webpackChunk_elliemae_pui_app_sdk=globalThis.webpackChunk_elliemae_pui_app_sdk||[]).push([[792],{11792(i,t,o){"use strict";var p=o(59443),m=o(96778),v=Object.defineProperty,l=Object.getOwnPropertySymbols,s=Object.prototype.hasOwnProperty,_=Object.prototype.propertyIsEnumerable,f=(e,a,r)=>a in e?v(e,a,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[a]=r,b=(e,a)=>{for(var r in a||(a={}))s.call(a,r)&&f(e,r,a[r]);if(l)for(var r of l(a))_.call(a,r)&&f(e,r,a[r]);return e},d=(e,a)=>{var r={};for(var n in e)s.call(e,n)&&a.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&l)for(var n of l(e))a.indexOf(n)<0&&_.call(e,n)&&(r[n]=e[n]);return r};const h=e=>{var a=e,{base:r="light",brandTitle:n="Platform UI Components"}=a,u=d(a,["base","brandTitle"]);return(0,m.vt)(b({base:r,brandTitle:`${n} v5.44.1`},u))};(e=>{p.MC.setConfig({panelPosition:"bottom",theme:h(e)})})({brandTitle:"Application SDK",brandUrl:"https://git.elliemae.io/platform-ui/pui-app-sdk.git"})},22179(){}},i=>{var t=p=>i(i.s=p);i.O(0,[659],()=>(t(54176),t(11792),t(68082),t(34023),t(72247),t(40652),t(41420),t(48510),t(75963),t(4547),t(15869),t(74157),t(28061),t(99789),t(40166),t(29923)));var o=i.O()}]);
|
|
Binary file
|
|
Binary file
|
package/demo/project.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"generatedAt":
|
|
1
|
+
{"generatedAt":1784919464096,"builder":{"name":"webpack5"},"hasCustomBabel":false,"hasCustomWebpack":true,"hasStaticDirs":false,"hasStorybookEslint":false,"refCount":0,"packageManager":{"type":"pnpm","version":"8.15.9"},"typescriptOptions":{"check":false,"checkOptions":{},"reactDocgen":false,"reactDocgenTypescriptOptions":{"shouldExtractLiteralValuesFromEnum":true,"compilerOptions":{"allowSyntheticDefaultImports":false,"esModuleInterop":false}}},"features":{"fastRefresh":true,"storyStoreV7":true},"language":"javascript","storybookPackages":{},"framework":{"options":{"fastRefresh":true,"strictMode":true,"legacyRootApi":true}},"addons":{"@storybook/addon-docs":{"options":{"sourceLoaderOptions":{"injectStoryParameters":false}},"version":"6.5.16"},"@storybook/addon-essentials":{"options":{"docs":false},"version":"6.5.16"},"@storybook/addon-storysource":{"version":"6.5.16"},"@storybook/addon-links":{"version":"6.5.16"},"@storybook/addon-events":{"version":"6.2.9"},"@storybook/addon-interactions":{"version":"6.5.16"},"@storybook/addon-a11y":{"version":"6.5.16"},"storybook-addon-turbo-build":{"options":{"optimizationLevel":2,"esbuildMinifyOptions":{"target":"es2022"}},"version":"1.1.0"}}}
|
|
@@ -49,6 +49,7 @@ var import_ssf_host2 = require("./ssf-host.js");
|
|
|
49
49
|
var import_webpack_public_path = require("./webpack-public-path.js");
|
|
50
50
|
const DEFAULT_CONTAINER_ID = "app-container";
|
|
51
51
|
const MODULE_SCRIPTING_OBJECT_TIMEOUT_MS = 2e3;
|
|
52
|
+
const SSF_CONNECT_TIMEOUT_MS = 1e3;
|
|
52
53
|
const isCrossDomain = () => {
|
|
53
54
|
try {
|
|
54
55
|
window.parent.document;
|
|
@@ -224,11 +225,20 @@ class CMicroAppGuest {
|
|
|
224
225
|
const browserWindow = (0, import_window.getWindow)();
|
|
225
226
|
if (!browserWindow) return;
|
|
226
227
|
browserWindow.emui = browserWindow.emui || {};
|
|
228
|
+
const performUnmount = this.unmount.bind(this);
|
|
227
229
|
const app = {
|
|
228
230
|
uuid: this.#uuid,
|
|
229
231
|
init: this.init.bind(this),
|
|
230
232
|
mount: this.mount.bind(this),
|
|
231
|
-
unmount:
|
|
233
|
+
unmount: (options) => {
|
|
234
|
+
if (options?.containerId) {
|
|
235
|
+
this.props.containerId = options.containerId;
|
|
236
|
+
}
|
|
237
|
+
if (this.props.host) {
|
|
238
|
+
return this.#internalTeardown().then(() => null);
|
|
239
|
+
}
|
|
240
|
+
return performUnmount(options);
|
|
241
|
+
},
|
|
232
242
|
getRef: this.getRef.bind(this),
|
|
233
243
|
navigate: this.navigate.bind(this)
|
|
234
244
|
};
|
|
@@ -257,23 +267,36 @@ class CMicroAppGuest {
|
|
|
257
267
|
window.emui.app = app;
|
|
258
268
|
window.addEventListener("beforeunload", this.#boundOnWindowUnload);
|
|
259
269
|
}
|
|
270
|
+
/**
|
|
271
|
+
* Removes legacy registerApp entries from the parent window and current window.
|
|
272
|
+
*/
|
|
273
|
+
#removeLegacyGlobalRegistration() {
|
|
274
|
+
if (this.#selfInitialize) return;
|
|
275
|
+
const browserWindow = (0, import_window.getWindow)();
|
|
276
|
+
if (!browserWindow?.emui) return;
|
|
277
|
+
if (Array.isArray(browserWindow.emui[this.appId])) {
|
|
278
|
+
const existingApps = browserWindow.emui[this.appId];
|
|
279
|
+
const index = existingApps.findIndex((app) => app.uuid === this.#uuid);
|
|
280
|
+
if (index > -1) existingApps.splice(index, 1);
|
|
281
|
+
if (existingApps.length === 0) {
|
|
282
|
+
delete browserWindow.emui[this.appId];
|
|
283
|
+
}
|
|
284
|
+
} else {
|
|
285
|
+
delete browserWindow.emui[this.appId];
|
|
286
|
+
}
|
|
287
|
+
delete window.emui.app;
|
|
288
|
+
}
|
|
260
289
|
/**
|
|
261
290
|
* remove the microapp from the global variable from the parent window and current window
|
|
262
291
|
*/
|
|
263
292
|
#onWindowUnload() {
|
|
293
|
+
if (this.props.host) {
|
|
294
|
+
this.#internalTeardown().catch(() => {
|
|
295
|
+
});
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
264
298
|
if (!this.#selfInitialize) {
|
|
265
|
-
|
|
266
|
-
if (Array.isArray(browserWindow.emui[this.appId])) {
|
|
267
|
-
const existingApps = browserWindow.emui[this.appId];
|
|
268
|
-
const index = existingApps.findIndex((app) => app.uuid === this.#uuid);
|
|
269
|
-
if (index > -1) existingApps.splice(index, 1);
|
|
270
|
-
if (existingApps.length === 0) {
|
|
271
|
-
delete browserWindow.emui[this.appId];
|
|
272
|
-
}
|
|
273
|
-
} else {
|
|
274
|
-
delete browserWindow.emui[this.appId];
|
|
275
|
-
}
|
|
276
|
-
delete window.emui.app;
|
|
299
|
+
this.#removeLegacyGlobalRegistration();
|
|
277
300
|
this.unmount({ containerId: this.props.containerId }).catch(() => {
|
|
278
301
|
});
|
|
279
302
|
return;
|
|
@@ -289,22 +312,31 @@ class CMicroAppGuest {
|
|
|
289
312
|
}
|
|
290
313
|
return value;
|
|
291
314
|
}
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
promise:
|
|
301
|
-
delay:
|
|
302
|
-
retValue:
|
|
303
|
-
})
|
|
304
|
-
|
|
305
|
-
|
|
315
|
+
#getLegacyParentHost() {
|
|
316
|
+
if (isCrossDomain()) return null;
|
|
317
|
+
return window.parent?.emui?.MicroAppHost ?? null;
|
|
318
|
+
}
|
|
319
|
+
async #tryConnectSSFGuest() {
|
|
320
|
+
const ssfGuest = new import_ssf_guest.SSFGuest({ appLogger: this.logger });
|
|
321
|
+
try {
|
|
322
|
+
const failed = await (0, import_helpers.abortPromise)({
|
|
323
|
+
promise: ssfGuest.connect(),
|
|
324
|
+
delay: SSF_CONNECT_TIMEOUT_MS,
|
|
325
|
+
retValue: true
|
|
326
|
+
});
|
|
327
|
+
if (!failed) {
|
|
328
|
+
this.#communicationMethod = "ssf" /* SSF */;
|
|
329
|
+
return ssfGuest;
|
|
330
|
+
}
|
|
331
|
+
} catch {
|
|
306
332
|
}
|
|
307
|
-
return
|
|
333
|
+
return null;
|
|
334
|
+
}
|
|
335
|
+
async findHost() {
|
|
336
|
+
const legacyHost = this.#getLegacyParentHost();
|
|
337
|
+
if (legacyHost) return legacyHost;
|
|
338
|
+
if (!this.#useV2Guest) return null;
|
|
339
|
+
return this.#tryConnectSSFGuest();
|
|
308
340
|
}
|
|
309
341
|
get uuid() {
|
|
310
342
|
return this.#uuid;
|
|
@@ -340,23 +372,10 @@ class CMicroAppGuest {
|
|
|
340
372
|
if (window.emui?.__host) {
|
|
341
373
|
return window.emui.__host;
|
|
342
374
|
}
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
if (this.#useV2Guest) {
|
|
348
|
-
const ssfGuest = new import_ssf_guest.SSFGuest({ appLogger: this.logger });
|
|
349
|
-
const failed = await (0, import_helpers.abortPromise)({
|
|
350
|
-
promise: ssfGuest.connect(),
|
|
351
|
-
delay: 1e3,
|
|
352
|
-
retValue: true
|
|
353
|
-
});
|
|
354
|
-
if (!failed) {
|
|
355
|
-
this.#communicationMethod = "ssf" /* SSF */;
|
|
356
|
-
return ssfGuest;
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
return null;
|
|
375
|
+
const legacyHost = this.#getLegacyParentHost();
|
|
376
|
+
if (legacyHost) return legacyHost;
|
|
377
|
+
if (!this.#useV2Guest) return null;
|
|
378
|
+
return this.#tryConnectSSFGuest();
|
|
360
379
|
}
|
|
361
380
|
#exposeGetHost() {
|
|
362
381
|
window.emui = window.emui || {};
|
|
@@ -413,9 +432,13 @@ class CMicroAppGuest {
|
|
|
413
432
|
*/
|
|
414
433
|
#internalTeardown() {
|
|
415
434
|
if (!this.#hostTeardownPromise) {
|
|
416
|
-
this.#hostTeardownPromise =
|
|
417
|
-
|
|
418
|
-
}).then(
|
|
435
|
+
this.#hostTeardownPromise = Promise.resolve().then(() => {
|
|
436
|
+
this.#removeLegacyGlobalRegistration();
|
|
437
|
+
}).then(
|
|
438
|
+
() => this.unmount({
|
|
439
|
+
containerId: this.props.containerId
|
|
440
|
+
})
|
|
441
|
+
).then(() => {
|
|
419
442
|
this.#unbindModuleUnmountListener();
|
|
420
443
|
}).catch((err) => {
|
|
421
444
|
this.#hostTeardownPromise = null;
|
|
@@ -425,16 +448,22 @@ class CMicroAppGuest {
|
|
|
425
448
|
return this.#hostTeardownPromise;
|
|
426
449
|
}
|
|
427
450
|
/**
|
|
428
|
-
*
|
|
429
|
-
*
|
|
451
|
+
* Hosted guests subscribe to `module.unmount` so the host can signal SDK
|
|
452
|
+
* teardown after the `module.unloading` veto phase (SSF always; App Bridge
|
|
453
|
+
* when selfInitialize is true).
|
|
430
454
|
*/
|
|
431
455
|
#bindModuleUnmountListener() {
|
|
432
|
-
if (
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
456
|
+
if (this.#moduleUnmountSubToken || !this.props.host) return;
|
|
457
|
+
try {
|
|
458
|
+
this.#moduleUnmountSubToken = this.subscribe({
|
|
459
|
+
eventId: MODULE_UNMOUNT_EVENT_ID,
|
|
460
|
+
callback: this.#handleModuleUnmount
|
|
461
|
+
});
|
|
462
|
+
} catch {
|
|
463
|
+
this.logger.warn(
|
|
464
|
+
"Unable to subscribe to module.unmount from host \u2014 continuing without host teardown listener"
|
|
465
|
+
);
|
|
466
|
+
}
|
|
438
467
|
}
|
|
439
468
|
#unbindModuleUnmountListener() {
|
|
440
469
|
if (!this.#moduleUnmountSubToken) return;
|
|
@@ -549,6 +578,7 @@ class CMicroAppGuest {
|
|
|
549
578
|
return (0, import_app_bridge.getAppBridge)().then((appBridge) => {
|
|
550
579
|
this.#appBridge = appBridge;
|
|
551
580
|
if (this.onInit) this.onInit(this.props);
|
|
581
|
+
this.#bindModuleUnmountListener();
|
|
552
582
|
});
|
|
553
583
|
});
|
|
554
584
|
}
|
|
@@ -21,18 +21,7 @@ exports[`CMicroAppGuest - Standalone calls onInit 1`] = `
|
|
|
21
21
|
"push": [Function],
|
|
22
22
|
"replace": [Function],
|
|
23
23
|
},
|
|
24
|
-
"host":
|
|
25
|
-
"addScript": [Function],
|
|
26
|
-
"close": [Function],
|
|
27
|
-
"connect": [Function],
|
|
28
|
-
"getAuthToken": [Function],
|
|
29
|
-
"getObject": [Function],
|
|
30
|
-
"listObjects": [Function],
|
|
31
|
-
"removeScript": [Function],
|
|
32
|
-
"setLogLevel": [Function],
|
|
33
|
-
"subscribe": [Function],
|
|
34
|
-
"unsubscribe": [Function],
|
|
35
|
-
},
|
|
24
|
+
"host": null,
|
|
36
25
|
"hostUrl": null,
|
|
37
26
|
"manifestPath": "./latest",
|
|
38
27
|
"prevState": null,
|
|
@@ -16,6 +16,7 @@ import { getSSFHost, setSSFHost } from "./ssf-host.js";
|
|
|
16
16
|
import { syncWebpackPublicPathFromAssetPath } from "./webpack-public-path.js";
|
|
17
17
|
const DEFAULT_CONTAINER_ID = "app-container";
|
|
18
18
|
const MODULE_SCRIPTING_OBJECT_TIMEOUT_MS = 2e3;
|
|
19
|
+
const SSF_CONNECT_TIMEOUT_MS = 1e3;
|
|
19
20
|
const isCrossDomain = () => {
|
|
20
21
|
try {
|
|
21
22
|
window.parent.document;
|
|
@@ -191,11 +192,20 @@ class CMicroAppGuest {
|
|
|
191
192
|
const browserWindow = getWindow();
|
|
192
193
|
if (!browserWindow) return;
|
|
193
194
|
browserWindow.emui = browserWindow.emui || {};
|
|
195
|
+
const performUnmount = this.unmount.bind(this);
|
|
194
196
|
const app = {
|
|
195
197
|
uuid: this.#uuid,
|
|
196
198
|
init: this.init.bind(this),
|
|
197
199
|
mount: this.mount.bind(this),
|
|
198
|
-
unmount:
|
|
200
|
+
unmount: (options) => {
|
|
201
|
+
if (options?.containerId) {
|
|
202
|
+
this.props.containerId = options.containerId;
|
|
203
|
+
}
|
|
204
|
+
if (this.props.host) {
|
|
205
|
+
return this.#internalTeardown().then(() => null);
|
|
206
|
+
}
|
|
207
|
+
return performUnmount(options);
|
|
208
|
+
},
|
|
199
209
|
getRef: this.getRef.bind(this),
|
|
200
210
|
navigate: this.navigate.bind(this)
|
|
201
211
|
};
|
|
@@ -224,23 +234,36 @@ class CMicroAppGuest {
|
|
|
224
234
|
window.emui.app = app;
|
|
225
235
|
window.addEventListener("beforeunload", this.#boundOnWindowUnload);
|
|
226
236
|
}
|
|
237
|
+
/**
|
|
238
|
+
* Removes legacy registerApp entries from the parent window and current window.
|
|
239
|
+
*/
|
|
240
|
+
#removeLegacyGlobalRegistration() {
|
|
241
|
+
if (this.#selfInitialize) return;
|
|
242
|
+
const browserWindow = getWindow();
|
|
243
|
+
if (!browserWindow?.emui) return;
|
|
244
|
+
if (Array.isArray(browserWindow.emui[this.appId])) {
|
|
245
|
+
const existingApps = browserWindow.emui[this.appId];
|
|
246
|
+
const index = existingApps.findIndex((app) => app.uuid === this.#uuid);
|
|
247
|
+
if (index > -1) existingApps.splice(index, 1);
|
|
248
|
+
if (existingApps.length === 0) {
|
|
249
|
+
delete browserWindow.emui[this.appId];
|
|
250
|
+
}
|
|
251
|
+
} else {
|
|
252
|
+
delete browserWindow.emui[this.appId];
|
|
253
|
+
}
|
|
254
|
+
delete window.emui.app;
|
|
255
|
+
}
|
|
227
256
|
/**
|
|
228
257
|
* remove the microapp from the global variable from the parent window and current window
|
|
229
258
|
*/
|
|
230
259
|
#onWindowUnload() {
|
|
260
|
+
if (this.props.host) {
|
|
261
|
+
this.#internalTeardown().catch(() => {
|
|
262
|
+
});
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
231
265
|
if (!this.#selfInitialize) {
|
|
232
|
-
|
|
233
|
-
if (Array.isArray(browserWindow.emui[this.appId])) {
|
|
234
|
-
const existingApps = browserWindow.emui[this.appId];
|
|
235
|
-
const index = existingApps.findIndex((app) => app.uuid === this.#uuid);
|
|
236
|
-
if (index > -1) existingApps.splice(index, 1);
|
|
237
|
-
if (existingApps.length === 0) {
|
|
238
|
-
delete browserWindow.emui[this.appId];
|
|
239
|
-
}
|
|
240
|
-
} else {
|
|
241
|
-
delete browserWindow.emui[this.appId];
|
|
242
|
-
}
|
|
243
|
-
delete window.emui.app;
|
|
266
|
+
this.#removeLegacyGlobalRegistration();
|
|
244
267
|
this.unmount({ containerId: this.props.containerId }).catch(() => {
|
|
245
268
|
});
|
|
246
269
|
return;
|
|
@@ -256,22 +279,31 @@ class CMicroAppGuest {
|
|
|
256
279
|
}
|
|
257
280
|
return value;
|
|
258
281
|
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
promise:
|
|
268
|
-
delay:
|
|
269
|
-
retValue:
|
|
270
|
-
})
|
|
271
|
-
|
|
272
|
-
|
|
282
|
+
#getLegacyParentHost() {
|
|
283
|
+
if (isCrossDomain()) return null;
|
|
284
|
+
return window.parent?.emui?.MicroAppHost ?? null;
|
|
285
|
+
}
|
|
286
|
+
async #tryConnectSSFGuest() {
|
|
287
|
+
const ssfGuest = new SSFGuest({ appLogger: this.logger });
|
|
288
|
+
try {
|
|
289
|
+
const failed = await abortPromise({
|
|
290
|
+
promise: ssfGuest.connect(),
|
|
291
|
+
delay: SSF_CONNECT_TIMEOUT_MS,
|
|
292
|
+
retValue: true
|
|
293
|
+
});
|
|
294
|
+
if (!failed) {
|
|
295
|
+
this.#communicationMethod = "ssf" /* SSF */;
|
|
296
|
+
return ssfGuest;
|
|
297
|
+
}
|
|
298
|
+
} catch {
|
|
273
299
|
}
|
|
274
|
-
return
|
|
300
|
+
return null;
|
|
301
|
+
}
|
|
302
|
+
async findHost() {
|
|
303
|
+
const legacyHost = this.#getLegacyParentHost();
|
|
304
|
+
if (legacyHost) return legacyHost;
|
|
305
|
+
if (!this.#useV2Guest) return null;
|
|
306
|
+
return this.#tryConnectSSFGuest();
|
|
275
307
|
}
|
|
276
308
|
get uuid() {
|
|
277
309
|
return this.#uuid;
|
|
@@ -307,23 +339,10 @@ class CMicroAppGuest {
|
|
|
307
339
|
if (window.emui?.__host) {
|
|
308
340
|
return window.emui.__host;
|
|
309
341
|
}
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
if (this.#useV2Guest) {
|
|
315
|
-
const ssfGuest = new SSFGuest({ appLogger: this.logger });
|
|
316
|
-
const failed = await abortPromise({
|
|
317
|
-
promise: ssfGuest.connect(),
|
|
318
|
-
delay: 1e3,
|
|
319
|
-
retValue: true
|
|
320
|
-
});
|
|
321
|
-
if (!failed) {
|
|
322
|
-
this.#communicationMethod = "ssf" /* SSF */;
|
|
323
|
-
return ssfGuest;
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
return null;
|
|
342
|
+
const legacyHost = this.#getLegacyParentHost();
|
|
343
|
+
if (legacyHost) return legacyHost;
|
|
344
|
+
if (!this.#useV2Guest) return null;
|
|
345
|
+
return this.#tryConnectSSFGuest();
|
|
327
346
|
}
|
|
328
347
|
#exposeGetHost() {
|
|
329
348
|
window.emui = window.emui || {};
|
|
@@ -380,9 +399,13 @@ class CMicroAppGuest {
|
|
|
380
399
|
*/
|
|
381
400
|
#internalTeardown() {
|
|
382
401
|
if (!this.#hostTeardownPromise) {
|
|
383
|
-
this.#hostTeardownPromise =
|
|
384
|
-
|
|
385
|
-
}).then(
|
|
402
|
+
this.#hostTeardownPromise = Promise.resolve().then(() => {
|
|
403
|
+
this.#removeLegacyGlobalRegistration();
|
|
404
|
+
}).then(
|
|
405
|
+
() => this.unmount({
|
|
406
|
+
containerId: this.props.containerId
|
|
407
|
+
})
|
|
408
|
+
).then(() => {
|
|
386
409
|
this.#unbindModuleUnmountListener();
|
|
387
410
|
}).catch((err) => {
|
|
388
411
|
this.#hostTeardownPromise = null;
|
|
@@ -392,16 +415,22 @@ class CMicroAppGuest {
|
|
|
392
415
|
return this.#hostTeardownPromise;
|
|
393
416
|
}
|
|
394
417
|
/**
|
|
395
|
-
*
|
|
396
|
-
*
|
|
418
|
+
* Hosted guests subscribe to `module.unmount` so the host can signal SDK
|
|
419
|
+
* teardown after the `module.unloading` veto phase (SSF always; App Bridge
|
|
420
|
+
* when selfInitialize is true).
|
|
397
421
|
*/
|
|
398
422
|
#bindModuleUnmountListener() {
|
|
399
|
-
if (
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
423
|
+
if (this.#moduleUnmountSubToken || !this.props.host) return;
|
|
424
|
+
try {
|
|
425
|
+
this.#moduleUnmountSubToken = this.subscribe({
|
|
426
|
+
eventId: MODULE_UNMOUNT_EVENT_ID,
|
|
427
|
+
callback: this.#handleModuleUnmount
|
|
428
|
+
});
|
|
429
|
+
} catch {
|
|
430
|
+
this.logger.warn(
|
|
431
|
+
"Unable to subscribe to module.unmount from host \u2014 continuing without host teardown listener"
|
|
432
|
+
);
|
|
433
|
+
}
|
|
405
434
|
}
|
|
406
435
|
#unbindModuleUnmountListener() {
|
|
407
436
|
if (!this.#moduleUnmountSubToken) return;
|
|
@@ -516,6 +545,7 @@ class CMicroAppGuest {
|
|
|
516
545
|
return getAppBridge().then((appBridge) => {
|
|
517
546
|
this.#appBridge = appBridge;
|
|
518
547
|
if (this.onInit) this.onInit(this.props);
|
|
548
|
+
this.#bindModuleUnmountListener();
|
|
519
549
|
});
|
|
520
550
|
});
|
|
521
551
|
}
|
|
@@ -21,18 +21,7 @@ exports[`CMicroAppGuest - Standalone calls onInit 1`] = `
|
|
|
21
21
|
"push": [Function],
|
|
22
22
|
"replace": [Function],
|
|
23
23
|
},
|
|
24
|
-
"host":
|
|
25
|
-
"addScript": [Function],
|
|
26
|
-
"close": [Function],
|
|
27
|
-
"connect": [Function],
|
|
28
|
-
"getAuthToken": [Function],
|
|
29
|
-
"getObject": [Function],
|
|
30
|
-
"listObjects": [Function],
|
|
31
|
-
"removeScript": [Function],
|
|
32
|
-
"setLogLevel": [Function],
|
|
33
|
-
"subscribe": [Function],
|
|
34
|
-
"unsubscribe": [Function],
|
|
35
|
-
},
|
|
24
|
+
"host": null,
|
|
36
25
|
"hostUrl": null,
|
|
37
26
|
"manifestPath": "./latest",
|
|
38
27
|
"prevState": null,
|