@deflectbot/deflect-sdk 1.1.4 → 1.1.5
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/index.js +8 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -34,10 +34,16 @@ class Deflect {
|
|
|
34
34
|
if (sessionId) {
|
|
35
35
|
window.Deflect.sessionId = sessionId;
|
|
36
36
|
}
|
|
37
|
-
const scriptText = yield response.text();
|
|
38
37
|
const scriptEl = document.createElement("script");
|
|
39
|
-
scriptEl.
|
|
38
|
+
scriptEl.type = "module";
|
|
39
|
+
const blob = new Blob([yield response.text()], { type: "text/javascript" });
|
|
40
|
+
const blobUrl = URL.createObjectURL(blob);
|
|
41
|
+
scriptEl.src = blobUrl;
|
|
40
42
|
document.head.appendChild(scriptEl);
|
|
43
|
+
yield new Promise((resolve, reject) => {
|
|
44
|
+
scriptEl.onload = () => resolve();
|
|
45
|
+
scriptEl.onerror = () => reject("Failed to load the Deflect script");
|
|
46
|
+
});
|
|
41
47
|
if (typeof window.Deflect === "undefined" ||
|
|
42
48
|
typeof window.Deflect.getToken !== "function") {
|
|
43
49
|
throw new Error("Deflect script did not load properly");
|