@spzhongwin/skill-logger-plugin 1.0.17 → 1.0.18

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/index.js CHANGED
@@ -30,9 +30,28 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
30
30
  mod
31
31
  ));
32
32
 
33
- // node_modules/adm-zip/util/constants.js
33
+ // ../../node_modules/adm-zip/util/fileSystem.js
34
+ var require_fileSystem = __commonJS({
35
+ "../../node_modules/adm-zip/util/fileSystem.js"(exports) {
36
+ exports.require = function() {
37
+ var fs10 = __require("fs");
38
+ if (process.versions["electron"]) {
39
+ try {
40
+ originalFs = __require("original-fs");
41
+ if (Object.keys(originalFs).length > 0) {
42
+ fs10 = originalFs;
43
+ }
44
+ } catch (e) {
45
+ }
46
+ }
47
+ return fs10;
48
+ };
49
+ }
50
+ });
51
+
52
+ // ../../node_modules/adm-zip/util/constants.js
34
53
  var require_constants = __commonJS({
35
- "node_modules/adm-zip/util/constants.js"(exports, module) {
54
+ "../../node_modules/adm-zip/util/constants.js"(exports, module) {
36
55
  module.exports = {
37
56
  /* The local file header */
38
57
  LOCHDR: 30,
@@ -169,54 +188,45 @@ var require_constants = __commonJS({
169
188
  // reduced with compression factor 4
170
189
  IMPLODED: 6,
171
190
  // imploded
172
- // 7 reserved for Tokenizing compression algorithm
191
+ // 7 reserved
173
192
  DEFLATED: 8,
174
193
  // deflated
175
194
  ENHANCED_DEFLATED: 9,
176
195
  // enhanced deflated
177
196
  PKWARE: 10,
178
197
  // PKWare DCL imploded
179
- // 11 reserved by PKWARE
198
+ // 11 reserved
180
199
  BZIP2: 12,
181
200
  // compressed using BZIP2
182
- // 13 reserved by PKWARE
201
+ // 13 reserved
183
202
  LZMA: 14,
184
203
  // LZMA
185
- // 15-17 reserved by PKWARE
204
+ // 15-17 reserved
186
205
  IBM_TERSE: 18,
187
206
  // compressed using IBM TERSE
188
207
  IBM_LZ77: 19,
189
- // IBM LZ77 z
190
- AES_ENCRYPT: 99,
191
- // WinZIP AES encryption method
208
+ //IBM LZ77 z
192
209
  /* General purpose bit flag */
193
- // values can obtained with expression 2**bitnr
194
- FLG_ENC: 1,
195
- // Bit 0: encrypted file
196
- FLG_COMP1: 2,
197
- // Bit 1, compression option
198
- FLG_COMP2: 4,
199
- // Bit 2, compression option
200
- FLG_DESC: 8,
201
- // Bit 3, data descriptor
202
- FLG_ENH: 16,
203
- // Bit 4, enhanced deflating
204
- FLG_PATCH: 32,
205
- // Bit 5, indicates that the file is compressed patched data.
206
- FLG_STR: 64,
207
- // Bit 6, strong encryption (patented)
208
- // Bits 7-10: Currently unused.
209
- FLG_EFS: 2048,
210
- // Bit 11: Language encoding flag (EFS)
211
- // Bit 12: Reserved by PKWARE for enhanced compression.
212
- // Bit 13: encrypted the Central Directory (patented).
213
- // Bits 14-15: Reserved by PKWARE.
210
+ FLG_ENC: 0,
211
+ // encripted file
212
+ FLG_COMP1: 1,
213
+ // compression option
214
+ FLG_COMP2: 2,
215
+ // compression option
216
+ FLG_DESC: 4,
217
+ // data descriptor
218
+ FLG_ENH: 8,
219
+ // enhanced deflation
220
+ FLG_STR: 16,
221
+ // strong encryption
222
+ FLG_LNG: 1024,
223
+ // language encoding
214
224
  FLG_MSK: 4096,
215
225
  // mask header values
216
226
  /* Load type */
217
- FILE: 2,
227
+ FILE: 0,
218
228
  BUFFER: 1,
219
- NONE: 0,
229
+ NONE: 2,
220
230
  /* 4.5 Extensible data fields */
221
231
  EF_ID: 0,
222
232
  EF_SIZE: 2,
@@ -249,370 +259,243 @@ var require_constants = __commonJS({
249
259
  }
250
260
  });
251
261
 
252
- // node_modules/adm-zip/util/errors.js
262
+ // ../../node_modules/adm-zip/util/errors.js
253
263
  var require_errors = __commonJS({
254
- "node_modules/adm-zip/util/errors.js"(exports) {
255
- var errors = {
264
+ "../../node_modules/adm-zip/util/errors.js"(exports, module) {
265
+ module.exports = {
256
266
  /* Header error messages */
257
- INVALID_LOC: "Invalid LOC header (bad signature)",
258
- INVALID_CEN: "Invalid CEN header (bad signature)",
259
- INVALID_END: "Invalid END header (bad signature)",
260
- /* Descriptor */
261
- DESCRIPTOR_NOT_EXIST: "No descriptor present",
262
- DESCRIPTOR_UNKNOWN: "Unknown descriptor format",
263
- DESCRIPTOR_FAULTY: "Descriptor data is malformed",
267
+ "INVALID_LOC": "Invalid LOC header (bad signature)",
268
+ "INVALID_CEN": "Invalid CEN header (bad signature)",
269
+ "INVALID_END": "Invalid END header (bad signature)",
264
270
  /* ZipEntry error messages*/
265
- NO_DATA: "Nothing to decompress",
266
- BAD_CRC: "CRC32 checksum failed {0}",
267
- FILE_IN_THE_WAY: "There is a file in the way: {0}",
268
- UNKNOWN_METHOD: "Invalid/unsupported compression method",
271
+ "NO_DATA": "Nothing to decompress",
272
+ "BAD_CRC": "CRC32 checksum failed",
273
+ "FILE_IN_THE_WAY": "There is a file in the way: %s",
274
+ "UNKNOWN_METHOD": "Invalid/unsupported compression method",
269
275
  /* Inflater error messages */
270
- AVAIL_DATA: "inflate::Available inflate data did not terminate",
271
- INVALID_DISTANCE: "inflate::Invalid literal/length or distance code in fixed or dynamic block",
272
- TO_MANY_CODES: "inflate::Dynamic block code description: too many length or distance codes",
273
- INVALID_REPEAT_LEN: "inflate::Dynamic block code description: repeat more than specified lengths",
274
- INVALID_REPEAT_FIRST: "inflate::Dynamic block code description: repeat lengths with no first length",
275
- INCOMPLETE_CODES: "inflate::Dynamic block code description: code lengths codes incomplete",
276
- INVALID_DYN_DISTANCE: "inflate::Dynamic block code description: invalid distance code lengths",
277
- INVALID_CODES_LEN: "inflate::Dynamic block code description: invalid literal/length code lengths",
278
- INVALID_STORE_BLOCK: "inflate::Stored block length did not match one's complement",
279
- INVALID_BLOCK_TYPE: "inflate::Invalid block type (type == 3)",
276
+ "AVAIL_DATA": "inflate::Available inflate data did not terminate",
277
+ "INVALID_DISTANCE": "inflate::Invalid literal/length or distance code in fixed or dynamic block",
278
+ "TO_MANY_CODES": "inflate::Dynamic block code description: too many length or distance codes",
279
+ "INVALID_REPEAT_LEN": "inflate::Dynamic block code description: repeat more than specified lengths",
280
+ "INVALID_REPEAT_FIRST": "inflate::Dynamic block code description: repeat lengths with no first length",
281
+ "INCOMPLETE_CODES": "inflate::Dynamic block code description: code lengths codes incomplete",
282
+ "INVALID_DYN_DISTANCE": "inflate::Dynamic block code description: invalid distance code lengths",
283
+ "INVALID_CODES_LEN": "inflate::Dynamic block code description: invalid literal/length code lengths",
284
+ "INVALID_STORE_BLOCK": "inflate::Stored block length did not match one's complement",
285
+ "INVALID_BLOCK_TYPE": "inflate::Invalid block type (type == 3)",
280
286
  /* ADM-ZIP error messages */
281
- CANT_EXTRACT_FILE: "Could not extract the file",
282
- CANT_OVERRIDE: "Target file already exists",
283
- DISK_ENTRY_TOO_LARGE: "Number of disk entries is too large",
284
- NO_ZIP: "No zip file was loaded",
285
- NO_ENTRY: "Entry doesn't exist",
286
- DIRECTORY_CONTENT_ERROR: "A directory cannot have content",
287
- FILE_NOT_FOUND: 'File not found: "{0}"',
288
- NOT_IMPLEMENTED: "Not implemented",
289
- INVALID_FILENAME: "Invalid filename",
290
- INVALID_FORMAT: "Invalid or unsupported zip format. No END header found",
291
- INVALID_PASS_PARAM: "Incompatible password parameter",
292
- WRONG_PASSWORD: "Wrong Password",
293
- /* ADM-ZIP */
294
- COMMENT_TOO_LONG: "Comment is too long",
295
- // Comment can be max 65535 bytes long (NOTE: some non-US characters may take more space)
296
- EXTRA_FIELD_PARSE_ERROR: "Extra field parsing error"
287
+ "CANT_EXTRACT_FILE": "Could not extract the file",
288
+ "CANT_OVERRIDE": "Target file already exists",
289
+ "NO_ZIP": "No zip file was loaded",
290
+ "NO_ENTRY": "Entry doesn't exist",
291
+ "DIRECTORY_CONTENT_ERROR": "A directory cannot have content",
292
+ "FILE_NOT_FOUND": "File not found: %s",
293
+ "NOT_IMPLEMENTED": "Not implemented",
294
+ "INVALID_FILENAME": "Invalid filename",
295
+ "INVALID_FORMAT": "Invalid or unsupported zip format. No END header found"
297
296
  };
298
- function E(message) {
299
- return function(...args) {
300
- if (args.length) {
301
- message = message.replace(/\{(\d)\}/g, (_, n) => args[n] || "");
302
- }
303
- return new Error("ADM-ZIP: " + message);
304
- };
305
- }
306
- for (const msg of Object.keys(errors)) {
307
- exports[msg] = E(errors[msg]);
308
- }
309
297
  }
310
298
  });
311
299
 
312
- // node_modules/adm-zip/util/utils.js
300
+ // ../../node_modules/adm-zip/util/utils.js
313
301
  var require_utils = __commonJS({
314
- "node_modules/adm-zip/util/utils.js"(exports, module) {
315
- var fsystem = __require("fs");
302
+ "../../node_modules/adm-zip/util/utils.js"(exports, module) {
303
+ var fs10 = require_fileSystem().require();
316
304
  var pth = __require("path");
317
- var Constants = require_constants();
318
- var Errors = require_errors();
319
- var isWin = typeof process === "object" && "win32" === process.platform;
320
- var is_Obj = (obj) => typeof obj === "object" && obj !== null;
321
- var crcTable = new Uint32Array(256).map((t, c) => {
322
- for (let k = 0; k < 8; k++) {
323
- if ((c & 1) !== 0) {
324
- c = 3988292384 ^ c >>> 1;
325
- } else {
326
- c >>>= 1;
327
- }
328
- }
329
- return c >>> 0;
330
- });
331
- function Utils(opts) {
332
- this.sep = pth.sep;
333
- this.fs = fsystem;
334
- if (is_Obj(opts)) {
335
- if (is_Obj(opts.fs) && typeof opts.fs.statSync === "function") {
336
- this.fs = opts.fs;
337
- }
338
- }
339
- }
340
- module.exports = Utils;
341
- Utils.prototype.makeDir = function(folder) {
342
- const self = this;
343
- function mkdirSync(fpath) {
344
- let resolvedPath = fpath.split(self.sep)[0];
345
- fpath.split(self.sep).forEach(function(name) {
305
+ fs10.existsSync = fs10.existsSync || pth.existsSync;
306
+ module.exports = (function() {
307
+ var crcTable = [], Constants = require_constants(), Errors = require_errors(), PATH_SEPARATOR = pth.sep;
308
+ function mkdirSync(path12) {
309
+ var resolvedPath = path12.split(PATH_SEPARATOR)[0];
310
+ path12.split(PATH_SEPARATOR).forEach(function(name) {
346
311
  if (!name || name.substr(-1, 1) === ":") return;
347
- resolvedPath += self.sep + name;
312
+ resolvedPath += PATH_SEPARATOR + name;
348
313
  var stat;
349
314
  try {
350
- stat = self.fs.statSync(resolvedPath);
315
+ stat = fs10.statSync(resolvedPath);
351
316
  } catch (e) {
352
- if (e.message && e.message.startsWith("ENOENT")) {
353
- self.fs.mkdirSync(resolvedPath);
354
- } else {
355
- throw e;
356
- }
317
+ fs10.mkdirSync(resolvedPath);
357
318
  }
358
- if (stat && stat.isFile()) throw Errors.FILE_IN_THE_WAY(`"${resolvedPath}"`);
319
+ if (stat && stat.isFile())
320
+ throw Errors.FILE_IN_THE_WAY.replace("%s", resolvedPath);
359
321
  });
360
322
  }
361
- mkdirSync(folder);
362
- };
363
- Utils.prototype.writeFileTo = function(path12, content, overwrite, attr) {
364
- const self = this;
365
- if (self.fs.existsSync(path12)) {
366
- if (!overwrite) return false;
367
- var stat = self.fs.statSync(path12);
368
- if (stat.isDirectory()) {
369
- return false;
370
- }
371
- }
372
- var folder = pth.dirname(path12);
373
- if (!self.fs.existsSync(folder)) {
374
- self.makeDir(folder);
375
- }
376
- var fd;
377
- try {
378
- fd = self.fs.openSync(path12, "w", 438);
379
- } catch (e) {
380
- self.fs.chmodSync(path12, 438);
381
- fd = self.fs.openSync(path12, "w", 438);
382
- }
383
- if (fd) {
384
- try {
385
- self.fs.writeSync(fd, content, 0, content.length, 0);
386
- } finally {
387
- self.fs.closeSync(fd);
323
+ function findSync(dir, pattern, recoursive) {
324
+ if (typeof pattern === "boolean") {
325
+ recoursive = pattern;
326
+ pattern = void 0;
388
327
  }
328
+ var files = [];
329
+ fs10.readdirSync(dir).forEach(function(file) {
330
+ var path12 = pth.join(dir, file);
331
+ if (fs10.statSync(path12).isDirectory() && recoursive)
332
+ files = files.concat(findSync(path12, pattern, recoursive));
333
+ if (!pattern || pattern.test(path12)) {
334
+ files.push(pth.normalize(path12) + (fs10.statSync(path12).isDirectory() ? PATH_SEPARATOR : ""));
335
+ }
336
+ });
337
+ return files;
389
338
  }
390
- self.fs.chmodSync(path12, attr || 438);
391
- return true;
392
- };
393
- Utils.prototype.writeFileToAsync = function(path12, content, overwrite, attr, callback) {
394
- if (typeof attr === "function") {
395
- callback = attr;
396
- attr = void 0;
339
+ function readBigUInt64LE(buffer, index) {
340
+ var slice = Buffer.from(buffer.slice(index, index + 8));
341
+ slice.swap64();
342
+ return parseInt(`0x${slice.toString("hex")}`);
397
343
  }
398
- const self = this;
399
- self.fs.exists(path12, function(exist) {
400
- if (exist && !overwrite) return callback(false);
401
- self.fs.stat(path12, function(err, stat) {
402
- if (exist && stat && stat.isDirectory()) {
403
- return callback(false);
344
+ return {
345
+ makeDir: function(path12) {
346
+ mkdirSync(path12);
347
+ },
348
+ crc32: function(buf) {
349
+ if (typeof buf === "string") {
350
+ buf = Buffer.alloc(buf.length, buf);
404
351
  }
405
- var folder = pth.dirname(path12);
406
- self.fs.exists(folder, function(exists) {
407
- if (!exists) {
408
- try {
409
- self.makeDir(folder);
410
- } catch (e) {
411
- return callback(false);
352
+ var b = Buffer.alloc(4);
353
+ if (!crcTable.length) {
354
+ for (var n = 0; n < 256; n++) {
355
+ var c = n;
356
+ for (var k = 8; --k >= 0; )
357
+ if ((c & 1) !== 0) {
358
+ c = 3988292384 ^ c >>> 1;
359
+ } else {
360
+ c = c >>> 1;
361
+ }
362
+ if (c < 0) {
363
+ b.writeInt32LE(c, 0);
364
+ c = b.readUInt32LE(0);
412
365
  }
366
+ crcTable[n] = c;
413
367
  }
414
- const writeToFd = function(fd) {
415
- self.fs.write(fd, content, 0, content.length, 0, function(writeErr) {
416
- self.fs.close(fd, function() {
417
- if (writeErr) return callback(false);
418
- self.fs.chmod(path12, attr || 438, function() {
419
- callback(true);
420
- });
421
- });
422
- });
423
- };
424
- self.fs.open(path12, "w", 438, function(err2, fd) {
425
- if (err2) {
426
- self.fs.chmod(path12, 438, function() {
427
- self.fs.open(path12, "w", 438, function(retryErr, fd2) {
428
- if (retryErr || !fd2) return callback(false);
429
- writeToFd(fd2);
430
- });
431
- });
432
- } else if (fd) {
433
- writeToFd(fd);
434
- } else {
435
- callback(false);
436
- }
437
- });
438
- });
439
- });
440
- });
441
- };
442
- Utils.prototype.findFiles = function(path12) {
443
- const self = this;
444
- function findSync(dir, pattern, recursive, visited) {
445
- if (typeof pattern === "boolean") {
446
- recursive = pattern;
447
- pattern = void 0;
448
- }
449
- let files = [];
450
- self.fs.readdirSync(dir).forEach(function(file) {
451
- const path13 = pth.join(dir, file);
452
- const stat = self.fs.statSync(path13);
453
- if (!pattern || pattern.test(path13)) {
454
- files.push(pth.normalize(path13) + (stat.isDirectory() ? self.sep : ""));
455
368
  }
456
- if (stat.isDirectory() && recursive) {
457
- const realDir = self.fs.realpathSync(path13);
458
- if (!visited.has(realDir)) {
459
- visited.add(realDir);
460
- files = files.concat(findSync(path13, pattern, recursive, visited));
369
+ var crc = 0, off = 0, len = buf.length, c1 = ~crc;
370
+ while (--len >= 0) c1 = crcTable[(c1 ^ buf[off++]) & 255] ^ c1 >>> 8;
371
+ crc = ~c1;
372
+ b.writeInt32LE(crc & 4294967295, 0);
373
+ return b.readUInt32LE(0);
374
+ },
375
+ methodToString: function(method) {
376
+ switch (method) {
377
+ case Constants.STORED:
378
+ return "STORED (" + method + ")";
379
+ case Constants.DEFLATED:
380
+ return "DEFLATED (" + method + ")";
381
+ default:
382
+ return "UNSUPPORTED (" + method + ")";
383
+ }
384
+ },
385
+ writeFileTo: function(path12, content, overwrite, attr) {
386
+ if (fs10.existsSync(path12)) {
387
+ if (!overwrite)
388
+ return false;
389
+ var stat = fs10.statSync(path12);
390
+ if (stat.isDirectory()) {
391
+ return false;
461
392
  }
462
393
  }
463
- });
464
- return files;
465
- }
466
- return findSync(path12, void 0, true, /* @__PURE__ */ new Set([self.fs.realpathSync(path12)]));
467
- };
468
- Utils.prototype.findFilesAsync = function(dir, cb) {
469
- const self = this;
470
- const results = [];
471
- let finished = false;
472
- const finish = function(err) {
473
- if (finished) return;
474
- finished = true;
475
- cb(err, err ? void 0 : results);
476
- };
477
- const walk = function(dir2, visited, done) {
478
- self.fs.readdir(dir2, function(err, list) {
479
- if (err) return done(err);
480
- let pending = list.length;
481
- if (!pending) return done();
482
- list.forEach(function(name) {
483
- const file = pth.join(dir2, name);
484
- self.fs.stat(file, function(err2, stat) {
485
- if (err2) return done(err2);
486
- if (!stat) {
487
- if (!--pending) done();
488
- return;
489
- }
490
- results.push(pth.normalize(file) + (stat.isDirectory() ? self.sep : ""));
491
- if (!stat.isDirectory()) {
492
- if (!--pending) done();
493
- return;
394
+ var folder = pth.dirname(path12);
395
+ if (!fs10.existsSync(folder)) {
396
+ mkdirSync(folder);
397
+ }
398
+ var fd;
399
+ try {
400
+ fd = fs10.openSync(path12, "w", 438);
401
+ } catch (e) {
402
+ fs10.chmodSync(path12, 438);
403
+ fd = fs10.openSync(path12, "w", 438);
404
+ }
405
+ if (fd) {
406
+ try {
407
+ fs10.writeSync(fd, content, 0, content.length, 0);
408
+ } catch (e) {
409
+ throw e;
410
+ } finally {
411
+ fs10.closeSync(fd);
412
+ }
413
+ }
414
+ fs10.chmodSync(path12, attr || 438);
415
+ return true;
416
+ },
417
+ writeFileToAsync: function(path12, content, overwrite, attr, callback) {
418
+ if (typeof attr === "function") {
419
+ callback = attr;
420
+ attr = void 0;
421
+ }
422
+ fs10.exists(path12, function(exists) {
423
+ if (exists && !overwrite)
424
+ return callback(false);
425
+ fs10.stat(path12, function(err, stat) {
426
+ if (exists && stat.isDirectory()) {
427
+ return callback(false);
494
428
  }
495
- self.fs.realpath(file, function(err3, realDir) {
496
- if (err3) return done(err3);
497
- if (visited.has(realDir)) {
498
- if (!--pending) done();
499
- return;
500
- }
501
- visited.add(realDir);
502
- walk(file, visited, function(err4) {
503
- if (err4) return done(err4);
504
- if (!--pending) done();
429
+ var folder = pth.dirname(path12);
430
+ fs10.exists(folder, function(exists2) {
431
+ if (!exists2)
432
+ mkdirSync(folder);
433
+ fs10.open(path12, "w", 438, function(err2, fd) {
434
+ if (err2) {
435
+ fs10.chmod(path12, 438, function() {
436
+ fs10.open(path12, "w", 438, function(err3, fd2) {
437
+ fs10.write(fd2, content, 0, content.length, 0, function() {
438
+ fs10.close(fd2, function() {
439
+ fs10.chmod(path12, attr || 438, function() {
440
+ callback(true);
441
+ });
442
+ });
443
+ });
444
+ });
445
+ });
446
+ } else {
447
+ if (fd) {
448
+ fs10.write(fd, content, 0, content.length, 0, function() {
449
+ fs10.close(fd, function() {
450
+ fs10.chmod(path12, attr || 438, function() {
451
+ callback(true);
452
+ });
453
+ });
454
+ });
455
+ } else {
456
+ fs10.chmod(path12, attr || 438, function() {
457
+ callback(true);
458
+ });
459
+ }
460
+ }
505
461
  });
506
462
  });
507
463
  });
508
464
  });
509
- });
465
+ },
466
+ findFiles: function(path12) {
467
+ return findSync(path12, true);
468
+ },
469
+ getAttributes: function(path12) {
470
+ },
471
+ setAttributes: function(path12) {
472
+ },
473
+ toBuffer: function(input) {
474
+ if (Buffer.isBuffer(input)) {
475
+ return input;
476
+ } else {
477
+ if (input.length === 0) {
478
+ return Buffer.alloc(0);
479
+ }
480
+ return Buffer.from(input, "utf8");
481
+ }
482
+ },
483
+ readBigUInt64LE,
484
+ Constants,
485
+ Errors
510
486
  };
511
- self.fs.realpath(dir, function(err, realDir) {
512
- if (err) return finish(err);
513
- walk(dir, /* @__PURE__ */ new Set([realDir]), finish);
514
- });
515
- };
516
- Utils.prototype.getAttributes = function() {
517
- };
518
- Utils.prototype.setAttributes = function() {
519
- };
520
- Utils.crc32update = function(crc, byte) {
521
- return crcTable[(crc ^ byte) & 255] ^ crc >>> 8;
522
- };
523
- Utils.crc32 = function(buf) {
524
- if (typeof buf === "string") {
525
- buf = Buffer.from(buf, "utf8");
526
- }
527
- let len = buf.length;
528
- let crc = ~0;
529
- for (let off = 0; off < len; ) crc = Utils.crc32update(crc, buf[off++]);
530
- return ~crc >>> 0;
531
- };
532
- Utils.methodToString = function(method) {
533
- switch (method) {
534
- case Constants.STORED:
535
- return "STORED (" + method + ")";
536
- case Constants.DEFLATED:
537
- return "DEFLATED (" + method + ")";
538
- default:
539
- return "UNSUPPORTED (" + method + ")";
540
- }
541
- };
542
- Utils.canonical = function(path12) {
543
- if (!path12) return "";
544
- const safeSuffix = pth.posix.normalize("/" + path12.split("\\").join("/"));
545
- return pth.join(".", safeSuffix);
546
- };
547
- Utils.zipnamefix = function(path12) {
548
- if (!path12) return "";
549
- const safeSuffix = pth.posix.normalize("/" + path12.split("\\").join("/"));
550
- return pth.posix.join(".", safeSuffix);
551
- };
552
- Utils.findLast = function(arr, callback) {
553
- if (!Array.isArray(arr)) throw new TypeError("arr is not array");
554
- const len = arr.length >>> 0;
555
- for (let i = len - 1; i >= 0; i--) {
556
- if (callback(arr[i], i, arr)) {
557
- return arr[i];
558
- }
559
- }
560
- return void 0;
561
- };
562
- Utils.sanitize = function(prefix, name) {
563
- prefix = pth.resolve(pth.normalize(prefix));
564
- var parts = name.split("/");
565
- for (var i = 0, l = parts.length; i < l; i++) {
566
- var path12 = pth.normalize(pth.join(prefix, parts.slice(i, l).join(pth.sep)));
567
- if (path12 === prefix || path12.startsWith(prefix + pth.sep)) {
568
- return path12;
569
- }
570
- }
571
- return pth.normalize(pth.join(prefix, pth.basename(name)));
572
- };
573
- Utils.toBuffer = function toBuffer(input, encoder) {
574
- if (Buffer.isBuffer(input)) {
575
- return input;
576
- } else if (input instanceof Uint8Array) {
577
- return Buffer.from(input);
578
- } else {
579
- return typeof input === "string" ? encoder(input) : Buffer.alloc(0);
580
- }
581
- };
582
- Utils.readBigUInt64LE = function(buffer, index) {
583
- const lo = buffer.readUInt32LE(index);
584
- const hi = buffer.readUInt32LE(index + 4);
585
- return hi * 4294967296 + lo;
586
- };
587
- Utils.writeBigUInt64LE = function(buffer, value, index) {
588
- const lo = value >>> 0;
589
- const hi = Math.floor(value / 4294967296) >>> 0;
590
- buffer.writeUInt32LE(lo, index);
591
- buffer.writeUInt32LE(hi, index + 4);
592
- };
593
- Utils.fromDOS2Date = function(val) {
594
- 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);
595
- };
596
- Utils.fromDate2DOS = function(val) {
597
- let date = 0;
598
- let time = 0;
599
- if (val.getFullYear() > 1979) {
600
- date = (val.getFullYear() - 1980 & 127) << 9 | val.getMonth() + 1 << 5 | val.getDate();
601
- time = val.getHours() << 11 | val.getMinutes() << 5 | val.getSeconds() >> 1;
602
- }
603
- return date << 16 | time;
604
- };
605
- Utils.isWin = isWin;
606
- Utils.crcTable = crcTable;
487
+ })();
607
488
  }
608
489
  });
609
490
 
610
- // node_modules/adm-zip/util/fattr.js
491
+ // ../../node_modules/adm-zip/util/fattr.js
611
492
  var require_fattr = __commonJS({
612
- "node_modules/adm-zip/util/fattr.js"(exports, module) {
493
+ "../../node_modules/adm-zip/util/fattr.js"(exports, module) {
494
+ var fs10 = require_fileSystem().require();
613
495
  var pth = __require("path");
614
- module.exports = function(path12, { fs: fs10 }) {
615
- var _path = path12 || "", _obj = newAttr(), _stat = null;
496
+ fs10.existsSync = fs10.existsSync || pth.existsSync;
497
+ module.exports = function(path12) {
498
+ var _path = path12 || "", _permissions = 0, _obj = newAttr(), _stat = null;
616
499
  function newAttr() {
617
500
  return {
618
501
  directory: false,
@@ -628,8 +511,8 @@ var require_fattr = __commonJS({
628
511
  _obj.directory = _stat.isDirectory();
629
512
  _obj.mtime = _stat.mtime;
630
513
  _obj.atime = _stat.atime;
631
- _obj.executable = (73 & _stat.mode) !== 0;
632
- _obj.readonly = (128 & _stat.mode) === 0;
514
+ _obj.executable = !!(1 & parseInt((_stat.mode & parseInt("777", 8)).toString(8)[0]));
515
+ _obj.readonly = !!(2 & parseInt((_stat.mode & parseInt("777", 8)).toString(8)[0]));
633
516
  _obj.hidden = pth.basename(_path)[0] === ".";
634
517
  } else {
635
518
  console.warn("Invalid path: " + _path);
@@ -653,67 +536,42 @@ var require_fattr = __commonJS({
653
536
  get executable() {
654
537
  return _obj.executable;
655
538
  },
656
- decodeAttributes: function() {
539
+ decodeAttributes: function(val) {
657
540
  },
658
- encodeAttributes: function() {
659
- },
660
- toJSON: function() {
661
- return {
662
- path: _path,
663
- isDirectory: _obj.directory,
664
- isReadOnly: _obj.readonly,
665
- isHidden: _obj.hidden,
666
- isExecutable: _obj.executable,
667
- mTime: _obj.mtime,
668
- aTime: _obj.atime
669
- };
541
+ encodeAttributes: function(val) {
670
542
  },
671
543
  toString: function() {
672
- return JSON.stringify(this.toJSON(), null, " ");
544
+ return '{\n "path" : "' + _path + ',\n "isDirectory" : ' + _obj.directory + ',\n "isReadOnly" : ' + _obj.readonly + ',\n "isHidden" : ' + _obj.hidden + ',\n "isExecutable" : ' + _obj.executable + ',\n "mTime" : ' + _obj.mtime + '\n "aTime" : ' + _obj.atime + "\n}";
673
545
  }
674
546
  };
675
547
  };
676
548
  }
677
549
  });
678
550
 
679
- // node_modules/adm-zip/util/decoder.js
680
- var require_decoder = __commonJS({
681
- "node_modules/adm-zip/util/decoder.js"(exports, module) {
682
- module.exports = {
683
- efs: true,
684
- encode: (data) => Buffer.from(data, "utf8"),
685
- decode: (data) => data.toString("utf8")
686
- };
687
- }
688
- });
689
-
690
- // node_modules/adm-zip/util/index.js
551
+ // ../../node_modules/adm-zip/util/index.js
691
552
  var require_util = __commonJS({
692
- "node_modules/adm-zip/util/index.js"(exports, module) {
553
+ "../../node_modules/adm-zip/util/index.js"(exports, module) {
693
554
  module.exports = require_utils();
555
+ module.exports.FileSystem = require_fileSystem();
694
556
  module.exports.Constants = require_constants();
695
557
  module.exports.Errors = require_errors();
696
558
  module.exports.FileAttr = require_fattr();
697
- module.exports.decoder = require_decoder();
698
559
  }
699
560
  });
700
561
 
701
- // node_modules/adm-zip/headers/entryHeader.js
562
+ // ../../node_modules/adm-zip/headers/entryHeader.js
702
563
  var require_entryHeader = __commonJS({
703
- "node_modules/adm-zip/headers/entryHeader.js"(exports, module) {
564
+ "../../node_modules/adm-zip/headers/entryHeader.js"(exports, module) {
704
565
  var Utils = require_util();
705
566
  var Constants = Utils.Constants;
706
567
  module.exports = function() {
707
- 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;
708
- _verMade |= Utils.isWin ? 2560 : 768;
709
- _flags |= Constants.FLG_EFS;
710
- const _localHeader = {
711
- extraLen: 0
712
- };
713
- const uint32 = (val) => Math.max(0, val) >>> 0;
714
- const uint16 = (val) => Math.max(0, val) & 65535;
715
- const uint8 = (val) => Math.max(0, val) & 255;
716
- _time = Utils.fromDate2DOS(/* @__PURE__ */ new Date());
568
+ var _verMade = 10, _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;
569
+ var _dataHeader = {};
570
+ function setTime(val) {
571
+ val = new Date(val);
572
+ _time = (val.getFullYear() - 1980 & 127) << 25 | val.getMonth() + 1 << 21 | val.getDate() << 16 | val.getHours() << 11 | val.getMinutes() << 5 | val.getSeconds() >> 1;
573
+ }
574
+ setTime(+/* @__PURE__ */ new Date());
717
575
  return {
718
576
  get made() {
719
577
  return _verMade;
@@ -733,73 +591,42 @@ var require_entryHeader = __commonJS({
733
591
  set flags(val) {
734
592
  _flags = val;
735
593
  },
736
- get flags_efs() {
737
- return (_flags & Constants.FLG_EFS) > 0;
738
- },
739
- set flags_efs(val) {
740
- if (val) {
741
- _flags |= Constants.FLG_EFS;
742
- } else {
743
- _flags &= ~Constants.FLG_EFS;
744
- }
745
- },
746
- get flags_desc() {
747
- return (_flags & Constants.FLG_DESC) > 0;
748
- },
749
- set flags_desc(val) {
750
- if (val) {
751
- _flags |= Constants.FLG_DESC;
752
- } else {
753
- _flags &= ~Constants.FLG_DESC;
754
- }
755
- },
756
594
  get method() {
757
595
  return _method;
758
596
  },
759
597
  set method(val) {
760
- switch (val) {
761
- case Constants.STORED:
762
- this.version = 10;
763
- break;
764
- case Constants.DEFLATED:
765
- default:
766
- this.version = 20;
767
- }
768
598
  _method = val;
769
599
  },
770
600
  get time() {
771
- return Utils.fromDOS2Date(this.timeval);
601
+ return new Date(
602
+ (_time >> 25 & 127) + 1980,
603
+ (_time >> 21 & 15) - 1,
604
+ _time >> 16 & 31,
605
+ _time >> 11 & 31,
606
+ _time >> 5 & 63,
607
+ (_time & 31) << 1
608
+ );
772
609
  },
773
610
  set time(val) {
774
- val = new Date(val);
775
- this.timeval = Utils.fromDate2DOS(val);
776
- },
777
- get timeval() {
778
- return _time;
779
- },
780
- set timeval(val) {
781
- _time = uint32(val);
782
- },
783
- get timeHighByte() {
784
- return uint8(_time >>> 8);
611
+ setTime(val);
785
612
  },
786
613
  get crc() {
787
614
  return _crc;
788
615
  },
789
616
  set crc(val) {
790
- _crc = uint32(val);
617
+ _crc = val;
791
618
  },
792
619
  get compressedSize() {
793
620
  return _compressedSize;
794
621
  },
795
622
  set compressedSize(val) {
796
- _compressedSize = uint32(val);
623
+ _compressedSize = val;
797
624
  },
798
625
  get size() {
799
626
  return _size;
800
627
  },
801
628
  set size(val) {
802
- _size = uint32(val);
629
+ _size = val;
803
630
  },
804
631
  get fileNameLength() {
805
632
  return _fnameLen;
@@ -813,12 +640,6 @@ var require_entryHeader = __commonJS({
813
640
  set extraLength(val) {
814
641
  _extraLen = val;
815
642
  },
816
- get extraLocalLength() {
817
- return _localHeader.extraLen;
818
- },
819
- set extraLocalLength(val) {
820
- _localHeader.extraLen = val;
821
- },
822
643
  get commentLength() {
823
644
  return _comLen;
824
645
  },
@@ -829,64 +650,67 @@ var require_entryHeader = __commonJS({
829
650
  return _diskStart;
830
651
  },
831
652
  set diskNumStart(val) {
832
- _diskStart = uint32(val);
653
+ _diskStart = val;
833
654
  },
834
655
  get inAttr() {
835
656
  return _inattr;
836
657
  },
837
658
  set inAttr(val) {
838
- _inattr = uint32(val);
659
+ _inattr = val;
839
660
  },
840
661
  get attr() {
841
662
  return _attr;
842
663
  },
843
664
  set attr(val) {
844
- _attr = uint32(val);
845
- },
846
- // get Unix file permissions
847
- get fileAttr() {
848
- return (_attr || 0) >> 16 & 4095;
665
+ _attr = val;
849
666
  },
850
667
  get offset() {
851
668
  return _offset;
852
669
  },
853
670
  set offset(val) {
854
- _offset = uint32(val);
671
+ _offset = val;
855
672
  },
856
- get encrypted() {
857
- return (_flags & Constants.FLG_ENC) === Constants.FLG_ENC;
673
+ get encripted() {
674
+ return (_flags & 1) === 1;
858
675
  },
859
- get centralHeaderSize() {
676
+ get entryHeaderSize() {
860
677
  return Constants.CENHDR + _fnameLen + _extraLen + _comLen;
861
678
  },
862
679
  get realDataOffset() {
863
- return _offset + Constants.LOCHDR + _localHeader.fnameLen + _localHeader.extraLen;
680
+ return _offset + Constants.LOCHDR + _dataHeader.fnameLen + _dataHeader.extraLen;
864
681
  },
865
- get localHeader() {
866
- return _localHeader;
682
+ get dataHeader() {
683
+ return _dataHeader;
867
684
  },
868
- loadLocalHeaderFromBinary: function(input) {
685
+ loadDataHeaderFromBinary: function(input) {
869
686
  var data = input.slice(_offset, _offset + Constants.LOCHDR);
870
687
  if (data.readUInt32LE(0) !== Constants.LOCSIG) {
871
- throw Utils.Errors.INVALID_LOC();
688
+ throw new Error(Utils.Errors.INVALID_LOC);
872
689
  }
873
- _localHeader.version = data.readUInt16LE(Constants.LOCVER);
874
- _localHeader.flags = data.readUInt16LE(Constants.LOCFLG);
875
- _localHeader.flags_desc = (_localHeader.flags & Constants.FLG_DESC) > 0;
876
- _localHeader.method = data.readUInt16LE(Constants.LOCHOW);
877
- _localHeader.time = data.readUInt32LE(Constants.LOCTIM);
878
- _localHeader.crc = data.readUInt32LE(Constants.LOCCRC);
879
- _localHeader.compressedSize = data.readUInt32LE(Constants.LOCSIZ);
880
- _localHeader.size = data.readUInt32LE(Constants.LOCLEN);
881
- _localHeader.fnameLen = data.readUInt16LE(Constants.LOCNAM);
882
- _localHeader.extraLen = data.readUInt16LE(Constants.LOCEXT);
883
- const extraStart = _offset + Constants.LOCHDR + _localHeader.fnameLen;
884
- const extraEnd = extraStart + _localHeader.extraLen;
885
- return input.slice(extraStart, extraEnd);
690
+ _dataHeader = {
691
+ // version needed to extract
692
+ version: data.readUInt16LE(Constants.LOCVER),
693
+ // general purpose bit flag
694
+ flags: data.readUInt16LE(Constants.LOCFLG),
695
+ // compression method
696
+ method: data.readUInt16LE(Constants.LOCHOW),
697
+ // modification time (2 bytes time, 2 bytes date)
698
+ time: data.readUInt32LE(Constants.LOCTIM),
699
+ // uncompressed file crc-32 value
700
+ crc: data.readUInt32LE(Constants.LOCCRC),
701
+ // compressed size
702
+ compressedSize: data.readUInt32LE(Constants.LOCSIZ),
703
+ // uncompressed size
704
+ size: data.readUInt32LE(Constants.LOCLEN),
705
+ // filename length
706
+ fnameLen: data.readUInt16LE(Constants.LOCNAM),
707
+ // extra field length
708
+ extraLen: data.readUInt16LE(Constants.LOCEXT)
709
+ };
886
710
  },
887
711
  loadFromBinary: function(data) {
888
712
  if (data.length !== Constants.CENHDR || data.readUInt32LE(0) !== Constants.CENSIG) {
889
- throw Utils.Errors.INVALID_CEN();
713
+ throw new Error(Utils.Errors.INVALID_CEN);
890
714
  }
891
715
  _verMade = data.readUInt16LE(Constants.CENVEM);
892
716
  _version = data.readUInt16LE(Constants.CENVER);
@@ -904,26 +728,26 @@ var require_entryHeader = __commonJS({
904
728
  _attr = data.readUInt32LE(Constants.CENATX);
905
729
  _offset = data.readUInt32LE(Constants.CENOFF);
906
730
  },
907
- localHeaderToBinary: function() {
731
+ dataHeaderToBinary: function() {
908
732
  var data = Buffer.alloc(Constants.LOCHDR);
909
733
  data.writeUInt32LE(Constants.LOCSIG, 0);
910
734
  data.writeUInt16LE(_version, Constants.LOCVER);
911
- data.writeUInt16LE(_flags & ~Constants.FLG_DESC, Constants.LOCFLG);
735
+ data.writeUInt16LE(_flags, Constants.LOCFLG);
912
736
  data.writeUInt16LE(_method, Constants.LOCHOW);
913
737
  data.writeUInt32LE(_time, Constants.LOCTIM);
914
738
  data.writeUInt32LE(_crc, Constants.LOCCRC);
915
739
  data.writeUInt32LE(_compressedSize, Constants.LOCSIZ);
916
740
  data.writeUInt32LE(_size, Constants.LOCLEN);
917
741
  data.writeUInt16LE(_fnameLen, Constants.LOCNAM);
918
- data.writeUInt16LE(_localHeader.extraLen, Constants.LOCEXT);
742
+ data.writeUInt16LE(_extraLen, Constants.LOCEXT);
919
743
  return data;
920
744
  },
921
- centralHeaderToBinary: function() {
745
+ entryHeaderToBinary: function() {
922
746
  var data = Buffer.alloc(Constants.CENHDR + _fnameLen + _extraLen + _comLen);
923
747
  data.writeUInt32LE(Constants.CENSIG, 0);
924
748
  data.writeUInt16LE(_verMade, Constants.CENVEM);
925
749
  data.writeUInt16LE(_version, Constants.CENVER);
926
- data.writeUInt16LE(_flags & ~Constants.FLG_DESC, Constants.CENFLG);
750
+ data.writeUInt16LE(_flags, Constants.CENFLG);
927
751
  data.writeUInt16LE(_method, Constants.CENHOW);
928
752
  data.writeUInt32LE(_time, Constants.CENTIM);
929
753
  data.writeUInt32LE(_crc, Constants.CENCRC);
@@ -936,47 +760,24 @@ var require_entryHeader = __commonJS({
936
760
  data.writeUInt16LE(_inattr, Constants.CENATT);
937
761
  data.writeUInt32LE(_attr, Constants.CENATX);
938
762
  data.writeUInt32LE(_offset, Constants.CENOFF);
763
+ data.fill(0, Constants.CENHDR);
939
764
  return data;
940
765
  },
941
- toJSON: function() {
942
- const bytes = function(nr) {
943
- return nr + " bytes";
944
- };
945
- return {
946
- made: _verMade,
947
- version: _version,
948
- flags: _flags,
949
- method: Utils.methodToString(_method),
950
- time: this.time,
951
- crc: "0x" + _crc.toString(16).toUpperCase(),
952
- compressedSize: bytes(_compressedSize),
953
- size: bytes(_size),
954
- fileNameLength: bytes(_fnameLen),
955
- extraLength: bytes(_extraLen),
956
- commentLength: bytes(_comLen),
957
- diskNumStart: _diskStart,
958
- inAttr: _inattr,
959
- attr: _attr,
960
- offset: _offset,
961
- centralHeaderSize: bytes(Constants.CENHDR + _fnameLen + _extraLen + _comLen)
962
- };
963
- },
964
766
  toString: function() {
965
- return JSON.stringify(this.toJSON(), null, " ");
767
+ return '{\n "made" : ' + _verMade + ',\n "version" : ' + _version + ',\n "flags" : ' + _flags + ',\n "method" : ' + Utils.methodToString(_method) + ',\n "time" : ' + this.time + ',\n "crc" : 0x' + _crc.toString(16).toUpperCase() + ',\n "compressedSize" : ' + _compressedSize + ' bytes,\n "size" : ' + _size + ' bytes,\n "fileNameLength" : ' + _fnameLen + ',\n "extraLength" : ' + _extraLen + ' bytes,\n "commentLength" : ' + _comLen + ' bytes,\n "diskNumStart" : ' + _diskStart + ',\n "inAttr" : ' + _inattr + ',\n "attr" : ' + _attr + ',\n "offset" : ' + _offset + ',\n "entryHeaderSize" : ' + (Constants.CENHDR + _fnameLen + _extraLen + _comLen) + " bytes\n}";
966
768
  }
967
769
  };
968
770
  };
969
771
  }
970
772
  });
971
773
 
972
- // node_modules/adm-zip/headers/mainHeader.js
774
+ // ../../node_modules/adm-zip/headers/mainHeader.js
973
775
  var require_mainHeader = __commonJS({
974
- "node_modules/adm-zip/headers/mainHeader.js"(exports, module) {
776
+ "../../node_modules/adm-zip/headers/mainHeader.js"(exports, module) {
975
777
  var Utils = require_util();
976
778
  var Constants = Utils.Constants;
977
779
  module.exports = function() {
978
780
  var _volumeEntries = 0, _totalEntries = 0, _size = 0, _offset = 0, _commentLength = 0;
979
- const needsZip64 = () => _volumeEntries > Constants.EF_ZIP64_OR_16 || _totalEntries > Constants.EF_ZIP64_OR_16 || _size > Constants.EF_ZIP64_OR_32 || _offset > Constants.EF_ZIP64_OR_32;
980
781
  return {
981
782
  get diskEntries() {
982
783
  return _volumeEntries;
@@ -1009,11 +810,11 @@ var require_mainHeader = __commonJS({
1009
810
  _commentLength = val;
1010
811
  },
1011
812
  get mainHeaderSize() {
1012
- return (needsZip64() ? Constants.ZIP64HDR + Constants.END64HDR : 0) + Constants.ENDHDR + _commentLength;
813
+ return Constants.ENDHDR + _commentLength;
1013
814
  },
1014
815
  loadFromBinary: function(data) {
1015
816
  if ((data.length !== Constants.ENDHDR || data.readUInt32LE(0) !== Constants.ENDSIG) && (data.length < Constants.ZIP64HDR || data.readUInt32LE(0) !== Constants.ZIP64SIG)) {
1016
- throw Utils.Errors.INVALID_END();
817
+ throw new Error(Utils.Errors.INVALID_END);
1017
818
  }
1018
819
  if (data.readUInt32LE(0) === Constants.ENDSIG) {
1019
820
  _volumeEntries = data.readUInt16LE(Constants.ENDSUB);
@@ -1024,86 +825,42 @@ var require_mainHeader = __commonJS({
1024
825
  } else {
1025
826
  _volumeEntries = Utils.readBigUInt64LE(data, Constants.ZIP64SUB);
1026
827
  _totalEntries = Utils.readBigUInt64LE(data, Constants.ZIP64TOT);
1027
- _size = Utils.readBigUInt64LE(data, Constants.ZIP64SIZB);
828
+ _size = Utils.readBigUInt64LE(data, Constants.ZIP64SIZ);
1028
829
  _offset = Utils.readBigUInt64LE(data, Constants.ZIP64OFF);
1029
830
  _commentLength = 0;
1030
831
  }
1031
832
  },
1032
833
  toBinary: function() {
1033
- if (!needsZip64()) {
1034
- var b = Buffer.alloc(Constants.ENDHDR + _commentLength);
1035
- b.writeUInt32LE(Constants.ENDSIG, 0);
1036
- b.writeUInt32LE(0, 4);
1037
- b.writeUInt16LE(_volumeEntries, Constants.ENDSUB);
1038
- b.writeUInt16LE(_totalEntries, Constants.ENDTOT);
1039
- b.writeUInt32LE(_size, Constants.ENDSIZ);
1040
- b.writeUInt32LE(_offset, Constants.ENDOFF);
1041
- b.writeUInt16LE(_commentLength, Constants.ENDCOM);
1042
- b.fill(" ", Constants.ENDHDR);
1043
- return b;
1044
- }
1045
- var b = Buffer.alloc(this.mainHeaderSize);
1046
- let offset = 0;
1047
- b.writeUInt32LE(Constants.ZIP64SIG, offset);
1048
- Utils.writeBigUInt64LE(b, Constants.ZIP64HDR - Constants.ZIP64LEAD, offset + Constants.ZIP64SIZE);
1049
- b.writeUInt16LE(45, offset + Constants.ZIP64VEM);
1050
- b.writeUInt16LE(45, offset + Constants.ZIP64VER);
1051
- b.writeUInt32LE(0, offset + Constants.ZIP64DSK);
1052
- b.writeUInt32LE(0, offset + Constants.ZIP64DSKDIR);
1053
- Utils.writeBigUInt64LE(b, _volumeEntries, offset + Constants.ZIP64SUB);
1054
- Utils.writeBigUInt64LE(b, _totalEntries, offset + Constants.ZIP64TOT);
1055
- Utils.writeBigUInt64LE(b, _size, offset + Constants.ZIP64SIZB);
1056
- Utils.writeBigUInt64LE(b, _offset, offset + Constants.ZIP64OFF);
1057
- const zip64EndOffset = _offset + _size;
1058
- offset += Constants.ZIP64HDR;
1059
- b.writeUInt32LE(Constants.END64SIG, offset);
1060
- b.writeUInt32LE(0, offset + Constants.END64START);
1061
- Utils.writeBigUInt64LE(b, zip64EndOffset, offset + Constants.END64OFF);
1062
- b.writeUInt32LE(1, offset + Constants.END64NUMDISKS);
1063
- offset += Constants.END64HDR;
1064
- b.writeUInt32LE(Constants.ENDSIG, offset);
1065
- b.writeUInt32LE(0, offset + 4);
1066
- b.writeUInt16LE(Math.min(_volumeEntries, Constants.EF_ZIP64_OR_16), offset + Constants.ENDSUB);
1067
- b.writeUInt16LE(Math.min(_totalEntries, Constants.EF_ZIP64_OR_16), offset + Constants.ENDTOT);
1068
- b.writeUInt32LE(Math.min(_size, Constants.EF_ZIP64_OR_32), offset + Constants.ENDSIZ);
1069
- b.writeUInt32LE(Math.min(_offset, Constants.EF_ZIP64_OR_32), offset + Constants.ENDOFF);
1070
- b.writeUInt16LE(_commentLength, offset + Constants.ENDCOM);
1071
- b.fill(" ", offset + Constants.ENDHDR);
834
+ var b = Buffer.alloc(Constants.ENDHDR + _commentLength);
835
+ b.writeUInt32LE(Constants.ENDSIG, 0);
836
+ b.writeUInt32LE(0, 4);
837
+ b.writeUInt16LE(_volumeEntries, Constants.ENDSUB);
838
+ b.writeUInt16LE(_totalEntries, Constants.ENDTOT);
839
+ b.writeUInt32LE(_size, Constants.ENDSIZ);
840
+ b.writeUInt32LE(_offset, Constants.ENDOFF);
841
+ b.writeUInt16LE(_commentLength, Constants.ENDCOM);
842
+ b.fill(" ", Constants.ENDHDR);
1072
843
  return b;
1073
844
  },
1074
- toJSON: function() {
1075
- const offset = function(nr, len) {
1076
- let offs = nr.toString(16).toUpperCase();
1077
- while (offs.length < len) offs = "0" + offs;
1078
- return "0x" + offs;
1079
- };
1080
- return {
1081
- diskEntries: _volumeEntries,
1082
- totalEntries: _totalEntries,
1083
- size: _size + " bytes",
1084
- offset: offset(_offset, 4),
1085
- commentLength: _commentLength
1086
- };
1087
- },
1088
845
  toString: function() {
1089
- return JSON.stringify(this.toJSON(), null, " ");
846
+ return '{\n "diskEntries" : ' + _volumeEntries + ',\n "totalEntries" : ' + _totalEntries + ',\n "size" : ' + _size + ' bytes,\n "offset" : 0x' + _offset.toString(16).toUpperCase() + ',\n "commentLength" : 0x' + _commentLength + "\n}";
1090
847
  }
1091
848
  };
1092
849
  };
1093
850
  }
1094
851
  });
1095
852
 
1096
- // node_modules/adm-zip/headers/index.js
853
+ // ../../node_modules/adm-zip/headers/index.js
1097
854
  var require_headers = __commonJS({
1098
- "node_modules/adm-zip/headers/index.js"(exports) {
855
+ "../../node_modules/adm-zip/headers/index.js"(exports) {
1099
856
  exports.EntryHeader = require_entryHeader();
1100
857
  exports.MainHeader = require_mainHeader();
1101
858
  }
1102
859
  });
1103
860
 
1104
- // node_modules/adm-zip/methods/deflater.js
861
+ // ../../node_modules/adm-zip/methods/deflater.js
1105
862
  var require_deflater = __commonJS({
1106
- "node_modules/adm-zip/methods/deflater.js"(exports, module) {
863
+ "../../node_modules/adm-zip/methods/deflater.js"(exports, module) {
1107
864
  module.exports = function(inbuf) {
1108
865
  var zlib = __require("zlib");
1109
866
  var opts = { chunkSize: (parseInt(inbuf.length / 1024) + 1) * 1024 };
@@ -1134,19 +891,17 @@ var require_deflater = __commonJS({
1134
891
  }
1135
892
  });
1136
893
 
1137
- // node_modules/adm-zip/methods/inflater.js
894
+ // ../../node_modules/adm-zip/methods/inflater.js
1138
895
  var require_inflater = __commonJS({
1139
- "node_modules/adm-zip/methods/inflater.js"(exports, module) {
1140
- var version = +(process?.versions?.node ?? "").split(".")[0] || 0;
1141
- module.exports = function(inbuf, expectedLength) {
896
+ "../../node_modules/adm-zip/methods/inflater.js"(exports, module) {
897
+ module.exports = function(inbuf) {
1142
898
  var zlib = __require("zlib");
1143
- const option = version >= 15 && expectedLength > 0 ? { maxOutputLength: expectedLength } : {};
1144
899
  return {
1145
900
  inflate: function() {
1146
- return zlib.inflateRawSync(inbuf, option);
901
+ return zlib.inflateRawSync(inbuf);
1147
902
  },
1148
903
  inflateAsync: function(callback) {
1149
- var tmp = zlib.createInflateRaw(option), parts = [], total = 0;
904
+ var tmp = zlib.createInflateRaw(), parts = [], total = 0;
1150
905
  tmp.on("data", function(data) {
1151
906
  parts.push(data);
1152
907
  total += data.length;
@@ -1168,153 +923,38 @@ var require_inflater = __commonJS({
1168
923
  }
1169
924
  });
1170
925
 
1171
- // node_modules/adm-zip/methods/zipcrypto.js
1172
- var require_zipcrypto = __commonJS({
1173
- "node_modules/adm-zip/methods/zipcrypto.js"(exports, module) {
1174
- "use strict";
1175
- var { randomFillSync } = __require("crypto");
1176
- var Errors = require_errors();
1177
- var crctable = new Uint32Array(256).map((t, crc) => {
1178
- for (let j = 0; j < 8; j++) {
1179
- if (0 !== (crc & 1)) {
1180
- crc = crc >>> 1 ^ 3988292384;
1181
- } else {
1182
- crc >>>= 1;
1183
- }
1184
- }
1185
- return crc >>> 0;
1186
- });
1187
- var uMul = (a, b) => Math.imul(a, b) >>> 0;
1188
- var crc32update = (pCrc32, bval) => {
1189
- return crctable[(pCrc32 ^ bval) & 255] ^ pCrc32 >>> 8;
1190
- };
1191
- var genSalt = () => {
1192
- if ("function" === typeof randomFillSync) {
1193
- return randomFillSync(Buffer.alloc(12));
1194
- } else {
1195
- return genSalt.node();
1196
- }
1197
- };
1198
- genSalt.node = () => {
1199
- const salt = Buffer.alloc(12);
1200
- const len = salt.length;
1201
- for (let i = 0; i < len; i++) salt[i] = Math.random() * 256 & 255;
1202
- return salt;
1203
- };
1204
- var config = {
1205
- genSalt
1206
- };
1207
- function Initkeys(pw) {
1208
- const pass = Buffer.isBuffer(pw) ? pw : Buffer.from(pw);
1209
- this.keys = new Uint32Array([305419896, 591751049, 878082192]);
1210
- for (let i = 0; i < pass.length; i++) {
1211
- this.updateKeys(pass[i]);
1212
- }
1213
- }
1214
- Initkeys.prototype.updateKeys = function(byteValue) {
1215
- const keys = this.keys;
1216
- keys[0] = crc32update(keys[0], byteValue);
1217
- keys[1] += keys[0] & 255;
1218
- keys[1] = uMul(keys[1], 134775813) + 1;
1219
- keys[2] = crc32update(keys[2], keys[1] >>> 24);
1220
- return byteValue;
1221
- };
1222
- Initkeys.prototype.next = function() {
1223
- const k = (this.keys[2] | 2) >>> 0;
1224
- return uMul(k, k ^ 1) >> 8 & 255;
1225
- };
1226
- function make_decrypter(pwd) {
1227
- const keys = new Initkeys(pwd);
1228
- return function(data) {
1229
- const result = Buffer.alloc(data.length);
1230
- let pos = 0;
1231
- for (let c of data) {
1232
- result[pos++] = keys.updateKeys(c ^ keys.next());
1233
- }
1234
- return result;
1235
- };
1236
- }
1237
- function make_encrypter(pwd) {
1238
- const keys = new Initkeys(pwd);
1239
- return function(data, result, pos = 0) {
1240
- if (!result) result = Buffer.alloc(data.length);
1241
- for (let c of data) {
1242
- const k = keys.next();
1243
- result[pos++] = c ^ k;
1244
- keys.updateKeys(c);
1245
- }
1246
- return result;
1247
- };
1248
- }
1249
- function decrypt(data, header, pwd) {
1250
- if (!data || !Buffer.isBuffer(data) || data.length < 12) {
1251
- return Buffer.alloc(0);
1252
- }
1253
- const decrypter = make_decrypter(pwd);
1254
- const salt = decrypter(data.slice(0, 12));
1255
- const verifyByte = (header.flags & 8) === 8 ? header.timeHighByte : header.crc >>> 24;
1256
- if (salt[11] !== verifyByte) {
1257
- throw Errors.WRONG_PASSWORD();
1258
- }
1259
- return decrypter(data.slice(12));
1260
- }
1261
- function _salter(data) {
1262
- if (Buffer.isBuffer(data) && data.length >= 12) {
1263
- config.genSalt = function() {
1264
- return data.slice(0, 12);
1265
- };
1266
- } else if (data === "node") {
1267
- config.genSalt = genSalt.node;
1268
- } else {
1269
- config.genSalt = genSalt;
1270
- }
1271
- }
1272
- function encrypt(data, header, pwd, oldlike = false) {
1273
- if (data == null) data = Buffer.alloc(0);
1274
- if (!Buffer.isBuffer(data)) data = Buffer.from(data.toString());
1275
- const encrypter = make_encrypter(pwd);
1276
- const salt = config.genSalt();
1277
- salt[11] = header.crc >>> 24 & 255;
1278
- if (oldlike) salt[10] = header.crc >>> 16 & 255;
1279
- const result = Buffer.alloc(data.length + 12);
1280
- encrypter(salt, result);
1281
- return encrypter(data, result, 12);
1282
- }
1283
- module.exports = { decrypt, encrypt, _salter };
1284
- }
1285
- });
1286
-
1287
- // node_modules/adm-zip/methods/index.js
926
+ // ../../node_modules/adm-zip/methods/index.js
1288
927
  var require_methods = __commonJS({
1289
- "node_modules/adm-zip/methods/index.js"(exports) {
928
+ "../../node_modules/adm-zip/methods/index.js"(exports) {
1290
929
  exports.Deflater = require_deflater();
1291
930
  exports.Inflater = require_inflater();
1292
- exports.ZipCrypto = require_zipcrypto();
1293
931
  }
1294
932
  });
1295
933
 
1296
- // node_modules/adm-zip/zipEntry.js
934
+ // ../../node_modules/adm-zip/zipEntry.js
1297
935
  var require_zipEntry = __commonJS({
1298
- "node_modules/adm-zip/zipEntry.js"(exports, module) {
936
+ "../../node_modules/adm-zip/zipEntry.js"(exports, module) {
1299
937
  var Utils = require_util();
1300
938
  var Headers = require_headers();
1301
939
  var Constants = Utils.Constants;
1302
940
  var Methods = require_methods();
1303
- module.exports = function(options, input) {
1304
- var _centralHeader = new Headers.EntryHeader(), _entryName = Buffer.alloc(0), _comment = Buffer.alloc(0), _isDirectory = false, uncompressedData = null, _extra = Buffer.alloc(0), _extralocal = Buffer.alloc(0), _efs = true;
1305
- const opts = options;
1306
- const decoder = typeof opts.decoder === "object" ? opts.decoder : Utils.decoder;
1307
- _efs = decoder.hasOwnProperty("efs") ? decoder.efs : false;
941
+ module.exports = function(input) {
942
+ var _entryHeader = new Headers.EntryHeader(), _entryName = Buffer.alloc(0), _comment = Buffer.alloc(0), _isDirectory = false, uncompressedData = null, _extra = Buffer.alloc(0);
1308
943
  function getCompressedDataFromZip() {
1309
- if (!input || !(input instanceof Uint8Array)) {
944
+ if (!input || !Buffer.isBuffer(input)) {
1310
945
  return Buffer.alloc(0);
1311
946
  }
1312
- _extralocal = _centralHeader.loadLocalHeaderFromBinary(input);
1313
- return input.slice(_centralHeader.realDataOffset, _centralHeader.realDataOffset + _centralHeader.compressedSize);
947
+ _entryHeader.loadDataHeaderFromBinary(input);
948
+ return input.slice(_entryHeader.realDataOffset, _entryHeader.realDataOffset + _entryHeader.compressedSize);
1314
949
  }
1315
950
  function crc32OK(data) {
1316
- const expectedCrc = _centralHeader.flags_desc || _centralHeader.localHeader.flags_desc ? _centralHeader.crc : _centralHeader.localHeader.crc;
1317
- return Utils.crc32(data) === expectedCrc;
951
+ if ((_entryHeader.flags & 8) !== 8) {
952
+ if (Utils.crc32(data) !== _entryHeader.dataHeader.crc) {
953
+ return false;
954
+ }
955
+ } else {
956
+ }
957
+ return true;
1318
958
  }
1319
959
  function decompress(async, callback, pass) {
1320
960
  if (typeof callback === "undefined" && typeof async === "string") {
@@ -1323,7 +963,7 @@ var require_zipEntry = __commonJS({
1323
963
  }
1324
964
  if (_isDirectory) {
1325
965
  if (async && callback) {
1326
- callback(Buffer.alloc(0), Utils.Errors.DIRECTORY_CONTENT_ERROR());
966
+ callback(Buffer.alloc(0), Utils.Errors.DIRECTORY_CONTENT_ERROR);
1327
967
  }
1328
968
  return Buffer.alloc(0);
1329
969
  }
@@ -1332,47 +972,40 @@ var require_zipEntry = __commonJS({
1332
972
  if (async && callback) callback(compressedData);
1333
973
  return compressedData;
1334
974
  }
1335
- if (_centralHeader.encrypted) {
1336
- if ("string" !== typeof pass && !Buffer.isBuffer(pass)) {
1337
- throw Utils.Errors.INVALID_PASS_PARAM();
1338
- }
1339
- compressedData = Methods.ZipCrypto.decrypt(compressedData, _centralHeader, pass);
1340
- }
1341
- var data;
1342
- switch (_centralHeader.method) {
975
+ var data = Buffer.alloc(_entryHeader.size);
976
+ switch (_entryHeader.method) {
1343
977
  case Utils.Constants.STORED:
1344
- data = Buffer.alloc(compressedData.length);
1345
978
  compressedData.copy(data);
1346
979
  if (!crc32OK(data)) {
1347
- if (async && callback) callback(data, Utils.Errors.BAD_CRC());
1348
- throw Utils.Errors.BAD_CRC();
980
+ if (async && callback) callback(data, Utils.Errors.BAD_CRC);
981
+ throw new Error(Utils.Errors.BAD_CRC);
1349
982
  } else {
1350
983
  if (async && callback) callback(data);
1351
984
  return data;
1352
985
  }
1353
986
  case Utils.Constants.DEFLATED:
1354
- var inflater = new Methods.Inflater(compressedData, _centralHeader.size);
987
+ var inflater = new Methods.Inflater(compressedData);
1355
988
  if (!async) {
1356
- data = inflater.inflate();
989
+ var result = inflater.inflate(data);
990
+ result.copy(data, 0);
1357
991
  if (!crc32OK(data)) {
1358
- throw Utils.Errors.BAD_CRC(`"${decoder.decode(_entryName)}"`);
992
+ throw new Error(Utils.Errors.BAD_CRC + " " + _entryName.toString());
1359
993
  }
1360
994
  return data;
1361
995
  } else {
1362
- inflater.inflateAsync(function(result) {
1363
- if (callback) {
1364
- if (!crc32OK(result)) {
1365
- callback(result, Utils.Errors.BAD_CRC());
1366
- } else {
1367
- callback(result);
1368
- }
996
+ inflater.inflateAsync(function(result2) {
997
+ result2.copy(data, 0);
998
+ if (!crc32OK(data)) {
999
+ if (callback) callback(data, Utils.Errors.BAD_CRC);
1000
+ } else {
1001
+ if (callback) callback(data);
1369
1002
  }
1370
1003
  });
1371
1004
  }
1372
1005
  break;
1373
1006
  default:
1374
- if (async && callback) callback(Buffer.alloc(0), Utils.Errors.UNKNOWN_METHOD());
1375
- throw Utils.Errors.UNKNOWN_METHOD();
1007
+ if (async && callback) callback(Buffer.alloc(0), Utils.Errors.UNKNOWN_METHOD);
1008
+ throw new Error(Utils.Errors.UNKNOWN_METHOD);
1376
1009
  }
1377
1010
  }
1378
1011
  function compress(async, callback) {
@@ -1382,9 +1015,9 @@ var require_zipEntry = __commonJS({
1382
1015
  }
1383
1016
  if (uncompressedData.length && !_isDirectory) {
1384
1017
  var compressedData;
1385
- switch (_centralHeader.method) {
1018
+ switch (_entryHeader.method) {
1386
1019
  case Utils.Constants.STORED:
1387
- _centralHeader.compressedSize = _centralHeader.size;
1020
+ _entryHeader.compressedSize = _entryHeader.size;
1388
1021
  compressedData = Buffer.alloc(uncompressedData.length);
1389
1022
  uncompressedData.copy(compressedData);
1390
1023
  if (async && callback) callback(compressedData);
@@ -1394,12 +1027,12 @@ var require_zipEntry = __commonJS({
1394
1027
  var deflater = new Methods.Deflater(uncompressedData);
1395
1028
  if (!async) {
1396
1029
  var deflated = deflater.deflate();
1397
- _centralHeader.compressedSize = deflated.length;
1030
+ _entryHeader.compressedSize = deflated.length;
1398
1031
  return deflated;
1399
1032
  } else {
1400
1033
  deflater.deflateAsync(function(data) {
1401
1034
  compressedData = Buffer.alloc(data.length);
1402
- _centralHeader.compressedSize = data.length;
1035
+ _entryHeader.compressedSize = data.length;
1403
1036
  data.copy(compressedData);
1404
1037
  callback && callback(compressedData);
1405
1038
  });
@@ -1407,100 +1040,90 @@ var require_zipEntry = __commonJS({
1407
1040
  deflater = null;
1408
1041
  break;
1409
1042
  }
1410
- } else if (async && callback) {
1411
- callback(Buffer.alloc(0));
1412
1043
  } else {
1413
- return Buffer.alloc(0);
1044
+ if (async && callback) {
1045
+ callback(Buffer.alloc(0));
1046
+ } else {
1047
+ return Buffer.alloc(0);
1048
+ }
1414
1049
  }
1415
1050
  }
1416
1051
  function readUInt64LE(buffer, offset) {
1417
- return Utils.readBigUInt64LE(buffer, offset);
1052
+ return (buffer.readUInt32LE(offset + 4) << 4) + buffer.readUInt32LE(offset);
1418
1053
  }
1419
1054
  function parseExtra(data) {
1420
- try {
1421
- var offset = 0;
1422
- var signature, size, part;
1423
- while (offset + 4 < data.length) {
1424
- signature = data.readUInt16LE(offset);
1425
- offset += 2;
1426
- size = data.readUInt16LE(offset);
1427
- offset += 2;
1428
- part = data.slice(offset, offset + size);
1429
- offset += size;
1430
- if (Constants.ID_ZIP64 === signature) {
1431
- parseZip64ExtendedInformation(part);
1432
- }
1055
+ var offset = 0;
1056
+ var signature, size, part;
1057
+ while (offset < data.length) {
1058
+ signature = data.readUInt16LE(offset);
1059
+ offset += 2;
1060
+ size = data.readUInt16LE(offset);
1061
+ offset += 2;
1062
+ part = data.slice(offset, offset + size);
1063
+ offset += size;
1064
+ if (Constants.ID_ZIP64 === signature) {
1065
+ parseZip64ExtendedInformation(part);
1433
1066
  }
1434
- } catch (error) {
1435
- throw Utils.Errors.EXTRA_FIELD_PARSE_ERROR();
1436
1067
  }
1437
1068
  }
1438
1069
  function parseZip64ExtendedInformation(data) {
1439
1070
  var size, compressedSize, offset, diskNumStart;
1440
1071
  if (data.length >= Constants.EF_ZIP64_SCOMP) {
1441
1072
  size = readUInt64LE(data, Constants.EF_ZIP64_SUNCOMP);
1442
- if (_centralHeader.size === Constants.EF_ZIP64_OR_32) {
1443
- _centralHeader.size = size;
1073
+ if (_entryHeader.size === Constants.EF_ZIP64_OR_32) {
1074
+ _entryHeader.size = size;
1444
1075
  }
1445
1076
  }
1446
1077
  if (data.length >= Constants.EF_ZIP64_RHO) {
1447
1078
  compressedSize = readUInt64LE(data, Constants.EF_ZIP64_SCOMP);
1448
- if (_centralHeader.compressedSize === Constants.EF_ZIP64_OR_32) {
1449
- _centralHeader.compressedSize = compressedSize;
1079
+ if (_entryHeader.compressedSize === Constants.EF_ZIP64_OR_32) {
1080
+ _entryHeader.compressedSize = compressedSize;
1450
1081
  }
1451
1082
  }
1452
1083
  if (data.length >= Constants.EF_ZIP64_DSN) {
1453
1084
  offset = readUInt64LE(data, Constants.EF_ZIP64_RHO);
1454
- if (_centralHeader.offset === Constants.EF_ZIP64_OR_32) {
1455
- _centralHeader.offset = offset;
1085
+ if (_entryHeader.offset === Constants.EF_ZIP64_OR_32) {
1086
+ _entryHeader.offset = offset;
1456
1087
  }
1457
1088
  }
1458
1089
  if (data.length >= Constants.EF_ZIP64_DSN + 4) {
1459
1090
  diskNumStart = data.readUInt32LE(Constants.EF_ZIP64_DSN);
1460
- if (_centralHeader.diskNumStart === Constants.EF_ZIP64_OR_16) {
1461
- _centralHeader.diskNumStart = diskNumStart;
1091
+ if (_entryHeader.diskNumStart === Constants.EF_ZIP64_OR_16) {
1092
+ _entryHeader.diskNumStart = diskNumStart;
1462
1093
  }
1463
1094
  }
1464
1095
  }
1465
1096
  return {
1466
1097
  get entryName() {
1467
- return decoder.decode(_entryName);
1098
+ return _entryName.toString();
1468
1099
  },
1469
1100
  get rawEntryName() {
1470
1101
  return _entryName;
1471
1102
  },
1472
1103
  set entryName(val) {
1473
- _entryName = Utils.toBuffer(val, decoder.encode);
1104
+ _entryName = Utils.toBuffer(val);
1474
1105
  var lastChar = _entryName[_entryName.length - 1];
1475
1106
  _isDirectory = lastChar === 47 || lastChar === 92;
1476
- _centralHeader.fileNameLength = _entryName.length;
1477
- },
1478
- get efs() {
1479
- if (typeof _efs === "function") {
1480
- return _efs(this.entryName);
1481
- } else {
1482
- return _efs;
1483
- }
1107
+ _entryHeader.fileNameLength = _entryName.length;
1484
1108
  },
1485
1109
  get extra() {
1486
1110
  return _extra;
1487
1111
  },
1488
1112
  set extra(val) {
1489
1113
  _extra = val;
1490
- _centralHeader.extraLength = val.length;
1114
+ _entryHeader.extraLength = val.length;
1491
1115
  parseExtra(val);
1492
1116
  },
1493
1117
  get comment() {
1494
- return decoder.decode(_comment);
1118
+ return _comment.toString();
1495
1119
  },
1496
1120
  set comment(val) {
1497
- _comment = Utils.toBuffer(val, decoder.encode);
1498
- _centralHeader.commentLength = _comment.length;
1499
- if (_comment.length > 65535) throw Utils.Errors.COMMENT_TOO_LONG();
1121
+ _comment = Utils.toBuffer(val);
1122
+ _entryHeader.commentLength = _comment.length;
1500
1123
  },
1501
1124
  get name() {
1502
- const n = decoder.decode(_entryName);
1503
- return _isDirectory ? n.replace(/[/\\]$/, "").split("/").pop() : n.split("/").pop();
1125
+ var n = _entryName.toString();
1126
+ return _isDirectory ? n.substr(n.length - 1).split("/").pop() : n.split("/").pop();
1504
1127
  },
1505
1128
  get isDirectory() {
1506
1129
  return _isDirectory;
@@ -1512,157 +1135,112 @@ var require_zipEntry = __commonJS({
1512
1135
  compress(true, callback);
1513
1136
  },
1514
1137
  setData: function(value) {
1515
- uncompressedData = Utils.toBuffer(value, Utils.decoder.encode);
1138
+ uncompressedData = Utils.toBuffer(value);
1516
1139
  if (!_isDirectory && uncompressedData.length) {
1517
- _centralHeader.size = uncompressedData.length;
1518
- _centralHeader.method = Utils.Constants.DEFLATED;
1519
- _centralHeader.crc = Utils.crc32(value);
1520
- _centralHeader.changed = true;
1140
+ _entryHeader.size = uncompressedData.length;
1141
+ _entryHeader.method = Utils.Constants.DEFLATED;
1142
+ _entryHeader.crc = Utils.crc32(value);
1143
+ _entryHeader.changed = true;
1521
1144
  } else {
1522
- _centralHeader.method = Utils.Constants.STORED;
1145
+ _entryHeader.method = Utils.Constants.STORED;
1523
1146
  }
1524
1147
  },
1525
1148
  getData: function(pass) {
1526
- if (_centralHeader.changed) {
1149
+ if (_entryHeader.changed) {
1527
1150
  return uncompressedData;
1528
1151
  } else {
1529
1152
  return decompress(false, null, pass);
1530
1153
  }
1531
1154
  },
1532
1155
  getDataAsync: function(callback, pass) {
1533
- if (_centralHeader.changed) {
1156
+ if (_entryHeader.changed) {
1534
1157
  callback(uncompressedData);
1535
1158
  } else {
1536
1159
  decompress(true, callback, pass);
1537
1160
  }
1538
1161
  },
1539
1162
  set attr(attr) {
1540
- _centralHeader.attr = attr;
1163
+ _entryHeader.attr = attr;
1541
1164
  },
1542
1165
  get attr() {
1543
- return _centralHeader.attr;
1166
+ return _entryHeader.attr;
1544
1167
  },
1545
1168
  set header(data) {
1546
- _centralHeader.loadFromBinary(data);
1169
+ _entryHeader.loadFromBinary(data);
1547
1170
  },
1548
1171
  get header() {
1549
- return _centralHeader;
1172
+ return _entryHeader;
1550
1173
  },
1551
- packCentralHeader: function() {
1552
- _centralHeader.flags_efs = this.efs;
1553
- _centralHeader.extraLength = _extra.length;
1554
- var header = _centralHeader.centralHeaderToBinary();
1555
- var addpos = Utils.Constants.CENHDR;
1556
- _entryName.copy(header, addpos);
1557
- addpos += _entryName.length;
1558
- _extra.copy(header, addpos);
1559
- addpos += _centralHeader.extraLength;
1560
- _comment.copy(header, addpos);
1174
+ packHeader: function() {
1175
+ var header = _entryHeader.entryHeaderToBinary();
1176
+ _entryName.copy(header, Utils.Constants.CENHDR);
1177
+ if (_entryHeader.extraLength) {
1178
+ _extra.copy(header, Utils.Constants.CENHDR + _entryName.length);
1179
+ }
1180
+ if (_entryHeader.commentLength) {
1181
+ _comment.copy(header, Utils.Constants.CENHDR + _entryName.length + _entryHeader.extraLength, _comment.length);
1182
+ }
1561
1183
  return header;
1562
1184
  },
1563
- packLocalHeader: function() {
1564
- let addpos = 0;
1565
- _centralHeader.flags_efs = this.efs;
1566
- _centralHeader.extraLocalLength = _extralocal.length;
1567
- const localHeaderBuf = _centralHeader.localHeaderToBinary();
1568
- const localHeader = Buffer.alloc(localHeaderBuf.length + _entryName.length + _centralHeader.extraLocalLength);
1569
- localHeaderBuf.copy(localHeader, addpos);
1570
- addpos += localHeaderBuf.length;
1571
- _entryName.copy(localHeader, addpos);
1572
- addpos += _entryName.length;
1573
- _extralocal.copy(localHeader, addpos);
1574
- addpos += _extralocal.length;
1575
- return localHeader;
1576
- },
1577
- toJSON: function() {
1578
- const bytes = function(nr) {
1579
- return "<" + (nr && nr.length + " bytes buffer" || "null") + ">";
1580
- };
1581
- return {
1582
- entryName: this.entryName,
1583
- name: this.name,
1584
- comment: this.comment,
1585
- isDirectory: this.isDirectory,
1586
- header: _centralHeader.toJSON(),
1587
- compressedData: bytes(input),
1588
- data: bytes(uncompressedData)
1589
- };
1590
- },
1591
1185
  toString: function() {
1592
- return JSON.stringify(this.toJSON(), null, " ");
1186
+ return '{\n "entryName" : "' + _entryName.toString() + '",\n "name" : "' + (_isDirectory ? _entryName.toString().replace(/\/$/, "").split("/").pop() : _entryName.toString().split("/").pop()) + '",\n "comment" : "' + _comment.toString() + '",\n "isDirectory" : ' + _isDirectory + ',\n "header" : ' + _entryHeader.toString().replace(/\t/mg, " ").replace(/}/mg, " }") + ',\n "compressedData" : <' + (input && input.length + " bytes buffer" || "null") + '>\n "data" : <' + (uncompressedData && uncompressedData.length + " bytes buffer" || "null") + ">\n}";
1593
1187
  }
1594
1188
  };
1595
1189
  };
1596
1190
  }
1597
1191
  });
1598
1192
 
1599
- // node_modules/adm-zip/zipFile.js
1193
+ // ../../node_modules/adm-zip/zipFile.js
1600
1194
  var require_zipFile = __commonJS({
1601
- "node_modules/adm-zip/zipFile.js"(exports, module) {
1195
+ "../../node_modules/adm-zip/zipFile.js"(exports, module) {
1602
1196
  var ZipEntry = require_zipEntry();
1603
1197
  var Headers = require_headers();
1604
1198
  var Utils = require_util();
1605
- module.exports = function(inBuffer, options) {
1606
- var entryList = [], entryTable = /* @__PURE__ */ Object.create(null), _comment = Buffer.alloc(0), mainHeader = new Headers.MainHeader(), loadedEntries = false;
1607
- var password = null;
1608
- const temporary = /* @__PURE__ */ new Set();
1609
- const opts = options;
1610
- const { noSort, decoder } = opts;
1611
- if (inBuffer) {
1612
- readMainHeader(opts.readEntries);
1199
+ module.exports = function(input, inputType) {
1200
+ var entryList = [], entryTable = {}, _comment = Buffer.alloc(0), filename = "", fs10 = Utils.FileSystem.require(), inBuffer = null, mainHeader = new Headers.MainHeader(), loadedEntries = false;
1201
+ if (inputType === Utils.Constants.FILE) {
1202
+ filename = input;
1203
+ inBuffer = fs10.readFileSync(filename);
1204
+ readMainHeader();
1205
+ } else if (inputType === Utils.Constants.BUFFER) {
1206
+ inBuffer = input;
1207
+ readMainHeader();
1613
1208
  } else {
1614
1209
  loadedEntries = true;
1615
1210
  }
1616
- function makeTemporaryFolders() {
1617
- const foldersList = /* @__PURE__ */ new Set();
1618
- for (const elem of Object.keys(entryTable)) {
1619
- const elements = elem.split("/");
1620
- elements.pop();
1621
- if (!elements.length) continue;
1622
- for (let i = 0; i < elements.length; i++) {
1623
- const sub = elements.slice(0, i + 1).join("/") + "/";
1624
- foldersList.add(sub);
1625
- }
1626
- }
1627
- for (const elem of foldersList) {
1628
- if (!(elem in entryTable)) {
1629
- const tempfolder = new ZipEntry(opts);
1630
- tempfolder.entryName = elem;
1631
- tempfolder.attr = 16;
1632
- tempfolder.temporary = true;
1633
- entryList.push(tempfolder);
1634
- entryTable[tempfolder.entryName] = tempfolder;
1635
- temporary.add(tempfolder);
1636
- }
1211
+ function iterateEntries(callback) {
1212
+ const totalEntries = mainHeader.diskEntries;
1213
+ let index = mainHeader.offset;
1214
+ for (let i = 0; i < totalEntries; i++) {
1215
+ let tmp = index;
1216
+ const entry = new ZipEntry(inBuffer);
1217
+ entry.header = inBuffer.slice(tmp, tmp += Utils.Constants.CENHDR);
1218
+ entry.entryName = inBuffer.slice(tmp, tmp += entry.header.fileNameLength);
1219
+ index += entry.header.entryHeaderSize;
1220
+ callback(entry);
1637
1221
  }
1638
1222
  }
1639
1223
  function readEntries() {
1640
1224
  loadedEntries = true;
1641
- entryTable = /* @__PURE__ */ Object.create(null);
1642
- if (mainHeader.diskEntries > (inBuffer.length - mainHeader.offset) / Utils.Constants.CENHDR) {
1643
- throw Utils.Errors.DISK_ENTRY_TOO_LARGE();
1644
- }
1225
+ entryTable = {};
1645
1226
  entryList = new Array(mainHeader.diskEntries);
1646
1227
  var index = mainHeader.offset;
1647
1228
  for (var i = 0; i < entryList.length; i++) {
1648
- var tmp = index, entry = new ZipEntry(opts, inBuffer);
1229
+ var tmp = index, entry = new ZipEntry(inBuffer);
1649
1230
  entry.header = inBuffer.slice(tmp, tmp += Utils.Constants.CENHDR);
1650
1231
  entry.entryName = inBuffer.slice(tmp, tmp += entry.header.fileNameLength);
1651
1232
  if (entry.header.extraLength) {
1652
1233
  entry.extra = inBuffer.slice(tmp, tmp += entry.header.extraLength);
1653
1234
  }
1654
- if (entry.header.commentLength) entry.comment = inBuffer.slice(tmp, tmp + entry.header.commentLength);
1655
- index += entry.header.centralHeaderSize;
1235
+ if (entry.header.commentLength)
1236
+ entry.comment = inBuffer.slice(tmp, tmp + entry.header.commentLength);
1237
+ index += entry.header.entryHeaderSize;
1656
1238
  entryList[i] = entry;
1657
1239
  entryTable[entry.entryName] = entry;
1658
1240
  }
1659
- temporary.clear();
1660
- makeTemporaryFolders();
1661
1241
  }
1662
- function readMainHeader(readNow) {
1242
+ function readMainHeader() {
1663
1243
  var i = inBuffer.length - Utils.Constants.ENDHDR, max = Math.max(0, i - 65535), n = max, endStart = inBuffer.length, endOffset = -1, commentEnd = 0;
1664
- const trailingSpace = typeof opts.trailingSpace === "boolean" ? opts.trailingSpace : false;
1665
- if (trailingSpace) max = 0;
1666
1244
  for (i; i >= n; i--) {
1667
1245
  if (inBuffer[i] !== 80) continue;
1668
1246
  if (inBuffer.readUInt32LE(i) === Utils.Constants.ENDSIG) {
@@ -1676,23 +1254,18 @@ var require_zipFile = __commonJS({
1676
1254
  n = max;
1677
1255
  continue;
1678
1256
  }
1679
- if (inBuffer.readUInt32LE(i) === Utils.Constants.ZIP64SIG) {
1257
+ if (inBuffer.readUInt32LE(i) == Utils.Constants.ZIP64SIG) {
1680
1258
  endOffset = i;
1681
1259
  endStart = i + Utils.readBigUInt64LE(inBuffer, i + Utils.Constants.ZIP64SIZE) + Utils.Constants.ZIP64LEAD;
1682
1260
  break;
1683
1261
  }
1684
1262
  }
1685
- if (endOffset == -1) throw Utils.Errors.INVALID_FORMAT();
1263
+ if (!~endOffset)
1264
+ throw new Error(Utils.Errors.INVALID_FORMAT);
1686
1265
  mainHeader.loadFromBinary(inBuffer.slice(endOffset, endStart));
1687
1266
  if (mainHeader.commentLength) {
1688
1267
  _comment = inBuffer.slice(commentEnd + Utils.Constants.ENDHDR);
1689
1268
  }
1690
- if (readNow) readEntries();
1691
- }
1692
- function sortEntries() {
1693
- if (entryList.length > 1 && !noSort) {
1694
- entryList = entryList.map((entry) => ({ entry, key: entry.entryName.toLowerCase() })).sort((a, b) => a.key.localeCompare(b.key)).map((pair) => pair.entry);
1695
- }
1696
1269
  }
1697
1270
  return {
1698
1271
  /**
@@ -1703,18 +1276,18 @@ var require_zipFile = __commonJS({
1703
1276
  if (!loadedEntries) {
1704
1277
  readEntries();
1705
1278
  }
1706
- return entryList.filter((e) => !temporary.has(e));
1279
+ return entryList;
1707
1280
  },
1708
1281
  /**
1709
1282
  * Archive comment
1710
1283
  * @return {String}
1711
1284
  */
1712
1285
  get comment() {
1713
- return decoder.decode(_comment);
1286
+ return _comment.toString();
1714
1287
  },
1715
1288
  set comment(val) {
1716
- _comment = Utils.toBuffer(val, decoder.encode);
1717
- mainHeader.commentLength = _comment.length;
1289
+ mainHeader.commentLength = val.length;
1290
+ _comment = val;
1718
1291
  },
1719
1292
  getEntryCount: function() {
1720
1293
  if (!loadedEntries) {
@@ -1723,7 +1296,11 @@ var require_zipFile = __commonJS({
1723
1296
  return entryList.length;
1724
1297
  },
1725
1298
  forEach: function(callback) {
1726
- this.entries.forEach(callback);
1299
+ if (!loadedEntries) {
1300
+ iterateEntries(callback);
1301
+ return;
1302
+ }
1303
+ entryList.forEach(callback);
1727
1304
  },
1728
1305
  /**
1729
1306
  * Returns a reference to the entry with the given name or null if entry is inexistent
@@ -1751,37 +1328,27 @@ var require_zipFile = __commonJS({
1751
1328
  mainHeader.totalEntries = entryList.length;
1752
1329
  },
1753
1330
  /**
1754
- * Removes the file with the given name from the entry list.
1331
+ * Removes the entry with the given name from the entry list.
1755
1332
  *
1756
1333
  * If the entry is a directory, then all nested files and directories will be removed
1757
1334
  * @param entryName
1758
- * @returns {void}
1759
- */
1760
- deleteFile: function(entryName, withsubfolders = true) {
1761
- if (!loadedEntries) {
1762
- readEntries();
1763
- }
1764
- const entry = entryTable[entryName];
1765
- const list = this.getEntryChildren(entry, withsubfolders).map((child) => child.entryName);
1766
- list.forEach(this.deleteEntry);
1767
- },
1768
- /**
1769
- * Removes the entry with the given name from the entry list.
1770
- *
1771
- * @param {string} entryName
1772
- * @returns {void}
1773
1335
  */
1774
1336
  deleteEntry: function(entryName) {
1775
1337
  if (!loadedEntries) {
1776
1338
  readEntries();
1777
1339
  }
1778
- const entry = entryTable[entryName];
1779
- const index = entryList.indexOf(entry);
1780
- if (index >= 0) {
1781
- entryList.splice(index, 1);
1782
- delete entryTable[entryName];
1783
- mainHeader.totalEntries = entryList.length;
1340
+ var entry = entryTable[entryName];
1341
+ if (entry && entry.isDirectory) {
1342
+ var _self = this;
1343
+ this.getEntryChildren(entry).forEach(function(child) {
1344
+ if (child.entryName !== entryName) {
1345
+ _self.deleteEntry(child.entryName);
1346
+ }
1347
+ });
1784
1348
  }
1349
+ entryList.splice(entryList.indexOf(entry), 1);
1350
+ delete entryTable[entryName];
1351
+ mainHeader.totalEntries = entryList.length;
1785
1352
  },
1786
1353
  /**
1787
1354
  * Iterates and returns all nested files and directories of the given entry
@@ -1789,39 +1356,21 @@ var require_zipFile = __commonJS({
1789
1356
  * @param entry
1790
1357
  * @return Array
1791
1358
  */
1792
- getEntryChildren: function(entry, subfolders = true) {
1359
+ getEntryChildren: function(entry) {
1793
1360
  if (!loadedEntries) {
1794
1361
  readEntries();
1795
1362
  }
1796
- if (typeof entry === "object") {
1797
- if (entry.isDirectory && subfolders) {
1798
- const list = [];
1799
- const name = entry.entryName;
1800
- for (const zipEntry of entryList) {
1801
- if (zipEntry.entryName.startsWith(name)) {
1802
- list.push(zipEntry);
1803
- }
1363
+ if (entry.isDirectory) {
1364
+ var list = [], name = entry.entryName, len = name.length;
1365
+ entryList.forEach(function(zipEntry) {
1366
+ if (zipEntry.entryName.substr(0, len) === name) {
1367
+ list.push(zipEntry);
1804
1368
  }
1805
- return list;
1806
- } else {
1807
- return [entry];
1808
- }
1369
+ });
1370
+ return list;
1809
1371
  }
1810
1372
  return [];
1811
1373
  },
1812
- /**
1813
- * How many child elements entry has
1814
- *
1815
- * @param {ZipEntry} entry
1816
- * @return {integer}
1817
- */
1818
- getChildCount: function(entry) {
1819
- if (entry && entry.isDirectory) {
1820
- const list = this.getEntryChildren(entry);
1821
- return list.includes(entry) ? list.length - 1 : list.length;
1822
- }
1823
- return 0;
1824
- },
1825
1374
  /**
1826
1375
  * Returns the zip file
1827
1376
  *
@@ -1831,229 +1380,200 @@ var require_zipFile = __commonJS({
1831
1380
  if (!loadedEntries) {
1832
1381
  readEntries();
1833
1382
  }
1834
- sortEntries();
1835
- const dataBlock = [];
1836
- const headerBlocks = [];
1837
- let totalSize = 0;
1838
- let dindex = 0;
1383
+ if (entryList.length > 1) {
1384
+ entryList.sort(function(a, b) {
1385
+ var nameA = a.entryName.toLowerCase();
1386
+ var nameB = b.entryName.toLowerCase();
1387
+ if (nameA < nameB) {
1388
+ return -1;
1389
+ }
1390
+ if (nameA > nameB) {
1391
+ return 1;
1392
+ }
1393
+ return 0;
1394
+ });
1395
+ }
1396
+ var totalSize = 0, dataBlock = [], entryHeaders = [], dindex = 0;
1839
1397
  mainHeader.size = 0;
1840
1398
  mainHeader.offset = 0;
1841
- let totalEntries = 0;
1842
- for (const entry of this.entries) {
1843
- const compressedData = entry.getCompressedData();
1399
+ entryList.forEach(function(entry) {
1400
+ var compressedData = entry.getCompressedData();
1844
1401
  entry.header.offset = dindex;
1845
- const localHeader = entry.packLocalHeader();
1846
- const dataLength = localHeader.length + compressedData.length;
1402
+ var dataHeader = entry.header.dataHeaderToBinary();
1403
+ var entryNameLen = entry.rawEntryName.length;
1404
+ var extra = entry.extra.toString();
1405
+ var postHeader = Buffer.alloc(entryNameLen + extra.length);
1406
+ entry.rawEntryName.copy(postHeader, 0);
1407
+ postHeader.fill(extra, entryNameLen);
1408
+ var dataLength = dataHeader.length + postHeader.length + compressedData.length;
1847
1409
  dindex += dataLength;
1848
- dataBlock.push(localHeader);
1410
+ dataBlock.push(dataHeader);
1411
+ dataBlock.push(postHeader);
1849
1412
  dataBlock.push(compressedData);
1850
- const centralHeader = entry.packCentralHeader();
1851
- headerBlocks.push(centralHeader);
1852
- mainHeader.size += centralHeader.length;
1853
- totalSize += dataLength + centralHeader.length;
1854
- totalEntries++;
1855
- }
1413
+ var entryHeader = entry.packHeader();
1414
+ entryHeaders.push(entryHeader);
1415
+ mainHeader.size += entryHeader.length;
1416
+ totalSize += dataLength + entryHeader.length;
1417
+ });
1856
1418
  totalSize += mainHeader.mainHeaderSize;
1857
1419
  mainHeader.offset = dindex;
1858
- mainHeader.totalEntries = totalEntries;
1859
1420
  dindex = 0;
1860
- const outBuffer = Buffer.alloc(totalSize);
1861
- for (const content of dataBlock) {
1421
+ var outBuffer = Buffer.alloc(totalSize);
1422
+ dataBlock.forEach(function(content) {
1862
1423
  content.copy(outBuffer, dindex);
1863
1424
  dindex += content.length;
1864
- }
1865
- for (const content of headerBlocks) {
1425
+ });
1426
+ entryHeaders.forEach(function(content) {
1866
1427
  content.copy(outBuffer, dindex);
1867
1428
  dindex += content.length;
1868
- }
1869
- const mh = mainHeader.toBinary();
1429
+ });
1430
+ var mh = mainHeader.toBinary();
1870
1431
  if (_comment) {
1871
- _comment.copy(mh, mh.length - _comment.length);
1432
+ Buffer.from(_comment).copy(mh, Utils.Constants.ENDHDR);
1872
1433
  }
1873
1434
  mh.copy(outBuffer, dindex);
1874
- inBuffer = outBuffer;
1875
- loadedEntries = false;
1876
1435
  return outBuffer;
1877
1436
  },
1878
1437
  toAsyncBuffer: function(onSuccess, onFail, onItemStart, onItemEnd) {
1879
- try {
1880
- if (!loadedEntries) {
1881
- readEntries();
1882
- }
1883
- sortEntries();
1884
- const dataBlock = [];
1885
- const centralHeaders = [];
1886
- let totalSize = 0;
1887
- let dindex = 0;
1888
- let totalEntries = 0;
1889
- mainHeader.size = 0;
1890
- mainHeader.offset = 0;
1891
- const compress2Buffer = function(entryLists) {
1892
- if (entryLists.length > 0) {
1893
- const entry = entryLists.shift();
1894
- const name = entry.entryName + entry.extra.toString();
1895
- if (onItemStart) onItemStart(name);
1896
- entry.getCompressedDataAsync(function(compressedData) {
1897
- if (onItemEnd) onItemEnd(name);
1898
- entry.header.offset = dindex;
1899
- const localHeader = entry.packLocalHeader();
1900
- const dataLength = localHeader.length + compressedData.length;
1901
- dindex += dataLength;
1902
- dataBlock.push(localHeader);
1903
- dataBlock.push(compressedData);
1904
- const centalHeader = entry.packCentralHeader();
1905
- centralHeaders.push(centalHeader);
1906
- mainHeader.size += centalHeader.length;
1907
- totalSize += dataLength + centalHeader.length;
1908
- totalEntries++;
1909
- compress2Buffer(entryLists);
1910
- });
1911
- } else {
1912
- totalSize += mainHeader.mainHeaderSize;
1913
- mainHeader.offset = dindex;
1914
- mainHeader.totalEntries = totalEntries;
1915
- dindex = 0;
1916
- const outBuffer = Buffer.alloc(totalSize);
1917
- dataBlock.forEach(function(content) {
1918
- content.copy(outBuffer, dindex);
1919
- dindex += content.length;
1920
- });
1921
- centralHeaders.forEach(function(content) {
1922
- content.copy(outBuffer, dindex);
1923
- dindex += content.length;
1924
- });
1925
- const mh = mainHeader.toBinary();
1926
- if (_comment) {
1927
- _comment.copy(mh, mh.length - _comment.length);
1928
- }
1929
- mh.copy(outBuffer, dindex);
1930
- inBuffer = outBuffer;
1931
- loadedEntries = false;
1932
- onSuccess(outBuffer);
1438
+ if (!loadedEntries) {
1439
+ readEntries();
1440
+ }
1441
+ if (entryList.length > 1) {
1442
+ entryList.sort(function(a, b) {
1443
+ var nameA = a.entryName.toLowerCase();
1444
+ var nameB = b.entryName.toLowerCase();
1445
+ if (nameA > nameB) {
1446
+ return -1;
1933
1447
  }
1934
- };
1935
- compress2Buffer(Array.from(this.entries));
1936
- } catch (e) {
1937
- onFail(e);
1448
+ if (nameA < nameB) {
1449
+ return 1;
1450
+ }
1451
+ return 0;
1452
+ });
1938
1453
  }
1454
+ var totalSize = 0, dataBlock = [], entryHeaders = [], dindex = 0;
1455
+ mainHeader.size = 0;
1456
+ mainHeader.offset = 0;
1457
+ var compress = function(entryList2) {
1458
+ var self = arguments.callee;
1459
+ if (entryList2.length) {
1460
+ var entry = entryList2.pop();
1461
+ var name = entry.entryName + entry.extra.toString();
1462
+ if (onItemStart) onItemStart(name);
1463
+ entry.getCompressedDataAsync(function(compressedData) {
1464
+ if (onItemEnd) onItemEnd(name);
1465
+ entry.header.offset = dindex;
1466
+ var dataHeader = entry.header.dataHeaderToBinary();
1467
+ var postHeader;
1468
+ try {
1469
+ postHeader = Buffer.alloc(name.length, name);
1470
+ } catch (e) {
1471
+ postHeader = new Buffer(name);
1472
+ }
1473
+ var dataLength = dataHeader.length + postHeader.length + compressedData.length;
1474
+ dindex += dataLength;
1475
+ dataBlock.push(dataHeader);
1476
+ dataBlock.push(postHeader);
1477
+ dataBlock.push(compressedData);
1478
+ var entryHeader = entry.packHeader();
1479
+ entryHeaders.push(entryHeader);
1480
+ mainHeader.size += entryHeader.length;
1481
+ totalSize += dataLength + entryHeader.length;
1482
+ if (entryList2.length) {
1483
+ self(entryList2);
1484
+ } else {
1485
+ totalSize += mainHeader.mainHeaderSize;
1486
+ mainHeader.offset = dindex;
1487
+ dindex = 0;
1488
+ var outBuffer = Buffer.alloc(totalSize);
1489
+ dataBlock.forEach(function(content) {
1490
+ content.copy(outBuffer, dindex);
1491
+ dindex += content.length;
1492
+ });
1493
+ entryHeaders.forEach(function(content) {
1494
+ content.copy(outBuffer, dindex);
1495
+ dindex += content.length;
1496
+ });
1497
+ var mh = mainHeader.toBinary();
1498
+ if (_comment) {
1499
+ _comment.copy(mh, Utils.Constants.ENDHDR);
1500
+ }
1501
+ mh.copy(outBuffer, dindex);
1502
+ onSuccess(outBuffer);
1503
+ }
1504
+ });
1505
+ }
1506
+ };
1507
+ compress(entryList);
1939
1508
  }
1940
1509
  };
1941
1510
  };
1942
1511
  }
1943
1512
  });
1944
1513
 
1945
- // node_modules/adm-zip/adm-zip.js
1514
+ // ../../node_modules/adm-zip/adm-zip.js
1946
1515
  var require_adm_zip = __commonJS({
1947
- "node_modules/adm-zip/adm-zip.js"(exports, module) {
1516
+ "../../node_modules/adm-zip/adm-zip.js"(exports, module) {
1948
1517
  var Utils = require_util();
1518
+ var fs10 = Utils.FileSystem.require();
1949
1519
  var pth = __require("path");
1520
+ fs10.existsSync = fs10.existsSync || pth.existsSync;
1950
1521
  var ZipEntry = require_zipEntry();
1951
1522
  var ZipFile = require_zipFile();
1952
- var get_Bool = (...val) => Utils.findLast(val, (c) => typeof c === "boolean");
1953
- var get_Str = (...val) => Utils.findLast(val, (c) => typeof c === "string");
1954
- var get_Fun = (...val) => Utils.findLast(val, (c) => typeof c === "function");
1955
- var defaultOptions = {
1956
- // option "noSort" : if true it disables files sorting
1957
- noSort: false,
1958
- // read entries during load (initial loading may be slower)
1959
- readEntries: false,
1960
- // default method is none
1961
- method: Utils.Constants.NONE,
1962
- // file system
1963
- fs: null
1964
- };
1965
- module.exports = function(input, options) {
1966
- let inBuffer = null;
1967
- const opts = Object.assign(/* @__PURE__ */ Object.create(null), defaultOptions);
1968
- if (input && "object" === typeof input) {
1969
- if (!(input instanceof Uint8Array)) {
1970
- Object.assign(opts, input);
1971
- input = opts.input ? opts.input : void 0;
1972
- if (opts.input) delete opts.input;
1973
- }
1974
- if (Buffer.isBuffer(input)) {
1975
- inBuffer = input;
1976
- opts.method = Utils.Constants.BUFFER;
1977
- input = void 0;
1978
- }
1979
- }
1980
- Object.assign(opts, options);
1981
- const filetools = new Utils(opts);
1982
- const applyDirAttributes = (dirEntries) => {
1983
- dirEntries.filter((d) => d.attr).sort((a, b) => b.path.length - a.path.length).forEach((d) => filetools.fs.chmodSync(d.path, d.attr));
1984
- };
1985
- if (typeof opts.decoder !== "object" || typeof opts.decoder.encode !== "function" || typeof opts.decoder.decode !== "function") {
1986
- opts.decoder = Utils.decoder;
1987
- }
1988
- if (input && "string" === typeof input) {
1989
- if (filetools.fs.existsSync(input)) {
1990
- opts.method = Utils.Constants.FILE;
1991
- opts.filename = input;
1992
- inBuffer = filetools.fs.readFileSync(input);
1523
+ var isWin = /^win/.test(process.platform);
1524
+ module.exports = function(input) {
1525
+ var _zip = void 0, _filename = "";
1526
+ if (input && typeof input === "string") {
1527
+ if (fs10.existsSync(input)) {
1528
+ _filename = input;
1529
+ _zip = new ZipFile(input, Utils.Constants.FILE);
1993
1530
  } else {
1994
- throw Utils.Errors.INVALID_FILENAME();
1531
+ throw new Error(Utils.Errors.INVALID_FILENAME);
1995
1532
  }
1533
+ } else if (input && Buffer.isBuffer(input)) {
1534
+ _zip = new ZipFile(input, Utils.Constants.BUFFER);
1535
+ } else {
1536
+ _zip = new ZipFile(null, Utils.Constants.NONE);
1537
+ }
1538
+ function sanitize(prefix, name) {
1539
+ prefix = pth.resolve(pth.normalize(prefix));
1540
+ var parts = name.split("/");
1541
+ for (var i = 0, l = parts.length; i < l; i++) {
1542
+ var path12 = pth.normalize(pth.join(prefix, parts.slice(i, l).join(pth.sep)));
1543
+ if (path12.indexOf(prefix) === 0) {
1544
+ return path12;
1545
+ }
1546
+ }
1547
+ return pth.normalize(pth.join(prefix, pth.basename(name)));
1996
1548
  }
1997
- const _zip = new ZipFile(inBuffer, opts);
1998
- const { canonical, sanitize, zipnamefix } = Utils;
1999
1549
  function getEntry(entry) {
2000
1550
  if (entry && _zip) {
2001
1551
  var item;
2002
- if (typeof entry === "string") item = _zip.getEntry(pth.posix.normalize(entry));
2003
- if (typeof entry === "object" && typeof entry.entryName !== "undefined" && typeof entry.header !== "undefined") item = _zip.getEntry(entry.entryName);
1552
+ if (typeof entry === "string")
1553
+ item = _zip.getEntry(entry);
1554
+ if (typeof entry === "object" && typeof entry.entryName !== "undefined" && typeof entry.header !== "undefined")
1555
+ item = _zip.getEntry(entry.entryName);
2004
1556
  if (item) {
2005
1557
  return item;
2006
1558
  }
2007
1559
  }
2008
1560
  return null;
2009
1561
  }
2010
- function fixPath(zipPath) {
2011
- const { join, normalize, sep } = pth.posix;
2012
- return join(pth.isAbsolute(zipPath) ? "/" : ".", normalize(sep + zipPath.split("\\").join(sep) + sep));
2013
- }
2014
- function filenameFilter(filterfn) {
2015
- if (filterfn instanceof RegExp) {
2016
- return /* @__PURE__ */ (function(rx) {
2017
- return function(filename) {
2018
- return rx.test(filename);
2019
- };
2020
- })(filterfn);
2021
- } else if ("function" !== typeof filterfn) {
2022
- return () => true;
2023
- }
2024
- return filterfn;
2025
- }
2026
- const relativePath = (local, entry) => {
2027
- let lastChar = entry.slice(-1);
2028
- lastChar = lastChar === filetools.sep ? filetools.sep : "";
2029
- return pth.relative(local, entry) + lastChar;
2030
- };
2031
1562
  return {
2032
1563
  /**
2033
1564
  * Extracts the given entry from the archive and returns the content as a Buffer object
2034
- * @param {ZipEntry|string} entry ZipEntry object or String with the full path of the entry
2035
- * @param {Buffer|string} [pass] - password
1565
+ * @param entry ZipEntry object or String with the full path of the entry
1566
+ *
2036
1567
  * @return Buffer or Null in case of error
2037
1568
  */
2038
- readFile: function(entry, pass) {
1569
+ readFile: function(entry) {
2039
1570
  var item = getEntry(entry);
2040
- return item && item.getData(pass) || null;
2041
- },
2042
- /**
2043
- * Returns how many child elements has on entry (directories) on files it is always 0
2044
- * @param {ZipEntry|string} entry ZipEntry object or String with the full path of the entry
2045
- * @returns {integer}
2046
- */
2047
- childCount: function(entry) {
2048
- const item = getEntry(entry);
2049
- if (item) {
2050
- return _zip.getChildCount(item);
2051
- }
1571
+ return item && item.getData() || null;
2052
1572
  },
2053
1573
  /**
2054
1574
  * Asynchronous readFile
2055
- * @param {ZipEntry|string} entry ZipEntry object or String with the full path of the entry
2056
- * @param {callback} callback
1575
+ * @param entry ZipEntry object or String with the full path of the entry
1576
+ * @param callback
2057
1577
  *
2058
1578
  * @return Buffer or Null in case of error
2059
1579
  */
@@ -2067,8 +1587,8 @@ var require_adm_zip = __commonJS({
2067
1587
  },
2068
1588
  /**
2069
1589
  * Extracts the given entry from the archive and returns the content as plain text in the given encoding
2070
- * @param {ZipEntry|string} entry - ZipEntry object or String with the full path of the entry
2071
- * @param {string} encoding - Optional. If no encoding is specified utf8 is used
1590
+ * @param entry ZipEntry object or String with the full path of the entry
1591
+ * @param encoding Optional. If no encoding is specified utf8 is used
2072
1592
  *
2073
1593
  * @return String
2074
1594
  */
@@ -2084,9 +1604,9 @@ var require_adm_zip = __commonJS({
2084
1604
  },
2085
1605
  /**
2086
1606
  * Asynchronous readAsText
2087
- * @param {ZipEntry|string} entry ZipEntry object or String with the full path of the entry
2088
- * @param {callback} callback
2089
- * @param {string} [encoding] - Optional. If no encoding is specified utf8 is used
1607
+ * @param entry ZipEntry object or String with the full path of the entry
1608
+ * @param callback
1609
+ * @param encoding Optional. If no encoding is specified utf8 is used
2090
1610
  *
2091
1611
  * @return String
2092
1612
  */
@@ -2111,23 +1631,9 @@ var require_adm_zip = __commonJS({
2111
1631
  /**
2112
1632
  * Remove the entry from the file or the entry and all it's nested directories and files if the given entry is a directory
2113
1633
  *
2114
- * @param {ZipEntry|string} entry
2115
- * @param {boolean} withsubfolders
2116
- * @returns {void}
2117
- */
2118
- deleteFile: function(entry, withsubfolders = true) {
2119
- var item = getEntry(entry);
2120
- if (item) {
2121
- _zip.deleteFile(item.entryName, withsubfolders);
2122
- }
2123
- },
2124
- /**
2125
- * Remove the entry from the file or directory without affecting any nested entries
2126
- *
2127
- * @param {ZipEntry|string} entry
2128
- * @returns {void}
1634
+ * @param entry
2129
1635
  */
2130
- deleteEntry: function(entry) {
1636
+ deleteFile: function(entry) {
2131
1637
  var item = getEntry(entry);
2132
1638
  if (item) {
2133
1639
  _zip.deleteEntry(item.entryName);
@@ -2136,7 +1642,7 @@ var require_adm_zip = __commonJS({
2136
1642
  /**
2137
1643
  * Adds a comment to the zip. The zip must be rewritten after adding the comment.
2138
1644
  *
2139
- * @param {string} comment
1645
+ * @param comment
2140
1646
  */
2141
1647
  addZipComment: function(comment) {
2142
1648
  _zip.comment = comment;
@@ -2153,8 +1659,8 @@ var require_adm_zip = __commonJS({
2153
1659
  * Adds a comment to a specified zipEntry. The zip must be rewritten after adding the comment
2154
1660
  * The comment cannot exceed 65535 characters in length
2155
1661
  *
2156
- * @param {ZipEntry} entry
2157
- * @param {string} comment
1662
+ * @param entry
1663
+ * @param comment
2158
1664
  */
2159
1665
  addZipEntryComment: function(entry, comment) {
2160
1666
  var item = getEntry(entry);
@@ -2165,7 +1671,7 @@ var require_adm_zip = __commonJS({
2165
1671
  /**
2166
1672
  * Returns the comment of the specified entry
2167
1673
  *
2168
- * @param {ZipEntry} entry
1674
+ * @param entry
2169
1675
  * @return String
2170
1676
  */
2171
1677
  getZipEntryComment: function(entry) {
@@ -2178,8 +1684,8 @@ var require_adm_zip = __commonJS({
2178
1684
  /**
2179
1685
  * Updates the content of an existing entry inside the archive. The zip must be rewritten after updating the content
2180
1686
  *
2181
- * @param {ZipEntry} entry
2182
- * @param {Buffer} content
1687
+ * @param entry
1688
+ * @param content
2183
1689
  */
2184
1690
  updateFile: function(entry, content) {
2185
1691
  var item = getEntry(entry);
@@ -2190,139 +1696,142 @@ var require_adm_zip = __commonJS({
2190
1696
  /**
2191
1697
  * Adds a file from the disk to the archive
2192
1698
  *
2193
- * @param {string} localPath File to add to zip
2194
- * @param {string} [zipPath] Optional path inside the zip
2195
- * @param {string} [zipName] Optional name for the file
2196
- * @param {string} [comment] Optional file comment
1699
+ * @param localPath File to add to zip
1700
+ * @param zipPath Optional path inside the zip
1701
+ * @param zipName Optional name for the file
2197
1702
  */
2198
- addLocalFile: function(localPath, zipPath, zipName, comment) {
2199
- if (filetools.fs.existsSync(localPath)) {
2200
- zipPath = zipPath ? fixPath(zipPath) : "";
2201
- const p = pth.win32.basename(pth.win32.normalize(localPath));
2202
- zipPath += zipName ? zipName : p;
2203
- const _attr = filetools.fs.statSync(localPath);
2204
- const data = _attr.isFile() ? filetools.fs.readFileSync(localPath) : Buffer.alloc(0);
2205
- if (_attr.isDirectory()) zipPath += filetools.sep;
2206
- this.addFile(zipPath, data, comment, _attr);
1703
+ addLocalFile: function(localPath, zipPath, zipName) {
1704
+ if (fs10.existsSync(localPath)) {
1705
+ if (zipPath) {
1706
+ zipPath = zipPath.split("\\").join("/");
1707
+ if (zipPath.charAt(zipPath.length - 1) !== "/") {
1708
+ zipPath += "/";
1709
+ }
1710
+ } else {
1711
+ zipPath = "";
1712
+ }
1713
+ var p = localPath.split("\\").join("/").split("/").pop();
1714
+ if (zipName) {
1715
+ this.addFile(zipPath + zipName, fs10.readFileSync(localPath), "", 0);
1716
+ } else {
1717
+ this.addFile(zipPath + p, fs10.readFileSync(localPath), "", 0);
1718
+ }
2207
1719
  } else {
2208
- throw Utils.Errors.FILE_NOT_FOUND(localPath);
1720
+ throw new Error(Utils.Errors.FILE_NOT_FOUND.replace("%s", localPath));
2209
1721
  }
2210
1722
  },
2211
- /**
2212
- * Callback for showing if everything was done.
2213
- *
2214
- * @callback doneCallback
2215
- * @param {Error} err - Error object
2216
- * @param {boolean} done - was request fully completed
2217
- */
2218
- /**
2219
- * Adds a file from the disk to the archive
2220
- *
2221
- * @param {(object|string)} options - options object, if it is string it us used as localPath.
2222
- * @param {string} options.localPath - Local path to the file.
2223
- * @param {string} [options.comment] - Optional file comment.
2224
- * @param {string} [options.zipPath] - Optional path inside the zip
2225
- * @param {string} [options.zipName] - Optional name for the file
2226
- * @param {doneCallback} callback - The callback that handles the response.
2227
- */
2228
- addLocalFileAsync: function(options2, callback) {
2229
- options2 = typeof options2 === "object" ? options2 : { localPath: options2 };
2230
- const localPath = pth.resolve(options2.localPath);
2231
- const { comment } = options2;
2232
- let { zipPath, zipName } = options2;
2233
- const self = this;
2234
- filetools.fs.stat(localPath, function(err, stats) {
2235
- if (err) return callback(err, false);
2236
- zipPath = zipPath ? fixPath(zipPath) : "";
2237
- const p = pth.win32.basename(pth.win32.normalize(localPath));
2238
- zipPath += zipName ? zipName : p;
2239
- if (stats.isFile()) {
2240
- filetools.fs.readFile(localPath, function(err2, data) {
2241
- if (err2) return callback(err2, false);
2242
- self.addFile(zipPath, data, comment, stats);
2243
- return setImmediate(callback, void 0, true);
2244
- });
2245
- } else if (stats.isDirectory()) {
2246
- zipPath += filetools.sep;
2247
- self.addFile(zipPath, Buffer.alloc(0), comment, stats);
2248
- return setImmediate(callback, void 0, true);
2249
- }
2250
- });
2251
- },
2252
1723
  /**
2253
1724
  * Adds a local directory and all its nested files and directories to the archive
2254
1725
  *
2255
- * @param {string} localPath - local path to the folder
2256
- * @param {string} [zipPath] - optional path inside zip
2257
- * @param {(RegExp|function)} [filter] - optional RegExp or Function if files match will be included.
1726
+ * @param localPath
1727
+ * @param zipPath optional path inside zip
1728
+ * @param filter optional RegExp or Function if files match will
1729
+ * be included.
2258
1730
  */
2259
1731
  addLocalFolder: function(localPath, zipPath, filter) {
2260
- filter = filenameFilter(filter);
2261
- zipPath = zipPath ? fixPath(zipPath) : "";
1732
+ if (filter === void 0) {
1733
+ filter = function() {
1734
+ return true;
1735
+ };
1736
+ } else if (filter instanceof RegExp) {
1737
+ filter = /* @__PURE__ */ (function(filter2) {
1738
+ return function(filename) {
1739
+ return filter2.test(filename);
1740
+ };
1741
+ })(filter);
1742
+ }
1743
+ if (zipPath) {
1744
+ zipPath = zipPath.split("\\").join("/");
1745
+ if (zipPath.charAt(zipPath.length - 1) !== "/") {
1746
+ zipPath += "/";
1747
+ }
1748
+ } else {
1749
+ zipPath = "";
1750
+ }
2262
1751
  localPath = pth.normalize(localPath);
2263
- if (filetools.fs.existsSync(localPath)) {
2264
- const items = filetools.findFiles(localPath);
2265
- const self = this;
1752
+ localPath = localPath.split("\\").join("/");
1753
+ if (localPath.charAt(localPath.length - 1) !== "/")
1754
+ localPath += "/";
1755
+ if (fs10.existsSync(localPath)) {
1756
+ var items = Utils.findFiles(localPath), self = this;
2266
1757
  if (items.length) {
2267
- for (const filepath of items) {
2268
- const p = pth.join(zipPath, relativePath(localPath, filepath));
1758
+ items.forEach(function(path12) {
1759
+ var p = path12.split("\\").join("/").replace(new RegExp(localPath.replace(/(\(|\)|\$)/g, "\\$1"), "i"), "");
2269
1760
  if (filter(p)) {
2270
- self.addLocalFile(filepath, pth.dirname(p));
1761
+ if (p.charAt(p.length - 1) !== "/") {
1762
+ self.addFile(zipPath + p, fs10.readFileSync(path12), "", 0);
1763
+ } else {
1764
+ self.addFile(zipPath + p, Buffer.alloc(0), "", 0);
1765
+ }
2271
1766
  }
2272
- }
1767
+ });
2273
1768
  }
2274
1769
  } else {
2275
- throw Utils.Errors.FILE_NOT_FOUND(localPath);
1770
+ throw new Error(Utils.Errors.FILE_NOT_FOUND.replace("%s", localPath));
2276
1771
  }
2277
1772
  },
2278
1773
  /**
2279
- * Asynchronous addLocalFolder
2280
- * @param {string} localPath
2281
- * @param {callback} callback
2282
- * @param {string} [zipPath] optional path inside zip
2283
- * @param {RegExp|function} [filter] optional RegExp or Function if files match will
1774
+ * Asynchronous addLocalFile
1775
+ * @param localPath
1776
+ * @param callback
1777
+ * @param zipPath optional path inside zip
1778
+ * @param filter optional RegExp or Function if files match will
2284
1779
  * be included.
2285
1780
  */
2286
1781
  addLocalFolderAsync: function(localPath, callback, zipPath, filter) {
2287
- filter = filenameFilter(filter);
2288
- zipPath = zipPath ? fixPath(zipPath) : "";
1782
+ if (filter === void 0) {
1783
+ filter = function() {
1784
+ return true;
1785
+ };
1786
+ } else if (filter instanceof RegExp) {
1787
+ filter = /* @__PURE__ */ (function(filter2) {
1788
+ return function(filename) {
1789
+ return filter2.test(filename);
1790
+ };
1791
+ })(filter);
1792
+ }
1793
+ if (zipPath) {
1794
+ zipPath = zipPath.split("\\").join("/");
1795
+ if (zipPath.charAt(zipPath.length - 1) !== "/") {
1796
+ zipPath += "/";
1797
+ }
1798
+ } else {
1799
+ zipPath = "";
1800
+ }
2289
1801
  localPath = pth.normalize(localPath);
1802
+ localPath = localPath.split("\\").join("/");
1803
+ if (localPath.charAt(localPath.length - 1) !== "/")
1804
+ localPath += "/";
2290
1805
  var self = this;
2291
- filetools.fs.open(localPath, "r", function(err) {
1806
+ fs10.open(localPath, "r", function(err, fd) {
2292
1807
  if (err && err.code === "ENOENT") {
2293
- callback(void 0, Utils.Errors.FILE_NOT_FOUND(localPath));
1808
+ callback(void 0, Utils.Errors.FILE_NOT_FOUND.replace("%s", localPath));
2294
1809
  } else if (err) {
2295
1810
  callback(void 0, err);
2296
1811
  } else {
2297
- var items = filetools.findFiles(localPath);
1812
+ var items = Utils.findFiles(localPath);
2298
1813
  var i = -1;
2299
1814
  var next = function() {
2300
1815
  i += 1;
2301
1816
  if (i < items.length) {
2302
- var filepath = items[i];
2303
- var p = relativePath(localPath, filepath).split("\\").join("/");
1817
+ var p = items[i].split("\\").join("/").replace(new RegExp(localPath.replace(/(\(|\))/g, "\\$1"), "i"), "");
2304
1818
  p = p.normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^\x20-\x7E]/g, "");
2305
1819
  if (filter(p)) {
2306
- filetools.fs.stat(filepath, function(er0, stats) {
2307
- if (er0) callback(void 0, er0);
2308
- if (stats.isFile()) {
2309
- filetools.fs.readFile(filepath, function(er1, data) {
2310
- if (er1) {
2311
- callback(void 0, er1);
2312
- } else {
2313
- self.addFile(zipPath + p, data, "", stats);
2314
- next();
2315
- }
2316
- });
2317
- } else {
2318
- self.addFile(zipPath + p + "/", Buffer.alloc(0), "", stats);
2319
- next();
2320
- }
2321
- });
2322
- } else {
2323
- process.nextTick(() => {
1820
+ if (p.charAt(p.length - 1) !== "/") {
1821
+ fs10.readFile(items[i], function(err2, data) {
1822
+ if (err2) {
1823
+ callback(void 0, err2);
1824
+ } else {
1825
+ self.addFile(zipPath + p, data, "", 0);
1826
+ next();
1827
+ }
1828
+ });
1829
+ } else {
1830
+ self.addFile(zipPath + p, Buffer.alloc(0), "", 0);
2324
1831
  next();
2325
- });
1832
+ }
1833
+ } else {
1834
+ next();
2326
1835
  }
2327
1836
  } else {
2328
1837
  callback(true, void 0);
@@ -2332,138 +1841,47 @@ var require_adm_zip = __commonJS({
2332
1841
  }
2333
1842
  });
2334
1843
  },
2335
- /**
2336
- * Adds a local directory and all its nested files and directories to the archive
2337
- *
2338
- * @param {object | string} options - options object, if it is string it us used as localPath.
2339
- * @param {string} options.localPath - Local path to the folder.
2340
- * @param {string} [options.zipPath] - optional path inside zip.
2341
- * @param {RegExp|function} [options.filter] - optional RegExp or Function if files match will be included.
2342
- * @param {function|string} [options.namefix] - optional function to help fix filename
2343
- * @param {doneCallback} callback - The callback that handles the response.
2344
- *
2345
- */
2346
- addLocalFolderAsync2: function(options2, callback) {
2347
- const self = this;
2348
- options2 = typeof options2 === "object" ? options2 : { localPath: options2 };
2349
- const localPath = pth.resolve(fixPath(options2.localPath));
2350
- let { zipPath, filter, namefix } = options2;
2351
- if (filter instanceof RegExp) {
2352
- filter = /* @__PURE__ */ (function(rx) {
2353
- return function(filename) {
2354
- return rx.test(filename);
2355
- };
2356
- })(filter);
2357
- } else if ("function" !== typeof filter) {
2358
- filter = function() {
2359
- return true;
2360
- };
2361
- }
2362
- zipPath = zipPath ? fixPath(zipPath) : "";
2363
- if (namefix === "latin1") {
2364
- namefix = (str) => str.normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^\x20-\x7E]/g, "");
2365
- }
2366
- if (typeof namefix !== "function") namefix = (str) => str;
2367
- const relPathFix = (entry) => pth.join(zipPath, namefix(relativePath(localPath, entry)));
2368
- const fileNameFix = (entry) => pth.win32.basename(pth.win32.normalize(namefix(entry)));
2369
- filetools.fs.open(localPath, "r", function(err) {
2370
- if (err && err.code === "ENOENT") {
2371
- callback(void 0, Utils.Errors.FILE_NOT_FOUND(localPath));
2372
- } else if (err) {
2373
- callback(void 0, err);
2374
- } else {
2375
- filetools.findFilesAsync(localPath, function(err2, fileEntries) {
2376
- if (err2) return callback(err2);
2377
- fileEntries = fileEntries.filter((dir) => filter(relPathFix(dir)));
2378
- if (!fileEntries.length) callback(void 0, false);
2379
- setImmediate(
2380
- fileEntries.reverse().reduce(function(next, entry) {
2381
- return function(err3, done) {
2382
- if (err3 || done === false) return setImmediate(next, err3, false);
2383
- self.addLocalFileAsync(
2384
- {
2385
- localPath: entry,
2386
- zipPath: pth.dirname(relPathFix(entry)),
2387
- zipName: fileNameFix(entry)
2388
- },
2389
- next
2390
- );
2391
- };
2392
- }, callback)
2393
- );
2394
- });
2395
- }
2396
- });
2397
- },
2398
- /**
2399
- * Adds a local directory and all its nested files and directories to the archive
2400
- *
2401
- * @param {string} localPath - path where files will be extracted
2402
- * @param {object} props - optional properties
2403
- * @param {string} [props.zipPath] - optional path inside zip
2404
- * @param {RegExp|function} [props.filter] - optional RegExp or Function if files match will be included.
2405
- * @param {function|string} [props.namefix] - optional function to help fix filename
2406
- */
2407
- addLocalFolderPromise: function(localPath, props) {
2408
- return new Promise((resolve, reject) => {
2409
- this.addLocalFolderAsync2(Object.assign({ localPath }, props), (err, done) => {
2410
- if (err) reject(err);
2411
- if (done) resolve(this);
2412
- });
2413
- });
2414
- },
2415
1844
  /**
2416
1845
  * Allows you to create a entry (file or directory) in the zip file.
2417
1846
  * If you want to create a directory the entryName must end in / and a null buffer should be provided.
2418
1847
  * Comment and attributes are optional
2419
1848
  *
2420
- * @param {string} entryName
2421
- * @param {Buffer | string} content - file content as buffer or utf8 coded string
2422
- * @param {string} [comment] - file comment
2423
- * @param {number | object} [attr] - number as unix file permissions, object as filesystem Stats object
1849
+ * @param entryName
1850
+ * @param content
1851
+ * @param comment
1852
+ * @param attr
2424
1853
  */
2425
1854
  addFile: function(entryName, content, comment, attr) {
2426
- entryName = zipnamefix(entryName);
2427
- let entry = getEntry(entryName);
2428
- const update = entry != null;
2429
- if (!update) {
2430
- entry = new ZipEntry(opts);
2431
- entry.entryName = entryName;
2432
- }
1855
+ var entry = new ZipEntry();
1856
+ entry.entryName = entryName;
2433
1857
  entry.comment = comment || "";
2434
- const isStat = "object" === typeof attr && attr instanceof filetools.fs.Stats;
2435
- if (isStat) {
2436
- entry.header.time = attr.mtime;
2437
- }
2438
- var fileattr = entry.isDirectory ? 16 : 0;
2439
- let unix = entry.isDirectory ? 16384 : 32768;
2440
- if (isStat) {
2441
- unix |= 4095 & attr.mode;
2442
- } else if ("number" === typeof attr) {
2443
- unix |= 4095 & attr;
2444
- } else {
2445
- unix |= entry.isDirectory ? 493 : 420;
1858
+ if (!attr) {
1859
+ if (entry.isDirectory) {
1860
+ attr = 16877 << 16 | 16;
1861
+ } else {
1862
+ attr = 420 << 16;
1863
+ }
2446
1864
  }
2447
- fileattr = (fileattr | unix << 16) >>> 0;
2448
- entry.attr = fileattr;
1865
+ entry.attr = attr;
2449
1866
  entry.setData(content);
2450
- if (!update) _zip.setEntry(entry);
2451
- return entry;
1867
+ _zip.setEntry(entry);
2452
1868
  },
2453
1869
  /**
2454
1870
  * Returns an array of ZipEntry objects representing the files and folders inside the archive
2455
1871
  *
2456
- * @param {string} [password]
2457
- * @returns Array
1872
+ * @return Array
2458
1873
  */
2459
- getEntries: function(password) {
2460
- _zip.password = password;
2461
- return _zip ? _zip.entries : [];
1874
+ getEntries: function() {
1875
+ if (_zip) {
1876
+ return _zip.entries;
1877
+ } else {
1878
+ return [];
1879
+ }
2462
1880
  },
2463
1881
  /**
2464
1882
  * Returns a ZipEntry object representing the file or folder specified by ``name``.
2465
1883
  *
2466
- * @param {string} name
1884
+ * @param name
2467
1885
  * @return ZipEntry
2468
1886
  */
2469
1887
  getEntry: function(name) {
@@ -2479,64 +1897,60 @@ var require_adm_zip = __commonJS({
2479
1897
  * Extracts the given entry to the given targetPath
2480
1898
  * If the entry is a directory inside the archive, the entire directory and it's subdirectories will be extracted
2481
1899
  *
2482
- * @param {string|ZipEntry} entry - ZipEntry object or String with the full path of the entry
2483
- * @param {string} targetPath - Target folder where to write the file
2484
- * @param {boolean} [maintainEntryPath=true] - If maintainEntryPath is true and the entry is inside a folder, the entry folder will be created in targetPath as well. Default is TRUE
2485
- * @param {boolean} [overwrite=false] - If the file already exists at the target path, the file will be overwriten if this is true.
2486
- * @param {boolean} [keepOriginalPermission=false] - The file will be set as the permission from the entry if this is true.
2487
- * @param {string} [outFileName] - String If set will override the filename of the extracted file (Only works if the entry is a file)
1900
+ * @param entry ZipEntry object or String with the full path of the entry
1901
+ * @param targetPath Target folder where to write the file
1902
+ * @param maintainEntryPath If maintainEntryPath is true and the entry is inside a folder, the entry folder
1903
+ * will be created in targetPath as well. Default is TRUE
1904
+ * @param overwrite If the file already exists at the target path, the file will be overwriten if this is true.
1905
+ * Default is FALSE
2488
1906
  *
2489
1907
  * @return Boolean
2490
1908
  */
2491
- extractEntryTo: function(entry, targetPath, maintainEntryPath, overwrite, keepOriginalPermission, outFileName) {
2492
- overwrite = get_Bool(false, overwrite);
2493
- keepOriginalPermission = get_Bool(false, keepOriginalPermission);
2494
- maintainEntryPath = get_Bool(true, maintainEntryPath);
2495
- outFileName = get_Str(keepOriginalPermission, outFileName);
1909
+ extractEntryTo: function(entry, targetPath, maintainEntryPath, overwrite) {
1910
+ overwrite = overwrite || false;
1911
+ maintainEntryPath = typeof maintainEntryPath === "undefined" ? true : maintainEntryPath;
2496
1912
  var item = getEntry(entry);
2497
1913
  if (!item) {
2498
- throw Utils.Errors.NO_ENTRY();
1914
+ throw new Error(Utils.Errors.NO_ENTRY);
2499
1915
  }
2500
- var entryName = canonical(item.entryName);
2501
- var target = sanitize(targetPath, outFileName && !item.isDirectory ? canonical(outFileName) : maintainEntryPath ? entryName : pth.basename(entryName));
1916
+ var entryName = item.entryName;
1917
+ var target = sanitize(targetPath, maintainEntryPath ? entryName : pth.basename(entryName));
2502
1918
  if (item.isDirectory) {
1919
+ target = pth.resolve(target, "..");
2503
1920
  var children = _zip.getEntryChildren(item);
2504
1921
  children.forEach(function(child) {
2505
1922
  if (child.isDirectory) return;
2506
1923
  var content2 = child.getData();
2507
1924
  if (!content2) {
2508
- throw Utils.Errors.CANT_EXTRACT_FILE();
1925
+ throw new Error(Utils.Errors.CANT_EXTRACT_FILE);
2509
1926
  }
2510
- var name = canonical(maintainEntryPath ? child.entryName : child.entryName.substring(item.entryName.length));
2511
- var childName = sanitize(targetPath, name);
2512
- const fileAttr2 = keepOriginalPermission ? child.header.fileAttr : void 0;
2513
- filetools.writeFileTo(childName, content2, overwrite, fileAttr2);
1927
+ var childName = sanitize(targetPath, maintainEntryPath ? child.entryName : pth.basename(child.entryName));
1928
+ Utils.writeFileTo(childName, content2, overwrite);
2514
1929
  });
2515
1930
  return true;
2516
1931
  }
2517
- var content = item.getData(_zip.password);
2518
- if (!content) throw Utils.Errors.CANT_EXTRACT_FILE();
2519
- if (filetools.fs.existsSync(target) && !overwrite) {
2520
- throw Utils.Errors.CANT_OVERRIDE();
1932
+ var content = item.getData();
1933
+ if (!content) throw new Error(Utils.Errors.CANT_EXTRACT_FILE);
1934
+ if (fs10.existsSync(target) && !overwrite) {
1935
+ throw new Error(Utils.Errors.CANT_OVERRIDE);
2521
1936
  }
2522
- const fileAttr = keepOriginalPermission ? entry.header.fileAttr : void 0;
2523
- filetools.writeFileTo(target, content, overwrite, fileAttr);
1937
+ Utils.writeFileTo(target, content, overwrite);
2524
1938
  return true;
2525
1939
  },
2526
1940
  /**
2527
1941
  * Test the archive
2528
- * @param {string} [pass]
1942
+ *
2529
1943
  */
2530
- test: function(pass) {
1944
+ test: function() {
2531
1945
  if (!_zip) {
2532
1946
  return false;
2533
1947
  }
2534
- for (var entry of _zip.entries) {
1948
+ for (var entry in _zip.entries) {
2535
1949
  try {
2536
1950
  if (entry.isDirectory) {
2537
1951
  continue;
2538
1952
  }
2539
- var content = entry.getData(pass);
1953
+ var content = _zip.entries[entry].getData();
2540
1954
  if (!content) {
2541
1955
  return false;
2542
1956
  }
@@ -2549,139 +1963,96 @@ var require_adm_zip = __commonJS({
2549
1963
  /**
2550
1964
  * Extracts the entire archive to the given location
2551
1965
  *
2552
- * @param {string} targetPath Target location
2553
- * @param {boolean} [overwrite=false] If the file already exists at the target path, the file will be overwriten if this is true.
2554
- * Default is FALSE
2555
- * @param {boolean} [keepOriginalPermission=false] The file will be set as the permission from the entry if this is true.
1966
+ * @param targetPath Target location
1967
+ * @param overwrite If the file already exists at the target path, the file will be overwriten if this is true.
2556
1968
  * Default is FALSE
2557
- * @param {string|Buffer} [pass] password
2558
1969
  */
2559
- extractAllTo: function(targetPath, overwrite, keepOriginalPermission, pass) {
2560
- keepOriginalPermission = get_Bool(false, keepOriginalPermission);
2561
- pass = get_Str(keepOriginalPermission, pass);
2562
- overwrite = get_Bool(false, overwrite);
2563
- if (!_zip) throw Utils.Errors.NO_ZIP();
2564
- const dirEntries = [];
1970
+ extractAllTo: function(targetPath, overwrite) {
1971
+ overwrite = overwrite || false;
1972
+ if (!_zip) {
1973
+ throw new Error(Utils.Errors.NO_ZIP);
1974
+ }
2565
1975
  _zip.entries.forEach(function(entry) {
2566
- var entryName = sanitize(targetPath, canonical(entry.entryName));
1976
+ var entryName = sanitize(targetPath, entry.entryName.toString());
2567
1977
  if (entry.isDirectory) {
2568
- filetools.makeDir(entryName);
2569
- if (keepOriginalPermission) dirEntries.push({ path: entryName, attr: entry.header.fileAttr });
1978
+ Utils.makeDir(entryName);
2570
1979
  return;
2571
1980
  }
2572
- var content = entry.getData(pass);
1981
+ var content = entry.getData();
2573
1982
  if (!content) {
2574
- throw Utils.Errors.CANT_EXTRACT_FILE();
1983
+ throw new Error(Utils.Errors.CANT_EXTRACT_FILE);
2575
1984
  }
2576
- const fileAttr = keepOriginalPermission ? entry.header.fileAttr : void 0;
2577
- filetools.writeFileTo(entryName, content, overwrite, fileAttr);
1985
+ Utils.writeFileTo(entryName, content, overwrite);
2578
1986
  try {
2579
- filetools.fs.utimesSync(entryName, entry.header.time, entry.header.time);
1987
+ fs10.utimesSync(entryName, entry.header.time, entry.header.time);
2580
1988
  } catch (err) {
1989
+ throw new Error(Utils.Errors.CANT_EXTRACT_FILE);
2581
1990
  }
2582
1991
  });
2583
- applyDirAttributes(dirEntries);
2584
1992
  },
2585
1993
  /**
2586
1994
  * Asynchronous extractAllTo
2587
1995
  *
2588
- * @param {string} targetPath Target location
2589
- * @param {boolean} [overwrite=false] If the file already exists at the target path, the file will be overwriten if this is true.
1996
+ * @param targetPath Target location
1997
+ * @param overwrite If the file already exists at the target path, the file will be overwriten if this is true.
2590
1998
  * Default is FALSE
2591
- * @param {boolean} [keepOriginalPermission=false] The file will be set as the permission from the entry if this is true.
2592
- * Default is FALSE
2593
- * @param {function} callback The callback will be executed when all entries are extracted successfully or any error is thrown.
1999
+ * @param callback
2594
2000
  */
2595
- extractAllToAsync: function(targetPath, overwrite, keepOriginalPermission, callback) {
2596
- callback = get_Fun(overwrite, keepOriginalPermission, callback);
2597
- keepOriginalPermission = get_Bool(false, keepOriginalPermission);
2598
- overwrite = get_Bool(false, overwrite);
2001
+ extractAllToAsync: function(targetPath, overwrite, callback) {
2599
2002
  if (!callback) {
2600
- return new Promise((resolve, reject) => {
2601
- this.extractAllToAsync(targetPath, overwrite, keepOriginalPermission, function(err) {
2602
- if (err) {
2603
- reject(err);
2604
- } else {
2605
- resolve(this);
2606
- }
2607
- });
2608
- });
2003
+ callback = function() {
2004
+ };
2609
2005
  }
2006
+ overwrite = overwrite || false;
2610
2007
  if (!_zip) {
2611
- callback(Utils.Errors.NO_ZIP());
2008
+ callback(new Error(Utils.Errors.NO_ZIP));
2612
2009
  return;
2613
2010
  }
2614
- targetPath = pth.resolve(targetPath);
2615
- const getPath = (entry) => sanitize(targetPath, pth.normalize(canonical(entry.entryName)));
2616
- const getError = (msg, file) => new Error(msg + ': "' + file + '"');
2617
- const dirEntries = [];
2618
- const fileEntries = [];
2619
- _zip.entries.forEach((e) => {
2620
- if (e.isDirectory) {
2621
- dirEntries.push(e);
2622
- } else {
2623
- fileEntries.push(e);
2624
- }
2625
- });
2626
- const deferredDirAttr = [];
2627
- for (const entry of dirEntries) {
2628
- const dirPath = getPath(entry);
2629
- const dirAttr = keepOriginalPermission ? entry.header.fileAttr : void 0;
2630
- try {
2631
- filetools.makeDir(dirPath);
2632
- } catch (er) {
2633
- callback(getError("Unable to create folder", dirPath));
2634
- continue;
2635
- }
2636
- if (dirAttr) deferredDirAttr.push({ path: dirPath, attr: dirAttr });
2637
- try {
2638
- filetools.fs.utimesSync(dirPath, entry.header.time, entry.header.time);
2639
- } catch (er) {
2640
- }
2641
- }
2642
- const done = (err) => {
2643
- if (!err) {
2644
- try {
2645
- applyDirAttributes(deferredDirAttr);
2646
- } catch (er) {
2647
- return callback(getError("Unable to set folder permissions", er.path || ""));
2648
- }
2011
+ var entries = _zip.entries;
2012
+ var i = entries.length;
2013
+ entries.forEach(function(entry) {
2014
+ if (i <= 0) return;
2015
+ var entryName = pth.normalize(entry.entryName.toString());
2016
+ if (entry.isDirectory) {
2017
+ Utils.makeDir(sanitize(targetPath, entryName));
2018
+ if (--i === 0)
2019
+ callback(void 0);
2020
+ return;
2649
2021
  }
2650
- callback(err);
2651
- };
2652
- fileEntries.reverse().reduce(function(next, entry) {
2653
- return function(err) {
2022
+ entry.getDataAsync(function(content, err) {
2023
+ if (i <= 0) return;
2654
2024
  if (err) {
2655
- next(err);
2656
- } else {
2657
- const entryName = pth.normalize(canonical(entry.entryName));
2658
- const filePath = sanitize(targetPath, entryName);
2659
- entry.getDataAsync(function(content, err_1) {
2660
- if (err_1) {
2661
- next(err_1);
2662
- } else if (!content) {
2663
- next(Utils.Errors.CANT_EXTRACT_FILE());
2664
- } else {
2665
- const fileAttr = keepOriginalPermission ? entry.header.fileAttr : void 0;
2666
- filetools.writeFileToAsync(filePath, content, overwrite, fileAttr, function(succ) {
2667
- if (!succ) {
2668
- return next(getError("Unable to write file", filePath));
2669
- }
2670
- filetools.fs.utimes(filePath, entry.header.time, entry.header.time, function() {
2671
- next();
2672
- });
2673
- });
2674
- }
2675
- });
2025
+ callback(new Error(err));
2026
+ return;
2676
2027
  }
2677
- };
2678
- }, done)();
2028
+ if (!content) {
2029
+ i = 0;
2030
+ callback(new Error(Utils.Errors.CANT_EXTRACT_FILE));
2031
+ return;
2032
+ }
2033
+ Utils.writeFileToAsync(sanitize(targetPath, entryName), content, overwrite, function(succ) {
2034
+ try {
2035
+ fs10.utimesSync(pth.resolve(targetPath, entryName), entry.header.time, entry.header.time);
2036
+ } catch (err2) {
2037
+ callback(new Error("Unable to set utimes"));
2038
+ }
2039
+ if (i <= 0) return;
2040
+ if (!succ) {
2041
+ i = 0;
2042
+ callback(new Error("Unable to write"));
2043
+ return;
2044
+ }
2045
+ if (--i === 0)
2046
+ callback(void 0);
2047
+ });
2048
+ });
2049
+ });
2679
2050
  },
2680
2051
  /**
2681
2052
  * Writes the newly created zip file to disk at the specified location or if a zip was opened and no ``targetFileName`` is provided, it will overwrite the opened zip
2682
2053
  *
2683
- * @param {string} targetFileName
2684
- * @param {function} callback
2054
+ * @param targetFileName
2055
+ * @param callback
2685
2056
  */
2686
2057
  writeZip: function(targetFileName, callback) {
2687
2058
  if (arguments.length === 1) {
@@ -2690,54 +2061,23 @@ var require_adm_zip = __commonJS({
2690
2061
  targetFileName = "";
2691
2062
  }
2692
2063
  }
2693
- if (!targetFileName && opts.filename) {
2694
- targetFileName = opts.filename;
2064
+ if (!targetFileName && _filename) {
2065
+ targetFileName = _filename;
2695
2066
  }
2696
2067
  if (!targetFileName) return;
2697
2068
  var zipData = _zip.compressToBuffer();
2698
2069
  if (zipData) {
2699
- var ok = filetools.writeFileTo(targetFileName, zipData, true);
2070
+ var ok = Utils.writeFileTo(targetFileName, zipData, true);
2700
2071
  if (typeof callback === "function") callback(!ok ? new Error("failed") : null, "");
2701
2072
  }
2702
2073
  },
2703
- /**
2704
- *
2705
- * @param {string} targetFileName
2706
- * @param {object} [props]
2707
- * @param {boolean} [props.overwrite=true] If the file already exists at the target path, the file will be overwriten if this is true.
2708
- * @param {boolean} [props.perm] The file will be set as the permission from the entry if this is true.
2709
-
2710
- * @returns {Promise<void>}
2711
- */
2712
- writeZipPromise: function(targetFileName, props) {
2713
- const { overwrite, perm } = Object.assign({ overwrite: true }, props);
2714
- return new Promise((resolve, reject) => {
2715
- if (!targetFileName && opts.filename) targetFileName = opts.filename;
2716
- if (!targetFileName) reject("ADM-ZIP: ZIP File Name Missing");
2717
- this.toBufferPromise().then((zipData) => {
2718
- const ret = (done) => done ? resolve(done) : reject("ADM-ZIP: Wasn't able to write zip file");
2719
- filetools.writeFileToAsync(targetFileName, zipData, overwrite, perm, ret);
2720
- }, reject);
2721
- });
2722
- },
2723
- /**
2724
- * @returns {Promise<Buffer>} A promise to the Buffer.
2725
- */
2726
- toBufferPromise: function() {
2727
- return new Promise((resolve, reject) => {
2728
- _zip.toAsyncBuffer(resolve, reject);
2729
- });
2730
- },
2731
2074
  /**
2732
2075
  * Returns the content of the entire zip file as a Buffer object
2733
2076
  *
2734
- * @prop {function} [onSuccess]
2735
- * @prop {function} [onFail]
2736
- * @prop {function} [onItemStart]
2737
- * @prop {function} [onItemEnd]
2738
- * @returns {Buffer}
2077
+ * @return Buffer
2739
2078
  */
2740
2079
  toBuffer: function(onSuccess, onFail, onItemStart, onItemEnd) {
2080
+ this.valueOf = 2;
2741
2081
  if (typeof onSuccess === "function") {
2742
2082
  _zip.toAsyncBuffer(onSuccess, onFail, onItemStart, onItemEnd);
2743
2083
  return null;
@@ -4712,6 +4052,12 @@ function normalizeCommandCode(code) {
4712
4052
  function shouldSyncBuiltInTemplate(action, isBuiltIn) {
4713
4053
  return action === "UPDATE_SKILL" && isBuiltIn === true;
4714
4054
  }
4055
+ function resolveGatewaySkillTarget(home = openclawHome()) {
4056
+ return path9.join(home, "skills");
4057
+ }
4058
+ function isGatewaySkillCommand(action, installScope) {
4059
+ return installScope === "gateway" && ["INSTALL_SKILL", "UPDATE_SKILL", "UNINSTALL_SKILL"].includes(String(action || ""));
4060
+ }
4715
4061
  async function findInstalledExpertSkillsRoot(rootPath, pureId, code) {
4716
4062
  const skillsRoot = path9.join(rootPath, `workspace-assistant-${pureId}`, ".user", "skills");
4717
4063
  try {
@@ -5013,7 +4359,8 @@ var GatewayWsClient = class {
5013
4359
  gatewayId: this.options.gatewayId,
5014
4360
  agentIds: Array.from(this.currentAgentIds),
5015
4361
  clientTime: Date.now(),
5016
- supportsBatch: true
4362
+ supportsBatch: true,
4363
+ supportsGatewaySkillScope: true
5017
4364
  }, "Heartbeat");
5018
4365
  }
5019
4366
  sendClientHeartbeat() {
@@ -5042,7 +4389,7 @@ var GatewayWsClient = class {
5042
4389
  * 核心指令分发中心:完全跳过沙盒,基于 userId 直接进行底层物理文件操作
5043
4390
  */
5044
4391
  async handleMessage(msg) {
5045
- const { action, userId, code, url, force, version, replyId, isBuiltIn } = msg;
4392
+ const { action, userId, code, url, force, version, replyId, isBuiltIn, installScope } = msg;
5046
4393
  this.appendLogToFile("INFO", "Command", `Received WS message`, {
5047
4394
  action,
5048
4395
  userId,
@@ -5050,6 +4397,7 @@ var GatewayWsClient = class {
5050
4397
  version,
5051
4398
  replyId,
5052
4399
  isBuiltIn,
4400
+ installScope,
5053
4401
  hasDirectUrl: Boolean(url)
5054
4402
  });
5055
4403
  if (!action) {
@@ -5082,15 +4430,16 @@ var GatewayWsClient = class {
5082
4430
  this.reply(replyId, { success: false, message: `Invalid code: ${String(code)}`, action });
5083
4431
  return;
5084
4432
  }
5085
- const pureId = normalizeAssistantUserId(userId);
5086
- if (!pureId) {
4433
+ const gatewaySkillCommand = isGatewaySkillCommand(action, installScope);
4434
+ const pureId = gatewaySkillCommand ? void 0 : normalizeAssistantUserId(userId);
4435
+ if (!gatewaySkillCommand && !pureId) {
5087
4436
  this.reply(replyId, { success: false, message: `Invalid userId: ${userId}`, action });
5088
4437
  return;
5089
4438
  }
5090
4439
  try {
5091
4440
  if (action === "INSTALL_SKILL") {
5092
4441
  if (!safeCode) throw new Error("Missing code parameter");
5093
- const targetDir = await this.resolveRegularSkillTarget(userId);
4442
+ const targetDir = gatewaySkillCommand ? resolveGatewaySkillTarget() : await this.resolveRegularSkillTarget(userId);
5094
4443
  console.log(`[skill-logger-plugin][WS] Executing INSTALL for user ${userId}, code: ${safeCode}`);
5095
4444
  this.appendLogToFile("INFO", "Command", `INSTALL_SKILL received`, { userId, code: safeCode, version });
5096
4445
  const result = await this.options.updater.manualInstall({
@@ -5101,109 +4450,119 @@ var GatewayWsClient = class {
5101
4450
  targetDir,
5102
4451
  trace: this.createInstallTrace({ action, replyId, userId, code: safeCode })
5103
4452
  });
5104
- this.reply(replyId, { success: result.success, message: result.message, action });
4453
+ this.reply(replyId, {
4454
+ success: result.success,
4455
+ message: result.message,
4456
+ action,
4457
+ data: { code: safeCode, version, installScope: gatewaySkillCommand ? "gateway" : "agent" }
4458
+ });
5105
4459
  } else if (action === "UNINSTALL_SKILL") {
5106
4460
  if (!safeCode) throw new Error("Missing code parameter");
5107
- const targetDir = await this.resolveRegularSkillTarget(userId);
4461
+ const targetDir = gatewaySkillCommand ? resolveGatewaySkillTarget() : await this.resolveRegularSkillTarget(userId);
5108
4462
  console.log(`[skill-logger-plugin][WS] Executing UNINSTALL for user ${userId}, code: ${safeCode}`);
5109
4463
  this.appendLogToFile("INFO", "Command", `UNINSTALL_SKILL received`, { userId, code: safeCode });
5110
4464
  const skillPath = path9.join(targetDir, safeCode);
5111
4465
  await fs8.rm(skillPath, { recursive: true, force: true });
5112
- this.reply(replyId, { success: true, message: `Skill ${safeCode} removed`, action });
4466
+ this.reply(replyId, {
4467
+ success: true,
4468
+ message: `Skill ${safeCode} removed`,
4469
+ action,
4470
+ data: { code: safeCode, installScope: gatewaySkillCommand ? "gateway" : "agent", removed: true }
4471
+ });
5113
4472
  } else if (action === "LIST_SKILLS") {
5114
- const targetDir = await this.resolveRegularSkillTarget(userId);
5115
- let list = [];
5116
- let targetDirExists = false;
5117
- try {
5118
- const targetStat = await fs8.stat(targetDir);
5119
- targetDirExists = targetStat.isDirectory();
5120
- } catch (err) {
5121
- if (err?.code !== "ENOENT") throw err;
5122
- }
5123
- if (!targetDirExists) {
5124
- throw new Error(`Target skills directory does not exist: ${targetDir}`);
5125
- }
5126
- const entries = await fs8.readdir(targetDir, { withFileTypes: true });
5127
- const dirs = entries.filter((e) => (e.isDirectory() || e.isSymbolicLink()) && !e.name.startsWith("."));
5128
- for (const e of dirs) {
5129
- const skillDir = path9.join(targetDir, e.name);
5130
- const skillMdPath = path9.join(skillDir, "SKILL.md");
4473
+ const regularTargetDir = await this.resolveRegularSkillTarget(userId);
4474
+ const skillsByCode = /* @__PURE__ */ new Map();
4475
+ const sources = [
4476
+ { dir: regularTargetDir, gatewayBuiltIn: false },
4477
+ { dir: resolveGatewaySkillTarget(), gatewayBuiltIn: true }
4478
+ ];
4479
+ for (const source of sources) {
4480
+ let entries;
5131
4481
  try {
5132
- const stat = await fs8.stat(skillMdPath);
5133
- if (!stat.isFile()) continue;
4482
+ entries = await fs8.readdir(source.dir, { withFileTypes: true });
5134
4483
  } catch (err) {
5135
- continue;
4484
+ if (err?.code === "ENOENT") continue;
4485
+ throw err;
5136
4486
  }
5137
- const metaPath = path9.join(skillDir, ".meta.json");
5138
- let isPlatform = false;
5139
- let isBuiltIn2 = e.isSymbolicLink();
5140
- let metaData = null;
5141
- let name = e.name;
5142
- let description = "";
5143
- let skillVersion = "";
5144
- try {
5145
- const mdContent = await fs8.readFile(skillMdPath, "utf8");
5146
- const fm = /^---\r?\n([\s\S]*?)\r?\n---/.exec(mdContent)?.[1] ?? "";
5147
- const parsedName = /(^|\n)name:\s*(.+)/.exec(fm)?.[2]?.trim();
5148
- if (parsedName) name = parsedName;
5149
- const descMatch = /(^|\n)description:\s*(?:>\s*\n\s*)?(.*?)(?=\n[a-z]+:|\n---|$)/is.exec(fm);
5150
- if (descMatch && descMatch[2]) {
5151
- description = descMatch[2].replace(/\n\s+/g, " ").trim();
4487
+ const dirs = entries.filter((e) => (e.isDirectory() || e.isSymbolicLink()) && !e.name.startsWith("."));
4488
+ for (const e of dirs) {
4489
+ const skillDir = path9.join(source.dir, e.name);
4490
+ const skillMdPath = path9.join(skillDir, "SKILL.md");
4491
+ try {
4492
+ const stat = await fs8.stat(skillMdPath);
4493
+ if (!stat.isFile()) continue;
4494
+ } catch {
4495
+ continue;
5152
4496
  }
5153
- } catch (err) {
5154
- }
5155
- try {
5156
- const metaContent = await fs8.readFile(metaPath, "utf8");
5157
- const parsed = JSON.parse(metaContent);
5158
- if (parsed) {
5159
- if (parsed.ownerId === "CMS" || parsed.ownerId === "CMS_COMPAT") isPlatform = true;
5160
- if (parsed.isBuiltIn === true || parsed.ownerId === "built-in") isBuiltIn2 = true;
5161
- metaData = parsed;
4497
+ const metaPath = path9.join(skillDir, ".meta.json");
4498
+ let isPlatform = source.gatewayBuiltIn;
4499
+ let isBuiltIn2 = source.gatewayBuiltIn || e.isSymbolicLink();
4500
+ let metaData = null;
4501
+ let name = e.name;
4502
+ let description = "";
4503
+ let skillVersion = "";
4504
+ try {
4505
+ const mdContent = await fs8.readFile(skillMdPath, "utf8");
4506
+ const fm = /^---\r?\n([\s\S]*?)\r?\n---/.exec(mdContent)?.[1] ?? "";
4507
+ const parsedName = /(^|\n)name:\s*(.+)/.exec(fm)?.[2]?.trim();
4508
+ if (parsedName) name = parsedName;
4509
+ const descMatch = /(^|\n)description:\s*(?:>\s*\n\s*)?(.*?)(?=\n[a-z]+:|\n---|$)/is.exec(fm);
4510
+ if (descMatch?.[2]) description = descMatch[2].replace(/\n\s+/g, " ").trim();
4511
+ } catch {
4512
+ }
4513
+ try {
4514
+ const parsed = JSON.parse(await fs8.readFile(metaPath, "utf8"));
4515
+ if (parsed) {
4516
+ if (parsed.ownerId === "CMS" || parsed.ownerId === "CMS_COMPAT") isPlatform = true;
4517
+ if (parsed.isBuiltIn === true || parsed.ownerId === "built-in") isBuiltIn2 = true;
4518
+ metaData = parsed;
4519
+ }
4520
+ } catch {
4521
+ }
4522
+ const resolvedVersion = await readSkillVersion(skillDir);
4523
+ if (resolvedVersion) skillVersion = resolvedVersion;
4524
+ if (isPlatform) {
4525
+ skillsByCode.set(e.name, {
4526
+ code: e.name,
4527
+ isPlatform: true,
4528
+ isBuiltIn: isBuiltIn2,
4529
+ version: skillVersion,
4530
+ name,
4531
+ description,
4532
+ publishedAt: metaData?.publishedAt
4533
+ });
4534
+ } else {
4535
+ skillsByCode.set(e.name, {
4536
+ code: e.name,
4537
+ isPlatform: false,
4538
+ isBuiltIn: isBuiltIn2,
4539
+ version: skillVersion,
4540
+ name,
4541
+ description
4542
+ });
5162
4543
  }
5163
- } catch (err) {
5164
- }
5165
- const resolvedVersion = await readSkillVersion(skillDir);
5166
- if (resolvedVersion) skillVersion = resolvedVersion;
5167
- if (isPlatform) {
5168
- list.push({
5169
- code: e.name,
5170
- isPlatform: true,
5171
- isBuiltIn: isBuiltIn2,
5172
- version: skillVersion,
5173
- name,
5174
- description,
5175
- publishedAt: metaData?.publishedAt
5176
- });
5177
- } else {
5178
- list.push({
5179
- code: e.name,
5180
- isPlatform: false,
5181
- isBuiltIn: isBuiltIn2,
5182
- version: skillVersion,
5183
- name,
5184
- description
5185
- });
5186
4544
  }
5187
4545
  }
5188
- this.reply(replyId, { success: true, data: list, action });
4546
+ this.reply(replyId, { success: true, data: [...skillsByCode.values()], action });
5189
4547
  } else if (action === "UPDATE_SKILL") {
5190
4548
  if (!safeCode) throw new Error("Missing code parameter");
5191
4549
  const delayMs = Math.random() * 5e3;
5192
- const syncBuiltInTemplate = shouldSyncBuiltInTemplate(action, isBuiltIn);
4550
+ const syncBuiltInTemplate = !gatewaySkillCommand && shouldSyncBuiltInTemplate(action, isBuiltIn);
5193
4551
  console.log(`[skill-logger-plugin][WS] Scheduled UPDATE for user ${userId}, code: ${safeCode} in ${Math.round(delayMs)}ms`);
5194
4552
  this.appendLogToFile("INFO", "Command", `Scheduled UPDATE_SKILL`, {
5195
4553
  userId,
5196
4554
  code: safeCode,
5197
4555
  version,
5198
4556
  isBuiltIn,
4557
+ installScope,
5199
4558
  syncBuiltInTemplate,
5200
4559
  delayMs: Math.round(delayMs)
5201
4560
  });
5202
4561
  setTimeout(async () => {
5203
4562
  try {
5204
- const targetDir = await this.resolveRegularSkillTarget(userId);
4563
+ const targetDir = gatewaySkillCommand ? resolveGatewaySkillTarget() : await this.resolveRegularSkillTarget(userId);
5205
4564
  const additionalTargetDirs = syncBuiltInTemplate ? [path9.join(openclawHome(), "workspace-xgjk-assistant-template", "skills")] : [];
5206
- const userSkillRoot = await findInstalledExpertSkillsRoot(openclawHome(), pureId, safeCode);
4565
+ const userSkillRoot = pureId ? await findInstalledExpertSkillsRoot(openclawHome(), pureId, safeCode) : void 0;
5207
4566
  if (userSkillRoot) additionalTargetDirs.push(userSkillRoot);
5208
4567
  const result = await this.options.updater.manualInstall({
5209
4568
  code: safeCode,
@@ -5230,7 +4589,12 @@ var GatewayWsClient = class {
5230
4589
  syncBuiltInTemplate
5231
4590
  });
5232
4591
  if (replyId) {
5233
- this.reply(replyId, { success: result.success, message: result.message, action });
4592
+ this.reply(replyId, {
4593
+ success: result.success,
4594
+ message: result.message,
4595
+ action,
4596
+ data: { code: safeCode, version, installScope: gatewaySkillCommand ? "gateway" : "agent" }
4597
+ });
5234
4598
  }
5235
4599
  } catch (e) {
5236
4600
  this.appendLogToFile("ERROR", "Command", `UPDATE_SKILL threw`, {