@malloy-publisher/server 0.0.198-dev2 → 0.0.198-dev3

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/server.mjs CHANGED
@@ -196773,2295 +196773,1640 @@ var require_dist10 = __commonJS((exports) => {
196773
196773
  }
196774
196774
  });
196775
196775
 
196776
- // ../../node_modules/adm-zip/util/constants.js
196777
- var require_constants24 = __commonJS((exports, module) => {
196778
- module.exports = {
196779
- LOCHDR: 30,
196780
- LOCSIG: 67324752,
196781
- LOCVER: 4,
196782
- LOCFLG: 6,
196783
- LOCHOW: 8,
196784
- LOCTIM: 10,
196785
- LOCCRC: 14,
196786
- LOCSIZ: 18,
196787
- LOCLEN: 22,
196788
- LOCNAM: 26,
196789
- LOCEXT: 28,
196790
- EXTSIG: 134695760,
196791
- EXTHDR: 16,
196792
- EXTCRC: 4,
196793
- EXTSIZ: 8,
196794
- EXTLEN: 12,
196795
- CENHDR: 46,
196796
- CENSIG: 33639248,
196797
- CENVEM: 4,
196798
- CENVER: 6,
196799
- CENFLG: 8,
196800
- CENHOW: 10,
196801
- CENTIM: 12,
196802
- CENCRC: 16,
196803
- CENSIZ: 20,
196804
- CENLEN: 24,
196805
- CENNAM: 28,
196806
- CENEXT: 30,
196807
- CENCOM: 32,
196808
- CENDSK: 34,
196809
- CENATT: 36,
196810
- CENATX: 38,
196811
- CENOFF: 42,
196812
- ENDHDR: 22,
196813
- ENDSIG: 101010256,
196814
- ENDSUB: 8,
196815
- ENDTOT: 10,
196816
- ENDSIZ: 12,
196817
- ENDOFF: 16,
196818
- ENDCOM: 20,
196819
- END64HDR: 20,
196820
- END64SIG: 117853008,
196821
- END64START: 4,
196822
- END64OFF: 8,
196823
- END64NUMDISKS: 16,
196824
- ZIP64SIG: 101075792,
196825
- ZIP64HDR: 56,
196826
- ZIP64LEAD: 12,
196827
- ZIP64SIZE: 4,
196828
- ZIP64VEM: 12,
196829
- ZIP64VER: 14,
196830
- ZIP64DSK: 16,
196831
- ZIP64DSKDIR: 20,
196832
- ZIP64SUB: 24,
196833
- ZIP64TOT: 32,
196834
- ZIP64SIZB: 40,
196835
- ZIP64OFF: 48,
196836
- ZIP64EXTRA: 56,
196837
- STORED: 0,
196838
- SHRUNK: 1,
196839
- REDUCED1: 2,
196840
- REDUCED2: 3,
196841
- REDUCED3: 4,
196842
- REDUCED4: 5,
196843
- IMPLODED: 6,
196844
- DEFLATED: 8,
196845
- ENHANCED_DEFLATED: 9,
196846
- PKWARE: 10,
196847
- BZIP2: 12,
196848
- LZMA: 14,
196849
- IBM_TERSE: 18,
196850
- IBM_LZ77: 19,
196851
- AES_ENCRYPT: 99,
196852
- FLG_ENC: 1,
196853
- FLG_COMP1: 2,
196854
- FLG_COMP2: 4,
196855
- FLG_DESC: 8,
196856
- FLG_ENH: 16,
196857
- FLG_PATCH: 32,
196858
- FLG_STR: 64,
196859
- FLG_EFS: 2048,
196860
- FLG_MSK: 4096,
196861
- FILE: 2,
196862
- BUFFER: 1,
196863
- NONE: 0,
196864
- EF_ID: 0,
196865
- EF_SIZE: 2,
196866
- ID_ZIP64: 1,
196867
- ID_AVINFO: 7,
196868
- ID_PFS: 8,
196869
- ID_OS2: 9,
196870
- ID_NTFS: 10,
196871
- ID_OPENVMS: 12,
196872
- ID_UNIX: 13,
196873
- ID_FORK: 14,
196874
- ID_PATCH: 15,
196875
- ID_X509_PKCS7: 20,
196876
- ID_X509_CERTID_F: 21,
196877
- ID_X509_CERTID_C: 22,
196878
- ID_STRONGENC: 23,
196879
- ID_RECORD_MGT: 24,
196880
- ID_X509_PKCS7_RL: 25,
196881
- ID_IBM1: 101,
196882
- ID_IBM2: 102,
196883
- ID_POSZIP: 18064,
196884
- EF_ZIP64_OR_32: 4294967295,
196885
- EF_ZIP64_OR_16: 65535,
196886
- EF_ZIP64_SUNCOMP: 0,
196887
- EF_ZIP64_SCOMP: 8,
196888
- EF_ZIP64_RHO: 16,
196889
- EF_ZIP64_DSN: 24
196890
- };
196891
- });
196892
-
196893
- // ../../node_modules/adm-zip/util/errors.js
196894
- var require_errors6 = __commonJS((exports) => {
196895
- var errors2 = {
196896
- INVALID_LOC: "Invalid LOC header (bad signature)",
196897
- INVALID_CEN: "Invalid CEN header (bad signature)",
196898
- INVALID_END: "Invalid END header (bad signature)",
196899
- DESCRIPTOR_NOT_EXIST: "No descriptor present",
196900
- DESCRIPTOR_UNKNOWN: "Unknown descriptor format",
196901
- DESCRIPTOR_FAULTY: "Descriptor data is malformed",
196902
- NO_DATA: "Nothing to decompress",
196903
- BAD_CRC: "CRC32 checksum failed {0}",
196904
- FILE_IN_THE_WAY: "There is a file in the way: {0}",
196905
- UNKNOWN_METHOD: "Invalid/unsupported compression method",
196906
- AVAIL_DATA: "inflate::Available inflate data did not terminate",
196907
- INVALID_DISTANCE: "inflate::Invalid literal/length or distance code in fixed or dynamic block",
196908
- TO_MANY_CODES: "inflate::Dynamic block code description: too many length or distance codes",
196909
- INVALID_REPEAT_LEN: "inflate::Dynamic block code description: repeat more than specified lengths",
196910
- INVALID_REPEAT_FIRST: "inflate::Dynamic block code description: repeat lengths with no first length",
196911
- INCOMPLETE_CODES: "inflate::Dynamic block code description: code lengths codes incomplete",
196912
- INVALID_DYN_DISTANCE: "inflate::Dynamic block code description: invalid distance code lengths",
196913
- INVALID_CODES_LEN: "inflate::Dynamic block code description: invalid literal/length code lengths",
196914
- INVALID_STORE_BLOCK: "inflate::Stored block length did not match one's complement",
196915
- INVALID_BLOCK_TYPE: "inflate::Invalid block type (type == 3)",
196916
- CANT_EXTRACT_FILE: "Could not extract the file",
196917
- CANT_OVERRIDE: "Target file already exists",
196918
- DISK_ENTRY_TOO_LARGE: "Number of disk entries is too large",
196919
- NO_ZIP: "No zip file was loaded",
196920
- NO_ENTRY: "Entry doesn't exist",
196921
- DIRECTORY_CONTENT_ERROR: "A directory cannot have content",
196922
- FILE_NOT_FOUND: 'File not found: "{0}"',
196923
- NOT_IMPLEMENTED: "Not implemented",
196924
- INVALID_FILENAME: "Invalid filename",
196925
- INVALID_FORMAT: "Invalid or unsupported zip format. No END header found",
196926
- INVALID_PASS_PARAM: "Incompatible password parameter",
196927
- WRONG_PASSWORD: "Wrong Password",
196928
- COMMENT_TOO_LONG: "Comment is too long",
196929
- EXTRA_FIELD_PARSE_ERROR: "Extra field parsing error"
196930
- };
196931
- function E(message) {
196932
- return function(...args) {
196933
- if (args.length) {
196934
- message = message.replace(/\{(\d)\}/g, (_, n) => args[n] || "");
196935
- }
196936
- return new Error("ADM-ZIP: " + message);
196776
+ // ../../node_modules/pump/index.js
196777
+ var require_pump = __commonJS((exports, module) => {
196778
+ var once = require_once2();
196779
+ var eos = require_end_of_stream4();
196780
+ var fs2;
196781
+ try {
196782
+ fs2 = __require("fs");
196783
+ } catch (e) {}
196784
+ var noop2 = function() {};
196785
+ var ancient = typeof process === "undefined" ? false : /^v?\.0/.test(process.version);
196786
+ var isFn = function(fn) {
196787
+ return typeof fn === "function";
196788
+ };
196789
+ var isFS = function(stream4) {
196790
+ if (!ancient)
196791
+ return false;
196792
+ if (!fs2)
196793
+ return false;
196794
+ return (stream4 instanceof (fs2.ReadStream || noop2) || stream4 instanceof (fs2.WriteStream || noop2)) && isFn(stream4.close);
196795
+ };
196796
+ var isRequest2 = function(stream4) {
196797
+ return stream4.setHeader && isFn(stream4.abort);
196798
+ };
196799
+ var destroyer = function(stream4, reading, writing, callback) {
196800
+ callback = once(callback);
196801
+ var closed = false;
196802
+ stream4.on("close", function() {
196803
+ closed = true;
196804
+ });
196805
+ eos(stream4, { readable: reading, writable: writing }, function(err) {
196806
+ if (err)
196807
+ return callback(err);
196808
+ closed = true;
196809
+ callback();
196810
+ });
196811
+ var destroyed = false;
196812
+ return function(err) {
196813
+ if (closed)
196814
+ return;
196815
+ if (destroyed)
196816
+ return;
196817
+ destroyed = true;
196818
+ if (isFS(stream4))
196819
+ return stream4.close(noop2);
196820
+ if (isRequest2(stream4))
196821
+ return stream4.abort();
196822
+ if (isFn(stream4.destroy))
196823
+ return stream4.destroy();
196824
+ callback(err || new Error("stream was destroyed"));
196937
196825
  };
196938
- }
196939
- for (const msg of Object.keys(errors2)) {
196940
- exports[msg] = E(errors2[msg]);
196941
- }
196826
+ };
196827
+ var call = function(fn) {
196828
+ fn();
196829
+ };
196830
+ var pipe = function(from, to) {
196831
+ return from.pipe(to);
196832
+ };
196833
+ var pump = function() {
196834
+ var streams = Array.prototype.slice.call(arguments);
196835
+ var callback = isFn(streams[streams.length - 1] || noop2) && streams.pop() || noop2;
196836
+ if (Array.isArray(streams[0]))
196837
+ streams = streams[0];
196838
+ if (streams.length < 2)
196839
+ throw new Error("pump requires two streams per minimum");
196840
+ var error;
196841
+ var destroys = streams.map(function(stream4, i) {
196842
+ var reading = i < streams.length - 1;
196843
+ var writing = i > 0;
196844
+ return destroyer(stream4, reading, writing, function(err) {
196845
+ if (!error)
196846
+ error = err;
196847
+ if (err)
196848
+ destroys.forEach(call);
196849
+ if (reading)
196850
+ return;
196851
+ destroys.forEach(call);
196852
+ callback(error);
196853
+ });
196854
+ });
196855
+ return streams.reduce(pipe);
196856
+ };
196857
+ module.exports = pump;
196942
196858
  });
196943
196859
 
196944
- // ../../node_modules/adm-zip/util/utils.js
196945
- var require_utils74 = __commonJS((exports, module) => {
196946
- var fsystem = __require("fs");
196947
- var pth = __require("path");
196948
- var Constants = require_constants24();
196949
- var Errors = require_errors6();
196950
- var isWin = typeof process === "object" && process.platform === "win32";
196951
- var is_Obj = (obj) => typeof obj === "object" && obj !== null;
196952
- var crcTable = new Uint32Array(256).map((t, c) => {
196953
- for (let k = 0;k < 8; k++) {
196954
- if ((c & 1) !== 0) {
196955
- c = 3988292384 ^ c >>> 1;
196860
+ // ../../node_modules/get-stream/buffer-stream.js
196861
+ var require_buffer_stream = __commonJS((exports, module) => {
196862
+ var { PassThrough: PassThroughStream } = __require("stream");
196863
+ module.exports = (options) => {
196864
+ options = { ...options };
196865
+ const { array } = options;
196866
+ let { encoding } = options;
196867
+ const isBuffer2 = encoding === "buffer";
196868
+ let objectMode = false;
196869
+ if (array) {
196870
+ objectMode = !(encoding || isBuffer2);
196871
+ } else {
196872
+ encoding = encoding || "utf8";
196873
+ }
196874
+ if (isBuffer2) {
196875
+ encoding = null;
196876
+ }
196877
+ const stream4 = new PassThroughStream({ objectMode });
196878
+ if (encoding) {
196879
+ stream4.setEncoding(encoding);
196880
+ }
196881
+ let length = 0;
196882
+ const chunks = [];
196883
+ stream4.on("data", (chunk) => {
196884
+ chunks.push(chunk);
196885
+ if (objectMode) {
196886
+ length = chunks.length;
196956
196887
  } else {
196957
- c >>>= 1;
196888
+ length += chunk.length;
196958
196889
  }
196959
- }
196960
- return c >>> 0;
196961
- });
196962
- function Utils(opts) {
196963
- this.sep = pth.sep;
196964
- this.fs = fsystem;
196965
- if (is_Obj(opts)) {
196966
- if (is_Obj(opts.fs) && typeof opts.fs.statSync === "function") {
196967
- this.fs = opts.fs;
196890
+ });
196891
+ stream4.getBufferedValue = () => {
196892
+ if (array) {
196893
+ return chunks;
196968
196894
  }
196895
+ return isBuffer2 ? Buffer.concat(chunks, length) : chunks.join("");
196896
+ };
196897
+ stream4.getBufferedLength = () => length;
196898
+ return stream4;
196899
+ };
196900
+ });
196901
+
196902
+ // ../../node_modules/get-stream/index.js
196903
+ var require_get_stream = __commonJS((exports, module) => {
196904
+ var { constants: BufferConstants } = __require("buffer");
196905
+ var pump = require_pump();
196906
+ var bufferStream = require_buffer_stream();
196907
+
196908
+ class MaxBufferError extends Error {
196909
+ constructor() {
196910
+ super("maxBuffer exceeded");
196911
+ this.name = "MaxBufferError";
196969
196912
  }
196970
196913
  }
196971
- module.exports = Utils;
196972
- Utils.prototype.makeDir = function(folder) {
196973
- const self2 = this;
196974
- function mkdirSync(fpath) {
196975
- let resolvedPath = fpath.split(self2.sep)[0];
196976
- fpath.split(self2.sep).forEach(function(name) {
196977
- if (!name || name.substr(-1, 1) === ":")
196914
+ async function getStream(inputStream, options) {
196915
+ if (!inputStream) {
196916
+ return Promise.reject(new Error("Expected a stream"));
196917
+ }
196918
+ options = {
196919
+ maxBuffer: Infinity,
196920
+ ...options
196921
+ };
196922
+ const { maxBuffer } = options;
196923
+ let stream4;
196924
+ await new Promise((resolve3, reject) => {
196925
+ const rejectPromise = (error) => {
196926
+ if (error && stream4.getBufferedLength() <= BufferConstants.MAX_LENGTH) {
196927
+ error.bufferedData = stream4.getBufferedValue();
196928
+ }
196929
+ reject(error);
196930
+ };
196931
+ stream4 = pump(inputStream, bufferStream(options), (error) => {
196932
+ if (error) {
196933
+ rejectPromise(error);
196978
196934
  return;
196979
- resolvedPath += self2.sep + name;
196980
- var stat4;
196981
- try {
196982
- stat4 = self2.fs.statSync(resolvedPath);
196983
- } catch (e) {
196984
- self2.fs.mkdirSync(resolvedPath);
196985
196935
  }
196986
- if (stat4 && stat4.isFile())
196987
- throw Errors.FILE_IN_THE_WAY(`"${resolvedPath}"`);
196936
+ resolve3();
196988
196937
  });
196938
+ stream4.on("data", () => {
196939
+ if (stream4.getBufferedLength() > maxBuffer) {
196940
+ rejectPromise(new MaxBufferError);
196941
+ }
196942
+ });
196943
+ });
196944
+ return stream4.getBufferedValue();
196945
+ }
196946
+ module.exports = getStream;
196947
+ module.exports.default = getStream;
196948
+ module.exports.buffer = (stream4, options) => getStream(stream4, { ...options, encoding: "buffer" });
196949
+ module.exports.array = (stream4, options) => getStream(stream4, { ...options, array: true });
196950
+ module.exports.MaxBufferError = MaxBufferError;
196951
+ });
196952
+
196953
+ // ../../node_modules/pend/index.js
196954
+ var require_pend = __commonJS((exports, module) => {
196955
+ module.exports = Pend;
196956
+ function Pend() {
196957
+ this.pending = 0;
196958
+ this.max = Infinity;
196959
+ this.listeners = [];
196960
+ this.waiting = [];
196961
+ this.error = null;
196962
+ }
196963
+ Pend.prototype.go = function(fn) {
196964
+ if (this.pending < this.max) {
196965
+ pendGo(this, fn);
196966
+ } else {
196967
+ this.waiting.push(fn);
196989
196968
  }
196990
- mkdirSync(folder);
196991
196969
  };
196992
- Utils.prototype.writeFileTo = function(path3, content, overwrite, attr) {
196993
- const self2 = this;
196994
- if (self2.fs.existsSync(path3)) {
196995
- if (!overwrite)
196996
- return false;
196997
- var stat4 = self2.fs.statSync(path3);
196998
- if (stat4.isDirectory()) {
196999
- return false;
197000
- }
197001
- }
197002
- var folder = pth.dirname(path3);
197003
- if (!self2.fs.existsSync(folder)) {
197004
- self2.makeDir(folder);
197005
- }
197006
- var fd;
197007
- try {
197008
- fd = self2.fs.openSync(path3, "w", 438);
197009
- } catch (e) {
197010
- self2.fs.chmodSync(path3, 438);
197011
- fd = self2.fs.openSync(path3, "w", 438);
196970
+ Pend.prototype.wait = function(cb) {
196971
+ if (this.pending === 0) {
196972
+ cb(this.error);
196973
+ } else {
196974
+ this.listeners.push(cb);
197012
196975
  }
197013
- if (fd) {
197014
- try {
197015
- self2.fs.writeSync(fd, content, 0, content.length, 0);
197016
- } finally {
197017
- self2.fs.closeSync(fd);
196976
+ };
196977
+ Pend.prototype.hold = function() {
196978
+ return pendHold(this);
196979
+ };
196980
+ function pendHold(self2) {
196981
+ self2.pending += 1;
196982
+ var called = false;
196983
+ return onCb;
196984
+ function onCb(err) {
196985
+ if (called)
196986
+ throw new Error("callback called twice");
196987
+ called = true;
196988
+ self2.error = self2.error || err;
196989
+ self2.pending -= 1;
196990
+ if (self2.waiting.length > 0 && self2.pending < self2.max) {
196991
+ pendGo(self2, self2.waiting.shift());
196992
+ } else if (self2.pending === 0) {
196993
+ var listeners = self2.listeners;
196994
+ self2.listeners = [];
196995
+ listeners.forEach(cbListener);
197018
196996
  }
197019
196997
  }
197020
- self2.fs.chmodSync(path3, attr || 438);
197021
- return true;
197022
- };
197023
- Utils.prototype.writeFileToAsync = function(path3, content, overwrite, attr, callback) {
197024
- if (typeof attr === "function") {
197025
- callback = attr;
197026
- attr = undefined;
196998
+ function cbListener(listener) {
196999
+ listener(self2.error);
197027
197000
  }
197028
- const self2 = this;
197029
- self2.fs.exists(path3, function(exist) {
197030
- if (exist && !overwrite)
197031
- return callback(false);
197032
- self2.fs.stat(path3, function(err, stat4) {
197033
- if (exist && stat4.isDirectory()) {
197034
- return callback(false);
197035
- }
197036
- var folder = pth.dirname(path3);
197037
- self2.fs.exists(folder, function(exists) {
197038
- if (!exists)
197039
- self2.makeDir(folder);
197040
- self2.fs.open(path3, "w", 438, function(err2, fd) {
197041
- if (err2) {
197042
- self2.fs.chmod(path3, 438, function() {
197043
- self2.fs.open(path3, "w", 438, function(err3, fd2) {
197044
- self2.fs.write(fd2, content, 0, content.length, 0, function() {
197045
- self2.fs.close(fd2, function() {
197046
- self2.fs.chmod(path3, attr || 438, function() {
197047
- callback(true);
197048
- });
197049
- });
197050
- });
197051
- });
197052
- });
197053
- } else if (fd) {
197054
- self2.fs.write(fd, content, 0, content.length, 0, function() {
197055
- self2.fs.close(fd, function() {
197056
- self2.fs.chmod(path3, attr || 438, function() {
197057
- callback(true);
197058
- });
197059
- });
197060
- });
197061
- } else {
197062
- self2.fs.chmod(path3, attr || 438, function() {
197063
- callback(true);
197064
- });
197065
- }
197066
- });
197067
- });
197001
+ }
197002
+ function pendGo(self2, fn) {
197003
+ fn(pendHold(self2));
197004
+ }
197005
+ });
197006
+
197007
+ // ../../node_modules/fd-slicer/index.js
197008
+ var require_fd_slicer = __commonJS((exports) => {
197009
+ var fs2 = __require("fs");
197010
+ var util5 = __require("util");
197011
+ var stream4 = __require("stream");
197012
+ var Readable3 = stream4.Readable;
197013
+ var Writable = stream4.Writable;
197014
+ var PassThrough = stream4.PassThrough;
197015
+ var Pend = require_pend();
197016
+ var EventEmitter3 = __require("events").EventEmitter;
197017
+ exports.createFromBuffer = createFromBuffer;
197018
+ exports.createFromFd = createFromFd;
197019
+ exports.BufferSlicer = BufferSlicer;
197020
+ exports.FdSlicer = FdSlicer;
197021
+ util5.inherits(FdSlicer, EventEmitter3);
197022
+ function FdSlicer(fd, options) {
197023
+ options = options || {};
197024
+ EventEmitter3.call(this);
197025
+ this.fd = fd;
197026
+ this.pend = new Pend;
197027
+ this.pend.max = 1;
197028
+ this.refCount = 0;
197029
+ this.autoClose = !!options.autoClose;
197030
+ }
197031
+ FdSlicer.prototype.read = function(buffer, offset, length, position, callback) {
197032
+ var self2 = this;
197033
+ self2.pend.go(function(cb) {
197034
+ fs2.read(self2.fd, buffer, offset, length, position, function(err, bytesRead, buffer2) {
197035
+ cb();
197036
+ callback(err, bytesRead, buffer2);
197068
197037
  });
197069
197038
  });
197070
197039
  };
197071
- Utils.prototype.findFiles = function(path3) {
197072
- const self2 = this;
197073
- function findSync(dir, pattern, recursive) {
197074
- if (typeof pattern === "boolean") {
197075
- recursive = pattern;
197076
- pattern = undefined;
197077
- }
197078
- let files = [];
197079
- self2.fs.readdirSync(dir).forEach(function(file) {
197080
- const path4 = pth.join(dir, file);
197081
- const stat4 = self2.fs.statSync(path4);
197082
- if (!pattern || pattern.test(path4)) {
197083
- files.push(pth.normalize(path4) + (stat4.isDirectory() ? self2.sep : ""));
197084
- }
197085
- if (stat4.isDirectory() && recursive)
197086
- files = files.concat(findSync(path4, pattern, recursive));
197087
- });
197088
- return files;
197089
- }
197090
- return findSync(path3, undefined, true);
197091
- };
197092
- Utils.prototype.findFilesAsync = function(dir, cb) {
197093
- const self2 = this;
197094
- let results = [];
197095
- self2.fs.readdir(dir, function(err, list) {
197096
- if (err)
197097
- return cb(err);
197098
- let list_length = list.length;
197099
- if (!list_length)
197100
- return cb(null, results);
197101
- list.forEach(function(file) {
197102
- file = pth.join(dir, file);
197103
- self2.fs.stat(file, function(err2, stat4) {
197104
- if (err2)
197105
- return cb(err2);
197106
- if (stat4) {
197107
- results.push(pth.normalize(file) + (stat4.isDirectory() ? self2.sep : ""));
197108
- if (stat4.isDirectory()) {
197109
- self2.findFilesAsync(file, function(err3, res) {
197110
- if (err3)
197111
- return cb(err3);
197112
- results = results.concat(res);
197113
- if (!--list_length)
197114
- cb(null, results);
197115
- });
197116
- } else {
197117
- if (!--list_length)
197118
- cb(null, results);
197119
- }
197120
- }
197121
- });
197040
+ FdSlicer.prototype.write = function(buffer, offset, length, position, callback) {
197041
+ var self2 = this;
197042
+ self2.pend.go(function(cb) {
197043
+ fs2.write(self2.fd, buffer, offset, length, position, function(err, written, buffer2) {
197044
+ cb();
197045
+ callback(err, written, buffer2);
197122
197046
  });
197123
197047
  });
197124
197048
  };
197125
- Utils.prototype.getAttributes = function() {};
197126
- Utils.prototype.setAttributes = function() {};
197127
- Utils.crc32update = function(crc, byte) {
197128
- return crcTable[(crc ^ byte) & 255] ^ crc >>> 8;
197129
- };
197130
- Utils.crc32 = function(buf) {
197131
- if (typeof buf === "string") {
197132
- buf = Buffer.from(buf, "utf8");
197133
- }
197134
- let len = buf.length;
197135
- let crc = ~0;
197136
- for (let off = 0;off < len; )
197137
- crc = Utils.crc32update(crc, buf[off++]);
197138
- return ~crc >>> 0;
197139
- };
197140
- Utils.methodToString = function(method) {
197141
- switch (method) {
197142
- case Constants.STORED:
197143
- return "STORED (" + method + ")";
197144
- case Constants.DEFLATED:
197145
- return "DEFLATED (" + method + ")";
197146
- default:
197147
- return "UNSUPPORTED (" + method + ")";
197148
- }
197049
+ FdSlicer.prototype.createReadStream = function(options) {
197050
+ return new ReadStream(this, options);
197149
197051
  };
197150
- Utils.canonical = function(path3) {
197151
- if (!path3)
197152
- return "";
197153
- const safeSuffix = pth.posix.normalize("/" + path3.split("\\").join("/"));
197154
- return pth.join(".", safeSuffix);
197052
+ FdSlicer.prototype.createWriteStream = function(options) {
197053
+ return new WriteStream(this, options);
197155
197054
  };
197156
- Utils.zipnamefix = function(path3) {
197157
- if (!path3)
197158
- return "";
197159
- const safeSuffix = pth.posix.normalize("/" + path3.split("\\").join("/"));
197160
- return pth.posix.join(".", safeSuffix);
197055
+ FdSlicer.prototype.ref = function() {
197056
+ this.refCount += 1;
197161
197057
  };
197162
- Utils.findLast = function(arr, callback) {
197163
- if (!Array.isArray(arr))
197164
- throw new TypeError("arr is not array");
197165
- const len = arr.length >>> 0;
197166
- for (let i = len - 1;i >= 0; i--) {
197167
- if (callback(arr[i], i, arr)) {
197168
- return arr[i];
197169
- }
197058
+ FdSlicer.prototype.unref = function() {
197059
+ var self2 = this;
197060
+ self2.refCount -= 1;
197061
+ if (self2.refCount > 0)
197062
+ return;
197063
+ if (self2.refCount < 0)
197064
+ throw new Error("invalid unref");
197065
+ if (self2.autoClose) {
197066
+ fs2.close(self2.fd, onCloseDone);
197170
197067
  }
197171
- return;
197172
- };
197173
- Utils.sanitize = function(prefix, name) {
197174
- prefix = pth.resolve(pth.normalize(prefix));
197175
- var parts = name.split("/");
197176
- for (var i = 0, l = parts.length;i < l; i++) {
197177
- var path3 = pth.normalize(pth.join(prefix, parts.slice(i, l).join(pth.sep)));
197178
- if (path3.indexOf(prefix) === 0) {
197179
- return path3;
197068
+ function onCloseDone(err) {
197069
+ if (err) {
197070
+ self2.emit("error", err);
197071
+ } else {
197072
+ self2.emit("close");
197180
197073
  }
197181
197074
  }
197182
- return pth.normalize(pth.join(prefix, pth.basename(name)));
197183
197075
  };
197184
- Utils.toBuffer = function toBuffer(input, encoder) {
197185
- if (Buffer.isBuffer(input)) {
197186
- return input;
197187
- } else if (input instanceof Uint8Array) {
197188
- return Buffer.from(input);
197189
- } else {
197190
- return typeof input === "string" ? encoder(input) : Buffer.alloc(0);
197076
+ util5.inherits(ReadStream, Readable3);
197077
+ function ReadStream(context, options) {
197078
+ options = options || {};
197079
+ Readable3.call(this, options);
197080
+ this.context = context;
197081
+ this.context.ref();
197082
+ this.start = options.start || 0;
197083
+ this.endOffset = options.end;
197084
+ this.pos = this.start;
197085
+ this.destroyed = false;
197086
+ }
197087
+ ReadStream.prototype._read = function(n) {
197088
+ var self2 = this;
197089
+ if (self2.destroyed)
197090
+ return;
197091
+ var toRead = Math.min(self2._readableState.highWaterMark, n);
197092
+ if (self2.endOffset != null) {
197093
+ toRead = Math.min(toRead, self2.endOffset - self2.pos);
197191
197094
  }
197095
+ if (toRead <= 0) {
197096
+ self2.destroyed = true;
197097
+ self2.push(null);
197098
+ self2.context.unref();
197099
+ return;
197100
+ }
197101
+ self2.context.pend.go(function(cb) {
197102
+ if (self2.destroyed)
197103
+ return cb();
197104
+ var buffer = new Buffer(toRead);
197105
+ fs2.read(self2.context.fd, buffer, 0, toRead, self2.pos, function(err, bytesRead) {
197106
+ if (err) {
197107
+ self2.destroy(err);
197108
+ } else if (bytesRead === 0) {
197109
+ self2.destroyed = true;
197110
+ self2.push(null);
197111
+ self2.context.unref();
197112
+ } else {
197113
+ self2.pos += bytesRead;
197114
+ self2.push(buffer.slice(0, bytesRead));
197115
+ }
197116
+ cb();
197117
+ });
197118
+ });
197192
197119
  };
197193
- Utils.readBigUInt64LE = function(buffer, index) {
197194
- var slice = Buffer.from(buffer.slice(index, index + 8));
197195
- slice.swap64();
197196
- return parseInt(`0x${slice.toString("hex")}`);
197197
- };
197198
- Utils.fromDOS2Date = function(val) {
197199
- return new Date((val >> 25 & 127) + 1980, Math.max((val >> 21 & 15) - 1, 0), Math.max(val >> 16 & 31, 1), val >> 11 & 31, val >> 5 & 63, (val & 31) << 1);
197120
+ ReadStream.prototype.destroy = function(err) {
197121
+ if (this.destroyed)
197122
+ return;
197123
+ err = err || new Error("stream destroyed");
197124
+ this.destroyed = true;
197125
+ this.emit("error", err);
197126
+ this.context.unref();
197200
197127
  };
197201
- Utils.fromDate2DOS = function(val) {
197202
- let date = 0;
197203
- let time = 0;
197204
- if (val.getFullYear() > 1979) {
197205
- date = (val.getFullYear() - 1980 & 127) << 9 | val.getMonth() + 1 << 5 | val.getDate();
197206
- time = val.getHours() << 11 | val.getMinutes() << 5 | val.getSeconds() >> 1;
197128
+ util5.inherits(WriteStream, Writable);
197129
+ function WriteStream(context, options) {
197130
+ options = options || {};
197131
+ Writable.call(this, options);
197132
+ this.context = context;
197133
+ this.context.ref();
197134
+ this.start = options.start || 0;
197135
+ this.endOffset = options.end == null ? Infinity : +options.end;
197136
+ this.bytesWritten = 0;
197137
+ this.pos = this.start;
197138
+ this.destroyed = false;
197139
+ this.on("finish", this.destroy.bind(this));
197140
+ }
197141
+ WriteStream.prototype._write = function(buffer, encoding, callback) {
197142
+ var self2 = this;
197143
+ if (self2.destroyed)
197144
+ return;
197145
+ if (self2.pos + buffer.length > self2.endOffset) {
197146
+ var err = new Error("maximum file length exceeded");
197147
+ err.code = "ETOOBIG";
197148
+ self2.destroy();
197149
+ callback(err);
197150
+ return;
197207
197151
  }
197208
- return date << 16 | time;
197152
+ self2.context.pend.go(function(cb) {
197153
+ if (self2.destroyed)
197154
+ return cb();
197155
+ fs2.write(self2.context.fd, buffer, 0, buffer.length, self2.pos, function(err2, bytes) {
197156
+ if (err2) {
197157
+ self2.destroy();
197158
+ cb();
197159
+ callback(err2);
197160
+ } else {
197161
+ self2.bytesWritten += bytes;
197162
+ self2.pos += bytes;
197163
+ self2.emit("progress");
197164
+ cb();
197165
+ callback();
197166
+ }
197167
+ });
197168
+ });
197209
197169
  };
197210
- Utils.isWin = isWin;
197211
- Utils.crcTable = crcTable;
197212
- });
197213
-
197214
- // ../../node_modules/adm-zip/util/fattr.js
197215
- var require_fattr = __commonJS((exports, module) => {
197216
- var pth = __require("path");
197217
- module.exports = function(path3, { fs: fs2 }) {
197218
- var _path = path3 || "", _obj = newAttr(), _stat = null;
197219
- function newAttr() {
197220
- return {
197221
- directory: false,
197222
- readonly: false,
197223
- hidden: false,
197224
- executable: false,
197225
- mtime: 0,
197226
- atime: 0
197227
- };
197228
- }
197229
- if (_path && fs2.existsSync(_path)) {
197230
- _stat = fs2.statSync(_path);
197231
- _obj.directory = _stat.isDirectory();
197232
- _obj.mtime = _stat.mtime;
197233
- _obj.atime = _stat.atime;
197234
- _obj.executable = (73 & _stat.mode) !== 0;
197235
- _obj.readonly = (128 & _stat.mode) === 0;
197236
- _obj.hidden = pth.basename(_path)[0] === ".";
197237
- } else {
197238
- console.warn("Invalid path: " + _path);
197239
- }
197240
- return {
197241
- get directory() {
197242
- return _obj.directory;
197243
- },
197244
- get readOnly() {
197245
- return _obj.readonly;
197246
- },
197247
- get hidden() {
197248
- return _obj.hidden;
197249
- },
197250
- get mtime() {
197251
- return _obj.mtime;
197252
- },
197253
- get atime() {
197254
- return _obj.atime;
197255
- },
197256
- get executable() {
197257
- return _obj.executable;
197258
- },
197259
- decodeAttributes: function() {},
197260
- encodeAttributes: function() {},
197261
- toJSON: function() {
197262
- return {
197263
- path: _path,
197264
- isDirectory: _obj.directory,
197265
- isReadOnly: _obj.readonly,
197266
- isHidden: _obj.hidden,
197267
- isExecutable: _obj.executable,
197268
- mTime: _obj.mtime,
197269
- aTime: _obj.atime
197270
- };
197271
- },
197272
- toString: function() {
197273
- return JSON.stringify(this.toJSON(), null, "\t");
197274
- }
197275
- };
197170
+ WriteStream.prototype.destroy = function() {
197171
+ if (this.destroyed)
197172
+ return;
197173
+ this.destroyed = true;
197174
+ this.context.unref();
197276
197175
  };
197277
- });
197278
-
197279
- // ../../node_modules/adm-zip/util/decoder.js
197280
- var require_decoder2 = __commonJS((exports, module) => {
197281
- module.exports = {
197282
- efs: true,
197283
- encode: (data) => Buffer.from(data, "utf8"),
197284
- decode: (data) => data.toString("utf8")
197176
+ util5.inherits(BufferSlicer, EventEmitter3);
197177
+ function BufferSlicer(buffer, options) {
197178
+ EventEmitter3.call(this);
197179
+ options = options || {};
197180
+ this.refCount = 0;
197181
+ this.buffer = buffer;
197182
+ this.maxChunkSize = options.maxChunkSize || Number.MAX_SAFE_INTEGER;
197183
+ }
197184
+ BufferSlicer.prototype.read = function(buffer, offset, length, position, callback) {
197185
+ var end = position + length;
197186
+ var delta = end - this.buffer.length;
197187
+ var written = delta > 0 ? delta : length;
197188
+ this.buffer.copy(buffer, offset, position, end);
197189
+ setImmediate(function() {
197190
+ callback(null, written);
197191
+ });
197285
197192
  };
197286
- });
197287
-
197288
- // ../../node_modules/adm-zip/util/index.js
197289
- var require_util12 = __commonJS((exports, module) => {
197290
- module.exports = require_utils74();
197291
- module.exports.Constants = require_constants24();
197292
- module.exports.Errors = require_errors6();
197293
- module.exports.FileAttr = require_fattr();
197294
- module.exports.decoder = require_decoder2();
197295
- });
197296
-
197297
- // ../../node_modules/adm-zip/headers/entryHeader.js
197298
- var require_entryHeader = __commonJS((exports, module) => {
197299
- var Utils = require_util12();
197300
- var Constants = Utils.Constants;
197301
- module.exports = function() {
197302
- var _verMade = 20, _version = 10, _flags = 0, _method = 0, _time = 0, _crc = 0, _compressedSize = 0, _size = 0, _fnameLen = 0, _extraLen = 0, _comLen = 0, _diskStart = 0, _inattr = 0, _attr = 0, _offset = 0;
197303
- _verMade |= Utils.isWin ? 2560 : 768;
197304
- _flags |= Constants.FLG_EFS;
197305
- const _localHeader = {
197306
- extraLen: 0
197307
- };
197308
- const uint32 = (val) => Math.max(0, val) >>> 0;
197309
- const uint16 = (val) => Math.max(0, val) & 65535;
197310
- const uint8 = (val) => Math.max(0, val) & 255;
197311
- _time = Utils.fromDate2DOS(new Date);
197312
- return {
197313
- get made() {
197314
- return _verMade;
197315
- },
197316
- set made(val) {
197317
- _verMade = val;
197318
- },
197319
- get version() {
197320
- return _version;
197321
- },
197322
- set version(val) {
197323
- _version = val;
197324
- },
197325
- get flags() {
197326
- return _flags;
197327
- },
197328
- set flags(val) {
197329
- _flags = val;
197330
- },
197331
- get flags_efs() {
197332
- return (_flags & Constants.FLG_EFS) > 0;
197333
- },
197334
- set flags_efs(val) {
197335
- if (val) {
197336
- _flags |= Constants.FLG_EFS;
197337
- } else {
197338
- _flags &= ~Constants.FLG_EFS;
197339
- }
197340
- },
197341
- get flags_desc() {
197342
- return (_flags & Constants.FLG_DESC) > 0;
197343
- },
197344
- set flags_desc(val) {
197345
- if (val) {
197346
- _flags |= Constants.FLG_DESC;
197347
- } else {
197348
- _flags &= ~Constants.FLG_DESC;
197349
- }
197350
- },
197351
- get method() {
197352
- return _method;
197353
- },
197354
- set method(val) {
197355
- switch (val) {
197356
- case Constants.STORED:
197357
- this.version = 10;
197358
- case Constants.DEFLATED:
197359
- default:
197360
- this.version = 20;
197193
+ BufferSlicer.prototype.write = function(buffer, offset, length, position, callback) {
197194
+ buffer.copy(this.buffer, position, offset, offset + length);
197195
+ setImmediate(function() {
197196
+ callback(null, length, buffer);
197197
+ });
197198
+ };
197199
+ BufferSlicer.prototype.createReadStream = function(options) {
197200
+ options = options || {};
197201
+ var readStream2 = new PassThrough(options);
197202
+ readStream2.destroyed = false;
197203
+ readStream2.start = options.start || 0;
197204
+ readStream2.endOffset = options.end;
197205
+ readStream2.pos = readStream2.endOffset || this.buffer.length;
197206
+ var entireSlice = this.buffer.slice(readStream2.start, readStream2.pos);
197207
+ var offset = 0;
197208
+ while (true) {
197209
+ var nextOffset = offset + this.maxChunkSize;
197210
+ if (nextOffset >= entireSlice.length) {
197211
+ if (offset < entireSlice.length) {
197212
+ readStream2.write(entireSlice.slice(offset, entireSlice.length));
197361
197213
  }
197362
- _method = val;
197363
- },
197364
- get time() {
197365
- return Utils.fromDOS2Date(this.timeval);
197366
- },
197367
- set time(val) {
197368
- this.timeval = Utils.fromDate2DOS(val);
197369
- },
197370
- get timeval() {
197371
- return _time;
197372
- },
197373
- set timeval(val) {
197374
- _time = uint32(val);
197375
- },
197376
- get timeHighByte() {
197377
- return uint8(_time >>> 8);
197378
- },
197379
- get crc() {
197380
- return _crc;
197381
- },
197382
- set crc(val) {
197383
- _crc = uint32(val);
197384
- },
197385
- get compressedSize() {
197386
- return _compressedSize;
197387
- },
197388
- set compressedSize(val) {
197389
- _compressedSize = uint32(val);
197390
- },
197391
- get size() {
197392
- return _size;
197393
- },
197394
- set size(val) {
197395
- _size = uint32(val);
197396
- },
197397
- get fileNameLength() {
197398
- return _fnameLen;
197399
- },
197400
- set fileNameLength(val) {
197401
- _fnameLen = val;
197402
- },
197403
- get extraLength() {
197404
- return _extraLen;
197405
- },
197406
- set extraLength(val) {
197407
- _extraLen = val;
197408
- },
197409
- get extraLocalLength() {
197410
- return _localHeader.extraLen;
197411
- },
197412
- set extraLocalLength(val) {
197413
- _localHeader.extraLen = val;
197414
- },
197415
- get commentLength() {
197416
- return _comLen;
197417
- },
197418
- set commentLength(val) {
197419
- _comLen = val;
197420
- },
197421
- get diskNumStart() {
197422
- return _diskStart;
197423
- },
197424
- set diskNumStart(val) {
197425
- _diskStart = uint32(val);
197426
- },
197427
- get inAttr() {
197428
- return _inattr;
197429
- },
197430
- set inAttr(val) {
197431
- _inattr = uint32(val);
197432
- },
197433
- get attr() {
197434
- return _attr;
197435
- },
197436
- set attr(val) {
197437
- _attr = uint32(val);
197438
- },
197439
- get fileAttr() {
197440
- return (_attr || 0) >> 16 & 4095;
197441
- },
197442
- get offset() {
197443
- return _offset;
197444
- },
197445
- set offset(val) {
197446
- _offset = uint32(val);
197447
- },
197448
- get encrypted() {
197449
- return (_flags & Constants.FLG_ENC) === Constants.FLG_ENC;
197450
- },
197451
- get centralHeaderSize() {
197452
- return Constants.CENHDR + _fnameLen + _extraLen + _comLen;
197453
- },
197454
- get realDataOffset() {
197455
- return _offset + Constants.LOCHDR + _localHeader.fnameLen + _localHeader.extraLen;
197456
- },
197457
- get localHeader() {
197458
- return _localHeader;
197459
- },
197460
- loadLocalHeaderFromBinary: function(input) {
197461
- var data = input.slice(_offset, _offset + Constants.LOCHDR);
197462
- if (data.readUInt32LE(0) !== Constants.LOCSIG) {
197463
- throw Utils.Errors.INVALID_LOC();
197464
- }
197465
- _localHeader.version = data.readUInt16LE(Constants.LOCVER);
197466
- _localHeader.flags = data.readUInt16LE(Constants.LOCFLG);
197467
- _localHeader.method = data.readUInt16LE(Constants.LOCHOW);
197468
- _localHeader.time = data.readUInt32LE(Constants.LOCTIM);
197469
- _localHeader.crc = data.readUInt32LE(Constants.LOCCRC);
197470
- _localHeader.compressedSize = data.readUInt32LE(Constants.LOCSIZ);
197471
- _localHeader.size = data.readUInt32LE(Constants.LOCLEN);
197472
- _localHeader.fnameLen = data.readUInt16LE(Constants.LOCNAM);
197473
- _localHeader.extraLen = data.readUInt16LE(Constants.LOCEXT);
197474
- const extraStart = _offset + Constants.LOCHDR + _localHeader.fnameLen;
197475
- const extraEnd = extraStart + _localHeader.extraLen;
197476
- return input.slice(extraStart, extraEnd);
197477
- },
197478
- loadFromBinary: function(data) {
197479
- if (data.length !== Constants.CENHDR || data.readUInt32LE(0) !== Constants.CENSIG) {
197480
- throw Utils.Errors.INVALID_CEN();
197481
- }
197482
- _verMade = data.readUInt16LE(Constants.CENVEM);
197483
- _version = data.readUInt16LE(Constants.CENVER);
197484
- _flags = data.readUInt16LE(Constants.CENFLG);
197485
- _method = data.readUInt16LE(Constants.CENHOW);
197486
- _time = data.readUInt32LE(Constants.CENTIM);
197487
- _crc = data.readUInt32LE(Constants.CENCRC);
197488
- _compressedSize = data.readUInt32LE(Constants.CENSIZ);
197489
- _size = data.readUInt32LE(Constants.CENLEN);
197490
- _fnameLen = data.readUInt16LE(Constants.CENNAM);
197491
- _extraLen = data.readUInt16LE(Constants.CENEXT);
197492
- _comLen = data.readUInt16LE(Constants.CENCOM);
197493
- _diskStart = data.readUInt16LE(Constants.CENDSK);
197494
- _inattr = data.readUInt16LE(Constants.CENATT);
197495
- _attr = data.readUInt32LE(Constants.CENATX);
197496
- _offset = data.readUInt32LE(Constants.CENOFF);
197497
- },
197498
- localHeaderToBinary: function() {
197499
- var data = Buffer.alloc(Constants.LOCHDR);
197500
- data.writeUInt32LE(Constants.LOCSIG, 0);
197501
- data.writeUInt16LE(_version, Constants.LOCVER);
197502
- data.writeUInt16LE(_flags, Constants.LOCFLG);
197503
- data.writeUInt16LE(_method, Constants.LOCHOW);
197504
- data.writeUInt32LE(_time, Constants.LOCTIM);
197505
- data.writeUInt32LE(_crc, Constants.LOCCRC);
197506
- data.writeUInt32LE(_compressedSize, Constants.LOCSIZ);
197507
- data.writeUInt32LE(_size, Constants.LOCLEN);
197508
- data.writeUInt16LE(_fnameLen, Constants.LOCNAM);
197509
- data.writeUInt16LE(_localHeader.extraLen, Constants.LOCEXT);
197510
- return data;
197511
- },
197512
- centralHeaderToBinary: function() {
197513
- var data = Buffer.alloc(Constants.CENHDR + _fnameLen + _extraLen + _comLen);
197514
- data.writeUInt32LE(Constants.CENSIG, 0);
197515
- data.writeUInt16LE(_verMade, Constants.CENVEM);
197516
- data.writeUInt16LE(_version, Constants.CENVER);
197517
- data.writeUInt16LE(_flags, Constants.CENFLG);
197518
- data.writeUInt16LE(_method, Constants.CENHOW);
197519
- data.writeUInt32LE(_time, Constants.CENTIM);
197520
- data.writeUInt32LE(_crc, Constants.CENCRC);
197521
- data.writeUInt32LE(_compressedSize, Constants.CENSIZ);
197522
- data.writeUInt32LE(_size, Constants.CENLEN);
197523
- data.writeUInt16LE(_fnameLen, Constants.CENNAM);
197524
- data.writeUInt16LE(_extraLen, Constants.CENEXT);
197525
- data.writeUInt16LE(_comLen, Constants.CENCOM);
197526
- data.writeUInt16LE(_diskStart, Constants.CENDSK);
197527
- data.writeUInt16LE(_inattr, Constants.CENATT);
197528
- data.writeUInt32LE(_attr, Constants.CENATX);
197529
- data.writeUInt32LE(_offset, Constants.CENOFF);
197530
- return data;
197531
- },
197532
- toJSON: function() {
197533
- const bytes = function(nr) {
197534
- return nr + " bytes";
197535
- };
197536
- return {
197537
- made: _verMade,
197538
- version: _version,
197539
- flags: _flags,
197540
- method: Utils.methodToString(_method),
197541
- time: this.time,
197542
- crc: "0x" + _crc.toString(16).toUpperCase(),
197543
- compressedSize: bytes(_compressedSize),
197544
- size: bytes(_size),
197545
- fileNameLength: bytes(_fnameLen),
197546
- extraLength: bytes(_extraLen),
197547
- commentLength: bytes(_comLen),
197548
- diskNumStart: _diskStart,
197549
- inAttr: _inattr,
197550
- attr: _attr,
197551
- offset: _offset,
197552
- centralHeaderSize: bytes(Constants.CENHDR + _fnameLen + _extraLen + _comLen)
197553
- };
197554
- },
197555
- toString: function() {
197556
- return JSON.stringify(this.toJSON(), null, "\t");
197214
+ break;
197557
197215
  }
197216
+ readStream2.write(entireSlice.slice(offset, nextOffset));
197217
+ offset = nextOffset;
197218
+ }
197219
+ readStream2.end();
197220
+ readStream2.destroy = function() {
197221
+ readStream2.destroyed = true;
197558
197222
  };
197223
+ return readStream2;
197559
197224
  };
197560
- });
197561
-
197562
- // ../../node_modules/adm-zip/headers/mainHeader.js
197563
- var require_mainHeader = __commonJS((exports, module) => {
197564
- var Utils = require_util12();
197565
- var Constants = Utils.Constants;
197566
- module.exports = function() {
197567
- var _volumeEntries = 0, _totalEntries = 0, _size = 0, _offset = 0, _commentLength = 0;
197568
- return {
197569
- get diskEntries() {
197570
- return _volumeEntries;
197571
- },
197572
- set diskEntries(val) {
197573
- _volumeEntries = _totalEntries = val;
197574
- },
197575
- get totalEntries() {
197576
- return _totalEntries;
197577
- },
197578
- set totalEntries(val) {
197579
- _totalEntries = _volumeEntries = val;
197580
- },
197581
- get size() {
197582
- return _size;
197583
- },
197584
- set size(val) {
197585
- _size = val;
197586
- },
197587
- get offset() {
197588
- return _offset;
197589
- },
197590
- set offset(val) {
197591
- _offset = val;
197592
- },
197593
- get commentLength() {
197594
- return _commentLength;
197595
- },
197596
- set commentLength(val) {
197597
- _commentLength = val;
197598
- },
197599
- get mainHeaderSize() {
197600
- return Constants.ENDHDR + _commentLength;
197601
- },
197602
- loadFromBinary: function(data) {
197603
- if ((data.length !== Constants.ENDHDR || data.readUInt32LE(0) !== Constants.ENDSIG) && (data.length < Constants.ZIP64HDR || data.readUInt32LE(0) !== Constants.ZIP64SIG)) {
197604
- throw Utils.Errors.INVALID_END();
197605
- }
197606
- if (data.readUInt32LE(0) === Constants.ENDSIG) {
197607
- _volumeEntries = data.readUInt16LE(Constants.ENDSUB);
197608
- _totalEntries = data.readUInt16LE(Constants.ENDTOT);
197609
- _size = data.readUInt32LE(Constants.ENDSIZ);
197610
- _offset = data.readUInt32LE(Constants.ENDOFF);
197611
- _commentLength = data.readUInt16LE(Constants.ENDCOM);
197612
- } else {
197613
- _volumeEntries = Utils.readBigUInt64LE(data, Constants.ZIP64SUB);
197614
- _totalEntries = Utils.readBigUInt64LE(data, Constants.ZIP64TOT);
197615
- _size = Utils.readBigUInt64LE(data, Constants.ZIP64SIZE);
197616
- _offset = Utils.readBigUInt64LE(data, Constants.ZIP64OFF);
197617
- _commentLength = 0;
197618
- }
197619
- },
197620
- toBinary: function() {
197621
- var b = Buffer.alloc(Constants.ENDHDR + _commentLength);
197622
- b.writeUInt32LE(Constants.ENDSIG, 0);
197623
- b.writeUInt32LE(0, 4);
197624
- b.writeUInt16LE(_volumeEntries, Constants.ENDSUB);
197625
- b.writeUInt16LE(_totalEntries, Constants.ENDTOT);
197626
- b.writeUInt32LE(_size, Constants.ENDSIZ);
197627
- b.writeUInt32LE(_offset, Constants.ENDOFF);
197628
- b.writeUInt16LE(_commentLength, Constants.ENDCOM);
197629
- b.fill(" ", Constants.ENDHDR);
197630
- return b;
197631
- },
197632
- toJSON: function() {
197633
- const offset = function(nr, len) {
197634
- let offs = nr.toString(16).toUpperCase();
197635
- while (offs.length < len)
197636
- offs = "0" + offs;
197637
- return "0x" + offs;
197638
- };
197639
- return {
197640
- diskEntries: _volumeEntries,
197641
- totalEntries: _totalEntries,
197642
- size: _size + " bytes",
197643
- offset: offset(_offset, 4),
197644
- commentLength: _commentLength
197645
- };
197646
- },
197647
- toString: function() {
197648
- return JSON.stringify(this.toJSON(), null, "\t");
197225
+ BufferSlicer.prototype.createWriteStream = function(options) {
197226
+ var bufferSlicer = this;
197227
+ options = options || {};
197228
+ var writeStream = new Writable(options);
197229
+ writeStream.start = options.start || 0;
197230
+ writeStream.endOffset = options.end == null ? this.buffer.length : +options.end;
197231
+ writeStream.bytesWritten = 0;
197232
+ writeStream.pos = writeStream.start;
197233
+ writeStream.destroyed = false;
197234
+ writeStream._write = function(buffer, encoding, callback) {
197235
+ if (writeStream.destroyed)
197236
+ return;
197237
+ var end = writeStream.pos + buffer.length;
197238
+ if (end > writeStream.endOffset) {
197239
+ var err = new Error("maximum file length exceeded");
197240
+ err.code = "ETOOBIG";
197241
+ writeStream.destroyed = true;
197242
+ callback(err);
197243
+ return;
197649
197244
  }
197245
+ buffer.copy(bufferSlicer.buffer, writeStream.pos, 0, buffer.length);
197246
+ writeStream.bytesWritten += buffer.length;
197247
+ writeStream.pos = end;
197248
+ writeStream.emit("progress");
197249
+ callback();
197250
+ };
197251
+ writeStream.destroy = function() {
197252
+ writeStream.destroyed = true;
197650
197253
  };
197254
+ return writeStream;
197651
197255
  };
197256
+ BufferSlicer.prototype.ref = function() {
197257
+ this.refCount += 1;
197258
+ };
197259
+ BufferSlicer.prototype.unref = function() {
197260
+ this.refCount -= 1;
197261
+ if (this.refCount < 0) {
197262
+ throw new Error("invalid unref");
197263
+ }
197264
+ };
197265
+ function createFromBuffer(buffer, options) {
197266
+ return new BufferSlicer(buffer, options);
197267
+ }
197268
+ function createFromFd(fd, options) {
197269
+ return new FdSlicer(fd, options);
197270
+ }
197652
197271
  });
197653
197272
 
197654
- // ../../node_modules/adm-zip/headers/index.js
197655
- var require_headers = __commonJS((exports) => {
197656
- exports.EntryHeader = require_entryHeader();
197657
- exports.MainHeader = require_mainHeader();
197658
- });
197659
-
197660
- // ../../node_modules/adm-zip/methods/deflater.js
197661
- var require_deflater = __commonJS((exports, module) => {
197662
- module.exports = function(inbuf) {
197663
- var zlib2 = __require("zlib");
197664
- var opts = { chunkSize: (parseInt(inbuf.length / 1024) + 1) * 1024 };
197665
- return {
197666
- deflate: function() {
197667
- return zlib2.deflateRawSync(inbuf, opts);
197668
- },
197669
- deflateAsync: function(callback) {
197670
- var tmp = zlib2.createDeflateRaw(opts), parts = [], total = 0;
197671
- tmp.on("data", function(data) {
197672
- parts.push(data);
197673
- total += data.length;
197674
- });
197675
- tmp.on("end", function() {
197676
- var buf = Buffer.alloc(total), written = 0;
197677
- buf.fill(0);
197678
- for (var i = 0;i < parts.length; i++) {
197679
- var part = parts[i];
197680
- part.copy(buf, written);
197681
- written += part.length;
197682
- }
197683
- callback && callback(buf);
197684
- });
197685
- tmp.end(inbuf);
197686
- }
197687
- };
197273
+ // ../../node_modules/yauzl/node_modules/buffer-crc32/index.js
197274
+ var require_buffer_crc32 = __commonJS((exports, module) => {
197275
+ var Buffer2 = __require("buffer").Buffer;
197276
+ var CRC_TABLE = [
197277
+ 0,
197278
+ 1996959894,
197279
+ 3993919788,
197280
+ 2567524794,
197281
+ 124634137,
197282
+ 1886057615,
197283
+ 3915621685,
197284
+ 2657392035,
197285
+ 249268274,
197286
+ 2044508324,
197287
+ 3772115230,
197288
+ 2547177864,
197289
+ 162941995,
197290
+ 2125561021,
197291
+ 3887607047,
197292
+ 2428444049,
197293
+ 498536548,
197294
+ 1789927666,
197295
+ 4089016648,
197296
+ 2227061214,
197297
+ 450548861,
197298
+ 1843258603,
197299
+ 4107580753,
197300
+ 2211677639,
197301
+ 325883990,
197302
+ 1684777152,
197303
+ 4251122042,
197304
+ 2321926636,
197305
+ 335633487,
197306
+ 1661365465,
197307
+ 4195302755,
197308
+ 2366115317,
197309
+ 997073096,
197310
+ 1281953886,
197311
+ 3579855332,
197312
+ 2724688242,
197313
+ 1006888145,
197314
+ 1258607687,
197315
+ 3524101629,
197316
+ 2768942443,
197317
+ 901097722,
197318
+ 1119000684,
197319
+ 3686517206,
197320
+ 2898065728,
197321
+ 853044451,
197322
+ 1172266101,
197323
+ 3705015759,
197324
+ 2882616665,
197325
+ 651767980,
197326
+ 1373503546,
197327
+ 3369554304,
197328
+ 3218104598,
197329
+ 565507253,
197330
+ 1454621731,
197331
+ 3485111705,
197332
+ 3099436303,
197333
+ 671266974,
197334
+ 1594198024,
197335
+ 3322730930,
197336
+ 2970347812,
197337
+ 795835527,
197338
+ 1483230225,
197339
+ 3244367275,
197340
+ 3060149565,
197341
+ 1994146192,
197342
+ 31158534,
197343
+ 2563907772,
197344
+ 4023717930,
197345
+ 1907459465,
197346
+ 112637215,
197347
+ 2680153253,
197348
+ 3904427059,
197349
+ 2013776290,
197350
+ 251722036,
197351
+ 2517215374,
197352
+ 3775830040,
197353
+ 2137656763,
197354
+ 141376813,
197355
+ 2439277719,
197356
+ 3865271297,
197357
+ 1802195444,
197358
+ 476864866,
197359
+ 2238001368,
197360
+ 4066508878,
197361
+ 1812370925,
197362
+ 453092731,
197363
+ 2181625025,
197364
+ 4111451223,
197365
+ 1706088902,
197366
+ 314042704,
197367
+ 2344532202,
197368
+ 4240017532,
197369
+ 1658658271,
197370
+ 366619977,
197371
+ 2362670323,
197372
+ 4224994405,
197373
+ 1303535960,
197374
+ 984961486,
197375
+ 2747007092,
197376
+ 3569037538,
197377
+ 1256170817,
197378
+ 1037604311,
197379
+ 2765210733,
197380
+ 3554079995,
197381
+ 1131014506,
197382
+ 879679996,
197383
+ 2909243462,
197384
+ 3663771856,
197385
+ 1141124467,
197386
+ 855842277,
197387
+ 2852801631,
197388
+ 3708648649,
197389
+ 1342533948,
197390
+ 654459306,
197391
+ 3188396048,
197392
+ 3373015174,
197393
+ 1466479909,
197394
+ 544179635,
197395
+ 3110523913,
197396
+ 3462522015,
197397
+ 1591671054,
197398
+ 702138776,
197399
+ 2966460450,
197400
+ 3352799412,
197401
+ 1504918807,
197402
+ 783551873,
197403
+ 3082640443,
197404
+ 3233442989,
197405
+ 3988292384,
197406
+ 2596254646,
197407
+ 62317068,
197408
+ 1957810842,
197409
+ 3939845945,
197410
+ 2647816111,
197411
+ 81470997,
197412
+ 1943803523,
197413
+ 3814918930,
197414
+ 2489596804,
197415
+ 225274430,
197416
+ 2053790376,
197417
+ 3826175755,
197418
+ 2466906013,
197419
+ 167816743,
197420
+ 2097651377,
197421
+ 4027552580,
197422
+ 2265490386,
197423
+ 503444072,
197424
+ 1762050814,
197425
+ 4150417245,
197426
+ 2154129355,
197427
+ 426522225,
197428
+ 1852507879,
197429
+ 4275313526,
197430
+ 2312317920,
197431
+ 282753626,
197432
+ 1742555852,
197433
+ 4189708143,
197434
+ 2394877945,
197435
+ 397917763,
197436
+ 1622183637,
197437
+ 3604390888,
197438
+ 2714866558,
197439
+ 953729732,
197440
+ 1340076626,
197441
+ 3518719985,
197442
+ 2797360999,
197443
+ 1068828381,
197444
+ 1219638859,
197445
+ 3624741850,
197446
+ 2936675148,
197447
+ 906185462,
197448
+ 1090812512,
197449
+ 3747672003,
197450
+ 2825379669,
197451
+ 829329135,
197452
+ 1181335161,
197453
+ 3412177804,
197454
+ 3160834842,
197455
+ 628085408,
197456
+ 1382605366,
197457
+ 3423369109,
197458
+ 3138078467,
197459
+ 570562233,
197460
+ 1426400815,
197461
+ 3317316542,
197462
+ 2998733608,
197463
+ 733239954,
197464
+ 1555261956,
197465
+ 3268935591,
197466
+ 3050360625,
197467
+ 752459403,
197468
+ 1541320221,
197469
+ 2607071920,
197470
+ 3965973030,
197471
+ 1969922972,
197472
+ 40735498,
197473
+ 2617837225,
197474
+ 3943577151,
197475
+ 1913087877,
197476
+ 83908371,
197477
+ 2512341634,
197478
+ 3803740692,
197479
+ 2075208622,
197480
+ 213261112,
197481
+ 2463272603,
197482
+ 3855990285,
197483
+ 2094854071,
197484
+ 198958881,
197485
+ 2262029012,
197486
+ 4057260610,
197487
+ 1759359992,
197488
+ 534414190,
197489
+ 2176718541,
197490
+ 4139329115,
197491
+ 1873836001,
197492
+ 414664567,
197493
+ 2282248934,
197494
+ 4279200368,
197495
+ 1711684554,
197496
+ 285281116,
197497
+ 2405801727,
197498
+ 4167216745,
197499
+ 1634467795,
197500
+ 376229701,
197501
+ 2685067896,
197502
+ 3608007406,
197503
+ 1308918612,
197504
+ 956543938,
197505
+ 2808555105,
197506
+ 3495958263,
197507
+ 1231636301,
197508
+ 1047427035,
197509
+ 2932959818,
197510
+ 3654703836,
197511
+ 1088359270,
197512
+ 936918000,
197513
+ 2847714899,
197514
+ 3736837829,
197515
+ 1202900863,
197516
+ 817233897,
197517
+ 3183342108,
197518
+ 3401237130,
197519
+ 1404277552,
197520
+ 615818150,
197521
+ 3134207493,
197522
+ 3453421203,
197523
+ 1423857449,
197524
+ 601450431,
197525
+ 3009837614,
197526
+ 3294710456,
197527
+ 1567103746,
197528
+ 711928724,
197529
+ 3020668471,
197530
+ 3272380065,
197531
+ 1510334235,
197532
+ 755167117
197533
+ ];
197534
+ if (typeof Int32Array !== "undefined") {
197535
+ CRC_TABLE = new Int32Array(CRC_TABLE);
197536
+ }
197537
+ function ensureBuffer(input) {
197538
+ if (Buffer2.isBuffer(input)) {
197539
+ return input;
197540
+ }
197541
+ var hasNewBufferAPI = typeof Buffer2.alloc === "function" && typeof Buffer2.from === "function";
197542
+ if (typeof input === "number") {
197543
+ return hasNewBufferAPI ? Buffer2.alloc(input) : new Buffer2(input);
197544
+ } else if (typeof input === "string") {
197545
+ return hasNewBufferAPI ? Buffer2.from(input) : new Buffer2(input);
197546
+ } else {
197547
+ throw new Error("input must be buffer, number, or string, received " + typeof input);
197548
+ }
197549
+ }
197550
+ function bufferizeInt(num) {
197551
+ var tmp = ensureBuffer(4);
197552
+ tmp.writeInt32BE(num, 0);
197553
+ return tmp;
197554
+ }
197555
+ function _crc32(buf, previous) {
197556
+ buf = ensureBuffer(buf);
197557
+ if (Buffer2.isBuffer(previous)) {
197558
+ previous = previous.readUInt32BE(0);
197559
+ }
197560
+ var crc = ~~previous ^ -1;
197561
+ for (var n = 0;n < buf.length; n++) {
197562
+ crc = CRC_TABLE[(crc ^ buf[n]) & 255] ^ crc >>> 8;
197563
+ }
197564
+ return crc ^ -1;
197565
+ }
197566
+ function crc32() {
197567
+ return bufferizeInt(_crc32.apply(null, arguments));
197568
+ }
197569
+ crc32.signed = function() {
197570
+ return _crc32.apply(null, arguments);
197688
197571
  };
197689
- });
197690
-
197691
- // ../../node_modules/adm-zip/methods/inflater.js
197692
- var require_inflater = __commonJS((exports, module) => {
197693
- var version = +(process.versions ? process.versions.node : "").split(".")[0] || 0;
197694
- module.exports = function(inbuf, expectedLength) {
197695
- var zlib2 = __require("zlib");
197696
- const option = version >= 15 && expectedLength > 0 ? { maxOutputLength: expectedLength } : {};
197697
- return {
197698
- inflate: function() {
197699
- return zlib2.inflateRawSync(inbuf, option);
197700
- },
197701
- inflateAsync: function(callback) {
197702
- var tmp = zlib2.createInflateRaw(option), parts = [], total = 0;
197703
- tmp.on("data", function(data) {
197704
- parts.push(data);
197705
- total += data.length;
197706
- });
197707
- tmp.on("end", function() {
197708
- var buf = Buffer.alloc(total), written = 0;
197709
- buf.fill(0);
197710
- for (var i = 0;i < parts.length; i++) {
197711
- var part = parts[i];
197712
- part.copy(buf, written);
197713
- written += part.length;
197714
- }
197715
- callback && callback(buf);
197716
- });
197717
- tmp.end(inbuf);
197718
- }
197719
- };
197572
+ crc32.unsigned = function() {
197573
+ return _crc32.apply(null, arguments) >>> 0;
197720
197574
  };
197575
+ module.exports = crc32;
197721
197576
  });
197722
197577
 
197723
- // ../../node_modules/adm-zip/methods/zipcrypto.js
197724
- var require_zipcrypto = __commonJS((exports, module) => {
197725
- var { randomFillSync } = __require("crypto");
197726
- var Errors = require_errors6();
197727
- var crctable = new Uint32Array(256).map((t, crc) => {
197728
- for (let j = 0;j < 8; j++) {
197729
- if ((crc & 1) !== 0) {
197730
- crc = crc >>> 1 ^ 3988292384;
197731
- } else {
197732
- crc >>>= 1;
197733
- }
197578
+ // ../../node_modules/yauzl/index.js
197579
+ var require_yauzl = __commonJS((exports) => {
197580
+ var fs2 = __require("fs");
197581
+ var zlib2 = __require("zlib");
197582
+ var fd_slicer = require_fd_slicer();
197583
+ var crc32 = require_buffer_crc32();
197584
+ var util5 = __require("util");
197585
+ var EventEmitter3 = __require("events").EventEmitter;
197586
+ var Transform = __require("stream").Transform;
197587
+ var PassThrough = __require("stream").PassThrough;
197588
+ var Writable = __require("stream").Writable;
197589
+ exports.open = open2;
197590
+ exports.fromFd = fromFd;
197591
+ exports.fromBuffer = fromBuffer;
197592
+ exports.fromRandomAccessReader = fromRandomAccessReader;
197593
+ exports.dosDateTimeToDate = dosDateTimeToDate;
197594
+ exports.validateFileName = validateFileName;
197595
+ exports.ZipFile = ZipFile;
197596
+ exports.Entry = Entry;
197597
+ exports.RandomAccessReader = RandomAccessReader;
197598
+ function open2(path3, options, callback) {
197599
+ if (typeof options === "function") {
197600
+ callback = options;
197601
+ options = null;
197734
197602
  }
197735
- return crc >>> 0;
197736
- });
197737
- var uMul = (a, b) => Math.imul(a, b) >>> 0;
197738
- var crc32update = (pCrc32, bval) => {
197739
- return crctable[(pCrc32 ^ bval) & 255] ^ pCrc32 >>> 8;
197740
- };
197741
- var genSalt = () => {
197742
- if (typeof randomFillSync === "function") {
197743
- return randomFillSync(Buffer.alloc(12));
197744
- } else {
197745
- return genSalt.node();
197746
- }
197747
- };
197748
- genSalt.node = () => {
197749
- const salt = Buffer.alloc(12);
197750
- const len = salt.length;
197751
- for (let i = 0;i < len; i++)
197752
- salt[i] = Math.random() * 256 & 255;
197753
- return salt;
197754
- };
197755
- var config = {
197756
- genSalt
197757
- };
197758
- function Initkeys(pw) {
197759
- const pass = Buffer.isBuffer(pw) ? pw : Buffer.from(pw);
197760
- this.keys = new Uint32Array([305419896, 591751049, 878082192]);
197761
- for (let i = 0;i < pass.length; i++) {
197762
- this.updateKeys(pass[i]);
197763
- }
197764
- }
197765
- Initkeys.prototype.updateKeys = function(byteValue) {
197766
- const keys = this.keys;
197767
- keys[0] = crc32update(keys[0], byteValue);
197768
- keys[1] += keys[0] & 255;
197769
- keys[1] = uMul(keys[1], 134775813) + 1;
197770
- keys[2] = crc32update(keys[2], keys[1] >>> 24);
197771
- return byteValue;
197772
- };
197773
- Initkeys.prototype.next = function() {
197774
- const k = (this.keys[2] | 2) >>> 0;
197775
- return uMul(k, k ^ 1) >> 8 & 255;
197776
- };
197777
- function make_decrypter(pwd) {
197778
- const keys = new Initkeys(pwd);
197779
- return function(data) {
197780
- const result = Buffer.alloc(data.length);
197781
- let pos = 0;
197782
- for (let c of data) {
197783
- result[pos++] = keys.updateKeys(c ^ keys.next());
197784
- }
197785
- return result;
197786
- };
197603
+ if (options == null)
197604
+ options = {};
197605
+ if (options.autoClose == null)
197606
+ options.autoClose = true;
197607
+ if (options.lazyEntries == null)
197608
+ options.lazyEntries = false;
197609
+ if (options.decodeStrings == null)
197610
+ options.decodeStrings = true;
197611
+ if (options.validateEntrySizes == null)
197612
+ options.validateEntrySizes = true;
197613
+ if (options.strictFileNames == null)
197614
+ options.strictFileNames = false;
197615
+ if (callback == null)
197616
+ callback = defaultCallback;
197617
+ fs2.open(path3, "r", function(err, fd) {
197618
+ if (err)
197619
+ return callback(err);
197620
+ fromFd(fd, options, function(err2, zipfile) {
197621
+ if (err2)
197622
+ fs2.close(fd, defaultCallback);
197623
+ callback(err2, zipfile);
197624
+ });
197625
+ });
197787
197626
  }
197788
- function make_encrypter(pwd) {
197789
- const keys = new Initkeys(pwd);
197790
- return function(data, result, pos = 0) {
197791
- if (!result)
197792
- result = Buffer.alloc(data.length);
197793
- for (let c of data) {
197794
- const k = keys.next();
197795
- result[pos++] = c ^ k;
197796
- keys.updateKeys(c);
197797
- }
197798
- return result;
197799
- };
197627
+ function fromFd(fd, options, callback) {
197628
+ if (typeof options === "function") {
197629
+ callback = options;
197630
+ options = null;
197631
+ }
197632
+ if (options == null)
197633
+ options = {};
197634
+ if (options.autoClose == null)
197635
+ options.autoClose = false;
197636
+ if (options.lazyEntries == null)
197637
+ options.lazyEntries = false;
197638
+ if (options.decodeStrings == null)
197639
+ options.decodeStrings = true;
197640
+ if (options.validateEntrySizes == null)
197641
+ options.validateEntrySizes = true;
197642
+ if (options.strictFileNames == null)
197643
+ options.strictFileNames = false;
197644
+ if (callback == null)
197645
+ callback = defaultCallback;
197646
+ fs2.fstat(fd, function(err, stats) {
197647
+ if (err)
197648
+ return callback(err);
197649
+ var reader = fd_slicer.createFromFd(fd, { autoClose: true });
197650
+ fromRandomAccessReader(reader, stats.size, options, callback);
197651
+ });
197800
197652
  }
197801
- function decrypt(data, header, pwd) {
197802
- if (!data || !Buffer.isBuffer(data) || data.length < 12) {
197803
- return Buffer.alloc(0);
197653
+ function fromBuffer(buffer, options, callback) {
197654
+ if (typeof options === "function") {
197655
+ callback = options;
197656
+ options = null;
197804
197657
  }
197805
- const decrypter = make_decrypter(pwd);
197806
- const salt = decrypter(data.slice(0, 12));
197807
- const verifyByte = (header.flags & 8) === 8 ? header.timeHighByte : header.crc >>> 24;
197808
- if (salt[11] !== verifyByte) {
197809
- throw Errors.WRONG_PASSWORD();
197658
+ if (options == null)
197659
+ options = {};
197660
+ options.autoClose = false;
197661
+ if (options.lazyEntries == null)
197662
+ options.lazyEntries = false;
197663
+ if (options.decodeStrings == null)
197664
+ options.decodeStrings = true;
197665
+ if (options.validateEntrySizes == null)
197666
+ options.validateEntrySizes = true;
197667
+ if (options.strictFileNames == null)
197668
+ options.strictFileNames = false;
197669
+ var reader = fd_slicer.createFromBuffer(buffer, { maxChunkSize: 65536 });
197670
+ fromRandomAccessReader(reader, buffer.length, options, callback);
197671
+ }
197672
+ function fromRandomAccessReader(reader, totalSize, options, callback) {
197673
+ if (typeof options === "function") {
197674
+ callback = options;
197675
+ options = null;
197810
197676
  }
197811
- return decrypter(data.slice(12));
197812
- }
197813
- function _salter(data) {
197814
- if (Buffer.isBuffer(data) && data.length >= 12) {
197815
- config.genSalt = function() {
197816
- return data.slice(0, 12);
197817
- };
197818
- } else if (data === "node") {
197819
- config.genSalt = genSalt.node;
197820
- } else {
197821
- config.genSalt = genSalt;
197822
- }
197823
- }
197824
- function encrypt(data, header, pwd, oldlike = false) {
197825
- if (data == null)
197826
- data = Buffer.alloc(0);
197827
- if (!Buffer.isBuffer(data))
197828
- data = Buffer.from(data.toString());
197829
- const encrypter = make_encrypter(pwd);
197830
- const salt = config.genSalt();
197831
- salt[11] = header.crc >>> 24 & 255;
197832
- if (oldlike)
197833
- salt[10] = header.crc >>> 16 & 255;
197834
- const result = Buffer.alloc(data.length + 12);
197835
- encrypter(salt, result);
197836
- return encrypter(data, result, 12);
197837
- }
197838
- module.exports = { decrypt, encrypt, _salter };
197839
- });
197840
-
197841
- // ../../node_modules/adm-zip/methods/index.js
197842
- var require_methods2 = __commonJS((exports) => {
197843
- exports.Deflater = require_deflater();
197844
- exports.Inflater = require_inflater();
197845
- exports.ZipCrypto = require_zipcrypto();
197846
- });
197847
-
197848
- // ../../node_modules/adm-zip/zipEntry.js
197849
- var require_zipEntry = __commonJS((exports, module) => {
197850
- var Utils = require_util12();
197851
- var Headers2 = require_headers();
197852
- var Constants = Utils.Constants;
197853
- var Methods = require_methods2();
197854
- module.exports = function(options, input) {
197855
- var _centralHeader = new Headers2.EntryHeader, _entryName = Buffer.alloc(0), _comment = Buffer.alloc(0), _isDirectory = false, uncompressedData = null, _extra = Buffer.alloc(0), _extralocal = Buffer.alloc(0), _efs = true;
197856
- const opts = options;
197857
- const decoder = typeof opts.decoder === "object" ? opts.decoder : Utils.decoder;
197858
- _efs = decoder.hasOwnProperty("efs") ? decoder.efs : false;
197859
- function getCompressedDataFromZip() {
197860
- if (!input || !(input instanceof Uint8Array)) {
197861
- return Buffer.alloc(0);
197862
- }
197863
- _extralocal = _centralHeader.loadLocalHeaderFromBinary(input);
197864
- return input.slice(_centralHeader.realDataOffset, _centralHeader.realDataOffset + _centralHeader.compressedSize);
197865
- }
197866
- function crc32OK(data) {
197867
- if (!_centralHeader.flags_desc) {
197868
- if (Utils.crc32(data) !== _centralHeader.localHeader.crc) {
197869
- return false;
197870
- }
197871
- } else {
197872
- const descriptor = {};
197873
- const dataEndOffset = _centralHeader.realDataOffset + _centralHeader.compressedSize;
197874
- if (input.readUInt32LE(dataEndOffset) == Constants.LOCSIG || input.readUInt32LE(dataEndOffset) == Constants.CENSIG) {
197875
- throw Utils.Errors.DESCRIPTOR_NOT_EXIST();
197876
- }
197877
- if (input.readUInt32LE(dataEndOffset) == Constants.EXTSIG) {
197878
- descriptor.crc = input.readUInt32LE(dataEndOffset + Constants.EXTCRC);
197879
- descriptor.compressedSize = input.readUInt32LE(dataEndOffset + Constants.EXTSIZ);
197880
- descriptor.size = input.readUInt32LE(dataEndOffset + Constants.EXTLEN);
197881
- } else if (input.readUInt16LE(dataEndOffset + 12) === 19280) {
197882
- descriptor.crc = input.readUInt32LE(dataEndOffset + Constants.EXTCRC - 4);
197883
- descriptor.compressedSize = input.readUInt32LE(dataEndOffset + Constants.EXTSIZ - 4);
197884
- descriptor.size = input.readUInt32LE(dataEndOffset + Constants.EXTLEN - 4);
197885
- } else {
197886
- throw Utils.Errors.DESCRIPTOR_UNKNOWN();
197887
- }
197888
- if (descriptor.compressedSize !== _centralHeader.compressedSize || descriptor.size !== _centralHeader.size || descriptor.crc !== _centralHeader.crc) {
197889
- throw Utils.Errors.DESCRIPTOR_FAULTY();
197890
- }
197891
- if (Utils.crc32(data) !== descriptor.crc) {
197892
- return false;
197893
- }
197677
+ if (options == null)
197678
+ options = {};
197679
+ if (options.autoClose == null)
197680
+ options.autoClose = true;
197681
+ if (options.lazyEntries == null)
197682
+ options.lazyEntries = false;
197683
+ if (options.decodeStrings == null)
197684
+ options.decodeStrings = true;
197685
+ var decodeStrings = !!options.decodeStrings;
197686
+ if (options.validateEntrySizes == null)
197687
+ options.validateEntrySizes = true;
197688
+ if (options.strictFileNames == null)
197689
+ options.strictFileNames = false;
197690
+ if (callback == null)
197691
+ callback = defaultCallback;
197692
+ if (typeof totalSize !== "number")
197693
+ throw new Error("expected totalSize parameter to be a number");
197694
+ if (totalSize > Number.MAX_SAFE_INTEGER) {
197695
+ 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.");
197696
+ }
197697
+ reader.ref();
197698
+ var eocdrWithoutCommentSize = 22;
197699
+ var maxCommentSize = 65535;
197700
+ var bufferSize = Math.min(eocdrWithoutCommentSize + maxCommentSize, totalSize);
197701
+ var buffer = newBuffer(bufferSize);
197702
+ var bufferReadStart = totalSize - buffer.length;
197703
+ readAndAssertNoEof(reader, buffer, 0, bufferSize, bufferReadStart, function(err) {
197704
+ if (err)
197705
+ return callback(err);
197706
+ for (var i = bufferSize - eocdrWithoutCommentSize;i >= 0; i -= 1) {
197707
+ if (buffer.readUInt32LE(i) !== 101010256)
197708
+ continue;
197709
+ var eocdrBuffer = buffer.slice(i);
197710
+ var diskNumber = eocdrBuffer.readUInt16LE(4);
197711
+ if (diskNumber !== 0) {
197712
+ return callback(new Error("multi-disk zip files are not supported: found disk number: " + diskNumber));
197713
+ }
197714
+ var entryCount = eocdrBuffer.readUInt16LE(10);
197715
+ var centralDirectoryOffset = eocdrBuffer.readUInt32LE(16);
197716
+ var commentLength = eocdrBuffer.readUInt16LE(20);
197717
+ var expectedCommentLength = eocdrBuffer.length - eocdrWithoutCommentSize;
197718
+ if (commentLength !== expectedCommentLength) {
197719
+ return callback(new Error("invalid comment length. expected: " + expectedCommentLength + ". found: " + commentLength));
197720
+ }
197721
+ var comment = decodeStrings ? decodeBuffer(eocdrBuffer, 22, eocdrBuffer.length, false) : eocdrBuffer.slice(22);
197722
+ if (!(entryCount === 65535 || centralDirectoryOffset === 4294967295)) {
197723
+ return callback(null, new ZipFile(reader, centralDirectoryOffset, totalSize, entryCount, comment, options.autoClose, options.lazyEntries, decodeStrings, options.validateEntrySizes, options.strictFileNames));
197724
+ }
197725
+ var zip64EocdlBuffer = newBuffer(20);
197726
+ var zip64EocdlOffset = bufferReadStart + i - zip64EocdlBuffer.length;
197727
+ readAndAssertNoEof(reader, zip64EocdlBuffer, 0, zip64EocdlBuffer.length, zip64EocdlOffset, function(err2) {
197728
+ if (err2)
197729
+ return callback(err2);
197730
+ if (zip64EocdlBuffer.readUInt32LE(0) !== 117853008) {
197731
+ return callback(new Error("invalid zip64 end of central directory locator signature"));
197732
+ }
197733
+ var zip64EocdrOffset = readUInt64LE(zip64EocdlBuffer, 8);
197734
+ var zip64EocdrBuffer = newBuffer(56);
197735
+ readAndAssertNoEof(reader, zip64EocdrBuffer, 0, zip64EocdrBuffer.length, zip64EocdrOffset, function(err3) {
197736
+ if (err3)
197737
+ return callback(err3);
197738
+ if (zip64EocdrBuffer.readUInt32LE(0) !== 101075792) {
197739
+ return callback(new Error("invalid zip64 end of central directory record signature"));
197740
+ }
197741
+ entryCount = readUInt64LE(zip64EocdrBuffer, 32);
197742
+ centralDirectoryOffset = readUInt64LE(zip64EocdrBuffer, 48);
197743
+ return callback(null, new ZipFile(reader, centralDirectoryOffset, totalSize, entryCount, comment, options.autoClose, options.lazyEntries, decodeStrings, options.validateEntrySizes, options.strictFileNames));
197744
+ });
197745
+ });
197746
+ return;
197894
197747
  }
197895
- return true;
197748
+ callback(new Error("end of central directory record signature not found"));
197749
+ });
197750
+ }
197751
+ util5.inherits(ZipFile, EventEmitter3);
197752
+ function ZipFile(reader, centralDirectoryOffset, fileSize, entryCount, comment, autoClose, lazyEntries, decodeStrings, validateEntrySizes, strictFileNames) {
197753
+ var self2 = this;
197754
+ EventEmitter3.call(self2);
197755
+ self2.reader = reader;
197756
+ self2.reader.on("error", function(err) {
197757
+ emitError(self2, err);
197758
+ });
197759
+ self2.reader.once("close", function() {
197760
+ self2.emit("close");
197761
+ });
197762
+ self2.readEntryCursor = centralDirectoryOffset;
197763
+ self2.fileSize = fileSize;
197764
+ self2.entryCount = entryCount;
197765
+ self2.comment = comment;
197766
+ self2.entriesRead = 0;
197767
+ self2.autoClose = !!autoClose;
197768
+ self2.lazyEntries = !!lazyEntries;
197769
+ self2.decodeStrings = !!decodeStrings;
197770
+ self2.validateEntrySizes = !!validateEntrySizes;
197771
+ self2.strictFileNames = !!strictFileNames;
197772
+ self2.isOpen = true;
197773
+ self2.emittedError = false;
197774
+ if (!self2.lazyEntries)
197775
+ self2._readEntry();
197776
+ }
197777
+ ZipFile.prototype.close = function() {
197778
+ if (!this.isOpen)
197779
+ return;
197780
+ this.isOpen = false;
197781
+ this.reader.unref();
197782
+ };
197783
+ function emitErrorAndAutoClose(self2, err) {
197784
+ if (self2.autoClose)
197785
+ self2.close();
197786
+ emitError(self2, err);
197787
+ }
197788
+ function emitError(self2, err) {
197789
+ if (self2.emittedError)
197790
+ return;
197791
+ self2.emittedError = true;
197792
+ self2.emit("error", err);
197793
+ }
197794
+ ZipFile.prototype.readEntry = function() {
197795
+ if (!this.lazyEntries)
197796
+ throw new Error("readEntry() called without lazyEntries:true");
197797
+ this._readEntry();
197798
+ };
197799
+ ZipFile.prototype._readEntry = function() {
197800
+ var self2 = this;
197801
+ if (self2.entryCount === self2.entriesRead) {
197802
+ setImmediate(function() {
197803
+ if (self2.autoClose)
197804
+ self2.close();
197805
+ if (self2.emittedError)
197806
+ return;
197807
+ self2.emit("end");
197808
+ });
197809
+ return;
197896
197810
  }
197897
- function decompress(async, callback, pass) {
197898
- if (typeof callback === "undefined" && typeof async === "string") {
197899
- pass = async;
197900
- async = undefined;
197901
- }
197902
- if (_isDirectory) {
197903
- if (async && callback) {
197904
- callback(Buffer.alloc(0), Utils.Errors.DIRECTORY_CONTENT_ERROR());
197905
- }
197906
- return Buffer.alloc(0);
197907
- }
197908
- var compressedData = getCompressedDataFromZip();
197909
- if (compressedData.length === 0) {
197910
- if (async && callback)
197911
- callback(compressedData);
197912
- return compressedData;
197913
- }
197914
- if (_centralHeader.encrypted) {
197915
- if (typeof pass !== "string" && !Buffer.isBuffer(pass)) {
197916
- throw Utils.Errors.INVALID_PASS_PARAM();
197917
- }
197918
- compressedData = Methods.ZipCrypto.decrypt(compressedData, _centralHeader, pass);
197919
- }
197920
- var data = Buffer.alloc(_centralHeader.size);
197921
- switch (_centralHeader.method) {
197922
- case Utils.Constants.STORED:
197923
- compressedData.copy(data);
197924
- if (!crc32OK(data)) {
197925
- if (async && callback)
197926
- callback(data, Utils.Errors.BAD_CRC());
197927
- throw Utils.Errors.BAD_CRC();
197928
- } else {
197929
- if (async && callback)
197930
- callback(data);
197931
- return data;
197932
- }
197933
- case Utils.Constants.DEFLATED:
197934
- var inflater = new Methods.Inflater(compressedData, _centralHeader.size);
197935
- if (!async) {
197936
- const result = inflater.inflate(data);
197937
- result.copy(data, 0);
197938
- if (!crc32OK(data)) {
197939
- throw Utils.Errors.BAD_CRC(`"${decoder.decode(_entryName)}"`);
197940
- }
197941
- return data;
197942
- } else {
197943
- inflater.inflateAsync(function(result) {
197944
- result.copy(result, 0);
197945
- if (callback) {
197946
- if (!crc32OK(result)) {
197947
- callback(result, Utils.Errors.BAD_CRC());
197948
- } else {
197949
- callback(result);
197950
- }
197951
- }
197952
- });
197811
+ if (self2.emittedError)
197812
+ return;
197813
+ var buffer = newBuffer(46);
197814
+ readAndAssertNoEof(self2.reader, buffer, 0, buffer.length, self2.readEntryCursor, function(err) {
197815
+ if (err)
197816
+ return emitErrorAndAutoClose(self2, err);
197817
+ if (self2.emittedError)
197818
+ return;
197819
+ var entry = new Entry;
197820
+ var signature = buffer.readUInt32LE(0);
197821
+ if (signature !== 33639248)
197822
+ return emitErrorAndAutoClose(self2, new Error("invalid central directory file header signature: 0x" + signature.toString(16)));
197823
+ entry.versionMadeBy = buffer.readUInt16LE(4);
197824
+ entry.versionNeededToExtract = buffer.readUInt16LE(6);
197825
+ entry.generalPurposeBitFlag = buffer.readUInt16LE(8);
197826
+ entry.compressionMethod = buffer.readUInt16LE(10);
197827
+ entry.lastModFileTime = buffer.readUInt16LE(12);
197828
+ entry.lastModFileDate = buffer.readUInt16LE(14);
197829
+ entry.crc32 = buffer.readUInt32LE(16);
197830
+ entry.compressedSize = buffer.readUInt32LE(20);
197831
+ entry.uncompressedSize = buffer.readUInt32LE(24);
197832
+ entry.fileNameLength = buffer.readUInt16LE(28);
197833
+ entry.extraFieldLength = buffer.readUInt16LE(30);
197834
+ entry.fileCommentLength = buffer.readUInt16LE(32);
197835
+ entry.internalFileAttributes = buffer.readUInt16LE(36);
197836
+ entry.externalFileAttributes = buffer.readUInt32LE(38);
197837
+ entry.relativeOffsetOfLocalHeader = buffer.readUInt32LE(42);
197838
+ if (entry.generalPurposeBitFlag & 64)
197839
+ return emitErrorAndAutoClose(self2, new Error("strong encryption is not supported"));
197840
+ self2.readEntryCursor += 46;
197841
+ buffer = newBuffer(entry.fileNameLength + entry.extraFieldLength + entry.fileCommentLength);
197842
+ readAndAssertNoEof(self2.reader, buffer, 0, buffer.length, self2.readEntryCursor, function(err2) {
197843
+ if (err2)
197844
+ return emitErrorAndAutoClose(self2, err2);
197845
+ if (self2.emittedError)
197846
+ return;
197847
+ var isUtf8 = (entry.generalPurposeBitFlag & 2048) !== 0;
197848
+ entry.fileName = self2.decodeStrings ? decodeBuffer(buffer, 0, entry.fileNameLength, isUtf8) : buffer.slice(0, entry.fileNameLength);
197849
+ var fileCommentStart = entry.fileNameLength + entry.extraFieldLength;
197850
+ var extraFieldBuffer = buffer.slice(entry.fileNameLength, fileCommentStart);
197851
+ entry.extraFields = [];
197852
+ var i = 0;
197853
+ while (i < extraFieldBuffer.length - 3) {
197854
+ var headerId = extraFieldBuffer.readUInt16LE(i + 0);
197855
+ var dataSize = extraFieldBuffer.readUInt16LE(i + 2);
197856
+ var dataStart = i + 4;
197857
+ var dataEnd = dataStart + dataSize;
197858
+ if (dataEnd > extraFieldBuffer.length)
197859
+ return emitErrorAndAutoClose(self2, new Error("extra field length exceeds extra field buffer size"));
197860
+ var dataBuffer = newBuffer(dataSize);
197861
+ extraFieldBuffer.copy(dataBuffer, 0, dataStart, dataEnd);
197862
+ entry.extraFields.push({
197863
+ id: headerId,
197864
+ data: dataBuffer
197865
+ });
197866
+ i = dataEnd;
197867
+ }
197868
+ entry.fileComment = self2.decodeStrings ? decodeBuffer(buffer, fileCommentStart, fileCommentStart + entry.fileCommentLength, isUtf8) : buffer.slice(fileCommentStart, fileCommentStart + entry.fileCommentLength);
197869
+ entry.comment = entry.fileComment;
197870
+ self2.readEntryCursor += buffer.length;
197871
+ self2.entriesRead += 1;
197872
+ if (entry.uncompressedSize === 4294967295 || entry.compressedSize === 4294967295 || entry.relativeOffsetOfLocalHeader === 4294967295) {
197873
+ var zip64EiefBuffer = null;
197874
+ for (var i = 0;i < entry.extraFields.length; i++) {
197875
+ var extraField = entry.extraFields[i];
197876
+ if (extraField.id === 1) {
197877
+ zip64EiefBuffer = extraField.data;
197878
+ break;
197879
+ }
197953
197880
  }
197954
- break;
197955
- default:
197956
- if (async && callback)
197957
- callback(Buffer.alloc(0), Utils.Errors.UNKNOWN_METHOD());
197958
- throw Utils.Errors.UNKNOWN_METHOD();
197959
- }
197960
- }
197961
- function compress(async, callback) {
197962
- if ((!uncompressedData || !uncompressedData.length) && Buffer.isBuffer(input)) {
197963
- if (async && callback)
197964
- callback(getCompressedDataFromZip());
197965
- return getCompressedDataFromZip();
197966
- }
197967
- if (uncompressedData.length && !_isDirectory) {
197968
- var compressedData;
197969
- switch (_centralHeader.method) {
197970
- case Utils.Constants.STORED:
197971
- _centralHeader.compressedSize = _centralHeader.size;
197972
- compressedData = Buffer.alloc(uncompressedData.length);
197973
- uncompressedData.copy(compressedData);
197974
- if (async && callback)
197975
- callback(compressedData);
197976
- return compressedData;
197977
- default:
197978
- case Utils.Constants.DEFLATED:
197979
- var deflater = new Methods.Deflater(uncompressedData);
197980
- if (!async) {
197981
- var deflated = deflater.deflate();
197982
- _centralHeader.compressedSize = deflated.length;
197983
- return deflated;
197984
- } else {
197985
- deflater.deflateAsync(function(data) {
197986
- compressedData = Buffer.alloc(data.length);
197987
- _centralHeader.compressedSize = data.length;
197988
- data.copy(compressedData);
197989
- callback && callback(compressedData);
197990
- });
197881
+ if (zip64EiefBuffer == null) {
197882
+ return emitErrorAndAutoClose(self2, new Error("expected zip64 extended information extra field"));
197883
+ }
197884
+ var index = 0;
197885
+ if (entry.uncompressedSize === 4294967295) {
197886
+ if (index + 8 > zip64EiefBuffer.length) {
197887
+ return emitErrorAndAutoClose(self2, new Error("zip64 extended information extra field does not include uncompressed size"));
197991
197888
  }
197992
- deflater = null;
197993
- break;
197889
+ entry.uncompressedSize = readUInt64LE(zip64EiefBuffer, index);
197890
+ index += 8;
197891
+ }
197892
+ if (entry.compressedSize === 4294967295) {
197893
+ if (index + 8 > zip64EiefBuffer.length) {
197894
+ return emitErrorAndAutoClose(self2, new Error("zip64 extended information extra field does not include compressed size"));
197895
+ }
197896
+ entry.compressedSize = readUInt64LE(zip64EiefBuffer, index);
197897
+ index += 8;
197898
+ }
197899
+ if (entry.relativeOffsetOfLocalHeader === 4294967295) {
197900
+ if (index + 8 > zip64EiefBuffer.length) {
197901
+ return emitErrorAndAutoClose(self2, new Error("zip64 extended information extra field does not include relative header offset"));
197902
+ }
197903
+ entry.relativeOffsetOfLocalHeader = readUInt64LE(zip64EiefBuffer, index);
197904
+ index += 8;
197905
+ }
197994
197906
  }
197995
- } else if (async && callback) {
197996
- callback(Buffer.alloc(0));
197997
- } else {
197998
- return Buffer.alloc(0);
197999
- }
198000
- }
198001
- function readUInt64LE(buffer, offset) {
198002
- return (buffer.readUInt32LE(offset + 4) << 4) + buffer.readUInt32LE(offset);
198003
- }
198004
- function parseExtra(data) {
198005
- try {
198006
- var offset = 0;
198007
- var signature, size, part;
198008
- while (offset + 4 < data.length) {
198009
- signature = data.readUInt16LE(offset);
198010
- offset += 2;
198011
- size = data.readUInt16LE(offset);
198012
- offset += 2;
198013
- part = data.slice(offset, offset + size);
198014
- offset += size;
198015
- if (Constants.ID_ZIP64 === signature) {
198016
- parseZip64ExtendedInformation(part);
197907
+ if (self2.decodeStrings) {
197908
+ for (var i = 0;i < entry.extraFields.length; i++) {
197909
+ var extraField = entry.extraFields[i];
197910
+ if (extraField.id === 28789) {
197911
+ if (extraField.data.length < 6) {
197912
+ continue;
197913
+ }
197914
+ if (extraField.data.readUInt8(0) !== 1) {
197915
+ continue;
197916
+ }
197917
+ var oldNameCrc32 = extraField.data.readUInt32LE(1);
197918
+ if (crc32.unsigned(buffer.slice(0, entry.fileNameLength)) !== oldNameCrc32) {
197919
+ continue;
197920
+ }
197921
+ entry.fileName = decodeBuffer(extraField.data, 5, extraField.data.length, true);
197922
+ break;
197923
+ }
198017
197924
  }
198018
197925
  }
198019
- } catch (error) {
198020
- throw Utils.Errors.EXTRA_FIELD_PARSE_ERROR();
198021
- }
198022
- }
198023
- function parseZip64ExtendedInformation(data) {
198024
- var size, compressedSize, offset, diskNumStart;
198025
- if (data.length >= Constants.EF_ZIP64_SCOMP) {
198026
- size = readUInt64LE(data, Constants.EF_ZIP64_SUNCOMP);
198027
- if (_centralHeader.size === Constants.EF_ZIP64_OR_32) {
198028
- _centralHeader.size = size;
197926
+ if (self2.validateEntrySizes && entry.compressionMethod === 0) {
197927
+ var expectedCompressedSize = entry.uncompressedSize;
197928
+ if (entry.isEncrypted()) {
197929
+ expectedCompressedSize += 12;
197930
+ }
197931
+ if (entry.compressedSize !== expectedCompressedSize) {
197932
+ var msg = "compressed/uncompressed size mismatch for stored file: " + entry.compressedSize + " != " + entry.uncompressedSize;
197933
+ return emitErrorAndAutoClose(self2, new Error(msg));
197934
+ }
198029
197935
  }
198030
- }
198031
- if (data.length >= Constants.EF_ZIP64_RHO) {
198032
- compressedSize = readUInt64LE(data, Constants.EF_ZIP64_SCOMP);
198033
- if (_centralHeader.compressedSize === Constants.EF_ZIP64_OR_32) {
198034
- _centralHeader.compressedSize = compressedSize;
197936
+ if (self2.decodeStrings) {
197937
+ if (!self2.strictFileNames) {
197938
+ entry.fileName = entry.fileName.replace(/\\/g, "/");
197939
+ }
197940
+ var errorMessage = validateFileName(entry.fileName, self2.validateFileNameOptions);
197941
+ if (errorMessage != null)
197942
+ return emitErrorAndAutoClose(self2, new Error(errorMessage));
198035
197943
  }
198036
- }
198037
- if (data.length >= Constants.EF_ZIP64_DSN) {
198038
- offset = readUInt64LE(data, Constants.EF_ZIP64_RHO);
198039
- if (_centralHeader.offset === Constants.EF_ZIP64_OR_32) {
198040
- _centralHeader.offset = offset;
197944
+ self2.emit("entry", entry);
197945
+ if (!self2.lazyEntries)
197946
+ self2._readEntry();
197947
+ });
197948
+ });
197949
+ };
197950
+ ZipFile.prototype.openReadStream = function(entry, options, callback) {
197951
+ var self2 = this;
197952
+ var relativeStart = 0;
197953
+ var relativeEnd = entry.compressedSize;
197954
+ if (callback == null) {
197955
+ callback = options;
197956
+ options = {};
197957
+ } else {
197958
+ if (options.decrypt != null) {
197959
+ if (!entry.isEncrypted()) {
197960
+ throw new Error("options.decrypt can only be specified for encrypted entries");
198041
197961
  }
198042
- }
198043
- if (data.length >= Constants.EF_ZIP64_DSN + 4) {
198044
- diskNumStart = data.readUInt32LE(Constants.EF_ZIP64_DSN);
198045
- if (_centralHeader.diskNumStart === Constants.EF_ZIP64_OR_16) {
198046
- _centralHeader.diskNumStart = diskNumStart;
197962
+ if (options.decrypt !== false)
197963
+ throw new Error("invalid options.decrypt value: " + options.decrypt);
197964
+ if (entry.isCompressed()) {
197965
+ if (options.decompress !== false)
197966
+ throw new Error("entry is encrypted and compressed, and options.decompress !== false");
198047
197967
  }
198048
197968
  }
198049
- }
198050
- return {
198051
- get entryName() {
198052
- return decoder.decode(_entryName);
198053
- },
198054
- get rawEntryName() {
198055
- return _entryName;
198056
- },
198057
- set entryName(val) {
198058
- _entryName = Utils.toBuffer(val, decoder.encode);
198059
- var lastChar = _entryName[_entryName.length - 1];
198060
- _isDirectory = lastChar === 47 || lastChar === 92;
198061
- _centralHeader.fileNameLength = _entryName.length;
198062
- },
198063
- get efs() {
198064
- if (typeof _efs === "function") {
198065
- return _efs(this.entryName);
198066
- } else {
198067
- return _efs;
198068
- }
198069
- },
198070
- get extra() {
198071
- return _extra;
198072
- },
198073
- set extra(val) {
198074
- _extra = val;
198075
- _centralHeader.extraLength = val.length;
198076
- parseExtra(val);
198077
- },
198078
- get comment() {
198079
- return decoder.decode(_comment);
198080
- },
198081
- set comment(val) {
198082
- _comment = Utils.toBuffer(val, decoder.encode);
198083
- _centralHeader.commentLength = _comment.length;
198084
- if (_comment.length > 65535)
198085
- throw Utils.Errors.COMMENT_TOO_LONG();
198086
- },
198087
- get name() {
198088
- var n = decoder.decode(_entryName);
198089
- return _isDirectory ? n.substr(n.length - 1).split("/").pop() : n.split("/").pop();
198090
- },
198091
- get isDirectory() {
198092
- return _isDirectory;
198093
- },
198094
- getCompressedData: function() {
198095
- return compress(false, null);
198096
- },
198097
- getCompressedDataAsync: function(callback) {
198098
- compress(true, callback);
198099
- },
198100
- setData: function(value) {
198101
- uncompressedData = Utils.toBuffer(value, Utils.decoder.encode);
198102
- if (!_isDirectory && uncompressedData.length) {
198103
- _centralHeader.size = uncompressedData.length;
198104
- _centralHeader.method = Utils.Constants.DEFLATED;
198105
- _centralHeader.crc = Utils.crc32(value);
198106
- _centralHeader.changed = true;
198107
- } else {
198108
- _centralHeader.method = Utils.Constants.STORED;
198109
- }
198110
- },
198111
- getData: function(pass) {
198112
- if (_centralHeader.changed) {
198113
- return uncompressedData;
198114
- } else {
198115
- return decompress(false, null, pass);
197969
+ if (options.decompress != null) {
197970
+ if (!entry.isCompressed()) {
197971
+ throw new Error("options.decompress can only be specified for compressed entries");
198116
197972
  }
198117
- },
198118
- getDataAsync: function(callback, pass) {
198119
- if (_centralHeader.changed) {
198120
- callback(uncompressedData);
198121
- } else {
198122
- decompress(true, callback, pass);
197973
+ if (!(options.decompress === false || options.decompress === true)) {
197974
+ throw new Error("invalid options.decompress value: " + options.decompress);
198123
197975
  }
198124
- },
198125
- set attr(attr) {
198126
- _centralHeader.attr = attr;
198127
- },
198128
- get attr() {
198129
- return _centralHeader.attr;
198130
- },
198131
- set header(data) {
198132
- _centralHeader.loadFromBinary(data);
198133
- },
198134
- get header() {
198135
- return _centralHeader;
198136
- },
198137
- packCentralHeader: function() {
198138
- _centralHeader.flags_efs = this.efs;
198139
- _centralHeader.extraLength = _extra.length;
198140
- var header = _centralHeader.centralHeaderToBinary();
198141
- var addpos = Utils.Constants.CENHDR;
198142
- _entryName.copy(header, addpos);
198143
- addpos += _entryName.length;
198144
- _extra.copy(header, addpos);
198145
- addpos += _centralHeader.extraLength;
198146
- _comment.copy(header, addpos);
198147
- return header;
198148
- },
198149
- packLocalHeader: function() {
198150
- let addpos = 0;
198151
- _centralHeader.flags_efs = this.efs;
198152
- _centralHeader.extraLocalLength = _extralocal.length;
198153
- const localHeaderBuf = _centralHeader.localHeaderToBinary();
198154
- const localHeader = Buffer.alloc(localHeaderBuf.length + _entryName.length + _centralHeader.extraLocalLength);
198155
- localHeaderBuf.copy(localHeader, addpos);
198156
- addpos += localHeaderBuf.length;
198157
- _entryName.copy(localHeader, addpos);
198158
- addpos += _entryName.length;
198159
- _extralocal.copy(localHeader, addpos);
198160
- addpos += _extralocal.length;
198161
- return localHeader;
198162
- },
198163
- toJSON: function() {
198164
- const bytes = function(nr) {
198165
- return "<" + (nr && nr.length + " bytes buffer" || "null") + ">";
198166
- };
198167
- return {
198168
- entryName: this.entryName,
198169
- name: this.name,
198170
- comment: this.comment,
198171
- isDirectory: this.isDirectory,
198172
- header: _centralHeader.toJSON(),
198173
- compressedData: bytes(input),
198174
- data: bytes(uncompressedData)
198175
- };
198176
- },
198177
- toString: function() {
198178
- return JSON.stringify(this.toJSON(), null, "\t");
198179
197976
  }
198180
- };
198181
- };
198182
- });
198183
-
198184
- // ../../node_modules/adm-zip/zipFile.js
198185
- var require_zipFile = __commonJS((exports, module) => {
198186
- var ZipEntry = require_zipEntry();
198187
- var Headers2 = require_headers();
198188
- var Utils = require_util12();
198189
- module.exports = function(inBuffer, options) {
198190
- var entryList = [], entryTable = {}, _comment = Buffer.alloc(0), mainHeader = new Headers2.MainHeader, loadedEntries = false;
198191
- var password = null;
198192
- const temporary = new Set;
198193
- const opts = options;
198194
- const { noSort, decoder } = opts;
198195
- if (inBuffer) {
198196
- readMainHeader(opts.readEntries);
198197
- } else {
198198
- loadedEntries = true;
198199
- }
198200
- function makeTemporaryFolders() {
198201
- const foldersList = new Set;
198202
- for (const elem of Object.keys(entryTable)) {
198203
- const elements = elem.split("/");
198204
- elements.pop();
198205
- if (!elements.length)
198206
- continue;
198207
- for (let i = 0;i < elements.length; i++) {
198208
- const sub = elements.slice(0, i + 1).join("/") + "/";
198209
- foldersList.add(sub);
198210
- }
198211
- }
198212
- for (const elem of foldersList) {
198213
- if (!(elem in entryTable)) {
198214
- const tempfolder = new ZipEntry(opts);
198215
- tempfolder.entryName = elem;
198216
- tempfolder.attr = 16;
198217
- tempfolder.temporary = true;
198218
- entryList.push(tempfolder);
198219
- entryTable[tempfolder.entryName] = tempfolder;
198220
- temporary.add(tempfolder);
198221
- }
198222
- }
198223
- }
198224
- function readEntries() {
198225
- loadedEntries = true;
198226
- entryTable = {};
198227
- if (mainHeader.diskEntries > (inBuffer.length - mainHeader.offset) / Utils.Constants.CENHDR) {
198228
- throw Utils.Errors.DISK_ENTRY_TOO_LARGE();
198229
- }
198230
- entryList = new Array(mainHeader.diskEntries);
198231
- var index = mainHeader.offset;
198232
- for (var i = 0;i < entryList.length; i++) {
198233
- var tmp = index, entry = new ZipEntry(opts, inBuffer);
198234
- entry.header = inBuffer.slice(tmp, tmp += Utils.Constants.CENHDR);
198235
- entry.entryName = inBuffer.slice(tmp, tmp += entry.header.fileNameLength);
198236
- if (entry.header.extraLength) {
198237
- entry.extra = inBuffer.slice(tmp, tmp += entry.header.extraLength);
198238
- }
198239
- if (entry.header.commentLength)
198240
- entry.comment = inBuffer.slice(tmp, tmp + entry.header.commentLength);
198241
- index += entry.header.centralHeaderSize;
198242
- entryList[i] = entry;
198243
- entryTable[entry.entryName] = entry;
198244
- }
198245
- temporary.clear();
198246
- makeTemporaryFolders();
198247
- }
198248
- function readMainHeader(readNow) {
198249
- var i = inBuffer.length - Utils.Constants.ENDHDR, max = Math.max(0, i - 65535), n = max, endStart = inBuffer.length, endOffset = -1, commentEnd = 0;
198250
- const trailingSpace = typeof opts.trailingSpace === "boolean" ? opts.trailingSpace : false;
198251
- if (trailingSpace)
198252
- max = 0;
198253
- for (i;i >= n; i--) {
198254
- if (inBuffer[i] !== 80)
198255
- continue;
198256
- if (inBuffer.readUInt32LE(i) === Utils.Constants.ENDSIG) {
198257
- endOffset = i;
198258
- commentEnd = i;
198259
- endStart = i + Utils.Constants.ENDHDR;
198260
- n = i - Utils.Constants.END64HDR;
198261
- continue;
198262
- }
198263
- if (inBuffer.readUInt32LE(i) === Utils.Constants.END64SIG) {
198264
- n = max;
198265
- continue;
197977
+ if (options.start != null || options.end != null) {
197978
+ if (entry.isCompressed() && options.decompress !== false) {
197979
+ throw new Error("start/end range not allowed for compressed entry without options.decompress === false");
198266
197980
  }
198267
- if (inBuffer.readUInt32LE(i) === Utils.Constants.ZIP64SIG) {
198268
- endOffset = i;
198269
- endStart = i + Utils.readBigUInt64LE(inBuffer, i + Utils.Constants.ZIP64SIZE) + Utils.Constants.ZIP64LEAD;
198270
- break;
197981
+ if (entry.isEncrypted() && options.decrypt !== false) {
197982
+ throw new Error("start/end range not allowed for encrypted entry without options.decrypt === false");
198271
197983
  }
198272
197984
  }
198273
- if (endOffset == -1)
198274
- throw Utils.Errors.INVALID_FORMAT();
198275
- mainHeader.loadFromBinary(inBuffer.slice(endOffset, endStart));
198276
- if (mainHeader.commentLength) {
198277
- _comment = inBuffer.slice(commentEnd + Utils.Constants.ENDHDR);
197985
+ if (options.start != null) {
197986
+ relativeStart = options.start;
197987
+ if (relativeStart < 0)
197988
+ throw new Error("options.start < 0");
197989
+ if (relativeStart > entry.compressedSize)
197990
+ throw new Error("options.start > entry.compressedSize");
198278
197991
  }
198279
- if (readNow)
198280
- readEntries();
198281
- }
198282
- function sortEntries() {
198283
- if (entryList.length > 1 && !noSort) {
198284
- entryList.sort((a, b) => a.entryName.toLowerCase().localeCompare(b.entryName.toLowerCase()));
197992
+ if (options.end != null) {
197993
+ relativeEnd = options.end;
197994
+ if (relativeEnd < 0)
197995
+ throw new Error("options.end < 0");
197996
+ if (relativeEnd > entry.compressedSize)
197997
+ throw new Error("options.end > entry.compressedSize");
197998
+ if (relativeEnd < relativeStart)
197999
+ throw new Error("options.end < options.start");
198285
198000
  }
198286
198001
  }
198287
- return {
198288
- get entries() {
198289
- if (!loadedEntries) {
198290
- readEntries();
198291
- }
198292
- return entryList.filter((e) => !temporary.has(e));
198293
- },
198294
- get comment() {
198295
- return decoder.decode(_comment);
198296
- },
198297
- set comment(val) {
198298
- _comment = Utils.toBuffer(val, decoder.encode);
198299
- mainHeader.commentLength = _comment.length;
198300
- },
198301
- getEntryCount: function() {
198302
- if (!loadedEntries) {
198303
- return mainHeader.diskEntries;
198304
- }
198305
- return entryList.length;
198306
- },
198307
- forEach: function(callback) {
198308
- this.entries.forEach(callback);
198309
- },
198310
- getEntry: function(entryName) {
198311
- if (!loadedEntries) {
198312
- readEntries();
198313
- }
198314
- return entryTable[entryName] || null;
198315
- },
198316
- setEntry: function(entry) {
198317
- if (!loadedEntries) {
198318
- readEntries();
198319
- }
198320
- entryList.push(entry);
198321
- entryTable[entry.entryName] = entry;
198322
- mainHeader.totalEntries = entryList.length;
198323
- },
198324
- deleteFile: function(entryName, withsubfolders = true) {
198325
- if (!loadedEntries) {
198326
- readEntries();
198327
- }
198328
- const entry = entryTable[entryName];
198329
- const list = this.getEntryChildren(entry, withsubfolders).map((child) => child.entryName);
198330
- list.forEach(this.deleteEntry);
198331
- },
198332
- deleteEntry: function(entryName) {
198333
- if (!loadedEntries) {
198334
- readEntries();
198335
- }
198336
- const entry = entryTable[entryName];
198337
- const index = entryList.indexOf(entry);
198338
- if (index >= 0) {
198339
- entryList.splice(index, 1);
198340
- delete entryTable[entryName];
198341
- mainHeader.totalEntries = entryList.length;
198342
- }
198343
- },
198344
- getEntryChildren: function(entry, subfolders = true) {
198345
- if (!loadedEntries) {
198346
- readEntries();
198002
+ if (!self2.isOpen)
198003
+ return callback(new Error("closed"));
198004
+ if (entry.isEncrypted()) {
198005
+ if (options.decrypt !== false)
198006
+ return callback(new Error("entry is encrypted, and options.decrypt !== false"));
198007
+ }
198008
+ self2.reader.ref();
198009
+ var buffer = newBuffer(30);
198010
+ readAndAssertNoEof(self2.reader, buffer, 0, buffer.length, entry.relativeOffsetOfLocalHeader, function(err) {
198011
+ try {
198012
+ if (err)
198013
+ return callback(err);
198014
+ var signature = buffer.readUInt32LE(0);
198015
+ if (signature !== 67324752) {
198016
+ return callback(new Error("invalid local file header signature: 0x" + signature.toString(16)));
198017
+ }
198018
+ var fileNameLength = buffer.readUInt16LE(26);
198019
+ var extraFieldLength = buffer.readUInt16LE(28);
198020
+ var localFileHeaderEnd = entry.relativeOffsetOfLocalHeader + buffer.length + fileNameLength + extraFieldLength;
198021
+ var decompress;
198022
+ if (entry.compressionMethod === 0) {
198023
+ decompress = false;
198024
+ } else if (entry.compressionMethod === 8) {
198025
+ decompress = options.decompress != null ? options.decompress : true;
198026
+ } else {
198027
+ return callback(new Error("unsupported compression method: " + entry.compressionMethod));
198347
198028
  }
198348
- if (typeof entry === "object") {
198349
- if (entry.isDirectory && subfolders) {
198350
- const list = [];
198351
- const name = entry.entryName;
198352
- for (const zipEntry of entryList) {
198353
- if (zipEntry.entryName.startsWith(name)) {
198354
- list.push(zipEntry);
198355
- }
198356
- }
198357
- return list;
198358
- } else {
198359
- return [entry];
198029
+ var fileDataStart = localFileHeaderEnd;
198030
+ var fileDataEnd = fileDataStart + entry.compressedSize;
198031
+ if (entry.compressedSize !== 0) {
198032
+ if (fileDataEnd > self2.fileSize) {
198033
+ return callback(new Error("file data overflows file bounds: " + fileDataStart + " + " + entry.compressedSize + " > " + self2.fileSize));
198360
198034
  }
198361
198035
  }
198362
- return [];
198363
- },
198364
- getChildCount: function(entry) {
198365
- if (entry && entry.isDirectory) {
198366
- const list = this.getEntryChildren(entry);
198367
- return list.includes(entry) ? list.length - 1 : list.length;
198368
- }
198369
- return 0;
198370
- },
198371
- compressToBuffer: function() {
198372
- if (!loadedEntries) {
198373
- readEntries();
198374
- }
198375
- sortEntries();
198376
- const dataBlock = [];
198377
- const headerBlocks = [];
198378
- let totalSize = 0;
198379
- let dindex = 0;
198380
- mainHeader.size = 0;
198381
- mainHeader.offset = 0;
198382
- let totalEntries = 0;
198383
- for (const entry of this.entries) {
198384
- const compressedData = entry.getCompressedData();
198385
- entry.header.offset = dindex;
198386
- const localHeader = entry.packLocalHeader();
198387
- const dataLength = localHeader.length + compressedData.length;
198388
- dindex += dataLength;
198389
- dataBlock.push(localHeader);
198390
- dataBlock.push(compressedData);
198391
- const centralHeader = entry.packCentralHeader();
198392
- headerBlocks.push(centralHeader);
198393
- mainHeader.size += centralHeader.length;
198394
- totalSize += dataLength + centralHeader.length;
198395
- totalEntries++;
198396
- }
198397
- totalSize += mainHeader.mainHeaderSize;
198398
- mainHeader.offset = dindex;
198399
- mainHeader.totalEntries = totalEntries;
198400
- dindex = 0;
198401
- const outBuffer = Buffer.alloc(totalSize);
198402
- for (const content of dataBlock) {
198403
- content.copy(outBuffer, dindex);
198404
- dindex += content.length;
198405
- }
198406
- for (const content of headerBlocks) {
198407
- content.copy(outBuffer, dindex);
198408
- dindex += content.length;
198409
- }
198410
- const mh = mainHeader.toBinary();
198411
- if (_comment) {
198412
- _comment.copy(mh, Utils.Constants.ENDHDR);
198413
- }
198414
- mh.copy(outBuffer, dindex);
198415
- inBuffer = outBuffer;
198416
- loadedEntries = false;
198417
- return outBuffer;
198418
- },
198419
- toAsyncBuffer: function(onSuccess, onFail, onItemStart, onItemEnd) {
198420
- try {
198421
- if (!loadedEntries) {
198422
- readEntries();
198423
- }
198424
- sortEntries();
198425
- const dataBlock = [];
198426
- const centralHeaders = [];
198427
- let totalSize = 0;
198428
- let dindex = 0;
198429
- let totalEntries = 0;
198430
- mainHeader.size = 0;
198431
- mainHeader.offset = 0;
198432
- const compress2Buffer = function(entryLists) {
198433
- if (entryLists.length > 0) {
198434
- const entry = entryLists.shift();
198435
- const name = entry.entryName + entry.extra.toString();
198436
- if (onItemStart)
198437
- onItemStart(name);
198438
- entry.getCompressedDataAsync(function(compressedData) {
198439
- if (onItemEnd)
198440
- onItemEnd(name);
198441
- entry.header.offset = dindex;
198442
- const localHeader = entry.packLocalHeader();
198443
- const dataLength = localHeader.length + compressedData.length;
198444
- dindex += dataLength;
198445
- dataBlock.push(localHeader);
198446
- dataBlock.push(compressedData);
198447
- const centalHeader = entry.packCentralHeader();
198448
- centralHeaders.push(centalHeader);
198449
- mainHeader.size += centalHeader.length;
198450
- totalSize += dataLength + centalHeader.length;
198451
- totalEntries++;
198452
- compress2Buffer(entryLists);
198453
- });
198454
- } else {
198455
- totalSize += mainHeader.mainHeaderSize;
198456
- mainHeader.offset = dindex;
198457
- mainHeader.totalEntries = totalEntries;
198458
- dindex = 0;
198459
- const outBuffer = Buffer.alloc(totalSize);
198460
- dataBlock.forEach(function(content) {
198461
- content.copy(outBuffer, dindex);
198462
- dindex += content.length;
198463
- });
198464
- centralHeaders.forEach(function(content) {
198465
- content.copy(outBuffer, dindex);
198466
- dindex += content.length;
198036
+ var readStream2 = self2.reader.createReadStream({
198037
+ start: fileDataStart + relativeStart,
198038
+ end: fileDataStart + relativeEnd
198039
+ });
198040
+ var endpointStream = readStream2;
198041
+ if (decompress) {
198042
+ var destroyed = false;
198043
+ var inflateFilter = zlib2.createInflateRaw();
198044
+ readStream2.on("error", function(err2) {
198045
+ setImmediate(function() {
198046
+ if (!destroyed)
198047
+ inflateFilter.emit("error", err2);
198048
+ });
198049
+ });
198050
+ readStream2.pipe(inflateFilter);
198051
+ if (self2.validateEntrySizes) {
198052
+ endpointStream = new AssertByteCountStream(entry.uncompressedSize);
198053
+ inflateFilter.on("error", function(err2) {
198054
+ setImmediate(function() {
198055
+ if (!destroyed)
198056
+ endpointStream.emit("error", err2);
198467
198057
  });
198468
- const mh = mainHeader.toBinary();
198469
- if (_comment) {
198470
- _comment.copy(mh, Utils.Constants.ENDHDR);
198471
- }
198472
- mh.copy(outBuffer, dindex);
198473
- inBuffer = outBuffer;
198474
- loadedEntries = false;
198475
- onSuccess(outBuffer);
198476
- }
198058
+ });
198059
+ inflateFilter.pipe(endpointStream);
198060
+ } else {
198061
+ endpointStream = inflateFilter;
198062
+ }
198063
+ endpointStream.destroy = function() {
198064
+ destroyed = true;
198065
+ if (inflateFilter !== endpointStream)
198066
+ inflateFilter.unpipe(endpointStream);
198067
+ readStream2.unpipe(inflateFilter);
198068
+ readStream2.destroy();
198477
198069
  };
198478
- compress2Buffer(Array.from(this.entries));
198479
- } catch (e) {
198480
- onFail(e);
198481
- }
198482
- }
198483
- };
198484
- };
198485
- });
198486
-
198487
- // ../../node_modules/adm-zip/adm-zip.js
198488
- var require_adm_zip = __commonJS((exports, module) => {
198489
- var Utils = require_util12();
198490
- var pth = __require("path");
198491
- var ZipEntry = require_zipEntry();
198492
- var ZipFile = require_zipFile();
198493
- var get_Bool = (...val) => Utils.findLast(val, (c) => typeof c === "boolean");
198494
- var get_Str = (...val) => Utils.findLast(val, (c) => typeof c === "string");
198495
- var get_Fun = (...val) => Utils.findLast(val, (c) => typeof c === "function");
198496
- var defaultOptions2 = {
198497
- noSort: false,
198498
- readEntries: false,
198499
- method: Utils.Constants.NONE,
198500
- fs: null
198501
- };
198502
- module.exports = function(input, options) {
198503
- let inBuffer = null;
198504
- const opts = Object.assign(Object.create(null), defaultOptions2);
198505
- if (input && typeof input === "object") {
198506
- if (!(input instanceof Uint8Array)) {
198507
- Object.assign(opts, input);
198508
- input = opts.input ? opts.input : undefined;
198509
- if (opts.input)
198510
- delete opts.input;
198511
- }
198512
- if (Buffer.isBuffer(input)) {
198513
- inBuffer = input;
198514
- opts.method = Utils.Constants.BUFFER;
198515
- input = undefined;
198516
- }
198517
- }
198518
- Object.assign(opts, options);
198519
- const filetools = new Utils(opts);
198520
- if (typeof opts.decoder !== "object" || typeof opts.decoder.encode !== "function" || typeof opts.decoder.decode !== "function") {
198521
- opts.decoder = Utils.decoder;
198522
- }
198523
- if (input && typeof input === "string") {
198524
- if (filetools.fs.existsSync(input)) {
198525
- opts.method = Utils.Constants.FILE;
198526
- opts.filename = input;
198527
- inBuffer = filetools.fs.readFileSync(input);
198528
- } else {
198529
- throw Utils.Errors.INVALID_FILENAME();
198530
- }
198531
- }
198532
- const _zip = new ZipFile(inBuffer, opts);
198533
- const { canonical, sanitize, zipnamefix } = Utils;
198534
- function getEntry(entry) {
198535
- if (entry && _zip) {
198536
- var item;
198537
- if (typeof entry === "string")
198538
- item = _zip.getEntry(pth.posix.normalize(entry));
198539
- if (typeof entry === "object" && typeof entry.entryName !== "undefined" && typeof entry.header !== "undefined")
198540
- item = _zip.getEntry(entry.entryName);
198541
- if (item) {
198542
- return item;
198543
198070
  }
198071
+ callback(null, endpointStream);
198072
+ } finally {
198073
+ self2.reader.unref();
198544
198074
  }
198545
- return null;
198075
+ });
198076
+ };
198077
+ function Entry() {}
198078
+ Entry.prototype.getLastModDate = function() {
198079
+ return dosDateTimeToDate(this.lastModFileDate, this.lastModFileTime);
198080
+ };
198081
+ Entry.prototype.isEncrypted = function() {
198082
+ return (this.generalPurposeBitFlag & 1) !== 0;
198083
+ };
198084
+ Entry.prototype.isCompressed = function() {
198085
+ return this.compressionMethod === 8;
198086
+ };
198087
+ function dosDateTimeToDate(date, time) {
198088
+ var day = date & 31;
198089
+ var month = (date >> 5 & 15) - 1;
198090
+ var year = (date >> 9 & 127) + 1980;
198091
+ var millisecond = 0;
198092
+ var second = (time & 31) * 2;
198093
+ var minute = time >> 5 & 63;
198094
+ var hour = time >> 11 & 31;
198095
+ return new Date(year, month, day, hour, minute, second, millisecond);
198096
+ }
198097
+ function validateFileName(fileName) {
198098
+ if (fileName.indexOf("\\") !== -1) {
198099
+ return "invalid characters in fileName: " + fileName;
198546
198100
  }
198547
- function fixPath(zipPath) {
198548
- const { join: join3, normalize: normalize2, sep } = pth.posix;
198549
- return join3(".", normalize2(sep + zipPath.split("\\").join(sep) + sep));
198101
+ if (/^[a-zA-Z]:/.test(fileName) || /^\//.test(fileName)) {
198102
+ return "absolute path: " + fileName;
198550
198103
  }
198551
- function filenameFilter(filterfn) {
198552
- if (filterfn instanceof RegExp) {
198553
- return function(rx) {
198554
- return function(filename) {
198555
- return rx.test(filename);
198556
- };
198557
- }(filterfn);
198558
- } else if (typeof filterfn !== "function") {
198559
- return () => true;
198104
+ if (fileName.split("/").indexOf("..") !== -1) {
198105
+ return "invalid relative path: " + fileName;
198106
+ }
198107
+ return null;
198108
+ }
198109
+ function readAndAssertNoEof(reader, buffer, offset, length, position, callback) {
198110
+ if (length === 0) {
198111
+ return setImmediate(function() {
198112
+ callback(null, newBuffer(0));
198113
+ });
198114
+ }
198115
+ reader.read(buffer, offset, length, position, function(err, bytesRead) {
198116
+ if (err)
198117
+ return callback(err);
198118
+ if (bytesRead < length) {
198119
+ return callback(new Error("unexpected EOF"));
198560
198120
  }
198561
- return filterfn;
198121
+ callback();
198122
+ });
198123
+ }
198124
+ util5.inherits(AssertByteCountStream, Transform);
198125
+ function AssertByteCountStream(byteCount) {
198126
+ Transform.call(this);
198127
+ this.actualByteCount = 0;
198128
+ this.expectedByteCount = byteCount;
198129
+ }
198130
+ AssertByteCountStream.prototype._transform = function(chunk, encoding, cb) {
198131
+ this.actualByteCount += chunk.length;
198132
+ if (this.actualByteCount > this.expectedByteCount) {
198133
+ var msg = "too many bytes in the stream. expected " + this.expectedByteCount + ". got at least " + this.actualByteCount;
198134
+ return cb(new Error(msg));
198135
+ }
198136
+ cb(null, chunk);
198137
+ };
198138
+ AssertByteCountStream.prototype._flush = function(cb) {
198139
+ if (this.actualByteCount < this.expectedByteCount) {
198140
+ var msg = "not enough bytes in the stream. expected " + this.expectedByteCount + ". got only " + this.actualByteCount;
198141
+ return cb(new Error(msg));
198142
+ }
198143
+ cb();
198144
+ };
198145
+ util5.inherits(RandomAccessReader, EventEmitter3);
198146
+ function RandomAccessReader() {
198147
+ EventEmitter3.call(this);
198148
+ this.refCount = 0;
198149
+ }
198150
+ RandomAccessReader.prototype.ref = function() {
198151
+ this.refCount += 1;
198152
+ };
198153
+ RandomAccessReader.prototype.unref = function() {
198154
+ var self2 = this;
198155
+ self2.refCount -= 1;
198156
+ if (self2.refCount > 0)
198157
+ return;
198158
+ if (self2.refCount < 0)
198159
+ throw new Error("invalid unref");
198160
+ self2.close(onCloseDone);
198161
+ function onCloseDone(err) {
198162
+ if (err)
198163
+ return self2.emit("error", err);
198164
+ self2.emit("close");
198165
+ }
198166
+ };
198167
+ RandomAccessReader.prototype.createReadStream = function(options) {
198168
+ var start = options.start;
198169
+ var end = options.end;
198170
+ if (start === end) {
198171
+ var emptyStream = new PassThrough;
198172
+ setImmediate(function() {
198173
+ emptyStream.end();
198174
+ });
198175
+ return emptyStream;
198562
198176
  }
198563
- const relativePath = (local, entry) => {
198564
- let lastChar = entry.slice(-1);
198565
- lastChar = lastChar === filetools.sep ? filetools.sep : "";
198566
- return pth.relative(local, entry) + lastChar;
198177
+ var stream4 = this._readStreamForRange(start, end);
198178
+ var destroyed = false;
198179
+ var refUnrefFilter = new RefUnrefFilter(this);
198180
+ stream4.on("error", function(err) {
198181
+ setImmediate(function() {
198182
+ if (!destroyed)
198183
+ refUnrefFilter.emit("error", err);
198184
+ });
198185
+ });
198186
+ refUnrefFilter.destroy = function() {
198187
+ stream4.unpipe(refUnrefFilter);
198188
+ refUnrefFilter.unref();
198189
+ stream4.destroy();
198567
198190
  };
198568
- return {
198569
- readFile: function(entry, pass) {
198570
- var item = getEntry(entry);
198571
- return item && item.getData(pass) || null;
198572
- },
198573
- childCount: function(entry) {
198574
- const item = getEntry(entry);
198575
- if (item) {
198576
- return _zip.getChildCount(item);
198577
- }
198578
- },
198579
- readFileAsync: function(entry, callback) {
198580
- var item = getEntry(entry);
198581
- if (item) {
198582
- item.getDataAsync(callback);
198583
- } else {
198584
- callback(null, "getEntry failed for:" + entry);
198585
- }
198586
- },
198587
- readAsText: function(entry, encoding) {
198588
- var item = getEntry(entry);
198589
- if (item) {
198590
- var data = item.getData();
198591
- if (data && data.length) {
198592
- return data.toString(encoding || "utf8");
198593
- }
198594
- }
198595
- return "";
198596
- },
198597
- readAsTextAsync: function(entry, callback, encoding) {
198598
- var item = getEntry(entry);
198599
- if (item) {
198600
- item.getDataAsync(function(data, err) {
198601
- if (err) {
198602
- callback(data, err);
198603
- return;
198604
- }
198605
- if (data && data.length) {
198606
- callback(data.toString(encoding || "utf8"));
198607
- } else {
198608
- callback("");
198609
- }
198610
- });
198611
- } else {
198612
- callback("");
198613
- }
198614
- },
198615
- deleteFile: function(entry, withsubfolders = true) {
198616
- var item = getEntry(entry);
198617
- if (item) {
198618
- _zip.deleteFile(item.entryName, withsubfolders);
198619
- }
198620
- },
198621
- deleteEntry: function(entry) {
198622
- var item = getEntry(entry);
198623
- if (item) {
198624
- _zip.deleteEntry(item.entryName);
198625
- }
198626
- },
198627
- addZipComment: function(comment) {
198628
- _zip.comment = comment;
198629
- },
198630
- getZipComment: function() {
198631
- return _zip.comment || "";
198632
- },
198633
- addZipEntryComment: function(entry, comment) {
198634
- var item = getEntry(entry);
198635
- if (item) {
198636
- item.comment = comment;
198637
- }
198638
- },
198639
- getZipEntryComment: function(entry) {
198640
- var item = getEntry(entry);
198641
- if (item) {
198642
- return item.comment || "";
198643
- }
198644
- return "";
198645
- },
198646
- updateFile: function(entry, content) {
198647
- var item = getEntry(entry);
198648
- if (item) {
198649
- item.setData(content);
198650
- }
198651
- },
198652
- addLocalFile: function(localPath2, zipPath, zipName, comment) {
198653
- if (filetools.fs.existsSync(localPath2)) {
198654
- zipPath = zipPath ? fixPath(zipPath) : "";
198655
- const p = pth.win32.basename(pth.win32.normalize(localPath2));
198656
- zipPath += zipName ? zipName : p;
198657
- const _attr = filetools.fs.statSync(localPath2);
198658
- const data = _attr.isFile() ? filetools.fs.readFileSync(localPath2) : Buffer.alloc(0);
198659
- if (_attr.isDirectory())
198660
- zipPath += filetools.sep;
198661
- this.addFile(zipPath, data, comment, _attr);
198662
- } else {
198663
- throw Utils.Errors.FILE_NOT_FOUND(localPath2);
198664
- }
198665
- },
198666
- addLocalFileAsync: function(options2, callback) {
198667
- options2 = typeof options2 === "object" ? options2 : { localPath: options2 };
198668
- const localPath2 = pth.resolve(options2.localPath);
198669
- const { comment } = options2;
198670
- let { zipPath, zipName } = options2;
198671
- const self2 = this;
198672
- filetools.fs.stat(localPath2, function(err, stats) {
198673
- if (err)
198674
- return callback(err, false);
198675
- zipPath = zipPath ? fixPath(zipPath) : "";
198676
- const p = pth.win32.basename(pth.win32.normalize(localPath2));
198677
- zipPath += zipName ? zipName : p;
198678
- if (stats.isFile()) {
198679
- filetools.fs.readFile(localPath2, function(err2, data) {
198680
- if (err2)
198681
- return callback(err2, false);
198682
- self2.addFile(zipPath, data, comment, stats);
198683
- return setImmediate(callback, undefined, true);
198684
- });
198685
- } else if (stats.isDirectory()) {
198686
- zipPath += filetools.sep;
198687
- self2.addFile(zipPath, Buffer.alloc(0), comment, stats);
198688
- return setImmediate(callback, undefined, true);
198689
- }
198690
- });
198691
- },
198692
- addLocalFolder: function(localPath2, zipPath, filter2) {
198693
- filter2 = filenameFilter(filter2);
198694
- zipPath = zipPath ? fixPath(zipPath) : "";
198695
- localPath2 = pth.normalize(localPath2);
198696
- if (filetools.fs.existsSync(localPath2)) {
198697
- const items = filetools.findFiles(localPath2);
198698
- const self2 = this;
198699
- if (items.length) {
198700
- for (const filepath of items) {
198701
- const p = pth.join(zipPath, relativePath(localPath2, filepath));
198702
- if (filter2(p)) {
198703
- self2.addLocalFile(filepath, pth.dirname(p));
198704
- }
198705
- }
198706
- }
198707
- } else {
198708
- throw Utils.Errors.FILE_NOT_FOUND(localPath2);
198709
- }
198710
- },
198711
- addLocalFolderAsync: function(localPath2, callback, zipPath, filter2) {
198712
- filter2 = filenameFilter(filter2);
198713
- zipPath = zipPath ? fixPath(zipPath) : "";
198714
- localPath2 = pth.normalize(localPath2);
198715
- var self2 = this;
198716
- filetools.fs.open(localPath2, "r", function(err) {
198717
- if (err && err.code === "ENOENT") {
198718
- callback(undefined, Utils.Errors.FILE_NOT_FOUND(localPath2));
198719
- } else if (err) {
198720
- callback(undefined, err);
198721
- } else {
198722
- var items = filetools.findFiles(localPath2);
198723
- var i = -1;
198724
- var next = function() {
198725
- i += 1;
198726
- if (i < items.length) {
198727
- var filepath = items[i];
198728
- var p = relativePath(localPath2, filepath).split("\\").join("/");
198729
- p = p.normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^\x20-\x7E]/g, "");
198730
- if (filter2(p)) {
198731
- filetools.fs.stat(filepath, function(er0, stats) {
198732
- if (er0)
198733
- callback(undefined, er0);
198734
- if (stats.isFile()) {
198735
- filetools.fs.readFile(filepath, function(er1, data) {
198736
- if (er1) {
198737
- callback(undefined, er1);
198738
- } else {
198739
- self2.addFile(zipPath + p, data, "", stats);
198740
- next();
198741
- }
198742
- });
198743
- } else {
198744
- self2.addFile(zipPath + p + "/", Buffer.alloc(0), "", stats);
198745
- next();
198746
- }
198747
- });
198748
- } else {
198749
- process.nextTick(() => {
198750
- next();
198751
- });
198752
- }
198753
- } else {
198754
- callback(true, undefined);
198755
- }
198756
- };
198757
- next();
198758
- }
198191
+ var byteCounter = new AssertByteCountStream(end - start);
198192
+ refUnrefFilter.on("error", function(err) {
198193
+ setImmediate(function() {
198194
+ if (!destroyed)
198195
+ byteCounter.emit("error", err);
198196
+ });
198197
+ });
198198
+ byteCounter.destroy = function() {
198199
+ destroyed = true;
198200
+ refUnrefFilter.unpipe(byteCounter);
198201
+ refUnrefFilter.destroy();
198202
+ };
198203
+ return stream4.pipe(refUnrefFilter).pipe(byteCounter);
198204
+ };
198205
+ RandomAccessReader.prototype._readStreamForRange = function(start, end) {
198206
+ throw new Error("not implemented");
198207
+ };
198208
+ RandomAccessReader.prototype.read = function(buffer, offset, length, position, callback) {
198209
+ var readStream2 = this.createReadStream({ start: position, end: position + length });
198210
+ var writeStream = new Writable;
198211
+ var written = 0;
198212
+ writeStream._write = function(chunk, encoding, cb) {
198213
+ chunk.copy(buffer, offset + written, 0, chunk.length);
198214
+ written += chunk.length;
198215
+ cb();
198216
+ };
198217
+ writeStream.on("finish", callback);
198218
+ readStream2.on("error", function(error) {
198219
+ callback(error);
198220
+ });
198221
+ readStream2.pipe(writeStream);
198222
+ };
198223
+ RandomAccessReader.prototype.close = function(callback) {
198224
+ setImmediate(callback);
198225
+ };
198226
+ util5.inherits(RefUnrefFilter, PassThrough);
198227
+ function RefUnrefFilter(context) {
198228
+ PassThrough.call(this);
198229
+ this.context = context;
198230
+ this.context.ref();
198231
+ this.unreffedYet = false;
198232
+ }
198233
+ RefUnrefFilter.prototype._flush = function(cb) {
198234
+ this.unref();
198235
+ cb();
198236
+ };
198237
+ RefUnrefFilter.prototype.unref = function(cb) {
198238
+ if (this.unreffedYet)
198239
+ return;
198240
+ this.unreffedYet = true;
198241
+ this.context.unref();
198242
+ };
198243
+ var cp437 = "\x00☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼ !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~⌂ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ ";
198244
+ function decodeBuffer(buffer, start, end, isUtf8) {
198245
+ if (isUtf8) {
198246
+ return buffer.toString("utf8", start, end);
198247
+ } else {
198248
+ var result = "";
198249
+ for (var i = start;i < end; i++) {
198250
+ result += cp437[buffer[i]];
198251
+ }
198252
+ return result;
198253
+ }
198254
+ }
198255
+ function readUInt64LE(buffer, offset) {
198256
+ var lower32 = buffer.readUInt32LE(offset);
198257
+ var upper32 = buffer.readUInt32LE(offset + 4);
198258
+ return upper32 * 4294967296 + lower32;
198259
+ }
198260
+ var newBuffer;
198261
+ if (typeof Buffer.allocUnsafe === "function") {
198262
+ newBuffer = function(len) {
198263
+ return Buffer.allocUnsafe(len);
198264
+ };
198265
+ } else {
198266
+ newBuffer = function(len) {
198267
+ return new Buffer(len);
198268
+ };
198269
+ }
198270
+ function defaultCallback(err) {
198271
+ if (err)
198272
+ throw err;
198273
+ }
198274
+ });
198275
+
198276
+ // ../../node_modules/extract-zip/index.js
198277
+ var require_extract_zip = __commonJS((exports, module) => {
198278
+ var debug = require_src5()("extract-zip");
198279
+ var { createWriteStream, promises: fs2 } = __require("fs");
198280
+ var getStream = require_get_stream();
198281
+ var path3 = __require("path");
198282
+ var { promisify } = __require("util");
198283
+ var stream4 = __require("stream");
198284
+ var yauzl = require_yauzl();
198285
+ var openZip = promisify(yauzl.open);
198286
+ var pipeline = promisify(stream4.pipeline);
198287
+
198288
+ class Extractor {
198289
+ constructor(zipPath, opts) {
198290
+ this.zipPath = zipPath;
198291
+ this.opts = opts;
198292
+ }
198293
+ async extract() {
198294
+ debug("opening", this.zipPath, "with opts", this.opts);
198295
+ this.zipfile = await openZip(this.zipPath, { lazyEntries: true });
198296
+ this.canceled = false;
198297
+ return new Promise((resolve3, reject) => {
198298
+ this.zipfile.on("error", (err) => {
198299
+ this.canceled = true;
198300
+ reject(err);
198759
198301
  });
198760
- },
198761
- addLocalFolderAsync2: function(options2, callback) {
198762
- const self2 = this;
198763
- options2 = typeof options2 === "object" ? options2 : { localPath: options2 };
198764
- localPath = pth.resolve(fixPath(options2.localPath));
198765
- let { zipPath, filter: filter2, namefix } = options2;
198766
- if (filter2 instanceof RegExp) {
198767
- filter2 = function(rx) {
198768
- return function(filename) {
198769
- return rx.test(filename);
198770
- };
198771
- }(filter2);
198772
- } else if (typeof filter2 !== "function") {
198773
- filter2 = function() {
198774
- return true;
198775
- };
198776
- }
198777
- zipPath = zipPath ? fixPath(zipPath) : "";
198778
- if (namefix == "latin1") {
198779
- namefix = (str) => str.normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^\x20-\x7E]/g, "");
198780
- }
198781
- if (typeof namefix !== "function")
198782
- namefix = (str) => str;
198783
- const relPathFix = (entry) => pth.join(zipPath, namefix(relativePath(localPath, entry)));
198784
- const fileNameFix = (entry) => pth.win32.basename(pth.win32.normalize(namefix(entry)));
198785
- filetools.fs.open(localPath, "r", function(err) {
198786
- if (err && err.code === "ENOENT") {
198787
- callback(undefined, Utils.Errors.FILE_NOT_FOUND(localPath));
198788
- } else if (err) {
198789
- callback(undefined, err);
198790
- } else {
198791
- filetools.findFilesAsync(localPath, function(err2, fileEntries) {
198792
- if (err2)
198793
- return callback(err2);
198794
- fileEntries = fileEntries.filter((dir) => filter2(relPathFix(dir)));
198795
- if (!fileEntries.length)
198796
- callback(undefined, false);
198797
- setImmediate(fileEntries.reverse().reduce(function(next, entry) {
198798
- return function(err3, done) {
198799
- if (err3 || done === false)
198800
- return setImmediate(next, err3, false);
198801
- self2.addLocalFileAsync({
198802
- localPath: entry,
198803
- zipPath: pth.dirname(relPathFix(entry)),
198804
- zipName: fileNameFix(entry)
198805
- }, next);
198806
- };
198807
- }, callback));
198808
- });
198302
+ this.zipfile.readEntry();
198303
+ this.zipfile.on("close", () => {
198304
+ if (!this.canceled) {
198305
+ debug("zip extraction complete");
198306
+ resolve3();
198809
198307
  }
198810
198308
  });
198811
- },
198812
- addLocalFolderPromise: function(localPath2, props) {
198813
- return new Promise((resolve3, reject) => {
198814
- this.addLocalFolderAsync2(Object.assign({ localPath: localPath2 }, props), (err, done) => {
198815
- if (err)
198816
- reject(err);
198817
- if (done)
198818
- resolve3(this);
198819
- });
198820
- });
198821
- },
198822
- addFile: function(entryName, content, comment, attr) {
198823
- entryName = zipnamefix(entryName);
198824
- let entry = getEntry(entryName);
198825
- const update = entry != null;
198826
- if (!update) {
198827
- entry = new ZipEntry(opts);
198828
- entry.entryName = entryName;
198829
- }
198830
- entry.comment = comment || "";
198831
- const isStat = typeof attr === "object" && attr instanceof filetools.fs.Stats;
198832
- if (isStat) {
198833
- entry.header.time = attr.mtime;
198834
- }
198835
- var fileattr = entry.isDirectory ? 16 : 0;
198836
- let unix = entry.isDirectory ? 16384 : 32768;
198837
- if (isStat) {
198838
- unix |= 4095 & attr.mode;
198839
- } else if (typeof attr === "number") {
198840
- unix |= 4095 & attr;
198841
- } else {
198842
- unix |= entry.isDirectory ? 493 : 420;
198843
- }
198844
- fileattr = (fileattr | unix << 16) >>> 0;
198845
- entry.attr = fileattr;
198846
- entry.setData(content);
198847
- if (!update)
198848
- _zip.setEntry(entry);
198849
- return entry;
198850
- },
198851
- getEntries: function(password) {
198852
- _zip.password = password;
198853
- return _zip ? _zip.entries : [];
198854
- },
198855
- getEntry: function(name) {
198856
- return getEntry(name);
198857
- },
198858
- getEntryCount: function() {
198859
- return _zip.getEntryCount();
198860
- },
198861
- forEach: function(callback) {
198862
- return _zip.forEach(callback);
198863
- },
198864
- extractEntryTo: function(entry, targetPath, maintainEntryPath, overwrite, keepOriginalPermission, outFileName) {
198865
- overwrite = get_Bool(false, overwrite);
198866
- keepOriginalPermission = get_Bool(false, keepOriginalPermission);
198867
- maintainEntryPath = get_Bool(true, maintainEntryPath);
198868
- outFileName = get_Str(keepOriginalPermission, outFileName);
198869
- var item = getEntry(entry);
198870
- if (!item) {
198871
- throw Utils.Errors.NO_ENTRY();
198872
- }
198873
- var entryName = canonical(item.entryName);
198874
- var target = sanitize(targetPath, outFileName && !item.isDirectory ? outFileName : maintainEntryPath ? entryName : pth.basename(entryName));
198875
- if (item.isDirectory) {
198876
- var children = _zip.getEntryChildren(item);
198877
- children.forEach(function(child) {
198878
- if (child.isDirectory)
198879
- return;
198880
- var content2 = child.getData();
198881
- if (!content2) {
198882
- throw Utils.Errors.CANT_EXTRACT_FILE();
198883
- }
198884
- var name = canonical(child.entryName);
198885
- var childName = sanitize(targetPath, maintainEntryPath ? name : pth.basename(name));
198886
- const fileAttr2 = keepOriginalPermission ? child.header.fileAttr : undefined;
198887
- filetools.writeFileTo(childName, content2, overwrite, fileAttr2);
198888
- });
198889
- return true;
198890
- }
198891
- var content = item.getData(_zip.password);
198892
- if (!content)
198893
- throw Utils.Errors.CANT_EXTRACT_FILE();
198894
- if (filetools.fs.existsSync(target) && !overwrite) {
198895
- throw Utils.Errors.CANT_OVERRIDE();
198896
- }
198897
- const fileAttr = keepOriginalPermission ? entry.header.fileAttr : undefined;
198898
- filetools.writeFileTo(target, content, overwrite, fileAttr);
198899
- return true;
198900
- },
198901
- test: function(pass) {
198902
- if (!_zip) {
198903
- return false;
198904
- }
198905
- for (var entry in _zip.entries) {
198906
- try {
198907
- if (entry.isDirectory) {
198908
- continue;
198909
- }
198910
- var content = _zip.entries[entry].getData(pass);
198911
- if (!content) {
198912
- return false;
198913
- }
198914
- } catch (err) {
198915
- return false;
198916
- }
198917
- }
198918
- return true;
198919
- },
198920
- extractAllTo: function(targetPath, overwrite, keepOriginalPermission, pass) {
198921
- keepOriginalPermission = get_Bool(false, keepOriginalPermission);
198922
- pass = get_Str(keepOriginalPermission, pass);
198923
- overwrite = get_Bool(false, overwrite);
198924
- if (!_zip)
198925
- throw Utils.Errors.NO_ZIP();
198926
- _zip.entries.forEach(function(entry) {
198927
- var entryName = sanitize(targetPath, canonical(entry.entryName));
198928
- if (entry.isDirectory) {
198929
- filetools.makeDir(entryName);
198309
+ this.zipfile.on("entry", async (entry) => {
198310
+ if (this.canceled) {
198311
+ debug("skipping entry", entry.fileName, { cancelled: this.canceled });
198930
198312
  return;
198931
198313
  }
198932
- var content = entry.getData(pass);
198933
- if (!content) {
198934
- throw Utils.Errors.CANT_EXTRACT_FILE();
198314
+ debug("zipfile entry", entry.fileName);
198315
+ if (entry.fileName.startsWith("__MACOSX/")) {
198316
+ this.zipfile.readEntry();
198317
+ return;
198935
198318
  }
198936
- const fileAttr = keepOriginalPermission ? entry.header.fileAttr : undefined;
198937
- filetools.writeFileTo(entryName, content, overwrite, fileAttr);
198319
+ const destDir = path3.dirname(path3.join(this.opts.dir, entry.fileName));
198938
198320
  try {
198939
- filetools.fs.utimesSync(entryName, entry.header.time, entry.header.time);
198321
+ await fs2.mkdir(destDir, { recursive: true });
198322
+ const canonicalDestDir = await fs2.realpath(destDir);
198323
+ const relativeDestDir = path3.relative(this.opts.dir, canonicalDestDir);
198324
+ if (relativeDestDir.split(path3.sep).includes("..")) {
198325
+ throw new Error(`Out of bound path "${canonicalDestDir}" found while processing file ${entry.fileName}`);
198326
+ }
198327
+ await this.extractEntry(entry);
198328
+ debug("finished processing", entry.fileName);
198329
+ this.zipfile.readEntry();
198940
198330
  } catch (err) {
198941
- throw Utils.Errors.CANT_EXTRACT_FILE();
198331
+ this.canceled = true;
198332
+ this.zipfile.close();
198333
+ reject(err);
198942
198334
  }
198943
198335
  });
198944
- },
198945
- extractAllToAsync: function(targetPath, overwrite, keepOriginalPermission, callback) {
198946
- callback = get_Fun(overwrite, keepOriginalPermission, callback);
198947
- keepOriginalPermission = get_Bool(false, keepOriginalPermission);
198948
- overwrite = get_Bool(false, overwrite);
198949
- if (!callback) {
198950
- return new Promise((resolve3, reject) => {
198951
- this.extractAllToAsync(targetPath, overwrite, keepOriginalPermission, function(err) {
198952
- if (err) {
198953
- reject(err);
198954
- } else {
198955
- resolve3(this);
198956
- }
198957
- });
198958
- });
198959
- }
198960
- if (!_zip) {
198961
- callback(Utils.Errors.NO_ZIP());
198962
- return;
198963
- }
198964
- targetPath = pth.resolve(targetPath);
198965
- const getPath = (entry) => sanitize(targetPath, pth.normalize(canonical(entry.entryName)));
198966
- const getError = (msg, file) => new Error(msg + ': "' + file + '"');
198967
- const dirEntries = [];
198968
- const fileEntries = [];
198969
- _zip.entries.forEach((e) => {
198970
- if (e.isDirectory) {
198971
- dirEntries.push(e);
198972
- } else {
198973
- fileEntries.push(e);
198336
+ });
198337
+ }
198338
+ async extractEntry(entry) {
198339
+ if (this.canceled) {
198340
+ debug("skipping entry extraction", entry.fileName, { cancelled: this.canceled });
198341
+ return;
198342
+ }
198343
+ if (this.opts.onEntry) {
198344
+ this.opts.onEntry(entry, this.zipfile);
198345
+ }
198346
+ const dest = path3.join(this.opts.dir, entry.fileName);
198347
+ const mode = entry.externalFileAttributes >> 16 & 65535;
198348
+ const IFMT = 61440;
198349
+ const IFDIR = 16384;
198350
+ const IFLNK = 40960;
198351
+ const symlink = (mode & IFMT) === IFLNK;
198352
+ let isDir = (mode & IFMT) === IFDIR;
198353
+ if (!isDir && entry.fileName.endsWith("/")) {
198354
+ isDir = true;
198355
+ }
198356
+ const madeBy = entry.versionMadeBy >> 8;
198357
+ if (!isDir)
198358
+ isDir = madeBy === 0 && entry.externalFileAttributes === 16;
198359
+ debug("extracting entry", { filename: entry.fileName, isDir, isSymlink: symlink });
198360
+ const procMode = this.getExtractedMode(mode, isDir) & 511;
198361
+ const destDir = isDir ? dest : path3.dirname(dest);
198362
+ const mkdirOptions = { recursive: true };
198363
+ if (isDir) {
198364
+ mkdirOptions.mode = procMode;
198365
+ }
198366
+ debug("mkdir", { dir: destDir, ...mkdirOptions });
198367
+ await fs2.mkdir(destDir, mkdirOptions);
198368
+ if (isDir)
198369
+ return;
198370
+ debug("opening read stream", dest);
198371
+ const readStream2 = await promisify(this.zipfile.openReadStream.bind(this.zipfile))(entry);
198372
+ if (symlink) {
198373
+ const link = await getStream(readStream2);
198374
+ debug("creating symlink", link, dest);
198375
+ await fs2.symlink(link, dest);
198376
+ } else {
198377
+ await pipeline(readStream2, createWriteStream(dest, { mode: procMode }));
198378
+ }
198379
+ }
198380
+ getExtractedMode(entryMode, isDir) {
198381
+ let mode = entryMode;
198382
+ if (mode === 0) {
198383
+ if (isDir) {
198384
+ if (this.opts.defaultDirMode) {
198385
+ mode = parseInt(this.opts.defaultDirMode, 10);
198974
198386
  }
198975
- });
198976
- for (const entry of dirEntries) {
198977
- const dirPath = getPath(entry);
198978
- const dirAttr = keepOriginalPermission ? entry.header.fileAttr : undefined;
198979
- try {
198980
- filetools.makeDir(dirPath);
198981
- if (dirAttr)
198982
- filetools.fs.chmodSync(dirPath, dirAttr);
198983
- filetools.fs.utimesSync(dirPath, entry.header.time, entry.header.time);
198984
- } catch (er) {
198985
- callback(getError("Unable to create folder", dirPath));
198387
+ if (!mode) {
198388
+ mode = 493;
198986
198389
  }
198987
- }
198988
- fileEntries.reverse().reduce(function(next, entry) {
198989
- return function(err) {
198990
- if (err) {
198991
- next(err);
198992
- } else {
198993
- const entryName = pth.normalize(canonical(entry.entryName));
198994
- const filePath = sanitize(targetPath, entryName);
198995
- entry.getDataAsync(function(content, err_1) {
198996
- if (err_1) {
198997
- next(err_1);
198998
- } else if (!content) {
198999
- next(Utils.Errors.CANT_EXTRACT_FILE());
199000
- } else {
199001
- const fileAttr = keepOriginalPermission ? entry.header.fileAttr : undefined;
199002
- filetools.writeFileToAsync(filePath, content, overwrite, fileAttr, function(succ) {
199003
- if (!succ) {
199004
- next(getError("Unable to write file", filePath));
199005
- }
199006
- filetools.fs.utimes(filePath, entry.header.time, entry.header.time, function(err_2) {
199007
- if (err_2) {
199008
- next(getError("Unable to set times", filePath));
199009
- } else {
199010
- next();
199011
- }
199012
- });
199013
- });
199014
- }
199015
- });
199016
- }
199017
- };
199018
- }, callback)();
199019
- },
199020
- writeZip: function(targetFileName, callback) {
199021
- if (arguments.length === 1) {
199022
- if (typeof targetFileName === "function") {
199023
- callback = targetFileName;
199024
- targetFileName = "";
198390
+ } else {
198391
+ if (this.opts.defaultFileMode) {
198392
+ mode = parseInt(this.opts.defaultFileMode, 10);
198393
+ }
198394
+ if (!mode) {
198395
+ mode = 420;
199025
198396
  }
199026
198397
  }
199027
- if (!targetFileName && opts.filename) {
199028
- targetFileName = opts.filename;
199029
- }
199030
- if (!targetFileName)
199031
- return;
199032
- var zipData = _zip.compressToBuffer();
199033
- if (zipData) {
199034
- var ok = filetools.writeFileTo(targetFileName, zipData, true);
199035
- if (typeof callback === "function")
199036
- callback(!ok ? new Error("failed") : null, "");
199037
- }
199038
- },
199039
- writeZipPromise: function(targetFileName, props) {
199040
- const { overwrite, perm } = Object.assign({ overwrite: true }, props);
199041
- return new Promise((resolve3, reject) => {
199042
- if (!targetFileName && opts.filename)
199043
- targetFileName = opts.filename;
199044
- if (!targetFileName)
199045
- reject("ADM-ZIP: ZIP File Name Missing");
199046
- this.toBufferPromise().then((zipData) => {
199047
- const ret = (done) => done ? resolve3(done) : reject("ADM-ZIP: Wasn't able to write zip file");
199048
- filetools.writeFileToAsync(targetFileName, zipData, overwrite, perm, ret);
199049
- }, reject);
199050
- });
199051
- },
199052
- toBufferPromise: function() {
199053
- return new Promise((resolve3, reject) => {
199054
- _zip.toAsyncBuffer(resolve3, reject);
199055
- });
199056
- },
199057
- toBuffer: function(onSuccess, onFail, onItemStart, onItemEnd) {
199058
- if (typeof onSuccess === "function") {
199059
- _zip.toAsyncBuffer(onSuccess, onFail, onItemStart, onItemEnd);
199060
- return null;
199061
- }
199062
- return _zip.compressToBuffer();
199063
198398
  }
199064
- };
198399
+ return mode;
198400
+ }
198401
+ }
198402
+ module.exports = async function(zipPath, opts) {
198403
+ debug("creating target directory", opts.dir);
198404
+ if (!path3.isAbsolute(opts.dir)) {
198405
+ throw new Error("Target directory is expected to be absolute");
198406
+ }
198407
+ await fs2.mkdir(opts.dir, { recursive: true });
198408
+ opts.dir = await fs2.realpath(opts.dir);
198409
+ return new Extractor(zipPath, opts).extract();
199065
198410
  };
199066
198411
  });
199067
198412
 
@@ -200771,7 +200116,7 @@ var require_uri_all = __commonJS((exports, module) => {
200771
200116
  target.fragment = relative4.fragment;
200772
200117
  return target;
200773
200118
  }
200774
- function resolve4(baseURI, relativeURI, options) {
200119
+ function resolve5(baseURI, relativeURI, options) {
200775
200120
  var schemelessOptions = assign({ scheme: "null" }, options);
200776
200121
  return serialize(resolveComponents(parse(baseURI, schemelessOptions), parse(relativeURI, schemelessOptions), schemelessOptions, true), schemelessOptions);
200777
200122
  }
@@ -201039,7 +200384,7 @@ var require_uri_all = __commonJS((exports, module) => {
201039
200384
  exports2.removeDotSegments = removeDotSegments;
201040
200385
  exports2.serialize = serialize;
201041
200386
  exports2.resolveComponents = resolveComponents;
201042
- exports2.resolve = resolve4;
200387
+ exports2.resolve = resolve5;
201043
200388
  exports2.normalize = normalize2;
201044
200389
  exports2.equal = equal;
201045
200390
  exports2.escapeComponent = escapeComponent;
@@ -201108,7 +200453,7 @@ var require_ucs2length = __commonJS((exports, module) => {
201108
200453
  });
201109
200454
 
201110
200455
  // ../../node_modules/@modelcontextprotocol/sdk/node_modules/ajv/lib/compile/util.js
201111
- var require_util13 = __commonJS((exports, module) => {
200456
+ var require_util12 = __commonJS((exports, module) => {
201112
200457
  module.exports = {
201113
200458
  copy,
201114
200459
  checkDataType,
@@ -201312,7 +200657,7 @@ var require_util13 = __commonJS((exports, module) => {
201312
200657
 
201313
200658
  // ../../node_modules/@modelcontextprotocol/sdk/node_modules/ajv/lib/compile/schema_obj.js
201314
200659
  var require_schema_obj = __commonJS((exports, module) => {
201315
- var util5 = require_util13();
200660
+ var util5 = require_util12();
201316
200661
  module.exports = SchemaObject;
201317
200662
  function SchemaObject(obj) {
201318
200663
  util5.copy(obj, this);
@@ -201402,23 +200747,23 @@ var require_json_schema_traverse = __commonJS((exports, module) => {
201402
200747
  var require_resolve2 = __commonJS((exports, module) => {
201403
200748
  var URI = require_uri_all();
201404
200749
  var equal = require_fast_deep_equal();
201405
- var util5 = require_util13();
200750
+ var util5 = require_util12();
201406
200751
  var SchemaObject = require_schema_obj();
201407
200752
  var traverse = require_json_schema_traverse();
201408
- module.exports = resolve4;
201409
- resolve4.normalizeId = normalizeId;
201410
- resolve4.fullPath = getFullPath;
201411
- resolve4.url = resolveUrl;
201412
- resolve4.ids = resolveIds;
201413
- resolve4.inlineRef = inlineRef;
201414
- resolve4.schema = resolveSchema;
201415
- function resolve4(compile, root, ref) {
200753
+ module.exports = resolve5;
200754
+ resolve5.normalizeId = normalizeId;
200755
+ resolve5.fullPath = getFullPath;
200756
+ resolve5.url = resolveUrl;
200757
+ resolve5.ids = resolveIds;
200758
+ resolve5.inlineRef = inlineRef;
200759
+ resolve5.schema = resolveSchema;
200760
+ function resolve5(compile, root, ref) {
201416
200761
  var refVal = this._refs[ref];
201417
200762
  if (typeof refVal == "string") {
201418
200763
  if (this._refs[refVal])
201419
200764
  refVal = this._refs[refVal];
201420
200765
  else
201421
- return resolve4.call(this, compile, root, refVal);
200766
+ return resolve5.call(this, compile, root, refVal);
201422
200767
  }
201423
200768
  refVal = refVal || this._schemas[ref];
201424
200769
  if (refVal instanceof SchemaObject) {
@@ -201641,7 +200986,7 @@ var require_resolve2 = __commonJS((exports, module) => {
201641
200986
 
201642
200987
  // ../../node_modules/@modelcontextprotocol/sdk/node_modules/ajv/lib/compile/error_classes.js
201643
200988
  var require_error_classes = __commonJS((exports, module) => {
201644
- var resolve4 = require_resolve2();
200989
+ var resolve5 = require_resolve2();
201645
200990
  module.exports = {
201646
200991
  Validation: errorSubclass(ValidationError),
201647
200992
  MissingRef: errorSubclass(MissingRefError)
@@ -201656,8 +201001,8 @@ var require_error_classes = __commonJS((exports, module) => {
201656
201001
  };
201657
201002
  function MissingRefError(baseId, ref, message) {
201658
201003
  this.message = message || MissingRefError.message(baseId, ref);
201659
- this.missingRef = resolve4.url(baseId, ref);
201660
- this.missingSchema = resolve4.normalizeId(resolve4.fullPath(this.missingRef));
201004
+ this.missingRef = resolve5.url(baseId, ref);
201005
+ this.missingSchema = resolve5.normalizeId(resolve5.fullPath(this.missingRef));
201661
201006
  }
201662
201007
  function errorSubclass(Subclass) {
201663
201008
  Subclass.prototype = Object.create(Error.prototype);
@@ -202199,8 +201544,8 @@ var require_validate4 = __commonJS((exports, module) => {
202199
201544
 
202200
201545
  // ../../node_modules/@modelcontextprotocol/sdk/node_modules/ajv/lib/compile/index.js
202201
201546
  var require_compile2 = __commonJS((exports, module) => {
202202
- var resolve4 = require_resolve2();
202203
- var util5 = require_util13();
201547
+ var resolve5 = require_resolve2();
201548
+ var util5 = require_util12();
202204
201549
  var errorClasses = require_error_classes();
202205
201550
  var stableStringify = require_fast_json_stable_stringify();
202206
201551
  var validateGenerator = require_validate4();
@@ -202259,7 +201604,7 @@ var require_compile2 = __commonJS((exports, module) => {
202259
201604
  RULES,
202260
201605
  validate: validateGenerator,
202261
201606
  util: util5,
202262
- resolve: resolve4,
201607
+ resolve: resolve5,
202263
201608
  resolveRef,
202264
201609
  usePattern,
202265
201610
  useDefault,
@@ -202298,7 +201643,7 @@ var require_compile2 = __commonJS((exports, module) => {
202298
201643
  return validate;
202299
201644
  }
202300
201645
  function resolveRef(baseId2, ref, isRoot) {
202301
- ref = resolve4.url(baseId2, ref);
201646
+ ref = resolve5.url(baseId2, ref);
202302
201647
  var refIndex = refs[ref];
202303
201648
  var _refVal, refCode;
202304
201649
  if (refIndex !== undefined) {
@@ -202315,11 +201660,11 @@ var require_compile2 = __commonJS((exports, module) => {
202315
201660
  }
202316
201661
  }
202317
201662
  refCode = addLocalRef(ref);
202318
- var v2 = resolve4.call(self2, localCompile, root, ref);
201663
+ var v2 = resolve5.call(self2, localCompile, root, ref);
202319
201664
  if (v2 === undefined) {
202320
201665
  var localSchema = localRefs && localRefs[ref];
202321
201666
  if (localSchema) {
202322
- v2 = resolve4.inlineRef(localSchema, opts.inlineRefs) ? localSchema : compile.call(self2, localSchema, root, localRefs, baseId2);
201667
+ v2 = resolve5.inlineRef(localSchema, opts.inlineRefs) ? localSchema : compile.call(self2, localSchema, root, localRefs, baseId2);
202323
201668
  }
202324
201669
  }
202325
201670
  if (v2 === undefined) {
@@ -202484,7 +201829,7 @@ var require_cache = __commonJS((exports, module) => {
202484
201829
 
202485
201830
  // ../../node_modules/@modelcontextprotocol/sdk/node_modules/ajv/lib/compile/formats.js
202486
201831
  var require_formats2 = __commonJS((exports, module) => {
202487
- var util5 = require_util13();
201832
+ var util5 = require_util12();
202488
201833
  var DATE = /^(\d\d\d\d)-(\d\d)-(\d\d)$/;
202489
201834
  var DAYS = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
202490
201835
  var TIME = /^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i;
@@ -205080,7 +204425,7 @@ var require_dotjs = __commonJS((exports, module) => {
205080
204425
  // ../../node_modules/@modelcontextprotocol/sdk/node_modules/ajv/lib/compile/rules.js
205081
204426
  var require_rules = __commonJS((exports, module) => {
205082
204427
  var ruleModules = require_dotjs();
205083
- var toHash = require_util13().toHash;
204428
+ var toHash = require_util12().toHash;
205084
204429
  module.exports = function rules() {
205085
204430
  var RULES = [
205086
204431
  {
@@ -205836,14 +205181,14 @@ var require_data2 = __commonJS((exports, module) => {
205836
205181
  // ../../node_modules/@modelcontextprotocol/sdk/node_modules/ajv/lib/ajv.js
205837
205182
  var require_ajv = __commonJS((exports, module) => {
205838
205183
  var compileSchema = require_compile2();
205839
- var resolve4 = require_resolve2();
205184
+ var resolve5 = require_resolve2();
205840
205185
  var Cache = require_cache();
205841
205186
  var SchemaObject = require_schema_obj();
205842
205187
  var stableStringify = require_fast_json_stable_stringify();
205843
205188
  var formats = require_formats2();
205844
205189
  var rules = require_rules();
205845
205190
  var $dataMetaSchema = require_data();
205846
- var util5 = require_util13();
205191
+ var util5 = require_util12();
205847
205192
  module.exports = Ajv;
205848
205193
  Ajv.prototype.validate = validate;
205849
205194
  Ajv.prototype.compile = compile;
@@ -205928,7 +205273,7 @@ var require_ajv = __commonJS((exports, module) => {
205928
205273
  var id = this._getId(schema);
205929
205274
  if (id !== undefined && typeof id != "string")
205930
205275
  throw new Error("schema id must be string");
205931
- key = resolve4.normalizeId(key || id);
205276
+ key = resolve5.normalizeId(key || id);
205932
205277
  checkUnique(this, key);
205933
205278
  this._schemas[key] = this._addSchema(schema, _skipValidation, _meta, true);
205934
205279
  return this;
@@ -205974,7 +205319,7 @@ var require_ajv = __commonJS((exports, module) => {
205974
205319
  }
205975
205320
  }
205976
205321
  function _getSchemaFragment(self2, ref) {
205977
- var res = resolve4.schema.call(self2, { schema: {} }, ref);
205322
+ var res = resolve5.schema.call(self2, { schema: {} }, ref);
205978
205323
  if (res) {
205979
205324
  var { schema, root, baseId } = res;
205980
205325
  var v = compileSchema.call(self2, schema, root, undefined, baseId);
@@ -205990,7 +205335,7 @@ var require_ajv = __commonJS((exports, module) => {
205990
205335
  }
205991
205336
  }
205992
205337
  function _getSchemaObj(self2, keyRef) {
205993
- keyRef = resolve4.normalizeId(keyRef);
205338
+ keyRef = resolve5.normalizeId(keyRef);
205994
205339
  return self2._schemas[keyRef] || self2._refs[keyRef] || self2._fragments[keyRef];
205995
205340
  }
205996
205341
  function removeSchema(schemaKeyRef) {
@@ -206018,7 +205363,7 @@ var require_ajv = __commonJS((exports, module) => {
206018
205363
  this._cache.del(cacheKey);
206019
205364
  var id = this._getId(schemaKeyRef);
206020
205365
  if (id) {
206021
- id = resolve4.normalizeId(id);
205366
+ id = resolve5.normalizeId(id);
206022
205367
  delete this._schemas[id];
206023
205368
  delete this._refs[id];
206024
205369
  }
@@ -206043,14 +205388,14 @@ var require_ajv = __commonJS((exports, module) => {
206043
205388
  if (cached)
206044
205389
  return cached;
206045
205390
  shouldAddSchema = shouldAddSchema || this._opts.addUsedSchema !== false;
206046
- var id = resolve4.normalizeId(this._getId(schema));
205391
+ var id = resolve5.normalizeId(this._getId(schema));
206047
205392
  if (id && shouldAddSchema)
206048
205393
  checkUnique(this, id);
206049
205394
  var willValidate = this._opts.validateSchema !== false && !skipValidation;
206050
205395
  var recursiveMeta;
206051
- if (willValidate && !(recursiveMeta = id && id == resolve4.normalizeId(schema.$schema)))
205396
+ if (willValidate && !(recursiveMeta = id && id == resolve5.normalizeId(schema.$schema)))
206052
205397
  this.validateSchema(schema, true);
206053
- var localRefs = resolve4.ids.call(this, schema);
205398
+ var localRefs = resolve5.ids.call(this, schema);
206054
205399
  var schemaObj = new SchemaObject({
206055
205400
  id,
206056
205401
  schema,
@@ -206212,7 +205557,7 @@ var require_ajv = __commonJS((exports, module) => {
206212
205557
  });
206213
205558
 
206214
205559
  // ../../node_modules/handlebars/dist/cjs/handlebars/utils.js
206215
- var require_utils75 = __commonJS((exports) => {
205560
+ var require_utils74 = __commonJS((exports) => {
206216
205561
  exports.__esModule = true;
206217
205562
  exports.extend = extend2;
206218
205563
  exports.indexOf = indexOf;
@@ -206355,7 +205700,7 @@ var require_exception = __commonJS((exports, module) => {
206355
205700
  // ../../node_modules/handlebars/dist/cjs/handlebars/helpers/block-helper-missing.js
206356
205701
  var require_block_helper_missing = __commonJS((exports, module) => {
206357
205702
  exports.__esModule = true;
206358
- var _utils = require_utils75();
205703
+ var _utils = require_utils74();
206359
205704
  exports.default = function(instance) {
206360
205705
  instance.registerHelper("blockHelperMissing", function(context, options) {
206361
205706
  var { inverse, fn } = options;
@@ -206391,7 +205736,7 @@ var require_each = __commonJS((exports, module) => {
206391
205736
  function _interopRequireDefault(obj) {
206392
205737
  return obj && obj.__esModule ? obj : { default: obj };
206393
205738
  }
206394
- var _utils = require_utils75();
205739
+ var _utils = require_utils74();
206395
205740
  var _exception = require_exception();
206396
205741
  var _exception2 = _interopRequireDefault(_exception);
206397
205742
  exports.default = function(instance) {
@@ -206492,7 +205837,7 @@ var require_if2 = __commonJS((exports, module) => {
206492
205837
  function _interopRequireDefault(obj) {
206493
205838
  return obj && obj.__esModule ? obj : { default: obj };
206494
205839
  }
206495
- var _utils = require_utils75();
205840
+ var _utils = require_utils74();
206496
205841
  var _exception = require_exception();
206497
205842
  var _exception2 = _interopRequireDefault(_exception);
206498
205843
  exports.default = function(instance) {
@@ -206565,7 +205910,7 @@ var require_with = __commonJS((exports, module) => {
206565
205910
  function _interopRequireDefault(obj) {
206566
205911
  return obj && obj.__esModule ? obj : { default: obj };
206567
205912
  }
206568
- var _utils = require_utils75();
205913
+ var _utils = require_utils74();
206569
205914
  var _exception = require_exception();
206570
205915
  var _exception2 = _interopRequireDefault(_exception);
206571
205916
  exports.default = function(instance) {
@@ -206639,7 +205984,7 @@ var require_helpers2 = __commonJS((exports) => {
206639
205984
  // ../../node_modules/handlebars/dist/cjs/handlebars/decorators/inline.js
206640
205985
  var require_inline = __commonJS((exports, module) => {
206641
205986
  exports.__esModule = true;
206642
- var _utils = require_utils75();
205987
+ var _utils = require_utils74();
206643
205988
  exports.default = function(instance) {
206644
205989
  instance.registerDecorator("inline", function(fn, props, container, options) {
206645
205990
  var ret = fn;
@@ -206677,7 +206022,7 @@ var require_decorators = __commonJS((exports) => {
206677
206022
  // ../../node_modules/handlebars/dist/cjs/handlebars/logger.js
206678
206023
  var require_logger4 = __commonJS((exports, module) => {
206679
206024
  exports.__esModule = true;
206680
- var _utils = require_utils75();
206025
+ var _utils = require_utils74();
206681
206026
  var logger2 = {
206682
206027
  methodMap: ["debug", "info", "warn", "error"],
206683
206028
  level: "info",
@@ -206714,7 +206059,7 @@ var require_logger4 = __commonJS((exports, module) => {
206714
206059
  var require_create_new_lookup_object = __commonJS((exports) => {
206715
206060
  exports.__esModule = true;
206716
206061
  exports.createNewLookupObject = createNewLookupObject;
206717
- var _utils = require_utils75();
206062
+ var _utils = require_utils74();
206718
206063
  function createNewLookupObject() {
206719
206064
  for (var _len = arguments.length, sources = Array(_len), _key = 0;_key < _len; _key++) {
206720
206065
  sources[_key] = arguments[_key];
@@ -206794,7 +206139,7 @@ var require_base = __commonJS((exports) => {
206794
206139
  function _interopRequireDefault(obj) {
206795
206140
  return obj && obj.__esModule ? obj : { default: obj };
206796
206141
  }
206797
- var _utils = require_utils75();
206142
+ var _utils = require_utils74();
206798
206143
  var _exception = require_exception();
206799
206144
  var _exception2 = _interopRequireDefault(_exception);
206800
206145
  var _helpers = require_helpers2();
@@ -206937,7 +206282,7 @@ var require_runtime = __commonJS((exports) => {
206937
206282
  return newObj;
206938
206283
  }
206939
206284
  }
206940
- var _utils = require_utils75();
206285
+ var _utils = require_utils74();
206941
206286
  var Utils = _interopRequireWildcard(_utils);
206942
206287
  var _exception = require_exception();
206943
206288
  var _exception2 = _interopRequireDefault(_exception);
@@ -207269,7 +206614,7 @@ var require_handlebars_runtime = __commonJS((exports, module) => {
207269
206614
  var _handlebarsSafeString2 = _interopRequireDefault(_handlebarsSafeString);
207270
206615
  var _handlebarsException = require_exception();
207271
206616
  var _handlebarsException2 = _interopRequireDefault(_handlebarsException);
207272
- var _handlebarsUtils = require_utils75();
206617
+ var _handlebarsUtils = require_utils74();
207273
206618
  var Utils = _interopRequireWildcard(_handlebarsUtils);
207274
206619
  var _handlebarsRuntime = require_runtime();
207275
206620
  var runtime = _interopRequireWildcard(_handlebarsRuntime);
@@ -208505,7 +207850,7 @@ var require_base2 = __commonJS((exports) => {
208505
207850
  var _whitespaceControl2 = _interopRequireDefault(_whitespaceControl);
208506
207851
  var _helpers = require_helpers3();
208507
207852
  var Helpers = _interopRequireWildcard(_helpers);
208508
- var _utils = require_utils75();
207853
+ var _utils = require_utils74();
208509
207854
  exports.parser = _parser2["default"];
208510
207855
  var yy = {};
208511
207856
  _utils.extend(yy, Helpers);
@@ -208538,7 +207883,7 @@ var require_compiler = __commonJS((exports) => {
208538
207883
  }
208539
207884
  var _exception = require_exception();
208540
207885
  var _exception2 = _interopRequireDefault(_exception);
208541
- var _utils = require_utils75();
207886
+ var _utils = require_utils74();
208542
207887
  var _ast = require_ast();
208543
207888
  var _ast2 = _interopRequireDefault(_ast);
208544
207889
  var slice = [].slice;
@@ -209036,7 +208381,7 @@ var require_base64_vlq = __commonJS((exports) => {
209036
208381
  });
209037
208382
 
209038
208383
  // ../../node_modules/source-map/lib/util.js
209039
- var require_util14 = __commonJS((exports) => {
208384
+ var require_util13 = __commonJS((exports) => {
209040
208385
  function getArg(aArgs, aName, aDefaultValue) {
209041
208386
  if (aName in aArgs) {
209042
208387
  return aArgs[aName];
@@ -209336,7 +208681,7 @@ var require_util14 = __commonJS((exports) => {
209336
208681
 
209337
208682
  // ../../node_modules/source-map/lib/array-set.js
209338
208683
  var require_array_set = __commonJS((exports) => {
209339
- var util5 = require_util14();
208684
+ var util5 = require_util13();
209340
208685
  var has = Object.prototype.hasOwnProperty;
209341
208686
  var hasNativeMap = typeof Map !== "undefined";
209342
208687
  function ArraySet() {
@@ -209404,7 +208749,7 @@ var require_array_set = __commonJS((exports) => {
209404
208749
 
209405
208750
  // ../../node_modules/source-map/lib/mapping-list.js
209406
208751
  var require_mapping_list = __commonJS((exports) => {
209407
- var util5 = require_util14();
208752
+ var util5 = require_util13();
209408
208753
  function generatedPositionAfter(mappingA, mappingB) {
209409
208754
  var lineA = mappingA.generatedLine;
209410
208755
  var lineB = mappingB.generatedLine;
@@ -209442,7 +208787,7 @@ var require_mapping_list = __commonJS((exports) => {
209442
208787
  // ../../node_modules/source-map/lib/source-map-generator.js
209443
208788
  var require_source_map_generator = __commonJS((exports) => {
209444
208789
  var base64VLQ = require_base64_vlq();
209445
- var util5 = require_util14();
208790
+ var util5 = require_util13();
209446
208791
  var ArraySet = require_array_set().ArraySet;
209447
208792
  var MappingList = require_mapping_list().MappingList;
209448
208793
  function SourceMapGenerator(aArgs) {
@@ -209791,7 +209136,7 @@ var require_quick_sort = __commonJS((exports) => {
209791
209136
 
209792
209137
  // ../../node_modules/source-map/lib/source-map-consumer.js
209793
209138
  var require_source_map_consumer = __commonJS((exports) => {
209794
- var util5 = require_util14();
209139
+ var util5 = require_util13();
209795
209140
  var binarySearch = require_binary_search();
209796
209141
  var ArraySet = require_array_set().ArraySet;
209797
209142
  var base64VLQ = require_base64_vlq();
@@ -210361,7 +209706,7 @@ var require_source_map_consumer = __commonJS((exports) => {
210361
209706
  // ../../node_modules/source-map/lib/source-node.js
210362
209707
  var require_source_node = __commonJS((exports) => {
210363
209708
  var SourceMapGenerator = require_source_map_generator().SourceMapGenerator;
210364
- var util5 = require_util14();
209709
+ var util5 = require_util13();
210365
209710
  var REGEX_NEWLINE = /(\r?\n)/;
210366
209711
  var NEWLINE_CODE = 10;
210367
209712
  var isSourceNode = "$$$isSourceNode$$$";
@@ -210622,7 +209967,7 @@ var require_source_map = __commonJS((exports) => {
210622
209967
  // ../../node_modules/handlebars/dist/cjs/handlebars/compiler/code-gen.js
210623
209968
  var require_code_gen = __commonJS((exports, module) => {
210624
209969
  exports.__esModule = true;
210625
- var _utils = require_utils75();
209970
+ var _utils = require_utils74();
210626
209971
  var SourceNode = undefined;
210627
209972
  try {
210628
209973
  if (typeof define !== "function" || !define.amd) {
@@ -210761,7 +210106,7 @@ var require_javascript_compiler = __commonJS((exports, module) => {
210761
210106
  var _base = require_base();
210762
210107
  var _exception = require_exception();
210763
210108
  var _exception2 = _interopRequireDefault(_exception);
210764
- var _utils = require_utils75();
210109
+ var _utils = require_utils74();
210765
210110
  var _codeGen = require_code_gen();
210766
210111
  var _codeGen2 = _interopRequireDefault(_codeGen);
210767
210112
  function Literal(value) {
@@ -224909,7 +224254,6 @@ import path11 from "path";
224909
224254
 
224910
224255
  // src/service/environment_store.ts
224911
224256
  var import_client_s32 = __toESM(require_dist_cjs75(), 1);
224912
- var import_adm_zip = __toESM(require_adm_zip(), 1);
224913
224257
  import { Storage } from "@google-cloud/storage";
224914
224258
 
224915
224259
  // ../../node_modules/async-mutex/index.mjs
@@ -225121,6 +224465,7 @@ class Mutex {
225121
224465
  }
225122
224466
 
225123
224467
  // src/service/environment_store.ts
224468
+ var import_extract_zip = __toESM(require_extract_zip(), 1);
225124
224469
  import crypto5 from "crypto";
225125
224470
  import * as fs7 from "fs";
225126
224471
  import * as path10 from "path";
@@ -228509,11 +227854,11 @@ var require_git = __commonJS2({
228509
227854
  Git2.prototype.stashList = function(options) {
228510
227855
  return this._runTask(stashListTask2(trailingOptionsArgument2(arguments) || {}, filterArray2(options) && options || []), trailingFunctionArgument2(arguments));
228511
227856
  };
228512
- function createCloneTask(api, task, repoPath, localPath2) {
227857
+ function createCloneTask(api, task, repoPath, localPath) {
228513
227858
  if (typeof repoPath !== "string") {
228514
227859
  return configurationErrorTask2(`git.${api}() requires a string 'repoPath'`);
228515
227860
  }
228516
- return task(repoPath, filterType2(localPath2, filterString2), getTrailingOptions2(arguments));
227861
+ return task(repoPath, filterType2(localPath, filterString2), getTrailingOptions2(arguments));
228517
227862
  }
228518
227863
  Git2.prototype.clone = function() {
228519
227864
  return this._runTask(createCloneTask("clone", cloneTask2, ...arguments), trailingFunctionArgument2(arguments));
@@ -231688,35 +231033,35 @@ class SchemaWorkerPool {
231688
231033
  }
231689
231034
  this.workerCurrentId.delete(index);
231690
231035
  }
231691
- logger.error("SchemaWorkerPool: worker errored, respawning", {
231036
+ logger.error("SchemaWorkerPool: worker errored", {
231692
231037
  workerIndex: index,
231693
231038
  error: err
231694
231039
  });
231695
- if (!this.stopped) {
231696
- this.workers[index] = this.spawn(index);
231697
- this.drain();
231698
- }
231699
231040
  });
231700
231041
  worker.on("exit", (code) => {
231701
231042
  if (this.stopped)
231702
231043
  return;
231044
+ const inFlightId = this.workerCurrentId.get(index);
231045
+ if (inFlightId !== undefined) {
231046
+ const req = this.inFlight.get(inFlightId);
231047
+ if (req) {
231048
+ this.inFlight.delete(inFlightId);
231049
+ req.reject(new Error(`SchemaWorker exited with code ${code}`));
231050
+ }
231051
+ this.workerCurrentId.delete(index);
231052
+ }
231703
231053
  if (code !== 0) {
231704
231054
  logger.warn("SchemaWorkerPool: worker exited unexpectedly", {
231705
231055
  workerIndex: index,
231706
231056
  code
231707
231057
  });
231708
- const inFlightId = this.workerCurrentId.get(index);
231709
- if (inFlightId !== undefined) {
231710
- const req = this.inFlight.get(inFlightId);
231711
- if (req) {
231712
- this.inFlight.delete(inFlightId);
231713
- req.reject(new Error(`SchemaWorker exited with code ${code}`));
231714
- }
231715
- this.workerCurrentId.delete(index);
231716
- }
231717
- this.workers[index] = this.spawn(index);
231718
- this.drain();
231058
+ } else {
231059
+ logger.info("SchemaWorkerPool: worker exited cleanly, respawning", {
231060
+ workerIndex: index
231061
+ });
231719
231062
  }
231063
+ this.workers[index] = this.spawn(index);
231064
+ this.drain();
231720
231065
  });
231721
231066
  return slot;
231722
231067
  }
@@ -233121,6 +232466,7 @@ class EnvironmentStore {
233121
232466
  return newEnvironment;
233122
232467
  }
233123
232468
  async unzipEnvironment(absoluteEnvironmentPath) {
232469
+ const startedAt = Date.now();
233124
232470
  logger.info(`Detected zip file at "${absoluteEnvironmentPath}". Unzipping...`);
233125
232471
  const unzippedEnvironmentPath = absoluteEnvironmentPath.replace(".zip", "");
233126
232472
  await fs7.promises.rm(unzippedEnvironmentPath, {
@@ -233128,8 +232474,17 @@ class EnvironmentStore {
233128
232474
  force: true
233129
232475
  });
233130
232476
  await fs7.promises.mkdir(unzippedEnvironmentPath, { recursive: true });
233131
- const zip = new import_adm_zip.default(absoluteEnvironmentPath);
233132
- zip.extractAllTo(unzippedEnvironmentPath, true);
232477
+ let entryCount = 0;
232478
+ let totalUncompressedBytes = 0;
232479
+ await import_extract_zip.default(absoluteEnvironmentPath, {
232480
+ dir: path10.resolve(unzippedEnvironmentPath),
232481
+ onEntry: (entry) => {
232482
+ entryCount += 1;
232483
+ totalUncompressedBytes += entry.uncompressedSize ?? 0;
232484
+ }
232485
+ });
232486
+ const mib = (totalUncompressedBytes / (1024 * 1024)).toFixed(1);
232487
+ logger.info(`Unzipped "${absoluteEnvironmentPath}" -> "${unzippedEnvironmentPath}" ` + `(${entryCount} entries, ${mib} MiB uncompressed) in ` + `${formatDuration(Date.now() - startedAt)}`);
233133
232488
  return unzippedEnvironmentPath;
233134
232489
  }
233135
232490
  async updateEnvironment(environment) {
@@ -233459,9 +232814,9 @@ class EnvironmentStore {
233459
232814
  }
233460
232815
  const file = fs7.createWriteStream(zipFilePath);
233461
232816
  item.Body.transformToWebStream().pipeTo(Writable.toWeb(file));
233462
- await new Promise((resolve4, reject) => {
232817
+ await new Promise((resolve5, reject) => {
233463
232818
  file.on("error", reject);
233464
- file.on("finish", resolve4);
232819
+ file.on("finish", resolve5);
233465
232820
  });
233466
232821
  await this.unzipEnvironment(zipFilePath);
233467
232822
  logger.info(`Downloaded S3 zip file ${s3Path} to ${absoluteDirPath}`);
@@ -233499,9 +232854,9 @@ class EnvironmentStore {
233499
232854
  }
233500
232855
  const file = fs7.createWriteStream(absoluteFilePath);
233501
232856
  item.Body.transformToWebStream().pipeTo(Writable.toWeb(file));
233502
- await new Promise((resolve4, reject) => {
232857
+ await new Promise((resolve5, reject) => {
233503
232858
  file.on("error", reject);
233504
- file.on("finish", resolve4);
232859
+ file.on("finish", resolve5);
233505
232860
  });
233506
232861
  }));
233507
232862
  logger.info(`Downloaded S3 directory ${s3Path} to ${absoluteDirPath}`);
@@ -233534,14 +232889,14 @@ class EnvironmentStore {
233534
232889
  });
233535
232890
  await fs7.promises.mkdir(absoluteDirPath, { recursive: true });
233536
232891
  const repoUrl = `https://github.com/${owner}/${repoName}`;
233537
- await new Promise((resolve4, reject) => {
232892
+ await new Promise((resolve5, reject) => {
233538
232893
  esm_default2().clone(repoUrl, absoluteDirPath, {}, (err) => {
233539
232894
  if (err) {
233540
232895
  const errorData = this.extractErrorDataFromError(err);
233541
232896
  logger.error(`Failed to clone GitHub repository "${repoUrl}"`, errorData);
233542
232897
  reject(err);
233543
232898
  }
233544
- resolve4();
232899
+ resolve5();
233545
232900
  });
233546
232901
  });
233547
232902
  if (!cleanPackagePath) {
@@ -233937,7 +233292,7 @@ class Protocol {
233937
233292
  }
233938
233293
  request(request, resultSchema, options) {
233939
233294
  const { relatedRequestId, resumptionToken, onresumptiontoken } = options !== null && options !== undefined ? options : {};
233940
- return new Promise((resolve4, reject) => {
233295
+ return new Promise((resolve5, reject) => {
233941
233296
  var _a2, _b, _c, _d, _e, _f;
233942
233297
  if (!this._transport) {
233943
233298
  reject(new Error("Not connected"));
@@ -233988,7 +233343,7 @@ class Protocol {
233988
233343
  }
233989
233344
  try {
233990
233345
  const result = resultSchema.parse(response.result);
233991
- resolve4(result);
233346
+ resolve5(result);
233992
233347
  } catch (error) {
233993
233348
  reject(error);
233994
233349
  }