@elliemae/pui-app-bridge 2.29.0-alpha.0 → 2.29.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.
- package/dist/cjs/appBridge.js +88 -35
- package/dist/cjs/config/app.js +7 -2
- package/dist/cjs/config/microFE.js +28 -30
- package/dist/cjs/eventManager.js +6 -7
- package/dist/cjs/frame.js +7 -10
- package/dist/cjs/loaders/manifest.js +1 -1
- package/dist/cjs/microfeHost.js +2 -5
- package/dist/cjs/tests/scriptingObjects/analytics.js +21 -6
- package/dist/cjs/tests/scriptingObjects/appraisalServiceModule.js +4 -1
- package/dist/cjs/tests/utils.js +1 -76
- package/dist/cjs/typings/window.js +1 -1
- package/dist/esm/appBridge.js +88 -35
- package/dist/esm/config/app.js +7 -2
- package/dist/esm/config/microFE.js +28 -30
- package/dist/esm/eventManager.js +6 -7
- package/dist/esm/frame.js +7 -10
- package/dist/esm/loaders/manifest.js +1 -1
- package/dist/esm/microfeHost.js +2 -5
- package/dist/esm/tests/scriptingObjects/analytics.js +21 -6
- package/dist/esm/tests/scriptingObjects/appraisalServiceModule.js +4 -1
- package/dist/esm/tests/serverHandlers.js +1 -3
- package/dist/esm/tests/utils.js +1 -76
- package/dist/esm/typings/window.js +1 -1
- package/dist/public/e2e-host.html +1 -1
- package/dist/public/e2e-index.html +1 -1
- package/dist/public/frame.html +1 -1
- package/dist/public/index.html +1 -1
- package/dist/public/js/emuiAppBridge.02aa5aed856e7e070591.js +17 -0
- package/dist/public/js/emuiAppBridge.02aa5aed856e7e070591.js.br +0 -0
- package/dist/public/js/emuiAppBridge.02aa5aed856e7e070591.js.gz +0 -0
- package/dist/public/js/emuiAppBridge.02aa5aed856e7e070591.js.map +1 -0
- package/dist/types/lib/appBridge.d.ts +6 -6
- package/dist/types/lib/appRegistry.d.ts +1 -1
- package/dist/types/lib/config/app.d.ts +1 -1
- package/dist/types/lib/config/microFE.d.ts +2 -2
- package/dist/types/lib/eventManager.d.ts +3 -3
- package/dist/types/lib/loaders/script.d.ts +1 -1
- package/dist/types/lib/loaders/style.d.ts +1 -1
- package/dist/types/lib/microfeHost.d.ts +6 -5
- package/dist/types/lib/tests/scriptingObjects/analytics.d.ts +5 -5
- package/dist/types/lib/tests/scriptingObjects/appraisalServiceModule.d.ts +5 -8
- package/dist/types/lib/tests/scriptingObjects/global.d.ts +1 -1
- package/dist/types/lib/tests/server.d.ts +1 -1
- package/dist/types/lib/tests/serverHandlers.d.ts +1 -1
- package/dist/types/lib/tests/utils.d.ts +2 -64
- package/dist/types/lib/typings/appInfo.d.ts +1 -1
- package/dist/types/lib/typings/common.d.ts +0 -10
- package/dist/types/lib/typings/guest.d.ts +6 -6
- package/dist/types/lib/typings/host.d.ts +4 -4
- package/dist/types/lib/typings/index.d.ts +1 -1
- package/dist/types/lib/typings/window.d.ts +4 -4
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/dist/umd/index.js +14 -9
- package/dist/umd/index.js.br +0 -0
- package/dist/umd/index.js.gz +0 -0
- package/dist/umd/index.js.map +1 -1
- package/package.json +13 -14
- package/dist/public/js/emuiAppBridge.e4cfaa7d8c810b09c233.js +0 -12
- package/dist/public/js/emuiAppBridge.e4cfaa7d8c810b09c233.js.br +0 -0
- package/dist/public/js/emuiAppBridge.e4cfaa7d8c810b09c233.js.gz +0 -0
- package/dist/public/js/emuiAppBridge.e4cfaa7d8c810b09c233.js.map +0 -1
package/dist/cjs/appBridge.js
CHANGED
|
@@ -44,6 +44,11 @@ var import_loaders = require("./loaders/index.js");
|
|
|
44
44
|
var import_microfeHost = require("./microfeHost.js");
|
|
45
45
|
var import_appRegistry = require("./appRegistry.js");
|
|
46
46
|
const KEEP_ALIVE_INTERVAL = 12e4;
|
|
47
|
+
const MODULE_UNLOADING_EVENT = "module.unloading";
|
|
48
|
+
const MODULE_UNMOUNT_EVENT = "module.unmount";
|
|
49
|
+
const MODULE_EVENT_TIMEOUT_MS = 1e3;
|
|
50
|
+
const MODULE_EVENT_STUB = new import_microfe_common.ScriptingObject(import_pui_scripting_object.ScriptingObjectNames.Module);
|
|
51
|
+
const isModuleUnloadVetoed = (feedback) => Array.isArray(feedback) && feedback.some((v) => v === false);
|
|
47
52
|
const userInteractionEvents = ["click", "scroll", "keypress", "touchstart"];
|
|
48
53
|
const cssType = /\.css$/;
|
|
49
54
|
const isCss = (fileName) => cssType.test(fileName);
|
|
@@ -123,13 +128,12 @@ class CAppBridge {
|
|
|
123
128
|
* @param value
|
|
124
129
|
* @returns
|
|
125
130
|
*/
|
|
126
|
-
#isProxyEvent = (value) =>
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
};
|
|
131
|
+
#isProxyEvent = (value) => (
|
|
132
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
133
|
+
value instanceof import_microfe_common.ProxyEvent || // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
134
|
+
typeof value?.subscribe === "function"
|
|
135
|
+
);
|
|
136
|
+
// support v1 scripting objects
|
|
133
137
|
/**
|
|
134
138
|
* format error message for app not found
|
|
135
139
|
* @param id app id
|
|
@@ -166,7 +170,8 @@ class CAppBridge {
|
|
|
166
170
|
instanceId,
|
|
167
171
|
documentEle,
|
|
168
172
|
elementIds,
|
|
169
|
-
microFEHost
|
|
173
|
+
microFEHost,
|
|
174
|
+
selfInitialize
|
|
170
175
|
}) => {
|
|
171
176
|
const app = this.#appRegistry.get({ id, instanceId });
|
|
172
177
|
if (!app) {
|
|
@@ -180,7 +185,8 @@ class CAppBridge {
|
|
|
180
185
|
guestWindow: documentEle?.defaultView,
|
|
181
186
|
...app
|
|
182
187
|
},
|
|
183
|
-
microFEHost
|
|
188
|
+
microFEHost,
|
|
189
|
+
selfInitialize
|
|
184
190
|
});
|
|
185
191
|
};
|
|
186
192
|
#initApplication = async ({
|
|
@@ -253,7 +259,8 @@ class CAppBridge {
|
|
|
253
259
|
instanceId,
|
|
254
260
|
documentEle,
|
|
255
261
|
elementIds: [...styleElementIds, ...scriptElementIds],
|
|
256
|
-
microFEHost: options.microFEHost
|
|
262
|
+
microFEHost: options.microFEHost,
|
|
263
|
+
selfInitialize: options.selfInitialize
|
|
257
264
|
});
|
|
258
265
|
if (!options.selfInitialize) {
|
|
259
266
|
await this.#initApplication(options);
|
|
@@ -268,7 +275,7 @@ class CAppBridge {
|
|
|
268
275
|
appId: options.id,
|
|
269
276
|
exception: err
|
|
270
277
|
});
|
|
271
|
-
throw new Error(message
|
|
278
|
+
throw new Error(message);
|
|
272
279
|
}
|
|
273
280
|
};
|
|
274
281
|
#unloadApp = ({ id, instanceId, hostUrl, documentEle }) => {
|
|
@@ -376,23 +383,36 @@ class CAppBridge {
|
|
|
376
383
|
}
|
|
377
384
|
};
|
|
378
385
|
/**
|
|
379
|
-
*
|
|
380
|
-
*
|
|
381
|
-
|
|
382
|
-
|
|
386
|
+
* Registered module SO for a guest, if the host added one.
|
|
387
|
+
* @param guestAppId
|
|
388
|
+
*/
|
|
389
|
+
#getGuestModuleScriptingObject = (guestAppId) => this.#soManager.getObject(
|
|
390
|
+
import_pui_scripting_object.ScriptingObjectNames.Module,
|
|
391
|
+
{ id: guestAppId }
|
|
392
|
+
);
|
|
393
|
+
/**
|
|
394
|
+
* Dispatch module.unloading or module.unmount to guest listeners.
|
|
395
|
+
* Uses a stub module SO when none is registered; routing is by eventId.
|
|
396
|
+
* @param guestAppId
|
|
397
|
+
* @param eventId
|
|
398
|
+
* @param eventName
|
|
399
|
+
*/
|
|
400
|
+
#dispatchGuestModuleEvent = async (guestAppId, eventId, eventName) => {
|
|
401
|
+
const moduleSO = this.#getGuestModuleScriptingObject(guestAppId) ?? MODULE_EVENT_STUB;
|
|
402
|
+
return this.#eventManager.dispatchEvent(moduleSO, {
|
|
403
|
+
event: { id: eventId, name: eventName },
|
|
404
|
+
eventParams: { moduleId: guestAppId },
|
|
405
|
+
eventOptions: { timeout: MODULE_EVENT_TIMEOUT_MS }
|
|
406
|
+
});
|
|
407
|
+
};
|
|
383
408
|
#canUnload = async (id) => {
|
|
384
|
-
const moduleSO = this.#soManager.getObject(
|
|
385
|
-
import_pui_scripting_object.ScriptingObjectNames.Module,
|
|
386
|
-
{ id }
|
|
387
|
-
);
|
|
388
|
-
if (!moduleSO) return true;
|
|
389
409
|
try {
|
|
390
|
-
const feedback = await this.#
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
if (
|
|
410
|
+
const feedback = await this.#dispatchGuestModuleEvent(
|
|
411
|
+
id,
|
|
412
|
+
MODULE_UNLOADING_EVENT,
|
|
413
|
+
"unloading"
|
|
414
|
+
);
|
|
415
|
+
if (isModuleUnloadVetoed(feedback)) {
|
|
396
416
|
this.#logger.info(
|
|
397
417
|
`Unload denied by guest ${id} via module.unloading event`
|
|
398
418
|
);
|
|
@@ -400,12 +420,37 @@ class CAppBridge {
|
|
|
400
420
|
}
|
|
401
421
|
} catch (err) {
|
|
402
422
|
this.#logger.warn({
|
|
403
|
-
message: `Error dispatching module.unloading event for ${id}`,
|
|
423
|
+
message: `Error dispatching module.unloading event for ${id}; proceeding with unload`,
|
|
404
424
|
exception: err
|
|
405
425
|
});
|
|
406
426
|
}
|
|
407
427
|
return true;
|
|
408
428
|
};
|
|
429
|
+
/**
|
|
430
|
+
* Legacy guests use registerApp.unmount; self-init guests receive module.unmount.
|
|
431
|
+
* @param root0
|
|
432
|
+
* @param root0.id
|
|
433
|
+
* @param root0.instanceId
|
|
434
|
+
* @param root0.selfInitialize
|
|
435
|
+
*/
|
|
436
|
+
#teardownGuest = async ({
|
|
437
|
+
id,
|
|
438
|
+
instanceId,
|
|
439
|
+
selfInitialize
|
|
440
|
+
}) => {
|
|
441
|
+
if (!selfInitialize) {
|
|
442
|
+
await this.#unmountApp({ id, instanceId });
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
445
|
+
try {
|
|
446
|
+
await this.#dispatchGuestModuleEvent(id, MODULE_UNMOUNT_EVENT, "unmount");
|
|
447
|
+
} catch (err) {
|
|
448
|
+
this.#logger.warn({
|
|
449
|
+
message: `Error dispatching module.unmount event for ${id}`,
|
|
450
|
+
exception: err
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
};
|
|
409
454
|
/**
|
|
410
455
|
* clear session management for the guest application
|
|
411
456
|
* @param instanceId unique instance id of the application
|
|
@@ -464,7 +509,9 @@ class CAppBridge {
|
|
|
464
509
|
eventOptions
|
|
465
510
|
}) => this.dispatchEvent({
|
|
466
511
|
event,
|
|
512
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
467
513
|
eventParams,
|
|
514
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
468
515
|
eventOptions
|
|
469
516
|
});
|
|
470
517
|
const token = propValue.subscribe(listener);
|
|
@@ -474,8 +521,7 @@ class CAppBridge {
|
|
|
474
521
|
} else if (this.#isFunction(propValue)) {
|
|
475
522
|
Object.defineProperty(so, propName, {
|
|
476
523
|
value: async (...args) => {
|
|
477
|
-
const
|
|
478
|
-
const callerCtx = soMethod?.callContext;
|
|
524
|
+
const callerCtx = so[propName]?.callContext;
|
|
479
525
|
if (callerCtx?.guest) {
|
|
480
526
|
const existingChain = callerCtx.callChain ?? [];
|
|
481
527
|
const guestId = callerCtx.guest.id;
|
|
@@ -536,7 +582,7 @@ class CAppBridge {
|
|
|
536
582
|
);
|
|
537
583
|
return;
|
|
538
584
|
}
|
|
539
|
-
const { id } = app;
|
|
585
|
+
const { id, selfInitialize } = app;
|
|
540
586
|
if (!await this.#canUnload(id)) return;
|
|
541
587
|
const appConfig = this.#microFEConfig.getConfigById(id);
|
|
542
588
|
if (!appConfig) {
|
|
@@ -546,11 +592,11 @@ class CAppBridge {
|
|
|
546
592
|
return;
|
|
547
593
|
}
|
|
548
594
|
const { hostUrl } = appConfig;
|
|
595
|
+
const frameEle = import_frame.Frame.get(instanceId);
|
|
549
596
|
try {
|
|
550
597
|
this.#clearSession(app);
|
|
551
|
-
await this.#
|
|
598
|
+
await this.#teardownGuest({ id, instanceId, selfInitialize });
|
|
552
599
|
} finally {
|
|
553
|
-
const frameEle = import_frame.Frame.get(instanceId);
|
|
554
600
|
if (frameEle?.contentDocument) {
|
|
555
601
|
this.#unloadApp({
|
|
556
602
|
id,
|
|
@@ -559,6 +605,9 @@ class CAppBridge {
|
|
|
559
605
|
documentEle: frameEle.contentDocument
|
|
560
606
|
});
|
|
561
607
|
}
|
|
608
|
+
if (frameEle) {
|
|
609
|
+
frameEle.src = "about:blank";
|
|
610
|
+
}
|
|
562
611
|
this.#activeApps.delete(instanceId);
|
|
563
612
|
this.#guestMetadata.delete(id);
|
|
564
613
|
import_frame.Frame.remove(instanceId);
|
|
@@ -681,7 +730,10 @@ class CAppBridge {
|
|
|
681
730
|
if (iframeWindow) {
|
|
682
731
|
iframeWindow.emui = iframeWindow.emui ?? {};
|
|
683
732
|
iframeWindow.emui.__host = microFEHost;
|
|
684
|
-
iframeWindow.emui.getHost = () =>
|
|
733
|
+
iframeWindow.emui.getHost = () => (
|
|
734
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
735
|
+
iframeWindow.emui?.__host ?? null
|
|
736
|
+
);
|
|
685
737
|
}
|
|
686
738
|
const preconnect = frameDoc.createElement("link");
|
|
687
739
|
preconnect.rel = "preconnect";
|
|
@@ -809,7 +861,8 @@ class CAppBridge {
|
|
|
809
861
|
*/
|
|
810
862
|
unmountApp = async (instanceId) => {
|
|
811
863
|
if (!instanceId) throw new Error("instanceId is required");
|
|
812
|
-
const
|
|
864
|
+
const activeApp = this.#activeApps.get(instanceId);
|
|
865
|
+
const { id, selfInitialize } = activeApp || {};
|
|
813
866
|
if (!id) {
|
|
814
867
|
throw new Error(
|
|
815
868
|
`Application with instance id ${instanceId} is not found`
|
|
@@ -819,6 +872,6 @@ class CAppBridge {
|
|
|
819
872
|
if (!appConfig) {
|
|
820
873
|
throw new Error(`Application with id ${id} is not found`);
|
|
821
874
|
}
|
|
822
|
-
await this.#
|
|
875
|
+
await this.#teardownGuest({ id, instanceId, selfInitialize });
|
|
823
876
|
};
|
|
824
877
|
}
|
package/dist/cjs/config/app.js
CHANGED
|
@@ -123,7 +123,9 @@ class CAppConfig {
|
|
|
123
123
|
await this.load(`${this.#baseUrl}latest/app.config.json`);
|
|
124
124
|
return;
|
|
125
125
|
}
|
|
126
|
-
throw new Error("Failed to fetch app config", {
|
|
126
|
+
throw new Error("Failed to fetch app config", {
|
|
127
|
+
cause: err
|
|
128
|
+
});
|
|
127
129
|
}
|
|
128
130
|
if (response.ok) {
|
|
129
131
|
try {
|
|
@@ -132,7 +134,10 @@ class CAppConfig {
|
|
|
132
134
|
} catch (err) {
|
|
133
135
|
if (!configUrl && this.#version !== import_constant.LATEST_VERSION) {
|
|
134
136
|
await this.load(`${this.#baseUrl}latest/app.config.json`);
|
|
135
|
-
} else
|
|
137
|
+
} else
|
|
138
|
+
throw new Error("Failed to parse app config", {
|
|
139
|
+
cause: err
|
|
140
|
+
});
|
|
136
141
|
}
|
|
137
142
|
} else {
|
|
138
143
|
if (!configUrl && this.#version !== import_constant.LATEST_VERSION) {
|
|
@@ -59,38 +59,36 @@ const isFileListValid = (files) => {
|
|
|
59
59
|
if (!files || !files.length) return false;
|
|
60
60
|
return files.every((file) => typeof file === "string");
|
|
61
61
|
};
|
|
62
|
-
const isLaunchMode = (mode, expected) => String(mode).toLowerCase() === expected.toLowerCase();
|
|
63
|
-
const isAppSdkManager = (manager) => String(manager).toLowerCase() === import_app.MicroAppManager.APPSDK.toLowerCase();
|
|
64
|
-
const validateMode = (id, mode) => {
|
|
65
|
-
if (!isLaunchMode(mode, import_app.LaunchMode.PRODUCTION) && !isLaunchMode(mode, import_app.LaunchMode.DEVELOPMENT)) {
|
|
66
|
-
throw new Error(`invalid mode '${String(mode)}' for ${id}`);
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
const validateAppSdkEnvFiles = (id, envSection, envName) => {
|
|
70
|
-
if (!envSection) {
|
|
71
|
-
throw new Error(
|
|
72
|
-
`microFrontendApps.${id} is missing ${envName} section in app.config.json`
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
if (!isFileListValid(envSection.files)) {
|
|
76
|
-
throw new Error(`invalid value for ${envName}.files`);
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
const validateAppSdkConfig = (id, mode, mfeConfig) => {
|
|
80
|
-
const { production, development } = mfeConfig;
|
|
81
|
-
if (isLaunchMode(mode, import_app.LaunchMode.PRODUCTION)) {
|
|
82
|
-
validateAppSdkEnvFiles(id, production, "production");
|
|
83
|
-
}
|
|
84
|
-
if (isLaunchMode(mode, import_app.LaunchMode.DEVELOPMENT)) {
|
|
85
|
-
validateAppSdkEnvFiles(id, development, "development");
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
62
|
const validate = (id, mfeConfig) => {
|
|
89
63
|
const { mode = import_app.LaunchMode.PRODUCTION } = mfeConfig;
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
64
|
+
if (String(mode).toLowerCase() !== import_app.LaunchMode.PRODUCTION.toLowerCase() && String(mode).toLowerCase() !== import_app.LaunchMode.DEVELOPMENT.toLowerCase())
|
|
65
|
+
throw new Error(`invalid mode '${String(mode)}' for ${id}`);
|
|
66
|
+
const {
|
|
67
|
+
production,
|
|
68
|
+
development,
|
|
69
|
+
microappManager = import_app.MicroAppManager.APPSDK
|
|
70
|
+
} = mfeConfig;
|
|
71
|
+
if (String(microappManager).toLowerCase() === import_app.MicroAppManager.APPSDK.toLowerCase()) {
|
|
72
|
+
if (String(mode).toLowerCase() === import_app.LaunchMode.PRODUCTION.toLowerCase()) {
|
|
73
|
+
if (!production) {
|
|
74
|
+
throw new Error(
|
|
75
|
+
`microFrontendApps.${id} is missing production section in app.config.json`
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
if (!isFileListValid(production.files)) {
|
|
79
|
+
throw new Error(`invalid value for production.files`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (String(mode).toLowerCase() === import_app.LaunchMode.DEVELOPMENT.toLowerCase()) {
|
|
83
|
+
if (!development) {
|
|
84
|
+
throw new Error(
|
|
85
|
+
`microFrontendApps.${id} is missing development section in app.config.json`
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
if (!isFileListValid(development.files)) {
|
|
89
|
+
throw new Error(`invalid value for development.files`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
94
92
|
}
|
|
95
93
|
};
|
|
96
94
|
const getConfig = ({
|
package/dist/cjs/eventManager.js
CHANGED
|
@@ -94,13 +94,12 @@ class EventManager {
|
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
return this.#asyncCallwithTimeout(
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
),
|
|
97
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
98
|
+
listener.callback({
|
|
99
|
+
obj: scriptingObject,
|
|
100
|
+
eventName,
|
|
101
|
+
eventParams
|
|
102
|
+
}),
|
|
104
103
|
feedbackWaitTime
|
|
105
104
|
);
|
|
106
105
|
});
|
package/dist/cjs/frame.js
CHANGED
|
@@ -99,14 +99,11 @@ const create = ({
|
|
|
99
99
|
frame.setAttribute("src", buildFrameSrc(options));
|
|
100
100
|
const FRAME_LOAD_TIMEOUT_MS = 1e4;
|
|
101
101
|
let settled = false;
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
onAbort: (() => {
|
|
105
|
-
})
|
|
106
|
-
};
|
|
102
|
+
let timeoutId;
|
|
103
|
+
let onAbort;
|
|
107
104
|
const cleanup = () => {
|
|
108
|
-
|
|
109
|
-
signal?.removeEventListener("abort",
|
|
105
|
+
clearTimeout(timeoutId);
|
|
106
|
+
signal?.removeEventListener("abort", onAbort);
|
|
110
107
|
};
|
|
111
108
|
const rejectIfAborted = () => {
|
|
112
109
|
if (!signal?.aborted) return false;
|
|
@@ -118,12 +115,12 @@ const create = ({
|
|
|
118
115
|
}
|
|
119
116
|
return true;
|
|
120
117
|
};
|
|
121
|
-
|
|
118
|
+
onAbort = () => {
|
|
122
119
|
rejectIfAborted();
|
|
123
120
|
};
|
|
124
121
|
if (rejectIfAborted()) return;
|
|
125
|
-
signal?.addEventListener("abort",
|
|
126
|
-
|
|
122
|
+
signal?.addEventListener("abort", onAbort);
|
|
123
|
+
timeoutId = setTimeout(() => {
|
|
127
124
|
if (!settled) {
|
|
128
125
|
settled = true;
|
|
129
126
|
cleanup();
|
package/dist/cjs/microfeHost.js
CHANGED
|
@@ -74,8 +74,7 @@ class CMicroFEHost {
|
|
|
74
74
|
} else if ((0, import_microfe_common.isPublicFunction)(propValue, propName)) {
|
|
75
75
|
Object.defineProperty(proxy, propName, {
|
|
76
76
|
value: (...args) => {
|
|
77
|
-
const
|
|
78
|
-
const existingCallChain = proxyMethod?.callContext?.callChain;
|
|
77
|
+
const existingCallChain = proxy[propName]?.callContext?.callChain;
|
|
79
78
|
Object.defineProperty(propValue, "callContext", {
|
|
80
79
|
value: {
|
|
81
80
|
guest: this.#guest,
|
|
@@ -95,9 +94,7 @@ class CMicroFEHost {
|
|
|
95
94
|
});
|
|
96
95
|
return Promise.resolve(proxy);
|
|
97
96
|
} catch (err) {
|
|
98
|
-
return Promise.reject(
|
|
99
|
-
err instanceof Error ? err : new Error(String(err))
|
|
100
|
-
);
|
|
97
|
+
return Promise.reject(err);
|
|
101
98
|
}
|
|
102
99
|
};
|
|
103
100
|
/**
|
|
@@ -26,16 +26,31 @@ class Analytics extends import_microfe_common.ScriptingObject {
|
|
|
26
26
|
constructor() {
|
|
27
27
|
super("analytics");
|
|
28
28
|
}
|
|
29
|
-
deleteTimingEventSamplingRatio = (
|
|
29
|
+
deleteTimingEventSamplingRatio = (names) => {
|
|
30
|
+
console.log("Analytics.deleteTimingEventSamplingRatio", names);
|
|
30
31
|
};
|
|
31
|
-
getAllTimingEventSamplingRatios = () =>
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
getAllTimingEventSamplingRatios = () => {
|
|
33
|
+
console.log("Analytics.getAllTimingEventSamplingRatios");
|
|
34
|
+
return {};
|
|
35
|
+
};
|
|
36
|
+
getTimingEventSamplingRatio = (names) => {
|
|
37
|
+
console.log("Analytics.getTimingEventSamplingRatio", names);
|
|
38
|
+
return {};
|
|
39
|
+
};
|
|
40
|
+
setTimingEventSamplingRatio = (ratios) => {
|
|
41
|
+
console.log("Analytics.setTimingEventSamplingRatio", ratios);
|
|
42
|
+
};
|
|
43
|
+
sendBAEvent = (event) => {
|
|
44
|
+
console.log("Analytics.sendBAEvent", event);
|
|
45
|
+
return Promise.resolve();
|
|
46
|
+
};
|
|
47
|
+
startTiming = (name, options) => {
|
|
48
|
+
console.log("Analytics.perfMarkStart", name);
|
|
49
|
+
return Promise.resolve(performance.mark(name, { detail: options }));
|
|
34
50
|
};
|
|
35
|
-
sendBAEvent = (_event) => Promise.resolve();
|
|
36
|
-
startTiming = (name, options) => Promise.resolve(performance.mark(name, { detail: options }));
|
|
37
51
|
endTiming = (start, options) => {
|
|
38
52
|
const name = typeof start === "string" ? start : start.name;
|
|
53
|
+
console.log("Analytics.perfMarkEnd", name);
|
|
39
54
|
performance.measure(name, {
|
|
40
55
|
detail: options,
|
|
41
56
|
start: name
|
|
@@ -72,7 +72,10 @@ class AppraisalService extends import_microfe_common.ScriptingObject {
|
|
|
72
72
|
delete = () => {
|
|
73
73
|
throw new Error("Not implemented");
|
|
74
74
|
};
|
|
75
|
-
log = async (
|
|
75
|
+
log = async (message, level) => {
|
|
76
|
+
console.log(message, level);
|
|
77
|
+
return Promise.resolve();
|
|
78
|
+
};
|
|
76
79
|
unload = async () => {
|
|
77
80
|
};
|
|
78
81
|
}
|
package/dist/cjs/tests/utils.js
CHANGED
|
@@ -28,91 +28,16 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
var utils_exports = {};
|
|
30
30
|
__export(utils_exports, {
|
|
31
|
-
clearWindowEmui: () => clearWindowEmui,
|
|
32
|
-
createTestModuleSO: () => createTestModuleSO,
|
|
33
|
-
expectInitHistoryShape: () => expectInitHistoryShape,
|
|
34
|
-
expectInitLoggerShape: () => expectInitLoggerShape,
|
|
35
|
-
expectInitThemeShape: () => expectInitThemeShape,
|
|
36
|
-
getEmuiApps: () => getEmuiApps,
|
|
37
|
-
getIframeWindow: () => getIframeWindow,
|
|
38
31
|
getMajorMinorVersion: () => getMajorMinorVersion,
|
|
39
32
|
logger: () => logger,
|
|
40
33
|
releaseJSThread: () => releaseJSThread,
|
|
41
34
|
sendJS: () => sendJS,
|
|
42
|
-
sendJSText: () => sendJSText
|
|
43
|
-
setEmuiAppEntry: () => setEmuiAppEntry,
|
|
44
|
-
snapshotInitOptionsPayload: () => snapshotInitOptionsPayload
|
|
35
|
+
sendJSText: () => sendJSText
|
|
45
36
|
});
|
|
46
37
|
module.exports = __toCommonJS(utils_exports);
|
|
47
38
|
var import_promises = require("fs/promises");
|
|
48
39
|
var import_node_path = __toESM(require("node:path"), 1);
|
|
49
40
|
var import_pui_diagnostics = require("@elliemae/pui-diagnostics");
|
|
50
|
-
var import_microfe_common = require("@elliemae/microfe-common");
|
|
51
|
-
const getIframeWindow = (frame) => {
|
|
52
|
-
const view = frame.contentDocument?.defaultView;
|
|
53
|
-
if (!view) {
|
|
54
|
-
throw new Error("iframe content window is not available");
|
|
55
|
-
}
|
|
56
|
-
return view;
|
|
57
|
-
};
|
|
58
|
-
const getEmuiApps = (emui, appId) => {
|
|
59
|
-
const entry = emui[appId];
|
|
60
|
-
if (Array.isArray(entry)) return entry;
|
|
61
|
-
return entry ? [entry] : [];
|
|
62
|
-
};
|
|
63
|
-
const setEmuiAppEntry = (emui, appId, entry) => {
|
|
64
|
-
emui[appId] = entry;
|
|
65
|
-
};
|
|
66
|
-
const clearWindowEmui = () => {
|
|
67
|
-
Reflect.deleteProperty(window, "emui");
|
|
68
|
-
};
|
|
69
|
-
const createTestModuleSO = () => {
|
|
70
|
-
const moduleSO = new import_microfe_common.ScriptingObject("module");
|
|
71
|
-
Object.defineProperty(moduleSO, "getParameters", {
|
|
72
|
-
value: () => Promise.resolve({ moduleId: "urn:test", homeRoute: "/test" }),
|
|
73
|
-
enumerable: true
|
|
74
|
-
});
|
|
75
|
-
return moduleSO;
|
|
76
|
-
};
|
|
77
|
-
const expectInitHistoryShape = (history) => {
|
|
78
|
-
expect(history).toBeDefined();
|
|
79
|
-
expect(history?.action).toBe("POP");
|
|
80
|
-
expect(typeof history?.push).toBe("function");
|
|
81
|
-
expect(typeof history?.replace).toBe("function");
|
|
82
|
-
};
|
|
83
|
-
const expectInitThemeShape = (theme) => {
|
|
84
|
-
expect(theme).toBeDefined();
|
|
85
|
-
expect(theme?.breakpoints).toBeDefined();
|
|
86
|
-
expect(theme?.colors).toBeDefined();
|
|
87
|
-
expect(typeof theme?.media.large).toBe("function");
|
|
88
|
-
expect(typeof theme?.media.medium).toBe("function");
|
|
89
|
-
};
|
|
90
|
-
const expectInitLoggerShape = (initLogger) => {
|
|
91
|
-
expect(initLogger).toBeDefined();
|
|
92
|
-
expect(typeof initLogger?.audit).toBe("function");
|
|
93
|
-
expect(typeof initLogger?.debug).toBe("function");
|
|
94
|
-
expect(typeof initLogger?.error).toBe("function");
|
|
95
|
-
};
|
|
96
|
-
const snapshotInitOptionsPayload = (initOptions) => ({
|
|
97
|
-
...initOptions,
|
|
98
|
-
logger: void 0,
|
|
99
|
-
history: initOptions.history ? {
|
|
100
|
-
action: initOptions.history.action,
|
|
101
|
-
location: initOptions.history.location
|
|
102
|
-
} : void 0,
|
|
103
|
-
theme: initOptions.theme ? {
|
|
104
|
-
breakpoints: initOptions.theme.breakpoints,
|
|
105
|
-
colors: initOptions.theme.colors,
|
|
106
|
-
fontSizes: initOptions.theme.fontSizes,
|
|
107
|
-
fontWeights: initOptions.theme.fontWeights,
|
|
108
|
-
fonts: initOptions.theme.fonts,
|
|
109
|
-
letterSpacings: initOptions.theme.letterSpacings,
|
|
110
|
-
lineHeights: initOptions.theme.lineHeights,
|
|
111
|
-
shadows: initOptions.theme.shadows,
|
|
112
|
-
space: initOptions.theme.space,
|
|
113
|
-
zIndex: initOptions.theme.zIndex
|
|
114
|
-
} : void 0
|
|
115
|
-
});
|
|
116
41
|
const getMajorMinorVersion = (version) => version.split(".").slice(0, 2).join(".");
|
|
117
42
|
const sendJS = async (res, ctx, filePath) => {
|
|
118
43
|
const fileContent = await (0, import_promises.readFile)(import_node_path.default.join(__dirname, filePath), "utf-8");
|