@ohbug/react 2.0.6 → 2.0.8

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.
@@ -0,0 +1,23 @@
1
+ import { OhbugBaseDetail, OhbugClient } from '@ohbug/types';
2
+ import React from 'react';
3
+
4
+ interface ReactErrorDetail extends OhbugBaseDetail {
5
+ name: string;
6
+ stack?: string;
7
+ errorInfo: any;
8
+ }
9
+ interface ErrorBoundaryProp {
10
+ client: OhbugClient;
11
+ FallbackComponent?: React.ReactElement;
12
+ children?: React.ReactNode;
13
+ }
14
+ interface ErrorBoundaryState {
15
+ error: any;
16
+ }
17
+ declare class OhbugErrorBoundary extends React.Component<ErrorBoundaryProp, ErrorBoundaryState> {
18
+ constructor(props: ErrorBoundaryProp);
19
+ componentDidCatch(error: Error, info: any): void;
20
+ render(): string | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined;
21
+ }
22
+
23
+ export { OhbugErrorBoundary, ReactErrorDetail };
package/dist/index.d.ts CHANGED
@@ -17,7 +17,7 @@ interface ErrorBoundaryState {
17
17
  declare class OhbugErrorBoundary extends React.Component<ErrorBoundaryProp, ErrorBoundaryState> {
18
18
  constructor(props: ErrorBoundaryProp);
19
19
  componentDidCatch(error: Error, info: any): void;
20
- render(): string | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | React.ReactFragment | null | undefined;
20
+ render(): string | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined;
21
21
  }
22
22
 
23
23
  export { OhbugErrorBoundary, ReactErrorDetail };
package/dist/index.js CHANGED
@@ -1 +1,75 @@
1
- "use strict";var m=Object.create;var a=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var d=Object.getPrototypeOf,f=Object.prototype.hasOwnProperty;var h=(t,e)=>{for(var r in e)a(t,r,{get:e[r],enumerable:!0})},c=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of y(e))!f.call(t,n)&&n!==r&&a(t,n,{get:()=>e[n],enumerable:!(o=u(e,n))||o.enumerable});return t};var E=(t,e,r)=>(r=t!=null?m(d(t)):{},c(e||!t||!t.__esModule?a(r,"default",{value:t,enumerable:!0}):r,t)),g=t=>c(a({},"__esModule",{value:!0}),t);var R={};h(R,{OhbugErrorBoundary:()=>s});module.exports=g(R);var i=E(require("react")),l=require("@ohbug/core"),s=class extends i.default.Component{constructor(e){super(e),this.state={error:null}}componentDidCatch(e,r){let{client:o}=this.props,n={name:e.name,message:e.message,stack:e.stack,errorInfo:r},p=o.createEvent({category:"error",type:l.EventTypes.REACT,detail:n});o.notify(p),this.setState({error:e})}render(){let{error:e}=this.state,{FallbackComponent:r,children:o}=this.props;return e?r||null:o}};0&&(module.exports={OhbugErrorBoundary});
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
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var src_exports = {};
32
+ __export(src_exports, {
33
+ OhbugErrorBoundary: () => OhbugErrorBoundary
34
+ });
35
+ module.exports = __toCommonJS(src_exports);
36
+
37
+ // src/OhbugErrorBoundary.ts
38
+ var import_react = __toESM(require("react"));
39
+ var import_core = require("@ohbug/core");
40
+ var OhbugErrorBoundary = class extends import_react.default.Component {
41
+ constructor(props) {
42
+ super(props);
43
+ this.state = { error: null };
44
+ }
45
+ componentDidCatch(error, info) {
46
+ const { client } = this.props;
47
+ const detail = {
48
+ name: error.name,
49
+ message: error.message,
50
+ stack: error.stack,
51
+ errorInfo: info
52
+ };
53
+ const event = client.createEvent({
54
+ category: "error",
55
+ type: import_core.EventTypes.REACT,
56
+ detail
57
+ });
58
+ client.notify(event);
59
+ this.setState({ error });
60
+ }
61
+ render() {
62
+ const { error } = this.state;
63
+ const { FallbackComponent, children } = this.props;
64
+ if (error) {
65
+ if (FallbackComponent)
66
+ return FallbackComponent;
67
+ return null;
68
+ }
69
+ return children;
70
+ }
71
+ };
72
+ // Annotate the CommonJS export names for ESM import in node:
73
+ 0 && (module.exports = {
74
+ OhbugErrorBoundary
75
+ });
package/dist/index.mjs CHANGED
@@ -1 +1,38 @@
1
- import s from"react";import{EventTypes as c}from"@ohbug/core";var o=class extends s.Component{constructor(e){super(e),this.state={error:null}}componentDidCatch(e,t){let{client:r}=this.props,n={name:e.name,message:e.message,stack:e.stack,errorInfo:t},a=r.createEvent({category:"error",type:c.REACT,detail:n});r.notify(a),this.setState({error:e})}render(){let{error:e}=this.state,{FallbackComponent:t,children:r}=this.props;return e?t||null:r}};export{o as OhbugErrorBoundary};
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.6",
3
+ "version": "2.0.8",
4
4
  "description": "Ohbug SDK for React",
5
5
  "license": "Apache-2.0",
6
6
  "author": "chenyueban <jasonchan0527@gmail.com>",
@@ -30,12 +30,12 @@
30
30
  "react": "^16.8.6"
31
31
  },
32
32
  "dependencies": {
33
- "@ohbug/core": "2.1.0",
34
- "@ohbug/types": "2.1.0"
33
+ "@ohbug/types": "2.2.0",
34
+ "@ohbug/core": "2.2.0"
35
35
  },
36
36
  "devDependencies": {
37
- "@ohbug/browser": "2.0.6",
38
- "@types/react": "^18.0.15"
37
+ "@types/react": "^18.2.14",
38
+ "@ohbug/browser": "2.5.0"
39
39
  },
40
40
  "publishConfig": {
41
41
  "access": "public"
@@ -43,6 +43,5 @@
43
43
  "scripts": {
44
44
  "build": "tsup",
45
45
  "dev": "tsup --watch"
46
- },
47
- "readme": "# `@ohbug/react`\n\n[![npm](https://img.shields.io/npm/v/@ohbug/react.svg?style=flat-square)](https://www.npmjs.com/package/@ohbug/react)\n[![npm bundle size](https://img.shields.io/bundlephobia/min/@ohbug/react?style=flat-square)](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
  }