comics
Version:
1 lines • 10.3 kB
JSON
{"ast":null,"code":"\"use strict\";\n\nvar _regeneratorRuntime = require(\"@babel/runtime/regenerator\");\n\nvar _asyncToGenerator = require(\"@babel/runtime/helpers/asyncToGenerator\");\n\nvar _interopRequireDefault = require(\"@babel/runtime/helpers/interopRequireDefault\");\n\nvar _unfetch = _interopRequireDefault(require(\"next/dist/build/polyfills/unfetch\"));\n\nvar _eventSourcePolyfill = _interopRequireDefault(require(\"./event-source-polyfill\"));\n\nvar _eventsource = require(\"./error-overlay/eventsource\");\n\nvar _onDemandEntriesUtils = require(\"./on-demand-entries-utils\");\n\nvar _fouc = require(\"./fouc\");\n/* globals __webpack_hash__ */\n\n\nif (!window.EventSource) {\n window.EventSource = _eventSourcePolyfill[\"default\"];\n}\n\nvar data = JSON.parse(document.getElementById('__NEXT_DATA__').textContent);\nvar assetPrefix = data.assetPrefix,\n page = data.page;\nassetPrefix = assetPrefix || '';\nvar mostRecentHash = null;\n/* eslint-disable-next-line */\n\nvar curHash = __webpack_hash__;\nvar hotUpdatePath = assetPrefix + (assetPrefix.endsWith('/') ? '' : '/') + '_next/static/webpack/'; // Is there a newer version of this code available?\n\nfunction isUpdateAvailable() {\n // __webpack_hash__ is the hash of the current compilation.\n // It's a global variable injected by Webpack.\n\n /* eslint-disable-next-line */\n return mostRecentHash !== __webpack_hash__;\n} // Webpack disallows updates in other states.\n\n\nfunction canApplyUpdates() {\n return module.hot.status() === 'idle';\n} // This function reads code updates on the fly and hard\n// reloads the page when it has changed.\n\n\nfunction tryApplyUpdates() {\n return _tryApplyUpdates.apply(this, arguments);\n}\n\nfunction _tryApplyUpdates() {\n _tryApplyUpdates = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {\n var res, _data, curPage, pageUpdated;\n\n return _regeneratorRuntime.wrap(function _callee$(_context) {\n while (1) {\n switch (_context.prev = _context.next) {\n case 0:\n if (!(!isUpdateAvailable() || !canApplyUpdates())) {\n _context.next = 2;\n break;\n }\n\n return _context.abrupt(\"return\");\n\n case 2:\n _context.prev = 2;\n _context.next = 5;\n return (0, _unfetch[\"default\"])(\"\".concat(hotUpdatePath).concat(curHash, \".hot-update.json\"));\n\n case 5:\n res = _context.sent;\n _context.next = 8;\n return res.json();\n\n case 8:\n _data = _context.sent;\n curPage = page === '/' ? 'index' : page;\n pageUpdated = Object.keys(_data.c).some(function (mod) {\n return mod.indexOf(\"pages\".concat(curPage.substr(0, 1) === '/' ? curPage : \"/\".concat(curPage))) !== -1 || mod.indexOf(\"pages\".concat(curPage.substr(0, 1) === '/' ? curPage : \"/\".concat(curPage)).replace(/\\//g, '\\\\')) !== -1;\n });\n\n if (pageUpdated) {\n document.location.reload(true);\n } else {\n curHash = mostRecentHash;\n }\n\n _context.next = 18;\n break;\n\n case 14:\n _context.prev = 14;\n _context.t0 = _context[\"catch\"](2);\n console.error('Error occurred checking for update', _context.t0);\n document.location.reload(true);\n\n case 18:\n case \"end\":\n return _context.stop();\n }\n }\n }, _callee, null, [[2, 14]]);\n }));\n return _tryApplyUpdates.apply(this, arguments);\n}\n\n(0, _eventsource.getEventSourceWrapper)({\n path: \"\".concat(assetPrefix, \"/_next/webpack-hmr\")\n}).addMessageListener(function (event) {\n if (event.data === \"\\uD83D\\uDC93\") {\n return;\n }\n\n try {\n var message = JSON.parse(event.data);\n\n if (message.action === 'sync' || message.action === 'built') {\n if (!message.hash) {\n return;\n }\n\n mostRecentHash = message.hash;\n tryApplyUpdates();\n } else if (message.action === 'reloadPage') {\n document.location.reload(true);\n }\n } catch (ex) {\n console.warn('Invalid HMR message: ' + event.data + '\\n' + ex);\n }\n});\n(0, _onDemandEntriesUtils.setupPing)(assetPrefix, function () {\n return page;\n});\n(0, _fouc.displayContent)();","map":{"version":3,"sources":["../../../client/dev/amp-dev.js"],"names":["window","EventSourcePolyfill","data","JSON","document","assetPrefix","mostRecentHash","curHash","hotUpdatePath","module","isUpdateAvailable","canApplyUpdates","res","curPage","page","pageUpdated","Object","mod","console","path","event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F;;AAAA,MAAI;AACF,QAAMC,OAAO,GAAGlB,IAAI,CAAJA,KAAAA,CAAWiB,KAAK,CAAhC,IAAgBjB,CAAhB;;AAEA,QAAIkB,OAAO,CAAPA,MAAAA,KAAAA,MAAAA,IAA6BA,OAAO,CAAPA,MAAAA,KAAjC,OAAA,EAA6D;AAC3D,UAAI,CAACA,OAAO,CAAZ,IAAA,EAAmB;AACjB;AAEFf;;AAAAA,MAAAA,cAAc,GAAGe,OAAO,CAAxBf,IAAAA;AACAgB,MAAAA,eAAe;AALjB,KAAA,MAMO,IAAID,OAAO,CAAPA,MAAAA,KAAJ,YAAA,EAAqC;AAC1CjB,MAAAA,QAAQ,CAARA,QAAAA,CAAAA,MAAAA,CAAAA,IAAAA;AAEH;AAAC,GAZF,CAYE,OAAA,EAAA,EAAW;AACXc,IAAAA,OAAO,CAAPA,IAAAA,CAAa,0BAA0BE,KAAK,CAA/B,IAAA,GAAA,IAAA,GAAbF,EAAAA;AAEH;AAtBD,CAAA;AAwBA,CAAA,GAAA,qBAAA,CAAA,SAAA,EAAA,WAAA,EAAuB;AAAA,SAAvB,IAAuB;AAAA,CAAvB;AACA,CAAA,GAAA,KAAA,CAAA,cAAA","sourcesContent":["/* globals __webpack_hash__ */\nimport fetch from 'next/dist/build/polyfills/unfetch'\nimport EventSourcePolyfill from './event-source-polyfill'\nimport { getEventSourceWrapper } from './error-overlay/eventsource'\nimport { setupPing } from './on-demand-entries-utils'\nimport { displayContent } from './fouc'\n\nif (!window.EventSource) {\n window.EventSource = EventSourcePolyfill\n}\n\nconst data = JSON.parse(document.getElementById('__NEXT_DATA__').textContent)\nlet { assetPrefix, page } = data\nassetPrefix = assetPrefix || ''\nlet mostRecentHash = null\n/* eslint-disable-next-line */\nlet curHash = __webpack_hash__\nconst hotUpdatePath =\n assetPrefix + (assetPrefix.endsWith('/') ? '' : '/') + '_next/static/webpack/'\n\n// Is there a newer version of this code available?\nfunction isUpdateAvailable() {\n // __webpack_hash__ is the hash of the current compilation.\n // It's a global variable injected by Webpack.\n /* eslint-disable-next-line */\n return mostRecentHash !== __webpack_hash__\n}\n\n// Webpack disallows updates in other states.\nfunction canApplyUpdates() {\n return module.hot.status() === 'idle'\n}\n\n// This function reads code updates on the fly and hard\n// reloads the page when it has changed.\nasync function tryApplyUpdates() {\n if (!isUpdateAvailable() || !canApplyUpdates()) {\n return\n }\n try {\n const res = await fetch(`${hotUpdatePath}${curHash}.hot-update.json`)\n const data = await res.json()\n const curPage = page === '/' ? 'index' : page\n const pageUpdated = Object.keys(data.c).some((mod) => {\n return (\n mod.indexOf(\n `pages${curPage.substr(0, 1) === '/' ? curPage : `/${curPage}`}`\n ) !== -1 ||\n mod.indexOf(\n `pages${\n curPage.substr(0, 1) === '/' ? curPage : `/${curPage}`\n }`.replace(/\\//g, '\\\\')\n ) !== -1\n )\n })\n\n if (pageUpdated) {\n document.location.reload(true)\n } else {\n curHash = mostRecentHash\n }\n } catch (err) {\n console.error('Error occurred checking for update', err)\n document.location.reload(true)\n }\n}\n\ngetEventSourceWrapper({\n path: `${assetPrefix}/_next/webpack-hmr`,\n}).addMessageListener((event) => {\n if (event.data === '\\uD83D\\uDC93') {\n return\n }\n\n try {\n const message = JSON.parse(event.data)\n\n if (message.action === 'sync' || message.action === 'built') {\n if (!message.hash) {\n return\n }\n mostRecentHash = message.hash\n tryApplyUpdates()\n } else if (message.action === 'reloadPage') {\n document.location.reload(true)\n }\n } catch (ex) {\n console.warn('Invalid HMR message: ' + event.data + '\\n' + ex)\n }\n})\n\nsetupPing(assetPrefix, () => page)\ndisplayContent()\n"]},"metadata":{},"sourceType":"script"}