@harmonyos-arkts/opencode-plugin 0.0.1 → 0.0.3

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 (78) hide show
  1. package/dist/index.js +227 -2767
  2. package/dist/templates/application/AppScope/app.json5 +10 -0
  3. package/dist/templates/application/AppScope/resources/base/element/string.json +8 -0
  4. package/dist/templates/application/AppScope/resources/base/media/background.png +0 -0
  5. package/dist/templates/application/AppScope/resources/base/media/foreground.png +0 -0
  6. package/dist/templates/application/AppScope/resources/base/media/layered_image.json +7 -0
  7. package/dist/templates/application/build-profile.json5 +42 -0
  8. package/dist/templates/application/code-linter.json5 +32 -0
  9. package/dist/templates/application/entry/build-profile.json5 +33 -0
  10. package/dist/templates/application/entry/hvigorfile.ts +6 -0
  11. package/dist/templates/application/entry/obfuscation-rules.txt +23 -0
  12. package/dist/templates/application/entry/oh-package.json5 +10 -0
  13. package/dist/templates/application/entry/src/main/ets/entryability/EntryAbility.ets +48 -0
  14. package/dist/templates/application/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +16 -0
  15. package/dist/templates/application/entry/src/main/ets/pages/Index.ets +23 -0
  16. package/dist/templates/application/entry/src/main/module.json5 +50 -0
  17. package/dist/templates/application/entry/src/main/resources/base/element/color.json +8 -0
  18. package/dist/templates/application/entry/src/main/resources/base/element/float.json +8 -0
  19. package/dist/templates/application/entry/src/main/resources/base/element/string.json +16 -0
  20. package/dist/templates/application/entry/src/main/resources/base/media/background.png +0 -0
  21. package/dist/templates/application/entry/src/main/resources/base/media/foreground.png +0 -0
  22. package/dist/templates/application/entry/src/main/resources/base/media/layered_image.json +7 -0
  23. package/dist/templates/application/entry/src/main/resources/base/media/startIcon.png +0 -0
  24. package/dist/templates/application/entry/src/main/resources/base/profile/backup_config.json +3 -0
  25. package/dist/templates/application/entry/src/main/resources/base/profile/main_pages.json +5 -0
  26. package/dist/templates/application/entry/src/main/resources/dark/element/color.json +8 -0
  27. package/dist/templates/application/entry/src/mock/mock-config.json5 +2 -0
  28. package/dist/templates/application/entry/src/ohosTest/ets/test/Ability.test.ets +35 -0
  29. package/dist/templates/application/entry/src/ohosTest/ets/test/List.test.ets +5 -0
  30. package/dist/templates/application/entry/src/ohosTest/module.json5 +11 -0
  31. package/dist/templates/application/entry/src/test/List.test.ets +5 -0
  32. package/dist/templates/application/entry/src/test/LocalUnit.test.ets +33 -0
  33. package/dist/templates/application/hvigor/hvigor-config.json5 +23 -0
  34. package/dist/templates/application/hvigorfile.ts +6 -0
  35. package/dist/templates/application/oh-package.json5 +10 -0
  36. package/dist/templates/atomic/AppScope/app.json5 +11 -0
  37. package/dist/templates/atomic/AppScope/resources/base/element/string.json +8 -0
  38. package/dist/templates/atomic/AppScope/resources/base/media/app_icon.png +0 -0
  39. package/dist/templates/atomic/build-profile.json5 +42 -0
  40. package/dist/templates/atomic/code-linter.json5 +32 -0
  41. package/dist/templates/atomic/entry/build-profile.json5 +33 -0
  42. package/dist/templates/atomic/entry/hvigorfile.ts +6 -0
  43. package/dist/templates/atomic/entry/obfuscation-rules.txt +23 -0
  44. package/dist/templates/atomic/entry/oh-package.json5 +10 -0
  45. package/dist/templates/atomic/entry/src/main/ets/entryability/EntryAbility.ets +43 -0
  46. package/dist/templates/atomic/entry/src/main/ets/pages/Index.ets +64 -0
  47. package/dist/templates/atomic/entry/src/main/module.json5 +36 -0
  48. package/dist/templates/atomic/entry/src/main/resources/base/element/color.json +8 -0
  49. package/dist/templates/atomic/entry/src/main/resources/base/element/float.json +8 -0
  50. package/dist/templates/atomic/entry/src/main/resources/base/element/string.json +16 -0
  51. package/dist/templates/atomic/entry/src/main/resources/base/media/icon.png +0 -0
  52. package/dist/templates/atomic/entry/src/main/resources/base/media/startIcon.png +0 -0
  53. package/dist/templates/atomic/entry/src/main/resources/base/profile/main_pages.json +5 -0
  54. package/dist/templates/atomic/entry/src/mock/mock-config.json5 +2 -0
  55. package/dist/templates/atomic/entry/src/ohosTest/ets/test/Ability.test.ets +35 -0
  56. package/dist/templates/atomic/entry/src/ohosTest/ets/test/List.test.ets +5 -0
  57. package/dist/templates/atomic/entry/src/ohosTest/module.json5 +11 -0
  58. package/dist/templates/atomic/entry/src/test/List.test.ets +5 -0
  59. package/dist/templates/atomic/entry/src/test/LocalUnit.test.ets +33 -0
  60. package/dist/templates/atomic/hvigor/hvigor-config.json5 +23 -0
  61. package/dist/templates/atomic/hvigorfile.ts +6 -0
  62. package/dist/templates/atomic/oh-package.json5 +9 -0
  63. package/dist/templates/module/Index.ets +1 -0
  64. package/dist/templates/module/build-profile.json5 +36 -0
  65. package/dist/templates/module/consumer-rules.txt +0 -0
  66. package/dist/templates/module/hvigorfile.ts +6 -0
  67. package/dist/templates/module/obfuscation-rules.txt +23 -0
  68. package/dist/templates/module/oh-package.json5 +9 -0
  69. package/dist/templates/module/src/main/ets/components/MainPage.ets +19 -0
  70. package/dist/templates/module/src/main/module.json5 +9 -0
  71. package/dist/templates/module/src/main/resources/base/element/float.json +8 -0
  72. package/dist/templates/module/src/main/resources/base/element/string.json +8 -0
  73. package/dist/templates/module/src/ohosTest/ets/test/Ability.test.ets +35 -0
  74. package/dist/templates/module/src/ohosTest/ets/test/List.test.ets +5 -0
  75. package/dist/templates/module/src/ohosTest/module.json5 +11 -0
  76. package/dist/templates/module/src/test/List.test.ets +5 -0
  77. package/dist/templates/module/src/test/LocalUnit.test.ets +33 -0
  78. package/package.json +8 -3
package/dist/index.js CHANGED
@@ -1,2700 +1,8 @@
1
- var __create = Object.create;
2
1
  var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
8
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
9
- }) : x)(function(x) {
10
- if (typeof require !== "undefined") return require.apply(this, arguments);
11
- throw Error('Dynamic require of "' + x + '" is not supported');
12
- });
13
- var __commonJS = (cb, mod) => function __require2() {
14
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
15
- };
16
- var __export = (target, all) => {
17
- for (var name in all)
18
- __defProp(target, name, { get: all[name], enumerable: true });
19
- };
20
- var __copyProps = (to, from, except, desc) => {
21
- if (from && typeof from === "object" || typeof from === "function") {
22
- for (let key of __getOwnPropNames(from))
23
- if (!__hasOwnProp.call(to, key) && key !== except)
24
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
25
- }
26
- return to;
27
- };
28
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
29
- // If the importer is in node compatibility mode or this is not an ESM
30
- // file that has been converted to a CommonJS file using a Babel-
31
- // compatible transform (i.e. "__esModule" has not been set), then set
32
- // "default" to the CommonJS "module.exports" for node compatibility.
33
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
34
- mod
35
- ));
36
-
37
- // node_modules/adm-zip/util/constants.js
38
- var require_constants = __commonJS({
39
- "node_modules/adm-zip/util/constants.js"(exports, module) {
40
- module.exports = {
41
- /* The local file header */
42
- LOCHDR: 30,
43
- // LOC header size
44
- LOCSIG: 67324752,
45
- // "PK\003\004"
46
- LOCVER: 4,
47
- // version needed to extract
48
- LOCFLG: 6,
49
- // general purpose bit flag
50
- LOCHOW: 8,
51
- // compression method
52
- LOCTIM: 10,
53
- // modification time (2 bytes time, 2 bytes date)
54
- LOCCRC: 14,
55
- // uncompressed file crc-32 value
56
- LOCSIZ: 18,
57
- // compressed size
58
- LOCLEN: 22,
59
- // uncompressed size
60
- LOCNAM: 26,
61
- // filename length
62
- LOCEXT: 28,
63
- // extra field length
64
- /* The Data descriptor */
65
- EXTSIG: 134695760,
66
- // "PK\007\008"
67
- EXTHDR: 16,
68
- // EXT header size
69
- EXTCRC: 4,
70
- // uncompressed file crc-32 value
71
- EXTSIZ: 8,
72
- // compressed size
73
- EXTLEN: 12,
74
- // uncompressed size
75
- /* The central directory file header */
76
- CENHDR: 46,
77
- // CEN header size
78
- CENSIG: 33639248,
79
- // "PK\001\002"
80
- CENVEM: 4,
81
- // version made by
82
- CENVER: 6,
83
- // version needed to extract
84
- CENFLG: 8,
85
- // encrypt, decrypt flags
86
- CENHOW: 10,
87
- // compression method
88
- CENTIM: 12,
89
- // modification time (2 bytes time, 2 bytes date)
90
- CENCRC: 16,
91
- // uncompressed file crc-32 value
92
- CENSIZ: 20,
93
- // compressed size
94
- CENLEN: 24,
95
- // uncompressed size
96
- CENNAM: 28,
97
- // filename length
98
- CENEXT: 30,
99
- // extra field length
100
- CENCOM: 32,
101
- // file comment length
102
- CENDSK: 34,
103
- // volume number start
104
- CENATT: 36,
105
- // internal file attributes
106
- CENATX: 38,
107
- // external file attributes (host system dependent)
108
- CENOFF: 42,
109
- // LOC header offset
110
- /* The entries in the end of central directory */
111
- ENDHDR: 22,
112
- // END header size
113
- ENDSIG: 101010256,
114
- // "PK\005\006"
115
- ENDSUB: 8,
116
- // number of entries on this disk
117
- ENDTOT: 10,
118
- // total number of entries
119
- ENDSIZ: 12,
120
- // central directory size in bytes
121
- ENDOFF: 16,
122
- // offset of first CEN header
123
- ENDCOM: 20,
124
- // zip file comment length
125
- END64HDR: 20,
126
- // zip64 END header size
127
- END64SIG: 117853008,
128
- // zip64 Locator signature, "PK\006\007"
129
- END64START: 4,
130
- // number of the disk with the start of the zip64
131
- END64OFF: 8,
132
- // relative offset of the zip64 end of central directory
133
- END64NUMDISKS: 16,
134
- // total number of disks
135
- ZIP64SIG: 101075792,
136
- // zip64 signature, "PK\006\006"
137
- ZIP64HDR: 56,
138
- // zip64 record minimum size
139
- ZIP64LEAD: 12,
140
- // leading bytes at the start of the record, not counted by the value stored in ZIP64SIZE
141
- ZIP64SIZE: 4,
142
- // zip64 size of the central directory record
143
- ZIP64VEM: 12,
144
- // zip64 version made by
145
- ZIP64VER: 14,
146
- // zip64 version needed to extract
147
- ZIP64DSK: 16,
148
- // zip64 number of this disk
149
- ZIP64DSKDIR: 20,
150
- // number of the disk with the start of the record directory
151
- ZIP64SUB: 24,
152
- // number of entries on this disk
153
- ZIP64TOT: 32,
154
- // total number of entries
155
- ZIP64SIZB: 40,
156
- // zip64 central directory size in bytes
157
- ZIP64OFF: 48,
158
- // offset of start of central directory with respect to the starting disk number
159
- ZIP64EXTRA: 56,
160
- // extensible data sector
161
- /* Compression methods */
162
- STORED: 0,
163
- // no compression
164
- SHRUNK: 1,
165
- // shrunk
166
- REDUCED1: 2,
167
- // reduced with compression factor 1
168
- REDUCED2: 3,
169
- // reduced with compression factor 2
170
- REDUCED3: 4,
171
- // reduced with compression factor 3
172
- REDUCED4: 5,
173
- // reduced with compression factor 4
174
- IMPLODED: 6,
175
- // imploded
176
- // 7 reserved for Tokenizing compression algorithm
177
- DEFLATED: 8,
178
- // deflated
179
- ENHANCED_DEFLATED: 9,
180
- // enhanced deflated
181
- PKWARE: 10,
182
- // PKWare DCL imploded
183
- // 11 reserved by PKWARE
184
- BZIP2: 12,
185
- // compressed using BZIP2
186
- // 13 reserved by PKWARE
187
- LZMA: 14,
188
- // LZMA
189
- // 15-17 reserved by PKWARE
190
- IBM_TERSE: 18,
191
- // compressed using IBM TERSE
192
- IBM_LZ77: 19,
193
- // IBM LZ77 z
194
- AES_ENCRYPT: 99,
195
- // WinZIP AES encryption method
196
- /* General purpose bit flag */
197
- // values can obtained with expression 2**bitnr
198
- FLG_ENC: 1,
199
- // Bit 0: encrypted file
200
- FLG_COMP1: 2,
201
- // Bit 1, compression option
202
- FLG_COMP2: 4,
203
- // Bit 2, compression option
204
- FLG_DESC: 8,
205
- // Bit 3, data descriptor
206
- FLG_ENH: 16,
207
- // Bit 4, enhanced deflating
208
- FLG_PATCH: 32,
209
- // Bit 5, indicates that the file is compressed patched data.
210
- FLG_STR: 64,
211
- // Bit 6, strong encryption (patented)
212
- // Bits 7-10: Currently unused.
213
- FLG_EFS: 2048,
214
- // Bit 11: Language encoding flag (EFS)
215
- // Bit 12: Reserved by PKWARE for enhanced compression.
216
- // Bit 13: encrypted the Central Directory (patented).
217
- // Bits 14-15: Reserved by PKWARE.
218
- FLG_MSK: 4096,
219
- // mask header values
220
- /* Load type */
221
- FILE: 2,
222
- BUFFER: 1,
223
- NONE: 0,
224
- /* 4.5 Extensible data fields */
225
- EF_ID: 0,
226
- EF_SIZE: 2,
227
- /* Header IDs */
228
- ID_ZIP64: 1,
229
- ID_AVINFO: 7,
230
- ID_PFS: 8,
231
- ID_OS2: 9,
232
- ID_NTFS: 10,
233
- ID_OPENVMS: 12,
234
- ID_UNIX: 13,
235
- ID_FORK: 14,
236
- ID_PATCH: 15,
237
- ID_X509_PKCS7: 20,
238
- ID_X509_CERTID_F: 21,
239
- ID_X509_CERTID_C: 22,
240
- ID_STRONGENC: 23,
241
- ID_RECORD_MGT: 24,
242
- ID_X509_PKCS7_RL: 25,
243
- ID_IBM1: 101,
244
- ID_IBM2: 102,
245
- ID_POSZIP: 18064,
246
- EF_ZIP64_OR_32: 4294967295,
247
- EF_ZIP64_OR_16: 65535,
248
- EF_ZIP64_SUNCOMP: 0,
249
- EF_ZIP64_SCOMP: 8,
250
- EF_ZIP64_RHO: 16,
251
- EF_ZIP64_DSN: 24
252
- };
253
- }
254
- });
255
-
256
- // node_modules/adm-zip/util/errors.js
257
- var require_errors = __commonJS({
258
- "node_modules/adm-zip/util/errors.js"(exports) {
259
- var errors = {
260
- /* Header error messages */
261
- INVALID_LOC: "Invalid LOC header (bad signature)",
262
- INVALID_CEN: "Invalid CEN header (bad signature)",
263
- INVALID_END: "Invalid END header (bad signature)",
264
- /* Descriptor */
265
- DESCRIPTOR_NOT_EXIST: "No descriptor present",
266
- DESCRIPTOR_UNKNOWN: "Unknown descriptor format",
267
- DESCRIPTOR_FAULTY: "Descriptor data is malformed",
268
- /* ZipEntry error messages*/
269
- NO_DATA: "Nothing to decompress",
270
- BAD_CRC: "CRC32 checksum failed {0}",
271
- FILE_IN_THE_WAY: "There is a file in the way: {0}",
272
- UNKNOWN_METHOD: "Invalid/unsupported compression method",
273
- /* Inflater error messages */
274
- AVAIL_DATA: "inflate::Available inflate data did not terminate",
275
- INVALID_DISTANCE: "inflate::Invalid literal/length or distance code in fixed or dynamic block",
276
- TO_MANY_CODES: "inflate::Dynamic block code description: too many length or distance codes",
277
- INVALID_REPEAT_LEN: "inflate::Dynamic block code description: repeat more than specified lengths",
278
- INVALID_REPEAT_FIRST: "inflate::Dynamic block code description: repeat lengths with no first length",
279
- INCOMPLETE_CODES: "inflate::Dynamic block code description: code lengths codes incomplete",
280
- INVALID_DYN_DISTANCE: "inflate::Dynamic block code description: invalid distance code lengths",
281
- INVALID_CODES_LEN: "inflate::Dynamic block code description: invalid literal/length code lengths",
282
- INVALID_STORE_BLOCK: "inflate::Stored block length did not match one's complement",
283
- INVALID_BLOCK_TYPE: "inflate::Invalid block type (type == 3)",
284
- /* ADM-ZIP error messages */
285
- CANT_EXTRACT_FILE: "Could not extract the file",
286
- CANT_OVERRIDE: "Target file already exists",
287
- DISK_ENTRY_TOO_LARGE: "Number of disk entries is too large",
288
- NO_ZIP: "No zip file was loaded",
289
- NO_ENTRY: "Entry doesn't exist",
290
- DIRECTORY_CONTENT_ERROR: "A directory cannot have content",
291
- FILE_NOT_FOUND: 'File not found: "{0}"',
292
- NOT_IMPLEMENTED: "Not implemented",
293
- INVALID_FILENAME: "Invalid filename",
294
- INVALID_FORMAT: "Invalid or unsupported zip format. No END header found",
295
- INVALID_PASS_PARAM: "Incompatible password parameter",
296
- WRONG_PASSWORD: "Wrong Password",
297
- /* ADM-ZIP */
298
- COMMENT_TOO_LONG: "Comment is too long",
299
- // Comment can be max 65535 bytes long (NOTE: some non-US characters may take more space)
300
- EXTRA_FIELD_PARSE_ERROR: "Extra field parsing error"
301
- };
302
- function E(message) {
303
- return function(...args) {
304
- if (args.length) {
305
- message = message.replace(/\{(\d)\}/g, (_, n) => args[n] || "");
306
- }
307
- return new Error("ADM-ZIP: " + message);
308
- };
309
- }
310
- for (const msg of Object.keys(errors)) {
311
- exports[msg] = E(errors[msg]);
312
- }
313
- }
314
- });
315
-
316
- // node_modules/adm-zip/util/utils.js
317
- var require_utils = __commonJS({
318
- "node_modules/adm-zip/util/utils.js"(exports, module) {
319
- var fsystem = __require("fs");
320
- var pth = __require("path");
321
- var Constants = require_constants();
322
- var Errors = require_errors();
323
- var isWin = typeof process === "object" && "win32" === process.platform;
324
- var is_Obj = (obj) => typeof obj === "object" && obj !== null;
325
- var crcTable = new Uint32Array(256).map((t, c) => {
326
- for (let k = 0; k < 8; k++) {
327
- if ((c & 1) !== 0) {
328
- c = 3988292384 ^ c >>> 1;
329
- } else {
330
- c >>>= 1;
331
- }
332
- }
333
- return c >>> 0;
334
- });
335
- function Utils(opts) {
336
- this.sep = pth.sep;
337
- this.fs = fsystem;
338
- if (is_Obj(opts)) {
339
- if (is_Obj(opts.fs) && typeof opts.fs.statSync === "function") {
340
- this.fs = opts.fs;
341
- }
342
- }
343
- }
344
- module.exports = Utils;
345
- Utils.prototype.makeDir = function(folder) {
346
- const self = this;
347
- function mkdirSync(fpath) {
348
- let resolvedPath = fpath.split(self.sep)[0];
349
- fpath.split(self.sep).forEach(function(name) {
350
- if (!name || name.substr(-1, 1) === ":") return;
351
- resolvedPath += self.sep + name;
352
- var stat;
353
- try {
354
- stat = self.fs.statSync(resolvedPath);
355
- } catch (e) {
356
- if (e.message && e.message.startsWith("ENOENT")) {
357
- self.fs.mkdirSync(resolvedPath);
358
- } else {
359
- throw e;
360
- }
361
- }
362
- if (stat && stat.isFile()) throw Errors.FILE_IN_THE_WAY(`"${resolvedPath}"`);
363
- });
364
- }
365
- mkdirSync(folder);
366
- };
367
- Utils.prototype.writeFileTo = function(path6, content, overwrite, attr) {
368
- const self = this;
369
- if (self.fs.existsSync(path6)) {
370
- if (!overwrite) return false;
371
- var stat = self.fs.statSync(path6);
372
- if (stat.isDirectory()) {
373
- return false;
374
- }
375
- }
376
- var folder = pth.dirname(path6);
377
- if (!self.fs.existsSync(folder)) {
378
- self.makeDir(folder);
379
- }
380
- var fd;
381
- try {
382
- fd = self.fs.openSync(path6, "w", 438);
383
- } catch (e) {
384
- self.fs.chmodSync(path6, 438);
385
- fd = self.fs.openSync(path6, "w", 438);
386
- }
387
- if (fd) {
388
- try {
389
- self.fs.writeSync(fd, content, 0, content.length, 0);
390
- } finally {
391
- self.fs.closeSync(fd);
392
- }
393
- }
394
- self.fs.chmodSync(path6, attr || 438);
395
- return true;
396
- };
397
- Utils.prototype.writeFileToAsync = function(path6, content, overwrite, attr, callback) {
398
- if (typeof attr === "function") {
399
- callback = attr;
400
- attr = void 0;
401
- }
402
- const self = this;
403
- self.fs.exists(path6, function(exist) {
404
- if (exist && !overwrite) return callback(false);
405
- self.fs.stat(path6, function(err, stat) {
406
- if (exist && stat.isDirectory()) {
407
- return callback(false);
408
- }
409
- var folder = pth.dirname(path6);
410
- self.fs.exists(folder, function(exists) {
411
- if (!exists) self.makeDir(folder);
412
- self.fs.open(path6, "w", 438, function(err2, fd) {
413
- if (err2) {
414
- self.fs.chmod(path6, 438, function() {
415
- self.fs.open(path6, "w", 438, function(err3, fd2) {
416
- self.fs.write(fd2, content, 0, content.length, 0, function() {
417
- self.fs.close(fd2, function() {
418
- self.fs.chmod(path6, attr || 438, function() {
419
- callback(true);
420
- });
421
- });
422
- });
423
- });
424
- });
425
- } else if (fd) {
426
- self.fs.write(fd, content, 0, content.length, 0, function() {
427
- self.fs.close(fd, function() {
428
- self.fs.chmod(path6, attr || 438, function() {
429
- callback(true);
430
- });
431
- });
432
- });
433
- } else {
434
- self.fs.chmod(path6, attr || 438, function() {
435
- callback(true);
436
- });
437
- }
438
- });
439
- });
440
- });
441
- });
442
- };
443
- Utils.prototype.findFiles = function(path6) {
444
- const self = this;
445
- function findSync(dir, pattern, recursive) {
446
- if (typeof pattern === "boolean") {
447
- recursive = pattern;
448
- pattern = void 0;
449
- }
450
- let files = [];
451
- self.fs.readdirSync(dir).forEach(function(file3) {
452
- const path7 = pth.join(dir, file3);
453
- const stat = self.fs.statSync(path7);
454
- if (!pattern || pattern.test(path7)) {
455
- files.push(pth.normalize(path7) + (stat.isDirectory() ? self.sep : ""));
456
- }
457
- if (stat.isDirectory() && recursive) files = files.concat(findSync(path7, pattern, recursive));
458
- });
459
- return files;
460
- }
461
- return findSync(path6, void 0, true);
462
- };
463
- Utils.prototype.findFilesAsync = function(dir, cb) {
464
- const self = this;
465
- let results = [];
466
- self.fs.readdir(dir, function(err, list) {
467
- if (err) return cb(err);
468
- let list_length = list.length;
469
- if (!list_length) return cb(null, results);
470
- list.forEach(function(file3) {
471
- file3 = pth.join(dir, file3);
472
- self.fs.stat(file3, function(err2, stat) {
473
- if (err2) return cb(err2);
474
- if (stat) {
475
- results.push(pth.normalize(file3) + (stat.isDirectory() ? self.sep : ""));
476
- if (stat.isDirectory()) {
477
- self.findFilesAsync(file3, function(err3, res) {
478
- if (err3) return cb(err3);
479
- results = results.concat(res);
480
- if (!--list_length) cb(null, results);
481
- });
482
- } else {
483
- if (!--list_length) cb(null, results);
484
- }
485
- }
486
- });
487
- });
488
- });
489
- };
490
- Utils.prototype.getAttributes = function() {
491
- };
492
- Utils.prototype.setAttributes = function() {
493
- };
494
- Utils.crc32update = function(crc, byte) {
495
- return crcTable[(crc ^ byte) & 255] ^ crc >>> 8;
496
- };
497
- Utils.crc32 = function(buf) {
498
- if (typeof buf === "string") {
499
- buf = Buffer.from(buf, "utf8");
500
- }
501
- let len = buf.length;
502
- let crc = ~0;
503
- for (let off = 0; off < len; ) crc = Utils.crc32update(crc, buf[off++]);
504
- return ~crc >>> 0;
505
- };
506
- Utils.methodToString = function(method) {
507
- switch (method) {
508
- case Constants.STORED:
509
- return "STORED (" + method + ")";
510
- case Constants.DEFLATED:
511
- return "DEFLATED (" + method + ")";
512
- default:
513
- return "UNSUPPORTED (" + method + ")";
514
- }
515
- };
516
- Utils.canonical = function(path6) {
517
- if (!path6) return "";
518
- const safeSuffix = pth.posix.normalize("/" + path6.split("\\").join("/"));
519
- return pth.join(".", safeSuffix);
520
- };
521
- Utils.zipnamefix = function(path6) {
522
- if (!path6) return "";
523
- const safeSuffix = pth.posix.normalize("/" + path6.split("\\").join("/"));
524
- return pth.posix.join(".", safeSuffix);
525
- };
526
- Utils.findLast = function(arr, callback) {
527
- if (!Array.isArray(arr)) throw new TypeError("arr is not array");
528
- const len = arr.length >>> 0;
529
- for (let i = len - 1; i >= 0; i--) {
530
- if (callback(arr[i], i, arr)) {
531
- return arr[i];
532
- }
533
- }
534
- return void 0;
535
- };
536
- Utils.sanitize = function(prefix, name) {
537
- prefix = pth.resolve(pth.normalize(prefix));
538
- var parts = name.split("/");
539
- for (var i = 0, l = parts.length; i < l; i++) {
540
- var path6 = pth.normalize(pth.join(prefix, parts.slice(i, l).join(pth.sep)));
541
- if (path6.indexOf(prefix) === 0) {
542
- return path6;
543
- }
544
- }
545
- return pth.normalize(pth.join(prefix, pth.basename(name)));
546
- };
547
- Utils.toBuffer = function toBuffer(input, encoder) {
548
- if (Buffer.isBuffer(input)) {
549
- return input;
550
- } else if (input instanceof Uint8Array) {
551
- return Buffer.from(input);
552
- } else {
553
- return typeof input === "string" ? encoder(input) : Buffer.alloc(0);
554
- }
555
- };
556
- Utils.readBigUInt64LE = function(buffer2, index) {
557
- const lo = buffer2.readUInt32LE(index);
558
- const hi = buffer2.readUInt32LE(index + 4);
559
- return hi * 4294967296 + lo;
560
- };
561
- Utils.fromDOS2Date = function(val) {
562
- 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);
563
- };
564
- Utils.fromDate2DOS = function(val) {
565
- let date9 = 0;
566
- let time5 = 0;
567
- if (val.getFullYear() > 1979) {
568
- date9 = (val.getFullYear() - 1980 & 127) << 9 | val.getMonth() + 1 << 5 | val.getDate();
569
- time5 = val.getHours() << 11 | val.getMinutes() << 5 | val.getSeconds() >> 1;
570
- }
571
- return date9 << 16 | time5;
572
- };
573
- Utils.isWin = isWin;
574
- Utils.crcTable = crcTable;
575
- }
576
- });
577
-
578
- // node_modules/adm-zip/util/fattr.js
579
- var require_fattr = __commonJS({
580
- "node_modules/adm-zip/util/fattr.js"(exports, module) {
581
- var pth = __require("path");
582
- module.exports = function(path6, { fs: fs5 }) {
583
- var _path = path6 || "", _obj = newAttr(), _stat = null;
584
- function newAttr() {
585
- return {
586
- directory: false,
587
- readonly: false,
588
- hidden: false,
589
- executable: false,
590
- mtime: 0,
591
- atime: 0
592
- };
593
- }
594
- if (_path && fs5.existsSync(_path)) {
595
- _stat = fs5.statSync(_path);
596
- _obj.directory = _stat.isDirectory();
597
- _obj.mtime = _stat.mtime;
598
- _obj.atime = _stat.atime;
599
- _obj.executable = (73 & _stat.mode) !== 0;
600
- _obj.readonly = (128 & _stat.mode) === 0;
601
- _obj.hidden = pth.basename(_path)[0] === ".";
602
- } else {
603
- console.warn("Invalid path: " + _path);
604
- }
605
- return {
606
- get directory() {
607
- return _obj.directory;
608
- },
609
- get readOnly() {
610
- return _obj.readonly;
611
- },
612
- get hidden() {
613
- return _obj.hidden;
614
- },
615
- get mtime() {
616
- return _obj.mtime;
617
- },
618
- get atime() {
619
- return _obj.atime;
620
- },
621
- get executable() {
622
- return _obj.executable;
623
- },
624
- decodeAttributes: function() {
625
- },
626
- encodeAttributes: function() {
627
- },
628
- toJSON: function() {
629
- return {
630
- path: _path,
631
- isDirectory: _obj.directory,
632
- isReadOnly: _obj.readonly,
633
- isHidden: _obj.hidden,
634
- isExecutable: _obj.executable,
635
- mTime: _obj.mtime,
636
- aTime: _obj.atime
637
- };
638
- },
639
- toString: function() {
640
- return JSON.stringify(this.toJSON(), null, " ");
641
- }
642
- };
643
- };
644
- }
645
- });
646
-
647
- // node_modules/adm-zip/util/decoder.js
648
- var require_decoder = __commonJS({
649
- "node_modules/adm-zip/util/decoder.js"(exports, module) {
650
- module.exports = {
651
- efs: true,
652
- encode: (data2) => Buffer.from(data2, "utf8"),
653
- decode: (data2) => data2.toString("utf8")
654
- };
655
- }
656
- });
657
-
658
- // node_modules/adm-zip/util/index.js
659
- var require_util = __commonJS({
660
- "node_modules/adm-zip/util/index.js"(exports, module) {
661
- module.exports = require_utils();
662
- module.exports.Constants = require_constants();
663
- module.exports.Errors = require_errors();
664
- module.exports.FileAttr = require_fattr();
665
- module.exports.decoder = require_decoder();
666
- }
667
- });
668
-
669
- // node_modules/adm-zip/headers/entryHeader.js
670
- var require_entryHeader = __commonJS({
671
- "node_modules/adm-zip/headers/entryHeader.js"(exports, module) {
672
- var Utils = require_util();
673
- var Constants = Utils.Constants;
674
- module.exports = function() {
675
- var _verMade = 20, _version = 10, _flags = 0, _method = 0, _time = 0, _crc = 0, _compressedSize = 0, _size3 = 0, _fnameLen = 0, _extraLen = 0, _comLen = 0, _diskStart = 0, _inattr = 0, _attr = 0, _offset = 0;
676
- _verMade |= Utils.isWin ? 2560 : 768;
677
- _flags |= Constants.FLG_EFS;
678
- const _localHeader = {
679
- extraLen: 0
680
- };
681
- const uint323 = (val) => Math.max(0, val) >>> 0;
682
- const uint16 = (val) => Math.max(0, val) & 65535;
683
- const uint8 = (val) => Math.max(0, val) & 255;
684
- _time = Utils.fromDate2DOS(/* @__PURE__ */ new Date());
685
- return {
686
- get made() {
687
- return _verMade;
688
- },
689
- set made(val) {
690
- _verMade = val;
691
- },
692
- get version() {
693
- return _version;
694
- },
695
- set version(val) {
696
- _version = val;
697
- },
698
- get flags() {
699
- return _flags;
700
- },
701
- set flags(val) {
702
- _flags = val;
703
- },
704
- get flags_efs() {
705
- return (_flags & Constants.FLG_EFS) > 0;
706
- },
707
- set flags_efs(val) {
708
- if (val) {
709
- _flags |= Constants.FLG_EFS;
710
- } else {
711
- _flags &= ~Constants.FLG_EFS;
712
- }
713
- },
714
- get flags_desc() {
715
- return (_flags & Constants.FLG_DESC) > 0;
716
- },
717
- set flags_desc(val) {
718
- if (val) {
719
- _flags |= Constants.FLG_DESC;
720
- } else {
721
- _flags &= ~Constants.FLG_DESC;
722
- }
723
- },
724
- get method() {
725
- return _method;
726
- },
727
- set method(val) {
728
- switch (val) {
729
- case Constants.STORED:
730
- this.version = 10;
731
- case Constants.DEFLATED:
732
- default:
733
- this.version = 20;
734
- }
735
- _method = val;
736
- },
737
- get time() {
738
- return Utils.fromDOS2Date(this.timeval);
739
- },
740
- set time(val) {
741
- val = new Date(val);
742
- this.timeval = Utils.fromDate2DOS(val);
743
- },
744
- get timeval() {
745
- return _time;
746
- },
747
- set timeval(val) {
748
- _time = uint323(val);
749
- },
750
- get timeHighByte() {
751
- return uint8(_time >>> 8);
752
- },
753
- get crc() {
754
- return _crc;
755
- },
756
- set crc(val) {
757
- _crc = uint323(val);
758
- },
759
- get compressedSize() {
760
- return _compressedSize;
761
- },
762
- set compressedSize(val) {
763
- _compressedSize = uint323(val);
764
- },
765
- get size() {
766
- return _size3;
767
- },
768
- set size(val) {
769
- _size3 = uint323(val);
770
- },
771
- get fileNameLength() {
772
- return _fnameLen;
773
- },
774
- set fileNameLength(val) {
775
- _fnameLen = val;
776
- },
777
- get extraLength() {
778
- return _extraLen;
779
- },
780
- set extraLength(val) {
781
- _extraLen = val;
782
- },
783
- get extraLocalLength() {
784
- return _localHeader.extraLen;
785
- },
786
- set extraLocalLength(val) {
787
- _localHeader.extraLen = val;
788
- },
789
- get commentLength() {
790
- return _comLen;
791
- },
792
- set commentLength(val) {
793
- _comLen = val;
794
- },
795
- get diskNumStart() {
796
- return _diskStart;
797
- },
798
- set diskNumStart(val) {
799
- _diskStart = uint323(val);
800
- },
801
- get inAttr() {
802
- return _inattr;
803
- },
804
- set inAttr(val) {
805
- _inattr = uint323(val);
806
- },
807
- get attr() {
808
- return _attr;
809
- },
810
- set attr(val) {
811
- _attr = uint323(val);
812
- },
813
- // get Unix file permissions
814
- get fileAttr() {
815
- return (_attr || 0) >> 16 & 4095;
816
- },
817
- get offset() {
818
- return _offset;
819
- },
820
- set offset(val) {
821
- _offset = uint323(val);
822
- },
823
- get encrypted() {
824
- return (_flags & Constants.FLG_ENC) === Constants.FLG_ENC;
825
- },
826
- get centralHeaderSize() {
827
- return Constants.CENHDR + _fnameLen + _extraLen + _comLen;
828
- },
829
- get realDataOffset() {
830
- return _offset + Constants.LOCHDR + _localHeader.fnameLen + _localHeader.extraLen;
831
- },
832
- get localHeader() {
833
- return _localHeader;
834
- },
835
- loadLocalHeaderFromBinary: function(input) {
836
- var data2 = input.slice(_offset, _offset + Constants.LOCHDR);
837
- if (data2.readUInt32LE(0) !== Constants.LOCSIG) {
838
- throw Utils.Errors.INVALID_LOC();
839
- }
840
- _localHeader.version = data2.readUInt16LE(Constants.LOCVER);
841
- _localHeader.flags = data2.readUInt16LE(Constants.LOCFLG);
842
- _localHeader.flags_desc = (_localHeader.flags & Constants.FLG_DESC) > 0;
843
- _localHeader.method = data2.readUInt16LE(Constants.LOCHOW);
844
- _localHeader.time = data2.readUInt32LE(Constants.LOCTIM);
845
- _localHeader.crc = data2.readUInt32LE(Constants.LOCCRC);
846
- _localHeader.compressedSize = data2.readUInt32LE(Constants.LOCSIZ);
847
- _localHeader.size = data2.readUInt32LE(Constants.LOCLEN);
848
- _localHeader.fnameLen = data2.readUInt16LE(Constants.LOCNAM);
849
- _localHeader.extraLen = data2.readUInt16LE(Constants.LOCEXT);
850
- const extraStart = _offset + Constants.LOCHDR + _localHeader.fnameLen;
851
- const extraEnd = extraStart + _localHeader.extraLen;
852
- return input.slice(extraStart, extraEnd);
853
- },
854
- loadFromBinary: function(data2) {
855
- if (data2.length !== Constants.CENHDR || data2.readUInt32LE(0) !== Constants.CENSIG) {
856
- throw Utils.Errors.INVALID_CEN();
857
- }
858
- _verMade = data2.readUInt16LE(Constants.CENVEM);
859
- _version = data2.readUInt16LE(Constants.CENVER);
860
- _flags = data2.readUInt16LE(Constants.CENFLG);
861
- _method = data2.readUInt16LE(Constants.CENHOW);
862
- _time = data2.readUInt32LE(Constants.CENTIM);
863
- _crc = data2.readUInt32LE(Constants.CENCRC);
864
- _compressedSize = data2.readUInt32LE(Constants.CENSIZ);
865
- _size3 = data2.readUInt32LE(Constants.CENLEN);
866
- _fnameLen = data2.readUInt16LE(Constants.CENNAM);
867
- _extraLen = data2.readUInt16LE(Constants.CENEXT);
868
- _comLen = data2.readUInt16LE(Constants.CENCOM);
869
- _diskStart = data2.readUInt16LE(Constants.CENDSK);
870
- _inattr = data2.readUInt16LE(Constants.CENATT);
871
- _attr = data2.readUInt32LE(Constants.CENATX);
872
- _offset = data2.readUInt32LE(Constants.CENOFF);
873
- },
874
- localHeaderToBinary: function() {
875
- var data2 = Buffer.alloc(Constants.LOCHDR);
876
- data2.writeUInt32LE(Constants.LOCSIG, 0);
877
- data2.writeUInt16LE(_version, Constants.LOCVER);
878
- data2.writeUInt16LE(_flags, Constants.LOCFLG);
879
- data2.writeUInt16LE(_method, Constants.LOCHOW);
880
- data2.writeUInt32LE(_time, Constants.LOCTIM);
881
- data2.writeUInt32LE(_crc, Constants.LOCCRC);
882
- data2.writeUInt32LE(_compressedSize, Constants.LOCSIZ);
883
- data2.writeUInt32LE(_size3, Constants.LOCLEN);
884
- data2.writeUInt16LE(_fnameLen, Constants.LOCNAM);
885
- data2.writeUInt16LE(_localHeader.extraLen, Constants.LOCEXT);
886
- return data2;
887
- },
888
- centralHeaderToBinary: function() {
889
- var data2 = Buffer.alloc(Constants.CENHDR + _fnameLen + _extraLen + _comLen);
890
- data2.writeUInt32LE(Constants.CENSIG, 0);
891
- data2.writeUInt16LE(_verMade, Constants.CENVEM);
892
- data2.writeUInt16LE(_version, Constants.CENVER);
893
- data2.writeUInt16LE(_flags, Constants.CENFLG);
894
- data2.writeUInt16LE(_method, Constants.CENHOW);
895
- data2.writeUInt32LE(_time, Constants.CENTIM);
896
- data2.writeUInt32LE(_crc, Constants.CENCRC);
897
- data2.writeUInt32LE(_compressedSize, Constants.CENSIZ);
898
- data2.writeUInt32LE(_size3, Constants.CENLEN);
899
- data2.writeUInt16LE(_fnameLen, Constants.CENNAM);
900
- data2.writeUInt16LE(_extraLen, Constants.CENEXT);
901
- data2.writeUInt16LE(_comLen, Constants.CENCOM);
902
- data2.writeUInt16LE(_diskStart, Constants.CENDSK);
903
- data2.writeUInt16LE(_inattr, Constants.CENATT);
904
- data2.writeUInt32LE(_attr, Constants.CENATX);
905
- data2.writeUInt32LE(_offset, Constants.CENOFF);
906
- return data2;
907
- },
908
- toJSON: function() {
909
- const bytes = function(nr) {
910
- return nr + " bytes";
911
- };
912
- return {
913
- made: _verMade,
914
- version: _version,
915
- flags: _flags,
916
- method: Utils.methodToString(_method),
917
- time: this.time,
918
- crc: "0x" + _crc.toString(16).toUpperCase(),
919
- compressedSize: bytes(_compressedSize),
920
- size: bytes(_size3),
921
- fileNameLength: bytes(_fnameLen),
922
- extraLength: bytes(_extraLen),
923
- commentLength: bytes(_comLen),
924
- diskNumStart: _diskStart,
925
- inAttr: _inattr,
926
- attr: _attr,
927
- offset: _offset,
928
- centralHeaderSize: bytes(Constants.CENHDR + _fnameLen + _extraLen + _comLen)
929
- };
930
- },
931
- toString: function() {
932
- return JSON.stringify(this.toJSON(), null, " ");
933
- }
934
- };
935
- };
936
- }
937
- });
938
-
939
- // node_modules/adm-zip/headers/mainHeader.js
940
- var require_mainHeader = __commonJS({
941
- "node_modules/adm-zip/headers/mainHeader.js"(exports, module) {
942
- var Utils = require_util();
943
- var Constants = Utils.Constants;
944
- module.exports = function() {
945
- var _volumeEntries = 0, _totalEntries = 0, _size3 = 0, _offset = 0, _commentLength = 0;
946
- return {
947
- get diskEntries() {
948
- return _volumeEntries;
949
- },
950
- set diskEntries(val) {
951
- _volumeEntries = _totalEntries = val;
952
- },
953
- get totalEntries() {
954
- return _totalEntries;
955
- },
956
- set totalEntries(val) {
957
- _totalEntries = _volumeEntries = val;
958
- },
959
- get size() {
960
- return _size3;
961
- },
962
- set size(val) {
963
- _size3 = val;
964
- },
965
- get offset() {
966
- return _offset;
967
- },
968
- set offset(val) {
969
- _offset = val;
970
- },
971
- get commentLength() {
972
- return _commentLength;
973
- },
974
- set commentLength(val) {
975
- _commentLength = val;
976
- },
977
- get mainHeaderSize() {
978
- return Constants.ENDHDR + _commentLength;
979
- },
980
- loadFromBinary: function(data2) {
981
- if ((data2.length !== Constants.ENDHDR || data2.readUInt32LE(0) !== Constants.ENDSIG) && (data2.length < Constants.ZIP64HDR || data2.readUInt32LE(0) !== Constants.ZIP64SIG)) {
982
- throw Utils.Errors.INVALID_END();
983
- }
984
- if (data2.readUInt32LE(0) === Constants.ENDSIG) {
985
- _volumeEntries = data2.readUInt16LE(Constants.ENDSUB);
986
- _totalEntries = data2.readUInt16LE(Constants.ENDTOT);
987
- _size3 = data2.readUInt32LE(Constants.ENDSIZ);
988
- _offset = data2.readUInt32LE(Constants.ENDOFF);
989
- _commentLength = data2.readUInt16LE(Constants.ENDCOM);
990
- } else {
991
- _volumeEntries = Utils.readBigUInt64LE(data2, Constants.ZIP64SUB);
992
- _totalEntries = Utils.readBigUInt64LE(data2, Constants.ZIP64TOT);
993
- _size3 = Utils.readBigUInt64LE(data2, Constants.ZIP64SIZE);
994
- _offset = Utils.readBigUInt64LE(data2, Constants.ZIP64OFF);
995
- _commentLength = 0;
996
- }
997
- },
998
- toBinary: function() {
999
- var b = Buffer.alloc(Constants.ENDHDR + _commentLength);
1000
- b.writeUInt32LE(Constants.ENDSIG, 0);
1001
- b.writeUInt32LE(0, 4);
1002
- b.writeUInt16LE(_volumeEntries, Constants.ENDSUB);
1003
- b.writeUInt16LE(_totalEntries, Constants.ENDTOT);
1004
- b.writeUInt32LE(_size3, Constants.ENDSIZ);
1005
- b.writeUInt32LE(_offset, Constants.ENDOFF);
1006
- b.writeUInt16LE(_commentLength, Constants.ENDCOM);
1007
- b.fill(" ", Constants.ENDHDR);
1008
- return b;
1009
- },
1010
- toJSON: function() {
1011
- const offset = function(nr, len) {
1012
- let offs = nr.toString(16).toUpperCase();
1013
- while (offs.length < len) offs = "0" + offs;
1014
- return "0x" + offs;
1015
- };
1016
- return {
1017
- diskEntries: _volumeEntries,
1018
- totalEntries: _totalEntries,
1019
- size: _size3 + " bytes",
1020
- offset: offset(_offset, 4),
1021
- commentLength: _commentLength
1022
- };
1023
- },
1024
- toString: function() {
1025
- return JSON.stringify(this.toJSON(), null, " ");
1026
- }
1027
- };
1028
- };
1029
- }
1030
- });
1031
-
1032
- // node_modules/adm-zip/headers/index.js
1033
- var require_headers = __commonJS({
1034
- "node_modules/adm-zip/headers/index.js"(exports) {
1035
- exports.EntryHeader = require_entryHeader();
1036
- exports.MainHeader = require_mainHeader();
1037
- }
1038
- });
1039
-
1040
- // node_modules/adm-zip/methods/deflater.js
1041
- var require_deflater = __commonJS({
1042
- "node_modules/adm-zip/methods/deflater.js"(exports, module) {
1043
- module.exports = function(inbuf) {
1044
- var zlib = __require("zlib");
1045
- var opts = { chunkSize: (parseInt(inbuf.length / 1024) + 1) * 1024 };
1046
- return {
1047
- deflate: function() {
1048
- return zlib.deflateRawSync(inbuf, opts);
1049
- },
1050
- deflateAsync: function(callback) {
1051
- var tmp = zlib.createDeflateRaw(opts), parts = [], total = 0;
1052
- tmp.on("data", function(data2) {
1053
- parts.push(data2);
1054
- total += data2.length;
1055
- });
1056
- tmp.on("end", function() {
1057
- var buf = Buffer.alloc(total), written = 0;
1058
- buf.fill(0);
1059
- for (var i = 0; i < parts.length; i++) {
1060
- var part = parts[i];
1061
- part.copy(buf, written);
1062
- written += part.length;
1063
- }
1064
- callback && callback(buf);
1065
- });
1066
- tmp.end(inbuf);
1067
- }
1068
- };
1069
- };
1070
- }
1071
- });
1072
-
1073
- // node_modules/adm-zip/methods/inflater.js
1074
- var require_inflater = __commonJS({
1075
- "node_modules/adm-zip/methods/inflater.js"(exports, module) {
1076
- var version3 = +(process.versions ? process.versions.node : "").split(".")[0] || 0;
1077
- module.exports = function(inbuf, expectedLength) {
1078
- var zlib = __require("zlib");
1079
- const option = version3 >= 15 && expectedLength > 0 ? { maxOutputLength: expectedLength } : {};
1080
- return {
1081
- inflate: function() {
1082
- return zlib.inflateRawSync(inbuf, option);
1083
- },
1084
- inflateAsync: function(callback) {
1085
- var tmp = zlib.createInflateRaw(option), parts = [], total = 0;
1086
- tmp.on("data", function(data2) {
1087
- parts.push(data2);
1088
- total += data2.length;
1089
- });
1090
- tmp.on("end", function() {
1091
- var buf = Buffer.alloc(total), written = 0;
1092
- buf.fill(0);
1093
- for (var i = 0; i < parts.length; i++) {
1094
- var part = parts[i];
1095
- part.copy(buf, written);
1096
- written += part.length;
1097
- }
1098
- callback && callback(buf);
1099
- });
1100
- tmp.end(inbuf);
1101
- }
1102
- };
1103
- };
1104
- }
1105
- });
1106
-
1107
- // node_modules/adm-zip/methods/zipcrypto.js
1108
- var require_zipcrypto = __commonJS({
1109
- "node_modules/adm-zip/methods/zipcrypto.js"(exports, module) {
1110
- "use strict";
1111
- var { randomFillSync } = __require("crypto");
1112
- var Errors = require_errors();
1113
- var crctable = new Uint32Array(256).map((t, crc) => {
1114
- for (let j = 0; j < 8; j++) {
1115
- if (0 !== (crc & 1)) {
1116
- crc = crc >>> 1 ^ 3988292384;
1117
- } else {
1118
- crc >>>= 1;
1119
- }
1120
- }
1121
- return crc >>> 0;
1122
- });
1123
- var uMul = (a, b) => Math.imul(a, b) >>> 0;
1124
- var crc32update = (pCrc32, bval) => {
1125
- return crctable[(pCrc32 ^ bval) & 255] ^ pCrc32 >>> 8;
1126
- };
1127
- var genSalt = () => {
1128
- if ("function" === typeof randomFillSync) {
1129
- return randomFillSync(Buffer.alloc(12));
1130
- } else {
1131
- return genSalt.node();
1132
- }
1133
- };
1134
- genSalt.node = () => {
1135
- const salt = Buffer.alloc(12);
1136
- const len = salt.length;
1137
- for (let i = 0; i < len; i++) salt[i] = Math.random() * 256 & 255;
1138
- return salt;
1139
- };
1140
- var config4 = {
1141
- genSalt
1142
- };
1143
- function Initkeys(pw) {
1144
- const pass = Buffer.isBuffer(pw) ? pw : Buffer.from(pw);
1145
- this.keys = new Uint32Array([305419896, 591751049, 878082192]);
1146
- for (let i = 0; i < pass.length; i++) {
1147
- this.updateKeys(pass[i]);
1148
- }
1149
- }
1150
- Initkeys.prototype.updateKeys = function(byteValue) {
1151
- const keys = this.keys;
1152
- keys[0] = crc32update(keys[0], byteValue);
1153
- keys[1] += keys[0] & 255;
1154
- keys[1] = uMul(keys[1], 134775813) + 1;
1155
- keys[2] = crc32update(keys[2], keys[1] >>> 24);
1156
- return byteValue;
1157
- };
1158
- Initkeys.prototype.next = function() {
1159
- const k = (this.keys[2] | 2) >>> 0;
1160
- return uMul(k, k ^ 1) >> 8 & 255;
1161
- };
1162
- function make_decrypter(pwd) {
1163
- const keys = new Initkeys(pwd);
1164
- return function(data2) {
1165
- const result = Buffer.alloc(data2.length);
1166
- let pos = 0;
1167
- for (let c of data2) {
1168
- result[pos++] = keys.updateKeys(c ^ keys.next());
1169
- }
1170
- return result;
1171
- };
1172
- }
1173
- function make_encrypter(pwd) {
1174
- const keys = new Initkeys(pwd);
1175
- return function(data2, result, pos = 0) {
1176
- if (!result) result = Buffer.alloc(data2.length);
1177
- for (let c of data2) {
1178
- const k = keys.next();
1179
- result[pos++] = c ^ k;
1180
- keys.updateKeys(c);
1181
- }
1182
- return result;
1183
- };
1184
- }
1185
- function decrypt(data2, header, pwd) {
1186
- if (!data2 || !Buffer.isBuffer(data2) || data2.length < 12) {
1187
- return Buffer.alloc(0);
1188
- }
1189
- const decrypter = make_decrypter(pwd);
1190
- const salt = decrypter(data2.slice(0, 12));
1191
- const verifyByte = (header.flags & 8) === 8 ? header.timeHighByte : header.crc >>> 24;
1192
- if (salt[11] !== verifyByte) {
1193
- throw Errors.WRONG_PASSWORD();
1194
- }
1195
- return decrypter(data2.slice(12));
1196
- }
1197
- function _salter(data2) {
1198
- if (Buffer.isBuffer(data2) && data2.length >= 12) {
1199
- config4.genSalt = function() {
1200
- return data2.slice(0, 12);
1201
- };
1202
- } else if (data2 === "node") {
1203
- config4.genSalt = genSalt.node;
1204
- } else {
1205
- config4.genSalt = genSalt;
1206
- }
1207
- }
1208
- function encrypt(data2, header, pwd, oldlike = false) {
1209
- if (data2 == null) data2 = Buffer.alloc(0);
1210
- if (!Buffer.isBuffer(data2)) data2 = Buffer.from(data2.toString());
1211
- const encrypter = make_encrypter(pwd);
1212
- const salt = config4.genSalt();
1213
- salt[11] = header.crc >>> 24 & 255;
1214
- if (oldlike) salt[10] = header.crc >>> 16 & 255;
1215
- const result = Buffer.alloc(data2.length + 12);
1216
- encrypter(salt, result);
1217
- return encrypter(data2, result, 12);
1218
- }
1219
- module.exports = { decrypt, encrypt, _salter };
1220
- }
1221
- });
1222
-
1223
- // node_modules/adm-zip/methods/index.js
1224
- var require_methods = __commonJS({
1225
- "node_modules/adm-zip/methods/index.js"(exports) {
1226
- exports.Deflater = require_deflater();
1227
- exports.Inflater = require_inflater();
1228
- exports.ZipCrypto = require_zipcrypto();
1229
- }
1230
- });
1231
-
1232
- // node_modules/adm-zip/zipEntry.js
1233
- var require_zipEntry = __commonJS({
1234
- "node_modules/adm-zip/zipEntry.js"(exports, module) {
1235
- var Utils = require_util();
1236
- var Headers = require_headers();
1237
- var Constants = Utils.Constants;
1238
- var Methods = require_methods();
1239
- module.exports = function(options, input) {
1240
- 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;
1241
- const opts = options;
1242
- const decoder = typeof opts.decoder === "object" ? opts.decoder : Utils.decoder;
1243
- _efs = decoder.hasOwnProperty("efs") ? decoder.efs : false;
1244
- function getCompressedDataFromZip() {
1245
- if (!input || !(input instanceof Uint8Array)) {
1246
- return Buffer.alloc(0);
1247
- }
1248
- _extralocal = _centralHeader.loadLocalHeaderFromBinary(input);
1249
- return input.slice(_centralHeader.realDataOffset, _centralHeader.realDataOffset + _centralHeader.compressedSize);
1250
- }
1251
- function crc32OK(data2) {
1252
- if (!_centralHeader.flags_desc && !_centralHeader.localHeader.flags_desc) {
1253
- if (Utils.crc32(data2) !== _centralHeader.localHeader.crc) {
1254
- return false;
1255
- }
1256
- } else {
1257
- const descriptor = {};
1258
- const dataEndOffset = _centralHeader.realDataOffset + _centralHeader.compressedSize;
1259
- if (input.readUInt32LE(dataEndOffset) == Constants.LOCSIG || input.readUInt32LE(dataEndOffset) == Constants.CENSIG) {
1260
- throw Utils.Errors.DESCRIPTOR_NOT_EXIST();
1261
- }
1262
- if (input.readUInt32LE(dataEndOffset) == Constants.EXTSIG) {
1263
- descriptor.crc = input.readUInt32LE(dataEndOffset + Constants.EXTCRC);
1264
- descriptor.compressedSize = input.readUInt32LE(dataEndOffset + Constants.EXTSIZ);
1265
- descriptor.size = input.readUInt32LE(dataEndOffset + Constants.EXTLEN);
1266
- } else if (input.readUInt16LE(dataEndOffset + 12) === 19280) {
1267
- descriptor.crc = input.readUInt32LE(dataEndOffset + Constants.EXTCRC - 4);
1268
- descriptor.compressedSize = input.readUInt32LE(dataEndOffset + Constants.EXTSIZ - 4);
1269
- descriptor.size = input.readUInt32LE(dataEndOffset + Constants.EXTLEN - 4);
1270
- } else {
1271
- throw Utils.Errors.DESCRIPTOR_UNKNOWN();
1272
- }
1273
- if (descriptor.compressedSize !== _centralHeader.compressedSize || descriptor.size !== _centralHeader.size || descriptor.crc !== _centralHeader.crc) {
1274
- throw Utils.Errors.DESCRIPTOR_FAULTY();
1275
- }
1276
- if (Utils.crc32(data2) !== descriptor.crc) {
1277
- return false;
1278
- }
1279
- }
1280
- return true;
1281
- }
1282
- function decompress(async, callback, pass) {
1283
- if (typeof callback === "undefined" && typeof async === "string") {
1284
- pass = async;
1285
- async = void 0;
1286
- }
1287
- if (_isDirectory) {
1288
- if (async && callback) {
1289
- callback(Buffer.alloc(0), Utils.Errors.DIRECTORY_CONTENT_ERROR());
1290
- }
1291
- return Buffer.alloc(0);
1292
- }
1293
- var compressedData = getCompressedDataFromZip();
1294
- if (compressedData.length === 0) {
1295
- if (async && callback) callback(compressedData);
1296
- return compressedData;
1297
- }
1298
- if (_centralHeader.encrypted) {
1299
- if ("string" !== typeof pass && !Buffer.isBuffer(pass)) {
1300
- throw Utils.Errors.INVALID_PASS_PARAM();
1301
- }
1302
- compressedData = Methods.ZipCrypto.decrypt(compressedData, _centralHeader, pass);
1303
- }
1304
- var data2 = Buffer.alloc(_centralHeader.size);
1305
- switch (_centralHeader.method) {
1306
- case Utils.Constants.STORED:
1307
- compressedData.copy(data2);
1308
- if (!crc32OK(data2)) {
1309
- if (async && callback) callback(data2, Utils.Errors.BAD_CRC());
1310
- throw Utils.Errors.BAD_CRC();
1311
- } else {
1312
- if (async && callback) callback(data2);
1313
- return data2;
1314
- }
1315
- case Utils.Constants.DEFLATED:
1316
- var inflater = new Methods.Inflater(compressedData, _centralHeader.size);
1317
- if (!async) {
1318
- const result = inflater.inflate(data2);
1319
- result.copy(data2, 0);
1320
- if (!crc32OK(data2)) {
1321
- throw Utils.Errors.BAD_CRC(`"${decoder.decode(_entryName)}"`);
1322
- }
1323
- return data2;
1324
- } else {
1325
- inflater.inflateAsync(function(result) {
1326
- result.copy(result, 0);
1327
- if (callback) {
1328
- if (!crc32OK(result)) {
1329
- callback(result, Utils.Errors.BAD_CRC());
1330
- } else {
1331
- callback(result);
1332
- }
1333
- }
1334
- });
1335
- }
1336
- break;
1337
- default:
1338
- if (async && callback) callback(Buffer.alloc(0), Utils.Errors.UNKNOWN_METHOD());
1339
- throw Utils.Errors.UNKNOWN_METHOD();
1340
- }
1341
- }
1342
- function compress(async, callback) {
1343
- if ((!uncompressedData || !uncompressedData.length) && Buffer.isBuffer(input)) {
1344
- if (async && callback) callback(getCompressedDataFromZip());
1345
- return getCompressedDataFromZip();
1346
- }
1347
- if (uncompressedData.length && !_isDirectory) {
1348
- var compressedData;
1349
- switch (_centralHeader.method) {
1350
- case Utils.Constants.STORED:
1351
- _centralHeader.compressedSize = _centralHeader.size;
1352
- compressedData = Buffer.alloc(uncompressedData.length);
1353
- uncompressedData.copy(compressedData);
1354
- if (async && callback) callback(compressedData);
1355
- return compressedData;
1356
- default:
1357
- case Utils.Constants.DEFLATED:
1358
- var deflater = new Methods.Deflater(uncompressedData);
1359
- if (!async) {
1360
- var deflated = deflater.deflate();
1361
- _centralHeader.compressedSize = deflated.length;
1362
- return deflated;
1363
- } else {
1364
- deflater.deflateAsync(function(data2) {
1365
- compressedData = Buffer.alloc(data2.length);
1366
- _centralHeader.compressedSize = data2.length;
1367
- data2.copy(compressedData);
1368
- callback && callback(compressedData);
1369
- });
1370
- }
1371
- deflater = null;
1372
- break;
1373
- }
1374
- } else if (async && callback) {
1375
- callback(Buffer.alloc(0));
1376
- } else {
1377
- return Buffer.alloc(0);
1378
- }
1379
- }
1380
- function readUInt64LE(buffer2, offset) {
1381
- return Utils.readBigUInt64LE(buffer2, offset);
1382
- }
1383
- function parseExtra(data2) {
1384
- try {
1385
- var offset = 0;
1386
- var signature, size, part;
1387
- while (offset + 4 < data2.length) {
1388
- signature = data2.readUInt16LE(offset);
1389
- offset += 2;
1390
- size = data2.readUInt16LE(offset);
1391
- offset += 2;
1392
- part = data2.slice(offset, offset + size);
1393
- offset += size;
1394
- if (Constants.ID_ZIP64 === signature) {
1395
- parseZip64ExtendedInformation(part);
1396
- }
1397
- }
1398
- } catch (error92) {
1399
- throw Utils.Errors.EXTRA_FIELD_PARSE_ERROR();
1400
- }
1401
- }
1402
- function parseZip64ExtendedInformation(data2) {
1403
- var size, compressedSize, offset, diskNumStart;
1404
- if (data2.length >= Constants.EF_ZIP64_SCOMP) {
1405
- size = readUInt64LE(data2, Constants.EF_ZIP64_SUNCOMP);
1406
- if (_centralHeader.size === Constants.EF_ZIP64_OR_32) {
1407
- _centralHeader.size = size;
1408
- }
1409
- }
1410
- if (data2.length >= Constants.EF_ZIP64_RHO) {
1411
- compressedSize = readUInt64LE(data2, Constants.EF_ZIP64_SCOMP);
1412
- if (_centralHeader.compressedSize === Constants.EF_ZIP64_OR_32) {
1413
- _centralHeader.compressedSize = compressedSize;
1414
- }
1415
- }
1416
- if (data2.length >= Constants.EF_ZIP64_DSN) {
1417
- offset = readUInt64LE(data2, Constants.EF_ZIP64_RHO);
1418
- if (_centralHeader.offset === Constants.EF_ZIP64_OR_32) {
1419
- _centralHeader.offset = offset;
1420
- }
1421
- }
1422
- if (data2.length >= Constants.EF_ZIP64_DSN + 4) {
1423
- diskNumStart = data2.readUInt32LE(Constants.EF_ZIP64_DSN);
1424
- if (_centralHeader.diskNumStart === Constants.EF_ZIP64_OR_16) {
1425
- _centralHeader.diskNumStart = diskNumStart;
1426
- }
1427
- }
1428
- }
1429
- return {
1430
- get entryName() {
1431
- return decoder.decode(_entryName);
1432
- },
1433
- get rawEntryName() {
1434
- return _entryName;
1435
- },
1436
- set entryName(val) {
1437
- _entryName = Utils.toBuffer(val, decoder.encode);
1438
- var lastChar = _entryName[_entryName.length - 1];
1439
- _isDirectory = lastChar === 47 || lastChar === 92;
1440
- _centralHeader.fileNameLength = _entryName.length;
1441
- },
1442
- get efs() {
1443
- if (typeof _efs === "function") {
1444
- return _efs(this.entryName);
1445
- } else {
1446
- return _efs;
1447
- }
1448
- },
1449
- get extra() {
1450
- return _extra;
1451
- },
1452
- set extra(val) {
1453
- _extra = val;
1454
- _centralHeader.extraLength = val.length;
1455
- parseExtra(val);
1456
- },
1457
- get comment() {
1458
- return decoder.decode(_comment);
1459
- },
1460
- set comment(val) {
1461
- _comment = Utils.toBuffer(val, decoder.encode);
1462
- _centralHeader.commentLength = _comment.length;
1463
- if (_comment.length > 65535) throw Utils.Errors.COMMENT_TOO_LONG();
1464
- },
1465
- get name() {
1466
- var n = decoder.decode(_entryName);
1467
- return _isDirectory ? n.substr(n.length - 1).split("/").pop() : n.split("/").pop();
1468
- },
1469
- get isDirectory() {
1470
- return _isDirectory;
1471
- },
1472
- getCompressedData: function() {
1473
- return compress(false, null);
1474
- },
1475
- getCompressedDataAsync: function(callback) {
1476
- compress(true, callback);
1477
- },
1478
- setData: function(value) {
1479
- uncompressedData = Utils.toBuffer(value, Utils.decoder.encode);
1480
- if (!_isDirectory && uncompressedData.length) {
1481
- _centralHeader.size = uncompressedData.length;
1482
- _centralHeader.method = Utils.Constants.DEFLATED;
1483
- _centralHeader.crc = Utils.crc32(value);
1484
- _centralHeader.changed = true;
1485
- } else {
1486
- _centralHeader.method = Utils.Constants.STORED;
1487
- }
1488
- },
1489
- getData: function(pass) {
1490
- if (_centralHeader.changed) {
1491
- return uncompressedData;
1492
- } else {
1493
- return decompress(false, null, pass);
1494
- }
1495
- },
1496
- getDataAsync: function(callback, pass) {
1497
- if (_centralHeader.changed) {
1498
- callback(uncompressedData);
1499
- } else {
1500
- decompress(true, callback, pass);
1501
- }
1502
- },
1503
- set attr(attr) {
1504
- _centralHeader.attr = attr;
1505
- },
1506
- get attr() {
1507
- return _centralHeader.attr;
1508
- },
1509
- set header(data2) {
1510
- _centralHeader.loadFromBinary(data2);
1511
- },
1512
- get header() {
1513
- return _centralHeader;
1514
- },
1515
- packCentralHeader: function() {
1516
- _centralHeader.flags_efs = this.efs;
1517
- _centralHeader.extraLength = _extra.length;
1518
- var header = _centralHeader.centralHeaderToBinary();
1519
- var addpos = Utils.Constants.CENHDR;
1520
- _entryName.copy(header, addpos);
1521
- addpos += _entryName.length;
1522
- _extra.copy(header, addpos);
1523
- addpos += _centralHeader.extraLength;
1524
- _comment.copy(header, addpos);
1525
- return header;
1526
- },
1527
- packLocalHeader: function() {
1528
- let addpos = 0;
1529
- _centralHeader.flags_efs = this.efs;
1530
- _centralHeader.extraLocalLength = _extralocal.length;
1531
- const localHeaderBuf = _centralHeader.localHeaderToBinary();
1532
- const localHeader = Buffer.alloc(localHeaderBuf.length + _entryName.length + _centralHeader.extraLocalLength);
1533
- localHeaderBuf.copy(localHeader, addpos);
1534
- addpos += localHeaderBuf.length;
1535
- _entryName.copy(localHeader, addpos);
1536
- addpos += _entryName.length;
1537
- _extralocal.copy(localHeader, addpos);
1538
- addpos += _extralocal.length;
1539
- return localHeader;
1540
- },
1541
- toJSON: function() {
1542
- const bytes = function(nr) {
1543
- return "<" + (nr && nr.length + " bytes buffer" || "null") + ">";
1544
- };
1545
- return {
1546
- entryName: this.entryName,
1547
- name: this.name,
1548
- comment: this.comment,
1549
- isDirectory: this.isDirectory,
1550
- header: _centralHeader.toJSON(),
1551
- compressedData: bytes(input),
1552
- data: bytes(uncompressedData)
1553
- };
1554
- },
1555
- toString: function() {
1556
- return JSON.stringify(this.toJSON(), null, " ");
1557
- }
1558
- };
1559
- };
1560
- }
1561
- });
1562
-
1563
- // node_modules/adm-zip/zipFile.js
1564
- var require_zipFile = __commonJS({
1565
- "node_modules/adm-zip/zipFile.js"(exports, module) {
1566
- var ZipEntry = require_zipEntry();
1567
- var Headers = require_headers();
1568
- var Utils = require_util();
1569
- module.exports = function(inBuffer, options) {
1570
- var entryList = [], entryTable = {}, _comment = Buffer.alloc(0), mainHeader = new Headers.MainHeader(), loadedEntries = false;
1571
- var password = null;
1572
- const temporary = /* @__PURE__ */ new Set();
1573
- const opts = options;
1574
- const { noSort, decoder } = opts;
1575
- if (inBuffer) {
1576
- readMainHeader(opts.readEntries);
1577
- } else {
1578
- loadedEntries = true;
1579
- }
1580
- function makeTemporaryFolders() {
1581
- const foldersList = /* @__PURE__ */ new Set();
1582
- for (const elem of Object.keys(entryTable)) {
1583
- const elements = elem.split("/");
1584
- elements.pop();
1585
- if (!elements.length) continue;
1586
- for (let i = 0; i < elements.length; i++) {
1587
- const sub = elements.slice(0, i + 1).join("/") + "/";
1588
- foldersList.add(sub);
1589
- }
1590
- }
1591
- for (const elem of foldersList) {
1592
- if (!(elem in entryTable)) {
1593
- const tempfolder = new ZipEntry(opts);
1594
- tempfolder.entryName = elem;
1595
- tempfolder.attr = 16;
1596
- tempfolder.temporary = true;
1597
- entryList.push(tempfolder);
1598
- entryTable[tempfolder.entryName] = tempfolder;
1599
- temporary.add(tempfolder);
1600
- }
1601
- }
1602
- }
1603
- function readEntries() {
1604
- loadedEntries = true;
1605
- entryTable = {};
1606
- if (mainHeader.diskEntries > (inBuffer.length - mainHeader.offset) / Utils.Constants.CENHDR) {
1607
- throw Utils.Errors.DISK_ENTRY_TOO_LARGE();
1608
- }
1609
- entryList = new Array(mainHeader.diskEntries);
1610
- var index = mainHeader.offset;
1611
- for (var i = 0; i < entryList.length; i++) {
1612
- var tmp = index, entry = new ZipEntry(opts, inBuffer);
1613
- entry.header = inBuffer.slice(tmp, tmp += Utils.Constants.CENHDR);
1614
- entry.entryName = inBuffer.slice(tmp, tmp += entry.header.fileNameLength);
1615
- if (entry.header.extraLength) {
1616
- entry.extra = inBuffer.slice(tmp, tmp += entry.header.extraLength);
1617
- }
1618
- if (entry.header.commentLength) entry.comment = inBuffer.slice(tmp, tmp + entry.header.commentLength);
1619
- index += entry.header.centralHeaderSize;
1620
- entryList[i] = entry;
1621
- entryTable[entry.entryName] = entry;
1622
- }
1623
- temporary.clear();
1624
- makeTemporaryFolders();
1625
- }
1626
- function readMainHeader(readNow) {
1627
- var i = inBuffer.length - Utils.Constants.ENDHDR, max = Math.max(0, i - 65535), n = max, endStart = inBuffer.length, endOffset = -1, commentEnd = 0;
1628
- const trailingSpace = typeof opts.trailingSpace === "boolean" ? opts.trailingSpace : false;
1629
- if (trailingSpace) max = 0;
1630
- for (i; i >= n; i--) {
1631
- if (inBuffer[i] !== 80) continue;
1632
- if (inBuffer.readUInt32LE(i) === Utils.Constants.ENDSIG) {
1633
- endOffset = i;
1634
- commentEnd = i;
1635
- endStart = i + Utils.Constants.ENDHDR;
1636
- n = i - Utils.Constants.END64HDR;
1637
- continue;
1638
- }
1639
- if (inBuffer.readUInt32LE(i) === Utils.Constants.END64SIG) {
1640
- n = max;
1641
- continue;
1642
- }
1643
- if (inBuffer.readUInt32LE(i) === Utils.Constants.ZIP64SIG) {
1644
- endOffset = i;
1645
- endStart = i + Utils.readBigUInt64LE(inBuffer, i + Utils.Constants.ZIP64SIZE) + Utils.Constants.ZIP64LEAD;
1646
- break;
1647
- }
1648
- }
1649
- if (endOffset == -1) throw Utils.Errors.INVALID_FORMAT();
1650
- mainHeader.loadFromBinary(inBuffer.slice(endOffset, endStart));
1651
- if (mainHeader.commentLength) {
1652
- _comment = inBuffer.slice(commentEnd + Utils.Constants.ENDHDR);
1653
- }
1654
- if (readNow) readEntries();
1655
- }
1656
- function sortEntries() {
1657
- if (entryList.length > 1 && !noSort) {
1658
- entryList.sort((a, b) => a.entryName.toLowerCase().localeCompare(b.entryName.toLowerCase()));
1659
- }
1660
- }
1661
- return {
1662
- /**
1663
- * Returns an array of ZipEntry objects existent in the current opened archive
1664
- * @return Array
1665
- */
1666
- get entries() {
1667
- if (!loadedEntries) {
1668
- readEntries();
1669
- }
1670
- return entryList.filter((e) => !temporary.has(e));
1671
- },
1672
- /**
1673
- * Archive comment
1674
- * @return {String}
1675
- */
1676
- get comment() {
1677
- return decoder.decode(_comment);
1678
- },
1679
- set comment(val) {
1680
- _comment = Utils.toBuffer(val, decoder.encode);
1681
- mainHeader.commentLength = _comment.length;
1682
- },
1683
- getEntryCount: function() {
1684
- if (!loadedEntries) {
1685
- return mainHeader.diskEntries;
1686
- }
1687
- return entryList.length;
1688
- },
1689
- forEach: function(callback) {
1690
- this.entries.forEach(callback);
1691
- },
1692
- /**
1693
- * Returns a reference to the entry with the given name or null if entry is inexistent
1694
- *
1695
- * @param entryName
1696
- * @return ZipEntry
1697
- */
1698
- getEntry: function(entryName) {
1699
- if (!loadedEntries) {
1700
- readEntries();
1701
- }
1702
- return entryTable[entryName] || null;
1703
- },
1704
- /**
1705
- * Adds the given entry to the entry list
1706
- *
1707
- * @param entry
1708
- */
1709
- setEntry: function(entry) {
1710
- if (!loadedEntries) {
1711
- readEntries();
1712
- }
1713
- entryList.push(entry);
1714
- entryTable[entry.entryName] = entry;
1715
- mainHeader.totalEntries = entryList.length;
1716
- },
1717
- /**
1718
- * Removes the file with the given name from the entry list.
1719
- *
1720
- * If the entry is a directory, then all nested files and directories will be removed
1721
- * @param entryName
1722
- * @returns {void}
1723
- */
1724
- deleteFile: function(entryName, withsubfolders = true) {
1725
- if (!loadedEntries) {
1726
- readEntries();
1727
- }
1728
- const entry = entryTable[entryName];
1729
- const list = this.getEntryChildren(entry, withsubfolders).map((child) => child.entryName);
1730
- list.forEach(this.deleteEntry);
1731
- },
1732
- /**
1733
- * Removes the entry with the given name from the entry list.
1734
- *
1735
- * @param {string} entryName
1736
- * @returns {void}
1737
- */
1738
- deleteEntry: function(entryName) {
1739
- if (!loadedEntries) {
1740
- readEntries();
1741
- }
1742
- const entry = entryTable[entryName];
1743
- const index = entryList.indexOf(entry);
1744
- if (index >= 0) {
1745
- entryList.splice(index, 1);
1746
- delete entryTable[entryName];
1747
- mainHeader.totalEntries = entryList.length;
1748
- }
1749
- },
1750
- /**
1751
- * Iterates and returns all nested files and directories of the given entry
1752
- *
1753
- * @param entry
1754
- * @return Array
1755
- */
1756
- getEntryChildren: function(entry, subfolders = true) {
1757
- if (!loadedEntries) {
1758
- readEntries();
1759
- }
1760
- if (typeof entry === "object") {
1761
- if (entry.isDirectory && subfolders) {
1762
- const list = [];
1763
- const name = entry.entryName;
1764
- for (const zipEntry of entryList) {
1765
- if (zipEntry.entryName.startsWith(name)) {
1766
- list.push(zipEntry);
1767
- }
1768
- }
1769
- return list;
1770
- } else {
1771
- return [entry];
1772
- }
1773
- }
1774
- return [];
1775
- },
1776
- /**
1777
- * How many child elements entry has
1778
- *
1779
- * @param {ZipEntry} entry
1780
- * @return {integer}
1781
- */
1782
- getChildCount: function(entry) {
1783
- if (entry && entry.isDirectory) {
1784
- const list = this.getEntryChildren(entry);
1785
- return list.includes(entry) ? list.length - 1 : list.length;
1786
- }
1787
- return 0;
1788
- },
1789
- /**
1790
- * Returns the zip file
1791
- *
1792
- * @return Buffer
1793
- */
1794
- compressToBuffer: function() {
1795
- if (!loadedEntries) {
1796
- readEntries();
1797
- }
1798
- sortEntries();
1799
- const dataBlock = [];
1800
- const headerBlocks = [];
1801
- let totalSize = 0;
1802
- let dindex = 0;
1803
- mainHeader.size = 0;
1804
- mainHeader.offset = 0;
1805
- let totalEntries = 0;
1806
- for (const entry of this.entries) {
1807
- const compressedData = entry.getCompressedData();
1808
- entry.header.offset = dindex;
1809
- const localHeader = entry.packLocalHeader();
1810
- const dataLength = localHeader.length + compressedData.length;
1811
- dindex += dataLength;
1812
- dataBlock.push(localHeader);
1813
- dataBlock.push(compressedData);
1814
- const centralHeader = entry.packCentralHeader();
1815
- headerBlocks.push(centralHeader);
1816
- mainHeader.size += centralHeader.length;
1817
- totalSize += dataLength + centralHeader.length;
1818
- totalEntries++;
1819
- }
1820
- totalSize += mainHeader.mainHeaderSize;
1821
- mainHeader.offset = dindex;
1822
- mainHeader.totalEntries = totalEntries;
1823
- dindex = 0;
1824
- const outBuffer = Buffer.alloc(totalSize);
1825
- for (const content of dataBlock) {
1826
- content.copy(outBuffer, dindex);
1827
- dindex += content.length;
1828
- }
1829
- for (const content of headerBlocks) {
1830
- content.copy(outBuffer, dindex);
1831
- dindex += content.length;
1832
- }
1833
- const mh = mainHeader.toBinary();
1834
- if (_comment) {
1835
- _comment.copy(mh, Utils.Constants.ENDHDR);
1836
- }
1837
- mh.copy(outBuffer, dindex);
1838
- inBuffer = outBuffer;
1839
- loadedEntries = false;
1840
- return outBuffer;
1841
- },
1842
- toAsyncBuffer: function(onSuccess, onFail, onItemStart, onItemEnd) {
1843
- try {
1844
- if (!loadedEntries) {
1845
- readEntries();
1846
- }
1847
- sortEntries();
1848
- const dataBlock = [];
1849
- const centralHeaders = [];
1850
- let totalSize = 0;
1851
- let dindex = 0;
1852
- let totalEntries = 0;
1853
- mainHeader.size = 0;
1854
- mainHeader.offset = 0;
1855
- const compress2Buffer = function(entryLists) {
1856
- if (entryLists.length > 0) {
1857
- const entry = entryLists.shift();
1858
- const name = entry.entryName + entry.extra.toString();
1859
- if (onItemStart) onItemStart(name);
1860
- entry.getCompressedDataAsync(function(compressedData) {
1861
- if (onItemEnd) onItemEnd(name);
1862
- entry.header.offset = dindex;
1863
- const localHeader = entry.packLocalHeader();
1864
- const dataLength = localHeader.length + compressedData.length;
1865
- dindex += dataLength;
1866
- dataBlock.push(localHeader);
1867
- dataBlock.push(compressedData);
1868
- const centalHeader = entry.packCentralHeader();
1869
- centralHeaders.push(centalHeader);
1870
- mainHeader.size += centalHeader.length;
1871
- totalSize += dataLength + centalHeader.length;
1872
- totalEntries++;
1873
- compress2Buffer(entryLists);
1874
- });
1875
- } else {
1876
- totalSize += mainHeader.mainHeaderSize;
1877
- mainHeader.offset = dindex;
1878
- mainHeader.totalEntries = totalEntries;
1879
- dindex = 0;
1880
- const outBuffer = Buffer.alloc(totalSize);
1881
- dataBlock.forEach(function(content) {
1882
- content.copy(outBuffer, dindex);
1883
- dindex += content.length;
1884
- });
1885
- centralHeaders.forEach(function(content) {
1886
- content.copy(outBuffer, dindex);
1887
- dindex += content.length;
1888
- });
1889
- const mh = mainHeader.toBinary();
1890
- if (_comment) {
1891
- _comment.copy(mh, Utils.Constants.ENDHDR);
1892
- }
1893
- mh.copy(outBuffer, dindex);
1894
- inBuffer = outBuffer;
1895
- loadedEntries = false;
1896
- onSuccess(outBuffer);
1897
- }
1898
- };
1899
- compress2Buffer(Array.from(this.entries));
1900
- } catch (e) {
1901
- onFail(e);
1902
- }
1903
- }
1904
- };
1905
- };
1906
- }
1907
- });
1908
-
1909
- // node_modules/adm-zip/adm-zip.js
1910
- var require_adm_zip = __commonJS({
1911
- "node_modules/adm-zip/adm-zip.js"(exports, module) {
1912
- var Utils = require_util();
1913
- var pth = __require("path");
1914
- var ZipEntry = require_zipEntry();
1915
- var ZipFile = require_zipFile();
1916
- var get_Bool = (...val) => Utils.findLast(val, (c) => typeof c === "boolean");
1917
- var get_Str = (...val) => Utils.findLast(val, (c) => typeof c === "string");
1918
- var get_Fun = (...val) => Utils.findLast(val, (c) => typeof c === "function");
1919
- var defaultOptions = {
1920
- // option "noSort" : if true it disables files sorting
1921
- noSort: false,
1922
- // read entries during load (initial loading may be slower)
1923
- readEntries: false,
1924
- // default method is none
1925
- method: Utils.Constants.NONE,
1926
- // file system
1927
- fs: null
1928
- };
1929
- module.exports = function(input, options) {
1930
- let inBuffer = null;
1931
- const opts = Object.assign(/* @__PURE__ */ Object.create(null), defaultOptions);
1932
- if (input && "object" === typeof input) {
1933
- if (!(input instanceof Uint8Array)) {
1934
- Object.assign(opts, input);
1935
- input = opts.input ? opts.input : void 0;
1936
- if (opts.input) delete opts.input;
1937
- }
1938
- if (Buffer.isBuffer(input)) {
1939
- inBuffer = input;
1940
- opts.method = Utils.Constants.BUFFER;
1941
- input = void 0;
1942
- }
1943
- }
1944
- Object.assign(opts, options);
1945
- const filetools = new Utils(opts);
1946
- if (typeof opts.decoder !== "object" || typeof opts.decoder.encode !== "function" || typeof opts.decoder.decode !== "function") {
1947
- opts.decoder = Utils.decoder;
1948
- }
1949
- if (input && "string" === typeof input) {
1950
- if (filetools.fs.existsSync(input)) {
1951
- opts.method = Utils.Constants.FILE;
1952
- opts.filename = input;
1953
- inBuffer = filetools.fs.readFileSync(input);
1954
- } else {
1955
- throw Utils.Errors.INVALID_FILENAME();
1956
- }
1957
- }
1958
- const _zip = new ZipFile(inBuffer, opts);
1959
- const { canonical, sanitize, zipnamefix } = Utils;
1960
- function getEntry(entry) {
1961
- if (entry && _zip) {
1962
- var item;
1963
- if (typeof entry === "string") item = _zip.getEntry(pth.posix.normalize(entry));
1964
- if (typeof entry === "object" && typeof entry.entryName !== "undefined" && typeof entry.header !== "undefined") item = _zip.getEntry(entry.entryName);
1965
- if (item) {
1966
- return item;
1967
- }
1968
- }
1969
- return null;
1970
- }
1971
- function fixPath(zipPath) {
1972
- const { join: join2, normalize, sep } = pth.posix;
1973
- return join2(pth.isAbsolute(zipPath) ? "/" : ".", normalize(sep + zipPath.split("\\").join(sep) + sep));
1974
- }
1975
- function filenameFilter(filterfn) {
1976
- if (filterfn instanceof RegExp) {
1977
- return /* @__PURE__ */ (function(rx) {
1978
- return function(filename) {
1979
- return rx.test(filename);
1980
- };
1981
- })(filterfn);
1982
- } else if ("function" !== typeof filterfn) {
1983
- return () => true;
1984
- }
1985
- return filterfn;
1986
- }
1987
- const relativePath = (local, entry) => {
1988
- let lastChar = entry.slice(-1);
1989
- lastChar = lastChar === filetools.sep ? filetools.sep : "";
1990
- return pth.relative(local, entry) + lastChar;
1991
- };
1992
- return {
1993
- /**
1994
- * Extracts the given entry from the archive and returns the content as a Buffer object
1995
- * @param {ZipEntry|string} entry ZipEntry object or String with the full path of the entry
1996
- * @param {Buffer|string} [pass] - password
1997
- * @return Buffer or Null in case of error
1998
- */
1999
- readFile: function(entry, pass) {
2000
- var item = getEntry(entry);
2001
- return item && item.getData(pass) || null;
2002
- },
2003
- /**
2004
- * Returns how many child elements has on entry (directories) on files it is always 0
2005
- * @param {ZipEntry|string} entry ZipEntry object or String with the full path of the entry
2006
- * @returns {integer}
2007
- */
2008
- childCount: function(entry) {
2009
- const item = getEntry(entry);
2010
- if (item) {
2011
- return _zip.getChildCount(item);
2012
- }
2013
- },
2014
- /**
2015
- * Asynchronous readFile
2016
- * @param {ZipEntry|string} entry ZipEntry object or String with the full path of the entry
2017
- * @param {callback} callback
2018
- *
2019
- * @return Buffer or Null in case of error
2020
- */
2021
- readFileAsync: function(entry, callback) {
2022
- var item = getEntry(entry);
2023
- if (item) {
2024
- item.getDataAsync(callback);
2025
- } else {
2026
- callback(null, "getEntry failed for:" + entry);
2027
- }
2028
- },
2029
- /**
2030
- * Extracts the given entry from the archive and returns the content as plain text in the given encoding
2031
- * @param {ZipEntry|string} entry - ZipEntry object or String with the full path of the entry
2032
- * @param {string} encoding - Optional. If no encoding is specified utf8 is used
2033
- *
2034
- * @return String
2035
- */
2036
- readAsText: function(entry, encoding) {
2037
- var item = getEntry(entry);
2038
- if (item) {
2039
- var data2 = item.getData();
2040
- if (data2 && data2.length) {
2041
- return data2.toString(encoding || "utf8");
2042
- }
2043
- }
2044
- return "";
2045
- },
2046
- /**
2047
- * Asynchronous readAsText
2048
- * @param {ZipEntry|string} entry ZipEntry object or String with the full path of the entry
2049
- * @param {callback} callback
2050
- * @param {string} [encoding] - Optional. If no encoding is specified utf8 is used
2051
- *
2052
- * @return String
2053
- */
2054
- readAsTextAsync: function(entry, callback, encoding) {
2055
- var item = getEntry(entry);
2056
- if (item) {
2057
- item.getDataAsync(function(data2, err) {
2058
- if (err) {
2059
- callback(data2, err);
2060
- return;
2061
- }
2062
- if (data2 && data2.length) {
2063
- callback(data2.toString(encoding || "utf8"));
2064
- } else {
2065
- callback("");
2066
- }
2067
- });
2068
- } else {
2069
- callback("");
2070
- }
2071
- },
2072
- /**
2073
- * Remove the entry from the file or the entry and all it's nested directories and files if the given entry is a directory
2074
- *
2075
- * @param {ZipEntry|string} entry
2076
- * @returns {void}
2077
- */
2078
- deleteFile: function(entry, withsubfolders = true) {
2079
- var item = getEntry(entry);
2080
- if (item) {
2081
- _zip.deleteFile(item.entryName, withsubfolders);
2082
- }
2083
- },
2084
- /**
2085
- * Remove the entry from the file or directory without affecting any nested entries
2086
- *
2087
- * @param {ZipEntry|string} entry
2088
- * @returns {void}
2089
- */
2090
- deleteEntry: function(entry) {
2091
- var item = getEntry(entry);
2092
- if (item) {
2093
- _zip.deleteEntry(item.entryName);
2094
- }
2095
- },
2096
- /**
2097
- * Adds a comment to the zip. The zip must be rewritten after adding the comment.
2098
- *
2099
- * @param {string} comment
2100
- */
2101
- addZipComment: function(comment) {
2102
- _zip.comment = comment;
2103
- },
2104
- /**
2105
- * Returns the zip comment
2106
- *
2107
- * @return String
2108
- */
2109
- getZipComment: function() {
2110
- return _zip.comment || "";
2111
- },
2112
- /**
2113
- * Adds a comment to a specified zipEntry. The zip must be rewritten after adding the comment
2114
- * The comment cannot exceed 65535 characters in length
2115
- *
2116
- * @param {ZipEntry} entry
2117
- * @param {string} comment
2118
- */
2119
- addZipEntryComment: function(entry, comment) {
2120
- var item = getEntry(entry);
2121
- if (item) {
2122
- item.comment = comment;
2123
- }
2124
- },
2125
- /**
2126
- * Returns the comment of the specified entry
2127
- *
2128
- * @param {ZipEntry} entry
2129
- * @return String
2130
- */
2131
- getZipEntryComment: function(entry) {
2132
- var item = getEntry(entry);
2133
- if (item) {
2134
- return item.comment || "";
2135
- }
2136
- return "";
2137
- },
2138
- /**
2139
- * Updates the content of an existing entry inside the archive. The zip must be rewritten after updating the content
2140
- *
2141
- * @param {ZipEntry} entry
2142
- * @param {Buffer} content
2143
- */
2144
- updateFile: function(entry, content) {
2145
- var item = getEntry(entry);
2146
- if (item) {
2147
- item.setData(content);
2148
- }
2149
- },
2150
- /**
2151
- * Adds a file from the disk to the archive
2152
- *
2153
- * @param {string} localPath File to add to zip
2154
- * @param {string} [zipPath] Optional path inside the zip
2155
- * @param {string} [zipName] Optional name for the file
2156
- * @param {string} [comment] Optional file comment
2157
- */
2158
- addLocalFile: function(localPath2, zipPath, zipName, comment) {
2159
- if (filetools.fs.existsSync(localPath2)) {
2160
- zipPath = zipPath ? fixPath(zipPath) : "";
2161
- const p = pth.win32.basename(pth.win32.normalize(localPath2));
2162
- zipPath += zipName ? zipName : p;
2163
- const _attr = filetools.fs.statSync(localPath2);
2164
- const data2 = _attr.isFile() ? filetools.fs.readFileSync(localPath2) : Buffer.alloc(0);
2165
- if (_attr.isDirectory()) zipPath += filetools.sep;
2166
- this.addFile(zipPath, data2, comment, _attr);
2167
- } else {
2168
- throw Utils.Errors.FILE_NOT_FOUND(localPath2);
2169
- }
2170
- },
2171
- /**
2172
- * Callback for showing if everything was done.
2173
- *
2174
- * @callback doneCallback
2175
- * @param {Error} err - Error object
2176
- * @param {boolean} done - was request fully completed
2177
- */
2178
- /**
2179
- * Adds a file from the disk to the archive
2180
- *
2181
- * @param {(object|string)} options - options object, if it is string it us used as localPath.
2182
- * @param {string} options.localPath - Local path to the file.
2183
- * @param {string} [options.comment] - Optional file comment.
2184
- * @param {string} [options.zipPath] - Optional path inside the zip
2185
- * @param {string} [options.zipName] - Optional name for the file
2186
- * @param {doneCallback} callback - The callback that handles the response.
2187
- */
2188
- addLocalFileAsync: function(options2, callback) {
2189
- options2 = typeof options2 === "object" ? options2 : { localPath: options2 };
2190
- const localPath2 = pth.resolve(options2.localPath);
2191
- const { comment } = options2;
2192
- let { zipPath, zipName } = options2;
2193
- const self = this;
2194
- filetools.fs.stat(localPath2, function(err, stats) {
2195
- if (err) return callback(err, false);
2196
- zipPath = zipPath ? fixPath(zipPath) : "";
2197
- const p = pth.win32.basename(pth.win32.normalize(localPath2));
2198
- zipPath += zipName ? zipName : p;
2199
- if (stats.isFile()) {
2200
- filetools.fs.readFile(localPath2, function(err2, data2) {
2201
- if (err2) return callback(err2, false);
2202
- self.addFile(zipPath, data2, comment, stats);
2203
- return setImmediate(callback, void 0, true);
2204
- });
2205
- } else if (stats.isDirectory()) {
2206
- zipPath += filetools.sep;
2207
- self.addFile(zipPath, Buffer.alloc(0), comment, stats);
2208
- return setImmediate(callback, void 0, true);
2209
- }
2210
- });
2211
- },
2212
- /**
2213
- * Adds a local directory and all its nested files and directories to the archive
2214
- *
2215
- * @param {string} localPath - local path to the folder
2216
- * @param {string} [zipPath] - optional path inside zip
2217
- * @param {(RegExp|function)} [filter] - optional RegExp or Function if files match will be included.
2218
- */
2219
- addLocalFolder: function(localPath2, zipPath, filter) {
2220
- filter = filenameFilter(filter);
2221
- zipPath = zipPath ? fixPath(zipPath) : "";
2222
- localPath2 = pth.normalize(localPath2);
2223
- if (filetools.fs.existsSync(localPath2)) {
2224
- const items = filetools.findFiles(localPath2);
2225
- const self = this;
2226
- if (items.length) {
2227
- for (const filepath of items) {
2228
- const p = pth.join(zipPath, relativePath(localPath2, filepath));
2229
- if (filter(p)) {
2230
- self.addLocalFile(filepath, pth.dirname(p));
2231
- }
2232
- }
2233
- }
2234
- } else {
2235
- throw Utils.Errors.FILE_NOT_FOUND(localPath2);
2236
- }
2237
- },
2238
- /**
2239
- * Asynchronous addLocalFolder
2240
- * @param {string} localPath
2241
- * @param {callback} callback
2242
- * @param {string} [zipPath] optional path inside zip
2243
- * @param {RegExp|function} [filter] optional RegExp or Function if files match will
2244
- * be included.
2245
- */
2246
- addLocalFolderAsync: function(localPath2, callback, zipPath, filter) {
2247
- filter = filenameFilter(filter);
2248
- zipPath = zipPath ? fixPath(zipPath) : "";
2249
- localPath2 = pth.normalize(localPath2);
2250
- var self = this;
2251
- filetools.fs.open(localPath2, "r", function(err) {
2252
- if (err && err.code === "ENOENT") {
2253
- callback(void 0, Utils.Errors.FILE_NOT_FOUND(localPath2));
2254
- } else if (err) {
2255
- callback(void 0, err);
2256
- } else {
2257
- var items = filetools.findFiles(localPath2);
2258
- var i = -1;
2259
- var next = function() {
2260
- i += 1;
2261
- if (i < items.length) {
2262
- var filepath = items[i];
2263
- var p = relativePath(localPath2, filepath).split("\\").join("/");
2264
- p = p.normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^\x20-\x7E]/g, "");
2265
- if (filter(p)) {
2266
- filetools.fs.stat(filepath, function(er0, stats) {
2267
- if (er0) callback(void 0, er0);
2268
- if (stats.isFile()) {
2269
- filetools.fs.readFile(filepath, function(er1, data2) {
2270
- if (er1) {
2271
- callback(void 0, er1);
2272
- } else {
2273
- self.addFile(zipPath + p, data2, "", stats);
2274
- next();
2275
- }
2276
- });
2277
- } else {
2278
- self.addFile(zipPath + p + "/", Buffer.alloc(0), "", stats);
2279
- next();
2280
- }
2281
- });
2282
- } else {
2283
- process.nextTick(() => {
2284
- next();
2285
- });
2286
- }
2287
- } else {
2288
- callback(true, void 0);
2289
- }
2290
- };
2291
- next();
2292
- }
2293
- });
2294
- },
2295
- /**
2296
- * Adds a local directory and all its nested files and directories to the archive
2297
- *
2298
- * @param {object | string} options - options object, if it is string it us used as localPath.
2299
- * @param {string} options.localPath - Local path to the folder.
2300
- * @param {string} [options.zipPath] - optional path inside zip.
2301
- * @param {RegExp|function} [options.filter] - optional RegExp or Function if files match will be included.
2302
- * @param {function|string} [options.namefix] - optional function to help fix filename
2303
- * @param {doneCallback} callback - The callback that handles the response.
2304
- *
2305
- */
2306
- addLocalFolderAsync2: function(options2, callback) {
2307
- const self = this;
2308
- options2 = typeof options2 === "object" ? options2 : { localPath: options2 };
2309
- localPath = pth.resolve(fixPath(options2.localPath));
2310
- let { zipPath, filter, namefix } = options2;
2311
- if (filter instanceof RegExp) {
2312
- filter = /* @__PURE__ */ (function(rx) {
2313
- return function(filename) {
2314
- return rx.test(filename);
2315
- };
2316
- })(filter);
2317
- } else if ("function" !== typeof filter) {
2318
- filter = function() {
2319
- return true;
2320
- };
2321
- }
2322
- zipPath = zipPath ? fixPath(zipPath) : "";
2323
- if (namefix == "latin1") {
2324
- namefix = (str) => str.normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^\x20-\x7E]/g, "");
2325
- }
2326
- if (typeof namefix !== "function") namefix = (str) => str;
2327
- const relPathFix = (entry) => pth.join(zipPath, namefix(relativePath(localPath, entry)));
2328
- const fileNameFix = (entry) => pth.win32.basename(pth.win32.normalize(namefix(entry)));
2329
- filetools.fs.open(localPath, "r", function(err) {
2330
- if (err && err.code === "ENOENT") {
2331
- callback(void 0, Utils.Errors.FILE_NOT_FOUND(localPath));
2332
- } else if (err) {
2333
- callback(void 0, err);
2334
- } else {
2335
- filetools.findFilesAsync(localPath, function(err2, fileEntries) {
2336
- if (err2) return callback(err2);
2337
- fileEntries = fileEntries.filter((dir) => filter(relPathFix(dir)));
2338
- if (!fileEntries.length) callback(void 0, false);
2339
- setImmediate(
2340
- fileEntries.reverse().reduce(function(next, entry) {
2341
- return function(err3, done) {
2342
- if (err3 || done === false) return setImmediate(next, err3, false);
2343
- self.addLocalFileAsync(
2344
- {
2345
- localPath: entry,
2346
- zipPath: pth.dirname(relPathFix(entry)),
2347
- zipName: fileNameFix(entry)
2348
- },
2349
- next
2350
- );
2351
- };
2352
- }, callback)
2353
- );
2354
- });
2355
- }
2356
- });
2357
- },
2358
- /**
2359
- * Adds a local directory and all its nested files and directories to the archive
2360
- *
2361
- * @param {string} localPath - path where files will be extracted
2362
- * @param {object} props - optional properties
2363
- * @param {string} [props.zipPath] - optional path inside zip
2364
- * @param {RegExp|function} [props.filter] - optional RegExp or Function if files match will be included.
2365
- * @param {function|string} [props.namefix] - optional function to help fix filename
2366
- */
2367
- addLocalFolderPromise: function(localPath2, props) {
2368
- return new Promise((resolve, reject) => {
2369
- this.addLocalFolderAsync2(Object.assign({ localPath: localPath2 }, props), (err, done) => {
2370
- if (err) reject(err);
2371
- if (done) resolve(this);
2372
- });
2373
- });
2374
- },
2375
- /**
2376
- * Allows you to create a entry (file or directory) in the zip file.
2377
- * If you want to create a directory the entryName must end in / and a null buffer should be provided.
2378
- * Comment and attributes are optional
2379
- *
2380
- * @param {string} entryName
2381
- * @param {Buffer | string} content - file content as buffer or utf8 coded string
2382
- * @param {string} [comment] - file comment
2383
- * @param {number | object} [attr] - number as unix file permissions, object as filesystem Stats object
2384
- */
2385
- addFile: function(entryName, content, comment, attr) {
2386
- entryName = zipnamefix(entryName);
2387
- let entry = getEntry(entryName);
2388
- const update = entry != null;
2389
- if (!update) {
2390
- entry = new ZipEntry(opts);
2391
- entry.entryName = entryName;
2392
- }
2393
- entry.comment = comment || "";
2394
- const isStat = "object" === typeof attr && attr instanceof filetools.fs.Stats;
2395
- if (isStat) {
2396
- entry.header.time = attr.mtime;
2397
- }
2398
- var fileattr = entry.isDirectory ? 16 : 0;
2399
- let unix = entry.isDirectory ? 16384 : 32768;
2400
- if (isStat) {
2401
- unix |= 4095 & attr.mode;
2402
- } else if ("number" === typeof attr) {
2403
- unix |= 4095 & attr;
2404
- } else {
2405
- unix |= entry.isDirectory ? 493 : 420;
2406
- }
2407
- fileattr = (fileattr | unix << 16) >>> 0;
2408
- entry.attr = fileattr;
2409
- entry.setData(content);
2410
- if (!update) _zip.setEntry(entry);
2411
- return entry;
2412
- },
2413
- /**
2414
- * Returns an array of ZipEntry objects representing the files and folders inside the archive
2415
- *
2416
- * @param {string} [password]
2417
- * @returns Array
2418
- */
2419
- getEntries: function(password) {
2420
- _zip.password = password;
2421
- return _zip ? _zip.entries : [];
2422
- },
2423
- /**
2424
- * Returns a ZipEntry object representing the file or folder specified by ``name``.
2425
- *
2426
- * @param {string} name
2427
- * @return ZipEntry
2428
- */
2429
- getEntry: function(name) {
2430
- return getEntry(name);
2431
- },
2432
- getEntryCount: function() {
2433
- return _zip.getEntryCount();
2434
- },
2435
- forEach: function(callback) {
2436
- return _zip.forEach(callback);
2437
- },
2438
- /**
2439
- * Extracts the given entry to the given targetPath
2440
- * If the entry is a directory inside the archive, the entire directory and it's subdirectories will be extracted
2441
- *
2442
- * @param {string|ZipEntry} entry - ZipEntry object or String with the full path of the entry
2443
- * @param {string} targetPath - Target folder where to write the file
2444
- * @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
2445
- * @param {boolean} [overwrite=false] - If the file already exists at the target path, the file will be overwriten if this is true.
2446
- * @param {boolean} [keepOriginalPermission=false] - The file will be set as the permission from the entry if this is true.
2447
- * @param {string} [outFileName] - String If set will override the filename of the extracted file (Only works if the entry is a file)
2448
- *
2449
- * @return Boolean
2450
- */
2451
- extractEntryTo: function(entry, targetPath, maintainEntryPath, overwrite, keepOriginalPermission, outFileName) {
2452
- overwrite = get_Bool(false, overwrite);
2453
- keepOriginalPermission = get_Bool(false, keepOriginalPermission);
2454
- maintainEntryPath = get_Bool(true, maintainEntryPath);
2455
- outFileName = get_Str(keepOriginalPermission, outFileName);
2456
- var item = getEntry(entry);
2457
- if (!item) {
2458
- throw Utils.Errors.NO_ENTRY();
2459
- }
2460
- var entryName = canonical(item.entryName);
2461
- var target = sanitize(targetPath, outFileName && !item.isDirectory ? outFileName : maintainEntryPath ? entryName : pth.basename(entryName));
2462
- if (item.isDirectory) {
2463
- var children = _zip.getEntryChildren(item);
2464
- children.forEach(function(child) {
2465
- if (child.isDirectory) return;
2466
- var content2 = child.getData();
2467
- if (!content2) {
2468
- throw Utils.Errors.CANT_EXTRACT_FILE();
2469
- }
2470
- var name = canonical(child.entryName);
2471
- var childName = sanitize(targetPath, maintainEntryPath ? name : pth.basename(name));
2472
- const fileAttr2 = keepOriginalPermission ? child.header.fileAttr : void 0;
2473
- filetools.writeFileTo(childName, content2, overwrite, fileAttr2);
2474
- });
2475
- return true;
2476
- }
2477
- var content = item.getData(_zip.password);
2478
- if (!content) throw Utils.Errors.CANT_EXTRACT_FILE();
2479
- if (filetools.fs.existsSync(target) && !overwrite) {
2480
- throw Utils.Errors.CANT_OVERRIDE();
2481
- }
2482
- const fileAttr = keepOriginalPermission ? entry.header.fileAttr : void 0;
2483
- filetools.writeFileTo(target, content, overwrite, fileAttr);
2484
- return true;
2485
- },
2486
- /**
2487
- * Test the archive
2488
- * @param {string} [pass]
2489
- */
2490
- test: function(pass) {
2491
- if (!_zip) {
2492
- return false;
2493
- }
2494
- for (var entry in _zip.entries) {
2495
- try {
2496
- if (entry.isDirectory) {
2497
- continue;
2498
- }
2499
- var content = _zip.entries[entry].getData(pass);
2500
- if (!content) {
2501
- return false;
2502
- }
2503
- } catch (err) {
2504
- return false;
2505
- }
2506
- }
2507
- return true;
2508
- },
2509
- /**
2510
- * Extracts the entire archive to the given location
2511
- *
2512
- * @param {string} targetPath Target location
2513
- * @param {boolean} [overwrite=false] If the file already exists at the target path, the file will be overwriten if this is true.
2514
- * Default is FALSE
2515
- * @param {boolean} [keepOriginalPermission=false] The file will be set as the permission from the entry if this is true.
2516
- * Default is FALSE
2517
- * @param {string|Buffer} [pass] password
2518
- */
2519
- extractAllTo: function(targetPath, overwrite, keepOriginalPermission, pass) {
2520
- keepOriginalPermission = get_Bool(false, keepOriginalPermission);
2521
- pass = get_Str(keepOriginalPermission, pass);
2522
- overwrite = get_Bool(false, overwrite);
2523
- if (!_zip) throw Utils.Errors.NO_ZIP();
2524
- _zip.entries.forEach(function(entry) {
2525
- var entryName = sanitize(targetPath, canonical(entry.entryName));
2526
- if (entry.isDirectory) {
2527
- filetools.makeDir(entryName);
2528
- return;
2529
- }
2530
- var content = entry.getData(pass);
2531
- if (!content) {
2532
- throw Utils.Errors.CANT_EXTRACT_FILE();
2533
- }
2534
- const fileAttr = keepOriginalPermission ? entry.header.fileAttr : void 0;
2535
- filetools.writeFileTo(entryName, content, overwrite, fileAttr);
2536
- try {
2537
- filetools.fs.utimesSync(entryName, entry.header.time, entry.header.time);
2538
- } catch (err) {
2539
- throw Utils.Errors.CANT_EXTRACT_FILE();
2540
- }
2541
- });
2542
- },
2543
- /**
2544
- * Asynchronous extractAllTo
2545
- *
2546
- * @param {string} targetPath Target location
2547
- * @param {boolean} [overwrite=false] If the file already exists at the target path, the file will be overwriten if this is true.
2548
- * Default is FALSE
2549
- * @param {boolean} [keepOriginalPermission=false] The file will be set as the permission from the entry if this is true.
2550
- * Default is FALSE
2551
- * @param {function} callback The callback will be executed when all entries are extracted successfully or any error is thrown.
2552
- */
2553
- extractAllToAsync: function(targetPath, overwrite, keepOriginalPermission, callback) {
2554
- callback = get_Fun(overwrite, keepOriginalPermission, callback);
2555
- keepOriginalPermission = get_Bool(false, keepOriginalPermission);
2556
- overwrite = get_Bool(false, overwrite);
2557
- if (!callback) {
2558
- return new Promise((resolve, reject) => {
2559
- this.extractAllToAsync(targetPath, overwrite, keepOriginalPermission, function(err) {
2560
- if (err) {
2561
- reject(err);
2562
- } else {
2563
- resolve(this);
2564
- }
2565
- });
2566
- });
2567
- }
2568
- if (!_zip) {
2569
- callback(Utils.Errors.NO_ZIP());
2570
- return;
2571
- }
2572
- targetPath = pth.resolve(targetPath);
2573
- const getPath = (entry) => sanitize(targetPath, pth.normalize(canonical(entry.entryName)));
2574
- const getError = (msg, file3) => new Error(msg + ': "' + file3 + '"');
2575
- const dirEntries = [];
2576
- const fileEntries = [];
2577
- _zip.entries.forEach((e) => {
2578
- if (e.isDirectory) {
2579
- dirEntries.push(e);
2580
- } else {
2581
- fileEntries.push(e);
2582
- }
2583
- });
2584
- for (const entry of dirEntries) {
2585
- const dirPath = getPath(entry);
2586
- const dirAttr = keepOriginalPermission ? entry.header.fileAttr : void 0;
2587
- try {
2588
- filetools.makeDir(dirPath);
2589
- if (dirAttr) filetools.fs.chmodSync(dirPath, dirAttr);
2590
- filetools.fs.utimesSync(dirPath, entry.header.time, entry.header.time);
2591
- } catch (er) {
2592
- callback(getError("Unable to create folder", dirPath));
2593
- }
2594
- }
2595
- fileEntries.reverse().reduce(function(next, entry) {
2596
- return function(err) {
2597
- if (err) {
2598
- next(err);
2599
- } else {
2600
- const entryName = pth.normalize(canonical(entry.entryName));
2601
- const filePath = sanitize(targetPath, entryName);
2602
- entry.getDataAsync(function(content, err_1) {
2603
- if (err_1) {
2604
- next(err_1);
2605
- } else if (!content) {
2606
- next(Utils.Errors.CANT_EXTRACT_FILE());
2607
- } else {
2608
- const fileAttr = keepOriginalPermission ? entry.header.fileAttr : void 0;
2609
- filetools.writeFileToAsync(filePath, content, overwrite, fileAttr, function(succ) {
2610
- if (!succ) {
2611
- next(getError("Unable to write file", filePath));
2612
- }
2613
- filetools.fs.utimes(filePath, entry.header.time, entry.header.time, function(err_2) {
2614
- if (err_2) {
2615
- next(getError("Unable to set times", filePath));
2616
- } else {
2617
- next();
2618
- }
2619
- });
2620
- });
2621
- }
2622
- });
2623
- }
2624
- };
2625
- }, callback)();
2626
- },
2627
- /**
2628
- * 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
2629
- *
2630
- * @param {string} targetFileName
2631
- * @param {function} callback
2632
- */
2633
- writeZip: function(targetFileName, callback) {
2634
- if (arguments.length === 1) {
2635
- if (typeof targetFileName === "function") {
2636
- callback = targetFileName;
2637
- targetFileName = "";
2638
- }
2639
- }
2640
- if (!targetFileName && opts.filename) {
2641
- targetFileName = opts.filename;
2642
- }
2643
- if (!targetFileName) return;
2644
- var zipData = _zip.compressToBuffer();
2645
- if (zipData) {
2646
- var ok = filetools.writeFileTo(targetFileName, zipData, true);
2647
- if (typeof callback === "function") callback(!ok ? new Error("failed") : null, "");
2648
- }
2649
- },
2650
- /**
2651
- *
2652
- * @param {string} targetFileName
2653
- * @param {object} [props]
2654
- * @param {boolean} [props.overwrite=true] If the file already exists at the target path, the file will be overwriten if this is true.
2655
- * @param {boolean} [props.perm] The file will be set as the permission from the entry if this is true.
2656
-
2657
- * @returns {Promise<void>}
2658
- */
2659
- writeZipPromise: function(targetFileName, props) {
2660
- const { overwrite, perm } = Object.assign({ overwrite: true }, props);
2661
- return new Promise((resolve, reject) => {
2662
- if (!targetFileName && opts.filename) targetFileName = opts.filename;
2663
- if (!targetFileName) reject("ADM-ZIP: ZIP File Name Missing");
2664
- this.toBufferPromise().then((zipData) => {
2665
- const ret = (done) => done ? resolve(done) : reject("ADM-ZIP: Wasn't able to write zip file");
2666
- filetools.writeFileToAsync(targetFileName, zipData, overwrite, perm, ret);
2667
- }, reject);
2668
- });
2669
- },
2670
- /**
2671
- * @returns {Promise<Buffer>} A promise to the Buffer.
2672
- */
2673
- toBufferPromise: function() {
2674
- return new Promise((resolve, reject) => {
2675
- _zip.toAsyncBuffer(resolve, reject);
2676
- });
2677
- },
2678
- /**
2679
- * Returns the content of the entire zip file as a Buffer object
2680
- *
2681
- * @prop {function} [onSuccess]
2682
- * @prop {function} [onFail]
2683
- * @prop {function} [onItemStart]
2684
- * @prop {function} [onItemEnd]
2685
- * @returns {Buffer}
2686
- */
2687
- toBuffer: function(onSuccess, onFail, onItemStart, onItemEnd) {
2688
- if (typeof onSuccess === "function") {
2689
- _zip.toAsyncBuffer(onSuccess, onFail, onItemStart, onItemEnd);
2690
- return null;
2691
- }
2692
- return _zip.compressToBuffer();
2693
- }
2694
- };
2695
- };
2696
- }
2697
- });
2
+ var __export = (target, all) => {
3
+ for (var name in all)
4
+ __defProp(target, name, { get: all[name], enumerable: true });
5
+ };
2698
6
 
2699
7
  // src/config/loader.ts
2700
8
  import { readFile } from "fs/promises";
@@ -4333,10 +1641,10 @@ function mergeDefs(...defs) {
4333
1641
  function cloneDef(schema) {
4334
1642
  return mergeDefs(schema._zod.def);
4335
1643
  }
4336
- function getElementAtPath(obj, path6) {
4337
- if (!path6)
1644
+ function getElementAtPath(obj, path7) {
1645
+ if (!path7)
4338
1646
  return obj;
4339
- return path6.reduce((acc, key) => acc?.[key], obj);
1647
+ return path7.reduce((acc, key) => acc?.[key], obj);
4340
1648
  }
4341
1649
  function promiseAllObject(promisesObj) {
4342
1650
  const keys = Object.keys(promisesObj);
@@ -4719,11 +2027,11 @@ function aborted(x, startIndex = 0) {
4719
2027
  }
4720
2028
  return false;
4721
2029
  }
4722
- function prefixIssues(path6, issues) {
2030
+ function prefixIssues(path7, issues) {
4723
2031
  return issues.map((iss) => {
4724
2032
  var _a2;
4725
2033
  (_a2 = iss).path ?? (_a2.path = []);
4726
- iss.path.unshift(path6);
2034
+ iss.path.unshift(path7);
4727
2035
  return iss;
4728
2036
  });
4729
2037
  }
@@ -4906,7 +2214,7 @@ function formatError(error92, mapper = (issue3) => issue3.message) {
4906
2214
  }
4907
2215
  function treeifyError(error92, mapper = (issue3) => issue3.message) {
4908
2216
  const result = { errors: [] };
4909
- const processError = (error93, path6 = []) => {
2217
+ const processError = (error93, path7 = []) => {
4910
2218
  var _a2, _b;
4911
2219
  for (const issue3 of error93.issues) {
4912
2220
  if (issue3.code === "invalid_union" && issue3.errors.length) {
@@ -4916,7 +2224,7 @@ function treeifyError(error92, mapper = (issue3) => issue3.message) {
4916
2224
  } else if (issue3.code === "invalid_element") {
4917
2225
  processError({ issues: issue3.issues }, issue3.path);
4918
2226
  } else {
4919
- const fullpath = [...path6, ...issue3.path];
2227
+ const fullpath = [...path7, ...issue3.path];
4920
2228
  if (fullpath.length === 0) {
4921
2229
  result.errors.push(mapper(issue3));
4922
2230
  continue;
@@ -4948,8 +2256,8 @@ function treeifyError(error92, mapper = (issue3) => issue3.message) {
4948
2256
  }
4949
2257
  function toDotPath(_path) {
4950
2258
  const segs = [];
4951
- const path6 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
4952
- for (const seg of path6) {
2259
+ const path7 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
2260
+ for (const seg of path7) {
4953
2261
  if (typeof seg === "number")
4954
2262
  segs.push(`[${seg}]`);
4955
2263
  else if (typeof seg === "symbol")
@@ -16926,13 +14234,13 @@ function resolveRef(ref, ctx) {
16926
14234
  if (!ref.startsWith("#")) {
16927
14235
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
16928
14236
  }
16929
- const path6 = ref.slice(1).split("/").filter(Boolean);
16930
- if (path6.length === 0) {
14237
+ const path7 = ref.slice(1).split("/").filter(Boolean);
14238
+ if (path7.length === 0) {
16931
14239
  return ctx.rootSchema;
16932
14240
  }
16933
14241
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
16934
- if (path6[0] === defsKey) {
16935
- const key = path6[1];
14242
+ if (path7[0] === defsKey) {
14243
+ const key = path7[1];
16936
14244
  if (!key || !ctx.defs[key]) {
16937
14245
  throw new Error(`Reference not found: ${ref}`);
16938
14246
  }
@@ -17494,6 +14802,12 @@ var HM_BUILD = `
17494
14802
  ### Build Phase
17495
14803
  - Use the \`harmonyos-hvigor\` skill to build the project
17496
14804
  - Check for TypeScript errors, ArkUI syntax errors, and dependency issues
14805
+ - If the build fails:
14806
+ 1. Read the error output and identify the root cause
14807
+ 2. Fix the errors in the source code, prioritizing first errors (later errors are often cascading)
14808
+ 3. Re-run the build to verify the fix
14809
+ 4. Repeat at least 3 times
14810
+ 5. If still failing after 3 attempts, report the remaining errors to the user and ask for guidance
17497
14811
  - Only after a successful build should the development cycle be considered complete
17498
14812
  `;
17499
14813
  var HM_ASCF = `
@@ -17510,7 +14824,7 @@ function buildPlanPrompt(type) {
17510
14824
  switch (type) {
17511
14825
  case "dev":
17512
14826
  return HM_DEVELOP + HM_BUILD;
17513
- case "desgin":
14827
+ case "design":
17514
14828
  return HM_DESIGN;
17515
14829
  case "build":
17516
14830
  return HM_BUILD;
@@ -17519,11 +14833,24 @@ function buildPlanPrompt(type) {
17519
14833
  case "one2many":
17520
14834
  return HM_ONE2MANY;
17521
14835
  case "all":
17522
- return HM_DESIGN + HM_DEVELOP + HM_BUILD + HM_ASCF;
14836
+ return buildAllAgentPrompt();
17523
14837
  default:
17524
14838
  return "";
17525
14839
  }
17526
14840
  }
14841
+ function buildAllAgentPrompt() {
14842
+ return `All HarmonyOS development tasks can be broadly categorized into three main phases: Design, Development, Build, and ASCF conversion. Each phase has its own set of best practices and workflows to ensure efficient and successful project completion.
14843
+ ${HM_DESIGN}
14844
+ ${HM_DEVELOP}
14845
+ ${HM_BUILD}
14846
+ ${HM_ASCF}
14847
+
14848
+ Follow these workflows:
14849
+ - **New project (greenfield)**: PRD Design \u2192 Development \u2192 Build.
14850
+ - **Incremental development (complex)**: Explore the project first \u2192 Use Plan Agent to list a plan \u2192 Discuss plan details with the user \u2192 Development \u2192 Build.
14851
+ - **Incremental development (simple)**: Development \u2192 Build directly.
14852
+ - **WeChat mini-program conversion**: ASCF Phase \u2192 Development \u2192 Build.`;
14853
+ }
17527
14854
  function buildHmExploreSubAgentPrompt() {
17528
14855
  return `
17529
14856
  You are a HarmonyOS project file search specialist. You excel at thoroughly navigating and exploring codebases.
@@ -17548,21 +14875,23 @@ function buildHmExploreSubAgentPrompt() {
17548
14875
  `;
17549
14876
  }
17550
14877
  function buildHmAgentPrompt(type) {
17551
- return `You are HarmonyOS Dev Assistant(HDACode), the best coding agent on the planet.
14878
+ return `You are HarmonyOS Dev Assistant(HDACode), an expert coding agent specialized in HarmonyOS development.
17552
14879
 
17553
14880
  You are an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.
17554
14881
 
17555
14882
  IMPORTANT: You must NEVER generate or guess URLs for the user unless you are confident that the URLs are for helping the user with programming. You may use URLs provided by the user in their messages or local files.
17556
14883
 
17557
- When the user directly asks about HDACode (eg. "can HDACode do...", "does HDACode have..."), or asks in second person (eg. "are you able...", "can you do..."), or asks how to use a specific HDACode feature (eg. implement a hook, write a slash command, or install an MCP server), use the WebFetch tool to gather information to answer the question from HDACode docs.
14884
+ When the user directly asks about HDACode (eg. "can HDACode do...", "does HDACode have..."), or asks in second person (eg. "are you able...", "can you do..."), or asks how to use a specific HDACode feature (eg. implement a hook, write a slash command, or install an MCP server), use the WebFetch tool to gather information to answer the question from HDACode docs.
17558
14885
 
17559
- **IMPORTANT**: All HarmonyOS development tasks must follow this workflow:
14886
+ **IMPORTANT**: All HarmonyOS development tasks must follow these workflows:
17560
14887
 
17561
14888
  ${buildPlanPrompt(type)}
17562
14889
 
17563
14890
  # Tone and style
17564
14891
  - Only use emojis if the user explicitly requests it. Avoid using emojis in all communication unless asked.
17565
- - Your output will be displayed on a command line interface. Your responses should be short and concise. You can use GitHub-flavored markdown for formatting, and will be rendered in a monospace font using the CommonMark specification.
14892
+ - Unless the user specifies a language, reply in the user's language; code encoding content is excluded from this rule.
14893
+ - Your output will be displayed on a command line interface. You can use GitHub-flavored markdown for formatting, and will be rendered in a monospace font using the CommonMark specification.
14894
+ - Keep your responses brief and direct. Lead with the answer or action, not the reasoning. Skip preamble and postamble (e.g., "The answer is...", "Based on the information provided..."). Only elaborate when the user asks for detail.
17566
14895
  - Output text to communicate with the user; all text you output outside of tool use is displayed to the user. Only use tools to complete tasks. Never use tools like Bash or code comments as means to communicate with the user during the session.
17567
14896
  - NEVER create files unless they're absolutely necessary for achieving your goal. ALWAYS prefer editing an existing file to creating a new one. This includes markdown files.
17568
14897
 
@@ -17618,11 +14947,22 @@ I've found some existing telemetry code. Let me mark the first todo as in_progre
17618
14947
 
17619
14948
  # Doing tasks
17620
14949
  The user will primarily request you perform software engineering tasks. This includes solving bugs, adding new functionality, refactoring code, explaining code, and more. For these tasks the following steps are recommended:
17621
- -
17622
14950
  - Use the TodoWrite tool to plan the task if required
17623
-
17624
14951
  - Tool results and user messages may include <system-reminder> tags. <system-reminder> tags contain useful information and reminders. They are automatically added by the system, and bear no direct relation to the specific tool results or user messages in which they appear.
17625
14952
 
14953
+ # Avoid over-engineering
14954
+ Only make changes that are directly requested or clearly necessary. Keep solutions simple and focused:
14955
+ - Don't add features, refactor code, or make "improvements" beyond what was asked. A bug fix doesn't need surrounding code cleaned up. A simple feature doesn't need extra configurability.
14956
+ - Don't add docstrings, comments, or type annotations to code you didn't change. Only add comments where the logic isn't self-evident.
14957
+ - Don't add error handling, fallbacks, or validation for scenarios that can't happen. Trust internal code and framework guarantees. Only validate at system boundaries (user input, external APIs).
14958
+ - Don't create helpers, utilities, or abstractions for one-time operations. Don't design for hypothetical future requirements. Three similar lines of code are better than a premature abstraction.
14959
+
14960
+ # Executing actions with care
14961
+ Carefully consider the reversibility and blast radius of actions:
14962
+ - Freely take local, reversible actions like editing files or running builds.
14963
+ - For hard-to-reverse or destructive actions, ask the user before proceeding. This includes: deleting files or branches, running rm -rf, overwriting uncommitted changes, force-pushing, dropping database tables.
14964
+ - If your approach is blocked, do not brute-force. Investigate root causes and consider alternative approaches instead of retrying the same failing action.
14965
+ - When encountering unknown files, branches, or configuration, investigate before deleting or overwriting \u2014 they may represent the user's in-progress work.
17626
14966
 
17627
14967
  # Tool usage policy
17628
14968
  - When doing file search, prefer to use the Task tool in order to reduce context usage.
@@ -17756,10 +15096,10 @@ function createHmExploreSubAgent() {
17756
15096
  "bash": "allow",
17757
15097
  "read": "allow",
17758
15098
  "edit": {
17759
- ".harmonyos/codebase.md": "allow"
15099
+ "*.harmonyos/codebase.md": "allow"
17760
15100
  },
17761
15101
  "write": {
17762
- ".harmonyos/codebase.md": "allow"
15102
+ "*.harmonyos/codebase.md": "allow"
17763
15103
  }
17764
15104
  },
17765
15105
  metadata: void 0
@@ -17981,10 +15321,13 @@ function createConfigHandler(_pluginConfig, agent) {
17981
15321
  config4.agent[id] = pluginAgentConfig;
17982
15322
  }
17983
15323
  }
17984
- config4.agent.build = { "disable": true };
17985
- config4.agent.plan = { "disable": true };
17986
15324
  config4.default_agent = "harmonyos-plugin";
17987
15325
  }
15326
+ config4.command = config4.command || {};
15327
+ config4.command["harmony-development-env-check"] = {
15328
+ template: "/harmony-development-env-check",
15329
+ description: "\u68C0\u67E5 HarmonyOS \u5F00\u53D1\u73AF\u5883\u914D\u7F6E\uFF08Node.js\u3001JDK\u3001ohpm\u3001hvigor\u3001DevEco SDK\uFF09"
15330
+ };
17988
15331
  log("Config merged", config4.agent);
17989
15332
  };
17990
15333
  }
@@ -18046,9 +15389,6 @@ var ToolRegistry = class {
18046
15389
  }
18047
15390
  };
18048
15391
 
18049
- // src/tools/create-template/create-template-tool.ts
18050
- import fs4 from "fs";
18051
-
18052
15392
  // node_modules/@opencode-ai/plugin/node_modules/zod/v4/classic/external.js
18053
15393
  var external_exports2 = {};
18054
15394
  __export(external_exports2, {
@@ -18780,10 +16120,10 @@ function mergeDefs2(...defs) {
18780
16120
  function cloneDef2(schema) {
18781
16121
  return mergeDefs2(schema._zod.def);
18782
16122
  }
18783
- function getElementAtPath2(obj, path6) {
18784
- if (!path6)
16123
+ function getElementAtPath2(obj, path7) {
16124
+ if (!path7)
18785
16125
  return obj;
18786
- return path6.reduce((acc, key) => acc?.[key], obj);
16126
+ return path7.reduce((acc, key) => acc?.[key], obj);
18787
16127
  }
18788
16128
  function promiseAllObject2(promisesObj) {
18789
16129
  const keys = Object.keys(promisesObj);
@@ -19144,11 +16484,11 @@ function aborted2(x, startIndex = 0) {
19144
16484
  }
19145
16485
  return false;
19146
16486
  }
19147
- function prefixIssues2(path6, issues) {
16487
+ function prefixIssues2(path7, issues) {
19148
16488
  return issues.map((iss) => {
19149
16489
  var _a2;
19150
16490
  (_a2 = iss).path ?? (_a2.path = []);
19151
- iss.path.unshift(path6);
16491
+ iss.path.unshift(path7);
19152
16492
  return iss;
19153
16493
  });
19154
16494
  }
@@ -19316,7 +16656,7 @@ function treeifyError2(error92, _mapper) {
19316
16656
  return issue3.message;
19317
16657
  };
19318
16658
  const result = { errors: [] };
19319
- const processError = (error93, path6 = []) => {
16659
+ const processError = (error93, path7 = []) => {
19320
16660
  var _a2, _b;
19321
16661
  for (const issue3 of error93.issues) {
19322
16662
  if (issue3.code === "invalid_union" && issue3.errors.length) {
@@ -19326,7 +16666,7 @@ function treeifyError2(error92, _mapper) {
19326
16666
  } else if (issue3.code === "invalid_element") {
19327
16667
  processError({ issues: issue3.issues }, issue3.path);
19328
16668
  } else {
19329
- const fullpath = [...path6, ...issue3.path];
16669
+ const fullpath = [...path7, ...issue3.path];
19330
16670
  if (fullpath.length === 0) {
19331
16671
  result.errors.push(mapper(issue3));
19332
16672
  continue;
@@ -19358,8 +16698,8 @@ function treeifyError2(error92, _mapper) {
19358
16698
  }
19359
16699
  function toDotPath2(_path) {
19360
16700
  const segs = [];
19361
- const path6 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
19362
- for (const seg of path6) {
16701
+ const path7 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
16702
+ for (const seg of path7) {
19363
16703
  if (typeof seg === "number")
19364
16704
  segs.push(`[${seg}]`);
19365
16705
  else if (typeof seg === "symbol")
@@ -30471,49 +27811,111 @@ function tool(input) {
30471
27811
  }
30472
27812
  tool.schema = external_exports2;
30473
27813
 
30474
- // src/tools/create-template/create-template-tool.ts
30475
- import path5 from "path";
30476
-
30477
27814
  // src/tools/create-template/download-template.ts
27815
+ import { cpSync, mkdirSync } from "fs";
27816
+ import path6 from "path";
27817
+ import { fileURLToPath } from "url";
27818
+
27819
+ // src/tools/create-template/sdk-detector.ts
30478
27820
  import fs3 from "fs";
30479
27821
  import path4 from "path";
27822
+ function findSdkDir() {
27823
+ const envSdkDir = process.env.DEVECO_SDK_HOME;
27824
+ if (envSdkDir) {
27825
+ return envSdkDir;
27826
+ }
27827
+ if (process.platform === "win32") {
27828
+ return "C:/Program Files/Huawei/DevEco Studio/sdk";
27829
+ }
27830
+ if (process.platform === "darwin") {
27831
+ return "/Applications/DevEco-Studio.app/Contents/sdk";
27832
+ }
27833
+ return "";
27834
+ }
27835
+ function readSdkVersionFromPkg(sdkDir) {
27836
+ const sdkPkgPath = path4.join(sdkDir, "default", "sdk-pkg.json");
27837
+ if (!fs3.existsSync(sdkPkgPath)) {
27838
+ return null;
27839
+ }
27840
+ try {
27841
+ const content = fs3.readFileSync(sdkPkgPath, "utf-8");
27842
+ const pkg = JSON.parse(content);
27843
+ return {
27844
+ platformVersion: pkg.data?.platformVersion ?? "",
27845
+ apiVersion: pkg.data?.apiVersion ?? ""
27846
+ };
27847
+ } catch {
27848
+ return null;
27849
+ }
27850
+ }
27851
+ function getSdkVersion() {
27852
+ const sdkDir = findSdkDir();
27853
+ return readSdkVersionFromPkg(sdkDir);
27854
+ }
27855
+
27856
+ // src/tools/create-template/config-modifier.ts
27857
+ import fs4 from "fs";
27858
+ import path5 from "path";
27859
+ function replaceJson5Field(content, field, newValue) {
27860
+ const regex = new RegExp(`("${field}"\\s*:\\s*)"[^"]*"`, "g");
27861
+ return content.replace(regex, `$1"${newValue}"`);
27862
+ }
27863
+ function buildSdkVersionString(sdkInfo) {
27864
+ return `${sdkInfo.platformVersion}(${sdkInfo.apiVersion})`;
27865
+ }
27866
+ function modifyTemplateConfig(projectRoot, sdkInfo) {
27867
+ const versionStr = buildSdkVersionString(sdkInfo);
27868
+ const buildProfilePath = path5.join(projectRoot, "build-profile.json5");
27869
+ if (fs4.existsSync(buildProfilePath)) {
27870
+ let content = fs4.readFileSync(buildProfilePath, "utf-8");
27871
+ content = replaceJson5Field(content, "targetSdkVersion", versionStr);
27872
+ content = replaceJson5Field(content, "compatibleSdkVersion", versionStr);
27873
+ fs4.writeFileSync(buildProfilePath, content, "utf-8");
27874
+ }
27875
+ const ohPackagePath = path5.join(projectRoot, "oh-package.json5");
27876
+ if (fs4.existsSync(ohPackagePath)) {
27877
+ let content = fs4.readFileSync(ohPackagePath, "utf-8");
27878
+ content = replaceJson5Field(content, "modelVersion", sdkInfo.platformVersion);
27879
+ fs4.writeFileSync(ohPackagePath, content, "utf-8");
27880
+ }
27881
+ const hvigorConfigPath = path5.join(projectRoot, "hvigor", "hvigor-config.json5");
27882
+ if (fs4.existsSync(hvigorConfigPath)) {
27883
+ let content = fs4.readFileSync(hvigorConfigPath, "utf-8");
27884
+ content = replaceJson5Field(content, "modelVersion", sdkInfo.platformVersion);
27885
+ fs4.writeFileSync(hvigorConfigPath, content, "utf-8");
27886
+ }
27887
+ }
27888
+
27889
+ // src/tools/create-template/download-template.ts
27890
+ var __dirname = path6.dirname(fileURLToPath(import.meta.url));
30480
27891
  var TEMPLATE_MAP = {
30481
- "unknown": "https://agc-storage-drcn.platform.dbankcloud.cn/v0/third-u6pwh/template%2Funknown.zip?token=72baa676-fa23-42c3-9bfa-5227bf9a62cf",
30482
- "application": "https://agc-storage-drcn.platform.dbankcloud.cn/v0/third-u6pwh/template%2Fapplication.zip?token=f8cc9226-3672-44cc-be14-a985fc562e6c",
30483
- "atomic": "https://agc-storage-drcn.platform.dbankcloud.cn/v0/third-u6pwh/template%2Fatomic.zip?token=7e1c032d-feaa-42a0-912b-36a2302a96e4",
30484
- "module": "https://agc-storage-drcn.platform.dbankcloud.cn/v0/third-u6pwh/template%2Fmodule.zip?token=bf5d0d67-e97d-4e14-9e54-91aa2fe9ee09"
27892
+ application: "application",
27893
+ atomic: "atomic",
27894
+ module: "module"
30485
27895
  };
30486
27896
  async function downloadTemplate(mode, filePath) {
30487
- const url3 = TEMPLATE_MAP[mode];
30488
- if (!url3) {
30489
- throw new Error(`Unknown domain: ${mode}. Available domains: ${Object.keys(TEMPLATE_MAP).join(", ")}`);
30490
- }
30491
- const targetDir = path4.resolve(filePath);
30492
- if (!fs3.existsSync(targetDir)) {
30493
- fs3.mkdirSync(targetDir, { recursive: true });
27897
+ const templateType = TEMPLATE_MAP[mode];
27898
+ if (!templateType) {
27899
+ throw new Error(
27900
+ `Unknown template type: ${mode}. Available types: ${Object.keys(TEMPLATE_MAP).join(", ")}`
27901
+ );
30494
27902
  }
30495
- const response = await fetch(url3);
30496
- if (!response.ok) {
30497
- throw new Error(`Failed to download template: ${response.status} ${response.statusText}`);
27903
+ const targetDir = path6.resolve(filePath);
27904
+ const templateDir = path6.join(__dirname, "templates", templateType);
27905
+ mkdirSync(targetDir, { recursive: true });
27906
+ cpSync(templateDir, targetDir, { recursive: true });
27907
+ const sdkInfo = getSdkVersion();
27908
+ if (sdkInfo) {
27909
+ modifyTemplateConfig(targetDir, sdkInfo);
30498
27910
  }
30499
- const tempZipPath = path4.join(targetDir, `template-${mode}.zip`);
30500
- const arrayBuffer = await response.arrayBuffer();
30501
- fs3.writeFileSync(tempZipPath, Buffer.from(arrayBuffer));
30502
- await extractZip(tempZipPath, targetDir);
30503
- fs3.unlinkSync(tempZipPath);
30504
- }
30505
- async function extractZip(zipPath, targetDir) {
30506
- const { default: AdmZip } = await Promise.resolve().then(() => __toESM(require_adm_zip(), 1));
30507
- const zip = new AdmZip(zipPath);
30508
- zip.extractAllTo(targetDir, true);
30509
27911
  }
30510
27912
 
30511
27913
  // src/tools/create-template/create-template-tool.ts
30512
27914
  var createHmTemplate = tool({
30513
- description: "create harmonyos empty template support applicaiton, module, atomic",
27915
+ description: "Create an empty HarmonyOS project template. Supports three modes: 'application' (full app), 'module' (sub-module), 'atomic' (atomic service). Downloads and extracts the template to the specified directory.",
30514
27916
  args: {
30515
- filePath: tool.schema.string(),
30516
- mode: tool.schema.string("mode support applicaiton(\u5E94\u7528), module(\u6A21\u5757), atomic(\u5143\u670D\u52A1)")
27917
+ filePath: tool.schema.string("Absolute path of the target directory where the template will be created"),
27918
+ mode: tool.schema.string("Template type: 'application' (\u5E94\u7528), 'module' (\u6A21\u5757), or 'atomic' (\u5143\u670D\u52A1)")
30517
27919
  },
30518
27920
  execute: async (args, context) => {
30519
27921
  try {
@@ -30551,7 +27953,7 @@ function processHvigorwCompileInfo(input, output) {
30551
27953
  if (!command.includes("hvigorw")) return;
30552
27954
  const rawLog = (typeof output.metadata?.output === "string" ? output.metadata.output : "") || output.output;
30553
27955
  if (!rawLog) return;
30554
- if (rawLog.includes("BUILD SUCCESSFUL in")) {
27956
+ if (rawLog.includes("BUILD SUCCESSFUL in") && !rawLog.includes("BUILD FAILED")) {
30555
27957
  const match = rawLog.match(/BUILD SUCCESSFUL in .+/);
30556
27958
  output.output = match ? stripAnsi(match[0]) : "BUILD SUCCESSFUL";
30557
27959
  return;
@@ -30576,6 +27978,53 @@ function createToolHooks() {
30576
27978
  };
30577
27979
  }
30578
27980
 
27981
+ // src/commands/env-check.ts
27982
+ import { execSync } from "child_process";
27983
+ function runEnvCheck() {
27984
+ const checks = [
27985
+ { name: "Java", cmd: "java -version" },
27986
+ { name: "Node.js", cmd: "node -v" },
27987
+ { name: "ohpm", cmd: "ohpm -v" },
27988
+ { name: "hvigorw", cmd: "hvigorw -v" }
27989
+ ];
27990
+ const lines = [];
27991
+ lines.push("HarmonyOS Development Environment Check\uFF1A");
27992
+ for (const check3 of checks) {
27993
+ try {
27994
+ const output = execSync(`${check3.cmd} 2>&1`, { timeout: 1e4, encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
27995
+ const firstLine = output.split(/\r?\n/)[0]?.trim() || "";
27996
+ lines.push(`[${check3.name}] ${firstLine}`);
27997
+ } catch (err) {
27998
+ lines.push(`[${check3.name}] NOT FOUND`);
27999
+ }
28000
+ }
28001
+ const sdkHome = process.env.DEVECO_SDK_HOME;
28002
+ lines.push(`[DEVECO_SDK_HOME] ${sdkHome ?? "NOT SET"}`);
28003
+ return lines.join("\n\n");
28004
+ }
28005
+
28006
+ // src/hooks/command-hooks.ts
28007
+ var ENV_CHECK_COMMAND = "harmony-development-env-check";
28008
+ function createCommandHooks(ctx) {
28009
+ return {
28010
+ "command.execute.before": async (input, output) => {
28011
+ if (input.command === ENV_CHECK_COMMAND) {
28012
+ log("Running env check command", { sessionID: input.sessionID });
28013
+ const result = runEnvCheck();
28014
+ log("Run env check command", result);
28015
+ await ctx.client.session.prompt({
28016
+ body: {
28017
+ parts: [{ type: "text", text: result, ignored: true }],
28018
+ noReply: true
28019
+ },
28020
+ path: { id: input.sessionID }
28021
+ });
28022
+ throw new Error("check env finished");
28023
+ }
28024
+ }
28025
+ };
28026
+ }
28027
+
30579
28028
  // src/hooks/chat-params.ts
30580
28029
  function createChatParamsHandler(config4) {
30581
28030
  return async (input, output) => {
@@ -30598,9 +28047,20 @@ function createHooks(args) {
30598
28047
  const isHookEnabled = (name) => !disabledHooks.has(name);
30599
28048
  log("Creating hooks", { disabledCount: disabledHooks.size });
30600
28049
  const hooks = {};
30601
- Object.assign(hooks, createToolHooks());
30602
- hooks["chat.params"] = createChatParamsHandler(config4);
30603
- hooks["chat.message"] = createChatMessageHandler(ctx, managers);
28050
+ const toolHooks = createToolHooks();
28051
+ const commandHooks = createCommandHooks(ctx);
28052
+ const registrations = [
28053
+ ["tool.execute.before", () => toolHooks["tool.execute.before"]],
28054
+ ["tool.execute.after", () => toolHooks["tool.execute.after"]],
28055
+ ["command.execute.before", () => commandHooks["command.execute.before"]],
28056
+ ["chat.params", () => createChatParamsHandler(config4)],
28057
+ ["chat.message", () => createChatMessageHandler(ctx, managers)]
28058
+ ];
28059
+ for (const [key, factory] of registrations) {
28060
+ if (factory && isHookEnabled(key)) {
28061
+ hooks[key] = factory();
28062
+ }
28063
+ }
30604
28064
  return hooks;
30605
28065
  }
30606
28066