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 line
22 KiB
1 line
22 KiB
2 years ago
|
{"ast":null,"code":"/* global __resourceQuery, __webpack_hash__ */\n/// <reference types=\"webpack/module\" />\nimport webpackHotLog from \"webpack/hot/log.js\";\nimport stripAnsi from \"./utils/stripAnsi.js\";\nimport parseURL from \"./utils/parseURL.js\";\nimport socket from \"./socket.js\";\nimport { formatProblem, show, hide } from \"./overlay.js\";\nimport { log, setLogLevel } from \"./utils/log.js\";\nimport sendMessage from \"./utils/sendMessage.js\";\nimport reloadApp from \"./utils/reloadApp.js\";\nimport createSocketURL from \"./utils/createSocketURL.js\";\n/**\n * @typedef {Object} Options\n * @property {boolean} hot\n * @property {boolean} liveReload\n * @property {boolean} progress\n * @property {boolean | { warnings?: boolean, errors?: boolean, trustedTypesPolicyName?: string }} overlay\n * @property {string} [logging]\n * @property {number} [reconnect]\n */\n\n/**\n * @typedef {Object} Status\n * @property {boolean} isUnloading\n * @property {string} currentHash\n * @property {string} [previousHash]\n */\n\n/**\n * @type {Status}\n */\n\nvar status = {\n isUnloading: false,\n // TODO Workaround for webpack v4, `__webpack_hash__` is not replaced without HotModuleReplacement\n // eslint-disable-next-line camelcase\n currentHash: typeof __webpack_hash__ !== \"undefined\" ? __webpack_hash__ : \"\"\n};\n/** @type {Options} */\n\nvar options = {\n hot: false,\n liveReload: false,\n progress: false,\n overlay: false\n};\nvar parsedResourceQuery = parseURL(__resourceQuery);\n\nif (parsedResourceQuery.hot === \"true\") {\n options.hot = true;\n log.info(\"Hot Module Replacement enabled.\");\n}\n\nif (parsedResourceQuery[\"live-reload\"] === \"true\") {\n options.liveReload = true;\n log.info(\"Live Reloading enabled.\");\n}\n\nif (parsedResourceQuery.logging) {\n options.logging = parsedResourceQuery.logging;\n}\n\nif (typeof parsedResourceQuery.reconnect !== \"undefined\") {\n options.reconnect = Number(parsedResourceQuery.reconnect);\n}\n/**\n * @param {string} level\n */\n\n\nfunction setAllLogLevel(level) {\n // This is needed because the HMR logger operate separately from dev server logger\n webpackHotLog.setLogLevel(level === \"verbose\" || level === \"log\" ? \"info\" : level);\n setLogLevel(level);\n}\n\nif (options.logging) {\n setAllLogLevel(options.logging);\n}\n\nself.addEventListener(\"beforeunload\", function () {\n status.isUnloading = true;\n});\nvar onSocketMessage = {\n hot: function hot() {\n if (parsedResourceQuery.hot === \"false\") {\n return;\n }\n\n options.hot = true;\n log.info(\"Hot Module Replacement enabled.\");\n },\n liveReload: function liveReload() {\n if (parsedResourceQuery[\"live-reload\"] === \"false\") {\n return;\n }\n\n options.liveReload = true;\n log.info(\"Live Reloading enabled.\");\n },\n invalid: function invalid() {\n log.info(\"App updated. Recompiling...\"); // Fixes #1042. overlay doesn't clear if errors are fixed but warnings remain.\n\n if (options.overlay) {\n hide();\n }\n\n sendMessage(\"Invalid\");\n },\n\n /**\n * @param {string} hash\n */\n hash: function hash(_hash) {\n status.previousHash = status.currentHash;\n status.currentHash = _hash;\n },\n logging: setAllLogLevel,\n\n /**\n * @param {boolean} value\n */\n overlay: function overlay(value) {\n if (typeof document === \"undefined\") {\n return;\n }\n\n options.overlay = value;\n },\n\n /**\n * @param {number} value\n */\n reconnect: function reconnect(value) {\n if (parsedResourceQuery.reconnect === \"false\") {\n return;\n }\n\n options.reconnect = value;\n },\n\n /**\n * @param {boolean} value\n */\n progress: function progress(value) {\n options.progress = value;\n },\n\n /**\n * @param {{ pluginName?: string, percent: number, msg: string }} data\n */\n \"progress-update\": function progressUpdate(data) {\n if (options.progress) {\n log.info(\"\".concat(data.pluginName ? \"[\".concat(data.pluginName, \"] \") : \"\").concat(data.percent, \"% - \"
|