@cookill/wallet-adapter 2.5.4 → 3.1.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.
- package/README.md +275 -196
- package/dist/ErrorBoundary.cjs +53 -110
- package/dist/ErrorBoundary.cjs.map +1 -1
- package/dist/ErrorBoundary.d.cts +11 -7
- package/dist/ErrorBoundary.d.ts +11 -7
- package/dist/ErrorBoundary.js +50 -85
- package/dist/ErrorBoundary.js.map +1 -1
- package/dist/LoadingStates.cjs +134 -267
- package/dist/LoadingStates.cjs.map +1 -1
- package/dist/LoadingStates.d.cts +11 -15
- package/dist/LoadingStates.d.ts +11 -15
- package/dist/LoadingStates.js +129 -239
- package/dist/LoadingStates.js.map +1 -1
- package/dist/index.cjs +483 -161
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +330 -62
- package/dist/index.d.ts +330 -62
- package/dist/index.js +463 -127
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +438 -1024
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +1 -118
- package/dist/react.d.ts +1 -118
- package/dist/react.js +430 -969
- package/dist/react.js.map +1 -1
- package/dist/standard.cjs +127 -121
- package/dist/standard.cjs.map +1 -1
- package/dist/standard.d.cts +6 -44
- package/dist/standard.d.ts +6 -44
- package/dist/standard.js +118 -91
- package/dist/standard.js.map +1 -1
- package/package.json +42 -36
package/dist/ErrorBoundary.cjs
CHANGED
|
@@ -1,127 +1,70 @@
|
|
|
1
|
-
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
'use strict';
|
|
19
2
|
|
|
20
|
-
|
|
21
|
-
var
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
var import_react = require("react");
|
|
28
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
29
|
-
var WalletErrorBoundary = class extends import_react.Component {
|
|
30
|
-
constructor() {
|
|
31
|
-
super(...arguments);
|
|
32
|
-
this.state = {
|
|
33
|
-
hasError: false,
|
|
34
|
-
error: null
|
|
35
|
-
};
|
|
36
|
-
this.handleRetry = () => {
|
|
3
|
+
var react = require('react');
|
|
4
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
5
|
+
|
|
6
|
+
var WalletErrorBoundary = class extends react.Component {
|
|
7
|
+
constructor(props) {
|
|
8
|
+
super(props);
|
|
9
|
+
this.handleReset = () => {
|
|
37
10
|
this.setState({ hasError: false, error: null });
|
|
38
11
|
};
|
|
12
|
+
this.state = { hasError: false, error: null };
|
|
39
13
|
}
|
|
40
14
|
static getDerivedStateFromError(error) {
|
|
41
15
|
return { hasError: true, error };
|
|
42
16
|
}
|
|
43
17
|
componentDidCatch(error, errorInfo) {
|
|
44
|
-
console.error("[
|
|
18
|
+
console.error("[WalletErrorBoundary] Caught error:", error, errorInfo);
|
|
45
19
|
this.props.onError?.(error, errorInfo);
|
|
46
20
|
}
|
|
47
21
|
render() {
|
|
48
|
-
if (this.state.hasError) {
|
|
49
|
-
|
|
50
|
-
|
|
22
|
+
if (this.state.hasError && this.state.error) {
|
|
23
|
+
const { fallback } = this.props;
|
|
24
|
+
if (typeof fallback === "function") {
|
|
25
|
+
return fallback(this.state.error, this.handleReset);
|
|
26
|
+
}
|
|
27
|
+
if (fallback) {
|
|
28
|
+
return fallback;
|
|
51
29
|
}
|
|
52
|
-
return /* @__PURE__ */ (
|
|
53
|
-
"
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
width: "24",
|
|
80
|
-
height: "24",
|
|
81
|
-
viewBox: "0 0 24 24",
|
|
82
|
-
fill: "none",
|
|
83
|
-
stroke: "#dc2626",
|
|
84
|
-
strokeWidth: "2",
|
|
85
|
-
strokeLinecap: "round",
|
|
86
|
-
strokeLinejoin: "round",
|
|
87
|
-
children: [
|
|
88
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "12", cy: "12", r: "10" }),
|
|
89
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: "12", y1: "8", x2: "12", y2: "12" }),
|
|
90
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: "12", y1: "16", x2: "12.01", y2: "16" })
|
|
91
|
-
]
|
|
92
|
-
}
|
|
93
|
-
)
|
|
94
|
-
}
|
|
95
|
-
),
|
|
96
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { style: { margin: "0 0 8px", fontSize: "16px", fontWeight: 600, color: "#991b1b" }, children: "Wallet Connection Error" }),
|
|
97
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { style: { margin: "0 0 16px", fontSize: "14px", color: "#b91c1c" }, children: this.state.error?.message || "Something went wrong" }),
|
|
98
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
99
|
-
"button",
|
|
100
|
-
{
|
|
101
|
-
onClick: this.handleRetry,
|
|
102
|
-
style: {
|
|
103
|
-
padding: "8px 16px",
|
|
104
|
-
borderRadius: "8px",
|
|
105
|
-
border: "none",
|
|
106
|
-
backgroundColor: "#dc2626",
|
|
107
|
-
color: "white",
|
|
108
|
-
cursor: "pointer",
|
|
109
|
-
fontSize: "14px",
|
|
110
|
-
fontWeight: 500
|
|
111
|
-
},
|
|
112
|
-
children: "Try Again"
|
|
113
|
-
}
|
|
114
|
-
)
|
|
115
|
-
]
|
|
116
|
-
}
|
|
117
|
-
);
|
|
30
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
|
|
31
|
+
padding: "20px",
|
|
32
|
+
margin: "10px",
|
|
33
|
+
backgroundColor: "#1a1a2e",
|
|
34
|
+
border: "1px solid #ef4444",
|
|
35
|
+
borderRadius: "12px",
|
|
36
|
+
color: "#ffffff"
|
|
37
|
+
}, children: [
|
|
38
|
+
/* @__PURE__ */ jsxRuntime.jsx("h3", { style: { color: "#ef4444", margin: "0 0 12px 0" }, children: "Wallet Connection Error" }),
|
|
39
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { style: { color: "#94a3b8", margin: "0 0 16px 0", fontSize: "14px" }, children: this.state.error.message }),
|
|
40
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
41
|
+
"button",
|
|
42
|
+
{
|
|
43
|
+
onClick: this.handleReset,
|
|
44
|
+
style: {
|
|
45
|
+
padding: "8px 16px",
|
|
46
|
+
backgroundColor: "#6EB9A8",
|
|
47
|
+
color: "#011B29",
|
|
48
|
+
border: "none",
|
|
49
|
+
borderRadius: "8px",
|
|
50
|
+
cursor: "pointer",
|
|
51
|
+
fontWeight: 500
|
|
52
|
+
},
|
|
53
|
+
children: "Try Again"
|
|
54
|
+
}
|
|
55
|
+
)
|
|
56
|
+
] });
|
|
118
57
|
}
|
|
119
58
|
return this.props.children;
|
|
120
59
|
}
|
|
121
60
|
};
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}
|
|
61
|
+
function withWalletErrorBoundary(WrappedComponent, fallback) {
|
|
62
|
+
return function WithErrorBoundary(props) {
|
|
63
|
+
return /* @__PURE__ */ jsxRuntime.jsx(WalletErrorBoundary, { fallback, children: /* @__PURE__ */ jsxRuntime.jsx(WrappedComponent, { ...props }) });
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
exports.WalletErrorBoundary = WalletErrorBoundary;
|
|
68
|
+
exports.withWalletErrorBoundary = withWalletErrorBoundary;
|
|
69
|
+
//# sourceMappingURL=ErrorBoundary.cjs.map
|
|
127
70
|
//# sourceMappingURL=ErrorBoundary.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/ErrorBoundary.tsx"],"sourcesContent":["/**\n * @cookill/wallet-adapter
|
|
1
|
+
{"version":3,"sources":["../src/react/ErrorBoundary.tsx"],"names":["Component","jsxs","jsx"],"mappings":";;;;;AAkBO,IAAM,mBAAA,GAAN,cAAkCA,eAAA,CAA2C;AAAA,EAClF,YAAY,KAAA,EAAiC;AAC3C,IAAA,KAAA,CAAM,KAAK,CAAA;AAab,IAAA,IAAA,CAAA,WAAA,GAAc,MAAY;AACxB,MAAA,IAAA,CAAK,SAAS,EAAE,QAAA,EAAU,KAAA,EAAO,KAAA,EAAO,MAAM,CAAA;AAAA,IAChD,CAAA;AAdE,IAAA,IAAA,CAAK,KAAA,GAAQ,EAAE,QAAA,EAAU,KAAA,EAAO,OAAO,IAAA,EAAK;AAAA,EAC9C;AAAA,EAEA,OAAO,yBAAyB,KAAA,EAAqB;AACnD,IAAA,OAAO,EAAE,QAAA,EAAU,IAAA,EAAM,KAAA,EAAM;AAAA,EACjC;AA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AAK,WAAA;AAAA,YACd,KAAA,EAAO;AAAA,cACL,OAAA,EAAS,UAAA;AAAA,cACT,eAAA,EAAiB,SAAA;AAAA,cACjB,KAAA,EAAO,SAAA;AAAA,cACP,MAAA,EAAQ,MAAA;AAAA,cACR,YAAA,EAAc,KAAA;AAAA,cACd,MAAA,EAAQ,SAAA;AAAA,cACR,UAAA,EAAY;AAAA,aACd;AAAA,YACD,QAAA,EAAA;AAAA;AAAA;AAED,OAAA,EACF,CAAA;AAAA,IAEJ;AAEA,IAAA,OAAO,KAAK,KAAA,CAAM,QAAA;AAAA,EACpB;AACF;AAKO,SAAS,uBAAA,CACd,kBACA,QAAA,EACA;AACA,EAAA,OAAO,SAAS,kBAAkB,KAAA,EAAU;AAC1C,IAAA,sCACG,mBAAA,EAAA,EAAoB,QAAA,EACnB,yCAAC,gBAAA,EAAA,EAAkB,GAAG,OAAO,CAAA,EAC/B,CAAA;AAAA,EAEJ,CAAA;AACF","file":"ErrorBoundary.cjs","sourcesContent":["/**\n * @cookill/wallet-adapter/react v3.0.0\n * Error Boundary for wallet integration\n */\n\nimport React, { Component, type ReactNode, type ErrorInfo } from 'react';\n\nexport interface WalletErrorBoundaryProps {\n children: ReactNode;\n fallback?: ReactNode | ((error: Error, reset: () => void) => ReactNode);\n onError?: (error: Error, errorInfo: ErrorInfo) => void;\n}\n\ninterface State {\n hasError: boolean;\n error: Error | null;\n}\n\nexport class WalletErrorBoundary extends Component<WalletErrorBoundaryProps, State> {\n constructor(props: WalletErrorBoundaryProps) {\n super(props);\n this.state = { hasError: false, error: null };\n }\n\n static getDerivedStateFromError(error: Error): State {\n return { hasError: true, error };\n }\n\n componentDidCatch(error: Error, errorInfo: ErrorInfo): void {\n console.error('[WalletErrorBoundary] Caught error:', error, errorInfo);\n this.props.onError?.(error, errorInfo);\n }\n\n handleReset = (): void => {\n this.setState({ hasError: false, error: null });\n };\n\n render(): ReactNode {\n if (this.state.hasError && this.state.error) {\n const { fallback } = this.props;\n \n if (typeof fallback === 'function') {\n return fallback(this.state.error, this.handleReset);\n }\n \n if (fallback) {\n return fallback;\n }\n\n return (\n <div style={{\n padding: '20px',\n margin: '10px',\n backgroundColor: '#1a1a2e',\n border: '1px solid #ef4444',\n borderRadius: '12px',\n color: '#ffffff',\n }}>\n <h3 style={{ color: '#ef4444', margin: '0 0 12px 0' }}>\n Wallet Connection Error\n </h3>\n <p style={{ color: '#94a3b8', margin: '0 0 16px 0', fontSize: '14px' }}>\n {this.state.error.message}\n </p>\n <button\n onClick={this.handleReset}\n style={{\n padding: '8px 16px',\n backgroundColor: '#6EB9A8',\n color: '#011B29',\n border: 'none',\n borderRadius: '8px',\n cursor: 'pointer',\n fontWeight: 500,\n }}\n >\n Try Again\n </button>\n </div>\n );\n }\n\n return this.props.children;\n }\n}\n\n/**\n * HOC to wrap components with error boundary\n */\nexport function withWalletErrorBoundary<P extends object>(\n WrappedComponent: React.ComponentType<P>,\n fallback?: WalletErrorBoundaryProps['fallback']\n) {\n return function WithErrorBoundary(props: P) {\n return (\n <WalletErrorBoundary fallback={fallback}>\n <WrappedComponent {...props} />\n </WalletErrorBoundary>\n );\n };\n}\n\nexport default WalletErrorBoundary;\n"]}
|
package/dist/ErrorBoundary.d.cts
CHANGED
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import React, { Component, ReactNode, ErrorInfo } from 'react';
|
|
3
3
|
|
|
4
|
-
interface
|
|
4
|
+
interface WalletErrorBoundaryProps {
|
|
5
5
|
children: ReactNode;
|
|
6
|
-
fallback?: ReactNode;
|
|
6
|
+
fallback?: ReactNode | ((error: Error, reset: () => void) => ReactNode);
|
|
7
7
|
onError?: (error: Error, errorInfo: ErrorInfo) => void;
|
|
8
8
|
}
|
|
9
9
|
interface State {
|
|
10
10
|
hasError: boolean;
|
|
11
11
|
error: Error | null;
|
|
12
12
|
}
|
|
13
|
-
declare class WalletErrorBoundary extends Component<
|
|
14
|
-
|
|
13
|
+
declare class WalletErrorBoundary extends Component<WalletErrorBoundaryProps, State> {
|
|
14
|
+
constructor(props: WalletErrorBoundaryProps);
|
|
15
15
|
static getDerivedStateFromError(error: Error): State;
|
|
16
16
|
componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
|
|
17
|
-
|
|
18
|
-
render():
|
|
17
|
+
handleReset: () => void;
|
|
18
|
+
render(): ReactNode;
|
|
19
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* HOC to wrap components with error boundary
|
|
22
|
+
*/
|
|
23
|
+
declare function withWalletErrorBoundary<P extends object>(WrappedComponent: React.ComponentType<P>, fallback?: WalletErrorBoundaryProps['fallback']): (props: P) => react_jsx_runtime.JSX.Element;
|
|
20
24
|
|
|
21
|
-
export { WalletErrorBoundary,
|
|
25
|
+
export { WalletErrorBoundary, type WalletErrorBoundaryProps, withWalletErrorBoundary };
|
package/dist/ErrorBoundary.d.ts
CHANGED
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import React, { Component, ReactNode, ErrorInfo } from 'react';
|
|
3
3
|
|
|
4
|
-
interface
|
|
4
|
+
interface WalletErrorBoundaryProps {
|
|
5
5
|
children: ReactNode;
|
|
6
|
-
fallback?: ReactNode;
|
|
6
|
+
fallback?: ReactNode | ((error: Error, reset: () => void) => ReactNode);
|
|
7
7
|
onError?: (error: Error, errorInfo: ErrorInfo) => void;
|
|
8
8
|
}
|
|
9
9
|
interface State {
|
|
10
10
|
hasError: boolean;
|
|
11
11
|
error: Error | null;
|
|
12
12
|
}
|
|
13
|
-
declare class WalletErrorBoundary extends Component<
|
|
14
|
-
|
|
13
|
+
declare class WalletErrorBoundary extends Component<WalletErrorBoundaryProps, State> {
|
|
14
|
+
constructor(props: WalletErrorBoundaryProps);
|
|
15
15
|
static getDerivedStateFromError(error: Error): State;
|
|
16
16
|
componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
|
|
17
|
-
|
|
18
|
-
render():
|
|
17
|
+
handleReset: () => void;
|
|
18
|
+
render(): ReactNode;
|
|
19
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* HOC to wrap components with error boundary
|
|
22
|
+
*/
|
|
23
|
+
declare function withWalletErrorBoundary<P extends object>(WrappedComponent: React.ComponentType<P>, fallback?: WalletErrorBoundaryProps['fallback']): (props: P) => react_jsx_runtime.JSX.Element;
|
|
20
24
|
|
|
21
|
-
export { WalletErrorBoundary,
|
|
25
|
+
export { WalletErrorBoundary, type WalletErrorBoundaryProps, withWalletErrorBoundary };
|
package/dist/ErrorBoundary.js
CHANGED
|
@@ -1,102 +1,67 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { Component } from 'react';
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
|
|
4
4
|
var WalletErrorBoundary = class extends Component {
|
|
5
|
-
constructor() {
|
|
6
|
-
super(
|
|
7
|
-
this.
|
|
8
|
-
hasError: false,
|
|
9
|
-
error: null
|
|
10
|
-
};
|
|
11
|
-
this.handleRetry = () => {
|
|
5
|
+
constructor(props) {
|
|
6
|
+
super(props);
|
|
7
|
+
this.handleReset = () => {
|
|
12
8
|
this.setState({ hasError: false, error: null });
|
|
13
9
|
};
|
|
10
|
+
this.state = { hasError: false, error: null };
|
|
14
11
|
}
|
|
15
12
|
static getDerivedStateFromError(error) {
|
|
16
13
|
return { hasError: true, error };
|
|
17
14
|
}
|
|
18
15
|
componentDidCatch(error, errorInfo) {
|
|
19
|
-
console.error("[
|
|
16
|
+
console.error("[WalletErrorBoundary] Caught error:", error, errorInfo);
|
|
20
17
|
this.props.onError?.(error, errorInfo);
|
|
21
18
|
}
|
|
22
19
|
render() {
|
|
23
|
-
if (this.state.hasError) {
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
if (this.state.hasError && this.state.error) {
|
|
21
|
+
const { fallback } = this.props;
|
|
22
|
+
if (typeof fallback === "function") {
|
|
23
|
+
return fallback(this.state.error, this.handleReset);
|
|
24
|
+
}
|
|
25
|
+
if (fallback) {
|
|
26
|
+
return fallback;
|
|
26
27
|
}
|
|
27
|
-
return /* @__PURE__ */ jsxs(
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
width: "24",
|
|
55
|
-
height: "24",
|
|
56
|
-
viewBox: "0 0 24 24",
|
|
57
|
-
fill: "none",
|
|
58
|
-
stroke: "#dc2626",
|
|
59
|
-
strokeWidth: "2",
|
|
60
|
-
strokeLinecap: "round",
|
|
61
|
-
strokeLinejoin: "round",
|
|
62
|
-
children: [
|
|
63
|
-
/* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "10" }),
|
|
64
|
-
/* @__PURE__ */ jsx("line", { x1: "12", y1: "8", x2: "12", y2: "12" }),
|
|
65
|
-
/* @__PURE__ */ jsx("line", { x1: "12", y1: "16", x2: "12.01", y2: "16" })
|
|
66
|
-
]
|
|
67
|
-
}
|
|
68
|
-
)
|
|
69
|
-
}
|
|
70
|
-
),
|
|
71
|
-
/* @__PURE__ */ jsx("h3", { style: { margin: "0 0 8px", fontSize: "16px", fontWeight: 600, color: "#991b1b" }, children: "Wallet Connection Error" }),
|
|
72
|
-
/* @__PURE__ */ jsx("p", { style: { margin: "0 0 16px", fontSize: "14px", color: "#b91c1c" }, children: this.state.error?.message || "Something went wrong" }),
|
|
73
|
-
/* @__PURE__ */ jsx(
|
|
74
|
-
"button",
|
|
75
|
-
{
|
|
76
|
-
onClick: this.handleRetry,
|
|
77
|
-
style: {
|
|
78
|
-
padding: "8px 16px",
|
|
79
|
-
borderRadius: "8px",
|
|
80
|
-
border: "none",
|
|
81
|
-
backgroundColor: "#dc2626",
|
|
82
|
-
color: "white",
|
|
83
|
-
cursor: "pointer",
|
|
84
|
-
fontSize: "14px",
|
|
85
|
-
fontWeight: 500
|
|
86
|
-
},
|
|
87
|
-
children: "Try Again"
|
|
88
|
-
}
|
|
89
|
-
)
|
|
90
|
-
]
|
|
91
|
-
}
|
|
92
|
-
);
|
|
28
|
+
return /* @__PURE__ */ jsxs("div", { style: {
|
|
29
|
+
padding: "20px",
|
|
30
|
+
margin: "10px",
|
|
31
|
+
backgroundColor: "#1a1a2e",
|
|
32
|
+
border: "1px solid #ef4444",
|
|
33
|
+
borderRadius: "12px",
|
|
34
|
+
color: "#ffffff"
|
|
35
|
+
}, children: [
|
|
36
|
+
/* @__PURE__ */ jsx("h3", { style: { color: "#ef4444", margin: "0 0 12px 0" }, children: "Wallet Connection Error" }),
|
|
37
|
+
/* @__PURE__ */ jsx("p", { style: { color: "#94a3b8", margin: "0 0 16px 0", fontSize: "14px" }, children: this.state.error.message }),
|
|
38
|
+
/* @__PURE__ */ jsx(
|
|
39
|
+
"button",
|
|
40
|
+
{
|
|
41
|
+
onClick: this.handleReset,
|
|
42
|
+
style: {
|
|
43
|
+
padding: "8px 16px",
|
|
44
|
+
backgroundColor: "#6EB9A8",
|
|
45
|
+
color: "#011B29",
|
|
46
|
+
border: "none",
|
|
47
|
+
borderRadius: "8px",
|
|
48
|
+
cursor: "pointer",
|
|
49
|
+
fontWeight: 500
|
|
50
|
+
},
|
|
51
|
+
children: "Try Again"
|
|
52
|
+
}
|
|
53
|
+
)
|
|
54
|
+
] });
|
|
93
55
|
}
|
|
94
56
|
return this.props.children;
|
|
95
57
|
}
|
|
96
58
|
};
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
59
|
+
function withWalletErrorBoundary(WrappedComponent, fallback) {
|
|
60
|
+
return function WithErrorBoundary(props) {
|
|
61
|
+
return /* @__PURE__ */ jsx(WalletErrorBoundary, { fallback, children: /* @__PURE__ */ jsx(WrappedComponent, { ...props }) });
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export { WalletErrorBoundary, withWalletErrorBoundary };
|
|
66
|
+
//# sourceMappingURL=ErrorBoundary.js.map
|
|
102
67
|
//# sourceMappingURL=ErrorBoundary.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/ErrorBoundary.tsx"],"sourcesContent":["/**\n * @cookill/wallet-adapter
|
|
1
|
+
{"version":3,"sources":["../src/react/ErrorBoundary.tsx"],"names":[],"mappings":";;;AAkBO,IAAM,mBAAA,GAAN,cAAkC,SAAA,CAA2C;AAAA,EAClF,YAAY,KAAA,EAAiC;AAC3C,IAAA,KAAA,CAAM,KAAK,CAAA;AAab,IAAA,IAAA,CAAA,WAAA,GAAc,MAAY;AACxB,MAAA,IAAA,CAAK,SAAS,EAAE,QAAA,EAAU,KAAA,EAAO,KAAA,EAAO,MAAM,CAAA;AAAA,IAChD,CAAA;AAdE,IAAA,IAAA,CAAK,KAAA,GAAQ,EAAE,QAAA,EAAU,KAAA,EAAO,OAAO,IAAA,EAAK;AAAA,EAC9C;AAAA,EAEA,OAAO,yBAAyB,KAAA,EAAqB;AACnD,IAAA,OAAO,EAAE,QAAA,EAAU,IAAA,EAAM,KAAA,EAAM;AAAA,EACjC;AAAA,EAEA,iBAAA,CAAkB,OAAc,SAAA,EAA4B;AAC1D,IAAA,OAAA,CAAQ,KAAA,CAAM,qCAAA,EAAuC,KAAA,EAAO,SAAS,CAAA;AACrE,IAAA,IAAA,CAAK,KAAA,CAAM,OAAA,GAAU,KAAA,EAAO,SAAS,CAAA;AAAA,EACvC;AAAA,EAMA,MAAA,GAAoB;AAClB,IAAA,IAAI,IAAA,CAAK,KAAA,CAAM,QAAA,IAAY,IAAA,CAAK,MAAM,KAAA,EAAO;A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,IAAA,OAAO,KAAK,KAAA,CAAM,QAAA;AAAA,EACpB;AACF;AAKO,SAAS,uBAAA,CACd,kBACA,QAAA,EACA;AACA,EAAA,OAAO,SAAS,kBAAkB,KAAA,EAAU;AAC1C,IAAA,2BACG,mBAAA,EAAA,EAAoB,QAAA,EACnB,8BAAC,gBAAA,EAAA,EAAkB,GAAG,OAAO,CAAA,EAC/B,CAAA;AAAA,EAEJ,CAAA;AACF","file":"ErrorBoundary.js","sourcesContent":["/**\n * @cookill/wallet-adapter/react v3.0.0\n * Error Boundary for wallet integration\n */\n\nimport React, { Component, type ReactNode, type ErrorInfo } from 'react';\n\nexport interface WalletErrorBoundaryProps {\n children: ReactNode;\n fallback?: ReactNode | ((error: Error, reset: () => void) => ReactNode);\n onError?: (error: Error, errorInfo: ErrorInfo) => void;\n}\n\ninterface State {\n hasError: boolean;\n error: Error | null;\n}\n\nexport class WalletErrorBoundary extends Component<WalletErrorBoundaryProps, State> {\n constructor(props: WalletErrorBoundaryProps) {\n super(props);\n this.state = { hasError: false, error: null };\n }\n\n static getDerivedStateFromError(error: Error): State {\n return { hasError: true, error };\n }\n\n componentDidCatch(error: Error, errorInfo: ErrorInfo): void {\n console.error('[WalletErrorBoundary] Caught error:', error, errorInfo);\n this.props.onError?.(error, errorInfo);\n }\n\n handleReset = (): void => {\n this.setState({ hasError: false, error: null });\n };\n\n render(): ReactNode {\n if (this.state.hasError && this.state.error) {\n const { fallback } = this.props;\n \n if (typeof fallback === 'function') {\n return fallback(this.state.error, this.handleReset);\n }\n \n if (fallback) {\n return fallback;\n }\n\n return (\n <div style={{\n padding: '20px',\n margin: '10px',\n backgroundColor: '#1a1a2e',\n border: '1px solid #ef4444',\n borderRadius: '12px',\n color: '#ffffff',\n }}>\n <h3 style={{ color: '#ef4444', margin: '0 0 12px 0' }}>\n Wallet Connection Error\n </h3>\n <p style={{ color: '#94a3b8', margin: '0 0 16px 0', fontSize: '14px' }}>\n {this.state.error.message}\n </p>\n <button\n onClick={this.handleReset}\n style={{\n padding: '8px 16px',\n backgroundColor: '#6EB9A8',\n color: '#011B29',\n border: 'none',\n borderRadius: '8px',\n cursor: 'pointer',\n fontWeight: 500,\n }}\n >\n Try Again\n </button>\n </div>\n );\n }\n\n return this.props.children;\n }\n}\n\n/**\n * HOC to wrap components with error boundary\n */\nexport function withWalletErrorBoundary<P extends object>(\n WrappedComponent: React.ComponentType<P>,\n fallback?: WalletErrorBoundaryProps['fallback']\n) {\n return function WithErrorBoundary(props: P) {\n return (\n <WalletErrorBoundary fallback={fallback}>\n <WrappedComponent {...props} />\n </WalletErrorBoundary>\n );\n };\n}\n\nexport default WalletErrorBoundary;\n"]}
|