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
11 KiB

{"ast":null,"code":"\"use strict\";\n\nvar _classCallCheck = require(\"@babel/runtime/helpers/classCallCheck\");\n\nvar _createClass = require(\"@babel/runtime/helpers/createClass\");\n\nvar _inherits = require(\"@babel/runtime/helpers/inherits\");\n\nvar _possibleConstructorReturn = require(\"@babel/runtime/helpers/possibleConstructorReturn\");\n\nvar _getPrototypeOf = require(\"@babel/runtime/helpers/getPrototypeOf\");\n\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\n\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }\n\nvar _interopRequireDefault = require(\"@babel/runtime/helpers/interopRequireDefault\");\n\nvar _interopRequireWildcard = require(\"@babel/runtime/helpers/interopRequireWildcard\");\n\nexports.__esModule = true;\nexports[\"default\"] = void 0;\n\nvar _react = _interopRequireWildcard(require(\"react\"));\n\nvar _url = require(\"url\");\n\nvar _utils = require(\"../next-server/lib/utils\");\n\nvar _router = _interopRequireDefault(require(\"./router\"));\n\nvar _router2 = require(\"../next-server/lib/router/router\");\n\nfunction isLocal(href) {\n var url = (0, _url.parse)(href, false, true);\n var origin = (0, _url.parse)((0, _utils.getLocationOrigin)(), false, true);\n return !url.host || url.protocol === origin.protocol && url.host === origin.host;\n}\n\nfunction memoizedFormatUrl(formatFunc) {\n var lastHref = null;\n var lastAs = null;\n var lastResult = null;\n return function (href, as) {\n if (lastResult && href === lastHref && as === lastAs) {\n return lastResult;\n }\n\n var result = formatFunc(href, as);\n lastHref = href;\n lastAs = as;\n lastResult = result;\n return result;\n };\n}\n\nfunction formatUrl(url) {\n return url && typeof url === 'object' ? (0, _utils.formatWithValidation)(url) : url;\n}\n\nvar observer;\nvar listeners = new Map();\nvar IntersectionObserver = true ? window.IntersectionObserver : null;\nvar prefetched = {};\n\nfunction getObserver() {\n // Return shared instance of IntersectionObserver if already created\n if (observer) {\n return observer;\n } // Only create shared IntersectionObserver if supported in browser\n\n\n if (!IntersectionObserver) {\n return undefined;\n }\n\n return observer = new IntersectionObserver(function (entries) {\n entries.forEach(function (entry) {\n if (!listeners.has(entry.target)) {\n return;\n }\n\n var cb = listeners.get(entry.target);\n\n if (entry.isIntersecting || entry.intersectionRatio > 0) {\n observer.unobserve(entry.target);\n listeners[\"delete\"](entry.target);\n cb();\n }\n });\n }, {\n rootMargin: '200px'\n });\n}\n\nvar listenToIntersections = function listenToIntersections(el, cb) {\n var observer = getObserver();\n\n if (!observer) {\n return function () {};\n }\n\n observer.observe(el);\n listeners.set(el, cb);\n return function () {\n try {\n observer.unobserve(el);\n } catch (err) {\n console.error(err);\n }\n\n listeners[\"delete\"](el);\n };\n};\n\nvar Link = /*#__PURE__*/function (_react$Component) {\n _inherits(Link, _react$Component);\n\n var _super = _createSuper(Link);\n\n function Link(props) {\n var _this;\n\n _classCallCheck(this, Link);\n\n _this = _super.call(this, props);\n _this.p = void 0;\n\n _this.cleanUpListeners = function () {};\n\n _this.formatUrls = memoizedFormatUrl(function (href, asHref) {\n return {\n href: (0, _router2.addBasePath)(formatUrl(href)),\n as: asHref ? (0, _router2.addBasePath)(formatUrl(asHref)) : asHref\n };\n });\n\n _this.linkClicked = function (e) {\n var _e$currentTarget = e.currentTarget,\n nodeName = _e$currentTarget.nodeName,\n target = _e$currentTarget.target;\n\n if (nodeName === 'A' && (target && target !== '_self' || e.metaKey || e.ctrlKey || e.shiftKey || e.nativeEvent && e.nativeEvent.which === 2)) {\n // ignore click for new tab / new window behavior\n return;\n }\n\n var _this$formatUrls = _this.formatUrls(_this.props.href, _this.props.as),\n href = _this$formatUrls.href,\n as = _this$formatUrls.as;\n\n if (!isLocal(href)) {\n // ignore click if it's outside our scope (e.g. https://google.com)\n return;\n }\n\n var pathname = window.location.pathname;\n href = (0, _url.resolve)(pathname, href);\n as = as ? (0, _url.resolve)(pathname, as) : href;\n e.preventDefault(); // avoid scroll for urls with anchor refs\n\n var scroll = _this.props.scroll;\n\n if (scroll == null) {\n scroll = as.indexOf('#') < 0;\n } // replace state instead of push if prop is present\n\n\n _router[\"default\"][_this.props.replace ? 'replace' : 'push'](href, as, {\n shallow: _this.props.shallow\n }).then(function (success) {\n if (!success) return;\n\n if (scroll) {\n window.scrollTo(0, 0);\n document.body.focus();\n }\n });\n };\n\n if (false) {\n if (props.prefetch) {\n console.warn('Next.js auto-prefetches automatically based on viewport. The prefetch attribute is no longer needed. More: https://err.sh/zeit/next.js/prefetch-true-deprecated');\n }\n }\n\n _this.p = props.prefetch !== false;\n return _this;\n }\n\n _createClass(Link, [{\n key: \"componentWillUnmount\",\n value: function componentWillUnmount() {\n this.cleanUpListeners();\n }\n }, {\n key: \"getPaths\",\n value: function getPaths() {\n var pathname = window.location.pathname;\n\n var _this$formatUrls2 = this.formatUrls(this.props.href, this.props.as),\n parsedHref = _this$formatUrls2.href,\n parsedAs = _this$formatUrls2.as;\n\n var resolvedHref = (0, _url.resolve)(pathname, parsedHref);\n return [resolvedHref, parsedAs ? (0, _url.resolve)(pathname, parsedAs) : resolvedHref];\n }\n }, {\n key: \"handleRef\",\n value: function handleRef(ref) {\n var _this2 = this;\n\n if (this.p && IntersectionObserver && ref && ref.tagName) {\n this.cleanUpListeners();\n var isPrefetched = prefetched[this.getPaths().join( // Join on an invalid URI character\n '%')];\n\n if (!isPrefetched) {\n this.cleanUpListeners = listenToIntersections(ref, function () {\n _this2.prefetch();\n });\n }\n }\n } // The function is memoized so that no extra lifecycles are needed\n // as per https://reactjs.org/blog/2018/06/07/you-probably-dont-need-derived-state.html\n\n }, {\n key: \"prefetch\",\n value: function prefetch(options) {\n if (!this.p || false) return; // Prefetch the JSON page if asked (only in the client)\n\n var paths = this.getPaths(); // We need to handle a prefetch error here since we may be\n // loading with priority which can reject but we don't\n // want to force navigation since this is only a prefetch\n\n _router[\"default\"].prefetch(paths[\n /* href */\n 0], paths[\n /* asPath */\n 1], options)[\"catch\"](function (err) {\n if (false) {\n // rethrow to show invalid URL errors\n throw err;\n }\n });\n\n prefetched[paths.join( // Join on an invalid URI character\n '%')] = true;\n }\n }, {\n key: \"render\",\n value: function render() {\n var _this3 = this;\n\n var children = this.props.children;\n\n var _this$formatUrls3 = this.formatUrls(this.props.href, this.props.as),\n href = _this$formatUrls3.href,\n as = _this$formatUrls3.as; // Deprecated. Warning shown by propType check. If the children provided is a string (<Link>example</Link>) we wrap it in an <a> tag\n\n\n if (typeof children === 'string') {\n children = _react[\"default\"].createElement(\"a\", null, children);\n } // This will return the first child, if multiple are provided it will throw an error\n\n\n var child = _react.Children.only(children);\n\n var props = {\n ref: function ref(el) {\n _this3.handleRef(el);\n\n if (child && typeof child === 'object' && child.ref) {\n if (typeof child.ref === 'function') child.ref(el);else if (typeof child.ref === 'object') {\n child.ref.current = el;\n }\n }\n },\n onMouseEnter: function onMouseEnter(e) {\n if (child.props && typeof child.props.onMouseEnter === 'function') {\n child.props.onMouseEnter(e);\n }\n\n _this3.prefetch({\n priority: true\n });\n },\n onClick: function onClick(e) {\n if (child.props && typeof child.props.onClick === 'function') {\n child.props.onClick(e);\n }\n\n if (!e.defaultPrevented) {\n _this3.linkClicked(e);\n }\n }\n }; // If child is an <a> tag and doesn't have a href attribute, or if the 'passHref' property is\n // defined, we specify the current 'href', so that repetition is not needed by the user\n\n if (this.props.passHref || child.type === 'a' && !('href' in child.props)) {\n props.href = as || href;\n } // Add the ending slash to the paths. So, we can serve the\n // \"<page>/index.html\" directly.\n\n\n if (process.env.__NEXT_EXPORT_TRAILING_SLASH) {\n var rewriteUrlForNextExport = require('../next-server/lib/router/rewrite-url-for-export').rewriteUrlForNextExport;\n\n if (props.href && typeof __NEXT_DATA__ !== 'undefined' && __NEXT_DATA__.nextExport) {\n props.href = rewriteUrlForNextExport(props.href);\n }\n }\n\n return _react[\"default\"].cloneElement(child, props);\n }\n }]);\n\n return Link;\n}(_react.Component);\n\nif (false) {\n var warn = (0, _utils.execOnce)(console.error); // This module gets removed by webpack.IgnorePlugin\n\n var PropTypes = require('prop-types');\n\n var exact = require('prop-types-exact'); // @ts-ignore the property is supported, when declaring it on the class it outputs an extra bit of code which is not needed.\n\n\n Link.propTypes = exact({\n href: PropTypes.oneOfType([PropTypes.string, PropTypes.object]).isRequired,\n as: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),\n prefetch: PropTypes.bool,\n replace: PropTypes.bool,\n shallow: PropTypes.bool,\n passHref: PropTypes.bool,\n scroll: PropTypes.bool,\n children: PropTypes.oneOfType([PropTypes.element, function (props, propName) {\n var value = props[propName];\n\n if (typeof value === 'string') {\n warn(\"Warning: You're using a string directly inside <Link>. This usage has been deprecated. Please add an <a> tag as child of <Link>\");\n }\n\n return null;\n }]).isRequired\n });\n}\n\nvar _default = Link;\nexports[\"default\"] = _default;","map":null,"metadata":{},"sourceType":"script"}