@wix/vibe-forms-plugin 0.32.10 → 0.32.12

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
@@ -2,33 +2,11 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var fs = require('fs');
6
- var path2 = require('path');
7
- var https = require('https');
5
+ var path = require('path');
8
6
 
9
7
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
10
8
 
11
- function _interopNamespace(e) {
12
- if (e && e.__esModule) return e;
13
- var n = Object.create(null);
14
- if (e) {
15
- Object.keys(e).forEach(function (k) {
16
- if (k !== 'default') {
17
- var d = Object.getOwnPropertyDescriptor(e, k);
18
- Object.defineProperty(n, k, d.get ? d : {
19
- enumerable: true,
20
- get: function () { return e[k]; }
21
- });
22
- }
23
- });
24
- }
25
- n.default = e;
26
- return Object.freeze(n);
27
- }
28
-
29
- var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
30
- var path2__namespace = /*#__PURE__*/_interopNamespace(path2);
31
- var https__default = /*#__PURE__*/_interopDefault(https);
9
+ var path__default = /*#__PURE__*/_interopDefault(path);
32
10
 
33
11
  var __create = Object.create;
34
12
  var __defProp = Object.defineProperty;
@@ -62,2661 +40,12 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
62
40
  mod
63
41
  ));
64
42
 
65
- // ../../../node_modules/adm-zip/util/constants.js
66
- var require_constants = __commonJS({
67
- "../../../node_modules/adm-zip/util/constants.js"(exports$1, module) {
68
- module.exports = {
69
- /* The local file header */
70
- LOCHDR: 30,
71
- // LOC header size
72
- LOCSIG: 67324752,
73
- // "PK\003\004"
74
- LOCVER: 4,
75
- // version needed to extract
76
- LOCFLG: 6,
77
- // general purpose bit flag
78
- LOCHOW: 8,
79
- // compression method
80
- LOCTIM: 10,
81
- // modification time (2 bytes time, 2 bytes date)
82
- LOCCRC: 14,
83
- // uncompressed file crc-32 value
84
- LOCSIZ: 18,
85
- // compressed size
86
- LOCLEN: 22,
87
- // uncompressed size
88
- LOCNAM: 26,
89
- // filename length
90
- LOCEXT: 28,
91
- // extra field length
92
- /* The Data descriptor */
93
- EXTSIG: 134695760,
94
- // "PK\007\008"
95
- EXTHDR: 16,
96
- // EXT header size
97
- EXTCRC: 4,
98
- // uncompressed file crc-32 value
99
- EXTSIZ: 8,
100
- // compressed size
101
- EXTLEN: 12,
102
- // uncompressed size
103
- /* The central directory file header */
104
- CENHDR: 46,
105
- // CEN header size
106
- CENSIG: 33639248,
107
- // "PK\001\002"
108
- CENVEM: 4,
109
- // version made by
110
- CENVER: 6,
111
- // version needed to extract
112
- CENFLG: 8,
113
- // encrypt, decrypt flags
114
- CENHOW: 10,
115
- // compression method
116
- CENTIM: 12,
117
- // modification time (2 bytes time, 2 bytes date)
118
- CENCRC: 16,
119
- // uncompressed file crc-32 value
120
- CENSIZ: 20,
121
- // compressed size
122
- CENLEN: 24,
123
- // uncompressed size
124
- CENNAM: 28,
125
- // filename length
126
- CENEXT: 30,
127
- // extra field length
128
- CENCOM: 32,
129
- // file comment length
130
- CENDSK: 34,
131
- // volume number start
132
- CENATT: 36,
133
- // internal file attributes
134
- CENATX: 38,
135
- // external file attributes (host system dependent)
136
- CENOFF: 42,
137
- // LOC header offset
138
- /* The entries in the end of central directory */
139
- ENDHDR: 22,
140
- // END header size
141
- ENDSIG: 101010256,
142
- // "PK\005\006"
143
- ENDSUB: 8,
144
- // number of entries on this disk
145
- ENDTOT: 10,
146
- // total number of entries
147
- ENDSIZ: 12,
148
- // central directory size in bytes
149
- ENDOFF: 16,
150
- // offset of first CEN header
151
- ENDCOM: 20,
152
- // zip file comment length
153
- END64HDR: 20,
154
- // zip64 END header size
155
- END64SIG: 117853008,
156
- // zip64 Locator signature, "PK\006\007"
157
- END64START: 4,
158
- // number of the disk with the start of the zip64
159
- END64OFF: 8,
160
- // relative offset of the zip64 end of central directory
161
- END64NUMDISKS: 16,
162
- // total number of disks
163
- ZIP64SIG: 101075792,
164
- // zip64 signature, "PK\006\006"
165
- ZIP64HDR: 56,
166
- // zip64 record minimum size
167
- ZIP64LEAD: 12,
168
- // leading bytes at the start of the record, not counted by the value stored in ZIP64SIZE
169
- ZIP64SIZE: 4,
170
- // zip64 size of the central directory record
171
- ZIP64VEM: 12,
172
- // zip64 version made by
173
- ZIP64VER: 14,
174
- // zip64 version needed to extract
175
- ZIP64DSK: 16,
176
- // zip64 number of this disk
177
- ZIP64DSKDIR: 20,
178
- // number of the disk with the start of the record directory
179
- ZIP64SUB: 24,
180
- // number of entries on this disk
181
- ZIP64TOT: 32,
182
- // total number of entries
183
- ZIP64SIZB: 40,
184
- // zip64 central directory size in bytes
185
- ZIP64OFF: 48,
186
- // offset of start of central directory with respect to the starting disk number
187
- ZIP64EXTRA: 56,
188
- // extensible data sector
189
- /* Compression methods */
190
- STORED: 0,
191
- // no compression
192
- SHRUNK: 1,
193
- // shrunk
194
- REDUCED1: 2,
195
- // reduced with compression factor 1
196
- REDUCED2: 3,
197
- // reduced with compression factor 2
198
- REDUCED3: 4,
199
- // reduced with compression factor 3
200
- REDUCED4: 5,
201
- // reduced with compression factor 4
202
- IMPLODED: 6,
203
- // imploded
204
- // 7 reserved for Tokenizing compression algorithm
205
- DEFLATED: 8,
206
- // deflated
207
- ENHANCED_DEFLATED: 9,
208
- // enhanced deflated
209
- PKWARE: 10,
210
- // PKWare DCL imploded
211
- // 11 reserved by PKWARE
212
- BZIP2: 12,
213
- // compressed using BZIP2
214
- // 13 reserved by PKWARE
215
- LZMA: 14,
216
- // LZMA
217
- // 15-17 reserved by PKWARE
218
- IBM_TERSE: 18,
219
- // compressed using IBM TERSE
220
- IBM_LZ77: 19,
221
- // IBM LZ77 z
222
- AES_ENCRYPT: 99,
223
- // WinZIP AES encryption method
224
- /* General purpose bit flag */
225
- // values can obtained with expression 2**bitnr
226
- FLG_ENC: 1,
227
- // Bit 0: encrypted file
228
- FLG_COMP1: 2,
229
- // Bit 1, compression option
230
- FLG_COMP2: 4,
231
- // Bit 2, compression option
232
- FLG_DESC: 8,
233
- // Bit 3, data descriptor
234
- FLG_ENH: 16,
235
- // Bit 4, enhanced deflating
236
- FLG_PATCH: 32,
237
- // Bit 5, indicates that the file is compressed patched data.
238
- FLG_STR: 64,
239
- // Bit 6, strong encryption (patented)
240
- // Bits 7-10: Currently unused.
241
- FLG_EFS: 2048,
242
- // Bit 11: Language encoding flag (EFS)
243
- // Bit 12: Reserved by PKWARE for enhanced compression.
244
- // Bit 13: encrypted the Central Directory (patented).
245
- // Bits 14-15: Reserved by PKWARE.
246
- FLG_MSK: 4096,
247
- // mask header values
248
- /* Load type */
249
- FILE: 2,
250
- BUFFER: 1,
251
- NONE: 0,
252
- /* 4.5 Extensible data fields */
253
- EF_ID: 0,
254
- EF_SIZE: 2,
255
- /* Header IDs */
256
- ID_ZIP64: 1,
257
- ID_AVINFO: 7,
258
- ID_PFS: 8,
259
- ID_OS2: 9,
260
- ID_NTFS: 10,
261
- ID_OPENVMS: 12,
262
- ID_UNIX: 13,
263
- ID_FORK: 14,
264
- ID_PATCH: 15,
265
- ID_X509_PKCS7: 20,
266
- ID_X509_CERTID_F: 21,
267
- ID_X509_CERTID_C: 22,
268
- ID_STRONGENC: 23,
269
- ID_RECORD_MGT: 24,
270
- ID_X509_PKCS7_RL: 25,
271
- ID_IBM1: 101,
272
- ID_IBM2: 102,
273
- ID_POSZIP: 18064,
274
- EF_ZIP64_OR_32: 4294967295,
275
- EF_ZIP64_OR_16: 65535,
276
- EF_ZIP64_SUNCOMP: 0,
277
- EF_ZIP64_SCOMP: 8,
278
- EF_ZIP64_RHO: 16,
279
- EF_ZIP64_DSN: 24
280
- };
281
- }
282
- });
283
-
284
- // ../../../node_modules/adm-zip/util/errors.js
285
- var require_errors = __commonJS({
286
- "../../../node_modules/adm-zip/util/errors.js"(exports$1) {
287
- var errors = {
288
- /* Header error messages */
289
- INVALID_LOC: "Invalid LOC header (bad signature)",
290
- INVALID_CEN: "Invalid CEN header (bad signature)",
291
- INVALID_END: "Invalid END header (bad signature)",
292
- /* Descriptor */
293
- DESCRIPTOR_NOT_EXIST: "No descriptor present",
294
- DESCRIPTOR_UNKNOWN: "Unknown descriptor format",
295
- DESCRIPTOR_FAULTY: "Descriptor data is malformed",
296
- /* ZipEntry error messages*/
297
- NO_DATA: "Nothing to decompress",
298
- BAD_CRC: "CRC32 checksum failed {0}",
299
- FILE_IN_THE_WAY: "There is a file in the way: {0}",
300
- UNKNOWN_METHOD: "Invalid/unsupported compression method",
301
- /* Inflater error messages */
302
- AVAIL_DATA: "inflate::Available inflate data did not terminate",
303
- INVALID_DISTANCE: "inflate::Invalid literal/length or distance code in fixed or dynamic block",
304
- TO_MANY_CODES: "inflate::Dynamic block code description: too many length or distance codes",
305
- INVALID_REPEAT_LEN: "inflate::Dynamic block code description: repeat more than specified lengths",
306
- INVALID_REPEAT_FIRST: "inflate::Dynamic block code description: repeat lengths with no first length",
307
- INCOMPLETE_CODES: "inflate::Dynamic block code description: code lengths codes incomplete",
308
- INVALID_DYN_DISTANCE: "inflate::Dynamic block code description: invalid distance code lengths",
309
- INVALID_CODES_LEN: "inflate::Dynamic block code description: invalid literal/length code lengths",
310
- INVALID_STORE_BLOCK: "inflate::Stored block length did not match one's complement",
311
- INVALID_BLOCK_TYPE: "inflate::Invalid block type (type == 3)",
312
- /* ADM-ZIP error messages */
313
- CANT_EXTRACT_FILE: "Could not extract the file",
314
- CANT_OVERRIDE: "Target file already exists",
315
- DISK_ENTRY_TOO_LARGE: "Number of disk entries is too large",
316
- NO_ZIP: "No zip file was loaded",
317
- NO_ENTRY: "Entry doesn't exist",
318
- DIRECTORY_CONTENT_ERROR: "A directory cannot have content",
319
- FILE_NOT_FOUND: 'File not found: "{0}"',
320
- NOT_IMPLEMENTED: "Not implemented",
321
- INVALID_FILENAME: "Invalid filename",
322
- INVALID_FORMAT: "Invalid or unsupported zip format. No END header found",
323
- INVALID_PASS_PARAM: "Incompatible password parameter",
324
- WRONG_PASSWORD: "Wrong Password",
325
- /* ADM-ZIP */
326
- COMMENT_TOO_LONG: "Comment is too long",
327
- // Comment can be max 65535 bytes long (NOTE: some non-US characters may take more space)
328
- EXTRA_FIELD_PARSE_ERROR: "Extra field parsing error"
329
- };
330
- function E(message) {
331
- return function(...args) {
332
- if (args.length) {
333
- message = message.replace(/\{(\d)\}/g, (_, n) => args[n] || "");
334
- }
335
- return new Error("ADM-ZIP: " + message);
336
- };
337
- }
338
- for (const msg of Object.keys(errors)) {
339
- exports$1[msg] = E(errors[msg]);
340
- }
341
- }
342
- });
343
-
344
- // ../../../node_modules/adm-zip/util/utils.js
345
- var require_utils = __commonJS({
346
- "../../../node_modules/adm-zip/util/utils.js"(exports$1, module) {
347
- var fsystem = __require("fs");
348
- var pth = __require("path");
349
- var Constants = require_constants();
350
- var Errors = require_errors();
351
- var isWin = typeof process === "object" && "win32" === process.platform;
352
- var is_Obj = (obj) => typeof obj === "object" && obj !== null;
353
- var crcTable = new Uint32Array(256).map((t, c) => {
354
- for (let k = 0; k < 8; k++) {
355
- if ((c & 1) !== 0) {
356
- c = 3988292384 ^ c >>> 1;
357
- } else {
358
- c >>>= 1;
359
- }
360
- }
361
- return c >>> 0;
362
- });
363
- function Utils(opts) {
364
- this.sep = pth.sep;
365
- this.fs = fsystem;
366
- if (is_Obj(opts)) {
367
- if (is_Obj(opts.fs) && typeof opts.fs.statSync === "function") {
368
- this.fs = opts.fs;
369
- }
370
- }
371
- }
372
- module.exports = Utils;
373
- Utils.prototype.makeDir = function(folder) {
374
- const self = this;
375
- function mkdirSync2(fpath) {
376
- let resolvedPath = fpath.split(self.sep)[0];
377
- fpath.split(self.sep).forEach(function(name) {
378
- if (!name || name.substr(-1, 1) === ":") return;
379
- resolvedPath += self.sep + name;
380
- var stat;
381
- try {
382
- stat = self.fs.statSync(resolvedPath);
383
- } catch (e) {
384
- self.fs.mkdirSync(resolvedPath);
385
- }
386
- if (stat && stat.isFile()) throw Errors.FILE_IN_THE_WAY(`"${resolvedPath}"`);
387
- });
388
- }
389
- mkdirSync2(folder);
390
- };
391
- Utils.prototype.writeFileTo = function(path3, content, overwrite, attr) {
392
- const self = this;
393
- if (self.fs.existsSync(path3)) {
394
- if (!overwrite) return false;
395
- var stat = self.fs.statSync(path3);
396
- if (stat.isDirectory()) {
397
- return false;
398
- }
399
- }
400
- var folder = pth.dirname(path3);
401
- if (!self.fs.existsSync(folder)) {
402
- self.makeDir(folder);
403
- }
404
- var fd;
405
- try {
406
- fd = self.fs.openSync(path3, "w", 438);
407
- } catch (e) {
408
- self.fs.chmodSync(path3, 438);
409
- fd = self.fs.openSync(path3, "w", 438);
410
- }
411
- if (fd) {
412
- try {
413
- self.fs.writeSync(fd, content, 0, content.length, 0);
414
- } finally {
415
- self.fs.closeSync(fd);
416
- }
417
- }
418
- self.fs.chmodSync(path3, attr || 438);
419
- return true;
420
- };
421
- Utils.prototype.writeFileToAsync = function(path3, content, overwrite, attr, callback) {
422
- if (typeof attr === "function") {
423
- callback = attr;
424
- attr = void 0;
425
- }
426
- const self = this;
427
- self.fs.exists(path3, function(exist) {
428
- if (exist && !overwrite) return callback(false);
429
- self.fs.stat(path3, function(err, stat) {
430
- if (exist && stat.isDirectory()) {
431
- return callback(false);
432
- }
433
- var folder = pth.dirname(path3);
434
- self.fs.exists(folder, function(exists) {
435
- if (!exists) self.makeDir(folder);
436
- self.fs.open(path3, "w", 438, function(err2, fd) {
437
- if (err2) {
438
- self.fs.chmod(path3, 438, function() {
439
- self.fs.open(path3, "w", 438, function(err3, fd2) {
440
- self.fs.write(fd2, content, 0, content.length, 0, function() {
441
- self.fs.close(fd2, function() {
442
- self.fs.chmod(path3, attr || 438, function() {
443
- callback(true);
444
- });
445
- });
446
- });
447
- });
448
- });
449
- } else if (fd) {
450
- self.fs.write(fd, content, 0, content.length, 0, function() {
451
- self.fs.close(fd, function() {
452
- self.fs.chmod(path3, attr || 438, function() {
453
- callback(true);
454
- });
455
- });
456
- });
457
- } else {
458
- self.fs.chmod(path3, attr || 438, function() {
459
- callback(true);
460
- });
461
- }
462
- });
463
- });
464
- });
465
- });
466
- };
467
- Utils.prototype.findFiles = function(path3) {
468
- const self = this;
469
- function findSync(dir, pattern, recursive) {
470
- let files = [];
471
- self.fs.readdirSync(dir).forEach(function(file) {
472
- const path4 = pth.join(dir, file);
473
- const stat = self.fs.statSync(path4);
474
- {
475
- files.push(pth.normalize(path4) + (stat.isDirectory() ? self.sep : ""));
476
- }
477
- if (stat.isDirectory() && recursive) files = files.concat(findSync(path4, pattern, recursive));
478
- });
479
- return files;
480
- }
481
- return findSync(path3, void 0, true);
482
- };
483
- Utils.prototype.findFilesAsync = function(dir, cb) {
484
- const self = this;
485
- let results = [];
486
- self.fs.readdir(dir, function(err, list) {
487
- if (err) return cb(err);
488
- let list_length = list.length;
489
- if (!list_length) return cb(null, results);
490
- list.forEach(function(file) {
491
- file = pth.join(dir, file);
492
- self.fs.stat(file, function(err2, stat) {
493
- if (err2) return cb(err2);
494
- if (stat) {
495
- results.push(pth.normalize(file) + (stat.isDirectory() ? self.sep : ""));
496
- if (stat.isDirectory()) {
497
- self.findFilesAsync(file, function(err3, res) {
498
- if (err3) return cb(err3);
499
- results = results.concat(res);
500
- if (!--list_length) cb(null, results);
501
- });
502
- } else {
503
- if (!--list_length) cb(null, results);
504
- }
505
- }
506
- });
507
- });
508
- });
509
- };
510
- Utils.prototype.getAttributes = function() {
511
- };
512
- Utils.prototype.setAttributes = function() {
513
- };
514
- Utils.crc32update = function(crc, byte) {
515
- return crcTable[(crc ^ byte) & 255] ^ crc >>> 8;
516
- };
517
- Utils.crc32 = function(buf) {
518
- if (typeof buf === "string") {
519
- buf = Buffer.from(buf, "utf8");
520
- }
521
- let len = buf.length;
522
- let crc = -1;
523
- for (let off = 0; off < len; ) crc = Utils.crc32update(crc, buf[off++]);
524
- return ~crc >>> 0;
525
- };
526
- Utils.methodToString = function(method) {
527
- switch (method) {
528
- case Constants.STORED:
529
- return "STORED (" + method + ")";
530
- case Constants.DEFLATED:
531
- return "DEFLATED (" + method + ")";
532
- default:
533
- return "UNSUPPORTED (" + method + ")";
534
- }
535
- };
536
- Utils.canonical = function(path3) {
537
- if (!path3) return "";
538
- const safeSuffix = pth.posix.normalize("/" + path3.split("\\").join("/"));
539
- return pth.join(".", safeSuffix);
540
- };
541
- Utils.zipnamefix = function(path3) {
542
- if (!path3) return "";
543
- const safeSuffix = pth.posix.normalize("/" + path3.split("\\").join("/"));
544
- return pth.posix.join(".", safeSuffix);
545
- };
546
- Utils.findLast = function(arr, callback) {
547
- if (!Array.isArray(arr)) throw new TypeError("arr is not array");
548
- const len = arr.length >>> 0;
549
- for (let i = len - 1; i >= 0; i--) {
550
- if (callback(arr[i], i, arr)) {
551
- return arr[i];
552
- }
553
- }
554
- return void 0;
555
- };
556
- Utils.sanitize = function(prefix, name) {
557
- prefix = pth.resolve(pth.normalize(prefix));
558
- var parts = name.split("/");
559
- for (var i = 0, l = parts.length; i < l; i++) {
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
- }
564
- }
565
- return pth.normalize(pth.join(prefix, pth.basename(name)));
566
- };
567
- Utils.toBuffer = function toBuffer(input, encoder) {
568
- if (Buffer.isBuffer(input)) {
569
- return input;
570
- } else if (input instanceof Uint8Array) {
571
- return Buffer.from(input);
572
- } else {
573
- return typeof input === "string" ? encoder(input) : Buffer.alloc(0);
574
- }
575
- };
576
- Utils.readBigUInt64LE = function(buffer, index) {
577
- var slice = Buffer.from(buffer.slice(index, index + 8));
578
- slice.swap64();
579
- return parseInt(`0x${slice.toString("hex")}`);
580
- };
581
- Utils.fromDOS2Date = function(val) {
582
- 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);
583
- };
584
- Utils.fromDate2DOS = function(val) {
585
- let date = 0;
586
- let time = 0;
587
- if (val.getFullYear() > 1979) {
588
- date = (val.getFullYear() - 1980 & 127) << 9 | val.getMonth() + 1 << 5 | val.getDate();
589
- time = val.getHours() << 11 | val.getMinutes() << 5 | val.getSeconds() >> 1;
590
- }
591
- return date << 16 | time;
592
- };
593
- Utils.isWin = isWin;
594
- Utils.crcTable = crcTable;
595
- }
596
- });
597
-
598
- // ../../../node_modules/adm-zip/util/fattr.js
599
- var require_fattr = __commonJS({
600
- "../../../node_modules/adm-zip/util/fattr.js"(exports$1, module) {
601
- var pth = __require("path");
602
- module.exports = function(path3, { fs: fs2 }) {
603
- var _path = path3 || "", _obj = newAttr(), _stat = null;
604
- function newAttr() {
605
- return {
606
- directory: false,
607
- readonly: false,
608
- hidden: false,
609
- executable: false,
610
- mtime: 0,
611
- atime: 0
612
- };
613
- }
614
- if (_path && fs2.existsSync(_path)) {
615
- _stat = fs2.statSync(_path);
616
- _obj.directory = _stat.isDirectory();
617
- _obj.mtime = _stat.mtime;
618
- _obj.atime = _stat.atime;
619
- _obj.executable = (73 & _stat.mode) !== 0;
620
- _obj.readonly = (128 & _stat.mode) === 0;
621
- _obj.hidden = pth.basename(_path)[0] === ".";
622
- } else {
623
- console.warn("Invalid path: " + _path);
624
- }
625
- return {
626
- get directory() {
627
- return _obj.directory;
628
- },
629
- get readOnly() {
630
- return _obj.readonly;
631
- },
632
- get hidden() {
633
- return _obj.hidden;
634
- },
635
- get mtime() {
636
- return _obj.mtime;
637
- },
638
- get atime() {
639
- return _obj.atime;
640
- },
641
- get executable() {
642
- return _obj.executable;
643
- },
644
- decodeAttributes: function() {
645
- },
646
- encodeAttributes: function() {
647
- },
648
- toJSON: function() {
649
- return {
650
- path: _path,
651
- isDirectory: _obj.directory,
652
- isReadOnly: _obj.readonly,
653
- isHidden: _obj.hidden,
654
- isExecutable: _obj.executable,
655
- mTime: _obj.mtime,
656
- aTime: _obj.atime
657
- };
658
- },
659
- toString: function() {
660
- return JSON.stringify(this.toJSON(), null, " ");
661
- }
662
- };
663
- };
664
- }
665
- });
666
-
667
- // ../../../node_modules/adm-zip/util/decoder.js
668
- var require_decoder = __commonJS({
669
- "../../../node_modules/adm-zip/util/decoder.js"(exports$1, module) {
670
- module.exports = {
671
- efs: true,
672
- encode: (data) => Buffer.from(data, "utf8"),
673
- decode: (data) => data.toString("utf8")
674
- };
675
- }
676
- });
677
-
678
- // ../../../node_modules/adm-zip/util/index.js
679
- var require_util = __commonJS({
680
- "../../../node_modules/adm-zip/util/index.js"(exports$1, module) {
681
- module.exports = require_utils();
682
- module.exports.Constants = require_constants();
683
- module.exports.Errors = require_errors();
684
- module.exports.FileAttr = require_fattr();
685
- module.exports.decoder = require_decoder();
686
- }
687
- });
688
-
689
- // ../../../node_modules/adm-zip/headers/entryHeader.js
690
- var require_entryHeader = __commonJS({
691
- "../../../node_modules/adm-zip/headers/entryHeader.js"(exports$1, module) {
692
- var Utils = require_util();
693
- var Constants = Utils.Constants;
694
- module.exports = function() {
695
- 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;
696
- _verMade |= Utils.isWin ? 2560 : 768;
697
- _flags |= Constants.FLG_EFS;
698
- const _localHeader = {
699
- extraLen: 0
700
- };
701
- const uint32 = (val) => Math.max(0, val) >>> 0;
702
- const uint8 = (val) => Math.max(0, val) & 255;
703
- _time = Utils.fromDate2DOS(/* @__PURE__ */ new Date());
704
- return {
705
- get made() {
706
- return _verMade;
707
- },
708
- set made(val) {
709
- _verMade = val;
710
- },
711
- get version() {
712
- return _version;
713
- },
714
- set version(val) {
715
- _version = val;
716
- },
717
- get flags() {
718
- return _flags;
719
- },
720
- set flags(val) {
721
- _flags = val;
722
- },
723
- get flags_efs() {
724
- return (_flags & Constants.FLG_EFS) > 0;
725
- },
726
- set flags_efs(val) {
727
- if (val) {
728
- _flags |= Constants.FLG_EFS;
729
- } else {
730
- _flags &= ~Constants.FLG_EFS;
731
- }
732
- },
733
- get flags_desc() {
734
- return (_flags & Constants.FLG_DESC) > 0;
735
- },
736
- set flags_desc(val) {
737
- if (val) {
738
- _flags |= Constants.FLG_DESC;
739
- } else {
740
- _flags &= ~Constants.FLG_DESC;
741
- }
742
- },
743
- get method() {
744
- return _method;
745
- },
746
- set method(val) {
747
- switch (val) {
748
- case Constants.STORED:
749
- this.version = 10;
750
- case Constants.DEFLATED:
751
- default:
752
- this.version = 20;
753
- }
754
- _method = val;
755
- },
756
- get time() {
757
- return Utils.fromDOS2Date(this.timeval);
758
- },
759
- set time(val) {
760
- this.timeval = Utils.fromDate2DOS(val);
761
- },
762
- get timeval() {
763
- return _time;
764
- },
765
- set timeval(val) {
766
- _time = uint32(val);
767
- },
768
- get timeHighByte() {
769
- return uint8(_time >>> 8);
770
- },
771
- get crc() {
772
- return _crc;
773
- },
774
- set crc(val) {
775
- _crc = uint32(val);
776
- },
777
- get compressedSize() {
778
- return _compressedSize;
779
- },
780
- set compressedSize(val) {
781
- _compressedSize = uint32(val);
782
- },
783
- get size() {
784
- return _size;
785
- },
786
- set size(val) {
787
- _size = uint32(val);
788
- },
789
- get fileNameLength() {
790
- return _fnameLen;
791
- },
792
- set fileNameLength(val) {
793
- _fnameLen = val;
794
- },
795
- get extraLength() {
796
- return _extraLen;
797
- },
798
- set extraLength(val) {
799
- _extraLen = val;
800
- },
801
- get extraLocalLength() {
802
- return _localHeader.extraLen;
803
- },
804
- set extraLocalLength(val) {
805
- _localHeader.extraLen = val;
806
- },
807
- get commentLength() {
808
- return _comLen;
809
- },
810
- set commentLength(val) {
811
- _comLen = val;
812
- },
813
- get diskNumStart() {
814
- return _diskStart;
815
- },
816
- set diskNumStart(val) {
817
- _diskStart = uint32(val);
818
- },
819
- get inAttr() {
820
- return _inattr;
821
- },
822
- set inAttr(val) {
823
- _inattr = uint32(val);
824
- },
825
- get attr() {
826
- return _attr;
827
- },
828
- set attr(val) {
829
- _attr = uint32(val);
830
- },
831
- // get Unix file permissions
832
- get fileAttr() {
833
- return (_attr || 0) >> 16 & 4095;
834
- },
835
- get offset() {
836
- return _offset;
837
- },
838
- set offset(val) {
839
- _offset = uint32(val);
840
- },
841
- get encrypted() {
842
- return (_flags & Constants.FLG_ENC) === Constants.FLG_ENC;
843
- },
844
- get centralHeaderSize() {
845
- return Constants.CENHDR + _fnameLen + _extraLen + _comLen;
846
- },
847
- get realDataOffset() {
848
- return _offset + Constants.LOCHDR + _localHeader.fnameLen + _localHeader.extraLen;
849
- },
850
- get localHeader() {
851
- return _localHeader;
852
- },
853
- loadLocalHeaderFromBinary: function(input) {
854
- var data = input.slice(_offset, _offset + Constants.LOCHDR);
855
- if (data.readUInt32LE(0) !== Constants.LOCSIG) {
856
- throw Utils.Errors.INVALID_LOC();
857
- }
858
- _localHeader.version = data.readUInt16LE(Constants.LOCVER);
859
- _localHeader.flags = data.readUInt16LE(Constants.LOCFLG);
860
- _localHeader.method = data.readUInt16LE(Constants.LOCHOW);
861
- _localHeader.time = data.readUInt32LE(Constants.LOCTIM);
862
- _localHeader.crc = data.readUInt32LE(Constants.LOCCRC);
863
- _localHeader.compressedSize = data.readUInt32LE(Constants.LOCSIZ);
864
- _localHeader.size = data.readUInt32LE(Constants.LOCLEN);
865
- _localHeader.fnameLen = data.readUInt16LE(Constants.LOCNAM);
866
- _localHeader.extraLen = data.readUInt16LE(Constants.LOCEXT);
867
- const extraStart = _offset + Constants.LOCHDR + _localHeader.fnameLen;
868
- const extraEnd = extraStart + _localHeader.extraLen;
869
- return input.slice(extraStart, extraEnd);
870
- },
871
- loadFromBinary: function(data) {
872
- if (data.length !== Constants.CENHDR || data.readUInt32LE(0) !== Constants.CENSIG) {
873
- throw Utils.Errors.INVALID_CEN();
874
- }
875
- _verMade = data.readUInt16LE(Constants.CENVEM);
876
- _version = data.readUInt16LE(Constants.CENVER);
877
- _flags = data.readUInt16LE(Constants.CENFLG);
878
- _method = data.readUInt16LE(Constants.CENHOW);
879
- _time = data.readUInt32LE(Constants.CENTIM);
880
- _crc = data.readUInt32LE(Constants.CENCRC);
881
- _compressedSize = data.readUInt32LE(Constants.CENSIZ);
882
- _size = data.readUInt32LE(Constants.CENLEN);
883
- _fnameLen = data.readUInt16LE(Constants.CENNAM);
884
- _extraLen = data.readUInt16LE(Constants.CENEXT);
885
- _comLen = data.readUInt16LE(Constants.CENCOM);
886
- _diskStart = data.readUInt16LE(Constants.CENDSK);
887
- _inattr = data.readUInt16LE(Constants.CENATT);
888
- _attr = data.readUInt32LE(Constants.CENATX);
889
- _offset = data.readUInt32LE(Constants.CENOFF);
890
- },
891
- localHeaderToBinary: function() {
892
- var data = Buffer.alloc(Constants.LOCHDR);
893
- data.writeUInt32LE(Constants.LOCSIG, 0);
894
- data.writeUInt16LE(_version, Constants.LOCVER);
895
- data.writeUInt16LE(_flags, Constants.LOCFLG);
896
- data.writeUInt16LE(_method, Constants.LOCHOW);
897
- data.writeUInt32LE(_time, Constants.LOCTIM);
898
- data.writeUInt32LE(_crc, Constants.LOCCRC);
899
- data.writeUInt32LE(_compressedSize, Constants.LOCSIZ);
900
- data.writeUInt32LE(_size, Constants.LOCLEN);
901
- data.writeUInt16LE(_fnameLen, Constants.LOCNAM);
902
- data.writeUInt16LE(_localHeader.extraLen, Constants.LOCEXT);
903
- return data;
904
- },
905
- centralHeaderToBinary: function() {
906
- var data = Buffer.alloc(Constants.CENHDR + _fnameLen + _extraLen + _comLen);
907
- data.writeUInt32LE(Constants.CENSIG, 0);
908
- data.writeUInt16LE(_verMade, Constants.CENVEM);
909
- data.writeUInt16LE(_version, Constants.CENVER);
910
- data.writeUInt16LE(_flags, Constants.CENFLG);
911
- data.writeUInt16LE(_method, Constants.CENHOW);
912
- data.writeUInt32LE(_time, Constants.CENTIM);
913
- data.writeUInt32LE(_crc, Constants.CENCRC);
914
- data.writeUInt32LE(_compressedSize, Constants.CENSIZ);
915
- data.writeUInt32LE(_size, Constants.CENLEN);
916
- data.writeUInt16LE(_fnameLen, Constants.CENNAM);
917
- data.writeUInt16LE(_extraLen, Constants.CENEXT);
918
- data.writeUInt16LE(_comLen, Constants.CENCOM);
919
- data.writeUInt16LE(_diskStart, Constants.CENDSK);
920
- data.writeUInt16LE(_inattr, Constants.CENATT);
921
- data.writeUInt32LE(_attr, Constants.CENATX);
922
- data.writeUInt32LE(_offset, Constants.CENOFF);
923
- return data;
924
- },
925
- toJSON: function() {
926
- const bytes = function(nr) {
927
- return nr + " bytes";
928
- };
929
- return {
930
- made: _verMade,
931
- version: _version,
932
- flags: _flags,
933
- method: Utils.methodToString(_method),
934
- time: this.time,
935
- crc: "0x" + _crc.toString(16).toUpperCase(),
936
- compressedSize: bytes(_compressedSize),
937
- size: bytes(_size),
938
- fileNameLength: bytes(_fnameLen),
939
- extraLength: bytes(_extraLen),
940
- commentLength: bytes(_comLen),
941
- diskNumStart: _diskStart,
942
- inAttr: _inattr,
943
- attr: _attr,
944
- offset: _offset,
945
- centralHeaderSize: bytes(Constants.CENHDR + _fnameLen + _extraLen + _comLen)
946
- };
947
- },
948
- toString: function() {
949
- return JSON.stringify(this.toJSON(), null, " ");
950
- }
951
- };
952
- };
953
- }
954
- });
955
-
956
- // ../../../node_modules/adm-zip/headers/mainHeader.js
957
- var require_mainHeader = __commonJS({
958
- "../../../node_modules/adm-zip/headers/mainHeader.js"(exports$1, module) {
959
- var Utils = require_util();
960
- var Constants = Utils.Constants;
961
- module.exports = function() {
962
- var _volumeEntries = 0, _totalEntries = 0, _size = 0, _offset = 0, _commentLength = 0;
963
- return {
964
- get diskEntries() {
965
- return _volumeEntries;
966
- },
967
- set diskEntries(val) {
968
- _volumeEntries = _totalEntries = val;
969
- },
970
- get totalEntries() {
971
- return _totalEntries;
972
- },
973
- set totalEntries(val) {
974
- _totalEntries = _volumeEntries = val;
975
- },
976
- get size() {
977
- return _size;
978
- },
979
- set size(val) {
980
- _size = val;
981
- },
982
- get offset() {
983
- return _offset;
984
- },
985
- set offset(val) {
986
- _offset = val;
987
- },
988
- get commentLength() {
989
- return _commentLength;
990
- },
991
- set commentLength(val) {
992
- _commentLength = val;
993
- },
994
- get mainHeaderSize() {
995
- return Constants.ENDHDR + _commentLength;
996
- },
997
- loadFromBinary: function(data) {
998
- if ((data.length !== Constants.ENDHDR || data.readUInt32LE(0) !== Constants.ENDSIG) && (data.length < Constants.ZIP64HDR || data.readUInt32LE(0) !== Constants.ZIP64SIG)) {
999
- throw Utils.Errors.INVALID_END();
1000
- }
1001
- if (data.readUInt32LE(0) === Constants.ENDSIG) {
1002
- _volumeEntries = data.readUInt16LE(Constants.ENDSUB);
1003
- _totalEntries = data.readUInt16LE(Constants.ENDTOT);
1004
- _size = data.readUInt32LE(Constants.ENDSIZ);
1005
- _offset = data.readUInt32LE(Constants.ENDOFF);
1006
- _commentLength = data.readUInt16LE(Constants.ENDCOM);
1007
- } else {
1008
- _volumeEntries = Utils.readBigUInt64LE(data, Constants.ZIP64SUB);
1009
- _totalEntries = Utils.readBigUInt64LE(data, Constants.ZIP64TOT);
1010
- _size = Utils.readBigUInt64LE(data, Constants.ZIP64SIZE);
1011
- _offset = Utils.readBigUInt64LE(data, Constants.ZIP64OFF);
1012
- _commentLength = 0;
1013
- }
1014
- },
1015
- toBinary: function() {
1016
- var b = Buffer.alloc(Constants.ENDHDR + _commentLength);
1017
- b.writeUInt32LE(Constants.ENDSIG, 0);
1018
- b.writeUInt32LE(0, 4);
1019
- b.writeUInt16LE(_volumeEntries, Constants.ENDSUB);
1020
- b.writeUInt16LE(_totalEntries, Constants.ENDTOT);
1021
- b.writeUInt32LE(_size, Constants.ENDSIZ);
1022
- b.writeUInt32LE(_offset, Constants.ENDOFF);
1023
- b.writeUInt16LE(_commentLength, Constants.ENDCOM);
1024
- b.fill(" ", Constants.ENDHDR);
1025
- return b;
1026
- },
1027
- toJSON: function() {
1028
- const offset = function(nr, len) {
1029
- let offs = nr.toString(16).toUpperCase();
1030
- while (offs.length < len) offs = "0" + offs;
1031
- return "0x" + offs;
1032
- };
1033
- return {
1034
- diskEntries: _volumeEntries,
1035
- totalEntries: _totalEntries,
1036
- size: _size + " bytes",
1037
- offset: offset(_offset, 4),
1038
- commentLength: _commentLength
1039
- };
1040
- },
1041
- toString: function() {
1042
- return JSON.stringify(this.toJSON(), null, " ");
1043
- }
1044
- };
1045
- };
1046
- }
1047
- });
1048
-
1049
- // ../../../node_modules/adm-zip/headers/index.js
1050
- var require_headers = __commonJS({
1051
- "../../../node_modules/adm-zip/headers/index.js"(exports$1) {
1052
- exports$1.EntryHeader = require_entryHeader();
1053
- exports$1.MainHeader = require_mainHeader();
1054
- }
1055
- });
1056
-
1057
- // ../../../node_modules/adm-zip/methods/deflater.js
1058
- var require_deflater = __commonJS({
1059
- "../../../node_modules/adm-zip/methods/deflater.js"(exports$1, module) {
1060
- module.exports = function(inbuf) {
1061
- var zlib = __require("zlib");
1062
- var opts = { chunkSize: (parseInt(inbuf.length / 1024) + 1) * 1024 };
1063
- return {
1064
- deflate: function() {
1065
- return zlib.deflateRawSync(inbuf, opts);
1066
- },
1067
- deflateAsync: function(callback) {
1068
- var tmp = zlib.createDeflateRaw(opts), parts = [], total = 0;
1069
- tmp.on("data", function(data) {
1070
- parts.push(data);
1071
- total += data.length;
1072
- });
1073
- tmp.on("end", function() {
1074
- var buf = Buffer.alloc(total), written = 0;
1075
- buf.fill(0);
1076
- for (var i = 0; i < parts.length; i++) {
1077
- var part = parts[i];
1078
- part.copy(buf, written);
1079
- written += part.length;
1080
- }
1081
- callback && callback(buf);
1082
- });
1083
- tmp.end(inbuf);
1084
- }
1085
- };
1086
- };
1087
- }
1088
- });
1089
-
1090
- // ../../../node_modules/adm-zip/methods/inflater.js
1091
- var require_inflater = __commonJS({
1092
- "../../../node_modules/adm-zip/methods/inflater.js"(exports$1, module) {
1093
- var version = +(process.versions ? process.versions.node : "").split(".")[0] || 0;
1094
- module.exports = function(inbuf, expectedLength) {
1095
- var zlib = __require("zlib");
1096
- const option = version >= 15 && expectedLength > 0 ? { maxOutputLength: expectedLength } : {};
1097
- return {
1098
- inflate: function() {
1099
- return zlib.inflateRawSync(inbuf, option);
1100
- },
1101
- inflateAsync: function(callback) {
1102
- var tmp = zlib.createInflateRaw(option), parts = [], total = 0;
1103
- tmp.on("data", function(data) {
1104
- parts.push(data);
1105
- total += data.length;
1106
- });
1107
- tmp.on("end", function() {
1108
- var buf = Buffer.alloc(total), written = 0;
1109
- buf.fill(0);
1110
- for (var i = 0; i < parts.length; i++) {
1111
- var part = parts[i];
1112
- part.copy(buf, written);
1113
- written += part.length;
1114
- }
1115
- callback && callback(buf);
1116
- });
1117
- tmp.end(inbuf);
1118
- }
1119
- };
1120
- };
1121
- }
1122
- });
1123
-
1124
- // ../../../node_modules/adm-zip/methods/zipcrypto.js
1125
- var require_zipcrypto = __commonJS({
1126
- "../../../node_modules/adm-zip/methods/zipcrypto.js"(exports$1, module) {
1127
- var { randomFillSync } = __require("crypto");
1128
- var Errors = require_errors();
1129
- var crctable = new Uint32Array(256).map((t, crc) => {
1130
- for (let j = 0; j < 8; j++) {
1131
- if (0 !== (crc & 1)) {
1132
- crc = crc >>> 1 ^ 3988292384;
1133
- } else {
1134
- crc >>>= 1;
1135
- }
1136
- }
1137
- return crc >>> 0;
1138
- });
1139
- var uMul = (a, b) => Math.imul(a, b) >>> 0;
1140
- var crc32update = (pCrc32, bval) => {
1141
- return crctable[(pCrc32 ^ bval) & 255] ^ pCrc32 >>> 8;
1142
- };
1143
- var genSalt = () => {
1144
- if ("function" === typeof randomFillSync) {
1145
- return randomFillSync(Buffer.alloc(12));
1146
- } else {
1147
- return genSalt.node();
1148
- }
1149
- };
1150
- genSalt.node = () => {
1151
- const salt = Buffer.alloc(12);
1152
- const len = salt.length;
1153
- for (let i = 0; i < len; i++) salt[i] = Math.random() * 256 & 255;
1154
- return salt;
1155
- };
1156
- var config = {
1157
- genSalt
1158
- };
1159
- function Initkeys(pw) {
1160
- const pass = Buffer.isBuffer(pw) ? pw : Buffer.from(pw);
1161
- this.keys = new Uint32Array([305419896, 591751049, 878082192]);
1162
- for (let i = 0; i < pass.length; i++) {
1163
- this.updateKeys(pass[i]);
1164
- }
1165
- }
1166
- Initkeys.prototype.updateKeys = function(byteValue) {
1167
- const keys = this.keys;
1168
- keys[0] = crc32update(keys[0], byteValue);
1169
- keys[1] += keys[0] & 255;
1170
- keys[1] = uMul(keys[1], 134775813) + 1;
1171
- keys[2] = crc32update(keys[2], keys[1] >>> 24);
1172
- return byteValue;
1173
- };
1174
- Initkeys.prototype.next = function() {
1175
- const k = (this.keys[2] | 2) >>> 0;
1176
- return uMul(k, k ^ 1) >> 8 & 255;
1177
- };
1178
- function make_decrypter(pwd) {
1179
- const keys = new Initkeys(pwd);
1180
- return function(data) {
1181
- const result = Buffer.alloc(data.length);
1182
- let pos = 0;
1183
- for (let c of data) {
1184
- result[pos++] = keys.updateKeys(c ^ keys.next());
1185
- }
1186
- return result;
1187
- };
1188
- }
1189
- function make_encrypter(pwd) {
1190
- const keys = new Initkeys(pwd);
1191
- return function(data, result, pos = 0) {
1192
- if (!result) result = Buffer.alloc(data.length);
1193
- for (let c of data) {
1194
- const k = keys.next();
1195
- result[pos++] = c ^ k;
1196
- keys.updateKeys(c);
1197
- }
1198
- return result;
1199
- };
1200
- }
1201
- function decrypt(data, header, pwd) {
1202
- if (!data || !Buffer.isBuffer(data) || data.length < 12) {
1203
- return Buffer.alloc(0);
1204
- }
1205
- const decrypter = make_decrypter(pwd);
1206
- const salt = decrypter(data.slice(0, 12));
1207
- const verifyByte = (header.flags & 8) === 8 ? header.timeHighByte : header.crc >>> 24;
1208
- if (salt[11] !== verifyByte) {
1209
- throw Errors.WRONG_PASSWORD();
1210
- }
1211
- return decrypter(data.slice(12));
1212
- }
1213
- function _salter(data) {
1214
- if (Buffer.isBuffer(data) && data.length >= 12) {
1215
- config.genSalt = function() {
1216
- return data.slice(0, 12);
1217
- };
1218
- } else if (data === "node") {
1219
- config.genSalt = genSalt.node;
1220
- } else {
1221
- config.genSalt = genSalt;
1222
- }
1223
- }
1224
- function encrypt(data, header, pwd, oldlike = false) {
1225
- if (data == null) data = Buffer.alloc(0);
1226
- if (!Buffer.isBuffer(data)) data = Buffer.from(data.toString());
1227
- const encrypter = make_encrypter(pwd);
1228
- const salt = config.genSalt();
1229
- salt[11] = header.crc >>> 24 & 255;
1230
- if (oldlike) salt[10] = header.crc >>> 16 & 255;
1231
- const result = Buffer.alloc(data.length + 12);
1232
- encrypter(salt, result);
1233
- return encrypter(data, result, 12);
1234
- }
1235
- module.exports = { decrypt, encrypt, _salter };
1236
- }
1237
- });
1238
-
1239
- // ../../../node_modules/adm-zip/methods/index.js
1240
- var require_methods = __commonJS({
1241
- "../../../node_modules/adm-zip/methods/index.js"(exports$1) {
1242
- exports$1.Deflater = require_deflater();
1243
- exports$1.Inflater = require_inflater();
1244
- exports$1.ZipCrypto = require_zipcrypto();
1245
- }
1246
- });
1247
-
1248
- // ../../../node_modules/adm-zip/zipEntry.js
1249
- var require_zipEntry = __commonJS({
1250
- "../../../node_modules/adm-zip/zipEntry.js"(exports$1, module) {
1251
- var Utils = require_util();
1252
- var Headers = require_headers();
1253
- var Constants = Utils.Constants;
1254
- var Methods = require_methods();
1255
- module.exports = function(options, input) {
1256
- 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;
1257
- const opts = options;
1258
- const decoder = typeof opts.decoder === "object" ? opts.decoder : Utils.decoder;
1259
- _efs = decoder.hasOwnProperty("efs") ? decoder.efs : false;
1260
- function getCompressedDataFromZip() {
1261
- if (!input || !(input instanceof Uint8Array)) {
1262
- return Buffer.alloc(0);
1263
- }
1264
- _extralocal = _centralHeader.loadLocalHeaderFromBinary(input);
1265
- return input.slice(_centralHeader.realDataOffset, _centralHeader.realDataOffset + _centralHeader.compressedSize);
1266
- }
1267
- function crc32OK(data) {
1268
- if (!_centralHeader.flags_desc) {
1269
- if (Utils.crc32(data) !== _centralHeader.localHeader.crc) {
1270
- return false;
1271
- }
1272
- } else {
1273
- const descriptor = {};
1274
- const dataEndOffset = _centralHeader.realDataOffset + _centralHeader.compressedSize;
1275
- if (input.readUInt32LE(dataEndOffset) == Constants.LOCSIG || input.readUInt32LE(dataEndOffset) == Constants.CENSIG) {
1276
- throw Utils.Errors.DESCRIPTOR_NOT_EXIST();
1277
- }
1278
- if (input.readUInt32LE(dataEndOffset) == Constants.EXTSIG) {
1279
- descriptor.crc = input.readUInt32LE(dataEndOffset + Constants.EXTCRC);
1280
- descriptor.compressedSize = input.readUInt32LE(dataEndOffset + Constants.EXTSIZ);
1281
- descriptor.size = input.readUInt32LE(dataEndOffset + Constants.EXTLEN);
1282
- } else if (input.readUInt16LE(dataEndOffset + 12) === 19280) {
1283
- descriptor.crc = input.readUInt32LE(dataEndOffset + Constants.EXTCRC - 4);
1284
- descriptor.compressedSize = input.readUInt32LE(dataEndOffset + Constants.EXTSIZ - 4);
1285
- descriptor.size = input.readUInt32LE(dataEndOffset + Constants.EXTLEN - 4);
1286
- } else {
1287
- throw Utils.Errors.DESCRIPTOR_UNKNOWN();
1288
- }
1289
- if (descriptor.compressedSize !== _centralHeader.compressedSize || descriptor.size !== _centralHeader.size || descriptor.crc !== _centralHeader.crc) {
1290
- throw Utils.Errors.DESCRIPTOR_FAULTY();
1291
- }
1292
- if (Utils.crc32(data) !== descriptor.crc) {
1293
- return false;
1294
- }
1295
- }
1296
- return true;
1297
- }
1298
- function decompress(async, callback, pass) {
1299
- if (typeof callback === "undefined" && typeof async === "string") {
1300
- pass = async;
1301
- async = void 0;
1302
- }
1303
- if (_isDirectory) {
1304
- if (async && callback) {
1305
- callback(Buffer.alloc(0), Utils.Errors.DIRECTORY_CONTENT_ERROR());
1306
- }
1307
- return Buffer.alloc(0);
1308
- }
1309
- var compressedData = getCompressedDataFromZip();
1310
- if (compressedData.length === 0) {
1311
- if (async && callback) callback(compressedData);
1312
- return compressedData;
1313
- }
1314
- if (_centralHeader.encrypted) {
1315
- if ("string" !== typeof pass && !Buffer.isBuffer(pass)) {
1316
- throw Utils.Errors.INVALID_PASS_PARAM();
1317
- }
1318
- compressedData = Methods.ZipCrypto.decrypt(compressedData, _centralHeader, pass);
1319
- }
1320
- var data = Buffer.alloc(_centralHeader.size);
1321
- switch (_centralHeader.method) {
1322
- case Utils.Constants.STORED:
1323
- compressedData.copy(data);
1324
- if (!crc32OK(data)) {
1325
- if (async && callback) callback(data, Utils.Errors.BAD_CRC());
1326
- throw Utils.Errors.BAD_CRC();
1327
- } else {
1328
- if (async && callback) callback(data);
1329
- return data;
1330
- }
1331
- case Utils.Constants.DEFLATED:
1332
- var inflater = new Methods.Inflater(compressedData, _centralHeader.size);
1333
- if (!async) {
1334
- const result = inflater.inflate(data);
1335
- result.copy(data, 0);
1336
- if (!crc32OK(data)) {
1337
- throw Utils.Errors.BAD_CRC(`"${decoder.decode(_entryName)}"`);
1338
- }
1339
- return data;
1340
- } else {
1341
- inflater.inflateAsync(function(result) {
1342
- result.copy(result, 0);
1343
- if (callback) {
1344
- if (!crc32OK(result)) {
1345
- callback(result, Utils.Errors.BAD_CRC());
1346
- } else {
1347
- callback(result);
1348
- }
1349
- }
1350
- });
1351
- }
1352
- break;
1353
- default:
1354
- if (async && callback) callback(Buffer.alloc(0), Utils.Errors.UNKNOWN_METHOD());
1355
- throw Utils.Errors.UNKNOWN_METHOD();
1356
- }
1357
- }
1358
- function compress(async, callback) {
1359
- if ((!uncompressedData || !uncompressedData.length) && Buffer.isBuffer(input)) {
1360
- if (async && callback) callback(getCompressedDataFromZip());
1361
- return getCompressedDataFromZip();
1362
- }
1363
- if (uncompressedData.length && !_isDirectory) {
1364
- var compressedData;
1365
- switch (_centralHeader.method) {
1366
- case Utils.Constants.STORED:
1367
- _centralHeader.compressedSize = _centralHeader.size;
1368
- compressedData = Buffer.alloc(uncompressedData.length);
1369
- uncompressedData.copy(compressedData);
1370
- if (async && callback) callback(compressedData);
1371
- return compressedData;
1372
- default:
1373
- case Utils.Constants.DEFLATED:
1374
- var deflater = new Methods.Deflater(uncompressedData);
1375
- if (!async) {
1376
- var deflated = deflater.deflate();
1377
- _centralHeader.compressedSize = deflated.length;
1378
- return deflated;
1379
- } else {
1380
- deflater.deflateAsync(function(data) {
1381
- compressedData = Buffer.alloc(data.length);
1382
- _centralHeader.compressedSize = data.length;
1383
- data.copy(compressedData);
1384
- callback && callback(compressedData);
1385
- });
1386
- }
1387
- deflater = null;
1388
- break;
1389
- }
1390
- } else if (async && callback) {
1391
- callback(Buffer.alloc(0));
1392
- } else {
1393
- return Buffer.alloc(0);
1394
- }
1395
- }
1396
- function readUInt64LE(buffer, offset) {
1397
- return (buffer.readUInt32LE(offset + 4) << 4) + buffer.readUInt32LE(offset);
1398
- }
1399
- function parseExtra(data) {
1400
- try {
1401
- var offset = 0;
1402
- var signature, size, part;
1403
- while (offset + 4 < data.length) {
1404
- signature = data.readUInt16LE(offset);
1405
- offset += 2;
1406
- size = data.readUInt16LE(offset);
1407
- offset += 2;
1408
- part = data.slice(offset, offset + size);
1409
- offset += size;
1410
- if (Constants.ID_ZIP64 === signature) {
1411
- parseZip64ExtendedInformation(part);
1412
- }
1413
- }
1414
- } catch (error) {
1415
- throw Utils.Errors.EXTRA_FIELD_PARSE_ERROR();
1416
- }
1417
- }
1418
- function parseZip64ExtendedInformation(data) {
1419
- var size, compressedSize, offset, diskNumStart;
1420
- if (data.length >= Constants.EF_ZIP64_SCOMP) {
1421
- size = readUInt64LE(data, Constants.EF_ZIP64_SUNCOMP);
1422
- if (_centralHeader.size === Constants.EF_ZIP64_OR_32) {
1423
- _centralHeader.size = size;
1424
- }
1425
- }
1426
- if (data.length >= Constants.EF_ZIP64_RHO) {
1427
- compressedSize = readUInt64LE(data, Constants.EF_ZIP64_SCOMP);
1428
- if (_centralHeader.compressedSize === Constants.EF_ZIP64_OR_32) {
1429
- _centralHeader.compressedSize = compressedSize;
1430
- }
1431
- }
1432
- if (data.length >= Constants.EF_ZIP64_DSN) {
1433
- offset = readUInt64LE(data, Constants.EF_ZIP64_RHO);
1434
- if (_centralHeader.offset === Constants.EF_ZIP64_OR_32) {
1435
- _centralHeader.offset = offset;
1436
- }
1437
- }
1438
- if (data.length >= Constants.EF_ZIP64_DSN + 4) {
1439
- diskNumStart = data.readUInt32LE(Constants.EF_ZIP64_DSN);
1440
- if (_centralHeader.diskNumStart === Constants.EF_ZIP64_OR_16) {
1441
- _centralHeader.diskNumStart = diskNumStart;
1442
- }
1443
- }
1444
- }
1445
- return {
1446
- get entryName() {
1447
- return decoder.decode(_entryName);
1448
- },
1449
- get rawEntryName() {
1450
- return _entryName;
1451
- },
1452
- set entryName(val) {
1453
- _entryName = Utils.toBuffer(val, decoder.encode);
1454
- var lastChar = _entryName[_entryName.length - 1];
1455
- _isDirectory = lastChar === 47 || lastChar === 92;
1456
- _centralHeader.fileNameLength = _entryName.length;
1457
- },
1458
- get efs() {
1459
- if (typeof _efs === "function") {
1460
- return _efs(this.entryName);
1461
- } else {
1462
- return _efs;
1463
- }
1464
- },
1465
- get extra() {
1466
- return _extra;
1467
- },
1468
- set extra(val) {
1469
- _extra = val;
1470
- _centralHeader.extraLength = val.length;
1471
- parseExtra(val);
1472
- },
1473
- get comment() {
1474
- return decoder.decode(_comment);
1475
- },
1476
- set comment(val) {
1477
- _comment = Utils.toBuffer(val, decoder.encode);
1478
- _centralHeader.commentLength = _comment.length;
1479
- if (_comment.length > 65535) throw Utils.Errors.COMMENT_TOO_LONG();
1480
- },
1481
- get name() {
1482
- var n = decoder.decode(_entryName);
1483
- return _isDirectory ? n.substr(n.length - 1).split("/").pop() : n.split("/").pop();
1484
- },
1485
- get isDirectory() {
1486
- return _isDirectory;
1487
- },
1488
- getCompressedData: function() {
1489
- return compress(false, null);
1490
- },
1491
- getCompressedDataAsync: function(callback) {
1492
- compress(true, callback);
1493
- },
1494
- setData: function(value) {
1495
- uncompressedData = Utils.toBuffer(value, Utils.decoder.encode);
1496
- if (!_isDirectory && uncompressedData.length) {
1497
- _centralHeader.size = uncompressedData.length;
1498
- _centralHeader.method = Utils.Constants.DEFLATED;
1499
- _centralHeader.crc = Utils.crc32(value);
1500
- _centralHeader.changed = true;
1501
- } else {
1502
- _centralHeader.method = Utils.Constants.STORED;
1503
- }
1504
- },
1505
- getData: function(pass) {
1506
- if (_centralHeader.changed) {
1507
- return uncompressedData;
1508
- } else {
1509
- return decompress(false, null, pass);
1510
- }
1511
- },
1512
- getDataAsync: function(callback, pass) {
1513
- if (_centralHeader.changed) {
1514
- callback(uncompressedData);
1515
- } else {
1516
- decompress(true, callback, pass);
1517
- }
1518
- },
1519
- set attr(attr) {
1520
- _centralHeader.attr = attr;
1521
- },
1522
- get attr() {
1523
- return _centralHeader.attr;
1524
- },
1525
- set header(data) {
1526
- _centralHeader.loadFromBinary(data);
1527
- },
1528
- get header() {
1529
- return _centralHeader;
1530
- },
1531
- packCentralHeader: function() {
1532
- _centralHeader.flags_efs = this.efs;
1533
- _centralHeader.extraLength = _extra.length;
1534
- var header = _centralHeader.centralHeaderToBinary();
1535
- var addpos = Utils.Constants.CENHDR;
1536
- _entryName.copy(header, addpos);
1537
- addpos += _entryName.length;
1538
- _extra.copy(header, addpos);
1539
- addpos += _centralHeader.extraLength;
1540
- _comment.copy(header, addpos);
1541
- return header;
1542
- },
1543
- packLocalHeader: function() {
1544
- let addpos = 0;
1545
- _centralHeader.flags_efs = this.efs;
1546
- _centralHeader.extraLocalLength = _extralocal.length;
1547
- const localHeaderBuf = _centralHeader.localHeaderToBinary();
1548
- const localHeader = Buffer.alloc(localHeaderBuf.length + _entryName.length + _centralHeader.extraLocalLength);
1549
- localHeaderBuf.copy(localHeader, addpos);
1550
- addpos += localHeaderBuf.length;
1551
- _entryName.copy(localHeader, addpos);
1552
- addpos += _entryName.length;
1553
- _extralocal.copy(localHeader, addpos);
1554
- addpos += _extralocal.length;
1555
- return localHeader;
1556
- },
1557
- toJSON: function() {
1558
- const bytes = function(nr) {
1559
- return "<" + (nr && nr.length + " bytes buffer" || "null") + ">";
1560
- };
1561
- return {
1562
- entryName: this.entryName,
1563
- name: this.name,
1564
- comment: this.comment,
1565
- isDirectory: this.isDirectory,
1566
- header: _centralHeader.toJSON(),
1567
- compressedData: bytes(input),
1568
- data: bytes(uncompressedData)
1569
- };
1570
- },
1571
- toString: function() {
1572
- return JSON.stringify(this.toJSON(), null, " ");
1573
- }
1574
- };
1575
- };
1576
- }
1577
- });
1578
-
1579
- // ../../../node_modules/adm-zip/zipFile.js
1580
- var require_zipFile = __commonJS({
1581
- "../../../node_modules/adm-zip/zipFile.js"(exports$1, module) {
1582
- var ZipEntry = require_zipEntry();
1583
- var Headers = require_headers();
1584
- var Utils = require_util();
1585
- module.exports = function(inBuffer, options) {
1586
- var entryList = [], entryTable = {}, _comment = Buffer.alloc(0), mainHeader = new Headers.MainHeader(), loadedEntries = false;
1587
- const temporary = /* @__PURE__ */ new Set();
1588
- const opts = options;
1589
- const { noSort, decoder } = opts;
1590
- if (inBuffer) {
1591
- readMainHeader(opts.readEntries);
1592
- } else {
1593
- loadedEntries = true;
1594
- }
1595
- function makeTemporaryFolders() {
1596
- const foldersList = /* @__PURE__ */ new Set();
1597
- for (const elem of Object.keys(entryTable)) {
1598
- const elements = elem.split("/");
1599
- elements.pop();
1600
- if (!elements.length) continue;
1601
- for (let i = 0; i < elements.length; i++) {
1602
- const sub = elements.slice(0, i + 1).join("/") + "/";
1603
- foldersList.add(sub);
1604
- }
1605
- }
1606
- for (const elem of foldersList) {
1607
- if (!(elem in entryTable)) {
1608
- const tempfolder = new ZipEntry(opts);
1609
- tempfolder.entryName = elem;
1610
- tempfolder.attr = 16;
1611
- tempfolder.temporary = true;
1612
- entryList.push(tempfolder);
1613
- entryTable[tempfolder.entryName] = tempfolder;
1614
- temporary.add(tempfolder);
1615
- }
1616
- }
1617
- }
1618
- function readEntries() {
1619
- loadedEntries = true;
1620
- entryTable = {};
1621
- if (mainHeader.diskEntries > (inBuffer.length - mainHeader.offset) / Utils.Constants.CENHDR) {
1622
- throw Utils.Errors.DISK_ENTRY_TOO_LARGE();
1623
- }
1624
- entryList = new Array(mainHeader.diskEntries);
1625
- var index = mainHeader.offset;
1626
- for (var i = 0; i < entryList.length; i++) {
1627
- var tmp = index, entry = new ZipEntry(opts, inBuffer);
1628
- entry.header = inBuffer.slice(tmp, tmp += Utils.Constants.CENHDR);
1629
- entry.entryName = inBuffer.slice(tmp, tmp += entry.header.fileNameLength);
1630
- if (entry.header.extraLength) {
1631
- entry.extra = inBuffer.slice(tmp, tmp += entry.header.extraLength);
1632
- }
1633
- if (entry.header.commentLength) entry.comment = inBuffer.slice(tmp, tmp + entry.header.commentLength);
1634
- index += entry.header.centralHeaderSize;
1635
- entryList[i] = entry;
1636
- entryTable[entry.entryName] = entry;
1637
- }
1638
- temporary.clear();
1639
- makeTemporaryFolders();
1640
- }
1641
- function readMainHeader(readNow) {
1642
- var i = inBuffer.length - Utils.Constants.ENDHDR, max = Math.max(0, i - 65535), n = max, endStart = inBuffer.length, endOffset = -1, commentEnd = 0;
1643
- const trailingSpace = typeof opts.trailingSpace === "boolean" ? opts.trailingSpace : false;
1644
- if (trailingSpace) max = 0;
1645
- for (i; i >= n; i--) {
1646
- if (inBuffer[i] !== 80) continue;
1647
- if (inBuffer.readUInt32LE(i) === Utils.Constants.ENDSIG) {
1648
- endOffset = i;
1649
- commentEnd = i;
1650
- endStart = i + Utils.Constants.ENDHDR;
1651
- n = i - Utils.Constants.END64HDR;
1652
- continue;
1653
- }
1654
- if (inBuffer.readUInt32LE(i) === Utils.Constants.END64SIG) {
1655
- n = max;
1656
- continue;
1657
- }
1658
- if (inBuffer.readUInt32LE(i) === Utils.Constants.ZIP64SIG) {
1659
- endOffset = i;
1660
- endStart = i + Utils.readBigUInt64LE(inBuffer, i + Utils.Constants.ZIP64SIZE) + Utils.Constants.ZIP64LEAD;
1661
- break;
1662
- }
1663
- }
1664
- if (endOffset == -1) throw Utils.Errors.INVALID_FORMAT();
1665
- mainHeader.loadFromBinary(inBuffer.slice(endOffset, endStart));
1666
- if (mainHeader.commentLength) {
1667
- _comment = inBuffer.slice(commentEnd + Utils.Constants.ENDHDR);
1668
- }
1669
- if (readNow) readEntries();
1670
- }
1671
- function sortEntries() {
1672
- if (entryList.length > 1 && !noSort) {
1673
- entryList.sort((a, b) => a.entryName.toLowerCase().localeCompare(b.entryName.toLowerCase()));
1674
- }
1675
- }
1676
- return {
1677
- /**
1678
- * Returns an array of ZipEntry objects existent in the current opened archive
1679
- * @return Array
1680
- */
1681
- get entries() {
1682
- if (!loadedEntries) {
1683
- readEntries();
1684
- }
1685
- return entryList.filter((e) => !temporary.has(e));
1686
- },
1687
- /**
1688
- * Archive comment
1689
- * @return {String}
1690
- */
1691
- get comment() {
1692
- return decoder.decode(_comment);
1693
- },
1694
- set comment(val) {
1695
- _comment = Utils.toBuffer(val, decoder.encode);
1696
- mainHeader.commentLength = _comment.length;
1697
- },
1698
- getEntryCount: function() {
1699
- if (!loadedEntries) {
1700
- return mainHeader.diskEntries;
1701
- }
1702
- return entryList.length;
1703
- },
1704
- forEach: function(callback) {
1705
- this.entries.forEach(callback);
1706
- },
1707
- /**
1708
- * Returns a reference to the entry with the given name or null if entry is inexistent
1709
- *
1710
- * @param entryName
1711
- * @return ZipEntry
1712
- */
1713
- getEntry: function(entryName) {
1714
- if (!loadedEntries) {
1715
- readEntries();
1716
- }
1717
- return entryTable[entryName] || null;
1718
- },
1719
- /**
1720
- * Adds the given entry to the entry list
1721
- *
1722
- * @param entry
1723
- */
1724
- setEntry: function(entry) {
1725
- if (!loadedEntries) {
1726
- readEntries();
1727
- }
1728
- entryList.push(entry);
1729
- entryTable[entry.entryName] = entry;
1730
- mainHeader.totalEntries = entryList.length;
1731
- },
1732
- /**
1733
- * Removes the file with the given name from the entry list.
1734
- *
1735
- * If the entry is a directory, then all nested files and directories will be removed
1736
- * @param entryName
1737
- * @returns {void}
1738
- */
1739
- deleteFile: function(entryName, withsubfolders = true) {
1740
- if (!loadedEntries) {
1741
- readEntries();
1742
- }
1743
- const entry = entryTable[entryName];
1744
- const list = this.getEntryChildren(entry, withsubfolders).map((child) => child.entryName);
1745
- list.forEach(this.deleteEntry);
1746
- },
1747
- /**
1748
- * Removes the entry with the given name from the entry list.
1749
- *
1750
- * @param {string} entryName
1751
- * @returns {void}
1752
- */
1753
- deleteEntry: function(entryName) {
1754
- if (!loadedEntries) {
1755
- readEntries();
1756
- }
1757
- const entry = entryTable[entryName];
1758
- const index = entryList.indexOf(entry);
1759
- if (index >= 0) {
1760
- entryList.splice(index, 1);
1761
- delete entryTable[entryName];
1762
- mainHeader.totalEntries = entryList.length;
1763
- }
1764
- },
1765
- /**
1766
- * Iterates and returns all nested files and directories of the given entry
1767
- *
1768
- * @param entry
1769
- * @return Array
1770
- */
1771
- getEntryChildren: function(entry, subfolders = true) {
1772
- if (!loadedEntries) {
1773
- readEntries();
1774
- }
1775
- if (typeof entry === "object") {
1776
- if (entry.isDirectory && subfolders) {
1777
- const list = [];
1778
- const name = entry.entryName;
1779
- for (const zipEntry of entryList) {
1780
- if (zipEntry.entryName.startsWith(name)) {
1781
- list.push(zipEntry);
1782
- }
1783
- }
1784
- return list;
1785
- } else {
1786
- return [entry];
1787
- }
1788
- }
1789
- return [];
1790
- },
1791
- /**
1792
- * How many child elements entry has
1793
- *
1794
- * @param {ZipEntry} entry
1795
- * @return {integer}
1796
- */
1797
- getChildCount: function(entry) {
1798
- if (entry && entry.isDirectory) {
1799
- const list = this.getEntryChildren(entry);
1800
- return list.includes(entry) ? list.length - 1 : list.length;
1801
- }
1802
- return 0;
1803
- },
1804
- /**
1805
- * Returns the zip file
1806
- *
1807
- * @return Buffer
1808
- */
1809
- compressToBuffer: function() {
1810
- if (!loadedEntries) {
1811
- readEntries();
1812
- }
1813
- sortEntries();
1814
- const dataBlock = [];
1815
- const headerBlocks = [];
1816
- let totalSize = 0;
1817
- let dindex = 0;
1818
- mainHeader.size = 0;
1819
- mainHeader.offset = 0;
1820
- let totalEntries = 0;
1821
- for (const entry of this.entries) {
1822
- const compressedData = entry.getCompressedData();
1823
- entry.header.offset = dindex;
1824
- const localHeader = entry.packLocalHeader();
1825
- const dataLength = localHeader.length + compressedData.length;
1826
- dindex += dataLength;
1827
- dataBlock.push(localHeader);
1828
- dataBlock.push(compressedData);
1829
- const centralHeader = entry.packCentralHeader();
1830
- headerBlocks.push(centralHeader);
1831
- mainHeader.size += centralHeader.length;
1832
- totalSize += dataLength + centralHeader.length;
1833
- totalEntries++;
1834
- }
1835
- totalSize += mainHeader.mainHeaderSize;
1836
- mainHeader.offset = dindex;
1837
- mainHeader.totalEntries = totalEntries;
1838
- dindex = 0;
1839
- const outBuffer = Buffer.alloc(totalSize);
1840
- for (const content of dataBlock) {
1841
- content.copy(outBuffer, dindex);
1842
- dindex += content.length;
1843
- }
1844
- for (const content of headerBlocks) {
1845
- content.copy(outBuffer, dindex);
1846
- dindex += content.length;
1847
- }
1848
- const mh = mainHeader.toBinary();
1849
- if (_comment) {
1850
- _comment.copy(mh, Utils.Constants.ENDHDR);
1851
- }
1852
- mh.copy(outBuffer, dindex);
1853
- inBuffer = outBuffer;
1854
- loadedEntries = false;
1855
- return outBuffer;
1856
- },
1857
- toAsyncBuffer: function(onSuccess, onFail, onItemStart, onItemEnd) {
1858
- try {
1859
- if (!loadedEntries) {
1860
- readEntries();
1861
- }
1862
- sortEntries();
1863
- const dataBlock = [];
1864
- const centralHeaders = [];
1865
- let totalSize = 0;
1866
- let dindex = 0;
1867
- let totalEntries = 0;
1868
- mainHeader.size = 0;
1869
- mainHeader.offset = 0;
1870
- const compress2Buffer = function(entryLists) {
1871
- if (entryLists.length > 0) {
1872
- const entry = entryLists.shift();
1873
- const name = entry.entryName + entry.extra.toString();
1874
- if (onItemStart) onItemStart(name);
1875
- entry.getCompressedDataAsync(function(compressedData) {
1876
- if (onItemEnd) onItemEnd(name);
1877
- entry.header.offset = dindex;
1878
- const localHeader = entry.packLocalHeader();
1879
- const dataLength = localHeader.length + compressedData.length;
1880
- dindex += dataLength;
1881
- dataBlock.push(localHeader);
1882
- dataBlock.push(compressedData);
1883
- const centalHeader = entry.packCentralHeader();
1884
- centralHeaders.push(centalHeader);
1885
- mainHeader.size += centalHeader.length;
1886
- totalSize += dataLength + centalHeader.length;
1887
- totalEntries++;
1888
- compress2Buffer(entryLists);
1889
- });
1890
- } else {
1891
- totalSize += mainHeader.mainHeaderSize;
1892
- mainHeader.offset = dindex;
1893
- mainHeader.totalEntries = totalEntries;
1894
- dindex = 0;
1895
- const outBuffer = Buffer.alloc(totalSize);
1896
- dataBlock.forEach(function(content) {
1897
- content.copy(outBuffer, dindex);
1898
- dindex += content.length;
1899
- });
1900
- centralHeaders.forEach(function(content) {
1901
- content.copy(outBuffer, dindex);
1902
- dindex += content.length;
1903
- });
1904
- const mh = mainHeader.toBinary();
1905
- if (_comment) {
1906
- _comment.copy(mh, Utils.Constants.ENDHDR);
1907
- }
1908
- mh.copy(outBuffer, dindex);
1909
- inBuffer = outBuffer;
1910
- loadedEntries = false;
1911
- onSuccess(outBuffer);
1912
- }
1913
- };
1914
- compress2Buffer(Array.from(this.entries));
1915
- } catch (e) {
1916
- onFail(e);
1917
- }
1918
- }
1919
- };
1920
- };
1921
- }
1922
- });
1923
-
1924
- // ../../../node_modules/adm-zip/adm-zip.js
1925
- var require_adm_zip = __commonJS({
1926
- "../../../node_modules/adm-zip/adm-zip.js"(exports$1, module) {
1927
- var Utils = require_util();
1928
- var pth = __require("path");
1929
- var ZipEntry = require_zipEntry();
1930
- var ZipFile = require_zipFile();
1931
- var get_Bool = (...val) => Utils.findLast(val, (c) => typeof c === "boolean");
1932
- var get_Str = (...val) => Utils.findLast(val, (c) => typeof c === "string");
1933
- var get_Fun = (...val) => Utils.findLast(val, (c) => typeof c === "function");
1934
- var defaultOptions = {
1935
- // option "noSort" : if true it disables files sorting
1936
- noSort: false,
1937
- // read entries during load (initial loading may be slower)
1938
- readEntries: false,
1939
- // default method is none
1940
- method: Utils.Constants.NONE,
1941
- // file system
1942
- fs: null
1943
- };
1944
- module.exports = function(input, options) {
1945
- let inBuffer = null;
1946
- const opts = Object.assign(/* @__PURE__ */ Object.create(null), defaultOptions);
1947
- if (input && "object" === typeof input) {
1948
- if (!(input instanceof Uint8Array)) {
1949
- Object.assign(opts, input);
1950
- input = opts.input ? opts.input : void 0;
1951
- if (opts.input) delete opts.input;
1952
- }
1953
- if (Buffer.isBuffer(input)) {
1954
- inBuffer = input;
1955
- opts.method = Utils.Constants.BUFFER;
1956
- input = void 0;
1957
- }
1958
- }
1959
- Object.assign(opts, options);
1960
- const filetools = new Utils(opts);
1961
- if (typeof opts.decoder !== "object" || typeof opts.decoder.encode !== "function" || typeof opts.decoder.decode !== "function") {
1962
- opts.decoder = Utils.decoder;
1963
- }
1964
- if (input && "string" === typeof input) {
1965
- if (filetools.fs.existsSync(input)) {
1966
- opts.method = Utils.Constants.FILE;
1967
- opts.filename = input;
1968
- inBuffer = filetools.fs.readFileSync(input);
1969
- } else {
1970
- throw Utils.Errors.INVALID_FILENAME();
1971
- }
1972
- }
1973
- const _zip = new ZipFile(inBuffer, opts);
1974
- const { canonical, sanitize, zipnamefix } = Utils;
1975
- function getEntry(entry) {
1976
- if (entry && _zip) {
1977
- var item;
1978
- if (typeof entry === "string") item = _zip.getEntry(pth.posix.normalize(entry));
1979
- if (typeof entry === "object" && typeof entry.entryName !== "undefined" && typeof entry.header !== "undefined") item = _zip.getEntry(entry.entryName);
1980
- if (item) {
1981
- return item;
1982
- }
1983
- }
1984
- return null;
1985
- }
1986
- function fixPath(zipPath) {
1987
- const { join: join2, normalize, sep } = pth.posix;
1988
- return join2(".", normalize(sep + zipPath.split("\\").join(sep) + sep));
1989
- }
1990
- function filenameFilter(filterfn) {
1991
- if (filterfn instanceof RegExp) {
1992
- return /* @__PURE__ */ (function(rx) {
1993
- return function(filename) {
1994
- return rx.test(filename);
1995
- };
1996
- })(filterfn);
1997
- } else if ("function" !== typeof filterfn) {
1998
- return () => true;
1999
- }
2000
- return filterfn;
2001
- }
2002
- const relativePath = (local, entry) => {
2003
- let lastChar = entry.slice(-1);
2004
- lastChar = lastChar === filetools.sep ? filetools.sep : "";
2005
- return pth.relative(local, entry) + lastChar;
2006
- };
2007
- return {
2008
- /**
2009
- * Extracts the given entry from the archive and returns the content as a Buffer object
2010
- * @param {ZipEntry|string} entry ZipEntry object or String with the full path of the entry
2011
- * @param {Buffer|string} [pass] - password
2012
- * @return Buffer or Null in case of error
2013
- */
2014
- readFile: function(entry, pass) {
2015
- var item = getEntry(entry);
2016
- return item && item.getData(pass) || null;
2017
- },
2018
- /**
2019
- * Returns how many child elements has on entry (directories) on files it is always 0
2020
- * @param {ZipEntry|string} entry ZipEntry object or String with the full path of the entry
2021
- * @returns {integer}
2022
- */
2023
- childCount: function(entry) {
2024
- const item = getEntry(entry);
2025
- if (item) {
2026
- return _zip.getChildCount(item);
2027
- }
2028
- },
2029
- /**
2030
- * Asynchronous readFile
2031
- * @param {ZipEntry|string} entry ZipEntry object or String with the full path of the entry
2032
- * @param {callback} callback
2033
- *
2034
- * @return Buffer or Null in case of error
2035
- */
2036
- readFileAsync: function(entry, callback) {
2037
- var item = getEntry(entry);
2038
- if (item) {
2039
- item.getDataAsync(callback);
2040
- } else {
2041
- callback(null, "getEntry failed for:" + entry);
2042
- }
2043
- },
2044
- /**
2045
- * Extracts the given entry from the archive and returns the content as plain text in the given encoding
2046
- * @param {ZipEntry|string} entry - ZipEntry object or String with the full path of the entry
2047
- * @param {string} encoding - Optional. If no encoding is specified utf8 is used
2048
- *
2049
- * @return String
2050
- */
2051
- readAsText: function(entry, encoding) {
2052
- var item = getEntry(entry);
2053
- if (item) {
2054
- var data = item.getData();
2055
- if (data && data.length) {
2056
- return data.toString(encoding || "utf8");
2057
- }
2058
- }
2059
- return "";
2060
- },
2061
- /**
2062
- * Asynchronous readAsText
2063
- * @param {ZipEntry|string} entry ZipEntry object or String with the full path of the entry
2064
- * @param {callback} callback
2065
- * @param {string} [encoding] - Optional. If no encoding is specified utf8 is used
2066
- *
2067
- * @return String
2068
- */
2069
- readAsTextAsync: function(entry, callback, encoding) {
2070
- var item = getEntry(entry);
2071
- if (item) {
2072
- item.getDataAsync(function(data, err) {
2073
- if (err) {
2074
- callback(data, err);
2075
- return;
2076
- }
2077
- if (data && data.length) {
2078
- callback(data.toString(encoding || "utf8"));
2079
- } else {
2080
- callback("");
2081
- }
2082
- });
2083
- } else {
2084
- callback("");
2085
- }
2086
- },
2087
- /**
2088
- * Remove the entry from the file or the entry and all it's nested directories and files if the given entry is a directory
2089
- *
2090
- * @param {ZipEntry|string} entry
2091
- * @returns {void}
2092
- */
2093
- deleteFile: function(entry, withsubfolders = true) {
2094
- var item = getEntry(entry);
2095
- if (item) {
2096
- _zip.deleteFile(item.entryName, withsubfolders);
2097
- }
2098
- },
2099
- /**
2100
- * Remove the entry from the file or directory without affecting any nested entries
2101
- *
2102
- * @param {ZipEntry|string} entry
2103
- * @returns {void}
2104
- */
2105
- deleteEntry: function(entry) {
2106
- var item = getEntry(entry);
2107
- if (item) {
2108
- _zip.deleteEntry(item.entryName);
2109
- }
2110
- },
2111
- /**
2112
- * Adds a comment to the zip. The zip must be rewritten after adding the comment.
2113
- *
2114
- * @param {string} comment
2115
- */
2116
- addZipComment: function(comment) {
2117
- _zip.comment = comment;
2118
- },
2119
- /**
2120
- * Returns the zip comment
2121
- *
2122
- * @return String
2123
- */
2124
- getZipComment: function() {
2125
- return _zip.comment || "";
2126
- },
2127
- /**
2128
- * Adds a comment to a specified zipEntry. The zip must be rewritten after adding the comment
2129
- * The comment cannot exceed 65535 characters in length
2130
- *
2131
- * @param {ZipEntry} entry
2132
- * @param {string} comment
2133
- */
2134
- addZipEntryComment: function(entry, comment) {
2135
- var item = getEntry(entry);
2136
- if (item) {
2137
- item.comment = comment;
2138
- }
2139
- },
2140
- /**
2141
- * Returns the comment of the specified entry
2142
- *
2143
- * @param {ZipEntry} entry
2144
- * @return String
2145
- */
2146
- getZipEntryComment: function(entry) {
2147
- var item = getEntry(entry);
2148
- if (item) {
2149
- return item.comment || "";
2150
- }
2151
- return "";
2152
- },
2153
- /**
2154
- * Updates the content of an existing entry inside the archive. The zip must be rewritten after updating the content
2155
- *
2156
- * @param {ZipEntry} entry
2157
- * @param {Buffer} content
2158
- */
2159
- updateFile: function(entry, content) {
2160
- var item = getEntry(entry);
2161
- if (item) {
2162
- item.setData(content);
2163
- }
2164
- },
2165
- /**
2166
- * Adds a file from the disk to the archive
2167
- *
2168
- * @param {string} localPath File to add to zip
2169
- * @param {string} [zipPath] Optional path inside the zip
2170
- * @param {string} [zipName] Optional name for the file
2171
- * @param {string} [comment] Optional file comment
2172
- */
2173
- addLocalFile: function(localPath2, zipPath, zipName, comment) {
2174
- if (filetools.fs.existsSync(localPath2)) {
2175
- zipPath = zipPath ? fixPath(zipPath) : "";
2176
- const p = pth.win32.basename(pth.win32.normalize(localPath2));
2177
- zipPath += zipName ? zipName : p;
2178
- const _attr = filetools.fs.statSync(localPath2);
2179
- const data = _attr.isFile() ? filetools.fs.readFileSync(localPath2) : Buffer.alloc(0);
2180
- if (_attr.isDirectory()) zipPath += filetools.sep;
2181
- this.addFile(zipPath, data, comment, _attr);
2182
- } else {
2183
- throw Utils.Errors.FILE_NOT_FOUND(localPath2);
2184
- }
2185
- },
2186
- /**
2187
- * Callback for showing if everything was done.
2188
- *
2189
- * @callback doneCallback
2190
- * @param {Error} err - Error object
2191
- * @param {boolean} done - was request fully completed
2192
- */
2193
- /**
2194
- * Adds a file from the disk to the archive
2195
- *
2196
- * @param {(object|string)} options - options object, if it is string it us used as localPath.
2197
- * @param {string} options.localPath - Local path to the file.
2198
- * @param {string} [options.comment] - Optional file comment.
2199
- * @param {string} [options.zipPath] - Optional path inside the zip
2200
- * @param {string} [options.zipName] - Optional name for the file
2201
- * @param {doneCallback} callback - The callback that handles the response.
2202
- */
2203
- addLocalFileAsync: function(options2, callback) {
2204
- options2 = typeof options2 === "object" ? options2 : { localPath: options2 };
2205
- const localPath2 = pth.resolve(options2.localPath);
2206
- const { comment } = options2;
2207
- let { zipPath, zipName } = options2;
2208
- const self = this;
2209
- filetools.fs.stat(localPath2, function(err, stats) {
2210
- if (err) return callback(err, false);
2211
- zipPath = zipPath ? fixPath(zipPath) : "";
2212
- const p = pth.win32.basename(pth.win32.normalize(localPath2));
2213
- zipPath += zipName ? zipName : p;
2214
- if (stats.isFile()) {
2215
- filetools.fs.readFile(localPath2, function(err2, data) {
2216
- if (err2) return callback(err2, false);
2217
- self.addFile(zipPath, data, comment, stats);
2218
- return setImmediate(callback, void 0, true);
2219
- });
2220
- } else if (stats.isDirectory()) {
2221
- zipPath += filetools.sep;
2222
- self.addFile(zipPath, Buffer.alloc(0), comment, stats);
2223
- return setImmediate(callback, void 0, true);
2224
- }
2225
- });
2226
- },
2227
- /**
2228
- * Adds a local directory and all its nested files and directories to the archive
2229
- *
2230
- * @param {string} localPath - local path to the folder
2231
- * @param {string} [zipPath] - optional path inside zip
2232
- * @param {(RegExp|function)} [filter] - optional RegExp or Function if files match will be included.
2233
- */
2234
- addLocalFolder: function(localPath2, zipPath, filter) {
2235
- filter = filenameFilter(filter);
2236
- zipPath = zipPath ? fixPath(zipPath) : "";
2237
- localPath2 = pth.normalize(localPath2);
2238
- if (filetools.fs.existsSync(localPath2)) {
2239
- const items = filetools.findFiles(localPath2);
2240
- const self = this;
2241
- if (items.length) {
2242
- for (const filepath of items) {
2243
- const p = pth.join(zipPath, relativePath(localPath2, filepath));
2244
- if (filter(p)) {
2245
- self.addLocalFile(filepath, pth.dirname(p));
2246
- }
2247
- }
2248
- }
2249
- } else {
2250
- throw Utils.Errors.FILE_NOT_FOUND(localPath2);
2251
- }
2252
- },
2253
- /**
2254
- * Asynchronous addLocalFolder
2255
- * @param {string} localPath
2256
- * @param {callback} callback
2257
- * @param {string} [zipPath] optional path inside zip
2258
- * @param {RegExp|function} [filter] optional RegExp or Function if files match will
2259
- * be included.
2260
- */
2261
- addLocalFolderAsync: function(localPath2, callback, zipPath, filter) {
2262
- filter = filenameFilter(filter);
2263
- zipPath = zipPath ? fixPath(zipPath) : "";
2264
- localPath2 = pth.normalize(localPath2);
2265
- var self = this;
2266
- filetools.fs.open(localPath2, "r", function(err) {
2267
- if (err && err.code === "ENOENT") {
2268
- callback(void 0, Utils.Errors.FILE_NOT_FOUND(localPath2));
2269
- } else if (err) {
2270
- callback(void 0, err);
2271
- } else {
2272
- var items = filetools.findFiles(localPath2);
2273
- var i = -1;
2274
- var next = function() {
2275
- i += 1;
2276
- if (i < items.length) {
2277
- var filepath = items[i];
2278
- var p = relativePath(localPath2, filepath).split("\\").join("/");
2279
- p = p.normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^\x20-\x7E]/g, "");
2280
- if (filter(p)) {
2281
- filetools.fs.stat(filepath, function(er0, stats) {
2282
- if (er0) callback(void 0, er0);
2283
- if (stats.isFile()) {
2284
- filetools.fs.readFile(filepath, function(er1, data) {
2285
- if (er1) {
2286
- callback(void 0, er1);
2287
- } else {
2288
- self.addFile(zipPath + p, data, "", stats);
2289
- next();
2290
- }
2291
- });
2292
- } else {
2293
- self.addFile(zipPath + p + "/", Buffer.alloc(0), "", stats);
2294
- next();
2295
- }
2296
- });
2297
- } else {
2298
- process.nextTick(() => {
2299
- next();
2300
- });
2301
- }
2302
- } else {
2303
- callback(true, void 0);
2304
- }
2305
- };
2306
- next();
2307
- }
2308
- });
2309
- },
2310
- /**
2311
- * Adds a local directory and all its nested files and directories to the archive
2312
- *
2313
- * @param {object | string} options - options object, if it is string it us used as localPath.
2314
- * @param {string} options.localPath - Local path to the folder.
2315
- * @param {string} [options.zipPath] - optional path inside zip.
2316
- * @param {RegExp|function} [options.filter] - optional RegExp or Function if files match will be included.
2317
- * @param {function|string} [options.namefix] - optional function to help fix filename
2318
- * @param {doneCallback} callback - The callback that handles the response.
2319
- *
2320
- */
2321
- addLocalFolderAsync2: function(options2, callback) {
2322
- const self = this;
2323
- options2 = typeof options2 === "object" ? options2 : { localPath: options2 };
2324
- localPath = pth.resolve(fixPath(options2.localPath));
2325
- let { zipPath, filter, namefix } = options2;
2326
- if (filter instanceof RegExp) {
2327
- filter = /* @__PURE__ */ (function(rx) {
2328
- return function(filename) {
2329
- return rx.test(filename);
2330
- };
2331
- })(filter);
2332
- } else if ("function" !== typeof filter) {
2333
- filter = function() {
2334
- return true;
2335
- };
2336
- }
2337
- zipPath = zipPath ? fixPath(zipPath) : "";
2338
- if (namefix == "latin1") {
2339
- namefix = (str) => str.normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^\x20-\x7E]/g, "");
2340
- }
2341
- if (typeof namefix !== "function") namefix = (str) => str;
2342
- const relPathFix = (entry) => pth.join(zipPath, namefix(relativePath(localPath, entry)));
2343
- const fileNameFix = (entry) => pth.win32.basename(pth.win32.normalize(namefix(entry)));
2344
- filetools.fs.open(localPath, "r", function(err) {
2345
- if (err && err.code === "ENOENT") {
2346
- callback(void 0, Utils.Errors.FILE_NOT_FOUND(localPath));
2347
- } else if (err) {
2348
- callback(void 0, err);
2349
- } else {
2350
- filetools.findFilesAsync(localPath, function(err2, fileEntries) {
2351
- if (err2) return callback(err2);
2352
- fileEntries = fileEntries.filter((dir) => filter(relPathFix(dir)));
2353
- if (!fileEntries.length) callback(void 0, false);
2354
- setImmediate(
2355
- fileEntries.reverse().reduce(function(next, entry) {
2356
- return function(err3, done) {
2357
- if (err3 || done === false) return setImmediate(next, err3, false);
2358
- self.addLocalFileAsync(
2359
- {
2360
- localPath: entry,
2361
- zipPath: pth.dirname(relPathFix(entry)),
2362
- zipName: fileNameFix(entry)
2363
- },
2364
- next
2365
- );
2366
- };
2367
- }, callback)
2368
- );
2369
- });
2370
- }
2371
- });
2372
- },
2373
- /**
2374
- * Adds a local directory and all its nested files and directories to the archive
2375
- *
2376
- * @param {string} localPath - path where files will be extracted
2377
- * @param {object} props - optional properties
2378
- * @param {string} [props.zipPath] - optional path inside zip
2379
- * @param {RegExp|function} [props.filter] - optional RegExp or Function if files match will be included.
2380
- * @param {function|string} [props.namefix] - optional function to help fix filename
2381
- */
2382
- addLocalFolderPromise: function(localPath2, props) {
2383
- return new Promise((resolve, reject) => {
2384
- this.addLocalFolderAsync2(Object.assign({ localPath: localPath2 }, props), (err, done) => {
2385
- if (err) reject(err);
2386
- if (done) resolve(this);
2387
- });
2388
- });
2389
- },
2390
- /**
2391
- * Allows you to create a entry (file or directory) in the zip file.
2392
- * If you want to create a directory the entryName must end in / and a null buffer should be provided.
2393
- * Comment and attributes are optional
2394
- *
2395
- * @param {string} entryName
2396
- * @param {Buffer | string} content - file content as buffer or utf8 coded string
2397
- * @param {string} [comment] - file comment
2398
- * @param {number | object} [attr] - number as unix file permissions, object as filesystem Stats object
2399
- */
2400
- addFile: function(entryName, content, comment, attr) {
2401
- entryName = zipnamefix(entryName);
2402
- let entry = getEntry(entryName);
2403
- const update = entry != null;
2404
- if (!update) {
2405
- entry = new ZipEntry(opts);
2406
- entry.entryName = entryName;
2407
- }
2408
- entry.comment = comment || "";
2409
- const isStat = "object" === typeof attr && attr instanceof filetools.fs.Stats;
2410
- if (isStat) {
2411
- entry.header.time = attr.mtime;
2412
- }
2413
- var fileattr = entry.isDirectory ? 16 : 0;
2414
- let unix = entry.isDirectory ? 16384 : 32768;
2415
- if (isStat) {
2416
- unix |= 4095 & attr.mode;
2417
- } else if ("number" === typeof attr) {
2418
- unix |= 4095 & attr;
2419
- } else {
2420
- unix |= entry.isDirectory ? 493 : 420;
2421
- }
2422
- fileattr = (fileattr | unix << 16) >>> 0;
2423
- entry.attr = fileattr;
2424
- entry.setData(content);
2425
- if (!update) _zip.setEntry(entry);
2426
- return entry;
2427
- },
2428
- /**
2429
- * Returns an array of ZipEntry objects representing the files and folders inside the archive
2430
- *
2431
- * @param {string} [password]
2432
- * @returns Array
2433
- */
2434
- getEntries: function(password) {
2435
- _zip.password = password;
2436
- return _zip ? _zip.entries : [];
2437
- },
2438
- /**
2439
- * Returns a ZipEntry object representing the file or folder specified by ``name``.
2440
- *
2441
- * @param {string} name
2442
- * @return ZipEntry
2443
- */
2444
- getEntry: function(name) {
2445
- return getEntry(name);
2446
- },
2447
- getEntryCount: function() {
2448
- return _zip.getEntryCount();
2449
- },
2450
- forEach: function(callback) {
2451
- return _zip.forEach(callback);
2452
- },
2453
- /**
2454
- * Extracts the given entry to the given targetPath
2455
- * If the entry is a directory inside the archive, the entire directory and it's subdirectories will be extracted
2456
- *
2457
- * @param {string|ZipEntry} entry - ZipEntry object or String with the full path of the entry
2458
- * @param {string} targetPath - Target folder where to write the file
2459
- * @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
2460
- * @param {boolean} [overwrite=false] - If the file already exists at the target path, the file will be overwriten if this is true.
2461
- * @param {boolean} [keepOriginalPermission=false] - The file will be set as the permission from the entry if this is true.
2462
- * @param {string} [outFileName] - String If set will override the filename of the extracted file (Only works if the entry is a file)
2463
- *
2464
- * @return Boolean
2465
- */
2466
- extractEntryTo: function(entry, targetPath, maintainEntryPath, overwrite, keepOriginalPermission, outFileName) {
2467
- overwrite = get_Bool(false, overwrite);
2468
- keepOriginalPermission = get_Bool(false, keepOriginalPermission);
2469
- maintainEntryPath = get_Bool(true, maintainEntryPath);
2470
- outFileName = get_Str(keepOriginalPermission, outFileName);
2471
- var item = getEntry(entry);
2472
- if (!item) {
2473
- throw Utils.Errors.NO_ENTRY();
2474
- }
2475
- var entryName = canonical(item.entryName);
2476
- var target = sanitize(targetPath, outFileName && !item.isDirectory ? outFileName : maintainEntryPath ? entryName : pth.basename(entryName));
2477
- if (item.isDirectory) {
2478
- var children = _zip.getEntryChildren(item);
2479
- children.forEach(function(child) {
2480
- if (child.isDirectory) return;
2481
- var content2 = child.getData();
2482
- if (!content2) {
2483
- throw Utils.Errors.CANT_EXTRACT_FILE();
2484
- }
2485
- var name = canonical(child.entryName);
2486
- var childName = sanitize(targetPath, maintainEntryPath ? name : pth.basename(name));
2487
- const fileAttr2 = keepOriginalPermission ? child.header.fileAttr : void 0;
2488
- filetools.writeFileTo(childName, content2, overwrite, fileAttr2);
2489
- });
2490
- return true;
2491
- }
2492
- var content = item.getData(_zip.password);
2493
- if (!content) throw Utils.Errors.CANT_EXTRACT_FILE();
2494
- if (filetools.fs.existsSync(target) && !overwrite) {
2495
- throw Utils.Errors.CANT_OVERRIDE();
2496
- }
2497
- const fileAttr = keepOriginalPermission ? entry.header.fileAttr : void 0;
2498
- filetools.writeFileTo(target, content, overwrite, fileAttr);
2499
- return true;
2500
- },
2501
- /**
2502
- * Test the archive
2503
- * @param {string} [pass]
2504
- */
2505
- test: function(pass) {
2506
- if (!_zip) {
2507
- return false;
2508
- }
2509
- for (var entry in _zip.entries) {
2510
- try {
2511
- if (entry.isDirectory) {
2512
- continue;
2513
- }
2514
- var content = _zip.entries[entry].getData(pass);
2515
- if (!content) {
2516
- return false;
2517
- }
2518
- } catch (err) {
2519
- return false;
2520
- }
2521
- }
2522
- return true;
2523
- },
2524
- /**
2525
- * Extracts the entire archive to the given location
2526
- *
2527
- * @param {string} targetPath Target location
2528
- * @param {boolean} [overwrite=false] If the file already exists at the target path, the file will be overwriten if this is true.
2529
- * Default is FALSE
2530
- * @param {boolean} [keepOriginalPermission=false] The file will be set as the permission from the entry if this is true.
2531
- * Default is FALSE
2532
- * @param {string|Buffer} [pass] password
2533
- */
2534
- extractAllTo: function(targetPath, overwrite, keepOriginalPermission, pass) {
2535
- keepOriginalPermission = get_Bool(false, keepOriginalPermission);
2536
- pass = get_Str(keepOriginalPermission, pass);
2537
- overwrite = get_Bool(false, overwrite);
2538
- if (!_zip) throw Utils.Errors.NO_ZIP();
2539
- _zip.entries.forEach(function(entry) {
2540
- var entryName = sanitize(targetPath, canonical(entry.entryName));
2541
- if (entry.isDirectory) {
2542
- filetools.makeDir(entryName);
2543
- return;
2544
- }
2545
- var content = entry.getData(pass);
2546
- if (!content) {
2547
- throw Utils.Errors.CANT_EXTRACT_FILE();
2548
- }
2549
- const fileAttr = keepOriginalPermission ? entry.header.fileAttr : void 0;
2550
- filetools.writeFileTo(entryName, content, overwrite, fileAttr);
2551
- try {
2552
- filetools.fs.utimesSync(entryName, entry.header.time, entry.header.time);
2553
- } catch (err) {
2554
- throw Utils.Errors.CANT_EXTRACT_FILE();
2555
- }
2556
- });
2557
- },
2558
- /**
2559
- * Asynchronous extractAllTo
2560
- *
2561
- * @param {string} targetPath Target location
2562
- * @param {boolean} [overwrite=false] If the file already exists at the target path, the file will be overwriten if this is true.
2563
- * Default is FALSE
2564
- * @param {boolean} [keepOriginalPermission=false] The file will be set as the permission from the entry if this is true.
2565
- * Default is FALSE
2566
- * @param {function} callback The callback will be executed when all entries are extracted successfully or any error is thrown.
2567
- */
2568
- extractAllToAsync: function(targetPath, overwrite, keepOriginalPermission, callback) {
2569
- callback = get_Fun(overwrite, keepOriginalPermission, callback);
2570
- keepOriginalPermission = get_Bool(false, keepOriginalPermission);
2571
- overwrite = get_Bool(false, overwrite);
2572
- if (!callback) {
2573
- return new Promise((resolve, reject) => {
2574
- this.extractAllToAsync(targetPath, overwrite, keepOriginalPermission, function(err) {
2575
- if (err) {
2576
- reject(err);
2577
- } else {
2578
- resolve(this);
2579
- }
2580
- });
2581
- });
2582
- }
2583
- if (!_zip) {
2584
- callback(Utils.Errors.NO_ZIP());
2585
- return;
2586
- }
2587
- targetPath = pth.resolve(targetPath);
2588
- const getPath = (entry) => sanitize(targetPath, pth.normalize(canonical(entry.entryName)));
2589
- const getError = (msg, file) => new Error(msg + ': "' + file + '"');
2590
- const dirEntries = [];
2591
- const fileEntries = [];
2592
- _zip.entries.forEach((e) => {
2593
- if (e.isDirectory) {
2594
- dirEntries.push(e);
2595
- } else {
2596
- fileEntries.push(e);
2597
- }
2598
- });
2599
- for (const entry of dirEntries) {
2600
- const dirPath = getPath(entry);
2601
- const dirAttr = keepOriginalPermission ? entry.header.fileAttr : void 0;
2602
- try {
2603
- filetools.makeDir(dirPath);
2604
- if (dirAttr) filetools.fs.chmodSync(dirPath, dirAttr);
2605
- filetools.fs.utimesSync(dirPath, entry.header.time, entry.header.time);
2606
- } catch (er) {
2607
- callback(getError("Unable to create folder", dirPath));
2608
- }
2609
- }
2610
- fileEntries.reverse().reduce(function(next, entry) {
2611
- return function(err) {
2612
- if (err) {
2613
- next(err);
2614
- } else {
2615
- const entryName = pth.normalize(canonical(entry.entryName));
2616
- const filePath = sanitize(targetPath, entryName);
2617
- entry.getDataAsync(function(content, err_1) {
2618
- if (err_1) {
2619
- next(err_1);
2620
- } else if (!content) {
2621
- next(Utils.Errors.CANT_EXTRACT_FILE());
2622
- } else {
2623
- const fileAttr = keepOriginalPermission ? entry.header.fileAttr : void 0;
2624
- filetools.writeFileToAsync(filePath, content, overwrite, fileAttr, function(succ) {
2625
- if (!succ) {
2626
- next(getError("Unable to write file", filePath));
2627
- }
2628
- filetools.fs.utimes(filePath, entry.header.time, entry.header.time, function(err_2) {
2629
- if (err_2) {
2630
- next(getError("Unable to set times", filePath));
2631
- } else {
2632
- next();
2633
- }
2634
- });
2635
- });
2636
- }
2637
- });
2638
- }
2639
- };
2640
- }, callback)();
2641
- },
2642
- /**
2643
- * 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
2644
- *
2645
- * @param {string} targetFileName
2646
- * @param {function} callback
2647
- */
2648
- writeZip: function(targetFileName, callback) {
2649
- if (arguments.length === 1) {
2650
- if (typeof targetFileName === "function") {
2651
- callback = targetFileName;
2652
- targetFileName = "";
2653
- }
2654
- }
2655
- if (!targetFileName && opts.filename) {
2656
- targetFileName = opts.filename;
2657
- }
2658
- if (!targetFileName) return;
2659
- var zipData = _zip.compressToBuffer();
2660
- if (zipData) {
2661
- var ok = filetools.writeFileTo(targetFileName, zipData, true);
2662
- if (typeof callback === "function") callback(!ok ? new Error("failed") : null, "");
2663
- }
2664
- },
2665
- /**
2666
- *
2667
- * @param {string} targetFileName
2668
- * @param {object} [props]
2669
- * @param {boolean} [props.overwrite=true] If the file already exists at the target path, the file will be overwriten if this is true.
2670
- * @param {boolean} [props.perm] The file will be set as the permission from the entry if this is true.
2671
-
2672
- * @returns {Promise<void>}
2673
- */
2674
- writeZipPromise: function(targetFileName, props) {
2675
- const { overwrite, perm } = Object.assign({ overwrite: true }, props);
2676
- return new Promise((resolve, reject) => {
2677
- if (!targetFileName && opts.filename) targetFileName = opts.filename;
2678
- if (!targetFileName) reject("ADM-ZIP: ZIP File Name Missing");
2679
- this.toBufferPromise().then((zipData) => {
2680
- const ret = (done) => done ? resolve(done) : reject("ADM-ZIP: Wasn't able to write zip file");
2681
- filetools.writeFileToAsync(targetFileName, zipData, overwrite, perm, ret);
2682
- }, reject);
2683
- });
2684
- },
2685
- /**
2686
- * @returns {Promise<Buffer>} A promise to the Buffer.
2687
- */
2688
- toBufferPromise: function() {
2689
- return new Promise((resolve, reject) => {
2690
- _zip.toAsyncBuffer(resolve, reject);
2691
- });
2692
- },
2693
- /**
2694
- * Returns the content of the entire zip file as a Buffer object
2695
- *
2696
- * @prop {function} [onSuccess]
2697
- * @prop {function} [onFail]
2698
- * @prop {function} [onItemStart]
2699
- * @prop {function} [onItemEnd]
2700
- * @returns {Buffer}
2701
- */
2702
- toBuffer: function(onSuccess, onFail, onItemStart, onItemEnd) {
2703
- if (typeof onSuccess === "function") {
2704
- _zip.toAsyncBuffer(onSuccess, onFail, onItemStart, onItemEnd);
2705
- return null;
2706
- }
2707
- return _zip.compressToBuffer();
2708
- }
2709
- };
2710
- };
2711
- }
2712
- });
2713
-
2714
43
  // ../../../packages/vibe-plugin-utils/dist/index.cjs
2715
44
  var require_dist = __commonJS({
2716
45
  "../../../packages/vibe-plugin-utils/dist/index.cjs"(exports$1) {
2717
- var fs2 = __require("fs");
2718
- var path3 = __require("path");
2719
- var https2 = __require("https");
46
+ var fs = __require("fs");
47
+ var path2 = __require("path");
48
+ var https = __require("https");
2720
49
  function _interopDefault(e) {
2721
50
  return e && e.__esModule ? e : { default: e };
2722
51
  }
@@ -2739,9 +68,9 @@ var require_dist = __commonJS({
2739
68
  n.default = e;
2740
69
  return Object.freeze(n);
2741
70
  }
2742
- var fs__namespace = /* @__PURE__ */ _interopNamespace(fs2);
2743
- var path__namespace = /* @__PURE__ */ _interopNamespace(path3);
2744
- var https__default = /* @__PURE__ */ _interopDefault(https2);
71
+ var fs__namespace = /* @__PURE__ */ _interopNamespace(fs);
72
+ var path__namespace = /* @__PURE__ */ _interopNamespace(path2);
73
+ var https__default = /* @__PURE__ */ _interopDefault(https);
2745
74
  var __create2 = Object.create;
2746
75
  var __defProp2 = Object.defineProperty;
2747
76
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
@@ -2773,7 +102,7 @@ var require_dist = __commonJS({
2773
102
  !mod || !mod.__esModule ? __defProp2(target, "default", { value: mod, enumerable: true }) : target,
2774
103
  mod
2775
104
  ));
2776
- var require_constants2 = __commonJS2({
105
+ var require_constants = __commonJS2({
2777
106
  "../../node_modules/adm-zip/util/constants.js"(exports$1, module2) {
2778
107
  module2.exports = {
2779
108
  /* The local file header */
@@ -2990,7 +319,7 @@ var require_dist = __commonJS({
2990
319
  };
2991
320
  }
2992
321
  });
2993
- var require_errors2 = __commonJS2({
322
+ var require_errors = __commonJS2({
2994
323
  "../../node_modules/adm-zip/util/errors.js"(exports$1) {
2995
324
  var errors = {
2996
325
  /* Header error messages */
@@ -3048,12 +377,12 @@ var require_dist = __commonJS({
3048
377
  }
3049
378
  }
3050
379
  });
3051
- var require_utils2 = __commonJS2({
380
+ var require_utils = __commonJS2({
3052
381
  "../../node_modules/adm-zip/util/utils.js"(exports$1, module2) {
3053
382
  var fsystem = __require2("fs");
3054
383
  var pth = __require2("path");
3055
- var Constants = require_constants2();
3056
- var Errors = require_errors2();
384
+ var Constants = require_constants();
385
+ var Errors = require_errors();
3057
386
  var isWin = typeof process === "object" && "win32" === process.platform;
3058
387
  var is_Obj = (obj) => typeof obj === "object" && obj !== null;
3059
388
  var crcTable = new Uint32Array(256).map((t, c) => {
@@ -3175,12 +504,12 @@ var require_dist = __commonJS({
3175
504
  function findSync(dir, pattern, recursive) {
3176
505
  let files = [];
3177
506
  self.fs.readdirSync(dir).forEach(function(file) {
3178
- const path32 = pth.join(dir, file);
3179
- const stat = self.fs.statSync(path32);
507
+ const path3 = pth.join(dir, file);
508
+ const stat = self.fs.statSync(path3);
3180
509
  {
3181
- files.push(pth.normalize(path32) + (stat.isDirectory() ? self.sep : ""));
510
+ files.push(pth.normalize(path3) + (stat.isDirectory() ? self.sep : ""));
3182
511
  }
3183
- if (stat.isDirectory() && recursive) files = files.concat(findSync(path32, pattern, recursive));
512
+ if (stat.isDirectory() && recursive) files = files.concat(findSync(path3, pattern, recursive));
3184
513
  });
3185
514
  return files;
3186
515
  }
@@ -3300,10 +629,10 @@ var require_dist = __commonJS({
3300
629
  Utils.crcTable = crcTable;
3301
630
  }
3302
631
  });
3303
- var require_fattr2 = __commonJS2({
632
+ var require_fattr = __commonJS2({
3304
633
  "../../node_modules/adm-zip/util/fattr.js"(exports$1, module2) {
3305
634
  var pth = __require2("path");
3306
- module2.exports = function(path22, { fs: fs22 }) {
635
+ module2.exports = function(path22, { fs: fs2 }) {
3307
636
  var _path = path22 || "", _obj = newAttr(), _stat = null;
3308
637
  function newAttr() {
3309
638
  return {
@@ -3315,8 +644,8 @@ var require_dist = __commonJS({
3315
644
  atime: 0
3316
645
  };
3317
646
  }
3318
- if (_path && fs22.existsSync(_path)) {
3319
- _stat = fs22.statSync(_path);
647
+ if (_path && fs2.existsSync(_path)) {
648
+ _stat = fs2.statSync(_path);
3320
649
  _obj.directory = _stat.isDirectory();
3321
650
  _obj.mtime = _stat.mtime;
3322
651
  _obj.atime = _stat.atime;
@@ -3367,7 +696,7 @@ var require_dist = __commonJS({
3367
696
  };
3368
697
  }
3369
698
  });
3370
- var require_decoder2 = __commonJS2({
699
+ var require_decoder = __commonJS2({
3371
700
  "../../node_modules/adm-zip/util/decoder.js"(exports$1, module2) {
3372
701
  module2.exports = {
3373
702
  efs: true,
@@ -3376,18 +705,18 @@ var require_dist = __commonJS({
3376
705
  };
3377
706
  }
3378
707
  });
3379
- var require_util2 = __commonJS2({
708
+ var require_util = __commonJS2({
3380
709
  "../../node_modules/adm-zip/util/index.js"(exports$1, 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();
710
+ module2.exports = require_utils();
711
+ module2.exports.Constants = require_constants();
712
+ module2.exports.Errors = require_errors();
713
+ module2.exports.FileAttr = require_fattr();
714
+ module2.exports.decoder = require_decoder();
3386
715
  }
3387
716
  });
3388
- var require_entryHeader2 = __commonJS2({
717
+ var require_entryHeader = __commonJS2({
3389
718
  "../../node_modules/adm-zip/headers/entryHeader.js"(exports$1, module2) {
3390
- var Utils = require_util2();
719
+ var Utils = require_util();
3391
720
  var Constants = Utils.Constants;
3392
721
  module2.exports = function() {
3393
722
  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;
@@ -3650,9 +979,9 @@ var require_dist = __commonJS({
3650
979
  };
3651
980
  }
3652
981
  });
3653
- var require_mainHeader2 = __commonJS2({
982
+ var require_mainHeader = __commonJS2({
3654
983
  "../../node_modules/adm-zip/headers/mainHeader.js"(exports$1, module2) {
3655
- var Utils = require_util2();
984
+ var Utils = require_util();
3656
985
  var Constants = Utils.Constants;
3657
986
  module2.exports = function() {
3658
987
  var _volumeEntries = 0, _totalEntries = 0, _size = 0, _offset = 0, _commentLength = 0;
@@ -3741,13 +1070,13 @@ var require_dist = __commonJS({
3741
1070
  };
3742
1071
  }
3743
1072
  });
3744
- var require_headers2 = __commonJS2({
1073
+ var require_headers = __commonJS2({
3745
1074
  "../../node_modules/adm-zip/headers/index.js"(exports$1) {
3746
- exports$1.EntryHeader = require_entryHeader2();
3747
- exports$1.MainHeader = require_mainHeader2();
1075
+ exports$1.EntryHeader = require_entryHeader();
1076
+ exports$1.MainHeader = require_mainHeader();
3748
1077
  }
3749
1078
  });
3750
- var require_deflater2 = __commonJS2({
1079
+ var require_deflater = __commonJS2({
3751
1080
  "../../node_modules/adm-zip/methods/deflater.js"(exports$1, module2) {
3752
1081
  module2.exports = function(inbuf) {
3753
1082
  var zlib = __require2("zlib");
@@ -3778,7 +1107,7 @@ var require_dist = __commonJS({
3778
1107
  };
3779
1108
  }
3780
1109
  });
3781
- var require_inflater2 = __commonJS2({
1110
+ var require_inflater = __commonJS2({
3782
1111
  "../../node_modules/adm-zip/methods/inflater.js"(exports$1, module2) {
3783
1112
  var version = +(process.versions ? process.versions.node : "").split(".")[0] || 0;
3784
1113
  module2.exports = function(inbuf, expectedLength) {
@@ -3810,10 +1139,10 @@ var require_dist = __commonJS({
3810
1139
  };
3811
1140
  }
3812
1141
  });
3813
- var require_zipcrypto2 = __commonJS2({
1142
+ var require_zipcrypto = __commonJS2({
3814
1143
  "../../node_modules/adm-zip/methods/zipcrypto.js"(exports$1, module2) {
3815
1144
  var { randomFillSync } = __require2("crypto");
3816
- var Errors = require_errors2();
1145
+ var Errors = require_errors();
3817
1146
  var crctable = new Uint32Array(256).map((t, crc) => {
3818
1147
  for (let j = 0; j < 8; j++) {
3819
1148
  if (0 !== (crc & 1)) {
@@ -3923,19 +1252,19 @@ var require_dist = __commonJS({
3923
1252
  module2.exports = { decrypt, encrypt, _salter };
3924
1253
  }
3925
1254
  });
3926
- var require_methods2 = __commonJS2({
1255
+ var require_methods = __commonJS2({
3927
1256
  "../../node_modules/adm-zip/methods/index.js"(exports$1) {
3928
- exports$1.Deflater = require_deflater2();
3929
- exports$1.Inflater = require_inflater2();
3930
- exports$1.ZipCrypto = require_zipcrypto2();
1257
+ exports$1.Deflater = require_deflater();
1258
+ exports$1.Inflater = require_inflater();
1259
+ exports$1.ZipCrypto = require_zipcrypto();
3931
1260
  }
3932
1261
  });
3933
- var require_zipEntry2 = __commonJS2({
1262
+ var require_zipEntry = __commonJS2({
3934
1263
  "../../node_modules/adm-zip/zipEntry.js"(exports$1, module2) {
3935
- var Utils = require_util2();
3936
- var Headers = require_headers2();
1264
+ var Utils = require_util();
1265
+ var Headers = require_headers();
3937
1266
  var Constants = Utils.Constants;
3938
- var Methods = require_methods2();
1267
+ var Methods = require_methods();
3939
1268
  module2.exports = function(options, input) {
3940
1269
  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
1270
  const opts = options;
@@ -4259,11 +1588,11 @@ var require_dist = __commonJS({
4259
1588
  };
4260
1589
  }
4261
1590
  });
4262
- var require_zipFile2 = __commonJS2({
1591
+ var require_zipFile = __commonJS2({
4263
1592
  "../../node_modules/adm-zip/zipFile.js"(exports$1, module2) {
4264
- var ZipEntry = require_zipEntry2();
4265
- var Headers = require_headers2();
4266
- var Utils = require_util2();
1593
+ var ZipEntry = require_zipEntry();
1594
+ var Headers = require_headers();
1595
+ var Utils = require_util();
4267
1596
  module2.exports = function(inBuffer, options) {
4268
1597
  var entryList = [], entryTable = {}, _comment = Buffer.alloc(0), mainHeader = new Headers.MainHeader(), loadedEntries = false;
4269
1598
  const temporary = /* @__PURE__ */ new Set();
@@ -4602,12 +1931,12 @@ var require_dist = __commonJS({
4602
1931
  };
4603
1932
  }
4604
1933
  });
4605
- var require_adm_zip2 = __commonJS2({
1934
+ var require_adm_zip = __commonJS2({
4606
1935
  "../../node_modules/adm-zip/adm-zip.js"(exports$1, module2) {
4607
- var Utils = require_util2();
1936
+ var Utils = require_util();
4608
1937
  var pth = __require2("path");
4609
- var ZipEntry = require_zipEntry2();
4610
- var ZipFile = require_zipFile2();
1938
+ var ZipEntry = require_zipEntry();
1939
+ var ZipFile = require_zipFile();
4611
1940
  var get_Bool = (...val) => Utils.findLast(val, (c) => typeof c === "boolean");
4612
1941
  var get_Str = (...val) => Utils.findLast(val, (c) => typeof c === "string");
4613
1942
  var get_Fun = (...val) => Utils.findLast(val, (c) => typeof c === "function");
@@ -5391,7 +2720,7 @@ var require_dist = __commonJS({
5391
2720
  }
5392
2721
  });
5393
2722
  function getPluginFilesVersion2(pluginFilesPackageName, pluginPackageJsonPath) {
5394
- const pluginPackageJson = JSON.parse(fs2.readFileSync(pluginPackageJsonPath, "utf-8"));
2723
+ const pluginPackageJson = JSON.parse(fs.readFileSync(pluginPackageJsonPath, "utf-8"));
5395
2724
  let version = pluginPackageJson.dependencies?.[pluginFilesPackageName];
5396
2725
  if (!version) {
5397
2726
  throw new Error(
@@ -5426,8 +2755,8 @@ var require_dist = __commonJS({
5426
2755
  console.log(`[get-plugin-files-version] Final resolved version for ${pluginFilesPackageName}: ${version}`);
5427
2756
  return version;
5428
2757
  }
5429
- var import_adm_zip2 = __toESM2(require_adm_zip2());
5430
- async function downloadZipFile2(url, filePath, env) {
2758
+ var import_adm_zip = __toESM2(require_adm_zip());
2759
+ async function downloadZipFile(url, filePath, env) {
5431
2760
  return new Promise((resolve, reject) => {
5432
2761
  const file = fs__namespace.createWriteStream(filePath);
5433
2762
  const makeRequest = (requestUrl) => {
@@ -5473,8 +2802,8 @@ var require_dist = __commonJS({
5473
2802
  const targetDir = path__namespace.join(env.CODEGEN_APP_ROOT, "src");
5474
2803
  try {
5475
2804
  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);
2805
+ await downloadZipFile(zipUrl, zipPath, env);
2806
+ const zip = new import_adm_zip.default(zipPath);
5478
2807
  env.logger.debug("[plugin-files-downloader] unzipping files...");
5479
2808
  zip.getEntries().forEach((entry) => {
5480
2809
  if (!entry.isDirectory) {
@@ -5503,165 +2832,30 @@ var require_dist = __commonJS({
5503
2832
  throw error;
5504
2833
  }
5505
2834
  }
5506
- exports$1.downloadZipFile = downloadZipFile2;
2835
+ exports$1.downloadZipFile = downloadZipFile;
5507
2836
  exports$1.getPluginFilesVersion = getPluginFilesVersion2;
5508
2837
  exports$1.unzipAndMergePluginFiles = unzipAndMergePluginFiles2;
5509
2838
  }
5510
2839
  });
5511
2840
 
5512
- // src/utils.ts
5513
- var import_adm_zip = __toESM(require_adm_zip());
2841
+ // src/index.ts
2842
+ var import_vibe_plugin_utils2 = __toESM(require_dist());
5514
2843
 
5515
2844
  // src/constants.ts
5516
2845
  var import_vibe_plugin_utils = __toESM(require_dist());
5517
2846
  var PLUGIN_FILES_VERSION = (0, import_vibe_plugin_utils.getPluginFilesVersion)(
5518
2847
  "@wix/vibe-forms-plugin-files",
5519
- path2__namespace.default.resolve(__dirname, "../package.json")
2848
+ path__default.default.resolve(__dirname, "../package.json")
5520
2849
  );
5521
- var PLUGIN_FILES_ZIP_URL = `https://static.parastorage.com/services/vibe-forms-plugin-files/${PLUGIN_FILES_VERSION}/forms-plugin-files-files.zip`;
2850
+ var PLUGIN_FILES_ZIP_URL = `https://static.parastorage.com/services/vibe-forms-plugin-files/${PLUGIN_FILES_VERSION}/vibe-forms-plugin-files-files.zip`;
5522
2851
  var VERTICAL_NAME = "forms";
5523
2852
 
5524
- // src/utils.ts
5525
- async function downloadZipFile(url, filePath, logger) {
5526
- return new Promise((resolve, reject) => {
5527
- const file = fs__namespace.createWriteStream(filePath);
5528
- const makeRequest = (requestUrl) => {
5529
- https__default.default.get(requestUrl, (response) => {
5530
- if (response.statusCode === 301 || response.statusCode === 302) {
5531
- const location = response.headers.location;
5532
- if (location) {
5533
- logger.debug(
5534
- `[${VERTICAL_NAME}-plugin-setup] following redirect to: ${location}`
5535
- );
5536
- makeRequest(location);
5537
- return;
5538
- }
5539
- }
5540
- if (response.statusCode !== 200) {
5541
- reject(
5542
- new Error(
5543
- `Failed to download: ${response.statusCode} ${response.statusMessage}`
5544
- )
5545
- );
5546
- return;
5547
- }
5548
- response.pipe(file);
5549
- file.on("finish", () => {
5550
- file.close();
5551
- resolve();
5552
- });
5553
- file.on("error", (err) => {
5554
- fs__namespace.unlink(filePath, () => {
5555
- });
5556
- reject(err);
5557
- });
5558
- }).on("error", (err) => {
5559
- reject(err);
5560
- });
5561
- };
5562
- makeRequest(url);
5563
- });
5564
- }
5565
- var unzipAndMergeParastoragePluginFiles = async (env, zipUrl) => {
5566
- env.logger.debug(
5567
- `[${VERTICAL_NAME}-plugin-install] Unzipping plugin files from dependency...`
5568
- );
5569
- const zipPath = path2__namespace.join(process.cwd(), "picasso-forms-plugin-files.zip");
5570
- const targetDir = path2__namespace.join(env.CODEGEN_APP_ROOT, "src");
5571
- try {
5572
- env.logger.debug(
5573
- `[${VERTICAL_NAME}-plugin-install] downloading zip file to:`,
5574
- { zipPath }
5575
- );
5576
- await downloadZipFile(zipUrl, zipPath, env.logger);
5577
- const zip = new import_adm_zip.default(zipPath);
5578
- env.logger.debug(`[${VERTICAL_NAME}-plugin-install] Unzipping files...`);
5579
- zip.getEntries().forEach((entry) => {
5580
- if (!entry.isDirectory) {
5581
- const entryPath = entry.entryName;
5582
- const targetPath = path2__namespace.join(targetDir, entryPath);
5583
- const targetDirPath = path2__namespace.dirname(targetPath);
5584
- if (!fs__namespace.existsSync(targetDirPath)) {
5585
- fs__namespace.mkdirSync(targetDirPath, { recursive: true });
5586
- }
5587
- fs__namespace.writeFileSync(targetPath, entry.getData());
5588
- env.logger.debug(
5589
- `[${VERTICAL_NAME}-plugin-install] Extracted: ${targetPath}`
5590
- );
5591
- }
5592
- });
5593
- env.logger.debug(
5594
- `[${VERTICAL_NAME}-plugin-install] Plugin files unzipped and merged successfully`
5595
- );
5596
- } catch (error) {
5597
- env.logger.error(
5598
- new Error(
5599
- `[${VERTICAL_NAME}-plugin-install] Error downloading or unzipping plugin files:`
5600
- ),
5601
- { error }
5602
- );
5603
- throw error;
5604
- }
5605
- };
5606
- var unzipAndMergePluginFiles = async (env, useLocal = false) => {
5607
- if (useLocal) {
5608
- return unzipAndMergeLocalPluginFiles(
5609
- env,
5610
- "/Users/laurale/vibe-plugins/plugins/forms/vibe-forms-plugin-files/dist/statics/forms-plugin-files-files.zip"
5611
- );
5612
- } else {
5613
- return unzipAndMergeParastoragePluginFiles(env, PLUGIN_FILES_ZIP_URL);
5614
- }
5615
- };
5616
- var unzipAndMergeLocalPluginFiles = async (env, zipPath) => {
5617
- env.logger.debug(
5618
- `[${VERTICAL_NAME}-plugin-install] Unzipping plugin files from local file...`
5619
- );
5620
- const targetDir = path2__namespace.join(env.CODEGEN_APP_ROOT, "src");
5621
- try {
5622
- env.logger.debug(
5623
- `[${VERTICAL_NAME}-plugin-install] Using local zip file:`,
5624
- { zipPath }
5625
- );
5626
- if (!fs__namespace.existsSync(zipPath)) {
5627
- throw new Error(`Local zip file not found at: ${zipPath}`);
5628
- }
5629
- const zip = new import_adm_zip.default(zipPath);
5630
- env.logger.debug(`[${VERTICAL_NAME}-plugin-install] Unzipping files...`);
5631
- zip.getEntries().forEach((entry) => {
5632
- if (!entry.isDirectory) {
5633
- const entryPath = entry.entryName;
5634
- const targetPath = path2__namespace.join(targetDir, entryPath);
5635
- const targetDirPath = path2__namespace.dirname(targetPath);
5636
- if (!fs__namespace.existsSync(targetDirPath)) {
5637
- fs__namespace.mkdirSync(targetDirPath, { recursive: true });
5638
- }
5639
- fs__namespace.writeFileSync(targetPath, entry.getData());
5640
- env.logger.debug(
5641
- `[${VERTICAL_NAME}-plugin-install] Extracted: ${targetPath}`
5642
- );
5643
- }
5644
- });
5645
- env.logger.debug(
5646
- `[${VERTICAL_NAME}-plugin-install] Plugin files unzipped and merged successfully`
5647
- );
5648
- } catch (error) {
5649
- env.logger.error(
5650
- new Error(
5651
- `[${VERTICAL_NAME}-plugin-install] Error unzipping plugin files:`
5652
- ),
5653
- { error }
5654
- );
5655
- throw error;
5656
- }
5657
- };
5658
-
5659
2853
  // src/index.ts
5660
2854
  var install = async (env) => {
5661
2855
  console.log(
5662
2856
  `[${VERTICAL_NAME}-plugin-install] Unzipping and merging plugin files...`
5663
2857
  );
5664
- await unzipAndMergePluginFiles(env, false);
2858
+ await (0, import_vibe_plugin_utils2.unzipAndMergePluginFiles)(env, PLUGIN_FILES_ZIP_URL, VERTICAL_NAME);
5665
2859
  console.log(`[${VERTICAL_NAME}-plugin-install] Files merged successfully`);
5666
2860
  };
5667
2861
  var formsPlugin = {