@heliofi/deposit-react 0.3.0 → 0.4.0-alpha.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.
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
|
|
3
|
+
import { PropsWithChildren } from 'react';
|
|
2
4
|
|
|
3
5
|
readonly SOL: true;
|
|
4
6
|
readonly ETH: true;
|
|
@@ -18,6 +20,7 @@
|
|
|
18
20
|
|
|
19
21
|
METAMASK = "METAMASK",
|
|
20
22
|
PHANTOM = "PHANTOM",
|
|
23
|
+
RABBY = "RABBY",
|
|
21
24
|
TRUST_WALLET = "TRUST_WALLET",
|
|
22
25
|
WALLET_CONNECT = "WALLET_CONNECT"
|
|
23
26
|
}
|
|
@@ -27,7 +30,7 @@
|
|
|
27
30
|
|
|
28
31
|
|
|
29
32
|
|
|
30
|
-
export declare const MoonpayCommerceDeposit: (props: MoonpayCommerceDepositReactProps) => JSX.Element
|
|
33
|
+
export declare const MoonpayCommerceDeposit: (props: MoonpayCommerceDepositReactProps) => JSX.Element;
|
|
31
34
|
|
|
32
35
|
currentlyConnectedWallet?: ConnectWalletSelection;
|
|
33
36
|
debug?: boolean;
|
|
@@ -44,6 +47,8 @@ export declare const MoonpayCommerceDeposit: (props: MoonpayCommerceDepositReact
|
|
|
44
47
|
themeMode?: DepositThemeMode;
|
|
45
48
|
variant?: DepositVariant;
|
|
46
49
|
}
|
|
50
|
+
|
|
51
|
+
export declare const MoonpayCommerceDepositProvider: (props: PropsWithChildren) => JSX.Element;
|
|
47
52
|
|
|
48
53
|
config: MoonpayCommerceDepositConfig;
|
|
49
54
|
trigger?: React.ComponentType<{
|
|
@@ -1,70 +1,115 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useRef as
|
|
3
|
-
const
|
|
1
|
+
import { jsxs as h, jsx as d, Fragment as D } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as y, useEffect as l, useState as a, useLayoutEffect as g } from "react";
|
|
3
|
+
const F = "v1", k = () => {
|
|
4
4
|
try {
|
|
5
5
|
return process.env.VITE_PROD_HOSTNAME || "embed.deposits.hel.io";
|
|
6
6
|
} catch {
|
|
7
7
|
return "embed.deposits.hel.io";
|
|
8
8
|
}
|
|
9
|
-
},
|
|
9
|
+
}, P = k(), A = "deposit-embed-script", H = `https://${P}/assets/index-${F}.js`, L = ({ children: e }) => /* @__PURE__ */ h("div", { children: [
|
|
10
10
|
"Error loading Helio Deposit for React",
|
|
11
11
|
e ? `: ${e}` : ""
|
|
12
|
-
] })
|
|
12
|
+
] });
|
|
13
|
+
process.env.VITE_EMBED_VERSION;
|
|
14
|
+
process.env.VITE_PROD_HOSTNAME;
|
|
15
|
+
process.env.VERCEL_ENV;
|
|
16
|
+
const I = (e, n) => {
|
|
13
17
|
const t = document.createElement("script");
|
|
14
|
-
return t.setAttribute("type", "module"), t.setAttribute("id",
|
|
15
|
-
},
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
18
|
+
return t.setAttribute("type", "module"), t.setAttribute("id", n), t.setAttribute("src", e), document.body.appendChild(t), t;
|
|
19
|
+
}, w = (e) => document.querySelector(
|
|
20
|
+
`script#${e}`
|
|
21
|
+
), N = ({
|
|
22
|
+
scriptIdentifier: e,
|
|
23
|
+
scriptSrc: n,
|
|
24
|
+
config: t
|
|
25
|
+
}) => {
|
|
26
|
+
const o = R(n, t), i = y(!1);
|
|
27
|
+
l(() => {
|
|
28
|
+
i.current || (i.current = !0, !w(e) && I(o, e));
|
|
29
|
+
}, [o, e]);
|
|
30
|
+
}, R = (e, n) => n.embedScriptSource || e, V = ({
|
|
31
|
+
type: e,
|
|
32
|
+
config: n,
|
|
33
|
+
scriptIdentifier: t,
|
|
34
|
+
scriptSrc: o,
|
|
35
|
+
trigger: i
|
|
36
|
+
}) => {
|
|
37
|
+
const p = y(null), [E, O] = a(!1);
|
|
38
|
+
l(() => O(!0), []);
|
|
39
|
+
const [s, _] = a(), [b, m] = a(""), S = R(o, n);
|
|
40
|
+
return l(() => {
|
|
41
|
+
let c = !1;
|
|
42
|
+
if (s) return;
|
|
43
|
+
const u = () => {
|
|
44
|
+
if (c) return;
|
|
45
|
+
let r;
|
|
46
|
+
if (e === "paylink" ? r = window.helioCheckout : r = window.moonpayCommerceDeposit, !r) {
|
|
47
|
+
m(
|
|
48
|
+
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"
|
|
26
49
|
);
|
|
27
50
|
return;
|
|
28
51
|
}
|
|
29
|
-
|
|
30
|
-
},
|
|
31
|
-
const
|
|
32
|
-
return
|
|
33
|
-
|
|
52
|
+
_(() => r);
|
|
53
|
+
}, f = (r) => {
|
|
54
|
+
const C = () => m("Error loading script tag");
|
|
55
|
+
return r.addEventListener("load", u), r.addEventListener("error", C), () => {
|
|
56
|
+
c = !0, r.removeEventListener("load", u), r.removeEventListener("error", C);
|
|
34
57
|
};
|
|
35
|
-
},
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
window.moonpayCommerceDeposit ? c() : a(f);
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
const S = h();
|
|
43
|
-
return a(S);
|
|
44
|
-
}, [r]), I(() => {
|
|
45
|
-
if (!(!r || !d)) {
|
|
46
|
-
if (!t.current) {
|
|
47
|
-
s("Missing element to mount Helio Deposit");
|
|
58
|
+
}, v = w(t);
|
|
59
|
+
if (v) {
|
|
60
|
+
if (e === "paylink" && window.helioCheckout || e === "deposit" && window.moonpayCommerceDeposit) {
|
|
61
|
+
u();
|
|
48
62
|
return;
|
|
49
63
|
}
|
|
50
|
-
|
|
64
|
+
return f(v);
|
|
51
65
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
66
|
+
const T = I(S, t);
|
|
67
|
+
return f(T);
|
|
68
|
+
}, [s, S, o, t, e]), g(() => {
|
|
69
|
+
if (!(!s || !E)) {
|
|
70
|
+
if (!p.current) {
|
|
71
|
+
m(
|
|
72
|
+
e === "paylink" ? "Missing element to mount MoonPay Commerce Checkout" : "Missing element to mount Helio Deposit"
|
|
73
|
+
);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (!i)
|
|
77
|
+
if (e === "paylink") {
|
|
78
|
+
const c = n;
|
|
79
|
+
s(p.current, c);
|
|
80
|
+
} else {
|
|
81
|
+
const c = s, u = n;
|
|
82
|
+
c(p.current, u);
|
|
62
83
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
84
|
+
}
|
|
85
|
+
}, [s, E, n, e, i]), { divRef: p, initFn: s, error: b, type: e };
|
|
86
|
+
}, M = {
|
|
87
|
+
scriptIdentifier: A,
|
|
88
|
+
scriptSrc: H
|
|
89
|
+
}, j = ({
|
|
90
|
+
config: e,
|
|
91
|
+
trigger: n
|
|
92
|
+
}) => {
|
|
93
|
+
const { divRef: t, initFn: o, error: i } = V({
|
|
94
|
+
type: "deposit",
|
|
95
|
+
trigger: n,
|
|
96
|
+
config: e,
|
|
97
|
+
...M
|
|
98
|
+
});
|
|
99
|
+
return i ? /* @__PURE__ */ d(L, { children: i }) : o ? n ? /* @__PURE__ */ h(D, { children: [
|
|
100
|
+
/* @__PURE__ */ d("div", { ref: t }),
|
|
101
|
+
/* @__PURE__ */ d(
|
|
102
|
+
n,
|
|
103
|
+
{
|
|
104
|
+
onClick: () => o(t.current, { ...e, display: "modal" })
|
|
105
|
+
}
|
|
106
|
+
)
|
|
107
|
+
] }) : /* @__PURE__ */ d("div", { ref: t }) : null;
|
|
108
|
+
}, $ = (e) => /* @__PURE__ */ d(j, { ...e }), B = (e) => (N({
|
|
109
|
+
...M,
|
|
110
|
+
config: {}
|
|
111
|
+
}), /* @__PURE__ */ d(D, { children: e.children }));
|
|
68
112
|
export {
|
|
69
|
-
|
|
113
|
+
$ as MoonpayCommerceDeposit,
|
|
114
|
+
B as MoonpayCommerceDepositProvider
|
|
70
115
|
};
|