2020-01-07 23:45:52 +08:00
|
|
|
|
module.exports =
|
|
|
|
|
/******/ (function(modules) { // webpackBootstrap
|
|
|
|
|
/******/ // The module cache
|
|
|
|
|
/******/ var installedModules = {};
|
|
|
|
|
/******/
|
|
|
|
|
/******/ // The require function
|
|
|
|
|
/******/ function __webpack_require__(moduleId) {
|
|
|
|
|
/******/
|
|
|
|
|
/******/ // Check if module is in cache
|
|
|
|
|
/******/ if(installedModules[moduleId]) {
|
|
|
|
|
/******/ return installedModules[moduleId].exports;
|
|
|
|
|
/******/ }
|
|
|
|
|
/******/ // Create a new module (and put it into the cache)
|
|
|
|
|
/******/ var module = installedModules[moduleId] = {
|
|
|
|
|
/******/ i: moduleId,
|
|
|
|
|
/******/ l: false,
|
|
|
|
|
/******/ exports: {}
|
|
|
|
|
/******/ };
|
|
|
|
|
/******/
|
|
|
|
|
/******/ // Execute the module function
|
|
|
|
|
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
|
|
|
/******/
|
|
|
|
|
/******/ // Flag the module as loaded
|
|
|
|
|
/******/ module.l = true;
|
|
|
|
|
/******/
|
|
|
|
|
/******/ // Return the exports of the module
|
|
|
|
|
/******/ return module.exports;
|
|
|
|
|
/******/ }
|
|
|
|
|
/******/
|
|
|
|
|
/******/
|
|
|
|
|
/******/ // expose the modules object (__webpack_modules__)
|
|
|
|
|
/******/ __webpack_require__.m = modules;
|
|
|
|
|
/******/
|
|
|
|
|
/******/ // expose the module cache
|
|
|
|
|
/******/ __webpack_require__.c = installedModules;
|
|
|
|
|
/******/
|
|
|
|
|
/******/ // define getter function for harmony exports
|
|
|
|
|
/******/ __webpack_require__.d = function(exports, name, getter) {
|
|
|
|
|
/******/ if(!__webpack_require__.o(exports, name)) {
|
|
|
|
|
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
|
|
|
|
/******/ }
|
|
|
|
|
/******/ };
|
|
|
|
|
/******/
|
|
|
|
|
/******/ // define __esModule on exports
|
|
|
|
|
/******/ __webpack_require__.r = function(exports) {
|
|
|
|
|
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
|
|
|
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
|
|
/******/ }
|
|
|
|
|
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
|
|
/******/ };
|
|
|
|
|
/******/
|
|
|
|
|
/******/ // create a fake namespace object
|
|
|
|
|
/******/ // mode & 1: value is a module id, require it
|
|
|
|
|
/******/ // mode & 2: merge all properties of value into the ns
|
|
|
|
|
/******/ // mode & 4: return value when already ns object
|
|
|
|
|
/******/ // mode & 8|1: behave like require
|
|
|
|
|
/******/ __webpack_require__.t = function(value, mode) {
|
|
|
|
|
/******/ if(mode & 1) value = __webpack_require__(value);
|
|
|
|
|
/******/ if(mode & 8) return value;
|
|
|
|
|
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
|
|
|
|
/******/ var ns = Object.create(null);
|
|
|
|
|
/******/ __webpack_require__.r(ns);
|
|
|
|
|
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
|
|
|
|
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
|
|
|
|
/******/ return ns;
|
|
|
|
|
/******/ };
|
|
|
|
|
/******/
|
|
|
|
|
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
|
|
|
/******/ __webpack_require__.n = function(module) {
|
|
|
|
|
/******/ var getter = module && module.__esModule ?
|
|
|
|
|
/******/ function getDefault() { return module['default']; } :
|
|
|
|
|
/******/ function getModuleExports() { return module; };
|
|
|
|
|
/******/ __webpack_require__.d(getter, 'a', getter);
|
|
|
|
|
/******/ return getter;
|
|
|
|
|
/******/ };
|
|
|
|
|
/******/
|
|
|
|
|
/******/ // Object.prototype.hasOwnProperty.call
|
|
|
|
|
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
|
|
|
|
/******/
|
|
|
|
|
/******/ // __webpack_public_path__
|
|
|
|
|
/******/ __webpack_require__.p = "";
|
|
|
|
|
/******/
|
|
|
|
|
/******/
|
|
|
|
|
/******/ // Load entry module and return exports
|
|
|
|
|
/******/ return __webpack_require__(__webpack_require__.s = "./src/extension.ts");
|
|
|
|
|
/******/ })
|
|
|
|
|
/************************************************************************/
|
|
|
|
|
/******/ ({
|
|
|
|
|
|
|
|
|
|
/***/ "./node_modules/axios/index.js":
|
|
|
|
|
/*!*************************************!*\
|
|
|
|
|
!*** ./node_modules/axios/index.js ***!
|
|
|
|
|
\*************************************/
|
|
|
|
|
/*! no static exports found */
|
|
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
module.exports = __webpack_require__(/*! ./lib/axios */ "./node_modules/axios/lib/axios.js");
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ "./node_modules/axios/lib/adapters/http.js":
|
|
|
|
|
/*!*************************************************!*\
|
|
|
|
|
!*** ./node_modules/axios/lib/adapters/http.js ***!
|
|
|
|
|
\*************************************************/
|
|
|
|
|
/*! no static exports found */
|
|
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
|
|
|
|
|
var settle = __webpack_require__(/*! ./../core/settle */ "./node_modules/axios/lib/core/settle.js");
|
|
|
|
|
var buildURL = __webpack_require__(/*! ./../helpers/buildURL */ "./node_modules/axios/lib/helpers/buildURL.js");
|
|
|
|
|
var http = __webpack_require__(/*! http */ "http");
|
|
|
|
|
var https = __webpack_require__(/*! https */ "https");
|
|
|
|
|
var httpFollow = __webpack_require__(/*! follow-redirects */ "./node_modules/follow-redirects/index.js").http;
|
|
|
|
|
var httpsFollow = __webpack_require__(/*! follow-redirects */ "./node_modules/follow-redirects/index.js").https;
|
|
|
|
|
var url = __webpack_require__(/*! url */ "url");
|
|
|
|
|
var zlib = __webpack_require__(/*! zlib */ "zlib");
|
|
|
|
|
var pkg = __webpack_require__(/*! ./../../package.json */ "./node_modules/axios/package.json");
|
|
|
|
|
var createError = __webpack_require__(/*! ../core/createError */ "./node_modules/axios/lib/core/createError.js");
|
|
|
|
|
var enhanceError = __webpack_require__(/*! ../core/enhanceError */ "./node_modules/axios/lib/core/enhanceError.js");
|
|
|
|
|
|
|
|
|
|
var isHttps = /https:?/;
|
|
|
|
|
|
|
|
|
|
/*eslint consistent-return:0*/
|
|
|
|
|
module.exports = function httpAdapter(config) {
|
|
|
|
|
return new Promise(function dispatchHttpRequest(resolvePromise, rejectPromise) {
|
|
|
|
|
var timer;
|
|
|
|
|
var resolve = function resolve(value) {
|
|
|
|
|
clearTimeout(timer);
|
|
|
|
|
resolvePromise(value);
|
|
|
|
|
};
|
|
|
|
|
var reject = function reject(value) {
|
|
|
|
|
clearTimeout(timer);
|
|
|
|
|
rejectPromise(value);
|
|
|
|
|
};
|
|
|
|
|
var data = config.data;
|
|
|
|
|
var headers = config.headers;
|
|
|
|
|
|
|
|
|
|
// Set User-Agent (required by some servers)
|
|
|
|
|
// Only set header if it hasn't been set in config
|
|
|
|
|
// See https://github.com/axios/axios/issues/69
|
|
|
|
|
if (!headers['User-Agent'] && !headers['user-agent']) {
|
|
|
|
|
headers['User-Agent'] = 'axios/' + pkg.version;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (data && !utils.isStream(data)) {
|
|
|
|
|
if (Buffer.isBuffer(data)) {
|
|
|
|
|
// Nothing to do...
|
|
|
|
|
} else if (utils.isArrayBuffer(data)) {
|
|
|
|
|
data = Buffer.from(new Uint8Array(data));
|
|
|
|
|
} else if (utils.isString(data)) {
|
|
|
|
|
data = Buffer.from(data, 'utf-8');
|
|
|
|
|
} else {
|
|
|
|
|
return reject(createError(
|
|
|
|
|
'Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream',
|
|
|
|
|
config
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Add Content-Length header if data exists
|
|
|
|
|
headers['Content-Length'] = data.length;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// HTTP basic authentication
|
|
|
|
|
var auth = undefined;
|
|
|
|
|
if (config.auth) {
|
|
|
|
|
var username = config.auth.username || '';
|
|
|
|
|
var password = config.auth.password || '';
|
|
|
|
|
auth = username + ':' + password;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Parse url
|
|
|
|
|
var parsed = url.parse(config.url);
|
|
|
|
|
var protocol = parsed.protocol || 'http:';
|
|
|
|
|
|
|
|
|
|
if (!auth && parsed.auth) {
|
|
|
|
|
var urlAuth = parsed.auth.split(':');
|
|
|
|
|
var urlUsername = urlAuth[0] || '';
|
|
|
|
|
var urlPassword = urlAuth[1] || '';
|
|
|
|
|
auth = urlUsername + ':' + urlPassword;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (auth) {
|
|
|
|
|
delete headers.Authorization;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var isHttpsRequest = isHttps.test(protocol);
|
|
|
|
|
var agent = isHttpsRequest ? config.httpsAgent : config.httpAgent;
|
|
|
|
|
|
|
|
|
|
var options = {
|
|
|
|
|
path: buildURL(parsed.path, config.params, config.paramsSerializer).replace(/^\?/, ''),
|
|
|
|
|
method: config.method.toUpperCase(),
|
|
|
|
|
headers: headers,
|
|
|
|
|
agent: agent,
|
|
|
|
|
auth: auth
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (config.socketPath) {
|
|
|
|
|
options.socketPath = config.socketPath;
|
|
|
|
|
} else {
|
|
|
|
|
options.hostname = parsed.hostname;
|
|
|
|
|
options.port = parsed.port;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var proxy = config.proxy;
|
|
|
|
|
if (!proxy && proxy !== false) {
|
|
|
|
|
var proxyEnv = protocol.slice(0, -1) + '_proxy';
|
|
|
|
|
var proxyUrl = process.env[proxyEnv] || process.env[proxyEnv.toUpperCase()];
|
|
|
|
|
if (proxyUrl) {
|
|
|
|
|
var parsedProxyUrl = url.parse(proxyUrl);
|
|
|
|
|
var noProxyEnv = process.env.no_proxy || process.env.NO_PROXY;
|
|
|
|
|
var shouldProxy = true;
|
|
|
|
|
|
|
|
|
|
if (noProxyEnv) {
|
|
|
|
|
var noProxy = noProxyEnv.split(',').map(function trim(s) {
|
|
|
|
|
return s.trim();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
shouldProxy = !noProxy.some(function proxyMatch(proxyElement) {
|
|
|
|
|
if (!proxyElement) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (proxyElement === '*') {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
if (proxyElement[0] === '.' &&
|
|
|
|
|
parsed.hostname.substr(parsed.hostname.length - proxyElement.length) === proxyElement &&
|
|
|
|
|
proxyElement.match(/\./g).length === parsed.hostname.match(/\./g).length) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return parsed.hostname === proxyElement;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (shouldProxy) {
|
|
|
|
|
proxy = {
|
|
|
|
|
host: parsedProxyUrl.hostname,
|
|
|
|
|
port: parsedProxyUrl.port
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (parsedProxyUrl.auth) {
|
|
|
|
|
var proxyUrlAuth = parsedProxyUrl.auth.split(':');
|
|
|
|
|
proxy.auth = {
|
|
|
|
|
username: proxyUrlAuth[0],
|
|
|
|
|
password: proxyUrlAuth[1]
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (proxy) {
|
|
|
|
|
options.hostname = proxy.host;
|
|
|
|
|
options.host = proxy.host;
|
|
|
|
|
options.headers.host = parsed.hostname + (parsed.port ? ':' + parsed.port : '');
|
|
|
|
|
options.port = proxy.port;
|
|
|
|
|
options.path = protocol + '//' + parsed.hostname + (parsed.port ? ':' + parsed.port : '') + options.path;
|
|
|
|
|
|
|
|
|
|
// Basic proxy authorization
|
|
|
|
|
if (proxy.auth) {
|
|
|
|
|
var base64 = Buffer.from(proxy.auth.username + ':' + proxy.auth.password, 'utf8').toString('base64');
|
|
|
|
|
options.headers['Proxy-Authorization'] = 'Basic ' + base64;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var transport;
|
|
|
|
|
var isHttpsProxy = isHttpsRequest && (proxy ? isHttps.test(proxy.protocol) : true);
|
|
|
|
|
if (config.transport) {
|
|
|
|
|
transport = config.transport;
|
|
|
|
|
} else if (config.maxRedirects === 0) {
|
|
|
|
|
transport = isHttpsProxy ? https : http;
|
|
|
|
|
} else {
|
|
|
|
|
if (config.maxRedirects) {
|
|
|
|
|
options.maxRedirects = config.maxRedirects;
|
|
|
|
|
}
|
|
|
|
|
transport = isHttpsProxy ? httpsFollow : httpFollow;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (config.maxContentLength && config.maxContentLength > -1) {
|
|
|
|
|
options.maxBodyLength = config.maxContentLength;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Create the request
|
|
|
|
|
var req = transport.request(options, function handleResponse(res) {
|
|
|
|
|
if (req.aborted) return;
|
|
|
|
|
|
|
|
|
|
// uncompress the response body transparently if required
|
|
|
|
|
var stream = res;
|
|
|
|
|
switch (res.headers['content-encoding']) {
|
|
|
|
|
/*eslint default-case:0*/
|
|
|
|
|
case 'gzip':
|
|
|
|
|
case 'compress':
|
|
|
|
|
case 'deflate':
|
|
|
|
|
// add the unzipper to the body stream processing pipeline
|
|
|
|
|
stream = (res.statusCode === 204) ? stream : stream.pipe(zlib.createUnzip());
|
|
|
|
|
|
|
|
|
|
// remove the content-encoding in order to not confuse downstream operations
|
|
|
|
|
delete res.headers['content-encoding'];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// return the last request in case of redirects
|
|
|
|
|
var lastRequest = res.req || req;
|
|
|
|
|
|
|
|
|
|
var response = {
|
|
|
|
|
status: res.statusCode,
|
|
|
|
|
statusText: res.statusMessage,
|
|
|
|
|
headers: res.headers,
|
|
|
|
|
config: config,
|
|
|
|
|
request: lastRequest
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (config.responseType === 'stream') {
|
|
|
|
|
response.data = stream;
|
|
|
|
|
settle(resolve, reject, response);
|
|
|
|
|
} else {
|
|
|
|
|
var responseBuffer = [];
|
|
|
|
|
stream.on('data', function handleStreamData(chunk) {
|
|
|
|
|
responseBuffer.push(chunk);
|
|
|
|
|
|
|
|
|
|
// make sure the content length is not over the maxContentLength if specified
|
|
|
|
|
if (config.maxContentLength > -1 && Buffer.concat(responseBuffer).length > config.maxContentLength) {
|
|
|
|
|
stream.destroy();
|
|
|
|
|
reject(createError('maxContentLength size of ' + config.maxContentLength + ' exceeded',
|
|
|
|
|
config, null, lastRequest));
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
stream.on('error', function handleStreamError(err) {
|
|
|
|
|
if (req.aborted) return;
|
|
|
|
|
reject(enhanceError(err, config, null, lastRequest));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
stream.on('end', function handleStreamEnd() {
|
|
|
|
|
var responseData = Buffer.concat(responseBuffer);
|
|
|
|
|
if (config.responseType !== 'arraybuffer') {
|
|
|
|
|
responseData = responseData.toString(config.responseEncoding);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
response.data = responseData;
|
|
|
|
|
settle(resolve, reject, response);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Handle errors
|
|
|
|
|
req.on('error', function handleRequestError(err) {
|
|
|
|
|
if (req.aborted) return;
|
|
|
|
|
reject(enhanceError(err, config, null, req));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Handle request timeout
|
|
|
|
|
if (config.timeout) {
|
|
|
|
|
timer = setTimeout(function handleRequestTimeout() {
|
|
|
|
|
req.abort();
|
|
|
|
|
reject(createError('timeout of ' + config.timeout + 'ms exceeded', config, 'ECONNABORTED', req));
|
|
|
|
|
}, config.timeout);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (config.cancelToken) {
|
|
|
|
|
// Handle cancellation
|
|
|
|
|
config.cancelToken.promise.then(function onCanceled(cancel) {
|
|
|
|
|
if (req.aborted) return;
|
|
|
|
|
|
|
|
|
|
req.abort();
|
|
|
|
|
reject(cancel);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Send the request
|
|
|
|
|
if (utils.isStream(data)) {
|
|
|
|
|
data.on('error', function handleStreamError(err) {
|
|
|
|
|
reject(enhanceError(err, config, null, req));
|
|
|
|
|
}).pipe(req);
|
|
|
|
|
} else {
|
|
|
|
|
req.end(data);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ "./node_modules/axios/lib/adapters/xhr.js":
|
|
|
|
|
/*!************************************************!*\
|
|
|
|
|
!*** ./node_modules/axios/lib/adapters/xhr.js ***!
|
|
|
|
|
\************************************************/
|
|
|
|
|
/*! no static exports found */
|
|
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
|
|
|
|
|
var settle = __webpack_require__(/*! ./../core/settle */ "./node_modules/axios/lib/core/settle.js");
|
|
|
|
|
var buildURL = __webpack_require__(/*! ./../helpers/buildURL */ "./node_modules/axios/lib/helpers/buildURL.js");
|
|
|
|
|
var parseHeaders = __webpack_require__(/*! ./../helpers/parseHeaders */ "./node_modules/axios/lib/helpers/parseHeaders.js");
|
|
|
|
|
var isURLSameOrigin = __webpack_require__(/*! ./../helpers/isURLSameOrigin */ "./node_modules/axios/lib/helpers/isURLSameOrigin.js");
|
|
|
|
|
var createError = __webpack_require__(/*! ../core/createError */ "./node_modules/axios/lib/core/createError.js");
|
|
|
|
|
|
|
|
|
|
module.exports = function xhrAdapter(config) {
|
|
|
|
|
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
|
|
|
|
var requestData = config.data;
|
|
|
|
|
var requestHeaders = config.headers;
|
|
|
|
|
|
|
|
|
|
if (utils.isFormData(requestData)) {
|
|
|
|
|
delete requestHeaders['Content-Type']; // Let the browser set it
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var request = new XMLHttpRequest();
|
|
|
|
|
|
|
|
|
|
// HTTP basic authentication
|
|
|
|
|
if (config.auth) {
|
|
|
|
|
var username = config.auth.username || '';
|
|
|
|
|
var password = config.auth.password || '';
|
|
|
|
|
requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
request.open(config.method.toUpperCase(), buildURL(config.url, config.params, config.paramsSerializer), true);
|
|
|
|
|
|
|
|
|
|
// Set the request timeout in MS
|
|
|
|
|
request.timeout = config.timeout;
|
|
|
|
|
|
|
|
|
|
// Listen for ready state
|
|
|
|
|
request.onreadystatechange = function handleLoad() {
|
|
|
|
|
if (!request || request.readyState !== 4) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// The request errored out and we didn't get a response, this will be
|
|
|
|
|
// handled by onerror instead
|
|
|
|
|
// With one exception: request that using file: protocol, most browsers
|
|
|
|
|
// will return status as 0 even though it's a successful request
|
|
|
|
|
if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Prepare the response
|
|
|
|
|
var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
|
|
|
|
|
var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;
|
|
|
|
|
var response = {
|
|
|
|
|
data: responseData,
|
|
|
|
|
status: request.status,
|
|
|
|
|
statusText: request.statusText,
|
|
|
|
|
headers: responseHeaders,
|
|
|
|
|
config: config,
|
|
|
|
|
request: request
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
settle(resolve, reject, response);
|
|
|
|
|
|
|
|
|
|
// Clean up request
|
|
|
|
|
request = null;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Handle browser request cancellation (as opposed to a manual cancellation)
|
|
|
|
|
request.onabort = function handleAbort() {
|
|
|
|
|
if (!request) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
reject(createError('Request aborted', config, 'ECONNABORTED', request));
|
|
|
|
|
|
|
|
|
|
// Clean up request
|
|
|
|
|
request = null;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Handle low level network errors
|
|
|
|
|
request.onerror = function handleError() {
|
|
|
|
|
// Real errors are hidden from us by the browser
|
|
|
|
|
// onerror should only fire if it's a network error
|
|
|
|
|
reject(createError('Network Error', config, null, request));
|
|
|
|
|
|
|
|
|
|
// Clean up request
|
|
|
|
|
request = null;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Handle timeout
|
|
|
|
|
request.ontimeout = function handleTimeout() {
|
|
|
|
|
reject(createError('timeout of ' + config.timeout + 'ms exceeded', config, 'ECONNABORTED',
|
|
|
|
|
request));
|
|
|
|
|
|
|
|
|
|
// Clean up request
|
|
|
|
|
request = null;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Add xsrf header
|
|
|
|
|
// This is only done if running in a standard browser environment.
|
|
|
|
|
// Specifically not if we're in a web worker, or react-native.
|
|
|
|
|
if (utils.isStandardBrowserEnv()) {
|
|
|
|
|
var cookies = __webpack_require__(/*! ./../helpers/cookies */ "./node_modules/axios/lib/helpers/cookies.js");
|
|
|
|
|
|
|
|
|
|
// Add xsrf header
|
|
|
|
|
var xsrfValue = (config.withCredentials || isURLSameOrigin(config.url)) && config.xsrfCookieName ?
|
|
|
|
|
cookies.read(config.xsrfCookieName) :
|
|
|
|
|
undefined;
|
|
|
|
|
|
|
|
|
|
if (xsrfValue) {
|
|
|
|
|
requestHeaders[config.xsrfHeaderName] = xsrfValue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Add headers to the request
|
|
|
|
|
if ('setRequestHeader' in request) {
|
|
|
|
|
utils.forEach(requestHeaders, function setRequestHeader(val, key) {
|
|
|
|
|
if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
|
|
|
|
|
// Remove Content-Type if data is undefined
|
|
|
|
|
delete requestHeaders[key];
|
|
|
|
|
} else {
|
|
|
|
|
// Otherwise add header to the request
|
|
|
|
|
request.setRequestHeader(key, val);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Add withCredentials to request if needed
|
|
|
|
|
if (config.withCredentials) {
|
|
|
|
|
request.withCredentials = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Add responseType to request if needed
|
|
|
|
|
if (config.responseType) {
|
|
|
|
|
try {
|
|
|
|
|
request.responseType = config.responseType;
|
|
|
|
|
} catch (e) {
|
|
|
|
|
// Expected DOMException thrown by browsers not compatible XMLHttpRequest Level 2.
|
|
|
|
|
// But, this can be suppressed for 'json' type as it can be parsed by default 'transformResponse' function.
|
|
|
|
|
if (config.responseType !== 'json') {
|
|
|
|
|
throw e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Handle progress if needed
|
|
|
|
|
if (typeof config.onDownloadProgress === 'function') {
|
|
|
|
|
request.addEventListener('progress', config.onDownloadProgress);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Not all browsers support upload events
|
|
|
|
|
if (typeof config.onUploadProgress === 'function' && request.upload) {
|
|
|
|
|
request.upload.addEventListener('progress', config.onUploadProgress);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (config.cancelToken) {
|
|
|
|
|
// Handle cancellation
|
|
|
|
|
config.cancelToken.promise.then(function onCanceled(cancel) {
|
|
|
|
|
if (!request) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
request.abort();
|
|
|
|
|
reject(cancel);
|
|
|
|
|
// Clean up request
|
|
|
|
|
request = null;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (requestData === undefined) {
|
|
|
|
|
requestData = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Send the request
|
|
|
|
|
request.send(requestData);
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ "./node_modules/axios/lib/axios.js":
|
|
|
|
|
/*!*****************************************!*\
|
|
|
|
|
!*** ./node_modules/axios/lib/axios.js ***!
|
|
|
|
|
\*****************************************/
|
|
|
|
|
/*! no static exports found */
|
|
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var utils = __webpack_require__(/*! ./utils */ "./node_modules/axios/lib/utils.js");
|
|
|
|
|
var bind = __webpack_require__(/*! ./helpers/bind */ "./node_modules/axios/lib/helpers/bind.js");
|
|
|
|
|
var Axios = __webpack_require__(/*! ./core/Axios */ "./node_modules/axios/lib/core/Axios.js");
|
|
|
|
|
var mergeConfig = __webpack_require__(/*! ./core/mergeConfig */ "./node_modules/axios/lib/core/mergeConfig.js");
|
|
|
|
|
var defaults = __webpack_require__(/*! ./defaults */ "./node_modules/axios/lib/defaults.js");
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create an instance of Axios
|
|
|
|
|
*
|
|
|
|
|
* @param {Object} defaultConfig The default config for the instance
|
|
|
|
|
* @return {Axios} A new instance of Axios
|
|
|
|
|
*/
|
|
|
|
|
function createInstance(defaultConfig) {
|
|
|
|
|
var context = new Axios(defaultConfig);
|
|
|
|
|
var instance = bind(Axios.prototype.request, context);
|
|
|
|
|
|
|
|
|
|
// Copy axios.prototype to instance
|
|
|
|
|
utils.extend(instance, Axios.prototype, context);
|
|
|
|
|
|
|
|
|
|
// Copy context to instance
|
|
|
|
|
utils.extend(instance, context);
|
|
|
|
|
|
|
|
|
|
return instance;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Create the default instance to be exported
|
|
|
|
|
var axios = createInstance(defaults);
|
|
|
|
|
|
|
|
|
|
// Expose Axios class to allow class inheritance
|
|
|
|
|
axios.Axios = Axios;
|
|
|
|
|
|
|
|
|
|
// Factory for creating new instances
|
|
|
|
|
axios.create = function create(instanceConfig) {
|
|
|
|
|
return createInstance(mergeConfig(axios.defaults, instanceConfig));
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Expose Cancel & CancelToken
|
|
|
|
|
axios.Cancel = __webpack_require__(/*! ./cancel/Cancel */ "./node_modules/axios/lib/cancel/Cancel.js");
|
|
|
|
|
axios.CancelToken = __webpack_require__(/*! ./cancel/CancelToken */ "./node_modules/axios/lib/cancel/CancelToken.js");
|
|
|
|
|
axios.isCancel = __webpack_require__(/*! ./cancel/isCancel */ "./node_modules/axios/lib/cancel/isCancel.js");
|
|
|
|
|
|
|
|
|
|
// Expose all/spread
|
|
|
|
|
axios.all = function all(promises) {
|
|
|
|
|
return Promise.all(promises);
|
|
|
|
|
};
|
|
|
|
|
axios.spread = __webpack_require__(/*! ./helpers/spread */ "./node_modules/axios/lib/helpers/spread.js");
|
|
|
|
|
|
|
|
|
|
module.exports = axios;
|
|
|
|
|
|
|
|
|
|
// Allow use of default import syntax in TypeScript
|
|
|
|
|
module.exports.default = axios;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ "./node_modules/axios/lib/cancel/Cancel.js":
|
|
|
|
|
/*!*************************************************!*\
|
|
|
|
|
!*** ./node_modules/axios/lib/cancel/Cancel.js ***!
|
|
|
|
|
\*************************************************/
|
|
|
|
|
/*! no static exports found */
|
|
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* A `Cancel` is an object that is thrown when an operation is canceled.
|
|
|
|
|
*
|
|
|
|
|
* @class
|
|
|
|
|
* @param {string=} message The message.
|
|
|
|
|
*/
|
|
|
|
|
function Cancel(message) {
|
|
|
|
|
this.message = message;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Cancel.prototype.toString = function toString() {
|
|
|
|
|
return 'Cancel' + (this.message ? ': ' + this.message : '');
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Cancel.prototype.__CANCEL__ = true;
|
|
|
|
|
|
|
|
|
|
module.exports = Cancel;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ "./node_modules/axios/lib/cancel/CancelToken.js":
|
|
|
|
|
/*!******************************************************!*\
|
|
|
|
|
!*** ./node_modules/axios/lib/cancel/CancelToken.js ***!
|
|
|
|
|
\******************************************************/
|
|
|
|
|
/*! no static exports found */
|
|
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var Cancel = __webpack_require__(/*! ./Cancel */ "./node_modules/axios/lib/cancel/Cancel.js");
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* A `CancelToken` is an object that can be used to request cancellation of an operation.
|
|
|
|
|
*
|
|
|
|
|
* @class
|
|
|
|
|
* @param {Function} executor The executor function.
|
|
|
|
|
*/
|
|
|
|
|
function CancelToken(executor) {
|
|
|
|
|
if (typeof executor !== 'function') {
|
|
|
|
|
throw new TypeError('executor must be a function.');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var resolvePromise;
|
|
|
|
|
this.promise = new Promise(function promiseExecutor(resolve) {
|
|
|
|
|
resolvePromise = resolve;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var token = this;
|
|
|
|
|
executor(function cancel(message) {
|
|
|
|
|
if (token.reason) {
|
|
|
|
|
// Cancellation has already been requested
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
token.reason = new Cancel(message);
|
|
|
|
|
resolvePromise(token.reason);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Throws a `Cancel` if cancellation has been requested.
|
|
|
|
|
*/
|
|
|
|
|
CancelToken.prototype.throwIfRequested = function throwIfRequested() {
|
|
|
|
|
if (this.reason) {
|
|
|
|
|
throw this.reason;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns an object that contains a new `CancelToken` and a function that, when called,
|
|
|
|
|
* cancels the `CancelToken`.
|
|
|
|
|
*/
|
|
|
|
|
CancelToken.source = function source() {
|
|
|
|
|
var cancel;
|
|
|
|
|
var token = new CancelToken(function executor(c) {
|
|
|
|
|
cancel = c;
|
|
|
|
|
});
|
|
|
|
|
return {
|
|
|
|
|
token: token,
|
|
|
|
|
cancel: cancel
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
module.exports = CancelToken;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ "./node_modules/axios/lib/cancel/isCancel.js":
|
|
|
|
|
/*!***************************************************!*\
|
|
|
|
|
!*** ./node_modules/axios/lib/cancel/isCancel.js ***!
|
|
|
|
|
\***************************************************/
|
|
|
|
|
/*! no static exports found */
|
|
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = function isCancel(value) {
|
|
|
|
|
return !!(value && value.__CANCEL__);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ "./node_modules/axios/lib/core/Axios.js":
|
|
|
|
|
/*!**********************************************!*\
|
|
|
|
|
!*** ./node_modules/axios/lib/core/Axios.js ***!
|
|
|
|
|
\**********************************************/
|
|
|
|
|
/*! no static exports found */
|
|
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
|
|
|
|
|
var buildURL = __webpack_require__(/*! ../helpers/buildURL */ "./node_modules/axios/lib/helpers/buildURL.js");
|
|
|
|
|
var InterceptorManager = __webpack_require__(/*! ./InterceptorManager */ "./node_modules/axios/lib/core/InterceptorManager.js");
|
|
|
|
|
var dispatchRequest = __webpack_require__(/*! ./dispatchRequest */ "./node_modules/axios/lib/core/dispatchRequest.js");
|
|
|
|
|
var mergeConfig = __webpack_require__(/*! ./mergeConfig */ "./node_modules/axios/lib/core/mergeConfig.js");
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create a new instance of Axios
|
|
|
|
|
*
|
|
|
|
|
* @param {Object} instanceConfig The default config for the instance
|
|
|
|
|
*/
|
|
|
|
|
function Axios(instanceConfig) {
|
|
|
|
|
this.defaults = instanceConfig;
|
|
|
|
|
this.interceptors = {
|
|
|
|
|
request: new InterceptorManager(),
|
|
|
|
|
response: new InterceptorManager()
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Dispatch a request
|
|
|
|
|
*
|
|
|
|
|
* @param {Object} config The config specific for this request (merged with this.defaults)
|
|
|
|
|
*/
|
|
|
|
|
Axios.prototype.request = function request(config) {
|
|
|
|
|
/*eslint no-param-reassign:0*/
|
|
|
|
|
// Allow for axios('example/url'[, config]) a la fetch API
|
|
|
|
|
if (typeof config === 'string') {
|
|
|
|
|
config = arguments[1] || {};
|
|
|
|
|
config.url = arguments[0];
|
|
|
|
|
} else {
|
|
|
|
|
config = config || {};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
config = mergeConfig(this.defaults, config);
|
|
|
|
|
config.method = config.method ? config.method.toLowerCase() : 'get';
|
|
|
|
|
|
|
|
|
|
// Hook up interceptors middleware
|
|
|
|
|
var chain = [dispatchRequest, undefined];
|
|
|
|
|
var promise = Promise.resolve(config);
|
|
|
|
|
|
|
|
|
|
this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
|
|
|
|
|
chain.unshift(interceptor.fulfilled, interceptor.rejected);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
|
|
|
|
|
chain.push(interceptor.fulfilled, interceptor.rejected);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
while (chain.length) {
|
|
|
|
|
promise = promise.then(chain.shift(), chain.shift());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return promise;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Axios.prototype.getUri = function getUri(config) {
|
|
|
|
|
config = mergeConfig(this.defaults, config);
|
|
|
|
|
return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, '');
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Provide aliases for supported request methods
|
|
|
|
|
utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
|
|
|
|
|
/*eslint func-names:0*/
|
|
|
|
|
Axios.prototype[method] = function(url, config) {
|
|
|
|
|
return this.request(utils.merge(config || {}, {
|
|
|
|
|
method: method,
|
|
|
|
|
url: url
|
|
|
|
|
}));
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
|
|
|
|
/*eslint func-names:0*/
|
|
|
|
|
Axios.prototype[method] = function(url, data, config) {
|
|
|
|
|
return this.request(utils.merge(config || {}, {
|
|
|
|
|
method: method,
|
|
|
|
|
url: url,
|
|
|
|
|
data: data
|
|
|
|
|
}));
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
module.exports = Axios;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ "./node_modules/axios/lib/core/InterceptorManager.js":
|
|
|
|
|
/*!***********************************************************!*\
|
|
|
|
|
!*** ./node_modules/axios/lib/core/InterceptorManager.js ***!
|
|
|
|
|
\***********************************************************/
|
|
|
|
|
/*! no static exports found */
|
|
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
|
|
|
|
|
|
|
|
|
|
function InterceptorManager() {
|
|
|
|
|
this.handlers = [];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Add a new interceptor to the stack
|
|
|
|
|
*
|
|
|
|
|
* @param {Function} fulfilled The function to handle `then` for a `Promise`
|
|
|
|
|
* @param {Function} rejected The function to handle `reject` for a `Promise`
|
|
|
|
|
*
|
|
|
|
|
* @return {Number} An ID used to remove interceptor later
|
|
|
|
|
*/
|
|
|
|
|
InterceptorManager.prototype.use = function use(fulfilled, rejected) {
|
|
|
|
|
this.handlers.push({
|
|
|
|
|
fulfilled: fulfilled,
|
|
|
|
|
rejected: rejected
|
|
|
|
|
});
|
|
|
|
|
return this.handlers.length - 1;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Remove an interceptor from the stack
|
|
|
|
|
*
|
|
|
|
|
* @param {Number} id The ID that was returned by `use`
|
|
|
|
|
*/
|
|
|
|
|
InterceptorManager.prototype.eject = function eject(id) {
|
|
|
|
|
if (this.handlers[id]) {
|
|
|
|
|
this.handlers[id] = null;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Iterate over all the registered interceptors
|
|
|
|
|
*
|
|
|
|
|
* This method is particularly useful for skipping over any
|
|
|
|
|
* interceptors that may have become `null` calling `eject`.
|
|
|
|
|
*
|
|
|
|
|
* @param {Function} fn The function to call for each interceptor
|
|
|
|
|
*/
|
|
|
|
|
InterceptorManager.prototype.forEach = function forEach(fn) {
|
|
|
|
|
utils.forEach(this.handlers, function forEachHandler(h) {
|
|
|
|
|
if (h !== null) {
|
|
|
|
|
fn(h);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
module.exports = InterceptorManager;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ "./node_modules/axios/lib/core/createError.js":
|
|
|
|
|
/*!****************************************************!*\
|
|
|
|
|
!*** ./node_modules/axios/lib/core/createError.js ***!
|
|
|
|
|
\****************************************************/
|
|
|
|
|
/*! no static exports found */
|
|
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var enhanceError = __webpack_require__(/*! ./enhanceError */ "./node_modules/axios/lib/core/enhanceError.js");
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create an Error with the specified message, config, error code, request and response.
|
|
|
|
|
*
|
|
|
|
|
* @param {string} message The error message.
|
|
|
|
|
* @param {Object} config The config.
|
|
|
|
|
* @param {string} [code] The error code (for example, 'ECONNABORTED').
|
|
|
|
|
* @param {Object} [request] The request.
|
|
|
|
|
* @param {Object} [response] The response.
|
|
|
|
|
* @returns {Error} The created error.
|
|
|
|
|
*/
|
|
|
|
|
module.exports = function createError(message, config, code, request, response) {
|
|
|
|
|
var error = new Error(message);
|
|
|
|
|
return enhanceError(error, config, code, request, response);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ "./node_modules/axios/lib/core/dispatchRequest.js":
|
|
|
|
|
/*!********************************************************!*\
|
|
|
|
|
!*** ./node_modules/axios/lib/core/dispatchRequest.js ***!
|
|
|
|
|
\********************************************************/
|
|
|
|
|
/*! no static exports found */
|
|
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
|
|
|
|
|
var transformData = __webpack_require__(/*! ./transformData */ "./node_modules/axios/lib/core/transformData.js");
|
|
|
|
|
var isCancel = __webpack_require__(/*! ../cancel/isCancel */ "./node_modules/axios/lib/cancel/isCancel.js");
|
|
|
|
|
var defaults = __webpack_require__(/*! ../defaults */ "./node_modules/axios/lib/defaults.js");
|
|
|
|
|
var isAbsoluteURL = __webpack_require__(/*! ./../helpers/isAbsoluteURL */ "./node_modules/axios/lib/helpers/isAbsoluteURL.js");
|
|
|
|
|
var combineURLs = __webpack_require__(/*! ./../helpers/combineURLs */ "./node_modules/axios/lib/helpers/combineURLs.js");
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Throws a `Cancel` if cancellation has been requested.
|
|
|
|
|
*/
|
|
|
|
|
function throwIfCancellationRequested(config) {
|
|
|
|
|
if (config.cancelToken) {
|
|
|
|
|
config.cancelToken.throwIfRequested();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Dispatch a request to the server using the configured adapter.
|
|
|
|
|
*
|
|
|
|
|
* @param {object} config The config that is to be used for the request
|
|
|
|
|
* @returns {Promise} The Promise to be fulfilled
|
|
|
|
|
*/
|
|
|
|
|
module.exports = function dispatchRequest(config) {
|
|
|
|
|
throwIfCancellationRequested(config);
|
|
|
|
|
|
|
|
|
|
// Support baseURL config
|
|
|
|
|
if (config.baseURL && !isAbsoluteURL(config.url)) {
|
|
|
|
|
config.url = combineURLs(config.baseURL, config.url);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Ensure headers exist
|
|
|
|
|
config.headers = config.headers || {};
|
|
|
|
|
|
|
|
|
|
// Transform request data
|
|
|
|
|
config.data = transformData(
|
|
|
|
|
config.data,
|
|
|
|
|
config.headers,
|
|
|
|
|
config.transformRequest
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Flatten headers
|
|
|
|
|
config.headers = utils.merge(
|
|
|
|
|
config.headers.common || {},
|
|
|
|
|
config.headers[config.method] || {},
|
|
|
|
|
config.headers || {}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
utils.forEach(
|
|
|
|
|
['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
|
|
|
|
|
function cleanHeaderConfig(method) {
|
|
|
|
|
delete config.headers[method];
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
var adapter = config.adapter || defaults.adapter;
|
|
|
|
|
|
|
|
|
|
return adapter(config).then(function onAdapterResolution(response) {
|
|
|
|
|
throwIfCancellationRequested(config);
|
|
|
|
|
|
|
|
|
|
// Transform response data
|
|
|
|
|
response.data = transformData(
|
|
|
|
|
response.data,
|
|
|
|
|
response.headers,
|
|
|
|
|
config.transformResponse
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return response;
|
|
|
|
|
}, function onAdapterRejection(reason) {
|
|
|
|
|
if (!isCancel(reason)) {
|
|
|
|
|
throwIfCancellationRequested(config);
|
|
|
|
|
|
|
|
|
|
// Transform response data
|
|
|
|
|
if (reason && reason.response) {
|
|
|
|
|
reason.response.data = transformData(
|
|
|
|
|
reason.response.data,
|
|
|
|
|
reason.response.headers,
|
|
|
|
|
config.transformResponse
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Promise.reject(reason);
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ "./node_modules/axios/lib/core/enhanceError.js":
|
|
|
|
|
/*!*****************************************************!*\
|
|
|
|
|
!*** ./node_modules/axios/lib/core/enhanceError.js ***!
|
|
|
|
|
\*****************************************************/
|
|
|
|
|
/*! no static exports found */
|
|
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Update an Error with the specified config, error code, and response.
|
|
|
|
|
*
|
|
|
|
|
* @param {Error} error The error to update.
|
|
|
|
|
* @param {Object} config The config.
|
|
|
|
|
* @param {string} [code] The error code (for example, 'ECONNABORTED').
|
|
|
|
|
* @param {Object} [request] The request.
|
|
|
|
|
* @param {Object} [response] The response.
|
|
|
|
|
* @returns {Error} The error.
|
|
|
|
|
*/
|
|
|
|
|
module.exports = function enhanceError(error, config, code, request, response) {
|
|
|
|
|
error.config = config;
|
|
|
|
|
if (code) {
|
|
|
|
|
error.code = code;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
error.request = request;
|
|
|
|
|
error.response = response;
|
|
|
|
|
error.isAxiosError = true;
|
|
|
|
|
|
|
|
|
|
error.toJSON = function() {
|
|
|
|
|
return {
|
|
|
|
|
// Standard
|
|
|
|
|
message: this.message,
|
|
|
|
|
name: this.name,
|
|
|
|
|
// Microsoft
|
|
|
|
|
description: this.description,
|
|
|
|
|
number: this.number,
|
|
|
|
|
// Mozilla
|
|
|
|
|
fileName: this.fileName,
|
|
|
|
|
lineNumber: this.lineNumber,
|
|
|
|
|
columnNumber: this.columnNumber,
|
|
|
|
|
stack: this.stack,
|
|
|
|
|
// Axios
|
|
|
|
|
config: this.config,
|
|
|
|
|
code: this.code
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
return error;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ "./node_modules/axios/lib/core/mergeConfig.js":
|
|
|
|
|
/*!****************************************************!*\
|
|
|
|
|
!*** ./node_modules/axios/lib/core/mergeConfig.js ***!
|
|
|
|
|
\****************************************************/
|
|
|
|
|
/*! no static exports found */
|
|
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var utils = __webpack_require__(/*! ../utils */ "./node_modules/axios/lib/utils.js");
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Config-specific merge-function which creates a new config-object
|
|
|
|
|
* by merging two configuration objects together.
|
|
|
|
|
*
|
|
|
|
|
* @param {Object} config1
|
|
|
|
|
* @param {Object} config2
|
|
|
|
|
* @returns {Object} New object resulting from merging config2 to config1
|
|
|
|
|
*/
|
|
|
|
|
module.exports = function mergeConfig(config1, config2) {
|
|
|
|
|
// eslint-disable-next-line no-param-reassign
|
|
|
|
|
config2 = config2 || {};
|
|
|
|
|
var config = {};
|
|
|
|
|
|
|
|
|
|
utils.forEach(['url', 'method', 'params', 'data'], function valueFromConfig2(prop) {
|
|
|
|
|
if (typeof config2[prop] !== 'undefined') {
|
|
|
|
|
config[prop] = config2[prop];
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
utils.forEach(['headers', 'auth', 'proxy'], function mergeDeepProperties(prop) {
|
|
|
|
|
if (utils.isObject(config2[prop])) {
|
|
|
|
|
config[prop] = utils.deepMerge(config1[prop], config2[prop]);
|
|
|
|
|
} else if (typeof config2[prop] !== 'undefined') {
|
|
|
|
|
config[prop] = config2[prop];
|
|
|
|
|
} else if (utils.isObject(config1[prop])) {
|
|
|
|
|
config[prop] = utils.deepMerge(config1[prop]);
|
|
|
|
|
} else if (typeof config1[prop] !== 'undefined') {
|
|
|
|
|
config[prop] = config1[prop];
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
utils.forEach([
|
|
|
|
|
'baseURL', 'transformRequest', 'transformResponse', 'paramsSerializer',
|
|
|
|
|
'timeout', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName',
|
|
|
|
|
'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress', 'maxContentLength',
|
|
|
|
|
'validateStatus', 'maxRedirects', 'httpAgent', 'httpsAgent', 'cancelToken',
|
|
|
|
|
'socketPath'
|
|
|
|
|
], function defaultToConfig2(prop) {
|
|
|
|
|
if (typeof config2[prop] !== 'undefined') {
|
|
|
|
|
config[prop] = config2[prop];
|
|
|
|
|
} else if (typeof config1[prop] !== 'undefined') {
|
|
|
|
|
config[prop] = config1[prop];
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return config;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ "./node_modules/axios/lib/core/settle.js":
|
|
|
|
|
/*!***********************************************!*\
|
|
|
|
|
!*** ./node_modules/axios/lib/core/settle.js ***!
|
|
|
|
|
\***********************************************/
|
|
|
|
|
/*! no static exports found */
|
|
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var createError = __webpack_require__(/*! ./createError */ "./node_modules/axios/lib/core/createError.js");
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Resolve or reject a Promise based on response status.
|
|
|
|
|
*
|
|
|
|
|
* @param {Function} resolve A function that resolves the promise.
|
|
|
|
|
* @param {Function} reject A function that rejects the promise.
|
|
|
|
|
* @param {object} response The response.
|
|
|
|
|
*/
|
|
|
|
|
module.exports = function settle(resolve, reject, response) {
|
|
|
|
|
var validateStatus = response.config.validateStatus;
|
|
|
|
|
if (!validateStatus || validateStatus(response.status)) {
|
|
|
|
|
resolve(response);
|
|
|
|
|
} else {
|
|
|
|
|
reject(createError(
|
|
|
|
|
'Request failed with status code ' + response.status,
|
|
|
|
|
response.config,
|
|
|
|
|
null,
|
|
|
|
|
response.request,
|
|
|
|
|
response
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ "./node_modules/axios/lib/core/transformData.js":
|
|
|
|
|
/*!******************************************************!*\
|
|
|
|
|
!*** ./node_modules/axios/lib/core/transformData.js ***!
|
|
|
|
|
\******************************************************/
|
|
|
|
|
/*! no static exports found */
|
|
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Transform the data for a request or a response
|
|
|
|
|
*
|
|
|
|
|
* @param {Object|String} data The data to be transformed
|
|
|
|
|
* @param {Array} headers The headers for the request or response
|
|
|
|
|
* @param {Array|Function} fns A single function or Array of functions
|
|
|
|
|
* @returns {*} The resulting transformed data
|
|
|
|
|
*/
|
|
|
|
|
module.exports = function transformData(data, headers, fns) {
|
|
|
|
|
/*eslint no-param-reassign:0*/
|
|
|
|
|
utils.forEach(fns, function transform(fn) {
|
|
|
|
|
data = fn(data, headers);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return data;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ "./node_modules/axios/lib/defaults.js":
|
|
|
|
|
/*!********************************************!*\
|
|
|
|
|
!*** ./node_modules/axios/lib/defaults.js ***!
|
|
|
|
|
\********************************************/
|
|
|
|
|
/*! no static exports found */
|
|
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var utils = __webpack_require__(/*! ./utils */ "./node_modules/axios/lib/utils.js");
|
|
|
|
|
var normalizeHeaderName = __webpack_require__(/*! ./helpers/normalizeHeaderName */ "./node_modules/axios/lib/helpers/normalizeHeaderName.js");
|
|
|
|
|
|
|
|
|
|
var DEFAULT_CONTENT_TYPE = {
|
|
|
|
|
'Content-Type': 'application/x-www-form-urlencoded'
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function setContentTypeIfUnset(headers, value) {
|
|
|
|
|
if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
|
|
|
|
|
headers['Content-Type'] = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getDefaultAdapter() {
|
|
|
|
|
var adapter;
|
|
|
|
|
// Only Node.JS has a process variable that is of [[Class]] process
|
|
|
|
|
if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
|
|
|
|
|
// For node use HTTP adapter
|
|
|
|
|
adapter = __webpack_require__(/*! ./adapters/http */ "./node_modules/axios/lib/adapters/http.js");
|
|
|
|
|
} else if (typeof XMLHttpRequest !== 'undefined') {
|
|
|
|
|
// For browsers use XHR adapter
|
|
|
|
|
adapter = __webpack_require__(/*! ./adapters/xhr */ "./node_modules/axios/lib/adapters/xhr.js");
|
|
|
|
|
}
|
|
|
|
|
return adapter;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var defaults = {
|
|
|
|
|
adapter: getDefaultAdapter(),
|
|
|
|
|
|
|
|
|
|
transformRequest: [function transformRequest(data, headers) {
|
|
|
|
|
normalizeHeaderName(headers, 'Accept');
|
|
|
|
|
normalizeHeaderName(headers, 'Content-Type');
|
|
|
|
|
if (utils.isFormData(data) ||
|
|
|
|
|
utils.isArrayBuffer(data) ||
|
|
|
|
|
utils.isBuffer(data) ||
|
|
|
|
|
utils.isStream(data) ||
|
|
|
|
|
utils.isFile(data) ||
|
|
|
|
|
utils.isBlob(data)
|
|
|
|
|
) {
|
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
if (utils.isArrayBufferView(data)) {
|
|
|
|
|
return data.buffer;
|
|
|
|
|
}
|
|
|
|
|
if (utils.isURLSearchParams(data)) {
|
|
|
|
|
setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
|
|
|
|
|
return data.toString();
|
|
|
|
|
}
|
|
|
|
|
if (utils.isObject(data)) {
|
|
|
|
|
setContentTypeIfUnset(headers, 'application/json;charset=utf-8');
|
|
|
|
|
return JSON.stringify(data);
|
|
|
|
|
}
|
|
|
|
|
return data;
|
|
|
|
|
}],
|
|
|
|
|
|
|
|
|
|
transformResponse: [function transformResponse(data) {
|
|
|
|
|
/*eslint no-param-reassign:0*/
|
|
|
|
|
if (typeof data === 'string') {
|
|
|
|
|
try {
|
|
|
|
|
data = JSON.parse(data);
|
|
|
|
|
} catch (e) { /* Ignore */ }
|
|
|
|
|
}
|
|
|
|
|
return data;
|
|
|
|
|
}],
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* A timeout in milliseconds to abort a request. If set to 0 (default) a
|
|
|
|
|
* timeout is not created.
|
|
|
|
|
*/
|
|
|
|
|
timeout: 0,
|
|
|
|
|
|
|
|
|
|
xsrfCookieName: 'XSRF-TOKEN',
|
|
|
|
|
xsrfHeaderName: 'X-XSRF-TOKEN',
|
|
|
|
|
|
|
|
|
|
maxContentLength: -1,
|
|
|
|
|
|
|
|
|
|
validateStatus: function validateStatus(status) {
|
|
|
|
|
return status >= 200 && status < 300;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
defaults.headers = {
|
|
|
|
|
common: {
|
|
|
|
|
'Accept': 'application/json, text/plain, */*'
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
|
|
|
|
|
defaults.headers[method] = {};
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
|
|
|
|
defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
module.exports = defaults;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ "./node_modules/axios/lib/helpers/bind.js":
|
|
|
|
|
/*!************************************************!*\
|
|
|
|
|
!*** ./node_modules/axios/lib/helpers/bind.js ***!
|
|
|
|
|
\************************************************/
|
|
|
|
|
/*! no static exports found */
|
|
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = function bind(fn, thisArg) {
|
|
|
|
|
return function wrap() {
|
|
|
|
|
var args = new Array(arguments.length);
|
|
|
|
|
for (var i = 0; i < args.length; i++) {
|
|
|
|
|
args[i] = arguments[i];
|
|
|
|
|
}
|
|
|
|
|
return fn.apply(thisArg, args);
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ "./node_modules/axios/lib/helpers/buildURL.js":
|
|
|
|
|
/*!****************************************************!*\
|
|
|
|
|
!*** ./node_modules/axios/lib/helpers/buildURL.js ***!
|
|
|
|
|
\****************************************************/
|
|
|
|
|
/*! no static exports found */
|
|
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
|
|
|
|
|
|
|
|
|
|
function encode(val) {
|
|
|
|
|
return encodeURIComponent(val).
|
|
|
|
|
replace(/%40/gi, '@').
|
|
|
|
|
replace(/%3A/gi, ':').
|
|
|
|
|
replace(/%24/g, '$').
|
|
|
|
|
replace(/%2C/gi, ',').
|
|
|
|
|
replace(/%20/g, '+').
|
|
|
|
|
replace(/%5B/gi, '[').
|
|
|
|
|
replace(/%5D/gi, ']');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Build a URL by appending params to the end
|
|
|
|
|
*
|
|
|
|
|
* @param {string} url The base of the url (e.g., http://www.google.com)
|
|
|
|
|
* @param {object} [params] The params to be appended
|
|
|
|
|
* @returns {string} The formatted url
|
|
|
|
|
*/
|
|
|
|
|
module.exports = function buildURL(url, params, paramsSerializer) {
|
|
|
|
|
/*eslint no-param-reassign:0*/
|
|
|
|
|
if (!params) {
|
|
|
|
|
return url;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var serializedParams;
|
|
|
|
|
if (paramsSerializer) {
|
|
|
|
|
serializedParams = paramsSerializer(params);
|
|
|
|
|
} else if (utils.isURLSearchParams(params)) {
|
|
|
|
|
serializedParams = params.toString();
|
|
|
|
|
} else {
|
|
|
|
|
var parts = [];
|
|
|
|
|
|
|
|
|
|
utils.forEach(params, function serialize(val, key) {
|
|
|
|
|
if (val === null || typeof val === 'undefined') {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (utils.isArray(val)) {
|
|
|
|
|
key = key + '[]';
|
|
|
|
|
} else {
|
|
|
|
|
val = [val];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
utils.forEach(val, function parseValue(v) {
|
|
|
|
|
if (utils.isDate(v)) {
|
|
|
|
|
v = v.toISOString();
|
|
|
|
|
} else if (utils.isObject(v)) {
|
|
|
|
|
v = JSON.stringify(v);
|
|
|
|
|
}
|
|
|
|
|
parts.push(encode(key) + '=' + encode(v));
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
serializedParams = parts.join('&');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (serializedParams) {
|
|
|
|
|
var hashmarkIndex = url.indexOf('#');
|
|
|
|
|
if (hashmarkIndex !== -1) {
|
|
|
|
|
url = url.slice(0, hashmarkIndex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return url;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ "./node_modules/axios/lib/helpers/combineURLs.js":
|
|
|
|
|
/*!*******************************************************!*\
|
|
|
|
|
!*** ./node_modules/axios/lib/helpers/combineURLs.js ***!
|
|
|
|
|
\*******************************************************/
|
|
|
|
|
/*! no static exports found */
|
|
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Creates a new URL by combining the specified URLs
|
|
|
|
|
*
|
|
|
|
|
* @param {string} baseURL The base URL
|
|
|
|
|
* @param {string} relativeURL The relative URL
|
|
|
|
|
* @returns {string} The combined URL
|
|
|
|
|
*/
|
|
|
|
|
module.exports = function combineURLs(baseURL, relativeURL) {
|
|
|
|
|
return relativeURL
|
|
|
|
|
? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
|
|
|
|
|
: baseURL;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ "./node_modules/axios/lib/helpers/cookies.js":
|
|
|
|
|
/*!***************************************************!*\
|
|
|
|
|
!*** ./node_modules/axios/lib/helpers/cookies.js ***!
|
|
|
|
|
\***************************************************/
|
|
|
|
|
/*! no static exports found */
|
|
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
|
|
|
|
|
|
|
|
|
|
module.exports = (
|
|
|
|
|
utils.isStandardBrowserEnv() ?
|
|
|
|
|
|
|
|
|
|
// Standard browser envs support document.cookie
|
|
|
|
|
(function standardBrowserEnv() {
|
|
|
|
|
return {
|
|
|
|
|
write: function write(name, value, expires, path, domain, secure) {
|
|
|
|
|
var cookie = [];
|
|
|
|
|
cookie.push(name + '=' + encodeURIComponent(value));
|
|
|
|
|
|
|
|
|
|
if (utils.isNumber(expires)) {
|
|
|
|
|
cookie.push('expires=' + new Date(expires).toGMTString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (utils.isString(path)) {
|
|
|
|
|
cookie.push('path=' + path);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (utils.isString(domain)) {
|
|
|
|
|
cookie.push('domain=' + domain);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (secure === true) {
|
|
|
|
|
cookie.push('secure');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
document.cookie = cookie.join('; ');
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
read: function read(name) {
|
|
|
|
|
var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
|
|
|
|
|
return (match ? decodeURIComponent(match[3]) : null);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
remove: function remove(name) {
|
|
|
|
|
this.write(name, '', Date.now() - 86400000);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
})() :
|
|
|
|
|
|
|
|
|
|
// Non standard browser env (web workers, react-native) lack needed support.
|
|
|
|
|
(function nonStandardBrowserEnv() {
|
|
|
|
|
return {
|
|
|
|
|
write: function write() {},
|
|
|
|
|
read: function read() { return null; },
|
|
|
|
|
remove: function remove() {}
|
|
|
|
|
};
|
|
|
|
|
})()
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ "./node_modules/axios/lib/helpers/isAbsoluteURL.js":
|
|
|
|
|
/*!*********************************************************!*\
|
|
|
|
|
!*** ./node_modules/axios/lib/helpers/isAbsoluteURL.js ***!
|
|
|
|
|
\*********************************************************/
|
|
|
|
|
/*! no static exports found */
|
|
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Determines whether the specified URL is absolute
|
|
|
|
|
*
|
|
|
|
|
* @param {string} url The URL to test
|
|
|
|
|
* @returns {boolean} True if the specified URL is absolute, otherwise false
|
|
|
|
|
*/
|
|
|
|
|
module.exports = function isAbsoluteURL(url) {
|
|
|
|
|
// A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
|
|
|
|
|
// RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
|
|
|
|
|
// by any combination of letters, digits, plus, period, or hyphen.
|
|
|
|
|
return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ "./node_modules/axios/lib/helpers/isURLSameOrigin.js":
|
|
|
|
|
/*!***********************************************************!*\
|
|
|
|
|
!*** ./node_modules/axios/lib/helpers/isURLSameOrigin.js ***!
|
|
|
|
|
\***********************************************************/
|
|
|
|
|
/*! no static exports found */
|
|
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
|
|
|
|
|
|
|
|
|
|
module.exports = (
|
|
|
|
|
utils.isStandardBrowserEnv() ?
|
|
|
|
|
|
|
|
|
|
// Standard browser envs have full support of the APIs needed to test
|
|
|
|
|
// whether the request URL is of the same origin as current location.
|
|
|
|
|
(function standardBrowserEnv() {
|
|
|
|
|
var msie = /(msie|trident)/i.test(navigator.userAgent);
|
|
|
|
|
var urlParsingNode = document.createElement('a');
|
|
|
|
|
var originURL;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Parse a URL to discover it's components
|
|
|
|
|
*
|
|
|
|
|
* @param {String} url The URL to be parsed
|
|
|
|
|
* @returns {Object}
|
|
|
|
|
*/
|
|
|
|
|
function resolveURL(url) {
|
|
|
|
|
var href = url;
|
|
|
|
|
|
|
|
|
|
if (msie) {
|
|
|
|
|
// IE needs attribute set twice to normalize properties
|
|
|
|
|
urlParsingNode.setAttribute('href', href);
|
|
|
|
|
href = urlParsingNode.href;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
urlParsingNode.setAttribute('href', href);
|
|
|
|
|
|
|
|
|
|
// urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
|
|
|
|
|
return {
|
|
|
|
|
href: urlParsingNode.href,
|
|
|
|
|
protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
|
|
|
|
|
host: urlParsingNode.host,
|
|
|
|
|
search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
|
|
|
|
|
hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
|
|
|
|
|
hostname: urlParsingNode.hostname,
|
|
|
|
|
port: urlParsingNode.port,
|
|
|
|
|
pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
|
|
|
|
|
urlParsingNode.pathname :
|
|
|
|
|
'/' + urlParsingNode.pathname
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
originURL = resolveURL(window.location.href);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Determine if a URL shares the same origin as the current location
|
|
|
|
|
*
|
|
|
|
|
* @param {String} requestURL The URL to test
|
|
|
|
|
* @returns {boolean} True if URL shares the same origin, otherwise false
|
|
|
|
|
*/
|
|
|
|
|
return function isURLSameOrigin(requestURL) {
|
|
|
|
|
var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
|
|
|
|
|
return (parsed.protocol === originURL.protocol &&
|
|
|
|
|
parsed.host === originURL.host);
|
|
|
|
|
};
|
|
|
|
|
})() :
|
|
|
|
|
|
|
|
|
|
// Non standard browser envs (web workers, react-native) lack needed support.
|
|
|
|
|
(function nonStandardBrowserEnv() {
|
|
|
|
|
return function isURLSameOrigin() {
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
})()
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ "./node_modules/axios/lib/helpers/normalizeHeaderName.js":
|
|
|
|
|
/*!***************************************************************!*\
|
|
|
|
|
!*** ./node_modules/axios/lib/helpers/normalizeHeaderName.js ***!
|
|
|
|
|
\***************************************************************/
|
|
|
|
|
/*! no static exports found */
|
|
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var utils = __webpack_require__(/*! ../utils */ "./node_modules/axios/lib/utils.js");
|
|
|
|
|
|
|
|
|
|
module.exports = function normalizeHeaderName(headers, normalizedName) {
|
|
|
|
|
utils.forEach(headers, function processHeader(value, name) {
|
|
|
|
|
if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
|
|
|
|
|
headers[normalizedName] = value;
|
|
|
|
|
delete headers[name];
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ "./node_modules/axios/lib/helpers/parseHeaders.js":
|
|
|
|
|
/*!********************************************************!*\
|
|
|
|
|
!*** ./node_modules/axios/lib/helpers/parseHeaders.js ***!
|
|
|
|
|
\********************************************************/
|
|
|
|
|
/*! no static exports found */
|
|
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
|
|
|
|
|
|
|
|
|
|
// Headers whose duplicates are ignored by node
|
|
|
|
|
// c.f. https://nodejs.org/api/http.html#http_message_headers
|
|
|
|
|
var ignoreDuplicateOf = [
|
|
|
|
|
'age', 'authorization', 'content-length', 'content-type', 'etag',
|
|
|
|
|
'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
|
|
|
|
|
'last-modified', 'location', 'max-forwards', 'proxy-authorization',
|
|
|
|
|
'referer', 'retry-after', 'user-agent'
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Parse headers into an object
|
|
|
|
|
*
|
|
|
|
|
* ```
|
|
|
|
|
* Date: Wed, 27 Aug 2014 08:58:49 GMT
|
|
|
|
|
* Content-Type: application/json
|
|
|
|
|
* Connection: keep-alive
|
|
|
|
|
* Transfer-Encoding: chunked
|
|
|
|
|
* ```
|
|
|
|
|
*
|
|
|
|
|
* @param {String} headers Headers needing to be parsed
|
|
|
|
|
* @returns {Object} Headers parsed into an object
|
|
|
|
|
*/
|
|
|
|
|
module.exports = function parseHeaders(headers) {
|
|
|
|
|
var parsed = {};
|
|
|
|
|
var key;
|
|
|
|
|
var val;
|
|
|
|
|
var i;
|
|
|
|
|
|
|
|
|
|
if (!headers) { return parsed; }
|
|
|
|
|
|
|
|
|
|
utils.forEach(headers.split('\n'), function parser(line) {
|
|
|
|
|
i = line.indexOf(':');
|
|
|
|
|
key = utils.trim(line.substr(0, i)).toLowerCase();
|
|
|
|
|
val = utils.trim(line.substr(i + 1));
|
|
|
|
|
|
|
|
|
|
if (key) {
|
|
|
|
|
if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (key === 'set-cookie') {
|
|
|
|
|
parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
|
|
|
|
|
} else {
|
|
|
|
|
parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return parsed;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ "./node_modules/axios/lib/helpers/spread.js":
|
|
|
|
|
/*!**************************************************!*\
|
|
|
|
|
!*** ./node_modules/axios/lib/helpers/spread.js ***!
|
|
|
|
|
\**************************************************/
|
|
|
|
|
/*! no static exports found */
|
|
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Syntactic sugar for invoking a function and expanding an array for arguments.
|
|
|
|
|
*
|
|
|
|
|
* Common use case would be to use `Function.prototype.apply`.
|
|
|
|
|
*
|
|
|
|
|
* ```js
|
|
|
|
|
* function f(x, y, z) {}
|
|
|
|
|
* var args = [1, 2, 3];
|
|
|
|
|
* f.apply(null, args);
|
|
|
|
|
* ```
|
|
|
|
|
*
|
|
|
|
|
* With `spread` this example can be re-written.
|
|
|
|
|
*
|
|
|
|
|
* ```js
|
|
|
|
|
* spread(function(x, y, z) {})([1, 2, 3]);
|
|
|
|
|
* ```
|
|
|
|
|
*
|
|
|
|
|
* @param {Function} callback
|
|
|
|
|
* @returns {Function}
|
|
|
|
|
*/
|
|
|
|
|
module.exports = function spread(callback) {
|
|
|
|
|
return function wrap(arr) {
|
|
|
|
|
return callback.apply(null, arr);
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ "./node_modules/axios/lib/utils.js":
|
|
|
|
|
/*!*****************************************!*\
|
|
|
|
|
!*** ./node_modules/axios/lib/utils.js ***!
|
|
|
|
|
\*****************************************/
|
|
|
|
|
/*! no static exports found */
|
|
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var bind = __webpack_require__(/*! ./helpers/bind */ "./node_modules/axios/lib/helpers/bind.js");
|
|
|
|
|
var isBuffer = __webpack_require__(/*! is-buffer */ "./node_modules/axios/node_modules/is-buffer/index.js");
|
|
|
|
|
|
|
|
|
|
/*global toString:true*/
|
|
|
|
|
|
|
|
|
|
// utils is a library of generic helper functions non-specific to axios
|
|
|
|
|
|
|
|
|
|
var toString = Object.prototype.toString;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Determine if a value is an Array
|
|
|
|
|
*
|
|
|
|
|
* @param {Object} val The value to test
|
|
|
|
|
* @returns {boolean} True if value is an Array, otherwise false
|
|
|
|
|
*/
|
|
|
|
|
function isArray(val) {
|
|
|
|
|
return toString.call(val) === '[object Array]';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Determine if a value is an ArrayBuffer
|
|
|
|
|
*
|
|
|
|
|
* @param {Object} val The value to test
|
|
|
|
|
* @returns {boolean} True if value is an ArrayBuffer, otherwise false
|
|
|
|
|
*/
|
|
|
|
|
function isArrayBuffer(val) {
|
|
|
|
|
return toString.call(val) === '[object ArrayBuffer]';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Determine if a value is a FormData
|
|
|
|
|
*
|
|
|
|
|
* @param {Object} val The value to test
|
|
|
|
|
* @returns {boolean} True if value is an FormData, otherwise false
|
|
|
|
|
*/
|
|
|
|
|
function isFormData(val) {
|
|
|
|
|
return (typeof FormData !== 'undefined') && (val instanceof FormData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Determine if a value is a view on an ArrayBuffer
|
|
|
|
|
*
|
|
|
|
|
* @param {Object} val The value to test
|
|
|
|
|
* @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
|
|
|
|
|
*/
|
|
|
|
|
function isArrayBufferView(val) {
|
|
|
|
|
var result;
|
|
|
|
|
if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
|
|
|
|
|
result = ArrayBuffer.isView(val);
|
|
|
|
|
} else {
|
|
|
|
|
result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Determine if a value is a String
|
|
|
|
|
*
|
|
|
|
|
* @param {Object} val The value to test
|
|
|
|
|
* @returns {boolean} True if value is a String, otherwise false
|
|
|
|
|
*/
|
|
|
|
|
function isString(val) {
|
|
|
|
|
return typeof val === 'string';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Determine if a value is a Number
|
|
|
|
|
*
|
|
|
|
|
* @param {Object} val The value to test
|
|
|
|
|
* @returns {boolean} True if value is a Number, otherwise false
|
|
|
|
|
*/
|
|
|
|
|
function isNumber(val) {
|
|
|
|
|
return typeof val === 'number';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Determine if a value is undefined
|
|
|
|
|
*
|
|
|
|
|
* @param {Object} val The value to test
|
|
|
|
|
* @returns {boolean} True if the value is undefined, otherwise false
|
|
|
|
|
*/
|
|
|
|
|
function isUndefined(val) {
|
|
|
|
|
return typeof val === 'undefined';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Determine if a value is an Object
|
|
|
|
|
*
|
|
|
|
|
* @param {Object} val The value to test
|
|
|
|
|
* @returns {boolean} True if value is an Object, otherwise false
|
|
|
|
|
*/
|
|
|
|
|
function isObject(val) {
|
|
|
|
|
return val !== null && typeof val === 'object';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Determine if a value is a Date
|
|
|
|
|
*
|
|
|
|
|
* @param {Object} val The value to test
|
|
|
|
|
* @returns {boolean} True if value is a Date, otherwise false
|
|
|
|
|
*/
|
|
|
|
|
function isDate(val) {
|
|
|
|
|
return toString.call(val) === '[object Date]';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Determine if a value is a File
|
|
|
|
|
*
|
|
|
|
|
* @param {Object} val The value to test
|
|
|
|
|
* @returns {boolean} True if value is a File, otherwise false
|
|
|
|
|
*/
|
|
|
|
|
function isFile(val) {
|
|
|
|
|
return toString.call(val) === '[object File]';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Determine if a value is a Blob
|
|
|
|
|
*
|
|
|
|
|
* @param {Object} val The value to test
|
|
|
|
|
* @returns {boolean} True if value is a Blob, otherwise false
|
|
|
|
|
*/
|
|
|
|
|
function isBlob(val) {
|
|
|
|
|
return toString.call(val) === '[object Blob]';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Determine if a value is a Function
|
|
|
|
|
*
|
|
|
|
|
* @param {Object} val The value to test
|
|
|
|
|
* @returns {boolean} True if value is a Function, otherwise false
|
|
|
|
|
*/
|
|
|
|
|
function isFunction(val) {
|
|
|
|
|
return toString.call(val) === '[object Function]';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Determine if a value is a Stream
|
|
|
|
|
*
|
|
|
|
|
* @param {Object} val The value to test
|
|
|
|
|
* @returns {boolean} True if value is a Stream, otherwise false
|
|
|
|
|
*/
|
|
|
|
|
function isStream(val) {
|
|
|
|
|
return isObject(val) && isFunction(val.pipe);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Determine if a value is a URLSearchParams object
|
|
|
|
|
*
|
|
|
|
|
* @param {Object} val The value to test
|
|
|
|
|
* @returns {boolean} True if value is a URLSearchParams object, otherwise false
|
|
|
|
|
*/
|
|
|
|
|
function isURLSearchParams(val) {
|
|
|
|
|
return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Trim excess whitespace off the beginning and end of a string
|
|
|
|
|
*
|
|
|
|
|
* @param {String} str The String to trim
|
|
|
|
|
* @returns {String} The String freed of excess whitespace
|
|
|
|
|
*/
|
|
|
|
|
function trim(str) {
|
|
|
|
|
return str.replace(/^\s*/, '').replace(/\s*$/, '');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Determine if we're running in a standard browser environment
|
|
|
|
|
*
|
|
|
|
|
* This allows axios to run in a web worker, and react-native.
|
|
|
|
|
* Both environments support XMLHttpRequest, but not fully standard globals.
|
|
|
|
|
*
|
|
|
|
|
* web workers:
|
|
|
|
|
* typeof window -> undefined
|
|
|
|
|
* typeof document -> undefined
|
|
|
|
|
*
|
|
|
|
|
* react-native:
|
|
|
|
|
* navigator.product -> 'ReactNative'
|
|
|
|
|
* nativescript
|
|
|
|
|
* navigator.product -> 'NativeScript' or 'NS'
|
|
|
|
|
*/
|
|
|
|
|
function isStandardBrowserEnv() {
|
|
|
|
|
if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
|
|
|
|
|
navigator.product === 'NativeScript' ||
|
|
|
|
|
navigator.product === 'NS')) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return (
|
|
|
|
|
typeof window !== 'undefined' &&
|
|
|
|
|
typeof document !== 'undefined'
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Iterate over an Array or an Object invoking a function for each item.
|
|
|
|
|
*
|
|
|
|
|
* If `obj` is an Array callback will be called passing
|
|
|
|
|
* the value, index, and complete array for each item.
|
|
|
|
|
*
|
|
|
|
|
* If 'obj' is an Object callback will be called passing
|
|
|
|
|
* the value, key, and complete object for each property.
|
|
|
|
|
*
|
|
|
|
|
* @param {Object|Array} obj The object to iterate
|
|
|
|
|
* @param {Function} fn The callback to invoke for each item
|
|
|
|
|
*/
|
|
|
|
|
function forEach(obj, fn) {
|
|
|
|
|
// Don't bother if no value provided
|
|
|
|
|
if (obj === null || typeof obj === 'undefined') {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Force an array if not already something iterable
|
|
|
|
|
if (typeof obj !== 'object') {
|
|
|
|
|
/*eslint no-param-reassign:0*/
|
|
|
|
|
obj = [obj];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isArray(obj)) {
|
|
|
|
|
// Iterate over array values
|
|
|
|
|
for (var i = 0, l = obj.length; i < l; i++) {
|
|
|
|
|
fn.call(null, obj[i], i, obj);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// Iterate over object keys
|
|
|
|
|
for (var key in obj) {
|
|
|
|
|
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
|
|
|
fn.call(null, obj[key], key, obj);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Accepts varargs expecting each argument to be an object, then
|
|
|
|
|
* immutably merges the properties of each object and returns result.
|
|
|
|
|
*
|
|
|
|
|
* When multiple objects contain the same key the later object in
|
|
|
|
|
* the arguments list will take precedence.
|
|
|
|
|
*
|
|
|
|
|
* Example:
|
|
|
|
|
*
|
|
|
|
|
* ```js
|
|
|
|
|
* var result = merge({foo: 123}, {foo: 456});
|
|
|
|
|
* console.log(result.foo); // outputs 456
|
|
|
|
|
* ```
|
|
|
|
|
*
|
|
|
|
|
* @param {Object} obj1 Object to merge
|
|
|
|
|
* @returns {Object} Result of all merge properties
|
|
|
|
|
*/
|
|
|
|
|
function merge(/* obj1, obj2, obj3, ... */) {
|
|
|
|
|
var result = {};
|
|
|
|
|
function assignValue(val, key) {
|
|
|
|
|
if (typeof result[key] === 'object' && typeof val === 'object') {
|
|
|
|
|
result[key] = merge(result[key], val);
|
|
|
|
|
} else {
|
|
|
|
|
result[key] = val;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (var i = 0, l = arguments.length; i < l; i++) {
|
|
|
|
|
forEach(arguments[i], assignValue);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Function equal to merge with the difference being that no reference
|
|
|
|
|
* to original objects is kept.
|
|
|
|
|
*
|
|
|
|
|
* @see merge
|
|
|
|
|
* @param {Object} obj1 Object to merge
|
|
|
|
|
* @returns {Object} Result of all merge properties
|
|
|
|
|
*/
|
|
|
|
|
function deepMerge(/* obj1, obj2, obj3, ... */) {
|
|
|
|
|
var result = {};
|
|
|
|
|
function assignValue(val, key) {
|
|
|
|
|
if (typeof result[key] === 'object' && typeof val === 'object') {
|
|
|
|
|
result[key] = deepMerge(result[key], val);
|
|
|
|
|
} else if (typeof val === 'object') {
|
|
|
|
|
result[key] = deepMerge({}, val);
|
|
|
|
|
} else {
|
|
|
|
|
result[key] = val;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (var i = 0, l = arguments.length; i < l; i++) {
|
|
|
|
|
forEach(arguments[i], assignValue);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Extends object a by mutably adding to it the properties of object b.
|
|
|
|
|
*
|
|
|
|
|
* @param {Object} a The object to be extended
|
|
|
|
|
* @param {Object} b The object to copy properties from
|
|
|
|
|
* @param {Object} thisArg The object to bind function to
|
|
|
|
|
* @return {Object} The resulting value of object a
|
|
|
|
|
*/
|
|
|
|
|
function extend(a, b, thisArg) {
|
|
|
|
|
forEach(b, function assignValue(val, key) {
|
|
|
|
|
if (thisArg && typeof val === 'function') {
|
|
|
|
|
a[key] = bind(val, thisArg);
|
|
|
|
|
} else {
|
|
|
|
|
a[key] = val;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return a;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
|
isArray: isArray,
|
|
|
|
|
isArrayBuffer: isArrayBuffer,
|
|
|
|
|
isBuffer: isBuffer,
|
|
|
|
|
isFormData: isFormData,
|
|
|
|
|
isArrayBufferView: isArrayBufferView,
|
|
|
|
|
isString: isString,
|
|
|
|
|
isNumber: isNumber,
|
|
|
|
|
isObject: isObject,
|
|
|
|
|
isUndefined: isUndefined,
|
|
|
|
|
isDate: isDate,
|
|
|
|
|
isFile: isFile,
|
|
|
|
|
isBlob: isBlob,
|
|
|
|
|
isFunction: isFunction,
|
|
|
|
|
isStream: isStream,
|
|
|
|
|
isURLSearchParams: isURLSearchParams,
|
|
|
|
|
isStandardBrowserEnv: isStandardBrowserEnv,
|
|
|
|
|
forEach: forEach,
|
|
|
|
|
merge: merge,
|
|
|
|
|
deepMerge: deepMerge,
|
|
|
|
|
extend: extend,
|
|
|
|
|
trim: trim
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ "./node_modules/axios/node_modules/is-buffer/index.js":
|
|
|
|
|
/*!************************************************************!*\
|
|
|
|
|
!*** ./node_modules/axios/node_modules/is-buffer/index.js ***!
|
|
|
|
|
\************************************************************/
|
|
|
|
|
/*! no static exports found */
|
|
|
|
|
/***/ (function(module, exports) {
|
|
|
|
|
|
2020-01-04 21:34:00 +08:00
|
|
|
|
/*!
|
|
|
|
|
* Determine if an object is a Buffer
|
|
|
|
|
*
|
|
|
|
|
* @author Feross Aboukhadijeh <https://feross.org>
|
|
|
|
|
* @license MIT
|
|
|
|
|
*/
|
2020-01-07 23:45:52 +08:00
|
|
|
|
|
|
|
|
|
module.exports = function isBuffer (obj) {
|
|
|
|
|
return obj != null && obj.constructor != null &&
|
|
|
|
|
typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ "./node_modules/axios/package.json":
|
|
|
|
|
/*!*****************************************!*\
|
|
|
|
|
!*** ./node_modules/axios/package.json ***!
|
|
|
|
|
\*****************************************/
|
|
|
|
|
/*! exports provided: name, version, description, main, scripts, repository, keywords, author, license, bugs, homepage, devDependencies, browser, typings, dependencies, bundlesize, default */
|
|
|
|
|
/***/ (function(module) {
|
|
|
|
|
|
|
|
|
|
module.exports = JSON.parse("{\"name\":\"axios\",\"version\":\"0.19.0\",\"description\":\"Promise based HTTP client for the browser and node.js\",\"main\":\"index.js\",\"scripts\":{\"test\":\"grunt test && bundlesize\",\"start\":\"node ./sandbox/server.js\",\"build\":\"NODE_ENV=production grunt build\",\"preversion\":\"npm test\",\"version\":\"npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json\",\"postversion\":\"git push && git push --tags\",\"examples\":\"node ./examples/server.js\",\"coveralls\":\"cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js\",\"fix\":\"eslint --fix lib/**/*.js\"},\"repository\":{\"type\":\"git\",\"url\":\"https://github.com/axios/axios.git\"},\"keywords\":[\"xhr\",\"http\",\"ajax\",\"promise\",\"node\"],\"author\":\"Matt Zabriskie\",\"license\":\"MIT\",\"bugs\":{\"url\":\"https://github.com/axios/axios/issues\"},\"homepage\":\"https://github.com/axios/axios\",\"devDependencies\":{\"bundlesize\":\"^0.17.0\",\"coveralls\":\"^3.0.0\",\"es6-promise\":\"^4.2.4\",\"grunt\":\"^1.0.2\",\"grunt-banner\":\"^0.6.0\",\"grunt-cli\":\"^1.2.0\",\"grunt-contrib-clean\":\"^1.1.0\",\"grunt-contrib-watch\":\"^1.0.0\",\"grunt-eslint\":\"^20.1.0\",\"grunt-karma\":\"^2.0.0\",\"grunt-mocha-test\":\"^0.13.3\",\"grunt-ts\":\"^6.0.0-beta.19\",\"grunt-webpack\":\"^1.0.18\",\"istanbul-instrumenter-loader\":\"^1.0.0\",\"jasmine-core\":\"^2.4.1\",\"karma\":\"^1.3.0\",\"karma-chrome-launcher\":\"^2.2.0\",\"karma-coverage\":\"^1.1.1\",\"karma-firefox-launcher\":\"^1.1.0\",\"karma-jasmine\":\"^1.1.1\",\"karma-jasmine-ajax\":\"^0.1.13\",\"karma-opera-launcher\":\"^1.0.0\",\"karma-safari-launcher\":\"^1.0.0\",\"karma-sauce-launcher\":\"^1.2.0\",\"karma-sinon\":\"^1.0.5\",\"karma-sourcemap-loader\":\"^0.3.7\",\"karma-webpack\":\"^1.7.0\",\"load-grunt-tasks\":\"^3.5.2\",\"minimist\":\"^1.2.0\",\"mocha\":\"^5.2.0\",\"sinon\":\"^4.5.0\",\"typescript\":\"^2.8.1\",\"url-search-params\":\"^0.10.0\",\"webpack\":\"^1.13.1\",\"webpack-dev-server\":\"^1.14.1\"},\"browser\":{\"./lib/adapters/http.js\":\"./lib/adapters/xhr.js\"},\"typings\":\"./index.d.ts\",\"dependencies\":{\"follow-redirects\":\"1.5.10\",\"is-buffer\":\"^2.0.2\"},\"bundlesize\":[{\"path\":\"./dist/axios.min.js\",\"threshold\":\"5kB\"}]}");
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ "./node_modules/follow-redirects/index.js":
|
|
|
|
|
/*!************************************************!*\
|
|
|
|
|
!*** ./node_modules/follow-redirects/index.js ***!
|
|
|
|
|
\************************************************/
|
|
|
|
|
/*! no static exports found */
|
|
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
var url = __webpack_require__(/*! url */ "url");
|
|
|
|
|
var http = __webpack_require__(/*! http */ "http");
|
|
|
|
|
var https = __webpack_require__(/*! https */ "https");
|
|
|
|
|
var assert = __webpack_require__(/*! assert */ "assert");
|
|
|
|
|
var Writable = __webpack_require__(/*! stream */ "stream").Writable;
|
|
|
|
|
var debug = __webpack_require__(/*! debug */ "./node_modules/follow-redirects/node_modules/debug/src/index.js")("follow-redirects");
|
|
|
|
|
|
|
|
|
|
// RFC7231§4.2.1: Of the request methods defined by this specification,
|
|
|
|
|
// the GET, HEAD, OPTIONS, and TRACE methods are defined to be safe.
|
|
|
|
|
var SAFE_METHODS = { GET: true, HEAD: true, OPTIONS: true, TRACE: true };
|
|
|
|
|
|
|
|
|
|
// Create handlers that pass events from native requests
|
|
|
|
|
var eventHandlers = Object.create(null);
|
|
|
|
|
["abort", "aborted", "error", "socket", "timeout"].forEach(function (event) {
|
|
|
|
|
eventHandlers[event] = function (arg) {
|
|
|
|
|
this._redirectable.emit(event, arg);
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// An HTTP(S) request that can be redirected
|
|
|
|
|
function RedirectableRequest(options, responseCallback) {
|
|
|
|
|
// Initialize the request
|
|
|
|
|
Writable.call(this);
|
|
|
|
|
options.headers = options.headers || {};
|
|
|
|
|
this._options = options;
|
|
|
|
|
this._redirectCount = 0;
|
|
|
|
|
this._redirects = [];
|
|
|
|
|
this._requestBodyLength = 0;
|
|
|
|
|
this._requestBodyBuffers = [];
|
|
|
|
|
|
|
|
|
|
// Since http.request treats host as an alias of hostname,
|
|
|
|
|
// but the url module interprets host as hostname plus port,
|
|
|
|
|
// eliminate the host property to avoid confusion.
|
|
|
|
|
if (options.host) {
|
|
|
|
|
// Use hostname if set, because it has precedence
|
|
|
|
|
if (!options.hostname) {
|
|
|
|
|
options.hostname = options.host;
|
|
|
|
|
}
|
|
|
|
|
delete options.host;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Attach a callback if passed
|
|
|
|
|
if (responseCallback) {
|
|
|
|
|
this.on("response", responseCallback);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// React to responses of native requests
|
|
|
|
|
var self = this;
|
|
|
|
|
this._onNativeResponse = function (response) {
|
|
|
|
|
self._processResponse(response);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Complete the URL object when necessary
|
|
|
|
|
if (!options.pathname && options.path) {
|
|
|
|
|
var searchPos = options.path.indexOf("?");
|
|
|
|
|
if (searchPos < 0) {
|
|
|
|
|
options.pathname = options.path;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
options.pathname = options.path.substring(0, searchPos);
|
|
|
|
|
options.search = options.path.substring(searchPos);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Perform the first request
|
|
|
|
|
this._performRequest();
|
|
|
|
|
}
|
|
|
|
|
RedirectableRequest.prototype = Object.create(Writable.prototype);
|
|
|
|
|
|
|
|
|
|
// Writes buffered data to the current native request
|
|
|
|
|
RedirectableRequest.prototype.write = function (data, encoding, callback) {
|
|
|
|
|
// Validate input and shift parameters if necessary
|
|
|
|
|
if (!(typeof data === "string" || typeof data === "object" && ("length" in data))) {
|
|
|
|
|
throw new Error("data should be a string, Buffer or Uint8Array");
|
|
|
|
|
}
|
|
|
|
|
if (typeof encoding === "function") {
|
|
|
|
|
callback = encoding;
|
|
|
|
|
encoding = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Ignore empty buffers, since writing them doesn't invoke the callback
|
|
|
|
|
// https://github.com/nodejs/node/issues/22066
|
|
|
|
|
if (data.length === 0) {
|
|
|
|
|
if (callback) {
|
|
|
|
|
callback();
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// Only write when we don't exceed the maximum body length
|
|
|
|
|
if (this._requestBodyLength + data.length <= this._options.maxBodyLength) {
|
|
|
|
|
this._requestBodyLength += data.length;
|
|
|
|
|
this._requestBodyBuffers.push({ data: data, encoding: encoding });
|
|
|
|
|
this._currentRequest.write(data, encoding, callback);
|
|
|
|
|
}
|
|
|
|
|
// Error when we exceed the maximum body length
|
|
|
|
|
else {
|
|
|
|
|
this.emit("error", new Error("Request body larger than maxBodyLength limit"));
|
|
|
|
|
this.abort();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Ends the current native request
|
|
|
|
|
RedirectableRequest.prototype.end = function (data, encoding, callback) {
|
|
|
|
|
// Shift parameters if necessary
|
|
|
|
|
if (typeof data === "function") {
|
|
|
|
|
callback = data;
|
|
|
|
|
data = encoding = null;
|
|
|
|
|
}
|
|
|
|
|
else if (typeof encoding === "function") {
|
|
|
|
|
callback = encoding;
|
|
|
|
|
encoding = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Write data and end
|
|
|
|
|
var currentRequest = this._currentRequest;
|
|
|
|
|
this.write(data || "", encoding, function () {
|
|
|
|
|
currentRequest.end(null, null, callback);
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Sets a header value on the current native request
|
|
|
|
|
RedirectableRequest.prototype.setHeader = function (name, value) {
|
|
|
|
|
this._options.headers[name] = value;
|
|
|
|
|
this._currentRequest.setHeader(name, value);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Clears a header value on the current native request
|
|
|
|
|
RedirectableRequest.prototype.removeHeader = function (name) {
|
|
|
|
|
delete this._options.headers[name];
|
|
|
|
|
this._currentRequest.removeHeader(name);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Proxy all other public ClientRequest methods
|
|
|
|
|
[
|
|
|
|
|
"abort", "flushHeaders", "getHeader",
|
|
|
|
|
"setNoDelay", "setSocketKeepAlive", "setTimeout",
|
|
|
|
|
].forEach(function (method) {
|
|
|
|
|
RedirectableRequest.prototype[method] = function (a, b) {
|
|
|
|
|
return this._currentRequest[method](a, b);
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Proxy all public ClientRequest properties
|
|
|
|
|
["aborted", "connection", "socket"].forEach(function (property) {
|
|
|
|
|
Object.defineProperty(RedirectableRequest.prototype, property, {
|
|
|
|
|
get: function () { return this._currentRequest[property]; },
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Executes the next native request (initial or redirect)
|
|
|
|
|
RedirectableRequest.prototype._performRequest = function () {
|
|
|
|
|
// Load the native protocol
|
|
|
|
|
var protocol = this._options.protocol;
|
|
|
|
|
var nativeProtocol = this._options.nativeProtocols[protocol];
|
|
|
|
|
if (!nativeProtocol) {
|
|
|
|
|
this.emit("error", new Error("Unsupported protocol " + protocol));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If specified, use the agent corresponding to the protocol
|
|
|
|
|
// (HTTP and HTTPS use different types of agents)
|
|
|
|
|
if (this._options.agents) {
|
|
|
|
|
var scheme = protocol.substr(0, protocol.length - 1);
|
|
|
|
|
this._options.agent = this._options.agents[scheme];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Create the native request
|
|
|
|
|
var request = this._currentRequest =
|
|
|
|
|
nativeProtocol.request(this._options, this._onNativeResponse);
|
|
|
|
|
this._currentUrl = url.format(this._options);
|
|
|
|
|
|
|
|
|
|
// Set up event handlers
|
|
|
|
|
request._redirectable = this;
|
|
|
|
|
for (var event in eventHandlers) {
|
|
|
|
|
/* istanbul ignore else */
|
|
|
|
|
if (event) {
|
|
|
|
|
request.on(event, eventHandlers[event]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// End a redirected request
|
|
|
|
|
// (The first request must be ended explicitly with RedirectableRequest#end)
|
|
|
|
|
if (this._isRedirect) {
|
|
|
|
|
// Write the request entity and end.
|
|
|
|
|
var i = 0;
|
|
|
|
|
var buffers = this._requestBodyBuffers;
|
|
|
|
|
(function writeNext() {
|
|
|
|
|
if (i < buffers.length) {
|
|
|
|
|
var buffer = buffers[i++];
|
|
|
|
|
request.write(buffer.data, buffer.encoding, writeNext);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
request.end();
|
|
|
|
|
}
|
|
|
|
|
}());
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Processes a response from the current native request
|
|
|
|
|
RedirectableRequest.prototype._processResponse = function (response) {
|
|
|
|
|
// Store the redirected response
|
|
|
|
|
if (this._options.trackRedirects) {
|
|
|
|
|
this._redirects.push({
|
|
|
|
|
url: this._currentUrl,
|
|
|
|
|
headers: response.headers,
|
|
|
|
|
statusCode: response.statusCode,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// RFC7231§6.4: The 3xx (Redirection) class of status code indicates
|
|
|
|
|
// that further action needs to be taken by the user agent in order to
|
|
|
|
|
// fulfill the request. If a Location header field is provided,
|
|
|
|
|
// the user agent MAY automatically redirect its request to the URI
|
|
|
|
|
// referenced by the Location field value,
|
|
|
|
|
// even if the specific status code is not understood.
|
|
|
|
|
var location = response.headers.location;
|
|
|
|
|
if (location && this._options.followRedirects !== false &&
|
|
|
|
|
response.statusCode >= 300 && response.statusCode < 400) {
|
|
|
|
|
// RFC7231§6.4: A client SHOULD detect and intervene
|
|
|
|
|
// in cyclical redirections (i.e., "infinite" redirection loops).
|
|
|
|
|
if (++this._redirectCount > this._options.maxRedirects) {
|
|
|
|
|
this.emit("error", new Error("Max redirects exceeded."));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// RFC7231§6.4: Automatic redirection needs to done with
|
|
|
|
|
// care for methods not known to be safe […],
|
|
|
|
|
// since the user might not wish to redirect an unsafe request.
|
|
|
|
|
// RFC7231§6.4.7: The 307 (Temporary Redirect) status code indicates
|
|
|
|
|
// that the target resource resides temporarily under a different URI
|
|
|
|
|
// and the user agent MUST NOT change the request method
|
|
|
|
|
// if it performs an automatic redirection to that URI.
|
|
|
|
|
var header;
|
|
|
|
|
var headers = this._options.headers;
|
|
|
|
|
if (response.statusCode !== 307 && !(this._options.method in SAFE_METHODS)) {
|
|
|
|
|
this._options.method = "GET";
|
|
|
|
|
// Drop a possible entity and headers related to it
|
|
|
|
|
this._requestBodyBuffers = [];
|
|
|
|
|
for (header in headers) {
|
|
|
|
|
if (/^content-/i.test(header)) {
|
|
|
|
|
delete headers[header];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Drop the Host header, as the redirect might lead to a different host
|
|
|
|
|
if (!this._isRedirect) {
|
|
|
|
|
for (header in headers) {
|
|
|
|
|
if (/^host$/i.test(header)) {
|
|
|
|
|
delete headers[header];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Perform the redirected request
|
|
|
|
|
var redirectUrl = url.resolve(this._currentUrl, location);
|
|
|
|
|
debug("redirecting to", redirectUrl);
|
|
|
|
|
Object.assign(this._options, url.parse(redirectUrl));
|
|
|
|
|
this._isRedirect = true;
|
|
|
|
|
this._performRequest();
|
|
|
|
|
|
|
|
|
|
// Discard the remainder of the response to avoid waiting for data
|
|
|
|
|
response.destroy();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
// The response is not a redirect; return it as-is
|
|
|
|
|
response.responseUrl = this._currentUrl;
|
|
|
|
|
response.redirects = this._redirects;
|
|
|
|
|
this.emit("response", response);
|
|
|
|
|
|
|
|
|
|
// Clean up
|
|
|
|
|
this._requestBodyBuffers = [];
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Wraps the key/value object of protocols with redirect functionality
|
|
|
|
|
function wrap(protocols) {
|
|
|
|
|
// Default settings
|
|
|
|
|
var exports = {
|
|
|
|
|
maxRedirects: 21,
|
|
|
|
|
maxBodyLength: 10 * 1024 * 1024,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Wrap each protocol
|
|
|
|
|
var nativeProtocols = {};
|
|
|
|
|
Object.keys(protocols).forEach(function (scheme) {
|
|
|
|
|
var protocol = scheme + ":";
|
|
|
|
|
var nativeProtocol = nativeProtocols[protocol] = protocols[scheme];
|
|
|
|
|
var wrappedProtocol = exports[scheme] = Object.create(nativeProtocol);
|
|
|
|
|
|
|
|
|
|
// Executes a request, following redirects
|
|
|
|
|
wrappedProtocol.request = function (options, callback) {
|
|
|
|
|
if (typeof options === "string") {
|
|
|
|
|
options = url.parse(options);
|
|
|
|
|
options.maxRedirects = exports.maxRedirects;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
options = Object.assign({
|
|
|
|
|
protocol: protocol,
|
|
|
|
|
maxRedirects: exports.maxRedirects,
|
|
|
|
|
maxBodyLength: exports.maxBodyLength,
|
|
|
|
|
}, options);
|
|
|
|
|
}
|
|
|
|
|
options.nativeProtocols = nativeProtocols;
|
|
|
|
|
assert.equal(options.protocol, protocol, "protocol mismatch");
|
|
|
|
|
debug("options", options);
|
|
|
|
|
return new RedirectableRequest(options, callback);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Executes a GET request, following redirects
|
|
|
|
|
wrappedProtocol.get = function (options, callback) {
|
|
|
|
|
var request = wrappedProtocol.request(options, callback);
|
|
|
|
|
request.end();
|
|
|
|
|
return request;
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
return exports;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Exports
|
|
|
|
|
module.exports = wrap({ http: http, https: https });
|
|
|
|
|
module.exports.wrap = wrap;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ "./node_modules/follow-redirects/node_modules/debug/src/browser.js":
|
|
|
|
|
/*!*************************************************************************!*\
|
|
|
|
|
!*** ./node_modules/follow-redirects/node_modules/debug/src/browser.js ***!
|
|
|
|
|
\*************************************************************************/
|
|
|
|
|
/*! no static exports found */
|
|
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This is the web browser implementation of `debug()`.
|
|
|
|
|
*
|
|
|
|
|
* Expose `debug()` as the module.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
exports = module.exports = __webpack_require__(/*! ./debug */ "./node_modules/follow-redirects/node_modules/debug/src/debug.js");
|
|
|
|
|
exports.log = log;
|
|
|
|
|
exports.formatArgs = formatArgs;
|
|
|
|
|
exports.save = save;
|
|
|
|
|
exports.load = load;
|
|
|
|
|
exports.useColors = useColors;
|
|
|
|
|
exports.storage = 'undefined' != typeof chrome
|
|
|
|
|
&& 'undefined' != typeof chrome.storage
|
|
|
|
|
? chrome.storage.local
|
|
|
|
|
: localstorage();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Colors.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
exports.colors = [
|
|
|
|
|
'#0000CC', '#0000FF', '#0033CC', '#0033FF', '#0066CC', '#0066FF', '#0099CC',
|
|
|
|
|
'#0099FF', '#00CC00', '#00CC33', '#00CC66', '#00CC99', '#00CCCC', '#00CCFF',
|
|
|
|
|
'#3300CC', '#3300FF', '#3333CC', '#3333FF', '#3366CC', '#3366FF', '#3399CC',
|
|
|
|
|
'#3399FF', '#33CC00', '#33CC33', '#33CC66', '#33CC99', '#33CCCC', '#33CCFF',
|
|
|
|
|
'#6600CC', '#6600FF', '#6633CC', '#6633FF', '#66CC00', '#66CC33', '#9900CC',
|
|
|
|
|
'#9900FF', '#9933CC', '#9933FF', '#99CC00', '#99CC33', '#CC0000', '#CC0033',
|
|
|
|
|
'#CC0066', '#CC0099', '#CC00CC', '#CC00FF', '#CC3300', '#CC3333', '#CC3366',
|
|
|
|
|
'#CC3399', '#CC33CC', '#CC33FF', '#CC6600', '#CC6633', '#CC9900', '#CC9933',
|
|
|
|
|
'#CCCC00', '#CCCC33', '#FF0000', '#FF0033', '#FF0066', '#FF0099', '#FF00CC',
|
|
|
|
|
'#FF00FF', '#FF3300', '#FF3333', '#FF3366', '#FF3399', '#FF33CC', '#FF33FF',
|
|
|
|
|
'#FF6600', '#FF6633', '#FF9900', '#FF9933', '#FFCC00', '#FFCC33'
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Currently only WebKit-based Web Inspectors, Firefox >= v31,
|
|
|
|
|
* and the Firebug extension (any Firefox version) are known
|
|
|
|
|
* to support "%c" CSS customizations.
|
|
|
|
|
*
|
|
|
|
|
* TODO: add a `localStorage` variable to explicitly enable/disable colors
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
function useColors() {
|
|
|
|
|
// NB: In an Electron preload script, document will be defined but not fully
|
|
|
|
|
// initialized. Since we know we're in Chrome, we'll just detect this case
|
|
|
|
|
// explicitly
|
|
|
|
|
if (typeof window !== 'undefined' && window.process && window.process.type === 'renderer') {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Internet Explorer and Edge do not support colors.
|
|
|
|
|
if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// is webkit? http://stackoverflow.com/a/16459606/376773
|
|
|
|
|
// document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
|
|
|
|
|
return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
|
|
|
|
|
// is firebug? http://stackoverflow.com/a/398120/376773
|
|
|
|
|
(typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
|
|
|
|
|
// is firefox >= v31?
|
|
|
|
|
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
|
|
|
|
|
(typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
|
|
|
|
|
// double check webkit in userAgent just in case we are in a worker
|
|
|
|
|
(typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
exports.formatters.j = function(v) {
|
|
|
|
|
try {
|
|
|
|
|
return JSON.stringify(v);
|
|
|
|
|
} catch (err) {
|
|
|
|
|
return '[UnexpectedJSONParseError]: ' + err.message;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Colorize log arguments if enabled.
|
|
|
|
|
*
|
|
|
|
|
* @api public
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
function formatArgs(args) {
|
|
|
|
|
var useColors = this.useColors;
|
|
|
|
|
|
|
|
|
|
args[0] = (useColors ? '%c' : '')
|
|
|
|
|
+ this.namespace
|
|
|
|
|
+ (useColors ? ' %c' : ' ')
|
|
|
|
|
+ args[0]
|
|
|
|
|
+ (useColors ? '%c ' : ' ')
|
|
|
|
|
+ '+' + exports.humanize(this.diff);
|
|
|
|
|
|
|
|
|
|
if (!useColors) return;
|
|
|
|
|
|
|
|
|
|
var c = 'color: ' + this.color;
|
|
|
|
|
args.splice(1, 0, c, 'color: inherit')
|
|
|
|
|
|
|
|
|
|
// the final "%c" is somewhat tricky, because there could be other
|
|
|
|
|
// arguments passed either before or after the %c, so we need to
|
|
|
|
|
// figure out the correct index to insert the CSS into
|
|
|
|
|
var index = 0;
|
|
|
|
|
var lastC = 0;
|
|
|
|
|
args[0].replace(/%[a-zA-Z%]/g, function(match) {
|
|
|
|
|
if ('%%' === match) return;
|
|
|
|
|
index++;
|
|
|
|
|
if ('%c' === match) {
|
|
|
|
|
// we only are interested in the *last* %c
|
|
|
|
|
// (the user may have provided their own)
|
|
|
|
|
lastC = index;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
args.splice(lastC, 0, c);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Invokes `console.log()` when available.
|
|
|
|
|
* No-op when `console.log` is not a "function".
|
|
|
|
|
*
|
|
|
|
|
* @api public
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
function log() {
|
|
|
|
|
// this hackery is required for IE8/9, where
|
|
|
|
|
// the `console.log` function doesn't have 'apply'
|
|
|
|
|
return 'object' === typeof console
|
|
|
|
|
&& console.log
|
|
|
|
|
&& Function.prototype.apply.call(console.log, console, arguments);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Save `namespaces`.
|
|
|
|
|
*
|
|
|
|
|
* @param {String} namespaces
|
|
|
|
|
* @api private
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
function save(namespaces) {
|
|
|
|
|
try {
|
|
|
|
|
if (null == namespaces) {
|
|
|
|
|
exports.storage.removeItem('debug');
|
|
|
|
|
} else {
|
|
|
|
|
exports.storage.debug = namespaces;
|
|
|
|
|
}
|
|
|
|
|
} catch(e) {}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Load `namespaces`.
|
|
|
|
|
*
|
|
|
|
|
* @return {String} returns the previously persisted debug modes
|
|
|
|
|
* @api private
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
function load() {
|
|
|
|
|
var r;
|
|
|
|
|
try {
|
|
|
|
|
r = exports.storage.debug;
|
|
|
|
|
} catch(e) {}
|
|
|
|
|
|
|
|
|
|
// If debug isn't set in LS, and we're in Electron, try to load $DEBUG
|
|
|
|
|
if (!r && typeof process !== 'undefined' && 'env' in process) {
|
|
|
|
|
r = process.env.DEBUG;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return r;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Enable namespaces listed in `localStorage.debug` initially.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
exports.enable(load());
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Localstorage attempts to return the localstorage.
|
|
|
|
|
*
|
|
|
|
|
* This is necessary because safari throws
|
|
|
|
|
* when a user disables cookies/localstorage
|
|
|
|
|
* and you attempt to access it.
|
|
|
|
|
*
|
|
|
|
|
* @return {LocalStorage}
|
|
|
|
|
* @api private
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
function localstorage() {
|
|
|
|
|
try {
|
|
|
|
|
return window.localStorage;
|
|
|
|
|
} catch (e) {}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ "./node_modules/follow-redirects/node_modules/debug/src/debug.js":
|
|
|
|
|
/*!***********************************************************************!*\
|
|
|
|
|
!*** ./node_modules/follow-redirects/node_modules/debug/src/debug.js ***!
|
|
|
|
|
\***********************************************************************/
|
|
|
|
|
/*! no static exports found */
|
|
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This is the common logic for both the Node.js and web browser
|
|
|
|
|
* implementations of `debug()`.
|
|
|
|
|
*
|
|
|
|
|
* Expose `debug()` as the module.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
exports = module.exports = createDebug.debug = createDebug['default'] = createDebug;
|
|
|
|
|
exports.coerce = coerce;
|
|
|
|
|
exports.disable = disable;
|
|
|
|
|
exports.enable = enable;
|
|
|
|
|
exports.enabled = enabled;
|
|
|
|
|
exports.humanize = __webpack_require__(/*! ms */ "./node_modules/ms/index.js");
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Active `debug` instances.
|
|
|
|
|
*/
|
|
|
|
|
exports.instances = [];
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The currently active debug mode names, and names to skip.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
exports.names = [];
|
|
|
|
|
exports.skips = [];
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Map of special "%n" handling functions, for the debug "format" argument.
|
|
|
|
|
*
|
|
|
|
|
* Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
exports.formatters = {};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Select a color.
|
|
|
|
|
* @param {String} namespace
|
|
|
|
|
* @return {Number}
|
|
|
|
|
* @api private
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
function selectColor(namespace) {
|
|
|
|
|
var hash = 0, i;
|
|
|
|
|
|
|
|
|
|
for (i in namespace) {
|
|
|
|
|
hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
|
|
|
|
|
hash |= 0; // Convert to 32bit integer
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return exports.colors[Math.abs(hash) % exports.colors.length];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create a debugger with the given `namespace`.
|
|
|
|
|
*
|
|
|
|
|
* @param {String} namespace
|
|
|
|
|
* @return {Function}
|
|
|
|
|
* @api public
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
function createDebug(namespace) {
|
|
|
|
|
|
|
|
|
|
var prevTime;
|
|
|
|
|
|
|
|
|
|
function debug() {
|
|
|
|
|
// disabled?
|
|
|
|
|
if (!debug.enabled) return;
|
|
|
|
|
|
|
|
|
|
var self = debug;
|
|
|
|
|
|
|
|
|
|
// set `diff` timestamp
|
|
|
|
|
var curr = +new Date();
|
|
|
|
|
var ms = curr - (prevTime || curr);
|
|
|
|
|
self.diff = ms;
|
|
|
|
|
self.prev = prevTime;
|
|
|
|
|
self.curr = curr;
|
|
|
|
|
prevTime = curr;
|
|
|
|
|
|
|
|
|
|
// turn the `arguments` into a proper Array
|
|
|
|
|
var args = new Array(arguments.length);
|
|
|
|
|
for (var i = 0; i < args.length; i++) {
|
|
|
|
|
args[i] = arguments[i];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
args[0] = exports.coerce(args[0]);
|
|
|
|
|
|
|
|
|
|
if ('string' !== typeof args[0]) {
|
|
|
|
|
// anything else let's inspect with %O
|
|
|
|
|
args.unshift('%O');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// apply any `formatters` transformations
|
|
|
|
|
var index = 0;
|
|
|
|
|
args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) {
|
|
|
|
|
// if we encounter an escaped % then don't increase the array index
|
|
|
|
|
if (match === '%%') return match;
|
|
|
|
|
index++;
|
|
|
|
|
var formatter = exports.formatters[format];
|
|
|
|
|
if ('function' === typeof formatter) {
|
|
|
|
|
var val = args[index];
|
|
|
|
|
match = formatter.call(self, val);
|
|
|
|
|
|
|
|
|
|
// now we need to remove `args[index]` since it's inlined in the `format`
|
|
|
|
|
args.splice(index, 1);
|
|
|
|
|
index--;
|
|
|
|
|
}
|
|
|
|
|
return match;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// apply env-specific formatting (colors, etc.)
|
|
|
|
|
exports.formatArgs.call(self, args);
|
|
|
|
|
|
|
|
|
|
var logFn = debug.log || exports.log || console.log.bind(console);
|
|
|
|
|
logFn.apply(self, args);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
debug.namespace = namespace;
|
|
|
|
|
debug.enabled = exports.enabled(namespace);
|
|
|
|
|
debug.useColors = exports.useColors();
|
|
|
|
|
debug.color = selectColor(namespace);
|
|
|
|
|
debug.destroy = destroy;
|
|
|
|
|
|
|
|
|
|
// env-specific initialization logic for debug instances
|
|
|
|
|
if ('function' === typeof exports.init) {
|
|
|
|
|
exports.init(debug);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
exports.instances.push(debug);
|
|
|
|
|
|
|
|
|
|
return debug;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function destroy () {
|
|
|
|
|
var index = exports.instances.indexOf(this);
|
|
|
|
|
if (index !== -1) {
|
|
|
|
|
exports.instances.splice(index, 1);
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Enables a debug mode by namespaces. This can include modes
|
|
|
|
|
* separated by a colon and wildcards.
|
|
|
|
|
*
|
|
|
|
|
* @param {String} namespaces
|
|
|
|
|
* @api public
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
function enable(namespaces) {
|
|
|
|
|
exports.save(namespaces);
|
|
|
|
|
|
|
|
|
|
exports.names = [];
|
|
|
|
|
exports.skips = [];
|
|
|
|
|
|
|
|
|
|
var i;
|
|
|
|
|
var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
|
|
|
|
|
var len = split.length;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < len; i++) {
|
|
|
|
|
if (!split[i]) continue; // ignore empty strings
|
|
|
|
|
namespaces = split[i].replace(/\*/g, '.*?');
|
|
|
|
|
if (namespaces[0] === '-') {
|
|
|
|
|
exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
|
|
|
|
|
} else {
|
|
|
|
|
exports.names.push(new RegExp('^' + namespaces + '$'));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < exports.instances.length; i++) {
|
|
|
|
|
var instance = exports.instances[i];
|
|
|
|
|
instance.enabled = exports.enabled(instance.namespace);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Disable debug output.
|
|
|
|
|
*
|
|
|
|
|
* @api public
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
function disable() {
|
|
|
|
|
exports.enable('');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns true if the given mode name is enabled, false otherwise.
|
|
|
|
|
*
|
|
|
|
|
* @param {String} name
|
|
|
|
|
* @return {Boolean}
|
|
|
|
|
* @api public
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
function enabled(name) {
|
|
|
|
|
if (name[name.length - 1] === '*') {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
var i, len;
|
|
|
|
|
for (i = 0, len = exports.skips.length; i < len; i++) {
|
|
|
|
|
if (exports.skips[i].test(name)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (i = 0, len = exports.names.length; i < len; i++) {
|
|
|
|
|
if (exports.names[i].test(name)) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Coerce `val`.
|
|
|
|
|
*
|
|
|
|
|
* @param {Mixed} val
|
|
|
|
|
* @return {Mixed}
|
|
|
|
|
* @api private
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
function coerce(val) {
|
|
|
|
|
if (val instanceof Error) return val.stack || val.message;
|
|
|
|
|
return val;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ "./node_modules/follow-redirects/node_modules/debug/src/index.js":
|
|
|
|
|
/*!***********************************************************************!*\
|
|
|
|
|
!*** ./node_modules/follow-redirects/node_modules/debug/src/index.js ***!
|
|
|
|
|
\***********************************************************************/
|
|
|
|
|
/*! no static exports found */
|
|
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Detect Electron renderer process, which is node, but we should
|
|
|
|
|
* treat as a browser.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
if (typeof process === 'undefined' || process.type === 'renderer') {
|
|
|
|
|
module.exports = __webpack_require__(/*! ./browser.js */ "./node_modules/follow-redirects/node_modules/debug/src/browser.js");
|
|
|
|
|
} else {
|
|
|
|
|
module.exports = __webpack_require__(/*! ./node.js */ "./node_modules/follow-redirects/node_modules/debug/src/node.js");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ "./node_modules/follow-redirects/node_modules/debug/src/node.js":
|
|
|
|
|
/*!**********************************************************************!*\
|
|
|
|
|
!*** ./node_modules/follow-redirects/node_modules/debug/src/node.js ***!
|
|
|
|
|
\**********************************************************************/
|
|
|
|
|
/*! no static exports found */
|
|
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Module dependencies.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
var tty = __webpack_require__(/*! tty */ "tty");
|
|
|
|
|
var util = __webpack_require__(/*! util */ "util");
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This is the Node.js implementation of `debug()`.
|
|
|
|
|
*
|
|
|
|
|
* Expose `debug()` as the module.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
exports = module.exports = __webpack_require__(/*! ./debug */ "./node_modules/follow-redirects/node_modules/debug/src/debug.js");
|
|
|
|
|
exports.init = init;
|
|
|
|
|
exports.log = log;
|
|
|
|
|
exports.formatArgs = formatArgs;
|
|
|
|
|
exports.save = save;
|
|
|
|
|
exports.load = load;
|
|
|
|
|
exports.useColors = useColors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Colors.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
exports.colors = [ 6, 2, 3, 4, 5, 1 ];
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
var supportsColor = __webpack_require__(/*! supports-color */ "./node_modules/supports-color/index.js");
|
|
|
|
|
if (supportsColor && supportsColor.level >= 2) {
|
|
|
|
|
exports.colors = [
|
|
|
|
|
20, 21, 26, 27, 32, 33, 38, 39, 40, 41, 42, 43, 44, 45, 56, 57, 62, 63, 68,
|
|
|
|
|
69, 74, 75, 76, 77, 78, 79, 80, 81, 92, 93, 98, 99, 112, 113, 128, 129, 134,
|
|
|
|
|
135, 148, 149, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171,
|
|
|
|
|
172, 173, 178, 179, 184, 185, 196, 197, 198, 199, 200, 201, 202, 203, 204,
|
|
|
|
|
205, 206, 207, 208, 209, 214, 215, 220, 221
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
} catch (err) {
|
|
|
|
|
// swallow - we only care if `supports-color` is available; it doesn't have to be.
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Build up the default `inspectOpts` object from the environment variables.
|
|
|
|
|
*
|
|
|
|
|
* $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
exports.inspectOpts = Object.keys(process.env).filter(function (key) {
|
|
|
|
|
return /^debug_/i.test(key);
|
|
|
|
|
}).reduce(function (obj, key) {
|
|
|
|
|
// camel-case
|
|
|
|
|
var prop = key
|
|
|
|
|
.substring(6)
|
|
|
|
|
.toLowerCase()
|
|
|
|
|
.replace(/_([a-z])/g, function (_, k) { return k.toUpperCase() });
|
|
|
|
|
|
|
|
|
|
// coerce string value into JS value
|
|
|
|
|
var val = process.env[key];
|
|
|
|
|
if (/^(yes|on|true|enabled)$/i.test(val)) val = true;
|
|
|
|
|
else if (/^(no|off|false|disabled)$/i.test(val)) val = false;
|
|
|
|
|
else if (val === 'null') val = null;
|
|
|
|
|
else val = Number(val);
|
|
|
|
|
|
|
|
|
|
obj[prop] = val;
|
|
|
|
|
return obj;
|
|
|
|
|
}, {});
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Is stdout a TTY? Colored output is enabled when `true`.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
function useColors() {
|
|
|
|
|
return 'colors' in exports.inspectOpts
|
|
|
|
|
? Boolean(exports.inspectOpts.colors)
|
|
|
|
|
: tty.isatty(process.stderr.fd);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Map %o to `util.inspect()`, all on a single line.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
exports.formatters.o = function(v) {
|
|
|
|
|
this.inspectOpts.colors = this.useColors;
|
|
|
|
|
return util.inspect(v, this.inspectOpts)
|
|
|
|
|
.split('\n').map(function(str) {
|
|
|
|
|
return str.trim()
|
|
|
|
|
}).join(' ');
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Map %o to `util.inspect()`, allowing multiple lines if needed.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
exports.formatters.O = function(v) {
|
|
|
|
|
this.inspectOpts.colors = this.useColors;
|
|
|
|
|
return util.inspect(v, this.inspectOpts);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Adds ANSI color escape codes if enabled.
|
|
|
|
|
*
|
|
|
|
|
* @api public
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
function formatArgs(args) {
|
|
|
|
|
var name = this.namespace;
|
|
|
|
|
var useColors = this.useColors;
|
|
|
|
|
|
|
|
|
|
if (useColors) {
|
|
|
|
|
var c = this.color;
|
|
|
|
|
var colorCode = '\u001b[3' + (c < 8 ? c : '8;5;' + c);
|
|
|
|
|
var prefix = ' ' + colorCode + ';1m' + name + ' ' + '\u001b[0m';
|
|
|
|
|
|
|
|
|
|
args[0] = prefix + args[0].split('\n').join('\n' + prefix);
|
|
|
|
|
args.push(colorCode + 'm+' + exports.humanize(this.diff) + '\u001b[0m');
|
|
|
|
|
} else {
|
|
|
|
|
args[0] = getDate() + name + ' ' + args[0];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getDate() {
|
|
|
|
|
if (exports.inspectOpts.hideDate) {
|
|
|
|
|
return '';
|
|
|
|
|
} else {
|
|
|
|
|
return new Date().toISOString() + ' ';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Invokes `util.format()` with the specified arguments and writes to stderr.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
function log() {
|
|
|
|
|
return process.stderr.write(util.format.apply(util, arguments) + '\n');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Save `namespaces`.
|
|
|
|
|
*
|
|
|
|
|
* @param {String} namespaces
|
|
|
|
|
* @api private
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
function save(namespaces) {
|
|
|
|
|
if (null == namespaces) {
|
|
|
|
|
// If you set a process.env field to null or undefined, it gets cast to the
|
|
|
|
|
// string 'null' or 'undefined'. Just delete instead.
|
|
|
|
|
delete process.env.DEBUG;
|
|
|
|
|
} else {
|
|
|
|
|
process.env.DEBUG = namespaces;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Load `namespaces`.
|
|
|
|
|
*
|
|
|
|
|
* @return {String} returns the previously persisted debug modes
|
|
|
|
|
* @api private
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
function load() {
|
|
|
|
|
return process.env.DEBUG;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Init logic for `debug` instances.
|
|
|
|
|
*
|
|
|
|
|
* Create a new `inspectOpts` object in case `useColors` is set
|
|
|
|
|
* differently for a particular `debug` instance.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
function init (debug) {
|
|
|
|
|
debug.inspectOpts = {};
|
|
|
|
|
|
|
|
|
|
var keys = Object.keys(exports.inspectOpts);
|
|
|
|
|
for (var i = 0; i < keys.length; i++) {
|
|
|
|
|
debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Enable namespaces listed in `process.env.DEBUG` initially.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
exports.enable(load());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ "./node_modules/has-flag/index.js":
|
|
|
|
|
/*!****************************************!*\
|
|
|
|
|
!*** ./node_modules/has-flag/index.js ***!
|
|
|
|
|
\****************************************/
|
|
|
|
|
/*! no static exports found */
|
|
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
module.exports = (flag, argv) => {
|
|
|
|
|
argv = argv || process.argv;
|
|
|
|
|
const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--');
|
|
|
|
|
const pos = argv.indexOf(prefix + flag);
|
|
|
|
|
const terminatorPos = argv.indexOf('--');
|
|
|
|
|
return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ "./node_modules/ms/index.js":
|
|
|
|
|
/*!**********************************!*\
|
|
|
|
|
!*** ./node_modules/ms/index.js ***!
|
|
|
|
|
\**********************************/
|
|
|
|
|
/*! no static exports found */
|
|
|
|
|
/***/ (function(module, exports) {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Helpers.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
var s = 1000;
|
|
|
|
|
var m = s * 60;
|
|
|
|
|
var h = m * 60;
|
|
|
|
|
var d = h * 24;
|
|
|
|
|
var y = d * 365.25;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Parse or format the given `val`.
|
|
|
|
|
*
|
|
|
|
|
* Options:
|
|
|
|
|
*
|
|
|
|
|
* - `long` verbose formatting [false]
|
|
|
|
|
*
|
|
|
|
|
* @param {String|Number} val
|
|
|
|
|
* @param {Object} [options]
|
|
|
|
|
* @throws {Error} throw an error if val is not a non-empty string or a number
|
|
|
|
|
* @return {String|Number}
|
|
|
|
|
* @api public
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
module.exports = function(val, options) {
|
|
|
|
|
options = options || {};
|
|
|
|
|
var type = typeof val;
|
|
|
|
|
if (type === 'string' && val.length > 0) {
|
|
|
|
|
return parse(val);
|
|
|
|
|
} else if (type === 'number' && isNaN(val) === false) {
|
|
|
|
|
return options.long ? fmtLong(val) : fmtShort(val);
|
|
|
|
|
}
|
|
|
|
|
throw new Error(
|
|
|
|
|
'val is not a non-empty string or a valid number. val=' +
|
|
|
|
|
JSON.stringify(val)
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Parse the given `str` and return milliseconds.
|
|
|
|
|
*
|
|
|
|
|
* @param {String} str
|
|
|
|
|
* @return {Number}
|
|
|
|
|
* @api private
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
function parse(str) {
|
|
|
|
|
str = String(str);
|
|
|
|
|
if (str.length > 100) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(
|
|
|
|
|
str
|
|
|
|
|
);
|
|
|
|
|
if (!match) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
var n = parseFloat(match[1]);
|
|
|
|
|
var type = (match[2] || 'ms').toLowerCase();
|
|
|
|
|
switch (type) {
|
|
|
|
|
case 'years':
|
|
|
|
|
case 'year':
|
|
|
|
|
case 'yrs':
|
|
|
|
|
case 'yr':
|
|
|
|
|
case 'y':
|
|
|
|
|
return n * y;
|
|
|
|
|
case 'days':
|
|
|
|
|
case 'day':
|
|
|
|
|
case 'd':
|
|
|
|
|
return n * d;
|
|
|
|
|
case 'hours':
|
|
|
|
|
case 'hour':
|
|
|
|
|
case 'hrs':
|
|
|
|
|
case 'hr':
|
|
|
|
|
case 'h':
|
|
|
|
|
return n * h;
|
|
|
|
|
case 'minutes':
|
|
|
|
|
case 'minute':
|
|
|
|
|
case 'mins':
|
|
|
|
|
case 'min':
|
|
|
|
|
case 'm':
|
|
|
|
|
return n * m;
|
|
|
|
|
case 'seconds':
|
|
|
|
|
case 'second':
|
|
|
|
|
case 'secs':
|
|
|
|
|
case 'sec':
|
|
|
|
|
case 's':
|
|
|
|
|
return n * s;
|
|
|
|
|
case 'milliseconds':
|
|
|
|
|
case 'millisecond':
|
|
|
|
|
case 'msecs':
|
|
|
|
|
case 'msec':
|
|
|
|
|
case 'ms':
|
|
|
|
|
return n;
|
|
|
|
|
default:
|
|
|
|
|
return undefined;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Short format for `ms`.
|
|
|
|
|
*
|
|
|
|
|
* @param {Number} ms
|
|
|
|
|
* @return {String}
|
|
|
|
|
* @api private
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
function fmtShort(ms) {
|
|
|
|
|
if (ms >= d) {
|
|
|
|
|
return Math.round(ms / d) + 'd';
|
|
|
|
|
}
|
|
|
|
|
if (ms >= h) {
|
|
|
|
|
return Math.round(ms / h) + 'h';
|
|
|
|
|
}
|
|
|
|
|
if (ms >= m) {
|
|
|
|
|
return Math.round(ms / m) + 'm';
|
|
|
|
|
}
|
|
|
|
|
if (ms >= s) {
|
|
|
|
|
return Math.round(ms / s) + 's';
|
|
|
|
|
}
|
|
|
|
|
return ms + 'ms';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Long format for `ms`.
|
|
|
|
|
*
|
|
|
|
|
* @param {Number} ms
|
|
|
|
|
* @return {String}
|
|
|
|
|
* @api private
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
function fmtLong(ms) {
|
|
|
|
|
return plural(ms, d, 'day') ||
|
|
|
|
|
plural(ms, h, 'hour') ||
|
|
|
|
|
plural(ms, m, 'minute') ||
|
|
|
|
|
plural(ms, s, 'second') ||
|
|
|
|
|
ms + ' ms';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Pluralization helper.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
function plural(ms, n, name) {
|
|
|
|
|
if (ms < n) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (ms < n * 1.5) {
|
|
|
|
|
return Math.floor(ms / n) + ' ' + name;
|
|
|
|
|
}
|
|
|
|
|
return Math.ceil(ms / n) + ' ' + name + 's';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ "./node_modules/supports-color/index.js":
|
|
|
|
|
/*!**********************************************!*\
|
|
|
|
|
!*** ./node_modules/supports-color/index.js ***!
|
|
|
|
|
\**********************************************/
|
|
|
|
|
/*! no static exports found */
|
|
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
const os = __webpack_require__(/*! os */ "os");
|
|
|
|
|
const hasFlag = __webpack_require__(/*! has-flag */ "./node_modules/has-flag/index.js");
|
|
|
|
|
|
|
|
|
|
const {env} = process;
|
|
|
|
|
|
|
|
|
|
let forceColor;
|
|
|
|
|
if (hasFlag('no-color') ||
|
|
|
|
|
hasFlag('no-colors') ||
|
|
|
|
|
hasFlag('color=false')) {
|
|
|
|
|
forceColor = 0;
|
|
|
|
|
} else if (hasFlag('color') ||
|
|
|
|
|
hasFlag('colors') ||
|
|
|
|
|
hasFlag('color=true') ||
|
|
|
|
|
hasFlag('color=always')) {
|
|
|
|
|
forceColor = 1;
|
|
|
|
|
}
|
|
|
|
|
if ('FORCE_COLOR' in env) {
|
|
|
|
|
if (env.FORCE_COLOR === true || env.FORCE_COLOR === 'true') {
|
|
|
|
|
forceColor = 1;
|
|
|
|
|
} else if (env.FORCE_COLOR === false || env.FORCE_COLOR === 'false') {
|
|
|
|
|
forceColor = 0;
|
|
|
|
|
} else {
|
|
|
|
|
forceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function translateLevel(level) {
|
|
|
|
|
if (level === 0) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
level,
|
|
|
|
|
hasBasic: true,
|
|
|
|
|
has256: level >= 2,
|
|
|
|
|
has16m: level >= 3
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function supportsColor(stream) {
|
|
|
|
|
if (forceColor === 0) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (hasFlag('color=16m') ||
|
|
|
|
|
hasFlag('color=full') ||
|
|
|
|
|
hasFlag('color=truecolor')) {
|
|
|
|
|
return 3;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (hasFlag('color=256')) {
|
|
|
|
|
return 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (stream && !stream.isTTY && forceColor === undefined) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const min = forceColor || 0;
|
|
|
|
|
|
|
|
|
|
if (env.TERM === 'dumb') {
|
|
|
|
|
return min;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (process.platform === 'win32') {
|
|
|
|
|
// Node.js 7.5.0 is the first version of Node.js to include a patch to
|
|
|
|
|
// libuv that enables 256 color output on Windows. Anything earlier and it
|
|
|
|
|
// won't work. However, here we target Node.js 8 at minimum as it is an LTS
|
|
|
|
|
// release, and Node.js 7 is not. Windows 10 build 10586 is the first Windows
|
|
|
|
|
// release that supports 256 colors. Windows 10 build 14931 is the first release
|
|
|
|
|
// that supports 16m/TrueColor.
|
|
|
|
|
const osRelease = os.release().split('.');
|
|
|
|
|
if (
|
|
|
|
|
Number(process.versions.node.split('.')[0]) >= 8 &&
|
|
|
|
|
Number(osRelease[0]) >= 10 &&
|
|
|
|
|
Number(osRelease[2]) >= 10586
|
|
|
|
|
) {
|
|
|
|
|
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ('CI' in env) {
|
|
|
|
|
if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return min;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ('TEAMCITY_VERSION' in env) {
|
|
|
|
|
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (env.COLORTERM === 'truecolor') {
|
|
|
|
|
return 3;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ('TERM_PROGRAM' in env) {
|
|
|
|
|
const version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
|
|
|
|
|
|
|
|
|
|
switch (env.TERM_PROGRAM) {
|
|
|
|
|
case 'iTerm.app':
|
|
|
|
|
return version >= 3 ? 3 : 2;
|
|
|
|
|
case 'Apple_Terminal':
|
|
|
|
|
return 2;
|
|
|
|
|
// No default
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (/-256(color)?$/i.test(env.TERM)) {
|
|
|
|
|
return 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ('COLORTERM' in env) {
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return min;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getSupportLevel(stream) {
|
|
|
|
|
const level = supportsColor(stream);
|
|
|
|
|
return translateLevel(level);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
|
supportsColor: getSupportLevel,
|
|
|
|
|
stdout: getSupportLevel(process.stdout),
|
|
|
|
|
stderr: getSupportLevel(process.stderr)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ "./node_modules/transliteration/dist/browser/bundle.esm.min.js":
|
|
|
|
|
/*!*********************************************************************!*\
|
|
|
|
|
!*** ./node_modules/transliteration/dist/browser/bundle.esm.min.js ***!
|
|
|
|
|
\*********************************************************************/
|
|
|
|
|
/*! exports provided: slugify, transl, transliterate */
|
|
|
|
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
__webpack_require__.r(__webpack_exports__);
|
|
|
|
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "slugify", function() { return j; });
|
|
|
|
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "transl", function() { return b; });
|
|
|
|
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "transliterate", function() { return b; });
|
|
|
|
|
let a=[["\0","","","","","","","","\b","\t","\n","\v","\f","\r","","","","","","","","","","","","","","","","","",""," ","!",'"',"#","$","%","&","'","(",")","*","+",",","-",".","/","0","1","2","3","4","5","6","7","8","9",":",";","<","=",">","?","@","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","[","\\","]","^","_","`","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","{","|","}","~","",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,," ","!","C/","PS","$?","Y=","|","SS",'"',"(c)","a","<<","!",,"(r)","-","deg","+-","2","3","'","u","P","*",",","1","o",">>","1/4","1/2","3/4","?","A","A","A","A","A","A","AE","C","E","E","E","E","I","I","I","I","D","N","O","O","O","O","O","x","O","U","U","U","U","U","Th","ss","a","a","a","a","a","a","ae","c","e","e","e","e","i","i","i","i","d","n","o","o","o","o","o","/","o","u","u","u","u","y","th","y"],["A","a","A","a","A","a","C","c","C","c","C","c","C","c","D","d","D","d","E","e","E","e","E","e","E","e","E","e","G","g","G","g","G","g","G","g","H","h","H","h","I","i","I","i","I","i","I","i","I","i","IJ","ij","J","j","K","k","k","L","l","L","l","L","l","L","l","L","l","N","n","N","n","N","n","'n","NG","ng","O","o","O","o","O","o","OE","oe","R","r","R","r","R","r","S","s","S","s","S","s","S","s","T","t","T","t","T","t","U","u","U","u","U","u","U","u","U","u","U","u","W","w","Y","y","Y","Z","z","Z","z","Z","z","s","b","B","B","b","6","6","O","C","c","D","D","D","d","d","3","@","E","F","f","G","G","hv","I","I","K","k","l","l","W","N","n","O","O","o","OI","oi","P","p","YR","2","2","SH","sh","t","T","t","T","U","u","Y","V","Y","y","Z","z","ZH","ZH","zh","zh","2","5","5","ts","w","|","||","|=","!","DZ","Dz","dz","LJ","Lj","lj","NJ","Nj","nj","A","a","I","i","O","o","U","u","U","u","U","u","U","u","U","u","@","A","a","A","a","AE","ae","G","g","G","g","K","k","O","o","O","o","ZH","zh","j","DZ","D","dz","G","g","HV","W","N","n","A","a","AE","ae","O","o"],["A","a","A","a","E","e","E","e","I","i","I","i","O","o","O","o","R","r","R","r","U","u","U","u","S","s","T","t","Y","y","H","h","N","d","OU","ou","Z","z","A","a","E","e","O","o","O","o","O","o","O","o","Y","y","l","n","t","j","db","qp","A","C","c","L","T","s","z","?","?","B","U","V","E","e","J","j","Q","q","R","r","Y","y","a","a","a","b","o","c","d","d","e","@","@","e","e","e","e","j","g","g","g","g","u","Y","h","h","i","i","I","l","l","l","lZ","W","W","m","n","n","n","o","OE","O","F","R","R","R","R","r","r","R","R","R","s","S","j","S","S","t","t","U","U","v","^","W","Y","Y","z","z","Z","Z","?","?","?","C","@","B","E","G","H","j","k","L","q","?","?","dz","dZ","dz","ts","tS","tC","fN","ls","lz","WW","]]","h","h","k","h","j","r","r","r","r","w","y","'",'"',"`","'","`","`","'","?","?","<",">","^","V","^","V","'","-","/","\\",",","_","\\","/",":",".","`","'","^","V","+","-","V",".","@",",","~",'"',"R","X","G","l","s","x","?",,,,,,,,"V","=",'"'],[,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,"'",",",,,,,,,,,"?",,,,,,,,"A",";","E","I","I",,"O",,"U","O","I","A","V","G","D","E","Z","I","Th","I","K","L","M","N","X","O","P","R",,"S","T","Y","F","H","Ps","O","I","Y","a","e","i","i","y","a","v","g","d","e","z","i","th","i","k","l","m","n","x","o","p","r","s","s","t","y","f","h","ps","o","i","y","o","y","o",,"b","th","U","U","U","ph","p","&",,,"St","st","W","w","Q","q","Sp","sp","Sh","sh","F","f","Kh","kh","H","h","G","g","CH","ch","Ti","ti","k","r","c","j"],["Jo","Yo","Dj","Gj","Ie","Dz","I","Yi","J","Lj","Nj","Tsh","Kj","I","U","Dzh","A","B","V","G","D","E","Zh","Z","I","Y","K","L","M","N","O","P","R","S","T","U","F","H","C","Ch","Sh","Shch",,"Y",,"E","Yu","Ya","a","b","v","g","d","e","zh","z","i","y","k","l","m","n","o","p","r","s","t","u","f","h","c","ch","sh","shch",,"y",,"e","yu","ya","je","yo","dj","gj","ie","dz","i","yi","j","lj","nj","tsh","kj","i","u","dzh","O","o","E","e","Ie","ie","E","e","Ie","ie","O","o","Io","io","Ks","ks","Ps","ps","F","f","Y","y","Y","y",
|
|
|
|
|
//# sourceMappingURL=bundle.esm.min.js.map
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ "./src/anyrule.ts":
|
|
|
|
|
/*!************************!*\
|
|
|
|
|
!*** ./src/anyrule.ts ***!
|
|
|
|
|
\************************/
|
|
|
|
|
/*! no static exports found */
|
|
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
|
const vscode_1 = __webpack_require__(/*! vscode */ "vscode");
|
|
|
|
|
const utils_1 = __webpack_require__(/*! ./utils */ "./src/utils.ts");
|
|
|
|
|
const loader_1 = __webpack_require__(/*! ./loader */ "./src/loader.ts");
|
|
|
|
|
const panel_1 = __webpack_require__(/*! ./diagram/panel */ "./src/diagram/panel.ts");
|
|
|
|
|
class AnyRule {
|
|
|
|
|
constructor(context) {
|
|
|
|
|
this.disposable = null;
|
|
|
|
|
this.rules = null;
|
|
|
|
|
this.regexDiagram = null;
|
|
|
|
|
this.context = context;
|
|
|
|
|
this.regexDiagram = new panel_1.RegexDiagram(context);
|
|
|
|
|
loader_1.loadRules(context.extensionPath).then(rules => {
|
|
|
|
|
this.rules = rules;
|
|
|
|
|
this.load();
|
|
|
|
|
this.oldFunctionCompatible();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
load() {
|
|
|
|
|
let currentRules = [];
|
|
|
|
|
const configuration = vscode_1.workspace.getConfiguration();
|
|
|
|
|
let START_IDENTIFIER = configuration.get('anyRule.triggerString') || 'zz';
|
|
|
|
|
const setting = configuration.get('anyRule.supportedLanguages') || 'javascript,typescirpt';
|
|
|
|
|
const supportedLanguages = setting.split(',');
|
|
|
|
|
this.commandRegisters(START_IDENTIFIER);
|
|
|
|
|
this.disposable = vscode_1.languages.registerCompletionItemProvider(supportedLanguages, {
|
|
|
|
|
provideCompletionItems: (document, position, token, context) => {
|
|
|
|
|
const line = document.lineAt(position);
|
|
|
|
|
const lineText = line.text.substring(0, position.character);
|
|
|
|
|
if (new RegExp(`${START_IDENTIFIER}\.`, 'g').test(lineText)) {
|
|
|
|
|
currentRules = utils_1.getRulesByText(START_IDENTIFIER, this.rules || [], lineText);
|
|
|
|
|
return currentRules.map(rule => {
|
|
|
|
|
const item = new vscode_1.CompletionItem(rule.title, rule.regex ? vscode_1.CompletionItemKind.Field : vscode_1.CompletionItemKind.Folder);
|
|
|
|
|
// @ts-ignore
|
|
|
|
|
item.rule = rule;
|
|
|
|
|
// item.commitCharacters = ['.'];
|
|
|
|
|
item.filterText = utils_1.generateFilterString(rule);
|
|
|
|
|
item.documentation = rule.regex ? `${rule.title}\n${rule.examples ? '\n示例:\n' + rule.examples.join('\n') : ''}` : undefined;
|
|
|
|
|
item.command = {
|
|
|
|
|
title: '插入正则',
|
|
|
|
|
command: 'functions.insertRegex',
|
|
|
|
|
arguments: [document, position, rule]
|
|
|
|
|
};
|
|
|
|
|
return item;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
resolveCompletionItem: (item) => {
|
|
|
|
|
// @ts-ignore
|
|
|
|
|
const rule = item.rule;
|
|
|
|
|
if (rule.regex) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
item.insertText = item.label + '.';
|
|
|
|
|
return item;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}, '.');
|
|
|
|
|
this.context.subscriptions.push(this.disposable);
|
|
|
|
|
// window.showInformationMessage('AnyRule加载成功');
|
|
|
|
|
}
|
|
|
|
|
reload() {
|
|
|
|
|
if (this.disposable) {
|
|
|
|
|
this.disposable.dispose();
|
|
|
|
|
}
|
|
|
|
|
this.load();
|
|
|
|
|
}
|
|
|
|
|
update() {
|
|
|
|
|
loader_1.loadRules(this.context.extensionPath, true).then(rules => {
|
|
|
|
|
this.rules = rules;
|
|
|
|
|
this.reload();
|
|
|
|
|
vscode_1.window.showInformationMessage('正则库已更新');
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
commandRegisters(START_IDENTIFIER) {
|
|
|
|
|
vscode_1.commands.getCommands().then((commandList) => {
|
|
|
|
|
if (commandList.indexOf('functions.insertRegex') !== -1) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
vscode_1.commands.registerCommand('functions.insertRegex', (document, position, rule) => {
|
|
|
|
|
var _a;
|
|
|
|
|
if (rule.regex) {
|
|
|
|
|
const editor = vscode_1.window.activeTextEditor;
|
|
|
|
|
(_a = editor) === null || _a === void 0 ? void 0 : _a.edit(editBuilder => {
|
|
|
|
|
const line = document.lineAt(position);
|
|
|
|
|
const start = line.text.indexOf(START_IDENTIFIER);
|
|
|
|
|
if (start === -1) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (rule.regex) {
|
|
|
|
|
editBuilder.replace(new vscode_1.Range(new vscode_1.Position(line.lineNumber, start), new vscode_1.Position(line.lineNumber, line.text.length)), String(rule.regex));
|
|
|
|
|
// TODO 处理输入文本后选中字符串的问题
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
const end = new vscode_1.Position(line.lineNumber, line.text.length + String(rule.regex).length);
|
|
|
|
|
editor.selection = new vscode_1.Selection(end, end);
|
|
|
|
|
}, 0);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
vscode_1.commands.executeCommand('editor.action.triggerSuggest');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* 兼容旧的功能,大概率会在未来废弃,仅过度使用
|
|
|
|
|
*/
|
|
|
|
|
oldFunctionCompatible() {
|
|
|
|
|
var _a;
|
|
|
|
|
(_a = this.rules) === null || _a === void 0 ? void 0 : _a.forEach((rule, index) => {
|
|
|
|
|
vscode_1.commands.registerCommand(`extension.rule${index}`, () => {
|
|
|
|
|
const editor = vscode_1.window.activeTextEditor;
|
|
|
|
|
if (editor) {
|
|
|
|
|
const { selections } = editor;
|
|
|
|
|
editor.edit(editBuilder => {
|
|
|
|
|
selections.forEach(selection => {
|
|
|
|
|
const { start, end } = selection;
|
|
|
|
|
const range = new vscode_1.Range(start, end);
|
|
|
|
|
editBuilder.replace(range, String(rule.regex));
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
// Display a message box to the user
|
|
|
|
|
vscode_1.window.showInformationMessage(`已插入正则: ${rule.title}`);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
vscode_1.window.showWarningMessage('any-rule: 只有在编辑文本的时候才可以使用!');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
exports.AnyRule = AnyRule;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ "./src/diagram/panel.ts":
|
|
|
|
|
/*!******************************!*\
|
|
|
|
|
!*** ./src/diagram/panel.ts ***!
|
|
|
|
|
\******************************/
|
|
|
|
|
/*! no static exports found */
|
|
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
|
const vscode_1 = __webpack_require__(/*! vscode */ "vscode");
|
|
|
|
|
const path_1 = __webpack_require__(/*! path */ "path");
|
|
|
|
|
const fs_1 = __webpack_require__(/*! fs */ "fs");
|
|
|
|
|
class RegexDiagram {
|
|
|
|
|
constructor(context) {
|
|
|
|
|
this.regex = null;
|
|
|
|
|
this.panel = null;
|
|
|
|
|
this.panel = vscode_1.window.createWebviewPanel('regexDiagram', '图解正则表达式', vscode_1.ViewColumn.Two, {
|
|
|
|
|
enableScripts: true,
|
|
|
|
|
retainContextWhenHidden: false,
|
|
|
|
|
});
|
|
|
|
|
console.log(path_1.join(context.extensionPath, 'src/diagram', './index.html'));
|
|
|
|
|
this.panel.webview.html = fs_1.readFileSync(path_1.join(context.extensionPath, 'src/diagram', './index.html')).toString();
|
|
|
|
|
this.panel.webview.postMessage({
|
|
|
|
|
regex: this.regex || '/aaaaab{1,3}/',
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
exports.RegexDiagram = RegexDiagram;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ "./src/extension.ts":
|
|
|
|
|
/*!**************************!*\
|
|
|
|
|
!*** ./src/extension.ts ***!
|
|
|
|
|
\**************************/
|
|
|
|
|
/*! no static exports found */
|
|
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
|
// The module 'vscode' contains the VS Code extensibility API
|
|
|
|
|
// Import the module and reference it with the alias vscode in your code below
|
|
|
|
|
const vscode_1 = __webpack_require__(/*! vscode */ "vscode");
|
|
|
|
|
const anyrule_1 = __webpack_require__(/*! ./anyrule */ "./src/anyrule.ts");
|
|
|
|
|
// this method is called when your extension is activated
|
|
|
|
|
// your extension is activated the very first time the command is executed
|
|
|
|
|
function activate(context) {
|
|
|
|
|
// Use the console to output diagnostic information (console.log) and errors (console.error)
|
|
|
|
|
// This line of code will only be executed once when your extension is activated
|
|
|
|
|
console.log('Congratulations, your extension "any-rule" is now active!');
|
|
|
|
|
// The command has been defined in the package.json file
|
|
|
|
|
// Now provide the implementation of the command with registerCommand
|
|
|
|
|
// The commandId parameter must match the command field in package.json
|
|
|
|
|
// let disposable = vscode.commands.registerCommand('extension.helloWorld', () => {
|
|
|
|
|
// // The code you place here will be executed every time your command is executed
|
|
|
|
|
const anyRule = new anyrule_1.AnyRule(context);
|
|
|
|
|
vscode_1.workspace.onDidChangeConfiguration((event) => {
|
|
|
|
|
anyRule.reload();
|
|
|
|
|
});
|
|
|
|
|
vscode_1.commands.registerCommand('extension.update', () => {
|
|
|
|
|
anyRule.update();
|
|
|
|
|
});
|
|
|
|
|
vscode_1.commands.registerCommand('extension.reload', () => {
|
|
|
|
|
anyRule.reload();
|
|
|
|
|
vscode_1.window.showInformationMessage('重新加载插件成功');
|
|
|
|
|
});
|
|
|
|
|
vscode_1.commands.registerCommand('extension.support', () => {
|
|
|
|
|
var _a;
|
|
|
|
|
const currentLanguage = (_a = vscode_1.window.activeTextEditor) === null || _a === void 0 ? void 0 : _a.document.languageId;
|
|
|
|
|
if (currentLanguage) {
|
|
|
|
|
try {
|
|
|
|
|
const configuration = vscode_1.workspace.getConfiguration();
|
|
|
|
|
const setting = configuration.get('anyRule.supportedLanguages') || 'javascript,typescirpt';
|
|
|
|
|
const supportedLanguages = setting.split(',');
|
|
|
|
|
const set = new Set(supportedLanguages);
|
|
|
|
|
set.add(currentLanguage);
|
|
|
|
|
console.log(Array.from(set).join(','));
|
|
|
|
|
configuration.update('anyRule.supportedLanguages', Array.from(set).join(',')).then(() => {
|
|
|
|
|
anyRule.reload();
|
|
|
|
|
});
|
|
|
|
|
vscode_1.window.showInformationMessage('更新关联语言成功');
|
|
|
|
|
}
|
|
|
|
|
catch (e) {
|
|
|
|
|
vscode_1.window.showInformationMessage('更新关联语言失败');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
exports.activate = activate;
|
|
|
|
|
// this method is called when your extension is deactivated
|
|
|
|
|
function deactivate() { }
|
|
|
|
|
exports.deactivate = deactivate;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ "./src/loader.ts":
|
|
|
|
|
/*!***********************!*\
|
|
|
|
|
!*** ./src/loader.ts ***!
|
|
|
|
|
\***********************/
|
|
|
|
|
/*! no static exports found */
|
|
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
|
|
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
|
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
|
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
|
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
|
|
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
|
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
|
const axios_1 = __webpack_require__(/*! axios */ "./node_modules/axios/index.js");
|
|
|
|
|
const fs_1 = __webpack_require__(/*! fs */ "fs");
|
|
|
|
|
const path_1 = __webpack_require__(/*! path */ "path");
|
|
|
|
|
function loadRulesFromFile(path) {
|
|
|
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
|
|
|
try {
|
|
|
|
|
const json = fs_1.readFileSync(path);
|
|
|
|
|
return JSON.parse(json.toString());
|
|
|
|
|
}
|
|
|
|
|
catch (e) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
function loadRulesFromWeb() {
|
|
|
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
|
|
|
const dataSources = [
|
|
|
|
|
'https://raw.githubusercontent.com/any86/any-rule/feature/vscode-refactor/rules.json'
|
|
|
|
|
];
|
|
|
|
|
let rules = [];
|
|
|
|
|
for (const source of dataSources) {
|
|
|
|
|
try {
|
|
|
|
|
const response = yield axios_1.default.get(source);
|
|
|
|
|
const body = response.data;
|
|
|
|
|
rules = body;
|
|
|
|
|
}
|
|
|
|
|
catch (e) {
|
|
|
|
|
console.log(e);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return rules;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
function loadRules(extensionPath, force = false) {
|
|
|
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
|
|
|
const rulePath = path_1.join(extensionPath, 'rules.json');
|
|
|
|
|
let rules = null;
|
|
|
|
|
if (!force) {
|
|
|
|
|
rules = yield loadRulesFromFile(rulePath);
|
|
|
|
|
}
|
|
|
|
|
if (!rules) {
|
|
|
|
|
rules = yield loadRulesFromWeb();
|
|
|
|
|
fs_1.writeFileSync(rulePath, Buffer.from(JSON.stringify(rules)));
|
|
|
|
|
}
|
|
|
|
|
return rules;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
exports.loadRules = loadRules;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ "./src/utils.ts":
|
|
|
|
|
/*!**********************!*\
|
|
|
|
|
!*** ./src/utils.ts ***!
|
|
|
|
|
\**********************/
|
|
|
|
|
/*! no static exports found */
|
|
|
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
|
// import { convertToPinyin } from 'tiny-pinyin';
|
|
|
|
|
const transliteration_1 = __webpack_require__(/*! transliteration */ "./node_modules/transliteration/dist/browser/bundle.esm.min.js");
|
|
|
|
|
function preprocessText(START_IDENTIFIER, text) {
|
|
|
|
|
const start = text.indexOf(START_IDENTIFIER);
|
|
|
|
|
if (start === -1) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
const pathString = text.substring(start, text.length);
|
|
|
|
|
const pathArray = pathString.split('.');
|
|
|
|
|
return pathArray;
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* 根据特定的字符串解析出当前可以用的规则列表
|
|
|
|
|
* @param text 待解析的字符串
|
|
|
|
|
*/
|
|
|
|
|
function getRulesByText(START_IDENTIFIER, rules, text) {
|
|
|
|
|
const pathArray = preprocessText(START_IDENTIFIER, text);
|
|
|
|
|
if (!pathArray) {
|
|
|
|
|
return [];
|
|
|
|
|
}
|
|
|
|
|
let currentRules = [];
|
|
|
|
|
let targetRules = rules;
|
|
|
|
|
for (const path of pathArray) {
|
|
|
|
|
if (path === START_IDENTIFIER) {
|
|
|
|
|
currentRules = rules;
|
|
|
|
|
}
|
|
|
|
|
else if (path === '') {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
const searchRule = targetRules.find(rule => rule.title === path);
|
|
|
|
|
if (!searchRule) {
|
|
|
|
|
return [];
|
|
|
|
|
}
|
|
|
|
|
if (searchRule.regex) {
|
|
|
|
|
return [];
|
|
|
|
|
}
|
|
|
|
|
currentRules = searchRule.rules || [];
|
|
|
|
|
targetRules = currentRules;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return currentRules;
|
|
|
|
|
}
|
|
|
|
|
exports.getRulesByText = getRulesByText;
|
|
|
|
|
function getRuleByText(START_IDENTIFIER, rules, text) {
|
|
|
|
|
const pathArray = preprocessText(START_IDENTIFIER, text);
|
|
|
|
|
if (!pathArray) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
let targetRules = rules;
|
|
|
|
|
let searchRule;
|
|
|
|
|
for (const path of pathArray) {
|
|
|
|
|
if (path === START_IDENTIFIER) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
searchRule = targetRules.find(rule => rule.title === path);
|
|
|
|
|
if (!searchRule) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
if (searchRule.regex) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
targetRules = searchRule.rules || [];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return searchRule || null;
|
|
|
|
|
}
|
|
|
|
|
exports.getRuleByText = getRuleByText;
|
|
|
|
|
function generateFilterString(rule) {
|
|
|
|
|
let filterString = '';
|
|
|
|
|
filterString += rule.title;
|
|
|
|
|
const pinyin = transliteration_1.slugify(rule.title).split('-');
|
|
|
|
|
if (/.*[\u4e00-\u9fa5]+.*$/.test(rule.title)) {
|
|
|
|
|
filterString += ' ' + pinyin.join('');
|
|
|
|
|
filterString += ' ' + pinyin.map(item => item.length ? item[0] : '');
|
|
|
|
|
}
|
|
|
|
|
if (rule.keywords) {
|
|
|
|
|
filterString += ' ' + rule.keywords.join(' ');
|
|
|
|
|
}
|
|
|
|
|
return filterString;
|
|
|
|
|
}
|
|
|
|
|
exports.generateFilterString = generateFilterString;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ "assert":
|
|
|
|
|
/*!*************************!*\
|
|
|
|
|
!*** external "assert" ***!
|
|
|
|
|
\*************************/
|
|
|
|
|
/*! no static exports found */
|
|
|
|
|
/***/ (function(module, exports) {
|
|
|
|
|
|
|
|
|
|
module.exports = require("assert");
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ "fs":
|
|
|
|
|
/*!*********************!*\
|
|
|
|
|
!*** external "fs" ***!
|
|
|
|
|
\*********************/
|
|
|
|
|
/*! no static exports found */
|
|
|
|
|
/***/ (function(module, exports) {
|
|
|
|
|
|
|
|
|
|
module.exports = require("fs");
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ "http":
|
|
|
|
|
/*!***********************!*\
|
|
|
|
|
!*** external "http" ***!
|
|
|
|
|
\***********************/
|
|
|
|
|
/*! no static exports found */
|
|
|
|
|
/***/ (function(module, exports) {
|
|
|
|
|
|
|
|
|
|
module.exports = require("http");
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ "https":
|
|
|
|
|
/*!************************!*\
|
|
|
|
|
!*** external "https" ***!
|
|
|
|
|
\************************/
|
|
|
|
|
/*! no static exports found */
|
|
|
|
|
/***/ (function(module, exports) {
|
|
|
|
|
|
|
|
|
|
module.exports = require("https");
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ "os":
|
|
|
|
|
/*!*********************!*\
|
|
|
|
|
!*** external "os" ***!
|
|
|
|
|
\*********************/
|
|
|
|
|
/*! no static exports found */
|
|
|
|
|
/***/ (function(module, exports) {
|
|
|
|
|
|
|
|
|
|
module.exports = require("os");
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ "path":
|
|
|
|
|
/*!***********************!*\
|
|
|
|
|
!*** external "path" ***!
|
|
|
|
|
\***********************/
|
|
|
|
|
/*! no static exports found */
|
|
|
|
|
/***/ (function(module, exports) {
|
|
|
|
|
|
|
|
|
|
module.exports = require("path");
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ "stream":
|
|
|
|
|
/*!*************************!*\
|
|
|
|
|
!*** external "stream" ***!
|
|
|
|
|
\*************************/
|
|
|
|
|
/*! no static exports found */
|
|
|
|
|
/***/ (function(module, exports) {
|
|
|
|
|
|
|
|
|
|
module.exports = require("stream");
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ "tty":
|
|
|
|
|
/*!**********************!*\
|
|
|
|
|
!*** external "tty" ***!
|
|
|
|
|
\**********************/
|
|
|
|
|
/*! no static exports found */
|
|
|
|
|
/***/ (function(module, exports) {
|
|
|
|
|
|
|
|
|
|
module.exports = require("tty");
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ "url":
|
|
|
|
|
/*!**********************!*\
|
|
|
|
|
!*** external "url" ***!
|
|
|
|
|
\**********************/
|
|
|
|
|
/*! no static exports found */
|
|
|
|
|
/***/ (function(module, exports) {
|
|
|
|
|
|
|
|
|
|
module.exports = require("url");
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ "util":
|
|
|
|
|
/*!***********************!*\
|
|
|
|
|
!*** external "util" ***!
|
|
|
|
|
\***********************/
|
|
|
|
|
/*! no static exports found */
|
|
|
|
|
/***/ (function(module, exports) {
|
|
|
|
|
|
|
|
|
|
module.exports = require("util");
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ "vscode":
|
|
|
|
|
/*!*************************!*\
|
|
|
|
|
!*** external "vscode" ***!
|
|
|
|
|
\*************************/
|
|
|
|
|
/*! no static exports found */
|
|
|
|
|
/***/ (function(module, exports) {
|
|
|
|
|
|
|
|
|
|
module.exports = require("vscode");
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ "zlib":
|
|
|
|
|
/*!***********************!*\
|
|
|
|
|
!*** external "zlib" ***!
|
|
|
|
|
\***********************/
|
|
|
|
|
/*! no static exports found */
|
|
|
|
|
/***/ (function(module, exports) {
|
|
|
|
|
|
|
|
|
|
module.exports = require("zlib");
|
|
|
|
|
|
|
|
|
|
/***/ })
|
|
|
|
|
|
|
|
|
|
/******/ });
|
2020-01-04 21:34:00 +08:00
|
|
|
|
//# sourceMappingURL=extension.js.map
|