@moneko/react 1.5.7 → 1.6.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/lib/error-boundary.d.ts +26 -0
- package/lib/error-boundary.js +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -1
- package/package.json +6 -6
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export declare const a: any;
|
|
3
|
+
export interface ErrorBoundaryProps {
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
/**
|
|
6
|
+
* 自定义错误降级组件
|
|
7
|
+
*/
|
|
8
|
+
fallback?: React.ComponentType<ErrorBoundaryState>;
|
|
9
|
+
}
|
|
10
|
+
/** 错误边界状态 */
|
|
11
|
+
export interface ErrorBoundaryState {
|
|
12
|
+
/** 捕获的错误 */
|
|
13
|
+
error?: Error;
|
|
14
|
+
/** 错误信息 */
|
|
15
|
+
errorInfo: {
|
|
16
|
+
/** 组件堆栈 */
|
|
17
|
+
componentStack?: string;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/** 错误边界 */
|
|
21
|
+
declare class ErrorBoundary extends React.Component<ErrorBoundaryProps, Partial<ErrorBoundaryState>> {
|
|
22
|
+
constructor(props: ErrorBoundaryProps);
|
|
23
|
+
componentDidCatch(error: ErrorBoundaryState['error'], errorInfo: ErrorBoundaryState['errorInfo']): void;
|
|
24
|
+
render(): string | number | boolean | React.JSX.Element | Iterable<React.ReactNode> | null | undefined;
|
|
25
|
+
}
|
|
26
|
+
export default ErrorBoundary;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as r,jsxs as t}from"react/jsx-runtime";import*as e from"react";import o from"lodash/isEqual";export const a=o;class s extends e.Component{constructor(r){super(r),this.state={}}componentDidCatch(r,t){this.setState({error:r,errorInfo:t})}render(){if(this.state.errorInfo){let e=this.props.fallback;return e?r(e,{error:this.state.error,errorInfo:this.state.errorInfo}):t("div",{children:[r("h2",{children:"Something went wrong."}),t("details",{style:{whiteSpace:"pre-wrap",color:"var(--error-color, red)"},children:[this.state.error&&this.state.error.toString(),r("br",{}),this.state.errorInfo.componentStack]})]})}return this.props.children}}export default s;
|
package/lib/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export * from 'react-router-dom';
|
|
|
3
3
|
export { default as LinkWithMenuId } from './link.js';
|
|
4
4
|
export { default as useNavigateWithMenuId } from './use-navgate.js';
|
|
5
5
|
export { default as renderApp, App } from './entry.js';
|
|
6
|
+
export { default as ErrorBoundary, type ErrorBoundaryProps, type ErrorBoundaryState, } from './error-boundary.js';
|
|
6
7
|
export type RenderAppProps = {
|
|
7
8
|
container?: HTMLElement;
|
|
8
9
|
basename?: string;
|
package/lib/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as
|
|
1
|
+
import*as r from"react";export*from"react-router-dom";export{default as LinkWithMenuId}from"./link.js";export{default as useNavigateWithMenuId}from"./use-navgate.js";export{default as renderApp,App}from"./entry.js";export{default as ErrorBoundary}from"./error-boundary.js";export default r;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moneko/react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "react",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -15,21 +15,21 @@
|
|
|
15
15
|
"@pmmmwh/react-refresh-webpack-plugin": "0.5.15",
|
|
16
16
|
"react-refresh": "0.14.2",
|
|
17
17
|
"react-refresh-typescript": "2.0.9",
|
|
18
|
-
"react-router": "6.
|
|
19
|
-
"react-router-dom": "6.
|
|
18
|
+
"react-router": "6.25.1",
|
|
19
|
+
"react-router-dom": "6.25.1",
|
|
20
20
|
"shared-store-object": "1.1.1"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@moneko/transform-imports": "0.6.0",
|
|
24
24
|
"@swc/cli": "0.4.0",
|
|
25
|
-
"@swc/core": "1.
|
|
26
|
-
"@types/node": "20.14.
|
|
25
|
+
"@swc/core": "1.7.3",
|
|
26
|
+
"@types/node": "20.14.12",
|
|
27
27
|
"@types/react": "18.3.3",
|
|
28
28
|
"@types/react-dom": "18.3.0",
|
|
29
29
|
"eslint-config-neko": "2.8.4",
|
|
30
30
|
"react": "18.3.1",
|
|
31
31
|
"react-dom": "18.3.1",
|
|
32
|
-
"typescript": "5.5.
|
|
32
|
+
"typescript": "5.5.4"
|
|
33
33
|
},
|
|
34
34
|
"files": [
|
|
35
35
|
"lib",
|