@moneko/react 1.7.0-beta.2 → 1.7.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 → error-boundary.d.tsx} +2 -10
- package/lib/error-boundary.js +1 -1
- package/lib/index.d.ts +3 -7
- package/lib/inject-react-refresh.d.ts +3 -1
- package/lib/link.d.tsx +8 -0
- package/lib/link.js +1 -1
- package/lib/use-navgate.d.ts +2 -5
- package/mdx.d.ts +5 -3
- package/mdx.js +1 -1
- package/package.json +13 -13
- package/lib/link.d.ts +0 -12
|
@@ -1,25 +1,17 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
export interface ErrorBoundaryProps {
|
|
3
3
|
children: React.ReactNode;
|
|
4
|
-
/**
|
|
5
|
-
* 自定义错误降级组件
|
|
6
|
-
*/
|
|
7
4
|
fallback?: React.ComponentType<ErrorBoundaryState>;
|
|
8
5
|
}
|
|
9
|
-
/** 错误边界状态 */
|
|
10
6
|
export interface ErrorBoundaryState {
|
|
11
|
-
/** 捕获的错误 */
|
|
12
7
|
error?: Error;
|
|
13
|
-
/** 错误信息 */
|
|
14
8
|
errorInfo: {
|
|
15
|
-
/** 组件堆栈 */
|
|
16
9
|
componentStack?: string;
|
|
17
10
|
};
|
|
18
11
|
}
|
|
19
|
-
/** 错误边界 */
|
|
20
12
|
declare class ErrorBoundary extends React.Component<ErrorBoundaryProps, Partial<ErrorBoundaryState>> {
|
|
21
13
|
constructor(props: ErrorBoundaryProps);
|
|
22
|
-
componentDidCatch(error: ErrorBoundaryState['error'], errorInfo: ErrorBoundaryState['errorInfo'])
|
|
23
|
-
render()
|
|
14
|
+
componentDidCatch(error: ErrorBoundaryState['error'], errorInfo: ErrorBoundaryState['errorInfo']);
|
|
15
|
+
render();
|
|
24
16
|
}
|
|
25
17
|
export default ErrorBoundary;
|
package/lib/error-boundary.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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
|
|
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;
|
package/lib/index.d.ts
CHANGED
|
@@ -2,16 +2,12 @@ import * as React from 'react';
|
|
|
2
2
|
export * from 'react-router-dom';
|
|
3
3
|
export { default as useNavigate } from './use-navgate.js';
|
|
4
4
|
export { default as Link } from './link.js';
|
|
5
|
-
export {
|
|
6
|
-
|
|
7
|
-
useNavigate as useNavigateReactRouter,
|
|
8
|
-
/** 原版 Link */
|
|
9
|
-
Link as LinkReactRouter, } from 'react-router-dom';
|
|
10
|
-
export { default as ErrorBoundary, type ErrorBoundaryProps, type ErrorBoundaryState, } from './error-boundary.js';
|
|
5
|
+
export { useNavigate as useNavigateReactRouter, Link as LinkReactRouter } from 'react-router-dom';
|
|
6
|
+
export { default as ErrorBoundary, type ErrorBoundaryProps, type ErrorBoundaryState } from './error-boundary.js';
|
|
11
7
|
export type RenderAppProps = {
|
|
12
8
|
container?: HTMLElement;
|
|
13
9
|
basename?: string;
|
|
14
|
-
fallback?: JSX.Element;
|
|
10
|
+
fallback?: React.JSX.Element;
|
|
15
11
|
language?: string;
|
|
16
12
|
};
|
|
17
13
|
export default React;
|
package/lib/link.d.tsx
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React, { type FC, useMemo } from 'react';
|
|
2
|
+
import { Link as ReactRouterLink, type LinkProps as ReactRouterLinkProps, type To, useSearchParams } from 'react-router-dom';
|
|
3
|
+
export interface LinkProps extends Omit<ReactRouterLinkProps, 'to'> {
|
|
4
|
+
reserved?: string | string[];
|
|
5
|
+
to: To | -1;
|
|
6
|
+
}
|
|
7
|
+
declare const Link: FC<LinkProps>;
|
|
8
|
+
export default Link;
|
package/lib/link.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as r}from"react/jsx-runtime";import{useMemo as e}from"react";import{Link as t,useSearchParams as a}from"react-router-dom";export default(({reserved:i,to:n,children:o,...m})=>{let l=e(()=>["menuId","dynamicTitle",...Array.isArray(i)?i:[i]].filter(Boolean),[i]),[c]=a(),s=e(()=>{if(-1===n)return -1;let r={};c.forEach((e,t)=>{l.includes(t)&&(r[t]=e)});let e=n,t=e.indexOf("?");-1!==t&&(new URLSearchParams(e.slice(t)).forEach((e,t)=>{r[t]=e}),e=e.substring(0,t));let a=new URLSearchParams(r).toString();return a?.trim().length?[e,a].join("?"):e},[l,c,n]);return
|
|
1
|
+
import{jsx as r}from"react/jsx-runtime";import{useMemo as e}from"react";import{Link as t,useSearchParams as a}from"react-router-dom";export default(({reserved:i,to:n,children:o,...m})=>{let l=e(()=>["menuId","dynamicTitle",...Array.isArray(i)?i:[i]].filter(Boolean),[i]),[c]=a(),s=e(()=>{if(-1===n)return -1;let r={};c.forEach((e,t)=>{l.includes(t)&&(r[t]=e)});let e=n,t=e.indexOf("?");-1!==t&&(new URLSearchParams(e.slice(t)).forEach((e,t)=>{r[t]=e}),e=e.substring(0,t));let a=new URLSearchParams(r).toString();return a?.trim().length?[e,a].join("?"):e},[l,c,n]);return r(t,{...m,to:s,children:o})});
|
package/lib/use-navgate.d.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { type NavigateOptions, type To } from 'react-router-dom';
|
|
2
|
-
|
|
3
|
-
* @default {string[]} ['menuId', 'dynamicTitle']
|
|
4
|
-
*/
|
|
5
|
-
declare const useNavigate: (reserved?: string | string[]) => (to: To | -1, options?: NavigateOptions) => void;
|
|
1
|
+
import { type NavigateOptions, type To, useNavigate as useNavigateReactRouter, useSearchParams } from 'react-router-dom';
|
|
2
|
+
declare const useNavigate: (reserved?: string | string[]) => any;
|
|
6
3
|
export default useNavigate;
|
package/mdx.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
export interface MDXComponents {
|
|
3
|
-
[k: string]: (props: Record<string, any>) => JSX.Element;
|
|
3
|
+
[k: string]: (props: Record<string, any>) => React.JSX.Element;
|
|
4
4
|
}
|
|
5
5
|
export interface MDXProviderProps extends React.Component {
|
|
6
|
-
children: JSX.Element;
|
|
6
|
+
children: React.JSX.Element;
|
|
7
7
|
components: MDXComponents | ((props: Record<string, any>) => MDXComponents);
|
|
8
8
|
disableParentContext?: boolean;
|
|
9
9
|
}
|
|
10
|
+
declare const emptyComponents: Readonly<MDXComponents>;
|
|
11
|
+
declare const MDXContext: React.Context<Readonly<MDXComponents>>;
|
|
10
12
|
export declare function useMDXComponents(components: MDXComponents | ((props: Record<string, any>) => MDXComponents)): MDXComponents;
|
|
11
|
-
export declare function MDXProvider(props: MDXProviderProps): JSX.Element;
|
|
13
|
+
export declare function MDXProvider(props: MDXProviderProps): React.JSX.Element;
|
package/mdx.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e}from"react/jsx-runtime";import*as t from"react";let n={},o
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import*as t from"react";let n={},o=t.createContext(n);export function useMDXComponents(e){let n=t.useContext(o);return t.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}export function MDXProvider(r){let s=t.useMemo(()=>r.disableParentContext?"function"==typeof r.components?r.components(n):r.components||n:useMDXComponents(r.components),[r.components,r.disableParentContext]);return e(o.Provider,{value:s,children:r.children})}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moneko/react",
|
|
3
|
-
"version": "1.7.0
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "react",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"prebuild": "rm -rf ./lib",
|
|
8
|
-
"
|
|
9
|
-
"
|
|
8
|
+
"build": "node ./build.mjs",
|
|
9
|
+
"prepublishOnly": "npm run build"
|
|
10
10
|
},
|
|
11
11
|
"author": "moneko",
|
|
12
12
|
"type": "module",
|
|
@@ -20,16 +20,16 @@
|
|
|
20
20
|
"shared-store-object": "1.1.4"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@moneko/
|
|
24
|
-
"@
|
|
25
|
-
"@
|
|
26
|
-
"@types/node": "22.
|
|
27
|
-
"@types/react": "
|
|
28
|
-
"@types/react-dom": "
|
|
29
|
-
"eslint-config-neko": "3.0.
|
|
30
|
-
"react": "
|
|
31
|
-
"react-dom": "
|
|
32
|
-
"typescript": "5.
|
|
23
|
+
"@moneko/convert": "1.0.0",
|
|
24
|
+
"@moneko/transform-imports": "0.6.1",
|
|
25
|
+
"@moneko/utils": "0.1.22",
|
|
26
|
+
"@types/node": "22.10.5",
|
|
27
|
+
"@types/react": "19.0.2",
|
|
28
|
+
"@types/react-dom": "19.0.2",
|
|
29
|
+
"eslint-config-neko": "3.0.3",
|
|
30
|
+
"react": "19.0.0",
|
|
31
|
+
"react-dom": "19.0.0",
|
|
32
|
+
"typescript": "5.7.2"
|
|
33
33
|
},
|
|
34
34
|
"files": [
|
|
35
35
|
"lib",
|
package/lib/link.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { type FC } from 'react';
|
|
2
|
-
import { type LinkProps as ReactRouterLinkProps, type To } from 'react-router-dom';
|
|
3
|
-
export interface LinkProps extends Omit<ReactRouterLinkProps, 'to'> {
|
|
4
|
-
/** 保留字 */
|
|
5
|
-
reserved?: string | string[];
|
|
6
|
-
to: To | -1;
|
|
7
|
-
}
|
|
8
|
-
/** 跳转时继承部分query参数
|
|
9
|
-
* @default {string[]} ['menuId', 'dynamicTitle']
|
|
10
|
-
*/
|
|
11
|
-
declare const Link: FC<LinkProps>;
|
|
12
|
-
export default Link;
|