@heliofi/checkout-react 4.0.2 → 4.0.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.
- package/README.md +1 -1
- package/dist/helio-checkout-react.es.d.ts +3 -3
- package/dist/helio-checkout-react.es.js +73 -39
- package/package.json +14 -14
package/README.md
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { BlockchainSymbol } from '@heliofi/common';
|
|
2
|
-
import { JSX as JSX_2 } from 'react/jsx-runtime';
|
|
3
2
|
|
|
4
3
|
mainButtonTitle?: string;
|
|
5
4
|
payButtonTitle?: string;
|
|
6
5
|
}
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
|
|
9
8
|
|
|
10
9
|
|
|
11
|
-
export declare const HelioCheckout: (props: HelioCheckoutReactProps) =>
|
|
10
|
+
export declare const HelioCheckout: (props: HelioCheckoutReactProps) => JSX.Element;
|
|
12
11
|
|
|
13
12
|
config: HelioEmbedConfig;
|
|
14
13
|
}
|
|
@@ -22,6 +21,7 @@ export declare const HelioCheckout: (props: HelioCheckoutReactProps) => JSX_2.El
|
|
|
22
21
|
primaryPaymentMethod?: PrimaryPaymentMethod;
|
|
23
22
|
theme?: HelioEmbedTheme;
|
|
24
23
|
stretchFullWidth?: boolean;
|
|
24
|
+
/** deprecated - paystream is no longer supported */
|
|
25
25
|
paymentType?: EmbedPaymentType;
|
|
26
26
|
platform?: WidgetPlatform;
|
|
27
27
|
display?: DisplayType;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { Component as
|
|
3
|
-
const
|
|
4
|
-
"Error loading
|
|
1
|
+
import { jsxs as b, jsx as c } from "react/jsx-runtime";
|
|
2
|
+
import { Component as g, useRef as O, useState as m, useEffect as v, useLayoutEffect as _ } from "react";
|
|
3
|
+
const S = ({ children: e }) => /* @__PURE__ */ b("div", { children: [
|
|
4
|
+
"Error loading MoonPay Commerce Checkout for React",
|
|
5
5
|
e ? `: ${e}` : ""
|
|
6
6
|
] });
|
|
7
|
-
class
|
|
7
|
+
class D extends g {
|
|
8
8
|
constructor(t) {
|
|
9
9
|
super(t), this.state = { hasError: !1 };
|
|
10
10
|
}
|
|
@@ -12,51 +12,85 @@ class L extends b {
|
|
|
12
12
|
return { hasError: !0 };
|
|
13
13
|
}
|
|
14
14
|
render() {
|
|
15
|
-
return this.state.hasError ? /* @__PURE__ */
|
|
15
|
+
return this.state.hasError ? /* @__PURE__ */ c(S, {}) : this.props.children;
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
return
|
|
24
|
-
|
|
18
|
+
process.env.VITE_EMBED_VERSION;
|
|
19
|
+
process.env.VITE_PROD_HOSTNAME;
|
|
20
|
+
process.env.VERCEL_ENV;
|
|
21
|
+
const F = (e, t) => {
|
|
22
|
+
const r = document.createElement("script");
|
|
23
|
+
return r.setAttribute("type", "module"), r.setAttribute("id", t), r.setAttribute("src", e), document.body.appendChild(r), r;
|
|
24
|
+
}, M = (e) => document.querySelector(
|
|
25
|
+
`script#${e}`
|
|
26
|
+
), R = (e, t) => t.embedScriptSource || e, L = ({
|
|
27
|
+
type: e,
|
|
28
|
+
config: t,
|
|
29
|
+
scriptIdentifier: r,
|
|
30
|
+
scriptSrc: u,
|
|
31
|
+
trigger: l
|
|
32
|
+
}) => {
|
|
33
|
+
const d = O(null), [p, y] = m(!1);
|
|
34
|
+
v(() => y(!0), []);
|
|
35
|
+
const [o, k] = m(), [w, a] = m(""), E = R(u, t);
|
|
36
|
+
return v(() => {
|
|
37
|
+
let i = !1;
|
|
25
38
|
if (o) return;
|
|
26
|
-
const
|
|
27
|
-
if (
|
|
28
|
-
|
|
29
|
-
if (!
|
|
30
|
-
|
|
31
|
-
"Unable to load
|
|
39
|
+
const s = () => {
|
|
40
|
+
if (i) return;
|
|
41
|
+
let n;
|
|
42
|
+
if (e === "paylink" ? n = window.helioCheckout : n = window.moonpayCommerceDeposit, !n) {
|
|
43
|
+
a(
|
|
44
|
+
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"
|
|
32
45
|
);
|
|
33
46
|
return;
|
|
34
47
|
}
|
|
35
|
-
|
|
36
|
-
},
|
|
37
|
-
const
|
|
38
|
-
return
|
|
39
|
-
|
|
48
|
+
k(() => n);
|
|
49
|
+
}, f = (n) => {
|
|
50
|
+
const C = () => a("Error loading script tag");
|
|
51
|
+
return n.addEventListener("load", s), n.addEventListener("error", C), () => {
|
|
52
|
+
i = !0, n.removeEventListener("load", s), n.removeEventListener("error", C);
|
|
40
53
|
};
|
|
41
|
-
}, h =
|
|
42
|
-
`script#${p}`
|
|
43
|
-
);
|
|
54
|
+
}, h = M(r);
|
|
44
55
|
if (h) {
|
|
45
|
-
window.helioCheckout
|
|
46
|
-
|
|
56
|
+
if (e === "paylink" && window.helioCheckout || e === "deposit" && window.moonpayCommerceDeposit) {
|
|
57
|
+
s();
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
return f(h);
|
|
47
61
|
}
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
62
|
+
const I = F(
|
|
63
|
+
E,
|
|
64
|
+
r
|
|
65
|
+
);
|
|
66
|
+
return f(I);
|
|
67
|
+
}, [o, E, u, r, e]), _(() => {
|
|
68
|
+
if (!(!o || !p)) {
|
|
69
|
+
if (!d.current) {
|
|
70
|
+
a(
|
|
71
|
+
e === "paylink" ? "Missing element to mount MoonPay Commerce Checkout" : "Missing element to mount Helio Deposit"
|
|
72
|
+
);
|
|
54
73
|
return;
|
|
55
74
|
}
|
|
56
|
-
|
|
75
|
+
if (!l)
|
|
76
|
+
if (e === "paylink") {
|
|
77
|
+
const i = t;
|
|
78
|
+
o(d.current, i);
|
|
79
|
+
} else {
|
|
80
|
+
const i = o, s = t;
|
|
81
|
+
i(d.current, s);
|
|
82
|
+
}
|
|
57
83
|
}
|
|
58
|
-
}, [o,
|
|
59
|
-
},
|
|
84
|
+
}, [o, p, t, e, l]), { divRef: d, initFn: o, error: w, type: e };
|
|
85
|
+
}, H = "https://embed.hel.io/assets/index-v1.js", T = "helio-checkout-react-v1", x = ({ config: e }) => {
|
|
86
|
+
const { divRef: t, initFn: r, error: u } = L({
|
|
87
|
+
type: "paylink",
|
|
88
|
+
config: e,
|
|
89
|
+
scriptIdentifier: T,
|
|
90
|
+
scriptSrc: H
|
|
91
|
+
});
|
|
92
|
+
return u ? /* @__PURE__ */ c(S, { children: u }) : r ? /* @__PURE__ */ c("div", { ref: t }) : null;
|
|
93
|
+
}, A = (e) => /* @__PURE__ */ c(D, { children: /* @__PURE__ */ c(x, { config: e.config }) }), P = (e) => /* @__PURE__ */ c(A, { config: e.config });
|
|
60
94
|
export {
|
|
61
|
-
|
|
95
|
+
P as HelioCheckout
|
|
62
96
|
};
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@heliofi/checkout-react",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "4.0.
|
|
4
|
+
"version": "4.0.4",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"dev": "vite",
|
|
8
|
-
"build": "vite build",
|
|
8
|
+
"build": "tsc && vite build",
|
|
9
9
|
"build:vercel": "tsc && vite build --config vite-vercel.config.ts",
|
|
10
10
|
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
|
11
11
|
"lint:strict": "yarn lint",
|
|
12
|
-
"lint:fix": "yarn lint --fix",
|
|
12
|
+
"lint:fix": "yarn lint --fix && yarn format",
|
|
13
13
|
"format": "prettier -w .",
|
|
14
14
|
"format:check": "prettier -c .",
|
|
15
15
|
"preview": "vite preview",
|
|
@@ -36,21 +36,21 @@
|
|
|
36
36
|
"react-dom": ">=18.2.0 <20"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@testing-library/dom": "
|
|
39
|
+
"@testing-library/dom": "9.3.3",
|
|
40
40
|
"@testing-library/jest-dom": "5.16.5",
|
|
41
|
-
"@testing-library/react": "
|
|
42
|
-
"@types/react": "
|
|
43
|
-
"@types/react-dom": "
|
|
44
|
-
"@typescript-eslint/eslint-plugin": "
|
|
45
|
-
"@typescript-eslint/parser": "
|
|
46
|
-
"@vitejs/plugin-react": "
|
|
41
|
+
"@testing-library/react": "14.0.0",
|
|
42
|
+
"@types/react": "18.2.0",
|
|
43
|
+
"@types/react-dom": "18.2.0",
|
|
44
|
+
"@typescript-eslint/eslint-plugin": "6.7.4",
|
|
45
|
+
"@typescript-eslint/parser": "6.7.4",
|
|
46
|
+
"@vitejs/plugin-react": "4.3.2",
|
|
47
47
|
"eslint": "8.45.0",
|
|
48
|
-
"eslint-plugin-react": "
|
|
49
|
-
"eslint-plugin-react-hooks": "
|
|
50
|
-
"jsdom": "
|
|
48
|
+
"eslint-plugin-react": "7.37.5",
|
|
49
|
+
"eslint-plugin-react-hooks": "4.6.0",
|
|
50
|
+
"jsdom": "23.0.1",
|
|
51
51
|
"typescript": "5.1.6",
|
|
52
52
|
"vite": "5.4.8",
|
|
53
|
-
"vite-plugin-dts": "
|
|
53
|
+
"vite-plugin-dts": "3.7.1",
|
|
54
54
|
"vitest": "3.2.4"
|
|
55
55
|
}
|
|
56
56
|
}
|