@xyo-network/react-error 2.82.0 → 2.83.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/browser/index.d.ts +62 -3
- package/package.json +7 -23
- package/xy.config.ts +12 -0
- package/dist/browser/components/ErrorBoundary/ThrownErrorBoundary.d.cts +0 -23
- package/dist/browser/components/ErrorBoundary/ThrownErrorBoundary.d.cts.map +0 -1
- package/dist/browser/components/ErrorBoundary/ThrownErrorBoundary.d.mts +0 -23
- package/dist/browser/components/ErrorBoundary/ThrownErrorBoundary.d.mts.map +0 -1
- package/dist/browser/components/ErrorBoundary/ThrownErrorBoundary.d.ts +0 -23
- package/dist/browser/components/ErrorBoundary/ThrownErrorBoundary.d.ts.map +0 -1
- package/dist/browser/components/ErrorBoundary/index.d.cts +0 -2
- package/dist/browser/components/ErrorBoundary/index.d.cts.map +0 -1
- package/dist/browser/components/ErrorBoundary/index.d.mts +0 -2
- package/dist/browser/components/ErrorBoundary/index.d.mts.map +0 -1
- package/dist/browser/components/ErrorBoundary/index.d.ts +0 -2
- package/dist/browser/components/ErrorBoundary/index.d.ts.map +0 -1
- package/dist/browser/components/ErrorRender/ErrorAlert.d.cts +0 -11
- package/dist/browser/components/ErrorRender/ErrorAlert.d.cts.map +0 -1
- package/dist/browser/components/ErrorRender/ErrorAlert.d.mts +0 -11
- package/dist/browser/components/ErrorRender/ErrorAlert.d.mts.map +0 -1
- package/dist/browser/components/ErrorRender/ErrorAlert.d.ts +0 -11
- package/dist/browser/components/ErrorRender/ErrorAlert.d.ts.map +0 -1
- package/dist/browser/components/ErrorRender/Props.d.cts +0 -15
- package/dist/browser/components/ErrorRender/Props.d.cts.map +0 -1
- package/dist/browser/components/ErrorRender/Props.d.mts +0 -15
- package/dist/browser/components/ErrorRender/Props.d.mts.map +0 -1
- package/dist/browser/components/ErrorRender/Props.d.ts +0 -15
- package/dist/browser/components/ErrorRender/Props.d.ts.map +0 -1
- package/dist/browser/components/ErrorRender/Render.d.cts +0 -4
- package/dist/browser/components/ErrorRender/Render.d.cts.map +0 -1
- package/dist/browser/components/ErrorRender/Render.d.mts +0 -4
- package/dist/browser/components/ErrorRender/Render.d.mts.map +0 -1
- package/dist/browser/components/ErrorRender/Render.d.ts +0 -4
- package/dist/browser/components/ErrorRender/Render.d.ts.map +0 -1
- package/dist/browser/components/ErrorRender/index.d.cts +0 -4
- package/dist/browser/components/ErrorRender/index.d.cts.map +0 -1
- package/dist/browser/components/ErrorRender/index.d.mts +0 -4
- package/dist/browser/components/ErrorRender/index.d.mts.map +0 -1
- package/dist/browser/components/ErrorRender/index.d.ts +0 -4
- package/dist/browser/components/ErrorRender/index.d.ts.map +0 -1
- package/dist/browser/components/index.d.cts +0 -3
- package/dist/browser/components/index.d.cts.map +0 -1
- package/dist/browser/components/index.d.mts +0 -3
- package/dist/browser/components/index.d.mts.map +0 -1
- package/dist/browser/components/index.d.ts +0 -3
- package/dist/browser/components/index.d.ts.map +0 -1
- package/dist/browser/contexts/ErrorReporter/Context.d.cts +0 -3
- package/dist/browser/contexts/ErrorReporter/Context.d.cts.map +0 -1
- package/dist/browser/contexts/ErrorReporter/Context.d.mts +0 -3
- package/dist/browser/contexts/ErrorReporter/Context.d.mts.map +0 -1
- package/dist/browser/contexts/ErrorReporter/Context.d.ts +0 -3
- package/dist/browser/contexts/ErrorReporter/Context.d.ts.map +0 -1
- package/dist/browser/contexts/ErrorReporter/Provider.d.cts +0 -9
- package/dist/browser/contexts/ErrorReporter/Provider.d.cts.map +0 -1
- package/dist/browser/contexts/ErrorReporter/Provider.d.mts +0 -9
- package/dist/browser/contexts/ErrorReporter/Provider.d.mts.map +0 -1
- package/dist/browser/contexts/ErrorReporter/Provider.d.ts +0 -9
- package/dist/browser/contexts/ErrorReporter/Provider.d.ts.map +0 -1
- package/dist/browser/contexts/ErrorReporter/State.d.cts +0 -5
- package/dist/browser/contexts/ErrorReporter/State.d.cts.map +0 -1
- package/dist/browser/contexts/ErrorReporter/State.d.mts +0 -5
- package/dist/browser/contexts/ErrorReporter/State.d.mts.map +0 -1
- package/dist/browser/contexts/ErrorReporter/State.d.ts +0 -5
- package/dist/browser/contexts/ErrorReporter/State.d.ts.map +0 -1
- package/dist/browser/contexts/ErrorReporter/index.d.cts +0 -4
- package/dist/browser/contexts/ErrorReporter/index.d.cts.map +0 -1
- package/dist/browser/contexts/ErrorReporter/index.d.mts +0 -4
- package/dist/browser/contexts/ErrorReporter/index.d.mts.map +0 -1
- package/dist/browser/contexts/ErrorReporter/index.d.ts +0 -4
- package/dist/browser/contexts/ErrorReporter/index.d.ts.map +0 -1
- package/dist/browser/contexts/ErrorReporter/useRollbar.d.cts +0 -3
- package/dist/browser/contexts/ErrorReporter/useRollbar.d.cts.map +0 -1
- package/dist/browser/contexts/ErrorReporter/useRollbar.d.mts +0 -3
- package/dist/browser/contexts/ErrorReporter/useRollbar.d.mts.map +0 -1
- package/dist/browser/contexts/ErrorReporter/useRollbar.d.ts +0 -3
- package/dist/browser/contexts/ErrorReporter/useRollbar.d.ts.map +0 -1
- package/dist/browser/contexts/index.d.cts +0 -2
- package/dist/browser/contexts/index.d.cts.map +0 -1
- package/dist/browser/contexts/index.d.mts +0 -2
- package/dist/browser/contexts/index.d.mts.map +0 -1
- package/dist/browser/contexts/index.d.ts +0 -2
- package/dist/browser/contexts/index.d.ts.map +0 -1
- package/dist/browser/index.cjs +0 -194
- package/dist/browser/index.cjs.map +0 -1
- package/dist/browser/index.d.cts +0 -3
- package/dist/browser/index.d.cts.map +0 -1
- package/dist/browser/index.d.mts +0 -3
- package/dist/browser/index.d.mts.map +0 -1
- package/dist/browser/index.d.ts.map +0 -1
- package/dist/neutral/components/ErrorBoundary/ThrownErrorBoundary.d.cts +0 -23
- package/dist/neutral/components/ErrorBoundary/ThrownErrorBoundary.d.cts.map +0 -1
- package/dist/neutral/components/ErrorBoundary/ThrownErrorBoundary.d.mts +0 -23
- package/dist/neutral/components/ErrorBoundary/ThrownErrorBoundary.d.mts.map +0 -1
- package/dist/neutral/components/ErrorBoundary/ThrownErrorBoundary.d.ts +0 -23
- package/dist/neutral/components/ErrorBoundary/ThrownErrorBoundary.d.ts.map +0 -1
- package/dist/neutral/components/ErrorBoundary/index.d.cts +0 -2
- package/dist/neutral/components/ErrorBoundary/index.d.cts.map +0 -1
- package/dist/neutral/components/ErrorBoundary/index.d.mts +0 -2
- package/dist/neutral/components/ErrorBoundary/index.d.mts.map +0 -1
- package/dist/neutral/components/ErrorBoundary/index.d.ts +0 -2
- package/dist/neutral/components/ErrorBoundary/index.d.ts.map +0 -1
- package/dist/neutral/components/ErrorRender/ErrorAlert.d.cts +0 -11
- package/dist/neutral/components/ErrorRender/ErrorAlert.d.cts.map +0 -1
- package/dist/neutral/components/ErrorRender/ErrorAlert.d.mts +0 -11
- package/dist/neutral/components/ErrorRender/ErrorAlert.d.mts.map +0 -1
- package/dist/neutral/components/ErrorRender/ErrorAlert.d.ts +0 -11
- package/dist/neutral/components/ErrorRender/ErrorAlert.d.ts.map +0 -1
- package/dist/neutral/components/ErrorRender/Props.d.cts +0 -15
- package/dist/neutral/components/ErrorRender/Props.d.cts.map +0 -1
- package/dist/neutral/components/ErrorRender/Props.d.mts +0 -15
- package/dist/neutral/components/ErrorRender/Props.d.mts.map +0 -1
- package/dist/neutral/components/ErrorRender/Props.d.ts +0 -15
- package/dist/neutral/components/ErrorRender/Props.d.ts.map +0 -1
- package/dist/neutral/components/ErrorRender/Render.d.cts +0 -4
- package/dist/neutral/components/ErrorRender/Render.d.cts.map +0 -1
- package/dist/neutral/components/ErrorRender/Render.d.mts +0 -4
- package/dist/neutral/components/ErrorRender/Render.d.mts.map +0 -1
- package/dist/neutral/components/ErrorRender/Render.d.ts +0 -4
- package/dist/neutral/components/ErrorRender/Render.d.ts.map +0 -1
- package/dist/neutral/components/ErrorRender/index.d.cts +0 -4
- package/dist/neutral/components/ErrorRender/index.d.cts.map +0 -1
- package/dist/neutral/components/ErrorRender/index.d.mts +0 -4
- package/dist/neutral/components/ErrorRender/index.d.mts.map +0 -1
- package/dist/neutral/components/ErrorRender/index.d.ts +0 -4
- package/dist/neutral/components/ErrorRender/index.d.ts.map +0 -1
- package/dist/neutral/components/index.d.cts +0 -3
- package/dist/neutral/components/index.d.cts.map +0 -1
- package/dist/neutral/components/index.d.mts +0 -3
- package/dist/neutral/components/index.d.mts.map +0 -1
- package/dist/neutral/components/index.d.ts +0 -3
- package/dist/neutral/components/index.d.ts.map +0 -1
- package/dist/neutral/contexts/ErrorReporter/Context.d.cts +0 -3
- package/dist/neutral/contexts/ErrorReporter/Context.d.cts.map +0 -1
- package/dist/neutral/contexts/ErrorReporter/Context.d.mts +0 -3
- package/dist/neutral/contexts/ErrorReporter/Context.d.mts.map +0 -1
- package/dist/neutral/contexts/ErrorReporter/Context.d.ts +0 -3
- package/dist/neutral/contexts/ErrorReporter/Context.d.ts.map +0 -1
- package/dist/neutral/contexts/ErrorReporter/Provider.d.cts +0 -9
- package/dist/neutral/contexts/ErrorReporter/Provider.d.cts.map +0 -1
- package/dist/neutral/contexts/ErrorReporter/Provider.d.mts +0 -9
- package/dist/neutral/contexts/ErrorReporter/Provider.d.mts.map +0 -1
- package/dist/neutral/contexts/ErrorReporter/Provider.d.ts +0 -9
- package/dist/neutral/contexts/ErrorReporter/Provider.d.ts.map +0 -1
- package/dist/neutral/contexts/ErrorReporter/State.d.cts +0 -5
- package/dist/neutral/contexts/ErrorReporter/State.d.cts.map +0 -1
- package/dist/neutral/contexts/ErrorReporter/State.d.mts +0 -5
- package/dist/neutral/contexts/ErrorReporter/State.d.mts.map +0 -1
- package/dist/neutral/contexts/ErrorReporter/State.d.ts +0 -5
- package/dist/neutral/contexts/ErrorReporter/State.d.ts.map +0 -1
- package/dist/neutral/contexts/ErrorReporter/index.d.cts +0 -4
- package/dist/neutral/contexts/ErrorReporter/index.d.cts.map +0 -1
- package/dist/neutral/contexts/ErrorReporter/index.d.mts +0 -4
- package/dist/neutral/contexts/ErrorReporter/index.d.mts.map +0 -1
- package/dist/neutral/contexts/ErrorReporter/index.d.ts +0 -4
- package/dist/neutral/contexts/ErrorReporter/index.d.ts.map +0 -1
- package/dist/neutral/contexts/ErrorReporter/useRollbar.d.cts +0 -3
- package/dist/neutral/contexts/ErrorReporter/useRollbar.d.cts.map +0 -1
- package/dist/neutral/contexts/ErrorReporter/useRollbar.d.mts +0 -3
- package/dist/neutral/contexts/ErrorReporter/useRollbar.d.mts.map +0 -1
- package/dist/neutral/contexts/ErrorReporter/useRollbar.d.ts +0 -3
- package/dist/neutral/contexts/ErrorReporter/useRollbar.d.ts.map +0 -1
- package/dist/neutral/contexts/index.d.cts +0 -2
- package/dist/neutral/contexts/index.d.cts.map +0 -1
- package/dist/neutral/contexts/index.d.mts +0 -2
- package/dist/neutral/contexts/index.d.mts.map +0 -1
- package/dist/neutral/contexts/index.d.ts +0 -2
- package/dist/neutral/contexts/index.d.ts.map +0 -1
- package/dist/neutral/index.cjs +0 -194
- package/dist/neutral/index.cjs.map +0 -1
- package/dist/neutral/index.d.cts +0 -3
- package/dist/neutral/index.d.cts.map +0 -1
- package/dist/neutral/index.d.mts +0 -3
- package/dist/neutral/index.d.mts.map +0 -1
- package/dist/neutral/index.d.ts +0 -3
- package/dist/neutral/index.d.ts.map +0 -1
- package/dist/neutral/index.mjs +0 -163
- package/dist/neutral/index.mjs.map +0 -1
- package/dist/node/components/ErrorBoundary/ThrownErrorBoundary.d.cts +0 -23
- package/dist/node/components/ErrorBoundary/ThrownErrorBoundary.d.cts.map +0 -1
- package/dist/node/components/ErrorBoundary/ThrownErrorBoundary.d.mts +0 -23
- package/dist/node/components/ErrorBoundary/ThrownErrorBoundary.d.mts.map +0 -1
- package/dist/node/components/ErrorBoundary/ThrownErrorBoundary.d.ts +0 -23
- package/dist/node/components/ErrorBoundary/ThrownErrorBoundary.d.ts.map +0 -1
- package/dist/node/components/ErrorBoundary/index.d.cts +0 -2
- package/dist/node/components/ErrorBoundary/index.d.cts.map +0 -1
- package/dist/node/components/ErrorBoundary/index.d.mts +0 -2
- package/dist/node/components/ErrorBoundary/index.d.mts.map +0 -1
- package/dist/node/components/ErrorBoundary/index.d.ts +0 -2
- package/dist/node/components/ErrorBoundary/index.d.ts.map +0 -1
- package/dist/node/components/ErrorRender/ErrorAlert.d.cts +0 -11
- package/dist/node/components/ErrorRender/ErrorAlert.d.cts.map +0 -1
- package/dist/node/components/ErrorRender/ErrorAlert.d.mts +0 -11
- package/dist/node/components/ErrorRender/ErrorAlert.d.mts.map +0 -1
- package/dist/node/components/ErrorRender/ErrorAlert.d.ts +0 -11
- package/dist/node/components/ErrorRender/ErrorAlert.d.ts.map +0 -1
- package/dist/node/components/ErrorRender/Props.d.cts +0 -15
- package/dist/node/components/ErrorRender/Props.d.cts.map +0 -1
- package/dist/node/components/ErrorRender/Props.d.mts +0 -15
- package/dist/node/components/ErrorRender/Props.d.mts.map +0 -1
- package/dist/node/components/ErrorRender/Props.d.ts +0 -15
- package/dist/node/components/ErrorRender/Props.d.ts.map +0 -1
- package/dist/node/components/ErrorRender/Render.d.cts +0 -4
- package/dist/node/components/ErrorRender/Render.d.cts.map +0 -1
- package/dist/node/components/ErrorRender/Render.d.mts +0 -4
- package/dist/node/components/ErrorRender/Render.d.mts.map +0 -1
- package/dist/node/components/ErrorRender/Render.d.ts +0 -4
- package/dist/node/components/ErrorRender/Render.d.ts.map +0 -1
- package/dist/node/components/ErrorRender/index.d.cts +0 -4
- package/dist/node/components/ErrorRender/index.d.cts.map +0 -1
- package/dist/node/components/ErrorRender/index.d.mts +0 -4
- package/dist/node/components/ErrorRender/index.d.mts.map +0 -1
- package/dist/node/components/ErrorRender/index.d.ts +0 -4
- package/dist/node/components/ErrorRender/index.d.ts.map +0 -1
- package/dist/node/components/index.d.cts +0 -3
- package/dist/node/components/index.d.cts.map +0 -1
- package/dist/node/components/index.d.mts +0 -3
- package/dist/node/components/index.d.mts.map +0 -1
- package/dist/node/components/index.d.ts +0 -3
- package/dist/node/components/index.d.ts.map +0 -1
- package/dist/node/contexts/ErrorReporter/Context.d.cts +0 -3
- package/dist/node/contexts/ErrorReporter/Context.d.cts.map +0 -1
- package/dist/node/contexts/ErrorReporter/Context.d.mts +0 -3
- package/dist/node/contexts/ErrorReporter/Context.d.mts.map +0 -1
- package/dist/node/contexts/ErrorReporter/Context.d.ts +0 -3
- package/dist/node/contexts/ErrorReporter/Context.d.ts.map +0 -1
- package/dist/node/contexts/ErrorReporter/Provider.d.cts +0 -9
- package/dist/node/contexts/ErrorReporter/Provider.d.cts.map +0 -1
- package/dist/node/contexts/ErrorReporter/Provider.d.mts +0 -9
- package/dist/node/contexts/ErrorReporter/Provider.d.mts.map +0 -1
- package/dist/node/contexts/ErrorReporter/Provider.d.ts +0 -9
- package/dist/node/contexts/ErrorReporter/Provider.d.ts.map +0 -1
- package/dist/node/contexts/ErrorReporter/State.d.cts +0 -5
- package/dist/node/contexts/ErrorReporter/State.d.cts.map +0 -1
- package/dist/node/contexts/ErrorReporter/State.d.mts +0 -5
- package/dist/node/contexts/ErrorReporter/State.d.mts.map +0 -1
- package/dist/node/contexts/ErrorReporter/State.d.ts +0 -5
- package/dist/node/contexts/ErrorReporter/State.d.ts.map +0 -1
- package/dist/node/contexts/ErrorReporter/index.d.cts +0 -4
- package/dist/node/contexts/ErrorReporter/index.d.cts.map +0 -1
- package/dist/node/contexts/ErrorReporter/index.d.mts +0 -4
- package/dist/node/contexts/ErrorReporter/index.d.mts.map +0 -1
- package/dist/node/contexts/ErrorReporter/index.d.ts +0 -4
- package/dist/node/contexts/ErrorReporter/index.d.ts.map +0 -1
- package/dist/node/contexts/ErrorReporter/useRollbar.d.cts +0 -3
- package/dist/node/contexts/ErrorReporter/useRollbar.d.cts.map +0 -1
- package/dist/node/contexts/ErrorReporter/useRollbar.d.mts +0 -3
- package/dist/node/contexts/ErrorReporter/useRollbar.d.mts.map +0 -1
- package/dist/node/contexts/ErrorReporter/useRollbar.d.ts +0 -3
- package/dist/node/contexts/ErrorReporter/useRollbar.d.ts.map +0 -1
- package/dist/node/contexts/index.d.cts +0 -2
- package/dist/node/contexts/index.d.cts.map +0 -1
- package/dist/node/contexts/index.d.mts +0 -2
- package/dist/node/contexts/index.d.mts.map +0 -1
- package/dist/node/contexts/index.d.ts +0 -2
- package/dist/node/contexts/index.d.ts.map +0 -1
- package/dist/node/index.cjs +0 -201
- package/dist/node/index.cjs.map +0 -1
- package/dist/node/index.d.cts +0 -3
- package/dist/node/index.d.cts.map +0 -1
- package/dist/node/index.d.mts +0 -3
- package/dist/node/index.d.mts.map +0 -1
- package/dist/node/index.d.ts +0 -3
- package/dist/node/index.d.ts.map +0 -1
- package/dist/node/index.mjs +0 -162
- package/dist/node/index.mjs.map +0 -1
package/dist/node/index.cjs
DELETED
@@ -1,201 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __create = Object.create;
|
3
|
-
var __defProp = Object.defineProperty;
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
9
|
-
var __export = (target, all) => {
|
10
|
-
for (var name in all)
|
11
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
12
|
-
};
|
13
|
-
var __copyProps = (to, from, except, desc) => {
|
14
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
15
|
-
for (let key of __getOwnPropNames(from))
|
16
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
17
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
18
|
-
}
|
19
|
-
return to;
|
20
|
-
};
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
22
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
23
|
-
// file that has been converted to a CommonJS file using a Babel-
|
24
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
25
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
26
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
27
|
-
mod
|
28
|
-
));
|
29
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
30
|
-
|
31
|
-
// src/index.ts
|
32
|
-
var src_exports = {};
|
33
|
-
__export(src_exports, {
|
34
|
-
ErrorAlert: () => ErrorAlert,
|
35
|
-
ErrorRender: () => ErrorRender,
|
36
|
-
ErrorReporterProvider: () => ErrorReporterProvider,
|
37
|
-
ThrownErrorBoundary: () => ThrownErrorBoundary,
|
38
|
-
useRollbar: () => useRollbar
|
39
|
-
});
|
40
|
-
module.exports = __toCommonJS(src_exports);
|
41
|
-
|
42
|
-
// src/components/ErrorBoundary/ThrownErrorBoundary.tsx
|
43
|
-
var import_payload_model = require("@xyo-network/payload-model");
|
44
|
-
var import_react3 = __toESM(require("react"), 1);
|
45
|
-
|
46
|
-
// src/components/ErrorRender/ErrorAlert.tsx
|
47
|
-
var import_icons_material = require("@mui/icons-material");
|
48
|
-
var import_material = require("@mui/material");
|
49
|
-
var import_react_button = require("@xylabs/react-button");
|
50
|
-
var import_react = __toESM(require("react"), 1);
|
51
|
-
var ErrorAlert = /* @__PURE__ */ __name(({ title = "Whoops! Something went wrong", onCancel, error = "An unknown error occurred", errorContext, scope, ...props }) => {
|
52
|
-
const finalScope = scope ?? errorContext;
|
53
|
-
return /* @__PURE__ */ import_react.default.createElement(import_material.Alert, {
|
54
|
-
severity: "error",
|
55
|
-
...props
|
56
|
-
}, /* @__PURE__ */ import_react.default.createElement(import_material.AlertTitle, null, title), finalScope ? /* @__PURE__ */ import_react.default.createElement("div", null, /* @__PURE__ */ import_react.default.createElement(import_material.Typography, {
|
57
|
-
variant: "caption",
|
58
|
-
mr: 0.5,
|
59
|
-
fontWeight: "bold"
|
60
|
-
}, "Scope:"), /* @__PURE__ */ import_react.default.createElement(import_material.Typography, {
|
61
|
-
variant: "caption"
|
62
|
-
}, finalScope)) : null, /* @__PURE__ */ import_react.default.createElement("div", null, /* @__PURE__ */ import_react.default.createElement(import_material.Typography, {
|
63
|
-
variant: "caption",
|
64
|
-
mr: 0.5,
|
65
|
-
fontWeight: "bold"
|
66
|
-
}, "Error:"), /* @__PURE__ */ import_react.default.createElement(import_material.Typography, {
|
67
|
-
variant: "caption"
|
68
|
-
}, typeof error === "string" ? error : error == null ? void 0 : error.message)), onCancel ? /* @__PURE__ */ import_react.default.createElement(import_react_button.ButtonEx, {
|
69
|
-
variant: "outlined",
|
70
|
-
size: "small",
|
71
|
-
onClick: onCancel,
|
72
|
-
position: "absolute",
|
73
|
-
style: {
|
74
|
-
right: 8,
|
75
|
-
top: 8
|
76
|
-
}
|
77
|
-
}, /* @__PURE__ */ import_react.default.createElement(import_icons_material.ExitToApp, {
|
78
|
-
fontSize: "small"
|
79
|
-
})) : null);
|
80
|
-
}, "ErrorAlert");
|
81
|
-
|
82
|
-
// src/components/ErrorRender/Render.tsx
|
83
|
-
var import_react_flexbox = require("@xylabs/react-flexbox");
|
84
|
-
var import_react2 = __toESM(require("react"), 1);
|
85
|
-
var ErrorRender = /* @__PURE__ */ __name(({ onCancel, error, noErrorDisplay = false, customError = null, children, errorContext, scope, useLocation, ...props }) => {
|
86
|
-
const location = useLocation == null ? void 0 : useLocation();
|
87
|
-
(0, import_react2.useEffect)(() => {
|
88
|
-
if (location) {
|
89
|
-
location.state = {
|
90
|
-
from: {
|
91
|
-
pathname: window.location.pathname
|
92
|
-
}
|
93
|
-
};
|
94
|
-
}
|
95
|
-
}, [
|
96
|
-
location
|
97
|
-
]);
|
98
|
-
return error ? /* @__PURE__ */ import_react2.default.createElement(import_react_flexbox.FlexCol, {
|
99
|
-
alignItems: "stretch",
|
100
|
-
...props
|
101
|
-
}, noErrorDisplay ? customError : /* @__PURE__ */ import_react2.default.createElement(import_react_flexbox.FlexCol, {
|
102
|
-
alignItems: "center",
|
103
|
-
...props
|
104
|
-
}, /* @__PURE__ */ import_react2.default.createElement(ErrorAlert, {
|
105
|
-
error,
|
106
|
-
errorContext,
|
107
|
-
onCancel,
|
108
|
-
scope
|
109
|
-
}))) : /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, children) ?? null;
|
110
|
-
}, "ErrorRender");
|
111
|
-
|
112
|
-
// src/components/ErrorBoundary/ThrownErrorBoundary.tsx
|
113
|
-
var _ThrownErrorBoundary = class _ThrownErrorBoundary extends import_react3.Component {
|
114
|
-
state = {
|
115
|
-
xyoError: void 0
|
116
|
-
};
|
117
|
-
static getDerivedStateFromError(error) {
|
118
|
-
return {
|
119
|
-
hasError: true,
|
120
|
-
xyoError: _ThrownErrorBoundary.normalizeError(error)
|
121
|
-
};
|
122
|
-
}
|
123
|
-
static normalizeError(error) {
|
124
|
-
return error.schema === import_payload_model.ModuleErrorSchema ? error : {
|
125
|
-
message: error.message,
|
126
|
-
schema: import_payload_model.ModuleErrorSchema,
|
127
|
-
sources: []
|
128
|
-
};
|
129
|
-
}
|
130
|
-
componentDidCatch(error, errorInfo) {
|
131
|
-
const { rethrow, rollbar } = this.props;
|
132
|
-
const { xyoError } = this.state;
|
133
|
-
rollbar == null ? void 0 : rollbar.error(error);
|
134
|
-
console.error("Error:", xyoError, errorInfo);
|
135
|
-
if (rethrow) {
|
136
|
-
throw error;
|
137
|
-
}
|
138
|
-
}
|
139
|
-
render() {
|
140
|
-
const { xyoError } = this.state;
|
141
|
-
const { children, boundaryName, errorComponent, scope, title } = this.props;
|
142
|
-
if (xyoError) {
|
143
|
-
if (errorComponent) {
|
144
|
-
return errorComponent(xyoError);
|
145
|
-
}
|
146
|
-
return /* @__PURE__ */ import_react3.default.createElement(ErrorRender, {
|
147
|
-
error: xyoError,
|
148
|
-
errorContext: `${boundaryName} Boundary`,
|
149
|
-
scope,
|
150
|
-
title
|
151
|
-
});
|
152
|
-
}
|
153
|
-
return children;
|
154
|
-
}
|
155
|
-
};
|
156
|
-
__name(_ThrownErrorBoundary, "ThrownErrorBoundary");
|
157
|
-
var ThrownErrorBoundary = _ThrownErrorBoundary;
|
158
|
-
|
159
|
-
// src/contexts/ErrorReporter/Provider.tsx
|
160
|
-
var import_react5 = __toESM(require("react"), 1);
|
161
|
-
|
162
|
-
// src/contexts/ErrorReporter/Context.ts
|
163
|
-
var import_react4 = require("react");
|
164
|
-
var ErrorReporterContext = (0, import_react4.createContext)({});
|
165
|
-
|
166
|
-
// src/contexts/ErrorReporter/Provider.tsx
|
167
|
-
var ErrorReporterProvider = /* @__PURE__ */ __name(({ children, rollbar }) => {
|
168
|
-
const [rollbarInstance, setRollBarInstance] = (0, import_react5.useState)();
|
169
|
-
(0, import_react5.useEffect)(() => {
|
170
|
-
if (rollbarInstance) {
|
171
|
-
setRollBarInstance(rollbarInstance);
|
172
|
-
}
|
173
|
-
}, [
|
174
|
-
rollbar,
|
175
|
-
rollbarInstance
|
176
|
-
]);
|
177
|
-
return /* @__PURE__ */ import_react5.default.createElement(ErrorReporterContext.Provider, {
|
178
|
-
value: {
|
179
|
-
rollbar
|
180
|
-
}
|
181
|
-
}, children);
|
182
|
-
}, "ErrorReporterProvider");
|
183
|
-
|
184
|
-
// src/contexts/ErrorReporter/useRollbar.tsx
|
185
|
-
var import_react6 = require("react");
|
186
|
-
var useRollbar = /* @__PURE__ */ __name(() => {
|
187
|
-
const context = (0, import_react6.useContext)(ErrorReporterContext);
|
188
|
-
if (context === void 0) {
|
189
|
-
console.warn("useRollbar must be used within a ErrorReporterContext");
|
190
|
-
}
|
191
|
-
return context ?? {};
|
192
|
-
}, "useRollbar");
|
193
|
-
// Annotate the CommonJS export names for ESM import in node:
|
194
|
-
0 && (module.exports = {
|
195
|
-
ErrorAlert,
|
196
|
-
ErrorRender,
|
197
|
-
ErrorReporterProvider,
|
198
|
-
ThrownErrorBoundary,
|
199
|
-
useRollbar
|
200
|
-
});
|
201
|
-
//# sourceMappingURL=index.cjs.map
|
package/dist/node/index.cjs.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts","../../src/components/ErrorBoundary/ThrownErrorBoundary.tsx","../../src/components/ErrorRender/ErrorAlert.tsx","../../src/components/ErrorRender/Render.tsx","../../src/contexts/ErrorReporter/Provider.tsx","../../src/contexts/ErrorReporter/Context.ts","../../src/contexts/ErrorReporter/useRollbar.tsx"],"sourcesContent":["export * from './components/index.ts'\nexport * from './contexts/index.ts'\n","import { ModuleError, ModuleErrorSchema } from '@xyo-network/payload-model'\nimport React, { Component, ErrorInfo, ReactNode } from 'react'\nimport Rollbar from 'rollbar'\n\nimport { ErrorRender } from '../ErrorRender/index.ts'\n\nexport interface ThrownErrorBoundaryProps {\n boundaryName?: string\n children: ReactNode\n errorComponent?: (e: ModuleError, boundaryName?: string) => ReactNode\n rethrow?: boolean\n rollbar?: Rollbar\n scope?: string\n title?: string\n}\n\nexport interface ThrownErrorBoundaryState {\n xyoError?: ModuleError\n}\n\nexport class ThrownErrorBoundary extends Component<ThrownErrorBoundaryProps, ThrownErrorBoundaryState> {\n 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 static normalizeError(error: Error | ModuleError): ModuleError {\n return (\n (error as ModuleError).schema === ModuleErrorSchema\n ? error\n : { message: error.message, schema: ModuleErrorSchema, sources: [] }) as ModuleError\n }\n\n 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 override render() {\n const { xyoError } = this.state\n const { children, boundaryName, errorComponent, scope, title } = this.props\n if (xyoError) {\n if (errorComponent) {\n return errorComponent(xyoError)\n }\n return <ErrorRender error={xyoError} errorContext={`${boundaryName} Boundary`} scope={scope} title={title} />\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'\nimport React from 'react'\n\nexport interface ErrorAlertProps extends AlertProps {\n error?: ModuleError | Error | string\n /** @deprecated use scope instead */\n errorContext?: string\n onCancel?: () => void\n scope?: string\n}\n\nexport const ErrorAlert: React.FC<ErrorAlertProps> = ({\n title = 'Whoops! Something went wrong',\n onCancel,\n error = 'An unknown error occurred',\n errorContext,\n scope,\n ...props\n}) => {\n const finalScope = scope ?? errorContext\n return (\n <Alert severity=\"error\" {...props}>\n <AlertTitle>{title}</AlertTitle>\n {finalScope\n ? (\n <div>\n <Typography variant=\"caption\" mr={0.5} fontWeight=\"bold\">\n Scope:\n </Typography>\n <Typography variant=\"caption\">{finalScope}</Typography>\n </div>\n )\n : null}\n <div>\n <Typography variant=\"caption\" mr={0.5} fontWeight=\"bold\">\n Error:\n </Typography>\n <Typography variant=\"caption\">{typeof error === 'string' ? error : error?.message}</Typography>\n </div>\n {onCancel\n ? (\n <ButtonEx variant=\"outlined\" size=\"small\" onClick={onCancel} position=\"absolute\" style={{ right: 8, top: 8 }}>\n <ExitIcon fontSize=\"small\" />\n </ButtonEx>\n )\n : null}\n </Alert>\n )\n}\n","import { FlexCol } from '@xylabs/react-flexbox'\nimport React, { useEffect } from 'react'\n\nimport { ErrorAlert } from './ErrorAlert.tsx'\nimport { ErrorRenderProps } from './Props.ts'\n\nexport const ErrorRender: React.FC<ErrorRenderProps> = ({\n onCancel,\n error,\n noErrorDisplay = false,\n customError = null,\n children,\n errorContext,\n scope,\n useLocation,\n ...props\n}) => {\n const location = useLocation?.()\n useEffect(() => {\n if (location) {\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 }\n }, [location])\n\n return error\n ? (\n <FlexCol alignItems=\"stretch\" {...props}>\n {noErrorDisplay\n ? customError\n : (\n <FlexCol alignItems=\"center\" {...props}>\n <ErrorAlert error={error} errorContext={errorContext} onCancel={onCancel} scope={scope} />\n </FlexCol>\n )}\n </FlexCol>\n )\n : (<>{children}</> ?? null)\n}\n","import { WithChildren } from '@xylabs/react-shared'\nimport React, { useEffect, useState } from 'react'\nimport Rollbar from 'rollbar'\n\nimport { ErrorReporterContext } from './Context.ts'\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 // eslint-disable-next-line @eslint-react/no-unstable-context-value\n return <ErrorReporterContext.Provider value={{ rollbar }}>{children}</ErrorReporterContext.Provider>\n}\n\nexport { ErrorReporterProvider }\n","import { createContext } from 'react'\n\nimport { ErrorReporterContextState } from './State.ts'\n\nexport const ErrorReporterContext = createContext<ErrorReporterContextState>({})\n","import { useContext } from 'react'\n\nimport { ErrorReporterContext } from './Context.ts'\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;;;;;;;;;;;ACAA,2BAA+C;AAC/C,IAAAA,gBAAuD;;;ACDvD,4BAAsC;AACtC,sBAA0D;AAC1D,0BAAyB;AAEzB,mBAAkB;AAUX,IAAMC,aAAwC,wBAAC,EACpDC,QAAQ,gCACRC,UACAC,QAAQ,6BACRC,cACAC,OACA,GAAGC,MAAAA,MACJ;AACC,QAAMC,aAAaF,SAASD;AAC5B,SACE,6BAAAI,QAAA,cAACC,uBAAAA;IAAMC,UAAS;IAAS,GAAGJ;KAC1B,6BAAA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AAA;AACR,QAAIH,iBAAiB;AACnBC,yBAAmBD,eAAAA;IACrB;EACF,GAAG;IAACD;IAASC;GAAgB;AAG7B,SAAO,8BAAAI,QAAA,cAACC,qBAAqBC,UAAQ;IAACC,OAAO;MAAER;IAAQ;KAAID,QAAAA;AAC7D,GAXkF;;;AEVlF,IAAAU,gBAA2B;AAI3B,IAAMC,aAAa,6BAAA;AACjB,QAAMC,cAAUC,0BAAWC,oBAAAA;AAC3B,MAAIF,YAAYG,QAAW;AACzBC,YAAQC,KAAK,uDAAA;EACf;AAEA,SAAOL,WAAW,CAAC;AACrB,GAPmB;","names":["import_react","ErrorAlert","title","onCancel","error","errorContext","scope","props","finalScope","React","Alert","severity","AlertTitle","div","Typography","variant","mr","fontWeight","message","ButtonEx","size","onClick","position","style","right","top","ExitIcon","fontSize","import_react","ErrorRender","onCancel","error","noErrorDisplay","customError","children","errorContext","scope","useLocation","props","location","useEffect","state","from","pathname","window","React","FlexCol","alignItems","ErrorAlert","ThrownErrorBoundary","Component","state","xyoError","undefined","getDerivedStateFromError","error","hasError","normalizeError","schema","ModuleErrorSchema","message","sources","componentDidCatch","errorInfo","rethrow","rollbar","props","console","render","children","boundaryName","errorComponent","scope","title","React","ErrorRender","errorContext","import_react","import_react","ErrorReporterContext","createContext","ErrorReporterProvider","children","rollbar","rollbarInstance","setRollBarInstance","useState","useEffect","React","ErrorReporterContext","Provider","value","import_react","useRollbar","context","useContext","ErrorReporterContext","undefined","console","warn"]}
|
package/dist/node/index.d.cts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,qBAAqB,CAAA"}
|
package/dist/node/index.d.mts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,qBAAqB,CAAA"}
|
package/dist/node/index.d.ts
DELETED
package/dist/node/index.d.ts.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,qBAAqB,CAAA"}
|
package/dist/node/index.mjs
DELETED
@@ -1,162 +0,0 @@
|
|
1
|
-
var __defProp = Object.defineProperty;
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
3
|
-
|
4
|
-
// src/components/ErrorBoundary/ThrownErrorBoundary.tsx
|
5
|
-
import { ModuleErrorSchema } from "@xyo-network/payload-model";
|
6
|
-
import React3, { Component } from "react";
|
7
|
-
|
8
|
-
// src/components/ErrorRender/ErrorAlert.tsx
|
9
|
-
import { ExitToApp as ExitIcon } from "@mui/icons-material";
|
10
|
-
import { Alert, AlertTitle, Typography } from "@mui/material";
|
11
|
-
import { ButtonEx } from "@xylabs/react-button";
|
12
|
-
import React from "react";
|
13
|
-
var ErrorAlert = /* @__PURE__ */ __name(({ title = "Whoops! Something went wrong", onCancel, error = "An unknown error occurred", errorContext, scope, ...props }) => {
|
14
|
-
const finalScope = scope ?? errorContext;
|
15
|
-
return /* @__PURE__ */ React.createElement(Alert, {
|
16
|
-
severity: "error",
|
17
|
-
...props
|
18
|
-
}, /* @__PURE__ */ React.createElement(AlertTitle, null, title), finalScope ? /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(Typography, {
|
19
|
-
variant: "caption",
|
20
|
-
mr: 0.5,
|
21
|
-
fontWeight: "bold"
|
22
|
-
}, "Scope:"), /* @__PURE__ */ React.createElement(Typography, {
|
23
|
-
variant: "caption"
|
24
|
-
}, finalScope)) : null, /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(Typography, {
|
25
|
-
variant: "caption",
|
26
|
-
mr: 0.5,
|
27
|
-
fontWeight: "bold"
|
28
|
-
}, "Error:"), /* @__PURE__ */ React.createElement(Typography, {
|
29
|
-
variant: "caption"
|
30
|
-
}, typeof error === "string" ? error : error == null ? void 0 : error.message)), onCancel ? /* @__PURE__ */ React.createElement(ButtonEx, {
|
31
|
-
variant: "outlined",
|
32
|
-
size: "small",
|
33
|
-
onClick: onCancel,
|
34
|
-
position: "absolute",
|
35
|
-
style: {
|
36
|
-
right: 8,
|
37
|
-
top: 8
|
38
|
-
}
|
39
|
-
}, /* @__PURE__ */ React.createElement(ExitIcon, {
|
40
|
-
fontSize: "small"
|
41
|
-
})) : null);
|
42
|
-
}, "ErrorAlert");
|
43
|
-
|
44
|
-
// src/components/ErrorRender/Render.tsx
|
45
|
-
import { FlexCol } from "@xylabs/react-flexbox";
|
46
|
-
import React2, { useEffect } from "react";
|
47
|
-
var ErrorRender = /* @__PURE__ */ __name(({ onCancel, error, noErrorDisplay = false, customError = null, children, errorContext, scope, useLocation, ...props }) => {
|
48
|
-
const location = useLocation == null ? void 0 : useLocation();
|
49
|
-
useEffect(() => {
|
50
|
-
if (location) {
|
51
|
-
location.state = {
|
52
|
-
from: {
|
53
|
-
pathname: window.location.pathname
|
54
|
-
}
|
55
|
-
};
|
56
|
-
}
|
57
|
-
}, [
|
58
|
-
location
|
59
|
-
]);
|
60
|
-
return error ? /* @__PURE__ */ React2.createElement(FlexCol, {
|
61
|
-
alignItems: "stretch",
|
62
|
-
...props
|
63
|
-
}, noErrorDisplay ? customError : /* @__PURE__ */ React2.createElement(FlexCol, {
|
64
|
-
alignItems: "center",
|
65
|
-
...props
|
66
|
-
}, /* @__PURE__ */ React2.createElement(ErrorAlert, {
|
67
|
-
error,
|
68
|
-
errorContext,
|
69
|
-
onCancel,
|
70
|
-
scope
|
71
|
-
}))) : /* @__PURE__ */ React2.createElement(React2.Fragment, null, children) ?? null;
|
72
|
-
}, "ErrorRender");
|
73
|
-
|
74
|
-
// src/components/ErrorBoundary/ThrownErrorBoundary.tsx
|
75
|
-
var _ThrownErrorBoundary = class _ThrownErrorBoundary extends Component {
|
76
|
-
state = {
|
77
|
-
xyoError: void 0
|
78
|
-
};
|
79
|
-
static getDerivedStateFromError(error) {
|
80
|
-
return {
|
81
|
-
hasError: true,
|
82
|
-
xyoError: _ThrownErrorBoundary.normalizeError(error)
|
83
|
-
};
|
84
|
-
}
|
85
|
-
static normalizeError(error) {
|
86
|
-
return error.schema === ModuleErrorSchema ? error : {
|
87
|
-
message: error.message,
|
88
|
-
schema: ModuleErrorSchema,
|
89
|
-
sources: []
|
90
|
-
};
|
91
|
-
}
|
92
|
-
componentDidCatch(error, errorInfo) {
|
93
|
-
const { rethrow, rollbar } = this.props;
|
94
|
-
const { xyoError } = this.state;
|
95
|
-
rollbar == null ? void 0 : rollbar.error(error);
|
96
|
-
console.error("Error:", xyoError, errorInfo);
|
97
|
-
if (rethrow) {
|
98
|
-
throw error;
|
99
|
-
}
|
100
|
-
}
|
101
|
-
render() {
|
102
|
-
const { xyoError } = this.state;
|
103
|
-
const { children, boundaryName, errorComponent, scope, title } = this.props;
|
104
|
-
if (xyoError) {
|
105
|
-
if (errorComponent) {
|
106
|
-
return errorComponent(xyoError);
|
107
|
-
}
|
108
|
-
return /* @__PURE__ */ React3.createElement(ErrorRender, {
|
109
|
-
error: xyoError,
|
110
|
-
errorContext: `${boundaryName} Boundary`,
|
111
|
-
scope,
|
112
|
-
title
|
113
|
-
});
|
114
|
-
}
|
115
|
-
return children;
|
116
|
-
}
|
117
|
-
};
|
118
|
-
__name(_ThrownErrorBoundary, "ThrownErrorBoundary");
|
119
|
-
var ThrownErrorBoundary = _ThrownErrorBoundary;
|
120
|
-
|
121
|
-
// src/contexts/ErrorReporter/Provider.tsx
|
122
|
-
import React4, { useEffect as useEffect2, useState } from "react";
|
123
|
-
|
124
|
-
// src/contexts/ErrorReporter/Context.ts
|
125
|
-
import { createContext } from "react";
|
126
|
-
var ErrorReporterContext = createContext({});
|
127
|
-
|
128
|
-
// src/contexts/ErrorReporter/Provider.tsx
|
129
|
-
var ErrorReporterProvider = /* @__PURE__ */ __name(({ children, rollbar }) => {
|
130
|
-
const [rollbarInstance, setRollBarInstance] = useState();
|
131
|
-
useEffect2(() => {
|
132
|
-
if (rollbarInstance) {
|
133
|
-
setRollBarInstance(rollbarInstance);
|
134
|
-
}
|
135
|
-
}, [
|
136
|
-
rollbar,
|
137
|
-
rollbarInstance
|
138
|
-
]);
|
139
|
-
return /* @__PURE__ */ React4.createElement(ErrorReporterContext.Provider, {
|
140
|
-
value: {
|
141
|
-
rollbar
|
142
|
-
}
|
143
|
-
}, children);
|
144
|
-
}, "ErrorReporterProvider");
|
145
|
-
|
146
|
-
// src/contexts/ErrorReporter/useRollbar.tsx
|
147
|
-
import { useContext } from "react";
|
148
|
-
var useRollbar = /* @__PURE__ */ __name(() => {
|
149
|
-
const context = useContext(ErrorReporterContext);
|
150
|
-
if (context === void 0) {
|
151
|
-
console.warn("useRollbar must be used within a ErrorReporterContext");
|
152
|
-
}
|
153
|
-
return context ?? {};
|
154
|
-
}, "useRollbar");
|
155
|
-
export {
|
156
|
-
ErrorAlert,
|
157
|
-
ErrorRender,
|
158
|
-
ErrorReporterProvider,
|
159
|
-
ThrownErrorBoundary,
|
160
|
-
useRollbar
|
161
|
-
};
|
162
|
-
//# sourceMappingURL=index.mjs.map
|
package/dist/node/index.mjs.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../src/components/ErrorBoundary/ThrownErrorBoundary.tsx","../../src/components/ErrorRender/ErrorAlert.tsx","../../src/components/ErrorRender/Render.tsx","../../src/contexts/ErrorReporter/Provider.tsx","../../src/contexts/ErrorReporter/Context.ts","../../src/contexts/ErrorReporter/useRollbar.tsx"],"sourcesContent":["import { ModuleError, ModuleErrorSchema } from '@xyo-network/payload-model'\nimport React, { Component, ErrorInfo, ReactNode } from 'react'\nimport Rollbar from 'rollbar'\n\nimport { ErrorRender } from '../ErrorRender/index.ts'\n\nexport interface ThrownErrorBoundaryProps {\n boundaryName?: string\n children: ReactNode\n errorComponent?: (e: ModuleError, boundaryName?: string) => ReactNode\n rethrow?: boolean\n rollbar?: Rollbar\n scope?: string\n title?: string\n}\n\nexport interface ThrownErrorBoundaryState {\n xyoError?: ModuleError\n}\n\nexport class ThrownErrorBoundary extends Component<ThrownErrorBoundaryProps, ThrownErrorBoundaryState> {\n 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 static normalizeError(error: Error | ModuleError): ModuleError {\n return (\n (error as ModuleError).schema === ModuleErrorSchema\n ? error\n : { message: error.message, schema: ModuleErrorSchema, sources: [] }) as ModuleError\n }\n\n 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 override render() {\n const { xyoError } = this.state\n const { children, boundaryName, errorComponent, scope, title } = this.props\n if (xyoError) {\n if (errorComponent) {\n return errorComponent(xyoError)\n }\n return <ErrorRender error={xyoError} errorContext={`${boundaryName} Boundary`} scope={scope} title={title} />\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'\nimport React from 'react'\n\nexport interface ErrorAlertProps extends AlertProps {\n error?: ModuleError | Error | string\n /** @deprecated use scope instead */\n errorContext?: string\n onCancel?: () => void\n scope?: string\n}\n\nexport const ErrorAlert: React.FC<ErrorAlertProps> = ({\n title = 'Whoops! Something went wrong',\n onCancel,\n error = 'An unknown error occurred',\n errorContext,\n scope,\n ...props\n}) => {\n const finalScope = scope ?? errorContext\n return (\n <Alert severity=\"error\" {...props}>\n <AlertTitle>{title}</AlertTitle>\n {finalScope\n ? (\n <div>\n <Typography variant=\"caption\" mr={0.5} fontWeight=\"bold\">\n Scope:\n </Typography>\n <Typography variant=\"caption\">{finalScope}</Typography>\n </div>\n )\n : null}\n <div>\n <Typography variant=\"caption\" mr={0.5} fontWeight=\"bold\">\n Error:\n </Typography>\n <Typography variant=\"caption\">{typeof error === 'string' ? error : error?.message}</Typography>\n </div>\n {onCancel\n ? (\n <ButtonEx variant=\"outlined\" size=\"small\" onClick={onCancel} position=\"absolute\" style={{ right: 8, top: 8 }}>\n <ExitIcon fontSize=\"small\" />\n </ButtonEx>\n )\n : null}\n </Alert>\n )\n}\n","import { FlexCol } from '@xylabs/react-flexbox'\nimport React, { useEffect } from 'react'\n\nimport { ErrorAlert } from './ErrorAlert.tsx'\nimport { ErrorRenderProps } from './Props.ts'\n\nexport const ErrorRender: React.FC<ErrorRenderProps> = ({\n onCancel,\n error,\n noErrorDisplay = false,\n customError = null,\n children,\n errorContext,\n scope,\n useLocation,\n ...props\n}) => {\n const location = useLocation?.()\n useEffect(() => {\n if (location) {\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 }\n }, [location])\n\n return error\n ? (\n <FlexCol alignItems=\"stretch\" {...props}>\n {noErrorDisplay\n ? customError\n : (\n <FlexCol alignItems=\"center\" {...props}>\n <ErrorAlert error={error} errorContext={errorContext} onCancel={onCancel} scope={scope} />\n </FlexCol>\n )}\n </FlexCol>\n )\n : (<>{children}</> ?? null)\n}\n","import { WithChildren } from '@xylabs/react-shared'\nimport React, { useEffect, useState } from 'react'\nimport Rollbar from 'rollbar'\n\nimport { ErrorReporterContext } from './Context.ts'\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 // eslint-disable-next-line @eslint-react/no-unstable-context-value\n return <ErrorReporterContext.Provider value={{ rollbar }}>{children}</ErrorReporterContext.Provider>\n}\n\nexport { ErrorReporterProvider }\n","import { createContext } from 'react'\n\nimport { ErrorReporterContextState } from './State.ts'\n\nexport const ErrorReporterContext = createContext<ErrorReporterContextState>({})\n","import { useContext } from 'react'\n\nimport { ErrorReporterContext } from './Context.ts'\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,SAAsBA,yBAAyB;AAC/C,OAAOC,UAASC,iBAAuC;;;ACDvD,SAASC,aAAaC,gBAAgB;AACtC,SAASC,OAAmBC,YAAYC,kBAAkB;AAC1D,SAASC,gBAAgB;AAEzB,OAAOC,WAAW;AAUX,IAAMC,aAAwC,wBAAC,EACpDC,QAAQ,gCACRC,UACAC,QAAQ,6BACRC,cACAC,OACA,GAAGC,MAAAA,MACJ;AACC,QAAMC,aAAaF,SAASD;AAC5B,SACE,sBAAA,cAACI,OAAAA;IAAMC,UAAS;IAAS,GAAGH;KAC1B,sBAAA,cAACI,YAAAA,MAAYT,KAAAA,GACZM,aAEK,sBAAA,cAACI,OAAAA,MACC,sBAAA,cAACC,YAAAA;IAAWC,SAAQ;IAAUC,IAAI;IAAKC,YAAW;KAAO,QAAA,GAGzD,sBAAA,cAACH,YAAAA;IAAWC,SAAQ;KAAWN,UAAAA,CAAAA,IAGnC,MACJ,sBAAA,cAACI,OAAAA,MACC,sBAAA,cAACC,YAAAA;IAAWC,SAAQ;IAAUC,IAAI;IAAKC,YAAW;KAAO,QAAA,GAGzD,sBAAA,cAACH,YAAAA;IAAWC,SAAQ;KAAW,OAAOV,UAAU,WAAWA,QAAQA,+BAAOa,OAAAA,CAAAA,GAE3Ed,WAEK,sBAAA,cAACe,UAAAA;IAASJ,SAAQ;IAAW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MA;AAEfY,YAAQZ,MAAM,UAAUH,UAAUW,SAAAA;AAClC,QAAIC,SAAS;AACX,YAAMT;IACR;EACF;EAESa,SAAS;AAChB,UAAM,EAAEhB,SAAQ,IAAK,KAAKD;AAC1B,UAAM,EAAEkB,UAAUC,cAAcC,gBAAgBC,OAAOC,MAAK,IAAK,KAAKP;AACtE,QAAId,UAAU;AACZ,UAAImB,gBAAgB;AAClB,eAAOA,eAAenB,QAAAA;MACxB;AACA,aAAO,gBAAAsB,OAAA,cAACC,aAAAA;QAAYpB,OAAOH;QAAUwB,cAAc,GAAGN,YAAAA;QAAyBE;QAAcC;;IAC/F;AAEA,WAAOJ;EACT;AACF;AAxCyCnB;AAAlC,IAAMD,sBAAN;;;AGnBP,OAAO4B,UAASC,aAAAA,YAAWC,gBAAgB;;;ACD3C,SAASC,qBAAqB;AAIvB,IAAMC,uBAAuBD,cAAyC,CAAC,CAAA;;;ADM9E,IAAME,wBAA4E,wBAAC,EAAEC,UAAUC,QAAO,MAAE;AACtG,QAAM,CAACC,iBAAiBC,kBAAAA,IAAsBC,SAAAA;AAE9CC,EAAAA,WAAU,MAAA;AACR,QAAIH,iBAAiB;AACnBC,yBAAmBD,eAAAA;IACrB;EACF,GAAG;IAACD;IAASC;GAAgB;AAG7B,SAAO,gBAAAI,OAAA,cAACC,qBAAqBC,UAAQ;IAACC,OAAO;MAAER;IAAQ;KAAID,QAAAA;AAC7D,GAXkF;;;AEVlF,SAASU,kBAAkB;AAI3B,IAAMC,aAAa,6BAAA;AACjB,QAAMC,UAAUC,WAAWC,oBAAAA;AAC3B,MAAIF,YAAYG,QAAW;AACzBC,YAAQC,KAAK,uDAAA;EACf;AAEA,SAAOL,WAAW,CAAC;AACrB,GAPmB;","names":["ModuleErrorSchema","React","Component","ExitToApp","ExitIcon","Alert","AlertTitle","Typography","ButtonEx","React","ErrorAlert","title","onCancel","error","errorContext","scope","props","finalScope","Alert","severity","AlertTitle","div","Typography","variant","mr","fontWeight","message","ButtonEx","size","onClick","position","style","right","top","ExitIcon","fontSize","FlexCol","React","useEffect","ErrorRender","onCancel","error","noErrorDisplay","customError","children","errorContext","scope","useLocation","props","location","useEffect","state","from","pathname","window","React","FlexCol","alignItems","ErrorAlert","ThrownErrorBoundary","Component","state","xyoError","undefined","getDerivedStateFromError","error","hasError","normalizeError","schema","ModuleErrorSchema","message","sources","componentDidCatch","errorInfo","rethrow","rollbar","props","console","render","children","boundaryName","errorComponent","scope","title","React","ErrorRender","errorContext","React","useEffect","useState","createContext","ErrorReporterContext","ErrorReporterProvider","children","rollbar","rollbarInstance","setRollBarInstance","useState","useEffect","React","ErrorReporterContext","Provider","value","useContext","useRollbar","context","useContext","ErrorReporterContext","undefined","console","warn"]}
|