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