@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.
@@ -1,127 +1,70 @@
1
- "use strict";
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
- // src/ErrorBoundary.tsx
21
- var ErrorBoundary_exports = {};
22
- __export(ErrorBoundary_exports, {
23
- WalletErrorBoundary: () => WalletErrorBoundary,
24
- default: () => ErrorBoundary_default
25
- });
26
- module.exports = __toCommonJS(ErrorBoundary_exports);
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("[WalletAdapter] Error caught by boundary:", error, errorInfo);
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
- if (this.props.fallback) {
50
- return this.props.fallback;
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__ */ (0, import_jsx_runtime.jsxs)(
53
- "div",
54
- {
55
- style: {
56
- padding: "20px",
57
- borderRadius: "12px",
58
- border: "1px solid #fee2e2",
59
- backgroundColor: "#fef2f2",
60
- textAlign: "center"
61
- },
62
- children: [
63
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
64
- "div",
65
- {
66
- style: {
67
- width: "48px",
68
- height: "48px",
69
- margin: "0 auto 12px",
70
- borderRadius: "50%",
71
- backgroundColor: "#fecaca",
72
- display: "flex",
73
- alignItems: "center",
74
- justifyContent: "center"
75
- },
76
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
77
- "svg",
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
- var ErrorBoundary_default = WalletErrorBoundary;
123
- // Annotate the CommonJS export names for ESM import in node:
124
- 0 && (module.exports = {
125
- WalletErrorBoundary
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 - Error Boundary\n * Prevents blank screens from uncaught errors\n */\n\nimport React, { Component, ErrorInfo, ReactNode } from 'react';\n\ninterface Props {\n children: ReactNode;\n fallback?: 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<Props, State> {\n public state: State = {\n hasError: false,\n error: null,\n };\n\n public static getDerivedStateFromError(error: Error): State {\n return { hasError: true, error };\n }\n\n public componentDidCatch(error: Error, errorInfo: ErrorInfo) {\n console.error('[WalletAdapter] Error caught by boundary:', error, errorInfo);\n this.props.onError?.(error, errorInfo);\n }\n\n private handleRetry = () => {\n this.setState({ hasError: false, error: null });\n };\n\n public render() {\n if (this.state.hasError) {\n if (this.props.fallback) {\n return this.props.fallback;\n }\n\n return (\n <div\n style={{\n padding: '20px',\n borderRadius: '12px',\n border: '1px solid #fee2e2',\n backgroundColor: '#fef2f2',\n textAlign: 'center',\n }}\n >\n <div\n style={{\n width: '48px',\n height: '48px',\n margin: '0 auto 12px',\n borderRadius: '50%',\n backgroundColor: '#fecaca',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n }}\n >\n <svg\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"#dc2626\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <circle cx=\"12\" cy=\"12\" r=\"10\" />\n <line x1=\"12\" y1=\"8\" x2=\"12\" y2=\"12\" />\n <line x1=\"12\" y1=\"16\" x2=\"12.01\" y2=\"16\" />\n </svg>\n </div>\n <h3 style={{ margin: '0 0 8px', fontSize: '16px', fontWeight: 600, color: '#991b1b' }}>\n Wallet Connection Error\n </h3>\n <p style={{ margin: '0 0 16px', fontSize: '14px', color: '#b91c1c' }}>\n {this.state.error?.message || 'Something went wrong'}\n </p>\n <button\n onClick={this.handleRetry}\n style={{\n padding: '8px 16px',\n borderRadius: '8px',\n border: 'none',\n backgroundColor: '#dc2626',\n color: 'white',\n cursor: 'pointer',\n fontSize: '14px',\n fontWeight: 500,\n }}\n >\n Try Again\n </button>\n </div>\n );\n }\n\n return this.props.children;\n }\n}\n\nexport default WalletErrorBoundary;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,mBAAuD;AA4D3C;AA/CL,IAAM,sBAAN,cAAkC,uBAAwB;AAAA,EAA1D;AAAA;AACL,SAAO,QAAe;AAAA,MACpB,UAAU;AAAA,MACV,OAAO;AAAA,IACT;AAWA,SAAQ,cAAc,MAAM;AAC1B,WAAK,SAAS,EAAE,UAAU,OAAO,OAAO,KAAK,CAAC;AAAA,IAChD;AAAA;AAAA,EAXA,OAAc,yBAAyB,OAAqB;AAC1D,WAAO,EAAE,UAAU,MAAM,MAAM;AAAA,EACjC;AAAA,EAEO,kBAAkB,OAAc,WAAsB;AAC3D,YAAQ,MAAM,6CAA6C,OAAO,SAAS;AAC3E,SAAK,MAAM,UAAU,OAAO,SAAS;AAAA,EACvC;AAAA,EAMO,SAAS;AACd,QAAI,KAAK,MAAM,UAAU;AACvB,UAAI,KAAK,MAAM,UAAU;AACvB,eAAO,KAAK,MAAM;AAAA,MACpB;AAEA,aACE;AAAA,QAAC;AAAA;AAAA,UACC,OAAO;AAAA,YACL,SAAS;AAAA,YACT,cAAc;AAAA,YACd,QAAQ;AAAA,YACR,iBAAiB;AAAA,YACjB,WAAW;AAAA,UACb;AAA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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"]}
@@ -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 Props {
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<Props, State> {
14
- state: State;
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
- private handleRetry;
18
- render(): string | number | boolean | Iterable<React.ReactNode> | react_jsx_runtime.JSX.Element | null | undefined;
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, WalletErrorBoundary as default };
25
+ export { WalletErrorBoundary, type WalletErrorBoundaryProps, withWalletErrorBoundary };
@@ -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 Props {
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<Props, State> {
14
- state: State;
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
- private handleRetry;
18
- render(): string | number | boolean | Iterable<React.ReactNode> | react_jsx_runtime.JSX.Element | null | undefined;
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, WalletErrorBoundary as default };
25
+ export { WalletErrorBoundary, type WalletErrorBoundaryProps, withWalletErrorBoundary };
@@ -1,102 +1,67 @@
1
- // src/ErrorBoundary.tsx
2
- import { Component } from "react";
3
- import { jsx, jsxs } from "react/jsx-runtime";
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(...arguments);
7
- this.state = {
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("[WalletAdapter] Error caught by boundary:", error, errorInfo);
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
- if (this.props.fallback) {
25
- return this.props.fallback;
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
- "div",
29
- {
30
- style: {
31
- padding: "20px",
32
- borderRadius: "12px",
33
- border: "1px solid #fee2e2",
34
- backgroundColor: "#fef2f2",
35
- textAlign: "center"
36
- },
37
- children: [
38
- /* @__PURE__ */ jsx(
39
- "div",
40
- {
41
- style: {
42
- width: "48px",
43
- height: "48px",
44
- margin: "0 auto 12px",
45
- borderRadius: "50%",
46
- backgroundColor: "#fecaca",
47
- display: "flex",
48
- alignItems: "center",
49
- justifyContent: "center"
50
- },
51
- children: /* @__PURE__ */ jsxs(
52
- "svg",
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
- var ErrorBoundary_default = WalletErrorBoundary;
98
- export {
99
- WalletErrorBoundary,
100
- ErrorBoundary_default as default
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 - Error Boundary\n * Prevents blank screens from uncaught errors\n */\n\nimport React, { Component, ErrorInfo, ReactNode } from 'react';\n\ninterface Props {\n children: ReactNode;\n fallback?: 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<Props, State> {\n public state: State = {\n hasError: false,\n error: null,\n };\n\n public static getDerivedStateFromError(error: Error): State {\n return { hasError: true, error };\n }\n\n public componentDidCatch(error: Error, errorInfo: ErrorInfo) {\n console.error('[WalletAdapter] Error caught by boundary:', error, errorInfo);\n this.props.onError?.(error, errorInfo);\n }\n\n private handleRetry = () => {\n this.setState({ hasError: false, error: null });\n };\n\n public render() {\n if (this.state.hasError) {\n if (this.props.fallback) {\n return this.props.fallback;\n }\n\n return (\n <div\n style={{\n padding: '20px',\n borderRadius: '12px',\n border: '1px solid #fee2e2',\n backgroundColor: '#fef2f2',\n textAlign: 'center',\n }}\n >\n <div\n style={{\n width: '48px',\n height: '48px',\n margin: '0 auto 12px',\n borderRadius: '50%',\n backgroundColor: '#fecaca',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n }}\n >\n <svg\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"#dc2626\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <circle cx=\"12\" cy=\"12\" r=\"10\" />\n <line x1=\"12\" y1=\"8\" x2=\"12\" y2=\"12\" />\n <line x1=\"12\" y1=\"16\" x2=\"12.01\" y2=\"16\" />\n </svg>\n </div>\n <h3 style={{ margin: '0 0 8px', fontSize: '16px', fontWeight: 600, color: '#991b1b' }}>\n Wallet Connection Error\n </h3>\n <p style={{ margin: '0 0 16px', fontSize: '14px', color: '#b91c1c' }}>\n {this.state.error?.message || 'Something went wrong'}\n </p>\n <button\n onClick={this.handleRetry}\n style={{\n padding: '8px 16px',\n borderRadius: '8px',\n border: 'none',\n backgroundColor: '#dc2626',\n color: 'white',\n cursor: 'pointer',\n fontSize: '14px',\n fontWeight: 500,\n }}\n >\n Try Again\n </button>\n </div>\n );\n }\n\n return this.props.children;\n }\n}\n\nexport default WalletErrorBoundary;\n"],"mappings":";AAKA,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AAA,YACC,SAAS,IAAA,CAAK,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,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"]}