mirror of
https://github.com/idanoo/GoScrobble
synced 2025-07-01 21:52:19 +00:00
0.2.0 - Mid migration
This commit is contained in:
parent
139e6a915e
commit
7e38fdbd7d
42393 changed files with 5358157 additions and 62 deletions
88
web/node_modules/webpack-dev-server/client/utils/createSocketUrl.js
generated
vendored
Normal file
88
web/node_modules/webpack-dev-server/client/utils/createSocketUrl.js
generated
vendored
Normal file
|
@ -0,0 +1,88 @@
|
|||
'use strict';
|
||||
/* global self */
|
||||
|
||||
var url = require('url');
|
||||
|
||||
var getCurrentScriptSource = require('./getCurrentScriptSource');
|
||||
|
||||
function createSocketUrl(resourceQuery, currentLocation) {
|
||||
var urlParts;
|
||||
|
||||
if (typeof resourceQuery === 'string' && resourceQuery !== '') {
|
||||
// If this bundle is inlined, use the resource query to get the correct url.
|
||||
// format is like `?http://0.0.0.0:8096&sockPort=8097&sockHost=localhost`
|
||||
urlParts = url.parse(resourceQuery // strip leading `?` from query string to get a valid URL
|
||||
.substr(1) // replace first `&` with `?` to have a valid query string
|
||||
.replace('&', '?'), true);
|
||||
} else {
|
||||
// Else, get the url from the <script> this file was called with.
|
||||
var scriptHost = getCurrentScriptSource();
|
||||
urlParts = url.parse(scriptHost || '/', true, true);
|
||||
} // Use parameter to allow passing location in unit tests
|
||||
|
||||
|
||||
if (typeof currentLocation === 'string' && currentLocation !== '') {
|
||||
currentLocation = url.parse(currentLocation);
|
||||
} else {
|
||||
currentLocation = self.location;
|
||||
}
|
||||
|
||||
return getSocketUrl(urlParts, currentLocation);
|
||||
}
|
||||
/*
|
||||
* Gets socket URL based on Script Source/Location
|
||||
* (scriptSrc: URL, location: URL) -> URL
|
||||
*/
|
||||
|
||||
|
||||
function getSocketUrl(urlParts, loc) {
|
||||
var auth = urlParts.auth,
|
||||
query = urlParts.query;
|
||||
var hostname = urlParts.hostname,
|
||||
protocol = urlParts.protocol,
|
||||
port = urlParts.port;
|
||||
|
||||
if (!port || port === '0') {
|
||||
port = loc.port;
|
||||
} // check ipv4 and ipv6 `all hostname`
|
||||
// why do we need this check?
|
||||
// hostname n/a for file protocol (example, when using electron, ionic)
|
||||
// see: https://github.com/webpack/webpack-dev-server/pull/384
|
||||
|
||||
|
||||
if ((hostname === '0.0.0.0' || hostname === '::') && loc.hostname && loc.protocol.indexOf('http') === 0) {
|
||||
hostname = loc.hostname;
|
||||
} // `hostname` can be empty when the script path is relative. In that case, specifying
|
||||
// a protocol would result in an invalid URL.
|
||||
// When https is used in the app, secure websockets are always necessary
|
||||
// because the browser doesn't accept non-secure websockets.
|
||||
|
||||
|
||||
if (hostname && hostname !== '127.0.0.1' && (loc.protocol === 'https:' || urlParts.hostname === '0.0.0.0')) {
|
||||
protocol = loc.protocol;
|
||||
} // all of these sock url params are optionally passed in through
|
||||
// resourceQuery, so we need to fall back to the default if
|
||||
// they are not provided
|
||||
|
||||
|
||||
var sockHost = query.sockHost || hostname;
|
||||
var sockPath = query.sockPath || '/sockjs-node';
|
||||
var sockPort = query.sockPort || port;
|
||||
|
||||
if (sockPort === 'location') {
|
||||
sockPort = loc.port;
|
||||
}
|
||||
|
||||
return url.format({
|
||||
protocol: protocol,
|
||||
auth: auth,
|
||||
hostname: sockHost,
|
||||
port: sockPort,
|
||||
// If sockPath is provided it'll be passed in via the resourceQuery as a
|
||||
// query param so it has to be parsed out of the querystring in order for the
|
||||
// client to open the socket to the correct location.
|
||||
pathname: sockPath
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = createSocketUrl;
|
22
web/node_modules/webpack-dev-server/client/utils/getCurrentScriptSource.js
generated
vendored
Normal file
22
web/node_modules/webpack-dev-server/client/utils/getCurrentScriptSource.js
generated
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
'use strict';
|
||||
|
||||
function getCurrentScriptSource() {
|
||||
// `document.currentScript` is the most accurate way to find the current script,
|
||||
// but is not supported in all browsers.
|
||||
if (document.currentScript) {
|
||||
return document.currentScript.getAttribute('src');
|
||||
} // Fall back to getting all scripts in the document.
|
||||
|
||||
|
||||
var scriptElements = document.scripts || [];
|
||||
var currentScript = scriptElements[scriptElements.length - 1];
|
||||
|
||||
if (currentScript) {
|
||||
return currentScript.getAttribute('src');
|
||||
} // Fail as there was no script to use.
|
||||
|
||||
|
||||
throw new Error('[WDS] Failed to get current script source.');
|
||||
}
|
||||
|
||||
module.exports = getCurrentScriptSource;
|
49
web/node_modules/webpack-dev-server/client/utils/log.js
generated
vendored
Normal file
49
web/node_modules/webpack-dev-server/client/utils/log.js
generated
vendored
Normal file
|
@ -0,0 +1,49 @@
|
|||
'use strict';
|
||||
|
||||
var log = require('loglevel').getLogger('webpack-dev-server');
|
||||
|
||||
var INFO = 'info';
|
||||
var WARN = 'warn';
|
||||
var ERROR = 'error';
|
||||
var DEBUG = 'debug';
|
||||
var TRACE = 'trace';
|
||||
var SILENT = 'silent'; // deprecated
|
||||
// TODO: remove these at major released
|
||||
// https://github.com/webpack/webpack-dev-server/pull/1825
|
||||
|
||||
var WARNING = 'warning';
|
||||
var NONE = 'none'; // Set the default log level
|
||||
|
||||
log.setDefaultLevel(INFO);
|
||||
|
||||
function setLogLevel(level) {
|
||||
switch (level) {
|
||||
case INFO:
|
||||
case WARN:
|
||||
case ERROR:
|
||||
case DEBUG:
|
||||
case TRACE:
|
||||
log.setLevel(level);
|
||||
break;
|
||||
// deprecated
|
||||
|
||||
case WARNING:
|
||||
// loglevel's warning name is different from webpack's
|
||||
log.setLevel('warn');
|
||||
break;
|
||||
// deprecated
|
||||
|
||||
case NONE:
|
||||
case SILENT:
|
||||
log.disableAll();
|
||||
break;
|
||||
|
||||
default:
|
||||
log.error("[WDS] Unknown clientLogLevel '".concat(level, "'"));
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
log: log,
|
||||
setLogLevel: setLogLevel
|
||||
};
|
55
web/node_modules/webpack-dev-server/client/utils/reloadApp.js
generated
vendored
Normal file
55
web/node_modules/webpack-dev-server/client/utils/reloadApp.js
generated
vendored
Normal file
|
@ -0,0 +1,55 @@
|
|||
'use strict';
|
||||
/* global WorkerGlobalScope self */
|
||||
|
||||
var _require = require('./log'),
|
||||
log = _require.log;
|
||||
|
||||
function reloadApp(_ref, _ref2) {
|
||||
var hotReload = _ref.hotReload,
|
||||
hot = _ref.hot,
|
||||
liveReload = _ref.liveReload;
|
||||
var isUnloading = _ref2.isUnloading,
|
||||
currentHash = _ref2.currentHash;
|
||||
|
||||
if (isUnloading || !hotReload) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (hot) {
|
||||
log.info('[WDS] App hot update...');
|
||||
|
||||
var hotEmitter = require('webpack/hot/emitter');
|
||||
|
||||
hotEmitter.emit('webpackHotUpdate', currentHash);
|
||||
|
||||
if (typeof self !== 'undefined' && self.window) {
|
||||
// broadcast update to window
|
||||
self.postMessage("webpackHotUpdate".concat(currentHash), '*');
|
||||
}
|
||||
} // allow refreshing the page only if liveReload isn't disabled
|
||||
else if (liveReload) {
|
||||
var rootWindow = self; // use parent window for reload (in case we're in an iframe with no valid src)
|
||||
|
||||
var intervalId = self.setInterval(function () {
|
||||
if (rootWindow.location.protocol !== 'about:') {
|
||||
// reload immediately if protocol is valid
|
||||
applyReload(rootWindow, intervalId);
|
||||
} else {
|
||||
rootWindow = rootWindow.parent;
|
||||
|
||||
if (rootWindow.parent === rootWindow) {
|
||||
// if parent equals current window we've reached the root which would continue forever, so trigger a reload anyways
|
||||
applyReload(rootWindow, intervalId);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function applyReload(rootWindow, intervalId) {
|
||||
clearInterval(intervalId);
|
||||
log.info('[WDS] App updated. Reloading...');
|
||||
rootWindow.location.reload();
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = reloadApp;
|
14
web/node_modules/webpack-dev-server/client/utils/sendMessage.js
generated
vendored
Normal file
14
web/node_modules/webpack-dev-server/client/utils/sendMessage.js
generated
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
'use strict';
|
||||
/* global __resourceQuery WorkerGlobalScope self */
|
||||
// Send messages to the outside, so plugins can consume it.
|
||||
|
||||
function sendMsg(type, data) {
|
||||
if (typeof self !== 'undefined' && (typeof WorkerGlobalScope === 'undefined' || !(self instanceof WorkerGlobalScope))) {
|
||||
self.postMessage({
|
||||
type: "webpack".concat(type),
|
||||
data: data
|
||||
}, '*');
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = sendMsg;
|
Loading…
Add table
Add a link
Reference in a new issue