@zerohash-sdk/fund-react 1.15.3 → 1.15.4

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.
Files changed (2) hide show
  1. package/dist/index.js +50 -50
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { jsxs as W, jsx as p } from "react/jsx-runtime";
2
- import M, { useEffect as A, useState as L, useCallback as j, useRef as D } from "react";
3
- const $ = {
2
+ import D, { useEffect as B, useState as L, useCallback as M, useRef as j } from "react";
3
+ const V = {
4
4
  dev: "https://grafana-faro-collector.dev.0hash.com/collect",
5
5
  cert: "https://grafana-faro-collector.cert.zerohash.com/collect",
6
6
  prod: "https://grafana-faro-collector.zerohash.com/collect",
@@ -8,7 +8,7 @@ const $ = {
8
8
  "eu-prod": "https://grafana-faro-collector.zerohash.eu/collect",
9
9
  sandbox: "https://grafana-faro-collector.cert.zerohash.com/collect",
10
10
  production: "https://grafana-faro-collector.zerohash.com/collect"
11
- }, V = (e) => {
11
+ }, $ = (e) => {
12
12
  if (!e || typeof e != "string")
13
13
  return null;
14
14
  const t = e.split(".");
@@ -23,7 +23,7 @@ const $ = {
23
23
  } catch {
24
24
  return null;
25
25
  }
26
- }, I = (e, t) => V(t) !== "eu" ? e : e === "cert" ? "eu-cert" : e === "prod" ? "eu-prod" : e, H = (e) => {
26
+ }, I = (e, t) => $(t) !== "eu" ? e : e === "cert" ? "eu-cert" : e === "prod" ? "eu-prod" : e, H = (e) => {
27
27
  if (!e || typeof e != "string")
28
28
  return {};
29
29
  const t = e.split(".");
@@ -46,7 +46,7 @@ const $ = {
46
46
  }, J = (e, t, o) => {
47
47
  const r = I(t, o);
48
48
  return e[r] ?? e[t];
49
- }, w = () => {
49
+ }, T = () => {
50
50
  }, P = () => {
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("");
@@ -93,58 +93,58 @@ const $ = {
93
93
  }, Z = (e) => {
94
94
  const { webComponentTag: t, appName: o, appVersion: r, scriptUrls: n, fallbackScriptUrls: i, collectorUrls: c, env: a, jwt: s, timeoutMs: g = 15e3, onLoad: h, onError: y } = e;
95
95
  if (typeof document > "u")
96
- return w;
96
+ return T;
97
97
  const u = `${t}-script-${a}`;
98
98
  if (customElements.get(t) || document.getElementById(u))
99
- return w;
100
- const S = H(s), b = e.report ?? ((f) => K(c && J(c, a, s), f, r));
101
- let d = !1, k = 0, x;
102
- const v = () => {
103
- x !== void 0 && clearTimeout(x);
104
- }, C = (f, _, l) => {
99
+ return T;
100
+ const S = H(s), _ = e.report ?? ((f) => K(c && J(c, a, s), f, r));
101
+ let d = !1, v = 0, C;
102
+ const k = () => {
103
+ C !== void 0 && clearTimeout(C);
104
+ }, O = (f, b, l) => {
105
105
  if (d)
106
106
  return;
107
- const U = Math.round(performance.now() - k), E = {
107
+ const U = Math.round(performance.now() - v), E = {
108
108
  webComponentTag: t,
109
109
  appName: o,
110
110
  env: a,
111
- scriptUrl: _,
111
+ scriptUrl: b,
112
112
  reason: f,
113
113
  triedFallback: l,
114
114
  elapsedMs: U,
115
115
  claims: S
116
116
  };
117
- b(E);
118
- const O = l ? void 0 : z(i ?? {}, a, s);
119
- if (O && O !== _) {
120
- N(O, !0);
117
+ _(E);
118
+ const x = l ? void 0 : z(i ?? {}, a, s);
119
+ if (x && x !== b) {
120
+ N(x, !0);
121
121
  return;
122
122
  }
123
- d = !0, v(), document.getElementById(u)?.remove(), y?.(E);
124
- }, N = (f, _) => {
125
- v(), k = performance.now();
123
+ d = !0, k(), document.getElementById(u)?.remove(), y?.(E);
124
+ }, N = (f, b) => {
125
+ k(), v = performance.now();
126
126
  const l = document.createElement("script");
127
127
  l.id = u, l.src = f, l.type = "module", l.async = !0, l.onload = () => {
128
128
  setTimeout(() => {
129
- d || (customElements.get(t) ? (d = !0, v(), h?.()) : C("not-defined", f, _));
129
+ d || (customElements.get(t) ? (d = !0, k(), h?.()) : O("not-defined", f, b));
130
130
  }, 0);
131
- }, l.onerror = () => C("network", f, _), x = setTimeout(() => C("timeout", f, _), g), document.getElementById(u)?.remove(), document.head.appendChild(l);
132
- }, T = z(n, a, s);
133
- return T ? (N(T, !1), () => {
134
- d = !0, v();
135
- }) : w;
136
- }, m = {
137
- local: "http://localhost:5173",
131
+ }, l.onerror = () => O("network", f, b), C = setTimeout(() => O("timeout", f, b), g), document.getElementById(u)?.remove(), document.head.appendChild(l);
132
+ }, w = z(n, a, s);
133
+ return w ? (N(w, !1), () => {
134
+ d = !0, k();
135
+ }) : T;
136
+ }, q = {}, Q = typeof import.meta < "u" && q?.VITE_LOCAL_CDN_HOST || "http://localhost:5173", m = {
137
+ local: Q,
138
138
  dev: "https://sdk-cdn.dev.0hash.com",
139
139
  cert: "https://sdk-cdn.cert.zerohash.com",
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 = "https://sdk-cdn.gating.0hash.com", Q = (e, t, o = {}) => {
143
+ }, X = "https://sdk-cdn.gating.0hash.com", Y = (e, t, o = {}) => {
144
144
  const { eu: r = !1, legacyAliases: n = !1, local: i = m.local } = o, c = (s) => `${s}/${e}/${t}`, a = {
145
145
  local: c(i),
146
146
  dev: c(m.dev),
147
- gating: c(q),
147
+ gating: c(X),
148
148
  cert: c(m.cert),
149
149
  prod: c(m.prod)
150
150
  };
@@ -159,7 +159,7 @@ const R = {
159
159
  green: "#CCFFD0",
160
160
  offBlack: "#1C1B1C",
161
161
  grayLight: "#EBEBE9"
162
- }, X = ({ onRetry: e, onClose: t }) => W("div", { role: "alert", style: {
162
+ }, ee = ({ onRetry: e, onClose: t }) => W("div", { role: "alert", style: {
163
163
  position: "relative",
164
164
  display: "flex",
165
165
  flexDirection: "column",
@@ -196,22 +196,22 @@ const R = {
196
196
  border: "none",
197
197
  borderRadius: "8px",
198
198
  cursor: "pointer"
199
- }, children: "Try again" })] }), Y = (e, t) => {
200
- A(() => {
199
+ }, children: "Try again" })] }), te = (e, t) => {
200
+ B(() => {
201
201
  const o = e.current;
202
202
  if (o)
203
203
  for (const [r, n] of Object.entries(t))
204
204
  n !== void 0 && (o[r] = n);
205
205
  });
206
- }, ee = (e) => {
206
+ }, oe = (e) => {
207
207
  const { webComponentTag: t, appName: o, appVersion: r, scriptUrls: n, fallbackScriptUrls: i, collectorUrls: c, env: a, jwt: s, timeoutMs: g } = e, [h, y] = L(!1), [u, S] = L(0);
208
- A(() => (y(!1), Z({
208
+ B(() => (y(!1), Z({
209
209
  webComponentTag: t,
210
210
  appName: o ?? t,
211
211
  appVersion: r,
212
212
  scriptUrls: n,
213
213
  fallbackScriptUrls: i,
214
- collectorUrls: c ?? $,
214
+ collectorUrls: c ?? V,
215
215
  env: a,
216
216
  jwt: s,
217
217
  timeoutMs: g,
@@ -228,9 +228,9 @@ const R = {
228
228
  g,
229
229
  u
230
230
  ]);
231
- const b = j(() => S((d) => d + 1), []);
232
- return { loadFailed: h, retry: b };
233
- }, te = Q("fund-web", "index.js", { eu: !0 }), B = "zerohash-fund", ne = ({
231
+ const _ = M(() => S((d) => d + 1), []);
232
+ return { loadFailed: h, retry: _ };
233
+ }, re = Y("fund-web", "index.js", { eu: !0 }), A = "zerohash-fund", ce = ({
234
234
  jwt: e,
235
235
  env: t = "prod",
236
236
  theme: o,
@@ -246,8 +246,8 @@ const R = {
246
246
  onEvent: u,
247
247
  ...S
248
248
  }) => {
249
- const b = D(null);
250
- Y(b, {
249
+ const _ = j(null);
250
+ te(_, {
251
251
  isPay: n,
252
252
  theme: o,
253
253
  branding: r,
@@ -260,21 +260,21 @@ const R = {
260
260
  onLoaded: y,
261
261
  onEvent: u
262
262
  });
263
- const { loadFailed: d, retry: k } = ee({
264
- webComponentTag: B,
265
- scriptUrls: te,
263
+ const { loadFailed: d, retry: v } = oe({
264
+ webComponentTag: A,
265
+ scriptUrls: re,
266
266
  // fallbackScriptUrls: FALLBACK_SCRIPT_URLS, // enable once the host is confirmed (AUTH-3095)
267
267
  env: t,
268
268
  jwt: e
269
269
  });
270
270
  return d ? /* @__PURE__ */ p(
271
- X,
271
+ ee,
272
272
  {
273
- onRetry: k,
273
+ onRetry: v,
274
274
  onClose: h
275
275
  }
276
- ) : M.createElement(B, {
277
- ref: b,
276
+ ) : D.createElement(A, {
277
+ ref: _,
278
278
  jwt: e,
279
279
  env: t,
280
280
  theme: o,
@@ -283,5 +283,5 @@ const R = {
283
283
  });
284
284
  };
285
285
  export {
286
- ne as Fund
286
+ ce as Fund
287
287
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zerohash-sdk/fund-react",
3
- "version": "1.15.3",
3
+ "version": "1.15.4",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",