UNPKG

powerplatform-review-tool

Version:

Evaluate Power Platform solution zip files based on best practice patterns

1,473 lines (1,460 loc) 1.06 MB
"use strict"; var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __commonJS = (cb, mod) => function __require() { return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; }; var __export = (target, all) => { for (var name2 in all) __defProp(target, name2, { get: all[name2], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // ../node_modules/process-nextick-args/index.js var require_process_nextick_args = __commonJS({ "../node_modules/process-nextick-args/index.js"(exports2, module2) { "use strict"; if (typeof process === "undefined" || !process.version || process.version.indexOf("v0.") === 0 || process.version.indexOf("v1.") === 0 && process.version.indexOf("v1.8.") !== 0) { module2.exports = { nextTick }; } else { module2.exports = process; } function nextTick(fn2, arg1, arg2, arg3) { if (typeof fn2 !== "function") { throw new TypeError('"callback" argument must be a function'); } var len = arguments.length; var args, i; switch (len) { case 0: case 1: return process.nextTick(fn2); case 2: return process.nextTick(function afterTickOne() { fn2.call(null, arg1); }); case 3: return process.nextTick(function afterTickTwo() { fn2.call(null, arg1, arg2); }); case 4: return process.nextTick(function afterTickThree() { fn2.call(null, arg1, arg2, arg3); }); default: args = new Array(len - 1); i = 0; while (i < args.length) { args[i++] = arguments[i]; } return process.nextTick(function afterTick() { fn2.apply(null, args); }); } } } }); // ../node_modules/isarray/index.js var require_isarray = __commonJS({ "../node_modules/isarray/index.js"(exports2, module2) { var toString = {}.toString; module2.exports = Array.isArray || function(arr) { return toString.call(arr) == "[object Array]"; }; } }); // ../node_modules/readable-stream/lib/internal/streams/stream.js var require_stream = __commonJS({ "../node_modules/readable-stream/lib/internal/streams/stream.js"(exports2, module2) { module2.exports = require("stream"); } }); // ../node_modules/safe-buffer/index.js var require_safe_buffer = __commonJS({ "../node_modules/safe-buffer/index.js"(exports2, module2) { var buffer = require("buffer"); var Buffer2 = buffer.Buffer; function copyProps(src, dst) { for (var key in src) { dst[key] = src[key]; } } if (Buffer2.from && Buffer2.alloc && Buffer2.allocUnsafe && Buffer2.allocUnsafeSlow) { module2.exports = buffer; } else { copyProps(buffer, exports2); exports2.Buffer = SafeBuffer; } function SafeBuffer(arg, encodingOrOffset, length) { return Buffer2(arg, encodingOrOffset, length); } copyProps(Buffer2, SafeBuffer); SafeBuffer.from = function(arg, encodingOrOffset, length) { if (typeof arg === "number") { throw new TypeError("Argument must not be a number"); } return Buffer2(arg, encodingOrOffset, length); }; SafeBuffer.alloc = function(size, fill, encoding) { if (typeof size !== "number") { throw new TypeError("Argument must be a number"); } var buf = Buffer2(size); if (fill !== void 0) { if (typeof encoding === "string") { buf.fill(fill, encoding); } else { buf.fill(fill); } } else { buf.fill(0); } return buf; }; SafeBuffer.allocUnsafe = function(size) { if (typeof size !== "number") { throw new TypeError("Argument must be a number"); } return Buffer2(size); }; SafeBuffer.allocUnsafeSlow = function(size) { if (typeof size !== "number") { throw new TypeError("Argument must be a number"); } return buffer.SlowBuffer(size); }; } }); // ../node_modules/core-util-is/lib/util.js var require_util = __commonJS({ "../node_modules/core-util-is/lib/util.js"(exports2) { function isArray(arg) { if (Array.isArray) { return Array.isArray(arg); } return objectToString(arg) === "[object Array]"; } exports2.isArray = isArray; function isBoolean(arg) { return typeof arg === "boolean"; } exports2.isBoolean = isBoolean; function isNull(arg) { return arg === null; } exports2.isNull = isNull; function isNullOrUndefined(arg) { return arg == null; } exports2.isNullOrUndefined = isNullOrUndefined; function isNumber(arg) { return typeof arg === "number"; } exports2.isNumber = isNumber; function isString(arg) { return typeof arg === "string"; } exports2.isString = isString; function isSymbol(arg) { return typeof arg === "symbol"; } exports2.isSymbol = isSymbol; function isUndefined(arg) { return arg === void 0; } exports2.isUndefined = isUndefined; function isRegExp(re) { return objectToString(re) === "[object RegExp]"; } exports2.isRegExp = isRegExp; function isObject(arg) { return typeof arg === "object" && arg !== null; } exports2.isObject = isObject; function isDate(d) { return objectToString(d) === "[object Date]"; } exports2.isDate = isDate; function isError(e) { return objectToString(e) === "[object Error]" || e instanceof Error; } exports2.isError = isError; function isFunction(arg) { return typeof arg === "function"; } exports2.isFunction = isFunction; function isPrimitive(arg) { return arg === null || typeof arg === "boolean" || typeof arg === "number" || typeof arg === "string" || typeof arg === "symbol" || // ES6 symbol typeof arg === "undefined"; } exports2.isPrimitive = isPrimitive; exports2.isBuffer = require("buffer").Buffer.isBuffer; function objectToString(o) { return Object.prototype.toString.call(o); } } }); // ../node_modules/inherits/inherits_browser.js var require_inherits_browser = __commonJS({ "../node_modules/inherits/inherits_browser.js"(exports2, module2) { if (typeof Object.create === "function") { module2.exports = function inherits(ctor, superCtor) { if (superCtor) { ctor.super_ = superCtor; ctor.prototype = Object.create(superCtor.prototype, { constructor: { value: ctor, enumerable: false, writable: true, configurable: true } }); } }; } else { module2.exports = function inherits(ctor, superCtor) { if (superCtor) { ctor.super_ = superCtor; var TempCtor = function() { }; TempCtor.prototype = superCtor.prototype; ctor.prototype = new TempCtor(); ctor.prototype.constructor = ctor; } }; } } }); // ../node_modules/inherits/inherits.js var require_inherits = __commonJS({ "../node_modules/inherits/inherits.js"(exports2, module2) { try { util = require("util"); if (typeof util.inherits !== "function") throw ""; module2.exports = util.inherits; } catch (e) { module2.exports = require_inherits_browser(); } var util; } }); // ../node_modules/readable-stream/lib/internal/streams/BufferList.js var require_BufferList = __commonJS({ "../node_modules/readable-stream/lib/internal/streams/BufferList.js"(exports2, module2) { "use strict"; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var Buffer2 = require_safe_buffer().Buffer; var util = require("util"); function copyBuffer(src, target, offset) { src.copy(target, offset); } module2.exports = function() { function BufferList() { _classCallCheck(this, BufferList); this.head = null; this.tail = null; this.length = 0; } BufferList.prototype.push = function push(v) { var entry = { data: v, next: null }; if (this.length > 0) this.tail.next = entry; else this.head = entry; this.tail = entry; ++this.length; }; BufferList.prototype.unshift = function unshift(v) { var entry = { data: v, next: this.head }; if (this.length === 0) this.tail = entry; this.head = entry; ++this.length; }; BufferList.prototype.shift = function shift() { if (this.length === 0) return; var ret = this.head.data; if (this.length === 1) this.head = this.tail = null; else this.head = this.head.next; --this.length; return ret; }; BufferList.prototype.clear = function clear() { this.head = this.tail = null; this.length = 0; }; BufferList.prototype.join = function join(s) { if (this.length === 0) return ""; var p = this.head; var ret = "" + p.data; while (p = p.next) { ret += s + p.data; } return ret; }; BufferList.prototype.concat = function concat(n) { if (this.length === 0) return Buffer2.alloc(0); var ret = Buffer2.allocUnsafe(n >>> 0); var p = this.head; var i = 0; while (p) { copyBuffer(p.data, ret, i); i += p.data.length; p = p.next; } return ret; }; return BufferList; }(); if (util && util.inspect && util.inspect.custom) { module2.exports.prototype[util.inspect.custom] = function() { var obj = util.inspect({ length: this.length }); return this.constructor.name + " " + obj; }; } } }); // ../node_modules/readable-stream/lib/internal/streams/destroy.js var require_destroy = __commonJS({ "../node_modules/readable-stream/lib/internal/streams/destroy.js"(exports2, module2) { "use strict"; var pna = require_process_nextick_args(); function destroy(err, cb) { var _this = this; var readableDestroyed = this._readableState && this._readableState.destroyed; var writableDestroyed = this._writableState && this._writableState.destroyed; if (readableDestroyed || writableDestroyed) { if (cb) { cb(err); } else if (err) { if (!this._writableState) { pna.nextTick(emitErrorNT, this, err); } else if (!this._writableState.errorEmitted) { this._writableState.errorEmitted = true; pna.nextTick(emitErrorNT, this, err); } } return this; } if (this._readableState) { this._readableState.destroyed = true; } if (this._writableState) { this._writableState.destroyed = true; } this._destroy(err || null, function(err2) { if (!cb && err2) { if (!_this._writableState) { pna.nextTick(emitErrorNT, _this, err2); } else if (!_this._writableState.errorEmitted) { _this._writableState.errorEmitted = true; pna.nextTick(emitErrorNT, _this, err2); } } else if (cb) { cb(err2); } }); return this; } function undestroy() { if (this._readableState) { this._readableState.destroyed = false; this._readableState.reading = false; this._readableState.ended = false; this._readableState.endEmitted = false; } if (this._writableState) { this._writableState.destroyed = false; this._writableState.ended = false; this._writableState.ending = false; this._writableState.finalCalled = false; this._writableState.prefinished = false; this._writableState.finished = false; this._writableState.errorEmitted = false; } } function emitErrorNT(self2, err) { self2.emit("error", err); } module2.exports = { destroy, undestroy }; } }); // ../node_modules/util-deprecate/node.js var require_node = __commonJS({ "../node_modules/util-deprecate/node.js"(exports2, module2) { module2.exports = require("util").deprecate; } }); // ../node_modules/readable-stream/lib/_stream_writable.js var require_stream_writable = __commonJS({ "../node_modules/readable-stream/lib/_stream_writable.js"(exports2, module2) { "use strict"; var pna = require_process_nextick_args(); module2.exports = Writable; function CorkedRequest(state) { var _this = this; this.next = null; this.entry = null; this.finish = function() { onCorkedFinish(_this, state); }; } var asyncWrite = !process.browser && ["v0.10", "v0.9."].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick; var Duplex; Writable.WritableState = WritableState; var util = Object.create(require_util()); util.inherits = require_inherits(); var internalUtil = { deprecate: require_node() }; var Stream = require_stream(); var Buffer2 = require_safe_buffer().Buffer; var OurUint8Array = (typeof global !== "undefined" ? global : typeof window !== "undefined" ? window : typeof self !== "undefined" ? self : {}).Uint8Array || function() { }; function _uint8ArrayToBuffer(chunk) { return Buffer2.from(chunk); } function _isUint8Array(obj) { return Buffer2.isBuffer(obj) || obj instanceof OurUint8Array; } var destroyImpl = require_destroy(); util.inherits(Writable, Stream); function nop() { } function WritableState(options, stream) { Duplex = Duplex || require_stream_duplex(); options = options || {}; var isDuplex = stream instanceof Duplex; this.objectMode = !!options.objectMode; if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode; var hwm = options.highWaterMark; var writableHwm = options.writableHighWaterMark; var defaultHwm = this.objectMode ? 16 : 16 * 1024; if (hwm || hwm === 0) this.highWaterMark = hwm; else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm; else this.highWaterMark = defaultHwm; this.highWaterMark = Math.floor(this.highWaterMark); this.finalCalled = false; this.needDrain = false; this.ending = false; this.ended = false; this.finished = false; this.destroyed = false; var noDecode = options.decodeStrings === false; this.decodeStrings = !noDecode; this.defaultEncoding = options.defaultEncoding || "utf8"; this.length = 0; this.writing = false; this.corked = 0; this.sync = true; this.bufferProcessing = false; this.onwrite = function(er) { onwrite(stream, er); }; this.writecb = null; this.writelen = 0; this.bufferedRequest = null; this.lastBufferedRequest = null; this.pendingcb = 0; this.prefinished = false; this.errorEmitted = false; this.bufferedRequestCount = 0; this.corkedRequestsFree = new CorkedRequest(this); } WritableState.prototype.getBuffer = function getBuffer() { var current = this.bufferedRequest; var out = []; while (current) { out.push(current); current = current.next; } return out; }; (function() { try { Object.defineProperty(WritableState.prototype, "buffer", { get: internalUtil.deprecate(function() { return this.getBuffer(); }, "_writableState.buffer is deprecated. Use _writableState.getBuffer instead.", "DEP0003") }); } catch (_) { } })(); var realHasInstance; if (typeof Symbol === "function" && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === "function") { realHasInstance = Function.prototype[Symbol.hasInstance]; Object.defineProperty(Writable, Symbol.hasInstance, { value: function(object) { if (realHasInstance.call(this, object)) return true; if (this !== Writable) return false; return object && object._writableState instanceof WritableState; } }); } else { realHasInstance = function(object) { return object instanceof this; }; } function Writable(options) { Duplex = Duplex || require_stream_duplex(); if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) { return new Writable(options); } this._writableState = new WritableState(options, this); this.writable = true; if (options) { if (typeof options.write === "function") this._write = options.write; if (typeof options.writev === "function") this._writev = options.writev; if (typeof options.destroy === "function") this._destroy = options.destroy; if (typeof options.final === "function") this._final = options.final; } Stream.call(this); } Writable.prototype.pipe = function() { this.emit("error", new Error("Cannot pipe, not readable")); }; function writeAfterEnd(stream, cb) { var er = new Error("write after end"); stream.emit("error", er); pna.nextTick(cb, er); } function validChunk(stream, state, chunk, cb) { var valid = true; var er = false; if (chunk === null) { er = new TypeError("May not write null values to stream"); } else if (typeof chunk !== "string" && chunk !== void 0 && !state.objectMode) { er = new TypeError("Invalid non-string/buffer chunk"); } if (er) { stream.emit("error", er); pna.nextTick(cb, er); valid = false; } return valid; } Writable.prototype.write = function(chunk, encoding, cb) { var state = this._writableState; var ret = false; var isBuf = !state.objectMode && _isUint8Array(chunk); if (isBuf && !Buffer2.isBuffer(chunk)) { chunk = _uint8ArrayToBuffer(chunk); } if (typeof encoding === "function") { cb = encoding; encoding = null; } if (isBuf) encoding = "buffer"; else if (!encoding) encoding = state.defaultEncoding; if (typeof cb !== "function") cb = nop; if (state.ended) writeAfterEnd(this, cb); else if (isBuf || validChunk(this, state, chunk, cb)) { state.pendingcb++; ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb); } return ret; }; Writable.prototype.cork = function() { var state = this._writableState; state.corked++; }; Writable.prototype.uncork = function() { var state = this._writableState; if (state.corked) { state.corked--; if (!state.writing && !state.corked && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state); } }; Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) { if (typeof encoding === "string") encoding = encoding.toLowerCase(); if (!(["hex", "utf8", "utf-8", "ascii", "binary", "base64", "ucs2", "ucs-2", "utf16le", "utf-16le", "raw"].indexOf((encoding + "").toLowerCase()) > -1)) throw new TypeError("Unknown encoding: " + encoding); this._writableState.defaultEncoding = encoding; return this; }; function decodeChunk(state, chunk, encoding) { if (!state.objectMode && state.decodeStrings !== false && typeof chunk === "string") { chunk = Buffer2.from(chunk, encoding); } return chunk; } Object.defineProperty(Writable.prototype, "writableHighWaterMark", { // making it explicit this property is not enumerable // because otherwise some prototype manipulation in // userland will fail enumerable: false, get: function() { return this._writableState.highWaterMark; } }); function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) { if (!isBuf) { var newChunk = decodeChunk(state, chunk, encoding); if (chunk !== newChunk) { isBuf = true; encoding = "buffer"; chunk = newChunk; } } var len = state.objectMode ? 1 : chunk.length; state.length += len; var ret = state.length < state.highWaterMark; if (!ret) state.needDrain = true; if (state.writing || state.corked) { var last = state.lastBufferedRequest; state.lastBufferedRequest = { chunk, encoding, isBuf, callback: cb, next: null }; if (last) { last.next = state.lastBufferedRequest; } else { state.bufferedRequest = state.lastBufferedRequest; } state.bufferedRequestCount += 1; } else { doWrite(stream, state, false, len, chunk, encoding, cb); } return ret; } function doWrite(stream, state, writev, len, chunk, encoding, cb) { state.writelen = len; state.writecb = cb; state.writing = true; state.sync = true; if (writev) stream._writev(chunk, state.onwrite); else stream._write(chunk, encoding, state.onwrite); state.sync = false; } function onwriteError(stream, state, sync, er, cb) { --state.pendingcb; if (sync) { pna.nextTick(cb, er); pna.nextTick(finishMaybe, stream, state); stream._writableState.errorEmitted = true; stream.emit("error", er); } else { cb(er); stream._writableState.errorEmitted = true; stream.emit("error", er); finishMaybe(stream, state); } } function onwriteStateUpdate(state) { state.writing = false; state.writecb = null; state.length -= state.writelen; state.writelen = 0; } function onwrite(stream, er) { var state = stream._writableState; var sync = state.sync; var cb = state.writecb; onwriteStateUpdate(state); if (er) onwriteError(stream, state, sync, er, cb); else { var finished = needFinish(state); if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) { clearBuffer(stream, state); } if (sync) { asyncWrite(afterWrite, stream, state, finished, cb); } else { afterWrite(stream, state, finished, cb); } } } function afterWrite(stream, state, finished, cb) { if (!finished) onwriteDrain(stream, state); state.pendingcb--; cb(); finishMaybe(stream, state); } function onwriteDrain(stream, state) { if (state.length === 0 && state.needDrain) { state.needDrain = false; stream.emit("drain"); } } function clearBuffer(stream, state) { state.bufferProcessing = true; var entry = state.bufferedRequest; if (stream._writev && entry && entry.next) { var l = state.bufferedRequestCount; var buffer = new Array(l); var holder = state.corkedRequestsFree; holder.entry = entry; var count = 0; var allBuffers = true; while (entry) { buffer[count] = entry; if (!entry.isBuf) allBuffers = false; entry = entry.next; count += 1; } buffer.allBuffers = allBuffers; doWrite(stream, state, true, state.length, buffer, "", holder.finish); state.pendingcb++; state.lastBufferedRequest = null; if (holder.next) { state.corkedRequestsFree = holder.next; holder.next = null; } else { state.corkedRequestsFree = new CorkedRequest(state); } state.bufferedRequestCount = 0; } else { while (entry) { var chunk = entry.chunk; var encoding = entry.encoding; var cb = entry.callback; var len = state.objectMode ? 1 : chunk.length; doWrite(stream, state, false, len, chunk, encoding, cb); entry = entry.next; state.bufferedRequestCount--; if (state.writing) { break; } } if (entry === null) state.lastBufferedRequest = null; } state.bufferedRequest = entry; state.bufferProcessing = false; } Writable.prototype._write = function(chunk, encoding, cb) { cb(new Error("_write() is not implemented")); }; Writable.prototype._writev = null; Writable.prototype.end = function(chunk, encoding, cb) { var state = this._writableState; if (typeof chunk === "function") { cb = chunk; chunk = null; encoding = null; } else if (typeof encoding === "function") { cb = encoding; encoding = null; } if (chunk !== null && chunk !== void 0) this.write(chunk, encoding); if (state.corked) { state.corked = 1; this.uncork(); } if (!state.ending) endWritable(this, state, cb); }; function needFinish(state) { return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing; } function callFinal(stream, state) { stream._final(function(err) { state.pendingcb--; if (err) { stream.emit("error", err); } state.prefinished = true; stream.emit("prefinish"); finishMaybe(stream, state); }); } function prefinish(stream, state) { if (!state.prefinished && !state.finalCalled) { if (typeof stream._final === "function") { state.pendingcb++; state.finalCalled = true; pna.nextTick(callFinal, stream, state); } else { state.prefinished = true; stream.emit("prefinish"); } } } function finishMaybe(stream, state) { var need = needFinish(state); if (need) { prefinish(stream, state); if (state.pendingcb === 0) { state.finished = true; stream.emit("finish"); } } return need; } function endWritable(stream, state, cb) { state.ending = true; finishMaybe(stream, state); if (cb) { if (state.finished) pna.nextTick(cb); else stream.once("finish", cb); } state.ended = true; stream.writable = false; } function onCorkedFinish(corkReq, state, err) { var entry = corkReq.entry; corkReq.entry = null; while (entry) { var cb = entry.callback; state.pendingcb--; cb(err); entry = entry.next; } state.corkedRequestsFree.next = corkReq; } Object.defineProperty(Writable.prototype, "destroyed", { get: function() { if (this._writableState === void 0) { return false; } return this._writableState.destroyed; }, set: function(value) { if (!this._writableState) { return; } this._writableState.destroyed = value; } }); Writable.prototype.destroy = destroyImpl.destroy; Writable.prototype._undestroy = destroyImpl.undestroy; Writable.prototype._destroy = function(err, cb) { this.end(); cb(err); }; } }); // ../node_modules/readable-stream/lib/_stream_duplex.js var require_stream_duplex = __commonJS({ "../node_modules/readable-stream/lib/_stream_duplex.js"(exports2, module2) { "use strict"; var pna = require_process_nextick_args(); var objectKeys = Object.keys || function(obj) { var keys2 = []; for (var key in obj) { keys2.push(key); } return keys2; }; module2.exports = Duplex; var util = Object.create(require_util()); util.inherits = require_inherits(); var Readable = require_stream_readable(); var Writable = require_stream_writable(); util.inherits(Duplex, Readable); { keys = objectKeys(Writable.prototype); for (v = 0; v < keys.length; v++) { method = keys[v]; if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method]; } } var keys; var method; var v; function Duplex(options) { if (!(this instanceof Duplex)) return new Duplex(options); Readable.call(this, options); Writable.call(this, options); if (options && options.readable === false) this.readable = false; if (options && options.writable === false) this.writable = false; this.allowHalfOpen = true; if (options && options.allowHalfOpen === false) this.allowHalfOpen = false; this.once("end", onend); } Object.defineProperty(Duplex.prototype, "writableHighWaterMark", { // making it explicit this property is not enumerable // because otherwise some prototype manipulation in // userland will fail enumerable: false, get: function() { return this._writableState.highWaterMark; } }); function onend() { if (this.allowHalfOpen || this._writableState.ended) return; pna.nextTick(onEndNT, this); } function onEndNT(self2) { self2.end(); } Object.defineProperty(Duplex.prototype, "destroyed", { get: function() { if (this._readableState === void 0 || this._writableState === void 0) { return false; } return this._readableState.destroyed && this._writableState.destroyed; }, set: function(value) { if (this._readableState === void 0 || this._writableState === void 0) { return; } this._readableState.destroyed = value; this._writableState.destroyed = value; } }); Duplex.prototype._destroy = function(err, cb) { this.push(null); this.end(); pna.nextTick(cb, err); }; } }); // ../node_modules/readable-stream/lib/_stream_readable.js var require_stream_readable = __commonJS({ "../node_modules/readable-stream/lib/_stream_readable.js"(exports2, module2) { "use strict"; var pna = require_process_nextick_args(); module2.exports = Readable; var isArray = require_isarray(); var Duplex; Readable.ReadableState = ReadableState; var EE = require("events").EventEmitter; var EElistenerCount = function(emitter, type) { return emitter.listeners(type).length; }; var Stream = require_stream(); var Buffer2 = require_safe_buffer().Buffer; var OurUint8Array = (typeof global !== "undefined" ? global : typeof window !== "undefined" ? window : typeof self !== "undefined" ? self : {}).Uint8Array || function() { }; function _uint8ArrayToBuffer(chunk) { return Buffer2.from(chunk); } function _isUint8Array(obj) { return Buffer2.isBuffer(obj) || obj instanceof OurUint8Array; } var util = Object.create(require_util()); util.inherits = require_inherits(); var debugUtil = require("util"); var debug = void 0; if (debugUtil && debugUtil.debuglog) { debug = debugUtil.debuglog("stream"); } else { debug = function() { }; } var BufferList = require_BufferList(); var destroyImpl = require_destroy(); var StringDecoder; util.inherits(Readable, Stream); var kProxyEvents = ["error", "close", "destroy", "pause", "resume"]; function prependListener(emitter, event, fn2) { if (typeof emitter.prependListener === "function") return emitter.prependListener(event, fn2); if (!emitter._events || !emitter._events[event]) emitter.on(event, fn2); else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn2); else emitter._events[event] = [fn2, emitter._events[event]]; } function ReadableState(options, stream) { Duplex = Duplex || require_stream_duplex(); options = options || {}; var isDuplex = stream instanceof Duplex; this.objectMode = !!options.objectMode; if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode; var hwm = options.highWaterMark; var readableHwm = options.readableHighWaterMark; var defaultHwm = this.objectMode ? 16 : 16 * 1024; if (hwm || hwm === 0) this.highWaterMark = hwm; else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm; else this.highWaterMark = defaultHwm; this.highWaterMark = Math.floor(this.highWaterMark); this.buffer = new BufferList(); this.length = 0; this.pipes = null; this.pipesCount = 0; this.flowing = null; this.ended = false; this.endEmitted = false; this.reading = false; this.sync = true; this.needReadable = false; this.emittedReadable = false; this.readableListening = false; this.resumeScheduled = false; this.destroyed = false; this.defaultEncoding = options.defaultEncoding || "utf8"; this.awaitDrain = 0; this.readingMore = false; this.decoder = null; this.encoding = null; if (options.encoding) { if (!StringDecoder) StringDecoder = require("string_decoder/").StringDecoder; this.decoder = new StringDecoder(options.encoding); this.encoding = options.encoding; } } function Readable(options) { Duplex = Duplex || require_stream_duplex(); if (!(this instanceof Readable)) return new Readable(options); this._readableState = new ReadableState(options, this); this.readable = true; if (options) { if (typeof options.read === "function") this._read = options.read; if (typeof options.destroy === "function") this._destroy = options.destroy; } Stream.call(this); } Object.defineProperty(Readable.prototype, "destroyed", { get: function() { if (this._readableState === void 0) { return false; } return this._readableState.destroyed; }, set: function(value) { if (!this._readableState) { return; } this._readableState.destroyed = value; } }); Readable.prototype.destroy = destroyImpl.destroy; Readable.prototype._undestroy = destroyImpl.undestroy; Readable.prototype._destroy = function(err, cb) { this.push(null); cb(err); }; Readable.prototype.push = function(chunk, encoding) { var state = this._readableState; var skipChunkCheck; if (!state.objectMode) { if (typeof chunk === "string") { encoding = encoding || state.defaultEncoding; if (encoding !== state.encoding) { chunk = Buffer2.from(chunk, encoding); encoding = ""; } skipChunkCheck = true; } } else { skipChunkCheck = true; } return readableAddChunk(this, chunk, encoding, false, skipChunkCheck); }; Readable.prototype.unshift = function(chunk) { return readableAddChunk(this, chunk, null, true, false); }; function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) { var state = stream._readableState; if (chunk === null) { state.reading = false; onEofChunk(stream, state); } else { var er; if (!skipChunkCheck) er = chunkInvalid(state, chunk); if (er) { stream.emit("error", er); } else if (state.objectMode || chunk && chunk.length > 0) { if (typeof chunk !== "string" && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer2.prototype) { chunk = _uint8ArrayToBuffer(chunk); } if (addToFront) { if (state.endEmitted) stream.emit("error", new Error("stream.unshift() after end event")); else addChunk(stream, state, chunk, true); } else if (state.ended) { stream.emit("error", new Error("stream.push() after EOF")); } else { state.reading = false; if (state.decoder && !encoding) { chunk = state.decoder.write(chunk); if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false); else maybeReadMore(stream, state); } else { addChunk(stream, state, chunk, false); } } } else if (!addToFront) { state.reading = false; } } return needMoreData(state); } function addChunk(stream, state, chunk, addToFront) { if (state.flowing && state.length === 0 && !state.sync) { stream.emit("data", chunk); stream.read(0); } else { state.length += state.objectMode ? 1 : chunk.length; if (addToFront) state.buffer.unshift(chunk); else state.buffer.push(chunk); if (state.needReadable) emitReadable(stream); } maybeReadMore(stream, state); } function chunkInvalid(state, chunk) { var er; if (!_isUint8Array(chunk) && typeof chunk !== "string" && chunk !== void 0 && !state.objectMode) { er = new TypeError("Invalid non-string/buffer chunk"); } return er; } function needMoreData(state) { return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0); } Readable.prototype.isPaused = function() { return this._readableState.flowing === false; }; Readable.prototype.setEncoding = function(enc) { if (!StringDecoder) StringDecoder = require("string_decoder/").StringDecoder; this._readableState.decoder = new StringDecoder(enc); this._readableState.encoding = enc; return this; }; var MAX_HWM = 8388608; function computeNewHighWaterMark(n) { if (n >= MAX_HWM) { n = MAX_HWM; } else { n--; n |= n >>> 1; n |= n >>> 2; n |= n >>> 4; n |= n >>> 8; n |= n >>> 16; n++; } return n; } function howMuchToRead(n, state) { if (n <= 0 || state.length === 0 && state.ended) return 0; if (state.objectMode) return 1; if (n !== n) { if (state.flowing && state.length) return state.buffer.head.data.length; else return state.length; } if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n); if (n <= state.length) return n; if (!state.ended) { state.needReadable = true; return 0; } return state.length; } Readable.prototype.read = function(n) { debug("read", n); n = parseInt(n, 10); var state = this._readableState; var nOrig = n; if (n !== 0) state.emittedReadable = false; if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) { debug("read: emitReadable", state.length, state.ended); if (state.length === 0 && state.ended) endReadable(this); else emitReadable(this); return null; } n = howMuchToRead(n, state); if (n === 0 && state.ended) { if (state.length === 0) endReadable(this); return null; } var doRead = state.needReadable; debug("need readable", doRead); if (state.length === 0 || state.length - n < state.highWaterMark) { doRead = true; debug("length less than watermark", doRead); } if (state.ended || state.reading) { doRead = false; debug("reading or ended", doRead); } else if (doRead) { debug("do read"); state.reading = true; state.sync = true; if (state.length === 0) state.needReadable = true; this._read(state.highWaterMark); state.sync = false; if (!state.reading) n = howMuchToRead(nOrig, state); } var ret; if (n > 0) ret = fromList(n, state); else ret = null; if (ret === null) { state.needReadable = true; n = 0; } else { state.length -= n; } if (state.length === 0) { if (!state.ended) state.needReadable = true; if (nOrig !== n && state.ended) endReadable(this); } if (ret !== null) this.emit("data", ret); return ret; }; function onEofChunk(stream, state) { if (state.ended) return; if (state.decoder) { var chunk = state.decoder.end(); if (chunk && chunk.length) { state.buffer.push(chunk); state.length += state.objectMode ? 1 : chunk.length; } } state.ended = true; emitReadable(stream); } function emitReadable(stream) { var state = stream._readableState; state.needReadable = false; if (!state.emittedReadable) { debug("emitReadable", state.flowing); state.emittedReadable = true; if (state.sync) pna.nextTick(emitReadable_, stream); else emitReadable_(stream); } } function emitReadable_(stream) { debug("emit readable"); stream.emit("readable"); flow(stream); } function maybeReadMore(stream, state) { if (!state.readingMore) { state.readingMore = true; pna.nextTick(maybeReadMore_, stream, state); } } function maybeReadMore_(stream, state) { var len = state.length; while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) { debug("maybeReadMore read 0"); stream.read(0); if (len === state.length) break; else len = state.length; } state.readingMore = false; } Readable.prototype._read = function(n) { this.emit("error", new Error("_read() is not implemented")); }; Readable.prototype.pipe = function(dest, pipeOpts) { var src = this; var state = this._readableState; switch (state.pipesCount) { case 0: state.pipes = dest; break; case 1: state.pipes = [state.pipes, dest]; break; default: state.pipes.push(dest); break; } state.pipesCount += 1; debug("pipe count=%d opts=%j", state.pipesCount, pipeOpts); var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr; var endFn = doEnd ? onend : unpipe; if (state.endEmitted) pna.nextTick(endFn); else src.once("end", endFn); dest.on("unpipe", onunpipe); function onunpipe(readable, unpipeInfo) { debug("onunpipe"); if (readable === src) { if (unpipeInfo && unpipeInfo.hasUnpiped === false) { unpipeInfo.hasUnpiped = true; cleanup(); } } } function onend() { debug("onend"); dest.end(); } var ondrain = pipeOnDrain(src); dest.on("drain", ondrain); var cleanedUp = false; function cleanup() { debug("cleanup"); dest.removeListener("close", onclose); dest.removeListener("finish", onfinish); dest.removeListener("drain", ondrain); dest.removeListener("error", onerror); dest.removeListener("unpipe", onunpipe); src.removeListener("end", onend); src.removeListener("end", unpipe); src.removeListener("data", ondata); cleanedUp = true; if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain(); } var increasedAwaitDrain = false; src.on("data", ondata); function ondata(chunk) { debug("ondata"); increasedAwaitDrain = false; var ret = dest.write(chunk); if (false === ret && !increasedAwaitDrain) { if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) { debug("false write response, pause", state.awaitDrain); state.awaitDrain++; increasedAwaitDrain = true; } src.pause(); } } function onerror(er) { debug("onerror", er); unpipe(); dest.removeListener("error", onerror); if (EElistenerCount(dest, "error") === 0) dest.emit("error", er); } prependListener(dest, "error", onerror); function onclose() { dest.removeListener("finish", onfinish); unpipe(); } dest.once("close", onclose); function onfinish() { debug("onfinish"); dest.removeListener("close", onclose); unpipe(); } dest.once("finish", onfinish); function unpipe() { debug("unpipe"); src.unpipe(dest); } dest.emit("pipe", src); if (!state.flowing) { debug("pipe resume"); src.resume(); } return dest; }; function pipeOnDrain(src) { return function() { var state = src._readableState; debug("pipeOnDrain", state.awaitDrain); if (state.awaitDrain) state.awaitDrain--; if (state.awaitDrain === 0 && EElistenerCount(src, "data")) { state.flowing = true; flow(src); } }; } Readable.prototype.unpipe = function(dest) { var state = this._readableState; var unpipeInfo = { hasUnpiped: false }; if (state.pipesCount === 0) return this; if (state.pipesCount === 1) { if (dest && dest !== state.pipes) return this; if (!dest) dest = state.pipes; state.pipes = null; state.pipesCount = 0; state.flowing = false; if (dest) dest.emit("unpipe", this, unpipeInfo); return this; } if (!dest) { var dests = state.pipes; var len = state.pipesCount; state.pipes = null; state.pipesCount = 0; state.flowing = false; for (var i = 0; i < len; i++) { dests[i].emit("unpipe", this, { hasUnpiped: false }); } return this; } var index = indexOf(state.pipes, dest); if (index === -1) return this; state.pipes.splice(index, 1); state.pipesCount -= 1; if (state.pipesCount === 1) state.pipes = state.pipes[0]; dest.emit("unpipe", this, unpipeInfo); return this; }; Readable.prototype.on = function(ev, fn2) { var res = Stream.prototype.on.call(this, ev, fn2); if (ev === "data") { if (this._readableState.flowing !== false) this.resume(); } else if (ev === "readable") { var state = this._readableState; if (!state.endEmitted && !state.readableListening) { state.readableListening = state.needReadable = true; state.emittedReadable = false; if (!state.reading) { pna.nextTick(nReadingNextTick, this); } else if (state.length) { emitReadable(this); } } } return res; }; Readable.prototype.addListener = Readable.prototype.on; function nReadingNextTick(self2) { debug("readable nexttick read 0"); self2.read(0); } Readable.prototype.resume = function() { var state = this._readableState; if (!state.flowing) { debug("resume"); state.flowing = true; resume(this, state); } return this; }; function resume(stream, state) { if (!state.resumeScheduled) { state.resumeScheduled = true; pna.nextTick(resume_, stream, state); } } function resume_(stream, state) { if (!state.reading) { debug("resume read 0"); stream.read(0); } state.resumeScheduled = false; state.awaitDrain = 0; stream.emit("resume"); flow(stream); if (state.flowing && !state.reading) stream.read(0); } Readable.prototype.pause = function() { debug("call pause flowing=%j", this._readableState.flowing); if (false !== this._readableState.flowing) { debug("pause"); this._readableState.flowing = false; this.emit("pause"); } return this; }; function flow(stream) { var state = stream._readableState; debug("flow", state.flowing); while (state.flowing && stream.read() !== null) { } } Readable.prototype.wrap = function(stream) { var _this = this; var state = this._readableState; var paused = false; stream.on("end", function() { debug("wrapped end"); if (state.decod