claude-presentation-master 3.8.5 → 3.8.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/BrowserWebSocketTransport-HTFZUK6G.mjs +7 -0
- package/dist/LaunchOptions-SFJP2D7Z.mjs +9 -0
- package/dist/NodeWebSocketTransport-RBVOEJLR.mjs +8 -0
- package/dist/bidi-BVFTPINL.mjs +18501 -0
- package/dist/chunk-3UL3L2R6.mjs +30 -0
- package/dist/chunk-4MOE77QU.mjs +1661 -0
- package/dist/chunk-5NJVL3OH.mjs +31312 -0
- package/dist/chunk-5TVEOHFT.mjs +244 -0
- package/dist/chunk-6D5VEPNW.mjs +12104 -0
- package/dist/chunk-CFGGYLHX.mjs +3684 -0
- package/dist/chunk-EC7LFFYG.mjs +15 -0
- package/dist/chunk-HEBXNMVQ.mjs +48 -0
- package/dist/chunk-KJPJW5EB.mjs +40 -0
- package/dist/chunk-QUYDTLMJ.mjs +775 -0
- package/dist/extract-zip-UJUIS3MT.mjs +1499 -0
- package/dist/helpers-GOUCEJ3S.mjs +17 -0
- package/dist/index.d.mts +36 -3
- package/dist/index.d.ts +36 -3
- package/dist/index.js +92418 -213
- package/dist/index.mjs +350 -30
- package/dist/main-GWERC3XX.mjs +56 -0
- package/dist/puppeteer-EG4MVFUF.mjs +14961 -0
- package/dist/src-HTL2N5EV.mjs +5 -0
- package/dist/tar-fs-NIVQWNBX.mjs +2562 -0
- package/dist/yargs-COGWK7P3.mjs +3230 -0
- package/package.json +1 -1
|
@@ -0,0 +1,1499 @@
|
|
|
1
|
+
import {
|
|
2
|
+
require_src
|
|
3
|
+
} from "./chunk-QUYDTLMJ.mjs";
|
|
4
|
+
import {
|
|
5
|
+
require_pump
|
|
6
|
+
} from "./chunk-5TVEOHFT.mjs";
|
|
7
|
+
import {
|
|
8
|
+
__commonJS,
|
|
9
|
+
__require
|
|
10
|
+
} from "./chunk-HEBXNMVQ.mjs";
|
|
11
|
+
|
|
12
|
+
// node_modules/extract-zip/node_modules/get-stream/buffer-stream.js
|
|
13
|
+
var require_buffer_stream = __commonJS({
|
|
14
|
+
"node_modules/extract-zip/node_modules/get-stream/buffer-stream.js"(exports, module) {
|
|
15
|
+
"use strict";
|
|
16
|
+
var { PassThrough: PassThroughStream } = __require("stream");
|
|
17
|
+
module.exports = (options) => {
|
|
18
|
+
options = { ...options };
|
|
19
|
+
const { array } = options;
|
|
20
|
+
let { encoding } = options;
|
|
21
|
+
const isBuffer = encoding === "buffer";
|
|
22
|
+
let objectMode = false;
|
|
23
|
+
if (array) {
|
|
24
|
+
objectMode = !(encoding || isBuffer);
|
|
25
|
+
} else {
|
|
26
|
+
encoding = encoding || "utf8";
|
|
27
|
+
}
|
|
28
|
+
if (isBuffer) {
|
|
29
|
+
encoding = null;
|
|
30
|
+
}
|
|
31
|
+
const stream = new PassThroughStream({ objectMode });
|
|
32
|
+
if (encoding) {
|
|
33
|
+
stream.setEncoding(encoding);
|
|
34
|
+
}
|
|
35
|
+
let length = 0;
|
|
36
|
+
const chunks = [];
|
|
37
|
+
stream.on("data", (chunk) => {
|
|
38
|
+
chunks.push(chunk);
|
|
39
|
+
if (objectMode) {
|
|
40
|
+
length = chunks.length;
|
|
41
|
+
} else {
|
|
42
|
+
length += chunk.length;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
stream.getBufferedValue = () => {
|
|
46
|
+
if (array) {
|
|
47
|
+
return chunks;
|
|
48
|
+
}
|
|
49
|
+
return isBuffer ? Buffer.concat(chunks, length) : chunks.join("");
|
|
50
|
+
};
|
|
51
|
+
stream.getBufferedLength = () => length;
|
|
52
|
+
return stream;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
// node_modules/extract-zip/node_modules/get-stream/index.js
|
|
58
|
+
var require_get_stream = __commonJS({
|
|
59
|
+
"node_modules/extract-zip/node_modules/get-stream/index.js"(exports, module) {
|
|
60
|
+
"use strict";
|
|
61
|
+
var { constants: BufferConstants } = __require("buffer");
|
|
62
|
+
var pump = require_pump();
|
|
63
|
+
var bufferStream = require_buffer_stream();
|
|
64
|
+
var MaxBufferError = class extends Error {
|
|
65
|
+
constructor() {
|
|
66
|
+
super("maxBuffer exceeded");
|
|
67
|
+
this.name = "MaxBufferError";
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
async function getStream(inputStream, options) {
|
|
71
|
+
if (!inputStream) {
|
|
72
|
+
return Promise.reject(new Error("Expected a stream"));
|
|
73
|
+
}
|
|
74
|
+
options = {
|
|
75
|
+
maxBuffer: Infinity,
|
|
76
|
+
...options
|
|
77
|
+
};
|
|
78
|
+
const { maxBuffer } = options;
|
|
79
|
+
let stream;
|
|
80
|
+
await new Promise((resolve, reject) => {
|
|
81
|
+
const rejectPromise = (error) => {
|
|
82
|
+
if (error && stream.getBufferedLength() <= BufferConstants.MAX_LENGTH) {
|
|
83
|
+
error.bufferedData = stream.getBufferedValue();
|
|
84
|
+
}
|
|
85
|
+
reject(error);
|
|
86
|
+
};
|
|
87
|
+
stream = pump(inputStream, bufferStream(options), (error) => {
|
|
88
|
+
if (error) {
|
|
89
|
+
rejectPromise(error);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
resolve();
|
|
93
|
+
});
|
|
94
|
+
stream.on("data", () => {
|
|
95
|
+
if (stream.getBufferedLength() > maxBuffer) {
|
|
96
|
+
rejectPromise(new MaxBufferError());
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
return stream.getBufferedValue();
|
|
101
|
+
}
|
|
102
|
+
module.exports = getStream;
|
|
103
|
+
module.exports.default = getStream;
|
|
104
|
+
module.exports.buffer = (stream, options) => getStream(stream, { ...options, encoding: "buffer" });
|
|
105
|
+
module.exports.array = (stream, options) => getStream(stream, { ...options, array: true });
|
|
106
|
+
module.exports.MaxBufferError = MaxBufferError;
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
// node_modules/pend/index.js
|
|
111
|
+
var require_pend = __commonJS({
|
|
112
|
+
"node_modules/pend/index.js"(exports, module) {
|
|
113
|
+
"use strict";
|
|
114
|
+
module.exports = Pend;
|
|
115
|
+
function Pend() {
|
|
116
|
+
this.pending = 0;
|
|
117
|
+
this.max = Infinity;
|
|
118
|
+
this.listeners = [];
|
|
119
|
+
this.waiting = [];
|
|
120
|
+
this.error = null;
|
|
121
|
+
}
|
|
122
|
+
Pend.prototype.go = function(fn) {
|
|
123
|
+
if (this.pending < this.max) {
|
|
124
|
+
pendGo(this, fn);
|
|
125
|
+
} else {
|
|
126
|
+
this.waiting.push(fn);
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
Pend.prototype.wait = function(cb) {
|
|
130
|
+
if (this.pending === 0) {
|
|
131
|
+
cb(this.error);
|
|
132
|
+
} else {
|
|
133
|
+
this.listeners.push(cb);
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
Pend.prototype.hold = function() {
|
|
137
|
+
return pendHold(this);
|
|
138
|
+
};
|
|
139
|
+
function pendHold(self) {
|
|
140
|
+
self.pending += 1;
|
|
141
|
+
var called = false;
|
|
142
|
+
return onCb;
|
|
143
|
+
function onCb(err) {
|
|
144
|
+
if (called) throw new Error("callback called twice");
|
|
145
|
+
called = true;
|
|
146
|
+
self.error = self.error || err;
|
|
147
|
+
self.pending -= 1;
|
|
148
|
+
if (self.waiting.length > 0 && self.pending < self.max) {
|
|
149
|
+
pendGo(self, self.waiting.shift());
|
|
150
|
+
} else if (self.pending === 0) {
|
|
151
|
+
var listeners = self.listeners;
|
|
152
|
+
self.listeners = [];
|
|
153
|
+
listeners.forEach(cbListener);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
function cbListener(listener) {
|
|
157
|
+
listener(self.error);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
function pendGo(self, fn) {
|
|
161
|
+
fn(pendHold(self));
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
// node_modules/fd-slicer/index.js
|
|
167
|
+
var require_fd_slicer = __commonJS({
|
|
168
|
+
"node_modules/fd-slicer/index.js"(exports) {
|
|
169
|
+
"use strict";
|
|
170
|
+
var fs = __require("fs");
|
|
171
|
+
var util = __require("util");
|
|
172
|
+
var stream = __require("stream");
|
|
173
|
+
var Readable = stream.Readable;
|
|
174
|
+
var Writable = stream.Writable;
|
|
175
|
+
var PassThrough = stream.PassThrough;
|
|
176
|
+
var Pend = require_pend();
|
|
177
|
+
var EventEmitter = __require("events").EventEmitter;
|
|
178
|
+
exports.createFromBuffer = createFromBuffer;
|
|
179
|
+
exports.createFromFd = createFromFd;
|
|
180
|
+
exports.BufferSlicer = BufferSlicer;
|
|
181
|
+
exports.FdSlicer = FdSlicer;
|
|
182
|
+
util.inherits(FdSlicer, EventEmitter);
|
|
183
|
+
function FdSlicer(fd, options) {
|
|
184
|
+
options = options || {};
|
|
185
|
+
EventEmitter.call(this);
|
|
186
|
+
this.fd = fd;
|
|
187
|
+
this.pend = new Pend();
|
|
188
|
+
this.pend.max = 1;
|
|
189
|
+
this.refCount = 0;
|
|
190
|
+
this.autoClose = !!options.autoClose;
|
|
191
|
+
}
|
|
192
|
+
FdSlicer.prototype.read = function(buffer, offset, length, position, callback) {
|
|
193
|
+
var self = this;
|
|
194
|
+
self.pend.go(function(cb) {
|
|
195
|
+
fs.read(self.fd, buffer, offset, length, position, function(err, bytesRead, buffer2) {
|
|
196
|
+
cb();
|
|
197
|
+
callback(err, bytesRead, buffer2);
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
};
|
|
201
|
+
FdSlicer.prototype.write = function(buffer, offset, length, position, callback) {
|
|
202
|
+
var self = this;
|
|
203
|
+
self.pend.go(function(cb) {
|
|
204
|
+
fs.write(self.fd, buffer, offset, length, position, function(err, written, buffer2) {
|
|
205
|
+
cb();
|
|
206
|
+
callback(err, written, buffer2);
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
};
|
|
210
|
+
FdSlicer.prototype.createReadStream = function(options) {
|
|
211
|
+
return new ReadStream(this, options);
|
|
212
|
+
};
|
|
213
|
+
FdSlicer.prototype.createWriteStream = function(options) {
|
|
214
|
+
return new WriteStream(this, options);
|
|
215
|
+
};
|
|
216
|
+
FdSlicer.prototype.ref = function() {
|
|
217
|
+
this.refCount += 1;
|
|
218
|
+
};
|
|
219
|
+
FdSlicer.prototype.unref = function() {
|
|
220
|
+
var self = this;
|
|
221
|
+
self.refCount -= 1;
|
|
222
|
+
if (self.refCount > 0) return;
|
|
223
|
+
if (self.refCount < 0) throw new Error("invalid unref");
|
|
224
|
+
if (self.autoClose) {
|
|
225
|
+
fs.close(self.fd, onCloseDone);
|
|
226
|
+
}
|
|
227
|
+
function onCloseDone(err) {
|
|
228
|
+
if (err) {
|
|
229
|
+
self.emit("error", err);
|
|
230
|
+
} else {
|
|
231
|
+
self.emit("close");
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
util.inherits(ReadStream, Readable);
|
|
236
|
+
function ReadStream(context, options) {
|
|
237
|
+
options = options || {};
|
|
238
|
+
Readable.call(this, options);
|
|
239
|
+
this.context = context;
|
|
240
|
+
this.context.ref();
|
|
241
|
+
this.start = options.start || 0;
|
|
242
|
+
this.endOffset = options.end;
|
|
243
|
+
this.pos = this.start;
|
|
244
|
+
this.destroyed = false;
|
|
245
|
+
}
|
|
246
|
+
ReadStream.prototype._read = function(n) {
|
|
247
|
+
var self = this;
|
|
248
|
+
if (self.destroyed) return;
|
|
249
|
+
var toRead = Math.min(self._readableState.highWaterMark, n);
|
|
250
|
+
if (self.endOffset != null) {
|
|
251
|
+
toRead = Math.min(toRead, self.endOffset - self.pos);
|
|
252
|
+
}
|
|
253
|
+
if (toRead <= 0) {
|
|
254
|
+
self.destroyed = true;
|
|
255
|
+
self.push(null);
|
|
256
|
+
self.context.unref();
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
self.context.pend.go(function(cb) {
|
|
260
|
+
if (self.destroyed) return cb();
|
|
261
|
+
var buffer = new Buffer(toRead);
|
|
262
|
+
fs.read(self.context.fd, buffer, 0, toRead, self.pos, function(err, bytesRead) {
|
|
263
|
+
if (err) {
|
|
264
|
+
self.destroy(err);
|
|
265
|
+
} else if (bytesRead === 0) {
|
|
266
|
+
self.destroyed = true;
|
|
267
|
+
self.push(null);
|
|
268
|
+
self.context.unref();
|
|
269
|
+
} else {
|
|
270
|
+
self.pos += bytesRead;
|
|
271
|
+
self.push(buffer.slice(0, bytesRead));
|
|
272
|
+
}
|
|
273
|
+
cb();
|
|
274
|
+
});
|
|
275
|
+
});
|
|
276
|
+
};
|
|
277
|
+
ReadStream.prototype.destroy = function(err) {
|
|
278
|
+
if (this.destroyed) return;
|
|
279
|
+
err = err || new Error("stream destroyed");
|
|
280
|
+
this.destroyed = true;
|
|
281
|
+
this.emit("error", err);
|
|
282
|
+
this.context.unref();
|
|
283
|
+
};
|
|
284
|
+
util.inherits(WriteStream, Writable);
|
|
285
|
+
function WriteStream(context, options) {
|
|
286
|
+
options = options || {};
|
|
287
|
+
Writable.call(this, options);
|
|
288
|
+
this.context = context;
|
|
289
|
+
this.context.ref();
|
|
290
|
+
this.start = options.start || 0;
|
|
291
|
+
this.endOffset = options.end == null ? Infinity : +options.end;
|
|
292
|
+
this.bytesWritten = 0;
|
|
293
|
+
this.pos = this.start;
|
|
294
|
+
this.destroyed = false;
|
|
295
|
+
this.on("finish", this.destroy.bind(this));
|
|
296
|
+
}
|
|
297
|
+
WriteStream.prototype._write = function(buffer, encoding, callback) {
|
|
298
|
+
var self = this;
|
|
299
|
+
if (self.destroyed) return;
|
|
300
|
+
if (self.pos + buffer.length > self.endOffset) {
|
|
301
|
+
var err = new Error("maximum file length exceeded");
|
|
302
|
+
err.code = "ETOOBIG";
|
|
303
|
+
self.destroy();
|
|
304
|
+
callback(err);
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
self.context.pend.go(function(cb) {
|
|
308
|
+
if (self.destroyed) return cb();
|
|
309
|
+
fs.write(self.context.fd, buffer, 0, buffer.length, self.pos, function(err2, bytes) {
|
|
310
|
+
if (err2) {
|
|
311
|
+
self.destroy();
|
|
312
|
+
cb();
|
|
313
|
+
callback(err2);
|
|
314
|
+
} else {
|
|
315
|
+
self.bytesWritten += bytes;
|
|
316
|
+
self.pos += bytes;
|
|
317
|
+
self.emit("progress");
|
|
318
|
+
cb();
|
|
319
|
+
callback();
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
});
|
|
323
|
+
};
|
|
324
|
+
WriteStream.prototype.destroy = function() {
|
|
325
|
+
if (this.destroyed) return;
|
|
326
|
+
this.destroyed = true;
|
|
327
|
+
this.context.unref();
|
|
328
|
+
};
|
|
329
|
+
util.inherits(BufferSlicer, EventEmitter);
|
|
330
|
+
function BufferSlicer(buffer, options) {
|
|
331
|
+
EventEmitter.call(this);
|
|
332
|
+
options = options || {};
|
|
333
|
+
this.refCount = 0;
|
|
334
|
+
this.buffer = buffer;
|
|
335
|
+
this.maxChunkSize = options.maxChunkSize || Number.MAX_SAFE_INTEGER;
|
|
336
|
+
}
|
|
337
|
+
BufferSlicer.prototype.read = function(buffer, offset, length, position, callback) {
|
|
338
|
+
var end = position + length;
|
|
339
|
+
var delta = end - this.buffer.length;
|
|
340
|
+
var written = delta > 0 ? delta : length;
|
|
341
|
+
this.buffer.copy(buffer, offset, position, end);
|
|
342
|
+
setImmediate(function() {
|
|
343
|
+
callback(null, written);
|
|
344
|
+
});
|
|
345
|
+
};
|
|
346
|
+
BufferSlicer.prototype.write = function(buffer, offset, length, position, callback) {
|
|
347
|
+
buffer.copy(this.buffer, position, offset, offset + length);
|
|
348
|
+
setImmediate(function() {
|
|
349
|
+
callback(null, length, buffer);
|
|
350
|
+
});
|
|
351
|
+
};
|
|
352
|
+
BufferSlicer.prototype.createReadStream = function(options) {
|
|
353
|
+
options = options || {};
|
|
354
|
+
var readStream = new PassThrough(options);
|
|
355
|
+
readStream.destroyed = false;
|
|
356
|
+
readStream.start = options.start || 0;
|
|
357
|
+
readStream.endOffset = options.end;
|
|
358
|
+
readStream.pos = readStream.endOffset || this.buffer.length;
|
|
359
|
+
var entireSlice = this.buffer.slice(readStream.start, readStream.pos);
|
|
360
|
+
var offset = 0;
|
|
361
|
+
while (true) {
|
|
362
|
+
var nextOffset = offset + this.maxChunkSize;
|
|
363
|
+
if (nextOffset >= entireSlice.length) {
|
|
364
|
+
if (offset < entireSlice.length) {
|
|
365
|
+
readStream.write(entireSlice.slice(offset, entireSlice.length));
|
|
366
|
+
}
|
|
367
|
+
break;
|
|
368
|
+
}
|
|
369
|
+
readStream.write(entireSlice.slice(offset, nextOffset));
|
|
370
|
+
offset = nextOffset;
|
|
371
|
+
}
|
|
372
|
+
readStream.end();
|
|
373
|
+
readStream.destroy = function() {
|
|
374
|
+
readStream.destroyed = true;
|
|
375
|
+
};
|
|
376
|
+
return readStream;
|
|
377
|
+
};
|
|
378
|
+
BufferSlicer.prototype.createWriteStream = function(options) {
|
|
379
|
+
var bufferSlicer = this;
|
|
380
|
+
options = options || {};
|
|
381
|
+
var writeStream = new Writable(options);
|
|
382
|
+
writeStream.start = options.start || 0;
|
|
383
|
+
writeStream.endOffset = options.end == null ? this.buffer.length : +options.end;
|
|
384
|
+
writeStream.bytesWritten = 0;
|
|
385
|
+
writeStream.pos = writeStream.start;
|
|
386
|
+
writeStream.destroyed = false;
|
|
387
|
+
writeStream._write = function(buffer, encoding, callback) {
|
|
388
|
+
if (writeStream.destroyed) return;
|
|
389
|
+
var end = writeStream.pos + buffer.length;
|
|
390
|
+
if (end > writeStream.endOffset) {
|
|
391
|
+
var err = new Error("maximum file length exceeded");
|
|
392
|
+
err.code = "ETOOBIG";
|
|
393
|
+
writeStream.destroyed = true;
|
|
394
|
+
callback(err);
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
buffer.copy(bufferSlicer.buffer, writeStream.pos, 0, buffer.length);
|
|
398
|
+
writeStream.bytesWritten += buffer.length;
|
|
399
|
+
writeStream.pos = end;
|
|
400
|
+
writeStream.emit("progress");
|
|
401
|
+
callback();
|
|
402
|
+
};
|
|
403
|
+
writeStream.destroy = function() {
|
|
404
|
+
writeStream.destroyed = true;
|
|
405
|
+
};
|
|
406
|
+
return writeStream;
|
|
407
|
+
};
|
|
408
|
+
BufferSlicer.prototype.ref = function() {
|
|
409
|
+
this.refCount += 1;
|
|
410
|
+
};
|
|
411
|
+
BufferSlicer.prototype.unref = function() {
|
|
412
|
+
this.refCount -= 1;
|
|
413
|
+
if (this.refCount < 0) {
|
|
414
|
+
throw new Error("invalid unref");
|
|
415
|
+
}
|
|
416
|
+
};
|
|
417
|
+
function createFromBuffer(buffer, options) {
|
|
418
|
+
return new BufferSlicer(buffer, options);
|
|
419
|
+
}
|
|
420
|
+
function createFromFd(fd, options) {
|
|
421
|
+
return new FdSlicer(fd, options);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
});
|
|
425
|
+
|
|
426
|
+
// node_modules/buffer-crc32/index.js
|
|
427
|
+
var require_buffer_crc32 = __commonJS({
|
|
428
|
+
"node_modules/buffer-crc32/index.js"(exports, module) {
|
|
429
|
+
"use strict";
|
|
430
|
+
var Buffer2 = __require("buffer").Buffer;
|
|
431
|
+
var CRC_TABLE = [
|
|
432
|
+
0,
|
|
433
|
+
1996959894,
|
|
434
|
+
3993919788,
|
|
435
|
+
2567524794,
|
|
436
|
+
124634137,
|
|
437
|
+
1886057615,
|
|
438
|
+
3915621685,
|
|
439
|
+
2657392035,
|
|
440
|
+
249268274,
|
|
441
|
+
2044508324,
|
|
442
|
+
3772115230,
|
|
443
|
+
2547177864,
|
|
444
|
+
162941995,
|
|
445
|
+
2125561021,
|
|
446
|
+
3887607047,
|
|
447
|
+
2428444049,
|
|
448
|
+
498536548,
|
|
449
|
+
1789927666,
|
|
450
|
+
4089016648,
|
|
451
|
+
2227061214,
|
|
452
|
+
450548861,
|
|
453
|
+
1843258603,
|
|
454
|
+
4107580753,
|
|
455
|
+
2211677639,
|
|
456
|
+
325883990,
|
|
457
|
+
1684777152,
|
|
458
|
+
4251122042,
|
|
459
|
+
2321926636,
|
|
460
|
+
335633487,
|
|
461
|
+
1661365465,
|
|
462
|
+
4195302755,
|
|
463
|
+
2366115317,
|
|
464
|
+
997073096,
|
|
465
|
+
1281953886,
|
|
466
|
+
3579855332,
|
|
467
|
+
2724688242,
|
|
468
|
+
1006888145,
|
|
469
|
+
1258607687,
|
|
470
|
+
3524101629,
|
|
471
|
+
2768942443,
|
|
472
|
+
901097722,
|
|
473
|
+
1119000684,
|
|
474
|
+
3686517206,
|
|
475
|
+
2898065728,
|
|
476
|
+
853044451,
|
|
477
|
+
1172266101,
|
|
478
|
+
3705015759,
|
|
479
|
+
2882616665,
|
|
480
|
+
651767980,
|
|
481
|
+
1373503546,
|
|
482
|
+
3369554304,
|
|
483
|
+
3218104598,
|
|
484
|
+
565507253,
|
|
485
|
+
1454621731,
|
|
486
|
+
3485111705,
|
|
487
|
+
3099436303,
|
|
488
|
+
671266974,
|
|
489
|
+
1594198024,
|
|
490
|
+
3322730930,
|
|
491
|
+
2970347812,
|
|
492
|
+
795835527,
|
|
493
|
+
1483230225,
|
|
494
|
+
3244367275,
|
|
495
|
+
3060149565,
|
|
496
|
+
1994146192,
|
|
497
|
+
31158534,
|
|
498
|
+
2563907772,
|
|
499
|
+
4023717930,
|
|
500
|
+
1907459465,
|
|
501
|
+
112637215,
|
|
502
|
+
2680153253,
|
|
503
|
+
3904427059,
|
|
504
|
+
2013776290,
|
|
505
|
+
251722036,
|
|
506
|
+
2517215374,
|
|
507
|
+
3775830040,
|
|
508
|
+
2137656763,
|
|
509
|
+
141376813,
|
|
510
|
+
2439277719,
|
|
511
|
+
3865271297,
|
|
512
|
+
1802195444,
|
|
513
|
+
476864866,
|
|
514
|
+
2238001368,
|
|
515
|
+
4066508878,
|
|
516
|
+
1812370925,
|
|
517
|
+
453092731,
|
|
518
|
+
2181625025,
|
|
519
|
+
4111451223,
|
|
520
|
+
1706088902,
|
|
521
|
+
314042704,
|
|
522
|
+
2344532202,
|
|
523
|
+
4240017532,
|
|
524
|
+
1658658271,
|
|
525
|
+
366619977,
|
|
526
|
+
2362670323,
|
|
527
|
+
4224994405,
|
|
528
|
+
1303535960,
|
|
529
|
+
984961486,
|
|
530
|
+
2747007092,
|
|
531
|
+
3569037538,
|
|
532
|
+
1256170817,
|
|
533
|
+
1037604311,
|
|
534
|
+
2765210733,
|
|
535
|
+
3554079995,
|
|
536
|
+
1131014506,
|
|
537
|
+
879679996,
|
|
538
|
+
2909243462,
|
|
539
|
+
3663771856,
|
|
540
|
+
1141124467,
|
|
541
|
+
855842277,
|
|
542
|
+
2852801631,
|
|
543
|
+
3708648649,
|
|
544
|
+
1342533948,
|
|
545
|
+
654459306,
|
|
546
|
+
3188396048,
|
|
547
|
+
3373015174,
|
|
548
|
+
1466479909,
|
|
549
|
+
544179635,
|
|
550
|
+
3110523913,
|
|
551
|
+
3462522015,
|
|
552
|
+
1591671054,
|
|
553
|
+
702138776,
|
|
554
|
+
2966460450,
|
|
555
|
+
3352799412,
|
|
556
|
+
1504918807,
|
|
557
|
+
783551873,
|
|
558
|
+
3082640443,
|
|
559
|
+
3233442989,
|
|
560
|
+
3988292384,
|
|
561
|
+
2596254646,
|
|
562
|
+
62317068,
|
|
563
|
+
1957810842,
|
|
564
|
+
3939845945,
|
|
565
|
+
2647816111,
|
|
566
|
+
81470997,
|
|
567
|
+
1943803523,
|
|
568
|
+
3814918930,
|
|
569
|
+
2489596804,
|
|
570
|
+
225274430,
|
|
571
|
+
2053790376,
|
|
572
|
+
3826175755,
|
|
573
|
+
2466906013,
|
|
574
|
+
167816743,
|
|
575
|
+
2097651377,
|
|
576
|
+
4027552580,
|
|
577
|
+
2265490386,
|
|
578
|
+
503444072,
|
|
579
|
+
1762050814,
|
|
580
|
+
4150417245,
|
|
581
|
+
2154129355,
|
|
582
|
+
426522225,
|
|
583
|
+
1852507879,
|
|
584
|
+
4275313526,
|
|
585
|
+
2312317920,
|
|
586
|
+
282753626,
|
|
587
|
+
1742555852,
|
|
588
|
+
4189708143,
|
|
589
|
+
2394877945,
|
|
590
|
+
397917763,
|
|
591
|
+
1622183637,
|
|
592
|
+
3604390888,
|
|
593
|
+
2714866558,
|
|
594
|
+
953729732,
|
|
595
|
+
1340076626,
|
|
596
|
+
3518719985,
|
|
597
|
+
2797360999,
|
|
598
|
+
1068828381,
|
|
599
|
+
1219638859,
|
|
600
|
+
3624741850,
|
|
601
|
+
2936675148,
|
|
602
|
+
906185462,
|
|
603
|
+
1090812512,
|
|
604
|
+
3747672003,
|
|
605
|
+
2825379669,
|
|
606
|
+
829329135,
|
|
607
|
+
1181335161,
|
|
608
|
+
3412177804,
|
|
609
|
+
3160834842,
|
|
610
|
+
628085408,
|
|
611
|
+
1382605366,
|
|
612
|
+
3423369109,
|
|
613
|
+
3138078467,
|
|
614
|
+
570562233,
|
|
615
|
+
1426400815,
|
|
616
|
+
3317316542,
|
|
617
|
+
2998733608,
|
|
618
|
+
733239954,
|
|
619
|
+
1555261956,
|
|
620
|
+
3268935591,
|
|
621
|
+
3050360625,
|
|
622
|
+
752459403,
|
|
623
|
+
1541320221,
|
|
624
|
+
2607071920,
|
|
625
|
+
3965973030,
|
|
626
|
+
1969922972,
|
|
627
|
+
40735498,
|
|
628
|
+
2617837225,
|
|
629
|
+
3943577151,
|
|
630
|
+
1913087877,
|
|
631
|
+
83908371,
|
|
632
|
+
2512341634,
|
|
633
|
+
3803740692,
|
|
634
|
+
2075208622,
|
|
635
|
+
213261112,
|
|
636
|
+
2463272603,
|
|
637
|
+
3855990285,
|
|
638
|
+
2094854071,
|
|
639
|
+
198958881,
|
|
640
|
+
2262029012,
|
|
641
|
+
4057260610,
|
|
642
|
+
1759359992,
|
|
643
|
+
534414190,
|
|
644
|
+
2176718541,
|
|
645
|
+
4139329115,
|
|
646
|
+
1873836001,
|
|
647
|
+
414664567,
|
|
648
|
+
2282248934,
|
|
649
|
+
4279200368,
|
|
650
|
+
1711684554,
|
|
651
|
+
285281116,
|
|
652
|
+
2405801727,
|
|
653
|
+
4167216745,
|
|
654
|
+
1634467795,
|
|
655
|
+
376229701,
|
|
656
|
+
2685067896,
|
|
657
|
+
3608007406,
|
|
658
|
+
1308918612,
|
|
659
|
+
956543938,
|
|
660
|
+
2808555105,
|
|
661
|
+
3495958263,
|
|
662
|
+
1231636301,
|
|
663
|
+
1047427035,
|
|
664
|
+
2932959818,
|
|
665
|
+
3654703836,
|
|
666
|
+
1088359270,
|
|
667
|
+
936918e3,
|
|
668
|
+
2847714899,
|
|
669
|
+
3736837829,
|
|
670
|
+
1202900863,
|
|
671
|
+
817233897,
|
|
672
|
+
3183342108,
|
|
673
|
+
3401237130,
|
|
674
|
+
1404277552,
|
|
675
|
+
615818150,
|
|
676
|
+
3134207493,
|
|
677
|
+
3453421203,
|
|
678
|
+
1423857449,
|
|
679
|
+
601450431,
|
|
680
|
+
3009837614,
|
|
681
|
+
3294710456,
|
|
682
|
+
1567103746,
|
|
683
|
+
711928724,
|
|
684
|
+
3020668471,
|
|
685
|
+
3272380065,
|
|
686
|
+
1510334235,
|
|
687
|
+
755167117
|
|
688
|
+
];
|
|
689
|
+
if (typeof Int32Array !== "undefined") {
|
|
690
|
+
CRC_TABLE = new Int32Array(CRC_TABLE);
|
|
691
|
+
}
|
|
692
|
+
function ensureBuffer(input) {
|
|
693
|
+
if (Buffer2.isBuffer(input)) {
|
|
694
|
+
return input;
|
|
695
|
+
}
|
|
696
|
+
var hasNewBufferAPI = typeof Buffer2.alloc === "function" && typeof Buffer2.from === "function";
|
|
697
|
+
if (typeof input === "number") {
|
|
698
|
+
return hasNewBufferAPI ? Buffer2.alloc(input) : new Buffer2(input);
|
|
699
|
+
} else if (typeof input === "string") {
|
|
700
|
+
return hasNewBufferAPI ? Buffer2.from(input) : new Buffer2(input);
|
|
701
|
+
} else {
|
|
702
|
+
throw new Error("input must be buffer, number, or string, received " + typeof input);
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
function bufferizeInt(num) {
|
|
706
|
+
var tmp = ensureBuffer(4);
|
|
707
|
+
tmp.writeInt32BE(num, 0);
|
|
708
|
+
return tmp;
|
|
709
|
+
}
|
|
710
|
+
function _crc32(buf, previous) {
|
|
711
|
+
buf = ensureBuffer(buf);
|
|
712
|
+
if (Buffer2.isBuffer(previous)) {
|
|
713
|
+
previous = previous.readUInt32BE(0);
|
|
714
|
+
}
|
|
715
|
+
var crc = ~~previous ^ -1;
|
|
716
|
+
for (var n = 0; n < buf.length; n++) {
|
|
717
|
+
crc = CRC_TABLE[(crc ^ buf[n]) & 255] ^ crc >>> 8;
|
|
718
|
+
}
|
|
719
|
+
return crc ^ -1;
|
|
720
|
+
}
|
|
721
|
+
function crc32() {
|
|
722
|
+
return bufferizeInt(_crc32.apply(null, arguments));
|
|
723
|
+
}
|
|
724
|
+
crc32.signed = function() {
|
|
725
|
+
return _crc32.apply(null, arguments);
|
|
726
|
+
};
|
|
727
|
+
crc32.unsigned = function() {
|
|
728
|
+
return _crc32.apply(null, arguments) >>> 0;
|
|
729
|
+
};
|
|
730
|
+
module.exports = crc32;
|
|
731
|
+
}
|
|
732
|
+
});
|
|
733
|
+
|
|
734
|
+
// node_modules/yauzl/index.js
|
|
735
|
+
var require_yauzl = __commonJS({
|
|
736
|
+
"node_modules/yauzl/index.js"(exports) {
|
|
737
|
+
"use strict";
|
|
738
|
+
var fs = __require("fs");
|
|
739
|
+
var zlib = __require("zlib");
|
|
740
|
+
var fd_slicer = require_fd_slicer();
|
|
741
|
+
var crc32 = require_buffer_crc32();
|
|
742
|
+
var util = __require("util");
|
|
743
|
+
var EventEmitter = __require("events").EventEmitter;
|
|
744
|
+
var Transform = __require("stream").Transform;
|
|
745
|
+
var PassThrough = __require("stream").PassThrough;
|
|
746
|
+
var Writable = __require("stream").Writable;
|
|
747
|
+
exports.open = open;
|
|
748
|
+
exports.fromFd = fromFd;
|
|
749
|
+
exports.fromBuffer = fromBuffer;
|
|
750
|
+
exports.fromRandomAccessReader = fromRandomAccessReader;
|
|
751
|
+
exports.dosDateTimeToDate = dosDateTimeToDate;
|
|
752
|
+
exports.validateFileName = validateFileName;
|
|
753
|
+
exports.ZipFile = ZipFile;
|
|
754
|
+
exports.Entry = Entry;
|
|
755
|
+
exports.RandomAccessReader = RandomAccessReader;
|
|
756
|
+
function open(path, options, callback) {
|
|
757
|
+
if (typeof options === "function") {
|
|
758
|
+
callback = options;
|
|
759
|
+
options = null;
|
|
760
|
+
}
|
|
761
|
+
if (options == null) options = {};
|
|
762
|
+
if (options.autoClose == null) options.autoClose = true;
|
|
763
|
+
if (options.lazyEntries == null) options.lazyEntries = false;
|
|
764
|
+
if (options.decodeStrings == null) options.decodeStrings = true;
|
|
765
|
+
if (options.validateEntrySizes == null) options.validateEntrySizes = true;
|
|
766
|
+
if (options.strictFileNames == null) options.strictFileNames = false;
|
|
767
|
+
if (callback == null) callback = defaultCallback;
|
|
768
|
+
fs.open(path, "r", function(err, fd) {
|
|
769
|
+
if (err) return callback(err);
|
|
770
|
+
fromFd(fd, options, function(err2, zipfile) {
|
|
771
|
+
if (err2) fs.close(fd, defaultCallback);
|
|
772
|
+
callback(err2, zipfile);
|
|
773
|
+
});
|
|
774
|
+
});
|
|
775
|
+
}
|
|
776
|
+
function fromFd(fd, options, callback) {
|
|
777
|
+
if (typeof options === "function") {
|
|
778
|
+
callback = options;
|
|
779
|
+
options = null;
|
|
780
|
+
}
|
|
781
|
+
if (options == null) options = {};
|
|
782
|
+
if (options.autoClose == null) options.autoClose = false;
|
|
783
|
+
if (options.lazyEntries == null) options.lazyEntries = false;
|
|
784
|
+
if (options.decodeStrings == null) options.decodeStrings = true;
|
|
785
|
+
if (options.validateEntrySizes == null) options.validateEntrySizes = true;
|
|
786
|
+
if (options.strictFileNames == null) options.strictFileNames = false;
|
|
787
|
+
if (callback == null) callback = defaultCallback;
|
|
788
|
+
fs.fstat(fd, function(err, stats) {
|
|
789
|
+
if (err) return callback(err);
|
|
790
|
+
var reader = fd_slicer.createFromFd(fd, { autoClose: true });
|
|
791
|
+
fromRandomAccessReader(reader, stats.size, options, callback);
|
|
792
|
+
});
|
|
793
|
+
}
|
|
794
|
+
function fromBuffer(buffer, options, callback) {
|
|
795
|
+
if (typeof options === "function") {
|
|
796
|
+
callback = options;
|
|
797
|
+
options = null;
|
|
798
|
+
}
|
|
799
|
+
if (options == null) options = {};
|
|
800
|
+
options.autoClose = false;
|
|
801
|
+
if (options.lazyEntries == null) options.lazyEntries = false;
|
|
802
|
+
if (options.decodeStrings == null) options.decodeStrings = true;
|
|
803
|
+
if (options.validateEntrySizes == null) options.validateEntrySizes = true;
|
|
804
|
+
if (options.strictFileNames == null) options.strictFileNames = false;
|
|
805
|
+
var reader = fd_slicer.createFromBuffer(buffer, { maxChunkSize: 65536 });
|
|
806
|
+
fromRandomAccessReader(reader, buffer.length, options, callback);
|
|
807
|
+
}
|
|
808
|
+
function fromRandomAccessReader(reader, totalSize, options, callback) {
|
|
809
|
+
if (typeof options === "function") {
|
|
810
|
+
callback = options;
|
|
811
|
+
options = null;
|
|
812
|
+
}
|
|
813
|
+
if (options == null) options = {};
|
|
814
|
+
if (options.autoClose == null) options.autoClose = true;
|
|
815
|
+
if (options.lazyEntries == null) options.lazyEntries = false;
|
|
816
|
+
if (options.decodeStrings == null) options.decodeStrings = true;
|
|
817
|
+
var decodeStrings = !!options.decodeStrings;
|
|
818
|
+
if (options.validateEntrySizes == null) options.validateEntrySizes = true;
|
|
819
|
+
if (options.strictFileNames == null) options.strictFileNames = false;
|
|
820
|
+
if (callback == null) callback = defaultCallback;
|
|
821
|
+
if (typeof totalSize !== "number") throw new Error("expected totalSize parameter to be a number");
|
|
822
|
+
if (totalSize > Number.MAX_SAFE_INTEGER) {
|
|
823
|
+
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.");
|
|
824
|
+
}
|
|
825
|
+
reader.ref();
|
|
826
|
+
var eocdrWithoutCommentSize = 22;
|
|
827
|
+
var maxCommentSize = 65535;
|
|
828
|
+
var bufferSize = Math.min(eocdrWithoutCommentSize + maxCommentSize, totalSize);
|
|
829
|
+
var buffer = newBuffer(bufferSize);
|
|
830
|
+
var bufferReadStart = totalSize - buffer.length;
|
|
831
|
+
readAndAssertNoEof(reader, buffer, 0, bufferSize, bufferReadStart, function(err) {
|
|
832
|
+
if (err) return callback(err);
|
|
833
|
+
for (var i = bufferSize - eocdrWithoutCommentSize; i >= 0; i -= 1) {
|
|
834
|
+
if (buffer.readUInt32LE(i) !== 101010256) continue;
|
|
835
|
+
var eocdrBuffer = buffer.slice(i);
|
|
836
|
+
var diskNumber = eocdrBuffer.readUInt16LE(4);
|
|
837
|
+
if (diskNumber !== 0) {
|
|
838
|
+
return callback(new Error("multi-disk zip files are not supported: found disk number: " + diskNumber));
|
|
839
|
+
}
|
|
840
|
+
var entryCount = eocdrBuffer.readUInt16LE(10);
|
|
841
|
+
var centralDirectoryOffset = eocdrBuffer.readUInt32LE(16);
|
|
842
|
+
var commentLength = eocdrBuffer.readUInt16LE(20);
|
|
843
|
+
var expectedCommentLength = eocdrBuffer.length - eocdrWithoutCommentSize;
|
|
844
|
+
if (commentLength !== expectedCommentLength) {
|
|
845
|
+
return callback(new Error("invalid comment length. expected: " + expectedCommentLength + ". found: " + commentLength));
|
|
846
|
+
}
|
|
847
|
+
var comment = decodeStrings ? decodeBuffer(eocdrBuffer, 22, eocdrBuffer.length, false) : eocdrBuffer.slice(22);
|
|
848
|
+
if (!(entryCount === 65535 || centralDirectoryOffset === 4294967295)) {
|
|
849
|
+
return callback(null, new ZipFile(reader, centralDirectoryOffset, totalSize, entryCount, comment, options.autoClose, options.lazyEntries, decodeStrings, options.validateEntrySizes, options.strictFileNames));
|
|
850
|
+
}
|
|
851
|
+
var zip64EocdlBuffer = newBuffer(20);
|
|
852
|
+
var zip64EocdlOffset = bufferReadStart + i - zip64EocdlBuffer.length;
|
|
853
|
+
readAndAssertNoEof(reader, zip64EocdlBuffer, 0, zip64EocdlBuffer.length, zip64EocdlOffset, function(err2) {
|
|
854
|
+
if (err2) return callback(err2);
|
|
855
|
+
if (zip64EocdlBuffer.readUInt32LE(0) !== 117853008) {
|
|
856
|
+
return callback(new Error("invalid zip64 end of central directory locator signature"));
|
|
857
|
+
}
|
|
858
|
+
var zip64EocdrOffset = readUInt64LE(zip64EocdlBuffer, 8);
|
|
859
|
+
var zip64EocdrBuffer = newBuffer(56);
|
|
860
|
+
readAndAssertNoEof(reader, zip64EocdrBuffer, 0, zip64EocdrBuffer.length, zip64EocdrOffset, function(err3) {
|
|
861
|
+
if (err3) return callback(err3);
|
|
862
|
+
if (zip64EocdrBuffer.readUInt32LE(0) !== 101075792) {
|
|
863
|
+
return callback(new Error("invalid zip64 end of central directory record signature"));
|
|
864
|
+
}
|
|
865
|
+
entryCount = readUInt64LE(zip64EocdrBuffer, 32);
|
|
866
|
+
centralDirectoryOffset = readUInt64LE(zip64EocdrBuffer, 48);
|
|
867
|
+
return callback(null, new ZipFile(reader, centralDirectoryOffset, totalSize, entryCount, comment, options.autoClose, options.lazyEntries, decodeStrings, options.validateEntrySizes, options.strictFileNames));
|
|
868
|
+
});
|
|
869
|
+
});
|
|
870
|
+
return;
|
|
871
|
+
}
|
|
872
|
+
callback(new Error("end of central directory record signature not found"));
|
|
873
|
+
});
|
|
874
|
+
}
|
|
875
|
+
util.inherits(ZipFile, EventEmitter);
|
|
876
|
+
function ZipFile(reader, centralDirectoryOffset, fileSize, entryCount, comment, autoClose, lazyEntries, decodeStrings, validateEntrySizes, strictFileNames) {
|
|
877
|
+
var self = this;
|
|
878
|
+
EventEmitter.call(self);
|
|
879
|
+
self.reader = reader;
|
|
880
|
+
self.reader.on("error", function(err) {
|
|
881
|
+
emitError(self, err);
|
|
882
|
+
});
|
|
883
|
+
self.reader.once("close", function() {
|
|
884
|
+
self.emit("close");
|
|
885
|
+
});
|
|
886
|
+
self.readEntryCursor = centralDirectoryOffset;
|
|
887
|
+
self.fileSize = fileSize;
|
|
888
|
+
self.entryCount = entryCount;
|
|
889
|
+
self.comment = comment;
|
|
890
|
+
self.entriesRead = 0;
|
|
891
|
+
self.autoClose = !!autoClose;
|
|
892
|
+
self.lazyEntries = !!lazyEntries;
|
|
893
|
+
self.decodeStrings = !!decodeStrings;
|
|
894
|
+
self.validateEntrySizes = !!validateEntrySizes;
|
|
895
|
+
self.strictFileNames = !!strictFileNames;
|
|
896
|
+
self.isOpen = true;
|
|
897
|
+
self.emittedError = false;
|
|
898
|
+
if (!self.lazyEntries) self._readEntry();
|
|
899
|
+
}
|
|
900
|
+
ZipFile.prototype.close = function() {
|
|
901
|
+
if (!this.isOpen) return;
|
|
902
|
+
this.isOpen = false;
|
|
903
|
+
this.reader.unref();
|
|
904
|
+
};
|
|
905
|
+
function emitErrorAndAutoClose(self, err) {
|
|
906
|
+
if (self.autoClose) self.close();
|
|
907
|
+
emitError(self, err);
|
|
908
|
+
}
|
|
909
|
+
function emitError(self, err) {
|
|
910
|
+
if (self.emittedError) return;
|
|
911
|
+
self.emittedError = true;
|
|
912
|
+
self.emit("error", err);
|
|
913
|
+
}
|
|
914
|
+
ZipFile.prototype.readEntry = function() {
|
|
915
|
+
if (!this.lazyEntries) throw new Error("readEntry() called without lazyEntries:true");
|
|
916
|
+
this._readEntry();
|
|
917
|
+
};
|
|
918
|
+
ZipFile.prototype._readEntry = function() {
|
|
919
|
+
var self = this;
|
|
920
|
+
if (self.entryCount === self.entriesRead) {
|
|
921
|
+
setImmediate(function() {
|
|
922
|
+
if (self.autoClose) self.close();
|
|
923
|
+
if (self.emittedError) return;
|
|
924
|
+
self.emit("end");
|
|
925
|
+
});
|
|
926
|
+
return;
|
|
927
|
+
}
|
|
928
|
+
if (self.emittedError) return;
|
|
929
|
+
var buffer = newBuffer(46);
|
|
930
|
+
readAndAssertNoEof(self.reader, buffer, 0, buffer.length, self.readEntryCursor, function(err) {
|
|
931
|
+
if (err) return emitErrorAndAutoClose(self, err);
|
|
932
|
+
if (self.emittedError) return;
|
|
933
|
+
var entry = new Entry();
|
|
934
|
+
var signature = buffer.readUInt32LE(0);
|
|
935
|
+
if (signature !== 33639248) return emitErrorAndAutoClose(self, new Error("invalid central directory file header signature: 0x" + signature.toString(16)));
|
|
936
|
+
entry.versionMadeBy = buffer.readUInt16LE(4);
|
|
937
|
+
entry.versionNeededToExtract = buffer.readUInt16LE(6);
|
|
938
|
+
entry.generalPurposeBitFlag = buffer.readUInt16LE(8);
|
|
939
|
+
entry.compressionMethod = buffer.readUInt16LE(10);
|
|
940
|
+
entry.lastModFileTime = buffer.readUInt16LE(12);
|
|
941
|
+
entry.lastModFileDate = buffer.readUInt16LE(14);
|
|
942
|
+
entry.crc32 = buffer.readUInt32LE(16);
|
|
943
|
+
entry.compressedSize = buffer.readUInt32LE(20);
|
|
944
|
+
entry.uncompressedSize = buffer.readUInt32LE(24);
|
|
945
|
+
entry.fileNameLength = buffer.readUInt16LE(28);
|
|
946
|
+
entry.extraFieldLength = buffer.readUInt16LE(30);
|
|
947
|
+
entry.fileCommentLength = buffer.readUInt16LE(32);
|
|
948
|
+
entry.internalFileAttributes = buffer.readUInt16LE(36);
|
|
949
|
+
entry.externalFileAttributes = buffer.readUInt32LE(38);
|
|
950
|
+
entry.relativeOffsetOfLocalHeader = buffer.readUInt32LE(42);
|
|
951
|
+
if (entry.generalPurposeBitFlag & 64) return emitErrorAndAutoClose(self, new Error("strong encryption is not supported"));
|
|
952
|
+
self.readEntryCursor += 46;
|
|
953
|
+
buffer = newBuffer(entry.fileNameLength + entry.extraFieldLength + entry.fileCommentLength);
|
|
954
|
+
readAndAssertNoEof(self.reader, buffer, 0, buffer.length, self.readEntryCursor, function(err2) {
|
|
955
|
+
if (err2) return emitErrorAndAutoClose(self, err2);
|
|
956
|
+
if (self.emittedError) return;
|
|
957
|
+
var isUtf8 = (entry.generalPurposeBitFlag & 2048) !== 0;
|
|
958
|
+
entry.fileName = self.decodeStrings ? decodeBuffer(buffer, 0, entry.fileNameLength, isUtf8) : buffer.slice(0, entry.fileNameLength);
|
|
959
|
+
var fileCommentStart = entry.fileNameLength + entry.extraFieldLength;
|
|
960
|
+
var extraFieldBuffer = buffer.slice(entry.fileNameLength, fileCommentStart);
|
|
961
|
+
entry.extraFields = [];
|
|
962
|
+
var i = 0;
|
|
963
|
+
while (i < extraFieldBuffer.length - 3) {
|
|
964
|
+
var headerId = extraFieldBuffer.readUInt16LE(i + 0);
|
|
965
|
+
var dataSize = extraFieldBuffer.readUInt16LE(i + 2);
|
|
966
|
+
var dataStart = i + 4;
|
|
967
|
+
var dataEnd = dataStart + dataSize;
|
|
968
|
+
if (dataEnd > extraFieldBuffer.length) return emitErrorAndAutoClose(self, new Error("extra field length exceeds extra field buffer size"));
|
|
969
|
+
var dataBuffer = newBuffer(dataSize);
|
|
970
|
+
extraFieldBuffer.copy(dataBuffer, 0, dataStart, dataEnd);
|
|
971
|
+
entry.extraFields.push({
|
|
972
|
+
id: headerId,
|
|
973
|
+
data: dataBuffer
|
|
974
|
+
});
|
|
975
|
+
i = dataEnd;
|
|
976
|
+
}
|
|
977
|
+
entry.fileComment = self.decodeStrings ? decodeBuffer(buffer, fileCommentStart, fileCommentStart + entry.fileCommentLength, isUtf8) : buffer.slice(fileCommentStart, fileCommentStart + entry.fileCommentLength);
|
|
978
|
+
entry.comment = entry.fileComment;
|
|
979
|
+
self.readEntryCursor += buffer.length;
|
|
980
|
+
self.entriesRead += 1;
|
|
981
|
+
if (entry.uncompressedSize === 4294967295 || entry.compressedSize === 4294967295 || entry.relativeOffsetOfLocalHeader === 4294967295) {
|
|
982
|
+
var zip64EiefBuffer = null;
|
|
983
|
+
for (var i = 0; i < entry.extraFields.length; i++) {
|
|
984
|
+
var extraField = entry.extraFields[i];
|
|
985
|
+
if (extraField.id === 1) {
|
|
986
|
+
zip64EiefBuffer = extraField.data;
|
|
987
|
+
break;
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
if (zip64EiefBuffer == null) {
|
|
991
|
+
return emitErrorAndAutoClose(self, new Error("expected zip64 extended information extra field"));
|
|
992
|
+
}
|
|
993
|
+
var index = 0;
|
|
994
|
+
if (entry.uncompressedSize === 4294967295) {
|
|
995
|
+
if (index + 8 > zip64EiefBuffer.length) {
|
|
996
|
+
return emitErrorAndAutoClose(self, new Error("zip64 extended information extra field does not include uncompressed size"));
|
|
997
|
+
}
|
|
998
|
+
entry.uncompressedSize = readUInt64LE(zip64EiefBuffer, index);
|
|
999
|
+
index += 8;
|
|
1000
|
+
}
|
|
1001
|
+
if (entry.compressedSize === 4294967295) {
|
|
1002
|
+
if (index + 8 > zip64EiefBuffer.length) {
|
|
1003
|
+
return emitErrorAndAutoClose(self, new Error("zip64 extended information extra field does not include compressed size"));
|
|
1004
|
+
}
|
|
1005
|
+
entry.compressedSize = readUInt64LE(zip64EiefBuffer, index);
|
|
1006
|
+
index += 8;
|
|
1007
|
+
}
|
|
1008
|
+
if (entry.relativeOffsetOfLocalHeader === 4294967295) {
|
|
1009
|
+
if (index + 8 > zip64EiefBuffer.length) {
|
|
1010
|
+
return emitErrorAndAutoClose(self, new Error("zip64 extended information extra field does not include relative header offset"));
|
|
1011
|
+
}
|
|
1012
|
+
entry.relativeOffsetOfLocalHeader = readUInt64LE(zip64EiefBuffer, index);
|
|
1013
|
+
index += 8;
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
if (self.decodeStrings) {
|
|
1017
|
+
for (var i = 0; i < entry.extraFields.length; i++) {
|
|
1018
|
+
var extraField = entry.extraFields[i];
|
|
1019
|
+
if (extraField.id === 28789) {
|
|
1020
|
+
if (extraField.data.length < 6) {
|
|
1021
|
+
continue;
|
|
1022
|
+
}
|
|
1023
|
+
if (extraField.data.readUInt8(0) !== 1) {
|
|
1024
|
+
continue;
|
|
1025
|
+
}
|
|
1026
|
+
var oldNameCrc32 = extraField.data.readUInt32LE(1);
|
|
1027
|
+
if (crc32.unsigned(buffer.slice(0, entry.fileNameLength)) !== oldNameCrc32) {
|
|
1028
|
+
continue;
|
|
1029
|
+
}
|
|
1030
|
+
entry.fileName = decodeBuffer(extraField.data, 5, extraField.data.length, true);
|
|
1031
|
+
break;
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
if (self.validateEntrySizes && entry.compressionMethod === 0) {
|
|
1036
|
+
var expectedCompressedSize = entry.uncompressedSize;
|
|
1037
|
+
if (entry.isEncrypted()) {
|
|
1038
|
+
expectedCompressedSize += 12;
|
|
1039
|
+
}
|
|
1040
|
+
if (entry.compressedSize !== expectedCompressedSize) {
|
|
1041
|
+
var msg = "compressed/uncompressed size mismatch for stored file: " + entry.compressedSize + " != " + entry.uncompressedSize;
|
|
1042
|
+
return emitErrorAndAutoClose(self, new Error(msg));
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
if (self.decodeStrings) {
|
|
1046
|
+
if (!self.strictFileNames) {
|
|
1047
|
+
entry.fileName = entry.fileName.replace(/\\/g, "/");
|
|
1048
|
+
}
|
|
1049
|
+
var errorMessage = validateFileName(entry.fileName, self.validateFileNameOptions);
|
|
1050
|
+
if (errorMessage != null) return emitErrorAndAutoClose(self, new Error(errorMessage));
|
|
1051
|
+
}
|
|
1052
|
+
self.emit("entry", entry);
|
|
1053
|
+
if (!self.lazyEntries) self._readEntry();
|
|
1054
|
+
});
|
|
1055
|
+
});
|
|
1056
|
+
};
|
|
1057
|
+
ZipFile.prototype.openReadStream = function(entry, options, callback) {
|
|
1058
|
+
var self = this;
|
|
1059
|
+
var relativeStart = 0;
|
|
1060
|
+
var relativeEnd = entry.compressedSize;
|
|
1061
|
+
if (callback == null) {
|
|
1062
|
+
callback = options;
|
|
1063
|
+
options = {};
|
|
1064
|
+
} else {
|
|
1065
|
+
if (options.decrypt != null) {
|
|
1066
|
+
if (!entry.isEncrypted()) {
|
|
1067
|
+
throw new Error("options.decrypt can only be specified for encrypted entries");
|
|
1068
|
+
}
|
|
1069
|
+
if (options.decrypt !== false) throw new Error("invalid options.decrypt value: " + options.decrypt);
|
|
1070
|
+
if (entry.isCompressed()) {
|
|
1071
|
+
if (options.decompress !== false) throw new Error("entry is encrypted and compressed, and options.decompress !== false");
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
if (options.decompress != null) {
|
|
1075
|
+
if (!entry.isCompressed()) {
|
|
1076
|
+
throw new Error("options.decompress can only be specified for compressed entries");
|
|
1077
|
+
}
|
|
1078
|
+
if (!(options.decompress === false || options.decompress === true)) {
|
|
1079
|
+
throw new Error("invalid options.decompress value: " + options.decompress);
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
if (options.start != null || options.end != null) {
|
|
1083
|
+
if (entry.isCompressed() && options.decompress !== false) {
|
|
1084
|
+
throw new Error("start/end range not allowed for compressed entry without options.decompress === false");
|
|
1085
|
+
}
|
|
1086
|
+
if (entry.isEncrypted() && options.decrypt !== false) {
|
|
1087
|
+
throw new Error("start/end range not allowed for encrypted entry without options.decrypt === false");
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
if (options.start != null) {
|
|
1091
|
+
relativeStart = options.start;
|
|
1092
|
+
if (relativeStart < 0) throw new Error("options.start < 0");
|
|
1093
|
+
if (relativeStart > entry.compressedSize) throw new Error("options.start > entry.compressedSize");
|
|
1094
|
+
}
|
|
1095
|
+
if (options.end != null) {
|
|
1096
|
+
relativeEnd = options.end;
|
|
1097
|
+
if (relativeEnd < 0) throw new Error("options.end < 0");
|
|
1098
|
+
if (relativeEnd > entry.compressedSize) throw new Error("options.end > entry.compressedSize");
|
|
1099
|
+
if (relativeEnd < relativeStart) throw new Error("options.end < options.start");
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
if (!self.isOpen) return callback(new Error("closed"));
|
|
1103
|
+
if (entry.isEncrypted()) {
|
|
1104
|
+
if (options.decrypt !== false) return callback(new Error("entry is encrypted, and options.decrypt !== false"));
|
|
1105
|
+
}
|
|
1106
|
+
self.reader.ref();
|
|
1107
|
+
var buffer = newBuffer(30);
|
|
1108
|
+
readAndAssertNoEof(self.reader, buffer, 0, buffer.length, entry.relativeOffsetOfLocalHeader, function(err) {
|
|
1109
|
+
try {
|
|
1110
|
+
if (err) return callback(err);
|
|
1111
|
+
var signature = buffer.readUInt32LE(0);
|
|
1112
|
+
if (signature !== 67324752) {
|
|
1113
|
+
return callback(new Error("invalid local file header signature: 0x" + signature.toString(16)));
|
|
1114
|
+
}
|
|
1115
|
+
var fileNameLength = buffer.readUInt16LE(26);
|
|
1116
|
+
var extraFieldLength = buffer.readUInt16LE(28);
|
|
1117
|
+
var localFileHeaderEnd = entry.relativeOffsetOfLocalHeader + buffer.length + fileNameLength + extraFieldLength;
|
|
1118
|
+
var decompress;
|
|
1119
|
+
if (entry.compressionMethod === 0) {
|
|
1120
|
+
decompress = false;
|
|
1121
|
+
} else if (entry.compressionMethod === 8) {
|
|
1122
|
+
decompress = options.decompress != null ? options.decompress : true;
|
|
1123
|
+
} else {
|
|
1124
|
+
return callback(new Error("unsupported compression method: " + entry.compressionMethod));
|
|
1125
|
+
}
|
|
1126
|
+
var fileDataStart = localFileHeaderEnd;
|
|
1127
|
+
var fileDataEnd = fileDataStart + entry.compressedSize;
|
|
1128
|
+
if (entry.compressedSize !== 0) {
|
|
1129
|
+
if (fileDataEnd > self.fileSize) {
|
|
1130
|
+
return callback(new Error("file data overflows file bounds: " + fileDataStart + " + " + entry.compressedSize + " > " + self.fileSize));
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
var readStream = self.reader.createReadStream({
|
|
1134
|
+
start: fileDataStart + relativeStart,
|
|
1135
|
+
end: fileDataStart + relativeEnd
|
|
1136
|
+
});
|
|
1137
|
+
var endpointStream = readStream;
|
|
1138
|
+
if (decompress) {
|
|
1139
|
+
var destroyed = false;
|
|
1140
|
+
var inflateFilter = zlib.createInflateRaw();
|
|
1141
|
+
readStream.on("error", function(err2) {
|
|
1142
|
+
setImmediate(function() {
|
|
1143
|
+
if (!destroyed) inflateFilter.emit("error", err2);
|
|
1144
|
+
});
|
|
1145
|
+
});
|
|
1146
|
+
readStream.pipe(inflateFilter);
|
|
1147
|
+
if (self.validateEntrySizes) {
|
|
1148
|
+
endpointStream = new AssertByteCountStream(entry.uncompressedSize);
|
|
1149
|
+
inflateFilter.on("error", function(err2) {
|
|
1150
|
+
setImmediate(function() {
|
|
1151
|
+
if (!destroyed) endpointStream.emit("error", err2);
|
|
1152
|
+
});
|
|
1153
|
+
});
|
|
1154
|
+
inflateFilter.pipe(endpointStream);
|
|
1155
|
+
} else {
|
|
1156
|
+
endpointStream = inflateFilter;
|
|
1157
|
+
}
|
|
1158
|
+
endpointStream.destroy = function() {
|
|
1159
|
+
destroyed = true;
|
|
1160
|
+
if (inflateFilter !== endpointStream) inflateFilter.unpipe(endpointStream);
|
|
1161
|
+
readStream.unpipe(inflateFilter);
|
|
1162
|
+
readStream.destroy();
|
|
1163
|
+
};
|
|
1164
|
+
}
|
|
1165
|
+
callback(null, endpointStream);
|
|
1166
|
+
} finally {
|
|
1167
|
+
self.reader.unref();
|
|
1168
|
+
}
|
|
1169
|
+
});
|
|
1170
|
+
};
|
|
1171
|
+
function Entry() {
|
|
1172
|
+
}
|
|
1173
|
+
Entry.prototype.getLastModDate = function() {
|
|
1174
|
+
return dosDateTimeToDate(this.lastModFileDate, this.lastModFileTime);
|
|
1175
|
+
};
|
|
1176
|
+
Entry.prototype.isEncrypted = function() {
|
|
1177
|
+
return (this.generalPurposeBitFlag & 1) !== 0;
|
|
1178
|
+
};
|
|
1179
|
+
Entry.prototype.isCompressed = function() {
|
|
1180
|
+
return this.compressionMethod === 8;
|
|
1181
|
+
};
|
|
1182
|
+
function dosDateTimeToDate(date, time) {
|
|
1183
|
+
var day = date & 31;
|
|
1184
|
+
var month = (date >> 5 & 15) - 1;
|
|
1185
|
+
var year = (date >> 9 & 127) + 1980;
|
|
1186
|
+
var millisecond = 0;
|
|
1187
|
+
var second = (time & 31) * 2;
|
|
1188
|
+
var minute = time >> 5 & 63;
|
|
1189
|
+
var hour = time >> 11 & 31;
|
|
1190
|
+
return new Date(year, month, day, hour, minute, second, millisecond);
|
|
1191
|
+
}
|
|
1192
|
+
function validateFileName(fileName) {
|
|
1193
|
+
if (fileName.indexOf("\\") !== -1) {
|
|
1194
|
+
return "invalid characters in fileName: " + fileName;
|
|
1195
|
+
}
|
|
1196
|
+
if (/^[a-zA-Z]:/.test(fileName) || /^\//.test(fileName)) {
|
|
1197
|
+
return "absolute path: " + fileName;
|
|
1198
|
+
}
|
|
1199
|
+
if (fileName.split("/").indexOf("..") !== -1) {
|
|
1200
|
+
return "invalid relative path: " + fileName;
|
|
1201
|
+
}
|
|
1202
|
+
return null;
|
|
1203
|
+
}
|
|
1204
|
+
function readAndAssertNoEof(reader, buffer, offset, length, position, callback) {
|
|
1205
|
+
if (length === 0) {
|
|
1206
|
+
return setImmediate(function() {
|
|
1207
|
+
callback(null, newBuffer(0));
|
|
1208
|
+
});
|
|
1209
|
+
}
|
|
1210
|
+
reader.read(buffer, offset, length, position, function(err, bytesRead) {
|
|
1211
|
+
if (err) return callback(err);
|
|
1212
|
+
if (bytesRead < length) {
|
|
1213
|
+
return callback(new Error("unexpected EOF"));
|
|
1214
|
+
}
|
|
1215
|
+
callback();
|
|
1216
|
+
});
|
|
1217
|
+
}
|
|
1218
|
+
util.inherits(AssertByteCountStream, Transform);
|
|
1219
|
+
function AssertByteCountStream(byteCount) {
|
|
1220
|
+
Transform.call(this);
|
|
1221
|
+
this.actualByteCount = 0;
|
|
1222
|
+
this.expectedByteCount = byteCount;
|
|
1223
|
+
}
|
|
1224
|
+
AssertByteCountStream.prototype._transform = function(chunk, encoding, cb) {
|
|
1225
|
+
this.actualByteCount += chunk.length;
|
|
1226
|
+
if (this.actualByteCount > this.expectedByteCount) {
|
|
1227
|
+
var msg = "too many bytes in the stream. expected " + this.expectedByteCount + ". got at least " + this.actualByteCount;
|
|
1228
|
+
return cb(new Error(msg));
|
|
1229
|
+
}
|
|
1230
|
+
cb(null, chunk);
|
|
1231
|
+
};
|
|
1232
|
+
AssertByteCountStream.prototype._flush = function(cb) {
|
|
1233
|
+
if (this.actualByteCount < this.expectedByteCount) {
|
|
1234
|
+
var msg = "not enough bytes in the stream. expected " + this.expectedByteCount + ". got only " + this.actualByteCount;
|
|
1235
|
+
return cb(new Error(msg));
|
|
1236
|
+
}
|
|
1237
|
+
cb();
|
|
1238
|
+
};
|
|
1239
|
+
util.inherits(RandomAccessReader, EventEmitter);
|
|
1240
|
+
function RandomAccessReader() {
|
|
1241
|
+
EventEmitter.call(this);
|
|
1242
|
+
this.refCount = 0;
|
|
1243
|
+
}
|
|
1244
|
+
RandomAccessReader.prototype.ref = function() {
|
|
1245
|
+
this.refCount += 1;
|
|
1246
|
+
};
|
|
1247
|
+
RandomAccessReader.prototype.unref = function() {
|
|
1248
|
+
var self = this;
|
|
1249
|
+
self.refCount -= 1;
|
|
1250
|
+
if (self.refCount > 0) return;
|
|
1251
|
+
if (self.refCount < 0) throw new Error("invalid unref");
|
|
1252
|
+
self.close(onCloseDone);
|
|
1253
|
+
function onCloseDone(err) {
|
|
1254
|
+
if (err) return self.emit("error", err);
|
|
1255
|
+
self.emit("close");
|
|
1256
|
+
}
|
|
1257
|
+
};
|
|
1258
|
+
RandomAccessReader.prototype.createReadStream = function(options) {
|
|
1259
|
+
var start = options.start;
|
|
1260
|
+
var end = options.end;
|
|
1261
|
+
if (start === end) {
|
|
1262
|
+
var emptyStream = new PassThrough();
|
|
1263
|
+
setImmediate(function() {
|
|
1264
|
+
emptyStream.end();
|
|
1265
|
+
});
|
|
1266
|
+
return emptyStream;
|
|
1267
|
+
}
|
|
1268
|
+
var stream = this._readStreamForRange(start, end);
|
|
1269
|
+
var destroyed = false;
|
|
1270
|
+
var refUnrefFilter = new RefUnrefFilter(this);
|
|
1271
|
+
stream.on("error", function(err) {
|
|
1272
|
+
setImmediate(function() {
|
|
1273
|
+
if (!destroyed) refUnrefFilter.emit("error", err);
|
|
1274
|
+
});
|
|
1275
|
+
});
|
|
1276
|
+
refUnrefFilter.destroy = function() {
|
|
1277
|
+
stream.unpipe(refUnrefFilter);
|
|
1278
|
+
refUnrefFilter.unref();
|
|
1279
|
+
stream.destroy();
|
|
1280
|
+
};
|
|
1281
|
+
var byteCounter = new AssertByteCountStream(end - start);
|
|
1282
|
+
refUnrefFilter.on("error", function(err) {
|
|
1283
|
+
setImmediate(function() {
|
|
1284
|
+
if (!destroyed) byteCounter.emit("error", err);
|
|
1285
|
+
});
|
|
1286
|
+
});
|
|
1287
|
+
byteCounter.destroy = function() {
|
|
1288
|
+
destroyed = true;
|
|
1289
|
+
refUnrefFilter.unpipe(byteCounter);
|
|
1290
|
+
refUnrefFilter.destroy();
|
|
1291
|
+
};
|
|
1292
|
+
return stream.pipe(refUnrefFilter).pipe(byteCounter);
|
|
1293
|
+
};
|
|
1294
|
+
RandomAccessReader.prototype._readStreamForRange = function(start, end) {
|
|
1295
|
+
throw new Error("not implemented");
|
|
1296
|
+
};
|
|
1297
|
+
RandomAccessReader.prototype.read = function(buffer, offset, length, position, callback) {
|
|
1298
|
+
var readStream = this.createReadStream({ start: position, end: position + length });
|
|
1299
|
+
var writeStream = new Writable();
|
|
1300
|
+
var written = 0;
|
|
1301
|
+
writeStream._write = function(chunk, encoding, cb) {
|
|
1302
|
+
chunk.copy(buffer, offset + written, 0, chunk.length);
|
|
1303
|
+
written += chunk.length;
|
|
1304
|
+
cb();
|
|
1305
|
+
};
|
|
1306
|
+
writeStream.on("finish", callback);
|
|
1307
|
+
readStream.on("error", function(error) {
|
|
1308
|
+
callback(error);
|
|
1309
|
+
});
|
|
1310
|
+
readStream.pipe(writeStream);
|
|
1311
|
+
};
|
|
1312
|
+
RandomAccessReader.prototype.close = function(callback) {
|
|
1313
|
+
setImmediate(callback);
|
|
1314
|
+
};
|
|
1315
|
+
util.inherits(RefUnrefFilter, PassThrough);
|
|
1316
|
+
function RefUnrefFilter(context) {
|
|
1317
|
+
PassThrough.call(this);
|
|
1318
|
+
this.context = context;
|
|
1319
|
+
this.context.ref();
|
|
1320
|
+
this.unreffedYet = false;
|
|
1321
|
+
}
|
|
1322
|
+
RefUnrefFilter.prototype._flush = function(cb) {
|
|
1323
|
+
this.unref();
|
|
1324
|
+
cb();
|
|
1325
|
+
};
|
|
1326
|
+
RefUnrefFilter.prototype.unref = function(cb) {
|
|
1327
|
+
if (this.unreffedYet) return;
|
|
1328
|
+
this.unreffedYet = true;
|
|
1329
|
+
this.context.unref();
|
|
1330
|
+
};
|
|
1331
|
+
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";
|
|
1332
|
+
function decodeBuffer(buffer, start, end, isUtf8) {
|
|
1333
|
+
if (isUtf8) {
|
|
1334
|
+
return buffer.toString("utf8", start, end);
|
|
1335
|
+
} else {
|
|
1336
|
+
var result = "";
|
|
1337
|
+
for (var i = start; i < end; i++) {
|
|
1338
|
+
result += cp437[buffer[i]];
|
|
1339
|
+
}
|
|
1340
|
+
return result;
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1343
|
+
function readUInt64LE(buffer, offset) {
|
|
1344
|
+
var lower32 = buffer.readUInt32LE(offset);
|
|
1345
|
+
var upper32 = buffer.readUInt32LE(offset + 4);
|
|
1346
|
+
return upper32 * 4294967296 + lower32;
|
|
1347
|
+
}
|
|
1348
|
+
var newBuffer;
|
|
1349
|
+
if (typeof Buffer.allocUnsafe === "function") {
|
|
1350
|
+
newBuffer = function(len) {
|
|
1351
|
+
return Buffer.allocUnsafe(len);
|
|
1352
|
+
};
|
|
1353
|
+
} else {
|
|
1354
|
+
newBuffer = function(len) {
|
|
1355
|
+
return new Buffer(len);
|
|
1356
|
+
};
|
|
1357
|
+
}
|
|
1358
|
+
function defaultCallback(err) {
|
|
1359
|
+
if (err) throw err;
|
|
1360
|
+
}
|
|
1361
|
+
}
|
|
1362
|
+
});
|
|
1363
|
+
|
|
1364
|
+
// node_modules/extract-zip/index.js
|
|
1365
|
+
var require_extract_zip = __commonJS({
|
|
1366
|
+
"node_modules/extract-zip/index.js"(exports, module) {
|
|
1367
|
+
var debug = require_src()("extract-zip");
|
|
1368
|
+
var { createWriteStream, promises: fs } = __require("fs");
|
|
1369
|
+
var getStream = require_get_stream();
|
|
1370
|
+
var path = __require("path");
|
|
1371
|
+
var { promisify } = __require("util");
|
|
1372
|
+
var stream = __require("stream");
|
|
1373
|
+
var yauzl = require_yauzl();
|
|
1374
|
+
var openZip = promisify(yauzl.open);
|
|
1375
|
+
var pipeline = promisify(stream.pipeline);
|
|
1376
|
+
var Extractor = class {
|
|
1377
|
+
constructor(zipPath, opts) {
|
|
1378
|
+
this.zipPath = zipPath;
|
|
1379
|
+
this.opts = opts;
|
|
1380
|
+
}
|
|
1381
|
+
async extract() {
|
|
1382
|
+
debug("opening", this.zipPath, "with opts", this.opts);
|
|
1383
|
+
this.zipfile = await openZip(this.zipPath, { lazyEntries: true });
|
|
1384
|
+
this.canceled = false;
|
|
1385
|
+
return new Promise((resolve, reject) => {
|
|
1386
|
+
this.zipfile.on("error", (err) => {
|
|
1387
|
+
this.canceled = true;
|
|
1388
|
+
reject(err);
|
|
1389
|
+
});
|
|
1390
|
+
this.zipfile.readEntry();
|
|
1391
|
+
this.zipfile.on("close", () => {
|
|
1392
|
+
if (!this.canceled) {
|
|
1393
|
+
debug("zip extraction complete");
|
|
1394
|
+
resolve();
|
|
1395
|
+
}
|
|
1396
|
+
});
|
|
1397
|
+
this.zipfile.on("entry", async (entry) => {
|
|
1398
|
+
if (this.canceled) {
|
|
1399
|
+
debug("skipping entry", entry.fileName, { cancelled: this.canceled });
|
|
1400
|
+
return;
|
|
1401
|
+
}
|
|
1402
|
+
debug("zipfile entry", entry.fileName);
|
|
1403
|
+
if (entry.fileName.startsWith("__MACOSX/")) {
|
|
1404
|
+
this.zipfile.readEntry();
|
|
1405
|
+
return;
|
|
1406
|
+
}
|
|
1407
|
+
const destDir = path.dirname(path.join(this.opts.dir, entry.fileName));
|
|
1408
|
+
try {
|
|
1409
|
+
await fs.mkdir(destDir, { recursive: true });
|
|
1410
|
+
const canonicalDestDir = await fs.realpath(destDir);
|
|
1411
|
+
const relativeDestDir = path.relative(this.opts.dir, canonicalDestDir);
|
|
1412
|
+
if (relativeDestDir.split(path.sep).includes("..")) {
|
|
1413
|
+
throw new Error(`Out of bound path "${canonicalDestDir}" found while processing file ${entry.fileName}`);
|
|
1414
|
+
}
|
|
1415
|
+
await this.extractEntry(entry);
|
|
1416
|
+
debug("finished processing", entry.fileName);
|
|
1417
|
+
this.zipfile.readEntry();
|
|
1418
|
+
} catch (err) {
|
|
1419
|
+
this.canceled = true;
|
|
1420
|
+
this.zipfile.close();
|
|
1421
|
+
reject(err);
|
|
1422
|
+
}
|
|
1423
|
+
});
|
|
1424
|
+
});
|
|
1425
|
+
}
|
|
1426
|
+
async extractEntry(entry) {
|
|
1427
|
+
if (this.canceled) {
|
|
1428
|
+
debug("skipping entry extraction", entry.fileName, { cancelled: this.canceled });
|
|
1429
|
+
return;
|
|
1430
|
+
}
|
|
1431
|
+
if (this.opts.onEntry) {
|
|
1432
|
+
this.opts.onEntry(entry, this.zipfile);
|
|
1433
|
+
}
|
|
1434
|
+
const dest = path.join(this.opts.dir, entry.fileName);
|
|
1435
|
+
const mode = entry.externalFileAttributes >> 16 & 65535;
|
|
1436
|
+
const IFMT = 61440;
|
|
1437
|
+
const IFDIR = 16384;
|
|
1438
|
+
const IFLNK = 40960;
|
|
1439
|
+
const symlink = (mode & IFMT) === IFLNK;
|
|
1440
|
+
let isDir = (mode & IFMT) === IFDIR;
|
|
1441
|
+
if (!isDir && entry.fileName.endsWith("/")) {
|
|
1442
|
+
isDir = true;
|
|
1443
|
+
}
|
|
1444
|
+
const madeBy = entry.versionMadeBy >> 8;
|
|
1445
|
+
if (!isDir) isDir = madeBy === 0 && entry.externalFileAttributes === 16;
|
|
1446
|
+
debug("extracting entry", { filename: entry.fileName, isDir, isSymlink: symlink });
|
|
1447
|
+
const procMode = this.getExtractedMode(mode, isDir) & 511;
|
|
1448
|
+
const destDir = isDir ? dest : path.dirname(dest);
|
|
1449
|
+
const mkdirOptions = { recursive: true };
|
|
1450
|
+
if (isDir) {
|
|
1451
|
+
mkdirOptions.mode = procMode;
|
|
1452
|
+
}
|
|
1453
|
+
debug("mkdir", { dir: destDir, ...mkdirOptions });
|
|
1454
|
+
await fs.mkdir(destDir, mkdirOptions);
|
|
1455
|
+
if (isDir) return;
|
|
1456
|
+
debug("opening read stream", dest);
|
|
1457
|
+
const readStream = await promisify(this.zipfile.openReadStream.bind(this.zipfile))(entry);
|
|
1458
|
+
if (symlink) {
|
|
1459
|
+
const link = await getStream(readStream);
|
|
1460
|
+
debug("creating symlink", link, dest);
|
|
1461
|
+
await fs.symlink(link, dest);
|
|
1462
|
+
} else {
|
|
1463
|
+
await pipeline(readStream, createWriteStream(dest, { mode: procMode }));
|
|
1464
|
+
}
|
|
1465
|
+
}
|
|
1466
|
+
getExtractedMode(entryMode, isDir) {
|
|
1467
|
+
let mode = entryMode;
|
|
1468
|
+
if (mode === 0) {
|
|
1469
|
+
if (isDir) {
|
|
1470
|
+
if (this.opts.defaultDirMode) {
|
|
1471
|
+
mode = parseInt(this.opts.defaultDirMode, 10);
|
|
1472
|
+
}
|
|
1473
|
+
if (!mode) {
|
|
1474
|
+
mode = 493;
|
|
1475
|
+
}
|
|
1476
|
+
} else {
|
|
1477
|
+
if (this.opts.defaultFileMode) {
|
|
1478
|
+
mode = parseInt(this.opts.defaultFileMode, 10);
|
|
1479
|
+
}
|
|
1480
|
+
if (!mode) {
|
|
1481
|
+
mode = 420;
|
|
1482
|
+
}
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1485
|
+
return mode;
|
|
1486
|
+
}
|
|
1487
|
+
};
|
|
1488
|
+
module.exports = async function(zipPath, opts) {
|
|
1489
|
+
debug("creating target directory", opts.dir);
|
|
1490
|
+
if (!path.isAbsolute(opts.dir)) {
|
|
1491
|
+
throw new Error("Target directory is expected to be absolute");
|
|
1492
|
+
}
|
|
1493
|
+
await fs.mkdir(opts.dir, { recursive: true });
|
|
1494
|
+
opts.dir = await fs.realpath(opts.dir);
|
|
1495
|
+
return new Extractor(zipPath, opts).extract();
|
|
1496
|
+
};
|
|
1497
|
+
}
|
|
1498
|
+
});
|
|
1499
|
+
export default require_extract_zip();
|