@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
|
|
2
|
-
import { useRef as
|
|
3
|
-
|
|
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
|
|
6
|
+
return P.VITE_PROD_HOSTNAME || "embed.deposits.hel.io";
|
|
6
7
|
} catch {
|
|
7
8
|
return "embed.deposits.hel.io";
|
|
8
9
|
}
|
|
9
|
-
},
|
|
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
|
-
},
|
|
16
|
+
}, w = (e) => document.querySelector(
|
|
20
17
|
`script#${e}`
|
|
21
|
-
),
|
|
18
|
+
), N = ({
|
|
22
19
|
scriptIdentifier: e,
|
|
23
20
|
scriptSrc: t
|
|
24
21
|
}) => {
|
|
25
|
-
const n =
|
|
22
|
+
const n = O(t, {
|
|
26
23
|
embedScriptSource: void 0
|
|
27
|
-
}), r =
|
|
28
|
-
|
|
29
|
-
r.current || (r.current = !0, !
|
|
24
|
+
}), r = S(!1);
|
|
25
|
+
p(() => {
|
|
26
|
+
r.current || (r.current = !0, !w(e) && I(n, e));
|
|
30
27
|
}, [n, e]);
|
|
31
|
-
},
|
|
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:
|
|
33
|
+
trigger: a
|
|
37
34
|
}) => {
|
|
38
|
-
const i =
|
|
39
|
-
|
|
40
|
-
const [s,
|
|
41
|
-
return
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
50
|
+
F(() => o);
|
|
54
51
|
}, v = (o) => {
|
|
55
|
-
const
|
|
56
|
-
return o.addEventListener("load",
|
|
57
|
-
u = !0, o.removeEventListener("load",
|
|
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 =
|
|
56
|
+
}, C = w(n);
|
|
60
57
|
if (C) {
|
|
61
58
|
if (e === "paylink" && window.helioCheckout || e === "deposit" && window.moonpayCommerceDeposit) {
|
|
62
|
-
|
|
59
|
+
l();
|
|
63
60
|
return;
|
|
64
61
|
}
|
|
65
62
|
return v(C);
|
|
66
63
|
}
|
|
67
|
-
const
|
|
68
|
-
|
|
64
|
+
const _ = I(
|
|
65
|
+
E,
|
|
69
66
|
n
|
|
70
67
|
);
|
|
71
|
-
return v(
|
|
72
|
-
}, [s,
|
|
68
|
+
return v(_);
|
|
69
|
+
}, [s, E, r, n, e]), k(() => {
|
|
73
70
|
if (!(!s || !m)) {
|
|
74
71
|
if (!i.current) {
|
|
75
|
-
|
|
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 (!
|
|
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,
|
|
86
|
-
u(i.current,
|
|
82
|
+
const u = s, l = t;
|
|
83
|
+
u(i.current, l);
|
|
87
84
|
}
|
|
88
85
|
}
|
|
89
|
-
}, [s, m, t, e,
|
|
90
|
-
},
|
|
91
|
-
scriptIdentifier:
|
|
92
|
-
scriptSrc:
|
|
93
|
-
},
|
|
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:
|
|
94
|
+
const { divRef: n, initFn: r, error: a } = g({
|
|
98
95
|
type: "deposit",
|
|
99
96
|
trigger: t,
|
|
100
97
|
config: e,
|
|
101
|
-
...
|
|
102
|
-
}), i =
|
|
103
|
-
return
|
|
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]),
|
|
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
|
-
},
|
|
119
|
+
}, W = (e) => /* @__PURE__ */ c(U, { ...e }), z = (e) => (N(R), /* @__PURE__ */ c(b, { children: e.children }));
|
|
123
120
|
export {
|
|
124
|
-
|
|
125
|
-
|
|
121
|
+
W as MoonpayCommerceDeposit,
|
|
122
|
+
z as MoonpayCommerceDepositProvider
|
|
126
123
|
};
|