Commit 2770be22 by Wee

reafactor: migrate to TypeScript

parent 9e6b616f
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
......@@ -22,13 +23,14 @@ var __assign = (this && this.__assign) || function () {
};
return __assign.apply(this, arguments);
};
import warning from 'warning';
import invariant from 'invariant';
import React from 'react';
import PropTypes from 'prop-types';
import ReactDOM from 'react-dom';
import { matchPath } from 'react-router';
import { isValidElementType } from 'react-is';
Object.defineProperty(exports, "__esModule", { value: true });
var warning = require("warning");
var invariant = require("invariant");
var React = require("react");
var PropTypes = require("prop-types");
var ReactDOM = require("react-dom");
var react_router_1 = require("react-router");
var react_is_1 = require("react-is");
var isEmptyChildren = function (children) { return React.Children.count(children) === 0; };
var LiveState;
(function (LiveState) {
......@@ -37,6 +39,9 @@ var LiveState;
LiveState["NORMAL_RENDER_ON_INIT"] = "normal render (matched or unmatched)";
LiveState["HIDE_RENDER"] = "hide route when livePath matched";
})(LiveState || (LiveState = {}));
var debugLog = function (message) {
// console.log(message)
};
/**
* The public API for matching a single path and rendering.
*/
......@@ -86,13 +91,13 @@ var LiveRoute = /** @class */ (function (_super) {
match: computedMatch
});
};
// 获取 Route 对应的 DOM
// get route of DOM
LiveRoute.prototype.componentDidUpdate = function (prevProps, prevState) {
if (!this.doesRouteEnableLive()) {
return;
}
// restore display when matched normally
console.log(this.liveState);
debugLog(this.liveState);
if (this.liveState === LiveState.NORMAL_RENDER_MATCHED) {
this.showRoute();
this.restoreScrollPosition();
......@@ -124,37 +129,41 @@ var LiveRoute = /** @class */ (function (_super) {
* Back up current router every time it is rendered normally, backing up to the next livePath rendering
*/
LiveRoute.prototype.computeMatchWithLive = function (props, nextProps, nextContext, match) {
// console.log(`>>> ` + this.props.name + ` <<<`)
debugLog(">>> " + this.props.name + " <<<");
// compute if livePath match
var livePath = nextProps.livePath;
var livePath = nextProps.livePath, alwaysLive = nextProps.alwaysLive;
var nextPropsWithLivePath = __assign({}, nextProps, { paths: livePath });
var prevMatch = this.computeMatch(props, this.context.router);
var livePathMatch = this.computePathsMatch(nextPropsWithLivePath, nextContext.router);
// normal matched render
if (match) {
// normal matched render
console.log('--- NORMAL MATCH FLAG ---');
debugLog('--- NORMAL MATCH FLAG ---');
if (this.liveState === LiveState.HIDE_RENDER && typeof this.props.onReappear === 'function') {
this.props.onReappear({ location: location, livePath: livePath, alwaysLive: alwaysLive });
}
this.liveState = LiveState.NORMAL_RENDER_MATCHED;
return match;
}
else if ((livePathMatch || props.alwaysLive) && this.routeDom) {
// hide render
if ((livePathMatch || props.alwaysLive) && this.routeDom) {
// backup router when from normal match render to hide render
if (prevMatch) {
this._latestMatchedRouter = this.context.router;
}
// hide render
console.log('--- HIDE FLAG ---');
if (typeof this.props.onHide === 'function') {
this.props.onHide({ location: location, livePath: livePath, alwaysLive: alwaysLive });
}
debugLog('--- HIDE FLAG ---');
this.liveState = LiveState.HIDE_RENDER;
this.saveScrollPosition();
this.hideRoute();
return prevMatch;
}
else {
// normal unmatched unmount
console.log('--- NORMAL UNMATCH FLAG ---');
this.liveState = LiveState.NORMAL_RENDER_UNMATCHED;
this.clearScroll();
this.clearDomData();
}
// normal unmatched unmount
debugLog('--- NORMAL UNMATCH FLAG ---');
this.liveState = LiveState.NORMAL_RENDER_UNMATCHED;
this.clearScroll();
this.clearDomData();
};
LiveRoute.prototype.computePathsMatch = function (_a, router) {
var computedMatch = _a.computedMatch, location = _a.location, paths = _a.paths, strict = _a.strict, exact = _a.exact, sensitive = _a.sensitive;
......@@ -168,7 +177,7 @@ var LiveRoute = /** @class */ (function (_super) {
if (typeof path !== 'string') {
continue;
}
var currPath = matchPath(pathname, { path: path, strict: strict, exact: exact, sensitive: sensitive }, router.match);
var currPath = react_router_1.matchPath(pathname, { path: path, strict: strict, exact: exact, sensitive: sensitive }, router.match);
// return if one of the livePaths is matched
if (currPath) {
return currPath;
......@@ -177,7 +186,7 @@ var LiveRoute = /** @class */ (function (_super) {
return null;
}
else {
return matchPath(pathname, { path: paths, strict: strict, exact: exact, sensitive: sensitive }, router.match);
return react_router_1.matchPath(pathname, { path: paths, strict: strict, exact: exact, sensitive: sensitive }, router.match);
}
};
LiveRoute.prototype.computeMatch = function (_a, router) {
......@@ -188,7 +197,7 @@ var LiveRoute = /** @class */ (function (_super) {
invariant(router, 'You should not use <Route> or withRouter() outside a <Router>');
var route = router.route;
var pathname = (location || route.location).pathname;
return matchPath(pathname, { path: path, strict: strict, exact: exact, sensitive: sensitive }, route.match);
return react_router_1.matchPath(pathname, { path: path, strict: strict, exact: exact, sensitive: sensitive }, route.match);
};
// get DOM of Route
LiveRoute.prototype.getRouteDom = function () {
......@@ -198,7 +207,7 @@ var LiveRoute = /** @class */ (function (_super) {
// backup scroll and hide DOM
LiveRoute.prototype.hideRoute = function () {
if (this.routeDom && this.routeDom.style.display !== 'none') {
console.log('--- hide route ---');
debugLog('--- hide route ---');
this.previousDisplayStyle = this.routeDom.style.display;
this.routeDom.style.display = 'none';
}
......@@ -214,14 +223,14 @@ var LiveRoute = /** @class */ (function (_super) {
if (this.routeDom && this.scrollPosBackup === null) {
var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
var scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft;
console.log("saved top = " + scrollTop + ", left = " + scrollLeft);
debugLog("saved top = " + scrollTop + ", left = " + scrollLeft);
this.scrollPosBackup = { top: scrollTop, left: scrollLeft };
}
};
// restore the scroll position before hide
LiveRoute.prototype.restoreScrollPosition = function () {
var scroll = this.scrollPosBackup;
console.log(scroll);
debugLog(scroll);
if (scroll && this.routeDom) {
window.scrollTo(scroll.left, scroll.top);
}
......@@ -241,7 +250,7 @@ var LiveRoute = /** @class */ (function (_super) {
};
// normally render or unmount Route
LiveRoute.prototype.renderRoute = function (component, render, props, match) {
console.log(match);
debugLog(match);
if (component)
return match ? React.createElement(component, props) : null;
if (render)
......@@ -249,12 +258,13 @@ var LiveRoute = /** @class */ (function (_super) {
};
LiveRoute.prototype.render = function () {
var match = this.state.match;
var _a = this.props, children = _a.children, component = _a.component, render = _a.render, livePath = _a.livePath, alwaysLive = _a.alwaysLive;
var _a = this.props, children = _a.children, component = _a.component, render = _a.render, livePath = _a.livePath, alwaysLive = _a.alwaysLive, onHide = _a.onHide;
var _b = this.context.router, history = _b.history, route = _b.route, staticContext = _b.staticContext;
var location = this.props.location || route.location;
var props = { match: match, location: location, history: history, staticContext: staticContext };
// only affect LiveRoute
if ((livePath || alwaysLive) && (component || render)) {
console.log('=== RENDER FLAG: ' + this.liveState + ' ===');
debugLog('=== RENDER FLAG: ' + this.liveState + ' ===');
if (this.liveState === LiveState.NORMAL_RENDER_MATCHED ||
this.liveState === LiveState.NORMAL_RENDER_UNMATCHED ||
this.liveState === LiveState.NORMAL_RENDER_ON_INIT) {
......@@ -264,10 +274,8 @@ var LiveRoute = /** @class */ (function (_super) {
else if (this.liveState === LiveState.HIDE_RENDER) {
// hide render
var prevRouter = this._latestMatchedRouter;
// load properties from prevRouter and fake props of latest normal render
var history_1 = prevRouter.history, route_1 = prevRouter.route, staticContext_1 = prevRouter.staticContext;
var location_1 = this.props.location || route_1.location;
var liveProps = { match: match, location: location_1, history: history_1, staticContext: staticContext_1 };
var history_1 = prevRouter.history, route_1 = prevRouter.route, staticContext_1 = prevRouter.staticContext; // load properties from prevRouter and fake props of latest normal render
var liveProps = { match: match, location: location, history: history_1, staticContext: staticContext_1 };
return this.renderRoute(component, render, liveProps, true);
}
}
......@@ -289,13 +297,14 @@ var LiveRoute = /** @class */ (function (_super) {
strict: PropTypes.bool,
sensitive: PropTypes.bool,
component: function (props, propName) {
if (props[propName] && !isValidElementType(props[propName])) {
if (props[propName] && !react_is_1.isValidElementType(props[propName])) {
return new Error("Invalid prop 'component' supplied to 'Route': the prop is not a valid React component");
}
},
render: PropTypes.func,
children: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
location: PropTypes.object,
onHide: PropTypes.func,
livePath: PropTypes.oneOfType([PropTypes.string, PropTypes.array]),
alwaysLive: PropTypes.bool,
name: PropTypes.string // for LiveRoute debug
......@@ -315,5 +324,5 @@ var LiveRoute = /** @class */ (function (_super) {
};
return LiveRoute;
}(React.Component));
export { LiveRoute };
exports.LiveRoute = LiveRoute;
//# sourceMappingURL=LiveRoute.js.map
\ No newline at end of file
{"version":3,"file":"LiveRoute.js","sourceRoot":"","sources":["../src/LiveRoute.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,OAAO,MAAM,SAAS,CAAA;AAC7B,OAAO,SAAS,MAAM,WAAW,CAAA;AACjC,OAAO,KAAoB,MAAM,OAAO,CAAA;AACxC,OAAO,SAAiC,MAAM,YAAY,CAAA;AAC1D,OAAO,QAAQ,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAE7C,IAAM,eAAe,GAAG,UAAA,QAAQ,IAAI,OAAA,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,EAApC,CAAoC,CAAA;AAExE,IAAK,SAKJ;AALD,WAAK,SAAS;IACZ,4DAA+C,CAAA;IAC/C,0EAA6D,CAAA;IAC7D,2EAA8D,CAAA;IAC9D,6DAAgD,CAAA;AAClD,CAAC,EALI,SAAS,KAAT,SAAS,QAKb;AAkBD;;GAEG;AACH;IAAwB,6BAA4B;IAApD;QAAA,qEA6TC;QAxRC,cAAQ,GAAa,IAAI,CAAA;QAczB,WAAK,GAAG;YACN,KAAK,EAAE,KAAI,CAAC,YAAY,CAAC,KAAI,CAAC,KAAY,EAAE,KAAI,CAAC,OAAO,CAAC,MAAM,CAAC;SACjE,CAAA;QAED,eAAS,GAAc,SAAS,CAAC,qBAAqB,CAAA;QACtD,qBAAe,GAAyC,IAAI,CAAA;QAC5D,0BAAoB,GAAkB,IAAI,CAAA;;IAoQ5C,CAAC;IAtRC,mCAAe,GAAf;QACE,O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 No newline at end of file
export { LiveRoute } from './LiveRoute';
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var LiveRoute_1 = require("./LiveRoute");
exports.default = LiveRoute_1.LiveRoute;
//# sourceMappingURL=index.js.map
\ No newline at end of file
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA"}
\ No newline at end of file
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":";;AAAA,yCAAuC;AAEvC,kBAAe,qBAAS,CAAA"}
\ No newline at end of file
console.log(233);
var a = 3;
export default a;
//# sourceMappingURL=test.js.map
\ No newline at end of file
{"version":3,"file":"test.js","sourceRoot":"","sources":["../src/test.tsx"],"names":[],"mappings":"AAAA,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;AAEhB,IAAM,CAAC,GAAG,CAAC,CAAA;AAEX,eAAe,CAAC,CAAA"}
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -7,7 +7,7 @@
"dependencies": {
"react": "16.4.1",
"react-dom": "16.4.1",
"react-live-route": "1.2.4",
"react-live-route": "../",
"react-router-dom": "4.3.1",
"react-scripts": "1.1.4"
},
......
......@@ -8,10 +8,10 @@ const List = props => {
<div>&gt;&gt; back to List</div>
</Link>
<div className="detailContent">{`hello, I'm item - ${props.match.params.id}`}</div>
<Link className="pagination" to={`/item/${Number.parseInt(props.match.params.id) - 1}`}>
<Link className="pagination" to={`/item/${Number.parseInt(props.match.params.id, 10) - 1}`}>
Prev item
</Link>
<Link className="pagination" to={`/item/${Number.parseInt(props.match.params.id) + 1}`}>
<Link className="pagination" to={`/item/${Number.parseInt(props.match.params.id, 10) + 1}`}>
Next item
</Link>
</div>
......
import React from 'react'
import ReactDOM from 'react-dom'
import { Route, BrowserRouter } from 'react-router-dom'
import LiveRoute from '../../dist/index'
import LiveRoute from 'react-live-route'
import List from './list'
import Detail from './detail'
import Bar from './bar'
......@@ -13,7 +13,20 @@ function App() {
return (
<div className="App">
<Route exact path="/" component={Home} />
<LiveRoute path="/items" component={List} livePath="/item/:id" name="items" />
<LiveRoute
path="/items"
component={List}
livePath="/item/:id"
name="items"
onHide={routeState => {
console.log('[on hide]')
console.log(routeState)
}}
onReappear={routeState => {
console.log('[on reappear]')
console.log(routeState)
}}
/>
<Route path="/item/:id" component={Detail} />
<LiveRoute path="/about" alwaysLive={true} component={About} name="about" />
<Bar />
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -5,10 +5,6 @@
"repository": "fi3ework/react-live-route",
"license": "MIT",
"authors": "fi3ework",
"files": [
"index.js",
"LiveRoute.js"
],
"main": "dist/index.js",
"module": "es/index.js",
"sideEffects": false,
......@@ -25,9 +21,9 @@
"dependencies": {
"invariant": "^2.2.4",
"prop-types": "^15.6.1",
"react-is": "^16.7.0",
"react": "^16.3.2",
"react-dom": "^16.3.2",
"react-is": "^16.7.0",
"react-router": "^4.3.1",
"react-router-dom": "^4.3.1",
"warning": "^4.0.1"
......
import warning from 'warning'
import invariant from 'invariant'
import React, { ReactNode } from 'react'
import PropTypes, { ReactComponentLike } from 'prop-types'
import ReactDOM from 'react-dom'
import * as warning from 'warning'
import * as invariant from 'invariant'
import * as React from 'react'
import * as PropTypes from 'prop-types'
import * as ReactDOM from 'react-dom'
import { matchPath } from 'react-router'
import { isValidElementType } from 'react-is'
......@@ -23,14 +23,20 @@ interface IProps {
exact?: boolean
strict?: boolean
sensitive?: boolean
component?: ReactComponentLike
component?: PropTypes.ReactComponentLike
render?: React.StatelessComponent
location: string
livePath?: string
alwaysLive: boolean
onHide?: Function
onReappear?: Function
name?: string
}
const debugLog = (message: any) => {
// console.log(message)
}
/**
* The public API for matching a single path and rendering.
*/
......@@ -49,6 +55,7 @@ class LiveRoute extends React.Component<IProps, any> {
render: PropTypes.func,
children: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
location: PropTypes.object,
onHide: PropTypes.func,
livePath: PropTypes.oneOfType([PropTypes.string, PropTypes.array]),
alwaysLive: PropTypes.bool,
name: PropTypes.string // for LiveRoute debug
......@@ -142,14 +149,14 @@ class LiveRoute extends React.Component<IProps, any> {
})
}
// 获取 Route 对应的 DOM
// get route of DOM
componentDidUpdate(prevProps, prevState) {
if (!this.doesRouteEnableLive()) {
return
}
// restore display when matched normally
console.log(this.liveState)
debugLog(this.liveState)
if (this.liveState === LiveState.NORMAL_RENDER_MATCHED) {
this.showRoute()
this.restoreScrollPosition()
......@@ -185,35 +192,44 @@ class LiveRoute extends React.Component<IProps, any> {
* Back up current router every time it is rendered normally, backing up to the next livePath rendering
*/
computeMatchWithLive(props, nextProps, nextContext, match) {
// console.log(`>>> ` + this.props.name + ` <<<`)
debugLog(`>>> ` + this.props.name + ` <<<`)
// compute if livePath match
const livePath = nextProps.livePath
const { livePath, alwaysLive } = nextProps
const nextPropsWithLivePath = { ...nextProps, paths: livePath }
const prevMatch = this.computeMatch(props, this.context.router)
const livePathMatch = this.computePathsMatch(nextPropsWithLivePath, nextContext.router)
// normal matched render
if (match) {
// normal matched render
console.log('--- NORMAL MATCH FLAG ---')
debugLog('--- NORMAL MATCH FLAG ---')
if (this.liveState === LiveState.HIDE_RENDER && typeof this.props.onReappear === 'function') {
this.props.onReappear({ location, livePath, alwaysLive })
}
this.liveState = LiveState.NORMAL_RENDER_MATCHED
return match
} else if ((livePathMatch || props.alwaysLive) && this.routeDom) {
}
// hide render
if ((livePathMatch || props.alwaysLive) && this.routeDom) {
// backup router when from normal match render to hide render
if (prevMatch) {
this._latestMatchedRouter = this.context.router
}
// hide render
console.log('--- HIDE FLAG ---')
if (typeof this.props.onHide === 'function') {
this.props.onHide({ location, livePath, alwaysLive })
}
debugLog('--- HIDE FLAG ---')
this.liveState = LiveState.HIDE_RENDER
this.saveScrollPosition()
this.hideRoute()
return prevMatch
} else {
// normal unmatched unmount
console.log('--- NORMAL UNMATCH FLAG ---')
this.liveState = LiveState.NORMAL_RENDER_UNMATCHED
this.clearScroll()
this.clearDomData()
}
// normal unmatched unmount
debugLog('--- NORMAL UNMATCH FLAG ---')
this.liveState = LiveState.NORMAL_RENDER_UNMATCHED
this.clearScroll()
this.clearDomData()
}
computePathsMatch({ computedMatch, location, paths, strict, exact, sensitive }, router) {
......@@ -260,7 +276,7 @@ class LiveRoute extends React.Component<IProps, any> {
// backup scroll and hide DOM
hideRoute() {
if (this.routeDom && this.routeDom.style.display !== 'none') {
console.log('--- hide route ---')
debugLog('--- hide route ---')
this.previousDisplayStyle = this.routeDom.style.display
this.routeDom.style.display = 'none'
}
......@@ -278,7 +294,7 @@ class LiveRoute extends React.Component<IProps, any> {
if (this.routeDom && this.scrollPosBackup === null) {
const scrollTop = document.documentElement.scrollTop || document.body.scrollTop
const scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft
console.log(`saved top = ${scrollTop}, left = ${scrollLeft}`)
debugLog(`saved top = ${scrollTop}, left = ${scrollLeft}`)
this.scrollPosBackup = { top: scrollTop, left: scrollLeft }
}
}
......@@ -286,7 +302,7 @@ class LiveRoute extends React.Component<IProps, any> {
// restore the scroll position before hide
restoreScrollPosition() {
const scroll = this.scrollPosBackup
console.log(scroll)
debugLog(scroll)
if (scroll && this.routeDom) {
window.scrollTo(scroll.left, scroll.top)
}
......@@ -309,19 +325,21 @@ class LiveRoute extends React.Component<IProps, any> {
// normally render or unmount Route
renderRoute(component, render, props, match) {
console.log(match)
debugLog(match)
if (component) return match ? React.createElement(component, props) : null
if (render) return match ? render(props) : null
}
render() {
const { match } = this.state
const { children, component, render, livePath, alwaysLive } = this.props
const { children, component, render, livePath, alwaysLive, onHide } = this.props
const { history, route, staticContext } = this.context.router
const location = this.props.location || route.location
const props = { match, location, history, staticContext }
// only affect LiveRoute
if ((livePath || alwaysLive) && (component || render)) {
console.log('=== RENDER FLAG: ' + this.liveState + ' ===')
debugLog('=== RENDER FLAG: ' + this.liveState + ' ===')
if (
this.liveState === LiveState.NORMAL_RENDER_MATCHED ||
this.liveState === LiveState.NORMAL_RENDER_UNMATCHED ||
......@@ -332,9 +350,7 @@ class LiveRoute extends React.Component<IProps, any> {
} else if (this.liveState === LiveState.HIDE_RENDER) {
// hide render
const prevRouter = this._latestMatchedRouter
// load properties from prevRouter and fake props of latest normal render
const { history, route, staticContext } = prevRouter
const location = this.props.location || route.location
const { history, route, staticContext } = prevRouter // load properties from prevRouter and fake props of latest normal render
const liveProps = { match, location, history, staticContext }
return this.renderRoute(component, render, liveProps, true)
}
......
export { LiveRoute } from './LiveRoute'
import { LiveRoute } from './LiveRoute'
export default LiveRoute
......@@ -3,16 +3,11 @@
"strict": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"baseUrl": ".",
"paths": {
"@/*": ["src/index/*"]
},
"outDir": "dist/",
"module": "esnext",
"module": "commonjs",
"target": "es5",
"lib": ["es6", "dom"],
"sourceMap": true,
"allowJs": true,
"jsx": "react",
"moduleResolution": "node",
"rootDir": "src",
......
{
"extends": "./tsconfig.json"
}
\ No newline at end of file
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "commonjs"
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment