@moneko/react 1.7.0-beta.2 → 1.7.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/lib/{error-boundary.d.ts → error-boundary.d.tsx} +2 -10
- package/lib/error-boundary.js +1 -1
- package/lib/index.d.ts +4 -7
- package/lib/index.js +1 -1
- package/lib/inject-react-refresh.d.ts +3 -1
- package/lib/link.d.tsx +8 -0
- package/lib/link.js +1 -1
- package/lib/parse-reserved-word.d.ts +5 -0
- package/lib/parse-reserved-word.js +1 -0
- package/lib/use-navgate.d.ts +3 -5
- package/lib/use-navgate.js +1 -1
- package/lib/use-query.d.ts +4 -0
- package/lib/use-query.js +1 -0
- package/mdx.d.ts +5 -3
- package/mdx.js +1 -1
- package/package.json +14 -14
- 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,13 @@ 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
|
-
|
|
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 { default as useQuery } from './use-query.js';
|
|
6
|
+
export { useNavigate as useNavigateReactRouter, Link as LinkReactRouter } from 'react-router-dom';
|
|
7
|
+
export { default as ErrorBoundary, type ErrorBoundaryProps, type ErrorBoundaryState } from './error-boundary.js';
|
|
11
8
|
export type RenderAppProps = {
|
|
12
9
|
container?: HTMLElement;
|
|
13
10
|
basename?: string;
|
|
14
|
-
fallback?: JSX.Element;
|
|
11
|
+
fallback?: React.JSX.Element;
|
|
15
12
|
language?: string;
|
|
16
13
|
};
|
|
17
14
|
export default React;
|
package/lib/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as
|
|
1
|
+
import*as e from"react";export*from"react-router-dom";export{default as useNavigate}from"./use-navgate.js";export{default as Link}from"./link.js";export{default as useQuery}from"./use-query.js";export{useNavigate as useNavigateReactRouter,Link as LinkReactRouter}from"react-router-dom";export{default as ErrorBoundary}from"./error-boundary.js";export default e;
|
package/lib/link.d.tsx
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Link as ReactRouterLink, type LinkProps as ReactRouterLinkProps } from 'react-router-dom';
|
|
3
|
+
import parseToByReservedWord from './parse-reserved-word.js';
|
|
4
|
+
export interface LinkProps extends ReactRouterLinkProps {
|
|
5
|
+
reserved?: string | string[];
|
|
6
|
+
}
|
|
7
|
+
declare const Link: React.FC<LinkProps>;
|
|
8
|
+
export default Link;
|
package/lib/link.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as r}from"react/jsx-runtime";import
|
|
1
|
+
import{jsx as r}from"react/jsx-runtime";import"react";import{Link as e}from"react-router-dom";import o from"./parse-reserved-word.js";export default(({reserved:t,to:m,children:a,...i})=>r(e,{...i,to:o(m,t),children:a}));
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { To } from 'react-router-dom';
|
|
2
|
+
declare function parse(reserved?: string | string[]);
|
|
3
|
+
declare function parseReservedWord(reserved?: string | string[]): string[];
|
|
4
|
+
declare const parseToByReservedWord: (to: To, reserved?: string | string[]) => any;
|
|
5
|
+
export default parseToByReservedWord;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default((e,a)=>{let r,t,s;if("string"==typeof e){let a=e.split("?");t=a[0],r=new URLSearchParams(a[1])}else t=e.pathname,r=new URLSearchParams(e.search),s=e.hash;let n=new URLSearchParams(location.search);return Array.from(new Set(["menuId","dynamicTitle",...(Array.isArray(a)?a:[a]).filter(Boolean)])).forEach(e=>{n.has(e)&&r.set(e,n.get(e))}),{pathname:t,search:r.toString(),hash:s}});
|
package/lib/use-navgate.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { type NavigateOptions, type To } from 'react-router-dom';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
*/
|
|
5
|
-
declare const useNavigate: (reserved?: string | string[]) => (to: To | -1, options?: NavigateOptions) => void;
|
|
1
|
+
import { type NavigateFunction, type NavigateOptions, type To, useNavigate as useNavigateReactRouter } from 'react-router-dom';
|
|
2
|
+
import parseToByReservedWord from './parse-reserved-word.js';
|
|
3
|
+
declare const useNavigate: (reserved?: string | string[]) => NavigateFunction;
|
|
6
4
|
export default useNavigate;
|
package/lib/use-navgate.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useNavigate as
|
|
1
|
+
import{useNavigate as r}from"react-router-dom";import e from"./parse-reserved-word.js";export default(t=>{let o=r();return(r,a)=>"number"==typeof r?o(r):o(e(r,t),a)});
|
package/lib/use-query.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useMemo as r}from"react";import{useLocation as e}from"react-router-dom";export default(()=>{let t=e();return r(()=>Object.fromEntries(new URLSearchParams(t.search)),[t.search])});
|
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.
|
|
3
|
+
"version": "1.7.1",
|
|
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",
|
|
@@ -17,19 +17,19 @@
|
|
|
17
17
|
"react-refresh-typescript": "2.0.10",
|
|
18
18
|
"react-router": "6.27.0",
|
|
19
19
|
"react-router-dom": "6.27.0",
|
|
20
|
-
"shared-store-object": "1.1
|
|
20
|
+
"shared-store-object": "1.2.1"
|
|
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;
|