@moneko/react 2.0.3 → 2.0.5

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/env.d.ts CHANGED
@@ -100,8 +100,8 @@ declare module '@app/info' {
100
100
  export default app;
101
101
  }
102
102
  declare module '@app/routes' {
103
- import type { NonIndexRouteObject } from 'react-router-dom';
104
- export interface RouteConfig extends Omit<NonIndexRouteObject, 'element' | 'children'> {
103
+ import type { RouteObject } from 'react-router-dom';
104
+ export interface RouteConfig extends Omit<RouteObject, 'element' | 'children'> {
105
105
  /** 菜单id */
106
106
  key?: string;
107
107
  value?: string;
@@ -130,9 +130,12 @@ declare module '@app/routes' {
130
130
  hideTabs?: boolean;
131
131
  }
132
132
  const routes: RouteConfig[];
133
- export function lazy(comp: () => Promise<{
134
- default: () => React.JSX.Element;
135
- }>): React.FunctionComponentElement<React.SuspenseProps>
133
+
134
+ export function lazy(
135
+ comp: () => Promise<{
136
+ default: () => React.JSX.Element;
137
+ }>,
138
+ ): React.FunctionComponentElement<React.SuspenseProps>;
136
139
  export default routes;
137
140
  }
138
141
 
@@ -7,11 +7,23 @@ export interface ErrorBoundaryState {
7
7
  error?: Error;
8
8
  errorInfo: {
9
9
  componentStack?: string;
10
+ digest?: string;
10
11
  };
11
12
  }
13
+ declare function parseStackFrame(frame: string);
14
+ declare const __webpack_require__: {
15
+ m: Record<string, string>;
16
+ };
17
+ declare function getSourceFromWebpack(file: string): string | null;
18
+ declare const ErrorStack: ({ stack, heading }: {
19
+ stack?: string;
20
+ heading?: React.ReactNode;
21
+ }) => any;
12
22
  declare class ErrorBoundary extends React.Component<ErrorBoundaryProps, Partial<ErrorBoundaryState>> {
23
+ componentNameRegex: RegExp;
13
24
  constructor(props: ErrorBoundaryProps);
14
25
  componentDidCatch(error: ErrorBoundaryState['error'], errorInfo: ErrorBoundaryState['errorInfo']): void;
26
+ getComponentName(componentStack?: string): string | null;
15
27
  render(): React.ReactNode;
16
28
  }
17
29
  export default ErrorBoundary;
@@ -1 +1,4 @@
1
- import{jsx as r,jsxs as t}from"react/jsx-runtime";import*as e from"react";class o 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 o;
1
+ import{jsx as r,jsxs as e,Fragment as t}from"react/jsx-runtime";import*as n from"react";let o=({stack:o,heading:i})=>{let[a,s]=n.useState(null);if(!o)return null;let l=o.split("\n");return e(t,{children:[i&&e("strong",{children:["🛑 ",i]}),l.map((o,i)=>{let l=function(r){let e=r.match(/webpack-internal:\/\/\/(.*?):(\d+):(\d+)/);if(e){let[r,t,n,o]=e;return{prefix:e.input?.substring(0,e.index),file:t,fileName:t.split("/").pop(),line:parseInt(n,10),column:parseInt(o,10),suffix:e.input?.substring((e.index??0)+r.length)}}let t=r.match(/at (?:(.+?)\s+\()?(?:(.+?):(\d+):(\d+))/);if(t){let[r,e,n,o,i]=t;return{prefix:t.input?.substring(0,t.index),func:e,file:n,fileName:n.split("/").pop(),line:parseInt(o,10),column:parseInt(i,10),suffix:t.input?.substring((t.index??0)+r.length)}}return null}(o);return e(n.Fragment,{children:[" ",l?e(t,{children:[l.prefix,e("a",{style:{color:"var(--link-color, #1677ff)",textDecoration:"none"},onClick:()=>{l.file===a?.file?s(null):s({file:l.file,source:function(r){try{let e=__webpack_require__.m,t=Object.keys(e).find(e=>e.includes(r));if(t)return e[t].toString();return null}catch(r){return r.message}}(l.file)})},children:[l.fileName,":",l.line,":",l.column]}),l.suffix]}):o,r("br",{})]},o+i)}),a&&e("div",{style:{marginBlockStart:16,border:"1px solid var(--warning-border, #ffe58f)",borderRadius:"var(--border-radius, 8px)",padding:16,backgroundColor:"var(--warning-bg, #fffbe6)"},children:[e("strong",{children:["Source: ",a.file]}),r("pre",{style:{whiteSpace:"pre-wrap"},children:a.source})]})]})};class i extends n.Component{constructor(r){super(r),this.componentNameRegex=/at (?:(.+?)\s+\()?(?:(.+?):(\d+):(\d+))/,this.state={}}componentDidCatch(r,e){this.setState({error:r,errorInfo:e})}getComponentName(r){let e=r?.trim().split("\n")?.[0].match(this.componentNameRegex)?.[1];return e?`The above error occurred in the <${e}> component.
2
+
3
+ React will try to recreate this component tree from scratch using the error boundary you provided, ErrorBoundary.
4
+ Error Component Stack`:null}render(){if(this.state.errorInfo){let n=this.props.fallback;return n?r(n,{error:this.state.error,errorInfo:this.state.errorInfo}):r("pre",{className:"error-boundary-component-stack",style:{display:"block",maxInlineSize:"100%",maxBlockSize:"100%",overflow:"auto",margin:24,border:"1px solid var(--error-border, #ffccc7)",borderRadius:"var(--border-radius, 8px)",padding:20,backgroundColor:"var(--error-bg, #fff2f0)",whiteSpace:"pre-wrap",fontSize:12,color:"var(--error-color, rgb(0 0 0 / 75%))",fontFamily:"var(--font-family, inherit)"},children:this.state.error&&e(t,{children:[r(o,{stack:this.state.error.stack?.replace(`${this.state.error.name}: ${this.state.error.message}`,""),heading:`${this.state.error.name}: ${this.state.error.message}`}),r("br",{}),r(o,{stack:this.state.errorInfo.componentStack,heading:this.getComponentName(this.state.errorInfo.componentStack)})]})})}return this.props.children}}export default i;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moneko/react",
3
- "version": "2.0.3",
3
+ "version": "2.0.5",
4
4
  "description": "react",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -18,8 +18,8 @@
18
18
  "@pmmmwh/react-refresh-webpack-plugin": "0.5.15",
19
19
  "react-refresh": "0.16.0",
20
20
  "react-refresh-typescript": "2.0.10",
21
- "react-router": "6.4.0",
22
- "react-router-dom": "6.4.0",
21
+ "react-router": "6.3.0",
22
+ "react-router-dom": "6.3.0",
23
23
  "shared-store-object": "1.2.1"
24
24
  },
25
25
  "devDependencies": {