claude-presentation-master 4.3.0 → 4.4.0
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/assets/presentation-knowledge.yaml +9 -9
- package/dist/index.d.mts +864 -1698
- package/dist/index.d.ts +864 -1698
- package/dist/index.js +3706 -100220
- package/dist/index.mjs +3621 -8236
- package/package.json +1 -1
- package/dist/BrowserWebSocketTransport-HTFZUK6G.mjs +0 -7
- package/dist/LaunchOptions-SFJP2D7Z.mjs +0 -9
- package/dist/NodeWebSocketTransport-RBVOEJLR.mjs +0 -8
- package/dist/bidi-BVFTPINL.mjs +0 -18501
- package/dist/chunk-3UL3L2R6.mjs +0 -30
- package/dist/chunk-4MOE77QU.mjs +0 -1661
- package/dist/chunk-5NJVL3OH.mjs +0 -31312
- package/dist/chunk-5TVEOHFT.mjs +0 -244
- package/dist/chunk-6D5VEPNW.mjs +0 -12104
- package/dist/chunk-CFGGYLHX.mjs +0 -3684
- package/dist/chunk-EC7LFFYG.mjs +0 -15
- package/dist/chunk-HEBXNMVQ.mjs +0 -48
- package/dist/chunk-KJPJW5EB.mjs +0 -40
- package/dist/chunk-QUYDTLMJ.mjs +0 -775
- package/dist/extract-zip-UJUIS3MT.mjs +0 -1499
- package/dist/helpers-GOUCEJ3S.mjs +0 -17
- package/dist/main-GWERC3XX.mjs +0 -56
- package/dist/puppeteer-EG4MVFUF.mjs +0 -14961
- package/dist/src-HTL2N5EV.mjs +0 -5
- package/dist/tar-fs-NIVQWNBX.mjs +0 -2562
- package/dist/yargs-COGWK7P3.mjs +0 -3230
package/dist/tar-fs-NIVQWNBX.mjs
DELETED
|
@@ -1,2562 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
require_pump
|
|
3
|
-
} from "./chunk-5TVEOHFT.mjs";
|
|
4
|
-
import {
|
|
5
|
-
__commonJS,
|
|
6
|
-
__require
|
|
7
|
-
} from "./chunk-HEBXNMVQ.mjs";
|
|
8
|
-
|
|
9
|
-
// node_modules/events-universal/default.js
|
|
10
|
-
var require_default = __commonJS({
|
|
11
|
-
"node_modules/events-universal/default.js"(exports, module) {
|
|
12
|
-
"use strict";
|
|
13
|
-
module.exports = __require("events");
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
// node_modules/fast-fifo/fixed-size.js
|
|
18
|
-
var require_fixed_size = __commonJS({
|
|
19
|
-
"node_modules/fast-fifo/fixed-size.js"(exports, module) {
|
|
20
|
-
"use strict";
|
|
21
|
-
module.exports = class FixedFIFO {
|
|
22
|
-
constructor(hwm) {
|
|
23
|
-
if (!(hwm > 0) || (hwm - 1 & hwm) !== 0) throw new Error("Max size for a FixedFIFO should be a power of two");
|
|
24
|
-
this.buffer = new Array(hwm);
|
|
25
|
-
this.mask = hwm - 1;
|
|
26
|
-
this.top = 0;
|
|
27
|
-
this.btm = 0;
|
|
28
|
-
this.next = null;
|
|
29
|
-
}
|
|
30
|
-
clear() {
|
|
31
|
-
this.top = this.btm = 0;
|
|
32
|
-
this.next = null;
|
|
33
|
-
this.buffer.fill(void 0);
|
|
34
|
-
}
|
|
35
|
-
push(data) {
|
|
36
|
-
if (this.buffer[this.top] !== void 0) return false;
|
|
37
|
-
this.buffer[this.top] = data;
|
|
38
|
-
this.top = this.top + 1 & this.mask;
|
|
39
|
-
return true;
|
|
40
|
-
}
|
|
41
|
-
shift() {
|
|
42
|
-
const last = this.buffer[this.btm];
|
|
43
|
-
if (last === void 0) return void 0;
|
|
44
|
-
this.buffer[this.btm] = void 0;
|
|
45
|
-
this.btm = this.btm + 1 & this.mask;
|
|
46
|
-
return last;
|
|
47
|
-
}
|
|
48
|
-
peek() {
|
|
49
|
-
return this.buffer[this.btm];
|
|
50
|
-
}
|
|
51
|
-
isEmpty() {
|
|
52
|
-
return this.buffer[this.btm] === void 0;
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
// node_modules/fast-fifo/index.js
|
|
59
|
-
var require_fast_fifo = __commonJS({
|
|
60
|
-
"node_modules/fast-fifo/index.js"(exports, module) {
|
|
61
|
-
"use strict";
|
|
62
|
-
var FixedFIFO = require_fixed_size();
|
|
63
|
-
module.exports = class FastFIFO {
|
|
64
|
-
constructor(hwm) {
|
|
65
|
-
this.hwm = hwm || 16;
|
|
66
|
-
this.head = new FixedFIFO(this.hwm);
|
|
67
|
-
this.tail = this.head;
|
|
68
|
-
this.length = 0;
|
|
69
|
-
}
|
|
70
|
-
clear() {
|
|
71
|
-
this.head = this.tail;
|
|
72
|
-
this.head.clear();
|
|
73
|
-
this.length = 0;
|
|
74
|
-
}
|
|
75
|
-
push(val) {
|
|
76
|
-
this.length++;
|
|
77
|
-
if (!this.head.push(val)) {
|
|
78
|
-
const prev = this.head;
|
|
79
|
-
this.head = prev.next = new FixedFIFO(2 * this.head.buffer.length);
|
|
80
|
-
this.head.push(val);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
shift() {
|
|
84
|
-
if (this.length !== 0) this.length--;
|
|
85
|
-
const val = this.tail.shift();
|
|
86
|
-
if (val === void 0 && this.tail.next) {
|
|
87
|
-
const next = this.tail.next;
|
|
88
|
-
this.tail.next = null;
|
|
89
|
-
this.tail = next;
|
|
90
|
-
return this.tail.shift();
|
|
91
|
-
}
|
|
92
|
-
return val;
|
|
93
|
-
}
|
|
94
|
-
peek() {
|
|
95
|
-
const val = this.tail.peek();
|
|
96
|
-
if (val === void 0 && this.tail.next) return this.tail.next.peek();
|
|
97
|
-
return val;
|
|
98
|
-
}
|
|
99
|
-
isEmpty() {
|
|
100
|
-
return this.length === 0;
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
// node_modules/b4a/index.js
|
|
107
|
-
var require_b4a = __commonJS({
|
|
108
|
-
"node_modules/b4a/index.js"(exports, module) {
|
|
109
|
-
"use strict";
|
|
110
|
-
function isBuffer(value) {
|
|
111
|
-
return Buffer.isBuffer(value) || value instanceof Uint8Array;
|
|
112
|
-
}
|
|
113
|
-
function isEncoding(encoding) {
|
|
114
|
-
return Buffer.isEncoding(encoding);
|
|
115
|
-
}
|
|
116
|
-
function alloc(size, fill2, encoding) {
|
|
117
|
-
return Buffer.alloc(size, fill2, encoding);
|
|
118
|
-
}
|
|
119
|
-
function allocUnsafe(size) {
|
|
120
|
-
return Buffer.allocUnsafe(size);
|
|
121
|
-
}
|
|
122
|
-
function allocUnsafeSlow(size) {
|
|
123
|
-
return Buffer.allocUnsafeSlow(size);
|
|
124
|
-
}
|
|
125
|
-
function byteLength(string, encoding) {
|
|
126
|
-
return Buffer.byteLength(string, encoding);
|
|
127
|
-
}
|
|
128
|
-
function compare(a, b) {
|
|
129
|
-
return Buffer.compare(a, b);
|
|
130
|
-
}
|
|
131
|
-
function concat(buffers, totalLength) {
|
|
132
|
-
return Buffer.concat(buffers, totalLength);
|
|
133
|
-
}
|
|
134
|
-
function copy(source, target, targetStart, start, end) {
|
|
135
|
-
return toBuffer(source).copy(target, targetStart, start, end);
|
|
136
|
-
}
|
|
137
|
-
function equals(a, b) {
|
|
138
|
-
return toBuffer(a).equals(b);
|
|
139
|
-
}
|
|
140
|
-
function fill(buffer, value, offset, end, encoding) {
|
|
141
|
-
return toBuffer(buffer).fill(value, offset, end, encoding);
|
|
142
|
-
}
|
|
143
|
-
function from(value, encodingOrOffset, length) {
|
|
144
|
-
return Buffer.from(value, encodingOrOffset, length);
|
|
145
|
-
}
|
|
146
|
-
function includes(buffer, value, byteOffset, encoding) {
|
|
147
|
-
return toBuffer(buffer).includes(value, byteOffset, encoding);
|
|
148
|
-
}
|
|
149
|
-
function indexOf(buffer, value, byfeOffset, encoding) {
|
|
150
|
-
return toBuffer(buffer).indexOf(value, byfeOffset, encoding);
|
|
151
|
-
}
|
|
152
|
-
function lastIndexOf(buffer, value, byteOffset, encoding) {
|
|
153
|
-
return toBuffer(buffer).lastIndexOf(value, byteOffset, encoding);
|
|
154
|
-
}
|
|
155
|
-
function swap16(buffer) {
|
|
156
|
-
return toBuffer(buffer).swap16();
|
|
157
|
-
}
|
|
158
|
-
function swap32(buffer) {
|
|
159
|
-
return toBuffer(buffer).swap32();
|
|
160
|
-
}
|
|
161
|
-
function swap64(buffer) {
|
|
162
|
-
return toBuffer(buffer).swap64();
|
|
163
|
-
}
|
|
164
|
-
function toBuffer(buffer) {
|
|
165
|
-
if (Buffer.isBuffer(buffer)) return buffer;
|
|
166
|
-
return Buffer.from(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
167
|
-
}
|
|
168
|
-
function toString(buffer, encoding, start, end) {
|
|
169
|
-
return toBuffer(buffer).toString(encoding, start, end);
|
|
170
|
-
}
|
|
171
|
-
function write(buffer, string, offset, length, encoding) {
|
|
172
|
-
return toBuffer(buffer).write(string, offset, length, encoding);
|
|
173
|
-
}
|
|
174
|
-
function readDoubleBE(buffer, offset) {
|
|
175
|
-
return toBuffer(buffer).readDoubleBE(offset);
|
|
176
|
-
}
|
|
177
|
-
function readDoubleLE(buffer, offset) {
|
|
178
|
-
return toBuffer(buffer).readDoubleLE(offset);
|
|
179
|
-
}
|
|
180
|
-
function readFloatBE(buffer, offset) {
|
|
181
|
-
return toBuffer(buffer).readFloatBE(offset);
|
|
182
|
-
}
|
|
183
|
-
function readFloatLE(buffer, offset) {
|
|
184
|
-
return toBuffer(buffer).readFloatLE(offset);
|
|
185
|
-
}
|
|
186
|
-
function readInt32BE(buffer, offset) {
|
|
187
|
-
return toBuffer(buffer).readInt32BE(offset);
|
|
188
|
-
}
|
|
189
|
-
function readInt32LE(buffer, offset) {
|
|
190
|
-
return toBuffer(buffer).readInt32LE(offset);
|
|
191
|
-
}
|
|
192
|
-
function readUInt32BE(buffer, offset) {
|
|
193
|
-
return toBuffer(buffer).readUInt32BE(offset);
|
|
194
|
-
}
|
|
195
|
-
function readUInt32LE(buffer, offset) {
|
|
196
|
-
return toBuffer(buffer).readUInt32LE(offset);
|
|
197
|
-
}
|
|
198
|
-
function writeDoubleBE(buffer, value, offset) {
|
|
199
|
-
return toBuffer(buffer).writeDoubleBE(value, offset);
|
|
200
|
-
}
|
|
201
|
-
function writeDoubleLE(buffer, value, offset) {
|
|
202
|
-
return toBuffer(buffer).writeDoubleLE(value, offset);
|
|
203
|
-
}
|
|
204
|
-
function writeFloatBE(buffer, value, offset) {
|
|
205
|
-
return toBuffer(buffer).writeFloatBE(value, offset);
|
|
206
|
-
}
|
|
207
|
-
function writeFloatLE(buffer, value, offset) {
|
|
208
|
-
return toBuffer(buffer).writeFloatLE(value, offset);
|
|
209
|
-
}
|
|
210
|
-
function writeInt32BE(buffer, value, offset) {
|
|
211
|
-
return toBuffer(buffer).writeInt32BE(value, offset);
|
|
212
|
-
}
|
|
213
|
-
function writeInt32LE(buffer, value, offset) {
|
|
214
|
-
return toBuffer(buffer).writeInt32LE(value, offset);
|
|
215
|
-
}
|
|
216
|
-
function writeUInt32BE(buffer, value, offset) {
|
|
217
|
-
return toBuffer(buffer).writeUInt32BE(value, offset);
|
|
218
|
-
}
|
|
219
|
-
function writeUInt32LE(buffer, value, offset) {
|
|
220
|
-
return toBuffer(buffer).writeUInt32LE(value, offset);
|
|
221
|
-
}
|
|
222
|
-
module.exports = {
|
|
223
|
-
isBuffer,
|
|
224
|
-
isEncoding,
|
|
225
|
-
alloc,
|
|
226
|
-
allocUnsafe,
|
|
227
|
-
allocUnsafeSlow,
|
|
228
|
-
byteLength,
|
|
229
|
-
compare,
|
|
230
|
-
concat,
|
|
231
|
-
copy,
|
|
232
|
-
equals,
|
|
233
|
-
fill,
|
|
234
|
-
from,
|
|
235
|
-
includes,
|
|
236
|
-
indexOf,
|
|
237
|
-
lastIndexOf,
|
|
238
|
-
swap16,
|
|
239
|
-
swap32,
|
|
240
|
-
swap64,
|
|
241
|
-
toBuffer,
|
|
242
|
-
toString,
|
|
243
|
-
write,
|
|
244
|
-
readDoubleBE,
|
|
245
|
-
readDoubleLE,
|
|
246
|
-
readFloatBE,
|
|
247
|
-
readFloatLE,
|
|
248
|
-
readInt32BE,
|
|
249
|
-
readInt32LE,
|
|
250
|
-
readUInt32BE,
|
|
251
|
-
readUInt32LE,
|
|
252
|
-
writeDoubleBE,
|
|
253
|
-
writeDoubleLE,
|
|
254
|
-
writeFloatBE,
|
|
255
|
-
writeFloatLE,
|
|
256
|
-
writeInt32BE,
|
|
257
|
-
writeInt32LE,
|
|
258
|
-
writeUInt32BE,
|
|
259
|
-
writeUInt32LE
|
|
260
|
-
};
|
|
261
|
-
}
|
|
262
|
-
});
|
|
263
|
-
|
|
264
|
-
// node_modules/text-decoder/lib/pass-through-decoder.js
|
|
265
|
-
var require_pass_through_decoder = __commonJS({
|
|
266
|
-
"node_modules/text-decoder/lib/pass-through-decoder.js"(exports, module) {
|
|
267
|
-
"use strict";
|
|
268
|
-
var b4a = require_b4a();
|
|
269
|
-
module.exports = class PassThroughDecoder {
|
|
270
|
-
constructor(encoding) {
|
|
271
|
-
this.encoding = encoding;
|
|
272
|
-
}
|
|
273
|
-
get remaining() {
|
|
274
|
-
return 0;
|
|
275
|
-
}
|
|
276
|
-
decode(tail) {
|
|
277
|
-
return b4a.toString(tail, this.encoding);
|
|
278
|
-
}
|
|
279
|
-
flush() {
|
|
280
|
-
return "";
|
|
281
|
-
}
|
|
282
|
-
};
|
|
283
|
-
}
|
|
284
|
-
});
|
|
285
|
-
|
|
286
|
-
// node_modules/text-decoder/lib/utf8-decoder.js
|
|
287
|
-
var require_utf8_decoder = __commonJS({
|
|
288
|
-
"node_modules/text-decoder/lib/utf8-decoder.js"(exports, module) {
|
|
289
|
-
"use strict";
|
|
290
|
-
var b4a = require_b4a();
|
|
291
|
-
module.exports = class UTF8Decoder {
|
|
292
|
-
constructor() {
|
|
293
|
-
this.codePoint = 0;
|
|
294
|
-
this.bytesSeen = 0;
|
|
295
|
-
this.bytesNeeded = 0;
|
|
296
|
-
this.lowerBoundary = 128;
|
|
297
|
-
this.upperBoundary = 191;
|
|
298
|
-
}
|
|
299
|
-
get remaining() {
|
|
300
|
-
return this.bytesSeen;
|
|
301
|
-
}
|
|
302
|
-
decode(data) {
|
|
303
|
-
if (this.bytesNeeded === 0) {
|
|
304
|
-
let isBoundary = true;
|
|
305
|
-
for (let i = Math.max(0, data.byteLength - 4), n = data.byteLength; i < n && isBoundary; i++) {
|
|
306
|
-
isBoundary = data[i] <= 127;
|
|
307
|
-
}
|
|
308
|
-
if (isBoundary) return b4a.toString(data, "utf8");
|
|
309
|
-
}
|
|
310
|
-
let result = "";
|
|
311
|
-
for (let i = 0, n = data.byteLength; i < n; i++) {
|
|
312
|
-
const byte = data[i];
|
|
313
|
-
if (this.bytesNeeded === 0) {
|
|
314
|
-
if (byte <= 127) {
|
|
315
|
-
result += String.fromCharCode(byte);
|
|
316
|
-
} else {
|
|
317
|
-
this.bytesSeen = 1;
|
|
318
|
-
if (byte >= 194 && byte <= 223) {
|
|
319
|
-
this.bytesNeeded = 2;
|
|
320
|
-
this.codePoint = byte & 31;
|
|
321
|
-
} else if (byte >= 224 && byte <= 239) {
|
|
322
|
-
if (byte === 224) this.lowerBoundary = 160;
|
|
323
|
-
else if (byte === 237) this.upperBoundary = 159;
|
|
324
|
-
this.bytesNeeded = 3;
|
|
325
|
-
this.codePoint = byte & 15;
|
|
326
|
-
} else if (byte >= 240 && byte <= 244) {
|
|
327
|
-
if (byte === 240) this.lowerBoundary = 144;
|
|
328
|
-
if (byte === 244) this.upperBoundary = 143;
|
|
329
|
-
this.bytesNeeded = 4;
|
|
330
|
-
this.codePoint = byte & 7;
|
|
331
|
-
} else {
|
|
332
|
-
result += "\uFFFD";
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
continue;
|
|
336
|
-
}
|
|
337
|
-
if (byte < this.lowerBoundary || byte > this.upperBoundary) {
|
|
338
|
-
this.codePoint = 0;
|
|
339
|
-
this.bytesNeeded = 0;
|
|
340
|
-
this.bytesSeen = 0;
|
|
341
|
-
this.lowerBoundary = 128;
|
|
342
|
-
this.upperBoundary = 191;
|
|
343
|
-
result += "\uFFFD";
|
|
344
|
-
continue;
|
|
345
|
-
}
|
|
346
|
-
this.lowerBoundary = 128;
|
|
347
|
-
this.upperBoundary = 191;
|
|
348
|
-
this.codePoint = this.codePoint << 6 | byte & 63;
|
|
349
|
-
this.bytesSeen++;
|
|
350
|
-
if (this.bytesSeen !== this.bytesNeeded) continue;
|
|
351
|
-
result += String.fromCodePoint(this.codePoint);
|
|
352
|
-
this.codePoint = 0;
|
|
353
|
-
this.bytesNeeded = 0;
|
|
354
|
-
this.bytesSeen = 0;
|
|
355
|
-
}
|
|
356
|
-
return result;
|
|
357
|
-
}
|
|
358
|
-
flush() {
|
|
359
|
-
const result = this.bytesNeeded > 0 ? "\uFFFD" : "";
|
|
360
|
-
this.codePoint = 0;
|
|
361
|
-
this.bytesNeeded = 0;
|
|
362
|
-
this.bytesSeen = 0;
|
|
363
|
-
this.lowerBoundary = 128;
|
|
364
|
-
this.upperBoundary = 191;
|
|
365
|
-
return result;
|
|
366
|
-
}
|
|
367
|
-
};
|
|
368
|
-
}
|
|
369
|
-
});
|
|
370
|
-
|
|
371
|
-
// node_modules/text-decoder/index.js
|
|
372
|
-
var require_text_decoder = __commonJS({
|
|
373
|
-
"node_modules/text-decoder/index.js"(exports, module) {
|
|
374
|
-
"use strict";
|
|
375
|
-
var PassThroughDecoder = require_pass_through_decoder();
|
|
376
|
-
var UTF8Decoder = require_utf8_decoder();
|
|
377
|
-
module.exports = class TextDecoder {
|
|
378
|
-
constructor(encoding = "utf8") {
|
|
379
|
-
this.encoding = normalizeEncoding(encoding);
|
|
380
|
-
switch (this.encoding) {
|
|
381
|
-
case "utf8":
|
|
382
|
-
this.decoder = new UTF8Decoder();
|
|
383
|
-
break;
|
|
384
|
-
case "utf16le":
|
|
385
|
-
case "base64":
|
|
386
|
-
throw new Error("Unsupported encoding: " + this.encoding);
|
|
387
|
-
default:
|
|
388
|
-
this.decoder = new PassThroughDecoder(this.encoding);
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
get remaining() {
|
|
392
|
-
return this.decoder.remaining;
|
|
393
|
-
}
|
|
394
|
-
push(data) {
|
|
395
|
-
if (typeof data === "string") return data;
|
|
396
|
-
return this.decoder.decode(data);
|
|
397
|
-
}
|
|
398
|
-
// For Node.js compatibility
|
|
399
|
-
write(data) {
|
|
400
|
-
return this.push(data);
|
|
401
|
-
}
|
|
402
|
-
end(data) {
|
|
403
|
-
let result = "";
|
|
404
|
-
if (data) result = this.push(data);
|
|
405
|
-
result += this.decoder.flush();
|
|
406
|
-
return result;
|
|
407
|
-
}
|
|
408
|
-
};
|
|
409
|
-
function normalizeEncoding(encoding) {
|
|
410
|
-
encoding = encoding.toLowerCase();
|
|
411
|
-
switch (encoding) {
|
|
412
|
-
case "utf8":
|
|
413
|
-
case "utf-8":
|
|
414
|
-
return "utf8";
|
|
415
|
-
case "ucs2":
|
|
416
|
-
case "ucs-2":
|
|
417
|
-
case "utf16le":
|
|
418
|
-
case "utf-16le":
|
|
419
|
-
return "utf16le";
|
|
420
|
-
case "latin1":
|
|
421
|
-
case "binary":
|
|
422
|
-
return "latin1";
|
|
423
|
-
case "base64":
|
|
424
|
-
case "ascii":
|
|
425
|
-
case "hex":
|
|
426
|
-
return encoding;
|
|
427
|
-
default:
|
|
428
|
-
throw new Error("Unknown encoding: " + encoding);
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
});
|
|
433
|
-
|
|
434
|
-
// node_modules/streamx/index.js
|
|
435
|
-
var require_streamx = __commonJS({
|
|
436
|
-
"node_modules/streamx/index.js"(exports, module) {
|
|
437
|
-
"use strict";
|
|
438
|
-
var { EventEmitter } = require_default();
|
|
439
|
-
var STREAM_DESTROYED = new Error("Stream was destroyed");
|
|
440
|
-
var PREMATURE_CLOSE = new Error("Premature close");
|
|
441
|
-
var FIFO = require_fast_fifo();
|
|
442
|
-
var TextDecoder = require_text_decoder();
|
|
443
|
-
var qmt = typeof queueMicrotask === "undefined" ? (fn) => global.process.nextTick(fn) : queueMicrotask;
|
|
444
|
-
var MAX = (1 << 29) - 1;
|
|
445
|
-
var OPENING = 1;
|
|
446
|
-
var PREDESTROYING = 2;
|
|
447
|
-
var DESTROYING = 4;
|
|
448
|
-
var DESTROYED = 8;
|
|
449
|
-
var NOT_OPENING = MAX ^ OPENING;
|
|
450
|
-
var NOT_PREDESTROYING = MAX ^ PREDESTROYING;
|
|
451
|
-
var READ_ACTIVE = 1 << 4;
|
|
452
|
-
var READ_UPDATING = 2 << 4;
|
|
453
|
-
var READ_PRIMARY = 4 << 4;
|
|
454
|
-
var READ_QUEUED = 8 << 4;
|
|
455
|
-
var READ_RESUMED = 16 << 4;
|
|
456
|
-
var READ_PIPE_DRAINED = 32 << 4;
|
|
457
|
-
var READ_ENDING = 64 << 4;
|
|
458
|
-
var READ_EMIT_DATA = 128 << 4;
|
|
459
|
-
var READ_EMIT_READABLE = 256 << 4;
|
|
460
|
-
var READ_EMITTED_READABLE = 512 << 4;
|
|
461
|
-
var READ_DONE = 1024 << 4;
|
|
462
|
-
var READ_NEXT_TICK = 2048 << 4;
|
|
463
|
-
var READ_NEEDS_PUSH = 4096 << 4;
|
|
464
|
-
var READ_READ_AHEAD = 8192 << 4;
|
|
465
|
-
var READ_FLOWING = READ_RESUMED | READ_PIPE_DRAINED;
|
|
466
|
-
var READ_ACTIVE_AND_NEEDS_PUSH = READ_ACTIVE | READ_NEEDS_PUSH;
|
|
467
|
-
var READ_PRIMARY_AND_ACTIVE = READ_PRIMARY | READ_ACTIVE;
|
|
468
|
-
var READ_EMIT_READABLE_AND_QUEUED = READ_EMIT_READABLE | READ_QUEUED;
|
|
469
|
-
var READ_RESUMED_READ_AHEAD = READ_RESUMED | READ_READ_AHEAD;
|
|
470
|
-
var READ_NOT_ACTIVE = MAX ^ READ_ACTIVE;
|
|
471
|
-
var READ_NON_PRIMARY = MAX ^ READ_PRIMARY;
|
|
472
|
-
var READ_NON_PRIMARY_AND_PUSHED = MAX ^ (READ_PRIMARY | READ_NEEDS_PUSH);
|
|
473
|
-
var READ_PUSHED = MAX ^ READ_NEEDS_PUSH;
|
|
474
|
-
var READ_PAUSED = MAX ^ READ_RESUMED;
|
|
475
|
-
var READ_NOT_QUEUED = MAX ^ (READ_QUEUED | READ_EMITTED_READABLE);
|
|
476
|
-
var READ_NOT_ENDING = MAX ^ READ_ENDING;
|
|
477
|
-
var READ_PIPE_NOT_DRAINED = MAX ^ READ_FLOWING;
|
|
478
|
-
var READ_NOT_NEXT_TICK = MAX ^ READ_NEXT_TICK;
|
|
479
|
-
var READ_NOT_UPDATING = MAX ^ READ_UPDATING;
|
|
480
|
-
var READ_NO_READ_AHEAD = MAX ^ READ_READ_AHEAD;
|
|
481
|
-
var READ_PAUSED_NO_READ_AHEAD = MAX ^ READ_RESUMED_READ_AHEAD;
|
|
482
|
-
var WRITE_ACTIVE = 1 << 18;
|
|
483
|
-
var WRITE_UPDATING = 2 << 18;
|
|
484
|
-
var WRITE_PRIMARY = 4 << 18;
|
|
485
|
-
var WRITE_QUEUED = 8 << 18;
|
|
486
|
-
var WRITE_UNDRAINED = 16 << 18;
|
|
487
|
-
var WRITE_DONE = 32 << 18;
|
|
488
|
-
var WRITE_EMIT_DRAIN = 64 << 18;
|
|
489
|
-
var WRITE_NEXT_TICK = 128 << 18;
|
|
490
|
-
var WRITE_WRITING = 256 << 18;
|
|
491
|
-
var WRITE_FINISHING = 512 << 18;
|
|
492
|
-
var WRITE_CORKED = 1024 << 18;
|
|
493
|
-
var WRITE_NOT_ACTIVE = MAX ^ (WRITE_ACTIVE | WRITE_WRITING);
|
|
494
|
-
var WRITE_NON_PRIMARY = MAX ^ WRITE_PRIMARY;
|
|
495
|
-
var WRITE_NOT_FINISHING = MAX ^ (WRITE_ACTIVE | WRITE_FINISHING);
|
|
496
|
-
var WRITE_DRAINED = MAX ^ WRITE_UNDRAINED;
|
|
497
|
-
var WRITE_NOT_QUEUED = MAX ^ WRITE_QUEUED;
|
|
498
|
-
var WRITE_NOT_NEXT_TICK = MAX ^ WRITE_NEXT_TICK;
|
|
499
|
-
var WRITE_NOT_UPDATING = MAX ^ WRITE_UPDATING;
|
|
500
|
-
var WRITE_NOT_CORKED = MAX ^ WRITE_CORKED;
|
|
501
|
-
var ACTIVE = READ_ACTIVE | WRITE_ACTIVE;
|
|
502
|
-
var NOT_ACTIVE = MAX ^ ACTIVE;
|
|
503
|
-
var DONE = READ_DONE | WRITE_DONE;
|
|
504
|
-
var DESTROY_STATUS = DESTROYING | DESTROYED | PREDESTROYING;
|
|
505
|
-
var OPEN_STATUS = DESTROY_STATUS | OPENING;
|
|
506
|
-
var AUTO_DESTROY = DESTROY_STATUS | DONE;
|
|
507
|
-
var NON_PRIMARY = WRITE_NON_PRIMARY & READ_NON_PRIMARY;
|
|
508
|
-
var ACTIVE_OR_TICKING = WRITE_NEXT_TICK | READ_NEXT_TICK;
|
|
509
|
-
var TICKING = ACTIVE_OR_TICKING & NOT_ACTIVE;
|
|
510
|
-
var IS_OPENING = OPEN_STATUS | TICKING;
|
|
511
|
-
var READ_PRIMARY_STATUS = OPEN_STATUS | READ_ENDING | READ_DONE;
|
|
512
|
-
var READ_STATUS = OPEN_STATUS | READ_DONE | READ_QUEUED;
|
|
513
|
-
var READ_ENDING_STATUS = OPEN_STATUS | READ_ENDING | READ_QUEUED;
|
|
514
|
-
var READ_READABLE_STATUS = OPEN_STATUS | READ_EMIT_READABLE | READ_QUEUED | READ_EMITTED_READABLE;
|
|
515
|
-
var SHOULD_NOT_READ = OPEN_STATUS | READ_ACTIVE | READ_ENDING | READ_DONE | READ_NEEDS_PUSH | READ_READ_AHEAD;
|
|
516
|
-
var READ_BACKPRESSURE_STATUS = DESTROY_STATUS | READ_ENDING | READ_DONE;
|
|
517
|
-
var READ_UPDATE_SYNC_STATUS = READ_UPDATING | OPEN_STATUS | READ_NEXT_TICK | READ_PRIMARY;
|
|
518
|
-
var READ_NEXT_TICK_OR_OPENING = READ_NEXT_TICK | OPENING;
|
|
519
|
-
var WRITE_PRIMARY_STATUS = OPEN_STATUS | WRITE_FINISHING | WRITE_DONE;
|
|
520
|
-
var WRITE_QUEUED_AND_UNDRAINED = WRITE_QUEUED | WRITE_UNDRAINED;
|
|
521
|
-
var WRITE_QUEUED_AND_ACTIVE = WRITE_QUEUED | WRITE_ACTIVE;
|
|
522
|
-
var WRITE_DRAIN_STATUS = WRITE_QUEUED | WRITE_UNDRAINED | OPEN_STATUS | WRITE_ACTIVE;
|
|
523
|
-
var WRITE_STATUS = OPEN_STATUS | WRITE_ACTIVE | WRITE_QUEUED | WRITE_CORKED;
|
|
524
|
-
var WRITE_PRIMARY_AND_ACTIVE = WRITE_PRIMARY | WRITE_ACTIVE;
|
|
525
|
-
var WRITE_ACTIVE_AND_WRITING = WRITE_ACTIVE | WRITE_WRITING;
|
|
526
|
-
var WRITE_FINISHING_STATUS = OPEN_STATUS | WRITE_FINISHING | WRITE_QUEUED_AND_ACTIVE | WRITE_DONE;
|
|
527
|
-
var WRITE_BACKPRESSURE_STATUS = WRITE_UNDRAINED | DESTROY_STATUS | WRITE_FINISHING | WRITE_DONE;
|
|
528
|
-
var WRITE_UPDATE_SYNC_STATUS = WRITE_UPDATING | OPEN_STATUS | WRITE_NEXT_TICK | WRITE_PRIMARY;
|
|
529
|
-
var WRITE_DROP_DATA = WRITE_FINISHING | WRITE_DONE | DESTROY_STATUS;
|
|
530
|
-
var asyncIterator = Symbol.asyncIterator || /* @__PURE__ */ Symbol("asyncIterator");
|
|
531
|
-
var WritableState = class {
|
|
532
|
-
constructor(stream, { highWaterMark = 16384, map = null, mapWritable, byteLength, byteLengthWritable } = {}) {
|
|
533
|
-
this.stream = stream;
|
|
534
|
-
this.queue = new FIFO();
|
|
535
|
-
this.highWaterMark = highWaterMark;
|
|
536
|
-
this.buffered = 0;
|
|
537
|
-
this.error = null;
|
|
538
|
-
this.pipeline = null;
|
|
539
|
-
this.drains = null;
|
|
540
|
-
this.byteLength = byteLengthWritable || byteLength || defaultByteLength;
|
|
541
|
-
this.map = mapWritable || map;
|
|
542
|
-
this.afterWrite = afterWrite.bind(this);
|
|
543
|
-
this.afterUpdateNextTick = updateWriteNT.bind(this);
|
|
544
|
-
}
|
|
545
|
-
get ended() {
|
|
546
|
-
return (this.stream._duplexState & WRITE_DONE) !== 0;
|
|
547
|
-
}
|
|
548
|
-
push(data) {
|
|
549
|
-
if ((this.stream._duplexState & WRITE_DROP_DATA) !== 0) return false;
|
|
550
|
-
if (this.map !== null) data = this.map(data);
|
|
551
|
-
this.buffered += this.byteLength(data);
|
|
552
|
-
this.queue.push(data);
|
|
553
|
-
if (this.buffered < this.highWaterMark) {
|
|
554
|
-
this.stream._duplexState |= WRITE_QUEUED;
|
|
555
|
-
return true;
|
|
556
|
-
}
|
|
557
|
-
this.stream._duplexState |= WRITE_QUEUED_AND_UNDRAINED;
|
|
558
|
-
return false;
|
|
559
|
-
}
|
|
560
|
-
shift() {
|
|
561
|
-
const data = this.queue.shift();
|
|
562
|
-
this.buffered -= this.byteLength(data);
|
|
563
|
-
if (this.buffered === 0) this.stream._duplexState &= WRITE_NOT_QUEUED;
|
|
564
|
-
return data;
|
|
565
|
-
}
|
|
566
|
-
end(data) {
|
|
567
|
-
if (typeof data === "function") this.stream.once("finish", data);
|
|
568
|
-
else if (data !== void 0 && data !== null) this.push(data);
|
|
569
|
-
this.stream._duplexState = (this.stream._duplexState | WRITE_FINISHING) & WRITE_NON_PRIMARY;
|
|
570
|
-
}
|
|
571
|
-
autoBatch(data, cb) {
|
|
572
|
-
const buffer = [];
|
|
573
|
-
const stream = this.stream;
|
|
574
|
-
buffer.push(data);
|
|
575
|
-
while ((stream._duplexState & WRITE_STATUS) === WRITE_QUEUED_AND_ACTIVE) {
|
|
576
|
-
buffer.push(stream._writableState.shift());
|
|
577
|
-
}
|
|
578
|
-
if ((stream._duplexState & OPEN_STATUS) !== 0) return cb(null);
|
|
579
|
-
stream._writev(buffer, cb);
|
|
580
|
-
}
|
|
581
|
-
update() {
|
|
582
|
-
const stream = this.stream;
|
|
583
|
-
stream._duplexState |= WRITE_UPDATING;
|
|
584
|
-
do {
|
|
585
|
-
while ((stream._duplexState & WRITE_STATUS) === WRITE_QUEUED) {
|
|
586
|
-
const data = this.shift();
|
|
587
|
-
stream._duplexState |= WRITE_ACTIVE_AND_WRITING;
|
|
588
|
-
stream._write(data, this.afterWrite);
|
|
589
|
-
}
|
|
590
|
-
if ((stream._duplexState & WRITE_PRIMARY_AND_ACTIVE) === 0) this.updateNonPrimary();
|
|
591
|
-
} while (this.continueUpdate() === true);
|
|
592
|
-
stream._duplexState &= WRITE_NOT_UPDATING;
|
|
593
|
-
}
|
|
594
|
-
updateNonPrimary() {
|
|
595
|
-
const stream = this.stream;
|
|
596
|
-
if ((stream._duplexState & WRITE_FINISHING_STATUS) === WRITE_FINISHING) {
|
|
597
|
-
stream._duplexState = stream._duplexState | WRITE_ACTIVE;
|
|
598
|
-
stream._final(afterFinal.bind(this));
|
|
599
|
-
return;
|
|
600
|
-
}
|
|
601
|
-
if ((stream._duplexState & DESTROY_STATUS) === DESTROYING) {
|
|
602
|
-
if ((stream._duplexState & ACTIVE_OR_TICKING) === 0) {
|
|
603
|
-
stream._duplexState |= ACTIVE;
|
|
604
|
-
stream._destroy(afterDestroy.bind(this));
|
|
605
|
-
}
|
|
606
|
-
return;
|
|
607
|
-
}
|
|
608
|
-
if ((stream._duplexState & IS_OPENING) === OPENING) {
|
|
609
|
-
stream._duplexState = (stream._duplexState | ACTIVE) & NOT_OPENING;
|
|
610
|
-
stream._open(afterOpen.bind(this));
|
|
611
|
-
}
|
|
612
|
-
}
|
|
613
|
-
continueUpdate() {
|
|
614
|
-
if ((this.stream._duplexState & WRITE_NEXT_TICK) === 0) return false;
|
|
615
|
-
this.stream._duplexState &= WRITE_NOT_NEXT_TICK;
|
|
616
|
-
return true;
|
|
617
|
-
}
|
|
618
|
-
updateCallback() {
|
|
619
|
-
if ((this.stream._duplexState & WRITE_UPDATE_SYNC_STATUS) === WRITE_PRIMARY) this.update();
|
|
620
|
-
else this.updateNextTick();
|
|
621
|
-
}
|
|
622
|
-
updateNextTick() {
|
|
623
|
-
if ((this.stream._duplexState & WRITE_NEXT_TICK) !== 0) return;
|
|
624
|
-
this.stream._duplexState |= WRITE_NEXT_TICK;
|
|
625
|
-
if ((this.stream._duplexState & WRITE_UPDATING) === 0) qmt(this.afterUpdateNextTick);
|
|
626
|
-
}
|
|
627
|
-
};
|
|
628
|
-
var ReadableState = class {
|
|
629
|
-
constructor(stream, { highWaterMark = 16384, map = null, mapReadable, byteLength, byteLengthReadable } = {}) {
|
|
630
|
-
this.stream = stream;
|
|
631
|
-
this.queue = new FIFO();
|
|
632
|
-
this.highWaterMark = highWaterMark === 0 ? 1 : highWaterMark;
|
|
633
|
-
this.buffered = 0;
|
|
634
|
-
this.readAhead = highWaterMark > 0;
|
|
635
|
-
this.error = null;
|
|
636
|
-
this.pipeline = null;
|
|
637
|
-
this.byteLength = byteLengthReadable || byteLength || defaultByteLength;
|
|
638
|
-
this.map = mapReadable || map;
|
|
639
|
-
this.pipeTo = null;
|
|
640
|
-
this.afterRead = afterRead.bind(this);
|
|
641
|
-
this.afterUpdateNextTick = updateReadNT.bind(this);
|
|
642
|
-
}
|
|
643
|
-
get ended() {
|
|
644
|
-
return (this.stream._duplexState & READ_DONE) !== 0;
|
|
645
|
-
}
|
|
646
|
-
pipe(pipeTo, cb) {
|
|
647
|
-
if (this.pipeTo !== null) throw new Error("Can only pipe to one destination");
|
|
648
|
-
if (typeof cb !== "function") cb = null;
|
|
649
|
-
this.stream._duplexState |= READ_PIPE_DRAINED;
|
|
650
|
-
this.pipeTo = pipeTo;
|
|
651
|
-
this.pipeline = new Pipeline(this.stream, pipeTo, cb);
|
|
652
|
-
if (cb) this.stream.on("error", noop);
|
|
653
|
-
if (isStreamx(pipeTo)) {
|
|
654
|
-
pipeTo._writableState.pipeline = this.pipeline;
|
|
655
|
-
if (cb) pipeTo.on("error", noop);
|
|
656
|
-
pipeTo.on("finish", this.pipeline.finished.bind(this.pipeline));
|
|
657
|
-
} else {
|
|
658
|
-
const onerror = this.pipeline.done.bind(this.pipeline, pipeTo);
|
|
659
|
-
const onclose = this.pipeline.done.bind(this.pipeline, pipeTo, null);
|
|
660
|
-
pipeTo.on("error", onerror);
|
|
661
|
-
pipeTo.on("close", onclose);
|
|
662
|
-
pipeTo.on("finish", this.pipeline.finished.bind(this.pipeline));
|
|
663
|
-
}
|
|
664
|
-
pipeTo.on("drain", afterDrain.bind(this));
|
|
665
|
-
this.stream.emit("piping", pipeTo);
|
|
666
|
-
pipeTo.emit("pipe", this.stream);
|
|
667
|
-
}
|
|
668
|
-
push(data) {
|
|
669
|
-
const stream = this.stream;
|
|
670
|
-
if (data === null) {
|
|
671
|
-
this.highWaterMark = 0;
|
|
672
|
-
stream._duplexState = (stream._duplexState | READ_ENDING) & READ_NON_PRIMARY_AND_PUSHED;
|
|
673
|
-
return false;
|
|
674
|
-
}
|
|
675
|
-
if (this.map !== null) {
|
|
676
|
-
data = this.map(data);
|
|
677
|
-
if (data === null) {
|
|
678
|
-
stream._duplexState &= READ_PUSHED;
|
|
679
|
-
return this.buffered < this.highWaterMark;
|
|
680
|
-
}
|
|
681
|
-
}
|
|
682
|
-
this.buffered += this.byteLength(data);
|
|
683
|
-
this.queue.push(data);
|
|
684
|
-
stream._duplexState = (stream._duplexState | READ_QUEUED) & READ_PUSHED;
|
|
685
|
-
return this.buffered < this.highWaterMark;
|
|
686
|
-
}
|
|
687
|
-
shift() {
|
|
688
|
-
const data = this.queue.shift();
|
|
689
|
-
this.buffered -= this.byteLength(data);
|
|
690
|
-
if (this.buffered === 0) this.stream._duplexState &= READ_NOT_QUEUED;
|
|
691
|
-
return data;
|
|
692
|
-
}
|
|
693
|
-
unshift(data) {
|
|
694
|
-
const pending = [this.map !== null ? this.map(data) : data];
|
|
695
|
-
while (this.buffered > 0) pending.push(this.shift());
|
|
696
|
-
for (let i = 0; i < pending.length - 1; i++) {
|
|
697
|
-
const data2 = pending[i];
|
|
698
|
-
this.buffered += this.byteLength(data2);
|
|
699
|
-
this.queue.push(data2);
|
|
700
|
-
}
|
|
701
|
-
this.push(pending[pending.length - 1]);
|
|
702
|
-
}
|
|
703
|
-
read() {
|
|
704
|
-
const stream = this.stream;
|
|
705
|
-
if ((stream._duplexState & READ_STATUS) === READ_QUEUED) {
|
|
706
|
-
const data = this.shift();
|
|
707
|
-
if (this.pipeTo !== null && this.pipeTo.write(data) === false) stream._duplexState &= READ_PIPE_NOT_DRAINED;
|
|
708
|
-
if ((stream._duplexState & READ_EMIT_DATA) !== 0) stream.emit("data", data);
|
|
709
|
-
return data;
|
|
710
|
-
}
|
|
711
|
-
if (this.readAhead === false) {
|
|
712
|
-
stream._duplexState |= READ_READ_AHEAD;
|
|
713
|
-
this.updateNextTick();
|
|
714
|
-
}
|
|
715
|
-
return null;
|
|
716
|
-
}
|
|
717
|
-
drain() {
|
|
718
|
-
const stream = this.stream;
|
|
719
|
-
while ((stream._duplexState & READ_STATUS) === READ_QUEUED && (stream._duplexState & READ_FLOWING) !== 0) {
|
|
720
|
-
const data = this.shift();
|
|
721
|
-
if (this.pipeTo !== null && this.pipeTo.write(data) === false) stream._duplexState &= READ_PIPE_NOT_DRAINED;
|
|
722
|
-
if ((stream._duplexState & READ_EMIT_DATA) !== 0) stream.emit("data", data);
|
|
723
|
-
}
|
|
724
|
-
}
|
|
725
|
-
update() {
|
|
726
|
-
const stream = this.stream;
|
|
727
|
-
stream._duplexState |= READ_UPDATING;
|
|
728
|
-
do {
|
|
729
|
-
this.drain();
|
|
730
|
-
while (this.buffered < this.highWaterMark && (stream._duplexState & SHOULD_NOT_READ) === READ_READ_AHEAD) {
|
|
731
|
-
stream._duplexState |= READ_ACTIVE_AND_NEEDS_PUSH;
|
|
732
|
-
stream._read(this.afterRead);
|
|
733
|
-
this.drain();
|
|
734
|
-
}
|
|
735
|
-
if ((stream._duplexState & READ_READABLE_STATUS) === READ_EMIT_READABLE_AND_QUEUED) {
|
|
736
|
-
stream._duplexState |= READ_EMITTED_READABLE;
|
|
737
|
-
stream.emit("readable");
|
|
738
|
-
}
|
|
739
|
-
if ((stream._duplexState & READ_PRIMARY_AND_ACTIVE) === 0) this.updateNonPrimary();
|
|
740
|
-
} while (this.continueUpdate() === true);
|
|
741
|
-
stream._duplexState &= READ_NOT_UPDATING;
|
|
742
|
-
}
|
|
743
|
-
updateNonPrimary() {
|
|
744
|
-
const stream = this.stream;
|
|
745
|
-
if ((stream._duplexState & READ_ENDING_STATUS) === READ_ENDING) {
|
|
746
|
-
stream._duplexState = (stream._duplexState | READ_DONE) & READ_NOT_ENDING;
|
|
747
|
-
stream.emit("end");
|
|
748
|
-
if ((stream._duplexState & AUTO_DESTROY) === DONE) stream._duplexState |= DESTROYING;
|
|
749
|
-
if (this.pipeTo !== null) this.pipeTo.end();
|
|
750
|
-
}
|
|
751
|
-
if ((stream._duplexState & DESTROY_STATUS) === DESTROYING) {
|
|
752
|
-
if ((stream._duplexState & ACTIVE_OR_TICKING) === 0) {
|
|
753
|
-
stream._duplexState |= ACTIVE;
|
|
754
|
-
stream._destroy(afterDestroy.bind(this));
|
|
755
|
-
}
|
|
756
|
-
return;
|
|
757
|
-
}
|
|
758
|
-
if ((stream._duplexState & IS_OPENING) === OPENING) {
|
|
759
|
-
stream._duplexState = (stream._duplexState | ACTIVE) & NOT_OPENING;
|
|
760
|
-
stream._open(afterOpen.bind(this));
|
|
761
|
-
}
|
|
762
|
-
}
|
|
763
|
-
continueUpdate() {
|
|
764
|
-
if ((this.stream._duplexState & READ_NEXT_TICK) === 0) return false;
|
|
765
|
-
this.stream._duplexState &= READ_NOT_NEXT_TICK;
|
|
766
|
-
return true;
|
|
767
|
-
}
|
|
768
|
-
updateCallback() {
|
|
769
|
-
if ((this.stream._duplexState & READ_UPDATE_SYNC_STATUS) === READ_PRIMARY) this.update();
|
|
770
|
-
else this.updateNextTick();
|
|
771
|
-
}
|
|
772
|
-
updateNextTickIfOpen() {
|
|
773
|
-
if ((this.stream._duplexState & READ_NEXT_TICK_OR_OPENING) !== 0) return;
|
|
774
|
-
this.stream._duplexState |= READ_NEXT_TICK;
|
|
775
|
-
if ((this.stream._duplexState & READ_UPDATING) === 0) qmt(this.afterUpdateNextTick);
|
|
776
|
-
}
|
|
777
|
-
updateNextTick() {
|
|
778
|
-
if ((this.stream._duplexState & READ_NEXT_TICK) !== 0) return;
|
|
779
|
-
this.stream._duplexState |= READ_NEXT_TICK;
|
|
780
|
-
if ((this.stream._duplexState & READ_UPDATING) === 0) qmt(this.afterUpdateNextTick);
|
|
781
|
-
}
|
|
782
|
-
};
|
|
783
|
-
var TransformState = class {
|
|
784
|
-
constructor(stream) {
|
|
785
|
-
this.data = null;
|
|
786
|
-
this.afterTransform = afterTransform.bind(stream);
|
|
787
|
-
this.afterFinal = null;
|
|
788
|
-
}
|
|
789
|
-
};
|
|
790
|
-
var Pipeline = class {
|
|
791
|
-
constructor(src, dst, cb) {
|
|
792
|
-
this.from = src;
|
|
793
|
-
this.to = dst;
|
|
794
|
-
this.afterPipe = cb;
|
|
795
|
-
this.error = null;
|
|
796
|
-
this.pipeToFinished = false;
|
|
797
|
-
}
|
|
798
|
-
finished() {
|
|
799
|
-
this.pipeToFinished = true;
|
|
800
|
-
}
|
|
801
|
-
done(stream, err) {
|
|
802
|
-
if (err) this.error = err;
|
|
803
|
-
if (stream === this.to) {
|
|
804
|
-
this.to = null;
|
|
805
|
-
if (this.from !== null) {
|
|
806
|
-
if ((this.from._duplexState & READ_DONE) === 0 || !this.pipeToFinished) {
|
|
807
|
-
this.from.destroy(this.error || new Error("Writable stream closed prematurely"));
|
|
808
|
-
}
|
|
809
|
-
return;
|
|
810
|
-
}
|
|
811
|
-
}
|
|
812
|
-
if (stream === this.from) {
|
|
813
|
-
this.from = null;
|
|
814
|
-
if (this.to !== null) {
|
|
815
|
-
if ((stream._duplexState & READ_DONE) === 0) {
|
|
816
|
-
this.to.destroy(this.error || new Error("Readable stream closed before ending"));
|
|
817
|
-
}
|
|
818
|
-
return;
|
|
819
|
-
}
|
|
820
|
-
}
|
|
821
|
-
if (this.afterPipe !== null) this.afterPipe(this.error);
|
|
822
|
-
this.to = this.from = this.afterPipe = null;
|
|
823
|
-
}
|
|
824
|
-
};
|
|
825
|
-
function afterDrain() {
|
|
826
|
-
this.stream._duplexState |= READ_PIPE_DRAINED;
|
|
827
|
-
this.updateCallback();
|
|
828
|
-
}
|
|
829
|
-
function afterFinal(err) {
|
|
830
|
-
const stream = this.stream;
|
|
831
|
-
if (err) stream.destroy(err);
|
|
832
|
-
if ((stream._duplexState & DESTROY_STATUS) === 0) {
|
|
833
|
-
stream._duplexState |= WRITE_DONE;
|
|
834
|
-
stream.emit("finish");
|
|
835
|
-
}
|
|
836
|
-
if ((stream._duplexState & AUTO_DESTROY) === DONE) {
|
|
837
|
-
stream._duplexState |= DESTROYING;
|
|
838
|
-
}
|
|
839
|
-
stream._duplexState &= WRITE_NOT_FINISHING;
|
|
840
|
-
if ((stream._duplexState & WRITE_UPDATING) === 0) this.update();
|
|
841
|
-
else this.updateNextTick();
|
|
842
|
-
}
|
|
843
|
-
function afterDestroy(err) {
|
|
844
|
-
const stream = this.stream;
|
|
845
|
-
if (!err && this.error !== STREAM_DESTROYED) err = this.error;
|
|
846
|
-
if (err) stream.emit("error", err);
|
|
847
|
-
stream._duplexState |= DESTROYED;
|
|
848
|
-
stream.emit("close");
|
|
849
|
-
const rs = stream._readableState;
|
|
850
|
-
const ws = stream._writableState;
|
|
851
|
-
if (rs !== null && rs.pipeline !== null) rs.pipeline.done(stream, err);
|
|
852
|
-
if (ws !== null) {
|
|
853
|
-
while (ws.drains !== null && ws.drains.length > 0) ws.drains.shift().resolve(false);
|
|
854
|
-
if (ws.pipeline !== null) ws.pipeline.done(stream, err);
|
|
855
|
-
}
|
|
856
|
-
}
|
|
857
|
-
function afterWrite(err) {
|
|
858
|
-
const stream = this.stream;
|
|
859
|
-
if (err) stream.destroy(err);
|
|
860
|
-
stream._duplexState &= WRITE_NOT_ACTIVE;
|
|
861
|
-
if (this.drains !== null) tickDrains(this.drains);
|
|
862
|
-
if ((stream._duplexState & WRITE_DRAIN_STATUS) === WRITE_UNDRAINED) {
|
|
863
|
-
stream._duplexState &= WRITE_DRAINED;
|
|
864
|
-
if ((stream._duplexState & WRITE_EMIT_DRAIN) === WRITE_EMIT_DRAIN) {
|
|
865
|
-
stream.emit("drain");
|
|
866
|
-
}
|
|
867
|
-
}
|
|
868
|
-
this.updateCallback();
|
|
869
|
-
}
|
|
870
|
-
function afterRead(err) {
|
|
871
|
-
if (err) this.stream.destroy(err);
|
|
872
|
-
this.stream._duplexState &= READ_NOT_ACTIVE;
|
|
873
|
-
if (this.readAhead === false && (this.stream._duplexState & READ_RESUMED) === 0) this.stream._duplexState &= READ_NO_READ_AHEAD;
|
|
874
|
-
this.updateCallback();
|
|
875
|
-
}
|
|
876
|
-
function updateReadNT() {
|
|
877
|
-
if ((this.stream._duplexState & READ_UPDATING) === 0) {
|
|
878
|
-
this.stream._duplexState &= READ_NOT_NEXT_TICK;
|
|
879
|
-
this.update();
|
|
880
|
-
}
|
|
881
|
-
}
|
|
882
|
-
function updateWriteNT() {
|
|
883
|
-
if ((this.stream._duplexState & WRITE_UPDATING) === 0) {
|
|
884
|
-
this.stream._duplexState &= WRITE_NOT_NEXT_TICK;
|
|
885
|
-
this.update();
|
|
886
|
-
}
|
|
887
|
-
}
|
|
888
|
-
function tickDrains(drains) {
|
|
889
|
-
for (let i = 0; i < drains.length; i++) {
|
|
890
|
-
if (--drains[i].writes === 0) {
|
|
891
|
-
drains.shift().resolve(true);
|
|
892
|
-
i--;
|
|
893
|
-
}
|
|
894
|
-
}
|
|
895
|
-
}
|
|
896
|
-
function afterOpen(err) {
|
|
897
|
-
const stream = this.stream;
|
|
898
|
-
if (err) stream.destroy(err);
|
|
899
|
-
if ((stream._duplexState & DESTROYING) === 0) {
|
|
900
|
-
if ((stream._duplexState & READ_PRIMARY_STATUS) === 0) stream._duplexState |= READ_PRIMARY;
|
|
901
|
-
if ((stream._duplexState & WRITE_PRIMARY_STATUS) === 0) stream._duplexState |= WRITE_PRIMARY;
|
|
902
|
-
stream.emit("open");
|
|
903
|
-
}
|
|
904
|
-
stream._duplexState &= NOT_ACTIVE;
|
|
905
|
-
if (stream._writableState !== null) {
|
|
906
|
-
stream._writableState.updateCallback();
|
|
907
|
-
}
|
|
908
|
-
if (stream._readableState !== null) {
|
|
909
|
-
stream._readableState.updateCallback();
|
|
910
|
-
}
|
|
911
|
-
}
|
|
912
|
-
function afterTransform(err, data) {
|
|
913
|
-
if (data !== void 0 && data !== null) this.push(data);
|
|
914
|
-
this._writableState.afterWrite(err);
|
|
915
|
-
}
|
|
916
|
-
function newListener(name) {
|
|
917
|
-
if (this._readableState !== null) {
|
|
918
|
-
if (name === "data") {
|
|
919
|
-
this._duplexState |= READ_EMIT_DATA | READ_RESUMED_READ_AHEAD;
|
|
920
|
-
this._readableState.updateNextTick();
|
|
921
|
-
}
|
|
922
|
-
if (name === "readable") {
|
|
923
|
-
this._duplexState |= READ_EMIT_READABLE;
|
|
924
|
-
this._readableState.updateNextTick();
|
|
925
|
-
}
|
|
926
|
-
}
|
|
927
|
-
if (this._writableState !== null) {
|
|
928
|
-
if (name === "drain") {
|
|
929
|
-
this._duplexState |= WRITE_EMIT_DRAIN;
|
|
930
|
-
this._writableState.updateNextTick();
|
|
931
|
-
}
|
|
932
|
-
}
|
|
933
|
-
}
|
|
934
|
-
var Stream = class extends EventEmitter {
|
|
935
|
-
constructor(opts) {
|
|
936
|
-
super();
|
|
937
|
-
this._duplexState = 0;
|
|
938
|
-
this._readableState = null;
|
|
939
|
-
this._writableState = null;
|
|
940
|
-
if (opts) {
|
|
941
|
-
if (opts.open) this._open = opts.open;
|
|
942
|
-
if (opts.destroy) this._destroy = opts.destroy;
|
|
943
|
-
if (opts.predestroy) this._predestroy = opts.predestroy;
|
|
944
|
-
if (opts.signal) {
|
|
945
|
-
opts.signal.addEventListener("abort", abort.bind(this));
|
|
946
|
-
}
|
|
947
|
-
}
|
|
948
|
-
this.on("newListener", newListener);
|
|
949
|
-
}
|
|
950
|
-
_open(cb) {
|
|
951
|
-
cb(null);
|
|
952
|
-
}
|
|
953
|
-
_destroy(cb) {
|
|
954
|
-
cb(null);
|
|
955
|
-
}
|
|
956
|
-
_predestroy() {
|
|
957
|
-
}
|
|
958
|
-
get readable() {
|
|
959
|
-
return this._readableState !== null ? true : void 0;
|
|
960
|
-
}
|
|
961
|
-
get writable() {
|
|
962
|
-
return this._writableState !== null ? true : void 0;
|
|
963
|
-
}
|
|
964
|
-
get destroyed() {
|
|
965
|
-
return (this._duplexState & DESTROYED) !== 0;
|
|
966
|
-
}
|
|
967
|
-
get destroying() {
|
|
968
|
-
return (this._duplexState & DESTROY_STATUS) !== 0;
|
|
969
|
-
}
|
|
970
|
-
destroy(err) {
|
|
971
|
-
if ((this._duplexState & DESTROY_STATUS) === 0) {
|
|
972
|
-
if (!err) err = STREAM_DESTROYED;
|
|
973
|
-
this._duplexState = (this._duplexState | DESTROYING) & NON_PRIMARY;
|
|
974
|
-
if (this._readableState !== null) {
|
|
975
|
-
this._readableState.highWaterMark = 0;
|
|
976
|
-
this._readableState.error = err;
|
|
977
|
-
}
|
|
978
|
-
if (this._writableState !== null) {
|
|
979
|
-
this._writableState.highWaterMark = 0;
|
|
980
|
-
this._writableState.error = err;
|
|
981
|
-
}
|
|
982
|
-
this._duplexState |= PREDESTROYING;
|
|
983
|
-
this._predestroy();
|
|
984
|
-
this._duplexState &= NOT_PREDESTROYING;
|
|
985
|
-
if (this._readableState !== null) this._readableState.updateNextTick();
|
|
986
|
-
if (this._writableState !== null) this._writableState.updateNextTick();
|
|
987
|
-
}
|
|
988
|
-
}
|
|
989
|
-
};
|
|
990
|
-
var Readable = class _Readable extends Stream {
|
|
991
|
-
constructor(opts) {
|
|
992
|
-
super(opts);
|
|
993
|
-
this._duplexState |= OPENING | WRITE_DONE | READ_READ_AHEAD;
|
|
994
|
-
this._readableState = new ReadableState(this, opts);
|
|
995
|
-
if (opts) {
|
|
996
|
-
if (this._readableState.readAhead === false) this._duplexState &= READ_NO_READ_AHEAD;
|
|
997
|
-
if (opts.read) this._read = opts.read;
|
|
998
|
-
if (opts.eagerOpen) this._readableState.updateNextTick();
|
|
999
|
-
if (opts.encoding) this.setEncoding(opts.encoding);
|
|
1000
|
-
}
|
|
1001
|
-
}
|
|
1002
|
-
setEncoding(encoding) {
|
|
1003
|
-
const dec = new TextDecoder(encoding);
|
|
1004
|
-
const map = this._readableState.map || echo;
|
|
1005
|
-
this._readableState.map = mapOrSkip;
|
|
1006
|
-
return this;
|
|
1007
|
-
function mapOrSkip(data) {
|
|
1008
|
-
const next = dec.push(data);
|
|
1009
|
-
return next === "" && (data.byteLength !== 0 || dec.remaining > 0) ? null : map(next);
|
|
1010
|
-
}
|
|
1011
|
-
}
|
|
1012
|
-
_read(cb) {
|
|
1013
|
-
cb(null);
|
|
1014
|
-
}
|
|
1015
|
-
pipe(dest, cb) {
|
|
1016
|
-
this._readableState.updateNextTick();
|
|
1017
|
-
this._readableState.pipe(dest, cb);
|
|
1018
|
-
return dest;
|
|
1019
|
-
}
|
|
1020
|
-
read() {
|
|
1021
|
-
this._readableState.updateNextTick();
|
|
1022
|
-
return this._readableState.read();
|
|
1023
|
-
}
|
|
1024
|
-
push(data) {
|
|
1025
|
-
this._readableState.updateNextTickIfOpen();
|
|
1026
|
-
return this._readableState.push(data);
|
|
1027
|
-
}
|
|
1028
|
-
unshift(data) {
|
|
1029
|
-
this._readableState.updateNextTickIfOpen();
|
|
1030
|
-
return this._readableState.unshift(data);
|
|
1031
|
-
}
|
|
1032
|
-
resume() {
|
|
1033
|
-
this._duplexState |= READ_RESUMED_READ_AHEAD;
|
|
1034
|
-
this._readableState.updateNextTick();
|
|
1035
|
-
return this;
|
|
1036
|
-
}
|
|
1037
|
-
pause() {
|
|
1038
|
-
this._duplexState &= this._readableState.readAhead === false ? READ_PAUSED_NO_READ_AHEAD : READ_PAUSED;
|
|
1039
|
-
return this;
|
|
1040
|
-
}
|
|
1041
|
-
static _fromAsyncIterator(ite, opts) {
|
|
1042
|
-
let destroy;
|
|
1043
|
-
const rs = new _Readable({
|
|
1044
|
-
...opts,
|
|
1045
|
-
read(cb) {
|
|
1046
|
-
ite.next().then(push).then(cb.bind(null, null)).catch(cb);
|
|
1047
|
-
},
|
|
1048
|
-
predestroy() {
|
|
1049
|
-
destroy = ite.return();
|
|
1050
|
-
},
|
|
1051
|
-
destroy(cb) {
|
|
1052
|
-
if (!destroy) return cb(null);
|
|
1053
|
-
destroy.then(cb.bind(null, null)).catch(cb);
|
|
1054
|
-
}
|
|
1055
|
-
});
|
|
1056
|
-
return rs;
|
|
1057
|
-
function push(data) {
|
|
1058
|
-
if (data.done) rs.push(null);
|
|
1059
|
-
else rs.push(data.value);
|
|
1060
|
-
}
|
|
1061
|
-
}
|
|
1062
|
-
static from(data, opts) {
|
|
1063
|
-
if (isReadStreamx(data)) return data;
|
|
1064
|
-
if (data[asyncIterator]) return this._fromAsyncIterator(data[asyncIterator](), opts);
|
|
1065
|
-
if (!Array.isArray(data)) data = data === void 0 ? [] : [data];
|
|
1066
|
-
let i = 0;
|
|
1067
|
-
return new _Readable({
|
|
1068
|
-
...opts,
|
|
1069
|
-
read(cb) {
|
|
1070
|
-
this.push(i === data.length ? null : data[i++]);
|
|
1071
|
-
cb(null);
|
|
1072
|
-
}
|
|
1073
|
-
});
|
|
1074
|
-
}
|
|
1075
|
-
static isBackpressured(rs) {
|
|
1076
|
-
return (rs._duplexState & READ_BACKPRESSURE_STATUS) !== 0 || rs._readableState.buffered >= rs._readableState.highWaterMark;
|
|
1077
|
-
}
|
|
1078
|
-
static isPaused(rs) {
|
|
1079
|
-
return (rs._duplexState & READ_RESUMED) === 0;
|
|
1080
|
-
}
|
|
1081
|
-
[asyncIterator]() {
|
|
1082
|
-
const stream = this;
|
|
1083
|
-
let error = null;
|
|
1084
|
-
let promiseResolve = null;
|
|
1085
|
-
let promiseReject = null;
|
|
1086
|
-
this.on("error", (err) => {
|
|
1087
|
-
error = err;
|
|
1088
|
-
});
|
|
1089
|
-
this.on("readable", onreadable);
|
|
1090
|
-
this.on("close", onclose);
|
|
1091
|
-
return {
|
|
1092
|
-
[asyncIterator]() {
|
|
1093
|
-
return this;
|
|
1094
|
-
},
|
|
1095
|
-
next() {
|
|
1096
|
-
return new Promise(function(resolve, reject) {
|
|
1097
|
-
promiseResolve = resolve;
|
|
1098
|
-
promiseReject = reject;
|
|
1099
|
-
const data = stream.read();
|
|
1100
|
-
if (data !== null) ondata(data);
|
|
1101
|
-
else if ((stream._duplexState & DESTROYED) !== 0) ondata(null);
|
|
1102
|
-
});
|
|
1103
|
-
},
|
|
1104
|
-
return() {
|
|
1105
|
-
return destroy(null);
|
|
1106
|
-
},
|
|
1107
|
-
throw(err) {
|
|
1108
|
-
return destroy(err);
|
|
1109
|
-
}
|
|
1110
|
-
};
|
|
1111
|
-
function onreadable() {
|
|
1112
|
-
if (promiseResolve !== null) ondata(stream.read());
|
|
1113
|
-
}
|
|
1114
|
-
function onclose() {
|
|
1115
|
-
if (promiseResolve !== null) ondata(null);
|
|
1116
|
-
}
|
|
1117
|
-
function ondata(data) {
|
|
1118
|
-
if (promiseReject === null) return;
|
|
1119
|
-
if (error) promiseReject(error);
|
|
1120
|
-
else if (data === null && (stream._duplexState & READ_DONE) === 0) promiseReject(STREAM_DESTROYED);
|
|
1121
|
-
else promiseResolve({ value: data, done: data === null });
|
|
1122
|
-
promiseReject = promiseResolve = null;
|
|
1123
|
-
}
|
|
1124
|
-
function destroy(err) {
|
|
1125
|
-
stream.destroy(err);
|
|
1126
|
-
return new Promise((resolve, reject) => {
|
|
1127
|
-
if (stream._duplexState & DESTROYED) return resolve({ value: void 0, done: true });
|
|
1128
|
-
stream.once("close", function() {
|
|
1129
|
-
if (err) reject(err);
|
|
1130
|
-
else resolve({ value: void 0, done: true });
|
|
1131
|
-
});
|
|
1132
|
-
});
|
|
1133
|
-
}
|
|
1134
|
-
}
|
|
1135
|
-
};
|
|
1136
|
-
var Writable = class extends Stream {
|
|
1137
|
-
constructor(opts) {
|
|
1138
|
-
super(opts);
|
|
1139
|
-
this._duplexState |= OPENING | READ_DONE;
|
|
1140
|
-
this._writableState = new WritableState(this, opts);
|
|
1141
|
-
if (opts) {
|
|
1142
|
-
if (opts.writev) this._writev = opts.writev;
|
|
1143
|
-
if (opts.write) this._write = opts.write;
|
|
1144
|
-
if (opts.final) this._final = opts.final;
|
|
1145
|
-
if (opts.eagerOpen) this._writableState.updateNextTick();
|
|
1146
|
-
}
|
|
1147
|
-
}
|
|
1148
|
-
cork() {
|
|
1149
|
-
this._duplexState |= WRITE_CORKED;
|
|
1150
|
-
}
|
|
1151
|
-
uncork() {
|
|
1152
|
-
this._duplexState &= WRITE_NOT_CORKED;
|
|
1153
|
-
this._writableState.updateNextTick();
|
|
1154
|
-
}
|
|
1155
|
-
_writev(batch, cb) {
|
|
1156
|
-
cb(null);
|
|
1157
|
-
}
|
|
1158
|
-
_write(data, cb) {
|
|
1159
|
-
this._writableState.autoBatch(data, cb);
|
|
1160
|
-
}
|
|
1161
|
-
_final(cb) {
|
|
1162
|
-
cb(null);
|
|
1163
|
-
}
|
|
1164
|
-
static isBackpressured(ws) {
|
|
1165
|
-
return (ws._duplexState & WRITE_BACKPRESSURE_STATUS) !== 0;
|
|
1166
|
-
}
|
|
1167
|
-
static drained(ws) {
|
|
1168
|
-
if (ws.destroyed) return Promise.resolve(false);
|
|
1169
|
-
const state = ws._writableState;
|
|
1170
|
-
const pending = isWritev(ws) ? Math.min(1, state.queue.length) : state.queue.length;
|
|
1171
|
-
const writes = pending + (ws._duplexState & WRITE_WRITING ? 1 : 0);
|
|
1172
|
-
if (writes === 0) return Promise.resolve(true);
|
|
1173
|
-
if (state.drains === null) state.drains = [];
|
|
1174
|
-
return new Promise((resolve) => {
|
|
1175
|
-
state.drains.push({ writes, resolve });
|
|
1176
|
-
});
|
|
1177
|
-
}
|
|
1178
|
-
write(data) {
|
|
1179
|
-
this._writableState.updateNextTick();
|
|
1180
|
-
return this._writableState.push(data);
|
|
1181
|
-
}
|
|
1182
|
-
end(data) {
|
|
1183
|
-
this._writableState.updateNextTick();
|
|
1184
|
-
this._writableState.end(data);
|
|
1185
|
-
return this;
|
|
1186
|
-
}
|
|
1187
|
-
};
|
|
1188
|
-
var Duplex = class extends Readable {
|
|
1189
|
-
// and Writable
|
|
1190
|
-
constructor(opts) {
|
|
1191
|
-
super(opts);
|
|
1192
|
-
this._duplexState = OPENING | this._duplexState & READ_READ_AHEAD;
|
|
1193
|
-
this._writableState = new WritableState(this, opts);
|
|
1194
|
-
if (opts) {
|
|
1195
|
-
if (opts.writev) this._writev = opts.writev;
|
|
1196
|
-
if (opts.write) this._write = opts.write;
|
|
1197
|
-
if (opts.final) this._final = opts.final;
|
|
1198
|
-
}
|
|
1199
|
-
}
|
|
1200
|
-
cork() {
|
|
1201
|
-
this._duplexState |= WRITE_CORKED;
|
|
1202
|
-
}
|
|
1203
|
-
uncork() {
|
|
1204
|
-
this._duplexState &= WRITE_NOT_CORKED;
|
|
1205
|
-
this._writableState.updateNextTick();
|
|
1206
|
-
}
|
|
1207
|
-
_writev(batch, cb) {
|
|
1208
|
-
cb(null);
|
|
1209
|
-
}
|
|
1210
|
-
_write(data, cb) {
|
|
1211
|
-
this._writableState.autoBatch(data, cb);
|
|
1212
|
-
}
|
|
1213
|
-
_final(cb) {
|
|
1214
|
-
cb(null);
|
|
1215
|
-
}
|
|
1216
|
-
write(data) {
|
|
1217
|
-
this._writableState.updateNextTick();
|
|
1218
|
-
return this._writableState.push(data);
|
|
1219
|
-
}
|
|
1220
|
-
end(data) {
|
|
1221
|
-
this._writableState.updateNextTick();
|
|
1222
|
-
this._writableState.end(data);
|
|
1223
|
-
return this;
|
|
1224
|
-
}
|
|
1225
|
-
};
|
|
1226
|
-
var Transform = class extends Duplex {
|
|
1227
|
-
constructor(opts) {
|
|
1228
|
-
super(opts);
|
|
1229
|
-
this._transformState = new TransformState(this);
|
|
1230
|
-
if (opts) {
|
|
1231
|
-
if (opts.transform) this._transform = opts.transform;
|
|
1232
|
-
if (opts.flush) this._flush = opts.flush;
|
|
1233
|
-
}
|
|
1234
|
-
}
|
|
1235
|
-
_write(data, cb) {
|
|
1236
|
-
if (this._readableState.buffered >= this._readableState.highWaterMark) {
|
|
1237
|
-
this._transformState.data = data;
|
|
1238
|
-
} else {
|
|
1239
|
-
this._transform(data, this._transformState.afterTransform);
|
|
1240
|
-
}
|
|
1241
|
-
}
|
|
1242
|
-
_read(cb) {
|
|
1243
|
-
if (this._transformState.data !== null) {
|
|
1244
|
-
const data = this._transformState.data;
|
|
1245
|
-
this._transformState.data = null;
|
|
1246
|
-
cb(null);
|
|
1247
|
-
this._transform(data, this._transformState.afterTransform);
|
|
1248
|
-
} else {
|
|
1249
|
-
cb(null);
|
|
1250
|
-
}
|
|
1251
|
-
}
|
|
1252
|
-
destroy(err) {
|
|
1253
|
-
super.destroy(err);
|
|
1254
|
-
if (this._transformState.data !== null) {
|
|
1255
|
-
this._transformState.data = null;
|
|
1256
|
-
this._transformState.afterTransform();
|
|
1257
|
-
}
|
|
1258
|
-
}
|
|
1259
|
-
_transform(data, cb) {
|
|
1260
|
-
cb(null, data);
|
|
1261
|
-
}
|
|
1262
|
-
_flush(cb) {
|
|
1263
|
-
cb(null);
|
|
1264
|
-
}
|
|
1265
|
-
_final(cb) {
|
|
1266
|
-
this._transformState.afterFinal = cb;
|
|
1267
|
-
this._flush(transformAfterFlush.bind(this));
|
|
1268
|
-
}
|
|
1269
|
-
};
|
|
1270
|
-
var PassThrough = class extends Transform {
|
|
1271
|
-
};
|
|
1272
|
-
function transformAfterFlush(err, data) {
|
|
1273
|
-
const cb = this._transformState.afterFinal;
|
|
1274
|
-
if (err) return cb(err);
|
|
1275
|
-
if (data !== null && data !== void 0) this.push(data);
|
|
1276
|
-
this.push(null);
|
|
1277
|
-
cb(null);
|
|
1278
|
-
}
|
|
1279
|
-
function pipelinePromise(...streams) {
|
|
1280
|
-
return new Promise((resolve, reject) => {
|
|
1281
|
-
return pipeline(...streams, (err) => {
|
|
1282
|
-
if (err) return reject(err);
|
|
1283
|
-
resolve();
|
|
1284
|
-
});
|
|
1285
|
-
});
|
|
1286
|
-
}
|
|
1287
|
-
function pipeline(stream, ...streams) {
|
|
1288
|
-
const all = Array.isArray(stream) ? [...stream, ...streams] : [stream, ...streams];
|
|
1289
|
-
const done = all.length && typeof all[all.length - 1] === "function" ? all.pop() : null;
|
|
1290
|
-
if (all.length < 2) throw new Error("Pipeline requires at least 2 streams");
|
|
1291
|
-
let src = all[0];
|
|
1292
|
-
let dest = null;
|
|
1293
|
-
let error = null;
|
|
1294
|
-
for (let i = 1; i < all.length; i++) {
|
|
1295
|
-
dest = all[i];
|
|
1296
|
-
if (isStreamx(src)) {
|
|
1297
|
-
src.pipe(dest, onerror);
|
|
1298
|
-
} else {
|
|
1299
|
-
errorHandle(src, true, i > 1, onerror);
|
|
1300
|
-
src.pipe(dest);
|
|
1301
|
-
}
|
|
1302
|
-
src = dest;
|
|
1303
|
-
}
|
|
1304
|
-
if (done) {
|
|
1305
|
-
let fin = false;
|
|
1306
|
-
const autoDestroy = isStreamx(dest) || !!(dest._writableState && dest._writableState.autoDestroy);
|
|
1307
|
-
dest.on("error", (err) => {
|
|
1308
|
-
if (error === null) error = err;
|
|
1309
|
-
});
|
|
1310
|
-
dest.on("finish", () => {
|
|
1311
|
-
fin = true;
|
|
1312
|
-
if (!autoDestroy) done(error);
|
|
1313
|
-
});
|
|
1314
|
-
if (autoDestroy) {
|
|
1315
|
-
dest.on("close", () => done(error || (fin ? null : PREMATURE_CLOSE)));
|
|
1316
|
-
}
|
|
1317
|
-
}
|
|
1318
|
-
return dest;
|
|
1319
|
-
function errorHandle(s, rd, wr, onerror2) {
|
|
1320
|
-
s.on("error", onerror2);
|
|
1321
|
-
s.on("close", onclose);
|
|
1322
|
-
function onclose() {
|
|
1323
|
-
if (rd && s._readableState && !s._readableState.ended) return onerror2(PREMATURE_CLOSE);
|
|
1324
|
-
if (wr && s._writableState && !s._writableState.ended) return onerror2(PREMATURE_CLOSE);
|
|
1325
|
-
}
|
|
1326
|
-
}
|
|
1327
|
-
function onerror(err) {
|
|
1328
|
-
if (!err || error) return;
|
|
1329
|
-
error = err;
|
|
1330
|
-
for (const s of all) {
|
|
1331
|
-
s.destroy(err);
|
|
1332
|
-
}
|
|
1333
|
-
}
|
|
1334
|
-
}
|
|
1335
|
-
function echo(s) {
|
|
1336
|
-
return s;
|
|
1337
|
-
}
|
|
1338
|
-
function isStream(stream) {
|
|
1339
|
-
return !!stream._readableState || !!stream._writableState;
|
|
1340
|
-
}
|
|
1341
|
-
function isStreamx(stream) {
|
|
1342
|
-
return typeof stream._duplexState === "number" && isStream(stream);
|
|
1343
|
-
}
|
|
1344
|
-
function isEnded(stream) {
|
|
1345
|
-
return !!stream._readableState && stream._readableState.ended;
|
|
1346
|
-
}
|
|
1347
|
-
function isFinished(stream) {
|
|
1348
|
-
return !!stream._writableState && stream._writableState.ended;
|
|
1349
|
-
}
|
|
1350
|
-
function getStreamError(stream, opts = {}) {
|
|
1351
|
-
const err = stream._readableState && stream._readableState.error || stream._writableState && stream._writableState.error;
|
|
1352
|
-
return !opts.all && err === STREAM_DESTROYED ? null : err;
|
|
1353
|
-
}
|
|
1354
|
-
function isReadStreamx(stream) {
|
|
1355
|
-
return isStreamx(stream) && stream.readable;
|
|
1356
|
-
}
|
|
1357
|
-
function isDisturbed(stream) {
|
|
1358
|
-
return (stream._duplexState & OPENING) !== OPENING || (stream._duplexState & ACTIVE_OR_TICKING) !== 0;
|
|
1359
|
-
}
|
|
1360
|
-
function isTypedArray(data) {
|
|
1361
|
-
return typeof data === "object" && data !== null && typeof data.byteLength === "number";
|
|
1362
|
-
}
|
|
1363
|
-
function defaultByteLength(data) {
|
|
1364
|
-
return isTypedArray(data) ? data.byteLength : 1024;
|
|
1365
|
-
}
|
|
1366
|
-
function noop() {
|
|
1367
|
-
}
|
|
1368
|
-
function abort() {
|
|
1369
|
-
this.destroy(new Error("Stream aborted."));
|
|
1370
|
-
}
|
|
1371
|
-
function isWritev(s) {
|
|
1372
|
-
return s._writev !== Writable.prototype._writev && s._writev !== Duplex.prototype._writev;
|
|
1373
|
-
}
|
|
1374
|
-
module.exports = {
|
|
1375
|
-
pipeline,
|
|
1376
|
-
pipelinePromise,
|
|
1377
|
-
isStream,
|
|
1378
|
-
isStreamx,
|
|
1379
|
-
isEnded,
|
|
1380
|
-
isFinished,
|
|
1381
|
-
isDisturbed,
|
|
1382
|
-
getStreamError,
|
|
1383
|
-
Stream,
|
|
1384
|
-
Writable,
|
|
1385
|
-
Readable,
|
|
1386
|
-
Duplex,
|
|
1387
|
-
Transform,
|
|
1388
|
-
// Export PassThrough for compatibility with Node.js core's stream module
|
|
1389
|
-
PassThrough
|
|
1390
|
-
};
|
|
1391
|
-
}
|
|
1392
|
-
});
|
|
1393
|
-
|
|
1394
|
-
// node_modules/@puppeteer/browsers/node_modules/tar-stream/headers.js
|
|
1395
|
-
var require_headers = __commonJS({
|
|
1396
|
-
"node_modules/@puppeteer/browsers/node_modules/tar-stream/headers.js"(exports) {
|
|
1397
|
-
"use strict";
|
|
1398
|
-
var b4a = require_b4a();
|
|
1399
|
-
var ZEROS = "0000000000000000000";
|
|
1400
|
-
var SEVENS = "7777777777777777777";
|
|
1401
|
-
var ZERO_OFFSET = "0".charCodeAt(0);
|
|
1402
|
-
var USTAR_MAGIC = b4a.from([117, 115, 116, 97, 114, 0]);
|
|
1403
|
-
var USTAR_VER = b4a.from([ZERO_OFFSET, ZERO_OFFSET]);
|
|
1404
|
-
var GNU_MAGIC = b4a.from([117, 115, 116, 97, 114, 32]);
|
|
1405
|
-
var GNU_VER = b4a.from([32, 0]);
|
|
1406
|
-
var MASK = 4095;
|
|
1407
|
-
var MAGIC_OFFSET = 257;
|
|
1408
|
-
var VERSION_OFFSET = 263;
|
|
1409
|
-
exports.decodeLongPath = function decodeLongPath(buf, encoding) {
|
|
1410
|
-
return decodeStr(buf, 0, buf.length, encoding);
|
|
1411
|
-
};
|
|
1412
|
-
exports.encodePax = function encodePax(opts) {
|
|
1413
|
-
let result = "";
|
|
1414
|
-
if (opts.name) result += addLength(" path=" + opts.name + "\n");
|
|
1415
|
-
if (opts.linkname) result += addLength(" linkpath=" + opts.linkname + "\n");
|
|
1416
|
-
const pax = opts.pax;
|
|
1417
|
-
if (pax) {
|
|
1418
|
-
for (const key in pax) {
|
|
1419
|
-
result += addLength(" " + key + "=" + pax[key] + "\n");
|
|
1420
|
-
}
|
|
1421
|
-
}
|
|
1422
|
-
return b4a.from(result);
|
|
1423
|
-
};
|
|
1424
|
-
exports.decodePax = function decodePax(buf) {
|
|
1425
|
-
const result = {};
|
|
1426
|
-
while (buf.length) {
|
|
1427
|
-
let i = 0;
|
|
1428
|
-
while (i < buf.length && buf[i] !== 32) i++;
|
|
1429
|
-
const len = parseInt(b4a.toString(buf.subarray(0, i)), 10);
|
|
1430
|
-
if (!len) return result;
|
|
1431
|
-
const b = b4a.toString(buf.subarray(i + 1, len - 1));
|
|
1432
|
-
const keyIndex = b.indexOf("=");
|
|
1433
|
-
if (keyIndex === -1) return result;
|
|
1434
|
-
result[b.slice(0, keyIndex)] = b.slice(keyIndex + 1);
|
|
1435
|
-
buf = buf.subarray(len);
|
|
1436
|
-
}
|
|
1437
|
-
return result;
|
|
1438
|
-
};
|
|
1439
|
-
exports.encode = function encode(opts) {
|
|
1440
|
-
const buf = b4a.alloc(512);
|
|
1441
|
-
let name = opts.name;
|
|
1442
|
-
let prefix = "";
|
|
1443
|
-
if (opts.typeflag === 5 && name[name.length - 1] !== "/") name += "/";
|
|
1444
|
-
if (b4a.byteLength(name) !== name.length) return null;
|
|
1445
|
-
while (b4a.byteLength(name) > 100) {
|
|
1446
|
-
const i = name.indexOf("/");
|
|
1447
|
-
if (i === -1) return null;
|
|
1448
|
-
prefix += prefix ? "/" + name.slice(0, i) : name.slice(0, i);
|
|
1449
|
-
name = name.slice(i + 1);
|
|
1450
|
-
}
|
|
1451
|
-
if (b4a.byteLength(name) > 100 || b4a.byteLength(prefix) > 155) return null;
|
|
1452
|
-
if (opts.linkname && b4a.byteLength(opts.linkname) > 100) return null;
|
|
1453
|
-
b4a.write(buf, name);
|
|
1454
|
-
b4a.write(buf, encodeOct(opts.mode & MASK, 6), 100);
|
|
1455
|
-
b4a.write(buf, encodeOct(opts.uid, 6), 108);
|
|
1456
|
-
b4a.write(buf, encodeOct(opts.gid, 6), 116);
|
|
1457
|
-
encodeSize(opts.size, buf, 124);
|
|
1458
|
-
b4a.write(buf, encodeOct(opts.mtime.getTime() / 1e3 | 0, 11), 136);
|
|
1459
|
-
buf[156] = ZERO_OFFSET + toTypeflag(opts.type);
|
|
1460
|
-
if (opts.linkname) b4a.write(buf, opts.linkname, 157);
|
|
1461
|
-
b4a.copy(USTAR_MAGIC, buf, MAGIC_OFFSET);
|
|
1462
|
-
b4a.copy(USTAR_VER, buf, VERSION_OFFSET);
|
|
1463
|
-
if (opts.uname) b4a.write(buf, opts.uname, 265);
|
|
1464
|
-
if (opts.gname) b4a.write(buf, opts.gname, 297);
|
|
1465
|
-
b4a.write(buf, encodeOct(opts.devmajor || 0, 6), 329);
|
|
1466
|
-
b4a.write(buf, encodeOct(opts.devminor || 0, 6), 337);
|
|
1467
|
-
if (prefix) b4a.write(buf, prefix, 345);
|
|
1468
|
-
b4a.write(buf, encodeOct(cksum(buf), 6), 148);
|
|
1469
|
-
return buf;
|
|
1470
|
-
};
|
|
1471
|
-
exports.decode = function decode(buf, filenameEncoding, allowUnknownFormat) {
|
|
1472
|
-
let typeflag = buf[156] === 0 ? 0 : buf[156] - ZERO_OFFSET;
|
|
1473
|
-
let name = decodeStr(buf, 0, 100, filenameEncoding);
|
|
1474
|
-
const mode = decodeOct(buf, 100, 8);
|
|
1475
|
-
const uid = decodeOct(buf, 108, 8);
|
|
1476
|
-
const gid = decodeOct(buf, 116, 8);
|
|
1477
|
-
const size = decodeOct(buf, 124, 12);
|
|
1478
|
-
const mtime = decodeOct(buf, 136, 12);
|
|
1479
|
-
const type = toType(typeflag);
|
|
1480
|
-
const linkname = buf[157] === 0 ? null : decodeStr(buf, 157, 100, filenameEncoding);
|
|
1481
|
-
const uname = decodeStr(buf, 265, 32);
|
|
1482
|
-
const gname = decodeStr(buf, 297, 32);
|
|
1483
|
-
const devmajor = decodeOct(buf, 329, 8);
|
|
1484
|
-
const devminor = decodeOct(buf, 337, 8);
|
|
1485
|
-
const c = cksum(buf);
|
|
1486
|
-
if (c === 8 * 32) return null;
|
|
1487
|
-
if (c !== decodeOct(buf, 148, 8)) throw new Error("Invalid tar header. Maybe the tar is corrupted or it needs to be gunzipped?");
|
|
1488
|
-
if (isUSTAR(buf)) {
|
|
1489
|
-
if (buf[345]) name = decodeStr(buf, 345, 155, filenameEncoding) + "/" + name;
|
|
1490
|
-
} else if (isGNU(buf)) {
|
|
1491
|
-
} else {
|
|
1492
|
-
if (!allowUnknownFormat) {
|
|
1493
|
-
throw new Error("Invalid tar header: unknown format.");
|
|
1494
|
-
}
|
|
1495
|
-
}
|
|
1496
|
-
if (typeflag === 0 && name && name[name.length - 1] === "/") typeflag = 5;
|
|
1497
|
-
return {
|
|
1498
|
-
name,
|
|
1499
|
-
mode,
|
|
1500
|
-
uid,
|
|
1501
|
-
gid,
|
|
1502
|
-
size,
|
|
1503
|
-
mtime: new Date(1e3 * mtime),
|
|
1504
|
-
type,
|
|
1505
|
-
linkname,
|
|
1506
|
-
uname,
|
|
1507
|
-
gname,
|
|
1508
|
-
devmajor,
|
|
1509
|
-
devminor,
|
|
1510
|
-
pax: null
|
|
1511
|
-
};
|
|
1512
|
-
};
|
|
1513
|
-
function isUSTAR(buf) {
|
|
1514
|
-
return b4a.equals(USTAR_MAGIC, buf.subarray(MAGIC_OFFSET, MAGIC_OFFSET + 6));
|
|
1515
|
-
}
|
|
1516
|
-
function isGNU(buf) {
|
|
1517
|
-
return b4a.equals(GNU_MAGIC, buf.subarray(MAGIC_OFFSET, MAGIC_OFFSET + 6)) && b4a.equals(GNU_VER, buf.subarray(VERSION_OFFSET, VERSION_OFFSET + 2));
|
|
1518
|
-
}
|
|
1519
|
-
function clamp(index, len, defaultValue) {
|
|
1520
|
-
if (typeof index !== "number") return defaultValue;
|
|
1521
|
-
index = ~~index;
|
|
1522
|
-
if (index >= len) return len;
|
|
1523
|
-
if (index >= 0) return index;
|
|
1524
|
-
index += len;
|
|
1525
|
-
if (index >= 0) return index;
|
|
1526
|
-
return 0;
|
|
1527
|
-
}
|
|
1528
|
-
function toType(flag) {
|
|
1529
|
-
switch (flag) {
|
|
1530
|
-
case 0:
|
|
1531
|
-
return "file";
|
|
1532
|
-
case 1:
|
|
1533
|
-
return "link";
|
|
1534
|
-
case 2:
|
|
1535
|
-
return "symlink";
|
|
1536
|
-
case 3:
|
|
1537
|
-
return "character-device";
|
|
1538
|
-
case 4:
|
|
1539
|
-
return "block-device";
|
|
1540
|
-
case 5:
|
|
1541
|
-
return "directory";
|
|
1542
|
-
case 6:
|
|
1543
|
-
return "fifo";
|
|
1544
|
-
case 7:
|
|
1545
|
-
return "contiguous-file";
|
|
1546
|
-
case 72:
|
|
1547
|
-
return "pax-header";
|
|
1548
|
-
case 55:
|
|
1549
|
-
return "pax-global-header";
|
|
1550
|
-
case 27:
|
|
1551
|
-
return "gnu-long-link-path";
|
|
1552
|
-
case 28:
|
|
1553
|
-
case 30:
|
|
1554
|
-
return "gnu-long-path";
|
|
1555
|
-
}
|
|
1556
|
-
return null;
|
|
1557
|
-
}
|
|
1558
|
-
function toTypeflag(flag) {
|
|
1559
|
-
switch (flag) {
|
|
1560
|
-
case "file":
|
|
1561
|
-
return 0;
|
|
1562
|
-
case "link":
|
|
1563
|
-
return 1;
|
|
1564
|
-
case "symlink":
|
|
1565
|
-
return 2;
|
|
1566
|
-
case "character-device":
|
|
1567
|
-
return 3;
|
|
1568
|
-
case "block-device":
|
|
1569
|
-
return 4;
|
|
1570
|
-
case "directory":
|
|
1571
|
-
return 5;
|
|
1572
|
-
case "fifo":
|
|
1573
|
-
return 6;
|
|
1574
|
-
case "contiguous-file":
|
|
1575
|
-
return 7;
|
|
1576
|
-
case "pax-header":
|
|
1577
|
-
return 72;
|
|
1578
|
-
}
|
|
1579
|
-
return 0;
|
|
1580
|
-
}
|
|
1581
|
-
function indexOf(block, num, offset, end) {
|
|
1582
|
-
for (; offset < end; offset++) {
|
|
1583
|
-
if (block[offset] === num) return offset;
|
|
1584
|
-
}
|
|
1585
|
-
return end;
|
|
1586
|
-
}
|
|
1587
|
-
function cksum(block) {
|
|
1588
|
-
let sum = 8 * 32;
|
|
1589
|
-
for (let i = 0; i < 148; i++) sum += block[i];
|
|
1590
|
-
for (let j = 156; j < 512; j++) sum += block[j];
|
|
1591
|
-
return sum;
|
|
1592
|
-
}
|
|
1593
|
-
function encodeOct(val, n) {
|
|
1594
|
-
val = val.toString(8);
|
|
1595
|
-
if (val.length > n) return SEVENS.slice(0, n) + " ";
|
|
1596
|
-
return ZEROS.slice(0, n - val.length) + val + " ";
|
|
1597
|
-
}
|
|
1598
|
-
function encodeSizeBin(num, buf, off) {
|
|
1599
|
-
buf[off] = 128;
|
|
1600
|
-
for (let i = 11; i > 0; i--) {
|
|
1601
|
-
buf[off + i] = num & 255;
|
|
1602
|
-
num = Math.floor(num / 256);
|
|
1603
|
-
}
|
|
1604
|
-
}
|
|
1605
|
-
function encodeSize(num, buf, off) {
|
|
1606
|
-
if (num.toString(8).length > 11) {
|
|
1607
|
-
encodeSizeBin(num, buf, off);
|
|
1608
|
-
} else {
|
|
1609
|
-
b4a.write(buf, encodeOct(num, 11), off);
|
|
1610
|
-
}
|
|
1611
|
-
}
|
|
1612
|
-
function parse256(buf) {
|
|
1613
|
-
let positive;
|
|
1614
|
-
if (buf[0] === 128) positive = true;
|
|
1615
|
-
else if (buf[0] === 255) positive = false;
|
|
1616
|
-
else return null;
|
|
1617
|
-
const tuple = [];
|
|
1618
|
-
let i;
|
|
1619
|
-
for (i = buf.length - 1; i > 0; i--) {
|
|
1620
|
-
const byte = buf[i];
|
|
1621
|
-
if (positive) tuple.push(byte);
|
|
1622
|
-
else tuple.push(255 - byte);
|
|
1623
|
-
}
|
|
1624
|
-
let sum = 0;
|
|
1625
|
-
const l = tuple.length;
|
|
1626
|
-
for (i = 0; i < l; i++) {
|
|
1627
|
-
sum += tuple[i] * Math.pow(256, i);
|
|
1628
|
-
}
|
|
1629
|
-
return positive ? sum : -1 * sum;
|
|
1630
|
-
}
|
|
1631
|
-
function decodeOct(val, offset, length) {
|
|
1632
|
-
val = val.subarray(offset, offset + length);
|
|
1633
|
-
offset = 0;
|
|
1634
|
-
if (val[offset] & 128) {
|
|
1635
|
-
return parse256(val);
|
|
1636
|
-
} else {
|
|
1637
|
-
while (offset < val.length && val[offset] === 32) offset++;
|
|
1638
|
-
const end = clamp(indexOf(val, 32, offset, val.length), val.length, val.length);
|
|
1639
|
-
while (offset < end && val[offset] === 0) offset++;
|
|
1640
|
-
if (end === offset) return 0;
|
|
1641
|
-
return parseInt(b4a.toString(val.subarray(offset, end)), 8);
|
|
1642
|
-
}
|
|
1643
|
-
}
|
|
1644
|
-
function decodeStr(val, offset, length, encoding) {
|
|
1645
|
-
return b4a.toString(val.subarray(offset, indexOf(val, 0, offset, offset + length)), encoding);
|
|
1646
|
-
}
|
|
1647
|
-
function addLength(str) {
|
|
1648
|
-
const len = b4a.byteLength(str);
|
|
1649
|
-
let digits = Math.floor(Math.log(len) / Math.log(10)) + 1;
|
|
1650
|
-
if (len + digits >= Math.pow(10, digits)) digits++;
|
|
1651
|
-
return len + digits + str;
|
|
1652
|
-
}
|
|
1653
|
-
}
|
|
1654
|
-
});
|
|
1655
|
-
|
|
1656
|
-
// node_modules/@puppeteer/browsers/node_modules/tar-stream/extract.js
|
|
1657
|
-
var require_extract = __commonJS({
|
|
1658
|
-
"node_modules/@puppeteer/browsers/node_modules/tar-stream/extract.js"(exports, module) {
|
|
1659
|
-
"use strict";
|
|
1660
|
-
var { Writable, Readable, getStreamError } = require_streamx();
|
|
1661
|
-
var FIFO = require_fast_fifo();
|
|
1662
|
-
var b4a = require_b4a();
|
|
1663
|
-
var headers = require_headers();
|
|
1664
|
-
var EMPTY = b4a.alloc(0);
|
|
1665
|
-
var BufferList = class {
|
|
1666
|
-
constructor() {
|
|
1667
|
-
this.buffered = 0;
|
|
1668
|
-
this.shifted = 0;
|
|
1669
|
-
this.queue = new FIFO();
|
|
1670
|
-
this._offset = 0;
|
|
1671
|
-
}
|
|
1672
|
-
push(buffer) {
|
|
1673
|
-
this.buffered += buffer.byteLength;
|
|
1674
|
-
this.queue.push(buffer);
|
|
1675
|
-
}
|
|
1676
|
-
shiftFirst(size) {
|
|
1677
|
-
return this._buffered === 0 ? null : this._next(size);
|
|
1678
|
-
}
|
|
1679
|
-
shift(size) {
|
|
1680
|
-
if (size > this.buffered) return null;
|
|
1681
|
-
if (size === 0) return EMPTY;
|
|
1682
|
-
let chunk = this._next(size);
|
|
1683
|
-
if (size === chunk.byteLength) return chunk;
|
|
1684
|
-
const chunks = [chunk];
|
|
1685
|
-
while ((size -= chunk.byteLength) > 0) {
|
|
1686
|
-
chunk = this._next(size);
|
|
1687
|
-
chunks.push(chunk);
|
|
1688
|
-
}
|
|
1689
|
-
return b4a.concat(chunks);
|
|
1690
|
-
}
|
|
1691
|
-
_next(size) {
|
|
1692
|
-
const buf = this.queue.peek();
|
|
1693
|
-
const rem = buf.byteLength - this._offset;
|
|
1694
|
-
if (size >= rem) {
|
|
1695
|
-
const sub = this._offset ? buf.subarray(this._offset, buf.byteLength) : buf;
|
|
1696
|
-
this.queue.shift();
|
|
1697
|
-
this._offset = 0;
|
|
1698
|
-
this.buffered -= rem;
|
|
1699
|
-
this.shifted += rem;
|
|
1700
|
-
return sub;
|
|
1701
|
-
}
|
|
1702
|
-
this.buffered -= size;
|
|
1703
|
-
this.shifted += size;
|
|
1704
|
-
return buf.subarray(this._offset, this._offset += size);
|
|
1705
|
-
}
|
|
1706
|
-
};
|
|
1707
|
-
var Source = class extends Readable {
|
|
1708
|
-
constructor(self, header, offset) {
|
|
1709
|
-
super();
|
|
1710
|
-
this.header = header;
|
|
1711
|
-
this.offset = offset;
|
|
1712
|
-
this._parent = self;
|
|
1713
|
-
}
|
|
1714
|
-
_read(cb) {
|
|
1715
|
-
if (this.header.size === 0) {
|
|
1716
|
-
this.push(null);
|
|
1717
|
-
}
|
|
1718
|
-
if (this._parent._stream === this) {
|
|
1719
|
-
this._parent._update();
|
|
1720
|
-
}
|
|
1721
|
-
cb(null);
|
|
1722
|
-
}
|
|
1723
|
-
_predestroy() {
|
|
1724
|
-
this._parent.destroy(getStreamError(this));
|
|
1725
|
-
}
|
|
1726
|
-
_detach() {
|
|
1727
|
-
if (this._parent._stream === this) {
|
|
1728
|
-
this._parent._stream = null;
|
|
1729
|
-
this._parent._missing = overflow(this.header.size);
|
|
1730
|
-
this._parent._update();
|
|
1731
|
-
}
|
|
1732
|
-
}
|
|
1733
|
-
_destroy(cb) {
|
|
1734
|
-
this._detach();
|
|
1735
|
-
cb(null);
|
|
1736
|
-
}
|
|
1737
|
-
};
|
|
1738
|
-
var Extract = class extends Writable {
|
|
1739
|
-
constructor(opts) {
|
|
1740
|
-
super(opts);
|
|
1741
|
-
if (!opts) opts = {};
|
|
1742
|
-
this._buffer = new BufferList();
|
|
1743
|
-
this._offset = 0;
|
|
1744
|
-
this._header = null;
|
|
1745
|
-
this._stream = null;
|
|
1746
|
-
this._missing = 0;
|
|
1747
|
-
this._longHeader = false;
|
|
1748
|
-
this._callback = noop;
|
|
1749
|
-
this._locked = false;
|
|
1750
|
-
this._finished = false;
|
|
1751
|
-
this._pax = null;
|
|
1752
|
-
this._paxGlobal = null;
|
|
1753
|
-
this._gnuLongPath = null;
|
|
1754
|
-
this._gnuLongLinkPath = null;
|
|
1755
|
-
this._filenameEncoding = opts.filenameEncoding || "utf-8";
|
|
1756
|
-
this._allowUnknownFormat = !!opts.allowUnknownFormat;
|
|
1757
|
-
this._unlockBound = this._unlock.bind(this);
|
|
1758
|
-
}
|
|
1759
|
-
_unlock(err) {
|
|
1760
|
-
this._locked = false;
|
|
1761
|
-
if (err) {
|
|
1762
|
-
this.destroy(err);
|
|
1763
|
-
this._continueWrite(err);
|
|
1764
|
-
return;
|
|
1765
|
-
}
|
|
1766
|
-
this._update();
|
|
1767
|
-
}
|
|
1768
|
-
_consumeHeader() {
|
|
1769
|
-
if (this._locked) return false;
|
|
1770
|
-
this._offset = this._buffer.shifted;
|
|
1771
|
-
try {
|
|
1772
|
-
this._header = headers.decode(this._buffer.shift(512), this._filenameEncoding, this._allowUnknownFormat);
|
|
1773
|
-
} catch (err) {
|
|
1774
|
-
this._continueWrite(err);
|
|
1775
|
-
return false;
|
|
1776
|
-
}
|
|
1777
|
-
if (!this._header) return true;
|
|
1778
|
-
switch (this._header.type) {
|
|
1779
|
-
case "gnu-long-path":
|
|
1780
|
-
case "gnu-long-link-path":
|
|
1781
|
-
case "pax-global-header":
|
|
1782
|
-
case "pax-header":
|
|
1783
|
-
this._longHeader = true;
|
|
1784
|
-
this._missing = this._header.size;
|
|
1785
|
-
return true;
|
|
1786
|
-
}
|
|
1787
|
-
this._locked = true;
|
|
1788
|
-
this._applyLongHeaders();
|
|
1789
|
-
if (this._header.size === 0 || this._header.type === "directory") {
|
|
1790
|
-
this.emit("entry", this._header, this._createStream(), this._unlockBound);
|
|
1791
|
-
return true;
|
|
1792
|
-
}
|
|
1793
|
-
this._stream = this._createStream();
|
|
1794
|
-
this._missing = this._header.size;
|
|
1795
|
-
this.emit("entry", this._header, this._stream, this._unlockBound);
|
|
1796
|
-
return true;
|
|
1797
|
-
}
|
|
1798
|
-
_applyLongHeaders() {
|
|
1799
|
-
if (this._gnuLongPath) {
|
|
1800
|
-
this._header.name = this._gnuLongPath;
|
|
1801
|
-
this._gnuLongPath = null;
|
|
1802
|
-
}
|
|
1803
|
-
if (this._gnuLongLinkPath) {
|
|
1804
|
-
this._header.linkname = this._gnuLongLinkPath;
|
|
1805
|
-
this._gnuLongLinkPath = null;
|
|
1806
|
-
}
|
|
1807
|
-
if (this._pax) {
|
|
1808
|
-
if (this._pax.path) this._header.name = this._pax.path;
|
|
1809
|
-
if (this._pax.linkpath) this._header.linkname = this._pax.linkpath;
|
|
1810
|
-
if (this._pax.size) this._header.size = parseInt(this._pax.size, 10);
|
|
1811
|
-
this._header.pax = this._pax;
|
|
1812
|
-
this._pax = null;
|
|
1813
|
-
}
|
|
1814
|
-
}
|
|
1815
|
-
_decodeLongHeader(buf) {
|
|
1816
|
-
switch (this._header.type) {
|
|
1817
|
-
case "gnu-long-path":
|
|
1818
|
-
this._gnuLongPath = headers.decodeLongPath(buf, this._filenameEncoding);
|
|
1819
|
-
break;
|
|
1820
|
-
case "gnu-long-link-path":
|
|
1821
|
-
this._gnuLongLinkPath = headers.decodeLongPath(buf, this._filenameEncoding);
|
|
1822
|
-
break;
|
|
1823
|
-
case "pax-global-header":
|
|
1824
|
-
this._paxGlobal = headers.decodePax(buf);
|
|
1825
|
-
break;
|
|
1826
|
-
case "pax-header":
|
|
1827
|
-
this._pax = this._paxGlobal === null ? headers.decodePax(buf) : Object.assign({}, this._paxGlobal, headers.decodePax(buf));
|
|
1828
|
-
break;
|
|
1829
|
-
}
|
|
1830
|
-
}
|
|
1831
|
-
_consumeLongHeader() {
|
|
1832
|
-
this._longHeader = false;
|
|
1833
|
-
this._missing = overflow(this._header.size);
|
|
1834
|
-
const buf = this._buffer.shift(this._header.size);
|
|
1835
|
-
try {
|
|
1836
|
-
this._decodeLongHeader(buf);
|
|
1837
|
-
} catch (err) {
|
|
1838
|
-
this._continueWrite(err);
|
|
1839
|
-
return false;
|
|
1840
|
-
}
|
|
1841
|
-
return true;
|
|
1842
|
-
}
|
|
1843
|
-
_consumeStream() {
|
|
1844
|
-
const buf = this._buffer.shiftFirst(this._missing);
|
|
1845
|
-
if (buf === null) return false;
|
|
1846
|
-
this._missing -= buf.byteLength;
|
|
1847
|
-
const drained = this._stream.push(buf);
|
|
1848
|
-
if (this._missing === 0) {
|
|
1849
|
-
this._stream.push(null);
|
|
1850
|
-
if (drained) this._stream._detach();
|
|
1851
|
-
return drained && this._locked === false;
|
|
1852
|
-
}
|
|
1853
|
-
return drained;
|
|
1854
|
-
}
|
|
1855
|
-
_createStream() {
|
|
1856
|
-
return new Source(this, this._header, this._offset);
|
|
1857
|
-
}
|
|
1858
|
-
_update() {
|
|
1859
|
-
while (this._buffer.buffered > 0 && !this.destroying) {
|
|
1860
|
-
if (this._missing > 0) {
|
|
1861
|
-
if (this._stream !== null) {
|
|
1862
|
-
if (this._consumeStream() === false) return;
|
|
1863
|
-
continue;
|
|
1864
|
-
}
|
|
1865
|
-
if (this._longHeader === true) {
|
|
1866
|
-
if (this._missing > this._buffer.buffered) break;
|
|
1867
|
-
if (this._consumeLongHeader() === false) return false;
|
|
1868
|
-
continue;
|
|
1869
|
-
}
|
|
1870
|
-
const ignore = this._buffer.shiftFirst(this._missing);
|
|
1871
|
-
if (ignore !== null) this._missing -= ignore.byteLength;
|
|
1872
|
-
continue;
|
|
1873
|
-
}
|
|
1874
|
-
if (this._buffer.buffered < 512) break;
|
|
1875
|
-
if (this._stream !== null || this._consumeHeader() === false) return;
|
|
1876
|
-
}
|
|
1877
|
-
this._continueWrite(null);
|
|
1878
|
-
}
|
|
1879
|
-
_continueWrite(err) {
|
|
1880
|
-
const cb = this._callback;
|
|
1881
|
-
this._callback = noop;
|
|
1882
|
-
cb(err);
|
|
1883
|
-
}
|
|
1884
|
-
_write(data, cb) {
|
|
1885
|
-
this._callback = cb;
|
|
1886
|
-
this._buffer.push(data);
|
|
1887
|
-
this._update();
|
|
1888
|
-
}
|
|
1889
|
-
_final(cb) {
|
|
1890
|
-
this._finished = this._missing === 0 && this._buffer.buffered === 0;
|
|
1891
|
-
cb(this._finished ? null : new Error("Unexpected end of data"));
|
|
1892
|
-
}
|
|
1893
|
-
_predestroy() {
|
|
1894
|
-
this._continueWrite(null);
|
|
1895
|
-
}
|
|
1896
|
-
_destroy(cb) {
|
|
1897
|
-
if (this._stream) this._stream.destroy(getStreamError(this));
|
|
1898
|
-
cb(null);
|
|
1899
|
-
}
|
|
1900
|
-
[Symbol.asyncIterator]() {
|
|
1901
|
-
let error = null;
|
|
1902
|
-
let promiseResolve = null;
|
|
1903
|
-
let promiseReject = null;
|
|
1904
|
-
let entryStream = null;
|
|
1905
|
-
let entryCallback = null;
|
|
1906
|
-
const extract = this;
|
|
1907
|
-
this.on("entry", onentry);
|
|
1908
|
-
this.on("error", (err) => {
|
|
1909
|
-
error = err;
|
|
1910
|
-
});
|
|
1911
|
-
this.on("close", onclose);
|
|
1912
|
-
return {
|
|
1913
|
-
[Symbol.asyncIterator]() {
|
|
1914
|
-
return this;
|
|
1915
|
-
},
|
|
1916
|
-
next() {
|
|
1917
|
-
return new Promise(onnext);
|
|
1918
|
-
},
|
|
1919
|
-
return() {
|
|
1920
|
-
return destroy(null);
|
|
1921
|
-
},
|
|
1922
|
-
throw(err) {
|
|
1923
|
-
return destroy(err);
|
|
1924
|
-
}
|
|
1925
|
-
};
|
|
1926
|
-
function consumeCallback(err) {
|
|
1927
|
-
if (!entryCallback) return;
|
|
1928
|
-
const cb = entryCallback;
|
|
1929
|
-
entryCallback = null;
|
|
1930
|
-
cb(err);
|
|
1931
|
-
}
|
|
1932
|
-
function onnext(resolve, reject) {
|
|
1933
|
-
if (error) {
|
|
1934
|
-
return reject(error);
|
|
1935
|
-
}
|
|
1936
|
-
if (entryStream) {
|
|
1937
|
-
resolve({ value: entryStream, done: false });
|
|
1938
|
-
entryStream = null;
|
|
1939
|
-
return;
|
|
1940
|
-
}
|
|
1941
|
-
promiseResolve = resolve;
|
|
1942
|
-
promiseReject = reject;
|
|
1943
|
-
consumeCallback(null);
|
|
1944
|
-
if (extract._finished && promiseResolve) {
|
|
1945
|
-
promiseResolve({ value: void 0, done: true });
|
|
1946
|
-
promiseResolve = promiseReject = null;
|
|
1947
|
-
}
|
|
1948
|
-
}
|
|
1949
|
-
function onentry(header, stream, callback) {
|
|
1950
|
-
entryCallback = callback;
|
|
1951
|
-
stream.on("error", noop);
|
|
1952
|
-
if (promiseResolve) {
|
|
1953
|
-
promiseResolve({ value: stream, done: false });
|
|
1954
|
-
promiseResolve = promiseReject = null;
|
|
1955
|
-
} else {
|
|
1956
|
-
entryStream = stream;
|
|
1957
|
-
}
|
|
1958
|
-
}
|
|
1959
|
-
function onclose() {
|
|
1960
|
-
consumeCallback(error);
|
|
1961
|
-
if (!promiseResolve) return;
|
|
1962
|
-
if (error) promiseReject(error);
|
|
1963
|
-
else promiseResolve({ value: void 0, done: true });
|
|
1964
|
-
promiseResolve = promiseReject = null;
|
|
1965
|
-
}
|
|
1966
|
-
function destroy(err) {
|
|
1967
|
-
extract.destroy(err);
|
|
1968
|
-
consumeCallback(err);
|
|
1969
|
-
return new Promise((resolve, reject) => {
|
|
1970
|
-
if (extract.destroyed) return resolve({ value: void 0, done: true });
|
|
1971
|
-
extract.once("close", function() {
|
|
1972
|
-
if (err) reject(err);
|
|
1973
|
-
else resolve({ value: void 0, done: true });
|
|
1974
|
-
});
|
|
1975
|
-
});
|
|
1976
|
-
}
|
|
1977
|
-
}
|
|
1978
|
-
};
|
|
1979
|
-
module.exports = function extract(opts) {
|
|
1980
|
-
return new Extract(opts);
|
|
1981
|
-
};
|
|
1982
|
-
function noop() {
|
|
1983
|
-
}
|
|
1984
|
-
function overflow(size) {
|
|
1985
|
-
size &= 511;
|
|
1986
|
-
return size && 512 - size;
|
|
1987
|
-
}
|
|
1988
|
-
}
|
|
1989
|
-
});
|
|
1990
|
-
|
|
1991
|
-
// node_modules/@puppeteer/browsers/node_modules/tar-stream/constants.js
|
|
1992
|
-
var require_constants = __commonJS({
|
|
1993
|
-
"node_modules/@puppeteer/browsers/node_modules/tar-stream/constants.js"(exports, module) {
|
|
1994
|
-
"use strict";
|
|
1995
|
-
var constants = {
|
|
1996
|
-
// just for envs without fs
|
|
1997
|
-
S_IFMT: 61440,
|
|
1998
|
-
S_IFDIR: 16384,
|
|
1999
|
-
S_IFCHR: 8192,
|
|
2000
|
-
S_IFBLK: 24576,
|
|
2001
|
-
S_IFIFO: 4096,
|
|
2002
|
-
S_IFLNK: 40960
|
|
2003
|
-
};
|
|
2004
|
-
try {
|
|
2005
|
-
module.exports = __require("fs").constants || constants;
|
|
2006
|
-
} catch {
|
|
2007
|
-
module.exports = constants;
|
|
2008
|
-
}
|
|
2009
|
-
}
|
|
2010
|
-
});
|
|
2011
|
-
|
|
2012
|
-
// node_modules/@puppeteer/browsers/node_modules/tar-stream/pack.js
|
|
2013
|
-
var require_pack = __commonJS({
|
|
2014
|
-
"node_modules/@puppeteer/browsers/node_modules/tar-stream/pack.js"(exports, module) {
|
|
2015
|
-
"use strict";
|
|
2016
|
-
var { Readable, Writable, getStreamError } = require_streamx();
|
|
2017
|
-
var b4a = require_b4a();
|
|
2018
|
-
var constants = require_constants();
|
|
2019
|
-
var headers = require_headers();
|
|
2020
|
-
var DMODE = 493;
|
|
2021
|
-
var FMODE = 420;
|
|
2022
|
-
var END_OF_TAR = b4a.alloc(1024);
|
|
2023
|
-
var Sink = class extends Writable {
|
|
2024
|
-
constructor(pack, header, callback) {
|
|
2025
|
-
super({ mapWritable, eagerOpen: true });
|
|
2026
|
-
this.written = 0;
|
|
2027
|
-
this.header = header;
|
|
2028
|
-
this._callback = callback;
|
|
2029
|
-
this._linkname = null;
|
|
2030
|
-
this._isLinkname = header.type === "symlink" && !header.linkname;
|
|
2031
|
-
this._isVoid = header.type !== "file" && header.type !== "contiguous-file";
|
|
2032
|
-
this._finished = false;
|
|
2033
|
-
this._pack = pack;
|
|
2034
|
-
this._openCallback = null;
|
|
2035
|
-
if (this._pack._stream === null) this._pack._stream = this;
|
|
2036
|
-
else this._pack._pending.push(this);
|
|
2037
|
-
}
|
|
2038
|
-
_open(cb) {
|
|
2039
|
-
this._openCallback = cb;
|
|
2040
|
-
if (this._pack._stream === this) this._continueOpen();
|
|
2041
|
-
}
|
|
2042
|
-
_continuePack(err) {
|
|
2043
|
-
if (this._callback === null) return;
|
|
2044
|
-
const callback = this._callback;
|
|
2045
|
-
this._callback = null;
|
|
2046
|
-
callback(err);
|
|
2047
|
-
}
|
|
2048
|
-
_continueOpen() {
|
|
2049
|
-
if (this._pack._stream === null) this._pack._stream = this;
|
|
2050
|
-
const cb = this._openCallback;
|
|
2051
|
-
this._openCallback = null;
|
|
2052
|
-
if (cb === null) return;
|
|
2053
|
-
if (this._pack.destroying) return cb(new Error("pack stream destroyed"));
|
|
2054
|
-
if (this._pack._finalized) return cb(new Error("pack stream is already finalized"));
|
|
2055
|
-
this._pack._stream = this;
|
|
2056
|
-
if (!this._isLinkname) {
|
|
2057
|
-
this._pack._encode(this.header);
|
|
2058
|
-
}
|
|
2059
|
-
if (this._isVoid) {
|
|
2060
|
-
this._finish();
|
|
2061
|
-
this._continuePack(null);
|
|
2062
|
-
}
|
|
2063
|
-
cb(null);
|
|
2064
|
-
}
|
|
2065
|
-
_write(data, cb) {
|
|
2066
|
-
if (this._isLinkname) {
|
|
2067
|
-
this._linkname = this._linkname ? b4a.concat([this._linkname, data]) : data;
|
|
2068
|
-
return cb(null);
|
|
2069
|
-
}
|
|
2070
|
-
if (this._isVoid) {
|
|
2071
|
-
if (data.byteLength > 0) {
|
|
2072
|
-
return cb(new Error("No body allowed for this entry"));
|
|
2073
|
-
}
|
|
2074
|
-
return cb();
|
|
2075
|
-
}
|
|
2076
|
-
this.written += data.byteLength;
|
|
2077
|
-
if (this._pack.push(data)) return cb();
|
|
2078
|
-
this._pack._drain = cb;
|
|
2079
|
-
}
|
|
2080
|
-
_finish() {
|
|
2081
|
-
if (this._finished) return;
|
|
2082
|
-
this._finished = true;
|
|
2083
|
-
if (this._isLinkname) {
|
|
2084
|
-
this.header.linkname = this._linkname ? b4a.toString(this._linkname, "utf-8") : "";
|
|
2085
|
-
this._pack._encode(this.header);
|
|
2086
|
-
}
|
|
2087
|
-
overflow(this._pack, this.header.size);
|
|
2088
|
-
this._pack._done(this);
|
|
2089
|
-
}
|
|
2090
|
-
_final(cb) {
|
|
2091
|
-
if (this.written !== this.header.size) {
|
|
2092
|
-
return cb(new Error("Size mismatch"));
|
|
2093
|
-
}
|
|
2094
|
-
this._finish();
|
|
2095
|
-
cb(null);
|
|
2096
|
-
}
|
|
2097
|
-
_getError() {
|
|
2098
|
-
return getStreamError(this) || new Error("tar entry destroyed");
|
|
2099
|
-
}
|
|
2100
|
-
_predestroy() {
|
|
2101
|
-
this._pack.destroy(this._getError());
|
|
2102
|
-
}
|
|
2103
|
-
_destroy(cb) {
|
|
2104
|
-
this._pack._done(this);
|
|
2105
|
-
this._continuePack(this._finished ? null : this._getError());
|
|
2106
|
-
cb();
|
|
2107
|
-
}
|
|
2108
|
-
};
|
|
2109
|
-
var Pack = class extends Readable {
|
|
2110
|
-
constructor(opts) {
|
|
2111
|
-
super(opts);
|
|
2112
|
-
this._drain = noop;
|
|
2113
|
-
this._finalized = false;
|
|
2114
|
-
this._finalizing = false;
|
|
2115
|
-
this._pending = [];
|
|
2116
|
-
this._stream = null;
|
|
2117
|
-
}
|
|
2118
|
-
entry(header, buffer, callback) {
|
|
2119
|
-
if (this._finalized || this.destroying) throw new Error("already finalized or destroyed");
|
|
2120
|
-
if (typeof buffer === "function") {
|
|
2121
|
-
callback = buffer;
|
|
2122
|
-
buffer = null;
|
|
2123
|
-
}
|
|
2124
|
-
if (!callback) callback = noop;
|
|
2125
|
-
if (!header.size || header.type === "symlink") header.size = 0;
|
|
2126
|
-
if (!header.type) header.type = modeToType(header.mode);
|
|
2127
|
-
if (!header.mode) header.mode = header.type === "directory" ? DMODE : FMODE;
|
|
2128
|
-
if (!header.uid) header.uid = 0;
|
|
2129
|
-
if (!header.gid) header.gid = 0;
|
|
2130
|
-
if (!header.mtime) header.mtime = /* @__PURE__ */ new Date();
|
|
2131
|
-
if (typeof buffer === "string") buffer = b4a.from(buffer);
|
|
2132
|
-
const sink = new Sink(this, header, callback);
|
|
2133
|
-
if (b4a.isBuffer(buffer)) {
|
|
2134
|
-
header.size = buffer.byteLength;
|
|
2135
|
-
sink.write(buffer);
|
|
2136
|
-
sink.end();
|
|
2137
|
-
return sink;
|
|
2138
|
-
}
|
|
2139
|
-
if (sink._isVoid) {
|
|
2140
|
-
return sink;
|
|
2141
|
-
}
|
|
2142
|
-
return sink;
|
|
2143
|
-
}
|
|
2144
|
-
finalize() {
|
|
2145
|
-
if (this._stream || this._pending.length > 0) {
|
|
2146
|
-
this._finalizing = true;
|
|
2147
|
-
return;
|
|
2148
|
-
}
|
|
2149
|
-
if (this._finalized) return;
|
|
2150
|
-
this._finalized = true;
|
|
2151
|
-
this.push(END_OF_TAR);
|
|
2152
|
-
this.push(null);
|
|
2153
|
-
}
|
|
2154
|
-
_done(stream) {
|
|
2155
|
-
if (stream !== this._stream) return;
|
|
2156
|
-
this._stream = null;
|
|
2157
|
-
if (this._finalizing) this.finalize();
|
|
2158
|
-
if (this._pending.length) this._pending.shift()._continueOpen();
|
|
2159
|
-
}
|
|
2160
|
-
_encode(header) {
|
|
2161
|
-
if (!header.pax) {
|
|
2162
|
-
const buf = headers.encode(header);
|
|
2163
|
-
if (buf) {
|
|
2164
|
-
this.push(buf);
|
|
2165
|
-
return;
|
|
2166
|
-
}
|
|
2167
|
-
}
|
|
2168
|
-
this._encodePax(header);
|
|
2169
|
-
}
|
|
2170
|
-
_encodePax(header) {
|
|
2171
|
-
const paxHeader = headers.encodePax({
|
|
2172
|
-
name: header.name,
|
|
2173
|
-
linkname: header.linkname,
|
|
2174
|
-
pax: header.pax
|
|
2175
|
-
});
|
|
2176
|
-
const newHeader = {
|
|
2177
|
-
name: "PaxHeader",
|
|
2178
|
-
mode: header.mode,
|
|
2179
|
-
uid: header.uid,
|
|
2180
|
-
gid: header.gid,
|
|
2181
|
-
size: paxHeader.byteLength,
|
|
2182
|
-
mtime: header.mtime,
|
|
2183
|
-
type: "pax-header",
|
|
2184
|
-
linkname: header.linkname && "PaxHeader",
|
|
2185
|
-
uname: header.uname,
|
|
2186
|
-
gname: header.gname,
|
|
2187
|
-
devmajor: header.devmajor,
|
|
2188
|
-
devminor: header.devminor
|
|
2189
|
-
};
|
|
2190
|
-
this.push(headers.encode(newHeader));
|
|
2191
|
-
this.push(paxHeader);
|
|
2192
|
-
overflow(this, paxHeader.byteLength);
|
|
2193
|
-
newHeader.size = header.size;
|
|
2194
|
-
newHeader.type = header.type;
|
|
2195
|
-
this.push(headers.encode(newHeader));
|
|
2196
|
-
}
|
|
2197
|
-
_doDrain() {
|
|
2198
|
-
const drain = this._drain;
|
|
2199
|
-
this._drain = noop;
|
|
2200
|
-
drain();
|
|
2201
|
-
}
|
|
2202
|
-
_predestroy() {
|
|
2203
|
-
const err = getStreamError(this);
|
|
2204
|
-
if (this._stream) this._stream.destroy(err);
|
|
2205
|
-
while (this._pending.length) {
|
|
2206
|
-
const stream = this._pending.shift();
|
|
2207
|
-
stream.destroy(err);
|
|
2208
|
-
stream._continueOpen();
|
|
2209
|
-
}
|
|
2210
|
-
this._doDrain();
|
|
2211
|
-
}
|
|
2212
|
-
_read(cb) {
|
|
2213
|
-
this._doDrain();
|
|
2214
|
-
cb();
|
|
2215
|
-
}
|
|
2216
|
-
};
|
|
2217
|
-
module.exports = function pack(opts) {
|
|
2218
|
-
return new Pack(opts);
|
|
2219
|
-
};
|
|
2220
|
-
function modeToType(mode) {
|
|
2221
|
-
switch (mode & constants.S_IFMT) {
|
|
2222
|
-
case constants.S_IFBLK:
|
|
2223
|
-
return "block-device";
|
|
2224
|
-
case constants.S_IFCHR:
|
|
2225
|
-
return "character-device";
|
|
2226
|
-
case constants.S_IFDIR:
|
|
2227
|
-
return "directory";
|
|
2228
|
-
case constants.S_IFIFO:
|
|
2229
|
-
return "fifo";
|
|
2230
|
-
case constants.S_IFLNK:
|
|
2231
|
-
return "symlink";
|
|
2232
|
-
}
|
|
2233
|
-
return "file";
|
|
2234
|
-
}
|
|
2235
|
-
function noop() {
|
|
2236
|
-
}
|
|
2237
|
-
function overflow(self, size) {
|
|
2238
|
-
size &= 511;
|
|
2239
|
-
if (size) self.push(END_OF_TAR.subarray(0, 512 - size));
|
|
2240
|
-
}
|
|
2241
|
-
function mapWritable(buf) {
|
|
2242
|
-
return b4a.isBuffer(buf) ? buf : b4a.from(buf);
|
|
2243
|
-
}
|
|
2244
|
-
}
|
|
2245
|
-
});
|
|
2246
|
-
|
|
2247
|
-
// node_modules/@puppeteer/browsers/node_modules/tar-stream/index.js
|
|
2248
|
-
var require_tar_stream = __commonJS({
|
|
2249
|
-
"node_modules/@puppeteer/browsers/node_modules/tar-stream/index.js"(exports) {
|
|
2250
|
-
"use strict";
|
|
2251
|
-
exports.extract = require_extract();
|
|
2252
|
-
exports.pack = require_pack();
|
|
2253
|
-
}
|
|
2254
|
-
});
|
|
2255
|
-
|
|
2256
|
-
// node_modules/@puppeteer/browsers/node_modules/tar-fs/index.js
|
|
2257
|
-
var require_tar_fs = __commonJS({
|
|
2258
|
-
"node_modules/@puppeteer/browsers/node_modules/tar-fs/index.js"(exports) {
|
|
2259
|
-
var tar = require_tar_stream();
|
|
2260
|
-
var pump = require_pump();
|
|
2261
|
-
var fs = __require("fs");
|
|
2262
|
-
var path = __require("path");
|
|
2263
|
-
var win32 = (global.Bare ? global.Bare.platform : process.platform) === "win32";
|
|
2264
|
-
exports.pack = function pack(cwd, opts) {
|
|
2265
|
-
if (!cwd) cwd = ".";
|
|
2266
|
-
if (!opts) opts = {};
|
|
2267
|
-
const xfs = opts.fs || fs;
|
|
2268
|
-
const ignore = opts.ignore || opts.filter || noop;
|
|
2269
|
-
const mapStream = opts.mapStream || echo;
|
|
2270
|
-
const statNext = statAll(xfs, opts.dereference ? xfs.stat : xfs.lstat, cwd, ignore, opts.entries, opts.sort);
|
|
2271
|
-
const strict = opts.strict !== false;
|
|
2272
|
-
const umask = typeof opts.umask === "number" ? ~opts.umask : ~processUmask();
|
|
2273
|
-
const pack2 = opts.pack || tar.pack();
|
|
2274
|
-
const finish = opts.finish || noop;
|
|
2275
|
-
let map = opts.map || noop;
|
|
2276
|
-
let dmode = typeof opts.dmode === "number" ? opts.dmode : 0;
|
|
2277
|
-
let fmode = typeof opts.fmode === "number" ? opts.fmode : 0;
|
|
2278
|
-
if (opts.strip) map = strip(map, opts.strip);
|
|
2279
|
-
if (opts.readable) {
|
|
2280
|
-
dmode |= parseInt(555, 8);
|
|
2281
|
-
fmode |= parseInt(444, 8);
|
|
2282
|
-
}
|
|
2283
|
-
if (opts.writable) {
|
|
2284
|
-
dmode |= parseInt(333, 8);
|
|
2285
|
-
fmode |= parseInt(222, 8);
|
|
2286
|
-
}
|
|
2287
|
-
onnextentry();
|
|
2288
|
-
function onsymlink(filename, header) {
|
|
2289
|
-
xfs.readlink(path.join(cwd, filename), function(err, linkname) {
|
|
2290
|
-
if (err) return pack2.destroy(err);
|
|
2291
|
-
header.linkname = normalize(linkname);
|
|
2292
|
-
pack2.entry(header, onnextentry);
|
|
2293
|
-
});
|
|
2294
|
-
}
|
|
2295
|
-
function onstat(err, filename, stat) {
|
|
2296
|
-
if (pack2.destroyed) return;
|
|
2297
|
-
if (err) return pack2.destroy(err);
|
|
2298
|
-
if (!filename) {
|
|
2299
|
-
if (opts.finalize !== false) pack2.finalize();
|
|
2300
|
-
return finish(pack2);
|
|
2301
|
-
}
|
|
2302
|
-
if (stat.isSocket()) return onnextentry();
|
|
2303
|
-
let header = {
|
|
2304
|
-
name: normalize(filename),
|
|
2305
|
-
mode: (stat.mode | (stat.isDirectory() ? dmode : fmode)) & umask,
|
|
2306
|
-
mtime: stat.mtime,
|
|
2307
|
-
size: stat.size,
|
|
2308
|
-
type: "file",
|
|
2309
|
-
uid: stat.uid,
|
|
2310
|
-
gid: stat.gid
|
|
2311
|
-
};
|
|
2312
|
-
if (stat.isDirectory()) {
|
|
2313
|
-
header.size = 0;
|
|
2314
|
-
header.type = "directory";
|
|
2315
|
-
header = map(header) || header;
|
|
2316
|
-
return pack2.entry(header, onnextentry);
|
|
2317
|
-
}
|
|
2318
|
-
if (stat.isSymbolicLink()) {
|
|
2319
|
-
header.size = 0;
|
|
2320
|
-
header.type = "symlink";
|
|
2321
|
-
header = map(header) || header;
|
|
2322
|
-
return onsymlink(filename, header);
|
|
2323
|
-
}
|
|
2324
|
-
header = map(header) || header;
|
|
2325
|
-
if (!stat.isFile()) {
|
|
2326
|
-
if (strict) return pack2.destroy(new Error("unsupported type for " + filename));
|
|
2327
|
-
return onnextentry();
|
|
2328
|
-
}
|
|
2329
|
-
const entry = pack2.entry(header, onnextentry);
|
|
2330
|
-
const rs = mapStream(xfs.createReadStream(path.join(cwd, filename), { start: 0, end: header.size > 0 ? header.size - 1 : header.size }), header);
|
|
2331
|
-
rs.on("error", function(err2) {
|
|
2332
|
-
entry.destroy(err2);
|
|
2333
|
-
});
|
|
2334
|
-
pump(rs, entry);
|
|
2335
|
-
}
|
|
2336
|
-
function onnextentry(err) {
|
|
2337
|
-
if (err) return pack2.destroy(err);
|
|
2338
|
-
statNext(onstat);
|
|
2339
|
-
}
|
|
2340
|
-
return pack2;
|
|
2341
|
-
};
|
|
2342
|
-
function head(list) {
|
|
2343
|
-
return list.length ? list[list.length - 1] : null;
|
|
2344
|
-
}
|
|
2345
|
-
function processGetuid() {
|
|
2346
|
-
return !global.Bare && process.getuid ? process.getuid() : -1;
|
|
2347
|
-
}
|
|
2348
|
-
function processUmask() {
|
|
2349
|
-
return !global.Bare && process.umask ? process.umask() : 0;
|
|
2350
|
-
}
|
|
2351
|
-
exports.extract = function extract(cwd, opts) {
|
|
2352
|
-
if (!cwd) cwd = ".";
|
|
2353
|
-
if (!opts) opts = {};
|
|
2354
|
-
cwd = path.resolve(cwd);
|
|
2355
|
-
const xfs = opts.fs || fs;
|
|
2356
|
-
const ignore = opts.ignore || opts.filter || noop;
|
|
2357
|
-
const mapStream = opts.mapStream || echo;
|
|
2358
|
-
const own = opts.chown !== false && !win32 && processGetuid() === 0;
|
|
2359
|
-
const extract2 = opts.extract || tar.extract();
|
|
2360
|
-
const stack = [];
|
|
2361
|
-
const now = /* @__PURE__ */ new Date();
|
|
2362
|
-
const umask = typeof opts.umask === "number" ? ~opts.umask : ~processUmask();
|
|
2363
|
-
const strict = opts.strict !== false;
|
|
2364
|
-
const validateSymLinks = opts.validateSymlinks !== false;
|
|
2365
|
-
let map = opts.map || noop;
|
|
2366
|
-
let dmode = typeof opts.dmode === "number" ? opts.dmode : 0;
|
|
2367
|
-
let fmode = typeof opts.fmode === "number" ? opts.fmode : 0;
|
|
2368
|
-
if (opts.strip) map = strip(map, opts.strip);
|
|
2369
|
-
if (opts.readable) {
|
|
2370
|
-
dmode |= parseInt(555, 8);
|
|
2371
|
-
fmode |= parseInt(444, 8);
|
|
2372
|
-
}
|
|
2373
|
-
if (opts.writable) {
|
|
2374
|
-
dmode |= parseInt(333, 8);
|
|
2375
|
-
fmode |= parseInt(222, 8);
|
|
2376
|
-
}
|
|
2377
|
-
extract2.on("entry", onentry);
|
|
2378
|
-
if (opts.finish) extract2.on("finish", opts.finish);
|
|
2379
|
-
return extract2;
|
|
2380
|
-
function onentry(header, stream, next) {
|
|
2381
|
-
header = map(header) || header;
|
|
2382
|
-
header.name = normalize(header.name);
|
|
2383
|
-
const name = path.join(cwd, path.join("/", header.name));
|
|
2384
|
-
if (ignore(name, header)) {
|
|
2385
|
-
stream.resume();
|
|
2386
|
-
return next();
|
|
2387
|
-
}
|
|
2388
|
-
const dir = path.join(name, ".") === path.join(cwd, ".") ? cwd : path.dirname(name);
|
|
2389
|
-
validate(xfs, dir, path.join(cwd, "."), function(err, valid) {
|
|
2390
|
-
if (err) return next(err);
|
|
2391
|
-
if (!valid) return next(new Error(dir + " is not a valid path"));
|
|
2392
|
-
if (header.type === "directory") {
|
|
2393
|
-
stack.push([name, header.mtime]);
|
|
2394
|
-
return mkdirfix(name, {
|
|
2395
|
-
fs: xfs,
|
|
2396
|
-
own,
|
|
2397
|
-
uid: header.uid,
|
|
2398
|
-
gid: header.gid,
|
|
2399
|
-
mode: header.mode
|
|
2400
|
-
}, stat);
|
|
2401
|
-
}
|
|
2402
|
-
mkdirfix(dir, {
|
|
2403
|
-
fs: xfs,
|
|
2404
|
-
own,
|
|
2405
|
-
uid: header.uid,
|
|
2406
|
-
gid: header.gid,
|
|
2407
|
-
// normally, the folders with rights and owner should be part of the TAR file
|
|
2408
|
-
// if this is not the case, create folder for same user as file and with
|
|
2409
|
-
// standard permissions of 0o755 (rwxr-xr-x)
|
|
2410
|
-
mode: 493
|
|
2411
|
-
}, function(err2) {
|
|
2412
|
-
if (err2) return next(err2);
|
|
2413
|
-
switch (header.type) {
|
|
2414
|
-
case "file":
|
|
2415
|
-
return onfile();
|
|
2416
|
-
case "link":
|
|
2417
|
-
return onlink();
|
|
2418
|
-
case "symlink":
|
|
2419
|
-
return onsymlink();
|
|
2420
|
-
}
|
|
2421
|
-
if (strict) return next(new Error("unsupported type for " + name + " (" + header.type + ")"));
|
|
2422
|
-
stream.resume();
|
|
2423
|
-
next();
|
|
2424
|
-
});
|
|
2425
|
-
});
|
|
2426
|
-
function stat(err) {
|
|
2427
|
-
if (err) return next(err);
|
|
2428
|
-
utimes(name, header, function(err2) {
|
|
2429
|
-
if (err2) return next(err2);
|
|
2430
|
-
if (win32) return next();
|
|
2431
|
-
chperm(name, header, next);
|
|
2432
|
-
});
|
|
2433
|
-
}
|
|
2434
|
-
function onsymlink() {
|
|
2435
|
-
if (win32) return next();
|
|
2436
|
-
xfs.unlink(name, function() {
|
|
2437
|
-
const dst = path.resolve(path.dirname(name), header.linkname);
|
|
2438
|
-
if (!inCwd(dst) && validateSymLinks) return next(new Error(name + " is not a valid symlink"));
|
|
2439
|
-
xfs.symlink(header.linkname, name, stat);
|
|
2440
|
-
});
|
|
2441
|
-
}
|
|
2442
|
-
function onlink() {
|
|
2443
|
-
if (win32) return next();
|
|
2444
|
-
xfs.unlink(name, function() {
|
|
2445
|
-
const link = path.join(cwd, path.join("/", header.linkname));
|
|
2446
|
-
fs.realpath(link, function(err, dst) {
|
|
2447
|
-
if (err || !inCwd(dst)) return next(new Error(name + " is not a valid hardlink"));
|
|
2448
|
-
xfs.link(dst, name, function(err2) {
|
|
2449
|
-
if (err2 && err2.code === "EPERM" && opts.hardlinkAsFilesFallback) {
|
|
2450
|
-
stream = xfs.createReadStream(dst);
|
|
2451
|
-
return onfile();
|
|
2452
|
-
}
|
|
2453
|
-
stat(err2);
|
|
2454
|
-
});
|
|
2455
|
-
});
|
|
2456
|
-
});
|
|
2457
|
-
}
|
|
2458
|
-
function inCwd(dst) {
|
|
2459
|
-
return dst === cwd || dst.startsWith(cwd + path.sep);
|
|
2460
|
-
}
|
|
2461
|
-
function onfile() {
|
|
2462
|
-
const ws = xfs.createWriteStream(name);
|
|
2463
|
-
const rs = mapStream(stream, header);
|
|
2464
|
-
ws.on("error", function(err) {
|
|
2465
|
-
rs.destroy(err);
|
|
2466
|
-
});
|
|
2467
|
-
pump(rs, ws, function(err) {
|
|
2468
|
-
if (err) return next(err);
|
|
2469
|
-
ws.on("close", stat);
|
|
2470
|
-
});
|
|
2471
|
-
}
|
|
2472
|
-
}
|
|
2473
|
-
function utimesParent(name, cb) {
|
|
2474
|
-
let top;
|
|
2475
|
-
while ((top = head(stack)) && name.slice(0, top[0].length) !== top[0]) stack.pop();
|
|
2476
|
-
if (!top) return cb();
|
|
2477
|
-
xfs.utimes(top[0], now, top[1], cb);
|
|
2478
|
-
}
|
|
2479
|
-
function utimes(name, header, cb) {
|
|
2480
|
-
if (opts.utimes === false) return cb();
|
|
2481
|
-
if (header.type === "directory") return xfs.utimes(name, now, header.mtime, cb);
|
|
2482
|
-
if (header.type === "symlink") return utimesParent(name, cb);
|
|
2483
|
-
xfs.utimes(name, now, header.mtime, function(err) {
|
|
2484
|
-
if (err) return cb(err);
|
|
2485
|
-
utimesParent(name, cb);
|
|
2486
|
-
});
|
|
2487
|
-
}
|
|
2488
|
-
function chperm(name, header, cb) {
|
|
2489
|
-
const link = header.type === "symlink";
|
|
2490
|
-
const chmod = link ? xfs.lchmod : xfs.chmod;
|
|
2491
|
-
const chown = link ? xfs.lchown : xfs.chown;
|
|
2492
|
-
if (!chmod) return cb();
|
|
2493
|
-
const mode = (header.mode | (header.type === "directory" ? dmode : fmode)) & umask;
|
|
2494
|
-
if (chown && own) chown.call(xfs, name, header.uid, header.gid, onchown);
|
|
2495
|
-
else onchown(null);
|
|
2496
|
-
function onchown(err) {
|
|
2497
|
-
if (err) return cb(err);
|
|
2498
|
-
if (!chmod) return cb();
|
|
2499
|
-
chmod.call(xfs, name, mode, cb);
|
|
2500
|
-
}
|
|
2501
|
-
}
|
|
2502
|
-
function mkdirfix(name, opts2, cb) {
|
|
2503
|
-
xfs.stat(name, function(err) {
|
|
2504
|
-
if (!err) return cb(null);
|
|
2505
|
-
if (err.code !== "ENOENT") return cb(err);
|
|
2506
|
-
xfs.mkdir(name, { mode: opts2.mode, recursive: true }, function(err2, made) {
|
|
2507
|
-
if (err2) return cb(err2);
|
|
2508
|
-
chperm(name, opts2, cb);
|
|
2509
|
-
});
|
|
2510
|
-
});
|
|
2511
|
-
}
|
|
2512
|
-
};
|
|
2513
|
-
function validate(fs2, name, root, cb) {
|
|
2514
|
-
if (name === root) return cb(null, true);
|
|
2515
|
-
fs2.lstat(name, function(err, st) {
|
|
2516
|
-
if (err && err.code !== "ENOENT" && err.code !== "EPERM") return cb(err);
|
|
2517
|
-
if (err || st.isDirectory()) return validate(fs2, path.join(name, ".."), root, cb);
|
|
2518
|
-
cb(null, false);
|
|
2519
|
-
});
|
|
2520
|
-
}
|
|
2521
|
-
function noop() {
|
|
2522
|
-
}
|
|
2523
|
-
function echo(name) {
|
|
2524
|
-
return name;
|
|
2525
|
-
}
|
|
2526
|
-
function normalize(name) {
|
|
2527
|
-
return win32 ? name.replace(/\\/g, "/").replace(/[:?<>|]/g, "_") : name;
|
|
2528
|
-
}
|
|
2529
|
-
function statAll(fs2, stat, cwd, ignore, entries, sort) {
|
|
2530
|
-
if (!entries) entries = ["."];
|
|
2531
|
-
const queue = entries.slice(0);
|
|
2532
|
-
return function loop(callback) {
|
|
2533
|
-
if (!queue.length) return callback(null);
|
|
2534
|
-
const next = queue.shift();
|
|
2535
|
-
const nextAbs = path.join(cwd, next);
|
|
2536
|
-
stat.call(fs2, nextAbs, function(err, stat2) {
|
|
2537
|
-
if (err) return callback(entries.indexOf(next) === -1 && err.code === "ENOENT" ? null : err);
|
|
2538
|
-
if (!stat2.isDirectory()) return callback(null, next, stat2);
|
|
2539
|
-
fs2.readdir(nextAbs, function(err2, files) {
|
|
2540
|
-
if (err2) return callback(err2);
|
|
2541
|
-
if (sort) files.sort();
|
|
2542
|
-
for (let i = 0; i < files.length; i++) {
|
|
2543
|
-
if (!ignore(path.join(cwd, next, files[i]))) queue.push(path.join(next, files[i]));
|
|
2544
|
-
}
|
|
2545
|
-
callback(null, next, stat2);
|
|
2546
|
-
});
|
|
2547
|
-
});
|
|
2548
|
-
};
|
|
2549
|
-
}
|
|
2550
|
-
function strip(map, level) {
|
|
2551
|
-
return function(header) {
|
|
2552
|
-
header.name = header.name.split("/").slice(level).join("/");
|
|
2553
|
-
const linkname = header.linkname;
|
|
2554
|
-
if (linkname && (header.type === "link" || path.isAbsolute(linkname))) {
|
|
2555
|
-
header.linkname = linkname.split("/").slice(level).join("/");
|
|
2556
|
-
}
|
|
2557
|
-
return map(header);
|
|
2558
|
-
};
|
|
2559
|
-
}
|
|
2560
|
-
}
|
|
2561
|
-
});
|
|
2562
|
-
export default require_tar_fs();
|