lambda-live-debugger
Version:
Debug Lambda functions locally like it is running in the cloud
1,454 lines (1,440 loc) • 2.67 MB
JavaScript
"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 __esm = (fn, res) => function __init() {
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
};
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 name in all)
__defProp(target, name, { get: all[name], 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/xtend/immutable.js
var require_immutable = __commonJS({
"../../node_modules/xtend/immutable.js"(exports2, module2) {
module2.exports = extend;
var hasOwnProperty = Object.prototype.hasOwnProperty;
function extend() {
var target = {};
for (var i4 = 0; i4 < arguments.length; i4++) {
var source = arguments[i4];
for (var key in source) {
if (hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
}
}
});
// ../../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/readable-stream/lib/internal/streams/buffer_list.js
var require_buffer_list = __commonJS({
"../../node_modules/readable-stream/lib/internal/streams/buffer_list.js"(exports2, module2) {
"use strict";
function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
enumerableOnly && (symbols = symbols.filter(function(sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
})), keys.push.apply(keys, symbols);
}
return keys;
}
function _objectSpread(target) {
for (var i4 = 1; i4 < arguments.length; i4++) {
var source = null != arguments[i4] ? arguments[i4] : {};
i4 % 2 ? ownKeys(Object(source), true).forEach(function(key) {
_defineProperty(target, key, source[key]);
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}
return target;
}
function _defineProperty(obj, key, value) {
key = _toPropertyKey(key);
if (key in obj) {
Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
} else {
obj[key] = value;
}
return obj;
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _defineProperties(target, props) {
for (var i4 = 0; i4 < props.length; i4++) {
var descriptor = props[i4];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
Object.defineProperty(Constructor, "prototype", { writable: false });
return Constructor;
}
function _toPropertyKey(arg) {
var key = _toPrimitive(arg, "string");
return typeof key === "symbol" ? key : String(key);
}
function _toPrimitive(input, hint) {
if (typeof input !== "object" || input === null) return input;
var prim = input[Symbol.toPrimitive];
if (prim !== void 0) {
var res = prim.call(input, hint || "default");
if (typeof res !== "object") return res;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return (hint === "string" ? String : Number)(input);
}
var _require = require("buffer");
var Buffer2 = _require.Buffer;
var _require2 = require("util");
var inspect = _require2.inspect;
var custom = inspect && inspect.custom || "inspect";
function copyBuffer(src, target, offset) {
Buffer2.prototype.copy.call(src, target, offset);
}
module2.exports = /* @__PURE__ */ (function() {
function BufferList() {
_classCallCheck(this, BufferList);
this.head = null;
this.tail = null;
this.length = 0;
}
_createClass(BufferList, [{
key: "push",
value: function push(v4) {
var entry = {
data: v4,
next: null
};
if (this.length > 0) this.tail.next = entry;
else this.head = entry;
this.tail = entry;
++this.length;
}
}, {
key: "unshift",
value: function unshift(v4) {
var entry = {
data: v4,
next: this.head
};
if (this.length === 0) this.tail = entry;
this.head = entry;
++this.length;
}
}, {
key: "shift",
value: 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;
}
}, {
key: "clear",
value: function clear() {
this.head = this.tail = null;
this.length = 0;
}
}, {
key: "join",
value: function join(s4) {
if (this.length === 0) return "";
var p4 = this.head;
var ret = "" + p4.data;
while (p4 = p4.next) ret += s4 + p4.data;
return ret;
}
}, {
key: "concat",
value: function concat(n4) {
if (this.length === 0) return Buffer2.alloc(0);
var ret = Buffer2.allocUnsafe(n4 >>> 0);
var p4 = this.head;
var i4 = 0;
while (p4) {
copyBuffer(p4.data, ret, i4);
i4 += p4.data.length;
p4 = p4.next;
}
return ret;
}
// Consumes a specified amount of bytes or characters from the buffered data.
}, {
key: "consume",
value: function consume(n4, hasStrings) {
var ret;
if (n4 < this.head.data.length) {
ret = this.head.data.slice(0, n4);
this.head.data = this.head.data.slice(n4);
} else if (n4 === this.head.data.length) {
ret = this.shift();
} else {
ret = hasStrings ? this._getString(n4) : this._getBuffer(n4);
}
return ret;
}
}, {
key: "first",
value: function first() {
return this.head.data;
}
// Consumes a specified amount of characters from the buffered data.
}, {
key: "_getString",
value: function _getString(n4) {
var p4 = this.head;
var c4 = 1;
var ret = p4.data;
n4 -= ret.length;
while (p4 = p4.next) {
var str = p4.data;
var nb = n4 > str.length ? str.length : n4;
if (nb === str.length) ret += str;
else ret += str.slice(0, n4);
n4 -= nb;
if (n4 === 0) {
if (nb === str.length) {
++c4;
if (p4.next) this.head = p4.next;
else this.head = this.tail = null;
} else {
this.head = p4;
p4.data = str.slice(nb);
}
break;
}
++c4;
}
this.length -= c4;
return ret;
}
// Consumes a specified amount of bytes from the buffered data.
}, {
key: "_getBuffer",
value: function _getBuffer(n4) {
var ret = Buffer2.allocUnsafe(n4);
var p4 = this.head;
var c4 = 1;
p4.data.copy(ret);
n4 -= p4.data.length;
while (p4 = p4.next) {
var buf = p4.data;
var nb = n4 > buf.length ? buf.length : n4;
buf.copy(ret, ret.length - n4, 0, nb);
n4 -= nb;
if (n4 === 0) {
if (nb === buf.length) {
++c4;
if (p4.next) this.head = p4.next;
else this.head = this.tail = null;
} else {
this.head = p4;
p4.data = buf.slice(nb);
}
break;
}
++c4;
}
this.length -= c4;
return ret;
}
// Make sure the linked list only shows the minimal necessary information.
}, {
key: custom,
value: function value(_, options) {
return inspect(this, _objectSpread(_objectSpread({}, options), {}, {
// Only inspect one level.
depth: 0,
// It should not recurse.
customInspect: false
}));
}
}]);
return BufferList;
})();
}
});
// ../../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";
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) {
process.nextTick(emitErrorNT, this, err);
} else if (!this._writableState.errorEmitted) {
this._writableState.errorEmitted = true;
process.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) {
process.nextTick(emitErrorAndCloseNT, _this, err2);
} else if (!_this._writableState.errorEmitted) {
_this._writableState.errorEmitted = true;
process.nextTick(emitErrorAndCloseNT, _this, err2);
} else {
process.nextTick(emitCloseNT, _this);
}
} else if (cb) {
process.nextTick(emitCloseNT, _this);
cb(err2);
} else {
process.nextTick(emitCloseNT, _this);
}
});
return this;
}
function emitErrorAndCloseNT(self2, err) {
emitErrorNT(self2, err);
emitCloseNT(self2);
}
function emitCloseNT(self2) {
if (self2._writableState && !self2._writableState.emitClose) return;
if (self2._readableState && !self2._readableState.emitClose) return;
self2.emit("close");
}
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);
}
function errorOrDestroy(stream, err) {
var rState = stream._readableState;
var wState = stream._writableState;
if (rState && rState.autoDestroy || wState && wState.autoDestroy) stream.destroy(err);
else stream.emit("error", err);
}
module2.exports = {
destroy,
undestroy,
errorOrDestroy
};
}
});
// ../../node_modules/readable-stream/errors.js
var require_errors = __commonJS({
"../../node_modules/readable-stream/errors.js"(exports2, module2) {
"use strict";
var codes = {};
function createErrorType(code, message, Base) {
if (!Base) {
Base = Error;
}
function getMessage(arg1, arg2, arg3) {
if (typeof message === "string") {
return message;
} else {
return message(arg1, arg2, arg3);
}
}
class NodeError extends Base {
constructor(arg1, arg2, arg3) {
super(getMessage(arg1, arg2, arg3));
}
}
NodeError.prototype.name = Base.name;
NodeError.prototype.code = code;
codes[code] = NodeError;
}
function oneOf(expected, thing) {
if (Array.isArray(expected)) {
const len = expected.length;
expected = expected.map((i4) => String(i4));
if (len > 2) {
return `one of ${thing} ${expected.slice(0, len - 1).join(", ")}, or ` + expected[len - 1];
} else if (len === 2) {
return `one of ${thing} ${expected[0]} or ${expected[1]}`;
} else {
return `of ${thing} ${expected[0]}`;
}
} else {
return `of ${thing} ${String(expected)}`;
}
}
function startsWith(str, search, pos) {
return str.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search;
}
function endsWith(str, search, this_len) {
if (this_len === void 0 || this_len > str.length) {
this_len = str.length;
}
return str.substring(this_len - search.length, this_len) === search;
}
function includes(str, search, start) {
if (typeof start !== "number") {
start = 0;
}
if (start + search.length > str.length) {
return false;
} else {
return str.indexOf(search, start) !== -1;
}
}
createErrorType("ERR_INVALID_OPT_VALUE", function(name, value) {
return 'The value "' + value + '" is invalid for option "' + name + '"';
}, TypeError);
createErrorType("ERR_INVALID_ARG_TYPE", function(name, expected, actual) {
let determiner;
if (typeof expected === "string" && startsWith(expected, "not ")) {
determiner = "must not be";
expected = expected.replace(/^not /, "");
} else {
determiner = "must be";
}
let msg;
if (endsWith(name, " argument")) {
msg = `The ${name} ${determiner} ${oneOf(expected, "type")}`;
} else {
const type = includes(name, ".") ? "property" : "argument";
msg = `The "${name}" ${type} ${determiner} ${oneOf(expected, "type")}`;
}
msg += `. Received type ${typeof actual}`;
return msg;
}, TypeError);
createErrorType("ERR_STREAM_PUSH_AFTER_EOF", "stream.push() after EOF");
createErrorType("ERR_METHOD_NOT_IMPLEMENTED", function(name) {
return "The " + name + " method is not implemented";
});
createErrorType("ERR_STREAM_PREMATURE_CLOSE", "Premature close");
createErrorType("ERR_STREAM_DESTROYED", function(name) {
return "Cannot call " + name + " after a stream was destroyed";
});
createErrorType("ERR_MULTIPLE_CALLBACK", "Callback called multiple times");
createErrorType("ERR_STREAM_CANNOT_PIPE", "Cannot pipe, not readable");
createErrorType("ERR_STREAM_WRITE_AFTER_END", "write after end");
createErrorType("ERR_STREAM_NULL_VALUES", "May not write null values to stream", TypeError);
createErrorType("ERR_UNKNOWN_ENCODING", function(arg) {
return "Unknown encoding: " + arg;
}, TypeError);
createErrorType("ERR_STREAM_UNSHIFT_AFTER_END_EVENT", "stream.unshift() after end event");
module2.exports.codes = codes;
}
});
// ../../node_modules/readable-stream/lib/internal/streams/state.js
var require_state = __commonJS({
"../../node_modules/readable-stream/lib/internal/streams/state.js"(exports2, module2) {
"use strict";
var ERR_INVALID_OPT_VALUE = require_errors().codes.ERR_INVALID_OPT_VALUE;
function highWaterMarkFrom(options, isDuplex, duplexKey) {
return options.highWaterMark != null ? options.highWaterMark : isDuplex ? options[duplexKey] : null;
}
function getHighWaterMark(state3, options, duplexKey, isDuplex) {
var hwm = highWaterMarkFrom(options, isDuplex, duplexKey);
if (hwm != null) {
if (!(isFinite(hwm) && Math.floor(hwm) === hwm) || hwm < 0) {
var name = isDuplex ? duplexKey : "highWaterMark";
throw new ERR_INVALID_OPT_VALUE(name, hwm);
}
return Math.floor(hwm);
}
return state3.objectMode ? 16 : 16 * 1024;
}
module2.exports = {
getHighWaterMark
};
}
});
// ../../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 (e4) {
module2.exports = require_inherits_browser();
}
var util;
}
});
// ../../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";
module2.exports = Writable;
function CorkedRequest(state3) {
var _this = this;
this.next = null;
this.entry = null;
this.finish = function() {
onCorkedFinish(_this, state3);
};
}
var Duplex;
Writable.WritableState = WritableState;
var internalUtil = {
deprecate: require_node()
};
var Stream = require_stream();
var Buffer2 = require("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();
var _require = require_state();
var getHighWaterMark = _require.getHighWaterMark;
var _require$codes = require_errors().codes;
var ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE;
var ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED;
var ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK;
var ERR_STREAM_CANNOT_PIPE = _require$codes.ERR_STREAM_CANNOT_PIPE;
var ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED;
var ERR_STREAM_NULL_VALUES = _require$codes.ERR_STREAM_NULL_VALUES;
var ERR_STREAM_WRITE_AFTER_END = _require$codes.ERR_STREAM_WRITE_AFTER_END;
var ERR_UNKNOWN_ENCODING = _require$codes.ERR_UNKNOWN_ENCODING;
var errorOrDestroy = destroyImpl.errorOrDestroy;
require_inherits()(Writable, Stream);
function nop() {
}
function WritableState(options, stream, isDuplex) {
Duplex = Duplex || require_stream_duplex();
options = options || {};
if (typeof isDuplex !== "boolean") isDuplex = stream instanceof Duplex;
this.objectMode = !!options.objectMode;
if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
this.highWaterMark = getHighWaterMark(this, options, "writableHighWaterMark", isDuplex);
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.emitClose = options.emitClose !== false;
this.autoDestroy = !!options.autoDestroy;
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 writableStateBufferGetter() {
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 value(object) {
if (realHasInstance.call(this, object)) return true;
if (this !== Writable) return false;
return object && object._writableState instanceof WritableState;
}
});
} else {
realHasInstance = function realHasInstance2(object) {
return object instanceof this;
};
}
function Writable(options) {
Duplex = Duplex || require_stream_duplex();
var isDuplex = this instanceof Duplex;
if (!isDuplex && !realHasInstance.call(Writable, this)) return new Writable(options);
this._writableState = new WritableState(options, this, isDuplex);
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() {
errorOrDestroy(this, new ERR_STREAM_CANNOT_PIPE());
};
function writeAfterEnd(stream, cb) {
var er = new ERR_STREAM_WRITE_AFTER_END();
errorOrDestroy(stream, er);
process.nextTick(cb, er);
}
function validChunk(stream, state3, chunk, cb) {
var er;
if (chunk === null) {
er = new ERR_STREAM_NULL_VALUES();
} else if (typeof chunk !== "string" && !state3.objectMode) {
er = new ERR_INVALID_ARG_TYPE("chunk", ["string", "Buffer"], chunk);
}
if (er) {
errorOrDestroy(stream, er);
process.nextTick(cb, er);
return false;
}
return true;
}
Writable.prototype.write = function(chunk, encoding, cb) {
var state3 = this._writableState;
var ret = false;
var isBuf = !state3.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 = state3.defaultEncoding;
if (typeof cb !== "function") cb = nop;
if (state3.ending) writeAfterEnd(this, cb);
else if (isBuf || validChunk(this, state3, chunk, cb)) {
state3.pendingcb++;
ret = writeOrBuffer(this, state3, isBuf, chunk, encoding, cb);
}
return ret;
};
Writable.prototype.cork = function() {
this._writableState.corked++;
};
Writable.prototype.uncork = function() {
var state3 = this._writableState;
if (state3.corked) {
state3.corked--;
if (!state3.writing && !state3.corked && !state3.bufferProcessing && state3.bufferedRequest) clearBuffer(this, state3);
}
};
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 ERR_UNKNOWN_ENCODING(encoding);
this._writableState.defaultEncoding = encoding;
return this;
};
Object.defineProperty(Writable.prototype, "writableBuffer", {
// making it explicit this property is not enumerable
// because otherwise some prototype manipulation in
// userland will fail
enumerable: false,
get: function get3() {
return this._writableState && this._writableState.getBuffer();
}
});
function decodeChunk(state3, chunk, encoding) {
if (!state3.objectMode && state3.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 get3() {
return this._writableState.highWaterMark;
}
});
function writeOrBuffer(stream, state3, isBuf, chunk, encoding, cb) {
if (!isBuf) {
var newChunk = decodeChunk(state3, chunk, encoding);
if (chunk !== newChunk) {
isBuf = true;
encoding = "buffer";
chunk = newChunk;
}
}
var len = state3.objectMode ? 1 : chunk.length;
state3.length += len;
var ret = state3.length < state3.highWaterMark;
if (!ret) state3.needDrain = true;
if (state3.writing || state3.corked) {
var last = state3.lastBufferedRequest;
state3.lastBufferedRequest = {
chunk,
encoding,
isBuf,
callback: cb,
next: null
};
if (last) {
last.next = state3.lastBufferedRequest;
} else {
state3.bufferedRequest = state3.lastBufferedRequest;
}
state3.bufferedRequestCount += 1;
} else {
doWrite(stream, state3, false, len, chunk, encoding, cb);
}
return ret;
}
function doWrite(stream, state3, writev, len, chunk, encoding, cb) {
state3.writelen = len;
state3.writecb = cb;
state3.writing = true;
state3.sync = true;
if (state3.destroyed) state3.onwrite(new ERR_STREAM_DESTROYED("write"));
else if (writev) stream._writev(chunk, state3.onwrite);
else stream._write(chunk, encoding, state3.onwrite);
state3.sync = false;
}
function onwriteError(stream, state3, sync, er, cb) {
--state3.pendingcb;
if (sync) {
process.nextTick(cb, er);
process.nextTick(finishMaybe, stream, state3);
stream._writableState.errorEmitted = true;
errorOrDestroy(stream, er);
} else {
cb(er);
stream._writableState.errorEmitted = true;
errorOrDestroy(stream, er);
finishMaybe(stream, state3);
}
}
function onwriteStateUpdate(state3) {
state3.writing = false;
state3.writecb = null;
state3.length -= state3.writelen;
state3.writelen = 0;
}
function onwrite(stream, er) {
var state3 = stream._writableState;
var sync = state3.sync;
var cb = state3.writecb;
if (typeof cb !== "function") throw new ERR_MULTIPLE_CALLBACK();
onwriteStateUpdate(state3);
if (er) onwriteError(stream, state3, sync, er, cb);
else {
var finished = needFinish(state3) || stream.destroyed;
if (!finished && !state3.corked && !state3.bufferProcessing && state3.bufferedRequest) {
clearBuffer(stream, state3);
}
if (sync) {
process.nextTick(afterWrite, stream, state3, finished, cb);
} else {
afterWrite(stream, state3, finished, cb);
}
}
}
function afterWrite(stream, state3, finished, cb) {
if (!finished) onwriteDrain(stream, state3);
state3.pendingcb--;
cb();
finishMaybe(stream, state3);
}
function onwriteDrain(stream, state3) {
if (state3.length === 0 && state3.needDrain) {
state3.needDrain = false;
stream.emit("drain");
}
}
function clearBuffer(stream, state3) {
state3.bufferProcessing = true;
var entry = state3.bufferedRequest;
if (stream._writev && entry && entry.next) {
var l4 = state3.bufferedRequestCount;
var buffer = new Array(l4);
var holder = state3.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, state3, true, state3.length, buffer, "", holder.finish);
state3.pendingcb++;
state3.lastBufferedRequest = null;
if (holder.next) {
state3.corkedRequestsFree = holder.next;
holder.next = null;
} else {
state3.corkedRequestsFree = new CorkedRequest(state3);
}
state3.bufferedRequestCount = 0;
} else {
while (entry) {
var chunk = entry.chunk;
var encoding = entry.encoding;
var cb = entry.callback;
var len = state3.objectMode ? 1 : chunk.length;
doWrite(stream, state3, false, len, chunk, encoding, cb);
entry = entry.next;
state3.bufferedRequestCount--;
if (state3.writing) {
break;
}
}
if (entry === null) state3.lastBufferedRequest = null;
}
state3.bufferedRequest = entry;
state3.bufferProcessing = false;
}
Writable.prototype._write = function(chunk, encoding, cb) {
cb(new ERR_METHOD_NOT_IMPLEMENTED("_write()"));
};
Writable.prototype._writev = null;
Writable.prototype.end = function(chunk, encoding, cb) {
var state3 = 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 (state3.corked) {
state3.corked = 1;
this.uncork();
}
if (!state3.ending) endWritable(this, state3, cb);
return this;
};
Object.defineProperty(Writable.prototype, "writableLength", {
// making it explicit this property is not enumerable
// because otherwise some prototype manipulation in
// userland will fail
enumerable: false,
get: function get3() {
return this._writableState.length;
}
});
function needFinish(state3) {
return state3.ending && state3.length === 0 && state3.bufferedRequest === null && !state3.finished && !state3.writing;
}
function callFinal(stream, state3) {
stream._final(function(err) {
state3.pendingcb--;
if (err) {
errorOrDestroy(stream, err);
}
state3.prefinished = true;
stream.emit("prefinish");
finishMaybe(stream, state3);
});
}
function prefinish(stream, state3) {
if (!state3.prefinished && !state3.finalCalled) {
if (typeof stream._final === "function" && !state3.destroyed) {
state3.pendingcb++;
state3.finalCalled = true;
process.nextTick(callFinal, stream, state3);
} else {
state3.prefinished = true;
stream.emit("prefinish");
}
}
}
function finishMaybe(stream, state3) {
var need = needFinish(state3);
if (need) {
prefinish(stream, state3);
if (state3.pendingcb === 0) {
state3.finished = true;
stream.emit("finish");
if (state3.autoDestroy) {
var rState = stream._readableState;
if (!rState || rState.autoDestroy && rState.endEmitted) {
stream.destroy();
}
}
}
}
return need;
}
function endWritable(stream, state3, cb) {
state3.ending = true;
finishMaybe(stream, state3);
if (cb) {
if (state3.finished) process.nextTick(cb);
else stream.once("finish", cb);
}
state3.ended = true;
stream.writable = false;
}
function onCorkedFinish(corkReq, state3, err) {
var entry = corkReq.entry;
corkReq.entry = null;
while (entry) {
var cb = entry.callback;
state3.pendingcb--;
cb(err);
entry = entry.next;
}
state3.corkedRequestsFree.next = corkReq;
}
Object.defineProperty(Writable.prototype, "destroyed", {
// making it explicit this property is not enumerable
// because otherwise some prototype manipulation in
// userland will fail
enumerable: false,
get: function get3() {
if (this._writableState === void 0) {
return false;
}
return this._writableState.destroyed;
},
set: function set(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) {
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 objectKeys = Object.keys || function(obj) {
var keys2 = [];
for (var key in obj) keys2.push(key);
return keys2;
};
module2.exports = Duplex;
var Readable = require_stream_readable();
var Writable = require_stream_writable();
require_inherits()(Duplex, Readable);
{
keys = objectKeys(Writable.prototype);
for (v4 = 0; v4 < keys.length; v4++) {
method = keys[v4];
if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
}
}
var keys;
var method;
var v4;
function Duplex(options) {
if (!(this instanceof Duplex)) return new Duplex(options);
Readable.call(this, options);
Writable.call(this, options);
this.allowHalfOpen = true;
if (options) {
if (options.readable === false) this.readable = false;
if (options.writable === false) this.writable = false;
if (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 get3() {
return this._writableState.highWaterMark;
}
});
Object.defineProperty(Duplex.prototype, "writableBuffer", {
// making it explicit this property is not enumerable
// because otherwise some prototype manipulation in
// userland will fail
enumerable: false,
get: function get3() {
return this._writableState && this._writableState.getBuffer();
}
});
Object.defineProperty(Duplex.prototype, "writableLength", {
// making it explicit this property is not enumerable
// because otherwise some prototype manipulation in
// userland will fail
enumerable: false,
get: function get3() {
return this._writableState.length;
}
});
function onend() {
if (this._writableState.ended) return;
process.nextTick(onEndNT, this);
}
function onEndNT(self2) {
self2.end();
}
Object.defineProperty(Duplex.prototype, "destroyed", {
// making it explicit this property is not enumerable
// because otherwise some prototype manipulation in
// userland will fail
enumerable: false,
get: function get3() {
if (this._readableState === void 0 || this._writableState === void 0) {
return false;
}
return this._readableState.destroyed && this._writableState.destroyed;
},
set: function set(value) {
if (this._readableState === void 0 || this._writableState === void 0) {
return;
}
this._readableState.destroyed = value;
this._writableState.destroyed = value;
}
});
}
});
// ../../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);
}
SafeBuffer.prototype = Object.create(Buffer2.prototype);
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/string_decoder/lib/string_decoder.js
var require_string_decoder = __commonJS({
"../../node_modules/string_decoder/lib/string_decoder.js"(exports2) {
"use strict";
var Buffer2 = require_safe_buffer().Buffer;
var isEncoding = Buffer2.isEncoding || function(encoding) {
encoding = "" + encoding;
switch (encoding && encoding.toLowerCase()) {
case "hex":
case "utf8":
case "utf-8":
case "ascii":
case "binary":
case "base64":
case "ucs2":
case "ucs-2":
case "utf16le":
case "utf-16le":
case "raw":
return true;
default:
return false;
}
};
function _normalizeEncoding(enc) {
if (!enc) return "utf8";
var retried;
while (true) {
switch (enc) {
case "utf8":
case "utf-8":
return "utf8";
case "ucs2":
case "ucs-2":
case "utf16le":
case "utf-16le":
return "utf16le";
case "latin1":
case "binary":
return "latin1";
case "base64":
case "ascii":
case "hex":
return enc;
default:
if (retried) return;
enc = ("" + enc).toLowerCase();
retried = true;
}
}
}
function normalizeEncoding(enc) {
var nenc = _normalizeEncoding(enc);
if (typeof nenc !== "string" && (Buffer2.isEncoding === isEncoding || !isEncoding(enc))) throw new Error("Unknown encoding: " + enc);
return nenc || enc;
}
exports2.StringDecoder = StringDecoder;
function StringDecoder(encoding) {
this.encoding = normalizeEncoding(encoding);
var nb;
switch (this.encoding) {
case "utf16le":
this.text = utf16Text;
this.end = utf16End;
nb = 4;
break;
case "utf8":
this.fillLast = utf8FillLast;
nb = 4;
break;
case "base64":
this.text = base64Text;
this.end = base64End;
nb = 3;
break;
default:
this.write = simpleWrite;
this.end = simpleEnd;
return;
}
this.lastNeed = 0;
this.lastTotal = 0;
this.lastChar = Buffer2.allocUnsafe(nb);
}
StringDecoder.prototype.write = function(buf) {
if (buf.length === 0) return "";
var r4;
var i4;
if (this.lastNeed) {
r4 = this.fillLast(buf);
if (r4 === void 0) return "";
i4 = this.lastNeed;
this.lastNeed = 0;
} else {
i4 = 0;
}
if (i4 < buf.length) return r4 ? r4 + this.text(buf, i4) : this.text(buf, i4);
return r4 || "";
};
StringDecoder.prototype.end = utf8End;
StringDecoder.prototype.text = utf8Text;
StringDecoder.prototype.fillLast = function(buf) {
if (this.lastNeed <= buf.length) {
buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);
return this.lastChar.toString(this.encoding, 0, this.lastTotal);
}
buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);
this.lastNeed -= buf.length;
};
function utf8CheckByte(byte) {
if (byte <= 127) return 0;
else if (byte >> 5 === 6) return 2;
else if (byte >> 4 === 14) return 3;
else if (byte >> 3 === 30) return 4;
return byte >> 6 === 2 ? -1 : -2;
}
function utf8CheckIncomplete(self2, buf, i4) {
var j4 = buf.length - 1;
if (j4 < i4) return 0;
var nb = utf8CheckByte(buf[j4]);
if (nb >= 0) {
if (nb > 0) self2.lastNeed = nb - 1;
return nb;
}
if (--j4 < i4 || nb === -2) return 0;
nb = utf8CheckByte(buf[j4]);
if (nb >= 0) {
if (nb > 0) self2.lastNeed = nb - 2;
return nb;
}
if (--j4 < i4 || nb === -2) return 0;
nb = utf8CheckByte(buf[j4]);
if (nb >= 0) {
if (nb > 0) {
if (nb === 2) nb = 0;
else self2.lastNeed = nb - 3;
}
return nb;
}
return 0;
}
function utf8CheckExtraBytes(self2, buf, p4) {
if ((buf[0] & 192) !== 128) {
self2.lastNeed = 0;
return "\uFFFD";
}
if (self2.lastNeed > 1 && buf.length > 1) {
if ((buf[1] & 192) !== 128) {
self2.lastNeed = 1;
return "\uFFFD";
}
if (self2.lastNeed > 2 && buf.length > 2) {
if ((buf[2] & 192) !== 128) {
self2.lastNeed = 2;
return "\uFFFD";
}
}
}
}
function utf8FillLast(buf) {
var p4 = this.lastTotal - this.lastNeed;
var r4 = utf8CheckExtraBytes(this, buf, p4);
if (r4 !== void 0) return r4;
if (this.lastNeed <= buf.length) {
buf.copy(this.lastChar, p4, 0, this.lastNeed);
return this.lastChar.toString(this.encoding, 0, this.lastTotal);
}
buf.copy(this.lastChar, p4, 0, buf.length);
this.lastNeed -= buf.length;
}
function utf8Text(buf, i4) {
var total = utf8CheckIncomplete(this, buf, i4);
if (!this.lastNeed) return buf.toString("utf8", i4);
this.lastTotal = total;
var end = buf.length - (total - this.lastNeed);
buf.copy(this.lastChar, 0, end);
return buf.toString("utf8", i4, end);
}
function utf8End(buf) {
var r4 = buf && buf.length ? this.write(buf) : "";
if (this.lastNeed) return r4 + "\uFFFD";
return r4;
}
function utf16Text(buf, i4) {
if ((buf.length - i4) % 2 === 0) {
var r4 = buf.toString("utf16le", i4);
if (r4) {
var c4 = r4.charCodeAt(r4.length - 1);
if (c4 >= 55296 && c4 <= 56319) {
this.lastNeed = 2;
this.lastTotal = 4;
this.lastChar[0] = buf[buf.length - 2];
this.lastChar[1] = buf[buf.length - 1];
return r4.slice(0, -1);
}
}
return r4;
}
this.lastNeed = 1;
this.lastTotal = 2;
this.lastChar[0] = buf[buf.length - 1];
return buf.toString("utf16le", i4, buf.length - 1);
}
function utf16End(buf) {
var r4 = buf && buf.length ? this.write(buf) : "";
if (this.lastNeed) {
var end = this.lastTotal - this.lastNeed;
return r4 + this.lastChar.toString("utf16le", 0, end);
}
return r4;
}
function base64Text(buf, i4) {
var n4 = (buf.length - i4) % 3;
if (n4 === 0) return buf.toString("base64", i4);
this.lastNeed = 3 - n4;
this.lastTotal = 3;
if (n4 === 1) {
this.lastChar[0] = buf[buf.length - 1];
} else {
this.lastChar[0] = buf[buf.length - 2];
this.lastChar[1] = buf[buf.length - 1];
}
return buf.toString("base64", i4, buf.length - n4);
}
function base64End(buf) {
var r4 = buf && buf.length ? this.write(buf) : "";
if (this.lastNeed) return r4 + this.lastChar.toString("base64", 0, 3 - this.lastNeed);
return r4;
}
function simpleWrite(buf) {
return buf.toString(this.encoding);
}
function simpleEnd(buf) {
return buf && buf.length ? this.write(buf) : "";
}
}
});
// ../../node_modules/readable-stream/lib/internal/streams/end-of-stream.js
var require_end_of_stream = __commonJS({
"../../node_modules/readable-stream/lib/internal/streams/end-of-stream.js"(exports2, module2) {
"use strict";
var ERR_STREAM_PREMATURE_CLOSE = require_errors().codes.ERR_STREAM_PREMATURE_CLOSE;
function once(callback) {
var called = false;
return function() {
if (called) return;
called = true;
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
callback.apply(this, args);
};
}
function noop() {
}
function isRequest(stream) {
return stream.setHeader && typeof stream.abort === "function";
}
function eos(stream, opts, callback) {
i