@zerohash-sdk/crypto-buy-react 1.17.0 → 1.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +36 -35
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsxs as W, jsx as
|
|
2
|
-
import
|
|
1
|
+
import { jsxs as W, jsx as _ } from "react/jsx-runtime";
|
|
2
|
+
import D, { useEffect as B, useState as z, useCallback as j, useRef as M } from "react";
|
|
3
3
|
const $ = {
|
|
4
4
|
dev: "https://grafana-faro-collector.dev.0hash.com/collect",
|
|
5
5
|
cert: "https://grafana-faro-collector.cert.zerohash.com/collect",
|
|
@@ -50,7 +50,7 @@ const $ = {
|
|
|
50
50
|
}, H = () => {
|
|
51
51
|
const e = new Uint8Array(8);
|
|
52
52
|
return globalThis.crypto.getRandomValues(e), Array.from(e, (t) => t.toString(16).padStart(2, "0")).join("");
|
|
53
|
-
},
|
|
53
|
+
}, G = (e, t) => {
|
|
54
54
|
const o = H(), r = globalThis.__ZH_WEB_SDK_VERSION__, a = {};
|
|
55
55
|
e.claims.participantCode && (a.participant_code = e.claims.participantCode), e.claims.platformName && (a.platform_name = e.claims.platformName), e.claims.platformCode && (a.platform_code = e.claims.platformCode), e.claims.region && (a.region = e.claims.region), r && (a.zh_web_sdk_version = r);
|
|
56
56
|
const i = {
|
|
@@ -76,10 +76,10 @@ const $ = {
|
|
|
76
76
|
]
|
|
77
77
|
};
|
|
78
78
|
return { sessionId: o, payload: i };
|
|
79
|
-
},
|
|
79
|
+
}, K = (e, t, o) => {
|
|
80
80
|
if (!e || typeof fetch > "u")
|
|
81
81
|
return;
|
|
82
|
-
const { sessionId: r, payload: a } =
|
|
82
|
+
const { sessionId: r, payload: a } = G(t, o);
|
|
83
83
|
try {
|
|
84
84
|
fetch(e, {
|
|
85
85
|
method: "POST",
|
|
@@ -97,14 +97,14 @@ const $ = {
|
|
|
97
97
|
const d = `${t}-script-${n}`;
|
|
98
98
|
if (customElements.get(t) || document.getElementById(d))
|
|
99
99
|
return x;
|
|
100
|
-
const S = P(s), v = e.report ?? ((p) =>
|
|
101
|
-
let f = !1,
|
|
100
|
+
const S = P(s), v = e.report ?? ((p) => K(c && J(c, n, s), p, r));
|
|
101
|
+
let f = !1, N = 0, C;
|
|
102
102
|
const R = () => {
|
|
103
103
|
C !== void 0 && clearTimeout(C);
|
|
104
104
|
}, k = (p, y, l) => {
|
|
105
105
|
if (f)
|
|
106
106
|
return;
|
|
107
|
-
const U = Math.round(performance.now() -
|
|
107
|
+
const U = Math.round(performance.now() - N), E = {
|
|
108
108
|
webComponentTag: t,
|
|
109
109
|
appName: o,
|
|
110
110
|
env: n,
|
|
@@ -114,23 +114,23 @@ const $ = {
|
|
|
114
114
|
elapsedMs: U,
|
|
115
115
|
claims: S
|
|
116
116
|
};
|
|
117
|
-
v(
|
|
117
|
+
v(E);
|
|
118
118
|
const O = l ? void 0 : L(i ?? {}, n, s);
|
|
119
119
|
if (O && O !== y) {
|
|
120
|
-
|
|
120
|
+
T(O, !0);
|
|
121
121
|
return;
|
|
122
122
|
}
|
|
123
|
-
f = !0, R(), document.getElementById(d)?.remove(), h?.(
|
|
124
|
-
},
|
|
125
|
-
R(),
|
|
123
|
+
f = !0, R(), document.getElementById(d)?.remove(), h?.(E);
|
|
124
|
+
}, T = (p, y) => {
|
|
125
|
+
R(), N = performance.now();
|
|
126
126
|
const l = document.createElement("script");
|
|
127
127
|
l.id = d, l.src = p, l.type = "module", l.async = !0, l.onload = () => {
|
|
128
128
|
setTimeout(() => {
|
|
129
129
|
f || (customElements.get(t) ? (f = !0, R(), g?.()) : k("not-defined", p, y));
|
|
130
130
|
}, 0);
|
|
131
131
|
}, l.onerror = () => k("network", p, y), C = setTimeout(() => k("timeout", p, y), m), document.getElementById(d)?.remove(), document.head.appendChild(l);
|
|
132
|
-
},
|
|
133
|
-
return
|
|
132
|
+
}, w = L(a, n, s);
|
|
133
|
+
return w ? (T(w, !1), () => {
|
|
134
134
|
f = !0, R();
|
|
135
135
|
}) : x;
|
|
136
136
|
}, u = {
|
|
@@ -140,10 +140,11 @@ const $ = {
|
|
|
140
140
|
prod: "https://sdk-cdn.zerohash.com",
|
|
141
141
|
"eu-cert": "https://sdk-cdn.cert.zerohash.eu",
|
|
142
142
|
"eu-prod": "https://sdk-cdn.zerohash.eu"
|
|
143
|
-
}, q = (e, t, o = {}) => {
|
|
143
|
+
}, q = "https://sdk-cdn.gating.0hash.com", Q = (e, t, o = {}) => {
|
|
144
144
|
const { eu: r = !1, legacyAliases: a = !1, local: i = u.local } = o, c = (s) => `${s}/${e}/${t}`, n = {
|
|
145
145
|
local: c(i),
|
|
146
146
|
dev: c(u.dev),
|
|
147
|
+
gating: c(q),
|
|
147
148
|
cert: c(u.cert),
|
|
148
149
|
prod: c(u.prod)
|
|
149
150
|
};
|
|
@@ -153,12 +154,12 @@ var F;
|
|
|
153
154
|
(function(e) {
|
|
154
155
|
e.NETWORK_ERROR = "network_error", e.AUTH_ERROR = "auth_error", e.NOT_FOUND_ERROR = "not_found_error", e.VALIDATION_ERROR = "validation_error", e.SERVER_ERROR = "server_error", e.CLIENT_ERROR = "client_error", e.UNKNOWN_ERROR = "unknown_error";
|
|
155
156
|
})(F || (F = {}));
|
|
156
|
-
const
|
|
157
|
+
const b = {
|
|
157
158
|
evergreen: "#00381D",
|
|
158
159
|
green: "#CCFFD0",
|
|
159
160
|
offBlack: "#1C1B1C",
|
|
160
161
|
grayLight: "#EBEBE9"
|
|
161
|
-
},
|
|
162
|
+
}, X = ({ onRetry: e }) => W("div", { role: "alert", style: {
|
|
162
163
|
display: "flex",
|
|
163
164
|
flexDirection: "column",
|
|
164
165
|
alignItems: "center",
|
|
@@ -168,31 +169,31 @@ const _ = {
|
|
|
168
169
|
padding: "32px 24px",
|
|
169
170
|
textAlign: "center",
|
|
170
171
|
fontFamily: "inherit",
|
|
171
|
-
color:
|
|
172
|
+
color: b.offBlack,
|
|
172
173
|
background: "#FFFFFF",
|
|
173
|
-
border: `1px solid ${
|
|
174
|
+
border: `1px solid ${b.grayLight}`,
|
|
174
175
|
borderRadius: "12px"
|
|
175
|
-
}, children: [
|
|
176
|
+
}, children: [_("svg", { width: "32", height: "32", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: _("path", { d: "M12 9v4m0 4h.01M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z", stroke: b.evergreen, strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }), _("p", { style: { margin: 0, fontSize: "16px", fontWeight: 600 }, children: "Something went wrong" }), _("p", { style: { margin: 0, fontSize: "14px", opacity: 0.75 }, children: "We couldn't load this content. Please check your internet connection and try again." }), _("button", { type: "button", onClick: e, style: {
|
|
176
177
|
marginTop: "8px",
|
|
177
178
|
padding: "8px 20px",
|
|
178
179
|
fontSize: "14px",
|
|
179
180
|
fontWeight: 600,
|
|
180
181
|
fontFamily: "inherit",
|
|
181
|
-
color:
|
|
182
|
-
background:
|
|
182
|
+
color: b.green,
|
|
183
|
+
background: b.evergreen,
|
|
183
184
|
border: "none",
|
|
184
185
|
borderRadius: "8px",
|
|
185
186
|
cursor: "pointer"
|
|
186
|
-
}, children: "Try again" })] }),
|
|
187
|
-
|
|
187
|
+
}, children: "Try again" })] }), Y = (e, t) => {
|
|
188
|
+
B(() => {
|
|
188
189
|
const o = e.current;
|
|
189
190
|
if (o)
|
|
190
191
|
for (const [r, a] of Object.entries(t))
|
|
191
192
|
a !== void 0 && (o[r] = a);
|
|
192
193
|
});
|
|
193
|
-
},
|
|
194
|
+
}, ee = (e) => {
|
|
194
195
|
const { webComponentTag: t, appName: o, appVersion: r, scriptUrls: a, fallbackScriptUrls: i, collectorUrls: c, env: n, jwt: s, timeoutMs: m } = e, [g, h] = z(!1), [d, S] = z(0);
|
|
195
|
-
|
|
196
|
+
B(() => (h(!1), Z({
|
|
196
197
|
webComponentTag: t,
|
|
197
198
|
appName: o ?? t,
|
|
198
199
|
appVersion: r,
|
|
@@ -215,9 +216,9 @@ const _ = {
|
|
|
215
216
|
m,
|
|
216
217
|
d
|
|
217
218
|
]);
|
|
218
|
-
const v =
|
|
219
|
+
const v = j(() => S((f) => f + 1), []);
|
|
219
220
|
return { loadFailed: g, retry: v };
|
|
220
|
-
},
|
|
221
|
+
}, te = Q("crypto-buy-web", "index.js"), A = "zerohash-crypto-buy", ne = ({
|
|
221
222
|
jwt: e,
|
|
222
223
|
env: t = "prod",
|
|
223
224
|
theme: o,
|
|
@@ -230,14 +231,14 @@ const _ = {
|
|
|
230
231
|
...m
|
|
231
232
|
}) => {
|
|
232
233
|
const g = M(null);
|
|
233
|
-
|
|
234
|
-
const { loadFailed: h, retry: d } =
|
|
235
|
-
webComponentTag:
|
|
236
|
-
scriptUrls:
|
|
234
|
+
Y(g, { theme: o, filters: r, onCompleted: a, onError: i, onClose: c, onLoaded: n, onEvent: s });
|
|
235
|
+
const { loadFailed: h, retry: d } = ee({
|
|
236
|
+
webComponentTag: A,
|
|
237
|
+
scriptUrls: te,
|
|
237
238
|
env: t,
|
|
238
239
|
jwt: e
|
|
239
240
|
});
|
|
240
|
-
return h ? /* @__PURE__ */
|
|
241
|
+
return h ? /* @__PURE__ */ _(X, { onRetry: d }) : D.createElement(A, {
|
|
241
242
|
ref: g,
|
|
242
243
|
jwt: e,
|
|
243
244
|
env: t,
|
|
@@ -247,5 +248,5 @@ const _ = {
|
|
|
247
248
|
});
|
|
248
249
|
};
|
|
249
250
|
export {
|
|
250
|
-
|
|
251
|
+
ne as CryptoBuy
|
|
251
252
|
};
|