@heliofi/deposit-react 0.4.4 → 0.4.6

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.
@@ -35,16 +35,19 @@ import { PropsWithChildren } from 'react';
35
35
 
36
36
  export declare const MoonpayCommerceDeposit: (props: MoonpayCommerceDepositReactProps) => JSX.Element;
37
37
 
38
+ buttonText?: string;
38
39
  currentlyConnectedWallet?: ConnectWalletSelection;
39
40
  debug?: boolean;
40
41
  depositCustomerToken: string;
41
42
  display?: DepositDisplay;
42
43
  forcedStep?: DepositForcedStep;
44
+ isLoading?: boolean;
43
45
  loadingText?: React.ReactNode;
44
46
  network?: DepositNetwork;
45
47
  onError?: (error: {
46
48
  message: string;
47
49
  }) => void;
50
+ onReady?: () => void;
48
51
  onSuccess?: () => void;
49
52
  openWalletConnectInNewTab?: boolean;
50
53
  themeMode?: DepositThemeMode;
@@ -1,112 +1,109 @@
1
- import { jsxs as y, jsx as c, Fragment as b } from "react/jsx-runtime";
2
- import { useRef as h, useEffect as a, useState as f, useLayoutEffect as k } from "react";
3
- const P = "v1", T = () => {
1
+ import { jsxs as D, jsx as c, Fragment as b } from "react/jsx-runtime";
2
+ import { useRef as S, useEffect as p, useState as h, useLayoutEffect as k } from "react";
3
+ var P = {};
4
+ const A = "v1", T = () => {
4
5
  try {
5
- return process.env.VITE_PROD_HOSTNAME || "embed.deposits.hel.io";
6
+ return P.VITE_PROD_HOSTNAME || "embed.deposits.hel.io";
6
7
  } catch {
7
8
  return "embed.deposits.hel.io";
8
9
  }
9
- }, A = T(), H = "deposit-embed-script", L = `https://${A}/assets/index-${P}.js`, N = ({ children: e }) => /* @__PURE__ */ y("div", { children: [
10
+ }, H = T(), L = "deposit-embed-script", j = `https://${H}/assets/index-${A}.js`, x = ({ children: e }) => /* @__PURE__ */ D("div", { children: [
10
11
  "Error loading Helio Deposit for React",
11
12
  e ? `: ${e}` : ""
12
- ] });
13
- process.env.VITE_EMBED_VERSION;
14
- process.env.VITE_PROD_HOSTNAME;
15
- process.env.VERCEL_ENV;
16
- const I = (e, t) => {
13
+ ] }), I = (e, t) => {
17
14
  const n = document.createElement("script");
18
15
  return n.setAttribute("type", "module"), n.setAttribute("id", t), n.setAttribute("src", e), document.body.appendChild(n), n;
19
- }, O = (e) => document.querySelector(
16
+ }, w = (e) => document.querySelector(
20
17
  `script#${e}`
21
- ), V = ({
18
+ ), N = ({
22
19
  scriptIdentifier: e,
23
20
  scriptSrc: t
24
21
  }) => {
25
- const n = R(t, {
22
+ const n = O(t, {
26
23
  embedScriptSource: void 0
27
- }), r = h(!1);
28
- a(() => {
29
- r.current || (r.current = !0, !O(e) && I(n, e));
24
+ }), r = S(!1);
25
+ p(() => {
26
+ r.current || (r.current = !0, !w(e) && I(n, e));
30
27
  }, [n, e]);
31
- }, R = (e, t) => t.embedScriptSource || e, j = ({
28
+ }, O = (e, t) => t.embedScriptSource || e, g = ({
32
29
  type: e,
33
30
  config: t,
34
31
  scriptIdentifier: n,
35
32
  scriptSrc: r,
36
- trigger: l
33
+ trigger: a
37
34
  }) => {
38
- const i = h(null), [m, d] = f(!1);
39
- a(() => d(!0), []);
40
- const [s, M] = f(), [_, E] = f(""), S = R(r, t);
41
- return a(() => {
35
+ const i = S(null), [m, d] = h(!1);
36
+ p(() => d(!0), []);
37
+ const [s, F] = h(), [M, f] = h(""), E = O(r, t);
38
+ return p(() => {
42
39
  let u = !1;
43
40
  if (s) return;
44
- const p = () => {
41
+ const l = () => {
45
42
  if (u) return;
46
43
  let o;
47
44
  if (e === "paylink" ? o = window.helioCheckout : o = window.moonpayCommerceDeposit, !o) {
48
- E(
45
+ f(
49
46
  e === "paylink" ? "Unable to load MoonPay Commerce Checkout - missing init function on window.helioCheckout" : "Unable to load Helio Deposit - missing init function on window.moonpayCommerceDeposit"
50
47
  );
51
48
  return;
52
49
  }
53
- M(() => o);
50
+ F(() => o);
54
51
  }, v = (o) => {
55
- const D = () => E("Error loading script tag");
56
- return o.addEventListener("load", p), o.addEventListener("error", D), () => {
57
- u = !0, o.removeEventListener("load", p), o.removeEventListener("error", D);
52
+ const y = () => f("Error loading script tag");
53
+ return o.addEventListener("load", l), o.addEventListener("error", y), () => {
54
+ u = !0, o.removeEventListener("load", l), o.removeEventListener("error", y);
58
55
  };
59
- }, C = O(n);
56
+ }, C = w(n);
60
57
  if (C) {
61
58
  if (e === "paylink" && window.helioCheckout || e === "deposit" && window.moonpayCommerceDeposit) {
62
- p();
59
+ l();
63
60
  return;
64
61
  }
65
62
  return v(C);
66
63
  }
67
- const F = I(
68
- S,
64
+ const _ = I(
65
+ E,
69
66
  n
70
67
  );
71
- return v(F);
72
- }, [s, S, r, n, e]), k(() => {
68
+ return v(_);
69
+ }, [s, E, r, n, e]), k(() => {
73
70
  if (!(!s || !m)) {
74
71
  if (!i.current) {
75
- E(
72
+ f(
76
73
  e === "paylink" ? "Missing element to mount MoonPay Commerce Checkout" : "Missing element to mount Helio Deposit"
77
74
  );
78
75
  return;
79
76
  }
80
- if (!l)
77
+ if (!a)
81
78
  if (e === "paylink") {
82
79
  const u = t;
83
80
  s(i.current, u);
84
81
  } else {
85
- const u = s, p = t;
86
- u(i.current, p);
82
+ const u = s, l = t;
83
+ u(i.current, l);
87
84
  }
88
85
  }
89
- }, [s, m, t, e, l]), { divRef: i, initFn: s, error: _, type: e };
90
- }, w = {
91
- scriptIdentifier: H,
92
- scriptSrc: L
93
- }, x = ({
86
+ }, [s, m, t, e, a]), { divRef: i, initFn: s, error: M, type: e };
87
+ }, R = {
88
+ scriptIdentifier: L,
89
+ scriptSrc: j
90
+ }, U = ({
94
91
  config: e,
95
92
  trigger: t
96
93
  }) => {
97
- const { divRef: n, initFn: r, error: l } = j({
94
+ const { divRef: n, initFn: r, error: a } = g({
98
95
  type: "deposit",
99
96
  trigger: t,
100
97
  config: e,
101
- ...w
102
- }), i = h(null);
103
- return a(() => {
98
+ ...R
99
+ }), i = S(null);
100
+ return p(() => {
104
101
  const d = i.current;
105
102
  if (!(!d || !t))
106
103
  return d.appendChild(t), () => {
107
104
  d.contains(t) && d.removeChild(t);
108
105
  };
109
- }, [t, !!r]), l ? /* @__PURE__ */ c(N, { children: l }) : r ? t ? /* @__PURE__ */ y(b, { children: [
106
+ }, [t, !!r]), a ? /* @__PURE__ */ c(x, { children: a }) : r ? t ? /* @__PURE__ */ D(b, { children: [
110
107
  /* @__PURE__ */ c("div", { ref: n }),
111
108
  /* @__PURE__ */ c(
112
109
  "button",
@@ -119,8 +116,8 @@ const I = (e, t) => {
119
116
  }
120
117
  )
121
118
  ] }) : /* @__PURE__ */ c("div", { ref: n }) : null;
122
- }, U = (e) => /* @__PURE__ */ c(x, { ...e }), $ = (e) => (V(w), /* @__PURE__ */ c(b, { children: e.children }));
119
+ }, W = (e) => /* @__PURE__ */ c(U, { ...e }), z = (e) => (N(R), /* @__PURE__ */ c(b, { children: e.children }));
123
120
  export {
124
- U as MoonpayCommerceDeposit,
125
- $ as MoonpayCommerceDepositProvider
121
+ W as MoonpayCommerceDeposit,
122
+ z as MoonpayCommerceDepositProvider
126
123
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@heliofi/deposit-react",
3
3
  "private": false,
4
- "version": "0.4.4",
4
+ "version": "0.4.6",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "dev": "vite",