import require$$0 from 'events'; import require$$0$2 from 'crypto'; import require$$1 from 'tty'; import require$$1$1 from 'util'; import require$$2 from 'os'; import require$$1$2 from 'fs'; import require$$0$1 from 'stream'; import require$$4 from 'url'; import require$$1$3 from 'string_decoder'; import require$$0$3 from 'constants'; import require$$5 from 'assert'; import require$$1$4 from 'path'; import require$$1$6 from 'child_process'; import require$$1$5 from 'electron'; import require$$15 from 'zlib'; import require$$4$1 from 'http'; var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; function getDefaultExportFromCjs (x) { return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; } var main$2 = {}; var out = {}; var CancellationToken$1 = {}; Object.defineProperty(CancellationToken$1, "__esModule", { value: true }); CancellationToken$1.CancellationError = CancellationToken$1.CancellationToken = void 0; const events_1 = require$$0; class CancellationToken extends events_1.EventEmitter { get cancelled() { return this._cancelled || (this._parent != null && this._parent.cancelled); } set parent(value) { this.removeParentCancelHandler(); this._parent = value; this.parentCancelHandler = () => this.cancel(); this._parent.onCancel(this.parentCancelHandler); } // babel cannot compile ... correctly for super calls constructor(parent) { super(); this.parentCancelHandler = null; this._parent = null; this._cancelled = false; if (parent != null) { this.parent = parent; } } cancel() { this._cancelled = true; this.emit("cancel"); } onCancel(handler) { if (this.cancelled) { handler(); } else { this.once("cancel", handler); } } createPromise(callback) { if (this.cancelled) { return Promise.reject(new CancellationError()); } const finallyHandler = () => { if (cancelHandler != null) { try { this.removeListener("cancel", cancelHandler); cancelHandler = null; } catch (ignore) { // ignore } } }; let cancelHandler = null; return new Promise((resolve, reject) => { let addedCancelHandler = null; cancelHandler = () => { try { if (addedCancelHandler != null) { addedCancelHandler(); addedCancelHandler = null; } } finally { reject(new CancellationError()); } }; if (this.cancelled) { cancelHandler(); return; } this.onCancel(cancelHandler); callback(resolve, reject, (callback) => { addedCancelHandler = callback; }); }) .then(it => { finallyHandler(); return it; }) .catch((e) => { finallyHandler(); throw e; }); } removeParentCancelHandler() { const parent = this._parent; if (parent != null && this.parentCancelHandler != null) { parent.removeListener("cancel", this.parentCancelHandler); this.parentCancelHandler = null; } } dispose() { try { this.removeParentCancelHandler(); } finally { this.removeAllListeners(); this._parent = null; } } } CancellationToken$1.CancellationToken = CancellationToken; class CancellationError extends Error { constructor() { super("cancelled"); } } CancellationToken$1.CancellationError = CancellationError; var httpExecutor = {}; var src = {exports: {}}; var browser = {exports: {}}; /** * Helpers. */ var ms; var hasRequiredMs; function requireMs () { if (hasRequiredMs) return ms; hasRequiredMs = 1; var s = 1000; var m = s * 60; var h = m * 60; var d = h * 24; var w = d * 7; 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 */ ms = function (val, options) { options = options || {}; var type = typeof val; if (type === 'string' && val.length > 0) { return parse(val); } else if (type === 'number' && isFinite(val)) { 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|weeks?|w|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 'weeks': case 'week': case 'w': return n * w; 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) { var msAbs = Math.abs(ms); if (msAbs >= d) { return Math.round(ms / d) + 'd'; } if (msAbs >= h) { return Math.round(ms / h) + 'h'; } if (msAbs >= m) { return Math.round(ms / m) + 'm'; } if (msAbs >= s) { return Math.round(ms / s) + 's'; } return ms + 'ms'; } /** * Long format for `ms`. * * @param {Number} ms * @return {String} * @api private */ function fmtLong(ms) { var msAbs = Math.abs(ms); if (msAbs >= d) { return plural(ms, msAbs, d, 'day'); } if (msAbs >= h) { return plural(ms, msAbs, h, 'hour'); } if (msAbs >= m) { return plural(ms, msAbs, m, 'minute'); } if (msAbs >= s) { return plural(ms, msAbs, s, 'second'); } return ms + ' ms'; } /** * Pluralization helper. */ function plural(ms, msAbs, n, name) { var isPlural = msAbs >= n * 1.5; return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : ''); } return ms; } var common$6; var hasRequiredCommon; function requireCommon () { if (hasRequiredCommon) return common$6; hasRequiredCommon = 1; /** * This is the common logic for both the Node.js and web browser * implementations of `debug()`. */ function setup(env) { createDebug.debug = createDebug; createDebug.default = createDebug; createDebug.coerce = coerce; createDebug.disable = disable; createDebug.enable = enable; createDebug.enabled = enabled; createDebug.humanize = requireMs(); createDebug.destroy = destroy; Object.keys(env).forEach(key => { createDebug[key] = env[key]; }); /** * The currently active debug mode names, and names to skip. */ createDebug.names = []; createDebug.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". */ createDebug.formatters = {}; /** * Selects a color for a debug namespace * @param {String} namespace The namespace string for the debug instance to be colored * @return {Number|String} An ANSI color code for the given namespace * @api private */ function selectColor(namespace) { let hash = 0; for (let i = 0; i < namespace.length; i++) { hash = ((hash << 5) - hash) + namespace.charCodeAt(i); hash |= 0; // Convert to 32bit integer } return createDebug.colors[Math.abs(hash) % createDebug.colors.length]; } createDebug.selectColor = selectColor; /** * Create a debugger with the given `namespace`. * * @param {String} namespace * @return {Function} * @api public */ function createDebug(namespace) { let prevTime; let enableOverride = null; let namespacesCache; let enabledCache; function debug(...args) { // Disabled? if (!debug.enabled) { return; } const self = debug; // Set `diff` timestamp const curr = Number(new Date()); const ms = curr - (prevTime || curr); self.diff = ms; self.prev = prevTime; self.curr = curr; prevTime = curr; args[0] = createDebug.coerce(args[0]); if (typeof args[0] !== 'string') { // Anything else let's inspect with %O args.unshift('%O'); } // Apply any `formatters` transformations let index = 0; args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => { // If we encounter an escaped % then don't increase the array index if (match === '%%') { return '%'; } index++; const formatter = createDebug.formatters[format]; if (typeof formatter === 'function') { const 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.) createDebug.formatArgs.call(self, args); const logFn = self.log || createDebug.log; logFn.apply(self, args); } debug.namespace = namespace; debug.useColors = createDebug.useColors(); debug.color = createDebug.selectColor(namespace); debug.extend = extend; debug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release. Object.defineProperty(debug, 'enabled', { enumerable: true, configurable: false, get: () => { if (enableOverride !== null) { return enableOverride; } if (namespacesCache !== createDebug.namespaces) { namespacesCache = createDebug.namespaces; enabledCache = createDebug.enabled(namespace); } return enabledCache; }, set: v => { enableOverride = v; } }); // Env-specific initialization logic for debug instances if (typeof createDebug.init === 'function') { createDebug.init(debug); } return debug; } function extend(namespace, delimiter) { const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace); newDebug.log = this.log; return newDebug; } /** * Enables a debug mode by namespaces. This can include modes * separated by a colon and wildcards. * * @param {String} namespaces * @api public */ function enable(namespaces) { createDebug.save(namespaces); createDebug.namespaces = namespaces; createDebug.names = []; createDebug.skips = []; const split = (typeof namespaces === 'string' ? namespaces : '') .trim() .replace(' ', ',') .split(',') .filter(Boolean); for (const ns of split) { if (ns[0] === '-') { createDebug.skips.push(ns.slice(1)); } else { createDebug.names.push(ns); } } } /** * Checks if the given string matches a namespace template, honoring * asterisks as wildcards. * * @param {String} search * @param {String} template * @return {Boolean} */ function matchesTemplate(search, template) { let searchIndex = 0; let templateIndex = 0; let starIndex = -1; let matchIndex = 0; while (searchIndex < search.length) { if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === '*')) { // Match character or proceed with wildcard if (template[templateIndex] === '*') { starIndex = templateIndex; matchIndex = searchIndex; templateIndex++; // Skip the '*' } else { searchIndex++; templateIndex++; } } else if (starIndex !== -1) { // eslint-disable-line no-negated-condition // Backtrack to the last '*' and try to match more characters templateIndex = starIndex + 1; matchIndex++; searchIndex = matchIndex; } else { return false; // No match } } // Handle trailing '*' in template while (templateIndex < template.length && template[templateIndex] === '*') { templateIndex++; } return templateIndex === template.length; } /** * Disable debug output. * * @return {String} namespaces * @api public */ function disable() { const namespaces = [ ...createDebug.names, ...createDebug.skips.map(namespace => '-' + namespace) ].join(','); createDebug.enable(''); return namespaces; } /** * Returns true if the given mode name is enabled, false otherwise. * * @param {String} name * @return {Boolean} * @api public */ function enabled(name) { for (const skip of createDebug.skips) { if (matchesTemplate(name, skip)) { return false; } } for (const ns of createDebug.names) { if (matchesTemplate(name, ns)) { 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; } /** * XXX DO NOT USE. This is a temporary stub function. * XXX It WILL be removed in the next major release. */ function destroy() { console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'); } createDebug.enable(createDebug.load()); return createDebug; } common$6 = setup; return common$6; } /* eslint-env browser */ var hasRequiredBrowser; function requireBrowser () { if (hasRequiredBrowser) return browser.exports; hasRequiredBrowser = 1; (function (module, exports) { /** * This is the web browser implementation of `debug()`. */ exports.formatArgs = formatArgs; exports.save = save; exports.load = load; exports.useColors = useColors; exports.storage = localstorage(); exports.destroy = (() => { let warned = false; return () => { if (!warned) { warned = true; console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'); } }; })(); /** * 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 */ // eslint-disable-next-line complexity 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' || window.process.__nwjs)) { 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; } let m; // Is webkit? http://stackoverflow.com/a/16459606/376773 // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 // eslint-disable-next-line no-return-assign 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 && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[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+)/)); } /** * Colorize log arguments if enabled. * * @api public */ function formatArgs(args) { args[0] = (this.useColors ? '%c' : '') + this.namespace + (this.useColors ? ' %c' : ' ') + args[0] + (this.useColors ? '%c ' : ' ') + '+' + module.exports.humanize(this.diff); if (!this.useColors) { return; } const 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 let index = 0; let lastC = 0; args[0].replace(/%[a-zA-Z%]/g, match => { if (match === '%%') { return; } index++; if (match === '%c') { // We only are interested in the *last* %c // (the user may have provided their own) lastC = index; } }); args.splice(lastC, 0, c); } /** * Invokes `console.debug()` when available. * No-op when `console.debug` is not a "function". * If `console.debug` is not available, falls back * to `console.log`. * * @api public */ exports.log = console.debug || console.log || (() => {}); /** * Save `namespaces`. * * @param {String} namespaces * @api private */ function save(namespaces) { try { if (namespaces) { exports.storage.setItem('debug', namespaces); } else { exports.storage.removeItem('debug'); } } catch (error) { // Swallow // XXX (@Qix-) should we be logging these? } } /** * Load `namespaces`. * * @return {String} returns the previously persisted debug modes * @api private */ function load() { let r; try { r = exports.storage.getItem('debug'); } catch (error) { // Swallow // XXX (@Qix-) should we be logging these? } // 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; } /** * 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 { // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context // The Browser also has localStorage in the global context. return localStorage; } catch (error) { // Swallow // XXX (@Qix-) should we be logging these? } } module.exports = requireCommon()(exports); const {formatters} = module.exports; /** * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. */ formatters.j = function (v) { try { return JSON.stringify(v); } catch (error) { return '[UnexpectedJSONParseError]: ' + error.message; } }; } (browser, browser.exports)); return browser.exports; } var node = {exports: {}}; var hasFlag; var hasRequiredHasFlag; function requireHasFlag () { if (hasRequiredHasFlag) return hasFlag; hasRequiredHasFlag = 1; hasFlag = (flag, argv = process.argv) => { const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--'); const position = argv.indexOf(prefix + flag); const terminatorPosition = argv.indexOf('--'); return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition); }; return hasFlag; } var supportsColor_1; var hasRequiredSupportsColor; function requireSupportsColor () { if (hasRequiredSupportsColor) return supportsColor_1; hasRequiredSupportsColor = 1; const os = require$$2; const tty = require$$1; const hasFlag = requireHasFlag(); const {env} = process; let forceColor; if (hasFlag('no-color') || hasFlag('no-colors') || hasFlag('color=false') || hasFlag('color=never')) { 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') { forceColor = 1; } else if (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(haveStream, streamIsTTY) { if (forceColor === 0) { return 0; } if (hasFlag('color=16m') || hasFlag('color=full') || hasFlag('color=truecolor')) { return 3; } if (hasFlag('color=256')) { return 2; } if (haveStream && !streamIsTTY && forceColor === undefined) { return 0; } const min = forceColor || 0; if (env.TERM === 'dumb') { return min; } if (process.platform === 'win32') { // 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(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', 'GITHUB_ACTIONS', 'BUILDKITE'].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, stream && stream.isTTY); return translateLevel(level); } supportsColor_1 = { supportsColor: getSupportLevel, stdout: translateLevel(supportsColor(true, tty.isatty(1))), stderr: translateLevel(supportsColor(true, tty.isatty(2))) }; return supportsColor_1; } /** * Module dependencies. */ var hasRequiredNode; function requireNode () { if (hasRequiredNode) return node.exports; hasRequiredNode = 1; (function (module, exports) { const tty = require$$1; const util = require$$1$1; /** * This is the Node.js implementation of `debug()`. */ exports.init = init; exports.log = log; exports.formatArgs = formatArgs; exports.save = save; exports.load = load; exports.useColors = useColors; exports.destroy = util.deprecate( () => {}, 'Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.' ); /** * Colors. */ exports.colors = [6, 2, 3, 4, 5, 1]; try { // Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json) // eslint-disable-next-line import/no-extraneous-dependencies const supportsColor = requireSupportsColor(); if (supportsColor && (supportsColor.stderr || 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 (error) { // 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(key => { return /^debug_/i.test(key); }).reduce((obj, key) => { // Camel-case const prop = key .substring(6) .toLowerCase() .replace(/_([a-z])/g, (_, k) => { return k.toUpperCase(); }); // Coerce string value into JS value let 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); } /** * Adds ANSI color escape codes if enabled. * * @api public */ function formatArgs(args) { const {namespace: name, useColors} = this; if (useColors) { const c = this.color; const colorCode = '\u001B[3' + (c < 8 ? c : '8;5;' + c); const prefix = ` ${colorCode};1m${name} \u001B[0m`; args[0] = prefix + args[0].split('\n').join('\n' + prefix); args.push(colorCode + 'm+' + module.exports.humanize(this.diff) + '\u001B[0m'); } else { args[0] = getDate() + name + ' ' + args[0]; } } function getDate() { if (exports.inspectOpts.hideDate) { return ''; } return new Date().toISOString() + ' '; } /** * Invokes `util.formatWithOptions()` with the specified arguments and writes to stderr. */ function log(...args) { return process.stderr.write(util.formatWithOptions(exports.inspectOpts, ...args) + '\n'); } /** * Save `namespaces`. * * @param {String} namespaces * @api private */ function save(namespaces) { if (namespaces) { process.env.DEBUG = namespaces; } else { // 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; } } /** * 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 = {}; const keys = Object.keys(exports.inspectOpts); for (let i = 0; i < keys.length; i++) { debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]]; } } module.exports = requireCommon()(exports); const {formatters} = module.exports; /** * Map %o to `util.inspect()`, all on a single line. */ formatters.o = function (v) { this.inspectOpts.colors = this.useColors; return util.inspect(v, this.inspectOpts) .split('\n') .map(str => str.trim()) .join(' '); }; /** * Map %O to `util.inspect()`, allowing multiple lines if needed. */ formatters.O = function (v) { this.inspectOpts.colors = this.useColors; return util.inspect(v, this.inspectOpts); }; } (node, node.exports)); return node.exports; } /** * Detect Electron renderer / nwjs process, which is node, but we should * treat as a browser. */ if (typeof process === 'undefined' || process.type === 'renderer' || process.browser === true || process.__nwjs) { src.exports = requireBrowser(); } else { src.exports = requireNode(); } var srcExports = src.exports; var error = {}; Object.defineProperty(error, "__esModule", { value: true }); error.newError = newError; function newError(message, code) { const error = new Error(message); error.code = code; return error; } var ProgressCallbackTransform$1 = {}; Object.defineProperty(ProgressCallbackTransform$1, "__esModule", { value: true }); ProgressCallbackTransform$1.ProgressCallbackTransform = void 0; const stream_1$3 = require$$0$1; class ProgressCallbackTransform extends stream_1$3.Transform { constructor(total, cancellationToken, onProgress) { super(); this.total = total; this.cancellationToken = cancellationToken; this.onProgress = onProgress; this.start = Date.now(); this.transferred = 0; this.delta = 0; this.nextUpdate = this.start + 1000; } _transform(chunk, encoding, callback) { if (this.cancellationToken.cancelled) { callback(new Error("cancelled"), null); return; } this.transferred += chunk.length; this.delta += chunk.length; const now = Date.now(); if (now >= this.nextUpdate && this.transferred !== this.total /* will be emitted on _flush */) { this.nextUpdate = now + 1000; this.onProgress({ total: this.total, delta: this.delta, transferred: this.transferred, percent: (this.transferred / this.total) * 100, bytesPerSecond: Math.round(this.transferred / ((now - this.start) / 1000)), }); this.delta = 0; } callback(null, chunk); } _flush(callback) { if (this.cancellationToken.cancelled) { callback(new Error("cancelled")); return; } this.onProgress({ total: this.total, delta: this.delta, transferred: this.total, percent: 100, bytesPerSecond: Math.round(this.transferred / ((Date.now() - this.start) / 1000)), }); this.delta = 0; callback(null); } } ProgressCallbackTransform$1.ProgressCallbackTransform = ProgressCallbackTransform; Object.defineProperty(httpExecutor, "__esModule", { value: true }); httpExecutor.DigestTransform = httpExecutor.HttpExecutor = httpExecutor.HttpError = void 0; httpExecutor.createHttpError = createHttpError; httpExecutor.parseJson = parseJson; httpExecutor.configureRequestOptionsFromUrl = configureRequestOptionsFromUrl; httpExecutor.configureRequestUrl = configureRequestUrl; httpExecutor.safeGetHeader = safeGetHeader; httpExecutor.configureRequestOptions = configureRequestOptions; httpExecutor.safeStringifyJson = safeStringifyJson; const crypto_1$2 = require$$0$2; const debug_1$1 = srcExports; const fs_1$3 = require$$1$2; const stream_1$2 = require$$0$1; const url_1$4 = require$$4; const CancellationToken_1 = CancellationToken$1; const error_1$2 = error; const ProgressCallbackTransform_1 = ProgressCallbackTransform$1; const debug$3 = (0, debug_1$1.default)("electron-builder"); function createHttpError(response, description = null) { return new HttpError(response.statusCode || -1, `${response.statusCode} ${response.statusMessage}` + (description == null ? "" : "\n" + JSON.stringify(description, null, " ")) + "\nHeaders: " + safeStringifyJson(response.headers), description); } const HTTP_STATUS_CODES = new Map([ [429, "Too many requests"], [400, "Bad request"], [403, "Forbidden"], [404, "Not found"], [405, "Method not allowed"], [406, "Not acceptable"], [408, "Request timeout"], [413, "Request entity too large"], [500, "Internal server error"], [502, "Bad gateway"], [503, "Service unavailable"], [504, "Gateway timeout"], [505, "HTTP version not supported"], ]); class HttpError extends Error { constructor(statusCode, message = `HTTP error: ${HTTP_STATUS_CODES.get(statusCode) || statusCode}`, description = null) { super(message); this.statusCode = statusCode; this.description = description; this.name = "HttpError"; this.code = `HTTP_ERROR_${statusCode}`; } isServerError() { return this.statusCode >= 500 && this.statusCode <= 599; } } httpExecutor.HttpError = HttpError; function parseJson(result) { return result.then(it => (it == null || it.length === 0 ? null : JSON.parse(it))); } class HttpExecutor { constructor() { this.maxRedirects = 10; } request(options, cancellationToken = new CancellationToken_1.CancellationToken(), data) { configureRequestOptions(options); const json = data == null ? undefined : JSON.stringify(data); const encodedData = json ? Buffer.from(json) : undefined; if (encodedData != null) { debug$3(json); const { headers, ...opts } = options; options = { method: "post", headers: { "Content-Type": "application/json", "Content-Length": encodedData.length, ...headers, }, ...opts, }; } return this.doApiRequest(options, cancellationToken, it => it.end(encodedData)); } doApiRequest(options, cancellationToken, requestProcessor, redirectCount = 0) { if (debug$3.enabled) { debug$3(`Request: ${safeStringifyJson(options)}`); } return cancellationToken.createPromise((resolve, reject, onCancel) => { const request = this.createRequest(options, (response) => { try { this.handleResponse(response, options, cancellationToken, resolve, reject, redirectCount, requestProcessor); } catch (e) { reject(e); } }); this.addErrorAndTimeoutHandlers(request, reject, options.timeout); this.addRedirectHandlers(request, options, reject, redirectCount, options => { this.doApiRequest(options, cancellationToken, requestProcessor, redirectCount).then(resolve).catch(reject); }); requestProcessor(request, reject); onCancel(() => request.abort()); }); } // noinspection JSUnusedLocalSymbols // eslint-disable-next-line addRedirectHandlers(request, options, reject, redirectCount, handler) { // not required for NodeJS } addErrorAndTimeoutHandlers(request, reject, timeout = 60 * 1000) { this.addTimeOutHandler(request, reject, timeout); request.on("error", reject); request.on("aborted", () => { reject(new Error("Request has been aborted by the server")); }); } handleResponse(response, options, cancellationToken, resolve, reject, redirectCount, requestProcessor) { var _a; if (debug$3.enabled) { debug$3(`Response: ${response.statusCode} ${response.statusMessage}, request options: ${safeStringifyJson(options)}`); } // we handle any other >= 400 error on request end (read detailed message in the response body) if (response.statusCode === 404) { // error is clear, we don't need to read detailed error description reject(createHttpError(response, `method: ${options.method || "GET"} url: ${options.protocol || "https:"}//${options.hostname}${options.port ? `:${options.port}` : ""}${options.path} Please double check that your authentication token is correct. Due to security reasons, actual status maybe not reported, but 404. `)); return; } else if (response.statusCode === 204) { // on DELETE request resolve(); return; } const code = (_a = response.statusCode) !== null && _a !== void 0 ? _a : 0; const shouldRedirect = code >= 300 && code < 400; const redirectUrl = safeGetHeader(response, "location"); if (shouldRedirect && redirectUrl != null) { if (redirectCount > this.maxRedirects) { reject(this.createMaxRedirectError()); return; } this.doApiRequest(HttpExecutor.prepareRedirectUrlOptions(redirectUrl, options), cancellationToken, requestProcessor, redirectCount).then(resolve).catch(reject); return; } response.setEncoding("utf8"); let data = ""; response.on("error", reject); response.on("data", (chunk) => (data += chunk)); response.on("end", () => { try { if (response.statusCode != null && response.statusCode >= 400) { const contentType = safeGetHeader(response, "content-type"); const isJson = contentType != null && (Array.isArray(contentType) ? contentType.find(it => it.includes("json")) != null : contentType.includes("json")); reject(createHttpError(response, `method: ${options.method || "GET"} url: ${options.protocol || "https:"}//${options.hostname}${options.port ? `:${options.port}` : ""}${options.path} Data: ${isJson ? JSON.stringify(JSON.parse(data)) : data} `)); } else { resolve(data.length === 0 ? null : data); } } catch (e) { reject(e); } }); } async downloadToBuffer(url, options) { return await options.cancellationToken.createPromise((resolve, reject, onCancel) => { const responseChunks = []; const requestOptions = { headers: options.headers || undefined, // because PrivateGitHubProvider requires HttpExecutor.prepareRedirectUrlOptions logic, so, we need to redirect manually redirect: "manual", }; configureRequestUrl(url, requestOptions); configureRequestOptions(requestOptions); this.doDownload(requestOptions, { destination: null, options, onCancel, callback: error => { if (error == null) { resolve(Buffer.concat(responseChunks)); } else { reject(error); } }, responseHandler: (response, callback) => { let receivedLength = 0; response.on("data", (chunk) => { receivedLength += chunk.length; if (receivedLength > 524288000) { callback(new Error("Maximum allowed size is 500 MB")); return; } responseChunks.push(chunk); }); response.on("end", () => { callback(null); }); }, }, 0); }); } doDownload(requestOptions, options, redirectCount) { const request = this.createRequest(requestOptions, (response) => { if (response.statusCode >= 400) { options.callback(new Error(`Cannot download "${requestOptions.protocol || "https:"}//${requestOptions.hostname}${requestOptions.path}", status ${response.statusCode}: ${response.statusMessage}`)); return; } // It is possible for the response stream to fail, e.g. when a network is lost while // response stream is in progress. Stop waiting and reject so consumer can catch the error. response.on("error", options.callback); // this code not relevant for Electron (redirect event instead handled) const redirectUrl = safeGetHeader(response, "location"); if (redirectUrl != null) { if (redirectCount < this.maxRedirects) { this.doDownload(HttpExecutor.prepareRedirectUrlOptions(redirectUrl, requestOptions), options, redirectCount++); } else { options.callback(this.createMaxRedirectError()); } return; } if (options.responseHandler == null) { configurePipes(options, response); } else { options.responseHandler(response, options.callback); } }); this.addErrorAndTimeoutHandlers(request, options.callback, requestOptions.timeout); this.addRedirectHandlers(request, requestOptions, options.callback, redirectCount, requestOptions => { this.doDownload(requestOptions, options, redirectCount++); }); request.end(); } createMaxRedirectError() { return new Error(`Too many redirects (> ${this.maxRedirects})`); } addTimeOutHandler(request, callback, timeout) { request.on("socket", (socket) => { socket.setTimeout(timeout, () => { request.abort(); callback(new Error("Request timed out")); }); }); } static prepareRedirectUrlOptions(redirectUrl, options) { const newOptions = configureRequestOptionsFromUrl(redirectUrl, { ...options }); const headers = newOptions.headers; if (headers === null || headers === void 0 ? void 0 : headers.authorization) { const parsedNewUrl = new url_1$4.URL(redirectUrl); if (parsedNewUrl.hostname.endsWith(".amazonaws.com") || parsedNewUrl.searchParams.has("X-Amz-Credential")) { delete headers.authorization; } } return newOptions; } static retryOnServerError(task, maxRetries = 3) { for (let attemptNumber = 0;; attemptNumber++) { try { return task(); } catch (e) { if (attemptNumber < maxRetries && ((e instanceof HttpError && e.isServerError()) || e.code === "EPIPE")) { continue; } throw e; } } } } httpExecutor.HttpExecutor = HttpExecutor; function configureRequestOptionsFromUrl(url, options) { const result = configureRequestOptions(options); configureRequestUrl(new url_1$4.URL(url), result); return result; } function configureRequestUrl(url, options) { options.protocol = url.protocol; options.hostname = url.hostname; if (url.port) { options.port = url.port; } else if (options.port) { delete options.port; } options.path = url.pathname + url.search; } class DigestTransform extends stream_1$2.Transform { // noinspection JSUnusedGlobalSymbols get actual() { return this._actual; } constructor(expected, algorithm = "sha512", encoding = "base64") { super(); this.expected = expected; this.algorithm = algorithm; this.encoding = encoding; this._actual = null; this.isValidateOnEnd = true; this.digester = (0, crypto_1$2.createHash)(algorithm); } // noinspection JSUnusedGlobalSymbols _transform(chunk, encoding, callback) { this.digester.update(chunk); callback(null, chunk); } // noinspection JSUnusedGlobalSymbols _flush(callback) { this._actual = this.digester.digest(this.encoding); if (this.isValidateOnEnd) { try { this.validate(); } catch (e) { callback(e); return; } } callback(null); } validate() { if (this._actual == null) { throw (0, error_1$2.newError)("Not finished yet", "ERR_STREAM_NOT_FINISHED"); } if (this._actual !== this.expected) { throw (0, error_1$2.newError)(`${this.algorithm} checksum mismatch, expected ${this.expected}, got ${this._actual}`, "ERR_CHECKSUM_MISMATCH"); } return null; } } httpExecutor.DigestTransform = DigestTransform; function checkSha2(sha2Header, sha2, callback) { if (sha2Header != null && sha2 != null && sha2Header !== sha2) { callback(new Error(`checksum mismatch: expected ${sha2} but got ${sha2Header} (X-Checksum-Sha2 header)`)); return false; } return true; } function safeGetHeader(response, headerKey) { const value = response.headers[headerKey]; if (value == null) { return null; } else if (Array.isArray(value)) { // electron API return value.length === 0 ? null : value[value.length - 1]; } else { return value; } } function configurePipes(options, response) { if (!checkSha2(safeGetHeader(response, "X-Checksum-Sha2"), options.options.sha2, options.callback)) { return; } const streams = []; if (options.options.onProgress != null) { const contentLength = safeGetHeader(response, "content-length"); if (contentLength != null) { streams.push(new ProgressCallbackTransform_1.ProgressCallbackTransform(parseInt(contentLength, 10), options.options.cancellationToken, options.options.onProgress)); } } const sha512 = options.options.sha512; if (sha512 != null) { streams.push(new DigestTransform(sha512, "sha512", sha512.length === 128 && !sha512.includes("+") && !sha512.includes("Z") && !sha512.includes("=") ? "hex" : "base64")); } else if (options.options.sha2 != null) { streams.push(new DigestTransform(options.options.sha2, "sha256", "hex")); } const fileOut = (0, fs_1$3.createWriteStream)(options.destination); streams.push(fileOut); let lastStream = response; for (const stream of streams) { stream.on("error", (error) => { fileOut.close(); if (!options.options.cancellationToken.cancelled) { options.callback(error); } }); lastStream = lastStream.pipe(stream); } fileOut.on("finish", () => { fileOut.close(options.callback); }); } function configureRequestOptions(options, token, method) { if (method != null) { options.method = method; } options.headers = { ...options.headers }; const headers = options.headers; if (token != null) { headers.authorization = token.startsWith("Basic") || token.startsWith("Bearer") ? token : `token ${token}`; } if (headers["User-Agent"] == null) { headers["User-Agent"] = "electron-builder"; } if (method == null || method === "GET" || headers["Cache-Control"] == null) { headers["Cache-Control"] = "no-cache"; } // do not specify for node (in any case we use https module) if (options.protocol == null && process.versions.electron != null) { options.protocol = "https:"; } return options; } function safeStringifyJson(data, skippedNames) { return JSON.stringify(data, (name, value) => { if (name.endsWith("Authorization") || name.endsWith("authorization") || name.endsWith("Password") || name.endsWith("PASSWORD") || name.endsWith("Token") || name.includes("password") || name.includes("token") || (skippedNames != null && skippedNames.has(name))) { return ""; } return value; }, 2); } var publishOptions = {}; Object.defineProperty(publishOptions, "__esModule", { value: true }); publishOptions.githubUrl = githubUrl; publishOptions.getS3LikeProviderBaseUrl = getS3LikeProviderBaseUrl; /** @private */ function githubUrl(options, defaultHost = "github.com") { return `${options.protocol || "https"}://${options.host || defaultHost}`; } function getS3LikeProviderBaseUrl(configuration) { const provider = configuration.provider; if (provider === "s3") { return s3Url(configuration); } if (provider === "spaces") { return spacesUrl(configuration); } throw new Error(`Not supported provider: ${provider}`); } function s3Url(options) { let url; if (options.accelerate == true) { url = `https://${options.bucket}.s3-accelerate.amazonaws.com`; } else if (options.endpoint != null) { url = `${options.endpoint}/${options.bucket}`; } else if (options.bucket.includes(".")) { if (options.region == null) { throw new Error(`Bucket name "${options.bucket}" includes a dot, but S3 region is missing`); } // special case, see http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingBucket.html#access-bucket-intro if (options.region === "us-east-1") { url = `https://s3.amazonaws.com/${options.bucket}`; } else { url = `https://s3-${options.region}.amazonaws.com/${options.bucket}`; } } else if (options.region === "cn-north-1") { url = `https://${options.bucket}.s3.${options.region}.amazonaws.com.cn`; } else { url = `https://${options.bucket}.s3.amazonaws.com`; } return appendPath(url, options.path); } function appendPath(url, p) { if (p != null && p.length > 0) { if (!p.startsWith("/")) { url += "/"; } url += p; } return url; } function spacesUrl(options) { if (options.name == null) { throw new Error(`name is missing`); } if (options.region == null) { throw new Error(`region is missing`); } return appendPath(`https://${options.name}.${options.region}.digitaloceanspaces.com`, options.path); } var rfc2253Parser = {}; Object.defineProperty(rfc2253Parser, "__esModule", { value: true }); rfc2253Parser.parseDn = parseDn; function parseDn(seq) { let quoted = false; let key = null; let token = ""; let nextNonSpace = 0; seq = seq.trim(); const result = new Map(); for (let i = 0; i <= seq.length; i++) { if (i === seq.length) { if (key !== null) { result.set(key, token); } break; } const ch = seq[i]; if (quoted) { if (ch === '"') { quoted = false; continue; } } else { if (ch === '"') { quoted = true; continue; } if (ch === "\\") { i++; const ord = parseInt(seq.slice(i, i + 2), 16); if (Number.isNaN(ord)) { token += seq[i]; } else { i++; token += String.fromCharCode(ord); } continue; } if (key === null && ch === "=") { key = token; token = ""; continue; } if (ch === "," || ch === ";" || ch === "+") { if (key !== null) { result.set(key, token); } key = null; token = ""; continue; } } if (ch === " " && !quoted) { if (token.length === 0) { continue; } if (i > nextNonSpace) { let j = i; while (seq[j] === " ") { j++; } nextNonSpace = j; } if (nextNonSpace >= seq.length || seq[nextNonSpace] === "," || seq[nextNonSpace] === ";" || (key === null && seq[nextNonSpace] === "=") || (key !== null && seq[nextNonSpace] === "+")) { i = nextNonSpace - 1; continue; } } token += ch; } return result; } var uuid = {}; Object.defineProperty(uuid, "__esModule", { value: true }); uuid.nil = uuid.UUID = void 0; const crypto_1$1 = require$$0$2; const error_1$1 = error; const invalidName = "options.name must be either a string or a Buffer"; // Node ID according to rfc4122#section-4.5 const randomHost = (0, crypto_1$1.randomBytes)(16); randomHost[0] = randomHost[0] | 0x01; // lookup table hex to byte const hex2byte = {}; // lookup table byte to hex const byte2hex = []; // populate lookup tables for (let i = 0; i < 256; i++) { const hex = (i + 0x100).toString(16).substr(1); hex2byte[hex] = i; byte2hex[i] = hex; } // UUID class class UUID { constructor(uuid) { this.ascii = null; this.binary = null; const check = UUID.check(uuid); if (!check) { throw new Error("not a UUID"); } this.version = check.version; if (check.format === "ascii") { this.ascii = uuid; } else { this.binary = uuid; } } static v5(name, namespace) { return uuidNamed(name, "sha1", 0x50, namespace); } toString() { if (this.ascii == null) { this.ascii = stringify$4(this.binary); } return this.ascii; } inspect() { return `UUID v${this.version} ${this.toString()}`; } static check(uuid, offset = 0) { if (typeof uuid === "string") { uuid = uuid.toLowerCase(); if (!/^[a-f0-9]{8}(-[a-f0-9]{4}){3}-([a-f0-9]{12})$/.test(uuid)) { return false; } if (uuid === "00000000-0000-0000-0000-000000000000") { return { version: undefined, variant: "nil", format: "ascii" }; } return { version: (hex2byte[uuid[14] + uuid[15]] & 0xf0) >> 4, variant: getVariant((hex2byte[uuid[19] + uuid[20]] & 0xe0) >> 5), format: "ascii", }; } if (Buffer.isBuffer(uuid)) { if (uuid.length < offset + 16) { return false; } let i = 0; for (; i < 16; i++) { if (uuid[offset + i] !== 0) { break; } } if (i === 16) { return { version: undefined, variant: "nil", format: "binary" }; } return { version: (uuid[offset + 6] & 0xf0) >> 4, variant: getVariant((uuid[offset + 8] & 0xe0) >> 5), format: "binary", }; } throw (0, error_1$1.newError)("Unknown type of uuid", "ERR_UNKNOWN_UUID_TYPE"); } // read stringified uuid into a Buffer static parse(input) { const buffer = Buffer.allocUnsafe(16); let j = 0; for (let i = 0; i < 16; i++) { buffer[i] = hex2byte[input[j++] + input[j++]]; if (i === 3 || i === 5 || i === 7 || i === 9) { j += 1; } } return buffer; } } uuid.UUID = UUID; // from rfc4122#appendix-C UUID.OID = UUID.parse("6ba7b812-9dad-11d1-80b4-00c04fd430c8"); // according to rfc4122#section-4.1.1 function getVariant(bits) { switch (bits) { case 0: case 1: case 3: return "ncs"; case 4: case 5: return "rfc4122"; case 6: return "microsoft"; default: return "future"; } } var UuidEncoding; (function (UuidEncoding) { UuidEncoding[UuidEncoding["ASCII"] = 0] = "ASCII"; UuidEncoding[UuidEncoding["BINARY"] = 1] = "BINARY"; UuidEncoding[UuidEncoding["OBJECT"] = 2] = "OBJECT"; })(UuidEncoding || (UuidEncoding = {})); // v3 + v5 function uuidNamed(name, hashMethod, version, namespace, encoding = UuidEncoding.ASCII) { const hash = (0, crypto_1$1.createHash)(hashMethod); const nameIsNotAString = typeof name !== "string"; if (nameIsNotAString && !Buffer.isBuffer(name)) { throw (0, error_1$1.newError)(invalidName, "ERR_INVALID_UUID_NAME"); } hash.update(namespace); hash.update(name); const buffer = hash.digest(); let result; switch (encoding) { case UuidEncoding.BINARY: buffer[6] = (buffer[6] & 0x0f) | version; buffer[8] = (buffer[8] & 0x3f) | 0x80; result = buffer; break; case UuidEncoding.OBJECT: buffer[6] = (buffer[6] & 0x0f) | version; buffer[8] = (buffer[8] & 0x3f) | 0x80; result = new UUID(buffer); break; default: result = byte2hex[buffer[0]] + byte2hex[buffer[1]] + byte2hex[buffer[2]] + byte2hex[buffer[3]] + "-" + byte2hex[buffer[4]] + byte2hex[buffer[5]] + "-" + byte2hex[(buffer[6] & 0x0f) | version] + byte2hex[buffer[7]] + "-" + byte2hex[(buffer[8] & 0x3f) | 0x80] + byte2hex[buffer[9]] + "-" + byte2hex[buffer[10]] + byte2hex[buffer[11]] + byte2hex[buffer[12]] + byte2hex[buffer[13]] + byte2hex[buffer[14]] + byte2hex[buffer[15]]; break; } return result; } function stringify$4(buffer) { return (byte2hex[buffer[0]] + byte2hex[buffer[1]] + byte2hex[buffer[2]] + byte2hex[buffer[3]] + "-" + byte2hex[buffer[4]] + byte2hex[buffer[5]] + "-" + byte2hex[buffer[6]] + byte2hex[buffer[7]] + "-" + byte2hex[buffer[8]] + byte2hex[buffer[9]] + "-" + byte2hex[buffer[10]] + byte2hex[buffer[11]] + byte2hex[buffer[12]] + byte2hex[buffer[13]] + byte2hex[buffer[14]] + byte2hex[buffer[15]]); } // according to rfc4122#section-4.1.7 uuid.nil = new UUID("00000000-0000-0000-0000-000000000000"); var xml = {}; var sax$1 = {}; (function (exports) { (function (sax) { // wrapper for non-node envs sax.parser = function (strict, opt) { return new SAXParser(strict, opt) }; sax.SAXParser = SAXParser; sax.SAXStream = SAXStream; sax.createStream = createStream; // When we pass the MAX_BUFFER_LENGTH position, start checking for buffer overruns. // When we check, schedule the next check for MAX_BUFFER_LENGTH - (max(buffer lengths)), // since that's the earliest that a buffer overrun could occur. This way, checks are // as rare as required, but as often as necessary to ensure never crossing this bound. // Furthermore, buffers are only tested at most once per write(), so passing a very // large string into write() might have undesirable effects, but this is manageable by // the caller, so it is assumed to be safe. Thus, a call to write() may, in the extreme // edge case, result in creating at most one complete copy of the string passed in. // Set to Infinity to have unlimited buffers. sax.MAX_BUFFER_LENGTH = 64 * 1024; var buffers = [ 'comment', 'sgmlDecl', 'textNode', 'tagName', 'doctype', 'procInstName', 'procInstBody', 'entity', 'attribName', 'attribValue', 'cdata', 'script' ]; sax.EVENTS = [ 'text', 'processinginstruction', 'sgmldeclaration', 'doctype', 'comment', 'opentagstart', 'attribute', 'opentag', 'closetag', 'opencdata', 'cdata', 'closecdata', 'error', 'end', 'ready', 'script', 'opennamespace', 'closenamespace' ]; function SAXParser (strict, opt) { if (!(this instanceof SAXParser)) { return new SAXParser(strict, opt) } var parser = this; clearBuffers(parser); parser.q = parser.c = ''; parser.bufferCheckPosition = sax.MAX_BUFFER_LENGTH; parser.opt = opt || {}; parser.opt.lowercase = parser.opt.lowercase || parser.opt.lowercasetags; parser.looseCase = parser.opt.lowercase ? 'toLowerCase' : 'toUpperCase'; parser.tags = []; parser.closed = parser.closedRoot = parser.sawRoot = false; parser.tag = parser.error = null; parser.strict = !!strict; parser.noscript = !!(strict || parser.opt.noscript); parser.state = S.BEGIN; parser.strictEntities = parser.opt.strictEntities; parser.ENTITIES = parser.strictEntities ? Object.create(sax.XML_ENTITIES) : Object.create(sax.ENTITIES); parser.attribList = []; // namespaces form a prototype chain. // it always points at the current tag, // which protos to its parent tag. if (parser.opt.xmlns) { parser.ns = Object.create(rootNS); } // disallow unquoted attribute values if not otherwise configured // and strict mode is true if (parser.opt.unquotedAttributeValues === undefined) { parser.opt.unquotedAttributeValues = !strict; } // mostly just for error reporting parser.trackPosition = parser.opt.position !== false; if (parser.trackPosition) { parser.position = parser.line = parser.column = 0; } emit(parser, 'onready'); } if (!Object.create) { Object.create = function (o) { function F () {} F.prototype = o; var newf = new F(); return newf }; } if (!Object.keys) { Object.keys = function (o) { var a = []; for (var i in o) if (o.hasOwnProperty(i)) a.push(i); return a }; } function checkBufferLength (parser) { var maxAllowed = Math.max(sax.MAX_BUFFER_LENGTH, 10); var maxActual = 0; for (var i = 0, l = buffers.length; i < l; i++) { var len = parser[buffers[i]].length; if (len > maxAllowed) { // Text/cdata nodes can get big, and since they're buffered, // we can get here under normal conditions. // Avoid issues by emitting the text node now, // so at least it won't get any bigger. switch (buffers[i]) { case 'textNode': closeText(parser); break case 'cdata': emitNode(parser, 'oncdata', parser.cdata); parser.cdata = ''; break case 'script': emitNode(parser, 'onscript', parser.script); parser.script = ''; break default: error(parser, 'Max buffer length exceeded: ' + buffers[i]); } } maxActual = Math.max(maxActual, len); } // schedule the next check for the earliest possible buffer overrun. var m = sax.MAX_BUFFER_LENGTH - maxActual; parser.bufferCheckPosition = m + parser.position; } function clearBuffers (parser) { for (var i = 0, l = buffers.length; i < l; i++) { parser[buffers[i]] = ''; } } function flushBuffers (parser) { closeText(parser); if (parser.cdata !== '') { emitNode(parser, 'oncdata', parser.cdata); parser.cdata = ''; } if (parser.script !== '') { emitNode(parser, 'onscript', parser.script); parser.script = ''; } } SAXParser.prototype = { end: function () { end(this); }, write: write, resume: function () { this.error = null; return this }, close: function () { return this.write(null) }, flush: function () { flushBuffers(this); } }; var Stream; try { Stream = require('stream').Stream; } catch (ex) { Stream = function () {}; } if (!Stream) Stream = function () {}; var streamWraps = sax.EVENTS.filter(function (ev) { return ev !== 'error' && ev !== 'end' }); function createStream (strict, opt) { return new SAXStream(strict, opt) } function SAXStream (strict, opt) { if (!(this instanceof SAXStream)) { return new SAXStream(strict, opt) } Stream.apply(this); this._parser = new SAXParser(strict, opt); this.writable = true; this.readable = true; var me = this; this._parser.onend = function () { me.emit('end'); }; this._parser.onerror = function (er) { me.emit('error', er); // if didn't throw, then means error was handled. // go ahead and clear error, so we can write again. me._parser.error = null; }; this._decoder = null; streamWraps.forEach(function (ev) { Object.defineProperty(me, 'on' + ev, { get: function () { return me._parser['on' + ev] }, set: function (h) { if (!h) { me.removeAllListeners(ev); me._parser['on' + ev] = h; return h } me.on(ev, h); }, enumerable: true, configurable: false }); }); } SAXStream.prototype = Object.create(Stream.prototype, { constructor: { value: SAXStream } }); SAXStream.prototype.write = function (data) { if (typeof Buffer === 'function' && typeof Buffer.isBuffer === 'function' && Buffer.isBuffer(data)) { if (!this._decoder) { var SD = require$$1$3.StringDecoder; this._decoder = new SD('utf8'); } data = this._decoder.write(data); } this._parser.write(data.toString()); this.emit('data', data); return true }; SAXStream.prototype.end = function (chunk) { if (chunk && chunk.length) { this.write(chunk); } this._parser.end(); return true }; SAXStream.prototype.on = function (ev, handler) { var me = this; if (!me._parser['on' + ev] && streamWraps.indexOf(ev) !== -1) { me._parser['on' + ev] = function () { var args = arguments.length === 1 ? [arguments[0]] : Array.apply(null, arguments); args.splice(0, 0, ev); me.emit.apply(me, args); }; } return Stream.prototype.on.call(me, ev, handler) }; // this really needs to be replaced with character classes. // XML allows all manner of ridiculous numbers and digits. var CDATA = '[CDATA['; var DOCTYPE = 'DOCTYPE'; var XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace'; var XMLNS_NAMESPACE = 'http://www.w3.org/2000/xmlns/'; var rootNS = { xml: XML_NAMESPACE, xmlns: XMLNS_NAMESPACE }; // http://www.w3.org/TR/REC-xml/#NT-NameStartChar // This implementation works on strings, a single character at a time // as such, it cannot ever support astral-plane characters (10000-EFFFF) // without a significant breaking change to either this parser, or the // JavaScript language. Implementation of an emoji-capable xml parser // is left as an exercise for the reader. var nameStart = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/; var nameBody = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/; var entityStart = /[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/; var entityBody = /[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/; function isWhitespace (c) { return c === ' ' || c === '\n' || c === '\r' || c === '\t' } function isQuote (c) { return c === '"' || c === '\'' } function isAttribEnd (c) { return c === '>' || isWhitespace(c) } function isMatch (regex, c) { return regex.test(c) } function notMatch (regex, c) { return !isMatch(regex, c) } var S = 0; sax.STATE = { BEGIN: S++, // leading byte order mark or whitespace BEGIN_WHITESPACE: S++, // leading whitespace TEXT: S++, // general stuff TEXT_ENTITY: S++, // & and such. OPEN_WAKA: S++, // < SGML_DECL: S++, // SCRIPT: S++, //