aboutsummaryrefslogtreecommitdiffstats
path: root/web/src/vendor/react-router/react-router.js
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2014-12-30 22:02:55 +1300
committerAldo Cortesi <aldo@nullcube.com>2014-12-30 22:02:55 +1300
commitb847faf37f53111ca6bd435e4374b3bbbe4a8c28 (patch)
tree7e10bf7a15d64d3c35c58217931c452f775155e3 /web/src/vendor/react-router/react-router.js
parentbc8687deb5f0f9273fc771e79b070f3b49e39fed (diff)
downloadmitmproxy-b847faf37f53111ca6bd435e4374b3bbbe4a8c28.tar.gz
mitmproxy-b847faf37f53111ca6bd435e4374b3bbbe4a8c28.tar.bz2
mitmproxy-b847faf37f53111ca6bd435e4374b3bbbe4a8c28.zip
Fix fonts, stylesheets, add much more flexible bootstrap over-rides.
Diffstat (limited to 'web/src/vendor/react-router/react-router.js')
-rw-r--r--web/src/vendor/react-router/react-router.js3774
1 files changed, 0 insertions, 3774 deletions
diff --git a/web/src/vendor/react-router/react-router.js b/web/src/vendor/react-router/react-router.js
deleted file mode 100644
index 683ab14e..00000000
--- a/web/src/vendor/react-router/react-router.js
+++ /dev/null
@@ -1,3774 +0,0 @@
-!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.ReactRouter=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
-/**
- * Actions that modify the URL.
- */
-var LocationActions = {
-
- /**
- * Indicates a new location is being pushed to the history stack.
- */
- PUSH: 'push',
-
- /**
- * Indicates the current location should be replaced.
- */
- REPLACE: 'replace',
-
- /**
- * Indicates the most recent entry should be removed from the history stack.
- */
- POP: 'pop'
-
-};
-
-module.exports = LocationActions;
-
-},{}],2:[function(_dereq_,module,exports){
-var LocationActions = _dereq_('../actions/LocationActions');
-
-/**
- * A scroll behavior that attempts to imitate the default behavior
- * of modern browsers.
- */
-var ImitateBrowserBehavior = {
-
- updateScrollPosition: function (position, actionType) {
- switch (actionType) {
- case LocationActions.PUSH:
- case LocationActions.REPLACE:
- window.scrollTo(0, 0);
- break;
- case LocationActions.POP:
- if (position) {
- window.scrollTo(position.x, position.y);
- } else {
- window.scrollTo(0, 0);
- }
- break;
- }
- }
-
-};
-
-module.exports = ImitateBrowserBehavior;
-
-},{"../actions/LocationActions":1}],3:[function(_dereq_,module,exports){
-/**
- * A scroll behavior that always scrolls to the top of the page
- * after a transition.
- */
-var ScrollToTopBehavior = {
-
- updateScrollPosition: function () {
- window.scrollTo(0, 0);
- }
-
-};
-
-module.exports = ScrollToTopBehavior;
-
-},{}],4:[function(_dereq_,module,exports){
-var React = (typeof window !== "undefined" ? window.React : typeof global !== "undefined" ? global.React : null);
-var FakeNode = _dereq_('../mixins/FakeNode');
-var PropTypes = _dereq_('../utils/PropTypes');
-
-/**
- * A <DefaultRoute> component is a special kind of <Route> that
- * renders when its parent matches but none of its siblings do.
- * Only one such route may be used at any given level in the
- * route hierarchy.
- */
-var DefaultRoute = React.createClass({
-
- displayName: 'DefaultRoute',
-
- mixins: [ FakeNode ],
-
- propTypes: {
- name: React.PropTypes.string,
- path: PropTypes.falsy,
- handler: React.PropTypes.func.isRequired
- }
-
-});
-
-module.exports = DefaultRoute;
-
-},{"../mixins/FakeNode":14,"../utils/PropTypes":23}],5:[function(_dereq_,module,exports){
-var React = (typeof window !== "undefined" ? window.React : typeof global !== "undefined" ? global.React : null);
-var classSet = _dereq_('react/lib/cx');
-var assign = _dereq_('react/lib/Object.assign');
-var Navigation = _dereq_('../mixins/Navigation');
-var State = _dereq_('../mixins/State');
-
-function isLeftClickEvent(event) {
- return event.button === 0;
-}
-
-function isModifiedEvent(event) {
- return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
-}
-
-/**
- * <Link> components are used to create an <a> element that links to a route.
- * When that route is active, the link gets an "active" class name (or the
- * value of its `activeClassName` prop).
- *
- * For example, assuming you have the following route:
- *
- * <Route name="showPost" path="/posts/:postID" handler={Post}/>
- *
- * You could use the following component to link to that route:
- *
- * <Link to="showPost" params={{ postID: "123" }} />
- *
- * In addition to params, links may pass along query string parameters
- * using the `query` prop.
- *
- * <Link to="showPost" params={{ postID: "123" }} query={{ show:true }}/>
- */
-var Link = React.createClass({
-
- displayName: 'Link',
-
- mixins: [ Navigation, State ],
-
- propTypes: {
- activeClassName: React.PropTypes.string.isRequired,
- to: React.PropTypes.string.isRequired,
- params: React.PropTypes.object,
- query: React.PropTypes.object,
- onClick: React.PropTypes.func
- },
-
- getDefaultProps: function () {
- return {
- activeClassName: 'active'
- };
- },
-
- handleClick: function (event) {
- var allowTransition = true;
- var clickResult;
-
- if (this.props.onClick)
- clickResult = this.props.onClick(event);
-
- if (isModifiedEvent(event) || !isLeftClickEvent(event))
- return;
-
- if (clickResult === false || event.defaultPrevented === true)
- allowTransition = false;
-
- event.preventDefault();
-
- if (allowTransition)
- this.transitionTo(this.props.to, this.props.params, this.props.query);
- },
-
- /**
- * Returns the value of the "href" attribute to use on the DOM element.
- */
- getHref: function () {
- return this.makeHref(this.props.to, this.props.params, this.props.query);
- },
-
- /**
- * Returns the value of the "class" attribute to use on the DOM element, which contains
- * the value of the activeClassName property when this <Link> is active.
- */
- getClassName: function () {
- var classNames = {};
-
- if (this.props.className)
- classNames[this.props.className] = true;
-
- if (this.isActive(this.props.to, this.props.params, this.props.query))
- classNames[this.props.activeClassName] = true;
-
- return classSet(classNames);
- },
-
- render: function () {
- var props = assign({}, this.props, {
- href: this.getHref(),
- className: this.getClassName(),
- onClick: this.handleClick
- });
-
- return React.DOM.a(props, this.props.children);
- }
-
-});
-
-module.exports = Link;
-
-},{"../mixins/Navigation":15,"../mixins/State":18,"react/lib/Object.assign":38,"react/lib/cx":39}],6:[function(_dereq_,module,exports){
-var React = (typeof window !== "undefined" ? window.React : typeof global !== "undefined" ? global.React : null);
-var FakeNode = _dereq_('../mixins/FakeNode');
-var PropTypes = _dereq_('../utils/PropTypes');
-
-/**
- * A <NotFoundRoute> is a special kind of <Route> that
- * renders when the beginning of its parent's path matches
- * but none of its siblings do, including any <DefaultRoute>.
- * Only one such route may be used at any given level in the
- * route hierarchy.
- */
-var NotFoundRoute = React.createClass({
-
- displayName: 'NotFoundRoute',
-
- mixins: [ FakeNode ],
-
- propTypes: {
- name: React.PropTypes.string,
- path: PropTypes.falsy,
- handler: React.PropTypes.func.isRequired
- }
-
-});
-
-module.exports = NotFoundRoute;
-
-},{"../mixins/FakeNode":14,"../utils/PropTypes":23}],7:[function(_dereq_,module,exports){
-var React = (typeof window !== "undefined" ? window.React : typeof global !== "undefined" ? global.React : null);
-var FakeNode = _dereq_('../mixins/FakeNode');
-var PropTypes = _dereq_('../utils/PropTypes');
-
-/**
- * A <Redirect> component is a special kind of <Route> that always
- * redirects to another route when it matches.
- */
-var Redirect = React.createClass({
-
- displayName: 'Redirect',
-
- mixins: [ FakeNode ],
-
- propTypes: {
- path: React.PropTypes.string,
- from: React.PropTypes.string, // Alias for path.
- to: React.PropTypes.string,
- handler: PropTypes.falsy
- }
-
-});
-
-module.exports = Redirect;
-
-},{"../mixins/FakeNode":14,"../utils/PropTypes":23}],8:[function(_dereq_,module,exports){
-var React = (typeof window !== "undefined" ? window.React : typeof global !== "undefined" ? global.React : null);
-var FakeNode = _dereq_('../mixins/FakeNode');
-
-/**
- * <Route> components specify components that are rendered to the page when the
- * URL matches a given pattern.
- *
- * Routes are arranged in a nested tree structure. When a new URL is requested,
- * the tree is searched depth-first to find a route whose path matches the URL.
- * When one is found, all routes in the tree that lead to it are considered
- * "active" and their components are rendered into the DOM, nested in the same
- * order as they are in the tree.
- *
- * The preferred way to configure a router is using JSX. The XML-like syntax is
- * a great way to visualize how routes are laid out in an application.
- *
- * var routes = [
- * <Route handler={App}>
- * <Route name="login" handler={Login}/>
- * <Route name="logout" handler={Logout}/>
- * <Route name="about" handler={About}/>
- * </Route>
- * ];
- *
- * Router.run(routes, function (Handler) {
- * React.render(<Handler/>, document.body);
- * });
- *
- * Handlers for Route components that contain children can render their active
- * child route using a <RouteHandler> element.
- *
- * var App = React.createClass({
- * render: function () {
- * return (
- * <div class="application">
- * <RouteHandler/>
- * </div>
- * );
- * }
- * });
- */
-var Route = React.createClass({
-
- displayName: 'Route',
-
- mixins: [ FakeNode ],
-
- propTypes: {
- name: React.PropTypes.string,
- path: React.PropTypes.string,
- handler: React.PropTypes.func.isRequired,
- ignoreScrollBehavior: React.PropTypes.bool
- }
-
-});
-
-module.exports = Route;
-
-},{"../mixins/FakeNode":14}],9:[function(_dereq_,module,exports){
-var React = (typeof window !== "undefined" ? window.React : typeof global !== "undefined" ? global.React : null);
-
-/**
- * A <RouteHandler> component renders the active child route handler
- * when routes are nested.
- */
-var RouteHandler = React.createClass({
-
- displayName: 'RouteHandler',
-
- getDefaultProps: function () {
- return {
- ref: '__routeHandler__'
- };
- },
-
- contextTypes: {
- getRouteAtDepth: React.PropTypes.func.isRequired,
- getRouteComponents: React.PropTypes.func.isRequired,
- routeHandlers: React.PropTypes.array.isRequired
- },
-
- childContextTypes: {
- routeHandlers: React.PropTypes.array.isRequired
- },
-
- getChildContext: function () {
- return {
- routeHandlers: this.context.routeHandlers.concat([ this ])
- };
- },
-
- getRouteDepth: function () {
- return this.context.routeHandlers.length - 1;
- },
-
- componentDidMount: function () {
- this._updateRouteComponent();
- },
-
- componentDidUpdate: function () {
- this._updateRouteComponent();
- },
-
- _updateRouteComponent: function () {
- var depth = this.getRouteDepth();
- var components = this.context.getRouteComponents();
- components[depth] = this.refs[this.props.ref];
- },
-
- render: function () {
- var route = this.context.getRouteAtDepth(this.getRouteDepth());
- return route ? React.createElement(route.handler, this.props) : null;
- }
-
-});
-
-module.exports = RouteHandler;
-
-},{}],10:[function(_dereq_,module,exports){
-exports.DefaultRoute = _dereq_('./components/DefaultRoute');
-exports.Link = _dereq_('./components/Link');
-exports.NotFoundRoute = _dereq_('./components/NotFoundRoute');
-exports.Redirect = _dereq_('./components/Redirect');
-exports.Route = _dereq_('./components/Route');
-exports.RouteHandler = _dereq_('./components/RouteHandler');
-
-exports.HashLocation = _dereq_('./locations/HashLocation');
-exports.HistoryLocation = _dereq_('./locations/HistoryLocation');
-exports.RefreshLocation = _dereq_('./locations/RefreshLocation');
-
-exports.ImitateBrowserBehavior = _dereq_('./behaviors/ImitateBrowserBehavior');
-exports.ScrollToTopBehavior = _dereq_('./behaviors/ScrollToTopBehavior');
-
-exports.Navigation = _dereq_('./mixins/Navigation');
-exports.State = _dereq_('./mixins/State');
-
-exports.create = _dereq_('./utils/createRouter');
-exports.run = _dereq_('./utils/runRouter');
-
-},{"./behaviors/ImitateBrowserBehavior":2,"./behaviors/ScrollToTopBehavior":3,"./components/DefaultRoute":4,"./components/Link":5,"./components/NotFoundRoute":6,"./components/Redirect":7,"./components/Route":8,"./components/RouteHandler":9,"./locations/HashLocation":11,"./locations/HistoryLocation":12,"./locations/RefreshLocation":13,"./mixins/Navigation":15,"./mixins/State":18,"./utils/createRouter":26,"./utils/runRouter":30}],11:[function(_dereq_,module,exports){
-var invariant = _dereq_('react/lib/invariant');
-var canUseDOM = _dereq_('react/lib/ExecutionEnvironment').canUseDOM;
-var LocationActions = _dereq_('../actions/LocationActions');
-var Path = _dereq_('../utils/Path');
-
-/**
- * Returns the current URL path from `window.location.hash`, including query string
- */
-function getHashPath() {
- invariant(
- canUseDOM,
- 'getHashPath needs a DOM'
- );
-
- return Path.decode(
- window.location.hash.substr(1)
- );
-}
-
-var _actionType;
-
-function ensureSlash() {
- var path = getHashPath();
-
- if (path.charAt(0) === '/')
- return true;
-
- HashLocation.replace('/' + path);
-
- return false;
-}
-
-var _changeListeners = [];
-
-function notifyChange(type) {
- var change = {
- path: getHashPath(),
- type: type
- };
-
- _changeListeners.forEach(function (listener) {
- listener(change);
- });
-}
-
-var _isListening = false;
-
-function onHashChange() {
- if (ensureSlash()) {
- // If we don't have an _actionType then all we know is the hash
- // changed. It was probably caused by the user clicking the Back
- // button, but may have also been the Forward button or manual
- // manipulation. So just guess 'pop'.
- notifyChange(_actionType || LocationActions.POP);
- _actionType = null;
- }
-}
-
-/**
- * A Location that uses `window.location.hash`.
- */
-var HashLocation = {
-
- addChangeListener: function (listener) {
- _changeListeners.push(listener);
-
- // Do this BEFORE listening for hashchange.
- ensureSlash();
-
- if (_isListening)
- return;
-
- if (window.addEventListener) {
- window.addEventListener('hashchange', onHashChange, false);
- } else {
- window.attachEvent('onhashchange', onHashChange);
- }
-
- _isListening = true;
- },
-
- push: function (path) {
- _actionType = LocationActions.PUSH;
- window.location.hash = Path.encode(path);
- },
-
- replace: function (path) {
- _actionType = LocationActions.REPLACE;
- window.location.replace(window.location.pathname + '#' + Path.encode(path));
- },
-
- pop: function () {
- _actionType = LocationActions.POP;
- window.history.back();
- },
-
- getCurrentPath: getHashPath,
-
- toString: function () {
- return '<HashLocation>';
- }
-
-};
-
-module.exports = HashLocation;
-
-},{"../actions/LocationActions":1,"../utils/Path":21,"react/lib/ExecutionEnvironment":37,"react/lib/invariant":41}],12:[function(_dereq_,module,exports){
-var invariant = _dereq_('react/lib/invariant');
-var canUseDOM = _dereq_('react/lib/ExecutionEnvironment').canUseDOM;
-var LocationActions = _dereq_('../actions/LocationActions');
-var Path = _dereq_('../utils/Path');
-
-/**
- * Returns the current URL path from `window.location`, including query string
- */
-function getWindowPath() {
- invariant(
- canUseDOM,
- 'getWindowPath needs a DOM'
- );
-
- return Path.decode(
- window.location.pathname + window.location.search
- );
-}
-
-var _changeListeners = [];
-
-function notifyChange(type) {
- var change = {
- path: getWindowPath(),
- type: type
- };
-
- _changeListeners.forEach(function (listener) {
- listener(change);
- });
-}
-
-var _isListening = false;
-
-function onPopState() {
- notifyChange(LocationActions.POP);
-}
-
-/**
- * A Location that uses HTML5 history.
- */
-var HistoryLocation = {
-
- addChangeListener: function (listener) {
- _changeListeners.push(listener);
-
- if (_isListening)
- return;
-
- if (window.addEventListener) {
- window.addEventListener('popstate', onPopState, false);
- } else {
- window.attachEvent('popstate', onPopState);
- }
-
- _isListening = true;
- },
-
- push: function (path) {
- window.history.pushState({ path: path }, '', Path.encode(path));
- notifyChange(LocationActions.PUSH);
- },
-
- replace: function (path) {
- window.history.replaceState({ path: path }, '', Path.encode(path));
- notifyChange(LocationActions.REPLACE);
- },
-
- pop: function () {
- window.history.back();
- },
-
- getCurrentPath: getWindowPath,
-
- toString: function () {
- return '<HistoryLocation>';
- }
-
-};
-
-module.exports = HistoryLocation;
-
-},{"../actions/LocationActions":1,"../utils/Path":21,"react/lib/ExecutionEnvironment":37,"react/lib/invariant":41}],13:[function(_dereq_,module,exports){
-var HistoryLocation = _dereq_('./HistoryLocation');
-var Path = _dereq_('../utils/Path');
-
-/**
- * A Location that uses full page refreshes. This is used as
- * the fallback for HistoryLocation in browsers that do not
- * support the HTML5 history API.
- */
-var RefreshLocation = {
-
- push: function (path) {
- window.location = Path.encode(path);
- },
-
- replace: function (path) {
- window.location.replace(Path.encode(path));
- },
-
- pop: function () {
- window.history.back();
- },
-
- getCurrentPath: HistoryLocation.getCurrentPath,
-
- toString: function () {
- return '<RefreshLocation>';
- }
-
-};
-
-module.exports = RefreshLocation;
-
-},{"../utils/Path":21,"./HistoryLocation":12}],14:[function(_dereq_,module,exports){
-var invariant = _dereq_('react/lib/invariant');
-
-var FakeNode = {
-
- render: function () {
- invariant(
- false,
- '%s elements should not be rendered',
- this.constructor.displayName
- );
- }
-
-};
-
-module.exports = FakeNode;
-
-},{"react/lib/invariant":41}],15:[function(_dereq_,module,exports){
-var React = (typeof window !== "undefined" ? window.React : typeof global !== "undefined" ? global.React : null);
-
-/**
- * A mixin for components that modify the URL.
- *
- * Example:
- *
- * var MyLink = React.createClass({
- * mixins: [ Router.Navigation ],
- * handleClick: function (event) {
- * event.preventDefault();
- * this.transitionTo('aRoute', { the: 'params' }, { the: 'query' });
- * },
- * render: function () {
- * return (
- * <a onClick={this.handleClick}>Click me!</a>
- * );
- * }
- * });
- */
-var Navigation = {
-
- contextTypes: {
- makePath: React.PropTypes.func.isRequired,
- makeHref: React.PropTypes.func.isRequired,
- transitionTo: React.PropTypes.func.isRequired,
- replaceWith: React.PropTypes.func.isRequired,
- goBack: React.PropTypes.func.isRequired
- },
-
- /**
- * Returns an absolute URL path created from the given route
- * name, URL parameters, and query values.
- */
- makePath: function (to, params, query) {
- return this.context.makePath(to, params, query);
- },
-
- /**
- * Returns a string that may safely be used as the href of a
- * link to the route with the given name.
- */
- makeHref: function (to, params, query) {
- return this.context.makeHref(to, params, query);
- },
-
- /**
- * Transitions to the URL specified in the arguments by pushing
- * a new URL onto the history stack.
- */
- transitionTo: function (to, params, query) {
- this.context.transitionTo(to, params, query);
- },
-
- /**
- * Transitions to the URL specified in the arguments by replacing
- * the current URL in the history stack.
- */
- replaceWith: function (to, params, query) {
- this.context.replaceWith(to, params, query);
- },
-
- /**
- * Transitions to the previous URL.
- */
- goBack: function () {
- this.context.goBack();
- }
-
-};
-
-module.exports = Navigation;
-
-},{}],16:[function(_dereq_,module,exports){
-var React = (typeof window !== "undefined" ? window.React : typeof global !== "undefined" ? global.React : null);
-
-/**
- * Provides the router with context for Router.Navigation.
- */
-var NavigationContext = {
-
- childContextTypes: {
- makePath: React.PropTypes.func.isRequired,
- makeHref: React.PropTypes.func.isRequired,
- transitionTo: React.PropTypes.func.isRequired,
- replaceWith: React.PropTypes.func.isRequired,
- goBack: React.PropTypes.func.isRequired
- },
-
- getChildContext: function () {
- return {
- makePath: this.constructor.makePath,
- makeHref: this.constructor.makeHref,
- transitionTo: this.constructor.transitionTo,
- replaceWith: this.constructor.replaceWith,
- goBack: this.constructor.goBack
- };
- }
-
-};
-
-module.exports = NavigationContext;
-
-},{}],17:[function(_dereq_,module,exports){
-var invariant = _dereq_('react/lib/invariant');
-var canUseDOM = _dereq_('react/lib/ExecutionEnvironment').canUseDOM;
-var getWindowScrollPosition = _dereq_('../utils/getWindowScrollPosition');
-
-function shouldUpdateScroll(state, prevState) {
- if (!prevState)
- return true;
-
- // Don't update scroll position when only the query has changed.
- if (state.pathname === prevState.pathname)
- return false;
-
- var routes = state.routes;
- var prevRoutes = prevState.routes;
-
- var sharedAncestorRoutes = routes.filter(function (route) {
- return prevRoutes.indexOf(route) !== -1;
- });
-
- return !sharedAncestorRoutes.some(function (route) {
- return route.ignoreScrollBehavior;
- });
-}
-
-/**
- * Provides the router with the ability to manage window scroll position
- * according to its scroll behavior.
- */
-var Scrolling = {
-
- statics: {
- /**
- * Records curent scroll position as the last known position for the given URL path.
- */
- recordScrollPosition: function (path) {
- if (!this.scrollHistory)
- this.scrollHistory = {};
-
- this.scrollHistory[path] = getWindowScrollPosition();
- },
-
- /**
- * Returns the last known scroll position for the given URL path.
- */
- getScrollPosition: function (path) {
- if (!this.scrollHistory)
- this.scrollHistory = {};
-
- return this.scrollHistory[path] || null;
- }
- },
-
- componentWillMount: function () {
- invariant(
- this.getScrollBehavior() == null || canUseDOM,
- 'Cannot use scroll behavior without a DOM'
- );
- },
-
- componentDidMount: function () {
- this._updateScroll();
- },
-
- componentDidUpdate: function (prevProps, prevState) {
- this._updateScroll(prevState);
- },
-
- _updateScroll: function (prevState) {
- if (!shouldUpdateScroll(this.state, prevState))
- return;
-
- var scrollBehavior = this.getScrollBehavior();
-
- if (scrollBehavior)
- scrollBehavior.updateScrollPosition(
- this.constructor.getScrollPosition(this.state.path),
- this.state.action
- );
- }
-
-};
-
-module.exports = Scrolling;
-
-},{"../utils/getWindowScrollPosition":28,"react/lib/ExecutionEnvironment":37,"react/lib/invariant":41}],18:[function(_dereq_,module,exports){
-var React = (typeof window !== "undefined" ? window.React : typeof global !== "undefined" ? global.React : null);
-
-/**
- * A mixin for components that need to know the path, routes, URL
- * params and query that are currently active.
- *
- * Example:
- *
- * var AboutLink = React.createClass({
- * mixins: [ Router.State ],
- * render: function () {
- * var className = this.props.className;
- *
- * if (this.isActive('about'))
- * className += ' is-active';
- *
- * return React.DOM.a({ className: className }, this.props.children);
- * }
- * });
- */
-var State = {
-
- contextTypes: {
- getCurrentPath: React.PropTypes.func.isRequired,
- getCurrentRoutes: React.PropTypes.func.isRequired,
- getCurrentPathname: React.PropTypes.func.isRequired,
- getCurrentParams: React.PropTypes.func.isRequired,
- getCurrentQuery: React.PropTypes.func.isRequired,
- isActive: React.PropTypes.func.isRequired
- },
-
- /**
- * Returns the current URL path.
- */
- getPath: function () {
- return this.context.getCurrentPath();
- },
-
- /**
- * Returns an array of the routes that are currently active.
- */
- getRoutes: function () {
- return this.context.getCurrentRoutes();
- },
-
- /**
- * Returns the current URL path without the query string.
- */
- getPathname: function () {
- return this.context.getCurrentPathname();
- },
-
- /**
- * Returns an object of the URL params that are currently active.
- */
- getParams: function () {
- return this.context.getCurrentParams();
- },
-
- /**
- * Returns an object of the query params that are currently active.
- */
- getQuery: function () {
- return this.context.getCurrentQuery();
- },
-
- /**
- * A helper method to determine if a given route, params, and query
- * are active.
- */
- isActive: function (to, params, query) {
- return this.context.isActive(to, params, query);
- }
-
-};
-
-module.exports = State;
-
-},{}],19:[function(_dereq_,module,exports){
-var React = (typeof window !== "undefined" ? window.React : typeof global !== "undefined" ? global.React : null);
-var assign = _dereq_('react/lib/Object.assign');
-var Path = _dereq_('../utils/Path');
-
-function routeIsActive(activeRoutes, routeName) {
- return activeRoutes.some(function (route) {
- return route.name === routeName;
- });
-}
-
-function paramsAreActive(activeParams, params) {
- for (var property in params)
- if (String(activeParams[property]) !== String(params[property]))
- return false;
-
- return true;
-}
-
-function queryIsActive(activeQuery, query) {
- for (var property in query)
- if (String(activeQuery[property]) !== String(query[property]))
- return false;
-
- return true;
-}
-
-/**
- * Provides the router with context for Router.State.
- */
-var StateContext = {
-
- /**
- * Returns the current URL path + query string.
- */
- getCurrentPath: function () {
- return this.state.path;
- },
-
- /**
- * Returns a read-only array of the currently active routes.
- */
- getCurrentRoutes: function () {
- return this.state.routes.slice(0);
- },
-
- /**
- * Returns the current URL path without the query string.
- */
- getCurrentPathname: function () {
- return this.state.pathname;
- },
-
- /**
- * Returns a read-only object of the currently active URL parameters.
- */
- getCurrentParams: function () {
- return assign({}, this.state.params);
- },
-
- /**
- * Returns a read-only object of the currently active query parameters.
- */
- getCurrentQuery: function () {
- return assign({}, this.state.query);
- },
-
- /**
- * Returns true if the given route, params, and query are active.
- */
- isActive: function (to, params, query) {
- if (Path.isAbsolute(to))
- return to === this.state.path;
-
- return routeIsActive(this.state.routes, to) &&
- paramsAreActive(this.state.params, params) &&
- (query == null || queryIsActive(this.state.query, query));
- },
-
- childContextTypes: {
- getCurrentPath: React.PropTypes.func.isRequired,
- getCurrentRoutes: React.PropTypes.func.isRequired,
- getCurrentPathname: React.PropTypes.func.isRequired,
- getCurrentParams: React.PropTypes.func.isRequired,
- getCurrentQuery: React.PropTypes.func.isRequired,
- isActive: React.PropTypes.func.isRequired
- },
-
- getChildContext: function () {
- return {
- getCurrentPath: this.getCurrentPath,
- getCurrentRoutes: this.getCurrentRoutes,
- getCurrentPathname: this.getCurrentPathname,
- getCurrentParams: this.getCurrentParams,
- getCurrentQuery: this.getCurrentQuery,
- isActive: this.isActive
- };
- }
-
-};
-
-module.exports = StateContext;
-
-},{"../utils/Path":21,"react/lib/Object.assign":38}],20:[function(_dereq_,module,exports){
-/**
- * Represents a cancellation caused by navigating away
- * before the previous transition has fully resolved.
- */
-function Cancellation() { }
-
-module.exports = Cancellation;
-
-},{}],21:[function(_dereq_,module,exports){
-var invariant = _dereq_('react/lib/invariant');
-var merge = _dereq_('qs/lib/utils').merge;
-var qs = _dereq_('qs');
-
-var paramCompileMatcher = /:([a-zA-Z_$][a-zA-Z0-9_$]*)|[*.()\[\]\\+|{}^$]/g;
-var paramInjectMatcher = /:([a-zA-Z_$][a-zA-Z0-9_$?]*[?]?)|[*]/g;
-var paramInjectTrailingSlashMatcher = /\/\/\?|\/\?/g;
-var queryMatcher = /\?(.+)/;
-
-var _compiledPatterns = {};
-
-function compilePattern(pattern) {
- if (!(pattern in _compiledPatterns)) {
- var paramNames = [];
- var source = pattern.replace(paramCompileMatcher, function (match, paramName) {
- if (paramName) {
- paramNames.push(paramName);
- return '([^/?#]+)';
- } else if (match === '*') {
- paramNames.push('splat');
- return '(.*?)';
- } else {
- return '\\' + match;
- }
- });
-
- _compiledPatterns[pattern] = {
- matcher: new RegExp('^' + source + '$', 'i'),
- paramNames: paramNames
- };
- }
-
- return _compiledPatterns[pattern];
-}
-
-var Path = {
-
- /**
- * Safely decodes special characters in the given URL path.
- */
- decode: function (path) {
- return decodeURI(path.replace(/\+/g, ' '));
- },
-
- /**
- * Safely encodes special characters in the given URL path.
- */
- encode: function (path) {
- return encodeURI(path).replace(/%20/g, '+');
- },
-
- /**
- * Returns an array of the names of all parameters in the given pattern.
- */
- extractParamNames: function (pattern) {
- return compilePattern(pattern).paramNames;
- },
-
- /**
- * Extracts the portions of the given URL path that match the given pattern
- * and returns an object of param name => value pairs. Returns null if the
- * pattern does not match the given path.
- */
- extractParams: function (pattern, path) {
- var object = compilePattern(pattern);
- var match = path.match(object.matcher);
-
- if (!match)
- return null;
-
- var params = {};
-
- object.paramNames.forEach(function (paramName, index) {
- params[paramName] = match[index + 1];
- });
-
- return params;
- },
-
- /**
- * Returns a version of the given route path with params interpolated. Throws
- * if there is a dynamic segment of the route path for which there is no param.
- */
- injectParams: function (pattern, params) {
- params = params || {};
-
- var splatIndex = 0;
-
- return pattern.replace(paramInjectMatcher, function (match, paramName) {
- paramName = paramName || 'splat';
-
- // If param is optional don't check for existence
- if (paramName.slice(-1) !== '?') {
- invariant(
- params[paramName] != null,
- 'Missing "' + paramName + '" parameter for path "' + pattern + '"'
- );
- } else {
- paramName = paramName.slice(0, -1);
-
- if (params[paramName] == null)
- return '';
- }
-
- var segment;
- if (paramName === 'splat' && Array.isArray(params[paramName])) {
- segment = params[paramName][splatIndex++];
-
- invariant(
- segment != null,
- 'Missing splat # ' + splatIndex + ' for path "' + pattern + '"'
- );
- } else {
- segment = params[paramName];
- }
-
- return segment;
- }).replace(paramInjectTrailingSlashMatcher, '/');
- },
-
- /**
- * Returns an object that is the result of parsing any query string contained
- * in the given path, null if the path contains no query string.
- */
- extractQuery: function (path) {
- var match = path.match(queryMatcher);
- return match && qs.parse(match[1]);
- },
-
- /**
- * Returns a version of the given path without the query string.
- */
- withoutQuery: function (path) {
- return path.replace(queryMatcher, '');
- },
-
- /**
- * Returns a version of the given path with the parameters in the given
- * query merged into the query string.
- */
- withQuery: function (path, query) {
- var existingQuery = Path.extractQuery(path);
-
- if (existingQuery)
- query = query ? merge(existingQuery, query) : existingQuery;
-
- var queryString = query && qs.stringify(query);
-
- if (queryString)
- return Path.withoutQuery(path) + '?' + queryString;
-
- return path;
- },
-
- /**
- * Returns true if the given path is absolute.
- */
- isAbsolute: function (path) {
- return path.charAt(0) === '/';
- },
-
- /**
- * Returns a normalized version of the given path.
- */
- normalize: function (path, parentRoute) {
- return path.replace(/^\/*/, '/');
- },
-
- /**
- * Joins two URL paths together.
- */
- join: function (a, b) {
- return a.replace(/\/*$/, '/') + b;
- }
-
-};
-
-module.exports = Path;
-
-},{"qs":32,"qs/lib/utils":36,"react/lib/invariant":41}],22:[function(_dereq_,module,exports){
-var Promise = _dereq_('when/lib/Promise');
-
-// TODO: Use process.env.NODE_ENV check + envify to enable
-// when's promise monitor here when in dev.
-
-module.exports = Promise;
-
-},{"when/lib/Promise":43}],23:[function(_dereq_,module,exports){
-var PropTypes = {
-
- /**
- * Requires that the value of a prop be falsy.
- */
- falsy: function (props, propName, elementName) {
- if (props[propName])
- return new Error('<' + elementName + '> may not have a "' + propName + '" prop');
- }
-
-};
-
-module.exports = PropTypes;
-
-},{}],24:[function(_dereq_,module,exports){
-/**
- * Encapsulates a redirect to the given route.
- */
-function Redirect(to, params, query) {
- this.to = to;
- this.params = params;
- this.query = query;
-}
-
-module.exports = Redirect;
-
-},{}],25:[function(_dereq_,module,exports){
-var assign = _dereq_('react/lib/Object.assign');
-var reversedArray = _dereq_('./reversedArray');
-var Redirect = _dereq_('./Redirect');
-var Promise = _dereq_('./Promise');
-
-/**
- * Runs all hook functions serially and calls callback(error) when finished.
- * A hook may return a promise if it needs to execute asynchronously.
- */
-function runHooks(hooks, callback) {
- try {
- var promise = hooks.reduce(function (promise, hook) {
- // The first hook to use transition.wait makes the rest
- // of the transition async from that point forward.
- return promise ? promise.then(hook) : hook();
- }, null);
- } catch (error) {
- return callback(error); // Sync error.
- }
-
- if (promise) {
- // Use setTimeout to break the promise chain.
- promise.then(function () {
- setTimeout(callback);
- }, function (error) {
- setTimeout(function () {
- callback(error);
- });
- });
- } else {
- callback();
- }
-}
-
-/**
- * Calls the willTransitionFrom hook of all handlers in the given matches
- * serially in reverse with the transition object and the current instance of
- * the route's handler, so that the deepest nested handlers are called first.
- * Calls callback(error) when finished.
- */
-function runTransitionFromHooks(transition, routes, components, callback) {
- components = reversedArray(components);
-
- var hooks = reversedArray(routes).map(function (route, index) {
- return function () {
- var handler = route.handler;
-
- if (!transition.isAborted && handler.willTransitionFrom)
- return handler.willTransitionFrom(transition, components[index]);
-
- var promise = transition._promise;
- transition._promise = null;
-
- return promise;
- };
- });
-
- runHooks(hooks, callback);
-}
-
-/**
- * Calls the willTransitionTo hook of all handlers in the given matches
- * serially with the transition object and any params that apply to that
- * handler. Calls callback(error) when finished.
- */
-function runTransitionToHooks(transition, routes, params, query, callback) {
- var hooks = routes.map(function (route) {
- return function () {
- var handler = route.handler;
-
- if (!transition.isAborted && handler.willTransitionTo)
- handler.willTransitionTo(transition, params, query);
-
- var promise = transition._promise;
- transition._promise = null;
-
- return promise;
- };
- });
-
- runHooks(hooks, callback);
-}
-
-/**
- * Encapsulates a transition to a given path.
- *
- * The willTransitionTo and willTransitionFrom handlers receive
- * an instance of this class as their first argument.
- */
-function Transition(path, retry) {
- this.path = path;
- this.abortReason = null;
- this.isAborted = false;
- this.retry = retry.bind(this);
- this._promise = null;
-}
-
-assign(Transition.prototype, {
-
- abort: function (reason) {
- if (this.isAborted) {
- // First abort wins.
- return;
- }
-
- this.abortReason = reason;
- this.isAborted = true;
- },
-
- redirect: function (to, params, query) {
- this.abort(new Redirect(to, params, query));
- },
-
- wait: function (value) {
- this._promise = Promise.resolve(value);
- },
-
- from: function (routes, components, callback) {
- return runTransitionFromHooks(this, routes, components, callback);
- },
-
- to: function (routes, params, query, callback) {
- return runTransitionToHooks(this, routes, params, query, callback);
- }
-
-});
-
-module.exports = Transition;
-
-},{"./Promise":22,"./Redirect":24,"./reversedArray":29,"react/lib/Object.assign":38}],26:[function(_dereq_,module,exports){
-var React = (typeof window !== "undefined" ? window.React : typeof global !== "undefined" ? global.React : null);
-var warning = _dereq_('react/lib/warning');
-var invariant = _dereq_('react/lib/invariant');
-var canUseDOM = _dereq_('react/lib/ExecutionEnvironment').canUseDOM;
-var ImitateBrowserBehavior = _dereq_('../behaviors/ImitateBrowserBehavior');
-var RouteHandler = _dereq_('../components/RouteHandler');
-var LocationActions = _dereq_('../actions/LocationActions');
-var HashLocation = _dereq_('../locations/HashLocation');
-var HistoryLocation = _dereq_('../locations/HistoryLocation');
-var RefreshLocation = _dereq_('../locations/RefreshLocation');
-var NavigationContext = _dereq_('../mixins/NavigationContext');
-var StateContext = _dereq_('../mixins/StateContext');
-var Scrolling = _dereq_('../mixins/Scrolling');
-var createRoutesFromChildren = _dereq_('./createRoutesFromChildren');
-var supportsHistory = _dereq_('./supportsHistory');
-var Transition = _dereq_('./Transition');
-var PropTypes = _dereq_('./PropTypes');
-var Redirect = _dereq_('./Redirect');
-var Cancellation = _dereq_('./Cancellation');
-var Path = _dereq_('./Path');
-
-/**
- * The default location for new routers.
- */
-var DEFAULT_LOCATION = canUseDOM ? HashLocation : '/';
-
-/**
- * The default scroll behavior for new routers.
- */
-var DEFAULT_SCROLL_BEHAVIOR = canUseDOM ? ImitateBrowserBehavior : null;
-
-/**
- * The default error handler for new routers.
- */
-function defaultErrorHandler(error) {
- // Throw so we don't silently swallow async errors.
- throw error; // This error probably originated in a transition hook.
-}
-
-/**
- * The default aborted transition handler for new routers.
- */
-function defaultAbortHandler(abortReason, location) {
- if (typeof location === 'string')
- throw new Error('Unhandled aborted transition! Reason: ' + abortReason);
-
- if (abortReason instanceof Cancellation) {
- return;
- } else if (abortReason instanceof Redirect) {
- location.replace(this.makePath(abortReason.to, abortReason.params, abortReason.query));
- } else {
- location.pop();
- }
-}
-
-function findMatch(pathname, routes, defaultRoute, notFoundRoute) {
- var match, route, params;
-
- for (var i = 0, len = routes.length; i < len; ++i) {
- route = routes[i];
-
- // Check the subtree first to find the most deeply-nested match.
- match = findMatch(pathname, route.childRoutes, route.defaultRoute, route.notFoundRoute);
-
- if (match != null) {
- match.routes.unshift(route);
- return match;
- }
-
- // No routes in the subtree matched, so check this route.
- params = Path.extractParams(route.path, pathname);
-
- if (params)
- return createMatch(route, params);
- }
-
- // No routes matched, so try the default route if there is one.
- if (defaultRoute && (params = Path.extractParams(defaultRoute.path, pathname)))
- return createMatch(defaultRoute, params);
-
- // Last attempt: does the "not found" route match?
- if (notFoundRoute && (params = Path.extractParams(notFoundRoute.path, pathname)))
- return createMatch(notFoundRoute, params);
-
- return match;
-}
-
-function createMatch(route, params) {
- return { routes: [ route ], params: params };
-}
-
-function hasMatch(routes, route, prevParams, nextParams) {
- return routes.some(function (r) {
- if (r !== route)
- return false;
-
- var paramNames = route.paramNames;
- var paramName;
-
- for (var i = 0, len = paramNames.length; i < len; ++i) {
- paramName = paramNames[i];
-
- if (nextParams[paramName] !== prevParams[paramName])
- return false;
- }
-
- return true;
- });
-}
-
-/**
- * Creates and returns a new router using the given options. A router
- * is a ReactComponent class that knows how to react to changes in the
- * URL and keep the contents of the page in sync.
- *
- * Options may be any of the following:
- *
- * - routes (required) The route config
- * - location The location to use. Defaults to HashLocation when
- * the DOM is available, "/" otherwise
- * - scrollBehavior The scroll behavior to use. Defaults to ImitateBrowserBehavior
- * when the DOM is available, null otherwise
- * - onError A function that is used to handle errors
- * - onAbort A function that is used to handle aborted transitions
- *
- * When rendering in a server-side environment, the location should simply
- * be the URL path that was used in the request, including the query string.
- */
-function createRouter(options) {
- options = options || {};
-
- if (typeof options === 'function') {
- options = { routes: options }; // Router.create(<Route>)
- } else if (Array.isArray(options)) {
- options = { routes: options }; // Router.create([ <Route>, <Route> ])
- }
-
- var routes = [];
- var namedRoutes = {};
- var components = [];
- var location = options.location || DEFAULT_LOCATION;
- var scrollBehavior = options.scrollBehavior || DEFAULT_SCROLL_BEHAVIOR;
- var onError = options.onError || defaultErrorHandler;
- var onAbort = options.onAbort || defaultAbortHandler;
- var state = {};
- var nextState = {};
- var pendingTransition = null;
-
- function updateState() {
- state = nextState;
- nextState = {};
- }
-
- // Automatically fall back to full page refreshes in
- // browsers that don't support the HTML history API.
- if (location === HistoryLocation && !supportsHistory())
- location = RefreshLocation;
-
- var router = React.createClass({
-
- displayName: 'Router',
-
- mixins: [ NavigationContext, StateContext, Scrolling ],
-
- statics: {
-
- defaultRoute: null,
- notFoundRoute: null,
-
- /**
- * Adds routes to this router from the given children object (see ReactChildren).
- */
- addRoutes: function (children) {
- routes.push.apply(routes, createRoutesFromChildren(children, this, namedRoutes));
- },
-
- /**
- * Returns an absolute URL path created from the given route
- * name, URL parameters, and query.
- */
- makePath: function (to, params, query) {
- var path;
- if (Path.isAbsolute(to)) {
- path = Path.normalize(to);
- } else {
- var route = namedRoutes[to];
-
- invariant(
- route,
- 'Unable to find <Route name="%s">',
- to
- );
-
- path = route.path;
- }
-
- return Path.withQuery(Path.injectParams(path, params), query);
- },
-
- /**
- * Returns a string that may safely be used as the href of a link
- * to the route with the given name, URL parameters, and query.
- */
- makeHref: function (to, params, query) {
- var path = this.makePath(to, params, query);
- return (location === HashLocation) ? '#' + path : path;
- },
-
- /**
- * Transitions to the URL specified in the arguments by pushing
- * a new URL onto the history stack.
- */
- transitionTo: function (to, params, query) {
- invariant(
- typeof location !== 'string',
- 'You cannot use transitionTo with a static location'
- );
-
- var path = this.makePath(to, params, query);
-
- if (pendingTransition) {
- // Replace so pending location does not stay in history.
- location.replace(path);
- } else {
- location.push(path);
- }
- },
-
- /**
- * Transitions to the URL specified in the arguments by replacing
- * the current URL in the history stack.
- */
- replaceWith: function (to, params, query) {
- invariant(
- typeof location !== 'string',
- 'You cannot use replaceWith with a static location'
- );
-
- location.replace(this.makePath(to, params, query));
- },
-
- /**
- * Transitions to the previous URL.
- */
- goBack: function () {
- invariant(
- typeof location !== 'string',
- 'You cannot use goBack with a static location'
- );
-
- location.pop();
- },
-
- /**
- * Performs a match of the given pathname against this router and returns an object
- * with the { routes, params } that match. Returns null if no match can be made.
- */
- match: function (pathname) {
- return findMatch(pathname, routes, this.defaultRoute, this.notFoundRoute) || null;
- },
-
- /**
- * Performs a transition to the given path and calls callback(error, abortReason)
- * when the transition is finished. If both arguments are null the router's state
- * was updated. Otherwise the transition did not complete.
- *
- * In a transition, a router first determines which routes are involved by beginning
- * with the current route, up the route tree to the first parent route that is shared
- * with the destination route, and back down the tree to the destination route. The
- * willTransitionFrom hook is invoked on all route handlers we're transitioning away
- * from, in reverse nesting order. Likewise, the willTransitionTo hook is invoked on
- * all route handlers we're transitioning to.
- *
- * Both willTransitionFrom and willTransitionTo hooks may either abort or redirect the
- * transition. To resolve asynchronously, they may use transition.wait(promise). If no
- * hooks wait, the transition is fully synchronous.
- */
- dispatch: function (path, action, callback) {
- if (pendingTransition) {
- pendingTransition.abort(new Cancellation);
- pendingTransition = null;
- }
-
- var prevPath = state.path;
- if (prevPath === path)
- return; // Nothing to do!
-
- // Record the scroll position as early as possible to
- // get it before browsers try update it automatically.
- if (prevPath && action !== LocationActions.REPLACE)
- this.recordScrollPosition(prevPath);
-
- var pathname = Path.withoutQuery(path);
- var match = this.match(pathname);
-
- warning(
- match != null,
- 'No route matches path "%s". Make sure you have <Route path="%s"> somewhere in your routes',
- path, path
- );
-
- if (match == null)
- match = {};
-
- var prevRoutes = state.routes || [];
- var prevParams = state.params || {};
-
- var nextRoutes = match.routes || [];
- var nextParams = match.params || {};
- var nextQuery = Path.extractQuery(path) || {};
-
- var fromRoutes, toRoutes;
- if (prevRoutes.length) {
- fromRoutes = prevRoutes.filter(function (route) {
- return !hasMatch(nextRoutes, route, prevParams, nextParams);
- });
-
- toRoutes = nextRoutes.filter(function (route) {
- return !hasMatch(prevRoutes, route, prevParams, nextParams);
- });
- } else {
- fromRoutes = [];
- toRoutes = nextRoutes;
- }
-
- var transition = new Transition(path, this.replaceWith.bind(this, path));
- pendingTransition = transition;
-
- transition.from(fromRoutes, components, function (error) {
- if (error || transition.isAborted)
- return callback.call(router, error, transition);
-
- transition.to(toRoutes, nextParams, nextQuery, function (error) {
- if (error || transition.isAborted)
- return callback.call(router, error, transition);
-
- nextState.path = path;
- nextState.action = action;
- nextState.pathname = pathname;
- nextState.routes = nextRoutes;
- nextState.params = nextParams;
- nextState.query = nextQuery;
-
- callback.call(router, null, transition);
- });
- });
- },
-
- /**
- * Starts this router and calls callback(router, state) when the route changes.
- *
- * If the router's location is static (i.e. a URL path in a server environment)
- * the callback is called only once. Otherwise, the location should be one of the
- * Router.*Location objects (e.g. Router.HashLocation or Router.HistoryLocation).
- */
- run: function (callback) {
- function dispatchHandler(error, transition) {
- pendingTransition = null;
-
- if (error) {
- onError.call(router, error);
- } else if (transition.isAborted) {
- onAbort.call(router, transition.abortReason, location);
- } else {
- callback.call(router, router, nextState);
- }
- }
-
- if (typeof location === 'string') {
- warning(
- !canUseDOM || "production" === 'test',
- 'You should not use a static location in a DOM environment because ' +
- 'the router will not be kept in sync with the current URL'
- );
-
- // Dispatch the location.
- router.dispatch(location, null, dispatchHandler);
- } else {
- invariant(
- canUseDOM,
- 'You cannot use %s in a non-DOM environment',
- location
- );
-
- // Listen for changes to the location.
- function changeListener(change) {
- router.dispatch(change.path, change.type, dispatchHandler);
- }
-
- if (location.addChangeListener)
- location.addChangeListener(changeListener);
-
- // Bootstrap using the current path.
- router.dispatch(location.getCurrentPath(), null, dispatchHandler);
- }
- }
-
- },
-
- propTypes: {
- children: PropTypes.falsy
- },
-
- getLocation: function () {
- return location;
- },
-
- getScrollBehavior: function () {
- return scrollBehavior;
- },
-
- getRouteAtDepth: function (depth) {
- var routes = this.state.routes;
- return routes && routes[depth];
- },
-
- getRouteComponents: function () {
- return components;
- },
-
- getInitialState: function () {
- updateState();
- return state;
- },
-
- componentWillReceiveProps: function () {
- updateState();
- this.setState(state);
- },
-
- render: function () {
- return this.getRouteAtDepth(0) ? React.createElement(RouteHandler, this.props) : null;
- },
-
- childContextTypes: {
- getRouteAtDepth: React.PropTypes.func.isRequired,
- getRouteComponents: React.PropTypes.func.isRequired,
- routeHandlers: React.PropTypes.array.isRequired
- },
-
- getChildContext: function () {
- return {
- getRouteComponents: this.getRouteComponents,
- getRouteAtDepth: this.getRouteAtDepth,
- routeHandlers: [ this ]
- };
- }
-
- });
-
- if (options.routes)
- router.addRoutes(options.routes);
-
- return router;
-}
-
-module.exports = createRouter;
-
-},{"../actions/LocationActions":1,"../behaviors/ImitateBrowserBehavior":2,"../components/RouteHandler":9,"../locations/HashLocation":11,"../locations/HistoryLocation":12,"../locations/RefreshLocation":13,"../mixins/NavigationContext":16,"../mixins/Scrolling":17,"../mixins/StateContext":19,"./Cancellation":20,"./Path":21,"./PropTypes":23,"./Redirect":24,"./Transition":25,"./createRoutesFromChildren":27,"./supportsHistory":31,"react/lib/ExecutionEnvironment":37,"react/lib/invariant":41,"react/lib/warning":42}],27:[function(_dereq_,module,exports){
-var React = (typeof window !== "undefined" ? window.React : typeof global !== "undefined" ? global.React : null);
-var warning = _dereq_('react/lib/warning');
-var invariant = _dereq_('react/lib/invariant');
-var DefaultRoute = _dereq_('../components/DefaultRoute');
-var NotFoundRoute = _dereq_('../components/NotFoundRoute');
-var Redirect = _dereq_('../components/Redirect');
-var Route = _dereq_('../components/Route');
-var Path = _dereq_('./Path');
-
-var CONFIG_ELEMENT_TYPES = [
- DefaultRoute.type,
- NotFoundRoute.type,
- Redirect.type,
- Route.type
-];
-
-function createRedirectHandler(to, _params, _query) {
- return React.createClass({
- statics: {
- willTransitionTo: function (transition, params, query) {
- transition.redirect(to, _params || params, _query || query);
- }
- },
-
- render: function () {
- return null;
- }
- });
-}
-
-function checkPropTypes(componentName, propTypes, props) {
- for (var propName in propTypes) {
- if (propTypes.hasOwnProperty(propName)) {
- var error = propTypes[propName](props, propName, componentName);
-
- if (error instanceof Error)
- warning(false, error.message);
- }
- }
-}
-
-function createRoute(element, parentRoute, namedRoutes) {
- var type = element.type;
- var props = element.props;
- var componentName = (type && type.displayName) || 'UnknownComponent';
-
- invariant(
- CONFIG_ELEMENT_TYPES.indexOf(type) !== -1,
- 'Unrecognized route configuration element "<%s>"',
- componentName
- );
-
- if (type.propTypes)
- checkPropTypes(componentName, type.propTypes, props);
-
- var route = { name: props.name };
-
- if (props.ignoreScrollBehavior) {
- route.ignoreScrollBehavior = true;
- }
-
- if (type === Redirect.type) {
- route.handler = createRedirectHandler(props.to, props.params, props.query);
- props.path = props.path || props.from || '*';
- } else {
- route.handler = props.handler;
- }
-
- var parentPath = (parentRoute && parentRoute.path) || '/';
-
- if ((props.path || props.name) && type !== DefaultRoute.type && type !== NotFoundRoute.type) {
- var path = props.path || props.name;
-
- // Relative paths extend their parent.
- if (!Path.isAbsolute(path))
- path = Path.join(parentPath, path);
-
- route.path = Path.normalize(path);
- } else {
- route.path = parentPath;
-
- if (type === NotFoundRoute.type)
- route.path += '*';
- }
-
- route.paramNames = Path.extractParamNames(route.path);
-
- // Make sure the route's path has all params its parent needs.
- if (parentRoute && Array.isArray(parentRoute.paramNames)) {
- parentRoute.paramNames.forEach(function (paramName) {
- invariant(
- route.paramNames.indexOf(paramName) !== -1,
- 'The nested route path "%s" is missing the "%s" parameter of its parent path "%s"',
- route.path, paramName, parentRoute.path
- );
- });
- }
-
- // Make sure the route can be looked up by <Link>s.
- if (props.name) {
- invariant(
- namedRoutes[props.name] == null,
- 'You cannot use the name "%s" for more than one route',
- props.name
- );
-
- namedRoutes[props.name] = route;
- }
-
- // Handle <NotFoundRoute>.
- if (type === NotFoundRoute.type) {
- invariant(
- parentRoute,
- '<NotFoundRoute> must have a parent <Route>'
- );
-
- invariant(
- parentRoute.notFoundRoute == null,
- 'You may not have more than one <NotFoundRoute> per <Route>'
- );
-
- parentRoute.notFoundRoute = route;
-
- return null;
- }
-
- // Handle <DefaultRoute>.
- if (type === DefaultRoute.type) {
- invariant(
- parentRoute,
- '<DefaultRoute> must have a parent <Route>'
- );
-
- invariant(
- parentRoute.defaultRoute == null,
- 'You may not have more than one <DefaultRoute> per <Route>'
- );
-
- parentRoute.defaultRoute = route;
-
- return null;
- }
-
- route.childRoutes = createRoutesFromChildren(props.children, route, namedRoutes);
-
- return route;
-}
-
-/**
- * Creates and returns an array of route objects from the given ReactChildren.
- */
-function createRoutesFromChildren(children, parentRoute, namedRoutes) {
- var routes = [];
-
- React.Children.forEach(children, function (child) {
- // Exclude <DefaultRoute>s and <NotFoundRoute>s.
- if (child = createRoute(child, parentRoute, namedRoutes))
- routes.push(child);
- });
-
- return routes;
-}
-
-module.exports = createRoutesFromChildren;
-
-},{"../components/DefaultRoute":4,"../components/NotFoundRoute":6,"../components/Redirect":7,"../components/Route":8,"./Path":21,"react/lib/invariant":41,"react/lib/warning":42}],28:[function(_dereq_,module,exports){
-var invariant = _dereq_('react/lib/invariant');
-var canUseDOM = _dereq_('react/lib/ExecutionEnvironment').canUseDOM;
-
-/**
- * Returns the current scroll position of the window as { x, y }.
- */
-function getWindowScrollPosition() {
- invariant(
- canUseDOM,
- 'Cannot get current scroll position without a DOM'
- );
-
- return {
- x: window.scrollX,
- y: window.scrollY
- };
-}
-
-module.exports = getWindowScrollPosition;
-
-},{"react/lib/ExecutionEnvironment":37,"react/lib/invariant":41}],29:[function(_dereq_,module,exports){
-function reversedArray(array) {
- return array.slice(0).reverse();
-}
-
-module.exports = reversedArray;
-
-},{}],30:[function(_dereq_,module,exports){
-var createRouter = _dereq_('./createRouter');
-
-/**
- * A high-level convenience method that creates, configures, and
- * runs a router in one shot. The method signature is:
- *
- * Router.run(routes[, location ], callback);
- *
- * Using `window.location.hash` to manage the URL, you could do:
- *
- * Router.run(routes, function (Handler) {
- * React.render(<Handler/>, document.body);
- * });
- *
- * Using HTML5 history and a custom "cursor" prop:
- *
- * Router.run(routes, Router.HistoryLocation, function (Handler) {
- * React.render(<Handler cursor={cursor}/>, document.body);
- * });
- *
- * Returns the newly created router.
- *
- * Note: If you need to specify further options for your router such
- * as error/abort handling or custom scroll behavior, use Router.create
- * instead.
- *
- * var router = Router.create(options);
- * router.run(function (Handler) {
- * // ...
- * });
- */
-function runRouter(routes, location, callback) {
- if (typeof location === 'function') {
- callback = location;
- location = null;
- }
-
- var router = createRouter({
- routes: routes,
- location: location
- });
-
- router.run(callback);
-
- return router;
-}
-
-module.exports = runRouter;
-
-},{"./createRouter":26}],31:[function(_dereq_,module,exports){
-function supportsHistory() {
- /*! taken from modernizr
- * https://github.com/Modernizr/Modernizr/blob/master/LICENSE
- * https://github.com/Modernizr/Modernizr/blob/master/feature-detects/history.js
- */
- var ua = navigator.userAgent;
- if ((ua.indexOf('Android 2.') !== -1 ||
- (ua.indexOf('Android 4.0') !== -1)) &&
- ua.indexOf('Mobile Safari') !== -1 &&
- ua.indexOf('Chrome') === -1) {
- return false;
- }
- return (window.history && 'pushState' in window.history);
-}
-
-module.exports = supportsHistory;
-
-},{}],32:[function(_dereq_,module,exports){
-module.exports = _dereq_('./lib');
-
-},{"./lib":33}],33:[function(_dereq_,module,exports){
-// Load modules
-
-var Stringify = _dereq_('./stringify');
-var Parse = _dereq_('./parse');
-
-
-// Declare internals
-
-var internals = {};
-
-
-module.exports = {
- stringify: Stringify,
- parse: Parse
-};
-
-},{"./parse":34,"./stringify":35}],34:[function(_dereq_,module,exports){
-// Load modules
-
-var Utils = _dereq_('./utils');
-
-
-// Declare internals
-
-var internals = {
- delimiter: '&',
- depth: 5,
- arrayLimit: 20,
- parameterLimit: 1000
-};
-
-
-internals.parseValues = function (str, options) {
-
- var obj = {};
- var parts = str.split(options.delimiter, options.parameterLimit === Infinity ? undefined : options.parameterLimit);
-
- for (var i = 0, il = parts.length; i < il; ++i) {
- var part = parts[i];
- var pos = part.indexOf(']=') === -1 ? part.indexOf('=') : part.indexOf(']=') + 1;
-
- if (pos === -1) {
- obj[Utils.decode(part)] = '';
- }
- else {
- var key = Utils.decode(part.slice(0, pos));
- var val = Utils.decode(part.slice(pos + 1));
-
- if (!obj[key]) {
- obj[key] = val;
- }
- else {
- obj[key] = [].concat(obj[key]).concat(val);
- }
- }
- }
-
- return obj;
-};
-
-
-internals.parseObject = function (chain, val, options) {
-
- if (!chain.length) {
- return val;
- }
-
- var root = chain.shift();
-
- var obj = {};
- if (root === '[]') {
- obj = [];
- obj = obj.concat(internals.parseObject(chain, val, options));
- }
- else {
- var cleanRoot = root[0] === '[' && root[root.length - 1] === ']' ? root.slice(1, root.length - 1) : root;
- var index = parseInt(cleanRoot, 10);
- if (!isNaN(index) &&
- root !== cleanRoot &&
- index <= options.arrayLimit) {
-
- obj = [];
- obj[index] = internals.parseObject(chain, val, options);
- }
- else {
- obj[cleanRoot] = internals.parseObject(chain, val, options);
- }
- }
-
- return obj;
-};
-
-
-internals.parseKeys = function (key, val, options) {
-
- if (!key) {
- return;
- }
-
- // The regex chunks
-
- var parent = /^([^\[\]]*)/;
- var child = /(\[[^\[\]]*\])/g;
-
- // Get the parent
-
- var segment = parent.exec(key);
-
- // Don't allow them to overwrite object prototype properties
-
- if (Object.prototype.hasOwnProperty(segment[1])) {
- return;
- }
-
- // Stash the parent if it exists
-
- var keys = [];
- if (segment[1]) {
- keys.push(segment[1]);
- }
-
- // Loop through children appending to the array until we hit depth
-
- var i = 0;
- while ((segment = child.exec(key)) !== null && i < options.depth) {
-
- ++i;
- if (!Object.prototype.hasOwnProperty(segment[1].replace(/\[|\]/g, ''))) {
- keys.push(segment[1]);
- }
- }
-
- // If there's a remainder, just add whatever is left
-
- if (segment) {
- keys.push('[' + key.slice(segment.index) + ']');
- }
-
- return internals.parseObject(keys, val, options);
-};
-
-
-module.exports = function (str, options) {
-
- if (str === '' ||
- str === null ||
- typeof str === 'undefined') {
-
- return {};
- }
-
- options = options || {};
- options.delimiter = typeof options.delimiter === 'string' || Utils.isRegExp(options.delimiter) ? options.delimiter : internals.delimiter;
- options.depth = typeof options.depth === 'number' ? options.depth : internals.depth;
- options.arrayLimit = typeof options.arrayLimit === 'number' ? options.arrayLimit : internals.arrayLimit;
- options.parameterLimit = typeof options.parameterLimit === 'number' ? options.parameterLimit : internals.parameterLimit;
-
- var tempObj = typeof str === 'string' ? internals.parseValues(str, options) : str;
- var obj = {};
-
- // Iterate over the keys and setup the new object
-
- var keys = Object.keys(tempObj);
- for (var i = 0, il = keys.length; i < il; ++i) {
- var key = keys[i];
- var newObj = internals.parseKeys(key, tempObj[key], options);
- obj = Utils.merge(obj, newObj);
- }
-
- return Utils.compact(obj);
-};
-
-},{"./utils":36}],35:[function(_dereq_,module,exports){
-// Load modules
-
-var Utils = _dereq_('./utils');
-
-
-// Declare internals
-
-var internals = {
- delimiter: '&'
-};
-
-
-internals.stringify = function (obj, prefix) {
-
- if (Utils.isBuffer(obj)) {
- obj = obj.toString();
- }
- else if (obj instanceof Date) {
- obj = obj.toISOString();
- }
- else if (obj === null) {
- obj = '';
- }
-
- if (typeof obj === 'string' ||
- typeof obj === 'number' ||
- typeof obj === 'boolean') {
-
- return [encodeURIComponent(prefix) + '=' + encodeURIComponent(obj)];
- }
-
- var values = [];
-
- for (var key in obj) {
- if (obj.hasOwnProperty(key)) {
- values = values.concat(internals.stringify(obj[key], prefix + '[' + key + ']'));
- }
- }
-
- return values;
-};
-
-
-module.exports = function (obj, options) {
-
- options = options || {};
- var delimiter = typeof options.delimiter === 'undefined' ? internals.delimiter : options.delimiter;
-
- var keys = [];
-
- for (var key in obj) {
- if (obj.hasOwnProperty(key)) {
- keys = keys.concat(internals.stringify(obj[key], key));
- }
- }
-
- return keys.join(delimiter);
-};
-
-},{"./utils":36}],36:[function(_dereq_,module,exports){
-// Load modules
-
-
-// Declare internals
-
-var internals = {};
-
-
-exports.arrayToObject = function (source) {
-
- var obj = {};
- for (var i = 0, il = source.length; i < il; ++i) {
- if (typeof source[i] !== 'undefined') {
-
- obj[i] = source[i];
- }
- }
-
- return obj;
-};
-
-
-exports.merge = function (target, source) {
-
- if (!source) {
- return target;
- }
-
- if (Array.isArray(source)) {
- for (var i = 0, il = source.length; i < il; ++i) {
- if (typeof source[i] !== 'undefined') {
- if (typeof target[i] === 'object') {
- target[i] = exports.merge(target[i], source[i]);
- }
- else {
- target[i] = source[i];
- }
- }
- }
-
- return target;
- }
-
- if (Array.isArray(target)) {
- if (typeof source !== 'object') {
- target.push(source);
- return target;
- }
- else {
- target = exports.arrayToObject(target);
- }
- }
-
- var keys = Object.keys(source);
- for (var k = 0, kl = keys.length; k < kl; ++k) {
- var key = keys[k];
- var value = source[key];
-
- if (value &&
- typeof value === 'object') {
-
- if (!target[key]) {
- target[key] = value;
- }
- else {
- target[key] = exports.merge(target[key], value);
- }
- }
- else {
- target[key] = value;
- }
- }
-
- return target;
-};
-
-
-exports.decode = function (str) {
-
- try {
- return decodeURIComponent(str.replace(/\+/g, ' '));
- } catch (e) {
- return str;
- }
-};
-
-
-exports.compact = function (obj, refs) {
-
- if (typeof obj !== 'object' ||
- obj === null) {
-
- return obj;
- }
-
- refs = refs || [];
- var lookup = refs.indexOf(obj);
- if (lookup !== -1) {
- return refs[lookup];
- }
-
- refs.push(obj);
-
- if (Array.isArray(obj)) {
- var compacted = [];
-
- for (var i = 0, l = obj.length; i < l; ++i) {
- if (typeof obj[i] !== 'undefined') {
- compacted.push(obj[i]);
- }
- }
-
- return compacted;
- }
-
- var keys = Object.keys(obj);
- for (var i = 0, il = keys.length; i < il; ++i) {
- var key = keys[i];
- obj[key] = exports.compact(obj[key], refs);
- }
-
- return obj;
-};
-
-
-exports.isRegExp = function (obj) {
- return Object.prototype.toString.call(obj) === '[object RegExp]';
-};
-
-
-exports.isBuffer = function (obj) {
-
- if (typeof Buffer !== 'undefined') {
- return Buffer.isBuffer(obj);
- }
- else {
- return false;
- }
-};
-
-},{}],37:[function(_dereq_,module,exports){
-/**
- * Copyright 2013-2014, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @providesModule ExecutionEnvironment
- */
-
-/*jslint evil: true */
-
-"use strict";
-
-var canUseDOM = !!(
- typeof window !== 'undefined' &&
- window.document &&
- window.document.createElement
-);
-
-/**
- * Simple, lightweight module assisting with the detection and context of
- * Worker. Helps avoid circular dependencies and allows code to reason about
- * whether or not they are in a Worker, even if they never include the main
- * `ReactWorker` dependency.
- */
-var ExecutionEnvironment = {
-
- canUseDOM: canUseDOM,
-
- canUseWorkers: typeof Worker !== 'undefined',
-
- canUseEventListeners:
- canUseDOM && !!(window.addEventListener || window.attachEvent),
-
- canUseViewport: canUseDOM && !!window.screen,
-
- isInWorker: !canUseDOM // For now, this is true - might change in the future.
-
-};
-
-module.exports = ExecutionEnvironment;
-
-},{}],38:[function(_dereq_,module,exports){
-/**
- * Copyright 2014, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @providesModule Object.assign
- */
-
-// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.assign
-
-function assign(target, sources) {
- if (target == null) {
- throw new TypeError('Object.assign target cannot be null or undefined');
- }
-
- var to = Object(target);
- var hasOwnProperty = Object.prototype.hasOwnProperty;
-
- for (var nextIndex = 1; nextIndex < arguments.length; nextIndex++) {
- var nextSource = arguments[nextIndex];
- if (nextSource == null) {
- continue;
- }
-
- var from = Object(nextSource);
-
- // We don't currently support accessors nor proxies. Therefore this
- // copy cannot throw. If we ever supported this then we must handle
- // exceptions and side-effects. We don't support symbols so they won't
- // be transferred.
-
- for (var key in from) {
- if (hasOwnProperty.call(from, key)) {
- to[key] = from[key];
- }
- }
- }
-
- return to;
-};
-
-module.exports = assign;
-
-},{}],39:[function(_dereq_,module,exports){
-/**
- * Copyright 2013-2014, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @providesModule cx
- */
-
-/**
- * This function is used to mark string literals representing CSS class names
- * so that they can be transformed statically. This allows for modularization
- * and minification of CSS class names.
- *
- * In static_upstream, this function is actually implemented, but it should
- * eventually be replaced with something more descriptive, and the transform
- * that is used in the main stack should be ported for use elsewhere.
- *
- * @param string|object className to modularize, or an object of key/values.
- * In the object case, the values are conditions that
- * determine if the className keys should be included.
- * @param [string ...] Variable list of classNames in the string case.
- * @return string Renderable space-separated CSS className.
- */
-function cx(classNames) {
- if (typeof classNames == 'object') {
- return Object.keys(classNames).filter(function(className) {
- return classNames[className];
- }).join(' ');
- } else {
- return Array.prototype.join.call(arguments, ' ');
- }
-}
-
-module.exports = cx;
-
-},{}],40:[function(_dereq_,module,exports){
-/**
- * Copyright 2013-2014, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @providesModule emptyFunction
- */
-
-function makeEmptyFunction(arg) {
- return function() {
- return arg;
- };
-}
-
-/**
- * This function accepts and discards inputs; it has no side effects. This is
- * primarily useful idiomatically for overridable function endpoints which
- * always need to be callable, since JS lacks a null-call idiom ala Cocoa.
- */
-function emptyFunction() {}
-
-emptyFunction.thatReturns = makeEmptyFunction;
-emptyFunction.thatReturnsFalse = makeEmptyFunction(false);
-emptyFunction.thatReturnsTrue = makeEmptyFunction(true);
-emptyFunction.thatReturnsNull = makeEmptyFunction(null);
-emptyFunction.thatReturnsThis = function() { return this; };
-emptyFunction.thatReturnsArgument = function(arg) { return arg; };
-
-module.exports = emptyFunction;
-
-},{}],41:[function(_dereq_,module,exports){
-/**
- * Copyright 2013-2014, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @providesModule invariant
- */
-
-"use strict";
-
-/**
- * Use invariant() to assert state which your program assumes to be true.
- *
- * Provide sprintf-style format (only %s is supported) and arguments
- * to provide information about what broke and what you were
- * expecting.
- *
- * The invariant message will be stripped in production, but the invariant
- * will remain to ensure logic does not differ in production.
- */
-
-var invariant = function(condition, format, a, b, c, d, e, f) {
- if ("production" !== "production") {
- if (format === undefined) {
- throw new Error('invariant requires an error message argument');
- }
- }
-
- if (!condition) {
- var error;
- if (format === undefined) {
- error = new Error(
- 'Minified exception occurred; use the non-minified dev environment ' +
- 'for the full error message and additional helpful warnings.'
- );
- } else {
- var args = [a, b, c, d, e, f];
- var argIndex = 0;
- error = new Error(
- 'Invariant Violation: ' +
- format.replace(/%s/g, function() { return args[argIndex++]; })
- );
- }
-
- error.framesToPop = 1; // we don't care about invariant's own frame
- throw error;
- }
-};
-
-module.exports = invariant;
-
-},{}],42:[function(_dereq_,module,exports){
-/**
- * Copyright 2014, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @providesModule warning
- */
-
-"use strict";
-
-var emptyFunction = _dereq_("./emptyFunction");
-
-/**
- * Similar to invariant but only logs a warning if the condition is not met.
- * This can be used to log issues in development environments in critical
- * paths. Removing the logging code for production environments will keep the
- * same logic and follow the same code paths.
- */
-
-var warning = emptyFunction;
-
-if ("production" !== "production") {
- warning = function(condition, format ) {var args=Array.prototype.slice.call(arguments,2);
- if (format === undefined) {
- throw new Error(
- '`warning(condition, format, ...args)` requires a warning ' +
- 'message argument'
- );
- }
-
- if (!condition) {
- var argIndex = 0;
- console.warn('Warning: ' + format.replace(/%s/g, function() {return args[argIndex++];}));
- }
- };
-}
-
-module.exports = warning;
-
-},{"./emptyFunction":40}],43:[function(_dereq_,module,exports){
-/** @license MIT License (c) copyright 2010-2014 original author or authors */
-/** @author Brian Cavalier */
-/** @author John Hann */
-
-(function(define) { 'use strict';
-define(function (_dereq_) {
-
- var makePromise = _dereq_('./makePromise');
- var Scheduler = _dereq_('./Scheduler');
- var async = _dereq_('./async');
-
- return makePromise({
- scheduler: new Scheduler(async)
- });
-
-});
-})(typeof define === 'function' && define.amd ? define : function (factory) { module.exports = factory(_dereq_); });
-
-},{"./Scheduler":45,"./async":46,"./makePromise":47}],44:[function(_dereq_,module,exports){
-/** @license MIT License (c) copyright 2010-2014 original author or authors */
-/** @author Brian Cavalier */
-/** @author John Hann */
-
-(function(define) { 'use strict';
-define(function() {
- /**
- * Circular queue
- * @param {number} capacityPow2 power of 2 to which this queue's capacity
- * will be set initially. eg when capacityPow2 == 3, queue capacity
- * will be 8.
- * @constructor
- */
- function Queue(capacityPow2) {
- this.head = this.tail = this.length = 0;
- this.buffer = new Array(1 << capacityPow2);
- }
-
- Queue.prototype.push = function(x) {
- if(this.length === this.buffer.length) {
- this._ensureCapacity(this.length * 2);
- }
-
- this.buffer[this.tail] = x;
- this.tail = (this.tail + 1) & (this.buffer.length - 1);
- ++this.length;
- return this.length;
- };
-
- Queue.prototype.shift = function() {
- var x = this.buffer[this.head];
- this.buffer[this.head] = void 0;
- this.head = (this.head + 1) & (this.buffer.length - 1);
- --this.length;
- return x;
- };
-
- Queue.prototype._ensureCapacity = function(capacity) {
- var head = this.head;
- var buffer = this.buffer;
- var newBuffer = new Array(capacity);
- var i = 0;
- var len;
-
- if(head === 0) {
- len = this.length;
- for(; i<len; ++i) {
- newBuffer[i] = buffer[i];
- }
- } else {
- capacity = buffer.length;
- len = this.tail;
- for(; head<capacity; ++i, ++head) {
- newBuffer[i] = buffer[head];
- }
-
- for(head=0; head<len; ++i, ++head) {
- newBuffer[i] = buffer[head];
- }
- }
-
- this.buffer = newBuffer;
- this.head = 0;
- this.tail = this.length;
- };
-
- return Queue;
-
-});
-}(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
-
-},{}],45:[function(_dereq_,module,exports){
-/** @license MIT License (c) copyright 2010-2014 original author or authors */
-/** @author Brian Cavalier */
-/** @author John Hann */
-
-(function(define) { 'use strict';
-define(function(_dereq_) {
-
- var Queue = _dereq_('./Queue');
-
- // Credit to Twisol (https://github.com/Twisol) for suggesting
- // this type of extensible queue + trampoline approach for next-tick conflation.
-
- /**
- * Async task scheduler
- * @param {function} async function to schedule a single async function
- * @constructor
- */
- function Scheduler(async) {
- this._async = async;
- this._queue = new Queue(15);
- this._afterQueue = new Queue(5);
- this._running = false;
-
- var self = this;
- this.drain = function() {
- self._drain();
- };
- }
-
- /**
- * Enqueue a task
- * @param {{ run:function }} task
- */
- Scheduler.prototype.enqueue = function(task) {
- this._add(this._queue, task);
- };
-
- /**
- * Enqueue a task to run after the main task queue
- * @param {{ run:function }} task
- */
- Scheduler.prototype.afterQueue = function(task) {
- this._add(this._afterQueue, task);
- };
-
- /**
- * Drain the handler queue entirely, and then the after queue
- */
- Scheduler.prototype._drain = function() {
- runQueue(this._queue);
- this._running = false;
- runQueue(this._afterQueue);
- };
-
- /**
- * Add a task to the q, and schedule drain if not already scheduled
- * @param {Queue} queue
- * @param {{run:function}} task
- * @private
- */
- Scheduler.prototype._add = function(queue, task) {
- queue.push(task);
- if(!this._running) {
- this._running = true;
- this._async(this.drain);
- }
- };
-
- /**
- * Run all the tasks in the q
- * @param queue
- */
- function runQueue(queue) {
- while(queue.length > 0) {
- queue.shift().run();
- }
- }
-
- return Scheduler;
-
-});
-}(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(_dereq_); }));
-
-},{"./Queue":44}],46:[function(_dereq_,module,exports){
-/** @license MIT License (c) copyright 2010-2014 original author or authors */
-/** @author Brian Cavalier */
-/** @author John Hann */
-
-(function(define) { 'use strict';
-define(function(_dereq_) {
-
- // Sniff "best" async scheduling option
- // Prefer process.nextTick or MutationObserver, then check for
- // vertx and finally fall back to setTimeout
-
- /*jshint maxcomplexity:6*/
- /*global process,document,setTimeout,MutationObserver,WebKitMutationObserver*/
- var nextTick, MutationObs;
-
- if (typeof process !== 'undefined' && process !== null &&
- typeof process.nextTick === 'function') {
- nextTick = function(f) {
- process.nextTick(f);
- };
-
- } else if (MutationObs =
- (typeof MutationObserver === 'function' && MutationObserver) ||
- (typeof WebKitMutationObserver === 'function' && WebKitMutationObserver)) {
- nextTick = (function (document, MutationObserver) {
- var scheduled;
- var el = document.createElement('div');
- var o = new MutationObserver(run);
- o.observe(el, { attributes: true });
-
- function run() {
- var f = scheduled;
- scheduled = void 0;
- f();
- }
-
- return function (f) {
- scheduled = f;
- el.setAttribute('class', 'x');
- };
- }(document, MutationObs));
-
- } else {
- nextTick = (function(cjsRequire) {
- var vertx;
- try {
- // vert.x 1.x || 2.x
- vertx = cjsRequire('vertx');
- } catch (ignore) {}
-
- if (vertx) {
- if (typeof vertx.runOnLoop === 'function') {
- return vertx.runOnLoop;
- }
- if (typeof vertx.runOnContext === 'function') {
- return vertx.runOnContext;
- }
- }
-
- // capture setTimeout to avoid being caught by fake timers
- // used in time based tests
- var capturedSetTimeout = setTimeout;
- return function (t) {
- capturedSetTimeout(t, 0);
- };
- }(_dereq_));
- }
-
- return nextTick;
-});
-}(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(_dereq_); }));
-
-},{}],47:[function(_dereq_,module,exports){
-/** @license MIT License (c) copyright 2010-2014 original author or authors */
-/** @author Brian Cavalier */
-/** @author John Hann */
-
-(function(define) { 'use strict';
-define(function() {
-
- return function makePromise(environment) {
-
- var tasks = environment.scheduler;
-
- var objectCreate = Object.create ||
- function(proto) {
- function Child() {}
- Child.prototype = proto;
- return new Child();
- };
-
- /**
- * Create a promise whose fate is determined by resolver
- * @constructor
- * @returns {Promise} promise
- * @name Promise
- */
- function Promise(resolver, handler) {
- this._handler = resolver === Handler ? handler : init(resolver);
- }
-
- /**
- * Run the supplied resolver
- * @param resolver
- * @returns {Pending}
- */
- function init(resolver) {
- var handler = new Pending();
-
- try {
- resolver(promiseResolve, promiseReject, promiseNotify);
- } catch (e) {
- promiseReject(e);
- }
-
- return handler;
-
- /**
- * Transition from pre-resolution state to post-resolution state, notifying
- * all listeners of the ultimate fulfillment or rejection
- * @param {*} x resolution value
- */
- function promiseResolve (x) {
- handler.resolve(x);
- }
- /**
- * Reject this promise with reason, which will be used verbatim
- * @param {Error|*} reason rejection reason, strongly suggested
- * to be an Error type
- */
- function promiseReject (reason) {
- handler.reject(reason);
- }
-
- /**
- * Issue a progress event, notifying all progress listeners
- * @param {*} x progress event payload to pass to all listeners
- */
- function promiseNotify (x) {
- handler.notify(x);
- }
- }
-
- // Creation
-
- Promise.resolve = resolve;
- Promise.reject = reject;
- Promise.never = never;
-
- Promise._defer = defer;
- Promise._handler = getHandler;
-
- /**
- * Returns a trusted promise. If x is already a trusted promise, it is
- * returned, otherwise returns a new trusted Promise which follows x.
- * @param {*} x
- * @return {Promise} promise
- */
- function resolve(x) {
- return isPromise(x) ? x
- : new Promise(Handler, new Async(getHandler(x)));
- }
-
- /**
- * Return a reject promise with x as its reason (x is used verbatim)
- * @param {*} x
- * @returns {Promise} rejected promise
- */
- function reject(x) {
- return new Promise(Handler, new Async(new Rejected(x)));
- }
-
- /**
- * Return a promise that remains pending forever
- * @returns {Promise} forever-pending promise.
- */
- function never() {
- return foreverPendingPromise; // Should be frozen
- }
-
- /**
- * Creates an internal {promise, resolver} pair
- * @private
- * @returns {Promise}
- */
- function defer() {
- return new Promise(Handler, new Pending());
- }
-
- // Transformation and flow control
-
- /**
- * Transform this promise's fulfillment value, returning a new Promise
- * for the transformed result. If the promise cannot be fulfilled, onRejected
- * is called with the reason. onProgress *may* be called with updates toward
- * this promise's fulfillment.
- * @param {function=} onFulfilled fulfillment handler
- * @param {function=} onRejected rejection handler
- * @deprecated @param {function=} onProgress progress handler
- * @return {Promise} new promise
- */
- Promise.prototype.then = function(onFulfilled, onRejected) {
- var parent = this._handler;
- var state = parent.join().state();
-
- if ((typeof onFulfilled !== 'function' && state > 0) ||
- (typeof onRejected !== 'function' && state < 0)) {
- // Short circuit: value will not change, simply share handler
- return new this.constructor(Handler, parent);
- }
-
- var p = this._beget();
- var child = p._handler;
-
- parent.chain(child, parent.receiver, onFulfilled, onRejected,
- arguments.length > 2 ? arguments[2] : void 0);
-
- return p;
- };
-
- /**
- * If this promise cannot be fulfilled due to an error, call onRejected to
- * handle the error. Shortcut for .then(undefined, onRejected)
- * @param {function?} onRejected
- * @return {Promise}
- */
- Promise.prototype['catch'] = function(onRejected) {
- return this.then(void 0, onRejected);
- };
-
- /**
- * Creates a new, pending promise of the same type as this promise
- * @private
- * @returns {Promise}
- */
- Promise.prototype._beget = function() {
- var parent = this._handler;
- var child = new Pending(parent.receiver, parent.join().context);
- return new this.constructor(Handler, child);
- };
-
- // Array combinators
-
- Promise.all = all;
- Promise.race = race;
-
- /**
- * Return a promise that will fulfill when all promises in the
- * input array have fulfilled, or will reject when one of the
- * promises rejects.
- * @param {array} promises array of promises
- * @returns {Promise} promise for array of fulfillment values
- */
- function all(promises) {
- /*jshint maxcomplexity:8*/
- var resolver = new Pending();
- var pending = promises.length >>> 0;
- var results = new Array(pending);
-
- var i, h, x, s;
- for (i = 0; i < promises.length; ++i) {
- x = promises[i];
-
- if (x === void 0 && !(i in promises)) {
- --pending;
- continue;
- }
-
- if (maybeThenable(x)) {
- h = getHandlerMaybeThenable(x);
-
- s = h.state();
- if (s === 0) {
- h.fold(settleAt, i, results, resolver);
- } else if (s > 0) {
- results[i] = h.value;
- --pending;
- } else {
- unreportRemaining(promises, i+1, h);
- resolver.become(h);
- break;
- }
-
- } else {
- results[i] = x;
- --pending;
- }
- }
-
- if(pending === 0) {
- resolver.become(new Fulfilled(results));
- }
-
- return new Promise(Handler, resolver);
-
- function settleAt(i, x, resolver) {
- /*jshint validthis:true*/
- this[i] = x;
- if(--pending === 0) {
- resolver.become(new Fulfilled(this));
- }
- }
- }
-
- function unreportRemaining(promises, start, rejectedHandler) {
- var i, h, x;
- for(i=start; i<promises.length; ++i) {
- x = promises[i];
- if(maybeThenable(x)) {
- h = getHandlerMaybeThenable(x);
-
- if(h !== rejectedHandler) {
- h.visit(h, void 0, h._unreport);
- }
- }
- }
- }
-
- /**
- * Fulfill-reject competitive race. Return a promise that will settle
- * to the same state as the earliest input promise to settle.
- *
- * WARNING: The ES6 Promise spec requires that race()ing an empty array
- * must return a promise that is pending forever. This implementation
- * returns a singleton forever-pending promise, the same singleton that is
- * returned by Promise.never(), thus can be checked with ===
- *
- * @param {array} promises array of promises to race
- * @returns {Promise} if input is non-empty, a promise that will settle
- * to the same outcome as the earliest input promise to settle. if empty
- * is empty, returns a promise that will never settle.
- */
- function race(promises) {
- // Sigh, race([]) is untestable unless we return *something*
- // that is recognizable without calling .then() on it.
- if(Object(promises) === promises && promises.length === 0) {
- return never();
- }
-
- var h = new Pending();
- var i, x;
- for(i=0; i<promises.length; ++i) {
- x = promises[i];
- if (x !== void 0 && i in promises) {
- getHandler(x).visit(h, h.resolve, h.reject);
- }
- }
- return new Promise(Handler, h);
- }
-
- // Promise internals
- // Below this, everything is @private
-
- /**
- * Get an appropriate handler for x, without checking for cycles
- * @param {*} x
- * @returns {object} handler
- */
- function getHandler(x) {
- if(isPromise(x)) {
- return x._handler.join();
- }
- return maybeThenable(x) ? getHandlerUntrusted(x) : new Fulfilled(x);
- }
-
- /**
- * Get a handler for thenable x.
- * NOTE: You must only call this if maybeThenable(x) == true
- * @param {object|function|Promise} x
- * @returns {object} handler
- */
- function getHandlerMaybeThenable(x) {
- return isPromise(x) ? x._handler.join() : getHandlerUntrusted(x);
- }
-
- /**
- * Get a handler for potentially untrusted thenable x
- * @param {*} x
- * @returns {object} handler
- */
- function getHandlerUntrusted(x) {
- try {
- var untrustedThen = x.then;
- return typeof untrustedThen === 'function'
- ? new Thenable(untrustedThen, x)
- : new Fulfilled(x);
- } catch(e) {
- return new Rejected(e);
- }
- }
-
- /**
- * Handler for a promise that is pending forever
- * @constructor
- */
- function Handler() {}
-
- Handler.prototype.when
- = Handler.prototype.become
- = Handler.prototype.notify
- = Handler.prototype.fail
- = Handler.prototype._unreport
- = Handler.prototype._report
- = noop;
-
- Handler.prototype._state = 0;
-
- Handler.prototype.state = function() {
- return this._state;
- };
-
- /**
- * Recursively collapse handler chain to find the handler
- * nearest to the fully resolved value.
- * @returns {object} handler nearest the fully resolved value
- */
- Handler.prototype.join = function() {
- var h = this;
- while(h.handler !== void 0) {
- h = h.handler;
- }
- return h;
- };
-
- Handler.prototype.chain = function(to, receiver, fulfilled, rejected, progress) {
- this.when({
- resolver: to,
- receiver: receiver,
- fulfilled: fulfilled,
- rejected: rejected,
- progress: progress
- });
- };
-
- Handler.prototype.visit = function(receiver, fulfilled, rejected, progress) {
- this.chain(failIfRejected, receiver, fulfilled, rejected, progress);
- };
-
- Handler.prototype.fold = function(f, z, c, to) {
- this.visit(to, function(x) {
- f.call(c, z, x, this);
- }, to.reject, to.notify);
- };
-
- /**
- * Handler that invokes fail() on any handler it becomes
- * @constructor
- */
- function FailIfRejected() {}
-
- inherit(Handler, FailIfRejected);
-
- FailIfRejected.prototype.become = function(h) {
- h.fail();
- };
-
- var failIfRejected = new FailIfRejected();
-
- /**
- * Handler that manages a queue of consumers waiting on a pending promise
- * @constructor
- */
- function Pending(receiver, inheritedContext) {
- Promise.createContext(this, inheritedContext);
-
- this.consumers = void 0;
- this.receiver = receiver;
- this.handler = void 0;
- this.resolved = false;
- }
-
- inherit(Handler, Pending);
-
- Pending.prototype._state = 0;
-
- Pending.prototype.resolve = function(x) {
- this.become(getHandler(x));
- };
-
- Pending.prototype.reject = function(x) {
- if(this.resolved) {
- return;
- }
-
- this.become(new Rejected(x));
- };
-
- Pending.prototype.join = function() {
- if (!this.resolved) {
- return this;
- }
-
- var h = this;
-
- while (h.handler !== void 0) {
- h = h.handler;
- if (h === this) {
- return this.handler = cycle();
- }
- }
-
- return h;
- };
-
- Pending.prototype.run = function() {
- var q = this.consumers;
- var handler = this.join();
- this.consumers = void 0;
-
- for (var i = 0; i < q.length; ++i) {
- handler.when(q[i]);
- }
- };
-
- Pending.prototype.become = function(handler) {
- if(this.resolved) {
- return;
- }
-
- this.resolved = true;
- this.handler = handler;
- if(this.consumers !== void 0) {
- tasks.enqueue(this);
- }
-
- if(this.context !== void 0) {
- handler._report(this.context);
- }
- };
-
- Pending.prototype.when = function(continuation) {
- if(this.resolved) {
- tasks.enqueue(new ContinuationTask(continuation, this.handler));
- } else {
- if(this.consumers === void 0) {
- this.consumers = [continuation];
- } else {
- this.consumers.push(continuation);
- }
- }
- };
-
- Pending.prototype.notify = function(x) {
- if(!this.resolved) {
- tasks.enqueue(new ProgressTask(x, this));
- }
- };
-
- Pending.prototype.fail = function(context) {
- var c = typeof context === 'undefined' ? this.context : context;
- this.resolved && this.handler.join().fail(c);
- };
-
- Pending.prototype._report = function(context) {
- this.resolved && this.handler.join()._report(context);
- };
-
- Pending.prototype._unreport = function() {
- this.resolved && this.handler.join()._unreport();
- };
-
- /**
- * Wrap another handler and force it into a future stack
- * @param {object} handler
- * @constructor
- */
- function Async(handler) {
- this.handler = handler;
- }
-
- inherit(Handler, Async);
-
- Async.prototype.when = function(continuation) {
- tasks.enqueue(new ContinuationTask(continuation, this));
- };
-
- Async.prototype._report = function(context) {
- this.join()._report(context);
- };
-
- Async.prototype._unreport = function() {
- this.join()._unreport();
- };
-
- /**
- * Handler that wraps an untrusted thenable and assimilates it in a future stack
- * @param {function} then
- * @param {{then: function}} thenable
- * @constructor
- */
- function Thenable(then, thenable) {
- Pending.call(this);
- tasks.enqueue(new AssimilateTask(then, thenable, this));
- }
-
- inherit(Pending, Thenable);
-
- /**
- * Handler for a fulfilled promise
- * @param {*} x fulfillment value
- * @constructor
- */
- function Fulfilled(x) {
- Promise.createContext(this);
- this.value = x;
- }
-
- inherit(Handler, Fulfilled);
-
- Fulfilled.prototype._state = 1;
-
- Fulfilled.prototype.fold = function(f, z, c, to) {
- runContinuation3(f, z, this, c, to);
- };
-
- Fulfilled.prototype.when = function(cont) {
- runContinuation1(cont.fulfilled, this, cont.receiver, cont.resolver);
- };
-
- var errorId = 0;
-
- /**
- * Handler for a rejected promise
- * @param {*} x rejection reason
- * @constructor
- */
- function Rejected(x) {
- Promise.createContext(this);
-
- this.id = ++errorId;
- this.value = x;
- this.handled = false;
- this.reported = false;
-
- this._report();
- }
-
- inherit(Handler, Rejected);
-
- Rejected.prototype._state = -1;
-
- Rejected.prototype.fold = function(f, z, c, to) {
- to.become(this);
- };
-
- Rejected.prototype.when = function(cont) {
- if(typeof cont.rejected === 'function') {
- this._unreport();
- }
- runContinuation1(cont.rejected, this, cont.receiver, cont.resolver);
- };
-
- Rejected.prototype._report = function(context) {
- tasks.afterQueue(new ReportTask(this, context));
- };
-
- Rejected.prototype._unreport = function() {
- this.handled = true;
- tasks.afterQueue(new UnreportTask(this));
- };
-
- Rejected.prototype.fail = function(context) {
- Promise.onFatalRejection(this, context === void 0 ? this.context : context);
- };
-
- function ReportTask(rejection, context) {
- this.rejection = rejection;
- this.context = context;
- }
-
- ReportTask.prototype.run = function() {
- if(!this.rejection.handled) {
- this.rejection.reported = true;
- Promise.onPotentiallyUnhandledRejection(this.rejection, this.context);
- }
- };
-
- function UnreportTask(rejection) {
- this.rejection = rejection;
- }
-
- UnreportTask.prototype.run = function() {
- if(this.rejection.reported) {
- Promise.onPotentiallyUnhandledRejectionHandled(this.rejection);
- }
- };
-
- // Unhandled rejection hooks
- // By default, everything is a noop
-
- // TODO: Better names: "annotate"?
- Promise.createContext
- = Promise.enterContext
- = Promise.exitContext
- = Promise.onPotentiallyUnhandledRejection
- = Promise.onPotentiallyUnhandledRejectionHandled
- = Promise.onFatalRejection
- = noop;
-
- // Errors and singletons
-
- var foreverPendingHandler = new Handler();
- var foreverPendingPromise = new Promise(Handler, foreverPendingHandler);
-
- function cycle() {
- return new Rejected(new TypeError('Promise cycle'));
- }
-
- // Task runners
-
- /**
- * Run a single consumer
- * @constructor
- */
- function ContinuationTask(continuation, handler) {
- this.continuation = continuation;
- this.handler = handler;
- }
-
- ContinuationTask.prototype.run = function() {
- this.handler.join().when(this.continuation);
- };
-
- /**
- * Run a queue of progress handlers
- * @constructor
- */
- function ProgressTask(value, handler) {
- this.handler = handler;
- this.value = value;
- }
-
- ProgressTask.prototype.run = function() {
- var q = this.handler.consumers;
- if(q === void 0) {
- return;
- }
-
- for (var c, i = 0; i < q.length; ++i) {
- c = q[i];
- runNotify(c.progress, this.value, this.handler, c.receiver, c.resolver);
- }
- };
-
- /**
- * Assimilate a thenable, sending it's value to resolver
- * @param {function} then
- * @param {object|function} thenable
- * @param {object} resolver
- * @constructor
- */
- function AssimilateTask(then, thenable, resolver) {
- this._then = then;
- this.thenable = thenable;
- this.resolver = resolver;
- }
-
- AssimilateTask.prototype.run = function() {
- var h = this.resolver;
- tryAssimilate(this._then, this.thenable, _resolve, _reject, _notify);
-
- function _resolve(x) { h.resolve(x); }
- function _reject(x) { h.reject(x); }
- function _notify(x) { h.notify(x); }
- };
-
- function tryAssimilate(then, thenable, resolve, reject, notify) {
- try {
- then.call(thenable, resolve, reject, notify);
- } catch (e) {
- reject(e);
- }
- }
-
- // Other helpers
-
- /**
- * @param {*} x
- * @returns {boolean} true iff x is a trusted Promise
- */
- function isPromise(x) {
- return x instanceof Promise;
- }
-
- /**
- * Test just enough to rule out primitives, in order to take faster
- * paths in some code
- * @param {*} x
- * @returns {boolean} false iff x is guaranteed *not* to be a thenable
- */
- function maybeThenable(x) {
- return (typeof x === 'object' || typeof x === 'function') && x !== null;
- }
-
- function runContinuation1(f, h, receiver, next) {
- if(typeof f !== 'function') {
- return next.become(h);
- }
-
- Promise.enterContext(h);
- tryCatchReject(f, h.value, receiver, next);
- Promise.exitContext();
- }
-
- function runContinuation3(f, x, h, receiver, next) {
- if(typeof f !== 'function') {
- return next.become(h);
- }
-
- Promise.enterContext(h);
- tryCatchReject3(f, x, h.value, receiver, next);
- Promise.exitContext();
- }
-
- function runNotify(f, x, h, receiver, next) {
- if(typeof f !== 'function') {
- return next.notify(x);
- }
-
- Promise.enterContext(h);
- tryCatchReturn(f, x, receiver, next);
- Promise.exitContext();
- }
-
- /**
- * Return f.call(thisArg, x), or if it throws return a rejected promise for
- * the thrown exception
- */
- function tryCatchReject(f, x, thisArg, next) {
- try {
- next.become(getHandler(f.call(thisArg, x)));
- } catch(e) {
- next.become(new Rejected(e));
- }
- }
-
- /**
- * Same as above, but includes the extra argument parameter.
- */
- function tryCatchReject3(f, x, y, thisArg, next) {
- try {
- f.call(thisArg, x, y, next);
- } catch(e) {
- next.become(new Rejected(e));
- }
- }
-
- /**
- * Return f.call(thisArg, x), or if it throws, *return* the exception
- */
- function tryCatchReturn(f, x, thisArg, next) {
- try {
- next.notify(f.call(thisArg, x));
- } catch(e) {
- next.notify(e);
- }
- }
-
- function inherit(Parent, Child) {
- Child.prototype = objectCreate(Parent.prototype);
- Child.prototype.constructor = Child;
- }
-
- function noop() {}
-
- return Promise;
- };
-});
-}(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
-
-},{}]},{},[10])
-(10)
-}); \ No newline at end of file