mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-25 09:55:15 +00:00
1 line
23 KiB
JSON
1 line
23 KiB
JSON
{"ast":null,"code":"/**\n * Copyright (c) 2015-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n'use strict'; // This alternative WebpackDevServer combines the functionality of:\n// https://github.com/webpack/webpack-dev-server/blob/webpack-1/client/index.js\n// https://github.com/webpack/webpack/blob/webpack-1/hot/dev-server.js\n// It only supports their simplest configuration (hot updates on same server).\n// It makes some opinionated choices on top, like adding a syntax error overlay\n// that looks similar to our console output. The error overlay is inspired by:\n// https://github.com/glenjamin/webpack-hot-middleware\n\nvar stripAnsi = require('strip-ansi');\n\nvar url = require('url');\n\nvar launchEditorEndpoint = require('./launchEditorEndpoint');\n\nvar formatWebpackMessages = require('./formatWebpackMessages');\n\nvar ErrorOverlay = require('react-error-overlay');\n\nErrorOverlay.setEditorHandler(function editorHandler(errorLocation) {\n // Keep this sync with errorOverlayMiddleware.js\n fetch(launchEditorEndpoint + '?fileName=' + window.encodeURIComponent(errorLocation.fileName) + '&lineNumber=' + window.encodeURIComponent(errorLocation.lineNumber || 1) + '&colNumber=' + window.encodeURIComponent(errorLocation.colNumber || 1));\n}); // We need to keep track of if there has been a runtime error.\n// Essentially, we cannot guarantee application state was not corrupted by the\n// runtime error. To prevent confusing behavior, we forcibly reload the entire\n// application. This is handled below when we are notified of a compile (code\n// change).\n// See https://github.com/facebook/create-react-app/issues/3096\n\nvar hadRuntimeError = false;\nErrorOverlay.startReportingRuntimeErrors({\n onError: function () {\n hadRuntimeError = true;\n },\n filename: '/static/js/bundle.js'\n});\n\nif (module.hot && typeof module.hot.dispose === 'function') {\n module.hot.dispose(function () {\n // TODO: why do we need this?\n ErrorOverlay.stopReportingRuntimeErrors();\n });\n} // Connect to WebpackDevServer via a socket.\n\n\nvar connection = new WebSocket(url.format({\n protocol: window.location.protocol === 'https:' ? 'wss' : 'ws',\n hostname: process.env.WDS_SOCKET_HOST || window.location.hostname,\n port: process.env.WDS_SOCKET_PORT || window.location.port,\n // Hardcoded in WebpackDevServer\n pathname: process.env.WDS_SOCKET_PATH || '/sockjs-node',\n slashes: true\n})); // Unlike WebpackDevServer client, we won't try to reconnect\n// to avoid spamming the console. Disconnect usually happens\n// when developer stops the server.\n\nconnection.onclose = function () {\n if (typeof console !== 'undefined' && typeof console.info === 'function') {\n console.info('The development server has disconnected.\\nRefresh the page if necessary.');\n }\n}; // Remember some state related to hot module replacement.\n\n\nvar isFirstCompilation = true;\nvar mostRecentCompilationHash = null;\nvar hasCompileErrors = false;\n\nfunction clearOutdatedErrors() {\n // Clean up outdated compile errors, if any.\n if (typeof console !== 'undefined' && typeof console.clear === 'function') {\n if (hasCompileErrors) {\n console.clear();\n }\n }\n} // Successful compilation.\n\n\nfunction handleSuccess() {\n clearOutdatedErrors();\n var isHotUpdate = !isFirstCompilation;\n isFirstCompilation = false;\n hasCompileErrors = false; // Attempt to apply hot updates or reload.\n\n if (isHotUpdate) {\n tryApplyUpdates(function onHotUpdateSuccess() {\n // Only dismiss it when we're sure it's a hot update.\n // Otherwise it would flicker right before the reload.\n tryDismissErrorOverlay();\n });\n }\n} // Compilation with warnings (e.g. ESLint).\n\n\nfunction handleWarnings(warnings) {\n clearOutdatedErrors();\n var isHotUpdate = !isFirstCompilation;\n isFirstCompilation = false;\n hasCompileErrors = false;\n\n function printWarnings() {\n // Print warnings to the console.\n var formatted = formatWebpackMessages({\n warnings: warnings,\n errors: []\n });\n\n if (typeof console !== 'undefined' && typeof console.warn === 'function') {\n for (var i = 0; i < formatted.warnings.length; i++) {\n if (i === 5) {\n console.warn('There were more warnings in other files.\\n' + 'You can find a complete log in the terminal.');\n break;\n }\n\n console.warn(stripAnsi(formatted.warnings[i]));\n }\n }\n }\n\n printWarnings(); // Attempt to apply hot updates or reload.\n\n if (isHotUpdate) {\n tryApplyUpdates(function onSuccessfulHotUpdate() {\n // Only dismiss it when we're sure it's a hot update.\n // Otherwise it would flicker right before the reload.\n tryDismissErrorOverlay();\n });\n }\n} // Compilation with errors (e.g. syntax error or missing modules).\n\n\nfunction handleErrors(errors) {\n clearOutdatedErrors();\n isFirstCompilation = false;\n hasCompileErrors = true; // \"Massage\" webpack messages.\n\n var formatted = formatWebpackMessages({\n errors: errors,\n warnings: []\n }); // Only show the first error.\n\n ErrorOverlay.reportBuildError(formatted.errors[0]); // Also log them to the console.\n\n if (typeof console !== 'undefined' && typeof console.error === 'function') {\n for (var i = 0; i < formatted.errors.length; i++) {\n console.error(stripAnsi(formatted.errors[i]));\n }\n } // Do not attempt to reload now.\n // We will reload on next success instead.\n\n}\n\nfunction tryDismissErrorOverlay() {\n if (!hasCompileErrors) {\n ErrorOverlay.dismissBuildError();\n }\n} // There is a newer version of the code available.\n\n\nfunction handleAvailableHash(hash) {\n // Update last known compilation hash.\n mostRecentCompilationHash = hash;\n} // Handle messages from the server.\n\n\nconnection.onmessage = function (e) {\n var message = JSON.parse(e.data);\n\n switch (message.type) {\n case 'hash':\n handleAvailableHash(message.data);\n break;\n\n case 'still-ok':\n case 'ok':\n handleSuccess();\n break;\n\n case 'content-changed':\n // Triggered when a file from `contentBase` changed.\n window.location.reload();\n break;\n\n case 'warnings':\n handleWarnings(message.data);\n break;\n\n case 'errors':\n handleErrors(message.data);\n break;\n\n default: // Do nothing.\n\n }\n}; // Is there a newer version of this code available?\n\n\nfunction isUpdateAvailable() {\n /* globals __webpack_hash__ */\n // __webpack_hash__ is the hash of the current compilation.\n // It's a global variable injected by webpack.\n return mostRecentCompilationHash !== __webpack_hash__;\n} // webpack disallows updates in other states.\n\n\nfunction canApplyUpdates() {\n return module.hot.status() === 'idle';\n} // Attempt to update code on the fly, fall back to a hard reload.\n\n\nfunction tryApplyUpdates(onHotUpdateSuccess) {\n if (!module.hot) {\n // HotModuleReplacementPlugin is not in webpack configuration.\n window.location.reload();\n return;\n }\n\n if (!isUpdateAvailable() || !canApplyUpdates()) {\n return;\n }\n\n function handleApplyUpdates(err, updatedModules) {\n // NOTE: This var is injected by Webpack's DefinePlugin, and is a boolean instead of string.\n const hasReactRefresh = process.env.FAST_REFRESH;\n const wantsForcedReload = err || !updatedModules || hadRuntimeError; // React refresh can handle hot-reloading over errors.\n\n if (!hasReactRefresh && wantsForcedReload) {\n window.location.reload();\n return;\n }\n\n if (typeof onHotUpdateSuccess === 'function') {\n // Maybe we want to do something.\n onHotUpdateSuccess();\n }\n\n if (isUpdateAvailable()) {\n // While we were updating, there was a new update! Do it again.\n tryApplyUpdates();\n }\n } // https://webpack.github.io/docs/hot-module-replacement.html#check\n\n\n var result = module.hot.check(\n /* autoApply */\n true, handleApplyUpdates); // // webpack 2 returns a Promise instead of invoking a callback\n\n if (result && result.then) {\n result.then(function (updatedModules) {\n handleApplyUpdates(null, updatedModules);\n }, function (err) {\n handleApplyUpdates(err, null);\n });\n }\n}","map":{"version":3,"sources":["/app/node_modules/react-dev-utils/webpackHotDevClient.js"],"names":["stripAnsi","require","url","launchEditorEndpoint","formatWebpackMessages","ErrorOverlay","setEditorHandler","editorHandler","errorLocation","fetch","window","encodeURIComponent","fileName","lineNumber","colNumber","hadRuntimeError","startReportingRuntimeErrors","onError","filename","module","hot","dispose","stopReportingRuntimeErrors","connection","WebSocket","format","protocol","location","hostname","process","env","WDS_SOCKET_HOST","port","WDS_SOCKET_PORT","pathname","WDS_SOCKET_PATH","slashes","onclose","console","info","isFirstCompilation","mostRecentCompilationHash","hasCompileErrors","clearOutdatedErrors","clear","handleSuccess","isHotUpdate","tryApplyUpdates","onHotUpdateSuccess","tryDismissErrorOverlay","handleWarnings","warnings","printWarnings","formatted","errors","warn","i","length","onSuccessfulHotUpdate","handleErrors","reportBuildError","error","dismissBuildError","handleAvailableHash","hash","onmessage","e","message","JSON","parse","data","type","reload","isUpdateAvailable","__webpack_hash__","canApplyUpdates","status","handleApplyUpdates","err","updatedModules","hasReactRefresh","FAST_REFRESH","wantsForcedReload","result","check","then"],"mappings":"AAAA;AAC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xBF,MAAAA,kBAAkB,CAAC,IAAD,EAAOE,cAAP,CAAlB;AACD,KAHH,EAIE,UAAUD,GAAV,EAAe;AACbD,MAAAA,kBAAkB,CAACC,GAAD,EAAM,IAAN,CAAlB;AACD,KANH;AAQD;AACF","sourcesContent":["/**\n * Copyright (c) 2015-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n'use strict';\n\n// This alternative WebpackDevServer combines the functionality of:\n// https://github.com/webpack/webpack-dev-server/blob/webpack-1/client/index.js\n// https://github.com/webpack/webpack/blob/webpack-1/hot/dev-server.js\n\n// It only supports their simplest configuration (hot updates on same server).\n// It makes some opinionated choices on top, like adding a syntax error overlay\n// that looks similar to our console output. The error overlay is inspired by:\n// https://github.com/glenjamin/webpack-hot-middleware\n\nvar stripAnsi = require('strip-ansi');\nvar url = require('url');\nvar launchEditorEndpoint = require('./launchEditorEndpoint');\nvar formatWebpackMessages = require('./formatWebpackMessages');\nvar ErrorOverlay = require('react-error-overlay');\n\nErrorOverlay.setEditorHandler(function editorHandler(errorLocation) {\n // Keep this sync with errorOverlayMiddleware.js\n fetch(\n launchEditorEndpoint +\n '?fileName=' +\n window.encodeURIComponent(errorLocation.fileName) +\n '&lineNumber=' +\n window.encodeURIComponent(errorLocation.lineNumber || 1) +\n '&colNumber=' +\n window.encodeURIComponent(errorLocation.colNumber || 1)\n );\n});\n\n// We need to keep track of if there has been a runtime error.\n// Essentially, we cannot guarantee application state was not corrupted by the\n// runtime error. To prevent confusing behavior, we forcibly reload the entire\n// application. This is handled below when we are notified of a compile (code\n// change).\n// See https://github.com/facebook/create-react-app/issues/3096\nvar hadRuntimeError = false;\nErrorOverlay.startReportingRuntimeErrors({\n onError: function () {\n hadRuntimeError = true;\n },\n filename: '/static/js/bundle.js',\n});\n\nif (module.hot && typeof module.hot.dispose === 'function') {\n module.hot.dispose(function () {\n // TODO: why do we need this?\n ErrorOverlay.stopReportingRuntimeErrors();\n });\n}\n\n// Connect to WebpackDevServer via a socket.\nvar connection = new WebSocket(\n url.format({\n protocol: window.location.protocol === 'https:' ? 'wss' : 'ws',\n hostname: process.env.WDS_SOCKET_HOST || window.location.hostname,\n port: process.env.WDS_SOCKET_PORT || window.location.port,\n // Hardcoded in WebpackDevServer\n pathname: process.env.WDS_SOCKET_PATH || '/sockjs-node',\n slashes: true,\n })\n);\n\n// Unlike WebpackDevServer client, we won't try to reconnect\n// to avoid spamming the console. Disconnect usually happens\n// when developer stops the server.\nconnection.onclose = function () {\n if (typeof console !== 'undefined' && typeof console.info === 'function') {\n console.info(\n 'The development server has disconnected.\\nRefresh the page if necessary.'\n );\n }\n};\n\n// Remember some state related to hot module replacement.\nvar isFirstCompilation = true;\nvar mostRecentCompilationHash = null;\nvar hasCompileErrors = false;\n\nfunction clearOutdatedErrors() {\n // Clean up outdated compile errors, if any.\n if (typeof console !== 'undefined' && typeof console.clear === 'function') {\n if (hasCompileErrors) {\n console.clear();\n }\n }\n}\n\n// Successful compilation.\nfunction handleSuccess() {\n clearOutdatedErrors();\n\n var isHotUpdate = !isFirstCompilation;\n isFirstCompilation = false;\n hasCompileErrors = false;\n\n // Attempt to apply hot updates or reload.\n if (isHotUpdate) {\n tryApplyUpdates(function onHotUpdateSuccess() {\n // Only dismiss it when we're sure it's a hot update.\n // Otherwise it would flicker right before the reload.\n tryDismissErrorOverlay();\n });\n }\n}\n\n// Compilation with warnings (e.g. ESLint).\nfunction handleWarnings(warnings) {\n clearOutdatedErrors();\n\n var isHotUpdate = !isFirstCompilation;\n isFirstCompilation = false;\n hasCompileErrors = false;\n\n function printWarnings() {\n // Print warnings to the console.\n var formatted = formatWebpackMessages({\n warnings: warnings,\n errors: [],\n });\n\n if (typeof console !== 'undefined' && typeof console.warn === 'function') {\n for (var i = 0; i < formatted.warnings.length; i++) {\n if (i === 5) {\n console.warn(\n 'There were more warnings in other files.\\n' +\n 'You can find a complete log in the terminal.'\n );\n break;\n }\n console.warn(stripAnsi(formatted.warnings[i]));\n }\n }\n }\n\n printWarnings();\n\n // Attempt to apply hot updates or reload.\n if (isHotUpdate) {\n tryApplyUpdates(function onSuccessfulHotUpdate() {\n // Only dismiss it when we're sure it's a hot update.\n // Otherwise it would flicker right before the reload.\n tryDismissErrorOverlay();\n });\n }\n}\n\n// Compilation with errors (e.g. syntax error or missing modules).\nfunction handleErrors(errors) {\n clearOutdatedErrors();\n\n isFirstCompilation = false;\n hasCompileErrors = true;\n\n // \"Massage\" webpack messages.\n var formatted = formatWebpackMessages({\n errors: errors,\n warnings: [],\n });\n\n // Only show the first error.\n ErrorOverlay.reportBuildError(formatted.errors[0]);\n\n // Also log them to the console.\n if (typeof console !== 'undefined' && typeof console.error === 'function') {\n for (var i = 0; i < formatted.errors.length; i++) {\n console.error(stripAnsi(formatted.errors[i]));\n }\n }\n\n // Do not attempt to reload now.\n // We will reload on next success instead.\n}\n\nfunction tryDismissErrorOverlay() {\n if (!hasCompileErrors) {\n ErrorOverlay.dismissBuildError();\n }\n}\n\n// There is a newer version of the code available.\nfunction handleAvailableHash(hash) {\n // Update last known compilation hash.\n mostRecentCompilationHash = hash;\n}\n\n// Handle messages from the server.\nconnection.onmessage = function (e) {\n var message = JSON.parse(e.data);\n switch (message.type) {\n case 'hash':\n handleAvailableHash(message.data);\n break;\n case 'still-ok':\n case 'ok':\n handleSuccess();\n break;\n case 'content-changed':\n // Triggered when a file from `contentBase` changed.\n window.location.reload();\n break;\n case 'warnings':\n handleWarnings(message.data);\n break;\n case 'errors':\n handleErrors(message.data);\n break;\n default:\n // Do nothing.\n }\n};\n\n// Is there a newer version of this code available?\nfunction isUpdateAvailable() {\n /* globals __webpack_hash__ */\n // __webpack_hash__ is the hash of the current compilation.\n // It's a global variable injected by webpack.\n return mostRecentCompilationHash !== __webpack_hash__;\n}\n\n// webpack disallows updates in other states.\nfunction canApplyUpdates() {\n return module.hot.status() === 'idle';\n}\n\n// Attempt to update code on the fly, fall back to a hard reload.\nfunction tryApplyUpdates(onHotUpdateSuccess) {\n if (!module.hot) {\n // HotModuleReplacementPlugin is not in webpack configuration.\n window.location.reload();\n return;\n }\n\n if (!isUpdateAvailable() || !canApplyUpdates()) {\n return;\n }\n\n function handleApplyUpdates(err, updatedModules) {\n // NOTE: This var is injected by Webpack's DefinePlugin, and is a boolean instead of string.\n const hasReactRefresh = process.env.FAST_REFRESH;\n const wantsForcedReload = err || !updatedModules || hadRuntimeError;\n // React refresh can handle hot-reloading over errors.\n if (!hasReactRefresh && wantsForcedReload) {\n window.location.reload();\n return;\n }\n\n if (typeof onHotUpdateSuccess === 'function') {\n // Maybe we want to do something.\n onHotUpdateSuccess();\n }\n\n if (isUpdateAvailable()) {\n // While we were updating, there was a new update! Do it again.\n tryApplyUpdates();\n }\n }\n\n // https://webpack.github.io/docs/hot-module-replacement.html#check\n var result = module.hot.check(/* autoApply */ true, handleApplyUpdates);\n\n // // webpack 2 returns a Promise instead of invoking a callback\n if (result && result.then) {\n result.then(\n function (updatedModules) {\n handleApplyUpdates(null, updatedModules);\n },\n function (err) {\n handleApplyUpdates(err, null);\n }\n );\n }\n}\n"]},"metadata":{},"sourceType":"script"} |