@holydeck/cli 2026.9.2

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.
Files changed (57) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +234 -0
  3. package/dist/BrowserWebSocketTransport-H3D6MINS.js +12 -0
  4. package/dist/BrowserWebSocketTransport-H3D6MINS.js.map +1 -0
  5. package/dist/LaunchOptions-42ZS55HH.js +12 -0
  6. package/dist/LaunchOptions-42ZS55HH.js.map +1 -0
  7. package/dist/NodeWebSocketTransport-BXHQGXRM.js +15 -0
  8. package/dist/NodeWebSocketTransport-BXHQGXRM.js.map +1 -0
  9. package/dist/bidi-25S23FWJ.js +18358 -0
  10. package/dist/bidi-25S23FWJ.js.map +1 -0
  11. package/dist/chunk-2BLOYUSF.js +795 -0
  12. package/dist/chunk-2BLOYUSF.js.map +1 -0
  13. package/dist/chunk-43CZTS57.js +38 -0
  14. package/dist/chunk-43CZTS57.js.map +1 -0
  15. package/dist/chunk-DIBLSFAG.js +34 -0
  16. package/dist/chunk-DIBLSFAG.js.map +1 -0
  17. package/dist/chunk-IEJ3OX3N.js +52 -0
  18. package/dist/chunk-IEJ3OX3N.js.map +1 -0
  19. package/dist/chunk-JM4YIWBN.js +3796 -0
  20. package/dist/chunk-JM4YIWBN.js.map +1 -0
  21. package/dist/chunk-NP3DTWF7.js +23282 -0
  22. package/dist/chunk-NP3DTWF7.js.map +1 -0
  23. package/dist/chunk-SWG4X375.js +51 -0
  24. package/dist/chunk-SWG4X375.js.map +1 -0
  25. package/dist/chunk-UC6TFXMD.js +2821 -0
  26. package/dist/chunk-UC6TFXMD.js.map +1 -0
  27. package/dist/chunk-V4BIHFVZ.js +2287 -0
  28. package/dist/chunk-V4BIHFVZ.js.map +1 -0
  29. package/dist/chunk-V77AQPDK.js +20 -0
  30. package/dist/chunk-V77AQPDK.js.map +1 -0
  31. package/dist/chunk-XAENXL52.js +101 -0
  32. package/dist/chunk-XAENXL52.js.map +1 -0
  33. package/dist/cli.js +64101 -0
  34. package/dist/cli.js.map +1 -0
  35. package/dist/dist-3ZE2HBJQ.js +20447 -0
  36. package/dist/dist-3ZE2HBJQ.js.map +1 -0
  37. package/dist/dist-575AQY5L.js +1161 -0
  38. package/dist/dist-575AQY5L.js.map +1 -0
  39. package/dist/dist-DL5M2SDJ.js +117 -0
  40. package/dist/dist-DL5M2SDJ.js.map +1 -0
  41. package/dist/dist-OMWR53J4.js +4713 -0
  42. package/dist/dist-OMWR53J4.js.map +1 -0
  43. package/dist/dist-UT6HKKCD.js +281 -0
  44. package/dist/dist-UT6HKKCD.js.map +1 -0
  45. package/dist/fs-P6GYHPGZ.js +1685 -0
  46. package/dist/fs-P6GYHPGZ.js.map +1 -0
  47. package/dist/helpers-64DWIL6C.js +21 -0
  48. package/dist/helpers-64DWIL6C.js.map +1 -0
  49. package/dist/main-IQ64YDOJ.js +61 -0
  50. package/dist/main-IQ64YDOJ.js.map +1 -0
  51. package/dist/puppeteer-RDWY6FSG.js +2386 -0
  52. package/dist/puppeteer-RDWY6FSG.js.map +1 -0
  53. package/dist/yargs-KMQWKLG6.js +3264 -0
  54. package/dist/yargs-KMQWKLG6.js.map +1 -0
  55. package/dist/yauzl-7KG7KPPF.js +1355 -0
  56. package/dist/yauzl-7KG7KPPF.js.map +1 -0
  57. package/package.json +44 -0
@@ -0,0 +1,1355 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __holydeckCreateRequire } from 'node:module';
3
+ const require = __holydeckCreateRequire(import.meta.url);
4
+ import {
5
+ __commonJS,
6
+ __require
7
+ } from "./chunk-IEJ3OX3N.js";
8
+
9
+ // ../../node_modules/.pnpm/pend@1.2.0/node_modules/pend/index.js
10
+ var require_pend = __commonJS({
11
+ "../../node_modules/.pnpm/pend@1.2.0/node_modules/pend/index.js"(exports, module) {
12
+ "use strict";
13
+ module.exports = Pend;
14
+ function Pend() {
15
+ this.pending = 0;
16
+ this.max = Infinity;
17
+ this.listeners = [];
18
+ this.waiting = [];
19
+ this.error = null;
20
+ }
21
+ Pend.prototype.go = function(fn) {
22
+ if (this.pending < this.max) {
23
+ pendGo(this, fn);
24
+ } else {
25
+ this.waiting.push(fn);
26
+ }
27
+ };
28
+ Pend.prototype.wait = function(cb) {
29
+ if (this.pending === 0) {
30
+ cb(this.error);
31
+ } else {
32
+ this.listeners.push(cb);
33
+ }
34
+ };
35
+ Pend.prototype.hold = function() {
36
+ return pendHold(this);
37
+ };
38
+ function pendHold(self) {
39
+ self.pending += 1;
40
+ var called = false;
41
+ return onCb;
42
+ function onCb(err) {
43
+ if (called) throw new Error("callback called twice");
44
+ called = true;
45
+ self.error = self.error || err;
46
+ self.pending -= 1;
47
+ if (self.waiting.length > 0 && self.pending < self.max) {
48
+ pendGo(self, self.waiting.shift());
49
+ } else if (self.pending === 0) {
50
+ var listeners = self.listeners;
51
+ self.listeners = [];
52
+ listeners.forEach(cbListener);
53
+ }
54
+ }
55
+ function cbListener(listener) {
56
+ listener(self.error);
57
+ }
58
+ }
59
+ function pendGo(self, fn) {
60
+ fn(pendHold(self));
61
+ }
62
+ }
63
+ });
64
+
65
+ // ../../node_modules/.pnpm/yauzl@3.4.0/node_modules/yauzl/fd-slicer.js
66
+ var require_fd_slicer = __commonJS({
67
+ "../../node_modules/.pnpm/yauzl@3.4.0/node_modules/yauzl/fd-slicer.js"(exports) {
68
+ "use strict";
69
+ var fs = __require("fs");
70
+ var util = __require("util");
71
+ var stream = __require("stream");
72
+ var Readable = stream.Readable;
73
+ var PassThrough = stream.PassThrough;
74
+ var Pend = require_pend();
75
+ var EventEmitter = __require("events").EventEmitter;
76
+ exports.BufferSlicer = BufferSlicer;
77
+ exports.FdSlicer = FdSlicer;
78
+ util.inherits(FdSlicer, EventEmitter);
79
+ function FdSlicer(fd) {
80
+ EventEmitter.call(this);
81
+ this.fd = fd;
82
+ this.pend = new Pend();
83
+ this.pend.max = 1;
84
+ this.refCount = 0;
85
+ }
86
+ FdSlicer.prototype.read = function(buffer, offset, length, position, callback) {
87
+ var self = this;
88
+ self.pend.go(function(cb) {
89
+ fs.read(self.fd, buffer, offset, length, position, function(err, bytesRead, buffer2) {
90
+ cb();
91
+ callback(err, bytesRead, buffer2);
92
+ });
93
+ });
94
+ };
95
+ FdSlicer.prototype.createReadStream = function(options2) {
96
+ return new ReadStream(this, options2);
97
+ };
98
+ FdSlicer.prototype.ref = function() {
99
+ this.refCount += 1;
100
+ };
101
+ FdSlicer.prototype.unref = function() {
102
+ var self = this;
103
+ self.refCount -= 1;
104
+ if (self.refCount < 0) throw new Error("invalid unref");
105
+ if (self.refCount > 0) return;
106
+ fs.close(self.fd, onCloseDone);
107
+ function onCloseDone(err) {
108
+ if (err) {
109
+ self.emit("error", err);
110
+ } else {
111
+ self.emit("close");
112
+ }
113
+ }
114
+ };
115
+ util.inherits(ReadStream, Readable);
116
+ function ReadStream(context, options2) {
117
+ options2 = options2 || {};
118
+ Readable.call(this, options2);
119
+ this.context = context;
120
+ this.context.ref();
121
+ this.start = options2.start || 0;
122
+ this.endOffset = options2.end;
123
+ this.pos = this.start;
124
+ }
125
+ ReadStream.prototype._read = function(n) {
126
+ var self = this;
127
+ var toRead = Math.min(self._readableState.highWaterMark, n);
128
+ if (self.endOffset != null) {
129
+ toRead = Math.min(toRead, self.endOffset - self.pos);
130
+ }
131
+ if (toRead <= 0) {
132
+ self.push(null);
133
+ this._cleanup();
134
+ return;
135
+ }
136
+ self.context.pend.go(function(cb) {
137
+ var buffer = Buffer.allocUnsafe(toRead);
138
+ fs.read(self.context.fd, buffer, 0, toRead, self.pos, function(err, bytesRead) {
139
+ if (err) {
140
+ self.destroy(err);
141
+ } else if (bytesRead === 0) {
142
+ self.push(null);
143
+ self._cleanup();
144
+ } else {
145
+ self.pos += bytesRead;
146
+ self.push(buffer.slice(0, bytesRead));
147
+ }
148
+ cb();
149
+ });
150
+ });
151
+ };
152
+ ReadStream.prototype._destroy = function(err, cb) {
153
+ this._cleanup();
154
+ cb(err);
155
+ };
156
+ ReadStream.prototype._cleanup = function() {
157
+ if (this.context != null) {
158
+ this.context.unref();
159
+ this.context = null;
160
+ }
161
+ };
162
+ util.inherits(BufferSlicer, EventEmitter);
163
+ function BufferSlicer(buffer) {
164
+ EventEmitter.call(this);
165
+ this.refCount = 0;
166
+ this.buffer = buffer;
167
+ }
168
+ BufferSlicer.prototype.read = function(buffer, offset, length, position, callback) {
169
+ if (!(0 <= offset && offset <= buffer.length)) throw new RangeError("offset outside buffer: 0 <= " + offset + " <= " + buffer.length);
170
+ if (position < 0) throw new RangeError("position is negative: " + position);
171
+ if (offset + length > buffer.length) {
172
+ length = buffer.length - offset;
173
+ }
174
+ if (position + length > this.buffer.length) {
175
+ length = this.buffer.length - position;
176
+ }
177
+ if (length <= 0) {
178
+ setImmediate(function() {
179
+ callback(null, 0);
180
+ });
181
+ return;
182
+ }
183
+ this.buffer.copy(buffer, offset, position, position + length);
184
+ setImmediate(function() {
185
+ callback(null, length);
186
+ });
187
+ };
188
+ BufferSlicer.prototype.createReadStream = function(options2) {
189
+ options2 = options2 || {};
190
+ var readStream = new PassThrough(options2);
191
+ readStream.start = options2.start || 0;
192
+ readStream.endOffset = options2.end;
193
+ readStream.pos = readStream.endOffset || this.buffer.length;
194
+ var entireSlice = this.buffer.slice(readStream.start, readStream.pos);
195
+ var maxChunkSize = 65536;
196
+ var offset = 0;
197
+ while (true) {
198
+ var nextOffset = offset + maxChunkSize;
199
+ if (nextOffset >= entireSlice.length) {
200
+ if (offset < entireSlice.length) {
201
+ readStream.write(entireSlice.slice(offset, entireSlice.length));
202
+ }
203
+ break;
204
+ }
205
+ readStream.write(entireSlice.slice(offset, nextOffset));
206
+ offset = nextOffset;
207
+ }
208
+ readStream.end();
209
+ return readStream;
210
+ };
211
+ BufferSlicer.prototype.ref = function() {
212
+ this.refCount += 1;
213
+ };
214
+ BufferSlicer.prototype.unref = function() {
215
+ this.refCount -= 1;
216
+ if (this.refCount < 0) {
217
+ throw new Error("invalid unref");
218
+ }
219
+ };
220
+ }
221
+ });
222
+
223
+ // ../../node_modules/.pnpm/yauzl@3.4.0/node_modules/yauzl/crc32.js
224
+ var require_crc32 = __commonJS({
225
+ "../../node_modules/.pnpm/yauzl@3.4.0/node_modules/yauzl/crc32.js"(exports, module) {
226
+ "use strict";
227
+ var CRC_TABLE = new Int32Array([
228
+ 0,
229
+ 1996959894,
230
+ 3993919788,
231
+ 2567524794,
232
+ 124634137,
233
+ 1886057615,
234
+ 3915621685,
235
+ 2657392035,
236
+ 249268274,
237
+ 2044508324,
238
+ 3772115230,
239
+ 2547177864,
240
+ 162941995,
241
+ 2125561021,
242
+ 3887607047,
243
+ 2428444049,
244
+ 498536548,
245
+ 1789927666,
246
+ 4089016648,
247
+ 2227061214,
248
+ 450548861,
249
+ 1843258603,
250
+ 4107580753,
251
+ 2211677639,
252
+ 325883990,
253
+ 1684777152,
254
+ 4251122042,
255
+ 2321926636,
256
+ 335633487,
257
+ 1661365465,
258
+ 4195302755,
259
+ 2366115317,
260
+ 997073096,
261
+ 1281953886,
262
+ 3579855332,
263
+ 2724688242,
264
+ 1006888145,
265
+ 1258607687,
266
+ 3524101629,
267
+ 2768942443,
268
+ 901097722,
269
+ 1119000684,
270
+ 3686517206,
271
+ 2898065728,
272
+ 853044451,
273
+ 1172266101,
274
+ 3705015759,
275
+ 2882616665,
276
+ 651767980,
277
+ 1373503546,
278
+ 3369554304,
279
+ 3218104598,
280
+ 565507253,
281
+ 1454621731,
282
+ 3485111705,
283
+ 3099436303,
284
+ 671266974,
285
+ 1594198024,
286
+ 3322730930,
287
+ 2970347812,
288
+ 795835527,
289
+ 1483230225,
290
+ 3244367275,
291
+ 3060149565,
292
+ 1994146192,
293
+ 31158534,
294
+ 2563907772,
295
+ 4023717930,
296
+ 1907459465,
297
+ 112637215,
298
+ 2680153253,
299
+ 3904427059,
300
+ 2013776290,
301
+ 251722036,
302
+ 2517215374,
303
+ 3775830040,
304
+ 2137656763,
305
+ 141376813,
306
+ 2439277719,
307
+ 3865271297,
308
+ 1802195444,
309
+ 476864866,
310
+ 2238001368,
311
+ 4066508878,
312
+ 1812370925,
313
+ 453092731,
314
+ 2181625025,
315
+ 4111451223,
316
+ 1706088902,
317
+ 314042704,
318
+ 2344532202,
319
+ 4240017532,
320
+ 1658658271,
321
+ 366619977,
322
+ 2362670323,
323
+ 4224994405,
324
+ 1303535960,
325
+ 984961486,
326
+ 2747007092,
327
+ 3569037538,
328
+ 1256170817,
329
+ 1037604311,
330
+ 2765210733,
331
+ 3554079995,
332
+ 1131014506,
333
+ 879679996,
334
+ 2909243462,
335
+ 3663771856,
336
+ 1141124467,
337
+ 855842277,
338
+ 2852801631,
339
+ 3708648649,
340
+ 1342533948,
341
+ 654459306,
342
+ 3188396048,
343
+ 3373015174,
344
+ 1466479909,
345
+ 544179635,
346
+ 3110523913,
347
+ 3462522015,
348
+ 1591671054,
349
+ 702138776,
350
+ 2966460450,
351
+ 3352799412,
352
+ 1504918807,
353
+ 783551873,
354
+ 3082640443,
355
+ 3233442989,
356
+ 3988292384,
357
+ 2596254646,
358
+ 62317068,
359
+ 1957810842,
360
+ 3939845945,
361
+ 2647816111,
362
+ 81470997,
363
+ 1943803523,
364
+ 3814918930,
365
+ 2489596804,
366
+ 225274430,
367
+ 2053790376,
368
+ 3826175755,
369
+ 2466906013,
370
+ 167816743,
371
+ 2097651377,
372
+ 4027552580,
373
+ 2265490386,
374
+ 503444072,
375
+ 1762050814,
376
+ 4150417245,
377
+ 2154129355,
378
+ 426522225,
379
+ 1852507879,
380
+ 4275313526,
381
+ 2312317920,
382
+ 282753626,
383
+ 1742555852,
384
+ 4189708143,
385
+ 2394877945,
386
+ 397917763,
387
+ 1622183637,
388
+ 3604390888,
389
+ 2714866558,
390
+ 953729732,
391
+ 1340076626,
392
+ 3518719985,
393
+ 2797360999,
394
+ 1068828381,
395
+ 1219638859,
396
+ 3624741850,
397
+ 2936675148,
398
+ 906185462,
399
+ 1090812512,
400
+ 3747672003,
401
+ 2825379669,
402
+ 829329135,
403
+ 1181335161,
404
+ 3412177804,
405
+ 3160834842,
406
+ 628085408,
407
+ 1382605366,
408
+ 3423369109,
409
+ 3138078467,
410
+ 570562233,
411
+ 1426400815,
412
+ 3317316542,
413
+ 2998733608,
414
+ 733239954,
415
+ 1555261956,
416
+ 3268935591,
417
+ 3050360625,
418
+ 752459403,
419
+ 1541320221,
420
+ 2607071920,
421
+ 3965973030,
422
+ 1969922972,
423
+ 40735498,
424
+ 2617837225,
425
+ 3943577151,
426
+ 1913087877,
427
+ 83908371,
428
+ 2512341634,
429
+ 3803740692,
430
+ 2075208622,
431
+ 213261112,
432
+ 2463272603,
433
+ 3855990285,
434
+ 2094854071,
435
+ 198958881,
436
+ 2262029012,
437
+ 4057260610,
438
+ 1759359992,
439
+ 534414190,
440
+ 2176718541,
441
+ 4139329115,
442
+ 1873836001,
443
+ 414664567,
444
+ 2282248934,
445
+ 4279200368,
446
+ 1711684554,
447
+ 285281116,
448
+ 2405801727,
449
+ 4167216745,
450
+ 1634467795,
451
+ 376229701,
452
+ 2685067896,
453
+ 3608007406,
454
+ 1308918612,
455
+ 956543938,
456
+ 2808555105,
457
+ 3495958263,
458
+ 1231636301,
459
+ 1047427035,
460
+ 2932959818,
461
+ 3654703836,
462
+ 1088359270,
463
+ 936918e3,
464
+ 2847714899,
465
+ 3736837829,
466
+ 1202900863,
467
+ 817233897,
468
+ 3183342108,
469
+ 3401237130,
470
+ 1404277552,
471
+ 615818150,
472
+ 3134207493,
473
+ 3453421203,
474
+ 1423857449,
475
+ 601450431,
476
+ 3009837614,
477
+ 3294710456,
478
+ 1567103746,
479
+ 711928724,
480
+ 3020668471,
481
+ 3272380065,
482
+ 1510334235,
483
+ 755167117
484
+ ]);
485
+ function crc32(buf) {
486
+ let crc = -1;
487
+ for (let x of buf) {
488
+ crc = CRC_TABLE[(crc ^ x) & 255] ^ crc >>> 8;
489
+ }
490
+ return (crc ^ -1) >>> 0;
491
+ }
492
+ module.exports = crc32;
493
+ }
494
+ });
495
+
496
+ // ../../node_modules/.pnpm/yauzl@3.4.0/node_modules/yauzl/index.js
497
+ var require_yauzl = __commonJS({
498
+ "../../node_modules/.pnpm/yauzl@3.4.0/node_modules/yauzl/index.js"(exports) {
499
+ var fs = __require("fs");
500
+ var zlib = __require("zlib");
501
+ var fd_slicer = require_fd_slicer();
502
+ var util = __require("util");
503
+ var EventEmitter = __require("events").EventEmitter;
504
+ var Transform = __require("stream").Transform;
505
+ var PassThrough = __require("stream").PassThrough;
506
+ var Writable = __require("stream").Writable;
507
+ var crc32 = typeof zlib.crc32 === "function" ? zlib.crc32 : require_crc32();
508
+ exports.open = open;
509
+ exports.fromFd = fromFd;
510
+ exports.fromBuffer = fromBuffer;
511
+ exports.fromRandomAccessReader = fromRandomAccessReader;
512
+ exports.openPromise = openPromise;
513
+ exports.fromFdPromise = fromFdPromise;
514
+ exports.fromBufferPromise = fromBufferPromise;
515
+ exports.fromRandomAccessReaderPromise = fromRandomAccessReaderPromise;
516
+ exports.dosDateTimeToDate = dosDateTimeToDate;
517
+ exports.getFileNameLowLevel = getFileNameLowLevel;
518
+ exports.validateFileName = validateFileName;
519
+ exports.parseExtraFields = parseExtraFields;
520
+ exports.ZipFile = ZipFile;
521
+ exports.Entry = Entry;
522
+ exports.LocalFileHeader = LocalFileHeader;
523
+ exports.RandomAccessReader = RandomAccessReader;
524
+ function openPromise(path, options2) {
525
+ return new Promise((resolve, reject) => {
526
+ open(path, { ...options2, lazyEntries: true }, function(err, zipfile) {
527
+ if (err) return reject(err);
528
+ resolve(zipfile);
529
+ });
530
+ });
531
+ }
532
+ function fromFdPromise(fd, options2) {
533
+ return new Promise((resolve, reject) => {
534
+ fromFd(fd, { ...options2, lazyEntries: true }, function(err, zipfile) {
535
+ if (err) return reject(err);
536
+ resolve(zipfile);
537
+ });
538
+ });
539
+ }
540
+ function fromBufferPromise(buffer, options2) {
541
+ return new Promise((resolve, reject) => {
542
+ fromBuffer(buffer, { ...options2, lazyEntries: true }, function(err, zipfile) {
543
+ if (err) return reject(err);
544
+ resolve(zipfile);
545
+ });
546
+ });
547
+ }
548
+ function fromRandomAccessReaderPromise(reader, totalSize, options2) {
549
+ return new Promise((resolve, reject) => {
550
+ fromRandomAccessReader(reader, totalSize, { ...options2, lazyEntries: true }, function(err, zipfile) {
551
+ if (err) return reject(err);
552
+ resolve(zipfile);
553
+ });
554
+ });
555
+ }
556
+ function open(path, options2, callback) {
557
+ if (typeof options2 === "function") {
558
+ callback = options2;
559
+ options2 = null;
560
+ }
561
+ if (options2 == null) options2 = {};
562
+ if (options2.autoClose == null) options2.autoClose = true;
563
+ if (options2.lazyEntries == null) options2.lazyEntries = false;
564
+ if (options2.decodeStrings == null) options2.decodeStrings = true;
565
+ if (options2.validateEntrySizes == null) options2.validateEntrySizes = true;
566
+ if (options2.strictFileNames == null) options2.strictFileNames = false;
567
+ if (callback == null) callback = defaultCallback;
568
+ fs.open(path, "r", function(err, fd) {
569
+ if (err) return callback(err);
570
+ fromFd(fd, options2, function(err2, zipfile) {
571
+ if (err2) fs.close(fd, defaultCallback);
572
+ callback(err2, zipfile);
573
+ });
574
+ });
575
+ }
576
+ function fromFd(fd, options2, callback) {
577
+ if (typeof options2 === "function") {
578
+ callback = options2;
579
+ options2 = null;
580
+ }
581
+ if (options2 == null) options2 = {};
582
+ if (options2.autoClose == null) options2.autoClose = false;
583
+ if (options2.lazyEntries == null) options2.lazyEntries = false;
584
+ if (options2.decodeStrings == null) options2.decodeStrings = true;
585
+ if (options2.validateEntrySizes == null) options2.validateEntrySizes = true;
586
+ if (options2.strictFileNames == null) options2.strictFileNames = false;
587
+ if (callback == null) callback = defaultCallback;
588
+ fs.fstat(fd, function(err, stats) {
589
+ if (err) return callback(err);
590
+ var reader = new fd_slicer.FdSlicer(fd);
591
+ fromRandomAccessReader(reader, stats.size, options2, callback);
592
+ });
593
+ }
594
+ function fromBuffer(buffer, options2, callback) {
595
+ if (typeof options2 === "function") {
596
+ callback = options2;
597
+ options2 = null;
598
+ }
599
+ if (options2 == null) options2 = {};
600
+ options2.autoClose = false;
601
+ if (options2.lazyEntries == null) options2.lazyEntries = false;
602
+ if (options2.decodeStrings == null) options2.decodeStrings = true;
603
+ if (options2.validateEntrySizes == null) options2.validateEntrySizes = true;
604
+ if (options2.strictFileNames == null) options2.strictFileNames = false;
605
+ var reader = new fd_slicer.BufferSlicer(buffer);
606
+ fromRandomAccessReader(reader, buffer.length, options2, callback);
607
+ }
608
+ function fromRandomAccessReader(reader, totalSize, options2, callback) {
609
+ if (typeof options2 === "function") {
610
+ callback = options2;
611
+ options2 = null;
612
+ }
613
+ if (options2 == null) options2 = {};
614
+ if (options2.autoClose == null) options2.autoClose = true;
615
+ if (options2.lazyEntries == null) options2.lazyEntries = false;
616
+ if (options2.decodeStrings == null) options2.decodeStrings = true;
617
+ var decodeStrings = !!options2.decodeStrings;
618
+ if (options2.validateEntrySizes == null) options2.validateEntrySizes = true;
619
+ if (options2.strictFileNames == null) options2.strictFileNames = false;
620
+ if (callback == null) callback = defaultCallback;
621
+ if (typeof totalSize !== "number") throw new Error("expected totalSize parameter to be a number");
622
+ if (totalSize > Number.MAX_SAFE_INTEGER) {
623
+ throw new Error("zip file too large. only file sizes up to 2^52 are supported due to JavaScript's Number type being an IEEE 754 double.");
624
+ }
625
+ reader.ref();
626
+ var eocdrWithoutCommentSize = 22;
627
+ var zip64EocdlSize = 20;
628
+ var maxCommentSize = 65535;
629
+ var bufferSize = Math.min(zip64EocdlSize + eocdrWithoutCommentSize + maxCommentSize, totalSize);
630
+ var buffer = newBuffer(bufferSize);
631
+ var bufferReadStart = totalSize - buffer.length;
632
+ readAndAssertNoEof(reader, buffer, 0, bufferSize, bufferReadStart, function(err) {
633
+ if (err) return callback(err);
634
+ for (var i = bufferSize - eocdrWithoutCommentSize; i >= 0; i -= 1) {
635
+ if (buffer.readUInt32LE(i) !== 101010256) continue;
636
+ var eocdrBuffer = buffer.subarray(i);
637
+ var diskNumber = eocdrBuffer.readUInt16LE(4);
638
+ var entryCount = eocdrBuffer.readUInt16LE(10);
639
+ var centralDirectoryOffset = eocdrBuffer.readUInt32LE(16);
640
+ var commentLength = eocdrBuffer.readUInt16LE(20);
641
+ var expectedCommentLength = eocdrBuffer.length - eocdrWithoutCommentSize;
642
+ if (commentLength !== expectedCommentLength) {
643
+ return callback(new Error("Invalid comment length. Expected: " + expectedCommentLength + ". Found: " + commentLength + ". Are there extra bytes at the end of the file? Or is the end of central dir signature `PK\u263A\u263B` in the comment?"));
644
+ }
645
+ var comment = decodeStrings ? decodeBuffer(eocdrBuffer.subarray(22), false) : eocdrBuffer.subarray(22);
646
+ if (i - zip64EocdlSize >= 0 && buffer.readUInt32LE(i - zip64EocdlSize) === 117853008) {
647
+ var zip64EocdlBuffer = buffer.subarray(i - zip64EocdlSize, i - zip64EocdlSize + zip64EocdlSize);
648
+ var zip64EocdrOffset = readUInt64LE(zip64EocdlBuffer, 8);
649
+ var zip64EocdrBuffer = newBuffer(56);
650
+ return readAndAssertNoEof(reader, zip64EocdrBuffer, 0, zip64EocdrBuffer.length, zip64EocdrOffset, function(err2) {
651
+ if (err2) return callback(err2);
652
+ if (zip64EocdrBuffer.readUInt32LE(0) !== 101075792) {
653
+ return callback(new Error("invalid zip64 end of central directory record signature"));
654
+ }
655
+ diskNumber = zip64EocdrBuffer.readUInt32LE(16);
656
+ if (diskNumber !== 0) {
657
+ return callback(new Error("multi-disk zip files are not supported: found disk number: " + diskNumber));
658
+ }
659
+ entryCount = readUInt64LE(zip64EocdrBuffer, 32);
660
+ centralDirectoryOffset = readUInt64LE(zip64EocdrBuffer, 48);
661
+ return callback(null, new ZipFile(reader, centralDirectoryOffset, totalSize, entryCount, comment, options2.autoClose, options2.lazyEntries, decodeStrings, options2.validateEntrySizes, options2.strictFileNames));
662
+ });
663
+ }
664
+ if (diskNumber !== 0) {
665
+ return callback(new Error("multi-disk zip files are not supported: found disk number: " + diskNumber));
666
+ }
667
+ return callback(null, new ZipFile(reader, centralDirectoryOffset, totalSize, entryCount, comment, options2.autoClose, options2.lazyEntries, decodeStrings, options2.validateEntrySizes, options2.strictFileNames));
668
+ }
669
+ callback(new Error("End of central directory record signature not found. Either not a zip file, or file is truncated."));
670
+ });
671
+ }
672
+ util.inherits(ZipFile, EventEmitter);
673
+ function ZipFile(reader, centralDirectoryOffset, fileSize, entryCount, comment, autoClose, lazyEntries, decodeStrings, validateEntrySizes, strictFileNames) {
674
+ var self = this;
675
+ EventEmitter.call(self);
676
+ self.reader = reader;
677
+ self.reader.on("error", function(err) {
678
+ emitError(self, err);
679
+ });
680
+ self.reader.once("close", function() {
681
+ self.emit("close");
682
+ });
683
+ self.readEntryCursor = centralDirectoryOffset;
684
+ self.fileSize = fileSize;
685
+ self.entryCount = entryCount;
686
+ self.comment = comment;
687
+ self.entriesRead = 0;
688
+ self.autoClose = !!autoClose;
689
+ self.lazyEntries = !!lazyEntries;
690
+ self.decodeStrings = !!decodeStrings;
691
+ self.validateEntrySizes = !!validateEntrySizes;
692
+ self.strictFileNames = !!strictFileNames;
693
+ self.isOpen = true;
694
+ self.emittedError = false;
695
+ self.hasEachEntryBeenCalled = false;
696
+ if (!self.lazyEntries) self._readEntry();
697
+ }
698
+ ZipFile.prototype.close = function() {
699
+ if (!this.isOpen) return;
700
+ this.isOpen = false;
701
+ this.reader.unref();
702
+ };
703
+ function emitErrorAndAutoClose(self, err) {
704
+ if (self.autoClose) self.close();
705
+ emitError(self, err);
706
+ }
707
+ function emitError(self, err) {
708
+ if (self.emittedError) return;
709
+ self.emittedError = true;
710
+ self.emit("error", err);
711
+ }
712
+ ZipFile.prototype.readEntry = function() {
713
+ if (!this.lazyEntries) throw new Error("readEntry() called without lazyEntries:true");
714
+ this._readEntry();
715
+ };
716
+ ZipFile.prototype._readEntry = function() {
717
+ var self = this;
718
+ if (self.entryCount === self.entriesRead) {
719
+ setImmediate(function() {
720
+ if (self.autoClose) self.close();
721
+ if (self.emittedError) return;
722
+ self.emit("end");
723
+ });
724
+ return;
725
+ }
726
+ if (self.emittedError) return;
727
+ var buffer = newBuffer(46);
728
+ readAndAssertNoEof(self.reader, buffer, 0, buffer.length, self.readEntryCursor, function(err) {
729
+ if (err) return emitErrorAndAutoClose(self, err);
730
+ if (self.emittedError) return;
731
+ var entry = new Entry();
732
+ var signature = buffer.readUInt32LE(0);
733
+ if (signature !== 33639248) return emitErrorAndAutoClose(self, new Error("invalid central directory file header signature: 0x" + signature.toString(16)));
734
+ entry.versionMadeBy = buffer.readUInt16LE(4);
735
+ entry.versionNeededToExtract = buffer.readUInt16LE(6);
736
+ entry.generalPurposeBitFlag = buffer.readUInt16LE(8);
737
+ entry.compressionMethod = buffer.readUInt16LE(10);
738
+ entry.lastModFileTime = buffer.readUInt16LE(12);
739
+ entry.lastModFileDate = buffer.readUInt16LE(14);
740
+ entry.crc32 = buffer.readUInt32LE(16);
741
+ entry.compressedSize = buffer.readUInt32LE(20);
742
+ entry.uncompressedSize = buffer.readUInt32LE(24);
743
+ entry.fileNameLength = buffer.readUInt16LE(28);
744
+ entry.extraFieldLength = buffer.readUInt16LE(30);
745
+ entry.fileCommentLength = buffer.readUInt16LE(32);
746
+ entry.internalFileAttributes = buffer.readUInt16LE(36);
747
+ entry.externalFileAttributes = buffer.readUInt32LE(38);
748
+ entry.relativeOffsetOfLocalHeader = buffer.readUInt32LE(42);
749
+ if (entry.generalPurposeBitFlag & 64) return emitErrorAndAutoClose(self, new Error("strong encryption is not supported"));
750
+ self.readEntryCursor += 46;
751
+ buffer = newBuffer(entry.fileNameLength + entry.extraFieldLength + entry.fileCommentLength);
752
+ readAndAssertNoEof(self.reader, buffer, 0, buffer.length, self.readEntryCursor, function(err2) {
753
+ if (err2) return emitErrorAndAutoClose(self, err2);
754
+ if (self.emittedError) return;
755
+ entry.fileNameRaw = buffer.subarray(0, entry.fileNameLength);
756
+ var fileCommentStart = entry.fileNameLength + entry.extraFieldLength;
757
+ entry.extraFieldRaw = buffer.subarray(entry.fileNameLength, fileCommentStart);
758
+ entry.fileCommentRaw = buffer.subarray(fileCommentStart, fileCommentStart + entry.fileCommentLength);
759
+ try {
760
+ entry.extraFields = parseExtraFields(entry.extraFieldRaw);
761
+ } catch (err3) {
762
+ return emitErrorAndAutoClose(self, err3);
763
+ }
764
+ if (self.decodeStrings) {
765
+ var isUtf8 = (entry.generalPurposeBitFlag & 2048) !== 0;
766
+ entry.fileComment = decodeBuffer(entry.fileCommentRaw, isUtf8);
767
+ entry.fileName = getFileNameLowLevel(entry.generalPurposeBitFlag, entry.fileNameRaw, entry.extraFields, self.strictFileNames);
768
+ var errorMessage = validateFileName(entry.fileName);
769
+ if (errorMessage != null) return emitErrorAndAutoClose(self, new Error(errorMessage));
770
+ } else {
771
+ entry.fileComment = entry.fileCommentRaw;
772
+ entry.fileName = entry.fileNameRaw;
773
+ }
774
+ entry.comment = entry.fileComment;
775
+ self.readEntryCursor += buffer.length;
776
+ self.entriesRead += 1;
777
+ for (var i = 0; i < entry.extraFields.length; i++) {
778
+ var extraField = entry.extraFields[i];
779
+ if (extraField.id !== 1) continue;
780
+ var zip64EiefBuffer = extraField.data;
781
+ var index = 0;
782
+ if (entry.uncompressedSize === 4294967295) {
783
+ if (index + 8 > zip64EiefBuffer.length) {
784
+ return emitErrorAndAutoClose(self, new Error("zip64 extended information extra field does not include uncompressed size"));
785
+ }
786
+ entry.uncompressedSize = readUInt64LE(zip64EiefBuffer, index);
787
+ index += 8;
788
+ }
789
+ if (entry.compressedSize === 4294967295) {
790
+ if (index + 8 > zip64EiefBuffer.length) {
791
+ return emitErrorAndAutoClose(self, new Error("zip64 extended information extra field does not include compressed size"));
792
+ }
793
+ entry.compressedSize = readUInt64LE(zip64EiefBuffer, index);
794
+ index += 8;
795
+ }
796
+ if (entry.relativeOffsetOfLocalHeader === 4294967295) {
797
+ if (index + 8 > zip64EiefBuffer.length) {
798
+ return emitErrorAndAutoClose(self, new Error("zip64 extended information extra field does not include relative header offset"));
799
+ }
800
+ entry.relativeOffsetOfLocalHeader = readUInt64LE(zip64EiefBuffer, index);
801
+ index += 8;
802
+ }
803
+ break;
804
+ }
805
+ if (self.validateEntrySizes && entry.compressionMethod === 0) {
806
+ var expectedCompressedSize = entry.uncompressedSize;
807
+ if (entry.isEncrypted()) {
808
+ expectedCompressedSize += 12;
809
+ }
810
+ if (entry.compressedSize !== expectedCompressedSize) {
811
+ var msg = "compressed/uncompressed size mismatch for stored file: " + entry.compressedSize + " != " + entry.uncompressedSize;
812
+ return emitErrorAndAutoClose(self, new Error(msg));
813
+ }
814
+ }
815
+ self.emit("entry", entry);
816
+ if (!self.lazyEntries) self._readEntry();
817
+ });
818
+ });
819
+ };
820
+ ZipFile.prototype.eachEntry = function() {
821
+ const self = this;
822
+ if (!self.lazyEntries) throw new Error("eachEntry() requires lazyEntries: true");
823
+ if (self.hasEachEntryBeenCalled) throw new Error("eachEntry() must only be called once per ZipFile");
824
+ self.hasEachEntryBeenCalled = true;
825
+ let pendingResolveReject = null;
826
+ self.on("entry", onEntry);
827
+ self.on("end", onEnd);
828
+ self.on("error", onError);
829
+ function cleanup() {
830
+ self.removeListener("entry", onEntry);
831
+ self.removeListener("end", onEnd);
832
+ self.removeListener("error", onError);
833
+ if (self.autoClose) self.close();
834
+ }
835
+ function onEntry(entry) {
836
+ let { resolve } = pendingResolveReject;
837
+ pendingResolveReject = null;
838
+ resolve({ value: entry });
839
+ }
840
+ function onEnd() {
841
+ let { resolve } = pendingResolveReject;
842
+ pendingResolveReject = null;
843
+ cleanup();
844
+ resolve({ done: true });
845
+ }
846
+ function onError(err) {
847
+ let { reject } = pendingResolveReject;
848
+ pendingResolveReject = null;
849
+ cleanup();
850
+ reject(err);
851
+ }
852
+ return {
853
+ [Symbol.asyncIterator]() {
854
+ return this;
855
+ },
856
+ next() {
857
+ const promise = new Promise((resolve, reject) => {
858
+ if (pendingResolveReject != null) throw new Error("next() called before previous Promise was resolved.");
859
+ pendingResolveReject = { resolve, reject };
860
+ });
861
+ self.readEntry();
862
+ return promise;
863
+ },
864
+ return(value) {
865
+ cleanup();
866
+ return Promise.resolve({ done: true, value });
867
+ },
868
+ throw(value) {
869
+ cleanup();
870
+ return Promise.reject(value);
871
+ }
872
+ };
873
+ };
874
+ ZipFile.prototype.openReadStream = function(entry, options2, callback) {
875
+ var self = this;
876
+ var relativeStart = 0;
877
+ var relativeEnd = entry.compressedSize;
878
+ if (callback == null) {
879
+ callback = options2;
880
+ options2 = null;
881
+ }
882
+ if (options2 == null) {
883
+ options2 = {};
884
+ } else {
885
+ if (options2.decodeFileData === false) {
886
+ if (options2.decrypt != null) {
887
+ throw new Error("cannot use options.decrypt when options.decodeFileData === false");
888
+ }
889
+ if (options2.decompress != null) {
890
+ throw new Error("cannot use options.decompress when options.decodeFileData === false");
891
+ }
892
+ } else {
893
+ if (options2.decrypt != null) {
894
+ if (!entry.isEncrypted()) {
895
+ throw new Error("options.decrypt can only be specified for encrypted entries. See also option decodeFileData.");
896
+ }
897
+ if (options2.decrypt !== false) throw new Error("invalid options.decrypt value: " + options2.decrypt);
898
+ if (entry.isCompressed()) {
899
+ if (options2.decompress !== false) throw new Error("entry is encrypted and compressed, and options.decompress !== false. See also option decodeFileData.");
900
+ }
901
+ }
902
+ if (options2.decompress != null) {
903
+ if (!entry.isCompressed()) {
904
+ throw new Error("options.decompress can only be specified for compressed entries. See also option decodeFileData.");
905
+ }
906
+ if (!(options2.decompress === false || options2.decompress === true)) {
907
+ throw new Error("invalid options.decompress value: " + options2.decompress);
908
+ }
909
+ decompress = options2.decompress;
910
+ }
911
+ }
912
+ if (options2.start != null) {
913
+ relativeStart = options2.start;
914
+ if (relativeStart < 0) throw new Error("options.start < 0");
915
+ if (relativeStart > entry.compressedSize) throw new Error("options.start > entry.compressedSize");
916
+ }
917
+ if (options2.end != null) {
918
+ relativeEnd = options2.end;
919
+ if (relativeEnd < 0) throw new Error("options.end < 0");
920
+ if (relativeEnd > entry.compressedSize) throw new Error("options.end > entry.compressedSize");
921
+ if (relativeEnd < relativeStart) throw new Error("options.end < options.start");
922
+ }
923
+ }
924
+ var rawMode = options2.decodeFileData === false || // Explicitly requested raw.
925
+ (entry.compressionMethod === 0 || // Naturally without compression.
926
+ entry.compressionMethod === 8 && options2.decompress === false) && (!entry.isEncrypted() || // Naturally without encryption.
927
+ options2.decrypt === false);
928
+ if (options2.start != null || options2.end != null) {
929
+ if (!rawMode) throw new Error("start/end range require options.decodeFileData === false for non-trivial encoded entries.");
930
+ }
931
+ if (!self.isOpen) return callback(new Error("closed"));
932
+ if (entry.isEncrypted() && !rawMode) {
933
+ if (options2.decrypt !== false) return callback(new Error("entry is encrypted, and options.decodeFileData !== false"));
934
+ }
935
+ var decompress;
936
+ if (rawMode) {
937
+ decompress = false;
938
+ } else if (entry.compressionMethod === 8) {
939
+ decompress = options2.decodeFileData !== true;
940
+ } else {
941
+ return callback(new Error("unsupported compression method: " + entry.compressionMethod));
942
+ }
943
+ self.readLocalFileHeader(entry, { minimal: true }, function(err, localFileHeader) {
944
+ if (err) return callback(err);
945
+ self.openReadStreamLowLevel(
946
+ localFileHeader.fileDataStart,
947
+ entry.compressedSize,
948
+ relativeStart,
949
+ relativeEnd,
950
+ decompress,
951
+ entry.uncompressedSize,
952
+ callback
953
+ );
954
+ });
955
+ };
956
+ ZipFile.prototype.openReadStreamLowLevel = function(fileDataStart, compressedSize, relativeStart, relativeEnd, decompress, uncompressedSize, callback) {
957
+ var self = this;
958
+ var fileDataEnd = fileDataStart + compressedSize;
959
+ var readStream = self.reader.createReadStream({
960
+ start: fileDataStart + relativeStart,
961
+ end: fileDataStart + relativeEnd
962
+ });
963
+ var endpointStream = readStream;
964
+ if (decompress) {
965
+ var destroyed = false;
966
+ var inflateFilter = zlib.createInflateRaw();
967
+ readStream.on("error", function(err) {
968
+ setImmediate(function() {
969
+ if (!destroyed) inflateFilter.emit("error", err);
970
+ });
971
+ });
972
+ readStream.pipe(inflateFilter);
973
+ if (self.validateEntrySizes) {
974
+ endpointStream = new AssertByteCountStream(uncompressedSize);
975
+ inflateFilter.on("error", function(err) {
976
+ setImmediate(function() {
977
+ if (!destroyed) endpointStream.emit("error", err);
978
+ });
979
+ });
980
+ inflateFilter.pipe(endpointStream);
981
+ } else {
982
+ endpointStream = inflateFilter;
983
+ }
984
+ installDestroyFn(endpointStream, function() {
985
+ destroyed = true;
986
+ if (inflateFilter !== endpointStream) inflateFilter.unpipe(endpointStream);
987
+ readStream.unpipe(inflateFilter);
988
+ readStream.destroy();
989
+ });
990
+ }
991
+ callback(null, endpointStream);
992
+ };
993
+ ZipFile.prototype.readLocalFileHeader = function(entry, options2, callback) {
994
+ var self = this;
995
+ if (callback == null) {
996
+ callback = options2;
997
+ options2 = null;
998
+ }
999
+ if (options2 == null) options2 = {};
1000
+ self.reader.ref();
1001
+ var buffer = newBuffer(30);
1002
+ readAndAssertNoEof(self.reader, buffer, 0, buffer.length, entry.relativeOffsetOfLocalHeader, function(err) {
1003
+ try {
1004
+ if (err) return callback(err);
1005
+ var signature = buffer.readUInt32LE(0);
1006
+ if (signature !== 67324752) {
1007
+ return callback(new Error("invalid local file header signature: 0x" + signature.toString(16)));
1008
+ }
1009
+ var fileNameLength = buffer.readUInt16LE(26);
1010
+ var extraFieldLength = buffer.readUInt16LE(28);
1011
+ var fileDataStart = entry.relativeOffsetOfLocalHeader + 30 + fileNameLength + extraFieldLength;
1012
+ if (fileDataStart + entry.compressedSize > self.fileSize) {
1013
+ return callback(new Error("file data overflows file bounds: " + fileDataStart + " + " + entry.compressedSize + " > " + self.fileSize));
1014
+ }
1015
+ if (options2.minimal) {
1016
+ return callback(null, { fileDataStart });
1017
+ }
1018
+ var localFileHeader = new LocalFileHeader();
1019
+ localFileHeader.fileDataStart = fileDataStart;
1020
+ localFileHeader.versionNeededToExtract = buffer.readUInt16LE(4);
1021
+ localFileHeader.generalPurposeBitFlag = buffer.readUInt16LE(6);
1022
+ localFileHeader.compressionMethod = buffer.readUInt16LE(8);
1023
+ localFileHeader.lastModFileTime = buffer.readUInt16LE(10);
1024
+ localFileHeader.lastModFileDate = buffer.readUInt16LE(12);
1025
+ localFileHeader.crc32 = buffer.readUInt32LE(14);
1026
+ localFileHeader.compressedSize = buffer.readUInt32LE(18);
1027
+ localFileHeader.uncompressedSize = buffer.readUInt32LE(22);
1028
+ localFileHeader.fileNameLength = fileNameLength;
1029
+ localFileHeader.extraFieldLength = extraFieldLength;
1030
+ buffer = newBuffer(fileNameLength + extraFieldLength);
1031
+ self.reader.ref();
1032
+ readAndAssertNoEof(self.reader, buffer, 0, buffer.length, entry.relativeOffsetOfLocalHeader + 30, function(err2) {
1033
+ try {
1034
+ if (err2) return callback(err2);
1035
+ localFileHeader.fileName = buffer.subarray(0, fileNameLength);
1036
+ localFileHeader.extraField = buffer.subarray(fileNameLength);
1037
+ return callback(null, localFileHeader);
1038
+ } finally {
1039
+ self.reader.unref();
1040
+ }
1041
+ });
1042
+ } finally {
1043
+ self.reader.unref();
1044
+ }
1045
+ });
1046
+ };
1047
+ ZipFile.prototype.openReadStreamPromise = function(entry, options2) {
1048
+ return new Promise((resolve, reject) => {
1049
+ this.openReadStream(entry, options2, function(err, readStream) {
1050
+ if (err) return reject(err);
1051
+ resolve(readStream);
1052
+ });
1053
+ });
1054
+ };
1055
+ ZipFile.prototype.openReadStreamLowLevelPromise = function(fileDataStart, compressedSize, relativeStart, relativeEnd, decompress, uncompressedSize) {
1056
+ return new Promise((resolve, reject) => {
1057
+ this.openReadStream(fileDataStart, compressedSize, relativeStart, relativeEnd, decompress, uncompressedSize, function(err, readStream) {
1058
+ if (err) return reject(err);
1059
+ resolve(readStream);
1060
+ });
1061
+ });
1062
+ };
1063
+ ZipFile.prototype.readLocalFileHeaderPromise = function(entry, options2) {
1064
+ return new Promise((resolve, reject) => {
1065
+ this.readLocalFileHeader(entry, options2, function(err, localFileHeader) {
1066
+ if (err) return reject(err);
1067
+ resolve(localFileHeader);
1068
+ });
1069
+ });
1070
+ };
1071
+ function Entry() {
1072
+ }
1073
+ Entry.prototype.getLastModDate = function(options2) {
1074
+ if (options2 == null) options2 = {};
1075
+ if (!options2.forceDosFormat) {
1076
+ for (var i = 0; i < this.extraFields.length; i++) {
1077
+ var extraField = this.extraFields[i];
1078
+ if (extraField.id === 21589) {
1079
+ var data = extraField.data;
1080
+ if (data.length < 5) continue;
1081
+ var flags = data[0];
1082
+ var HAS_MTIME = 1;
1083
+ if (!(flags & HAS_MTIME)) continue;
1084
+ var posixTimestamp = data.readInt32LE(1);
1085
+ return new Date(posixTimestamp * 1e3);
1086
+ } else if (extraField.id === 10) {
1087
+ var data = extraField.data;
1088
+ if (data.length !== 32) continue;
1089
+ if (data.readUInt16LE(4) !== 1) continue;
1090
+ if (data.readUInt16LE(6) !== 24) continue;
1091
+ var hundredNanoSecondsSince1601 = data.readUInt32LE(8) + 4294967296 * data.readInt32LE(12);
1092
+ var millisecondsSince1970 = hundredNanoSecondsSince1601 / 1e4 - 116444736e5;
1093
+ return new Date(millisecondsSince1970);
1094
+ }
1095
+ }
1096
+ }
1097
+ return dosDateTimeToDate(this.lastModFileDate, this.lastModFileTime, options2.timezone);
1098
+ };
1099
+ Entry.prototype.canDecodeFileData = function() {
1100
+ return !this.isEncrypted() && (this.compressionMethod === 0 || this.compressionMethod === 8);
1101
+ };
1102
+ Entry.prototype.isEncrypted = function() {
1103
+ return (this.generalPurposeBitFlag & 1) !== 0;
1104
+ };
1105
+ Entry.prototype.isCompressed = function() {
1106
+ return this.compressionMethod === 8;
1107
+ };
1108
+ function LocalFileHeader() {
1109
+ }
1110
+ function dosDateTimeToDate(date, time, timezone) {
1111
+ var day = date & 31;
1112
+ var month = (date >> 5 & 15) - 1;
1113
+ var year = (date >> 9 & 127) + 1980;
1114
+ var millisecond = 0;
1115
+ var second = (time & 31) * 2;
1116
+ var minute = time >> 5 & 63;
1117
+ var hour = time >> 11 & 31;
1118
+ if (timezone == null || timezone === "local") {
1119
+ return new Date(year, month, day, hour, minute, second, millisecond);
1120
+ } else if (timezone === "UTC") {
1121
+ return new Date(Date.UTC(year, month, day, hour, minute, second, millisecond));
1122
+ } else {
1123
+ throw new Error("unrecognized options.timezone: " + options.timezone);
1124
+ }
1125
+ }
1126
+ function getFileNameLowLevel(generalPurposeBitFlag, fileNameBuffer, extraFields, strictFileNames) {
1127
+ var fileName = null;
1128
+ for (var i = 0; i < extraFields.length; i++) {
1129
+ var extraField = extraFields[i];
1130
+ if (extraField.id === 28789) {
1131
+ if (extraField.data.length < 6) {
1132
+ continue;
1133
+ }
1134
+ if (extraField.data.readUInt8(0) !== 1) {
1135
+ continue;
1136
+ }
1137
+ var oldNameCrc32 = extraField.data.readUInt32LE(1);
1138
+ if (crc32(fileNameBuffer) !== oldNameCrc32) {
1139
+ continue;
1140
+ }
1141
+ fileName = decodeBuffer(extraField.data.subarray(5), true);
1142
+ break;
1143
+ }
1144
+ }
1145
+ if (fileName == null) {
1146
+ var isUtf8 = (generalPurposeBitFlag & 2048) !== 0;
1147
+ fileName = decodeBuffer(fileNameBuffer, isUtf8);
1148
+ }
1149
+ if (!strictFileNames) {
1150
+ fileName = fileName.replace(/\\/g, "/");
1151
+ }
1152
+ return fileName;
1153
+ }
1154
+ function validateFileName(fileName) {
1155
+ if (fileName.indexOf("\\") !== -1) {
1156
+ return "invalid characters in fileName: " + fileName;
1157
+ }
1158
+ if (/^[a-zA-Z]:/.test(fileName) || /^\//.test(fileName)) {
1159
+ return "absolute path: " + fileName;
1160
+ }
1161
+ if (fileName.split("/").indexOf("..") !== -1) {
1162
+ return "invalid relative path: " + fileName;
1163
+ }
1164
+ return null;
1165
+ }
1166
+ function parseExtraFields(extraFieldBuffer) {
1167
+ var extraFields = [];
1168
+ var i = 0;
1169
+ while (i < extraFieldBuffer.length - 3) {
1170
+ var headerId = extraFieldBuffer.readUInt16LE(i + 0);
1171
+ var dataSize = extraFieldBuffer.readUInt16LE(i + 2);
1172
+ var dataStart = i + 4;
1173
+ var dataEnd = dataStart + dataSize;
1174
+ if (dataEnd > extraFieldBuffer.length) throw new Error("extra field length exceeds extra field buffer size");
1175
+ var dataBuffer = extraFieldBuffer.subarray(dataStart, dataEnd);
1176
+ extraFields.push({
1177
+ id: headerId,
1178
+ data: dataBuffer
1179
+ });
1180
+ i = dataEnd;
1181
+ }
1182
+ return extraFields;
1183
+ }
1184
+ function readAndAssertNoEof(reader, buffer, offset, length, position, callback) {
1185
+ if (length === 0) {
1186
+ return setImmediate(function() {
1187
+ callback(null, newBuffer(0));
1188
+ });
1189
+ }
1190
+ reader.read(buffer, offset, length, position, function(err, bytesRead) {
1191
+ if (err) return callback(err);
1192
+ if (bytesRead < length) {
1193
+ return callback(new Error("unexpected EOF"));
1194
+ }
1195
+ callback();
1196
+ });
1197
+ }
1198
+ util.inherits(AssertByteCountStream, Transform);
1199
+ function AssertByteCountStream(byteCount) {
1200
+ Transform.call(this);
1201
+ this.actualByteCount = 0;
1202
+ this.expectedByteCount = byteCount;
1203
+ }
1204
+ AssertByteCountStream.prototype._transform = function(chunk, encoding, cb) {
1205
+ this.actualByteCount += chunk.length;
1206
+ if (this.actualByteCount > this.expectedByteCount) {
1207
+ var msg = "too many bytes in the stream. expected " + this.expectedByteCount + ". got at least " + this.actualByteCount;
1208
+ return cb(new Error(msg));
1209
+ }
1210
+ cb(null, chunk);
1211
+ };
1212
+ AssertByteCountStream.prototype._flush = function(cb) {
1213
+ if (this.actualByteCount < this.expectedByteCount) {
1214
+ var msg = "not enough bytes in the stream. expected " + this.expectedByteCount + ". got only " + this.actualByteCount;
1215
+ return cb(new Error(msg));
1216
+ }
1217
+ cb();
1218
+ };
1219
+ util.inherits(RandomAccessReader, EventEmitter);
1220
+ function RandomAccessReader() {
1221
+ EventEmitter.call(this);
1222
+ this.refCount = 0;
1223
+ }
1224
+ RandomAccessReader.prototype.ref = function() {
1225
+ this.refCount += 1;
1226
+ };
1227
+ RandomAccessReader.prototype.unref = function() {
1228
+ var self = this;
1229
+ self.refCount -= 1;
1230
+ if (self.refCount > 0) return;
1231
+ if (self.refCount < 0) throw new Error("invalid unref");
1232
+ self.close(onCloseDone);
1233
+ function onCloseDone(err) {
1234
+ if (err) return self.emit("error", err);
1235
+ self.emit("close");
1236
+ }
1237
+ };
1238
+ RandomAccessReader.prototype.createReadStream = function(options2) {
1239
+ if (options2 == null) options2 = {};
1240
+ var start = options2.start;
1241
+ var end = options2.end;
1242
+ if (start === end) {
1243
+ var emptyStream = new PassThrough();
1244
+ setImmediate(function() {
1245
+ emptyStream.end();
1246
+ });
1247
+ return emptyStream;
1248
+ }
1249
+ var stream = this._readStreamForRange(start, end);
1250
+ var destroyed = false;
1251
+ var refUnrefFilter = new RefUnrefFilter(this);
1252
+ stream.on("error", function(err) {
1253
+ setImmediate(function() {
1254
+ if (!destroyed) refUnrefFilter.emit("error", err);
1255
+ });
1256
+ });
1257
+ installDestroyFn(refUnrefFilter, function() {
1258
+ stream.unpipe(refUnrefFilter);
1259
+ refUnrefFilter.unref();
1260
+ stream.destroy();
1261
+ });
1262
+ var byteCounter = new AssertByteCountStream(end - start);
1263
+ refUnrefFilter.on("error", function(err) {
1264
+ setImmediate(function() {
1265
+ if (!destroyed) byteCounter.emit("error", err);
1266
+ });
1267
+ });
1268
+ installDestroyFn(byteCounter, function() {
1269
+ destroyed = true;
1270
+ refUnrefFilter.unpipe(byteCounter);
1271
+ refUnrefFilter.destroy();
1272
+ });
1273
+ return stream.pipe(refUnrefFilter).pipe(byteCounter);
1274
+ };
1275
+ RandomAccessReader.prototype._readStreamForRange = function(start, end) {
1276
+ throw new Error("not implemented");
1277
+ };
1278
+ RandomAccessReader.prototype.read = function(buffer, offset, length, position, callback) {
1279
+ var readStream = this.createReadStream({ start: position, end: position + length });
1280
+ var writeStream = new Writable();
1281
+ var written = 0;
1282
+ writeStream._write = function(chunk, encoding, cb) {
1283
+ chunk.copy(buffer, offset + written, 0, chunk.length);
1284
+ written += chunk.length;
1285
+ cb();
1286
+ };
1287
+ writeStream.on("finish", callback);
1288
+ readStream.on("error", function(error) {
1289
+ callback(error);
1290
+ });
1291
+ readStream.pipe(writeStream);
1292
+ };
1293
+ RandomAccessReader.prototype.close = function(callback) {
1294
+ setImmediate(callback);
1295
+ };
1296
+ util.inherits(RefUnrefFilter, PassThrough);
1297
+ function RefUnrefFilter(context) {
1298
+ PassThrough.call(this);
1299
+ this.context = context;
1300
+ this.context.ref();
1301
+ this.unreffedYet = false;
1302
+ }
1303
+ RefUnrefFilter.prototype._flush = function(cb) {
1304
+ this.unref();
1305
+ cb();
1306
+ };
1307
+ RefUnrefFilter.prototype.unref = function(cb) {
1308
+ if (this.unreffedYet) return;
1309
+ this.unreffedYet = true;
1310
+ this.context.unref();
1311
+ };
1312
+ var cp437 = "\0\u263A\u263B\u2665\u2666\u2663\u2660\u2022\u25D8\u25CB\u25D9\u2642\u2640\u266A\u266B\u263C\u25BA\u25C4\u2195\u203C\xB6\xA7\u25AC\u21A8\u2191\u2193\u2192\u2190\u221F\u2194\u25B2\u25BC !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u2302\xC7\xFC\xE9\xE2\xE4\xE0\xE5\xE7\xEA\xEB\xE8\xEF\xEE\xEC\xC4\xC5\xC9\xE6\xC6\xF4\xF6\xF2\xFB\xF9\xFF\xD6\xDC\xA2\xA3\xA5\u20A7\u0192\xE1\xED\xF3\xFA\xF1\xD1\xAA\xBA\xBF\u2310\xAC\xBD\xBC\xA1\xAB\xBB\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u03B1\xDF\u0393\u03C0\u03A3\u03C3\xB5\u03C4\u03A6\u0398\u03A9\u03B4\u221E\u03C6\u03B5\u2229\u2261\xB1\u2265\u2264\u2320\u2321\xF7\u2248\xB0\u2219\xB7\u221A\u207F\xB2\u25A0\xA0";
1313
+ function decodeBuffer(buffer, isUtf8) {
1314
+ if (isUtf8) {
1315
+ return buffer.toString("utf8");
1316
+ } else {
1317
+ var result = "";
1318
+ for (var i = 0; i < buffer.length; i++) {
1319
+ result += cp437[buffer[i]];
1320
+ }
1321
+ return result;
1322
+ }
1323
+ }
1324
+ function readUInt64LE(buffer, offset) {
1325
+ var lower32 = buffer.readUInt32LE(offset);
1326
+ var upper32 = buffer.readUInt32LE(offset + 4);
1327
+ return upper32 * 4294967296 + lower32;
1328
+ }
1329
+ var newBuffer;
1330
+ if (typeof Buffer.allocUnsafe === "function") {
1331
+ newBuffer = function(len) {
1332
+ return Buffer.allocUnsafe(len);
1333
+ };
1334
+ } else {
1335
+ newBuffer = function(len) {
1336
+ return new Buffer(len);
1337
+ };
1338
+ }
1339
+ function installDestroyFn(stream, fn) {
1340
+ if (typeof stream.destroy === "function") {
1341
+ stream._destroy = function(err, cb) {
1342
+ fn();
1343
+ if (cb != null) cb(err);
1344
+ };
1345
+ } else {
1346
+ stream.destroy = fn;
1347
+ }
1348
+ }
1349
+ function defaultCallback(err) {
1350
+ if (err) throw err;
1351
+ }
1352
+ }
1353
+ });
1354
+ export default require_yauzl();
1355
+ //# sourceMappingURL=yauzl-7KG7KPPF.js.map