@c-rex/core 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +70 -0
- package/dist/index.d.ts +70 -0
- package/dist/index.js +3022 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +3014 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +37 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,3022 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
+
};
|
|
11
|
+
var __export = (target, all) => {
|
|
12
|
+
for (var name in all)
|
|
13
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from))
|
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
+
mod
|
|
30
|
+
));
|
|
31
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
|
+
|
|
33
|
+
// ../../node_modules/util-deprecate/node.js
|
|
34
|
+
var require_node = __commonJS({
|
|
35
|
+
"../../node_modules/util-deprecate/node.js"(exports2, module2) {
|
|
36
|
+
"use strict";
|
|
37
|
+
module2.exports = require("util").deprecate;
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// ../../node_modules/readable-stream/lib/internal/streams/stream.js
|
|
42
|
+
var require_stream = __commonJS({
|
|
43
|
+
"../../node_modules/readable-stream/lib/internal/streams/stream.js"(exports2, module2) {
|
|
44
|
+
"use strict";
|
|
45
|
+
module2.exports = require("stream");
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// ../../node_modules/readable-stream/lib/internal/streams/destroy.js
|
|
50
|
+
var require_destroy = __commonJS({
|
|
51
|
+
"../../node_modules/readable-stream/lib/internal/streams/destroy.js"(exports2, module2) {
|
|
52
|
+
"use strict";
|
|
53
|
+
function destroy(err, cb) {
|
|
54
|
+
var _this = this;
|
|
55
|
+
var readableDestroyed = this._readableState && this._readableState.destroyed;
|
|
56
|
+
var writableDestroyed = this._writableState && this._writableState.destroyed;
|
|
57
|
+
if (readableDestroyed || writableDestroyed) {
|
|
58
|
+
if (cb) {
|
|
59
|
+
cb(err);
|
|
60
|
+
} else if (err) {
|
|
61
|
+
if (!this._writableState) {
|
|
62
|
+
process.nextTick(emitErrorNT, this, err);
|
|
63
|
+
} else if (!this._writableState.errorEmitted) {
|
|
64
|
+
this._writableState.errorEmitted = true;
|
|
65
|
+
process.nextTick(emitErrorNT, this, err);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return this;
|
|
69
|
+
}
|
|
70
|
+
if (this._readableState) {
|
|
71
|
+
this._readableState.destroyed = true;
|
|
72
|
+
}
|
|
73
|
+
if (this._writableState) {
|
|
74
|
+
this._writableState.destroyed = true;
|
|
75
|
+
}
|
|
76
|
+
this._destroy(err || null, function(err2) {
|
|
77
|
+
if (!cb && err2) {
|
|
78
|
+
if (!_this._writableState) {
|
|
79
|
+
process.nextTick(emitErrorAndCloseNT, _this, err2);
|
|
80
|
+
} else if (!_this._writableState.errorEmitted) {
|
|
81
|
+
_this._writableState.errorEmitted = true;
|
|
82
|
+
process.nextTick(emitErrorAndCloseNT, _this, err2);
|
|
83
|
+
} else {
|
|
84
|
+
process.nextTick(emitCloseNT, _this);
|
|
85
|
+
}
|
|
86
|
+
} else if (cb) {
|
|
87
|
+
process.nextTick(emitCloseNT, _this);
|
|
88
|
+
cb(err2);
|
|
89
|
+
} else {
|
|
90
|
+
process.nextTick(emitCloseNT, _this);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
return this;
|
|
94
|
+
}
|
|
95
|
+
function emitErrorAndCloseNT(self2, err) {
|
|
96
|
+
emitErrorNT(self2, err);
|
|
97
|
+
emitCloseNT(self2);
|
|
98
|
+
}
|
|
99
|
+
function emitCloseNT(self2) {
|
|
100
|
+
if (self2._writableState && !self2._writableState.emitClose) return;
|
|
101
|
+
if (self2._readableState && !self2._readableState.emitClose) return;
|
|
102
|
+
self2.emit("close");
|
|
103
|
+
}
|
|
104
|
+
function undestroy() {
|
|
105
|
+
if (this._readableState) {
|
|
106
|
+
this._readableState.destroyed = false;
|
|
107
|
+
this._readableState.reading = false;
|
|
108
|
+
this._readableState.ended = false;
|
|
109
|
+
this._readableState.endEmitted = false;
|
|
110
|
+
}
|
|
111
|
+
if (this._writableState) {
|
|
112
|
+
this._writableState.destroyed = false;
|
|
113
|
+
this._writableState.ended = false;
|
|
114
|
+
this._writableState.ending = false;
|
|
115
|
+
this._writableState.finalCalled = false;
|
|
116
|
+
this._writableState.prefinished = false;
|
|
117
|
+
this._writableState.finished = false;
|
|
118
|
+
this._writableState.errorEmitted = false;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
function emitErrorNT(self2, err) {
|
|
122
|
+
self2.emit("error", err);
|
|
123
|
+
}
|
|
124
|
+
function errorOrDestroy(stream, err) {
|
|
125
|
+
var rState = stream._readableState;
|
|
126
|
+
var wState = stream._writableState;
|
|
127
|
+
if (rState && rState.autoDestroy || wState && wState.autoDestroy) stream.destroy(err);
|
|
128
|
+
else stream.emit("error", err);
|
|
129
|
+
}
|
|
130
|
+
module2.exports = {
|
|
131
|
+
destroy,
|
|
132
|
+
undestroy,
|
|
133
|
+
errorOrDestroy
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
// ../../node_modules/readable-stream/errors.js
|
|
139
|
+
var require_errors = __commonJS({
|
|
140
|
+
"../../node_modules/readable-stream/errors.js"(exports2, module2) {
|
|
141
|
+
"use strict";
|
|
142
|
+
var codes = {};
|
|
143
|
+
function createErrorType(code, message, Base) {
|
|
144
|
+
if (!Base) {
|
|
145
|
+
Base = Error;
|
|
146
|
+
}
|
|
147
|
+
function getMessage(arg1, arg2, arg3) {
|
|
148
|
+
if (typeof message === "string") {
|
|
149
|
+
return message;
|
|
150
|
+
} else {
|
|
151
|
+
return message(arg1, arg2, arg3);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
class NodeError extends Base {
|
|
155
|
+
constructor(arg1, arg2, arg3) {
|
|
156
|
+
super(getMessage(arg1, arg2, arg3));
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
NodeError.prototype.name = Base.name;
|
|
160
|
+
NodeError.prototype.code = code;
|
|
161
|
+
codes[code] = NodeError;
|
|
162
|
+
}
|
|
163
|
+
function oneOf(expected, thing) {
|
|
164
|
+
if (Array.isArray(expected)) {
|
|
165
|
+
const len = expected.length;
|
|
166
|
+
expected = expected.map((i) => String(i));
|
|
167
|
+
if (len > 2) {
|
|
168
|
+
return `one of ${thing} ${expected.slice(0, len - 1).join(", ")}, or ` + expected[len - 1];
|
|
169
|
+
} else if (len === 2) {
|
|
170
|
+
return `one of ${thing} ${expected[0]} or ${expected[1]}`;
|
|
171
|
+
} else {
|
|
172
|
+
return `of ${thing} ${expected[0]}`;
|
|
173
|
+
}
|
|
174
|
+
} else {
|
|
175
|
+
return `of ${thing} ${String(expected)}`;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
function startsWith(str, search, pos) {
|
|
179
|
+
return str.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search;
|
|
180
|
+
}
|
|
181
|
+
function endsWith(str, search, this_len) {
|
|
182
|
+
if (this_len === void 0 || this_len > str.length) {
|
|
183
|
+
this_len = str.length;
|
|
184
|
+
}
|
|
185
|
+
return str.substring(this_len - search.length, this_len) === search;
|
|
186
|
+
}
|
|
187
|
+
function includes(str, search, start) {
|
|
188
|
+
if (typeof start !== "number") {
|
|
189
|
+
start = 0;
|
|
190
|
+
}
|
|
191
|
+
if (start + search.length > str.length) {
|
|
192
|
+
return false;
|
|
193
|
+
} else {
|
|
194
|
+
return str.indexOf(search, start) !== -1;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
createErrorType("ERR_INVALID_OPT_VALUE", function(name, value) {
|
|
198
|
+
return 'The value "' + value + '" is invalid for option "' + name + '"';
|
|
199
|
+
}, TypeError);
|
|
200
|
+
createErrorType("ERR_INVALID_ARG_TYPE", function(name, expected, actual) {
|
|
201
|
+
let determiner;
|
|
202
|
+
if (typeof expected === "string" && startsWith(expected, "not ")) {
|
|
203
|
+
determiner = "must not be";
|
|
204
|
+
expected = expected.replace(/^not /, "");
|
|
205
|
+
} else {
|
|
206
|
+
determiner = "must be";
|
|
207
|
+
}
|
|
208
|
+
let msg;
|
|
209
|
+
if (endsWith(name, " argument")) {
|
|
210
|
+
msg = `The ${name} ${determiner} ${oneOf(expected, "type")}`;
|
|
211
|
+
} else {
|
|
212
|
+
const type = includes(name, ".") ? "property" : "argument";
|
|
213
|
+
msg = `The "${name}" ${type} ${determiner} ${oneOf(expected, "type")}`;
|
|
214
|
+
}
|
|
215
|
+
msg += `. Received type ${typeof actual}`;
|
|
216
|
+
return msg;
|
|
217
|
+
}, TypeError);
|
|
218
|
+
createErrorType("ERR_STREAM_PUSH_AFTER_EOF", "stream.push() after EOF");
|
|
219
|
+
createErrorType("ERR_METHOD_NOT_IMPLEMENTED", function(name) {
|
|
220
|
+
return "The " + name + " method is not implemented";
|
|
221
|
+
});
|
|
222
|
+
createErrorType("ERR_STREAM_PREMATURE_CLOSE", "Premature close");
|
|
223
|
+
createErrorType("ERR_STREAM_DESTROYED", function(name) {
|
|
224
|
+
return "Cannot call " + name + " after a stream was destroyed";
|
|
225
|
+
});
|
|
226
|
+
createErrorType("ERR_MULTIPLE_CALLBACK", "Callback called multiple times");
|
|
227
|
+
createErrorType("ERR_STREAM_CANNOT_PIPE", "Cannot pipe, not readable");
|
|
228
|
+
createErrorType("ERR_STREAM_WRITE_AFTER_END", "write after end");
|
|
229
|
+
createErrorType("ERR_STREAM_NULL_VALUES", "May not write null values to stream", TypeError);
|
|
230
|
+
createErrorType("ERR_UNKNOWN_ENCODING", function(arg) {
|
|
231
|
+
return "Unknown encoding: " + arg;
|
|
232
|
+
}, TypeError);
|
|
233
|
+
createErrorType("ERR_STREAM_UNSHIFT_AFTER_END_EVENT", "stream.unshift() after end event");
|
|
234
|
+
module2.exports.codes = codes;
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
// ../../node_modules/readable-stream/lib/internal/streams/state.js
|
|
239
|
+
var require_state = __commonJS({
|
|
240
|
+
"../../node_modules/readable-stream/lib/internal/streams/state.js"(exports2, module2) {
|
|
241
|
+
"use strict";
|
|
242
|
+
var ERR_INVALID_OPT_VALUE = require_errors().codes.ERR_INVALID_OPT_VALUE;
|
|
243
|
+
function highWaterMarkFrom(options, isDuplex, duplexKey) {
|
|
244
|
+
return options.highWaterMark != null ? options.highWaterMark : isDuplex ? options[duplexKey] : null;
|
|
245
|
+
}
|
|
246
|
+
function getHighWaterMark(state, options, duplexKey, isDuplex) {
|
|
247
|
+
var hwm = highWaterMarkFrom(options, isDuplex, duplexKey);
|
|
248
|
+
if (hwm != null) {
|
|
249
|
+
if (!(isFinite(hwm) && Math.floor(hwm) === hwm) || hwm < 0) {
|
|
250
|
+
var name = isDuplex ? duplexKey : "highWaterMark";
|
|
251
|
+
throw new ERR_INVALID_OPT_VALUE(name, hwm);
|
|
252
|
+
}
|
|
253
|
+
return Math.floor(hwm);
|
|
254
|
+
}
|
|
255
|
+
return state.objectMode ? 16 : 16 * 1024;
|
|
256
|
+
}
|
|
257
|
+
module2.exports = {
|
|
258
|
+
getHighWaterMark
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
// ../../node_modules/inherits/inherits_browser.js
|
|
264
|
+
var require_inherits_browser = __commonJS({
|
|
265
|
+
"../../node_modules/inherits/inherits_browser.js"(exports2, module2) {
|
|
266
|
+
"use strict";
|
|
267
|
+
if (typeof Object.create === "function") {
|
|
268
|
+
module2.exports = function inherits(ctor, superCtor) {
|
|
269
|
+
if (superCtor) {
|
|
270
|
+
ctor.super_ = superCtor;
|
|
271
|
+
ctor.prototype = Object.create(superCtor.prototype, {
|
|
272
|
+
constructor: {
|
|
273
|
+
value: ctor,
|
|
274
|
+
enumerable: false,
|
|
275
|
+
writable: true,
|
|
276
|
+
configurable: true
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
} else {
|
|
282
|
+
module2.exports = function inherits(ctor, superCtor) {
|
|
283
|
+
if (superCtor) {
|
|
284
|
+
ctor.super_ = superCtor;
|
|
285
|
+
var TempCtor = function() {
|
|
286
|
+
};
|
|
287
|
+
TempCtor.prototype = superCtor.prototype;
|
|
288
|
+
ctor.prototype = new TempCtor();
|
|
289
|
+
ctor.prototype.constructor = ctor;
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
// ../../node_modules/inherits/inherits.js
|
|
297
|
+
var require_inherits = __commonJS({
|
|
298
|
+
"../../node_modules/inherits/inherits.js"(exports2, module2) {
|
|
299
|
+
"use strict";
|
|
300
|
+
try {
|
|
301
|
+
util = require("util");
|
|
302
|
+
if (typeof util.inherits !== "function") throw "";
|
|
303
|
+
module2.exports = util.inherits;
|
|
304
|
+
} catch (e) {
|
|
305
|
+
module2.exports = require_inherits_browser();
|
|
306
|
+
}
|
|
307
|
+
var util;
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
// ../../node_modules/readable-stream/lib/internal/streams/buffer_list.js
|
|
312
|
+
var require_buffer_list = __commonJS({
|
|
313
|
+
"../../node_modules/readable-stream/lib/internal/streams/buffer_list.js"(exports2, module2) {
|
|
314
|
+
"use strict";
|
|
315
|
+
function ownKeys(object, enumerableOnly) {
|
|
316
|
+
var keys = Object.keys(object);
|
|
317
|
+
if (Object.getOwnPropertySymbols) {
|
|
318
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
319
|
+
enumerableOnly && (symbols = symbols.filter(function(sym) {
|
|
320
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
321
|
+
})), keys.push.apply(keys, symbols);
|
|
322
|
+
}
|
|
323
|
+
return keys;
|
|
324
|
+
}
|
|
325
|
+
function _objectSpread(target) {
|
|
326
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
327
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
328
|
+
i % 2 ? ownKeys(Object(source), true).forEach(function(key) {
|
|
329
|
+
_defineProperty(target, key, source[key]);
|
|
330
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
|
|
331
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
return target;
|
|
335
|
+
}
|
|
336
|
+
function _defineProperty(obj, key, value) {
|
|
337
|
+
key = _toPropertyKey(key);
|
|
338
|
+
if (key in obj) {
|
|
339
|
+
Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
|
|
340
|
+
} else {
|
|
341
|
+
obj[key] = value;
|
|
342
|
+
}
|
|
343
|
+
return obj;
|
|
344
|
+
}
|
|
345
|
+
function _classCallCheck(instance, Constructor) {
|
|
346
|
+
if (!(instance instanceof Constructor)) {
|
|
347
|
+
throw new TypeError("Cannot call a class as a function");
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
function _defineProperties(target, props) {
|
|
351
|
+
for (var i = 0; i < props.length; i++) {
|
|
352
|
+
var descriptor = props[i];
|
|
353
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
354
|
+
descriptor.configurable = true;
|
|
355
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
356
|
+
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
360
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
361
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
362
|
+
Object.defineProperty(Constructor, "prototype", { writable: false });
|
|
363
|
+
return Constructor;
|
|
364
|
+
}
|
|
365
|
+
function _toPropertyKey(arg) {
|
|
366
|
+
var key = _toPrimitive(arg, "string");
|
|
367
|
+
return typeof key === "symbol" ? key : String(key);
|
|
368
|
+
}
|
|
369
|
+
function _toPrimitive(input, hint) {
|
|
370
|
+
if (typeof input !== "object" || input === null) return input;
|
|
371
|
+
var prim = input[Symbol.toPrimitive];
|
|
372
|
+
if (prim !== void 0) {
|
|
373
|
+
var res = prim.call(input, hint || "default");
|
|
374
|
+
if (typeof res !== "object") return res;
|
|
375
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
376
|
+
}
|
|
377
|
+
return (hint === "string" ? String : Number)(input);
|
|
378
|
+
}
|
|
379
|
+
var _require = require("buffer");
|
|
380
|
+
var Buffer2 = _require.Buffer;
|
|
381
|
+
var _require2 = require("util");
|
|
382
|
+
var inspect = _require2.inspect;
|
|
383
|
+
var custom = inspect && inspect.custom || "inspect";
|
|
384
|
+
function copyBuffer(src, target, offset) {
|
|
385
|
+
Buffer2.prototype.copy.call(src, target, offset);
|
|
386
|
+
}
|
|
387
|
+
module2.exports = /* @__PURE__ */ function() {
|
|
388
|
+
function BufferList() {
|
|
389
|
+
_classCallCheck(this, BufferList);
|
|
390
|
+
this.head = null;
|
|
391
|
+
this.tail = null;
|
|
392
|
+
this.length = 0;
|
|
393
|
+
}
|
|
394
|
+
_createClass(BufferList, [{
|
|
395
|
+
key: "push",
|
|
396
|
+
value: function push(v) {
|
|
397
|
+
var entry = {
|
|
398
|
+
data: v,
|
|
399
|
+
next: null
|
|
400
|
+
};
|
|
401
|
+
if (this.length > 0) this.tail.next = entry;
|
|
402
|
+
else this.head = entry;
|
|
403
|
+
this.tail = entry;
|
|
404
|
+
++this.length;
|
|
405
|
+
}
|
|
406
|
+
}, {
|
|
407
|
+
key: "unshift",
|
|
408
|
+
value: function unshift(v) {
|
|
409
|
+
var entry = {
|
|
410
|
+
data: v,
|
|
411
|
+
next: this.head
|
|
412
|
+
};
|
|
413
|
+
if (this.length === 0) this.tail = entry;
|
|
414
|
+
this.head = entry;
|
|
415
|
+
++this.length;
|
|
416
|
+
}
|
|
417
|
+
}, {
|
|
418
|
+
key: "shift",
|
|
419
|
+
value: function shift() {
|
|
420
|
+
if (this.length === 0) return;
|
|
421
|
+
var ret = this.head.data;
|
|
422
|
+
if (this.length === 1) this.head = this.tail = null;
|
|
423
|
+
else this.head = this.head.next;
|
|
424
|
+
--this.length;
|
|
425
|
+
return ret;
|
|
426
|
+
}
|
|
427
|
+
}, {
|
|
428
|
+
key: "clear",
|
|
429
|
+
value: function clear() {
|
|
430
|
+
this.head = this.tail = null;
|
|
431
|
+
this.length = 0;
|
|
432
|
+
}
|
|
433
|
+
}, {
|
|
434
|
+
key: "join",
|
|
435
|
+
value: function join(s) {
|
|
436
|
+
if (this.length === 0) return "";
|
|
437
|
+
var p = this.head;
|
|
438
|
+
var ret = "" + p.data;
|
|
439
|
+
while (p = p.next) ret += s + p.data;
|
|
440
|
+
return ret;
|
|
441
|
+
}
|
|
442
|
+
}, {
|
|
443
|
+
key: "concat",
|
|
444
|
+
value: function concat(n) {
|
|
445
|
+
if (this.length === 0) return Buffer2.alloc(0);
|
|
446
|
+
var ret = Buffer2.allocUnsafe(n >>> 0);
|
|
447
|
+
var p = this.head;
|
|
448
|
+
var i = 0;
|
|
449
|
+
while (p) {
|
|
450
|
+
copyBuffer(p.data, ret, i);
|
|
451
|
+
i += p.data.length;
|
|
452
|
+
p = p.next;
|
|
453
|
+
}
|
|
454
|
+
return ret;
|
|
455
|
+
}
|
|
456
|
+
// Consumes a specified amount of bytes or characters from the buffered data.
|
|
457
|
+
}, {
|
|
458
|
+
key: "consume",
|
|
459
|
+
value: function consume(n, hasStrings) {
|
|
460
|
+
var ret;
|
|
461
|
+
if (n < this.head.data.length) {
|
|
462
|
+
ret = this.head.data.slice(0, n);
|
|
463
|
+
this.head.data = this.head.data.slice(n);
|
|
464
|
+
} else if (n === this.head.data.length) {
|
|
465
|
+
ret = this.shift();
|
|
466
|
+
} else {
|
|
467
|
+
ret = hasStrings ? this._getString(n) : this._getBuffer(n);
|
|
468
|
+
}
|
|
469
|
+
return ret;
|
|
470
|
+
}
|
|
471
|
+
}, {
|
|
472
|
+
key: "first",
|
|
473
|
+
value: function first() {
|
|
474
|
+
return this.head.data;
|
|
475
|
+
}
|
|
476
|
+
// Consumes a specified amount of characters from the buffered data.
|
|
477
|
+
}, {
|
|
478
|
+
key: "_getString",
|
|
479
|
+
value: function _getString(n) {
|
|
480
|
+
var p = this.head;
|
|
481
|
+
var c = 1;
|
|
482
|
+
var ret = p.data;
|
|
483
|
+
n -= ret.length;
|
|
484
|
+
while (p = p.next) {
|
|
485
|
+
var str = p.data;
|
|
486
|
+
var nb = n > str.length ? str.length : n;
|
|
487
|
+
if (nb === str.length) ret += str;
|
|
488
|
+
else ret += str.slice(0, n);
|
|
489
|
+
n -= nb;
|
|
490
|
+
if (n === 0) {
|
|
491
|
+
if (nb === str.length) {
|
|
492
|
+
++c;
|
|
493
|
+
if (p.next) this.head = p.next;
|
|
494
|
+
else this.head = this.tail = null;
|
|
495
|
+
} else {
|
|
496
|
+
this.head = p;
|
|
497
|
+
p.data = str.slice(nb);
|
|
498
|
+
}
|
|
499
|
+
break;
|
|
500
|
+
}
|
|
501
|
+
++c;
|
|
502
|
+
}
|
|
503
|
+
this.length -= c;
|
|
504
|
+
return ret;
|
|
505
|
+
}
|
|
506
|
+
// Consumes a specified amount of bytes from the buffered data.
|
|
507
|
+
}, {
|
|
508
|
+
key: "_getBuffer",
|
|
509
|
+
value: function _getBuffer(n) {
|
|
510
|
+
var ret = Buffer2.allocUnsafe(n);
|
|
511
|
+
var p = this.head;
|
|
512
|
+
var c = 1;
|
|
513
|
+
p.data.copy(ret);
|
|
514
|
+
n -= p.data.length;
|
|
515
|
+
while (p = p.next) {
|
|
516
|
+
var buf = p.data;
|
|
517
|
+
var nb = n > buf.length ? buf.length : n;
|
|
518
|
+
buf.copy(ret, ret.length - n, 0, nb);
|
|
519
|
+
n -= nb;
|
|
520
|
+
if (n === 0) {
|
|
521
|
+
if (nb === buf.length) {
|
|
522
|
+
++c;
|
|
523
|
+
if (p.next) this.head = p.next;
|
|
524
|
+
else this.head = this.tail = null;
|
|
525
|
+
} else {
|
|
526
|
+
this.head = p;
|
|
527
|
+
p.data = buf.slice(nb);
|
|
528
|
+
}
|
|
529
|
+
break;
|
|
530
|
+
}
|
|
531
|
+
++c;
|
|
532
|
+
}
|
|
533
|
+
this.length -= c;
|
|
534
|
+
return ret;
|
|
535
|
+
}
|
|
536
|
+
// Make sure the linked list only shows the minimal necessary information.
|
|
537
|
+
}, {
|
|
538
|
+
key: custom,
|
|
539
|
+
value: function value(_, options) {
|
|
540
|
+
return inspect(this, _objectSpread(_objectSpread({}, options), {}, {
|
|
541
|
+
// Only inspect one level.
|
|
542
|
+
depth: 0,
|
|
543
|
+
// It should not recurse.
|
|
544
|
+
customInspect: false
|
|
545
|
+
}));
|
|
546
|
+
}
|
|
547
|
+
}]);
|
|
548
|
+
return BufferList;
|
|
549
|
+
}();
|
|
550
|
+
}
|
|
551
|
+
});
|
|
552
|
+
|
|
553
|
+
// ../../node_modules/safe-buffer/index.js
|
|
554
|
+
var require_safe_buffer = __commonJS({
|
|
555
|
+
"../../node_modules/safe-buffer/index.js"(exports2, module2) {
|
|
556
|
+
"use strict";
|
|
557
|
+
var buffer = require("buffer");
|
|
558
|
+
var Buffer2 = buffer.Buffer;
|
|
559
|
+
function copyProps(src, dst) {
|
|
560
|
+
for (var key in src) {
|
|
561
|
+
dst[key] = src[key];
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
if (Buffer2.from && Buffer2.alloc && Buffer2.allocUnsafe && Buffer2.allocUnsafeSlow) {
|
|
565
|
+
module2.exports = buffer;
|
|
566
|
+
} else {
|
|
567
|
+
copyProps(buffer, exports2);
|
|
568
|
+
exports2.Buffer = SafeBuffer;
|
|
569
|
+
}
|
|
570
|
+
function SafeBuffer(arg, encodingOrOffset, length) {
|
|
571
|
+
return Buffer2(arg, encodingOrOffset, length);
|
|
572
|
+
}
|
|
573
|
+
SafeBuffer.prototype = Object.create(Buffer2.prototype);
|
|
574
|
+
copyProps(Buffer2, SafeBuffer);
|
|
575
|
+
SafeBuffer.from = function(arg, encodingOrOffset, length) {
|
|
576
|
+
if (typeof arg === "number") {
|
|
577
|
+
throw new TypeError("Argument must not be a number");
|
|
578
|
+
}
|
|
579
|
+
return Buffer2(arg, encodingOrOffset, length);
|
|
580
|
+
};
|
|
581
|
+
SafeBuffer.alloc = function(size, fill, encoding) {
|
|
582
|
+
if (typeof size !== "number") {
|
|
583
|
+
throw new TypeError("Argument must be a number");
|
|
584
|
+
}
|
|
585
|
+
var buf = Buffer2(size);
|
|
586
|
+
if (fill !== void 0) {
|
|
587
|
+
if (typeof encoding === "string") {
|
|
588
|
+
buf.fill(fill, encoding);
|
|
589
|
+
} else {
|
|
590
|
+
buf.fill(fill);
|
|
591
|
+
}
|
|
592
|
+
} else {
|
|
593
|
+
buf.fill(0);
|
|
594
|
+
}
|
|
595
|
+
return buf;
|
|
596
|
+
};
|
|
597
|
+
SafeBuffer.allocUnsafe = function(size) {
|
|
598
|
+
if (typeof size !== "number") {
|
|
599
|
+
throw new TypeError("Argument must be a number");
|
|
600
|
+
}
|
|
601
|
+
return Buffer2(size);
|
|
602
|
+
};
|
|
603
|
+
SafeBuffer.allocUnsafeSlow = function(size) {
|
|
604
|
+
if (typeof size !== "number") {
|
|
605
|
+
throw new TypeError("Argument must be a number");
|
|
606
|
+
}
|
|
607
|
+
return buffer.SlowBuffer(size);
|
|
608
|
+
};
|
|
609
|
+
}
|
|
610
|
+
});
|
|
611
|
+
|
|
612
|
+
// ../../node_modules/string_decoder/lib/string_decoder.js
|
|
613
|
+
var require_string_decoder = __commonJS({
|
|
614
|
+
"../../node_modules/string_decoder/lib/string_decoder.js"(exports2) {
|
|
615
|
+
"use strict";
|
|
616
|
+
var Buffer2 = require_safe_buffer().Buffer;
|
|
617
|
+
var isEncoding = Buffer2.isEncoding || function(encoding) {
|
|
618
|
+
encoding = "" + encoding;
|
|
619
|
+
switch (encoding && encoding.toLowerCase()) {
|
|
620
|
+
case "hex":
|
|
621
|
+
case "utf8":
|
|
622
|
+
case "utf-8":
|
|
623
|
+
case "ascii":
|
|
624
|
+
case "binary":
|
|
625
|
+
case "base64":
|
|
626
|
+
case "ucs2":
|
|
627
|
+
case "ucs-2":
|
|
628
|
+
case "utf16le":
|
|
629
|
+
case "utf-16le":
|
|
630
|
+
case "raw":
|
|
631
|
+
return true;
|
|
632
|
+
default:
|
|
633
|
+
return false;
|
|
634
|
+
}
|
|
635
|
+
};
|
|
636
|
+
function _normalizeEncoding(enc) {
|
|
637
|
+
if (!enc) return "utf8";
|
|
638
|
+
var retried;
|
|
639
|
+
while (true) {
|
|
640
|
+
switch (enc) {
|
|
641
|
+
case "utf8":
|
|
642
|
+
case "utf-8":
|
|
643
|
+
return "utf8";
|
|
644
|
+
case "ucs2":
|
|
645
|
+
case "ucs-2":
|
|
646
|
+
case "utf16le":
|
|
647
|
+
case "utf-16le":
|
|
648
|
+
return "utf16le";
|
|
649
|
+
case "latin1":
|
|
650
|
+
case "binary":
|
|
651
|
+
return "latin1";
|
|
652
|
+
case "base64":
|
|
653
|
+
case "ascii":
|
|
654
|
+
case "hex":
|
|
655
|
+
return enc;
|
|
656
|
+
default:
|
|
657
|
+
if (retried) return;
|
|
658
|
+
enc = ("" + enc).toLowerCase();
|
|
659
|
+
retried = true;
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
function normalizeEncoding(enc) {
|
|
664
|
+
var nenc = _normalizeEncoding(enc);
|
|
665
|
+
if (typeof nenc !== "string" && (Buffer2.isEncoding === isEncoding || !isEncoding(enc))) throw new Error("Unknown encoding: " + enc);
|
|
666
|
+
return nenc || enc;
|
|
667
|
+
}
|
|
668
|
+
exports2.StringDecoder = StringDecoder;
|
|
669
|
+
function StringDecoder(encoding) {
|
|
670
|
+
this.encoding = normalizeEncoding(encoding);
|
|
671
|
+
var nb;
|
|
672
|
+
switch (this.encoding) {
|
|
673
|
+
case "utf16le":
|
|
674
|
+
this.text = utf16Text;
|
|
675
|
+
this.end = utf16End;
|
|
676
|
+
nb = 4;
|
|
677
|
+
break;
|
|
678
|
+
case "utf8":
|
|
679
|
+
this.fillLast = utf8FillLast;
|
|
680
|
+
nb = 4;
|
|
681
|
+
break;
|
|
682
|
+
case "base64":
|
|
683
|
+
this.text = base64Text;
|
|
684
|
+
this.end = base64End;
|
|
685
|
+
nb = 3;
|
|
686
|
+
break;
|
|
687
|
+
default:
|
|
688
|
+
this.write = simpleWrite;
|
|
689
|
+
this.end = simpleEnd;
|
|
690
|
+
return;
|
|
691
|
+
}
|
|
692
|
+
this.lastNeed = 0;
|
|
693
|
+
this.lastTotal = 0;
|
|
694
|
+
this.lastChar = Buffer2.allocUnsafe(nb);
|
|
695
|
+
}
|
|
696
|
+
StringDecoder.prototype.write = function(buf) {
|
|
697
|
+
if (buf.length === 0) return "";
|
|
698
|
+
var r;
|
|
699
|
+
var i;
|
|
700
|
+
if (this.lastNeed) {
|
|
701
|
+
r = this.fillLast(buf);
|
|
702
|
+
if (r === void 0) return "";
|
|
703
|
+
i = this.lastNeed;
|
|
704
|
+
this.lastNeed = 0;
|
|
705
|
+
} else {
|
|
706
|
+
i = 0;
|
|
707
|
+
}
|
|
708
|
+
if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i);
|
|
709
|
+
return r || "";
|
|
710
|
+
};
|
|
711
|
+
StringDecoder.prototype.end = utf8End;
|
|
712
|
+
StringDecoder.prototype.text = utf8Text;
|
|
713
|
+
StringDecoder.prototype.fillLast = function(buf) {
|
|
714
|
+
if (this.lastNeed <= buf.length) {
|
|
715
|
+
buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);
|
|
716
|
+
return this.lastChar.toString(this.encoding, 0, this.lastTotal);
|
|
717
|
+
}
|
|
718
|
+
buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);
|
|
719
|
+
this.lastNeed -= buf.length;
|
|
720
|
+
};
|
|
721
|
+
function utf8CheckByte(byte) {
|
|
722
|
+
if (byte <= 127) return 0;
|
|
723
|
+
else if (byte >> 5 === 6) return 2;
|
|
724
|
+
else if (byte >> 4 === 14) return 3;
|
|
725
|
+
else if (byte >> 3 === 30) return 4;
|
|
726
|
+
return byte >> 6 === 2 ? -1 : -2;
|
|
727
|
+
}
|
|
728
|
+
function utf8CheckIncomplete(self2, buf, i) {
|
|
729
|
+
var j = buf.length - 1;
|
|
730
|
+
if (j < i) return 0;
|
|
731
|
+
var nb = utf8CheckByte(buf[j]);
|
|
732
|
+
if (nb >= 0) {
|
|
733
|
+
if (nb > 0) self2.lastNeed = nb - 1;
|
|
734
|
+
return nb;
|
|
735
|
+
}
|
|
736
|
+
if (--j < i || nb === -2) return 0;
|
|
737
|
+
nb = utf8CheckByte(buf[j]);
|
|
738
|
+
if (nb >= 0) {
|
|
739
|
+
if (nb > 0) self2.lastNeed = nb - 2;
|
|
740
|
+
return nb;
|
|
741
|
+
}
|
|
742
|
+
if (--j < i || nb === -2) return 0;
|
|
743
|
+
nb = utf8CheckByte(buf[j]);
|
|
744
|
+
if (nb >= 0) {
|
|
745
|
+
if (nb > 0) {
|
|
746
|
+
if (nb === 2) nb = 0;
|
|
747
|
+
else self2.lastNeed = nb - 3;
|
|
748
|
+
}
|
|
749
|
+
return nb;
|
|
750
|
+
}
|
|
751
|
+
return 0;
|
|
752
|
+
}
|
|
753
|
+
function utf8CheckExtraBytes(self2, buf, p) {
|
|
754
|
+
if ((buf[0] & 192) !== 128) {
|
|
755
|
+
self2.lastNeed = 0;
|
|
756
|
+
return "\uFFFD";
|
|
757
|
+
}
|
|
758
|
+
if (self2.lastNeed > 1 && buf.length > 1) {
|
|
759
|
+
if ((buf[1] & 192) !== 128) {
|
|
760
|
+
self2.lastNeed = 1;
|
|
761
|
+
return "\uFFFD";
|
|
762
|
+
}
|
|
763
|
+
if (self2.lastNeed > 2 && buf.length > 2) {
|
|
764
|
+
if ((buf[2] & 192) !== 128) {
|
|
765
|
+
self2.lastNeed = 2;
|
|
766
|
+
return "\uFFFD";
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
function utf8FillLast(buf) {
|
|
772
|
+
var p = this.lastTotal - this.lastNeed;
|
|
773
|
+
var r = utf8CheckExtraBytes(this, buf, p);
|
|
774
|
+
if (r !== void 0) return r;
|
|
775
|
+
if (this.lastNeed <= buf.length) {
|
|
776
|
+
buf.copy(this.lastChar, p, 0, this.lastNeed);
|
|
777
|
+
return this.lastChar.toString(this.encoding, 0, this.lastTotal);
|
|
778
|
+
}
|
|
779
|
+
buf.copy(this.lastChar, p, 0, buf.length);
|
|
780
|
+
this.lastNeed -= buf.length;
|
|
781
|
+
}
|
|
782
|
+
function utf8Text(buf, i) {
|
|
783
|
+
var total = utf8CheckIncomplete(this, buf, i);
|
|
784
|
+
if (!this.lastNeed) return buf.toString("utf8", i);
|
|
785
|
+
this.lastTotal = total;
|
|
786
|
+
var end = buf.length - (total - this.lastNeed);
|
|
787
|
+
buf.copy(this.lastChar, 0, end);
|
|
788
|
+
return buf.toString("utf8", i, end);
|
|
789
|
+
}
|
|
790
|
+
function utf8End(buf) {
|
|
791
|
+
var r = buf && buf.length ? this.write(buf) : "";
|
|
792
|
+
if (this.lastNeed) return r + "\uFFFD";
|
|
793
|
+
return r;
|
|
794
|
+
}
|
|
795
|
+
function utf16Text(buf, i) {
|
|
796
|
+
if ((buf.length - i) % 2 === 0) {
|
|
797
|
+
var r = buf.toString("utf16le", i);
|
|
798
|
+
if (r) {
|
|
799
|
+
var c = r.charCodeAt(r.length - 1);
|
|
800
|
+
if (c >= 55296 && c <= 56319) {
|
|
801
|
+
this.lastNeed = 2;
|
|
802
|
+
this.lastTotal = 4;
|
|
803
|
+
this.lastChar[0] = buf[buf.length - 2];
|
|
804
|
+
this.lastChar[1] = buf[buf.length - 1];
|
|
805
|
+
return r.slice(0, -1);
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
return r;
|
|
809
|
+
}
|
|
810
|
+
this.lastNeed = 1;
|
|
811
|
+
this.lastTotal = 2;
|
|
812
|
+
this.lastChar[0] = buf[buf.length - 1];
|
|
813
|
+
return buf.toString("utf16le", i, buf.length - 1);
|
|
814
|
+
}
|
|
815
|
+
function utf16End(buf) {
|
|
816
|
+
var r = buf && buf.length ? this.write(buf) : "";
|
|
817
|
+
if (this.lastNeed) {
|
|
818
|
+
var end = this.lastTotal - this.lastNeed;
|
|
819
|
+
return r + this.lastChar.toString("utf16le", 0, end);
|
|
820
|
+
}
|
|
821
|
+
return r;
|
|
822
|
+
}
|
|
823
|
+
function base64Text(buf, i) {
|
|
824
|
+
var n = (buf.length - i) % 3;
|
|
825
|
+
if (n === 0) return buf.toString("base64", i);
|
|
826
|
+
this.lastNeed = 3 - n;
|
|
827
|
+
this.lastTotal = 3;
|
|
828
|
+
if (n === 1) {
|
|
829
|
+
this.lastChar[0] = buf[buf.length - 1];
|
|
830
|
+
} else {
|
|
831
|
+
this.lastChar[0] = buf[buf.length - 2];
|
|
832
|
+
this.lastChar[1] = buf[buf.length - 1];
|
|
833
|
+
}
|
|
834
|
+
return buf.toString("base64", i, buf.length - n);
|
|
835
|
+
}
|
|
836
|
+
function base64End(buf) {
|
|
837
|
+
var r = buf && buf.length ? this.write(buf) : "";
|
|
838
|
+
if (this.lastNeed) return r + this.lastChar.toString("base64", 0, 3 - this.lastNeed);
|
|
839
|
+
return r;
|
|
840
|
+
}
|
|
841
|
+
function simpleWrite(buf) {
|
|
842
|
+
return buf.toString(this.encoding);
|
|
843
|
+
}
|
|
844
|
+
function simpleEnd(buf) {
|
|
845
|
+
return buf && buf.length ? this.write(buf) : "";
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
});
|
|
849
|
+
|
|
850
|
+
// ../../node_modules/readable-stream/lib/internal/streams/end-of-stream.js
|
|
851
|
+
var require_end_of_stream = __commonJS({
|
|
852
|
+
"../../node_modules/readable-stream/lib/internal/streams/end-of-stream.js"(exports2, module2) {
|
|
853
|
+
"use strict";
|
|
854
|
+
var ERR_STREAM_PREMATURE_CLOSE = require_errors().codes.ERR_STREAM_PREMATURE_CLOSE;
|
|
855
|
+
function once(callback) {
|
|
856
|
+
var called = false;
|
|
857
|
+
return function() {
|
|
858
|
+
if (called) return;
|
|
859
|
+
called = true;
|
|
860
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
861
|
+
args[_key] = arguments[_key];
|
|
862
|
+
}
|
|
863
|
+
callback.apply(this, args);
|
|
864
|
+
};
|
|
865
|
+
}
|
|
866
|
+
function noop() {
|
|
867
|
+
}
|
|
868
|
+
function isRequest(stream) {
|
|
869
|
+
return stream.setHeader && typeof stream.abort === "function";
|
|
870
|
+
}
|
|
871
|
+
function eos(stream, opts, callback) {
|
|
872
|
+
if (typeof opts === "function") return eos(stream, null, opts);
|
|
873
|
+
if (!opts) opts = {};
|
|
874
|
+
callback = once(callback || noop);
|
|
875
|
+
var readable = opts.readable || opts.readable !== false && stream.readable;
|
|
876
|
+
var writable = opts.writable || opts.writable !== false && stream.writable;
|
|
877
|
+
var onlegacyfinish = function onlegacyfinish2() {
|
|
878
|
+
if (!stream.writable) onfinish();
|
|
879
|
+
};
|
|
880
|
+
var writableEnded = stream._writableState && stream._writableState.finished;
|
|
881
|
+
var onfinish = function onfinish2() {
|
|
882
|
+
writable = false;
|
|
883
|
+
writableEnded = true;
|
|
884
|
+
if (!readable) callback.call(stream);
|
|
885
|
+
};
|
|
886
|
+
var readableEnded = stream._readableState && stream._readableState.endEmitted;
|
|
887
|
+
var onend = function onend2() {
|
|
888
|
+
readable = false;
|
|
889
|
+
readableEnded = true;
|
|
890
|
+
if (!writable) callback.call(stream);
|
|
891
|
+
};
|
|
892
|
+
var onerror = function onerror2(err) {
|
|
893
|
+
callback.call(stream, err);
|
|
894
|
+
};
|
|
895
|
+
var onclose = function onclose2() {
|
|
896
|
+
var err;
|
|
897
|
+
if (readable && !readableEnded) {
|
|
898
|
+
if (!stream._readableState || !stream._readableState.ended) err = new ERR_STREAM_PREMATURE_CLOSE();
|
|
899
|
+
return callback.call(stream, err);
|
|
900
|
+
}
|
|
901
|
+
if (writable && !writableEnded) {
|
|
902
|
+
if (!stream._writableState || !stream._writableState.ended) err = new ERR_STREAM_PREMATURE_CLOSE();
|
|
903
|
+
return callback.call(stream, err);
|
|
904
|
+
}
|
|
905
|
+
};
|
|
906
|
+
var onrequest = function onrequest2() {
|
|
907
|
+
stream.req.on("finish", onfinish);
|
|
908
|
+
};
|
|
909
|
+
if (isRequest(stream)) {
|
|
910
|
+
stream.on("complete", onfinish);
|
|
911
|
+
stream.on("abort", onclose);
|
|
912
|
+
if (stream.req) onrequest();
|
|
913
|
+
else stream.on("request", onrequest);
|
|
914
|
+
} else if (writable && !stream._writableState) {
|
|
915
|
+
stream.on("end", onlegacyfinish);
|
|
916
|
+
stream.on("close", onlegacyfinish);
|
|
917
|
+
}
|
|
918
|
+
stream.on("end", onend);
|
|
919
|
+
stream.on("finish", onfinish);
|
|
920
|
+
if (opts.error !== false) stream.on("error", onerror);
|
|
921
|
+
stream.on("close", onclose);
|
|
922
|
+
return function() {
|
|
923
|
+
stream.removeListener("complete", onfinish);
|
|
924
|
+
stream.removeListener("abort", onclose);
|
|
925
|
+
stream.removeListener("request", onrequest);
|
|
926
|
+
if (stream.req) stream.req.removeListener("finish", onfinish);
|
|
927
|
+
stream.removeListener("end", onlegacyfinish);
|
|
928
|
+
stream.removeListener("close", onlegacyfinish);
|
|
929
|
+
stream.removeListener("finish", onfinish);
|
|
930
|
+
stream.removeListener("end", onend);
|
|
931
|
+
stream.removeListener("error", onerror);
|
|
932
|
+
stream.removeListener("close", onclose);
|
|
933
|
+
};
|
|
934
|
+
}
|
|
935
|
+
module2.exports = eos;
|
|
936
|
+
}
|
|
937
|
+
});
|
|
938
|
+
|
|
939
|
+
// ../../node_modules/readable-stream/lib/internal/streams/async_iterator.js
|
|
940
|
+
var require_async_iterator = __commonJS({
|
|
941
|
+
"../../node_modules/readable-stream/lib/internal/streams/async_iterator.js"(exports2, module2) {
|
|
942
|
+
"use strict";
|
|
943
|
+
var _Object$setPrototypeO;
|
|
944
|
+
function _defineProperty(obj, key, value) {
|
|
945
|
+
key = _toPropertyKey(key);
|
|
946
|
+
if (key in obj) {
|
|
947
|
+
Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
|
|
948
|
+
} else {
|
|
949
|
+
obj[key] = value;
|
|
950
|
+
}
|
|
951
|
+
return obj;
|
|
952
|
+
}
|
|
953
|
+
function _toPropertyKey(arg) {
|
|
954
|
+
var key = _toPrimitive(arg, "string");
|
|
955
|
+
return typeof key === "symbol" ? key : String(key);
|
|
956
|
+
}
|
|
957
|
+
function _toPrimitive(input, hint) {
|
|
958
|
+
if (typeof input !== "object" || input === null) return input;
|
|
959
|
+
var prim = input[Symbol.toPrimitive];
|
|
960
|
+
if (prim !== void 0) {
|
|
961
|
+
var res = prim.call(input, hint || "default");
|
|
962
|
+
if (typeof res !== "object") return res;
|
|
963
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
964
|
+
}
|
|
965
|
+
return (hint === "string" ? String : Number)(input);
|
|
966
|
+
}
|
|
967
|
+
var finished = require_end_of_stream();
|
|
968
|
+
var kLastResolve = Symbol("lastResolve");
|
|
969
|
+
var kLastReject = Symbol("lastReject");
|
|
970
|
+
var kError = Symbol("error");
|
|
971
|
+
var kEnded = Symbol("ended");
|
|
972
|
+
var kLastPromise = Symbol("lastPromise");
|
|
973
|
+
var kHandlePromise = Symbol("handlePromise");
|
|
974
|
+
var kStream = Symbol("stream");
|
|
975
|
+
function createIterResult(value, done) {
|
|
976
|
+
return {
|
|
977
|
+
value,
|
|
978
|
+
done
|
|
979
|
+
};
|
|
980
|
+
}
|
|
981
|
+
function readAndResolve(iter) {
|
|
982
|
+
var resolve = iter[kLastResolve];
|
|
983
|
+
if (resolve !== null) {
|
|
984
|
+
var data = iter[kStream].read();
|
|
985
|
+
if (data !== null) {
|
|
986
|
+
iter[kLastPromise] = null;
|
|
987
|
+
iter[kLastResolve] = null;
|
|
988
|
+
iter[kLastReject] = null;
|
|
989
|
+
resolve(createIterResult(data, false));
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
function onReadable(iter) {
|
|
994
|
+
process.nextTick(readAndResolve, iter);
|
|
995
|
+
}
|
|
996
|
+
function wrapForNext(lastPromise, iter) {
|
|
997
|
+
return function(resolve, reject) {
|
|
998
|
+
lastPromise.then(function() {
|
|
999
|
+
if (iter[kEnded]) {
|
|
1000
|
+
resolve(createIterResult(void 0, true));
|
|
1001
|
+
return;
|
|
1002
|
+
}
|
|
1003
|
+
iter[kHandlePromise](resolve, reject);
|
|
1004
|
+
}, reject);
|
|
1005
|
+
};
|
|
1006
|
+
}
|
|
1007
|
+
var AsyncIteratorPrototype = Object.getPrototypeOf(function() {
|
|
1008
|
+
});
|
|
1009
|
+
var ReadableStreamAsyncIteratorPrototype = Object.setPrototypeOf((_Object$setPrototypeO = {
|
|
1010
|
+
get stream() {
|
|
1011
|
+
return this[kStream];
|
|
1012
|
+
},
|
|
1013
|
+
next: function next() {
|
|
1014
|
+
var _this = this;
|
|
1015
|
+
var error = this[kError];
|
|
1016
|
+
if (error !== null) {
|
|
1017
|
+
return Promise.reject(error);
|
|
1018
|
+
}
|
|
1019
|
+
if (this[kEnded]) {
|
|
1020
|
+
return Promise.resolve(createIterResult(void 0, true));
|
|
1021
|
+
}
|
|
1022
|
+
if (this[kStream].destroyed) {
|
|
1023
|
+
return new Promise(function(resolve, reject) {
|
|
1024
|
+
process.nextTick(function() {
|
|
1025
|
+
if (_this[kError]) {
|
|
1026
|
+
reject(_this[kError]);
|
|
1027
|
+
} else {
|
|
1028
|
+
resolve(createIterResult(void 0, true));
|
|
1029
|
+
}
|
|
1030
|
+
});
|
|
1031
|
+
});
|
|
1032
|
+
}
|
|
1033
|
+
var lastPromise = this[kLastPromise];
|
|
1034
|
+
var promise;
|
|
1035
|
+
if (lastPromise) {
|
|
1036
|
+
promise = new Promise(wrapForNext(lastPromise, this));
|
|
1037
|
+
} else {
|
|
1038
|
+
var data = this[kStream].read();
|
|
1039
|
+
if (data !== null) {
|
|
1040
|
+
return Promise.resolve(createIterResult(data, false));
|
|
1041
|
+
}
|
|
1042
|
+
promise = new Promise(this[kHandlePromise]);
|
|
1043
|
+
}
|
|
1044
|
+
this[kLastPromise] = promise;
|
|
1045
|
+
return promise;
|
|
1046
|
+
}
|
|
1047
|
+
}, _defineProperty(_Object$setPrototypeO, Symbol.asyncIterator, function() {
|
|
1048
|
+
return this;
|
|
1049
|
+
}), _defineProperty(_Object$setPrototypeO, "return", function _return() {
|
|
1050
|
+
var _this2 = this;
|
|
1051
|
+
return new Promise(function(resolve, reject) {
|
|
1052
|
+
_this2[kStream].destroy(null, function(err) {
|
|
1053
|
+
if (err) {
|
|
1054
|
+
reject(err);
|
|
1055
|
+
return;
|
|
1056
|
+
}
|
|
1057
|
+
resolve(createIterResult(void 0, true));
|
|
1058
|
+
});
|
|
1059
|
+
});
|
|
1060
|
+
}), _Object$setPrototypeO), AsyncIteratorPrototype);
|
|
1061
|
+
var createReadableStreamAsyncIterator = function createReadableStreamAsyncIterator2(stream) {
|
|
1062
|
+
var _Object$create;
|
|
1063
|
+
var iterator = Object.create(ReadableStreamAsyncIteratorPrototype, (_Object$create = {}, _defineProperty(_Object$create, kStream, {
|
|
1064
|
+
value: stream,
|
|
1065
|
+
writable: true
|
|
1066
|
+
}), _defineProperty(_Object$create, kLastResolve, {
|
|
1067
|
+
value: null,
|
|
1068
|
+
writable: true
|
|
1069
|
+
}), _defineProperty(_Object$create, kLastReject, {
|
|
1070
|
+
value: null,
|
|
1071
|
+
writable: true
|
|
1072
|
+
}), _defineProperty(_Object$create, kError, {
|
|
1073
|
+
value: null,
|
|
1074
|
+
writable: true
|
|
1075
|
+
}), _defineProperty(_Object$create, kEnded, {
|
|
1076
|
+
value: stream._readableState.endEmitted,
|
|
1077
|
+
writable: true
|
|
1078
|
+
}), _defineProperty(_Object$create, kHandlePromise, {
|
|
1079
|
+
value: function value(resolve, reject) {
|
|
1080
|
+
var data = iterator[kStream].read();
|
|
1081
|
+
if (data) {
|
|
1082
|
+
iterator[kLastPromise] = null;
|
|
1083
|
+
iterator[kLastResolve] = null;
|
|
1084
|
+
iterator[kLastReject] = null;
|
|
1085
|
+
resolve(createIterResult(data, false));
|
|
1086
|
+
} else {
|
|
1087
|
+
iterator[kLastResolve] = resolve;
|
|
1088
|
+
iterator[kLastReject] = reject;
|
|
1089
|
+
}
|
|
1090
|
+
},
|
|
1091
|
+
writable: true
|
|
1092
|
+
}), _Object$create));
|
|
1093
|
+
iterator[kLastPromise] = null;
|
|
1094
|
+
finished(stream, function(err) {
|
|
1095
|
+
if (err && err.code !== "ERR_STREAM_PREMATURE_CLOSE") {
|
|
1096
|
+
var reject = iterator[kLastReject];
|
|
1097
|
+
if (reject !== null) {
|
|
1098
|
+
iterator[kLastPromise] = null;
|
|
1099
|
+
iterator[kLastResolve] = null;
|
|
1100
|
+
iterator[kLastReject] = null;
|
|
1101
|
+
reject(err);
|
|
1102
|
+
}
|
|
1103
|
+
iterator[kError] = err;
|
|
1104
|
+
return;
|
|
1105
|
+
}
|
|
1106
|
+
var resolve = iterator[kLastResolve];
|
|
1107
|
+
if (resolve !== null) {
|
|
1108
|
+
iterator[kLastPromise] = null;
|
|
1109
|
+
iterator[kLastResolve] = null;
|
|
1110
|
+
iterator[kLastReject] = null;
|
|
1111
|
+
resolve(createIterResult(void 0, true));
|
|
1112
|
+
}
|
|
1113
|
+
iterator[kEnded] = true;
|
|
1114
|
+
});
|
|
1115
|
+
stream.on("readable", onReadable.bind(null, iterator));
|
|
1116
|
+
return iterator;
|
|
1117
|
+
};
|
|
1118
|
+
module2.exports = createReadableStreamAsyncIterator;
|
|
1119
|
+
}
|
|
1120
|
+
});
|
|
1121
|
+
|
|
1122
|
+
// ../../node_modules/readable-stream/lib/internal/streams/from.js
|
|
1123
|
+
var require_from = __commonJS({
|
|
1124
|
+
"../../node_modules/readable-stream/lib/internal/streams/from.js"(exports2, module2) {
|
|
1125
|
+
"use strict";
|
|
1126
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
1127
|
+
try {
|
|
1128
|
+
var info = gen[key](arg);
|
|
1129
|
+
var value = info.value;
|
|
1130
|
+
} catch (error) {
|
|
1131
|
+
reject(error);
|
|
1132
|
+
return;
|
|
1133
|
+
}
|
|
1134
|
+
if (info.done) {
|
|
1135
|
+
resolve(value);
|
|
1136
|
+
} else {
|
|
1137
|
+
Promise.resolve(value).then(_next, _throw);
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
function _asyncToGenerator(fn) {
|
|
1141
|
+
return function() {
|
|
1142
|
+
var self2 = this, args = arguments;
|
|
1143
|
+
return new Promise(function(resolve, reject) {
|
|
1144
|
+
var gen = fn.apply(self2, args);
|
|
1145
|
+
function _next(value) {
|
|
1146
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
1147
|
+
}
|
|
1148
|
+
function _throw(err) {
|
|
1149
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
1150
|
+
}
|
|
1151
|
+
_next(void 0);
|
|
1152
|
+
});
|
|
1153
|
+
};
|
|
1154
|
+
}
|
|
1155
|
+
function ownKeys(object, enumerableOnly) {
|
|
1156
|
+
var keys = Object.keys(object);
|
|
1157
|
+
if (Object.getOwnPropertySymbols) {
|
|
1158
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
1159
|
+
enumerableOnly && (symbols = symbols.filter(function(sym) {
|
|
1160
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
1161
|
+
})), keys.push.apply(keys, symbols);
|
|
1162
|
+
}
|
|
1163
|
+
return keys;
|
|
1164
|
+
}
|
|
1165
|
+
function _objectSpread(target) {
|
|
1166
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
1167
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
1168
|
+
i % 2 ? ownKeys(Object(source), true).forEach(function(key) {
|
|
1169
|
+
_defineProperty(target, key, source[key]);
|
|
1170
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
|
|
1171
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
1172
|
+
});
|
|
1173
|
+
}
|
|
1174
|
+
return target;
|
|
1175
|
+
}
|
|
1176
|
+
function _defineProperty(obj, key, value) {
|
|
1177
|
+
key = _toPropertyKey(key);
|
|
1178
|
+
if (key in obj) {
|
|
1179
|
+
Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
|
|
1180
|
+
} else {
|
|
1181
|
+
obj[key] = value;
|
|
1182
|
+
}
|
|
1183
|
+
return obj;
|
|
1184
|
+
}
|
|
1185
|
+
function _toPropertyKey(arg) {
|
|
1186
|
+
var key = _toPrimitive(arg, "string");
|
|
1187
|
+
return typeof key === "symbol" ? key : String(key);
|
|
1188
|
+
}
|
|
1189
|
+
function _toPrimitive(input, hint) {
|
|
1190
|
+
if (typeof input !== "object" || input === null) return input;
|
|
1191
|
+
var prim = input[Symbol.toPrimitive];
|
|
1192
|
+
if (prim !== void 0) {
|
|
1193
|
+
var res = prim.call(input, hint || "default");
|
|
1194
|
+
if (typeof res !== "object") return res;
|
|
1195
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
1196
|
+
}
|
|
1197
|
+
return (hint === "string" ? String : Number)(input);
|
|
1198
|
+
}
|
|
1199
|
+
var ERR_INVALID_ARG_TYPE = require_errors().codes.ERR_INVALID_ARG_TYPE;
|
|
1200
|
+
function from(Readable, iterable, opts) {
|
|
1201
|
+
var iterator;
|
|
1202
|
+
if (iterable && typeof iterable.next === "function") {
|
|
1203
|
+
iterator = iterable;
|
|
1204
|
+
} else if (iterable && iterable[Symbol.asyncIterator]) iterator = iterable[Symbol.asyncIterator]();
|
|
1205
|
+
else if (iterable && iterable[Symbol.iterator]) iterator = iterable[Symbol.iterator]();
|
|
1206
|
+
else throw new ERR_INVALID_ARG_TYPE("iterable", ["Iterable"], iterable);
|
|
1207
|
+
var readable = new Readable(_objectSpread({
|
|
1208
|
+
objectMode: true
|
|
1209
|
+
}, opts));
|
|
1210
|
+
var reading = false;
|
|
1211
|
+
readable._read = function() {
|
|
1212
|
+
if (!reading) {
|
|
1213
|
+
reading = true;
|
|
1214
|
+
next();
|
|
1215
|
+
}
|
|
1216
|
+
};
|
|
1217
|
+
function next() {
|
|
1218
|
+
return _next2.apply(this, arguments);
|
|
1219
|
+
}
|
|
1220
|
+
function _next2() {
|
|
1221
|
+
_next2 = _asyncToGenerator(function* () {
|
|
1222
|
+
try {
|
|
1223
|
+
var _yield$iterator$next = yield iterator.next(), value = _yield$iterator$next.value, done = _yield$iterator$next.done;
|
|
1224
|
+
if (done) {
|
|
1225
|
+
readable.push(null);
|
|
1226
|
+
} else if (readable.push(yield value)) {
|
|
1227
|
+
next();
|
|
1228
|
+
} else {
|
|
1229
|
+
reading = false;
|
|
1230
|
+
}
|
|
1231
|
+
} catch (err) {
|
|
1232
|
+
readable.destroy(err);
|
|
1233
|
+
}
|
|
1234
|
+
});
|
|
1235
|
+
return _next2.apply(this, arguments);
|
|
1236
|
+
}
|
|
1237
|
+
return readable;
|
|
1238
|
+
}
|
|
1239
|
+
module2.exports = from;
|
|
1240
|
+
}
|
|
1241
|
+
});
|
|
1242
|
+
|
|
1243
|
+
// ../../node_modules/readable-stream/lib/_stream_readable.js
|
|
1244
|
+
var require_stream_readable = __commonJS({
|
|
1245
|
+
"../../node_modules/readable-stream/lib/_stream_readable.js"(exports2, module2) {
|
|
1246
|
+
"use strict";
|
|
1247
|
+
module2.exports = Readable;
|
|
1248
|
+
var Duplex;
|
|
1249
|
+
Readable.ReadableState = ReadableState;
|
|
1250
|
+
var EE = require("events").EventEmitter;
|
|
1251
|
+
var EElistenerCount = function EElistenerCount2(emitter, type) {
|
|
1252
|
+
return emitter.listeners(type).length;
|
|
1253
|
+
};
|
|
1254
|
+
var Stream = require_stream();
|
|
1255
|
+
var Buffer2 = require("buffer").Buffer;
|
|
1256
|
+
var OurUint8Array = (typeof global !== "undefined" ? global : typeof window !== "undefined" ? window : typeof self !== "undefined" ? self : {}).Uint8Array || function() {
|
|
1257
|
+
};
|
|
1258
|
+
function _uint8ArrayToBuffer(chunk) {
|
|
1259
|
+
return Buffer2.from(chunk);
|
|
1260
|
+
}
|
|
1261
|
+
function _isUint8Array(obj) {
|
|
1262
|
+
return Buffer2.isBuffer(obj) || obj instanceof OurUint8Array;
|
|
1263
|
+
}
|
|
1264
|
+
var debugUtil = require("util");
|
|
1265
|
+
var debug;
|
|
1266
|
+
if (debugUtil && debugUtil.debuglog) {
|
|
1267
|
+
debug = debugUtil.debuglog("stream");
|
|
1268
|
+
} else {
|
|
1269
|
+
debug = function debug2() {
|
|
1270
|
+
};
|
|
1271
|
+
}
|
|
1272
|
+
var BufferList = require_buffer_list();
|
|
1273
|
+
var destroyImpl = require_destroy();
|
|
1274
|
+
var _require = require_state();
|
|
1275
|
+
var getHighWaterMark = _require.getHighWaterMark;
|
|
1276
|
+
var _require$codes = require_errors().codes;
|
|
1277
|
+
var ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE;
|
|
1278
|
+
var ERR_STREAM_PUSH_AFTER_EOF = _require$codes.ERR_STREAM_PUSH_AFTER_EOF;
|
|
1279
|
+
var ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED;
|
|
1280
|
+
var ERR_STREAM_UNSHIFT_AFTER_END_EVENT = _require$codes.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;
|
|
1281
|
+
var StringDecoder;
|
|
1282
|
+
var createReadableStreamAsyncIterator;
|
|
1283
|
+
var from;
|
|
1284
|
+
require_inherits()(Readable, Stream);
|
|
1285
|
+
var errorOrDestroy = destroyImpl.errorOrDestroy;
|
|
1286
|
+
var kProxyEvents = ["error", "close", "destroy", "pause", "resume"];
|
|
1287
|
+
function prependListener(emitter, event, fn) {
|
|
1288
|
+
if (typeof emitter.prependListener === "function") return emitter.prependListener(event, fn);
|
|
1289
|
+
if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);
|
|
1290
|
+
else if (Array.isArray(emitter._events[event])) emitter._events[event].unshift(fn);
|
|
1291
|
+
else emitter._events[event] = [fn, emitter._events[event]];
|
|
1292
|
+
}
|
|
1293
|
+
function ReadableState(options, stream, isDuplex) {
|
|
1294
|
+
Duplex = Duplex || require_stream_duplex();
|
|
1295
|
+
options = options || {};
|
|
1296
|
+
if (typeof isDuplex !== "boolean") isDuplex = stream instanceof Duplex;
|
|
1297
|
+
this.objectMode = !!options.objectMode;
|
|
1298
|
+
if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode;
|
|
1299
|
+
this.highWaterMark = getHighWaterMark(this, options, "readableHighWaterMark", isDuplex);
|
|
1300
|
+
this.buffer = new BufferList();
|
|
1301
|
+
this.length = 0;
|
|
1302
|
+
this.pipes = null;
|
|
1303
|
+
this.pipesCount = 0;
|
|
1304
|
+
this.flowing = null;
|
|
1305
|
+
this.ended = false;
|
|
1306
|
+
this.endEmitted = false;
|
|
1307
|
+
this.reading = false;
|
|
1308
|
+
this.sync = true;
|
|
1309
|
+
this.needReadable = false;
|
|
1310
|
+
this.emittedReadable = false;
|
|
1311
|
+
this.readableListening = false;
|
|
1312
|
+
this.resumeScheduled = false;
|
|
1313
|
+
this.paused = true;
|
|
1314
|
+
this.emitClose = options.emitClose !== false;
|
|
1315
|
+
this.autoDestroy = !!options.autoDestroy;
|
|
1316
|
+
this.destroyed = false;
|
|
1317
|
+
this.defaultEncoding = options.defaultEncoding || "utf8";
|
|
1318
|
+
this.awaitDrain = 0;
|
|
1319
|
+
this.readingMore = false;
|
|
1320
|
+
this.decoder = null;
|
|
1321
|
+
this.encoding = null;
|
|
1322
|
+
if (options.encoding) {
|
|
1323
|
+
if (!StringDecoder) StringDecoder = require_string_decoder().StringDecoder;
|
|
1324
|
+
this.decoder = new StringDecoder(options.encoding);
|
|
1325
|
+
this.encoding = options.encoding;
|
|
1326
|
+
}
|
|
1327
|
+
}
|
|
1328
|
+
function Readable(options) {
|
|
1329
|
+
Duplex = Duplex || require_stream_duplex();
|
|
1330
|
+
if (!(this instanceof Readable)) return new Readable(options);
|
|
1331
|
+
var isDuplex = this instanceof Duplex;
|
|
1332
|
+
this._readableState = new ReadableState(options, this, isDuplex);
|
|
1333
|
+
this.readable = true;
|
|
1334
|
+
if (options) {
|
|
1335
|
+
if (typeof options.read === "function") this._read = options.read;
|
|
1336
|
+
if (typeof options.destroy === "function") this._destroy = options.destroy;
|
|
1337
|
+
}
|
|
1338
|
+
Stream.call(this);
|
|
1339
|
+
}
|
|
1340
|
+
Object.defineProperty(Readable.prototype, "destroyed", {
|
|
1341
|
+
// making it explicit this property is not enumerable
|
|
1342
|
+
// because otherwise some prototype manipulation in
|
|
1343
|
+
// userland will fail
|
|
1344
|
+
enumerable: false,
|
|
1345
|
+
get: function get() {
|
|
1346
|
+
if (this._readableState === void 0) {
|
|
1347
|
+
return false;
|
|
1348
|
+
}
|
|
1349
|
+
return this._readableState.destroyed;
|
|
1350
|
+
},
|
|
1351
|
+
set: function set(value) {
|
|
1352
|
+
if (!this._readableState) {
|
|
1353
|
+
return;
|
|
1354
|
+
}
|
|
1355
|
+
this._readableState.destroyed = value;
|
|
1356
|
+
}
|
|
1357
|
+
});
|
|
1358
|
+
Readable.prototype.destroy = destroyImpl.destroy;
|
|
1359
|
+
Readable.prototype._undestroy = destroyImpl.undestroy;
|
|
1360
|
+
Readable.prototype._destroy = function(err, cb) {
|
|
1361
|
+
cb(err);
|
|
1362
|
+
};
|
|
1363
|
+
Readable.prototype.push = function(chunk, encoding) {
|
|
1364
|
+
var state = this._readableState;
|
|
1365
|
+
var skipChunkCheck;
|
|
1366
|
+
if (!state.objectMode) {
|
|
1367
|
+
if (typeof chunk === "string") {
|
|
1368
|
+
encoding = encoding || state.defaultEncoding;
|
|
1369
|
+
if (encoding !== state.encoding) {
|
|
1370
|
+
chunk = Buffer2.from(chunk, encoding);
|
|
1371
|
+
encoding = "";
|
|
1372
|
+
}
|
|
1373
|
+
skipChunkCheck = true;
|
|
1374
|
+
}
|
|
1375
|
+
} else {
|
|
1376
|
+
skipChunkCheck = true;
|
|
1377
|
+
}
|
|
1378
|
+
return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);
|
|
1379
|
+
};
|
|
1380
|
+
Readable.prototype.unshift = function(chunk) {
|
|
1381
|
+
return readableAddChunk(this, chunk, null, true, false);
|
|
1382
|
+
};
|
|
1383
|
+
function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
|
|
1384
|
+
debug("readableAddChunk", chunk);
|
|
1385
|
+
var state = stream._readableState;
|
|
1386
|
+
if (chunk === null) {
|
|
1387
|
+
state.reading = false;
|
|
1388
|
+
onEofChunk(stream, state);
|
|
1389
|
+
} else {
|
|
1390
|
+
var er;
|
|
1391
|
+
if (!skipChunkCheck) er = chunkInvalid(state, chunk);
|
|
1392
|
+
if (er) {
|
|
1393
|
+
errorOrDestroy(stream, er);
|
|
1394
|
+
} else if (state.objectMode || chunk && chunk.length > 0) {
|
|
1395
|
+
if (typeof chunk !== "string" && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer2.prototype) {
|
|
1396
|
+
chunk = _uint8ArrayToBuffer(chunk);
|
|
1397
|
+
}
|
|
1398
|
+
if (addToFront) {
|
|
1399
|
+
if (state.endEmitted) errorOrDestroy(stream, new ERR_STREAM_UNSHIFT_AFTER_END_EVENT());
|
|
1400
|
+
else addChunk(stream, state, chunk, true);
|
|
1401
|
+
} else if (state.ended) {
|
|
1402
|
+
errorOrDestroy(stream, new ERR_STREAM_PUSH_AFTER_EOF());
|
|
1403
|
+
} else if (state.destroyed) {
|
|
1404
|
+
return false;
|
|
1405
|
+
} else {
|
|
1406
|
+
state.reading = false;
|
|
1407
|
+
if (state.decoder && !encoding) {
|
|
1408
|
+
chunk = state.decoder.write(chunk);
|
|
1409
|
+
if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);
|
|
1410
|
+
else maybeReadMore(stream, state);
|
|
1411
|
+
} else {
|
|
1412
|
+
addChunk(stream, state, chunk, false);
|
|
1413
|
+
}
|
|
1414
|
+
}
|
|
1415
|
+
} else if (!addToFront) {
|
|
1416
|
+
state.reading = false;
|
|
1417
|
+
maybeReadMore(stream, state);
|
|
1418
|
+
}
|
|
1419
|
+
}
|
|
1420
|
+
return !state.ended && (state.length < state.highWaterMark || state.length === 0);
|
|
1421
|
+
}
|
|
1422
|
+
function addChunk(stream, state, chunk, addToFront) {
|
|
1423
|
+
if (state.flowing && state.length === 0 && !state.sync) {
|
|
1424
|
+
state.awaitDrain = 0;
|
|
1425
|
+
stream.emit("data", chunk);
|
|
1426
|
+
} else {
|
|
1427
|
+
state.length += state.objectMode ? 1 : chunk.length;
|
|
1428
|
+
if (addToFront) state.buffer.unshift(chunk);
|
|
1429
|
+
else state.buffer.push(chunk);
|
|
1430
|
+
if (state.needReadable) emitReadable(stream);
|
|
1431
|
+
}
|
|
1432
|
+
maybeReadMore(stream, state);
|
|
1433
|
+
}
|
|
1434
|
+
function chunkInvalid(state, chunk) {
|
|
1435
|
+
var er;
|
|
1436
|
+
if (!_isUint8Array(chunk) && typeof chunk !== "string" && chunk !== void 0 && !state.objectMode) {
|
|
1437
|
+
er = new ERR_INVALID_ARG_TYPE("chunk", ["string", "Buffer", "Uint8Array"], chunk);
|
|
1438
|
+
}
|
|
1439
|
+
return er;
|
|
1440
|
+
}
|
|
1441
|
+
Readable.prototype.isPaused = function() {
|
|
1442
|
+
return this._readableState.flowing === false;
|
|
1443
|
+
};
|
|
1444
|
+
Readable.prototype.setEncoding = function(enc) {
|
|
1445
|
+
if (!StringDecoder) StringDecoder = require_string_decoder().StringDecoder;
|
|
1446
|
+
var decoder = new StringDecoder(enc);
|
|
1447
|
+
this._readableState.decoder = decoder;
|
|
1448
|
+
this._readableState.encoding = this._readableState.decoder.encoding;
|
|
1449
|
+
var p = this._readableState.buffer.head;
|
|
1450
|
+
var content = "";
|
|
1451
|
+
while (p !== null) {
|
|
1452
|
+
content += decoder.write(p.data);
|
|
1453
|
+
p = p.next;
|
|
1454
|
+
}
|
|
1455
|
+
this._readableState.buffer.clear();
|
|
1456
|
+
if (content !== "") this._readableState.buffer.push(content);
|
|
1457
|
+
this._readableState.length = content.length;
|
|
1458
|
+
return this;
|
|
1459
|
+
};
|
|
1460
|
+
var MAX_HWM = 1073741824;
|
|
1461
|
+
function computeNewHighWaterMark(n) {
|
|
1462
|
+
if (n >= MAX_HWM) {
|
|
1463
|
+
n = MAX_HWM;
|
|
1464
|
+
} else {
|
|
1465
|
+
n--;
|
|
1466
|
+
n |= n >>> 1;
|
|
1467
|
+
n |= n >>> 2;
|
|
1468
|
+
n |= n >>> 4;
|
|
1469
|
+
n |= n >>> 8;
|
|
1470
|
+
n |= n >>> 16;
|
|
1471
|
+
n++;
|
|
1472
|
+
}
|
|
1473
|
+
return n;
|
|
1474
|
+
}
|
|
1475
|
+
function howMuchToRead(n, state) {
|
|
1476
|
+
if (n <= 0 || state.length === 0 && state.ended) return 0;
|
|
1477
|
+
if (state.objectMode) return 1;
|
|
1478
|
+
if (n !== n) {
|
|
1479
|
+
if (state.flowing && state.length) return state.buffer.head.data.length;
|
|
1480
|
+
else return state.length;
|
|
1481
|
+
}
|
|
1482
|
+
if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
|
|
1483
|
+
if (n <= state.length) return n;
|
|
1484
|
+
if (!state.ended) {
|
|
1485
|
+
state.needReadable = true;
|
|
1486
|
+
return 0;
|
|
1487
|
+
}
|
|
1488
|
+
return state.length;
|
|
1489
|
+
}
|
|
1490
|
+
Readable.prototype.read = function(n) {
|
|
1491
|
+
debug("read", n);
|
|
1492
|
+
n = parseInt(n, 10);
|
|
1493
|
+
var state = this._readableState;
|
|
1494
|
+
var nOrig = n;
|
|
1495
|
+
if (n !== 0) state.emittedReadable = false;
|
|
1496
|
+
if (n === 0 && state.needReadable && ((state.highWaterMark !== 0 ? state.length >= state.highWaterMark : state.length > 0) || state.ended)) {
|
|
1497
|
+
debug("read: emitReadable", state.length, state.ended);
|
|
1498
|
+
if (state.length === 0 && state.ended) endReadable(this);
|
|
1499
|
+
else emitReadable(this);
|
|
1500
|
+
return null;
|
|
1501
|
+
}
|
|
1502
|
+
n = howMuchToRead(n, state);
|
|
1503
|
+
if (n === 0 && state.ended) {
|
|
1504
|
+
if (state.length === 0) endReadable(this);
|
|
1505
|
+
return null;
|
|
1506
|
+
}
|
|
1507
|
+
var doRead = state.needReadable;
|
|
1508
|
+
debug("need readable", doRead);
|
|
1509
|
+
if (state.length === 0 || state.length - n < state.highWaterMark) {
|
|
1510
|
+
doRead = true;
|
|
1511
|
+
debug("length less than watermark", doRead);
|
|
1512
|
+
}
|
|
1513
|
+
if (state.ended || state.reading) {
|
|
1514
|
+
doRead = false;
|
|
1515
|
+
debug("reading or ended", doRead);
|
|
1516
|
+
} else if (doRead) {
|
|
1517
|
+
debug("do read");
|
|
1518
|
+
state.reading = true;
|
|
1519
|
+
state.sync = true;
|
|
1520
|
+
if (state.length === 0) state.needReadable = true;
|
|
1521
|
+
this._read(state.highWaterMark);
|
|
1522
|
+
state.sync = false;
|
|
1523
|
+
if (!state.reading) n = howMuchToRead(nOrig, state);
|
|
1524
|
+
}
|
|
1525
|
+
var ret;
|
|
1526
|
+
if (n > 0) ret = fromList(n, state);
|
|
1527
|
+
else ret = null;
|
|
1528
|
+
if (ret === null) {
|
|
1529
|
+
state.needReadable = state.length <= state.highWaterMark;
|
|
1530
|
+
n = 0;
|
|
1531
|
+
} else {
|
|
1532
|
+
state.length -= n;
|
|
1533
|
+
state.awaitDrain = 0;
|
|
1534
|
+
}
|
|
1535
|
+
if (state.length === 0) {
|
|
1536
|
+
if (!state.ended) state.needReadable = true;
|
|
1537
|
+
if (nOrig !== n && state.ended) endReadable(this);
|
|
1538
|
+
}
|
|
1539
|
+
if (ret !== null) this.emit("data", ret);
|
|
1540
|
+
return ret;
|
|
1541
|
+
};
|
|
1542
|
+
function onEofChunk(stream, state) {
|
|
1543
|
+
debug("onEofChunk");
|
|
1544
|
+
if (state.ended) return;
|
|
1545
|
+
if (state.decoder) {
|
|
1546
|
+
var chunk = state.decoder.end();
|
|
1547
|
+
if (chunk && chunk.length) {
|
|
1548
|
+
state.buffer.push(chunk);
|
|
1549
|
+
state.length += state.objectMode ? 1 : chunk.length;
|
|
1550
|
+
}
|
|
1551
|
+
}
|
|
1552
|
+
state.ended = true;
|
|
1553
|
+
if (state.sync) {
|
|
1554
|
+
emitReadable(stream);
|
|
1555
|
+
} else {
|
|
1556
|
+
state.needReadable = false;
|
|
1557
|
+
if (!state.emittedReadable) {
|
|
1558
|
+
state.emittedReadable = true;
|
|
1559
|
+
emitReadable_(stream);
|
|
1560
|
+
}
|
|
1561
|
+
}
|
|
1562
|
+
}
|
|
1563
|
+
function emitReadable(stream) {
|
|
1564
|
+
var state = stream._readableState;
|
|
1565
|
+
debug("emitReadable", state.needReadable, state.emittedReadable);
|
|
1566
|
+
state.needReadable = false;
|
|
1567
|
+
if (!state.emittedReadable) {
|
|
1568
|
+
debug("emitReadable", state.flowing);
|
|
1569
|
+
state.emittedReadable = true;
|
|
1570
|
+
process.nextTick(emitReadable_, stream);
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1573
|
+
function emitReadable_(stream) {
|
|
1574
|
+
var state = stream._readableState;
|
|
1575
|
+
debug("emitReadable_", state.destroyed, state.length, state.ended);
|
|
1576
|
+
if (!state.destroyed && (state.length || state.ended)) {
|
|
1577
|
+
stream.emit("readable");
|
|
1578
|
+
state.emittedReadable = false;
|
|
1579
|
+
}
|
|
1580
|
+
state.needReadable = !state.flowing && !state.ended && state.length <= state.highWaterMark;
|
|
1581
|
+
flow(stream);
|
|
1582
|
+
}
|
|
1583
|
+
function maybeReadMore(stream, state) {
|
|
1584
|
+
if (!state.readingMore) {
|
|
1585
|
+
state.readingMore = true;
|
|
1586
|
+
process.nextTick(maybeReadMore_, stream, state);
|
|
1587
|
+
}
|
|
1588
|
+
}
|
|
1589
|
+
function maybeReadMore_(stream, state) {
|
|
1590
|
+
while (!state.reading && !state.ended && (state.length < state.highWaterMark || state.flowing && state.length === 0)) {
|
|
1591
|
+
var len = state.length;
|
|
1592
|
+
debug("maybeReadMore read 0");
|
|
1593
|
+
stream.read(0);
|
|
1594
|
+
if (len === state.length)
|
|
1595
|
+
break;
|
|
1596
|
+
}
|
|
1597
|
+
state.readingMore = false;
|
|
1598
|
+
}
|
|
1599
|
+
Readable.prototype._read = function(n) {
|
|
1600
|
+
errorOrDestroy(this, new ERR_METHOD_NOT_IMPLEMENTED("_read()"));
|
|
1601
|
+
};
|
|
1602
|
+
Readable.prototype.pipe = function(dest, pipeOpts) {
|
|
1603
|
+
var src = this;
|
|
1604
|
+
var state = this._readableState;
|
|
1605
|
+
switch (state.pipesCount) {
|
|
1606
|
+
case 0:
|
|
1607
|
+
state.pipes = dest;
|
|
1608
|
+
break;
|
|
1609
|
+
case 1:
|
|
1610
|
+
state.pipes = [state.pipes, dest];
|
|
1611
|
+
break;
|
|
1612
|
+
default:
|
|
1613
|
+
state.pipes.push(dest);
|
|
1614
|
+
break;
|
|
1615
|
+
}
|
|
1616
|
+
state.pipesCount += 1;
|
|
1617
|
+
debug("pipe count=%d opts=%j", state.pipesCount, pipeOpts);
|
|
1618
|
+
var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
|
|
1619
|
+
var endFn = doEnd ? onend : unpipe;
|
|
1620
|
+
if (state.endEmitted) process.nextTick(endFn);
|
|
1621
|
+
else src.once("end", endFn);
|
|
1622
|
+
dest.on("unpipe", onunpipe);
|
|
1623
|
+
function onunpipe(readable, unpipeInfo) {
|
|
1624
|
+
debug("onunpipe");
|
|
1625
|
+
if (readable === src) {
|
|
1626
|
+
if (unpipeInfo && unpipeInfo.hasUnpiped === false) {
|
|
1627
|
+
unpipeInfo.hasUnpiped = true;
|
|
1628
|
+
cleanup();
|
|
1629
|
+
}
|
|
1630
|
+
}
|
|
1631
|
+
}
|
|
1632
|
+
function onend() {
|
|
1633
|
+
debug("onend");
|
|
1634
|
+
dest.end();
|
|
1635
|
+
}
|
|
1636
|
+
var ondrain = pipeOnDrain(src);
|
|
1637
|
+
dest.on("drain", ondrain);
|
|
1638
|
+
var cleanedUp = false;
|
|
1639
|
+
function cleanup() {
|
|
1640
|
+
debug("cleanup");
|
|
1641
|
+
dest.removeListener("close", onclose);
|
|
1642
|
+
dest.removeListener("finish", onfinish);
|
|
1643
|
+
dest.removeListener("drain", ondrain);
|
|
1644
|
+
dest.removeListener("error", onerror);
|
|
1645
|
+
dest.removeListener("unpipe", onunpipe);
|
|
1646
|
+
src.removeListener("end", onend);
|
|
1647
|
+
src.removeListener("end", unpipe);
|
|
1648
|
+
src.removeListener("data", ondata);
|
|
1649
|
+
cleanedUp = true;
|
|
1650
|
+
if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
|
|
1651
|
+
}
|
|
1652
|
+
src.on("data", ondata);
|
|
1653
|
+
function ondata(chunk) {
|
|
1654
|
+
debug("ondata");
|
|
1655
|
+
var ret = dest.write(chunk);
|
|
1656
|
+
debug("dest.write", ret);
|
|
1657
|
+
if (ret === false) {
|
|
1658
|
+
if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
|
|
1659
|
+
debug("false write response, pause", state.awaitDrain);
|
|
1660
|
+
state.awaitDrain++;
|
|
1661
|
+
}
|
|
1662
|
+
src.pause();
|
|
1663
|
+
}
|
|
1664
|
+
}
|
|
1665
|
+
function onerror(er) {
|
|
1666
|
+
debug("onerror", er);
|
|
1667
|
+
unpipe();
|
|
1668
|
+
dest.removeListener("error", onerror);
|
|
1669
|
+
if (EElistenerCount(dest, "error") === 0) errorOrDestroy(dest, er);
|
|
1670
|
+
}
|
|
1671
|
+
prependListener(dest, "error", onerror);
|
|
1672
|
+
function onclose() {
|
|
1673
|
+
dest.removeListener("finish", onfinish);
|
|
1674
|
+
unpipe();
|
|
1675
|
+
}
|
|
1676
|
+
dest.once("close", onclose);
|
|
1677
|
+
function onfinish() {
|
|
1678
|
+
debug("onfinish");
|
|
1679
|
+
dest.removeListener("close", onclose);
|
|
1680
|
+
unpipe();
|
|
1681
|
+
}
|
|
1682
|
+
dest.once("finish", onfinish);
|
|
1683
|
+
function unpipe() {
|
|
1684
|
+
debug("unpipe");
|
|
1685
|
+
src.unpipe(dest);
|
|
1686
|
+
}
|
|
1687
|
+
dest.emit("pipe", src);
|
|
1688
|
+
if (!state.flowing) {
|
|
1689
|
+
debug("pipe resume");
|
|
1690
|
+
src.resume();
|
|
1691
|
+
}
|
|
1692
|
+
return dest;
|
|
1693
|
+
};
|
|
1694
|
+
function pipeOnDrain(src) {
|
|
1695
|
+
return function pipeOnDrainFunctionResult() {
|
|
1696
|
+
var state = src._readableState;
|
|
1697
|
+
debug("pipeOnDrain", state.awaitDrain);
|
|
1698
|
+
if (state.awaitDrain) state.awaitDrain--;
|
|
1699
|
+
if (state.awaitDrain === 0 && EElistenerCount(src, "data")) {
|
|
1700
|
+
state.flowing = true;
|
|
1701
|
+
flow(src);
|
|
1702
|
+
}
|
|
1703
|
+
};
|
|
1704
|
+
}
|
|
1705
|
+
Readable.prototype.unpipe = function(dest) {
|
|
1706
|
+
var state = this._readableState;
|
|
1707
|
+
var unpipeInfo = {
|
|
1708
|
+
hasUnpiped: false
|
|
1709
|
+
};
|
|
1710
|
+
if (state.pipesCount === 0) return this;
|
|
1711
|
+
if (state.pipesCount === 1) {
|
|
1712
|
+
if (dest && dest !== state.pipes) return this;
|
|
1713
|
+
if (!dest) dest = state.pipes;
|
|
1714
|
+
state.pipes = null;
|
|
1715
|
+
state.pipesCount = 0;
|
|
1716
|
+
state.flowing = false;
|
|
1717
|
+
if (dest) dest.emit("unpipe", this, unpipeInfo);
|
|
1718
|
+
return this;
|
|
1719
|
+
}
|
|
1720
|
+
if (!dest) {
|
|
1721
|
+
var dests = state.pipes;
|
|
1722
|
+
var len = state.pipesCount;
|
|
1723
|
+
state.pipes = null;
|
|
1724
|
+
state.pipesCount = 0;
|
|
1725
|
+
state.flowing = false;
|
|
1726
|
+
for (var i = 0; i < len; i++) dests[i].emit("unpipe", this, {
|
|
1727
|
+
hasUnpiped: false
|
|
1728
|
+
});
|
|
1729
|
+
return this;
|
|
1730
|
+
}
|
|
1731
|
+
var index = indexOf(state.pipes, dest);
|
|
1732
|
+
if (index === -1) return this;
|
|
1733
|
+
state.pipes.splice(index, 1);
|
|
1734
|
+
state.pipesCount -= 1;
|
|
1735
|
+
if (state.pipesCount === 1) state.pipes = state.pipes[0];
|
|
1736
|
+
dest.emit("unpipe", this, unpipeInfo);
|
|
1737
|
+
return this;
|
|
1738
|
+
};
|
|
1739
|
+
Readable.prototype.on = function(ev, fn) {
|
|
1740
|
+
var res = Stream.prototype.on.call(this, ev, fn);
|
|
1741
|
+
var state = this._readableState;
|
|
1742
|
+
if (ev === "data") {
|
|
1743
|
+
state.readableListening = this.listenerCount("readable") > 0;
|
|
1744
|
+
if (state.flowing !== false) this.resume();
|
|
1745
|
+
} else if (ev === "readable") {
|
|
1746
|
+
if (!state.endEmitted && !state.readableListening) {
|
|
1747
|
+
state.readableListening = state.needReadable = true;
|
|
1748
|
+
state.flowing = false;
|
|
1749
|
+
state.emittedReadable = false;
|
|
1750
|
+
debug("on readable", state.length, state.reading);
|
|
1751
|
+
if (state.length) {
|
|
1752
|
+
emitReadable(this);
|
|
1753
|
+
} else if (!state.reading) {
|
|
1754
|
+
process.nextTick(nReadingNextTick, this);
|
|
1755
|
+
}
|
|
1756
|
+
}
|
|
1757
|
+
}
|
|
1758
|
+
return res;
|
|
1759
|
+
};
|
|
1760
|
+
Readable.prototype.addListener = Readable.prototype.on;
|
|
1761
|
+
Readable.prototype.removeListener = function(ev, fn) {
|
|
1762
|
+
var res = Stream.prototype.removeListener.call(this, ev, fn);
|
|
1763
|
+
if (ev === "readable") {
|
|
1764
|
+
process.nextTick(updateReadableListening, this);
|
|
1765
|
+
}
|
|
1766
|
+
return res;
|
|
1767
|
+
};
|
|
1768
|
+
Readable.prototype.removeAllListeners = function(ev) {
|
|
1769
|
+
var res = Stream.prototype.removeAllListeners.apply(this, arguments);
|
|
1770
|
+
if (ev === "readable" || ev === void 0) {
|
|
1771
|
+
process.nextTick(updateReadableListening, this);
|
|
1772
|
+
}
|
|
1773
|
+
return res;
|
|
1774
|
+
};
|
|
1775
|
+
function updateReadableListening(self2) {
|
|
1776
|
+
var state = self2._readableState;
|
|
1777
|
+
state.readableListening = self2.listenerCount("readable") > 0;
|
|
1778
|
+
if (state.resumeScheduled && !state.paused) {
|
|
1779
|
+
state.flowing = true;
|
|
1780
|
+
} else if (self2.listenerCount("data") > 0) {
|
|
1781
|
+
self2.resume();
|
|
1782
|
+
}
|
|
1783
|
+
}
|
|
1784
|
+
function nReadingNextTick(self2) {
|
|
1785
|
+
debug("readable nexttick read 0");
|
|
1786
|
+
self2.read(0);
|
|
1787
|
+
}
|
|
1788
|
+
Readable.prototype.resume = function() {
|
|
1789
|
+
var state = this._readableState;
|
|
1790
|
+
if (!state.flowing) {
|
|
1791
|
+
debug("resume");
|
|
1792
|
+
state.flowing = !state.readableListening;
|
|
1793
|
+
resume(this, state);
|
|
1794
|
+
}
|
|
1795
|
+
state.paused = false;
|
|
1796
|
+
return this;
|
|
1797
|
+
};
|
|
1798
|
+
function resume(stream, state) {
|
|
1799
|
+
if (!state.resumeScheduled) {
|
|
1800
|
+
state.resumeScheduled = true;
|
|
1801
|
+
process.nextTick(resume_, stream, state);
|
|
1802
|
+
}
|
|
1803
|
+
}
|
|
1804
|
+
function resume_(stream, state) {
|
|
1805
|
+
debug("resume", state.reading);
|
|
1806
|
+
if (!state.reading) {
|
|
1807
|
+
stream.read(0);
|
|
1808
|
+
}
|
|
1809
|
+
state.resumeScheduled = false;
|
|
1810
|
+
stream.emit("resume");
|
|
1811
|
+
flow(stream);
|
|
1812
|
+
if (state.flowing && !state.reading) stream.read(0);
|
|
1813
|
+
}
|
|
1814
|
+
Readable.prototype.pause = function() {
|
|
1815
|
+
debug("call pause flowing=%j", this._readableState.flowing);
|
|
1816
|
+
if (this._readableState.flowing !== false) {
|
|
1817
|
+
debug("pause");
|
|
1818
|
+
this._readableState.flowing = false;
|
|
1819
|
+
this.emit("pause");
|
|
1820
|
+
}
|
|
1821
|
+
this._readableState.paused = true;
|
|
1822
|
+
return this;
|
|
1823
|
+
};
|
|
1824
|
+
function flow(stream) {
|
|
1825
|
+
var state = stream._readableState;
|
|
1826
|
+
debug("flow", state.flowing);
|
|
1827
|
+
while (state.flowing && stream.read() !== null) ;
|
|
1828
|
+
}
|
|
1829
|
+
Readable.prototype.wrap = function(stream) {
|
|
1830
|
+
var _this = this;
|
|
1831
|
+
var state = this._readableState;
|
|
1832
|
+
var paused = false;
|
|
1833
|
+
stream.on("end", function() {
|
|
1834
|
+
debug("wrapped end");
|
|
1835
|
+
if (state.decoder && !state.ended) {
|
|
1836
|
+
var chunk = state.decoder.end();
|
|
1837
|
+
if (chunk && chunk.length) _this.push(chunk);
|
|
1838
|
+
}
|
|
1839
|
+
_this.push(null);
|
|
1840
|
+
});
|
|
1841
|
+
stream.on("data", function(chunk) {
|
|
1842
|
+
debug("wrapped data");
|
|
1843
|
+
if (state.decoder) chunk = state.decoder.write(chunk);
|
|
1844
|
+
if (state.objectMode && (chunk === null || chunk === void 0)) return;
|
|
1845
|
+
else if (!state.objectMode && (!chunk || !chunk.length)) return;
|
|
1846
|
+
var ret = _this.push(chunk);
|
|
1847
|
+
if (!ret) {
|
|
1848
|
+
paused = true;
|
|
1849
|
+
stream.pause();
|
|
1850
|
+
}
|
|
1851
|
+
});
|
|
1852
|
+
for (var i in stream) {
|
|
1853
|
+
if (this[i] === void 0 && typeof stream[i] === "function") {
|
|
1854
|
+
this[i] = /* @__PURE__ */ function methodWrap(method) {
|
|
1855
|
+
return function methodWrapReturnFunction() {
|
|
1856
|
+
return stream[method].apply(stream, arguments);
|
|
1857
|
+
};
|
|
1858
|
+
}(i);
|
|
1859
|
+
}
|
|
1860
|
+
}
|
|
1861
|
+
for (var n = 0; n < kProxyEvents.length; n++) {
|
|
1862
|
+
stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));
|
|
1863
|
+
}
|
|
1864
|
+
this._read = function(n2) {
|
|
1865
|
+
debug("wrapped _read", n2);
|
|
1866
|
+
if (paused) {
|
|
1867
|
+
paused = false;
|
|
1868
|
+
stream.resume();
|
|
1869
|
+
}
|
|
1870
|
+
};
|
|
1871
|
+
return this;
|
|
1872
|
+
};
|
|
1873
|
+
if (typeof Symbol === "function") {
|
|
1874
|
+
Readable.prototype[Symbol.asyncIterator] = function() {
|
|
1875
|
+
if (createReadableStreamAsyncIterator === void 0) {
|
|
1876
|
+
createReadableStreamAsyncIterator = require_async_iterator();
|
|
1877
|
+
}
|
|
1878
|
+
return createReadableStreamAsyncIterator(this);
|
|
1879
|
+
};
|
|
1880
|
+
}
|
|
1881
|
+
Object.defineProperty(Readable.prototype, "readableHighWaterMark", {
|
|
1882
|
+
// making it explicit this property is not enumerable
|
|
1883
|
+
// because otherwise some prototype manipulation in
|
|
1884
|
+
// userland will fail
|
|
1885
|
+
enumerable: false,
|
|
1886
|
+
get: function get() {
|
|
1887
|
+
return this._readableState.highWaterMark;
|
|
1888
|
+
}
|
|
1889
|
+
});
|
|
1890
|
+
Object.defineProperty(Readable.prototype, "readableBuffer", {
|
|
1891
|
+
// making it explicit this property is not enumerable
|
|
1892
|
+
// because otherwise some prototype manipulation in
|
|
1893
|
+
// userland will fail
|
|
1894
|
+
enumerable: false,
|
|
1895
|
+
get: function get() {
|
|
1896
|
+
return this._readableState && this._readableState.buffer;
|
|
1897
|
+
}
|
|
1898
|
+
});
|
|
1899
|
+
Object.defineProperty(Readable.prototype, "readableFlowing", {
|
|
1900
|
+
// making it explicit this property is not enumerable
|
|
1901
|
+
// because otherwise some prototype manipulation in
|
|
1902
|
+
// userland will fail
|
|
1903
|
+
enumerable: false,
|
|
1904
|
+
get: function get() {
|
|
1905
|
+
return this._readableState.flowing;
|
|
1906
|
+
},
|
|
1907
|
+
set: function set(state) {
|
|
1908
|
+
if (this._readableState) {
|
|
1909
|
+
this._readableState.flowing = state;
|
|
1910
|
+
}
|
|
1911
|
+
}
|
|
1912
|
+
});
|
|
1913
|
+
Readable._fromList = fromList;
|
|
1914
|
+
Object.defineProperty(Readable.prototype, "readableLength", {
|
|
1915
|
+
// making it explicit this property is not enumerable
|
|
1916
|
+
// because otherwise some prototype manipulation in
|
|
1917
|
+
// userland will fail
|
|
1918
|
+
enumerable: false,
|
|
1919
|
+
get: function get() {
|
|
1920
|
+
return this._readableState.length;
|
|
1921
|
+
}
|
|
1922
|
+
});
|
|
1923
|
+
function fromList(n, state) {
|
|
1924
|
+
if (state.length === 0) return null;
|
|
1925
|
+
var ret;
|
|
1926
|
+
if (state.objectMode) ret = state.buffer.shift();
|
|
1927
|
+
else if (!n || n >= state.length) {
|
|
1928
|
+
if (state.decoder) ret = state.buffer.join("");
|
|
1929
|
+
else if (state.buffer.length === 1) ret = state.buffer.first();
|
|
1930
|
+
else ret = state.buffer.concat(state.length);
|
|
1931
|
+
state.buffer.clear();
|
|
1932
|
+
} else {
|
|
1933
|
+
ret = state.buffer.consume(n, state.decoder);
|
|
1934
|
+
}
|
|
1935
|
+
return ret;
|
|
1936
|
+
}
|
|
1937
|
+
function endReadable(stream) {
|
|
1938
|
+
var state = stream._readableState;
|
|
1939
|
+
debug("endReadable", state.endEmitted);
|
|
1940
|
+
if (!state.endEmitted) {
|
|
1941
|
+
state.ended = true;
|
|
1942
|
+
process.nextTick(endReadableNT, state, stream);
|
|
1943
|
+
}
|
|
1944
|
+
}
|
|
1945
|
+
function endReadableNT(state, stream) {
|
|
1946
|
+
debug("endReadableNT", state.endEmitted, state.length);
|
|
1947
|
+
if (!state.endEmitted && state.length === 0) {
|
|
1948
|
+
state.endEmitted = true;
|
|
1949
|
+
stream.readable = false;
|
|
1950
|
+
stream.emit("end");
|
|
1951
|
+
if (state.autoDestroy) {
|
|
1952
|
+
var wState = stream._writableState;
|
|
1953
|
+
if (!wState || wState.autoDestroy && wState.finished) {
|
|
1954
|
+
stream.destroy();
|
|
1955
|
+
}
|
|
1956
|
+
}
|
|
1957
|
+
}
|
|
1958
|
+
}
|
|
1959
|
+
if (typeof Symbol === "function") {
|
|
1960
|
+
Readable.from = function(iterable, opts) {
|
|
1961
|
+
if (from === void 0) {
|
|
1962
|
+
from = require_from();
|
|
1963
|
+
}
|
|
1964
|
+
return from(Readable, iterable, opts);
|
|
1965
|
+
};
|
|
1966
|
+
}
|
|
1967
|
+
function indexOf(xs, x) {
|
|
1968
|
+
for (var i = 0, l = xs.length; i < l; i++) {
|
|
1969
|
+
if (xs[i] === x) return i;
|
|
1970
|
+
}
|
|
1971
|
+
return -1;
|
|
1972
|
+
}
|
|
1973
|
+
}
|
|
1974
|
+
});
|
|
1975
|
+
|
|
1976
|
+
// ../../node_modules/readable-stream/lib/_stream_duplex.js
|
|
1977
|
+
var require_stream_duplex = __commonJS({
|
|
1978
|
+
"../../node_modules/readable-stream/lib/_stream_duplex.js"(exports2, module2) {
|
|
1979
|
+
"use strict";
|
|
1980
|
+
var objectKeys = Object.keys || function(obj) {
|
|
1981
|
+
var keys2 = [];
|
|
1982
|
+
for (var key in obj) keys2.push(key);
|
|
1983
|
+
return keys2;
|
|
1984
|
+
};
|
|
1985
|
+
module2.exports = Duplex;
|
|
1986
|
+
var Readable = require_stream_readable();
|
|
1987
|
+
var Writable = require_stream_writable();
|
|
1988
|
+
require_inherits()(Duplex, Readable);
|
|
1989
|
+
{
|
|
1990
|
+
keys = objectKeys(Writable.prototype);
|
|
1991
|
+
for (v = 0; v < keys.length; v++) {
|
|
1992
|
+
method = keys[v];
|
|
1993
|
+
if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
|
|
1994
|
+
}
|
|
1995
|
+
}
|
|
1996
|
+
var keys;
|
|
1997
|
+
var method;
|
|
1998
|
+
var v;
|
|
1999
|
+
function Duplex(options) {
|
|
2000
|
+
if (!(this instanceof Duplex)) return new Duplex(options);
|
|
2001
|
+
Readable.call(this, options);
|
|
2002
|
+
Writable.call(this, options);
|
|
2003
|
+
this.allowHalfOpen = true;
|
|
2004
|
+
if (options) {
|
|
2005
|
+
if (options.readable === false) this.readable = false;
|
|
2006
|
+
if (options.writable === false) this.writable = false;
|
|
2007
|
+
if (options.allowHalfOpen === false) {
|
|
2008
|
+
this.allowHalfOpen = false;
|
|
2009
|
+
this.once("end", onend);
|
|
2010
|
+
}
|
|
2011
|
+
}
|
|
2012
|
+
}
|
|
2013
|
+
Object.defineProperty(Duplex.prototype, "writableHighWaterMark", {
|
|
2014
|
+
// making it explicit this property is not enumerable
|
|
2015
|
+
// because otherwise some prototype manipulation in
|
|
2016
|
+
// userland will fail
|
|
2017
|
+
enumerable: false,
|
|
2018
|
+
get: function get() {
|
|
2019
|
+
return this._writableState.highWaterMark;
|
|
2020
|
+
}
|
|
2021
|
+
});
|
|
2022
|
+
Object.defineProperty(Duplex.prototype, "writableBuffer", {
|
|
2023
|
+
// making it explicit this property is not enumerable
|
|
2024
|
+
// because otherwise some prototype manipulation in
|
|
2025
|
+
// userland will fail
|
|
2026
|
+
enumerable: false,
|
|
2027
|
+
get: function get() {
|
|
2028
|
+
return this._writableState && this._writableState.getBuffer();
|
|
2029
|
+
}
|
|
2030
|
+
});
|
|
2031
|
+
Object.defineProperty(Duplex.prototype, "writableLength", {
|
|
2032
|
+
// making it explicit this property is not enumerable
|
|
2033
|
+
// because otherwise some prototype manipulation in
|
|
2034
|
+
// userland will fail
|
|
2035
|
+
enumerable: false,
|
|
2036
|
+
get: function get() {
|
|
2037
|
+
return this._writableState.length;
|
|
2038
|
+
}
|
|
2039
|
+
});
|
|
2040
|
+
function onend() {
|
|
2041
|
+
if (this._writableState.ended) return;
|
|
2042
|
+
process.nextTick(onEndNT, this);
|
|
2043
|
+
}
|
|
2044
|
+
function onEndNT(self2) {
|
|
2045
|
+
self2.end();
|
|
2046
|
+
}
|
|
2047
|
+
Object.defineProperty(Duplex.prototype, "destroyed", {
|
|
2048
|
+
// making it explicit this property is not enumerable
|
|
2049
|
+
// because otherwise some prototype manipulation in
|
|
2050
|
+
// userland will fail
|
|
2051
|
+
enumerable: false,
|
|
2052
|
+
get: function get() {
|
|
2053
|
+
if (this._readableState === void 0 || this._writableState === void 0) {
|
|
2054
|
+
return false;
|
|
2055
|
+
}
|
|
2056
|
+
return this._readableState.destroyed && this._writableState.destroyed;
|
|
2057
|
+
},
|
|
2058
|
+
set: function set(value) {
|
|
2059
|
+
if (this._readableState === void 0 || this._writableState === void 0) {
|
|
2060
|
+
return;
|
|
2061
|
+
}
|
|
2062
|
+
this._readableState.destroyed = value;
|
|
2063
|
+
this._writableState.destroyed = value;
|
|
2064
|
+
}
|
|
2065
|
+
});
|
|
2066
|
+
}
|
|
2067
|
+
});
|
|
2068
|
+
|
|
2069
|
+
// ../../node_modules/readable-stream/lib/_stream_writable.js
|
|
2070
|
+
var require_stream_writable = __commonJS({
|
|
2071
|
+
"../../node_modules/readable-stream/lib/_stream_writable.js"(exports2, module2) {
|
|
2072
|
+
"use strict";
|
|
2073
|
+
module2.exports = Writable;
|
|
2074
|
+
function CorkedRequest(state) {
|
|
2075
|
+
var _this = this;
|
|
2076
|
+
this.next = null;
|
|
2077
|
+
this.entry = null;
|
|
2078
|
+
this.finish = function() {
|
|
2079
|
+
onCorkedFinish(_this, state);
|
|
2080
|
+
};
|
|
2081
|
+
}
|
|
2082
|
+
var Duplex;
|
|
2083
|
+
Writable.WritableState = WritableState;
|
|
2084
|
+
var internalUtil = {
|
|
2085
|
+
deprecate: require_node()
|
|
2086
|
+
};
|
|
2087
|
+
var Stream = require_stream();
|
|
2088
|
+
var Buffer2 = require("buffer").Buffer;
|
|
2089
|
+
var OurUint8Array = (typeof global !== "undefined" ? global : typeof window !== "undefined" ? window : typeof self !== "undefined" ? self : {}).Uint8Array || function() {
|
|
2090
|
+
};
|
|
2091
|
+
function _uint8ArrayToBuffer(chunk) {
|
|
2092
|
+
return Buffer2.from(chunk);
|
|
2093
|
+
}
|
|
2094
|
+
function _isUint8Array(obj) {
|
|
2095
|
+
return Buffer2.isBuffer(obj) || obj instanceof OurUint8Array;
|
|
2096
|
+
}
|
|
2097
|
+
var destroyImpl = require_destroy();
|
|
2098
|
+
var _require = require_state();
|
|
2099
|
+
var getHighWaterMark = _require.getHighWaterMark;
|
|
2100
|
+
var _require$codes = require_errors().codes;
|
|
2101
|
+
var ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE;
|
|
2102
|
+
var ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED;
|
|
2103
|
+
var ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK;
|
|
2104
|
+
var ERR_STREAM_CANNOT_PIPE = _require$codes.ERR_STREAM_CANNOT_PIPE;
|
|
2105
|
+
var ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED;
|
|
2106
|
+
var ERR_STREAM_NULL_VALUES = _require$codes.ERR_STREAM_NULL_VALUES;
|
|
2107
|
+
var ERR_STREAM_WRITE_AFTER_END = _require$codes.ERR_STREAM_WRITE_AFTER_END;
|
|
2108
|
+
var ERR_UNKNOWN_ENCODING = _require$codes.ERR_UNKNOWN_ENCODING;
|
|
2109
|
+
var errorOrDestroy = destroyImpl.errorOrDestroy;
|
|
2110
|
+
require_inherits()(Writable, Stream);
|
|
2111
|
+
function nop() {
|
|
2112
|
+
}
|
|
2113
|
+
function WritableState(options, stream, isDuplex) {
|
|
2114
|
+
Duplex = Duplex || require_stream_duplex();
|
|
2115
|
+
options = options || {};
|
|
2116
|
+
if (typeof isDuplex !== "boolean") isDuplex = stream instanceof Duplex;
|
|
2117
|
+
this.objectMode = !!options.objectMode;
|
|
2118
|
+
if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
|
|
2119
|
+
this.highWaterMark = getHighWaterMark(this, options, "writableHighWaterMark", isDuplex);
|
|
2120
|
+
this.finalCalled = false;
|
|
2121
|
+
this.needDrain = false;
|
|
2122
|
+
this.ending = false;
|
|
2123
|
+
this.ended = false;
|
|
2124
|
+
this.finished = false;
|
|
2125
|
+
this.destroyed = false;
|
|
2126
|
+
var noDecode = options.decodeStrings === false;
|
|
2127
|
+
this.decodeStrings = !noDecode;
|
|
2128
|
+
this.defaultEncoding = options.defaultEncoding || "utf8";
|
|
2129
|
+
this.length = 0;
|
|
2130
|
+
this.writing = false;
|
|
2131
|
+
this.corked = 0;
|
|
2132
|
+
this.sync = true;
|
|
2133
|
+
this.bufferProcessing = false;
|
|
2134
|
+
this.onwrite = function(er) {
|
|
2135
|
+
onwrite(stream, er);
|
|
2136
|
+
};
|
|
2137
|
+
this.writecb = null;
|
|
2138
|
+
this.writelen = 0;
|
|
2139
|
+
this.bufferedRequest = null;
|
|
2140
|
+
this.lastBufferedRequest = null;
|
|
2141
|
+
this.pendingcb = 0;
|
|
2142
|
+
this.prefinished = false;
|
|
2143
|
+
this.errorEmitted = false;
|
|
2144
|
+
this.emitClose = options.emitClose !== false;
|
|
2145
|
+
this.autoDestroy = !!options.autoDestroy;
|
|
2146
|
+
this.bufferedRequestCount = 0;
|
|
2147
|
+
this.corkedRequestsFree = new CorkedRequest(this);
|
|
2148
|
+
}
|
|
2149
|
+
WritableState.prototype.getBuffer = function getBuffer() {
|
|
2150
|
+
var current = this.bufferedRequest;
|
|
2151
|
+
var out = [];
|
|
2152
|
+
while (current) {
|
|
2153
|
+
out.push(current);
|
|
2154
|
+
current = current.next;
|
|
2155
|
+
}
|
|
2156
|
+
return out;
|
|
2157
|
+
};
|
|
2158
|
+
(function() {
|
|
2159
|
+
try {
|
|
2160
|
+
Object.defineProperty(WritableState.prototype, "buffer", {
|
|
2161
|
+
get: internalUtil.deprecate(function writableStateBufferGetter() {
|
|
2162
|
+
return this.getBuffer();
|
|
2163
|
+
}, "_writableState.buffer is deprecated. Use _writableState.getBuffer instead.", "DEP0003")
|
|
2164
|
+
});
|
|
2165
|
+
} catch (_) {
|
|
2166
|
+
}
|
|
2167
|
+
})();
|
|
2168
|
+
var realHasInstance;
|
|
2169
|
+
if (typeof Symbol === "function" && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === "function") {
|
|
2170
|
+
realHasInstance = Function.prototype[Symbol.hasInstance];
|
|
2171
|
+
Object.defineProperty(Writable, Symbol.hasInstance, {
|
|
2172
|
+
value: function value(object) {
|
|
2173
|
+
if (realHasInstance.call(this, object)) return true;
|
|
2174
|
+
if (this !== Writable) return false;
|
|
2175
|
+
return object && object._writableState instanceof WritableState;
|
|
2176
|
+
}
|
|
2177
|
+
});
|
|
2178
|
+
} else {
|
|
2179
|
+
realHasInstance = function realHasInstance2(object) {
|
|
2180
|
+
return object instanceof this;
|
|
2181
|
+
};
|
|
2182
|
+
}
|
|
2183
|
+
function Writable(options) {
|
|
2184
|
+
Duplex = Duplex || require_stream_duplex();
|
|
2185
|
+
var isDuplex = this instanceof Duplex;
|
|
2186
|
+
if (!isDuplex && !realHasInstance.call(Writable, this)) return new Writable(options);
|
|
2187
|
+
this._writableState = new WritableState(options, this, isDuplex);
|
|
2188
|
+
this.writable = true;
|
|
2189
|
+
if (options) {
|
|
2190
|
+
if (typeof options.write === "function") this._write = options.write;
|
|
2191
|
+
if (typeof options.writev === "function") this._writev = options.writev;
|
|
2192
|
+
if (typeof options.destroy === "function") this._destroy = options.destroy;
|
|
2193
|
+
if (typeof options.final === "function") this._final = options.final;
|
|
2194
|
+
}
|
|
2195
|
+
Stream.call(this);
|
|
2196
|
+
}
|
|
2197
|
+
Writable.prototype.pipe = function() {
|
|
2198
|
+
errorOrDestroy(this, new ERR_STREAM_CANNOT_PIPE());
|
|
2199
|
+
};
|
|
2200
|
+
function writeAfterEnd(stream, cb) {
|
|
2201
|
+
var er = new ERR_STREAM_WRITE_AFTER_END();
|
|
2202
|
+
errorOrDestroy(stream, er);
|
|
2203
|
+
process.nextTick(cb, er);
|
|
2204
|
+
}
|
|
2205
|
+
function validChunk(stream, state, chunk, cb) {
|
|
2206
|
+
var er;
|
|
2207
|
+
if (chunk === null) {
|
|
2208
|
+
er = new ERR_STREAM_NULL_VALUES();
|
|
2209
|
+
} else if (typeof chunk !== "string" && !state.objectMode) {
|
|
2210
|
+
er = new ERR_INVALID_ARG_TYPE("chunk", ["string", "Buffer"], chunk);
|
|
2211
|
+
}
|
|
2212
|
+
if (er) {
|
|
2213
|
+
errorOrDestroy(stream, er);
|
|
2214
|
+
process.nextTick(cb, er);
|
|
2215
|
+
return false;
|
|
2216
|
+
}
|
|
2217
|
+
return true;
|
|
2218
|
+
}
|
|
2219
|
+
Writable.prototype.write = function(chunk, encoding, cb) {
|
|
2220
|
+
var state = this._writableState;
|
|
2221
|
+
var ret = false;
|
|
2222
|
+
var isBuf = !state.objectMode && _isUint8Array(chunk);
|
|
2223
|
+
if (isBuf && !Buffer2.isBuffer(chunk)) {
|
|
2224
|
+
chunk = _uint8ArrayToBuffer(chunk);
|
|
2225
|
+
}
|
|
2226
|
+
if (typeof encoding === "function") {
|
|
2227
|
+
cb = encoding;
|
|
2228
|
+
encoding = null;
|
|
2229
|
+
}
|
|
2230
|
+
if (isBuf) encoding = "buffer";
|
|
2231
|
+
else if (!encoding) encoding = state.defaultEncoding;
|
|
2232
|
+
if (typeof cb !== "function") cb = nop;
|
|
2233
|
+
if (state.ending) writeAfterEnd(this, cb);
|
|
2234
|
+
else if (isBuf || validChunk(this, state, chunk, cb)) {
|
|
2235
|
+
state.pendingcb++;
|
|
2236
|
+
ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
|
|
2237
|
+
}
|
|
2238
|
+
return ret;
|
|
2239
|
+
};
|
|
2240
|
+
Writable.prototype.cork = function() {
|
|
2241
|
+
this._writableState.corked++;
|
|
2242
|
+
};
|
|
2243
|
+
Writable.prototype.uncork = function() {
|
|
2244
|
+
var state = this._writableState;
|
|
2245
|
+
if (state.corked) {
|
|
2246
|
+
state.corked--;
|
|
2247
|
+
if (!state.writing && !state.corked && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
|
|
2248
|
+
}
|
|
2249
|
+
};
|
|
2250
|
+
Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
|
|
2251
|
+
if (typeof encoding === "string") encoding = encoding.toLowerCase();
|
|
2252
|
+
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);
|
|
2253
|
+
this._writableState.defaultEncoding = encoding;
|
|
2254
|
+
return this;
|
|
2255
|
+
};
|
|
2256
|
+
Object.defineProperty(Writable.prototype, "writableBuffer", {
|
|
2257
|
+
// making it explicit this property is not enumerable
|
|
2258
|
+
// because otherwise some prototype manipulation in
|
|
2259
|
+
// userland will fail
|
|
2260
|
+
enumerable: false,
|
|
2261
|
+
get: function get() {
|
|
2262
|
+
return this._writableState && this._writableState.getBuffer();
|
|
2263
|
+
}
|
|
2264
|
+
});
|
|
2265
|
+
function decodeChunk(state, chunk, encoding) {
|
|
2266
|
+
if (!state.objectMode && state.decodeStrings !== false && typeof chunk === "string") {
|
|
2267
|
+
chunk = Buffer2.from(chunk, encoding);
|
|
2268
|
+
}
|
|
2269
|
+
return chunk;
|
|
2270
|
+
}
|
|
2271
|
+
Object.defineProperty(Writable.prototype, "writableHighWaterMark", {
|
|
2272
|
+
// making it explicit this property is not enumerable
|
|
2273
|
+
// because otherwise some prototype manipulation in
|
|
2274
|
+
// userland will fail
|
|
2275
|
+
enumerable: false,
|
|
2276
|
+
get: function get() {
|
|
2277
|
+
return this._writableState.highWaterMark;
|
|
2278
|
+
}
|
|
2279
|
+
});
|
|
2280
|
+
function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
|
|
2281
|
+
if (!isBuf) {
|
|
2282
|
+
var newChunk = decodeChunk(state, chunk, encoding);
|
|
2283
|
+
if (chunk !== newChunk) {
|
|
2284
|
+
isBuf = true;
|
|
2285
|
+
encoding = "buffer";
|
|
2286
|
+
chunk = newChunk;
|
|
2287
|
+
}
|
|
2288
|
+
}
|
|
2289
|
+
var len = state.objectMode ? 1 : chunk.length;
|
|
2290
|
+
state.length += len;
|
|
2291
|
+
var ret = state.length < state.highWaterMark;
|
|
2292
|
+
if (!ret) state.needDrain = true;
|
|
2293
|
+
if (state.writing || state.corked) {
|
|
2294
|
+
var last = state.lastBufferedRequest;
|
|
2295
|
+
state.lastBufferedRequest = {
|
|
2296
|
+
chunk,
|
|
2297
|
+
encoding,
|
|
2298
|
+
isBuf,
|
|
2299
|
+
callback: cb,
|
|
2300
|
+
next: null
|
|
2301
|
+
};
|
|
2302
|
+
if (last) {
|
|
2303
|
+
last.next = state.lastBufferedRequest;
|
|
2304
|
+
} else {
|
|
2305
|
+
state.bufferedRequest = state.lastBufferedRequest;
|
|
2306
|
+
}
|
|
2307
|
+
state.bufferedRequestCount += 1;
|
|
2308
|
+
} else {
|
|
2309
|
+
doWrite(stream, state, false, len, chunk, encoding, cb);
|
|
2310
|
+
}
|
|
2311
|
+
return ret;
|
|
2312
|
+
}
|
|
2313
|
+
function doWrite(stream, state, writev, len, chunk, encoding, cb) {
|
|
2314
|
+
state.writelen = len;
|
|
2315
|
+
state.writecb = cb;
|
|
2316
|
+
state.writing = true;
|
|
2317
|
+
state.sync = true;
|
|
2318
|
+
if (state.destroyed) state.onwrite(new ERR_STREAM_DESTROYED("write"));
|
|
2319
|
+
else if (writev) stream._writev(chunk, state.onwrite);
|
|
2320
|
+
else stream._write(chunk, encoding, state.onwrite);
|
|
2321
|
+
state.sync = false;
|
|
2322
|
+
}
|
|
2323
|
+
function onwriteError(stream, state, sync, er, cb) {
|
|
2324
|
+
--state.pendingcb;
|
|
2325
|
+
if (sync) {
|
|
2326
|
+
process.nextTick(cb, er);
|
|
2327
|
+
process.nextTick(finishMaybe, stream, state);
|
|
2328
|
+
stream._writableState.errorEmitted = true;
|
|
2329
|
+
errorOrDestroy(stream, er);
|
|
2330
|
+
} else {
|
|
2331
|
+
cb(er);
|
|
2332
|
+
stream._writableState.errorEmitted = true;
|
|
2333
|
+
errorOrDestroy(stream, er);
|
|
2334
|
+
finishMaybe(stream, state);
|
|
2335
|
+
}
|
|
2336
|
+
}
|
|
2337
|
+
function onwriteStateUpdate(state) {
|
|
2338
|
+
state.writing = false;
|
|
2339
|
+
state.writecb = null;
|
|
2340
|
+
state.length -= state.writelen;
|
|
2341
|
+
state.writelen = 0;
|
|
2342
|
+
}
|
|
2343
|
+
function onwrite(stream, er) {
|
|
2344
|
+
var state = stream._writableState;
|
|
2345
|
+
var sync = state.sync;
|
|
2346
|
+
var cb = state.writecb;
|
|
2347
|
+
if (typeof cb !== "function") throw new ERR_MULTIPLE_CALLBACK();
|
|
2348
|
+
onwriteStateUpdate(state);
|
|
2349
|
+
if (er) onwriteError(stream, state, sync, er, cb);
|
|
2350
|
+
else {
|
|
2351
|
+
var finished = needFinish(state) || stream.destroyed;
|
|
2352
|
+
if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
|
|
2353
|
+
clearBuffer(stream, state);
|
|
2354
|
+
}
|
|
2355
|
+
if (sync) {
|
|
2356
|
+
process.nextTick(afterWrite, stream, state, finished, cb);
|
|
2357
|
+
} else {
|
|
2358
|
+
afterWrite(stream, state, finished, cb);
|
|
2359
|
+
}
|
|
2360
|
+
}
|
|
2361
|
+
}
|
|
2362
|
+
function afterWrite(stream, state, finished, cb) {
|
|
2363
|
+
if (!finished) onwriteDrain(stream, state);
|
|
2364
|
+
state.pendingcb--;
|
|
2365
|
+
cb();
|
|
2366
|
+
finishMaybe(stream, state);
|
|
2367
|
+
}
|
|
2368
|
+
function onwriteDrain(stream, state) {
|
|
2369
|
+
if (state.length === 0 && state.needDrain) {
|
|
2370
|
+
state.needDrain = false;
|
|
2371
|
+
stream.emit("drain");
|
|
2372
|
+
}
|
|
2373
|
+
}
|
|
2374
|
+
function clearBuffer(stream, state) {
|
|
2375
|
+
state.bufferProcessing = true;
|
|
2376
|
+
var entry = state.bufferedRequest;
|
|
2377
|
+
if (stream._writev && entry && entry.next) {
|
|
2378
|
+
var l = state.bufferedRequestCount;
|
|
2379
|
+
var buffer = new Array(l);
|
|
2380
|
+
var holder = state.corkedRequestsFree;
|
|
2381
|
+
holder.entry = entry;
|
|
2382
|
+
var count = 0;
|
|
2383
|
+
var allBuffers = true;
|
|
2384
|
+
while (entry) {
|
|
2385
|
+
buffer[count] = entry;
|
|
2386
|
+
if (!entry.isBuf) allBuffers = false;
|
|
2387
|
+
entry = entry.next;
|
|
2388
|
+
count += 1;
|
|
2389
|
+
}
|
|
2390
|
+
buffer.allBuffers = allBuffers;
|
|
2391
|
+
doWrite(stream, state, true, state.length, buffer, "", holder.finish);
|
|
2392
|
+
state.pendingcb++;
|
|
2393
|
+
state.lastBufferedRequest = null;
|
|
2394
|
+
if (holder.next) {
|
|
2395
|
+
state.corkedRequestsFree = holder.next;
|
|
2396
|
+
holder.next = null;
|
|
2397
|
+
} else {
|
|
2398
|
+
state.corkedRequestsFree = new CorkedRequest(state);
|
|
2399
|
+
}
|
|
2400
|
+
state.bufferedRequestCount = 0;
|
|
2401
|
+
} else {
|
|
2402
|
+
while (entry) {
|
|
2403
|
+
var chunk = entry.chunk;
|
|
2404
|
+
var encoding = entry.encoding;
|
|
2405
|
+
var cb = entry.callback;
|
|
2406
|
+
var len = state.objectMode ? 1 : chunk.length;
|
|
2407
|
+
doWrite(stream, state, false, len, chunk, encoding, cb);
|
|
2408
|
+
entry = entry.next;
|
|
2409
|
+
state.bufferedRequestCount--;
|
|
2410
|
+
if (state.writing) {
|
|
2411
|
+
break;
|
|
2412
|
+
}
|
|
2413
|
+
}
|
|
2414
|
+
if (entry === null) state.lastBufferedRequest = null;
|
|
2415
|
+
}
|
|
2416
|
+
state.bufferedRequest = entry;
|
|
2417
|
+
state.bufferProcessing = false;
|
|
2418
|
+
}
|
|
2419
|
+
Writable.prototype._write = function(chunk, encoding, cb) {
|
|
2420
|
+
cb(new ERR_METHOD_NOT_IMPLEMENTED("_write()"));
|
|
2421
|
+
};
|
|
2422
|
+
Writable.prototype._writev = null;
|
|
2423
|
+
Writable.prototype.end = function(chunk, encoding, cb) {
|
|
2424
|
+
var state = this._writableState;
|
|
2425
|
+
if (typeof chunk === "function") {
|
|
2426
|
+
cb = chunk;
|
|
2427
|
+
chunk = null;
|
|
2428
|
+
encoding = null;
|
|
2429
|
+
} else if (typeof encoding === "function") {
|
|
2430
|
+
cb = encoding;
|
|
2431
|
+
encoding = null;
|
|
2432
|
+
}
|
|
2433
|
+
if (chunk !== null && chunk !== void 0) this.write(chunk, encoding);
|
|
2434
|
+
if (state.corked) {
|
|
2435
|
+
state.corked = 1;
|
|
2436
|
+
this.uncork();
|
|
2437
|
+
}
|
|
2438
|
+
if (!state.ending) endWritable(this, state, cb);
|
|
2439
|
+
return this;
|
|
2440
|
+
};
|
|
2441
|
+
Object.defineProperty(Writable.prototype, "writableLength", {
|
|
2442
|
+
// making it explicit this property is not enumerable
|
|
2443
|
+
// because otherwise some prototype manipulation in
|
|
2444
|
+
// userland will fail
|
|
2445
|
+
enumerable: false,
|
|
2446
|
+
get: function get() {
|
|
2447
|
+
return this._writableState.length;
|
|
2448
|
+
}
|
|
2449
|
+
});
|
|
2450
|
+
function needFinish(state) {
|
|
2451
|
+
return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
|
|
2452
|
+
}
|
|
2453
|
+
function callFinal(stream, state) {
|
|
2454
|
+
stream._final(function(err) {
|
|
2455
|
+
state.pendingcb--;
|
|
2456
|
+
if (err) {
|
|
2457
|
+
errorOrDestroy(stream, err);
|
|
2458
|
+
}
|
|
2459
|
+
state.prefinished = true;
|
|
2460
|
+
stream.emit("prefinish");
|
|
2461
|
+
finishMaybe(stream, state);
|
|
2462
|
+
});
|
|
2463
|
+
}
|
|
2464
|
+
function prefinish(stream, state) {
|
|
2465
|
+
if (!state.prefinished && !state.finalCalled) {
|
|
2466
|
+
if (typeof stream._final === "function" && !state.destroyed) {
|
|
2467
|
+
state.pendingcb++;
|
|
2468
|
+
state.finalCalled = true;
|
|
2469
|
+
process.nextTick(callFinal, stream, state);
|
|
2470
|
+
} else {
|
|
2471
|
+
state.prefinished = true;
|
|
2472
|
+
stream.emit("prefinish");
|
|
2473
|
+
}
|
|
2474
|
+
}
|
|
2475
|
+
}
|
|
2476
|
+
function finishMaybe(stream, state) {
|
|
2477
|
+
var need = needFinish(state);
|
|
2478
|
+
if (need) {
|
|
2479
|
+
prefinish(stream, state);
|
|
2480
|
+
if (state.pendingcb === 0) {
|
|
2481
|
+
state.finished = true;
|
|
2482
|
+
stream.emit("finish");
|
|
2483
|
+
if (state.autoDestroy) {
|
|
2484
|
+
var rState = stream._readableState;
|
|
2485
|
+
if (!rState || rState.autoDestroy && rState.endEmitted) {
|
|
2486
|
+
stream.destroy();
|
|
2487
|
+
}
|
|
2488
|
+
}
|
|
2489
|
+
}
|
|
2490
|
+
}
|
|
2491
|
+
return need;
|
|
2492
|
+
}
|
|
2493
|
+
function endWritable(stream, state, cb) {
|
|
2494
|
+
state.ending = true;
|
|
2495
|
+
finishMaybe(stream, state);
|
|
2496
|
+
if (cb) {
|
|
2497
|
+
if (state.finished) process.nextTick(cb);
|
|
2498
|
+
else stream.once("finish", cb);
|
|
2499
|
+
}
|
|
2500
|
+
state.ended = true;
|
|
2501
|
+
stream.writable = false;
|
|
2502
|
+
}
|
|
2503
|
+
function onCorkedFinish(corkReq, state, err) {
|
|
2504
|
+
var entry = corkReq.entry;
|
|
2505
|
+
corkReq.entry = null;
|
|
2506
|
+
while (entry) {
|
|
2507
|
+
var cb = entry.callback;
|
|
2508
|
+
state.pendingcb--;
|
|
2509
|
+
cb(err);
|
|
2510
|
+
entry = entry.next;
|
|
2511
|
+
}
|
|
2512
|
+
state.corkedRequestsFree.next = corkReq;
|
|
2513
|
+
}
|
|
2514
|
+
Object.defineProperty(Writable.prototype, "destroyed", {
|
|
2515
|
+
// making it explicit this property is not enumerable
|
|
2516
|
+
// because otherwise some prototype manipulation in
|
|
2517
|
+
// userland will fail
|
|
2518
|
+
enumerable: false,
|
|
2519
|
+
get: function get() {
|
|
2520
|
+
if (this._writableState === void 0) {
|
|
2521
|
+
return false;
|
|
2522
|
+
}
|
|
2523
|
+
return this._writableState.destroyed;
|
|
2524
|
+
},
|
|
2525
|
+
set: function set(value) {
|
|
2526
|
+
if (!this._writableState) {
|
|
2527
|
+
return;
|
|
2528
|
+
}
|
|
2529
|
+
this._writableState.destroyed = value;
|
|
2530
|
+
}
|
|
2531
|
+
});
|
|
2532
|
+
Writable.prototype.destroy = destroyImpl.destroy;
|
|
2533
|
+
Writable.prototype._undestroy = destroyImpl.undestroy;
|
|
2534
|
+
Writable.prototype._destroy = function(err, cb) {
|
|
2535
|
+
cb(err);
|
|
2536
|
+
};
|
|
2537
|
+
}
|
|
2538
|
+
});
|
|
2539
|
+
|
|
2540
|
+
// ../../node_modules/triple-beam/config/cli.js
|
|
2541
|
+
var require_cli = __commonJS({
|
|
2542
|
+
"../../node_modules/triple-beam/config/cli.js"(exports2) {
|
|
2543
|
+
"use strict";
|
|
2544
|
+
exports2.levels = {
|
|
2545
|
+
error: 0,
|
|
2546
|
+
warn: 1,
|
|
2547
|
+
help: 2,
|
|
2548
|
+
data: 3,
|
|
2549
|
+
info: 4,
|
|
2550
|
+
debug: 5,
|
|
2551
|
+
prompt: 6,
|
|
2552
|
+
verbose: 7,
|
|
2553
|
+
input: 8,
|
|
2554
|
+
silly: 9
|
|
2555
|
+
};
|
|
2556
|
+
exports2.colors = {
|
|
2557
|
+
error: "red",
|
|
2558
|
+
warn: "yellow",
|
|
2559
|
+
help: "cyan",
|
|
2560
|
+
data: "grey",
|
|
2561
|
+
info: "green",
|
|
2562
|
+
debug: "blue",
|
|
2563
|
+
prompt: "grey",
|
|
2564
|
+
verbose: "cyan",
|
|
2565
|
+
input: "grey",
|
|
2566
|
+
silly: "magenta"
|
|
2567
|
+
};
|
|
2568
|
+
}
|
|
2569
|
+
});
|
|
2570
|
+
|
|
2571
|
+
// ../../node_modules/triple-beam/config/npm.js
|
|
2572
|
+
var require_npm = __commonJS({
|
|
2573
|
+
"../../node_modules/triple-beam/config/npm.js"(exports2) {
|
|
2574
|
+
"use strict";
|
|
2575
|
+
exports2.levels = {
|
|
2576
|
+
error: 0,
|
|
2577
|
+
warn: 1,
|
|
2578
|
+
info: 2,
|
|
2579
|
+
http: 3,
|
|
2580
|
+
verbose: 4,
|
|
2581
|
+
debug: 5,
|
|
2582
|
+
silly: 6
|
|
2583
|
+
};
|
|
2584
|
+
exports2.colors = {
|
|
2585
|
+
error: "red",
|
|
2586
|
+
warn: "yellow",
|
|
2587
|
+
info: "green",
|
|
2588
|
+
http: "green",
|
|
2589
|
+
verbose: "cyan",
|
|
2590
|
+
debug: "blue",
|
|
2591
|
+
silly: "magenta"
|
|
2592
|
+
};
|
|
2593
|
+
}
|
|
2594
|
+
});
|
|
2595
|
+
|
|
2596
|
+
// ../../node_modules/triple-beam/config/syslog.js
|
|
2597
|
+
var require_syslog = __commonJS({
|
|
2598
|
+
"../../node_modules/triple-beam/config/syslog.js"(exports2) {
|
|
2599
|
+
"use strict";
|
|
2600
|
+
exports2.levels = {
|
|
2601
|
+
emerg: 0,
|
|
2602
|
+
alert: 1,
|
|
2603
|
+
crit: 2,
|
|
2604
|
+
error: 3,
|
|
2605
|
+
warning: 4,
|
|
2606
|
+
notice: 5,
|
|
2607
|
+
info: 6,
|
|
2608
|
+
debug: 7
|
|
2609
|
+
};
|
|
2610
|
+
exports2.colors = {
|
|
2611
|
+
emerg: "red",
|
|
2612
|
+
alert: "yellow",
|
|
2613
|
+
crit: "red",
|
|
2614
|
+
error: "red",
|
|
2615
|
+
warning: "red",
|
|
2616
|
+
notice: "yellow",
|
|
2617
|
+
info: "green",
|
|
2618
|
+
debug: "blue"
|
|
2619
|
+
};
|
|
2620
|
+
}
|
|
2621
|
+
});
|
|
2622
|
+
|
|
2623
|
+
// ../../node_modules/triple-beam/config/index.js
|
|
2624
|
+
var require_config = __commonJS({
|
|
2625
|
+
"../../node_modules/triple-beam/config/index.js"(exports2) {
|
|
2626
|
+
"use strict";
|
|
2627
|
+
Object.defineProperty(exports2, "cli", {
|
|
2628
|
+
value: require_cli()
|
|
2629
|
+
});
|
|
2630
|
+
Object.defineProperty(exports2, "npm", {
|
|
2631
|
+
value: require_npm()
|
|
2632
|
+
});
|
|
2633
|
+
Object.defineProperty(exports2, "syslog", {
|
|
2634
|
+
value: require_syslog()
|
|
2635
|
+
});
|
|
2636
|
+
}
|
|
2637
|
+
});
|
|
2638
|
+
|
|
2639
|
+
// ../../node_modules/triple-beam/index.js
|
|
2640
|
+
var require_triple_beam = __commonJS({
|
|
2641
|
+
"../../node_modules/triple-beam/index.js"(exports2) {
|
|
2642
|
+
"use strict";
|
|
2643
|
+
Object.defineProperty(exports2, "LEVEL", {
|
|
2644
|
+
value: Symbol.for("level")
|
|
2645
|
+
});
|
|
2646
|
+
Object.defineProperty(exports2, "MESSAGE", {
|
|
2647
|
+
value: Symbol.for("message")
|
|
2648
|
+
});
|
|
2649
|
+
Object.defineProperty(exports2, "SPLAT", {
|
|
2650
|
+
value: Symbol.for("splat")
|
|
2651
|
+
});
|
|
2652
|
+
Object.defineProperty(exports2, "configs", {
|
|
2653
|
+
value: require_config()
|
|
2654
|
+
});
|
|
2655
|
+
}
|
|
2656
|
+
});
|
|
2657
|
+
|
|
2658
|
+
// ../../node_modules/winston-transport/modern.js
|
|
2659
|
+
var require_modern = __commonJS({
|
|
2660
|
+
"../../node_modules/winston-transport/modern.js"(exports2, module2) {
|
|
2661
|
+
"use strict";
|
|
2662
|
+
var util = require("util");
|
|
2663
|
+
var Writable = require_stream_writable();
|
|
2664
|
+
var { LEVEL } = require_triple_beam();
|
|
2665
|
+
var TransportStream = module2.exports = function TransportStream2(options = {}) {
|
|
2666
|
+
Writable.call(this, { objectMode: true, highWaterMark: options.highWaterMark });
|
|
2667
|
+
this.format = options.format;
|
|
2668
|
+
this.level = options.level;
|
|
2669
|
+
this.handleExceptions = options.handleExceptions;
|
|
2670
|
+
this.handleRejections = options.handleRejections;
|
|
2671
|
+
this.silent = options.silent;
|
|
2672
|
+
if (options.log) this.log = options.log;
|
|
2673
|
+
if (options.logv) this.logv = options.logv;
|
|
2674
|
+
if (options.close) this.close = options.close;
|
|
2675
|
+
this.once("pipe", (logger) => {
|
|
2676
|
+
this.levels = logger.levels;
|
|
2677
|
+
this.parent = logger;
|
|
2678
|
+
});
|
|
2679
|
+
this.once("unpipe", (src) => {
|
|
2680
|
+
if (src === this.parent) {
|
|
2681
|
+
this.parent = null;
|
|
2682
|
+
if (this.close) {
|
|
2683
|
+
this.close();
|
|
2684
|
+
}
|
|
2685
|
+
}
|
|
2686
|
+
});
|
|
2687
|
+
};
|
|
2688
|
+
util.inherits(TransportStream, Writable);
|
|
2689
|
+
TransportStream.prototype._write = function _write(info, enc, callback) {
|
|
2690
|
+
if (this.silent || info.exception === true && !this.handleExceptions) {
|
|
2691
|
+
return callback(null);
|
|
2692
|
+
}
|
|
2693
|
+
const level = this.level || this.parent && this.parent.level;
|
|
2694
|
+
if (!level || this.levels[level] >= this.levels[info[LEVEL]]) {
|
|
2695
|
+
if (info && !this.format) {
|
|
2696
|
+
return this.log(info, callback);
|
|
2697
|
+
}
|
|
2698
|
+
let errState;
|
|
2699
|
+
let transformed;
|
|
2700
|
+
try {
|
|
2701
|
+
transformed = this.format.transform(Object.assign({}, info), this.format.options);
|
|
2702
|
+
} catch (err) {
|
|
2703
|
+
errState = err;
|
|
2704
|
+
}
|
|
2705
|
+
if (errState || !transformed) {
|
|
2706
|
+
callback();
|
|
2707
|
+
if (errState) throw errState;
|
|
2708
|
+
return;
|
|
2709
|
+
}
|
|
2710
|
+
return this.log(transformed, callback);
|
|
2711
|
+
}
|
|
2712
|
+
this._writableState.sync = false;
|
|
2713
|
+
return callback(null);
|
|
2714
|
+
};
|
|
2715
|
+
TransportStream.prototype._writev = function _writev(chunks, callback) {
|
|
2716
|
+
if (this.logv) {
|
|
2717
|
+
const infos = chunks.filter(this._accept, this);
|
|
2718
|
+
if (!infos.length) {
|
|
2719
|
+
return callback(null);
|
|
2720
|
+
}
|
|
2721
|
+
return this.logv(infos, callback);
|
|
2722
|
+
}
|
|
2723
|
+
for (let i = 0; i < chunks.length; i++) {
|
|
2724
|
+
if (!this._accept(chunks[i])) continue;
|
|
2725
|
+
if (chunks[i].chunk && !this.format) {
|
|
2726
|
+
this.log(chunks[i].chunk, chunks[i].callback);
|
|
2727
|
+
continue;
|
|
2728
|
+
}
|
|
2729
|
+
let errState;
|
|
2730
|
+
let transformed;
|
|
2731
|
+
try {
|
|
2732
|
+
transformed = this.format.transform(
|
|
2733
|
+
Object.assign({}, chunks[i].chunk),
|
|
2734
|
+
this.format.options
|
|
2735
|
+
);
|
|
2736
|
+
} catch (err) {
|
|
2737
|
+
errState = err;
|
|
2738
|
+
}
|
|
2739
|
+
if (errState || !transformed) {
|
|
2740
|
+
chunks[i].callback();
|
|
2741
|
+
if (errState) {
|
|
2742
|
+
callback(null);
|
|
2743
|
+
throw errState;
|
|
2744
|
+
}
|
|
2745
|
+
} else {
|
|
2746
|
+
this.log(transformed, chunks[i].callback);
|
|
2747
|
+
}
|
|
2748
|
+
}
|
|
2749
|
+
return callback(null);
|
|
2750
|
+
};
|
|
2751
|
+
TransportStream.prototype._accept = function _accept(write) {
|
|
2752
|
+
const info = write.chunk;
|
|
2753
|
+
if (this.silent) {
|
|
2754
|
+
return false;
|
|
2755
|
+
}
|
|
2756
|
+
const level = this.level || this.parent && this.parent.level;
|
|
2757
|
+
if (info.exception === true || !level || this.levels[level] >= this.levels[info[LEVEL]]) {
|
|
2758
|
+
if (this.handleExceptions || info.exception !== true) {
|
|
2759
|
+
return true;
|
|
2760
|
+
}
|
|
2761
|
+
}
|
|
2762
|
+
return false;
|
|
2763
|
+
};
|
|
2764
|
+
TransportStream.prototype._nop = function _nop() {
|
|
2765
|
+
return void 0;
|
|
2766
|
+
};
|
|
2767
|
+
}
|
|
2768
|
+
});
|
|
2769
|
+
|
|
2770
|
+
// ../../node_modules/winston-transport/legacy.js
|
|
2771
|
+
var require_legacy = __commonJS({
|
|
2772
|
+
"../../node_modules/winston-transport/legacy.js"(exports2, module2) {
|
|
2773
|
+
"use strict";
|
|
2774
|
+
var util = require("util");
|
|
2775
|
+
var { LEVEL } = require_triple_beam();
|
|
2776
|
+
var TransportStream = require_modern();
|
|
2777
|
+
var LegacyTransportStream = module2.exports = function LegacyTransportStream2(options = {}) {
|
|
2778
|
+
TransportStream.call(this, options);
|
|
2779
|
+
if (!options.transport || typeof options.transport.log !== "function") {
|
|
2780
|
+
throw new Error("Invalid transport, must be an object with a log method.");
|
|
2781
|
+
}
|
|
2782
|
+
this.transport = options.transport;
|
|
2783
|
+
this.level = this.level || options.transport.level;
|
|
2784
|
+
this.handleExceptions = this.handleExceptions || options.transport.handleExceptions;
|
|
2785
|
+
this._deprecated();
|
|
2786
|
+
function transportError(err) {
|
|
2787
|
+
this.emit("error", err, this.transport);
|
|
2788
|
+
}
|
|
2789
|
+
if (!this.transport.__winstonError) {
|
|
2790
|
+
this.transport.__winstonError = transportError.bind(this);
|
|
2791
|
+
this.transport.on("error", this.transport.__winstonError);
|
|
2792
|
+
}
|
|
2793
|
+
};
|
|
2794
|
+
util.inherits(LegacyTransportStream, TransportStream);
|
|
2795
|
+
LegacyTransportStream.prototype._write = function _write(info, enc, callback) {
|
|
2796
|
+
if (this.silent || info.exception === true && !this.handleExceptions) {
|
|
2797
|
+
return callback(null);
|
|
2798
|
+
}
|
|
2799
|
+
if (!this.level || this.levels[this.level] >= this.levels[info[LEVEL]]) {
|
|
2800
|
+
this.transport.log(info[LEVEL], info.message, info, this._nop);
|
|
2801
|
+
}
|
|
2802
|
+
callback(null);
|
|
2803
|
+
};
|
|
2804
|
+
LegacyTransportStream.prototype._writev = function _writev(chunks, callback) {
|
|
2805
|
+
for (let i = 0; i < chunks.length; i++) {
|
|
2806
|
+
if (this._accept(chunks[i])) {
|
|
2807
|
+
this.transport.log(
|
|
2808
|
+
chunks[i].chunk[LEVEL],
|
|
2809
|
+
chunks[i].chunk.message,
|
|
2810
|
+
chunks[i].chunk,
|
|
2811
|
+
this._nop
|
|
2812
|
+
);
|
|
2813
|
+
chunks[i].callback();
|
|
2814
|
+
}
|
|
2815
|
+
}
|
|
2816
|
+
return callback(null);
|
|
2817
|
+
};
|
|
2818
|
+
LegacyTransportStream.prototype._deprecated = function _deprecated() {
|
|
2819
|
+
console.error([
|
|
2820
|
+
`${this.transport.name} is a legacy winston transport. Consider upgrading: `,
|
|
2821
|
+
"- Upgrade docs: https://github.com/winstonjs/winston/blob/master/UPGRADE-3.0.md"
|
|
2822
|
+
].join("\n"));
|
|
2823
|
+
};
|
|
2824
|
+
LegacyTransportStream.prototype.close = function close() {
|
|
2825
|
+
if (this.transport.close) {
|
|
2826
|
+
this.transport.close();
|
|
2827
|
+
}
|
|
2828
|
+
if (this.transport.__winstonError) {
|
|
2829
|
+
this.transport.removeListener("error", this.transport.__winstonError);
|
|
2830
|
+
this.transport.__winstonError = null;
|
|
2831
|
+
}
|
|
2832
|
+
};
|
|
2833
|
+
}
|
|
2834
|
+
});
|
|
2835
|
+
|
|
2836
|
+
// ../../node_modules/winston-transport/index.js
|
|
2837
|
+
var require_winston_transport = __commonJS({
|
|
2838
|
+
"../../node_modules/winston-transport/index.js"(exports2, module2) {
|
|
2839
|
+
"use strict";
|
|
2840
|
+
module2.exports = require_modern();
|
|
2841
|
+
module2.exports.LegacyTransportStream = require_legacy();
|
|
2842
|
+
}
|
|
2843
|
+
});
|
|
2844
|
+
|
|
2845
|
+
// src/index.ts
|
|
2846
|
+
var index_exports = {};
|
|
2847
|
+
__export(index_exports, {
|
|
2848
|
+
CrexSDK: () => CrexSDK
|
|
2849
|
+
});
|
|
2850
|
+
module.exports = __toCommonJS(index_exports);
|
|
2851
|
+
|
|
2852
|
+
// src/requests.ts
|
|
2853
|
+
var import_axios = __toESM(require("axios"));
|
|
2854
|
+
|
|
2855
|
+
// src/constants.ts
|
|
2856
|
+
var ALL = "*";
|
|
2857
|
+
var LOG_LEVELS = {
|
|
2858
|
+
critical: 2,
|
|
2859
|
+
error: 3,
|
|
2860
|
+
warning: 4,
|
|
2861
|
+
info: 6,
|
|
2862
|
+
debug: 7
|
|
2863
|
+
};
|
|
2864
|
+
var API = {
|
|
2865
|
+
MAX_RETRY: 3,
|
|
2866
|
+
API_TIMEOUT: 1e4,
|
|
2867
|
+
API_HEADERS: {
|
|
2868
|
+
"content-Type": "application/json"
|
|
2869
|
+
}
|
|
2870
|
+
};
|
|
2871
|
+
|
|
2872
|
+
// src/requests.ts
|
|
2873
|
+
var CrexApi = class {
|
|
2874
|
+
apiClient;
|
|
2875
|
+
logger;
|
|
2876
|
+
constructor(baseUrl, logger) {
|
|
2877
|
+
this.apiClient = import_axios.default.create({
|
|
2878
|
+
baseURL: baseUrl,
|
|
2879
|
+
headers: {
|
|
2880
|
+
"content-Type": "application/json"
|
|
2881
|
+
}
|
|
2882
|
+
});
|
|
2883
|
+
this.logger = logger;
|
|
2884
|
+
}
|
|
2885
|
+
async execute({
|
|
2886
|
+
url,
|
|
2887
|
+
method,
|
|
2888
|
+
params,
|
|
2889
|
+
body,
|
|
2890
|
+
headers
|
|
2891
|
+
}) {
|
|
2892
|
+
let response = void 0;
|
|
2893
|
+
for (let retry = 0; retry < API.MAX_RETRY; retry++) {
|
|
2894
|
+
try {
|
|
2895
|
+
response = await this.apiClient.request({
|
|
2896
|
+
url,
|
|
2897
|
+
method,
|
|
2898
|
+
data: body,
|
|
2899
|
+
params,
|
|
2900
|
+
headers
|
|
2901
|
+
});
|
|
2902
|
+
} catch (error) {
|
|
2903
|
+
this.logger.log("error", `API.execute error when request ${url}. Error: ${error}`);
|
|
2904
|
+
throw error;
|
|
2905
|
+
}
|
|
2906
|
+
}
|
|
2907
|
+
if (response) {
|
|
2908
|
+
return response;
|
|
2909
|
+
}
|
|
2910
|
+
throw new Error("API.execute error: Failed to retrieve a valid response");
|
|
2911
|
+
}
|
|
2912
|
+
};
|
|
2913
|
+
|
|
2914
|
+
// src/logger.ts
|
|
2915
|
+
var import_winston = __toESM(require("winston"));
|
|
2916
|
+
|
|
2917
|
+
// src/transports/matomo.ts
|
|
2918
|
+
var import_winston_transport = __toESM(require_winston_transport());
|
|
2919
|
+
var MatomoTransport = class extends import_winston_transport.default {
|
|
2920
|
+
matomoTransport;
|
|
2921
|
+
constructor(opts) {
|
|
2922
|
+
super(opts);
|
|
2923
|
+
this.matomoTransport = new import_winston_transport.default();
|
|
2924
|
+
}
|
|
2925
|
+
log(info, callback) {
|
|
2926
|
+
const SDK = CrexSDK.getInstance();
|
|
2927
|
+
const matomoCategory = SDK.customerConfig.logs.matomo.categoriesLevel;
|
|
2928
|
+
if (matomoCategory.includes(info.category) || matomoCategory.includes(ALL)) {
|
|
2929
|
+
this.matomoTransport.log(info, callback);
|
|
2930
|
+
}
|
|
2931
|
+
}
|
|
2932
|
+
};
|
|
2933
|
+
|
|
2934
|
+
// src/transports/graylog.ts
|
|
2935
|
+
var import_winston_transport2 = __toESM(require_winston_transport());
|
|
2936
|
+
var import_winston_graylog2 = __toESM(require("winston-graylog2"));
|
|
2937
|
+
var GraylogTransport = class extends import_winston_transport2.default {
|
|
2938
|
+
graylogTransport;
|
|
2939
|
+
constructor(opts) {
|
|
2940
|
+
super(opts);
|
|
2941
|
+
this.graylogTransport = new import_winston_graylog2.default({
|
|
2942
|
+
name: "Periotto-TEST",
|
|
2943
|
+
silent: false,
|
|
2944
|
+
handleExceptions: false,
|
|
2945
|
+
graylog: {
|
|
2946
|
+
servers: [{ host: "localhost", port: 12201 }]
|
|
2947
|
+
}
|
|
2948
|
+
});
|
|
2949
|
+
}
|
|
2950
|
+
log(info, callback) {
|
|
2951
|
+
const SDK = CrexSDK.getInstance();
|
|
2952
|
+
const graylogCategory = SDK.customerConfig.logs.graylog.categoriesLevel;
|
|
2953
|
+
if (graylogCategory.includes(info.category) || graylogCategory.includes(ALL)) {
|
|
2954
|
+
this.graylogTransport.log(info, callback);
|
|
2955
|
+
}
|
|
2956
|
+
}
|
|
2957
|
+
};
|
|
2958
|
+
|
|
2959
|
+
// src/logger.ts
|
|
2960
|
+
var CrexLogger = class {
|
|
2961
|
+
customerConfig;
|
|
2962
|
+
logger;
|
|
2963
|
+
constructor(config) {
|
|
2964
|
+
this.customerConfig = config;
|
|
2965
|
+
this.logger = this.createLogger();
|
|
2966
|
+
}
|
|
2967
|
+
log(level, message, category) {
|
|
2968
|
+
this.logger.log(level, message, category);
|
|
2969
|
+
}
|
|
2970
|
+
createLogger() {
|
|
2971
|
+
return import_winston.default.createLogger({
|
|
2972
|
+
levels: LOG_LEVELS,
|
|
2973
|
+
transports: [
|
|
2974
|
+
new import_winston.default.transports.Console({
|
|
2975
|
+
level: this.customerConfig.logs.console.minimumLevel,
|
|
2976
|
+
silent: this.customerConfig.logs.console.silent
|
|
2977
|
+
}),
|
|
2978
|
+
new MatomoTransport({
|
|
2979
|
+
level: this.customerConfig.logs.console.minimumLevel,
|
|
2980
|
+
silent: this.customerConfig.logs.console.silent
|
|
2981
|
+
}),
|
|
2982
|
+
new GraylogTransport({
|
|
2983
|
+
level: this.customerConfig.logs.graylog.minimumLevel,
|
|
2984
|
+
silent: this.customerConfig.logs.graylog.silent
|
|
2985
|
+
})
|
|
2986
|
+
]
|
|
2987
|
+
});
|
|
2988
|
+
}
|
|
2989
|
+
};
|
|
2990
|
+
|
|
2991
|
+
// src/index.ts
|
|
2992
|
+
var CrexSDK = class _CrexSDK {
|
|
2993
|
+
static instance;
|
|
2994
|
+
customerConfig;
|
|
2995
|
+
logger;
|
|
2996
|
+
api;
|
|
2997
|
+
constructor(config) {
|
|
2998
|
+
if (_CrexSDK.instance) {
|
|
2999
|
+
throw new Error("SDK already initialized");
|
|
3000
|
+
}
|
|
3001
|
+
this.customerConfig = config;
|
|
3002
|
+
this.logger = new CrexLogger(this.customerConfig);
|
|
3003
|
+
this.api = new CrexApi(this.customerConfig.baseUrl, this.logger);
|
|
3004
|
+
_CrexSDK.instance = this;
|
|
3005
|
+
}
|
|
3006
|
+
static getInstance() {
|
|
3007
|
+
if (!_CrexSDK.instance) {
|
|
3008
|
+
throw new Error("SDK not initialized");
|
|
3009
|
+
}
|
|
3010
|
+
return _CrexSDK.instance;
|
|
3011
|
+
}
|
|
3012
|
+
};
|
|
3013
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
3014
|
+
0 && (module.exports = {
|
|
3015
|
+
CrexSDK
|
|
3016
|
+
});
|
|
3017
|
+
/*! Bundled license information:
|
|
3018
|
+
|
|
3019
|
+
safe-buffer/index.js:
|
|
3020
|
+
(*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)
|
|
3021
|
+
*/
|
|
3022
|
+
//# sourceMappingURL=index.js.map
|