Match-id-b9300c6aa54f0948789213f9ff4cb3e786935f85
This commit is contained in:
parent
dc35633382
commit
8e2abff929
|
@ -21,7 +21,7 @@ export default {
|
||||||
'@babel/plugin-transform-react-jsx',
|
'@babel/plugin-transform-react-jsx',
|
||||||
{
|
{
|
||||||
runtime: 'automatic',
|
runtime: 'automatic',
|
||||||
importSource: '@cloudsop/horizon',
|
importSource: 'inulajs',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
['@babel/plugin-proposal-class-properties', { loose: true }],
|
['@babel/plugin-proposal-class-properties', { loose: true }],
|
||||||
|
|
|
@ -29,7 +29,7 @@ const routerBuildConfig = mode => {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
file: path.join(output, `router/umd/router.${prod ? 'min.' : ''}js`),
|
file: path.join(output, `router/umd/router.${prod ? 'min.' : ''}js`),
|
||||||
name: 'HorizonRouter',
|
name: 'InulaRouter',
|
||||||
sourcemap: 'true',
|
sourcemap: 'true',
|
||||||
format: 'umd',
|
format: 'umd',
|
||||||
},
|
},
|
||||||
|
@ -70,7 +70,7 @@ const connectRouterConfig = mode => {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
file: path.join(output, `connectRouter/umd/connectRouter.${prod ? 'min.' : ''}js`),
|
file: path.join(output, `connectRouter/umd/connectRouter.${prod ? 'min.' : ''}js`),
|
||||||
name: 'HorizonRouter',
|
name: 'InulaRouter',
|
||||||
sourcemap: 'true',
|
sourcemap: 'true',
|
||||||
format: 'umd',
|
format: 'umd',
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
export default {
|
export default {
|
||||||
preset: "ts-jest",
|
preset: 'ts-jest',
|
||||||
testMatch: ["**/__tests__/*.test.[jt]s?(x)"],
|
testMatch: ['**/__tests__/*.test.[jt]s?(x)'],
|
||||||
globals: {
|
globals: {
|
||||||
__DEV__: true,
|
__DEV__: true,
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "@cloudsop/horizon-router",
|
"name": "inula-router",
|
||||||
"version": "1.0.5-rc2",
|
"version": "1.0.5-rc2",
|
||||||
"description": "router for horizon framework, a part of horizon-ecosystem",
|
"description": "router for inula framework, a part of inula-ecosystem",
|
||||||
"main": "./router/cjs/router.js",
|
"main": "./router/cjs/router.js",
|
||||||
"module": "./router/esm/router.js",
|
"module": "./router/esm/router.js",
|
||||||
"types": "./router/@types/index.d.ts",
|
"types": "./router/@types/index.d.ts",
|
||||||
|
@ -11,18 +11,11 @@
|
||||||
"/router",
|
"/router",
|
||||||
"README.md"
|
"README.md"
|
||||||
],
|
],
|
||||||
"bugs": {
|
|
||||||
"url": "https://open.codehub.huawei.com/innersource/fenghuang/horizon/horizon-ecosystem/issues"
|
|
||||||
},
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "jest",
|
"test": "jest",
|
||||||
"build": "rollup -c build.js && npm run build-types",
|
"build": "rollup -c build.js && npm run build-types",
|
||||||
"build-types": "tsc -p tsconfig.build.json && tsc -p tsconfig.cbuild.json && rollup -c build-types.js"
|
"build-types": "tsc -p tsconfig.build.json && tsc -p tsconfig.cbuild.json && rollup -c build-types.js"
|
||||||
},
|
},
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://szv-open.codehub.huawei.com/innersource/fenghuang/horizon/horizon-ecosystem.git"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "7.21.3",
|
"@babel/core": "7.21.3",
|
||||||
"@babel/plugin-proposal-class-properties": "7.16.7",
|
"@babel/plugin-proposal-class-properties": "7.16.7",
|
||||||
|
@ -49,14 +42,13 @@
|
||||||
"@babel/plugin-transform-template-literals": "7.16.7",
|
"@babel/plugin-transform-template-literals": "7.16.7",
|
||||||
"@babel/preset-env": "7.16.7",
|
"@babel/preset-env": "7.16.7",
|
||||||
"@babel/preset-typescript": "^7.16.7",
|
"@babel/preset-typescript": "^7.16.7",
|
||||||
"@cloudsop/horizon": "^0.0.58",
|
"inulajs": "^0.0.11",
|
||||||
"@rollup/plugin-babel": "^6.0.3",
|
"@rollup/plugin-babel": "^6.0.3",
|
||||||
"@rollup/plugin-node-resolve": "^15.1.0",
|
"@rollup/plugin-node-resolve": "^15.1.0",
|
||||||
"@testing-library/jest-dom": "^5.16.5",
|
"@testing-library/jest-dom": "^5.16.5",
|
||||||
"@testing-library/react": "^14.0.0",
|
"@testing-library/react": "^14.0.0",
|
||||||
"@testing-library/user-event": "^14.4.3",
|
"@testing-library/user-event": "^14.4.3",
|
||||||
"@types/jest": "^29.2.3",
|
"@types/jest": "^29.2.3",
|
||||||
"@types/react": "18.0.25",
|
|
||||||
"@types/react-redux": "7.0.0",
|
"@types/react-redux": "7.0.0",
|
||||||
"jest": "29.3.1",
|
"jest": "29.3.1",
|
||||||
"jest-environment-jsdom": "^29.5.0",
|
"jest-environment-jsdom": "^29.5.0",
|
||||||
|
@ -70,7 +62,7 @@
|
||||||
"typescript": "4.9.3"
|
"typescript": "4.9.3"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@cloudsop/horizon": ">=0.0.10"
|
"inulajs": ">=0.0.10"
|
||||||
},
|
},
|
||||||
"browserslist": {
|
"browserslist": {
|
||||||
"production": [
|
"production": [
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import Inula from '@cloudsop/horizon';
|
import Inula from 'inulajs';
|
||||||
import { useLayoutEffect, useRef, reduxAdapter, InulaNode } from '@cloudsop/horizon';
|
import { useLayoutEffect, useRef, reduxAdapter, InulaNode } from 'inulajs';
|
||||||
import { connect, ReactReduxContext } from 'react-redux';
|
import { connect, ReactReduxContext } from 'react-redux';
|
||||||
import { Store } from 'redux';
|
import { Store } from 'redux';
|
||||||
import { History, Location, Router } from '../router';
|
import { History, Location, Router } from '../router';
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import Inula from '@cloudsop/horizon';
|
import Inula from 'inulajs';
|
||||||
import { useRef, InulaNode } from '@cloudsop/horizon';
|
import { useRef, InulaNode } from 'inulajs';
|
||||||
import Router from './Router';
|
import Router from './Router';
|
||||||
import { createBrowserHistory } from '../history/browerHistory';
|
import { createBrowserHistory } from '../history/browerHistory';
|
||||||
import { ConfirmationFunc, History } from '../history/types';
|
import { ConfirmationFunc, History } from '../history/types';
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import Inula from '@cloudsop/horizon';
|
import Inula from 'inulajs';
|
||||||
import { useRef } from '@cloudsop/horizon';
|
import { useRef } from 'inulajs';
|
||||||
import { History } from '../history/types';
|
import { History } from '../history/types';
|
||||||
import { BaseRouterProps } from './BrowserRouter';
|
import { BaseRouterProps } from './BrowserRouter';
|
||||||
import { createHashHistory, urlHashType } from '../history/hashHistory';
|
import { createHashHistory, urlHashType } from '../history/hashHistory';
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import Inula from '@cloudsop/horizon';
|
import Inula from 'inulajs';
|
||||||
import { useContext, MouseEvent, ComponentType, Ref } from '@cloudsop/horizon';
|
import { useContext, MouseEvent, ComponentType, Ref } from 'inulajs';
|
||||||
import RouterContext from './context';
|
import RouterContext from './context';
|
||||||
import { Location } from './index';
|
import { Location } from './index';
|
||||||
import { createPath, parsePath } from '../history/utils';
|
import { createPath, parsePath } from '../history/utils';
|
||||||
|
@ -10,10 +10,6 @@ export type LinkProps = {
|
||||||
to: Partial<Location> | string | ((location: Location) => string | Partial<Location>);
|
to: Partial<Location> | string | ((location: Location) => string | Partial<Location>);
|
||||||
replace?: boolean;
|
replace?: boolean;
|
||||||
tag?: string;
|
tag?: string;
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
* React16以后不再需要该属性
|
|
||||||
**/
|
|
||||||
innerRef?: Ref<HTMLAnchorElement>;
|
innerRef?: Ref<HTMLAnchorElement>;
|
||||||
} & { [key: string]: any };
|
} & { [key: string]: any };
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import Inula from '@cloudsop/horizon';
|
import Inula from 'inulajs';
|
||||||
import { useContext } from '@cloudsop/horizon';
|
import { useContext } from 'inulajs';
|
||||||
import type { LinkProps } from './Link';
|
import type { LinkProps } from './Link';
|
||||||
import Link from './Link';
|
import Link from './Link';
|
||||||
import { Location, matchPath } from './index';
|
import { Location, matchPath } from './index';
|
||||||
|
@ -10,7 +10,6 @@ import { parsePath } from '../history/utils';
|
||||||
type NavLinkProps = {
|
type NavLinkProps = {
|
||||||
to: Partial<Location> | string | ((location: Location) => string | Partial<Location>);
|
to: Partial<Location> | string | ((location: Location) => string | Partial<Location>);
|
||||||
isActive?: (match: Matched | null, location: Location) => boolean;
|
isActive?: (match: Matched | null, location: Location) => boolean;
|
||||||
// compat react-router NavLink props type
|
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
} & LinkProps;
|
} & LinkProps;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import Inula from '@cloudsop/horizon';
|
import Inula from 'inulajs';
|
||||||
import { useContext } from '@cloudsop/horizon';
|
import { useContext } from 'inulajs';
|
||||||
import { LifeCycle, LifeCycleProps } from './lifeCycleHook';
|
import { LifeCycle, LifeCycleProps } from './lifeCycleHook';
|
||||||
import { Location } from './index';
|
import { Location } from './index';
|
||||||
import { Action } from '../history/types';
|
import { Action } from '../history/types';
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import Inula from '@cloudsop/horizon';
|
import Inula from 'inulajs';
|
||||||
import { useContext } from '@cloudsop/horizon';
|
import { useContext } from 'inulajs';
|
||||||
import RouterContext from './context';
|
import RouterContext from './context';
|
||||||
import { LifeCycle, LifeCycleProps } from './lifeCycleHook';
|
import { LifeCycle, LifeCycleProps } from './lifeCycleHook';
|
||||||
import { Matched, createPathParser } from './matcher/parser';
|
import { Matched, createPathParser } from './matcher/parser';
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import Inula from '@cloudsop/horizon';
|
import Inula from 'inulajs';
|
||||||
import { History, Location } from './index';
|
import { History, Location } from './index';
|
||||||
import { Matched, matchPath } from './matcher/parser';
|
import { Matched, matchPath } from './matcher/parser';
|
||||||
import { useContext, Children, createElement, InulaNode, ComponentType } from '@cloudsop/horizon';
|
import { useContext, Children, createElement, InulaNode, ComponentType } from 'inulajs';
|
||||||
import RouterContext from './context';
|
import RouterContext from './context';
|
||||||
import { GetURLParams } from './matcher/types';
|
import { GetURLParams } from './matcher/types';
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import Inula from '@cloudsop/horizon';
|
import Inula from 'inulajs';
|
||||||
import { useLayoutEffect, useMemo, useRef, useState, InulaNode } from '@cloudsop/horizon';
|
import { useLayoutEffect, useMemo, useRef, useState, InulaNode } from 'inulajs';
|
||||||
|
|
||||||
import { History, Location } from '../history/types';
|
import { History, Location } from '../history/types';
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import Inula from '@cloudsop/horizon';
|
import Inula from 'inulajs';
|
||||||
import { useContext, Children, isValidElement, cloneElement, InulaNode, InulaElement } from '@cloudsop/horizon';
|
import { useContext, Children, isValidElement, cloneElement, InulaNode, InulaElement } from 'inulajs';
|
||||||
|
|
||||||
import { Location } from './index';
|
import { Location } from './index';
|
||||||
import RouterContext from './context';
|
import RouterContext from './context';
|
||||||
|
@ -19,7 +19,7 @@ function Switch<P extends SwitchProps>(props: P): InulaElement | null {
|
||||||
let element: InulaElement | null = null;
|
let element: InulaElement | null = null;
|
||||||
let match: Matched | null = null;
|
let match: Matched | null = null;
|
||||||
|
|
||||||
// 使用forEach不会给React.ReactNode增加key属性,防止重新渲染
|
// 使用forEach不会给InulaNode增加key属性,防止重新渲染
|
||||||
Children.forEach(props.children, node => {
|
Children.forEach(props.children, node => {
|
||||||
if (match === null && isValidElement(node)) {
|
if (match === null && isValidElement(node)) {
|
||||||
element = node;
|
element = node;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { createContext } from '@cloudsop/horizon';
|
import { createContext } from 'inulajs';
|
||||||
import { History, Location } from './index';
|
import { History, Location } from './index';
|
||||||
import { Matched } from './matcher/parser';
|
import { Matched } from './matcher/parser';
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { useContext } from '@cloudsop/horizon';
|
import { useContext } from 'inulajs';
|
||||||
import RouterContext from './context';
|
import RouterContext from './context';
|
||||||
import { Matched, matchPath, Params } from './matcher/parser';
|
import { Matched, matchPath, Params } from './matcher/parser';
|
||||||
import { History } from '../history/types';
|
import { History } from '../history/types';
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { useLayoutEffect, useRef } from '@cloudsop/horizon';
|
import { useLayoutEffect, useRef } from 'inulajs';
|
||||||
|
|
||||||
export type LifeCycleProps = {
|
export type LifeCycleProps = {
|
||||||
onMount?: () => void;
|
onMount?: () => void;
|
||||||
|
|
|
@ -15,7 +15,6 @@ enum MatchScore {
|
||||||
|
|
||||||
export type Params<P> = { [K in keyof P]?: P[K] };
|
export type Params<P> = { [K in keyof P]?: P[K] };
|
||||||
|
|
||||||
// 兼容 react v5 matched类型
|
|
||||||
export type Matched<P = any> = {
|
export type Matched<P = any> = {
|
||||||
score: number[];
|
score: number[];
|
||||||
params: Params<P>;
|
params: Params<P>;
|
||||||
|
|
|
@ -30,7 +30,7 @@ export type ParserOption = {
|
||||||
caseSensitive?: boolean;
|
caseSensitive?: boolean;
|
||||||
// 是否启用严格模式
|
// 是否启用严格模式
|
||||||
strictMode?: boolean;
|
strictMode?: boolean;
|
||||||
// 精准匹配 兼容 React-RouterV5
|
// 精准匹配
|
||||||
exact?: boolean;
|
exact?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import Inula from '@cloudsop/horizon';
|
import Inula from 'inulajs';
|
||||||
import { useContext, ComponentType } from '@cloudsop/horizon';
|
import { useContext, ComponentType } from 'inulajs';
|
||||||
import RouterContext from './context';
|
import RouterContext from './context';
|
||||||
|
|
||||||
function withRouter<C extends ComponentType>(Component: C) {
|
function withRouter<C extends ComponentType>(Component: C) {
|
||||||
|
|
Loading…
Reference in New Issue