@zerohash-sdk/fund-react 1.10.2 → 1.11.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.
Files changed (2) hide show
  1. package/dist/index.js +31 -30
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { jsxs as W, jsx as _ } from "react/jsx-runtime";
2
- import j, { useEffect as B, useState as z, useCallback as D, useRef as M } from "react";
2
+ import D, { useEffect as I, 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",
@@ -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, J = (e) => {
26
+ }, B = (e, t) => V(t) !== "eu" ? e : e === "cert" ? "eu-cert" : e === "prod" ? "eu-prod" : e, J = (e) => {
27
27
  if (!e || typeof e != "string")
28
28
  return {};
29
29
  const t = e.split(".");
@@ -41,16 +41,16 @@ const $ = {
41
41
  return {};
42
42
  }
43
43
  }, F = (e, t, o) => {
44
- const r = I(t, o);
44
+ const r = B(t, o);
45
45
  return e[r] ?? e[t] ?? e.prod;
46
46
  }, P = (e, t, o) => {
47
- const r = I(t, o);
47
+ const r = B(t, o);
48
48
  return e[r] ?? e[t];
49
49
  }, x = () => {
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
- }, K = (e, t) => {
53
+ }, G = (e, t) => {
54
54
  const o = H(), r = globalThis.__ZH_WEB_SDK_VERSION__, n = {};
55
55
  e.claims.participantCode && (n.participant_code = e.claims.participantCode), e.claims.platformName && (n.platform_name = e.claims.platformName), e.claims.platformCode && (n.platform_code = e.claims.platformCode), e.claims.region && (n.region = e.claims.region), r && (n.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
- }, G = (e, t, o) => {
79
+ }, K = (e, t, o) => {
80
80
  if (!e || typeof fetch > "u")
81
81
  return;
82
- const { sessionId: r, payload: n } = K(t, o);
82
+ const { sessionId: r, payload: n } = G(t, o);
83
83
  try {
84
84
  fetch(e, {
85
85
  method: "POST",
@@ -97,14 +97,14 @@ const $ = {
97
97
  const p = `${t}-script-${a}`;
98
98
  if (customElements.get(t) || document.getElementById(p))
99
99
  return x;
100
- const h = J(s), R = e.report ?? ((u) => G(c && P(c, a, s), u, r));
101
- let d = !1, w = 0, C;
100
+ const h = J(s), R = e.report ?? ((u) => K(c && P(c, a, s), u, r));
101
+ let d = !1, N = 0, C;
102
102
  const v = () => {
103
103
  C !== void 0 && clearTimeout(C);
104
104
  }, k = (u, y, l) => {
105
105
  if (d)
106
106
  return;
107
- const U = Math.round(performance.now() - w), T = {
107
+ const U = Math.round(performance.now() - N), E = {
108
108
  webComponentTag: t,
109
109
  appName: o,
110
110
  env: a,
@@ -114,23 +114,23 @@ const $ = {
114
114
  elapsedMs: U,
115
115
  claims: h
116
116
  };
117
- R(T);
117
+ R(E);
118
118
  const O = l ? void 0 : F(i ?? {}, a, s);
119
119
  if (O && O !== y) {
120
- E(O, !0);
120
+ T(O, !0);
121
121
  return;
122
122
  }
123
- d = !0, v(), document.getElementById(p)?.remove(), g?.(T);
124
- }, E = (u, y) => {
125
- v(), w = performance.now();
123
+ d = !0, v(), document.getElementById(p)?.remove(), g?.(E);
124
+ }, T = (u, y) => {
125
+ v(), N = performance.now();
126
126
  const l = document.createElement("script");
127
127
  l.id = p, l.src = u, l.type = "module", l.async = !0, l.onload = () => {
128
128
  setTimeout(() => {
129
129
  d || (customElements.get(t) ? (d = !0, v(), b?.()) : k("not-defined", u, y));
130
130
  }, 0);
131
131
  }, l.onerror = () => k("network", u, y), C = setTimeout(() => k("timeout", u, y), m), document.getElementById(p)?.remove(), document.head.appendChild(l);
132
- }, N = F(n, a, s);
133
- return N ? (E(N, !1), () => {
132
+ }, w = F(n, a, s);
133
+ return w ? (T(w, !1), () => {
134
134
  d = !0, v();
135
135
  }) : x;
136
136
  }, f = {
@@ -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: n = !1, local: i = f.local } = o, c = (s) => `${s}/${e}/${t}`, a = {
145
145
  local: c(i),
146
146
  dev: c(f.dev),
147
+ gating: c(q),
147
148
  cert: c(f.cert),
148
149
  prod: c(f.prod)
149
150
  };
@@ -158,7 +159,7 @@ const S = {
158
159
  green: "#CCFFD0",
159
160
  offBlack: "#1C1B1C",
160
161
  grayLight: "#EBEBE9"
161
- }, Q = ({ onRetry: e }) => W("div", { role: "alert", style: {
162
+ }, X = ({ onRetry: e }) => W("div", { role: "alert", style: {
162
163
  display: "flex",
163
164
  flexDirection: "column",
164
165
  alignItems: "center",
@@ -183,16 +184,16 @@ const S = {
183
184
  border: "none",
184
185
  borderRadius: "8px",
185
186
  cursor: "pointer"
186
- }, children: "Try again" })] }), X = (e, t) => {
187
- B(() => {
187
+ }, children: "Try again" })] }), Y = (e, t) => {
188
+ I(() => {
188
189
  const o = e.current;
189
190
  if (o)
190
191
  for (const [r, n] of Object.entries(t))
191
192
  n !== void 0 && (o[r] = n);
192
193
  });
193
- }, Y = (e) => {
194
+ }, ee = (e) => {
194
195
  const { webComponentTag: t, appName: o, appVersion: r, scriptUrls: n, fallbackScriptUrls: i, collectorUrls: c, env: a, jwt: s, timeoutMs: m } = e, [b, g] = z(!1), [p, h] = z(0);
195
- B(() => (g(!1), Z({
196
+ I(() => (g(!1), Z({
196
197
  webComponentTag: t,
197
198
  appName: o ?? t,
198
199
  appVersion: r,
@@ -215,9 +216,9 @@ const S = {
215
216
  m,
216
217
  p
217
218
  ]);
218
- const R = D(() => h((d) => d + 1), []);
219
+ const R = j(() => h((d) => d + 1), []);
219
220
  return { loadFailed: b, retry: R };
220
- }, ee = q("fund-web", "index.js", { eu: !0 }), A = "zerohash-fund", re = ({
221
+ }, te = Q("fund-web", "index.js", { eu: !0 }), A = "zerohash-fund", ne = ({
221
222
  jwt: e,
222
223
  env: t = "prod",
223
224
  theme: o,
@@ -233,7 +234,7 @@ const S = {
233
234
  ...p
234
235
  }) => {
235
236
  const h = M(null);
236
- X(h, {
237
+ Y(h, {
237
238
  isPay: n,
238
239
  theme: o,
239
240
  branding: r,
@@ -245,14 +246,14 @@ const S = {
245
246
  onLoaded: b,
246
247
  onEvent: g
247
248
  });
248
- const { loadFailed: R, retry: d } = Y({
249
+ const { loadFailed: R, retry: d } = ee({
249
250
  webComponentTag: A,
250
- scriptUrls: ee,
251
+ scriptUrls: te,
251
252
  // fallbackScriptUrls: FALLBACK_SCRIPT_URLS, // enable once the host is confirmed (AUTH-3095)
252
253
  env: t,
253
254
  jwt: e
254
255
  });
255
- return R ? /* @__PURE__ */ _(Q, { onRetry: d }) : j.createElement(A, {
256
+ return R ? /* @__PURE__ */ _(X, { onRetry: d }) : D.createElement(A, {
256
257
  ref: h,
257
258
  jwt: e,
258
259
  env: t,
@@ -262,5 +263,5 @@ const S = {
262
263
  });
263
264
  };
264
265
  export {
265
- re as Fund
266
+ ne as Fund
266
267
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zerohash-sdk/fund-react",
3
- "version": "1.10.2",
3
+ "version": "1.11.1",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",