@heliofi/deposit-react 0.0.1-beta.1

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 ADDED
@@ -0,0 +1,9 @@
1
+ # @heliofi/deposit-react
2
+
3
+ React component for Helio crypto deposits.
4
+
5
+ ## Documentation
6
+
7
+ For installation, usage, and examples, visit the official Helio documentation:
8
+
9
+ **[docs.hel.io](https://docs.hel.io)**
@@ -0,0 +1,29 @@
1
+ export declare const MoonpayCommerceDeposit: (props: MoonpayCommerceDepositReactProps) => JSX.Element | null;
2
+
3
+ /**
4
+ * Configuration for MoonPay Commerce Deposit
5
+ * Note: This type is duplicated from deposit-embed to maintain package independence.
6
+ * The deposit-embed package is a private build artifact (embed script), not a library.
7
+ */
8
+ /** Required: Deposit customer token */
9
+ depositCustomerToken: string;
10
+ /** Optional: Success callback */
11
+ onSuccess?: (data: {
12
+ transaction?: string;
13
+ depositCustomer?: unknown;
14
+ }) => void;
15
+ /** Optional: Error callback */
16
+ onError?: (error: {
17
+ errorMessage?: string;
18
+ transaction?: string;
19
+ }) => void;
20
+ /** Optional: Network - test or main */
21
+ network?: 'test' | 'main';
22
+ /** Optional: Debug mode */
23
+ debug?: boolean;
24
+ }
25
+
26
+ config: MoonpayCommerceDepositConfig;
27
+ }
28
+
29
+ export { }
@@ -0,0 +1,52 @@
1
+ import { jsxs as _, jsx as a } from "react/jsx-runtime";
2
+ import { useRef as R, useState as i, useEffect as l, useLayoutEffect as g } from "react";
3
+ const f = process.env.VITE_EMBED_VERSION || "v1", C = process.env.VITE_PROD_HOSTNAME || "embed.deposits.hel.io";
4
+ process.env.VERCEL_ENV;
5
+ const v = `helio-deposit-react-${f}`, O = process.env.NODE_ENV === "development" ? "http://localhost:20300/main.tsx" : `https://${C}/assets/main-${f}.js`, y = ({ children: t }) => /* @__PURE__ */ _("div", { children: [
6
+ "Error loading Helio Deposit for React",
7
+ t ? `: ${t}` : ""
8
+ ] }), M = (t = O) => {
9
+ const e = document.createElement("script");
10
+ return e.setAttribute("type", "module"), e.setAttribute("id", v), e.setAttribute("src", t), document.body.appendChild(e), e;
11
+ }, h = (t) => {
12
+ const e = R(null), [c, D] = i(!1), [r, S] = i(), [p, n] = i("");
13
+ return l(() => D(!0), []), l(() => {
14
+ let u = !1;
15
+ if (r) return;
16
+ const s = () => {
17
+ if (u) return;
18
+ const o = window.moonpayCommerceDeposit;
19
+ if (!o) {
20
+ n(
21
+ "Unable to load Helio Deposit - missing init function on window.moonpayCommerceDeposit"
22
+ );
23
+ return;
24
+ }
25
+ S(() => o);
26
+ }, m = (o) => {
27
+ const d = () => n("Error loading script tag");
28
+ return o.addEventListener("load", s), o.addEventListener("error", d), () => {
29
+ u = !0, o.removeEventListener("load", s), o.removeEventListener("error", d);
30
+ };
31
+ }, E = document.querySelector(
32
+ `script#${v}`
33
+ );
34
+ if (E) {
35
+ window.moonpayCommerceDeposit ? s() : m(E);
36
+ return;
37
+ }
38
+ const I = M();
39
+ return m(I);
40
+ }, [r]), g(() => {
41
+ if (!(!r || !c)) {
42
+ if (!e.current) {
43
+ n("Missing element to mount Helio Deposit");
44
+ return;
45
+ }
46
+ r(e.current, t.config);
47
+ }
48
+ }, [r, c, t.config]), p ? /* @__PURE__ */ a(y, { children: p }) : r ? /* @__PURE__ */ a("div", { ref: e }) : null;
49
+ };
50
+ export {
51
+ h as MoonpayCommerceDeposit
52
+ };
package/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "@heliofi/deposit-react",
3
+ "private": false,
4
+ "version": "0.0.1-beta.1",
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "vite",
8
+ "build": "vite build",
9
+ "start": "vite",
10
+ "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
11
+ "lint:strict": "yarn lint",
12
+ "lint:fix": "yarn lint --fix",
13
+ "format": "prettier -w .",
14
+ "format:check": "prettier -c .",
15
+ "preview": "vite preview",
16
+ "prepublishOnly": "rimraf dist && yarn build",
17
+ "test": "vitest run",
18
+ "test:watch": "vitest",
19
+ "typecheck": "tsc -p tsconfig.json --noEmit",
20
+ "typecheck:fast": "tsc --noEmit --incremental"
21
+ },
22
+ "main": "./dist/helio-deposit-react.es.js",
23
+ "module": "./dist/helio-deposit-react.es.js",
24
+ "types": "./dist/helio-deposit-react.es.d.ts",
25
+ "exports": {
26
+ ".": {
27
+ "import": "./dist/helio-deposit-react.es.js"
28
+ }
29
+ },
30
+ "files": [
31
+ "dist/helio-deposit-react.es.js",
32
+ "dist/helio-deposit-react.es.d.ts"
33
+ ],
34
+ "peerDependencies": {
35
+ "react": ">=18.2.0 <20",
36
+ "react-dom": ">=18.2.0 <20"
37
+ },
38
+ "devDependencies": {
39
+ "@testing-library/dom": "9.3.3",
40
+ "@testing-library/jest-dom": "5.16.5",
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": "4.33.0",
45
+ "@typescript-eslint/parser": "4.33.0",
46
+ "@vitejs/plugin-react": "4.3.2",
47
+ "eslint": "7.32.0",
48
+ "eslint-plugin-react": "7.33.2",
49
+ "eslint-plugin-react-hooks": "4.6.0",
50
+ "jsdom": "23.0.1",
51
+ "react": "18.2.0",
52
+ "react-dom": "18.2.0",
53
+ "rimraf": "3.0.2",
54
+ "typescript": "5.1.6",
55
+ "vite": "5.4.8",
56
+ "vite-plugin-dts": "3.7.1",
57
+ "vite-tsconfig-paths": "4.3.2",
58
+ "vitest": "3.2.4"
59
+ }
60
+ }