WIP - add extractor, generate snippet_data
This commit is contained in:
20
node_modules/@reach/router/CHANGELOG.md
generated
vendored
Normal file
20
node_modules/@reach/router/CHANGELOG.md
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
## v1.2.0
|
||||
|
||||
- a7a1c84 fixed focus being stolen from [autofocus] elements
|
||||
- 8a56262 Added `hash` and `search` to server location
|
||||
- 1c13f8a Added history "PUSH" and "POP" actions to listener callback
|
||||
- 534f67c Added globalHistory to index exports
|
||||
- 8cb6e83 allow falsey children in Router
|
||||
|
||||
## v1.1.1
|
||||
|
||||
- e0338b5c Removed vestigial dependencies from package.json
|
||||
- fix/automated linting
|
||||
|
||||
## v1.1.0
|
||||
|
||||
- 53f06958 Added ref forwarding and `innerRef` fallback
|
||||
|
||||
## v1.0.0
|
||||
|
||||
- Added literally everything.
|
||||
9
node_modules/@reach/router/LICENSE
generated
vendored
Normal file
9
node_modules/@reach/router/LICENSE
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2018-present, Ryan Florence
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
30
node_modules/@reach/router/README.md
generated
vendored
Normal file
30
node_modules/@reach/router/README.md
generated
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
<p align="center">
|
||||
<a href="https://reach.tech/router/">
|
||||
<img alt="Reach Router" src="./logo-horizontal.png" width="400">
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
Next Generation Routing for <a href="https://facebook.github.io/react">React</a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://www.npmjs.com/package/@reach/router"><img src="https://img.shields.io/npm/v/@reach/router.svg?style=flat-square"></a>
|
||||
<a href="https://www.npmjs.com/package/@reach/router"><img src="https://img.shields.io/npm/dm/@reach/router.svg?style=flat-square"></a>
|
||||
<a href="https://travis-ci.org/reach/router"><img src="https://img.shields.io/travis/reach/router/master.svg?style=flat-square"></a>
|
||||
</p>
|
||||
|
||||
## Documentation
|
||||
|
||||
[Documentation Site](https://reach.tech/router)
|
||||
|
||||
You can also find the docs in the [website directory](./website/src/markdown).
|
||||
|
||||
## Community
|
||||
|
||||
[Join us on Spectrum](https://spectrum.chat/reach)
|
||||
|
||||
## Legal
|
||||
|
||||
MIT License
|
||||
Copyright (c) 2018-present, Ryan Florence
|
||||
619
node_modules/@reach/router/es/index.js
generated
vendored
Normal file
619
node_modules/@reach/router/es/index.js
generated
vendored
Normal file
@ -0,0 +1,619 @@
|
||||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
||||
|
||||
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||||
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
||||
|
||||
/* eslint-disable jsx-a11y/anchor-has-content */
|
||||
import React from "react";
|
||||
import warning from "warning";
|
||||
import PropTypes from "prop-types";
|
||||
import invariant from "invariant";
|
||||
import createContext from "create-react-context";
|
||||
import { polyfill } from "react-lifecycles-compat";
|
||||
import { startsWith, pick, resolve, match, insertParams, validateRedirect } from "./lib/utils";
|
||||
import { globalHistory, navigate, createHistory, createMemorySource } from "./lib/history";
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
var createNamedContext = function createNamedContext(name, defaultValue) {
|
||||
var Ctx = createContext(defaultValue);
|
||||
Ctx.Consumer.displayName = name + ".Consumer";
|
||||
Ctx.Provider.displayName = name + ".Provider";
|
||||
return Ctx;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Location Context/Provider
|
||||
var LocationContext = createNamedContext("Location");
|
||||
|
||||
// sets up a listener if there isn't one already so apps don't need to be
|
||||
// wrapped in some top level provider
|
||||
var Location = function Location(_ref) {
|
||||
var children = _ref.children;
|
||||
return React.createElement(
|
||||
LocationContext.Consumer,
|
||||
null,
|
||||
function (context) {
|
||||
return context ? children(context) : React.createElement(
|
||||
LocationProvider,
|
||||
null,
|
||||
children
|
||||
);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
var LocationProvider = function (_React$Component) {
|
||||
_inherits(LocationProvider, _React$Component);
|
||||
|
||||
function LocationProvider() {
|
||||
var _temp, _this, _ret;
|
||||
|
||||
_classCallCheck(this, LocationProvider);
|
||||
|
||||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
||||
args[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _this.state = {
|
||||
context: _this.getContext(),
|
||||
refs: { unlisten: null }
|
||||
}, _temp), _possibleConstructorReturn(_this, _ret);
|
||||
}
|
||||
|
||||
LocationProvider.prototype.getContext = function getContext() {
|
||||
var _props$history = this.props.history,
|
||||
navigate = _props$history.navigate,
|
||||
location = _props$history.location;
|
||||
|
||||
return { navigate: navigate, location: location };
|
||||
};
|
||||
|
||||
LocationProvider.prototype.componentDidCatch = function componentDidCatch(error, info) {
|
||||
if (isRedirect(error)) {
|
||||
var _navigate = this.props.history.navigate;
|
||||
|
||||
_navigate(error.uri, { replace: true });
|
||||
} else {
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
LocationProvider.prototype.componentDidUpdate = function componentDidUpdate(prevProps, prevState) {
|
||||
if (prevState.context.location !== this.state.context.location) {
|
||||
this.props.history._onTransitionComplete();
|
||||
}
|
||||
};
|
||||
|
||||
LocationProvider.prototype.componentDidMount = function componentDidMount() {
|
||||
var _this2 = this;
|
||||
|
||||
var refs = this.state.refs,
|
||||
history = this.props.history;
|
||||
|
||||
refs.unlisten = history.listen(function () {
|
||||
Promise.resolve().then(function () {
|
||||
// TODO: replace rAF with react deferred update API when it's ready https://github.com/facebook/react/issues/13306
|
||||
requestAnimationFrame(function () {
|
||||
if (!_this2.unmounted) {
|
||||
_this2.setState(function () {
|
||||
return { context: _this2.getContext() };
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
LocationProvider.prototype.componentWillUnmount = function componentWillUnmount() {
|
||||
var refs = this.state.refs;
|
||||
|
||||
this.unmounted = true;
|
||||
refs.unlisten();
|
||||
};
|
||||
|
||||
LocationProvider.prototype.render = function render() {
|
||||
var context = this.state.context,
|
||||
children = this.props.children;
|
||||
|
||||
return React.createElement(
|
||||
LocationContext.Provider,
|
||||
{ value: context },
|
||||
typeof children === "function" ? children(context) : children || null
|
||||
);
|
||||
};
|
||||
|
||||
return LocationProvider;
|
||||
}(React.Component);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
LocationProvider.defaultProps = {
|
||||
history: globalHistory
|
||||
};
|
||||
process.env.NODE_ENV !== "production" ? LocationProvider.propTypes = {
|
||||
history: PropTypes.object.isRequired
|
||||
} : void 0;
|
||||
var ServerLocation = function ServerLocation(_ref2) {
|
||||
var url = _ref2.url,
|
||||
children = _ref2.children;
|
||||
return React.createElement(
|
||||
LocationContext.Provider,
|
||||
{
|
||||
value: {
|
||||
location: {
|
||||
pathname: url,
|
||||
search: "",
|
||||
hash: ""
|
||||
},
|
||||
navigate: function navigate() {
|
||||
throw new Error("You can't call navigate on the server.");
|
||||
}
|
||||
}
|
||||
},
|
||||
children
|
||||
);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Sets baseuri and basepath for nested routers and links
|
||||
var BaseContext = createNamedContext("Base", { baseuri: "/", basepath: "/" });
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// The main event, welcome to the show everybody.
|
||||
var Router = function Router(props) {
|
||||
return React.createElement(
|
||||
BaseContext.Consumer,
|
||||
null,
|
||||
function (baseContext) {
|
||||
return React.createElement(
|
||||
Location,
|
||||
null,
|
||||
function (locationContext) {
|
||||
return React.createElement(RouterImpl, _extends({}, baseContext, locationContext, props));
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
var RouterImpl = function (_React$PureComponent) {
|
||||
_inherits(RouterImpl, _React$PureComponent);
|
||||
|
||||
function RouterImpl() {
|
||||
_classCallCheck(this, RouterImpl);
|
||||
|
||||
return _possibleConstructorReturn(this, _React$PureComponent.apply(this, arguments));
|
||||
}
|
||||
|
||||
RouterImpl.prototype.render = function render() {
|
||||
var _props = this.props,
|
||||
location = _props.location,
|
||||
_navigate2 = _props.navigate,
|
||||
basepath = _props.basepath,
|
||||
primary = _props.primary,
|
||||
children = _props.children,
|
||||
baseuri = _props.baseuri,
|
||||
_props$component = _props.component,
|
||||
component = _props$component === undefined ? "div" : _props$component,
|
||||
domProps = _objectWithoutProperties(_props, ["location", "navigate", "basepath", "primary", "children", "baseuri", "component"]);
|
||||
|
||||
var routes = React.Children.map(children, createRoute(basepath));
|
||||
var pathname = location.pathname;
|
||||
|
||||
|
||||
var match = pick(routes, pathname);
|
||||
|
||||
if (match) {
|
||||
var params = match.params,
|
||||
uri = match.uri,
|
||||
route = match.route,
|
||||
element = match.route.value;
|
||||
|
||||
// remove the /* from the end for child routes relative paths
|
||||
|
||||
basepath = route.default ? basepath : route.path.replace(/\*$/, "");
|
||||
|
||||
var props = _extends({}, params, {
|
||||
uri: uri,
|
||||
location: location,
|
||||
navigate: function navigate(to, options) {
|
||||
return _navigate2(resolve(to, uri), options);
|
||||
}
|
||||
});
|
||||
|
||||
var clone = React.cloneElement(element, props, element.props.children ? React.createElement(
|
||||
Router,
|
||||
{ primary: primary },
|
||||
element.props.children
|
||||
) : undefined);
|
||||
|
||||
// using 'div' for < 16.3 support
|
||||
var FocusWrapper = primary ? FocusHandler : component;
|
||||
// don't pass any props to 'div'
|
||||
var wrapperProps = primary ? _extends({ uri: uri, location: location, component: component }, domProps) : domProps;
|
||||
|
||||
return React.createElement(
|
||||
BaseContext.Provider,
|
||||
{ value: { baseuri: uri, basepath: basepath } },
|
||||
React.createElement(
|
||||
FocusWrapper,
|
||||
wrapperProps,
|
||||
clone
|
||||
)
|
||||
);
|
||||
} else {
|
||||
// Not sure if we want this, would require index routes at every level
|
||||
// warning(
|
||||
// false,
|
||||
// `<Router basepath="${basepath}">\n\nNothing matched:\n\t${
|
||||
// location.pathname
|
||||
// }\n\nPaths checked: \n\t${routes
|
||||
// .map(route => route.path)
|
||||
// .join(
|
||||
// "\n\t"
|
||||
// )}\n\nTo get rid of this warning, add a default NotFound component as child of Router:
|
||||
// \n\tlet NotFound = () => <div>Not Found!</div>
|
||||
// \n\t<Router>\n\t <NotFound default/>\n\t {/* ... */}\n\t</Router>`
|
||||
// );
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
return RouterImpl;
|
||||
}(React.PureComponent);
|
||||
|
||||
RouterImpl.defaultProps = {
|
||||
primary: true
|
||||
};
|
||||
|
||||
|
||||
var FocusContext = createNamedContext("Focus");
|
||||
|
||||
var FocusHandler = function FocusHandler(_ref3) {
|
||||
var uri = _ref3.uri,
|
||||
location = _ref3.location,
|
||||
component = _ref3.component,
|
||||
domProps = _objectWithoutProperties(_ref3, ["uri", "location", "component"]);
|
||||
|
||||
return React.createElement(
|
||||
FocusContext.Consumer,
|
||||
null,
|
||||
function (requestFocus) {
|
||||
return React.createElement(FocusHandlerImpl, _extends({}, domProps, {
|
||||
component: component,
|
||||
requestFocus: requestFocus,
|
||||
uri: uri,
|
||||
location: location
|
||||
}));
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
// don't focus on initial render
|
||||
var initialRender = true;
|
||||
var focusHandlerCount = 0;
|
||||
|
||||
var FocusHandlerImpl = function (_React$Component2) {
|
||||
_inherits(FocusHandlerImpl, _React$Component2);
|
||||
|
||||
function FocusHandlerImpl() {
|
||||
var _temp2, _this4, _ret2;
|
||||
|
||||
_classCallCheck(this, FocusHandlerImpl);
|
||||
|
||||
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
||||
args[_key2] = arguments[_key2];
|
||||
}
|
||||
|
||||
return _ret2 = (_temp2 = (_this4 = _possibleConstructorReturn(this, _React$Component2.call.apply(_React$Component2, [this].concat(args))), _this4), _this4.state = {}, _this4.requestFocus = function (node) {
|
||||
if (!_this4.state.shouldFocus) {
|
||||
node.focus();
|
||||
}
|
||||
}, _temp2), _possibleConstructorReturn(_this4, _ret2);
|
||||
}
|
||||
|
||||
FocusHandlerImpl.getDerivedStateFromProps = function getDerivedStateFromProps(nextProps, prevState) {
|
||||
var initial = prevState.uri == null;
|
||||
if (initial) {
|
||||
return _extends({
|
||||
shouldFocus: true
|
||||
}, nextProps);
|
||||
} else {
|
||||
var myURIChanged = nextProps.uri !== prevState.uri;
|
||||
var navigatedUpToMe = prevState.location.pathname !== nextProps.location.pathname && nextProps.location.pathname === nextProps.uri;
|
||||
return _extends({
|
||||
shouldFocus: myURIChanged || navigatedUpToMe
|
||||
}, nextProps);
|
||||
}
|
||||
};
|
||||
|
||||
FocusHandlerImpl.prototype.componentDidMount = function componentDidMount() {
|
||||
focusHandlerCount++;
|
||||
this.focus();
|
||||
};
|
||||
|
||||
FocusHandlerImpl.prototype.componentWillUnmount = function componentWillUnmount() {
|
||||
focusHandlerCount--;
|
||||
if (focusHandlerCount === 0) {
|
||||
initialRender = true;
|
||||
}
|
||||
};
|
||||
|
||||
FocusHandlerImpl.prototype.componentDidUpdate = function componentDidUpdate(prevProps, prevState) {
|
||||
if (prevProps.location !== this.props.location && this.state.shouldFocus) {
|
||||
this.focus();
|
||||
}
|
||||
};
|
||||
|
||||
FocusHandlerImpl.prototype.focus = function focus() {
|
||||
if (process.env.NODE_ENV === "test") {
|
||||
// getting cannot read property focus of null in the tests
|
||||
// and that bit of global `initialRender` state causes problems
|
||||
// should probably figure it out!
|
||||
return;
|
||||
}
|
||||
|
||||
var requestFocus = this.props.requestFocus;
|
||||
|
||||
|
||||
if (requestFocus) {
|
||||
requestFocus(this.node);
|
||||
} else {
|
||||
if (initialRender) {
|
||||
initialRender = false;
|
||||
} else {
|
||||
// React polyfills [autofocus] and it fires earlier than cDM,
|
||||
// so we were stealing focus away, this line prevents that.
|
||||
if (!this.node.contains(document.activeElement)) {
|
||||
this.node.focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
FocusHandlerImpl.prototype.render = function render() {
|
||||
var _this5 = this;
|
||||
|
||||
var _props2 = this.props,
|
||||
children = _props2.children,
|
||||
style = _props2.style,
|
||||
requestFocus = _props2.requestFocus,
|
||||
_props2$role = _props2.role,
|
||||
role = _props2$role === undefined ? "group" : _props2$role,
|
||||
_props2$component = _props2.component,
|
||||
Comp = _props2$component === undefined ? "div" : _props2$component,
|
||||
uri = _props2.uri,
|
||||
location = _props2.location,
|
||||
domProps = _objectWithoutProperties(_props2, ["children", "style", "requestFocus", "role", "component", "uri", "location"]);
|
||||
|
||||
return React.createElement(
|
||||
Comp,
|
||||
_extends({
|
||||
style: _extends({ outline: "none" }, style),
|
||||
tabIndex: "-1",
|
||||
role: role,
|
||||
ref: function ref(n) {
|
||||
return _this5.node = n;
|
||||
}
|
||||
}, domProps),
|
||||
React.createElement(
|
||||
FocusContext.Provider,
|
||||
{ value: this.requestFocus },
|
||||
this.props.children
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
return FocusHandlerImpl;
|
||||
}(React.Component);
|
||||
|
||||
polyfill(FocusHandlerImpl);
|
||||
|
||||
var k = function k() {};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
var forwardRef = React.forwardRef;
|
||||
|
||||
if (typeof forwardRef === "undefined") {
|
||||
forwardRef = function forwardRef(C) {
|
||||
return C;
|
||||
};
|
||||
}
|
||||
|
||||
var Link = forwardRef(function (_ref4, ref) {
|
||||
var innerRef = _ref4.innerRef,
|
||||
props = _objectWithoutProperties(_ref4, ["innerRef"]);
|
||||
|
||||
return React.createElement(
|
||||
BaseContext.Consumer,
|
||||
null,
|
||||
function (_ref5) {
|
||||
var basepath = _ref5.basepath,
|
||||
baseuri = _ref5.baseuri;
|
||||
return React.createElement(
|
||||
Location,
|
||||
null,
|
||||
function (_ref6) {
|
||||
var location = _ref6.location,
|
||||
navigate = _ref6.navigate;
|
||||
|
||||
var to = props.to,
|
||||
state = props.state,
|
||||
replace = props.replace,
|
||||
_props$getProps = props.getProps,
|
||||
getProps = _props$getProps === undefined ? k : _props$getProps,
|
||||
anchorProps = _objectWithoutProperties(props, ["to", "state", "replace", "getProps"]);
|
||||
|
||||
var href = resolve(to, baseuri);
|
||||
var isCurrent = location.pathname === href;
|
||||
var isPartiallyCurrent = startsWith(location.pathname, href);
|
||||
|
||||
return React.createElement("a", _extends({
|
||||
ref: ref || innerRef,
|
||||
"aria-current": isCurrent ? "page" : undefined
|
||||
}, anchorProps, getProps({ isCurrent: isCurrent, isPartiallyCurrent: isPartiallyCurrent, href: href, location: location }), {
|
||||
href: href,
|
||||
onClick: function onClick(event) {
|
||||
if (anchorProps.onClick) anchorProps.onClick(event);
|
||||
if (shouldNavigate(event)) {
|
||||
event.preventDefault();
|
||||
navigate(href, { state: state, replace: replace });
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
function RedirectRequest(uri) {
|
||||
this.uri = uri;
|
||||
}
|
||||
|
||||
var isRedirect = function isRedirect(o) {
|
||||
return o instanceof RedirectRequest;
|
||||
};
|
||||
|
||||
var redirectTo = function redirectTo(to) {
|
||||
throw new RedirectRequest(to);
|
||||
};
|
||||
|
||||
var RedirectImpl = function (_React$Component3) {
|
||||
_inherits(RedirectImpl, _React$Component3);
|
||||
|
||||
function RedirectImpl() {
|
||||
_classCallCheck(this, RedirectImpl);
|
||||
|
||||
return _possibleConstructorReturn(this, _React$Component3.apply(this, arguments));
|
||||
}
|
||||
|
||||
// Support React < 16 with this hook
|
||||
RedirectImpl.prototype.componentDidMount = function componentDidMount() {
|
||||
var _props3 = this.props,
|
||||
navigate = _props3.navigate,
|
||||
to = _props3.to,
|
||||
from = _props3.from,
|
||||
_props3$replace = _props3.replace,
|
||||
replace = _props3$replace === undefined ? true : _props3$replace,
|
||||
state = _props3.state,
|
||||
noThrow = _props3.noThrow,
|
||||
props = _objectWithoutProperties(_props3, ["navigate", "to", "from", "replace", "state", "noThrow"]);
|
||||
|
||||
Promise.resolve().then(function () {
|
||||
navigate(insertParams(to, props), { replace: replace, state: state });
|
||||
});
|
||||
};
|
||||
|
||||
RedirectImpl.prototype.render = function render() {
|
||||
var _props4 = this.props,
|
||||
navigate = _props4.navigate,
|
||||
to = _props4.to,
|
||||
from = _props4.from,
|
||||
replace = _props4.replace,
|
||||
state = _props4.state,
|
||||
noThrow = _props4.noThrow,
|
||||
props = _objectWithoutProperties(_props4, ["navigate", "to", "from", "replace", "state", "noThrow"]);
|
||||
|
||||
if (!noThrow) redirectTo(insertParams(to, props));
|
||||
return null;
|
||||
};
|
||||
|
||||
return RedirectImpl;
|
||||
}(React.Component);
|
||||
|
||||
var Redirect = function Redirect(props) {
|
||||
return React.createElement(
|
||||
Location,
|
||||
null,
|
||||
function (locationContext) {
|
||||
return React.createElement(RedirectImpl, _extends({}, locationContext, props));
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
process.env.NODE_ENV !== "production" ? Redirect.propTypes = {
|
||||
from: PropTypes.string,
|
||||
to: PropTypes.string.isRequired
|
||||
} : void 0;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
var Match = function Match(_ref7) {
|
||||
var path = _ref7.path,
|
||||
children = _ref7.children;
|
||||
return React.createElement(
|
||||
BaseContext.Consumer,
|
||||
null,
|
||||
function (_ref8) {
|
||||
var baseuri = _ref8.baseuri;
|
||||
return React.createElement(
|
||||
Location,
|
||||
null,
|
||||
function (_ref9) {
|
||||
var navigate = _ref9.navigate,
|
||||
location = _ref9.location;
|
||||
|
||||
var resolvedPath = resolve(path, baseuri);
|
||||
var result = match(resolvedPath, location.pathname);
|
||||
return children({
|
||||
navigate: navigate,
|
||||
location: location,
|
||||
match: result ? _extends({}, result.params, {
|
||||
uri: result.uri,
|
||||
path: path
|
||||
}) : null
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Junk
|
||||
var stripSlashes = function stripSlashes(str) {
|
||||
return str.replace(/(^\/+|\/+$)/g, "");
|
||||
};
|
||||
|
||||
var createRoute = function createRoute(basepath) {
|
||||
return function (element) {
|
||||
if (!element) {
|
||||
return null;
|
||||
}
|
||||
|
||||
!(element.props.path || element.props.default || element.type === Redirect) ? process.env.NODE_ENV !== "production" ? invariant(false, "<Router>: Children of <Router> must have a `path` or `default` prop, or be a `<Redirect>`. None found on element type `" + element.type + "`") : invariant(false) : void 0;
|
||||
|
||||
!!(element.type === Redirect && (!element.props.from || !element.props.to)) ? process.env.NODE_ENV !== "production" ? invariant(false, "<Redirect from=\"" + element.props.from + " to=\"" + element.props.to + "\"/> requires both \"from\" and \"to\" props when inside a <Router>.") : invariant(false) : void 0;
|
||||
|
||||
!!(element.type === Redirect && !validateRedirect(element.props.from, element.props.to)) ? process.env.NODE_ENV !== "production" ? invariant(false, "<Redirect from=\"" + element.props.from + " to=\"" + element.props.to + "\"/> has mismatched dynamic segments, ensure both paths have the exact same dynamic segments.") : invariant(false) : void 0;
|
||||
|
||||
if (element.props.default) {
|
||||
return { value: element, default: true };
|
||||
}
|
||||
|
||||
var elementPath = element.type === Redirect ? element.props.from : element.props.path;
|
||||
|
||||
var path = elementPath === "/" ? basepath : stripSlashes(basepath) + "/" + stripSlashes(elementPath);
|
||||
|
||||
return {
|
||||
value: element,
|
||||
default: element.props.default,
|
||||
path: element.props.children ? stripSlashes(path) + "/*" : path
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
var shouldNavigate = function shouldNavigate(event) {
|
||||
return !event.defaultPrevented && event.button === 0 && !(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
export { Link, Location, LocationProvider, Match, Redirect, Router, ServerLocation, createHistory, createMemorySource, isRedirect, navigate, redirectTo, globalHistory };
|
||||
89
node_modules/@reach/router/es/lib/ManageScroll.js
generated
vendored
Normal file
89
node_modules/@reach/router/es/lib/ManageScroll.js
generated
vendored
Normal file
@ -0,0 +1,89 @@
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||||
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
||||
|
||||
import React from "react";
|
||||
import { Location } from "../";
|
||||
|
||||
var scrollPositions = {};
|
||||
|
||||
var ManageScrollImpl = function (_React$Component) {
|
||||
_inherits(ManageScrollImpl, _React$Component);
|
||||
|
||||
function ManageScrollImpl() {
|
||||
var _temp, _this, _ret;
|
||||
|
||||
_classCallCheck(this, ManageScrollImpl);
|
||||
|
||||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
||||
args[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _this.listener = function () {
|
||||
scrollPositions[_this.props.location.key] = window.scrollY;
|
||||
try {
|
||||
sessionStorage.setItem("scrollPositions", JSON.stringify(scrollPositions));
|
||||
} catch (e) {}
|
||||
}, _temp), _possibleConstructorReturn(_this, _ret);
|
||||
}
|
||||
|
||||
ManageScrollImpl.prototype.componentDidMount = function componentDidMount() {
|
||||
try {
|
||||
// session storage will throw for a few reasons
|
||||
// - user settings
|
||||
// - in-cognito/private browsing
|
||||
// - who knows...
|
||||
var storage = JSON.parse(sessionStorage.getItem("scrollPositions"));
|
||||
if (storage) {
|
||||
scrollPositions = JSON.parse(storage) || {};
|
||||
var key = this.props.location.key;
|
||||
|
||||
if (scrollPositions[key]) {
|
||||
window.scrollTo(0, scrollPositions[key]);
|
||||
}
|
||||
}
|
||||
} catch (e) {}
|
||||
|
||||
window.addEventListener("scroll", this.listener);
|
||||
};
|
||||
|
||||
ManageScrollImpl.prototype.componentWillUnmount = function componentWillUnmount() {
|
||||
window.removeEventListener("scroll", this.listener);
|
||||
};
|
||||
|
||||
ManageScrollImpl.prototype.componentDidUpdate = function componentDidUpdate() {
|
||||
var key = this.props.location.key;
|
||||
|
||||
if (!scrollPositions[key]) {
|
||||
// never seen this location before
|
||||
window.scrollTo(0, 0);
|
||||
} else {
|
||||
// seen it
|
||||
window.scrollTo(0, scrollPositions[key]);
|
||||
}
|
||||
};
|
||||
|
||||
ManageScrollImpl.prototype.render = function render() {
|
||||
return null;
|
||||
};
|
||||
|
||||
return ManageScrollImpl;
|
||||
}(React.Component);
|
||||
|
||||
process.env.NODE_ENV !== "production" ? ManageScrollImpl.propTypes = {
|
||||
location: function location() {}
|
||||
} : void 0;
|
||||
|
||||
|
||||
export default (function () {
|
||||
return React.createElement(
|
||||
Location,
|
||||
null,
|
||||
function (_ref) {
|
||||
var location = _ref.location;
|
||||
return React.createElement(ManageScrollImpl, { location: location });
|
||||
}
|
||||
);
|
||||
});
|
||||
139
node_modules/@reach/router/es/lib/history.js
generated
vendored
Normal file
139
node_modules/@reach/router/es/lib/history.js
generated
vendored
Normal file
@ -0,0 +1,139 @@
|
||||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
||||
|
||||
var getLocation = function getLocation(source) {
|
||||
return _extends({}, source.location, {
|
||||
state: source.history.state,
|
||||
key: source.history.state && source.history.state.key || "initial"
|
||||
});
|
||||
};
|
||||
|
||||
var createHistory = function createHistory(source, options) {
|
||||
var listeners = [];
|
||||
var location = getLocation(source);
|
||||
var transitioning = false;
|
||||
var resolveTransition = function resolveTransition() {};
|
||||
|
||||
return {
|
||||
get location() {
|
||||
return location;
|
||||
},
|
||||
|
||||
get transitioning() {
|
||||
return transitioning;
|
||||
},
|
||||
|
||||
_onTransitionComplete: function _onTransitionComplete() {
|
||||
transitioning = false;
|
||||
resolveTransition();
|
||||
},
|
||||
listen: function listen(listener) {
|
||||
listeners.push(listener);
|
||||
|
||||
var popstateListener = function popstateListener() {
|
||||
location = getLocation(source);
|
||||
listener({ location: location, action: "POP" });
|
||||
};
|
||||
|
||||
source.addEventListener("popstate", popstateListener);
|
||||
|
||||
return function () {
|
||||
source.removeEventListener("popstate", popstateListener);
|
||||
listeners = listeners.filter(function (fn) {
|
||||
return fn !== listener;
|
||||
});
|
||||
};
|
||||
},
|
||||
navigate: function navigate(to) {
|
||||
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
||||
state = _ref.state,
|
||||
_ref$replace = _ref.replace,
|
||||
replace = _ref$replace === undefined ? false : _ref$replace;
|
||||
|
||||
state = _extends({}, state, { key: Date.now() + "" });
|
||||
// try...catch iOS Safari limits to 100 pushState calls
|
||||
try {
|
||||
if (transitioning || replace) {
|
||||
source.history.replaceState(state, null, to);
|
||||
} else {
|
||||
source.history.pushState(state, null, to);
|
||||
}
|
||||
} catch (e) {
|
||||
source.location[replace ? "replace" : "assign"](to);
|
||||
}
|
||||
|
||||
location = getLocation(source);
|
||||
transitioning = true;
|
||||
var transition = new Promise(function (res) {
|
||||
return resolveTransition = res;
|
||||
});
|
||||
listeners.forEach(function (listener) {
|
||||
return listener({ location: location, action: "PUSH" });
|
||||
});
|
||||
return transition;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Stores history entries in memory for testing or other platforms like Native
|
||||
var createMemorySource = function createMemorySource() {
|
||||
var initialPathname = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "/";
|
||||
|
||||
var index = 0;
|
||||
var stack = [{ pathname: initialPathname, search: "" }];
|
||||
var states = [];
|
||||
|
||||
return {
|
||||
get location() {
|
||||
return stack[index];
|
||||
},
|
||||
addEventListener: function addEventListener(name, fn) {},
|
||||
removeEventListener: function removeEventListener(name, fn) {},
|
||||
|
||||
history: {
|
||||
get entries() {
|
||||
return stack;
|
||||
},
|
||||
get index() {
|
||||
return index;
|
||||
},
|
||||
get state() {
|
||||
return states[index];
|
||||
},
|
||||
pushState: function pushState(state, _, uri) {
|
||||
var _uri$split = uri.split("?"),
|
||||
pathname = _uri$split[0],
|
||||
_uri$split$ = _uri$split[1],
|
||||
search = _uri$split$ === undefined ? "" : _uri$split$;
|
||||
|
||||
index++;
|
||||
stack.push({ pathname: pathname, search: search });
|
||||
states.push(state);
|
||||
},
|
||||
replaceState: function replaceState(state, _, uri) {
|
||||
var _uri$split2 = uri.split("?"),
|
||||
pathname = _uri$split2[0],
|
||||
_uri$split2$ = _uri$split2[1],
|
||||
search = _uri$split2$ === undefined ? "" : _uri$split2$;
|
||||
|
||||
stack[index] = { pathname: pathname, search: search };
|
||||
states[index] = state;
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// global history - uses window.history as the source if available, otherwise a
|
||||
// memory history
|
||||
var canUseDOM = !!(typeof window !== "undefined" && window.document && window.document.createElement);
|
||||
var getSource = function getSource() {
|
||||
return canUseDOM ? window : createMemorySource();
|
||||
};
|
||||
|
||||
var globalHistory = createHistory(getSource());
|
||||
var navigate = globalHistory.navigate;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
export { globalHistory, navigate, createHistory, createMemorySource };
|
||||
250
node_modules/@reach/router/es/lib/utils.js
generated
vendored
Normal file
250
node_modules/@reach/router/es/lib/utils.js
generated
vendored
Normal file
@ -0,0 +1,250 @@
|
||||
import invariant from "invariant";
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// startsWith(string, search) - Check if `string` starts with `search`
|
||||
var startsWith = function startsWith(string, search) {
|
||||
return string.substr(0, search.length) === search;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// pick(routes, uri)
|
||||
//
|
||||
// Ranks and picks the best route to match. Each segment gets the highest
|
||||
// amount of points, then the type of segment gets an additional amount of
|
||||
// points where
|
||||
//
|
||||
// static > dynamic > splat > root
|
||||
//
|
||||
// This way we don't have to worry about the order of our routes, let the
|
||||
// computers do it.
|
||||
//
|
||||
// A route looks like this
|
||||
//
|
||||
// { path, default, value }
|
||||
//
|
||||
// And a returned match looks like:
|
||||
//
|
||||
// { route, params, uri }
|
||||
//
|
||||
// I know, I should use TypeScript not comments for these types.
|
||||
var pick = function pick(routes, uri) {
|
||||
var match = void 0;
|
||||
var default_ = void 0;
|
||||
|
||||
var _uri$split = uri.split("?"),
|
||||
uriPathname = _uri$split[0];
|
||||
|
||||
var uriSegments = segmentize(uriPathname);
|
||||
var isRootUri = uriSegments[0] === "";
|
||||
var ranked = rankRoutes(routes);
|
||||
|
||||
for (var i = 0, l = ranked.length; i < l; i++) {
|
||||
var missed = false;
|
||||
var route = ranked[i].route;
|
||||
|
||||
if (route.default) {
|
||||
default_ = {
|
||||
route: route,
|
||||
params: {},
|
||||
uri: uri
|
||||
};
|
||||
continue;
|
||||
}
|
||||
|
||||
var routeSegments = segmentize(route.path);
|
||||
var params = {};
|
||||
var max = Math.max(uriSegments.length, routeSegments.length);
|
||||
var index = 0;
|
||||
|
||||
for (; index < max; index++) {
|
||||
var routeSegment = routeSegments[index];
|
||||
var uriSegment = uriSegments[index];
|
||||
|
||||
var _isSplat = routeSegment === "*";
|
||||
if (_isSplat) {
|
||||
// Hit a splat, just grab the rest, and return a match
|
||||
// uri: /files/documents/work
|
||||
// route: /files/*
|
||||
params["*"] = uriSegments.slice(index).map(decodeURIComponent).join("/");
|
||||
break;
|
||||
}
|
||||
|
||||
if (uriSegment === undefined) {
|
||||
// URI is shorter than the route, no match
|
||||
// uri: /users
|
||||
// route: /users/:userId
|
||||
missed = true;
|
||||
break;
|
||||
}
|
||||
|
||||
var dynamicMatch = paramRe.exec(routeSegment);
|
||||
|
||||
if (dynamicMatch && !isRootUri) {
|
||||
var matchIsNotReserved = reservedNames.indexOf(dynamicMatch[1]) === -1;
|
||||
!matchIsNotReserved ? process.env.NODE_ENV !== "production" ? invariant(false, "<Router> dynamic segment \"" + dynamicMatch[1] + "\" is a reserved name. Please use a different name in path \"" + route.path + "\".") : invariant(false) : void 0;
|
||||
var value = decodeURIComponent(uriSegment);
|
||||
params[dynamicMatch[1]] = value;
|
||||
} else if (routeSegment !== uriSegment) {
|
||||
// Current segments don't match, not dynamic, not splat, so no match
|
||||
// uri: /users/123/settings
|
||||
// route: /users/:id/profile
|
||||
missed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!missed) {
|
||||
match = {
|
||||
route: route,
|
||||
params: params,
|
||||
uri: "/" + uriSegments.slice(0, index).join("/")
|
||||
};
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return match || default_ || null;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// match(path, uri) - Matches just one path to a uri, also lol
|
||||
var match = function match(path, uri) {
|
||||
return pick([{ path: path }], uri);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// resolve(to, basepath)
|
||||
//
|
||||
// Resolves URIs as though every path is a directory, no files. Relative URIs
|
||||
// in the browser can feel awkward because not only can you be "in a directory"
|
||||
// you can be "at a file", too. For example
|
||||
//
|
||||
// browserSpecResolve('foo', '/bar/') => /bar/foo
|
||||
// browserSpecResolve('foo', '/bar') => /foo
|
||||
//
|
||||
// But on the command line of a file system, it's not as complicated, you can't
|
||||
// `cd` from a file, only directories. This way, links have to know less about
|
||||
// their current path. To go deeper you can do this:
|
||||
//
|
||||
// <Link to="deeper"/>
|
||||
// // instead of
|
||||
// <Link to=`{${props.uri}/deeper}`/>
|
||||
//
|
||||
// Just like `cd`, if you want to go deeper from the command line, you do this:
|
||||
//
|
||||
// cd deeper
|
||||
// # not
|
||||
// cd $(pwd)/deeper
|
||||
//
|
||||
// By treating every path as a directory, linking to relative paths should
|
||||
// require less contextual information and (fingers crossed) be more intuitive.
|
||||
var resolve = function resolve(to, base) {
|
||||
// /foo/bar, /baz/qux => /foo/bar
|
||||
if (startsWith(to, "/")) {
|
||||
return to;
|
||||
}
|
||||
|
||||
var _to$split = to.split("?"),
|
||||
toPathname = _to$split[0],
|
||||
toQuery = _to$split[1];
|
||||
|
||||
var _base$split = base.split("?"),
|
||||
basePathname = _base$split[0];
|
||||
|
||||
var toSegments = segmentize(toPathname);
|
||||
var baseSegments = segmentize(basePathname);
|
||||
|
||||
// ?a=b, /users?b=c => /users?a=b
|
||||
if (toSegments[0] === "") {
|
||||
return addQuery(basePathname, toQuery);
|
||||
}
|
||||
|
||||
// profile, /users/789 => /users/789/profile
|
||||
if (!startsWith(toSegments[0], ".")) {
|
||||
var pathname = baseSegments.concat(toSegments).join("/");
|
||||
return addQuery((basePathname === "/" ? "" : "/") + pathname, toQuery);
|
||||
}
|
||||
|
||||
// ./ /users/123 => /users/123
|
||||
// ../ /users/123 => /users
|
||||
// ../.. /users/123 => /
|
||||
// ../../one /a/b/c/d => /a/b/one
|
||||
// .././one /a/b/c/d => /a/b/c/one
|
||||
var allSegments = baseSegments.concat(toSegments);
|
||||
var segments = [];
|
||||
for (var i = 0, l = allSegments.length; i < l; i++) {
|
||||
var segment = allSegments[i];
|
||||
if (segment === "..") segments.pop();else if (segment !== ".") segments.push(segment);
|
||||
}
|
||||
|
||||
return addQuery("/" + segments.join("/"), toQuery);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// insertParams(path, params)
|
||||
var insertParams = function insertParams(path, params) {
|
||||
var segments = segmentize(path);
|
||||
return "/" + segments.map(function (segment) {
|
||||
var match = paramRe.exec(segment);
|
||||
return match ? params[match[1]] : segment;
|
||||
}).join("/");
|
||||
};
|
||||
|
||||
var validateRedirect = function validateRedirect(from, to) {
|
||||
var filter = function filter(segment) {
|
||||
return isDynamic(segment);
|
||||
};
|
||||
var fromString = segmentize(from).filter(filter).sort().join("/");
|
||||
var toString = segmentize(to).filter(filter).sort().join("/");
|
||||
return fromString === toString;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Junk
|
||||
var paramRe = /^:(.+)/;
|
||||
|
||||
var SEGMENT_POINTS = 4;
|
||||
var STATIC_POINTS = 3;
|
||||
var DYNAMIC_POINTS = 2;
|
||||
var SPLAT_PENALTY = 1;
|
||||
var ROOT_POINTS = 1;
|
||||
|
||||
var isRootSegment = function isRootSegment(segment) {
|
||||
return segment === "";
|
||||
};
|
||||
var isDynamic = function isDynamic(segment) {
|
||||
return paramRe.test(segment);
|
||||
};
|
||||
var isSplat = function isSplat(segment) {
|
||||
return segment === "*";
|
||||
};
|
||||
|
||||
var rankRoute = function rankRoute(route, index) {
|
||||
var score = route.default ? 0 : segmentize(route.path).reduce(function (score, segment) {
|
||||
score += SEGMENT_POINTS;
|
||||
if (isRootSegment(segment)) score += ROOT_POINTS;else if (isDynamic(segment)) score += DYNAMIC_POINTS;else if (isSplat(segment)) score -= SEGMENT_POINTS + SPLAT_PENALTY;else score += STATIC_POINTS;
|
||||
return score;
|
||||
}, 0);
|
||||
return { route: route, score: score, index: index };
|
||||
};
|
||||
|
||||
var rankRoutes = function rankRoutes(routes) {
|
||||
return routes.map(rankRoute).sort(function (a, b) {
|
||||
return a.score < b.score ? 1 : a.score > b.score ? -1 : a.index - b.index;
|
||||
});
|
||||
};
|
||||
|
||||
var segmentize = function segmentize(uri) {
|
||||
return uri
|
||||
// strip starting/ending slashes
|
||||
.replace(/(^\/+|\/+$)/g, "").split("/");
|
||||
};
|
||||
|
||||
var addQuery = function addQuery(pathname, query) {
|
||||
return pathname + (query ? "?" + query : "");
|
||||
};
|
||||
|
||||
var reservedNames = ["uri", "path"];
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
export { startsWith, pick, match, resolve, insertParams, validateRedirect };
|
||||
655
node_modules/@reach/router/index.js
generated
vendored
Normal file
655
node_modules/@reach/router/index.js
generated
vendored
Normal file
@ -0,0 +1,655 @@
|
||||
"use strict";
|
||||
|
||||
exports.__esModule = true;
|
||||
exports.globalHistory = exports.redirectTo = exports.navigate = exports.isRedirect = exports.createMemorySource = exports.createHistory = exports.ServerLocation = exports.Router = exports.Redirect = exports.Match = exports.LocationProvider = exports.Location = exports.Link = undefined;
|
||||
|
||||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
||||
|
||||
var _react = require("react");
|
||||
|
||||
var _react2 = _interopRequireDefault(_react);
|
||||
|
||||
var _warning = require("warning");
|
||||
|
||||
var _warning2 = _interopRequireDefault(_warning);
|
||||
|
||||
var _propTypes = require("prop-types");
|
||||
|
||||
var _propTypes2 = _interopRequireDefault(_propTypes);
|
||||
|
||||
var _invariant = require("invariant");
|
||||
|
||||
var _invariant2 = _interopRequireDefault(_invariant);
|
||||
|
||||
var _createReactContext = require("create-react-context");
|
||||
|
||||
var _createReactContext2 = _interopRequireDefault(_createReactContext);
|
||||
|
||||
var _reactLifecyclesCompat = require("react-lifecycles-compat");
|
||||
|
||||
var _utils = require("./lib/utils");
|
||||
|
||||
var _history = require("./lib/history");
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||||
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /* eslint-disable jsx-a11y/anchor-has-content */
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
var createNamedContext = function createNamedContext(name, defaultValue) {
|
||||
var Ctx = (0, _createReactContext2.default)(defaultValue);
|
||||
Ctx.Consumer.displayName = name + ".Consumer";
|
||||
Ctx.Provider.displayName = name + ".Provider";
|
||||
return Ctx;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Location Context/Provider
|
||||
var LocationContext = createNamedContext("Location");
|
||||
|
||||
// sets up a listener if there isn't one already so apps don't need to be
|
||||
// wrapped in some top level provider
|
||||
var Location = function Location(_ref) {
|
||||
var children = _ref.children;
|
||||
return _react2.default.createElement(
|
||||
LocationContext.Consumer,
|
||||
null,
|
||||
function (context) {
|
||||
return context ? children(context) : _react2.default.createElement(
|
||||
LocationProvider,
|
||||
null,
|
||||
children
|
||||
);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
var LocationProvider = function (_React$Component) {
|
||||
_inherits(LocationProvider, _React$Component);
|
||||
|
||||
function LocationProvider() {
|
||||
var _temp, _this, _ret;
|
||||
|
||||
_classCallCheck(this, LocationProvider);
|
||||
|
||||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
||||
args[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _this.state = {
|
||||
context: _this.getContext(),
|
||||
refs: { unlisten: null }
|
||||
}, _temp), _possibleConstructorReturn(_this, _ret);
|
||||
}
|
||||
|
||||
LocationProvider.prototype.getContext = function getContext() {
|
||||
var _props$history = this.props.history,
|
||||
navigate = _props$history.navigate,
|
||||
location = _props$history.location;
|
||||
|
||||
return { navigate: navigate, location: location };
|
||||
};
|
||||
|
||||
LocationProvider.prototype.componentDidCatch = function componentDidCatch(error, info) {
|
||||
if (isRedirect(error)) {
|
||||
var _navigate = this.props.history.navigate;
|
||||
|
||||
_navigate(error.uri, { replace: true });
|
||||
} else {
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
LocationProvider.prototype.componentDidUpdate = function componentDidUpdate(prevProps, prevState) {
|
||||
if (prevState.context.location !== this.state.context.location) {
|
||||
this.props.history._onTransitionComplete();
|
||||
}
|
||||
};
|
||||
|
||||
LocationProvider.prototype.componentDidMount = function componentDidMount() {
|
||||
var _this2 = this;
|
||||
|
||||
var refs = this.state.refs,
|
||||
history = this.props.history;
|
||||
|
||||
refs.unlisten = history.listen(function () {
|
||||
Promise.resolve().then(function () {
|
||||
// TODO: replace rAF with react deferred update API when it's ready https://github.com/facebook/react/issues/13306
|
||||
requestAnimationFrame(function () {
|
||||
if (!_this2.unmounted) {
|
||||
_this2.setState(function () {
|
||||
return { context: _this2.getContext() };
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
LocationProvider.prototype.componentWillUnmount = function componentWillUnmount() {
|
||||
var refs = this.state.refs;
|
||||
|
||||
this.unmounted = true;
|
||||
refs.unlisten();
|
||||
};
|
||||
|
||||
LocationProvider.prototype.render = function render() {
|
||||
var context = this.state.context,
|
||||
children = this.props.children;
|
||||
|
||||
return _react2.default.createElement(
|
||||
LocationContext.Provider,
|
||||
{ value: context },
|
||||
typeof children === "function" ? children(context) : children || null
|
||||
);
|
||||
};
|
||||
|
||||
return LocationProvider;
|
||||
}(_react2.default.Component);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
LocationProvider.defaultProps = {
|
||||
history: _history.globalHistory
|
||||
};
|
||||
process.env.NODE_ENV !== "production" ? LocationProvider.propTypes = {
|
||||
history: _propTypes2.default.object.isRequired
|
||||
} : void 0;
|
||||
var ServerLocation = function ServerLocation(_ref2) {
|
||||
var url = _ref2.url,
|
||||
children = _ref2.children;
|
||||
return _react2.default.createElement(
|
||||
LocationContext.Provider,
|
||||
{
|
||||
value: {
|
||||
location: {
|
||||
pathname: url,
|
||||
search: "",
|
||||
hash: ""
|
||||
},
|
||||
navigate: function navigate() {
|
||||
throw new Error("You can't call navigate on the server.");
|
||||
}
|
||||
}
|
||||
},
|
||||
children
|
||||
);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Sets baseuri and basepath for nested routers and links
|
||||
var BaseContext = createNamedContext("Base", { baseuri: "/", basepath: "/" });
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// The main event, welcome to the show everybody.
|
||||
var Router = function Router(props) {
|
||||
return _react2.default.createElement(
|
||||
BaseContext.Consumer,
|
||||
null,
|
||||
function (baseContext) {
|
||||
return _react2.default.createElement(
|
||||
Location,
|
||||
null,
|
||||
function (locationContext) {
|
||||
return _react2.default.createElement(RouterImpl, _extends({}, baseContext, locationContext, props));
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
var RouterImpl = function (_React$PureComponent) {
|
||||
_inherits(RouterImpl, _React$PureComponent);
|
||||
|
||||
function RouterImpl() {
|
||||
_classCallCheck(this, RouterImpl);
|
||||
|
||||
return _possibleConstructorReturn(this, _React$PureComponent.apply(this, arguments));
|
||||
}
|
||||
|
||||
RouterImpl.prototype.render = function render() {
|
||||
var _props = this.props,
|
||||
location = _props.location,
|
||||
_navigate2 = _props.navigate,
|
||||
basepath = _props.basepath,
|
||||
primary = _props.primary,
|
||||
children = _props.children,
|
||||
baseuri = _props.baseuri,
|
||||
_props$component = _props.component,
|
||||
component = _props$component === undefined ? "div" : _props$component,
|
||||
domProps = _objectWithoutProperties(_props, ["location", "navigate", "basepath", "primary", "children", "baseuri", "component"]);
|
||||
|
||||
var routes = _react2.default.Children.map(children, createRoute(basepath));
|
||||
var pathname = location.pathname;
|
||||
|
||||
|
||||
var match = (0, _utils.pick)(routes, pathname);
|
||||
|
||||
if (match) {
|
||||
var params = match.params,
|
||||
uri = match.uri,
|
||||
route = match.route,
|
||||
element = match.route.value;
|
||||
|
||||
// remove the /* from the end for child routes relative paths
|
||||
|
||||
basepath = route.default ? basepath : route.path.replace(/\*$/, "");
|
||||
|
||||
var props = _extends({}, params, {
|
||||
uri: uri,
|
||||
location: location,
|
||||
navigate: function navigate(to, options) {
|
||||
return _navigate2((0, _utils.resolve)(to, uri), options);
|
||||
}
|
||||
});
|
||||
|
||||
var clone = _react2.default.cloneElement(element, props, element.props.children ? _react2.default.createElement(
|
||||
Router,
|
||||
{ primary: primary },
|
||||
element.props.children
|
||||
) : undefined);
|
||||
|
||||
// using 'div' for < 16.3 support
|
||||
var FocusWrapper = primary ? FocusHandler : component;
|
||||
// don't pass any props to 'div'
|
||||
var wrapperProps = primary ? _extends({ uri: uri, location: location, component: component }, domProps) : domProps;
|
||||
|
||||
return _react2.default.createElement(
|
||||
BaseContext.Provider,
|
||||
{ value: { baseuri: uri, basepath: basepath } },
|
||||
_react2.default.createElement(
|
||||
FocusWrapper,
|
||||
wrapperProps,
|
||||
clone
|
||||
)
|
||||
);
|
||||
} else {
|
||||
// Not sure if we want this, would require index routes at every level
|
||||
// warning(
|
||||
// false,
|
||||
// `<Router basepath="${basepath}">\n\nNothing matched:\n\t${
|
||||
// location.pathname
|
||||
// }\n\nPaths checked: \n\t${routes
|
||||
// .map(route => route.path)
|
||||
// .join(
|
||||
// "\n\t"
|
||||
// )}\n\nTo get rid of this warning, add a default NotFound component as child of Router:
|
||||
// \n\tlet NotFound = () => <div>Not Found!</div>
|
||||
// \n\t<Router>\n\t <NotFound default/>\n\t {/* ... */}\n\t</Router>`
|
||||
// );
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
return RouterImpl;
|
||||
}(_react2.default.PureComponent);
|
||||
|
||||
RouterImpl.defaultProps = {
|
||||
primary: true
|
||||
};
|
||||
|
||||
|
||||
var FocusContext = createNamedContext("Focus");
|
||||
|
||||
var FocusHandler = function FocusHandler(_ref3) {
|
||||
var uri = _ref3.uri,
|
||||
location = _ref3.location,
|
||||
component = _ref3.component,
|
||||
domProps = _objectWithoutProperties(_ref3, ["uri", "location", "component"]);
|
||||
|
||||
return _react2.default.createElement(
|
||||
FocusContext.Consumer,
|
||||
null,
|
||||
function (requestFocus) {
|
||||
return _react2.default.createElement(FocusHandlerImpl, _extends({}, domProps, {
|
||||
component: component,
|
||||
requestFocus: requestFocus,
|
||||
uri: uri,
|
||||
location: location
|
||||
}));
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
// don't focus on initial render
|
||||
var initialRender = true;
|
||||
var focusHandlerCount = 0;
|
||||
|
||||
var FocusHandlerImpl = function (_React$Component2) {
|
||||
_inherits(FocusHandlerImpl, _React$Component2);
|
||||
|
||||
function FocusHandlerImpl() {
|
||||
var _temp2, _this4, _ret2;
|
||||
|
||||
_classCallCheck(this, FocusHandlerImpl);
|
||||
|
||||
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
||||
args[_key2] = arguments[_key2];
|
||||
}
|
||||
|
||||
return _ret2 = (_temp2 = (_this4 = _possibleConstructorReturn(this, _React$Component2.call.apply(_React$Component2, [this].concat(args))), _this4), _this4.state = {}, _this4.requestFocus = function (node) {
|
||||
if (!_this4.state.shouldFocus) {
|
||||
node.focus();
|
||||
}
|
||||
}, _temp2), _possibleConstructorReturn(_this4, _ret2);
|
||||
}
|
||||
|
||||
FocusHandlerImpl.getDerivedStateFromProps = function getDerivedStateFromProps(nextProps, prevState) {
|
||||
var initial = prevState.uri == null;
|
||||
if (initial) {
|
||||
return _extends({
|
||||
shouldFocus: true
|
||||
}, nextProps);
|
||||
} else {
|
||||
var myURIChanged = nextProps.uri !== prevState.uri;
|
||||
var navigatedUpToMe = prevState.location.pathname !== nextProps.location.pathname && nextProps.location.pathname === nextProps.uri;
|
||||
return _extends({
|
||||
shouldFocus: myURIChanged || navigatedUpToMe
|
||||
}, nextProps);
|
||||
}
|
||||
};
|
||||
|
||||
FocusHandlerImpl.prototype.componentDidMount = function componentDidMount() {
|
||||
focusHandlerCount++;
|
||||
this.focus();
|
||||
};
|
||||
|
||||
FocusHandlerImpl.prototype.componentWillUnmount = function componentWillUnmount() {
|
||||
focusHandlerCount--;
|
||||
if (focusHandlerCount === 0) {
|
||||
initialRender = true;
|
||||
}
|
||||
};
|
||||
|
||||
FocusHandlerImpl.prototype.componentDidUpdate = function componentDidUpdate(prevProps, prevState) {
|
||||
if (prevProps.location !== this.props.location && this.state.shouldFocus) {
|
||||
this.focus();
|
||||
}
|
||||
};
|
||||
|
||||
FocusHandlerImpl.prototype.focus = function focus() {
|
||||
if (process.env.NODE_ENV === "test") {
|
||||
// getting cannot read property focus of null in the tests
|
||||
// and that bit of global `initialRender` state causes problems
|
||||
// should probably figure it out!
|
||||
return;
|
||||
}
|
||||
|
||||
var requestFocus = this.props.requestFocus;
|
||||
|
||||
|
||||
if (requestFocus) {
|
||||
requestFocus(this.node);
|
||||
} else {
|
||||
if (initialRender) {
|
||||
initialRender = false;
|
||||
} else {
|
||||
// React polyfills [autofocus] and it fires earlier than cDM,
|
||||
// so we were stealing focus away, this line prevents that.
|
||||
if (!this.node.contains(document.activeElement)) {
|
||||
this.node.focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
FocusHandlerImpl.prototype.render = function render() {
|
||||
var _this5 = this;
|
||||
|
||||
var _props2 = this.props,
|
||||
children = _props2.children,
|
||||
style = _props2.style,
|
||||
requestFocus = _props2.requestFocus,
|
||||
_props2$role = _props2.role,
|
||||
role = _props2$role === undefined ? "group" : _props2$role,
|
||||
_props2$component = _props2.component,
|
||||
Comp = _props2$component === undefined ? "div" : _props2$component,
|
||||
uri = _props2.uri,
|
||||
location = _props2.location,
|
||||
domProps = _objectWithoutProperties(_props2, ["children", "style", "requestFocus", "role", "component", "uri", "location"]);
|
||||
|
||||
return _react2.default.createElement(
|
||||
Comp,
|
||||
_extends({
|
||||
style: _extends({ outline: "none" }, style),
|
||||
tabIndex: "-1",
|
||||
role: role,
|
||||
ref: function ref(n) {
|
||||
return _this5.node = n;
|
||||
}
|
||||
}, domProps),
|
||||
_react2.default.createElement(
|
||||
FocusContext.Provider,
|
||||
{ value: this.requestFocus },
|
||||
this.props.children
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
return FocusHandlerImpl;
|
||||
}(_react2.default.Component);
|
||||
|
||||
(0, _reactLifecyclesCompat.polyfill)(FocusHandlerImpl);
|
||||
|
||||
var k = function k() {};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
var forwardRef = _react2.default.forwardRef;
|
||||
|
||||
if (typeof forwardRef === "undefined") {
|
||||
forwardRef = function forwardRef(C) {
|
||||
return C;
|
||||
};
|
||||
}
|
||||
|
||||
var Link = forwardRef(function (_ref4, ref) {
|
||||
var innerRef = _ref4.innerRef,
|
||||
props = _objectWithoutProperties(_ref4, ["innerRef"]);
|
||||
|
||||
return _react2.default.createElement(
|
||||
BaseContext.Consumer,
|
||||
null,
|
||||
function (_ref5) {
|
||||
var basepath = _ref5.basepath,
|
||||
baseuri = _ref5.baseuri;
|
||||
return _react2.default.createElement(
|
||||
Location,
|
||||
null,
|
||||
function (_ref6) {
|
||||
var location = _ref6.location,
|
||||
navigate = _ref6.navigate;
|
||||
|
||||
var to = props.to,
|
||||
state = props.state,
|
||||
replace = props.replace,
|
||||
_props$getProps = props.getProps,
|
||||
getProps = _props$getProps === undefined ? k : _props$getProps,
|
||||
anchorProps = _objectWithoutProperties(props, ["to", "state", "replace", "getProps"]);
|
||||
|
||||
var href = (0, _utils.resolve)(to, baseuri);
|
||||
var isCurrent = location.pathname === href;
|
||||
var isPartiallyCurrent = (0, _utils.startsWith)(location.pathname, href);
|
||||
|
||||
return _react2.default.createElement("a", _extends({
|
||||
ref: ref || innerRef,
|
||||
"aria-current": isCurrent ? "page" : undefined
|
||||
}, anchorProps, getProps({ isCurrent: isCurrent, isPartiallyCurrent: isPartiallyCurrent, href: href, location: location }), {
|
||||
href: href,
|
||||
onClick: function onClick(event) {
|
||||
if (anchorProps.onClick) anchorProps.onClick(event);
|
||||
if (shouldNavigate(event)) {
|
||||
event.preventDefault();
|
||||
navigate(href, { state: state, replace: replace });
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
function RedirectRequest(uri) {
|
||||
this.uri = uri;
|
||||
}
|
||||
|
||||
var isRedirect = function isRedirect(o) {
|
||||
return o instanceof RedirectRequest;
|
||||
};
|
||||
|
||||
var redirectTo = function redirectTo(to) {
|
||||
throw new RedirectRequest(to);
|
||||
};
|
||||
|
||||
var RedirectImpl = function (_React$Component3) {
|
||||
_inherits(RedirectImpl, _React$Component3);
|
||||
|
||||
function RedirectImpl() {
|
||||
_classCallCheck(this, RedirectImpl);
|
||||
|
||||
return _possibleConstructorReturn(this, _React$Component3.apply(this, arguments));
|
||||
}
|
||||
|
||||
// Support React < 16 with this hook
|
||||
RedirectImpl.prototype.componentDidMount = function componentDidMount() {
|
||||
var _props3 = this.props,
|
||||
navigate = _props3.navigate,
|
||||
to = _props3.to,
|
||||
from = _props3.from,
|
||||
_props3$replace = _props3.replace,
|
||||
replace = _props3$replace === undefined ? true : _props3$replace,
|
||||
state = _props3.state,
|
||||
noThrow = _props3.noThrow,
|
||||
props = _objectWithoutProperties(_props3, ["navigate", "to", "from", "replace", "state", "noThrow"]);
|
||||
|
||||
Promise.resolve().then(function () {
|
||||
navigate((0, _utils.insertParams)(to, props), { replace: replace, state: state });
|
||||
});
|
||||
};
|
||||
|
||||
RedirectImpl.prototype.render = function render() {
|
||||
var _props4 = this.props,
|
||||
navigate = _props4.navigate,
|
||||
to = _props4.to,
|
||||
from = _props4.from,
|
||||
replace = _props4.replace,
|
||||
state = _props4.state,
|
||||
noThrow = _props4.noThrow,
|
||||
props = _objectWithoutProperties(_props4, ["navigate", "to", "from", "replace", "state", "noThrow"]);
|
||||
|
||||
if (!noThrow) redirectTo((0, _utils.insertParams)(to, props));
|
||||
return null;
|
||||
};
|
||||
|
||||
return RedirectImpl;
|
||||
}(_react2.default.Component);
|
||||
|
||||
var Redirect = function Redirect(props) {
|
||||
return _react2.default.createElement(
|
||||
Location,
|
||||
null,
|
||||
function (locationContext) {
|
||||
return _react2.default.createElement(RedirectImpl, _extends({}, locationContext, props));
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
process.env.NODE_ENV !== "production" ? Redirect.propTypes = {
|
||||
from: _propTypes2.default.string,
|
||||
to: _propTypes2.default.string.isRequired
|
||||
} : void 0;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
var Match = function Match(_ref7) {
|
||||
var path = _ref7.path,
|
||||
children = _ref7.children;
|
||||
return _react2.default.createElement(
|
||||
BaseContext.Consumer,
|
||||
null,
|
||||
function (_ref8) {
|
||||
var baseuri = _ref8.baseuri;
|
||||
return _react2.default.createElement(
|
||||
Location,
|
||||
null,
|
||||
function (_ref9) {
|
||||
var navigate = _ref9.navigate,
|
||||
location = _ref9.location;
|
||||
|
||||
var resolvedPath = (0, _utils.resolve)(path, baseuri);
|
||||
var result = (0, _utils.match)(resolvedPath, location.pathname);
|
||||
return children({
|
||||
navigate: navigate,
|
||||
location: location,
|
||||
match: result ? _extends({}, result.params, {
|
||||
uri: result.uri,
|
||||
path: path
|
||||
}) : null
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Junk
|
||||
var stripSlashes = function stripSlashes(str) {
|
||||
return str.replace(/(^\/+|\/+$)/g, "");
|
||||
};
|
||||
|
||||
var createRoute = function createRoute(basepath) {
|
||||
return function (element) {
|
||||
if (!element) {
|
||||
return null;
|
||||
}
|
||||
|
||||
!(element.props.path || element.props.default || element.type === Redirect) ? process.env.NODE_ENV !== "production" ? (0, _invariant2.default)(false, "<Router>: Children of <Router> must have a `path` or `default` prop, or be a `<Redirect>`. None found on element type `" + element.type + "`") : (0, _invariant2.default)(false) : void 0;
|
||||
|
||||
!!(element.type === Redirect && (!element.props.from || !element.props.to)) ? process.env.NODE_ENV !== "production" ? (0, _invariant2.default)(false, "<Redirect from=\"" + element.props.from + " to=\"" + element.props.to + "\"/> requires both \"from\" and \"to\" props when inside a <Router>.") : (0, _invariant2.default)(false) : void 0;
|
||||
|
||||
!!(element.type === Redirect && !(0, _utils.validateRedirect)(element.props.from, element.props.to)) ? process.env.NODE_ENV !== "production" ? (0, _invariant2.default)(false, "<Redirect from=\"" + element.props.from + " to=\"" + element.props.to + "\"/> has mismatched dynamic segments, ensure both paths have the exact same dynamic segments.") : (0, _invariant2.default)(false) : void 0;
|
||||
|
||||
if (element.props.default) {
|
||||
return { value: element, default: true };
|
||||
}
|
||||
|
||||
var elementPath = element.type === Redirect ? element.props.from : element.props.path;
|
||||
|
||||
var path = elementPath === "/" ? basepath : stripSlashes(basepath) + "/" + stripSlashes(elementPath);
|
||||
|
||||
return {
|
||||
value: element,
|
||||
default: element.props.default,
|
||||
path: element.props.children ? stripSlashes(path) + "/*" : path
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
var shouldNavigate = function shouldNavigate(event) {
|
||||
return !event.defaultPrevented && event.button === 0 && !(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
exports.Link = Link;
|
||||
exports.Location = Location;
|
||||
exports.LocationProvider = LocationProvider;
|
||||
exports.Match = Match;
|
||||
exports.Redirect = Redirect;
|
||||
exports.Router = Router;
|
||||
exports.ServerLocation = ServerLocation;
|
||||
exports.createHistory = _history.createHistory;
|
||||
exports.createMemorySource = _history.createMemorySource;
|
||||
exports.isRedirect = isRedirect;
|
||||
exports.navigate = _history.navigate;
|
||||
exports.redirectTo = redirectTo;
|
||||
exports.globalHistory = _history.globalHistory;
|
||||
BIN
node_modules/@reach/router/lib/.DS_Store
generated
vendored
Normal file
BIN
node_modules/@reach/router/lib/.DS_Store
generated
vendored
Normal file
Binary file not shown.
146
node_modules/@reach/router/lib/history.js
generated
vendored
Normal file
146
node_modules/@reach/router/lib/history.js
generated
vendored
Normal file
@ -0,0 +1,146 @@
|
||||
"use strict";
|
||||
|
||||
exports.__esModule = true;
|
||||
|
||||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
||||
|
||||
var getLocation = function getLocation(source) {
|
||||
return _extends({}, source.location, {
|
||||
state: source.history.state,
|
||||
key: source.history.state && source.history.state.key || "initial"
|
||||
});
|
||||
};
|
||||
|
||||
var createHistory = function createHistory(source, options) {
|
||||
var listeners = [];
|
||||
var location = getLocation(source);
|
||||
var transitioning = false;
|
||||
var resolveTransition = function resolveTransition() {};
|
||||
|
||||
return {
|
||||
get location() {
|
||||
return location;
|
||||
},
|
||||
|
||||
get transitioning() {
|
||||
return transitioning;
|
||||
},
|
||||
|
||||
_onTransitionComplete: function _onTransitionComplete() {
|
||||
transitioning = false;
|
||||
resolveTransition();
|
||||
},
|
||||
listen: function listen(listener) {
|
||||
listeners.push(listener);
|
||||
|
||||
var popstateListener = function popstateListener() {
|
||||
location = getLocation(source);
|
||||
listener({ location: location, action: "POP" });
|
||||
};
|
||||
|
||||
source.addEventListener("popstate", popstateListener);
|
||||
|
||||
return function () {
|
||||
source.removeEventListener("popstate", popstateListener);
|
||||
listeners = listeners.filter(function (fn) {
|
||||
return fn !== listener;
|
||||
});
|
||||
};
|
||||
},
|
||||
navigate: function navigate(to) {
|
||||
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
||||
state = _ref.state,
|
||||
_ref$replace = _ref.replace,
|
||||
replace = _ref$replace === undefined ? false : _ref$replace;
|
||||
|
||||
state = _extends({}, state, { key: Date.now() + "" });
|
||||
// try...catch iOS Safari limits to 100 pushState calls
|
||||
try {
|
||||
if (transitioning || replace) {
|
||||
source.history.replaceState(state, null, to);
|
||||
} else {
|
||||
source.history.pushState(state, null, to);
|
||||
}
|
||||
} catch (e) {
|
||||
source.location[replace ? "replace" : "assign"](to);
|
||||
}
|
||||
|
||||
location = getLocation(source);
|
||||
transitioning = true;
|
||||
var transition = new Promise(function (res) {
|
||||
return resolveTransition = res;
|
||||
});
|
||||
listeners.forEach(function (listener) {
|
||||
return listener({ location: location, action: "PUSH" });
|
||||
});
|
||||
return transition;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Stores history entries in memory for testing or other platforms like Native
|
||||
var createMemorySource = function createMemorySource() {
|
||||
var initialPathname = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "/";
|
||||
|
||||
var index = 0;
|
||||
var stack = [{ pathname: initialPathname, search: "" }];
|
||||
var states = [];
|
||||
|
||||
return {
|
||||
get location() {
|
||||
return stack[index];
|
||||
},
|
||||
addEventListener: function addEventListener(name, fn) {},
|
||||
removeEventListener: function removeEventListener(name, fn) {},
|
||||
|
||||
history: {
|
||||
get entries() {
|
||||
return stack;
|
||||
},
|
||||
get index() {
|
||||
return index;
|
||||
},
|
||||
get state() {
|
||||
return states[index];
|
||||
},
|
||||
pushState: function pushState(state, _, uri) {
|
||||
var _uri$split = uri.split("?"),
|
||||
pathname = _uri$split[0],
|
||||
_uri$split$ = _uri$split[1],
|
||||
search = _uri$split$ === undefined ? "" : _uri$split$;
|
||||
|
||||
index++;
|
||||
stack.push({ pathname: pathname, search: search });
|
||||
states.push(state);
|
||||
},
|
||||
replaceState: function replaceState(state, _, uri) {
|
||||
var _uri$split2 = uri.split("?"),
|
||||
pathname = _uri$split2[0],
|
||||
_uri$split2$ = _uri$split2[1],
|
||||
search = _uri$split2$ === undefined ? "" : _uri$split2$;
|
||||
|
||||
stack[index] = { pathname: pathname, search: search };
|
||||
states[index] = state;
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// global history - uses window.history as the source if available, otherwise a
|
||||
// memory history
|
||||
var canUseDOM = !!(typeof window !== "undefined" && window.document && window.document.createElement);
|
||||
var getSource = function getSource() {
|
||||
return canUseDOM ? window : createMemorySource();
|
||||
};
|
||||
|
||||
var globalHistory = createHistory(getSource());
|
||||
var navigate = globalHistory.navigate;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
exports.globalHistory = globalHistory;
|
||||
exports.navigate = navigate;
|
||||
exports.createHistory = createHistory;
|
||||
exports.createMemorySource = createMemorySource;
|
||||
264
node_modules/@reach/router/lib/utils.js
generated
vendored
Normal file
264
node_modules/@reach/router/lib/utils.js
generated
vendored
Normal file
@ -0,0 +1,264 @@
|
||||
"use strict";
|
||||
|
||||
exports.__esModule = true;
|
||||
exports.validateRedirect = exports.insertParams = exports.resolve = exports.match = exports.pick = exports.startsWith = undefined;
|
||||
|
||||
var _invariant = require("invariant");
|
||||
|
||||
var _invariant2 = _interopRequireDefault(_invariant);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// startsWith(string, search) - Check if `string` starts with `search`
|
||||
var startsWith = function startsWith(string, search) {
|
||||
return string.substr(0, search.length) === search;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// pick(routes, uri)
|
||||
//
|
||||
// Ranks and picks the best route to match. Each segment gets the highest
|
||||
// amount of points, then the type of segment gets an additional amount of
|
||||
// points where
|
||||
//
|
||||
// static > dynamic > splat > root
|
||||
//
|
||||
// This way we don't have to worry about the order of our routes, let the
|
||||
// computers do it.
|
||||
//
|
||||
// A route looks like this
|
||||
//
|
||||
// { path, default, value }
|
||||
//
|
||||
// And a returned match looks like:
|
||||
//
|
||||
// { route, params, uri }
|
||||
//
|
||||
// I know, I should use TypeScript not comments for these types.
|
||||
var pick = function pick(routes, uri) {
|
||||
var match = void 0;
|
||||
var default_ = void 0;
|
||||
|
||||
var _uri$split = uri.split("?"),
|
||||
uriPathname = _uri$split[0];
|
||||
|
||||
var uriSegments = segmentize(uriPathname);
|
||||
var isRootUri = uriSegments[0] === "";
|
||||
var ranked = rankRoutes(routes);
|
||||
|
||||
for (var i = 0, l = ranked.length; i < l; i++) {
|
||||
var missed = false;
|
||||
var route = ranked[i].route;
|
||||
|
||||
if (route.default) {
|
||||
default_ = {
|
||||
route: route,
|
||||
params: {},
|
||||
uri: uri
|
||||
};
|
||||
continue;
|
||||
}
|
||||
|
||||
var routeSegments = segmentize(route.path);
|
||||
var params = {};
|
||||
var max = Math.max(uriSegments.length, routeSegments.length);
|
||||
var index = 0;
|
||||
|
||||
for (; index < max; index++) {
|
||||
var routeSegment = routeSegments[index];
|
||||
var uriSegment = uriSegments[index];
|
||||
|
||||
var _isSplat = routeSegment === "*";
|
||||
if (_isSplat) {
|
||||
// Hit a splat, just grab the rest, and return a match
|
||||
// uri: /files/documents/work
|
||||
// route: /files/*
|
||||
params["*"] = uriSegments.slice(index).map(decodeURIComponent).join("/");
|
||||
break;
|
||||
}
|
||||
|
||||
if (uriSegment === undefined) {
|
||||
// URI is shorter than the route, no match
|
||||
// uri: /users
|
||||
// route: /users/:userId
|
||||
missed = true;
|
||||
break;
|
||||
}
|
||||
|
||||
var dynamicMatch = paramRe.exec(routeSegment);
|
||||
|
||||
if (dynamicMatch && !isRootUri) {
|
||||
var matchIsNotReserved = reservedNames.indexOf(dynamicMatch[1]) === -1;
|
||||
!matchIsNotReserved ? process.env.NODE_ENV !== "production" ? (0, _invariant2.default)(false, "<Router> dynamic segment \"" + dynamicMatch[1] + "\" is a reserved name. Please use a different name in path \"" + route.path + "\".") : (0, _invariant2.default)(false) : void 0;
|
||||
var value = decodeURIComponent(uriSegment);
|
||||
params[dynamicMatch[1]] = value;
|
||||
} else if (routeSegment !== uriSegment) {
|
||||
// Current segments don't match, not dynamic, not splat, so no match
|
||||
// uri: /users/123/settings
|
||||
// route: /users/:id/profile
|
||||
missed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!missed) {
|
||||
match = {
|
||||
route: route,
|
||||
params: params,
|
||||
uri: "/" + uriSegments.slice(0, index).join("/")
|
||||
};
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return match || default_ || null;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// match(path, uri) - Matches just one path to a uri, also lol
|
||||
var match = function match(path, uri) {
|
||||
return pick([{ path: path }], uri);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// resolve(to, basepath)
|
||||
//
|
||||
// Resolves URIs as though every path is a directory, no files. Relative URIs
|
||||
// in the browser can feel awkward because not only can you be "in a directory"
|
||||
// you can be "at a file", too. For example
|
||||
//
|
||||
// browserSpecResolve('foo', '/bar/') => /bar/foo
|
||||
// browserSpecResolve('foo', '/bar') => /foo
|
||||
//
|
||||
// But on the command line of a file system, it's not as complicated, you can't
|
||||
// `cd` from a file, only directories. This way, links have to know less about
|
||||
// their current path. To go deeper you can do this:
|
||||
//
|
||||
// <Link to="deeper"/>
|
||||
// // instead of
|
||||
// <Link to=`{${props.uri}/deeper}`/>
|
||||
//
|
||||
// Just like `cd`, if you want to go deeper from the command line, you do this:
|
||||
//
|
||||
// cd deeper
|
||||
// # not
|
||||
// cd $(pwd)/deeper
|
||||
//
|
||||
// By treating every path as a directory, linking to relative paths should
|
||||
// require less contextual information and (fingers crossed) be more intuitive.
|
||||
var resolve = function resolve(to, base) {
|
||||
// /foo/bar, /baz/qux => /foo/bar
|
||||
if (startsWith(to, "/")) {
|
||||
return to;
|
||||
}
|
||||
|
||||
var _to$split = to.split("?"),
|
||||
toPathname = _to$split[0],
|
||||
toQuery = _to$split[1];
|
||||
|
||||
var _base$split = base.split("?"),
|
||||
basePathname = _base$split[0];
|
||||
|
||||
var toSegments = segmentize(toPathname);
|
||||
var baseSegments = segmentize(basePathname);
|
||||
|
||||
// ?a=b, /users?b=c => /users?a=b
|
||||
if (toSegments[0] === "") {
|
||||
return addQuery(basePathname, toQuery);
|
||||
}
|
||||
|
||||
// profile, /users/789 => /users/789/profile
|
||||
if (!startsWith(toSegments[0], ".")) {
|
||||
var pathname = baseSegments.concat(toSegments).join("/");
|
||||
return addQuery((basePathname === "/" ? "" : "/") + pathname, toQuery);
|
||||
}
|
||||
|
||||
// ./ /users/123 => /users/123
|
||||
// ../ /users/123 => /users
|
||||
// ../.. /users/123 => /
|
||||
// ../../one /a/b/c/d => /a/b/one
|
||||
// .././one /a/b/c/d => /a/b/c/one
|
||||
var allSegments = baseSegments.concat(toSegments);
|
||||
var segments = [];
|
||||
for (var i = 0, l = allSegments.length; i < l; i++) {
|
||||
var segment = allSegments[i];
|
||||
if (segment === "..") segments.pop();else if (segment !== ".") segments.push(segment);
|
||||
}
|
||||
|
||||
return addQuery("/" + segments.join("/"), toQuery);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// insertParams(path, params)
|
||||
var insertParams = function insertParams(path, params) {
|
||||
var segments = segmentize(path);
|
||||
return "/" + segments.map(function (segment) {
|
||||
var match = paramRe.exec(segment);
|
||||
return match ? params[match[1]] : segment;
|
||||
}).join("/");
|
||||
};
|
||||
|
||||
var validateRedirect = function validateRedirect(from, to) {
|
||||
var filter = function filter(segment) {
|
||||
return isDynamic(segment);
|
||||
};
|
||||
var fromString = segmentize(from).filter(filter).sort().join("/");
|
||||
var toString = segmentize(to).filter(filter).sort().join("/");
|
||||
return fromString === toString;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Junk
|
||||
var paramRe = /^:(.+)/;
|
||||
|
||||
var SEGMENT_POINTS = 4;
|
||||
var STATIC_POINTS = 3;
|
||||
var DYNAMIC_POINTS = 2;
|
||||
var SPLAT_PENALTY = 1;
|
||||
var ROOT_POINTS = 1;
|
||||
|
||||
var isRootSegment = function isRootSegment(segment) {
|
||||
return segment === "";
|
||||
};
|
||||
var isDynamic = function isDynamic(segment) {
|
||||
return paramRe.test(segment);
|
||||
};
|
||||
var isSplat = function isSplat(segment) {
|
||||
return segment === "*";
|
||||
};
|
||||
|
||||
var rankRoute = function rankRoute(route, index) {
|
||||
var score = route.default ? 0 : segmentize(route.path).reduce(function (score, segment) {
|
||||
score += SEGMENT_POINTS;
|
||||
if (isRootSegment(segment)) score += ROOT_POINTS;else if (isDynamic(segment)) score += DYNAMIC_POINTS;else if (isSplat(segment)) score -= SEGMENT_POINTS + SPLAT_PENALTY;else score += STATIC_POINTS;
|
||||
return score;
|
||||
}, 0);
|
||||
return { route: route, score: score, index: index };
|
||||
};
|
||||
|
||||
var rankRoutes = function rankRoutes(routes) {
|
||||
return routes.map(rankRoute).sort(function (a, b) {
|
||||
return a.score < b.score ? 1 : a.score > b.score ? -1 : a.index - b.index;
|
||||
});
|
||||
};
|
||||
|
||||
var segmentize = function segmentize(uri) {
|
||||
return uri
|
||||
// strip starting/ending slashes
|
||||
.replace(/(^\/+|\/+$)/g, "").split("/");
|
||||
};
|
||||
|
||||
var addQuery = function addQuery(pathname, query) {
|
||||
return pathname + (query ? "?" + query : "");
|
||||
};
|
||||
|
||||
var reservedNames = ["uri", "path"];
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
exports.startsWith = startsWith;
|
||||
exports.pick = pick;
|
||||
exports.match = match;
|
||||
exports.resolve = resolve;
|
||||
exports.insertParams = insertParams;
|
||||
exports.validateRedirect = validateRedirect;
|
||||
120
node_modules/@reach/router/package.json
generated
vendored
Normal file
120
node_modules/@reach/router/package.json
generated
vendored
Normal file
@ -0,0 +1,120 @@
|
||||
{
|
||||
"_from": "@reach/router@^1.1.1",
|
||||
"_id": "@reach/router@1.2.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-kTaX08X4g27tzIFQGRukaHmNbtMYDS3LEWIS8+l6OayGIw6Oyo1HIF/JzeuR2FoF9z6oV+x/wJSVSq4v8tcUGQ==",
|
||||
"_location": "/@reach/router",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "@reach/router@^1.1.1",
|
||||
"name": "@reach/router",
|
||||
"escapedName": "@reach%2frouter",
|
||||
"scope": "@reach",
|
||||
"rawSpec": "^1.1.1",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^1.1.1"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/gatsby"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/@reach/router/-/router-1.2.1.tgz",
|
||||
"_shasum": "34ae3541a5ac44fa7796e5506a5d7274a162be4e",
|
||||
"_spec": "@reach/router@^1.1.1",
|
||||
"_where": "/Users/stefanfejes/Projects/30-seconds-of-python-code/node_modules/gatsby",
|
||||
"author": {
|
||||
"name": "Ryan Florence"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/reach/router/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"create-react-context": "^0.2.1",
|
||||
"invariant": "^2.2.3",
|
||||
"prop-types": "^15.6.1",
|
||||
"react-lifecycles-compat": "^3.0.4",
|
||||
"warning": "^3.0.0"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Next generation Routing for React.",
|
||||
"devDependencies": {
|
||||
"babel-cli": "^6.26.0",
|
||||
"babel-core": "^6",
|
||||
"babel-eslint": "^7.2.3",
|
||||
"babel-plugin-dev-expression": "^0.2.1",
|
||||
"babel-plugin-external-helpers": "^6.22.0",
|
||||
"babel-plugin-transform-class-properties": "^6.24.1",
|
||||
"babel-plugin-transform-inline-environment-variables": "^0.3.0",
|
||||
"babel-plugin-transform-object-rest-spread": "^6.26.0",
|
||||
"babel-plugin-transform-react-remove-prop-types": "^0.4.13",
|
||||
"babel-preset-env": "^1.6.1",
|
||||
"babel-preset-react": "^6.24.1",
|
||||
"eslint": "^4.18.2",
|
||||
"eslint-config-react-app": "^2.1.0",
|
||||
"eslint-plugin-flowtype": "^2.34.1",
|
||||
"eslint-plugin-import": "^2.9.0",
|
||||
"eslint-plugin-jsx-a11y": "^5.1.1",
|
||||
"eslint-plugin-react": "^7.1.0",
|
||||
"gzip-size": "^4.1.0",
|
||||
"husky": "^0.14.3",
|
||||
"jest": "^22.4.2",
|
||||
"prettier": "^1.13.4",
|
||||
"pretty-bytes": "^4.0.2",
|
||||
"pretty-quick": "^1.6.0",
|
||||
"react": "16.4.1",
|
||||
"react-dom": "16.4.1",
|
||||
"react-test-renderer": "16.4",
|
||||
"render-markdown-js": "^1.3.0",
|
||||
"rollup": "^0.56.3",
|
||||
"rollup-plugin-babel": "^3.0.3",
|
||||
"rollup-plugin-commonjs": "^8.3.0",
|
||||
"rollup-plugin-node-resolve": "^3.0.3",
|
||||
"rollup-plugin-replace": "^2.0.0",
|
||||
"rollup-plugin-uglify": "^3.0.0",
|
||||
"watch-cli": "^0.2.2"
|
||||
},
|
||||
"files": [
|
||||
"es",
|
||||
"index.js",
|
||||
"umd",
|
||||
"lib"
|
||||
],
|
||||
"homepage": "https://github.com/reach/router#readme",
|
||||
"jest": {
|
||||
"globals": {
|
||||
"__DEV__": true
|
||||
},
|
||||
"testRegex": ".+\\.test\\.js$"
|
||||
},
|
||||
"keywords": [
|
||||
"react",
|
||||
"react router"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"module": "es/index.js",
|
||||
"name": "@reach/router",
|
||||
"peerDependencies": {
|
||||
"react": "15.x || 16.x || 16.4.0-alpha.0911da3",
|
||||
"react-dom": "15.x || 16.x || 16.4.0-alpha.0911da3"
|
||||
},
|
||||
"prettier": {
|
||||
"printWidth": 80
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/reach/router.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "node build/build.js",
|
||||
"clean": "rm -rf lib es umd index.js",
|
||||
"format": "prettier '**/*.js' --write",
|
||||
"lint": "eslint src",
|
||||
"precommit": "pretty-quick --staged",
|
||||
"test": "jest",
|
||||
"watch": "watch -p \"src/**/*.js\" -c \"yarn build\""
|
||||
},
|
||||
"version": "1.2.1"
|
||||
}
|
||||
2343
node_modules/@reach/router/umd/reach-router.js
generated
vendored
Normal file
2343
node_modules/@reach/router/umd/reach-router.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
node_modules/@reach/router/umd/reach-router.min.js
generated
vendored
Normal file
1
node_modules/@reach/router/umd/reach-router.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user