@zerohash-sdk/crypto-buy-react 1.7.0 → 1.9.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/index.d.ts +18 -0
- package/dist/index.js +42 -40
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CryptoBuyFilters } from '@zerohash-sdk/crypto-buy';
|
|
1
2
|
import { default as default_2 } from 'react';
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -111,6 +112,23 @@ declare interface CryptoBuyProps {
|
|
|
111
112
|
* ```
|
|
112
113
|
*/
|
|
113
114
|
theme?: Theme;
|
|
115
|
+
/**
|
|
116
|
+
* Optional filters that narrow the list of assets shown in the widget.
|
|
117
|
+
*
|
|
118
|
+
* - `getAssets.stablecoin`: pass `false` to hide stablecoins, `true` to show
|
|
119
|
+
* only stablecoins, or omit to include both.
|
|
120
|
+
* - `getAssets.deposit_address_creation`: restrict assets by their deposit
|
|
121
|
+
* address creation policy.
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* ```tsx
|
|
125
|
+
* <CryptoBuy
|
|
126
|
+
* jwt={token}
|
|
127
|
+
* filters={{ getAssets: { stablecoin: false } }}
|
|
128
|
+
* />
|
|
129
|
+
* ```
|
|
130
|
+
*/
|
|
131
|
+
filters?: CryptoBuyFilters;
|
|
114
132
|
/**
|
|
115
133
|
* Callback invoked when the crypto sell flow is successfully completed.
|
|
116
134
|
*
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsxs as W, jsx as
|
|
1
|
+
import { jsxs as W, jsx as b } from "react/jsx-runtime";
|
|
2
2
|
import j, { useEffect as A, useState as z, useCallback as D, useRef as M } from "react";
|
|
3
3
|
const $ = {
|
|
4
4
|
dev: "https://grafana-faro-collector.dev.0hash.com/collect",
|
|
@@ -91,49 +91,49 @@ const $ = {
|
|
|
91
91
|
} catch {
|
|
92
92
|
}
|
|
93
93
|
}, Z = (e) => {
|
|
94
|
-
const { webComponentTag: t, appName: o, appVersion: r, scriptUrls: a, fallbackScriptUrls: i, collectorUrls: c, env: n, jwt: s, timeoutMs:
|
|
94
|
+
const { webComponentTag: t, appName: o, appVersion: r, scriptUrls: a, fallbackScriptUrls: i, collectorUrls: c, env: n, jwt: s, timeoutMs: m = 15e3, onLoad: g, onError: h } = e;
|
|
95
95
|
if (typeof document > "u")
|
|
96
96
|
return x;
|
|
97
|
-
const
|
|
98
|
-
if (customElements.get(t) || document.getElementById(
|
|
97
|
+
const d = `${t}-script-${n}`;
|
|
98
|
+
if (customElements.get(t) || document.getElementById(d))
|
|
99
99
|
return x;
|
|
100
|
-
const S = P(s), v = e.report ?? ((
|
|
100
|
+
const S = P(s), v = e.report ?? ((p) => G(c && J(c, n, s), p, r));
|
|
101
101
|
let f = !1, w = 0, C;
|
|
102
102
|
const R = () => {
|
|
103
103
|
C !== void 0 && clearTimeout(C);
|
|
104
|
-
}, k = (
|
|
104
|
+
}, k = (p, y, l) => {
|
|
105
105
|
if (f)
|
|
106
106
|
return;
|
|
107
107
|
const U = Math.round(performance.now() - w), T = {
|
|
108
108
|
webComponentTag: t,
|
|
109
109
|
appName: o,
|
|
110
110
|
env: n,
|
|
111
|
-
scriptUrl:
|
|
112
|
-
reason:
|
|
111
|
+
scriptUrl: y,
|
|
112
|
+
reason: p,
|
|
113
113
|
triedFallback: l,
|
|
114
114
|
elapsedMs: U,
|
|
115
115
|
claims: S
|
|
116
116
|
};
|
|
117
117
|
v(T);
|
|
118
118
|
const O = l ? void 0 : L(i ?? {}, n, s);
|
|
119
|
-
if (O && O !==
|
|
119
|
+
if (O && O !== y) {
|
|
120
120
|
E(O, !0);
|
|
121
121
|
return;
|
|
122
122
|
}
|
|
123
|
-
f = !0, R(), document.getElementById(
|
|
124
|
-
}, E = (
|
|
123
|
+
f = !0, R(), document.getElementById(d)?.remove(), h?.(T);
|
|
124
|
+
}, E = (p, y) => {
|
|
125
125
|
R(), w = performance.now();
|
|
126
126
|
const l = document.createElement("script");
|
|
127
|
-
l.id =
|
|
127
|
+
l.id = d, l.src = p, l.type = "module", l.async = !0, l.onload = () => {
|
|
128
128
|
setTimeout(() => {
|
|
129
|
-
f || (customElements.get(t) ? (f = !0, R(),
|
|
129
|
+
f || (customElements.get(t) ? (f = !0, R(), g?.()) : k("not-defined", p, y));
|
|
130
130
|
}, 0);
|
|
131
|
-
}, l.onerror = () => k("network",
|
|
131
|
+
}, l.onerror = () => k("network", p, y), C = setTimeout(() => k("timeout", p, y), m), document.getElementById(d)?.remove(), document.head.appendChild(l);
|
|
132
132
|
}, N = L(a, n, s);
|
|
133
133
|
return N ? (E(N, !1), () => {
|
|
134
134
|
f = !0, R();
|
|
135
135
|
}) : x;
|
|
136
|
-
},
|
|
136
|
+
}, u = {
|
|
137
137
|
local: "http://localhost:5173",
|
|
138
138
|
dev: "https://sdk-cdn.dev.0hash.com",
|
|
139
139
|
cert: "https://sdk-cdn.cert.zerohash.com",
|
|
@@ -141,13 +141,13 @@ const $ = {
|
|
|
141
141
|
"eu-cert": "https://sdk-cdn.cert.zerohash.eu",
|
|
142
142
|
"eu-prod": "https://sdk-cdn.zerohash.eu"
|
|
143
143
|
}, q = (e, t, o = {}) => {
|
|
144
|
-
const { eu: r = !1, legacyAliases: a = !1, local: i =
|
|
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
|
-
dev: c(
|
|
147
|
-
cert: c(
|
|
148
|
-
prod: c(
|
|
146
|
+
dev: c(u.dev),
|
|
147
|
+
cert: c(u.cert),
|
|
148
|
+
prod: c(u.prod)
|
|
149
149
|
};
|
|
150
|
-
return a && (n.sandbox = c(
|
|
150
|
+
return a && (n.sandbox = c(u.cert), n.production = c(u.prod)), r && (n["eu-cert"] = c(u["eu-cert"]), n["eu-prod"] = c(u["eu-prod"])), n;
|
|
151
151
|
};
|
|
152
152
|
var F;
|
|
153
153
|
(function(e) {
|
|
@@ -172,7 +172,7 @@ const _ = {
|
|
|
172
172
|
background: "#FFFFFF",
|
|
173
173
|
border: `1px solid ${_.grayLight}`,
|
|
174
174
|
borderRadius: "12px"
|
|
175
|
-
}, children: [
|
|
175
|
+
}, children: [b("svg", { width: "32", height: "32", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: b("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: _.evergreen, strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }), b("p", { style: { margin: 0, fontSize: "16px", fontWeight: 600 }, children: "Something went wrong" }), b("p", { style: { margin: 0, fontSize: "14px", opacity: 0.75 }, children: "We couldn't load this content. Please check your internet connection and try again." }), b("button", { type: "button", onClick: e, style: {
|
|
176
176
|
marginTop: "8px",
|
|
177
177
|
padding: "8px 20px",
|
|
178
178
|
fontSize: "14px",
|
|
@@ -191,8 +191,8 @@ const _ = {
|
|
|
191
191
|
a !== void 0 && (o[r] = a);
|
|
192
192
|
});
|
|
193
193
|
}, Y = (e) => {
|
|
194
|
-
const { webComponentTag: t, appName: o, appVersion: r, scriptUrls: a, fallbackScriptUrls: i, collectorUrls: c, env: n, jwt: s, timeoutMs:
|
|
195
|
-
A(() => (
|
|
194
|
+
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
|
+
A(() => (h(!1), Z({
|
|
196
196
|
webComponentTag: t,
|
|
197
197
|
appName: o ?? t,
|
|
198
198
|
appVersion: r,
|
|
@@ -201,8 +201,8 @@ const _ = {
|
|
|
201
201
|
collectorUrls: c ?? $,
|
|
202
202
|
env: n,
|
|
203
203
|
jwt: s,
|
|
204
|
-
timeoutMs:
|
|
205
|
-
onError: () =>
|
|
204
|
+
timeoutMs: m,
|
|
205
|
+
onError: () => h(!0)
|
|
206
206
|
})), [
|
|
207
207
|
t,
|
|
208
208
|
o,
|
|
@@ -212,36 +212,38 @@ const _ = {
|
|
|
212
212
|
c,
|
|
213
213
|
n,
|
|
214
214
|
s,
|
|
215
|
-
|
|
216
|
-
|
|
215
|
+
m,
|
|
216
|
+
d
|
|
217
217
|
]);
|
|
218
218
|
const v = D(() => S((f) => f + 1), []);
|
|
219
|
-
return { loadFailed:
|
|
219
|
+
return { loadFailed: g, retry: v };
|
|
220
220
|
}, ee = q("crypto-buy-web", "index.js"), B = "zerohash-crypto-buy", re = ({
|
|
221
221
|
jwt: e,
|
|
222
222
|
env: t = "prod",
|
|
223
223
|
theme: o,
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
224
|
+
filters: r,
|
|
225
|
+
onCompleted: a,
|
|
226
|
+
onError: i,
|
|
227
|
+
onClose: c,
|
|
228
|
+
onLoaded: n,
|
|
229
|
+
onEvent: s,
|
|
230
|
+
...m
|
|
230
231
|
}) => {
|
|
231
|
-
const
|
|
232
|
-
X(
|
|
233
|
-
const { loadFailed:
|
|
232
|
+
const g = M(null);
|
|
233
|
+
X(g, { theme: o, filters: r, onCompleted: a, onError: i, onClose: c, onLoaded: n, onEvent: s });
|
|
234
|
+
const { loadFailed: h, retry: d } = Y({
|
|
234
235
|
webComponentTag: B,
|
|
235
236
|
scriptUrls: ee,
|
|
236
237
|
env: t,
|
|
237
238
|
jwt: e
|
|
238
239
|
});
|
|
239
|
-
return
|
|
240
|
-
ref:
|
|
240
|
+
return h ? /* @__PURE__ */ b(Q, { onRetry: d }) : j.createElement(B, {
|
|
241
|
+
ref: g,
|
|
241
242
|
jwt: e,
|
|
242
243
|
env: t,
|
|
243
244
|
theme: o,
|
|
244
|
-
|
|
245
|
+
filters: r,
|
|
246
|
+
...m
|
|
245
247
|
});
|
|
246
248
|
};
|
|
247
249
|
export {
|