@wix/vibe-forms-plugin 0.25.0 → 0.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var fs = require('fs');
6
- var path = require('path');
6
+ var path2 = require('path');
7
7
  var https = require('https');
8
8
 
9
9
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
@@ -27,7 +27,7 @@ function _interopNamespace(e) {
27
27
  }
28
28
 
29
29
  var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
30
- var path__namespace = /*#__PURE__*/_interopNamespace(path);
30
+ var path2__namespace = /*#__PURE__*/_interopNamespace(path2);
31
31
  var https__default = /*#__PURE__*/_interopDefault(https);
32
32
 
33
33
  var __create = Object.create;
@@ -388,25 +388,25 @@ var require_utils = __commonJS({
388
388
  }
389
389
  mkdirSync2(folder);
390
390
  };
391
- Utils.prototype.writeFileTo = function(path2, content, overwrite, attr) {
391
+ Utils.prototype.writeFileTo = function(path3, content, overwrite, attr) {
392
392
  const self = this;
393
- if (self.fs.existsSync(path2)) {
393
+ if (self.fs.existsSync(path3)) {
394
394
  if (!overwrite) return false;
395
- var stat = self.fs.statSync(path2);
395
+ var stat = self.fs.statSync(path3);
396
396
  if (stat.isDirectory()) {
397
397
  return false;
398
398
  }
399
399
  }
400
- var folder = pth.dirname(path2);
400
+ var folder = pth.dirname(path3);
401
401
  if (!self.fs.existsSync(folder)) {
402
402
  self.makeDir(folder);
403
403
  }
404
404
  var fd;
405
405
  try {
406
- fd = self.fs.openSync(path2, "w", 438);
406
+ fd = self.fs.openSync(path3, "w", 438);
407
407
  } catch (e) {
408
- self.fs.chmodSync(path2, 438);
409
- fd = self.fs.openSync(path2, "w", 438);
408
+ self.fs.chmodSync(path3, 438);
409
+ fd = self.fs.openSync(path3, "w", 438);
410
410
  }
411
411
  if (fd) {
412
412
  try {
@@ -415,31 +415,31 @@ var require_utils = __commonJS({
415
415
  self.fs.closeSync(fd);
416
416
  }
417
417
  }
418
- self.fs.chmodSync(path2, attr || 438);
418
+ self.fs.chmodSync(path3, attr || 438);
419
419
  return true;
420
420
  };
421
- Utils.prototype.writeFileToAsync = function(path2, content, overwrite, attr, callback) {
421
+ Utils.prototype.writeFileToAsync = function(path3, content, overwrite, attr, callback) {
422
422
  if (typeof attr === "function") {
423
423
  callback = attr;
424
424
  attr = void 0;
425
425
  }
426
426
  const self = this;
427
- self.fs.exists(path2, function(exist) {
427
+ self.fs.exists(path3, function(exist) {
428
428
  if (exist && !overwrite) return callback(false);
429
- self.fs.stat(path2, function(err, stat) {
429
+ self.fs.stat(path3, function(err, stat) {
430
430
  if (exist && stat.isDirectory()) {
431
431
  return callback(false);
432
432
  }
433
- var folder = pth.dirname(path2);
433
+ var folder = pth.dirname(path3);
434
434
  self.fs.exists(folder, function(exists) {
435
435
  if (!exists) self.makeDir(folder);
436
- self.fs.open(path2, "w", 438, function(err2, fd) {
436
+ self.fs.open(path3, "w", 438, function(err2, fd) {
437
437
  if (err2) {
438
- self.fs.chmod(path2, 438, function() {
439
- self.fs.open(path2, "w", 438, function(err3, fd2) {
438
+ self.fs.chmod(path3, 438, function() {
439
+ self.fs.open(path3, "w", 438, function(err3, fd2) {
440
440
  self.fs.write(fd2, content, 0, content.length, 0, function() {
441
441
  self.fs.close(fd2, function() {
442
- self.fs.chmod(path2, attr || 438, function() {
442
+ self.fs.chmod(path3, attr || 438, function() {
443
443
  callback(true);
444
444
  });
445
445
  });
@@ -449,13 +449,13 @@ var require_utils = __commonJS({
449
449
  } else if (fd) {
450
450
  self.fs.write(fd, content, 0, content.length, 0, function() {
451
451
  self.fs.close(fd, function() {
452
- self.fs.chmod(path2, attr || 438, function() {
452
+ self.fs.chmod(path3, attr || 438, function() {
453
453
  callback(true);
454
454
  });
455
455
  });
456
456
  });
457
457
  } else {
458
- self.fs.chmod(path2, attr || 438, function() {
458
+ self.fs.chmod(path3, attr || 438, function() {
459
459
  callback(true);
460
460
  });
461
461
  }
@@ -464,21 +464,21 @@ var require_utils = __commonJS({
464
464
  });
465
465
  });
466
466
  };
467
- Utils.prototype.findFiles = function(path2) {
467
+ Utils.prototype.findFiles = function(path3) {
468
468
  const self = this;
469
469
  function findSync(dir, pattern, recursive) {
470
470
  let files = [];
471
471
  self.fs.readdirSync(dir).forEach(function(file) {
472
- const path3 = pth.join(dir, file);
473
- const stat = self.fs.statSync(path3);
472
+ const path4 = pth.join(dir, file);
473
+ const stat = self.fs.statSync(path4);
474
474
  {
475
- files.push(pth.normalize(path3) + (stat.isDirectory() ? self.sep : ""));
475
+ files.push(pth.normalize(path4) + (stat.isDirectory() ? self.sep : ""));
476
476
  }
477
- if (stat.isDirectory() && recursive) files = files.concat(findSync(path3, pattern, recursive));
477
+ if (stat.isDirectory() && recursive) files = files.concat(findSync(path4, pattern, recursive));
478
478
  });
479
479
  return files;
480
480
  }
481
- return findSync(path2, void 0, true);
481
+ return findSync(path3, void 0, true);
482
482
  };
483
483
  Utils.prototype.findFilesAsync = function(dir, cb) {
484
484
  const self = this;
@@ -533,14 +533,14 @@ var require_utils = __commonJS({
533
533
  return "UNSUPPORTED (" + method + ")";
534
534
  }
535
535
  };
536
- Utils.canonical = function(path2) {
537
- if (!path2) return "";
538
- const safeSuffix = pth.posix.normalize("/" + path2.split("\\").join("/"));
536
+ Utils.canonical = function(path3) {
537
+ if (!path3) return "";
538
+ const safeSuffix = pth.posix.normalize("/" + path3.split("\\").join("/"));
539
539
  return pth.join(".", safeSuffix);
540
540
  };
541
- Utils.zipnamefix = function(path2) {
542
- if (!path2) return "";
543
- const safeSuffix = pth.posix.normalize("/" + path2.split("\\").join("/"));
541
+ Utils.zipnamefix = function(path3) {
542
+ if (!path3) return "";
543
+ const safeSuffix = pth.posix.normalize("/" + path3.split("\\").join("/"));
544
544
  return pth.posix.join(".", safeSuffix);
545
545
  };
546
546
  Utils.findLast = function(arr, callback) {
@@ -557,9 +557,9 @@ var require_utils = __commonJS({
557
557
  prefix = pth.resolve(pth.normalize(prefix));
558
558
  var parts = name.split("/");
559
559
  for (var i = 0, l = parts.length; i < l; i++) {
560
- var path2 = pth.normalize(pth.join(prefix, parts.slice(i, l).join(pth.sep)));
561
- if (path2.indexOf(prefix) === 0) {
562
- return path2;
560
+ var path3 = pth.normalize(pth.join(prefix, parts.slice(i, l).join(pth.sep)));
561
+ if (path3.indexOf(prefix) === 0) {
562
+ return path3;
563
563
  }
564
564
  }
565
565
  return pth.normalize(pth.join(prefix, pth.basename(name)));
@@ -599,8 +599,8 @@ var require_utils = __commonJS({
599
599
  var require_fattr = __commonJS({
600
600
  "../../../node_modules/adm-zip/util/fattr.js"(exports, module) {
601
601
  var pth = __require("path");
602
- module.exports = function(path2, { fs: fs2 }) {
603
- var _path = path2 || "", _obj = newAttr(), _stat = null;
602
+ module.exports = function(path3, { fs: fs2 }) {
603
+ var _path = path3 || "", _obj = newAttr(), _stat = null;
604
604
  function newAttr() {
605
605
  return {
606
606
  directory: false,
@@ -2711,11 +2711,2814 @@ var require_adm_zip = __commonJS({
2711
2711
  }
2712
2712
  });
2713
2713
 
2714
+ // ../../../packages/vibe-plugin-utils/dist/index.cjs
2715
+ var require_dist = __commonJS({
2716
+ "../../../packages/vibe-plugin-utils/dist/index.cjs"(exports) {
2717
+ var fs2 = __require("fs");
2718
+ var path3 = __require("path");
2719
+ var https2 = __require("https");
2720
+ function _interopDefault(e) {
2721
+ return e && e.__esModule ? e : { default: e };
2722
+ }
2723
+ function _interopNamespace(e) {
2724
+ if (e && e.__esModule) return e;
2725
+ var n = /* @__PURE__ */ Object.create(null);
2726
+ if (e) {
2727
+ Object.keys(e).forEach(function(k) {
2728
+ if (k !== "default") {
2729
+ var d = Object.getOwnPropertyDescriptor(e, k);
2730
+ Object.defineProperty(n, k, d.get ? d : {
2731
+ enumerable: true,
2732
+ get: function() {
2733
+ return e[k];
2734
+ }
2735
+ });
2736
+ }
2737
+ });
2738
+ }
2739
+ n.default = e;
2740
+ return Object.freeze(n);
2741
+ }
2742
+ var fs__namespace = /* @__PURE__ */ _interopNamespace(fs2);
2743
+ var path__namespace = /* @__PURE__ */ _interopNamespace(path3);
2744
+ var https__default = /* @__PURE__ */ _interopDefault(https2);
2745
+ var __create2 = Object.create;
2746
+ var __defProp2 = Object.defineProperty;
2747
+ var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
2748
+ var __getOwnPropNames2 = Object.getOwnPropertyNames;
2749
+ var __getProtoOf2 = Object.getPrototypeOf;
2750
+ var __hasOwnProp2 = Object.prototype.hasOwnProperty;
2751
+ var __require2 = /* @__PURE__ */ ((x) => typeof __require !== "undefined" ? __require : typeof Proxy !== "undefined" ? new Proxy(x, {
2752
+ get: (a, b) => (typeof __require !== "undefined" ? __require : a)[b]
2753
+ }) : x)(function(x) {
2754
+ if (typeof __require !== "undefined") return __require.apply(this, arguments);
2755
+ throw Error('Dynamic require of "' + x + '" is not supported');
2756
+ });
2757
+ var __commonJS2 = (cb, mod) => function __require22() {
2758
+ return mod || (0, cb[__getOwnPropNames2(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
2759
+ };
2760
+ var __copyProps2 = (to, from, except, desc) => {
2761
+ if (from && typeof from === "object" || typeof from === "function") {
2762
+ for (let key of __getOwnPropNames2(from))
2763
+ if (!__hasOwnProp2.call(to, key) && key !== except)
2764
+ __defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
2765
+ }
2766
+ return to;
2767
+ };
2768
+ var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create2(__getProtoOf2(mod)) : {}, __copyProps2(
2769
+ // If the importer is in node compatibility mode or this is not an ESM
2770
+ // file that has been converted to a CommonJS file using a Babel-
2771
+ // compatible transform (i.e. "__esModule" has not been set), then set
2772
+ // "default" to the CommonJS "module.exports" for node compatibility.
2773
+ !mod || !mod.__esModule ? __defProp2(target, "default", { value: mod, enumerable: true }) : target,
2774
+ mod
2775
+ ));
2776
+ var require_constants2 = __commonJS2({
2777
+ "../../node_modules/adm-zip/util/constants.js"(exports2, module2) {
2778
+ module2.exports = {
2779
+ /* The local file header */
2780
+ LOCHDR: 30,
2781
+ // LOC header size
2782
+ LOCSIG: 67324752,
2783
+ // "PK\003\004"
2784
+ LOCVER: 4,
2785
+ // version needed to extract
2786
+ LOCFLG: 6,
2787
+ // general purpose bit flag
2788
+ LOCHOW: 8,
2789
+ // compression method
2790
+ LOCTIM: 10,
2791
+ // modification time (2 bytes time, 2 bytes date)
2792
+ LOCCRC: 14,
2793
+ // uncompressed file crc-32 value
2794
+ LOCSIZ: 18,
2795
+ // compressed size
2796
+ LOCLEN: 22,
2797
+ // uncompressed size
2798
+ LOCNAM: 26,
2799
+ // filename length
2800
+ LOCEXT: 28,
2801
+ // extra field length
2802
+ /* The Data descriptor */
2803
+ EXTSIG: 134695760,
2804
+ // "PK\007\008"
2805
+ EXTHDR: 16,
2806
+ // EXT header size
2807
+ EXTCRC: 4,
2808
+ // uncompressed file crc-32 value
2809
+ EXTSIZ: 8,
2810
+ // compressed size
2811
+ EXTLEN: 12,
2812
+ // uncompressed size
2813
+ /* The central directory file header */
2814
+ CENHDR: 46,
2815
+ // CEN header size
2816
+ CENSIG: 33639248,
2817
+ // "PK\001\002"
2818
+ CENVEM: 4,
2819
+ // version made by
2820
+ CENVER: 6,
2821
+ // version needed to extract
2822
+ CENFLG: 8,
2823
+ // encrypt, decrypt flags
2824
+ CENHOW: 10,
2825
+ // compression method
2826
+ CENTIM: 12,
2827
+ // modification time (2 bytes time, 2 bytes date)
2828
+ CENCRC: 16,
2829
+ // uncompressed file crc-32 value
2830
+ CENSIZ: 20,
2831
+ // compressed size
2832
+ CENLEN: 24,
2833
+ // uncompressed size
2834
+ CENNAM: 28,
2835
+ // filename length
2836
+ CENEXT: 30,
2837
+ // extra field length
2838
+ CENCOM: 32,
2839
+ // file comment length
2840
+ CENDSK: 34,
2841
+ // volume number start
2842
+ CENATT: 36,
2843
+ // internal file attributes
2844
+ CENATX: 38,
2845
+ // external file attributes (host system dependent)
2846
+ CENOFF: 42,
2847
+ // LOC header offset
2848
+ /* The entries in the end of central directory */
2849
+ ENDHDR: 22,
2850
+ // END header size
2851
+ ENDSIG: 101010256,
2852
+ // "PK\005\006"
2853
+ ENDSUB: 8,
2854
+ // number of entries on this disk
2855
+ ENDTOT: 10,
2856
+ // total number of entries
2857
+ ENDSIZ: 12,
2858
+ // central directory size in bytes
2859
+ ENDOFF: 16,
2860
+ // offset of first CEN header
2861
+ ENDCOM: 20,
2862
+ // zip file comment length
2863
+ END64HDR: 20,
2864
+ // zip64 END header size
2865
+ END64SIG: 117853008,
2866
+ // zip64 Locator signature, "PK\006\007"
2867
+ END64START: 4,
2868
+ // number of the disk with the start of the zip64
2869
+ END64OFF: 8,
2870
+ // relative offset of the zip64 end of central directory
2871
+ END64NUMDISKS: 16,
2872
+ // total number of disks
2873
+ ZIP64SIG: 101075792,
2874
+ // zip64 signature, "PK\006\006"
2875
+ ZIP64HDR: 56,
2876
+ // zip64 record minimum size
2877
+ ZIP64LEAD: 12,
2878
+ // leading bytes at the start of the record, not counted by the value stored in ZIP64SIZE
2879
+ ZIP64SIZE: 4,
2880
+ // zip64 size of the central directory record
2881
+ ZIP64VEM: 12,
2882
+ // zip64 version made by
2883
+ ZIP64VER: 14,
2884
+ // zip64 version needed to extract
2885
+ ZIP64DSK: 16,
2886
+ // zip64 number of this disk
2887
+ ZIP64DSKDIR: 20,
2888
+ // number of the disk with the start of the record directory
2889
+ ZIP64SUB: 24,
2890
+ // number of entries on this disk
2891
+ ZIP64TOT: 32,
2892
+ // total number of entries
2893
+ ZIP64SIZB: 40,
2894
+ // zip64 central directory size in bytes
2895
+ ZIP64OFF: 48,
2896
+ // offset of start of central directory with respect to the starting disk number
2897
+ ZIP64EXTRA: 56,
2898
+ // extensible data sector
2899
+ /* Compression methods */
2900
+ STORED: 0,
2901
+ // no compression
2902
+ SHRUNK: 1,
2903
+ // shrunk
2904
+ REDUCED1: 2,
2905
+ // reduced with compression factor 1
2906
+ REDUCED2: 3,
2907
+ // reduced with compression factor 2
2908
+ REDUCED3: 4,
2909
+ // reduced with compression factor 3
2910
+ REDUCED4: 5,
2911
+ // reduced with compression factor 4
2912
+ IMPLODED: 6,
2913
+ // imploded
2914
+ // 7 reserved for Tokenizing compression algorithm
2915
+ DEFLATED: 8,
2916
+ // deflated
2917
+ ENHANCED_DEFLATED: 9,
2918
+ // enhanced deflated
2919
+ PKWARE: 10,
2920
+ // PKWare DCL imploded
2921
+ // 11 reserved by PKWARE
2922
+ BZIP2: 12,
2923
+ // compressed using BZIP2
2924
+ // 13 reserved by PKWARE
2925
+ LZMA: 14,
2926
+ // LZMA
2927
+ // 15-17 reserved by PKWARE
2928
+ IBM_TERSE: 18,
2929
+ // compressed using IBM TERSE
2930
+ IBM_LZ77: 19,
2931
+ // IBM LZ77 z
2932
+ AES_ENCRYPT: 99,
2933
+ // WinZIP AES encryption method
2934
+ /* General purpose bit flag */
2935
+ // values can obtained with expression 2**bitnr
2936
+ FLG_ENC: 1,
2937
+ // Bit 0: encrypted file
2938
+ FLG_COMP1: 2,
2939
+ // Bit 1, compression option
2940
+ FLG_COMP2: 4,
2941
+ // Bit 2, compression option
2942
+ FLG_DESC: 8,
2943
+ // Bit 3, data descriptor
2944
+ FLG_ENH: 16,
2945
+ // Bit 4, enhanced deflating
2946
+ FLG_PATCH: 32,
2947
+ // Bit 5, indicates that the file is compressed patched data.
2948
+ FLG_STR: 64,
2949
+ // Bit 6, strong encryption (patented)
2950
+ // Bits 7-10: Currently unused.
2951
+ FLG_EFS: 2048,
2952
+ // Bit 11: Language encoding flag (EFS)
2953
+ // Bit 12: Reserved by PKWARE for enhanced compression.
2954
+ // Bit 13: encrypted the Central Directory (patented).
2955
+ // Bits 14-15: Reserved by PKWARE.
2956
+ FLG_MSK: 4096,
2957
+ // mask header values
2958
+ /* Load type */
2959
+ FILE: 2,
2960
+ BUFFER: 1,
2961
+ NONE: 0,
2962
+ /* 4.5 Extensible data fields */
2963
+ EF_ID: 0,
2964
+ EF_SIZE: 2,
2965
+ /* Header IDs */
2966
+ ID_ZIP64: 1,
2967
+ ID_AVINFO: 7,
2968
+ ID_PFS: 8,
2969
+ ID_OS2: 9,
2970
+ ID_NTFS: 10,
2971
+ ID_OPENVMS: 12,
2972
+ ID_UNIX: 13,
2973
+ ID_FORK: 14,
2974
+ ID_PATCH: 15,
2975
+ ID_X509_PKCS7: 20,
2976
+ ID_X509_CERTID_F: 21,
2977
+ ID_X509_CERTID_C: 22,
2978
+ ID_STRONGENC: 23,
2979
+ ID_RECORD_MGT: 24,
2980
+ ID_X509_PKCS7_RL: 25,
2981
+ ID_IBM1: 101,
2982
+ ID_IBM2: 102,
2983
+ ID_POSZIP: 18064,
2984
+ EF_ZIP64_OR_32: 4294967295,
2985
+ EF_ZIP64_OR_16: 65535,
2986
+ EF_ZIP64_SUNCOMP: 0,
2987
+ EF_ZIP64_SCOMP: 8,
2988
+ EF_ZIP64_RHO: 16,
2989
+ EF_ZIP64_DSN: 24
2990
+ };
2991
+ }
2992
+ });
2993
+ var require_errors2 = __commonJS2({
2994
+ "../../node_modules/adm-zip/util/errors.js"(exports2) {
2995
+ var errors = {
2996
+ /* Header error messages */
2997
+ INVALID_LOC: "Invalid LOC header (bad signature)",
2998
+ INVALID_CEN: "Invalid CEN header (bad signature)",
2999
+ INVALID_END: "Invalid END header (bad signature)",
3000
+ /* Descriptor */
3001
+ DESCRIPTOR_NOT_EXIST: "No descriptor present",
3002
+ DESCRIPTOR_UNKNOWN: "Unknown descriptor format",
3003
+ DESCRIPTOR_FAULTY: "Descriptor data is malformed",
3004
+ /* ZipEntry error messages*/
3005
+ NO_DATA: "Nothing to decompress",
3006
+ BAD_CRC: "CRC32 checksum failed {0}",
3007
+ FILE_IN_THE_WAY: "There is a file in the way: {0}",
3008
+ UNKNOWN_METHOD: "Invalid/unsupported compression method",
3009
+ /* Inflater error messages */
3010
+ AVAIL_DATA: "inflate::Available inflate data did not terminate",
3011
+ INVALID_DISTANCE: "inflate::Invalid literal/length or distance code in fixed or dynamic block",
3012
+ TO_MANY_CODES: "inflate::Dynamic block code description: too many length or distance codes",
3013
+ INVALID_REPEAT_LEN: "inflate::Dynamic block code description: repeat more than specified lengths",
3014
+ INVALID_REPEAT_FIRST: "inflate::Dynamic block code description: repeat lengths with no first length",
3015
+ INCOMPLETE_CODES: "inflate::Dynamic block code description: code lengths codes incomplete",
3016
+ INVALID_DYN_DISTANCE: "inflate::Dynamic block code description: invalid distance code lengths",
3017
+ INVALID_CODES_LEN: "inflate::Dynamic block code description: invalid literal/length code lengths",
3018
+ INVALID_STORE_BLOCK: "inflate::Stored block length did not match one's complement",
3019
+ INVALID_BLOCK_TYPE: "inflate::Invalid block type (type == 3)",
3020
+ /* ADM-ZIP error messages */
3021
+ CANT_EXTRACT_FILE: "Could not extract the file",
3022
+ CANT_OVERRIDE: "Target file already exists",
3023
+ DISK_ENTRY_TOO_LARGE: "Number of disk entries is too large",
3024
+ NO_ZIP: "No zip file was loaded",
3025
+ NO_ENTRY: "Entry doesn't exist",
3026
+ DIRECTORY_CONTENT_ERROR: "A directory cannot have content",
3027
+ FILE_NOT_FOUND: 'File not found: "{0}"',
3028
+ NOT_IMPLEMENTED: "Not implemented",
3029
+ INVALID_FILENAME: "Invalid filename",
3030
+ INVALID_FORMAT: "Invalid or unsupported zip format. No END header found",
3031
+ INVALID_PASS_PARAM: "Incompatible password parameter",
3032
+ WRONG_PASSWORD: "Wrong Password",
3033
+ /* ADM-ZIP */
3034
+ COMMENT_TOO_LONG: "Comment is too long",
3035
+ // Comment can be max 65535 bytes long (NOTE: some non-US characters may take more space)
3036
+ EXTRA_FIELD_PARSE_ERROR: "Extra field parsing error"
3037
+ };
3038
+ function E(message) {
3039
+ return function(...args) {
3040
+ if (args.length) {
3041
+ message = message.replace(/\{(\d)\}/g, (_, n) => args[n] || "");
3042
+ }
3043
+ return new Error("ADM-ZIP: " + message);
3044
+ };
3045
+ }
3046
+ for (const msg of Object.keys(errors)) {
3047
+ exports2[msg] = E(errors[msg]);
3048
+ }
3049
+ }
3050
+ });
3051
+ var require_utils2 = __commonJS2({
3052
+ "../../node_modules/adm-zip/util/utils.js"(exports2, module2) {
3053
+ var fsystem = __require2("fs");
3054
+ var pth = __require2("path");
3055
+ var Constants = require_constants2();
3056
+ var Errors = require_errors2();
3057
+ var isWin = typeof process === "object" && "win32" === process.platform;
3058
+ var is_Obj = (obj) => typeof obj === "object" && obj !== null;
3059
+ var crcTable = new Uint32Array(256).map((t, c) => {
3060
+ for (let k = 0; k < 8; k++) {
3061
+ if ((c & 1) !== 0) {
3062
+ c = 3988292384 ^ c >>> 1;
3063
+ } else {
3064
+ c >>>= 1;
3065
+ }
3066
+ }
3067
+ return c >>> 0;
3068
+ });
3069
+ function Utils(opts) {
3070
+ this.sep = pth.sep;
3071
+ this.fs = fsystem;
3072
+ if (is_Obj(opts)) {
3073
+ if (is_Obj(opts.fs) && typeof opts.fs.statSync === "function") {
3074
+ this.fs = opts.fs;
3075
+ }
3076
+ }
3077
+ }
3078
+ module2.exports = Utils;
3079
+ Utils.prototype.makeDir = function(folder) {
3080
+ const self = this;
3081
+ function mkdirSync2(fpath) {
3082
+ let resolvedPath = fpath.split(self.sep)[0];
3083
+ fpath.split(self.sep).forEach(function(name) {
3084
+ if (!name || name.substr(-1, 1) === ":") return;
3085
+ resolvedPath += self.sep + name;
3086
+ var stat;
3087
+ try {
3088
+ stat = self.fs.statSync(resolvedPath);
3089
+ } catch (e) {
3090
+ self.fs.mkdirSync(resolvedPath);
3091
+ }
3092
+ if (stat && stat.isFile()) throw Errors.FILE_IN_THE_WAY(`"${resolvedPath}"`);
3093
+ });
3094
+ }
3095
+ mkdirSync2(folder);
3096
+ };
3097
+ Utils.prototype.writeFileTo = function(path22, content, overwrite, attr) {
3098
+ const self = this;
3099
+ if (self.fs.existsSync(path22)) {
3100
+ if (!overwrite) return false;
3101
+ var stat = self.fs.statSync(path22);
3102
+ if (stat.isDirectory()) {
3103
+ return false;
3104
+ }
3105
+ }
3106
+ var folder = pth.dirname(path22);
3107
+ if (!self.fs.existsSync(folder)) {
3108
+ self.makeDir(folder);
3109
+ }
3110
+ var fd;
3111
+ try {
3112
+ fd = self.fs.openSync(path22, "w", 438);
3113
+ } catch (e) {
3114
+ self.fs.chmodSync(path22, 438);
3115
+ fd = self.fs.openSync(path22, "w", 438);
3116
+ }
3117
+ if (fd) {
3118
+ try {
3119
+ self.fs.writeSync(fd, content, 0, content.length, 0);
3120
+ } finally {
3121
+ self.fs.closeSync(fd);
3122
+ }
3123
+ }
3124
+ self.fs.chmodSync(path22, attr || 438);
3125
+ return true;
3126
+ };
3127
+ Utils.prototype.writeFileToAsync = function(path22, content, overwrite, attr, callback) {
3128
+ if (typeof attr === "function") {
3129
+ callback = attr;
3130
+ attr = void 0;
3131
+ }
3132
+ const self = this;
3133
+ self.fs.exists(path22, function(exist) {
3134
+ if (exist && !overwrite) return callback(false);
3135
+ self.fs.stat(path22, function(err, stat) {
3136
+ if (exist && stat.isDirectory()) {
3137
+ return callback(false);
3138
+ }
3139
+ var folder = pth.dirname(path22);
3140
+ self.fs.exists(folder, function(exists) {
3141
+ if (!exists) self.makeDir(folder);
3142
+ self.fs.open(path22, "w", 438, function(err2, fd) {
3143
+ if (err2) {
3144
+ self.fs.chmod(path22, 438, function() {
3145
+ self.fs.open(path22, "w", 438, function(err3, fd2) {
3146
+ self.fs.write(fd2, content, 0, content.length, 0, function() {
3147
+ self.fs.close(fd2, function() {
3148
+ self.fs.chmod(path22, attr || 438, function() {
3149
+ callback(true);
3150
+ });
3151
+ });
3152
+ });
3153
+ });
3154
+ });
3155
+ } else if (fd) {
3156
+ self.fs.write(fd, content, 0, content.length, 0, function() {
3157
+ self.fs.close(fd, function() {
3158
+ self.fs.chmod(path22, attr || 438, function() {
3159
+ callback(true);
3160
+ });
3161
+ });
3162
+ });
3163
+ } else {
3164
+ self.fs.chmod(path22, attr || 438, function() {
3165
+ callback(true);
3166
+ });
3167
+ }
3168
+ });
3169
+ });
3170
+ });
3171
+ });
3172
+ };
3173
+ Utils.prototype.findFiles = function(path22) {
3174
+ const self = this;
3175
+ function findSync(dir, pattern, recursive) {
3176
+ let files = [];
3177
+ self.fs.readdirSync(dir).forEach(function(file) {
3178
+ const path32 = pth.join(dir, file);
3179
+ const stat = self.fs.statSync(path32);
3180
+ {
3181
+ files.push(pth.normalize(path32) + (stat.isDirectory() ? self.sep : ""));
3182
+ }
3183
+ if (stat.isDirectory() && recursive) files = files.concat(findSync(path32, pattern, recursive));
3184
+ });
3185
+ return files;
3186
+ }
3187
+ return findSync(path22, void 0, true);
3188
+ };
3189
+ Utils.prototype.findFilesAsync = function(dir, cb) {
3190
+ const self = this;
3191
+ let results = [];
3192
+ self.fs.readdir(dir, function(err, list) {
3193
+ if (err) return cb(err);
3194
+ let list_length = list.length;
3195
+ if (!list_length) return cb(null, results);
3196
+ list.forEach(function(file) {
3197
+ file = pth.join(dir, file);
3198
+ self.fs.stat(file, function(err2, stat) {
3199
+ if (err2) return cb(err2);
3200
+ if (stat) {
3201
+ results.push(pth.normalize(file) + (stat.isDirectory() ? self.sep : ""));
3202
+ if (stat.isDirectory()) {
3203
+ self.findFilesAsync(file, function(err3, res) {
3204
+ if (err3) return cb(err3);
3205
+ results = results.concat(res);
3206
+ if (!--list_length) cb(null, results);
3207
+ });
3208
+ } else {
3209
+ if (!--list_length) cb(null, results);
3210
+ }
3211
+ }
3212
+ });
3213
+ });
3214
+ });
3215
+ };
3216
+ Utils.prototype.getAttributes = function() {
3217
+ };
3218
+ Utils.prototype.setAttributes = function() {
3219
+ };
3220
+ Utils.crc32update = function(crc, byte) {
3221
+ return crcTable[(crc ^ byte) & 255] ^ crc >>> 8;
3222
+ };
3223
+ Utils.crc32 = function(buf) {
3224
+ if (typeof buf === "string") {
3225
+ buf = Buffer.from(buf, "utf8");
3226
+ }
3227
+ let len = buf.length;
3228
+ let crc = -1;
3229
+ for (let off = 0; off < len; ) crc = Utils.crc32update(crc, buf[off++]);
3230
+ return ~crc >>> 0;
3231
+ };
3232
+ Utils.methodToString = function(method) {
3233
+ switch (method) {
3234
+ case Constants.STORED:
3235
+ return "STORED (" + method + ")";
3236
+ case Constants.DEFLATED:
3237
+ return "DEFLATED (" + method + ")";
3238
+ default:
3239
+ return "UNSUPPORTED (" + method + ")";
3240
+ }
3241
+ };
3242
+ Utils.canonical = function(path22) {
3243
+ if (!path22) return "";
3244
+ const safeSuffix = pth.posix.normalize("/" + path22.split("\\").join("/"));
3245
+ return pth.join(".", safeSuffix);
3246
+ };
3247
+ Utils.zipnamefix = function(path22) {
3248
+ if (!path22) return "";
3249
+ const safeSuffix = pth.posix.normalize("/" + path22.split("\\").join("/"));
3250
+ return pth.posix.join(".", safeSuffix);
3251
+ };
3252
+ Utils.findLast = function(arr, callback) {
3253
+ if (!Array.isArray(arr)) throw new TypeError("arr is not array");
3254
+ const len = arr.length >>> 0;
3255
+ for (let i = len - 1; i >= 0; i--) {
3256
+ if (callback(arr[i], i, arr)) {
3257
+ return arr[i];
3258
+ }
3259
+ }
3260
+ return void 0;
3261
+ };
3262
+ Utils.sanitize = function(prefix, name) {
3263
+ prefix = pth.resolve(pth.normalize(prefix));
3264
+ var parts = name.split("/");
3265
+ for (var i = 0, l = parts.length; i < l; i++) {
3266
+ var path22 = pth.normalize(pth.join(prefix, parts.slice(i, l).join(pth.sep)));
3267
+ if (path22.indexOf(prefix) === 0) {
3268
+ return path22;
3269
+ }
3270
+ }
3271
+ return pth.normalize(pth.join(prefix, pth.basename(name)));
3272
+ };
3273
+ Utils.toBuffer = function toBuffer(input, encoder) {
3274
+ if (Buffer.isBuffer(input)) {
3275
+ return input;
3276
+ } else if (input instanceof Uint8Array) {
3277
+ return Buffer.from(input);
3278
+ } else {
3279
+ return typeof input === "string" ? encoder(input) : Buffer.alloc(0);
3280
+ }
3281
+ };
3282
+ Utils.readBigUInt64LE = function(buffer, index) {
3283
+ var slice = Buffer.from(buffer.slice(index, index + 8));
3284
+ slice.swap64();
3285
+ return parseInt(`0x${slice.toString("hex")}`);
3286
+ };
3287
+ Utils.fromDOS2Date = function(val) {
3288
+ 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);
3289
+ };
3290
+ Utils.fromDate2DOS = function(val) {
3291
+ let date = 0;
3292
+ let time = 0;
3293
+ if (val.getFullYear() > 1979) {
3294
+ date = (val.getFullYear() - 1980 & 127) << 9 | val.getMonth() + 1 << 5 | val.getDate();
3295
+ time = val.getHours() << 11 | val.getMinutes() << 5 | val.getSeconds() >> 1;
3296
+ }
3297
+ return date << 16 | time;
3298
+ };
3299
+ Utils.isWin = isWin;
3300
+ Utils.crcTable = crcTable;
3301
+ }
3302
+ });
3303
+ var require_fattr2 = __commonJS2({
3304
+ "../../node_modules/adm-zip/util/fattr.js"(exports2, module2) {
3305
+ var pth = __require2("path");
3306
+ module2.exports = function(path22, { fs: fs22 }) {
3307
+ var _path = path22 || "", _obj = newAttr(), _stat = null;
3308
+ function newAttr() {
3309
+ return {
3310
+ directory: false,
3311
+ readonly: false,
3312
+ hidden: false,
3313
+ executable: false,
3314
+ mtime: 0,
3315
+ atime: 0
3316
+ };
3317
+ }
3318
+ if (_path && fs22.existsSync(_path)) {
3319
+ _stat = fs22.statSync(_path);
3320
+ _obj.directory = _stat.isDirectory();
3321
+ _obj.mtime = _stat.mtime;
3322
+ _obj.atime = _stat.atime;
3323
+ _obj.executable = (73 & _stat.mode) !== 0;
3324
+ _obj.readonly = (128 & _stat.mode) === 0;
3325
+ _obj.hidden = pth.basename(_path)[0] === ".";
3326
+ } else {
3327
+ console.warn("Invalid path: " + _path);
3328
+ }
3329
+ return {
3330
+ get directory() {
3331
+ return _obj.directory;
3332
+ },
3333
+ get readOnly() {
3334
+ return _obj.readonly;
3335
+ },
3336
+ get hidden() {
3337
+ return _obj.hidden;
3338
+ },
3339
+ get mtime() {
3340
+ return _obj.mtime;
3341
+ },
3342
+ get atime() {
3343
+ return _obj.atime;
3344
+ },
3345
+ get executable() {
3346
+ return _obj.executable;
3347
+ },
3348
+ decodeAttributes: function() {
3349
+ },
3350
+ encodeAttributes: function() {
3351
+ },
3352
+ toJSON: function() {
3353
+ return {
3354
+ path: _path,
3355
+ isDirectory: _obj.directory,
3356
+ isReadOnly: _obj.readonly,
3357
+ isHidden: _obj.hidden,
3358
+ isExecutable: _obj.executable,
3359
+ mTime: _obj.mtime,
3360
+ aTime: _obj.atime
3361
+ };
3362
+ },
3363
+ toString: function() {
3364
+ return JSON.stringify(this.toJSON(), null, " ");
3365
+ }
3366
+ };
3367
+ };
3368
+ }
3369
+ });
3370
+ var require_decoder2 = __commonJS2({
3371
+ "../../node_modules/adm-zip/util/decoder.js"(exports2, module2) {
3372
+ module2.exports = {
3373
+ efs: true,
3374
+ encode: (data) => Buffer.from(data, "utf8"),
3375
+ decode: (data) => data.toString("utf8")
3376
+ };
3377
+ }
3378
+ });
3379
+ var require_util2 = __commonJS2({
3380
+ "../../node_modules/adm-zip/util/index.js"(exports2, module2) {
3381
+ module2.exports = require_utils2();
3382
+ module2.exports.Constants = require_constants2();
3383
+ module2.exports.Errors = require_errors2();
3384
+ module2.exports.FileAttr = require_fattr2();
3385
+ module2.exports.decoder = require_decoder2();
3386
+ }
3387
+ });
3388
+ var require_entryHeader2 = __commonJS2({
3389
+ "../../node_modules/adm-zip/headers/entryHeader.js"(exports2, module2) {
3390
+ var Utils = require_util2();
3391
+ var Constants = Utils.Constants;
3392
+ module2.exports = function() {
3393
+ 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;
3394
+ _verMade |= Utils.isWin ? 2560 : 768;
3395
+ _flags |= Constants.FLG_EFS;
3396
+ const _localHeader = {
3397
+ extraLen: 0
3398
+ };
3399
+ const uint32 = (val) => Math.max(0, val) >>> 0;
3400
+ const uint8 = (val) => Math.max(0, val) & 255;
3401
+ _time = Utils.fromDate2DOS(/* @__PURE__ */ new Date());
3402
+ return {
3403
+ get made() {
3404
+ return _verMade;
3405
+ },
3406
+ set made(val) {
3407
+ _verMade = val;
3408
+ },
3409
+ get version() {
3410
+ return _version;
3411
+ },
3412
+ set version(val) {
3413
+ _version = val;
3414
+ },
3415
+ get flags() {
3416
+ return _flags;
3417
+ },
3418
+ set flags(val) {
3419
+ _flags = val;
3420
+ },
3421
+ get flags_efs() {
3422
+ return (_flags & Constants.FLG_EFS) > 0;
3423
+ },
3424
+ set flags_efs(val) {
3425
+ if (val) {
3426
+ _flags |= Constants.FLG_EFS;
3427
+ } else {
3428
+ _flags &= ~Constants.FLG_EFS;
3429
+ }
3430
+ },
3431
+ get flags_desc() {
3432
+ return (_flags & Constants.FLG_DESC) > 0;
3433
+ },
3434
+ set flags_desc(val) {
3435
+ if (val) {
3436
+ _flags |= Constants.FLG_DESC;
3437
+ } else {
3438
+ _flags &= ~Constants.FLG_DESC;
3439
+ }
3440
+ },
3441
+ get method() {
3442
+ return _method;
3443
+ },
3444
+ set method(val) {
3445
+ switch (val) {
3446
+ case Constants.STORED:
3447
+ this.version = 10;
3448
+ case Constants.DEFLATED:
3449
+ default:
3450
+ this.version = 20;
3451
+ }
3452
+ _method = val;
3453
+ },
3454
+ get time() {
3455
+ return Utils.fromDOS2Date(this.timeval);
3456
+ },
3457
+ set time(val) {
3458
+ this.timeval = Utils.fromDate2DOS(val);
3459
+ },
3460
+ get timeval() {
3461
+ return _time;
3462
+ },
3463
+ set timeval(val) {
3464
+ _time = uint32(val);
3465
+ },
3466
+ get timeHighByte() {
3467
+ return uint8(_time >>> 8);
3468
+ },
3469
+ get crc() {
3470
+ return _crc;
3471
+ },
3472
+ set crc(val) {
3473
+ _crc = uint32(val);
3474
+ },
3475
+ get compressedSize() {
3476
+ return _compressedSize;
3477
+ },
3478
+ set compressedSize(val) {
3479
+ _compressedSize = uint32(val);
3480
+ },
3481
+ get size() {
3482
+ return _size;
3483
+ },
3484
+ set size(val) {
3485
+ _size = uint32(val);
3486
+ },
3487
+ get fileNameLength() {
3488
+ return _fnameLen;
3489
+ },
3490
+ set fileNameLength(val) {
3491
+ _fnameLen = val;
3492
+ },
3493
+ get extraLength() {
3494
+ return _extraLen;
3495
+ },
3496
+ set extraLength(val) {
3497
+ _extraLen = val;
3498
+ },
3499
+ get extraLocalLength() {
3500
+ return _localHeader.extraLen;
3501
+ },
3502
+ set extraLocalLength(val) {
3503
+ _localHeader.extraLen = val;
3504
+ },
3505
+ get commentLength() {
3506
+ return _comLen;
3507
+ },
3508
+ set commentLength(val) {
3509
+ _comLen = val;
3510
+ },
3511
+ get diskNumStart() {
3512
+ return _diskStart;
3513
+ },
3514
+ set diskNumStart(val) {
3515
+ _diskStart = uint32(val);
3516
+ },
3517
+ get inAttr() {
3518
+ return _inattr;
3519
+ },
3520
+ set inAttr(val) {
3521
+ _inattr = uint32(val);
3522
+ },
3523
+ get attr() {
3524
+ return _attr;
3525
+ },
3526
+ set attr(val) {
3527
+ _attr = uint32(val);
3528
+ },
3529
+ // get Unix file permissions
3530
+ get fileAttr() {
3531
+ return (_attr || 0) >> 16 & 4095;
3532
+ },
3533
+ get offset() {
3534
+ return _offset;
3535
+ },
3536
+ set offset(val) {
3537
+ _offset = uint32(val);
3538
+ },
3539
+ get encrypted() {
3540
+ return (_flags & Constants.FLG_ENC) === Constants.FLG_ENC;
3541
+ },
3542
+ get centralHeaderSize() {
3543
+ return Constants.CENHDR + _fnameLen + _extraLen + _comLen;
3544
+ },
3545
+ get realDataOffset() {
3546
+ return _offset + Constants.LOCHDR + _localHeader.fnameLen + _localHeader.extraLen;
3547
+ },
3548
+ get localHeader() {
3549
+ return _localHeader;
3550
+ },
3551
+ loadLocalHeaderFromBinary: function(input) {
3552
+ var data = input.slice(_offset, _offset + Constants.LOCHDR);
3553
+ if (data.readUInt32LE(0) !== Constants.LOCSIG) {
3554
+ throw Utils.Errors.INVALID_LOC();
3555
+ }
3556
+ _localHeader.version = data.readUInt16LE(Constants.LOCVER);
3557
+ _localHeader.flags = data.readUInt16LE(Constants.LOCFLG);
3558
+ _localHeader.method = data.readUInt16LE(Constants.LOCHOW);
3559
+ _localHeader.time = data.readUInt32LE(Constants.LOCTIM);
3560
+ _localHeader.crc = data.readUInt32LE(Constants.LOCCRC);
3561
+ _localHeader.compressedSize = data.readUInt32LE(Constants.LOCSIZ);
3562
+ _localHeader.size = data.readUInt32LE(Constants.LOCLEN);
3563
+ _localHeader.fnameLen = data.readUInt16LE(Constants.LOCNAM);
3564
+ _localHeader.extraLen = data.readUInt16LE(Constants.LOCEXT);
3565
+ const extraStart = _offset + Constants.LOCHDR + _localHeader.fnameLen;
3566
+ const extraEnd = extraStart + _localHeader.extraLen;
3567
+ return input.slice(extraStart, extraEnd);
3568
+ },
3569
+ loadFromBinary: function(data) {
3570
+ if (data.length !== Constants.CENHDR || data.readUInt32LE(0) !== Constants.CENSIG) {
3571
+ throw Utils.Errors.INVALID_CEN();
3572
+ }
3573
+ _verMade = data.readUInt16LE(Constants.CENVEM);
3574
+ _version = data.readUInt16LE(Constants.CENVER);
3575
+ _flags = data.readUInt16LE(Constants.CENFLG);
3576
+ _method = data.readUInt16LE(Constants.CENHOW);
3577
+ _time = data.readUInt32LE(Constants.CENTIM);
3578
+ _crc = data.readUInt32LE(Constants.CENCRC);
3579
+ _compressedSize = data.readUInt32LE(Constants.CENSIZ);
3580
+ _size = data.readUInt32LE(Constants.CENLEN);
3581
+ _fnameLen = data.readUInt16LE(Constants.CENNAM);
3582
+ _extraLen = data.readUInt16LE(Constants.CENEXT);
3583
+ _comLen = data.readUInt16LE(Constants.CENCOM);
3584
+ _diskStart = data.readUInt16LE(Constants.CENDSK);
3585
+ _inattr = data.readUInt16LE(Constants.CENATT);
3586
+ _attr = data.readUInt32LE(Constants.CENATX);
3587
+ _offset = data.readUInt32LE(Constants.CENOFF);
3588
+ },
3589
+ localHeaderToBinary: function() {
3590
+ var data = Buffer.alloc(Constants.LOCHDR);
3591
+ data.writeUInt32LE(Constants.LOCSIG, 0);
3592
+ data.writeUInt16LE(_version, Constants.LOCVER);
3593
+ data.writeUInt16LE(_flags, Constants.LOCFLG);
3594
+ data.writeUInt16LE(_method, Constants.LOCHOW);
3595
+ data.writeUInt32LE(_time, Constants.LOCTIM);
3596
+ data.writeUInt32LE(_crc, Constants.LOCCRC);
3597
+ data.writeUInt32LE(_compressedSize, Constants.LOCSIZ);
3598
+ data.writeUInt32LE(_size, Constants.LOCLEN);
3599
+ data.writeUInt16LE(_fnameLen, Constants.LOCNAM);
3600
+ data.writeUInt16LE(_localHeader.extraLen, Constants.LOCEXT);
3601
+ return data;
3602
+ },
3603
+ centralHeaderToBinary: function() {
3604
+ var data = Buffer.alloc(Constants.CENHDR + _fnameLen + _extraLen + _comLen);
3605
+ data.writeUInt32LE(Constants.CENSIG, 0);
3606
+ data.writeUInt16LE(_verMade, Constants.CENVEM);
3607
+ data.writeUInt16LE(_version, Constants.CENVER);
3608
+ data.writeUInt16LE(_flags, Constants.CENFLG);
3609
+ data.writeUInt16LE(_method, Constants.CENHOW);
3610
+ data.writeUInt32LE(_time, Constants.CENTIM);
3611
+ data.writeUInt32LE(_crc, Constants.CENCRC);
3612
+ data.writeUInt32LE(_compressedSize, Constants.CENSIZ);
3613
+ data.writeUInt32LE(_size, Constants.CENLEN);
3614
+ data.writeUInt16LE(_fnameLen, Constants.CENNAM);
3615
+ data.writeUInt16LE(_extraLen, Constants.CENEXT);
3616
+ data.writeUInt16LE(_comLen, Constants.CENCOM);
3617
+ data.writeUInt16LE(_diskStart, Constants.CENDSK);
3618
+ data.writeUInt16LE(_inattr, Constants.CENATT);
3619
+ data.writeUInt32LE(_attr, Constants.CENATX);
3620
+ data.writeUInt32LE(_offset, Constants.CENOFF);
3621
+ return data;
3622
+ },
3623
+ toJSON: function() {
3624
+ const bytes = function(nr) {
3625
+ return nr + " bytes";
3626
+ };
3627
+ return {
3628
+ made: _verMade,
3629
+ version: _version,
3630
+ flags: _flags,
3631
+ method: Utils.methodToString(_method),
3632
+ time: this.time,
3633
+ crc: "0x" + _crc.toString(16).toUpperCase(),
3634
+ compressedSize: bytes(_compressedSize),
3635
+ size: bytes(_size),
3636
+ fileNameLength: bytes(_fnameLen),
3637
+ extraLength: bytes(_extraLen),
3638
+ commentLength: bytes(_comLen),
3639
+ diskNumStart: _diskStart,
3640
+ inAttr: _inattr,
3641
+ attr: _attr,
3642
+ offset: _offset,
3643
+ centralHeaderSize: bytes(Constants.CENHDR + _fnameLen + _extraLen + _comLen)
3644
+ };
3645
+ },
3646
+ toString: function() {
3647
+ return JSON.stringify(this.toJSON(), null, " ");
3648
+ }
3649
+ };
3650
+ };
3651
+ }
3652
+ });
3653
+ var require_mainHeader2 = __commonJS2({
3654
+ "../../node_modules/adm-zip/headers/mainHeader.js"(exports2, module2) {
3655
+ var Utils = require_util2();
3656
+ var Constants = Utils.Constants;
3657
+ module2.exports = function() {
3658
+ var _volumeEntries = 0, _totalEntries = 0, _size = 0, _offset = 0, _commentLength = 0;
3659
+ return {
3660
+ get diskEntries() {
3661
+ return _volumeEntries;
3662
+ },
3663
+ set diskEntries(val) {
3664
+ _volumeEntries = _totalEntries = val;
3665
+ },
3666
+ get totalEntries() {
3667
+ return _totalEntries;
3668
+ },
3669
+ set totalEntries(val) {
3670
+ _totalEntries = _volumeEntries = val;
3671
+ },
3672
+ get size() {
3673
+ return _size;
3674
+ },
3675
+ set size(val) {
3676
+ _size = val;
3677
+ },
3678
+ get offset() {
3679
+ return _offset;
3680
+ },
3681
+ set offset(val) {
3682
+ _offset = val;
3683
+ },
3684
+ get commentLength() {
3685
+ return _commentLength;
3686
+ },
3687
+ set commentLength(val) {
3688
+ _commentLength = val;
3689
+ },
3690
+ get mainHeaderSize() {
3691
+ return Constants.ENDHDR + _commentLength;
3692
+ },
3693
+ loadFromBinary: function(data) {
3694
+ if ((data.length !== Constants.ENDHDR || data.readUInt32LE(0) !== Constants.ENDSIG) && (data.length < Constants.ZIP64HDR || data.readUInt32LE(0) !== Constants.ZIP64SIG)) {
3695
+ throw Utils.Errors.INVALID_END();
3696
+ }
3697
+ if (data.readUInt32LE(0) === Constants.ENDSIG) {
3698
+ _volumeEntries = data.readUInt16LE(Constants.ENDSUB);
3699
+ _totalEntries = data.readUInt16LE(Constants.ENDTOT);
3700
+ _size = data.readUInt32LE(Constants.ENDSIZ);
3701
+ _offset = data.readUInt32LE(Constants.ENDOFF);
3702
+ _commentLength = data.readUInt16LE(Constants.ENDCOM);
3703
+ } else {
3704
+ _volumeEntries = Utils.readBigUInt64LE(data, Constants.ZIP64SUB);
3705
+ _totalEntries = Utils.readBigUInt64LE(data, Constants.ZIP64TOT);
3706
+ _size = Utils.readBigUInt64LE(data, Constants.ZIP64SIZE);
3707
+ _offset = Utils.readBigUInt64LE(data, Constants.ZIP64OFF);
3708
+ _commentLength = 0;
3709
+ }
3710
+ },
3711
+ toBinary: function() {
3712
+ var b = Buffer.alloc(Constants.ENDHDR + _commentLength);
3713
+ b.writeUInt32LE(Constants.ENDSIG, 0);
3714
+ b.writeUInt32LE(0, 4);
3715
+ b.writeUInt16LE(_volumeEntries, Constants.ENDSUB);
3716
+ b.writeUInt16LE(_totalEntries, Constants.ENDTOT);
3717
+ b.writeUInt32LE(_size, Constants.ENDSIZ);
3718
+ b.writeUInt32LE(_offset, Constants.ENDOFF);
3719
+ b.writeUInt16LE(_commentLength, Constants.ENDCOM);
3720
+ b.fill(" ", Constants.ENDHDR);
3721
+ return b;
3722
+ },
3723
+ toJSON: function() {
3724
+ const offset = function(nr, len) {
3725
+ let offs = nr.toString(16).toUpperCase();
3726
+ while (offs.length < len) offs = "0" + offs;
3727
+ return "0x" + offs;
3728
+ };
3729
+ return {
3730
+ diskEntries: _volumeEntries,
3731
+ totalEntries: _totalEntries,
3732
+ size: _size + " bytes",
3733
+ offset: offset(_offset, 4),
3734
+ commentLength: _commentLength
3735
+ };
3736
+ },
3737
+ toString: function() {
3738
+ return JSON.stringify(this.toJSON(), null, " ");
3739
+ }
3740
+ };
3741
+ };
3742
+ }
3743
+ });
3744
+ var require_headers2 = __commonJS2({
3745
+ "../../node_modules/adm-zip/headers/index.js"(exports2) {
3746
+ exports2.EntryHeader = require_entryHeader2();
3747
+ exports2.MainHeader = require_mainHeader2();
3748
+ }
3749
+ });
3750
+ var require_deflater2 = __commonJS2({
3751
+ "../../node_modules/adm-zip/methods/deflater.js"(exports2, module2) {
3752
+ module2.exports = function(inbuf) {
3753
+ var zlib = __require2("zlib");
3754
+ var opts = { chunkSize: (parseInt(inbuf.length / 1024) + 1) * 1024 };
3755
+ return {
3756
+ deflate: function() {
3757
+ return zlib.deflateRawSync(inbuf, opts);
3758
+ },
3759
+ deflateAsync: function(callback) {
3760
+ var tmp = zlib.createDeflateRaw(opts), parts = [], total = 0;
3761
+ tmp.on("data", function(data) {
3762
+ parts.push(data);
3763
+ total += data.length;
3764
+ });
3765
+ tmp.on("end", function() {
3766
+ var buf = Buffer.alloc(total), written = 0;
3767
+ buf.fill(0);
3768
+ for (var i = 0; i < parts.length; i++) {
3769
+ var part = parts[i];
3770
+ part.copy(buf, written);
3771
+ written += part.length;
3772
+ }
3773
+ callback && callback(buf);
3774
+ });
3775
+ tmp.end(inbuf);
3776
+ }
3777
+ };
3778
+ };
3779
+ }
3780
+ });
3781
+ var require_inflater2 = __commonJS2({
3782
+ "../../node_modules/adm-zip/methods/inflater.js"(exports2, module2) {
3783
+ var version = +(process.versions ? process.versions.node : "").split(".")[0] || 0;
3784
+ module2.exports = function(inbuf, expectedLength) {
3785
+ var zlib = __require2("zlib");
3786
+ const option = version >= 15 && expectedLength > 0 ? { maxOutputLength: expectedLength } : {};
3787
+ return {
3788
+ inflate: function() {
3789
+ return zlib.inflateRawSync(inbuf, option);
3790
+ },
3791
+ inflateAsync: function(callback) {
3792
+ var tmp = zlib.createInflateRaw(option), parts = [], total = 0;
3793
+ tmp.on("data", function(data) {
3794
+ parts.push(data);
3795
+ total += data.length;
3796
+ });
3797
+ tmp.on("end", function() {
3798
+ var buf = Buffer.alloc(total), written = 0;
3799
+ buf.fill(0);
3800
+ for (var i = 0; i < parts.length; i++) {
3801
+ var part = parts[i];
3802
+ part.copy(buf, written);
3803
+ written += part.length;
3804
+ }
3805
+ callback && callback(buf);
3806
+ });
3807
+ tmp.end(inbuf);
3808
+ }
3809
+ };
3810
+ };
3811
+ }
3812
+ });
3813
+ var require_zipcrypto2 = __commonJS2({
3814
+ "../../node_modules/adm-zip/methods/zipcrypto.js"(exports2, module2) {
3815
+ var { randomFillSync } = __require2("crypto");
3816
+ var Errors = require_errors2();
3817
+ var crctable = new Uint32Array(256).map((t, crc) => {
3818
+ for (let j = 0; j < 8; j++) {
3819
+ if (0 !== (crc & 1)) {
3820
+ crc = crc >>> 1 ^ 3988292384;
3821
+ } else {
3822
+ crc >>>= 1;
3823
+ }
3824
+ }
3825
+ return crc >>> 0;
3826
+ });
3827
+ var uMul = (a, b) => Math.imul(a, b) >>> 0;
3828
+ var crc32update = (pCrc32, bval) => {
3829
+ return crctable[(pCrc32 ^ bval) & 255] ^ pCrc32 >>> 8;
3830
+ };
3831
+ var genSalt = () => {
3832
+ if ("function" === typeof randomFillSync) {
3833
+ return randomFillSync(Buffer.alloc(12));
3834
+ } else {
3835
+ return genSalt.node();
3836
+ }
3837
+ };
3838
+ genSalt.node = () => {
3839
+ const salt = Buffer.alloc(12);
3840
+ const len = salt.length;
3841
+ for (let i = 0; i < len; i++) salt[i] = Math.random() * 256 & 255;
3842
+ return salt;
3843
+ };
3844
+ var config = {
3845
+ genSalt
3846
+ };
3847
+ function Initkeys(pw) {
3848
+ const pass = Buffer.isBuffer(pw) ? pw : Buffer.from(pw);
3849
+ this.keys = new Uint32Array([305419896, 591751049, 878082192]);
3850
+ for (let i = 0; i < pass.length; i++) {
3851
+ this.updateKeys(pass[i]);
3852
+ }
3853
+ }
3854
+ Initkeys.prototype.updateKeys = function(byteValue) {
3855
+ const keys = this.keys;
3856
+ keys[0] = crc32update(keys[0], byteValue);
3857
+ keys[1] += keys[0] & 255;
3858
+ keys[1] = uMul(keys[1], 134775813) + 1;
3859
+ keys[2] = crc32update(keys[2], keys[1] >>> 24);
3860
+ return byteValue;
3861
+ };
3862
+ Initkeys.prototype.next = function() {
3863
+ const k = (this.keys[2] | 2) >>> 0;
3864
+ return uMul(k, k ^ 1) >> 8 & 255;
3865
+ };
3866
+ function make_decrypter(pwd) {
3867
+ const keys = new Initkeys(pwd);
3868
+ return function(data) {
3869
+ const result = Buffer.alloc(data.length);
3870
+ let pos = 0;
3871
+ for (let c of data) {
3872
+ result[pos++] = keys.updateKeys(c ^ keys.next());
3873
+ }
3874
+ return result;
3875
+ };
3876
+ }
3877
+ function make_encrypter(pwd) {
3878
+ const keys = new Initkeys(pwd);
3879
+ return function(data, result, pos = 0) {
3880
+ if (!result) result = Buffer.alloc(data.length);
3881
+ for (let c of data) {
3882
+ const k = keys.next();
3883
+ result[pos++] = c ^ k;
3884
+ keys.updateKeys(c);
3885
+ }
3886
+ return result;
3887
+ };
3888
+ }
3889
+ function decrypt(data, header, pwd) {
3890
+ if (!data || !Buffer.isBuffer(data) || data.length < 12) {
3891
+ return Buffer.alloc(0);
3892
+ }
3893
+ const decrypter = make_decrypter(pwd);
3894
+ const salt = decrypter(data.slice(0, 12));
3895
+ const verifyByte = (header.flags & 8) === 8 ? header.timeHighByte : header.crc >>> 24;
3896
+ if (salt[11] !== verifyByte) {
3897
+ throw Errors.WRONG_PASSWORD();
3898
+ }
3899
+ return decrypter(data.slice(12));
3900
+ }
3901
+ function _salter(data) {
3902
+ if (Buffer.isBuffer(data) && data.length >= 12) {
3903
+ config.genSalt = function() {
3904
+ return data.slice(0, 12);
3905
+ };
3906
+ } else if (data === "node") {
3907
+ config.genSalt = genSalt.node;
3908
+ } else {
3909
+ config.genSalt = genSalt;
3910
+ }
3911
+ }
3912
+ function encrypt(data, header, pwd, oldlike = false) {
3913
+ if (data == null) data = Buffer.alloc(0);
3914
+ if (!Buffer.isBuffer(data)) data = Buffer.from(data.toString());
3915
+ const encrypter = make_encrypter(pwd);
3916
+ const salt = config.genSalt();
3917
+ salt[11] = header.crc >>> 24 & 255;
3918
+ if (oldlike) salt[10] = header.crc >>> 16 & 255;
3919
+ const result = Buffer.alloc(data.length + 12);
3920
+ encrypter(salt, result);
3921
+ return encrypter(data, result, 12);
3922
+ }
3923
+ module2.exports = { decrypt, encrypt, _salter };
3924
+ }
3925
+ });
3926
+ var require_methods2 = __commonJS2({
3927
+ "../../node_modules/adm-zip/methods/index.js"(exports2) {
3928
+ exports2.Deflater = require_deflater2();
3929
+ exports2.Inflater = require_inflater2();
3930
+ exports2.ZipCrypto = require_zipcrypto2();
3931
+ }
3932
+ });
3933
+ var require_zipEntry2 = __commonJS2({
3934
+ "../../node_modules/adm-zip/zipEntry.js"(exports2, module2) {
3935
+ var Utils = require_util2();
3936
+ var Headers = require_headers2();
3937
+ var Constants = Utils.Constants;
3938
+ var Methods = require_methods2();
3939
+ module2.exports = function(options, input) {
3940
+ 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;
3941
+ const opts = options;
3942
+ const decoder = typeof opts.decoder === "object" ? opts.decoder : Utils.decoder;
3943
+ _efs = decoder.hasOwnProperty("efs") ? decoder.efs : false;
3944
+ function getCompressedDataFromZip() {
3945
+ if (!input || !(input instanceof Uint8Array)) {
3946
+ return Buffer.alloc(0);
3947
+ }
3948
+ _extralocal = _centralHeader.loadLocalHeaderFromBinary(input);
3949
+ return input.slice(_centralHeader.realDataOffset, _centralHeader.realDataOffset + _centralHeader.compressedSize);
3950
+ }
3951
+ function crc32OK(data) {
3952
+ if (!_centralHeader.flags_desc) {
3953
+ if (Utils.crc32(data) !== _centralHeader.localHeader.crc) {
3954
+ return false;
3955
+ }
3956
+ } else {
3957
+ const descriptor = {};
3958
+ const dataEndOffset = _centralHeader.realDataOffset + _centralHeader.compressedSize;
3959
+ if (input.readUInt32LE(dataEndOffset) == Constants.LOCSIG || input.readUInt32LE(dataEndOffset) == Constants.CENSIG) {
3960
+ throw Utils.Errors.DESCRIPTOR_NOT_EXIST();
3961
+ }
3962
+ if (input.readUInt32LE(dataEndOffset) == Constants.EXTSIG) {
3963
+ descriptor.crc = input.readUInt32LE(dataEndOffset + Constants.EXTCRC);
3964
+ descriptor.compressedSize = input.readUInt32LE(dataEndOffset + Constants.EXTSIZ);
3965
+ descriptor.size = input.readUInt32LE(dataEndOffset + Constants.EXTLEN);
3966
+ } else if (input.readUInt16LE(dataEndOffset + 12) === 19280) {
3967
+ descriptor.crc = input.readUInt32LE(dataEndOffset + Constants.EXTCRC - 4);
3968
+ descriptor.compressedSize = input.readUInt32LE(dataEndOffset + Constants.EXTSIZ - 4);
3969
+ descriptor.size = input.readUInt32LE(dataEndOffset + Constants.EXTLEN - 4);
3970
+ } else {
3971
+ throw Utils.Errors.DESCRIPTOR_UNKNOWN();
3972
+ }
3973
+ if (descriptor.compressedSize !== _centralHeader.compressedSize || descriptor.size !== _centralHeader.size || descriptor.crc !== _centralHeader.crc) {
3974
+ throw Utils.Errors.DESCRIPTOR_FAULTY();
3975
+ }
3976
+ if (Utils.crc32(data) !== descriptor.crc) {
3977
+ return false;
3978
+ }
3979
+ }
3980
+ return true;
3981
+ }
3982
+ function decompress(async, callback, pass) {
3983
+ if (typeof callback === "undefined" && typeof async === "string") {
3984
+ pass = async;
3985
+ async = void 0;
3986
+ }
3987
+ if (_isDirectory) {
3988
+ if (async && callback) {
3989
+ callback(Buffer.alloc(0), Utils.Errors.DIRECTORY_CONTENT_ERROR());
3990
+ }
3991
+ return Buffer.alloc(0);
3992
+ }
3993
+ var compressedData = getCompressedDataFromZip();
3994
+ if (compressedData.length === 0) {
3995
+ if (async && callback) callback(compressedData);
3996
+ return compressedData;
3997
+ }
3998
+ if (_centralHeader.encrypted) {
3999
+ if ("string" !== typeof pass && !Buffer.isBuffer(pass)) {
4000
+ throw Utils.Errors.INVALID_PASS_PARAM();
4001
+ }
4002
+ compressedData = Methods.ZipCrypto.decrypt(compressedData, _centralHeader, pass);
4003
+ }
4004
+ var data = Buffer.alloc(_centralHeader.size);
4005
+ switch (_centralHeader.method) {
4006
+ case Utils.Constants.STORED:
4007
+ compressedData.copy(data);
4008
+ if (!crc32OK(data)) {
4009
+ if (async && callback) callback(data, Utils.Errors.BAD_CRC());
4010
+ throw Utils.Errors.BAD_CRC();
4011
+ } else {
4012
+ if (async && callback) callback(data);
4013
+ return data;
4014
+ }
4015
+ case Utils.Constants.DEFLATED:
4016
+ var inflater = new Methods.Inflater(compressedData, _centralHeader.size);
4017
+ if (!async) {
4018
+ const result = inflater.inflate(data);
4019
+ result.copy(data, 0);
4020
+ if (!crc32OK(data)) {
4021
+ throw Utils.Errors.BAD_CRC(`"${decoder.decode(_entryName)}"`);
4022
+ }
4023
+ return data;
4024
+ } else {
4025
+ inflater.inflateAsync(function(result) {
4026
+ result.copy(result, 0);
4027
+ if (callback) {
4028
+ if (!crc32OK(result)) {
4029
+ callback(result, Utils.Errors.BAD_CRC());
4030
+ } else {
4031
+ callback(result);
4032
+ }
4033
+ }
4034
+ });
4035
+ }
4036
+ break;
4037
+ default:
4038
+ if (async && callback) callback(Buffer.alloc(0), Utils.Errors.UNKNOWN_METHOD());
4039
+ throw Utils.Errors.UNKNOWN_METHOD();
4040
+ }
4041
+ }
4042
+ function compress(async, callback) {
4043
+ if ((!uncompressedData || !uncompressedData.length) && Buffer.isBuffer(input)) {
4044
+ if (async && callback) callback(getCompressedDataFromZip());
4045
+ return getCompressedDataFromZip();
4046
+ }
4047
+ if (uncompressedData.length && !_isDirectory) {
4048
+ var compressedData;
4049
+ switch (_centralHeader.method) {
4050
+ case Utils.Constants.STORED:
4051
+ _centralHeader.compressedSize = _centralHeader.size;
4052
+ compressedData = Buffer.alloc(uncompressedData.length);
4053
+ uncompressedData.copy(compressedData);
4054
+ if (async && callback) callback(compressedData);
4055
+ return compressedData;
4056
+ default:
4057
+ case Utils.Constants.DEFLATED:
4058
+ var deflater = new Methods.Deflater(uncompressedData);
4059
+ if (!async) {
4060
+ var deflated = deflater.deflate();
4061
+ _centralHeader.compressedSize = deflated.length;
4062
+ return deflated;
4063
+ } else {
4064
+ deflater.deflateAsync(function(data) {
4065
+ compressedData = Buffer.alloc(data.length);
4066
+ _centralHeader.compressedSize = data.length;
4067
+ data.copy(compressedData);
4068
+ callback && callback(compressedData);
4069
+ });
4070
+ }
4071
+ deflater = null;
4072
+ break;
4073
+ }
4074
+ } else if (async && callback) {
4075
+ callback(Buffer.alloc(0));
4076
+ } else {
4077
+ return Buffer.alloc(0);
4078
+ }
4079
+ }
4080
+ function readUInt64LE(buffer, offset) {
4081
+ return (buffer.readUInt32LE(offset + 4) << 4) + buffer.readUInt32LE(offset);
4082
+ }
4083
+ function parseExtra(data) {
4084
+ try {
4085
+ var offset = 0;
4086
+ var signature, size, part;
4087
+ while (offset + 4 < data.length) {
4088
+ signature = data.readUInt16LE(offset);
4089
+ offset += 2;
4090
+ size = data.readUInt16LE(offset);
4091
+ offset += 2;
4092
+ part = data.slice(offset, offset + size);
4093
+ offset += size;
4094
+ if (Constants.ID_ZIP64 === signature) {
4095
+ parseZip64ExtendedInformation(part);
4096
+ }
4097
+ }
4098
+ } catch (error) {
4099
+ throw Utils.Errors.EXTRA_FIELD_PARSE_ERROR();
4100
+ }
4101
+ }
4102
+ function parseZip64ExtendedInformation(data) {
4103
+ var size, compressedSize, offset, diskNumStart;
4104
+ if (data.length >= Constants.EF_ZIP64_SCOMP) {
4105
+ size = readUInt64LE(data, Constants.EF_ZIP64_SUNCOMP);
4106
+ if (_centralHeader.size === Constants.EF_ZIP64_OR_32) {
4107
+ _centralHeader.size = size;
4108
+ }
4109
+ }
4110
+ if (data.length >= Constants.EF_ZIP64_RHO) {
4111
+ compressedSize = readUInt64LE(data, Constants.EF_ZIP64_SCOMP);
4112
+ if (_centralHeader.compressedSize === Constants.EF_ZIP64_OR_32) {
4113
+ _centralHeader.compressedSize = compressedSize;
4114
+ }
4115
+ }
4116
+ if (data.length >= Constants.EF_ZIP64_DSN) {
4117
+ offset = readUInt64LE(data, Constants.EF_ZIP64_RHO);
4118
+ if (_centralHeader.offset === Constants.EF_ZIP64_OR_32) {
4119
+ _centralHeader.offset = offset;
4120
+ }
4121
+ }
4122
+ if (data.length >= Constants.EF_ZIP64_DSN + 4) {
4123
+ diskNumStart = data.readUInt32LE(Constants.EF_ZIP64_DSN);
4124
+ if (_centralHeader.diskNumStart === Constants.EF_ZIP64_OR_16) {
4125
+ _centralHeader.diskNumStart = diskNumStart;
4126
+ }
4127
+ }
4128
+ }
4129
+ return {
4130
+ get entryName() {
4131
+ return decoder.decode(_entryName);
4132
+ },
4133
+ get rawEntryName() {
4134
+ return _entryName;
4135
+ },
4136
+ set entryName(val) {
4137
+ _entryName = Utils.toBuffer(val, decoder.encode);
4138
+ var lastChar = _entryName[_entryName.length - 1];
4139
+ _isDirectory = lastChar === 47 || lastChar === 92;
4140
+ _centralHeader.fileNameLength = _entryName.length;
4141
+ },
4142
+ get efs() {
4143
+ if (typeof _efs === "function") {
4144
+ return _efs(this.entryName);
4145
+ } else {
4146
+ return _efs;
4147
+ }
4148
+ },
4149
+ get extra() {
4150
+ return _extra;
4151
+ },
4152
+ set extra(val) {
4153
+ _extra = val;
4154
+ _centralHeader.extraLength = val.length;
4155
+ parseExtra(val);
4156
+ },
4157
+ get comment() {
4158
+ return decoder.decode(_comment);
4159
+ },
4160
+ set comment(val) {
4161
+ _comment = Utils.toBuffer(val, decoder.encode);
4162
+ _centralHeader.commentLength = _comment.length;
4163
+ if (_comment.length > 65535) throw Utils.Errors.COMMENT_TOO_LONG();
4164
+ },
4165
+ get name() {
4166
+ var n = decoder.decode(_entryName);
4167
+ return _isDirectory ? n.substr(n.length - 1).split("/").pop() : n.split("/").pop();
4168
+ },
4169
+ get isDirectory() {
4170
+ return _isDirectory;
4171
+ },
4172
+ getCompressedData: function() {
4173
+ return compress(false, null);
4174
+ },
4175
+ getCompressedDataAsync: function(callback) {
4176
+ compress(true, callback);
4177
+ },
4178
+ setData: function(value) {
4179
+ uncompressedData = Utils.toBuffer(value, Utils.decoder.encode);
4180
+ if (!_isDirectory && uncompressedData.length) {
4181
+ _centralHeader.size = uncompressedData.length;
4182
+ _centralHeader.method = Utils.Constants.DEFLATED;
4183
+ _centralHeader.crc = Utils.crc32(value);
4184
+ _centralHeader.changed = true;
4185
+ } else {
4186
+ _centralHeader.method = Utils.Constants.STORED;
4187
+ }
4188
+ },
4189
+ getData: function(pass) {
4190
+ if (_centralHeader.changed) {
4191
+ return uncompressedData;
4192
+ } else {
4193
+ return decompress(false, null, pass);
4194
+ }
4195
+ },
4196
+ getDataAsync: function(callback, pass) {
4197
+ if (_centralHeader.changed) {
4198
+ callback(uncompressedData);
4199
+ } else {
4200
+ decompress(true, callback, pass);
4201
+ }
4202
+ },
4203
+ set attr(attr) {
4204
+ _centralHeader.attr = attr;
4205
+ },
4206
+ get attr() {
4207
+ return _centralHeader.attr;
4208
+ },
4209
+ set header(data) {
4210
+ _centralHeader.loadFromBinary(data);
4211
+ },
4212
+ get header() {
4213
+ return _centralHeader;
4214
+ },
4215
+ packCentralHeader: function() {
4216
+ _centralHeader.flags_efs = this.efs;
4217
+ _centralHeader.extraLength = _extra.length;
4218
+ var header = _centralHeader.centralHeaderToBinary();
4219
+ var addpos = Utils.Constants.CENHDR;
4220
+ _entryName.copy(header, addpos);
4221
+ addpos += _entryName.length;
4222
+ _extra.copy(header, addpos);
4223
+ addpos += _centralHeader.extraLength;
4224
+ _comment.copy(header, addpos);
4225
+ return header;
4226
+ },
4227
+ packLocalHeader: function() {
4228
+ let addpos = 0;
4229
+ _centralHeader.flags_efs = this.efs;
4230
+ _centralHeader.extraLocalLength = _extralocal.length;
4231
+ const localHeaderBuf = _centralHeader.localHeaderToBinary();
4232
+ const localHeader = Buffer.alloc(localHeaderBuf.length + _entryName.length + _centralHeader.extraLocalLength);
4233
+ localHeaderBuf.copy(localHeader, addpos);
4234
+ addpos += localHeaderBuf.length;
4235
+ _entryName.copy(localHeader, addpos);
4236
+ addpos += _entryName.length;
4237
+ _extralocal.copy(localHeader, addpos);
4238
+ addpos += _extralocal.length;
4239
+ return localHeader;
4240
+ },
4241
+ toJSON: function() {
4242
+ const bytes = function(nr) {
4243
+ return "<" + (nr && nr.length + " bytes buffer" || "null") + ">";
4244
+ };
4245
+ return {
4246
+ entryName: this.entryName,
4247
+ name: this.name,
4248
+ comment: this.comment,
4249
+ isDirectory: this.isDirectory,
4250
+ header: _centralHeader.toJSON(),
4251
+ compressedData: bytes(input),
4252
+ data: bytes(uncompressedData)
4253
+ };
4254
+ },
4255
+ toString: function() {
4256
+ return JSON.stringify(this.toJSON(), null, " ");
4257
+ }
4258
+ };
4259
+ };
4260
+ }
4261
+ });
4262
+ var require_zipFile2 = __commonJS2({
4263
+ "../../node_modules/adm-zip/zipFile.js"(exports2, module2) {
4264
+ var ZipEntry = require_zipEntry2();
4265
+ var Headers = require_headers2();
4266
+ var Utils = require_util2();
4267
+ module2.exports = function(inBuffer, options) {
4268
+ var entryList = [], entryTable = {}, _comment = Buffer.alloc(0), mainHeader = new Headers.MainHeader(), loadedEntries = false;
4269
+ const temporary = /* @__PURE__ */ new Set();
4270
+ const opts = options;
4271
+ const { noSort, decoder } = opts;
4272
+ if (inBuffer) {
4273
+ readMainHeader(opts.readEntries);
4274
+ } else {
4275
+ loadedEntries = true;
4276
+ }
4277
+ function makeTemporaryFolders() {
4278
+ const foldersList = /* @__PURE__ */ new Set();
4279
+ for (const elem of Object.keys(entryTable)) {
4280
+ const elements = elem.split("/");
4281
+ elements.pop();
4282
+ if (!elements.length) continue;
4283
+ for (let i = 0; i < elements.length; i++) {
4284
+ const sub = elements.slice(0, i + 1).join("/") + "/";
4285
+ foldersList.add(sub);
4286
+ }
4287
+ }
4288
+ for (const elem of foldersList) {
4289
+ if (!(elem in entryTable)) {
4290
+ const tempfolder = new ZipEntry(opts);
4291
+ tempfolder.entryName = elem;
4292
+ tempfolder.attr = 16;
4293
+ tempfolder.temporary = true;
4294
+ entryList.push(tempfolder);
4295
+ entryTable[tempfolder.entryName] = tempfolder;
4296
+ temporary.add(tempfolder);
4297
+ }
4298
+ }
4299
+ }
4300
+ function readEntries() {
4301
+ loadedEntries = true;
4302
+ entryTable = {};
4303
+ if (mainHeader.diskEntries > (inBuffer.length - mainHeader.offset) / Utils.Constants.CENHDR) {
4304
+ throw Utils.Errors.DISK_ENTRY_TOO_LARGE();
4305
+ }
4306
+ entryList = new Array(mainHeader.diskEntries);
4307
+ var index = mainHeader.offset;
4308
+ for (var i = 0; i < entryList.length; i++) {
4309
+ var tmp = index, entry = new ZipEntry(opts, inBuffer);
4310
+ entry.header = inBuffer.slice(tmp, tmp += Utils.Constants.CENHDR);
4311
+ entry.entryName = inBuffer.slice(tmp, tmp += entry.header.fileNameLength);
4312
+ if (entry.header.extraLength) {
4313
+ entry.extra = inBuffer.slice(tmp, tmp += entry.header.extraLength);
4314
+ }
4315
+ if (entry.header.commentLength) entry.comment = inBuffer.slice(tmp, tmp + entry.header.commentLength);
4316
+ index += entry.header.centralHeaderSize;
4317
+ entryList[i] = entry;
4318
+ entryTable[entry.entryName] = entry;
4319
+ }
4320
+ temporary.clear();
4321
+ makeTemporaryFolders();
4322
+ }
4323
+ function readMainHeader(readNow) {
4324
+ var i = inBuffer.length - Utils.Constants.ENDHDR, max = Math.max(0, i - 65535), n = max, endStart = inBuffer.length, endOffset = -1, commentEnd = 0;
4325
+ const trailingSpace = typeof opts.trailingSpace === "boolean" ? opts.trailingSpace : false;
4326
+ if (trailingSpace) max = 0;
4327
+ for (i; i >= n; i--) {
4328
+ if (inBuffer[i] !== 80) continue;
4329
+ if (inBuffer.readUInt32LE(i) === Utils.Constants.ENDSIG) {
4330
+ endOffset = i;
4331
+ commentEnd = i;
4332
+ endStart = i + Utils.Constants.ENDHDR;
4333
+ n = i - Utils.Constants.END64HDR;
4334
+ continue;
4335
+ }
4336
+ if (inBuffer.readUInt32LE(i) === Utils.Constants.END64SIG) {
4337
+ n = max;
4338
+ continue;
4339
+ }
4340
+ if (inBuffer.readUInt32LE(i) === Utils.Constants.ZIP64SIG) {
4341
+ endOffset = i;
4342
+ endStart = i + Utils.readBigUInt64LE(inBuffer, i + Utils.Constants.ZIP64SIZE) + Utils.Constants.ZIP64LEAD;
4343
+ break;
4344
+ }
4345
+ }
4346
+ if (endOffset == -1) throw Utils.Errors.INVALID_FORMAT();
4347
+ mainHeader.loadFromBinary(inBuffer.slice(endOffset, endStart));
4348
+ if (mainHeader.commentLength) {
4349
+ _comment = inBuffer.slice(commentEnd + Utils.Constants.ENDHDR);
4350
+ }
4351
+ if (readNow) readEntries();
4352
+ }
4353
+ function sortEntries() {
4354
+ if (entryList.length > 1 && !noSort) {
4355
+ entryList.sort((a, b) => a.entryName.toLowerCase().localeCompare(b.entryName.toLowerCase()));
4356
+ }
4357
+ }
4358
+ return {
4359
+ /**
4360
+ * Returns an array of ZipEntry objects existent in the current opened archive
4361
+ * @return Array
4362
+ */
4363
+ get entries() {
4364
+ if (!loadedEntries) {
4365
+ readEntries();
4366
+ }
4367
+ return entryList.filter((e) => !temporary.has(e));
4368
+ },
4369
+ /**
4370
+ * Archive comment
4371
+ * @return {String}
4372
+ */
4373
+ get comment() {
4374
+ return decoder.decode(_comment);
4375
+ },
4376
+ set comment(val) {
4377
+ _comment = Utils.toBuffer(val, decoder.encode);
4378
+ mainHeader.commentLength = _comment.length;
4379
+ },
4380
+ getEntryCount: function() {
4381
+ if (!loadedEntries) {
4382
+ return mainHeader.diskEntries;
4383
+ }
4384
+ return entryList.length;
4385
+ },
4386
+ forEach: function(callback) {
4387
+ this.entries.forEach(callback);
4388
+ },
4389
+ /**
4390
+ * Returns a reference to the entry with the given name or null if entry is inexistent
4391
+ *
4392
+ * @param entryName
4393
+ * @return ZipEntry
4394
+ */
4395
+ getEntry: function(entryName) {
4396
+ if (!loadedEntries) {
4397
+ readEntries();
4398
+ }
4399
+ return entryTable[entryName] || null;
4400
+ },
4401
+ /**
4402
+ * Adds the given entry to the entry list
4403
+ *
4404
+ * @param entry
4405
+ */
4406
+ setEntry: function(entry) {
4407
+ if (!loadedEntries) {
4408
+ readEntries();
4409
+ }
4410
+ entryList.push(entry);
4411
+ entryTable[entry.entryName] = entry;
4412
+ mainHeader.totalEntries = entryList.length;
4413
+ },
4414
+ /**
4415
+ * Removes the file with the given name from the entry list.
4416
+ *
4417
+ * If the entry is a directory, then all nested files and directories will be removed
4418
+ * @param entryName
4419
+ * @returns {void}
4420
+ */
4421
+ deleteFile: function(entryName, withsubfolders = true) {
4422
+ if (!loadedEntries) {
4423
+ readEntries();
4424
+ }
4425
+ const entry = entryTable[entryName];
4426
+ const list = this.getEntryChildren(entry, withsubfolders).map((child) => child.entryName);
4427
+ list.forEach(this.deleteEntry);
4428
+ },
4429
+ /**
4430
+ * Removes the entry with the given name from the entry list.
4431
+ *
4432
+ * @param {string} entryName
4433
+ * @returns {void}
4434
+ */
4435
+ deleteEntry: function(entryName) {
4436
+ if (!loadedEntries) {
4437
+ readEntries();
4438
+ }
4439
+ const entry = entryTable[entryName];
4440
+ const index = entryList.indexOf(entry);
4441
+ if (index >= 0) {
4442
+ entryList.splice(index, 1);
4443
+ delete entryTable[entryName];
4444
+ mainHeader.totalEntries = entryList.length;
4445
+ }
4446
+ },
4447
+ /**
4448
+ * Iterates and returns all nested files and directories of the given entry
4449
+ *
4450
+ * @param entry
4451
+ * @return Array
4452
+ */
4453
+ getEntryChildren: function(entry, subfolders = true) {
4454
+ if (!loadedEntries) {
4455
+ readEntries();
4456
+ }
4457
+ if (typeof entry === "object") {
4458
+ if (entry.isDirectory && subfolders) {
4459
+ const list = [];
4460
+ const name = entry.entryName;
4461
+ for (const zipEntry of entryList) {
4462
+ if (zipEntry.entryName.startsWith(name)) {
4463
+ list.push(zipEntry);
4464
+ }
4465
+ }
4466
+ return list;
4467
+ } else {
4468
+ return [entry];
4469
+ }
4470
+ }
4471
+ return [];
4472
+ },
4473
+ /**
4474
+ * How many child elements entry has
4475
+ *
4476
+ * @param {ZipEntry} entry
4477
+ * @return {integer}
4478
+ */
4479
+ getChildCount: function(entry) {
4480
+ if (entry && entry.isDirectory) {
4481
+ const list = this.getEntryChildren(entry);
4482
+ return list.includes(entry) ? list.length - 1 : list.length;
4483
+ }
4484
+ return 0;
4485
+ },
4486
+ /**
4487
+ * Returns the zip file
4488
+ *
4489
+ * @return Buffer
4490
+ */
4491
+ compressToBuffer: function() {
4492
+ if (!loadedEntries) {
4493
+ readEntries();
4494
+ }
4495
+ sortEntries();
4496
+ const dataBlock = [];
4497
+ const headerBlocks = [];
4498
+ let totalSize = 0;
4499
+ let dindex = 0;
4500
+ mainHeader.size = 0;
4501
+ mainHeader.offset = 0;
4502
+ let totalEntries = 0;
4503
+ for (const entry of this.entries) {
4504
+ const compressedData = entry.getCompressedData();
4505
+ entry.header.offset = dindex;
4506
+ const localHeader = entry.packLocalHeader();
4507
+ const dataLength = localHeader.length + compressedData.length;
4508
+ dindex += dataLength;
4509
+ dataBlock.push(localHeader);
4510
+ dataBlock.push(compressedData);
4511
+ const centralHeader = entry.packCentralHeader();
4512
+ headerBlocks.push(centralHeader);
4513
+ mainHeader.size += centralHeader.length;
4514
+ totalSize += dataLength + centralHeader.length;
4515
+ totalEntries++;
4516
+ }
4517
+ totalSize += mainHeader.mainHeaderSize;
4518
+ mainHeader.offset = dindex;
4519
+ mainHeader.totalEntries = totalEntries;
4520
+ dindex = 0;
4521
+ const outBuffer = Buffer.alloc(totalSize);
4522
+ for (const content of dataBlock) {
4523
+ content.copy(outBuffer, dindex);
4524
+ dindex += content.length;
4525
+ }
4526
+ for (const content of headerBlocks) {
4527
+ content.copy(outBuffer, dindex);
4528
+ dindex += content.length;
4529
+ }
4530
+ const mh = mainHeader.toBinary();
4531
+ if (_comment) {
4532
+ _comment.copy(mh, Utils.Constants.ENDHDR);
4533
+ }
4534
+ mh.copy(outBuffer, dindex);
4535
+ inBuffer = outBuffer;
4536
+ loadedEntries = false;
4537
+ return outBuffer;
4538
+ },
4539
+ toAsyncBuffer: function(onSuccess, onFail, onItemStart, onItemEnd) {
4540
+ try {
4541
+ if (!loadedEntries) {
4542
+ readEntries();
4543
+ }
4544
+ sortEntries();
4545
+ const dataBlock = [];
4546
+ const centralHeaders = [];
4547
+ let totalSize = 0;
4548
+ let dindex = 0;
4549
+ let totalEntries = 0;
4550
+ mainHeader.size = 0;
4551
+ mainHeader.offset = 0;
4552
+ const compress2Buffer = function(entryLists) {
4553
+ if (entryLists.length > 0) {
4554
+ const entry = entryLists.shift();
4555
+ const name = entry.entryName + entry.extra.toString();
4556
+ if (onItemStart) onItemStart(name);
4557
+ entry.getCompressedDataAsync(function(compressedData) {
4558
+ if (onItemEnd) onItemEnd(name);
4559
+ entry.header.offset = dindex;
4560
+ const localHeader = entry.packLocalHeader();
4561
+ const dataLength = localHeader.length + compressedData.length;
4562
+ dindex += dataLength;
4563
+ dataBlock.push(localHeader);
4564
+ dataBlock.push(compressedData);
4565
+ const centalHeader = entry.packCentralHeader();
4566
+ centralHeaders.push(centalHeader);
4567
+ mainHeader.size += centalHeader.length;
4568
+ totalSize += dataLength + centalHeader.length;
4569
+ totalEntries++;
4570
+ compress2Buffer(entryLists);
4571
+ });
4572
+ } else {
4573
+ totalSize += mainHeader.mainHeaderSize;
4574
+ mainHeader.offset = dindex;
4575
+ mainHeader.totalEntries = totalEntries;
4576
+ dindex = 0;
4577
+ const outBuffer = Buffer.alloc(totalSize);
4578
+ dataBlock.forEach(function(content) {
4579
+ content.copy(outBuffer, dindex);
4580
+ dindex += content.length;
4581
+ });
4582
+ centralHeaders.forEach(function(content) {
4583
+ content.copy(outBuffer, dindex);
4584
+ dindex += content.length;
4585
+ });
4586
+ const mh = mainHeader.toBinary();
4587
+ if (_comment) {
4588
+ _comment.copy(mh, Utils.Constants.ENDHDR);
4589
+ }
4590
+ mh.copy(outBuffer, dindex);
4591
+ inBuffer = outBuffer;
4592
+ loadedEntries = false;
4593
+ onSuccess(outBuffer);
4594
+ }
4595
+ };
4596
+ compress2Buffer(Array.from(this.entries));
4597
+ } catch (e) {
4598
+ onFail(e);
4599
+ }
4600
+ }
4601
+ };
4602
+ };
4603
+ }
4604
+ });
4605
+ var require_adm_zip2 = __commonJS2({
4606
+ "../../node_modules/adm-zip/adm-zip.js"(exports2, module2) {
4607
+ var Utils = require_util2();
4608
+ var pth = __require2("path");
4609
+ var ZipEntry = require_zipEntry2();
4610
+ var ZipFile = require_zipFile2();
4611
+ var get_Bool = (...val) => Utils.findLast(val, (c) => typeof c === "boolean");
4612
+ var get_Str = (...val) => Utils.findLast(val, (c) => typeof c === "string");
4613
+ var get_Fun = (...val) => Utils.findLast(val, (c) => typeof c === "function");
4614
+ var defaultOptions = {
4615
+ // option "noSort" : if true it disables files sorting
4616
+ noSort: false,
4617
+ // read entries during load (initial loading may be slower)
4618
+ readEntries: false,
4619
+ // default method is none
4620
+ method: Utils.Constants.NONE,
4621
+ // file system
4622
+ fs: null
4623
+ };
4624
+ module2.exports = function(input, options) {
4625
+ let inBuffer = null;
4626
+ const opts = Object.assign(/* @__PURE__ */ Object.create(null), defaultOptions);
4627
+ if (input && "object" === typeof input) {
4628
+ if (!(input instanceof Uint8Array)) {
4629
+ Object.assign(opts, input);
4630
+ input = opts.input ? opts.input : void 0;
4631
+ if (opts.input) delete opts.input;
4632
+ }
4633
+ if (Buffer.isBuffer(input)) {
4634
+ inBuffer = input;
4635
+ opts.method = Utils.Constants.BUFFER;
4636
+ input = void 0;
4637
+ }
4638
+ }
4639
+ Object.assign(opts, options);
4640
+ const filetools = new Utils(opts);
4641
+ if (typeof opts.decoder !== "object" || typeof opts.decoder.encode !== "function" || typeof opts.decoder.decode !== "function") {
4642
+ opts.decoder = Utils.decoder;
4643
+ }
4644
+ if (input && "string" === typeof input) {
4645
+ if (filetools.fs.existsSync(input)) {
4646
+ opts.method = Utils.Constants.FILE;
4647
+ opts.filename = input;
4648
+ inBuffer = filetools.fs.readFileSync(input);
4649
+ } else {
4650
+ throw Utils.Errors.INVALID_FILENAME();
4651
+ }
4652
+ }
4653
+ const _zip = new ZipFile(inBuffer, opts);
4654
+ const { canonical, sanitize, zipnamefix } = Utils;
4655
+ function getEntry(entry) {
4656
+ if (entry && _zip) {
4657
+ var item;
4658
+ if (typeof entry === "string") item = _zip.getEntry(pth.posix.normalize(entry));
4659
+ if (typeof entry === "object" && typeof entry.entryName !== "undefined" && typeof entry.header !== "undefined") item = _zip.getEntry(entry.entryName);
4660
+ if (item) {
4661
+ return item;
4662
+ }
4663
+ }
4664
+ return null;
4665
+ }
4666
+ function fixPath(zipPath) {
4667
+ const { join: join2, normalize, sep } = pth.posix;
4668
+ return join2(".", normalize(sep + zipPath.split("\\").join(sep) + sep));
4669
+ }
4670
+ function filenameFilter(filterfn) {
4671
+ if (filterfn instanceof RegExp) {
4672
+ return /* @__PURE__ */ (function(rx) {
4673
+ return function(filename) {
4674
+ return rx.test(filename);
4675
+ };
4676
+ })(filterfn);
4677
+ } else if ("function" !== typeof filterfn) {
4678
+ return () => true;
4679
+ }
4680
+ return filterfn;
4681
+ }
4682
+ const relativePath = (local, entry) => {
4683
+ let lastChar = entry.slice(-1);
4684
+ lastChar = lastChar === filetools.sep ? filetools.sep : "";
4685
+ return pth.relative(local, entry) + lastChar;
4686
+ };
4687
+ return {
4688
+ /**
4689
+ * Extracts the given entry from the archive and returns the content as a Buffer object
4690
+ * @param {ZipEntry|string} entry ZipEntry object or String with the full path of the entry
4691
+ * @param {Buffer|string} [pass] - password
4692
+ * @return Buffer or Null in case of error
4693
+ */
4694
+ readFile: function(entry, pass) {
4695
+ var item = getEntry(entry);
4696
+ return item && item.getData(pass) || null;
4697
+ },
4698
+ /**
4699
+ * Returns how many child elements has on entry (directories) on files it is always 0
4700
+ * @param {ZipEntry|string} entry ZipEntry object or String with the full path of the entry
4701
+ * @returns {integer}
4702
+ */
4703
+ childCount: function(entry) {
4704
+ const item = getEntry(entry);
4705
+ if (item) {
4706
+ return _zip.getChildCount(item);
4707
+ }
4708
+ },
4709
+ /**
4710
+ * Asynchronous readFile
4711
+ * @param {ZipEntry|string} entry ZipEntry object or String with the full path of the entry
4712
+ * @param {callback} callback
4713
+ *
4714
+ * @return Buffer or Null in case of error
4715
+ */
4716
+ readFileAsync: function(entry, callback) {
4717
+ var item = getEntry(entry);
4718
+ if (item) {
4719
+ item.getDataAsync(callback);
4720
+ } else {
4721
+ callback(null, "getEntry failed for:" + entry);
4722
+ }
4723
+ },
4724
+ /**
4725
+ * Extracts the given entry from the archive and returns the content as plain text in the given encoding
4726
+ * @param {ZipEntry|string} entry - ZipEntry object or String with the full path of the entry
4727
+ * @param {string} encoding - Optional. If no encoding is specified utf8 is used
4728
+ *
4729
+ * @return String
4730
+ */
4731
+ readAsText: function(entry, encoding) {
4732
+ var item = getEntry(entry);
4733
+ if (item) {
4734
+ var data = item.getData();
4735
+ if (data && data.length) {
4736
+ return data.toString(encoding || "utf8");
4737
+ }
4738
+ }
4739
+ return "";
4740
+ },
4741
+ /**
4742
+ * Asynchronous readAsText
4743
+ * @param {ZipEntry|string} entry ZipEntry object or String with the full path of the entry
4744
+ * @param {callback} callback
4745
+ * @param {string} [encoding] - Optional. If no encoding is specified utf8 is used
4746
+ *
4747
+ * @return String
4748
+ */
4749
+ readAsTextAsync: function(entry, callback, encoding) {
4750
+ var item = getEntry(entry);
4751
+ if (item) {
4752
+ item.getDataAsync(function(data, err) {
4753
+ if (err) {
4754
+ callback(data, err);
4755
+ return;
4756
+ }
4757
+ if (data && data.length) {
4758
+ callback(data.toString(encoding || "utf8"));
4759
+ } else {
4760
+ callback("");
4761
+ }
4762
+ });
4763
+ } else {
4764
+ callback("");
4765
+ }
4766
+ },
4767
+ /**
4768
+ * Remove the entry from the file or the entry and all it's nested directories and files if the given entry is a directory
4769
+ *
4770
+ * @param {ZipEntry|string} entry
4771
+ * @returns {void}
4772
+ */
4773
+ deleteFile: function(entry, withsubfolders = true) {
4774
+ var item = getEntry(entry);
4775
+ if (item) {
4776
+ _zip.deleteFile(item.entryName, withsubfolders);
4777
+ }
4778
+ },
4779
+ /**
4780
+ * Remove the entry from the file or directory without affecting any nested entries
4781
+ *
4782
+ * @param {ZipEntry|string} entry
4783
+ * @returns {void}
4784
+ */
4785
+ deleteEntry: function(entry) {
4786
+ var item = getEntry(entry);
4787
+ if (item) {
4788
+ _zip.deleteEntry(item.entryName);
4789
+ }
4790
+ },
4791
+ /**
4792
+ * Adds a comment to the zip. The zip must be rewritten after adding the comment.
4793
+ *
4794
+ * @param {string} comment
4795
+ */
4796
+ addZipComment: function(comment) {
4797
+ _zip.comment = comment;
4798
+ },
4799
+ /**
4800
+ * Returns the zip comment
4801
+ *
4802
+ * @return String
4803
+ */
4804
+ getZipComment: function() {
4805
+ return _zip.comment || "";
4806
+ },
4807
+ /**
4808
+ * Adds a comment to a specified zipEntry. The zip must be rewritten after adding the comment
4809
+ * The comment cannot exceed 65535 characters in length
4810
+ *
4811
+ * @param {ZipEntry} entry
4812
+ * @param {string} comment
4813
+ */
4814
+ addZipEntryComment: function(entry, comment) {
4815
+ var item = getEntry(entry);
4816
+ if (item) {
4817
+ item.comment = comment;
4818
+ }
4819
+ },
4820
+ /**
4821
+ * Returns the comment of the specified entry
4822
+ *
4823
+ * @param {ZipEntry} entry
4824
+ * @return String
4825
+ */
4826
+ getZipEntryComment: function(entry) {
4827
+ var item = getEntry(entry);
4828
+ if (item) {
4829
+ return item.comment || "";
4830
+ }
4831
+ return "";
4832
+ },
4833
+ /**
4834
+ * Updates the content of an existing entry inside the archive. The zip must be rewritten after updating the content
4835
+ *
4836
+ * @param {ZipEntry} entry
4837
+ * @param {Buffer} content
4838
+ */
4839
+ updateFile: function(entry, content) {
4840
+ var item = getEntry(entry);
4841
+ if (item) {
4842
+ item.setData(content);
4843
+ }
4844
+ },
4845
+ /**
4846
+ * Adds a file from the disk to the archive
4847
+ *
4848
+ * @param {string} localPath File to add to zip
4849
+ * @param {string} [zipPath] Optional path inside the zip
4850
+ * @param {string} [zipName] Optional name for the file
4851
+ * @param {string} [comment] Optional file comment
4852
+ */
4853
+ addLocalFile: function(localPath2, zipPath, zipName, comment) {
4854
+ if (filetools.fs.existsSync(localPath2)) {
4855
+ zipPath = zipPath ? fixPath(zipPath) : "";
4856
+ const p = pth.win32.basename(pth.win32.normalize(localPath2));
4857
+ zipPath += zipName ? zipName : p;
4858
+ const _attr = filetools.fs.statSync(localPath2);
4859
+ const data = _attr.isFile() ? filetools.fs.readFileSync(localPath2) : Buffer.alloc(0);
4860
+ if (_attr.isDirectory()) zipPath += filetools.sep;
4861
+ this.addFile(zipPath, data, comment, _attr);
4862
+ } else {
4863
+ throw Utils.Errors.FILE_NOT_FOUND(localPath2);
4864
+ }
4865
+ },
4866
+ /**
4867
+ * Callback for showing if everything was done.
4868
+ *
4869
+ * @callback doneCallback
4870
+ * @param {Error} err - Error object
4871
+ * @param {boolean} done - was request fully completed
4872
+ */
4873
+ /**
4874
+ * Adds a file from the disk to the archive
4875
+ *
4876
+ * @param {(object|string)} options - options object, if it is string it us used as localPath.
4877
+ * @param {string} options.localPath - Local path to the file.
4878
+ * @param {string} [options.comment] - Optional file comment.
4879
+ * @param {string} [options.zipPath] - Optional path inside the zip
4880
+ * @param {string} [options.zipName] - Optional name for the file
4881
+ * @param {doneCallback} callback - The callback that handles the response.
4882
+ */
4883
+ addLocalFileAsync: function(options2, callback) {
4884
+ options2 = typeof options2 === "object" ? options2 : { localPath: options2 };
4885
+ const localPath2 = pth.resolve(options2.localPath);
4886
+ const { comment } = options2;
4887
+ let { zipPath, zipName } = options2;
4888
+ const self = this;
4889
+ filetools.fs.stat(localPath2, function(err, stats) {
4890
+ if (err) return callback(err, false);
4891
+ zipPath = zipPath ? fixPath(zipPath) : "";
4892
+ const p = pth.win32.basename(pth.win32.normalize(localPath2));
4893
+ zipPath += zipName ? zipName : p;
4894
+ if (stats.isFile()) {
4895
+ filetools.fs.readFile(localPath2, function(err2, data) {
4896
+ if (err2) return callback(err2, false);
4897
+ self.addFile(zipPath, data, comment, stats);
4898
+ return setImmediate(callback, void 0, true);
4899
+ });
4900
+ } else if (stats.isDirectory()) {
4901
+ zipPath += filetools.sep;
4902
+ self.addFile(zipPath, Buffer.alloc(0), comment, stats);
4903
+ return setImmediate(callback, void 0, true);
4904
+ }
4905
+ });
4906
+ },
4907
+ /**
4908
+ * Adds a local directory and all its nested files and directories to the archive
4909
+ *
4910
+ * @param {string} localPath - local path to the folder
4911
+ * @param {string} [zipPath] - optional path inside zip
4912
+ * @param {(RegExp|function)} [filter] - optional RegExp or Function if files match will be included.
4913
+ */
4914
+ addLocalFolder: function(localPath2, zipPath, filter) {
4915
+ filter = filenameFilter(filter);
4916
+ zipPath = zipPath ? fixPath(zipPath) : "";
4917
+ localPath2 = pth.normalize(localPath2);
4918
+ if (filetools.fs.existsSync(localPath2)) {
4919
+ const items = filetools.findFiles(localPath2);
4920
+ const self = this;
4921
+ if (items.length) {
4922
+ for (const filepath of items) {
4923
+ const p = pth.join(zipPath, relativePath(localPath2, filepath));
4924
+ if (filter(p)) {
4925
+ self.addLocalFile(filepath, pth.dirname(p));
4926
+ }
4927
+ }
4928
+ }
4929
+ } else {
4930
+ throw Utils.Errors.FILE_NOT_FOUND(localPath2);
4931
+ }
4932
+ },
4933
+ /**
4934
+ * Asynchronous addLocalFolder
4935
+ * @param {string} localPath
4936
+ * @param {callback} callback
4937
+ * @param {string} [zipPath] optional path inside zip
4938
+ * @param {RegExp|function} [filter] optional RegExp or Function if files match will
4939
+ * be included.
4940
+ */
4941
+ addLocalFolderAsync: function(localPath2, callback, zipPath, filter) {
4942
+ filter = filenameFilter(filter);
4943
+ zipPath = zipPath ? fixPath(zipPath) : "";
4944
+ localPath2 = pth.normalize(localPath2);
4945
+ var self = this;
4946
+ filetools.fs.open(localPath2, "r", function(err) {
4947
+ if (err && err.code === "ENOENT") {
4948
+ callback(void 0, Utils.Errors.FILE_NOT_FOUND(localPath2));
4949
+ } else if (err) {
4950
+ callback(void 0, err);
4951
+ } else {
4952
+ var items = filetools.findFiles(localPath2);
4953
+ var i = -1;
4954
+ var next = function() {
4955
+ i += 1;
4956
+ if (i < items.length) {
4957
+ var filepath = items[i];
4958
+ var p = relativePath(localPath2, filepath).split("\\").join("/");
4959
+ p = p.normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^\x20-\x7E]/g, "");
4960
+ if (filter(p)) {
4961
+ filetools.fs.stat(filepath, function(er0, stats) {
4962
+ if (er0) callback(void 0, er0);
4963
+ if (stats.isFile()) {
4964
+ filetools.fs.readFile(filepath, function(er1, data) {
4965
+ if (er1) {
4966
+ callback(void 0, er1);
4967
+ } else {
4968
+ self.addFile(zipPath + p, data, "", stats);
4969
+ next();
4970
+ }
4971
+ });
4972
+ } else {
4973
+ self.addFile(zipPath + p + "/", Buffer.alloc(0), "", stats);
4974
+ next();
4975
+ }
4976
+ });
4977
+ } else {
4978
+ process.nextTick(() => {
4979
+ next();
4980
+ });
4981
+ }
4982
+ } else {
4983
+ callback(true, void 0);
4984
+ }
4985
+ };
4986
+ next();
4987
+ }
4988
+ });
4989
+ },
4990
+ /**
4991
+ * Adds a local directory and all its nested files and directories to the archive
4992
+ *
4993
+ * @param {object | string} options - options object, if it is string it us used as localPath.
4994
+ * @param {string} options.localPath - Local path to the folder.
4995
+ * @param {string} [options.zipPath] - optional path inside zip.
4996
+ * @param {RegExp|function} [options.filter] - optional RegExp or Function if files match will be included.
4997
+ * @param {function|string} [options.namefix] - optional function to help fix filename
4998
+ * @param {doneCallback} callback - The callback that handles the response.
4999
+ *
5000
+ */
5001
+ addLocalFolderAsync2: function(options2, callback) {
5002
+ const self = this;
5003
+ options2 = typeof options2 === "object" ? options2 : { localPath: options2 };
5004
+ localPath = pth.resolve(fixPath(options2.localPath));
5005
+ let { zipPath, filter, namefix } = options2;
5006
+ if (filter instanceof RegExp) {
5007
+ filter = /* @__PURE__ */ (function(rx) {
5008
+ return function(filename) {
5009
+ return rx.test(filename);
5010
+ };
5011
+ })(filter);
5012
+ } else if ("function" !== typeof filter) {
5013
+ filter = function() {
5014
+ return true;
5015
+ };
5016
+ }
5017
+ zipPath = zipPath ? fixPath(zipPath) : "";
5018
+ if (namefix == "latin1") {
5019
+ namefix = (str) => str.normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^\x20-\x7E]/g, "");
5020
+ }
5021
+ if (typeof namefix !== "function") namefix = (str) => str;
5022
+ const relPathFix = (entry) => pth.join(zipPath, namefix(relativePath(localPath, entry)));
5023
+ const fileNameFix = (entry) => pth.win32.basename(pth.win32.normalize(namefix(entry)));
5024
+ filetools.fs.open(localPath, "r", function(err) {
5025
+ if (err && err.code === "ENOENT") {
5026
+ callback(void 0, Utils.Errors.FILE_NOT_FOUND(localPath));
5027
+ } else if (err) {
5028
+ callback(void 0, err);
5029
+ } else {
5030
+ filetools.findFilesAsync(localPath, function(err2, fileEntries) {
5031
+ if (err2) return callback(err2);
5032
+ fileEntries = fileEntries.filter((dir) => filter(relPathFix(dir)));
5033
+ if (!fileEntries.length) callback(void 0, false);
5034
+ setImmediate(
5035
+ fileEntries.reverse().reduce(function(next, entry) {
5036
+ return function(err3, done) {
5037
+ if (err3 || done === false) return setImmediate(next, err3, false);
5038
+ self.addLocalFileAsync(
5039
+ {
5040
+ localPath: entry,
5041
+ zipPath: pth.dirname(relPathFix(entry)),
5042
+ zipName: fileNameFix(entry)
5043
+ },
5044
+ next
5045
+ );
5046
+ };
5047
+ }, callback)
5048
+ );
5049
+ });
5050
+ }
5051
+ });
5052
+ },
5053
+ /**
5054
+ * Adds a local directory and all its nested files and directories to the archive
5055
+ *
5056
+ * @param {string} localPath - path where files will be extracted
5057
+ * @param {object} props - optional properties
5058
+ * @param {string} [props.zipPath] - optional path inside zip
5059
+ * @param {RegExp|function} [props.filter] - optional RegExp or Function if files match will be included.
5060
+ * @param {function|string} [props.namefix] - optional function to help fix filename
5061
+ */
5062
+ addLocalFolderPromise: function(localPath2, props) {
5063
+ return new Promise((resolve, reject) => {
5064
+ this.addLocalFolderAsync2(Object.assign({ localPath: localPath2 }, props), (err, done) => {
5065
+ if (err) reject(err);
5066
+ if (done) resolve(this);
5067
+ });
5068
+ });
5069
+ },
5070
+ /**
5071
+ * Allows you to create a entry (file or directory) in the zip file.
5072
+ * If you want to create a directory the entryName must end in / and a null buffer should be provided.
5073
+ * Comment and attributes are optional
5074
+ *
5075
+ * @param {string} entryName
5076
+ * @param {Buffer | string} content - file content as buffer or utf8 coded string
5077
+ * @param {string} [comment] - file comment
5078
+ * @param {number | object} [attr] - number as unix file permissions, object as filesystem Stats object
5079
+ */
5080
+ addFile: function(entryName, content, comment, attr) {
5081
+ entryName = zipnamefix(entryName);
5082
+ let entry = getEntry(entryName);
5083
+ const update = entry != null;
5084
+ if (!update) {
5085
+ entry = new ZipEntry(opts);
5086
+ entry.entryName = entryName;
5087
+ }
5088
+ entry.comment = comment || "";
5089
+ const isStat = "object" === typeof attr && attr instanceof filetools.fs.Stats;
5090
+ if (isStat) {
5091
+ entry.header.time = attr.mtime;
5092
+ }
5093
+ var fileattr = entry.isDirectory ? 16 : 0;
5094
+ let unix = entry.isDirectory ? 16384 : 32768;
5095
+ if (isStat) {
5096
+ unix |= 4095 & attr.mode;
5097
+ } else if ("number" === typeof attr) {
5098
+ unix |= 4095 & attr;
5099
+ } else {
5100
+ unix |= entry.isDirectory ? 493 : 420;
5101
+ }
5102
+ fileattr = (fileattr | unix << 16) >>> 0;
5103
+ entry.attr = fileattr;
5104
+ entry.setData(content);
5105
+ if (!update) _zip.setEntry(entry);
5106
+ return entry;
5107
+ },
5108
+ /**
5109
+ * Returns an array of ZipEntry objects representing the files and folders inside the archive
5110
+ *
5111
+ * @param {string} [password]
5112
+ * @returns Array
5113
+ */
5114
+ getEntries: function(password) {
5115
+ _zip.password = password;
5116
+ return _zip ? _zip.entries : [];
5117
+ },
5118
+ /**
5119
+ * Returns a ZipEntry object representing the file or folder specified by ``name``.
5120
+ *
5121
+ * @param {string} name
5122
+ * @return ZipEntry
5123
+ */
5124
+ getEntry: function(name) {
5125
+ return getEntry(name);
5126
+ },
5127
+ getEntryCount: function() {
5128
+ return _zip.getEntryCount();
5129
+ },
5130
+ forEach: function(callback) {
5131
+ return _zip.forEach(callback);
5132
+ },
5133
+ /**
5134
+ * Extracts the given entry to the given targetPath
5135
+ * If the entry is a directory inside the archive, the entire directory and it's subdirectories will be extracted
5136
+ *
5137
+ * @param {string|ZipEntry} entry - ZipEntry object or String with the full path of the entry
5138
+ * @param {string} targetPath - Target folder where to write the file
5139
+ * @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
5140
+ * @param {boolean} [overwrite=false] - If the file already exists at the target path, the file will be overwriten if this is true.
5141
+ * @param {boolean} [keepOriginalPermission=false] - The file will be set as the permission from the entry if this is true.
5142
+ * @param {string} [outFileName] - String If set will override the filename of the extracted file (Only works if the entry is a file)
5143
+ *
5144
+ * @return Boolean
5145
+ */
5146
+ extractEntryTo: function(entry, targetPath, maintainEntryPath, overwrite, keepOriginalPermission, outFileName) {
5147
+ overwrite = get_Bool(false, overwrite);
5148
+ keepOriginalPermission = get_Bool(false, keepOriginalPermission);
5149
+ maintainEntryPath = get_Bool(true, maintainEntryPath);
5150
+ outFileName = get_Str(keepOriginalPermission, outFileName);
5151
+ var item = getEntry(entry);
5152
+ if (!item) {
5153
+ throw Utils.Errors.NO_ENTRY();
5154
+ }
5155
+ var entryName = canonical(item.entryName);
5156
+ var target = sanitize(targetPath, outFileName && !item.isDirectory ? outFileName : maintainEntryPath ? entryName : pth.basename(entryName));
5157
+ if (item.isDirectory) {
5158
+ var children = _zip.getEntryChildren(item);
5159
+ children.forEach(function(child) {
5160
+ if (child.isDirectory) return;
5161
+ var content2 = child.getData();
5162
+ if (!content2) {
5163
+ throw Utils.Errors.CANT_EXTRACT_FILE();
5164
+ }
5165
+ var name = canonical(child.entryName);
5166
+ var childName = sanitize(targetPath, maintainEntryPath ? name : pth.basename(name));
5167
+ const fileAttr2 = keepOriginalPermission ? child.header.fileAttr : void 0;
5168
+ filetools.writeFileTo(childName, content2, overwrite, fileAttr2);
5169
+ });
5170
+ return true;
5171
+ }
5172
+ var content = item.getData(_zip.password);
5173
+ if (!content) throw Utils.Errors.CANT_EXTRACT_FILE();
5174
+ if (filetools.fs.existsSync(target) && !overwrite) {
5175
+ throw Utils.Errors.CANT_OVERRIDE();
5176
+ }
5177
+ const fileAttr = keepOriginalPermission ? entry.header.fileAttr : void 0;
5178
+ filetools.writeFileTo(target, content, overwrite, fileAttr);
5179
+ return true;
5180
+ },
5181
+ /**
5182
+ * Test the archive
5183
+ * @param {string} [pass]
5184
+ */
5185
+ test: function(pass) {
5186
+ if (!_zip) {
5187
+ return false;
5188
+ }
5189
+ for (var entry in _zip.entries) {
5190
+ try {
5191
+ if (entry.isDirectory) {
5192
+ continue;
5193
+ }
5194
+ var content = _zip.entries[entry].getData(pass);
5195
+ if (!content) {
5196
+ return false;
5197
+ }
5198
+ } catch (err) {
5199
+ return false;
5200
+ }
5201
+ }
5202
+ return true;
5203
+ },
5204
+ /**
5205
+ * Extracts the entire archive to the given location
5206
+ *
5207
+ * @param {string} targetPath Target location
5208
+ * @param {boolean} [overwrite=false] If the file already exists at the target path, the file will be overwriten if this is true.
5209
+ * Default is FALSE
5210
+ * @param {boolean} [keepOriginalPermission=false] The file will be set as the permission from the entry if this is true.
5211
+ * Default is FALSE
5212
+ * @param {string|Buffer} [pass] password
5213
+ */
5214
+ extractAllTo: function(targetPath, overwrite, keepOriginalPermission, pass) {
5215
+ keepOriginalPermission = get_Bool(false, keepOriginalPermission);
5216
+ pass = get_Str(keepOriginalPermission, pass);
5217
+ overwrite = get_Bool(false, overwrite);
5218
+ if (!_zip) throw Utils.Errors.NO_ZIP();
5219
+ _zip.entries.forEach(function(entry) {
5220
+ var entryName = sanitize(targetPath, canonical(entry.entryName));
5221
+ if (entry.isDirectory) {
5222
+ filetools.makeDir(entryName);
5223
+ return;
5224
+ }
5225
+ var content = entry.getData(pass);
5226
+ if (!content) {
5227
+ throw Utils.Errors.CANT_EXTRACT_FILE();
5228
+ }
5229
+ const fileAttr = keepOriginalPermission ? entry.header.fileAttr : void 0;
5230
+ filetools.writeFileTo(entryName, content, overwrite, fileAttr);
5231
+ try {
5232
+ filetools.fs.utimesSync(entryName, entry.header.time, entry.header.time);
5233
+ } catch (err) {
5234
+ throw Utils.Errors.CANT_EXTRACT_FILE();
5235
+ }
5236
+ });
5237
+ },
5238
+ /**
5239
+ * Asynchronous extractAllTo
5240
+ *
5241
+ * @param {string} targetPath Target location
5242
+ * @param {boolean} [overwrite=false] If the file already exists at the target path, the file will be overwriten if this is true.
5243
+ * Default is FALSE
5244
+ * @param {boolean} [keepOriginalPermission=false] The file will be set as the permission from the entry if this is true.
5245
+ * Default is FALSE
5246
+ * @param {function} callback The callback will be executed when all entries are extracted successfully or any error is thrown.
5247
+ */
5248
+ extractAllToAsync: function(targetPath, overwrite, keepOriginalPermission, callback) {
5249
+ callback = get_Fun(overwrite, keepOriginalPermission, callback);
5250
+ keepOriginalPermission = get_Bool(false, keepOriginalPermission);
5251
+ overwrite = get_Bool(false, overwrite);
5252
+ if (!callback) {
5253
+ return new Promise((resolve, reject) => {
5254
+ this.extractAllToAsync(targetPath, overwrite, keepOriginalPermission, function(err) {
5255
+ if (err) {
5256
+ reject(err);
5257
+ } else {
5258
+ resolve(this);
5259
+ }
5260
+ });
5261
+ });
5262
+ }
5263
+ if (!_zip) {
5264
+ callback(Utils.Errors.NO_ZIP());
5265
+ return;
5266
+ }
5267
+ targetPath = pth.resolve(targetPath);
5268
+ const getPath = (entry) => sanitize(targetPath, pth.normalize(canonical(entry.entryName)));
5269
+ const getError = (msg, file) => new Error(msg + ': "' + file + '"');
5270
+ const dirEntries = [];
5271
+ const fileEntries = [];
5272
+ _zip.entries.forEach((e) => {
5273
+ if (e.isDirectory) {
5274
+ dirEntries.push(e);
5275
+ } else {
5276
+ fileEntries.push(e);
5277
+ }
5278
+ });
5279
+ for (const entry of dirEntries) {
5280
+ const dirPath = getPath(entry);
5281
+ const dirAttr = keepOriginalPermission ? entry.header.fileAttr : void 0;
5282
+ try {
5283
+ filetools.makeDir(dirPath);
5284
+ if (dirAttr) filetools.fs.chmodSync(dirPath, dirAttr);
5285
+ filetools.fs.utimesSync(dirPath, entry.header.time, entry.header.time);
5286
+ } catch (er) {
5287
+ callback(getError("Unable to create folder", dirPath));
5288
+ }
5289
+ }
5290
+ fileEntries.reverse().reduce(function(next, entry) {
5291
+ return function(err) {
5292
+ if (err) {
5293
+ next(err);
5294
+ } else {
5295
+ const entryName = pth.normalize(canonical(entry.entryName));
5296
+ const filePath = sanitize(targetPath, entryName);
5297
+ entry.getDataAsync(function(content, err_1) {
5298
+ if (err_1) {
5299
+ next(err_1);
5300
+ } else if (!content) {
5301
+ next(Utils.Errors.CANT_EXTRACT_FILE());
5302
+ } else {
5303
+ const fileAttr = keepOriginalPermission ? entry.header.fileAttr : void 0;
5304
+ filetools.writeFileToAsync(filePath, content, overwrite, fileAttr, function(succ) {
5305
+ if (!succ) {
5306
+ next(getError("Unable to write file", filePath));
5307
+ }
5308
+ filetools.fs.utimes(filePath, entry.header.time, entry.header.time, function(err_2) {
5309
+ if (err_2) {
5310
+ next(getError("Unable to set times", filePath));
5311
+ } else {
5312
+ next();
5313
+ }
5314
+ });
5315
+ });
5316
+ }
5317
+ });
5318
+ }
5319
+ };
5320
+ }, callback)();
5321
+ },
5322
+ /**
5323
+ * 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
5324
+ *
5325
+ * @param {string} targetFileName
5326
+ * @param {function} callback
5327
+ */
5328
+ writeZip: function(targetFileName, callback) {
5329
+ if (arguments.length === 1) {
5330
+ if (typeof targetFileName === "function") {
5331
+ callback = targetFileName;
5332
+ targetFileName = "";
5333
+ }
5334
+ }
5335
+ if (!targetFileName && opts.filename) {
5336
+ targetFileName = opts.filename;
5337
+ }
5338
+ if (!targetFileName) return;
5339
+ var zipData = _zip.compressToBuffer();
5340
+ if (zipData) {
5341
+ var ok = filetools.writeFileTo(targetFileName, zipData, true);
5342
+ if (typeof callback === "function") callback(!ok ? new Error("failed") : null, "");
5343
+ }
5344
+ },
5345
+ /**
5346
+ *
5347
+ * @param {string} targetFileName
5348
+ * @param {object} [props]
5349
+ * @param {boolean} [props.overwrite=true] If the file already exists at the target path, the file will be overwriten if this is true.
5350
+ * @param {boolean} [props.perm] The file will be set as the permission from the entry if this is true.
5351
+
5352
+ * @returns {Promise<void>}
5353
+ */
5354
+ writeZipPromise: function(targetFileName, props) {
5355
+ const { overwrite, perm } = Object.assign({ overwrite: true }, props);
5356
+ return new Promise((resolve, reject) => {
5357
+ if (!targetFileName && opts.filename) targetFileName = opts.filename;
5358
+ if (!targetFileName) reject("ADM-ZIP: ZIP File Name Missing");
5359
+ this.toBufferPromise().then((zipData) => {
5360
+ const ret = (done) => done ? resolve(done) : reject("ADM-ZIP: Wasn't able to write zip file");
5361
+ filetools.writeFileToAsync(targetFileName, zipData, overwrite, perm, ret);
5362
+ }, reject);
5363
+ });
5364
+ },
5365
+ /**
5366
+ * @returns {Promise<Buffer>} A promise to the Buffer.
5367
+ */
5368
+ toBufferPromise: function() {
5369
+ return new Promise((resolve, reject) => {
5370
+ _zip.toAsyncBuffer(resolve, reject);
5371
+ });
5372
+ },
5373
+ /**
5374
+ * Returns the content of the entire zip file as a Buffer object
5375
+ *
5376
+ * @prop {function} [onSuccess]
5377
+ * @prop {function} [onFail]
5378
+ * @prop {function} [onItemStart]
5379
+ * @prop {function} [onItemEnd]
5380
+ * @returns {Buffer}
5381
+ */
5382
+ toBuffer: function(onSuccess, onFail, onItemStart, onItemEnd) {
5383
+ if (typeof onSuccess === "function") {
5384
+ _zip.toAsyncBuffer(onSuccess, onFail, onItemStart, onItemEnd);
5385
+ return null;
5386
+ }
5387
+ return _zip.compressToBuffer();
5388
+ }
5389
+ };
5390
+ };
5391
+ }
5392
+ });
5393
+ function getPluginFilesVersion2(pluginFilesPackageName, pluginPackageJsonPath) {
5394
+ const pluginPackageJson = JSON.parse(fs2.readFileSync(pluginPackageJsonPath, "utf-8"));
5395
+ let version = pluginPackageJson.dependencies?.[pluginFilesPackageName];
5396
+ if (!version) {
5397
+ throw new Error(
5398
+ `Could not find ${pluginFilesPackageName} in dependencies of ${pluginPackageJsonPath}`
5399
+ );
5400
+ }
5401
+ if (version.startsWith("http://") || version.startsWith("https://")) {
5402
+ console.log(`[get-plugin-files-version] Detected tarball URL: ${version}`);
5403
+ try {
5404
+ const url = new URL(version);
5405
+ const pathParts = url.pathname.split("/");
5406
+ const guidWithExt = pathParts[pathParts.length - 1];
5407
+ version = guidWithExt.replace(/\.tar\.gz$/, "");
5408
+ console.log(`[get-plugin-files-version] Extracted GUID from URL: ${version}`);
5409
+ } catch (e) {
5410
+ throw new Error(
5411
+ `Failed to parse tarball URL for ${pluginFilesPackageName}: ${e instanceof Error ? e.message : String(e)}`
5412
+ );
5413
+ }
5414
+ } else if (version.startsWith("workspace:")) {
5415
+ console.log(`[get-plugin-files-version] Detected workspace protocol: ${version}, resolving from ${pluginFilesPackageName}`);
5416
+ try {
5417
+ const pluginFilesPackageJson = __require2(`${pluginFilesPackageName}/package.json`);
5418
+ version = pluginFilesPackageJson.version;
5419
+ console.log(`[get-plugin-files-version] Resolved workspace version: ${version}`);
5420
+ } catch (e) {
5421
+ throw new Error(
5422
+ `Failed to resolve ${pluginFilesPackageName} version: ${e instanceof Error ? e.message : String(e)}`
5423
+ );
5424
+ }
5425
+ }
5426
+ console.log(`[get-plugin-files-version] Final resolved version for ${pluginFilesPackageName}: ${version}`);
5427
+ return version;
5428
+ }
5429
+ var import_adm_zip2 = __toESM2(require_adm_zip2());
5430
+ async function downloadZipFile2(url, filePath, env) {
5431
+ return new Promise((resolve, reject) => {
5432
+ const file = fs__namespace.createWriteStream(filePath);
5433
+ const makeRequest = (requestUrl) => {
5434
+ https__default.default.get(requestUrl, (response) => {
5435
+ if (response.statusCode === 301 || response.statusCode === 302) {
5436
+ const location = response.headers.location;
5437
+ if (location) {
5438
+ env.logger.debug(
5439
+ `[plugin-files-downloader] following redirect to: ${location}`
5440
+ );
5441
+ makeRequest(location);
5442
+ return;
5443
+ }
5444
+ }
5445
+ if (response.statusCode !== 200) {
5446
+ reject(
5447
+ new Error(
5448
+ `Failed to download: ${response.statusCode} ${response.statusMessage}`
5449
+ )
5450
+ );
5451
+ return;
5452
+ }
5453
+ response.pipe(file);
5454
+ file.on("finish", () => {
5455
+ file.close();
5456
+ resolve();
5457
+ });
5458
+ file.on("error", (err) => {
5459
+ fs__namespace.unlink(filePath, () => {
5460
+ });
5461
+ reject(err);
5462
+ });
5463
+ }).on("error", (err) => {
5464
+ reject(err);
5465
+ });
5466
+ };
5467
+ makeRequest(url);
5468
+ });
5469
+ }
5470
+ async function unzipAndMergePluginFiles2(env, zipUrl, pluginName) {
5471
+ env.logger.debug("[plugin-files-downloader] unzipping plugin files from dependency...");
5472
+ const zipPath = path__namespace.join(process.cwd(), `${pluginName}-plugin-files.zip`);
5473
+ const targetDir = path__namespace.join(env.CODEGEN_APP_ROOT, "src");
5474
+ try {
5475
+ env.logger.debug("[plugin-files-downloader] downloading zip file to:", { zipPath });
5476
+ await downloadZipFile2(zipUrl, zipPath, env);
5477
+ const zip = new import_adm_zip2.default(zipPath);
5478
+ env.logger.debug("[plugin-files-downloader] unzipping files...");
5479
+ zip.getEntries().forEach((entry) => {
5480
+ if (!entry.isDirectory) {
5481
+ const entryPath = entry.entryName;
5482
+ const targetPath = path__namespace.join(
5483
+ targetDir,
5484
+ entryPath.replace(`picasso-${pluginName}-plugin-files/`, "")
5485
+ );
5486
+ const targetDirPath = path__namespace.dirname(targetPath);
5487
+ if (!fs__namespace.existsSync(targetDirPath)) {
5488
+ fs__namespace.mkdirSync(targetDirPath, { recursive: true });
5489
+ }
5490
+ fs__namespace.writeFileSync(targetPath, entry.getData());
5491
+ env.logger.debug(`[plugin-files-downloader] extracted: ${targetPath}`);
5492
+ }
5493
+ });
5494
+ env.logger.debug(
5495
+ "[plugin-files-downloader] plugin files unzipped and merged successfully"
5496
+ );
5497
+ } catch (error) {
5498
+ const errorMessage = error instanceof Error ? error : new Error(String(error));
5499
+ env.logger.error(
5500
+ errorMessage,
5501
+ { context: "[plugin-files-downloader] error downloading or unzipping plugin files" }
5502
+ );
5503
+ throw error;
5504
+ }
5505
+ }
5506
+ exports.downloadZipFile = downloadZipFile2;
5507
+ exports.getPluginFilesVersion = getPluginFilesVersion2;
5508
+ exports.unzipAndMergePluginFiles = unzipAndMergePluginFiles2;
5509
+ }
5510
+ });
5511
+
2714
5512
  // src/utils.ts
2715
5513
  var import_adm_zip = __toESM(require_adm_zip());
2716
5514
 
2717
5515
  // src/constants.ts
2718
- var PLUGIN_FILES_ZIP_URL = "https://static.parastorage.com/services/vibe-forms-plugin-files/0.24.0/forms-plugin-files-files.zip";
5516
+ var import_vibe_plugin_utils = __toESM(require_dist());
5517
+ var PLUGIN_FILES_VERSION = (0, import_vibe_plugin_utils.getPluginFilesVersion)(
5518
+ "@wix/vibe-forms-plugin-files",
5519
+ path2__namespace.default.resolve(__dirname, "../package.json")
5520
+ );
5521
+ var PLUGIN_FILES_ZIP_URL = `https://static.parastorage.com/services/vibe-forms-plugin-files/${PLUGIN_FILES_VERSION}/forms-plugin-files-files.zip`;
2719
5522
  var VERTICAL_NAME = "forms";
2720
5523
  var FORMS_PLATFORM_APP_DEF_ID = "14ce1214-b278-a7e4-1373-00cebd1bef7c";
2721
5524
 
@@ -2840,8 +5643,8 @@ var unzipAndMergeParastoragePluginFiles = async (env, zipUrl) => {
2840
5643
  env.logger.debug(
2841
5644
  `[${VERTICAL_NAME}-plugin-install] Unzipping plugin files from dependency...`
2842
5645
  );
2843
- const zipPath = path__namespace.join(process.cwd(), "picasso-forms-plugin-files.zip");
2844
- const targetDir = path__namespace.join(env.CODEGEN_APP_ROOT, "src");
5646
+ const zipPath = path2__namespace.join(process.cwd(), "picasso-forms-plugin-files.zip");
5647
+ const targetDir = path2__namespace.join(env.CODEGEN_APP_ROOT, "src");
2845
5648
  try {
2846
5649
  env.logger.debug(
2847
5650
  `[${VERTICAL_NAME}-plugin-install] downloading zip file to:`,
@@ -2853,8 +5656,8 @@ var unzipAndMergeParastoragePluginFiles = async (env, zipUrl) => {
2853
5656
  zip.getEntries().forEach((entry) => {
2854
5657
  if (!entry.isDirectory) {
2855
5658
  const entryPath = entry.entryName;
2856
- const targetPath = path__namespace.join(targetDir, entryPath);
2857
- const targetDirPath = path__namespace.dirname(targetPath);
5659
+ const targetPath = path2__namespace.join(targetDir, entryPath);
5660
+ const targetDirPath = path2__namespace.dirname(targetPath);
2858
5661
  if (!fs__namespace.existsSync(targetDirPath)) {
2859
5662
  fs__namespace.mkdirSync(targetDirPath, { recursive: true });
2860
5663
  }
@@ -2891,7 +5694,7 @@ var unzipAndMergeLocalPluginFiles = async (env, zipPath) => {
2891
5694
  env.logger.debug(
2892
5695
  `[${VERTICAL_NAME}-plugin-install] Unzipping plugin files from local file...`
2893
5696
  );
2894
- const targetDir = path__namespace.join(env.CODEGEN_APP_ROOT, "src");
5697
+ const targetDir = path2__namespace.join(env.CODEGEN_APP_ROOT, "src");
2895
5698
  try {
2896
5699
  env.logger.debug(
2897
5700
  `[${VERTICAL_NAME}-plugin-install] Using local zip file:`,
@@ -2905,8 +5708,8 @@ var unzipAndMergeLocalPluginFiles = async (env, zipPath) => {
2905
5708
  zip.getEntries().forEach((entry) => {
2906
5709
  if (!entry.isDirectory) {
2907
5710
  const entryPath = entry.entryName;
2908
- const targetPath = path__namespace.join(targetDir, entryPath);
2909
- const targetDirPath = path__namespace.dirname(targetPath);
5711
+ const targetPath = path2__namespace.join(targetDir, entryPath);
5712
+ const targetDirPath = path2__namespace.dirname(targetPath);
2910
5713
  if (!fs__namespace.existsSync(targetDirPath)) {
2911
5714
  fs__namespace.mkdirSync(targetDirPath, { recursive: true });
2912
5715
  }