@heliofi/deposit-react 0.4.1-alpha.1770389993 → 0.4.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.
|
@@ -54,9 +54,7 @@ export declare const MoonpayCommerceDeposit: (props: MoonpayCommerceDepositReact
|
|
|
54
54
|
export declare const MoonpayCommerceDepositProvider: (props: PropsWithChildren) => JSX.Element;
|
|
55
55
|
|
|
56
56
|
config: MoonpayCommerceDepositConfig;
|
|
57
|
-
trigger?:
|
|
58
|
-
onClick: () => void;
|
|
59
|
-
}>;
|
|
57
|
+
trigger?: HTMLElement;
|
|
60
58
|
}
|
|
61
59
|
|
|
62
60
|
|
|
@@ -1,116 +1,126 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useRef as
|
|
3
|
-
const
|
|
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 = () => {
|
|
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
|
+
}, A = T(), H = "deposit-embed-script", L = `https://${A}/assets/index-${P}.js`, N = ({ children: e }) => /* @__PURE__ */ y("div", { children: [
|
|
10
10
|
"Error loading Helio Deposit for React",
|
|
11
11
|
e ? `: ${e}` : ""
|
|
12
12
|
] });
|
|
13
13
|
process.env.VITE_EMBED_VERSION;
|
|
14
14
|
process.env.VITE_PROD_HOSTNAME;
|
|
15
15
|
process.env.VERCEL_ENV;
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
return
|
|
19
|
-
},
|
|
16
|
+
const I = (e, t) => {
|
|
17
|
+
const n = document.createElement("script");
|
|
18
|
+
return n.setAttribute("type", "module"), n.setAttribute("id", t), n.setAttribute("src", e), document.body.appendChild(n), n;
|
|
19
|
+
}, O = (e) => document.querySelector(
|
|
20
20
|
`script#${e}`
|
|
21
|
-
),
|
|
21
|
+
), V = ({
|
|
22
22
|
scriptIdentifier: e,
|
|
23
|
-
scriptSrc:
|
|
23
|
+
scriptSrc: t
|
|
24
24
|
}) => {
|
|
25
|
-
const
|
|
25
|
+
const n = R(t, {
|
|
26
26
|
embedScriptSource: void 0
|
|
27
|
-
}),
|
|
27
|
+
}), r = h(!1);
|
|
28
28
|
a(() => {
|
|
29
|
-
|
|
30
|
-
}, [
|
|
31
|
-
},
|
|
29
|
+
r.current || (r.current = !0, !O(e) && I(n, e));
|
|
30
|
+
}, [n, e]);
|
|
31
|
+
}, R = (e, t) => t.embedScriptSource || e, j = ({
|
|
32
32
|
type: e,
|
|
33
|
-
config:
|
|
34
|
-
scriptIdentifier:
|
|
35
|
-
scriptSrc:
|
|
36
|
-
trigger:
|
|
33
|
+
config: t,
|
|
34
|
+
scriptIdentifier: n,
|
|
35
|
+
scriptSrc: r,
|
|
36
|
+
trigger: l
|
|
37
37
|
}) => {
|
|
38
|
-
const
|
|
39
|
-
a(() =>
|
|
40
|
-
const [
|
|
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
41
|
return a(() => {
|
|
42
|
-
let
|
|
43
|
-
if (
|
|
44
|
-
const
|
|
45
|
-
if (
|
|
46
|
-
let
|
|
47
|
-
if (e === "paylink" ?
|
|
48
|
-
|
|
42
|
+
let u = !1;
|
|
43
|
+
if (s) return;
|
|
44
|
+
const p = () => {
|
|
45
|
+
if (u) return;
|
|
46
|
+
let o;
|
|
47
|
+
if (e === "paylink" ? o = window.helioCheckout : o = window.moonpayCommerceDeposit, !o) {
|
|
48
|
+
E(
|
|
49
49
|
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
50
|
);
|
|
51
51
|
return;
|
|
52
52
|
}
|
|
53
|
-
M(() =>
|
|
54
|
-
},
|
|
55
|
-
const
|
|
56
|
-
return
|
|
57
|
-
|
|
53
|
+
M(() => o);
|
|
54
|
+
}, 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);
|
|
58
58
|
};
|
|
59
|
-
},
|
|
60
|
-
if (
|
|
59
|
+
}, C = O(n);
|
|
60
|
+
if (C) {
|
|
61
61
|
if (e === "paylink" && window.helioCheckout || e === "deposit" && window.moonpayCommerceDeposit) {
|
|
62
|
-
|
|
62
|
+
p();
|
|
63
63
|
return;
|
|
64
64
|
}
|
|
65
|
-
return
|
|
65
|
+
return v(C);
|
|
66
66
|
}
|
|
67
|
-
const
|
|
67
|
+
const F = I(
|
|
68
68
|
S,
|
|
69
|
-
|
|
69
|
+
n
|
|
70
70
|
);
|
|
71
|
-
return
|
|
72
|
-
}, [
|
|
73
|
-
if (!(!
|
|
74
|
-
if (!
|
|
75
|
-
|
|
71
|
+
return v(F);
|
|
72
|
+
}, [s, S, r, n, e]), k(() => {
|
|
73
|
+
if (!(!s || !m)) {
|
|
74
|
+
if (!i.current) {
|
|
75
|
+
E(
|
|
76
76
|
e === "paylink" ? "Missing element to mount MoonPay Commerce Checkout" : "Missing element to mount Helio Deposit"
|
|
77
77
|
);
|
|
78
78
|
return;
|
|
79
79
|
}
|
|
80
|
-
if (!
|
|
80
|
+
if (!l)
|
|
81
81
|
if (e === "paylink") {
|
|
82
|
-
const
|
|
83
|
-
i
|
|
82
|
+
const u = t;
|
|
83
|
+
s(i.current, u);
|
|
84
84
|
} else {
|
|
85
|
-
const
|
|
86
|
-
|
|
85
|
+
const u = s, p = t;
|
|
86
|
+
u(i.current, p);
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
|
-
}, [
|
|
90
|
-
},
|
|
91
|
-
scriptIdentifier:
|
|
92
|
-
scriptSrc:
|
|
93
|
-
},
|
|
89
|
+
}, [s, m, t, e, l]), { divRef: i, initFn: s, error: _, type: e };
|
|
90
|
+
}, w = {
|
|
91
|
+
scriptIdentifier: H,
|
|
92
|
+
scriptSrc: L
|
|
93
|
+
}, x = ({
|
|
94
94
|
config: e,
|
|
95
|
-
trigger:
|
|
95
|
+
trigger: t
|
|
96
96
|
}) => {
|
|
97
|
-
const { divRef:
|
|
97
|
+
const { divRef: n, initFn: r, error: l } = j({
|
|
98
98
|
type: "deposit",
|
|
99
|
-
trigger:
|
|
99
|
+
trigger: t,
|
|
100
100
|
config: e,
|
|
101
|
-
...
|
|
102
|
-
});
|
|
103
|
-
return
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
101
|
+
...w
|
|
102
|
+
}), i = h(null);
|
|
103
|
+
return a(() => {
|
|
104
|
+
const d = i.current;
|
|
105
|
+
if (!(!d || !t))
|
|
106
|
+
return d.appendChild(t), () => {
|
|
107
|
+
d.contains(t) && d.removeChild(t);
|
|
108
|
+
};
|
|
109
|
+
}, [t, !!r]), l ? /* @__PURE__ */ c(N, { children: l }) : r ? t ? /* @__PURE__ */ y(b, { children: [
|
|
110
|
+
/* @__PURE__ */ c("div", { ref: n }),
|
|
111
|
+
/* @__PURE__ */ c(
|
|
112
|
+
"button",
|
|
107
113
|
{
|
|
108
|
-
onClick: () =>
|
|
114
|
+
onClick: () => r(n.current, { ...e, display: "modal" }),
|
|
115
|
+
className: "hel-bg-transparent hel-border-none hel-outline-none hel-p-0 hel-m-0",
|
|
116
|
+
id: "moonpay-commerce-deposit-trigger",
|
|
117
|
+
type: "button",
|
|
118
|
+
children: /* @__PURE__ */ c("span", { ref: i })
|
|
109
119
|
}
|
|
110
120
|
)
|
|
111
|
-
] }) : /* @__PURE__ */
|
|
112
|
-
},
|
|
121
|
+
] }) : /* @__PURE__ */ c("div", { ref: n }) : null;
|
|
122
|
+
}, U = (e) => /* @__PURE__ */ c(x, { ...e }), $ = (e) => (V(w), /* @__PURE__ */ c(b, { children: e.children }));
|
|
113
123
|
export {
|
|
114
|
-
|
|
115
|
-
|
|
124
|
+
U as MoonpayCommerceDeposit,
|
|
125
|
+
$ as MoonpayCommerceDepositProvider
|
|
116
126
|
};
|