@servicetitan/error-boundary 33.1.1 → 34.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/dist/error-boundary.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-boundary.d.ts","sourceRoot":"","sources":["../src/error-boundary.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"error-boundary.d.ts","sourceRoot":"","sources":["../src/error-boundary.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,2BAA2B,CAAC;AAEhD,OAAO,EAAE,SAAS,EAAE,aAAa,EAAM,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAExE,MAAM,WAAW,aAAa;IAC1B,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;CAC1B;AAED,MAAM,MAAM,kBAAkB,GAAG,iBAAiB,CAAC;IAC/C,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,aAAa,CAAC,aAAa,CAAC,CAAC;IACxC,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;CACxE,CAAC,CAAC;AAEH,qBAAa,aAAc,SAAQ,SAAS,CAAC,kBAAkB,CAAC;IAC5D,KAAK;;MAEH;IAEF,QAEgB,UAAU,CAAC,CAAM;IAEjC,iBAAiB,CAAC,KAAK,EAAE,KAAK;IAU9B,MAAM;CAcT"}
|
package/dist/error-boundary.js
CHANGED
|
@@ -21,9 +21,9 @@ function _ts_metadata(k, v) {
|
|
|
21
21
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
22
22
|
}
|
|
23
23
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
|
-
import { Component } from 'react';
|
|
25
24
|
import { Log } from '@servicetitan/log-service';
|
|
26
25
|
import { injectDependency, optional } from '@servicetitan/react-ioc';
|
|
26
|
+
import { Component } from 'react';
|
|
27
27
|
export class ErrorBoundary extends Component {
|
|
28
28
|
componentDidCatch(error) {
|
|
29
29
|
if (this.logService) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/error-boundary.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../src/error-boundary.tsx"],"sourcesContent":["import { Log } from '@servicetitan/log-service';\nimport { injectDependency, optional } from '@servicetitan/react-ioc';\nimport { Component, ComponentType, FC, PropsWithChildren } from 'react';\n\nexport interface FallbackProps {\n onRefresh?: () => void;\n}\n\nexport type ErrorBoundaryProps = PropsWithChildren<{\n moduleName: string;\n fallback?: ComponentType<FallbackProps>;\n getErrorData?: (error: Error) => Parameters<Log['error']>[0]['data'];\n}>;\n\nexport class ErrorBoundary extends Component<ErrorBoundaryProps> {\n state = {\n hasError: false,\n };\n\n @optional()\n @injectDependency(Log)\n declare private logService?: Log;\n\n componentDidCatch(error: Error) {\n if (this.logService) {\n const { moduleName: Module, getErrorData } = this.props;\n const data = { Module, ...getErrorData?.(error) };\n this.logService.error({ error, message: error.message, data }, { skipConsole: true });\n }\n\n this.setState({ hasError: true }); // eslint-disable-line react/no-set-state\n }\n\n render() {\n const { fallback: Fallback = DefaultFallback } = this.props;\n\n const { hasError } = this.state;\n\n if (hasError) {\n const handleRefresh = () => {\n this.setState({ hasError: false }); // eslint-disable-line react/no-set-state\n };\n return <Fallback onRefresh={handleRefresh} />;\n }\n\n return this.props.children;\n }\n}\n\nconst DefaultFallback: FC = () => <h2>Something went wrong</h2>;\n"],"names":["Log","injectDependency","optional","Component","ErrorBoundary","componentDidCatch","error","logService","moduleName","Module","getErrorData","props","data","message","skipConsole","setState","hasError","render","fallback","Fallback","DefaultFallback","state","handleRefresh","onRefresh","children","h2"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,SAASA,GAAG,QAAQ,4BAA4B;AAChD,SAASC,gBAAgB,EAAEC,QAAQ,QAAQ,0BAA0B;AACrE,SAASC,SAAS,QAA8C,QAAQ;AAYxE,OAAO,MAAMC,sBAAsBD;IAS/BE,kBAAkBC,KAAY,EAAE;QAC5B,IAAI,IAAI,CAACC,UAAU,EAAE;YACjB,MAAM,EAAEC,YAAYC,MAAM,EAAEC,YAAY,EAAE,GAAG,IAAI,CAACC,KAAK;YACvD,MAAMC,OAAO;gBAAEH;mBAAWC,yBAAAA,mCAAAA,aAAeJ,MAAlB;YAAyB;YAChD,IAAI,CAACC,UAAU,CAACD,KAAK,CAAC;gBAAEA;gBAAOO,SAASP,MAAMO,OAAO;gBAAED;YAAK,GAAG;gBAAEE,aAAa;YAAK;QACvF;QAEA,IAAI,CAACC,QAAQ,CAAC;YAAEC,UAAU;QAAK,IAAI,yCAAyC;IAChF;IAEAC,SAAS;QACL,MAAM,EAAEC,UAAUC,WAAWC,eAAe,EAAE,GAAG,IAAI,CAACT,KAAK;QAE3D,MAAM,EAAEK,QAAQ,EAAE,GAAG,IAAI,CAACK,KAAK;QAE/B,IAAIL,UAAU;YACV,MAAMM,gBAAgB;gBAClB,IAAI,CAACP,QAAQ,CAAC;oBAAEC,UAAU;gBAAM,IAAI,yCAAyC;YACjF;YACA,qBAAO,KAACG;gBAASI,WAAWD;;QAChC;QAEA,OAAO,IAAI,CAACX,KAAK,CAACa,QAAQ;IAC9B;;QAhCG,gBACHH,uBAAAA,SAAQ;YACJL,UAAU;QACd;;AA8BJ;;;;;;AAEA,MAAMI,kBAAsB,kBAAM,KAACK;kBAAG"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@servicetitan/error-boundary",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "",
|
|
5
|
-
"homepage": "https://docs.st.dev/docs/frontend/error-boundary",
|
|
3
|
+
"version": "34.0.1",
|
|
4
|
+
"description": "Implementation of React error boundary mechanism",
|
|
5
|
+
"homepage": "https://docs.st.dev/docs/frontend/uikit/error-boundary",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "https://github.com/servicetitan/uikit.git",
|
|
@@ -16,17 +16,17 @@
|
|
|
16
16
|
"src"
|
|
17
17
|
],
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@servicetitan/log-service": "
|
|
20
|
-
"@servicetitan/react-ioc": "
|
|
19
|
+
"@servicetitan/log-service": "34.0.1",
|
|
20
|
+
"@servicetitan/react-ioc": "34.0.1",
|
|
21
21
|
"@testing-library/dom": "^10.4.1",
|
|
22
22
|
"@testing-library/jest-dom": "^6.9.1",
|
|
23
|
-
"@testing-library/react": "^16.3.
|
|
23
|
+
"@testing-library/react": "^16.3.2",
|
|
24
24
|
"@types/react": "~18.3.3",
|
|
25
25
|
"react": "~18.3.1"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
|
-
"@servicetitan/log-service": "
|
|
29
|
-
"@servicetitan/react-ioc": "
|
|
28
|
+
"@servicetitan/log-service": "34.0.1",
|
|
29
|
+
"@servicetitan/react-ioc": "34.0.1",
|
|
30
30
|
"react": ">=17.0.2"
|
|
31
31
|
},
|
|
32
32
|
"publishConfig": {
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"cli": {
|
|
36
36
|
"webpack": false
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "e42375d199bbc11b2f0b8881c26a8f0229446256"
|
|
39
39
|
}
|
|
@@ -3,7 +3,6 @@ import { Provider } from '@servicetitan/react-ioc';
|
|
|
3
3
|
import '@testing-library/jest-dom';
|
|
4
4
|
import { render, screen, waitFor } from '@testing-library/react';
|
|
5
5
|
import { FC, ReactNode } from 'react';
|
|
6
|
-
|
|
7
6
|
import { ErrorBoundary, ErrorBoundaryProps, FallbackProps } from '../error-boundary';
|
|
8
7
|
|
|
9
8
|
describe(`[error-boundary] ${ErrorBoundary.name}`, () => {
|
package/src/error-boundary.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Component, ComponentType, FC, PropsWithChildren } from 'react';
|
|
2
1
|
import { Log } from '@servicetitan/log-service';
|
|
3
2
|
import { injectDependency, optional } from '@servicetitan/react-ioc';
|
|
3
|
+
import { Component, ComponentType, FC, PropsWithChildren } from 'react';
|
|
4
4
|
|
|
5
5
|
export interface FallbackProps {
|
|
6
6
|
onRefresh?: () => void;
|