@wordpress/plugins 7.26.1-next.719a03cbe.0 → 7.27.0
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/CHANGELOG.md +2 -0
- package/build/components/index.js.map +1 -1
- package/build/components/plugin-error-boundary/index.js +4 -7
- package/build/components/plugin-error-boundary/index.js.map +1 -1
- package/build/index.js.map +1 -1
- package/build/types.js +6 -0
- package/build/types.js.map +1 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/plugin-error-boundary/index.js +5 -7
- package/build-module/components/plugin-error-boundary/index.js.map +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/types.js +2 -0
- package/build-module/types.js.map +1 -0
- package/build-types/components/index.d.ts +2 -2
- package/build-types/components/index.d.ts.map +1 -1
- package/build-types/components/plugin-error-boundary/index.d.ts +12 -16
- package/build-types/components/plugin-error-boundary/index.d.ts.map +1 -1
- package/build-types/index.d.ts +2 -2
- package/build-types/index.d.ts.map +1 -1
- package/build-types/types.d.ts +24 -0
- package/build-types/types.d.ts.map +1 -0
- package/package.json +9 -9
- package/src/components/plugin-error-boundary/{index.js → index.tsx} +13 -11
- package/src/types.ts +24 -0
- package/tsconfig.tsbuildinfo +1 -1
- /package/src/components/{index.js → index.ts} +0 -0
- /package/src/{index.js → index.ts} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_pluginArea","_interopRequireDefault","require","_pluginContext"],"sources":["@wordpress/plugins/src/components/index.
|
|
1
|
+
{"version":3,"names":["_pluginArea","_interopRequireDefault","require","_pluginContext"],"sources":["@wordpress/plugins/src/components/index.ts"],"sourcesContent":["export { default as PluginArea } from './plugin-area';\nexport { usePluginContext, withPluginContext } from './plugin-context';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA","ignoreList":[]}
|
|
@@ -9,10 +9,11 @@ var _element = require("@wordpress/element");
|
|
|
9
9
|
* WordPress dependencies
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Internal dependencies
|
|
14
|
+
*/
|
|
15
|
+
|
|
12
16
|
class PluginErrorBoundary extends _element.Component {
|
|
13
|
-
/**
|
|
14
|
-
* @param {Object} props
|
|
15
|
-
*/
|
|
16
17
|
constructor(props) {
|
|
17
18
|
super(props);
|
|
18
19
|
this.state = {
|
|
@@ -24,10 +25,6 @@ class PluginErrorBoundary extends _element.Component {
|
|
|
24
25
|
hasError: true
|
|
25
26
|
};
|
|
26
27
|
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* @param {Error} error Error object passed by React.
|
|
30
|
-
*/
|
|
31
28
|
componentDidCatch(error) {
|
|
32
29
|
const {
|
|
33
30
|
name,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_element","require","PluginErrorBoundary","Component","constructor","props","state","hasError","getDerivedStateFromError","componentDidCatch","error","name","onError","render","children","exports"],"sources":["@wordpress/plugins/src/components/plugin-error-boundary/index.
|
|
1
|
+
{"version":3,"names":["_element","require","PluginErrorBoundary","Component","constructor","props","state","hasError","getDerivedStateFromError","componentDidCatch","error","name","onError","render","children","exports"],"sources":["@wordpress/plugins/src/components/plugin-error-boundary/index.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tPluginErrorBoundaryProps as Props,\n\tPluginErrorBoundaryState as State,\n} from '../../types';\n\nexport class PluginErrorBoundary extends Component< Props, State > {\n\tconstructor( props: Props ) {\n\t\tsuper( props );\n\t\tthis.state = {\n\t\t\thasError: false,\n\t\t};\n\t}\n\n\tstatic getDerivedStateFromError(): State {\n\t\treturn { hasError: true };\n\t}\n\n\tcomponentDidCatch( error: Error ): void {\n\t\tconst { name, onError } = this.props;\n\t\tif ( onError ) {\n\t\t\tonError( name, error );\n\t\t}\n\t}\n\n\trender(): React.ReactNode {\n\t\tif ( ! this.state.hasError ) {\n\t\t\treturn this.props.children;\n\t\t}\n\n\t\treturn null;\n\t}\n}\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;;AAMO,MAAMC,mBAAmB,SAASC,kBAAS,CAAiB;EAClEC,WAAWA,CAAEC,KAAY,EAAG;IAC3B,KAAK,CAAEA,KAAM,CAAC;IACd,IAAI,CAACC,KAAK,GAAG;MACZC,QAAQ,EAAE;IACX,CAAC;EACF;EAEA,OAAOC,wBAAwBA,CAAA,EAAU;IACxC,OAAO;MAAED,QAAQ,EAAE;IAAK,CAAC;EAC1B;EAEAE,iBAAiBA,CAAEC,KAAY,EAAS;IACvC,MAAM;MAAEC,IAAI;MAAEC;IAAQ,CAAC,GAAG,IAAI,CAACP,KAAK;IACpC,IAAKO,OAAO,EAAG;MACdA,OAAO,CAAED,IAAI,EAAED,KAAM,CAAC;IACvB;EACD;EAEAG,MAAMA,CAAA,EAAoB;IACzB,IAAK,CAAE,IAAI,CAACP,KAAK,CAACC,QAAQ,EAAG;MAC5B,OAAO,IAAI,CAACF,KAAK,CAACS,QAAQ;IAC3B;IAEA,OAAO,IAAI;EACZ;AACD;AAACC,OAAA,CAAAb,mBAAA,GAAAA,mBAAA","ignoreList":[]}
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_components","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_api"],"sources":["@wordpress/plugins/src/index.
|
|
1
|
+
{"version":3,"names":["_components","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_api"],"sources":["@wordpress/plugins/src/index.ts"],"sourcesContent":["export * from './components';\nexport * from './api';\n"],"mappings":";;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,WAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,WAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,WAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,IAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,IAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,IAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,IAAA,CAAAL,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
package/build/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["@wordpress/plugins/src/types.ts"],"sourcesContent":["/**\n * Props for the PluginErrorBoundary component.\n */\nexport interface PluginErrorBoundaryProps {\n\t/**\n\t * The name of the plugin that may encounter an error.\n\t */\n\tname: string;\n\t/**\n\t * The child components to render.\n\t */\n\tchildren: React.ReactNode;\n\t/**\n\t * Callback function called when an error occurs.\n\t */\n\tonError?: ( name: string, error: Error ) => void;\n}\n\n/**\n * State for the PluginErrorBoundary component.\n */\nexport interface PluginErrorBoundaryState {\n\thasError: boolean;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["default","PluginArea","usePluginContext","withPluginContext"],"sources":["@wordpress/plugins/src/components/index.
|
|
1
|
+
{"version":3,"names":["default","PluginArea","usePluginContext","withPluginContext"],"sources":["@wordpress/plugins/src/components/index.ts"],"sourcesContent":["export { default as PluginArea } from './plugin-area';\nexport { usePluginContext, withPluginContext } from './plugin-context';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,UAAU,QAAQ,eAAe;AACrD,SAASC,gBAAgB,EAAEC,iBAAiB,QAAQ,kBAAkB","ignoreList":[]}
|
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { Component } from '@wordpress/element';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
|
|
5
10
|
export class PluginErrorBoundary extends Component {
|
|
6
|
-
/**
|
|
7
|
-
* @param {Object} props
|
|
8
|
-
*/
|
|
9
11
|
constructor(props) {
|
|
10
12
|
super(props);
|
|
11
13
|
this.state = {
|
|
@@ -17,10 +19,6 @@ export class PluginErrorBoundary extends Component {
|
|
|
17
19
|
hasError: true
|
|
18
20
|
};
|
|
19
21
|
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* @param {Error} error Error object passed by React.
|
|
23
|
-
*/
|
|
24
22
|
componentDidCatch(error) {
|
|
25
23
|
const {
|
|
26
24
|
name,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Component","PluginErrorBoundary","constructor","props","state","hasError","getDerivedStateFromError","componentDidCatch","error","name","onError","render","children"],"sources":["@wordpress/plugins/src/components/plugin-error-boundary/index.
|
|
1
|
+
{"version":3,"names":["Component","PluginErrorBoundary","constructor","props","state","hasError","getDerivedStateFromError","componentDidCatch","error","name","onError","render","children"],"sources":["@wordpress/plugins/src/components/plugin-error-boundary/index.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tPluginErrorBoundaryProps as Props,\n\tPluginErrorBoundaryState as State,\n} from '../../types';\n\nexport class PluginErrorBoundary extends Component< Props, State > {\n\tconstructor( props: Props ) {\n\t\tsuper( props );\n\t\tthis.state = {\n\t\t\thasError: false,\n\t\t};\n\t}\n\n\tstatic getDerivedStateFromError(): State {\n\t\treturn { hasError: true };\n\t}\n\n\tcomponentDidCatch( error: Error ): void {\n\t\tconst { name, onError } = this.props;\n\t\tif ( onError ) {\n\t\t\tonError( name, error );\n\t\t}\n\t}\n\n\trender(): React.ReactNode {\n\t\tif ( ! this.state.hasError ) {\n\t\t\treturn this.props.children;\n\t\t}\n\n\t\treturn null;\n\t}\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,oBAAoB;;AAE9C;AACA;AACA;;AAMA,OAAO,MAAMC,mBAAmB,SAASD,SAAS,CAAiB;EAClEE,WAAWA,CAAEC,KAAY,EAAG;IAC3B,KAAK,CAAEA,KAAM,CAAC;IACd,IAAI,CAACC,KAAK,GAAG;MACZC,QAAQ,EAAE;IACX,CAAC;EACF;EAEA,OAAOC,wBAAwBA,CAAA,EAAU;IACxC,OAAO;MAAED,QAAQ,EAAE;IAAK,CAAC;EAC1B;EAEAE,iBAAiBA,CAAEC,KAAY,EAAS;IACvC,MAAM;MAAEC,IAAI;MAAEC;IAAQ,CAAC,GAAG,IAAI,CAACP,KAAK;IACpC,IAAKO,OAAO,EAAG;MACdA,OAAO,CAAED,IAAI,EAAED,KAAM,CAAC;IACvB;EACD;EAEAG,MAAMA,CAAA,EAAoB;IACzB,IAAK,CAAE,IAAI,CAACP,KAAK,CAACC,QAAQ,EAAG;MAC5B,OAAO,IAAI,CAACF,KAAK,CAACS,QAAQ;IAC3B;IAEA,OAAO,IAAI;EACZ;AACD","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["@wordpress/plugins/src/index.
|
|
1
|
+
{"version":3,"names":[],"sources":["@wordpress/plugins/src/index.ts"],"sourcesContent":["export * from './components';\nexport * from './api';\n"],"mappings":"AAAA,cAAc,cAAc;AAC5B,cAAc,OAAO","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["@wordpress/plugins/src/types.ts"],"sourcesContent":["/**\n * Props for the PluginErrorBoundary component.\n */\nexport interface PluginErrorBoundaryProps {\n\t/**\n\t * The name of the plugin that may encounter an error.\n\t */\n\tname: string;\n\t/**\n\t * The child components to render.\n\t */\n\tchildren: React.ReactNode;\n\t/**\n\t * Callback function called when an error occurs.\n\t */\n\tonError?: ( name: string, error: Error ) => void;\n}\n\n/**\n * State for the PluginErrorBoundary component.\n */\nexport interface PluginErrorBoundaryState {\n\thasError: boolean;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { default as PluginArea } from
|
|
2
|
-
export { usePluginContext, withPluginContext } from
|
|
1
|
+
export { default as PluginArea } from './plugin-area';
|
|
2
|
+
export { usePluginContext, withPluginContext } from './plugin-context';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -1,19 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @param {Error} error Error object passed by React.
|
|
14
|
-
*/
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { Component } from '@wordpress/element';
|
|
5
|
+
/**
|
|
6
|
+
* Internal dependencies
|
|
7
|
+
*/
|
|
8
|
+
import type { PluginErrorBoundaryProps as Props, PluginErrorBoundaryState as State } from '../../types';
|
|
9
|
+
export declare class PluginErrorBoundary extends Component<Props, State> {
|
|
10
|
+
constructor(props: Props);
|
|
11
|
+
static getDerivedStateFromError(): State;
|
|
15
12
|
componentDidCatch(error: Error): void;
|
|
16
|
-
render():
|
|
13
|
+
render(): React.ReactNode;
|
|
17
14
|
}
|
|
18
|
-
import { Component } from '@wordpress/element';
|
|
19
15
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/plugin-error-boundary/index.
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/plugin-error-boundary/index.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C;;GAEG;AACH,OAAO,KAAK,EACX,wBAAwB,IAAI,KAAK,EACjC,wBAAwB,IAAI,KAAK,EACjC,MAAM,aAAa,CAAC;AAErB,qBAAa,mBAAoB,SAAQ,SAAS,CAAE,KAAK,EAAE,KAAK,CAAE;gBACpD,KAAK,EAAE,KAAK;IAOzB,MAAM,CAAC,wBAAwB,IAAI,KAAK;IAIxC,iBAAiB,CAAE,KAAK,EAAE,KAAK,GAAI,IAAI;IAOvC,MAAM,IAAI,KAAK,CAAC,SAAS;CAOzB"}
|
package/build-types/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
1
|
+
export * from './components';
|
|
2
|
+
export * from './api';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,OAAO,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Props for the PluginErrorBoundary component.
|
|
3
|
+
*/
|
|
4
|
+
export interface PluginErrorBoundaryProps {
|
|
5
|
+
/**
|
|
6
|
+
* The name of the plugin that may encounter an error.
|
|
7
|
+
*/
|
|
8
|
+
name: string;
|
|
9
|
+
/**
|
|
10
|
+
* The child components to render.
|
|
11
|
+
*/
|
|
12
|
+
children: React.ReactNode;
|
|
13
|
+
/**
|
|
14
|
+
* Callback function called when an error occurs.
|
|
15
|
+
*/
|
|
16
|
+
onError?: (name: string, error: Error) => void;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* State for the PluginErrorBoundary component.
|
|
20
|
+
*/
|
|
21
|
+
export interface PluginErrorBoundaryState {
|
|
22
|
+
hasError: boolean;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACxC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B;;OAEG;IACH,OAAO,CAAC,EAAE,CAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,KAAM,IAAI,CAAC;CACjD;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACxC,QAAQ,EAAE,OAAO,CAAC;CAClB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/plugins",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.27.0",
|
|
4
4
|
"description": "Plugins module for WordPress.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -29,13 +29,13 @@
|
|
|
29
29
|
"types": "build-types",
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@babel/runtime": "7.25.7",
|
|
32
|
-
"@wordpress/components": "^
|
|
33
|
-
"@wordpress/compose": "^7.
|
|
34
|
-
"@wordpress/deprecated": "^4.
|
|
35
|
-
"@wordpress/element": "^6.
|
|
36
|
-
"@wordpress/hooks": "^4.
|
|
37
|
-
"@wordpress/icons": "^10.
|
|
38
|
-
"@wordpress/is-shallow-equal": "^5.
|
|
32
|
+
"@wordpress/components": "^30.0.0",
|
|
33
|
+
"@wordpress/compose": "^7.27.0",
|
|
34
|
+
"@wordpress/deprecated": "^4.27.0",
|
|
35
|
+
"@wordpress/element": "^6.27.0",
|
|
36
|
+
"@wordpress/hooks": "^4.27.0",
|
|
37
|
+
"@wordpress/icons": "^10.27.0",
|
|
38
|
+
"@wordpress/is-shallow-equal": "^5.27.0",
|
|
39
39
|
"memize": "^2.0.1"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"publishConfig": {
|
|
46
46
|
"access": "public"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "abe06a6f2aef8d03c30ea9d5b3e133f041e523b1"
|
|
49
49
|
}
|
|
@@ -3,32 +3,34 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { Component } from '@wordpress/element';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import type {
|
|
10
|
+
PluginErrorBoundaryProps as Props,
|
|
11
|
+
PluginErrorBoundaryState as State,
|
|
12
|
+
} from '../../types';
|
|
13
|
+
|
|
14
|
+
export class PluginErrorBoundary extends Component< Props, State > {
|
|
15
|
+
constructor( props: Props ) {
|
|
11
16
|
super( props );
|
|
12
17
|
this.state = {
|
|
13
18
|
hasError: false,
|
|
14
19
|
};
|
|
15
20
|
}
|
|
16
21
|
|
|
17
|
-
static getDerivedStateFromError() {
|
|
22
|
+
static getDerivedStateFromError(): State {
|
|
18
23
|
return { hasError: true };
|
|
19
24
|
}
|
|
20
25
|
|
|
21
|
-
|
|
22
|
-
* @param {Error} error Error object passed by React.
|
|
23
|
-
*/
|
|
24
|
-
componentDidCatch( error ) {
|
|
26
|
+
componentDidCatch( error: Error ): void {
|
|
25
27
|
const { name, onError } = this.props;
|
|
26
28
|
if ( onError ) {
|
|
27
29
|
onError( name, error );
|
|
28
30
|
}
|
|
29
31
|
}
|
|
30
32
|
|
|
31
|
-
render() {
|
|
33
|
+
render(): React.ReactNode {
|
|
32
34
|
if ( ! this.state.hasError ) {
|
|
33
35
|
return this.props.children;
|
|
34
36
|
}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Props for the PluginErrorBoundary component.
|
|
3
|
+
*/
|
|
4
|
+
export interface PluginErrorBoundaryProps {
|
|
5
|
+
/**
|
|
6
|
+
* The name of the plugin that may encounter an error.
|
|
7
|
+
*/
|
|
8
|
+
name: string;
|
|
9
|
+
/**
|
|
10
|
+
* The child components to render.
|
|
11
|
+
*/
|
|
12
|
+
children: React.ReactNode;
|
|
13
|
+
/**
|
|
14
|
+
* Callback function called when an error occurs.
|
|
15
|
+
*/
|
|
16
|
+
onError?: ( name: string, error: Error ) => void;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* State for the PluginErrorBoundary component.
|
|
21
|
+
*/
|
|
22
|
+
export interface PluginErrorBoundaryState {
|
|
23
|
+
hasError: boolean;
|
|
24
|
+
}
|