@ohbug/react 2.0.4 → 2.0.7
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/dist/index.js +71 -1
- package/dist/index.mjs +38 -1
- package/package.json +5 -6
package/dist/index.js
CHANGED
|
@@ -1 +1,71 @@
|
|
|
1
|
-
"use strict";
|
|
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 __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
|
|
26
|
+
// src/index.ts
|
|
27
|
+
var src_exports = {};
|
|
28
|
+
__export(src_exports, {
|
|
29
|
+
OhbugErrorBoundary: () => OhbugErrorBoundary
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(src_exports);
|
|
32
|
+
|
|
33
|
+
// src/OhbugErrorBoundary.ts
|
|
34
|
+
var import_react = __toESM(require("react"));
|
|
35
|
+
var import_core = require("@ohbug/core");
|
|
36
|
+
var OhbugErrorBoundary = class extends import_react.default.Component {
|
|
37
|
+
constructor(props) {
|
|
38
|
+
super(props);
|
|
39
|
+
this.state = { error: null };
|
|
40
|
+
}
|
|
41
|
+
componentDidCatch(error, info) {
|
|
42
|
+
const { client } = this.props;
|
|
43
|
+
const detail = {
|
|
44
|
+
name: error.name,
|
|
45
|
+
message: error.message,
|
|
46
|
+
stack: error.stack,
|
|
47
|
+
errorInfo: info
|
|
48
|
+
};
|
|
49
|
+
const event = client.createEvent({
|
|
50
|
+
category: "error",
|
|
51
|
+
type: import_core.EventTypes.REACT,
|
|
52
|
+
detail
|
|
53
|
+
});
|
|
54
|
+
client.notify(event);
|
|
55
|
+
this.setState({ error });
|
|
56
|
+
}
|
|
57
|
+
render() {
|
|
58
|
+
const { error } = this.state;
|
|
59
|
+
const { FallbackComponent, children } = this.props;
|
|
60
|
+
if (error) {
|
|
61
|
+
if (FallbackComponent)
|
|
62
|
+
return FallbackComponent;
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
return children;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
69
|
+
0 && (module.exports = {
|
|
70
|
+
OhbugErrorBoundary
|
|
71
|
+
});
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1,38 @@
|
|
|
1
|
-
|
|
1
|
+
// src/OhbugErrorBoundary.ts
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { EventTypes } from "@ohbug/core";
|
|
4
|
+
var OhbugErrorBoundary = class extends React.Component {
|
|
5
|
+
constructor(props) {
|
|
6
|
+
super(props);
|
|
7
|
+
this.state = { error: null };
|
|
8
|
+
}
|
|
9
|
+
componentDidCatch(error, info) {
|
|
10
|
+
const { client } = this.props;
|
|
11
|
+
const detail = {
|
|
12
|
+
name: error.name,
|
|
13
|
+
message: error.message,
|
|
14
|
+
stack: error.stack,
|
|
15
|
+
errorInfo: info
|
|
16
|
+
};
|
|
17
|
+
const event = client.createEvent({
|
|
18
|
+
category: "error",
|
|
19
|
+
type: EventTypes.REACT,
|
|
20
|
+
detail
|
|
21
|
+
});
|
|
22
|
+
client.notify(event);
|
|
23
|
+
this.setState({ error });
|
|
24
|
+
}
|
|
25
|
+
render() {
|
|
26
|
+
const { error } = this.state;
|
|
27
|
+
const { FallbackComponent, children } = this.props;
|
|
28
|
+
if (error) {
|
|
29
|
+
if (FallbackComponent)
|
|
30
|
+
return FallbackComponent;
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
return children;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
export {
|
|
37
|
+
OhbugErrorBoundary
|
|
38
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ohbug/react",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.7",
|
|
4
4
|
"description": "Ohbug SDK for React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "chenyueban <jasonchan0527@gmail.com>",
|
|
@@ -30,11 +30,11 @@
|
|
|
30
30
|
"react": "^16.8.6"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@ohbug/core": "2.
|
|
34
|
-
"@ohbug/types": "2.
|
|
33
|
+
"@ohbug/core": "2.1.1",
|
|
34
|
+
"@ohbug/types": "2.1.1"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@ohbug/browser": "2.
|
|
37
|
+
"@ohbug/browser": "2.1.2",
|
|
38
38
|
"@types/react": "^18.0.15"
|
|
39
39
|
},
|
|
40
40
|
"publishConfig": {
|
|
@@ -43,6 +43,5 @@
|
|
|
43
43
|
"scripts": {
|
|
44
44
|
"build": "tsup",
|
|
45
45
|
"dev": "tsup --watch"
|
|
46
|
-
}
|
|
47
|
-
"readme": "# `@ohbug/react`\n\n[](https://www.npmjs.com/package/@ohbug/react)\n[](https://bundlephobia.com/result?p=@ohbug/react)\n\nEnglish | [简体中文](./README-zh_CN.md)\n\n## Installation\n\n```\npnpm instal @ohbug/browser @ohbug/react\n```\n\n## Usage\n\n```jsx\nimport React from 'react'\nimport Ohbug from '@ohbug/browser'\nimport { OhbugErrorBoundary } from '@ohbug/react'\n\nconst client = Ohbug.setup({ apiKey: 'YOUR_API_KEY' })\n\nfunction App() {\n return (\n <div className=\"App\">\n <OhbugErrorBoundary client={client}>\n <HelloWorld />\n </OhbugErrorBoundary>\n </div>\n )\n}\n```\n"
|
|
46
|
+
}
|
|
48
47
|
}
|