@ohbug/react 2.0.0 → 2.0.3

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 CHANGED
@@ -1,67 +1 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
20
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
-
22
- // src/index.ts
23
- var src_exports = {};
24
- __export(src_exports, {
25
- OhbugErrorBoundary: () => OhbugErrorBoundary
26
- });
27
- module.exports = __toCommonJS(src_exports);
28
-
29
- // src/OhbugErrorBoundary.ts
30
- var import_react = __toESM(require("react"));
31
- var import_core = require("@ohbug/core");
32
- var OhbugErrorBoundary = class extends import_react.default.Component {
33
- constructor(props) {
34
- super(props);
35
- this.state = { error: null };
36
- }
37
- componentDidCatch(error, info) {
38
- const { client } = this.props;
39
- const detail = {
40
- name: error.name,
41
- message: error.message,
42
- stack: error.stack,
43
- errorInfo: info
44
- };
45
- const event = client.createEvent({
46
- category: "error",
47
- type: import_core.EventTypes.REACT,
48
- detail
49
- });
50
- client.notify(event);
51
- this.setState({ error });
52
- }
53
- render() {
54
- const { error } = this.state;
55
- const { FallbackComponent, children } = this.props;
56
- if (error) {
57
- if (FallbackComponent)
58
- return FallbackComponent;
59
- return null;
60
- }
61
- return children;
62
- }
63
- };
64
- // Annotate the CommonJS export names for ESM import in node:
65
- 0 && (module.exports = {
66
- OhbugErrorBoundary
67
- });
1
+ 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 C={};h(C,{OhbugErrorBoundary:()=>s});module.exports=g(C);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});
package/dist/index.mjs CHANGED
@@ -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
- };
1
+ import i from"react";import{EventTypes as l}from"@ohbug/core";var o=class extends i.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:l.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};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ohbug/react",
3
- "version": "2.0.0",
3
+ "version": "2.0.3",
4
4
  "description": "Ohbug SDK for React",
5
5
  "license": "Apache-2.0",
6
6
  "author": "chenyueban <jasonchan0527@gmail.com>",
@@ -23,19 +23,18 @@
23
23
  }
24
24
  },
25
25
  "files": [
26
- "dist",
27
- "src"
26
+ "dist"
28
27
  ],
29
28
  "sideEffects": false,
30
29
  "peerDependencies": {
31
30
  "react": "^16.8.6"
32
31
  },
33
32
  "dependencies": {
34
- "@ohbug/core": "2.0.0",
35
- "@ohbug/types": "2.0.0"
33
+ "@ohbug/core": "2.0.3",
34
+ "@ohbug/types": "2.0.3"
36
35
  },
37
36
  "devDependencies": {
38
- "@ohbug/browser": "2.0.0",
37
+ "@ohbug/browser": "2.0.3",
39
38
  "@types/react": "^18.0.9"
40
39
  },
41
40
  "publishConfig": {
@@ -1,55 +0,0 @@
1
- import type { OhbugBaseDetail, OhbugClient } from '@ohbug/types'
2
- import React from 'react'
3
- import { EventTypes } from '@ohbug/core'
4
-
5
- export interface ReactErrorDetail extends OhbugBaseDetail {
6
- name: string
7
- stack?: string
8
- errorInfo: any
9
- }
10
-
11
- interface ErrorBoundaryProp {
12
- client: OhbugClient
13
- FallbackComponent?: React.ReactElement
14
- children?: React.ReactNode
15
- }
16
- interface ErrorBoundaryState {
17
- error: any
18
- }
19
- export class OhbugErrorBoundary extends React.Component<
20
- ErrorBoundaryProp,
21
- ErrorBoundaryState
22
- > {
23
- constructor(props: ErrorBoundaryProp) {
24
- super(props)
25
- this.state = { error: null }
26
- }
27
-
28
- componentDidCatch(error: Error, info: any) {
29
- const { client } = this.props
30
- const detail: ReactErrorDetail = {
31
- name: error.name,
32
- message: error.message,
33
- stack: error.stack,
34
- errorInfo: info,
35
- }
36
-
37
- const event = client.createEvent<ReactErrorDetail>({
38
- category: 'error',
39
- type: EventTypes.REACT,
40
- detail,
41
- })
42
- client.notify(event)
43
- this.setState({ error })
44
- }
45
-
46
- render() {
47
- const { error } = this.state
48
- const { FallbackComponent, children } = this.props
49
- if (error) {
50
- if (FallbackComponent) return FallbackComponent
51
- return null
52
- }
53
- return children
54
- }
55
- }
package/src/index.ts DELETED
@@ -1 +0,0 @@
1
- export * from './OhbugErrorBoundary'