@xyo-network/react-error 2.64.0-rc.3 → 2.64.0-rc.5
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/browser/components/ErrorBoundary/ThrownErrorBoundary.d.mts.map +1 -0
- package/dist/browser/components/ErrorBoundary/ThrownErrorBoundary.d.ts.map +1 -0
- package/dist/browser/components/ErrorBoundary/ThrownErrorBoundary.js +39 -0
- package/dist/browser/components/ErrorBoundary/ThrownErrorBoundary.js.map +1 -0
- package/dist/browser/components/ErrorBoundary/ThrownErrorBoundary.stories.js +26 -0
- package/dist/browser/components/ErrorBoundary/ThrownErrorBoundary.stories.js.map +1 -0
- package/dist/browser/components/ErrorBoundary/index.d.mts.map +1 -0
- package/dist/browser/components/ErrorBoundary/index.d.ts.map +1 -0
- package/dist/browser/components/ErrorBoundary/index.js +2 -0
- package/dist/browser/components/ErrorBoundary/index.js.map +1 -0
- package/dist/browser/components/ErrorRender/ErrorAlert.d.mts.map +1 -0
- package/dist/browser/components/ErrorRender/ErrorAlert.d.ts.map +1 -0
- package/dist/browser/components/ErrorRender/ErrorAlert.js +17 -0
- package/dist/browser/components/ErrorRender/ErrorAlert.js.map +1 -0
- package/dist/browser/components/ErrorRender/Props.d.mts.map +1 -0
- package/dist/browser/components/ErrorRender/Props.d.ts.map +1 -0
- package/dist/browser/components/ErrorRender/Props.js +1 -0
- package/dist/browser/components/ErrorRender/Props.js.map +1 -0
- package/dist/browser/components/ErrorRender/Render.d.mts.map +1 -0
- package/dist/browser/components/ErrorRender/Render.d.ts.map +1 -0
- package/dist/browser/components/ErrorRender/Render.js +32 -0
- package/dist/browser/components/ErrorRender/Render.js.map +1 -0
- package/dist/browser/components/ErrorRender/index.d.mts.map +1 -0
- package/dist/browser/components/ErrorRender/index.d.ts.map +1 -0
- package/dist/browser/components/ErrorRender/index.js +4 -0
- package/dist/browser/components/ErrorRender/index.js.map +1 -0
- package/dist/browser/components/index.d.mts.map +1 -0
- package/dist/browser/components/index.d.ts.map +1 -0
- package/dist/browser/components/index.js +3 -0
- package/dist/browser/components/index.js.map +1 -0
- package/dist/browser/contexts/ErrorReporter/Context.d.mts.map +1 -0
- package/dist/browser/contexts/ErrorReporter/Context.d.ts.map +1 -0
- package/dist/browser/contexts/ErrorReporter/Context.js +6 -0
- package/dist/browser/contexts/ErrorReporter/Context.js.map +1 -0
- package/dist/browser/contexts/ErrorReporter/Provider.d.mts.map +1 -0
- package/dist/browser/contexts/ErrorReporter/Provider.d.ts.map +1 -0
- package/dist/browser/contexts/ErrorReporter/Provider.js +16 -0
- package/dist/browser/contexts/ErrorReporter/Provider.js.map +1 -0
- package/dist/browser/contexts/ErrorReporter/Provider.stories.js +35 -0
- package/dist/browser/contexts/ErrorReporter/Provider.stories.js.map +1 -0
- package/dist/browser/contexts/ErrorReporter/State.d.mts.map +1 -0
- package/dist/browser/contexts/ErrorReporter/State.d.ts.map +1 -0
- package/dist/browser/contexts/ErrorReporter/State.js +1 -0
- package/dist/browser/contexts/ErrorReporter/State.js.map +1 -0
- package/dist/browser/contexts/ErrorReporter/index.d.mts.map +1 -0
- package/dist/browser/contexts/ErrorReporter/index.d.ts.map +1 -0
- package/dist/browser/contexts/ErrorReporter/index.js +4 -0
- package/dist/browser/contexts/ErrorReporter/index.js.map +1 -0
- package/dist/browser/contexts/ErrorReporter/useRollbar.d.mts.map +1 -0
- package/dist/browser/contexts/ErrorReporter/useRollbar.d.ts.map +1 -0
- package/dist/browser/contexts/ErrorReporter/useRollbar.js +13 -0
- package/dist/browser/contexts/ErrorReporter/useRollbar.js.map +1 -0
- package/dist/browser/contexts/index.d.mts.map +1 -0
- package/dist/browser/contexts/index.d.ts.map +1 -0
- package/dist/browser/contexts/index.js +2 -0
- package/dist/browser/contexts/index.js.map +1 -0
- package/dist/browser/index.d.mts.map +1 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js +3 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/node/components/ErrorBoundary/ThrownErrorBoundary.d.mts +21 -0
- package/dist/node/components/ErrorBoundary/ThrownErrorBoundary.d.mts.map +1 -0
- package/dist/node/components/ErrorBoundary/ThrownErrorBoundary.d.ts +21 -0
- package/dist/node/components/ErrorBoundary/ThrownErrorBoundary.d.ts.map +1 -0
- package/dist/node/components/ErrorBoundary/ThrownErrorBoundary.js +63 -0
- package/dist/node/components/ErrorBoundary/ThrownErrorBoundary.js.map +1 -0
- package/dist/node/components/ErrorBoundary/ThrownErrorBoundary.mjs +39 -0
- package/dist/node/components/ErrorBoundary/ThrownErrorBoundary.mjs.map +1 -0
- package/dist/node/components/ErrorBoundary/ThrownErrorBoundary.stories.js +51 -0
- package/dist/node/components/ErrorBoundary/ThrownErrorBoundary.stories.js.map +1 -0
- package/dist/node/components/ErrorBoundary/ThrownErrorBoundary.stories.mjs +26 -0
- package/dist/node/components/ErrorBoundary/ThrownErrorBoundary.stories.mjs.map +1 -0
- package/dist/node/components/ErrorBoundary/index.d.mts +2 -0
- package/dist/node/components/ErrorBoundary/index.d.mts.map +1 -0
- package/dist/node/components/ErrorBoundary/index.d.ts +2 -0
- package/dist/node/components/ErrorBoundary/index.d.ts.map +1 -0
- package/dist/node/components/ErrorBoundary/index.js +23 -0
- package/dist/node/components/ErrorBoundary/index.js.map +1 -0
- package/dist/node/components/ErrorBoundary/index.mjs +2 -0
- package/dist/node/components/ErrorBoundary/index.mjs.map +1 -0
- package/dist/node/components/ErrorRender/ErrorAlert.d.mts +10 -0
- package/dist/node/components/ErrorRender/ErrorAlert.d.mts.map +1 -0
- package/dist/node/components/ErrorRender/ErrorAlert.d.ts +10 -0
- package/dist/node/components/ErrorRender/ErrorAlert.d.ts.map +1 -0
- package/dist/node/components/ErrorRender/ErrorAlert.js +41 -0
- package/dist/node/components/ErrorRender/ErrorAlert.js.map +1 -0
- package/dist/node/components/ErrorRender/ErrorAlert.mjs +17 -0
- package/dist/node/components/ErrorRender/ErrorAlert.mjs.map +1 -0
- package/dist/node/components/ErrorRender/Props.d.mts +12 -0
- package/dist/node/components/ErrorRender/Props.d.mts.map +1 -0
- package/dist/node/components/ErrorRender/Props.d.ts +12 -0
- package/dist/node/components/ErrorRender/Props.d.ts.map +1 -0
- package/dist/node/components/ErrorRender/Props.js +17 -0
- package/dist/node/components/ErrorRender/Props.js.map +1 -0
- package/dist/node/components/ErrorRender/Props.mjs +1 -0
- package/dist/node/components/ErrorRender/Props.mjs.map +1 -0
- package/dist/node/components/ErrorRender/Render.d.mts +4 -0
- package/dist/node/components/ErrorRender/Render.d.mts.map +1 -0
- package/dist/node/components/ErrorRender/Render.d.ts +4 -0
- package/dist/node/components/ErrorRender/Render.d.ts.map +1 -0
- package/dist/node/components/ErrorRender/Render.js +56 -0
- package/dist/node/components/ErrorRender/Render.js.map +1 -0
- package/dist/node/components/ErrorRender/Render.mjs +32 -0
- package/dist/node/components/ErrorRender/Render.mjs.map +1 -0
- package/dist/node/components/ErrorRender/index.d.mts +4 -0
- package/dist/node/components/ErrorRender/index.d.mts.map +1 -0
- package/dist/node/components/ErrorRender/index.d.ts +4 -0
- package/dist/node/components/ErrorRender/index.d.ts.map +1 -0
- package/dist/node/components/ErrorRender/index.js +27 -0
- package/dist/node/components/ErrorRender/index.js.map +1 -0
- package/dist/node/components/ErrorRender/index.mjs +4 -0
- package/dist/node/components/ErrorRender/index.mjs.map +1 -0
- package/dist/node/components/index.d.mts +3 -0
- package/dist/node/components/index.d.mts.map +1 -0
- package/dist/node/components/index.d.ts +3 -0
- package/dist/node/components/index.d.ts.map +1 -0
- package/dist/node/components/index.js +25 -0
- package/dist/node/components/index.js.map +1 -0
- package/dist/node/components/index.mjs +3 -0
- package/dist/node/components/index.mjs.map +1 -0
- package/dist/node/contexts/ErrorReporter/Context.d.mts +4 -0
- package/dist/node/contexts/ErrorReporter/Context.d.mts.map +1 -0
- package/dist/node/contexts/ErrorReporter/Context.d.ts +4 -0
- package/dist/node/contexts/ErrorReporter/Context.d.ts.map +1 -0
- package/dist/node/contexts/ErrorReporter/Context.js +30 -0
- package/dist/node/contexts/ErrorReporter/Context.js.map +1 -0
- package/dist/node/contexts/ErrorReporter/Context.mjs +6 -0
- package/dist/node/contexts/ErrorReporter/Context.mjs.map +1 -0
- package/dist/node/contexts/ErrorReporter/Provider.d.mts +9 -0
- package/dist/node/contexts/ErrorReporter/Provider.d.mts.map +1 -0
- package/dist/node/contexts/ErrorReporter/Provider.d.ts +9 -0
- package/dist/node/contexts/ErrorReporter/Provider.d.ts.map +1 -0
- package/dist/node/contexts/ErrorReporter/Provider.js +40 -0
- package/dist/node/contexts/ErrorReporter/Provider.js.map +1 -0
- package/dist/node/contexts/ErrorReporter/Provider.mjs +16 -0
- package/dist/node/contexts/ErrorReporter/Provider.mjs.map +1 -0
- package/dist/node/contexts/ErrorReporter/Provider.stories.js +69 -0
- package/dist/node/contexts/ErrorReporter/Provider.stories.js.map +1 -0
- package/dist/node/contexts/ErrorReporter/Provider.stories.mjs +35 -0
- package/dist/node/contexts/ErrorReporter/Provider.stories.mjs.map +1 -0
- package/dist/node/contexts/ErrorReporter/State.d.mts +5 -0
- package/dist/node/contexts/ErrorReporter/State.d.mts.map +1 -0
- package/dist/node/contexts/ErrorReporter/State.d.ts +5 -0
- package/dist/node/contexts/ErrorReporter/State.d.ts.map +1 -0
- package/dist/node/contexts/ErrorReporter/State.js +17 -0
- package/dist/node/contexts/ErrorReporter/State.js.map +1 -0
- package/dist/node/contexts/ErrorReporter/State.mjs +1 -0
- package/dist/node/contexts/ErrorReporter/State.mjs.map +1 -0
- package/dist/node/contexts/ErrorReporter/index.d.mts +4 -0
- package/dist/node/contexts/ErrorReporter/index.d.mts.map +1 -0
- package/dist/node/contexts/ErrorReporter/index.d.ts +4 -0
- package/dist/node/contexts/ErrorReporter/index.d.ts.map +1 -0
- package/dist/node/contexts/ErrorReporter/index.js +27 -0
- package/dist/node/contexts/ErrorReporter/index.js.map +1 -0
- package/dist/node/contexts/ErrorReporter/index.mjs +4 -0
- package/dist/node/contexts/ErrorReporter/index.mjs.map +1 -0
- package/dist/node/contexts/ErrorReporter/useRollbar.d.mts +3 -0
- package/dist/node/contexts/ErrorReporter/useRollbar.d.mts.map +1 -0
- package/dist/node/contexts/ErrorReporter/useRollbar.d.ts +3 -0
- package/dist/node/contexts/ErrorReporter/useRollbar.d.ts.map +1 -0
- package/dist/node/contexts/ErrorReporter/useRollbar.js +37 -0
- package/dist/node/contexts/ErrorReporter/useRollbar.js.map +1 -0
- package/dist/node/contexts/ErrorReporter/useRollbar.mjs +13 -0
- package/dist/node/contexts/ErrorReporter/useRollbar.mjs.map +1 -0
- package/dist/node/contexts/index.d.mts +2 -0
- package/dist/node/contexts/index.d.mts.map +1 -0
- package/dist/node/contexts/index.d.ts +2 -0
- package/dist/node/contexts/index.d.ts.map +1 -0
- package/dist/node/contexts/index.js +23 -0
- package/dist/node/contexts/index.js.map +1 -0
- package/dist/node/contexts/index.mjs +2 -0
- package/dist/node/contexts/index.mjs.map +1 -0
- package/dist/node/index.d.mts +3 -0
- package/dist/node/index.d.mts.map +1 -0
- package/dist/node/index.d.ts +3 -0
- package/dist/node/index.d.ts.map +1 -0
- package/dist/node/index.js +25 -0
- package/dist/node/index.js.map +1 -0
- package/dist/node/index.mjs +3 -0
- package/dist/node/index.mjs.map +1 -0
- package/package.json +20 -20
- package/dist/components/ErrorBoundary/ThrownErrorBoundary.d.mts.map +0 -1
- package/dist/components/ErrorBoundary/ThrownErrorBoundary.d.ts.map +0 -1
- package/dist/components/ErrorBoundary/ThrownErrorBoundary.stories.d.mts +0 -7
- package/dist/components/ErrorBoundary/ThrownErrorBoundary.stories.d.mts.map +0 -1
- package/dist/components/ErrorBoundary/ThrownErrorBoundary.stories.d.ts +0 -7
- package/dist/components/ErrorBoundary/ThrownErrorBoundary.stories.d.ts.map +0 -1
- package/dist/components/ErrorBoundary/index.d.mts.map +0 -1
- package/dist/components/ErrorBoundary/index.d.ts.map +0 -1
- package/dist/components/ErrorRender/ErrorAlert.d.mts.map +0 -1
- package/dist/components/ErrorRender/ErrorAlert.d.ts.map +0 -1
- package/dist/components/ErrorRender/Props.d.mts.map +0 -1
- package/dist/components/ErrorRender/Props.d.ts.map +0 -1
- package/dist/components/ErrorRender/Render.d.mts.map +0 -1
- package/dist/components/ErrorRender/Render.d.ts.map +0 -1
- package/dist/components/ErrorRender/index.d.mts.map +0 -1
- package/dist/components/ErrorRender/index.d.ts.map +0 -1
- package/dist/components/index.d.mts.map +0 -1
- package/dist/components/index.d.ts.map +0 -1
- package/dist/contexts/ErrorReporter/Context.d.mts.map +0 -1
- package/dist/contexts/ErrorReporter/Context.d.ts.map +0 -1
- package/dist/contexts/ErrorReporter/Provider.d.mts.map +0 -1
- package/dist/contexts/ErrorReporter/Provider.d.ts.map +0 -1
- package/dist/contexts/ErrorReporter/Provider.stories.d.mts +0 -10
- package/dist/contexts/ErrorReporter/Provider.stories.d.mts.map +0 -1
- package/dist/contexts/ErrorReporter/Provider.stories.d.ts +0 -10
- package/dist/contexts/ErrorReporter/Provider.stories.d.ts.map +0 -1
- package/dist/contexts/ErrorReporter/State.d.mts.map +0 -1
- package/dist/contexts/ErrorReporter/State.d.ts.map +0 -1
- package/dist/contexts/ErrorReporter/index.d.mts.map +0 -1
- package/dist/contexts/ErrorReporter/index.d.ts.map +0 -1
- package/dist/contexts/ErrorReporter/useRollbar.d.mts.map +0 -1
- package/dist/contexts/ErrorReporter/useRollbar.d.ts.map +0 -1
- package/dist/contexts/index.d.mts.map +0 -1
- package/dist/contexts/index.d.ts.map +0 -1
- package/dist/index.d.mts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -149
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -118
- package/dist/index.mjs.map +0 -1
- /package/dist/{components → browser/components}/ErrorBoundary/ThrownErrorBoundary.d.mts +0 -0
- /package/dist/{components → browser/components}/ErrorBoundary/ThrownErrorBoundary.d.ts +0 -0
- /package/dist/{components → browser/components}/ErrorBoundary/index.d.mts +0 -0
- /package/dist/{components → browser/components}/ErrorBoundary/index.d.ts +0 -0
- /package/dist/{components → browser/components}/ErrorRender/ErrorAlert.d.mts +0 -0
- /package/dist/{components → browser/components}/ErrorRender/ErrorAlert.d.ts +0 -0
- /package/dist/{components → browser/components}/ErrorRender/Props.d.mts +0 -0
- /package/dist/{components → browser/components}/ErrorRender/Props.d.ts +0 -0
- /package/dist/{components → browser/components}/ErrorRender/Render.d.mts +0 -0
- /package/dist/{components → browser/components}/ErrorRender/Render.d.ts +0 -0
- /package/dist/{components → browser/components}/ErrorRender/index.d.mts +0 -0
- /package/dist/{components → browser/components}/ErrorRender/index.d.ts +0 -0
- /package/dist/{components → browser/components}/index.d.mts +0 -0
- /package/dist/{components → browser/components}/index.d.ts +0 -0
- /package/dist/{contexts → browser/contexts}/ErrorReporter/Context.d.mts +0 -0
- /package/dist/{contexts → browser/contexts}/ErrorReporter/Context.d.ts +0 -0
- /package/dist/{contexts → browser/contexts}/ErrorReporter/Provider.d.mts +0 -0
- /package/dist/{contexts → browser/contexts}/ErrorReporter/Provider.d.ts +0 -0
- /package/dist/{contexts → browser/contexts}/ErrorReporter/State.d.mts +0 -0
- /package/dist/{contexts → browser/contexts}/ErrorReporter/State.d.ts +0 -0
- /package/dist/{contexts → browser/contexts}/ErrorReporter/index.d.mts +0 -0
- /package/dist/{contexts → browser/contexts}/ErrorReporter/index.d.ts +0 -0
- /package/dist/{contexts → browser/contexts}/ErrorReporter/useRollbar.d.mts +0 -0
- /package/dist/{contexts → browser/contexts}/ErrorReporter/useRollbar.d.ts +0 -0
- /package/dist/{contexts → browser/contexts}/index.d.mts +0 -0
- /package/dist/{contexts → browser/contexts}/index.d.ts +0 -0
- /package/dist/{index.d.mts → browser/index.d.mts} +0 -0
- /package/dist/{index.d.ts → browser/index.d.ts} +0 -0
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ThrownErrorBoundary.d.ts","sourceRoot":"","sources":["../../../../src/components/ErrorBoundary/ThrownErrorBoundary.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAqB,MAAM,4BAA4B,CAAA;AAC3E,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACvD,OAAO,OAAO,MAAM,SAAS,CAAA;AAI7B,MAAM,WAAW,wBAAwB;IACvC,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,QAAQ,EAAE,SAAS,CAAA;IACnB,cAAc,CAAC,EAAE,CAAC,CAAC,EAAE,WAAW,EAAE,YAAY,CAAC,EAAE,MAAM,KAAK,SAAS,CAAA;IACrE,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,EAAE,WAAW,CAAA;CACvB;AAED,qBAAa,mBAAoB,SAAQ,SAAS,CAAC,wBAAwB,EAAE,wBAAwB,CAAC;IACpF,KAAK,EAAE,wBAAwB,CAE9C;IAED,MAAM,CAAC,wBAAwB,CAAC,KAAK,EAAE,KAAK;WAI9B,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,WAAW,GAAG,WAAW;IAMrD,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS;IAYpD,MAAM;CAYvB"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ThrownErrorBoundary.d.ts","sourceRoot":"","sources":["../../../../src/components/ErrorBoundary/ThrownErrorBoundary.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAqB,MAAM,4BAA4B,CAAA;AAC3E,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACvD,OAAO,OAAO,MAAM,SAAS,CAAA;AAI7B,MAAM,WAAW,wBAAwB;IACvC,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,QAAQ,EAAE,SAAS,CAAA;IACnB,cAAc,CAAC,EAAE,CAAC,CAAC,EAAE,WAAW,EAAE,YAAY,CAAC,EAAE,MAAM,KAAK,SAAS,CAAA;IACrE,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,EAAE,WAAW,CAAA;CACvB;AAED,qBAAa,mBAAoB,SAAQ,SAAS,CAAC,wBAAwB,EAAE,wBAAwB,CAAC;IACpF,KAAK,EAAE,wBAAwB,CAE9C;IAED,MAAM,CAAC,wBAAwB,CAAC,KAAK,EAAE,KAAK;WAI9B,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,WAAW,GAAG,WAAW;IAMrD,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS;IAYpD,MAAM;CAYvB"}
|
@@ -0,0 +1,39 @@
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
2
|
+
import { ModuleErrorSchema } from "@xyo-network/payload-model";
|
3
|
+
import { Component } from "react";
|
4
|
+
import { ErrorRender } from "../ErrorRender";
|
5
|
+
class ThrownErrorBoundary extends Component {
|
6
|
+
state = {
|
7
|
+
xyoError: void 0
|
8
|
+
};
|
9
|
+
static getDerivedStateFromError(error) {
|
10
|
+
return { hasError: true, xyoError: ThrownErrorBoundary.normalizeError(error) };
|
11
|
+
}
|
12
|
+
static normalizeError(error) {
|
13
|
+
return error.schema === ModuleErrorSchema ? error : { message: error.message, schema: ModuleErrorSchema, sources: [] };
|
14
|
+
}
|
15
|
+
componentDidCatch(error, errorInfo) {
|
16
|
+
const { rethrow, rollbar } = this.props;
|
17
|
+
const { xyoError } = this.state;
|
18
|
+
rollbar?.error(error);
|
19
|
+
console.error("Error:", xyoError, errorInfo);
|
20
|
+
if (rethrow) {
|
21
|
+
throw error;
|
22
|
+
}
|
23
|
+
}
|
24
|
+
render() {
|
25
|
+
const { xyoError } = this.state;
|
26
|
+
const { children, boundaryName, errorComponent } = this.props;
|
27
|
+
if (xyoError) {
|
28
|
+
if (errorComponent) {
|
29
|
+
return errorComponent(xyoError);
|
30
|
+
}
|
31
|
+
return /* @__PURE__ */ jsx(ErrorRender, { error: xyoError, errorContext: `${boundaryName} Boundary` });
|
32
|
+
}
|
33
|
+
return children;
|
34
|
+
}
|
35
|
+
}
|
36
|
+
export {
|
37
|
+
ThrownErrorBoundary
|
38
|
+
};
|
39
|
+
//# sourceMappingURL=ThrownErrorBoundary.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/ErrorBoundary/ThrownErrorBoundary.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"],"mappings":"AAoDa;AApDb,SAAsB,yBAAyB;AAC/C,SAAS,iBAAuC;AAGhD,SAAS,mBAAmB;AAcrB,MAAM,4BAA4B,UAA8D;AAAA,EACrF,QAAkC;AAAA,IAChD,UAAU;AAAA,EACZ;AAAA,EAEA,OAAO,yBAAyB,OAAc;AAC5C,WAAO,EAAE,UAAU,MAAM,UAAU,oBAAoB,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,oBAAC,eAAY,OAAO,UAAU,cAAc,GAAG,YAAY,aAAa;AAAA,IACjF;AAEA,WAAO;AAAA,EACT;AACF;","names":[]}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
2
|
+
import { Alert } from "@mui/material";
|
3
|
+
import { ThrownErrorBoundary } from "./ThrownErrorBoundary";
|
4
|
+
const StorybookEntry = {
|
5
|
+
component: ThrownErrorBoundary,
|
6
|
+
title: "auth-service/ApiBoundary/ThrownErrorBoundary"
|
7
|
+
};
|
8
|
+
const Template = ({ errorComponent }) => {
|
9
|
+
return /* @__PURE__ */ jsx(ThrownErrorBoundary, { errorComponent, boundaryName: "StoryBook", children: /* @__PURE__ */ jsx(Alert, { severity: "info", children: "Use React Dev Tools to trigger and error within the boundary" }) });
|
10
|
+
};
|
11
|
+
const Default = Template.bind({});
|
12
|
+
Default.args = {};
|
13
|
+
const CustomErrorComponent = Template.bind({});
|
14
|
+
CustomErrorComponent.args = {
|
15
|
+
errorComponent: (e) => /* @__PURE__ */ jsxs(Alert, { severity: "error", children: [
|
16
|
+
"Using Custom Error Component with error: ",
|
17
|
+
e.message
|
18
|
+
] })
|
19
|
+
};
|
20
|
+
var ThrownErrorBoundary_stories_default = StorybookEntry;
|
21
|
+
export {
|
22
|
+
CustomErrorComponent,
|
23
|
+
Default,
|
24
|
+
ThrownErrorBoundary_stories_default as default
|
25
|
+
};
|
26
|
+
//# sourceMappingURL=ThrownErrorBoundary.stories.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/ErrorBoundary/ThrownErrorBoundary.stories.tsx"],"sourcesContent":["/* eslint-disable import/no-internal-modules */\nimport { Alert } from '@mui/material'\nimport { Meta, StoryFn } from '@storybook/react'\n\nimport { ThrownErrorBoundary } from './ThrownErrorBoundary'\n\nconst StorybookEntry: Meta = {\n component: ThrownErrorBoundary,\n title: 'auth-service/ApiBoundary/ThrownErrorBoundary',\n}\n\nconst Template: StoryFn<typeof ThrownErrorBoundary> = ({ errorComponent }) => {\n return (\n <ThrownErrorBoundary errorComponent={errorComponent} boundaryName=\"StoryBook\">\n <Alert severity=\"info\">Use React Dev Tools to trigger and error within the boundary</Alert>\n </ThrownErrorBoundary>\n )\n}\n\nconst Default = Template.bind({})\nDefault.args = {}\n\nconst CustomErrorComponent = Template.bind({})\nCustomErrorComponent.args = {\n errorComponent: (e) => <Alert severity=\"error\">Using Custom Error Component with error: {e.message}</Alert>,\n}\n\nexport { CustomErrorComponent, Default }\n\n// eslint-disable-next-line import/no-default-export\nexport default StorybookEntry\n"],"mappings":"AAcM,cAUmB,YAVnB;AAbN,SAAS,aAAa;AAGtB,SAAS,2BAA2B;AAEpC,MAAM,iBAAuB;AAAA,EAC3B,WAAW;AAAA,EACX,OAAO;AACT;AAEA,MAAM,WAAgD,CAAC,EAAE,eAAe,MAAM;AAC5E,SACE,oBAAC,uBAAoB,gBAAgC,cAAa,aAChE,8BAAC,SAAM,UAAS,QAAO,0EAA4D,GACrF;AAEJ;AAEA,MAAM,UAAU,SAAS,KAAK,CAAC,CAAC;AAChC,QAAQ,OAAO,CAAC;AAEhB,MAAM,uBAAuB,SAAS,KAAK,CAAC,CAAC;AAC7C,qBAAqB,OAAO;AAAA,EAC1B,gBAAgB,CAAC,MAAM,qBAAC,SAAM,UAAS,SAAQ;AAAA;AAAA,IAA0C,EAAE;AAAA,KAAQ;AACrG;AAKA,IAAO,sCAAQ;","names":[]}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/ErrorBoundary/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/ErrorBoundary/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/ErrorBoundary/index.ts"],"sourcesContent":["export * from './ThrownErrorBoundary'\n"],"mappings":"AAAA,cAAc;","names":[]}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ErrorAlert.d.ts","sourceRoot":"","sources":["../../../../src/components/ErrorRender/ErrorAlert.tsx"],"names":[],"mappings":";AACA,OAAO,EAAS,UAAU,EAA0B,MAAM,eAAe,CAAA;AAEzE,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAExD,MAAM,WAAW,eAAgB,SAAQ,UAAU;IACjD,KAAK,CAAC,EAAE,WAAW,GAAG,KAAK,CAAA;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAA;CACtB;AAED,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAoBhD,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ErrorAlert.d.ts","sourceRoot":"","sources":["../../../../src/components/ErrorRender/ErrorAlert.tsx"],"names":[],"mappings":";AACA,OAAO,EAAS,UAAU,EAA0B,MAAM,eAAe,CAAA;AAEzE,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAExD,MAAM,WAAW,eAAgB,SAAQ,UAAU;IACjD,KAAK,CAAC,EAAE,WAAW,GAAG,KAAK,CAAA;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAA;CACtB;AAED,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAoBhD,CAAA"}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
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
|
+
const ErrorAlert = ({ onCancel, error, errorContext, ...props }) => {
|
6
|
+
return /* @__PURE__ */ jsxs(Alert, { severity: "error", ...props, children: [
|
7
|
+
/* @__PURE__ */ jsx(AlertTitle, { children: "Whoops! Something went wrong" }),
|
8
|
+
errorContext ? /* @__PURE__ */ jsx(Typography, { variant: "caption", my: 0.5, lineHeight: "1", display: "block", children: errorContext }) : null,
|
9
|
+
/* @__PURE__ */ jsx(Typography, { variant: "caption", mr: 0.5, fontWeight: "bold", children: "Error:" }),
|
10
|
+
/* @__PURE__ */ jsx(Typography, { variant: "caption", children: error?.message }),
|
11
|
+
onCancel ? /* @__PURE__ */ jsx(ButtonEx, { variant: "outlined", size: "small", onClick: onCancel, position: "absolute", style: { right: 8, top: 8 }, children: /* @__PURE__ */ jsx(ExitIcon, { fontSize: "small" }) }) : null
|
12
|
+
] });
|
13
|
+
};
|
14
|
+
export {
|
15
|
+
ErrorAlert
|
16
|
+
};
|
17
|
+
//# sourceMappingURL=ErrorAlert.js.map
|
@@ -0,0 +1 @@
|
|
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":"AAaI,SACE,KADF;AAbJ,SAAS,aAAa,gBAAgB;AACtC,SAAS,OAAmB,YAAY,kBAAkB;AAC1D,SAAS,gBAAgB;AASlB,MAAM,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":[]}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Props.d.ts","sourceRoot":"","sources":["../../../../src/components/ErrorRender/Props.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEjC,MAAM,WAAW,gBAAiB,SAAQ,YAAY;IACpD,WAAW,CAAC,EAAE,SAAS,CAAA;IACvB,KAAK,CAAC,EAAE,WAAW,GAAG,KAAK,CAAA;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAA;CACtB"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Props.d.ts","sourceRoot":"","sources":["../../../../src/components/ErrorRender/Props.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEjC,MAAM,WAAW,gBAAiB,SAAQ,YAAY;IACpD,WAAW,CAAC,EAAE,SAAS,CAAA;IACvB,KAAK,CAAC,EAAE,WAAW,GAAG,KAAK,CAAA;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAA;CACtB"}
|
@@ -0,0 +1 @@
|
|
1
|
+
//# sourceMappingURL=Props.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Render.d.ts","sourceRoot":"","sources":["../../../../src/components/ErrorRender/Render.tsx"],"names":[],"mappings":";AAKA,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAE1C,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CAkClD,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Render.d.ts","sourceRoot":"","sources":["../../../../src/components/ErrorRender/Render.tsx"],"names":[],"mappings":";AAKA,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAE1C,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CAkClD,CAAA"}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
2
|
+
import { FlexCol } from "@xylabs/react-flexbox";
|
3
|
+
import { useEffect } from "react";
|
4
|
+
import { useLocation } from "react-router-dom";
|
5
|
+
import { ErrorAlert } from "./ErrorAlert";
|
6
|
+
const ErrorRender = ({
|
7
|
+
onCancel,
|
8
|
+
error,
|
9
|
+
noErrorDisplay = false,
|
10
|
+
customError = null,
|
11
|
+
children,
|
12
|
+
errorContext,
|
13
|
+
...props
|
14
|
+
}) => {
|
15
|
+
const location = useLocation();
|
16
|
+
useEffect(() => {
|
17
|
+
location.state = {
|
18
|
+
from: {
|
19
|
+
pathname: window.location.pathname
|
20
|
+
}
|
21
|
+
};
|
22
|
+
}, [location]);
|
23
|
+
if (error) {
|
24
|
+
return /* @__PURE__ */ jsx(FlexCol, { alignItems: "stretch", ...props, children: noErrorDisplay ? customError : /* @__PURE__ */ jsx(FlexCol, { alignItems: "center", ...props, children: /* @__PURE__ */ jsx(ErrorAlert, { error, errorContext, onCancel }) }) });
|
25
|
+
} else {
|
26
|
+
return /* @__PURE__ */ jsx(Fragment, { children }) ?? null;
|
27
|
+
}
|
28
|
+
};
|
29
|
+
export {
|
30
|
+
ErrorRender
|
31
|
+
};
|
32
|
+
//# sourceMappingURL=Render.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/ErrorRender/Render.tsx"],"sourcesContent":["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":"AAiCY,SAMD,UANC;AAjCZ,SAAS,eAAe;AACxB,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAE5B,SAAS,kBAAkB;AAGpB,MAAM,cAA0C,CAAC;AAAA,EACtD;AAAA,EACA;AAAA,EACA,iBAAiB;AAAA,EACjB,cAAc;AAAA,EACd;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACJ,QAAM,WAAW,YAAY;AAC7B,YAAU,MAAM;AAEd,aAAS,QAAQ;AAAA,MACf,MAAM;AAAA,QACJ,UAAU,OAAO,SAAS;AAAA,MAC5B;AAAA,IACF;AAAA,EACF,GAAG,CAAC,QAAQ,CAAC;AAEb,MAAI,OAAO;AACT,WACE,oBAAC,WAAQ,YAAW,WAAW,GAAG,OAC/B,2BACC,cAEA,oBAAC,WAAQ,YAAW,UAAU,GAAG,OAC/B,8BAAC,cAAW,OAAc,cAA4B,UAAoB,GAC5E,GAEJ;AAAA,EAEJ,OAAO;AACL,WAAO,gCAAG,UAAS,KAAO;AAAA,EAC5B;AACF;","names":[]}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/ErrorRender/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/ErrorRender/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/ErrorRender/index.ts"],"sourcesContent":["export * from './ErrorAlert'\nexport * from './Props'\nexport * from './Render'\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,eAAe,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,eAAe,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../src/components/index.ts"],"sourcesContent":["export * from './ErrorBoundary'\nexport * from './ErrorRender'\n"],"mappings":"AAAA,cAAc;AACd,cAAc;","names":[]}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../../../src/contexts/ErrorReporter/Context.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAA;AAEnD,eAAO,MAAM,oBAAoB,oDAA+C,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../../../src/contexts/ErrorReporter/Context.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAA;AAEnD,eAAO,MAAM,oBAAoB,oDAA+C,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../src/contexts/ErrorReporter/Context.ts"],"sourcesContent":["import { createContext } from 'react'\n\nimport { ErrorReporterContextState } from './State'\n\nexport const ErrorReporterContext = createContext<ErrorReporterContextState>({})\n"],"mappings":"AAAA,SAAS,qBAAqB;AAIvB,MAAM,uBAAuB,cAAyC,CAAC,CAAC;","names":[]}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../../../src/contexts/ErrorReporter/Provider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAEnD,OAAO,OAAO,MAAM,SAAS,CAAA;AAI7B,MAAM,WAAW,0BAA0B;IACzC,OAAO,EAAE,OAAO,CAAA;CACjB;AAED,QAAA,MAAM,qBAAqB,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,0BAA0B,CAAC,CAU7E,CAAA;AAED,OAAO,EAAE,qBAAqB,EAAE,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../../../src/contexts/ErrorReporter/Provider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAEnD,OAAO,OAAO,MAAM,SAAS,CAAA;AAI7B,MAAM,WAAW,0BAA0B;IACzC,OAAO,EAAE,OAAO,CAAA;CACjB;AAED,QAAA,MAAM,qBAAqB,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,0BAA0B,CAAC,CAU7E,CAAA;AAED,OAAO,EAAE,qBAAqB,EAAE,CAAA"}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
2
|
+
import { useEffect, useState } from "react";
|
3
|
+
import { ErrorReporterContext } from "./Context";
|
4
|
+
const ErrorReporterProvider = ({ children, rollbar }) => {
|
5
|
+
const [rollbarInstance, setRollBarInstance] = useState();
|
6
|
+
useEffect(() => {
|
7
|
+
if (rollbarInstance) {
|
8
|
+
setRollBarInstance(rollbarInstance);
|
9
|
+
}
|
10
|
+
}, [rollbar, rollbarInstance]);
|
11
|
+
return /* @__PURE__ */ jsx(ErrorReporterContext.Provider, { value: { rollbar }, children });
|
12
|
+
};
|
13
|
+
export {
|
14
|
+
ErrorReporterProvider
|
15
|
+
};
|
16
|
+
//# sourceMappingURL=Provider.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../src/contexts/ErrorReporter/Provider.tsx"],"sourcesContent":["import { WithChildren } from '@xylabs/react-shared'\nimport { useEffect, useState } from 'react'\nimport Rollbar from 'rollbar'\n\nimport { ErrorReporterContext } from './Context'\n\nexport interface ErrorReporterProviderProps {\n rollbar: Rollbar\n}\n\nconst ErrorReporterProvider: React.FC<WithChildren<ErrorReporterProviderProps>> = ({ children, rollbar }) => {\n const [rollbarInstance, setRollBarInstance] = useState<Rollbar>()\n\n useEffect(() => {\n if (rollbarInstance) {\n setRollBarInstance(rollbarInstance)\n }\n }, [rollbar, rollbarInstance])\n\n return <ErrorReporterContext.Provider value={{ rollbar }}>{children}</ErrorReporterContext.Provider>\n}\n\nexport { ErrorReporterProvider }\n"],"mappings":"AAmBS;AAlBT,SAAS,WAAW,gBAAgB;AAGpC,SAAS,4BAA4B;AAMrC,MAAM,wBAA4E,CAAC,EAAE,UAAU,QAAQ,MAAM;AAC3G,QAAM,CAAC,iBAAiB,kBAAkB,IAAI,SAAkB;AAEhE,YAAU,MAAM;AACd,QAAI,iBAAiB;AACnB,yBAAmB,eAAe;AAAA,IACpC;AAAA,EACF,GAAG,CAAC,SAAS,eAAe,CAAC;AAE7B,SAAO,oBAAC,qBAAqB,UAArB,EAA8B,OAAO,EAAE,QAAQ,GAAI,UAAS;AACtE;","names":[]}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
2
|
+
import { Typography } from "@mui/material";
|
3
|
+
import Rollbar from "rollbar";
|
4
|
+
import { ErrorReporterProvider } from "./Provider";
|
5
|
+
import { useRollbar } from "./useRollbar";
|
6
|
+
const StorybookEntry = {
|
7
|
+
argTypes: {},
|
8
|
+
component: ErrorReporterProvider,
|
9
|
+
parameters: {
|
10
|
+
docs: {
|
11
|
+
page: null
|
12
|
+
}
|
13
|
+
},
|
14
|
+
title: "auth-service/ErrorReporterProvider"
|
15
|
+
};
|
16
|
+
const RollbarComponent = () => {
|
17
|
+
const { rollbar } = useRollbar();
|
18
|
+
const rollbarFound = typeof rollbar?.error === "function";
|
19
|
+
return /* @__PURE__ */ jsxs(Typography, { color: rollbarFound ? "green" : "red", children: [
|
20
|
+
"Rollbar instance ",
|
21
|
+
rollbarFound ? "" : "NOT",
|
22
|
+
" found from context!"
|
23
|
+
] });
|
24
|
+
};
|
25
|
+
const Template = () => {
|
26
|
+
const rollbar = new Rollbar();
|
27
|
+
return /* @__PURE__ */ jsx(ErrorReporterProvider, { rollbar, children: /* @__PURE__ */ jsx(RollbarComponent, {}) });
|
28
|
+
};
|
29
|
+
const Default = Template.bind({});
|
30
|
+
var Provider_stories_default = StorybookEntry;
|
31
|
+
export {
|
32
|
+
Default,
|
33
|
+
Provider_stories_default as default
|
34
|
+
};
|
35
|
+
//# sourceMappingURL=Provider.stories.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../src/contexts/ErrorReporter/Provider.stories.tsx"],"sourcesContent":["import { Typography } from '@mui/material'\nimport { Meta, StoryFn } from '@storybook/react'\nimport Rollbar from 'rollbar'\n\nimport { ErrorReporterProvider } from './Provider'\nimport { useRollbar } from './useRollbar'\n\nconst StorybookEntry = {\n argTypes: {},\n component: ErrorReporterProvider,\n parameters: {\n docs: {\n page: null,\n },\n },\n title: 'auth-service/ErrorReporterProvider',\n} as Meta<typeof ErrorReporterProvider>\n\nconst RollbarComponent = () => {\n const { rollbar } = useRollbar()\n const rollbarFound = typeof rollbar?.error === 'function'\n\n return <Typography color={rollbarFound ? 'green' : 'red'}>Rollbar instance {rollbarFound ? '' : 'NOT'} found from context!</Typography>\n}\n\nconst Template: StoryFn<typeof ErrorReporterProvider> = () => {\n const rollbar = new Rollbar()\n return (\n <ErrorReporterProvider rollbar={rollbar}>\n <RollbarComponent />\n </ErrorReporterProvider>\n )\n}\n\nconst Default = Template.bind({})\n\nexport { Default }\n\n// eslint-disable-next-line import/no-default-export\nexport default StorybookEntry\n"],"mappings":"AAsBS,SAOH,KAPG;AAtBT,SAAS,kBAAkB;AAE3B,OAAO,aAAa;AAEpB,SAAS,6BAA6B;AACtC,SAAS,kBAAkB;AAE3B,MAAM,iBAAiB;AAAA,EACrB,UAAU,CAAC;AAAA,EACX,WAAW;AAAA,EACX,YAAY;AAAA,IACV,MAAM;AAAA,MACJ,MAAM;AAAA,IACR;AAAA,EACF;AAAA,EACA,OAAO;AACT;AAEA,MAAM,mBAAmB,MAAM;AAC7B,QAAM,EAAE,QAAQ,IAAI,WAAW;AAC/B,QAAM,eAAe,OAAO,SAAS,UAAU;AAE/C,SAAO,qBAAC,cAAW,OAAO,eAAe,UAAU,OAAO;AAAA;AAAA,IAAkB,eAAe,KAAK;AAAA,IAAM;AAAA,KAAoB;AAC5H;AAEA,MAAM,WAAkD,MAAM;AAC5D,QAAM,UAAU,IAAI,QAAQ;AAC5B,SACE,oBAAC,yBAAsB,SACrB,8BAAC,oBAAiB,GACpB;AAEJ;AAEA,MAAM,UAAU,SAAS,KAAK,CAAC,CAAC;AAKhC,IAAO,2BAAQ;","names":[]}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"State.d.ts","sourceRoot":"","sources":["../../../../src/contexts/ErrorReporter/State.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAA;AAE7B,MAAM,WAAW,yBAAyB;IACxC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"State.d.ts","sourceRoot":"","sources":["../../../../src/contexts/ErrorReporter/State.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAA;AAE7B,MAAM,WAAW,yBAAyB;IACxC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB"}
|
@@ -0,0 +1 @@
|
|
1
|
+
//# sourceMappingURL=State.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/contexts/ErrorReporter/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,SAAS,CAAA;AACvB,cAAc,cAAc,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/contexts/ErrorReporter/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,SAAS,CAAA;AACvB,cAAc,cAAc,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../src/contexts/ErrorReporter/index.ts"],"sourcesContent":["export * from './Provider'\nexport * from './State'\nexport * from './useRollbar'\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"useRollbar.d.ts","sourceRoot":"","sources":["../../../../src/contexts/ErrorReporter/useRollbar.tsx"],"names":[],"mappings":"AAIA,QAAA,MAAM,UAAU,mDAOf,CAAA;AAED,OAAO,EAAE,UAAU,EAAE,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"useRollbar.d.ts","sourceRoot":"","sources":["../../../../src/contexts/ErrorReporter/useRollbar.tsx"],"names":[],"mappings":"AAIA,QAAA,MAAM,UAAU,mDAOf,CAAA;AAED,OAAO,EAAE,UAAU,EAAE,CAAA"}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { useContext } from "react";
|
2
|
+
import { ErrorReporterContext } from "./Context";
|
3
|
+
const useRollbar = () => {
|
4
|
+
const context = useContext(ErrorReporterContext);
|
5
|
+
if (context === void 0) {
|
6
|
+
console.warn("useRollbar must be used within a ErrorReporterContext");
|
7
|
+
}
|
8
|
+
return context ?? {};
|
9
|
+
};
|
10
|
+
export {
|
11
|
+
useRollbar
|
12
|
+
};
|
13
|
+
//# sourceMappingURL=useRollbar.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../src/contexts/ErrorReporter/useRollbar.tsx"],"sourcesContent":["import { useContext } from 'react'\n\nimport { ErrorReporterContext } from './Context'\n\nconst useRollbar = () => {\n const context = useContext(ErrorReporterContext)\n if (context === undefined) {\n console.warn('useRollbar must be used within a ErrorReporterContext')\n }\n\n return context ?? {}\n}\n\nexport { useRollbar }\n"],"mappings":"AAAA,SAAS,kBAAkB;AAE3B,SAAS,4BAA4B;AAErC,MAAM,aAAa,MAAM;AACvB,QAAM,UAAU,WAAW,oBAAoB;AAC/C,MAAI,YAAY,QAAW;AACzB,YAAQ,KAAK,uDAAuD;AAAA,EACtE;AAEA,SAAO,WAAW,CAAC;AACrB;","names":[]}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/contexts/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/contexts/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../src/contexts/index.ts"],"sourcesContent":["export * from './ErrorReporter'\n"],"mappings":"AAAA,cAAc;","names":[]}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export * from './components'\nexport * from './contexts'\n"],"mappings":"AAAA,cAAc;AACd,cAAc;","names":[]}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import { ModuleError } from '@xyo-network/payload-model';
|
2
|
+
import { Component, ErrorInfo, ReactNode } from 'react';
|
3
|
+
import Rollbar from 'rollbar';
|
4
|
+
export interface ThrownErrorBoundaryProps {
|
5
|
+
boundaryName?: string;
|
6
|
+
children: ReactNode;
|
7
|
+
errorComponent?: (e: ModuleError, boundaryName?: string) => ReactNode;
|
8
|
+
rethrow?: boolean;
|
9
|
+
rollbar?: Rollbar;
|
10
|
+
}
|
11
|
+
export interface ThrownErrorBoundaryState {
|
12
|
+
xyoError?: ModuleError;
|
13
|
+
}
|
14
|
+
export declare class ThrownErrorBoundary extends Component<ThrownErrorBoundaryProps, ThrownErrorBoundaryState> {
|
15
|
+
state: ThrownErrorBoundaryState;
|
16
|
+
static getDerivedStateFromError(error: Error): ThrownErrorBoundaryState;
|
17
|
+
static normalizeError(error: Error | ModuleError): ModuleError;
|
18
|
+
componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
|
19
|
+
render(): string | number | boolean | import("react/jsx-runtime").JSX.Element | Iterable<ReactNode> | null | undefined;
|
20
|
+
}
|
21
|
+
//# sourceMappingURL=ThrownErrorBoundary.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ThrownErrorBoundary.d.ts","sourceRoot":"","sources":["../../../../src/components/ErrorBoundary/ThrownErrorBoundary.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAqB,MAAM,4BAA4B,CAAA;AAC3E,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACvD,OAAO,OAAO,MAAM,SAAS,CAAA;AAI7B,MAAM,WAAW,wBAAwB;IACvC,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,QAAQ,EAAE,SAAS,CAAA;IACnB,cAAc,CAAC,EAAE,CAAC,CAAC,EAAE,WAAW,EAAE,YAAY,CAAC,EAAE,MAAM,KAAK,SAAS,CAAA;IACrE,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,EAAE,WAAW,CAAA;CACvB;AAED,qBAAa,mBAAoB,SAAQ,SAAS,CAAC,wBAAwB,EAAE,wBAAwB,CAAC;IACpF,KAAK,EAAE,wBAAwB,CAE9C;IAED,MAAM,CAAC,wBAAwB,CAAC,KAAK,EAAE,KAAK;WAI9B,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,WAAW,GAAG,WAAW;IAMrD,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS;IAYpD,MAAM;CAYvB"}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import { ModuleError } from '@xyo-network/payload-model';
|
2
|
+
import { Component, ErrorInfo, ReactNode } from 'react';
|
3
|
+
import Rollbar from 'rollbar';
|
4
|
+
export interface ThrownErrorBoundaryProps {
|
5
|
+
boundaryName?: string;
|
6
|
+
children: ReactNode;
|
7
|
+
errorComponent?: (e: ModuleError, boundaryName?: string) => ReactNode;
|
8
|
+
rethrow?: boolean;
|
9
|
+
rollbar?: Rollbar;
|
10
|
+
}
|
11
|
+
export interface ThrownErrorBoundaryState {
|
12
|
+
xyoError?: ModuleError;
|
13
|
+
}
|
14
|
+
export declare class ThrownErrorBoundary extends Component<ThrownErrorBoundaryProps, ThrownErrorBoundaryState> {
|
15
|
+
state: ThrownErrorBoundaryState;
|
16
|
+
static getDerivedStateFromError(error: Error): ThrownErrorBoundaryState;
|
17
|
+
static normalizeError(error: Error | ModuleError): ModuleError;
|
18
|
+
componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
|
19
|
+
render(): string | number | boolean | import("react/jsx-runtime").JSX.Element | Iterable<ReactNode> | null | undefined;
|
20
|
+
}
|
21
|
+
//# sourceMappingURL=ThrownErrorBoundary.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ThrownErrorBoundary.d.ts","sourceRoot":"","sources":["../../../../src/components/ErrorBoundary/ThrownErrorBoundary.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAqB,MAAM,4BAA4B,CAAA;AAC3E,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACvD,OAAO,OAAO,MAAM,SAAS,CAAA;AAI7B,MAAM,WAAW,wBAAwB;IACvC,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,QAAQ,EAAE,SAAS,CAAA;IACnB,cAAc,CAAC,EAAE,CAAC,CAAC,EAAE,WAAW,EAAE,YAAY,CAAC,EAAE,MAAM,KAAK,SAAS,CAAA;IACrE,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,EAAE,WAAW,CAAA;CACvB;AAED,qBAAa,mBAAoB,SAAQ,SAAS,CAAC,wBAAwB,EAAE,wBAAwB,CAAC;IACpF,KAAK,EAAE,wBAAwB,CAE9C;IAED,MAAM,CAAC,wBAAwB,CAAC,KAAK,EAAE,KAAK;WAI9B,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,WAAW,GAAG,WAAW;IAMrD,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS;IAYpD,MAAM;CAYvB"}
|
@@ -0,0 +1,63 @@
|
|
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
|
+
var ThrownErrorBoundary_exports = {};
|
20
|
+
__export(ThrownErrorBoundary_exports, {
|
21
|
+
ThrownErrorBoundary: () => ThrownErrorBoundary
|
22
|
+
});
|
23
|
+
module.exports = __toCommonJS(ThrownErrorBoundary_exports);
|
24
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
25
|
+
var import_payload_model = require("@xyo-network/payload-model");
|
26
|
+
var import_react = require("react");
|
27
|
+
var import_ErrorRender = require("../ErrorRender");
|
28
|
+
class ThrownErrorBoundary extends import_react.Component {
|
29
|
+
state = {
|
30
|
+
xyoError: void 0
|
31
|
+
};
|
32
|
+
static getDerivedStateFromError(error) {
|
33
|
+
return { hasError: true, xyoError: ThrownErrorBoundary.normalizeError(error) };
|
34
|
+
}
|
35
|
+
static normalizeError(error) {
|
36
|
+
return error.schema === import_payload_model.ModuleErrorSchema ? error : { message: error.message, schema: import_payload_model.ModuleErrorSchema, sources: [] };
|
37
|
+
}
|
38
|
+
componentDidCatch(error, errorInfo) {
|
39
|
+
const { rethrow, rollbar } = this.props;
|
40
|
+
const { xyoError } = this.state;
|
41
|
+
rollbar?.error(error);
|
42
|
+
console.error("Error:", xyoError, errorInfo);
|
43
|
+
if (rethrow) {
|
44
|
+
throw error;
|
45
|
+
}
|
46
|
+
}
|
47
|
+
render() {
|
48
|
+
const { xyoError } = this.state;
|
49
|
+
const { children, boundaryName, errorComponent } = this.props;
|
50
|
+
if (xyoError) {
|
51
|
+
if (errorComponent) {
|
52
|
+
return errorComponent(xyoError);
|
53
|
+
}
|
54
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ErrorRender.ErrorRender, { error: xyoError, errorContext: `${boundaryName} Boundary` });
|
55
|
+
}
|
56
|
+
return children;
|
57
|
+
}
|
58
|
+
}
|
59
|
+
// Annotate the CommonJS export names for ESM import in node:
|
60
|
+
0 && (module.exports = {
|
61
|
+
ThrownErrorBoundary
|
62
|
+
});
|
63
|
+
//# sourceMappingURL=ThrownErrorBoundary.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/ErrorBoundary/ThrownErrorBoundary.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"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAoDa;AApDb,2BAA+C;AAC/C,mBAAgD;AAGhD,yBAA4B;AAcrB,MAAM,4BAA4B,uBAA8D;AAAA,EACrF,QAAkC;AAAA,IAChD,UAAU;AAAA,EACZ;AAAA,EAEA,OAAO,yBAAyB,OAAc;AAC5C,WAAO,EAAE,UAAU,MAAM,UAAU,oBAAoB,eAAe,KAAK,EAAE;AAAA,EAC/E;AAAA,EAEA,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,4CAAC,kCAAY,OAAO,UAAU,cAAc,GAAG,YAAY,aAAa;AAAA,IACjF;AAEA,WAAO;AAAA,EACT;AACF;","names":[]}
|
@@ -0,0 +1,39 @@
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
2
|
+
import { ModuleErrorSchema } from "@xyo-network/payload-model";
|
3
|
+
import { Component } from "react";
|
4
|
+
import { ErrorRender } from "../ErrorRender";
|
5
|
+
class ThrownErrorBoundary extends Component {
|
6
|
+
state = {
|
7
|
+
xyoError: void 0
|
8
|
+
};
|
9
|
+
static getDerivedStateFromError(error) {
|
10
|
+
return { hasError: true, xyoError: ThrownErrorBoundary.normalizeError(error) };
|
11
|
+
}
|
12
|
+
static normalizeError(error) {
|
13
|
+
return error.schema === ModuleErrorSchema ? error : { message: error.message, schema: ModuleErrorSchema, sources: [] };
|
14
|
+
}
|
15
|
+
componentDidCatch(error, errorInfo) {
|
16
|
+
const { rethrow, rollbar } = this.props;
|
17
|
+
const { xyoError } = this.state;
|
18
|
+
rollbar?.error(error);
|
19
|
+
console.error("Error:", xyoError, errorInfo);
|
20
|
+
if (rethrow) {
|
21
|
+
throw error;
|
22
|
+
}
|
23
|
+
}
|
24
|
+
render() {
|
25
|
+
const { xyoError } = this.state;
|
26
|
+
const { children, boundaryName, errorComponent } = this.props;
|
27
|
+
if (xyoError) {
|
28
|
+
if (errorComponent) {
|
29
|
+
return errorComponent(xyoError);
|
30
|
+
}
|
31
|
+
return /* @__PURE__ */ jsx(ErrorRender, { error: xyoError, errorContext: `${boundaryName} Boundary` });
|
32
|
+
}
|
33
|
+
return children;
|
34
|
+
}
|
35
|
+
}
|
36
|
+
export {
|
37
|
+
ThrownErrorBoundary
|
38
|
+
};
|
39
|
+
//# sourceMappingURL=ThrownErrorBoundary.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/ErrorBoundary/ThrownErrorBoundary.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"],"mappings":"AAoDa;AApDb,SAAsB,yBAAyB;AAC/C,SAAS,iBAAuC;AAGhD,SAAS,mBAAmB;AAcrB,MAAM,4BAA4B,UAA8D;AAAA,EACrF,QAAkC;AAAA,IAChD,UAAU;AAAA,EACZ;AAAA,EAEA,OAAO,yBAAyB,OAAc;AAC5C,WAAO,EAAE,UAAU,MAAM,UAAU,oBAAoB,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,oBAAC,eAAY,OAAO,UAAU,cAAc,GAAG,YAAY,aAAa;AAAA,IACjF;AAEA,WAAO;AAAA,EACT;AACF;","names":[]}
|