@honeybadger-io/react 1.0.1 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -54,7 +54,7 @@ REACT_APP_HONEYBADGER_API_KEY=b425b636 npm run start
54
54
 
55
55
  This will serve the demo app with hot reload at localhost:3000
56
56
 
57
- For a detailed explanation on how hot reloading works, check out the [guide](http://reactjs-templates.github.io/webpack/) and [docs for react-loader](http://reactjs.github.io/react-loader).
57
+ For a detailed explanation on how hot reloading works, check out the [documentation](https://webpack.js.org/concepts/hot-module-replacement/).
58
58
 
59
59
  ## Changelog
60
60
 
@@ -0,0 +1,13 @@
1
+ import React, { Component } from "react";
2
+ import PropTypes from "prop-types";
3
+ export interface DefaultErrorComponentProps {
4
+ error: Error | null;
5
+ info: React.ErrorInfo | null;
6
+ }
7
+ export default class DefaultErrorComponent extends Component<DefaultErrorComponentProps, {}> {
8
+ static propTypes: {
9
+ error: PropTypes.Requireable<object>;
10
+ info: PropTypes.Requireable<object>;
11
+ };
12
+ render(): JSX.Element;
13
+ }
@@ -0,0 +1,24 @@
1
+ import React, { Component, ReactNode } from 'react';
2
+ import HoneybadgerClient from '@honeybadger-io/js/dist/browser/types/core/client';
3
+ import { DefaultErrorComponentProps } from "./DefaultErrorComponent";
4
+ import PropTypes from "prop-types";
5
+ interface HoneybadgerErrorBoundaryProps {
6
+ honeybadger: HoneybadgerClient;
7
+ ErrorComponent?: ReactNode;
8
+ }
9
+ interface HoneybadgerErrorBoundaryState extends DefaultErrorComponentProps {
10
+ errorOccurred: boolean;
11
+ }
12
+ export default class HoneybadgerErrorBoundary extends Component<HoneybadgerErrorBoundaryProps, HoneybadgerErrorBoundaryState> {
13
+ static propTypes: {
14
+ honeybadger: PropTypes.Validator<object>;
15
+ children: PropTypes.Requireable<PropTypes.ReactElementLike>;
16
+ ErrorComponent: PropTypes.Requireable<PropTypes.ReactElementLike | ((...args: any[]) => any)>;
17
+ };
18
+ constructor(props: HoneybadgerErrorBoundaryProps);
19
+ static getDerivedStateFromError(error: Error): HoneybadgerErrorBoundaryState;
20
+ componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void;
21
+ private getErrorComponent;
22
+ render(): JSX.Element;
23
+ }
24
+ export {};
@@ -1,211 +1,66 @@
1
1
  'use strict';
2
2
 
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var js = require('@honeybadger-io/js');
6
+ var jsxRuntime = require('react/jsx-runtime');
3
7
  var React = require('react');
4
8
  var PropTypes = require('prop-types');
5
9
 
6
10
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
7
11
 
12
+ var js__default = /*#__PURE__*/_interopDefaultLegacy(js);
8
13
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
9
14
  var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
10
15
 
11
- function _classCallCheck(instance, Constructor) {
12
- if (!(instance instanceof Constructor)) {
13
- throw new TypeError("Cannot call a class as a function");
14
- }
15
- }
16
-
17
- function _defineProperties(target, props) {
18
- for (var i = 0; i < props.length; i++) {
19
- var descriptor = props[i];
20
- descriptor.enumerable = descriptor.enumerable || false;
21
- descriptor.configurable = true;
22
- if ("value" in descriptor) descriptor.writable = true;
23
- Object.defineProperty(target, descriptor.key, descriptor);
24
- }
25
- }
26
-
27
- function _createClass(Constructor, protoProps, staticProps) {
28
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
29
- if (staticProps) _defineProperties(Constructor, staticProps);
30
- return Constructor;
31
- }
32
-
33
- function _defineProperty(obj, key, value) {
34
- if (key in obj) {
35
- Object.defineProperty(obj, key, {
36
- value: value,
37
- enumerable: true,
38
- configurable: true,
39
- writable: true
40
- });
41
- } else {
42
- obj[key] = value;
43
- }
44
-
45
- return obj;
46
- }
47
-
48
- function _inherits(subClass, superClass) {
49
- if (typeof superClass !== "function" && superClass !== null) {
50
- throw new TypeError("Super expression must either be null or a function");
51
- }
52
-
53
- subClass.prototype = Object.create(superClass && superClass.prototype, {
54
- constructor: {
55
- value: subClass,
56
- writable: true,
57
- configurable: true
16
+ class DefaultErrorComponent extends React.Component {
17
+ render() {
18
+ return (jsxRuntime.jsxs("div", Object.assign({ className: 'error' }, { children: [jsxRuntime.jsx("div", { children: "An Error Occurred" }, void 0), jsxRuntime.jsx("div", { children: JSON.stringify(this.props.error, null, 2) }, void 0), jsxRuntime.jsx("div", { children: this.props.info ? JSON.stringify(this.props.info, null, 2) : '' }, void 0)] }), void 0));
58
19
  }
59
- });
60
- if (superClass) _setPrototypeOf(subClass, superClass);
61
- }
62
-
63
- function _getPrototypeOf(o) {
64
- _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
65
- return o.__proto__ || Object.getPrototypeOf(o);
66
- };
67
- return _getPrototypeOf(o);
68
- }
69
-
70
- function _setPrototypeOf(o, p) {
71
- _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
72
- o.__proto__ = p;
73
- return o;
74
- };
75
-
76
- return _setPrototypeOf(o, p);
77
- }
78
-
79
- function _isNativeReflectConstruct() {
80
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
81
- if (Reflect.construct.sham) return false;
82
- if (typeof Proxy === "function") return true;
83
-
84
- try {
85
- Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
86
- return true;
87
- } catch (e) {
88
- return false;
89
- }
90
- }
91
-
92
- function _assertThisInitialized(self) {
93
- if (self === void 0) {
94
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
95
- }
96
-
97
- return self;
98
- }
99
-
100
- function _possibleConstructorReturn(self, call) {
101
- if (call && (typeof call === "object" || typeof call === "function")) {
102
- return call;
103
- }
104
-
105
- return _assertThisInitialized(self);
106
20
  }
107
-
108
- function _createSuper(Derived) {
109
- var hasNativeReflectConstruct = _isNativeReflectConstruct();
110
-
111
- return function _createSuperInternal() {
112
- var Super = _getPrototypeOf(Derived),
113
- result;
114
-
115
- if (hasNativeReflectConstruct) {
116
- var NewTarget = _getPrototypeOf(this).constructor;
117
-
118
- result = Reflect.construct(Super, arguments, NewTarget);
119
- } else {
120
- result = Super.apply(this, arguments);
21
+ DefaultErrorComponent.propTypes = {
22
+ error: PropTypes__default['default'].object,
23
+ info: PropTypes__default['default'].object
24
+ };
25
+
26
+ class HoneybadgerErrorBoundary extends React.Component {
27
+ constructor(props) {
28
+ super(props);
29
+ this.state = {
30
+ error: null,
31
+ info: null,
32
+ errorOccurred: false
33
+ };
121
34
  }
122
-
123
- return _possibleConstructorReturn(this, result);
124
- };
125
- }
126
-
127
- var DefaultErrorComponent = /*#__PURE__*/function (_Component) {
128
- _inherits(DefaultErrorComponent, _Component);
129
-
130
- var _super = _createSuper(DefaultErrorComponent);
131
-
132
- function DefaultErrorComponent() {
133
- _classCallCheck(this, DefaultErrorComponent);
134
-
135
- return _super.apply(this, arguments);
136
- }
137
-
138
- _createClass(DefaultErrorComponent, [{
139
- key: "render",
140
- value: function render() {
141
- return /*#__PURE__*/React__default['default'].createElement("div", {
142
- className: "error"
143
- }, /*#__PURE__*/React__default['default'].createElement("div", null, "An Error Occurred"), /*#__PURE__*/React__default['default'].createElement("div", null, this.error), /*#__PURE__*/React__default['default'].createElement("div", null, this.info));
35
+ static getDerivedStateFromError(error) {
36
+ return { error: error, errorOccurred: true, info: null };
144
37
  }
145
- }]);
146
-
147
- return DefaultErrorComponent;
148
- }(React.Component);
149
-
150
- var HoneyBadgerErrorBoundary = /*#__PURE__*/function (_Component2) {
151
- _inherits(HoneyBadgerErrorBoundary, _Component2);
152
-
153
- var _super2 = _createSuper(HoneyBadgerErrorBoundary);
154
-
155
- function HoneyBadgerErrorBoundary(props) {
156
- var _this;
157
-
158
- _classCallCheck(this, HoneyBadgerErrorBoundary);
159
-
160
- _this = _super2.call(this, props);
161
- _this.state = {
162
- error: null,
163
- info: null,
164
- errorOccurred: false
165
- };
166
- return _this;
167
- }
168
-
169
- _createClass(HoneyBadgerErrorBoundary, [{
170
- key: "componentDidCatch",
171
- value: function componentDidCatch(error, info) {
172
- this.setState({
173
- errorOccurred: true,
174
- error: error,
175
- info: info
176
- });
177
- this.props.honeybadger.notify(error, {
178
- context: info
179
- });
38
+ componentDidCatch(error, errorInfo) {
39
+ this.setState({ errorOccurred: true, error: error, info: errorInfo });
40
+ this.props.honeybadger.notify(error, { context: errorInfo });
180
41
  }
181
- }, {
182
- key: "render",
183
- value: function render() {
184
- if (this.state.errorOccurred) {
185
- var ErrorComponent = this.props.ErrorComponent;
186
- return ErrorComponent ? /*#__PURE__*/React__default['default'].createElement(ErrorComponent, this.state) : /*#__PURE__*/React__default['default'].createElement(DefaultErrorComponent, null);
187
- } else {
188
- return this.props.children;
189
- }
42
+ getErrorComponent() {
43
+ return this.props.ErrorComponent
44
+ ? React__default['default'].createElement(this.props.ErrorComponent, this.state)
45
+ : jsxRuntime.jsx(DefaultErrorComponent, Object.assign({}, this.state), void 0);
190
46
  }
191
- }], [{
192
- key: "getDerivedStateFromError",
193
- value: function getDerivedStateFromError(error) {
194
- return {
195
- errorOccurred: true,
196
- error: error
197
- };
47
+ render() {
48
+ return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: this.state.errorOccurred
49
+ ? this.getErrorComponent()
50
+ : this.props.children }, void 0));
51
+ }
52
+ }
53
+ HoneybadgerErrorBoundary.propTypes = {
54
+ honeybadger: PropTypes__default['default'].object.isRequired,
55
+ children: PropTypes__default['default'].element,
56
+ ErrorComponent: PropTypes__default['default'].oneOfType([PropTypes__default['default'].element, PropTypes__default['default'].func])
57
+ };
58
+
59
+ Object.defineProperty(exports, 'Honeybadger', {
60
+ enumerable: true,
61
+ get: function () {
62
+ return js__default['default'];
198
63
  }
199
- }]);
200
-
201
- return HoneyBadgerErrorBoundary;
202
- }(React.Component);
203
-
204
- _defineProperty(HoneyBadgerErrorBoundary, "propTypes", {
205
- honeybadger: PropTypes__default['default'].object,
206
- children: PropTypes__default['default'].element,
207
- ErrorComponent: PropTypes__default['default'].oneOfType([PropTypes__default['default'].element, PropTypes__default['default'].func])
208
64
  });
209
-
210
- module.exports = HoneyBadgerErrorBoundary;
65
+ exports.HoneybadgerErrorBoundary = HoneybadgerErrorBoundary;
211
66
  //# sourceMappingURL=honeybadger-react.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"honeybadger-react.cjs.js","sources":["../../src/index.js"],"sourcesContent":["import React, { Component } from 'react'\nimport PropTypes from 'prop-types'\n\nclass DefaultErrorComponent extends Component {\n render() {\n return (\n <div className='error'>\n <div>An Error Occurred</div>\n <div>{this.error}</div>\n <div>{this.info}</div>\n </div>\n )\n }\n}\n\nexport default class HoneyBadgerErrorBoundary extends Component {\n static propTypes = {\n honeybadger: PropTypes.object,\n children: PropTypes.element,\n ErrorComponent: PropTypes.oneOfType([PropTypes.element, PropTypes.func])\n }\n\n constructor (props) {\n super(props)\n this.state = {\n error: null,\n info: null,\n errorOccurred: false\n }\n }\n\n static getDerivedStateFromError (error) {\n return { errorOccurred: true, error: error }\n }\n\n componentDidCatch (error, info) {\n this.setState({errorOccurred: true, error: error, info: info})\n this.props.honeybadger.notify(error, { context: info })\n }\n render() {\n if (this.state.errorOccurred) {\n const {ErrorComponent} = this.props\n return ErrorComponent ? React.createElement(ErrorComponent, this.state) : <DefaultErrorComponent />\n } else {\n return this.props.children\n }\n }\n}\n"],"names":["DefaultErrorComponent","React","error","info","Component","HoneyBadgerErrorBoundary","props","state","errorOccurred","setState","honeybadger","notify","context","ErrorComponent","createElement","children","PropTypes","object","element","oneOfType","func"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAGMA;;;;;;;;;;;;;6BACK;AACP,0BACEC;AAAK,QAAA,SAAS,EAAC;AAAf,sBACEA,yEADF,eAEEA,qDAAM,KA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,"file":"honeybadger-react.cjs.js","sources":["../../src/DefaultErrorComponent.tsx","../../src/HoneybadgerErrorBoundary.tsx"],"sourcesContent":["import React, {Component} from \"react\"\nimport PropTypes from \"prop-types\";\n\nexport interface DefaultErrorComponentProps {\n error: Error | null\n info: React.ErrorInfo | null\n}\n\nexport default class DefaultErrorComponent extends Component<DefaultErrorComponentProps, {}> {\n\n static propTypes = {\n error: PropTypes.object,\n info: PropTypes.object\n }\n\n render() {\n return (\n <div className='error'>\n <div>\n An Error Occurred\n </div>\n <div>\n {JSON.stringify(this.props.error, null, 2)}\n </div>\n <div>\n {this.props.info ? JSON.stringify(this.props.info, null, 2) : ''}\n </div>\n </div>\n )\n }\n}\n","import React, {Component, ReactNode} from 'react'\nimport HoneybadgerClient from '@honeybadger-io/js/dist/browser/types/core/client'\nimport DefaultErrorComponent, {DefaultErrorComponentProps} from \"./DefaultErrorComponent\"\nimport PropTypes from \"prop-types\";\n\ninterface HoneybadgerErrorBoundaryProps {\n honeybadger: HoneybadgerClient\n ErrorComponent?: ReactNode\n}\n\ninterface HoneybadgerErrorBoundaryState extends DefaultErrorComponentProps {\n errorOccurred: boolean\n}\n\nexport default class HoneybadgerErrorBoundary extends Component<HoneybadgerErrorBoundaryProps, HoneybadgerErrorBoundaryState> {\n\n static propTypes = {\n honeybadger: PropTypes.object.isRequired,\n children: PropTypes.element,\n ErrorComponent: PropTypes.oneOfType([PropTypes.element, PropTypes.func])\n }\n\n constructor(props: HoneybadgerErrorBoundaryProps) {\n super(props)\n this.state = {\n error: null,\n info: null,\n errorOccurred: false\n }\n }\n\n public static getDerivedStateFromError(error: Error): HoneybadgerErrorBoundaryState {\n return {error: error, errorOccurred: true, info: null}\n }\n\n componentDidCatch(error: Error, errorInfo: React.ErrorInfo) {\n this.setState({errorOccurred: true, error: error, info: errorInfo})\n this.props.honeybadger.notify(error, {context: errorInfo as any})\n }\n\n private getErrorComponent(): ReactNode {\n return this.props.ErrorComponent\n ? React.createElement(this.props.ErrorComponent as any, this.state)\n : <DefaultErrorComponent {...this.state} />\n }\n\n render() {\n return (\n <>\n {this.state.errorOccurred\n ? this.getErrorComponent()\n : this.props.children\n }\n </>\n )\n }\n}\n"],"names":["Component","_jsxs","_jsx","PropTypes","React"],"mappings":";;;;;;;;;;;;;;;MAQqB,qBAAsB,SAAQA,eAAyC;IAO1F,MAAM;QACJ,QACEC,uCAAK,SAAS,EAAC,OAAO,iBACpBC,gEAEM,EACNA,kCACG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,WACtC,EACNA,kCACG,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,EAAE,WAC5D,aACF,EACP;KACF;;AAnBM,+BAAS,GAAG;IACjB,KAAK,EAAEC,6BAAS,CAAC,MAAM;IACvB,IAAI,EAAEA,6BAAS,CAAC,MAAM;CACvB;;MCCkB,wBAAyB,SAAQH,eAAuE;IAQ3H,YAAY,KAAoC;QAC9C,KAAK,CAAC,KAAK,CAAC,CAAA;QACZ,IAAI,CAAC,KAAK,GAAG;YACX,KAAK,EAAE,IAAI;YACX,IAAI,EAAE,IAAI;YACV,aAAa,EAAE,KAAK;SACrB,CAAA;KACF;IAEM,OAAO,wBAAwB,CAAC,KAAY;QACjD,OAAO,EAAC,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAC,CAAA;KACvD;IAED,iBAAiB,CAAC,KAAY,EAAE,SAA0B;QACxD,IAAI,CAAC,QAAQ,CAAC,EAAC,aAAa,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAC,CAAC,CAAA;QACnE,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,EAAE,EAAC,OAAO,EAAE,SAAgB,EAAC,CAAC,CAAA;KAClE;IAEO,iBAAiB;QACvB,OAAO,IAAI,CAAC,KAAK,CAAC,cAAc;cAC5BI,yBAAK,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,cAAqB,EAAE,IAAI,CAAC,KAAK,CAAC;cACjEF,eAAC,qBAAqB,oBAAK,IAAI,CAAC,KAAK,UAAI,CAAA;KAC9C;IAED,MAAM;QACJ,QACEA,gDACG,IAAI,CAAC,KAAK,CAAC,aAAa;kBACrB,IAAI,CAAC,iBAAiB,EAAE;kBACxB,IAAI,CAAC,KAAK,CAAC,QAAQ,WAEtB,EACJ;KACF;;AAvCM,kCAAS,GAAG;IACjB,WAAW,EAAEC,6BAAS,CAAC,MAAM,CAAC,UAAU;IACxC,QAAQ,EAAEA,6BAAS,CAAC,OAAO;IAC3B,cAAc,EAAEA,6BAAS,CAAC,SAAS,CAAC,CAACA,6BAAS,CAAC,OAAO,EAAEA,6BAAS,CAAC,IAAI,CAAC,CAAC;CACzE;;;;;;;;;;"}
@@ -1,204 +1,50 @@
1
+ export { default as Honeybadger } from '@honeybadger-io/js';
2
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
1
3
  import React, { Component } from 'react';
2
4
  import PropTypes from 'prop-types';
3
5
 
4
- function _classCallCheck(instance, Constructor) {
5
- if (!(instance instanceof Constructor)) {
6
- throw new TypeError("Cannot call a class as a function");
7
- }
8
- }
9
-
10
- function _defineProperties(target, props) {
11
- for (var i = 0; i < props.length; i++) {
12
- var descriptor = props[i];
13
- descriptor.enumerable = descriptor.enumerable || false;
14
- descriptor.configurable = true;
15
- if ("value" in descriptor) descriptor.writable = true;
16
- Object.defineProperty(target, descriptor.key, descriptor);
17
- }
18
- }
19
-
20
- function _createClass(Constructor, protoProps, staticProps) {
21
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
22
- if (staticProps) _defineProperties(Constructor, staticProps);
23
- return Constructor;
24
- }
25
-
26
- function _defineProperty(obj, key, value) {
27
- if (key in obj) {
28
- Object.defineProperty(obj, key, {
29
- value: value,
30
- enumerable: true,
31
- configurable: true,
32
- writable: true
33
- });
34
- } else {
35
- obj[key] = value;
36
- }
37
-
38
- return obj;
39
- }
40
-
41
- function _inherits(subClass, superClass) {
42
- if (typeof superClass !== "function" && superClass !== null) {
43
- throw new TypeError("Super expression must either be null or a function");
44
- }
45
-
46
- subClass.prototype = Object.create(superClass && superClass.prototype, {
47
- constructor: {
48
- value: subClass,
49
- writable: true,
50
- configurable: true
6
+ class DefaultErrorComponent extends Component {
7
+ render() {
8
+ return (jsxs("div", Object.assign({ className: 'error' }, { children: [jsx("div", { children: "An Error Occurred" }, void 0), jsx("div", { children: JSON.stringify(this.props.error, null, 2) }, void 0), jsx("div", { children: this.props.info ? JSON.stringify(this.props.info, null, 2) : '' }, void 0)] }), void 0));
51
9
  }
52
- });
53
- if (superClass) _setPrototypeOf(subClass, superClass);
54
- }
55
-
56
- function _getPrototypeOf(o) {
57
- _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
58
- return o.__proto__ || Object.getPrototypeOf(o);
59
- };
60
- return _getPrototypeOf(o);
61
10
  }
62
-
63
- function _setPrototypeOf(o, p) {
64
- _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
65
- o.__proto__ = p;
66
- return o;
67
- };
68
-
69
- return _setPrototypeOf(o, p);
70
- }
71
-
72
- function _isNativeReflectConstruct() {
73
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
74
- if (Reflect.construct.sham) return false;
75
- if (typeof Proxy === "function") return true;
76
-
77
- try {
78
- Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
79
- return true;
80
- } catch (e) {
81
- return false;
82
- }
83
- }
84
-
85
- function _assertThisInitialized(self) {
86
- if (self === void 0) {
87
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
88
- }
89
-
90
- return self;
91
- }
92
-
93
- function _possibleConstructorReturn(self, call) {
94
- if (call && (typeof call === "object" || typeof call === "function")) {
95
- return call;
96
- }
97
-
98
- return _assertThisInitialized(self);
99
- }
100
-
101
- function _createSuper(Derived) {
102
- var hasNativeReflectConstruct = _isNativeReflectConstruct();
103
-
104
- return function _createSuperInternal() {
105
- var Super = _getPrototypeOf(Derived),
106
- result;
107
-
108
- if (hasNativeReflectConstruct) {
109
- var NewTarget = _getPrototypeOf(this).constructor;
110
-
111
- result = Reflect.construct(Super, arguments, NewTarget);
112
- } else {
113
- result = Super.apply(this, arguments);
11
+ DefaultErrorComponent.propTypes = {
12
+ error: PropTypes.object,
13
+ info: PropTypes.object
14
+ };
15
+
16
+ class HoneybadgerErrorBoundary extends Component {
17
+ constructor(props) {
18
+ super(props);
19
+ this.state = {
20
+ error: null,
21
+ info: null,
22
+ errorOccurred: false
23
+ };
114
24
  }
115
-
116
- return _possibleConstructorReturn(this, result);
117
- };
118
- }
119
-
120
- var DefaultErrorComponent = /*#__PURE__*/function (_Component) {
121
- _inherits(DefaultErrorComponent, _Component);
122
-
123
- var _super = _createSuper(DefaultErrorComponent);
124
-
125
- function DefaultErrorComponent() {
126
- _classCallCheck(this, DefaultErrorComponent);
127
-
128
- return _super.apply(this, arguments);
129
- }
130
-
131
- _createClass(DefaultErrorComponent, [{
132
- key: "render",
133
- value: function render() {
134
- return /*#__PURE__*/React.createElement("div", {
135
- className: "error"
136
- }, /*#__PURE__*/React.createElement("div", null, "An Error Occurred"), /*#__PURE__*/React.createElement("div", null, this.error), /*#__PURE__*/React.createElement("div", null, this.info));
25
+ static getDerivedStateFromError(error) {
26
+ return { error: error, errorOccurred: true, info: null };
137
27
  }
138
- }]);
139
-
140
- return DefaultErrorComponent;
141
- }(Component);
142
-
143
- var HoneyBadgerErrorBoundary = /*#__PURE__*/function (_Component2) {
144
- _inherits(HoneyBadgerErrorBoundary, _Component2);
145
-
146
- var _super2 = _createSuper(HoneyBadgerErrorBoundary);
147
-
148
- function HoneyBadgerErrorBoundary(props) {
149
- var _this;
150
-
151
- _classCallCheck(this, HoneyBadgerErrorBoundary);
152
-
153
- _this = _super2.call(this, props);
154
- _this.state = {
155
- error: null,
156
- info: null,
157
- errorOccurred: false
158
- };
159
- return _this;
160
- }
161
-
162
- _createClass(HoneyBadgerErrorBoundary, [{
163
- key: "componentDidCatch",
164
- value: function componentDidCatch(error, info) {
165
- this.setState({
166
- errorOccurred: true,
167
- error: error,
168
- info: info
169
- });
170
- this.props.honeybadger.notify(error, {
171
- context: info
172
- });
28
+ componentDidCatch(error, errorInfo) {
29
+ this.setState({ errorOccurred: true, error: error, info: errorInfo });
30
+ this.props.honeybadger.notify(error, { context: errorInfo });
173
31
  }
174
- }, {
175
- key: "render",
176
- value: function render() {
177
- if (this.state.errorOccurred) {
178
- var ErrorComponent = this.props.ErrorComponent;
179
- return ErrorComponent ? /*#__PURE__*/React.createElement(ErrorComponent, this.state) : /*#__PURE__*/React.createElement(DefaultErrorComponent, null);
180
- } else {
181
- return this.props.children;
182
- }
32
+ getErrorComponent() {
33
+ return this.props.ErrorComponent
34
+ ? React.createElement(this.props.ErrorComponent, this.state)
35
+ : jsx(DefaultErrorComponent, Object.assign({}, this.state), void 0);
183
36
  }
184
- }], [{
185
- key: "getDerivedStateFromError",
186
- value: function getDerivedStateFromError(error) {
187
- return {
188
- errorOccurred: true,
189
- error: error
190
- };
37
+ render() {
38
+ return (jsx(Fragment, { children: this.state.errorOccurred
39
+ ? this.getErrorComponent()
40
+ : this.props.children }, void 0));
191
41
  }
192
- }]);
193
-
194
- return HoneyBadgerErrorBoundary;
195
- }(Component);
196
-
197
- _defineProperty(HoneyBadgerErrorBoundary, "propTypes", {
198
- honeybadger: PropTypes.object,
199
- children: PropTypes.element,
200
- ErrorComponent: PropTypes.oneOfType([PropTypes.element, PropTypes.func])
201
- });
42
+ }
43
+ HoneybadgerErrorBoundary.propTypes = {
44
+ honeybadger: PropTypes.object.isRequired,
45
+ children: PropTypes.element,
46
+ ErrorComponent: PropTypes.oneOfType([PropTypes.element, PropTypes.func])
47
+ };
202
48
 
203
- export default HoneyBadgerErrorBoundary;
49
+ export { HoneybadgerErrorBoundary };
204
50
  //# sourceMappingURL=honeybadger-react.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"honeybadger-react.esm.js","sources":["../../src/index.js"],"sourcesContent":["import React, { Component } from 'react'\nimport PropTypes from 'prop-types'\n\nclass DefaultErrorComponent extends Component {\n render() {\n return (\n <div className='error'>\n <div>An Error Occurred</div>\n <div>{this.error}</div>\n <div>{this.info}</div>\n </div>\n )\n }\n}\n\nexport default class HoneyBadgerErrorBoundary extends Component {\n static propTypes = {\n honeybadger: PropTypes.object,\n children: PropTypes.element,\n ErrorComponent: PropTypes.oneOfType([PropTypes.element, PropTypes.func])\n }\n\n constructor (props) {\n super(props)\n this.state = {\n error: null,\n info: null,\n errorOccurred: false\n }\n }\n\n static getDerivedStateFromError (error) {\n return { errorOccurred: true, error: error }\n }\n\n componentDidCatch (error, info) {\n this.setState({errorOccurred: true, error: error, info: info})\n this.props.honeybadger.notify(error, { context: info })\n }\n render() {\n if (this.state.errorOccurred) {\n const {ErrorComponent} = this.props\n return ErrorComponent ? React.createElement(ErrorComponent, this.state) : <DefaultErrorComponent />\n } else {\n return this.props.children\n }\n }\n}\n"],"names":["DefaultErrorComponent","error","info","Component","HoneyBadgerErrorBoundary","props","state","errorOccurred","setState","honeybadger","notify","context","ErrorComponent","React","createElement","children","PropTypes","object","element","oneOfType","func"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAGMA;;;;;;;;;;;;;6BACK;AACP,0BACE;AAAK,QAAA,SAAS,EAAC;AAAf,sBACE,qDADF,eAEE,iCAAM,KAAKC,KAAX,CAFF,eAGE,iCAAM,KAAKC,IAAX,CAHF,CADF;AAOD;;;;EATiCC;;IAYfC;;;;;AAOnB,oCAAaC,KAAb,EAAoB;AAAA;;AAAA;;AAClB,+BAAMA,KAAN;AACA,UAAKC,KAAL,GAAa;AACXL,MAAAA,KAAK,EAAE,IADI;AAEXC,MAAAA,IAAI,EAAE,IAFK;AAGXK,MAAAA,aAAa,EAAE;AAHJ,KAAb;AAFkB;AAOnB;;;;sCAMkBN,OAAOC,MAAM;AAC9B,WAAKM,QAAL,CAAc;AAACD,QAAAA,aAAa,EAAE,IAAhB;AAAsBN,QAAAA,KAAK,EAAEA,KAA7B;AAAoCC,QAAAA,IAAI,EAAEA;AAA1C,OAAd;AACA,WAAKG,KAAL,CAAWI,WAAX,CAAuBC,MAAvB,CAA8BT,KAA9B,EAAqC;AAAEU,QAAAA,OAAO,EAAET;AAAX,OAArC;AACD;;;6BACQ;AACP,UAAI,KAAKI,KAAL,CAAWC,aAAf,EAA8B;AAAA,YACrBK,cADqB,GACH,KAAKP,KADF,CACrBO,cADqB;AAE5B,eAAOA,cAAc,gBAAGC,KAAK,CAACC,aAAN,CAAoBF,cAApB,EAAoC,KAAKN,KAAzC,CAAH,gBAAqD,oBAAC,qBAAD,OAA1E;AACD,OAHD,MAGO;AACL,eAAO,KAAKD,KAAL,CAAWU,QAAlB;AACD;AACF;;;6CAfgCd,OAAO;AACtC,aAAO;AAAEM,QAAAA,aAAa,EAAE,IAAjB;AAAuBN,QAAAA,KAAK,EAAEA;AAA9B,OAAP;AACD;;;;EAlBmDE;;gBAAjCC,uCACA;AACjBK,EAAAA,WAAW,EAAEO,SAAS,CAACC,MADN;AAEjBF,EAAAA,QAAQ,EAAEC,SAAS,CAACE,OAFH;AAGjBN,EAAAA,cAAc,EAAEI,SAAS,CAACG,SAAV,CAAoB,CAACH,SAAS,CAACE,OAAX,EAAoBF,SAAS,CAACI,IAA9B,CAApB;AAHC;;;;"}
1
+ {"version":3,"file":"honeybadger-react.esm.js","sources":["../../src/DefaultErrorComponent.tsx","../../src/HoneybadgerErrorBoundary.tsx"],"sourcesContent":["import React, {Component} from \"react\"\nimport PropTypes from \"prop-types\";\n\nexport interface DefaultErrorComponentProps {\n error: Error | null\n info: React.ErrorInfo | null\n}\n\nexport default class DefaultErrorComponent extends Component<DefaultErrorComponentProps, {}> {\n\n static propTypes = {\n error: PropTypes.object,\n info: PropTypes.object\n }\n\n render() {\n return (\n <div className='error'>\n <div>\n An Error Occurred\n </div>\n <div>\n {JSON.stringify(this.props.error, null, 2)}\n </div>\n <div>\n {this.props.info ? JSON.stringify(this.props.info, null, 2) : ''}\n </div>\n </div>\n )\n }\n}\n","import React, {Component, ReactNode} from 'react'\nimport HoneybadgerClient from '@honeybadger-io/js/dist/browser/types/core/client'\nimport DefaultErrorComponent, {DefaultErrorComponentProps} from \"./DefaultErrorComponent\"\nimport PropTypes from \"prop-types\";\n\ninterface HoneybadgerErrorBoundaryProps {\n honeybadger: HoneybadgerClient\n ErrorComponent?: ReactNode\n}\n\ninterface HoneybadgerErrorBoundaryState extends DefaultErrorComponentProps {\n errorOccurred: boolean\n}\n\nexport default class HoneybadgerErrorBoundary extends Component<HoneybadgerErrorBoundaryProps, HoneybadgerErrorBoundaryState> {\n\n static propTypes = {\n honeybadger: PropTypes.object.isRequired,\n children: PropTypes.element,\n ErrorComponent: PropTypes.oneOfType([PropTypes.element, PropTypes.func])\n }\n\n constructor(props: HoneybadgerErrorBoundaryProps) {\n super(props)\n this.state = {\n error: null,\n info: null,\n errorOccurred: false\n }\n }\n\n public static getDerivedStateFromError(error: Error): HoneybadgerErrorBoundaryState {\n return {error: error, errorOccurred: true, info: null}\n }\n\n componentDidCatch(error: Error, errorInfo: React.ErrorInfo) {\n this.setState({errorOccurred: true, error: error, info: errorInfo})\n this.props.honeybadger.notify(error, {context: errorInfo as any})\n }\n\n private getErrorComponent(): ReactNode {\n return this.props.ErrorComponent\n ? React.createElement(this.props.ErrorComponent as any, this.state)\n : <DefaultErrorComponent {...this.state} />\n }\n\n render() {\n return (\n <>\n {this.state.errorOccurred\n ? this.getErrorComponent()\n : this.props.children\n }\n </>\n )\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C,cAAqB,EAAE,IAAI,CAAC,KAAK,CAAC;cACjEA,IAAC,qBAAqB,oBAAK,IAAI,CAAC,KAAK,UAAI,CAAA;KAC9C;IAED,MAAM;QACJ,QACEA,0BACG,IAAI,CAAC,KAAK,CAAC,aAAa;kBACrB,IAAI,CAAC,iBAAiB,EAAE;kBACxB,IAAI,CAAC,KAAK,CAAC,QAAQ,WAEtB,EACJ;KACF;;AAvCM,kCAAS,GAAG;IACjB,WAAW,EAAE,SAAS,CAAC,MAAM,CAAC,UAAU;IACxC,QAAQ,EAAE,SAAS,CAAC,OAAO;IAC3B,cAAc,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,OAAO,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;CACzE;;;;"}
@@ -1,211 +1,66 @@
1
- var HoneybadgerReact = (function (React, PropTypes) {
2
- 'use strict';
1
+ var HoneybadgerReact = (function (exports, js, jsxRuntime, React, PropTypes) {
2
+ 'use strict';
3
3
 
4
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
4
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
5
5
 
6
- var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
7
- var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
6
+ var js__default = /*#__PURE__*/_interopDefaultLegacy(js);
7
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
8
+ var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
8
9
 
9
- function _classCallCheck(instance, Constructor) {
10
- if (!(instance instanceof Constructor)) {
11
- throw new TypeError("Cannot call a class as a function");
12
- }
13
- }
14
-
15
- function _defineProperties(target, props) {
16
- for (var i = 0; i < props.length; i++) {
17
- var descriptor = props[i];
18
- descriptor.enumerable = descriptor.enumerable || false;
19
- descriptor.configurable = true;
20
- if ("value" in descriptor) descriptor.writable = true;
21
- Object.defineProperty(target, descriptor.key, descriptor);
22
- }
23
- }
24
-
25
- function _createClass(Constructor, protoProps, staticProps) {
26
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
27
- if (staticProps) _defineProperties(Constructor, staticProps);
28
- return Constructor;
29
- }
30
-
31
- function _defineProperty(obj, key, value) {
32
- if (key in obj) {
33
- Object.defineProperty(obj, key, {
34
- value: value,
35
- enumerable: true,
36
- configurable: true,
37
- writable: true
38
- });
39
- } else {
40
- obj[key] = value;
41
- }
42
-
43
- return obj;
44
- }
45
-
46
- function _inherits(subClass, superClass) {
47
- if (typeof superClass !== "function" && superClass !== null) {
48
- throw new TypeError("Super expression must either be null or a function");
10
+ class DefaultErrorComponent extends React.Component {
11
+ render() {
12
+ return (jsxRuntime.jsxs("div", Object.assign({ className: 'error' }, { children: [jsxRuntime.jsx("div", { children: "An Error Occurred" }, void 0), jsxRuntime.jsx("div", { children: JSON.stringify(this.props.error, null, 2) }, void 0), jsxRuntime.jsx("div", { children: this.props.info ? JSON.stringify(this.props.info, null, 2) : '' }, void 0)] }), void 0));
13
+ }
49
14
  }
50
-
51
- subClass.prototype = Object.create(superClass && superClass.prototype, {
52
- constructor: {
53
- value: subClass,
54
- writable: true,
55
- configurable: true
56
- }
57
- });
58
- if (superClass) _setPrototypeOf(subClass, superClass);
59
- }
60
-
61
- function _getPrototypeOf(o) {
62
- _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
63
- return o.__proto__ || Object.getPrototypeOf(o);
15
+ DefaultErrorComponent.propTypes = {
16
+ error: PropTypes__default['default'].object,
17
+ info: PropTypes__default['default'].object
64
18
  };
65
- return _getPrototypeOf(o);
66
- }
67
19
 
68
- function _setPrototypeOf(o, p) {
69
- _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
70
- o.__proto__ = p;
71
- return o;
72
- };
73
-
74
- return _setPrototypeOf(o, p);
75
- }
76
-
77
- function _isNativeReflectConstruct() {
78
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
79
- if (Reflect.construct.sham) return false;
80
- if (typeof Proxy === "function") return true;
81
-
82
- try {
83
- Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
84
- return true;
85
- } catch (e) {
86
- return false;
87
- }
88
- }
89
-
90
- function _assertThisInitialized(self) {
91
- if (self === void 0) {
92
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
93
- }
94
-
95
- return self;
96
- }
97
-
98
- function _possibleConstructorReturn(self, call) {
99
- if (call && (typeof call === "object" || typeof call === "function")) {
100
- return call;
20
+ class HoneybadgerErrorBoundary extends React.Component {
21
+ constructor(props) {
22
+ super(props);
23
+ this.state = {
24
+ error: null,
25
+ info: null,
26
+ errorOccurred: false
27
+ };
28
+ }
29
+ static getDerivedStateFromError(error) {
30
+ return { error: error, errorOccurred: true, info: null };
31
+ }
32
+ componentDidCatch(error, errorInfo) {
33
+ this.setState({ errorOccurred: true, error: error, info: errorInfo });
34
+ this.props.honeybadger.notify(error, { context: errorInfo });
35
+ }
36
+ getErrorComponent() {
37
+ return this.props.ErrorComponent
38
+ ? React__default['default'].createElement(this.props.ErrorComponent, this.state)
39
+ : jsxRuntime.jsx(DefaultErrorComponent, Object.assign({}, this.state), void 0);
40
+ }
41
+ render() {
42
+ return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: this.state.errorOccurred
43
+ ? this.getErrorComponent()
44
+ : this.props.children }, void 0));
45
+ }
101
46
  }
102
-
103
- return _assertThisInitialized(self);
104
- }
105
-
106
- function _createSuper(Derived) {
107
- var hasNativeReflectConstruct = _isNativeReflectConstruct();
108
-
109
- return function _createSuperInternal() {
110
- var Super = _getPrototypeOf(Derived),
111
- result;
112
-
113
- if (hasNativeReflectConstruct) {
114
- var NewTarget = _getPrototypeOf(this).constructor;
115
-
116
- result = Reflect.construct(Super, arguments, NewTarget);
117
- } else {
118
- result = Super.apply(this, arguments);
119
- }
120
-
121
- return _possibleConstructorReturn(this, result);
47
+ HoneybadgerErrorBoundary.propTypes = {
48
+ honeybadger: PropTypes__default['default'].object.isRequired,
49
+ children: PropTypes__default['default'].element,
50
+ ErrorComponent: PropTypes__default['default'].oneOfType([PropTypes__default['default'].element, PropTypes__default['default'].func])
122
51
  };
123
- }
124
-
125
- var DefaultErrorComponent = /*#__PURE__*/function (_Component) {
126
- _inherits(DefaultErrorComponent, _Component);
127
-
128
- var _super = _createSuper(DefaultErrorComponent);
129
-
130
- function DefaultErrorComponent() {
131
- _classCallCheck(this, DefaultErrorComponent);
132
-
133
- return _super.apply(this, arguments);
134
- }
135
-
136
- _createClass(DefaultErrorComponent, [{
137
- key: "render",
138
- value: function render() {
139
- return /*#__PURE__*/React__default['default'].createElement("div", {
140
- className: "error"
141
- }, /*#__PURE__*/React__default['default'].createElement("div", null, "An Error Occurred"), /*#__PURE__*/React__default['default'].createElement("div", null, this.error), /*#__PURE__*/React__default['default'].createElement("div", null, this.info));
142
- }
143
- }]);
144
-
145
- return DefaultErrorComponent;
146
- }(React.Component);
147
-
148
- var HoneyBadgerErrorBoundary = /*#__PURE__*/function (_Component2) {
149
- _inherits(HoneyBadgerErrorBoundary, _Component2);
150
-
151
- var _super2 = _createSuper(HoneyBadgerErrorBoundary);
152
-
153
- function HoneyBadgerErrorBoundary(props) {
154
- var _this;
155
52
 
156
- _classCallCheck(this, HoneyBadgerErrorBoundary);
157
-
158
- _this = _super2.call(this, props);
159
- _this.state = {
160
- error: null,
161
- info: null,
162
- errorOccurred: false
163
- };
164
- return _this;
165
- }
166
-
167
- _createClass(HoneyBadgerErrorBoundary, [{
168
- key: "componentDidCatch",
169
- value: function componentDidCatch(error, info) {
170
- this.setState({
171
- errorOccurred: true,
172
- error: error,
173
- info: info
174
- });
175
- this.props.honeybadger.notify(error, {
176
- context: info
177
- });
178
- }
179
- }, {
180
- key: "render",
181
- value: function render() {
182
- if (this.state.errorOccurred) {
183
- var ErrorComponent = this.props.ErrorComponent;
184
- return ErrorComponent ? /*#__PURE__*/React__default['default'].createElement(ErrorComponent, this.state) : /*#__PURE__*/React__default['default'].createElement(DefaultErrorComponent, null);
185
- } else {
186
- return this.props.children;
53
+ Object.defineProperty(exports, 'Honeybadger', {
54
+ enumerable: true,
55
+ get: function () {
56
+ return js__default['default'];
187
57
  }
188
- }
189
- }], [{
190
- key: "getDerivedStateFromError",
191
- value: function getDerivedStateFromError(error) {
192
- return {
193
- errorOccurred: true,
194
- error: error
195
- };
196
- }
197
- }]);
198
-
199
- return HoneyBadgerErrorBoundary;
200
- }(React.Component);
58
+ });
59
+ exports.HoneybadgerErrorBoundary = HoneybadgerErrorBoundary;
201
60
 
202
- _defineProperty(HoneyBadgerErrorBoundary, "propTypes", {
203
- honeybadger: PropTypes__default['default'].object,
204
- children: PropTypes__default['default'].element,
205
- ErrorComponent: PropTypes__default['default'].oneOfType([PropTypes__default['default'].element, PropTypes__default['default'].func])
206
- });
61
+ Object.defineProperty(exports, '__esModule', { value: true });
207
62
 
208
- return HoneyBadgerErrorBoundary;
63
+ return exports;
209
64
 
210
- }(React, PropTypes));
65
+ }({}, Honeybadger, jsxRuntime, React, PropTypes));
211
66
  //# sourceMappingURL=honeybadger-react.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"honeybadger-react.js","sources":["../../src/index.js"],"sourcesContent":["import React, { Component } from 'react'\nimport PropTypes from 'prop-types'\n\nclass DefaultErrorComponent extends Component {\n render() {\n return (\n <div className='error'>\n <div>An Error Occurred</div>\n <div>{this.error}</div>\n <div>{this.info}</div>\n </div>\n )\n }\n}\n\nexport default class HoneyBadgerErrorBoundary extends Component {\n static propTypes = {\n honeybadger: PropTypes.object,\n children: PropTypes.element,\n ErrorComponent: PropTypes.oneOfType([PropTypes.element, PropTypes.func])\n }\n\n constructor (props) {\n super(props)\n this.state = {\n error: null,\n info: null,\n errorOccurred: false\n }\n }\n\n static getDerivedStateFromError (error) {\n return { errorOccurred: true, error: error }\n }\n\n componentDidCatch (error, info) {\n this.setState({errorOccurred: true, error: error, info: info})\n this.props.honeybadger.notify(error, { context: info })\n }\n render() {\n if (this.state.errorOccurred) {\n const {ErrorComponent} = this.props\n return ErrorComponent ? React.createElement(ErrorComponent, this.state) : <DefaultErrorComponent />\n } else {\n return this.props.children\n }\n }\n}\n"],"names":["DefaultErrorComponent","React","error","info","Component","HoneyBadgerErrorBoundary","props","state","errorOccurred","setState","honeybadger","notify","context","ErrorComponent","createElement","children","PropTypes","object","element","oneOfType","func"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAGMA;;;;;;;;;;;;;+BACK;EACP,0BACEC;EAAK,QAAA,SAAS,EAAC;EAAf,sBACEA,yEADF,eAEEA,qDAAM,KAAKC,KAAX,CAFF,eAGED,qDAAM,KAAKE,IAAX,CAHF,CADF;EAOD;;;;IATiCC;;MAYfC;;;;;EAOnB,oCAAaC,KAAb,EAAoB;EAAA;;EAAA;;EAClB,+BAAMA,KAAN;EACA,UAAKC,KAAL,GAAa;EACXL,MAAAA,KAAK,EAAE,IADI;EAEXC,MAAAA,IAAI,EAAE,IAFK;EAGXK,MAAAA,aAAa,EAAE;EAHJ,KAAb;EAFkB;EAOnB;;;;wCAMkBN,OAAOC,MAAM;EAC9B,WAAKM,QAAL,CAAc;EAACD,QAAAA,aAAa,EAAE,IAAhB;EAAsBN,QAAAA,KAAK,EAAEA,KAA7B;EAAoCC,QAAAA,IAAI,EAAEA;EAA1C,OAAd;EACA,WAAKG,KAAL,CAAWI,WAAX,CAAuBC,MAAvB,CAA8BT,KAA9B,EAAqC;EAAEU,QAAAA,OAAO,EAAET;EAAX,OAArC;EACD;;;+BACQ;EACP,UAAI,KAAKI,KAAL,CAAWC,aAAf,EAA8B;EAAA,YACrBK,cADqB,GACH,KAAKP,KADF,CACrBO,cADqB;EAE5B,eAAOA,cAAc,gBAAGZ,yBAAK,CAACa,aAAN,CAAoBD,cAApB,EAAoC,KAAKN,KAAzC,CAAH,gBAAqDN,wCAAC,qBAAD,OAA1E;EACD,OAHD,MAGO;EACL,eAAO,KAAKK,KAAL,CAAWS,QAAlB;EACD;EACF;;;+CAfgCb,OAAO;EACtC,aAAO;EAAEM,QAAAA,aAAa,EAAE,IAAjB;EAAuBN,QAAAA,KAAK,EAAEA;EAA9B,OAAP;EACD;;;;IAlBmDE;;kBAAjCC,uCACA;EACjBK,EAAAA,WAAW,EAAEM,6BAAS,CAACC,MADN;EAEjBF,EAAAA,QAAQ,EAAEC,6BAAS,CAACE,OAFH;EAGjBL,EAAAA,cAAc,EAAEG,6BAAS,CAACG,SAAV,CAAoB,CAACH,6BAAS,CAACE,OAAX,EAAoBF,6BAAS,CAACI,IAA9B,CAApB;EAHC;;;;;;;;"}
1
+ {"version":3,"file":"honeybadger-react.js","sources":["../../src/DefaultErrorComponent.tsx","../../src/HoneybadgerErrorBoundary.tsx"],"sourcesContent":["import React, {Component} from \"react\"\nimport PropTypes from \"prop-types\";\n\nexport interface DefaultErrorComponentProps {\n error: Error | null\n info: React.ErrorInfo | null\n}\n\nexport default class DefaultErrorComponent extends Component<DefaultErrorComponentProps, {}> {\n\n static propTypes = {\n error: PropTypes.object,\n info: PropTypes.object\n }\n\n render() {\n return (\n <div className='error'>\n <div>\n An Error Occurred\n </div>\n <div>\n {JSON.stringify(this.props.error, null, 2)}\n </div>\n <div>\n {this.props.info ? JSON.stringify(this.props.info, null, 2) : ''}\n </div>\n </div>\n )\n }\n}\n","import React, {Component, ReactNode} from 'react'\nimport HoneybadgerClient from '@honeybadger-io/js/dist/browser/types/core/client'\nimport DefaultErrorComponent, {DefaultErrorComponentProps} from \"./DefaultErrorComponent\"\nimport PropTypes from \"prop-types\";\n\ninterface HoneybadgerErrorBoundaryProps {\n honeybadger: HoneybadgerClient\n ErrorComponent?: ReactNode\n}\n\ninterface HoneybadgerErrorBoundaryState extends DefaultErrorComponentProps {\n errorOccurred: boolean\n}\n\nexport default class HoneybadgerErrorBoundary extends Component<HoneybadgerErrorBoundaryProps, HoneybadgerErrorBoundaryState> {\n\n static propTypes = {\n honeybadger: PropTypes.object.isRequired,\n children: PropTypes.element,\n ErrorComponent: PropTypes.oneOfType([PropTypes.element, PropTypes.func])\n }\n\n constructor(props: HoneybadgerErrorBoundaryProps) {\n super(props)\n this.state = {\n error: null,\n info: null,\n errorOccurred: false\n }\n }\n\n public static getDerivedStateFromError(error: Error): HoneybadgerErrorBoundaryState {\n return {error: error, errorOccurred: true, info: null}\n }\n\n componentDidCatch(error: Error, errorInfo: React.ErrorInfo) {\n this.setState({errorOccurred: true, error: error, info: errorInfo})\n this.props.honeybadger.notify(error, {context: errorInfo as any})\n }\n\n private getErrorComponent(): ReactNode {\n return this.props.ErrorComponent\n ? React.createElement(this.props.ErrorComponent as any, this.state)\n : <DefaultErrorComponent {...this.state} />\n }\n\n render() {\n return (\n <>\n {this.state.errorOccurred\n ? this.getErrorComponent()\n : this.props.children\n }\n </>\n )\n }\n}\n"],"names":["Component","_jsxs","_jsx","PropTypes","React"],"mappings":";;;;;;;;;UAQqB,qBAAsB,SAAQA,eAAyC;QAO1F,MAAM;YACJ,QACEC,uCAAK,SAAS,EAAC,OAAO,iBACpBC,gEAEM,EACNA,kCACG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,WACtC,EACNA,kCACG,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,EAAE,WAC5D,aACF,EACP;SACF;;IAnBM,+BAAS,GAAG;QACjB,KAAK,EAAEC,6BAAS,CAAC,MAAM;QACvB,IAAI,EAAEA,6BAAS,CAAC,MAAM;KACvB;;UCCkB,wBAAyB,SAAQH,eAAuE;QAQ3H,YAAY,KAAoC;YAC9C,KAAK,CAAC,KAAK,CAAC,C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oneybadgerErrorBoundary";
3
+ export { Honeybadger, HoneybadgerErrorBoundary };
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@honeybadger-io/react",
3
- "version": "1.0.1",
3
+ "version": "2.0.1",
4
4
  "description": "React.js integration for honeybadger",
5
5
  "author": "Jason Truesdell <jason@yuzuten.com> (https://github.com/JasonTrue)",
6
6
  "license": "MIT",
@@ -9,7 +9,7 @@
9
9
  "url": "git+ssh://git@github.com/honeybadger-io/honeybadger-react.git"
10
10
  },
11
11
  "main": "dist/honeybadger-react.cjs.js",
12
- "types": "./honeybadger-react.d.ts",
12
+ "types": "./dist/index.d.ts",
13
13
  "module": "dist/honeybadger-react.esm.js",
14
14
  "unpkg": "dist/honeybadger-react.js",
15
15
  "jsnext:main": "dist/honeybadger-react.esm.js",
@@ -20,7 +20,7 @@
20
20
  "scripts": {
21
21
  "test": "cross-env CI=1 react-scripts test --env=jsdom",
22
22
  "test:watch": "react-scripts test --env=jsdom",
23
- "build": "rollup -c",
23
+ "build": "tsc --emitDeclarationOnly --noEmit false && rollup -c",
24
24
  "start": "rollup -c -w",
25
25
  "prepare": "npm run build",
26
26
  "predeploy": "cd example && npm install && npm run build",
@@ -28,7 +28,7 @@
28
28
  "preversion": "npm test",
29
29
  "version": "scripts/update-versions.sh",
30
30
  "postversion": "git push && git push --tags",
31
- "prepublishOnly": "npm build && npm test"
31
+ "prepublishOnly": "npm run build && npm test"
32
32
  },
33
33
  "peerDependencies": {
34
34
  "prop-types": "^15.5.4",
@@ -36,33 +36,25 @@
36
36
  "react-dom": "^15.0.0 || ^16.0.0 || ^17.0.0"
37
37
  },
38
38
  "devDependencies": {
39
- "@babel/core": "^7.8.4",
40
- "@babel/plugin-external-helpers": "^7.8.3",
41
- "@babel/plugin-proposal-class-properties": "^7.8.3",
42
- "@babel/preset-env": "^7.8.4",
43
- "@babel/preset-react": "^7.8.3",
44
- "@rollup/plugin-commonjs": "^17.0.0",
45
- "@rollup/plugin-node-resolve": "^11.0.1",
46
- "@rollup/plugin-url": "^6.0.0",
47
- "@svgr/rollup": "^5.3.1",
39
+ "@rollup/plugin-commonjs": "^21.0.2",
40
+ "@rollup/plugin-typescript": "^8.3.1",
41
+ "@types/jest": "^27.4.1",
42
+ "@types/react": "^17.0.40",
43
+ "@types/react-test-renderer": "^17.0.1",
44
+ "@types/sinon": "^10.0.11",
48
45
  "cross-env": "^7.0.0",
49
- "gh-pages": "^3.0.0",
50
- "react": "^17.0.1",
51
- "react-dom": "^17.0.1",
52
- "react-scripts": "^4.0.0",
53
- "react-test-renderer": "^17.0.1",
54
- "rollup": "^2.37.1",
55
- "rollup-plugin-babel": "^4.3.3",
56
- "rollup-plugin-peer-deps-external": "^2.2.2",
57
- "rollup-plugin-postcss": "^3.1.1",
58
- "rollup-plugin-uglify": "^6.0.4",
59
- "sinon": "^9.0.0"
46
+ "gh-pages": "^3.2.3",
47
+ "react": "^17.0.2",
48
+ "react-scripts": "^4.0.3",
49
+ "react-test-renderer": "^17.0.2",
50
+ "rollup": "^2.70.1",
51
+ "sinon": "^13.0.1",
52
+ "typescript": "^4.6.2"
60
53
  },
61
54
  "files": [
62
- "dist",
63
- "honeybadger-react.d.ts"
55
+ "dist"
64
56
  ],
65
57
  "dependencies": {
66
- "@honeybadger-io/js": "^3.0.1"
58
+ "@honeybadger-io/js": "^3.2.8"
67
59
  }
68
60
  }
package/CHANGELOG.md DELETED
@@ -1,51 +0,0 @@
1
- # Changelog
2
- All notable changes to this project will be documented in this file.
3
-
4
- The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5
- and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6
-
7
- ## [Unreleased]
8
-
9
- ## [1.0.1] - 2021-02-18
10
- ### Fixed
11
- - Bump peerDependencies version for React 17
12
-
13
- ## [1.0.0] - 2021-01-19
14
- ### Changed
15
- - Migrate honeybadger-js dependency to @honeybadger-io/js 3.0.0
16
- See https://docs.honeybadger.io/lib/javascript/support/upgrading-to-v3.html
17
-
18
- ## [0.0.8] - 2020-09-24
19
- ### Fixed
20
- - Update honeybadger-js to 2.3.0
21
-
22
- ## [0.0.7] - 2020-04-24
23
- ### Fixed
24
- - Update honeybadger-js to 2.2.1 (security release, see
25
- [here](https://github.com/honeybadger-io/honeybadger-js/blob/master/CHANGELOG.md#220---2020-03-16))
26
-
27
- ## [0.0.6] - 2020-01-08
28
- ### Fixed
29
- - Fix TypeScript type definitions
30
-
31
- ## [0.0.5] - 2019-12-18
32
- ### Fixed
33
- - Deps & security updates
34
- - Proptypes bug (#39) (#40)
35
-
36
- ## [0.0.4] - 2019-07-01
37
- ### Fixed
38
- - Fix PropType mismatch #38 @andrewsouthard
39
-
40
- ## [0.0.3] - 2019-04-16
41
- ### Changed
42
- - Update honeybadger-js to v1.0. See
43
- https://github.com/honeybadger-io/honeybadger-js/blob/master/CHANGELOG.md
44
-
45
- ## [0.0.2] - 2019-01-21
46
- ### Added
47
- - Add TypeScript definition
48
-
49
- ## [0.0.1] - 2018-11-30
50
- ### Added
51
- - Initial release
@@ -1,16 +0,0 @@
1
- declare module "@honeybadger-io/react" {
2
- import { Component } from "react";
3
- import Honeybadger from "@honeybadger-io/js";
4
-
5
- interface Props {
6
- honeybadger: Honeybadger;
7
- children: React.ReactNode;
8
- ErrorComponent?: React.ReactNode | Function;
9
- }
10
-
11
- class ErrorBoundary extends Component<Props> {}
12
-
13
- namespace ErrorBoundary {}
14
-
15
- export = ErrorBoundary;
16
- }