From 8af8f15ce4d967b79e80c06d6792042e1425c05e Mon Sep 17 00:00:00 2001
From: wangxinrong <18629193282@163.com>
Date: Wed, 1 Nov 2023 20:44:41 +0800
Subject: [PATCH 01/10] =?UTF-8?q?[inula-connectRouter]=20=E5=A2=9E?=
=?UTF-8?q?=E5=8A=A0=E6=94=AF=E6=8C=81inulax=E7=8A=B6=E6=80=81=E7=AE=A1?=
=?UTF-8?q?=E7=90=86=E5=99=A8=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../inula-router/src/connect-router/connectedRouter.tsx | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/packages/inula-router/src/connect-router/connectedRouter.tsx b/packages/inula-router/src/connect-router/connectedRouter.tsx
index a526663a..4845dca2 100644
--- a/packages/inula-router/src/connect-router/connectedRouter.tsx
+++ b/packages/inula-router/src/connect-router/connectedRouter.tsx
@@ -130,9 +130,14 @@ function getConnectedRouter(type: StoreType) {
);
};
+ const ConnectHRouterWithContext = (props: any) => {
+ const { store, ...rest } = props;
+ return ;
+ };
+
// 针对不同的Store类型,使用对应的connect函数
if (type === 'InulaXCompat') {
- return hConnect(null as any, mapDispatchToProps)(ConnectedRouterWithContext as any);
+ return hConnect(null as any, mapDispatchToProps)(ConnectHRouterWithContext as any);
}
if (type === 'Redux') {
return connect(null, mapDispatchToProps)(ConnectedRouterWithContext);
From 2d5de65ac000e37627bbe14c3f972f0e0f28d4f3 Mon Sep 17 00:00:00 2001
From: wangxinrong <18629193282@163.com>
Date: Wed, 1 Nov 2023 21:02:10 +0800
Subject: [PATCH 02/10] =?UTF-8?q?[inula-package.json]=20exports=E6=9B=B4?=
=?UTF-8?q?=E6=96=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
packages/inula/package.json | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/packages/inula/package.json b/packages/inula/package.json
index 3ec98d8b..38de80bf 100644
--- a/packages/inula/package.json
+++ b/packages/inula/package.json
@@ -24,5 +24,13 @@
"watch-test": "yarn test --watch --dev"
},
"files": ["build/@types", "build/cjs", "build/umd", "build/index.js", "build/jsx-dev-runtime.js", "build/jsx-runtime.js", "README.md"],
- "types": "./build/@types/index.d.ts"
+ "types": "./build/@types/index.d.ts",
+ "exports": {
+ ".": {
+ "default": "./index.js"
+ },
+ "./package.json": "./package.json",
+ "./jsx-runtime": "./jsx-runtime.js",
+ "./jsx-dev-runtime": "./jsx-dev-runtime.js"
+ }
}
From 79d40a9b9d9858620b5d1f26ddc2731bc2d34177 Mon Sep 17 00:00:00 2001
From: wangxinrong <18629193282@163.com>
Date: Wed, 1 Nov 2023 21:19:41 +0800
Subject: [PATCH 03/10] =?UTF-8?q?[inula-package.json]=20exports=E6=9B=B4?=
=?UTF-8?q?=E6=96=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
packages/inula/package.json | 10 +---------
1 file changed, 1 insertion(+), 9 deletions(-)
diff --git a/packages/inula/package.json b/packages/inula/package.json
index 38de80bf..3ec98d8b 100644
--- a/packages/inula/package.json
+++ b/packages/inula/package.json
@@ -24,13 +24,5 @@
"watch-test": "yarn test --watch --dev"
},
"files": ["build/@types", "build/cjs", "build/umd", "build/index.js", "build/jsx-dev-runtime.js", "build/jsx-runtime.js", "README.md"],
- "types": "./build/@types/index.d.ts",
- "exports": {
- ".": {
- "default": "./index.js"
- },
- "./package.json": "./package.json",
- "./jsx-runtime": "./jsx-runtime.js",
- "./jsx-dev-runtime": "./jsx-dev-runtime.js"
- }
+ "types": "./build/@types/index.d.ts"
}
From 08077af64f2e42a9aafa41f7b7030f251453419b Mon Sep 17 00:00:00 2001
From: wangxinrong <18629193282@163.com>
Date: Wed, 1 Nov 2023 21:28:59 +0800
Subject: [PATCH 04/10] =?UTF-8?q?[inula-package.json]=20exports=E6=9B=B4?=
=?UTF-8?q?=E6=96=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
packages/inula/package.json | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/packages/inula/package.json b/packages/inula/package.json
index 3ec98d8b..38de80bf 100644
--- a/packages/inula/package.json
+++ b/packages/inula/package.json
@@ -24,5 +24,13 @@
"watch-test": "yarn test --watch --dev"
},
"files": ["build/@types", "build/cjs", "build/umd", "build/index.js", "build/jsx-dev-runtime.js", "build/jsx-runtime.js", "README.md"],
- "types": "./build/@types/index.d.ts"
+ "types": "./build/@types/index.d.ts",
+ "exports": {
+ ".": {
+ "default": "./index.js"
+ },
+ "./package.json": "./package.json",
+ "./jsx-runtime": "./jsx-runtime.js",
+ "./jsx-dev-runtime": "./jsx-dev-runtime.js"
+ }
}
From cc49467c2ff38db684435d830cd280577b74db70 Mon Sep 17 00:00:00 2001
From: wangxinrong <18629193282@163.com>
Date: Wed, 1 Nov 2023 21:36:57 +0800
Subject: [PATCH 05/10] =?UTF-8?q?[inula-package.json]=20exports=E6=9B=B4?=
=?UTF-8?q?=E6=96=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../inula-router/src/connect-router/connectedRouter.tsx | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/packages/inula-router/src/connect-router/connectedRouter.tsx b/packages/inula-router/src/connect-router/connectedRouter.tsx
index 4845dca2..a526663a 100644
--- a/packages/inula-router/src/connect-router/connectedRouter.tsx
+++ b/packages/inula-router/src/connect-router/connectedRouter.tsx
@@ -130,14 +130,9 @@ function getConnectedRouter(type: StoreType) {
);
};
- const ConnectHRouterWithContext = (props: any) => {
- const { store, ...rest } = props;
- return ;
- };
-
// 针对不同的Store类型,使用对应的connect函数
if (type === 'InulaXCompat') {
- return hConnect(null as any, mapDispatchToProps)(ConnectHRouterWithContext as any);
+ return hConnect(null as any, mapDispatchToProps)(ConnectedRouterWithContext as any);
}
if (type === 'Redux') {
return connect(null, mapDispatchToProps)(ConnectedRouterWithContext);
From 0636d8dab05abd839e4bbbaae6ee45729531deed Mon Sep 17 00:00:00 2001
From: wangxinrong <18629193282@163.com>
Date: Wed, 1 Nov 2023 21:44:43 +0800
Subject: [PATCH 06/10] =?UTF-8?q?[inulax]=20connect=20API=20=E6=94=AF?=
=?UTF-8?q?=E6=8C=81forwardRef=E5=8F=82=E6=95=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../inula-router/src/router/withRouter.tsx | 5 +++--
packages/inula/package.json | 10 +--------
.../inula/src/inulax/adapters/reduxReact.ts | 21 ++++++++++++++-----
3 files changed, 20 insertions(+), 16 deletions(-)
diff --git a/packages/inula-router/src/router/withRouter.tsx b/packages/inula-router/src/router/withRouter.tsx
index 3d7f58bd..43f7dc01 100644
--- a/packages/inula-router/src/router/withRouter.tsx
+++ b/packages/inula-router/src/router/withRouter.tsx
@@ -20,13 +20,14 @@ import RouterContext from './context';
function withRouter(Component: C) {
function ComponentWithRouterProp(props: any) {
+ const { wrappedComponentRef, ...rest } = props;
const { history, location, match } = useContext(RouterContext);
const routeProps = { history: history, location: location, match: match };
- return ;
+ return ;
}
return ComponentWithRouterProp;
}
-export default withRouter;
\ No newline at end of file
+export default withRouter;
diff --git a/packages/inula/package.json b/packages/inula/package.json
index 38de80bf..3ec98d8b 100644
--- a/packages/inula/package.json
+++ b/packages/inula/package.json
@@ -24,13 +24,5 @@
"watch-test": "yarn test --watch --dev"
},
"files": ["build/@types", "build/cjs", "build/umd", "build/index.js", "build/jsx-dev-runtime.js", "build/jsx-runtime.js", "README.md"],
- "types": "./build/@types/index.d.ts",
- "exports": {
- ".": {
- "default": "./index.js"
- },
- "./package.json": "./package.json",
- "./jsx-runtime": "./jsx-runtime.js",
- "./jsx-dev-runtime": "./jsx-dev-runtime.js"
- }
+ "types": "./build/@types/index.d.ts"
}
diff --git a/packages/inula/src/inulax/adapters/reduxReact.ts b/packages/inula/src/inulax/adapters/reduxReact.ts
index 51650f98..203622f3 100644
--- a/packages/inula/src/inulax/adapters/reduxReact.ts
+++ b/packages/inula/src/inulax/adapters/reduxReact.ts
@@ -17,6 +17,7 @@ import { useState, useContext, useEffect, useRef } from '../../renderer/hooks/Ho
import { createContext } from '../../renderer/components/context/CreateContext';
import { createElement } from '../../external/JSXElement';
import type { ReduxStoreHandler, ReduxAction, BoundActionCreator } from './redux';
+import { forwardRef } from '../../renderer/components/ForwardRef';
const DefaultContext = createContext(null);
type Context = typeof DefaultContext;
@@ -90,6 +91,11 @@ type MergePropsP = (
type WrappedComponent = (props: OwnProps) => ReturnType;
type OriginalComponent = (props: MergedProps) => ReturnType;
type Connector = (Component: OriginalComponent) => WrappedComponent;
+type ConnectOption = {
+ areStatesEqual?: (oldState: State, newState: State) => boolean;
+ context?: Context;
+ forwardRef?: boolean
+}
export function connect(
mapStateToProps: MapStateToPropsP = () => ({} as StateProps),
@@ -97,12 +103,9 @@ export function connect(
mergeProps: MergePropsP = (
stateProps,
dispatchProps,
- ownProps
+ ownProps,
): MergedProps => ({ ...stateProps, ...dispatchProps, ...ownProps } as unknown as MergedProps),
- options?: {
- areStatesEqual?: (oldState: any, newState: any) => boolean;
- context?: Context;
- }
+ options: ConnectOption,
): Connector {
if (!options) {
options = {};
@@ -159,6 +162,7 @@ export function connect(
mappedDispatch = mapDispatchToProps(store.dispatch, props);
}
}
+ mappedDispatch = Object.assign({}, mappedDispatch, { dispatch: store.dispatch });
const mergedProps = (
mergeProps ||
((state, dispatch, originalProps) => {
@@ -172,6 +176,13 @@ export function connect(
return node;
};
+ if (options.forwardRef) {
+ const forwarded = forwardRef(function (props, ref) {
+ return Wrapper({ ...props, ref: ref });
+ });
+ return forwarded as WrappedComponent;
+ }
+
return Wrapper;
};
}
From 628e09fe20d0d3ce601f78b8d297ea974c75baec Mon Sep 17 00:00:00 2001
From: wangxinrong <18629193282@163.com>
Date: Wed, 1 Nov 2023 21:51:14 +0800
Subject: [PATCH 07/10] =?UTF-8?q?[inulax]=20history=E5=8F=82=E6=95=B0?=
=?UTF-8?q?=E5=BC=82=E5=B8=B8=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
packages/inula-router/src/history/hashHistory.ts | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/packages/inula-router/src/history/hashHistory.ts b/packages/inula-router/src/history/hashHistory.ts
index c44a85bb..f1cf421d 100644
--- a/packages/inula-router/src/history/hashHistory.ts
+++ b/packages/inula-router/src/history/hashHistory.ts
@@ -107,7 +107,7 @@ export function createHashHistory(option: HashHistoryOptio
warning(state !== undefined, 'Hash history does not support state, it will be ignored');
const action = Action.push;
- const location = createLocation(history.location, to, undefined, '');
+ const location = createLocation(history.location, to, state, '');
transitionManager.confirmJumpTo(location, action, getUserConfirmation, isJump => {
if (!isJump) {
@@ -132,7 +132,7 @@ export function createHashHistory(option: HashHistoryOptio
function replace(to: To, state?: S) {
warning(state !== undefined, 'Hash history does not support state, it will be ignored');
const action = Action.replace;
- const location = createLocation(history.location, to, undefined, '');
+ const location = createLocation(history.location, to, state, '');
transitionManager.confirmJumpTo(location, action, getUserConfirmation, isJump => {
if (!isJump) {
From 8c0372803c2229b5f88b8924c07fbb03c262da51 Mon Sep 17 00:00:00 2001
From: wangxinrong <18629193282@163.com>
Date: Wed, 1 Nov 2023 21:56:49 +0800
Subject: [PATCH 08/10] =?UTF-8?q?[inulax]=20history=E5=8F=82=E6=95=B0?=
=?UTF-8?q?=E5=BC=82=E5=B8=B8=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../inula-router/src/router/withRouter.tsx | 5 ++---
.../inula/src/inulax/adapters/reduxReact.ts | 21 +++++--------------
2 files changed, 7 insertions(+), 19 deletions(-)
diff --git a/packages/inula-router/src/router/withRouter.tsx b/packages/inula-router/src/router/withRouter.tsx
index 43f7dc01..3d7f58bd 100644
--- a/packages/inula-router/src/router/withRouter.tsx
+++ b/packages/inula-router/src/router/withRouter.tsx
@@ -20,14 +20,13 @@ import RouterContext from './context';
function withRouter(Component: C) {
function ComponentWithRouterProp(props: any) {
- const { wrappedComponentRef, ...rest } = props;
const { history, location, match } = useContext(RouterContext);
const routeProps = { history: history, location: location, match: match };
- return ;
+ return ;
}
return ComponentWithRouterProp;
}
-export default withRouter;
+export default withRouter;
\ No newline at end of file
diff --git a/packages/inula/src/inulax/adapters/reduxReact.ts b/packages/inula/src/inulax/adapters/reduxReact.ts
index 203622f3..51650f98 100644
--- a/packages/inula/src/inulax/adapters/reduxReact.ts
+++ b/packages/inula/src/inulax/adapters/reduxReact.ts
@@ -17,7 +17,6 @@ import { useState, useContext, useEffect, useRef } from '../../renderer/hooks/Ho
import { createContext } from '../../renderer/components/context/CreateContext';
import { createElement } from '../../external/JSXElement';
import type { ReduxStoreHandler, ReduxAction, BoundActionCreator } from './redux';
-import { forwardRef } from '../../renderer/components/ForwardRef';
const DefaultContext = createContext(null);
type Context = typeof DefaultContext;
@@ -91,11 +90,6 @@ type MergePropsP = (
type WrappedComponent = (props: OwnProps) => ReturnType;
type OriginalComponent = (props: MergedProps) => ReturnType;
type Connector = (Component: OriginalComponent) => WrappedComponent;
-type ConnectOption = {
- areStatesEqual?: (oldState: State, newState: State) => boolean;
- context?: Context;
- forwardRef?: boolean
-}
export function connect(
mapStateToProps: MapStateToPropsP = () => ({} as StateProps),
@@ -103,9 +97,12 @@ export function connect(
mergeProps: MergePropsP = (
stateProps,
dispatchProps,
- ownProps,
+ ownProps
): MergedProps => ({ ...stateProps, ...dispatchProps, ...ownProps } as unknown as MergedProps),
- options: ConnectOption,
+ options?: {
+ areStatesEqual?: (oldState: any, newState: any) => boolean;
+ context?: Context;
+ }
): Connector {
if (!options) {
options = {};
@@ -162,7 +159,6 @@ export function connect(
mappedDispatch = mapDispatchToProps(store.dispatch, props);
}
}
- mappedDispatch = Object.assign({}, mappedDispatch, { dispatch: store.dispatch });
const mergedProps = (
mergeProps ||
((state, dispatch, originalProps) => {
@@ -176,13 +172,6 @@ export function connect(
return node;
};
- if (options.forwardRef) {
- const forwarded = forwardRef(function (props, ref) {
- return Wrapper({ ...props, ref: ref });
- });
- return forwarded as WrappedComponent;
- }
-
return Wrapper;
};
}
From a907240e58963654998a77aa265b77e4b07ccc63 Mon Sep 17 00:00:00 2001
From: wangxinrong <18629193282@163.com>
Date: Wed, 1 Nov 2023 22:00:57 +0800
Subject: [PATCH 09/10] =?UTF-8?q?[inulax]=20history=E5=93=88=E5=B8=8C?=
=?UTF-8?q?=E5=80=BC=E5=92=8Csearch=E8=AE=A1=E7=AE=97?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
packages/inula-router/src/history/utils.ts | 43 +++++++++++++---------
1 file changed, 25 insertions(+), 18 deletions(-)
diff --git a/packages/inula-router/src/history/utils.ts b/packages/inula-router/src/history/utils.ts
index cfa49b7a..27447967 100644
--- a/packages/inula-router/src/history/utils.ts
+++ b/packages/inula-router/src/history/utils.ts
@@ -28,31 +28,32 @@ export function createPath(path: Partial): string {
}
export function parsePath(url: string): Partial {
- if (!url) {
- return {};
- }
- let parsedPath: Partial = {};
+ const parsedPath: Partial = {
+ pathname: url || '/',
+ search: '',
+ hash: '',
+ };
- let hashIdx = url.indexOf('#');
+ const hashIdx = url.indexOf('#');
if (hashIdx > -1) {
- parsedPath.hash = url.substring(hashIdx);
+ const hash = url.substring(hashIdx);
+ parsedPath.hash = hash === '#' ? '' : hash;
url = url.substring(0, hashIdx);
}
- let searchIdx = url.indexOf('?');
+ const searchIdx = url.indexOf('?');
if (searchIdx > -1) {
- parsedPath.search = url.substring(searchIdx);
+ const search = url.substring(searchIdx);
+ parsedPath.search = search === '?' ? '' : search;
url = url.substring(0, searchIdx);
}
- if (url) {
- parsedPath.pathname = url;
- }
+ parsedPath.pathname = url;
return parsedPath;
}
export function createLocation(current: string | Location, to: To, state?: S, key?: string): Readonly> {
- let pathname = typeof current === 'string' ? current : current.pathname;
- let urlObj = typeof to === 'string' ? parsePath(to) : to;
+ const pathname = typeof current === 'string' ? current : current.pathname;
+ const urlObj = typeof to === 'string' ? parsePath(to) : to;
// 随机key长度取6
const getRandKey = genRandomKey(6);
const location = {
@@ -64,7 +65,13 @@ export function createLocation(current: string | Location, to: To, state?: S,
...urlObj,
};
if (!location.pathname) {
- location.pathname = '/';
+ location.pathname = pathname ? pathname : '/';
+ }
+ if (location.search && location.search[0] !== '?') {
+ location.search = '?' + location.search;
+ }
+ if (location.hash && location.hash[0] !== '#') {
+ location.hash = '#' + location.hash;
}
return location;
}
@@ -95,7 +102,7 @@ export function normalizeSlash(path: string): string {
return tempPath;
}
-export function hasBasename(path: string, prefix: string): Boolean {
+export function hasBasename(path: string, prefix: string): boolean {
return (
path.toLowerCase().indexOf(prefix.toLowerCase()) === 0 && ['/', '?', '#', ''].includes(path.charAt(prefix.length))
);
@@ -109,12 +116,12 @@ export function stripBasename(path: string, prefix: string): string {
export function createMemoryRecord(initVal: S, fn: (arg: S) => T) {
let visitedRecord: T[] = [fn(initVal)];
- function getDelta(toKey: S, fromKey: S): number {
- let toIdx = visitedRecord.lastIndexOf(fn(toKey));
+ function getDelta(to: S, form: S): number {
+ let toIdx = visitedRecord.lastIndexOf(fn(to));
if (toIdx === -1) {
toIdx = 0;
}
- let fromIdx = visitedRecord.lastIndexOf(fn(fromKey));
+ let fromIdx = visitedRecord.lastIndexOf(fn(form));
if (fromIdx === -1) {
fromIdx = 0;
}
From d6e105e9c4d7526d47e157902946d6b40a912443 Mon Sep 17 00:00:00 2001
From: wangxinrong <18629193282@163.com>
Date: Wed, 1 Nov 2023 22:04:46 +0800
Subject: [PATCH 10/10] =?UTF-8?q?[inulax]=20history=E5=93=88=E5=B8=8C?=
=?UTF-8?q?=E5=80=BC=E5=92=8Csearch=E8=AE=A1=E7=AE=97?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
packages/inula-router/src/history/hashHistory.ts | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/packages/inula-router/src/history/hashHistory.ts b/packages/inula-router/src/history/hashHistory.ts
index f1cf421d..c44a85bb 100644
--- a/packages/inula-router/src/history/hashHistory.ts
+++ b/packages/inula-router/src/history/hashHistory.ts
@@ -107,7 +107,7 @@ export function createHashHistory(option: HashHistoryOptio
warning(state !== undefined, 'Hash history does not support state, it will be ignored');
const action = Action.push;
- const location = createLocation(history.location, to, state, '');
+ const location = createLocation(history.location, to, undefined, '');
transitionManager.confirmJumpTo(location, action, getUserConfirmation, isJump => {
if (!isJump) {
@@ -132,7 +132,7 @@ export function createHashHistory(option: HashHistoryOptio
function replace(to: To, state?: S) {
warning(state !== undefined, 'Hash history does not support state, it will be ignored');
const action = Action.replace;
- const location = createLocation(history.location, to, state, '');
+ const location = createLocation(history.location, to, undefined, '');
transitionManager.confirmJumpTo(location, action, getUserConfirmation, isJump => {
if (!isJump) {