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