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
22 KiB
1 lines
22 KiB
{"ast":null,"code":"import \"core-js/modules/es.number.constructor.js\";\nimport \"core-js/modules/es.array.concat.js\";\nimport \"core-js/modules/es.array.map.js\";\n\n/* global __resourceQuery, __webpack_hash__ */\n/// <reference types=\"webpack/module\" />\nimport webpackHotLog from \"webpack/hot/log.js\";\nimport stripAnsi from \"./modules/strip-ansi/index.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 }} 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, \"% - \").concat(data.msg, \".\"));\n }\n\n sendMessage(\"Progress\", data);\n },\n \"still-ok\": function stillOk() {\n log.info(\"Nothing changed.\");\n\n if (options.overlay) {\n hide();\n }\n\n sendMessage(\"StillOk\");\n },\n ok: function ok() {\n sendMessage(\"Ok\");\n\n if (options.overlay) {\n hide();\n }\n\n reloadApp(options, status);\n },\n // TODO: remove in v5 in favor of 'static-changed'\n\n /**\n * @param {string} file\n */\n \"content-changed\": function contentChanged(file) {\n log.info(\"\".concat(file ? \"\\\"\".concat(file, \"\\\"\") : \"Content\", \" from static directory was changed. Reloading...\"));\n self.location.reload();\n },\n\n /**\n * @param {string} file\n */\n \"static-changed\": function staticChanged(file) {\n log.info(\"\".concat(file ? \"\\\"\".concat(file, \"\\\"\") : \"Content\", \" from static directory was changed. Reloading...\"));\n self.location.reload();\n },\n\n /**\n * @param {Error[]} warnings\n * @param {any} params\n */\n warnings: function warnings(_warnings, params) {\n log.warn(\"Warnings while compiling.\");\n\n var printableWarnings = _warnings.map(function (error) {\n var _formatProblem = formatProblem(\"warning\", error),\n header = _formatProblem.header,\n body = _formatProblem.body;\n\n return \"\".concat(header, \"\\n\").concat(stripAnsi(body));\n });\n\n sendMessage(\"Warnings\", printableWarnings);\n\n for (var i = 0; i < printableWarnings.length; i++) {\n log.warn(printableWarnings[i]);\n }\n\n var needShowOverlayForWarnings = typeof options.overlay === \"boolean\" ? options.overlay : options.overlay && options.overlay.warnings;\n\n if (needShowOverlayForWarnings) {\n show(\"warning\", _warnings);\n }\n\n if (params && params.preventReloading) {\n return;\n }\n\n reloadApp(options, status);\n },\n\n /**\n * @param {Error[]} errors\n */\n errors: function errors(_errors) {\n log.error(\"Errors while compiling. Reload prevented.\");\n\n var printableErrors = _errors.map(function (error) {\n var _formatProblem2 = formatProblem(\"error\", error),\n header = _formatProblem2.header,\n body = _formatProblem2.body;\n\n return \"\".concat(header, \"\\n\").concat(stripAnsi(body));\n });\n\n sendMessage(\"Errors\", printableErrors);\n\n for (var i = 0; i < printableErrors.length; i++) {\n log.error(printableErrors[i]);\n }\n\n var needShowOverlayForErrors = typeof options.overlay === \"boolean\" ? options.overlay : options.overlay && options.overlay.errors;\n\n if (needShowOverlayForErrors) {\n show(\"error\", _errors);\n }\n },\n\n /**\n * @param {Error} error\n */\n error: function error(_error) {\n log.error(_error);\n },\n close: function close() {\n log.info(\"Disconnected!\");\n\n if (options.overlay) {\n hide();\n }\n\n sendMessage(\"Close\");\n }\n};\nvar socketURL = createSocketURL(parsedResourceQuery);\nsocket(socketURL, onSocketMessage, options.reconnect);","map":{"version":3,"sources":["/tmp/vue-hello/node_modules/webpack-dev-server/client/index.js"],"names":["webpackHotLog","stripAnsi","parseURL","socket","formatProblem","show","hide","log","setLogLevel","sendMessage","reloadApp","createSocketURL","status","isUnloading","currentHash","__webpack_hash__","options","hot","liveReload","progress","overlay","parsedResourceQuery","__resourceQuery","info","logging","reconnect","Number","setAllLogLevel","level","self","addEventListener","onSocketMessage","invalid","hash","_hash","previousHash","value","document","progressUpdate","data","concat","pluginName","percent","msg","stillOk","ok","contentChanged","file","location","reload","staticChanged","warnings","_warnings","params","warn","printableWarnings","map","error","_formatProblem","header","body","i","length","needShowOverlayForWarnings","preventReloading","errors","_errors","printableErrors","_formatProblem2","needShowOverlayForErrors","_error","close","socketURL"],"mappings":";;;;AAAA;AACA;AACA,OAAOA,aAAP,MAA0B,oBAA1B;AACA,OAAOC,SAAP,MAAsB,+BAAtB;AACA,OAAOC,QAAP,MAAqB,qBAArB;AACA,OAAOC,MAAP,MAAmB,aAAnB;AACA,SAASC,aAAT,EAAwBC,IAAxB,EAA8BC,IAA9B,QAA0C,cAA1C;AACA,SAASC,GAAT,EAAcC,WAAd,QAAiC,gBAAjC;AACA,OAAOC,WAAP,MAAwB,wBAAxB;AACA,OAAOC,SAAP,MAAsB,sBAAtB;AACA,OAAOC,eAAP,MAA4B,4BAA5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,IAAIC,MAAM,GAAG;AACXC,EAAAA,WAAW,EAAE,KADF;AAEX;AACA;AACAC,EAAAA,WAAW,EAAE,OAAOC,gBAAP,KAA4B,WAA5B,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B,GAAG,OAAOrD,OAAO,CAACI,OAAf,KAA2B,SAA3B,GAAuCJ,OAAO,CAACI,OAA/C,GAAyDJ,OAAO,CAACI,OAAR,IAAmBJ,OAAO,CAACI,OAAR,CAAgB6C,MAA3H;;AAEA,QAAII,wBAAJ,EAA8B;AAC5BhE,MAAAA,IAAI,CAAC,OAAD,EAAU6D,OAAV,CAAJ;AACD;AACF,GA1KmB;;AA4KpB;AACF;AACA;AACET,EAAAA,KAAK,EAAE,SAASA,KAAT,CAAea,MAAf,EAAuB;AAC5B/D,IAAAA,GAAG,CAACkD,KAAJ,CAAUa,MAAV;AACD,GAjLmB;AAkLpBC,EAAAA,KAAK,EAAE,SAASA,KAAT,GAAiB;AACtBhE,IAAAA,GAAG,CAACgB,IAAJ,CAAS,eAAT;;AAEA,QAAIP,OAAO,CAACI,OAAZ,EAAqB;AACnBd,MAAAA,IAAI;AACL;;AAEDG,IAAAA,WAAW,CAAC,OAAD,CAAX;AACD;AA1LmB,CAAtB;AA4LA,IAAI+D,SAAS,GAAG7D,eAAe,CAACU,mBAAD,CAA/B;AACAlB,MAAM,CAACqE,SAAD,EAAYzC,eAAZ,EAA6Bf,OAAO,CAACS,SAArC,CAAN","sourcesContent":["/* global __resourceQuery, __webpack_hash__ */\n/// <reference types=\"webpack/module\" />\nimport webpackHotLog from \"webpack/hot/log.js\";\nimport stripAnsi from \"./modules/strip-ansi/index.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 }} 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, \"% - \").concat(data.msg, \".\"));\n }\n\n sendMessage(\"Progress\", data);\n },\n \"still-ok\": function stillOk() {\n log.info(\"Nothing changed.\");\n\n if (options.overlay) {\n hide();\n }\n\n sendMessage(\"StillOk\");\n },\n ok: function ok() {\n sendMessage(\"Ok\");\n\n if (options.overlay) {\n hide();\n }\n\n reloadApp(options, status);\n },\n // TODO: remove in v5 in favor of 'static-changed'\n\n /**\n * @param {string} file\n */\n \"content-changed\": function contentChanged(file) {\n log.info(\"\".concat(file ? \"\\\"\".concat(file, \"\\\"\") : \"Content\", \" from static directory was changed. Reloading...\"));\n self.location.reload();\n },\n\n /**\n * @param {string} file\n */\n \"static-changed\": function staticChanged(file) {\n log.info(\"\".concat(file ? \"\\\"\".concat(file, \"\\\"\") : \"Content\", \" from static directory was changed. Reloading...\"));\n self.location.reload();\n },\n\n /**\n * @param {Error[]} warnings\n * @param {any} params\n */\n warnings: function warnings(_warnings, params) {\n log.warn(\"Warnings while compiling.\");\n\n var printableWarnings = _warnings.map(function (error) {\n var _formatProblem = formatProblem(\"warning\", error),\n header = _formatProblem.header,\n body = _formatProblem.body;\n\n return \"\".concat(header, \"\\n\").concat(stripAnsi(body));\n });\n\n sendMessage(\"Warnings\", printableWarnings);\n\n for (var i = 0; i < printableWarnings.length; i++) {\n log.warn(printableWarnings[i]);\n }\n\n var needShowOverlayForWarnings = typeof options.overlay === \"boolean\" ? options.overlay : options.overlay && options.overlay.warnings;\n\n if (needShowOverlayForWarnings) {\n show(\"warning\", _warnings);\n }\n\n if (params && params.preventReloading) {\n return;\n }\n\n reloadApp(options, status);\n },\n\n /**\n * @param {Error[]} errors\n */\n errors: function errors(_errors) {\n log.error(\"Errors while compiling. Reload prevented.\");\n\n var printableErrors = _errors.map(function (error) {\n var _formatProblem2 = formatProblem(\"error\", error),\n header = _formatProblem2.header,\n body = _formatProblem2.body;\n\n return \"\".concat(header, \"\\n\").concat(stripAnsi(body));\n });\n\n sendMessage(\"Errors\", printableErrors);\n\n for (var i = 0; i < printableErrors.length; i++) {\n log.error(printableErrors[i]);\n }\n\n var needShowOverlayForErrors = typeof options.overlay === \"boolean\" ? options.overlay : options.overlay && options.overlay.errors;\n\n if (needShowOverlayForErrors) {\n show(\"error\", _errors);\n }\n },\n\n /**\n * @param {Error} error\n */\n error: function error(_error) {\n log.error(_error);\n },\n close: function close() {\n log.info(\"Disconnected!\");\n\n if (options.overlay) {\n hide();\n }\n\n sendMessage(\"Close\");\n }\n};\nvar socketURL = createSocketURL(parsedResourceQuery);\nsocket(socketURL, onSocketMessage, options.reconnect);"]},"metadata":{},"sourceType":"module"} |