infly-libs
Version:
工具组件库
2,118 lines (1,766 loc) • 147 kB
JavaScript
/******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ({
/***/ 16:
/***/ ((module) => {
"use strict";
module.exports = require("url");
/***/ }),
/***/ 18:
/***/ ((module) => {
"use strict";
module.exports = require("tty");
/***/ }),
/***/ 23:
/***/ ((module) => {
"use strict";
/*!
* encodeurl
* Copyright(c) 2016 Douglas Christopher Wilson
* MIT Licensed
*/
/**
* Module exports.
* @public
*/
module.exports = encodeUrl;
/**
* RegExp to match non-URL code points, *after* encoding (i.e. not including "%")
* and including invalid escape sequences.
* @private
*/
var ENCODE_CHARS_REGEXP = /(?:[^\x21\x23-\x3B\x3D\x3F-\x5F\x61-\x7A\x7C\x7E]|%(?:[^0-9A-Fa-f]|[0-9A-Fa-f][^0-9A-Fa-f]|$))+/g;
/**
* RegExp to match unmatched surrogate pair.
* @private
*/
var UNMATCHED_SURROGATE_PAIR_REGEXP = /(^|[^\uD800-\uDBFF])[\uDC00-\uDFFF]|[\uD800-\uDBFF]([^\uDC00-\uDFFF]|$)/g;
/**
* String to replace unmatched surrogate pair with.
* @private
*/
var UNMATCHED_SURROGATE_PAIR_REPLACE = '$1\uFFFD$2';
/**
* Encode a URL to a percent-encoded form, excluding already-encoded sequences.
*
* This function will take an already-encoded URL and encode all the non-URL
* code points. This function will not encode the "%" character unless it is
* not part of a valid sequence (`%20` will be left as-is, but `%foo` will
* be encoded as `%25foo`).
*
* This encode is meant to be "safe" and does not throw errors. It will try as
* hard as it can to properly encode the given URL, including replacing any raw,
* unpaired surrogate pairs with the Unicode replacement character prior to
* encoding.
*
* @param {string} url
* @return {string}
* @public
*/
function encodeUrl(url) {
return String(url).replace(UNMATCHED_SURROGATE_PAIR_REGEXP, UNMATCHED_SURROGATE_PAIR_REPLACE).replace(ENCODE_CHARS_REGEXP, encodeURI);
}
/***/ }),
/***/ 68:
/***/ ((module, __unused_webpack_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__(192);
} else {
module.exports = __webpack_require__(498);
}
/***/ }),
/***/ 74:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
"use strict";
/*!
* statuses
* Copyright(c) 2014 Jonathan Ong
* Copyright(c) 2016 Douglas Christopher Wilson
* MIT Licensed
*/
/**
* Module dependencies.
* @private
*/
var codes = __webpack_require__(900);
/**
* Module exports.
* @public
*/
module.exports = status;
// status code to message map
status.message = codes;
// status message (lower-case) to code map
status.code = createMessageToStatusCodeMap(codes);
// array of status codes
status.codes = createStatusCodeList(codes);
// status codes for redirects
status.redirect = {
300: true,
301: true,
302: true,
303: true,
305: true,
307: true,
308: true
};
// status codes for empty bodies
status.empty = {
204: true,
205: true,
304: true
};
// status codes for when you should retry the request
status.retry = {
502: true,
503: true,
504: true
};
/**
* Create a map of message to status code.
* @private
*/
function createMessageToStatusCodeMap(codes) {
var map = {};
Object.keys(codes).forEach(function forEachCode(code) {
var message = codes[code];
var status = Number(code);
// populate map
map[message.toLowerCase()] = status;
});
return map;
}
/**
* Create a list of all status codes.
* @private
*/
function createStatusCodeList(codes) {
return Object.keys(codes).map(function mapCode(code) {
return Number(code);
});
}
/**
* Get the status code for given message.
* @private
*/
function getStatusCode(message) {
var msg = message.toLowerCase();
if (!Object.prototype.hasOwnProperty.call(status.code, msg)) {
throw new Error('invalid status message: "' + message + '"');
}
return status.code[msg];
}
/**
* Get the status message for given code.
* @private
*/
function getStatusMessage(code) {
if (!Object.prototype.hasOwnProperty.call(status.message, code)) {
throw new Error('invalid status code: ' + code);
}
return status.message[code];
}
/**
* Get the status code.
*
* Given a number, this will throw if it is not a known status
* code, otherwise the code will be returned. Given a string,
* the string will be parsed for a number and return the code
* if valid, otherwise will lookup the code assuming this is
* the status message.
*
* @param {string|number} code
* @returns {number}
* @public
*/
function status(code) {
if (typeof code === 'number') {
return getStatusMessage(code);
}
if (typeof code !== 'string') {
throw new TypeError('code must be a number or string');
}
// '403'
var n = parseInt(code, 10);
if (!isNaN(n)) {
return getStatusMessage(n);
}
return getStatusCode(code);
}
/***/ }),
/***/ 88:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
"use strict";
/*!
* http-errors
* Copyright(c) 2014 Jonathan Ong
* Copyright(c) 2016 Douglas Christopher Wilson
* MIT Licensed
*/
/**
* Module dependencies.
* @private
*/
var deprecate = __webpack_require__(959)('http-errors');
var setPrototypeOf = __webpack_require__(127);
var statuses = __webpack_require__(74);
var inherits = __webpack_require__(726);
var toIdentifier = __webpack_require__(282);
/**
* Module exports.
* @public
*/
module.exports = createError;
module.exports.HttpError = createHttpErrorConstructor();
module.exports.isHttpError = createIsHttpErrorFunction(module.exports.HttpError);
// Populate exports for all constructors
populateConstructorExports(module.exports, statuses.codes, module.exports.HttpError);
/**
* Get the code class of a status code.
* @private
*/
function codeClass(status) {
return Number(String(status).charAt(0) + '00');
}
/**
* Create a new HTTP Error.
*
* @returns {Error}
* @public
*/
function createError() {
// so much arity going on ~_~
var err;
var msg;
var status = 500;
var props = {};
for (var i = 0; i < arguments.length; i++) {
var arg = arguments[i];
var type = typeof arg;
if (type === 'object' && arg instanceof Error) {
err = arg;
status = err.status || err.statusCode || status;
} else if (type === 'number' && i === 0) {
status = arg;
} else if (type === 'string') {
msg = arg;
} else if (type === 'object') {
props = arg;
} else {
throw new TypeError('argument #' + (i + 1) + ' unsupported type ' + type);
}
}
if (typeof status === 'number' && (status < 400 || status >= 600)) {
deprecate('non-error status code; use only 4xx or 5xx status codes');
}
if (typeof status !== 'number' || !statuses.message[status] && (status < 400 || status >= 600)) {
status = 500;
}
// constructor
var HttpError = createError[status] || createError[codeClass(status)];
if (!err) {
// create error
err = HttpError ? new HttpError(msg) : new Error(msg || statuses.message[status]);
Error.captureStackTrace(err, createError);
}
if (!HttpError || !(err instanceof HttpError) || err.status !== status) {
// add properties to generic error
err.expose = status < 500;
err.status = err.statusCode = status;
}
for (var key in props) {
if (key !== 'status' && key !== 'statusCode') {
err[key] = props[key];
}
}
return err;
}
/**
* Create HTTP error abstract base class.
* @private
*/
function createHttpErrorConstructor() {
function HttpError() {
throw new TypeError('cannot construct abstract class');
}
inherits(HttpError, Error);
return HttpError;
}
/**
* Create a constructor for a client error.
* @private
*/
function createClientErrorConstructor(HttpError, name, code) {
var className = toClassName(name);
function ClientError(message) {
// create the error object
var msg = message != null ? message : statuses.message[code];
var err = new Error(msg);
// capture a stack trace to the construction point
Error.captureStackTrace(err, ClientError);
// adjust the [[Prototype]]
setPrototypeOf(err, ClientError.prototype);
// redefine the error message
Object.defineProperty(err, 'message', {
enumerable: true,
configurable: true,
value: msg,
writable: true
});
// redefine the error name
Object.defineProperty(err, 'name', {
enumerable: false,
configurable: true,
value: className,
writable: true
});
return err;
}
inherits(ClientError, HttpError);
nameFunc(ClientError, className);
ClientError.prototype.status = code;
ClientError.prototype.statusCode = code;
ClientError.prototype.expose = true;
return ClientError;
}
/**
* Create function to test is a value is a HttpError.
* @private
*/
function createIsHttpErrorFunction(HttpError) {
return function isHttpError(val) {
if (!val || typeof val !== 'object') {
return false;
}
if (val instanceof HttpError) {
return true;
}
return val instanceof Error && typeof val.expose === 'boolean' && typeof val.statusCode === 'number' && val.status === val.statusCode;
};
}
/**
* Create a constructor for a server error.
* @private
*/
function createServerErrorConstructor(HttpError, name, code) {
var className = toClassName(name);
function ServerError(message) {
// create the error object
var msg = message != null ? message : statuses.message[code];
var err = new Error(msg);
// capture a stack trace to the construction point
Error.captureStackTrace(err, ServerError);
// adjust the [[Prototype]]
setPrototypeOf(err, ServerError.prototype);
// redefine the error message
Object.defineProperty(err, 'message', {
enumerable: true,
configurable: true,
value: msg,
writable: true
});
// redefine the error name
Object.defineProperty(err, 'name', {
enumerable: false,
configurable: true,
value: className,
writable: true
});
return err;
}
inherits(ServerError, HttpError);
nameFunc(ServerError, className);
ServerError.prototype.status = code;
ServerError.prototype.statusCode = code;
ServerError.prototype.expose = false;
return ServerError;
}
/**
* Set the name of a function, if possible.
* @private
*/
function nameFunc(func, name) {
var desc = Object.getOwnPropertyDescriptor(func, 'name');
if (desc && desc.configurable) {
desc.value = name;
Object.defineProperty(func, 'name', desc);
}
}
/**
* Populate the exports object with constructors for every error class.
* @private
*/
function populateConstructorExports(exports, codes, HttpError) {
codes.forEach(function forEachCode(code) {
var CodeError;
var name = toIdentifier(statuses.message[code]);
switch (codeClass(code)) {
case 400:
CodeError = createClientErrorConstructor(HttpError, name, code);
break;
case 500:
CodeError = createServerErrorConstructor(HttpError, name, code);
break;
}
if (CodeError) {
// export the constructor
exports[code] = CodeError;
exports[name] = CodeError;
}
});
}
/**
* Get a class name from a name identifier.
* @private
*/
function toClassName(name) {
return name.substr(-5) !== 'Error' ? name + 'Error' : name;
}
/***/ }),
/***/ 100:
/***/ ((module) => {
"use strict";
module.exports = /*#__PURE__*/JSON.parse('{"100":"Continue","101":"Switching Protocols","102":"Processing","103":"Early Hints","200":"OK","201":"Created","202":"Accepted","203":"Non-Authoritative Information","204":"No Content","205":"Reset Content","206":"Partial Content","207":"Multi-Status","208":"Already Reported","226":"IM Used","300":"Multiple Choices","301":"Moved Permanently","302":"Found","303":"See Other","304":"Not Modified","305":"Use Proxy","307":"Temporary Redirect","308":"Permanent Redirect","400":"Bad Request","401":"Unauthorized","402":"Payment Required","403":"Forbidden","404":"Not Found","405":"Method Not Allowed","406":"Not Acceptable","407":"Proxy Authentication Required","408":"Request Timeout","409":"Conflict","410":"Gone","411":"Length Required","412":"Precondition Failed","413":"Payload Too Large","414":"URI Too Long","415":"Unsupported Media Type","416":"Range Not Satisfiable","417":"Expectation Failed","418":"I\'m a Teapot","421":"Misdirected Request","422":"Unprocessable Entity","423":"Locked","424":"Failed Dependency","425":"Too Early","426":"Upgrade Required","428":"Precondition Required","429":"Too Many Requests","431":"Request Header Fields Too Large","451":"Unavailable For Legal Reasons","500":"Internal Server Error","501":"Not Implemented","502":"Bad Gateway","503":"Service Unavailable","504":"Gateway Timeout","505":"HTTP Version Not Supported","506":"Variant Also Negotiates","507":"Insufficient Storage","508":"Loop Detected","509":"Bandwidth Limit Exceeded","510":"Not Extended","511":"Network Authentication Required"}');
/***/ }),
/***/ 106:
/***/ ((module) => {
"use strict";
module.exports = require("zlib");
/***/ }),
/***/ 127:
/***/ ((module) => {
"use strict";
/* eslint no-proto: 0 */
module.exports = Object.setPrototypeOf || ({
__proto__: []
} instanceof Array ? setProtoOf : mixinProperties);
function setProtoOf(obj, proto) {
obj.__proto__ = proto;
return obj;
}
function mixinProperties(obj, proto) {
for (var prop in proto) {
if (!Object.prototype.hasOwnProperty.call(obj, prop)) {
obj[prop] = proto[prop];
}
}
return obj;
}
/***/ }),
/***/ 192:
/***/ ((module, exports, __webpack_require__) => {
/**
* This is the web browser implementation of `debug()`.
*
* Expose `debug()` as the module.
*/
exports = module.exports = __webpack_require__(843);
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 = ['lightseagreen', 'forestgreen', 'goldenrod', 'dodgerblue', 'darkorchid', 'crimson'];
/**
* 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;
}
// 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) {}
}
/***/ }),
/***/ 193:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
"use strict";
/*!
* etag
* Copyright(c) 2014-2016 Douglas Christopher Wilson
* MIT Licensed
*/
/**
* Module exports.
* @public
*/
module.exports = etag;
/**
* Module dependencies.
* @private
*/
var crypto = __webpack_require__(982);
var Stats = (__webpack_require__(896).Stats);
/**
* Module variables.
* @private
*/
var toString = Object.prototype.toString;
/**
* Generate an entity tag.
*
* @param {Buffer|string} entity
* @return {string}
* @private
*/
function entitytag(entity) {
if (entity.length === 0) {
// fast-path empty
return '"0-2jmj7l5rSw0yVb/vlWAYkK/YBwk"';
}
// compute hash of entity
var hash = crypto.createHash('sha1').update(entity, 'utf8').digest('base64').substring(0, 27);
// compute length of entity
var len = typeof entity === 'string' ? Buffer.byteLength(entity, 'utf8') : entity.length;
return '"' + len.toString(16) + '-' + hash + '"';
}
/**
* Create a simple ETag.
*
* @param {string|Buffer|Stats} entity
* @param {object} [options]
* @param {boolean} [options.weak]
* @return {String}
* @public
*/
function etag(entity, options) {
if (entity == null) {
throw new TypeError('argument entity is required');
}
// support fs.Stats object
var isStats = isstats(entity);
var weak = options && typeof options.weak === 'boolean' ? options.weak : isStats;
// validate argument
if (!isStats && typeof entity !== 'string' && !Buffer.isBuffer(entity)) {
throw new TypeError('argument entity must be string, Buffer, or fs.Stats');
}
// generate entity tag
var tag = isStats ? stattag(entity) : entitytag(entity);
return weak ? 'W/' + tag : tag;
}
/**
* Determine if object is a Stats object.
*
* @param {object} obj
* @return {boolean}
* @api private
*/
function isstats(obj) {
// genuine fs.Stats
if (typeof Stats === 'function' && obj instanceof Stats) {
return true;
}
// quack quack
return obj && typeof obj === 'object' && 'ctime' in obj && toString.call(obj.ctime) === '[object Date]' && 'mtime' in obj && toString.call(obj.mtime) === '[object Date]' && 'ino' in obj && typeof obj.ino === 'number' && 'size' in obj && typeof obj.size === 'number';
}
/**
* Generate a tag for a stat.
*
* @param {object} stat
* @return {string}
* @private
*/
function stattag(stat) {
var mtime = stat.mtime.getTime().toString(16);
var size = stat.size.toString(16);
return '"' + size + '-' + mtime + '"';
}
/***/ }),
/***/ 203:
/***/ ((module) => {
"use strict";
module.exports = require("stream");
/***/ }),
/***/ 252:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
"use strict";
/*!
* parseurl
* Copyright(c) 2014 Jonathan Ong
* Copyright(c) 2014-2017 Douglas Christopher Wilson
* MIT Licensed
*/
/**
* Module dependencies.
* @private
*/
var url = __webpack_require__(16);
var parse = url.parse;
var Url = url.Url;
/**
* Module exports.
* @public
*/
module.exports = parseurl;
module.exports.original = originalurl;
/**
* Parse the `req` url with memoization.
*
* @param {ServerRequest} req
* @return {Object}
* @public
*/
function parseurl(req) {
var url = req.url;
if (url === undefined) {
// URL is undefined
return undefined;
}
var parsed = req._parsedUrl;
if (fresh(url, parsed)) {
// Return cached URL parse
return parsed;
}
// Parse the URL
parsed = fastparse(url);
parsed._raw = url;
return req._parsedUrl = parsed;
}
;
/**
* Parse the `req` original url with fallback and memoization.
*
* @param {ServerRequest} req
* @return {Object}
* @public
*/
function originalurl(req) {
var url = req.originalUrl;
if (typeof url !== 'string') {
// Fallback
return parseurl(req);
}
var parsed = req._parsedOriginalUrl;
if (fresh(url, parsed)) {
// Return cached URL parse
return parsed;
}
// Parse the URL
parsed = fastparse(url);
parsed._raw = url;
return req._parsedOriginalUrl = parsed;
}
;
/**
* Parse the `str` url with fast-path short-cut.
*
* @param {string} str
* @return {Object}
* @private
*/
function fastparse(str) {
if (typeof str !== 'string' || str.charCodeAt(0) !== 0x2f /* / */) {
return parse(str);
}
var pathname = str;
var query = null;
var search = null;
// This takes the regexp from https://github.com/joyent/node/pull/7878
// Which is /^(\/[^?#\s]*)(\?[^#\s]*)?$/
// And unrolls it into a for loop
for (var i = 1; i < str.length; i++) {
switch (str.charCodeAt(i)) {
case 0x3f:
/* ? */
if (search === null) {
pathname = str.substring(0, i);
query = str.substring(i + 1);
search = str.substring(i);
}
break;
case 0x09: /* \t */
case 0x0a: /* \n */
case 0x0c: /* \f */
case 0x0d: /* \r */
case 0x20: /* */
case 0x23: /* # */
case 0xa0:
case 0xfeff:
return parse(str);
}
}
var url = Url !== undefined ? new Url() : {};
url.path = str;
url.href = str;
url.pathname = pathname;
if (search !== null) {
url.query = query;
url.search = search;
}
return url;
}
/**
* Determine if parsed is still fresh for url.
*
* @param {string} url
* @param {object} parsedUrl
* @return {boolean}
* @private
*/
function fresh(url, parsedUrl) {
return typeof parsedUrl === 'object' && parsedUrl !== null && (Url === undefined || parsedUrl instanceof Url) && parsedUrl._raw === url;
}
/***/ }),
/***/ 268:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// 集中导出常用方法
module.exports = {
// connect: require('connect'),
serveStatic: __webpack_require__(804)
};
/***/ }),
/***/ 274:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
var path = __webpack_require__(928);
var fs = __webpack_require__(896);
function Mime() {
// Map of extension -> mime type
this.types = Object.create(null);
// Map of mime type -> extension
this.extensions = Object.create(null);
}
/**
* Define mimetype -> extension mappings. Each key is a mime-type that maps
* to an array of extensions associated with the type. The first extension is
* used as the default extension for the type.
*
* e.g. mime.define({'audio/ogg', ['oga', 'ogg', 'spx']});
*
* @param map (Object) type definitions
*/
Mime.prototype.define = function (map) {
for (var type in map) {
var exts = map[type];
for (var i = 0; i < exts.length; i++) {
if (process.env.DEBUG_MIME && this.types[exts[i]]) {
console.warn((this._loading || "define()").replace(/.*\//, ''), 'changes "' + exts[i] + '" extension type from ' + this.types[exts[i]] + ' to ' + type);
}
this.types[exts[i]] = type;
}
// Default extension is the first one we encounter
if (!this.extensions[type]) {
this.extensions[type] = exts[0];
}
}
};
/**
* Load an Apache2-style ".types" file
*
* This may be called multiple times (it's expected). Where files declare
* overlapping types/extensions, the last file wins.
*
* @param file (String) path of file to load.
*/
Mime.prototype.load = function (file) {
this._loading = file;
// Read file and split into lines
var map = {},
content = fs.readFileSync(file, 'ascii'),
lines = content.split(/[\r\n]+/);
lines.forEach(function (line) {
// Clean up whitespace/comments, and split into fields
var fields = line.replace(/\s*#.*|^\s*|\s*$/g, '').split(/\s+/);
map[fields.shift()] = fields;
});
this.define(map);
this._loading = null;
};
/**
* Lookup a mime type based on extension
*/
Mime.prototype.lookup = function (path, fallback) {
var ext = path.replace(/^.*[\.\/\\]/, '').toLowerCase();
return this.types[ext] || fallback || this.default_type;
};
/**
* Return file extension associated with a mime type
*/
Mime.prototype.extension = function (mimeType) {
var type = mimeType.match(/^\s*([^;\s]*)(?:;|\s|$)/)[1].toLowerCase();
return this.extensions[type];
};
// Default instance
var mime = new Mime();
// Define built-in types
mime.define(__webpack_require__(796));
// Default type
mime.default_type = mime.lookup('bin');
//
// Additional API specific to the default instance
//
mime.Mime = Mime;
/**
* Lookup a charset based on mime type.
*/
mime.charsets = {
lookup: function (mimeType, fallback) {
// Assume text types are utf8
return /^text\/|^application\/(javascript|json)/.test(mimeType) ? 'UTF-8' : fallback;
}
};
module.exports = mime;
/***/ }),
/***/ 278:
/***/ ((module) => {
"use strict";
module.exports = require("net");
/***/ }),
/***/ 282:
/***/ ((module) => {
"use strict";
/*!
* toidentifier
* Copyright(c) 2016 Douglas Christopher Wilson
* MIT Licensed
*/
/**
* Module exports.
* @public
*/
module.exports = toIdentifier;
/**
* Trasform the given string into a JavaScript identifier
*
* @param {string} str
* @returns {string}
* @public
*/
function toIdentifier(str) {
return str.split(' ').map(function (token) {
return token.slice(0, 1).toUpperCase() + token.slice(1);
}).join('').replace(/[^ _0-9a-z]/gi, '');
}
/***/ }),
/***/ 289:
/***/ ((module) => {
"use strict";
/*!
* ee-first
* Copyright(c) 2014 Jonathan Ong
* MIT Licensed
*/
/**
* Module exports.
* @public
*/
module.exports = first;
/**
* Get the first event in a set of event emitters and event pairs.
*
* @param {array} stuff
* @param {function} done
* @public
*/
function first(stuff, done) {
if (!Array.isArray(stuff)) throw new TypeError('arg must be an array of [ee, events...] arrays');
var cleanups = [];
for (var i = 0; i < stuff.length; i++) {
var arr = stuff[i];
if (!Array.isArray(arr) || arr.length < 2) throw new TypeError('each array member must be [ee, events...]');
var ee = arr[0];
for (var j = 1; j < arr.length; j++) {
var event = arr[j];
var fn = listener(event, callback);
// listen to the event
ee.on(event, fn);
// push this listener to the list of cleanups
cleanups.push({
ee: ee,
event: event,
fn: fn
});
}
}
function callback() {
cleanup();
done.apply(null, arguments);
}
function cleanup() {
var x;
for (var i = 0; i < cleanups.length; i++) {
x = cleanups[i];
x.ee.removeListener(x.event, x.fn);
}
}
function thunk(fn) {
done = fn;
}
thunk.cancel = cleanup;
return thunk;
}
/**
* Create the event listener.
* @private
*/
function listener(event, done) {
return function onevent(arg1) {
var args = new Array(arguments.length);
var ee = this;
var err = event === 'error' ? arg1 : null;
// copy args to prevent arguments escaping scope
for (var i = 0; i < args.length; i++) {
args[i] = arguments[i];
}
done(err, ee, event, args);
};
}
/***/ }),
/***/ 290:
/***/ ((module) => {
"use strict";
module.exports = require("async_hooks");
/***/ }),
/***/ 365:
/***/ ((module) => {
if (typeof Object.create === 'function') {
// implementation from standard node.js 'util' module
module.exports = function inherits(ctor, superCtor) {
if (superCtor) {
ctor.super_ = superCtor;
ctor.prototype = Object.create(superCtor.prototype, {
constructor: {
value: ctor,
enumerable: false,
writable: true,
configurable: true
}
});
}
};
} else {
// old school shim for old browsers
module.exports = function inherits(ctor, superCtor) {
if (superCtor) {
ctor.super_ = superCtor;
var TempCtor = function () {};
TempCtor.prototype = superCtor.prototype;
ctor.prototype = new TempCtor();
ctor.prototype.constructor = ctor;
}
};
}
/***/ }),
/***/ 404:
/***/ ((module) => {
"use strict";
module.exports = require("util");
/***/ }),
/***/ 415:
/***/ ((module) => {
"use strict";
/*!
* escape-html
* Copyright(c) 2012-2013 TJ Holowaychuk
* Copyright(c) 2015 Andreas Lubbe
* Copyright(c) 2015 Tiancheng "Timothy" Gu
* MIT Licensed
*/
/**
* Module variables.
* @private
*/
var matchHtmlRegExp = /["'&<>]/;
/**
* Module exports.
* @public
*/
module.exports = escapeHtml;
/**
* Escape special characters in the given string of html.
*
* @param {string} string The string to escape for inserting into HTML
* @return {string}
* @public
*/
function escapeHtml(string) {
var str = '' + string;
var match = matchHtmlRegExp.exec(str);
if (!match) {
return str;
}
var escape;
var html = '';
var index = 0;
var lastIndex = 0;
for (index = match.index; index < str.length; index++) {
switch (str.charCodeAt(index)) {
case 34:
// "
escape = '"';
break;
case 38:
// &
escape = '&';
break;
case 39:
// '
escape = ''';
break;
case 60:
// <
escape = '<';
break;
case 62:
// >
escape = '>';
break;
default:
continue;
}
if (lastIndex !== index) {
html += str.substring(lastIndex, index);
}
lastIndex = index + 1;
html += escape;
}
return lastIndex !== index ? html + str.substring(lastIndex, index) : html;
}
/***/ }),
/***/ 420:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
"use strict";
/*!
* on-finished
* Copyright(c) 2013 Jonathan Ong
* Copyright(c) 2014 Douglas Christopher Wilson
* MIT Licensed
*/
/**
* Module exports.
* @public
*/
module.exports = onFinished;
module.exports.isFinished = isFinished;
/**
* Module dependencies.
* @private
*/
var asyncHooks = tryRequireAsyncHooks();
var first = __webpack_require__(289);
/**
* Variables.
* @private
*/
/* istanbul ignore next */
var defer = typeof setImmediate === 'function' ? setImmediate : function (fn) {
process.nextTick(fn.bind.apply(fn, arguments));
};
/**
* Invoke callback when the response has finished, useful for
* cleaning up resources afterwards.
*
* @param {object} msg
* @param {function} listener
* @return {object}
* @public
*/
function onFinished(msg, listener) {
if (isFinished(msg) !== false) {
defer(listener, null, msg);
return msg;
}
// attach the listener to the message
attachListener(msg, wrap(listener));
return msg;
}
/**
* Determine if message is already finished.
*
* @param {object} msg
* @return {boolean}
* @public
*/
function isFinished(msg) {
var socket = msg.socket;
if (typeof msg.finished === 'boolean') {
// OutgoingMessage
return Boolean(msg.finished || socket && !socket.writable);
}
if (typeof msg.complete === 'boolean') {
// IncomingMessage
return Boolean(msg.upgrade || !socket || !socket.readable || msg.complete && !msg.readable);
}
// don't know
return undefined;
}
/**
* Attach a finished listener to the message.
*
* @param {object} msg
* @param {function} callback
* @private
*/
function attachFinishedListener(msg, callback) {
var eeMsg;
var eeSocket;
var finished = false;
function onFinish(error) {
eeMsg.cancel();
eeSocket.cancel();
finished = true;
callback(error);
}
// finished on first message event
eeMsg = eeSocket = first([[msg, 'end', 'finish']], onFinish);
function onSocket(socket) {
// remove listener
msg.removeListener('socket', onSocket);
if (finished) return;
if (eeMsg !== eeSocket) return;
// finished on first socket event
eeSocket = first([[socket, 'error', 'close']], onFinish);
}
if (msg.socket) {
// socket already assigned
onSocket(msg.socket);
return;
}
// wait for socket to be assigned
msg.on('socket', onSocket);
if (msg.socket === undefined) {
// istanbul ignore next: node.js 0.8 patch
patchAssignSocket(msg, onSocket);
}
}
/**
* Attach the listener to the message.
*
* @param {object} msg
* @return {function}
* @private
*/
function attachListener(msg, listener) {
var attached = msg.__onFinished;
// create a private single listener with queue
if (!attached || !attached.queue) {
attached = msg.__onFinished = createListener(msg);
attachFinishedListener(msg, attached);
}
attached.queue.push(listener);
}
/**
* Create listener on message.
*
* @param {object} msg
* @return {function}
* @private
*/
function createListener(msg) {
function listener(err) {
if (msg.__onFinished === listener) msg.__onFinished = null;
if (!listener.queue) return;
var queue = listener.queue;
listener.queue = null;
for (var i = 0; i < queue.length; i++) {
queue[i](err, msg);
}
}
listener.queue = [];
return listener;
}
/**
* Patch ServerResponse.prototype.assignSocket for node.js 0.8.
*
* @param {ServerResponse} res
* @param {function} callback
* @private
*/
// istanbul ignore next: node.js 0.8 patch
function patchAssignSocket(res, callback) {
var assignSocket = res.assignSocket;
if (typeof assignSocket !== 'function') return;
// res.on('socket', callback) is broken in 0.8
res.assignSocket = function _assignSocket(socket) {
assignSocket.call(this, socket);
callback(socket);
};
}
/**
* Try to require async_hooks
* @private
*/
function tryRequireAsyncHooks() {
try {
return __webpack_require__(290);
} catch (e) {
return {};
}
}
/**
* Wrap function with async resource, if possible.
* AsyncResource.bind static method backported.
* @private
*/
function wrap(fn) {
var res;
// create anonymous resource
if (asyncHooks.AsyncResource) {
res = new asyncHooks.AsyncResource(fn.name || 'bound-anonymous-fn');
}
// incompatible node.js
if (!res || !res.runInAsyncScope) {
return fn;
}
// return bound function
return res.runInAsyncScope.bind(res, fn, null);
}
/***/ }),
/***/ 434:
/***/ ((module) => {
"use strict";
module.exports = require("events");
/***/ }),
/***/ 479:
/***/ ((module) => {
"use strict";
/*!
* range-parser
* Copyright(c) 2012-2014 TJ Holowaychuk
* Copyright(c) 2015-2016 Douglas Christopher Wilson
* MIT Licensed
*/
/**
* Module exports.
* @public
*/
module.exports = rangeParser;
/**
* Parse "Range" header `str` relative to the given file `size`.
*
* @param {Number} size
* @param {String} str
* @param {Object} [options]
* @return {Array}
* @public
*/
function rangeParser(size, str, options) {
if (typeof str !== 'string') {
throw new TypeError('argument str must be a string');
}
var index = str.indexOf('=');
if (index === -1) {
return -2;
}
// split the range string
var arr = str.slice(index + 1).split(',');
var ranges = [];
// add ranges type
ranges.type = str.slice(0, index);
// parse all ranges
for (var i = 0; i < arr.length; i++) {
var range = arr[i].split('-');
var start = parseInt(range[0], 10);
var end = parseInt(range[1], 10);
// -nnn
if (isNaN(start)) {
start = size - end;
end = size - 1;
// nnn-
} else if (isNaN(end)) {
end = size - 1;
}
// limit last-byte-pos to current length
if (end > size - 1) {
end = size - 1;
}
// invalid or unsatisifiable
if (isNaN(start) || isNaN(end) || start > end || start < 0) {
continue;
}
// add range
ranges.push({
start: start,
end: end
});
}
if (ranges.length < 1) {
// unsatisifiable
return -1;
}
return options && options.combine ? combineRanges(ranges) : ranges;
}
/**
* Combine overlapping & adjacent ranges.
* @private
*/
function combineRanges(ranges) {
var ordered = ranges.map(mapWithIndex).sort(sortByRangeStart);
for (var j = 0, i = 1; i < ordered.length; i++) {
var range = ordered[i];
var current = ordered[j];
if (range.start > current.end + 1) {
// next range
ordered[++j] = range;
} else if (range.end > current.end) {
// extend range
current.end = range.end;
current.index = Math.min(current.index, range.index);
}
}
// trim ordered array
ordered.length = j + 1;
// generate combined range
var combined = ordered.sort(sortByRangeIndex).map(mapWithoutIndex);
// copy ranges type
combined.type = ranges.type;
return combined;
}
/**
* Map function to add index value to ranges.
* @private
*/
function mapWithIndex(range, index) {
return {
start: range.start,
end: range.end,
index: index
};
}
/**
* Map function to remove index value from ranges.
* @private
*/
function mapWithoutIndex(range) {
return {
start: range.start,
end: range.end
};
}
/**
* Sort function to sort ranges by index.
* @private
*/
function sortByRangeIndex(a, b) {
return a.index - b.index;
}
/**
* Sort function to sort ranges by start position.
* @private
*/
function sortByRangeStart(a, b) {
return a.start - b.start;
}
/***/ }),
/***/ 480:
/***/ ((module) => {
"use strict";
/*!
* fresh
* Copyright(c) 2012 TJ Holowaychuk
* Copyright(c) 2016-2017 Douglas Christopher Wilson
* MIT Licensed
*/
/**
* RegExp to check for no-cache token in Cache-Control.
* @private
*/
var CACHE_CONTROL_NO_CACHE_REGEXP = /(?:^|,)\s*?no-cache\s*?(?:,|$)/;
/**
* Module exports.
* @public
*/
module.exports = fresh;
/**
* Check freshness of the response using request and response headers.
*
* @param {Object} reqHeaders
* @param {Object} resHeaders
* @return {Boolean}
* @public
*/
function fresh(reqHeaders, resHeaders) {
// fields
var modifiedSince = reqHeaders['if-modified-since'];
var noneMatch = reqHeaders['if-none-match'];
// unconditional request
if (!modifiedSince && !noneMatch) {
return false;
}
// Always return stale when Cache-Control: no-cache
// to support end-to-end reload requests
// https://tools.ietf.org/html/rfc2616#section-14.9.4
var cacheControl = reqHeaders['cache-control'];
if (cacheControl && CACHE_CONTROL_NO_CACHE_REGEXP.test(cacheControl)) {
return false;
}
// if-none-match
if (noneMatch && noneMatch !== '*') {
var etag = resHeaders['etag'];
if (!etag) {
return false;
}
var etagStale = true;
var matches = parseTokenList(noneMatch);
for (var i = 0; i < matches.length; i++) {
var match = matches[i];
if (match === etag || match === 'W/' + etag || 'W/' + match === etag) {
etagStale = false;
break;
}
}
if (etagStale) {
return false;
}
}
// if-modified-since
if (modifiedSince) {
var lastModified = resHeaders['last-modified'];
var modifiedStale = !lastModified || !(parseHttpDate(lastModified) <= parseHttpDate(modifiedSince));
if (modifiedStale) {
return false;
}
}
return true;
}
/**
* Parse an HTTP Date into a number.
*
* @param {string} date
* @private
*/
function parseHttpDate(date) {
var timestamp = date && Date.parse(date);
// istanbul ignore next: guard against date.js Date.parse patching
return typeof timestamp === 'number' ? timestamp : NaN;
}
/**
* Parse a HTTP token list.
*
* @param {string} str
* @private
*/
function parseTokenList(str) {
var end = 0;
var list = [];
var start = 0;
// gather tokens
for (var i = 0, len = str.length; i < len; i++) {
switch (str.charCodeAt(i)) {
case 0x20:
/* */
if (start === end) {
start = end = i + 1;
}
break;
case 0x2c:
/* , */
list.push(str.substring(start, end));
start = end = i + 1;
break;
default:
end = i + 1;
break;
}
}
// final token
list.push(str.substring(start, end));
return list;
}
/***/ }),
/***/ 498:
/***/ ((module, exports, __webpack_require__) => {
/**
* Module dependencies.
*/
var tty = __webpack_require__(18);
var util = __webpack_require__(404);
/**
* This is the Node.js implementation of `debug()`.
*
* Expose `debug()` as the module.
*/
exports = module.exports = __webpack_require__(843);
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];
/**
* 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;
}, {});
/**
* The file descriptor to write the `debug()` calls to.
* Set the `DEBUG_FD` env variable to override with another value. i.e.:
*
* $ DEBUG_FD=3 node script.js 3>debug.log
*/
var fd = parseInt(process.env.DEBUG_FD, 10) || 2;
if (1 !== fd && 2 !== fd) {
util.deprecate(function () {}, 'except for stderr(2) and stdout(1), any other usage of DEBUG_FD is deprecated. Override debug.log if you want to use a different log function (https://git.io/debug_fd)')();
}
var stream = 1 === fd ? process.stdout : 2 === fd ? process.stderr : createWritableStdioStream(fd);
/**
* Is stdout a TTY? Colored output is enabled when `true`.
*/
function useColors() {
return 'colors' in exports.inspectOpts ? Boolean(exports.inspectOpts.colors) : tty.isatty(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 prefix = ' \u001b[3' + c + ';1m' + name + ' ' + '\u001b[0m';
args[0] = prefix + args[0].split('\n').join('\n' + prefix);
args.push('\u001b[3' + c + 'm+' + exports.humanize(this.diff) + '\u001b[0m');
} else {
args[0] = new Date().toUTCString() + ' ' + name + ' ' + args[0];
}
}
/**
* Invokes `util.format()` with the specified arguments and writes to `stream`.
*/
function log() {
return stream.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;
}
/**
* Copied from `node/src/node.js`.
*
* XXX: It's lame that node doesn't expose this API out-of-the-box. It also
* relies on the undocumented `tty_wrap.guessHandleType()` which is also lame.
*/
function createWritableStdioStream(fd) {
var stream;
var tty_wrap = process.binding('tty_wrap');
// Note stream._type is used for test-module-load-list.js
switch (tty_wrap.guessHandleType(fd)) {
case 'TTY':
stream = new tty.WriteStream(fd);
stream._type = 'tty';
// Hack to have stream not keep the event loop alive.
// See https://github.com/joyent/node/issues/1726
if (stream._handle && stream._handle.unref) {
stream._handle.unref();
}
break;
case 'FILE':
var fs = __webpack_require__(896);
stream = new fs.SyncWriteStream(fd, {
autoClose: false
});
stream._type = 'fs';
break;
case 'PIPE':
case 'TCP':
var net = __webpack_require__(278);
stream = new net.Socket({
fd: fd,
readable: false,
writable: true
});
// FIXME Should probably have an option in net.Socket to create a
// stream from an existing fd which is writable only. But for now
// we'll just add this hack and set the `readable` member to false.
// Test: ./node test/fixtures/echo.js < /etc/passwd
stream.readable = false;
stream.read = null;
stream._type = 'pipe';
// FIXME Hack to have stream not keep the event loop alive.
// See https://github.com/joyent/node/issues/1726
if (stream._handle && stream._handle.unref) {
stream._handle.unref();
}
break;
default:
// Probably an error on in uv_guess_handle()
throw new Error('Implement me. Unknown stream file type!');
}
// For supporting legacy API we put the FD here.
stream.fd = fd;
stream._isStdio = true;
return stream;
}
/**
* 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 =