@elliemae/ssf-host 2.22.0 → 2.23.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/guest.js +15 -5
- package/dist/cjs/host.js +114 -88
- package/dist/cjs/utils.js +2 -19
- package/dist/esm/guest.js +15 -5
- package/dist/esm/host.js +114 -88
- package/dist/esm/utils.js +2 -19
- package/dist/public/analytics-object-v1.js.map +1 -1
- package/dist/public/analytics-object-v2.js.map +1 -1
- package/dist/public/application-object-v1.js.map +1 -1
- package/dist/public/application-object-v2.js.map +1 -1
- package/dist/public/autoFill.js.map +1 -1
- package/dist/public/index.html +1 -1
- package/dist/public/init.js.map +1 -1
- package/dist/public/js/emuiSsfHost.6b964dde53916a3845ae.js +3 -0
- package/dist/public/js/emuiSsfHost.6b964dde53916a3845ae.js.br +0 -0
- package/dist/public/js/emuiSsfHost.6b964dde53916a3845ae.js.gz +0 -0
- package/dist/public/js/emuiSsfHost.6b964dde53916a3845ae.js.map +1 -0
- package/dist/public/loan-object-v1.js.map +1 -1
- package/dist/public/loan-object.js.map +1 -1
- package/dist/public/utils.js +1 -1
- package/dist/public/utils.js.br +0 -0
- package/dist/public/utils.js.gz +0 -0
- package/dist/public/utils.js.map +1 -1
- package/dist/public/v1-guest-v2-host.html +1 -1
- package/dist/public/v2-host-v1-guest.html +1 -1
- package/dist/types/lib/host.d.ts +2 -2
- package/dist/types/lib/ihost.d.ts +7 -6
- package/dist/types/lib/types.d.ts +1 -2
- package/dist/types/lib/utils.d.ts +2 -5
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/dist/umd/analytics-object-v1.js.map +1 -1
- package/dist/umd/analytics-object-v2.js.map +1 -1
- package/dist/umd/application-object-v1.js.map +1 -1
- package/dist/umd/application-object-v2.js.map +1 -1
- package/dist/umd/autoFill.js.map +1 -1
- package/dist/umd/index.js +1 -1
- 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/dist/umd/init.js.map +1 -1
- package/dist/umd/loan-object-v1.js.map +1 -1
- package/dist/umd/loan-object.js.map +1 -1
- package/dist/umd/utils.js +1 -1
- package/dist/umd/utils.js.br +0 -0
- package/dist/umd/utils.js.gz +0 -0
- package/dist/umd/utils.js.map +1 -1
- package/package.json +22 -23
- package/dist/public/js/emuiSsfHost.01546664223ea88ed947.js +0 -3
- package/dist/public/js/emuiSsfHost.01546664223ea88ed947.js.br +0 -0
- package/dist/public/js/emuiSsfHost.01546664223ea88ed947.js.gz +0 -0
- package/dist/public/js/emuiSsfHost.01546664223ea88ed947.js.map +0 -1
package/dist/esm/host.js
CHANGED
|
@@ -48,6 +48,14 @@ class SSFHost {
|
|
|
48
48
|
* list of guests
|
|
49
49
|
*/
|
|
50
50
|
#guests = /* @__PURE__ */ new Map();
|
|
51
|
+
/**
|
|
52
|
+
* reverse lookup: window -> guest for O(1) message routing
|
|
53
|
+
*/
|
|
54
|
+
#guestsByWindow = /* @__PURE__ */ new Map();
|
|
55
|
+
/**
|
|
56
|
+
* reverse lookup: url -> guest for O(1) popup dedup
|
|
57
|
+
*/
|
|
58
|
+
#guestsByUrl = /* @__PURE__ */ new Map();
|
|
51
59
|
/**
|
|
52
60
|
* list of callbacks for guest close.
|
|
53
61
|
*/
|
|
@@ -94,50 +102,46 @@ class SSFHost {
|
|
|
94
102
|
this.#remoting.initialize(window);
|
|
95
103
|
this.#connect();
|
|
96
104
|
window.addEventListener("beforeunload", this.#closeAllPopupGuests);
|
|
97
|
-
this.#monitorPopupGuests();
|
|
98
105
|
this.#logger.debug(
|
|
99
106
|
`host is initialized. hostId: ${this.hostId}, correlationId: ${this.#correlationId}`
|
|
100
107
|
);
|
|
101
108
|
}
|
|
102
109
|
#sendBAEvent = (event, data) => {
|
|
103
110
|
const baEvent = { event, ...data };
|
|
104
|
-
this.#analyticsObj.sendBAEvent(baEvent).catch(() => {
|
|
111
|
+
this.#analyticsObj.sendBAEvent(baEvent).catch((e) => {
|
|
112
|
+
this.#logger.debug(
|
|
113
|
+
`Analytics sendBAEvent failed: ${e.message}`
|
|
114
|
+
);
|
|
105
115
|
});
|
|
106
116
|
};
|
|
107
117
|
#startTiming = (name, options) => {
|
|
108
|
-
this.#analyticsObj.startTiming(name, options).catch(() => {
|
|
118
|
+
this.#analyticsObj.startTiming(name, options).catch((e) => {
|
|
119
|
+
this.#logger.debug(
|
|
120
|
+
`Analytics startTiming failed: ${e.message}`
|
|
121
|
+
);
|
|
109
122
|
});
|
|
110
123
|
};
|
|
111
124
|
#endTiming = (start, options) => {
|
|
112
|
-
this.#analyticsObj.endTiming(start, options).catch(() => {
|
|
125
|
+
this.#analyticsObj.endTiming(start, options).catch((e) => {
|
|
126
|
+
this.#logger.debug(`Analytics endTiming failed: ${e.message}`);
|
|
113
127
|
});
|
|
114
128
|
};
|
|
115
129
|
#closeAllPopupGuests = () => {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
this.unloadGuest(guest.id);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
130
|
+
const popupIds = Array.from(this.#guests.values()).filter((guest) => guest.openMode === OpenMode.Popup).map((guest) => guest.id);
|
|
131
|
+
popupIds.forEach((id) => this.unloadGuest(id));
|
|
121
132
|
};
|
|
122
133
|
/**
|
|
123
134
|
* get the reference to the guest application by its window
|
|
124
135
|
* @param guestWindow reference to the guest window
|
|
125
136
|
* @returns reference to the guest
|
|
126
137
|
*/
|
|
127
|
-
#getGuestForWindow = (guestWindow) =>
|
|
128
|
-
(guest) => guest.window === guestWindow
|
|
129
|
-
);
|
|
138
|
+
#getGuestForWindow = (guestWindow) => this.#guestsByWindow.get(guestWindow);
|
|
130
139
|
/**
|
|
131
140
|
* get the reference to the guest application by its window
|
|
132
141
|
* @param url url of the guest application
|
|
133
142
|
* @returns reference to the guest
|
|
134
143
|
*/
|
|
135
|
-
#getGuestForUrl = (url) =>
|
|
136
|
-
for (const guest of this.#guests.values()) {
|
|
137
|
-
if (guest.url === url) return guest;
|
|
138
|
-
}
|
|
139
|
-
return null;
|
|
140
|
-
};
|
|
144
|
+
#getGuestForUrl = (url) => this.#guestsByUrl.get(url) ?? null;
|
|
141
145
|
/**
|
|
142
146
|
* check if a object is a scripting object
|
|
143
147
|
* @param value javascript object
|
|
@@ -409,6 +413,9 @@ class SSFHost {
|
|
|
409
413
|
token
|
|
410
414
|
});
|
|
411
415
|
} catch (error) {
|
|
416
|
+
this.#logger.warn(
|
|
417
|
+
`Error in onGuestEventSubscribe callback for event ${eventId}: ${error.message}`
|
|
418
|
+
);
|
|
412
419
|
}
|
|
413
420
|
}, 0);
|
|
414
421
|
};
|
|
@@ -452,6 +459,9 @@ class SSFHost {
|
|
|
452
459
|
token
|
|
453
460
|
});
|
|
454
461
|
} catch (error) {
|
|
462
|
+
this.#logger.warn(
|
|
463
|
+
`Error in onGuestEventUnsubscribe callback for event ${eventId}: ${error.message}`
|
|
464
|
+
);
|
|
455
465
|
}
|
|
456
466
|
}, 0);
|
|
457
467
|
};
|
|
@@ -626,6 +636,8 @@ class SSFHost {
|
|
|
626
636
|
});
|
|
627
637
|
guest.init();
|
|
628
638
|
this.#guests.set(param.guestId, guest);
|
|
639
|
+
this.#guestsByWindow.set(guest.window, guest);
|
|
640
|
+
this.#guestsByUrl.set(guest.url, guest);
|
|
629
641
|
return guest;
|
|
630
642
|
};
|
|
631
643
|
/**
|
|
@@ -634,15 +646,17 @@ class SSFHost {
|
|
|
634
646
|
* @returns guest object
|
|
635
647
|
*/
|
|
636
648
|
#findGuest = (guestIdOrWindowOrEle) => {
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
guest = Array.from(this.#guests.values()).find(
|
|
640
|
-
(value) => value.window === guestIdOrWindowOrEle || value.domElement === guestIdOrWindowOrEle
|
|
641
|
-
);
|
|
649
|
+
if (typeof guestIdOrWindowOrEle === "string") {
|
|
650
|
+
return this.#guests.get(guestIdOrWindowOrEle);
|
|
642
651
|
}
|
|
643
|
-
|
|
652
|
+
const byWindow = this.#guestsByWindow.get(guestIdOrWindowOrEle);
|
|
653
|
+
if (byWindow) return byWindow;
|
|
654
|
+
return Array.from(this.#guests.values()).find(
|
|
655
|
+
(value) => value.domElement === guestIdOrWindowOrEle
|
|
656
|
+
);
|
|
644
657
|
};
|
|
645
658
|
#monitorPopupGuests = () => {
|
|
659
|
+
if (this.#popupGuestMonitor) return;
|
|
646
660
|
this.#popupGuestMonitor = setInterval(() => {
|
|
647
661
|
const guestsToRemove = [];
|
|
648
662
|
this.#guests.forEach((guest) => {
|
|
@@ -655,12 +669,22 @@ class SSFHost {
|
|
|
655
669
|
this.unloadGuest(id);
|
|
656
670
|
const callbacks = this.#guestCloseCallbackList.get(id);
|
|
657
671
|
callbacks?.forEach((callback) => {
|
|
658
|
-
callback({ id }).catch(() => {
|
|
672
|
+
Promise.resolve(callback({ id })).catch(() => {
|
|
659
673
|
});
|
|
660
674
|
});
|
|
661
675
|
});
|
|
662
676
|
}, 1e3);
|
|
663
677
|
};
|
|
678
|
+
#stopMonitoringPopupGuests = () => {
|
|
679
|
+
if (!this.#popupGuestMonitor) return;
|
|
680
|
+
const hasPopups = Array.from(this.#guests.values()).some(
|
|
681
|
+
(guest) => guest.openMode === OpenMode.Popup
|
|
682
|
+
);
|
|
683
|
+
if (!hasPopups) {
|
|
684
|
+
clearInterval(this.#popupGuestMonitor);
|
|
685
|
+
this.#popupGuestMonitor = null;
|
|
686
|
+
}
|
|
687
|
+
};
|
|
664
688
|
#openPopupGuest = (param) => {
|
|
665
689
|
const {
|
|
666
690
|
url,
|
|
@@ -686,37 +710,29 @@ class SSFHost {
|
|
|
686
710
|
});
|
|
687
711
|
}
|
|
688
712
|
} else {
|
|
689
|
-
const windowFeatures = [
|
|
690
|
-
{ key: "width", value: width },
|
|
691
|
-
{ key: "height", value: height },
|
|
692
|
-
{ key: "top", value: top },
|
|
693
|
-
{ key: "left", value: left }
|
|
694
|
-
].reduce((acc, cur, curIndex) => {
|
|
695
|
-
if (curIndex > 0 && cur.value) acc += ",";
|
|
696
|
-
return cur.value ? `${acc}${cur.key}=${cur.value}` : acc;
|
|
697
|
-
}, "");
|
|
713
|
+
const windowFeatures = Object.entries({ width, height, top, left }).filter(([, v]) => v).map(([k, v]) => `${k}=${v}`).join(",");
|
|
698
714
|
const guestWindow = window.open(url, title, `popup, ${windowFeatures}`);
|
|
699
715
|
if (!guestWindow) {
|
|
700
|
-
|
|
701
|
-
|
|
716
|
+
setTimeout(() => {
|
|
717
|
+
try {
|
|
702
718
|
onError?.(guestId);
|
|
703
|
-
}
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
}
|
|
719
|
+
} catch (error) {
|
|
720
|
+
this.#logger.debug(
|
|
721
|
+
`Error occurred in onError for guest with id '${guestId}': ${error.message}`
|
|
722
|
+
);
|
|
723
|
+
}
|
|
724
|
+
}, 0);
|
|
709
725
|
throw new Error("Failed to open guest application in popup window");
|
|
710
726
|
} else {
|
|
711
|
-
|
|
712
|
-
|
|
727
|
+
setTimeout(() => {
|
|
728
|
+
try {
|
|
713
729
|
onLoad?.(guestId);
|
|
714
|
-
}
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
}
|
|
730
|
+
} catch (error) {
|
|
731
|
+
this.#logger.debug(
|
|
732
|
+
`Error occurred in onLoad for guest with id '${guestId}': ${error.message}`
|
|
733
|
+
);
|
|
734
|
+
}
|
|
735
|
+
}, 0);
|
|
720
736
|
}
|
|
721
737
|
guestWindow.opener = null;
|
|
722
738
|
guest = this.#attachGuest({
|
|
@@ -727,6 +743,7 @@ class SSFHost {
|
|
|
727
743
|
searchParams,
|
|
728
744
|
openMode: OpenMode.Popup
|
|
729
745
|
});
|
|
746
|
+
this.#monitorPopupGuests();
|
|
730
747
|
}
|
|
731
748
|
return guest;
|
|
732
749
|
};
|
|
@@ -913,7 +930,10 @@ class SSFHost {
|
|
|
913
930
|
* dispose the resources used by the host application
|
|
914
931
|
*/
|
|
915
932
|
close = () => {
|
|
916
|
-
|
|
933
|
+
if (this.#popupGuestMonitor) {
|
|
934
|
+
clearInterval(this.#popupGuestMonitor);
|
|
935
|
+
this.#popupGuestMonitor = null;
|
|
936
|
+
}
|
|
917
937
|
this.#closeAllPopupGuests();
|
|
918
938
|
this.#remoting.close();
|
|
919
939
|
window.removeEventListener("beforeunload", this.#closeAllPopupGuests);
|
|
@@ -966,39 +986,42 @@ class SSFHost {
|
|
|
966
986
|
}
|
|
967
987
|
const guestPromises = [];
|
|
968
988
|
let timingMetricStarted = false;
|
|
969
|
-
|
|
989
|
+
const dispatchToGuest = (guest) => {
|
|
970
990
|
const guestInfo = guest.getInfo();
|
|
971
|
-
if (
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
timingMetricStarted = true;
|
|
983
|
-
}
|
|
984
|
-
this.#logger.audit({
|
|
985
|
-
message: "Event dispatched and awaiting feedback",
|
|
986
|
-
scriptingEventId: id,
|
|
987
|
-
...guestInfo
|
|
988
|
-
});
|
|
989
|
-
} else {
|
|
990
|
-
guest.send({
|
|
991
|
-
messageType: MessageType.ObjectEvent,
|
|
992
|
-
messageBody: eventObj
|
|
993
|
-
});
|
|
994
|
-
this.#logger.audit({
|
|
995
|
-
message: "Event dispatched",
|
|
996
|
-
scriptingEventId: id,
|
|
997
|
-
...guestInfo
|
|
998
|
-
});
|
|
991
|
+
if (timeout && guest?.capabilities?.eventFeedback) {
|
|
992
|
+
guestPromises.push(guest.dispatchEvent(eventObj, timeout));
|
|
993
|
+
if (!timingMetricStarted) {
|
|
994
|
+
this.#startTiming(
|
|
995
|
+
`ScriptingObject.Event.${scriptingObject.id}.${name}`,
|
|
996
|
+
{
|
|
997
|
+
appId: this.hostId,
|
|
998
|
+
appUrl: window.location.href
|
|
999
|
+
}
|
|
1000
|
+
);
|
|
1001
|
+
timingMetricStarted = true;
|
|
999
1002
|
}
|
|
1003
|
+
this.#logger.audit({
|
|
1004
|
+
message: "Event dispatched and awaiting feedback",
|
|
1005
|
+
scriptingEventId: id,
|
|
1006
|
+
...guestInfo
|
|
1007
|
+
});
|
|
1008
|
+
} else {
|
|
1009
|
+
guest.send({
|
|
1010
|
+
messageType: MessageType.ObjectEvent,
|
|
1011
|
+
messageBody: eventObj
|
|
1012
|
+
});
|
|
1013
|
+
this.#logger.audit({
|
|
1014
|
+
message: "Event dispatched",
|
|
1015
|
+
scriptingEventId: id,
|
|
1016
|
+
...guestInfo
|
|
1017
|
+
});
|
|
1000
1018
|
}
|
|
1001
|
-
}
|
|
1019
|
+
};
|
|
1020
|
+
if (targetGuest) {
|
|
1021
|
+
dispatchToGuest(targetGuest);
|
|
1022
|
+
} else {
|
|
1023
|
+
this.#guests.forEach(dispatchToGuest);
|
|
1024
|
+
}
|
|
1002
1025
|
const retValue = await Promise.all(guestPromises).then((values) => {
|
|
1003
1026
|
this.#logger.audit({
|
|
1004
1027
|
message: "Event feedback received",
|
|
@@ -1028,13 +1051,7 @@ class SSFHost {
|
|
|
1028
1051
|
* get reference to all guest applications
|
|
1029
1052
|
* @returns list of guest application references
|
|
1030
1053
|
*/
|
|
1031
|
-
getGuests = () =>
|
|
1032
|
-
const guestList = [];
|
|
1033
|
-
this.#guests.forEach((guest) => {
|
|
1034
|
-
guestList.push(guest);
|
|
1035
|
-
});
|
|
1036
|
-
return guestList;
|
|
1037
|
-
};
|
|
1054
|
+
getGuests = () => Array.from(this.#guests.values());
|
|
1038
1055
|
/**
|
|
1039
1056
|
* get the scripting object by id
|
|
1040
1057
|
* @param objectId - id of the scripting object
|
|
@@ -1059,6 +1076,12 @@ class SSFHost {
|
|
|
1059
1076
|
options = {}
|
|
1060
1077
|
} = param;
|
|
1061
1078
|
if (!guestId) throw new Error("id for guest application is required");
|
|
1079
|
+
if (this.#guests.has(guestId)) {
|
|
1080
|
+
this.#logger.warn(
|
|
1081
|
+
`Guest with id '${guestId}' is already loaded. Unloading existing guest first.`
|
|
1082
|
+
);
|
|
1083
|
+
this.unloadGuest(guestId);
|
|
1084
|
+
}
|
|
1062
1085
|
const { openMode = OpenMode.Embed, popupWindowFeatures = {} } = options;
|
|
1063
1086
|
const srcUrl = this.#getGuestUrl(url, searchParams);
|
|
1064
1087
|
let guest = null;
|
|
@@ -1153,11 +1176,14 @@ class SSFHost {
|
|
|
1153
1176
|
const guest = this.#findGuest(guestIdOrWindowOrEle);
|
|
1154
1177
|
if (guest) {
|
|
1155
1178
|
guest.dispose();
|
|
1179
|
+
this.#guestsByWindow.delete(guest.window);
|
|
1180
|
+
this.#guestsByUrl.delete(guest.url);
|
|
1156
1181
|
this.#guests.delete(guest.id);
|
|
1157
1182
|
this.#logger.audit({
|
|
1158
1183
|
message: `Guest is removed from host`,
|
|
1159
1184
|
...guest.getInfo()
|
|
1160
1185
|
});
|
|
1186
|
+
this.#stopMonitoringPopupGuests();
|
|
1161
1187
|
}
|
|
1162
1188
|
};
|
|
1163
1189
|
/**
|
package/dist/esm/utils.js
CHANGED
|
@@ -8,29 +8,12 @@ const getOrigin = (url) => {
|
|
|
8
8
|
return origin;
|
|
9
9
|
}
|
|
10
10
|
};
|
|
11
|
-
const flatten = (source
|
|
12
|
-
const retVal = target || [];
|
|
13
|
-
if (source && source.forEach) {
|
|
14
|
-
source.forEach((item) => {
|
|
15
|
-
flatten(item, retVal);
|
|
16
|
-
});
|
|
17
|
-
} else if (typeof source !== "undefined") {
|
|
18
|
-
retVal.push(source);
|
|
19
|
-
}
|
|
20
|
-
return retVal;
|
|
21
|
-
};
|
|
22
|
-
const isScriptingObject = (value) => (
|
|
23
|
-
// eslint-disable-next-line no-underscore-dangle, @typescript-eslint/no-unsafe-member-access
|
|
24
|
-
typeof value?._toJSON === "function"
|
|
25
|
-
);
|
|
11
|
+
const flatten = (source) => source.flat(Infinity).filter((v) => v !== void 0);
|
|
26
12
|
function isFunction(value) {
|
|
27
13
|
return typeof value === "function";
|
|
28
14
|
}
|
|
29
|
-
const getObjectId = (elementOrId) => elementOrId?.id ?? elementOrId;
|
|
30
15
|
export {
|
|
31
16
|
flatten,
|
|
32
|
-
getObjectId,
|
|
33
17
|
getOrigin,
|
|
34
|
-
isFunction
|
|
35
|
-
isScriptingObject
|
|
18
|
+
isFunction
|
|
36
19
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["webpack://ice.host/analytics-object-v1.js"],"sourcesContent":["export class Analytics extends elli.ssf.ScriptingObject {\n constructor() {\n super('Analytics');\n }\n\n sendBAEvent = (event) => {\n return Promise.resolve();\n }\n\n startTiming = (name, options) => {\n return Promise.resolve(performance.mark(name, { detail: options }));\n }\n\n endTiming = (start, options) => {\n performance.measure(start, {\n detail: options,\n start: start,\n });\n return Promise.resolve();\n }\n}\n"],"mappings":"AAAO,aAAM,kBAAkB,KAAK,IAAI,eAAgB,CACtD,aAAc,CACZ,MAAM,WAAW,CACnB,CAEA,YAAeA,GACN,QAAQ,QAAQ,EAGzB,YAAc,CAACC,EAAMC,IACZ,QAAQ,QAAQ,YAAY,KAAKD,EAAM,CAAE,OAAQC,CAAQ,CAAC,CAAC,EAGpE,UAAY,CAACC,EAAOD,KAClB,YAAY,QAAQC,EAAO,CACzB,OAAQD,EACR,MAAOC,CACT,CAAC,EACM,QAAQ,QAAQ,EAE3B","names":["event","name","options","start"],"sourceRoot":"","file":"analytics-object-v1.js"}
|
|
1
|
+
{"version":3,"sources":["webpack://ice.host/analytics-object-v1.js"],"sourcesContent":["export class Analytics extends elli.ssf.ScriptingObject {\n constructor() {\n super('Analytics');\n }\n\n sendBAEvent = (event) => {\n return Promise.resolve();\n }\n\n startTiming = (name, options) => {\n return Promise.resolve(performance.mark(name, { detail: options }));\n }\n\n endTiming = (start, options) => {\n performance.measure(start, {\n detail: options,\n start: start,\n });\n return Promise.resolve();\n }\n}\n"],"mappings":"AAAO,aAAM,kBAAkB,KAAK,IAAI,eAAgB,CACtD,aAAc,CACZ,MAAM,WAAW,CACnB,CAEA,YAAeA,GACN,QAAQ,QAAQ,EAGzB,YAAc,CAACC,EAAMC,IACZ,QAAQ,QAAQ,YAAY,KAAKD,EAAM,CAAE,OAAQC,CAAQ,CAAC,CAAC,EAGpE,UAAY,CAACC,EAAOD,KAClB,YAAY,QAAQC,EAAO,CACzB,OAAQD,EACR,MAAOC,CACT,CAAC,EACM,QAAQ,QAAQ,EAE3B","names":["event","name","options","start"],"ignoreList":[],"sourceRoot":"","file":"analytics-object-v1.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["webpack://ice.host/analytics-object-v2.js"],"sourcesContent":["export class Analytics extends ice.host.ScriptingObject {\n constructor() {\n super('Analytics');\n }\n\n sendBAEvent = (event) => {\n return Promise.resolve();\n }\n\n startTiming = (name, options) => {\n return Promise.resolve(performance.mark(name, { detail: options }));\n }\n\n endTiming = (start, options) => {\n performance.measure(start, {\n detail: options,\n start: start,\n });\n return Promise.resolve();\n }\n}\n"],"mappings":"AAAO,aAAM,kBAAkB,IAAI,KAAK,eAAgB,CACtD,aAAc,CACZ,MAAM,WAAW,CACnB,CAEA,YAAeA,GACN,QAAQ,QAAQ,EAGzB,YAAc,CAACC,EAAMC,IACZ,QAAQ,QAAQ,YAAY,KAAKD,EAAM,CAAE,OAAQC,CAAQ,CAAC,CAAC,EAGpE,UAAY,CAACC,EAAOD,KAClB,YAAY,QAAQC,EAAO,CACzB,OAAQD,EACR,MAAOC,CACT,CAAC,EACM,QAAQ,QAAQ,EAE3B","names":["event","name","options","start"],"sourceRoot":"","file":"analytics-object-v2.js"}
|
|
1
|
+
{"version":3,"sources":["webpack://ice.host/analytics-object-v2.js"],"sourcesContent":["export class Analytics extends ice.host.ScriptingObject {\n constructor() {\n super('Analytics');\n }\n\n sendBAEvent = (event) => {\n return Promise.resolve();\n }\n\n startTiming = (name, options) => {\n return Promise.resolve(performance.mark(name, { detail: options }));\n }\n\n endTiming = (start, options) => {\n performance.measure(start, {\n detail: options,\n start: start,\n });\n return Promise.resolve();\n }\n}\n"],"mappings":"AAAO,aAAM,kBAAkB,IAAI,KAAK,eAAgB,CACtD,aAAc,CACZ,MAAM,WAAW,CACnB,CAEA,YAAeA,GACN,QAAQ,QAAQ,EAGzB,YAAc,CAACC,EAAMC,IACZ,QAAQ,QAAQ,YAAY,KAAKD,EAAM,CAAE,OAAQC,CAAQ,CAAC,CAAC,EAGpE,UAAY,CAACC,EAAOD,KAClB,YAAY,QAAQC,EAAO,CACzB,OAAQD,EACR,MAAOC,CACT,CAAC,EACM,QAAQ,QAAQ,EAE3B","names":["event","name","options","start"],"ignoreList":[],"sourceRoot":"","file":"analytics-object-v2.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["webpack://ice.host/application-object-v1.js"],"sourcesContent":["export class Application extends elli.ssf.ScriptingObject {\n constructor() {\n super('Application');\n }\n\n keepSessionAlive = () => {\n return Promise.resolve();\n }\n}\n"],"mappings":"AAAO,aAAM,oBAAoB,KAAK,IAAI,eAAgB,CACxD,aAAc,CACZ,MAAM,aAAa,CACrB,CAEA,iBAAmB,IACV,QAAQ,QAAQ,CAE3B","names":[],"sourceRoot":"","file":"application-object-v1.js"}
|
|
1
|
+
{"version":3,"sources":["webpack://ice.host/application-object-v1.js"],"sourcesContent":["export class Application extends elli.ssf.ScriptingObject {\n constructor() {\n super('Application');\n }\n\n keepSessionAlive = () => {\n return Promise.resolve();\n }\n}\n"],"mappings":"AAAO,aAAM,oBAAoB,KAAK,IAAI,eAAgB,CACxD,aAAc,CACZ,MAAM,aAAa,CACrB,CAEA,iBAAmB,IACV,QAAQ,QAAQ,CAE3B","names":[],"ignoreList":[],"sourceRoot":"","file":"application-object-v1.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["webpack://ice.host/application-object-v2.js"],"sourcesContent":["export class Application extends ice.host.ScriptingObject {\n constructor() {\n super('Application');\n }\n\n keepSessionAlive = () => {\n return Promise.resolve();\n }\n}\n"],"mappings":"AAAO,aAAM,oBAAoB,IAAI,KAAK,eAAgB,CACxD,aAAc,CACZ,MAAM,aAAa,CACrB,CAEA,iBAAmB,IACV,QAAQ,QAAQ,CAE3B","names":[],"sourceRoot":"","file":"application-object-v2.js"}
|
|
1
|
+
{"version":3,"sources":["webpack://ice.host/application-object-v2.js"],"sourcesContent":["export class Application extends ice.host.ScriptingObject {\n constructor() {\n super('Application');\n }\n\n keepSessionAlive = () => {\n return Promise.resolve();\n }\n}\n"],"mappings":"AAAO,aAAM,oBAAoB,IAAI,KAAK,eAAgB,CACxD,aAAc,CACZ,MAAM,aAAa,CACrB,CAEA,iBAAmB,IACV,QAAQ,QAAQ,CAE3B","names":[],"ignoreList":[],"sourceRoot":"","file":"application-object-v2.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["webpack://ice.host/autoFill.js"],"sourcesContent":["import { faker } from 'https://cdn.skypack.dev/@faker-js/faker';\n\nexport const getBorrowerDetails = () => {\n const firstName = faker.name.firstName();\n const lastName = faker.name.lastName();\n const email = faker.internet.email();\n const phone = faker.phone.phoneNumber();\n const address = faker.address.streetAddress();\n const city = faker.address.city();\n const state = faker.address.state();\n const zip = faker.address.zipCode();\n return {\n firstName,\n lastName,\n email,\n phone,\n address,\n city,\n state,\n zip,\n };\n};\n"],"mappings":"AAAA,OAAS,SAAAA,MAAa,0CAEf,aAAM,mBAAqB,IAAM,CACtC,MAAMC,EAAYD,EAAM,KAAK,UAAU,EACjCE,EAAWF,EAAM,KAAK,SAAS,EAC/BG,EAAQH,EAAM,SAAS,MAAM,EAC7BI,EAAQJ,EAAM,MAAM,YAAY,EAChCK,EAAUL,EAAM,QAAQ,cAAc,EACtCM,EAAON,EAAM,QAAQ,KAAK,EAC1BO,EAAQP,EAAM,QAAQ,MAAM,EAC5BQ,EAAMR,EAAM,QAAQ,QAAQ,EAClC,MAAO,CACL,UAAAC,EACA,SAAAC,EACA,MAAAC,EACA,MAAAC,EACA,QAAAC,EACA,KAAAC,EACA,MAAAC,EACA,IAAAC,CACF,CACF","names":["faker","firstName","lastName","email","phone","address","city","state","zip"],"sourceRoot":"","file":"autoFill.js"}
|
|
1
|
+
{"version":3,"sources":["webpack://ice.host/autoFill.js"],"sourcesContent":["import { faker } from 'https://cdn.skypack.dev/@faker-js/faker';\n\nexport const getBorrowerDetails = () => {\n const firstName = faker.name.firstName();\n const lastName = faker.name.lastName();\n const email = faker.internet.email();\n const phone = faker.phone.phoneNumber();\n const address = faker.address.streetAddress();\n const city = faker.address.city();\n const state = faker.address.state();\n const zip = faker.address.zipCode();\n return {\n firstName,\n lastName,\n email,\n phone,\n address,\n city,\n state,\n zip,\n };\n};\n"],"mappings":"AAAA,OAAS,SAAAA,MAAa,0CAEf,aAAM,mBAAqB,IAAM,CACtC,MAAMC,EAAYD,EAAM,KAAK,UAAU,EACjCE,EAAWF,EAAM,KAAK,SAAS,EAC/BG,EAAQH,EAAM,SAAS,MAAM,EAC7BI,EAAQJ,EAAM,MAAM,YAAY,EAChCK,EAAUL,EAAM,QAAQ,cAAc,EACtCM,EAAON,EAAM,QAAQ,KAAK,EAC1BO,EAAQP,EAAM,QAAQ,MAAM,EAC5BQ,EAAMR,EAAM,QAAQ,QAAQ,EAClC,MAAO,CACL,UAAAC,EACA,SAAAC,EACA,MAAAC,EACA,MAAAC,EACA,QAAAC,EACA,KAAAC,EACA,MAAAC,EACA,IAAAC,CACF,CACF","names":["faker","firstName","lastName","email","phone","address","city","state","zip"],"ignoreList":[],"sourceRoot":"","file":"autoFill.js"}
|
package/dist/public/index.html
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><meta name="viewport" content="width=device-width,initial-scale=1"/><title>Host</title><script src="https://cdn.tailwindcss.com?plugins=forms"></script><script src="https://cdn.mortgagetech.q1.ice.com/pui-diagnostics@3"></script><script defer="defer" src="js/emuiSsfHost.
|
|
1
|
+
<!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><meta name="viewport" content="width=device-width,initial-scale=1"/><title>Host</title><script src="https://cdn.tailwindcss.com?plugins=forms"></script><script src="https://cdn.mortgagetech.q1.ice.com/pui-diagnostics@3"></script><script defer="defer" src="js/emuiSsfHost.6b964dde53916a3845ae.js"></script></head><body><header class="bg-indigo-300 h-10 flex place-items-center"><div class="px-2">ICE Mortgage Product</div></header><main class="mx-auto max-w-7xl px-2 sm:px-6 lg:px-8"><div class="min-w-0 flex-1 mt-4"><h1 class="text-2xl font-bold leading-7 text-gray-900 sm:truncate sm:text-3xl sm:tracking-tight">Loan Application</h1></div><div id="successFeedback" class="hidden rounded-md bg-green-50 p-4"><div class="flex"><div class="flex-shrink-0"><svg class="h-5 w-5 text-green-400" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true"><path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z" clip-rule="evenodd"/></svg></div><div class="ml-3"><p class="text-sm font-medium text-green-800">Loan Saved Successfully</p></div></div></div><div id="errorFeedback" class="hidden rounded-md bg-red-50 p-4"><div class="flex"><div class="flex-shrink-0"><svg class="h-5 w-5 text-red-400" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true"><path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.28 7.22a.75.75 0 00-1.06 1.06L8.94 10l-1.72 1.72a.75.75 0 101.06 1.06L10 11.06l1.72 1.72a.75.75 0 101.06-1.06L11.06 10l1.72-1.72a.75.75 0 00-1.06-1.06L10 8.94 8.28 7.22z" clip-rule="evenodd"/></svg></div><div class="ml-3"><h3 class="text-sm font-medium text-red-800">Credit Score is not meeting the requirement</h3></div></div></div><div class="mt-2 sm:grid sm:grid-cols-2 sm:gap-2"><form class="px-2 py-2 space-y-8 divide-y divide-gray-200 bg-gray-50"><div class="space-y-8 divide-y divide-gray-200 sm:space-y-5"><div class="space-y-6 sm:space-y-5"><div><h3 class="text-lg font-medium leading-6 text-gray-900">Personal Information</h3></div><div class="space-y-6 sm:space-y-5"><div class="sm:grid sm:grid-cols-3 sm:items-start sm:gap-4 sm:border-gray-200"><label for="firstName" class="block text-sm font-medium text-gray-700 sm:mt-px sm:pt-2">First name</label><div class="mt-1 sm:col-span-2 sm:mt-0"><input name="firstName" id="firstName" autocomplete="given-name" class="block w-full max-w-lg rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:max-w-xs sm:text-sm" value="John" placeholder="John"/></div></div><div class="sm:grid sm:grid-cols-3 sm:items-start sm:gap-4 sm:border-gray-200"><label for="lastName" class="block text-sm font-medium text-gray-700 sm:mt-px sm:pt-2">Last name</label><div class="mt-1 sm:col-span-2 sm:mt-0"><input name="lastName" id="lastName" autocomplete="family-name" class="block w-full max-w-lg rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:max-w-xs sm:text-sm" value="Doe" placeholder="Doe"/></div></div><div class="sm:grid sm:grid-cols-3 sm:items-start sm:gap-4 sm:border-gray-200"><label for="ssn" class="block text-sm font-medium text-gray-700 sm:mt-px sm:pt-2">SSN</label><div class="mt-1 sm:col-span-2 sm:mt-0"><input type="number" name="ssn" id="ssn" class="block w-full max-w-lg rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:max-w-xs sm:text-sm" value="123456789" placeholder="123456789"/></div></div></div><div><h3 class="text-lg font-medium leading-6 text-gray-900">Loan Information</h3></div><div class="space-y-6 sm:space-y-5"><div class="sm:grid sm:grid-cols-3 sm:items-start sm:gap-4 sm:border-gray-200"><label for="amount" class="block text-sm font-medium text-gray-700 sm:mt-px sm:pt-2">Amount</label><div class="mt-1 sm:col-span-2 sm:mt-0"><input type="number" name="amount" id="amount" class="block w-full max-w-lg rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:max-w-xs sm:text-sm" value="500000" placeholder="500000"/></div></div><div class="sm:grid sm:grid-cols-3 sm:items-start sm:gap-4 sm:border-gray-200"><label for="Term" class="block text-sm font-medium text-gray-700 sm:mt-px sm:pt-2">Term (years)</label><div class="mt-1 sm:col-span-2 sm:mt-0"><input type="number" name="term" id="term" class="block w-full max-w-lg rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:max-w-xs sm:text-sm" value="30" placeholder="30"/></div></div><div class="sm:grid sm:grid-cols-3 sm:items-start sm:gap-4 sm:border-gray-200"><label for="downPayment" class="block text-sm font-medium text-gray-700 sm:mt-px sm:pt-2">Down Payment</label><div class="mt-1 sm:col-span-2 sm:mt-0"><input type="number" name="downPayment" id="downPayment" class="block w-full max-w-lg rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:max-w-xs sm:text-sm" value="50000" placeholder="50000"/></div></div><div><h3 class="text-lg font-medium leading-6 text-gray-900">Order Services</h3></div><div class="sm:grid sm:grid-cols-3 sm:items-start sm:gap-4 sm:border-gray-200"><div class="mt-1 sm:mt-0"><button id="title" type="button" class="inline-flex items-center rounded-md border border-transparent bg-indigo-600 px-4 py-2 text-sm font-medium text-white shadow-sm hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 disabled:opacity-50 disabled:cursor-not-allowed focus:ring-offset-2"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="w-6 h-6"><path fill-rule="evenodd" d="M7.502 6h7.128A3.375 3.375 0 0118 9.375v9.375a3 3 0 003-3V6.108c0-1.505-1.125-2.811-2.664-2.94a48.972 48.972 0 00-.673-.05A3 3 0 0015 1.5h-1.5a3 3 0 00-2.663 1.618c-.225.015-.45.032-.673.05C8.662 3.295 7.554 4.542 7.502 6zM13.5 3A1.5 1.5 0 0012 4.5h4.5A1.5 1.5 0 0015 3h-1.5z" clip-rule="evenodd"/><path fill-rule="evenodd" d="M3 9.375C3 8.339 3.84 7.5 4.875 7.5h9.75c1.036 0 1.875.84 1.875 1.875v11.25c0 1.035-.84 1.875-1.875 1.875h-9.75A1.875 1.875 0 013 20.625V9.375zM6 12a.75.75 0 01.75-.75h.008a.75.75 0 01.75.75v.008a.75.75 0 01-.75.75H6.75a.75.75 0 01-.75-.75V12zm2.25 0a.75.75 0 01.75-.75h3.75a.75.75 0 010 1.5H9a.75.75 0 01-.75-.75zM6 15a.75.75 0 01.75-.75h.008a.75.75 0 01.75.75v.008a.75.75 0 01-.75.75H6.75a.75.75 0 01-.75-.75V15zm2.25 0a.75.75 0 01.75-.75h3.75a.75.75 0 010 1.5H9a.75.75 0 01-.75-.75zM6 18a.75.75 0 01.75-.75h.008a.75.75 0 01.75.75v.008a.75.75 0 01-.75.75H6.75a.75.75 0 01-.75-.75V18zm2.25 0a.75.75 0 01.75-.75h3.75a.75.75 0 010 1.5H9a.75.75 0 01-.75-.75z" clip-rule="evenodd"/></svg> Title</button></div><div class="mt-1 sm:mt-0"><button id="credit" type="button" class="inline-flex items-center rounded-md border border-transparent bg-indigo-600 px-4 py-2 text-sm font-medium text-white shadow-sm hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 disabled:opacity-50 disabled:cursor-not-allowed focus:ring-offset-2"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="w-6 h-6"><path fill-rule="evenodd" d="M2.25 13.5a8.25 8.25 0 018.25-8.25.75.75 0 01.75.75v6.75H18a.75.75 0 01.75.75 8.25 8.25 0 01-16.5 0z" clip-rule="evenodd"/><path fill-rule="evenodd" d="M12.75 3a.75.75 0 01.75-.75 8.25 8.25 0 018.25 8.25.75.75 0 01-.75.75h-7.5a.75.75 0 01-.75-.75V3z" clip-rule="evenodd"/></svg> Credit Score</button></div></div></div></div></div><div class="flex flex-col"><button id="saveLoan" type="button" class="rounded-md border border-transparent bg-indigo-600 px-4 py-2 text-sm font-medium text-white shadow-sm hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2">Save</button></div></form><div id="aside-container" class="flex flex-col gap-4 items-start mt-4 border-2 p-2 rounded-lg border-dashed border-cyan-300 sm:mt-0"></div></div><div id="bottom-container" class="flex flex-col gap-4 items-start mt-4 p-2 sm:mt-0"></div></main><script src="./init.js" type="module"></script></body></html>
|
package/dist/public/init.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["webpack://ice.host/init.js"],"sourcesContent":["import { Loan } from './loan-object.js';\nimport { Analytics } from './analytics-object-v2.js';\nimport { Application } from './application-object-v2.js';\nimport { getGuestBaseUrl, getHost } from './utils.js';\n\nlet host = null;\nlet loanObj = null;\n\nconst setupCreditService = async () => {\n const baseUrl = await getGuestBaseUrl();\n document.getElementById('credit').addEventListener('click', () => {\n const { id } = host.loadGuest({\n id: 'creditService',\n url: new URL('./creditService.html', baseUrl).href,\n title: 'Credit Service Corp',\n searchParams: { src: new URL('./creditScoreService.js', baseUrl).href },\n targetElement: document.getElementById('bottom-container'),\n options: { fitToContent: true },\n });\n });\n};\n\nconst setupPricingService = async () => {\n const baseUrl = await getGuestBaseUrl();\n const params = {};\n host.loadGuest({\n id: 'pricingService',\n url: new URL('./pricingService.html', baseUrl).href,\n title: 'Pricing Service Corp',\n params,\n targetElement: document.getElementById('aside-container'),\n options: { fitToContent: true },\n });\n};\n\nconst setupLoanValidationService = async () => {\n const baseUrl = await getGuestBaseUrl();\n const params = {};\n host.loadGuest({\n id: 'loanValidation',\n url: new URL('./loanValidation.html', baseUrl).href,\n title: 'Loan Validation Service Corp',\n params,\n targetElement: document.getElementById('bottom-container'),\n options: { fitToContent: true },\n });\n};\n\nconst setupTitleService = async () => {\n const baseUrl = await getGuestBaseUrl();\n const params = {};\n host.loadGuest({\n id: 'titleService',\n url: new URL('./titleService.html', baseUrl).href,\n title: 'Title Service Corp',\n params,\n targetElement: document.getElementById('aside-container'),\n options: { openMode: ice.host.OpenMode.Popup },\n });\n};\n\nconst setupObjects = () => {\n loanObj = new Loan();\n host.addScriptingObject(loanObj);\n const appObj = new Application();\n host.addScriptingObject(appObj);\n};\n\nconst saveLoan = async () => {\n const loanDetails = loanObj.getLoanDetails();\n const results = await host.dispatchEvent({\n event: loanObj.onPreSave,\n eventParams: loanDetails,\n eventOptions: {\n timeout: 1000,\n },\n });\n if (results.some((result) => result === false)) {\n const errorFeedback = document.getElementById('errorFeedback');\n errorFeedback.classList.remove('hidden');\n } else {\n const successFeedback = document.getElementById('successFeedback');\n successFeedback.classList.remove('hidden');\n }\n};\n\nconst init = () => {\n // elli.ssf.setLogLevel(0);\n const analyticsObj = new Analytics();\n host = getHost(analyticsObj);\n setupObjects();\n const saveLoanButton = document.getElementById('saveLoan');\n if (saveLoanButton) saveLoanButton.addEventListener('click', saveLoan);\n setupCreditService();\n setupPricingService();\n setupLoanValidationService();\n document\n .getElementById('title')\n ?.addEventListener?.('click', setupTitleService);\n};\n\nwindow.addEventListener('DOMContentLoaded', init);\n"],"mappings":"AAAA,OAAS,QAAAA,MAAY,mBACrB,OAAS,aAAAC,MAAiB,2BAC1B,OAAS,eAAAC,MAAmB,6BAC5B,OAAS,mBAAAC,EAAiB,WAAAC,MAAe,aAEzC,IAAIC,EAAO,KACPC,EAAU,KAEd,MAAMC,EAAqB,SAAY,CACrC,MAAMC,EAAU,MAAML,EAAgB,EACtC,SAAS,eAAe,QAAQ,EAAE,iBAAiB,QAAS,IAAM,CAChE,KAAM,CAAE,GAAAM,CAAG,EAAIJ,EAAK,UAAU,CAC5B,GAAI,gBACJ,IAAK,IAAI,IAAI,uBAAwBG,CAAO,EAAE,KAC9C,MAAO,sBACP,aAAc,CAAE,IAAK,IAAI,IAAI,0BAA2BA,CAAO,EAAE,IAAK,EACtE,cAAe,SAAS,eAAe,kBAAkB,EACzD,QAAS,CAAE,aAAc,EAAK,CAChC,CAAC,CACH,CAAC,CACH,EAEME,EAAsB,SAAY,CACtC,MAAMF,EAAU,MAAML,EAAgB,EAChCQ,EAAS,CAAC,EAChBN,EAAK,UAAU,CACb,GAAI,iBACJ,IAAK,IAAI,IAAI,wBAAyBG,CAAO,EAAE,KAC/C,MAAO,uBACP,OAAAG,EACA,cAAe,SAAS,eAAe,iBAAiB,EACxD,QAAS,CAAE,aAAc,EAAK,CAChC,CAAC,CACH,EAEMC,EAA6B,SAAY,CAC7C,MAAMJ,EAAU,MAAML,EAAgB,EAChCQ,EAAS,CAAC,EAChBN,EAAK,UAAU,CACb,GAAI,iBACJ,IAAK,IAAI,IAAI,wBAAyBG,CAAO,EAAE,KAC/C,MAAO,+BACP,OAAAG,EACA,cAAe,SAAS,eAAe,kBAAkB,EACzD,QAAS,CAAE,aAAc,EAAK,CAChC,CAAC,CACH,EAEME,EAAoB,SAAY,CACpC,MAAML,EAAU,MAAML,EAAgB,EAChCQ,EAAS,CAAC,EAChBN,EAAK,UAAU,CACb,GAAI,eACJ,IAAK,IAAI,IAAI,sBAAuBG,CAAO,EAAE,KAC7C,MAAO,qBACP,OAAAG,EACA,cAAe,SAAS,eAAe,iBAAiB,EACxD,QAAS,CAAE,SAAU,IAAI,KAAK,SAAS,KAAM,CAC/C,CAAC,CACH,EAEMG,EAAe,IAAM,CACzBR,EAAU,IAAIN,EACdK,EAAK,mBAAmBC,CAAO,EAC/B,MAAMS,EAAS,IAAIb,EACnBG,EAAK,mBAAmBU,CAAM,CAChC,EAEMC,EAAW,SAAY,CAC3B,MAAMC,EAAcX,EAAQ,eAAe,GAC3B,MAAMD,EAAK,cAAc,CACvC,MAAOC,EAAQ,UACf,YAAaW,EACb,aAAc,CACZ,QAAS,GACX,CACF,CAAC,GACW,KAAMC,GAAWA,IAAW,EAAK,EACrB,SAAS,eAAe,eAAe,EAC/C,UAAU,OAAO,QAAQ,EAEf,SAAS,eAAe,iBAAiB,EACjD,UAAU,OAAO,QAAQ,CAE7C,EAEMC,EAAO,IAAM,CAEjB,MAAMC,EAAe,IAAInB,EACzBI,EAAOD,EAAQgB,CAAY,EAC3BN,EAAa,EACb,MAAMO,EAAiB,SAAS,eAAe,UAAU,EACrDA,GAAgBA,EAAe,iBAAiB,QAASL,CAAQ,EACrET,EAAmB,EACnBG,EAAoB,EACpBE,EAA2B,EAC3B,SACG,eAAe,OAAO,GACrB,mBAAmB,QAASC,CAAiB,CACnD,EAEA,OAAO,iBAAiB,mBAAoBM,CAAI","names":["Loan","Analytics","Application","getGuestBaseUrl","getHost","host","loanObj","setupCreditService","baseUrl","id","setupPricingService","params","setupLoanValidationService","setupTitleService","setupObjects","appObj","saveLoan","loanDetails","result","init","analyticsObj","saveLoanButton"],"sourceRoot":"","file":"init.js"}
|
|
1
|
+
{"version":3,"sources":["webpack://ice.host/init.js"],"sourcesContent":["import { Loan } from './loan-object.js';\nimport { Analytics } from './analytics-object-v2.js';\nimport { Application } from './application-object-v2.js';\nimport { getGuestBaseUrl, getHost } from './utils.js';\n\nlet host = null;\nlet loanObj = null;\n\nconst setupCreditService = async () => {\n const baseUrl = await getGuestBaseUrl();\n document.getElementById('credit').addEventListener('click', () => {\n const { id } = host.loadGuest({\n id: 'creditService',\n url: new URL('./creditService.html', baseUrl).href,\n title: 'Credit Service Corp',\n searchParams: { src: new URL('./creditScoreService.js', baseUrl).href },\n targetElement: document.getElementById('bottom-container'),\n options: { fitToContent: true },\n });\n });\n};\n\nconst setupPricingService = async () => {\n const baseUrl = await getGuestBaseUrl();\n const params = {};\n host.loadGuest({\n id: 'pricingService',\n url: new URL('./pricingService.html', baseUrl).href,\n title: 'Pricing Service Corp',\n params,\n targetElement: document.getElementById('aside-container'),\n options: { fitToContent: true },\n });\n};\n\nconst setupLoanValidationService = async () => {\n const baseUrl = await getGuestBaseUrl();\n const params = {};\n host.loadGuest({\n id: 'loanValidation',\n url: new URL('./loanValidation.html', baseUrl).href,\n title: 'Loan Validation Service Corp',\n params,\n targetElement: document.getElementById('bottom-container'),\n options: { fitToContent: true },\n });\n};\n\nconst setupTitleService = async () => {\n const baseUrl = await getGuestBaseUrl();\n const params = {};\n host.loadGuest({\n id: 'titleService',\n url: new URL('./titleService.html', baseUrl).href,\n title: 'Title Service Corp',\n params,\n targetElement: document.getElementById('aside-container'),\n options: { openMode: ice.host.OpenMode.Popup },\n });\n};\n\nconst setupObjects = () => {\n loanObj = new Loan();\n host.addScriptingObject(loanObj);\n const appObj = new Application();\n host.addScriptingObject(appObj);\n};\n\nconst saveLoan = async () => {\n const loanDetails = loanObj.getLoanDetails();\n const results = await host.dispatchEvent({\n event: loanObj.onPreSave,\n eventParams: loanDetails,\n eventOptions: {\n timeout: 1000,\n },\n });\n if (results.some((result) => result === false)) {\n const errorFeedback = document.getElementById('errorFeedback');\n errorFeedback.classList.remove('hidden');\n } else {\n const successFeedback = document.getElementById('successFeedback');\n successFeedback.classList.remove('hidden');\n }\n};\n\nconst init = () => {\n // elli.ssf.setLogLevel(0);\n const analyticsObj = new Analytics();\n host = getHost(analyticsObj);\n setupObjects();\n const saveLoanButton = document.getElementById('saveLoan');\n if (saveLoanButton) saveLoanButton.addEventListener('click', saveLoan);\n setupCreditService();\n setupPricingService();\n setupLoanValidationService();\n document\n .getElementById('title')\n ?.addEventListener?.('click', setupTitleService);\n};\n\nwindow.addEventListener('DOMContentLoaded', init);\n"],"mappings":"AAAA,OAAS,QAAAA,MAAY,mBACrB,OAAS,aAAAC,MAAiB,2BAC1B,OAAS,eAAAC,MAAmB,6BAC5B,OAAS,mBAAAC,EAAiB,WAAAC,MAAe,aAEzC,IAAIC,EAAO,KACPC,EAAU,KAEd,MAAMC,EAAqB,SAAY,CACrC,MAAMC,EAAU,MAAML,EAAgB,EACtC,SAAS,eAAe,QAAQ,EAAE,iBAAiB,QAAS,IAAM,CAChE,KAAM,CAAE,GAAAM,CAAG,EAAIJ,EAAK,UAAU,CAC5B,GAAI,gBACJ,IAAK,IAAI,IAAI,uBAAwBG,CAAO,EAAE,KAC9C,MAAO,sBACP,aAAc,CAAE,IAAK,IAAI,IAAI,0BAA2BA,CAAO,EAAE,IAAK,EACtE,cAAe,SAAS,eAAe,kBAAkB,EACzD,QAAS,CAAE,aAAc,EAAK,CAChC,CAAC,CACH,CAAC,CACH,EAEME,EAAsB,SAAY,CACtC,MAAMF,EAAU,MAAML,EAAgB,EAChCQ,EAAS,CAAC,EAChBN,EAAK,UAAU,CACb,GAAI,iBACJ,IAAK,IAAI,IAAI,wBAAyBG,CAAO,EAAE,KAC/C,MAAO,uBACP,OAAAG,EACA,cAAe,SAAS,eAAe,iBAAiB,EACxD,QAAS,CAAE,aAAc,EAAK,CAChC,CAAC,CACH,EAEMC,EAA6B,SAAY,CAC7C,MAAMJ,EAAU,MAAML,EAAgB,EAChCQ,EAAS,CAAC,EAChBN,EAAK,UAAU,CACb,GAAI,iBACJ,IAAK,IAAI,IAAI,wBAAyBG,CAAO,EAAE,KAC/C,MAAO,+BACP,OAAAG,EACA,cAAe,SAAS,eAAe,kBAAkB,EACzD,QAAS,CAAE,aAAc,EAAK,CAChC,CAAC,CACH,EAEME,EAAoB,SAAY,CACpC,MAAML,EAAU,MAAML,EAAgB,EAChCQ,EAAS,CAAC,EAChBN,EAAK,UAAU,CACb,GAAI,eACJ,IAAK,IAAI,IAAI,sBAAuBG,CAAO,EAAE,KAC7C,MAAO,qBACP,OAAAG,EACA,cAAe,SAAS,eAAe,iBAAiB,EACxD,QAAS,CAAE,SAAU,IAAI,KAAK,SAAS,KAAM,CAC/C,CAAC,CACH,EAEMG,EAAe,IAAM,CACzBR,EAAU,IAAIN,EACdK,EAAK,mBAAmBC,CAAO,EAC/B,MAAMS,EAAS,IAAIb,EACnBG,EAAK,mBAAmBU,CAAM,CAChC,EAEMC,EAAW,SAAY,CAC3B,MAAMC,EAAcX,EAAQ,eAAe,GAC3B,MAAMD,EAAK,cAAc,CACvC,MAAOC,EAAQ,UACf,YAAaW,EACb,aAAc,CACZ,QAAS,GACX,CACF,CAAC,GACW,KAAMC,GAAWA,IAAW,EAAK,EACrB,SAAS,eAAe,eAAe,EAC/C,UAAU,OAAO,QAAQ,EAEf,SAAS,eAAe,iBAAiB,EACjD,UAAU,OAAO,QAAQ,CAE7C,EAEMC,EAAO,IAAM,CAEjB,MAAMC,EAAe,IAAInB,EACzBI,EAAOD,EAAQgB,CAAY,EAC3BN,EAAa,EACb,MAAMO,EAAiB,SAAS,eAAe,UAAU,EACrDA,GAAgBA,EAAe,iBAAiB,QAASL,CAAQ,EACrET,EAAmB,EACnBG,EAAoB,EACpBE,EAA2B,EAC3B,SACG,eAAe,OAAO,GACrB,mBAAmB,QAASC,CAAiB,CACnD,EAEA,OAAO,iBAAiB,mBAAoBM,CAAI","names":["Loan","Analytics","Application","getGuestBaseUrl","getHost","host","loanObj","setupCreditService","baseUrl","id","setupPricingService","params","setupLoanValidationService","setupTitleService","setupObjects","appObj","saveLoan","loanDetails","result","init","analyticsObj","saveLoanButton"],"ignoreList":[],"sourceRoot":"","file":"init.js"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
(function(I,y){typeof exports=="object"&&typeof module=="object"?module.exports=y():typeof define=="function"&&define.amd?define([],y):typeof exports=="object"?exports.ice=y():(I.ice=I.ice||{},I.ice.host=y())})(globalThis,()=>(()=>{"use strict";var v={};v.d=(n,e)=>{for(var t in e)v.o(e,t)&&!v.o(n,t)&&Object.defineProperty(n,t,{enumerable:!0,get:e[t]})},v.o=(n,e)=>Object.prototype.hasOwnProperty.call(n,e),v.r=n=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})};var I={};v.r(I),v.d(I,{Event:()=>y,Guest:()=>q,IFrameSandboxValues:()=>E,OpenMode:()=>f,SANDBOX_DEFAULT:()=>N,SSFHost:()=>te,ScriptingObject:()=>U});class y{name;objectId;id;constructor(e){const{name:t,objectId:i}=e;if(!t)throw new Error("Event name is required");if(!i)throw new Error("Scripting object id is required");this.objectId=i,this.name=t,this.id=`${this.objectId}.${this.name}`.toLowerCase()}}class A{static[Symbol.hasInstance](e){return typeof e=="object"&&e!==null&&"getType"in e&&typeof e.getType=="function"&&e.getType()==="ProxyEvent"}#t;objectId;name;id;getType(){return"ProxyEvent"}constructor(e){const{name:t,objectId:i,eventSrc:s}=e;if(!t)throw new Error("Event name is required");if(!i)throw new Error("Scripting object id is required");if(!s)throw new Error("Event source is required");this.objectId=i,this.name=t,this.#t=s,this.id=`${this.objectId}.${this.name}`.toLowerCase()}subscribe=e=>this.#t.subscribe({eventId:this.id,callback:e});unsubscribe=e=>{this.#t.unsubscribe({eventId:this.id,token:e})}}const W=n=>n instanceof y,ie=(n,e)=>`${n.toLowerCase()}.${e.toLowerCase()}`,H="function",F=(n,e)=>typeof n===H&&!!e&&!e.startsWith("_");class U{#t;#i="Object";constructor(e,t){this.#t=e,this.#i=t||this.#i}get id(){return this.#t}get objectType(){return this.#i}_toJSON=()=>{const e=[],t=[];return Object.keys(this).forEach(i=>{const s=this[i];W(s)?t.push(i):F(s,i)&&e.push(i)}),{objectId:this.#t,objectType:this.#i,functions:e,events:t}};_dispose=()=>{};dispose=()=>{}}var l=(n=>(n.GuestClose="guest:close",n.GuestEventSubscribe="guest:eventSubscribe",n.GuestEventUnsubscribe="guest:eventUnsubscribe",n.GuestFocus="guest:focus",n.GuestReady="guest:ready",n.GuestReadyComplete="guest:readyComplete",n.GuestResize="guest:resize",n.HandShake="handshake",n.HandShakeAck="handshake:ack",n.HostClose="host:close",n.HostConfig="host:config",n.ListObjects="list:objects",n.ObjectEvent="object:event",n.ObjectGet="object:get",n.ObjectInvoke="object:invoke",n))(l||{}),f=(n=>(n.Popup="popup",n.Embed="embed",n))(f||{}),E=(n=>(n.AllowDownloadsWithoutUserActivation="allow-downloads-without-user-activation",n.AllowDownloads="allow-downloads",n.AllowForms="allow-forms",n.AllowModals="allow-modals",n.AllowOrientationLock="allow-orientation-lock",n.AllowPointerLock="allow-pointer-lock",n.AllowPopups="allow-popups",n.AllowPopupsToEscapeSandbox="allow-popups-to-escape-sandbox",n.AllowPresentation="allow-presentation",n.AllowSameOrigin="allow-same-origin",n.AllowScripts="allow-scripts",n.AllowStorageAccessByUserActivation="allow-storage-access-by-user-activation",n.AllowTopNavigation="allow-top-navigation",n.AllowTopNavigationByUserActivation="allow-top-navigation-by-user-activation",n))(E||{});const J=n=>{if(n==="about:blank")return"*";try{const{origin:e}=new URL(n);return e==="null"||!e?n:e}catch{const{origin:t}=new URL(n,document.baseURI);return t}},Y=n=>n.flat(1/0).filter(e=>e!==void 0);function R(n){return typeof n=="function"}class q{id;title;url;searchParams;domElement;window;openMode;origin;initialized=!1;ready=!1;capabilities;#t;#i;constructor(e){const{guestId:t,domElement:i=null,title:s,url:o,window:r,searchParams:c={},openMode:a=f.Embed,remoting:d,analyticsObj:u}=e;this.id=t,this.title=s,this.url=o,this.origin=J(o),this.searchParams=c,this.domElement=i,this.window=r,this.openMode=a,this.capabilities={},this.#i=u,this.#t=d}dispose=()=>{if(this.openMode===f.Popup&&!this.window.closed)try{this.window.document,this.window.close()}catch{this.#t.send({targetWin:this.window,targetOrigin:this.origin,messageType:l.HostClose,messageBody:{}})}else this.domElement?.remove?.();this.#t.removeSender({origin:this.origin,window:this.window})};getInfo=()=>({guestId:this.id,guestTitle:this.title,guestUrl:this.url});handShake=()=>new Promise(e=>{let t=0;const i=5;let s;const o=()=>{clearInterval(s),this.#t.unlisten({messageType:l.HandShakeAck,callback:o}),e(!0)};s=setInterval(()=>{t>=i?(clearInterval(s),this.#t.unlisten({messageType:l.HandShakeAck,callback:o}),e(!1)):(this.#t.send({targetWin:this.window,targetOrigin:this.origin,messageType:l.HandShake,messageBody:{}}),t+=1)},1e3),this.#t.listen({messageType:l.HandShakeAck,callback:o})});init=()=>{this.#t.addSender({origin:this.origin,window:this.window}),this.openMode===f.Popup&&this.handShake().catch(()=>{})};dispatchEvent=(e,t)=>(this.#i.startTiming(`ScriptingObject.Event.${e.object.objectId}.${e.eventName}`,{appId:this.id,appUrl:this.url}).catch(()=>{}),this.#t.invoke({targetWin:this.window,targetOrigin:this.origin,messageType:l.ObjectEvent,messageBody:e,responseTimeoutMs:t}).finally(()=>{this.#i.endTiming(`ScriptingObject.Event.${e.object.objectId}.${e.eventName}`,{appId:this.id,appUrl:this.url}).catch(()=>{})}));send=e=>{this.#t.send({targetWin:this.window,targetOrigin:this.origin,...e})}}const _={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};let P;const X=new Uint8Array(16);function K(){if(!P&&(P=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!P))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return P(X)}const h=[];for(let n=0;n<256;++n)h.push((n+256).toString(16).slice(1));function L(n,e=0){return h[n[e+0]]+h[n[e+1]]+h[n[e+2]]+h[n[e+3]]+"-"+h[n[e+4]]+h[n[e+5]]+"-"+h[n[e+6]]+h[n[e+7]]+"-"+h[n[e+8]]+h[n[e+9]]+"-"+h[n[e+10]]+h[n[e+11]]+h[n[e+12]]+h[n[e+13]]+h[n[e+14]]+h[n[e+15]]}function ne(n,e=0){const t=L(n,e);if(!validate(t))throw TypeError("Stringified UUID is invalid");return t}const oe=null;function Q(n,e,t){if(_.randomUUID&&!e&&!n)return _.randomUUID();n=n||{};const i=n.random||(n.rng||K)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,e){t=t||0;for(let s=0;s<16;++s)e[t+s]=i[s];return e}return L(i)}const M=Q,C="elli:remoting",x="elli:remoting:response",D="elli:remoting:exception",$=({messageType:n,messageBody:e,requestId:t,onewayMsg:i=!1})=>({requestId:t??(i?null:M()),source:C,type:n,body:e}),re=n=>{const{targetWin:e,targetOrigin:t,messageType:i,messageBody:s}=n,o=$({messageType:i,messageBody:s});e.postMessage(o,t)};class Z{#t;#i;#e=new Map;#n=new Map;#s=null;#o=null;#r=new Map;constructor(e,t){if(!e)throw new Error("logger is required");if(!t)throw new Error("correlationId is required");this.#t=t,this.#i=e}#l=()=>{this.#s=null;const e=Date.now(),t=[];let i=null;if(this.#n.forEach((s,o)=>{const{requestId:r,cancelTime:c}=s;c&&c<=e?(this.#i.debug(`Detected response timeout for requestId: ${r}...`),t.push(o),s.resolve(void 0)):c&&(i=i===null?c:Math.min(i,c))}),t.forEach(s=>{this.#n.delete(s)}),i!==null){const s=Math.max(i-Date.now(),0);this.#c(s)}};#c=e=>{this.#s===null&&(this.#s=window.setTimeout(this.#l,e))};#h=()=>{this.#s!==null&&(window.clearTimeout(this.#s),this.#s=null)};#a=e=>{const t=this.#n.get(e);return this.#i.debug(`serving requestId: ${e}`),this.#n.delete(e),t};#g=e=>{const{requestId:t}=e;this.#i.debug(`Response received for invocation requestId: ${t}`);const i=this.#a(t);return i?(i.resolve(e.body),!0):(this.#i.debug(`Received response to stale/invalid request with requestId: ${t}`),!1)};#p=e=>{this.#i.debug(`Exception received for invocation (requestId = ${e.requestId})`);const t=this.#a(e.requestId);return t?(t.reject(new Error(e.body)),!0):(this.#i.warn(`Received exception for stale/invalid request (requestId = ${e.requestId})`),!1)};#m=({sourceWin:e,sourceOrigin:t,message:i})=>{this.#i.debug(`Received message of type "${i.type}"`);const s=this.#e.get(i.type);return s?(s.forEach(o=>{this.#i.debug(`Invoking message handler ${o.name}`),o({sourceWin:e,sourceOrigin:t,requestId:i.requestId,type:i.type,body:i.body})}),!0):!1};#u=e=>{if(this.#r.size===0||!e.source)return!1;const t=this.#r.get(e.source);return!t||e?.data?.source!==C?!1:(this.#i.debug(`Remoting: Received message of type "${e.data.type}"`),e.data.type===x?this.#g(e.data):e.data.type===D?this.#p(e.data):this.#m({sourceWin:e.source,sourceOrigin:t,message:e.data}),!0)};addSender=e=>{const{origin:t,window:i}=e;if(!t)throw new Error("origin is required");if(!i)throw new Error("window is required");this.#r.set(i,t)};initialize=e=>{this.#o&&this.#o.removeEventListener("message",this.#u),e.addEventListener("message",this.#u),this.#o=e,this.#i.debug(`initialized remoting id: ${this.#t}`)};close=()=>{this.#o&&(this.#o.removeEventListener("message",this.#u),this.#o=null),this.#h(),this.#i.debug(`closed remoting id: ${this.#t}`)};invoke=e=>{const{targetWin:t,targetOrigin:i,messageType:s,messageBody:o,responseTimeoutMs:r}=e;return new Promise((c,a)=>{const d=$({messageType:s,messageBody:o});this.#n.set(d.requestId,{requestId:d.requestId,resolve:c,reject:a,cancelTime:r?Date.now()+r:null}),t.postMessage(d,i);const{requestId:u}=d;this.#i.debug(`Posted invocation message of type ${s} requestId: ${u||""}`),r&&(this.#i.debug(`scheduling timeout check for requestId: ${u||""} in ${r} ms`),this.#c(r))})};listen=e=>{const{messageType:t,callback:i}=e,s=this.#e.get(t)||[];s.push(i),this.#e.set(t,s)};unlisten=e=>{const{messageType:t,callback:i}=e,s=this.#e.get(t);if(!s)return;const o=s.indexOf(i);o!==-1&&s.splice(o,1)};send=e=>{const{targetWin:t,targetOrigin:i,messageType:s,messageBody:o}=e,r=$({messageType:s,messageBody:o,onewayMsg:!0});t.postMessage(r,i),this.#i.debug(`Posted one-way message of type "${s}"`)};removeSender=e=>{const{window:t}=e;t&&this.#r.delete(t)};respond=e=>{const{targetWin:t,targetOrigin:i,requestId:s,response:o}=e,r=$({messageType:x,messageBody:o,requestId:s});t.postMessage(r,i),this.#i.debug(`Response sent to caller for invocation requestId: ${s}`)};raiseException=e=>{const{targetWin:t,targetOrigin:i,requestId:s,ex:o}=e,r=o instanceof Error?o.message:o,c=$({messageType:D,messageBody:r,requestId:s});t.postMessage(c,i),this.#i.debug(`Exception sent to caller for invocation. requestId: ${s}`)}}const z="module";var V=(n=>(n.USER="USER",n.PARTNER="PARTNER",n))(V||{});class ee{#t=e=>e.trim().toLowerCase();#i=new Map;#e=new Map;#n=e=>{const{so:t,guestId:i}=e,s=this.#t(t.id),o=this.#e.get(i);if(!o)this.#e.set(i,new Map([[s,e]]));else{if(o.has(s))throw new Error(`Scripting Object ${t.id} already exists for guest ${i}`);o.set(s,e)}};#s=({so:e})=>{if(e._dispose&&typeof e._dispose=="function")try{e._dispose()}catch{}};#o=({objectId:e,guestId:t})=>{if(e===z&&!t)for(const[,s]of this.#e){const o=s.get(e);if(o)return o}const i=t?this.#e.get(t):null;return i?i.get(e)??null:null};#r=({objectId:e,guestId:t}={})=>{if(t){if(!e){const s=this.#e.get(t);s&&s.forEach(this.#s),this.#e.delete(t);return}const i=this.#e.get(t);if(i){const s=i.get(e);s&&this.#s(s),i.delete(e)}}else e&&this.#e.forEach(i=>{const s=i.get(e);s&&this.#s(s),i.delete(e)})};addScriptingObject=(e,t)=>{const{guestId:i}=t||{};if(!e?.id||!e?._toJSON)throw new Error("Object is not derived from ScriptingObject");const s=this.#t(e.id);if(s===z&&!i)throw new Error("Guest id is required to add Module scripting object");if(i){this.#n({so:e,...t,guestId:i});return}if(this.#i.has(s))throw new Error(`Scripting Object ${e.id} already exists`);this.#i.set(s,{so:e,...t})};getObject=(e,t)=>{const i=this.#t(e);let s=this.#o({objectId:i,guestId:t?.id});s=s??this.#i.get(i)??null;const{so:o}=s||{};return o||null};has=(e,t)=>this.getObject(e,t)!==null;listScriptingObjects=e=>{const t=new Set(this.#i.keys()),i=this.#e.get(e);if(i)for(const s of i.keys())t.add(s);return Array.from(t)};removeScriptingObject=(e,t)=>{const i=this.#t(e);if(t)this.#r({objectId:i,guestId:t});else{this.#r({objectId:i});const s=this.#i.get(i);s&&this.#s(s),this.#i.delete(i)}};removeAllScriptingObjects=e=>{e?this.#r({guestId:e}):(this.#i.forEach(this.#s),this.#i.clear())}}class ce{__TYPE__="Proxy";id;objectType;constructor(e,t){this.id=e,this.objectType=t}}const B=n=>n?.constructor?.name==="Proxy"||n?.constructor?.name==="ScriptingObjectProxy"||n?.__TYPE__==="Proxy",N=[E.AllowScripts,E.AllowPopups,E.AllowModals,E.AllowForms,E.AllowDownloads,E.AllowSameOrigin];class te{hostId;#t;#i;#e;#n;#s=new Map;#o=new Map;#r=new Map;#l=new Map;#c;#h=null;#a=null;#g=null;#p=null;constructor(e,t){if(this.hostId=e,!t?.logger)throw new Error("Logger is required");if(!t?.analyticsObj)throw new Error("Analytics object is required");if(this.#e=t.logger,this.#n=t.analyticsObj,this.#i=M(),this.#t=new Z(this.#e,this.#i),t?.readyStateCallback&&typeof t?.readyStateCallback!="function")throw new Error("readyStateCallback must be a function");this.#h=t?.readyStateCallback||null,this.#g=t?.onGuestEventSubscribe||null,this.#p=t?.onGuestEventUnsubscribe||null,this.#c=new ee,this.#t.initialize(window),this.#_(),window.addEventListener("beforeunload",this.#f),this.#e.debug(`host is initialized. hostId: ${this.hostId}, correlationId: ${this.#i}`)}#m=(e,t)=>{const i={event:e,...t};this.#n.sendBAEvent(i).catch(s=>{this.#e.debug(`Analytics sendBAEvent failed: ${s.message}`)})};#u=(e,t)=>{this.#n.startTiming(e,t).catch(i=>{this.#e.debug(`Analytics startTiming failed: ${i.message}`)})};#b=(e,t)=>{this.#n.endTiming(e,t).catch(i=>{this.#e.debug(`Analytics endTiming failed: ${i.message}`)})};#f=()=>{Array.from(this.#s.values()).filter(t=>t.openMode===f.Popup).map(t=>t.id).forEach(t=>this.unloadGuest(t))};#d=e=>this.#o.get(e);#O=e=>this.#r.get(e)??null;#S=e=>typeof e?._toJSON=="function";#v=(e,t)=>this.#S(e)?(this.#c.has(e?.id,t)||this.#c.addScriptingObject(e,t?{guestId:t?.id}:{}),{type:"object",object:e._toJSON()}):{type:"value",value:e};#B=e=>typeof e=="string"?e:e instanceof Error?e.message:"An unexpected error occurred in the host application";#y=e=>{e.ready&&this.#t.send({targetWin:e.window,targetOrigin:e.origin,messageType:l.HostConfig,messageBody:{logLevel:this.#e.getLogLevel(),...e.getInfo()}})};#I=({guest:e,obj:t,functionName:i,functionParams:s})=>{const o=t[i];return R(o)?(this.#e.debug(`Invoking host implementation of ${t.id}.${String(i)}()`),new Promise(r=>{Object.defineProperty(o,"callContext",{value:{guest:e},configurable:!0,enumerable:!0,writable:!0}),r(o(...s))})):(this.#e.warn(`Attempt to call invalid function on object type ${t.objectType}: ${String(i)}`),Promise.reject(new Error(`Method '${i}' not found in Scripting Object '${t.id}'`)))};#E=({sourceWin:e,sourceOrigin:t,requestId:i})=>{const s=this.#d(e);if(!s){this.#e.warn(`Received ready event for unknown guest. requestId: ${i}`);return}if(!s.initialized){this.#e.warn("Guest must be initialized before it is marked as ready"),this.#t.raiseException({targetWin:e,targetOrigin:t,requestId:i,ex:"Guest must be initialized before it is marked as ready"});return}if(!s.ready){s.ready=!0;const o=s.getInfo();this.#b("SSF.Guest.Load",{appId:o.guestId,appUrl:o.guestUrl}),this.#y(s),this.#h?.(s),this.#e.audit({message:"Guest is ready",...o})}};#$=({sourceWin:e,sourceOrigin:t,requestId:i,body:s})=>{const o=this.#d(e);if(!o){this.#e.warn(`Received ready event for unknown guest. requestid = ${i}`);return}o.initialized||(o.initialized=!0,o.capabilities=s||{},this.#e.audit({message:"Guest is initialized",...o.getInfo()})),(!s||!s.onReady)&&this.#E({sourceWin:e,sourceOrigin:t,requestId:i,type:"",body:null})};#k=async({sourceWin:e})=>{if(e?.window){const t=this.#w(e);t&&!await t.handShake()&&this.unloadGuest(e)}};#P=({sourceWin:e,sourceOrigin:t,requestId:i})=>{this.#e.debug(`Processing listObjects request. requestId = ${i}`);const s=this.#d(e);if(!s)return this.#e.warn("Rejected object request from unknown guest window"),!1;const o=this.#c.listScriptingObjects(s.id);return this.#t.respond({targetWin:e,targetOrigin:t,requestId:i,response:o}),this.#e.audit({message:"name of scripting objects returned",requestId:i,objects:o,...s.getInfo()}),!0};#G=({sourceWin:e,sourceOrigin:t,requestId:i,body:s})=>{const{objectId:o}=s;this.#e.debug(`Processing getObject request for object ${o}. requestId = ${i}`);const r=this.#d(e);if(!r)return this.#e.warn("Rejected object request from unknown guest window"),!1;const c=this.getScriptingObject(o,{guest:r});return c?(this.#t.respond({targetWin:e,targetOrigin:t,requestId:i,response:this.#v(c,r)}),this.#e.audit({message:"Scripting Object returned",requestId:i,scriptingObject:o,...r.getInfo()}),!0):(this.#e.warn(`unknown or unauthorized object ${o} from guest ${r.id}`),this.#t.raiseException({targetWin:e,targetOrigin:t,requestId:i,ex:`The requested object (${o}) is not available`}),!1)};#T=({sourceWin:e,requestId:t,body:i})=>{const{eventId:s,criteria:o,token:r}=i;this.#e.debug(`Processing guest event subscribe request for event ${s}. requestId = ${t}`);const c=this.#d(e);if(!c){this.#e.warn("Rejected event subscribe request from unknown guest window");return}setTimeout(()=>{try{this.#g?.({guestId:c.id,eventId:s,criteria:o,token:r})}catch(a){this.#e.warn(`Error in onGuestEventSubscribe callback for event ${s}: ${a.message}`)}},0)};#A=({sourceWin:e,requestId:t,body:i})=>{const{eventId:s,token:o}=i;this.#e.debug(`Processing guest event unsubscribe request for event ${s}. requestId = ${t}`);const r=this.#d(e);if(!r){this.#e.warn("Rejected event unsubscribe request from unknown guest window");return}setTimeout(()=>{try{this.#p?.({guestId:r.id,eventId:s,token:o})}catch(c){this.#e.warn(`Error in onGuestEventUnsubscribe callback for event ${s}: ${c.message}`)}},0)};#U=({sourceWin:e,requestId:t,body:i})=>{const s=this.#d(e);if(!s){this.#e.warn(`Received resize event from unknown guest. requestid = ${t}`);return}s.domElement&&(s.domElement.style.height=`${i.height}px`),this.#e.debug(`Guest ${s.id} resized to ${i.width}x${i.height}`)};#R=({sourceWin:e,sourceOrigin:t,requestId:i,body:s})=>{const{objectId:o}=s,r=this.#d(e);if(!r)return this.#e.warn("Rejected method invocation request from unknown guest window"),!1;this.#e.debug(`Function ${o}.${String(s.functionName)}() called from guest "${r.id}" (requestId = ${i})`);const c=this.getScriptingObject(o,{guest:r});if(!c)return this.#e.warn(`Invocation of unknown or unauthorized object ${o} from guest ${r.id}`),this.#t.raiseException({targetWin:e,targetOrigin:t,requestId:i,ex:`The requested object (${o}) is not available`}),!1;const a=r.getInfo();return this.#u(`ScriptingObject.API.${o}.${s.functionName}`,{appId:a.guestId,appUrl:a.guestUrl}),this.#I({guest:r,obj:c,functionName:s.functionName,functionParams:s.functionParams}).then(d=>{this.#t.respond({targetWin:e,targetOrigin:t,requestId:i,response:this.#v(d,r)}),this.#e.audit({message:"Value returned for Scripting Object method call",requestId:i,scriptingObject:o,scriptingMethod:s.functionName,...a})}).catch(d=>{this.#t.raiseException({targetWin:e,targetOrigin:r.origin,requestId:i,ex:d}),this.#e.audit({message:"Exception thrown for Scripting Object method call",requestId:i,scriptingObject:o,scriptingMethod:s.functionName,...a})}).finally(()=>{this.#b(`ScriptingObject.API.${o}.${s.functionName}`,{appId:a.guestId,appUrl:a.guestUrl})}),!0};#q=()=>{this.#t.listen({messageType:l.GuestResize,callback:this.#U})};#_=()=>{this.#t.listen({messageType:l.GuestReady,callback:this.#$}),this.#t.listen({messageType:l.GuestReadyComplete,callback:this.#E}),this.#t.listen({messageType:l.GuestClose,callback:this.#k}),this.#t.listen({messageType:l.ListObjects,callback:this.#P}),this.#t.listen({messageType:l.ObjectGet,callback:this.#G}),this.#t.listen({messageType:l.ObjectInvoke,callback:this.#R}),this.#t.listen({messageType:l.GuestEventSubscribe,callback:this.#T}),this.#t.listen({messageType:l.GuestEventUnsubscribe,callback:this.#A})};#L=e=>e instanceof A||typeof e?.subscribe=="function";#j=e=>{const t=new q({...e,remoting:this.#t,analyticsObj:this.#n});return t.init(),this.#s.set(e.guestId,t),this.#o.set(t.window,t),this.#r.set(t.url,t),t};#w=e=>{if(typeof e=="string")return this.#s.get(e);const t=this.#o.get(e);return t||Array.from(this.#s.values()).find(i=>i.domElement===e)};#M=()=>{this.#a||(this.#a=setInterval(()=>{const e=[];this.#s.forEach(t=>{t.openMode===f.Popup&&t.window.closed&&e.push(t)}),e.forEach(t=>{const{id:i}=t;this.unloadGuest(i),this.#l.get(i)?.forEach(o=>{Promise.resolve(o({id:i})).catch(()=>{})})})},1e3))};#C=()=>{if(!this.#a)return;Array.from(this.#s.values()).some(t=>t.openMode===f.Popup)||(clearInterval(this.#a),this.#a=null)};#x=e=>{const{url:t,title:i,popupWindowFeatures:s={},searchParams:o,guestId:r,onLoad:c,onError:a}=e,{width:d=800,height:u=600,top:j=100,left:w=100}=s;let g=this.#O(t);if(g)g.window.closed||g.send({messageType:l.GuestFocus,messageBody:{}});else{const O=Object.entries({width:d,height:u,top:j,left:w}).filter(([,b])=>b).map(([b,p])=>`${b}=${p}`).join(","),S=window.open(t,i,`popup, ${O}`);if(S)setTimeout(()=>{try{c?.(r)}catch(b){this.#e.debug(`Error occurred in onLoad for guest with id '${r}': ${b.message}`)}},0);else throw setTimeout(()=>{try{a?.(r)}catch(b){this.#e.debug(`Error occurred in onError for guest with id '${r}': ${b.message}`)}},0),new Error("Failed to open guest application in popup window");S.opener=null,g=this.#j({guestId:r,window:S,title:i,url:t,searchParams:o,openMode:f.Popup}),this.#M()}return g};#D=e=>{const{url:t,title:i,targetElement:s,searchParams:o,guestId:r,onLoad:c,onError:a,options:d={}}=e,u=s.ownerDocument??document,{fitToContent:j=!1,disableSandbox:w=!1,sandboxValues:g=[],customSandboxValues:O=[],style:S="",permissionPolicy:b=""}=d;if(!i)throw new Error("title is required");j&&this.#q();const p=u.createElement("iframe");p.setAttribute("id",r);const G=()=>{setTimeout(()=>{try{c?.(r)}catch(T){this.#e.debug(`Error occurred in onLoad for guest with id '${r}': ${T.message}`)}},0),this.#e.debug(`frame loaded for guest with id '${r}'`),p.removeEventListener("load",G)},m=()=>{setTimeout(()=>{try{a?.(r)}catch(T){this.#e.debug(`Error occurred in onError for guest with id '${r}': ${T.message}`)}},0),this.#e.error(`frame load failed for guest with id '${r}'`),p.removeEventListener("error",m)};p.addEventListener("load",G),p.addEventListener("error",m),p.setAttribute("style",`min-width: 100%; height: 100%; border: 0px; ${S}`),w||p.setAttribute("sandbox",O.length>0?O.join(" "):[...N,...g].join(" ")),p.setAttribute("title",i),p.setAttribute("src",t),b&&p.setAttribute("allow",b),s.appendChild(p);const k=u.getElementById(r);return this.#j({guestId:r,domElement:k,window:k.contentWindow,title:i,url:t,searchParams:o,openMode:f.Embed})};#z=(e,t)=>{let i="";return Object.keys(t).forEach(s=>{i+=`${(i.length?"&":"")+encodeURIComponent(s)}=${encodeURIComponent(t[s])}`}),e+(i?(e.indexOf("?")>=0?"&":"?")+i:"")};addScriptingObject=(e,t)=>{if(B(e)){const i=this.cloneScriptingObject(e);this.#c.addScriptingObject(i,t)}else this.#c.addScriptingObject(e,t)};cloneScriptingObject=e=>{if(!e)throw new Error("proxy is required");const t=new U(e.id,e.objectType);let i=[];return Object.keys(e).forEach(s=>{const o=e[s];if(this.#L(o)){const r=new y({name:o.name||s,objectId:t.id});if(Object.defineProperty(t,s,{value:r,enumerable:!0}),o instanceof A){const c=({eventParams:d,eventOptions:u})=>this.dispatchEvent({event:r,eventParams:d,eventOptions:u}),a=o.subscribe(c);i.push(()=>{o.unsubscribe(a)})}else{const c=o.subscribe?.((a,d,u)=>this.dispatchEvent({event:r,eventParams:d,eventOptions:u}));i.push(()=>{o.unsubscribe?.(c)})}}else if(R(o)&&(Object.defineProperty(t,s,{value:async(...r)=>{const c=await o(...r);return B(c)?this.cloneScriptingObject(c):c},enumerable:!0}),s==="dispose")){const r=t.dispose;Object.defineProperty(t,s,{value:()=>(t._dispose(),r.apply(t)),enumerable:!0})}}),t._dispose=()=>{i.forEach(s=>{s?.()}),i=[]},t};close=()=>{this.#a&&(clearInterval(this.#a),this.#a=null),this.#f(),this.#t.close(),window.removeEventListener("beforeunload",this.#f),this.#e.debug(`host is closed. hostId: ${this.hostId}, correlationId: ${this.#i}`)};dispatchEvent=async e=>{const{event:{id:t,name:i},eventParams:s,eventOptions:o={}}=e,{eventHandler:r=null,timeout:c=null,window:a=null,guestId:d}=o,u=t.split(".")[0],j=d||a,w=j?this.#w(j):null,g=w?this.getScriptingObject(u,{guest:w}):this.getScriptingObject(u);if(!g)return this.#e.warn(`Attempt to dispatch event ${i} on unknown object ${u}`),Promise.resolve([]);const O={object:g._toJSON(),eventName:i,eventParams:s,eventHandler:r,eventOptions:{allowsFeedback:!1}};c&&!Number.isNaN(c)&&(O.eventOptions={allowsFeedback:!0,timeout:Number(c)});const S=[];let b=!1;const p=m=>{const k=m.getInfo();c&&m?.capabilities?.eventFeedback?(S.push(m.dispatchEvent(O,c)),b||(this.#u(`ScriptingObject.Event.${g.id}.${i}`,{appId:this.hostId,appUrl:window.location.href}),b=!0),this.#e.audit({message:"Event dispatched and awaiting feedback",scriptingEventId:t,...k})):(m.send({messageType:l.ObjectEvent,messageBody:O}),this.#e.audit({message:"Event dispatched",scriptingEventId:t,...k}))};return w?p(w):this.#s.forEach(p),await Promise.all(S).then(m=>(this.#e.audit({message:"Event feedback received",scriptingEventId:t}),Y(m))).catch(m=>{throw this.#e.error({message:"Error processing event",eventId:t,exception:m}),m}).finally(()=>{b&&this.#b(`ScriptingObject.Event.${g.id}.${i}`,{appId:this.hostId,appUrl:window.location.href})})};getGuests=()=>Array.from(this.#s.values());getScriptingObject=(e,t)=>this.#c.getObject(e,t?.guest);loadGuest=e=>{const{id:t,url:i,targetElement:s,title:o,searchParams:r={},onLoad:c,onError:a,options:d={}}=e;if(!t)throw new Error("id for guest application is required");this.#s.has(t)&&(this.#e.warn(`Guest with id '${t}' is already loaded. Unloading existing guest first.`),this.unloadGuest(t));const{openMode:u=f.Embed,popupWindowFeatures:j={}}=d,w=this.#z(i,r);let g=null;if(this.#u("SSF.Guest.Load",{appId:t,appUrl:w}),u===f.Popup)g=this.#x({guestId:t,url:w,title:o,searchParams:r,popupWindowFeatures:j,onLoad:c,onError:a});else if(u===f.Embed)g=this.#D({guestId:t,url:w,title:o,targetElement:s,searchParams:r,onLoad:c,onError:a,options:d});else throw new Error(`Invalid openMode: ${u}`);return this.#e.audit({message:"Guest loaded",...g.getInfo()}),g};loadGuests=e=>{const{id:t,url:i,targetElement:s,title:o,searchParamsList:r=[],options:c={}}=e;r.forEach((a,d)=>{this.loadGuest({id:`${t}-${d}`,url:i,title:o,targetElement:s,searchParams:a,options:c})},this)};removeAllScriptingObjects=e=>{this.#c.removeAllScriptingObjects(e)};removeScriptingObject=(e,t)=>{this.#c.removeScriptingObject(e,t)};setLogLevel=e=>{this.#e.setLogLevel(e),this.#s.forEach(this.#y),this.#e.debug("Dispatched config events to all guests")};unloadGuest=e=>{const t=this.#w(e);t&&(t.dispose(),this.#o.delete(t.window),this.#r.delete(t.url),this.#s.delete(t.id),this.#e.audit({message:"Guest is removed from host",...t.getInfo()}),this.#C())};onGuestClose=e=>{const{id:t,guestCloseCallback:i}=e,s=this.#l.get(t)||[];s.push(i),this.#l.set(t,s)}}return I})());
|
|
2
|
+
|
|
3
|
+
//# sourceMappingURL=emuiSsfHost.6b964dde53916a3845ae.js.map
|
|
Binary file
|
|
Binary file
|