UNPKG

truffle

Version:

Truffle - Simple development framework for Ethereum

1,879 lines (1,528 loc) 47.7 kB
#!/usr/bin/env node exports.id = 8834; exports.ids = [8834]; exports.modules = { /***/ 10298: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { const hljs = __webpack_require__(77869) const cheerio = __webpack_require__(52905) const camelCase = __webpack_require__(66653) const chalk = __webpack_require__(55629) const stripAnsi = __webpack_require__(95508) const merge = __webpack_require__(72378) const stripIndent = __webpack_require__(79922) const detectIndent = __webpack_require__(99983) const darkPalette = { addition: chalk.green, attr: chalk.yellow, attribute: chalk.blue, attrString: chalk.cyan, base: chalk.white, builtIn: chalk.blue, builtInName: chalk.blue, bullet: chalk.magenta, class: chalk.green, code: chalk.yellow, comment: chalk.white.dim, deletion: chalk.red, doctag: chalk.blue, emphasis: chalk.magenta, function: chalk.white, formula: chalk.green, keyword: chalk.red, lineNumbers: chalk.grey, literal: chalk.magenta, link: chalk.blue.underline, meta: chalk.cyan, name: chalk.cyan, number: chalk.green, params: chalk.blue, quote: chalk.gray, regexp: chalk.magenta, selectorAttr: chalk.green, selectorClass: chalk.yellow, selectorId: chalk.blue, selectorPseudo: chalk.cyan, selectorTag: chalk.magenta, string: chalk.yellow, strong: chalk.red, subst: chalk.cyan, symbol: chalk.cyan, tag: chalk.blue, templateTag: chalk.magenta, templateVariable: chalk.green, title: chalk.green, trailingSpace: chalk, type: chalk.magenta, variable: chalk.red } const filter = (node, opts) => { let color let text let childText if (node.type === 'text') { text = node.data return text } if (node.name === 'span' && node.type === 'tag') { color = camelCase(node.attribs.class.split('-')[1]) } if (node.childNodes && node.childNodes.length > 0) { childText = node.childNodes.map(childNode => filter(childNode, opts)).join('') if (typeof color === 'string') { return opts.colors[color](childText) } return childText } return '' } const findLongestLine = (text, opts) => { let tabPad = '' if (opts.$indent.tabs) { tabPad = String().padEnd(opts.consoleTabWidth, ' ') } const lines = stripAnsi(text) .replace(/\t/g, tabPad) .split('\n') let max = 0 lines.forEach(line => { if (line.length > max) { max = line.length } }) return max } const padLine = (line, padding) => { const padStr = String().padStart(padding, ' ') return padStr + line + padStr } const getIndentStr = opts => { if (opts.$indent.tabs) { return String().padStart(1, '\t') } // Opts.$indent.spaces === true if (opts.tabsToSpaces === 0) { return '\u0000' } return String().padEnd(opts.tabsToSpaces, ' ') } const syntaxHlStr = (lang, script, opts, indentStart) => { const indentStr = getIndentStr(opts) if (opts.$indent.tabs) { script = script.replace(/\t/g, indentStr) } if (opts.$indent.spaces) { script = script.replace(/\t/g, indentStr) } if (indentStart) { script = indentStr + script } const code = hljs.highlight(lang, script).value const html = `<code>${code}</code>` const $body = cheerio.load(html).root().find('code')[0] const output = filter($body, opts) return output } const syntaxHlJson = (json, opts) => { const indentStr = getIndentStr(opts) try { json = JSON.stringify(json, (key, val) => { if (val instanceof Function) { return `[FUNCTION]${String(val)}[FUNCTION]` } return val }, indentStr) } catch (err) { err.message = '🦅 Chromafi: ' + err.message throw new Error(err) } const highlighted = json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+-]?\d+)?)/g, match => { let colorClass = 'number' // eslint-disable-next-line unicorn/prefer-starts-ends-with if (/^"/.test(match)) { // eslint-disable-next-line unicorn/prefer-starts-ends-with if (/:$/.test(match)) { if (match.includes('-')) { colorClass = 'attrString' match = match.replace(/"/g, '\'') } else { colorClass = 'attr' match = match.replace(/"/g, '') } } else { colorClass = 'string' if (match.substr(1, 10) === '[FUNCTION]' && match.substr(match.length - 11, 10) === '[FUNCTION]') { colorClass = 'function' } else { match = match.replace(/"/g, '\'') match = match.replace(/\\n/g, '\n') match = match.replace(/\\t/g, indentStr) } } } else if (/true|false/.test(match)) { colorClass = 'literal' } else if (/null/.test(match)) { colorClass = 'literal' } return opts.colors[colorClass](match) }) const getFnStrIndent = (fnStr, opts) => { fnStr = fnStr.replace(/\t/g, indentStr) const indent = detectIndent(fnStr) if (opts.$indent.spaces) { const indentLevel = indent.amount / opts.tabsToSpaces return indentLevel } if (opts.$indent.tabs) { const indentLevel = indent.amount return indentLevel } } const lines = highlighted.split('\n').map(line => { const fnParts = line.split('[FUNCTION]') if (fnParts.length === 3) { const plain = stripAnsi(line) let outerIndent if (opts.$indent.spaces) { outerIndent = plain.match(/^[ \\t]*/)[0].length / opts.tabsToSpaces } if (opts.$indent.tabs) { outerIndent = plain.match(/^\t*/)[0].length } const fnStr = fnParts[1] .replace(/"/g, '\'') .replace(/\\n/g, '\n') .replace(/\\t/g, '\t') const innerIndent = getFnStrIndent(fnStr, opts) const indentOffset = Math.abs(outerIndent - (innerIndent - 1)) const re = new RegExp(`\n(\t){${indentOffset}}`, 'g') const reTabbed = fnStr .replace(re, '\n') .replace(/\\t/g, indentStr) const preFn = fnParts[0].substr(0, fnParts[0].length - 1) const postFn = fnParts[2].substr(1) const jsHighlighted = syntaxHlStr('javascript', reTabbed, opts) return preFn + jsHighlighted + postFn } return line }).join('\n') return lines } const lineNumberPad = (number, opts) => { if (!opts.lineNumbers) { return '' } let output = '' const offsetLineN = number + (opts.lineNumberStart - 1) if (opts.$indent.spaces) { const padStr = String().padStart(opts.lineNumberPad, ' ') const prePad = opts.lineNumberPad + opts.$maxDigitWidth output = String(offsetLineN).padStart(prePad) + padStr } // Indent using spaces - up to the tabwidth required to contain number str if (opts.$indent.tabs) { output = String(offsetLineN).padStart(opts.$maxTabSpace, ' ') } return opts.colors.lineNumbers(output) } const cropPadAndNumber = (text, opts) => { let output = '' const lines = text.split('\n') const maxDigitWidth = String(lines.length + (opts.lineNumberStart - 1)).length // Tabs needed to contain digits (so we dont break code tab indentation) const tabsNeeded = Math.ceil(maxDigitWidth / opts.consoleTabWidth) const maxTabSpace = tabsNeeded * opts.consoleTabWidth const longestLineLen = findLongestLine(text, opts) opts.$maxTabSpace = maxTabSpace opts.$maxDigitWidth = maxDigitWidth lines.forEach((line, i) => { const lineNumber = i + 1 if (lineNumber < opts.firstLine || lineNumber > opts.lastLine) { return } const lineNo = lineNumberPad(lineNumber, opts) const tabCount = (line.match(/\t/g) || []).length const tabAdjust = (tabCount * opts.consoleTabWidth) const plain = stripAnsi(line).replace(/\t/g, '') let runLengthLine if (opts.lineEndPad === true) { const linePad = String().padEnd((longestLineLen - plain.length) - tabAdjust, ' ') runLengthLine = line + opts.colors.trailingSpace(linePad) } else { runLengthLine = line } let lineOutput if (opts.tabsToSpaces === false) { lineOutput = lineNo + runLengthLine } if (typeof opts.tabsToSpaces === 'number') { lineOutput = lineNo + padLine(runLengthLine, opts.codePad) } output += lineOutput + '\n' }) return opts.colors.base(output) } const decorate = (ansiStr, opts) => { // AnsiMark has been removed for causing problems. ansiStr = cropPadAndNumber(ansiStr, opts) return ansiStr } const nameifyArrowFn = (fn, opts) => { if (Reflect.has(fn, 'prototype') && Reflect.has(fn.prototype, 'constructor')) { return '' } return `${opts.arrowKeyword} ${fn.name} = ` } const procOpts = (opts = {}) => { let options = { lineNumbers: true, lang: 'javascript', lineNumberPad: 0, lineNumberStart: 1, start: 1, end: Infinity, stripIndent: true, codePad: 1, colors: darkPalette, tabsToSpaces: 4, consoleTabWidth: 8, arrowKeyword: 'const', lineEndPad: true } options = merge(options, opts) options.$indent = { spaces: typeof options.tabsToSpaces === 'number', tabs: typeof options.tabsToSpaces === 'boolean' && options.tabsToSpaces === false, size: typeof options.tabsToSpaces === 'number' ? options.tabsToSpaces : 1 } return options } const chromafi = (value, opts) => { opts = procOpts(opts) if (typeof value === 'function') { value = nameifyArrowFn(value, opts) + String(value) const indentStart = true value = syntaxHlStr('javascript', value, opts, indentStart) value = stripIndent(value) value = decorate(value, opts) return value } if (typeof value === 'string') { value = syntaxHlStr(opts.lang, value, opts) value = decorate(value, opts) return value } if (typeof value === 'object') { value = syntaxHlJson(value, opts) value = decorate(value, opts) return value } throw new Error('🦅 Chromafi: You must pass a function, string or object.') } chromafi.hljs = hljs // Expose hljs for modification module.exports = chromafi /***/ }), /***/ 96834: /***/ ((module) => { "use strict"; module.exports = () => { const pattern = [ '[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[a-zA-Z\\d]*)*)?\\u0007)', '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))' ].join('|'); return new RegExp(pattern, 'g'); }; /***/ }), /***/ 66653: /***/ ((module) => { "use strict"; function preserveCamelCase(str) { let isLastCharLower = false; let isLastCharUpper = false; let isLastLastCharUpper = false; for (let i = 0; i < str.length; i++) { const c = str[i]; if (isLastCharLower && /[a-zA-Z]/.test(c) && c.toUpperCase() === c) { str = str.substr(0, i) + '-' + str.substr(i); isLastCharLower = false; isLastLastCharUpper = isLastCharUpper; isLastCharUpper = true; i++; } else if (isLastCharUpper && isLastLastCharUpper && /[a-zA-Z]/.test(c) && c.toLowerCase() === c) { str = str.substr(0, i - 1) + '-' + str.substr(i - 1); isLastLastCharUpper = isLastCharUpper; isLastCharUpper = false; isLastCharLower = true; } else { isLastCharLower = c.toLowerCase() === c; isLastLastCharUpper = isLastCharUpper; isLastCharUpper = c.toUpperCase() === c; } } return str; } module.exports = function (str) { if (arguments.length > 1) { str = Array.from(arguments) .map(x => x.trim()) .filter(x => x.length) .join('-'); } else { str = str.trim(); } if (str.length === 0) { return ''; } if (str.length === 1) { return str.toLowerCase(); } if (/^[a-z0-9]+$/.test(str)) { return str; } const hasUpperCase = str !== str.toLowerCase(); if (hasUpperCase) { str = preserveCamelCase(str); } return str .replace(/^[_.\- ]+/, '') .toLowerCase() .replace(/[_.\- ]+(\w|$)/g, (m, p1) => p1.toUpperCase()); }; /***/ }), /***/ 55629: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { "use strict"; const escapeStringRegexp = __webpack_require__(71915); const ansiStyles = __webpack_require__(26434); const stdoutColor = (__webpack_require__(81593).stdout); const template = __webpack_require__(63233); const isSimpleWindowsTerm = process.platform === 'win32' && !(process.env.TERM || '').toLowerCase().startsWith('xterm'); // `supportsColor.level` → `ansiStyles.color[name]` mapping const levelMapping = ['ansi', 'ansi', 'ansi256', 'ansi16m']; // `color-convert` models to exclude from the Chalk API due to conflicts and such const skipModels = new Set(['gray']); const styles = Object.create(null); function applyOptions(obj, options) { options = options || {}; // Detect level if not set manually const scLevel = stdoutColor ? stdoutColor.level : 0; obj.level = options.level === undefined ? scLevel : options.level; obj.enabled = 'enabled' in options ? options.enabled : obj.level > 0; } function Chalk(options) { // We check for this.template here since calling `chalk.constructor()` // by itself will have a `this` of a previously constructed chalk object if (!this || !(this instanceof Chalk) || this.template) { const chalk = {}; applyOptions(chalk, options); chalk.template = function () { const args = [].slice.call(arguments); return chalkTag.apply(null, [chalk.template].concat(args)); }; Object.setPrototypeOf(chalk, Chalk.prototype); Object.setPrototypeOf(chalk.template, chalk); chalk.template.constructor = Chalk; return chalk.template; } applyOptions(this, options); } // Use bright blue on Windows as the normal blue color is illegible if (isSimpleWindowsTerm) { ansiStyles.blue.open = '\u001B[94m'; } for (const key of Object.keys(ansiStyles)) { ansiStyles[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles[key].close), 'g'); styles[key] = { get() { const codes = ansiStyles[key]; return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, key); } }; } styles.visible = { get() { return build.call(this, this._styles || [], true, 'visible'); } }; ansiStyles.color.closeRe = new RegExp(escapeStringRegexp(ansiStyles.color.close), 'g'); for (const model of Object.keys(ansiStyles.color.ansi)) { if (skipModels.has(model)) { continue; } styles[model] = { get() { const level = this.level; return function () { const open = ansiStyles.color[levelMapping[level]][model].apply(null, arguments); const codes = { open, close: ansiStyles.color.close, closeRe: ansiStyles.color.closeRe }; return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model); }; } }; } ansiStyles.bgColor.closeRe = new RegExp(escapeStringRegexp(ansiStyles.bgColor.close), 'g'); for (const model of Object.keys(ansiStyles.bgColor.ansi)) { if (skipModels.has(model)) { continue; } const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1); styles[bgModel] = { get() { const level = this.level; return function () { const open = ansiStyles.bgColor[levelMapping[level]][model].apply(null, arguments); const codes = { open, close: ansiStyles.bgColor.close, closeRe: ansiStyles.bgColor.closeRe }; return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model); }; } }; } const proto = Object.defineProperties(() => {}, styles); function build(_styles, _empty, key) { const builder = function () { return applyStyle.apply(builder, arguments); }; builder._styles = _styles; builder._empty = _empty; const self = this; Object.defineProperty(builder, 'level', { enumerable: true, get() { return self.level; }, set(level) { self.level = level; } }); Object.defineProperty(builder, 'enabled', { enumerable: true, get() { return self.enabled; }, set(enabled) { self.enabled = enabled; } }); // See below for fix regarding invisible grey/dim combination on Windows builder.hasGrey = this.hasGrey || key === 'gray' || key === 'grey'; // `__proto__` is used because we must return a function, but there is // no way to create a function with a different prototype builder.__proto__ = proto; // eslint-disable-line no-proto return builder; } function applyStyle() { // Support varags, but simply cast to string in case there's only one arg const args = arguments; const argsLen = args.length; let str = String(arguments[0]); if (argsLen === 0) { return ''; } if (argsLen > 1) { // Don't slice `arguments`, it prevents V8 optimizations for (let a = 1; a < argsLen; a++) { str += ' ' + args[a]; } } if (!this.enabled || this.level <= 0 || !str) { return this._empty ? '' : str; } // Turns out that on Windows dimmed gray text becomes invisible in cmd.exe, // see https://github.com/chalk/chalk/issues/58 // If we're on Windows and we're dealing with a gray color, temporarily make 'dim' a noop. const originalDim = ansiStyles.dim.open; if (isSimpleWindowsTerm && this.hasGrey) { ansiStyles.dim.open = ''; } for (const code of this._styles.slice().reverse()) { // Replace any instances already present with a re-opening code // otherwise only the part of the string until said closing code // will be colored, and the rest will simply be 'plain'. str = code.open + str.replace(code.closeRe, code.open) + code.close; // Close the styling before a linebreak and reopen // after next line to fix a bleed issue on macOS // https://github.com/chalk/chalk/pull/92 str = str.replace(/\r?\n/g, `${code.close}$&${code.open}`); } // Reset the original `dim` if we changed it to work around the Windows dimmed gray issue ansiStyles.dim.open = originalDim; return str; } function chalkTag(chalk, strings) { if (!Array.isArray(strings)) { // If chalk() was called by itself or with a string, // return the string itself as a string. return [].slice.call(arguments, 1).join(' '); } const args = [].slice.call(arguments, 2); const parts = [strings.raw[0]]; for (let i = 1; i < strings.length; i++) { parts.push(String(args[i - 1]).replace(/[{}\\]/g, '\\$&')); parts.push(String(strings.raw[i])); } return template(chalk, parts.join('')); } Object.defineProperties(Chalk.prototype, styles); module.exports = Chalk(); // eslint-disable-line new-cap module.exports.supportsColor = stdoutColor; module.exports["default"] = module.exports; // For TypeScript /***/ }), /***/ 63233: /***/ ((module) => { "use strict"; const TEMPLATE_REGEX = /(?:\\(u[a-f\d]{4}|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi; const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g; const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/; const ESCAPE_REGEX = /\\(u[a-f\d]{4}|x[a-f\d]{2}|.)|([^\\])/gi; const ESCAPES = new Map([ ['n', '\n'], ['r', '\r'], ['t', '\t'], ['b', '\b'], ['f', '\f'], ['v', '\v'], ['0', '\0'], ['\\', '\\'], ['e', '\u001B'], ['a', '\u0007'] ]); function unescape(c) { if ((c[0] === 'u' && c.length === 5) || (c[0] === 'x' && c.length === 3)) { return String.fromCharCode(parseInt(c.slice(1), 16)); } return ESCAPES.get(c) || c; } function parseArguments(name, args) { const results = []; const chunks = args.trim().split(/\s*,\s*/g); let matches; for (const chunk of chunks) { if (!isNaN(chunk)) { results.push(Number(chunk)); } else if ((matches = chunk.match(STRING_REGEX))) { results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, chr) => escape ? unescape(escape) : chr)); } else { throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`); } } return results; } function parseStyle(style) { STYLE_REGEX.lastIndex = 0; const results = []; let matches; while ((matches = STYLE_REGEX.exec(style)) !== null) { const name = matches[1]; if (matches[2]) { const args = parseArguments(name, matches[2]); results.push([name].concat(args)); } else { results.push([name]); } } return results; } function buildStyle(chalk, styles) { const enabled = {}; for (const layer of styles) { for (const style of layer.styles) { enabled[style[0]] = layer.inverse ? null : style.slice(1); } } let current = chalk; for (const styleName of Object.keys(enabled)) { if (Array.isArray(enabled[styleName])) { if (!(styleName in current)) { throw new Error(`Unknown Chalk style: ${styleName}`); } if (enabled[styleName].length > 0) { current = current[styleName].apply(current, enabled[styleName]); } else { current = current[styleName]; } } } return current; } module.exports = (chalk, tmp) => { const styles = []; const chunks = []; let chunk = []; // eslint-disable-next-line max-params tmp.replace(TEMPLATE_REGEX, (m, escapeChar, inverse, style, close, chr) => { if (escapeChar) { chunk.push(unescape(escapeChar)); } else if (style) { const str = chunk.join(''); chunk = []; chunks.push(styles.length === 0 ? str : buildStyle(chalk, styles)(str)); styles.push({inverse, styles: parseStyle(style)}); } else if (close) { if (styles.length === 0) { throw new Error('Found extraneous } in Chalk template literal'); } chunks.push(buildStyle(chalk, styles)(chunk.join(''))); chunk = []; styles.pop(); } else { chunk.push(chr); } }); chunks.push(chunk.join('')); if (styles.length > 0) { const errMsg = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`; throw new Error(errMsg); } return chunks.join(''); }; /***/ }), /***/ 71915: /***/ ((module) => { "use strict"; var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g; module.exports = function (str) { if (typeof str !== 'string') { throw new TypeError('Expected a string'); } return str.replace(matchOperatorsRe, '\\$&'); }; /***/ }), /***/ 44358: /***/ ((module) => { "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); }; /***/ }), /***/ 95508: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { "use strict"; const ansiRegex = __webpack_require__(96834); module.exports = input => typeof input === 'string' ? input.replace(ansiRegex(), '') : input; /***/ }), /***/ 81593: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { "use strict"; const os = __webpack_require__(22037); const hasFlag = __webpack_require__(44358); const env = process.env; let forceColor; if (hasFlag('no-color') || hasFlag('no-colors') || hasFlag('color=false')) { forceColor = false; } else if (hasFlag('color') || hasFlag('colors') || hasFlag('color=true') || hasFlag('color=always')) { forceColor = true; } if ('FORCE_COLOR' in env) { forceColor = env.FORCE_COLOR.length === 0 || parseInt(env.FORCE_COLOR, 10) !== 0; } function translateLevel(level) { if (level === 0) { return false; } return { level, hasBasic: true, has256: level >= 2, has16m: level >= 3 }; } function supportsColor(stream) { if (forceColor === false) { 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 !== true) { return 0; } const min = forceColor ? 1 : 0; 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; } if (env.TERM === 'dumb') { return min; } return min; } function getSupportLevel(stream) { const level = supportsColor(stream); return translateLevel(level); } module.exports = { supportsColor: getSupportLevel, stdout: getSupportLevel(process.stdout), stderr: getSupportLevel(process.stderr) }; /***/ }), /***/ 79785: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { "use strict"; var Buffer = (__webpack_require__(14300).Buffer) var inherits = __webpack_require__(94378) var HashBase = __webpack_require__(3349) var ARRAY16 = new Array(16) var zl = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8, 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12, 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2, 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13 ] var zr = [ 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12, 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2, 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13, 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14, 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11 ] var sl = [ 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8, 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12, 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5, 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12, 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6 ] var sr = [ 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6, 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11, 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5, 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8, 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11 ] var hl = [0x00000000, 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xa953fd4e] var hr = [0x50a28be6, 0x5c4dd124, 0x6d703ef3, 0x7a6d76e9, 0x00000000] function RIPEMD160 () { HashBase.call(this, 64) // state this._a = 0x67452301 this._b = 0xefcdab89 this._c = 0x98badcfe this._d = 0x10325476 this._e = 0xc3d2e1f0 } inherits(RIPEMD160, HashBase) RIPEMD160.prototype._update = function () { var words = ARRAY16 for (var j = 0; j < 16; ++j) words[j] = this._block.readInt32LE(j * 4) var al = this._a | 0 var bl = this._b | 0 var cl = this._c | 0 var dl = this._d | 0 var el = this._e | 0 var ar = this._a | 0 var br = this._b | 0 var cr = this._c | 0 var dr = this._d | 0 var er = this._e | 0 // computation for (var i = 0; i < 80; i += 1) { var tl var tr if (i < 16) { tl = fn1(al, bl, cl, dl, el, words[zl[i]], hl[0], sl[i]) tr = fn5(ar, br, cr, dr, er, words[zr[i]], hr[0], sr[i]) } else if (i < 32) { tl = fn2(al, bl, cl, dl, el, words[zl[i]], hl[1], sl[i]) tr = fn4(ar, br, cr, dr, er, words[zr[i]], hr[1], sr[i]) } else if (i < 48) { tl = fn3(al, bl, cl, dl, el, words[zl[i]], hl[2], sl[i]) tr = fn3(ar, br, cr, dr, er, words[zr[i]], hr[2], sr[i]) } else if (i < 64) { tl = fn4(al, bl, cl, dl, el, words[zl[i]], hl[3], sl[i]) tr = fn2(ar, br, cr, dr, er, words[zr[i]], hr[3], sr[i]) } else { // if (i<80) { tl = fn5(al, bl, cl, dl, el, words[zl[i]], hl[4], sl[i]) tr = fn1(ar, br, cr, dr, er, words[zr[i]], hr[4], sr[i]) } al = el el = dl dl = rotl(cl, 10) cl = bl bl = tl ar = er er = dr dr = rotl(cr, 10) cr = br br = tr } // update state var t = (this._b + cl + dr) | 0 this._b = (this._c + dl + er) | 0 this._c = (this._d + el + ar) | 0 this._d = (this._e + al + br) | 0 this._e = (this._a + bl + cr) | 0 this._a = t } RIPEMD160.prototype._digest = function () { // create padding and handle blocks this._block[this._blockOffset++] = 0x80 if (this._blockOffset > 56) { this._block.fill(0, this._blockOffset, 64) this._update() this._blockOffset = 0 } this._block.fill(0, this._blockOffset, 56) this._block.writeUInt32LE(this._length[0], 56) this._block.writeUInt32LE(this._length[1], 60) this._update() // produce result var buffer = Buffer.alloc ? Buffer.alloc(20) : new Buffer(20) buffer.writeInt32LE(this._a, 0) buffer.writeInt32LE(this._b, 4) buffer.writeInt32LE(this._c, 8) buffer.writeInt32LE(this._d, 12) buffer.writeInt32LE(this._e, 16) return buffer } function rotl (x, n) { return (x << n) | (x >>> (32 - n)) } function fn1 (a, b, c, d, e, m, k, s) { return (rotl((a + (b ^ c ^ d) + m + k) | 0, s) + e) | 0 } function fn2 (a, b, c, d, e, m, k, s) { return (rotl((a + ((b & c) | ((~b) & d)) + m + k) | 0, s) + e) | 0 } function fn3 (a, b, c, d, e, m, k, s) { return (rotl((a + ((b | (~c)) ^ d) + m + k) | 0, s) + e) | 0 } function fn4 (a, b, c, d, e, m, k, s) { return (rotl((a + ((b & d) | (c & (~d))) + m + k) | 0, s) + e) | 0 } function fn5 (a, b, c, d, e, m, k, s) { return (rotl((a + (b ^ (c | (~d))) + m + k) | 0, s) + e) | 0 } module.exports = RIPEMD160 /***/ }), /***/ 79922: /***/ ((module) => { "use strict"; module.exports = str => { const match = str.match(/^[ \t]*(?=\S)/gm); if (!match) { return str; } // TODO: use spread operator when targeting Node.js 6 const indent = Math.min.apply(Math, match.map(x => x.length)); // eslint-disable-line const re = new RegExp(`^[ \\t]{${indent}}`, 'gm'); return indent > 0 ? str.replace(re, '') : str; }; /***/ }), /***/ 84844: /***/ ((__unused_webpack_module, exports, __webpack_require__) => { /** * Wrapper for built-in http.js to emulate the browser XMLHttpRequest object. * * This can be used with JS designed for browsers to improve reuse of code and * allow the use of existing libraries. * * Usage: include("XMLHttpRequest.js") and use XMLHttpRequest per W3C specs. * * @author Dan DeFelippi <dan@driverdan.com> * @contributor David Ellis <d.f.ellis@ieee.org> * @license MIT */ var Url = __webpack_require__(57310); var spawn = (__webpack_require__(32081).spawn); var fs = __webpack_require__(57147); exports.XMLHttpRequest = function() { "use strict"; /** * Private variables */ var self = this; var http = __webpack_require__(13685); var https = __webpack_require__(95687); // Holds http.js objects var request; var response; // Request settings var settings = {}; // Disable header blacklist. // Not part of XHR specs. var disableHeaderCheck = false; // Set some default headers var defaultHeaders = { "User-Agent": "node-XMLHttpRequest", "Accept": "*/*", }; var headers = {}; var headersCase = {}; // These headers are not user setable. // The following are allowed but banned in the spec: // * user-agent var forbiddenRequestHeaders = [ "accept-charset", "accept-encoding", "access-control-request-headers", "access-control-request-method", "connection", "content-length", "content-transfer-encoding", "cookie", "cookie2", "date", "expect", "host", "keep-alive", "origin", "referer", "te", "trailer", "transfer-encoding", "upgrade", "via" ]; // These request methods are not allowed var forbiddenRequestMethods = [ "TRACE", "TRACK", "CONNECT" ]; // Send flag var sendFlag = false; // Error flag, used when errors occur or abort is called var errorFlag = false; // Event listeners var listeners = {}; /** * Constants */ this.UNSENT = 0; this.OPENED = 1; this.HEADERS_RECEIVED = 2; this.LOADING = 3; this.DONE = 4; /** * Public vars */ // Current state this.readyState = this.UNSENT; // default ready state change handler in case one is not set or is set late this.onreadystatechange = null; // Result & response this.responseText = ""; this.responseXML = ""; this.status = null; this.statusText = null; // Whether cross-site Access-Control requests should be made using // credentials such as cookies or authorization headers this.withCredentials = false; /** * Private methods */ /** * Check if the specified header is allowed. * * @param string header Header to validate * @return boolean False if not allowed, otherwise true */ var isAllowedHttpHeader = function(header) { return disableHeaderCheck || (header && forbiddenRequestHeaders.indexOf(header.toLowerCase()) === -1); }; /** * Check if the specified method is allowed. * * @param string method Request method to validate * @return boolean False if not allowed, otherwise true */ var isAllowedHttpMethod = function(method) { return (method && forbiddenRequestMethods.indexOf(method) === -1); }; /** * Public methods */ /** * Open the connection. Currently supports local server requests. * * @param string method Connection method (eg GET, POST) * @param string url URL for the connection. * @param boolean async Asynchronous connection. Default is true. * @param string user Username for basic authentication (optional) * @param string password Password for basic authentication (optional) */ this.open = function(method, url, async, user, password) { this.abort(); errorFlag = false; // Check for valid request method if (!isAllowedHttpMethod(method)) { throw new Error("SecurityError: Request method not allowed"); } settings = { "method": method, "url": url.toString(), "async": (typeof async !== "boolean" ? true : async), "user": user || null, "password": password || null }; setState(this.OPENED); }; /** * Disables or enables isAllowedHttpHeader() check the request. Enabled by default. * This does not conform to the W3C spec. * * @param boolean state Enable or disable header checking. */ this.setDisableHeaderCheck = function(state) { disableHeaderCheck = state; }; /** * Sets a header for the request or appends the value if one is already set. * * @param string header Header name * @param string value Header value */ this.setRequestHeader = function(header, value) { if (this.readyState !== this.OPENED) { throw new Error("INVALID_STATE_ERR: setRequestHeader can only be called when state is OPEN"); } if (!isAllowedHttpHeader(header)) { console.warn("Refused to set unsafe header \"" + header + "\""); return; } if (sendFlag) { throw new Error("INVALID_STATE_ERR: send flag is true"); } header = headersCase[header.toLowerCase()] || header; headersCase[header.toLowerCase()] = header; headers[header] = headers[header] ? headers[header] + ', ' + value : value; }; /** * Gets a header from the server response. * * @param string header Name of header to get. * @return string Text of the header or null if it doesn't exist. */ this.getResponseHeader = function(header) { if (typeof header === "string" && this.readyState > this.OPENED && response && response.headers && response.headers[header.toLowerCase()] && !errorFlag ) { return response.headers[header.toLowerCase()]; } return null; }; /** * Gets all the response headers. * * @return string A string with all response headers separated by CR+LF */ this.getAllResponseHeaders = function() { if (this.readyState < this.HEADERS_RECEIVED || errorFlag) { return ""; } var result = ""; for (var i in response.headers) { // Cookie headers are excluded if (i !== "set-cookie" && i !== "set-cookie2") { result += i + ": " + response.headers[i] + "\r\n"; } } return result.substr(0, result.length - 2); }; /** * Gets a request header * * @param string name Name of header to get * @return string Returns the request header or empty string if not set */ this.getRequestHeader = function(name) { if (typeof name === "string" && headersCase[name.toLowerCase()]) { return headers[headersCase[name.toLowerCase()]]; } return ""; }; /** * Sends the request to the server. * * @param string data Optional data to send as request body. */ this.send = function(data) { if (this.readyState !== this.OPENED) { throw new Error("INVALID_STATE_ERR: connection must be opened before send() is called"); } if (sendFlag) { throw new Error("INVALID_STATE_ERR: send has already been called"); } var ssl = false, local = false; var url = Url.parse(settings.url); var host; // Determine the server switch (url.protocol) { case "https:": ssl = true; // SSL & non-SSL both need host, no break here. case "http:": host = url.hostname; break; case "file:": local = true; break; case undefined: case null: case "": host = "localhost"; break; default: throw new Error("Protocol not supported."); } // Load files off the local filesystem (file://) if (local) { if (settings.method !== "GET") { throw new Error("XMLHttpRequest: Only GET method is supported"); } if (settings.async) { fs.readFile(url.pathname, "utf8", function(error, data) { if (error) { self.handleError(error); } else { self.status = 200; self.responseText = data; setState(self.DONE); } }); } else { try { this.responseText = fs.readFileSync(url.pathname, "utf8"); this.status = 200; setState(self.DONE); } catch(e) { this.handleError(e); } } return; } // Default to port 80. If accessing localhost on another port be sure // to use http://localhost:port/path var port = url.port || (ssl ? 443 : 80); // Add query string if one is used var uri = url.pathname + (url.search ? url.search : ""); // Set the defaults if they haven't been set for (var name in defaultHeaders) { if (!headersCase[name.toLowerCase()]) { headers[name] = defaultHeaders[name]; } } // Set the Host header or the server may reject the request headers.Host = host; if (!((ssl && port === 443) || port === 80)) { headers.Host += ":" + url.port; } // Set Basic Auth if necessary if (settings.user) { if (typeof settings.password === "undefined") { settings.password = ""; } var authBuf = new Buffer(settings.user + ":" + settings.password); headers.Authorization = "Basic " + authBuf.toString("base64"); } // Set content length header if (settings.method === "GET" || settings.method === "HEAD") { data = null; } else if (data) { headers["Content-Length"] = Buffer.isBuffer(data) ? data.length : Buffer.byteLength(data); if (!headers["Content-Type"]) { headers["Content-Type"] = "text/plain;charset=UTF-8"; } } else if (settings.method === "POST") { // For a post with no data set Content-Length: 0. // This is required by buggy servers that don't meet the specs. headers["Content-Length"] = 0; } var options = { host: host, port: port, path: uri, method: settings.method, headers: headers, agent: false, withCredentials: self.withCredentials }; // Reset error flag errorFlag = false; // Handle async requests if (settings.async) { // Use the proper protocol var doRequest = ssl ? https.request : http.request; // Request is being sent, set send flag sendFlag = true; // As per spec, this is called here for historical reasons. self.dispatchEvent("readystatechange"); // Handler for the response var responseHandler = function responseHandler(resp) { // Set response var to the response we got back // This is so it remains accessable outside this scope response = resp; // Check for redirect // @TODO Prevent looped redirects if (response.statusCode === 301 || response.statusCode === 302 || response.statusCode === 303 || response.statusCode === 307) { // Change URL to the redirect location settings.url = response.headers.location; var url = Url.parse(settings.url); // Set host var in case it's used later host = url.hostname; // Options for the new request var newOptions = { hostname: url.hostname, port: url.port, path: url.path, method: response.statusCode === 303 ? "GET" : settings.method, headers: headers, withCredentials: self.withCredentials }; // Issue the new request request = doRequest(newOptions, responseHandler).on("error", errorHandler); request.end(); // @TODO Check if an XHR event needs to be fired here return; } response.setEncoding("utf8"); setState(self.HEADERS_RECEIVED); self.status = response.statusCode; response.on("data", function(chunk) { // Make sure there's some data if (chunk) { self.responseText += chunk; } // Don't emit state changes if the connection has been aborted. if (sendFlag) { setState(self.LOADING); } }); response.on("end", function() { if (sendFlag) { // Discard the end event if the connection has been aborted setState(self.DONE); sendFlag = false; } }); response.on("error", function(error) { self.handleError(error); }); }; // Error handler for the request var errorHandler = function errorHandler(error) { self.handleError(error); }; // Create the request request = doRequest(options, responseHandler).on("error", errorHandler); // Node 0.4 and later won't accept empty data. Make sure it's needed. if (data) { request.write(data); } request.end(); self.dispatchEvent("loadstart"); } else { // Synchronous // Create a temporary file for communication with the other Node process var contentFile = ".node-xmlhttprequest-content-" + process.pid; var syncFile = ".node-xmlhttprequest-sync-" + process.pid; fs.writeFileSync(syncFile, "", "utf8"); // The async request the other Node process executes var execString = "var http = require('http'), https = require('https'), fs = require('fs');" + "var doRequest = http" + (ssl ? "s" : "") + ".request;" + "var options = " + JSON.stringify(options) + ";" + "var responseText = '';" + "var req = doRequest(options, function(response) {" + "response.setEncoding('utf8');" + "response.on('data', function(chunk) {" + " responseText += chunk;" + "});" + "response.on('end', function() {" + "fs.writeFileSync('" + contentFile + "', JSON.stringify({err: null, data: {statusCode: response.statusCode, headers: response.headers, text: responseText}}), 'utf8');" + "fs.unlinkSync('" + syncFile + "');" + "});" + "response.on('error', function(error) {" + "fs.writeFileSync('" + contentFile + "', JSON.stringify({err: error}), 'utf8');" + "fs.unlinkSync('" + syncFile + "');" + "});" + "}).on('error', function(error) {" + "fs.writeFileSync('" + contentFile + "', JSON.stringify({err: error}), 'utf8');" + "fs.unlinkSync('" + syncFile + "');" + "});" + (data ? "req.write('" + JSON.stringify(data).slice(1,-1).replace(/'/g, "\\'") + "');":"") + "req.end();"; // Start the other Node Process, executing this string var syncProc = spawn(process.argv[0], ["-e", execString]); while(fs.existsSync(syncFile)) { // Wait while the sync file is empty } var resp = JSON.parse(fs.readFileSync(contentFile, 'utf8')); // Kill the child process once the file has data syncProc.stdin.end(); // Remove the temporary file fs.unlinkSync(contentFile); if (resp.err) { self.handleError(resp.err); } else { response = resp.data; self.status = resp.data.statusCode; self.responseText = resp.data.text; setState(self.DONE); } } }; /** * Called when an error is encountered to deal with it. */ this.handleError = function(error) { this.status = 0; this.statusText = error; this.responseText = error.stack; errorFlag = true; setState(this.DONE); this.dispatchEvent('error'); }; /** * Aborts a request. */ this.abort = function() { if (request) { request.abort(); request = null; } headers = defaultHeaders; this.status = 0; this.responseText = ""; this.responseXML = ""; errorFlag = true; if (this.readyState !== this.UNSENT && (this.readyState !== this.OPENED || sendFlag) && this.readyState !== this.DONE) { sendFlag = false; setState(this.DONE); } this.readyState = this.UNSENT; this.dispatchEvent('abort'); }; /** * Adds an event listener. Preferred method of binding to events. */ this.addEventListener = function(event, callback) { if (!(event in listeners)) { listeners[event] = []; } // Currently allows duplicate callbacks. Should it? listeners[event].push(callback); }; /** * Remove an event callback that has already been bound. * Only works on the matching funciton, cannot be a copy. */ this.removeEventListener = function(event, callback) { if (event in listeners) { // Filter will return a new array with the callback removed listeners[event] = listeners[event].filter(function(ev) { return ev !== callback; }); } }; /** * Dispatch any events, including both "on" methods and events attached using addEventListener. */ this.dispatchEvent = function(event) { if (typeof self["on" + event] === "function") { self["on" + event](); } if (event in listeners) { for (var i = 0, len = listeners[event].length; i < len; i++) { listeners[event][i].call(self); } } }; /** * Changes readyState and calls onreadystatechange. * * @param int state New state */ var setState = function(state) { if (state == self.LOADING || self.readyState !== state) { self.readyState = state; if (settings.async || self.readyState < self.OPENED || self.readyState === self.DONE) { self.dispatchEvent("readystatechange"); } if (self.readyState === self.DONE && !errorFlag) { self.dispatchEvent("load"); // @TODO figure out InspectorInstrumentation::didLoadXHR(cookie) self.dispatchEvent("loadend"); } } }; }; /***/ }) }; ; //# sourceMappingURL=8834.bundled.js.map