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.

0 lines
26 KiB

4 years ago
  1. {"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