react-router 5.3.2 → 5.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/react-router.js +193 -5
- package/cjs/react-router.js.map +1 -1
- package/cjs/react-router.min.js +1 -1
- package/cjs/react-router.min.js.map +1 -1
- package/esm/react-router.js +193 -5
- package/esm/react-router.js.map +1 -1
- package/modules/createContext.js +8 -0
- package/modules/createNamedContext.js +1 -1
- package/modules/miniCreateReactContext.js +175 -0
- package/package.json +1 -2
- package/umd/react-router.js +62 -43
- package/umd/react-router.js.map +1 -1
- package/umd/react-router.min.js +1 -1
- package/umd/react-router.min.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-router.min.js","sources":["../modules/createNamedContext.js","../modules/HistoryContext.js","../modules/RouterContext.js","../modules/Router.js","../modules/MemoryRouter.js","../modules/Lifecycle.js","../modules/Prompt.js","../modules/generatePath.js","../modules/Redirect.js","../modules/matchPath.js","../modules/Route.js","../modules/StaticRouter.js","../modules/Switch.js","../modules/withRouter.js","../modules/hooks.js"],"sourcesContent":["// TODO: Replace with React.createContext once we can assume React 16+\nimport createContext from \"mini-create-react-context\";\n\nconst createNamedContext = name => {\n const context = createContext();\n context.displayName = name;\n\n return context;\n};\n\nexport default createNamedContext;\n","import createNamedContext from \"./createNamedContext\";\n\nconst historyContext = /*#__PURE__*/ createNamedContext(\"Router-History\");\nexport default historyContext;\n","import createNamedContext from \"./createNamedContext\";\n\nconst context = /*#__PURE__*/ createNamedContext(\"Router\");\nexport default context;\n","import React from \"react\";\nimport PropTypes from \"prop-types\";\nimport warning from \"tiny-warning\";\n\nimport HistoryContext from \"./HistoryContext.js\";\nimport RouterContext from \"./RouterContext.js\";\n\n/**\n * The public API for putting history on context.\n */\nclass Router extends React.Component {\n static computeRootMatch(pathname) {\n return { path: \"/\", url: \"/\", params: {}, isExact: pathname === \"/\" };\n }\n\n constructor(props) {\n super(props);\n\n this.state = {\n location: props.history.location\n };\n\n // This is a bit of a hack. We have to start listening for location\n // changes here in the constructor in case there are any <Redirect>s\n // on the initial render. If there are, they will replace/push when\n // they mount and since cDM fires in children before parents, we may\n // get a new location before the <Router> is mounted.\n this._isMounted = false;\n this._pendingLocation = null;\n\n if (!props.staticContext) {\n this.unlisten = props.history.listen(location => {\n this._pendingLocation = location;\n });\n }\n }\n\n componentDidMount() {\n this._isMounted = true;\n\n if (this.unlisten) {\n // Any pre-mount location changes have been captured at\n // this point, so unregister the listener.\n this.unlisten();\n }\n if (!this.props.staticContext) {\n this.unlisten = this.props.history.listen(location => {\n if (this._isMounted) {\n this.setState({ location });\n }\n });\n }\n if (this._pendingLocation) {\n this.setState({ location: this._pendingLocation });\n }\n }\n\n componentWillUnmount() {\n if (this.unlisten) {\n this.unlisten();\n this._isMounted = false;\n this._pendingLocation = null;\n }\n }\n\n render() {\n return (\n <RouterContext.Provider\n value={{\n history: this.props.history,\n location: this.state.location,\n match: Router.computeRootMatch(this.state.location.pathname),\n staticContext: this.props.staticContext\n }}\n >\n <HistoryContext.Provider\n children={this.props.children || null}\n value={this.props.history}\n />\n </RouterContext.Provider>\n );\n }\n}\n\nif (__DEV__) {\n Router.propTypes = {\n children: PropTypes.node,\n history: PropTypes.object.isRequired,\n staticContext: PropTypes.object\n };\n\n Router.prototype.componentDidUpdate = function(prevProps) {\n warning(\n prevProps.history === this.props.history,\n \"You cannot change <Router history>\"\n );\n };\n}\n\nexport default Router;\n","import React from \"react\";\nimport PropTypes from \"prop-types\";\nimport { createMemoryHistory as createHistory } from \"history\";\nimport warning from \"tiny-warning\";\n\nimport Router from \"./Router.js\";\n\n/**\n * The public API for a <Router> that stores location in memory.\n */\nclass MemoryRouter extends React.Component {\n history = createHistory(this.props);\n\n render() {\n return <Router history={this.history} children={this.props.children} />;\n }\n}\n\nif (__DEV__) {\n MemoryRouter.propTypes = {\n initialEntries: PropTypes.array,\n initialIndex: PropTypes.number,\n getUserConfirmation: PropTypes.func,\n keyLength: PropTypes.number,\n children: PropTypes.node\n };\n\n MemoryRouter.prototype.componentDidMount = function() {\n warning(\n !this.props.history,\n \"<MemoryRouter> ignores the history prop. To use a custom history, \" +\n \"use `import { Router }` instead of `import { MemoryRouter as Router }`.\"\n );\n };\n}\n\nexport default MemoryRouter;\n","import React from \"react\";\n\nclass Lifecycle extends React.Component {\n componentDidMount() {\n if (this.props.onMount) this.props.onMount.call(this, this);\n }\n\n componentDidUpdate(prevProps) {\n if (this.props.onUpdate) this.props.onUpdate.call(this, this, prevProps);\n }\n\n componentWillUnmount() {\n if (this.props.onUnmount) this.props.onUnmount.call(this, this);\n }\n\n render() {\n return null;\n }\n}\n\nexport default Lifecycle;\n","import React from \"react\";\nimport PropTypes from \"prop-types\";\nimport invariant from \"tiny-invariant\";\n\nimport Lifecycle from \"./Lifecycle.js\";\nimport RouterContext from \"./RouterContext.js\";\n\n/**\n * The public API for prompting the user before navigating away from a screen.\n */\nfunction Prompt({ message, when = true }) {\n return (\n <RouterContext.Consumer>\n {context => {\n invariant(context, \"You should not use <Prompt> outside a <Router>\");\n\n if (!when || context.staticContext) return null;\n\n const method = context.history.block;\n\n return (\n <Lifecycle\n onMount={self => {\n self.release = method(message);\n }}\n onUpdate={(self, prevProps) => {\n if (prevProps.message !== message) {\n self.release();\n self.release = method(message);\n }\n }}\n onUnmount={self => {\n self.release();\n }}\n message={message}\n />\n );\n }}\n </RouterContext.Consumer>\n );\n}\n\nif (__DEV__) {\n const messageType = PropTypes.oneOfType([PropTypes.func, PropTypes.string]);\n\n Prompt.propTypes = {\n when: PropTypes.bool,\n message: messageType.isRequired\n };\n}\n\nexport default Prompt;\n","import pathToRegexp from \"path-to-regexp\";\n\nconst cache = {};\nconst cacheLimit = 10000;\nlet cacheCount = 0;\n\nfunction compilePath(path) {\n if (cache[path]) return cache[path];\n\n const generator = pathToRegexp.compile(path);\n\n if (cacheCount < cacheLimit) {\n cache[path] = generator;\n cacheCount++;\n }\n\n return generator;\n}\n\n/**\n * Public API for generating a URL pathname from a path and parameters.\n */\nfunction generatePath(path = \"/\", params = {}) {\n return path === \"/\" ? path : compilePath(path)(params, { pretty: true });\n}\n\nexport default generatePath;\n","import React from \"react\";\nimport PropTypes from \"prop-types\";\nimport { createLocation, locationsAreEqual } from \"history\";\nimport invariant from \"tiny-invariant\";\n\nimport Lifecycle from \"./Lifecycle.js\";\nimport RouterContext from \"./RouterContext.js\";\nimport generatePath from \"./generatePath.js\";\n\n/**\n * The public API for navigating programmatically with a component.\n */\nfunction Redirect({ computedMatch, to, push = false }) {\n return (\n <RouterContext.Consumer>\n {context => {\n invariant(context, \"You should not use <Redirect> outside a <Router>\");\n\n const { history, staticContext } = context;\n\n const method = push ? history.push : history.replace;\n const location = createLocation(\n computedMatch\n ? typeof to === \"string\"\n ? generatePath(to, computedMatch.params)\n : {\n ...to,\n pathname: generatePath(to.pathname, computedMatch.params)\n }\n : to\n );\n\n // When rendering in a static context,\n // set the new location immediately.\n if (staticContext) {\n method(location);\n return null;\n }\n\n return (\n <Lifecycle\n onMount={() => {\n method(location);\n }}\n onUpdate={(self, prevProps) => {\n const prevLocation = createLocation(prevProps.to);\n if (\n !locationsAreEqual(prevLocation, {\n ...location,\n key: prevLocation.key\n })\n ) {\n method(location);\n }\n }}\n to={to}\n />\n );\n }}\n </RouterContext.Consumer>\n );\n}\n\nif (__DEV__) {\n Redirect.propTypes = {\n push: PropTypes.bool,\n from: PropTypes.string,\n to: PropTypes.oneOfType([PropTypes.string, PropTypes.object]).isRequired\n };\n}\n\nexport default Redirect;\n","import pathToRegexp from \"path-to-regexp\";\n\nconst cache = {};\nconst cacheLimit = 10000;\nlet cacheCount = 0;\n\nfunction compilePath(path, options) {\n const cacheKey = `${options.end}${options.strict}${options.sensitive}`;\n const pathCache = cache[cacheKey] || (cache[cacheKey] = {});\n\n if (pathCache[path]) return pathCache[path];\n\n const keys = [];\n const regexp = pathToRegexp(path, keys, options);\n const result = { regexp, keys };\n\n if (cacheCount < cacheLimit) {\n pathCache[path] = result;\n cacheCount++;\n }\n\n return result;\n}\n\n/**\n * Public API for matching a URL pathname to a path.\n */\nfunction matchPath(pathname, options = {}) {\n if (typeof options === \"string\" || Array.isArray(options)) {\n options = { path: options };\n }\n\n const { path, exact = false, strict = false, sensitive = false } = options;\n\n const paths = [].concat(path);\n\n return paths.reduce((matched, path) => {\n if (!path && path !== \"\") return null;\n if (matched) return matched;\n\n const { regexp, keys } = compilePath(path, {\n end: exact,\n strict,\n sensitive\n });\n const match = regexp.exec(pathname);\n\n if (!match) return null;\n\n const [url, ...values] = match;\n const isExact = pathname === url;\n\n if (exact && !isExact) return null;\n\n return {\n path, // the path used to match\n url: path === \"/\" && url === \"\" ? \"/\" : url, // the matched portion of the URL\n isExact, // whether or not we matched exactly\n params: keys.reduce((memo, key, index) => {\n memo[key.name] = values[index];\n return memo;\n }, {})\n };\n }, null);\n}\n\nexport default matchPath;\n","import React from \"react\";\nimport { isValidElementType } from \"react-is\";\nimport PropTypes from \"prop-types\";\nimport invariant from \"tiny-invariant\";\nimport warning from \"tiny-warning\";\n\nimport RouterContext from \"./RouterContext.js\";\nimport matchPath from \"./matchPath.js\";\n\nfunction isEmptyChildren(children) {\n return React.Children.count(children) === 0;\n}\n\nfunction evalChildrenDev(children, props, path) {\n const value = children(props);\n\n warning(\n value !== undefined,\n \"You returned `undefined` from the `children` function of \" +\n `<Route${path ? ` path=\"${path}\"` : \"\"}>, but you ` +\n \"should have returned a React element or `null`\"\n );\n\n return value || null;\n}\n\n/**\n * The public API for matching a single path and rendering.\n */\nclass Route extends React.Component {\n render() {\n return (\n <RouterContext.Consumer>\n {context => {\n invariant(context, \"You should not use <Route> outside a <Router>\");\n\n const location = this.props.location || context.location;\n const match = this.props.computedMatch\n ? this.props.computedMatch // <Switch> already computed the match for us\n : this.props.path\n ? matchPath(location.pathname, this.props)\n : context.match;\n\n const props = { ...context, location, match };\n\n let { children, component, render } = this.props;\n\n // Preact uses an empty array as children by\n // default, so use null if that's the case.\n if (Array.isArray(children) && isEmptyChildren(children)) {\n children = null;\n }\n\n return (\n <RouterContext.Provider value={props}>\n {props.match\n ? children\n ? typeof children === \"function\"\n ? __DEV__\n ? evalChildrenDev(children, props, this.props.path)\n : children(props)\n : children\n : component\n ? React.createElement(component, props)\n : render\n ? render(props)\n : null\n : typeof children === \"function\"\n ? __DEV__\n ? evalChildrenDev(children, props, this.props.path)\n : children(props)\n : null}\n </RouterContext.Provider>\n );\n }}\n </RouterContext.Consumer>\n );\n }\n}\n\nif (__DEV__) {\n Route.propTypes = {\n children: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),\n component: (props, propName) => {\n if (props[propName] && !isValidElementType(props[propName])) {\n return new Error(\n `Invalid prop 'component' supplied to 'Route': the prop is not a valid React component`\n );\n }\n },\n exact: PropTypes.bool,\n location: PropTypes.object,\n path: PropTypes.oneOfType([\n PropTypes.string,\n PropTypes.arrayOf(PropTypes.string)\n ]),\n render: PropTypes.func,\n sensitive: PropTypes.bool,\n strict: PropTypes.bool\n };\n\n Route.prototype.componentDidMount = function() {\n warning(\n !(\n this.props.children &&\n !isEmptyChildren(this.props.children) &&\n this.props.component\n ),\n \"You should not use <Route component> and <Route children> in the same route; <Route component> will be ignored\"\n );\n\n warning(\n !(\n this.props.children &&\n !isEmptyChildren(this.props.children) &&\n this.props.render\n ),\n \"You should not use <Route render> and <Route children> in the same route; <Route render> will be ignored\"\n );\n\n warning(\n !(this.props.component && this.props.render),\n \"You should not use <Route component> and <Route render> in the same route; <Route render> will be ignored\"\n );\n };\n\n Route.prototype.componentDidUpdate = function(prevProps) {\n warning(\n !(this.props.location && !prevProps.location),\n '<Route> elements should not change from uncontrolled to controlled (or vice versa). You initially used no \"location\" prop and then provided one on a subsequent render.'\n );\n\n warning(\n !(!this.props.location && prevProps.location),\n '<Route> elements should not change from controlled to uncontrolled (or vice versa). You provided a \"location\" prop initially but omitted it on a subsequent render.'\n );\n };\n}\n\nexport default Route;\n","import React from \"react\";\nimport PropTypes from \"prop-types\";\nimport { createLocation, createPath } from \"history\";\nimport invariant from \"tiny-invariant\";\nimport warning from \"tiny-warning\";\n\nimport Router from \"./Router.js\";\n\nfunction addLeadingSlash(path) {\n return path.charAt(0) === \"/\" ? path : \"/\" + path;\n}\n\nfunction addBasename(basename, location) {\n if (!basename) return location;\n\n return {\n ...location,\n pathname: addLeadingSlash(basename) + location.pathname\n };\n}\n\nfunction stripBasename(basename, location) {\n if (!basename) return location;\n\n const base = addLeadingSlash(basename);\n\n if (location.pathname.indexOf(base) !== 0) return location;\n\n return {\n ...location,\n pathname: location.pathname.substr(base.length)\n };\n}\n\nfunction createURL(location) {\n return typeof location === \"string\" ? location : createPath(location);\n}\n\nfunction staticHandler(methodName) {\n return () => {\n invariant(false, \"You cannot %s with <StaticRouter>\", methodName);\n };\n}\n\nfunction noop() {}\n\n/**\n * The public top-level API for a \"static\" <Router>, so-called because it\n * can't actually change the current location. Instead, it just records\n * location changes in a context object. Useful mainly in testing and\n * server-rendering scenarios.\n */\nclass StaticRouter extends React.Component {\n navigateTo(location, action) {\n const { basename = \"\", context = {} } = this.props;\n context.action = action;\n context.location = addBasename(basename, createLocation(location));\n context.url = createURL(context.location);\n }\n\n handlePush = location => this.navigateTo(location, \"PUSH\");\n handleReplace = location => this.navigateTo(location, \"REPLACE\");\n handleListen = () => noop;\n handleBlock = () => noop;\n\n render() {\n const { basename = \"\", context = {}, location = \"/\", ...rest } = this.props;\n\n const history = {\n createHref: path => addLeadingSlash(basename + createURL(path)),\n action: \"POP\",\n location: stripBasename(basename, createLocation(location)),\n push: this.handlePush,\n replace: this.handleReplace,\n go: staticHandler(\"go\"),\n goBack: staticHandler(\"goBack\"),\n goForward: staticHandler(\"goForward\"),\n listen: this.handleListen,\n block: this.handleBlock\n };\n\n return <Router {...rest} history={history} staticContext={context} />;\n }\n}\n\nif (__DEV__) {\n StaticRouter.propTypes = {\n basename: PropTypes.string,\n context: PropTypes.object,\n location: PropTypes.oneOfType([PropTypes.string, PropTypes.object])\n };\n\n StaticRouter.prototype.componentDidMount = function() {\n warning(\n !this.props.history,\n \"<StaticRouter> ignores the history prop. To use a custom history, \" +\n \"use `import { Router }` instead of `import { StaticRouter as Router }`.\"\n );\n };\n}\n\nexport default StaticRouter;\n","import React from \"react\";\nimport PropTypes from \"prop-types\";\nimport invariant from \"tiny-invariant\";\nimport warning from \"tiny-warning\";\n\nimport RouterContext from \"./RouterContext.js\";\nimport matchPath from \"./matchPath.js\";\n\n/**\n * The public API for rendering the first <Route> that matches.\n */\nclass Switch extends React.Component {\n render() {\n return (\n <RouterContext.Consumer>\n {context => {\n invariant(context, \"You should not use <Switch> outside a <Router>\");\n\n const location = this.props.location || context.location;\n\n let element, match;\n\n // We use React.Children.forEach instead of React.Children.toArray().find()\n // here because toArray adds keys to all child elements and we do not want\n // to trigger an unmount/remount for two <Route>s that render the same\n // component at different URLs.\n React.Children.forEach(this.props.children, child => {\n if (match == null && React.isValidElement(child)) {\n element = child;\n\n const path = child.props.path || child.props.from;\n\n match = path\n ? matchPath(location.pathname, { ...child.props, path })\n : context.match;\n }\n });\n\n return match\n ? React.cloneElement(element, { location, computedMatch: match })\n : null;\n }}\n </RouterContext.Consumer>\n );\n }\n}\n\nif (__DEV__) {\n Switch.propTypes = {\n children: PropTypes.node,\n location: PropTypes.object\n };\n\n Switch.prototype.componentDidUpdate = function(prevProps) {\n warning(\n !(this.props.location && !prevProps.location),\n '<Switch> elements should not change from uncontrolled to controlled (or vice versa). You initially used no \"location\" prop and then provided one on a subsequent render.'\n );\n\n warning(\n !(!this.props.location && prevProps.location),\n '<Switch> elements should not change from controlled to uncontrolled (or vice versa). You provided a \"location\" prop initially but omitted it on a subsequent render.'\n );\n };\n}\n\nexport default Switch;\n","import React from \"react\";\nimport PropTypes from \"prop-types\";\nimport hoistStatics from \"hoist-non-react-statics\";\nimport invariant from \"tiny-invariant\";\n\nimport RouterContext from \"./RouterContext.js\";\n\n/**\n * A public higher-order component to access the imperative API\n */\nfunction withRouter(Component) {\n const displayName = `withRouter(${Component.displayName || Component.name})`;\n const C = props => {\n const { wrappedComponentRef, ...remainingProps } = props;\n\n return (\n <RouterContext.Consumer>\n {context => {\n invariant(\n context,\n `You should not use <${displayName} /> outside a <Router>`\n );\n return (\n <Component\n {...remainingProps}\n {...context}\n ref={wrappedComponentRef}\n />\n );\n }}\n </RouterContext.Consumer>\n );\n };\n\n C.displayName = displayName;\n C.WrappedComponent = Component;\n\n if (__DEV__) {\n C.propTypes = {\n wrappedComponentRef: PropTypes.oneOfType([\n PropTypes.string,\n PropTypes.func,\n PropTypes.object\n ])\n };\n }\n\n return hoistStatics(C, Component);\n}\n\nexport default withRouter;\n","import React from \"react\";\nimport invariant from \"tiny-invariant\";\n\nimport RouterContext from \"./RouterContext.js\";\nimport HistoryContext from \"./HistoryContext.js\";\nimport matchPath from \"./matchPath.js\";\n\nconst useContext = React.useContext;\n\nexport function useHistory() {\n if (__DEV__) {\n invariant(\n typeof useContext === \"function\",\n \"You must use React >= 16.8 in order to use useHistory()\"\n );\n }\n\n return useContext(HistoryContext);\n}\n\nexport function useLocation() {\n if (__DEV__) {\n invariant(\n typeof useContext === \"function\",\n \"You must use React >= 16.8 in order to use useLocation()\"\n );\n }\n\n return useContext(RouterContext).location;\n}\n\nexport function useParams() {\n if (__DEV__) {\n invariant(\n typeof useContext === \"function\",\n \"You must use React >= 16.8 in order to use useParams()\"\n );\n }\n\n const match = useContext(RouterContext).match;\n return match ? match.params : {};\n}\n\nexport function useRouteMatch(path) {\n if (__DEV__) {\n invariant(\n typeof useContext === \"function\",\n \"You must use React >= 16.8 in order to use useRouteMatch()\"\n );\n }\n\n const location = useLocation();\n const match = useContext(RouterContext).match;\n return path ? matchPath(location.pathname, path) : match;\n}\n"],"names":["createNamedContext","name","context","createContext","displayName","historyContext","Router","props","state","location","history","_isMounted","_pendingLocation","staticContext","unlisten","listen","computeRootMatch","pathname","path","url","params","isExact","componentDidMount","this","_this2","setState","componentWillUnmount","render","React","RouterContext","Provider","value","match","HistoryContext","children","Component","MemoryRouter","createHistory","_this","Lifecycle","onMount","call","componentDidUpdate","prevProps","onUpdate","onUnmount","Prompt","message","when","Consumer","invariant","method","block","self","release","cache","cacheLimit","cacheCount","compilePath","generator","pathToRegexp","compile","generatePath","pretty","Redirect","computedMatch","to","push","replace","createLocation","prevLocation","locationsAreEqual","key","options","cacheKey","end","strict","sensitive","pathCache","keys","result","regexp","matchPath","Array","isArray","exact","concat","reduce","matched","exec","values","memo","index","isEmptyChildren","Children","count","Route","component","createElement","addLeadingSlash","charAt","addBasename","basename","stripBasename","base","indexOf","substr","length","createURL","createPath","staticHandler","methodName","noop","StaticRouter","handlePush","navigateTo","handleReplace","handleListen","handleBlock","action","rest","createHref","go","goBack","goForward","Switch","element","forEach","child","isValidElement","from","cloneElement","withRouter","C","wrappedComponentRef","remainingProps","ref","WrappedComponent","hoistStatics","useContext","useHistory","useLocation","useParams","useRouteMatch"],"mappings":"uoCAGA,IAAMA,mBAAqB,SAAAC,OACnBC,EAAUC,uBAChBD,EAAQE,YAAcH,EAEfC,GCLHG,eAA+BL,mBAAmB,kBCAlDE,QAAwBF,mBAAmB,UCQ3CM,8BAKQC,8BACJA,UAEDC,MAAQ,CACXC,SAAUF,EAAMG,QAAQD,YAQrBE,YAAa,IACbC,iBAAmB,KAEnBL,EAAMM,kBACJC,SAAWP,EAAMG,QAAQK,OAAO,SAAAN,KAC9BG,iBAAmBH,6BArBvBO,iBAAP,SAAwBC,SACf,CAAEC,KAAM,IAAKC,IAAK,IAAKC,OAAQ,GAAIC,QAAsB,MAAbJ,+BAyBrDK,kBAAA,2BACOX,YAAa,EAEdY,KAAKT,eAGFA,WAEFS,KAAKhB,MAAMM,qBACTC,SAAWS,KAAKhB,MAAMG,QAAQK,OAAO,SAAAN,GACpCe,EAAKb,YACPa,EAAKC,SAAS,CAAEhB,SAAAA,OAIlBc,KAAKX,uBACFa,SAAS,CAAEhB,SAAUc,KAAKX,sBAInCc,qBAAA,WACMH,KAAKT,gBACFA,g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W9G,SAAeG,aACjCd,EAAOgE,UAAUzE,EAASQ,SAAUC,GAAQc"}
|
|
1
|
+
{"version":3,"file":"react-router.min.js","sources":["../modules/miniCreateReactContext.js","../modules/createContext.js","../modules/createNamedContext.js","../modules/HistoryContext.js","../modules/RouterContext.js","../modules/Router.js","../modules/MemoryRouter.js","../modules/Lifecycle.js","../modules/Prompt.js","../modules/generatePath.js","../modules/Redirect.js","../modules/matchPath.js","../modules/Route.js","../modules/StaticRouter.js","../modules/Switch.js","../modules/withRouter.js","../modules/hooks.js"],"sourcesContent":["// MIT License\n// Copyright (c) 2019-present StringEpsilon <StringEpsilon@gmail.com>\n// Copyright (c) 2017-2019 James Kyle <me@thejameskyle.com>\n// https://github.com/StringEpsilon/mini-create-react-context\nimport React from \"react\";\nimport PropTypes from \"prop-types\";\nimport warning from \"tiny-warning\";\n\nconst MAX_SIGNED_31_BIT_INT = 1073741823;\n\nconst commonjsGlobal =\n typeof globalThis !== \"undefined\" // 'global proper'\n ? // eslint-disable-next-line no-undef\n globalThis\n : typeof window !== \"undefined\"\n ? window // Browser\n : typeof global !== \"undefined\"\n ? global // node.js\n : {};\n\nfunction getUniqueId() {\n let key = \"__global_unique_id__\";\n return (commonjsGlobal[key] = (commonjsGlobal[key] || 0) + 1);\n}\n\n// Inlined Object.is polyfill.\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is\nfunction objectIs(x, y) {\n if (x === y) {\n return x !== 0 || 1 / x === 1 / y;\n } else {\n // eslint-disable-next-line no-self-compare\n return x !== x && y !== y;\n }\n}\n\nfunction createEventEmitter(value) {\n let handlers = [];\n return {\n on(handler) {\n handlers.push(handler);\n },\n\n off(handler) {\n handlers = handlers.filter(h => h !== handler);\n },\n\n get() {\n return value;\n },\n\n set(newValue, changedBits) {\n value = newValue;\n handlers.forEach(handler => handler(value, changedBits));\n }\n };\n}\n\nfunction onlyChild(children) {\n return Array.isArray(children) ? children[0] : children;\n}\n\nexport default function createReactContext(defaultValue, calculateChangedBits) {\n const contextProp = \"__create-react-context-\" + getUniqueId() + \"__\";\n\n class Provider extends React.Component {\n emitter = createEventEmitter(this.props.value);\n\n static childContextTypes = {\n [contextProp]: PropTypes.object.isRequired\n };\n\n getChildContext() {\n return {\n [contextProp]: this.emitter\n };\n }\n\n componentWillReceiveProps(nextProps) {\n if (this.props.value !== nextProps.value) {\n let oldValue = this.props.value;\n let newValue = nextProps.value;\n let changedBits;\n\n if (objectIs(oldValue, newValue)) {\n changedBits = 0; // No change\n } else {\n changedBits =\n typeof calculateChangedBits === \"function\"\n ? calculateChangedBits(oldValue, newValue)\n : MAX_SIGNED_31_BIT_INT;\n if (process.env.NODE_ENV !== \"production\") {\n warning(\n (changedBits & MAX_SIGNED_31_BIT_INT) === changedBits,\n \"calculateChangedBits: Expected the return value to be a \" +\n \"31-bit integer. Instead received: \" +\n changedBits\n );\n }\n\n changedBits |= 0;\n\n if (changedBits !== 0) {\n this.emitter.set(nextProps.value, changedBits);\n }\n }\n }\n }\n\n render() {\n return this.props.children;\n }\n }\n\n class Consumer extends React.Component {\n static contextTypes = {\n [contextProp]: PropTypes.object\n };\n\n observedBits;\n\n state = {\n value: this.getValue()\n };\n\n componentWillReceiveProps(nextProps) {\n let { observedBits } = nextProps;\n this.observedBits =\n observedBits === undefined || observedBits === null\n ? MAX_SIGNED_31_BIT_INT // Subscribe to all changes by default\n : observedBits;\n }\n\n componentDidMount() {\n if (this.context[contextProp]) {\n this.context[contextProp].on(this.onUpdate);\n }\n let { observedBits } = this.props;\n this.observedBits =\n observedBits === undefined || observedBits === null\n ? MAX_SIGNED_31_BIT_INT // Subscribe to all changes by default\n : observedBits;\n }\n\n componentWillUnmount() {\n if (this.context[contextProp]) {\n this.context[contextProp].off(this.onUpdate);\n }\n }\n\n getValue() {\n if (this.context[contextProp]) {\n return this.context[contextProp].get();\n } else {\n return defaultValue;\n }\n }\n\n onUpdate = (newValue, changedBits) => {\n const observedBits = this.observedBits | 0;\n if ((observedBits & changedBits) !== 0) {\n this.setState({ value: this.getValue() });\n }\n };\n\n render() {\n return onlyChild(this.props.children)(this.state.value);\n }\n }\n\n return {\n Provider,\n Consumer\n };\n}\n","// MIT License\n// Copyright (c) 2019-present StringEpsilon <StringEpsilon@gmail.com>\n// Copyright (c) 2017-2019 James Kyle <me@thejameskyle.com>\n// https://github.com/StringEpsilon/mini-create-react-context\nimport React from \"react\";\nimport createReactContext from \"./miniCreateReactContext\";\n\nexport default React.createContext || createReactContext;\n","// TODO: Replace with React.createContext once we can assume React 16+\nimport createContext from \"./createContext\";\n\nconst createNamedContext = name => {\n const context = createContext();\n context.displayName = name;\n\n return context;\n};\n\nexport default createNamedContext;\n","import createNamedContext from \"./createNamedContext\";\n\nconst historyContext = /*#__PURE__*/ createNamedContext(\"Router-History\");\nexport default historyContext;\n","import createNamedContext from \"./createNamedContext\";\n\nconst context = /*#__PURE__*/ createNamedContext(\"Router\");\nexport default context;\n","import React from \"react\";\nimport PropTypes from \"prop-types\";\nimport warning from \"tiny-warning\";\n\nimport HistoryContext from \"./HistoryContext.js\";\nimport RouterContext from \"./RouterContext.js\";\n\n/**\n * The public API for putting history on context.\n */\nclass Router extends React.Component {\n static computeRootMatch(pathname) {\n return { path: \"/\", url: \"/\", params: {}, isExact: pathname === \"/\" };\n }\n\n constructor(props) {\n super(props);\n\n this.state = {\n location: props.history.location\n };\n\n // This is a bit of a hack. We have to start listening for location\n // changes here in the constructor in case there are any <Redirect>s\n // on the initial render. If there are, they will replace/push when\n // they mount and since cDM fires in children before parents, we may\n // get a new location before the <Router> is mounted.\n this._isMounted = false;\n this._pendingLocation = null;\n\n if (!props.staticContext) {\n this.unlisten = props.history.listen(location => {\n this._pendingLocation = location;\n });\n }\n }\n\n componentDidMount() {\n this._isMounted = true;\n\n if (this.unlisten) {\n // Any pre-mount location changes have been captured at\n // this point, so unregister the listener.\n this.unlisten();\n }\n if (!this.props.staticContext) {\n this.unlisten = this.props.history.listen(location => {\n if (this._isMounted) {\n this.setState({ location });\n }\n });\n }\n if (this._pendingLocation) {\n this.setState({ location: this._pendingLocation });\n }\n }\n\n componentWillUnmount() {\n if (this.unlisten) {\n this.unlisten();\n this._isMounted = false;\n this._pendingLocation = null;\n }\n }\n\n render() {\n return (\n <RouterContext.Provider\n value={{\n history: this.props.history,\n location: this.state.location,\n match: Router.computeRootMatch(this.state.location.pathname),\n staticContext: this.props.staticContext\n }}\n >\n <HistoryContext.Provider\n children={this.props.children || null}\n value={this.props.history}\n />\n </RouterContext.Provider>\n );\n }\n}\n\nif (__DEV__) {\n Router.propTypes = {\n children: PropTypes.node,\n history: PropTypes.object.isRequired,\n staticContext: PropTypes.object\n };\n\n Router.prototype.componentDidUpdate = function(prevProps) {\n warning(\n prevProps.history === this.props.history,\n \"You cannot change <Router history>\"\n );\n };\n}\n\nexport default Router;\n","import React from \"react\";\nimport PropTypes from \"prop-types\";\nimport { createMemoryHistory as createHistory } from \"history\";\nimport warning from \"tiny-warning\";\n\nimport Router from \"./Router.js\";\n\n/**\n * The public API for a <Router> that stores location in memory.\n */\nclass MemoryRouter extends React.Component {\n history = createHistory(this.props);\n\n render() {\n return <Router history={this.history} children={this.props.children} />;\n }\n}\n\nif (__DEV__) {\n MemoryRouter.propTypes = {\n initialEntries: PropTypes.array,\n initialIndex: PropTypes.number,\n getUserConfirmation: PropTypes.func,\n keyLength: PropTypes.number,\n children: PropTypes.node\n };\n\n MemoryRouter.prototype.componentDidMount = function() {\n warning(\n !this.props.history,\n \"<MemoryRouter> ignores the history prop. To use a custom history, \" +\n \"use `import { Router }` instead of `import { MemoryRouter as Router }`.\"\n );\n };\n}\n\nexport default MemoryRouter;\n","import React from \"react\";\n\nclass Lifecycle extends React.Component {\n componentDidMount() {\n if (this.props.onMount) this.props.onMount.call(this, this);\n }\n\n componentDidUpdate(prevProps) {\n if (this.props.onUpdate) this.props.onUpdate.call(this, this, prevProps);\n }\n\n componentWillUnmount() {\n if (this.props.onUnmount) this.props.onUnmount.call(this, this);\n }\n\n render() {\n return null;\n }\n}\n\nexport default Lifecycle;\n","import React from \"react\";\nimport PropTypes from \"prop-types\";\nimport invariant from \"tiny-invariant\";\n\nimport Lifecycle from \"./Lifecycle.js\";\nimport RouterContext from \"./RouterContext.js\";\n\n/**\n * The public API for prompting the user before navigating away from a screen.\n */\nfunction Prompt({ message, when = true }) {\n return (\n <RouterContext.Consumer>\n {context => {\n invariant(context, \"You should not use <Prompt> outside a <Router>\");\n\n if (!when || context.staticContext) return null;\n\n const method = context.history.block;\n\n return (\n <Lifecycle\n onMount={self => {\n self.release = method(message);\n }}\n onUpdate={(self, prevProps) => {\n if (prevProps.message !== message) {\n self.release();\n self.release = method(message);\n }\n }}\n onUnmount={self => {\n self.release();\n }}\n message={message}\n />\n );\n }}\n </RouterContext.Consumer>\n );\n}\n\nif (__DEV__) {\n const messageType = PropTypes.oneOfType([PropTypes.func, PropTypes.string]);\n\n Prompt.propTypes = {\n when: PropTypes.bool,\n message: messageType.isRequired\n };\n}\n\nexport default Prompt;\n","import pathToRegexp from \"path-to-regexp\";\n\nconst cache = {};\nconst cacheLimit = 10000;\nlet cacheCount = 0;\n\nfunction compilePath(path) {\n if (cache[path]) return cache[path];\n\n const generator = pathToRegexp.compile(path);\n\n if (cacheCount < cacheLimit) {\n cache[path] = generator;\n cacheCount++;\n }\n\n return generator;\n}\n\n/**\n * Public API for generating a URL pathname from a path and parameters.\n */\nfunction generatePath(path = \"/\", params = {}) {\n return path === \"/\" ? path : compilePath(path)(params, { pretty: true });\n}\n\nexport default generatePath;\n","import React from \"react\";\nimport PropTypes from \"prop-types\";\nimport { createLocation, locationsAreEqual } from \"history\";\nimport invariant from \"tiny-invariant\";\n\nimport Lifecycle from \"./Lifecycle.js\";\nimport RouterContext from \"./RouterContext.js\";\nimport generatePath from \"./generatePath.js\";\n\n/**\n * The public API for navigating programmatically with a component.\n */\nfunction Redirect({ computedMatch, to, push = false }) {\n return (\n <RouterContext.Consumer>\n {context => {\n invariant(context, \"You should not use <Redirect> outside a <Router>\");\n\n const { history, staticContext } = context;\n\n const method = push ? history.push : history.replace;\n const location = createLocation(\n computedMatch\n ? typeof to === \"string\"\n ? generatePath(to, computedMatch.params)\n : {\n ...to,\n pathname: generatePath(to.pathname, computedMatch.params)\n }\n : to\n );\n\n // When rendering in a static context,\n // set the new location immediately.\n if (staticContext) {\n method(location);\n return null;\n }\n\n return (\n <Lifecycle\n onMount={() => {\n method(location);\n }}\n onUpdate={(self, prevProps) => {\n const prevLocation = createLocation(prevProps.to);\n if (\n !locationsAreEqual(prevLocation, {\n ...location,\n key: prevLocation.key\n })\n ) {\n method(location);\n }\n }}\n to={to}\n />\n );\n }}\n </RouterContext.Consumer>\n );\n}\n\nif (__DEV__) {\n Redirect.propTypes = {\n push: PropTypes.bool,\n from: PropTypes.string,\n to: PropTypes.oneOfType([PropTypes.string, PropTypes.object]).isRequired\n };\n}\n\nexport default Redirect;\n","import pathToRegexp from \"path-to-regexp\";\n\nconst cache = {};\nconst cacheLimit = 10000;\nlet cacheCount = 0;\n\nfunction compilePath(path, options) {\n const cacheKey = `${options.end}${options.strict}${options.sensitive}`;\n const pathCache = cache[cacheKey] || (cache[cacheKey] = {});\n\n if (pathCache[path]) return pathCache[path];\n\n const keys = [];\n const regexp = pathToRegexp(path, keys, options);\n const result = { regexp, keys };\n\n if (cacheCount < cacheLimit) {\n pathCache[path] = result;\n cacheCount++;\n }\n\n return result;\n}\n\n/**\n * Public API for matching a URL pathname to a path.\n */\nfunction matchPath(pathname, options = {}) {\n if (typeof options === \"string\" || Array.isArray(options)) {\n options = { path: options };\n }\n\n const { path, exact = false, strict = false, sensitive = false } = options;\n\n const paths = [].concat(path);\n\n return paths.reduce((matched, path) => {\n if (!path && path !== \"\") return null;\n if (matched) return matched;\n\n const { regexp, keys } = compilePath(path, {\n end: exact,\n strict,\n sensitive\n });\n const match = regexp.exec(pathname);\n\n if (!match) return null;\n\n const [url, ...values] = match;\n const isExact = pathname === url;\n\n if (exact && !isExact) return null;\n\n return {\n path, // the path used to match\n url: path === \"/\" && url === \"\" ? \"/\" : url, // the matched portion of the URL\n isExact, // whether or not we matched exactly\n params: keys.reduce((memo, key, index) => {\n memo[key.name] = values[index];\n return memo;\n }, {})\n };\n }, null);\n}\n\nexport default matchPath;\n","import React from \"react\";\nimport { isValidElementType } from \"react-is\";\nimport PropTypes from \"prop-types\";\nimport invariant from \"tiny-invariant\";\nimport warning from \"tiny-warning\";\n\nimport RouterContext from \"./RouterContext.js\";\nimport matchPath from \"./matchPath.js\";\n\nfunction isEmptyChildren(children) {\n return React.Children.count(children) === 0;\n}\n\nfunction evalChildrenDev(children, props, path) {\n const value = children(props);\n\n warning(\n value !== undefined,\n \"You returned `undefined` from the `children` function of \" +\n `<Route${path ? ` path=\"${path}\"` : \"\"}>, but you ` +\n \"should have returned a React element or `null`\"\n );\n\n return value || null;\n}\n\n/**\n * The public API for matching a single path and rendering.\n */\nclass Route extends React.Component {\n render() {\n return (\n <RouterContext.Consumer>\n {context => {\n invariant(context, \"You should not use <Route> outside a <Router>\");\n\n const location = this.props.location || context.location;\n const match = this.props.computedMatch\n ? this.props.computedMatch // <Switch> already computed the match for us\n : this.props.path\n ? matchPath(location.pathname, this.props)\n : context.match;\n\n const props = { ...context, location, match };\n\n let { children, component, render } = this.props;\n\n // Preact uses an empty array as children by\n // default, so use null if that's the case.\n if (Array.isArray(children) && isEmptyChildren(children)) {\n children = null;\n }\n\n return (\n <RouterContext.Provider value={props}>\n {props.match\n ? children\n ? typeof children === \"function\"\n ? __DEV__\n ? evalChildrenDev(children, props, this.props.path)\n : children(props)\n : children\n : component\n ? React.createElement(component, props)\n : render\n ? render(props)\n : null\n : typeof children === \"function\"\n ? __DEV__\n ? evalChildrenDev(children, props, this.props.path)\n : children(props)\n : null}\n </RouterContext.Provider>\n );\n }}\n </RouterContext.Consumer>\n );\n }\n}\n\nif (__DEV__) {\n Route.propTypes = {\n children: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),\n component: (props, propName) => {\n if (props[propName] && !isValidElementType(props[propName])) {\n return new Error(\n `Invalid prop 'component' supplied to 'Route': the prop is not a valid React component`\n );\n }\n },\n exact: PropTypes.bool,\n location: PropTypes.object,\n path: PropTypes.oneOfType([\n PropTypes.string,\n PropTypes.arrayOf(PropTypes.string)\n ]),\n render: PropTypes.func,\n sensitive: PropTypes.bool,\n strict: PropTypes.bool\n };\n\n Route.prototype.componentDidMount = function() {\n warning(\n !(\n this.props.children &&\n !isEmptyChildren(this.props.children) &&\n this.props.component\n ),\n \"You should not use <Route component> and <Route children> in the same route; <Route component> will be ignored\"\n );\n\n warning(\n !(\n this.props.children &&\n !isEmptyChildren(this.props.children) &&\n this.props.render\n ),\n \"You should not use <Route render> and <Route children> in the same route; <Route render> will be ignored\"\n );\n\n warning(\n !(this.props.component && this.props.render),\n \"You should not use <Route component> and <Route render> in the same route; <Route render> will be ignored\"\n );\n };\n\n Route.prototype.componentDidUpdate = function(prevProps) {\n warning(\n !(this.props.location && !prevProps.location),\n '<Route> elements should not change from uncontrolled to controlled (or vice versa). You initially used no \"location\" prop and then provided one on a subsequent render.'\n );\n\n warning(\n !(!this.props.location && prevProps.location),\n '<Route> elements should not change from controlled to uncontrolled (or vice versa). You provided a \"location\" prop initially but omitted it on a subsequent render.'\n );\n };\n}\n\nexport default Route;\n","import React from \"react\";\nimport PropTypes from \"prop-types\";\nimport { createLocation, createPath } from \"history\";\nimport invariant from \"tiny-invariant\";\nimport warning from \"tiny-warning\";\n\nimport Router from \"./Router.js\";\n\nfunction addLeadingSlash(path) {\n return path.charAt(0) === \"/\" ? path : \"/\" + path;\n}\n\nfunction addBasename(basename, location) {\n if (!basename) return location;\n\n return {\n ...location,\n pathname: addLeadingSlash(basename) + location.pathname\n };\n}\n\nfunction stripBasename(basename, location) {\n if (!basename) return location;\n\n const base = addLeadingSlash(basename);\n\n if (location.pathname.indexOf(base) !== 0) return location;\n\n return {\n ...location,\n pathname: location.pathname.substr(base.length)\n };\n}\n\nfunction createURL(location) {\n return typeof location === \"string\" ? location : createPath(location);\n}\n\nfunction staticHandler(methodName) {\n return () => {\n invariant(false, \"You cannot %s with <StaticRouter>\", methodName);\n };\n}\n\nfunction noop() {}\n\n/**\n * The public top-level API for a \"static\" <Router>, so-called because it\n * can't actually change the current location. Instead, it just records\n * location changes in a context object. Useful mainly in testing and\n * server-rendering scenarios.\n */\nclass StaticRouter extends React.Component {\n navigateTo(location, action) {\n const { basename = \"\", context = {} } = this.props;\n context.action = action;\n context.location = addBasename(basename, createLocation(location));\n context.url = createURL(context.location);\n }\n\n handlePush = location => this.navigateTo(location, \"PUSH\");\n handleReplace = location => this.navigateTo(location, \"REPLACE\");\n handleListen = () => noop;\n handleBlock = () => noop;\n\n render() {\n const { basename = \"\", context = {}, location = \"/\", ...rest } = this.props;\n\n const history = {\n createHref: path => addLeadingSlash(basename + createURL(path)),\n action: \"POP\",\n location: stripBasename(basename, createLocation(location)),\n push: this.handlePush,\n replace: this.handleReplace,\n go: staticHandler(\"go\"),\n goBack: staticHandler(\"goBack\"),\n goForward: staticHandler(\"goForward\"),\n listen: this.handleListen,\n block: this.handleBlock\n };\n\n return <Router {...rest} history={history} staticContext={context} />;\n }\n}\n\nif (__DEV__) {\n StaticRouter.propTypes = {\n basename: PropTypes.string,\n context: PropTypes.object,\n location: PropTypes.oneOfType([PropTypes.string, PropTypes.object])\n };\n\n StaticRouter.prototype.componentDidMount = function() {\n warning(\n !this.props.history,\n \"<StaticRouter> ignores the history prop. To use a custom history, \" +\n \"use `import { Router }` instead of `import { StaticRouter as Router }`.\"\n );\n };\n}\n\nexport default StaticRouter;\n","import React from \"react\";\nimport PropTypes from \"prop-types\";\nimport invariant from \"tiny-invariant\";\nimport warning from \"tiny-warning\";\n\nimport RouterContext from \"./RouterContext.js\";\nimport matchPath from \"./matchPath.js\";\n\n/**\n * The public API for rendering the first <Route> that matches.\n */\nclass Switch extends React.Component {\n render() {\n return (\n <RouterContext.Consumer>\n {context => {\n invariant(context, \"You should not use <Switch> outside a <Router>\");\n\n const location = this.props.location || context.location;\n\n let element, match;\n\n // We use React.Children.forEach instead of React.Children.toArray().find()\n // here because toArray adds keys to all child elements and we do not want\n // to trigger an unmount/remount for two <Route>s that render the same\n // component at different URLs.\n React.Children.forEach(this.props.children, child => {\n if (match == null && React.isValidElement(child)) {\n element = child;\n\n const path = child.props.path || child.props.from;\n\n match = path\n ? matchPath(location.pathname, { ...child.props, path })\n : context.match;\n }\n });\n\n return match\n ? React.cloneElement(element, { location, computedMatch: match })\n : null;\n }}\n </RouterContext.Consumer>\n );\n }\n}\n\nif (__DEV__) {\n Switch.propTypes = {\n children: PropTypes.node,\n location: PropTypes.object\n };\n\n Switch.prototype.componentDidUpdate = function(prevProps) {\n warning(\n !(this.props.location && !prevProps.location),\n '<Switch> elements should not change from uncontrolled to controlled (or vice versa). You initially used no \"location\" prop and then provided one on a subsequent render.'\n );\n\n warning(\n !(!this.props.location && prevProps.location),\n '<Switch> elements should not change from controlled to uncontrolled (or vice versa). You provided a \"location\" prop initially but omitted it on a subsequent render.'\n );\n };\n}\n\nexport default Switch;\n","import React from \"react\";\nimport PropTypes from \"prop-types\";\nimport hoistStatics from \"hoist-non-react-statics\";\nimport invariant from \"tiny-invariant\";\n\nimport RouterContext from \"./RouterContext.js\";\n\n/**\n * A public higher-order component to access the imperative API\n */\nfunction withRouter(Component) {\n const displayName = `withRouter(${Component.displayName || Component.name})`;\n const C = props => {\n const { wrappedComponentRef, ...remainingProps } = props;\n\n return (\n <RouterContext.Consumer>\n {context => {\n invariant(\n context,\n `You should not use <${displayName} /> outside a <Router>`\n );\n return (\n <Component\n {...remainingProps}\n {...context}\n ref={wrappedComponentRef}\n />\n );\n }}\n </RouterContext.Consumer>\n );\n };\n\n C.displayName = displayName;\n C.WrappedComponent = Component;\n\n if (__DEV__) {\n C.propTypes = {\n wrappedComponentRef: PropTypes.oneOfType([\n PropTypes.string,\n PropTypes.func,\n PropTypes.object\n ])\n };\n }\n\n return hoistStatics(C, Component);\n}\n\nexport default withRouter;\n","import React from \"react\";\nimport invariant from \"tiny-invariant\";\n\nimport RouterContext from \"./RouterContext.js\";\nimport HistoryContext from \"./HistoryContext.js\";\nimport matchPath from \"./matchPath.js\";\n\nconst useContext = React.useContext;\n\nexport function useHistory() {\n if (__DEV__) {\n invariant(\n typeof useContext === \"function\",\n \"You must use React >= 16.8 in order to use useHistory()\"\n );\n }\n\n return useContext(HistoryContext);\n}\n\nexport function useLocation() {\n if (__DEV__) {\n invariant(\n typeof useContext === \"function\",\n \"You must use React >= 16.8 in order to use useLocation()\"\n );\n }\n\n return useContext(RouterContext).location;\n}\n\nexport function useParams() {\n if (__DEV__) {\n invariant(\n typeof useContext === \"function\",\n \"You must use React >= 16.8 in order to use useParams()\"\n );\n }\n\n const match = useContext(RouterContext).match;\n return match ? match.params : {};\n}\n\nexport function useRouteMatch(path) {\n if (__DEV__) {\n invariant(\n typeof useContext === \"function\",\n \"You must use React >= 16.8 in order to use useRouteMatch()\"\n );\n }\n\n const location = useLocation();\n const match = useContext(RouterContext).match;\n return path ? matchPath(location.pathname, path) : match;\n}\n"],"names":["MAX_SIGNED_31_BIT_INT","commonjsGlobal","globalThis","window","global","getUniqueId","key","objectIs","x","y","createEventEmitter","value","handlers","on","handler","push","off","filter","h","get","set","newValue","changedBits","forEach","onlyChild","children","Array","isArray","createReactContext","defaultValue","calculateChangedBits","contextProp","Provider","emitter","_this","props","getChildContext","this","componentWillReceiveProps","nextProps","oldValue","render","React","Component","childContextTypes","PropTypes","object","isRequired","Consumer","observedBits","state","_this2","getValue","onUpdate","setState","componentDidMount","context","componentWillUnmount","contextTypes","createContext","createNamedContext","name","displayName","historyContext","Router","location","history","_isMounted","_pendingLocation","staticContext","unlisten","listen","computeRootMatch","pathname","path","url","params","isExact","RouterContext","match","HistoryContext","MemoryRouter","createHistory","Lifecycle","onMount","call","componentDidUpdate","prevProps","onUnmount","Prompt","message","when","invariant","method","block","self","release","cache","cacheLimit","cacheCount","compilePath","generator","pathToRegexp","compile","generatePath","pretty","Redirect","computedMatch","to","replace","createLocation","prevLocation","locationsAreEqual","options","cacheKey","end","strict","sensitive","pathCache","keys","result","regexp","matchPath","exact","concat","reduce","matched","exec","values","memo","index","isEmptyChildren","Children","count","Route","component","createElement","addLeadingSlash","charAt","addBasename","basename","stripBasename","base","indexOf","substr","length","createURL","createPath","staticHandler","methodName","noop","StaticRouter","handlePush","navigateTo","handleReplace","handleListen","handleBlock","action","rest","createHref","go","goBack","goForward","Switch","element","child","isValidElement","from","cloneElement","withRouter","C","wrappedComponentRef","remainingProps","ref","WrappedComponent","hoistStatics","useContext","useHistory","useLocation","useParams","useRouteMatch"],"mappings":"0lCAQA,IAAMA,sBAAwB,WAExBC,eACkB,oBAAfC,WAEHA,WACkB,oBAAXC,OACPA,OACkB,oBAAXC,OACPA,OACA,GAEN,SAASC,kBACHC,EAAM,8BACFL,eAAeK,IAAQL,eAAeK,IAAQ,GAAK,EAK7D,SAASC,SAASC,EAAGC,UACfD,IAAMC,EACK,IAAND,GAAW,EAAIA,GAAM,EAAIC,EAGzBD,GAAMA,GAAKC,GAAMA,EAI5B,SAASC,mBAAmBC,OACtBC,EAAW,SACR,CACLC,YAAGC,GACDF,EAASG,KAAKD,IAGhBE,aAAIF,GACFF,EAAWA,EAASK,OAAO,SAAAC,UAAKA,IAAMJ,KAGxCK,sBACSR,GAGTS,aAAIC,EAAUC,GACZX,EAAQU,EACRT,EAASW,QAAQ,SAAAT,UAAWA,EAAQH,EAAOW,OAKjD,SAASE,UAAUC,UACVC,MAAMC,QAAQF,GAAYA,EAAS,GAAKA,EAGlC,SAASG,mBAAmBC,EAAcC,WACjDC,EAAc,0BAA4B1B,cAAgB,KAE1D2B,sJACJC,QAAUvB,mBAAmBwB,EAAKC,MAAMxB,wDAMxCyB,gBAAA,8BAEKL,GAAcM,KAAKJ,aAIxBK,0BAAA,SAA0BC,MACpBF,KAAKF,MAAMxB,QAAU4B,EAAU5B,MAAO,KAGpCW,EAFAkB,EAAWH,KAAKF,M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,EAA3CwI,oBAAwBC,gCAAmBzI,kCAGjDO,oBAACoC,QAAc9B,cACZ,SAAAQ,UAEGA,GADFoC,cAKElD,oBAACC,cACKiI,EACApH,GACJqH,IAAKF,WAfX7G,iBAA4BnB,EAAUmB,aAAenB,EAAUkB,iBAuBrE6G,EAAE5G,YAAcA,EAChB4G,EAAEI,iBAAmBnI,EAYdoI,aAAaL,EAAG/H,GCxCzB,IAAMqI,WAAatI,MAAMsI,WAEzB,SAAgBC,oBAQPD,WAAWhG,gBAGpB,SAAgBkG,qBAQPF,WAAWlG,SAAeb,SAGnC,SAAgBkH,gBAQRpG,EAAQiG,WAAWlG,SAAeC,aACjCA,EAAQA,EAAMH,OAAS,GAGzB,SAASwG,cAAc1G,OAQtBT,EAAWiH,cACXnG,EAAQiG,WAAWlG,SAAeC,aACjCL,EAAOgD,UAAUzD,EAASQ,SAAUC,GAAQK"}
|
package/esm/react-router.js
CHANGED
|
@@ -3,7 +3,6 @@ import React from 'react';
|
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import { createMemoryHistory, createLocation, locationsAreEqual, createPath } from 'history';
|
|
5
5
|
import warning from 'tiny-warning';
|
|
6
|
-
import createContext from 'mini-create-react-context';
|
|
7
6
|
import invariant from 'tiny-invariant';
|
|
8
7
|
import _extends from '@babel/runtime/helpers/esm/extends';
|
|
9
8
|
import pathToRegexp from 'path-to-regexp';
|
|
@@ -11,6 +10,195 @@ import { isValidElementType } from 'react-is';
|
|
|
11
10
|
import _objectWithoutPropertiesLoose from '@babel/runtime/helpers/esm/objectWithoutPropertiesLoose';
|
|
12
11
|
import hoistStatics from 'hoist-non-react-statics';
|
|
13
12
|
|
|
13
|
+
var MAX_SIGNED_31_BIT_INT = 1073741823;
|
|
14
|
+
var commonjsGlobal = typeof globalThis !== "undefined" // 'global proper'
|
|
15
|
+
? // eslint-disable-next-line no-undef
|
|
16
|
+
globalThis : typeof window !== "undefined" ? window // Browser
|
|
17
|
+
: typeof global !== "undefined" ? global // node.js
|
|
18
|
+
: {};
|
|
19
|
+
|
|
20
|
+
function getUniqueId() {
|
|
21
|
+
var key = "__global_unique_id__";
|
|
22
|
+
return commonjsGlobal[key] = (commonjsGlobal[key] || 0) + 1;
|
|
23
|
+
} // Inlined Object.is polyfill.
|
|
24
|
+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
function objectIs(x, y) {
|
|
28
|
+
if (x === y) {
|
|
29
|
+
return x !== 0 || 1 / x === 1 / y;
|
|
30
|
+
} else {
|
|
31
|
+
// eslint-disable-next-line no-self-compare
|
|
32
|
+
return x !== x && y !== y;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function createEventEmitter(value) {
|
|
37
|
+
var handlers = [];
|
|
38
|
+
return {
|
|
39
|
+
on: function on(handler) {
|
|
40
|
+
handlers.push(handler);
|
|
41
|
+
},
|
|
42
|
+
off: function off(handler) {
|
|
43
|
+
handlers = handlers.filter(function (h) {
|
|
44
|
+
return h !== handler;
|
|
45
|
+
});
|
|
46
|
+
},
|
|
47
|
+
get: function get() {
|
|
48
|
+
return value;
|
|
49
|
+
},
|
|
50
|
+
set: function set(newValue, changedBits) {
|
|
51
|
+
value = newValue;
|
|
52
|
+
handlers.forEach(function (handler) {
|
|
53
|
+
return handler(value, changedBits);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function onlyChild(children) {
|
|
60
|
+
return Array.isArray(children) ? children[0] : children;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function createReactContext(defaultValue, calculateChangedBits) {
|
|
64
|
+
var _Provider$childContex, _Consumer$contextType;
|
|
65
|
+
|
|
66
|
+
var contextProp = "__create-react-context-" + getUniqueId() + "__";
|
|
67
|
+
|
|
68
|
+
var Provider = /*#__PURE__*/function (_React$Component) {
|
|
69
|
+
_inheritsLoose(Provider, _React$Component);
|
|
70
|
+
|
|
71
|
+
function Provider() {
|
|
72
|
+
var _this;
|
|
73
|
+
|
|
74
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
75
|
+
args[_key] = arguments[_key];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
_this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
|
|
79
|
+
_this.emitter = createEventEmitter(_this.props.value);
|
|
80
|
+
return _this;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
var _proto = Provider.prototype;
|
|
84
|
+
|
|
85
|
+
_proto.getChildContext = function getChildContext() {
|
|
86
|
+
var _ref;
|
|
87
|
+
|
|
88
|
+
return _ref = {}, _ref[contextProp] = this.emitter, _ref;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
_proto.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
|
|
92
|
+
if (this.props.value !== nextProps.value) {
|
|
93
|
+
var oldValue = this.props.value;
|
|
94
|
+
var newValue = nextProps.value;
|
|
95
|
+
var changedBits;
|
|
96
|
+
|
|
97
|
+
if (objectIs(oldValue, newValue)) {
|
|
98
|
+
changedBits = 0; // No change
|
|
99
|
+
} else {
|
|
100
|
+
changedBits = typeof calculateChangedBits === "function" ? calculateChangedBits(oldValue, newValue) : MAX_SIGNED_31_BIT_INT;
|
|
101
|
+
|
|
102
|
+
if (process.env.NODE_ENV !== "production") {
|
|
103
|
+
process.env.NODE_ENV !== "production" ? warning((changedBits & MAX_SIGNED_31_BIT_INT) === changedBits, "calculateChangedBits: Expected the return value to be a " + "31-bit integer. Instead received: " + changedBits) : void 0;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
changedBits |= 0;
|
|
107
|
+
|
|
108
|
+
if (changedBits !== 0) {
|
|
109
|
+
this.emitter.set(nextProps.value, changedBits);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
_proto.render = function render() {
|
|
116
|
+
return this.props.children;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
return Provider;
|
|
120
|
+
}(React.Component);
|
|
121
|
+
|
|
122
|
+
Provider.childContextTypes = (_Provider$childContex = {}, _Provider$childContex[contextProp] = PropTypes.object.isRequired, _Provider$childContex);
|
|
123
|
+
|
|
124
|
+
var Consumer = /*#__PURE__*/function (_React$Component2) {
|
|
125
|
+
_inheritsLoose(Consumer, _React$Component2);
|
|
126
|
+
|
|
127
|
+
function Consumer() {
|
|
128
|
+
var _this2;
|
|
129
|
+
|
|
130
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
131
|
+
args[_key2] = arguments[_key2];
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
_this2 = _React$Component2.call.apply(_React$Component2, [this].concat(args)) || this;
|
|
135
|
+
_this2.observedBits = void 0;
|
|
136
|
+
_this2.state = {
|
|
137
|
+
value: _this2.getValue()
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
_this2.onUpdate = function (newValue, changedBits) {
|
|
141
|
+
var observedBits = _this2.observedBits | 0;
|
|
142
|
+
|
|
143
|
+
if ((observedBits & changedBits) !== 0) {
|
|
144
|
+
_this2.setState({
|
|
145
|
+
value: _this2.getValue()
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
return _this2;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
var _proto2 = Consumer.prototype;
|
|
154
|
+
|
|
155
|
+
_proto2.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
|
|
156
|
+
var observedBits = nextProps.observedBits;
|
|
157
|
+
this.observedBits = observedBits === undefined || observedBits === null ? MAX_SIGNED_31_BIT_INT // Subscribe to all changes by default
|
|
158
|
+
: observedBits;
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
_proto2.componentDidMount = function componentDidMount() {
|
|
162
|
+
if (this.context[contextProp]) {
|
|
163
|
+
this.context[contextProp].on(this.onUpdate);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
var observedBits = this.props.observedBits;
|
|
167
|
+
this.observedBits = observedBits === undefined || observedBits === null ? MAX_SIGNED_31_BIT_INT // Subscribe to all changes by default
|
|
168
|
+
: observedBits;
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
_proto2.componentWillUnmount = function componentWillUnmount() {
|
|
172
|
+
if (this.context[contextProp]) {
|
|
173
|
+
this.context[contextProp].off(this.onUpdate);
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
_proto2.getValue = function getValue() {
|
|
178
|
+
if (this.context[contextProp]) {
|
|
179
|
+
return this.context[contextProp].get();
|
|
180
|
+
} else {
|
|
181
|
+
return defaultValue;
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
_proto2.render = function render() {
|
|
186
|
+
return onlyChild(this.props.children)(this.state.value);
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
return Consumer;
|
|
190
|
+
}(React.Component);
|
|
191
|
+
|
|
192
|
+
Consumer.contextTypes = (_Consumer$contextType = {}, _Consumer$contextType[contextProp] = PropTypes.object, _Consumer$contextType);
|
|
193
|
+
return {
|
|
194
|
+
Provider: Provider,
|
|
195
|
+
Consumer: Consumer
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// MIT License
|
|
200
|
+
var createContext = React.createContext || createReactContext;
|
|
201
|
+
|
|
14
202
|
// TODO: Replace with React.createContext once we can assume React 16+
|
|
15
203
|
|
|
16
204
|
var createNamedContext = function createNamedContext(name) {
|
|
@@ -738,7 +926,7 @@ function useRouteMatch(path) {
|
|
|
738
926
|
|
|
739
927
|
if (process.env.NODE_ENV !== "production") {
|
|
740
928
|
if (typeof window !== "undefined") {
|
|
741
|
-
var global = window;
|
|
929
|
+
var global$1 = window;
|
|
742
930
|
var key = "__react_router_build__";
|
|
743
931
|
var buildNames = {
|
|
744
932
|
cjs: "CommonJS",
|
|
@@ -746,15 +934,15 @@ if (process.env.NODE_ENV !== "production") {
|
|
|
746
934
|
umd: "UMD"
|
|
747
935
|
};
|
|
748
936
|
|
|
749
|
-
if (global[key] && global[key] !== "esm") {
|
|
750
|
-
var initialBuildName = buildNames[global[key]];
|
|
937
|
+
if (global$1[key] && global$1[key] !== "esm") {
|
|
938
|
+
var initialBuildName = buildNames[global$1[key]];
|
|
751
939
|
var secondaryBuildName = buildNames["esm"]; // TODO: Add link to article that explains in detail how to avoid
|
|
752
940
|
// loading 2 different builds.
|
|
753
941
|
|
|
754
942
|
throw new Error("You are loading the " + secondaryBuildName + " build of React Router " + ("on a page that is already running the " + initialBuildName + " ") + "build, so things won't work right.");
|
|
755
943
|
}
|
|
756
944
|
|
|
757
|
-
global[key] = "esm";
|
|
945
|
+
global$1[key] = "esm";
|
|
758
946
|
}
|
|
759
947
|
}
|
|
760
948
|
|