Second frontend, written in Next.JS + Typescript.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

1 lines
70 KiB

{"ast":null,"code":"\"use strict\";\n\nvar _regeneratorRuntime = require(\"@babel/runtime/regenerator\");\n\nvar _slicedToArray = require(\"@babel/runtime/helpers/slicedToArray\");\n\nvar _classCallCheck = require(\"@babel/runtime/helpers/classCallCheck\");\n\nvar _createClass = require(\"@babel/runtime/helpers/createClass\");\n\nvar __importDefault = this && this.__importDefault || function (mod) {\n return mod && mod.__esModule ? mod : {\n \"default\": mod\n };\n};\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar url_1 = require(\"url\");\n\nvar mitt_1 = __importDefault(require(\"../mitt\"));\n\nvar utils_1 = require(\"../utils\");\n\nvar is_dynamic_1 = require(\"./utils/is-dynamic\");\n\nvar route_matcher_1 = require(\"./utils/route-matcher\");\n\nvar route_regex_1 = require(\"./utils/route-regex\");\n\nvar basePath = process.env.__NEXT_ROUTER_BASEPATH || '';\n\nfunction addBasePath(path) {\n return path.indexOf(basePath) !== 0 ? basePath + path : path;\n}\n\nexports.addBasePath = addBasePath;\n\nfunction delBasePath(path) {\n return path.indexOf(basePath) === 0 ? path.substr(basePath.length) || '/' : path;\n}\n\nfunction toRoute(path) {\n return path.replace(/\\/$/, '') || '/';\n}\n\nvar prepareRoute = function prepareRoute(path) {\n return toRoute(!path || path === '/' ? '/index' : path);\n};\n\nfunction fetchNextData(pathname, query, isServerRender, cb) {\n var attempts = isServerRender ? 3 : 1;\n\n function getResponse() {\n return fetch(utils_1.formatWithValidation({\n // @ts-ignore __NEXT_DATA__\n pathname: \"/_next/data/\".concat(__NEXT_DATA__.buildId).concat(pathname, \".json\"),\n query: query\n }), {\n // Cookies are required to be present for Next.js' SSG \"Preview Mode\".\n // Cookies may also be required for `getServerSideProps`.\n //\n // > `fetch` won’t send cookies, unless you set the credentials init\n // > option.\n // https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch\n //\n // > For maximum browser compatibility when it comes to sending &\n // > receiving cookies, always supply the `credentials: 'same-origin'`\n // > option instead of relying on the default.\n // https://github.com/github/fetch#caveats\n credentials: 'same-origin'\n }).then(function (res) {\n if (!res.ok) {\n if (--attempts > 0 && res.status >= 500) {\n return getResponse();\n }\n\n throw new Error(\"Failed to load static props\");\n }\n\n return res.json();\n });\n }\n\n return getResponse().then(function (data) {\n return cb ? cb(data) : data;\n })[\"catch\"](function (err) {\n // We should only trigger a server-side transition if this was caused\n // on a client-side transition. Otherwise, we'd get into an infinite\n // loop.\n if (!isServerRender) {\n ;\n err.code = 'PAGE_LOAD_ERROR';\n }\n\n throw err;\n });\n}\n\nvar Router = /*#__PURE__*/function () {\n function Router(pathname, query, as, _ref) {\n var _this = this;\n\n var initialProps = _ref.initialProps,\n pageLoader = _ref.pageLoader,\n App = _ref.App,\n wrapApp = _ref.wrapApp,\n Component = _ref.Component,\n err = _ref.err,\n subscription = _ref.subscription,\n isFallback = _ref.isFallback;\n\n _classCallCheck(this, Router);\n\n // Static Data Cache\n this.sdc = {};\n\n this.onPopState = function (e) {\n if (!e.state) {\n // We get state as undefined for two reasons.\n // 1. With older safari (< 8) and older chrome (< 34)\n // 2. When the URL changed with #\n //\n // In the both cases, we don't need to proceed and change the route.\n // (as it's already changed)\n // But we can simply replace the state with the new changes.\n // Actually, for (1) we don't need to nothing. But it's hard to detect that event.\n // So, doing the following for (1) does no harm.\n var _pathname = _this.pathname,\n _query = _this.query;\n\n _this.changeState('replaceState', utils_1.formatWithValidation({\n pathname: _pathname,\n query: _query\n }), utils_1.getURL());\n\n return;\n } // Make sure we don't re-render on initial load,\n // can be caused by navigating back from an external site\n\n\n if (e.state && _this.isSsr && e.state.as === _this.asPath && url_1.parse(e.state.url).pathname === _this.pathname) {\n return;\n } // If the downstream application returns falsy, return.\n // They will then be responsible for handling the event.\n\n\n if (_this._bps && !_this._bps(e.state)) {\n return;\n }\n\n var _e$state = e.state,\n url = _e$state.url,\n as = _e$state.as,\n options = _e$state.options;\n\n if (true) {\n if (typeof url === 'undefined' || typeof as === 'undefined') {\n console.warn('`popstate` event triggered but `event.state` did not have `url` or `as` https://err.sh/zeit/next.js/popstate-state-empty');\n }\n }\n\n _this.replace(url, as, options);\n };\n\n this._getStaticData = function (asPath) {\n var pathname = prepareRoute(url_1.parse(asPath).pathname);\n return false && _this.sdc[pathname] ? Promise.resolve(_this.sdc[pathname]) : fetchNextData(pathname, null, _this.isSsr, function (data) {\n return _this.sdc[pathname] = data;\n });\n };\n\n this._getServerData = function (asPath) {\n var _url_1$parse = url_1.parse(asPath, true),\n pathname = _url_1$parse.pathname,\n query = _url_1$parse.query;\n\n pathname = prepareRoute(pathname);\n return fetchNextData(pathname, query, _this.isSsr);\n }; // represents the current component key\n\n\n this.route = toRoute(pathname); // set up the component cache (by route keys)\n\n this.components = {}; // We should not keep the cache, if there's an error\n // Otherwise, this cause issues when when going back and\n // come again to the errored page.\n\n if (pathname !== '/_error') {\n this.components[this.route] = {\n Component: Component,\n props: initialProps,\n err: err,\n __N_SSG: initialProps && initialProps.__N_SSG,\n __N_SSP: initialProps && initialProps.__N_SSP\n };\n }\n\n this.components['/_app'] = {\n Component: App\n }; // Backwards compat for Router.router.events\n // TODO: Should be remove the following major version as it was never documented\n\n this.events = Router.events;\n this.pageLoader = pageLoader;\n this.pathname = pathname;\n this.query = query; // if auto prerendered and dynamic route wait to update asPath\n // until after mount to prevent hydration mismatch\n\n this.asPath = // @ts-ignore this is temporarily global (attached to window)\n is_dynamic_1.isDynamicRoute(pathname) && __NEXT_DATA__.autoExport ? pathname : as;\n this.basePath = basePath;\n this.sub = subscription;\n this.clc = null;\n this._wrapApp = wrapApp; // make sure to ignore extra popState in safari on navigating\n // back from external site\n\n this.isSsr = true;\n this.isFallback = isFallback;\n\n if (true) {\n // in order for `e.state` to work on the `onpopstate` event\n // we have to register the initial route upon initialization\n this.changeState('replaceState', utils_1.formatWithValidation({\n pathname: pathname,\n query: query\n }), as);\n window.addEventListener('popstate', this.onPopState);\n }\n } // @deprecated backwards compatibility even though it's a private method.\n\n\n _createClass(Router, [{\n key: \"update\",\n value: function update(route, mod) {\n var Component = mod[\"default\"] || mod;\n var data = this.components[route];\n\n if (!data) {\n throw new Error(\"Cannot update unavailable route: \".concat(route));\n }\n\n var newData = Object.assign(Object.assign({}, data), {\n Component: Component,\n __N_SSG: mod.__N_SSG,\n __N_SSP: mod.__N_SSP\n });\n this.components[route] = newData; // pages/_app.js updated\n\n if (route === '/_app') {\n this.notify(this.components[this.route]);\n return;\n }\n\n if (route === this.route) {\n this.notify(newData);\n }\n }\n }, {\n key: \"reload\",\n value: function reload() {\n window.location.reload();\n }\n /**\n * Go back in history\n */\n\n }, {\n key: \"back\",\n value: function back() {\n window.history.back();\n }\n /**\n * Performs a `pushState` with arguments\n * @param url of the route\n * @param as masks `url` for the browser\n * @param options object you can define `shallow` and other options\n */\n\n }, {\n key: \"push\",\n value: function push(url) {\n var as = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : url;\n var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n return this.change('pushState', url, as, options);\n }\n /**\n * Performs a `replaceState` with arguments\n * @param url of the route\n * @param as masks `url` for the browser\n * @param options object you can define `shallow` and other options\n */\n\n }, {\n key: \"replace\",\n value: function replace(url) {\n var as = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : url;\n var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n return this.change('replaceState', url, as, options);\n }\n }, {\n key: \"change\",\n value: function change(method, _url, _as, options) {\n var _this2 = this;\n\n return new Promise(function (resolve, reject) {\n if (!options._h) {\n _this2.isSsr = false;\n } // marking route changes as a navigation start entry\n\n\n if (utils_1.ST) {\n performance.mark('routeChange');\n } // If url and as provided as an object representation,\n // we'll format them into the string version here.\n\n\n var url = typeof _url === 'object' ? utils_1.formatWithValidation(_url) : _url;\n var as = typeof _as === 'object' ? utils_1.formatWithValidation(_as) : _as;\n url = addBasePath(url);\n as = addBasePath(as); // Add the ending slash to the paths. So, we can serve the\n // \"<page>/index.html\" directly for the SSR page.\n\n if (process.env.__NEXT_EXPORT_TRAILING_SLASH) {\n var rewriteUrlForNextExport = require('./rewrite-url-for-export').rewriteUrlForNextExport; // @ts-ignore this is temporarily global (attached to window)\n\n\n if (__NEXT_DATA__.nextExport) {\n as = rewriteUrlForNextExport(as);\n }\n }\n\n _this2.abortComponentLoad(as); // If the url change is only related to a hash change\n // We should not proceed. We should only change the state.\n // WARNING: `_h` is an internal option for handing Next.js client-side\n // hydration. Your app should _never_ use this property. It may change at\n // any time without notice.\n\n\n if (!options._h && _this2.onlyAHashChange(as)) {\n _this2.asPath = as;\n Router.events.emit('hashChangeStart', as);\n\n _this2.changeState(method, url, as, options);\n\n _this2.scrollToHash(as);\n\n Router.events.emit('hashChangeComplete', as);\n return resolve(true);\n }\n\n var _url_1$parse2 = url_1.parse(url, true),\n pathname = _url_1$parse2.pathname,\n query = _url_1$parse2.query,\n protocol = _url_1$parse2.protocol;\n\n if (!pathname || protocol) {\n if (true) {\n throw new Error(\"Invalid href passed to router: \".concat(url, \" https://err.sh/zeit/next.js/invalid-href-passed\"));\n }\n\n return resolve(false);\n } // If asked to change the current URL we should reload the current page\n // (not location.reload() but reload getInitialProps and other Next.js stuffs)\n // We also need to set the method = replaceState always\n // as this should not go into the history (That's how browsers work)\n // We should compare the new asPath to the current asPath, not the url\n\n\n if (!_this2.urlIsNew(as)) {\n method = 'replaceState';\n }\n\n var route = toRoute(pathname);\n var _options$shallow = options.shallow,\n shallow = _options$shallow === void 0 ? false : _options$shallow;\n\n if (is_dynamic_1.isDynamicRoute(route)) {\n var _url_1$parse3 = url_1.parse(as),\n asPathname = _url_1$parse3.pathname;\n\n var routeRegex = route_regex_1.getRouteRegex(route);\n var routeMatch = route_matcher_1.getRouteMatcher(routeRegex)(asPathname);\n\n if (!routeMatch) {\n var missingParams = Object.keys(routeRegex.groups).filter(function (param) {\n return !query[param];\n });\n\n if (missingParams.length > 0) {\n if (true) {\n console.warn(\"Mismatching `as` and `href` failed to manually provide \" + \"the params: \".concat(missingParams.join(', '), \" in the `href`'s `query`\"));\n }\n\n return reject(new Error(\"The provided `as` value (\".concat(asPathname, \") is incompatible with the `href` value (\").concat(route, \"). \") + \"Read more: https://err.sh/zeit/next.js/incompatible-href-as\"));\n }\n } else {\n // Merge params into `query`, overwriting any specified in search\n Object.assign(query, routeMatch);\n }\n }\n\n Router.events.emit('routeChangeStart', as); // If shallow is true and the route exists in the router cache we reuse the previous result\n\n _this2.getRouteInfo(route, pathname, query, as, shallow).then(function (routeInfo) {\n var error = routeInfo.error;\n\n if (error && error.cancelled) {\n return resolve(false);\n }\n\n Router.events.emit('beforeHistoryChange', as);\n\n _this2.changeState(method, url, as, options);\n\n if (true) {\n var appComp = _this2.components['/_app'].Component;\n window.next.isPrerendered = appComp.getInitialProps === appComp.origGetInitialProps && !routeInfo.Component.getInitialProps;\n }\n\n _this2.set(route, pathname, query, as, routeInfo);\n\n if (error) {\n Router.events.emit('routeChangeError', error, as);\n throw error;\n }\n\n Router.events.emit('routeChangeComplete', as);\n return resolve(true);\n }, reject);\n });\n }\n }, {\n key: \"changeState\",\n value: function changeState(method, url, as) {\n var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};\n\n if (true) {\n if (typeof window.history === 'undefined') {\n console.error(\"Warning: window.history is not available.\");\n return;\n }\n\n if (typeof window.history[method] === 'undefined') {\n console.error(\"Warning: window.history.\".concat(method, \" is not available\"));\n return;\n }\n }\n\n if (method !== 'pushState' || utils_1.getURL() !== as) {\n window.history[method]({\n url: url,\n as: as,\n options: options\n }, // Most browsers currently ignores this parameter, although they may use it in the future.\n // Passing the empty string here should be safe against future changes to the method.\n // https://developer.mozilla.org/en-US/docs/Web/API/History/replaceState\n '', as);\n }\n }\n }, {\n key: \"getRouteInfo\",\n value: function getRouteInfo(route, pathname, query, as) {\n var _this3 = this;\n\n var shallow = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;\n var cachedRouteInfo = this.components[route]; // If there is a shallow route transition possible\n // If the route is already rendered on the screen.\n\n if (shallow && cachedRouteInfo && this.route === route) {\n return Promise.resolve(cachedRouteInfo);\n }\n\n var handleError = function handleError(err, loadErrorFail) {\n return new Promise(function (resolve) {\n if (err.code === 'PAGE_LOAD_ERROR' || loadErrorFail) {\n // If we can't load the page it could be one of following reasons\n // 1. Page doesn't exists\n // 2. Page does exist in a different zone\n // 3. Internal error while loading the page\n // So, doing a hard reload is the proper way to deal with this.\n window.location.href = as; // Changing the URL doesn't block executing the current code path.\n // So, we need to mark it as a cancelled error and stop the routing logic.\n\n err.cancelled = true; // @ts-ignore TODO: fix the control flow here\n\n return resolve({\n error: err\n });\n }\n\n if (err.cancelled) {\n // @ts-ignore TODO: fix the control flow here\n return resolve({\n error: err\n });\n }\n\n resolve(_this3.fetchComponent('/_error').then(function (res) {\n var Component = res.page;\n var routeInfo = {\n Component: Component,\n err: err\n };\n return new Promise(function (resolve) {\n _this3.getInitialProps(Component, {\n err: err,\n pathname: pathname,\n query: query\n }).then(function (props) {\n routeInfo.props = props;\n routeInfo.error = err;\n resolve(routeInfo);\n }, function (gipErr) {\n console.error('Error in error page `getInitialProps`: ', gipErr);\n routeInfo.error = err;\n routeInfo.props = {};\n resolve(routeInfo);\n });\n });\n })[\"catch\"](function (err) {\n return handleError(err, true);\n }));\n });\n };\n\n return new Promise(function (resolve, reject) {\n if (cachedRouteInfo) {\n return resolve(cachedRouteInfo);\n }\n\n _this3.fetchComponent(route).then(function (res) {\n return resolve({\n Component: res.page,\n __N_SSG: res.mod.__N_SSG,\n __N_SSP: res.mod.__N_SSP\n });\n }, reject);\n }).then(function (routeInfo) {\n var Component = routeInfo.Component,\n __N_SSG = routeInfo.__N_SSG,\n __N_SSP = routeInfo.__N_SSP;\n\n if (true) {\n var _require = require('react-is'),\n isValidElementType = _require.isValidElementType;\n\n if (!isValidElementType(Component)) {\n throw new Error(\"The default export is not a React Component in page: \\\"\".concat(pathname, \"\\\"\"));\n }\n }\n\n return _this3._getData(function () {\n return __N_SSG ? _this3._getStaticData(as) : __N_SSP ? _this3._getServerData(as) : _this3.getInitialProps(Component, // we provide AppTree later so this needs to be `any`\n {\n pathname: pathname,\n query: query,\n asPath: as\n });\n }).then(function (props) {\n routeInfo.props = props;\n _this3.components[route] = routeInfo;\n return routeInfo;\n });\n })[\"catch\"](handleError);\n }\n }, {\n key: \"set\",\n value: function set(route, pathname, query, as, data) {\n this.isFallback = false;\n this.route = route;\n this.pathname = pathname;\n this.query = query;\n this.asPath = as;\n this.notify(data);\n }\n /**\n * Callback to execute before replacing router state\n * @param cb callback to be executed\n */\n\n }, {\n key: \"beforePopState\",\n value: function beforePopState(cb) {\n this._bps = cb;\n }\n }, {\n key: \"onlyAHashChange\",\n value: function onlyAHashChange(as) {\n if (!this.asPath) return false;\n\n var _this$asPath$split = this.asPath.split('#'),\n _this$asPath$split2 = _slicedToArray(_this$asPath$split, 2),\n oldUrlNoHash = _this$asPath$split2[0],\n oldHash = _this$asPath$split2[1];\n\n var _as$split = as.split('#'),\n _as$split2 = _slicedToArray(_as$split, 2),\n newUrlNoHash = _as$split2[0],\n newHash = _as$split2[1]; // Makes sure we scroll to the provided hash if the url/hash are the same\n\n\n if (newHash && oldUrlNoHash === newUrlNoHash && oldHash === newHash) {\n return true;\n } // If the urls are change, there's more than a hash change\n\n\n if (oldUrlNoHash !== newUrlNoHash) {\n return false;\n } // If the hash has changed, then it's a hash only change.\n // This check is necessary to handle both the enter and\n // leave hash === '' cases. The identity case falls through\n // and is treated as a next reload.\n\n\n return oldHash !== newHash;\n }\n }, {\n key: \"scrollToHash\",\n value: function scrollToHash(as) {\n var _as$split3 = as.split('#'),\n _as$split4 = _slicedToArray(_as$split3, 2),\n hash = _as$split4[1]; // Scroll to top if the hash is just `#` with no value\n\n\n if (hash === '') {\n window.scrollTo(0, 0);\n return;\n } // First we check if the element by id is found\n\n\n var idEl = document.getElementById(hash);\n\n if (idEl) {\n idEl.scrollIntoView();\n return;\n } // If there's no element with the id, we check the `name` property\n // To mirror browsers\n\n\n var nameEl = document.getElementsByName(hash)[0];\n\n if (nameEl) {\n nameEl.scrollIntoView();\n }\n }\n }, {\n key: \"urlIsNew\",\n value: function urlIsNew(asPath) {\n return this.asPath !== asPath;\n }\n /**\n * Prefetch page code, you may wait for the data during page rendering.\n * This feature only works in production!\n * @param url the href of prefetched page\n * @param asPath the as path of the prefetched page\n */\n\n }, {\n key: \"prefetch\",\n value: function prefetch(url) {\n var _this4 = this;\n\n var asPath = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : url;\n var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n return new Promise(function (resolve, reject) {\n var _url_1$parse4 = url_1.parse(url),\n pathname = _url_1$parse4.pathname,\n protocol = _url_1$parse4.protocol;\n\n if (!pathname || protocol) {\n if (true) {\n throw new Error(\"Invalid href passed to router: \".concat(url, \" https://err.sh/zeit/next.js/invalid-href-passed\"));\n }\n\n return;\n } // Prefetch is not supported in development mode because it would trigger on-demand-entries\n\n\n if (true) {\n return;\n }\n\n var route = delBasePath(toRoute(pathname));\n Promise.all([_this4.pageLoader.prefetchData(url, delBasePath(asPath)), _this4.pageLoader[options.priority ? 'loadPage' : 'prefetch'](route)]).then(function () {\n return resolve();\n }, reject);\n });\n }\n }, {\n key: \"fetchComponent\",\n value: function fetchComponent(route) {\n var cancelled, cancel, componentResult, error;\n return _regeneratorRuntime.async(function fetchComponent$(_context) {\n while (1) {\n switch (_context.prev = _context.next) {\n case 0:\n cancelled = false;\n\n cancel = this.clc = function () {\n cancelled = true;\n };\n\n route = delBasePath(route);\n _context.next = 5;\n return _regeneratorRuntime.awrap(this.pageLoader.loadPage(route));\n\n case 5:\n componentResult = _context.sent;\n\n if (!cancelled) {\n _context.next = 10;\n break;\n }\n\n error = new Error(\"Abort fetching component for route: \\\"\".concat(route, \"\\\"\"));\n error.cancelled = true;\n throw error;\n\n case 10:\n if (cancel === this.clc) {\n this.clc = null;\n }\n\n return _context.abrupt(\"return\", componentResult);\n\n case 12:\n case \"end\":\n return _context.stop();\n }\n }\n }, null, this, null, Promise);\n }\n }, {\n key: \"_getData\",\n value: function _getData(fn) {\n var _this5 = this;\n\n var cancelled = false;\n\n var cancel = function cancel() {\n cancelled = true;\n };\n\n this.clc = cancel;\n return fn().then(function (data) {\n if (cancel === _this5.clc) {\n _this5.clc = null;\n }\n\n if (cancelled) {\n var err = new Error('Loading initial props cancelled');\n err.cancelled = true;\n throw err;\n }\n\n return data;\n });\n }\n }, {\n key: \"getInitialProps\",\n value: function getInitialProps(Component, ctx) {\n var App = this.components['/_app'].Component;\n\n var AppTree = this._wrapApp(App);\n\n ctx.AppTree = AppTree;\n return utils_1.loadGetInitialProps(App, {\n AppTree: AppTree,\n Component: Component,\n router: this,\n ctx: ctx\n });\n }\n }, {\n key: \"abortComponentLoad\",\n value: function abortComponentLoad(as) {\n if (this.clc) {\n var e = new Error('Route Cancelled');\n e.cancelled = true;\n Router.events.emit('routeChangeError', e, as);\n this.clc();\n this.clc = null;\n }\n }\n }, {\n key: \"notify\",\n value: function notify(data) {\n this.sub(data, this.components['/_app'].Component);\n }\n }], [{\n key: \"_rewriteUrlForNextExport\",\n value: function _rewriteUrlForNextExport(url) {\n if (process.env.__NEXT_EXPORT_TRAILING_SLASH) {\n var rewriteUrlForNextExport = require('./rewrite-url-for-export').rewriteUrlForNextExport;\n\n return rewriteUrlForNextExport(url);\n } else {\n return url;\n }\n }\n }]);\n\n return Router;\n}();\n\nexports[\"default\"] = Router;\nRouter.events = mitt_1[\"default\"]();","map":{"version":3,"sources":["/home/gisle/projects/react/rpdata-frontend2/node_modules/next/dist/next-server/lib/router/router.js"],"names":["__importDefault","mod","__esModule","Object","defineProperty","exports","value","url_1","require","mitt_1","utils_1","is_dynamic_1","route_matcher_1","route_regex_1","basePath","process","env","__NEXT_ROUTER_BASEPATH","addBasePath","path","indexOf","delBasePath","substr","length","toRoute","replace","prepareRoute","fetchNextData","pathname","query","isServerRender","cb","attempts","getResponse","fetch","formatWithValidation","__NEXT_DATA__","buildId","credentials","then","res","ok","status","Error","json","data","err","code","Router","as","initialProps","pageLoader","App","wrapApp","Component","subscription","isFallback","sdc","onPopState","e","state","changeState","getURL","isSsr","asPath","parse","url","_bps","options","console","warn","_getStaticData","Promise","resolve","_getServerData","route","components","props","__N_SSG","__N_SSP","events","isDynamicRoute","autoExport","sub","clc","_wrapApp","window","addEventListener","newData","assign","notify","location","reload","history","back","change","method","_url","_as","reject","_h","ST","performance","mark","__NEXT_EXPORT_TRAILING_SLASH","rewriteUrlForNextExport","nextExport","abortComponentLoad","onlyAHashChange","emit","scrollToHash","protocol","urlIsNew","shallow","asPathname","routeRegex","getRouteRegex","routeMatch","getRouteMatcher","missingParams","keys","groups","filter","param","join","getRouteInfo","routeInfo","error","cancelled","appComp","next","isPrerendered","getInitialProps","origGetInitialProps","set","cachedRouteInfo","handleError","loadErrorFail","href","fetchComponent","page","gipErr","isValidElementType","_getData","split","oldUrlNoHash","oldHash","newUrlNoHash","newHash","hash","scrollTo","idEl","document","getElementById","scrollIntoView","nameEl","getElementsByName","all","prefetchData","priority","cancel","loadPage","componentResult","fn","ctx","AppTree","loadGetInitialProps","router"],"mappings":"AAAA;;;;;;;;;;AACA,IAAIA,eAAe,GAAI,QAAQ,KAAKA,eAAd,IAAkC,UAAUC,GAAV,EAAe;AACnE,SAAQA,GAAG,IAAIA,GAAG,CAACC,UAAZ,GAA0BD,GAA1B,GAAgC;AAAE,eAAWA;AAAb,GAAvC;AACH,CAFD;;AAGAE,MAAM,CAACC,cAAP,CAAsBC,OAAtB,EAA+B,YAA/B,EAA6C;AAAEC,EAAAA,KAAK,EAAE;AAAT,CAA7C;;AACA,IAAMC,KAAK,GAAGC,OAAO,CAAC,KAAD,CAArB;;AACA,IAAMC,MAAM,GAAGT,eAAe,CAACQ,OAAO,CAAC,SAAD,CAAR,CAA9B;;AACA,IAAME,OAAO,GAAGF,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aAAKmC,GAAL;AACA,aAAKA,GAAL,GAAW,IAAX;AACH;AACJ;;;2BACMvC,I,EAAM;AACT,WAAKsC,GAAL,CAAStC,IAAT,EAAe,KAAK+B,UAAL,CAAgB,OAAhB,EAAyBtB,SAAxC;AACH;;;6CApZ+BY,G,EAAK;AACjC,UAAInD,OAAO,CAACC,GAAR,CAAYwF,4BAAhB,EAA8C;AAC1C,YAAMC,uBAAuB,GAAGjG,OAAO,CAAC,0BAAD,CAAP,CAC3BiG,uBADL;;AAEA,eAAOA,uBAAuB,CAACvC,GAAD,CAA9B;AACH,OAJD,MAKK;AACD,eAAOA,GAAP;AACH;AACJ;;;;;;AA6YL7D,OAAO,WAAP,GAAkB2C,MAAlB;AACAA,MAAM,CAACgC,MAAP,GAAgBvE,MAAM,WAAN,EAAhB","sourcesContent":["\"use strict\";\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nconst url_1 = require(\"url\");\nconst mitt_1 = __importDefault(require(\"../mitt\"));\nconst utils_1 = require(\"../utils\");\nconst is_dynamic_1 = require(\"./utils/is-dynamic\");\nconst route_matcher_1 = require(\"./utils/route-matcher\");\nconst route_regex_1 = require(\"./utils/route-regex\");\nconst basePath = process.env.__NEXT_ROUTER_BASEPATH || '';\nfunction addBasePath(path) {\n return path.indexOf(basePath) !== 0 ? basePath + path : path;\n}\nexports.addBasePath = addBasePath;\nfunction delBasePath(path) {\n return path.indexOf(basePath) === 0\n ? path.substr(basePath.length) || '/'\n : path;\n}\nfunction toRoute(path) {\n return path.replace(/\\/$/, '') || '/';\n}\nconst prepareRoute = (path) => toRoute(!path || path === '/' ? '/index' : path);\nfunction fetchNextData(pathname, query, isServerRender, cb) {\n let attempts = isServerRender ? 3 : 1;\n function getResponse() {\n return fetch(utils_1.formatWithValidation({\n // @ts-ignore __NEXT_DATA__\n pathname: `/_next/data/${__NEXT_DATA__.buildId}${pathname}.json`,\n query,\n }), {\n // Cookies are required to be present for Next.js' SSG \"Preview Mode\".\n // Cookies may also be required for `getServerSideProps`.\n //\n // > `fetch` won’t send cookies, unless you set the credentials init\n // > option.\n // https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch\n //\n // > For maximum browser compatibility when it comes to sending &\n // > receiving cookies, always supply the `credentials: 'same-origin'`\n // > option instead of relying on the default.\n // https://github.com/github/fetch#caveats\n credentials: 'same-origin',\n }).then(res => {\n if (!res.ok) {\n if (--attempts > 0 && res.status >= 500) {\n return getResponse();\n }\n throw new Error(`Failed to load static props`);\n }\n return res.json();\n });\n }\n return getResponse()\n .then(data => {\n return cb ? cb(data) : data;\n })\n .catch((err) => {\n // We should only trigger a server-side transition if this was caused\n // on a client-side transition. Otherwise, we'd get into an infinite\n // loop.\n if (!isServerRender) {\n ;\n err.code = 'PAGE_LOAD_ERROR';\n }\n throw err;\n });\n}\nclass Router {\n constructor(pathname, query, as, { initialProps, pageLoader, App, wrapApp, Component, err, subscription, isFallback, }) {\n // Static Data Cache\n this.sdc = {};\n this.onPopState = (e) => {\n if (!e.state) {\n // We get state as undefined for two reasons.\n // 1. With older safari (< 8) and older chrome (< 34)\n // 2. When the URL changed with #\n //\n // In the both cases, we don't need to proceed and change the route.\n // (as it's already changed)\n // But we can simply replace the state with the new changes.\n // Actually, for (1) we don't need to nothing. But it's hard to detect that event.\n // So, doing the following for (1) does no harm.\n const { pathname, query } = this;\n this.changeState('replaceState', utils_1.formatWithValidation({ pathname, query }), utils_1.getURL());\n return;\n }\n // Make sure we don't re-render on initial load,\n // can be caused by navigating back from an external site\n if (e.state &&\n this.isSsr &&\n e.state.as === this.asPath &&\n url_1.parse(e.state.url).pathname === this.pathname) {\n return;\n }\n // If the downstream application returns falsy, return.\n // They will then be responsible for handling the event.\n if (this._bps && !this._bps(e.state)) {\n return;\n }\n const { url, as, options } = e.state;\n if (process.env.NODE_ENV !== 'production') {\n if (typeof url === 'undefined' || typeof as === 'undefined') {\n console.warn('`popstate` event triggered but `event.state` did not have `url` or `as` https://err.sh/zeit/next.js/popstate-state-empty');\n }\n }\n this.replace(url, as, options);\n };\n this._getStaticData = (asPath) => {\n const pathname = prepareRoute(url_1.parse(asPath).pathname);\n return process.env.NODE_ENV === 'production' && this.sdc[pathname]\n ? Promise.resolve(this.sdc[pathname])\n : fetchNextData(pathname, null, this.isSsr, data => (this.sdc[pathname] = data));\n };\n this._getServerData = (asPath) => {\n let { pathname, query } = url_1.parse(asPath, true);\n pathname = prepareRoute(pathname);\n return fetchNextData(pathname, query, this.isSsr);\n };\n // represents the current component key\n this.route = toRoute(pathname);\n // set up the component cache (by route keys)\n this.components = {};\n // We should not keep the cache, if there's an error\n // Otherwise, this cause issues when when going back and\n // come again to the errored page.\n if (pathname !== '/_error') {\n this.components[this.route] = {\n Component,\n props: initialProps,\n err,\n __N_SSG: initialProps && initialProps.__N_SSG,\n __N_SSP: initialProps && initialProps.__N_SSP,\n };\n }\n this.components['/_app'] = { Component: App };\n // Backwards compat for Router.router.events\n // TODO: Should be remove the following major version as it was never documented\n this.events = Router.events;\n this.pageLoader = pageLoader;\n this.pathname = pathname;\n this.query = query;\n // if auto prerendered and dynamic route wait to update asPath\n // until after mount to prevent hydration mismatch\n this.asPath =\n // @ts-ignore this is temporarily global (attached to window)\n is_dynamic_1.isDynamicRoute(pathname) && __NEXT_DATA__.autoExport ? pathname : as;\n this.basePath = basePath;\n this.sub = subscription;\n this.clc = null;\n this._wrapApp = wrapApp;\n // make sure to ignore extra popState in safari on navigating\n // back from external site\n this.isSsr = true;\n this.isFallback = isFallback;\n if (typeof window !== 'undefined') {\n // in order for `e.state` to work on the `onpopstate` event\n // we have to register the initial route upon initialization\n this.changeState('replaceState', utils_1.formatWithValidation({ pathname, query }), as);\n window.addEventListener('popstate', this.onPopState);\n }\n }\n // @deprecated backwards compatibility even though it's a private method.\n static _rewriteUrlForNextExport(url) {\n if (process.env.__NEXT_EXPORT_TRAILING_SLASH) {\n const rewriteUrlForNextExport = require('./rewrite-url-for-export')\n .rewriteUrlForNextExport;\n return rewriteUrlForNextExport(url);\n }\n else {\n return url;\n }\n }\n update(route, mod) {\n const Component = mod.default || mod;\n const data = this.components[route];\n if (!data) {\n throw new Error(`Cannot update unavailable route: ${route}`);\n }\n const newData = Object.assign(Object.assign({}, data), { Component, __N_SSG: mod.__N_SSG, __N_SSP: mod.__N_SSP });\n this.components[route] = newData;\n // pages/_app.js updated\n if (route === '/_app') {\n this.notify(this.components[this.route]);\n return;\n }\n if (route === this.route) {\n this.notify(newData);\n }\n }\n reload() {\n window.location.reload();\n }\n /**\n * Go back in history\n */\n back() {\n window.history.back();\n }\n /**\n * Performs a `pushState` with arguments\n * @param url of the route\n * @param as masks `url` for the browser\n * @param options object you can define `shallow` and other options\n */\n push(url, as = url, options = {}) {\n return this.change('pushState', url, as, options);\n }\n /**\n * Performs a `replaceState` with arguments\n * @param url of the route\n * @param as masks `url` for the browser\n * @param options object you can define `shallow` and other options\n */\n replace(url, as = url, options = {}) {\n return this.change('replaceState', url, as, options);\n }\n change(method, _url, _as, options) {\n return new Promise((resolve, reject) => {\n if (!options._h) {\n this.isSsr = false;\n }\n // marking route changes as a navigation start entry\n if (utils_1.ST) {\n performance.mark('routeChange');\n }\n // If url and as provided as an object representation,\n // we'll format them into the string version here.\n let url = typeof _url === 'object' ? utils_1.formatWithValidation(_url) : _url;\n let as = typeof _as === 'object' ? utils_1.formatWithValidation(_as) : _as;\n url = addBasePath(url);\n as = addBasePath(as);\n // Add the ending slash to the paths. So, we can serve the\n // \"<page>/index.html\" directly for the SSR page.\n if (process.env.__NEXT_EXPORT_TRAILING_SLASH) {\n const rewriteUrlForNextExport = require('./rewrite-url-for-export')\n .rewriteUrlForNextExport;\n // @ts-ignore this is temporarily global (attached to window)\n if (__NEXT_DATA__.nextExport) {\n as = rewriteUrlForNextExport(as);\n }\n }\n this.abortComponentLoad(as);\n // If the url change is only related to a hash change\n // We should not proceed. We should only change the state.\n // WARNING: `_h` is an internal option for handing Next.js client-side\n // hydration. Your app should _never_ use this property. It may change at\n // any time without notice.\n if (!options._h && this.onlyAHashChange(as)) {\n this.asPath = as;\n Router.events.emit('hashChangeStart', as);\n this.changeState(method, url, as, options);\n this.scrollToHash(as);\n Router.events.emit('hashChangeComplete', as);\n return resolve(true);\n }\n const { pathname, query, protocol } = url_1.parse(url, true);\n if (!pathname || protocol) {\n if (process.env.NODE_ENV !== 'production') {\n throw new Error(`Invalid href passed to router: ${url} https://err.sh/zeit/next.js/invalid-href-passed`);\n }\n return resolve(false);\n }\n // If asked to change the current URL we should reload the current page\n // (not location.reload() but reload getInitialProps and other Next.js stuffs)\n // We also need to set the method = replaceState always\n // as this should not go into the history (That's how browsers work)\n // We should compare the new asPath to the current asPath, not the url\n if (!this.urlIsNew(as)) {\n method = 'replaceState';\n }\n const route = toRoute(pathname);\n const { shallow = false } = options;\n if (is_dynamic_1.isDynamicRoute(route)) {\n const { pathname: asPathname } = url_1.parse(as);\n const routeRegex = route_regex_1.getRouteRegex(route);\n const routeMatch = route_matcher_1.getRouteMatcher(routeRegex)(asPathname);\n if (!routeMatch) {\n const missingParams = Object.keys(routeRegex.groups).filter(param => !query[param]);\n if (missingParams.length > 0) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(`Mismatching \\`as\\` and \\`href\\` failed to manually provide ` +\n `the params: ${missingParams.join(', ')} in the \\`href\\`'s \\`query\\``);\n }\n return reject(new Error(`The provided \\`as\\` value (${asPathname}) is incompatible with the \\`href\\` value (${route}). ` +\n `Read more: https://err.sh/zeit/next.js/incompatible-href-as`));\n }\n }\n else {\n // Merge params into `query`, overwriting any specified in search\n Object.assign(query, routeMatch);\n }\n }\n Router.events.emit('routeChangeStart', as);\n // If shallow is true and the route exists in the router cache we reuse the previous result\n this.getRouteInfo(route, pathname, query, as, shallow).then(routeInfo => {\n const { error } = routeInfo;\n if (error && error.cancelled) {\n return resolve(false);\n }\n Router.events.emit('beforeHistoryChange', as);\n this.changeState(method, url, as, options);\n if (process.env.NODE_ENV !== 'production') {\n const appComp = this.components['/_app'].Component;\n window.next.isPrerendered =\n appComp.getInitialProps === appComp.origGetInitialProps &&\n !routeInfo.Component.getInitialProps;\n }\n this.set(route, pathname, query, as, routeInfo);\n if (error) {\n Router.events.emit('routeChangeError', error, as);\n throw error;\n }\n Router.events.emit('routeChangeComplete', as);\n return resolve(true);\n }, reject);\n });\n }\n changeState(method, url, as, options = {}) {\n if (process.env.NODE_ENV !== 'production') {\n if (typeof window.history === 'undefined') {\n console.error(`Warning: window.history is not available.`);\n return;\n }\n if (typeof window.history[method] === 'undefined') {\n console.error(`Warning: window.history.${method} is not available`);\n return;\n }\n }\n if (method !== 'pushState' || utils_1.getURL() !== as) {\n window.history[method]({\n url,\n as,\n options,\n }, \n // Most browsers currently ignores this parameter, although they may use it in the future.\n // Passing the empty string here should be safe against future changes to the method.\n // https://developer.mozilla.org/en-US/docs/Web/API/History/replaceState\n '', as);\n }\n }\n getRouteInfo(route, pathname, query, as, shallow = false) {\n const cachedRouteInfo = this.components[route];\n // If there is a shallow route transition possible\n // If the route is already rendered on the screen.\n if (shallow && cachedRouteInfo && this.route === route) {\n return Promise.resolve(cachedRouteInfo);\n }\n const handleError = (err, loadErrorFail) => {\n return new Promise(resolve => {\n if (err.code === 'PAGE_LOAD_ERROR' || loadErrorFail) {\n // If we can't load the page it could be one of following reasons\n // 1. Page doesn't exists\n // 2. Page does exist in a different zone\n // 3. Internal error while loading the page\n // So, doing a hard reload is the proper way to deal with this.\n window.location.href = as;\n // Changing the URL doesn't block executing the current code path.\n // So, we need to mark it as a cancelled error and stop the routing logic.\n err.cancelled = true;\n // @ts-ignore TODO: fix the control flow here\n return resolve({ error: err });\n }\n if (err.cancelled) {\n // @ts-ignore TODO: fix the control flow here\n return resolve({ error: err });\n }\n resolve(this.fetchComponent('/_error')\n .then(res => {\n const { page: Component } = res;\n const routeInfo = { Component, err };\n return new Promise(resolve => {\n this.getInitialProps(Component, {\n err,\n pathname,\n query,\n }).then(props => {\n routeInfo.props = props;\n routeInfo.error = err;\n resolve(routeInfo);\n }, gipErr => {\n console.error('Error in error page `getInitialProps`: ', gipErr);\n routeInfo.error = err;\n routeInfo.props = {};\n resolve(routeInfo);\n });\n });\n })\n .catch(err => handleError(err, true)));\n });\n };\n return new Promise((resolve, reject) => {\n if (cachedRouteInfo) {\n return resolve(cachedRouteInfo);\n }\n this.fetchComponent(route).then(res => resolve({\n Component: res.page,\n __N_SSG: res.mod.__N_SSG,\n __N_SSP: res.mod.__N_SSP,\n }), reject);\n })\n .then((routeInfo) => {\n const { Component, __N_SSG, __N_SSP } = routeInfo;\n if (process.env.NODE_ENV !== 'production') {\n const { isValidElementType } = require('react-is');\n if (!isValidElementType(Component)) {\n throw new Error(`The default export is not a React Component in page: \"${pathname}\"`);\n }\n }\n return this._getData(() => __N_SSG\n ? this._getStaticData(as)\n : __N_SSP\n ? this._getServerData(as)\n : this.getInitialProps(Component, \n // we provide AppTree later so this needs to be `any`\n {\n pathname,\n query,\n asPath: as,\n })).then(props => {\n routeInfo.props = props;\n this.components[route] = routeInfo;\n return routeInfo;\n });\n })\n .catch(handleError);\n }\n set(route, pathname, query, as, data) {\n this.isFallback = false;\n this.route = route;\n this.pathname = pathname;\n this.query = query;\n this.asPath = as;\n this.notify(data);\n }\n /**\n * Callback to execute before replacing router state\n * @param cb callback to be executed\n */\n beforePopState(cb) {\n this._bps = cb;\n }\n onlyAHashChange(as) {\n if (!this.asPath)\n return false;\n const [oldUrlNoHash, oldHash] = this.asPath.split('#');\n const [newUrlNoHash, newHash] = as.split('#');\n // Makes sure we scroll to the provided hash if the url/hash are the same\n if (newHash && oldUrlNoHash === newUrlNoHash && oldHash === newHash) {\n return true;\n }\n // If the urls are change, there's more than a hash change\n if (oldUrlNoHash !== newUrlNoHash) {\n return false;\n }\n // If the hash has changed, then it's a hash only change.\n // This check is necessary to handle both the enter and\n // leave hash === '' cases. The identity case falls through\n // and is treated as a next reload.\n return oldHash !== newHash;\n }\n scrollToHash(as) {\n const [, hash] = as.split('#');\n // Scroll to top if the hash is just `#` with no value\n if (hash === '') {\n window.scrollTo(0, 0);\n return;\n }\n // First we check if the element by id is found\n const idEl = document.getElementById(hash);\n if (idEl) {\n idEl.scrollIntoView();\n return;\n }\n // If there's no element with the id, we check the `name` property\n // To mirror browsers\n const nameEl = document.getElementsByName(hash)[0];\n if (nameEl) {\n nameEl.scrollIntoView();\n }\n }\n urlIsNew(asPath) {\n return this.asPath !== asPath;\n }\n /**\n * Prefetch page code, you may wait for the data during page rendering.\n * This feature only works in production!\n * @param url the href of prefetched page\n * @param asPath the as path of the prefetched page\n */\n prefetch(url, asPath = url, options = {}) {\n return new Promise((resolve, reject) => {\n const { pathname, protocol } = url_1.parse(url);\n if (!pathname || protocol) {\n if (process.env.NODE_ENV !== 'production') {\n throw new Error(`Invalid href passed to router: ${url} https://err.sh/zeit/next.js/invalid-href-passed`);\n }\n return;\n }\n // Prefetch is not supported in development mode because it would trigger on-demand-entries\n if (process.env.NODE_ENV !== 'production') {\n return;\n }\n const route = delBasePath(toRoute(pathname));\n Promise.all([\n this.pageLoader.prefetchData(url, delBasePath(asPath)),\n this.pageLoader[options.priority ? 'loadPage' : 'prefetch'](route),\n ]).then(() => resolve(), reject);\n });\n }\n async fetchComponent(route) {\n let cancelled = false;\n const cancel = (this.clc = () => {\n cancelled = true;\n });\n route = delBasePath(route);\n const componentResult = await this.pageLoader.loadPage(route);\n if (cancelled) {\n const error = new Error(`Abort fetching component for route: \"${route}\"`);\n error.cancelled = true;\n throw error;\n }\n if (cancel === this.clc) {\n this.clc = null;\n }\n return componentResult;\n }\n _getData(fn) {\n let cancelled = false;\n const cancel = () => {\n cancelled = true;\n };\n this.clc = cancel;\n return fn().then(data => {\n if (cancel === this.clc) {\n this.clc = null;\n }\n if (cancelled) {\n const err = new Error('Loading initial props cancelled');\n err.cancelled = true;\n throw err;\n }\n return data;\n });\n }\n getInitialProps(Component, ctx) {\n const { Component: App } = this.components['/_app'];\n const AppTree = this._wrapApp(App);\n ctx.AppTree = AppTree;\n return utils_1.loadGetInitialProps(App, {\n AppTree,\n Component,\n router: this,\n ctx,\n });\n }\n abortComponentLoad(as) {\n if (this.clc) {\n const e = new Error('Route Cancelled');\n e.cancelled = true;\n Router.events.emit('routeChangeError', e, as);\n this.clc();\n this.clc = null;\n }\n }\n notify(data) {\n this.sub(data, this.components['/_app'].Component);\n }\n}\nexports.default = Router;\nRouter.events = mitt_1.default();\n"]},"metadata":{},"sourceType":"script"}