@lark.js/sentry 0.0.7 → 0.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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e="0.0.7",r={version:e};exports.default=r,exports.version=e;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e="0.0.8",r={version:e};exports.default=r,exports.version=e;
@@ -1 +1 @@
1
- var a="0.0.7",e={version:a};export{e as default,a as version};
1
+ var a="0.0.8",e={version:a};export{e as default,a as version};
@@ -1 +1 @@
1
- "use strict";var r=require("react"),e=require("../types/enums.cjs"),t=require("./framework-error.cjs");class o extends r.Component{state={error:null,errorInfo:null};componentDidCatch(r,o){this.setState({error:r,errorInfo:o}),t.reportFrameworkError({type:e.EventType.React,error:r,context:o})}render(){const{error:r,errorInfo:e}=this.state;if(r&&e){const{fallback:t}=this.props;return"function"==typeof t?t(r,e):t??null}return this.props.children??null}}exports.ReactErrorBoundary=o;
1
+ "use strict";var r=require("react"),e=require("../types/enums.cjs"),t=require("./framework-error.cjs");class o extends r.Component{state={};static getDerivedStateFromError(r){return{error:r}}componentDidCatch(r,o){this.setState({error:r,errorInfo:o}),t.reportFrameworkError({type:e.EventType.React,error:r,context:o})}render(){const{error:r,errorInfo:e}=this.state;if(r){const{fallback:t}=this.props;return"function"==typeof t?t(r,e):t??null}return this.props.children??null}}exports.ReactErrorBoundary=o;
@@ -1,15 +1,100 @@
1
1
  import { Component, ReactNode, ErrorInfo } from 'react';
2
2
 
3
+ /**
4
+ * Props for the {@link ReactErrorBoundary} component.
5
+ *
6
+ * The boundary renders `children` normally. When a descendant throws during
7
+ * rendering, it switches to rendering {@link fallback} and reports the error
8
+ * to the Sentry SDK.
9
+ */
3
10
  interface ReactErrorBoundaryProps {
11
+ /**
12
+ * The subtree to render when no error has occurred. When an error is
13
+ * caught, this is replaced by {@link fallback}.
14
+ */
4
15
  readonly children?: ReactNode;
5
- readonly fallback?: ReactNode | ((error: Error, errorInfo: ErrorInfo) => ReactNode);
16
+ /**
17
+ * The UI to display when a descendant throws.
18
+ *
19
+ * Can be a static `ReactNode` (no access to the error) or a render function
20
+ * that receives the caught error and React's component-stack info.
21
+ *
22
+ * @remarks
23
+ * The render function may be invoked twice during an error cycle:
24
+ * 1. First, right after `getDerivedStateFromError` runs in the render
25
+ * phase — at this point `errorInfo` is still `undefined` because React
26
+ * only delivers {@link ErrorInfo} in `componentDidCatch` (commit phase).
27
+ * 2. Again after `componentDidCatch` merges `errorInfo` into state.
28
+ *
29
+ * Therefore `errorInfo` is typed as optional. Guard against `undefined` if
30
+ * your fallback relies on `componentStack`.
31
+ *
32
+ * @param error - The Error thrown by the descendant component. Always
33
+ * defined when the fallback is invoked, because the boundary only enters
34
+ * the error state when an Error is present.
35
+ * @param errorInfo - React's {@link ErrorInfo}, containing `componentStack`.
36
+ * `undefined` on the first render after the error is caught.
37
+ * @returns The fallback React subtree to render.
38
+ */
39
+ readonly fallback?: ReactNode | ((error: Error, errorInfo?: ErrorInfo) => ReactNode);
6
40
  }
41
+ /** Internal state tracking the caught error and React component-stack info. */
7
42
  interface ReactErrorBoundaryState {
8
- readonly error: Error | null;
9
- readonly errorInfo: ErrorInfo | null;
43
+ readonly error?: Error;
44
+ readonly errorInfo?: ErrorInfo;
10
45
  }
46
+ /**
47
+ * A React Error Boundary that reports caught errors to the Sentry SDK.
48
+ *
49
+ * @example
50
+ * ```tsx
51
+ * <ReactErrorBoundary fallback={<div>Something went wrong</div>}>
52
+ * <Page />
53
+ * </ReactErrorBoundary>
54
+ * ```
55
+ */
11
56
  declare class ReactErrorBoundary extends Component<ReactErrorBoundaryProps, ReactErrorBoundaryState> {
12
57
  state: ReactErrorBoundaryState;
58
+ /**
59
+ * Called by React during the **render phase** when a descendant throws.
60
+ *
61
+ * This is a pure static method — it must not access `this` or cause side
62
+ * effects. Its sole responsibility is to return the next state so React can
63
+ * immediately re-render the boundary and show the fallback UI without
64
+ * waiting for the commit phase.
65
+ *
66
+ * Only `error` is available here; React does not deliver {@link ErrorInfo}
67
+ * until {@link componentDidCatch} runs (commit phase), so `errorInfo` is
68
+ * left `undefined` at this point.
69
+ *
70
+ * This method is **not redundant** with {@link componentDidCatch}. It
71
+ * triggers the fallback render synchronously in the render phase; without
72
+ * it the fallback would not appear until after commit.
73
+ *
74
+ * @param error - The Error thrown by the descendant component.
75
+ * @returns The next state, setting `error` so the boundary renders the
76
+ * fallback.
77
+ */
78
+ static getDerivedStateFromError(error: Error): ReactErrorBoundaryState;
79
+ /**
80
+ * Called by React during the **commit phase** (after the DOM has been
81
+ * updated) when a descendant throws.
82
+ *
83
+ * This is where side effects belong. It performs two duties:
84
+ * 1. Merges `errorInfo` (React's component-stack trace) into state so the
85
+ * fallback render function can access it. `error` is also set again —
86
+ * it is already present from
87
+ * {@link getDerivedStateFromError | getDerivedStateFromError} but is
88
+ * included for a single atomic state update.
89
+ * 2. Reports the error to the Sentry SDK as a `React` event via
90
+ * {@link reportFrameworkError}.
91
+ *
92
+ * @param error - The Error thrown by the descendant component.
93
+ * @param errorInfo - React's {@link ErrorInfo}, containing `componentStack`:
94
+ * a string describing the component tree from the throwing component up to
95
+ * this boundary. Useful for locating where in the component hierarchy the
96
+ * error originated.
97
+ */
13
98
  componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
14
99
  render(): ReactNode;
15
100
  }
@@ -1 +1 @@
1
- import{Component as r}from"react";import{EventType as t}from"../types/enums.js";import{reportFrameworkError as e}from"./framework-error.js";class o extends r{state={error:null,errorInfo:null};componentDidCatch(r,o){this.setState({error:r,errorInfo:o}),e({type:t.React,error:r,context:o})}render(){const{error:r,errorInfo:t}=this.state;if(r&&t){const{fallback:e}=this.props;return"function"==typeof e?e(r,t):e??null}return this.props.children??null}}export{o as ReactErrorBoundary};
1
+ import{Component as r}from"react";import{EventType as t}from"../types/enums.js";import{reportFrameworkError as e}from"./framework-error.js";class o extends r{state={};static getDerivedStateFromError(r){return{error:r}}componentDidCatch(r,o){this.setState({error:r,errorInfo:o}),e({type:t.React,error:r,context:o})}render(){const{error:r,errorInfo:t}=this.state;if(r){const{fallback:e}=this.props;return"function"==typeof e?e(r,t):e??null}return this.props.children??null}}export{o as ReactErrorBoundary};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark.js/sentry",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "description": "sentry sdk",
5
5
  "keywords": [
6
6
  "sdk",
@@ -54,22 +54,26 @@
54
54
  "test:coverage": "vitest run --config ./vitest.config.ts --coverage",
55
55
  "typecheck": "tsc --noEmit",
56
56
  "vite7": "pnpm add -D vite7@npm:vite@7.3.3",
57
- "format": "oxfmt --write ./"
57
+ "format": "oxfmt --write ./",
58
+ "build": "rollup -c ./rollup.config.ts",
59
+ "build:tsup": "tsup --config ./tsup.config.ts"
58
60
  },
59
61
  "dependencies": {
60
62
  "@fingerprintjs/fingerprintjs": "^5.2.0",
61
63
  "@rrweb/record": "2.0.0-alpha.20",
62
- "pako": "^2.1.0",
64
+ "pako": "^2.2.0",
63
65
  "ua-parser-js": "^2.0.10",
64
66
  "web-vitals": "^5.3.0",
65
67
  "zod": "^4.4.3"
66
68
  },
67
69
  "devDependencies": {
68
70
  "@rollup/plugin-commonjs": "^29.0.3",
71
+ "@rollup/plugin-json": "^6.1.0",
69
72
  "@rollup/plugin-node-resolve": "^16.0.3",
73
+ "@rollup/plugin-terser": "^1.0.0",
70
74
  "@rollup/plugin-typescript": "^12.3.0",
71
75
  "@rrweb/record": "2.0.0-alpha.20",
72
- "@types/node": "^25.9.2",
76
+ "@types/node": "^25.9.4",
73
77
  "@types/pako": "^2.0.4",
74
78
  "@types/react": "^19.2.17",
75
79
  "@types/react-dom": "^19.2.3",
@@ -77,14 +81,16 @@
77
81
  "jsdom": "^24.1.3",
78
82
  "oxfmt": "^0.54.0",
79
83
  "react": "^19.2.7",
80
- "rollup": "^4.61.1",
84
+ "rollup": "^4.62.2",
85
+ "rollup-plugin-dts": "^6.4.1",
86
+ "tsup": "^8.5.1",
81
87
  "typescript": "^6.0.3",
82
- "vite": "^8.0.16",
88
+ "vite": "^8.1.0",
83
89
  "vite7": "npm:vite@7.3.3",
84
90
  "vitest": "^1.6.1",
85
- "vue": "^3.5.35",
86
- "webpack": "^5.107.2",
87
- "webpack-dev-server": "^5.2.4"
91
+ "vue": "^3.5.39",
92
+ "webpack": "^5.108.1",
93
+ "webpack-dev-server": "^5.2.5"
88
94
  },
89
95
  "peerDependencies": {
90
96
  "react": "^19.0.0",