@wix/vibe-forms-app-plugin 0.23.0 → 0.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -2,2796 +2,17 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var fs = require('fs');
6
- var path = require('path');
7
- var https = require('https');
8
-
9
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
10
-
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 path__namespace = /*#__PURE__*/_interopNamespace(path);
31
- var https__default = /*#__PURE__*/_interopDefault(https);
32
-
33
- var __create = Object.create;
34
5
  var __defProp = Object.defineProperty;
35
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
36
- var __getOwnPropNames = Object.getOwnPropertyNames;
37
- var __getProtoOf = Object.getPrototypeOf;
38
- var __hasOwnProp = Object.prototype.hasOwnProperty;
39
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
40
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
41
- }) : x)(function(x) {
42
- if (typeof require !== "undefined") return require.apply(this, arguments);
43
- throw Error('Dynamic require of "' + x + '" is not supported');
44
- });
45
- var __commonJS = (cb, mod) => function __require2() {
46
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
47
- };
48
6
  var __export = (target, all) => {
49
7
  for (var name in all)
50
8
  __defProp(target, name, { get: all[name], enumerable: true });
51
9
  };
52
- var __copyProps = (to, from, except, desc) => {
53
- if (from && typeof from === "object" || typeof from === "function") {
54
- for (let key of __getOwnPropNames(from))
55
- if (!__hasOwnProp.call(to, key) && key !== except)
56
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
57
- }
58
- return to;
59
- };
60
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
61
- // If the importer is in node compatibility mode or this is not an ESM
62
- // file that has been converted to a CommonJS file using a Babel-
63
- // compatible transform (i.e. "__esModule" has not been set), then set
64
- // "default" to the CommonJS "module.exports" for node compatibility.
65
- !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
66
- mod
67
- ));
68
-
69
- // ../../../node_modules/adm-zip/util/constants.js
70
- var require_constants = __commonJS({
71
- "../../../node_modules/adm-zip/util/constants.js"(exports, module) {
72
- module.exports = {
73
- /* The local file header */
74
- LOCHDR: 30,
75
- // LOC header size
76
- LOCSIG: 67324752,
77
- // "PK\003\004"
78
- LOCVER: 4,
79
- // version needed to extract
80
- LOCFLG: 6,
81
- // general purpose bit flag
82
- LOCHOW: 8,
83
- // compression method
84
- LOCTIM: 10,
85
- // modification time (2 bytes time, 2 bytes date)
86
- LOCCRC: 14,
87
- // uncompressed file crc-32 value
88
- LOCSIZ: 18,
89
- // compressed size
90
- LOCLEN: 22,
91
- // uncompressed size
92
- LOCNAM: 26,
93
- // filename length
94
- LOCEXT: 28,
95
- // extra field length
96
- /* The Data descriptor */
97
- EXTSIG: 134695760,
98
- // "PK\007\008"
99
- EXTHDR: 16,
100
- // EXT header size
101
- EXTCRC: 4,
102
- // uncompressed file crc-32 value
103
- EXTSIZ: 8,
104
- // compressed size
105
- EXTLEN: 12,
106
- // uncompressed size
107
- /* The central directory file header */
108
- CENHDR: 46,
109
- // CEN header size
110
- CENSIG: 33639248,
111
- // "PK\001\002"
112
- CENVEM: 4,
113
- // version made by
114
- CENVER: 6,
115
- // version needed to extract
116
- CENFLG: 8,
117
- // encrypt, decrypt flags
118
- CENHOW: 10,
119
- // compression method
120
- CENTIM: 12,
121
- // modification time (2 bytes time, 2 bytes date)
122
- CENCRC: 16,
123
- // uncompressed file crc-32 value
124
- CENSIZ: 20,
125
- // compressed size
126
- CENLEN: 24,
127
- // uncompressed size
128
- CENNAM: 28,
129
- // filename length
130
- CENEXT: 30,
131
- // extra field length
132
- CENCOM: 32,
133
- // file comment length
134
- CENDSK: 34,
135
- // volume number start
136
- CENATT: 36,
137
- // internal file attributes
138
- CENATX: 38,
139
- // external file attributes (host system dependent)
140
- CENOFF: 42,
141
- // LOC header offset
142
- /* The entries in the end of central directory */
143
- ENDHDR: 22,
144
- // END header size
145
- ENDSIG: 101010256,
146
- // "PK\005\006"
147
- ENDSUB: 8,
148
- // number of entries on this disk
149
- ENDTOT: 10,
150
- // total number of entries
151
- ENDSIZ: 12,
152
- // central directory size in bytes
153
- ENDOFF: 16,
154
- // offset of first CEN header
155
- ENDCOM: 20,
156
- // zip file comment length
157
- END64HDR: 20,
158
- // zip64 END header size
159
- END64SIG: 117853008,
160
- // zip64 Locator signature, "PK\006\007"
161
- END64START: 4,
162
- // number of the disk with the start of the zip64
163
- END64OFF: 8,
164
- // relative offset of the zip64 end of central directory
165
- END64NUMDISKS: 16,
166
- // total number of disks
167
- ZIP64SIG: 101075792,
168
- // zip64 signature, "PK\006\006"
169
- ZIP64HDR: 56,
170
- // zip64 record minimum size
171
- ZIP64LEAD: 12,
172
- // leading bytes at the start of the record, not counted by the value stored in ZIP64SIZE
173
- ZIP64SIZE: 4,
174
- // zip64 size of the central directory record
175
- ZIP64VEM: 12,
176
- // zip64 version made by
177
- ZIP64VER: 14,
178
- // zip64 version needed to extract
179
- ZIP64DSK: 16,
180
- // zip64 number of this disk
181
- ZIP64DSKDIR: 20,
182
- // number of the disk with the start of the record directory
183
- ZIP64SUB: 24,
184
- // number of entries on this disk
185
- ZIP64TOT: 32,
186
- // total number of entries
187
- ZIP64SIZB: 40,
188
- // zip64 central directory size in bytes
189
- ZIP64OFF: 48,
190
- // offset of start of central directory with respect to the starting disk number
191
- ZIP64EXTRA: 56,
192
- // extensible data sector
193
- /* Compression methods */
194
- STORED: 0,
195
- // no compression
196
- SHRUNK: 1,
197
- // shrunk
198
- REDUCED1: 2,
199
- // reduced with compression factor 1
200
- REDUCED2: 3,
201
- // reduced with compression factor 2
202
- REDUCED3: 4,
203
- // reduced with compression factor 3
204
- REDUCED4: 5,
205
- // reduced with compression factor 4
206
- IMPLODED: 6,
207
- // imploded
208
- // 7 reserved for Tokenizing compression algorithm
209
- DEFLATED: 8,
210
- // deflated
211
- ENHANCED_DEFLATED: 9,
212
- // enhanced deflated
213
- PKWARE: 10,
214
- // PKWare DCL imploded
215
- // 11 reserved by PKWARE
216
- BZIP2: 12,
217
- // compressed using BZIP2
218
- // 13 reserved by PKWARE
219
- LZMA: 14,
220
- // LZMA
221
- // 15-17 reserved by PKWARE
222
- IBM_TERSE: 18,
223
- // compressed using IBM TERSE
224
- IBM_LZ77: 19,
225
- // IBM LZ77 z
226
- AES_ENCRYPT: 99,
227
- // WinZIP AES encryption method
228
- /* General purpose bit flag */
229
- // values can obtained with expression 2**bitnr
230
- FLG_ENC: 1,
231
- // Bit 0: encrypted file
232
- FLG_COMP1: 2,
233
- // Bit 1, compression option
234
- FLG_COMP2: 4,
235
- // Bit 2, compression option
236
- FLG_DESC: 8,
237
- // Bit 3, data descriptor
238
- FLG_ENH: 16,
239
- // Bit 4, enhanced deflating
240
- FLG_PATCH: 32,
241
- // Bit 5, indicates that the file is compressed patched data.
242
- FLG_STR: 64,
243
- // Bit 6, strong encryption (patented)
244
- // Bits 7-10: Currently unused.
245
- FLG_EFS: 2048,
246
- // Bit 11: Language encoding flag (EFS)
247
- // Bit 12: Reserved by PKWARE for enhanced compression.
248
- // Bit 13: encrypted the Central Directory (patented).
249
- // Bits 14-15: Reserved by PKWARE.
250
- FLG_MSK: 4096,
251
- // mask header values
252
- /* Load type */
253
- FILE: 2,
254
- BUFFER: 1,
255
- NONE: 0,
256
- /* 4.5 Extensible data fields */
257
- EF_ID: 0,
258
- EF_SIZE: 2,
259
- /* Header IDs */
260
- ID_ZIP64: 1,
261
- ID_AVINFO: 7,
262
- ID_PFS: 8,
263
- ID_OS2: 9,
264
- ID_NTFS: 10,
265
- ID_OPENVMS: 12,
266
- ID_UNIX: 13,
267
- ID_FORK: 14,
268
- ID_PATCH: 15,
269
- ID_X509_PKCS7: 20,
270
- ID_X509_CERTID_F: 21,
271
- ID_X509_CERTID_C: 22,
272
- ID_STRONGENC: 23,
273
- ID_RECORD_MGT: 24,
274
- ID_X509_PKCS7_RL: 25,
275
- ID_IBM1: 101,
276
- ID_IBM2: 102,
277
- ID_POSZIP: 18064,
278
- EF_ZIP64_OR_32: 4294967295,
279
- EF_ZIP64_OR_16: 65535,
280
- EF_ZIP64_SUNCOMP: 0,
281
- EF_ZIP64_SCOMP: 8,
282
- EF_ZIP64_RHO: 16,
283
- EF_ZIP64_DSN: 24
284
- };
285
- }
286
- });
287
-
288
- // ../../../node_modules/adm-zip/util/errors.js
289
- var require_errors = __commonJS({
290
- "../../../node_modules/adm-zip/util/errors.js"(exports) {
291
- var errors = {
292
- /* Header error messages */
293
- INVALID_LOC: "Invalid LOC header (bad signature)",
294
- INVALID_CEN: "Invalid CEN header (bad signature)",
295
- INVALID_END: "Invalid END header (bad signature)",
296
- /* Descriptor */
297
- DESCRIPTOR_NOT_EXIST: "No descriptor present",
298
- DESCRIPTOR_UNKNOWN: "Unknown descriptor format",
299
- DESCRIPTOR_FAULTY: "Descriptor data is malformed",
300
- /* ZipEntry error messages*/
301
- NO_DATA: "Nothing to decompress",
302
- BAD_CRC: "CRC32 checksum failed {0}",
303
- FILE_IN_THE_WAY: "There is a file in the way: {0}",
304
- UNKNOWN_METHOD: "Invalid/unsupported compression method",
305
- /* Inflater error messages */
306
- AVAIL_DATA: "inflate::Available inflate data did not terminate",
307
- INVALID_DISTANCE: "inflate::Invalid literal/length or distance code in fixed or dynamic block",
308
- TO_MANY_CODES: "inflate::Dynamic block code description: too many length or distance codes",
309
- INVALID_REPEAT_LEN: "inflate::Dynamic block code description: repeat more than specified lengths",
310
- INVALID_REPEAT_FIRST: "inflate::Dynamic block code description: repeat lengths with no first length",
311
- INCOMPLETE_CODES: "inflate::Dynamic block code description: code lengths codes incomplete",
312
- INVALID_DYN_DISTANCE: "inflate::Dynamic block code description: invalid distance code lengths",
313
- INVALID_CODES_LEN: "inflate::Dynamic block code description: invalid literal/length code lengths",
314
- INVALID_STORE_BLOCK: "inflate::Stored block length did not match one's complement",
315
- INVALID_BLOCK_TYPE: "inflate::Invalid block type (type == 3)",
316
- /* ADM-ZIP error messages */
317
- CANT_EXTRACT_FILE: "Could not extract the file",
318
- CANT_OVERRIDE: "Target file already exists",
319
- DISK_ENTRY_TOO_LARGE: "Number of disk entries is too large",
320
- NO_ZIP: "No zip file was loaded",
321
- NO_ENTRY: "Entry doesn't exist",
322
- DIRECTORY_CONTENT_ERROR: "A directory cannot have content",
323
- FILE_NOT_FOUND: 'File not found: "{0}"',
324
- NOT_IMPLEMENTED: "Not implemented",
325
- INVALID_FILENAME: "Invalid filename",
326
- INVALID_FORMAT: "Invalid or unsupported zip format. No END header found",
327
- INVALID_PASS_PARAM: "Incompatible password parameter",
328
- WRONG_PASSWORD: "Wrong Password",
329
- /* ADM-ZIP */
330
- COMMENT_TOO_LONG: "Comment is too long",
331
- // Comment can be max 65535 bytes long (NOTE: some non-US characters may take more space)
332
- EXTRA_FIELD_PARSE_ERROR: "Extra field parsing error"
333
- };
334
- function E(message) {
335
- return function(...args) {
336
- if (args.length) {
337
- message = message.replace(/\{(\d)\}/g, (_, n) => args[n] || "");
338
- }
339
- return new Error("ADM-ZIP: " + message);
340
- };
341
- }
342
- for (const msg of Object.keys(errors)) {
343
- exports[msg] = E(errors[msg]);
344
- }
345
- }
346
- });
347
-
348
- // ../../../node_modules/adm-zip/util/utils.js
349
- var require_utils = __commonJS({
350
- "../../../node_modules/adm-zip/util/utils.js"(exports, module) {
351
- var fsystem = __require("fs");
352
- var pth = __require("path");
353
- var Constants = require_constants();
354
- var Errors = require_errors();
355
- var isWin = typeof process === "object" && "win32" === process.platform;
356
- var is_Obj = (obj) => typeof obj === "object" && obj !== null;
357
- var crcTable = new Uint32Array(256).map((t, c) => {
358
- for (let k = 0; k < 8; k++) {
359
- if ((c & 1) !== 0) {
360
- c = 3988292384 ^ c >>> 1;
361
- } else {
362
- c >>>= 1;
363
- }
364
- }
365
- return c >>> 0;
366
- });
367
- function Utils(opts) {
368
- this.sep = pth.sep;
369
- this.fs = fsystem;
370
- if (is_Obj(opts)) {
371
- if (is_Obj(opts.fs) && typeof opts.fs.statSync === "function") {
372
- this.fs = opts.fs;
373
- }
374
- }
375
- }
376
- module.exports = Utils;
377
- Utils.prototype.makeDir = function(folder) {
378
- const self = this;
379
- function mkdirSync2(fpath) {
380
- let resolvedPath = fpath.split(self.sep)[0];
381
- fpath.split(self.sep).forEach(function(name) {
382
- if (!name || name.substr(-1, 1) === ":") return;
383
- resolvedPath += self.sep + name;
384
- var stat;
385
- try {
386
- stat = self.fs.statSync(resolvedPath);
387
- } catch (e) {
388
- self.fs.mkdirSync(resolvedPath);
389
- }
390
- if (stat && stat.isFile()) throw Errors.FILE_IN_THE_WAY(`"${resolvedPath}"`);
391
- });
392
- }
393
- mkdirSync2(folder);
394
- };
395
- Utils.prototype.writeFileTo = function(path2, content, overwrite, attr) {
396
- const self = this;
397
- if (self.fs.existsSync(path2)) {
398
- if (!overwrite) return false;
399
- var stat = self.fs.statSync(path2);
400
- if (stat.isDirectory()) {
401
- return false;
402
- }
403
- }
404
- var folder = pth.dirname(path2);
405
- if (!self.fs.existsSync(folder)) {
406
- self.makeDir(folder);
407
- }
408
- var fd;
409
- try {
410
- fd = self.fs.openSync(path2, "w", 438);
411
- } catch (e) {
412
- self.fs.chmodSync(path2, 438);
413
- fd = self.fs.openSync(path2, "w", 438);
414
- }
415
- if (fd) {
416
- try {
417
- self.fs.writeSync(fd, content, 0, content.length, 0);
418
- } finally {
419
- self.fs.closeSync(fd);
420
- }
421
- }
422
- self.fs.chmodSync(path2, attr || 438);
423
- return true;
424
- };
425
- Utils.prototype.writeFileToAsync = function(path2, content, overwrite, attr, callback) {
426
- if (typeof attr === "function") {
427
- callback = attr;
428
- attr = void 0;
429
- }
430
- const self = this;
431
- self.fs.exists(path2, function(exist) {
432
- if (exist && !overwrite) return callback(false);
433
- self.fs.stat(path2, function(err, stat) {
434
- if (exist && stat.isDirectory()) {
435
- return callback(false);
436
- }
437
- var folder = pth.dirname(path2);
438
- self.fs.exists(folder, function(exists) {
439
- if (!exists) self.makeDir(folder);
440
- self.fs.open(path2, "w", 438, function(err2, fd) {
441
- if (err2) {
442
- self.fs.chmod(path2, 438, function() {
443
- self.fs.open(path2, "w", 438, function(err3, fd2) {
444
- self.fs.write(fd2, content, 0, content.length, 0, function() {
445
- self.fs.close(fd2, function() {
446
- self.fs.chmod(path2, attr || 438, function() {
447
- callback(true);
448
- });
449
- });
450
- });
451
- });
452
- });
453
- } else if (fd) {
454
- self.fs.write(fd, content, 0, content.length, 0, function() {
455
- self.fs.close(fd, function() {
456
- self.fs.chmod(path2, attr || 438, function() {
457
- callback(true);
458
- });
459
- });
460
- });
461
- } else {
462
- self.fs.chmod(path2, attr || 438, function() {
463
- callback(true);
464
- });
465
- }
466
- });
467
- });
468
- });
469
- });
470
- };
471
- Utils.prototype.findFiles = function(path2) {
472
- const self = this;
473
- function findSync(dir, pattern, recursive) {
474
- let files = [];
475
- self.fs.readdirSync(dir).forEach(function(file) {
476
- const path3 = pth.join(dir, file);
477
- const stat = self.fs.statSync(path3);
478
- {
479
- files.push(pth.normalize(path3) + (stat.isDirectory() ? self.sep : ""));
480
- }
481
- if (stat.isDirectory() && recursive) files = files.concat(findSync(path3, pattern, recursive));
482
- });
483
- return files;
484
- }
485
- return findSync(path2, void 0, true);
486
- };
487
- Utils.prototype.findFilesAsync = function(dir, cb) {
488
- const self = this;
489
- let results = [];
490
- self.fs.readdir(dir, function(err, list) {
491
- if (err) return cb(err);
492
- let list_length = list.length;
493
- if (!list_length) return cb(null, results);
494
- list.forEach(function(file) {
495
- file = pth.join(dir, file);
496
- self.fs.stat(file, function(err2, stat) {
497
- if (err2) return cb(err2);
498
- if (stat) {
499
- results.push(pth.normalize(file) + (stat.isDirectory() ? self.sep : ""));
500
- if (stat.isDirectory()) {
501
- self.findFilesAsync(file, function(err3, res) {
502
- if (err3) return cb(err3);
503
- results = results.concat(res);
504
- if (!--list_length) cb(null, results);
505
- });
506
- } else {
507
- if (!--list_length) cb(null, results);
508
- }
509
- }
510
- });
511
- });
512
- });
513
- };
514
- Utils.prototype.getAttributes = function() {
515
- };
516
- Utils.prototype.setAttributes = function() {
517
- };
518
- Utils.crc32update = function(crc, byte) {
519
- return crcTable[(crc ^ byte) & 255] ^ crc >>> 8;
520
- };
521
- Utils.crc32 = function(buf) {
522
- if (typeof buf === "string") {
523
- buf = Buffer.from(buf, "utf8");
524
- }
525
- let len = buf.length;
526
- let crc = -1;
527
- for (let off = 0; off < len; ) crc = Utils.crc32update(crc, buf[off++]);
528
- return ~crc >>> 0;
529
- };
530
- Utils.methodToString = function(method) {
531
- switch (method) {
532
- case Constants.STORED:
533
- return "STORED (" + method + ")";
534
- case Constants.DEFLATED:
535
- return "DEFLATED (" + method + ")";
536
- default:
537
- return "UNSUPPORTED (" + method + ")";
538
- }
539
- };
540
- Utils.canonical = function(path2) {
541
- if (!path2) return "";
542
- const safeSuffix = pth.posix.normalize("/" + path2.split("\\").join("/"));
543
- return pth.join(".", safeSuffix);
544
- };
545
- Utils.zipnamefix = function(path2) {
546
- if (!path2) return "";
547
- const safeSuffix = pth.posix.normalize("/" + path2.split("\\").join("/"));
548
- return pth.posix.join(".", safeSuffix);
549
- };
550
- Utils.findLast = function(arr, callback) {
551
- if (!Array.isArray(arr)) throw new TypeError("arr is not array");
552
- const len = arr.length >>> 0;
553
- for (let i = len - 1; i >= 0; i--) {
554
- if (callback(arr[i], i, arr)) {
555
- return arr[i];
556
- }
557
- }
558
- return void 0;
559
- };
560
- Utils.sanitize = function(prefix, name) {
561
- prefix = pth.resolve(pth.normalize(prefix));
562
- var parts = name.split("/");
563
- for (var i = 0, l = parts.length; i < l; i++) {
564
- var path2 = pth.normalize(pth.join(prefix, parts.slice(i, l).join(pth.sep)));
565
- if (path2.indexOf(prefix) === 0) {
566
- return path2;
567
- }
568
- }
569
- return pth.normalize(pth.join(prefix, pth.basename(name)));
570
- };
571
- Utils.toBuffer = function toBuffer(input, encoder) {
572
- if (Buffer.isBuffer(input)) {
573
- return input;
574
- } else if (input instanceof Uint8Array) {
575
- return Buffer.from(input);
576
- } else {
577
- return typeof input === "string" ? encoder(input) : Buffer.alloc(0);
578
- }
579
- };
580
- Utils.readBigUInt64LE = function(buffer, index) {
581
- var slice = Buffer.from(buffer.slice(index, index + 8));
582
- slice.swap64();
583
- return parseInt(`0x${slice.toString("hex")}`);
584
- };
585
- Utils.fromDOS2Date = function(val) {
586
- 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);
587
- };
588
- Utils.fromDate2DOS = function(val) {
589
- let date = 0;
590
- let time = 0;
591
- if (val.getFullYear() > 1979) {
592
- date = (val.getFullYear() - 1980 & 127) << 9 | val.getMonth() + 1 << 5 | val.getDate();
593
- time = val.getHours() << 11 | val.getMinutes() << 5 | val.getSeconds() >> 1;
594
- }
595
- return date << 16 | time;
596
- };
597
- Utils.isWin = isWin;
598
- Utils.crcTable = crcTable;
599
- }
600
- });
601
-
602
- // ../../../node_modules/adm-zip/util/fattr.js
603
- var require_fattr = __commonJS({
604
- "../../../node_modules/adm-zip/util/fattr.js"(exports, module) {
605
- var pth = __require("path");
606
- module.exports = function(path2, { fs: fs2 }) {
607
- var _path = path2 || "", _obj = newAttr(), _stat = null;
608
- function newAttr() {
609
- return {
610
- directory: false,
611
- readonly: false,
612
- hidden: false,
613
- executable: false,
614
- mtime: 0,
615
- atime: 0
616
- };
617
- }
618
- if (_path && fs2.existsSync(_path)) {
619
- _stat = fs2.statSync(_path);
620
- _obj.directory = _stat.isDirectory();
621
- _obj.mtime = _stat.mtime;
622
- _obj.atime = _stat.atime;
623
- _obj.executable = (73 & _stat.mode) !== 0;
624
- _obj.readonly = (128 & _stat.mode) === 0;
625
- _obj.hidden = pth.basename(_path)[0] === ".";
626
- } else {
627
- console.warn("Invalid path: " + _path);
628
- }
629
- return {
630
- get directory() {
631
- return _obj.directory;
632
- },
633
- get readOnly() {
634
- return _obj.readonly;
635
- },
636
- get hidden() {
637
- return _obj.hidden;
638
- },
639
- get mtime() {
640
- return _obj.mtime;
641
- },
642
- get atime() {
643
- return _obj.atime;
644
- },
645
- get executable() {
646
- return _obj.executable;
647
- },
648
- decodeAttributes: function() {
649
- },
650
- encodeAttributes: function() {
651
- },
652
- toJSON: function() {
653
- return {
654
- path: _path,
655
- isDirectory: _obj.directory,
656
- isReadOnly: _obj.readonly,
657
- isHidden: _obj.hidden,
658
- isExecutable: _obj.executable,
659
- mTime: _obj.mtime,
660
- aTime: _obj.atime
661
- };
662
- },
663
- toString: function() {
664
- return JSON.stringify(this.toJSON(), null, " ");
665
- }
666
- };
667
- };
668
- }
669
- });
670
-
671
- // ../../../node_modules/adm-zip/util/decoder.js
672
- var require_decoder = __commonJS({
673
- "../../../node_modules/adm-zip/util/decoder.js"(exports, module) {
674
- module.exports = {
675
- efs: true,
676
- encode: (data) => Buffer.from(data, "utf8"),
677
- decode: (data) => data.toString("utf8")
678
- };
679
- }
680
- });
681
-
682
- // ../../../node_modules/adm-zip/util/index.js
683
- var require_util = __commonJS({
684
- "../../../node_modules/adm-zip/util/index.js"(exports, module) {
685
- module.exports = require_utils();
686
- module.exports.Constants = require_constants();
687
- module.exports.Errors = require_errors();
688
- module.exports.FileAttr = require_fattr();
689
- module.exports.decoder = require_decoder();
690
- }
691
- });
692
-
693
- // ../../../node_modules/adm-zip/headers/entryHeader.js
694
- var require_entryHeader = __commonJS({
695
- "../../../node_modules/adm-zip/headers/entryHeader.js"(exports, module) {
696
- var Utils = require_util();
697
- var Constants = Utils.Constants;
698
- module.exports = function() {
699
- 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;
700
- _verMade |= Utils.isWin ? 2560 : 768;
701
- _flags |= Constants.FLG_EFS;
702
- const _localHeader = {
703
- extraLen: 0
704
- };
705
- const uint32 = (val) => Math.max(0, val) >>> 0;
706
- const uint8 = (val) => Math.max(0, val) & 255;
707
- _time = Utils.fromDate2DOS(/* @__PURE__ */ new Date());
708
- return {
709
- get made() {
710
- return _verMade;
711
- },
712
- set made(val) {
713
- _verMade = val;
714
- },
715
- get version() {
716
- return _version;
717
- },
718
- set version(val) {
719
- _version = val;
720
- },
721
- get flags() {
722
- return _flags;
723
- },
724
- set flags(val) {
725
- _flags = val;
726
- },
727
- get flags_efs() {
728
- return (_flags & Constants.FLG_EFS) > 0;
729
- },
730
- set flags_efs(val) {
731
- if (val) {
732
- _flags |= Constants.FLG_EFS;
733
- } else {
734
- _flags &= ~Constants.FLG_EFS;
735
- }
736
- },
737
- get flags_desc() {
738
- return (_flags & Constants.FLG_DESC) > 0;
739
- },
740
- set flags_desc(val) {
741
- if (val) {
742
- _flags |= Constants.FLG_DESC;
743
- } else {
744
- _flags &= ~Constants.FLG_DESC;
745
- }
746
- },
747
- get method() {
748
- return _method;
749
- },
750
- set method(val) {
751
- switch (val) {
752
- case Constants.STORED:
753
- this.version = 10;
754
- case Constants.DEFLATED:
755
- default:
756
- this.version = 20;
757
- }
758
- _method = val;
759
- },
760
- get time() {
761
- return Utils.fromDOS2Date(this.timeval);
762
- },
763
- set time(val) {
764
- this.timeval = Utils.fromDate2DOS(val);
765
- },
766
- get timeval() {
767
- return _time;
768
- },
769
- set timeval(val) {
770
- _time = uint32(val);
771
- },
772
- get timeHighByte() {
773
- return uint8(_time >>> 8);
774
- },
775
- get crc() {
776
- return _crc;
777
- },
778
- set crc(val) {
779
- _crc = uint32(val);
780
- },
781
- get compressedSize() {
782
- return _compressedSize;
783
- },
784
- set compressedSize(val) {
785
- _compressedSize = uint32(val);
786
- },
787
- get size() {
788
- return _size;
789
- },
790
- set size(val) {
791
- _size = uint32(val);
792
- },
793
- get fileNameLength() {
794
- return _fnameLen;
795
- },
796
- set fileNameLength(val) {
797
- _fnameLen = val;
798
- },
799
- get extraLength() {
800
- return _extraLen;
801
- },
802
- set extraLength(val) {
803
- _extraLen = val;
804
- },
805
- get extraLocalLength() {
806
- return _localHeader.extraLen;
807
- },
808
- set extraLocalLength(val) {
809
- _localHeader.extraLen = val;
810
- },
811
- get commentLength() {
812
- return _comLen;
813
- },
814
- set commentLength(val) {
815
- _comLen = val;
816
- },
817
- get diskNumStart() {
818
- return _diskStart;
819
- },
820
- set diskNumStart(val) {
821
- _diskStart = uint32(val);
822
- },
823
- get inAttr() {
824
- return _inattr;
825
- },
826
- set inAttr(val) {
827
- _inattr = uint32(val);
828
- },
829
- get attr() {
830
- return _attr;
831
- },
832
- set attr(val) {
833
- _attr = uint32(val);
834
- },
835
- // get Unix file permissions
836
- get fileAttr() {
837
- return (_attr || 0) >> 16 & 4095;
838
- },
839
- get offset() {
840
- return _offset;
841
- },
842
- set offset(val) {
843
- _offset = uint32(val);
844
- },
845
- get encrypted() {
846
- return (_flags & Constants.FLG_ENC) === Constants.FLG_ENC;
847
- },
848
- get centralHeaderSize() {
849
- return Constants.CENHDR + _fnameLen + _extraLen + _comLen;
850
- },
851
- get realDataOffset() {
852
- return _offset + Constants.LOCHDR + _localHeader.fnameLen + _localHeader.extraLen;
853
- },
854
- get localHeader() {
855
- return _localHeader;
856
- },
857
- loadLocalHeaderFromBinary: function(input) {
858
- var data = input.slice(_offset, _offset + Constants.LOCHDR);
859
- if (data.readUInt32LE(0) !== Constants.LOCSIG) {
860
- throw Utils.Errors.INVALID_LOC();
861
- }
862
- _localHeader.version = data.readUInt16LE(Constants.LOCVER);
863
- _localHeader.flags = data.readUInt16LE(Constants.LOCFLG);
864
- _localHeader.method = data.readUInt16LE(Constants.LOCHOW);
865
- _localHeader.time = data.readUInt32LE(Constants.LOCTIM);
866
- _localHeader.crc = data.readUInt32LE(Constants.LOCCRC);
867
- _localHeader.compressedSize = data.readUInt32LE(Constants.LOCSIZ);
868
- _localHeader.size = data.readUInt32LE(Constants.LOCLEN);
869
- _localHeader.fnameLen = data.readUInt16LE(Constants.LOCNAM);
870
- _localHeader.extraLen = data.readUInt16LE(Constants.LOCEXT);
871
- const extraStart = _offset + Constants.LOCHDR + _localHeader.fnameLen;
872
- const extraEnd = extraStart + _localHeader.extraLen;
873
- return input.slice(extraStart, extraEnd);
874
- },
875
- loadFromBinary: function(data) {
876
- if (data.length !== Constants.CENHDR || data.readUInt32LE(0) !== Constants.CENSIG) {
877
- throw Utils.Errors.INVALID_CEN();
878
- }
879
- _verMade = data.readUInt16LE(Constants.CENVEM);
880
- _version = data.readUInt16LE(Constants.CENVER);
881
- _flags = data.readUInt16LE(Constants.CENFLG);
882
- _method = data.readUInt16LE(Constants.CENHOW);
883
- _time = data.readUInt32LE(Constants.CENTIM);
884
- _crc = data.readUInt32LE(Constants.CENCRC);
885
- _compressedSize = data.readUInt32LE(Constants.CENSIZ);
886
- _size = data.readUInt32LE(Constants.CENLEN);
887
- _fnameLen = data.readUInt16LE(Constants.CENNAM);
888
- _extraLen = data.readUInt16LE(Constants.CENEXT);
889
- _comLen = data.readUInt16LE(Constants.CENCOM);
890
- _diskStart = data.readUInt16LE(Constants.CENDSK);
891
- _inattr = data.readUInt16LE(Constants.CENATT);
892
- _attr = data.readUInt32LE(Constants.CENATX);
893
- _offset = data.readUInt32LE(Constants.CENOFF);
894
- },
895
- localHeaderToBinary: function() {
896
- var data = Buffer.alloc(Constants.LOCHDR);
897
- data.writeUInt32LE(Constants.LOCSIG, 0);
898
- data.writeUInt16LE(_version, Constants.LOCVER);
899
- data.writeUInt16LE(_flags, Constants.LOCFLG);
900
- data.writeUInt16LE(_method, Constants.LOCHOW);
901
- data.writeUInt32LE(_time, Constants.LOCTIM);
902
- data.writeUInt32LE(_crc, Constants.LOCCRC);
903
- data.writeUInt32LE(_compressedSize, Constants.LOCSIZ);
904
- data.writeUInt32LE(_size, Constants.LOCLEN);
905
- data.writeUInt16LE(_fnameLen, Constants.LOCNAM);
906
- data.writeUInt16LE(_localHeader.extraLen, Constants.LOCEXT);
907
- return data;
908
- },
909
- centralHeaderToBinary: function() {
910
- var data = Buffer.alloc(Constants.CENHDR + _fnameLen + _extraLen + _comLen);
911
- data.writeUInt32LE(Constants.CENSIG, 0);
912
- data.writeUInt16LE(_verMade, Constants.CENVEM);
913
- data.writeUInt16LE(_version, Constants.CENVER);
914
- data.writeUInt16LE(_flags, Constants.CENFLG);
915
- data.writeUInt16LE(_method, Constants.CENHOW);
916
- data.writeUInt32LE(_time, Constants.CENTIM);
917
- data.writeUInt32LE(_crc, Constants.CENCRC);
918
- data.writeUInt32LE(_compressedSize, Constants.CENSIZ);
919
- data.writeUInt32LE(_size, Constants.CENLEN);
920
- data.writeUInt16LE(_fnameLen, Constants.CENNAM);
921
- data.writeUInt16LE(_extraLen, Constants.CENEXT);
922
- data.writeUInt16LE(_comLen, Constants.CENCOM);
923
- data.writeUInt16LE(_diskStart, Constants.CENDSK);
924
- data.writeUInt16LE(_inattr, Constants.CENATT);
925
- data.writeUInt32LE(_attr, Constants.CENATX);
926
- data.writeUInt32LE(_offset, Constants.CENOFF);
927
- return data;
928
- },
929
- toJSON: function() {
930
- const bytes = function(nr) {
931
- return nr + " bytes";
932
- };
933
- return {
934
- made: _verMade,
935
- version: _version,
936
- flags: _flags,
937
- method: Utils.methodToString(_method),
938
- time: this.time,
939
- crc: "0x" + _crc.toString(16).toUpperCase(),
940
- compressedSize: bytes(_compressedSize),
941
- size: bytes(_size),
942
- fileNameLength: bytes(_fnameLen),
943
- extraLength: bytes(_extraLen),
944
- commentLength: bytes(_comLen),
945
- diskNumStart: _diskStart,
946
- inAttr: _inattr,
947
- attr: _attr,
948
- offset: _offset,
949
- centralHeaderSize: bytes(Constants.CENHDR + _fnameLen + _extraLen + _comLen)
950
- };
951
- },
952
- toString: function() {
953
- return JSON.stringify(this.toJSON(), null, " ");
954
- }
955
- };
956
- };
957
- }
958
- });
959
-
960
- // ../../../node_modules/adm-zip/headers/mainHeader.js
961
- var require_mainHeader = __commonJS({
962
- "../../../node_modules/adm-zip/headers/mainHeader.js"(exports, module) {
963
- var Utils = require_util();
964
- var Constants = Utils.Constants;
965
- module.exports = function() {
966
- var _volumeEntries = 0, _totalEntries = 0, _size = 0, _offset = 0, _commentLength = 0;
967
- return {
968
- get diskEntries() {
969
- return _volumeEntries;
970
- },
971
- set diskEntries(val) {
972
- _volumeEntries = _totalEntries = val;
973
- },
974
- get totalEntries() {
975
- return _totalEntries;
976
- },
977
- set totalEntries(val) {
978
- _totalEntries = _volumeEntries = val;
979
- },
980
- get size() {
981
- return _size;
982
- },
983
- set size(val) {
984
- _size = val;
985
- },
986
- get offset() {
987
- return _offset;
988
- },
989
- set offset(val) {
990
- _offset = val;
991
- },
992
- get commentLength() {
993
- return _commentLength;
994
- },
995
- set commentLength(val) {
996
- _commentLength = val;
997
- },
998
- get mainHeaderSize() {
999
- return Constants.ENDHDR + _commentLength;
1000
- },
1001
- loadFromBinary: function(data) {
1002
- if ((data.length !== Constants.ENDHDR || data.readUInt32LE(0) !== Constants.ENDSIG) && (data.length < Constants.ZIP64HDR || data.readUInt32LE(0) !== Constants.ZIP64SIG)) {
1003
- throw Utils.Errors.INVALID_END();
1004
- }
1005
- if (data.readUInt32LE(0) === Constants.ENDSIG) {
1006
- _volumeEntries = data.readUInt16LE(Constants.ENDSUB);
1007
- _totalEntries = data.readUInt16LE(Constants.ENDTOT);
1008
- _size = data.readUInt32LE(Constants.ENDSIZ);
1009
- _offset = data.readUInt32LE(Constants.ENDOFF);
1010
- _commentLength = data.readUInt16LE(Constants.ENDCOM);
1011
- } else {
1012
- _volumeEntries = Utils.readBigUInt64LE(data, Constants.ZIP64SUB);
1013
- _totalEntries = Utils.readBigUInt64LE(data, Constants.ZIP64TOT);
1014
- _size = Utils.readBigUInt64LE(data, Constants.ZIP64SIZE);
1015
- _offset = Utils.readBigUInt64LE(data, Constants.ZIP64OFF);
1016
- _commentLength = 0;
1017
- }
1018
- },
1019
- toBinary: function() {
1020
- var b = Buffer.alloc(Constants.ENDHDR + _commentLength);
1021
- b.writeUInt32LE(Constants.ENDSIG, 0);
1022
- b.writeUInt32LE(0, 4);
1023
- b.writeUInt16LE(_volumeEntries, Constants.ENDSUB);
1024
- b.writeUInt16LE(_totalEntries, Constants.ENDTOT);
1025
- b.writeUInt32LE(_size, Constants.ENDSIZ);
1026
- b.writeUInt32LE(_offset, Constants.ENDOFF);
1027
- b.writeUInt16LE(_commentLength, Constants.ENDCOM);
1028
- b.fill(" ", Constants.ENDHDR);
1029
- return b;
1030
- },
1031
- toJSON: function() {
1032
- const offset = function(nr, len) {
1033
- let offs = nr.toString(16).toUpperCase();
1034
- while (offs.length < len) offs = "0" + offs;
1035
- return "0x" + offs;
1036
- };
1037
- return {
1038
- diskEntries: _volumeEntries,
1039
- totalEntries: _totalEntries,
1040
- size: _size + " bytes",
1041
- offset: offset(_offset, 4),
1042
- commentLength: _commentLength
1043
- };
1044
- },
1045
- toString: function() {
1046
- return JSON.stringify(this.toJSON(), null, " ");
1047
- }
1048
- };
1049
- };
1050
- }
1051
- });
1052
-
1053
- // ../../../node_modules/adm-zip/headers/index.js
1054
- var require_headers = __commonJS({
1055
- "../../../node_modules/adm-zip/headers/index.js"(exports) {
1056
- exports.EntryHeader = require_entryHeader();
1057
- exports.MainHeader = require_mainHeader();
1058
- }
1059
- });
1060
-
1061
- // ../../../node_modules/adm-zip/methods/deflater.js
1062
- var require_deflater = __commonJS({
1063
- "../../../node_modules/adm-zip/methods/deflater.js"(exports, module) {
1064
- module.exports = function(inbuf) {
1065
- var zlib = __require("zlib");
1066
- var opts = { chunkSize: (parseInt(inbuf.length / 1024) + 1) * 1024 };
1067
- return {
1068
- deflate: function() {
1069
- return zlib.deflateRawSync(inbuf, opts);
1070
- },
1071
- deflateAsync: function(callback) {
1072
- var tmp = zlib.createDeflateRaw(opts), parts = [], total = 0;
1073
- tmp.on("data", function(data) {
1074
- parts.push(data);
1075
- total += data.length;
1076
- });
1077
- tmp.on("end", function() {
1078
- var buf = Buffer.alloc(total), written = 0;
1079
- buf.fill(0);
1080
- for (var i = 0; i < parts.length; i++) {
1081
- var part = parts[i];
1082
- part.copy(buf, written);
1083
- written += part.length;
1084
- }
1085
- callback && callback(buf);
1086
- });
1087
- tmp.end(inbuf);
1088
- }
1089
- };
1090
- };
1091
- }
1092
- });
1093
-
1094
- // ../../../node_modules/adm-zip/methods/inflater.js
1095
- var require_inflater = __commonJS({
1096
- "../../../node_modules/adm-zip/methods/inflater.js"(exports, module) {
1097
- var version = +(process.versions ? process.versions.node : "").split(".")[0] || 0;
1098
- module.exports = function(inbuf, expectedLength) {
1099
- var zlib = __require("zlib");
1100
- const option = version >= 15 && expectedLength > 0 ? { maxOutputLength: expectedLength } : {};
1101
- return {
1102
- inflate: function() {
1103
- return zlib.inflateRawSync(inbuf, option);
1104
- },
1105
- inflateAsync: function(callback) {
1106
- var tmp = zlib.createInflateRaw(option), parts = [], total = 0;
1107
- tmp.on("data", function(data) {
1108
- parts.push(data);
1109
- total += data.length;
1110
- });
1111
- tmp.on("end", function() {
1112
- var buf = Buffer.alloc(total), written = 0;
1113
- buf.fill(0);
1114
- for (var i = 0; i < parts.length; i++) {
1115
- var part = parts[i];
1116
- part.copy(buf, written);
1117
- written += part.length;
1118
- }
1119
- callback && callback(buf);
1120
- });
1121
- tmp.end(inbuf);
1122
- }
1123
- };
1124
- };
1125
- }
1126
- });
1127
-
1128
- // ../../../node_modules/adm-zip/methods/zipcrypto.js
1129
- var require_zipcrypto = __commonJS({
1130
- "../../../node_modules/adm-zip/methods/zipcrypto.js"(exports, module) {
1131
- var { randomFillSync } = __require("crypto");
1132
- var Errors = require_errors();
1133
- var crctable = new Uint32Array(256).map((t, crc) => {
1134
- for (let j = 0; j < 8; j++) {
1135
- if (0 !== (crc & 1)) {
1136
- crc = crc >>> 1 ^ 3988292384;
1137
- } else {
1138
- crc >>>= 1;
1139
- }
1140
- }
1141
- return crc >>> 0;
1142
- });
1143
- var uMul = (a, b) => Math.imul(a, b) >>> 0;
1144
- var crc32update = (pCrc32, bval) => {
1145
- return crctable[(pCrc32 ^ bval) & 255] ^ pCrc32 >>> 8;
1146
- };
1147
- var genSalt = () => {
1148
- if ("function" === typeof randomFillSync) {
1149
- return randomFillSync(Buffer.alloc(12));
1150
- } else {
1151
- return genSalt.node();
1152
- }
1153
- };
1154
- genSalt.node = () => {
1155
- const salt = Buffer.alloc(12);
1156
- const len = salt.length;
1157
- for (let i = 0; i < len; i++) salt[i] = Math.random() * 256 & 255;
1158
- return salt;
1159
- };
1160
- var config = {
1161
- genSalt
1162
- };
1163
- function Initkeys(pw) {
1164
- const pass = Buffer.isBuffer(pw) ? pw : Buffer.from(pw);
1165
- this.keys = new Uint32Array([305419896, 591751049, 878082192]);
1166
- for (let i = 0; i < pass.length; i++) {
1167
- this.updateKeys(pass[i]);
1168
- }
1169
- }
1170
- Initkeys.prototype.updateKeys = function(byteValue) {
1171
- const keys = this.keys;
1172
- keys[0] = crc32update(keys[0], byteValue);
1173
- keys[1] += keys[0] & 255;
1174
- keys[1] = uMul(keys[1], 134775813) + 1;
1175
- keys[2] = crc32update(keys[2], keys[1] >>> 24);
1176
- return byteValue;
1177
- };
1178
- Initkeys.prototype.next = function() {
1179
- const k = (this.keys[2] | 2) >>> 0;
1180
- return uMul(k, k ^ 1) >> 8 & 255;
1181
- };
1182
- function make_decrypter(pwd) {
1183
- const keys = new Initkeys(pwd);
1184
- return function(data) {
1185
- const result = Buffer.alloc(data.length);
1186
- let pos = 0;
1187
- for (let c of data) {
1188
- result[pos++] = keys.updateKeys(c ^ keys.next());
1189
- }
1190
- return result;
1191
- };
1192
- }
1193
- function make_encrypter(pwd) {
1194
- const keys = new Initkeys(pwd);
1195
- return function(data, result, pos = 0) {
1196
- if (!result) result = Buffer.alloc(data.length);
1197
- for (let c of data) {
1198
- const k = keys.next();
1199
- result[pos++] = c ^ k;
1200
- keys.updateKeys(c);
1201
- }
1202
- return result;
1203
- };
1204
- }
1205
- function decrypt(data, header, pwd) {
1206
- if (!data || !Buffer.isBuffer(data) || data.length < 12) {
1207
- return Buffer.alloc(0);
1208
- }
1209
- const decrypter = make_decrypter(pwd);
1210
- const salt = decrypter(data.slice(0, 12));
1211
- const verifyByte = (header.flags & 8) === 8 ? header.timeHighByte : header.crc >>> 24;
1212
- if (salt[11] !== verifyByte) {
1213
- throw Errors.WRONG_PASSWORD();
1214
- }
1215
- return decrypter(data.slice(12));
1216
- }
1217
- function _salter(data) {
1218
- if (Buffer.isBuffer(data) && data.length >= 12) {
1219
- config.genSalt = function() {
1220
- return data.slice(0, 12);
1221
- };
1222
- } else if (data === "node") {
1223
- config.genSalt = genSalt.node;
1224
- } else {
1225
- config.genSalt = genSalt;
1226
- }
1227
- }
1228
- function encrypt(data, header, pwd, oldlike = false) {
1229
- if (data == null) data = Buffer.alloc(0);
1230
- if (!Buffer.isBuffer(data)) data = Buffer.from(data.toString());
1231
- const encrypter = make_encrypter(pwd);
1232
- const salt = config.genSalt();
1233
- salt[11] = header.crc >>> 24 & 255;
1234
- if (oldlike) salt[10] = header.crc >>> 16 & 255;
1235
- const result = Buffer.alloc(data.length + 12);
1236
- encrypter(salt, result);
1237
- return encrypter(data, result, 12);
1238
- }
1239
- module.exports = { decrypt, encrypt, _salter };
1240
- }
1241
- });
1242
-
1243
- // ../../../node_modules/adm-zip/methods/index.js
1244
- var require_methods = __commonJS({
1245
- "../../../node_modules/adm-zip/methods/index.js"(exports) {
1246
- exports.Deflater = require_deflater();
1247
- exports.Inflater = require_inflater();
1248
- exports.ZipCrypto = require_zipcrypto();
1249
- }
1250
- });
1251
-
1252
- // ../../../node_modules/adm-zip/zipEntry.js
1253
- var require_zipEntry = __commonJS({
1254
- "../../../node_modules/adm-zip/zipEntry.js"(exports, module) {
1255
- var Utils = require_util();
1256
- var Headers = require_headers();
1257
- var Constants = Utils.Constants;
1258
- var Methods = require_methods();
1259
- module.exports = function(options, input) {
1260
- 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;
1261
- const opts = options;
1262
- const decoder = typeof opts.decoder === "object" ? opts.decoder : Utils.decoder;
1263
- _efs = decoder.hasOwnProperty("efs") ? decoder.efs : false;
1264
- function getCompressedDataFromZip() {
1265
- if (!input || !(input instanceof Uint8Array)) {
1266
- return Buffer.alloc(0);
1267
- }
1268
- _extralocal = _centralHeader.loadLocalHeaderFromBinary(input);
1269
- return input.slice(_centralHeader.realDataOffset, _centralHeader.realDataOffset + _centralHeader.compressedSize);
1270
- }
1271
- function crc32OK(data) {
1272
- if (!_centralHeader.flags_desc) {
1273
- if (Utils.crc32(data) !== _centralHeader.localHeader.crc) {
1274
- return false;
1275
- }
1276
- } else {
1277
- const descriptor = {};
1278
- const dataEndOffset = _centralHeader.realDataOffset + _centralHeader.compressedSize;
1279
- if (input.readUInt32LE(dataEndOffset) == Constants.LOCSIG || input.readUInt32LE(dataEndOffset) == Constants.CENSIG) {
1280
- throw Utils.Errors.DESCRIPTOR_NOT_EXIST();
1281
- }
1282
- if (input.readUInt32LE(dataEndOffset) == Constants.EXTSIG) {
1283
- descriptor.crc = input.readUInt32LE(dataEndOffset + Constants.EXTCRC);
1284
- descriptor.compressedSize = input.readUInt32LE(dataEndOffset + Constants.EXTSIZ);
1285
- descriptor.size = input.readUInt32LE(dataEndOffset + Constants.EXTLEN);
1286
- } else if (input.readUInt16LE(dataEndOffset + 12) === 19280) {
1287
- descriptor.crc = input.readUInt32LE(dataEndOffset + Constants.EXTCRC - 4);
1288
- descriptor.compressedSize = input.readUInt32LE(dataEndOffset + Constants.EXTSIZ - 4);
1289
- descriptor.size = input.readUInt32LE(dataEndOffset + Constants.EXTLEN - 4);
1290
- } else {
1291
- throw Utils.Errors.DESCRIPTOR_UNKNOWN();
1292
- }
1293
- if (descriptor.compressedSize !== _centralHeader.compressedSize || descriptor.size !== _centralHeader.size || descriptor.crc !== _centralHeader.crc) {
1294
- throw Utils.Errors.DESCRIPTOR_FAULTY();
1295
- }
1296
- if (Utils.crc32(data) !== descriptor.crc) {
1297
- return false;
1298
- }
1299
- }
1300
- return true;
1301
- }
1302
- function decompress(async, callback, pass) {
1303
- if (typeof callback === "undefined" && typeof async === "string") {
1304
- pass = async;
1305
- async = void 0;
1306
- }
1307
- if (_isDirectory) {
1308
- if (async && callback) {
1309
- callback(Buffer.alloc(0), Utils.Errors.DIRECTORY_CONTENT_ERROR());
1310
- }
1311
- return Buffer.alloc(0);
1312
- }
1313
- var compressedData = getCompressedDataFromZip();
1314
- if (compressedData.length === 0) {
1315
- if (async && callback) callback(compressedData);
1316
- return compressedData;
1317
- }
1318
- if (_centralHeader.encrypted) {
1319
- if ("string" !== typeof pass && !Buffer.isBuffer(pass)) {
1320
- throw Utils.Errors.INVALID_PASS_PARAM();
1321
- }
1322
- compressedData = Methods.ZipCrypto.decrypt(compressedData, _centralHeader, pass);
1323
- }
1324
- var data = Buffer.alloc(_centralHeader.size);
1325
- switch (_centralHeader.method) {
1326
- case Utils.Constants.STORED:
1327
- compressedData.copy(data);
1328
- if (!crc32OK(data)) {
1329
- if (async && callback) callback(data, Utils.Errors.BAD_CRC());
1330
- throw Utils.Errors.BAD_CRC();
1331
- } else {
1332
- if (async && callback) callback(data);
1333
- return data;
1334
- }
1335
- case Utils.Constants.DEFLATED:
1336
- var inflater = new Methods.Inflater(compressedData, _centralHeader.size);
1337
- if (!async) {
1338
- const result = inflater.inflate(data);
1339
- result.copy(data, 0);
1340
- if (!crc32OK(data)) {
1341
- throw Utils.Errors.BAD_CRC(`"${decoder.decode(_entryName)}"`);
1342
- }
1343
- return data;
1344
- } else {
1345
- inflater.inflateAsync(function(result) {
1346
- result.copy(result, 0);
1347
- if (callback) {
1348
- if (!crc32OK(result)) {
1349
- callback(result, Utils.Errors.BAD_CRC());
1350
- } else {
1351
- callback(result);
1352
- }
1353
- }
1354
- });
1355
- }
1356
- break;
1357
- default:
1358
- if (async && callback) callback(Buffer.alloc(0), Utils.Errors.UNKNOWN_METHOD());
1359
- throw Utils.Errors.UNKNOWN_METHOD();
1360
- }
1361
- }
1362
- function compress(async, callback) {
1363
- if ((!uncompressedData || !uncompressedData.length) && Buffer.isBuffer(input)) {
1364
- if (async && callback) callback(getCompressedDataFromZip());
1365
- return getCompressedDataFromZip();
1366
- }
1367
- if (uncompressedData.length && !_isDirectory) {
1368
- var compressedData;
1369
- switch (_centralHeader.method) {
1370
- case Utils.Constants.STORED:
1371
- _centralHeader.compressedSize = _centralHeader.size;
1372
- compressedData = Buffer.alloc(uncompressedData.length);
1373
- uncompressedData.copy(compressedData);
1374
- if (async && callback) callback(compressedData);
1375
- return compressedData;
1376
- default:
1377
- case Utils.Constants.DEFLATED:
1378
- var deflater = new Methods.Deflater(uncompressedData);
1379
- if (!async) {
1380
- var deflated = deflater.deflate();
1381
- _centralHeader.compressedSize = deflated.length;
1382
- return deflated;
1383
- } else {
1384
- deflater.deflateAsync(function(data) {
1385
- compressedData = Buffer.alloc(data.length);
1386
- _centralHeader.compressedSize = data.length;
1387
- data.copy(compressedData);
1388
- callback && callback(compressedData);
1389
- });
1390
- }
1391
- deflater = null;
1392
- break;
1393
- }
1394
- } else if (async && callback) {
1395
- callback(Buffer.alloc(0));
1396
- } else {
1397
- return Buffer.alloc(0);
1398
- }
1399
- }
1400
- function readUInt64LE(buffer, offset) {
1401
- return (buffer.readUInt32LE(offset + 4) << 4) + buffer.readUInt32LE(offset);
1402
- }
1403
- function parseExtra(data) {
1404
- try {
1405
- var offset = 0;
1406
- var signature, size, part;
1407
- while (offset + 4 < data.length) {
1408
- signature = data.readUInt16LE(offset);
1409
- offset += 2;
1410
- size = data.readUInt16LE(offset);
1411
- offset += 2;
1412
- part = data.slice(offset, offset + size);
1413
- offset += size;
1414
- if (Constants.ID_ZIP64 === signature) {
1415
- parseZip64ExtendedInformation(part);
1416
- }
1417
- }
1418
- } catch (error) {
1419
- throw Utils.Errors.EXTRA_FIELD_PARSE_ERROR();
1420
- }
1421
- }
1422
- function parseZip64ExtendedInformation(data) {
1423
- var size, compressedSize, offset, diskNumStart;
1424
- if (data.length >= Constants.EF_ZIP64_SCOMP) {
1425
- size = readUInt64LE(data, Constants.EF_ZIP64_SUNCOMP);
1426
- if (_centralHeader.size === Constants.EF_ZIP64_OR_32) {
1427
- _centralHeader.size = size;
1428
- }
1429
- }
1430
- if (data.length >= Constants.EF_ZIP64_RHO) {
1431
- compressedSize = readUInt64LE(data, Constants.EF_ZIP64_SCOMP);
1432
- if (_centralHeader.compressedSize === Constants.EF_ZIP64_OR_32) {
1433
- _centralHeader.compressedSize = compressedSize;
1434
- }
1435
- }
1436
- if (data.length >= Constants.EF_ZIP64_DSN) {
1437
- offset = readUInt64LE(data, Constants.EF_ZIP64_RHO);
1438
- if (_centralHeader.offset === Constants.EF_ZIP64_OR_32) {
1439
- _centralHeader.offset = offset;
1440
- }
1441
- }
1442
- if (data.length >= Constants.EF_ZIP64_DSN + 4) {
1443
- diskNumStart = data.readUInt32LE(Constants.EF_ZIP64_DSN);
1444
- if (_centralHeader.diskNumStart === Constants.EF_ZIP64_OR_16) {
1445
- _centralHeader.diskNumStart = diskNumStart;
1446
- }
1447
- }
1448
- }
1449
- return {
1450
- get entryName() {
1451
- return decoder.decode(_entryName);
1452
- },
1453
- get rawEntryName() {
1454
- return _entryName;
1455
- },
1456
- set entryName(val) {
1457
- _entryName = Utils.toBuffer(val, decoder.encode);
1458
- var lastChar = _entryName[_entryName.length - 1];
1459
- _isDirectory = lastChar === 47 || lastChar === 92;
1460
- _centralHeader.fileNameLength = _entryName.length;
1461
- },
1462
- get efs() {
1463
- if (typeof _efs === "function") {
1464
- return _efs(this.entryName);
1465
- } else {
1466
- return _efs;
1467
- }
1468
- },
1469
- get extra() {
1470
- return _extra;
1471
- },
1472
- set extra(val) {
1473
- _extra = val;
1474
- _centralHeader.extraLength = val.length;
1475
- parseExtra(val);
1476
- },
1477
- get comment() {
1478
- return decoder.decode(_comment);
1479
- },
1480
- set comment(val) {
1481
- _comment = Utils.toBuffer(val, decoder.encode);
1482
- _centralHeader.commentLength = _comment.length;
1483
- if (_comment.length > 65535) throw Utils.Errors.COMMENT_TOO_LONG();
1484
- },
1485
- get name() {
1486
- var n = decoder.decode(_entryName);
1487
- return _isDirectory ? n.substr(n.length - 1).split("/").pop() : n.split("/").pop();
1488
- },
1489
- get isDirectory() {
1490
- return _isDirectory;
1491
- },
1492
- getCompressedData: function() {
1493
- return compress(false, null);
1494
- },
1495
- getCompressedDataAsync: function(callback) {
1496
- compress(true, callback);
1497
- },
1498
- setData: function(value) {
1499
- uncompressedData = Utils.toBuffer(value, Utils.decoder.encode);
1500
- if (!_isDirectory && uncompressedData.length) {
1501
- _centralHeader.size = uncompressedData.length;
1502
- _centralHeader.method = Utils.Constants.DEFLATED;
1503
- _centralHeader.crc = Utils.crc32(value);
1504
- _centralHeader.changed = true;
1505
- } else {
1506
- _centralHeader.method = Utils.Constants.STORED;
1507
- }
1508
- },
1509
- getData: function(pass) {
1510
- if (_centralHeader.changed) {
1511
- return uncompressedData;
1512
- } else {
1513
- return decompress(false, null, pass);
1514
- }
1515
- },
1516
- getDataAsync: function(callback, pass) {
1517
- if (_centralHeader.changed) {
1518
- callback(uncompressedData);
1519
- } else {
1520
- decompress(true, callback, pass);
1521
- }
1522
- },
1523
- set attr(attr) {
1524
- _centralHeader.attr = attr;
1525
- },
1526
- get attr() {
1527
- return _centralHeader.attr;
1528
- },
1529
- set header(data) {
1530
- _centralHeader.loadFromBinary(data);
1531
- },
1532
- get header() {
1533
- return _centralHeader;
1534
- },
1535
- packCentralHeader: function() {
1536
- _centralHeader.flags_efs = this.efs;
1537
- _centralHeader.extraLength = _extra.length;
1538
- var header = _centralHeader.centralHeaderToBinary();
1539
- var addpos = Utils.Constants.CENHDR;
1540
- _entryName.copy(header, addpos);
1541
- addpos += _entryName.length;
1542
- _extra.copy(header, addpos);
1543
- addpos += _centralHeader.extraLength;
1544
- _comment.copy(header, addpos);
1545
- return header;
1546
- },
1547
- packLocalHeader: function() {
1548
- let addpos = 0;
1549
- _centralHeader.flags_efs = this.efs;
1550
- _centralHeader.extraLocalLength = _extralocal.length;
1551
- const localHeaderBuf = _centralHeader.localHeaderToBinary();
1552
- const localHeader = Buffer.alloc(localHeaderBuf.length + _entryName.length + _centralHeader.extraLocalLength);
1553
- localHeaderBuf.copy(localHeader, addpos);
1554
- addpos += localHeaderBuf.length;
1555
- _entryName.copy(localHeader, addpos);
1556
- addpos += _entryName.length;
1557
- _extralocal.copy(localHeader, addpos);
1558
- addpos += _extralocal.length;
1559
- return localHeader;
1560
- },
1561
- toJSON: function() {
1562
- const bytes = function(nr) {
1563
- return "<" + (nr && nr.length + " bytes buffer" || "null") + ">";
1564
- };
1565
- return {
1566
- entryName: this.entryName,
1567
- name: this.name,
1568
- comment: this.comment,
1569
- isDirectory: this.isDirectory,
1570
- header: _centralHeader.toJSON(),
1571
- compressedData: bytes(input),
1572
- data: bytes(uncompressedData)
1573
- };
1574
- },
1575
- toString: function() {
1576
- return JSON.stringify(this.toJSON(), null, " ");
1577
- }
1578
- };
1579
- };
1580
- }
1581
- });
1582
-
1583
- // ../../../node_modules/adm-zip/zipFile.js
1584
- var require_zipFile = __commonJS({
1585
- "../../../node_modules/adm-zip/zipFile.js"(exports, module) {
1586
- var ZipEntry = require_zipEntry();
1587
- var Headers = require_headers();
1588
- var Utils = require_util();
1589
- module.exports = function(inBuffer, options) {
1590
- var entryList = [], entryTable = {}, _comment = Buffer.alloc(0), mainHeader = new Headers.MainHeader(), loadedEntries = false;
1591
- const temporary = /* @__PURE__ */ new Set();
1592
- const opts = options;
1593
- const { noSort, decoder } = opts;
1594
- if (inBuffer) {
1595
- readMainHeader(opts.readEntries);
1596
- } else {
1597
- loadedEntries = true;
1598
- }
1599
- function makeTemporaryFolders() {
1600
- const foldersList = /* @__PURE__ */ new Set();
1601
- for (const elem of Object.keys(entryTable)) {
1602
- const elements = elem.split("/");
1603
- elements.pop();
1604
- if (!elements.length) continue;
1605
- for (let i = 0; i < elements.length; i++) {
1606
- const sub = elements.slice(0, i + 1).join("/") + "/";
1607
- foldersList.add(sub);
1608
- }
1609
- }
1610
- for (const elem of foldersList) {
1611
- if (!(elem in entryTable)) {
1612
- const tempfolder = new ZipEntry(opts);
1613
- tempfolder.entryName = elem;
1614
- tempfolder.attr = 16;
1615
- tempfolder.temporary = true;
1616
- entryList.push(tempfolder);
1617
- entryTable[tempfolder.entryName] = tempfolder;
1618
- temporary.add(tempfolder);
1619
- }
1620
- }
1621
- }
1622
- function readEntries() {
1623
- loadedEntries = true;
1624
- entryTable = {};
1625
- if (mainHeader.diskEntries > (inBuffer.length - mainHeader.offset) / Utils.Constants.CENHDR) {
1626
- throw Utils.Errors.DISK_ENTRY_TOO_LARGE();
1627
- }
1628
- entryList = new Array(mainHeader.diskEntries);
1629
- var index = mainHeader.offset;
1630
- for (var i = 0; i < entryList.length; i++) {
1631
- var tmp = index, entry = new ZipEntry(opts, inBuffer);
1632
- entry.header = inBuffer.slice(tmp, tmp += Utils.Constants.CENHDR);
1633
- entry.entryName = inBuffer.slice(tmp, tmp += entry.header.fileNameLength);
1634
- if (entry.header.extraLength) {
1635
- entry.extra = inBuffer.slice(tmp, tmp += entry.header.extraLength);
1636
- }
1637
- if (entry.header.commentLength) entry.comment = inBuffer.slice(tmp, tmp + entry.header.commentLength);
1638
- index += entry.header.centralHeaderSize;
1639
- entryList[i] = entry;
1640
- entryTable[entry.entryName] = entry;
1641
- }
1642
- temporary.clear();
1643
- makeTemporaryFolders();
1644
- }
1645
- function readMainHeader(readNow) {
1646
- var i = inBuffer.length - Utils.Constants.ENDHDR, max = Math.max(0, i - 65535), n = max, endStart = inBuffer.length, endOffset = -1, commentEnd = 0;
1647
- const trailingSpace = typeof opts.trailingSpace === "boolean" ? opts.trailingSpace : false;
1648
- if (trailingSpace) max = 0;
1649
- for (i; i >= n; i--) {
1650
- if (inBuffer[i] !== 80) continue;
1651
- if (inBuffer.readUInt32LE(i) === Utils.Constants.ENDSIG) {
1652
- endOffset = i;
1653
- commentEnd = i;
1654
- endStart = i + Utils.Constants.ENDHDR;
1655
- n = i - Utils.Constants.END64HDR;
1656
- continue;
1657
- }
1658
- if (inBuffer.readUInt32LE(i) === Utils.Constants.END64SIG) {
1659
- n = max;
1660
- continue;
1661
- }
1662
- if (inBuffer.readUInt32LE(i) === Utils.Constants.ZIP64SIG) {
1663
- endOffset = i;
1664
- endStart = i + Utils.readBigUInt64LE(inBuffer, i + Utils.Constants.ZIP64SIZE) + Utils.Constants.ZIP64LEAD;
1665
- break;
1666
- }
1667
- }
1668
- if (endOffset == -1) throw Utils.Errors.INVALID_FORMAT();
1669
- mainHeader.loadFromBinary(inBuffer.slice(endOffset, endStart));
1670
- if (mainHeader.commentLength) {
1671
- _comment = inBuffer.slice(commentEnd + Utils.Constants.ENDHDR);
1672
- }
1673
- if (readNow) readEntries();
1674
- }
1675
- function sortEntries() {
1676
- if (entryList.length > 1 && !noSort) {
1677
- entryList.sort((a, b) => a.entryName.toLowerCase().localeCompare(b.entryName.toLowerCase()));
1678
- }
1679
- }
1680
- return {
1681
- /**
1682
- * Returns an array of ZipEntry objects existent in the current opened archive
1683
- * @return Array
1684
- */
1685
- get entries() {
1686
- if (!loadedEntries) {
1687
- readEntries();
1688
- }
1689
- return entryList.filter((e) => !temporary.has(e));
1690
- },
1691
- /**
1692
- * Archive comment
1693
- * @return {String}
1694
- */
1695
- get comment() {
1696
- return decoder.decode(_comment);
1697
- },
1698
- set comment(val) {
1699
- _comment = Utils.toBuffer(val, decoder.encode);
1700
- mainHeader.commentLength = _comment.length;
1701
- },
1702
- getEntryCount: function() {
1703
- if (!loadedEntries) {
1704
- return mainHeader.diskEntries;
1705
- }
1706
- return entryList.length;
1707
- },
1708
- forEach: function(callback) {
1709
- this.entries.forEach(callback);
1710
- },
1711
- /**
1712
- * Returns a reference to the entry with the given name or null if entry is inexistent
1713
- *
1714
- * @param entryName
1715
- * @return ZipEntry
1716
- */
1717
- getEntry: function(entryName) {
1718
- if (!loadedEntries) {
1719
- readEntries();
1720
- }
1721
- return entryTable[entryName] || null;
1722
- },
1723
- /**
1724
- * Adds the given entry to the entry list
1725
- *
1726
- * @param entry
1727
- */
1728
- setEntry: function(entry) {
1729
- if (!loadedEntries) {
1730
- readEntries();
1731
- }
1732
- entryList.push(entry);
1733
- entryTable[entry.entryName] = entry;
1734
- mainHeader.totalEntries = entryList.length;
1735
- },
1736
- /**
1737
- * Removes the file with the given name from the entry list.
1738
- *
1739
- * If the entry is a directory, then all nested files and directories will be removed
1740
- * @param entryName
1741
- * @returns {void}
1742
- */
1743
- deleteFile: function(entryName, withsubfolders = true) {
1744
- if (!loadedEntries) {
1745
- readEntries();
1746
- }
1747
- const entry = entryTable[entryName];
1748
- const list = this.getEntryChildren(entry, withsubfolders).map((child) => child.entryName);
1749
- list.forEach(this.deleteEntry);
1750
- },
1751
- /**
1752
- * Removes the entry with the given name from the entry list.
1753
- *
1754
- * @param {string} entryName
1755
- * @returns {void}
1756
- */
1757
- deleteEntry: function(entryName) {
1758
- if (!loadedEntries) {
1759
- readEntries();
1760
- }
1761
- const entry = entryTable[entryName];
1762
- const index = entryList.indexOf(entry);
1763
- if (index >= 0) {
1764
- entryList.splice(index, 1);
1765
- delete entryTable[entryName];
1766
- mainHeader.totalEntries = entryList.length;
1767
- }
1768
- },
1769
- /**
1770
- * Iterates and returns all nested files and directories of the given entry
1771
- *
1772
- * @param entry
1773
- * @return Array
1774
- */
1775
- getEntryChildren: function(entry, subfolders = true) {
1776
- if (!loadedEntries) {
1777
- readEntries();
1778
- }
1779
- if (typeof entry === "object") {
1780
- if (entry.isDirectory && subfolders) {
1781
- const list = [];
1782
- const name = entry.entryName;
1783
- for (const zipEntry of entryList) {
1784
- if (zipEntry.entryName.startsWith(name)) {
1785
- list.push(zipEntry);
1786
- }
1787
- }
1788
- return list;
1789
- } else {
1790
- return [entry];
1791
- }
1792
- }
1793
- return [];
1794
- },
1795
- /**
1796
- * How many child elements entry has
1797
- *
1798
- * @param {ZipEntry} entry
1799
- * @return {integer}
1800
- */
1801
- getChildCount: function(entry) {
1802
- if (entry && entry.isDirectory) {
1803
- const list = this.getEntryChildren(entry);
1804
- return list.includes(entry) ? list.length - 1 : list.length;
1805
- }
1806
- return 0;
1807
- },
1808
- /**
1809
- * Returns the zip file
1810
- *
1811
- * @return Buffer
1812
- */
1813
- compressToBuffer: function() {
1814
- if (!loadedEntries) {
1815
- readEntries();
1816
- }
1817
- sortEntries();
1818
- const dataBlock = [];
1819
- const headerBlocks = [];
1820
- let totalSize = 0;
1821
- let dindex = 0;
1822
- mainHeader.size = 0;
1823
- mainHeader.offset = 0;
1824
- let totalEntries = 0;
1825
- for (const entry of this.entries) {
1826
- const compressedData = entry.getCompressedData();
1827
- entry.header.offset = dindex;
1828
- const localHeader = entry.packLocalHeader();
1829
- const dataLength = localHeader.length + compressedData.length;
1830
- dindex += dataLength;
1831
- dataBlock.push(localHeader);
1832
- dataBlock.push(compressedData);
1833
- const centralHeader = entry.packCentralHeader();
1834
- headerBlocks.push(centralHeader);
1835
- mainHeader.size += centralHeader.length;
1836
- totalSize += dataLength + centralHeader.length;
1837
- totalEntries++;
1838
- }
1839
- totalSize += mainHeader.mainHeaderSize;
1840
- mainHeader.offset = dindex;
1841
- mainHeader.totalEntries = totalEntries;
1842
- dindex = 0;
1843
- const outBuffer = Buffer.alloc(totalSize);
1844
- for (const content of dataBlock) {
1845
- content.copy(outBuffer, dindex);
1846
- dindex += content.length;
1847
- }
1848
- for (const content of headerBlocks) {
1849
- content.copy(outBuffer, dindex);
1850
- dindex += content.length;
1851
- }
1852
- const mh = mainHeader.toBinary();
1853
- if (_comment) {
1854
- _comment.copy(mh, Utils.Constants.ENDHDR);
1855
- }
1856
- mh.copy(outBuffer, dindex);
1857
- inBuffer = outBuffer;
1858
- loadedEntries = false;
1859
- return outBuffer;
1860
- },
1861
- toAsyncBuffer: function(onSuccess, onFail, onItemStart, onItemEnd) {
1862
- try {
1863
- if (!loadedEntries) {
1864
- readEntries();
1865
- }
1866
- sortEntries();
1867
- const dataBlock = [];
1868
- const centralHeaders = [];
1869
- let totalSize = 0;
1870
- let dindex = 0;
1871
- let totalEntries = 0;
1872
- mainHeader.size = 0;
1873
- mainHeader.offset = 0;
1874
- const compress2Buffer = function(entryLists) {
1875
- if (entryLists.length > 0) {
1876
- const entry = entryLists.shift();
1877
- const name = entry.entryName + entry.extra.toString();
1878
- if (onItemStart) onItemStart(name);
1879
- entry.getCompressedDataAsync(function(compressedData) {
1880
- if (onItemEnd) onItemEnd(name);
1881
- entry.header.offset = dindex;
1882
- const localHeader = entry.packLocalHeader();
1883
- const dataLength = localHeader.length + compressedData.length;
1884
- dindex += dataLength;
1885
- dataBlock.push(localHeader);
1886
- dataBlock.push(compressedData);
1887
- const centalHeader = entry.packCentralHeader();
1888
- centralHeaders.push(centalHeader);
1889
- mainHeader.size += centalHeader.length;
1890
- totalSize += dataLength + centalHeader.length;
1891
- totalEntries++;
1892
- compress2Buffer(entryLists);
1893
- });
1894
- } else {
1895
- totalSize += mainHeader.mainHeaderSize;
1896
- mainHeader.offset = dindex;
1897
- mainHeader.totalEntries = totalEntries;
1898
- dindex = 0;
1899
- const outBuffer = Buffer.alloc(totalSize);
1900
- dataBlock.forEach(function(content) {
1901
- content.copy(outBuffer, dindex);
1902
- dindex += content.length;
1903
- });
1904
- centralHeaders.forEach(function(content) {
1905
- content.copy(outBuffer, dindex);
1906
- dindex += content.length;
1907
- });
1908
- const mh = mainHeader.toBinary();
1909
- if (_comment) {
1910
- _comment.copy(mh, Utils.Constants.ENDHDR);
1911
- }
1912
- mh.copy(outBuffer, dindex);
1913
- inBuffer = outBuffer;
1914
- loadedEntries = false;
1915
- onSuccess(outBuffer);
1916
- }
1917
- };
1918
- compress2Buffer(Array.from(this.entries));
1919
- } catch (e) {
1920
- onFail(e);
1921
- }
1922
- }
1923
- };
1924
- };
1925
- }
1926
- });
1927
-
1928
- // ../../../node_modules/adm-zip/adm-zip.js
1929
- var require_adm_zip = __commonJS({
1930
- "../../../node_modules/adm-zip/adm-zip.js"(exports, module) {
1931
- var Utils = require_util();
1932
- var pth = __require("path");
1933
- var ZipEntry = require_zipEntry();
1934
- var ZipFile = require_zipFile();
1935
- var get_Bool = (...val) => Utils.findLast(val, (c) => typeof c === "boolean");
1936
- var get_Str = (...val) => Utils.findLast(val, (c) => typeof c === "string");
1937
- var get_Fun = (...val) => Utils.findLast(val, (c) => typeof c === "function");
1938
- var defaultOptions = {
1939
- // option "noSort" : if true it disables files sorting
1940
- noSort: false,
1941
- // read entries during load (initial loading may be slower)
1942
- readEntries: false,
1943
- // default method is none
1944
- method: Utils.Constants.NONE,
1945
- // file system
1946
- fs: null
1947
- };
1948
- module.exports = function(input, options) {
1949
- let inBuffer = null;
1950
- const opts = Object.assign(/* @__PURE__ */ Object.create(null), defaultOptions);
1951
- if (input && "object" === typeof input) {
1952
- if (!(input instanceof Uint8Array)) {
1953
- Object.assign(opts, input);
1954
- input = opts.input ? opts.input : void 0;
1955
- if (opts.input) delete opts.input;
1956
- }
1957
- if (Buffer.isBuffer(input)) {
1958
- inBuffer = input;
1959
- opts.method = Utils.Constants.BUFFER;
1960
- input = void 0;
1961
- }
1962
- }
1963
- Object.assign(opts, options);
1964
- const filetools = new Utils(opts);
1965
- if (typeof opts.decoder !== "object" || typeof opts.decoder.encode !== "function" || typeof opts.decoder.decode !== "function") {
1966
- opts.decoder = Utils.decoder;
1967
- }
1968
- if (input && "string" === typeof input) {
1969
- if (filetools.fs.existsSync(input)) {
1970
- opts.method = Utils.Constants.FILE;
1971
- opts.filename = input;
1972
- inBuffer = filetools.fs.readFileSync(input);
1973
- } else {
1974
- throw Utils.Errors.INVALID_FILENAME();
1975
- }
1976
- }
1977
- const _zip = new ZipFile(inBuffer, opts);
1978
- const { canonical, sanitize, zipnamefix } = Utils;
1979
- function getEntry(entry) {
1980
- if (entry && _zip) {
1981
- var item;
1982
- if (typeof entry === "string") item = _zip.getEntry(pth.posix.normalize(entry));
1983
- if (typeof entry === "object" && typeof entry.entryName !== "undefined" && typeof entry.header !== "undefined") item = _zip.getEntry(entry.entryName);
1984
- if (item) {
1985
- return item;
1986
- }
1987
- }
1988
- return null;
1989
- }
1990
- function fixPath(zipPath) {
1991
- const { join: join2, normalize, sep } = pth.posix;
1992
- return join2(".", normalize(sep + zipPath.split("\\").join(sep) + sep));
1993
- }
1994
- function filenameFilter(filterfn) {
1995
- if (filterfn instanceof RegExp) {
1996
- return /* @__PURE__ */ (function(rx) {
1997
- return function(filename) {
1998
- return rx.test(filename);
1999
- };
2000
- })(filterfn);
2001
- } else if ("function" !== typeof filterfn) {
2002
- return () => true;
2003
- }
2004
- return filterfn;
2005
- }
2006
- const relativePath = (local, entry) => {
2007
- let lastChar = entry.slice(-1);
2008
- lastChar = lastChar === filetools.sep ? filetools.sep : "";
2009
- return pth.relative(local, entry) + lastChar;
2010
- };
2011
- return {
2012
- /**
2013
- * Extracts the given entry from the archive and returns the content as a Buffer object
2014
- * @param {ZipEntry|string} entry ZipEntry object or String with the full path of the entry
2015
- * @param {Buffer|string} [pass] - password
2016
- * @return Buffer or Null in case of error
2017
- */
2018
- readFile: function(entry, pass) {
2019
- var item = getEntry(entry);
2020
- return item && item.getData(pass) || null;
2021
- },
2022
- /**
2023
- * Returns how many child elements has on entry (directories) on files it is always 0
2024
- * @param {ZipEntry|string} entry ZipEntry object or String with the full path of the entry
2025
- * @returns {integer}
2026
- */
2027
- childCount: function(entry) {
2028
- const item = getEntry(entry);
2029
- if (item) {
2030
- return _zip.getChildCount(item);
2031
- }
2032
- },
2033
- /**
2034
- * Asynchronous readFile
2035
- * @param {ZipEntry|string} entry ZipEntry object or String with the full path of the entry
2036
- * @param {callback} callback
2037
- *
2038
- * @return Buffer or Null in case of error
2039
- */
2040
- readFileAsync: function(entry, callback) {
2041
- var item = getEntry(entry);
2042
- if (item) {
2043
- item.getDataAsync(callback);
2044
- } else {
2045
- callback(null, "getEntry failed for:" + entry);
2046
- }
2047
- },
2048
- /**
2049
- * Extracts the given entry from the archive and returns the content as plain text in the given encoding
2050
- * @param {ZipEntry|string} entry - ZipEntry object or String with the full path of the entry
2051
- * @param {string} encoding - Optional. If no encoding is specified utf8 is used
2052
- *
2053
- * @return String
2054
- */
2055
- readAsText: function(entry, encoding) {
2056
- var item = getEntry(entry);
2057
- if (item) {
2058
- var data = item.getData();
2059
- if (data && data.length) {
2060
- return data.toString(encoding || "utf8");
2061
- }
2062
- }
2063
- return "";
2064
- },
2065
- /**
2066
- * Asynchronous readAsText
2067
- * @param {ZipEntry|string} entry ZipEntry object or String with the full path of the entry
2068
- * @param {callback} callback
2069
- * @param {string} [encoding] - Optional. If no encoding is specified utf8 is used
2070
- *
2071
- * @return String
2072
- */
2073
- readAsTextAsync: function(entry, callback, encoding) {
2074
- var item = getEntry(entry);
2075
- if (item) {
2076
- item.getDataAsync(function(data, err) {
2077
- if (err) {
2078
- callback(data, err);
2079
- return;
2080
- }
2081
- if (data && data.length) {
2082
- callback(data.toString(encoding || "utf8"));
2083
- } else {
2084
- callback("");
2085
- }
2086
- });
2087
- } else {
2088
- callback("");
2089
- }
2090
- },
2091
- /**
2092
- * Remove the entry from the file or the entry and all it's nested directories and files if the given entry is a directory
2093
- *
2094
- * @param {ZipEntry|string} entry
2095
- * @returns {void}
2096
- */
2097
- deleteFile: function(entry, withsubfolders = true) {
2098
- var item = getEntry(entry);
2099
- if (item) {
2100
- _zip.deleteFile(item.entryName, withsubfolders);
2101
- }
2102
- },
2103
- /**
2104
- * Remove the entry from the file or directory without affecting any nested entries
2105
- *
2106
- * @param {ZipEntry|string} entry
2107
- * @returns {void}
2108
- */
2109
- deleteEntry: function(entry) {
2110
- var item = getEntry(entry);
2111
- if (item) {
2112
- _zip.deleteEntry(item.entryName);
2113
- }
2114
- },
2115
- /**
2116
- * Adds a comment to the zip. The zip must be rewritten after adding the comment.
2117
- *
2118
- * @param {string} comment
2119
- */
2120
- addZipComment: function(comment) {
2121
- _zip.comment = comment;
2122
- },
2123
- /**
2124
- * Returns the zip comment
2125
- *
2126
- * @return String
2127
- */
2128
- getZipComment: function() {
2129
- return _zip.comment || "";
2130
- },
2131
- /**
2132
- * Adds a comment to a specified zipEntry. The zip must be rewritten after adding the comment
2133
- * The comment cannot exceed 65535 characters in length
2134
- *
2135
- * @param {ZipEntry} entry
2136
- * @param {string} comment
2137
- */
2138
- addZipEntryComment: function(entry, comment) {
2139
- var item = getEntry(entry);
2140
- if (item) {
2141
- item.comment = comment;
2142
- }
2143
- },
2144
- /**
2145
- * Returns the comment of the specified entry
2146
- *
2147
- * @param {ZipEntry} entry
2148
- * @return String
2149
- */
2150
- getZipEntryComment: function(entry) {
2151
- var item = getEntry(entry);
2152
- if (item) {
2153
- return item.comment || "";
2154
- }
2155
- return "";
2156
- },
2157
- /**
2158
- * Updates the content of an existing entry inside the archive. The zip must be rewritten after updating the content
2159
- *
2160
- * @param {ZipEntry} entry
2161
- * @param {Buffer} content
2162
- */
2163
- updateFile: function(entry, content) {
2164
- var item = getEntry(entry);
2165
- if (item) {
2166
- item.setData(content);
2167
- }
2168
- },
2169
- /**
2170
- * Adds a file from the disk to the archive
2171
- *
2172
- * @param {string} localPath File to add to zip
2173
- * @param {string} [zipPath] Optional path inside the zip
2174
- * @param {string} [zipName] Optional name for the file
2175
- * @param {string} [comment] Optional file comment
2176
- */
2177
- addLocalFile: function(localPath2, zipPath, zipName, comment) {
2178
- if (filetools.fs.existsSync(localPath2)) {
2179
- zipPath = zipPath ? fixPath(zipPath) : "";
2180
- const p = pth.win32.basename(pth.win32.normalize(localPath2));
2181
- zipPath += zipName ? zipName : p;
2182
- const _attr = filetools.fs.statSync(localPath2);
2183
- const data = _attr.isFile() ? filetools.fs.readFileSync(localPath2) : Buffer.alloc(0);
2184
- if (_attr.isDirectory()) zipPath += filetools.sep;
2185
- this.addFile(zipPath, data, comment, _attr);
2186
- } else {
2187
- throw Utils.Errors.FILE_NOT_FOUND(localPath2);
2188
- }
2189
- },
2190
- /**
2191
- * Callback for showing if everything was done.
2192
- *
2193
- * @callback doneCallback
2194
- * @param {Error} err - Error object
2195
- * @param {boolean} done - was request fully completed
2196
- */
2197
- /**
2198
- * Adds a file from the disk to the archive
2199
- *
2200
- * @param {(object|string)} options - options object, if it is string it us used as localPath.
2201
- * @param {string} options.localPath - Local path to the file.
2202
- * @param {string} [options.comment] - Optional file comment.
2203
- * @param {string} [options.zipPath] - Optional path inside the zip
2204
- * @param {string} [options.zipName] - Optional name for the file
2205
- * @param {doneCallback} callback - The callback that handles the response.
2206
- */
2207
- addLocalFileAsync: function(options2, callback) {
2208
- options2 = typeof options2 === "object" ? options2 : { localPath: options2 };
2209
- const localPath2 = pth.resolve(options2.localPath);
2210
- const { comment } = options2;
2211
- let { zipPath, zipName } = options2;
2212
- const self = this;
2213
- filetools.fs.stat(localPath2, function(err, stats) {
2214
- if (err) return callback(err, false);
2215
- zipPath = zipPath ? fixPath(zipPath) : "";
2216
- const p = pth.win32.basename(pth.win32.normalize(localPath2));
2217
- zipPath += zipName ? zipName : p;
2218
- if (stats.isFile()) {
2219
- filetools.fs.readFile(localPath2, function(err2, data) {
2220
- if (err2) return callback(err2, false);
2221
- self.addFile(zipPath, data, comment, stats);
2222
- return setImmediate(callback, void 0, true);
2223
- });
2224
- } else if (stats.isDirectory()) {
2225
- zipPath += filetools.sep;
2226
- self.addFile(zipPath, Buffer.alloc(0), comment, stats);
2227
- return setImmediate(callback, void 0, true);
2228
- }
2229
- });
2230
- },
2231
- /**
2232
- * Adds a local directory and all its nested files and directories to the archive
2233
- *
2234
- * @param {string} localPath - local path to the folder
2235
- * @param {string} [zipPath] - optional path inside zip
2236
- * @param {(RegExp|function)} [filter] - optional RegExp or Function if files match will be included.
2237
- */
2238
- addLocalFolder: function(localPath2, zipPath, filter) {
2239
- filter = filenameFilter(filter);
2240
- zipPath = zipPath ? fixPath(zipPath) : "";
2241
- localPath2 = pth.normalize(localPath2);
2242
- if (filetools.fs.existsSync(localPath2)) {
2243
- const items = filetools.findFiles(localPath2);
2244
- const self = this;
2245
- if (items.length) {
2246
- for (const filepath of items) {
2247
- const p = pth.join(zipPath, relativePath(localPath2, filepath));
2248
- if (filter(p)) {
2249
- self.addLocalFile(filepath, pth.dirname(p));
2250
- }
2251
- }
2252
- }
2253
- } else {
2254
- throw Utils.Errors.FILE_NOT_FOUND(localPath2);
2255
- }
2256
- },
2257
- /**
2258
- * Asynchronous addLocalFolder
2259
- * @param {string} localPath
2260
- * @param {callback} callback
2261
- * @param {string} [zipPath] optional path inside zip
2262
- * @param {RegExp|function} [filter] optional RegExp or Function if files match will
2263
- * be included.
2264
- */
2265
- addLocalFolderAsync: function(localPath2, callback, zipPath, filter) {
2266
- filter = filenameFilter(filter);
2267
- zipPath = zipPath ? fixPath(zipPath) : "";
2268
- localPath2 = pth.normalize(localPath2);
2269
- var self = this;
2270
- filetools.fs.open(localPath2, "r", function(err) {
2271
- if (err && err.code === "ENOENT") {
2272
- callback(void 0, Utils.Errors.FILE_NOT_FOUND(localPath2));
2273
- } else if (err) {
2274
- callback(void 0, err);
2275
- } else {
2276
- var items = filetools.findFiles(localPath2);
2277
- var i = -1;
2278
- var next = function() {
2279
- i += 1;
2280
- if (i < items.length) {
2281
- var filepath = items[i];
2282
- var p = relativePath(localPath2, filepath).split("\\").join("/");
2283
- p = p.normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^\x20-\x7E]/g, "");
2284
- if (filter(p)) {
2285
- filetools.fs.stat(filepath, function(er0, stats) {
2286
- if (er0) callback(void 0, er0);
2287
- if (stats.isFile()) {
2288
- filetools.fs.readFile(filepath, function(er1, data) {
2289
- if (er1) {
2290
- callback(void 0, er1);
2291
- } else {
2292
- self.addFile(zipPath + p, data, "", stats);
2293
- next();
2294
- }
2295
- });
2296
- } else {
2297
- self.addFile(zipPath + p + "/", Buffer.alloc(0), "", stats);
2298
- next();
2299
- }
2300
- });
2301
- } else {
2302
- process.nextTick(() => {
2303
- next();
2304
- });
2305
- }
2306
- } else {
2307
- callback(true, void 0);
2308
- }
2309
- };
2310
- next();
2311
- }
2312
- });
2313
- },
2314
- /**
2315
- * Adds a local directory and all its nested files and directories to the archive
2316
- *
2317
- * @param {object | string} options - options object, if it is string it us used as localPath.
2318
- * @param {string} options.localPath - Local path to the folder.
2319
- * @param {string} [options.zipPath] - optional path inside zip.
2320
- * @param {RegExp|function} [options.filter] - optional RegExp or Function if files match will be included.
2321
- * @param {function|string} [options.namefix] - optional function to help fix filename
2322
- * @param {doneCallback} callback - The callback that handles the response.
2323
- *
2324
- */
2325
- addLocalFolderAsync2: function(options2, callback) {
2326
- const self = this;
2327
- options2 = typeof options2 === "object" ? options2 : { localPath: options2 };
2328
- localPath = pth.resolve(fixPath(options2.localPath));
2329
- let { zipPath, filter, namefix } = options2;
2330
- if (filter instanceof RegExp) {
2331
- filter = /* @__PURE__ */ (function(rx) {
2332
- return function(filename) {
2333
- return rx.test(filename);
2334
- };
2335
- })(filter);
2336
- } else if ("function" !== typeof filter) {
2337
- filter = function() {
2338
- return true;
2339
- };
2340
- }
2341
- zipPath = zipPath ? fixPath(zipPath) : "";
2342
- if (namefix == "latin1") {
2343
- namefix = (str) => str.normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^\x20-\x7E]/g, "");
2344
- }
2345
- if (typeof namefix !== "function") namefix = (str) => str;
2346
- const relPathFix = (entry) => pth.join(zipPath, namefix(relativePath(localPath, entry)));
2347
- const fileNameFix = (entry) => pth.win32.basename(pth.win32.normalize(namefix(entry)));
2348
- filetools.fs.open(localPath, "r", function(err) {
2349
- if (err && err.code === "ENOENT") {
2350
- callback(void 0, Utils.Errors.FILE_NOT_FOUND(localPath));
2351
- } else if (err) {
2352
- callback(void 0, err);
2353
- } else {
2354
- filetools.findFilesAsync(localPath, function(err2, fileEntries) {
2355
- if (err2) return callback(err2);
2356
- fileEntries = fileEntries.filter((dir) => filter(relPathFix(dir)));
2357
- if (!fileEntries.length) callback(void 0, false);
2358
- setImmediate(
2359
- fileEntries.reverse().reduce(function(next, entry) {
2360
- return function(err3, done) {
2361
- if (err3 || done === false) return setImmediate(next, err3, false);
2362
- self.addLocalFileAsync(
2363
- {
2364
- localPath: entry,
2365
- zipPath: pth.dirname(relPathFix(entry)),
2366
- zipName: fileNameFix(entry)
2367
- },
2368
- next
2369
- );
2370
- };
2371
- }, callback)
2372
- );
2373
- });
2374
- }
2375
- });
2376
- },
2377
- /**
2378
- * Adds a local directory and all its nested files and directories to the archive
2379
- *
2380
- * @param {string} localPath - path where files will be extracted
2381
- * @param {object} props - optional properties
2382
- * @param {string} [props.zipPath] - optional path inside zip
2383
- * @param {RegExp|function} [props.filter] - optional RegExp or Function if files match will be included.
2384
- * @param {function|string} [props.namefix] - optional function to help fix filename
2385
- */
2386
- addLocalFolderPromise: function(localPath2, props) {
2387
- return new Promise((resolve, reject) => {
2388
- this.addLocalFolderAsync2(Object.assign({ localPath: localPath2 }, props), (err, done) => {
2389
- if (err) reject(err);
2390
- if (done) resolve(this);
2391
- });
2392
- });
2393
- },
2394
- /**
2395
- * Allows you to create a entry (file or directory) in the zip file.
2396
- * If you want to create a directory the entryName must end in / and a null buffer should be provided.
2397
- * Comment and attributes are optional
2398
- *
2399
- * @param {string} entryName
2400
- * @param {Buffer | string} content - file content as buffer or utf8 coded string
2401
- * @param {string} [comment] - file comment
2402
- * @param {number | object} [attr] - number as unix file permissions, object as filesystem Stats object
2403
- */
2404
- addFile: function(entryName, content, comment, attr) {
2405
- entryName = zipnamefix(entryName);
2406
- let entry = getEntry(entryName);
2407
- const update = entry != null;
2408
- if (!update) {
2409
- entry = new ZipEntry(opts);
2410
- entry.entryName = entryName;
2411
- }
2412
- entry.comment = comment || "";
2413
- const isStat = "object" === typeof attr && attr instanceof filetools.fs.Stats;
2414
- if (isStat) {
2415
- entry.header.time = attr.mtime;
2416
- }
2417
- var fileattr = entry.isDirectory ? 16 : 0;
2418
- let unix = entry.isDirectory ? 16384 : 32768;
2419
- if (isStat) {
2420
- unix |= 4095 & attr.mode;
2421
- } else if ("number" === typeof attr) {
2422
- unix |= 4095 & attr;
2423
- } else {
2424
- unix |= entry.isDirectory ? 493 : 420;
2425
- }
2426
- fileattr = (fileattr | unix << 16) >>> 0;
2427
- entry.attr = fileattr;
2428
- entry.setData(content);
2429
- if (!update) _zip.setEntry(entry);
2430
- return entry;
2431
- },
2432
- /**
2433
- * Returns an array of ZipEntry objects representing the files and folders inside the archive
2434
- *
2435
- * @param {string} [password]
2436
- * @returns Array
2437
- */
2438
- getEntries: function(password) {
2439
- _zip.password = password;
2440
- return _zip ? _zip.entries : [];
2441
- },
2442
- /**
2443
- * Returns a ZipEntry object representing the file or folder specified by ``name``.
2444
- *
2445
- * @param {string} name
2446
- * @return ZipEntry
2447
- */
2448
- getEntry: function(name) {
2449
- return getEntry(name);
2450
- },
2451
- getEntryCount: function() {
2452
- return _zip.getEntryCount();
2453
- },
2454
- forEach: function(callback) {
2455
- return _zip.forEach(callback);
2456
- },
2457
- /**
2458
- * Extracts the given entry to the given targetPath
2459
- * If the entry is a directory inside the archive, the entire directory and it's subdirectories will be extracted
2460
- *
2461
- * @param {string|ZipEntry} entry - ZipEntry object or String with the full path of the entry
2462
- * @param {string} targetPath - Target folder where to write the file
2463
- * @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
2464
- * @param {boolean} [overwrite=false] - If the file already exists at the target path, the file will be overwriten if this is true.
2465
- * @param {boolean} [keepOriginalPermission=false] - The file will be set as the permission from the entry if this is true.
2466
- * @param {string} [outFileName] - String If set will override the filename of the extracted file (Only works if the entry is a file)
2467
- *
2468
- * @return Boolean
2469
- */
2470
- extractEntryTo: function(entry, targetPath, maintainEntryPath, overwrite, keepOriginalPermission, outFileName) {
2471
- overwrite = get_Bool(false, overwrite);
2472
- keepOriginalPermission = get_Bool(false, keepOriginalPermission);
2473
- maintainEntryPath = get_Bool(true, maintainEntryPath);
2474
- outFileName = get_Str(keepOriginalPermission, outFileName);
2475
- var item = getEntry(entry);
2476
- if (!item) {
2477
- throw Utils.Errors.NO_ENTRY();
2478
- }
2479
- var entryName = canonical(item.entryName);
2480
- var target = sanitize(targetPath, outFileName && !item.isDirectory ? outFileName : maintainEntryPath ? entryName : pth.basename(entryName));
2481
- if (item.isDirectory) {
2482
- var children = _zip.getEntryChildren(item);
2483
- children.forEach(function(child) {
2484
- if (child.isDirectory) return;
2485
- var content2 = child.getData();
2486
- if (!content2) {
2487
- throw Utils.Errors.CANT_EXTRACT_FILE();
2488
- }
2489
- var name = canonical(child.entryName);
2490
- var childName = sanitize(targetPath, maintainEntryPath ? name : pth.basename(name));
2491
- const fileAttr2 = keepOriginalPermission ? child.header.fileAttr : void 0;
2492
- filetools.writeFileTo(childName, content2, overwrite, fileAttr2);
2493
- });
2494
- return true;
2495
- }
2496
- var content = item.getData(_zip.password);
2497
- if (!content) throw Utils.Errors.CANT_EXTRACT_FILE();
2498
- if (filetools.fs.existsSync(target) && !overwrite) {
2499
- throw Utils.Errors.CANT_OVERRIDE();
2500
- }
2501
- const fileAttr = keepOriginalPermission ? entry.header.fileAttr : void 0;
2502
- filetools.writeFileTo(target, content, overwrite, fileAttr);
2503
- return true;
2504
- },
2505
- /**
2506
- * Test the archive
2507
- * @param {string} [pass]
2508
- */
2509
- test: function(pass) {
2510
- if (!_zip) {
2511
- return false;
2512
- }
2513
- for (var entry in _zip.entries) {
2514
- try {
2515
- if (entry.isDirectory) {
2516
- continue;
2517
- }
2518
- var content = _zip.entries[entry].getData(pass);
2519
- if (!content) {
2520
- return false;
2521
- }
2522
- } catch (err) {
2523
- return false;
2524
- }
2525
- }
2526
- return true;
2527
- },
2528
- /**
2529
- * Extracts the entire archive to the given location
2530
- *
2531
- * @param {string} targetPath Target location
2532
- * @param {boolean} [overwrite=false] If the file already exists at the target path, the file will be overwriten if this is true.
2533
- * Default is FALSE
2534
- * @param {boolean} [keepOriginalPermission=false] The file will be set as the permission from the entry if this is true.
2535
- * Default is FALSE
2536
- * @param {string|Buffer} [pass] password
2537
- */
2538
- extractAllTo: function(targetPath, overwrite, keepOriginalPermission, pass) {
2539
- keepOriginalPermission = get_Bool(false, keepOriginalPermission);
2540
- pass = get_Str(keepOriginalPermission, pass);
2541
- overwrite = get_Bool(false, overwrite);
2542
- if (!_zip) throw Utils.Errors.NO_ZIP();
2543
- _zip.entries.forEach(function(entry) {
2544
- var entryName = sanitize(targetPath, canonical(entry.entryName));
2545
- if (entry.isDirectory) {
2546
- filetools.makeDir(entryName);
2547
- return;
2548
- }
2549
- var content = entry.getData(pass);
2550
- if (!content) {
2551
- throw Utils.Errors.CANT_EXTRACT_FILE();
2552
- }
2553
- const fileAttr = keepOriginalPermission ? entry.header.fileAttr : void 0;
2554
- filetools.writeFileTo(entryName, content, overwrite, fileAttr);
2555
- try {
2556
- filetools.fs.utimesSync(entryName, entry.header.time, entry.header.time);
2557
- } catch (err) {
2558
- throw Utils.Errors.CANT_EXTRACT_FILE();
2559
- }
2560
- });
2561
- },
2562
- /**
2563
- * Asynchronous extractAllTo
2564
- *
2565
- * @param {string} targetPath Target location
2566
- * @param {boolean} [overwrite=false] If the file already exists at the target path, the file will be overwriten if this is true.
2567
- * Default is FALSE
2568
- * @param {boolean} [keepOriginalPermission=false] The file will be set as the permission from the entry if this is true.
2569
- * Default is FALSE
2570
- * @param {function} callback The callback will be executed when all entries are extracted successfully or any error is thrown.
2571
- */
2572
- extractAllToAsync: function(targetPath, overwrite, keepOriginalPermission, callback) {
2573
- callback = get_Fun(overwrite, keepOriginalPermission, callback);
2574
- keepOriginalPermission = get_Bool(false, keepOriginalPermission);
2575
- overwrite = get_Bool(false, overwrite);
2576
- if (!callback) {
2577
- return new Promise((resolve, reject) => {
2578
- this.extractAllToAsync(targetPath, overwrite, keepOriginalPermission, function(err) {
2579
- if (err) {
2580
- reject(err);
2581
- } else {
2582
- resolve(this);
2583
- }
2584
- });
2585
- });
2586
- }
2587
- if (!_zip) {
2588
- callback(Utils.Errors.NO_ZIP());
2589
- return;
2590
- }
2591
- targetPath = pth.resolve(targetPath);
2592
- const getPath = (entry) => sanitize(targetPath, pth.normalize(canonical(entry.entryName)));
2593
- const getError = (msg, file) => new Error(msg + ': "' + file + '"');
2594
- const dirEntries = [];
2595
- const fileEntries = [];
2596
- _zip.entries.forEach((e) => {
2597
- if (e.isDirectory) {
2598
- dirEntries.push(e);
2599
- } else {
2600
- fileEntries.push(e);
2601
- }
2602
- });
2603
- for (const entry of dirEntries) {
2604
- const dirPath = getPath(entry);
2605
- const dirAttr = keepOriginalPermission ? entry.header.fileAttr : void 0;
2606
- try {
2607
- filetools.makeDir(dirPath);
2608
- if (dirAttr) filetools.fs.chmodSync(dirPath, dirAttr);
2609
- filetools.fs.utimesSync(dirPath, entry.header.time, entry.header.time);
2610
- } catch (er) {
2611
- callback(getError("Unable to create folder", dirPath));
2612
- }
2613
- }
2614
- fileEntries.reverse().reduce(function(next, entry) {
2615
- return function(err) {
2616
- if (err) {
2617
- next(err);
2618
- } else {
2619
- const entryName = pth.normalize(canonical(entry.entryName));
2620
- const filePath = sanitize(targetPath, entryName);
2621
- entry.getDataAsync(function(content, err_1) {
2622
- if (err_1) {
2623
- next(err_1);
2624
- } else if (!content) {
2625
- next(Utils.Errors.CANT_EXTRACT_FILE());
2626
- } else {
2627
- const fileAttr = keepOriginalPermission ? entry.header.fileAttr : void 0;
2628
- filetools.writeFileToAsync(filePath, content, overwrite, fileAttr, function(succ) {
2629
- if (!succ) {
2630
- next(getError("Unable to write file", filePath));
2631
- }
2632
- filetools.fs.utimes(filePath, entry.header.time, entry.header.time, function(err_2) {
2633
- if (err_2) {
2634
- next(getError("Unable to set times", filePath));
2635
- } else {
2636
- next();
2637
- }
2638
- });
2639
- });
2640
- }
2641
- });
2642
- }
2643
- };
2644
- }, callback)();
2645
- },
2646
- /**
2647
- * 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
2648
- *
2649
- * @param {string} targetFileName
2650
- * @param {function} callback
2651
- */
2652
- writeZip: function(targetFileName, callback) {
2653
- if (arguments.length === 1) {
2654
- if (typeof targetFileName === "function") {
2655
- callback = targetFileName;
2656
- targetFileName = "";
2657
- }
2658
- }
2659
- if (!targetFileName && opts.filename) {
2660
- targetFileName = opts.filename;
2661
- }
2662
- if (!targetFileName) return;
2663
- var zipData = _zip.compressToBuffer();
2664
- if (zipData) {
2665
- var ok = filetools.writeFileTo(targetFileName, zipData, true);
2666
- if (typeof callback === "function") callback(!ok ? new Error("failed") : null, "");
2667
- }
2668
- },
2669
- /**
2670
- *
2671
- * @param {string} targetFileName
2672
- * @param {object} [props]
2673
- * @param {boolean} [props.overwrite=true] If the file already exists at the target path, the file will be overwriten if this is true.
2674
- * @param {boolean} [props.perm] The file will be set as the permission from the entry if this is true.
2675
-
2676
- * @returns {Promise<void>}
2677
- */
2678
- writeZipPromise: function(targetFileName, props) {
2679
- const { overwrite, perm } = Object.assign({ overwrite: true }, props);
2680
- return new Promise((resolve, reject) => {
2681
- if (!targetFileName && opts.filename) targetFileName = opts.filename;
2682
- if (!targetFileName) reject("ADM-ZIP: ZIP File Name Missing");
2683
- this.toBufferPromise().then((zipData) => {
2684
- const ret = (done) => done ? resolve(done) : reject("ADM-ZIP: Wasn't able to write zip file");
2685
- filetools.writeFileToAsync(targetFileName, zipData, overwrite, perm, ret);
2686
- }, reject);
2687
- });
2688
- },
2689
- /**
2690
- * @returns {Promise<Buffer>} A promise to the Buffer.
2691
- */
2692
- toBufferPromise: function() {
2693
- return new Promise((resolve, reject) => {
2694
- _zip.toAsyncBuffer(resolve, reject);
2695
- });
2696
- },
2697
- /**
2698
- * Returns the content of the entire zip file as a Buffer object
2699
- *
2700
- * @prop {function} [onSuccess]
2701
- * @prop {function} [onFail]
2702
- * @prop {function} [onItemStart]
2703
- * @prop {function} [onItemEnd]
2704
- * @returns {Buffer}
2705
- */
2706
- toBuffer: function(onSuccess, onFail, onItemStart, onItemEnd) {
2707
- if (typeof onSuccess === "function") {
2708
- _zip.toAsyncBuffer(onSuccess, onFail, onItemStart, onItemEnd);
2709
- return null;
2710
- }
2711
- return _zip.compressToBuffer();
2712
- }
2713
- };
2714
- };
2715
- }
2716
- });
2717
-
2718
- // src/utils.ts
2719
- var import_adm_zip = __toESM(require_adm_zip());
2720
10
 
2721
11
  // src/constants.ts
2722
12
  var VERTICAL_NAME = "forms-app";
2723
13
  var FORMS_APP_DEF_ID = "225dd912-7dea-4738-8688-4b8c6955ffc2";
2724
- var PLUGIN_FILES_ZIP_URL = "https://static.parastorage.com/services/vibe-forms-plugin-files/0.21.0/forms-plugin-files-files.zip";
2725
14
  var PROMPT_ID = "b04334db-8243-4b9e-9773-ecb2775f329e";
2726
15
 
2727
- // src/wix-apis.ts
2728
- var callWixAPI = async ({
2729
- url,
2730
- method,
2731
- body,
2732
- additionalHeaders,
2733
- logger
2734
- }) => {
2735
- if (!process.env.WIX_TOKEN) {
2736
- logger.warn("[wix-apis] WIX_TOKEN is not set");
2737
- }
2738
- try {
2739
- logger.debug("[wix-apis] Calling Wix API...", {
2740
- url,
2741
- method,
2742
- additionalHeaders
2743
- });
2744
- const response = await fetch(url, {
2745
- method,
2746
- headers: {
2747
- "Content-Type": "application/json",
2748
- Authorization: process.env.WIX_TOKEN,
2749
- ...additionalHeaders
2750
- },
2751
- ...method === "GET" ? {} : { body: JSON.stringify(body) }
2752
- });
2753
- if (!response.ok) {
2754
- const responseText = await response.text();
2755
- logger.error(new Error("[wix-apis] Error calling Wix API"), {
2756
- responseText,
2757
- url,
2758
- method,
2759
- body,
2760
- requestId: response.headers.get("x-wix-request-id")
2761
- });
2762
- return null;
2763
- }
2764
- return await response.json();
2765
- } catch (error) {
2766
- logger.error(new Error("[wix-apis] Error calling Wix API"), {
2767
- error,
2768
- url,
2769
- method,
2770
- body,
2771
- requestId: error instanceof Error && "requestId" in error ? error.requestId : void 0
2772
- });
2773
- return null;
2774
- }
2775
- };
2776
- var installWixApp = async (appDefId, siteId, logger) => {
2777
- logger.debug("Installing Wix app...", { appDefId, siteId });
2778
- const response = await callWixAPI({
2779
- url: "https://www.wixapis.com/apps-installer-service/v1/app-instance/install",
2780
- method: "POST",
2781
- body: {
2782
- tenant: {
2783
- tenantType: "SITE",
2784
- id: siteId
2785
- },
2786
- appInstance: {
2787
- appDefId
2788
- }
2789
- },
2790
- logger
2791
- });
2792
- return response;
2793
- };
2794
-
2795
16
  // ../../../node_modules/@wix/sdk-runtime/build/constants.js
2796
17
  var WIX_PROTOCOL = "wix:";
2797
18
  var SDKRequestToRESTRequestRenameMap = {
@@ -2810,16 +31,16 @@ var DEFAULT_LIMIT = 50;
2810
31
 
2811
32
  // ../../../node_modules/@wix/sdk-runtime/build/rename-all-nested-keys.js
2812
33
  function renameAllNestedKeys(payload, renameMap, ignorePaths) {
2813
- const isIgnored = (path2) => ignorePaths.includes(path2);
2814
- const traverse = (obj, path2) => {
34
+ const isIgnored = (path) => ignorePaths.includes(path);
35
+ const traverse = (obj, path) => {
2815
36
  if (Array.isArray(obj)) {
2816
37
  obj.forEach((item) => {
2817
- traverse(item, path2);
38
+ traverse(item, path);
2818
39
  });
2819
40
  } else if (typeof obj === "object" && obj !== null) {
2820
41
  const objAsRecord = obj;
2821
42
  Object.keys(objAsRecord).forEach((key) => {
2822
- const newPath = path2 === "" ? key : `${path2}.${key}`;
43
+ const newPath = path === "" ? key : `${path}.${key}`;
2823
44
  if (isIgnored(newPath)) {
2824
45
  return;
2825
46
  }
@@ -2850,10 +71,10 @@ function transformRESTTimestampToSDKTimestamp(val) {
2850
71
  }
2851
72
 
2852
73
  // ../../../node_modules/@wix/sdk-runtime/build/transformations/transform-paths.js
2853
- function transformPath(obj, { path: path2, isRepeated, isMap }, transformFn) {
2854
- const pathParts = path2.split(".");
2855
- if (pathParts.length === 1 && path2 in obj) {
2856
- obj[path2] = isRepeated ? obj[path2].map(transformFn) : isMap ? Object.fromEntries(Object.entries(obj[path2]).map(([key, value]) => [key, transformFn(value)])) : transformFn(obj[path2]);
74
+ function transformPath(obj, { path, isRepeated, isMap }, transformFn) {
75
+ const pathParts = path.split(".");
76
+ if (pathParts.length === 1 && path in obj) {
77
+ obj[path] = isRepeated ? obj[path].map(transformFn) : isMap ? Object.fromEntries(Object.entries(obj[path]).map(([key, value]) => [key, transformFn(value)])) : transformFn(obj[path]);
2857
78
  return obj;
2858
79
  }
2859
80
  const [first, ...rest] = pathParts;
@@ -2876,7 +97,7 @@ function transformPath(obj, { path: path2, isRepeated, isMap }, transformFn) {
2876
97
  return obj;
2877
98
  }
2878
99
  function transformPaths(obj, transformations) {
2879
- return transformations.reduce((acc, { paths, transformFn }) => paths.reduce((transformerAcc, path2) => transformPath(transformerAcc, path2, transformFn), acc), obj);
100
+ return transformations.reduce((acc, { paths, transformFn }) => paths.reduce((transformerAcc, path) => transformPath(transformerAcc, path, transformFn), acc), obj);
2880
101
  }
2881
102
 
2882
103
  // ../../../node_modules/@wix/sdk-types/build/index.mjs
@@ -3044,7 +265,7 @@ var violationsWithRenamedFields = ({ spreadPathsToArguments, explicitPathsToArgu
3044
265
  field: withRenamedArgument(exactMatchArgumentExpression, argumentNames)
3045
266
  };
3046
267
  }
3047
- const longestPartialPathMatch = allPathsToArgumentsKeys?.sort((a, b) => b.length - a.length)?.find((path2) => fieldViolation.field.startsWith(path2));
268
+ const longestPartialPathMatch = allPathsToArgumentsKeys?.sort((a, b) => b.length - a.length)?.find((path) => fieldViolation.field.startsWith(path));
3048
269
  if (longestPartialPathMatch) {
3049
270
  const partialMatchArgumentExpression = allPathsToArguments[longestPartialPathMatch];
3050
271
  if (partialMatchArgumentExpression) {
@@ -3519,7 +740,7 @@ function queryBuilder(opts) {
3519
740
  });
3520
741
  }
3521
742
  function renameFieldByPaths(transformationPaths, fieldPath) {
3522
- const transformationPath = Object.entries(transformationPaths).find(([path2]) => path2 === fieldPath || fieldPath.startsWith(`${path2}.`))?.[0];
743
+ const transformationPath = Object.entries(transformationPaths).find(([path]) => path === fieldPath || fieldPath.startsWith(`${path}.`))?.[0];
3523
744
  if (transformationPath) {
3524
745
  return fieldPath.replace(transformationPath, transformationPaths[transformationPath]);
3525
746
  }
@@ -3667,14 +888,14 @@ function toURLSearchParams(params, isComplexRequest) {
3667
888
  function resolveUrl(opts) {
3668
889
  const domain = resolveDomain(opts.host);
3669
890
  const mappings = resolveMappingsByDomain(domain, opts.domainToMappings);
3670
- const path2 = injectDataIntoProtoPath(opts.protoPath, opts.data || {});
3671
- return resolvePathFromMappings(path2, mappings);
891
+ const path = injectDataIntoProtoPath(opts.protoPath, opts.data || {});
892
+ return resolvePathFromMappings(path, mappings);
3672
893
  }
3673
- function flattenParams(data, path2 = "") {
894
+ function flattenParams(data, path = "") {
3674
895
  const params = {};
3675
896
  Object.entries(data).forEach(([key, value]) => {
3676
897
  const isObject2 = value !== null && typeof value === "object" && !Array.isArray(value);
3677
- const fieldPath = resolvePath(path2, key);
898
+ const fieldPath = resolvePath(path, key);
3678
899
  if (isObject2) {
3679
900
  const serializedObject = flattenParams(value, fieldPath);
3680
901
  Object.assign(params, serializedObject);
@@ -3684,8 +905,8 @@ function flattenParams(data, path2 = "") {
3684
905
  });
3685
906
  return params;
3686
907
  }
3687
- function resolvePath(path2, key) {
3688
- return `${path2}${path2 ? "." : ""}${key}`;
908
+ function resolvePath(path, key) {
909
+ return `${path}${path ? "." : ""}${key}`;
3689
910
  }
3690
911
  var base64Encode = (value) => {
3691
912
  const base64 = typeof btoa !== "undefined" ? btoa(value) : Buffer.from(value, "utf-8").toString("base64");
@@ -3720,7 +941,7 @@ function isBaseDomain(domain) {
3720
941
  }
3721
942
  var wwwBaseDomain = "www._base_domain_";
3722
943
  function injectDataIntoProtoPath(protoPath, data) {
3723
- return protoPath.split("/").map((path2) => maybeProtoPathToData(path2, data)).join("/");
944
+ return protoPath.split("/").map((path) => maybeProtoPathToData(path, data)).join("/");
3724
945
  }
3725
946
  function maybeProtoPathToData(protoPath, data) {
3726
947
  const protoRegExpMatch = protoPath.match(REGEX_CAPTURE_PROTO_FIELD) || [];
@@ -3731,9 +952,9 @@ function maybeProtoPathToData(protoPath, data) {
3731
952
  }
3732
953
  return protoPath;
3733
954
  }
3734
- function findByPath(obj, path2, defaultValue, suffix) {
955
+ function findByPath(obj, path, defaultValue, suffix) {
3735
956
  let result = obj;
3736
- for (const field of path2.split(".")) {
957
+ for (const field of path.split(".")) {
3737
958
  if (!result) {
3738
959
  return defaultValue;
3739
960
  }
@@ -146975,7 +144196,7 @@ var violationsWithRenamedFields2 = ({ spreadPathsToArguments, explicitPathsToArg
146975
144196
  field: withRenamedArgument2(exactMatchArgumentExpression, argumentNames)
146976
144197
  };
146977
144198
  }
146978
- const longestPartialPathMatch = allPathsToArgumentsKeys?.sort((a, b) => b.length - a.length)?.find((path2) => fieldViolation.field.startsWith(path2));
144199
+ const longestPartialPathMatch = allPathsToArgumentsKeys?.sort((a, b) => b.length - a.length)?.find((path) => fieldViolation.field.startsWith(path));
146979
144200
  if (longestPartialPathMatch) {
146980
144201
  const partialMatchArgumentExpression = allPathsToArguments[longestPartialPathMatch];
146981
144202
  if (partialMatchArgumentExpression) {
@@ -147520,6 +144741,74 @@ function findConsistentHeader(response) {
147520
144741
  return response.headers?.get(X_WIX_CONSISTENT_HEADER) ?? response.headers?.get(X_WIX_CONSISTENT_HEADER.toLowerCase());
147521
144742
  }
147522
144743
 
144744
+ // src/wix-apis.ts
144745
+ var callWixAPI = async ({
144746
+ url,
144747
+ method,
144748
+ body,
144749
+ additionalHeaders,
144750
+ logger
144751
+ }) => {
144752
+ if (!process.env.WIX_TOKEN) {
144753
+ logger.warn("[wix-apis] WIX_TOKEN is not set");
144754
+ }
144755
+ try {
144756
+ logger.debug("[wix-apis] Calling Wix API...", {
144757
+ url,
144758
+ method,
144759
+ additionalHeaders
144760
+ });
144761
+ const response = await fetch(url, {
144762
+ method,
144763
+ headers: {
144764
+ "Content-Type": "application/json",
144765
+ Authorization: process.env.WIX_TOKEN,
144766
+ ...additionalHeaders
144767
+ },
144768
+ ...method === "GET" ? {} : { body: JSON.stringify(body) }
144769
+ });
144770
+ if (!response.ok) {
144771
+ const responseText = await response.text();
144772
+ logger.error(new Error("[wix-apis] Error calling Wix API"), {
144773
+ responseText,
144774
+ url,
144775
+ method,
144776
+ body,
144777
+ requestId: response.headers.get("x-wix-request-id")
144778
+ });
144779
+ return null;
144780
+ }
144781
+ return await response.json();
144782
+ } catch (error) {
144783
+ logger.error(new Error("[wix-apis] Error calling Wix API"), {
144784
+ error,
144785
+ url,
144786
+ method,
144787
+ body,
144788
+ requestId: error instanceof Error && "requestId" in error ? error.requestId : void 0
144789
+ });
144790
+ return null;
144791
+ }
144792
+ };
144793
+ var installWixApp = async (appDefId, siteId, logger) => {
144794
+ logger.debug("Installing Wix app...", { appDefId, siteId });
144795
+ const response = await callWixAPI({
144796
+ url: "https://www.wixapis.com/apps-installer-service/v1/app-instance/install",
144797
+ method: "POST",
144798
+ body: {
144799
+ tenant: {
144800
+ tenantType: "SITE",
144801
+ id: siteId
144802
+ },
144803
+ appInstance: {
144804
+ appDefId
144805
+ }
144806
+ },
144807
+ logger
144808
+ });
144809
+ return response;
144810
+ };
144811
+
147523
144812
  // src/wix-forms-apis.ts
147524
144813
  var getWixClient = async (siteId) => {
147525
144814
  const authHeaders = {
@@ -147580,46 +144869,6 @@ async function createForm5(schema, siteId, logger) {
147580
144869
  }
147581
144870
 
147582
144871
  // src/utils.ts
147583
- async function downloadZipFile(url, filePath, logger) {
147584
- return new Promise((resolve, reject) => {
147585
- const file = fs__namespace.createWriteStream(filePath);
147586
- const makeRequest = (requestUrl) => {
147587
- https__default.default.get(requestUrl, (response) => {
147588
- if (response.statusCode === 301 || response.statusCode === 302) {
147589
- const location = response.headers.location;
147590
- if (location) {
147591
- logger.debug(
147592
- `[${VERTICAL_NAME}-plugin-setup] following redirect to: ${location}`
147593
- );
147594
- makeRequest(location);
147595
- return;
147596
- }
147597
- }
147598
- if (response.statusCode !== 200) {
147599
- reject(
147600
- new Error(
147601
- `Failed to download: ${response.statusCode} ${response.statusMessage}`
147602
- )
147603
- );
147604
- return;
147605
- }
147606
- response.pipe(file);
147607
- file.on("finish", () => {
147608
- file.close();
147609
- resolve();
147610
- });
147611
- file.on("error", (err) => {
147612
- fs__namespace.unlink(filePath, () => {
147613
- });
147614
- reject(err);
147615
- });
147616
- }).on("error", (err) => {
147617
- reject(err);
147618
- });
147619
- };
147620
- makeRequest(url);
147621
- });
147622
- }
147623
144872
  var installFormsApp = async (env) => {
147624
144873
  env.logger.debug(
147625
144874
  `[${VERTICAL_NAME}-plugin-install] Installing vertical functionality...`,
@@ -147628,99 +144877,6 @@ var installFormsApp = async (env) => {
147628
144877
  await installWixApp(FORMS_APP_DEF_ID, env.WIX_SITE_ID, env.logger);
147629
144878
  env.logger.debug(`[${VERTICAL_NAME}-plugin-install] Installation completed`);
147630
144879
  };
147631
- var unzipAndMergeParastoragePluginFiles = async (env, zipUrl) => {
147632
- env.logger.debug(
147633
- `[${VERTICAL_NAME}-plugin-install] Unzipping plugin files from dependency...`
147634
- );
147635
- const zipPath = path__namespace.join(process.cwd(), "picasso-forms-plugin-files.zip");
147636
- const targetDir = path__namespace.join(env.CODEGEN_APP_ROOT, "src");
147637
- try {
147638
- env.logger.debug(
147639
- `[${VERTICAL_NAME}-plugin-install] downloading zip file to:`,
147640
- { zipPath }
147641
- );
147642
- await downloadZipFile(zipUrl, zipPath, env.logger);
147643
- const zip = new import_adm_zip.default(zipPath);
147644
- env.logger.debug(`[${VERTICAL_NAME}-plugin-install] Unzipping files...`);
147645
- zip.getEntries().forEach((entry) => {
147646
- if (!entry.isDirectory) {
147647
- const entryPath = entry.entryName;
147648
- const targetPath = path__namespace.join(targetDir, entryPath);
147649
- const targetDirPath = path__namespace.dirname(targetPath);
147650
- if (!fs__namespace.existsSync(targetDirPath)) {
147651
- fs__namespace.mkdirSync(targetDirPath, { recursive: true });
147652
- }
147653
- fs__namespace.writeFileSync(targetPath, entry.getData());
147654
- env.logger.debug(
147655
- `[${VERTICAL_NAME}-plugin-install] Extracted: ${targetPath}`
147656
- );
147657
- }
147658
- });
147659
- env.logger.debug(
147660
- `[${VERTICAL_NAME}-plugin-install] Plugin files unzipped and merged successfully`
147661
- );
147662
- } catch (error) {
147663
- env.logger.error(
147664
- new Error(
147665
- `[${VERTICAL_NAME}-plugin-install] Error downloading or unzipping plugin files:`
147666
- ),
147667
- { error }
147668
- );
147669
- throw error;
147670
- }
147671
- };
147672
- var unzipAndMergePluginFiles = async (env, useLocal = false) => {
147673
- if (useLocal) {
147674
- return unzipAndMergeLocalPluginFiles(
147675
- env,
147676
- "/Users/laurale/vibe-plugins/plugins/forms/vibe-forms-plugin-files/dist/statics/forms-plugin-files-files.zip"
147677
- );
147678
- } else {
147679
- return unzipAndMergeParastoragePluginFiles(env, PLUGIN_FILES_ZIP_URL);
147680
- }
147681
- };
147682
- var unzipAndMergeLocalPluginFiles = async (env, zipPath) => {
147683
- env.logger.debug(
147684
- `[${VERTICAL_NAME}-plugin-install] Unzipping plugin files from local file...`
147685
- );
147686
- const targetDir = path__namespace.join(env.CODEGEN_APP_ROOT, "src");
147687
- try {
147688
- env.logger.debug(
147689
- `[${VERTICAL_NAME}-plugin-install] Using local zip file:`,
147690
- { zipPath }
147691
- );
147692
- if (!fs__namespace.existsSync(zipPath)) {
147693
- throw new Error(`Local zip file not found at: ${zipPath}`);
147694
- }
147695
- const zip = new import_adm_zip.default(zipPath);
147696
- env.logger.debug(`[${VERTICAL_NAME}-plugin-install] Unzipping files...`);
147697
- zip.getEntries().forEach((entry) => {
147698
- if (!entry.isDirectory) {
147699
- const entryPath = entry.entryName;
147700
- const targetPath = path__namespace.join(targetDir, entryPath);
147701
- const targetDirPath = path__namespace.dirname(targetPath);
147702
- if (!fs__namespace.existsSync(targetDirPath)) {
147703
- fs__namespace.mkdirSync(targetDirPath, { recursive: true });
147704
- }
147705
- fs__namespace.writeFileSync(targetPath, entry.getData());
147706
- env.logger.debug(
147707
- `[${VERTICAL_NAME}-plugin-install] Extracted: ${targetPath}`
147708
- );
147709
- }
147710
- });
147711
- env.logger.debug(
147712
- `[${VERTICAL_NAME}-plugin-install] Plugin files unzipped and merged successfully`
147713
- );
147714
- } catch (error) {
147715
- env.logger.error(
147716
- new Error(
147717
- `[${VERTICAL_NAME}-plugin-install] Error unzipping plugin files:`
147718
- ),
147719
- { error }
147720
- );
147721
- throw error;
147722
- }
147723
- };
147724
144880
  var generateFormDefinitions = async (env) => {
147725
144881
  try {
147726
144882
  const userMessage = env.userRequest;
@@ -148087,7 +145243,6 @@ var install = async (env) => {
148087
145243
  env.logger.debug(
148088
145244
  `[${VERTICAL_NAME}-plugin-install] Unzipping and merging plugin files...`
148089
145245
  );
148090
- await unzipAndMergePluginFiles(env, false);
148091
145246
  env.logger.info(
148092
145247
  `
148093
145248
  \x1B[34m ==== ${VERTICAL_NAME} installation completed ==== \x1B[0m