@odus/checkout 1.17.0-beta.0 → 1.17.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/loader.es.js +87 -0
- package/dist/shared.js +1 -1
- package/package.json +6 -1
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
//#region libs/checkout/src/loader/loadOdus.ts
|
|
2
|
+
var e = "https://js.odus.com", t = "1.17.0", n = {
|
|
3
|
+
test: "https://sandbox-analytics.odus.com/collect",
|
|
4
|
+
live: "https://analytics.odus.com/collect"
|
|
5
|
+
}, r = {
|
|
6
|
+
checkout: "OdusCheckout",
|
|
7
|
+
elements: "OdusElements"
|
|
8
|
+
}, i = class extends Error {
|
|
9
|
+
code;
|
|
10
|
+
constructor(e, t) {
|
|
11
|
+
super(t), this.name = "OdusLoadError", this.code = e;
|
|
12
|
+
}
|
|
13
|
+
}, a = /* @__PURE__ */ new Map(), o = !1;
|
|
14
|
+
function s() {
|
|
15
|
+
if (o || typeof document > "u") return;
|
|
16
|
+
o = !0;
|
|
17
|
+
let t = document.createElement("link");
|
|
18
|
+
t.rel = "preconnect", t.href = e, t.crossOrigin = "anonymous", document.head.append(t);
|
|
19
|
+
}
|
|
20
|
+
s();
|
|
21
|
+
function c(e, r, i, a) {
|
|
22
|
+
try {
|
|
23
|
+
if (/^(localhost|127\.0\.0\.1|0\.0\.0\.0|\[::1\])$|\.localhost$/.test(window.location.hostname)) return;
|
|
24
|
+
window.navigator.sendBeacon(n[e], JSON.stringify({
|
|
25
|
+
meta: {
|
|
26
|
+
app: {
|
|
27
|
+
name: "odus-checkout",
|
|
28
|
+
version: t,
|
|
29
|
+
environment: e === "test" ? "sandbox" : "production"
|
|
30
|
+
},
|
|
31
|
+
page: { url: window.location.origin }
|
|
32
|
+
},
|
|
33
|
+
events: [{
|
|
34
|
+
name: "checkout.runtime.load_failed",
|
|
35
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
36
|
+
attributes: {
|
|
37
|
+
code: i,
|
|
38
|
+
integration: r === "checkout" ? "dropin" : "elements",
|
|
39
|
+
delivery: "cdn",
|
|
40
|
+
loader_version: t,
|
|
41
|
+
runtime: a
|
|
42
|
+
}
|
|
43
|
+
}]
|
|
44
|
+
}));
|
|
45
|
+
} catch {}
|
|
46
|
+
}
|
|
47
|
+
function l(e, n, a) {
|
|
48
|
+
let { environment: o = "live", timeout: s = 15e3, integrity: l } = a, u = performance.now();
|
|
49
|
+
return new Promise((d, f) => {
|
|
50
|
+
let p = !1, m = !1, h = (e) => {
|
|
51
|
+
e.disposition !== "report" && `${e.blockedURI}/`.startsWith("https://js.odus.com/") && (p = !0);
|
|
52
|
+
}, g = () => !m && (m = !0, clearTimeout(y), document.removeEventListener("securitypolicyviolation", h), !0), _ = (t, n) => {
|
|
53
|
+
g() && (c(o, e, t, a.version ?? "channel"), f(new i(t, n)));
|
|
54
|
+
}, v = (e) => _(p ? "blocked_by_csp" : "network", `${e} ${p ? "was blocked by the page CSP" : "could not load"}: ${n}`);
|
|
55
|
+
document.addEventListener("securitypolicyviolation", h);
|
|
56
|
+
let y = setTimeout(() => _("timeout", `No runtime within ${s} ms: ${n}`), s), b = globalThis.__ODUS_RUNTIME__ ??= {};
|
|
57
|
+
delete b[1];
|
|
58
|
+
let x = document.createElement("script");
|
|
59
|
+
x.src = n, x.crossOrigin = "anonymous", l && (x.integrity = l), x.addEventListener("error", () => setTimeout(() => v("The Odus runtime"))), x.addEventListener("load", () => {
|
|
60
|
+
let i = b[1];
|
|
61
|
+
if (delete b[1], m) return;
|
|
62
|
+
let a;
|
|
63
|
+
try {
|
|
64
|
+
a = i?.boot?.({
|
|
65
|
+
contract: 1,
|
|
66
|
+
loader: t,
|
|
67
|
+
started: u
|
|
68
|
+
});
|
|
69
|
+
} catch {}
|
|
70
|
+
if (typeof a?.[r[e]] != "function" || typeof a.version != "string") {
|
|
71
|
+
_("incompatible_runtime", `${n} did not register a contract 1 runtime`);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
let o = a;
|
|
75
|
+
Promise.resolve(o.styles).then(() => {
|
|
76
|
+
g() && d(o);
|
|
77
|
+
}, () => setTimeout(() => v("The Odus runtime stylesheet")));
|
|
78
|
+
}), document.head.append(x);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
function u(n, r = {}) {
|
|
82
|
+
s();
|
|
83
|
+
let i = r.version ? `${e}/r/${r.version}/${n}.js` : `${e}/v1/${n}.js?min=${t}`, o = `${i} ${r.integrity ?? ""}`, c = a.get(o);
|
|
84
|
+
return c || (c = l(n, i, r), a.set(o, c), c.catch(() => a.delete(o))), c;
|
|
85
|
+
}
|
|
86
|
+
//#endregion
|
|
87
|
+
export { i as OdusLoadError, e as RUNTIME_ORIGIN, u as loadOdus };
|
package/dist/shared.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@odus/checkout",
|
|
3
|
-
"version": "1.17.0
|
|
3
|
+
"version": "1.17.0",
|
|
4
4
|
"displayName": "ODUS Checkout SDK",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"odus",
|
|
@@ -26,6 +26,11 @@
|
|
|
26
26
|
"types": "./dist/elements.d.ts",
|
|
27
27
|
"import": "./dist/elements.es.js",
|
|
28
28
|
"default": "./dist/elements.es.js"
|
|
29
|
+
},
|
|
30
|
+
"./loader": {
|
|
31
|
+
"types": "./dist/loader.d.ts",
|
|
32
|
+
"import": "./dist/loader.es.js",
|
|
33
|
+
"default": "./dist/loader.es.js"
|
|
29
34
|
}
|
|
30
35
|
},
|
|
31
36
|
"files": [
|