Socket
Socket
Sign inDemoInstall

react-router

Package Overview
Dependencies
5
Maintainers
2
Versions
433
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0-alpha2 to 1.0.0-beta1

lib/RouterContextMixin.js

4

doc/00 Guides/0 Overview.md

@@ -159,3 +159,3 @@ To illustrate the problems React Router is going to solve for you, let’s build a

component: App,
childRoute: [
childRoutes: [
{ path: 'about', component: About },

@@ -166,3 +166,3 @@ { path: 'inbox', component: Inbox },

React.render(<Router children={routes}/>, document.body):
React.render(<Router history={HashHistory} children={routes}/>, document.body):
```

@@ -169,0 +169,0 @@

@@ -28,4 +28,3 @@ Rendering on the server is not much different than rendering in the

// server.js
import { Router } from 'react-router';
import ServerHistory from 'react-router/lib/ServerHistory';
import { Router, Location } from 'react-router';
import routes from './routes';

@@ -36,7 +35,8 @@

serveNonStaticPaths((req, res) => {
var history = new ServerHistory(req.path);
Router.match(routes, history, (err, initialState) => {
// do your own data fetching, perhaps using the branch of components
// in the initialState
fetchSomeData(initialState.components, (err, initialData) => {
var location = new Location(req.path, req.query);
Router.run(routes, location, (error, initialState, transition) => {
// do your own data fetching, perhaps using the
// branch of components in the initialState
fetchSomeData(initialState.components, (error, initialData) => {
var html = React.renderToString(

@@ -43,0 +43,0 @@ <Router history={history} {...initialState}/>

@@ -127,11 +127,11 @@ A `Route` is used to declaratively map routes to your application's

### `onEnter(nextState, router)`
### `onEnter(nextState, transition)`
Called when a route is about to be entered. It provides the next router
state and the router instance for cancelling/redirecting the transition.
state and the [transition][Transition] instance for cancelling/redirecting.
### `onLeave(nextState, router)`
### `onLeave(nextState, transition)`
Called when a route is about to be exited. It provides the next router
state and the router instance for cancelling/redirecting the transition.
state and the [transition][Transition] instance for cancelling/redirecting.

@@ -143,2 +143,3 @@ [overview]:#TODO

[history]:#TODO
[Transition]:#TODO

@@ -18,3 +18,3 @@ Primary component of React Router. It keeps your UI and the URL in sync.

### `history` (required)
### `history`

@@ -33,3 +33,8 @@ The [`History`][History] the router should set up and listen for changes

### `stringifyQuery(query)`
A function that should be used to convert an object to a URL query string.
By default, this function uses `qs.stringify(query, { arrayFormat: 'brackets' })`.
#### Examples

@@ -36,0 +41,0 @@

@@ -6,5 +6,4 @@ `Router` sets up a `History` and updates `Router` state when the

```js
// typical usage
import BrowserHistory from 'react-router/lib/BrowserHistory';
<Router history={BrowserHistory}/>
import History from 'react-router/lib/BrowserHistory';
<Router history={History}/>
```

@@ -15,5 +14,3 @@

```js
// note the `{ ... }` in the import statement...
import { BrowserHistory } from 'react-router/lib/BrowserHistory';
// ...this gives you a class instead of a singleton instance

@@ -23,5 +20,2 @@ var history = new BrowserHistory({

return customParse(string);
},
stringifyQuery(obj) {
return customStringify(obj);
}

@@ -32,2 +26,1 @@ });

```

@@ -46,6 +46,6 @@ `BrowserHistory` is a [history][Histories] implementation for DOM environments that

import { Router } from 'react-router';
import BrowserHistory from 'react-router/lib/BrowserHistory';
import History from 'react-router/lib/BrowserHistory';
React.render((
<Router history={BrowserHistory}>
<Router history={History}>
{/* ... */}

@@ -52,0 +52,0 @@ </Router>

@@ -36,6 +36,6 @@ `HashHistory` is a [history][Histories] implementation for DOM environments that

import { Router } from 'react-router';
import HashHistory from 'react-router/lib/HashHistory';
import History from 'react-router/lib/HashHistory';
React.render((
<Router history={HashHistory}>
<Router history={History}>
{/* ... */}

@@ -49,3 +49,2 @@ </Router>

```js
// note the `{ ... }` syntax on the import
import { HashHistory } from 'react-router/lib/HashHistory';

@@ -57,3 +56,3 @@

// use your own
var history = new HashHistory({queryKey: 'k'});
var history = new HashHistory({ queryKey: 'k' });

@@ -60,0 +59,0 @@ React.render((

@@ -13,4 +13,6 @@ `MemoryHistory` is a [history][Histories] implementation that does not

var history = new MemoryHistory([ '/', '/a/path' ]);
React.render((
<Router history={MemoryHistory}>
<Router history={history}>
{/* ... */}

@@ -21,5 +23,3 @@ </Router>

[Histories]:#TODO

@@ -69,3 +69,3 @@ 'use strict';

this.location = this._createLocation((0, _DOMUtils.getWindowPath)(), state, navigationType);
this.location = this.createLocation((0, _DOMUtils.getWindowPath)(), state, navigationType);
}

@@ -122,3 +122,3 @@ }, {

window.history.pushState(state, '', path);
this.location = this._createLocation(path, state, _NavigationTypes2['default'].PUSH);
this.location = this.createLocation(path, state, _NavigationTypes2['default'].PUSH);
this._notifyChange();

@@ -138,3 +138,3 @@ } else {

window.history.replaceState(state, '', path);
this.location = this._createLocation(path, state, _NavigationTypes2['default'].REPLACE);
this.location = this.createLocation(path, state, _NavigationTypes2['default'].REPLACE);
this._notifyChange();

@@ -141,0 +141,0 @@ } else {

@@ -10,2 +10,3 @@ 'use strict';

exports.getWindowScrollPosition = getWindowScrollPosition;
exports.setWindowScrollPosition = setWindowScrollPosition;
exports.supportsHistory = supportsHistory;

@@ -38,2 +39,6 @@ var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);

function setWindowScrollPosition(scrollX, scrollY) {
window.scrollTo(scrollX, scrollY);
}
/**

@@ -40,0 +45,0 @@ * taken from modernizr

@@ -116,3 +116,3 @@ 'use strict';

var state = this.queryKey ? readState(path, this.queryKey) : null;
this.location = this._createLocation(path, state, navigationType);
this.location = this.createLocation(path, state, navigationType);
}

@@ -179,3 +179,3 @@ }, {

this.location = this._createLocation(path, state, _NavigationTypes2['default'].PUSH);
this.location = this.createLocation(path, state, _NavigationTypes2['default'].PUSH);

@@ -194,3 +194,3 @@ this._notifyChange();

this.location = this._createLocation(path, state, _NavigationTypes2['default'].REPLACE);
this.location = this.createLocation(path, state, _NavigationTypes2['default'].REPLACE);

@@ -197,0 +197,0 @@ this._notifyChange();

@@ -9,4 +9,2 @@ 'use strict';

var _get = function get(_x2, _x3, _x4) { var _again = true; _function: while (_again) { var object = _x2, property = _x3, receiver = _x4; desc = parent = getter = undefined; _again = false; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x2 = parent; _x3 = property; _x4 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

@@ -16,4 +14,2 @@

function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }
var _invariant = require('invariant');

@@ -25,6 +21,2 @@

var _ChangeEmitter2 = require('./ChangeEmitter');
var _ChangeEmitter3 = _interopRequireDefault(_ChangeEmitter2);
var _Location = require('./Location');

@@ -34,3 +26,3 @@

var RequiredSubclassMethods = ['pushState', 'replaceState', 'go'];
var RequiredHistorySubclassMethods = ['pushState', 'replaceState', 'go'];

@@ -51,3 +43,3 @@ function createRandomKey() {

var History = (function (_ChangeEmitter) {
var History = (function () {
function History() {

@@ -58,16 +50,29 @@ var options = arguments[0] === undefined ? {} : arguments[0];

_get(Object.getPrototypeOf(History.prototype), 'constructor', this).call(this);
RequiredHistorySubclassMethods.forEach(function (method) {
(0, _invariant2['default'])(typeof this[method] === 'function', '%s needs a "%s" method', this.constructor.name, method);
}, this);
this.parseQueryString = options.parseQueryString || _URLUtils.parseQueryString;
this.stringifyQuery = options.stringifyQuery || _URLUtils.stringifyQuery;
this.changeListeners = [];
this.location = null;
RequiredSubclassMethods.forEach(function (method) {
(0, _invariant2['default'])(typeof this[method] === 'function', '%s needs a "%s" method', this.constructor.name, method);
}, this);
}
_inherits(History, _ChangeEmitter);
_createClass(History, [{
key: '_notifyChange',
value: function _notifyChange() {
for (var i = 0, len = this.changeListeners.length; i < len; ++i) this.changeListeners[i].call(this);
}
}, {
key: 'addChangeListener',
value: function addChangeListener(listener) {
this.changeListeners.push(listener);
}
}, {
key: 'removeChangeListener',
value: function removeChangeListener(listener) {
this.changeListeners = this.changeListeners.filter(function (li) {
return li !== listener;
});
}
}, {
key: 'back',

@@ -92,4 +97,4 @@ value: function back() {

}, {
key: '_createLocation',
value: function _createLocation(path, state, navigationType) {
key: 'createLocation',
value: function createLocation(path, state, navigationType) {
var pathname = (0, _URLUtils.getPathname)(path);

@@ -100,33 +105,8 @@ var queryString = (0, _URLUtils.getQueryString)(path);

}
}, {
key: 'makePath',
/**
* Returns a full URL path from the given pathname and query.
*/
value: function makePath(pathname, query) {
if (query) {
if (typeof query !== 'string') query = this.stringifyQuery(query);
if (query !== '') return pathname + '?' + query;
}
return pathname;
}
}, {
key: 'makeHref',
/**
* Returns a string that may safely be used to link to the given
* pathname and query.
*/
value: function makeHref(pathname, query) {
return this.makePath(pathname, query);
}
}]);
return History;
})(_ChangeEmitter3['default']);
})();
exports['default'] = History;
module.exports = exports['default'];

@@ -70,3 +70,3 @@ 'use strict';

this.location = this._createLocation(currentEntry.path, currentEntry.state);
this.location = this.createLocation(currentEntry.path, currentEntry.state);
}

@@ -85,3 +85,3 @@

this.entries = this.entries.slice(0, this.current).concat([{ state: state, path: path }]);
this.location = this._createLocation(path, state, _NavigationTypes2['default'].PUSH);
this.location = this.createLocation(path, state, _NavigationTypes2['default'].PUSH);

@@ -98,3 +98,3 @@ this._notifyChange();

this.entries[this.current] = { state: state, path: path };
this.location = this._createLocation(path, state, _NavigationTypes2['default'].REPLACE);
this.location = this.createLocation(path, state, _NavigationTypes2['default'].REPLACE);

@@ -113,3 +113,3 @@ this._notifyChange();

this.location = this._createLocation(currentEntry.path, currentEntry.state, _NavigationTypes2['default'].POP);
this.location = this.createLocation(currentEntry.path, currentEntry.state, _NavigationTypes2['default'].POP);

@@ -139,3 +139,3 @@ this._notifyChange();

exports.MemoryHistory = MemoryHistory;
exports['default'] = MemoryHistory;
exports['default'] = MemoryHistory;
module.exports = exports['default'];

@@ -18,3 +18,2 @@ 'use strict';

var _React$PropTypes = _react2['default'].PropTypes;
var any = _React$PropTypes.any;
var func = _React$PropTypes.func;

@@ -25,3 +24,2 @@ var object = _React$PropTypes.object;

var oneOfType = _React$PropTypes.oneOfType;
var oneOf = _React$PropTypes.oneOf;
var element = _React$PropTypes.element;

@@ -37,4 +35,4 @@

var location = instanceOf(_Location2['default']);
var route = any; //oneOf([object, element]);
var routes = any; //oneOf([route, arrayOf(route), object]);
var route = oneOfType([object, element]);
var routes = oneOfType([route, arrayOf(route)]);

@@ -41,0 +39,0 @@ module.exports = {

@@ -27,4 +27,2 @@ 'use strict';

var _ActiveUtils = require('./ActiveUtils');
var _RoutingUtils = require('./RoutingUtils');

@@ -34,101 +32,101 @@

var _Location = require('./Location');
var _RouterContextMixin = require('./RouterContextMixin');
var _Location2 = _interopRequireDefault(_Location);
var _RouterContextMixin2 = _interopRequireDefault(_RouterContextMixin);
var _React$PropTypes = _react2['default'].PropTypes;
var any = _React$PropTypes.any;
var array = _React$PropTypes.array;
var func = _React$PropTypes.func;
var object = _React$PropTypes.object;
var instanceOf = _React$PropTypes.instanceOf;
var _ScrollManagementMixin = require('./ScrollManagementMixin');
var ContextMixin = {
var _ScrollManagementMixin2 = _interopRequireDefault(_ScrollManagementMixin);
childContextTypes: {
router: object.isRequired
},
var _Location = require('./Location');
getChildContext: function getChildContext() {
return {
router: this
};
},
var _Transition = require('./Transition');
makePath: function makePath(pathname, query) {
return this.props.history.makePath(pathname, query);
},
var _Transition2 = _interopRequireDefault(_Transition);
makeHref: function makeHref(pathname, query) {
return this.props.history.makeHref(pathname, query);
},
var _React$PropTypes = _react2['default'].PropTypes;
var arrayOf = _React$PropTypes.arrayOf;
var func = _React$PropTypes.func;
var object = _React$PropTypes.object;
transitionTo: function transitionTo(pathname, query) {
var state = arguments[2] === undefined ? null : arguments[2];
var history = this.props.history;
function runTransition(prevState, routes, location, hooks, callback) {
var transition = new _Transition2['default']();
var path = this.makePath(pathname, query);
if (this.nextLocation) {
history.replaceState(state, path);
(0, _RoutingUtils.getState)(routes, location, function (error, nextState) {
if (error || nextState == null || transition.isCancelled) {
callback(error, null, transition);
} else {
history.pushState(state, path);
}
},
nextState.location = location;
replaceWith: function replaceWith(pathname, query) {
var state = arguments[2] === undefined ? null : arguments[2];
var history = this.props.history;
var transitionHooks = (0, _RoutingUtils.getTransitionHooks)(prevState, nextState);
if (Array.isArray(hooks)) transitionHooks.unshift.apply(transitionHooks, hooks);
var path = this.makePath(pathname, query);
(0, _AsyncUtils.loopAsync)(transitionHooks.length, function (index, next, done) {
transitionHooks[index](nextState, transition, function (error) {
if (error || transition.isCancelled) {
done(error); // No need to continue.
} else {
next();
}
});
}, function (error) {
if (error || transition.isCancelled) {
callback(error, null, transition);
} else {
(0, _RoutingUtils.getComponents)(nextState.branch, function (error, components) {
if (error || transition.isCancelled) {
callback(error, null, transition);
} else {
nextState.components = components;
callback(null, nextState, transition);
}
});
}
});
}
});
}
history.replaceState(state, path);
},
go: function go(n) {
this.props.history.go(n);
},
goBack: function goBack() {
this.go(-1);
},
goForward: function goForward() {
this.go(1);
},
isActive: function isActive(pathname, query) {
var location = this.state.location;
if (location == null) return false;
return (0, _ActiveUtils.pathnameIsActive)(pathname, location.pathname) && (0, _ActiveUtils.queryIsActive)(query, location.query);
}
};
var Router = _react2['default'].createClass({
displayName: 'Router',
mixins: [ContextMixin],
mixins: [_RouterContextMixin2['default'], _ScrollManagementMixin2['default']],
statics: {
match: function match(routes, history, callback) {}
/**
* Runs a transition to the given location using the given routes and
* transition hooks (optional) and calls callback(error, state, transition)
* when finished. This is primarily useful for server-side rendering.
*/
run: function run(routes, location, transitionHooks, callback) {
if (typeof transitionHooks === 'function') {
callback = transitionHooks;
transitionHooks = null;
}
(0, _invariant2['default'])(typeof callback === 'function', 'Router.run needs a callback');
runTransition(null, routes, location, transitionHooks, callback);
}
},
propTypes: {
history: _PropTypes.history.isRequired,
children: _PropTypes.routes,
routes: _PropTypes.routes, // Alias for children
createElement: func.isRequired,
onError: func.isRequired,
onAbort: func,
onError: func,
onUpdate: func,
// For server-side rendering
location: any,
// Client-side
history: _PropTypes.history,
routes: _PropTypes.routes,
// Routes may also be given as children (JSX)
children: _PropTypes.routes,
// Server-side
location: _PropTypes.location,
branch: _PropTypes.routes,
params: object,
components: _PropTypes.components
components: arrayOf(_PropTypes.components)
},

@@ -138,7 +136,3 @@

return {
createElement: _react.createElement,
onError: function onError(error) {
// Throw errors by default so we don't silently swallow them!
throw error; // This error probably originated in getChildRoutes or getComponents.
}
createElement: _react.createElement
};

@@ -149,7 +143,7 @@ },

return {
isTransitioning: false,
location: null,
branch: null,
params: null,
components: null,
isTransitioning: false
components: null
};

@@ -161,96 +155,37 @@ },

(0, _invariant2['default'])(_Location2['default'].isLocation(location), 'A <Router> needs a valid Location');
(0, _invariant2['default'])((0, _Location.isLocation)(location), 'A <Router> needs a valid Location');
this.nextLocation = location;
var hooks = this.transitionHooks;
if (hooks) hooks = hooks.map(function (hook) {
return (0, _RoutingUtils.createTransitionHook)(hook, _this);
});
this.setState({ isTransitioning: true });
this._getState(this.routes, location, function (error, state) {
if (error || _this.nextLocation !== location) {
_this._finishTransition(error);
runTransition(this.state, this.routes, location, hooks, function (error, state, transition) {
if (error) {
_this.handleError(error);
} else if (transition.isCancelled) {
if (transition.redirectInfo) {
var _transition$redirectInfo = transition.redirectInfo;
var pathname = _transition$redirectInfo.pathname;
var query = _transition$redirectInfo.query;
var state = _transition$redirectInfo.state;
_this.replaceWith(pathname, query, state);
} else {
(0, _invariant2['default'])(_this.state.location, 'You may not abort the initial transition');
_this.handleAbort(reason);
}
} else if (state == null) {
(0, _warning2['default'])(false, 'Location "%s" did not match any routes', location.pathname);
_this._finishTransition();
} else {
state.location = location;
_this._runTransitionHooks(state, function (error) {
if (error || _this.nextLocation !== location) {
_this._finishTransition(error);
} else {
_this._getComponents(state, function (error, components) {
if (error || _this.nextLocation !== location) {
_this._finishTransition(error);
} else {
state.components = components;
_this._finishTransition(null, state);
}
});
}
});
_this.setState(state, _this.props.onUpdate);
}
});
},
_finishTransition: function _finishTransition(error, state) {
this.setState({ isTransitioning: false });
this.nextLocation = null;
if (error) {
this.handleError(error);
} else if (state) {
this.setState(state, this.props.onUpdate);
this._alreadyUpdated = true;
}
},
_getState: function _getState(routes, location, callback) {
var _props = this.props;
var branch = _props.branch;
var params = _props.params;
if (branch && params && query) {
callback(null, { branch: branch, params: params });
} else {
(0, _RoutingUtils.getState)(routes, location, callback);
}
},
_runTransitionHooks: function _runTransitionHooks(nextState, callback) {
var _this2 = this;
// Run component hooks before route hooks.
var hooks = this.transitionHooks.map(function (hook) {
return (0, _RoutingUtils.createTransitionHook)(hook, _this2);
_this.setState({ isTransitioning: false });
});
hooks.push.apply(hooks, (0, _RoutingUtils.getTransitionHooks)(this.state, nextState));
var nextLocation = this.nextLocation;
(0, _AsyncUtils.loopAsync)(hooks.length, function (index, next, done) {
var hook = hooks[index];
hooks[index].call(_this2, nextState, _this2, function (error) {
if (error || _this2.nextLocation !== nextLocation) {
done.call(_this2, error); // No need to continue.
} else {
next.call(_this2);
}
});
}, callback);
},
_getComponents: function _getComponents(nextState, callback) {
if (this.props.components) {
callback(null, this.props.components);
} else {
(0, _RoutingUtils.getComponents)(nextState, callback);
}
},
_createElement: function _createElement(component, props) {
return typeof component === 'function' ? this.props.createElement(component, props) : null;
},
/**

@@ -261,2 +196,4 @@ * Adds a transition hook that runs before all route hooks in a

addTransitionHook: function addTransitionHook(hook) {
if (!this.transitionHooks) this.transitionHooks = [];
this.transitionHooks.push(hook);

@@ -269,3 +206,3 @@ },

removeTransitionHook: function removeTransitionHook(hook) {
this.transitionHooks = this.transitionHooks.filter(function (h) {
if (this.transitionHooks) this.transitionHooks = this.transitionHooks.filter(function (h) {
return h !== hook;

@@ -275,19 +212,20 @@ });

/**
* Cancels the current transition, preventing any subsequent transition
* hooks from running and restoring the previous location.
*/
cancelTransition: function cancelTransition() {
(0, _invariant2['default'])(this.state.location, 'Router#cancelTransition: You may not cancel the initial transition');
if (this.nextLocation) {
this.nextLocation = null;
handleAbort: function handleAbort(reason) {
if (this.props.onAbort) {
this.props.onAbort.call(this, reason);
} else {
// The best we can do here is goBack so the location state reverts
// to what it was. However, we also set a flag so that we know not
// to run through _updateState again.
// to run through _updateState again since state did not change.
this._ignoreNextHistoryChange = true;
this.goBack();
}
},
handleError: function handleError(error) {
if (this.props.onError) {
this.props.onError.call(this, error);
} else {
(0, _warning2['default'])(false, 'Router#cancelTransition: Router is not transitioning');
// Throw errors by default so we don't silently swallow them!
throw error; // This error probably originated in getChildRoutes or getComponents.
}

@@ -305,27 +243,27 @@ },

componentWillMount: function componentWillMount() {
var _props2 = this.props;
var history = _props2.history;
var routes = _props2.routes;
var children = _props2.children;
var _props = this.props;
var history = _props.history;
var routes = _props.routes;
var children = _props.children;
var location = _props.location;
var branch = _props.branch;
var params = _props.params;
var components = _props.components;
(0, _invariant2['default'])(routes || children, 'A <Router> needs some routes');
if (history) {
(0, _invariant2['default'])(routes || children, 'Client-side <Router>s need routes. Try using <Router routes> or ' + 'passing your routes as nested <Route> children');
this.routes = (0, _RouteUtils.createRoutes)(routes || children);
this.transitionHooks = [];
this.nextLocation = null;
this.routes = (0, _RouteUtils.createRoutes)(routes || children);
if (typeof history.setup === 'function') history.setup();
if (typeof history.setup === 'function') history.setup();
// We need to listen first in case we redirect immediately.
if (history.addChangeListener) history.addChangeListener(this.handleHistoryChange);
// We need to listen first in case we redirect immediately.
if (history.addChangeListener) history.addChangeListener(this.handleHistoryChange);
this._updateState(history.location);
},
this._updateState(history.location);
} else {
(0, _invariant2['default'])(location && branch && params && components, 'Server-side <Router>s need location, branch, params, and components ' + 'props. Try using Router.run to get all the props you need');
componentDidMount: function componentDidMount() {
// React doesn't fire the setState callback when we call setState
// synchronously within componentWillMount, so we need this. Note
// that we still only get one call to onUpdate, even if setState
// was called multiple times in componentWillMount.
if (this._alreadyUpdated && this.props.onUpdate) this.props.onUpdate.call(this);
this.setState({ location: location, branch: branch, params: params, components: components });
}
},

@@ -336,11 +274,13 @@

var currentRoutes = this.props.routes || this.props.children;
var nextRoutes = nextProps.routes || nextProps.children;
if (nextProps.history) {
var currentRoutes = this.props.routes || this.props.children;
var nextRoutes = nextProps.routes || nextProps.children;
if (currentRoutes !== nextRoutes) {
this.routes = (0, _RouteUtils.createRoutes)(nextRoutes);
if (currentRoutes !== nextRoutes) {
this.routes = (0, _RouteUtils.createRoutes)(nextRoutes);
// Call this here because _updateState
// uses this.routes to determine state.
if (nextProps.history.location) this._updateState(nextProps.history.location);
// Call this here because _updateState
// uses this.routes to determine state.
if (nextProps.history.location) this._updateState(nextProps.history.location);
}
}

@@ -352,7 +292,11 @@ },

if (history.removeChangeListener) history.removeChangeListener(this.handleHistoryChange);
if (history && history.removeChangeListener) history.removeChangeListener(this.handleHistoryChange);
},
_createElement: function _createElement(component, props) {
return typeof component === 'function' ? this.props.createElement(component, props) : null;
},
render: function render() {
var _this3 = this;
var _this2 = this;

@@ -386,3 +330,3 @@ var _state = this.state;

for (var key in components) if (components.hasOwnProperty(key)) elements[key] = _this3._createElement(components[key], props);
for (var key in components) if (components.hasOwnProperty(key)) elements[key] = _this2._createElement(components[key], props);

@@ -392,3 +336,3 @@ return elements;

return _this3._createElement(components, props);
return _this2._createElement(components, props);
}, element);

@@ -404,6 +348,3 @@ }

exports.Router = Router;
exports['default'] = Router;
// TODO: Mimic what we're doing in _updateState, but statically
// so we can get the right props for doing server-side rendering.
module.exports = exports['default'];

@@ -7,3 +7,2 @@ 'use strict';

exports.getState = getState;
exports.computeDiff = computeDiff;
exports.createTransitionHook = createTransitionHook;

@@ -14,4 +13,10 @@ exports.getTransitionHooks = getTransitionHooks;

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _slicedToArray(arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i['return']) _i['return'](); } finally { if (_d) throw _e; } } return _arr; } else { throw new TypeError('Invalid attempt to destructure non-iterable instance'); } }
var _invariant = require('invariant');
var _invariant2 = _interopRequireDefault(_invariant);
var _RouteUtils = require('./RouteUtils');

@@ -159,3 +164,2 @@

*/
function computeDiff(prevState, nextState) {

@@ -186,9 +190,9 @@ var fromRoutes = prevState && prevState.branch;

function createTransitionHook(fn, context) {
return function (nextState, router, callback) {
return function (nextState, transition, callback) {
if (fn.length > 2) {
fn.call(context, nextState, router, callback);
fn.call(context, nextState, transition, callback);
} else {
// Assume fn executes synchronously and
// automatically call the callback for them.
fn.call(context, nextState, router);
fn.call(context, nextState, transition);
callback();

@@ -212,4 +216,4 @@ }

*
* - route.onLeave(nextState, router[, callback ])
* - route.onEnter(nextState, router[, callback ])
* - route.onLeave(nextState, transition[, callback ])
* - route.onEnter(nextState, transition[, callback ])
*

@@ -250,8 +254,2 @@ * Transition hooks run in order from the leaf route in the branch

function getComponentsForRoutes(routes, callback) {
(0, _AsyncUtils.mapAsync)(routes, function (route, index, callback) {
getComponentsForRoute(route, callback);
}, callback);
}
/**

@@ -265,4 +263,6 @@ * Asynchronously fetches all components needed for the given router

function getComponents(state, callback) {
getComponentsForRoutes(state.branch, callback);
function getComponents(routes, callback) {
(0, _AsyncUtils.mapAsync)(routes, function (route, index, callback) {
getComponentsForRoute(route, callback);
}, callback);
}

@@ -269,0 +269,0 @@

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?exports.ReactRouter=t(require("react")):e.ReactRouter=t(e.React)}(this,function(e){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(18),i=r(o);t.Router=i["default"];var a=n(13),u=r(a);t.Link=u["default"];var s=n(16),c=r(s);t.Redirect=c["default"];var l=n(17),f=r(l);t.Route=f["default"];var p=n(14),d=r(p);t.Navigation=d["default"];var h=n(21),y=r(h);t.TransitionHook=y["default"];var m=n(20),v=r(m);t.State=v["default"];var g=n(2);Object.defineProperty(t,"createRoutesFromReactChildren",{enumerable:!0,get:function(){return g.createRoutesFromReactChildren}});var b=n(3),_=r(b);t.PropTypes=_["default"];var x=r(o);t["default"]=x["default"]},function(t){t.exports=e},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e){return null==e||f.isValidElement(e)}function i(e){return o(e)||Array.isArray(e)&&e.every(o)}function a(e,t,n){e=e||"UnknownComponent";for(var r in t)if(t.hasOwnProperty(r)){var o=t[r](n,r,e);o instanceof Error&&h["default"](!1,o.message)}}function u(e){var t=e.type,n=l({},t.defaultProps,e.props);return t.propTypes&&a(t.displayName||t.name,t.propTypes,n),n.children&&(n.childRoutes=s(n.children),delete n.children),n}function s(e){var t=[];return p["default"].Children.forEach(e,function(e){f.isValidElement(e)&&t.push(e.type.createRouteFromReactElement?e.type.createRouteFromReactElement(e):u(e))}),t}function c(e){return i(e)?e=s(e):Array.isArray(e)||(e=[e]),e}Object.defineProperty(t,"__esModule",{value:!0});var l=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e};t.isReactChildren=i,t.createRouteFromReactElement=u,t.createRoutesFromReactChildren=s,t.createRoutes=c;var f=n(1),p=r(f),d=n(7),h=r(d)},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t,n){return e[t]?new Error("<"+n+'> should not have a "'+t+'" prop'):void 0}var i=n(1),a=r(i),u=n(5),s=r(u),c=n(12),l=r(c),f=a["default"].PropTypes,p=f.any,d=f.func,h=f.object,y=(f.arrayOf,f.instanceOf),m=f.oneOfType,v=(f.oneOf,f.element,d),g=m([v,h]),b=y(l["default"]),_=y(s["default"]),x=p,O=p;e.exports={falsy:o,component:v,components:g,history:b,location:_,route:x,routes:O}},function(e){"use strict";var t=function(e,t,n,r,o,i,a,u){if(!e){var s;if(void 0===t)s=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var c=[n,r,o,i,a,u],l=0;s=new Error("Invariant Violation: "+t.replace(/%s/g,function(){return c[l++]}))}throw s.framesToPop=1,s}};e.exports=t},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=n(15),u=r(a),s=function(){function e(){var t=void 0===arguments[0]?"/":arguments[0],n=void 0===arguments[1]?null:arguments[1],r=void 0===arguments[2]?null:arguments[2],i=void 0===arguments[3]?u["default"].POP:arguments[3];o(this,e),this.pathname=t,this.query=n,this.state=r,this.navigationType=i}return i(e,null,[{key:"isLocation",value:function(t){return t instanceof e}}]),e}();t["default"]=s,e.exports=t["default"]},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e){return m["default"].stringify(e,{arrayFormat:"brackets"})}function i(e){return e.replace(g,"")}function a(e){var t=e.match(g);return t?t[1]:""}function u(e){return e?e.replace(/^\/+/,""):""}function s(e){return"string"==typeof e&&"/"===e.charAt(0)}function c(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function l(e){return c(e).replace(/\/+/g,"/+")}function f(e){for(var t,n="",r=[],o=[],i=0,a=/:([a-zA-Z_$][a-zA-Z0-9_$]*)|\*|\(|\)/g;t=a.exec(e);)t.index!==i&&(o.push(e.slice(i,t.index)),n+=l(e.slice(i,t.index))),t[1]?(n+="([^/?#]+)",r.push(t[1])):"*"===t[0]?(n+="(.*?)",r.push("splat")):"("===t[0]?n+="(?:":")"===t[0]&&(n+=")?"),o.push(t[0]),i=a.lastIndex;return i!==e.length&&(o.push(e.slice(i,e.length)),n+=l(e.slice(i,e.length))),{pattern:e,regexpSource:n,paramNames:r,tokens:o}}function p(e){return e in b||(b[e]=f(e)),b[e]}function d(e,t){var n=p(u(e)),r=n.regexpSource,o=n.paramNames,i=n.tokens;r+="/*";var a="*"!==i[i.length-1];a&&(r+="(.*?)");var s,c,l=t.match(new RegExp("^"+r+"$","i"));return null!=l&&(c=Array.prototype.slice.call(l,1),s=a?c.pop():t.replace(l[0],"")),{remainingPathname:s,paramNames:o,paramValues:c}}function h(e){return p(e).paramNames}Object.defineProperty(t,"__esModule",{value:!0}),t.stringifyQuery=o,t.getPathname=i,t.getQueryString=a,t.stripLeadingSlashes=u,t.isAbsolutePath=s,t.compilePattern=p,t.matchPattern=d,t.getParamNames=h;var y=n(23),m=r(y),v=m["default"].parse;t.parseQueryString=v;var g=/\?(.*)$/,b={}},function(e){"use strict";var t=!1,n=function(){};t&&(n=function(e,t,n){var r=arguments.length;n=new Array(r>2?r-2:0);for(var o=2;r>o;o++)n[o-2]=arguments[o];if(void 0===t)throw new Error("`warning(condition, format, ...args)` requires a warning message argument");if(t.length<10||/^[s\W]*$/.test(t))throw new Error("The warning format should be able to uniquely identify this warning. Please, use a more descriptive format than: "+t);if(!e){var i=0,a="Warning: "+t.replace(/%s/g,function(){n[i++]});"undefined"!=typeof console&&console.error(a);try{throw new Error(a)}catch(u){}}}),e.exports=n},function(e,t){"use strict";function n(e,t,n){function r(){a=!0,n.apply(this,arguments)}function o(){a||(e>i?(i+=1,t.call(this,i-1,o,r)):r.apply(this,arguments))}var i=0,a=!1;o()}function r(e,t,n){function r(e,t,r){a||(t?(a=!0,n(t)):(i[e]=r,a=++u===o,a&&n(null,i)))}var o=e.length,i=[];if(0===o)return n(null,i);var a=!1,u=0;e.forEach(function(e,n){t(e,n,function(e,t){r(n,e,t)})})}function o(e,t,n){var o=Object.keys(e);r(o,function(n,r,o){t(e[n],o)},function(e,t){if(e)n(e);else{var r=t.reduce(function(e,t,n){return e[o[n]]=t,e},{});n(null,r)}})}Object.defineProperty(t,"__esModule",{value:!0}),t.loopAsync=n,t.mapAsync=r,t.hashAsync=o},function(e,t){t.arrayToObject=function(e){for(var t={},n=0,r=e.length;r>n;++n)"undefined"!=typeof e[n]&&(t[n]=e[n]);return t},t.merge=function(e,n){if(!n)return e;if("object"!=typeof n)return Array.isArray(e)?e.push(n):e[n]=!0,e;if("object"!=typeof e)return e=[e].concat(n);Array.isArray(e)&&!Array.isArray(n)&&(e=t.arrayToObject(e));for(var r=Object.keys(n),o=0,i=r.length;i>o;++o){var a=r[o],u=n[a];e[a]=e[a]?t.merge(e[a],u):u}return e},t.decode=function(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch(t){return e}},t.compact=function(e,n){if("object"!=typeof e||null===e)return e;n=n||[];var r=n.indexOf(e);if(-1!==r)return n[r];if(n.push(e),Array.isArray(e)){for(var o=[],i=0,a=e.length;a>i;++i)"undefined"!=typeof e[i]&&o.push(e[i]);return o}var u=Object.keys(e);for(i=0,a=u.length;a>i;++i){var s=u[i];e[s]=t.compact(e[s],n)}return e},t.isRegExp=function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},t.isBuffer=function(e){return null===e||"undefined"==typeof e?!1:!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))}},function(e,t,n){"use strict";function r(e,t){return 0===i.stripLeadingSlashes(t).indexOf(i.stripLeadingSlashes(e))?!0:!1}function o(e,t){if(null==t)return null==e;if(null==e)return!0;for(var n in e)if(e.hasOwnProperty(n)&&String(e[n])!==String(t[n]))return!1;return!0}Object.defineProperty(t,"__esModule",{value:!0}),t.pathnameIsActive=r,t.queryIsActive=o;var i=n(6)},function(e,t){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=function(){function e(){n(this,e),this.changeListeners=[]}return r(e,[{key:"_notifyChange",value:function(){for(var e=0,t=this.changeListeners.length;t>e;++e)this.changeListeners[e].call(this)}},{key:"addChangeListener",value:function(e){this.changeListeners.push(e)}},{key:"removeChangeListener",value:function(e){this.changeListeners=this.changeListeners.filter(function(t){return t!==e})}}]),e}();t["default"]=o,e.exports=t["default"]},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(e.__proto__=t)}function a(){return Math.random().toString(36).substr(2)}Object.defineProperty(t,"__esModule",{value:!0});var u=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),s=function(e,t,n){for(var r=!0;r;){var o=e,i=t,a=n;u=c=s=void 0,r=!1;var u=Object.getOwnPropertyDescriptor(o,i);if(void 0!==u){if("value"in u)return u.value;var s=u.get;return void 0===s?void 0:s.call(a)}var c=Object.getPrototypeOf(o);if(null===c)return void 0;e=c,t=i,n=a,r=!0}},c=n(4),l=r(c),f=n(6),p=n(11),d=r(p),h=n(5),y=r(h),m=["pushState","replaceState","go"],v=function(e){function t(){var e=void 0===arguments[0]?{}:arguments[0];o(this,t),s(Object.getPrototypeOf(t.prototype),"constructor",this).call(this),this.parseQueryString=e.parseQueryString||f.parseQueryString,this.stringifyQuery=e.stringifyQuery||f.stringifyQuery,this.location=null,m.forEach(function(e){l["default"]("function"==typeof this[e],'%s needs a "%s" method',this.constructor.name,e)},this)}return i(t,e),u(t,[{key:"back",value:function(){this.go(-1)}},{key:"forward",value:function(){this.go(1)}},{key:"_createState",value:function(e){return e=e||{},e.key||(e.key=a()),e}},{key:"_createLocation",value:function(e,t,n){var r=f.getPathname(e),o=f.getQueryString(e),i=o?this.parseQueryString(o):null;return new y["default"](r,i,t,n)}},{key:"makePath",value:function(e,t){return t&&("string"!=typeof t&&(t=this.stringifyQuery(t)),""!==t)?e+"?"+t:e}},{key:"makeHref",value:function(e,t){return this.makePath(e,t)}}]),t}(d["default"]);t["default"]=v,e.exports=t["default"]},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e){return 0===e.button}function i(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}Object.defineProperty(t,"__esModule",{value:!0});var a=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},u=n(1),s=r(u),c=s["default"].PropTypes,l=c.object,f=c.string,p=c.func,d=s["default"].createClass({displayName:"Link",contextTypes:{router:l},propTypes:{activeStyle:l,activeClassName:f,to:f.isRequired,query:l,state:l,onClick:p},getDefaultProps:function(){return{className:"",activeClassName:"active",style:{}}},handleClick:function(e){var t,n=!0;this.props.onClick&&(t=this.props.onClick(e)),!i(e)&&o(e)&&((t===!1||e.defaultPrevented===!0)&&(n=!1),e.preventDefault(),n&&this.context.router.transitionTo(this.props.to,this.props.query,this.props.state))},render:function(){var e=this.context.router,t=this.props,n=t.to,r=t.query,o=a({},this.props,{href:e.makeHref(n,r),onClick:this.handleClick});return e&&e.isActive(n,r)&&(o.activeClassName&&(o.className+=" "+o.activeClassName),o.activeStyle&&a(o.style,o.activeStyle)),s["default"].createElement("a",o)}});t.Link=d,t["default"]=d},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(1),i=r(o),a=i["default"].PropTypes.object,u={contextTypes:{router:a.isRequired}},s=["makePath","makeHref","transitionTo","replaceWith","go","goBack","goForward"];s.forEach(function(e){u[e]=function(){var t=this.context.router;return t[e].apply(t,arguments)}}),t["default"]=u,e.exports=t["default"]},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(22),i=r(o),a=i["default"]({PUSH:null,REPLACE:null,POP:null});t["default"]=a,e.exports=t["default"]},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(1),i=r(o),a=n(4),u=r(a),s=n(2),c=n(3),l=i["default"].PropTypes.string,f=i["default"].createClass({displayName:"Redirect",statics:{createRouteFromReactElement:function(e){var t=s.createRouteFromReactElement(e);return t.from&&(t.path=t.from),t.onEnter=function(e,n){n.replaceWith(t.to,e.query)},t}},propTypes:{from:l,to:l.isRequired,onEnter:c.falsy,children:c.falsy},render:function(){u["default"](!1,"<Redirect> elements are for router configuration only and should not be rendered")}});t.Redirect=f,t["default"]=f},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(1),i=r(o),a=n(4),u=r(a),s=n(2),c=n(3),l=i["default"].PropTypes,f=l.string,p=l.bool,d=l.func,h=i["default"].createClass({displayName:"Route",statics:{createRouteFromReactElement:function(e){var t=s.createRouteFromReactElement(e);return t.handler&&(warning(!1,"<Route handler> is deprecated, use <Route component> instead"),t.component=t.handler,delete t.handler),t}},propTypes:{path:f,ignoreScrollBehavior:p,handler:c.component,component:c.component,components:c.components,getComponents:d},render:function(){u["default"](!1,"<Route> elements are for router configuration only and should not be rendered")}});t.Route=h,t["default"]=h},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0});var o=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},i=n(1),a=r(i),u=n(7),s=r(u),c=n(4),l=r(c),f=n(8),p=n(2),d=n(10),h=n(19),y=n(3),m=n(5),v=r(m),g=a["default"].PropTypes,b=g.any,_=(g.array,g.func),x=g.object,O=(g.instanceOf,{childContextTypes:{router:x.isRequired},getChildContext:function(){return{router:this}},makePath:function(e,t){return this.props.history.makePath(e,t)},makeHref:function(e,t){return this.props.history.makeHref(e,t)},transitionTo:function(e,t){var n=void 0===arguments[2]?null:arguments[2],r=this.props.history,o=this.makePath(e,t);this.nextLocation?r.replaceState(n,o):r.pushState(n,o)},replaceWith:function(e,t){var n=void 0===arguments[2]?null:arguments[2],r=this.props.history,o=this.makePath(e,t);r.replaceState(n,o)},go:function(e){this.props.history.go(e)},goBack:function(){this.go(-1)},goForward:function(){this.go(1)},isActive:function(e,t){var n=this.state.location;return null==n?!1:d.pathnameIsActive(e,n.pathname)&&d.queryIsActive(t,n.query)}}),P=a["default"].createClass({displayName:"Router",mixins:[O],statics:{match:function(){}},propTypes:{history:y.history.isRequired,children:y.routes,routes:y.routes,createElement:_.isRequired,onError:_.isRequired,onUpdate:_,location:b,branch:y.routes,params:x,components:y.components},getDefaultProps:function(){return{createElement:i.createElement,onError:function(e){throw e}}},getInitialState:function(){return{location:null,branch:null,params:null,components:null,isTransitioning:!1}},_updateState:function(e){var t=this;l["default"](v["default"].isLocation(e),"A <Router> needs a valid Location"),this.nextLocation=e,this.setState({isTransitioning:!0}),this._getState(this.routes,e,function(n,r){n||t.nextLocation!==e?t._finishTransition(n):null==r?(s["default"](!1,'Location "%s" did not match any routes',e.pathname),t._finishTransition()):(r.location=e,t._runTransitionHooks(r,function(n){n||t.nextLocation!==e?t._finishTransition(n):t._getComponents(r,function(n,o){n||t.nextLocation!==e?t._finishTransition(n):(r.components=o,t._finishTransition(null,r))})}))})},_finishTransition:function(e,t){this.setState({isTransitioning:!1}),this.nextLocation=null,e?this.handleError(e):t&&(this.setState(t,this.props.onUpdate),this._alreadyUpdated=!0)},_getState:function(e,t,n){var r=this.props,o=r.branch,i=r.params;o&&i&&query?n(null,{branch:o,params:i}):h.getState(e,t,n)},_runTransitionHooks:function(e,t){var n=this,r=this.transitionHooks.map(function(e){return h.createTransitionHook(e,n)});r.push.apply(r,h.getTransitionHooks(this.state,e));var o=this.nextLocation;f.loopAsync(r.length,function(t,i,a){r[t];r[t].call(n,e,n,function(e){e||n.nextLocation!==o?a.call(n,e):i.call(n)})},t)},_getComponents:function(e,t){this.props.components?t(null,this.props.components):h.getComponents(e,t)},_createElement:function(e,t){return"function"==typeof e?this.props.createElement(e,t):null},addTransitionHook:function(e){this.transitionHooks.push(e)},removeTransitionHook:function(e){this.transitionHooks=this.transitionHooks.filter(function(t){return t!==e})},cancelTransition:function(){l["default"](this.state.location,"Router#cancelTransition: You may not cancel the initial transition"),this.nextLocation?(this.nextLocation=null,this._ignoreNextHistoryChange=!0,this.goBack()):s["default"](!1,"Router#cancelTransition: Router is not transitioning")},handleHistoryChange:function(){this._ignoreNextHistoryChange?this._ignoreNextHistoryChange=!1:this._updateState(this.props.history.location)},componentWillMount:function(){var e=this.props,t=e.history,n=e.routes,r=e.children;l["default"](n||r,"A <Router> needs some routes"),this.routes=p.createRoutes(n||r),this.transitionHooks=[],this.nextLocation=null,"function"==typeof t.setup&&t.setup(),t.addChangeListener&&t.addChangeListener(this.handleHistoryChange),this._updateState(t.location)},componentDidMount:function(){this._alreadyUpdated&&this.props.onUpdate&&this.props.onUpdate.call(this)},componentWillReceiveProps:function(e){l["default"](this.props.history===e.history,"<Router history> may not be changed");var t=this.props.routes||this.props.children,n=e.routes||e.children;t!==n&&(this.routes=p.createRoutes(n),e.history.location&&this._updateState(e.history.location))},componentWillUnmount:function(){var e=this.props.history;e.removeChangeListener&&e.removeChangeListener(this.handleHistoryChange)},render:function(){var e=this,t=this.state,n=t.location,r=t.branch,a=t.params,u=t.components,s=t.isTransitioning,c=null;return u&&(c=u.reduceRight(function(t,u,c){if(null==u)return t;var l=r[c],f=h.getRouteParams(l,a),p={location:n,params:a,route:l,routeParams:f,isTransitioning:s};if(i.isValidElement(t)?p.children=t:t&&o(p,t),"object"==typeof u){var d={};for(var y in u)u.hasOwnProperty(y)&&(d[y]=e._createElement(u[y],p));return d}return e._createElement(u,p)},c)),l["default"](null===c||c===!1||i.isValidElement(c),"The root route must render a single element"),c}});t.Router=P,t["default"]=P},function(e,t,n){"use strict";function r(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e)){var n=[],r=!0,o=!1,i=void 0;try{for(var a,u=e[Symbol.iterator]();!(r=(a=u.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(s){o=!0,i=s}finally{try{!r&&u["return"]&&u["return"]()}finally{if(o)throw i}}return n}throw new TypeError("Invalid attempt to destructure non-iterable instance")}function o(e,t,n){e.childRoutes?n(null,e.childRoutes):e.getChildRoutes?e.getChildRoutes(t,n):n()}function i(e,t,n){e.indexRoute?n(null,e.indexRoute):e.getIndexRoute?e.getIndexRoute(n,t):n()}function a(e,t,n){return t.reduceRight(function(e,t,r){var o=n[r];return Array.isArray(e[t])?e[t].unshift(o):e[t]=t in e?[o,e[t]]:o,e},e)}function u(e,t){return a({},e,t)}function s(e,t,n,r){var s=x.matchPattern(e.path,t),l=s.remainingPathname,f=s.paramNames,p=s.paramValues,d=""===l;if(d&&e.path){var h=u(f,p),y=[e];i(e,n,function(e,t){e?r(e):(t&&y.push(t),r(null,{params:h,branch:y}))})}else null!=l?o(e,n,function(t,o){t?r(t):o?c(o,l,n,function(t,n){t?r(t):n?(a(n.params,f,p),n.branch.unshift(e),r(null,n)):r()}):r()}):r()}function c(e,t,n,r){e=_.createRoutes(e),O.loopAsync(e.length,function(r,o,i){s(e[r],t,n,function(e,t){e||t?i(e,t):o()})},r)}function l(e,t,n){c(e,x.stripLeadingSlashes(t.pathname),t.state,n)}function f(e,t,n){if(!e.path)return!1;var r=x.getParamNames(e.path);return r.some(function(e){return t.params[e]!==n.params[e]})}function p(e,t){var n,r,o=e&&e.branch,i=t.branch;return o?(n=o.filter(function(n){return-1===i.indexOf(n)||f(n,e,t)}),n.reverse(),r=i.filter(function(e){return-1===o.indexOf(e)||-1!==n.indexOf(e)})):(n=[],r=i),[n,r]}function d(e,t){return function(n,r,o){e.length>2?e.call(t,n,r,o):(e.call(t,n,r),o())}}function h(e,t){return e.reduce(function(e,n){return n[t]&&e.push(d(n[t],n)),e},[])}function y(e,t){var n=p(e,t),o=r(n,2),i=o[0],a=o[1],u=h(i,"onLeave");return u.push.apply(u,h(a,"onEnter")),u}function m(e,t){e.component||e.components?t(null,e.component||e.components):e.getComponents?e.getComponents(t):t()}function v(e,t){O.mapAsync(e,function(e,t,n){m(e,n)},t)}function g(e,t){v(e.branch,t)}function b(e,t){var n={};if(!e.path)return n;var r=x.getParamNames(e.path);for(var o in t)t.hasOwnProperty(o)&&-1!==r.indexOf(o)&&(n[o]=t[o]);return n}Object.defineProperty(t,"__esModule",{value:!0}),t.getState=l,t.computeDiff=p,t.createTransitionHook=d,t.getTransitionHooks=y,t.getComponents=g,t.getRouteParams=b;var _=n(2),x=n(6),O=n(8)},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(1),i=r(o),a=i["default"].PropTypes.object,u={contextTypes:{router:a.isRequired}},s=["isActive"];s.forEach(function(e){u[e]=function(){var t=this.context.router;return t[e].apply(t,arguments)}}),t["default"]=u,e.exports=t["default"]},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(1),i=r(o),a=n(7),u=r(a),s=i["default"].PropTypes.object,c={contextTypes:{router:s.isRequired},componentDidMount:function(){u["default"]("function"==typeof this.routerWillLeave,"Components that mixin TransitionHook should have a routerWillLeave method, check %s",this.constructor.displayName||this.constructor.name),this.routerWillLeave&&this.context.router.addTransitionHook(this.routerWillLeave)},componentWillUnmount:function(){this.routerWillLeave&&this.context.router.removeTransitionHook(this.routerWillLeave)}};t["default"]=c,e.exports=t["default"]},function(e){"use strict";var t=function(e){var t,n={};if(!(e instanceof Object)||Array.isArray(e))throw new Error("keyMirror(...): Argument must be an object.");for(t in e)e.hasOwnProperty(t)&&(n[t]=t);return n};e.exports=t},function(e,t,n){e.exports=n(24)},function(e,t,n){var r=n(26),o=n(25);e.exports={stringify:r,parse:o}},function(e,t,n){var r=n(9),o={delimiter:"&",depth:5,arrayLimit:20,parameterLimit:1e3};o.parseValues=function(e,t){for(var n={},o=e.split(t.delimiter,1/0===t.parameterLimit?void 0:t.parameterLimit),i=0,a=o.length;a>i;++i){var u=o[i],s=-1===u.indexOf("]=")?u.indexOf("="):u.indexOf("]=")+1;if(-1===s)n[r.decode(u)]="";else{var c=r.decode(u.slice(0,s)),l=r.decode(u.slice(s+1));if(Object.prototype.hasOwnProperty(c))continue;n[c]=n.hasOwnProperty(c)?[].concat(n[c]).concat(l):l}}return n},o.parseObject=function(e,t,n){if(!e.length)return t;var r=e.shift(),i={};if("[]"===r)i=[],i=i.concat(o.parseObject(e,t,n));else{var a="["===r[0]&&"]"===r[r.length-1]?r.slice(1,r.length-1):r,u=parseInt(a,10),s=""+u;!isNaN(u)&&r!==a&&s===a&&u>=0&&u<=n.arrayLimit?(i=[],i[u]=o.parseObject(e,t,n)):i[a]=o.parseObject(e,t,n)}return i},o.parseKeys=function(e,t,n){if(e){var r=/^([^\[\]]*)/,i=/(\[[^\[\]]*\])/g,a=r.exec(e);if(!Object.prototype.hasOwnProperty(a[1])){var u=[];a[1]&&u.push(a[1]);for(var s=0;null!==(a=i.exec(e))&&s<n.depth;)++s,Object.prototype.hasOwnProperty(a[1].replace(/\[|\]/g,""))||u.push(a[1]);return a&&u.push("["+e.slice(a.index)+"]"),o.parseObject(u,t,n)}}},e.exports=function(e,t){if(""===e||null===e||"undefined"==typeof e)return{};t=t||{},t.delimiter="string"==typeof t.delimiter||r.isRegExp(t.delimiter)?t.delimiter:o.delimiter,t.depth="number"==typeof t.depth?t.depth:o.depth,t.arrayLimit="number"==typeof t.arrayLimit?t.arrayLimit:o.arrayLimit,t.parameterLimit="number"==typeof t.parameterLimit?t.parameterLimit:o.parameterLimit;for(var n="string"==typeof e?o.parseValues(e,t):e,i={},a=Object.keys(n),u=0,s=a.length;s>u;++u){var c=a[u],l=o.parseKeys(c,n[c],t);i=r.merge(i,l)}return r.compact(i)}},function(e,t,n){var r=n(9),o={delimiter:"&",arrayPrefixGenerators:{brackets:function(e){return e+"[]"},indices:function(e,t){return e+"["+t+"]"},repeat:function(e){return e}}};o.stringify=function(e,t,n){if(r.isBuffer(e)?e=e.toString():e instanceof Date?e=e.toISOString():null===e&&(e=""),"string"==typeof e||"number"==typeof e||"boolean"==typeof e)return[encodeURIComponent(t)+"="+encodeURIComponent(e)];var i=[];if("undefined"==typeof e)return i;for(var a=Object.keys(e),u=0,s=a.length;s>u;++u){var c=a[u];i=i.concat(Array.isArray(e)?o.stringify(e[c],n(t,c),n):o.stringify(e[c],t+"["+c+"]",n))}return i},e.exports=function(e,t){t=t||{};var n="undefined"==typeof t.delimiter?o.delimiter:t.delimiter,r=[];if("object"!=typeof e||null===e)return"";var i;i=t.arrayFormat in o.arrayPrefixGenerators?t.arrayFormat:"indices"in t?t.indices?"indices":"repeat":"indices";for(var a=o.arrayPrefixGenerators[i],u=Object.keys(e),s=0,c=u.length;c>s;++s){var l=u[s];r=r.concat(o.stringify(e[l],l,a))}return r.join(n)}}])});
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?exports.ReactRouter=t(require("react")):e.ReactRouter=t(e.React)}(this,function(e){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(17),i=r(o);t.Router=i["default"];var a=n(13),u=r(a);t.Link=u["default"];var s=n(15),c=r(s);t.Redirect=c["default"];var l=n(16),f=r(l);t.Route=f["default"];var p=n(14),d=r(p);t.Navigation=d["default"];var h=n(23),y=r(h);t.TransitionHook=y["default"];var m=n(21),v=r(m);t.State=v["default"];var g=n(3);Object.defineProperty(t,"createRoutesFromReactChildren",{enumerable:!0,get:function(){return g.createRoutesFromReactChildren}});var b=n(4),P=r(b);t.PropTypes=P["default"];var R=r(o);t["default"]=R["default"]},function(t){t.exports=e},function(e){"use strict";var t=function(e,t,n,r,o,i,a,u){if(!e){var s;if(void 0===t)s=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var c=[n,r,o,i,a,u],l=0;s=new Error("Invariant Violation: "+t.replace(/%s/g,function(){return c[l++]}))}throw s.framesToPop=1,s}};e.exports=t},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e){return null==e||f.isValidElement(e)}function i(e){return o(e)||Array.isArray(e)&&e.every(o)}function a(e,t,n){e=e||"UnknownComponent";for(var r in t)if(t.hasOwnProperty(r)){var o=t[r](n,r,e);o instanceof Error&&h["default"](!1,o.message)}}function u(e){var t=e.type,n=l({},t.defaultProps,e.props);return t.propTypes&&a(t.displayName||t.name,t.propTypes,n),n.children&&(n.childRoutes=s(n.children),delete n.children),n}function s(e){var t=[];return p["default"].Children.forEach(e,function(e){f.isValidElement(e)&&t.push(e.type.createRouteFromReactElement?e.type.createRouteFromReactElement(e):u(e))}),t}function c(e){return i(e)?e=s(e):Array.isArray(e)||(e=[e]),e}Object.defineProperty(t,"__esModule",{value:!0});var l=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e};t.isReactChildren=i,t.createRouteFromReactElement=u,t.createRoutesFromReactChildren=s,t.createRoutes=c;var f=n(1),p=r(f),d=n(7),h=r(d)},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t,n){return e[t]?new Error("<"+n+'> should not have a "'+t+'" prop'):void 0}var i=n(1),a=r(i),u=n(5),s=r(u),c=n(12),l=r(c),f=a["default"].PropTypes,p=f.func,d=f.object,h=f.arrayOf,y=f.instanceOf,m=f.oneOfType,v=f.element,g=p,b=m([g,d]),P=y(l["default"]),R=y(s["default"]),O=m([d,v]),_=m([O,h(O)]);e.exports={falsy:o,component:g,components:b,history:P,location:R,route:O,routes:_}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=n(9),u=r(a),s=function(){function e(){var t=void 0===arguments[0]?"/":arguments[0],n=void 0===arguments[1]?null:arguments[1],r=void 0===arguments[2]?null:arguments[2],i=void 0===arguments[3]?u["default"].POP:arguments[3];o(this,e),this.pathname=t,this.query=n,this.state=r,this.navigationType=i}return i(e,null,[{key:"isLocation",value:function(t){return t instanceof e}}]),e}();t["default"]=s,e.exports=t["default"]},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e){return m["default"].stringify(e,{arrayFormat:"brackets"})}function i(e){return e.replace(g,"")}function a(e){var t=e.match(g);return t?t[1]:""}function u(e){return e?e.replace(/^\/+/,""):""}function s(e){return"string"==typeof e&&"/"===e.charAt(0)}function c(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function l(e){return c(e).replace(/\/+/g,"/+")}function f(e){for(var t,n="",r=[],o=[],i=0,a=/:([a-zA-Z_$][a-zA-Z0-9_$]*)|\*|\(|\)/g;t=a.exec(e);)t.index!==i&&(o.push(e.slice(i,t.index)),n+=l(e.slice(i,t.index))),t[1]?(n+="([^/?#]+)",r.push(t[1])):"*"===t[0]?(n+="(.*?)",r.push("splat")):"("===t[0]?n+="(?:":")"===t[0]&&(n+=")?"),o.push(t[0]),i=a.lastIndex;return i!==e.length&&(o.push(e.slice(i,e.length)),n+=l(e.slice(i,e.length))),{pattern:e,regexpSource:n,paramNames:r,tokens:o}}function p(e){return e in b||(b[e]=f(e)),b[e]}function d(e,t){var n=p(u(e)),r=n.regexpSource,o=n.paramNames,i=n.tokens;r+="/*";var a="*"!==i[i.length-1];a&&(r+="(.*?)");var s,c,l=t.match(new RegExp("^"+r+"$","i"));return null!=l&&(c=Array.prototype.slice.call(l,1),s=a?c.pop():t.replace(l[0],"")),{remainingPathname:s,paramNames:o,paramValues:c}}function h(e){return p(e).paramNames}Object.defineProperty(t,"__esModule",{value:!0}),t.stringifyQuery=o,t.getPathname=i,t.getQueryString=a,t.stripLeadingSlashes=u,t.isAbsolutePath=s,t.compilePattern=p,t.matchPattern=d,t.getParamNames=h;var y=n(25),m=r(y),v=m["default"].parse;t.parseQueryString=v;var g=/\?(.*)$/,b={}},function(e){"use strict";var t=!1,n=function(){};t&&(n=function(e,t,n){var r=arguments.length;n=new Array(r>2?r-2:0);for(var o=2;r>o;o++)n[o-2]=arguments[o];if(void 0===t)throw new Error("`warning(condition, format, ...args)` requires a warning message argument");if(t.length<10||/^[s\W]*$/.test(t))throw new Error("The warning format should be able to uniquely identify this warning. Please, use a more descriptive format than: "+t);if(!e){var i=0,a="Warning: "+t.replace(/%s/g,function(){n[i++]});"undefined"!=typeof console&&console.error(a);try{throw new Error(a)}catch(u){}}}),e.exports=n},function(e,t){"use strict";function n(e,t,n){function r(){a=!0,n.apply(this,arguments)}function o(){a||(e>i?(i+=1,t.call(this,i-1,o,r)):r.apply(this,arguments))}var i=0,a=!1;o()}function r(e,t,n){function r(e,t,r){a||(t?(a=!0,n(t)):(i[e]=r,a=++u===o,a&&n(null,i)))}var o=e.length,i=[];if(0===o)return n(null,i);var a=!1,u=0;e.forEach(function(e,n){t(e,n,function(e,t){r(n,e,t)})})}function o(e,t,n){var o=Object.keys(e);r(o,function(n,r,o){t(e[n],o)},function(e,t){if(e)n(e);else{var r=t.reduce(function(e,t,n){return e[o[n]]=t,e},{});n(null,r)}})}Object.defineProperty(t,"__esModule",{value:!0}),t.loopAsync=n,t.mapAsync=r,t.hashAsync=o},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(24),i=r(o),a=i["default"]({PUSH:null,REPLACE:null,POP:null});t["default"]=a,e.exports=t["default"]},function(e,t){t.arrayToObject=function(e){for(var t={},n=0,r=e.length;r>n;++n)"undefined"!=typeof e[n]&&(t[n]=e[n]);return t},t.merge=function(e,n){if(!n)return e;if("object"!=typeof n)return Array.isArray(e)?e.push(n):e[n]=!0,e;if("object"!=typeof e)return e=[e].concat(n);Array.isArray(e)&&!Array.isArray(n)&&(e=t.arrayToObject(e));for(var r=Object.keys(n),o=0,i=r.length;i>o;++o){var a=r[o],u=n[a];e[a]=e[a]?t.merge(e[a],u):u}return e},t.decode=function(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch(t){return e}},t.compact=function(e,n){if("object"!=typeof e||null===e)return e;n=n||[];var r=n.indexOf(e);if(-1!==r)return n[r];if(n.push(e),Array.isArray(e)){for(var o=[],i=0,a=e.length;a>i;++i)"undefined"!=typeof e[i]&&o.push(e[i]);return o}var u=Object.keys(e);for(i=0,a=u.length;a>i;++i){var s=u[i];e[s]=t.compact(e[s],n)}return e},t.isRegExp=function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},t.isBuffer=function(e){return null===e||"undefined"==typeof e?!1:!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))}},function(e,t){"use strict";function n(){return decodeURI(window.location.href.split("#")[1]||"")}function r(e){window.location.replace(window.location.pathname+window.location.search+"#"+e)}function o(){return decodeURI(window.location.pathname+window.location.search)}function i(){return{scrollX:window.pageXOffset||document.documentElement.scrollLeft,scrollY:window.pageYOffset||document.documentElement.scrollTop}}function a(e,t){window.scrollTo(e,t)}function u(){var e=navigator.userAgent;return-1===e.indexOf("Android 2.")&&-1===e.indexOf("Android 4.0")||-1===e.indexOf("Mobile Safari")||-1!==e.indexOf("Chrome")||-1!==e.indexOf("Windows Phone")?window.history&&"pushState"in window.history:!1}Object.defineProperty(t,"__esModule",{value:!0}),t.getHashPath=n,t.replaceHashPath=r,t.getWindowPath=o,t.getWindowScrollPosition=i,t.setWindowScrollPosition=a,t.supportsHistory=u;var s=!("undefined"==typeof window||!window.document||!window.document.createElement);t.canUseDOM=s},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(){return Math.random().toString(36).substr(2)}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),u=n(2),s=r(u),c=n(6),l=n(5),f=r(l),p=["pushState","replaceState","go"],d=function(){function e(){var t=void 0===arguments[0]?{}:arguments[0];o(this,e),p.forEach(function(e){s["default"]("function"==typeof this[e],'%s needs a "%s" method',this.constructor.name,e)},this),this.parseQueryString=t.parseQueryString||c.parseQueryString,this.changeListeners=[],this.location=null}return a(e,[{key:"_notifyChange",value:function(){for(var e=0,t=this.changeListeners.length;t>e;++e)this.changeListeners[e].call(this)}},{key:"addChangeListener",value:function(e){this.changeListeners.push(e)}},{key:"removeChangeListener",value:function(e){this.changeListeners=this.changeListeners.filter(function(t){return t!==e})}},{key:"back",value:function(){this.go(-1)}},{key:"forward",value:function(){this.go(1)}},{key:"_createState",value:function(e){return e=e||{},e.key||(e.key=i()),e}},{key:"createLocation",value:function(e,t,n){var r=c.getPathname(e),o=c.getQueryString(e),i=o?this.parseQueryString(o):null;return new f["default"](r,i,t,n)}}]),e}();t["default"]=d,e.exports=t["default"]},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e){return 0===e.button}function i(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}Object.defineProperty(t,"__esModule",{value:!0});var a=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},u=n(1),s=r(u),c=s["default"].PropTypes,l=c.object,f=c.string,p=c.func,d=s["default"].createClass({displayName:"Link",contextTypes:{router:l},propTypes:{activeStyle:l,activeClassName:f,to:f.isRequired,query:l,state:l,onClick:p},getDefaultProps:function(){return{className:"",activeClassName:"active",style:{}}},handleClick:function(e){var t,n=!0;this.props.onClick&&(t=this.props.onClick(e)),!i(e)&&o(e)&&((t===!1||e.defaultPrevented===!0)&&(n=!1),e.preventDefault(),n&&this.context.router.transitionTo(this.props.to,this.props.query,this.props.state))},render:function(){var e=this.context.router,t=this.props,n=t.to,r=t.query,o=a({},this.props,{href:e.makeHref(n,r),onClick:this.handleClick});return e&&e.isActive(n,r)&&(o.activeClassName&&(o.className+=" "+o.activeClassName),o.activeStyle&&a(o.style,o.activeStyle)),s["default"].createElement("a",o)}});t.Link=d,t["default"]=d},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(1),i=r(o),a=i["default"].PropTypes.object,u={contextTypes:{router:a.isRequired}},s=["makePath","makeHref","transitionTo","replaceWith","go","goBack","goForward"];s.forEach(function(e){u[e]=function(){var t=this.context.router;return t[e].apply(t,arguments)}}),t["default"]=u,e.exports=t["default"]},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(1),i=r(o),a=n(2),u=r(a),s=n(3),c=n(4),l=i["default"].PropTypes.string,f=i["default"].createClass({displayName:"Redirect",statics:{createRouteFromReactElement:function(e){var t=s.createRouteFromReactElement(e);return t.from&&(t.path=t.from),t.onEnter=function(e,n){n.replaceWith(t.to,e.query)},t}},propTypes:{from:l,to:l.isRequired,onEnter:c.falsy,children:c.falsy},render:function(){u["default"](!1,"<Redirect> elements are for router configuration only and should not be rendered")}});t.Redirect=f,t["default"]=f},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(1),i=r(o),a=n(2),u=r(a),s=n(3),c=n(4),l=i["default"].PropTypes,f=l.string,p=l.bool,d=l.func,h=i["default"].createClass({displayName:"Route",statics:{createRouteFromReactElement:function(e){var t=s.createRouteFromReactElement(e);return t.handler&&(warning(!1,"<Route handler> is deprecated, use <Route component> instead"),t.component=t.handler,delete t.handler),t}},propTypes:{path:f,ignoreScrollBehavior:p,handler:c.component,component:c.component,components:c.components,getComponents:d},render:function(){u["default"](!1,"<Route> elements are for router configuration only and should not be rendered")}});t.Route=h,t["default"]=h},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t,n,r,o){var i=new O["default"];h.getState(t,n,function(t,a){if(t||null==a||i.isCancelled)o(t,null,i);else{a.location=n;var u=h.getTransitionHooks(e,a);Array.isArray(r)&&u.unshift.apply(u,r),p.loopAsync(u.length,function(e,t,n){u[e](a,i,function(e){e||i.isCancelled?n(e):t()})},function(e){e||i.isCancelled?o(e,null,i):h.getComponents(a.branch,function(e,t){e||i.isCancelled?o(e,null,i):(a.components=t,o(null,a,i))})})}})}Object.defineProperty(t,"__esModule",{value:!0});var i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},a=n(1),u=r(a),s=n(7),c=r(s),l=n(2),f=r(l),p=n(8),d=n(3),h=n(19),y=n(4),m=n(18),v=r(m),g=n(20),b=r(g),P=n(5),R=n(22),O=r(R),_=u["default"].PropTypes,w=_.arrayOf,x=_.func,k=_.object,j=u["default"].createClass({displayName:"Router",mixins:[v["default"],b["default"]],statics:{run:function(e,t,n,r){"function"==typeof n&&(r=n,n=null),f["default"]("function"==typeof r,"Router.run needs a callback"),o(null,e,t,n,r)}},propTypes:{createElement:x.isRequired,onAbort:x,onError:x,onUpdate:x,history:y.history,routes:y.routes,children:y.routes,location:y.location,branch:y.routes,params:k,components:w(y.components)},getDefaultProps:function(){return{createElement:a.createElement}},getInitialState:function(){return{isTransitioning:!1,location:null,branch:null,params:null,components:null}},_updateState:function(e){var t=this;f["default"](P.isLocation(e),"A <Router> needs a valid Location");var n=this.transitionHooks;n&&(n=n.map(function(e){return h.createTransitionHook(e,t)})),this.setState({isTransitioning:!0}),o(this.state,this.routes,e,n,function(n,r,o){if(n)t.handleError(n);else if(o.isCancelled)if(o.redirectInfo){var i=o.redirectInfo,a=i.pathname,u=i.query,r=i.state;t.replaceWith(a,u,r)}else f["default"](t.state.location,"You may not abort the initial transition"),t.handleAbort(reason);else null==r?c["default"](!1,'Location "%s" did not match any routes',e.pathname):t.setState(r,t.props.onUpdate);t.setState({isTransitioning:!1})})},addTransitionHook:function(e){this.transitionHooks||(this.transitionHooks=[]),this.transitionHooks.push(e)},removeTransitionHook:function(e){this.transitionHooks&&(this.transitionHooks=this.transitionHooks.filter(function(t){return t!==e}))},handleAbort:function(e){this.props.onAbort?this.props.onAbort.call(this,e):(this._ignoreNextHistoryChange=!0,this.goBack())},handleError:function(e){if(!this.props.onError)throw e;this.props.onError.call(this,e)},handleHistoryChange:function(){this._ignoreNextHistoryChange?this._ignoreNextHistoryChange=!1:this._updateState(this.props.history.location)},componentWillMount:function(){var e=this.props,t=e.history,n=e.routes,r=e.children,o=e.location,i=e.branch,a=e.params,u=e.components;t?(f["default"](n||r,"Client-side <Router>s need routes. Try using <Router routes> or passing your routes as nested <Route> children"),this.routes=d.createRoutes(n||r),"function"==typeof t.setup&&t.setup(),t.addChangeListener&&t.addChangeListener(this.handleHistoryChange),this._updateState(t.location)):(f["default"](o&&i&&a&&u,"Server-side <Router>s need location, branch, params, and components props. Try using Router.run to get all the props you need"),this.setState({location:o,branch:i,params:a,components:u}))},componentWillReceiveProps:function(e){if(f["default"](this.props.history===e.history,"<Router history> may not be changed"),e.history){var t=this.props.routes||this.props.children,n=e.routes||e.children;t!==n&&(this.routes=d.createRoutes(n),e.history.location&&this._updateState(e.history.location))}},componentWillUnmount:function(){var e=this.props.history;e&&e.removeChangeListener&&e.removeChangeListener(this.handleHistoryChange)},_createElement:function(e,t){return"function"==typeof e?this.props.createElement(e,t):null},render:function(){var e=this,t=this.state,n=t.location,r=t.branch,o=t.params,u=t.components,s=t.isTransitioning,c=null;return u&&(c=u.reduceRight(function(t,u,c){if(null==u)return t;var l=r[c],f=h.getRouteParams(l,o),p={location:n,params:o,route:l,routeParams:f,isTransitioning:s};if(a.isValidElement(t)?p.children=t:t&&i(p,t),"object"==typeof u){var d={};for(var y in u)u.hasOwnProperty(y)&&(d[y]=e._createElement(u[y],p));return d}return e._createElement(u,p)},c)),f["default"](null===c||c===!1||a.isValidElement(c),"The root route must render a single element"),c}});t["default"]=j,e.exports=t["default"]},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){return 0===l.stripLeadingSlashes(t).indexOf(l.stripLeadingSlashes(e))?!0:!1}function i(e,t){if(null==t)return null==e;if(null==e)return!0;for(var n in e)if(e.hasOwnProperty(n)&&String(e[n])!==String(t[n]))return!1;return!0}Object.defineProperty(t,"__esModule",{value:!0});var a=n(1),u=r(a),s=n(2),c=r(s),l=n(6),f=u["default"].PropTypes,p=f.func,d=f.object,h={propTypes:{stringifyQuery:p.isRequired},getDefaultProps:function(){return{stringifyQuery:l.stringifyQuery}},childContextTypes:{router:d.isRequired},getChildContext:function(){return{router:this}},makePath:function(e,t){return t&&("string"!=typeof t&&(t=this.props.stringifyQuery(t)),""!==t)?e+"?"+t:e},makeHref:function(e,t){return this.makePath(e,t)},transitionTo:function(e,t){var n=void 0===arguments[2]?null:arguments[2],r=this.props.history;c["default"](r,"Router#transitionTo is client-side only (needs history)"),r.pushState(n,this.makePath(e,t))},replaceWith:function(e,t){var n=void 0===arguments[2]?null:arguments[2],r=this.props.history;c["default"](r,"Router#replaceWith is client-side only (needs history)"),r.replaceState(n,this.makePath(e,t))},go:function(e){var t=this.props.history;c["default"](t,"Router#go is client-side only (needs history)"),t.go(e)},goBack:function(){this.go(-1)},goForward:function(){this.go(1)},isActive:function(e,t){var n=this.state.location;return null==n?!1:o(e,n.pathname)&&i(t,n.query)}};t["default"]=h,e.exports=t["default"]},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e)){var n=[],r=!0,o=!1,i=void 0;try{for(var a,u=e[Symbol.iterator]();!(r=(a=u.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(s){o=!0,i=s}finally{try{!r&&u["return"]&&u["return"]()}finally{if(o)throw i}}return n}throw new TypeError("Invalid attempt to destructure non-iterable instance")}function i(e,t,n){e.childRoutes?n(null,e.childRoutes):e.getChildRoutes?e.getChildRoutes(t,n):n()}function a(e,t,n){e.indexRoute?n(null,e.indexRoute):e.getIndexRoute?e.getIndexRoute(n,t):n()}function u(e,t,n){return t.reduceRight(function(e,t,r){var o=n[r];return Array.isArray(e[t])?e[t].unshift(o):e[t]=t in e?[o,e[t]]:o,e},e)}function s(e,t){return u({},e,t)}function c(e,t,n,r){var o=O.matchPattern(e.path,t),c=o.remainingPathname,f=o.paramNames,p=o.paramValues,d=""===c;if(d&&e.path){var h=s(f,p),y=[e];a(e,n,function(e,t){e?r(e):(t&&y.push(t),r(null,{params:h,branch:y}))})}else null!=c?i(e,n,function(t,o){t?r(t):o?l(o,c,n,function(t,n){t?r(t):n?(u(n.params,f,p),n.branch.unshift(e),r(null,n)):r()}):r()}):r()}function l(e,t,n,r){e=R.createRoutes(e),_.loopAsync(e.length,function(r,o,i){c(e[r],t,n,function(e,t){e||t?i(e,t):o()})},r)}function f(e,t,n){l(e,O.stripLeadingSlashes(t.pathname),t.state,n)}function p(e,t,n){if(!e.path)return!1;var r=O.getParamNames(e.path);return r.some(function(e){return t.params[e]!==n.params[e]})}function d(e,t){var n,r,o=e&&e.branch,i=t.branch;return o?(n=o.filter(function(n){return-1===i.indexOf(n)||p(n,e,t)}),n.reverse(),r=i.filter(function(e){return-1===o.indexOf(e)||-1!==n.indexOf(e)})):(n=[],r=i),[n,r]}function h(e,t){return function(n,r,o){e.length>2?e.call(t,n,r,o):(e.call(t,n,r),o())}}function y(e,t){return e.reduce(function(e,n){return n[t]&&e.push(h(n[t],n)),e},[])}function m(e,t){var n=d(e,t),r=o(n,2),i=r[0],a=r[1],u=y(i,"onLeave");return u.push.apply(u,y(a,"onEnter")),u}function v(e,t){e.component||e.components?t(null,e.component||e.components):e.getComponents?e.getComponents(t):t()}function g(e,t){_.mapAsync(e,function(e,t,n){v(e,n)},t)}function b(e,t){var n={};if(!e.path)return n;var r=O.getParamNames(e.path);for(var o in t)t.hasOwnProperty(o)&&-1!==r.indexOf(o)&&(n[o]=t[o]);return n}Object.defineProperty(t,"__esModule",{value:!0}),t.getState=f,t.createTransitionHook=h,t.getTransitionHooks=m,t.getComponents=g,t.getRouteParams=b;var P=n(2),R=(r(P),n(3)),O=n(6),_=n(8)},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){return e.filter(function(e){return-1!==t.indexOf(e)})}function i(e,t){var n=e.location,r=e.branch,i=t.location,a=t.branch;if(n.pathname===i.pathname)return!1;var u=o(r,a);return u.some(function(e){return e.ignoreScrollBehavior})?!1:!0}function a(e,t,n){c.canUseDOM&&(e===f["default"].POP?c.setWindowScrollPosition(t,n):c.setWindowScrollPosition(0,0))}Object.defineProperty(t,"__esModule",{value:!0});var u=n(1),s=r(u),c=n(11),l=n(9),f=r(l),p=s["default"].PropTypes.func,d={propTypes:{shouldUpdateScrollPosition:p.isRequired,updateScrollPosition:p.isRequired},getDefaultProps:function(){return{shouldUpdateScrollPosition:i,updateScrollPosition:a}},componentDidUpdate:function(e,t){var n=this.state.location,r=n&&n.state;if(r&&this.props.shouldUpdateScrollPosition(this.state,t)){var o=r.scrollX,i=r.scrollY;null!=o&&null!=i&&this.props.updateScrollPosition(n.navigationType,o,i)}}};t["default"]=d,e.exports=t["default"]},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(1),i=r(o),a=i["default"].PropTypes.object,u={contextTypes:{router:a.isRequired}},s=["isActive"];s.forEach(function(e){u[e]=function(){var t=this.context.router;return t[e].apply(t,arguments)}}),t["default"]=u,e.exports=t["default"]},function(e,t){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=function(){function e(){n(this,e),this.isCancelled=!1,this.redirectInfo=null,this.abortReason=null}return r(e,[{key:"to",value:function(e,t,n){this.redirectInfo={pathname:e,query:t,state:n},this.isCancelled=!0}},{key:"abort",value:function(e){this.abortReason=e,this.isCancelled=!0}}]),e}();t["default"]=o,e.exports=t["default"]},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(1),i=r(o),a=n(7),u=r(a),s=i["default"].PropTypes.object,c={contextTypes:{router:s.isRequired},componentDidMount:function(){u["default"]("function"==typeof this.routerWillLeave,"Components that mixin TransitionHook should have a routerWillLeave method, check %s",this.constructor.displayName||this.constructor.name),this.routerWillLeave&&this.context.router.addTransitionHook(this.routerWillLeave)},componentWillUnmount:function(){this.routerWillLeave&&this.context.router.removeTransitionHook(this.routerWillLeave)}};t["default"]=c,e.exports=t["default"]},function(e){"use strict";var t=function(e){var t,n={};if(!(e instanceof Object)||Array.isArray(e))throw new Error("keyMirror(...): Argument must be an object.");for(t in e)e.hasOwnProperty(t)&&(n[t]=t);return n};e.exports=t},function(e,t,n){e.exports=n(26)},function(e,t,n){var r=n(28),o=n(27);e.exports={stringify:r,parse:o}},function(e,t,n){var r=n(10),o={delimiter:"&",depth:5,arrayLimit:20,parameterLimit:1e3};o.parseValues=function(e,t){for(var n={},o=e.split(t.delimiter,1/0===t.parameterLimit?void 0:t.parameterLimit),i=0,a=o.length;a>i;++i){var u=o[i],s=-1===u.indexOf("]=")?u.indexOf("="):u.indexOf("]=")+1;if(-1===s)n[r.decode(u)]="";else{var c=r.decode(u.slice(0,s)),l=r.decode(u.slice(s+1));if(Object.prototype.hasOwnProperty(c))continue;n[c]=n.hasOwnProperty(c)?[].concat(n[c]).concat(l):l}}return n},o.parseObject=function(e,t,n){if(!e.length)return t;var r=e.shift(),i={};if("[]"===r)i=[],i=i.concat(o.parseObject(e,t,n));else{var a="["===r[0]&&"]"===r[r.length-1]?r.slice(1,r.length-1):r,u=parseInt(a,10),s=""+u;!isNaN(u)&&r!==a&&s===a&&u>=0&&u<=n.arrayLimit?(i=[],i[u]=o.parseObject(e,t,n)):i[a]=o.parseObject(e,t,n)}return i},o.parseKeys=function(e,t,n){if(e){var r=/^([^\[\]]*)/,i=/(\[[^\[\]]*\])/g,a=r.exec(e);if(!Object.prototype.hasOwnProperty(a[1])){var u=[];a[1]&&u.push(a[1]);for(var s=0;null!==(a=i.exec(e))&&s<n.depth;)++s,Object.prototype.hasOwnProperty(a[1].replace(/\[|\]/g,""))||u.push(a[1]);return a&&u.push("["+e.slice(a.index)+"]"),o.parseObject(u,t,n)}}},e.exports=function(e,t){if(""===e||null===e||"undefined"==typeof e)return{};t=t||{},t.delimiter="string"==typeof t.delimiter||r.isRegExp(t.delimiter)?t.delimiter:o.delimiter,t.depth="number"==typeof t.depth?t.depth:o.depth,t.arrayLimit="number"==typeof t.arrayLimit?t.arrayLimit:o.arrayLimit,t.parameterLimit="number"==typeof t.parameterLimit?t.parameterLimit:o.parameterLimit;for(var n="string"==typeof e?o.parseValues(e,t):e,i={},a=Object.keys(n),u=0,s=a.length;s>u;++u){var c=a[u],l=o.parseKeys(c,n[c],t);i=r.merge(i,l)}return r.compact(i)}},function(e,t,n){var r=n(10),o={delimiter:"&",arrayPrefixGenerators:{brackets:function(e){return e+"[]"},indices:function(e,t){return e+"["+t+"]"},repeat:function(e){return e}}};o.stringify=function(e,t,n){if(r.isBuffer(e)?e=e.toString():e instanceof Date?e=e.toISOString():null===e&&(e=""),"string"==typeof e||"number"==typeof e||"boolean"==typeof e)return[encodeURIComponent(t)+"="+encodeURIComponent(e)];var i=[];if("undefined"==typeof e)return i;for(var a=Object.keys(e),u=0,s=a.length;s>u;++u){var c=a[u];i=i.concat(Array.isArray(e)?o.stringify(e[c],n(t,c),n):o.stringify(e[c],t+"["+c+"]",n))}return i},e.exports=function(e,t){t=t||{};var n="undefined"==typeof t.delimiter?o.delimiter:t.delimiter,r=[];if("object"!=typeof e||null===e)return"";var i;i=t.arrayFormat in o.arrayPrefixGenerators?t.arrayFormat:"indices"in t?t.indices?"indices":"repeat":"indices";for(var a=o.arrayPrefixGenerators[i],u=Object.keys(e),s=0,c=u.length;c>s;++s){var l=u[s];r=r.concat(o.stringify(e[l],l,a))}return r.join(n)}}])});

@@ -41,3 +41,3 @@ import DOMHistory from './DOMHistory';

this.location = this._createLocation(getWindowPath(), state, navigationType);
this.location = this.createLocation(getWindowPath(), state, navigationType);
}

@@ -90,3 +90,3 @@

window.history.pushState(state, '', path);
this.location = this._createLocation(path, state, NavigationTypes.PUSH);
this.location = this.createLocation(path, state, NavigationTypes.PUSH);
this._notifyChange();

@@ -104,3 +104,3 @@ } else {

window.history.replaceState(state, '', path);
this.location = this._createLocation(path, state, NavigationTypes.REPLACE);
this.location = this.createLocation(path, state, NavigationTypes.REPLACE);
this._notifyChange();

@@ -107,0 +107,0 @@ } else {

@@ -33,2 +33,6 @@ export var canUseDOM = !!(

export function setWindowScrollPosition(scrollX, scrollY) {
window.scrollTo(scrollX, scrollY);
}
/**

@@ -35,0 +39,0 @@ * taken from modernizr

@@ -85,3 +85,3 @@ import warning from 'warning';

var state = this.queryKey ? readState(path, this.queryKey) : null;
this.location = this._createLocation(path, state, navigationType);
this.location = this.createLocation(path, state, navigationType);
}

@@ -149,3 +149,3 @@

this.location = this._createLocation(path, state, NavigationTypes.PUSH);
this.location = this.createLocation(path, state, NavigationTypes.PUSH);

@@ -164,3 +164,3 @@ this._notifyChange();

this.location = this._createLocation(path, state, NavigationTypes.REPLACE);
this.location = this.createLocation(path, state, NavigationTypes.REPLACE);

@@ -167,0 +167,0 @@ this._notifyChange();

import invariant from 'invariant';
import { getPathname, getQueryString, parseQueryString, stringifyQuery } from './URLUtils';
import ChangeEmitter from './ChangeEmitter';
import { getPathname, getQueryString, parseQueryString } from './URLUtils';
import Location from './Location';
var RequiredSubclassMethods = [ 'pushState', 'replaceState', 'go' ];
var RequiredHistorySubclassMethods = [ 'pushState', 'replaceState', 'go' ];

@@ -21,12 +20,6 @@ function createRandomKey() {

*/
class History extends ChangeEmitter {
class History {
constructor(options={}) {
super();
this.parseQueryString = options.parseQueryString || parseQueryString;
this.stringifyQuery = options.stringifyQuery || stringifyQuery;
this.location = null;
RequiredSubclassMethods.forEach(function (method) {
RequiredHistorySubclassMethods.forEach(function (method) {
invariant(

@@ -38,4 +31,23 @@ typeof this[method] === 'function',

}, this);
this.parseQueryString = options.parseQueryString || parseQueryString;
this.changeListeners = [];
this.location = null;
}
_notifyChange() {
for (var i = 0, len = this.changeListeners.length; i < len; ++i)
this.changeListeners[i].call(this);
}
addChangeListener(listener) {
this.changeListeners.push(listener);
}
removeChangeListener(listener) {
this.changeListeners = this.changeListeners.filter(function (li) {
return li !== listener;
});
}
back() {

@@ -58,3 +70,3 @@ this.go(-1);

_createLocation(path, state, navigationType) {
createLocation(path, state, navigationType) {
var pathname = getPathname(path);

@@ -66,27 +78,4 @@ var queryString = getQueryString(path);

/**
* Returns a full URL path from the given pathname and query.
*/
makePath(pathname, query) {
if (query) {
if (typeof query !== 'string')
query = this.stringifyQuery(query);
if (query !== '')
return pathname + '?' + query;
}
return pathname;
}
/**
* Returns a string that may safely be used to link to the given
* pathname and query.
*/
makeHref(pathname, query) {
return this.makePath(pathname, query);
}
}
export default History;

@@ -20,3 +20,3 @@ import invariant from 'invariant';

*/
export class MemoryHistory extends History {
class MemoryHistory extends History {

@@ -51,3 +51,3 @@ constructor(entries, current) {

this.location = this._createLocation(
this.location = this.createLocation(
currentEntry.path,

@@ -64,3 +64,3 @@ currentEntry.state

this.entries = this.entries.slice(0, this.current).concat([{ state, path }]);
this.location = this._createLocation(path, state, NavigationTypes.PUSH);
this.location = this.createLocation(path, state, NavigationTypes.PUSH);

@@ -75,3 +75,3 @@ this._notifyChange();

this.entries[this.current] = { state, path };
this.location = this._createLocation(path, state, NavigationTypes.REPLACE);
this.location = this.createLocation(path, state, NavigationTypes.REPLACE);

@@ -94,3 +94,3 @@ this._notifyChange();

this.location = this._createLocation(
this.location = this.createLocation(
currentEntry.path,

@@ -97,0 +97,0 @@ currentEntry.state,

@@ -5,3 +5,3 @@ import React from 'react';

var { any, func, object, arrayOf, instanceOf, oneOfType, oneOf, element } = React.PropTypes;
var { func, object, arrayOf, instanceOf, oneOfType, element } = React.PropTypes;

@@ -17,4 +17,4 @@ function falsy(props, propName, componentName) {

var location = instanceOf(Location);
var route = any; //oneOf([object, element]);
var routes = any; //oneOf([route, arrayOf(route), object]);
var route = oneOfType([ object, element ]);
var routes = oneOfType([ route, arrayOf(route) ]);

@@ -21,0 +21,0 @@ module.exports = {

@@ -6,80 +6,73 @@ import React, { createElement, isValidElement } from 'react';

import { createRoutes } from './RouteUtils';
import { pathnameIsActive, queryIsActive } from './ActiveUtils';
import { getState, getTransitionHooks, createTransitionHook, getComponents, getRouteParams } from './RoutingUtils';
import { getState, getTransitionHooks, getComponents, getRouteParams, createTransitionHook } from './RoutingUtils';
import { routes, component, components, history, location } from './PropTypes';
import Location from './Location';
import RouterContextMixin from './RouterContextMixin';
import ScrollManagementMixin from './ScrollManagementMixin';
import { isLocation } from './Location';
import Transition from './Transition';
var { any, array, func, object, instanceOf } = React.PropTypes;
var { arrayOf, func, object } = React.PropTypes;
var ContextMixin = {
function runTransition(prevState, routes, location, hooks, callback) {
var transition = new Transition;
childContextTypes: {
router: object.isRequired
},
getState(routes, location, function (error, nextState) {
if (error || nextState == null || transition.isCancelled) {
callback(error, null, transition);
} else {
nextState.location = location;
getChildContext() {
return {
router: this
};
},
var transitionHooks = getTransitionHooks(prevState, nextState);
if (Array.isArray(hooks))
transitionHooks.unshift.apply(transitionHooks, hooks);
makePath(pathname, query) {
return this.props.history.makePath(pathname, query);
},
makeHref(pathname, query) {
return this.props.history.makeHref(pathname, query);
},
transitionTo(pathname, query, state=null) {
var { history } = this.props;
var path = this.makePath(pathname, query);
if (this.nextLocation) {
history.replaceState(state, path);
} else {
history.pushState(state, path);
loopAsync(transitionHooks.length, (index, next, done) => {
transitionHooks[index](nextState, transition, (error) => {
if (error || transition.isCancelled) {
done(error); // No need to continue.
} else {
next();
}
});
}, function (error) {
if (error || transition.isCancelled) {
callback(error, null, transition);
} else {
getComponents(nextState.branch, function (error, components) {
if (error || transition.isCancelled) {
callback(error, null, transition);
} else {
nextState.components = components;
callback(null, nextState, transition);
}
});
}
});
}
},
});
}
replaceWith(pathname, query, state=null) {
var { history } = this.props;
var path = this.makePath(pathname, query);
var Router = React.createClass({
history.replaceState(state, path);
},
mixins: [ RouterContextMixin, ScrollManagementMixin ],
go(n) {
this.props.history.go(n);
},
statics: {
goBack() {
this.go(-1);
},
/**
* Runs a transition to the given location using the given routes and
* transition hooks (optional) and calls callback(error, state, transition)
* when finished. This is primarily useful for server-side rendering.
*/
run(routes, location, transitionHooks, callback) {
if (typeof transitionHooks === 'function') {
callback = transitionHooks;
transitionHooks = null;
}
goForward() {
this.go(1);
},
isActive(pathname, query) {
var { location } = this.state;
invariant(
typeof callback === 'function',
'Router.run needs a callback'
);
if (location == null)
return false;
return pathnameIsActive(pathname, location.pathname) &&
queryIsActive(query, location.query);
}
};
export var Router = React.createClass({
mixins: [ ContextMixin ],
statics: {
match(routes, history, callback) {
// TODO: Mimic what we're doing in _updateState, but statically
// so we can get the right props for doing server-side rendering.
runTransition(null, routes, location, transitionHooks, callback);
}

@@ -90,14 +83,18 @@

propTypes: {
history: history.isRequired,
children: routes,
routes, // Alias for children
createElement: func.isRequired,
onError: func.isRequired,
onAbort: func,
onError: func,
onUpdate: func,
// For server-side rendering
location: any,
// Client-side
history,
routes,
// Routes may also be given as children (JSX)
children: routes,
// Server-side
location,
branch: routes,
params: object,
components
components: arrayOf(components)
},

@@ -107,7 +104,3 @@

return {
createElement,
onError: function (error) {
// Throw errors by default so we don't silently swallow them!
throw error; // This error probably originated in getChildRoutes or getComponents.
}
createElement
};

@@ -118,7 +111,7 @@ },

return {
isTransitioning: false,
location: null,
branch: null,
params: null,
components: null,
isTransitioning: false
components: null
};

@@ -129,95 +122,37 @@ },

invariant(
Location.isLocation(location),
isLocation(location),
'A <Router> needs a valid Location'
);
this.nextLocation = location;
var hooks = this.transitionHooks;
if (hooks)
hooks = hooks.map(hook => createTransitionHook(hook, this));
this.setState({ isTransitioning: true });
this._getState(this.routes, location, (error, state) => {
if (error || this.nextLocation !== location) {
this._finishTransition(error);
runTransition(this.state, this.routes, location, hooks, (error, state, transition) => {
if (error) {
this.handleError(error);
} else if (transition.isCancelled) {
if (transition.redirectInfo) {
var { pathname, query, state } = transition.redirectInfo;
this.replaceWith(pathname, query, state);
} else {
invariant(
this.state.location,
'You may not abort the initial transition'
);
this.handleAbort(reason);
}
} else if (state == null) {
warning(false, 'Location "%s" did not match any routes', location.pathname);
this._finishTransition();
} else {
state.location = location;
this.setState(state, this.props.onUpdate);
}
this._runTransitionHooks(state, (error) => {
if (error || this.nextLocation !== location) {
this._finishTransition(error);
} else {
this._getComponents(state, (error, components) => {
if (error || this.nextLocation !== location) {
this._finishTransition(error);
} else {
state.components = components;
this._finishTransition(null, state);
}
});
}
});
}
this.setState({ isTransitioning: false });
});
},
_finishTransition(error, state) {
this.setState({ isTransitioning: false });
this.nextLocation = null;
if (error) {
this.handleError(error);
} else if (state) {
this.setState(state, this.props.onUpdate);
this._alreadyUpdated = true;
}
},
_getState(routes, location, callback) {
var { branch, params } = this.props;
if (branch && params && query) {
callback(null, { branch, params });
} else {
getState(routes, location, callback);
}
},
_runTransitionHooks(nextState, callback) {
// Run component hooks before route hooks.
var hooks = this.transitionHooks.map(hook => createTransitionHook(hook, this));
hooks.push.apply(
hooks,
getTransitionHooks(this.state, nextState)
);
var nextLocation = this.nextLocation;
loopAsync(hooks.length, (index, next, done) => {
var hook = hooks[index];
hooks[index].call(this, nextState, this, (error) => {
if (error || this.nextLocation !== nextLocation) {
done.call(this, error); // No need to continue.
} else {
next.call(this);
}
});
}, callback);
},
_getComponents(nextState, callback) {
if (this.props.components) {
callback(null, this.props.components);
} else {
getComponents(nextState, callback);
}
},
_createElement(component, props) {
return typeof component === 'function' ? this.props.createElement(component, props) : null;
},
/**

@@ -228,2 +163,5 @@ * Adds a transition hook that runs before all route hooks in a

addTransitionHook(hook) {
if (!this.transitionHooks)
this.transitionHooks = [];
this.transitionHooks.push(hook);

@@ -236,25 +174,24 @@ },

removeTransitionHook(hook) {
this.transitionHooks = this.transitionHooks.filter(h => h !== hook);
if (this.transitionHooks)
this.transitionHooks = this.transitionHooks.filter(h => h !== hook);
},
/**
* Cancels the current transition, preventing any subsequent transition
* hooks from running and restoring the previous location.
*/
cancelTransition() {
invariant(
this.state.location,
'Router#cancelTransition: You may not cancel the initial transition'
);
if (this.nextLocation) {
this.nextLocation = null;
handleAbort(reason) {
if (this.props.onAbort) {
this.props.onAbort.call(this, reason);
} else {
// The best we can do here is goBack so the location state reverts
// to what it was. However, we also set a flag so that we know not
// to run through _updateState again.
// to run through _updateState again since state did not change.
this._ignoreNextHistoryChange = true;
this.goBack();
}
},
handleError(error) {
if (this.props.onError) {
this.props.onError.call(this, error);
} else {
warning(false, 'Router#cancelTransition: Router is not transitioning');
// Throw errors by default so we don't silently swallow them!
throw error; // This error probably originated in getChildRoutes or getComponents.
}

@@ -272,30 +209,30 @@ },

componentWillMount() {
var { history, routes, children } = this.props;
var { history, routes, children, location, branch, params, components } = this.props;
invariant(
routes || children,
'A <Router> needs some routes'
);
if (history) {
invariant(
routes || children,
'Client-side <Router>s need routes. Try using <Router routes> or ' +
'passing your routes as nested <Route> children'
);
this.routes = createRoutes(routes || children);
this.transitionHooks = [];
this.nextLocation = null;
this.routes = createRoutes(routes || children);
if (typeof history.setup === 'function')
history.setup();
if (typeof history.setup === 'function')
history.setup();
// We need to listen first in case we redirect immediately.
if (history.addChangeListener)
history.addChangeListener(this.handleHistoryChange);
// We need to listen first in case we redirect immediately.
if (history.addChangeListener)
history.addChangeListener(this.handleHistoryChange);
this._updateState(history.location);
},
this._updateState(history.location);
} else {
invariant(
location && branch && params && components,
'Server-side <Router>s need location, branch, params, and components ' +
'props. Try using Router.run to get all the props you need'
);
componentDidMount() {
// React doesn't fire the setState callback when we call setState
// synchronously within componentWillMount, so we need this. Note
// that we still only get one call to onUpdate, even if setState
// was called multiple times in componentWillMount.
if (this._alreadyUpdated && this.props.onUpdate)
this.props.onUpdate.call(this);
this.setState({ location, branch, params, components });
}
},

@@ -309,12 +246,14 @@

var currentRoutes = this.props.routes || this.props.children;
var nextRoutes = nextProps.routes || nextProps.children;
if (nextProps.history) {
var currentRoutes = this.props.routes || this.props.children;
var nextRoutes = nextProps.routes || nextProps.children;
if (currentRoutes !== nextRoutes) {
this.routes = createRoutes(nextRoutes);
if (currentRoutes !== nextRoutes) {
this.routes = createRoutes(nextRoutes);
// Call this here because _updateState
// uses this.routes to determine state.
if (nextProps.history.location)
this._updateState(nextProps.history.location);
// Call this here because _updateState
// uses this.routes to determine state.
if (nextProps.history.location)
this._updateState(nextProps.history.location);
}
}

@@ -326,6 +265,10 @@ },

if (history.removeChangeListener)
if (history && history.removeChangeListener)
history.removeChangeListener(this.handleHistoryChange);
},
_createElement(component, props) {
return typeof component === 'function' ? this.props.createElement(component, props) : null;
},
render() {

@@ -332,0 +275,0 @@ var { location, branch, params, components, isTransitioning } = this.state;

@@ -0,1 +1,2 @@

import invariant from 'invariant';
import { createRoutes } from './RouteUtils';

@@ -137,3 +138,3 @@ import { getParamNames, matchPattern, stripLeadingSlashes } from './URLUtils';

*/
export function computeDiff(prevState, nextState) {
function computeDiff(prevState, nextState) {
var fromRoutes = prevState && prevState.branch;

@@ -166,9 +167,9 @@ var toRoutes = nextState.branch;

export function createTransitionHook(fn, context) {
return function (nextState, router, callback) {
return function (nextState, transition, callback) {
if (fn.length > 2) {
fn.call(context, nextState, router, callback);
fn.call(context, nextState, transition, callback);
} else {
// Assume fn executes synchronously and
// automatically call the callback for them.
fn.call(context, nextState, router);
fn.call(context, nextState, transition);
callback();

@@ -193,4 +194,4 @@ }

*
* - route.onLeave(nextState, router[, callback ])
* - route.onEnter(nextState, router[, callback ])
* - route.onLeave(nextState, transition[, callback ])
* - route.onEnter(nextState, transition[, callback ])
*

@@ -227,8 +228,2 @@ * Transition hooks run in order from the leaf route in the branch

function getComponentsForRoutes(routes, callback) {
mapAsync(routes, function (route, index, callback) {
getComponentsForRoute(route, callback);
}, callback);
}
/**

@@ -241,4 +236,6 @@ * Asynchronously fetches all components needed for the given router

*/
export function getComponents(state, callback) {
getComponentsForRoutes(state.branch, callback);
export function getComponents(routes, callback) {
mapAsync(routes, function (route, index, callback) {
getComponentsForRoute(route, callback);
}, callback);
}

@@ -245,0 +242,0 @@

{
"name": "react-router",
"version": "1.0.0-alpha2",
"version": "1.0.0-beta1",
"description": "A complete routing library for React.js",

@@ -10,3 +10,3 @@ "main": "lib/index",

},
"homepage": "https://github.com/rackt/react-router/blob/latest/README.md",
"homepage": "https://rackt.github.io/react-router/",
"bugs": "https://github.com/rackt/react-router/issues",

@@ -13,0 +13,0 @@ "scripts": {

[![npm package](https://img.shields.io/npm/v/react-router.svg?style=flat-square)](https://www.npmjs.org/package/react-router)
[![build status](https://img.shields.io/travis/rackt/react-router/master.svg?style=flat-square)](https://travis-ci.org/rackt/react-router)
[![dependency status](https://img.shields.io/david/rackt/react-router.svg?style=flat-square)](https://david-dm.org/rackt/react-router)
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/rackt/react-router?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
[![Gitter](https://img.shields.io/badge/GITTER-join%20chat-1DCF73.svg?style=flat-square)](https://gitter.im/rackt/react-router?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)

@@ -124,3 +124,3 @@ <img src="https://rackt.github.io/react-router/img/vertical.png" width="300"/>

See more in the [overview guide](/docs/00 Guides/0 Overview.md) and [Advanced
See more in the [overview guide](/doc/00 Guides/0 Overview.md) and [Advanced
Usage](/doc/00 Guides/Advanced Usage.md)

@@ -127,0 +127,0 @@

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc