@xyo-network/react-error 2.64.9 → 2.64.10
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/docs.json +4069 -817
- package/package.json +7 -7
- package/dist/browser/components/ErrorBoundary/ThrownErrorBoundary.cjs +0 -106
- package/dist/browser/components/ErrorBoundary/ThrownErrorBoundary.cjs.map +0 -1
- package/dist/browser/components/ErrorBoundary/ThrownErrorBoundary.js +0 -85
- package/dist/browser/components/ErrorBoundary/ThrownErrorBoundary.js.map +0 -1
- package/dist/browser/components/ErrorBoundary/index.cjs +0 -108
- package/dist/browser/components/ErrorBoundary/index.cjs.map +0 -1
- package/dist/browser/components/ErrorBoundary/index.js +0 -85
- package/dist/browser/components/ErrorBoundary/index.js.map +0 -1
- package/dist/browser/components/ErrorRender/ErrorAlert.cjs +0 -39
- package/dist/browser/components/ErrorRender/ErrorAlert.cjs.map +0 -1
- package/dist/browser/components/ErrorRender/ErrorAlert.js +0 -18
- package/dist/browser/components/ErrorRender/ErrorAlert.js.map +0 -1
- package/dist/browser/components/ErrorRender/Props.cjs +0 -19
- package/dist/browser/components/ErrorRender/Props.cjs.map +0 -1
- package/dist/browser/components/ErrorRender/Props.js +0 -1
- package/dist/browser/components/ErrorRender/Props.js.map +0 -1
- package/dist/browser/components/ErrorRender/Render.cjs +0 -70
- package/dist/browser/components/ErrorRender/Render.cjs.map +0 -1
- package/dist/browser/components/ErrorRender/Render.js +0 -49
- package/dist/browser/components/ErrorRender/Render.js.map +0 -1
- package/dist/browser/components/ErrorRender/index.cjs +0 -71
- package/dist/browser/components/ErrorRender/index.cjs.map +0 -1
- package/dist/browser/components/ErrorRender/index.js +0 -48
- package/dist/browser/components/ErrorRender/index.js.map +0 -1
- package/dist/browser/components/index.cjs +0 -110
- package/dist/browser/components/index.cjs.map +0 -1
- package/dist/browser/components/index.js +0 -87
- package/dist/browser/components/index.js.map +0 -1
- package/dist/browser/contexts/ErrorReporter/Context.cjs +0 -28
- package/dist/browser/contexts/ErrorReporter/Context.cjs.map +0 -1
- package/dist/browser/contexts/ErrorReporter/Context.js +0 -7
- package/dist/browser/contexts/ErrorReporter/Context.js.map +0 -1
- package/dist/browser/contexts/ErrorReporter/Provider.cjs +0 -43
- package/dist/browser/contexts/ErrorReporter/Provider.cjs.map +0 -1
- package/dist/browser/contexts/ErrorReporter/Provider.js +0 -22
- package/dist/browser/contexts/ErrorReporter/Provider.js.map +0 -1
- package/dist/browser/contexts/ErrorReporter/State.cjs +0 -19
- package/dist/browser/contexts/ErrorReporter/State.cjs.map +0 -1
- package/dist/browser/contexts/ErrorReporter/State.js +0 -1
- package/dist/browser/contexts/ErrorReporter/State.js.map +0 -1
- package/dist/browser/contexts/ErrorReporter/index.cjs +0 -56
- package/dist/browser/contexts/ErrorReporter/index.cjs.map +0 -1
- package/dist/browser/contexts/ErrorReporter/index.js +0 -33
- package/dist/browser/contexts/ErrorReporter/index.js.map +0 -1
- package/dist/browser/contexts/ErrorReporter/useRollbar.cjs +0 -40
- package/dist/browser/contexts/ErrorReporter/useRollbar.cjs.map +0 -1
- package/dist/browser/contexts/ErrorReporter/useRollbar.js +0 -19
- package/dist/browser/contexts/ErrorReporter/useRollbar.js.map +0 -1
- package/dist/browser/contexts/index.cjs +0 -56
- package/dist/browser/contexts/index.cjs.map +0 -1
- package/dist/browser/contexts/index.js +0 -33
- package/dist/browser/contexts/index.js.map +0 -1
- package/dist/node/components/ErrorBoundary/ThrownErrorBoundary.cjs +0 -110
- package/dist/node/components/ErrorBoundary/ThrownErrorBoundary.cjs.map +0 -1
- package/dist/node/components/ErrorBoundary/ThrownErrorBoundary.js +0 -85
- package/dist/node/components/ErrorBoundary/ThrownErrorBoundary.js.map +0 -1
- package/dist/node/components/ErrorBoundary/index.cjs +0 -112
- package/dist/node/components/ErrorBoundary/index.cjs.map +0 -1
- package/dist/node/components/ErrorBoundary/index.js +0 -85
- package/dist/node/components/ErrorBoundary/index.js.map +0 -1
- package/dist/node/components/ErrorRender/ErrorAlert.cjs +0 -43
- package/dist/node/components/ErrorRender/ErrorAlert.cjs.map +0 -1
- package/dist/node/components/ErrorRender/ErrorAlert.js +0 -18
- package/dist/node/components/ErrorRender/ErrorAlert.js.map +0 -1
- package/dist/node/components/ErrorRender/Props.cjs +0 -19
- package/dist/node/components/ErrorRender/Props.cjs.map +0 -1
- package/dist/node/components/ErrorRender/Props.js +0 -1
- package/dist/node/components/ErrorRender/Props.js.map +0 -1
- package/dist/node/components/ErrorRender/Render.cjs +0 -74
- package/dist/node/components/ErrorRender/Render.cjs.map +0 -1
- package/dist/node/components/ErrorRender/Render.js +0 -49
- package/dist/node/components/ErrorRender/Render.js.map +0 -1
- package/dist/node/components/ErrorRender/index.cjs +0 -76
- package/dist/node/components/ErrorRender/index.cjs.map +0 -1
- package/dist/node/components/ErrorRender/index.js +0 -48
- package/dist/node/components/ErrorRender/index.js.map +0 -1
- package/dist/node/components/index.cjs +0 -116
- package/dist/node/components/index.cjs.map +0 -1
- package/dist/node/components/index.js +0 -87
- package/dist/node/components/index.js.map +0 -1
- package/dist/node/contexts/ErrorReporter/Context.cjs +0 -32
- package/dist/node/contexts/ErrorReporter/Context.cjs.map +0 -1
- package/dist/node/contexts/ErrorReporter/Context.js +0 -7
- package/dist/node/contexts/ErrorReporter/Context.js.map +0 -1
- package/dist/node/contexts/ErrorReporter/Provider.cjs +0 -47
- package/dist/node/contexts/ErrorReporter/Provider.cjs.map +0 -1
- package/dist/node/contexts/ErrorReporter/Provider.js +0 -22
- package/dist/node/contexts/ErrorReporter/Provider.js.map +0 -1
- package/dist/node/contexts/ErrorReporter/State.cjs +0 -19
- package/dist/node/contexts/ErrorReporter/State.cjs.map +0 -1
- package/dist/node/contexts/ErrorReporter/State.js +0 -1
- package/dist/node/contexts/ErrorReporter/State.js.map +0 -1
- package/dist/node/contexts/ErrorReporter/index.cjs +0 -61
- package/dist/node/contexts/ErrorReporter/index.cjs.map +0 -1
- package/dist/node/contexts/ErrorReporter/index.js +0 -33
- package/dist/node/contexts/ErrorReporter/index.js.map +0 -1
- package/dist/node/contexts/ErrorReporter/useRollbar.cjs +0 -44
- package/dist/node/contexts/ErrorReporter/useRollbar.cjs.map +0 -1
- package/dist/node/contexts/ErrorReporter/useRollbar.js +0 -19
- package/dist/node/contexts/ErrorReporter/useRollbar.js.map +0 -1
- package/dist/node/contexts/index.cjs +0 -61
- package/dist/node/contexts/index.cjs.map +0 -1
- package/dist/node/contexts/index.js +0 -33
- package/dist/node/contexts/index.js.map +0 -1
package/package.json
CHANGED
@@ -10,10 +10,10 @@
|
|
10
10
|
"url": "https://github.com/XYOracleNetwork/sdk-xyo-react-js/issues"
|
11
11
|
},
|
12
12
|
"dependencies": {
|
13
|
-
"@xylabs/react-button": "^3.0.
|
14
|
-
"@xylabs/react-flexbox": "^3.0.
|
15
|
-
"@xylabs/react-shared": "^3.0.
|
16
|
-
"@xyo-network/payload-model": "^2.75.
|
13
|
+
"@xylabs/react-button": "^3.0.18",
|
14
|
+
"@xylabs/react-flexbox": "^3.0.18",
|
15
|
+
"@xylabs/react-shared": "^3.0.18",
|
16
|
+
"@xyo-network/payload-model": "^2.75.16",
|
17
17
|
"react-router-dom": "^6.16.0"
|
18
18
|
},
|
19
19
|
"peerDependencies": {
|
@@ -26,8 +26,8 @@
|
|
26
26
|
},
|
27
27
|
"devDependencies": {
|
28
28
|
"@storybook/react": "^7.4.6",
|
29
|
-
"@xylabs/ts-scripts-yarn3": "^3.
|
30
|
-
"@xylabs/tsconfig-react": "^3.
|
29
|
+
"@xylabs/ts-scripts-yarn3": "^3.1.3",
|
30
|
+
"@xylabs/tsconfig-react": "^3.1.3",
|
31
31
|
"typescript": "^5.2.2"
|
32
32
|
},
|
33
33
|
"peerDependenciesMeta": {
|
@@ -86,6 +86,6 @@
|
|
86
86
|
},
|
87
87
|
"sideEffects": false,
|
88
88
|
"types": "dist/browser/index.d.ts",
|
89
|
-
"version": "2.64.
|
89
|
+
"version": "2.64.10",
|
90
90
|
"type": "module"
|
91
91
|
}
|
@@ -1,106 +0,0 @@
|
|
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);
|
19
|
-
|
20
|
-
// src/components/ErrorBoundary/ThrownErrorBoundary.tsx
|
21
|
-
var ThrownErrorBoundary_exports = {};
|
22
|
-
__export(ThrownErrorBoundary_exports, {
|
23
|
-
ThrownErrorBoundary: () => ThrownErrorBoundary
|
24
|
-
});
|
25
|
-
module.exports = __toCommonJS(ThrownErrorBoundary_exports);
|
26
|
-
var import_payload_model = require("@xyo-network/payload-model");
|
27
|
-
var import_react2 = require("react");
|
28
|
-
|
29
|
-
// src/components/ErrorRender/ErrorAlert.tsx
|
30
|
-
var import_icons_material = require("@mui/icons-material");
|
31
|
-
var import_material = require("@mui/material");
|
32
|
-
var import_react_button = require("@xylabs/react-button");
|
33
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
34
|
-
var ErrorAlert = ({ onCancel, error, errorContext, ...props }) => {
|
35
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_material.Alert, { severity: "error", ...props, children: [
|
36
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.AlertTitle, { children: "Whoops! Something went wrong" }),
|
37
|
-
errorContext ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.Typography, { variant: "caption", my: 0.5, lineHeight: "1", display: "block", children: errorContext }) : null,
|
38
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.Typography, { variant: "caption", mr: 0.5, fontWeight: "bold", children: "Error:" }),
|
39
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.Typography, { variant: "caption", children: error?.message }),
|
40
|
-
onCancel ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_button.ButtonEx, { variant: "outlined", size: "small", onClick: onCancel, position: "absolute", style: { right: 8, top: 8 }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons_material.ExitToApp, { fontSize: "small" }) }) : null
|
41
|
-
] });
|
42
|
-
};
|
43
|
-
|
44
|
-
// src/components/ErrorRender/Render.tsx
|
45
|
-
var import_react_flexbox = require("@xylabs/react-flexbox");
|
46
|
-
var import_react = require("react");
|
47
|
-
var import_react_router_dom = require("react-router-dom");
|
48
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
49
|
-
var ErrorRender = ({
|
50
|
-
onCancel,
|
51
|
-
error,
|
52
|
-
noErrorDisplay = false,
|
53
|
-
customError = null,
|
54
|
-
children,
|
55
|
-
errorContext,
|
56
|
-
...props
|
57
|
-
}) => {
|
58
|
-
const location = (0, import_react_router_dom.useLocation)();
|
59
|
-
(0, import_react.useEffect)(() => {
|
60
|
-
location.state = {
|
61
|
-
from: {
|
62
|
-
pathname: window.location.pathname
|
63
|
-
}
|
64
|
-
};
|
65
|
-
}, [location]);
|
66
|
-
if (error) {
|
67
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_flexbox.FlexCol, { alignItems: "stretch", ...props, children: noErrorDisplay ? customError : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_flexbox.FlexCol, { alignItems: "center", ...props, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ErrorAlert, { error, errorContext, onCancel }) }) });
|
68
|
-
} else {
|
69
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children }) ?? null;
|
70
|
-
}
|
71
|
-
};
|
72
|
-
|
73
|
-
// src/components/ErrorBoundary/ThrownErrorBoundary.tsx
|
74
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
75
|
-
var ThrownErrorBoundary = class _ThrownErrorBoundary extends import_react2.Component {
|
76
|
-
state = {
|
77
|
-
xyoError: void 0
|
78
|
-
};
|
79
|
-
static getDerivedStateFromError(error) {
|
80
|
-
return { hasError: true, xyoError: _ThrownErrorBoundary.normalizeError(error) };
|
81
|
-
}
|
82
|
-
static normalizeError(error) {
|
83
|
-
return error.schema === import_payload_model.ModuleErrorSchema ? error : { message: error.message, schema: import_payload_model.ModuleErrorSchema, sources: [] };
|
84
|
-
}
|
85
|
-
componentDidCatch(error, errorInfo) {
|
86
|
-
const { rethrow, rollbar } = this.props;
|
87
|
-
const { xyoError } = this.state;
|
88
|
-
rollbar?.error(error);
|
89
|
-
console.error("Error:", xyoError, errorInfo);
|
90
|
-
if (rethrow) {
|
91
|
-
throw error;
|
92
|
-
}
|
93
|
-
}
|
94
|
-
render() {
|
95
|
-
const { xyoError } = this.state;
|
96
|
-
const { children, boundaryName, errorComponent } = this.props;
|
97
|
-
if (xyoError) {
|
98
|
-
if (errorComponent) {
|
99
|
-
return errorComponent(xyoError);
|
100
|
-
}
|
101
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ErrorRender, { error: xyoError, errorContext: `${boundaryName} Boundary` });
|
102
|
-
}
|
103
|
-
return children;
|
104
|
-
}
|
105
|
-
};
|
106
|
-
//# sourceMappingURL=ThrownErrorBoundary.cjs.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/ErrorBoundary/ThrownErrorBoundary.tsx","../../../../src/components/ErrorRender/ErrorAlert.tsx","../../../../src/components/ErrorRender/Render.tsx"],"sourcesContent":["import { ModuleError, ModuleErrorSchema } from '@xyo-network/payload-model'\nimport { Component, ErrorInfo, ReactNode } from 'react'\nimport Rollbar from 'rollbar'\n\nimport { ErrorRender } from '../ErrorRender'\n\nexport interface ThrownErrorBoundaryProps {\n boundaryName?: string\n children: ReactNode\n errorComponent?: (e: ModuleError, boundaryName?: string) => ReactNode\n rethrow?: boolean\n rollbar?: Rollbar\n}\n\nexport interface ThrownErrorBoundaryState {\n xyoError?: ModuleError\n}\n\nexport class ThrownErrorBoundary extends Component<ThrownErrorBoundaryProps, ThrownErrorBoundaryState> {\n public override state: ThrownErrorBoundaryState = {\n xyoError: undefined,\n }\n\n static getDerivedStateFromError(error: Error) {\n return { hasError: true, xyoError: ThrownErrorBoundary.normalizeError(error) } as ThrownErrorBoundaryState\n }\n\n public static normalizeError(error: Error | ModuleError): ModuleError {\n return (\n (error as ModuleError).schema === ModuleErrorSchema ? error : { message: error.message, schema: ModuleErrorSchema, sources: [] }\n ) as ModuleError\n }\n\n public override componentDidCatch(error: Error, errorInfo: ErrorInfo) {\n const { rethrow, rollbar } = this.props\n const { xyoError } = this.state\n\n rollbar?.error(error)\n\n console.error('Error:', xyoError, errorInfo)\n if (rethrow) {\n throw error\n }\n }\n\n public override render() {\n const { xyoError } = this.state\n const { children, boundaryName, errorComponent } = this.props\n if (xyoError) {\n if (errorComponent) {\n return errorComponent(xyoError)\n }\n return <ErrorRender error={xyoError} errorContext={`${boundaryName} Boundary`} />\n }\n\n return children\n }\n}\n","import { ExitToApp as ExitIcon } from '@mui/icons-material'\nimport { Alert, AlertProps, AlertTitle, Typography } from '@mui/material'\nimport { ButtonEx } from '@xylabs/react-button'\nimport { ModuleError } from '@xyo-network/payload-model'\n\nexport interface ErrorAlertProps extends AlertProps {\n error?: ModuleError | Error\n errorContext?: string\n onCancel?: () => void\n}\n\nexport const ErrorAlert: React.FC<ErrorAlertProps> = ({ onCancel, error, errorContext, ...props }) => {\n return (\n <Alert severity=\"error\" {...props}>\n <AlertTitle>Whoops! Something went wrong</AlertTitle>\n {errorContext ? (\n <Typography variant=\"caption\" my={0.5} lineHeight=\"1\" display=\"block\">\n {errorContext}\n </Typography>\n ) : null}\n <Typography variant=\"caption\" mr={0.5} fontWeight=\"bold\">\n Error:\n </Typography>\n <Typography variant=\"caption\">{error?.message}</Typography>\n {onCancel ? (\n <ButtonEx variant=\"outlined\" size=\"small\" onClick={onCancel} position=\"absolute\" style={{ right: 8, top: 8 }}>\n <ExitIcon fontSize=\"small\" />\n </ButtonEx>\n ) : null}\n </Alert>\n )\n}\n","import { FlexCol } from '@xylabs/react-flexbox'\nimport { useEffect } from 'react'\nimport { useLocation } from 'react-router-dom'\n\nimport { ErrorAlert } from './ErrorAlert'\nimport { ErrorRenderProps } from './Props'\n\nexport const ErrorRender: React.FC<ErrorRenderProps> = ({\n onCancel,\n error,\n noErrorDisplay = false,\n customError = null,\n children,\n errorContext,\n ...props\n}) => {\n const location = useLocation()\n useEffect(() => {\n // ensure we end up at the same place we are now after logging in\n location.state = {\n from: {\n pathname: window.location.pathname,\n },\n }\n }, [location])\n\n if (error) {\n return (\n <FlexCol alignItems=\"stretch\" {...props}>\n {noErrorDisplay ? (\n customError\n ) : (\n <FlexCol alignItems=\"center\" {...props}>\n <ErrorAlert error={error} errorContext={errorContext} onCancel={onCancel} />\n </FlexCol>\n )}\n </FlexCol>\n )\n } else {\n return <>{children}</> ?? null\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2BAA+C;AAC/C,IAAAA,gBAAgD;;;ACDhD,4BAAsC;AACtC,sBAA0D;AAC1D,0BAAyB;AAWrB;AAFG,IAAM,aAAwC,CAAC,EAAE,UAAU,OAAO,cAAc,GAAG,MAAM,MAAM;AACpG,SACE,6CAAC,yBAAM,UAAS,SAAS,GAAG,OAC1B;AAAA,gDAAC,8BAAW,0CAA4B;AAAA,IACvC,eACC,4CAAC,8BAAW,SAAQ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OAAc,eAAe,OAAyC;AACpE,WACG,MAAsB,WAAW,yCAAoB,QAAQ,EAAE,SAAS,MAAM,SAAS,QAAQ,wCAAmB,SAAS,CAAC,EAAE;AAAA,EAEnI;AAAA,EAEgB,kBAAkB,OAAc,WAAsB;AACpE,UAAM,EAAE,SAAS,QAAQ,IAAI,KAAK;AAClC,UAAM,EAAE,SAAS,IAAI,KAAK;AAE1B,aAAS,MAAM,KAAK;AAEpB,YAAQ,MAAM,UAAU,UAAU,SAAS;AAC3C,QAAI,SAAS;AACX,YAAM;AAAA,IACR;AAAA,EACF;AAAA,EAEgB,SAAS;AACvB,UAAM,EAAE,SAAS,IAAI,KAAK;AAC1B,UAAM,EAAE,UAAU,cAAc,eAAe,IAAI,KAAK;AACxD,QAAI,UAAU;AACZ,UAAI,gBAAgB;AAClB,eAAO,eAAe,QAAQ;AAAA,MAChC;AACA,aAAO,6CAAC,eAAY,OAAO,UAAU,cAAc,GAAG,YAAY,aAAa;AAAA,IACjF;AAEA,WAAO;AAAA,EACT;AACF;","names":["import_react","ExitIcon","import_jsx_runtime","import_jsx_runtime"]}
|
@@ -1,85 +0,0 @@
|
|
1
|
-
// src/components/ErrorBoundary/ThrownErrorBoundary.tsx
|
2
|
-
import { ModuleErrorSchema } from "@xyo-network/payload-model";
|
3
|
-
import { Component } from "react";
|
4
|
-
|
5
|
-
// src/components/ErrorRender/ErrorAlert.tsx
|
6
|
-
import { ExitToApp as ExitIcon } from "@mui/icons-material";
|
7
|
-
import { Alert, AlertTitle, Typography } from "@mui/material";
|
8
|
-
import { ButtonEx } from "@xylabs/react-button";
|
9
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
10
|
-
var ErrorAlert = ({ onCancel, error, errorContext, ...props }) => {
|
11
|
-
return /* @__PURE__ */ jsxs(Alert, { severity: "error", ...props, children: [
|
12
|
-
/* @__PURE__ */ jsx(AlertTitle, { children: "Whoops! Something went wrong" }),
|
13
|
-
errorContext ? /* @__PURE__ */ jsx(Typography, { variant: "caption", my: 0.5, lineHeight: "1", display: "block", children: errorContext }) : null,
|
14
|
-
/* @__PURE__ */ jsx(Typography, { variant: "caption", mr: 0.5, fontWeight: "bold", children: "Error:" }),
|
15
|
-
/* @__PURE__ */ jsx(Typography, { variant: "caption", children: error?.message }),
|
16
|
-
onCancel ? /* @__PURE__ */ jsx(ButtonEx, { variant: "outlined", size: "small", onClick: onCancel, position: "absolute", style: { right: 8, top: 8 }, children: /* @__PURE__ */ jsx(ExitIcon, { fontSize: "small" }) }) : null
|
17
|
-
] });
|
18
|
-
};
|
19
|
-
|
20
|
-
// src/components/ErrorRender/Render.tsx
|
21
|
-
import { FlexCol } from "@xylabs/react-flexbox";
|
22
|
-
import { useEffect } from "react";
|
23
|
-
import { useLocation } from "react-router-dom";
|
24
|
-
import { Fragment, jsx as jsx2 } from "react/jsx-runtime";
|
25
|
-
var ErrorRender = ({
|
26
|
-
onCancel,
|
27
|
-
error,
|
28
|
-
noErrorDisplay = false,
|
29
|
-
customError = null,
|
30
|
-
children,
|
31
|
-
errorContext,
|
32
|
-
...props
|
33
|
-
}) => {
|
34
|
-
const location = useLocation();
|
35
|
-
useEffect(() => {
|
36
|
-
location.state = {
|
37
|
-
from: {
|
38
|
-
pathname: window.location.pathname
|
39
|
-
}
|
40
|
-
};
|
41
|
-
}, [location]);
|
42
|
-
if (error) {
|
43
|
-
return /* @__PURE__ */ jsx2(FlexCol, { alignItems: "stretch", ...props, children: noErrorDisplay ? customError : /* @__PURE__ */ jsx2(FlexCol, { alignItems: "center", ...props, children: /* @__PURE__ */ jsx2(ErrorAlert, { error, errorContext, onCancel }) }) });
|
44
|
-
} else {
|
45
|
-
return /* @__PURE__ */ jsx2(Fragment, { children }) ?? null;
|
46
|
-
}
|
47
|
-
};
|
48
|
-
|
49
|
-
// src/components/ErrorBoundary/ThrownErrorBoundary.tsx
|
50
|
-
import { jsx as jsx3 } from "react/jsx-runtime";
|
51
|
-
var ThrownErrorBoundary = class _ThrownErrorBoundary extends Component {
|
52
|
-
state = {
|
53
|
-
xyoError: void 0
|
54
|
-
};
|
55
|
-
static getDerivedStateFromError(error) {
|
56
|
-
return { hasError: true, xyoError: _ThrownErrorBoundary.normalizeError(error) };
|
57
|
-
}
|
58
|
-
static normalizeError(error) {
|
59
|
-
return error.schema === ModuleErrorSchema ? error : { message: error.message, schema: ModuleErrorSchema, sources: [] };
|
60
|
-
}
|
61
|
-
componentDidCatch(error, errorInfo) {
|
62
|
-
const { rethrow, rollbar } = this.props;
|
63
|
-
const { xyoError } = this.state;
|
64
|
-
rollbar?.error(error);
|
65
|
-
console.error("Error:", xyoError, errorInfo);
|
66
|
-
if (rethrow) {
|
67
|
-
throw error;
|
68
|
-
}
|
69
|
-
}
|
70
|
-
render() {
|
71
|
-
const { xyoError } = this.state;
|
72
|
-
const { children, boundaryName, errorComponent } = this.props;
|
73
|
-
if (xyoError) {
|
74
|
-
if (errorComponent) {
|
75
|
-
return errorComponent(xyoError);
|
76
|
-
}
|
77
|
-
return /* @__PURE__ */ jsx3(ErrorRender, { error: xyoError, errorContext: `${boundaryName} Boundary` });
|
78
|
-
}
|
79
|
-
return children;
|
80
|
-
}
|
81
|
-
};
|
82
|
-
export {
|
83
|
-
ThrownErrorBoundary
|
84
|
-
};
|
85
|
-
//# sourceMappingURL=ThrownErrorBoundary.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/ErrorBoundary/ThrownErrorBoundary.tsx","../../../../src/components/ErrorRender/ErrorAlert.tsx","../../../../src/components/ErrorRender/Render.tsx"],"sourcesContent":["import { ModuleError, ModuleErrorSchema } from '@xyo-network/payload-model'\nimport { Component, ErrorInfo, ReactNode } from 'react'\nimport Rollbar from 'rollbar'\n\nimport { ErrorRender } from '../ErrorRender'\n\nexport interface ThrownErrorBoundaryProps {\n boundaryName?: string\n children: ReactNode\n errorComponent?: (e: ModuleError, boundaryName?: string) => ReactNode\n rethrow?: boolean\n rollbar?: Rollbar\n}\n\nexport interface ThrownErrorBoundaryState {\n xyoError?: ModuleError\n}\n\nexport class ThrownErrorBoundary extends Component<ThrownErrorBoundaryProps, ThrownErrorBoundaryState> {\n public override state: ThrownErrorBoundaryState = {\n xyoError: undefined,\n }\n\n static getDerivedStateFromError(error: Error) {\n return { hasError: true, xyoError: ThrownErrorBoundary.normalizeError(error) } as ThrownErrorBoundaryState\n }\n\n public static normalizeError(error: Error | ModuleError): ModuleError {\n return (\n (error as ModuleError).schema === ModuleErrorSchema ? error : { message: error.message, schema: ModuleErrorSchema, sources: [] }\n ) as ModuleError\n }\n\n public override componentDidCatch(error: Error, errorInfo: ErrorInfo) {\n const { rethrow, rollbar } = this.props\n const { xyoError } = this.state\n\n rollbar?.error(error)\n\n console.error('Error:', xyoError, errorInfo)\n if (rethrow) {\n throw error\n }\n }\n\n public override render() {\n const { xyoError } = this.state\n const { children, boundaryName, errorComponent } = this.props\n if (xyoError) {\n if (errorComponent) {\n return errorComponent(xyoError)\n }\n return <ErrorRender error={xyoError} errorContext={`${boundaryName} Boundary`} />\n }\n\n return children\n }\n}\n","import { ExitToApp as ExitIcon } from '@mui/icons-material'\nimport { Alert, AlertProps, AlertTitle, Typography } from '@mui/material'\nimport { ButtonEx } from '@xylabs/react-button'\nimport { ModuleError } from '@xyo-network/payload-model'\n\nexport interface ErrorAlertProps extends AlertProps {\n error?: ModuleError | Error\n errorContext?: string\n onCancel?: () => void\n}\n\nexport const ErrorAlert: React.FC<ErrorAlertProps> = ({ onCancel, error, errorContext, ...props }) => {\n return (\n <Alert severity=\"error\" {...props}>\n <AlertTitle>Whoops! Something went wrong</AlertTitle>\n {errorContext ? (\n <Typography variant=\"caption\" my={0.5} lineHeight=\"1\" display=\"block\">\n {errorContext}\n </Typography>\n ) : null}\n <Typography variant=\"caption\" mr={0.5} fontWeight=\"bold\">\n Error:\n </Typography>\n <Typography variant=\"caption\">{error?.message}</Typography>\n {onCancel ? (\n <ButtonEx variant=\"outlined\" size=\"small\" onClick={onCancel} position=\"absolute\" style={{ right: 8, top: 8 }}>\n <ExitIcon fontSize=\"small\" />\n </ButtonEx>\n ) : null}\n </Alert>\n )\n}\n","import { FlexCol } from '@xylabs/react-flexbox'\nimport { useEffect } from 'react'\nimport { useLocation } from 'react-router-dom'\n\nimport { ErrorAlert } from './ErrorAlert'\nimport { ErrorRenderProps } from './Props'\n\nexport const ErrorRender: React.FC<ErrorRenderProps> = ({\n onCancel,\n error,\n noErrorDisplay = false,\n customError = null,\n children,\n errorContext,\n ...props\n}) => {\n const location = useLocation()\n useEffect(() => {\n // ensure we end up at the same place we are now after logging in\n location.state = {\n from: {\n pathname: window.location.pathname,\n },\n }\n }, [location])\n\n if (error) {\n return (\n <FlexCol alignItems=\"stretch\" {...props}>\n {noErrorDisplay ? (\n customError\n ) : (\n <FlexCol alignItems=\"center\" {...props}>\n <ErrorAlert error={error} errorContext={errorContext} onCancel={onCancel} />\n </FlexCol>\n )}\n </FlexCol>\n )\n } else {\n return <>{children}</> ?? null\n }\n}\n"],"mappings":";AAAA,SAAsB,yBAAyB;AAC/C,SAAS,iBAAuC;;;ACDhD,SAAS,aAAa,gBAAgB;AACtC,SAAS,OAAmB,YAAY,kBAAkB;AAC1D,SAAS,gBAAgB;AAWrB,SACE,KADF;AAFG,IAAM,aAAwC,CAAC,EAAE,UAAU,OAAO,cAAc,GAAG,MAAM,MAAM;AACpG,SACE,qBAAC,SAAM,UAAS,SAAS,GAAG,OAC1B;AAAA,wBAAC,cAAW,0CAA4B;AAAA,IACvC,eACC,oBAAC,cAAW,SAAQ,WAAU,IAAI,KAAK,YAAW,KAAI,SAAQ,SAC3D,wBACH,IACE;AAAA,IACJ,oBAAC,cAAW,SAAQ,WAAU,IAAI,KAAK,YAAW,QAAO,oBAEzD;AAAA,IACA,oBAAC,cAAW,SAAQ,WAAW,iBAAO,SAAQ;AAAA,IAC7C,WACC,oBAAC,YAAS,SAAQ,YAAW,MAAK,SAAQ,SAAS,UAAU,UAAS,YAAW,OAAO,EAAE,OAAO,GAAG,KA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AAS,MAAM,KAAK;AAEpB,YAAQ,MAAM,UAAU,UAAU,SAAS;AAC3C,QAAI,SAAS;AACX,YAAM;AAAA,IACR;AAAA,EACF;AAAA,EAEgB,SAAS;AACvB,UAAM,EAAE,SAAS,IAAI,KAAK;AAC1B,UAAM,EAAE,UAAU,cAAc,eAAe,IAAI,KAAK;AACxD,QAAI,UAAU;AACZ,UAAI,gBAAgB;AAClB,eAAO,eAAe,QAAQ;AAAA,MAChC;AACA,aAAO,gBAAAA,KAAC,eAAY,OAAO,UAAU,cAAc,GAAG,YAAY,aAAa;AAAA,IACjF;AAEA,WAAO;AAAA,EACT;AACF;","names":["jsx","jsx"]}
|
@@ -1,108 +0,0 @@
|
|
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);
|
19
|
-
|
20
|
-
// src/components/ErrorBoundary/index.ts
|
21
|
-
var ErrorBoundary_exports = {};
|
22
|
-
__export(ErrorBoundary_exports, {
|
23
|
-
ThrownErrorBoundary: () => ThrownErrorBoundary
|
24
|
-
});
|
25
|
-
module.exports = __toCommonJS(ErrorBoundary_exports);
|
26
|
-
|
27
|
-
// src/components/ErrorBoundary/ThrownErrorBoundary.tsx
|
28
|
-
var import_payload_model = require("@xyo-network/payload-model");
|
29
|
-
var import_react2 = require("react");
|
30
|
-
|
31
|
-
// src/components/ErrorRender/ErrorAlert.tsx
|
32
|
-
var import_icons_material = require("@mui/icons-material");
|
33
|
-
var import_material = require("@mui/material");
|
34
|
-
var import_react_button = require("@xylabs/react-button");
|
35
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
36
|
-
var ErrorAlert = ({ onCancel, error, errorContext, ...props }) => {
|
37
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_material.Alert, { severity: "error", ...props, children: [
|
38
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.AlertTitle, { children: "Whoops! Something went wrong" }),
|
39
|
-
errorContext ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.Typography, { variant: "caption", my: 0.5, lineHeight: "1", display: "block", children: errorContext }) : null,
|
40
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.Typography, { variant: "caption", mr: 0.5, fontWeight: "bold", children: "Error:" }),
|
41
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.Typography, { variant: "caption", children: error?.message }),
|
42
|
-
onCancel ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_button.ButtonEx, { variant: "outlined", size: "small", onClick: onCancel, position: "absolute", style: { right: 8, top: 8 }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons_material.ExitToApp, { fontSize: "small" }) }) : null
|
43
|
-
] });
|
44
|
-
};
|
45
|
-
|
46
|
-
// src/components/ErrorRender/Render.tsx
|
47
|
-
var import_react_flexbox = require("@xylabs/react-flexbox");
|
48
|
-
var import_react = require("react");
|
49
|
-
var import_react_router_dom = require("react-router-dom");
|
50
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
51
|
-
var ErrorRender = ({
|
52
|
-
onCancel,
|
53
|
-
error,
|
54
|
-
noErrorDisplay = false,
|
55
|
-
customError = null,
|
56
|
-
children,
|
57
|
-
errorContext,
|
58
|
-
...props
|
59
|
-
}) => {
|
60
|
-
const location = (0, import_react_router_dom.useLocation)();
|
61
|
-
(0, import_react.useEffect)(() => {
|
62
|
-
location.state = {
|
63
|
-
from: {
|
64
|
-
pathname: window.location.pathname
|
65
|
-
}
|
66
|
-
};
|
67
|
-
}, [location]);
|
68
|
-
if (error) {
|
69
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_flexbox.FlexCol, { alignItems: "stretch", ...props, children: noErrorDisplay ? customError : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_flexbox.FlexCol, { alignItems: "center", ...props, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ErrorAlert, { error, errorContext, onCancel }) }) });
|
70
|
-
} else {
|
71
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children }) ?? null;
|
72
|
-
}
|
73
|
-
};
|
74
|
-
|
75
|
-
// src/components/ErrorBoundary/ThrownErrorBoundary.tsx
|
76
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
77
|
-
var ThrownErrorBoundary = class _ThrownErrorBoundary extends import_react2.Component {
|
78
|
-
state = {
|
79
|
-
xyoError: void 0
|
80
|
-
};
|
81
|
-
static getDerivedStateFromError(error) {
|
82
|
-
return { hasError: true, xyoError: _ThrownErrorBoundary.normalizeError(error) };
|
83
|
-
}
|
84
|
-
static normalizeError(error) {
|
85
|
-
return error.schema === import_payload_model.ModuleErrorSchema ? error : { message: error.message, schema: import_payload_model.ModuleErrorSchema, sources: [] };
|
86
|
-
}
|
87
|
-
componentDidCatch(error, errorInfo) {
|
88
|
-
const { rethrow, rollbar } = this.props;
|
89
|
-
const { xyoError } = this.state;
|
90
|
-
rollbar?.error(error);
|
91
|
-
console.error("Error:", xyoError, errorInfo);
|
92
|
-
if (rethrow) {
|
93
|
-
throw error;
|
94
|
-
}
|
95
|
-
}
|
96
|
-
render() {
|
97
|
-
const { xyoError } = this.state;
|
98
|
-
const { children, boundaryName, errorComponent } = this.props;
|
99
|
-
if (xyoError) {
|
100
|
-
if (errorComponent) {
|
101
|
-
return errorComponent(xyoError);
|
102
|
-
}
|
103
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ErrorRender, { error: xyoError, errorContext: `${boundaryName} Boundary` });
|
104
|
-
}
|
105
|
-
return children;
|
106
|
-
}
|
107
|
-
};
|
108
|
-
//# sourceMappingURL=index.cjs.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/ErrorBoundary/index.ts","../../../../src/components/ErrorBoundary/ThrownErrorBoundary.tsx","../../../../src/components/ErrorRender/ErrorAlert.tsx","../../../../src/components/ErrorRender/Render.tsx"],"sourcesContent":["export * from './ThrownErrorBoundary'\n","import { ModuleError, ModuleErrorSchema } from '@xyo-network/payload-model'\nimport { Component, ErrorInfo, ReactNode } from 'react'\nimport Rollbar from 'rollbar'\n\nimport { ErrorRender } from '../ErrorRender'\n\nexport interface ThrownErrorBoundaryProps {\n boundaryName?: string\n children: ReactNode\n errorComponent?: (e: ModuleError, boundaryName?: string) => ReactNode\n rethrow?: boolean\n rollbar?: Rollbar\n}\n\nexport interface ThrownErrorBoundaryState {\n xyoError?: ModuleError\n}\n\nexport class ThrownErrorBoundary extends Component<ThrownErrorBoundaryProps, ThrownErrorBoundaryState> {\n public override state: ThrownErrorBoundaryState = {\n xyoError: undefined,\n }\n\n static getDerivedStateFromError(error: Error) {\n return { hasError: true, xyoError: ThrownErrorBoundary.normalizeError(error) } as ThrownErrorBoundaryState\n }\n\n public static normalizeError(error: Error | ModuleError): ModuleError {\n return (\n (error as ModuleError).schema === ModuleErrorSchema ? error : { message: error.message, schema: ModuleErrorSchema, sources: [] }\n ) as ModuleError\n }\n\n public override componentDidCatch(error: Error, errorInfo: ErrorInfo) {\n const { rethrow, rollbar } = this.props\n const { xyoError } = this.state\n\n rollbar?.error(error)\n\n console.error('Error:', xyoError, errorInfo)\n if (rethrow) {\n throw error\n }\n }\n\n public override render() {\n const { xyoError } = this.state\n const { children, boundaryName, errorComponent } = this.props\n if (xyoError) {\n if (errorComponent) {\n return errorComponent(xyoError)\n }\n return <ErrorRender error={xyoError} errorContext={`${boundaryName} Boundary`} />\n }\n\n return children\n }\n}\n","import { ExitToApp as ExitIcon } from '@mui/icons-material'\nimport { Alert, AlertProps, AlertTitle, Typography } from '@mui/material'\nimport { ButtonEx } from '@xylabs/react-button'\nimport { ModuleError } from '@xyo-network/payload-model'\n\nexport interface ErrorAlertProps extends AlertProps {\n error?: ModuleError | Error\n errorContext?: string\n onCancel?: () => void\n}\n\nexport const ErrorAlert: React.FC<ErrorAlertProps> = ({ onCancel, error, errorContext, ...props }) => {\n return (\n <Alert severity=\"error\" {...props}>\n <AlertTitle>Whoops! Something went wrong</AlertTitle>\n {errorContext ? (\n <Typography variant=\"caption\" my={0.5} lineHeight=\"1\" display=\"block\">\n {errorContext}\n </Typography>\n ) : null}\n <Typography variant=\"caption\" mr={0.5} fontWeight=\"bold\">\n Error:\n </Typography>\n <Typography variant=\"caption\">{error?.message}</Typography>\n {onCancel ? (\n <ButtonEx variant=\"outlined\" size=\"small\" onClick={onCancel} position=\"absolute\" style={{ right: 8, top: 8 }}>\n <ExitIcon fontSize=\"small\" />\n </ButtonEx>\n ) : null}\n </Alert>\n )\n}\n","import { FlexCol } from '@xylabs/react-flexbox'\nimport { useEffect } from 'react'\nimport { useLocation } from 'react-router-dom'\n\nimport { ErrorAlert } from './ErrorAlert'\nimport { ErrorRenderProps } from './Props'\n\nexport const ErrorRender: React.FC<ErrorRenderProps> = ({\n onCancel,\n error,\n noErrorDisplay = false,\n customError = null,\n children,\n errorContext,\n ...props\n}) => {\n const location = useLocation()\n useEffect(() => {\n // ensure we end up at the same place we are now after logging in\n location.state = {\n from: {\n pathname: window.location.pathname,\n },\n }\n }, [location])\n\n if (error) {\n return (\n <FlexCol alignItems=\"stretch\" {...props}>\n {noErrorDisplay ? (\n customError\n ) : (\n <FlexCol alignItems=\"center\" {...props}>\n <ErrorAlert error={error} errorContext={errorContext} onCancel={onCancel} />\n </FlexCol>\n )}\n </FlexCol>\n )\n } else {\n return <>{children}</> ?? null\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,2BAA+C;AAC/C,IAAAA,gBAAgD;;;ACDhD,4BAAsC;AACtC,sBAA0D;AAC1D,0BAAyB;AAWrB;AAFG,IAAM,aAAwC,CAAC,EAAE,UAAU,OAAO,cAAc,GAAG,MAAM,MAAM;AACpG,SACE,6CAAC,yBAAM,UAAS,SAAS,GAAG,OAC1B;AAAA,gDAAC,8BAAW,0CAA4B;AAAA,IACvC,eACC,4CAAC,8BAAW,SAAQ,WAAU,IAAI,KAAK,YAAW,KAAI,SAAQ,SAC3D,wBACH,IACE;AAAA,IACJ,4CAAC,8BAAW,SAAQ,WAAU,IAAI,KAAK,YAAW,QAAO,oBAEzD;AAAA,IACA,4CAAC,8BAAW,SAAQ,WAAW,iBAAO,SAAQ;AAAA,IAC7C,WACC,4CAAC,gCAAS,SAAQ,YAAW,MAAK,SAAQ,SAAS,UAAU,UAAS,YAAW,OAAO,EAAE,OAAO,GAAG,KAAK,EAAE,GACzG,sDAAC,sBAAAC,WAAA,EAAS,UAAS,SAAQ,GAC7B,IACE;AAAA,KACN;AAEJ;;;AC/BA,2BAAwB;AACxB,mBAA0B;AAC1B,8BAA4B;AA+BhB,IAAAC,sBAAA;AA1BL,IAAM,cAA0C,CAAC;AAAA,EACtD;AAAA,EACA;AAAA,EACA,iBAAiB;AAAA,EACjB,cAAc;AAAA,EACd;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACJ,QAAM,eAAW,qCAAY;AAC7B,8BAAU,MAAM;AAEd,aAAS,QAAQ;AAAA,MACf,MAAM;AAAA,QACJ,UAAU,OAAO,SAAS;AAAA,MAC5B;AA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
|
-
// src/components/ErrorBoundary/ThrownErrorBoundary.tsx
|
2
|
-
import { ModuleErrorSchema } from "@xyo-network/payload-model";
|
3
|
-
import { Component } from "react";
|
4
|
-
|
5
|
-
// src/components/ErrorRender/ErrorAlert.tsx
|
6
|
-
import { ExitToApp as ExitIcon } from "@mui/icons-material";
|
7
|
-
import { Alert, AlertTitle, Typography } from "@mui/material";
|
8
|
-
import { ButtonEx } from "@xylabs/react-button";
|
9
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
10
|
-
var ErrorAlert = ({ onCancel, error, errorContext, ...props }) => {
|
11
|
-
return /* @__PURE__ */ jsxs(Alert, { severity: "error", ...props, children: [
|
12
|
-
/* @__PURE__ */ jsx(AlertTitle, { children: "Whoops! Something went wrong" }),
|
13
|
-
errorContext ? /* @__PURE__ */ jsx(Typography, { variant: "caption", my: 0.5, lineHeight: "1", display: "block", children: errorContext }) : null,
|
14
|
-
/* @__PURE__ */ jsx(Typography, { variant: "caption", mr: 0.5, fontWeight: "bold", children: "Error:" }),
|
15
|
-
/* @__PURE__ */ jsx(Typography, { variant: "caption", children: error?.message }),
|
16
|
-
onCancel ? /* @__PURE__ */ jsx(ButtonEx, { variant: "outlined", size: "small", onClick: onCancel, position: "absolute", style: { right: 8, top: 8 }, children: /* @__PURE__ */ jsx(ExitIcon, { fontSize: "small" }) }) : null
|
17
|
-
] });
|
18
|
-
};
|
19
|
-
|
20
|
-
// src/components/ErrorRender/Render.tsx
|
21
|
-
import { FlexCol } from "@xylabs/react-flexbox";
|
22
|
-
import { useEffect } from "react";
|
23
|
-
import { useLocation } from "react-router-dom";
|
24
|
-
import { Fragment, jsx as jsx2 } from "react/jsx-runtime";
|
25
|
-
var ErrorRender = ({
|
26
|
-
onCancel,
|
27
|
-
error,
|
28
|
-
noErrorDisplay = false,
|
29
|
-
customError = null,
|
30
|
-
children,
|
31
|
-
errorContext,
|
32
|
-
...props
|
33
|
-
}) => {
|
34
|
-
const location = useLocation();
|
35
|
-
useEffect(() => {
|
36
|
-
location.state = {
|
37
|
-
from: {
|
38
|
-
pathname: window.location.pathname
|
39
|
-
}
|
40
|
-
};
|
41
|
-
}, [location]);
|
42
|
-
if (error) {
|
43
|
-
return /* @__PURE__ */ jsx2(FlexCol, { alignItems: "stretch", ...props, children: noErrorDisplay ? customError : /* @__PURE__ */ jsx2(FlexCol, { alignItems: "center", ...props, children: /* @__PURE__ */ jsx2(ErrorAlert, { error, errorContext, onCancel }) }) });
|
44
|
-
} else {
|
45
|
-
return /* @__PURE__ */ jsx2(Fragment, { children }) ?? null;
|
46
|
-
}
|
47
|
-
};
|
48
|
-
|
49
|
-
// src/components/ErrorBoundary/ThrownErrorBoundary.tsx
|
50
|
-
import { jsx as jsx3 } from "react/jsx-runtime";
|
51
|
-
var ThrownErrorBoundary = class _ThrownErrorBoundary extends Component {
|
52
|
-
state = {
|
53
|
-
xyoError: void 0
|
54
|
-
};
|
55
|
-
static getDerivedStateFromError(error) {
|
56
|
-
return { hasError: true, xyoError: _ThrownErrorBoundary.normalizeError(error) };
|
57
|
-
}
|
58
|
-
static normalizeError(error) {
|
59
|
-
return error.schema === ModuleErrorSchema ? error : { message: error.message, schema: ModuleErrorSchema, sources: [] };
|
60
|
-
}
|
61
|
-
componentDidCatch(error, errorInfo) {
|
62
|
-
const { rethrow, rollbar } = this.props;
|
63
|
-
const { xyoError } = this.state;
|
64
|
-
rollbar?.error(error);
|
65
|
-
console.error("Error:", xyoError, errorInfo);
|
66
|
-
if (rethrow) {
|
67
|
-
throw error;
|
68
|
-
}
|
69
|
-
}
|
70
|
-
render() {
|
71
|
-
const { xyoError } = this.state;
|
72
|
-
const { children, boundaryName, errorComponent } = this.props;
|
73
|
-
if (xyoError) {
|
74
|
-
if (errorComponent) {
|
75
|
-
return errorComponent(xyoError);
|
76
|
-
}
|
77
|
-
return /* @__PURE__ */ jsx3(ErrorRender, { error: xyoError, errorContext: `${boundaryName} Boundary` });
|
78
|
-
}
|
79
|
-
return children;
|
80
|
-
}
|
81
|
-
};
|
82
|
-
export {
|
83
|
-
ThrownErrorBoundary
|
84
|
-
};
|
85
|
-
//# sourceMappingURL=index.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/ErrorBoundary/ThrownErrorBoundary.tsx","../../../../src/components/ErrorRender/ErrorAlert.tsx","../../../../src/components/ErrorRender/Render.tsx"],"sourcesContent":["import { ModuleError, ModuleErrorSchema } from '@xyo-network/payload-model'\nimport { Component, ErrorInfo, ReactNode } from 'react'\nimport Rollbar from 'rollbar'\n\nimport { ErrorRender } from '../ErrorRender'\n\nexport interface ThrownErrorBoundaryProps {\n boundaryName?: string\n children: ReactNode\n errorComponent?: (e: ModuleError, boundaryName?: string) => ReactNode\n rethrow?: boolean\n rollbar?: Rollbar\n}\n\nexport interface ThrownErrorBoundaryState {\n xyoError?: ModuleError\n}\n\nexport class ThrownErrorBoundary extends Component<ThrownErrorBoundaryProps, ThrownErrorBoundaryState> {\n public override state: ThrownErrorBoundaryState = {\n xyoError: undefined,\n }\n\n static getDerivedStateFromError(error: Error) {\n return { hasError: true, xyoError: ThrownErrorBoundary.normalizeError(error) } as ThrownErrorBoundaryState\n }\n\n public static normalizeError(error: Error | ModuleError): ModuleError {\n return (\n (error as ModuleError).schema === ModuleErrorSchema ? error : { message: error.message, schema: ModuleErrorSchema, sources: [] }\n ) as ModuleError\n }\n\n public override componentDidCatch(error: Error, errorInfo: ErrorInfo) {\n const { rethrow, rollbar } = this.props\n const { xyoError } = this.state\n\n rollbar?.error(error)\n\n console.error('Error:', xyoError, errorInfo)\n if (rethrow) {\n throw error\n }\n }\n\n public override render() {\n const { xyoError } = this.state\n const { children, boundaryName, errorComponent } = this.props\n if (xyoError) {\n if (errorComponent) {\n return errorComponent(xyoError)\n }\n return <ErrorRender error={xyoError} errorContext={`${boundaryName} Boundary`} />\n }\n\n return children\n }\n}\n","import { ExitToApp as ExitIcon } from '@mui/icons-material'\nimport { Alert, AlertProps, AlertTitle, Typography } from '@mui/material'\nimport { ButtonEx } from '@xylabs/react-button'\nimport { ModuleError } from '@xyo-network/payload-model'\n\nexport interface ErrorAlertProps extends AlertProps {\n error?: ModuleError | Error\n errorContext?: string\n onCancel?: () => void\n}\n\nexport const ErrorAlert: React.FC<ErrorAlertProps> = ({ onCancel, error, errorContext, ...props }) => {\n return (\n <Alert severity=\"error\" {...props}>\n <AlertTitle>Whoops! Something went wrong</AlertTitle>\n {errorContext ? (\n <Typography variant=\"caption\" my={0.5} lineHeight=\"1\" display=\"block\">\n {errorContext}\n </Typography>\n ) : null}\n <Typography variant=\"caption\" mr={0.5} fontWeight=\"bold\">\n Error:\n </Typography>\n <Typography variant=\"caption\">{error?.message}</Typography>\n {onCancel ? (\n <ButtonEx variant=\"outlined\" size=\"small\" onClick={onCancel} position=\"absolute\" style={{ right: 8, top: 8 }}>\n <ExitIcon fontSize=\"small\" />\n </ButtonEx>\n ) : null}\n </Alert>\n )\n}\n","import { FlexCol } from '@xylabs/react-flexbox'\nimport { useEffect } from 'react'\nimport { useLocation } from 'react-router-dom'\n\nimport { ErrorAlert } from './ErrorAlert'\nimport { ErrorRenderProps } from './Props'\n\nexport const ErrorRender: React.FC<ErrorRenderProps> = ({\n onCancel,\n error,\n noErrorDisplay = false,\n customError = null,\n children,\n errorContext,\n ...props\n}) => {\n const location = useLocation()\n useEffect(() => {\n // ensure we end up at the same place we are now after logging in\n location.state = {\n from: {\n pathname: window.location.pathname,\n },\n }\n }, [location])\n\n if (error) {\n return (\n <FlexCol alignItems=\"stretch\" {...props}>\n {noErrorDisplay ? (\n customError\n ) : (\n <FlexCol alignItems=\"center\" {...props}>\n <ErrorAlert error={error} errorContext={errorContext} onCancel={onCancel} />\n </FlexCol>\n )}\n </FlexCol>\n )\n } else {\n return <>{children}</> ?? null\n }\n}\n"],"mappings":";AAAA,SAAsB,yBAAyB;AAC/C,SAAS,iBAAuC;;;ACDhD,SAAS,aAAa,gBAAgB;AACtC,SAAS,OAAmB,YAAY,kBAAkB;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AAAA,EAC5B;AACF;;;AFWa,gBAAAC,YAAA;AAlCN,IAAM,sBAAN,MAAM,6BAA4B,UAA8D;AAAA,EACrF,QAAkC;AAAA,IAChD,UAAU;AAAA,EACZ;AAAA,EAEA,OAAO,yBAAyB,OAAc;AAC5C,WAAO,EAAE,UAAU,MAAM,UAAU,qBAAoB,eAAe,KAAK,EAAE;AAAA,EAC/E;AAAA,EAEA,OAAc,eAAe,OAAyC;AACpE,WACG,MAAsB,WAAW,oBAAoB,QAAQ,EAAE,SAAS,MAAM,SAAS,QAAQ,mBAAmB,SAAS,CAAC,EAAE;AAAA,EAEnI;AAAA,EAEgB,kBAAkB,OAAc,WAAsB;AACpE,UAAM,EAAE,SAAS,QAAQ,IAAI,KAAK;AAClC,UAAM,EAAE,SAAS,IAAI,KAAK;AAE1B,aAAS,MAAM,KAAK;AAEpB,YAAQ,MAAM,UAAU,UAAU,SAAS;AAC3C,QAAI,SAAS;AACX,YAAM;AAAA,IACR;AAAA,EACF;AAAA,EAEgB,SAAS;AACvB,UAAM,EAAE,SAAS,IAAI,KAAK;AAC1B,UAAM,EAAE,UAAU,cAAc,eAAe,IAAI,KAAK;AACxD,QAAI,UAAU;AACZ,UAAI,gBAAgB;AAClB,eAAO,eAAe,QAAQ;AAAA,MAChC;AACA,aAAO,gBAAAA,KAAC,eAAY,OAAO,UAAU,cAAc,GAAG,YAAY,aAAa;AAAA,IACjF;AAEA,WAAO;AAAA,EACT;AACF;","names":["jsx","jsx"]}
|
@@ -1,39 +0,0 @@
|
|
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);
|
19
|
-
|
20
|
-
// src/components/ErrorRender/ErrorAlert.tsx
|
21
|
-
var ErrorAlert_exports = {};
|
22
|
-
__export(ErrorAlert_exports, {
|
23
|
-
ErrorAlert: () => ErrorAlert
|
24
|
-
});
|
25
|
-
module.exports = __toCommonJS(ErrorAlert_exports);
|
26
|
-
var import_icons_material = require("@mui/icons-material");
|
27
|
-
var import_material = require("@mui/material");
|
28
|
-
var import_react_button = require("@xylabs/react-button");
|
29
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
30
|
-
var ErrorAlert = ({ onCancel, error, errorContext, ...props }) => {
|
31
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_material.Alert, { severity: "error", ...props, children: [
|
32
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.AlertTitle, { children: "Whoops! Something went wrong" }),
|
33
|
-
errorContext ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.Typography, { variant: "caption", my: 0.5, lineHeight: "1", display: "block", children: errorContext }) : null,
|
34
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.Typography, { variant: "caption", mr: 0.5, fontWeight: "bold", children: "Error:" }),
|
35
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.Typography, { variant: "caption", children: error?.message }),
|
36
|
-
onCancel ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_button.ButtonEx, { variant: "outlined", size: "small", onClick: onCancel, position: "absolute", style: { right: 8, top: 8 }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons_material.ExitToApp, { fontSize: "small" }) }) : null
|
37
|
-
] });
|
38
|
-
};
|
39
|
-
//# sourceMappingURL=ErrorAlert.cjs.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/ErrorRender/ErrorAlert.tsx"],"sourcesContent":["import { ExitToApp as ExitIcon } from '@mui/icons-material'\nimport { Alert, AlertProps, AlertTitle, Typography } from '@mui/material'\nimport { ButtonEx } from '@xylabs/react-button'\nimport { ModuleError } from '@xyo-network/payload-model'\n\nexport interface ErrorAlertProps extends AlertProps {\n error?: ModuleError | Error\n errorContext?: string\n onCancel?: () => void\n}\n\nexport const ErrorAlert: React.FC<ErrorAlertProps> = ({ onCancel, error, errorContext, ...props }) => {\n return (\n <Alert severity=\"error\" {...props}>\n <AlertTitle>Whoops! Something went wrong</AlertTitle>\n {errorContext ? (\n <Typography variant=\"caption\" my={0.5} lineHeight=\"1\" display=\"block\">\n {errorContext}\n </Typography>\n ) : null}\n <Typography variant=\"caption\" mr={0.5} fontWeight=\"bold\">\n Error:\n </Typography>\n <Typography variant=\"caption\">{error?.message}</Typography>\n {onCancel ? (\n <ButtonEx variant=\"outlined\" size=\"small\" onClick={onCancel} position=\"absolute\" style={{ right: 8, top: 8 }}>\n <ExitIcon fontSize=\"small\" />\n </ButtonEx>\n ) : null}\n </Alert>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAAsC;AACtC,sBAA0D;AAC1D,0BAAyB;AAWrB;AAFG,IAAM,aAAwC,CAAC,EAAE,UAAU,OAAO,cAAc,GAAG,MAAM,MAAM;AACpG,SACE,6CAAC,yBAAM,UAAS,SAAS,GAAG,OAC1B;AAAA,gDAAC,8BAAW,0CAA4B;AAAA,IACvC,eACC,4CAAC,8BAAW,SAAQ,WAAU,IAAI,KAAK,YAAW,KAAI,SAAQ,SAC3D,wBACH,IACE;AAAA,IACJ,4CAAC,8BAAW,SAAQ,WAAU,IAAI,KAAK,YAAW,QAAO,oBAEzD;AAAA,IACA,4CAAC,8BAAW,SAAQ,WAAW,iBAAO,SAAQ;AAAA,IAC7C,WACC,4CAAC,gCAAS,SAAQ,YAAW,MAAK,SAAQ,SAAS,UAAU,UAAS,YAAW,OAAO,EAAE,OAAO,GAAG,KAAK,EAAE,GACzG,sDAAC,sBAAAA,WAAA,EAAS,UAAS,SAAQ,GAC7B,IACE;AAAA,KACN;AAEJ;","names":["ExitIcon"]}
|
@@ -1,18 +0,0 @@
|
|
1
|
-
// src/components/ErrorRender/ErrorAlert.tsx
|
2
|
-
import { ExitToApp as ExitIcon } from "@mui/icons-material";
|
3
|
-
import { Alert, AlertTitle, Typography } from "@mui/material";
|
4
|
-
import { ButtonEx } from "@xylabs/react-button";
|
5
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
6
|
-
var ErrorAlert = ({ onCancel, error, errorContext, ...props }) => {
|
7
|
-
return /* @__PURE__ */ jsxs(Alert, { severity: "error", ...props, children: [
|
8
|
-
/* @__PURE__ */ jsx(AlertTitle, { children: "Whoops! Something went wrong" }),
|
9
|
-
errorContext ? /* @__PURE__ */ jsx(Typography, { variant: "caption", my: 0.5, lineHeight: "1", display: "block", children: errorContext }) : null,
|
10
|
-
/* @__PURE__ */ jsx(Typography, { variant: "caption", mr: 0.5, fontWeight: "bold", children: "Error:" }),
|
11
|
-
/* @__PURE__ */ jsx(Typography, { variant: "caption", children: error?.message }),
|
12
|
-
onCancel ? /* @__PURE__ */ jsx(ButtonEx, { variant: "outlined", size: "small", onClick: onCancel, position: "absolute", style: { right: 8, top: 8 }, children: /* @__PURE__ */ jsx(ExitIcon, { fontSize: "small" }) }) : null
|
13
|
-
] });
|
14
|
-
};
|
15
|
-
export {
|
16
|
-
ErrorAlert
|
17
|
-
};
|
18
|
-
//# sourceMappingURL=ErrorAlert.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/ErrorRender/ErrorAlert.tsx"],"sourcesContent":["import { ExitToApp as ExitIcon } from '@mui/icons-material'\nimport { Alert, AlertProps, AlertTitle, Typography } from '@mui/material'\nimport { ButtonEx } from '@xylabs/react-button'\nimport { ModuleError } from '@xyo-network/payload-model'\n\nexport interface ErrorAlertProps extends AlertProps {\n error?: ModuleError | Error\n errorContext?: string\n onCancel?: () => void\n}\n\nexport const ErrorAlert: React.FC<ErrorAlertProps> = ({ onCancel, error, errorContext, ...props }) => {\n return (\n <Alert severity=\"error\" {...props}>\n <AlertTitle>Whoops! Something went wrong</AlertTitle>\n {errorContext ? (\n <Typography variant=\"caption\" my={0.5} lineHeight=\"1\" display=\"block\">\n {errorContext}\n </Typography>\n ) : null}\n <Typography variant=\"caption\" mr={0.5} fontWeight=\"bold\">\n Error:\n </Typography>\n <Typography variant=\"caption\">{error?.message}</Typography>\n {onCancel ? (\n <ButtonEx variant=\"outlined\" size=\"small\" onClick={onCancel} position=\"absolute\" style={{ right: 8, top: 8 }}>\n <ExitIcon fontSize=\"small\" />\n </ButtonEx>\n ) : null}\n </Alert>\n )\n}\n"],"mappings":";AAAA,SAAS,aAAa,gBAAgB;AACtC,SAAS,OAAmB,YAAY,kBAAkB;AAC1D,SAAS,gBAAgB;AAWrB,SACE,KADF;AAFG,IAAM,aAAwC,CAAC,EAAE,UAAU,OAAO,cAAc,GAAG,MAAM,MAAM;AACpG,SACE,qBAAC,SAAM,UAAS,SAAS,GAAG,OAC1B;AAAA,wBAAC,cAAW,0CAA4B;AAAA,IACvC,eACC,oBAAC,cAAW,SAAQ,WAAU,IAAI,KAAK,YAAW,KAAI,SAAQ,SAC3D,wBACH,IACE;AAAA,IACJ,oBAAC,cAAW,SAAQ,WAAU,IAAI,KAAK,YAAW,QAAO,oBAEzD;AAAA,IACA,oBAAC,cAAW,SAAQ,WAAW,iBAAO,SAAQ;AAAA,IAC7C,WACC,oBAAC,YAAS,SAAQ,YAAW,MAAK,SAAQ,SAAS,UAAU,UAAS,YAAW,OAAO,EAAE,OAAO,GAAG,KAAK,EAAE,GACzG,8BAAC,YAAS,UAAS,SAAQ,GAC7B,IACE;AAAA,KACN;AAEJ;","names":[]}
|
@@ -1,19 +0,0 @@
|
|
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 __copyProps = (to, from, except, desc) => {
|
7
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
8
|
-
for (let key of __getOwnPropNames(from))
|
9
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
10
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
11
|
-
}
|
12
|
-
return to;
|
13
|
-
};
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
15
|
-
|
16
|
-
// src/components/ErrorRender/Props.ts
|
17
|
-
var Props_exports = {};
|
18
|
-
module.exports = __toCommonJS(Props_exports);
|
19
|
-
//# sourceMappingURL=Props.cjs.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/ErrorRender/Props.ts"],"sourcesContent":["import { FlexBoxProps } from '@xylabs/react-flexbox'\nimport { ModuleError } from '@xyo-network/payload-model'\nimport { ReactNode } from 'react'\n\nexport interface ErrorRenderProps extends FlexBoxProps {\n customError?: ReactNode\n error?: ModuleError | Error\n errorContext?: string\n noErrorDisplay?: boolean\n noReAuth?: boolean\n onCancel?: () => void\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
@@ -1 +0,0 @@
|
|
1
|
-
//# sourceMappingURL=Props.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|